@alexkroman1/aai 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/tsconfig.tsbuildinfo +1 -0
- package/dist/cli.js +1223 -1701
- package/dist/sdk/_mock_ws.js +2 -2
- package/dist/sdk/_mock_ws.js.map +1 -1
- package/dist/sdk/_render_check.d.ts.map +1 -1
- package/dist/sdk/_render_check.js +29 -2
- package/dist/sdk/_render_check.js.map +1 -1
- package/dist/sdk/_utils.d.ts +4 -0
- package/dist/sdk/_utils.d.ts.map +1 -0
- package/dist/sdk/_utils.js +7 -0
- package/dist/sdk/_utils.js.map +1 -0
- package/dist/sdk/builtin_tools.d.ts +35 -11
- package/dist/sdk/builtin_tools.d.ts.map +1 -1
- package/dist/sdk/builtin_tools.js +118 -76
- package/dist/sdk/builtin_tools.js.map +1 -1
- package/dist/sdk/capnweb.d.ts +76 -47
- package/dist/sdk/capnweb.d.ts.map +1 -1
- package/dist/sdk/capnweb.js +99 -242
- package/dist/sdk/capnweb.js.map +1 -1
- package/dist/sdk/direct_executor.d.ts.map +1 -1
- package/dist/sdk/direct_executor.js +0 -2
- package/dist/sdk/direct_executor.js.map +1 -1
- package/dist/sdk/host.d.ts +59 -0
- package/dist/sdk/host.d.ts.map +1 -0
- package/dist/sdk/host.js +131 -0
- package/dist/sdk/host.js.map +1 -0
- package/dist/sdk/mod.d.ts +2 -4
- package/dist/sdk/mod.d.ts.map +1 -1
- package/dist/sdk/mod.js +2 -3
- package/dist/sdk/mod.js.map +1 -1
- package/dist/sdk/protocol.d.ts +33 -135
- package/dist/sdk/protocol.d.ts.map +1 -1
- package/dist/sdk/protocol.js +49 -51
- package/dist/sdk/protocol.js.map +1 -1
- package/dist/sdk/runtime.d.ts +0 -1
- package/dist/sdk/runtime.d.ts.map +1 -1
- package/dist/sdk/runtime.js +5 -24
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/s2s.d.ts +14 -3
- package/dist/sdk/s2s.d.ts.map +1 -1
- package/dist/sdk/s2s.js +72 -113
- package/dist/sdk/s2s.js.map +1 -1
- package/dist/sdk/server.d.ts +1 -1
- package/dist/sdk/server.d.ts.map +1 -1
- package/dist/sdk/server.js +26 -10
- package/dist/sdk/server.js.map +1 -1
- package/dist/sdk/session.d.ts +5 -1
- package/dist/sdk/session.d.ts.map +1 -1
- package/dist/sdk/session.js +131 -137
- package/dist/sdk/session.js.map +1 -1
- package/dist/sdk/tsconfig.tsbuildinfo +1 -0
- package/dist/sdk/types.d.ts +30 -3
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/sdk/types.js +37 -0
- package/dist/sdk/types.js.map +1 -1
- package/dist/sdk/winterc_server.d.ts +0 -1
- package/dist/sdk/winterc_server.d.ts.map +1 -1
- package/dist/sdk/winterc_server.js +0 -1
- package/dist/sdk/winterc_server.js.map +1 -1
- package/dist/sdk/worker_entry.d.ts +3 -11
- package/dist/sdk/worker_entry.d.ts.map +1 -1
- package/dist/sdk/worker_entry.js +8 -18
- package/dist/sdk/worker_entry.js.map +1 -1
- package/dist/sdk/worker_shim.d.ts +5 -6
- package/dist/sdk/worker_shim.d.ts.map +1 -1
- package/dist/sdk/worker_shim.js +93 -136
- package/dist/sdk/worker_shim.js.map +1 -1
- package/dist/sdk/ws_handler.d.ts +1 -3
- package/dist/sdk/ws_handler.d.ts.map +1 -1
- package/dist/sdk/ws_handler.js +14 -25
- package/dist/sdk/ws_handler.js.map +1 -1
- package/dist/ui/_cn.d.ts +5 -0
- package/dist/ui/_cn.d.ts.map +1 -0
- package/dist/ui/_cn.js +22 -0
- package/dist/ui/_cn.js.map +1 -0
- package/dist/ui/_components/app.d.ts +3 -1
- package/dist/ui/_components/app.d.ts.map +1 -1
- package/dist/ui/_components/app.js +2 -2
- package/dist/ui/_components/app.js.map +1 -1
- package/dist/ui/_components/button.d.ts +11 -0
- package/dist/ui/_components/button.d.ts.map +1 -0
- package/dist/ui/_components/button.js +17 -0
- package/dist/ui/_components/button.js.map +1 -0
- package/dist/ui/_components/chat_view.d.ts +3 -1
- package/dist/ui/_components/chat_view.d.ts.map +1 -1
- package/dist/ui/_components/chat_view.js +4 -2
- package/dist/ui/_components/chat_view.js.map +1 -1
- package/dist/ui/_components/controls.d.ts +3 -1
- package/dist/ui/_components/controls.d.ts.map +1 -1
- package/dist/ui/_components/controls.js +4 -5
- package/dist/ui/_components/controls.js.map +1 -1
- package/dist/ui/_components/error_banner.d.ts +2 -1
- package/dist/ui/_components/error_banner.d.ts.map +1 -1
- package/dist/ui/_components/error_banner.js +3 -2
- package/dist/ui/_components/error_banner.js.map +1 -1
- package/dist/ui/_components/message_bubble.d.ts +2 -1
- package/dist/ui/_components/message_bubble.d.ts.map +1 -1
- package/dist/ui/_components/message_bubble.js +5 -3
- package/dist/ui/_components/message_bubble.js.map +1 -1
- package/dist/ui/_components/message_list.d.ts +3 -1
- package/dist/ui/_components/message_list.d.ts.map +1 -1
- package/dist/ui/_components/message_list.js +7 -15
- package/dist/ui/_components/message_list.js.map +1 -1
- package/dist/ui/_components/sidebar_layout.d.ts +2 -1
- package/dist/ui/_components/sidebar_layout.d.ts.map +1 -1
- package/dist/ui/_components/sidebar_layout.js +5 -7
- package/dist/ui/_components/sidebar_layout.js.map +1 -1
- package/dist/ui/_components/start_screen.d.ts +2 -1
- package/dist/ui/_components/start_screen.d.ts.map +1 -1
- package/dist/ui/_components/start_screen.js +5 -2
- package/dist/ui/_components/start_screen.js.map +1 -1
- package/dist/ui/_components/state_indicator.d.ts +2 -1
- package/dist/ui/_components/state_indicator.d.ts.map +1 -1
- package/dist/ui/_components/state_indicator.js +3 -2
- package/dist/ui/_components/state_indicator.js.map +1 -1
- package/dist/ui/_components/thinking_indicator.d.ts +3 -1
- package/dist/ui/_components/thinking_indicator.d.ts.map +1 -1
- package/dist/ui/_components/thinking_indicator.js +4 -2
- package/dist/ui/_components/thinking_indicator.js.map +1 -1
- package/dist/ui/_components/tool_call_block.d.ts +2 -1
- package/dist/ui/_components/tool_call_block.d.ts.map +1 -1
- package/dist/ui/_components/tool_call_block.js +13 -25
- package/dist/ui/_components/tool_call_block.js.map +1 -1
- package/dist/ui/_components/transcript.d.ts +2 -1
- package/dist/ui/_components/transcript.d.ts.map +1 -1
- package/dist/ui/_components/transcript.js +3 -2
- package/dist/ui/_components/transcript.js.map +1 -1
- package/dist/ui/_jsdom_setup.d.ts +1 -0
- package/dist/ui/_jsdom_setup.d.ts.map +1 -0
- package/dist/ui/_jsdom_setup.js +6 -0
- package/dist/ui/_jsdom_setup.js.map +1 -0
- package/dist/ui/audio.d.ts.map +1 -1
- package/dist/ui/audio.js +4 -4
- package/dist/ui/audio.js.map +1 -1
- package/dist/ui/components.d.ts +13 -55
- package/dist/ui/components.d.ts.map +1 -1
- package/dist/ui/components.js +13 -42
- package/dist/ui/components.js.map +1 -1
- package/dist/ui/components_mod.d.ts +14 -3
- package/dist/ui/components_mod.d.ts.map +1 -1
- package/dist/ui/components_mod.js +14 -3
- package/dist/ui/components_mod.js.map +1 -1
- package/dist/ui/mod.d.ts +1 -8
- package/dist/ui/mod.d.ts.map +1 -1
- package/dist/ui/mod.js +1 -5
- package/dist/ui/mod.js.map +1 -1
- package/dist/ui/mount.d.ts +1 -1
- package/dist/ui/mount.d.ts.map +1 -1
- package/dist/ui/mount.js +1 -0
- package/dist/ui/mount.js.map +1 -1
- package/dist/ui/session.d.ts +0 -2
- package/dist/ui/session.d.ts.map +1 -1
- package/dist/ui/session.js +9 -18
- package/dist/ui/session.js.map +1 -1
- package/dist/ui/signals.d.ts +8 -3
- package/dist/ui/signals.d.ts.map +1 -1
- package/dist/ui/signals.js +22 -11
- package/dist/ui/signals.js.map +1 -1
- package/dist/ui/tsconfig.tsbuildinfo +1 -0
- package/dist/ui/worklets/playback-processor.js +3 -3
- package/package.json +37 -17
- package/templates/_shared/CLAUDE.md +4 -7
- package/templates/dispatch-center/agent.ts +85 -397
- package/templates/solo-rpg/agent.ts +3 -3
|
@@ -1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AE,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;YAChE,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;IAEF,SAAS,aAAa,CAAC,WAKtB;QACC,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACrF,CAAC;QACD,MAAM,MAAM,GAAG,SAAS,CAAC,kBAAkB,IAAI,EAAE,CAAC;QAClD,OAAO,gBAAgB,CAAC;YACtB,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,WAAW;YACX,WAAW;YACX,MAAM;YACN,SAAS;YACT,WAAW;YACX,eAAe;YACf,WAAW;YACX,YAAY,EAAE,WAAW,CAAC,YAAY,IAAI,KAAK;YAC/C,MAAM;YACN,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side helpers for managing sandboxed workers.
|
|
3
|
+
*
|
|
4
|
+
* Provides `createHostEndpoint` factory that registers all standard
|
|
5
|
+
* host→worker RPC methods for server implementations.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { type BridgeableWebSocket, type WorkerPort } from "./capnweb.ts";
|
|
10
|
+
import type { Kv } from "./kv.ts";
|
|
11
|
+
import type { VectorStore } from "./vector.ts";
|
|
12
|
+
/** Serialized fetch response for RPC transport. */
|
|
13
|
+
export type FetchResult = {
|
|
14
|
+
status: number;
|
|
15
|
+
headers: Record<string, string>;
|
|
16
|
+
body: string;
|
|
17
|
+
};
|
|
18
|
+
/** Fetch function signature for host→worker RPC. */
|
|
19
|
+
export type HostFetchFn = (url: string, method: string, headers: Record<string, string>, body?: string) => Promise<FetchResult>;
|
|
20
|
+
/** Kv with optional key-listing support. */
|
|
21
|
+
export type KvWithKeys = Kv & {
|
|
22
|
+
keys?(pattern?: string): Promise<string[]>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Execute an HTTP fetch on behalf of the sandboxed worker.
|
|
26
|
+
*
|
|
27
|
+
* Default implementation for the host fetch RPC — performs the fetch
|
|
28
|
+
* and returns a serialized response. Servers can wrap this to add SSRF
|
|
29
|
+
* checks or other guards.
|
|
30
|
+
*/
|
|
31
|
+
export declare function defaultHostFetch(url: string, method: string, headers: Record<string, string>, body?: string): Promise<FetchResult>;
|
|
32
|
+
/** Options for {@linkcode createHostEndpoint}. */
|
|
33
|
+
export type HostEndpointOptions = {
|
|
34
|
+
/** Environment variables passed to the worker on init. */
|
|
35
|
+
env: Record<string, string>;
|
|
36
|
+
/** KV store operations. */
|
|
37
|
+
kv: KvWithKeys;
|
|
38
|
+
/** Vector store operations. Omit if not configured. */
|
|
39
|
+
vector?: VectorStore | undefined;
|
|
40
|
+
/** Fetch handler. Use {@linkcode defaultHostFetch} as the base. */
|
|
41
|
+
fetch: HostFetchFn;
|
|
42
|
+
/** Called when the worker requests an S2S WebSocket connection. */
|
|
43
|
+
createWebSocket(url: string, headers: Record<string, string>, port: MessagePort): void;
|
|
44
|
+
};
|
|
45
|
+
/** A host-side sandbox created by {@linkcode createHostEndpoint}. */
|
|
46
|
+
export type HostSandbox = {
|
|
47
|
+
/** Bridge a WebSocket to a new worker session. */
|
|
48
|
+
startSession(socket: BridgeableWebSocket, skipGreeting?: boolean): void;
|
|
49
|
+
/** Forward an HTTP request to the worker. */
|
|
50
|
+
fetch(request: Request): Promise<Response>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Create a host endpoint for a sandboxed worker.
|
|
54
|
+
*
|
|
55
|
+
* Sets up capnweb RPC with a {@linkcode HostService}, initializes the worker,
|
|
56
|
+
* and returns a {@linkcode HostSandbox} with `startSession` and `fetch`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createHostEndpoint(port: WorkerPort, opts: HostEndpointOptions): Promise<HostSandbox>;
|
|
59
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../sdk/host.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,mBAAmB,EAMxB,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,EAAiB,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB/C,mDAAmD;AACnD,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5F,oDAAoD;AACpD,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,CAAC,EAAE,MAAM,KACV,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1B,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,EAAE,GAAG;IAAE,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC;AAE7E;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,WAAW,CAAC,CAOtB;AAuED,kDAAkD;AAClD,MAAM,MAAM,mBAAmB,GAAG;IAChC,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,2BAA2B;IAC3B,EAAE,EAAE,UAAU,CAAC;IACf,uDAAuD;IACvD,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,mEAAmE;IACnE,KAAK,EAAE,WAAW,CAAC;IACnB,mEAAmE;IACnE,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;CACxF,CAAC;AAEF,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG;IACxB,kDAAkD;IAClD,YAAY,CAAC,MAAM,EAAE,mBAAmB,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxE,6CAA6C;IAC7C,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,WAAW,CAAC,CA2CtB"}
|
package/dist/sdk/host.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Copyright 2025 the AAI authors. MIT license.
|
|
2
|
+
/**
|
|
3
|
+
* Host-side helpers for managing sandboxed workers.
|
|
4
|
+
*
|
|
5
|
+
* Provides `createHostEndpoint` factory that registers all standard
|
|
6
|
+
* host→worker RPC methods for server implementations.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { bridgeWebSocketToPort, createRpcSession, isTransferMessage, RpcTarget, sendTransfer, } from "./capnweb.js";
|
|
11
|
+
// ─── Audio validation (applied at the host transport layer) ─────────────────
|
|
12
|
+
/** Max size for a single audio chunk from the browser (1 MB). */
|
|
13
|
+
const MAX_AUDIO_CHUNK_BYTES = 1_048_576;
|
|
14
|
+
/** Validate a PCM16 audio chunk: non-empty, within size bounds, even byte length. */
|
|
15
|
+
function isValidAudioChunk(data) {
|
|
16
|
+
return (data.byteLength > 0 && data.byteLength <= MAX_AUDIO_CHUNK_BYTES && data.byteLength % 2 === 0);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execute an HTTP fetch on behalf of the sandboxed worker.
|
|
20
|
+
*
|
|
21
|
+
* Default implementation for the host fetch RPC — performs the fetch
|
|
22
|
+
* and returns a serialized response. Servers can wrap this to add SSRF
|
|
23
|
+
* checks or other guards.
|
|
24
|
+
*/
|
|
25
|
+
export async function defaultHostFetch(url, method, headers, body) {
|
|
26
|
+
const response = await fetch(new Request(url, { method, headers, ...(body ? { body } : {}) }));
|
|
27
|
+
return {
|
|
28
|
+
status: response.status,
|
|
29
|
+
headers: Object.fromEntries(response.headers),
|
|
30
|
+
body: await response.text(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// ─── Host RPC service ────────────────────────────────────────────────────────
|
|
34
|
+
/** Convert a void promise to null (capnweb RPC requires a return value). */
|
|
35
|
+
async function voidToNull(p) {
|
|
36
|
+
await p;
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* RPC service exposed by the host to the sandboxed worker.
|
|
41
|
+
* Methods are callable via capnweb RPC stubs.
|
|
42
|
+
*/
|
|
43
|
+
class HostService extends RpcTarget {
|
|
44
|
+
#kv;
|
|
45
|
+
#vec;
|
|
46
|
+
#fetchFn;
|
|
47
|
+
constructor(kv, vec, fetchFn) {
|
|
48
|
+
super();
|
|
49
|
+
this.#kv = kv;
|
|
50
|
+
this.#vec = vec;
|
|
51
|
+
this.#fetchFn = fetchFn;
|
|
52
|
+
}
|
|
53
|
+
hostFetch(url, method, headers, body) {
|
|
54
|
+
return this.#fetchFn(url, method, headers, body);
|
|
55
|
+
}
|
|
56
|
+
kvGet(key) {
|
|
57
|
+
return this.#kv.get(key);
|
|
58
|
+
}
|
|
59
|
+
kvSet(key, value, options) {
|
|
60
|
+
return voidToNull(this.#kv.set(key, value, options));
|
|
61
|
+
}
|
|
62
|
+
kvDel(key) {
|
|
63
|
+
return voidToNull(this.#kv.delete(key));
|
|
64
|
+
}
|
|
65
|
+
kvList(prefix, options) {
|
|
66
|
+
return this.#kv.list(prefix, options);
|
|
67
|
+
}
|
|
68
|
+
kvKeys(pattern) {
|
|
69
|
+
if (!this.#kv.keys)
|
|
70
|
+
throw new Error("keys op not supported");
|
|
71
|
+
return this.#kv.keys(pattern);
|
|
72
|
+
}
|
|
73
|
+
#requireVec() {
|
|
74
|
+
if (!this.#vec)
|
|
75
|
+
throw new Error("Vector store not configured");
|
|
76
|
+
return this.#vec;
|
|
77
|
+
}
|
|
78
|
+
vecUpsert(id, data, metadata) {
|
|
79
|
+
return voidToNull(this.#requireVec().upsert(id, data, metadata));
|
|
80
|
+
}
|
|
81
|
+
vecQuery(text, options) {
|
|
82
|
+
return this.#requireVec().query(text, options);
|
|
83
|
+
}
|
|
84
|
+
vecRemove(ids) {
|
|
85
|
+
return voidToNull(this.#requireVec().remove(ids));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a host endpoint for a sandboxed worker.
|
|
90
|
+
*
|
|
91
|
+
* Sets up capnweb RPC with a {@linkcode HostService}, initializes the worker,
|
|
92
|
+
* and returns a {@linkcode HostSandbox} with `startSession` and `fetch`.
|
|
93
|
+
*/
|
|
94
|
+
export async function createHostEndpoint(port, opts) {
|
|
95
|
+
const hostService = new HostService(opts.kv, opts.vector, opts.fetch);
|
|
96
|
+
const workerStub = createRpcSession({
|
|
97
|
+
port,
|
|
98
|
+
localMain: hostService,
|
|
99
|
+
onTransfer(data, ports) {
|
|
100
|
+
if (!isTransferMessage(data))
|
|
101
|
+
return;
|
|
102
|
+
if (data._t === "createWs") {
|
|
103
|
+
const transferPort = ports[0];
|
|
104
|
+
if (!transferPort)
|
|
105
|
+
throw new Error("No port transferred for WebSocket");
|
|
106
|
+
const headers = JSON.parse(data.headers);
|
|
107
|
+
opts.createWebSocket(data.url, headers, transferPort);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
// Initialize the worker
|
|
112
|
+
await workerStub.init(opts.env);
|
|
113
|
+
return {
|
|
114
|
+
startSession(socket, skipGreeting) {
|
|
115
|
+
const { port1, port2 } = new MessageChannel();
|
|
116
|
+
bridgeWebSocketToPort(socket, port1, {
|
|
117
|
+
filterBinary: isValidAudioChunk,
|
|
118
|
+
});
|
|
119
|
+
sendTransfer(port, { _t: "handleWs", skipGreeting: skipGreeting ?? false }, [port2]);
|
|
120
|
+
},
|
|
121
|
+
async fetch(request) {
|
|
122
|
+
const body = request.body ? await request.text() : undefined;
|
|
123
|
+
const result = await workerStub.workerFetch(request.url, request.method, Object.fromEntries(request.headers), body);
|
|
124
|
+
return new Response(result.body, {
|
|
125
|
+
status: result.status,
|
|
126
|
+
headers: result.headers,
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../sdk/host.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C;;;;;;;GAOG;AAEH,OAAO,EAEL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,YAAY,GAEb,MAAM,cAAc,CAAC;AAItB,+EAA+E;AAE/E,iEAAiE;AACjE,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAExC,qFAAqF;AACrF,SAAS,iBAAiB,CAAC,IAAiB;IAC1C,OAAO,CACL,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,qBAAqB,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,CAC7F,CAAC;AACJ,CA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AAI,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,WAAW,CACzC,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,MAAM,EACd,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,EACnC,IAAI,CACL,CAAC;YACF,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;gBAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/sdk/mod.d.ts
CHANGED
|
@@ -21,9 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @module
|
|
23
23
|
*/
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export type { AgentOptions, BeforeStepResult, BuiltinTool, HookContext, Message, StepInfo, ToolContext, ToolDef, } from "./types.ts";
|
|
27
|
-
export { tool } from "./types.ts";
|
|
24
|
+
export { memoryTools } from "./builtin_tools.ts";
|
|
25
|
+
export { type AgentOptions, type BeforeStepResult, type BuiltinTool, defineAgent, type HookContext, type Message, type StepInfo, type ToolContext, type ToolDef, tool, } from "./types.ts";
|
|
28
26
|
export type { VectorEntry, VectorStore } from "./vector.ts";
|
|
29
27
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/sdk/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../sdk/mod.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../sdk/mod.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,IAAI,GACL,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/sdk/mod.js
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @module
|
|
24
24
|
*/
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export { tool } from "./types.js";
|
|
25
|
+
export { memoryTools } from "./builtin_tools.js";
|
|
26
|
+
export { defineAgent, tool, } from "./types.js";
|
|
28
27
|
//# sourceMappingURL=mod.js.map
|
package/dist/sdk/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../sdk/mod.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../sdk/mod.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAIL,WAAW,EAMX,IAAI,GACL,MAAM,YAAY,CAAC"}
|
package/dist/sdk/protocol.d.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
8
|
import { z } from "zod";
|
|
9
|
-
import type { Message, StepInfo } from "./types.ts";
|
|
10
9
|
/**
|
|
11
10
|
* Default sample rate for speech-to-text audio in Hz.
|
|
12
11
|
*
|
|
@@ -27,42 +26,14 @@ export declare const DEFAULT_TTS_SAMPLE_RATE = 24000;
|
|
|
27
26
|
export declare const AUDIO_FORMAT: "pcm16";
|
|
28
27
|
/** Specification for binary audio frames exchanged over WebSocket. */
|
|
29
28
|
export declare const AudioFrameSpec: {
|
|
30
|
-
/** Audio codec identifier sent in the `ready` message. */
|
|
31
29
|
readonly format: "pcm16";
|
|
32
|
-
/** Signed 16-bit integer samples. */
|
|
33
30
|
readonly bitsPerSample: 16;
|
|
34
|
-
/** Little-endian byte order. */
|
|
35
31
|
readonly endianness: "little";
|
|
36
|
-
/** Mono audio. */
|
|
37
32
|
readonly channels: 1;
|
|
38
|
-
|
|
39
|
-
readonly bytesPerSample: number;
|
|
33
|
+
readonly bytesPerSample: 2;
|
|
40
34
|
};
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
* This is a discriminated union on the `op` field, representing the four
|
|
45
|
-
* key-value store operations available to sandboxed agent workers.
|
|
46
|
-
*/
|
|
47
|
-
export type KvRequest = {
|
|
48
|
-
op: "get";
|
|
49
|
-
key: string;
|
|
50
|
-
} | {
|
|
51
|
-
op: "set";
|
|
52
|
-
key: string;
|
|
53
|
-
value: string;
|
|
54
|
-
ttl?: number | undefined;
|
|
55
|
-
} | {
|
|
56
|
-
op: "del";
|
|
57
|
-
key: string;
|
|
58
|
-
} | {
|
|
59
|
-
op: "list";
|
|
60
|
-
prefix: string;
|
|
61
|
-
limit?: number | undefined;
|
|
62
|
-
reverse?: boolean | undefined;
|
|
63
|
-
};
|
|
64
|
-
/** Zod schema for {@linkcode KvRequest}. */
|
|
65
|
-
export declare const KvRequestBaseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
|
+
/** Zod schema for KV operation requests from the worker to the host. */
|
|
36
|
+
export declare const KvRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
66
37
|
op: z.ZodLiteral<"get">;
|
|
67
38
|
key: z.ZodString;
|
|
68
39
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -78,14 +49,34 @@ export declare const KvRequestBaseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
78
49
|
prefix: z.ZodString;
|
|
79
50
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
80
51
|
reverse: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
op: z.ZodLiteral<"keys">;
|
|
54
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>], "op">;
|
|
56
|
+
/** KV operation request — discriminated union on the `op` field. */
|
|
57
|
+
export type KvRequest = z.infer<typeof KvRequestSchema>;
|
|
58
|
+
/** Zod schema for vector operation requests. */
|
|
59
|
+
export declare const VectorRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
60
|
+
op: z.ZodLiteral<"upsert">;
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
data: z.ZodString;
|
|
63
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
64
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
65
|
+
op: z.ZodLiteral<"query">;
|
|
66
|
+
text: z.ZodString;
|
|
67
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
filter: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
+
op: z.ZodLiteral<"remove">;
|
|
71
|
+
ids: z.ZodArray<z.ZodString>;
|
|
81
72
|
}, z.core.$strip>], "op">;
|
|
73
|
+
/** Vector operation request — discriminated union on the `op` field. */
|
|
74
|
+
export type VectorRequest = z.infer<typeof VectorRequestSchema>;
|
|
82
75
|
/** Default timeout for agent lifecycle hooks (onConnect, onTurn, etc). */
|
|
83
76
|
export declare const HOOK_TIMEOUT_MS = 5000;
|
|
84
77
|
/** Default timeout for tool execution in the worker. */
|
|
85
78
|
export declare const TOOL_EXECUTION_TIMEOUT_MS = 30000;
|
|
86
|
-
/**
|
|
87
|
-
export type SessionErrorCode = "stt" | "llm" | "tts" | "tool" | "protocol" | "connection" | "audio" | "internal";
|
|
88
|
-
/** Zod schema for {@linkcode SessionErrorCode}. */
|
|
79
|
+
/** Zod schema for session error codes. */
|
|
89
80
|
export declare const SessionErrorCodeSchema: z.ZodEnum<{
|
|
90
81
|
tool: "tool";
|
|
91
82
|
audio: "audio";
|
|
@@ -96,54 +87,8 @@ export declare const SessionErrorCodeSchema: z.ZodEnum<{
|
|
|
96
87
|
connection: "connection";
|
|
97
88
|
internal: "internal";
|
|
98
89
|
}>;
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
* Sent via a single `event()` RPC method instead of one method per type.
|
|
103
|
-
*/
|
|
104
|
-
export type ClientEvent = {
|
|
105
|
-
type: "speech_started";
|
|
106
|
-
} | {
|
|
107
|
-
type: "speech_stopped";
|
|
108
|
-
} | {
|
|
109
|
-
type: "transcript";
|
|
110
|
-
text: string;
|
|
111
|
-
isFinal: false;
|
|
112
|
-
} | {
|
|
113
|
-
type: "transcript";
|
|
114
|
-
text: string;
|
|
115
|
-
isFinal: true;
|
|
116
|
-
turnOrder?: number | undefined;
|
|
117
|
-
} | {
|
|
118
|
-
type: "turn";
|
|
119
|
-
text: string;
|
|
120
|
-
turnOrder?: number | undefined;
|
|
121
|
-
} | {
|
|
122
|
-
type: "chat";
|
|
123
|
-
text: string;
|
|
124
|
-
} | {
|
|
125
|
-
type: "chat_delta";
|
|
126
|
-
text: string;
|
|
127
|
-
} | {
|
|
128
|
-
type: "tool_call_start";
|
|
129
|
-
toolCallId: string;
|
|
130
|
-
toolName: string;
|
|
131
|
-
args: Record<string, unknown>;
|
|
132
|
-
} | {
|
|
133
|
-
type: "tool_call_done";
|
|
134
|
-
toolCallId: string;
|
|
135
|
-
result: string;
|
|
136
|
-
} | {
|
|
137
|
-
type: "tts_done";
|
|
138
|
-
} | {
|
|
139
|
-
type: "cancelled";
|
|
140
|
-
} | {
|
|
141
|
-
type: "reset";
|
|
142
|
-
} | {
|
|
143
|
-
type: "error";
|
|
144
|
-
code: SessionErrorCode;
|
|
145
|
-
message: string;
|
|
146
|
-
};
|
|
90
|
+
/** Error codes for categorizing session errors on the wire. */
|
|
91
|
+
export type SessionErrorCode = z.infer<typeof SessionErrorCodeSchema>;
|
|
147
92
|
/** Zod schema for {@linkcode ClientEvent}. */
|
|
148
93
|
export declare const ClientEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
149
94
|
type: z.ZodLiteral<"speech_started">;
|
|
@@ -193,6 +138,8 @@ export declare const ClientEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
193
138
|
}>;
|
|
194
139
|
message: z.ZodString;
|
|
195
140
|
}, z.core.$strip>], "type">;
|
|
141
|
+
/** Discriminated union of all server→client session events. */
|
|
142
|
+
export type ClientEvent = z.infer<typeof ClientEventSchema>;
|
|
196
143
|
/**
|
|
197
144
|
* Typed interface for pushing session events to a connected client.
|
|
198
145
|
*
|
|
@@ -216,27 +163,13 @@ export type ReadyConfig = {
|
|
|
216
163
|
sampleRate: number;
|
|
217
164
|
ttsSampleRate: number;
|
|
218
165
|
};
|
|
219
|
-
/** Client→server text messages (binary frames carry raw PCM16 audio). */
|
|
220
|
-
export type ClientMessage = {
|
|
221
|
-
type: "audio_ready";
|
|
222
|
-
} | {
|
|
223
|
-
type: "cancel";
|
|
224
|
-
} | {
|
|
225
|
-
type: "reset";
|
|
226
|
-
} | {
|
|
227
|
-
type: "history";
|
|
228
|
-
messages: readonly {
|
|
229
|
-
role: "user" | "assistant";
|
|
230
|
-
text: string;
|
|
231
|
-
}[];
|
|
232
|
-
};
|
|
233
166
|
/** Server→client text messages (binary frames carry raw PCM16 audio). */
|
|
234
167
|
export type ServerMessage = ({
|
|
235
168
|
type: "config";
|
|
236
169
|
} & ReadyConfig) | {
|
|
237
170
|
type: "audio_done";
|
|
238
171
|
} | ClientEvent;
|
|
239
|
-
/** Zod schema for
|
|
172
|
+
/** Zod schema for client→server text messages. */
|
|
240
173
|
export declare const ClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
241
174
|
type: z.ZodLiteral<"audio_ready">;
|
|
242
175
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -253,46 +186,11 @@ export declare const ClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
253
186
|
text: z.ZodString;
|
|
254
187
|
}, z.core.$strip>>;
|
|
255
188
|
}, z.core.$strip>], "type">;
|
|
256
|
-
/**
|
|
257
|
-
|
|
258
|
-
*
|
|
259
|
-
* Since workers run with all permissions denied, they use this interface
|
|
260
|
-
* to proxy network requests and KV operations back to the host.
|
|
261
|
-
*/
|
|
262
|
-
export type HostApi = {
|
|
263
|
-
fetch(req: {
|
|
264
|
-
url: string;
|
|
265
|
-
method: string;
|
|
266
|
-
headers: Readonly<Record<string, string>>;
|
|
267
|
-
body: string | null;
|
|
268
|
-
}): Promise<{
|
|
269
|
-
status: number;
|
|
270
|
-
statusText: string;
|
|
271
|
-
headers: Record<string, string>;
|
|
272
|
-
body: string;
|
|
273
|
-
}>;
|
|
274
|
-
kv(req: KvRequest): Promise<{
|
|
275
|
-
result: unknown;
|
|
276
|
-
}>;
|
|
277
|
-
vectorSearch(req: {
|
|
278
|
-
query: string;
|
|
279
|
-
topK: number;
|
|
280
|
-
}): Promise<string>;
|
|
281
|
-
};
|
|
189
|
+
/** Client→server text messages (binary frames carry raw PCM16 audio). */
|
|
190
|
+
export type ClientMessage = z.infer<typeof ClientMessageSchema>;
|
|
282
191
|
/** Combined turn configuration resolved from the worker before a turn starts. */
|
|
283
192
|
export type TurnConfig = {
|
|
284
193
|
maxSteps?: number;
|
|
285
194
|
activeTools?: string[];
|
|
286
195
|
};
|
|
287
|
-
/** Worker-side RPC target interface (host calls these methods). */
|
|
288
|
-
export interface WorkerRpcApi {
|
|
289
|
-
withEnv(env: Record<string, string>): WorkerRpcApi;
|
|
290
|
-
executeTool(name: string, args: Readonly<Record<string, unknown>>, sessionId: string | undefined, messages: readonly Message[] | undefined): Promise<string>;
|
|
291
|
-
onConnect(sessionId: string): Promise<void>;
|
|
292
|
-
onDisconnect(sessionId: string): Promise<void>;
|
|
293
|
-
onTurn(sessionId: string, text: string): Promise<void>;
|
|
294
|
-
onError(sessionId: string, error: string): void;
|
|
295
|
-
onStep(sessionId: string, step: StepInfo): Promise<void>;
|
|
296
|
-
resolveTurnConfig(sessionId: string): Promise<TurnConfig | null>;
|
|
297
|
-
}
|
|
298
196
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../sdk/protocol.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../sdk/protocol.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAG,OAAgB,CAAC;AAE7C,sEAAsE;AACtE,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,wEAAwE;AACxE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;yBAgB1B,CAAC;AAEH,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAIxD,gDAAgD;AAChD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;yBAiB9B,CAAC;AAEH,wEAAwE;AACxE,MAAM,MAAM,a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