@happyvertical/smrt-chat 0.62.3 → 0.62.4

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.
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-chat",
6
- "packageVersion": "0.62.3",
6
+ "packageVersion": "0.62.4",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "29b4b9aede2eeb3b2be07f5f325862d4c5c26123a51c175dd9adee58f239e297",
11
- "packageJson": "6be64b0b31bf32fc4b579642dc299405e4f869b5b4fbe2905a7101a128a901f4",
10
+ "manifest": "6302d14a8048cc302c2fd0bf574f49d29d269988e3e6dbf645fdb8a32b6eb65c",
11
+ "packageJson": "3e04e1b9cdc8b1424c61e30c664ad911102a8ac8122faa59a6cc6a9955484b46",
12
12
  "agents": "6f17bbd164ff7bb235faea14499df6546d9a994861df91d4741e934dda8e8eaa",
13
13
  "moduleDoc:agents/dev-workbench.md": "f07a428519e8cca4a46371da0a3b33b9c8d3102f1d9056e4c8efba3c0b702048",
14
14
  "moduleDoc:agents/runtime-report-tools.md": "116b6371207cec6bc8ee891a358b3457fc08d3ae86f9c31b428c6c13dfb25a40",
@@ -19,7 +19,7 @@
19
19
  "moduleDoc:agents/owner-approvals.md": "ad8b489636a4849a0191d53988158b24b7ea808dc2905e773260044d58b0172b",
20
20
  "moduleDoc:agents/tool-summaries.md": "ddf438d307fbb7127f8290cd22046eef3b1d8e41c0d742a040707222b87be1bb",
21
21
  "moduleDoc:agents/runtime-exposure.md": "4a55759e1d2e754d421cfb3b9150818c71b59b3aacc0c011f0f2f45507086b58",
22
- "moduleDoc:agents/assistant-turn-runs.md": "d7de91fbaab9c7543d88f5e0bc7d4de46a56b3673edca8285ff0a9b24302b17a",
22
+ "moduleDoc:agents/assistant-turn-runs.md": "9f77acc37e5b291a9ac3d19931d271a7e4e78da4ccd93fe35937de5ac15ee3a7",
23
23
  "moduleDoc:agents/ai-unavailable.md": "e12b175c932411c4445b59ee8144ae06cc962c430960b6c5a26e0002f2d15369",
24
24
  "moduleDoc:agents/assistant-questions.md": "a0371870b3bc99e313d8287912208f3e315bab7dc4ee138214895031ae79a5b0",
25
25
  "moduleDoc:agents/recipes.md": "89c2c86e4e26cea9ba10d917f8ad71c23a71d4fd8eaacf638a6cd252e2376c07",
@@ -4529,6 +4529,9 @@
4529
4529
  },
4530
4530
  {
4531
4531
  "filePath": "src/turn-tracking.ts"
4532
+ },
4533
+ {
4534
+ "filePath": "src/workflow-step-turn.test.ts"
4532
4535
  }
4533
4536
  ],
