@happyvertical/smrt-chat 0.57.32 → 0.57.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/AGENTS.md +1 -1
  2. package/agents/tool-loop.md +224 -0
  3. package/dist/assistant-turn-events.d.ts +10 -1
  4. package/dist/assistant-turn-events.d.ts.map +1 -1
  5. package/dist/assistant-turn.d.ts +42 -5
  6. package/dist/assistant-turn.d.ts.map +1 -1
  7. package/dist/chat-stream.d.ts +15 -0
  8. package/dist/chat-stream.d.ts.map +1 -1
  9. package/dist/chunks/{ChatService-DjGf2AoJ.js → ChatService-D0XuiCTk.js} +3 -2
  10. package/dist/chunks/ChatService-D0XuiCTk.js.map +1 -0
  11. package/dist/chunks/assistant-turn-events-BbZUf-Ju.js.map +1 -1
  12. package/dist/chunks/{chat-stream-DJuup0go.js → chat-stream-CsD8FwnS.js} +552 -77
  13. package/dist/chunks/chat-stream-CsD8FwnS.js.map +1 -0
  14. package/dist/data-surface-tools.d.ts +1 -1
  15. package/dist/data-surface-tools.d.ts.map +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +9 -5
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal/agent-runtime.js +1 -1
  21. package/dist/manifest.json +1 -1
  22. package/dist/persona-conversation.d.ts +41 -1
  23. package/dist/persona-conversation.d.ts.map +1 -1
  24. package/dist/services/ChatService.d.ts +6 -0
  25. package/dist/services/ChatService.d.ts.map +1 -1
  26. package/dist/smrt-knowledge.json +11 -6
  27. package/dist/svelte/components/assistant/assistant-http-client.d.ts +7 -0
  28. package/dist/svelte/components/assistant/assistant-http-client.d.ts.map +1 -1
  29. package/dist/svelte/components/assistant/assistant-http-client.js +8 -0
  30. package/dist/svelte/components/assistant/assistant-transport.d.ts.map +1 -1
  31. package/dist/svelte/components/assistant/assistant-transport.js +3 -0
  32. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts.map +1 -1
  33. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.js +10 -4
  34. package/dist/sveltekit.d.ts +26 -0
  35. package/dist/sveltekit.d.ts.map +1 -1
  36. package/dist/sveltekit.js +27 -10
  37. package/dist/sveltekit.js.map +1 -1
  38. package/dist/tool-loop.d.ts +223 -2
  39. package/dist/tool-loop.d.ts.map +1 -1
  40. package/dist/voice.d.ts.map +1 -1
  41. package/package.json +17 -18
  42. package/dist/chunks/ChatService-DjGf2AoJ.js.map +0 -1
  43. package/dist/chunks/chat-stream-DJuup0go.js.map +0 -1
