@alexkroman1/aai 1.7.0 → 1.8.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/.turbo/turbo-build.log +11 -9
- package/CHANGELOG.md +16 -0
- package/dist/{_internal-types-CrnTi9Ew.js → _internal-types-CfOAbK6V.js} +22 -35
- package/dist/constants-y68COEGj.js +29 -0
- package/dist/host/_base64.d.ts +2 -0
- package/dist/host/_mock-ws.d.ts +0 -61
- package/dist/host/_pipeline-test-fakes.d.ts +7 -4
- package/dist/host/_run-code.d.ts +0 -25
- package/dist/host/_runtime-conformance.d.ts +3 -34
- package/dist/host/memory-vector.d.ts +0 -11
- package/dist/host/providers/resolve-kv.d.ts +0 -7
- package/dist/host/providers/resolve-vector.d.ts +0 -8
- package/dist/host/providers/stt/assemblyai.d.ts +0 -14
- package/dist/host/providers/stt/deepgram.d.ts +2 -14
- package/dist/host/providers/stt/soniox.d.ts +0 -22
- package/dist/host/providers/tts/rime.d.ts +10 -31
- package/dist/host/runtime-barrel.js +628 -642
- package/dist/host/runtime-config.d.ts +9 -6
- package/dist/host/runtime.d.ts +3 -0
- package/dist/host/to-vercel-tools.d.ts +3 -33
- package/dist/host/transports/openai-realtime-transport.d.ts +43 -0
- package/dist/host/unstorage-kv.d.ts +0 -26
- package/dist/index.js +3 -3
- package/dist/openai-realtime-cjPAHMMx.js +10 -0
- package/dist/sdk/_internal-types.d.ts +6 -55
- package/dist/sdk/allowed-hosts.d.ts +4 -3
- package/dist/sdk/constants.d.ts +4 -29
- package/dist/sdk/define.d.ts +7 -4
- package/dist/sdk/kv.d.ts +13 -37
- package/dist/sdk/manifest-barrel.js +1 -1
- package/dist/sdk/manifest.d.ts +8 -2
- package/dist/sdk/protocol.js +1 -1
- package/dist/sdk/providers/s2s/openai-realtime.d.ts +17 -0
- package/dist/sdk/providers/s2s-barrel.d.ts +9 -0
- package/dist/sdk/providers/s2s-barrel.js +2 -0
- package/dist/sdk/providers/tts/rime.d.ts +1 -1
- package/dist/sdk/providers.d.ts +6 -2
- package/dist/sdk/types.d.ts +7 -1
- package/dist/{types-KUgezM6u.js → types-DOWVZhb9.js} +1 -7
- package/dist/{ws-upgrade-BeOQ7fXL.js → ws-upgrade-CG8-by1n.js} +2 -3
- package/host/_base64.ts +9 -0
- package/host/_mock-ws.ts +0 -65
- package/host/_pipeline-test-fakes.ts +19 -31
- package/host/_run-code.ts +10 -53
- package/host/_runtime-conformance.ts +3 -44
- package/host/_test-utils.ts +20 -42
- package/host/builtin-tools.test.ts +127 -222
- package/host/builtin-tools.ts +6 -10
- package/host/cleanup.test.ts +30 -73
- package/host/integration/pipeline-reference.integration.test.ts +12 -17
- package/host/integration.test.ts +0 -7
- package/host/memory-vector.test.ts +3 -1
- package/host/memory-vector.ts +16 -21
- package/host/pinecone-vector.test.ts +14 -17
- package/host/pinecone-vector.ts +10 -19
- package/host/providers/providers.test-d.ts +5 -3
- package/host/providers/resolve-kv.ts +23 -41
- package/host/providers/resolve-vector.ts +3 -12
- package/host/providers/resolve.test.ts +15 -28
- package/host/providers/resolve.ts +24 -24
- package/host/providers/stt/assemblyai.test.ts +2 -14
- package/host/providers/stt/assemblyai.ts +12 -35
- package/host/providers/stt/deepgram.test.ts +23 -83
- package/host/providers/stt/deepgram.ts +15 -40
- package/host/providers/stt/elevenlabs.test.ts +26 -38
- package/host/providers/stt/elevenlabs.ts +10 -9
- package/host/providers/stt/soniox.test.ts +35 -85
- package/host/providers/stt/soniox.ts +8 -53
- package/host/providers/tts/cartesia.test.ts +19 -58
- package/host/providers/tts/cartesia.ts +36 -66
- package/host/providers/tts/rime.test.ts +12 -38
- package/host/providers/tts/rime.ts +23 -86
- package/host/runtime-config.test.ts +9 -9
- package/host/runtime-config.ts +16 -22
- package/host/runtime.test.ts +111 -73
- package/host/runtime.ts +138 -86
- package/host/s2s.test.ts +92 -191
- package/host/s2s.ts +56 -53
- package/host/server-shutdown.test.ts +9 -30
- package/host/server.test.ts +2 -13
- package/host/server.ts +85 -100
- package/host/session-core.test.ts +15 -30
- package/host/session-core.ts +10 -13
- package/host/session-prompt.test.ts +1 -5
- package/host/to-vercel-tools.test.ts +53 -72
- package/host/to-vercel-tools.ts +9 -39
- package/host/tool-executor.test.ts +25 -51
- package/host/tool-executor.ts +18 -12
- package/host/transports/openai-realtime-transport.test.ts +371 -0
- package/host/transports/openai-realtime-transport.ts +319 -0
- package/host/transports/pipeline-transport.test.ts +125 -298
- package/host/transports/pipeline-transport.ts +20 -68
- package/host/transports/s2s-transport-fixtures.test.ts +31 -92
- package/host/transports/s2s-transport.test.ts +65 -134
- package/host/transports/s2s-transport.ts +15 -43
- package/host/transports/types.test.ts +4 -8
- package/host/unstorage-kv.test.ts +3 -2
- package/host/unstorage-kv.ts +5 -35
- package/host/ws-handler.test.ts +72 -176
- package/host/ws-handler.ts +6 -12
- package/package.json +6 -1
- package/sdk/__snapshots__/exports.test.ts.snap +7 -0
- package/sdk/__snapshots__/schema-shapes.test.ts.snap +1 -0
- package/sdk/_internal-types.test.ts +6 -9
- package/sdk/_internal-types.ts +16 -57
- package/sdk/_test-matchers.ts +25 -15
- package/sdk/allowed-hosts.test.ts +50 -114
- package/sdk/allowed-hosts.ts +8 -14
- package/sdk/constants.ts +5 -52
- package/sdk/define.test.ts +7 -6
- package/sdk/define.ts +7 -3
- package/sdk/exports.test.ts +6 -1
- package/sdk/kv.ts +13 -37
- package/sdk/manifest.test-d.ts +5 -0
- package/sdk/manifest.test.ts +61 -9
- package/sdk/manifest.ts +11 -11
- package/sdk/protocol-compat.test.ts +66 -98
- package/sdk/protocol-snapshot.test.ts +2 -16
- package/sdk/protocol.test.ts +13 -22
- package/sdk/providers/s2s/openai-realtime.ts +36 -0
- package/sdk/providers/s2s-barrel.ts +12 -0
- package/sdk/providers/tts/rime.ts +1 -1
- package/sdk/providers.ts +24 -5
- package/sdk/schema-alignment.test.ts +25 -73
- package/sdk/schema-shapes.test.ts +1 -29
- package/sdk/system-prompt.test.ts +0 -1
- package/sdk/system-prompt.ts +17 -19
- package/sdk/types-inference.test.ts +10 -36
- package/sdk/types.ts +7 -0
- package/sdk/ws-upgrade.test.ts +24 -23
- package/sdk/ws-upgrade.ts +2 -3
- package/tsdown.config.ts +8 -11
- package/dist/constants-C2nirZUI.js +0 -54
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Structured context attached to log messages. */
|
|
2
2
|
export type LogContext = Record<string, unknown>;
|
|
3
|
+
type LogLevel = "info" | "warn" | "error" | "debug";
|
|
4
|
+
type LogFn = (msg: string, ctx?: LogContext) => void;
|
|
3
5
|
/**
|
|
4
6
|
* Structured logger interface. Used by tests to suppress output and by
|
|
5
7
|
* consumers to plug in custom logging backends.
|
|
@@ -15,14 +17,14 @@ export type LogContext = Record<string, unknown>;
|
|
|
15
17
|
* createServer({ agent, logger: myLogger });
|
|
16
18
|
* ```
|
|
17
19
|
*/
|
|
18
|
-
export type Logger =
|
|
19
|
-
info(msg: string, ctx?: LogContext): void;
|
|
20
|
-
warn(msg: string, ctx?: LogContext): void;
|
|
21
|
-
error(msg: string, ctx?: LogContext): void;
|
|
22
|
-
debug(msg: string, ctx?: LogContext): void;
|
|
23
|
-
};
|
|
20
|
+
export type Logger = Record<LogLevel, LogFn>;
|
|
24
21
|
/** Default console-backed logger. */
|
|
25
22
|
export declare const consoleLogger: Logger;
|
|
23
|
+
/**
|
|
24
|
+
* Structured JSON logger for production diagnostics. Each log entry is a
|
|
25
|
+
* single-line JSON object with `timestamp`, `level`, `msg`, and any
|
|
26
|
+
* caller-provided context fields.
|
|
27
|
+
*/
|
|
26
28
|
export declare const jsonLogger: Logger;
|
|
27
29
|
/**
|
|
28
30
|
* Speech-to-Speech (S2S) endpoint configuration.
|
|
@@ -40,3 +42,4 @@ export type S2SConfig = {
|
|
|
40
42
|
};
|
|
41
43
|
/** Default S2S endpoint configuration. */
|
|
42
44
|
export declare const DEFAULT_S2S_CONFIG: S2SConfig;
|
|
45
|
+
export {};
|
package/dist/host/runtime.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { Logger, S2SConfig } from "./runtime-config.ts";
|
|
|
17
17
|
import type { CreateS2sWebSocket } from "./s2s.ts";
|
|
18
18
|
import { type SessionCore } from "./session-core.ts";
|
|
19
19
|
import { type ExecuteTool } from "./tool-executor.ts";
|
|
20
|
+
import { type CreateOpenaiRealtimeWebSocket } from "./transports/openai-realtime-transport.ts";
|
|
20
21
|
import { type SessionWebSocket } from "./ws-handler.ts";
|
|
21
22
|
/** Per-session options passed to {@link AgentRuntime.startSession}. */
|
|
22
23
|
export type SessionStartOptions = {
|
|
@@ -58,6 +59,8 @@ export type RuntimeOptions = {
|
|
|
58
59
|
vector?: Vector | undefined;
|
|
59
60
|
/** Custom WebSocket factory for the S2S connection (useful for testing). */
|
|
60
61
|
createWebSocket?: CreateS2sWebSocket | undefined;
|
|
62
|
+
/** Custom WebSocket factory for the OpenAI Realtime connection (testing). */
|
|
63
|
+
createOpenaiRealtimeWebSocket?: CreateOpenaiRealtimeWebSocket | undefined;
|
|
61
64
|
logger?: Logger | undefined;
|
|
62
65
|
s2sConfig?: S2SConfig | undefined;
|
|
63
66
|
/**
|
|
@@ -1,45 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts agent {@link ToolSchema}[] to Vercel AI SDK tools
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* The pipeline orchestrator passes the output to `streamText({ tools })`.
|
|
6
|
-
* Each produced tool's `execute` closure calls
|
|
7
|
-
* `ctx.executeTool(name, args, sessionId, messages(), { signal, toolCallId })`,
|
|
8
|
-
* so the existing agent tool infrastructure (argument validation, KV, hooks,
|
|
9
|
-
* timeout) remains the single source of truth for tool behavior.
|
|
10
|
-
*
|
|
11
|
-
* Per-call `options.abortSignal` (forwarded by `streamText` when the
|
|
12
|
-
* outer turn is aborted, e.g. barge-in) takes precedence over the
|
|
13
|
-
* bag-level `ctx.signal` so individual invocations respect streamText
|
|
14
|
-
* aborts.
|
|
2
|
+
* Converts agent {@link ToolSchema}[] to Vercel AI SDK tools, delegating
|
|
3
|
+
* `execute` to the agent's {@link ExecuteTool} so validation, KV, hooks,
|
|
4
|
+
* and timeouts remain the single source of truth for tool behavior.
|
|
15
5
|
*/
|
|
16
6
|
import { type Tool } from "ai";
|
|
17
7
|
import type { ExecuteTool, ToolSchema } from "../sdk/_internal-types.ts";
|
|
18
8
|
import type { Message } from "../sdk/types.ts";
|
|
19
9
|
export interface ToVercelToolsContext {
|
|
20
|
-
/** The agent's tool-execution function (from the runtime). */
|
|
21
10
|
executeTool: ExecuteTool;
|
|
22
|
-
/** Session id threaded to {@link executeTool}. */
|
|
23
11
|
sessionId: string;
|
|
24
|
-
/**
|
|
25
|
-
* Returns the current conversation history at call-time. The orchestrator
|
|
26
|
-
* calls this per invocation; `toVercelTools` snapshots the returned array
|
|
27
|
-
* before forwarding to `executeTool` so concurrent mutations cannot leak
|
|
28
|
-
* across tool calls.
|
|
29
|
-
*/
|
|
30
12
|
messages: () => readonly Message[];
|
|
31
|
-
/**
|
|
32
|
-
* Bag-level abort signal. Used as a fallback when the per-call
|
|
33
|
-
* `options.abortSignal` from Vercel's `ToolExecutionOptions` is absent.
|
|
34
|
-
*/
|
|
35
13
|
signal?: AbortSignal;
|
|
36
14
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Convert an array of {@link ToolSchema} to a Vercel AI SDK `ToolSet`
|
|
39
|
-
* (record keyed by tool name).
|
|
40
|
-
*
|
|
41
|
-
* Uses the v6 `tool()` helper with `inputSchema: jsonSchema(...)` wrapping
|
|
42
|
-
* the agent's JSON Schema `parameters`. Execution is delegated to
|
|
43
|
-
* `ctx.executeTool` so validation, KV, timeouts, and hooks keep working.
|
|
44
|
-
*/
|
|
45
15
|
export declare function toVercelTools(schemas: readonly ToolSchema[], ctx: ToVercelToolsContext): Record<string, Tool>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { JSONSchema7 } from "json-schema";
|
|
2
|
+
import type { OpenaiRealtimeOptions } from "../../sdk/providers/s2s/openai-realtime.ts";
|
|
3
|
+
import type { Logger } from "../runtime-config.ts";
|
|
4
|
+
import type { Transport, TransportCallbacks, TransportSessionConfig } from "./types.ts";
|
|
5
|
+
export type OpenaiRealtimeWebSocket = {
|
|
6
|
+
readonly readyState: number;
|
|
7
|
+
send(data: string): void;
|
|
8
|
+
close(): void;
|
|
9
|
+
addEventListener(type: "open", fn: () => void): void;
|
|
10
|
+
addEventListener(type: "message", fn: (ev: {
|
|
11
|
+
data: unknown;
|
|
12
|
+
}) => void): void;
|
|
13
|
+
addEventListener(type: "close", fn: (ev: {
|
|
14
|
+
code?: number;
|
|
15
|
+
reason?: string;
|
|
16
|
+
}) => void): void;
|
|
17
|
+
addEventListener(type: "error", fn: (ev: {
|
|
18
|
+
message?: string;
|
|
19
|
+
}) => void): void;
|
|
20
|
+
};
|
|
21
|
+
export type CreateOpenaiRealtimeWebSocket = (url: string, opts: {
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
}) => OpenaiRealtimeWebSocket;
|
|
24
|
+
export declare const defaultCreateOpenaiRealtimeWebSocket: CreateOpenaiRealtimeWebSocket;
|
|
25
|
+
export type OpenaiRealtimeToolSchema = {
|
|
26
|
+
type: "function";
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
parameters: JSONSchema7;
|
|
30
|
+
};
|
|
31
|
+
export type OpenaiRealtimeTransportOptions = {
|
|
32
|
+
apiKey: string;
|
|
33
|
+
options: OpenaiRealtimeOptions;
|
|
34
|
+
sessionConfig: TransportSessionConfig;
|
|
35
|
+
toolSchemas: OpenaiRealtimeToolSchema[];
|
|
36
|
+
toolChoice: "auto" | "required";
|
|
37
|
+
callbacks: TransportCallbacks;
|
|
38
|
+
sid: string;
|
|
39
|
+
agent: string;
|
|
40
|
+
createWebSocket?: CreateOpenaiRealtimeWebSocket;
|
|
41
|
+
logger?: Logger;
|
|
42
|
+
};
|
|
43
|
+
export declare function createOpenaiRealtimeTransport(opts: OpenaiRealtimeTransportOptions): Transport;
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key-value store backed by unstorage.
|
|
3
|
-
*
|
|
4
|
-
* Works with any unstorage driver (memory, fs, S3/R2, etc.).
|
|
5
|
-
*/
|
|
6
1
|
import { type Storage } from "unstorage";
|
|
7
2
|
import type { Kv } from "../sdk/kv.ts";
|
|
8
|
-
/**
|
|
9
|
-
* Options for creating an unstorage-backed KV store.
|
|
10
|
-
*/
|
|
11
3
|
export type UnstorageKvOptions = {
|
|
12
|
-
/** Configured unstorage Storage instance. */
|
|
13
4
|
storage: Storage;
|
|
14
|
-
/** Key prefix prepended to all operations (e.g. `"agents/my-agent/kv"`). */
|
|
15
5
|
prefix?: string;
|
|
16
6
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Create a KV store backed by any unstorage driver.
|
|
19
|
-
*
|
|
20
|
-
* @param options - See {@link UnstorageKvOptions}.
|
|
21
|
-
* @returns A {@link Kv} instance.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { createStorage } from "unstorage";
|
|
26
|
-
* import { createUnstorageKv } from "@alexkroman1/aai/unstorage-kv";
|
|
27
|
-
*
|
|
28
|
-
* const kv = createUnstorageKv({ storage: createStorage() });
|
|
29
|
-
* await kv.set("greeting", "hello");
|
|
30
|
-
* const value = await kv.get<string>("greeting"); // "hello"
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
7
|
export declare function createUnstorageKv(options: UnstorageKvOptions): Kv;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as matchesAllowedHost, i as ToolChoiceSchema, n as DEFAULT_GREETING, o as validateAllowedHostPattern, r as DEFAULT_SYSTEM_PROMPT, t as BuiltinToolSchema } from "./types-
|
|
2
|
-
import { _ as TOOL_EXECUTION_TIMEOUT_MS, a as DEFAULT_SHUTDOWN_TIMEOUT_MS, c as FETCH_TIMEOUT_MS, d as MAX_PAGE_CHARS, f as MAX_TOOL_RESULT_CHARS, g as RUN_CODE_TIMEOUT_MS, h as PIPELINE_FLUSH_TIMEOUT_MS, i as DEFAULT_SESSION_START_TIMEOUT_MS, l as MAX_HTML_BYTES, m as MAX_WS_PAYLOAD_BYTES, n as DEFAULT_IDLE_TIMEOUT_MS, o as DEFAULT_STT_SAMPLE_RATE, p as MAX_VALUE_SIZE, r as DEFAULT_MAX_HISTORY, s as DEFAULT_TTS_SAMPLE_RATE, t as AGENT_CSP, u as MAX_MESSAGE_BUFFER_SIZE, v as WS_OPEN } from "./constants-
|
|
3
|
-
import { i as toolError, n as errorDetail, r as errorMessage, t as parseWsUpgradeParams } from "./ws-upgrade-
|
|
1
|
+
import { a as matchesAllowedHost, i as ToolChoiceSchema, n as DEFAULT_GREETING, o as validateAllowedHostPattern, r as DEFAULT_SYSTEM_PROMPT, t as BuiltinToolSchema } from "./types-DOWVZhb9.js";
|
|
2
|
+
import { _ as TOOL_EXECUTION_TIMEOUT_MS, a as DEFAULT_SHUTDOWN_TIMEOUT_MS, c as FETCH_TIMEOUT_MS, d as MAX_PAGE_CHARS, f as MAX_TOOL_RESULT_CHARS, g as RUN_CODE_TIMEOUT_MS, h as PIPELINE_FLUSH_TIMEOUT_MS, i as DEFAULT_SESSION_START_TIMEOUT_MS, l as MAX_HTML_BYTES, m as MAX_WS_PAYLOAD_BYTES, n as DEFAULT_IDLE_TIMEOUT_MS, o as DEFAULT_STT_SAMPLE_RATE, p as MAX_VALUE_SIZE, r as DEFAULT_MAX_HISTORY, s as DEFAULT_TTS_SAMPLE_RATE, t as AGENT_CSP, u as MAX_MESSAGE_BUFFER_SIZE, v as WS_OPEN } from "./constants-y68COEGj.js";
|
|
3
|
+
import { i as toolError, n as errorDetail, r as errorMessage, t as parseWsUpgradeParams } from "./ws-upgrade-CG8-by1n.js";
|
|
4
4
|
//#region sdk/define.ts
|
|
5
5
|
/**
|
|
6
6
|
* Define a tool with typed parameters and execute function.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region sdk/providers/s2s/openai-realtime.ts
|
|
2
|
+
const OPENAI_REALTIME_KIND = "openai-realtime";
|
|
3
|
+
function openaiRealtime(opts = {}) {
|
|
4
|
+
return {
|
|
5
|
+
kind: OPENAI_REALTIME_KIND,
|
|
6
|
+
options: { ...opts }
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { openaiRealtime as n, OPENAI_REALTIME_KIND as t };
|
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal type definitions shared by server and CLI.
|
|
3
|
-
*
|
|
4
|
-
* Note: this module is for internal use only and should not be used directly.
|
|
5
|
-
*/
|
|
6
1
|
import type { JSONSchema7 } from "json-schema";
|
|
7
2
|
import { z } from "zod";
|
|
8
|
-
import { type KvProvider, type LlmProvider, type SttProvider, type TtsProvider, type VectorProvider } from "./providers.ts";
|
|
3
|
+
import { type KvProvider, type LlmProvider, type S2sProvider, type SttProvider, type TtsProvider, type VectorProvider } from "./providers.ts";
|
|
9
4
|
import type { Message } from "./types.ts";
|
|
10
5
|
import { type ToolDef } from "./types.ts";
|
|
11
|
-
/**
|
|
12
|
-
* Options forwarded to an {@link ExecuteTool} invocation.
|
|
13
|
-
*
|
|
14
|
-
* Primarily used by the pipeline orchestrator (streamText tool loop) to
|
|
15
|
-
* thread an {@link AbortSignal} into tool execution. The S2S voice path
|
|
16
|
-
* does not pass these options today — recipients must treat the whole
|
|
17
|
-
* bag as optional.
|
|
18
|
-
*/
|
|
19
6
|
export interface ExecuteToolOptions {
|
|
20
|
-
/** Abort signal bound to the enclosing LLM turn / request. */
|
|
21
7
|
signal?: AbortSignal;
|
|
22
|
-
/** Vercel AI SDK tool-call ID for this invocation. Useful for tracing and correlation. */
|
|
23
8
|
toolCallId?: string;
|
|
24
9
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Function signature for executing a tool by name.
|
|
27
|
-
*
|
|
28
|
-
* Used by session.ts to invoke tools, by direct-executor.ts and
|
|
29
|
-
* harness-runtime.ts to implement the execution.
|
|
30
|
-
*/
|
|
31
10
|
export type ExecuteTool = (name: string, args: Readonly<Record<string, unknown>>, sessionId?: string, messages?: readonly Message[], opts?: ExecuteToolOptions) => Promise<string>;
|
|
32
|
-
/**
|
|
33
|
-
* Zod schema for serializable agent configuration sent over the wire.
|
|
34
|
-
*
|
|
35
|
-
* This is the JSON-safe subset of the agent definition that can be
|
|
36
|
-
* transmitted between the worker and the host process via structured clone.
|
|
37
|
-
*/
|
|
38
11
|
export declare const AgentConfigSchema: z.ZodObject<{
|
|
39
12
|
name: z.ZodString;
|
|
40
13
|
systemPrompt: z.ZodString;
|
|
@@ -64,6 +37,10 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
64
37
|
kind: z.ZodString;
|
|
65
38
|
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
66
39
|
}, z.core.$strip>>;
|
|
40
|
+
s2s: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
kind: z.ZodString;
|
|
42
|
+
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
67
44
|
mode: z.ZodOptional<z.ZodEnum<{
|
|
68
45
|
s2s: "s2s";
|
|
69
46
|
pipeline: "pipeline";
|
|
@@ -77,13 +54,7 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
77
54
|
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
78
55
|
}, z.core.$strip>>;
|
|
79
56
|
}, z.core.$strip>;
|
|
80
|
-
/** Serializable agent configuration — derived from {@link AgentConfigSchema}. */
|
|
81
57
|
export type AgentConfig = z.infer<typeof AgentConfigSchema>;
|
|
82
|
-
/**
|
|
83
|
-
* Input shape accepted by {@link toAgentConfig}. Covers both `AgentDef`
|
|
84
|
-
* (where `maxSteps` may be a function) and `IsolateConfig` (where it is
|
|
85
|
-
* always a number).
|
|
86
|
-
*/
|
|
87
58
|
export interface AgentConfigSource {
|
|
88
59
|
name: string;
|
|
89
60
|
systemPrompt: string;
|
|
@@ -96,42 +67,22 @@ export interface AgentConfigSource {
|
|
|
96
67
|
stt?: SttProvider | undefined;
|
|
97
68
|
llm?: LlmProvider | undefined;
|
|
98
69
|
tts?: TtsProvider | undefined;
|
|
70
|
+
s2s?: S2sProvider | undefined;
|
|
99
71
|
kv?: KvProvider | undefined;
|
|
100
72
|
vector?: VectorProvider | undefined;
|
|
101
73
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Extract the serializable {@link AgentConfig} subset from a source object.
|
|
104
|
-
*
|
|
105
|
-
* When `stt`, `llm`, and `tts` descriptors are present they are all three
|
|
106
|
-
* required (or none) — enforced here so the server can trust the config.
|
|
107
|
-
* `mode` is derived from their presence.
|
|
108
|
-
*/
|
|
109
74
|
export declare function toAgentConfig(src: AgentConfigSource): AgentConfig;
|
|
110
|
-
/**
|
|
111
|
-
* Zod schema for serialized tool definitions sent over the wire.
|
|
112
|
-
*
|
|
113
|
-
* `parameters` must be a valid JSON Schema object (with `type`, `properties`,
|
|
114
|
-
* etc.) — the Vercel AI SDK wraps it via `jsonSchema()`.
|
|
115
|
-
*/
|
|
116
75
|
export declare const ToolSchemaSchema: z.ZodObject<{
|
|
117
76
|
type: z.ZodLiteral<"function">;
|
|
118
77
|
name: z.ZodString;
|
|
119
78
|
description: z.ZodString;
|
|
120
79
|
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
121
80
|
}, z.core.$strip>;
|
|
122
|
-
/** Serialized tool schema — derived from {@link ToolSchemaSchema}. */
|
|
123
81
|
export type ToolSchema = {
|
|
124
82
|
type: "function";
|
|
125
83
|
name: string;
|
|
126
84
|
description: string;
|
|
127
85
|
parameters: JSONSchema7;
|
|
128
86
|
};
|
|
129
|
-
/** Empty Zod object schema used as default when tools have no parameters. */
|
|
130
87
|
export declare const EMPTY_PARAMS: z.ZodObject<{}, z.core.$strip>;
|
|
131
|
-
/**
|
|
132
|
-
* Convert agent tool definitions to JSON Schema format for wire transport.
|
|
133
|
-
*
|
|
134
|
-
* Transforms the Zod-based `parameters` of each tool into a plain JSON Schema
|
|
135
|
-
* object suitable for structured clone / JSON serialization.
|
|
136
|
-
*/
|
|
137
88
|
export declare function agentToolsToSchemas(tools: Readonly<Record<string, ToolDef>>): ToolSchema[];
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
* Lives in sdk/ because it has zero Node.js dependencies and can run in any
|
|
8
8
|
* environment (browser, Deno, Node.js sandboxes).
|
|
9
9
|
*/
|
|
10
|
-
type
|
|
11
|
-
valid: true;
|
|
12
|
-
} | {
|
|
10
|
+
type ValidationFailure = {
|
|
13
11
|
valid: false;
|
|
14
12
|
reason: string;
|
|
15
13
|
};
|
|
14
|
+
type ValidationResult = {
|
|
15
|
+
valid: true;
|
|
16
|
+
} | ValidationFailure;
|
|
16
17
|
/**
|
|
17
18
|
* Validate a single `allowedHosts` pattern at deploy time.
|
|
18
19
|
*
|
package/dist/sdk/constants.d.ts
CHANGED
|
@@ -1,51 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralised numeric constants — timeouts, size limits, sample rates.
|
|
3
|
-
*
|
|
4
|
-
* Every magic number that controls a timeout, buffer size, or threshold
|
|
5
|
-
* lives here so the values are discoverable in one place.
|
|
6
|
-
*/
|
|
7
|
-
/** Default sample rate for speech-to-text audio in Hz (AssemblyAI). */
|
|
8
1
|
export declare const DEFAULT_STT_SAMPLE_RATE = 16000;
|
|
9
|
-
/** Default sample rate for text-to-speech audio in Hz. */
|
|
10
2
|
export declare const DEFAULT_TTS_SAMPLE_RATE = 24000;
|
|
11
|
-
/** Default timeout for tool execution in the worker. */
|
|
12
3
|
export declare const TOOL_EXECUTION_TIMEOUT_MS = 30000;
|
|
13
|
-
/** Timeout for session.start() (S2S connection setup). */
|
|
14
4
|
export declare const DEFAULT_SESSION_START_TIMEOUT_MS = 10000;
|
|
15
|
-
/** S2S session idle timeout before auto-close. */
|
|
16
5
|
export declare const DEFAULT_IDLE_TIMEOUT_MS = 300000;
|
|
17
|
-
/** Per-fetch timeout for network tools (web_search, visit_webpage, fetch_json). */
|
|
18
6
|
export declare const FETCH_TIMEOUT_MS = 15000;
|
|
19
|
-
/** Timeout for sandboxed run_code execution. */
|
|
20
7
|
export declare const RUN_CODE_TIMEOUT_MS = 5000;
|
|
21
|
-
/** Maximum time to wait for sessions to stop during graceful shutdown. */
|
|
22
8
|
export declare const DEFAULT_SHUTDOWN_TIMEOUT_MS = 30000;
|
|
23
9
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* the session. Short relative to `DEFAULT_SHUTDOWN_TIMEOUT_MS` so stop()
|
|
27
|
-
* can still reclaim the socket cleanly.
|
|
10
|
+
* Short relative to `DEFAULT_SHUTDOWN_TIMEOUT_MS` so a stuck TTS provider
|
|
11
|
+
* can't wedge the session — stop() must still reclaim the socket cleanly.
|
|
28
12
|
*/
|
|
29
13
|
export declare const PIPELINE_FLUSH_TIMEOUT_MS = 10000;
|
|
30
|
-
/** Maximum length for tool result strings sent to clients. */
|
|
31
14
|
export declare const MAX_TOOL_RESULT_CHARS = 4000;
|
|
32
|
-
/** Maximum chars for webpage text after HTML-to-text conversion. */
|
|
33
15
|
export declare const MAX_PAGE_CHARS = 10000;
|
|
34
|
-
/** Maximum bytes to fetch from an HTML page before conversion. */
|
|
35
16
|
export declare const MAX_HTML_BYTES = 200000;
|
|
36
|
-
/** Maximum value size for KV store entries (bytes). */
|
|
37
17
|
export declare const MAX_VALUE_SIZE = 65536;
|
|
38
|
-
/** Maximum conversation messages to retain (sliding window). */
|
|
39
18
|
export declare const DEFAULT_MAX_HISTORY = 200;
|
|
40
|
-
/** Maximum WebSocket message payload size (bytes, 1 MiB). */
|
|
41
19
|
export declare const MAX_WS_PAYLOAD_BYTES: number;
|
|
42
|
-
/** Maximum messages buffered while session.start() is pending. */
|
|
43
20
|
export declare const MAX_MESSAGE_BUFFER_SIZE = 100;
|
|
44
|
-
/** WebSocket readyState value indicating the connection is open. */
|
|
45
21
|
export declare const WS_OPEN = 1;
|
|
46
22
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* and per-response CSP headers.
|
|
23
|
+
* Single source of truth — used by `secureHeaders` middleware and
|
|
24
|
+
* per-response CSP headers across self-hosted and platform agent UIs.
|
|
50
25
|
*/
|
|
51
26
|
export declare const AGENT_CSP: string;
|
package/dist/sdk/define.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper functions for defining agents and tools with full type inference.
|
|
3
|
-
*/
|
|
4
1
|
import type { z } from "zod";
|
|
5
|
-
import type { KvProvider, LlmProvider, SttProvider, TtsProvider, VectorProvider } from "./providers.ts";
|
|
2
|
+
import type { KvProvider, LlmProvider, S2sProvider, SttProvider, TtsProvider, VectorProvider } from "./providers.ts";
|
|
6
3
|
import { type AgentDef, type BuiltinTool, type ToolChoice, type ToolContext, type ToolDef } from "./types.ts";
|
|
7
4
|
/**
|
|
8
5
|
* Define a tool with typed parameters and execute function.
|
|
@@ -84,6 +81,12 @@ export declare function agent(def: {
|
|
|
84
81
|
* enable pipeline mode.
|
|
85
82
|
*/
|
|
86
83
|
tts?: TtsProvider;
|
|
84
|
+
/**
|
|
85
|
+
* Pluggable S2S provider descriptor. When set, overrides the implicit
|
|
86
|
+
* AssemblyAI default. Mutually exclusive with the `stt`/`llm`/`tts`
|
|
87
|
+
* pipeline triple.
|
|
88
|
+
*/
|
|
89
|
+
s2s?: S2sProvider;
|
|
87
90
|
/** Pluggable KV backend. Falls back to platform default when omitted. */
|
|
88
91
|
kv?: KvProvider;
|
|
89
92
|
/** Pluggable Vector backend. Falls back to platform default when omitted. */
|
package/dist/sdk/kv.d.ts
CHANGED
|
@@ -1,60 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key-value storage interface and shared utilities.
|
|
3
|
-
*/
|
|
4
1
|
/**
|
|
5
2
|
* Async key-value store interface used by agents.
|
|
6
3
|
*
|
|
7
|
-
* Agents access the KV store via `ToolContext.kv`. Values are JSON-serialized
|
|
8
|
-
* strings with an optional TTL.
|
|
4
|
+
* Agents access the KV store via `ToolContext.kv`. Values are JSON-serialized
|
|
5
|
+
* and stored as strings with an optional TTL.
|
|
9
6
|
*
|
|
10
7
|
* @example
|
|
11
8
|
* ```ts
|
|
12
|
-
*
|
|
13
|
-
* const
|
|
14
|
-
* description: "Save and retrieve data",
|
|
15
|
-
* execute: async (_args: unknown, ctx: { kv: Kv }) => {
|
|
16
|
-
* await ctx.kv.set("user:name", "Alice", { expireIn: 60_000 });
|
|
17
|
-
* const name = await ctx.kv.get<string>("user:name");
|
|
18
|
-
* return name; // "Alice"
|
|
19
|
-
* },
|
|
20
|
-
* };
|
|
9
|
+
* await ctx.kv.set("user:name", "Alice", { expireIn: 60_000 });
|
|
10
|
+
* const name = await ctx.kv.get<string>("user:name"); // "Alice"
|
|
21
11
|
* ```
|
|
22
12
|
*
|
|
23
13
|
* @public
|
|
24
14
|
*/
|
|
25
15
|
export type Kv = {
|
|
26
|
-
/**
|
|
27
|
-
* Get a value by key, or `null` if not found.
|
|
28
|
-
*
|
|
29
|
-
* @typeParam T - The expected type of the stored value.
|
|
30
|
-
* @param key - The key to look up.
|
|
31
|
-
* @returns The deserialized value, or `null` if the key does not exist
|
|
32
|
-
* or has expired.
|
|
33
|
-
*/
|
|
16
|
+
/** Get a value by key. Returns `null` if missing or expired. */
|
|
34
17
|
get<T = unknown>(key: string): Promise<T | null>;
|
|
35
18
|
/**
|
|
36
|
-
* Set a value, optionally with a TTL
|
|
19
|
+
* Set a value, optionally with a TTL.
|
|
37
20
|
*
|
|
38
|
-
* @param
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
* (e.g. `60_000` for 1 minute). The entry is automatically removed after this duration.
|
|
42
|
-
* @throws Throws an Error if the serialized value exceeds 65,536 bytes.
|
|
21
|
+
* @param options.expireIn - Time-to-live in **milliseconds** (e.g. `60_000`
|
|
22
|
+
* for 1 minute). The entry is automatically removed after this duration.
|
|
23
|
+
* @throws If the serialized value exceeds 65,536 bytes.
|
|
43
24
|
*/
|
|
44
25
|
set(key: string, value: unknown, options?: {
|
|
45
26
|
expireIn?: number;
|
|
46
27
|
}): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Delete one or more keys.
|
|
49
|
-
*
|
|
50
|
-
* @param keys - A single key or array of keys to delete. No-op for keys that do not exist.
|
|
51
|
-
*/
|
|
28
|
+
/** Delete one or more keys. No-op for keys that do not exist. */
|
|
52
29
|
delete(keys: string | string[]): Promise<void>;
|
|
53
30
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* for implementations that hold no resources (e.g. in-memory stores).
|
|
31
|
+
* Release any held resources (intervals, database handles). After calling,
|
|
32
|
+
* the store must not be used. No-op for stateless implementations (e.g.
|
|
33
|
+
* in-memory stores).
|
|
58
34
|
*/
|
|
59
35
|
close?(): void;
|
|
60
36
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as toAgentConfig, i as agentToolsToSchemas, n as EMPTY_PARAMS, o as ProviderDescriptorSchema, r as ToolSchemaSchema, s as assertProviderTriple, t as AgentConfigSchema } from "../_internal-types-
|
|
1
|
+
import { a as toAgentConfig, i as agentToolsToSchemas, n as EMPTY_PARAMS, o as ProviderDescriptorSchema, r as ToolSchemaSchema, s as assertProviderTriple, t as AgentConfigSchema } from "../_internal-types-CfOAbK6V.js";
|
|
2
2
|
export { AgentConfigSchema, EMPTY_PARAMS, ProviderDescriptorSchema, ToolSchemaSchema, agentToolsToSchemas, assertProviderTriple, toAgentConfig };
|
package/dist/sdk/manifest.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* then used as a plain typed object throughout the runtime.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { type KvProvider, type LlmProvider, type SessionMode, type SttProvider, type TtsProvider, type VectorProvider } from "./providers.ts";
|
|
8
|
+
import { type KvProvider, type LlmProvider, type S2sProvider, type SessionMode, type SttProvider, type TtsProvider, type VectorProvider } from "./providers.ts";
|
|
9
9
|
/**
|
|
10
10
|
* Tool definition as it appears in the serialized manifest JSON.
|
|
11
11
|
*
|
|
@@ -56,13 +56,19 @@ export type Manifest = {
|
|
|
56
56
|
* enable pipeline mode.
|
|
57
57
|
*/
|
|
58
58
|
tts?: TtsProvider | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Pluggable S2S provider descriptor. When set, overrides the implicit
|
|
61
|
+
* AssemblyAI default. Mutually exclusive with the `stt`/`llm`/`tts`
|
|
62
|
+
* pipeline triple.
|
|
63
|
+
*/
|
|
64
|
+
s2s?: S2sProvider | undefined;
|
|
59
65
|
/** Pluggable KV backend descriptor. Falls back to platform default when omitted. */
|
|
60
66
|
kv?: KvProvider | undefined;
|
|
61
67
|
/** Pluggable Vector backend descriptor. Falls back to platform default when omitted. */
|
|
62
68
|
vector?: VectorProvider | undefined;
|
|
63
69
|
/**
|
|
64
70
|
* Session mode derived from provider fields:
|
|
65
|
-
* - `"s2s"
|
|
71
|
+
* - `"s2s"`: speech-to-speech path (default when no stt/llm/tts set, or when `s2s` is set).
|
|
66
72
|
* - `"pipeline"`: pluggable STT → LLM → TTS path (stt + llm + tts all set).
|
|
67
73
|
*/
|
|
68
74
|
mode: SessionMode;
|
package/dist/sdk/protocol.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** OpenAI Realtime S2S descriptor — host transport resolves at session start. */
|
|
2
|
+
import type { S2sProvider } from "../../providers.ts";
|
|
3
|
+
export declare const OPENAI_REALTIME_KIND: "openai-realtime";
|
|
4
|
+
export type OpenaiRealtimeVoice = "alloy" | "ash" | "ballad" | "cedar" | "coral" | "echo" | "marin" | "sage" | "shimmer" | "verse";
|
|
5
|
+
export type OpenaiRealtimeOptions = {
|
|
6
|
+
/** Realtime model identifier. Default applied by the host (currently `"gpt-realtime-2"`). */
|
|
7
|
+
model?: string;
|
|
8
|
+
/** TTS voice. Default applied by the host (currently `"alloy"`). */
|
|
9
|
+
voice?: OpenaiRealtimeVoice;
|
|
10
|
+
/** Override the WebSocket base URL (testing/proxy). */
|
|
11
|
+
url?: string;
|
|
12
|
+
};
|
|
13
|
+
export type OpenaiRealtimeProvider = S2sProvider & {
|
|
14
|
+
readonly kind: typeof OPENAI_REALTIME_KIND;
|
|
15
|
+
readonly options: OpenaiRealtimeOptions;
|
|
16
|
+
};
|
|
17
|
+
export declare function openaiRealtime(opts?: OpenaiRealtimeOptions): OpenaiRealtimeProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@alexkroman1/aai/s2s` subpath barrel.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports S2S descriptor factories. Importing this barrel does not
|
|
5
|
+
* pull in any provider SDK — the host resolver handles that at session
|
|
6
|
+
* start.
|
|
7
|
+
*/
|
|
8
|
+
export type { S2sProvider } from "../providers.ts";
|
|
9
|
+
export * from "./s2s/openai-realtime.ts";
|
|
@@ -24,7 +24,7 @@ export interface RimeOptions {
|
|
|
24
24
|
* Rime model ID. Defaults to `"mistv2"` (Rime's most compatible model).
|
|
25
25
|
* Common values: `"mistv2"`, `"arcana"`.
|
|
26
26
|
*/
|
|
27
|
-
model?:
|
|
27
|
+
model?: string;
|
|
28
28
|
/**
|
|
29
29
|
* Spoken language. Uses ISO 639-3 (three-letter codes).
|
|
30
30
|
* Defaults to `"eng"` (English).
|
package/dist/sdk/providers.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export type SttProvider = ProviderDescriptor<string, Record<string, unknown>>;
|
|
|
39
39
|
export type LlmProvider = ProviderDescriptor<string, Record<string, unknown>>;
|
|
40
40
|
/** Descriptor for a TTS provider. Returned by factories like `cartesia(...)`. */
|
|
41
41
|
export type TtsProvider = ProviderDescriptor<string, Record<string, unknown>>;
|
|
42
|
+
/** Descriptor for an S2S provider. Returned by factories like `openaiRealtime(...)`. */
|
|
43
|
+
export type S2sProvider = ProviderDescriptor<string, Record<string, unknown>>;
|
|
42
44
|
/** Descriptor for a KV backend. Returned by factories like `redisKv()`. */
|
|
43
45
|
export type KvProvider = ProviderDescriptor<string, Record<string, unknown>>;
|
|
44
46
|
/** Descriptor for a Vector backend. Returned by factories like `pinecone(...)`. */
|
|
@@ -55,9 +57,11 @@ export type SessionMode = "s2s" | "pipeline";
|
|
|
55
57
|
* Enforce the all-or-nothing provider rule and return the derived mode.
|
|
56
58
|
*
|
|
57
59
|
* Pipeline mode requires STT, LLM, and TTS all set; S2S mode requires
|
|
58
|
-
* none of them. Anything in-between is a configuration error.
|
|
60
|
+
* none of them. Anything in-between is a configuration error. An optional
|
|
61
|
+
* `s2s` descriptor selects a non-default S2S provider — it must not be
|
|
62
|
+
* combined with any pipeline field.
|
|
59
63
|
*/
|
|
60
|
-
export declare function assertProviderTriple(stt: unknown, llm: unknown, tts: unknown): SessionMode;
|
|
64
|
+
export declare function assertProviderTriple(stt: unknown, llm: unknown, tts: unknown, s2s?: unknown): SessionMode;
|
|
61
65
|
export interface SttError extends Error {
|
|
62
66
|
readonly code: "stt_connect_failed" | "stt_auth_failed" | "stt_stream_error";
|
|
63
67
|
}
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import type { Kv } from "./kv.ts";
|
|
6
|
-
import type { KvProvider, LlmProvider, SttProvider, TtsProvider, VectorProvider } from "./providers.ts";
|
|
6
|
+
import type { KvProvider, LlmProvider, S2sProvider, SttProvider, TtsProvider, VectorProvider } from "./providers.ts";
|
|
7
7
|
import type { Vector } from "./vector.ts";
|
|
8
8
|
/**
|
|
9
9
|
* Identifier for a built-in server-side tool.
|
|
@@ -207,6 +207,12 @@ export type AgentDef<S = Record<string, unknown>> = {
|
|
|
207
207
|
* pipeline mode.
|
|
208
208
|
*/
|
|
209
209
|
tts?: TtsProvider;
|
|
210
|
+
/**
|
|
211
|
+
* Pluggable S2S provider descriptor. When set, overrides the implicit
|
|
212
|
+
* AssemblyAI default. Mutually exclusive with the `stt`/`llm`/`tts`
|
|
213
|
+
* pipeline triple.
|
|
214
|
+
*/
|
|
215
|
+
s2s?: S2sProvider;
|
|
210
216
|
/** Pluggable KV backend. Falls back to platform default when omitted. */
|
|
211
217
|
kv?: KvProvider;
|
|
212
218
|
/** Pluggable Vector backend. Falls back to platform default when omitted. */
|
|
@@ -9,16 +9,11 @@ import { z } from "zod";
|
|
|
9
9
|
* Lives in sdk/ because it has zero Node.js dependencies and can run in any
|
|
10
10
|
* environment (browser, Deno, Node.js sandboxes).
|
|
11
11
|
*/
|
|
12
|
-
/** Private/special-use TLDs that must never appear in allowedHosts patterns. */
|
|
13
12
|
const BLOCKED_TLDS = [
|
|
14
13
|
"local",
|
|
15
14
|
"internal",
|
|
16
15
|
"localhost"
|
|
17
16
|
];
|
|
18
|
-
/**
|
|
19
|
-
* Regex that matches an IPv4 address (four decimal octets separated by dots).
|
|
20
|
-
* Anchored so partial matches like "192.168.1.1.example.com" don't trigger it.
|
|
21
|
-
*/
|
|
22
17
|
const IPV4_RE = /^(\d{1,3}\.){3}\d{1,3}$/;
|
|
23
18
|
function fail(reason) {
|
|
24
19
|
return {
|
|
@@ -76,8 +71,7 @@ function validateAllowedHostPattern(pattern) {
|
|
|
76
71
|
function matchesAllowedHost(hostname, patterns) {
|
|
77
72
|
if (patterns.length === 0) return false;
|
|
78
73
|
const portIndex = hostname.lastIndexOf(":");
|
|
79
|
-
|
|
80
|
-
host = host.toLowerCase().replace(/\.$/, "");
|
|
74
|
+
const host = (portIndex !== -1 && !hostname.includes("[") ? hostname.slice(0, portIndex) : hostname).toLowerCase().replace(/\.$/, "");
|
|
81
75
|
for (const pattern of patterns) {
|
|
82
76
|
const p = pattern.toLowerCase();
|
|
83
77
|
if (p.startsWith("*.")) {
|