@alexkroman1/aai 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{constants-CwotjpJR.js → constants-CpLN9WGY.js} +1 -1
- package/dist/{direct-executor-DAGCZOAN.js → direct-executor-DyY-Y4ZE.js} +58 -221
- package/dist/{_run-code.d.ts → host/_run-code.d.ts} +1 -1
- package/dist/{_runtime-conformance.d.ts → host/_runtime-conformance.d.ts} +4 -4
- package/dist/{_test-utils.d.ts → host/_test-utils.d.ts} +3 -3
- package/dist/{builtin-tools.d.ts → host/builtin-tools.d.ts} +3 -3
- package/dist/{direct-executor.d.ts → host/direct-executor.d.ts} +7 -7
- package/dist/{internal.d.ts → host/index.d.ts} +5 -6
- package/dist/{internal.js → host/index.js} +12 -9
- package/dist/{matchers.js → host/matchers.js} +2 -2
- package/dist/{server.d.ts → host/server.d.ts} +1 -17
- package/dist/{server.js → host/server.js} +25 -22
- package/dist/{session.d.ts → host/session.d.ts} +7 -7
- package/dist/{testing.d.ts → host/testing.d.ts} +2 -2
- package/dist/{testing.js → host/testing.js} +1 -1
- package/dist/{unstorage-kv.d.ts → host/unstorage-kv.d.ts} +1 -1
- package/dist/{vite-plugin.js → host/vite-plugin.js} +1 -1
- package/dist/{ws-handler.d.ts → host/ws-handler.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{_utils.d.ts → isolate/_utils.d.ts} +0 -2
- package/dist/{_utils.js → isolate/_utils.js} +2 -13
- package/dist/{hooks.js → isolate/hooks.js} +1 -1
- package/dist/isolate/index.d.ts +19 -0
- package/dist/isolate/index.js +8 -0
- package/dist/{kv.js → isolate/kv.js} +2 -2
- package/dist/{protocol.js → isolate/protocol.js} +2 -2
- package/dist/{types.js → isolate/types.js} +1 -1
- package/dist/system-prompt-u19j6xfA.js +166 -0
- package/dist/{testing-Dmx-dudh.js → testing-CNNg2-n-.js} +7 -7
- package/package.json +39 -34
- package/dist/{_mock-ws.d.ts → host/_mock-ws.d.ts} +0 -0
- package/dist/{matchers.d.ts → host/matchers.d.ts} +0 -0
- package/dist/{runtime.d.ts → host/runtime.d.ts} +0 -0
- package/dist/{s2s.d.ts → host/s2s.d.ts} +0 -0
- package/dist/{vite-plugin.d.ts → host/vite-plugin.d.ts} +0 -0
- package/dist/{_internal-types.d.ts → isolate/_internal-types.d.ts} +0 -0
- package/dist/{constants.d.ts → isolate/constants.d.ts} +0 -0
- package/dist/{hooks.d.ts → isolate/hooks.d.ts} +0 -0
- package/dist/{kv.d.ts → isolate/kv.d.ts} +0 -0
- package/dist/{memory-tools.d.ts → isolate/memory-tools.d.ts} +0 -0
- package/dist/{protocol.d.ts → isolate/protocol.d.ts} +3 -3
- /package/dist/{system-prompt.d.ts → isolate/system-prompt.d.ts} +0 -0
- /package/dist/{types.d.ts → isolate/types.d.ts} +0 -0
|
@@ -1,117 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { callResolveTurnConfig, createAgentHooks } from "./hooks.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { i as EMPTY_PARAMS, n as memoryTools, o as agentToolsToSchemas, s as toAgentConfig, t as buildSystemPrompt } from "./system-prompt-u19j6xfA.js";
|
|
2
|
+
import { errorDetail, errorMessage, toolError } from "./isolate/_utils.js";
|
|
3
|
+
import { a as DEFAULT_SHUTDOWN_TIMEOUT_MS, c as FETCH_TIMEOUT_MS, d as MAX_HTML_BYTES, f as MAX_PAGE_CHARS, g as TOOL_EXECUTION_TIMEOUT_MS, h as RUN_CODE_TIMEOUT_MS, l as HOOK_TIMEOUT_MS, m as MAX_VALUE_SIZE, o as DEFAULT_STT_SAMPLE_RATE, p as MAX_TOOL_RESULT_CHARS, s as DEFAULT_TTS_SAMPLE_RATE } from "./constants-CpLN9WGY.js";
|
|
4
|
+
import { callResolveTurnConfig, createAgentHooks } from "./isolate/hooks.js";
|
|
5
|
+
import { matchGlob, sortAndPaginate } from "./isolate/kv.js";
|
|
6
|
+
import { ClientMessageSchema, buildReadyConfig } from "./isolate/protocol.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import WsWebSocket from "ws";
|
|
9
8
|
import pTimeout from "p-timeout";
|
|
10
9
|
import { createStorage, prefixStorage } from "unstorage";
|
|
11
10
|
import vm from "node:vm";
|
|
12
11
|
import { createNanoEvents } from "nanoevents";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Runtime dependencies injected into the session pipeline.
|
|
16
|
-
*
|
|
17
|
-
* Defines the {@link Logger} interface, a default {@link consoleLogger},
|
|
18
|
-
* and the {@link S2SConfig} for Speech-to-Speech endpoint configuration.
|
|
19
|
-
*/
|
|
20
|
-
/** Default console-backed logger. */
|
|
21
|
-
const consoleLogger = {
|
|
22
|
-
info: (msg, ctx) => ctx ? console.log(msg, ctx) : console.log(msg),
|
|
23
|
-
warn: (msg, ctx) => ctx ? console.warn(msg, ctx) : console.warn(msg),
|
|
24
|
-
error: (msg, ctx) => ctx ? console.error(msg, ctx) : console.error(msg),
|
|
25
|
-
debug: (msg, ctx) => ctx ? console.debug(msg, ctx) : console.debug(msg)
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Structured JSON logger for production diagnostics. Each log entry is a
|
|
29
|
-
* single-line JSON object with `timestamp`, `level`, `msg`, and any
|
|
30
|
-
* caller-provided context fields.
|
|
31
|
-
*/
|
|
32
|
-
function jsonLog(level) {
|
|
33
|
-
return (msg, ctx) => {
|
|
34
|
-
const entry = {
|
|
35
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
36
|
-
level,
|
|
37
|
-
msg
|
|
38
|
-
};
|
|
39
|
-
if (ctx) Object.assign(entry, ctx);
|
|
40
|
-
(level === "error" || level === "warn" ? process.stderr : process.stdout).write(`${JSON.stringify(entry)}\n`);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const jsonLogger = {
|
|
44
|
-
info: jsonLog("info"),
|
|
45
|
-
warn: jsonLog("warn"),
|
|
46
|
-
error: jsonLog("error"),
|
|
47
|
-
debug: jsonLog("debug")
|
|
48
|
-
};
|
|
49
|
-
/** Default S2S endpoint configuration. */
|
|
50
|
-
const DEFAULT_S2S_CONFIG = {
|
|
51
|
-
wssUrl: "wss://speech-to-speech.us.assemblyai.com/v1/realtime",
|
|
52
|
-
inputSampleRate: DEFAULT_STT_SAMPLE_RATE,
|
|
53
|
-
outputSampleRate: DEFAULT_TTS_SAMPLE_RATE
|
|
54
|
-
};
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region _internal-types.ts
|
|
57
|
-
/**
|
|
58
|
-
* Zod schema for serializable agent configuration sent over the wire.
|
|
59
|
-
*
|
|
60
|
-
* This is the JSON-safe subset of the agent definition that can be
|
|
61
|
-
* transmitted between the worker and the host process via structured clone.
|
|
62
|
-
*/
|
|
63
|
-
const AgentConfigSchema = z.object({
|
|
64
|
-
name: z.string().min(1),
|
|
65
|
-
instructions: z.string(),
|
|
66
|
-
greeting: z.string(),
|
|
67
|
-
sttPrompt: z.string().optional(),
|
|
68
|
-
maxSteps: z.number().int().positive().optional(),
|
|
69
|
-
toolChoice: ToolChoiceSchema.optional(),
|
|
70
|
-
builtinTools: z.array(BuiltinToolSchema).readonly().optional(),
|
|
71
|
-
idleTimeoutMs: z.number().nonnegative().optional()
|
|
72
|
-
});
|
|
73
|
-
/** Extract the serializable {@link AgentConfig} subset from a source object. */
|
|
74
|
-
function toAgentConfig(src) {
|
|
75
|
-
const config = {
|
|
76
|
-
name: src.name,
|
|
77
|
-
instructions: src.instructions,
|
|
78
|
-
greeting: src.greeting
|
|
79
|
-
};
|
|
80
|
-
if (src.sttPrompt !== void 0) config.sttPrompt = src.sttPrompt;
|
|
81
|
-
if (typeof src.maxSteps !== "function" && src.maxSteps !== void 0) config.maxSteps = src.maxSteps;
|
|
82
|
-
if (src.toolChoice !== void 0) config.toolChoice = src.toolChoice;
|
|
83
|
-
if (src.builtinTools) config.builtinTools = [...src.builtinTools];
|
|
84
|
-
if (src.idleTimeoutMs !== void 0) config.idleTimeoutMs = src.idleTimeoutMs;
|
|
85
|
-
return config;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Zod schema for serialized tool definitions sent over the wire.
|
|
89
|
-
*
|
|
90
|
-
* `parameters` must be a valid JSON Schema object (with `type`, `properties`,
|
|
91
|
-
* etc.) — the Vercel AI SDK wraps it via `jsonSchema()`.
|
|
92
|
-
*/
|
|
93
|
-
const ToolSchemaSchema = z.object({
|
|
94
|
-
name: z.string().min(1),
|
|
95
|
-
description: z.string().min(1),
|
|
96
|
-
parameters: z.record(z.string(), z.unknown())
|
|
97
|
-
});
|
|
98
|
-
/** Empty Zod object schema used as default when tools have no parameters. */
|
|
99
|
-
const EMPTY_PARAMS = z.object({});
|
|
100
|
-
/**
|
|
101
|
-
* Convert agent tool definitions to JSON Schema format for wire transport.
|
|
102
|
-
*
|
|
103
|
-
* Transforms the Zod-based `parameters` of each tool into a plain JSON Schema
|
|
104
|
-
* object suitable for structured clone / JSON serialization.
|
|
105
|
-
*/
|
|
106
|
-
function agentToolsToSchemas(tools) {
|
|
107
|
-
return Object.entries(tools).map(([name, def]) => ({
|
|
108
|
-
name,
|
|
109
|
-
description: def.description,
|
|
110
|
-
parameters: z.toJSONSchema(def.parameters ?? EMPTY_PARAMS)
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region _run-code.ts
|
|
12
|
+
import WsWebSocket from "ws";
|
|
13
|
+
//#region host/_run-code.ts
|
|
115
14
|
/**
|
|
116
15
|
* run_code built-in tool — executes user JavaScript in a fresh `node:vm`
|
|
117
16
|
* context with no network, filesystem, or process access.
|
|
@@ -181,82 +80,7 @@ async function executeInIsolate(code) {
|
|
|
181
80
|
}
|
|
182
81
|
}
|
|
183
82
|
//#endregion
|
|
184
|
-
//#region
|
|
185
|
-
/**
|
|
186
|
-
* KV-backed memory tools for agent persistent state.
|
|
187
|
-
*/
|
|
188
|
-
/**
|
|
189
|
-
* Returns a standard set of KV-backed memory tools: `save_memory`,
|
|
190
|
-
* `recall_memory`, `list_memories`, and `forget_memory`.
|
|
191
|
-
*
|
|
192
|
-
* Spread the result into your agent's `tools` record.
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* ```ts
|
|
196
|
-
* import { defineAgent, memoryTools } from "aai";
|
|
197
|
-
*
|
|
198
|
-
* export default defineAgent({
|
|
199
|
-
* name: "My Agent",
|
|
200
|
-
* tools: { ...memoryTools() },
|
|
201
|
-
* });
|
|
202
|
-
* ```
|
|
203
|
-
*
|
|
204
|
-
* @returns A record with four tool definitions: `save_memory`, `recall_memory`,
|
|
205
|
-
* `list_memories`, and `forget_memory`.
|
|
206
|
-
* @public
|
|
207
|
-
*/
|
|
208
|
-
function memoryTools() {
|
|
209
|
-
return {
|
|
210
|
-
save_memory: defineTool({
|
|
211
|
-
description: "Save a piece of information to persistent memory. Use a descriptive key like 'user:name' or 'project:status'.",
|
|
212
|
-
parameters: z.object({
|
|
213
|
-
key: z.string().describe("A descriptive key for this memory (e.g. 'user:name', 'preference:color')"),
|
|
214
|
-
value: z.string().describe("The information to remember")
|
|
215
|
-
}),
|
|
216
|
-
execute: async ({ key, value }, ctx) => {
|
|
217
|
-
await ctx.kv.set(key, value);
|
|
218
|
-
return { saved: key };
|
|
219
|
-
}
|
|
220
|
-
}),
|
|
221
|
-
recall_memory: defineTool({
|
|
222
|
-
description: "Retrieve a previously saved memory by its key.",
|
|
223
|
-
parameters: z.object({ key: z.string().describe("The key to look up") }),
|
|
224
|
-
execute: async ({ key }, ctx) => {
|
|
225
|
-
const value = await ctx.kv.get(key);
|
|
226
|
-
if (value === null) return {
|
|
227
|
-
found: false,
|
|
228
|
-
key
|
|
229
|
-
};
|
|
230
|
-
return {
|
|
231
|
-
found: true,
|
|
232
|
-
key,
|
|
233
|
-
value
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}),
|
|
237
|
-
list_memories: defineTool({
|
|
238
|
-
description: "List all saved memory keys, optionally filtered by a prefix (e.g. 'user:').",
|
|
239
|
-
parameters: z.object({ prefix: z.string().describe("Prefix to filter keys (e.g. 'user:'). Use empty string for all.").optional() }),
|
|
240
|
-
execute: async ({ prefix }, ctx) => {
|
|
241
|
-
const entries = await ctx.kv.list(prefix ?? "");
|
|
242
|
-
return {
|
|
243
|
-
count: entries.length,
|
|
244
|
-
keys: entries.map((e) => e.key)
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
}),
|
|
248
|
-
forget_memory: defineTool({
|
|
249
|
-
description: "Delete a previously saved memory by its key.",
|
|
250
|
-
parameters: z.object({ key: z.string().describe("The key to delete") }),
|
|
251
|
-
execute: async ({ key }, ctx) => {
|
|
252
|
-
await ctx.kv.delete(key);
|
|
253
|
-
return { deleted: key };
|
|
254
|
-
}
|
|
255
|
-
})
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region builtin-tools.ts
|
|
83
|
+
//#region host/builtin-tools.ts
|
|
260
84
|
/**
|
|
261
85
|
* Built-in tool definitions for the AAI agent SDK.
|
|
262
86
|
*
|
|
@@ -418,7 +242,50 @@ function getBuiltinToolSchemas(names) {
|
|
|
418
242
|
})));
|
|
419
243
|
}
|
|
420
244
|
//#endregion
|
|
421
|
-
//#region
|
|
245
|
+
//#region host/runtime.ts
|
|
246
|
+
/**
|
|
247
|
+
* Runtime dependencies injected into the session pipeline.
|
|
248
|
+
*
|
|
249
|
+
* Defines the {@link Logger} interface, a default {@link consoleLogger},
|
|
250
|
+
* and the {@link S2SConfig} for Speech-to-Speech endpoint configuration.
|
|
251
|
+
*/
|
|
252
|
+
/** Default console-backed logger. */
|
|
253
|
+
const consoleLogger = {
|
|
254
|
+
info: (msg, ctx) => ctx ? console.log(msg, ctx) : console.log(msg),
|
|
255
|
+
warn: (msg, ctx) => ctx ? console.warn(msg, ctx) : console.warn(msg),
|
|
256
|
+
error: (msg, ctx) => ctx ? console.error(msg, ctx) : console.error(msg),
|
|
257
|
+
debug: (msg, ctx) => ctx ? console.debug(msg, ctx) : console.debug(msg)
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Structured JSON logger for production diagnostics. Each log entry is a
|
|
261
|
+
* single-line JSON object with `timestamp`, `level`, `msg`, and any
|
|
262
|
+
* caller-provided context fields.
|
|
263
|
+
*/
|
|
264
|
+
function jsonLog(level) {
|
|
265
|
+
return (msg, ctx) => {
|
|
266
|
+
const entry = {
|
|
267
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
268
|
+
level,
|
|
269
|
+
msg
|
|
270
|
+
};
|
|
271
|
+
if (ctx) Object.assign(entry, ctx);
|
|
272
|
+
(level === "error" || level === "warn" ? process.stderr : process.stdout).write(`${JSON.stringify(entry)}\n`);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
const jsonLogger = {
|
|
276
|
+
info: jsonLog("info"),
|
|
277
|
+
warn: jsonLog("warn"),
|
|
278
|
+
error: jsonLog("error"),
|
|
279
|
+
debug: jsonLog("debug")
|
|
280
|
+
};
|
|
281
|
+
/** Default S2S endpoint configuration. */
|
|
282
|
+
const DEFAULT_S2S_CONFIG = {
|
|
283
|
+
wssUrl: "wss://speech-to-speech.us.assemblyai.com/v1/realtime",
|
|
284
|
+
inputSampleRate: DEFAULT_STT_SAMPLE_RATE,
|
|
285
|
+
outputSampleRate: DEFAULT_TTS_SAMPLE_RATE
|
|
286
|
+
};
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region host/s2s.ts
|
|
422
289
|
const uint8ToBase64 = (bytes) => Buffer.from(bytes).toString("base64");
|
|
423
290
|
const base64ToUint8 = (base64) => new Uint8Array(Buffer.from(base64, "base64"));
|
|
424
291
|
const WS_OPEN = 1;
|
|
@@ -667,37 +534,7 @@ function connectS2s(opts) {
|
|
|
667
534
|
});
|
|
668
535
|
}
|
|
669
536
|
//#endregion
|
|
670
|
-
//#region
|
|
671
|
-
function getFormattedDate() {
|
|
672
|
-
return (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
673
|
-
weekday: "long",
|
|
674
|
-
year: "numeric",
|
|
675
|
-
month: "long",
|
|
676
|
-
day: "numeric"
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
const VOICE_RULES = "\n\nCRITICAL OUTPUT RULES — you MUST follow these for EVERY response:\nYour response will be spoken aloud by a TTS system and displayed as plain text.\n- NEVER use markdown: no **, no *, no _, no #, no `, no [](), no ---\n- NEVER use bullet points (-, *, •) or numbered lists (1., 2.)\n- NEVER use code blocks or inline code\n- NEVER mention tools, search, APIs, or technical failures to the user. If a tool returns no results, just answer naturally without explaining why.\n- Write exactly as you would say it out loud to a friend\n- Use short conversational sentences. To list things, say \"First,\" \"Next,\" \"Finally,\"\n- Keep responses concise — 1 to 3 sentences max";
|
|
680
|
-
/**
|
|
681
|
-
* Build the system prompt sent to the LLM from the agent configuration.
|
|
682
|
-
*
|
|
683
|
-
* Assembles the default instructions, today's date, agent-specific instructions,
|
|
684
|
-
* and optional sections for tool usage preamble and voice output rules.
|
|
685
|
-
*
|
|
686
|
-
* @param config - The serializable agent configuration (name, instructions, etc.).
|
|
687
|
-
* @param opts.hasTools - When `true`, appends a preamble instructing the LLM to
|
|
688
|
-
* speak a brief phrase before each tool call to fill silence.
|
|
689
|
-
* @param opts.voice - When `true`, appends strict voice-specific output rules
|
|
690
|
-
* (no markdown, no bullet points, conversational tone, concise responses).
|
|
691
|
-
* @returns The assembled system prompt string.
|
|
692
|
-
*/
|
|
693
|
-
function buildSystemPrompt(config, opts) {
|
|
694
|
-
const { hasTools } = opts;
|
|
695
|
-
const agentInstructions = config.instructions && config.instructions !== DEFAULT_INSTRUCTIONS ? `\n\nAgent-Specific Instructions:\n${config.instructions}` : "";
|
|
696
|
-
const toolPreamble = hasTools ? "\n\nWhen you decide to use a tool, ALWAYS say a brief natural phrase BEFORE the tool call (e.g. \"Let me look that up\" or \"One moment while I check\"). This fills silence while the tool executes. Keep preambles to one short sentence." : "";
|
|
697
|
-
return DEFAULT_INSTRUCTIONS + `\n\nToday's date is ${getFormattedDate()}.` + agentInstructions + toolPreamble + (opts.voice ? VOICE_RULES : "");
|
|
698
|
-
}
|
|
699
|
-
//#endregion
|
|
700
|
-
//#region session.ts
|
|
537
|
+
//#region host/session.ts
|
|
701
538
|
function buildCtx(opts) {
|
|
702
539
|
const { id, agentConfig, hooks, log } = opts;
|
|
703
540
|
const maxHistory = opts.maxHistory ?? 200;
|
|
@@ -1090,7 +927,7 @@ function createS2sSession(opts) {
|
|
|
1090
927
|
};
|
|
1091
928
|
}
|
|
1092
929
|
//#endregion
|
|
1093
|
-
//#region unstorage-kv.ts
|
|
930
|
+
//#region host/unstorage-kv.ts
|
|
1094
931
|
/**
|
|
1095
932
|
* Key-value store backed by unstorage.
|
|
1096
933
|
*
|
|
@@ -1151,7 +988,7 @@ function createUnstorageKv(options) {
|
|
|
1151
988
|
};
|
|
1152
989
|
}
|
|
1153
990
|
//#endregion
|
|
1154
|
-
//#region ws-handler.ts
|
|
991
|
+
//#region host/ws-handler.ts
|
|
1155
992
|
/**
|
|
1156
993
|
* WebSocket session lifecycle handler.
|
|
1157
994
|
*
|
|
@@ -1341,7 +1178,7 @@ function wireSessionSocket(ws, opts) {
|
|
|
1341
1178
|
});
|
|
1342
1179
|
}
|
|
1343
1180
|
//#endregion
|
|
1344
|
-
//#region direct-executor.ts
|
|
1181
|
+
//#region host/direct-executor.ts
|
|
1345
1182
|
/**
|
|
1346
1183
|
* Agent runtime — the execution engine for voice agents.
|
|
1347
1184
|
*
|
|
@@ -1527,4 +1364,4 @@ function createRuntime(opts) {
|
|
|
1527
1364
|
};
|
|
1528
1365
|
}
|
|
1529
1366
|
//#endregion
|
|
1530
|
-
export {
|
|
1367
|
+
export { _internals as a, connectS2s as c, consoleLogger as d, jsonLogger as f, createUnstorageKv as i, defaultCreateS2sWebSocket as l, executeToolCall as n, buildCtx as o, wireSessionSocket as r, createS2sSession as s, createRuntime as t, DEFAULT_S2S_CONFIG as u };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* context with no network, filesystem, or process access.
|
|
4
4
|
*/
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import type { ToolDef } from "
|
|
6
|
+
import type { ToolDef } from "../isolate/types.ts";
|
|
7
7
|
declare const runCodeParams: z.ZodObject<{
|
|
8
8
|
code: z.ZodString;
|
|
9
9
|
}, z.core.$strip>;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @example Sandbox (integration test in aai-server)
|
|
21
21
|
* ```ts
|
|
22
|
-
* import { testRuntime } from "@alexkroman1/aai/
|
|
22
|
+
* import { testRuntime } from "@alexkroman1/aai/host";
|
|
23
23
|
*
|
|
24
24
|
* testRuntime("sandbox", async () => {
|
|
25
25
|
* // ... start isolate with a bundled agent
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
* });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
import type { ExecuteTool } from "
|
|
31
|
-
import type { AgentHooks } from "
|
|
32
|
-
import { type AgentDef } from "
|
|
30
|
+
import type { ExecuteTool } from "../isolate/_internal-types.ts";
|
|
31
|
+
import type { AgentHooks } from "../isolate/hooks.ts";
|
|
32
|
+
import { type AgentDef } from "../isolate/types.ts";
|
|
33
33
|
/**
|
|
34
34
|
* Minimal runtime surface needed for conformance tests.
|
|
35
35
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AgentConfig } from "
|
|
2
|
-
import type { ClientSink } from "
|
|
1
|
+
import type { AgentConfig } from "../isolate/_internal-types.ts";
|
|
2
|
+
import type { ClientSink } from "../isolate/protocol.ts";
|
|
3
|
+
import type { AgentDef, ToolContext, ToolDef } from "../isolate/types.ts";
|
|
3
4
|
import type { S2sEvents, S2sHandle } from "./s2s.ts";
|
|
4
5
|
import type { Session } from "./session.ts";
|
|
5
6
|
import { type S2sSessionOptions } from "./session.ts";
|
|
6
|
-
import type { AgentDef, ToolContext, ToolDef } from "./types.ts";
|
|
7
7
|
/** Yield to the microtask queue so pending promises settle. */
|
|
8
8
|
export declare function flush(): Promise<void>;
|
|
9
9
|
export declare function createMockToolContext(overrides?: Partial<ToolContext>): ToolContext;
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* Network requests go through the host's fetch proxy (with SSRF protection).
|
|
7
7
|
*/
|
|
8
8
|
import { z } from "zod";
|
|
9
|
-
import { type ToolSchema } from "
|
|
10
|
-
import type { ToolDef } from "
|
|
9
|
+
import { type ToolSchema } from "../isolate/_internal-types.ts";
|
|
10
|
+
import type { ToolDef } from "../isolate/types.ts";
|
|
11
|
+
export { memoryTools } from "../isolate/memory-tools.ts";
|
|
11
12
|
export { executeInIsolate } from "./_run-code.ts";
|
|
12
|
-
export { memoryTools } from "./memory-tools.ts";
|
|
13
13
|
/** Options for creating built-in tool definitions. */
|
|
14
14
|
export type BuiltinToolOptions = {
|
|
15
15
|
/** Override fetch implementation (defaults to globalThis.fetch). For testing. */
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
* self-hosted servers and the platform sandbox. It wires up tool execution,
|
|
6
6
|
* lifecycle hooks, and session management.
|
|
7
7
|
*/
|
|
8
|
-
import { type ExecuteTool, type ToolSchema } from "
|
|
9
|
-
import { type AgentHooks } from "
|
|
10
|
-
import type { Kv } from "
|
|
11
|
-
import type { ClientSink } from "
|
|
12
|
-
import { type ReadyConfig } from "
|
|
8
|
+
import { type ExecuteTool, type ToolSchema } from "../isolate/_internal-types.ts";
|
|
9
|
+
import { type AgentHooks } from "../isolate/hooks.ts";
|
|
10
|
+
import type { Kv } from "../isolate/kv.ts";
|
|
11
|
+
import type { ClientSink } from "../isolate/protocol.ts";
|
|
12
|
+
import { type ReadyConfig } from "../isolate/protocol.ts";
|
|
13
|
+
import type { AgentDef, Message, ToolDef } from "../isolate/types.ts";
|
|
13
14
|
import type { Logger, S2SConfig } from "./runtime.ts";
|
|
14
15
|
import type { CreateS2sWebSocket } from "./s2s.ts";
|
|
15
16
|
import { type Session } from "./session.ts";
|
|
16
|
-
import type { AgentDef, Message, ToolDef } from "./types.ts";
|
|
17
17
|
import { type SessionWebSocket } from "./ws-handler.ts";
|
|
18
|
-
export type { ExecuteTool } from "
|
|
18
|
+
export type { ExecuteTool } from "../isolate/_internal-types.ts";
|
|
19
19
|
export type ExecuteToolCallOptions = {
|
|
20
20
|
tool: ToolDef;
|
|
21
21
|
env: Readonly<Record<string, string>>;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Host barrel — re-exports all SDK internals for use by the platform
|
|
3
3
|
* server (`aai-server`) and CLI. **Not a public API.**
|
|
4
4
|
*
|
|
5
|
+
* Includes the full isolate-safe kernel plus host-only modules that
|
|
6
|
+
* depend on Node.js APIs (server, executor, S2S, etc.).
|
|
7
|
+
*
|
|
5
8
|
* Consumer packages should import from the top-level `@alexkroman1/aai`
|
|
6
9
|
* entry, `./server`, `./types`, `./kv`, `./protocol`, or `./testing`.
|
|
7
10
|
*/
|
|
8
|
-
export * from "
|
|
11
|
+
export * from "../isolate/index.ts";
|
|
9
12
|
export * from "./_runtime-conformance.ts";
|
|
10
|
-
export * from "./_utils.ts";
|
|
11
|
-
export * from "./constants.ts";
|
|
12
13
|
export * from "./direct-executor.ts";
|
|
13
|
-
export * from "./hooks.ts";
|
|
14
|
-
export * from "./protocol.ts";
|
|
15
14
|
export * from "./runtime.ts";
|
|
16
15
|
export * from "./s2s.ts";
|
|
17
16
|
export * from "./session.ts";
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { defineTool } from "
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { callResolveTurnConfig, createAgentHooks } from "
|
|
6
|
-
import {
|
|
1
|
+
import { BuiltinToolSchema, DEFAULT_GREETING, DEFAULT_INSTRUCTIONS, ToolChoiceSchema, defineAgent, defineTool, defineToolFactory } from "../isolate/types.js";
|
|
2
|
+
import { a as ToolSchemaSchema, i as EMPTY_PARAMS, n as memoryTools, o as agentToolsToSchemas, r as AgentConfigSchema, s as toAgentConfig, t as buildSystemPrompt } from "../system-prompt-u19j6xfA.js";
|
|
3
|
+
import { errorDetail, errorMessage, toolError } from "../isolate/_utils.js";
|
|
4
|
+
import { a as DEFAULT_SHUTDOWN_TIMEOUT_MS, c as FETCH_TIMEOUT_MS, d as MAX_HTML_BYTES, f as MAX_PAGE_CHARS, g as TOOL_EXECUTION_TIMEOUT_MS, h as RUN_CODE_TIMEOUT_MS, i as DEFAULT_SESSION_START_TIMEOUT_MS, l as HOOK_TIMEOUT_MS, m as MAX_VALUE_SIZE, n as DEFAULT_IDLE_TIMEOUT_MS, o as DEFAULT_STT_SAMPLE_RATE, p as MAX_TOOL_RESULT_CHARS, r as DEFAULT_MAX_HISTORY, s as DEFAULT_TTS_SAMPLE_RATE, t as AGENT_CSP, u as MAX_GLOB_PATTERN_LENGTH } from "../constants-CpLN9WGY.js";
|
|
5
|
+
import { callResolveTurnConfig, createAgentHooks } from "../isolate/hooks.js";
|
|
6
|
+
import { matchGlob, sortAndPaginate } from "../isolate/kv.js";
|
|
7
|
+
import { AUDIO_FORMAT, ClientEventSchema, ClientMessageSchema, KvRequestSchema, ReadyConfigSchema, ServerMessageSchema, SessionErrorCodeSchema, TurnConfigSchema, buildReadyConfig } from "../isolate/protocol.js";
|
|
8
|
+
import "../isolate/index.js";
|
|
9
|
+
import { a as _internals, c as connectS2s, d as consoleLogger, f as jsonLogger, i as createUnstorageKv, l as defaultCreateS2sWebSocket, n as executeToolCall, o as buildCtx, r as wireSessionSocket, s as createS2sSession, t as createRuntime, u as DEFAULT_S2S_CONFIG } from "../direct-executor-DyY-Y4ZE.js";
|
|
7
10
|
import { z } from "zod";
|
|
8
11
|
import { describe, expect, test } from "vitest";
|
|
9
|
-
//#region _runtime-conformance.ts
|
|
12
|
+
//#region host/_runtime-conformance.ts
|
|
10
13
|
/**
|
|
11
14
|
* Shared runtime conformance tests.
|
|
12
15
|
*
|
|
@@ -28,7 +31,7 @@ import { describe, expect, test } from "vitest";
|
|
|
28
31
|
*
|
|
29
32
|
* @example Sandbox (integration test in aai-server)
|
|
30
33
|
* ```ts
|
|
31
|
-
* import { testRuntime } from "@alexkroman1/aai/
|
|
34
|
+
* import { testRuntime } from "@alexkroman1/aai/host";
|
|
32
35
|
*
|
|
33
36
|
* testRuntime("sandbox", async () => {
|
|
34
37
|
* // ... start isolate with a bundled agent
|
|
@@ -161,4 +164,4 @@ function testRuntime(label, getContext) {
|
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
//#endregion
|
|
164
|
-
export { AGENT_CSP, AUDIO_FORMAT, AgentConfigSchema, CONFORMANCE_AGENT, ClientEventSchema, ClientMessageSchema, DEFAULT_IDLE_TIMEOUT_MS, DEFAULT_MAX_HISTORY, DEFAULT_S2S_CONFIG, DEFAULT_SESSION_START_TIMEOUT_MS, DEFAULT_SHUTDOWN_TIMEOUT_MS, DEFAULT_STT_SAMPLE_RATE, DEFAULT_TTS_SAMPLE_RATE, EMPTY_PARAMS, FETCH_TIMEOUT_MS, HOOK_TIMEOUT_MS, KvRequestSchema, MAX_GLOB_PATTERN_LENGTH, MAX_HTML_BYTES, MAX_PAGE_CHARS, MAX_TOOL_RESULT_CHARS, MAX_VALUE_SIZE, RUN_CODE_TIMEOUT_MS, ReadyConfigSchema, ServerMessageSchema, SessionErrorCodeSchema, TOOL_EXECUTION_TIMEOUT_MS, ToolSchemaSchema, TurnConfigSchema, _internals, agentToolsToSchemas, buildCtx, buildReadyConfig, buildSystemPrompt, callResolveTurnConfig, connectS2s, consoleLogger, createAgentHooks, createRuntime, createS2sSession, createUnstorageKv, defaultCreateS2sWebSocket, errorDetail, errorMessage, executeToolCall,
|
|
167
|
+
export { AGENT_CSP, AUDIO_FORMAT, AgentConfigSchema, BuiltinToolSchema, CONFORMANCE_AGENT, ClientEventSchema, ClientMessageSchema, DEFAULT_GREETING, DEFAULT_IDLE_TIMEOUT_MS, DEFAULT_INSTRUCTIONS, DEFAULT_MAX_HISTORY, DEFAULT_S2S_CONFIG, DEFAULT_SESSION_START_TIMEOUT_MS, DEFAULT_SHUTDOWN_TIMEOUT_MS, DEFAULT_STT_SAMPLE_RATE, DEFAULT_TTS_SAMPLE_RATE, EMPTY_PARAMS, FETCH_TIMEOUT_MS, HOOK_TIMEOUT_MS, KvRequestSchema, MAX_GLOB_PATTERN_LENGTH, MAX_HTML_BYTES, MAX_PAGE_CHARS, MAX_TOOL_RESULT_CHARS, MAX_VALUE_SIZE, RUN_CODE_TIMEOUT_MS, ReadyConfigSchema, ServerMessageSchema, SessionErrorCodeSchema, TOOL_EXECUTION_TIMEOUT_MS, ToolChoiceSchema, ToolSchemaSchema, TurnConfigSchema, _internals, agentToolsToSchemas, buildCtx, buildReadyConfig, buildSystemPrompt, callResolveTurnConfig, connectS2s, consoleLogger, createAgentHooks, createRuntime, createS2sSession, createUnstorageKv, defaultCreateS2sWebSocket, defineAgent, defineTool, defineTool as tool, defineToolFactory, errorDetail, errorMessage, executeToolCall, jsonLogger, matchGlob, memoryTools, sortAndPaginate, testRuntime, toAgentConfig, toolError, wireSessionSocket };
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* {@link createServer} wraps a {@link Runtime} with an HTTP + WebSocket
|
|
5
5
|
* server using only `node:http` and `ws` (no framework dependencies).
|
|
6
6
|
*/
|
|
7
|
+
import type { Kv } from "../isolate/kv.ts";
|
|
7
8
|
import type { Runtime } from "./direct-executor.ts";
|
|
8
|
-
import type { Kv } from "./kv.ts";
|
|
9
9
|
import type { Logger } from "./runtime.ts";
|
|
10
10
|
export { createRuntime, type Runtime, type RuntimeOptions } from "./direct-executor.ts";
|
|
11
11
|
/**
|
|
@@ -29,20 +29,4 @@ export type AgentServer = {
|
|
|
29
29
|
close(): Promise<void>;
|
|
30
30
|
port: number | undefined;
|
|
31
31
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Create an HTTP + WebSocket server for self-hosted agent deployments.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* import { defineAgent } from "@alexkroman1/aai";
|
|
38
|
-
* import { createRuntime, createServer } from "@alexkroman1/aai/server";
|
|
39
|
-
*
|
|
40
|
-
* const agent = defineAgent({ name: "my-agent" });
|
|
41
|
-
* const runtime = createRuntime({ agent, env: process.env });
|
|
42
|
-
* const server = createServer({ runtime, name: agent.name });
|
|
43
|
-
* await server.listen(3000);
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
32
|
export declare function createServer(options: ServerOptions): AgentServer;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as AGENT_CSP } from "
|
|
2
|
-
import {
|
|
1
|
+
import { t as AGENT_CSP } from "../constants-CpLN9WGY.js";
|
|
2
|
+
import { d as consoleLogger, t as createRuntime } from "../direct-executor-DyY-Y4ZE.js";
|
|
3
|
+
import { WebSocketServer } from "ws";
|
|
3
4
|
import fs from "node:fs";
|
|
4
5
|
import http from "node:http";
|
|
5
6
|
import path from "node:path";
|
|
6
|
-
|
|
7
|
-
//#region server.ts
|
|
7
|
+
//#region host/server.ts
|
|
8
8
|
/**
|
|
9
9
|
* Self-hostable agent server.
|
|
10
10
|
*
|
|
@@ -59,6 +59,26 @@ function serveStatic(dir, req, res) {
|
|
|
59
59
|
*
|
|
60
60
|
* @public
|
|
61
61
|
*/
|
|
62
|
+
function handleKvGet(kv, req, res) {
|
|
63
|
+
const key = new URL(req.url ?? "/", "http://localhost").searchParams.get("key");
|
|
64
|
+
if (!key) {
|
|
65
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
66
|
+
res.end(JSON.stringify({ error: "Missing key query parameter" }));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
kv.get(key).then((value) => {
|
|
70
|
+
if (value === null) {
|
|
71
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
72
|
+
res.end("null");
|
|
73
|
+
} else {
|
|
74
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
75
|
+
res.end(JSON.stringify(value));
|
|
76
|
+
}
|
|
77
|
+
}).catch(() => {
|
|
78
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
79
|
+
res.end(JSON.stringify({ error: "KV error" }));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
62
82
|
function createServer(options) {
|
|
63
83
|
const { runtime, clientHtml, clientDir, logger = consoleLogger, kv } = options;
|
|
64
84
|
const name = options.name ?? "agent";
|
|
@@ -78,24 +98,7 @@ function createServer(options) {
|
|
|
78
98
|
return;
|
|
79
99
|
}
|
|
80
100
|
if (kv && method === "GET" && url === "/kv") {
|
|
81
|
-
|
|
82
|
-
if (!key) {
|
|
83
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
84
|
-
res.end(JSON.stringify({ error: "Missing key query parameter" }));
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
kv.get(key).then((value) => {
|
|
88
|
-
if (value === null) {
|
|
89
|
-
res.writeHead(404, { "Content-Type": "application/json" });
|
|
90
|
-
res.end("null");
|
|
91
|
-
} else {
|
|
92
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
93
|
-
res.end(JSON.stringify(value));
|
|
94
|
-
}
|
|
95
|
-
}).catch(() => {
|
|
96
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
97
|
-
res.end(JSON.stringify({ error: "KV error" }));
|
|
98
|
-
});
|
|
101
|
+
handleKvGet(kv, req, res);
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
101
104
|
if (clientDir && serveStatic(clientDir, req, res)) return;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** S2S session — relays audio between client and AssemblyAI S2S API. */
|
|
2
|
-
import type { AgentConfig, ExecuteTool, ToolSchema } from "
|
|
3
|
-
import type { AgentHookMap, AgentHooks } from "
|
|
4
|
-
import type { ClientSink } from "
|
|
2
|
+
import type { AgentConfig, ExecuteTool, ToolSchema } from "../isolate/_internal-types.ts";
|
|
3
|
+
import type { AgentHookMap, AgentHooks } from "../isolate/hooks.ts";
|
|
4
|
+
import type { ClientSink } from "../isolate/protocol.ts";
|
|
5
|
+
import type { Message } from "../isolate/types.ts";
|
|
5
6
|
import type { Logger, S2SConfig } from "./runtime.ts";
|
|
6
7
|
import { type CreateS2sWebSocket, connectS2s, type S2sHandle } from "./s2s.ts";
|
|
7
|
-
import type { Message } from "./types.ts";
|
|
8
8
|
export type { S2sHandle } from "./s2s.ts";
|
|
9
9
|
type PendingTool = {
|
|
10
10
|
callId: string;
|
|
@@ -63,9 +63,9 @@ export declare function buildCtx(opts: {
|
|
|
63
63
|
log: Logger;
|
|
64
64
|
maxHistory?: number | undefined;
|
|
65
65
|
}): S2sSessionCtx;
|
|
66
|
-
export type { AgentHookMap, AgentHooks } from "
|
|
67
|
-
export { callResolveTurnConfig, createAgentHooks } from "
|
|
68
|
-
export { buildSystemPrompt } from "
|
|
66
|
+
export type { AgentHookMap, AgentHooks } from "../isolate/hooks.ts";
|
|
67
|
+
export { callResolveTurnConfig, createAgentHooks } from "../isolate/hooks.ts";
|
|
68
|
+
export { buildSystemPrompt } from "../isolate/system-prompt.ts";
|
|
69
69
|
/**
|
|
70
70
|
* A voice session managing the Speech-to-Speech connection for one client.
|
|
71
71
|
*
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
*
|
|
36
36
|
* @packageDocumentation
|
|
37
37
|
*/
|
|
38
|
+
import type { Kv } from "../isolate/kv.ts";
|
|
39
|
+
import type { AgentDef, Message } from "../isolate/types.ts";
|
|
38
40
|
import { type Runtime } from "./direct-executor.ts";
|
|
39
|
-
import type { Kv } from "./kv.ts";
|
|
40
|
-
import type { AgentDef, Message } from "./types.ts";
|
|
41
41
|
export { installMockWebSocket, MockWebSocket } from "./_mock-ws.ts";
|
|
42
42
|
export { flush, makeStubSession } from "./_test-utils.ts";
|
|
43
43
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as makeStubSession, i as flush, n as TurnResult, o as MockWebSocket, r as createTestHarness, s as installMockWebSocket, t as TestHarness } from "
|
|
1
|
+
import { a as makeStubSession, i as flush, n as TurnResult, o as MockWebSocket, r as createTestHarness, s as installMockWebSocket, t as TestHarness } from "../testing-CNNg2-n-.js";
|
|
2
2
|
export { MockWebSocket, TestHarness, TurnResult, createTestHarness, flush, installMockWebSocket, makeStubSession };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Audio validation is handled at the host transport layer (see server.ts).
|
|
5
5
|
*/
|
|
6
|
-
import type { ClientSink, ReadyConfig } from "
|
|
6
|
+
import type { ClientSink, ReadyConfig } from "../isolate/protocol.ts";
|
|
7
7
|
import type { Logger } from "./runtime.ts";
|
|
8
8
|
import type { Session } from "./session.ts";
|
|
9
9
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
* });
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export type { Kv, KvEntry, KvListOptions } from "./kv.ts";
|
|
23
|
-
export { type AgentDef, type AgentOptions, type BuiltinTool, defineAgent, defineTool, defineToolFactory, type HookContext, type Message, type ToolChoice, type ToolContext, type ToolDef, type ToolResultMap, tool, } from "./types.ts";
|
|
22
|
+
export type { Kv, KvEntry, KvListOptions } from "./isolate/kv.ts";
|
|
23
|
+
export { type AgentDef, type AgentOptions, type BuiltinTool, defineAgent, defineTool, defineToolFactory, type HookContext, type Message, type ToolChoice, type ToolContext, type ToolDef, type ToolResultMap, tool, } from "./isolate/types.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { defineAgent, defineTool, defineToolFactory } from "./types.js";
|
|
1
|
+
import { defineAgent, defineTool, defineToolFactory } from "./isolate/types.js";
|
|
2
2
|
export { defineAgent, defineTool, defineTool as tool, defineToolFactory };
|
|
@@ -3,7 +3,5 @@
|
|
|
3
3
|
export declare function errorMessage(err: unknown): string;
|
|
4
4
|
/** Extract a detailed error string (message + stack) for diagnostic logging. */
|
|
5
5
|
export declare function errorDetail(err: unknown): string;
|
|
6
|
-
/** Check whether a filesystem operation is a read-only operation. */
|
|
7
|
-
export declare function isReadOnlyFsOp(op: string): boolean;
|
|
8
6
|
/** Return a JSON error string for the LLM: `'{"error":"<message>"}'`. */
|
|
9
7
|
export declare function toolError(message: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region _utils.ts
|
|
1
|
+
//#region isolate/_utils.ts
|
|
2
2
|
/** Shared utility functions. */
|
|
3
3
|
/** Extract an error message from an unknown thrown value. */
|
|
4
4
|
function errorMessage(err) {
|
|
@@ -9,20 +9,9 @@ function errorDetail(err) {
|
|
|
9
9
|
if (err instanceof Error) return err.stack ?? err.message;
|
|
10
10
|
return String(err);
|
|
11
11
|
}
|
|
12
|
-
/** Set of filesystem operations that are safe for read-only access. */
|
|
13
|
-
const READ_ONLY_FS_OPS = new Set([
|
|
14
|
-
"read",
|
|
15
|
-
"stat",
|
|
16
|
-
"readdir",
|
|
17
|
-
"exists"
|
|
18
|
-
]);
|
|
19
|
-
/** Check whether a filesystem operation is a read-only operation. */
|
|
20
|
-
function isReadOnlyFsOp(op) {
|
|
21
|
-
return READ_ONLY_FS_OPS.has(op);
|
|
22
|
-
}
|
|
23
12
|
/** Return a JSON error string for the LLM: `'{"error":"<message>"}'`. */
|
|
24
13
|
function toolError(message) {
|
|
25
14
|
return JSON.stringify({ error: message });
|
|
26
15
|
}
|
|
27
16
|
//#endregion
|
|
28
|
-
export { errorDetail, errorMessage,
|
|
17
|
+
export { errorDetail, errorMessage, toolError };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Isolate-safe barrel — re-exports all SDK modules that are guaranteed to
|
|
3
|
+
* run inside secure-exec V8 isolates (no `node:*` dependencies).
|
|
4
|
+
*
|
|
5
|
+
* This directory is compiled under a restricted `tsconfig.json` that excludes
|
|
6
|
+
* `@types/node`. Any accidental `node:*` import becomes a type error.
|
|
7
|
+
*
|
|
8
|
+
* Host-only code (server, executor, S2S, etc.) lives at the package root
|
|
9
|
+
* and is re-exported via `./host`.
|
|
10
|
+
*/
|
|
11
|
+
export * from "./_internal-types.ts";
|
|
12
|
+
export * from "./_utils.ts";
|
|
13
|
+
export * from "./constants.ts";
|
|
14
|
+
export * from "./hooks.ts";
|
|
15
|
+
export * from "./kv.ts";
|
|
16
|
+
export * from "./memory-tools.ts";
|
|
17
|
+
export * from "./protocol.ts";
|
|
18
|
+
export * from "./system-prompt.ts";
|
|
19
|
+
export * from "./types.ts";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BuiltinToolSchema, DEFAULT_GREETING, DEFAULT_INSTRUCTIONS, ToolChoiceSchema, defineAgent, defineTool, defineToolFactory } from "./types.js";
|
|
2
|
+
import { a as ToolSchemaSchema, i as EMPTY_PARAMS, n as memoryTools, o as agentToolsToSchemas, r as AgentConfigSchema, s as toAgentConfig, t as buildSystemPrompt } from "../system-prompt-u19j6xfA.js";
|
|
3
|
+
import { errorDetail, errorMessage, toolError } from "./_utils.js";
|
|
4
|
+
import { a as DEFAULT_SHUTDOWN_TIMEOUT_MS, c as FETCH_TIMEOUT_MS, d as MAX_HTML_BYTES, f as MAX_PAGE_CHARS, g as TOOL_EXECUTION_TIMEOUT_MS, h as RUN_CODE_TIMEOUT_MS, i as DEFAULT_SESSION_START_TIMEOUT_MS, l as HOOK_TIMEOUT_MS, m as MAX_VALUE_SIZE, n as DEFAULT_IDLE_TIMEOUT_MS, o as DEFAULT_STT_SAMPLE_RATE, p as MAX_TOOL_RESULT_CHARS, r as DEFAULT_MAX_HISTORY, s as DEFAULT_TTS_SAMPLE_RATE, t as AGENT_CSP, u as MAX_GLOB_PATTERN_LENGTH } from "../constants-CpLN9WGY.js";
|
|
5
|
+
import { callResolveTurnConfig, createAgentHooks } from "./hooks.js";
|
|
6
|
+
import { matchGlob, sortAndPaginate } from "./kv.js";
|
|
7
|
+
import { AUDIO_FORMAT, ClientEventSchema, ClientMessageSchema, KvRequestSchema, ReadyConfigSchema, ServerMessageSchema, SessionErrorCodeSchema, TurnConfigSchema, buildReadyConfig } from "./protocol.js";
|
|
8
|
+
export { AGENT_CSP, AUDIO_FORMAT, AgentConfigSchema, BuiltinToolSchema, ClientEventSchema, ClientMessageSchema, DEFAULT_GREETING, DEFAULT_IDLE_TIMEOUT_MS, DEFAULT_INSTRUCTIONS, DEFAULT_MAX_HISTORY, DEFAULT_SESSION_START_TIMEOUT_MS, DEFAULT_SHUTDOWN_TIMEOUT_MS, DEFAULT_STT_SAMPLE_RATE, DEFAULT_TTS_SAMPLE_RATE, EMPTY_PARAMS, FETCH_TIMEOUT_MS, HOOK_TIMEOUT_MS, KvRequestSchema, MAX_GLOB_PATTERN_LENGTH, MAX_HTML_BYTES, MAX_PAGE_CHARS, MAX_TOOL_RESULT_CHARS, MAX_VALUE_SIZE, RUN_CODE_TIMEOUT_MS, ReadyConfigSchema, ServerMessageSchema, SessionErrorCodeSchema, TOOL_EXECUTION_TIMEOUT_MS, ToolChoiceSchema, ToolSchemaSchema, TurnConfigSchema, agentToolsToSchemas, buildReadyConfig, buildSystemPrompt, callResolveTurnConfig, createAgentHooks, defineAgent, defineTool, defineTool as tool, defineToolFactory, errorDetail, errorMessage, matchGlob, memoryTools, sortAndPaginate, toAgentConfig, toolError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as MAX_VALUE_SIZE, u as MAX_GLOB_PATTERN_LENGTH } from "
|
|
2
|
-
//#region kv.ts
|
|
1
|
+
import { m as MAX_VALUE_SIZE, u as MAX_GLOB_PATTERN_LENGTH } from "../constants-CpLN9WGY.js";
|
|
2
|
+
//#region isolate/kv.ts
|
|
3
3
|
/**
|
|
4
4
|
* Key-value storage interface and shared utilities.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as MAX_TOOL_RESULT_CHARS } from "
|
|
1
|
+
import { p as MAX_TOOL_RESULT_CHARS } from "../constants-CpLN9WGY.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
//#region protocol.ts
|
|
3
|
+
//#region isolate/protocol.ts
|
|
4
4
|
/**
|
|
5
5
|
* WebSocket wire-format types shared by server and client.
|
|
6
6
|
*
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { BuiltinToolSchema, DEFAULT_INSTRUCTIONS, ToolChoiceSchema, defineTool } from "./isolate/types.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region isolate/_internal-types.ts
|
|
4
|
+
/**
|
|
5
|
+
* Zod schema for serializable agent configuration sent over the wire.
|
|
6
|
+
*
|
|
7
|
+
* This is the JSON-safe subset of the agent definition that can be
|
|
8
|
+
* transmitted between the worker and the host process via structured clone.
|
|
9
|
+
*/
|
|
10
|
+
const AgentConfigSchema = z.object({
|
|
11
|
+
name: z.string().min(1),
|
|
12
|
+
instructions: z.string(),
|
|
13
|
+
greeting: z.string(),
|
|
14
|
+
sttPrompt: z.string().optional(),
|
|
15
|
+
maxSteps: z.number().int().positive().optional(),
|
|
16
|
+
toolChoice: ToolChoiceSchema.optional(),
|
|
17
|
+
builtinTools: z.array(BuiltinToolSchema).readonly().optional(),
|
|
18
|
+
idleTimeoutMs: z.number().nonnegative().optional()
|
|
19
|
+
});
|
|
20
|
+
/** Extract the serializable {@link AgentConfig} subset from a source object. */
|
|
21
|
+
function toAgentConfig(src) {
|
|
22
|
+
const config = {
|
|
23
|
+
name: src.name,
|
|
24
|
+
instructions: src.instructions,
|
|
25
|
+
greeting: src.greeting
|
|
26
|
+
};
|
|
27
|
+
if (src.sttPrompt !== void 0) config.sttPrompt = src.sttPrompt;
|
|
28
|
+
if (typeof src.maxSteps !== "function" && src.maxSteps !== void 0) config.maxSteps = src.maxSteps;
|
|
29
|
+
if (src.toolChoice !== void 0) config.toolChoice = src.toolChoice;
|
|
30
|
+
if (src.builtinTools) config.builtinTools = [...src.builtinTools];
|
|
31
|
+
if (src.idleTimeoutMs !== void 0) config.idleTimeoutMs = src.idleTimeoutMs;
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Zod schema for serialized tool definitions sent over the wire.
|
|
36
|
+
*
|
|
37
|
+
* `parameters` must be a valid JSON Schema object (with `type`, `properties`,
|
|
38
|
+
* etc.) — the Vercel AI SDK wraps it via `jsonSchema()`.
|
|
39
|
+
*/
|
|
40
|
+
const ToolSchemaSchema = z.object({
|
|
41
|
+
name: z.string().min(1),
|
|
42
|
+
description: z.string().min(1),
|
|
43
|
+
parameters: z.record(z.string(), z.unknown())
|
|
44
|
+
});
|
|
45
|
+
/** Empty Zod object schema used as default when tools have no parameters. */
|
|
46
|
+
const EMPTY_PARAMS = z.object({});
|
|
47
|
+
/**
|
|
48
|
+
* Convert agent tool definitions to JSON Schema format for wire transport.
|
|
49
|
+
*
|
|
50
|
+
* Transforms the Zod-based `parameters` of each tool into a plain JSON Schema
|
|
51
|
+
* object suitable for structured clone / JSON serialization.
|
|
52
|
+
*/
|
|
53
|
+
function agentToolsToSchemas(tools) {
|
|
54
|
+
return Object.entries(tools).map(([name, def]) => ({
|
|
55
|
+
name,
|
|
56
|
+
description: def.description,
|
|
57
|
+
parameters: z.toJSONSchema(def.parameters ?? EMPTY_PARAMS)
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region isolate/memory-tools.ts
|
|
62
|
+
/**
|
|
63
|
+
* KV-backed memory tools for agent persistent state.
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* Returns a standard set of KV-backed memory tools: `save_memory`,
|
|
67
|
+
* `recall_memory`, `list_memories`, and `forget_memory`.
|
|
68
|
+
*
|
|
69
|
+
* Spread the result into your agent's `tools` record.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { defineAgent, memoryTools } from "aai";
|
|
74
|
+
*
|
|
75
|
+
* export default defineAgent({
|
|
76
|
+
* name: "My Agent",
|
|
77
|
+
* tools: { ...memoryTools() },
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @returns A record with four tool definitions: `save_memory`, `recall_memory`,
|
|
82
|
+
* `list_memories`, and `forget_memory`.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
function memoryTools() {
|
|
86
|
+
return {
|
|
87
|
+
save_memory: defineTool({
|
|
88
|
+
description: "Save a piece of information to persistent memory. Use a descriptive key like 'user:name' or 'project:status'.",
|
|
89
|
+
parameters: z.object({
|
|
90
|
+
key: z.string().describe("A descriptive key for this memory (e.g. 'user:name', 'preference:color')"),
|
|
91
|
+
value: z.string().describe("The information to remember")
|
|
92
|
+
}),
|
|
93
|
+
execute: async ({ key, value }, ctx) => {
|
|
94
|
+
await ctx.kv.set(key, value);
|
|
95
|
+
return { saved: key };
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
recall_memory: defineTool({
|
|
99
|
+
description: "Retrieve a previously saved memory by its key.",
|
|
100
|
+
parameters: z.object({ key: z.string().describe("The key to look up") }),
|
|
101
|
+
execute: async ({ key }, ctx) => {
|
|
102
|
+
const value = await ctx.kv.get(key);
|
|
103
|
+
if (value === null) return {
|
|
104
|
+
found: false,
|
|
105
|
+
key
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
found: true,
|
|
109
|
+
key,
|
|
110
|
+
value
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
list_memories: defineTool({
|
|
115
|
+
description: "List all saved memory keys, optionally filtered by a prefix (e.g. 'user:').",
|
|
116
|
+
parameters: z.object({ prefix: z.string().describe("Prefix to filter keys (e.g. 'user:'). Use empty string for all.").optional() }),
|
|
117
|
+
execute: async ({ prefix }, ctx) => {
|
|
118
|
+
const entries = await ctx.kv.list(prefix ?? "");
|
|
119
|
+
return {
|
|
120
|
+
count: entries.length,
|
|
121
|
+
keys: entries.map((e) => e.key)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
forget_memory: defineTool({
|
|
126
|
+
description: "Delete a previously saved memory by its key.",
|
|
127
|
+
parameters: z.object({ key: z.string().describe("The key to delete") }),
|
|
128
|
+
execute: async ({ key }, ctx) => {
|
|
129
|
+
await ctx.kv.delete(key);
|
|
130
|
+
return { deleted: key };
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region isolate/system-prompt.ts
|
|
137
|
+
function getFormattedDate() {
|
|
138
|
+
return (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
139
|
+
weekday: "long",
|
|
140
|
+
year: "numeric",
|
|
141
|
+
month: "long",
|
|
142
|
+
day: "numeric"
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const VOICE_RULES = "\n\nCRITICAL OUTPUT RULES — you MUST follow these for EVERY response:\nYour response will be spoken aloud by a TTS system and displayed as plain text.\n- NEVER use markdown: no **, no *, no _, no #, no `, no [](), no ---\n- NEVER use bullet points (-, *, •) or numbered lists (1., 2.)\n- NEVER use code blocks or inline code\n- NEVER mention tools, search, APIs, or technical failures to the user. If a tool returns no results, just answer naturally without explaining why.\n- Write exactly as you would say it out loud to a friend\n- Use short conversational sentences. To list things, say \"First,\" \"Next,\" \"Finally,\"\n- Keep responses concise — 1 to 3 sentences max";
|
|
146
|
+
/**
|
|
147
|
+
* Build the system prompt sent to the LLM from the agent configuration.
|
|
148
|
+
*
|
|
149
|
+
* Assembles the default instructions, today's date, agent-specific instructions,
|
|
150
|
+
* and optional sections for tool usage preamble and voice output rules.
|
|
151
|
+
*
|
|
152
|
+
* @param config - The serializable agent configuration (name, instructions, etc.).
|
|
153
|
+
* @param opts.hasTools - When `true`, appends a preamble instructing the LLM to
|
|
154
|
+
* speak a brief phrase before each tool call to fill silence.
|
|
155
|
+
* @param opts.voice - When `true`, appends strict voice-specific output rules
|
|
156
|
+
* (no markdown, no bullet points, conversational tone, concise responses).
|
|
157
|
+
* @returns The assembled system prompt string.
|
|
158
|
+
*/
|
|
159
|
+
function buildSystemPrompt(config, opts) {
|
|
160
|
+
const { hasTools } = opts;
|
|
161
|
+
const agentInstructions = config.instructions && config.instructions !== DEFAULT_INSTRUCTIONS ? `\n\nAgent-Specific Instructions:\n${config.instructions}` : "";
|
|
162
|
+
const toolPreamble = hasTools ? "\n\nWhen you decide to use a tool, ALWAYS say a brief natural phrase BEFORE the tool call (e.g. \"Let me look that up\" or \"One moment while I check\"). This fills silence while the tool executes. Keep preambles to one short sentence." : "";
|
|
163
|
+
return DEFAULT_INSTRUCTIONS + `\n\nToday's date is ${getFormattedDate()}.` + agentInstructions + toolPreamble + (opts.voice ? VOICE_RULES : "");
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { ToolSchemaSchema as a, EMPTY_PARAMS as i, memoryTools as n, agentToolsToSchemas as o, AgentConfigSchema as r, toAgentConfig as s, buildSystemPrompt as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./types.js";
|
|
2
|
-
import { i as createUnstorageKv, t as createRuntime } from "./direct-executor-
|
|
3
|
-
import {
|
|
1
|
+
import "./isolate/types.js";
|
|
2
|
+
import { i as createUnstorageKv, t as createRuntime } from "./direct-executor-DyY-Y4ZE.js";
|
|
3
|
+
import { vi } from "vitest";
|
|
4
4
|
import { createStorage } from "unstorage";
|
|
5
5
|
import "nanoevents";
|
|
6
|
-
import {
|
|
7
|
-
//#region _mock-ws.ts
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
//#region host/_mock-ws.ts
|
|
8
8
|
/**
|
|
9
9
|
* A mock WebSocket implementation for testing.
|
|
10
10
|
*
|
|
@@ -157,7 +157,7 @@ function installMockWebSocket() {
|
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
//#endregion
|
|
160
|
-
//#region _test-utils.ts
|
|
160
|
+
//#region host/_test-utils.ts
|
|
161
161
|
/** Yield to the microtask queue so pending promises settle. */
|
|
162
162
|
function flush() {
|
|
163
163
|
return new Promise((r) => queueMicrotask(r));
|
|
@@ -179,7 +179,7 @@ function makeStubSession(overrides) {
|
|
|
179
179
|
vi.fn(), vi.fn(), vi.fn(), vi.fn();
|
|
180
180
|
resolve(import.meta.dirname, "__fixtures__");
|
|
181
181
|
//#endregion
|
|
182
|
-
//#region testing.ts
|
|
182
|
+
//#region host/testing.ts
|
|
183
183
|
/**
|
|
184
184
|
* Testing utilities for AAI agents.
|
|
185
185
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexkroman1/aai",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -11,55 +11,60 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./isolate": {
|
|
15
|
+
"@dev/source": "./isolate/index.ts",
|
|
16
|
+
"types": "./dist/isolate/index.d.ts",
|
|
17
|
+
"import": "./dist/isolate/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./host": {
|
|
20
|
+
"@dev/source": "./host/index.ts",
|
|
21
|
+
"types": "./dist/host/index.d.ts",
|
|
22
|
+
"import": "./dist/host/index.js"
|
|
23
|
+
},
|
|
14
24
|
"./server": {
|
|
15
|
-
"@dev/source": "./server.ts",
|
|
16
|
-
"types": "./dist/server.d.ts",
|
|
17
|
-
"import": "./dist/server.js"
|
|
25
|
+
"@dev/source": "./host/server.ts",
|
|
26
|
+
"types": "./dist/host/server.d.ts",
|
|
27
|
+
"import": "./dist/host/server.js"
|
|
18
28
|
},
|
|
19
29
|
"./types": {
|
|
20
|
-
"@dev/source": "./types.ts",
|
|
21
|
-
"types": "./dist/types.d.ts",
|
|
22
|
-
"import": "./dist/types.js"
|
|
30
|
+
"@dev/source": "./isolate/types.ts",
|
|
31
|
+
"types": "./dist/isolate/types.d.ts",
|
|
32
|
+
"import": "./dist/isolate/types.js"
|
|
23
33
|
},
|
|
24
34
|
"./kv": {
|
|
25
|
-
"@dev/source": "./kv.ts",
|
|
26
|
-
"types": "./dist/kv.d.ts",
|
|
27
|
-
"import": "./dist/kv.js"
|
|
35
|
+
"@dev/source": "./isolate/kv.ts",
|
|
36
|
+
"types": "./dist/isolate/kv.d.ts",
|
|
37
|
+
"import": "./dist/isolate/kv.js"
|
|
28
38
|
},
|
|
29
39
|
"./protocol": {
|
|
30
|
-
"@dev/source": "./protocol.ts",
|
|
31
|
-
"types": "./dist/protocol.d.ts",
|
|
32
|
-
"import": "./dist/protocol.js"
|
|
40
|
+
"@dev/source": "./isolate/protocol.ts",
|
|
41
|
+
"types": "./dist/isolate/protocol.d.ts",
|
|
42
|
+
"import": "./dist/isolate/protocol.js"
|
|
33
43
|
},
|
|
34
44
|
"./testing": {
|
|
35
|
-
"@dev/source": "./testing.ts",
|
|
36
|
-
"types": "./dist/testing.d.ts",
|
|
37
|
-
"import": "./dist/testing.js"
|
|
45
|
+
"@dev/source": "./host/testing.ts",
|
|
46
|
+
"types": "./dist/host/testing.d.ts",
|
|
47
|
+
"import": "./dist/host/testing.js"
|
|
38
48
|
},
|
|
39
49
|
"./testing/matchers": {
|
|
40
|
-
"@dev/source": "./matchers.ts",
|
|
41
|
-
"types": "./dist/matchers.d.ts",
|
|
42
|
-
"import": "./dist/matchers.js"
|
|
43
|
-
},
|
|
44
|
-
"./internal": {
|
|
45
|
-
"@dev/source": "./internal.ts",
|
|
46
|
-
"types": "./dist/internal.d.ts",
|
|
47
|
-
"import": "./dist/internal.js"
|
|
50
|
+
"@dev/source": "./host/matchers.ts",
|
|
51
|
+
"types": "./dist/host/matchers.d.ts",
|
|
52
|
+
"import": "./dist/host/matchers.js"
|
|
48
53
|
},
|
|
49
54
|
"./hooks": {
|
|
50
|
-
"@dev/source": "./hooks.ts",
|
|
51
|
-
"types": "./dist/hooks.d.ts",
|
|
52
|
-
"import": "./dist/hooks.js"
|
|
55
|
+
"@dev/source": "./isolate/hooks.ts",
|
|
56
|
+
"types": "./dist/isolate/hooks.d.ts",
|
|
57
|
+
"import": "./dist/isolate/hooks.js"
|
|
53
58
|
},
|
|
54
59
|
"./utils": {
|
|
55
|
-
"@dev/source": "./_utils.ts",
|
|
56
|
-
"types": "./dist/_utils.d.ts",
|
|
57
|
-
"import": "./dist/_utils.js"
|
|
60
|
+
"@dev/source": "./isolate/_utils.ts",
|
|
61
|
+
"types": "./dist/isolate/_utils.d.ts",
|
|
62
|
+
"import": "./dist/isolate/_utils.js"
|
|
58
63
|
},
|
|
59
64
|
"./vite-plugin": {
|
|
60
|
-
"@dev/source": "./vite-plugin.ts",
|
|
61
|
-
"types": "./dist/vite-plugin.d.ts",
|
|
62
|
-
"import": "./dist/vite-plugin.js"
|
|
65
|
+
"@dev/source": "./host/vite-plugin.ts",
|
|
66
|
+
"types": "./dist/host/vite-plugin.d.ts",
|
|
67
|
+
"import": "./dist/host/vite-plugin.js"
|
|
63
68
|
}
|
|
64
69
|
},
|
|
65
70
|
"dependencies": {
|
|
@@ -95,7 +100,7 @@
|
|
|
95
100
|
},
|
|
96
101
|
"scripts": {
|
|
97
102
|
"build": "tsdown && tsc -p tsconfig.build.json",
|
|
98
|
-
"typecheck": "tsc --noEmit",
|
|
103
|
+
"typecheck": "tsc --noEmit && tsc -p isolate/tsconfig.json",
|
|
99
104
|
"lint": "biome check .",
|
|
100
105
|
"check:publint": "publint",
|
|
101
106
|
"check:attw": "attw --pack --profile esm-only"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -39,11 +39,11 @@ export type KvRequest = z.infer<typeof KvRequestSchema>;
|
|
|
39
39
|
*/
|
|
40
40
|
export declare const SessionErrorCodeSchema: z.ZodEnum<{
|
|
41
41
|
tool: "tool";
|
|
42
|
-
connection: "connection";
|
|
43
42
|
stt: "stt";
|
|
44
43
|
llm: "llm";
|
|
45
44
|
tts: "tts";
|
|
46
45
|
protocol: "protocol";
|
|
46
|
+
connection: "connection";
|
|
47
47
|
audio: "audio";
|
|
48
48
|
internal: "internal";
|
|
49
49
|
}>;
|
|
@@ -94,11 +94,11 @@ export declare const ClientEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
94
94
|
type: z.ZodLiteral<"error">;
|
|
95
95
|
code: z.ZodEnum<{
|
|
96
96
|
tool: "tool";
|
|
97
|
-
connection: "connection";
|
|
98
97
|
stt: "stt";
|
|
99
98
|
llm: "llm";
|
|
100
99
|
tts: "tts";
|
|
101
100
|
protocol: "protocol";
|
|
101
|
+
connection: "connection";
|
|
102
102
|
audio: "audio";
|
|
103
103
|
internal: "internal";
|
|
104
104
|
}>;
|
|
@@ -182,11 +182,11 @@ export declare const ServerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
182
182
|
type: z.ZodLiteral<"error">;
|
|
183
183
|
code: z.ZodEnum<{
|
|
184
184
|
tool: "tool";
|
|
185
|
-
connection: "connection";
|
|
186
185
|
stt: "stt";
|
|
187
186
|
llm: "llm";
|
|
188
187
|
tts: "tts";
|
|
189
188
|
protocol: "protocol";
|
|
189
|
+
connection: "connection";
|
|
190
190
|
audio: "audio";
|
|
191
191
|
internal: "internal";
|
|
192
192
|
}>;
|
|
File without changes
|
|
File without changes
|