package/AGENTS.md CHANGED
@@ -150,7 +150,7 @@ The host opens a page per `PrincipalRun` (smrt-svelte's
150
150
  The `AgentSession` runtime depends on personas, agents, and users. Keep those
151
151
  edges acyclic: none of those packages may depend back on chat.
152
152
 
153
- - **`runToolLoop(options)`** (`tool-loop.ts`) — a bounded `tool_call → observe → respond` loop. Tools are **manifest operations** of installed packages: `buildManifestToolCatalog({ allowedTools })` reads the `PermissionCatalogService` catalog and keeps only the `(collection, action)` entries named in the persona's allow-list (the **offer gate**; absent/empty ⇒ NO tools). The loop runs inside one `executeAsPrincipal` context, and `invokeManifestTool` executes each op **in-process ("side door")** against `run.context.database` (the RLS tx when Postgres RLS is on), after re-asserting the fail-closed allow-list (`run.assertToolAllowed`) AND the catalog permission (`run.assertOperation`) — the **execution gate**. Bounded by a max-steps ceiling (`DEFAULT_MAX_STEPS = 8`): on the ceiling it disables tools for one final completion so the turn always terminates with text. A thrown tool error is classified (`classifyToolError`): permission denials and 401/403 are `not_permitted`; a `ValidationError` or 400/404/409/422 is `invalid_request` (observation: actionable message, `publicMessage` first, `code`, fix-and-retry hint); else (incl. 429) `execution_error`.
153
+ - **`runToolLoop(options)`** (`tool-loop.ts`) — a bounded `tool_call → observe → respond` loop. Tools are **manifest operations** of installed packages: `buildManifestToolCatalog({ allowedTools })` reads the `PermissionCatalogService` catalog and keeps only the `(collection, action)` entries named in the persona's allow-list (the **offer gate**; absent/empty ⇒ NO tools). The loop runs inside one `executeAsPrincipal` context, and `invokeManifestTool` executes each op **in-process ("side door")** against `run.context.database` (the RLS tx when Postgres RLS is on), after re-asserting the fail-closed allow-list (`run.assertToolAllowed`) AND the catalog permission (`run.assertOperation`) — the **execution gate**. Bounded by `DEFAULT_MAX_STEPS = 8`, an optional token budget and a deadline. Termination, the forced final call, observation caps, argument validation and tool-error classification: [agents/tool-loop.md](agents/tool-loop.md).
154
154
  - **`runPersonaConversationTurn(options)`** (`persona-conversation.ts`) — binds a conversation to an `AgentPersona`/`ResolvedPersona`: runs as its principal (`runAsUserId`), offers only its `allowedTools`, speaks its instructions (`resolvePersonaInstructions`, layering approved learned directives), and injects its **recalled learning memory** (`personaLearningMemory`, isolated per `memoryScope`) into the system prompt. `bindPersonaToSession()` mirrors the persona's `allowedTools`/instructions onto the `AgentSession` so the chat authoring gate agrees with the loop's offer gate. Authors the reply (and each executed tool) via the internal `sendAgentReply` bridge. Tools run with the run-as user's **live** permissions unless the host passes a `permissions` snapshot (#2978), which `runToolLoop` forwards to `executeAsPrincipal` so a narrowed principal (e.g. a shared station) cannot reach grants — such as `readPermission`-gated data-surface fields — beyond that snapshot, including through `agents.invoke` delegation (the snapshot becomes the worker's permission ceiling).
