@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
@@ -22,7 +22,7 @@ import type { PrincipalAuditSink, PrincipalBinding, PrincipalTool } from '@happy
22
22
  import { type LearningMemoryRecord, type LearningSemanticSearch, type SmrtClassOptions } from '@happyvertical/smrt-core';
23
23
  import type { AgentSession } from './models/AgentSession.js';
24
24
  import type { ChatMessage } from './models/ChatMessage.js';
25
- import { type ManifestTool, type ToolLoopResult } from './tool-loop.js';
25
+ import { type FallbackReplyReason, type ManifestTool, type ToolLoopOptions, type ToolLoopResult } from './tool-loop.js';
26
26
  /**
27
27
  * The structural persona shape the conversation binding needs. Both a
28
28
  * `ResolvedPersona` (from `PersonaResolver.resolve()`) and a raw `AgentPersona`
@@ -163,6 +163,34 @@ export interface PersonaConversationTurnOptions {
163
163
  temperature?: number;
164
164
  /** Max tokens per completion. */
165
165
  maxTokens?: number;
166
+ /** Tool-choice behaviour while tools are offered (forwarded). Default `'auto'`. */
167
+ toolChoice?: ToolLoopOptions['toolChoice'];
168
+ /**
169
+ * Token budget for the whole turn (forwarded as `maxTotalTokens`, #4379):
170
+ * once spent, the model answers without tools and the turn stops with
171
+ * `budget`. Unset: no budget.
172
+ */
173
+ maxTotalTokens?: number;
174
+ /** Wall-clock deadline for the turn, epoch ms (forwarded, #4379). */
175
+ deadline?: number;
176
+ /** Per-model-call timeout in ms (forwarded as `requestTimeoutMs`, #4379). */
177
+ requestTimeoutMs?: number;
178
+ /**
179
+ * Text stored as the assistant reply when the turn produced no answer
180
+ * (#4379). Default {@link DEFAULT_EMPTY_ANSWER_FALLBACK}; never `''`.
181
+ */
182
+ emptyAnswerFallback?: string;
183
+ /**
184
+ * Host opt-in: answer from the model's reasoning text when the final round
185
+ * and its retry are blank (forwarded, see `ToolLoopOptions`). Default false.
186
+ */
187
+ answerFromReasoning?: boolean;
188
+ /**
189
+ * Reasoning-text sink (forwarded, see `ToolLoopOptions.onReasoning`).
190
+ * Reasoning can quote documents and tool results: send it only to logs
191
+ * with the same protection as the conversation itself.
192
+ */
193
+ onReasoning?: ToolLoopOptions['onReasoning'];
166
194
  /** Originating user the turn runs on behalf of (audited). */
167
195
  onBehalfOfUserId?: string | null;
168
196
  /** Audit sink for the on-behalf-of entry (forwarded to `executeAsPrincipal`). */
