@happyvertical/smrt-chat 0.61.6 → 0.62.1

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 (67) hide show
  1. package/AGENTS.md +4 -0
  2. package/agents/assistant-turn-runs.md +74 -0
  3. package/agents/tool-summaries.md +1 -1
  4. package/agents/turn-drivers.md +64 -46
  5. package/dist/assistant-approvals.js +1 -1
  6. package/dist/assistant-approvals.js.map +1 -1
  7. package/dist/assistant-turn-driver.d.ts +11 -8
  8. package/dist/assistant-turn-driver.d.ts.map +1 -1
  9. package/dist/assistant-turn-events.d.ts +1 -1
  10. package/dist/assistant-turn-events.d.ts.map +1 -1
  11. package/dist/assistant-turn.d.ts +34 -3
  12. package/dist/assistant-turn.d.ts.map +1 -1
  13. package/dist/chunks/{ChatService-CeOVzOqN.js → ChatService-CDLAEJms.js} +2 -2
  14. package/dist/chunks/{ChatService-CeOVzOqN.js.map → ChatService-CDLAEJms.js.map} +1 -1
  15. package/dist/chunks/assistant-turn-events-DwdCZzQ0.js.map +1 -1
  16. package/dist/chunks/{chat-stream-Cl8JV-K0.js → chat-stream-CTYRRbHD.js} +742 -254
  17. package/dist/chunks/chat-stream-CTYRRbHD.js.map +1 -0
  18. package/dist/engines.d.ts +4 -4
  19. package/dist/engines.d.ts.map +1 -1
  20. package/dist/engines.js +22 -24
  21. package/dist/engines.js.map +1 -1
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +3 -3
  25. package/dist/internal/agent-runtime.js +1 -1
  26. package/dist/manifest.json +2 -1
  27. package/dist/smrt-knowledge.json +28 -10
  28. package/dist/smrt-knowledge.okf.md +16 -11
  29. package/dist/svelte/components/assistant/AssistantDock.svelte +2 -2
  30. package/dist/svelte/components/assistant/FloatingAssistant.svelte +5 -6
  31. package/dist/svelte/components/assistant/FloatingAssistant.svelte.d.ts +2 -7
  32. package/dist/svelte/components/assistant/FloatingAssistant.svelte.d.ts.map +1 -1
  33. package/dist/svelte/components/assistant/assistant-http-client.d.ts +2 -2
  34. package/dist/svelte/components/assistant/assistant-http-client.d.ts.map +1 -1
  35. package/dist/svelte/components/assistant/assistant-http-client.js +5 -5
  36. package/dist/svelte/components/assistant/assistant-transport.d.ts +8 -7
  37. package/dist/svelte/components/assistant/assistant-transport.d.ts.map +1 -1
  38. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts +3 -3
  39. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts.map +1 -1
  40. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.js +30 -30
  41. package/dist/svelte/components/shared/AiUnavailableNotice.svelte +5 -10
  42. package/dist/svelte/components/shared/AiUnavailableNotice.svelte.d.ts +2 -9
  43. package/dist/svelte/components/shared/AiUnavailableNotice.svelte.d.ts.map +1 -1
  44. package/dist/svelte/components/shared/ModelPicker.svelte +5 -5
  45. package/dist/svelte/components/shared/ModelPicker.svelte.d.ts +2 -4
  46. package/dist/svelte/components/shared/ModelPicker.svelte.d.ts.map +1 -1
  47. package/dist/svelte/i18n.d.ts +1 -1
  48. package/dist/svelte/i18n.js +1 -1
  49. package/dist/svelte/index.d.ts +3 -5
  50. package/dist/svelte/index.d.ts.map +1 -1
  51. package/dist/svelte/index.js +1 -1
  52. package/dist/svelte/types.d.ts +16 -0
  53. package/dist/svelte/types.d.ts.map +1 -1
  54. package/dist/sveltekit.d.ts +55 -24
  55. package/dist/sveltekit.d.ts.map +1 -1
  56. package/dist/sveltekit.js +109 -44
  57. package/dist/sveltekit.js.map +1 -1
  58. package/dist/tool-loop.d.ts +2 -1
  59. package/dist/tool-loop.d.ts.map +1 -1
  60. package/dist/tool-run-types.d.ts +102 -0
  61. package/dist/tool-run-types.d.ts.map +1 -0
  62. package/dist/turn-tracking.d.ts +246 -0
  63. package/dist/turn-tracking.d.ts.map +1 -0
  64. package/package.json +22 -21
  65. package/dist/chunks/chat-stream-Cl8JV-K0.js.map +0 -1
  66. package/dist/work-profile.d.ts +0 -64
  67. package/dist/work-profile.d.ts.map +0 -1
package/AGENTS.md CHANGED
@@ -181,6 +181,10 @@ Durable owner approvals of destructive server tools: [agents/owner-approvals.md]
181
181
  Tool summaries and inference engine adapters: [agents/tool-summaries.md](agents/tool-summaries.md).
182
182
  Live cookbook exposure of manifest tools: [agents/runtime-exposure.md](agents/runtime-exposure.md).
183
183
 
184
+ ## Assistant turns as AI runs (#5005)
185
+
186
+ Each turn opens one `turn` run and sends every model call through core's tracked client; the system prompt is the registered `chat.assistant.system` prompt. Details: [agents/assistant-turn-runs.md](agents/assistant-turn-runs.md).
187
+
184
188
  ## AssistantDock (#2904)
185
189
 
186
190
  `AssistantDock` (`svelte/components/assistant/`, exported from `./svelte`)
