@happyvertical/smrt-chat 0.61.6 → 0.62.0
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.
- package/AGENTS.md +4 -0
- package/agents/assistant-turn-runs.md +74 -0
- package/agents/tool-summaries.md +1 -1
- package/agents/turn-drivers.md +64 -46
- package/dist/assistant-approvals.js +1 -1
- package/dist/assistant-approvals.js.map +1 -1
- package/dist/assistant-turn-driver.d.ts +11 -8
- package/dist/assistant-turn-driver.d.ts.map +1 -1
- package/dist/assistant-turn-events.d.ts +1 -1
- package/dist/assistant-turn-events.d.ts.map +1 -1
- package/dist/assistant-turn.d.ts +34 -3
- package/dist/assistant-turn.d.ts.map +1 -1
- package/dist/chunks/{ChatService-CeOVzOqN.js → ChatService-CDLAEJms.js} +2 -2
- package/dist/chunks/{ChatService-CeOVzOqN.js.map → ChatService-CDLAEJms.js.map} +1 -1
- package/dist/chunks/assistant-turn-events-DwdCZzQ0.js.map +1 -1
- package/dist/chunks/{chat-stream-Cl8JV-K0.js → chat-stream-BJbmqHsu.js} +742 -254
- package/dist/chunks/chat-stream-BJbmqHsu.js.map +1 -0
- package/dist/engines.d.ts +4 -4
- package/dist/engines.d.ts.map +1 -1
- package/dist/engines.js +22 -24
- package/dist/engines.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/internal/agent-runtime.js +1 -1
- package/dist/manifest.json +2 -1
- package/dist/smrt-knowledge.json +28 -10
- package/dist/smrt-knowledge.okf.md +16 -11
- package/dist/svelte/components/assistant/AssistantDock.svelte +2 -2
- package/dist/svelte/components/assistant/assistant-http-client.d.ts +2 -2
- package/dist/svelte/components/assistant/assistant-http-client.d.ts.map +1 -1
- package/dist/svelte/components/assistant/assistant-http-client.js +5 -5
- package/dist/svelte/components/assistant/assistant-transport.d.ts +7 -6
- package/dist/svelte/components/assistant/assistant-transport.d.ts.map +1 -1
- package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts +3 -3
- package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts.map +1 -1
- package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.js +30 -30
- package/dist/svelte/i18n.d.ts +1 -1
- package/dist/svelte/i18n.js +1 -1
- package/dist/svelte/index.d.ts +1 -1
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/sveltekit.d.ts +55 -24
- package/dist/sveltekit.d.ts.map +1 -1
- package/dist/sveltekit.js +109 -44
- package/dist/sveltekit.js.map +1 -1
- package/dist/tool-loop.d.ts +2 -1
- package/dist/tool-loop.d.ts.map +1 -1
- package/dist/tool-run-types.d.ts +102 -0
- package/dist/tool-run-types.d.ts.map +1 -0
- package/dist/turn-tracking.d.ts +246 -0
- package/dist/turn-tracking.d.ts.map +1 -0
- package/package.json +20 -19
- package/dist/chunks/chat-stream-Cl8JV-K0.js.map +0 -1
- package/dist/work-profile.d.ts +0 -64
- package/dist/work-profile.d.ts.map +0 -1
package/dist/engines.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export { type
|
|
1
|
+
import type { EngineExecution } from '@happyvertical/smrt-inference';
|
|
2
|
+
export { type AssistantModelSelection, type AssistantRunTypeOptions, assertToolRunType, ToolRunTypeRefusal, } from './tool-run-types.js';
|
|
3
3
|
/** Node-only adapters over inference's engines; chat retains transcript ownership. */
|
|
4
4
|
import type { AIInterface } from '@happyvertical/ai';
|
|
5
5
|
import { type AgentTool, type AgentTurnHost, type AgentTurnOptions, type ChatGPTModelOptions, type InferenceEngineId, type InferenceEngineStatusHost } from '@happyvertical/smrt-inference/server';
|
|
@@ -7,7 +7,7 @@ import type { AssistantTurnDriver, AssistantTurnDriverContext } from './assistan
|
|
|
7
7
|
import { type MountAssistantRoutesOptions } from './sveltekit.js';
|
|
8
8
|
import { type DescribeAssistantTool } from './tool-summary.js';
|
|
9
9
|
/** All credentials, working directories and MCP authority are bound by the host per turn. */
|
|
10
|
-
export type AgentCliChatBinding = Pick<AgentTurnOptions, 'mcpUrl' | 'deps' | 'fallback' | 'outputSchema' | 'protection'> & Pick<AgentTurnHost, 'allowTool' | 'approvals'> & {
|
|
10
|
+
export type AgentCliChatBinding = Pick<AgentTurnOptions, 'mcpUrl' | 'deps' | 'fallback' | 'outputSchema' | 'protection' | 'limits'> & Pick<AgentTurnHost, 'allowTool' | 'approvals'> & {
|
|
11
11
|
/** Optional MCP wire-name → canonical offered chat slug mapping. Unknown names deny. */
|
|
12
12
|
canonicalToolName?(name: string): string | undefined;
|
|
13
13
|
/** Existing describe seam, bound to this turn's server-authored vocabulary. */
|
|
@@ -20,7 +20,7 @@ export declare function createAgentCliTurnDriver(options: {
|
|
|
20
20
|
}): AssistantTurnDriver;
|
|
21
21
|
/** An SDK chat client over inference's plan-only model; no API-key fallback. */
|
|
22
22
|
export declare function createChatGPTAssistantAI(options: ChatGPTModelOptions): Promise<Pick<AIInterface, 'chat'> & {
|
|
23
|
-
|
|
23
|
+
getEngineExecution(): EngineExecution | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
/** Per-authenticated-request engine selection, suitable for spreading into mountAssistantRoutes. */
|
|
26
26
|
export declare function createInferenceAssistantAdapters(options: {
|
package/dist/engines.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,sFA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OAAO,CACL,OAAO,EAAE,UAAU,CACjB,WAAW,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC,CAC9D,CAAC,CAAC,CAAC,GACH,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;IAC1C,MAAM,CACJ,OAAO,EAAE,UAAU,CACjB,WAAW,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC,CAC9D,CAAC,CAAC,CAAC,GACH,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACtC,GAAG,CACD,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,UAAU,CACjB,WAAW,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC,CAC9D,CAAC,CAAC,CAAC,GACH,mBAAmB,CAAC;IACvB,OAAO,CACL,OAAO,EAAE,UAAU,CACjB,WAAW,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC,CAC9D,CAAC,CAAC,CAAC,GACH,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,GAAG,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;CAC7D,GAAG,IAAI,CAAC,2BAA2B,EAAE,mBAAmB,GAAG,IAAI,CAAC,CAqEhE"}
|
package/dist/engines.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as assertToolRunType, b as AssistantTurnUserError, ct as isManifestToolEnabled, kt as ToolRunTypeRefusal } from "./chunks/chat-stream-BJbmqHsu.js";
|
|
2
2
|
import { describeAssistantTool } from "./tool-summary.js";
|
|
3
3
|
import { configuredAssistantAI } from "./sveltekit.js";
|
|
4
4
|
import { InferenceUnavailableError } from "@happyvertical/smrt-core/inference-availability";
|
|
@@ -59,7 +59,7 @@ function createAgentCliTurnDriver(options) {
|
|
|
59
59
|
let queue = Promise.resolve();
|
|
60
60
|
let failure;
|
|
61
61
|
let text = "";
|
|
62
|
-
let
|
|
62
|
+
let execution;
|
|
63
63
|
let decision;
|
|
64
64
|
const append = async (message) => {
|
|
65
65
|
for (const call of message.toolCalls ?? []) {
|
|
@@ -77,7 +77,9 @@ function createAgentCliTurnDriver(options) {
|
|
|
77
77
|
try {
|
|
78
78
|
const stop = await runAgentTurn({
|
|
79
79
|
tool: options.tool,
|
|
80
|
-
|
|
80
|
+
...context.selection?.model ? { model: context.selection.model } : {},
|
|
81
|
+
...context.selection?.effort ? { effort: context.selection.effort } : {},
|
|
82
|
+
...binding.limits ? { limits: binding.limits } : {},
|
|
81
83
|
text: context.userMessage,
|
|
82
84
|
mcpUrl: binding.mcpUrl,
|
|
83
85
|
deps: binding.deps,
|
|
@@ -87,9 +89,9 @@ function createAgentCliTurnDriver(options) {
|
|
|
87
89
|
signal,
|
|
88
90
|
host: {
|
|
89
91
|
appendMessage: append,
|
|
90
|
-
recordExecution: async (
|
|
91
|
-
|
|
92
|
-
callbacks.execution?.(
|
|
92
|
+
recordExecution: async (recorded) => {
|
|
93
|
+
execution = recorded;
|
|
94
|
+
callbacks.execution?.(recorded);
|
|
93
95
|
},
|
|
94
96
|
lastSession: async () => null,
|
|
95
97
|
guidance: async () => ({
|
|
@@ -149,7 +151,7 @@ ${JSON.stringify(context.history)}`
|
|
|
149
151
|
if (context.signal.aborted || stop === "aborted") return;
|
|
150
152
|
if (stop === "error" || stop === "timeout") throw new Error("CLI turn failed.");
|
|
151
153
|
callbacks.done({
|
|
152
|
-
|
|
154
|
+
...execution ? { execution } : {},
|
|
153
155
|
text: held.size ? decision ? "Approval recorded. Ask the assistant to continue." : "That action was not approved." : text
|
|
154
156
|
});
|
|
155
157
|
} catch (error) {
|
|
@@ -168,16 +170,16 @@ async function createChatGPTAssistantAI(options) {
|
|
|
168
170
|
if (error instanceof EngineModelFailure) throw new AssistantTurnUserError(error.message, error.code);
|
|
169
171
|
throw new AssistantTurnUserError("ChatGPT could not connect. Try again in AI settings.", "chatgpt_unavailable");
|
|
170
172
|
};
|
|
171
|
-
let
|
|
173
|
+
let execution;
|
|
172
174
|
const model = await createChatGPTModel({
|
|
173
175
|
...options,
|
|
174
|
-
recordExecution: async (
|
|
175
|
-
|
|
176
|
-
await options.recordExecution?.(
|
|
176
|
+
recordExecution: async (recorded) => {
|
|
177
|
+
execution = recorded;
|
|
178
|
+
await options.recordExecution?.(recorded);
|
|
177
179
|
}
|
|
178
180
|
}).catch(safeFailure);
|
|
179
181
|
return {
|
|
180
|
-
|
|
182
|
+
getEngineExecution: () => execution,
|
|
181
183
|
async chat(messages, request) {
|
|
182
184
|
const reply = await model.complete({
|
|
183
185
|
messages,
|
|
@@ -188,7 +190,7 @@ async function createChatGPTAssistantAI(options) {
|
|
|
188
190
|
}).catch(safeFailure);
|
|
189
191
|
return {
|
|
190
192
|
content: reply.text,
|
|
191
|
-
...
|
|
193
|
+
...execution?.model ? { model: execution.model } : {},
|
|
192
194
|
...reply.raw ? { toolCalls: reply.raw } : {},
|
|
193
195
|
finishReason: reply.toolCalls.length ? "tool_calls" : "stop",
|
|
194
196
|
...reply.totalTokens !== void 0 ? { usage: {
|
|
@@ -203,7 +205,7 @@ async function createChatGPTAssistantAI(options) {
|
|
|
203
205
|
function createInferenceAssistantAdapters(options) {
|
|
204
206
|
const selected = /* @__PURE__ */ new WeakMap();
|
|
205
207
|
const resolve = async (context) => {
|
|
206
|
-
const engine = context.
|
|
208
|
+
const engine = context.selection?.engine ?? await options.binding(context) ?? "api";
|
|
207
209
|
if (![
|
|
208
210
|
"api",
|
|
209
211
|
"chatgpt",
|
|
@@ -221,7 +223,7 @@ function createInferenceAssistantAdapters(options) {
|
|
|
221
223
|
return engine;
|
|
222
224
|
};
|
|
223
225
|
const select = (context) => {
|
|
224
|
-
if (context.
|
|
226
|
+
if (context.selection) return resolve(context);
|
|
225
227
|
let pending = selected.get(context.event.request);
|
|
226
228
|
if (!pending) {
|
|
227
229
|
pending = resolve(context);
|
|
@@ -238,14 +240,10 @@ function createInferenceAssistantAdapters(options) {
|
|
|
238
240
|
const engine = await select(context);
|
|
239
241
|
if (engine === "chatgpt") return createChatGPTAssistantAI({
|
|
240
242
|
...await options.chatgpt(context),
|
|
241
|
-
...context.
|
|
242
|
-
|
|
243
|
-
model: context.
|
|
244
|
-
|
|
245
|
-
model: context.workProfile.model,
|
|
246
|
-
effort: context.workProfile.effort,
|
|
247
|
-
budgets: context.workProfile.budgets
|
|
248
|
-
}
|
|
243
|
+
...context.selection ? {
|
|
244
|
+
tier: context.selection.tier,
|
|
245
|
+
...context.selection.model ? { model: context.selection.model } : {},
|
|
246
|
+
...context.selection.effort ? { effort: context.selection.effort } : {}
|
|
249
247
|
} : {}
|
|
250
248
|
});
|
|
251
249
|
if (engine !== "api") throw new Error("A CLI engine requires its turn driver.");
|
|
@@ -255,6 +253,6 @@ function createInferenceAssistantAdapters(options) {
|
|
|
255
253
|
};
|
|
256
254
|
}
|
|
257
255
|
//#endregion
|
|
258
|
-
export {
|
|
256
|
+
export { ToolRunTypeRefusal, assertToolRunType, createAgentCliTurnDriver, createChatGPTAssistantAI, createInferenceAssistantAdapters };
|
|
259
257
|
|
|
260
258
|
//# sourceMappingURL=engines.js.map
|
package/dist/engines.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engines.js","names":["text"],"sources":["../src/engines.ts"],"sourcesContent":["import type { WorkRunMetadata } from '@happyvertical/smrt-inference';\n\nexport {\n type AssistantWorkProfileOptions,\n assertWorkProfileTool,\n WorkProfileEscalation,\n} from './work-profile.js';\n\n/** Node-only adapters over inference's engines; chat retains transcript ownership. */\nimport type { AIInterface } from '@happyvertical/ai';\nimport { InferenceUnavailableError } from '@happyvertical/smrt-core/inference-availability';\nimport {\n type AgentTool,\n type AgentTurnHost,\n type AgentTurnMessage,\n type AgentTurnOptions,\n type ChatGPTModelOptions,\n ChatGPTSignedOutError,\n createChatGPTModel,\n EngineModelFailure,\n type InferenceEngineId,\n type InferenceEngineStatusHost,\n inferenceEngineStatus,\n reportAgentFailure,\n runAgentTurn,\n} from '@happyvertical/smrt-inference/server';\nimport { AssistantTurnUserError } from './assistant-turn.js';\nimport type {\n AssistantTurnDriver,\n AssistantTurnDriverContext,\n} from './assistant-turn-driver.js';\nimport {\n configuredAssistantAI,\n type MountAssistantRoutesOptions,\n} from './sveltekit.js';\nimport { isManifestToolEnabled } from './tool-loop.js';\nimport {\n type DescribeAssistantTool,\n describeAssistantTool,\n} from './tool-summary.js';\n\n/** All credentials, working directories and MCP authority are bound by the host per turn. */\nexport type AgentCliChatBinding = Pick<\n AgentTurnOptions,\n 'mcpUrl' | 'deps' | 'fallback' | 'outputSchema' | 'protection'\n> &\n Pick<AgentTurnHost, 'allowTool' | 'approvals'> & {\n /** Optional MCP wire-name → canonical offered chat slug mapping. Unknown names deny. */\n canonicalToolName?(name: string): string | undefined;\n /** Existing describe seam, bound to this turn's server-authored vocabulary. */\n describeTool?: DescribeAssistantTool;\n };\n\n/** A CLI loop driver. Starts a fresh CLI session with chat's authenticated history each turn. */\nexport function createAgentCliTurnDriver(options: {\n tool: AgentTool;\n bind(context: AssistantTurnDriverContext): Promise<AgentCliChatBinding>;\n}): AssistantTurnDriver {\n const bindings = new WeakMap<\n AssistantTurnDriverContext,\n AgentCliChatBinding\n >();\n return {\n async waitForApproval(request, context) {\n const binding = bindings.get(context);\n if (!binding || context.signal.aborted) return { approved: false };\n // Subscribe before the first read so a decision between them cannot be lost.\n return new Promise((resolve) => {\n let unsubscribe = () => {};\n let ended = false;\n const finish = (approved: boolean, reason?: string) => {\n if (ended) return;\n ended = true;\n unsubscribe();\n context.signal.removeEventListener('abort', abort);\n resolve({ approved, reason });\n };\n const abort = () => finish(false, 'cancelled');\n const check = async () => {\n try {\n const found = await binding.approvals.get(request.id);\n if (!found || found.status !== 'pending')\n finish(\n found?.status === 'approved' &&\n context.tools.every(\n (tool) =>\n tool.slug !== request.tool ||\n isManifestToolEnabled(tool, context.principal.tenantId),\n ),\n found?.status ?? 'missing',\n );\n } catch {\n finish(false, 'unavailable');\n }\n };\n try {\n unsubscribe = binding.approvals.subscribe((event) => {\n if (event.id === request.id) void check();\n });\n if (ended) unsubscribe();\n context.signal.addEventListener('abort', abort, { once: true });\n if (context.signal.aborted) abort();\n else void check();\n } catch {\n finish(false, 'unavailable');\n }\n });\n },\n async run(context, callbacks) {\n const binding = await options.bind(context).catch((error) => {\n const reference = reportAgentFailure(options.tool, 'binding', error);\n throw new AssistantTurnUserError(\n `The local AI could not start. Try again. Reference: ${reference}`,\n 'agent_cli_unavailable',\n );\n });\n const failed = new AbortController();\n const signal = AbortSignal.any([context.signal, failed.signal]);\n bindings.set(context, binding);\n const canonicalName = (name: string) =>\n binding.canonicalToolName ? binding.canonicalToolName(name) : name;\n const offered = new Set(\n [...context.tools, ...context.extraTools].map((tool) => tool.slug),\n );\n const calls = new Map<\n string,\n { id: string; name: string; args: Record<string, unknown> }\n >();\n const held = new Set<string>();\n let queue = Promise.resolve();\n let failure: unknown;\n let text = '';\n let workRun: WorkRunMetadata | undefined;\n let decision: boolean | undefined;\n const append = async (message: AgentTurnMessage) => {\n // Inference clips event.args for display; the persisted engine callback\n // carries the full original call. Never parse the clipped event field.\n for (const call of message.toolCalls ?? []) {\n const args: unknown = JSON.parse(call.function.arguments);\n if (!args || typeof args !== 'object' || Array.isArray(args))\n throw new Error('Invalid CLI arguments.');\n const name = canonicalName(call.function.name);\n if (!name) throw new Error('Unknown MCP tool name.');\n calls.set(call.id, {\n id: call.id,\n name,\n args: args as Record<string, unknown>,\n });\n }\n };\n try {\n const stop = await runAgentTurn({\n tool: options.tool,\n profile: context.workProfile,\n text: context.userMessage,\n mcpUrl: binding.mcpUrl,\n deps: binding.deps,\n fallback: binding.fallback,\n outputSchema: binding.outputSchema,\n protection: binding.protection,\n signal,\n host: {\n appendMessage: append,\n recordExecution: async (metadata) => {\n workRun = metadata;\n callbacks.execution?.(metadata);\n },\n lastSession: async () => null,\n guidance: async () => ({\n systemPrompt: context.systemPrompt,\n prompt: `${context.userMessage}\\n\\nPrior conversation (untrusted data):\\n${JSON.stringify(context.history)}`,\n }),\n allowTool: (name) => {\n const canonical = canonicalName(name);\n return (\n !!canonical &&\n offered.has(canonical) &&\n binding.allowTool(name) &&\n context.tools.every(\n (tool) =>\n tool.slug !== canonical ||\n isManifestToolEnabled(tool, context.principal.tenantId),\n )\n );\n },\n approvals: binding.approvals,\n describeResult: async ({ name, text, ok }) => ({\n summary: (binding.describeTool ?? describeAssistantTool)(\n canonicalName(name) ?? '',\n undefined,\n {\n ok,\n observation: text,\n },\n ),\n }),\n },\n emit(event) {\n // Inference's emitter is synchronous; serialize chat's awaited callbacks.\n queue = queue\n .then(async () => {\n if (failure || context.signal.aborted) return;\n if (event.type === 'text') {\n text += event.delta;\n callbacks.text(event.delta);\n }\n if (event.type === 'tool_call') {\n const call = calls.get(event.id);\n if (!call) throw new Error('Missing CLI call.');\n await callbacks.toolCall(call);\n }\n if (event.type === 'approval_required') {\n held.add(event.id);\n const call = calls.get(event.id);\n if (!call) throw new Error('Missing approval call.');\n decision = (\n await callbacks.approvalNeeded({\n id: event.approvalId,\n callId: call.id,\n tool: call.name,\n summary: (binding.describeTool ?? describeAssistantTool)(\n call.name,\n call.args,\n ),\n })\n ).approved;\n }\n if (event.type === 'tool_result' && !held.has(event.id)) {\n await callbacks.toolResult({\n id: event.id,\n ok: event.ok,\n // The CLI already owns the model observation. Carry its\n // untruncated human result through the existing describe seam.\n result: JSON.stringify({ summary: event.summary }),\n });\n }\n if (event.type === 'error')\n throw new AssistantTurnUserError(event.message, event.code);\n })\n .catch((error: unknown) => {\n failure ??= error;\n failed.abort();\n });\n },\n });\n await queue;\n if (failure) throw failure;\n if (context.signal.aborted || stop === 'aborted') return;\n if (stop === 'error' || stop === 'timeout')\n throw new Error('CLI turn failed.');\n // A pending MCP response is NOT a successful effect. No auto-resume or\n // approval decision is performed here; only the host can execute a hold.\n callbacks.done({\n workRun,\n text: held.size\n ? decision\n ? 'Approval recorded. Ask the assistant to continue.'\n : 'That action was not approved.'\n : text,\n });\n } catch (error) {\n if (error instanceof AssistantTurnUserError) throw error;\n const reference = reportAgentFailure(options.tool, 'driver', error);\n throw new AssistantTurnUserError(\n `The local AI turn could not finish. Try again. Reference: ${reference}`,\n 'agent_cli_failed',\n );\n } finally {\n bindings.delete(context);\n }\n },\n };\n}\n\n/** An SDK chat client over inference's plan-only model; no API-key fallback. */\nexport async function createChatGPTAssistantAI(\n options: ChatGPTModelOptions,\n): Promise<\n Pick<AIInterface, 'chat'> & {\n getWorkRunMetadata(): WorkRunMetadata | undefined;\n }\n> {\n const safeFailure = (error: unknown): never => {\n reportAgentFailure('chatgpt', 'driver', error);\n if (error instanceof ChatGPTSignedOutError)\n throw new InferenceUnavailableError({ reason: 'unconfigured' });\n if (error instanceof EngineModelFailure)\n throw new AssistantTurnUserError(error.message, error.code);\n throw new AssistantTurnUserError(\n 'ChatGPT could not connect. Try again in AI settings.',\n 'chatgpt_unavailable',\n );\n };\n let workRun: WorkRunMetadata | undefined;\n const model = await createChatGPTModel({\n ...options,\n recordExecution: async (metadata) => {\n workRun = metadata;\n await options.recordExecution?.(metadata);\n },\n }).catch(safeFailure);\n return {\n getWorkRunMetadata: () => workRun,\n async chat(messages, request) {\n const reply = await model\n .complete({\n messages,\n tools: request?.toolChoice === 'none' ? [] : (request?.tools ?? []),\n maxTokens: request?.maxTokens ?? 0,\n signal: request?.signal ?? new AbortController().signal,\n onText: (delta) => request?.onProgress?.(delta),\n })\n .catch(safeFailure);\n return {\n content: reply.text,\n ...(workRun?.model ? { model: workRun.model } : {}),\n ...(reply.raw ? { toolCalls: reply.raw } : {}),\n finishReason: reply.toolCalls.length ? 'tool_calls' : 'stop',\n ...(reply.totalTokens !== undefined\n ? {\n usage: {\n promptTokens: 0,\n completionTokens: 0,\n totalTokens: reply.totalTokens,\n },\n }\n : {}),\n };\n },\n };\n}\n\n/** Per-authenticated-request engine selection, suitable for spreading into mountAssistantRoutes. */\nexport function createInferenceAssistantAdapters(options: {\n /** Read the authenticated user's stored preference; never requestContext. No binding means API. */\n binding(\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): Promise<InferenceEngineId | undefined>;\n status(\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): Promise<InferenceEngineStatusHost>;\n cli(\n tool: AgentTool,\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): AssistantTurnDriver;\n chatgpt(\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): Promise<ChatGPTModelOptions>;\n api?: Exclude<MountAssistantRoutesOptions['ai'], undefined>;\n}): Pick<MountAssistantRoutesOptions, 'resolveTurnDriver' | 'ai'> {\n type Context = Parameters<typeof options.binding>[0];\n const selected = new WeakMap<Request, Promise<InferenceEngineId>>();\n const resolve = async (context: Context) => {\n const engine =\n context.workProfile?.engine ?? (await options.binding(context)) ?? 'api';\n if (!['api', 'chatgpt', 'claude-code', 'codex'].includes(engine))\n throw new InferenceUnavailableError({ reason: 'unconfigured' });\n const status = await inferenceEngineStatus(\n engine,\n await options.status(context),\n );\n if (!status.configured) {\n if (engine === 'claude-code' || engine === 'codex') {\n const reference = reportAgentFailure(\n engine,\n 'preflight',\n undefined,\n status.startError ?? status.code,\n );\n if (status.code === 'agent_cli_startup')\n throw new AssistantTurnUserError(\n `${status.message} Reference: ${reference}`,\n 'agent_cli_startup',\n );\n }\n throw new InferenceUnavailableError({ reason: 'unconfigured' });\n }\n return engine;\n };\n const select = (context: Context) => {\n if (context.workProfile) return resolve(context);\n let pending = selected.get(context.event.request);\n if (!pending) {\n pending = resolve(context);\n selected.set(context.event.request, pending);\n }\n return pending;\n };\n return {\n async resolveTurnDriver(context) {\n const engine = await select(context);\n return engine === 'claude-code' || engine === 'codex'\n ? options.cli(engine, context)\n : undefined;\n },\n async ai(context) {\n const engine = await select(context);\n if (engine === 'chatgpt')\n return createChatGPTAssistantAI({\n ...(await options.chatgpt(context)),\n ...(context.workProfile\n ? {\n profile: context.workProfile.name,\n model: context.workProfile.model,\n settings: {\n model: context.workProfile.model,\n effort: context.workProfile.effort,\n budgets: context.workProfile.budgets,\n },\n }\n : {}),\n });\n if (engine !== 'api')\n throw new Error('A CLI engine requires its turn driver.');\n const api = options.api ?? configuredAssistantAI;\n return typeof api === 'function' ? api(context) : api;\n },\n };\n}\n"],"mappings":";;;;;;AAsDO,SAAS,yBAAyB,SAGjB;CACtB,MAAM,2BAAW,IAAI,QAGnB;CACF,OAAO;EACL,MAAM,gBAAgB,SAAS,SAAS;GACtC,MAAM,UAAU,SAAS,IAAI,OAAO;GACpC,IAAI,CAAC,WAAW,QAAQ,OAAO,SAAS,OAAO,EAAE,UAAU,MAAM;GAEjE,OAAO,IAAI,SAAS,YAAY;IAC9B,IAAI,oBAAoB,CAAC;IACzB,IAAI,QAAQ;IACZ,MAAM,UAAU,UAAmB,WAAoB;KACrD,IAAI,OAAO;KACX,QAAQ;KACR,YAAY;KACZ,QAAQ,OAAO,oBAAoB,SAAS,KAAK;KACjD,QAAQ;MAAE;MAAU;KAAO,CAAC;IAC9B;IACA,MAAM,cAAc,OAAO,OAAO,WAAW;IAC7C,MAAM,QAAQ,YAAY;KACxB,IAAI;MACF,MAAM,QAAQ,MAAM,QAAQ,UAAU,IAAI,QAAQ,EAAE;MACpD,IAAI,CAAC,SAAS,MAAM,WAAW,WAC7B,OACE,OAAO,WAAW,cAChB,QAAQ,MAAM,OACX,SACC,KAAK,SAAS,QAAQ,QACtB,sBAAsB,MAAM,QAAQ,UAAU,QAAQ,CAC1D,GACF,OAAO,UAAU,SACnB;KACJ,QAAQ;MACN,OAAO,OAAO,aAAa;KAC7B;IACF;IACA,IAAI;KACF,cAAc,QAAQ,UAAU,WAAW,UAAU;MACnD,IAAI,MAAM,OAAO,QAAQ,IAAI,MAAW;KAC1C,CAAC;KACD,IAAI,OAAO,YAAY;KACvB,QAAQ,OAAO,iBAAiB,SAAS,OAAO,EAAE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YAAY,mBAChB,QACA,aACA,KAAA,GACA,OAAO,cAAc,OAAO,IAC9B;IACA,IAAI,OAAO,SAAS,qBAClB,MAAM,IAAI,uBACR,GAAG,OAAO,QAAO,cAAe,aAChC,mBACF;GACJ;GACA,MAAM,IAAI,0BAA0B,EAAE,QAAQ,eAAe,CAAC;EAChE;EACA,OAAO;CACT;CACA,MAAM,UAAU,YAAqB;EACnC,IAAI,QAAQ,aAAa,OAAO,QAAQ,OAAO;EAC/C,IAAI,UAAU,SAAS,IAAI,QAAQ,MAAM,OAAO;EAChD,IAAI,CAAC,SAAS;GACZ,UAAU,QAAQ,OAAO;GACzB,SAAS,IAAI,QAAQ,MAAM,SAAS,OAAO;EAC7C;EACA,OAAO;CACT;CACA,OAAO;EACL,MAAM,kBAAkB,SAAS;GAC/B,MAAM,SAAS,MAAM,OAAO,OAAO;GACnC,OAAO,WAAW,iBAAiB,WAAW,UAC1C,QAAQ,IAAI,QAAQ,OAAO,IAC3B,KAAA;EACN;EACA,MAAM,GAAG,SAAS;GAChB,MAAM,SAAS,MAAM,OAAO,OAAO;GACnC,IAAI,WAAW,WACb,OAAO,yBAAyB;IAC9B,GAAI,MAAM,QAAQ,QAAQ,OAAO;IACjC,GAAI,QAAQ,cACR;KACE,SAAS,QAAQ,YAAY;KAC7B,OAAO,QAAQ,YAAY;KAC3B,UAAU;MACR,OAAO,QAAQ,YAAY;MAC3B,QAAQ,QAAQ,YAAY;MAC5B,SAAS,QAAQ,YAAY;KAC/B;IACF,IACA,CAAC;GACP,CAAC;GACH,IAAI,WAAW,OACb,MAAM,IAAI,MAAM,wCAAwC;GAC1D,MAAM,MAAM,QAAQ,OAAO;GAC3B,OAAO,OAAO,QAAQ,aAAa,IAAI,OAAO,IAAI;EACpD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"engines.js","names":["text"],"sources":["../src/engines.ts"],"sourcesContent":["import type { EngineExecution } from '@happyvertical/smrt-inference';\n\nexport {\n type AssistantModelSelection,\n type AssistantRunTypeOptions,\n assertToolRunType,\n ToolRunTypeRefusal,\n} from './tool-run-types.js';\n\n/** Node-only adapters over inference's engines; chat retains transcript ownership. */\nimport type { AIInterface } from '@happyvertical/ai';\nimport { InferenceUnavailableError } from '@happyvertical/smrt-core/inference-availability';\nimport {\n type AgentTool,\n type AgentTurnHost,\n type AgentTurnMessage,\n type AgentTurnOptions,\n type ChatGPTModelOptions,\n ChatGPTSignedOutError,\n createChatGPTModel,\n EngineModelFailure,\n type InferenceEngineId,\n type InferenceEngineStatusHost,\n inferenceEngineStatus,\n reportAgentFailure,\n runAgentTurn,\n} from '@happyvertical/smrt-inference/server';\nimport { AssistantTurnUserError } from './assistant-turn.js';\nimport type {\n AssistantTurnDriver,\n AssistantTurnDriverContext,\n} from './assistant-turn-driver.js';\nimport {\n configuredAssistantAI,\n type MountAssistantRoutesOptions,\n} from './sveltekit.js';\nimport { isManifestToolEnabled } from './tool-loop.js';\nimport {\n type DescribeAssistantTool,\n describeAssistantTool,\n} from './tool-summary.js';\n\n/** All credentials, working directories and MCP authority are bound by the host per turn. */\nexport type AgentCliChatBinding = Pick<\n AgentTurnOptions,\n 'mcpUrl' | 'deps' | 'fallback' | 'outputSchema' | 'protection' | 'limits'\n> &\n Pick<AgentTurnHost, 'allowTool' | 'approvals'> & {\n /** Optional MCP wire-name → canonical offered chat slug mapping. Unknown names deny. */\n canonicalToolName?(name: string): string | undefined;\n /** Existing describe seam, bound to this turn's server-authored vocabulary. */\n describeTool?: DescribeAssistantTool;\n };\n\n/** A CLI loop driver. Starts a fresh CLI session with chat's authenticated history each turn. */\nexport function createAgentCliTurnDriver(options: {\n tool: AgentTool;\n bind(context: AssistantTurnDriverContext): Promise<AgentCliChatBinding>;\n}): AssistantTurnDriver {\n const bindings = new WeakMap<\n AssistantTurnDriverContext,\n AgentCliChatBinding\n >();\n return {\n async waitForApproval(request, context) {\n const binding = bindings.get(context);\n if (!binding || context.signal.aborted) return { approved: false };\n // Subscribe before the first read so a decision between them cannot be lost.\n return new Promise((resolve) => {\n let unsubscribe = () => {};\n let ended = false;\n const finish = (approved: boolean, reason?: string) => {\n if (ended) return;\n ended = true;\n unsubscribe();\n context.signal.removeEventListener('abort', abort);\n resolve({ approved, reason });\n };\n const abort = () => finish(false, 'cancelled');\n const check = async () => {\n try {\n const found = await binding.approvals.get(request.id);\n if (!found || found.status !== 'pending')\n finish(\n found?.status === 'approved' &&\n context.tools.every(\n (tool) =>\n tool.slug !== request.tool ||\n isManifestToolEnabled(tool, context.principal.tenantId),\n ),\n found?.status ?? 'missing',\n );\n } catch {\n finish(false, 'unavailable');\n }\n };\n try {\n unsubscribe = binding.approvals.subscribe((event) => {\n if (event.id === request.id) void check();\n });\n if (ended) unsubscribe();\n context.signal.addEventListener('abort', abort, { once: true });\n if (context.signal.aborted) abort();\n else void check();\n } catch {\n finish(false, 'unavailable');\n }\n });\n },\n async run(context, callbacks) {\n const binding = await options.bind(context).catch((error) => {\n const reference = reportAgentFailure(options.tool, 'binding', error);\n throw new AssistantTurnUserError(\n `The local AI could not start. Try again. Reference: ${reference}`,\n 'agent_cli_unavailable',\n );\n });\n const failed = new AbortController();\n const signal = AbortSignal.any([context.signal, failed.signal]);\n bindings.set(context, binding);\n const canonicalName = (name: string) =>\n binding.canonicalToolName ? binding.canonicalToolName(name) : name;\n const offered = new Set(\n [...context.tools, ...context.extraTools].map((tool) => tool.slug),\n );\n const calls = new Map<\n string,\n { id: string; name: string; args: Record<string, unknown> }\n >();\n const held = new Set<string>();\n let queue = Promise.resolve();\n let failure: unknown;\n let text = '';\n let execution: EngineExecution | undefined;\n let decision: boolean | undefined;\n const append = async (message: AgentTurnMessage) => {\n // Inference clips event.args for display; the persisted engine callback\n // carries the full original call. Never parse the clipped event field.\n for (const call of message.toolCalls ?? []) {\n const args: unknown = JSON.parse(call.function.arguments);\n if (!args || typeof args !== 'object' || Array.isArray(args))\n throw new Error('Invalid CLI arguments.');\n const name = canonicalName(call.function.name);\n if (!name) throw new Error('Unknown MCP tool name.');\n calls.set(call.id, {\n id: call.id,\n name,\n args: args as Record<string, unknown>,\n });\n }\n };\n try {\n const stop = await runAgentTurn({\n tool: options.tool,\n ...(context.selection?.model\n ? { model: context.selection.model }\n : {}),\n ...(context.selection?.effort\n ? { effort: context.selection.effort }\n : {}),\n ...(binding.limits ? { limits: binding.limits } : {}),\n text: context.userMessage,\n mcpUrl: binding.mcpUrl,\n deps: binding.deps,\n fallback: binding.fallback,\n outputSchema: binding.outputSchema,\n protection: binding.protection,\n signal,\n host: {\n appendMessage: append,\n recordExecution: async (recorded) => {\n execution = recorded;\n callbacks.execution?.(recorded);\n },\n lastSession: async () => null,\n guidance: async () => ({\n systemPrompt: context.systemPrompt,\n prompt: `${context.userMessage}\\n\\nPrior conversation (untrusted data):\\n${JSON.stringify(context.history)}`,\n }),\n allowTool: (name) => {\n const canonical = canonicalName(name);\n return (\n !!canonical &&\n offered.has(canonical) &&\n binding.allowTool(name) &&\n context.tools.every(\n (tool) =>\n tool.slug !== canonical ||\n isManifestToolEnabled(tool, context.principal.tenantId),\n )\n );\n },\n approvals: binding.approvals,\n describeResult: async ({ name, text, ok }) => ({\n summary: (binding.describeTool ?? describeAssistantTool)(\n canonicalName(name) ?? '',\n undefined,\n {\n ok,\n observation: text,\n },\n ),\n }),\n },\n emit(event) {\n // Inference's emitter is synchronous; serialize chat's awaited callbacks.\n queue = queue\n .then(async () => {\n if (failure || context.signal.aborted) return;\n if (event.type === 'text') {\n text += event.delta;\n callbacks.text(event.delta);\n }\n if (event.type === 'tool_call') {\n const call = calls.get(event.id);\n if (!call) throw new Error('Missing CLI call.');\n await callbacks.toolCall(call);\n }\n if (event.type === 'approval_required') {\n held.add(event.id);\n const call = calls.get(event.id);\n if (!call) throw new Error('Missing approval call.');\n decision = (\n await callbacks.approvalNeeded({\n id: event.approvalId,\n callId: call.id,\n tool: call.name,\n summary: (binding.describeTool ?? describeAssistantTool)(\n call.name,\n call.args,\n ),\n })\n ).approved;\n }\n if (event.type === 'tool_result' && !held.has(event.id)) {\n await callbacks.toolResult({\n id: event.id,\n ok: event.ok,\n // The CLI already owns the model observation. Carry its\n // untruncated human result through the existing describe seam.\n result: JSON.stringify({ summary: event.summary }),\n });\n }\n if (event.type === 'error')\n throw new AssistantTurnUserError(event.message, event.code);\n })\n .catch((error: unknown) => {\n failure ??= error;\n failed.abort();\n });\n },\n });\n await queue;\n if (failure) throw failure;\n if (context.signal.aborted || stop === 'aborted') return;\n if (stop === 'error' || stop === 'timeout')\n throw new Error('CLI turn failed.');\n // A pending MCP response is NOT a successful effect. No auto-resume or\n // approval decision is performed here; only the host can execute a hold.\n callbacks.done({\n ...(execution ? { execution } : {}),\n text: held.size\n ? decision\n ? 'Approval recorded. Ask the assistant to continue.'\n : 'That action was not approved.'\n : text,\n });\n } catch (error) {\n if (error instanceof AssistantTurnUserError) throw error;\n const reference = reportAgentFailure(options.tool, 'driver', error);\n throw new AssistantTurnUserError(\n `The local AI turn could not finish. Try again. Reference: ${reference}`,\n 'agent_cli_failed',\n );\n } finally {\n bindings.delete(context);\n }\n },\n };\n}\n\n/** An SDK chat client over inference's plan-only model; no API-key fallback. */\nexport async function createChatGPTAssistantAI(\n options: ChatGPTModelOptions,\n): Promise<\n Pick<AIInterface, 'chat'> & {\n getEngineExecution(): EngineExecution | undefined;\n }\n> {\n const safeFailure = (error: unknown): never => {\n reportAgentFailure('chatgpt', 'driver', error);\n if (error instanceof ChatGPTSignedOutError)\n throw new InferenceUnavailableError({ reason: 'unconfigured' });\n if (error instanceof EngineModelFailure)\n throw new AssistantTurnUserError(error.message, error.code);\n throw new AssistantTurnUserError(\n 'ChatGPT could not connect. Try again in AI settings.',\n 'chatgpt_unavailable',\n );\n };\n let execution: EngineExecution | undefined;\n const model = await createChatGPTModel({\n ...options,\n recordExecution: async (recorded) => {\n execution = recorded;\n await options.recordExecution?.(recorded);\n },\n }).catch(safeFailure);\n return {\n getEngineExecution: () => execution,\n async chat(messages, request) {\n const reply = await model\n .complete({\n messages,\n tools: request?.toolChoice === 'none' ? [] : (request?.tools ?? []),\n maxTokens: request?.maxTokens ?? 0,\n signal: request?.signal ?? new AbortController().signal,\n onText: (delta) => request?.onProgress?.(delta),\n })\n .catch(safeFailure);\n return {\n content: reply.text,\n ...(execution?.model ? { model: execution.model } : {}),\n ...(reply.raw ? { toolCalls: reply.raw } : {}),\n finishReason: reply.toolCalls.length ? 'tool_calls' : 'stop',\n ...(reply.totalTokens !== undefined\n ? {\n usage: {\n promptTokens: 0,\n completionTokens: 0,\n totalTokens: reply.totalTokens,\n },\n }\n : {}),\n };\n },\n };\n}\n\n/** Per-authenticated-request engine selection, suitable for spreading into mountAssistantRoutes. */\nexport function createInferenceAssistantAdapters(options: {\n /** Read the authenticated user's stored preference; never requestContext. No binding means API. */\n binding(\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): Promise<InferenceEngineId | undefined>;\n status(\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): Promise<InferenceEngineStatusHost>;\n cli(\n tool: AgentTool,\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): AssistantTurnDriver;\n chatgpt(\n context: Parameters<\n NonNullable<MountAssistantRoutesOptions['resolveTurnDriver']>\n >[0],\n ): Promise<ChatGPTModelOptions>;\n api?: Exclude<MountAssistantRoutesOptions['ai'], undefined>;\n}): Pick<MountAssistantRoutesOptions, 'resolveTurnDriver' | 'ai'> {\n type Context = Parameters<typeof options.binding>[0];\n const selected = new WeakMap<Request, Promise<InferenceEngineId>>();\n const resolve = async (context: Context) => {\n const engine =\n context.selection?.engine ?? (await options.binding(context)) ?? 'api';\n if (!['api', 'chatgpt', 'claude-code', 'codex'].includes(engine))\n throw new InferenceUnavailableError({ reason: 'unconfigured' });\n const status = await inferenceEngineStatus(\n engine,\n await options.status(context),\n );\n if (!status.configured) {\n if (engine === 'claude-code' || engine === 'codex') {\n const reference = reportAgentFailure(\n engine,\n 'preflight',\n undefined,\n status.startError ?? status.code,\n );\n if (status.code === 'agent_cli_startup')\n throw new AssistantTurnUserError(\n `${status.message} Reference: ${reference}`,\n 'agent_cli_startup',\n );\n }\n throw new InferenceUnavailableError({ reason: 'unconfigured' });\n }\n return engine;\n };\n const select = (context: Context) => {\n if (context.selection) return resolve(context);\n let pending = selected.get(context.event.request);\n if (!pending) {\n pending = resolve(context);\n selected.set(context.event.request, pending);\n }\n return pending;\n };\n return {\n async resolveTurnDriver(context) {\n const engine = await select(context);\n return engine === 'claude-code' || engine === 'codex'\n ? options.cli(engine, context)\n : undefined;\n },\n async ai(context) {\n const engine = await select(context);\n if (engine === 'chatgpt')\n return createChatGPTAssistantAI({\n ...(await options.chatgpt(context)),\n ...(context.selection\n ? {\n tier: context.selection.tier,\n ...(context.selection.model\n ? { model: context.selection.model }\n : {}),\n ...(context.selection.effort\n ? { effort: context.selection.effort }\n : {}),\n }\n : {}),\n });\n if (engine !== 'api')\n throw new Error('A CLI engine requires its turn driver.');\n const api = options.api ?? configuredAssistantAI;\n return typeof api === 'function' ? api(context) : api;\n },\n };\n}\n"],"mappings":";;;;;;AAuDO,SAAS,yBAAyB,SAGjB;CACtB,MAAM,2BAAW,IAAI,QAGnB;CACF,OAAO;EACL,MAAM,gBAAgB,SAAS,SAAS;GACtC,MAAM,UAAU,SAAS,IAAI,OAAO;GACpC,IAAI,CAAC,WAAW,QAAQ,OAAO,SAAS,OAAO,EAAE,UAAU,MAAM;GAEjE,OAAO,IAAI,SAAS,YAAY;IAC9B,IAAI,oBAAoB,CAAC;IACzB,IAAI,QAAQ;IACZ,MAAM,UAAU,UAAmB,WAAoB;KACrD,IAAI,OAAO;KACX,QAAQ;KACR,YAAY;KACZ,QAAQ,OAAO,oBAAoB,SAAS,KAAK;KACjD,QAAQ;MAAE;MAAU;KAAO,CAAC;IAC9B;IACA,MAAM,cAAc,OAAO,OAAO,WAAW;IAC7C,MAAM,QAAQ,YAAY;KACxB,IAAI;M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iBAAiB,WAAW,UAC1C,QAAQ,IAAI,QAAQ,OAAO,IAC3B,KAAA;EACN;EACA,MAAM,GAAG,SAAS;GAChB,MAAM,SAAS,MAAM,OAAO,OAAO;GACnC,IAAI,WAAW,WACb,OAAO,yBAAyB;IAC9B,GAAI,MAAM,QAAQ,QAAQ,OAAO;IACjC,GAAI,QAAQ,YACR;KACE,MAAM,QAAQ,UAAU;KACxB,GAAI,QAAQ,UAAU,QAClB,EAAE,OAAO,QAAQ,UAAU,MAAM,IACjC,CAAC;KACL,GAAI,QAAQ,UAAU,SAClB,EAAE,QAAQ,QAAQ,UAAU,OAAO,IACnC,CAAC;IACP,IACA,CAAC;GACP,CAAC;GACH,IAAI,WAAW,OACb,MAAM,IAAI,MAAM,wCAAwC;GAC1D,MAAM,MAAM,QAAQ,OAAO;GAC3B,OAAO,OAAO,QAAQ,aAAa,IAAI,OAAO,IAAI;EACpD;CACF;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type
|
|
1
|
+
export { type AssistantModelSelection, type AssistantRunTypeOptions, assertToolRunType, ToolRunTypeRefusal, toolRunTypes, } from './tool-run-types.js';
|
|
2
2
|
/**
|
|
3
3
|
* @happyvertical/smrt-chat
|
|
4
4
|
*
|
|
@@ -61,6 +61,7 @@ export { createRuntimeReportTools, RUNTIME_REPORT_DEFINE_FUNCTION_NAME, RUNTIME_
|
|
|
61
61
|
export { ChatClientRequestConflictError, type ChatClientRequestOutcome, type ChatMessageAttachment, ChatService, clientRequestMessageId, } from './services/index.js';
|
|
62
62
|
export { appendClientToolResults, buildManifestToolCatalog, CLIENT_TOOL_RESULT_GUIDANCE, type ClientToolDefinition, type ClientToolEffect, type ClientToolResultInput, classifyToolError, DEFAULT_EMPTY_ANSWER_FALLBACK, DEFAULT_MAX_REPEATED_CALLS, DEFAULT_MAX_STEPS, FALLBACK_HISTORY_PLACEHOLDER, FALLBACK_REPLY_METADATA_KEY, type FallbackReplyReason, invokeManifestTool, isFallbackReply, MAX_CLIENT_TOOL_RESULT_CHARS, MAX_CLIENT_TOOL_SCHEMA_BYTES, MAX_CLIENT_TOOLS, MAX_DEDUPED_CALLS_PER_TURN, MAX_REPEATED_CALLS_LIMIT, MAX_SERVER_TOOL_OBSERVATION_CHARS, MAX_TOOL_FAILURE_ARGS_CHARS, MAX_TOOL_LOOP_REASONING_CHARS, type ManifestTool, manifestToolToAITool, matchesToolAllowList, type PendingClientToolCall, replyContentFor, replyMetadataFor, resolveTurnReply, runToolLoop, SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER, sanitizeClientToolDeclarations, TOOL_CALL_DEDUPED_NOTE, TOOL_CALL_DEDUPED_REJECTED_NOTE, TOOL_EXECUTION_ERROR_HINT, TOOL_LOOP_ANSWER_NOW_INSTRUCTION, TOOL_LOOP_REPEATED_CALLS_INSTRUCTION, type ToolErrorKind, type ToolExecutionContext, type ToolFailureRecord, type ToolInvocation, type ToolLoopCapReason, type ToolLoopOptions, type ToolLoopResult, type ToolLoopStepEvent, type ToolLoopStopReason, type ToolLoopUsage, type TurnReply, toolFailureAuditMetadata, toolFailureRecord, } from './tool-loop.js';
|
|
63
63
|
export { type AssistantToolOutcome, type DescribeAssistantTool, describeAssistantTool, toolSummary, } from './tool-summary.js';
|
|
64
|
+
export { AssistantTurnRun, type AssistantTurnTracking, CHAT_ASSISTANT_PROMPT_KEY, CHAT_TURN_DEFINITION_KEY, chatAssistantSystemPrompt, resolveChatAssistantPrompt, resolveChatAssistantTier, } from './turn-tracking.js';
|
|
64
65
|
export type { AgentSessionOptions, AgentSessionStatus, ChatMessageOptions, ChatMessageRole, ChatMessageSearchFilters, ChatMessageType, ChatParticipantOptions, ChatParticipantRole, ChatParticipantStatus, ChatReactionOptions, ChatRoomOptions, ChatRoomStatus, ChatRoomType, ChatThreadOptions, OnlineStatus, VoiceGatewayTurnOptions, VoiceGatewayTurnStatus, VoiceSessionOptions, VoiceSessionStatus, } from './types.js';
|
|
65
66
|
export { CHAT_MODULE_META, CHAT_UI_SLOTS } from './ui.js';
|
|
66
67
|
export { assertVoiceGatewayBearer, type CreateVoiceChatSessionOptions, createVoiceChatSession, createVoiceGatewayTurnHandler, type HandleVoiceGatewayTurnOptions, handleVoiceGatewayTurn, MAX_VOICE_GATEWAY_TEXT_LENGTH, SMRT_CHAT_VOICE_TARGET, type VoiceChatSessionCreationResult, VoiceGatewayBadRequestError, VoiceGatewayError, VoiceGatewayReplayError, type VoiceGatewayTurnHandlerOptions, type VoiceGatewayTurnMetadata, type VoiceGatewayTurnPayload, type VoiceGatewayTurnResponse, type VoiceGatewayTurnResponseMetadata, VoiceGatewayUnauthorizedError, VoiceSessionExpiredError, VoiceSessionRejectedError, } from './voice.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAKH,OAAO,wBAAwB,CAAC;AAahC,OAAO,EACL,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,4BAA4B,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,yBAAyB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,5 +1,5 @@
|
|
|
1
|
-
import { c as ChatThread, d as ChatParticipant, f as ChatMessage, i as clientRequestMessageId, l as ChatRoom, n as ChatService, o as VoiceSessionCollection, p as AgentSession, s as VoiceSession, t as ChatClientRequestConflictError, u as ChatReaction } from "./chunks/ChatService-
|
|
2
|
-
import { $ as
|
|
1
|
+
import { c as ChatThread, d as ChatParticipant, f as ChatMessage, i as clientRequestMessageId, l as ChatRoom, n as ChatService, o as VoiceSessionCollection, p as AgentSession, s as VoiceSession, t as ChatClientRequestConflictError, u as ChatReaction } from "./chunks/ChatService-CDLAEJms.js";
|
|
2
|
+
import { $ as TOOL_CALL_DEDUPED_REJECTED_NOTE, A as CHAT_ASSISTANT_PROMPT_KEY, At as assertToolRunType, B as DEFAULT_MAX_STEPS, C as DEFAULT_CONTINUATION_TTL_MS, Ct as RUNTIME_REPORT_SOURCES_FUNCTION_NAME, D as createSessionContinuationStore, Dt as chatUnavailableBody, E as createMemoryContinuationStore, Et as CHAT_AI_UNAVAILABLE_CODE, F as resolveChatAssistantPrompt, G as MAX_CLIENT_TOOL_SCHEMA_BYTES, H as FALLBACK_REPLY_METADATA_KEY, I as resolveChatAssistantTier, J as MAX_SERVER_TOOL_OBSERVATION_CHARS, K as MAX_DEDUPED_CALLS_PER_TURN, L as CLIENT_TOOL_RESULT_GUIDANCE, M as chatAssistantSystemPrompt, O as runAssistantTurn, Ot as chatUnconfiguredBody, Q as TOOL_CALL_DEDUPED_NOTE, R as DEFAULT_EMPTY_ANSWER_FALLBACK, S as DEFAULT_ASSISTANT_TURN_HEARTBEAT_MS, St as RUNTIME_REPORT_RUN_TOOL_SLUG, T as createAssistantTurnResponse, Tt as createRuntimeReportTools, U as MAX_CLIENT_TOOLS, V as FALLBACK_HISTORY_PLACEHOLDER, W as MAX_CLIENT_TOOL_RESULT_CHARS, X as MAX_TOOL_LOOP_REASONING_CHARS, Y as MAX_TOOL_FAILURE_ARGS_CHARS, Z as SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER, _ as resolveConversationInstructions, _t as RUNTIME_REPORT_DEFINE_FUNCTION_NAME, a as DEFAULT_CHAT_STREAM_HEARTBEAT_MS, at as classifyToolError, b as AssistantTurnUserError, bt as RUNTIME_REPORT_LIST_TOOL_SLUG, c as createChatStreamHandler, d as bindPersonaToSession, dt as replyMetadataFor, et as TOOL_EXECUTION_ERROR_HINT, f as conversationPersonaFromAgentPersona, ft as resolveTurnReply, g as recallPersonaMemory, gt as toolFailureRecord, h as principalBindingFor, ht as toolFailureAuditMetadata, i as ChatStreamUnauthorizedError, it as buildManifestToolCatalog, j as CHAT_TURN_DEFINITION_KEY, jt as toolRunTypes, k as AssistantTurnRun, kt as ToolRunTypeRefusal, l as encodeChatStreamEvent, lt as manifestToolToAITool, m as formatRecalledMemory, mt as sanitizeClientToolDeclarations, n as ChatStreamBadRequestError, nt as TOOL_LOOP_REPEATED_CALLS_INSTRUCTION, o as MAX_CHAT_STREAM_CONTENT_LENGTH, ot as invokeManifestTool, p as conversationPersonaFromResolved, pt as runToolLoop, q as MAX_REPEATED_CALLS_LIMIT, r as ChatStreamError, rt as appendClientToolResults, s as MAX_CHAT_STREAM_MESSAGES, st as isFallbackReply, t as CHAT_STREAM_TIMEOUT_ERROR, tt as TOOL_LOOP_ANSWER_NOW_INSTRUCTION, u as runChatConversationStream, ut as replyContentFor, v as runPersonaConversationTurn, vt as RUNTIME_REPORT_DEFINE_TOOL_SLUG, w as SESSION_CONTINUATIONS_FIELD, wt as RUNTIME_REPORT_SOURCES_TOOL_SLUG, x as CONTINUATION_CLAIM_TTL_MS, xt as RUNTIME_REPORT_RUN_FUNCTION_NAME, y as ASSISTANT_TURN_GENERIC_ERROR, yt as RUNTIME_REPORT_LIST_FUNCTION_NAME, z as DEFAULT_MAX_REPEATED_CALLS } from "./chunks/chat-stream-BJbmqHsu.js";
|
|
3
3
|
import { createAssistantApprovalBridge, observeAssistantApproval, requiresOwnerApproval } from "./assistant-approvals.js";
|
|
4
4
|
import { describeAssistantTool, toolSummary } from "./tool-summary.js";
|
|
5
5
|
import { a as matchesToolAllowList, i as reconcileAssistantApprovalView, n as encodeAssistantTurnEvent, r as readAssistantTurnStream, t as AssistantTurnStreamError } from "./chunks/assistant-turn-events-DwdCZzQ0.js";
|
|
@@ -1310,6 +1310,6 @@ function jsonResponse(body, status) {
|
|
|
1310
1310
|
});
|
|
1311
1311
|
}
|
|
1312
1312
|
//#endregion
|
|
1313
|
-
export { ASSISTANT_TURN_GENERIC_ERROR, AgentSession, AssistantRecipe, AssistantTurnStreamError, AssistantTurnUserError, CHAT_AI_UNAVAILABLE_CODE, CHAT_MODULE_META, CHAT_STREAM_TIMEOUT_ERROR, CHAT_UI_SLOTS, CLIENT_TOOL_RESULT_GUIDANCE, CONTINUATION_CLAIM_TTL_MS, ChatClientRequestConflictError, ChatMessage, ChatParticipant, ChatReaction, ChatRoom, ChatRoomsRecipe, ChatService, ChatStreamBadRequestError, ChatStreamError, ChatStreamUnauthorizedError, ChatThread, DATA_DISCOVER_FUNCTION_NAME, DATA_DISCOVER_TOOL_SLUG, DATA_INSPECT_FUNCTION_NAME, DATA_INSPECT_TOOL_SLUG, DATA_QUERY_FUNCTION_NAME, DATA_QUERY_TOOL_SLUG, DATA_SURFACE_BRIDGE_VERSION, DEFAULT_ASSISTANT_TURN_HEARTBEAT_MS, DEFAULT_CHAT_STREAM_HEARTBEAT_MS, DEFAULT_CONTINUATION_TTL_MS, DEFAULT_DATA_SURFACE_BRIDGE_TTL_MS, DEFAULT_DATA_SURFACE_DEADLINE_MS, DEFAULT_EMPTY_ANSWER_FALLBACK, DEFAULT_MAX_REPEATED_CALLS, DEFAULT_MAX_STEPS, DataSurfaceActionDeniedError, DataSurfaceDeadlineError, DataSurfaceDeniedError, DataSurfaceQueryError, DataSurfaceRequestError, DataSurfaceResultOrderError, FALLBACK_HISTORY_PLACEHOLDER, FALLBACK_REPLY_METADATA_KEY, HELPER_CLEARED_PREFERENCES, HELPER_PREFERENCES_VERSION, HelperPreferencesAuthorizationError, HelperPreferencesService, HelperPreferencesValidationError, HelperProfileStoreError, MAX_CHAT_STREAM_CONTENT_LENGTH, MAX_CHAT_STREAM_MESSAGES, MAX_CLIENT_TOOLS, MAX_CLIENT_TOOL_RESULT_CHARS, MAX_CLIENT_TOOL_SCHEMA_BYTES, MAX_DATA_SURFACE_DEADLINE_MS, MAX_DEDUPED_CALLS_PER_TURN, MAX_REPEATED_CALLS_LIMIT, MAX_SERVER_TOOL_OBSERVATION_CHARS, MAX_TOOL_FAILURE_ARGS_CHARS, MAX_TOOL_LOOP_REASONING_CHARS, MAX_VOICE_GATEWAY_TEXT_LENGTH, OVERVIEW_APPLY_FUNCTION_NAME, OVERVIEW_APPLY_TOOL_SLUG, OVERVIEW_DESCRIBE_FUNCTION_NAME, OVERVIEW_DESCRIBE_TOOL_SLUG, OVERVIEW_TOOL_MAX_OPERATIONS, OVERVIEW_UNDO_FUNCTION_NAME, OVERVIEW_UNDO_TOOL_SLUG, OverviewToolError, ProfileHelperPreferenceStore, RUNTIME_REPORT_DEFINE_FUNCTION_NAME, RUNTIME_REPORT_DEFINE_TOOL_SLUG, RUNTIME_REPORT_LIST_FUNCTION_NAME, RUNTIME_REPORT_LIST_TOOL_SLUG, RUNTIME_REPORT_RUN_FUNCTION_NAME, RUNTIME_REPORT_RUN_TOOL_SLUG, RUNTIME_REPORT_SOURCES_FUNCTION_NAME, RUNTIME_REPORT_SOURCES_TOOL_SLUG, SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER, SESSION_CONTINUATIONS_FIELD, SMRT_CHAT_VOICE_TARGET, TOOL_CALL_DEDUPED_NOTE, TOOL_CALL_DEDUPED_REJECTED_NOTE, TOOL_EXECUTION_ERROR_HINT, TOOL_LOOP_ANSWER_NOW_INSTRUCTION, TOOL_LOOP_REPEATED_CALLS_INSTRUCTION, VoiceGatewayBadRequestError, VoiceGatewayError, VoiceGatewayReplayError, VoiceGatewayTurn, VoiceGatewayUnauthorizedError, VoiceSession, VoiceSessionExpiredError, VoiceSessionRejectedError,
|
|
1313
|
+
export { ASSISTANT_TURN_GENERIC_ERROR, AgentSession, AssistantRecipe, AssistantTurnRun, AssistantTurnStreamError, AssistantTurnUserError, CHAT_AI_UNAVAILABLE_CODE, CHAT_ASSISTANT_PROMPT_KEY, CHAT_MODULE_META, CHAT_STREAM_TIMEOUT_ERROR, CHAT_TURN_DEFINITION_KEY, CHAT_UI_SLOTS, CLIENT_TOOL_RESULT_GUIDANCE, CONTINUATION_CLAIM_TTL_MS, ChatClientRequestConflictError, ChatMessage, ChatParticipant, ChatReaction, ChatRoom, ChatRoomsRecipe, ChatService, ChatStreamBadRequestError, ChatStreamError, ChatStreamUnauthorizedError, ChatThread, DATA_DISCOVER_FUNCTION_NAME, DATA_DISCOVER_TOOL_SLUG, DATA_INSPECT_FUNCTION_NAME, DATA_INSPECT_TOOL_SLUG, DATA_QUERY_FUNCTION_NAME, DATA_QUERY_TOOL_SLUG, DATA_SURFACE_BRIDGE_VERSION, DEFAULT_ASSISTANT_TURN_HEARTBEAT_MS, DEFAULT_CHAT_STREAM_HEARTBEAT_MS, DEFAULT_CONTINUATION_TTL_MS, DEFAULT_DATA_SURFACE_BRIDGE_TTL_MS, DEFAULT_DATA_SURFACE_DEADLINE_MS, DEFAULT_EMPTY_ANSWER_FALLBACK, DEFAULT_MAX_REPEATED_CALLS, DEFAULT_MAX_STEPS, DataSurfaceActionDeniedError, DataSurfaceDeadlineError, DataSurfaceDeniedError, DataSurfaceQueryError, DataSurfaceRequestError, DataSurfaceResultOrderError, FALLBACK_HISTORY_PLACEHOLDER, FALLBACK_REPLY_METADATA_KEY, HELPER_CLEARED_PREFERENCES, HELPER_PREFERENCES_VERSION, HelperPreferencesAuthorizationError, HelperPreferencesService, HelperPreferencesValidationError, HelperProfileStoreError, MAX_CHAT_STREAM_CONTENT_LENGTH, MAX_CHAT_STREAM_MESSAGES, MAX_CLIENT_TOOLS, MAX_CLIENT_TOOL_RESULT_CHARS, MAX_CLIENT_TOOL_SCHEMA_BYTES, MAX_DATA_SURFACE_DEADLINE_MS, MAX_DEDUPED_CALLS_PER_TURN, MAX_REPEATED_CALLS_LIMIT, MAX_SERVER_TOOL_OBSERVATION_CHARS, MAX_TOOL_FAILURE_ARGS_CHARS, MAX_TOOL_LOOP_REASONING_CHARS, MAX_VOICE_GATEWAY_TEXT_LENGTH, OVERVIEW_APPLY_FUNCTION_NAME, OVERVIEW_APPLY_TOOL_SLUG, OVERVIEW_DESCRIBE_FUNCTION_NAME, OVERVIEW_DESCRIBE_TOOL_SLUG, OVERVIEW_TOOL_MAX_OPERATIONS, OVERVIEW_UNDO_FUNCTION_NAME, OVERVIEW_UNDO_TOOL_SLUG, OverviewToolError, ProfileHelperPreferenceStore, RUNTIME_REPORT_DEFINE_FUNCTION_NAME, RUNTIME_REPORT_DEFINE_TOOL_SLUG, RUNTIME_REPORT_LIST_FUNCTION_NAME, RUNTIME_REPORT_LIST_TOOL_SLUG, RUNTIME_REPORT_RUN_FUNCTION_NAME, RUNTIME_REPORT_RUN_TOOL_SLUG, RUNTIME_REPORT_SOURCES_FUNCTION_NAME, RUNTIME_REPORT_SOURCES_TOOL_SLUG, SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER, SESSION_CONTINUATIONS_FIELD, SMRT_CHAT_VOICE_TARGET, TOOL_CALL_DEDUPED_NOTE, TOOL_CALL_DEDUPED_REJECTED_NOTE, TOOL_EXECUTION_ERROR_HINT, TOOL_LOOP_ANSWER_NOW_INSTRUCTION, TOOL_LOOP_REPEATED_CALLS_INSTRUCTION, ToolRunTypeRefusal, VoiceGatewayBadRequestError, VoiceGatewayError, VoiceGatewayReplayError, VoiceGatewayTurn, VoiceGatewayUnauthorizedError, VoiceSession, VoiceSessionExpiredError, VoiceSessionRejectedError, acceptAppliedChange, appendClientToolResults, assertToolRunType, assertVoiceGatewayBearer, bindPersonaToSession, buildManifestToolCatalog, captureChatFeedback, chatAssistantSystemPrompt, chatUnavailableBody, chatUnconfiguredBody, classifyToolError, clientRequestMessageId, conversationPersonaFromAgentPersona, conversationPersonaFromResolved, correctResponse, createAssistantApprovalBridge, createAssistantTurnResponse, createChatStreamHandler, createDataSurfaceBridge, createDataSurfaceCommandBridge, createDataSurfaceQueryFingerprint, createDataSurfaceTools, createHelperProfilePreferenceStore, createMemoryContinuationStore, createMemoryOverviewUndoStore, createOverviewTools, createRuntimeReportTools, createServerDataSurfaceBridge, createSessionContinuationStore, createVoiceChatSession, createVoiceGatewayTurnHandler, defaultOverviewUndoStore, describeAssistantTool, encodeAssistantTurnEvent, encodeChatStreamEvent, formatOverviewIssues, formatRecalledMemory, handleVoiceGatewayTurn, helperPreferenceFields, invokeManifestTool, isFallbackReply, isHelperClearedPreferences, manifestToolToAITool, matchesToolAllowList, normalizeDataSurfaceRowCountHint, observeAssistantApproval, parseHelperPreferences, principalBindingFor, rateResponse, readAssistantTurnStream, recallPersonaMemory, reconcileAssistantApprovalView, rejectAppliedChange, replyContentFor, replyMetadataFor, requiresOwnerApproval, resolveChatAssistantPrompt, resolveChatAssistantTier, resolveConversationInstructions, resolveTurnReply, runAssistantTurn, runChatConversationStream, runPersonaConversationTurn, runToolLoop, sanitizeClientToolDeclarations, thumbsDown, thumbsUp, toolFailureAuditMetadata, toolFailureRecord, toolRunTypes, toolSummary };
|
|
1314
1314
|
|
|
1315
1315
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as sendAgentReply } from "../chunks/ChatService-
|
|
1
|
+
import { a as sendAgentReply } from "../chunks/ChatService-CDLAEJms.js";
|
|
2
2
|
export { sendAgentReply };
|
package/dist/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": "1.0.0",
|
|
3
3
|
"timestamp": 0,
|
|
4
4
|
"packageName": "@happyvertical/smrt-chat",
|
|
5
|
-
"packageVersion": "0.
|
|
5
|
+
"packageVersion": "0.62.0",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-chat:AgentSessionCollection": {
|
|
8
8
|
"name": "agentsessioncollection",
|
|
@@ -5916,6 +5916,7 @@
|
|
|
5916
5916
|
"@happyvertical/smrt-inference",
|
|
5917
5917
|
"@happyvertical/smrt-personas",
|
|
5918
5918
|
"@happyvertical/smrt-profiles",
|
|
5919
|
+
"@happyvertical/smrt-prompts",
|
|
5919
5920
|
"@happyvertical/smrt-reports",
|
|
5920
5921
|
"@happyvertical/smrt-tenancy",
|
|
5921
5922
|
"@happyvertical/smrt-users"
|