4534
4537
  "relationshipsV2": {
@@ -4589,7 +4592,7 @@
4589
4592
  {
4590
4593
  "path": "agents/assistant-turn-runs.md",
4591
4594
  "module": "assistant-turn-runs",
4592
- "content": "# Assistant turns as AI runs (#5005)\n\n`mountAssistantRoutes` builds a tracked client per turn\n(`createTrackedAiClient`, the principal's tenant on the request's database,\nover the turn's client, `transcript: false` because chat stores the\nconversation) and passes `tracking` to `runAssistantTurn`\n(`turn-tracking.ts`). The turn then opens one `turn` run before its first\nmodel call (`AssistantTurnRun.open`, definition `chat.assistant.turn`), the\ntool loop calls the tracked client (each model call is a reserved, settled\ncall of the run: one usage row and one `call` event, tagged with the prompt\nkey), tool use is an `action` event and its result an `observation` event\nwhose `parent_event_id` is the action, and the run ends `done` (`cancelled`\nfor an abort, `failed` for an error). Messages are never copied into the\ntrajectory: events point at them with `payload_ref` (`chat-message:<id>`).\nA turn that needs an owner approval records a requested `approval` event\n(`payload_ref` `approval:<id>`) and ends `done` with the approval pending; it\ndoes not wait. The decision is recorded as an `approval` event in the NEXT\nturn's run, once, with `parent_event_id` the request in the earlier run\n(`tracking.decisions` reads the thread's decided approvals from the host's\nstore). A chat turn does not run untracked: with usage persistence off it ends\nwith the user-facing error `ai_tracking_disabled` before any call is sent.\nA ChatGPT plan turn is a built-in loop over a host-built client: its calls\nare recorded under the engine (`label` on `createTrackedAiClient`, provider\n`chatgpt`, the bound model unless the response reports one), uncosted, with\n`tier_requested`/`tier_resolved` from the prompt and the selection.\n\n## A turn on an external engine (Claude Code, Codex)\n\nAn external `turnDriver` turn opens the same run. The engine's turn is ONE\ntracked call of it (`AssistantTurnRun.beginEngineCall`, reserved in\n`runExternalAssistantAttempt` before `driver.run`, call id minted first):\nthe engine runs its own loop and reports one result per turn, so its internal\nmodel calls are not seen one by one. The usage row's provider is the engine\nid, its model the one the CLI reported (Claude Code does; Codex does not),\nelse the tier binding's; it carries the prompt key and tiers and is always\nuncosted. Tokens are the CLI's reported usage (`EngineExecution.tokens`,\nsplit into `inputTokens`/`outputTokens`, cache reads and writes in the\ninput); a turn that answered without them is charged what it reserved (ai-runs\nsection 6.4) and its row has NULL token columns. A refused reservation\n(`maxCalls`, `maxTokens`, `maxDurationMs`, or a parent's limit or stop) ends\nthe turn `budget` before the CLI starts; `callTimeoutMs` aborts the CLI and\nfails the turn. A turn that fails, is cancelled or hands off to a workflow is\nsettled with its tokens when the CLI reported them, else released. Limits:\n`maxSteps` cannot bound the CLI's internal rounds (a workflow parent's step\nlimit still refuses the child's call), and a parent stop or cancel during an\nengine turn takes effect at its end, not by interrupting the CLI. Tests:\n`sveltekit.test.ts` (external engine), `engines.test.ts` (real driver over\nthe stub CLI), `turn-tracking-child.test.ts`.\n\nThe system prompt is the registered prompt `chat.assistant.system`\n(`chatAssistantSystemPrompt`): the host's `systemPrompt` option is its runtime\nlayer and an app or tenant override of the key replaces it\n(`resolveChatAssistantPrompt`). The text is sent only when a layer above the\ndefault supplies it, so a host with no `systemPrompt` sends no system message,\nas before. The prompt declares the tier the assistant asks for, `ai.profile: 'best'`;\n`resolveChatAssistantTier({ db, tenantId })` reads it back through\n`resolvePrompt` (so config and stored layers apply) and a host binds the\nturn's model at that tier.\n\n## A workflow step's turn (child run)\n\nA host's trusted `internalTurn` may return `step: { parent, prompt,\nstepIndex, name }` (the template-sveltekit host does, for each workflow step\nit runs through the assistant route). The turn's run is then a CHILD of the\nworkflow run (`parent_run_id`, opened with a `handoff` event in the parent\nnamed after the step, in the same transaction); its calls carry the parent's\nclaim fence and are tracked under the step's registered `prompt` (whose text\nfollows the host's system prompt), so they roll into the parent's inclusive\ntotals and budget. A parent stop or limit stops the child's next call, and\nwhen the turn ends a stopped or cancelled child stops the parent the same way\n(`stopAiRunForChild`); cancelling the parent cancels the child. The turn\ncloses the `handoff` with how the child ended. A step on an external engine\nis the same child run with its one engine call. Tests:\n`turn-tracking-child.test.ts`.\n"
4595
+ "content": "# Assistant turns as AI runs (#5005)\n\n`mountAssistantRoutes` builds a tracked client per turn\n(`createTrackedAiClient`, the principal's tenant on the request's database,\nover the turn's client, `transcript: false` because chat stores the\nconversation) and passes `tracking` to `runAssistantTurn`\n(`turn-tracking.ts`). The turn then opens one `turn` run before its first\nmodel call (`AssistantTurnRun.open`, definition `chat.assistant.turn`), the\ntool loop calls the tracked client (each model call is a reserved, settled\ncall of the run: one usage row and one `call` event, tagged with the prompt\nkey), tool use is an `action` event and its result an `observation` event\nwhose `parent_event_id` is the action, and the run ends `done` (`cancelled`\nfor an abort, `failed` for an error). Messages are never copied into the\ntrajectory: events point at them with `payload_ref` (`chat-message:<id>`).\nA turn that needs an owner approval records a requested `approval` event\n(`payload_ref` `approval:<id>`) and ends `done` with the approval pending; it\ndoes not wait. The decision is recorded as an `approval` event in the NEXT\nturn's run, once, with `parent_event_id` the request in the earlier run\n(`tracking.decisions` reads the thread's decided approvals from the host's\nstore). A chat turn does not run untracked: with usage persistence off it ends\nwith the user-facing error `ai_tracking_disabled` before any call is sent.\nA ChatGPT plan turn is a built-in loop over a host-built client: its calls\nare recorded under the engine (`label` on `createTrackedAiClient`, provider\n`chatgpt`, the bound model unless the response reports one), uncosted, with\n`tier_requested`/`tier_resolved` from the prompt and the selection.\n\n## A turn on an external engine (Claude Code, Codex)\n\nAn external `turnDriver` turn opens the same run. The engine's turn is ONE\ntracked call of it (`AssistantTurnRun.beginEngineCall`, reserved in\n`runExternalAssistantAttempt` before `driver.run`, call id minted first):\nthe engine runs its own loop and reports one result per turn, so its internal\nmodel calls are not seen one by one. The usage row's provider is the engine\nid, its model the one the CLI reported (Claude Code does; Codex does not),\nelse the tier binding's; it carries the prompt key and tiers and is always\nuncosted. Tokens are the CLI's reported usage (`EngineExecution.tokens`,\nsplit into `inputTokens`/`outputTokens`, cache reads and writes in the\ninput); a turn that answered without them is charged what it reserved (ai-runs\nsection 6.4) and its row has NULL token columns. A refused reservation\n(`maxCalls`, `maxTokens`, `maxDurationMs`, or a parent's limit or stop) ends\nthe turn `budget` before the CLI starts; `callTimeoutMs` aborts the CLI and\nfails the turn. A turn that fails, is cancelled or hands off to a workflow is\nsettled with its tokens when the CLI reported them, else released. Limits:\n`maxSteps` cannot bound the CLI's internal rounds (a workflow parent's step\nlimit still refuses the child's call), and a parent stop or cancel during an\nengine turn takes effect at its end, not by interrupting the CLI. Tests:\n`sveltekit.test.ts` (external engine), `engines.test.ts` (real driver over\nthe stub CLI), `turn-tracking-child.test.ts`.\n\nThe system prompt is the registered prompt `chat.assistant.system`\n(`chatAssistantSystemPrompt`): the host's `systemPrompt` option is its runtime\nlayer and an app or tenant override of the key replaces it\n(`resolveChatAssistantPrompt`). The text is sent only when a layer above the\ndefault supplies it, so a host with no `systemPrompt` sends no system message,\nas before. The prompt declares the tier the assistant asks for, `ai.profile: 'best'`;\n`resolveChatAssistantTier({ db, tenantId })` reads it back through\n`resolvePrompt` (so config and stored layers apply) and a host binds the\nturn's model at that tier.\n\n## A workflow step's turn (child run)\n\nA host's trusted `internalTurn` may return `step: { parent, prompt,\nstepIndex, name }` (the template-sveltekit host does, for each workflow step\nit runs through the assistant route). The turn's run is then a CHILD of the\nworkflow run (`parent_run_id`, opened with a `handoff` event in the parent\nnamed after the step, in the same transaction); its calls carry the parent's\nclaim fence and are tracked under the step's registered `prompt` (whose text\nfollows the host's system prompt), so they roll into the parent's inclusive\ntotals and budget. A parent stop or limit stops the child's next call, and\nwhen the turn ends a stopped or cancelled child stops the parent the same way\n(`stopAiRunForChild`); cancelling the parent cancels the child. The turn\ncloses the `handoff` with how the child ended. A step on an external engine\nis the same child run with its one engine call. Tests:\n`turn-tracking-child.test.ts`.\n\n\n### Tool-free hosts without chat storage\n\n`runWorkflowStepTurn(options: WorkflowStepTurnOptions): Promise<string>` is the\nsame internal child-turn runner for a host with no chat rooms, session or HTTP\nrequest. Pass `tracking` with its resolved registered `prompt`, tenant-bound\n`tracked` client and required `parent: { context, stepIndex, name }`, the\nserver-authorized `principal`, `selection`, `signal`, and either `ai` or\n`turnDriver`. It offers no tools, persists no chat messages and returns the raw\nanswer for the workflow's schema/check. External drivers must also deny tools\nat their MCP execution boundary. Never expose this trusted API as request input.\nThe existing `chatClientForTracking(ai: object)` adapter is also exported from\nthe root so a host can bind its chat-only provider to core without duplicating\nthe adapter. It preserves parent budget stops and claim errors rather than returning a\nsynthetic chat error as plan output. Existing route and turn callers are\nunchanged. Tests: `workflow-step-turn.test.ts`.\n"
4593
4596
  },
4594
4597
  {
4595
4598
  "path": "agents/ai-unavailable.md",
@@ -5,10 +5,10 @@ description: "Chat rooms, DMs, threads, and agent conversations for the SMRT fra
5
5
  status: "stable"
6
6
  generated:
7
7
  by: "smrt/scripts/generate-knowledge-okf.ts"
8
- at: "2026-11-16T15:42:51Z"
8
+ at: "2026-11-16T23:22:04Z"
9
9
  audience: "internal"
10
10
  evidence_level: "source-inspected"
11
- source_revision: "sha256:1db30214dd6191d94dac322248575c3b48d27a7daed4daa069964eb5af925e0e"
11
+ source_revision: "sha256:ffa6cc6b9f69c95ae0c8f8a89aaa579ec528c7d6b294375506eb8d82482c5acf"
12
12
  sources:
13
13
  - id: "manifest"
14
14
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/chat/package.json"
@@ -1420,6 +1420,13 @@ async function handleConfirmAction(requestId: string) {
1420
1420
  .smrt-assistant-dock__markdown :global(:is(ul, ol)) {
1421
1421
  padding-inline-start: 1.25em;
1422
1422
  }
1423
+ .smrt-assistant-dock__markdown :global(table) {
1424
+ display: block;
1425
+ overflow-x: auto;
1426
+ }
1427
+ .smrt-assistant-dock__markdown :global(:is(th, td)) {
1428
+ padding: 0.15em 0.5em;
1429
+ }
1423
1430
  .smrt-assistant-dock__markdown :global(pre) {
1424
1431
  overflow-x: auto;
1425
1432
  white-space: pre;
@@ -1631,5 +1638,12 @@ async function handleConfirmAction(requestId: string) {
1631
1638
  background: var(--smrt-color-error-container);
1632
1639
  border-bottom: var(--smrt-hairline);
1633
1640
  }
1641
+ .smrt-assistant-dock__markdown :global(table) {
1642
+ border-collapse: collapse;
1643
+ }
1644
+ .smrt-assistant-dock__markdown :global(:is(th, td)) {
1645
+ border: 1px solid currentColor;
1646
+ text-align: start;
1647
+ }
1634
1648
  }
1635
1649
  </style>
@@ -11,11 +11,16 @@
11
11
  *
12
12
  * Supported: paragraphs (single newlines become `<br>`), `#`/`##`/`###`
13
13
  * headings, `-`/`*`/`+` and `1.`/`1)` lists (one level), fenced code blocks
14
- * (``` or ~~~), inline `code`, `**bold**`/`__bold__`, `*italic*`/`_italic_`,
14
+ * (``` or ~~~), pipe tables (a header row, a `---` delimiter row, then
15
+ * body rows; cells hold inline Markdown, column alignment is ignored),
16
+ * inline `code`, `**bold**`/`__bold__`, `*italic*`/`_italic_`,
15
17
  * and `[text](https://…)` links. Anything else renders as literal text.
16
18
  */
17
19
  /** Escape text for an HTML text node or a double-quoted attribute value. */
18
20
  export declare function escapeHtml(text: string): string;
21
+ /** Table budget: wider or larger tables render as escaped plain text. */
22
+ export declare const MAX_TABLE_COLUMNS = 20;
23
+ export declare const MAX_TABLE_CELLS = 2000;
19
24
  /**
20
25
  * Render assistant Markdown to sanitized HTML. Safe for `{@html}`: see the
21
26
  * module comment for the exact output vocabulary.
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-markdown.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/assistant-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAgGD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAmG9D"}
1
+ {"version":3,"file":"assistant-markdown.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/assistant-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAUH,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAWD,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,eAAe,OAAO,CAAC;AAkHpC;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAiJ9D"}
@@ -11,7 +11,9 @@
11
11
  *
12
12
  * Supported: paragraphs (single newlines become `<br>`), `#`/`##`/`###`
13
13
  * headings, `-`/`*`/`+` and `1.`/`1)` lists (one level), fenced code blocks
14
- * (``` or ~~~), inline `code`, `**bold**`/`__bold__`, `*italic*`/`_italic_`,
14
+ * (``` or ~~~), pipe tables (a header row, a `---` delimiter row, then
15
+ * body rows; cells hold inline Markdown, column alignment is ignored),
16
+ * inline `code`, `**bold**`/`__bold__`, `*italic*`/`_italic_`,
15
17
  * and `[text](https://…)` links. Anything else renders as literal text.
16
18
  */
17
19
  const HTML_ESCAPES = {
@@ -33,6 +35,10 @@ const FENCE = /^ {0,3}(`{3,}|~{3,})[ \t]*([A-Za-z0-9_+-]{0,32})[ \t]*$/;
33
35
  const HEADING = /^ {0,3}(#{1,3})[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/;
34
36
  const UNORDERED_ITEM = /^ {0,3}[-*+][ \t]+(.*)$/;
35
37
  const ORDERED_ITEM = /^ {0,3}(\d{1,9})[.)][ \t]+(.*)$/;
38
+ const TABLE_DELIMITER_CELL = /^:?-{1,}:?$/;
39
+ /** Table budget: wider or larger tables render as escaped plain text. */
40
+ export const MAX_TABLE_COLUMNS = 20;
41
+ export const MAX_TABLE_CELLS = 2000;
36
42
  const CONTINUATION = /^(?: {2,}|\t)\S/;
37
43
  /** A safe absolute http(s) URL for an href, already attribute-escaped. */
38
44
  function safeHref(raw) {
@@ -99,6 +105,31 @@ function inline(text) {
99
105
  } while (out !== previous);
100
106
  return out;
101
107
  }
108
+ /** Cells of a pipe-table row (outer pipes optional, `\\|` is a literal pipe). */
109
+ function tableCells(line) {
110
+ if (!line.includes('|'))
111
+ return null;
112
+ const body = line
113
+ .trim()
114
+ .replace(/^\|/, '')
115
+ .replace(/(?<!\\)\|$/, '');
116
+ return body
117
+ .split(/(?<!\\)\|/)
118
+ .map((cell) => cell.trim().replace(/\\\|/g, '|'));
119
+ }
120
+ /** The header cells when `line` + `next` open a table, else null. */
121
+ function tableHeader(line, next) {
122
+ if (next === undefined || next.length > LINE_PARSE_LIMIT)
123
+ return null;
124
+ const header = tableCells(line);
125
+ const delimiter = tableCells(next);
126
+ if (!header ||
127
+ !delimiter ||
128
+ header.length !== delimiter.length ||
129
+ !delimiter.every((cell) => TABLE_DELIMITER_CELL.test(cell)))
130
+ return null;
131
+ return header;
132
+ }
102
133
  /**
103
134
  * Render assistant Markdown to sanitized HTML. Safe for `{@html}`: see the
104
135
  * module comment for the exact output vocabulary.
@@ -161,6 +192,41 @@ export function renderAssistantMarkdown(source) {
161
192
  flush();
162
193
  continue;
163
194
  }
195
+ const header = tableHeader(line, lines[index + 1]);
196
+ if (header) {
197
+ flush();
198
+ const columns = header.length;
199
+ const rows = [];
200
+ const sourceLines = [line, lines[index + 1]];
201
+ let rowCount = 0;
202
+ index += 2;
203
+ while (index < lines.length &&
204
+ lines[index].trim() !== '' &&
205
+ lines[index].length <= LINE_PARSE_LIMIT) {
206
+ const cells = tableCells(lines[index]);
207
+ if (!cells)
208
+ break;
209
+ sourceLines.push(lines[index]);
210
+ rowCount += 1;
211
+ // Over budget: stop building rows (the block falls back to text).
212
+ if (columns <= MAX_TABLE_COLUMNS &&
213
+ columns * (rowCount + 1) <= MAX_TABLE_CELLS) {
214
+ // Short rows are padded and long rows trimmed to the header width.
215
+ const row = Array.from({ length: columns }, (_, c) => cells[c] ?? '');
216
+ rows.push(`<tr>${row.map((c) => `<td>${inline(c)}</td>`).join('')}</tr>`);
217
+ }
218
+ index += 1;
219
+ }
220
+ index -= 1;
221
+ if (columns > MAX_TABLE_COLUMNS ||
222
+ columns * (rowCount + 1) > MAX_TABLE_CELLS) {
223
+ blocks.push(`<p>${sourceLines.map((l) => escapeHtml(l)).join('<br>')}</p>`);
224
+ continue;
225
+ }
226
+ blocks.push(`<table><thead><tr>${header.map((c) => `<th>${inline(c)}</th>`).join('')}</tr></thead>` +
227
+ `<tbody>${rows.join('')}</tbody></table>`);
228
+ continue;
229
+ }
164
230
  const heading = HEADING.exec(line);
165
231
  if (heading) {
166
232
  flush();
package/dist/sveltekit.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as sendAgentReply, i as clientRequestMessageId, n as ChatService, t as ChatClientRequestConflictError } from "./chunks/ChatService-CDLAEJms.js";
2
- import { At as assertToolRunType, D as createSessionContinuationStore, Dt as chatUnavailableBody, F as resolveChatAssistantPrompt, I as resolveChatAssistantTier, N as chatAssistantSystemText, O as runAssistantTurn, Ot as chatUnconfiguredBody, P as chatClientForTracking, T as createAssistantTurnResponse, V as FALLBACK_HISTORY_PLACEHOLDER, W as MAX_CLIENT_TOOL_RESULT_CHARS, b as AssistantTurnUserError, it as buildManifestToolCatalog, kt as ToolRunTypeRefusal, mt as sanitizeClientToolDeclarations, ot as invokeManifestTool, st as isFallbackReply, y as ASSISTANT_TURN_GENERIC_ERROR } from "./chunks/chat-stream-1RJmQO0D.js";
2
+ import { At as assertToolRunType, D as createSessionContinuationStore, Dt as chatUnavailableBody, F as resolveChatAssistantPrompt, I as resolveChatAssistantTier, N as chatAssistantSystemText, O as runAssistantTurn, Ot as chatUnconfiguredBody, P as chatClientForTracking, T as createAssistantTurnResponse, V as FALLBACK_HISTORY_PLACEHOLDER, W as MAX_CLIENT_TOOL_RESULT_CHARS, b as AssistantTurnUserError, it as buildManifestToolCatalog, kt as ToolRunTypeRefusal, mt as sanitizeClientToolDeclarations, ot as invokeManifestTool, st as isFallbackReply, y as ASSISTANT_TURN_GENERIC_ERROR } from "./chunks/chat-stream-Cvl2kFvI.js";
3
3
  import { createAssistantApprovalBridge } from "./assistant-approvals.js";
4
4
  import { describeAssistantTool } from "./tool-summary.js";
5
5
  import { ObjectRegistry, createTrackedAiClient, resolveDatabase, resolveInferenceTarget } from "@happyvertical/smrt-core";
@@ -1 +1 @@
1
- {"version":3,"file":"tool-summary.d.ts","sourceRoot":"","sources":["../src/tool-summary.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,aAAa,CAAC,CAAC;AAE9E,qEAAqE;AACrE,MAAM,MAAM,qBAAqB,GAAG,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,SAAS,CAAA;CAAE,KACnC,MAAM,CAAC;AA8CZ,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,EAAE,qBAkEnC,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,EAAE,UAAO,EACT,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE,MAAM,CA6BR"}
1
+ {"version":3,"file":"tool-summary.d.ts","sourceRoot":"","sources":["../src/tool-summary.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,aAAa,CAAC,CAAC;AAE9E,qEAAqE;AACrE,MAAM,MAAM,qBAAqB,GAAG,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,SAAS,CAAA;CAAE,KACnC,MAAM,CAAC;AAyDZ,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,EAAE,qBAqEnC,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,EAAE,UAAO,EACT,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE,MAAM,CA6BR"}
@@ -30,8 +30,13 @@ function payload(value, depth = 0, plainText = false) {
30
30
  }
31
31
  return record;
32
32
  }
33
+ function failureReason(observation) {
34
+ const record = payload(observation, 0, false);
35
+ if (!record || Array.isArray(record)) return;
36
+ return safeText(record.summary) ?? safeText(record.message) ?? safeText(record.error);
37
+ }
33
38
  var describeAssistantTool = (name, _args, outcome, options) => {
34
- if (outcome && !outcome.ok) return "Could not complete this action";
39
+ if (outcome && !outcome.ok) return failureReason(outcome.observation) ?? "Could not complete this action";
35
40
  const special = {
36
41
  app_describe: "Checked the app structure",
37
42
  "app.describe": "Checked the app structure",
@@ -80,7 +85,7 @@ var describeAssistantTool = (name, _args, outcome, options) => {
80
85
  return `${verb[1]} ${noun}${displayName ? ` ${displayName}` : ""}`;
81
86
  };
82
87
  function toolSummary(name, result, ok = true, options) {
83
- if (!ok) return "Could not complete this action";
88
+ if (!ok) return failureReason(result) ?? "Could not complete this action";
84
89
  const compatible = options?.plainTextSummary ? payload(result, 0, true) : void 0;
85
90
  const text = safeText(options?.plainTextSummary ? compatible && !Array.isArray(compatible) ? compatible.summary : void 0 : result);
86
91
  const summary = text && (options?.plainTextSummary || /^(?:Added|Updated|Deleted|Removed|Created|Checked|Looked up|Completed|Could not)\b/i.test(text)) ? text : void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-summary.js","names":[],"sources":["../src/tool-summary.ts"],"sourcesContent":["/** Plain-language tool labels shared by the built-in loop and external drivers. */\nimport type { ToolInvocation } from './tool-loop.js';\n\nexport type AssistantToolOutcome = Pick<ToolInvocation, 'ok' | 'observation'>;\n\n/** The existing describe seam, with an optional completed result. */\nexport type DescribeAssistantTool = (\n name: string,\n args?: Record<string, unknown>,\n outcome?: AssistantToolOutcome,\n options?: { recordLabels?: 'generic' },\n) => string;\n\n// Tool payloads belong to the model, never to a chip or its title attribute.\nfunction safeText(value: unknown): string | undefined {\n if (typeof value !== 'string') return;\n const text = value.replace(/\\s+/g, ' ').trim();\n if (\n !text ||\n /[{}[\\]<>]|(?:\\/|[A-Z]:\\\\)\\S+|\\b(?:ALTER TABLE|CREATE TABLE|DROP TABLE|SELECT .* FROM|INSERT INTO|DELETE FROM|Bearer|token|password|secret|api.?key)\\b|\\b(?:sk-|eyJ)[\\w-]+|\\b[\\w-]{32,}\\b/i.test(\n text,\n )\n )\n return;\n return text.length > 160 ? `${text.slice(0, 159)}…` : text;\n}\n\nfunction payload(\n value: unknown,\n depth = 0,\n plainText = false,\n): Record<string, unknown> | unknown[] | undefined {\n if (depth > 6) return;\n if (typeof value === 'string') {\n try {\n return payload(JSON.parse(value), depth + 1, plainText);\n } catch {\n return plainText ? { summary: value } : undefined;\n }\n }\n if (!value || typeof value !== 'object') return;\n if (Array.isArray(value)) return value;\n const record = value as Record<string, unknown>;\n if (typeof record.summary === 'string') return record;\n for (const key of ['data', 'result', 'structuredContent']) {\n const found = payload(record[key], depth + 1, plainText);\n if (found) return found;\n }\n if (Array.isArray(record.content)) {\n for (const block of record.content) {\n const found = payload(block?.text, depth + 1, plainText);\n if (found) return found;\n }\n }\n return record;\n}\n\n/** Short bounded summaries; never echoes an unknown tool name or a raw payload. */\nexport const describeAssistantTool: DescribeAssistantTool = (\n name,\n _args,\n outcome,\n options,\n) => {\n if (outcome && !outcome.ok) return 'Could not complete this action';\n const special: Record<string, string> = {\n app_describe: 'Checked the app structure',\n 'app.describe': 'Checked the app structure',\n 'app.history': 'Checked app history',\n 'recipes.search': 'Looked for useful lists',\n 'recipes.describe': 'Checked how a list works',\n app_history: 'Checked app history',\n approval_pending: 'Checked pending approvals',\n };\n if (outcome && special[name]) return special[name];\n if (\n outcome &&\n options?.recordLabels === 'generic' &&\n /(?:_list|_search|_get)$/.test(name)\n )\n return 'Checked records';\n const match =\n /^([a-z][a-z\\d]*(?:[._-][a-z][a-z\\d]*)*)[._-](create|update|delete|remove|list|search|read|get)$/i.exec(\n name,\n );\n const record = outcome ? payload(outcome.observation) : undefined;\n const summary =\n record && !Array.isArray(record) ? safeText(record.summary) : undefined;\n if (summary) return summary;\n if (outcome && options?.recordLabels === 'generic')\n return 'Completed this action';\n if (!match) {\n return outcome ? 'Completed this action' : 'Working on this action';\n }\n const plural = match[1]\n .replace(/[._-]/g, ' ')\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n .toLowerCase();\n const noun = plural.replace(/ies$/, 'y').replace(/(?<!s)s$/, '');\n const action = match[2].toLowerCase();\n const verb = {\n create: ['Adding', 'Added'],\n update: ['Updating', 'Updated'],\n delete: ['Deleting', 'Deleted'],\n remove: ['Deleting', 'Deleted'],\n list: ['Looking up', 'Looked up'],\n search: ['Looking up', 'Looked up'],\n read: ['Looking up', 'Looked up'],\n get: ['Looking up', 'Looked up'],\n }[action] ?? ['Working on', 'Completed'];\n if (!outcome)\n return `${verb[0]} ${['list', 'search', 'read'].includes(action) ? plural : noun}`;\n if (['list', 'search', 'read'].includes(action)) {\n const rows = Array.isArray(record)\n ? record\n : (record?.items ?? record?.rows);\n const count = Array.isArray(rows) ? rows.length : undefined;\n return `${verb[1]} ${count === undefined ? '' : `${count} `}${count === 1 ? noun : plural}`;\n }\n const displayName =\n record && !Array.isArray(record)\n ? safeText(record.name ?? record.displayName ?? record.title)\n : undefined;\n return `${verb[1]} ${noun}${displayName ? ` ${displayName}` : ''}`;\n};\n\n/** Shell-compatible result entry point, using the same describe/label mechanism. */\nexport function toolSummary(\n name: string,\n result: unknown,\n ok = true,\n options?: { recordLabels?: 'generic'; plainTextSummary?: boolean },\n): string {\n if (!ok) return 'Could not complete this action';\n const compatible = options?.plainTextSummary\n ? payload(result, 0, true)\n : undefined;\n const text = safeText(\n options?.plainTextSummary\n ? compatible && !Array.isArray(compatible)\n ? compatible.summary\n : undefined\n : result,\n );\n const summary =\n text &&\n (options?.plainTextSummary ||\n /^(?:Added|Updated|Deleted|Removed|Created|Checked|Looked up|Completed|Could not)\\b/i.test(\n text,\n ))\n ? text\n : undefined;\n return describeAssistantTool(\n name,\n undefined,\n {\n ok,\n observation: summary ? { summary } : result,\n },\n options,\n );\n}\n"],"mappings":";AAcA,SAAS,SAAS,OAAoC;CACpD,IAAI,OAAO,UAAU,UAAU;CAC/B,MAAM,OAAO,MAAM,QAAQ,QAAQ,GAAG,CAAA,CAAE,KAAK;CAC7C,IACE,CAAC,QACD,4LAA4L,KAC1L,IACF,GAEA;CACF,OAAO,KAAK,SAAS,MAAM,GAAG,KAAK,MAAM,GAAG,GAAG,EAAC,UAAM;AACxD;AAEA,SAAS,QACP,OACA,QAAQ,GACR,YAAY,OACqC;CACjD,IAAI,QAAQ,GAAG;CACf,IAAI,OAAO,UAAU,UACnB,IAAI;EACF,OAAO,QAAQ,KAAK,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,SAAS,mBACL,cAAc,CAAC,MAAM,QAAQ,UAAU,IACrC,WAAW,UACX,KAAA,IACF,MACN;CACA,MAAM,UACJ,SACC,SAAS,oBACR,sFAAsF,KACpF,IACF,KACE,OACA,KAAA;CACN,OAAO,sBACL,MACA,KAAA,GACA;EACE;EACA,aAAa,UAAU,EAAE,QAAQ,IAAI;CACvC,GACA,OACF;AACF"}
1
+ {"version":3,"file":"tool-summary.js","names":[],"sources":["../src/tool-summary.ts"],"sourcesContent":["/** Plain-language tool labels shared by the built-in loop and external drivers. */\nimport type { ToolInvocation } from './tool-loop.js';\n\nexport type AssistantToolOutcome = Pick<ToolInvocation, 'ok' | 'observation'>;\n\n/** The existing describe seam, with an optional completed result. */\nexport type DescribeAssistantTool = (\n name: string,\n args?: Record<string, unknown>,\n outcome?: AssistantToolOutcome,\n options?: { recordLabels?: 'generic' },\n) => string;\n\n// Tool payloads belong to the model, never to a chip or its title attribute.\nfunction safeText(value: unknown): string | undefined {\n if (typeof value !== 'string') return;\n const text = value.replace(/\\s+/g, ' ').trim();\n if (\n !text ||\n /[{}[\\]<>]|(?:\\/|[A-Z]:\\\\)\\S+|\\b(?:ALTER TABLE|CREATE TABLE|DROP TABLE|SELECT .* FROM|INSERT INTO|DELETE FROM|Bearer|token|password|secret|api.?key)\\b|\\b(?:sk-|eyJ)[\\w-]+|\\b[\\w-]{32,}\\b/i.test(\n text,\n )\n )\n return;\n return text.length > 160 ? `${text.slice(0, 159)}…` : text;\n}\n\nfunction payload(\n value: unknown,\n depth = 0,\n plainText = false,\n): Record<string, unknown> | unknown[] | undefined {\n if (depth > 6) return;\n if (typeof value === 'string') {\n try {\n return payload(JSON.parse(value), depth + 1, plainText);\n } catch {\n return plainText ? { summary: value } : undefined;\n }\n }\n if (!value || typeof value !== 'object') return;\n if (Array.isArray(value)) return value;\n const record = value as Record<string, unknown>;\n if (typeof record.summary === 'string') return record;\n for (const key of ['data', 'result', 'structuredContent']) {\n const found = payload(record[key], depth + 1, plainText);\n if (found) return found;\n }\n if (Array.isArray(record.content)) {\n for (const block of record.content) {\n const found = payload(block?.text, depth + 1, plainText);\n if (found) return found;\n }\n }\n return record;\n}\n\n/** The plain reason a tool failed, when its error carries a safe sentence. */\nfunction failureReason(observation: unknown): string | undefined {\n const record = payload(observation, 0, false);\n if (!record || Array.isArray(record)) return;\n return (\n safeText(record.summary) ??\n safeText(record.message) ??\n safeText(record.error)\n );\n}\n\n/** Short bounded summaries; never echoes an unknown tool name or a raw payload. */\nexport const describeAssistantTool: DescribeAssistantTool = (\n name,\n _args,\n outcome,\n options,\n) => {\n if (outcome && !outcome.ok)\n return (\n failureReason(outcome.observation) ?? 'Could not complete this action'\n );\n const special: Record<string, string> = {\n app_describe: 'Checked the app structure',\n 'app.describe': 'Checked the app structure',\n 'app.history': 'Checked app history',\n 'recipes.search': 'Looked for useful lists',\n 'recipes.describe': 'Checked how a list works',\n app_history: 'Checked app history',\n approval_pending: 'Checked pending approvals',\n };\n if (outcome && special[name]) return special[name];\n if (\n outcome &&\n options?.recordLabels === 'generic' &&\n /(?:_list|_search|_get)$/.test(name)\n )\n return 'Checked records';\n const match =\n /^([a-z][a-z\\d]*(?:[._-][a-z][a-z\\d]*)*)[._-](create|update|delete|remove|list|search|read|get)$/i.exec(\n name,\n );\n const record = outcome ? payload(outcome.observation) : undefined;\n const summary =\n record && !Array.isArray(record) ? safeText(record.summary) : undefined;\n if (summary) return summary;\n if (outcome && options?.recordLabels === 'generic')\n return 'Completed this action';\n if (!match) {\n return outcome ? 'Completed this action' : 'Working on this action';\n }\n const plural = match[1]\n .replace(/[._-]/g, ' ')\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n .toLowerCase();\n const noun = plural.replace(/ies$/, 'y').replace(/(?<!s)s$/, '');\n const action = match[2].toLowerCase();\n const verb = {\n create: ['Adding', 'Added'],\n update: ['Updating', 'Updated'],\n delete: ['Deleting', 'Deleted'],\n remove: ['Deleting', 'Deleted'],\n list: ['Looking up', 'Looked up'],\n search: ['Looking up', 'Looked up'],\n read: ['Looking up', 'Looked up'],\n get: ['Looking up', 'Looked up'],\n }[action] ?? ['Working on', 'Completed'];\n if (!outcome)\n return `${verb[0]} ${['list', 'search', 'read'].includes(action) ? plural : noun}`;\n if (['list', 'search', 'read'].includes(action)) {\n const rows = Array.isArray(record)\n ? record\n : (record?.items ?? record?.rows);\n const count = Array.isArray(rows) ? rows.length : undefined;\n return `${verb[1]} ${count === undefined ? '' : `${count} `}${count === 1 ? noun : plural}`;\n }\n const displayName =\n record && !Array.isArray(record)\n ? safeText(record.name ?? record.displayName ?? record.title)\n : undefined;\n return `${verb[1]} ${noun}${displayName ? ` ${displayName}` : ''}`;\n};\n\n/** Shell-compatible result entry point, using the same describe/label mechanism. */\nexport function toolSummary(\n name: string,\n result: unknown,\n ok = true,\n options?: { recordLabels?: 'generic'; plainTextSummary?: boolean },\n): string {\n if (!ok) return failureReason(result) ?? 'Could not complete this action';\n const compatible = options?.plainTextSummary\n ? payload(result, 0, true)\n : undefined;\n const text = safeText(\n options?.plainTextSummary\n ? compatible && !Array.isArray(compatible)\n ? compatible.summary\n : undefined\n : result,\n );\n const summary =\n text &&\n (options?.plainTextSummary ||\n /^(?:Added|Updated|Deleted|Removed|Created|Checked|Looked up|Completed|Could not)\\b/i.test(\n text,\n ))\n ? text\n : undefined;\n return describeAssistantTool(\n name,\n undefined,\n {\n ok,\n observation: summary ? { summary } : result,\n },\n options,\n );\n}\n"],"mappings":";AAcA,SAAS,SAAS,OAAoC;CACpD,IAAI,OAAO,UAAU,UAAU;CAC/B,MAAM,OAAO,MAAM,QAAQ,QAAQ,GAAG,CAAA,CAAE,KAAK;CAC7C,IACE,CAAC,QACD,4LAA4L,KAC1L,IACF,GAEA;CACF,OAAO,KAAK,SAAS,MAAM,GAAG,KAAK,MAAM,GAAG,GAAG,EAAC,UAAM;AACxD;AAEA,SAAS,QACP,OACA,QAAQ,GACR,YAAY,OACqC;CACjD,IAAI,QAAQ,GAAG;CACf,IAAI,OAA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AAQ,OAAO,eAAe,OAAO,KAAK,IAC1D,KAAA;CACN,OAAO,GAAG,KAAK,GAAE,GAAI,OAAO,cAAc,IAAI,gBAAgB;AAChE;AAGO,SAAS,YACd,MACA,QACA,KAAK,MACL,SACQ;CACR,IAAI,CAAC,IAAI,OAAO,cAAc,MAAM,KAAK;CACzC,MAAM,aAAa,SAAS,mBACxB,QAAQ,QAAQ,GAAG,IAAI,IACvB,KAAA;CACJ,MAAM,OAAO,SACX,SAAS,mBACL,cAAc,CAAC,MAAM,QAAQ,UAAU,IACrC,WAAW,UACX,KAAA,IACF,MACN;CACA,MAAM,UACJ,SACC,SAAS,oBACR,sFAAsF,KACpF,IACF,KACE,OACA,KAAA;CACN,OAAO,sBACL,MACA,KAAA,GACA;EACE;EACA,aAAa,UAAU,EAAE,QAAQ,IAAI;CACvC,GACA,OACF;AACF"}
@@ -0,0 +1,17 @@
1
+ import { type AssistantTurnOptions } from './assistant-turn.js';
2
+ import type { AssistantTurnTracking } from './turn-tracking.js';
3
+ /** Server-selected engine and registered prompt for one workflow child turn. */
4
+ export interface WorkflowStepTurnOptions extends Pick<AssistantTurnOptions, 'ai' | 'turnDriver' | 'principal' | 'selection' | 'signal' | 'maxTokens'> {
5
+ tracking: AssistantTurnTracking & {
6
+ parent: NonNullable<AssistantTurnTracking['parent']>;
7
+ };
8
+ }
9
+ /**
10
+ * Run a private, tool-free child turn using the same runner as `internalTurn`.
11
+ * The host binds its engine (and denies tools at an external engine's MCP
12
+ * boundary). No messages, sessions, tools or approvals are created. Calls and
13
+ * reported usage belong to the child; the parent's handoff, fence and budgets
14
+ * remain authoritative. Returns JSON text for the workflow's own validator.
15
+ */
16
+ export declare function runWorkflowStepTurn(options: WorkflowStepTurnOptions): Promise<string>;
17
+ //# sourceMappingURL=workflow-step-turn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-step-turn.d.ts","sourceRoot":"","sources":["../src/workflow-step-turn.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,gFAAgF;AAChF,MAAM,WAAW,uBACf,SAAQ,IAAI,CACV,oBAAoB,EACpB,IAAI,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CACzE;IACD,QAAQ,EAAE,qBAAqB,GAAG;QAChC,MAAM,EAAE,WAAW,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;KACtD,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC,CA6CjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-chat",
3
- "version": "0.62.3",
3
+ "version": "0.62.4",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Chat rooms, DMs, threads, and agent conversations for the SMRT framework",
6
6
  "type": "module",
@@ -97,24 +97,24 @@
97
97
  "@happyvertical/animation": "0.5.0",
98
98
  "@happyvertical/ai": "^0.113.0",
99
99
  "@happyvertical/speech": "^0.113.0",
100
- "@happyvertical/smrt-images": "0.62.3",
101
- "@happyvertical/smrt-app-runtime": "0.62.3",
102
- "@happyvertical/smrt-agents": "0.62.3",
103
- "@happyvertical/smrt-assets": "0.62.3",
104
- "@happyvertical/smrt-config": "0.62.3",
105
- "@happyvertical/smrt-core": "0.62.3",
106
- "@happyvertical/smrt-prompts": "0.62.3",
107
- "@happyvertical/smrt-personas": "0.62.3",
108
- "@happyvertical/smrt-profiles": "0.62.3",
109
- "@happyvertical/smrt-reports": "0.62.3",
110
- "@happyvertical/smrt-tenancy": "0.62.3",
111
- "@happyvertical/smrt-types": "0.62.3",
112
- "@happyvertical/smrt-ui": "0.62.3",
113
- "@happyvertical/smrt-users": "0.62.3",
100
+ "@happyvertical/smrt-images": "0.62.4",
101
+ "@happyvertical/smrt-app-runtime": "0.62.4",
102
+ "@happyvertical/smrt-agents": "0.62.4",
103
+ "@happyvertical/smrt-assets": "0.62.4",
104
+ "@happyvertical/smrt-config": "0.62.4",
105
+ "@happyvertical/smrt-core": "0.62.4",
106
+ "@happyvertical/smrt-prompts": "0.62.4",
107
+ "@happyvertical/smrt-personas": "0.62.4",
108
+ "@happyvertical/smrt-profiles": "0.62.4",
109
+ "@happyvertical/smrt-reports": "0.62.4",
110
+ "@happyvertical/smrt-tenancy": "0.62.4",
111
+ "@happyvertical/smrt-types": "0.62.4",
112
+ "@happyvertical/smrt-ui": "0.62.4",
113
+ "@happyvertical/smrt-users": "0.62.4",
114
114
  "@happyvertical/sql": "^0.113.0",
115
115
  "@happyvertical/images": "^0.113.0",
116
116
  "gsap": "^3.13.0",
117
- "@happyvertical/smrt-inference": "0.62.3"
117
+ "@happyvertical/smrt-inference": "0.62.4"
118
118
  },
119
119
  "peerDependencies": {
120
120
  "svelte": "^5.57.0"
@@ -125,10 +125,10 @@
125
125
  }
126
126
  },
127
127
  "devDependencies": {
128
- "@happyvertical/smrt-playground": "0.62.3",
129
- "@happyvertical/smrt-scanner": "0.62.3",
130
- "@happyvertical/smrt-vitest": "0.62.3",
131
- "@happyvertical/smrt-web": "0.62.3",
128
+ "@happyvertical/smrt-playground": "0.62.4",
129
+ "@happyvertical/smrt-scanner": "0.62.4",
130
+ "@happyvertical/smrt-vitest": "0.62.4",
131
+ "@happyvertical/smrt-web": "0.62.4",
132
132
  "@mlc-ai/web-llm": "^0.2.85",
133
133
  "bitgpu": "0.19.1",
134
134
  "@sveltejs/kit": "2.69.1",