@@ -0,0 +1,74 @@
1
+ # Assistant turns as AI runs (#5005)
2
+
3
+ `mountAssistantRoutes` builds a tracked client per turn
4
+ (`createTrackedAiClient`, the principal's tenant on the request's database,
5
+ over the turn's client, `transcript: false` because chat stores the
6
+ conversation) and passes `tracking` to `runAssistantTurn`
7
+ (`turn-tracking.ts`). The turn then opens one `turn` run before its first
8
+ model call (`AssistantTurnRun.open`, definition `chat.assistant.turn`), the
9
+ tool loop calls the tracked client (each model call is a reserved, settled
10
+ call of the run: one usage row and one `call` event, tagged with the prompt
11
+ key), tool use is an `action` event and its result an `observation` event
12
+ whose `parent_event_id` is the action, and the run ends `done` (`cancelled`
13
+ for an abort, `failed` for an error). Messages are never copied into the
14
+ trajectory: events point at them with `payload_ref` (`chat-message:<id>`).
15
+ A turn that needs an owner approval records a requested `approval` event
16
+ (`payload_ref` `approval:<id>`) and ends `done` with the approval pending; it
17
+ does not wait. The decision is recorded as an `approval` event in the NEXT
18
+ turn's run, once, with `parent_event_id` the request in the earlier run
19
+ (`tracking.decisions` reads the thread's decided approvals from the host's
20
+ store). A chat turn does not run untracked: with usage persistence off it ends
21
+ with the user-facing error `ai_tracking_disabled` before any call is sent.
22
+ A ChatGPT plan turn is a built-in loop over a host-built client: its calls
23
+ are recorded under the engine (`label` on `createTrackedAiClient`, provider
24
+ `chatgpt`, the bound model unless the response reports one), uncosted, with
25
+ `tier_requested`/`tier_resolved` from the prompt and the selection.
26
+
27
+ ## A turn on an external engine (Claude Code, Codex)
28
+
29
+ An external `turnDriver` turn opens the same run. The engine's turn is ONE
30
+ tracked call of it (`AssistantTurnRun.beginEngineCall`, reserved in
31
+ `runExternalAssistantAttempt` before `driver.run`, call id minted first):
32
+ the engine runs its own loop and reports one result per turn, so its internal
33
+ model calls are not seen one by one. The usage row's provider is the engine
34
+ id, its model the one the CLI reported (Claude Code does; Codex does not),
35
+ else the tier binding's; it carries the prompt key and tiers and is always
36
+ uncosted. Tokens are the CLI's reported usage (`EngineExecution.tokens`,
37
+ split into `inputTokens`/`outputTokens`, cache reads and writes in the
38
+ input); a turn that answered without them is charged what it reserved (ai-runs
39
+ section 6.4) and its row has NULL token columns. A refused reservation
40
+ (`maxCalls`, `maxTokens`, `maxDurationMs`, or a parent's limit or stop) ends
41
+ the turn `budget` before the CLI starts; `callTimeoutMs` aborts the CLI and
42
+ fails the turn. A turn that fails, is cancelled or hands off to a workflow is
43
+ settled with its tokens when the CLI reported them, else released. Limits:
44
+ `maxSteps` cannot bound the CLI's internal rounds (a workflow parent's step
45
+ limit still refuses the child's call), and a parent stop or cancel during an
46
+ engine turn takes effect at its end, not by interrupting the CLI. Tests:
47
+ `sveltekit.test.ts` (external engine), `engines.test.ts` (real driver over
48
+ the stub CLI), `turn-tracking-child.test.ts`.
49
+
50
+ The system prompt is the registered prompt `chat.assistant.system`
51
+ (`chatAssistantSystemPrompt`): the host's `systemPrompt` option is its runtime
52
+ layer and an app or tenant override of the key replaces it
53
+ (`resolveChatAssistantPrompt`). The text is sent only when a layer above the
54
+ default supplies it, so a host with no `systemPrompt` sends no system message,
55
+ as before. The prompt declares the tier the assistant asks for, `ai.profile: 'best'`;
56
+ `resolveChatAssistantTier({ db, tenantId })` reads it back through
57
+ `resolvePrompt` (so config and stored layers apply) and a host binds the
58
+ turn's model at that tier.
59
+
60
+ ## A workflow step's turn (child run)
61
+
62
+ A host's trusted `internalTurn` may return `step: { parent, prompt,
63
+ stepIndex, name }` (the template-sveltekit host does, for each workflow step
64
+ it runs through the assistant route). The turn's run is then a CHILD of the
65
+ workflow run (`parent_run_id`, opened with a `handoff` event in the parent
66
+ named after the step, in the same transaction); its calls carry the parent's
67
+ claim fence and are tracked under the step's registered `prompt` (whose text
68
+ follows the host's system prompt), so they roll into the parent's inclusive
69
+ totals and budget. A parent stop or limit stops the child's next call, and
70
+ when the turn ends a stopped or cancelled child stops the parent the same way
71
+ (`stopAiRunForChild`); cancelling the parent cancels the child. The turn
72
+ closes the `handoff` with how the child ended. A step on an external engine
73
+ is the same child run with its one engine call. Tests:
74
+ `turn-tracking-child.test.ts`.
@@ -152,4 +152,4 @@ stub engines under the exact desktop `buildSidecarEnv` composition. No desktop
152
152
  production environment policy changed. Reuse the desktop environment helper via
153
153
  a test-only import; no duplicate environment builder is introduced.
154
154
 
155
- S1: canonical dotted `app.describe`, `app.history`, `recipes.search` and `recipes.describe` names use the existing person-facing summary table, including durable design steps. Unknown tool payloads remain hidden. ChatGPT failures pass their cause to inference's existing correlated failure reporter; only allow-listed codes and bounded `req_` or UUID request ids are logged, never exception messages or accounts.
155
+ S1: canonical dotted `app.describe`, `app.history`, `recipes.search` and `recipes.describe` names use the existing person-facing summary table, including durable workflow steps. Unknown tool payloads remain hidden. ChatGPT failures pass their cause to inference's existing correlated failure reporter; only allow-listed codes and bounded `req_` or UUID request ids are logged, never exception messages or accounts.
@@ -179,35 +179,54 @@ would introduce the prohibited `chat → smrt-svelte → smrt-content → chat`
179
179
  cycle. Production driver code introduces neither that import nor a new
180
180
  shell; no dependency change is appropriate for C1.
181
181
 
182
- ## Work profiles and design interception
183
-
184
- `resolveWorkProfile(context, name?)` selects intelligence from authenticated
185
- owner settings before authoring the user message. It receives a requested name
186
- only on escalation; known design flows select `design` in the initial callback.
187
- The resolved profile is forwarded to inference and its budgets govern the loop.
188
- Background work must request `background` explicitly. Profile selection never
182
+ ## Model selection, budget and workflow-only tools (#5005)
183
+
184
+ `resolveSelection(context)` returns the turn's `AssistantModelSelection`
185
+ (`engine`, `tier`, `model?`, `effort?`) from authenticated host state before
186
+ the user message is authored; a request body model is honoured only without
187
+ one. The host binds the tier: core for an API key, inference's
188
+ `engineTierModel` for Claude Code, Codex and a ChatGPT plan. The assistant asks
189
+ for the tier its prompt declares (`chat.assistant.system`, `best`;
190
+ `resolveChatAssistantTier`). The selection's effort is the tier
191
+ binding's; the assistant prompt's `ai.effort` wins over it, and the route
192
+ hands the result to the built-in loop (`reasoning: { effort }`) and to an
193
+ external driver (`context.selection.effort`). A body model is honoured only
194
+ where the selection names none (an API key). `turnBudget` (an `AiRunBudget`)
195
+ is stored on the turn's `turn` run (core enforces it on tracked calls; it
196
+ counts `maxSteps` only for calls with a step index, so the loop enforces a
197
+ turn's steps) and applied to the loop
198
+ (`maxSteps`, `maxTokens` → `maxTurnTokens`, `maxDurationMs` → `maxTurnMs`,
199
+ `callTimeoutMs` → `requestTimeoutMs`); a call core refuses at a budget limit
200
+ ends the turn `budget` with a plain reply. `maxTokens` (output per call) and
201
+ `toolResultChars` stay route options and may be per request. A selection never
189
202
  changes principal, tenant, permission ceiling, allow-list or owner approvals.
190
203
 
191
- Hosts declare structural tools with `designTools`, or trusted tool metadata
192
- `annotations.workProfile: 'design'` (core cookbook tools provide this annotation).
193
- The built-in loop checks the whole proposed batch before executing any call.
194
- External drivers MUST call `context.beforeToolExecution(canonicalSlug)` at their
195
- **authenticated MCP execution boundary**, before effects or approval creation.
196
- A later CLI tool-call stream event is too late. Interception aborts and settles
197
- the old pass, then restarts once under design while retaining completed tool
198
- observations. The intercepted assist call never executes.
199
-
200
- Production hosts use `onDesignEscalation(context, input)` to enqueue a durable
201
- design job. Returning `{runId, message?}` ends the request with `done.runId` and
202
- prevents inline restart. Without the hook, the shared bounded turn restarts
203
- inline once. `resolveWorkProfileRuntime` reselects an engine on that restart.
204
- `Thinking this through` identifies escalation using the existing status stream.
205
-
206
- Stored assistant rows contain `metadata.workRun`: profile, engine, actual model
207
- when reported by the engine, effort, cumulative tokens, duration, tool calls and
208
- fallback. `onWorkRun` receives the same sanitized accounting; the default logs
209
- one line. CLI adapters report observed execution through `callbacks.execution`;
210
- this also preserves spent assist work when escalation aborts its attempt.
204
+ Tools limited to workflow runs carry the trusted annotation
205
+ `annotations.runTypes: ['workflow']` (core cookbook tools provide it); hosts may
206
+ also list them in `workflowTools`. A chat `turn` run refuses such a call with a
207
+ typed `ToolRunTypeRefusal` before it executes. The built-in loop checks the
208
+ whole proposed batch before executing any call. External drivers MUST call
209
+ `context.beforeToolExecution(canonicalSlug)` at their **authenticated MCP
210
+ execution boundary**, before effects or approval creation. A later CLI
211
+ tool-call stream event is too late. The refused call never executes.
212
+
213
+ The owner's assistant settings (`assistantSettings(context)`) decide what
214
+ happens next. With `escalateToWorkflow` on (the default) and a host
215
+ `onWorkflowEscalation(context, input)`, the request is handed to a workflow run:
216
+ returning `{runId, message?}` ends the request with `done.runId`. Otherwise the
217
+ turn ends with the user-facing `tool_run_type` error. There is no inline restart
218
+ and no second client: every call of the turn stays on its tracked client.
219
+ `Thinking this through` identifies the handoff using the existing status stream.
220
+
221
+ `onExecution(context, execution)` receives the turn's `EngineExecution`
222
+ (engine, model when reported, requested model, effort, cumulative tokens when
223
+ fully known, duration, tool calls, fallback) once, when the turn ends or hands
224
+ off. Nothing of it is stored on a message. CLI adapters report observed
225
+ execution through `callbacks.execution`; this also keeps the work a handed-off
226
+ turn spent. With a database the driver's turn is also a `turn` run: the
227
+ engine's turn is one reserved call of it, settled from that execution, so
228
+ `turnBudget` applies before the engine starts
229
+ ([assistant turn runs](assistant-turn-runs.md)).
211
230
 
212
231
  Reuse audit: the developer intent index and MCP build-context architecture
213
232
  inventory, plus name/purpose searches in chat/core/inference/smrt-ui/smrt-svelte,
@@ -215,8 +234,8 @@ identified the existing turn driver, tool-loop and cookbook annotations as the
215
234
  owning seams. This extends those APIs; it adds no alternate approval ledger,
216
235
  model registry, UI component or tool executor.
217
236
 
218
- For durable jobs, the browser's `createAssistantHttpTransport({designRuns:true})`
219
- reads `GET /design-runs?threadId=…` and posts `/design-runs/{runId}/stop` or
237
+ For durable jobs, the browser's `createAssistantHttpTransport({workflowRuns:true})`
238
+ reads `GET /runs?threadId=…` and posts `/runs/{runId}/stop` or
220
239
  `/resume`. Hosts authenticate and owner-scope these routes. Each returns
221
240
  `{run?:{runId,pass:{index,count,name},status,note?}}` with a one-based pass index.
222
241
  The dock reloads progress when opening a thread, polls it, and reuses its status
@@ -226,11 +245,11 @@ leaves a durable job running. No browser id grants access to a run.
226
245
  `formatAssistantReply(content, context)` is a trusted host presentation hook for
227
246
  structured pass output. It returns human-facing `content` and optional metadata
228
247
  before persistence; hosts can keep the validated output under
229
- `metadata.designOutput` for their durable runner. That output is available only
248
+ `metadata.workflowOutput` for their durable runner. That output is available only
230
249
  on the trusted internal pass SSE handoff, never ordinary message wire objects.
231
250
  Ordinary replies are unchanged.
232
251
 
233
- Known design flows set `deferDesignTurn` to queue through that same durable hook
252
+ Known design flows set `deferWorkflowTurn` to queue through that same durable hook
234
253
  before any model call. Detached passes use the trusted `internalTurn(context)`
235
254
  callback to supply private pass input and the original owner-message id. The
236
255
  route still authenticates ownership and validates that original message against
@@ -245,13 +264,13 @@ select that provenance. Raw rows remain available to private provider history.
245
264
 
246
265
  The ordinary message route requests `ChatService`'s conversation visibility.
247
266
  It excludes marked assistant/tool rows and positively identified legacy assistant
248
- rows with `designOutput`; user rows are never hidden by metadata. Filtering runs
267
+ rows with `workflowOutput`; user rows are never hidden by metadata. Filtering runs
249
268
  before the visible limit using ordinary tenant/member-scoped collection pages
250
269
  of 200, deterministic timestamp/id ordering, and the existing list-bound resolver.
251
270
  Reply lookup rejects a hidden root and filters linked replies in the same way.
252
271
  Raw service reads retain their previous default. Legacy unmarked tool rows have
253
272
  no reliable run/pass linkage and are not deleted or heuristically attributed.
254
- Public wire metadata includes only `workRun` and `designRunId`.
273
+ Public wire metadata includes only `runId`.
255
274
 
256
275
  Hosts may opt into `toolPresentation: 'generic'` on the routes and AssistantDock.
257
276
  It uses `describeAssistantTool` without raw observations, summaries or arguments;
@@ -278,16 +297,15 @@ rows ahead of the public page. DOM tests render legacy messages, browser-tool
278
297
  confirmation and approval refresh with malicious raw captions and safe host previews.
279
298
  Both default contracts and opted presentation run in the affected regression suites.
280
299
 
281
- Token accounting is conservative: `workRun.tokens` is omitted if any completion
282
- omits valid usage, including across escalation and browser continuations. An
283
- explicit zero remains zero. `ToolLoopResult.totalTokens` remains the numeric
284
- known subtotal; `usageKnown` distinguishes it from complete usage. API model
285
- metadata uses a provider-reported model when available; effort describes the
286
- requested profile effort, subject to provider support and normalization.
287
-
288
- On durable admission, the intercepted assist turn is recorded separately before
289
- `done`: a human handoff message carries `metadata.designRunId` and its original
290
- `workRun` (spent tokens when fully known, elapsed time and calls). The durable
291
- job's budget begins at its own admission; earlier assist work is not presented
292
- as part of that job's usage. Missing observed external models remain unknown;
293
- the requested profile alias is never substituted as an actual model.
300
+ Token accounting is conservative: an execution's `tokens` is omitted if any
301
+ completion omits valid usage, including across a handoff and browser
302
+ continuations. An explicit zero remains zero. `ToolLoopResult.totalTokens`
303
+ remains the numeric known subtotal; `usageKnown` distinguishes it from complete
304
+ usage. The execution's model is a provider-reported one when available; effort
305
+ is the requested effort, subject to provider support and normalization.
306
+
307
+ On a workflow handoff, the refused turn is reported through `onExecution`
308
+ before `done`, and a human handoff message carries `metadata.runId`. The
309
+ workflow run's budget begins at its own admission; the turn's work is not
310
+ presented as part of its usage. Missing observed external models remain
311
+ unknown; the requested model is never substituted as an actual model.
@@ -26,7 +26,7 @@ function requiresOwnerApproval(tool, args, policy, destructiveHint = false) {
26
26
  "@happyvertical/smrt-app-shell",
27
27
  "@happyvertical/smrt-inference",
28
28
  "@happyvertical/smrt-approvals"
29
- ].includes(name.split(":")[0])) || !!declaration && ObjectRegistry.getConfig(declaration.qualifiedName ?? declaration.name).sensitive === true) && "action" in tool && tool.action === "delete" && tool.annotations?.recordDeletion === true && tool.annotations?.workProfile !== "design" && typeof args.id === "string" && args.id.trim().length > 0;
29
+ ].includes(name.split(":")[0])) || !!declaration && ObjectRegistry.getConfig(declaration.qualifiedName ?? declaration.name).sensitive === true) && "action" in tool && tool.action === "delete" && tool.annotations?.recordDeletion === true && !tool.annotations?.runTypes?.includes("workflow") && typeof args.id === "string" && args.id.trim().length > 0;
30
30
  if (purge) return true;
31
31
  return policy?.tools?.[tool.slug] ?? policy?.operations?.[operation] ?? (policy?.allowRemovalsInChat && recordDeletion ? false : destructiveHint || destructive(operation) || destructive(tool.slug) || destructive(String(args.operation ?? args.action ?? "")));
32
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-approvals.js","names":[],"sources":["../src/assistant-approvals.ts"],"sourcesContent":["/** Server-write policy and durable hold bridge. Host code supplies authority, never model output. */\nimport type { PrincipalTool } from '@happyvertical/smrt-agents';\nimport type { OwnerApprovalAuthority } from '@happyvertical/smrt-app-runtime';\nimport { ObjectRegistry } from '@happyvertical/smrt-core';\nimport type { AssistantApprovalWaiter } from './assistant-turn-driver.js';\nimport type { AssistantApprovalRequest } from './assistant-turn-events.js';\nimport type { ManifestTool } from './tool-loop.js';\n\nexport interface AssistantApprovalCall {\n id: string;\n originMessageId?: string;\n permissions?: readonly string[];\n tool: ManifestTool | PrincipalTool;\n args: Record<string, unknown>;\n}\n\n/** Tool override, then operation override, then destructive-name default. */\nexport interface AssistantApprovalPolicy {\n /** Trusted host choice for in-app chat only. Never read from tool arguments. */\n allowRemovalsInChat?: boolean;\n tools?: Readonly<Record<string, boolean>>;\n operations?: Readonly<Record<string, boolean>>;\n}\n\nexport function requiresOwnerApproval(\n tool: ManifestTool | PrincipalTool,\n args: Record<string, unknown>,\n policy?: AssistantApprovalPolicy,\n destructiveHint = false,\n): boolean {\n const operation =\n 'action' in tool ? tool.action : (tool.slug.split('.').at(-1) ?? '');\n const destructive = (value: string) =>\n /(?:^|[._-])(delete|remove|destroy|purge|drop|truncate)(?:$|[._-])/i.test(\n value.replace(/([a-z])([A-Z])/g, '$1_$2'),\n );\n const values = [\n operation,\n tool.slug,\n String(args.operation ?? args.action ?? ''),\n ].map((value) => value.replace(/([a-z])([A-Z])/g, '$1_$2'));\n const purge = values.some((value) =>\n /(?:^|[._-])(purge|drop|truncate|destroy)(?:$|[._-])/i.test(value),\n );\n // Opt-in metadata is server-owned. Names and model arguments never classify\n // a tool as ordinary app data; extra/custom/security operations stay held.\n const identity =\n 'action' in tool ? (tool.qualifiedName ?? tool.className) : undefined;\n const declaration = identity ? ObjectRegistry.getClass(identity) : undefined;\n const controlModel =\n [\n identity,\n ...(declaration\n ? ObjectRegistry.getInheritanceChain(\n declaration.qualifiedName ?? declaration.name,\n )\n : []),\n ...(declaration?.replacedQualifiedNames ?? []),\n ].some(\n (name) =>\n name &&\n [\n '@happyvertical/smrt-users',\n '@happyvertical/smrt-profiles',\n '@happyvertical/smrt-tenancy',\n '@happyvertical/smrt-secrets',\n '@happyvertical/smrt-preferences',\n '@happyvertical/smrt-config',\n '@happyvertical/smrt-features',\n '@happyvertical/smrt-app-runtime',\n '@happyvertical/smrt-app-shell',\n '@happyvertical/smrt-inference',\n '@happyvertical/smrt-approvals',\n ].includes(name.split(':')[0]),\n ) ||\n (!!declaration &&\n ObjectRegistry.getConfig(declaration.qualifiedName ?? declaration.name)\n .sensitive === true);\n const recordDeletion =\n !controlModel &&\n 'action' in tool &&\n tool.action === 'delete' &&\n tool.annotations?.recordDeletion === true &&\n tool.annotations?.workProfile !== 'design' &&\n typeof args.id === 'string' &&\n args.id.trim().length > 0;\n if (purge) return true;\n // Native tools may own an independent hold (the existing explicit overrides).\n // The new chat setting itself can never waive a purge or an unknown effect.\n return (\n policy?.tools?.[tool.slug] ??\n policy?.operations?.[operation] ??\n (policy?.allowRemovalsInChat && recordDeletion\n ? false\n : destructiveHint ||\n destructive(operation) ||\n destructive(tool.slug) ||\n destructive(String(args.operation ?? args.action ?? '')))\n );\n}\n\nexport interface AssistantApprovalBridge {\n policy?: AssistantApprovalPolicy;\n request(call: AssistantApprovalCall): Promise<AssistantApprovalRequest>;\n wait?: AssistantApprovalWaiter;\n complete?: (\n request: AssistantApprovalRequest,\n ok: boolean,\n result: unknown,\n ) => Promise<void>;\n}\n\n/** Creates requests from server-supplied snapshots and canonical calls, never an engine's id/summary. */\nexport function createAssistantApprovalBridge(options: {\n authority: OwnerApprovalAuthority;\n tenantId: string;\n requestedBy: string;\n context: Record<string, unknown>;\n policy?: AssistantApprovalPolicy;\n summary?: (call: AssistantApprovalCall) => string;\n}): AssistantApprovalBridge {\n return {\n policy: options.policy,\n async request(call) {\n const record = await options.authority.request({\n tenantId: options.tenantId,\n requestedBy: options.requestedBy,\n tool: call.tool.slug,\n callId: call.id,\n args: call.args,\n summary:\n options.summary?.(call) ??\n `Allow ${call.tool.slug}${typeof call.args.id === 'string' ? ` for ${call.args.id.slice(0, 200)}` : ''}?`,\n context: {\n ...options.context,\n ...(call.permissions\n ? { permissionCeiling: [...call.permissions] }\n : {}),\n ...(call.originMessageId\n ? { originMessageId: call.originMessageId }\n : {}),\n },\n });\n return {\n id: record.id,\n tool: record.tool,\n callId: record.callId,\n summary: record.summary,\n };\n },\n async complete(request, ok, result) {\n await options.authority.complete(\n options.tenantId,\n request.id,\n ok,\n result,\n );\n },\n async wait(request, context) {\n const record = await options.authority.wait(\n options.tenantId,\n request.id,\n context.signal,\n );\n if (context.signal.aborted || record?.status !== 'approved')\n return { approved: false, reason: record?.status ?? 'cancelled' };\n await options.authority.consume(options.tenantId, request.id);\n return { approved: true };\n },\n };\n}\n\n/** Observe a host-executed durable hold without deciding, consuming or replaying it. */\nexport async function observeAssistantApproval(options: {\n authority: OwnerApprovalAuthority;\n tenantId: string;\n id: string;\n signal: AbortSignal;\n timeoutMs: number;\n}) {\n const timeout = new AbortController();\n const timer = setTimeout(() => timeout.abort(), options.timeoutMs);\n try {\n return await options.authority.wait(\n options.tenantId,\n options.id,\n AbortSignal.any([options.signal, timeout.signal]),\n { settled: true },\n );\n } finally {\n clearTimeout(timer);\n }\n}\n"],"mappings":";;AAwBO,SAAS,sBACd,MACA,MACA,QACA,kBAAkB,OACT;CACT,MAAM,YACJ,YAAY,OAAO,KAAK,SAAU,KAAK,KAAK,MAAM,GAAG,CAAA,CAAE,GAAG,EAAE,KAAK;CACnE,MAAM,eAAe,UACnB,qEAAqE,KACnE,MAAM,QAAQ,mBAAmB,OAAO,CAC1C;CAMF,MAAM,QALS;EACb;EACA,KAAK;EACL,OAAO,KAAK,aAAa,KAAK,UAAU,EAAE;CAC5C,CAAA,CAAE,KAAK,UAAU,MAAM,QAAQ,mBAAmB,OAAO,CAC3C,CAAA,CAAO,MAAM,UACzB,uDAAuD,KAAK,KAAK,CACnE;CAGA,MAAM,WACJ,YAAY,OAAQ,KAAK,iBAAiB,KAAK,YAAa,KAAA;CAC9D,MAAM,cAAc,WAAW,eAAe,SAAS,QAAQ,IAAI,KAAA;CA8BnE,MAAM,iBACJ,EA7BA;EACE;EACA,GAAI,cACA,eAAe,oBACb,YAAY,iBAAiB,YAAY,IAC3C,IACA,CAAC;EACL,GAAI,aAAa,0BAA0B,CAAC;CAC9C,CAAA,CAAE,MACC,SACC,QACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAA,CAAE,SAAS,KAAK,MAAM,GAAG,CAAA,CAAE,EAAE,CACjC,KACC,CAAC,CAAC,eACD,eAAe,UAAU,YAAY,iBAAiB,YAAY,IAAI,CAAA,CACnE,cAAc,SAGnB,YAAY,QACZ,KAAK,WAAW,YAChB,KAAK,aAAa,mBAAmB,QACrC,KAAK,aAAa,gBAAgB,YAClC,OAAO,KAAK,OAAO,YACnB,KAAK,GAAG,KAAK,CAAA,CAAE,SAAS;CAC1B,IAAI,OAAO,OAAO;CAGlB,OACE,QAAQ,QAAQ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CACF;AACF;AAGA,eAAsB,yBAAyB,SAM5C;CACD,MAAM,UAAU,IAAI,gBAAgB;CACpC,MAAM,QAAQ,iBAAiB,QAAQ,MAAM,GAAG,QAAQ,SAAS;CACjE,IAAI;EACF,OAAO,MAAM,QAAQ,UAAU,KAC7B,QAAQ,UACR,QAAQ,IACR,YAAY,IAAI,CAAC,QAAQ,QAAQ,QAAQ,MAAM,CAAC,GAChD,EAAE,SAAS,KAAK,CAClB;CACF,UAAE;EACA,aAAa,KAAK;CACpB;AACF"}
1
+ {"version":3,"file":"assistant-approvals.js","names":[],"sources":["../src/assistant-approvals.ts"],"sourcesContent":["/** Server-write policy and durable hold bridge. Host code supplies authority, never model output. */\nimport type { PrincipalTool } from '@happyvertical/smrt-agents';\nimport type { OwnerApprovalAuthority } from '@happyvertical/smrt-app-runtime';\nimport { ObjectRegistry } from '@happyvertical/smrt-core';\nimport type { AssistantApprovalWaiter } from './assistant-turn-driver.js';\nimport type { AssistantApprovalRequest } from './assistant-turn-events.js';\nimport type { ManifestTool } from './tool-loop.js';\n\nexport interface AssistantApprovalCall {\n id: string;\n originMessageId?: string;\n permissions?: readonly string[];\n tool: ManifestTool | PrincipalTool;\n args: Record<string, unknown>;\n}\n\n/** Tool override, then operation override, then destructive-name default. */\nexport interface AssistantApprovalPolicy {\n /** Trusted host choice for in-app chat only. Never read from tool arguments. */\n allowRemovalsInChat?: boolean;\n tools?: Readonly<Record<string, boolean>>;\n operations?: Readonly<Record<string, boolean>>;\n}\n\nexport function requiresOwnerApproval(\n tool: ManifestTool | PrincipalTool,\n args: Record<string, unknown>,\n policy?: AssistantApprovalPolicy,\n destructiveHint = false,\n): boolean {\n const operation =\n 'action' in tool ? tool.action : (tool.slug.split('.').at(-1) ?? '');\n const destructive = (value: string) =>\n /(?:^|[._-])(delete|remove|destroy|purge|drop|truncate)(?:$|[._-])/i.test(\n value.replace(/([a-z])([A-Z])/g, '$1_$2'),\n );\n const values = [\n operation,\n tool.slug,\n String(args.operation ?? args.action ?? ''),\n ].map((value) => value.replace(/([a-z])([A-Z])/g, '$1_$2'));\n const purge = values.some((value) =>\n /(?:^|[._-])(purge|drop|truncate|destroy)(?:$|[._-])/i.test(value),\n );\n // Opt-in metadata is server-owned. Names and model arguments never classify\n // a tool as ordinary app data; extra/custom/security operations stay held.\n const identity =\n 'action' in tool ? (tool.qualifiedName ?? tool.className) : undefined;\n const declaration = identity ? ObjectRegistry.getClass(identity) : undefined;\n const controlModel =\n [\n identity,\n ...(declaration\n ? ObjectRegistry.getInheritanceChain(\n declaration.qualifiedName ?? declaration.name,\n )\n : []),\n ...(declaration?.replacedQualifiedNames ?? []),\n ].some(\n (name) =>\n name &&\n [\n '@happyvertical/smrt-users',\n '@happyvertical/smrt-profiles',\n '@happyvertical/smrt-tenancy',\n '@happyvertical/smrt-secrets',\n '@happyvertical/smrt-preferences',\n '@happyvertical/smrt-config',\n '@happyvertical/smrt-features',\n '@happyvertical/smrt-app-runtime',\n '@happyvertical/smrt-app-shell',\n '@happyvertical/smrt-inference',\n '@happyvertical/smrt-approvals',\n ].includes(name.split(':')[0]),\n ) ||\n (!!declaration &&\n ObjectRegistry.getConfig(declaration.qualifiedName ?? declaration.name)\n .sensitive === true);\n const recordDeletion =\n !controlModel &&\n 'action' in tool &&\n tool.action === 'delete' &&\n tool.annotations?.recordDeletion === true &&\n !tool.annotations?.runTypes?.includes('workflow') &&\n typeof args.id === 'string' &&\n args.id.trim().length > 0;\n if (purge) return true;\n // Native tools may own an independent hold (the existing explicit overrides).\n // The new chat setting itself can never waive a purge or an unknown effect.\n return (\n policy?.tools?.[tool.slug] ??\n policy?.operations?.[operation] ??\n (policy?.allowRemovalsInChat && recordDeletion\n ? false\n : destructiveHint ||\n destructive(operation) ||\n destructive(tool.slug) ||\n destructive(String(args.operation ?? args.action ?? '')))\n );\n}\n\nexport interface AssistantApprovalBridge {\n policy?: AssistantApprovalPolicy;\n request(call: AssistantApprovalCall): Promise<AssistantApprovalRequest>;\n wait?: AssistantApprovalWaiter;\n complete?: (\n request: AssistantApprovalRequest,\n ok: boolean,\n result: unknown,\n ) => Promise<void>;\n}\n\n/** Creates requests from server-supplied snapshots and canonical calls, never an engine's id/summary. */\nexport function createAssistantApprovalBridge(options: {\n authority: OwnerApprovalAuthority;\n tenantId: string;\n requestedBy: string;\n context: Record<string, unknown>;\n policy?: AssistantApprovalPolicy;\n summary?: (call: AssistantApprovalCall) => string;\n}): AssistantApprovalBridge {\n return {\n policy: options.policy,\n async request(call) {\n const record = await options.authority.request({\n tenantId: options.tenantId,\n requestedBy: options.requestedBy,\n tool: call.tool.slug,\n callId: call.id,\n args: call.args,\n summary:\n options.summary?.(call) ??\n `Allow ${call.tool.slug}${typeof call.args.id === 'string' ? ` for ${call.args.id.slice(0, 200)}` : ''}?`,\n context: {\n ...options.context,\n ...(call.permissions\n ? { permissionCeiling: [...call.permissions] }\n : {}),\n ...(call.originMessageId\n ? { originMessageId: call.originMessageId }\n : {}),\n },\n });\n return {\n id: record.id,\n tool: record.tool,\n callId: record.callId,\n summary: record.summary,\n };\n },\n async complete(request, ok, result) {\n await options.authority.complete(\n options.tenantId,\n request.id,\n ok,\n result,\n );\n },\n async wait(request, context) {\n const record = await options.authority.wait(\n options.tenantId,\n request.id,\n context.signal,\n );\n if (context.signal.aborted || record?.status !== 'approved')\n return { approved: false, reason: record?.status ?? 'cancelled' };\n await options.authority.consume(options.tenantId, request.id);\n return { approved: true };\n },\n };\n}\n\n/** Observe a host-executed durable hold without deciding, consuming or replaying it. */\nexport async function observeAssistantApproval(options: {\n authority: OwnerApprovalAuthority;\n tenantId: string;\n id: string;\n signal: AbortSignal;\n timeoutMs: number;\n}) {\n const timeout = new AbortController();\n const timer = setTimeout(() => timeout.abort(), options.timeoutMs);\n try {\n return await options.authority.wait(\n options.tenantId,\n options.id,\n AbortSignal.any([options.signal, timeout.signal]),\n { settled: true },\n );\n } finally {\n clearTimeout(timer);\n }\n}\n"],"mappings":";;AAwBO,SAAS,sBACd,MACA,MACA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M,QAAQ,UAAU,KAC7B,QAAQ,UACR,QAAQ,IACR,YAAY,IAAI,CAAC,QAAQ,QAAQ,QAAQ,MAAM,CAAC,GAChD,EAAE,SAAS,KAAK,CAClB;CACF,UAAE;EACA,aAAa,KAAK;CACpB;AACF"}
@@ -1,10 +1,11 @@
1
1
  /** Host-supplied assistant loops. This module never imports an inference engine. */
2
2
  import type { AIMessage } from '@happyvertical/ai';
3
3
  import type { PrincipalBinding, PrincipalTool } from '@happyvertical/smrt-agents';
4
- import type { ResolvedWorkProfile, WorkRunMetadata } from '@happyvertical/smrt-inference';
4
+ import type { EngineExecution } from '@happyvertical/smrt-inference';
5
5
  import { type AssistantTurnOptions, type AssistantTurnResult, type AssistantTurnState } from './assistant-turn.js';
6
6
  import type { AssistantApprovalRequest, AssistantClientToolCall, AssistantClientToolResult, AssistantTurnEvent } from './assistant-turn-events.js';
7
7
  import { type ManifestTool, type ToolLoopUsage } from './tool-loop.js';
8
+ import { type AssistantModelSelection } from './tool-run-types.js';
8
9
  import type { DescribeAssistantTool } from './tool-summary.js';
9
10
  /** A decision from the host's owner-approval authority, never from model output. */
10
11
  export interface AssistantApprovalDecision {
@@ -28,7 +29,8 @@ export interface AssistantTurnDriverContext {
28
29
  /** Only offered, allow-listed server tools. MCP execution must enforce this principal too. */
29
30
  tools: readonly ManifestTool[];
30
31
  extraTools: readonly PrincipalTool[];
31
- workProfile?: ResolvedWorkProfile;
32
+ /** The engine, tier, model and effort the host's tier binding chose. */
33
+ selection?: AssistantModelSelection;
32
34
  /** MUST run at the authenticated MCP boundary before any side effect. */
33
35
  beforeToolExecution(tool: string): void;
34
36
  signal: AbortSignal;
@@ -45,11 +47,12 @@ export interface AssistantTurnDriverCallbacks {
45
47
  toolCall(call: AssistantDriverToolCall): Promise<void>;
46
48
  toolResult(result: AssistantClientToolResult): Promise<void>;
47
49
  approvalNeeded(request: AssistantApprovalRequest): Promise<AssistantApprovalDecision>;
48
- execution?(metadata: WorkRunMetadata): void;
50
+ /** What the engine ran with and used, as soon as it knows. */
51
+ execution?(execution: EngineExecution): void;
49
52
  done(result: {
50
53
  text: string;
51
54
  usage?: ToolLoopUsage;
52
- workRun?: WorkRunMetadata;
55
+ execution?: EngineExecution;
53
56
  }): void;
54
57
  /** Detail is logged server-side; the wire and stored error are sanitized. */
55
58
  error(error: unknown): void;
@@ -60,14 +63,14 @@ export interface AssistantTurnDriver {
60
63
  waitForApproval?: AssistantApprovalWaiter;
61
64
  run(context: AssistantTurnDriverContext, callbacks: AssistantTurnDriverCallbacks): Promise<void>;
62
65
  }
63
- /** Persist the human handoff and the intercepted assist work before the durable job takes over. */
64
- export declare function recordDesignHandoff<M>(options: AssistantTurnOptions<M>, accepted: {
66
+ /** Persist the human handoff and report the turn's work before the workflow run takes over. */
67
+ export declare function recordWorkflowHandoff<M>(options: AssistantTurnOptions<M>, accepted: {
65
68
  runId: string;
66
69
  message?: string;
67
- }, emit: (event: AssistantTurnEvent<M>) => void, serialize: (message: unknown) => M, observed?: WorkRunMetadata): Promise<{
70
+ }, emit: (event: AssistantTurnEvent<M>) => void, serialize: (message: unknown) => M, observed?: EngineExecution): Promise<{
68
71
  content: string;
69
72
  message?: M;
70
73
  }>;
71
- /** Restart once with the same authority after a host-boundary design interception. */
74
+ /** Run an external turn; a refused workflow-only tool hands off to a workflow run or ends it. */
72
75
  export declare function runExternalAssistantTurn<M>(options: AssistantTurnOptions<M>, emit: (event: AssistantTurnEvent<M>) => void, serialize: (message: unknown) => M, describe: DescribeAssistantTool, report: (state: AssistantTurnState['state']) => Promise<boolean>): Promise<AssistantTurnResult>;
73
76
  //# sourceMappingURL=assistant-turn-driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-turn-driver.d.ts","sourceRoot":"","sources":["../src/assistant-turn-driver.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EACV,gBAAgB,EAChB,a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kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,EAClC,QAAQ,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC,CA0B3C;AAED,iGAAiG;AACjG,wBAAsB,wBAAwB,CAAC,CAAC,EAC9C,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAChC,IAAI,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,EAClC,QAAQ,EAAE,qBAAqB,EAC/B,MAAM,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GAC/D,OAAO,CAAC,mBAAmB,CAAC,CAqD9B"}
@@ -142,7 +142,7 @@ export type AssistantTurnEvent<M = Record<string, unknown>> = {
142
142
  calls: AssistantClientToolCall[];
143
143
  } | {
144
144
  type: 'done';
145
- /** Durable design run accepted by the authenticated host. */
145
+ /** Durable workflow run accepted by the authenticated host. */
146
146
  runId?: string;
147
147
  message?: M;
148
148
  stoppedReason: AssistantTurnStopReason;
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-turn-events.d.ts","sourceRoot":"","sources":["../src/assistant-turn-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oEAAoE;AACpE,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,oBAAoB,CAAC;IAC5B,qEAAqE;IACrE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uEAAuE;IACvE,OAAO,CAAC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M,CAAC;IACd,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,2CAA2C;AAC3C,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,GACjC,MAAM,CAER;AAED,gDAAgD;AAChD,MAAM,WAAW,0BAA0B,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACrE,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,iEAAiE;IACjE,eAAe,CAAC,EAAE,OAAO,CACvB,kBAAkB,CAAC,CAAC,CAAC,EACrB;QAAE,IAAI,EAAE,mBAAmB,CAAA;KAAE,CAC9B,CAAC;CACH;AAED,wFAAwF;AACxF,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B;AAaD;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvE,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAgExC;AAED,sEAAsE;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import { type AssistantApprovalBridge, type AssistantApprovalPolicy } from './assistant-approvals.js';
2
+ import { type AssistantRunTypeOptions, ToolRunTypeRefusal } from './tool-run-types.js';
2
3
  import { type DescribeAssistantTool } from './tool-summary.js';
3
- import { type AssistantWorkProfileOptions } from './work-profile.js';
4
4
  import type { AIInterface, AIMessage, ChatOptions } from '@happyvertical/ai';
5
5
  import type { PrincipalAuditSink, PrincipalBinding, PrincipalTool } from '@happyvertical/smrt-agents';
6
- import type { SmrtClassOptions } from '@happyvertical/smrt-core';
6
+ import { type AiRunBudget, type SmrtClassOptions } from '@happyvertical/smrt-core';
7
7
  import type { AssistantApprovalWaiter, AssistantTurnDriver, AssistantTurnDriverContext } from './assistant-turn-driver.js';
8
8
  import type { AssistantTurnEvent, AssistantTurnStopReason } from './assistant-turn-events.js';
9
9
  import type { AgentReplyService } from './services/ChatService.js';
10
10
  import { type ClientToolDefinition, type ClientToolResultInput, type ManifestTool, type PendingClientToolCall, type ToolInvocation, type ToolLoopOptions, type ToolLoopResult, type ToolLoopUsage } from './tool-loop.js';
11
+ import { AssistantTurnRun, type AssistantTurnTracking, TURN_RUN } from './turn-tracking.js';
11
12
  /** How long a suspended turn waits for the browser's results. */
12
13
  export declare const DEFAULT_CONTINUATION_TTL_MS: number;
13
14
  /**
@@ -141,9 +142,21 @@ export interface AssistantTurnAuthor {
141
142
  collapseRecoveredFailures?: boolean;
142
143
  }
143
144
  /** Options for {@link runAssistantTurn}. */
144
- export interface AssistantTurnOptions<M = Record<string, unknown>> extends AssistantWorkProfileOptions {
145
+ export interface AssistantTurnOptions<M = Record<string, unknown>> extends AssistantRunTypeOptions {
145
146
  /** Required for the default tool loop; unused by an external driver. */
146
147
  ai?: Pick<AIInterface, 'chat'>;
148
+ /**
149
+ * Track this turn as an AI run (#5005): it opens a `turn` run before the
150
+ * first model call, every call of the tool loop is a tracked call of it,
151
+ * and tool use and approvals are events of its trajectory. The loop then
152
+ * calls the tracked client instead of `ai`.
153
+ * Throws the turn's `ai_tracking_disabled` error while usage persistence
154
+ * is off. An external driver's turn (a Claude Code or Codex engine) opens
155
+ * the same run and records the engine's turn as one tracked call of it.
156
+ */
157
+ tracking?: AssistantTurnTracking;
158
+ /** Internal: the open run an external driver's turn records its call in. */
159
+ [TURN_RUN]?: AssistantTurnRun;
147
160
  /** Omitted: today's bounded tool loop, including browser continuations. */
148
161
  turnDriver?: AssistantTurnDriver;
149
162
  /** Host-owned durable approval bridge. Absent: approval requests fail closed. */
@@ -227,6 +240,18 @@ export interface AssistantTurnOptions<M = Record<string, unknown>> extends Assis
227
240
  * `stoppedReason: 'timeout'` and the fallback reply.
228
241
  */
229
242
  requestTimeoutMs?: number;
243
+ /**
244
+ * The turn's budget (#5005; ai-runs section 6.1), stored on its `turn` run
245
+ * (core enforces it on every tracked call) and applied to the loop:
246
+ * `maxSteps` → `maxSteps`, `maxTokens` → `maxTurnTokens`, `maxDurationMs`
247
+ * → `maxTurnMs`, `callTimeoutMs` → `requestTimeoutMs`. A key it sets wins
248
+ * over the matching option. A call core refuses at a limit ends the turn
249
+ * `budget`. Core's `maxCallTokens` counts input too, so a per-call output
250
+ * cap stays the `maxTokens` option.
251
+ */
252
+ budget?: AiRunBudget;
253
+ /** Longest tool result kept in the conversation (characters). */
254
+ toolResultChars?: number;
230
255
  /**
231
256
  * Reply stored when the turn produced no answer (#4379; `stoppedReason`
232
257
  * `empty` or `timeout`, or blank content). Default
@@ -361,4 +386,10 @@ export declare function createAssistantTurnResponse(events: AsyncGenerator<Assis
361
386
  */
362
387
  onCancel?: () => void;
363
388
  }): Response;
389
+ /** A refused workflow-only tool, as the turn's user-facing error. */
390
+ export declare function refusedInTurn(error: ToolRunTypeRefusal): AssistantTurnUserError;
391
+ /** The reply of a turn whose run stopped at a budget limit. */
392
+ export declare const TURN_BUDGET_REPLY = "I reached the limit for this turn before finishing. Ask again to continue.";
393
+ /** A run stop at one of its budget limits (ai-runs section 6.4). */
394
+ export declare function isRunBudgetStop(error: unknown): boolean;
364
395
  //# sourceMappingURL=assistant-turn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-turn.d.ts","sourceRoot":"","sources":["../src/assistant-turn.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAE7B,MAAM,0BAA0B,CAAC;AAClC,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;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB,GACL,QAAQ,CA2DV;AAgCD,qEAAqE;AACrE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,kBAAkB,GACxB,sBAAsB,CAKxB;AAED,+DAA+D;AAC/D,eAAO,MAAM,iBAAiB,+EACgD,CAAC;AAE/E,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOvD"}
@@ -2152,7 +2152,7 @@ var ChatService = class ChatService {
2152
2152
  #isConversationMessage(message) {
2153
2153
  if (message.role !== "assistant" && message.role !== "tool") return true;
2154
2154
  const metadata = message.getMetadata();
2155
- return !(metadata && typeof metadata === "object" && (metadata.assistantInternalTurn === true || message.role === "assistant" && Object.hasOwn(metadata, "designOutput")));
2155
+ return !(metadata && typeof metadata === "object" && (metadata.assistantInternalTurn === true || message.role === "assistant" && Object.hasOwn(metadata, "workflowOutput")));
2156
2156
  }
2157
2157
  async #listConversationMessages(options) {
2158
2158
  const visible = [];
@@ -2331,4 +2331,4 @@ function sendAgentReply(service, params) {
2331
2331
  //#endregion
2332
2332
  export { sendAgentReply as a, ChatThread as c, ChatParticipant as d, ChatMessage as f, clientRequestMessageId as i, ChatRoom as l, ChatService as n, VoiceSessionCollection as o, AgentSession as p, ChatService_exports as r, VoiceSession as s, ChatClientRequestConflictError as t, ChatReaction as u };
2333
2333
 
2334
- //# sourceMappingURL=ChatService-CeOVzOqN.js.map
2334
+ //# sourceMappingURL=ChatService-CDLAEJms.js.map