@alexkroman1/aai 0.11.0 → 0.12.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/dist/{direct-executor-DAGCZOAN.js → direct-executor-ZUU0Ke4j.js} +146 -276
- 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} +2 -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} +10 -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} +37 -28
- 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} +2 -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/{_internal-types.d.ts → isolate/_internal-types.d.ts} +0 -1
- package/dist/isolate/_kv-utils.d.ts +10 -0
- 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 +18 -0
- package/dist/isolate/index.js +6 -0
- package/dist/{kv.d.ts → isolate/kv.d.ts} +0 -10
- package/dist/isolate/kv.js +1 -0
- package/dist/isolate/protocol.js +2 -0
- package/dist/{types.d.ts → isolate/types.d.ts} +1 -2
- package/dist/{types.js → isolate/types.js} +2 -3
- package/dist/{protocol.js → protocol-rcOrz7T3.js} +46 -3
- package/dist/system-prompt-CVJSQJiA.js +91 -0
- package/dist/{testing-Dmx-dudh.js → testing-Bb2B5Uob.js} +7 -7
- package/package.json +39 -34
- package/dist/constants-CwotjpJR.js +0 -45
- package/dist/kv.js +0 -33
- package/dist/memory-tools.d.ts +0 -39
- 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/{constants.d.ts → isolate/constants.d.ts} +0 -0
- package/dist/{hooks.d.ts → isolate/hooks.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexkroman1/aai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
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"
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//#region constants.ts
|
|
2
|
-
/**
|
|
3
|
-
* Centralised numeric constants — timeouts, size limits, sample rates.
|
|
4
|
-
*
|
|
5
|
-
* Every magic number that controls a timeout, buffer size, or threshold
|
|
6
|
-
* lives here so the values are discoverable in one place.
|
|
7
|
-
*/
|
|
8
|
-
/** Default sample rate for speech-to-text audio in Hz (AssemblyAI). */
|
|
9
|
-
const DEFAULT_STT_SAMPLE_RATE = 16e3;
|
|
10
|
-
/** Default sample rate for text-to-speech audio in Hz. */
|
|
11
|
-
const DEFAULT_TTS_SAMPLE_RATE = 24e3;
|
|
12
|
-
/** Default timeout for agent lifecycle hooks (onConnect, onTurn, etc). */
|
|
13
|
-
const HOOK_TIMEOUT_MS = 5e3;
|
|
14
|
-
/** Default timeout for tool execution in the worker. */
|
|
15
|
-
const TOOL_EXECUTION_TIMEOUT_MS = 3e4;
|
|
16
|
-
/** Timeout for session.start() (S2S connection setup). */
|
|
17
|
-
const DEFAULT_SESSION_START_TIMEOUT_MS = 1e4;
|
|
18
|
-
/** S2S session idle timeout before auto-close. */
|
|
19
|
-
const DEFAULT_IDLE_TIMEOUT_MS = 3e5;
|
|
20
|
-
/** Per-fetch timeout for network tools (web_search, visit_webpage, fetch_json). */
|
|
21
|
-
const FETCH_TIMEOUT_MS = 15e3;
|
|
22
|
-
/** Timeout for sandboxed run_code execution. */
|
|
23
|
-
const RUN_CODE_TIMEOUT_MS = 5e3;
|
|
24
|
-
/** Maximum time to wait for sessions to stop during graceful shutdown. */
|
|
25
|
-
const DEFAULT_SHUTDOWN_TIMEOUT_MS = 3e4;
|
|
26
|
-
/** Maximum length for tool result strings sent to clients. */
|
|
27
|
-
const MAX_TOOL_RESULT_CHARS = 4e3;
|
|
28
|
-
/** Maximum chars for webpage text after HTML-to-text conversion. */
|
|
29
|
-
const MAX_PAGE_CHARS = 1e4;
|
|
30
|
-
/** Maximum bytes to fetch from an HTML page before conversion. */
|
|
31
|
-
const MAX_HTML_BYTES = 2e5;
|
|
32
|
-
/** Maximum value size for KV store entries (bytes). */
|
|
33
|
-
const MAX_VALUE_SIZE = 65536;
|
|
34
|
-
/** Maximum glob pattern length to prevent ReDoS. */
|
|
35
|
-
const MAX_GLOB_PATTERN_LENGTH = 1024;
|
|
36
|
-
/** Maximum conversation messages to retain (sliding window). */
|
|
37
|
-
const DEFAULT_MAX_HISTORY = 200;
|
|
38
|
-
/**
|
|
39
|
-
* Content-Security-Policy applied to agent UI pages (both self-hosted and
|
|
40
|
-
* platform). Single source of truth — used by `secureHeaders` middleware
|
|
41
|
-
* and per-response CSP headers.
|
|
42
|
-
*/
|
|
43
|
-
const AGENT_CSP = "default-src 'self'; script-src 'self' 'unsafe-eval' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src 'self' wss: ws:; img-src 'self' data:; font-src 'self' https://fonts.gstatic.com; object-src 'none'; base-uri 'self'";
|
|
44
|
-
//#endregion
|
|
45
|
-
export { DEFAULT_SHUTDOWN_TIMEOUT_MS as a, FETCH_TIMEOUT_MS as c, MAX_HTML_BYTES as d, MAX_PAGE_CHARS as f, TOOL_EXECUTION_TIMEOUT_MS as g, RUN_CODE_TIMEOUT_MS as h, DEFAULT_SESSION_START_TIMEOUT_MS as i, HOOK_TIMEOUT_MS as l, MAX_VALUE_SIZE as m, DEFAULT_IDLE_TIMEOUT_MS as n, DEFAULT_STT_SAMPLE_RATE as o, MAX_TOOL_RESULT_CHARS as p, DEFAULT_MAX_HISTORY as r, DEFAULT_TTS_SAMPLE_RATE as s, AGENT_CSP as t, MAX_GLOB_PATTERN_LENGTH as u };
|
package/dist/kv.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { m as MAX_VALUE_SIZE, u as MAX_GLOB_PATTERN_LENGTH } from "./constants-CwotjpJR.js";
|
|
2
|
-
//#region kv.ts
|
|
3
|
-
/**
|
|
4
|
-
* Key-value storage interface and shared utilities.
|
|
5
|
-
*/
|
|
6
|
-
/** Sort entries by key and apply reverse/limit options. Mutates the array. */
|
|
7
|
-
function sortAndPaginate(entries, options) {
|
|
8
|
-
entries.sort((a, b) => a.key.localeCompare(b.key));
|
|
9
|
-
if (options?.reverse) entries.reverse();
|
|
10
|
-
if (options?.limit && options.limit > 0) entries.length = Math.min(entries.length, options.limit);
|
|
11
|
-
return entries;
|
|
12
|
-
}
|
|
13
|
-
/** Simple glob matcher — supports `*` as a wildcard for any characters. */
|
|
14
|
-
function matchGlob(key, pattern) {
|
|
15
|
-
if (pattern.length > 1024) throw new Error(`Glob pattern exceeds maximum length of ${MAX_GLOB_PATTERN_LENGTH}`);
|
|
16
|
-
const parts = pattern.split("*");
|
|
17
|
-
if (parts.length === 1) return key === pattern;
|
|
18
|
-
const first = parts[0];
|
|
19
|
-
if (!key.startsWith(first)) return false;
|
|
20
|
-
const last = parts.at(-1);
|
|
21
|
-
if (key.length < first.length + last.length) return false;
|
|
22
|
-
if (!key.endsWith(last)) return false;
|
|
23
|
-
let pos = first.length;
|
|
24
|
-
const end = key.length - last.length;
|
|
25
|
-
for (const part of parts.slice(1, -1)) {
|
|
26
|
-
const idx = key.indexOf(part, pos);
|
|
27
|
-
if (idx === -1 || idx > end) return false;
|
|
28
|
-
pos = idx + part.length;
|
|
29
|
-
}
|
|
30
|
-
return pos <= end;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { MAX_VALUE_SIZE, matchGlob, sortAndPaginate };
|
package/dist/memory-tools.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* KV-backed memory tools for agent persistent state.
|
|
3
|
-
*/
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
/**
|
|
6
|
-
* Returns a standard set of KV-backed memory tools: `save_memory`,
|
|
7
|
-
* `recall_memory`, `list_memories`, and `forget_memory`.
|
|
8
|
-
*
|
|
9
|
-
* Spread the result into your agent's `tools` record.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { defineAgent, memoryTools } from "aai";
|
|
14
|
-
*
|
|
15
|
-
* export default defineAgent({
|
|
16
|
-
* name: "My Agent",
|
|
17
|
-
* tools: { ...memoryTools() },
|
|
18
|
-
* });
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @returns A record with four tool definitions: `save_memory`, `recall_memory`,
|
|
22
|
-
* `list_memories`, and `forget_memory`.
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export declare function memoryTools(): {
|
|
26
|
-
save_memory: import("./types.ts").ToolDef<z.ZodObject<{
|
|
27
|
-
key: z.ZodString;
|
|
28
|
-
value: z.ZodString;
|
|
29
|
-
}, z.core.$strip>, Record<string, unknown>>;
|
|
30
|
-
recall_memory: import("./types.ts").ToolDef<z.ZodObject<{
|
|
31
|
-
key: z.ZodString;
|
|
32
|
-
}, z.core.$strip>, Record<string, unknown>>;
|
|
33
|
-
list_memories: import("./types.ts").ToolDef<z.ZodObject<{
|
|
34
|
-
prefix: z.ZodOptional<z.ZodString>;
|
|
35
|
-
}, z.core.$strip>, Record<string, unknown>>;
|
|
36
|
-
forget_memory: import("./types.ts").ToolDef<z.ZodObject<{
|
|
37
|
-
key: z.ZodString;
|
|
38
|
-
}, z.core.$strip>, Record<string, unknown>>;
|
|
39
|
-
};
|
|
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
|