diff --git a/examples/web-chat/CHANGELOG.md b/examples/web-chat/CHANGELOG.md index f71bc8f..997d71a 100644 --- a/examples/web-chat/CHANGELOG.md +++ b/examples/web-chat/CHANGELOG.md @@ -1,5 +1,12 @@ # @smooai/smooth-operator-web-chat-example +## 0.0.5 + +### Patch Changes + +- Updated dependencies + - @smooai/smooth-operator@1.22.12 + ## 0.0.4 ### Patch Changes diff --git a/examples/web-chat/package.json b/examples/web-chat/package.json index d858c2d..7aeb6b8 100644 --- a/examples/web-chat/package.json +++ b/examples/web-chat/package.json @@ -1,6 +1,6 @@ { "name": "@smooai/smooth-operator-web-chat-example", - "version": "0.0.4", + "version": "0.0.5", "private": true, "description": "A smooth-web-like Vite + React chat client that drives a running smooth-operator server over its WebSocket protocol — token streaming, inline tool-call/result blocks, a conversation sidebar, and oldest-first history, all on top of the published @smooai/smooth-operator SDK.", "type": "module", diff --git a/go/version.go b/go/version.go index 052b679..d257d1c 100644 --- a/go/version.go +++ b/go/version.go @@ -5,4 +5,4 @@ package e2e // language artifacts. The real Go "publish" is a git tag (go/v); this // constant is the anchor that scripts/sync-versions.mjs keeps in sync with the // canonical npm version on every changeset release. -const Version = "1.22.11" +const Version = "1.22.12" diff --git a/python/pyproject.toml b/python/pyproject.toml index 8315ca6..5c9fd9e 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "smooai-smooth-operator" -version = "1.22.11" +version = "1.22.12" description = "Python protocol types and native async WebSocket client for the smooth-operator protocol. Generated from the language-neutral JSON Schemas in spec/." readme = "README.md" license = { text = "MIT" } diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 7d2e1b3..db926e7 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -3974,7 +3974,7 @@ checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "smooai-smooth-operator" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-trait", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-adapter-backplane-nats" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-nats", @@ -4022,7 +4022,7 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-adapter-backplane-redis" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-trait", @@ -4038,7 +4038,7 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-adapter-dynamodb" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-trait", @@ -4059,7 +4059,7 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-adapter-memory" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-trait", @@ -4072,7 +4072,7 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-adapter-postgres" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-trait", @@ -4093,9 +4093,9 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-core" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46339a69d4d8d2b7eda66ebdb1151a4d56bc3c3410f61576120f0fa2e17bc76" +checksum = "d04127c32b5bd73ebb0c85084bfe36a2f203c94a7cda919a21f44769fbbc1495" dependencies = [ "anyhow", "async-trait", @@ -4163,7 +4163,7 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-ingestion" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-trait", @@ -4210,7 +4210,7 @@ dependencies = [ [[package]] name = "smooai-smooth-operator-server" -version = "1.22.11" +version = "1.22.12" dependencies = [ "anyhow", "async-trait", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 46c2f01..849f7fd 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -29,11 +29,11 @@ repository = "https://github.com/SmooAI/smooth-operator" # external `cargo build` resolve the broken 0.16.0 and fail to compile. Pin the # floor at 0.16.1. (The prior `git`/`rev = d03fa10` pin was a stopgap for exactly # that unpublished-API gap, now closed.) -smooai-smooth-operator-core = "0.16.1" +smooai-smooth-operator-core = "0.16.2" # Intra-workspace dep on the reference lib carries its version so the adapters / # ingestion / server that depend on it are publishable (path = local dev, # version = the crates.io requirement). -smooth-operator = { package = "smooai-smooth-operator", path = "smooth-operator", version = "1.22.11" } +smooth-operator = { package = "smooai-smooth-operator", path = "smooth-operator", version = "1.22.12" } async-trait = "0.1" anyhow = "1" diff --git a/rust/adapters/backplane-nats/Cargo.toml b/rust/adapters/backplane-nats/Cargo.toml index b3c03cc..85029ac 100644 --- a/rust/adapters/backplane-nats/Cargo.toml +++ b/rust/adapters/backplane-nats/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator-adapter-backplane-nats" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true diff --git a/rust/adapters/backplane-redis/Cargo.toml b/rust/adapters/backplane-redis/Cargo.toml index 1400be9..9d48f8a 100644 --- a/rust/adapters/backplane-redis/Cargo.toml +++ b/rust/adapters/backplane-redis/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator-adapter-backplane-redis" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true diff --git a/rust/adapters/dynamodb/Cargo.toml b/rust/adapters/dynamodb/Cargo.toml index c13f0ef..dd7b14a 100644 --- a/rust/adapters/dynamodb/Cargo.toml +++ b/rust/adapters/dynamodb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator-adapter-dynamodb" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true @@ -19,7 +19,7 @@ s3-vectors = ["dep:aws-sdk-s3vectors", "dep:aws-smithy-types"] smooth-operator = { workspace = true } smooai-smooth-operator-core = { workspace = true } # IndexingStore / IndexingRun for the persistent admin indexing-runs store. -smooai-smooth-operator-ingestion = { path = "../../ingestion", version = "1.22.11" } +smooai-smooth-operator-ingestion = { path = "../../ingestion", version = "1.22.12" } async-trait = { workspace = true } anyhow = { workspace = true } chrono = { workspace = true } diff --git a/rust/adapters/in-memory/Cargo.toml b/rust/adapters/in-memory/Cargo.toml index dd437e1..7bcc70b 100644 --- a/rust/adapters/in-memory/Cargo.toml +++ b/rust/adapters/in-memory/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator-adapter-memory" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true diff --git a/rust/adapters/postgres/Cargo.toml b/rust/adapters/postgres/Cargo.toml index 7e996a2..f2737dc 100644 --- a/rust/adapters/postgres/Cargo.toml +++ b/rust/adapters/postgres/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator-adapter-postgres" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true @@ -15,7 +15,7 @@ smooth-operator = { workspace = true } # `postgres` feature pulls in PostgresCheckpointStore (sync r2d2 path). smooai-smooth-operator-core = { workspace = true, features = ["postgres"] } # IndexingStore / IndexingRun for the persistent admin indexing-runs store. -smooai-smooth-operator-ingestion = { path = "../../ingestion", version = "1.22.11" } +smooai-smooth-operator-ingestion = { path = "../../ingestion", version = "1.22.12" } async-trait = { workspace = true } anyhow = { workspace = true } chrono = { workspace = true } diff --git a/rust/ingestion/Cargo.toml b/rust/ingestion/Cargo.toml index e47a75e..2435b1e 100644 --- a/rust/ingestion/Cargo.toml +++ b/rust/ingestion/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator-ingestion" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true diff --git a/rust/smooth-operator-server/Cargo.toml b/rust/smooth-operator-server/Cargo.toml index 9542705..48d2512 100644 --- a/rust/smooth-operator-server/Cargo.toml +++ b/rust/smooth-operator-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator-server" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true @@ -35,22 +35,22 @@ smooth-operator = { workspace = true } smooai-smooth-operator-core = { workspace = true } # In-memory storage + backplane — ALWAYS included. The local-flavor default and # the lean (`--no-default-features`) build run entirely on these. -smooai-smooth-operator-adapter-memory = { path = "../adapters/in-memory", version = "1.22.11" } +smooai-smooth-operator-adapter-memory = { path = "../adapters/in-memory", version = "1.22.12" } # Persistent storage + admin-store backends, selected at runtime to match the # configured storage backend (Postgres / DynamoDB; default in-memory). Optional: # gated behind the `postgres` / `dynamodb` features so a lean local/embed build # can exclude tokio-postgres / the AWS SDK. The `postgres` crate also provides the # gateway-backed embedder/reranker, so the `postgres` feature additionally enables # the semantic-retrieval path in `embedder.rs` / `reranker.rs`. -smooai-smooth-operator-adapter-postgres = { path = "../adapters/postgres", version = "1.22.11", optional = true } -smooai-smooth-operator-adapter-dynamodb = { path = "../adapters/dynamodb", version = "1.22.11", optional = true } +smooai-smooth-operator-adapter-postgres = { path = "../adapters/postgres", version = "1.22.12", optional = true } +smooai-smooth-operator-adapter-dynamodb = { path = "../adapters/dynamodb", version = "1.22.12", optional = true } # Distributed Backplane backends for horizontal scale-out, selected at runtime # via SMOOTH_AGENT_BACKPLANE (default in-memory / single-process). Optional: gated # behind the `redis` / `nats` features so a lean build excludes their drivers. -smooai-smooth-operator-adapter-backplane-redis = { path = "../adapters/backplane-redis", version = "1.22.11", optional = true } -smooai-smooth-operator-adapter-backplane-nats = { path = "../adapters/backplane-nats", version = "1.22.11", optional = true } +smooai-smooth-operator-adapter-backplane-redis = { path = "../adapters/backplane-redis", version = "1.22.12", optional = true } +smooai-smooth-operator-adapter-backplane-nats = { path = "../adapters/backplane-nats", version = "1.22.12", optional = true } # Admin API surfaces indexing-run status via the ingestion crate's IndexingStore. -smooai-smooth-operator-ingestion = { path = "../ingestion", version = "1.22.11" } +smooai-smooth-operator-ingestion = { path = "../ingestion", version = "1.22.12" } async-trait = { workspace = true } anyhow = { workspace = true } diff --git a/rust/smooth-operator-server/src/suggestions.rs b/rust/smooth-operator-server/src/suggestions.rs index 2752119..20bcec6 100644 --- a/rust/smooth-operator-server/src/suggestions.rs +++ b/rust/smooth-operator-server/src/suggestions.rs @@ -54,7 +54,14 @@ Rules: #[must_use] pub fn extract_suggested_replies(reply: &str) -> (String, Vec) { let Some(start) = reply.rfind(MARKER_OPEN) else { - return (reply.to_string(), Vec::new()); + // Some models (gpt-oss-120b) ignore the marker contract and instead end + // the reply with a markdown "Suggested replies:" list. Parse that as a + // fallback so chips still populate; otherwise leave the reply untouched. + // ponytail: responseParts is cleaned here; the raw list can still flash in + // the live token stream (MarkerSuppressor only hides ) — + // pearl th-gptoss-chips-stream if that becomes visible enough to matter. + return extract_markdown_suggested_replies(reply) + .unwrap_or_else(|| (reply.to_string(), Vec::new())); }; let after_open = start + MARKER_OPEN.len(); let (body, end) = match reply[after_open..].find(MARKER_CLOSE) { @@ -87,6 +94,70 @@ pub fn extract_suggested_replies(reply: &str) -> (String, Vec) { (clean, suggestions) } +/// Fallback for models that ignore the `` marker and instead +/// end the reply with a markdown `Suggested replies:` list (observed on +/// gpt-oss-120b, TP agent's default model). Returns the cleaned reply (list +/// stripped) + parsed items, or `None` when there is no such trailing list. +/// Conservative: fires only when a `suggested replies:` header is followed by a +/// pure bullet/numbered list to the end of the reply, so a normal list in the +/// body is never mistaken for chips. +fn extract_markdown_suggested_replies(reply: &str) -> Option<(String, Vec)> { + let (start, header_len) = ["suggested replies:", "suggested_replies:"] + .iter() + .filter_map(|h| rfind_ci(reply, h).map(|p| (p, h.len()))) + .max_by_key(|&(p, _)| p)?; + // The header must own its line — the list starts on the NEXT line. Anything + // else after the header on the same line means it's prose, not a trailer. + let after = &reply[start + header_len..]; + let nl = after.find('\n')?; + let mut items = Vec::new(); + for line in after[nl + 1..].lines() { + let t = line.trim(); + if t.is_empty() { + continue; + } + // Every non-empty line must be a bullet (-, *, •) or "N." / "N)" item; + // any prose line means this isn't a clean chip trailer. + let bulleted = t.trim_start_matches(['-', '*', '•']); + let item = if bulleted.len() < t.len() { + bulleted.trim_start() + } else if let Some(i) = t + .find(['.', ')']) + .filter(|&i| i > 0 && t[..i].bytes().all(|b| b.is_ascii_digit())) + { + t[i + 1..].trim_start() + } else { + return None; + }; + let item = item.trim().trim_matches(['"', '\'', '`']).trim(); + if item.is_empty() { + return None; + } + items.push(item.to_string()); + } + if items.is_empty() { + return None; + } + let clean = reply[..start].trim_end().to_string(); + Some((clean, items.into_iter().take(MAX_SUGGESTIONS).collect())) +} + +/// Case-insensitive `rfind` returning a byte offset into `haystack` (ASCII +/// needle ⇒ the offset is always a char boundary). Avoids allocating a +/// lowercased copy, which would desync offsets on non-ASCII text. +fn rfind_ci(haystack: &str, needle_lower: &str) -> Option { + let (hb, nb) = (haystack.as_bytes(), needle_lower.as_bytes()); + if nb.is_empty() || hb.len() < nb.len() { + return None; + } + (0..=hb.len() - nb.len()).rev().find(|&i| { + hb[i..i + nb.len()] + .iter() + .zip(nb) + .all(|(a, b)| a.eq_ignore_ascii_case(b)) + }) +} + /// Streaming hold-back so the trailer never flashes in the live token stream. /// /// Feed each token delta through [`push`](Self::push) and forward only what it @@ -194,6 +265,52 @@ mod tests { assert!(sug.is_empty(), "truncated JSON parses to nothing"); } + #[test] + fn gptoss_markdown_list_becomes_chips() { + // Real gpt-oss-120b shape: ignores the marker, ends with a quoted list. + let (clean, sug) = extract_suggested_replies( + "Could you tell me your current process maturity level?\n\nsuggested_replies:\n- \"I'm at the initial stage.\"\n- \"We have defined processes.\"\n- \"Our processes are mature.\"\n- \"Explain the maturity model?\"", + ); + assert_eq!( + clean, + "Could you tell me your current process maturity level?" + ); + assert_eq!( + sug, + vec![ + "I'm at the initial stage.", + "We have defined processes.", + "Our processes are mature.", + "Explain the maturity model?" + ] + ); + } + + #[test] + fn markdown_list_handles_numbered_and_header_casing() { + let (clean, sug) = + extract_suggested_replies("Pick one.\n\n**Suggested Replies:**\n1. Yes\n2) No"); + assert_eq!(clean, "Pick one.\n\n**"); // trailing "**" before the header is left as-is + assert_eq!(sug, vec!["Yes", "No"]); + } + + #[test] + fn markdown_fallback_ignores_a_body_list_without_the_header() { + let reply = "Here are the steps:\n- do a\n- do b"; + let (clean, sug) = extract_suggested_replies(reply); + assert_eq!(clean, reply); // no "suggested replies:" header ⇒ untouched + assert!(sug.is_empty()); + } + + #[test] + fn markdown_fallback_bails_when_header_is_followed_by_prose() { + // A header followed by a non-list line is not a clean chip trailer. + let reply = "Suggested replies: I don't have any right now."; + let (clean, sug) = extract_suggested_replies(reply); + assert_eq!(clean, reply); + assert!(sug.is_empty()); + } + #[test] fn suppressor_passes_plain_text_through() { let mut s = MarkerSuppressor::new(); diff --git a/rust/smooth-operator/Cargo.toml b/rust/smooth-operator/Cargo.toml index 93807f2..a886423 100644 --- a/rust/smooth-operator/Cargo.toml +++ b/rust/smooth-operator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smooai-smooth-operator" -version = "1.22.11" +version = "1.22.12" edition.workspace = true license.workspace = true repository.workspace = true diff --git a/typescript/CHANGELOG.md b/typescript/CHANGELOG.md index e3313bc..7720462 100644 --- a/typescript/CHANGELOG.md +++ b/typescript/CHANGELOG.md @@ -1,5 +1,20 @@ # @smooai/smooth-operator +## 1.22.12 + +### Patch Changes + +- Harden chat streaming + fix gpt-oss suggested-reply chips. + + - `chat_stream` now retries retryable HTTP statuses (429/5xx) before reading any + stream bytes, mirroring the non-streaming `chat()` path. A transient gateway + 5xx (groq/LiteLLM 502/503) previously propagated as an `AGENT_ERROR` and the + chat widget rendered an empty reply. Bumps the core dep to 0.16.2 (where the + retry lives). + - `extract_suggested_replies` now also parses a trailing markdown + `Suggested replies:` list, so models that ignore the `` + marker (gpt-oss-120b) still populate chips. + ## 1.22.11 ### Patch Changes diff --git a/typescript/package.json b/typescript/package.json index f24128a..4534af4 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@smooai/smooth-operator", - "version": "1.22.11", + "version": "1.22.12", "description": "TypeScript SDK for the smooth-operator WebSocket protocol: the native client (`.`), React bindings (`./react`), and the embeddable web-component chat widget (`./widget`). Generated from the language-neutral JSON Schemas in spec/.", "license": "MIT", "type": "module",