@@ -189,6 +217,18 @@ export interface PersonaConversationTurnOptions {
189
217
  export interface PersonaConversationTurnResult {
190
218
  /** The tool-loop result (final text, invocations, transcript). */
191
219
  result: ToolLoopResult;
220
+ /**
221
+ * The reply text the turn stands behind (#4379): `result.content`
222
+ * trimmed, or the `emptyAnswerFallback` when that is blank. This is what is
223
+ * authored into the room; speak or display this rather than
224
+ * `result.content`.
225
+ */
226
+ reply: string;
227
+ /**
228
+ * Set when `reply` is the fallback (`empty` or `timeout`). The authored
229
+ * message carries it as `metadata.fallback`, and history builders skip it.
230
+ */
231
+ replyFallback?: FallbackReplyReason;
192
232
  /** The correlation id feedback on this turn should reference. */
193
233
  correlationId: string;
194
234
  /** The memory recalled into the turn's context. */
@@ -1 +1 @@
1
- {"version":3,"file":"persona-conversation.d.ts","sourceRoot":"","sources":["../src/persona-conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC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AC7B;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,YAAY,CAAC,CAavB"}
@@ -24,6 +24,12 @@ export interface AgentReplyParams {
24
24
  * turn). Validated to the same room/tenant like `threadId`.
25
25
  */
26
26
  replyToMessageId?: string | null;
27
+ /**
28
+ * Message metadata, set by the trusted runtime only: the #4383 tool
29
+ * status on a failed call's row, and the #4379 `stoppedReason` /
30
+ * `fallback` markers on a reply.
31
+ */
32
+ metadata?: Record<string, unknown> | null;
27
33
  }
28
34
  /**
29
35
  * A file reference stored on a user message (`ChatMessage.attachments`). The
@@ -1 +1 @@
1
- {"version":3,"file":"ChatService.d.ts","sourceRoot":"","sources":["../../src/services/ChatService.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAYlC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAEV,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,YAAY,EACb,MAAM,aAAa,CAAC;AA2BrB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAA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,EAAE,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB;IA8ED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,CAAC,eAAe,CAAC,CACtB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,gBAAgB;CAO3B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,gBAAgB,wBAGzB"}
@@ -3,15 +3,16 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-chat",
6
- "packageVersion": "0.57.32",
6
+ "packageVersion": "0.57.34",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "23c4bdd0c532f4b4f45820a999985a7cc4b285c0519f5ca4de4b99f0a4851c28",
11
- "packageJson": "4791bafeeb30d9378c1794b1f9c174fadb74ce950bd2550db06987fa8c94ab47",
12
- "agents": "fbe59050d13081c743f92497371a2911d07e3b23720571f28fe07c1078c411f1",
10
+ "manifest": "cbfea1ab4a21e4748fcdb294902ee14076cf332b5e76477abdb2fc2d890dc97c",
11
+ "packageJson": "dfbd2c190793e0e696c4b2ff55c4291906f5e6e31fa4624364837dcd10ccdc9e",
12
+ "agents": "070c6bd790c209515457c27e6ad34e9d1c4e5e7b5787e3c7c28f4bf85a808013",
13
13
  "moduleDoc:agents/dev-workbench.md": "f07a428519e8cca4a46371da0a3b33b9c8d3102f1d9056e4c8efba3c0b702048",
14
14
  "moduleDoc:agents/overview-tools.md": "752a4afb6b57a2e9224f3c65a98b0deb23cda87371f01ac0566f0887e9bb12da",
15
+ "moduleDoc:agents/tool-loop.md": "7976d80521c4212a3eb7e66f9bb4abb6192c00bacf4e4722571280a175cc8d07",
15
16
  "moduleDoc:agents/token-streaming.md": "e92a28a8702d111a3751a86b8cdff30cb5146cc115fed86c227402bef1c683fd",
16
17
  "moduleDoc:agents/assistant-questions.md": "a0371870b3bc99e313d8287912208f3e315bab7dc4ee138214895031ae79a5b0",
17
18
  "moduleDoc:agents/recipes.md": "89c2c86e4e26cea9ba10d917f8ad71c23a71d4fd8eaacf638a6cd252e2376c07",
@@ -61,7 +62,6 @@
61
62
  "@sveltejs/package": "^2.5.8",
62
63
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
63
64
  "@types/node": "24.13.6",
64
- "fast-glob": "^3.3.3",
65
65
  "svelte": "^5.57.0",
66
66
  "svelte-check": "^4.7.6",
67
67
  "typescript": "6.0.3",
@@ -4513,7 +4513,7 @@
4513
4513
  "polymorphicAssociations": 0,
4514
4514
  "uuidColumns": 78
4515
4515
  },
4516
- "agentDoc": "# @happyvertical/smrt-chat\n\nChat rooms, threads, and agent sessions with app-controlled tool whitelisting.\n\n## Dev Server\n\n`pnpm --dir packages/chat dev` runs a package-local SvelteKit workbench. The root\nroute separates **Character setup** and **Chat dev** into tabs; switching tabs\nretains the current character rig and chat state. The chat tab is an interactive\nsurface with a dev-only `/api/dev-chat` endpoint:\nit uses `@happyvertical/ai` when local provider credentials are present and\nfalls back to a deterministic local assistant otherwise. `/api/dev-chat-stream`\nis its SSE companion (#1936) — the same provider/local-fallback resolution wired\nthrough `createChatStreamHandler` in plain mode, so an embedded `SmrtChatBackend`\nclient can exercise token streaming locally. `/previews` hosts the shared\ncomponent playground entries from `src/svelte/playground.ts`.\n\nThe root route also drives the **browser inference path**\n(`@happyvertical/smrt-web/ai`: bitgpu, WebLLM, and route backends composed by\n`createInferencePath`) and an **agent-addressable draft form** (`useViewIntent`\nover `src/routes/chat-dev.intents.ts`, #2588). Their dev-config dependencies\n(static optional-peer imports, `workspace-aliases.js` prefix rules, the theme\nstylesheet import) and the stage→apply tool-call gotchas are in\n[agents/dev-workbench.md](agents/dev-workbench.md).\n\nDev-only voice and opt-in local character persistence are documented in\n[agents/dev-workbench.md](agents/dev-workbench.md#voice-and-local-character-persistence).\nThese endpoints are loopback-only demos; production hosts supply authenticated\nprincipals, tenancy, and authorization to the owning services.\n\n## Models\n\nAll seven models expose only generated REST/MCP `list`/`get`; structural tests\ncheck the registry for accidental mutating operations. Writes go through\nmembership/owner-checked `ChatService` or the binding-checked voice adapter.\n\n`ChatService` is a closed facade. Its collections and security-sensitive\nhelpers use ES `#private` fields/methods (TypeScript `private` is erased).\nCollection classes are not exported from the package index. The agent-reply\nbridge is a Symbol-keyed static accessible through a non-exported symbol held\nby the module-local `sendAgentReply` function.\n\n- **ChatRoom**: `roomType` (public/private/dm/agent), `status`, `topic`, `maxParticipants`, `lastMessageAt`. Tenant-scoped (required).\n- **ChatMessage**: shared by users + agents. `role` (user/assistant/system/tool), `messageType` (text/system/action/file/tool_call/tool_result), `toolCallData` JSON. Unified model — no separate agent message type. Tenant-scoped (required).\n- **ChatParticipant**: `role` (owner/admin/member/viewer), `onlineStatus`, `lastReadMessageId`, `isMuted`. Tenant-scoped (required).\n- **ChatThread**: `rootMessageId`, `isResolved`, `messageCount`. Created via `ChatService.startThread()` (member-checked). Tenant-scoped (required).\n- **ChatReaction**: `messageId`, `profileId`, `emoji`. Added/removed via `ChatService.addReaction()`/`removeReaction()` (member-checked, self-keyed). Tenant-scoped (required).\n- **AgentSession**: `agentId` (application slug, string ref, not FK), `agentProfileId` (nullable `crossPackageRef` to `Profile` — the `bot` profile the agent AUTHORS as, #2995), `allowedTools` (JSON string array), `sessionContext` (JSON, sensitive), `systemPrompt`, limits (`maxTokens`/`maxMessages`/`expiresAt`). Optional tenancy.\n- **VoiceSession**: short-lived voice-gateway binding over `(tenant, actorProfileId, personaId, room/thread/agentSession)` plus a persona snapshot, gateway `session_id`, expiry, replay tracking, and metadata. Tenant-scoped (required). Generated surface is read-only; creation and turns go through `createVoiceChatSession()` / `handleVoiceGatewayTurn()`.\n\n## ChatService\n\nPublic writes take server-supplied `actorProfileId`; never trust a request's\n`senderProfileId`, `role`, owner id, or participant id as authority.\n\n| Operation | Authorization and behavior |\n|---|---|\n| `sendMessage()` | Room member; authors as actor with `role: 'user'`; no public membership bypass |\n| `createRoom()` | Actor becomes owner |\n| `startThread()` | Member; optional root message bound to room and tenant |\n| `addParticipant()` / `removeParticipant()` | Owner/admin; self-leave allowed |\n| `updateRoom()` | Owner/admin |\n| `addReaction()` / `removeReaction()` | Member; self-keyed |\n| `getOrCreateDM()` | Actor must be a DM participant |\n| `createAgentSession()` | Actor becomes session participant; existing-session lookup tenant-bound; optional `sessionKey` isolates conversation subjects |\n| `updateAgentSessionConfig()` | Owner; mandatory tenant-bound lookup |\n| `sendAgentUserMessage()` | Actor must be session participant; authored as participant |\n\nRead facade: `getAgentSession({agentSessionId, tenantId})`,\n`findActiveAgentSessions({tenantId, agentId, participantProfileId})`, and\n`getThread({threadId, tenantId})` are tenant-bound; consumers still check\nownership/context. `listRoomThreads({roomId, actorProfileId, tenantId})`,\n`getThreadMessages({threadId, actorProfileId, tenantId, limit?})` (chronological),\n`getRoomMessages({roomId, actorProfileId, tenantId})`, and\n`getRoomForMember(roomId, actorProfileId, tenantId)` additionally require\nmembership of the server-supplied actor, not a caller-selected subject.\n\nTrusted agent runtime imports `sendAgentReply(service, params)` only from\n`@happyvertical/smrt-chat/internal/agent-runtime`. It is not a `ChatService`\nmethod or package-index export. It authors as `session.agentProfileId` — the\nagent's resolved `bot` Profile, NEVER the `agentId` slug (#2995) — accepts a\nsame-room/tenant thread, and enforces `allowedTools` fail-closed.\n\nPrivate `#writeMessage` alone can select arbitrary authors/roles or bypass\nmembership. It binds every supplied `threadId`, `agentSessionId`, and\n`replyToMessageId` to the same room **and** tenant. Internal enrollment supports\nautomatically created rooms, sessions, and participants.\n\n## Agent Tool Whitelisting\n\n`allowedTools` is a JSON array controlled by the consuming app. Fail-closed: an empty/unparseable whitelist permits NO tools. The internal `sendAgentReply(service, params)` function enforces the whitelist before emitting any `tool`/`tool_call` message; a caller cannot supply a `senderProfileId`/`role` to post as the agent, and the function is not reachable from the package index.\n\nPrincipal-bound data discovery and reads are available as `PrincipalTool[]` via\n`createDataSurfaceTools()` (re-exported by the chat package). Pass the tools as\n`extraTools` to the persona conversation/tool loop. They use the same\nfail-closed `allowedTools` offer/execution gates; RBAC, tenant, redaction,\nbounded query results, and audit authority remain in the authenticated\n`PrincipalRun` supplied by `@happyvertical/smrt-agents`.\n\n## Commerce money tools (#3937)\n\nHosts that offer invoice money work must explicitly register\n`createCommerceMoneyTools()` from `@happyvertical/smrt-commerce` in\ntheir authenticated assistant route's `extraTools` (for example, `extraTools: () => createCommerceMoneyTools()`) and\nadd only the desired `commerce.*` slugs to the persona's `allowedTools`.\nThey are not generic manifest CRUD tools: tax codes are selected by code,\npreview is calculator-only, and line writes run through the document-money\ncoordinator. Each execution reasserts the principal allow-list and required\n`Invoice`, `InvoiceLineItem`, `DocumentTax`, and `TaxCode` operations. The\ngenerated MCP invoice `get` serializer remains commerce-owned; use its\nstored-facts integration when that serializer exposes `DocumentTax` rows.\n\n## Runtime report tools (#3711)\n\n`createRuntimeReportTools()` (`runtime-report-tools.ts`) returns four\n`PrincipalTool`s for the persona `extraTools` seam: `reports.runtime.sources`,\n`reports.runtime.define` (`preview` / `apply`), `reports.runtime.list`, and\n`reports.runtime.run`. The model supplies only a declarative\n`RuntimeReportSpec` from `@happyvertical/smrt-reports`; sources are a\nserver-owned allow-list gated by `run.assertOperation(collection, 'read')`, and\nfield policy, `readPermission`, and tenancy are enforced by the compiler against\nthe live run on every compile and every stored-report run. `apply` needs the\n`specHash` of the previewed spec plus an app-owned `confirmation` host that\nresolves only after a human approved that exact spec; with no host apply returns an `awaiting_confirmation` proposal for the\nsame-origin browser confirm route and stores nothing and a model-supplied `confirmed` flag is ignored. Saving also needs\n`create` on the `RuntimeReport` collection, and `list`/`run` need `read`; the\ndefault `reportsCollection` is the `RuntimeReport` class itself, which resolves\nto the catalog slug. A string `collection`/`reportsCollection` is used verbatim\nas a catalog slug (never a class name); tests must run the tools under the real\n`assertOperationPermission` guard so a wrong slug fails. A stored report is\nwritten only by this confirmed `apply`: the model layer refuses every other\ninsert/spec change, and the generic manifest tools (`buildManifestToolCatalog`,\n`invokeManifestTool`) never offer or run a `RuntimeReport` write. Stored-report\nreads/saves run under the principal's tenant (`withPrincipalTenant`), refuse a\nmismatching ambient tenant (checked before `confirmSave`), and filter by the principal tenant explicitly. Contract and authority model:\n[`packages/reports/agents/runtime-reports.md`](../reports/agents/runtime-reports.md).\n\n## Overview tools (#3727)\n\n`createOverviewTools({ host })` (`overview-tools.ts`) returns\n`overviews.describe`, `overviews.apply` (an atomic batch of structured widget\noperations) and `overviews.undo` (single step, keyed by tenant, user and page).\nThe host opens a page per `PrincipalRun` (smrt-svelte's\n`createOverviewAssistantSurface`, typed structurally here); validation and\n`canCustomize` are the surface's. Contract:\n[agents/overview-tools.md](agents/overview-tools.md).\n\n## Conversational Harness (L3, #1891)\n\nThe `AgentSession` runtime depends on personas, agents, and users. Keep those\nedges acyclic: none of those packages may depend back on chat.\n\n- **`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`.\n- **`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).\n- **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.\n- **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.\n\n## Voice Gateway Turns (#1910)\n\nVoice is an input mode for the existing persona chat harness, not a separate chat runtime. `createVoiceChatSession()` creates a short-lived `VoiceSession` for an authenticated actor/profile, binding tenant, persona, agent session, room, and optional thread. `handleVoiceGatewayTurn()` resolves that binding from `metadata.voiceSessionId`, checks the gateway's `session_id` and any supplied tenant/profile/persona/session/thread metadata against the server-side binding, persists the transcript through `ChatService.sendAgentUserMessage()`, runs `runPersonaConversationTurn()`, stamps voice/correlation metadata onto the persisted user/assistant/tool messages, records the gateway `turn_id`, and returns the gateway response contract. The Fetch-compatible `createVoiceGatewayTurnHandler()` adds the coarse gateway bearer-token check.\n\nThe gateway bearer token proves only \"this request came from the gateway\"; it never authorizes the end user. The short-lived `VoiceSession` binding is the user/session proof, and untrusted gateway metadata must be validated against that binding before any chat write or tool loop. Tool execution remains fail-closed through the persona allow-list mirrored onto `AgentSession` by `bindPersonaToSession()`.\n\n## Token streaming\n\n`chat-stream.ts` serves browser-safe SSE through `./client`. The host's\n`authorize(request, body)` is the sole trust boundary: resolve identity, tenant,\ncapabilities, and generation limits server-side; never authorize from request\nsession metadata. Persona turns reuse the principal and fail-closed tool gates.\nThe engine and browser-safe `SmrtChatBackend` keep custom-tool resolution\nserver-side. See [agents/token-streaming.md](agents/token-streaming.md) for the\nevent contract, CORS policy, and streaming behavior.\n\n## Streamed assistant turns with browser tools (#2908)\n\n`runAssistantTurn()` (`assistant-turn.ts`) is the host-route engine for the\nAssistantDock: one turn over `runToolLoop` with server tools (offer-gated by\n`principal.allowedTools`), browser tools (validated by\n`sanitizeClientToolDeclarations` + a server allow-list), `maxSteps`, `signal`,\nand `onUsage`. A browser tool call SUSPENDS the turn (`stoppedReason:\n'client_tools'`); the transcript waits in an `AssistantContinuationStore`\n(single-use, 15-minute TTL; `createSessionContinuationStore` keeps it in the\nAgentSession's `sessionContext`) and the browser resumes it with results,\nwhich reach the model wrapped `untrusted`. `createAssistantTurnResponse`\nserves the events as SSE; `assistant-turn-events.ts` is the browser-safe wire\ncontract (`./assistant-turn` subpath, also a vite library entry because the\nSvelte dock imports it). The dock decides whether a browser call runs or waits\nfor the user from the page registry, never the server's echo; destructive\nalways waits. Details: [`docs/assistant-dock.md`](../../docs/assistant-dock.md).\n\n## AssistantDock (#2904)\n\n`AssistantDock` (`svelte/components/assistant/`, exported from `./svelte`)\nuses a host `DataSurfaceRegistry`'s mounted descriptors (none: plain chat).\nActions: `normalizeDataSurfaceActionRequest` → `AssistantActionClient`\n(preview/apply over a server `DataSurfaceActionAdapter`, not the\n`data-surface-bridge.ts` channel). Generated `ChatThread`/`ChatMessage`\n`list`/`get` are tenant- not member-scoped; the dock never calls them.\n\n**Server routes (#3368).** `./sveltekit` `mountAssistantRoutes()` serves the\ndock from one `[...path]` route; `createAssistantHttp{Transport,ActionClient}`\n(`./svelte`) are its browser half. Principal from `event.locals` or\n`resolvePrincipal`; threads only from the actor's keyed session room in that\ntenant (else 404). `allowedTools` is fail-closed; without `tools` it offers\nthose manifest ops (an unprovided name is an error, #3414). `ai` defaults to\nthe config `ai` block. Pass `runtime`: a turn never keeps the RLS request tx\n(own `runAsPrincipal` tx). `clientRequestId` makes the row id a UUIDv5\n(`clientRequestMessageId`): the PK is the retry reservation. See\n[docs](../../docs/assistant-dock.md).\n\nStructured questions and page requests (#4100): [agents/assistant-questions.md](agents/assistant-questions.md).\n\n## Recipes (#3719)\n\n`src/recipes.ts` declares `chat.assistant` (the AssistantDock as a `header.end`\nshell widget, an `llm` provider, runtime `both`; help in\n`src/assistant.recipe.md`). Keep each recipe class self-contained. Details:\n[agents/recipes.md](agents/recipes.md).\n\n## Gotchas\n\n- **sessionContext, not context**: `context` is reserved for slug scoping. Use `getSessionContext()`/`updateSessionContext()` for agent memory.\n- **Agent rooms auto-created**: `roomType: 'agent'`, `maxParticipants` defaults to 2; the agent is enrolled as a member so its replies pass the membership check. `createAgentSession()` re-enrolls the participant AND the agent on the existing-session path, so legacy sessions created before the agent was enrolled self-heal.\n- **The agent's author is a Profile, not `agentId` (#2995)**: `senderProfileId`/`profileId` are `crossPackageRef`s to `Profile` and therefore uuid columns on PostgreSQL, so the slug fails the cast (`22P02`) and no agent reply can persist. `createAgentSession()` resolves the agent's `bot` Profile through `resolveAgentProfile()` in `@happyvertical/smrt-profiles` (created on first use, tenant-bound) and records it as `AgentSession.agentProfileId`; both enrolment and `sendAgentReply` use that uuid. A consumer whose agent already has an acting identity passes `agentProfileId` to skip resolution — the voice path does this with the persona's `actsAsProfileId`, so persona replies stay attributed to the configured acting profile. Like `actorProfileId`, `agentProfileId` is SERVER-supplied, never request input: it selects the author of every later assistant message. It is validated (`#requireAgentProfile`) to exist and be visible in the tenant and to differ from the acting participant, and it can never re-point a session that already resolved one — only a pre-#2995 session with none is backfilled. **Migration**: `agent_profile_id` is an ordinary additive manifest field, so a consumer adopts it the same way as any other — `smrt db:migrate` generates and applies the column from the manifest, and `db:status --parity` verifies it; the framework never creates application schema at runtime. It is nullable and needs no offline DATA backfill — a session created before #2995 resolves and persists its `agentProfileId`, and re-enrols the agent, on its first agent turn after the upgrade. Two pre-#2995 cohorts: a session whose `agentId` is an ordinary slug never committed an author on PostgreSQL (the cast failed), so there is nothing to repair there, while SQLite/DuckDB may hold `chat_messages`/`chat_participants` rows whose id column holds the slug — readable, but not joinable to `profiles`. A session whose `agentId` is already a Profile uuid (the voice path used to collapse a persona's `actsAsProfileId` into it) DID commit on PostgreSQL; that profile is ADOPTED as the author, tenant-checked and never the participant, so the conversation's author does not change and the two-seat room gains no third identity. Known one-time effect: because `voice.ts` no longer derives `agentId` from `actsAsProfileId`, a keyless `createVoiceChatSession()` for such a persona opens a new session and room instead of reusing the legacy one; the old room and its messages stay intact and readable, and resuming with an explicit `agentSessionId` is unaffected.\n- **Only SQLite-backed tests would miss this class of bug**: uuid columns accept any text on SQLite. `src/__tests__/agent-reply-postgres.test.ts` (`pnpm --filter @happyvertical/smrt-chat test:postgres`) pins the agent-reply path against real PostgreSQL. That suite runs in `postgres-tests.yml` on every same-repository PR and merge group (#2659); keep a cheap SQLite assertion alongside it anyway, since the default lane is SQLite-only (`chat-service.test.ts` asserts the author is the profile uuid, not the slug).\n- **Per-subject sessions need `sessionKey`**: `createAgentSession()` reuses ANY active session for the same `(agentId, participantProfileId, tenantId)`. Callers that open separate conversations per subject (e.g. one content-editor session per content id) MUST pass a stable `sessionKey` (stored in `sessionContext.__sessionKey`, read via `AgentSession.getSessionKey()`); otherwise a session opened for one subject is reused and its context overwritten for another, surfacing the wrong room/threads (S5 #1392). A keyed create never reuses a keyless/legacy session.\n- **Session expiry**: check `isActive()` before allowing messages (expiresAt or limit-based)\n- **DM identity**: derived from the deterministic per-tenant `canonicalDmRoomId()` and the authoritative `chat_participants` join, not client metadata; concurrent creates upsert onto one row.\n- **Tenant-bound lookups**: membership/session/DM lookups REQUIRE `tenantId` and always bind it into the WHERE clause (`findActiveMembership`/`isActiveMember`/`findActiveSession` take a required `tenantId`; AgentSession's `null` tenant is an explicit bound scope, not \"any tenant\") so they can never resolve a row from another tenant.\n",
4516
+ "agentDoc": "# @happyvertical/smrt-chat\n\nChat rooms, threads, and agent sessions with app-controlled tool whitelisting.\n\n## Dev Server\n\n`pnpm --dir packages/chat dev` runs a package-local SvelteKit workbench. The root\nroute separates **Character setup** and **Chat dev** into tabs; switching tabs\nretains the current character rig and chat state. The chat tab is an interactive\nsurface with a dev-only `/api/dev-chat` endpoint:\nit uses `@happyvertical/ai` when local provider credentials are present and\nfalls back to a deterministic local assistant otherwise. `/api/dev-chat-stream`\nis its SSE companion (#1936) — the same provider/local-fallback resolution wired\nthrough `createChatStreamHandler` in plain mode, so an embedded `SmrtChatBackend`\nclient can exercise token streaming locally. `/previews` hosts the shared\ncomponent playground entries from `src/svelte/playground.ts`.\n\nThe root route also drives the **browser inference path**\n(`@happyvertical/smrt-web/ai`: bitgpu, WebLLM, and route backends composed by\n`createInferencePath`) and an **agent-addressable draft form** (`useViewIntent`\nover `src/routes/chat-dev.intents.ts`, #2588). Their dev-config dependencies\n(static optional-peer imports, `workspace-aliases.js` prefix rules, the theme\nstylesheet import) and the stage→apply tool-call gotchas are in\n[agents/dev-workbench.md](agents/dev-workbench.md).\n\nDev-only voice and opt-in local character persistence are documented in\n[agents/dev-workbench.md](agents/dev-workbench.md#voice-and-local-character-persistence).\nThese endpoints are loopback-only demos; production hosts supply authenticated\nprincipals, tenancy, and authorization to the owning services.\n\n## Models\n\nAll seven models expose only generated REST/MCP `list`/`get`; structural tests\ncheck the registry for accidental mutating operations. Writes go through\nmembership/owner-checked `ChatService` or the binding-checked voice adapter.\n\n`ChatService` is a closed facade. Its collections and security-sensitive\nhelpers use ES `#private` fields/methods (TypeScript `private` is erased).\nCollection classes are not exported from the package index. The agent-reply\nbridge is a Symbol-keyed static accessible through a non-exported symbol held\nby the module-local `sendAgentReply` function.\n\n- **ChatRoom**: `roomType` (public/private/dm/agent), `status`, `topic`, `maxParticipants`, `lastMessageAt`. Tenant-scoped (required).\n- **ChatMessage**: shared by users + agents. `role` (user/assistant/system/tool), `messageType` (text/system/action/file/tool_call/tool_result), `toolCallData` JSON. Unified model — no separate agent message type. Tenant-scoped (required).\n- **ChatParticipant**: `role` (owner/admin/member/viewer), `onlineStatus`, `lastReadMessageId`, `isMuted`. Tenant-scoped (required).\n- **ChatThread**: `rootMessageId`, `isResolved`, `messageCount`. Created via `ChatService.startThread()` (member-checked). Tenant-scoped (required).\n- **ChatReaction**: `messageId`, `profileId`, `emoji`. Added/removed via `ChatService.addReaction()`/`removeReaction()` (member-checked, self-keyed). Tenant-scoped (required).\n- **AgentSession**: `agentId` (application slug, string ref, not FK), `agentProfileId` (nullable `crossPackageRef` to `Profile` — the `bot` profile the agent AUTHORS as, #2995), `allowedTools` (JSON string array), `sessionContext` (JSON, sensitive), `systemPrompt`, limits (`maxTokens`/`maxMessages`/`expiresAt`). Optional tenancy.\n- **VoiceSession**: short-lived voice-gateway binding over `(tenant, actorProfileId, personaId, room/thread/agentSession)` plus a persona snapshot, gateway `session_id`, expiry, replay tracking, and metadata. Tenant-scoped (required). Generated surface is read-only; creation and turns go through `createVoiceChatSession()` / `handleVoiceGatewayTurn()`.\n\n## ChatService\n\nPublic writes take server-supplied `actorProfileId`; never trust a request's\n`senderProfileId`, `role`, owner id, or participant id as authority.\n\n| Operation | Authorization and behavior |\n|---|---|\n| `sendMessage()` | Room member; authors as actor with `role: 'user'`; no public membership bypass |\n| `createRoom()` | Actor becomes owner |\n| `startThread()` | Member; optional root message bound to room and tenant |\n| `addParticipant()` / `removeParticipant()` | Owner/admin; self-leave allowed |\n| `updateRoom()` | Owner/admin |\n| `addReaction()` / `removeReaction()` | Member; self-keyed |\n| `getOrCreateDM()` | Actor must be a DM participant |\n| `createAgentSession()` | Actor becomes session participant; existing-session lookup tenant-bound; optional `sessionKey` isolates conversation subjects |\n| `updateAgentSessionConfig()` | Owner; mandatory tenant-bound lookup |\n| `sendAgentUserMessage()` | Actor must be session participant; authored as participant |\n\nRead facade: `getAgentSession({agentSessionId, tenantId})`,\n`findActiveAgentSessions({tenantId, agentId, participantProfileId})`, and\n`getThread({threadId, tenantId})` are tenant-bound; consumers still check\nownership/context. `listRoomThreads({roomId, actorProfileId, tenantId})`,\n`getThreadMessages({threadId, actorProfileId, tenantId, limit?})` (chronological),\n`getRoomMessages({roomId, actorProfileId, tenantId})`, and\n`getRoomForMember(roomId, actorProfileId, tenantId)` additionally require\nmembership of the server-supplied actor, not a caller-selected subject.\n\nTrusted agent runtime imports `sendAgentReply(service, params)` only from\n`@happyvertical/smrt-chat/internal/agent-runtime`. It is not a `ChatService`\nmethod or package-index export. It authors as `session.agentProfileId` — the\nagent's resolved `bot` Profile, NEVER the `agentId` slug (#2995) — accepts a\nsame-room/tenant thread, and enforces `allowedTools` fail-closed.\n\nPrivate `#writeMessage` alone can select arbitrary authors/roles or bypass\nmembership. It binds every supplied `threadId`, `agentSessionId`, and\n`replyToMessageId` to the same room **and** tenant. Internal enrollment supports\nautomatically created rooms, sessions, and participants.\n\n## Agent Tool Whitelisting\n\n`allowedTools` is a JSON array controlled by the consuming app. Fail-closed: an empty/unparseable whitelist permits NO tools. The internal `sendAgentReply(service, params)` function enforces the whitelist before emitting any `tool`/`tool_call` message; a caller cannot supply a `senderProfileId`/`role` to post as the agent, and the function is not reachable from the package index.\n\nPrincipal-bound data discovery and reads are available as `PrincipalTool[]` via\n`createDataSurfaceTools()` (re-exported by the chat package). Pass the tools as\n`extraTools` to the persona conversation/tool loop. They use the same\nfail-closed `allowedTools` offer/execution gates; RBAC, tenant, redaction,\nbounded query results, and audit authority remain in the authenticated\n`PrincipalRun` supplied by `@happyvertical/smrt-agents`.\n\n## Commerce money tools (#3937)\n\nHosts that offer invoice money work must explicitly register\n`createCommerceMoneyTools()` from `@happyvertical/smrt-commerce` in\ntheir authenticated assistant route's `extraTools` (for example, `extraTools: () => createCommerceMoneyTools()`) and\nadd only the desired `commerce.*` slugs to the persona's `allowedTools`.\nThey are not generic manifest CRUD tools: tax codes are selected by code,\npreview is calculator-only, and line writes run through the document-money\ncoordinator. Each execution reasserts the principal allow-list and required\n`Invoice`, `InvoiceLineItem`, `DocumentTax`, and `TaxCode` operations. The\ngenerated MCP invoice `get` serializer remains commerce-owned; use its\nstored-facts integration when that serializer exposes `DocumentTax` rows.\n\n## Runtime report tools (#3711)\n\n`createRuntimeReportTools()` (`runtime-report-tools.ts`) returns four\n`PrincipalTool`s for the persona `extraTools` seam: `reports.runtime.sources`,\n`reports.runtime.define` (`preview` / `apply`), `reports.runtime.list`, and\n`reports.runtime.run`. The model supplies only a declarative\n`RuntimeReportSpec` from `@happyvertical/smrt-reports`; sources are a\nserver-owned allow-list gated by `run.assertOperation(collection, 'read')`, and\nfield policy, `readPermission`, and tenancy are enforced by the compiler against\nthe live run on every compile and every stored-report run. `apply` needs the\n`specHash` of the previewed spec plus an app-owned `confirmation` host that\nresolves only after a human approved that exact spec; with no host apply returns an `awaiting_confirmation` proposal for the\nsame-origin browser confirm route and stores nothing and a model-supplied `confirmed` flag is ignored. Saving also needs\n`create` on the `RuntimeReport` collection, and `list`/`run` need `read`; the\ndefault `reportsCollection` is the `RuntimeReport` class itself, which resolves\nto the catalog slug. A string `collection`/`reportsCollection` is used verbatim\nas a catalog slug (never a class name); tests must run the tools under the real\n`assertOperationPermission` guard so a wrong slug fails. A stored report is\nwritten only by this confirmed `apply`: the model layer refuses every other\ninsert/spec change, and the generic manifest tools (`buildManifestToolCatalog`,\n`invokeManifestTool`) never offer or run a `RuntimeReport` write. Stored-report\nreads/saves run under the principal's tenant (`withPrincipalTenant`), refuse a\nmismatching ambient tenant (checked before `confirmSave`), and filter by the principal tenant explicitly. Contract and authority model:\n[`packages/reports/agents/runtime-reports.md`](../reports/agents/runtime-reports.md).\n\n## Overview tools (#3727)\n\n`createOverviewTools({ host })` (`overview-tools.ts`) returns\n`overviews.describe`, `overviews.apply` (an atomic batch of structured widget\noperations) and `overviews.undo` (single step, keyed by tenant, user and page).\nThe host opens a page per `PrincipalRun` (smrt-svelte's\n`createOverviewAssistantSurface`, typed structurally here); validation and\n`canCustomize` are the surface's. Contract:\n[agents/overview-tools.md](agents/overview-tools.md).\n\n## Conversational Harness (L3, #1891)\n\nThe `AgentSession` runtime depends on personas, agents, and users. Keep those\nedges acyclic: none of those packages may depend back on chat.\n\n- **`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).\n- **`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).\n- **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.\n- **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.\n\n## Voice Gateway Turns (#1910)\n\nVoice is an input mode for the existing persona chat harness, not a separate chat runtime. `createVoiceChatSession()` creates a short-lived `VoiceSession` for an authenticated actor/profile, binding tenant, persona, agent session, room, and optional thread. `handleVoiceGatewayTurn()` resolves that binding from `metadata.voiceSessionId`, checks the gateway's `session_id` and any supplied tenant/profile/persona/session/thread metadata against the server-side binding, persists the transcript through `ChatService.sendAgentUserMessage()`, runs `runPersonaConversationTurn()`, stamps voice/correlation metadata onto the persisted user/assistant/tool messages, records the gateway `turn_id`, and returns the gateway response contract. The Fetch-compatible `createVoiceGatewayTurnHandler()` adds the coarse gateway bearer-token check.\n\nThe gateway bearer token proves only \"this request came from the gateway\"; it never authorizes the end user. The short-lived `VoiceSession` binding is the user/session proof, and untrusted gateway metadata must be validated against that binding before any chat write or tool loop. Tool execution remains fail-closed through the persona allow-list mirrored onto `AgentSession` by `bindPersonaToSession()`.\n\n## Token streaming\n\n`chat-stream.ts` serves browser-safe SSE through `./client`. The host's\n`authorize(request, body)` is the sole trust boundary: resolve identity, tenant,\ncapabilities, and generation limits server-side; never authorize from request\nsession metadata. Persona turns reuse the principal and fail-closed tool gates.\nThe engine and browser-safe `SmrtChatBackend` keep custom-tool resolution\nserver-side. See [agents/token-streaming.md](agents/token-streaming.md) for the\nevent contract, CORS policy, and streaming behavior.\n\n## Streamed assistant turns with browser tools (#2908)\n\n`runAssistantTurn()` (`assistant-turn.ts`) is the host-route engine for the\nAssistantDock: one turn over `runToolLoop` with server tools (offer-gated by\n`principal.allowedTools`), browser tools (validated by\n`sanitizeClientToolDeclarations` + a server allow-list), `maxSteps`, `signal`,\nand `onUsage`. A browser tool call SUSPENDS the turn (`stoppedReason:\n'client_tools'`); the transcript waits in an `AssistantContinuationStore`\n(single-use, 15-minute TTL; `createSessionContinuationStore` keeps it in the\nAgentSession's `sessionContext`) and the browser resumes it with results,\nwhich reach the model wrapped `untrusted`. `createAssistantTurnResponse`\nserves the events as SSE; `assistant-turn-events.ts` is the browser-safe wire\ncontract (`./assistant-turn` subpath, also a vite library entry because the\nSvelte dock imports it). The dock decides whether a browser call runs or waits\nfor the user from the page registry, never the server's echo; destructive\nalways waits. Details: [`docs/assistant-dock.md`](../../docs/assistant-dock.md).\n\n## AssistantDock (#2904)\n\n`AssistantDock` (`svelte/components/assistant/`, exported from `./svelte`)\nuses a host `DataSurfaceRegistry`'s mounted descriptors (none: plain chat).\nActions: `normalizeDataSurfaceActionRequest` → `AssistantActionClient`\n(preview/apply over a server `DataSurfaceActionAdapter`, not the\n`data-surface-bridge.ts` channel). Generated `ChatThread`/`ChatMessage`\n`list`/`get` are tenant- not member-scoped; the dock never calls them.\n\n**Server routes (#3368).** `./sveltekit` `mountAssistantRoutes()` serves the\ndock from one `[...path]` route; `createAssistantHttp{Transport,ActionClient}`\n(`./svelte`) are its browser half. Principal from `event.locals` or\n`resolvePrincipal`; threads only from the actor's keyed session room in that\ntenant (else 404). `allowedTools` is fail-closed; without `tools` it offers\nthose manifest ops (an unprovided name is an error, #3414). `ai` defaults to\nthe config `ai` block. Pass `runtime`: a turn never keeps the RLS request tx\n(own `runAsPrincipal` tx). `clientRequestId` makes the row id a UUIDv5\n(`clientRequestMessageId`): the PK is the retry reservation. See\n[docs](../../docs/assistant-dock.md).\n\nStructured questions and page requests (#4100): [agents/assistant-questions.md](agents/assistant-questions.md).\n\n## Recipes (#3719)\n\n`src/recipes.ts` declares `chat.assistant` (the AssistantDock as a `header.end`\nshell widget, an `llm` provider, runtime `both`; help in\n`src/assistant.recipe.md`). Keep each recipe class self-contained. Details:\n[agents/recipes.md](agents/recipes.md).\n\n## Gotchas\n\n- **sessionContext, not context**: `context` is reserved for slug scoping. Use `getSessionContext()`/`updateSessionContext()` for agent memory.\n- **Agent rooms auto-created**: `roomType: 'agent'`, `maxParticipants` defaults to 2; the agent is enrolled as a member so its replies pass the membership check. `createAgentSession()` re-enrolls the participant AND the agent on the existing-session path, so legacy sessions created before the agent was enrolled self-heal.\n- **The agent's author is a Profile, not `agentId` (#2995)**: `senderProfileId`/`profileId` are `crossPackageRef`s to `Profile` and therefore uuid columns on PostgreSQL, so the slug fails the cast (`22P02`) and no agent reply can persist. `createAgentSession()` resolves the agent's `bot` Profile through `resolveAgentProfile()` in `@happyvertical/smrt-profiles` (created on first use, tenant-bound) and records it as `AgentSession.agentProfileId`; both enrolment and `sendAgentReply` use that uuid. A consumer whose agent already has an acting identity passes `agentProfileId` to skip resolution — the voice path does this with the persona's `actsAsProfileId`, so persona replies stay attributed to the configured acting profile. Like `actorProfileId`, `agentProfileId` is SERVER-supplied, never request input: it selects the author of every later assistant message. It is validated (`#requireAgentProfile`) to exist and be visible in the tenant and to differ from the acting participant, and it can never re-point a session that already resolved one — only a pre-#2995 session with none is backfilled. **Migration**: `agent_profile_id` is an ordinary additive manifest field, so a consumer adopts it the same way as any other — `smrt db:migrate` generates and applies the column from the manifest, and `db:status --parity` verifies it; the framework never creates application schema at runtime. It is nullable and needs no offline DATA backfill — a session created before #2995 resolves and persists its `agentProfileId`, and re-enrols the agent, on its first agent turn after the upgrade. Two pre-#2995 cohorts: a session whose `agentId` is an ordinary slug never committed an author on PostgreSQL (the cast failed), so there is nothing to repair there, while SQLite/DuckDB may hold `chat_messages`/`chat_participants` rows whose id column holds the slug — readable, but not joinable to `profiles`. A session whose `agentId` is already a Profile uuid (the voice path used to collapse a persona's `actsAsProfileId` into it) DID commit on PostgreSQL; that profile is ADOPTED as the author, tenant-checked and never the participant, so the conversation's author does not change and the two-seat room gains no third identity. Known one-time effect: because `voice.ts` no longer derives `agentId` from `actsAsProfileId`, a keyless `createVoiceChatSession()` for such a persona opens a new session and room instead of reusing the legacy one; the old room and its messages stay intact and readable, and resuming with an explicit `agentSessionId` is unaffected.\n- **Only SQLite-backed tests would miss this class of bug**: uuid columns accept any text on SQLite. `src/__tests__/agent-reply-postgres.test.ts` (`pnpm --filter @happyvertical/smrt-chat test:postgres`) pins the agent-reply path against real PostgreSQL. That suite runs in `postgres-tests.yml` on every same-repository PR and merge group (#2659); keep a cheap SQLite assertion alongside it anyway, since the default lane is SQLite-only (`chat-service.test.ts` asserts the author is the profile uuid, not the slug).\n- **Per-subject sessions need `sessionKey`**: `createAgentSession()` reuses ANY active session for the same `(agentId, participantProfileId, tenantId)`. Callers that open separate conversations per subject (e.g. one content-editor session per content id) MUST pass a stable `sessionKey` (stored in `sessionContext.__sessionKey`, read via `AgentSession.getSessionKey()`); otherwise a session opened for one subject is reused and its context overwritten for another, surfacing the wrong room/threads (S5 #1392). A keyed create never reuses a keyless/legacy session.\n- **Session expiry**: check `isActive()` before allowing messages (expiresAt or limit-based)\n- **DM identity**: derived from the deterministic per-tenant `canonicalDmRoomId()` and the authoritative `chat_participants` join, not client metadata; concurrent creates upsert onto one row.\n- **Tenant-bound lookups**: membership/session/DM lookups REQUIRE `tenantId` and always bind it into the WHERE clause (`findActiveMembership`/`isActiveMember`/`findActiveSession` take a required `tenantId`; AgentSession's `null` tenant is an explicit bound scope, not \"any tenant\") so they can never resolve a row from another tenant.\n",
4517
4517
  "moduleDocs": [
4518
4518
  {
4519
4519
  "path": "agents/dev-workbench.md",
@@ -4525,6 +4525,11 @@
4525
4525
  "module": "overview-tools",
4526
4526
  "content": "# Overview assistant tools (#3727 phase 4)\n\n`createOverviewTools({ host, undoStore?, audit?, maxOperations? })`\n(`src/overview-tools.ts`, package index) returns three `PrincipalTool`s for the\npersona / assistant-route `extraTools` seam. They let the assistant add and\nconfigure widgets on a customizable overview page (\"add a chart of overdue\ninvoices\") with structured operations, and undo its last change. The overview\nmodel, widget registry and option schemas are smrt-svelte's\n([overview-surfaces.md](../../smrt-svelte/agents/overview-surfaces.md)).\n\n| Slug (function name) | Arguments | Result |\n|---|---|---|\n| `overviews.describe` (`overviews-describe`) | `{ page? }` | `{ page, overview }`: allowed widget types with option fields (type, required, default, range, `choices`, page `models`), span range, the current widgets in order, `canCustomize`. Without `page`: `{ pages }` from `host.pages` |\n| `overviews.apply` (`overviews-apply`) | `{ page, operations }` | `{ page, changed, applied: [{ index, op, id }], undoToken, overview }`; `changed: false` and `undoToken: null` for a batch that changes nothing |\n| `overviews.undo` (`overviews-undo`) | `{ page, undoToken }` | `{ page, undone: true, overview }` |\n\nOperations (1 to `maxOperations`, default 20): `add { type, span?, options?,\nindex? }`, `configure { id, options }` (merged onto the current options; `null`\nclears a key to its default), `move { id, index }`, `resize { id, span }`,\n`remove { id }`. Option values are JSON primitives over the widget's closed\nfield vocabulary; there is no query, filter expression, URL or SQL anywhere.\n\n## Authority\n\n- **The host decides, per principal.** `host.open(run, pageId)` returns the\n page for that `PrincipalRun` or `null` (unknown and not offered answer the\n same 404). Build it with smrt-svelte's `createOverviewAssistantSurface`\n (`./overview/server`) from the page's `OverviewDefinition`, the\n principal's own stored override, `canCustomize` from the principal's role,\n and `persist`. Never derive any of these from model input except the page id.\n- **Tenant.** Like the runtime-report tools, with tenancy on a run without\n `run.context.tenantId` is refused (403 `tenant_required`), `host.open` and\n every surface call (including `persist`) run under the principal's tenant\n (entered when no tenant context is active), and an ambient tenant that\n differs from the principal's is refused (`DataSurfaceDeniedError`) unless\n the caller is in a system-context or super-admin path. The host scopes its\n reads and writes by `run.context.tenantId`.\n- **Validation is the overview model's.** The surface plans each batch with\n `planOverviewOperations` and checks the result with `checkOverviewOverride`\n (allowed set and `allowedIn`, page-confined `models`, option schemas, span\n ranges, the widget cap), so the assistant can only store an override the\n page's own save endpoint accepts. A batch is atomic.\n- **Errors** are `OverviewToolError` with `status`, `code`, `publicMessage`,\n `issues`. `runToolLoop` classifies 404/409/422 as `invalid_request` (the model\n sees `publicMessage`, which lists every issue as `#<n> <op>: <message>`, and is\n told to fix and retry) and 403 as `not_permitted`. Codes: `invalid_page`,\n `invalid_operations` (422), `unknown_page` (404), `tenant_required` (403),\n `not_allowed` (403,\n `canCustomize` false, on apply and on undo), `conflict` (409, apply lost a\n race with another save), `nothing_to_undo`, `changed_since`,\n `cannot_restore` (409).\n- **Writes are conditional.** `surface.persist(override)` answers\n `OverviewToolPersistResult` (`{ ok: true }` or `{ ok: false, reason:\n 'conflict' | 'not_allowed' | 'invalid', issues? }`) and must write only if\n the stored row is still the revision the surface was opened on. A save that\n lands between `host.open` and the write is a `conflict`: apply answers 409\n `conflict` (describe again, rebuild the batch), undo answers 409\n `changed_since` and keeps its entry. smrt-svelte's surface takes the loaded\n `revision` and passes `{ revision }` to its `persist` option, so the\n revision-guarded `save` of `@happyvertical/smrt-preferences`'\n `createOverviewStore` plugs in directly (see below).\n- **Undo** is single-step. Apply stores `{ token, before, after }` under\n `[tenantId, userId, pageId]` of the calling run; undo looks it up under the\n calling run only, so another principal's (or tenant's) token is simply not\n found. It refuses when the stored override is no longer `after` (someone\n changed the page since), re-checks `before` with `check`, persists it\n conditionally, and deletes the entry only after that write succeeded.\n Removal is compare-and-delete: `OverviewUndoStore.delete(key, token)` is a\n no-op unless the stored entry still carries that token, so an undo that\n finishes after a newer batch stored its entry never removes that entry.\n Storing is a conditional set: an entry's `createdAt` is stamped right after\n its batch's conditional write succeeded (strictly increasing per process),\n and `set` is a no-op when the stored entry is newer, so an older apply whose\n entry write lands late never replaces a newer batch's entry. Ordering by\n write-success time rather than serializing per key works across replicas\n sharing one store (a lock would only cover one process), and the revision\n guard already serializes the writes themselves; revisions are opaque here,\n so they cannot order entries. Across replicas the stamps rely on clocks\n agreeing to within the time between two applies by the same person on the\n same page.\n- **The undo store must outlive a request and a turn.** Without `undoStore`\n the tools use `defaultOverviewUndoStore()`, one in-memory store per process\n (30-minute TTL, 1000 keys), so tools built per turn\n (`extraTools: (context) => createOverviewTools(...)`) still undo an earlier\n turn's batch. Never pass a store created inside the per-turn factory. A\n multi-replica host passes one shared `OverviewUndoStore`, created once,\n whose `set` (newer `createdAt` wins) and `delete(key, token)` are atomic\n conditional operations.\n- **After a successful write the call never fails.** The undo entry is written\n after the write; if the store throws, apply still answers `changed: true`\n with `undoToken: null` and a `note` not to apply the batch again (a lost entry\n only costs the Undo, while an entry written first could later restore over a\n value the batch never wrote). Audit is best effort; failures go to\n `onError` (default `console.warn`).\n\n## Wiring to persistence (phase 3)\n\nThe surface is the only seam; this package has no table and no dependency on\nsmrt-svelte or `@happyvertical/smrt-preferences` (smrt-svelte depends on chat\nfor tests, so the types are structural). Phase 3 stores overview layouts in\n`@happyvertical/smrt-preferences` (table `_smrt_ui_preferences`, preference\nkind `overview`); its overview layer is `createOverviewStore({ db })`, built\nover the generic `createPreferenceStore({ db })` (pass `preferences` to share\none). Every store call acts as the ambient principal, which is the run's\nprincipal inside the tool loop, under the tenant the tools enter.\n\n```ts\nimport { createOverviewTools } from '@happyvertical/smrt-chat';\nimport {\n createOverviewStore,\n withTenantDefaults,\n} from '@happyvertical/smrt-preferences';\nimport { createOverviewAssistantSurface } from '@happyvertical/smrt-svelte/overview/server';\n\n// Module scope: created once, shared by every turn and request.\nconst overviewUndo = createSharedOverviewUndoStore(); // or omit for the process default\n\nconst overviewTools = (db: DatabaseInterface /* per turn */) => {\n const store = createOverviewStore({ db });\n return createOverviewTools({\n undoStore: overviewUndo,\n host: {\n async open(run, pageId) {\n const definition = overviewDefinitions.get(pageId);\n if (!definition) return null;\n const state = await store.load(definition, registry);\n if (!state.user) return null;\n return createOverviewAssistantSurface({\n // The user tier is a delta over the tenant default.\n definition: withTenantDefaults(definition, state.tenant.document),\n registry,\n override: state.user.override,\n revision: state.user.revision,\n canCustomize: state.canCustomize.user,\n // The page definition: the store merges the tenant tier itself.\n persist: (override, { revision }) =>\n store.save(definition, registry, { scope: 'user', override, revision }),\n });\n },\n },\n });\n};\n```\n\n`createSharedOverviewUndoStore` stands for the host's own shared store (any\n`OverviewUndoStore`). How the store's answer maps onto the tools:\n\n| `store.save(definition, registry, { scope, override, revision })` (`OverviewSaveResult`) | Surface / tool |\n|---|---|\n| `{ ok: true, override, revision }` | the surface follows the new `revision`; apply answers `changed: true` |\n| `{ ok: false, reason: 'conflict' }` (the loaded `revision` is stale, or a first write raced another; nothing is overwritten) | apply: 409 `conflict`; undo: 409 `changed_since`, entry kept |\n| `{ ok: false, reason: 'not_allowed' }` (no `overviews.personalize` / `overviews.customize`) | 403 `not_allowed` |\n| `{ ok: false, reason: 'invalid', issues }` (`checkOverviewOverride` refused it) | 422 `invalid_operations` |\n\n`revision` is `null` when the principal had no row yet; the first write then\ncreates it, and a concurrent first write answers `conflict`. Add the three\nslugs to the persona's / route's `allowedTools`.\n\n## In the browser\n\nWhen the overview is mounted on the page the dock runs on, use the browser\ntools instead: smrt-svelte's `createOverviewAssistant(controller)` +\n`useOverviewAssistantTools` register `overview_describe`, `overview_apply` and\n`overview_undo` as page tools (add `overview_*` to the route's\n`clientToolAllowList`). A batch lands through `controller.restore`, so the grid\nupdates live and the host's `onchange` persists it, and `OverviewAssistantUndo`\n(or a toast) offers Undo. Same operations, same validation, same error shape\n(returned as JSON, not thrown).\n\nTests: `src/overview-tools.test.ts` (contract against a structural surface) and\n`packages/smrt-svelte/src/components/overview/__tests__/assistant-tools.integration.test.ts`\n(these tools over the real model).\n"
4527
4527
  },
4528
+ {
4529
+ "path": "agents/tool-loop.md",
4530
+ "module": "tool-loop",
4531
+ "content": "# Tool loop termination and tool-call hygiene\n\n`runToolLoop()` (`src/tool-loop.ts`) runs one bounded\n`tool_call → observe → respond` turn. Both `runPersonaConversationTurn()` and\n`runAssistantTurn()` go through it, so every rule below holds for both.\n\n## Termination\n\n- Rounds that execute tools are capped by `maxSteps`\n (`DEFAULT_MAX_STEPS = 8`; `initialSteps` counts earlier legs of a resumed\n turn). `maxTotalTokens` (with `initialTokens`) and `deadline` end the turn\n early with `stoppedReason: 'budget'`.\n- **Forced final call (#4378).** At the cap, or once the budget is spent, the\n next round is offered no tools (`tools: undefined`, `toolChoice: 'none'`),\n and any tool calls the model still emits are discarded. That call alone gets\n the fixed `TOOL_LOOP_ANSWER_NOW_INSTRUCTION` as a temporary `user`\n instruction. If the transcript already ends with a user turn, it is added\n to a copy of that turn's text or multimodal content instead of introducing\n consecutive user roles that strict templates reject. Otherwise it is a new\n user message. It never enters the returned `messages` transcript; input\n messages, stored conversations, and continuations stay unchanged.\n\n## Blank answers and timeouts (#4379)\n\n- **Retry once, within budget.** A final round with blank content and no\n usable tool calls (none made, or discarded on a no-tools round) is retried\n once without tools, with `TOOL_LOOP_ANSWER_NOW_INSTRUCTION` appended to\n that call only, and `emptyRetried: true`. The retry is skipped when the\n token budget (`maxTotalTokens`) or `deadline` is already spent: the turn\n goes straight to `empty`. The forced final call itself is one uncapped\n call, so a spent budget still gets one answer attempt; only the retry is\n budget-gated. Each blank round emits an `empty_round` step event (no model\n text; `retry` says whether a retry follows). `runAssistantTurn` does not\n show it as a dock step.\n- **Report.** Still blank: `stoppedReason: 'empty'`, `content: ''`. A model\n call that throws a timeout (`AI_TIMEOUT`, `TIMEOUT`, `REQUEST_TIMEOUT`,\n `TimeoutError`, or an `AbortError` the caller's signal did not cause) ends\n `stoppedReason: 'timeout'` instead of failing or passing as an empty\n success; other errors still throw. When the final round was the forced\n no-tools call, `capReason` (`max_steps` | `budget`) keeps that cause\n alongside `empty`/`timeout`.\n- **Quiet stream ends (older SDKs).** SDKs <= 0.108.0 can end a timed-out\n stream quietly: no text, no tool calls, no finish reason. That shape is a\n suspected timeout only for an AI boundary that has already reported a\n finish reason in this process (so its absence is anomalous), and only when\n the retry ends the same way; then the turn is `timeout`. A boundary that\n never reports finish reasons, or a blank reply that has one, is `empty`.\n The \"has reported\" flag is kept per AI client object for the process\n lifetime, so one client that routes to providers with and without finish\n reasons can mislabel an `empty` turn as `timeout` (or the reverse).\n- **Timeouts are configurable, not derived.** `requestTimeoutMs` is\n forwarded as the per-call `timeout` (default: the provider's 120 s). It is\n not derived from `deadline`/`maxTurnMs`: those only stop new tool rounds\n and gate the retry.\n- **Fallback text.** Both callers store `resolveTurnReply(result,\n fallback)`: the content trimmed at its outer edges only (both paths\n alike; persona replies were stored untrimmed before), or\n `emptyAnswerFallback` / `DEFAULT_EMPTY_ANSWER_FALLBACK` when blank.\n `runPersonaConversationTurn` returns it as `reply` (plus `replyFallback`);\n voice and the chat stream use it. `runAssistantTurn` replaces its old\n `'Done.'`. The plain chat-stream path retries a blank stream once, then\n sends the fallback, or `CHAT_STREAM_TIMEOUT_ERROR` only under the\n quiet-end rule above.\n- **Stored metadata.** Every authored assistant reply carries\n `replyMetadataFor(result, reply)`: `metadata.stoppedReason` (enum),\n `metadata.capReason` when set, and `metadata.fallback` (`empty` |\n `timeout`) when the content is the fallback. Hosts read the stop reason\n from `turn.result.stoppedReason` (persona), `AssistantTurnResult` / the\n `done` event's `stoppedReason` and `capReason` (assistant), or the stored\n message's metadata. `isFallbackReply(message)` tells a fallback apart; the\n assistant route's and voice's history builders skip fallback replies so\n they are never replayed to the model as answers. The chat-stream paths\n (plain and persona) take history from the browser, which sends no\n metadata, so they recognise an assistant message whose text exactly\n equals the configured or default fallback text. All three replay the\n fixed `FALLBACK_HISTORY_PLACEHOLDER` in its place rather than dropping\n it: a drop would leave two user messages in a row, which strict chat\n templates (Gemma, Anthropic) reject. Hosts should hide feedback\n controls (thumbs, corrections) on a message where `isFallbackReply` is\n true: there is no model answer to rate.\n- **Dock.** The `done` event's `capReason` reaches the dock, which offers\n Continue for a capped turn even when it ended `empty` or `timeout`.\n- **Reasoning.** `AIResponse.reasoning` (newer SDKs, sdk#1459) is read\n defensively, capped at `MAX_TOOL_LOOP_REASONING_CHARS` code points, passed\n to `onReasoning` (forwarded by both callers; a throw is ignored) and\n returned as `result.reasoning` (the retry's, else the first round's).\n Reasoning can quote documents and tool results: send it only to logs with\n the same protection as the conversation. It is never persisted and never\n the answer unless the host opts in with `answerFromReasoning` — which\n stores raw chain-of-thought as the reply (`contentFromReasoning: true`).\n- **Budgets on the persona path.** `runPersonaConversationTurn` forwards\n `maxTotalTokens`, `deadline`, `toolChoice` and `requestTimeoutMs`\n (`runAssistantTurn` exposes them as `maxTurnTokens`/`maxTurnMs`).\n\n## Observation bounds\n\n- A server tool observation is serialized and capped at\n `MAX_SERVER_TOOL_OBSERVATION_CHARS` (16,000, the same bound as\n `MAX_CLIENT_TOOL_RESULT_CHARS` for browser results) before it enters the\n transcript (#4378). A longer one is cut and gets the fixed\n `SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER`, which says the result is\n incomplete and tells the model to narrow the request (filter, fewer fields,\n a smaller page, or a count). The marker carries no tool output.\n- The cut never splits a surrogate pair (it keeps one unit fewer instead);\n browser results (`appendClientToolResults`) are cut the same way.\n- Only the model's copy is capped: `ToolInvocation.observation` (handed to\n `onInvocation`, persisted as tool messages, audited) keeps the full value.\n- A tool returning `undefined` observes `null`; an unserializable result\n observes `{\"error\":\"unserializable_result\"}` instead of throwing.\n\n## Argument hygiene (#4378)\n\nArguments the model sends are never dropped silently; each case below is an\n`invalid_request` observation the model can correct and retry. Messages are\nvalue-free: they name the accepted shape, never the model's values.\n\n- **Malformed JSON.** Raw arguments that do not parse to a JSON object\n (malformed JSON, an array, a scalar) fail with code\n `TOOL_ARGUMENTS_MALFORMED`; the tool does not run and the invocation's\n `args` is `{}`. Blank or `null` arguments are a no-argument call. A browser\n tool call with malformed arguments is answered in the transcript and never\n suspends the turn.\n- **Manifest `read`.** Accepts only `id` (string), `where` (object of\n equality filters), `limit` (integer >= 1) and `offset` (integer >= 0). This\n is stricter than before, where these were dropped or defaulted silently:\n an unknown key such as `filter`, a numeric `id`, a non-object `where`, and\n a fractional, zero or string `limit` (or a negative or fractional `offset`)\n now fail with a retryable `invalid_request` (`TOOL_ARGUMENTS_INVALID`)\n instead of listing every row. The offered schema says\n `additionalProperties: false` with `integer` `limit`/`offset` minimums.\n- **`data.query`** (`@happyvertical/smrt-agents`). With a `request` object,\n the only other top-level key allowed is `surfaceId`; a sibling such as\n `filter` fails with `DataSurfaceRequestError` reason\n `DATA_QUERY_ARGUMENTS_UNEXPECTED`, naming only misplaced grammar keys. The\n flat form (request keys beside `surfaceId`, no `request`) still works.\n- **`surfaceId` placement** (`data.query`, `data.inspect`). A\n `request.surfaceId` string is lifted to the top level and removed from\n `request`; a `query` object standing in for `request`, or one that is\n `request`'s only key, is unwrapped (its keys are then validated as usual,\n so nothing is dropped; unwrapping was chosen over rejecting because the\n intent is unambiguous). Two different ids are\n `DATA_QUERY_SURFACE_ID_CONFLICT`; no id at all is a 400\n `DATA_QUERY_SURFACE_ID_REQUIRED` with an example. Only an id naming no\n visible surface gets the generic \"not available\" denial. A filter `kind`\n that is an operator (`in`) or a logical word (`or`) gets a targeted hint.\n- **Valid examples.** Every `data.query` request error ends with a one-line\n `Valid example: {\"surfaceId\":…,\"request\":{…}}` for that surface, in the\n failed request's mode (count, rows or facets), built from the surface id\n and caller-visible field ids with `<value>` placeholders — never the\n caller's own values. Row examples cap page size at the surface’s\n `maxPageLimit`.\n\n## Dedupe of identical read-only calls (#4382)\n\nWithin one `runToolLoop` call, a server call that repeats an earlier one —\nsame tool, same arguments after canonicalization (object keys sorted) — is\nnot executed again. Its invocation has `deduped: true`, mirrors the earlier\n`ok`/`error`, and observes the fixed `TOOL_CALL_DEDUPED_NOTE` instead of a\nsecond copy of the result.\n\n- Only read-only, idempotent tools qualify: manifest `read`, and\n `data.discover`, `data.inspect`, `data.query`. Mutating tools,\n `agents.invoke`, other extra tools and browser tools never do; nor do\n malformed-argument calls.\n- **Invalidation.** Any resolved server call that is not on that allow-list\n (a write, `agents.invoke`, any other extra tool), whatever its result,\n clears every remembered read, so a read after a write always runs fresh.\n- A repeat of a rejected or refused call observes\n `TOOL_CALL_DEDUPED_REJECTED_NOTE` (repeating it will not work; fix the\n arguments) instead of the plain pointer note.\n- An earlier `execution_error` is not reused: a transient server failure\n may be retried. Arguments over 4,000 canonical characters are never keyed.\n- The cache holds at most `MAX_DEDUPED_CALLS_PER_TURN` (64) calls and lives\n only inside that `runToolLoop` call: never across turns (an assistant\n resume leg starts a fresh cache).\n- Deduped calls count toward the step cap: a round of repeats is still a\n round, so a model stuck repeating a call still stops at `maxSteps`.\n- The audit sink gets `action: 'chat.tool_call_deduped'` (not a fresh\n execution or failure); the persona path's tool row carries\n `toolCallData.deduped: true`.\n\n## Failed calls are persisted (#4383)\n\nEvery tool invocation records `modelContent`, the exact (capped) text the\nmodel was shown. `toolFailureRecord(invocation)` turns a failed, rejected or\ndenied call into a bounded record: `name`, `args` (over\n`MAX_TOOL_FAILURE_ARGS_CHARS` = 2,000 serialized characters they become\n`{ truncated: true }`; unserializable ones `{ unserializable: true }`;\nmalformed-JSON calls carry `{}`), `status` (`rejected` | `error`),\n`errorKind`, `errorCode` (the error's own stable `A-Z0-9_` code, else the\nkind) and `shown`. Like a successful call's row it carries the arguments\nand shown text, so it is not value-free. A deduped repeat has no record.\n\n- `runPersonaConversationTurn` authors each failed call as a `tool_result`\n row: content = `shown`, `toolCallData` `{ name, args, status, errorCode }`,\n `metadata` `{ toolStatus, errorKind, errorCode }`.\n- `runAssistantTurn` now does the same **by default** when an `author` is\n set — a behaviour change: before, failed calls were never persisted.\n `author.authorFailedInvocation` overrides the row or returns `null` to\n skip it; `authorInvocation` sees successful calls only (never a failed or\n deduped-failed one). A failed row's write error is not a dock step.\n- `runToolLoop` sends the audit sink `action: 'chat.tool_call_failed'` with\n only `toolFailureAuditMetadata(record)`: `name`, `status`, `errorKind`,\n `errorCode`, `argsChars`, `shownChars` — never the arguments or the shown\n text, which can hold user data or raw server errors. A sink throw never\n fails the turn.\n- A browser tool call with malformed arguments is recorded the same way (an\n invocation, an audit entry, `onInvocation`), besides being answered in\n the transcript.\n- Gap: a call to a tool the session does not allow-list cannot be a tool row\n — `sendAgentReply`'s authoring gate refuses the name, and that gate is\n unchanged — so it reaches the audit sink only.\n\n## Tool errors\n\nA thrown tool error is classified by `classifyToolError`: permission denials\nand 401/403 are `not_permitted` (reported as a rejection); a `ValidationError`\nor 400/404/409/422 is `invalid_request` (observation: the actionable message,\n`publicMessage` first, its `code`, and a fix-and-retry hint); everything else,\nincluding 429, is `execution_error`. An `execution_error` observation\ncarries the error's message, its stable `code` when it has one (e.g.\n`DATA_SURFACE_QUERY_FAILED`), and the fixed `TOOL_EXECUTION_ERROR_HINT`:\nthe failure is the server's, so the model should not resend the same call\nbut answer with what it has or tell the user (#4378).\n"
4532
+ },
4528
4533
  {
4529
4534
  "path": "agents/token-streaming.md",
4530
4535
  "module": "token-streaming",
@@ -27,6 +27,13 @@ export interface AssistantHttpOptions {
27
27
  export interface AssistantHttpTransportOptions extends AssistantHttpOptions {
28
28
  /** When set, the dock renders `ModelPicker`; the server checks the choice. */
29
29
  models?: ModelOption[];
30
+ /**
31
+ * A JSON object sent as `context` with every send and resume, for the
32
+ * server's per-request callbacks (`AssistantRequestContext.requestContext`),
33
+ * e.g. the surfaces the page has mounted. A function is read per request.
34
+ * The server caps it (8 KiB) and treats it as untrusted.
35
+ */
36
+ context?: Record<string, unknown> | (() => Record<string, unknown>);
30
37
  }
31
38
  /** A non-2xx answer from the assistant routes. `message` is user-safe. */
32
39
  export declare class AssistantHttpError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-http-client.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/assistant-http-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EACV,wBAAwB,EAExB,mBAAmB,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAOL,KAAK,kBAAkB,EAGvB,KAAK,WAAW,EAIjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE,4DAA4D;IAC5D,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED,wDAAwD;AACxD,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IACzE,8EAA8E;IAC9E,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,0EAA0E;AAC1E,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;gBAFjC,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,SAAS;CAKpC;AAiFD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,kBAAkB,CAgFpB;AAED,2DAA2D;AAC3D,MAAM,WAAW,gCAAiC,SAAQ,oBAAoB;IAC5E;;;;OAIG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;IAChD,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,MAAM,GAAG,SAAS,CAAC;CAC9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,qBAAqB,CAkEvB"}
1
+ {"version":3,"file":"assistant-http-client.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/assistant-http-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EACV,wBAAwB,EAExB,mBAAmB,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAOL,KAAK,kBAAkB,EAGvB,KAAK,WAAW,EAIjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE,4DAA4D;IAC5D,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED,wDAAwD;AACxD,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IACzE,8EAA8E;IAC9E,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrE;AAED,0EAA0E;AAC1E,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;gBAFjC,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,SAAS;CAKpC;AAiFD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,kBAAkB,CAyFpB;AAED,2DAA2D;AAC3D,MAAM,WAAW,gCAAiC,SAAQ,oBAAoB;IAC5E;;;;OAIG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;IAChD,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,MAAM,GAAG,SAAS,CAAC;CAC9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,qBAAqB,CAkEvB"}
@@ -92,6 +92,12 @@ export function createAssistantHttpTransport(options) {
92
92
  body: JSON.stringify(body),
93
93
  ...(signal ? { signal } : {}),
94
94
  });
95
+ const contextField = () => {
96
+ const value = typeof options.context === 'function'
97
+ ? options.context()
98
+ : options.context;
99
+ return value ? { context: value } : {};
100
+ };
95
101
  const threadPath = (threadId, leaf) => `/threads/${encodeURIComponent(threadId)}/${leaf}`;
96
102
  return createSmrtAssistantTransport({
97
103
  readEndpoint: base,
@@ -117,6 +123,7 @@ export function createAssistantHttpTransport(options) {
117
123
  ...(input.clientTools?.length
118
124
  ? { clientTools: input.clientTools }
119
125
  : {}),
126
+ ...contextField(),
120
127
  }, input.signal);
121
128
  return readTurn(response, input.onEvent);
122
129
  },
@@ -129,6 +136,7 @@ export function createAssistantHttpTransport(options) {
129
136
  ...(input.clientTools?.length
130
137
  ? { clientTools: input.clientTools }
131
138
  : {}),
139
+ ...contextField(),
132
140
  }, input.signal);
133
141
  return readTurn(response, input.onEvent);
134
142
  },
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-transport.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/assistant-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EAExB,MAAM,mCAAmC,CAAC;AAC3C;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAE5E,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;qEAKiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,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AAI,CAAC;CACpD,GACA,OAAO,CAAC,0BAA0B,CAAC,CAsCrC"}
1
+ {"version":3,"file":"assistant-transport.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/assistant-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EAExB,MAAM,mCAAmC,CAAC;AAC3C;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAE5E,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;qEAKiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE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ClD,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,gBAAgB,EAAE,CAIpB;AAED,MAAM,WAAW,6BAA6B;IAC5C;;;;;;;sEAOkE;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd;;;;+CAI2C;IAC3C,aAAa,CAAC,EAAE;QACd,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAClE,WAAW,EAAE,CACX,KAAK,EAAE,yBAAyB,KAC7B,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACzC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACnE;8CACsC;QACtC,UAAU,CAAC,EAAE,CACX,KAAK,EAAE,wBAAwB,KAC5B,OAAO,CAAC,0BAA0B,CAAC,CAAC;KAC1C,CAAC;IACF;;6EAEyE;IACzE,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAkBD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,kBAAkB,CA2DpB;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvE,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE;IACP,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,gBAAgB,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACpD,GACA,OAAO,CAAC,0BAA0B,CAAC,CAyCrC"}
@@ -332,6 +332,9 @@ export async function readAssistantTurnResult(response, options) {
332
332
  options.onEvent({
333
333
  type: 'done',
334
334
  stoppedReason: event.stoppedReason,
335
+ // Why tools were withdrawn, kept when the turn then ended `empty`
336
+ // or `timeout` (#4379): the dock still offers Continue.
337
+ ...(event.capReason ? { capReason: event.capReason } : {}),
335
338
  ...(event.message
336
339
  ? { message: options.mapMessage(event.message) }
337
340
  : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"create-assistant-dock-controller.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/create-assistant-dock-controller.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAGzB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EAGV,eAAe,EACf,iBAAiB,EAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAEnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAG7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAEhB,sBAAsB,EACtB,kBAAkB,EAElB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EAG1B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,0BAA0B,GAClC,SAAS,GACT,YAAY,GACZ,OAAO,GACP,QAAQ,CAAC;AAEb,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACxC;AAED,sEAAsE;AACt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C,IAAI,CAAC,CAAC;IAC5C,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,KAAK,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,gFAAgF;IAChF,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAC9E;;;;OAIG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE;+EAC2E;IAC3E,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C;;iEAE6D;IAC7D,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,YAAY,IAAI,IAAI,CAAC;IACrB,WAAW,IAAI,IAAI,CAAC;IACpB;;;;;;2EAMuE;IACvE,YAAY,IAAI,IAAI,CAAC;IACrB;;;;;;gBAMY;IACZ,YAAY,IAAI,IAAI,CAAC;IACrB;;;;;;;;mCAQ+B;IAC/B,aAAa,IAAI,IAAI,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC;CACjB;AA0BD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,uBAAuB,CAk8DzB"}
1
+ {"version":3,"file":"create-assistant-dock-controller.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/create-assistant-dock-controller.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;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AAC,CAAC;IAC9C,gFAAgF;IAChF,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAC9E;;;;OAIG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE;+EAC2E;IAC3E,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C;;iEAE6D;IAC7D,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,YAAY,IAAI,IAAI,CAAC;IACrB,WAAW,IAAI,IAAI,CAAC;IACpB;;;;;;2EAMuE;IACvE,YAAY,IAAI,IAAI,CAAC;IACrB;;;;;;gBAMY;IACZ,YAAY,IAAI,IAAI,CAAC;IACrB;;;;;;;;mCAQ+B;IAC/B,aAAa,IAAI,IAAI,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC;CACjB;AA0BD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,uBAAuB,CAu8DzB"}
@@ -1050,10 +1050,16 @@ export function createAssistantDockController(options) {
1050
1050
  return;
1051
1051
  case 'done':
1052
1052
  streamingText = '';
1053
- if (runCore &&
1054
- (event.stoppedReason === 'max_steps' ||
1055
- event.stoppedReason === 'budget')) {
1056
- runCore = { ...runCore, stoppedReason: event.stoppedReason };
1053
+ {
1054
+ // A capped turn is continuable even when it then ended `empty`
1055
+ // or `timeout` (#4379): its `capReason` keeps the cap cause.
1056
+ const cap = event.stoppedReason === 'max_steps' ||
1057
+ event.stoppedReason === 'budget'
1058
+ ? event.stoppedReason
1059
+ : event.capReason;
1060
+ if (runCore && cap) {
1061
+ runCore = { ...runCore, stoppedReason: cap };
1062
+ }
1057
1063
  }
1058
1064
  return;
1059
1065
  default:
@@ -81,6 +81,15 @@ export type AssistantPrincipalResolver = (event: AssistantRouteEvent) => Assista
81
81
  export interface AssistantRequestContext {
82
82
  event: AssistantRouteEvent;
83
83
  principal: AssistantPrincipal;
84
+ /**
85
+ * The client-supplied `context` object of a send or resume body (for
86
+ * example the surfaces the page has mounted), validated to be a plain JSON
87
+ * object of at most {@link MAX_ASSISTANT_REQUEST_CONTEXT_BYTES} bytes.
88
+ * Present only on the callbacks of a send or resume; absent when the client
89
+ * sent none. It is untrusted request input: use it to narrow, never to
90
+ * grant.
91
+ */
92
+ requestContext?: Readonly<Record<string, unknown>>;
84
93
  }
85
94
  /** A value, or a per-request callback producing it. */
86
95
  export type AssistantRouteValue<T> = T | ((context: AssistantRequestContext) => T | Promise<T>);
@@ -178,6 +187,17 @@ export interface MountAssistantRoutesOptions {
178
187
  resolvePrincipal?: AssistantPrincipalResolver;
179
188
  /** The assistant's agent id (its `bot` profile slug). Default `smrt-assistant`. */
180
189
  agentId?: string;
190
+ /**
191
+ * Session key of the dock's `AgentSession`. Default
192
+ * {@link ASSISTANT_DOCK_SESSION_KEY} (`assistant-dock`). A host whose
193
+ * assistant threads already live in another session passes that session's
194
+ * key to list and continue them: `null` adopts the person's unkeyed session
195
+ * (what `ChatService.createAgentSession` opens without a `sessionKey`), a
196
+ * string adopts the session stored under that key. Sessions are matched on
197
+ * the key exactly, so a host changing it from the default stops seeing the
198
+ * threads of the old key.
199
+ */
200
+ sessionKey?: string | null;
181
201
  systemPrompt?: AssistantRouteValue<string | undefined>;
182
202
  /**
183
203
  * Server tool allow-list, fail-closed: absent or empty offers NO tools.
@@ -216,6 +236,10 @@ export interface MountAssistantRoutesOptions {
216
236
  maxSteps?: number;
217
237
  maxTurnTokens?: number;
218
238
  maxTurnMs?: number;
239
+ /** Per-model-call timeout in ms (see `AssistantTurnOptions`, #4379). */
240
+ requestTimeoutMs?: number;
241
+ /** Reply stored when the turn produced no answer (#4379). */
242
+ emptyAnswerFallback?: string;
219
243
  maxTokens?: number;
220
244
  temperature?: number;
221
245
  /** Earlier messages sent with a new turn. Default 20. */
@@ -317,6 +341,8 @@ export interface AssistantDuplicateSendWire {
317
341
  export declare const DEFAULT_ASSISTANT_AGENT_ID = "smrt-assistant";
318
342
  /** Session key isolating the dock's session from other uses of the agent id. */
319
343
  export declare const ASSISTANT_DOCK_SESSION_KEY = "assistant-dock";
344
+ /** Largest serialized `context` object a send or resume body may carry. */
345
+ export declare const MAX_ASSISTANT_REQUEST_CONTEXT_BYTES: number;
320
346
  /** Default JSON body cap. */
321
347
  export declare const DEFAULT_ASSISTANT_MAX_BODY_BYTES: number;
322
348
  /** Default attachment cap. */
@@ -1 +1 @@
1
- {"version":3,"file":"sveltekit.d.ts","sourceRoot":"","sources":["../src/sveltekit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAOlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAE7B,KAAK,iBAAiB,EAKvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAQzD,OAAO,EAKL,KAAK,YAAY,EAEjB,KAAK,cAAc,EACnB,KAAK,aAAa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