155
155
  - **Agent orchestration** (L3, #1892) — the loop accepts non-manifest **`extraTools`** (`PrincipalTool[]`, from `@happyvertical/smrt-agents`), gated by the *same* fail-closed allow-list. The standard **`invoke-agent`** tool (`createInvokeAgentTool`, slug `agents.invoke`) lets a conversational agent delegate to a **worker agent under its own principal** — the worker runs via `executeAsPrincipal` as the originating user (never its own authority), the principal is immutable along the chain, and its completion is surfaced back into the conversation. `runPersonaConversationTurn` filters `extraTools` by the persona's `allowedTools` (offer gate); the tool's `execute` re-asserts `assertToolAllowed` (execution gate). See `@happyvertical/smrt-agents` for the delegation envelope + transports.
156
156
  - **Chat feedback capture** (`chat-feedback.ts`) — `captureChatFeedback()` + `acceptAppliedChange`/`rejectAppliedChange`/`correctResponse`/`rateResponse`/`thumbsUp`/`thumbsDown` write a `Feedback` row (personas) carrying the conversation's **correlation-id**, and (by default) reinforce the persona's learning memory (`reinforceFromFeedback`). So an in-chat reject decays a strategy below the reuse floor and it stops being recalled; a correction supersedes its stored value.
@@ -0,0 +1,224 @@
1
+ # Tool loop termination and tool-call hygiene
2
+
3
+ `runToolLoop()` (`src/tool-loop.ts`) runs one bounded
4
+ `tool_call → observe → respond` turn. Both `runPersonaConversationTurn()` and
5
+ `runAssistantTurn()` go through it, so every rule below holds for both.
6
+
7
+ ## Termination
8
+
9
+ - Rounds that execute tools are capped by `maxSteps`
10
+ (`DEFAULT_MAX_STEPS = 8`; `initialSteps` counts earlier legs of a resumed
11
+ turn). `maxTotalTokens` (with `initialTokens`) and `deadline` end the turn
12
+ early with `stoppedReason: 'budget'`.
13
+ - **Forced final call (#4378).** At the cap, or once the budget is spent, the
14
+ next round is offered no tools (`tools: undefined`, `toolChoice: 'none'`),
15
+ and any tool calls the model still emits are discarded. That call alone gets
16
+ the fixed `TOOL_LOOP_ANSWER_NOW_INSTRUCTION` as a temporary `user`
17
+ instruction. If the transcript already ends with a user turn, it is added
18
+ to a copy of that turn's text or multimodal content instead of introducing
19
+ consecutive user roles that strict templates reject. Otherwise it is a new
20
+ user message. It never enters the returned `messages` transcript; input
21
+ messages, stored conversations, and continuations stay unchanged.
22
+
23
+ ## Blank answers and timeouts (#4379)
24
+
25
+ - **Retry once, within budget.** A final round with blank content and no
26
+ usable tool calls (none made, or discarded on a no-tools round) is retried
27
+ once without tools, with `TOOL_LOOP_ANSWER_NOW_INSTRUCTION` appended to
28
+ that call only, and `emptyRetried: true`. The retry is skipped when the
29
+ token budget (`maxTotalTokens`) or `deadline` is already spent: the turn
30
+ goes straight to `empty`. The forced final call itself is one uncapped
31
+ call, so a spent budget still gets one answer attempt; only the retry is
32
+ budget-gated. Each blank round emits an `empty_round` step event (no model
33
+ text; `retry` says whether a retry follows). `runAssistantTurn` does not
34
+ show it as a dock step.
35
+ - **Report.** Still blank: `stoppedReason: 'empty'`, `content: ''`. A model
36
+ call that throws a timeout (`AI_TIMEOUT`, `TIMEOUT`, `REQUEST_TIMEOUT`,
37
+ `TimeoutError`, or an `AbortError` the caller's signal did not cause) ends
38
+ `stoppedReason: 'timeout'` instead of failing or passing as an empty
39
+ success; other errors still throw. When the final round was the forced
40
+ no-tools call, `capReason` (`max_steps` | `budget`) keeps that cause
41
+ alongside `empty`/`timeout`.
42
+ - **Quiet stream ends (older SDKs).** SDKs <= 0.108.0 can end a timed-out
43
+ stream quietly: no text, no tool calls, no finish reason. That shape is a
44
+ suspected timeout only for an AI boundary that has already reported a
45
+ finish reason in this process (so its absence is anomalous), and only when
46
+ the retry ends the same way; then the turn is `timeout`. A boundary that
47
+ never reports finish reasons, or a blank reply that has one, is `empty`.
48
+ The "has reported" flag is kept per AI client object for the process
49
+ lifetime, so one client that routes to providers with and without finish
50
+ reasons can mislabel an `empty` turn as `timeout` (or the reverse).
51
+ - **Timeouts are configurable, not derived.** `requestTimeoutMs` is
52
+ forwarded as the per-call `timeout` (default: the provider's 120 s). It is
53
+ not derived from `deadline`/`maxTurnMs`: those only stop new tool rounds
54
+ and gate the retry.
55
+ - **Fallback text.** Both callers store `resolveTurnReply(result,
56
+ fallback)`: the content trimmed at its outer edges only (both paths
57
+ alike; persona replies were stored untrimmed before), or
58
+ `emptyAnswerFallback` / `DEFAULT_EMPTY_ANSWER_FALLBACK` when blank.
59
+ `runPersonaConversationTurn` returns it as `reply` (plus `replyFallback`);
60
+ voice and the chat stream use it. `runAssistantTurn` replaces its old
61
+ `'Done.'`. The plain chat-stream path retries a blank stream once, then
62
+ sends the fallback, or `CHAT_STREAM_TIMEOUT_ERROR` only under the
63
+ quiet-end rule above.
64
+ - **Stored metadata.** Every authored assistant reply carries
65
+ `replyMetadataFor(result, reply)`: `metadata.stoppedReason` (enum),
66
+ `metadata.capReason` when set, and `metadata.fallback` (`empty` |
67
+ `timeout`) when the content is the fallback. Hosts read the stop reason
68
+ from `turn.result.stoppedReason` (persona), `AssistantTurnResult` / the
69
+ `done` event's `stoppedReason` and `capReason` (assistant), or the stored
70
+ message's metadata. `isFallbackReply(message)` tells a fallback apart; the
71
+ assistant route's and voice's history builders skip fallback replies so
72
+ they are never replayed to the model as answers. The chat-stream paths
73
+ (plain and persona) take history from the browser, which sends no
74
+ metadata, so they recognise an assistant message whose text exactly
75
+ equals the configured or default fallback text. All three replay the
76
+ fixed `FALLBACK_HISTORY_PLACEHOLDER` in its place rather than dropping
77
+ it: a drop would leave two user messages in a row, which strict chat
78
+ templates (Gemma, Anthropic) reject. Hosts should hide feedback
79
+ controls (thumbs, corrections) on a message where `isFallbackReply` is
80
+ true: there is no model answer to rate.
81
+ - **Dock.** The `done` event's `capReason` reaches the dock, which offers
82
+ Continue for a capped turn even when it ended `empty` or `timeout`.
83
+ - **Reasoning.** `AIResponse.reasoning` (newer SDKs, sdk#1459) is read
84
+ defensively, capped at `MAX_TOOL_LOOP_REASONING_CHARS` code points, passed
85
+ to `onReasoning` (forwarded by both callers; a throw is ignored) and
86
+ returned as `result.reasoning` (the retry's, else the first round's).
87
+ Reasoning can quote documents and tool results: send it only to logs with
88
+ the same protection as the conversation. It is never persisted and never
89
+ the answer unless the host opts in with `answerFromReasoning` — which
90
+ stores raw chain-of-thought as the reply (`contentFromReasoning: true`).
91
+ - **Budgets on the persona path.** `runPersonaConversationTurn` forwards
92
+ `maxTotalTokens`, `deadline`, `toolChoice` and `requestTimeoutMs`
93
+ (`runAssistantTurn` exposes them as `maxTurnTokens`/`maxTurnMs`).
94
+
95
+ ## Observation bounds
96
+
97
+ - A server tool observation is serialized and capped at
98
+ `MAX_SERVER_TOOL_OBSERVATION_CHARS` (16,000, the same bound as
99
+ `MAX_CLIENT_TOOL_RESULT_CHARS` for browser results) before it enters the
100
+ transcript (#4378). A longer one is cut and gets the fixed
101
+ `SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER`, which says the result is
102
+ incomplete and tells the model to narrow the request (filter, fewer fields,
103
+ a smaller page, or a count). The marker carries no tool output.
104
+ - The cut never splits a surrogate pair (it keeps one unit fewer instead);
105
+ browser results (`appendClientToolResults`) are cut the same way.
106
+ - Only the model's copy is capped: `ToolInvocation.observation` (handed to
107
+ `onInvocation`, persisted as tool messages, audited) keeps the full value.
108
+ - A tool returning `undefined` observes `null`; an unserializable result
109
+ observes `{"error":"unserializable_result"}` instead of throwing.
110
+
111
+ ## Argument hygiene (#4378)
112
+
113
+ Arguments the model sends are never dropped silently; each case below is an
114
+ `invalid_request` observation the model can correct and retry. Messages are
115
+ value-free: they name the accepted shape, never the model's values.
116
+
117
+ - **Malformed JSON.** Raw arguments that do not parse to a JSON object
118
+ (malformed JSON, an array, a scalar) fail with code
119
+ `TOOL_ARGUMENTS_MALFORMED`; the tool does not run and the invocation's
120
+ `args` is `{}`. Blank or `null` arguments are a no-argument call. A browser
121
+ tool call with malformed arguments is answered in the transcript and never
122
+ suspends the turn.
123
+ - **Manifest `read`.** Accepts only `id` (string), `where` (object of
124
+ equality filters), `limit` (integer >= 1) and `offset` (integer >= 0). This
125
+ is stricter than before, where these were dropped or defaulted silently:
126
+ an unknown key such as `filter`, a numeric `id`, a non-object `where`, and
127
+ a fractional, zero or string `limit` (or a negative or fractional `offset`)
128
+ now fail with a retryable `invalid_request` (`TOOL_ARGUMENTS_INVALID`)
129
+ instead of listing every row. The offered schema says
130
+ `additionalProperties: false` with `integer` `limit`/`offset` minimums.
131
+ - **`data.query`** (`@happyvertical/smrt-agents`). With a `request` object,
132
+ the only other top-level key allowed is `surfaceId`; a sibling such as
133
+ `filter` fails with `DataSurfaceRequestError` reason
134
+ `DATA_QUERY_ARGUMENTS_UNEXPECTED`, naming only misplaced grammar keys. The
135
+ flat form (request keys beside `surfaceId`, no `request`) still works.
136
+ - **`surfaceId` placement** (`data.query`, `data.inspect`). A
137
+ `request.surfaceId` string is lifted to the top level and removed from
138
+ `request`; a `query` object standing in for `request`, or one that is
139
+ `request`'s only key, is unwrapped (its keys are then validated as usual,
140
+ so nothing is dropped; unwrapping was chosen over rejecting because the
141
+ intent is unambiguous). Two different ids are
142
+ `DATA_QUERY_SURFACE_ID_CONFLICT`; no id at all is a 400
143
+ `DATA_QUERY_SURFACE_ID_REQUIRED` with an example. Only an id naming no
144
+ visible surface gets the generic "not available" denial. A filter `kind`
145
+ that is an operator (`in`) or a logical word (`or`) gets a targeted hint.
146
+ - **Valid examples.** Every `data.query` request error ends with a one-line
147
+ `Valid example: {"surfaceId":…,"request":{…}}` for that surface, in the
148
+ failed request's mode (count, rows or facets), built from the surface id
149
+ and caller-visible field ids with `<value>` placeholders — never the
150
+ caller's own values. Row examples cap page size at the surface’s
151
+ `maxPageLimit`.
152
+
153
+ ## Dedupe of identical read-only calls (#4382)
154
+
155
+ Within one `runToolLoop` call, a server call that repeats an earlier one —
156
+ same tool, same arguments after canonicalization (object keys sorted) — is
157
+ not executed again. Its invocation has `deduped: true`, mirrors the earlier
158
+ `ok`/`error`, and observes the fixed `TOOL_CALL_DEDUPED_NOTE` instead of a
159
+ second copy of the result.
160
+
161
+ - Only read-only, idempotent tools qualify: manifest `read`, and
162
+ `data.discover`, `data.inspect`, `data.query`. Mutating tools,
163
+ `agents.invoke`, other extra tools and browser tools never do; nor do
164
+ malformed-argument calls.
165
+ - **Invalidation.** Any resolved server call that is not on that allow-list
166
+ (a write, `agents.invoke`, any other extra tool), whatever its result,
167
+ clears every remembered read, so a read after a write always runs fresh.
168
+ - A repeat of a rejected or refused call observes
169
+ `TOOL_CALL_DEDUPED_REJECTED_NOTE` (repeating it will not work; fix the
170
+ arguments) instead of the plain pointer note.
171
+ - An earlier `execution_error` is not reused: a transient server failure
172
+ may be retried. Arguments over 4,000 canonical characters are never keyed.
173
+ - The cache holds at most `MAX_DEDUPED_CALLS_PER_TURN` (64) calls and lives
174
+ only inside that `runToolLoop` call: never across turns (an assistant
175
+ resume leg starts a fresh cache).
176
+ - Deduped calls count toward the step cap: a round of repeats is still a
177
+ round, so a model stuck repeating a call still stops at `maxSteps`.
178
+ - The audit sink gets `action: 'chat.tool_call_deduped'` (not a fresh
179
+ execution or failure); the persona path's tool row carries
180
+ `toolCallData.deduped: true`.
181
+
182
+ ## Failed calls are persisted (#4383)
183
+
184
+ Every tool invocation records `modelContent`, the exact (capped) text the
185
+ model was shown. `toolFailureRecord(invocation)` turns a failed, rejected or
186
+ denied call into a bounded record: `name`, `args` (over
187
+ `MAX_TOOL_FAILURE_ARGS_CHARS` = 2,000 serialized characters they become
188
+ `{ truncated: true }`; unserializable ones `{ unserializable: true }`;
189
+ malformed-JSON calls carry `{}`), `status` (`rejected` | `error`),
190
+ `errorKind`, `errorCode` (the error's own stable `A-Z0-9_` code, else the
191
+ kind) and `shown`. Like a successful call's row it carries the arguments
192
+ and shown text, so it is not value-free. A deduped repeat has no record.
193
+
194
+ - `runPersonaConversationTurn` authors each failed call as a `tool_result`
195
+ row: content = `shown`, `toolCallData` `{ name, args, status, errorCode }`,
196
+ `metadata` `{ toolStatus, errorKind, errorCode }`.
197
+ - `runAssistantTurn` now does the same **by default** when an `author` is
198
+ set — a behaviour change: before, failed calls were never persisted.
199
+ `author.authorFailedInvocation` overrides the row or returns `null` to
200
+ skip it; `authorInvocation` sees successful calls only (never a failed or
201
+ deduped-failed one). A failed row's write error is not a dock step.
202
+ - `runToolLoop` sends the audit sink `action: 'chat.tool_call_failed'` with
203
+ only `toolFailureAuditMetadata(record)`: `name`, `status`, `errorKind`,
204
+ `errorCode`, `argsChars`, `shownChars` — never the arguments or the shown
205
+ text, which can hold user data or raw server errors. A sink throw never
206
+ fails the turn.
207
+ - A browser tool call with malformed arguments is recorded the same way (an
208
+ invocation, an audit entry, `onInvocation`), besides being answered in
209
+ the transcript.
210
+ - Gap: a call to a tool the session does not allow-list cannot be a tool row
211
+ — `sendAgentReply`'s authoring gate refuses the name, and that gate is
212
+ unchanged — so it reaches the audit sink only.
213
+
214
+ ## Tool errors
215
+
216
+ A thrown tool error is classified by `classifyToolError`: permission denials
217
+ and 401/403 are `not_permitted` (reported as a rejection); a `ValidationError`
218
+ or 400/404/409/422 is `invalid_request` (observation: the actionable message,
219
+ `publicMessage` first, its `code`, and a fix-and-retry hint); everything else,
220
+ including 429, is `execution_error`. An `execution_error` observation
221
+ carries the error's message, its stable `code` when it has one (e.g.
222
+ `DATA_SURFACE_QUERY_FAILED`), and the fixed `TOOL_EXECUTION_ERROR_HINT`:
223
+ the failure is the server's, so the model should not resend the same call
224
+ but answer with what it has or tell the user (#4378).
@@ -86,7 +86,11 @@ export interface AssistantClientToolResult {
86
86
  /** Why a turn finished. */
87
87
  export type AssistantTurnStopReason = 'stop' | 'max_steps'
88
88
  /** The turn's token or time budget ran out (`maxTurnTokens`/`maxTurnMs`). */
89
- | 'budget' | 'no_tools' | 'cancelled';
89
+ | 'budget' | 'no_tools' | 'cancelled'
90
+ /** The model returned no answer, even after one retry; the reply is the fallback (#4379). */
91
+ | 'empty'
92
+ /** A model call timed out; the reply is the fallback (#4379). */
93
+ | 'timeout';
90
94
  /** One event of a streamed assistant turn. `M` is the host's message shape. */
91
95
  export type AssistantTurnEvent<M = Record<string, unknown>> = {
92
96
  type: 'status';
@@ -108,6 +112,11 @@ export type AssistantTurnEvent<M = Record<string, unknown>> = {
108
112
  type: 'done';
109
113
  message?: M;
110
114
  stoppedReason: AssistantTurnStopReason;
115
+ /**
116
+ * Why tools were withdrawn on the final round, kept when the turn then
117
+ * ends `empty` or `timeout` (#4379).
118
+ */
119
+ capReason?: 'max_steps' | 'budget';
111
120
  } | {
112
121
  type: 'error';
113
122
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-turn-events.d.ts","sourceRoot":"","sources":["../src/assistant-turn-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oEAAoE;AACpE,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzE;;;;GAI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,EAAE,CAAC,EAAE,CAAC;IACd,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,iEAAiE;IACjE,eAAe,CAAC,EAAE,OAAO,CACvB,kBAAkB,CAAC,CAAC,CAAC,EACrB;QAAE,IAAI,EAAE,mBAAmB,CAAA;KAAE,CAC9B,CAAC;CACH;AAED,wFAAwF;AACxF,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B;AAaD;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvE,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAgExC;AAED,sEAAsE;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -35,7 +35,7 @@ import type { PrincipalAuditSink, PrincipalBinding, PrincipalTool } from '@happy
35
35
  import type { SmrtClassOptions } from '@happyvertical/smrt-core';
36
36
  import type { AssistantTurnEvent, AssistantTurnStopReason } from './assistant-turn-events.js';
37
37
  import type { AgentReplyService } from './services/ChatService.js';
38
- import { type ClientToolDefinition, type ClientToolResultInput, type ManifestTool, type PendingClientToolCall, type ToolInvocation, type ToolLoopResult, type ToolLoopUsage } from './tool-loop.js';
38
+ import { type ClientToolDefinition, type ClientToolResultInput, type ManifestTool, type PendingClientToolCall, type ToolInvocation, type ToolLoopOptions, type ToolLoopResult, type ToolLoopUsage } from './tool-loop.js';
39
39
  /** How long a suspended turn waits for the browser's results. */
40
40
  export declare const DEFAULT_CONTINUATION_TTL_MS: number;
41
41
  /**
@@ -135,12 +135,24 @@ export interface AssistantTurnAuthor {
135
135
  tenantId: string;
136
136
  threadId?: string | null;
137
137
  /**
138
- * Maps a server tool invocation to a persisted message, or `null` to keep
139
- * it out of the conversation (the default for every invocation). The
140
- * message's `toolCallData` tool name must be on the session's
141
- * `allowedTools` — `sendAgentReply`'s gate is unchanged.
138
+ * Maps a SUCCESSFUL server tool invocation to a persisted message, or
139
+ * `null` to keep it out of the conversation (the default for successful
140
+ * calls). Failed calls go through {@link authorFailedInvocation}, which
141
+ * persists them by default (#4383, a behaviour change: before, nothing was
142
+ * persisted for a failed call). The message's `toolCallData` tool name
143
+ * must be on the session's `allowedTools` — `sendAgentReply`'s gate is
144
+ * unchanged.
142
145
  */
143
146
  authorInvocation?: (invocation: ToolInvocation) => AuthoredToolReply | null;
147
+ /**
148
+ * Maps a FAILED, rejected or denied server tool invocation to a persisted
149
+ * message (#4383). Default: a `tool_result` row with the exact text the
150
+ * model was shown and `toolCallData`/`metadata` carrying the tool status
151
+ * and a value-free error code. Return `null` to keep one out. A call to a
152
+ * tool the session does not allow-list is refused by `sendAgentReply`'s
153
+ * gate and is reported to the audit sink only.
154
+ */
155
+ authorFailedInvocation?: (invocation: ToolInvocation) => AuthoredToolReply | null;
144
156
  }
145
157
  /** Options for {@link runAssistantTurn}. */
146
158
  export interface AssistantTurnOptions<M = Record<string, unknown>> {
@@ -206,6 +218,29 @@ export interface AssistantTurnOptions<M = Record<string, unknown>> {
206
218
  temperature?: number;
207
219
  maxTokens?: number;
208
220
  toolChoice?: ChatOptions['toolChoice'];
221
+ /**
222
+ * Per-model-call timeout in ms (forwarded as `requestTimeoutMs`, #4379).
223
+ * Unset: the provider default. A timed-out call ends the turn with
224
+ * `stoppedReason: 'timeout'` and the fallback reply.
225
+ */
226
+ requestTimeoutMs?: number;
227
+ /**
228
+ * Reply stored when the turn produced no answer (#4379; `stoppedReason`
229
+ * `empty` or `timeout`, or blank content). Default
230
+ * `DEFAULT_EMPTY_ANSWER_FALLBACK`. Replaces the old `'Done.'`.
231
+ */
232
+ emptyAnswerFallback?: string;
233
+ /**
234
+ * Host opt-in: answer from the model's reasoning text when the final round
235
+ * and its retry are blank (forwarded, see `ToolLoopOptions`). Default false.
236
+ */
237
+ answerFromReasoning?: boolean;
238
+ /**
239
+ * Reasoning-text sink (forwarded, see `ToolLoopOptions.onReasoning`).
240
+ * Reasoning can quote documents and tool results: send it only to logs
241
+ * with the same protection as the conversation itself.
242
+ */
243
+ onReasoning?: ToolLoopOptions['onReasoning'];
209
244
  /** Cancels the turn (e.g. the request's own abort signal). */
210
245
  signal?: AbortSignal;
211
246
  /** Per-round token usage, for the host's usage attribution. */
@@ -249,6 +284,8 @@ export interface AssistantTurnState {
249
284
  /** What {@link runAssistantTurn} returns when its generator completes. */
250
285
  export interface AssistantTurnResult {
251
286
  stoppedReason: AssistantTurnStopReason | 'client_tools' | 'error';
287
+ /** Why tools were withdrawn on the final round, when they were (#4379). */
288
+ capReason?: 'max_steps' | 'budget';
252
289
  content: string;
253
290
  loop?: ToolLoopResult;
254
291
  /** The turn's origin message (from the continuation on a resume). */
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-turn.d.ts","sourceRoot":"","sources":["../src/assistant-turn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAEV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE1B,KAAK,YAAY,EACjB,K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,EAC5D,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,wBAAwB,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB,GACL,QAAQ,CA2DV"}
@@ -161,7 +161,22 @@ export interface ChatStreamContext {
161
161
  temperature?: number;
162
162
  maxTokens?: number;
163
163
  maxSteps?: number;
164
+ /**
165
+ * Per-model-call timeout in ms, forwarded to the AI boundary on both paths
166
+ * (#4379). Unset: the provider default (120 s in `@happyvertical/ai`).
167
+ */
168
+ requestTimeoutMs?: number;
169
+ /**
170
+ * Reply text used when the model produces no answer (#4379). Default
171
+ * `DEFAULT_EMPTY_ANSWER_FALLBACK`.
172
+ */
173
+ emptyAnswerFallback?: string;
164
174
  }
175
+ /**
176
+ * Error text the plain path emits when a stream ends the way an older SDK
177
+ * ends a timed-out stream — no text and no finish reason — twice (#4379).
178
+ */
179
+ export declare const CHAT_STREAM_TIMEOUT_ERROR = "The model did not answer in time. Please try again.";
165
180
  /** Options for {@link runChatConversationStream}. */
166
181
  export interface RunChatConversationStreamOptions {
167
182
  context: ChatStreamContext;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-stream.d.ts","sourceRoot":"","sources":["../src/chat-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBA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;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAkFzC;AAID,8DAA8D;AAC9D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAEpE"}
@@ -1903,7 +1903,8 @@ var ChatService = class ChatService {
1903
1903
  threadId: params.threadId ?? null,
1904
1904
  agentSessionId: params.agentSessionId,
1905
1905
  replyToMessageId: params.replyToMessageId ?? null,
1906
- toolCallData: params.toolCallData ?? null
1906
+ toolCallData: params.toolCallData ?? null,
1907
+ ...params.metadata ? { metadata: params.metadata } : {}
1907
1908
  });
1908
1909
  }
1909
1910
  /**
@@ -2249,4 +2250,4 @@ function sendAgentReply(service, params) {
2249
2250
  //#endregion
2250
2251
  export { sendAgentReply as a, ChatThread as c, ChatParticipant as d, ChatMessage as f, clientRequestMessageId as i, ChatRoom as l, ChatService as n, VoiceSessionCollection as o, AgentSession as p, ChatService_exports as r, VoiceSession as s, ChatClientRequestConflictError as t, ChatReaction as u };
2251
2252
 
2252
- //# sourceMappingURL=ChatService-DjGf2AoJ.js.map
2253
+ //# sourceMappingURL=ChatService-D0XuiCTk.js.map