@alexkroman1/aai 0.8.8 → 0.9.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/{sdk/_internal_types.d.ts → _internal-types.d.ts} +0 -3
- package/dist/_internal-types.js +19 -0
- package/dist/{sdk/_mock_ws.d.ts → _mock-ws.d.ts} +16 -5
- package/dist/_mock-ws.js +158 -0
- package/dist/{sdk/_utils.d.ts → _utils.d.ts} +1 -2
- package/dist/_utils.js +8 -0
- package/dist/{sdk/builtin_tools.d.ts → builtin-tools.d.ts} +5 -8
- package/dist/builtin-tools.js +270 -0
- package/dist/{sdk/direct_executor.d.ts → direct-executor.d.ts} +3 -7
- package/dist/direct-executor.js +125 -0
- package/dist/{sdk/mod.d.ts → index.d.ts} +0 -4
- package/dist/index.js +2 -0
- package/dist/{sdk/kv.d.ts → kv.d.ts} +23 -20
- package/dist/kv.js +99 -0
- package/dist/{sdk/protocol.d.ts → protocol.d.ts} +65 -29
- package/dist/protocol.js +142 -0
- package/dist/runtime.d.ts +18 -0
- package/dist/runtime.js +16 -0
- package/dist/s2s.d.ts +110 -0
- package/dist/s2s.js +242 -0
- package/dist/{sdk/server.d.ts → server.d.ts} +3 -23
- package/dist/server.js +105 -0
- package/dist/{sdk/session.d.ts → session.d.ts} +4 -11
- package/dist/session.js +312 -0
- package/dist/tsdown.config.d.ts +2 -0
- package/dist/{sdk/types.d.ts → types.d.ts} +41 -25
- package/dist/types.js +139 -0
- package/dist/{sdk/vector.d.ts → vector.d.ts} +14 -15
- package/dist/vector.js +56 -0
- package/dist/{sdk/worker_entry.d.ts → worker-entry.d.ts} +2 -5
- package/dist/worker-entry.js +59 -0
- package/dist/{sdk/ws_handler.d.ts → ws-handler.d.ts} +10 -8
- package/dist/ws-handler.js +155 -0
- package/package.json +66 -149
- package/README.md +0 -34
- package/dist/aai.js +0 -3
- package/dist/cli/tsconfig.tsbuildinfo +0 -1
- package/dist/cli.js +0 -2811
- package/dist/sdk/_internal_types.d.ts.map +0 -1
- package/dist/sdk/_internal_types.js +0 -25
- package/dist/sdk/_internal_types.js.map +0 -1
- package/dist/sdk/_mock_ws.d.ts.map +0 -1
- package/dist/sdk/_mock_ws.js +0 -154
- package/dist/sdk/_mock_ws.js.map +0 -1
- package/dist/sdk/_render_check.d.ts +0 -10
- package/dist/sdk/_render_check.d.ts.map +0 -1
- package/dist/sdk/_render_check.js +0 -72
- package/dist/sdk/_render_check.js.map +0 -1
- package/dist/sdk/_utils.d.ts.map +0 -1
- package/dist/sdk/_utils.js +0 -7
- package/dist/sdk/_utils.js.map +0 -1
- package/dist/sdk/builtin_tools.d.ts.map +0 -1
- package/dist/sdk/builtin_tools.js +0 -309
- package/dist/sdk/builtin_tools.js.map +0 -1
- package/dist/sdk/capnweb.d.ts +0 -102
- package/dist/sdk/capnweb.d.ts.map +0 -1
- package/dist/sdk/capnweb.js +0 -219
- package/dist/sdk/capnweb.js.map +0 -1
- package/dist/sdk/define_agent.d.ts +0 -36
- package/dist/sdk/define_agent.d.ts.map +0 -1
- package/dist/sdk/define_agent.js +0 -71
- package/dist/sdk/define_agent.js.map +0 -1
- package/dist/sdk/direct_executor.d.ts.map +0 -1
- package/dist/sdk/direct_executor.js +0 -145
- package/dist/sdk/direct_executor.js.map +0 -1
- package/dist/sdk/host.d.ts +0 -59
- package/dist/sdk/host.d.ts.map +0 -1
- package/dist/sdk/host.js +0 -131
- package/dist/sdk/host.js.map +0 -1
- package/dist/sdk/kv.d.ts.map +0 -1
- package/dist/sdk/kv.js +0 -94
- package/dist/sdk/kv.js.map +0 -1
- package/dist/sdk/memory_tools.d.ts +0 -38
- package/dist/sdk/memory_tools.d.ts.map +0 -1
- package/dist/sdk/memory_tools.js +0 -77
- package/dist/sdk/memory_tools.js.map +0 -1
- package/dist/sdk/mod.d.ts.map +0 -1
- package/dist/sdk/mod.js +0 -27
- package/dist/sdk/mod.js.map +0 -1
- package/dist/sdk/protocol.d.ts.map +0 -1
- package/dist/sdk/protocol.js +0 -133
- package/dist/sdk/protocol.js.map +0 -1
- package/dist/sdk/runtime.d.ts +0 -36
- package/dist/sdk/runtime.d.ts.map +0 -1
- package/dist/sdk/runtime.js +0 -27
- package/dist/sdk/runtime.js.map +0 -1
- package/dist/sdk/s2s.d.ts +0 -74
- package/dist/sdk/s2s.d.ts.map +0 -1
- package/dist/sdk/s2s.js +0 -218
- package/dist/sdk/s2s.js.map +0 -1
- package/dist/sdk/server.d.ts.map +0 -1
- package/dist/sdk/server.js +0 -144
- package/dist/sdk/server.js.map +0 -1
- package/dist/sdk/session.d.ts.map +0 -1
- package/dist/sdk/session.js +0 -303
- package/dist/sdk/session.js.map +0 -1
- package/dist/sdk/system_prompt.d.ts +0 -6
- package/dist/sdk/system_prompt.d.ts.map +0 -1
- package/dist/sdk/system_prompt.js +0 -35
- package/dist/sdk/system_prompt.js.map +0 -1
- package/dist/sdk/tsconfig.tsbuildinfo +0 -1
- package/dist/sdk/types.d.ts.map +0 -1
- package/dist/sdk/types.js +0 -96
- package/dist/sdk/types.js.map +0 -1
- package/dist/sdk/vector.d.ts.map +0 -1
- package/dist/sdk/vector.js +0 -63
- package/dist/sdk/vector.js.map +0 -1
- package/dist/sdk/winterc_server.d.ts +0 -56
- package/dist/sdk/winterc_server.d.ts.map +0 -1
- package/dist/sdk/winterc_server.js +0 -77
- package/dist/sdk/winterc_server.js.map +0 -1
- package/dist/sdk/worker_entry.d.ts.map +0 -1
- package/dist/sdk/worker_entry.js +0 -68
- package/dist/sdk/worker_entry.js.map +0 -1
- package/dist/sdk/worker_shim.d.ts +0 -19
- package/dist/sdk/worker_shim.d.ts.map +0 -1
- package/dist/sdk/worker_shim.js +0 -141
- package/dist/sdk/worker_shim.js.map +0 -1
- package/dist/sdk/ws_handler.d.ts.map +0 -1
- package/dist/sdk/ws_handler.js +0 -158
- package/dist/sdk/ws_handler.js.map +0 -1
- package/dist/ui/_cn.d.ts +0 -5
- package/dist/ui/_cn.d.ts.map +0 -1
- package/dist/ui/_cn.js +0 -22
- package/dist/ui/_cn.js.map +0 -1
- package/dist/ui/_components/app.d.ts +0 -5
- package/dist/ui/_components/app.d.ts.map +0 -1
- package/dist/ui/_components/app.js +0 -12
- package/dist/ui/_components/app.js.map +0 -1
- package/dist/ui/_components/button.d.ts +0 -11
- package/dist/ui/_components/button.d.ts.map +0 -1
- package/dist/ui/_components/button.js +0 -17
- package/dist/ui/_components/button.js.map +0 -1
- package/dist/ui/_components/chat_view.d.ts +0 -5
- package/dist/ui/_components/chat_view.d.ts.map +0 -1
- package/dist/ui/_components/chat_view.js +0 -15
- package/dist/ui/_components/chat_view.js.map +0 -1
- package/dist/ui/_components/controls.d.ts +0 -4
- package/dist/ui/_components/controls.d.ts.map +0 -1
- package/dist/ui/_components/controls.js +0 -10
- package/dist/ui/_components/controls.js.map +0 -1
- package/dist/ui/_components/error_banner.d.ts +0 -8
- package/dist/ui/_components/error_banner.d.ts.map +0 -1
- package/dist/ui/_components/error_banner.js +0 -8
- package/dist/ui/_components/error_banner.js.map +0 -1
- package/dist/ui/_components/message_bubble.d.ts +0 -7
- package/dist/ui/_components/message_bubble.d.ts.map +0 -1
- package/dist/ui/_components/message_bubble.js +0 -11
- package/dist/ui/_components/message_bubble.js.map +0 -1
- package/dist/ui/_components/message_list.d.ts +0 -4
- package/dist/ui/_components/message_list.d.ts.map +0 -1
- package/dist/ui/_components/message_list.js +0 -45
- package/dist/ui/_components/message_list.js.map +0 -1
- package/dist/ui/_components/sidebar_layout.d.ts +0 -20
- package/dist/ui/_components/sidebar_layout.d.ts.map +0 -1
- package/dist/ui/_components/sidebar_layout.js +0 -19
- package/dist/ui/_components/sidebar_layout.js.map +0 -1
- package/dist/ui/_components/start_screen.d.ts +0 -25
- package/dist/ui/_components/start_screen.d.ts.map +0 -1
- package/dist/ui/_components/start_screen.js +0 -28
- package/dist/ui/_components/start_screen.js.map +0 -1
- package/dist/ui/_components/state_indicator.d.ts +0 -8
- package/dist/ui/_components/state_indicator.d.ts.map +0 -1
- package/dist/ui/_components/state_indicator.js +0 -6
- package/dist/ui/_components/state_indicator.js.map +0 -1
- package/dist/ui/_components/thinking_indicator.d.ts +0 -5
- package/dist/ui/_components/thinking_indicator.d.ts.map +0 -1
- package/dist/ui/_components/thinking_indicator.js +0 -10
- package/dist/ui/_components/thinking_indicator.js.map +0 -1
- package/dist/ui/_components/tool_call_block.d.ts +0 -7
- package/dist/ui/_components/tool_call_block.d.ts.map +0 -1
- package/dist/ui/_components/tool_call_block.js +0 -46
- package/dist/ui/_components/tool_call_block.js.map +0 -1
- package/dist/ui/_components/tool_icons.d.ts +0 -18
- package/dist/ui/_components/tool_icons.d.ts.map +0 -1
- package/dist/ui/_components/tool_icons.js +0 -26
- package/dist/ui/_components/tool_icons.js.map +0 -1
- package/dist/ui/_components/transcript.d.ts +0 -7
- package/dist/ui/_components/transcript.d.ts.map +0 -1
- package/dist/ui/_components/transcript.js +0 -9
- package/dist/ui/_components/transcript.js.map +0 -1
- package/dist/ui/_dom_shim.d.ts +0 -7
- package/dist/ui/_dom_shim.d.ts.map +0 -1
- package/dist/ui/_dom_shim.js +0 -21
- package/dist/ui/_dom_shim.js.map +0 -1
- package/dist/ui/_hooks.d.ts +0 -21
- package/dist/ui/_hooks.d.ts.map +0 -1
- package/dist/ui/_hooks.js +0 -35
- package/dist/ui/_hooks.js.map +0 -1
- package/dist/ui/_jsdom_setup.d.ts +0 -1
- package/dist/ui/_jsdom_setup.d.ts.map +0 -1
- package/dist/ui/_jsdom_setup.js +0 -6
- package/dist/ui/_jsdom_setup.js.map +0 -1
- package/dist/ui/_render_check.d.ts +0 -10
- package/dist/ui/_render_check.d.ts.map +0 -1
- package/dist/ui/_render_check.js +0 -72
- package/dist/ui/_render_check.js.map +0 -1
- package/dist/ui/_test_utils.js +0 -272
- package/dist/ui/_test_utils.js.map +0 -1
- package/dist/ui/audio.d.ts +0 -46
- package/dist/ui/audio.d.ts.map +0 -1
- package/dist/ui/audio.js +0 -130
- package/dist/ui/audio.js.map +0 -1
- package/dist/ui/components.d.ts +0 -14
- package/dist/ui/components.d.ts.map +0 -1
- package/dist/ui/components.js +0 -15
- package/dist/ui/components.js.map +0 -1
- package/dist/ui/components_mod.d.ts +0 -34
- package/dist/ui/components_mod.d.ts.map +0 -1
- package/dist/ui/components_mod.js +0 -32
- package/dist/ui/components_mod.js.map +0 -1
- package/dist/ui/mod.d.ts +0 -23
- package/dist/ui/mod.d.ts.map +0 -1
- package/dist/ui/mod.js +0 -22
- package/dist/ui/mod.js.map +0 -1
- package/dist/ui/mount.d.ts +0 -44
- package/dist/ui/mount.d.ts.map +0 -1
- package/dist/ui/mount.js +0 -61
- package/dist/ui/mount.js.map +0 -1
- package/dist/ui/mount_context.d.ts +0 -22
- package/dist/ui/mount_context.d.ts.map +0 -1
- package/dist/ui/mount_context.js +0 -10
- package/dist/ui/mount_context.js.map +0 -1
- package/dist/ui/session.d.ts +0 -96
- package/dist/ui/session.d.ts.map +0 -1
- package/dist/ui/session.js +0 -379
- package/dist/ui/session.js.map +0 -1
- package/dist/ui/session_mod.d.ts +0 -19
- package/dist/ui/session_mod.d.ts.map +0 -1
- package/dist/ui/session_mod.js +0 -18
- package/dist/ui/session_mod.js.map +0 -1
- package/dist/ui/signals.d.ts +0 -80
- package/dist/ui/signals.d.ts.map +0 -1
- package/dist/ui/signals.js +0 -137
- package/dist/ui/signals.js.map +0 -1
- package/dist/ui/tsconfig.tsbuildinfo +0 -1
- package/dist/ui/types.d.ts +0 -36
- package/dist/ui/types.d.ts.map +0 -1
- package/dist/ui/types.js +0 -4
- package/dist/ui/types.js.map +0 -1
- package/dist/ui/worklets/capture-processor.d.ts +0 -3
- package/dist/ui/worklets/capture-processor.d.ts.map +0 -1
- package/dist/ui/worklets/capture-processor.js +0 -61
- package/dist/ui/worklets/capture-processor.js.map +0 -1
- package/dist/ui/worklets/playback-processor.d.ts +0 -3
- package/dist/ui/worklets/playback-processor.d.ts.map +0 -1
- package/dist/ui/worklets/playback-processor.js +0 -109
- package/dist/ui/worklets/playback-processor.js.map +0 -1
- package/templates/.env +0 -1
- package/templates/_shared/.env.example +0 -5
- package/templates/_shared/CLAUDE.md +0 -1073
- package/templates/_shared/biome.json +0 -32
- package/templates/_shared/global.d.ts +0 -1
- package/templates/_shared/index.html +0 -16
- package/templates/_shared/package.json +0 -22
- package/templates/_shared/tsconfig.json +0 -16
- package/templates/code-interpreter/agent.ts +0 -27
- package/templates/code-interpreter/client.tsx +0 -3
- package/templates/dispatch-center/agent.ts +0 -1223
- package/templates/dispatch-center/client.tsx +0 -505
- package/templates/embedded-assets/agent.ts +0 -48
- package/templates/embedded-assets/client.tsx +0 -3
- package/templates/embedded-assets/knowledge.json +0 -20
- package/templates/health-assistant/agent.ts +0 -160
- package/templates/health-assistant/client.tsx +0 -3
- package/templates/infocom-adventure/agent.ts +0 -164
- package/templates/infocom-adventure/client.tsx +0 -300
- package/templates/math-buddy/agent.ts +0 -21
- package/templates/math-buddy/client.tsx +0 -3
- package/templates/memory-agent/agent.ts +0 -20
- package/templates/memory-agent/client.tsx +0 -3
- package/templates/night-owl/agent.ts +0 -98
- package/templates/night-owl/client.tsx +0 -12
- package/templates/personal-finance/agent.ts +0 -26
- package/templates/personal-finance/client.tsx +0 -3
- package/templates/pizza-ordering/agent.ts +0 -214
- package/templates/pizza-ordering/client.tsx +0 -264
- package/templates/simple/agent.ts +0 -6
- package/templates/simple/client.tsx +0 -3
- package/templates/smart-research/agent.ts +0 -164
- package/templates/smart-research/client.tsx +0 -3
- package/templates/solo-rpg/agent.ts +0 -1240
- package/templates/solo-rpg/client.tsx +0 -698
- package/templates/support/README.md +0 -62
- package/templates/support/agent.ts +0 -19
- package/templates/support/client.tsx +0 -3
- package/templates/travel-concierge/agent.ts +0 -29
- package/templates/travel-concierge/client.tsx +0 -3
- package/templates/tsconfig.json +0 -1
- package/templates/web-researcher/agent.ts +0 -17
- package/templates/web-researcher/client.tsx +0 -3
- package/ui/styles.css +0 -74
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Internal type definitions shared by server and CLI.
|
|
3
3
|
*
|
|
4
4
|
* Note: this module is for internal use only and should not be used directly.
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
5
|
*/
|
|
8
6
|
import type { JSONSchema7 } from "json-schema";
|
|
9
7
|
import { z } from "zod";
|
|
@@ -56,4 +54,3 @@ export declare const EMPTY_PARAMS: z.ZodObject<{}, z.core.$strip>;
|
|
|
56
54
|
* object suitable for structured clone / JSON serialization.
|
|
57
55
|
*/
|
|
58
56
|
export declare function agentToolsToSchemas(tools: Readonly<Record<string, ToolDef>>): ToolSchema[];
|
|
59
|
-
//# sourceMappingURL=_internal_types.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region _internal-types.ts
|
|
3
|
+
/** Empty Zod object schema used as default when tools have no parameters. */
|
|
4
|
+
const EMPTY_PARAMS = z.object({});
|
|
5
|
+
/**
|
|
6
|
+
* Convert agent tool definitions to JSON Schema format for wire transport.
|
|
7
|
+
*
|
|
8
|
+
* Transforms the Zod-based `parameters` of each tool into a plain JSON Schema
|
|
9
|
+
* object suitable for structured clone / JSON serialization.
|
|
10
|
+
*/
|
|
11
|
+
function agentToolsToSchemas(tools) {
|
|
12
|
+
return Object.entries(tools).map(([name, def]) => ({
|
|
13
|
+
name,
|
|
14
|
+
description: def.description,
|
|
15
|
+
parameters: z.toJSONSchema(def.parameters ?? EMPTY_PARAMS)
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { EMPTY_PARAMS, agentToolsToSchemas };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A mock WebSocket implementation for testing.
|
|
3
3
|
*
|
|
4
4
|
* Extends `EventTarget` to simulate WebSocket behavior without a real
|
|
5
|
-
* network connection. Records all sent messages in the {@
|
|
5
|
+
* network connection. Records all sent messages in the {@link sent}
|
|
6
6
|
* array and provides helper methods to simulate incoming messages,
|
|
7
7
|
* connection events, and errors.
|
|
8
8
|
*
|
|
@@ -21,7 +21,7 @@ export declare class MockWebSocket extends EventTarget {
|
|
|
21
21
|
static readonly CLOSED = 3;
|
|
22
22
|
readyState: number;
|
|
23
23
|
binaryType: string;
|
|
24
|
-
/** All messages passed to {@
|
|
24
|
+
/** All messages passed to {@link send}, in order. */
|
|
25
25
|
sent: (string | ArrayBuffer | Uint8Array)[];
|
|
26
26
|
url: string;
|
|
27
27
|
/**
|
|
@@ -34,6 +34,18 @@ export declare class MockWebSocket extends EventTarget {
|
|
|
34
34
|
* @param _protocols - Ignored; accepted for API compatibility.
|
|
35
35
|
*/
|
|
36
36
|
constructor(url: string | URL, _protocols?: string | string[] | Record<string, unknown>);
|
|
37
|
+
addEventListener(type: "open", listener: () => void): void;
|
|
38
|
+
addEventListener(type: "message", listener: (event: {
|
|
39
|
+
data: unknown;
|
|
40
|
+
}) => void): void;
|
|
41
|
+
addEventListener(type: "close", listener: () => void): void;
|
|
42
|
+
addEventListener(type: "close", listener: (event: {
|
|
43
|
+
code?: number;
|
|
44
|
+
reason?: string;
|
|
45
|
+
}) => void): void;
|
|
46
|
+
addEventListener(type: "error", listener: (event: {
|
|
47
|
+
message?: string;
|
|
48
|
+
}) => void): void;
|
|
37
49
|
/**
|
|
38
50
|
* Record a sent message without transmitting it.
|
|
39
51
|
*
|
|
@@ -56,7 +68,7 @@ export declare class MockWebSocket extends EventTarget {
|
|
|
56
68
|
/** Transition to `OPEN` state and dispatch an `"open"` event. */
|
|
57
69
|
open(): void;
|
|
58
70
|
/**
|
|
59
|
-
* Shorthand for {@
|
|
71
|
+
* Shorthand for {@link simulateMessage}.
|
|
60
72
|
*
|
|
61
73
|
* @param data - The message data to dispatch.
|
|
62
74
|
*/
|
|
@@ -79,7 +91,7 @@ export declare class MockWebSocket extends EventTarget {
|
|
|
79
91
|
sentJson(): Record<string, unknown>[];
|
|
80
92
|
}
|
|
81
93
|
/**
|
|
82
|
-
* Replace `globalThis.WebSocket` with {@
|
|
94
|
+
* Replace `globalThis.WebSocket` with {@link MockWebSocket} for testing.
|
|
83
95
|
*
|
|
84
96
|
* Returns a handle that tracks all created mock sockets and can restore the
|
|
85
97
|
* original `WebSocket` constructor. Supports the `using` declaration via
|
|
@@ -102,4 +114,3 @@ export declare function installMockWebSocket(): {
|
|
|
102
114
|
get lastWs(): MockWebSocket | null;
|
|
103
115
|
[Symbol.dispose]: () => void;
|
|
104
116
|
};
|
|
105
|
-
//# sourceMappingURL=_mock_ws.d.ts.map
|
package/dist/_mock-ws.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//#region _mock-ws.ts
|
|
2
|
+
/**
|
|
3
|
+
* A mock WebSocket implementation for testing.
|
|
4
|
+
*
|
|
5
|
+
* Extends `EventTarget` to simulate WebSocket behavior without a real
|
|
6
|
+
* network connection. Records all sent messages in the {@link sent}
|
|
7
|
+
* array and provides helper methods to simulate incoming messages,
|
|
8
|
+
* connection events, and errors.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const ws = new MockWebSocket("wss://example.com");
|
|
13
|
+
* ws.send(JSON.stringify({ type: "ping" }));
|
|
14
|
+
* ws.simulateMessage(JSON.stringify({ type: "pong" }));
|
|
15
|
+
* assertEquals(ws.sentJson(), [{ type: "ping" }]);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
var MockWebSocket = class MockWebSocket extends EventTarget {
|
|
19
|
+
static CONNECTING = 0;
|
|
20
|
+
static OPEN = 1;
|
|
21
|
+
static CLOSING = 2;
|
|
22
|
+
static CLOSED = 3;
|
|
23
|
+
readyState = MockWebSocket.CONNECTING;
|
|
24
|
+
binaryType = "arraybuffer";
|
|
25
|
+
/** All messages passed to {@link send}, in order. */
|
|
26
|
+
sent = [];
|
|
27
|
+
url;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new MockWebSocket.
|
|
30
|
+
*
|
|
31
|
+
* Automatically transitions to `OPEN` state on the next microtask,
|
|
32
|
+
* dispatching an `"open"` event.
|
|
33
|
+
*
|
|
34
|
+
* @param url - The WebSocket URL.
|
|
35
|
+
* @param _protocols - Ignored; accepted for API compatibility.
|
|
36
|
+
*/
|
|
37
|
+
constructor(url, _protocols) {
|
|
38
|
+
super();
|
|
39
|
+
this.url = typeof url === "string" ? url : url.toString();
|
|
40
|
+
queueMicrotask(() => {
|
|
41
|
+
if (this.readyState === MockWebSocket.CONNECTING) {
|
|
42
|
+
this.readyState = MockWebSocket.OPEN;
|
|
43
|
+
this.dispatchEvent(new Event("open"));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
addEventListener(type, listener) {
|
|
48
|
+
super.addEventListener(type, listener);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Record a sent message without transmitting it.
|
|
52
|
+
*
|
|
53
|
+
* @param data - The message data to record.
|
|
54
|
+
*/
|
|
55
|
+
send(data) {
|
|
56
|
+
this.sent.push(data);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Transition to `CLOSED` state and dispatch a `"close"` event.
|
|
60
|
+
*
|
|
61
|
+
* @param code - The close code (defaults to 1000).
|
|
62
|
+
* @param _reason - Ignored; accepted for API compatibility.
|
|
63
|
+
*/
|
|
64
|
+
close(code, _reason) {
|
|
65
|
+
this.readyState = MockWebSocket.CLOSED;
|
|
66
|
+
const ev = new Event("close");
|
|
67
|
+
ev.code = code ?? 1e3;
|
|
68
|
+
this.dispatchEvent(ev);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Simulate receiving a message from the server.
|
|
72
|
+
*
|
|
73
|
+
* @param data - The message data (string or binary).
|
|
74
|
+
*/
|
|
75
|
+
simulateMessage(data) {
|
|
76
|
+
this.dispatchEvent(new MessageEvent("message", { data }));
|
|
77
|
+
}
|
|
78
|
+
/** Transition to `OPEN` state and dispatch an `"open"` event. */
|
|
79
|
+
open() {
|
|
80
|
+
this.readyState = MockWebSocket.OPEN;
|
|
81
|
+
this.dispatchEvent(new Event("open"));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Shorthand for {@link simulateMessage}.
|
|
85
|
+
*
|
|
86
|
+
* @param data - The message data to dispatch.
|
|
87
|
+
*/
|
|
88
|
+
msg(data) {
|
|
89
|
+
this.simulateMessage(data);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Simulate a connection close from the server.
|
|
93
|
+
*
|
|
94
|
+
* @param code - The close code (defaults to 1000).
|
|
95
|
+
*/
|
|
96
|
+
disconnect(code = 1e3) {
|
|
97
|
+
const ev = new Event("close");
|
|
98
|
+
ev.code = code;
|
|
99
|
+
this.dispatchEvent(ev);
|
|
100
|
+
}
|
|
101
|
+
/** Dispatch an `"error"` event on this socket. */
|
|
102
|
+
error() {
|
|
103
|
+
this.dispatchEvent(new Event("error"));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Return all sent string messages parsed as JSON objects.
|
|
107
|
+
*
|
|
108
|
+
* Binary messages are filtered out.
|
|
109
|
+
*
|
|
110
|
+
* @returns An array of parsed JSON objects from sent string messages.
|
|
111
|
+
*/
|
|
112
|
+
sentJson() {
|
|
113
|
+
return this.sent.filter((d) => typeof d === "string").map((s) => JSON.parse(s));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const g = globalThis;
|
|
117
|
+
/**
|
|
118
|
+
* Replace `globalThis.WebSocket` with {@link MockWebSocket} for testing.
|
|
119
|
+
*
|
|
120
|
+
* Returns a handle that tracks all created mock sockets and can restore the
|
|
121
|
+
* original `WebSocket` constructor. Supports the `using` declaration via
|
|
122
|
+
* `Symbol.dispose` for automatic cleanup.
|
|
123
|
+
*
|
|
124
|
+
* @returns An object with `created` array, `lastWs` getter, `restore()`, and `[Symbol.dispose]()`.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* using mock = installMockWebSocket();
|
|
129
|
+
* const session = new Session("wss://example.com");
|
|
130
|
+
* const ws = mock.lastWs!;
|
|
131
|
+
* ws.simulateMessage(JSON.stringify({ type: "ready" }));
|
|
132
|
+
* // mock automatically restores WebSocket when disposed
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
function installMockWebSocket() {
|
|
136
|
+
const saved = globalThis.WebSocket;
|
|
137
|
+
const created = [];
|
|
138
|
+
g.WebSocket = class extends MockWebSocket {
|
|
139
|
+
constructor(url, protocols) {
|
|
140
|
+
super(url, protocols);
|
|
141
|
+
created.push(this);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
created,
|
|
146
|
+
get lastWs() {
|
|
147
|
+
return created.at(-1) ?? null;
|
|
148
|
+
},
|
|
149
|
+
restore() {
|
|
150
|
+
globalThis.WebSocket = saved;
|
|
151
|
+
},
|
|
152
|
+
[Symbol.dispose]() {
|
|
153
|
+
this.restore();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
export { MockWebSocket, installMockWebSocket };
|
package/dist/_utils.js
ADDED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These tools run inside the sandboxed worker alongside custom tools.
|
|
5
5
|
* Network requests go through the host's fetch proxy (with SSRF protection).
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
6
|
*/
|
|
9
7
|
import { z } from "zod";
|
|
10
|
-
import { type ToolSchema } from "./
|
|
8
|
+
import { type ToolSchema } from "./_internal-types.ts";
|
|
11
9
|
import { type ToolDef } from "./types.ts";
|
|
12
10
|
/** Callback for proxying vector search through the host RPC. */
|
|
13
11
|
export type VectorSearchFn = (query: string, topK: number) => Promise<string>;
|
|
@@ -46,16 +44,15 @@ export declare function memoryTools(): {
|
|
|
46
44
|
save_memory: ToolDef<z.ZodObject<{
|
|
47
45
|
key: z.ZodString;
|
|
48
46
|
value: z.ZodString;
|
|
49
|
-
}, z.core.$strip>,
|
|
47
|
+
}, z.core.$strip>, Record<string, unknown>>;
|
|
50
48
|
recall_memory: ToolDef<z.ZodObject<{
|
|
51
49
|
key: z.ZodString;
|
|
52
|
-
}, z.core.$strip>,
|
|
50
|
+
}, z.core.$strip>, Record<string, unknown>>;
|
|
53
51
|
list_memories: ToolDef<z.ZodObject<{
|
|
54
52
|
prefix: z.ZodOptional<z.ZodString>;
|
|
55
|
-
}, z.core.$strip>,
|
|
53
|
+
}, z.core.$strip>, Record<string, unknown>>;
|
|
56
54
|
forget_memory: ToolDef<z.ZodObject<{
|
|
57
55
|
key: z.ZodString;
|
|
58
|
-
}, z.core.$strip>,
|
|
56
|
+
}, z.core.$strip>, Record<string, unknown>>;
|
|
59
57
|
};
|
|
60
58
|
export {};
|
|
61
|
-
//# sourceMappingURL=builtin_tools.d.ts.map
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { tool } from "./types.js";
|
|
2
|
+
import { EMPTY_PARAMS } from "./_internal-types.js";
|
|
3
|
+
import { errorMessage } from "./_utils.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { convert } from "html-to-text";
|
|
6
|
+
//#region builtin-tools.ts
|
|
7
|
+
/**
|
|
8
|
+
* Built-in tool definitions for the AAI agent SDK.
|
|
9
|
+
*
|
|
10
|
+
* These tools run inside the sandboxed worker alongside custom tools.
|
|
11
|
+
* Network requests go through the host's fetch proxy (with SSRF protection).
|
|
12
|
+
*/
|
|
13
|
+
/** Per-fetch timeout for network tools — tighter than the overall tool timeout. */
|
|
14
|
+
const FETCH_TIMEOUT_MS = 15e3;
|
|
15
|
+
/** Timeout for sandboxed code execution. */
|
|
16
|
+
const RUN_CODE_TIMEOUT = 5e3;
|
|
17
|
+
/** Create a fetch timeout signal. */
|
|
18
|
+
function fetchSignal() {
|
|
19
|
+
return AbortSignal.timeout(FETCH_TIMEOUT_MS);
|
|
20
|
+
}
|
|
21
|
+
function htmlToText(html) {
|
|
22
|
+
return convert(html, { wordwrap: false });
|
|
23
|
+
}
|
|
24
|
+
const webSearchParams = z.object({
|
|
25
|
+
query: z.string().describe("The search query"),
|
|
26
|
+
max_results: z.number().describe("Maximum number of results to return (default 5)").optional()
|
|
27
|
+
});
|
|
28
|
+
const BRAVE_SEARCH_URL = "https://api.search.brave.com/res/v1/web/search";
|
|
29
|
+
const BraveSearchResponseSchema = z.object({ web: z.object({ results: z.array(z.object({
|
|
30
|
+
title: z.string(),
|
|
31
|
+
url: z.string(),
|
|
32
|
+
description: z.string()
|
|
33
|
+
})) }).optional() });
|
|
34
|
+
function createWebSearch(fetchFn = globalThis.fetch) {
|
|
35
|
+
return {
|
|
36
|
+
description: "Search the web for current information, facts, news, or answers to questions. Returns a list of results with title, URL, and description. Use this when the user asks about something you don't know, need up-to-date information, or want to verify facts.",
|
|
37
|
+
parameters: webSearchParams,
|
|
38
|
+
async execute(args, ctx) {
|
|
39
|
+
const { query, max_results: maxResults = 5 } = args;
|
|
40
|
+
const apiKey = ctx.env.BRAVE_API_KEY ?? "";
|
|
41
|
+
if (!apiKey) return { error: "BRAVE_API_KEY is not set — web search unavailable" };
|
|
42
|
+
const resp = await fetchFn(`${BRAVE_SEARCH_URL}?${new URLSearchParams({
|
|
43
|
+
q: query,
|
|
44
|
+
count: String(maxResults),
|
|
45
|
+
text_decorations: "false"
|
|
46
|
+
})}`, {
|
|
47
|
+
headers: { "X-Subscription-Token": apiKey },
|
|
48
|
+
signal: fetchSignal()
|
|
49
|
+
});
|
|
50
|
+
if (!resp.ok) return [];
|
|
51
|
+
const raw = await resp.json();
|
|
52
|
+
const data = BraveSearchResponseSchema.safeParse(raw);
|
|
53
|
+
if (!data.success) return [];
|
|
54
|
+
return (data.data.web?.results ?? []).slice(0, maxResults).map((r) => ({
|
|
55
|
+
title: r.title,
|
|
56
|
+
url: r.url,
|
|
57
|
+
description: r.description
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const MAX_PAGE_CHARS = 1e4;
|
|
63
|
+
const MAX_HTML_BYTES = 2e5;
|
|
64
|
+
const visitWebpageParams = z.object({ url: z.string().describe("The full URL to fetch (e.g., 'https://example.com/page')") });
|
|
65
|
+
function createVisitWebpage(fetchFn = globalThis.fetch) {
|
|
66
|
+
return {
|
|
67
|
+
description: "Fetch a webpage and return its content as clean text. Use this to read the full content of a URL found via web_search, or any link the user shares. Good for reading articles, documentation, blog posts, or product pages.",
|
|
68
|
+
parameters: visitWebpageParams,
|
|
69
|
+
async execute(args, _ctx) {
|
|
70
|
+
const { url } = args;
|
|
71
|
+
const resp = await fetchFn(url, {
|
|
72
|
+
headers: {
|
|
73
|
+
"User-Agent": "Mozilla/5.0 (compatible; VoiceAgent/1.0; +https://github.com/AssemblyAI/aai)",
|
|
74
|
+
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
|
|
75
|
+
},
|
|
76
|
+
redirect: "follow",
|
|
77
|
+
signal: fetchSignal()
|
|
78
|
+
});
|
|
79
|
+
if (!resp.ok) return {
|
|
80
|
+
error: `Failed to fetch: ${resp.status} ${resp.statusText}`,
|
|
81
|
+
url
|
|
82
|
+
};
|
|
83
|
+
const htmlContent = await resp.text();
|
|
84
|
+
const text = htmlToText(htmlContent.length > MAX_HTML_BYTES ? htmlContent.slice(0, MAX_HTML_BYTES) : htmlContent);
|
|
85
|
+
const truncated = text.length > MAX_PAGE_CHARS;
|
|
86
|
+
return {
|
|
87
|
+
url,
|
|
88
|
+
content: truncated ? text.slice(0, MAX_PAGE_CHARS) : text,
|
|
89
|
+
...truncated ? {
|
|
90
|
+
truncated: true,
|
|
91
|
+
totalChars: text.length
|
|
92
|
+
} : {}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const fetchJsonParams = z.object({
|
|
98
|
+
url: z.string().describe("The URL to fetch JSON from"),
|
|
99
|
+
headers: z.record(z.string(), z.string()).describe("Optional HTTP headers to include in the request").optional()
|
|
100
|
+
});
|
|
101
|
+
function createFetchJson(fetchFn = globalThis.fetch) {
|
|
102
|
+
return {
|
|
103
|
+
description: "Call a REST API endpoint via HTTP GET and return the JSON response. Use this to fetch structured data from APIs — for example, weather data, stock prices, exchange rates, or any public JSON API. Supports custom headers for authenticated APIs.",
|
|
104
|
+
parameters: fetchJsonParams,
|
|
105
|
+
async execute(args, _ctx) {
|
|
106
|
+
const { url, headers } = args;
|
|
107
|
+
const resp = await fetchFn(url, {
|
|
108
|
+
...headers && { headers },
|
|
109
|
+
signal: fetchSignal()
|
|
110
|
+
});
|
|
111
|
+
if (!resp.ok) return {
|
|
112
|
+
error: `HTTP ${resp.status} ${resp.statusText}`,
|
|
113
|
+
url
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
return await resp.json();
|
|
117
|
+
} catch {
|
|
118
|
+
return {
|
|
119
|
+
error: "Response was not valid JSON",
|
|
120
|
+
url
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const runCodeParams = z.object({ code: z.string().describe("JavaScript code to execute. Use console.log() for output.") });
|
|
127
|
+
function createRunCode() {
|
|
128
|
+
return {
|
|
129
|
+
description: "Execute JavaScript code in a secure sandbox and return the output. Use this for calculations, data transformations, string manipulation, or any task that benefits from running code. Output is captured from console.log(). No network or filesystem access.",
|
|
130
|
+
parameters: runCodeParams,
|
|
131
|
+
async execute(args) {
|
|
132
|
+
const { code } = args;
|
|
133
|
+
const output = [];
|
|
134
|
+
function capture(...captureArgs) {
|
|
135
|
+
output.push(captureArgs.map(String).join(" "));
|
|
136
|
+
}
|
|
137
|
+
const fakeConsole = {
|
|
138
|
+
log: capture,
|
|
139
|
+
info: capture,
|
|
140
|
+
warn: capture,
|
|
141
|
+
error: capture,
|
|
142
|
+
debug: capture
|
|
143
|
+
};
|
|
144
|
+
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
|
|
145
|
+
try {
|
|
146
|
+
const fn = new AsyncFunction("console", code);
|
|
147
|
+
await Promise.race([fn(fakeConsole), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Code execution timed out")), RUN_CODE_TIMEOUT))]);
|
|
148
|
+
return output.join("\n").trim() || "Code ran successfully (no output)";
|
|
149
|
+
} catch (err) {
|
|
150
|
+
return { error: errorMessage(err) };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const vectorSearchParams = z.object({
|
|
156
|
+
query: z.string().describe("Short keyword query to search the knowledge base. Use specific topic terms, not full sentences. Do NOT include the company or product name since all documents are from the same source. For example, if the user asks \"how much does Acme cost\", search for \"pricing plans rates\"."),
|
|
157
|
+
topK: z.number().describe("Maximum results to return (default: 5)").optional()
|
|
158
|
+
});
|
|
159
|
+
function createVectorSearch(vectorSearchFn) {
|
|
160
|
+
return {
|
|
161
|
+
description: "Search the agent's knowledge base for relevant information. Use this when the user asks a question that might be answered by previously ingested documents or data. Returns the most relevant matches ranked by similarity.",
|
|
162
|
+
parameters: vectorSearchParams,
|
|
163
|
+
async execute(args) {
|
|
164
|
+
const { query, topK = 5 } = args;
|
|
165
|
+
return vectorSearchFn(query, topK);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** Single-tool creators and multi-tool expanders in one registry. */
|
|
170
|
+
const TOOL_REGISTRY = {
|
|
171
|
+
web_search: { create: (opts) => createWebSearch(opts?.fetch) },
|
|
172
|
+
visit_webpage: { create: (opts) => createVisitWebpage(opts?.fetch) },
|
|
173
|
+
fetch_json: { create: (opts) => createFetchJson(opts?.fetch) },
|
|
174
|
+
run_code: { create: createRunCode },
|
|
175
|
+
vector_search: { create: (opts) => createVectorSearch(opts?.vectorSearch ?? (async () => "")) },
|
|
176
|
+
memory: { multi: memoryTools }
|
|
177
|
+
};
|
|
178
|
+
/** Resolve a builtin name to an array of [toolName, ToolDef] pairs. */
|
|
179
|
+
function resolveBuiltin(name, opts) {
|
|
180
|
+
const entry = TOOL_REGISTRY[name];
|
|
181
|
+
if (!entry) return [];
|
|
182
|
+
if ("multi" in entry) return Object.entries(entry.multi());
|
|
183
|
+
if (name === "vector_search" && !opts?.vectorSearch) return [];
|
|
184
|
+
return [[name, entry.create(opts)]];
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Create built-in tool definitions for the given tool names.
|
|
188
|
+
* For runtime use — vector_search requires opts.vectorSearch to be included.
|
|
189
|
+
*/
|
|
190
|
+
function getBuiltinToolDefs(names, opts) {
|
|
191
|
+
const defs = {};
|
|
192
|
+
for (const name of names) for (const [k, v] of resolveBuiltin(name, opts)) defs[k] = v;
|
|
193
|
+
return defs;
|
|
194
|
+
}
|
|
195
|
+
/** Returns JSON tool schemas for the specified builtin tools. */
|
|
196
|
+
function getBuiltinToolSchemas(names) {
|
|
197
|
+
return names.flatMap((name) => resolveBuiltin(name, { vectorSearch: async () => "" }).map(([toolName, def]) => ({
|
|
198
|
+
name: toolName,
|
|
199
|
+
description: def.description,
|
|
200
|
+
parameters: z.toJSONSchema(def.parameters ?? EMPTY_PARAMS)
|
|
201
|
+
})));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns a standard set of KV-backed memory tools: `save_memory`,
|
|
205
|
+
* `recall_memory`, `list_memories`, and `forget_memory`.
|
|
206
|
+
*
|
|
207
|
+
* Spread the result into your agent's `tools` record.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* import { defineAgent, memoryTools } from "aai";
|
|
212
|
+
*
|
|
213
|
+
* export default defineAgent({
|
|
214
|
+
* name: "My Agent",
|
|
215
|
+
* tools: { ...memoryTools() },
|
|
216
|
+
* });
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
function memoryTools() {
|
|
220
|
+
return {
|
|
221
|
+
save_memory: tool({
|
|
222
|
+
description: "Save a piece of information to persistent memory. Use a descriptive key like 'user:name' or 'project:status'.",
|
|
223
|
+
parameters: z.object({
|
|
224
|
+
key: z.string().describe("A descriptive key for this memory (e.g. 'user:name', 'preference:color')"),
|
|
225
|
+
value: z.string().describe("The information to remember")
|
|
226
|
+
}),
|
|
227
|
+
execute: async ({ key, value }, ctx) => {
|
|
228
|
+
await ctx.kv.set(key, value);
|
|
229
|
+
return { saved: key };
|
|
230
|
+
}
|
|
231
|
+
}),
|
|
232
|
+
recall_memory: tool({
|
|
233
|
+
description: "Retrieve a previously saved memory by its key.",
|
|
234
|
+
parameters: z.object({ key: z.string().describe("The key to look up") }),
|
|
235
|
+
execute: async ({ key }, ctx) => {
|
|
236
|
+
const value = await ctx.kv.get(key);
|
|
237
|
+
if (value === null) return {
|
|
238
|
+
found: false,
|
|
239
|
+
key
|
|
240
|
+
};
|
|
241
|
+
return {
|
|
242
|
+
found: true,
|
|
243
|
+
key,
|
|
244
|
+
value
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
list_memories: tool({
|
|
249
|
+
description: "List all saved memory keys, optionally filtered by a prefix (e.g. 'user:').",
|
|
250
|
+
parameters: z.object({ prefix: z.string().describe("Prefix to filter keys (e.g. 'user:'). Use empty string for all.").optional() }),
|
|
251
|
+
execute: async ({ prefix }, ctx) => {
|
|
252
|
+
const entries = await ctx.kv.list(prefix ?? "");
|
|
253
|
+
return {
|
|
254
|
+
count: entries.length,
|
|
255
|
+
keys: entries.map((e) => e.key)
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}),
|
|
259
|
+
forget_memory: tool({
|
|
260
|
+
description: "Delete a previously saved memory by its key.",
|
|
261
|
+
parameters: z.object({ key: z.string().describe("The key to delete") }),
|
|
262
|
+
execute: async ({ key }, ctx) => {
|
|
263
|
+
await ctx.kv.delete(key);
|
|
264
|
+
return { deleted: key };
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
export { getBuiltinToolDefs, getBuiltinToolSchemas, memoryTools };
|
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* In self-hosted mode, agent code is trusted (you're running your own code).
|
|
5
5
|
* Tools execute directly in-process — no sandbox, no RPC.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
6
|
*/
|
|
9
|
-
import { type AgentConfig, type ToolSchema } from "./
|
|
7
|
+
import { type AgentConfig, type ToolSchema } from "./_internal-types.ts";
|
|
10
8
|
import type { Kv } from "./kv.ts";
|
|
11
9
|
import type { ClientSink } from "./protocol.ts";
|
|
12
|
-
import type { Logger,
|
|
10
|
+
import type { Logger, S2SConfig } from "./runtime.ts";
|
|
13
11
|
import type { CreateS2sWebSocket } from "./s2s.ts";
|
|
14
12
|
import { type HookInvoker, type Session } from "./session.ts";
|
|
15
13
|
import type { AgentDef } from "./types.ts";
|
|
16
14
|
import type { VectorStore } from "./vector.ts";
|
|
17
|
-
import type { ExecuteTool } from "./
|
|
15
|
+
import type { ExecuteTool } from "./worker-entry.ts";
|
|
18
16
|
export type DirectExecutorOptions = {
|
|
19
17
|
agent: AgentDef;
|
|
20
18
|
env: Record<string, string>;
|
|
@@ -23,7 +21,6 @@ export type DirectExecutorOptions = {
|
|
|
23
21
|
vectorSearch?: ((query: string, topK: number) => Promise<string>) | undefined;
|
|
24
22
|
createWebSocket?: CreateS2sWebSocket | undefined;
|
|
25
23
|
logger?: Logger | undefined;
|
|
26
|
-
metrics?: Metrics | undefined;
|
|
27
24
|
s2sConfig?: S2SConfig | undefined;
|
|
28
25
|
};
|
|
29
26
|
export type DirectExecutor = {
|
|
@@ -41,4 +38,3 @@ export type DirectExecutor = {
|
|
|
41
38
|
export declare function buildAgentConfig(agent: AgentDef): AgentConfig;
|
|
42
39
|
/** Create a direct (in-process) tool executor and hook invoker for an agent. */
|
|
43
40
|
export declare function createDirectExecutor(opts: DirectExecutorOptions): DirectExecutor;
|
|
44
|
-
//# sourceMappingURL=direct_executor.d.ts.map
|