@alexkroman1/aai 1.6.0 → 1.7.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 +22 -18
- package/CHANGELOG.md +16 -0
- package/dist/{_internal-types-DFL07G3f.js → _internal-types-CrnTi9Ew.js} +8 -2
- package/dist/host/memory-vector.d.ts +17 -0
- package/dist/host/pinecone-vector.d.ts +19 -0
- package/dist/host/providers/resolve-kv.d.ts +10 -0
- package/dist/host/providers/resolve-vector.d.ts +11 -0
- package/dist/host/providers/resolve.d.ts +7 -7
- package/dist/host/runtime-barrel.d.ts +5 -0
- package/dist/host/runtime-barrel.js +416 -149
- package/dist/host/runtime.d.ts +6 -0
- package/dist/host/server.d.ts +2 -0
- package/dist/host/tool-executor.d.ts +2 -0
- package/dist/pinecone-CeJ69aRs.js +19 -0
- package/dist/{cartesia-BfQPOQ7Y.js → rime-58p9mDR8.js} +19 -19
- package/dist/s3-BtCMvCod.js +37 -0
- package/dist/sdk/_internal-types.d.ts +11 -1
- package/dist/sdk/define.d.ts +5 -1
- package/dist/sdk/manifest-barrel.js +1 -1
- package/dist/sdk/manifest.d.ts +5 -1
- package/dist/sdk/protocol.d.ts +36 -0
- package/dist/sdk/protocol.js +26 -1
- package/dist/sdk/providers/kv/fs.d.ts +12 -0
- package/dist/sdk/providers/kv/memory.d.ts +9 -0
- package/dist/sdk/providers/kv/redis.d.ts +17 -0
- package/dist/sdk/providers/kv/s3.d.ts +25 -0
- package/dist/sdk/providers/kv-barrel.d.ts +13 -0
- package/dist/sdk/providers/kv-barrel.js +2 -0
- package/dist/sdk/providers/llm-barrel.js +1 -1
- package/dist/sdk/providers/stt-barrel.js +1 -1
- package/dist/sdk/providers/tts-barrel.js +1 -1
- package/dist/sdk/providers/vector/in-memory.d.ts +15 -0
- package/dist/sdk/providers/vector/pinecone.d.ts +19 -0
- package/dist/sdk/providers/vector-barrel.d.ts +11 -0
- package/dist/sdk/providers/vector-barrel.js +2 -0
- package/dist/sdk/providers.d.ts +4 -0
- package/dist/sdk/types.d.ts +8 -1
- package/dist/sdk/vector.d.ts +29 -0
- package/dist/{soniox-DCQ3GqJq.js → soniox-BQdL0mB5.js} +13 -13
- package/host/_runtime-conformance.ts +21 -0
- package/host/_test-utils.ts +1 -0
- package/host/memory-vector.test.ts +87 -0
- package/host/memory-vector.ts +108 -0
- package/host/pinecone-vector.test.ts +79 -0
- package/host/pinecone-vector.ts +79 -0
- package/host/providers/resolve-kv.test.ts +48 -0
- package/host/providers/resolve-kv.ts +128 -0
- package/host/providers/resolve-vector.test.ts +26 -0
- package/host/providers/resolve-vector.ts +42 -0
- package/host/providers/resolve.ts +28 -55
- package/host/runtime-barrel.ts +5 -0
- package/host/runtime-config.ts +1 -1
- package/host/runtime.ts +28 -2
- package/host/server.ts +57 -1
- package/host/tool-executor.ts +7 -1
- package/package.json +20 -29
- package/sdk/__snapshots__/exports.test.ts.snap +8 -0
- package/sdk/__snapshots__/schema-shapes.test.ts.snap +2 -0
- package/sdk/_internal-types.ts +8 -0
- package/sdk/define.ts +11 -1
- package/sdk/manifest.test.ts +20 -0
- package/sdk/manifest.ts +10 -0
- package/sdk/protocol-snapshot.test.ts +53 -0
- package/sdk/protocol.test.ts +54 -0
- package/sdk/protocol.ts +32 -0
- package/sdk/providers/kv/fs.ts +20 -0
- package/sdk/providers/kv/memory.ts +17 -0
- package/sdk/providers/kv/redis.ts +25 -0
- package/sdk/providers/kv/s3.ts +33 -0
- package/sdk/providers/kv-barrel.ts +19 -0
- package/sdk/providers/vector/in-memory.ts +23 -0
- package/sdk/providers/vector/pinecone.ts +27 -0
- package/sdk/providers/vector-barrel.ts +15 -0
- package/sdk/providers.ts +6 -0
- package/sdk/types.ts +14 -1
- package/sdk/vector.ts +32 -0
- /package/dist/{xai-jfQsxxPZ.js → xai-BDI61Y2M.js} +0 -0
package/dist/host/runtime.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { ClientSink } from "../sdk/protocol.ts";
|
|
|
12
12
|
import { type ReadyConfig } from "../sdk/protocol.ts";
|
|
13
13
|
import { type LlmProvider, type SttOpener, type SttProvider, type TtsOpener, type TtsProvider } from "../sdk/providers.ts";
|
|
14
14
|
import type { AgentDef } from "../sdk/types.ts";
|
|
15
|
+
import type { Vector } from "../sdk/vector.ts";
|
|
15
16
|
import type { Logger, S2SConfig } from "./runtime-config.ts";
|
|
16
17
|
import type { CreateS2sWebSocket } from "./s2s.ts";
|
|
17
18
|
import { type SessionCore } from "./session-core.ts";
|
|
@@ -50,6 +51,11 @@ export type RuntimeOptions = {
|
|
|
50
51
|
agent: AgentDef<any>;
|
|
51
52
|
env: Record<string, string>;
|
|
52
53
|
kv?: Kv | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Vector store. If omitted, an in-memory store is created. The
|
|
56
|
+
* runtime overrides this with `agent.vector` if set.
|
|
57
|
+
*/
|
|
58
|
+
vector?: Vector | undefined;
|
|
53
59
|
/** Custom WebSocket factory for the S2S connection (useful for testing). */
|
|
54
60
|
createWebSocket?: CreateS2sWebSocket | undefined;
|
|
55
61
|
logger?: Logger | undefined;
|
package/dist/host/server.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* Import via `aai/host`.
|
|
9
9
|
*/
|
|
10
10
|
import type { Kv } from "../sdk/kv.ts";
|
|
11
|
+
import type { Vector } from "../sdk/vector.ts";
|
|
11
12
|
import type { Runtime } from "./runtime.ts";
|
|
12
13
|
import type { Logger } from "./runtime-config.ts";
|
|
13
14
|
export { createRuntime, type Runtime, type RuntimeOptions } from "./runtime.ts";
|
|
@@ -19,6 +20,7 @@ type ServerOptions = {
|
|
|
19
20
|
runtime: Runtime;
|
|
20
21
|
name?: string;
|
|
21
22
|
kv?: Kv;
|
|
23
|
+
vector?: Vector;
|
|
22
24
|
clientHtml?: string;
|
|
23
25
|
clientDir?: string;
|
|
24
26
|
logger?: Logger;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Kv } from "../sdk/kv.ts";
|
|
8
8
|
import type { Message, ToolDef } from "../sdk/types.ts";
|
|
9
|
+
import type { Vector } from "../sdk/vector.ts";
|
|
9
10
|
import type { Logger } from "./runtime-config.ts";
|
|
10
11
|
export type { ExecuteTool } from "../sdk/_internal-types.ts";
|
|
11
12
|
export type ExecuteToolCallOptions = {
|
|
@@ -14,6 +15,7 @@ export type ExecuteToolCallOptions = {
|
|
|
14
15
|
state?: Record<string, unknown>;
|
|
15
16
|
sessionId?: string | undefined;
|
|
16
17
|
kv?: Kv | undefined;
|
|
18
|
+
vector?: Vector | undefined;
|
|
17
19
|
messages?: readonly Message[] | undefined;
|
|
18
20
|
logger?: Logger | undefined;
|
|
19
21
|
send?: ((event: string, data: unknown) => void) | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region sdk/providers/vector/in-memory.ts
|
|
2
|
+
const IN_MEMORY_VECTOR_KIND = "in-memory";
|
|
3
|
+
function inMemoryVector() {
|
|
4
|
+
return {
|
|
5
|
+
kind: IN_MEMORY_VECTOR_KIND,
|
|
6
|
+
options: {}
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region sdk/providers/vector/pinecone.ts
|
|
11
|
+
const PINECONE_VECTOR_KIND = "pinecone";
|
|
12
|
+
function pinecone(opts) {
|
|
13
|
+
return {
|
|
14
|
+
kind: PINECONE_VECTOR_KIND,
|
|
15
|
+
options: { ...opts }
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { inMemoryVector as i, pinecone as n, IN_MEMORY_VECTOR_KIND as r, PINECONE_VECTOR_KIND as t };
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
//#region sdk/providers/tts/rime.ts
|
|
2
|
-
const RIME_KIND = "rime";
|
|
3
|
-
/**
|
|
4
|
-
* Default Rime speaker used when callers invoke `rime()` with no `voice`.
|
|
5
|
-
* `cove` is a `mistv2` speaker, matching the default model below — so a
|
|
6
|
-
* bare `rime()` works out of the box for new agents.
|
|
7
|
-
*/
|
|
8
|
-
const RIME_DEFAULT_VOICE = "cove";
|
|
9
|
-
function rime(opts = {}) {
|
|
10
|
-
return {
|
|
11
|
-
kind: RIME_KIND,
|
|
12
|
-
options: {
|
|
13
|
-
...opts,
|
|
14
|
-
voice: opts.voice ?? "cove"
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
1
|
//#region sdk/providers/tts/cartesia.ts
|
|
20
2
|
const CARTESIA_KIND = "cartesia";
|
|
21
3
|
/**
|
|
@@ -34,4 +16,22 @@ function cartesia(opts = {}) {
|
|
|
34
16
|
};
|
|
35
17
|
}
|
|
36
18
|
//#endregion
|
|
37
|
-
|
|
19
|
+
//#region sdk/providers/tts/rime.ts
|
|
20
|
+
const RIME_KIND = "rime";
|
|
21
|
+
/**
|
|
22
|
+
* Default Rime speaker used when callers invoke `rime()` with no `voice`.
|
|
23
|
+
* `cove` is a `mistv2` speaker, matching the default model below — so a
|
|
24
|
+
* bare `rime()` works out of the box for new agents.
|
|
25
|
+
*/
|
|
26
|
+
const RIME_DEFAULT_VOICE = "cove";
|
|
27
|
+
function rime(opts = {}) {
|
|
28
|
+
return {
|
|
29
|
+
kind: RIME_KIND,
|
|
30
|
+
options: {
|
|
31
|
+
...opts,
|
|
32
|
+
voice: opts.voice ?? "cove"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { CARTESIA_KIND as a, CARTESIA_DEFAULT_VOICE as i, RIME_KIND as n, cartesia as o, rime as r, RIME_DEFAULT_VOICE as t };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region sdk/providers/kv/fs.ts
|
|
2
|
+
const FS_KV_KIND = "fs";
|
|
3
|
+
function fsKv(opts) {
|
|
4
|
+
return {
|
|
5
|
+
kind: "fs",
|
|
6
|
+
options: { ...opts }
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region sdk/providers/kv/memory.ts
|
|
11
|
+
const MEMORY_KV_KIND = "memory";
|
|
12
|
+
function memoryKv() {
|
|
13
|
+
return {
|
|
14
|
+
kind: MEMORY_KV_KIND,
|
|
15
|
+
options: {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region sdk/providers/kv/redis.ts
|
|
20
|
+
const REDIS_KV_KIND = "redis";
|
|
21
|
+
function redisKv(opts = {}) {
|
|
22
|
+
return {
|
|
23
|
+
kind: REDIS_KV_KIND,
|
|
24
|
+
options: { ...opts }
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region sdk/providers/kv/s3.ts
|
|
29
|
+
const S3_KV_KIND = "s3";
|
|
30
|
+
function s3Kv(opts) {
|
|
31
|
+
return {
|
|
32
|
+
kind: "s3",
|
|
33
|
+
options: { ...opts }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { MEMORY_KV_KIND as a, fsKv as c, redisKv as i, s3Kv as n, memoryKv as o, REDIS_KV_KIND as r, FS_KV_KIND as s, S3_KV_KIND as t };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { JSONSchema7 } from "json-schema";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { type LlmProvider, type SttProvider, type TtsProvider } from "./providers.ts";
|
|
8
|
+
import { type KvProvider, type LlmProvider, type SttProvider, type TtsProvider, type VectorProvider } from "./providers.ts";
|
|
9
9
|
import type { Message } from "./types.ts";
|
|
10
10
|
import { type ToolDef } from "./types.ts";
|
|
11
11
|
/**
|
|
@@ -68,6 +68,14 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
68
68
|
s2s: "s2s";
|
|
69
69
|
pipeline: "pipeline";
|
|
70
70
|
}>>;
|
|
71
|
+
kv: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
kind: z.ZodString;
|
|
73
|
+
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
vector: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
kind: z.ZodString;
|
|
77
|
+
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
78
|
+
}, z.core.$strip>>;
|
|
71
79
|
}, z.core.$strip>;
|
|
72
80
|
/** Serializable agent configuration — derived from {@link AgentConfigSchema}. */
|
|
73
81
|
export type AgentConfig = z.infer<typeof AgentConfigSchema>;
|
|
@@ -88,6 +96,8 @@ export interface AgentConfigSource {
|
|
|
88
96
|
stt?: SttProvider | undefined;
|
|
89
97
|
llm?: LlmProvider | undefined;
|
|
90
98
|
tts?: TtsProvider | undefined;
|
|
99
|
+
kv?: KvProvider | undefined;
|
|
100
|
+
vector?: VectorProvider | undefined;
|
|
91
101
|
}
|
|
92
102
|
/**
|
|
93
103
|
* Extract the serializable {@link AgentConfig} subset from a source object.
|
package/dist/sdk/define.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Helper functions for defining agents and tools with full type inference.
|
|
3
3
|
*/
|
|
4
4
|
import type { z } from "zod";
|
|
5
|
-
import type { LlmProvider, SttProvider, TtsProvider } from "./providers.ts";
|
|
5
|
+
import type { KvProvider, LlmProvider, SttProvider, TtsProvider, VectorProvider } from "./providers.ts";
|
|
6
6
|
import { type AgentDef, type BuiltinTool, type ToolChoice, type ToolContext, type ToolDef } from "./types.ts";
|
|
7
7
|
/**
|
|
8
8
|
* Define a tool with typed parameters and execute function.
|
|
@@ -84,4 +84,8 @@ export declare function agent(def: {
|
|
|
84
84
|
* enable pipeline mode.
|
|
85
85
|
*/
|
|
86
86
|
tts?: TtsProvider;
|
|
87
|
+
/** Pluggable KV backend. Falls back to platform default when omitted. */
|
|
88
|
+
kv?: KvProvider;
|
|
89
|
+
/** Pluggable Vector backend. Falls back to platform default when omitted. */
|
|
90
|
+
vector?: VectorProvider;
|
|
87
91
|
}): AgentDef;
|
|
@@ -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-CrnTi9Ew.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 LlmProvider, type SessionMode, type SttProvider, type TtsProvider } from "./providers.ts";
|
|
8
|
+
import { type KvProvider, type LlmProvider, 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,6 +56,10 @@ export type Manifest = {
|
|
|
56
56
|
* enable pipeline mode.
|
|
57
57
|
*/
|
|
58
58
|
tts?: TtsProvider | undefined;
|
|
59
|
+
/** Pluggable KV backend descriptor. Falls back to platform default when omitted. */
|
|
60
|
+
kv?: KvProvider | undefined;
|
|
61
|
+
/** Pluggable Vector backend descriptor. Falls back to platform default when omitted. */
|
|
62
|
+
vector?: VectorProvider | undefined;
|
|
59
63
|
/**
|
|
60
64
|
* Session mode derived from provider fields:
|
|
61
65
|
* - `"s2s"` (default): AssemblyAI Streaming Speech-to-Speech path (no stt/llm/tts set).
|
package/dist/sdk/protocol.d.ts
CHANGED
|
@@ -55,6 +55,42 @@ export declare const KvRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
55
55
|
}, z.core.$strip>], "op">;
|
|
56
56
|
/** KV operation request — discriminated union on the `op` field. */
|
|
57
57
|
export type KvRequest = z.infer<typeof KvRequestSchema>;
|
|
58
|
+
/** Zod schema for the Vector "upsert" operation. */
|
|
59
|
+
export declare const VectorUpsertSchema: z.ZodObject<{
|
|
60
|
+
op: z.ZodLiteral<"upsert">;
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
text: z.ZodString;
|
|
63
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
/** Zod schema for the Vector "query" operation. */
|
|
66
|
+
export declare const VectorQuerySchema: z.ZodObject<{
|
|
67
|
+
op: z.ZodLiteral<"query">;
|
|
68
|
+
text: z.ZodString;
|
|
69
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
/** Zod schema for the Vector "delete" operation. */
|
|
73
|
+
export declare const VectorDeleteSchema: z.ZodObject<{
|
|
74
|
+
op: z.ZodLiteral<"delete">;
|
|
75
|
+
ids: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
/** Zod schema for Vector operation requests from the worker to the host. */
|
|
78
|
+
export declare const VectorRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
79
|
+
op: z.ZodLiteral<"upsert">;
|
|
80
|
+
id: z.ZodString;
|
|
81
|
+
text: z.ZodString;
|
|
82
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
op: z.ZodLiteral<"query">;
|
|
85
|
+
text: z.ZodString;
|
|
86
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
88
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
89
|
+
op: z.ZodLiteral<"delete">;
|
|
90
|
+
ids: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
91
|
+
}, z.core.$strip>], "op">;
|
|
92
|
+
/** Vector operation request — discriminated union on the `op` field. */
|
|
93
|
+
export type VectorRequest = z.infer<typeof VectorRequestSchema>;
|
|
58
94
|
/**
|
|
59
95
|
* Zod schema for session error codes.
|
|
60
96
|
* @public
|
package/dist/sdk/protocol.js
CHANGED
|
@@ -67,6 +67,31 @@ const KvRequestSchema = z.discriminatedUnion("op", [
|
|
|
67
67
|
KvSetSchema,
|
|
68
68
|
KvDelSchema
|
|
69
69
|
]);
|
|
70
|
+
/** Zod schema for the Vector "upsert" operation. */
|
|
71
|
+
const VectorUpsertSchema = z.object({
|
|
72
|
+
op: z.literal("upsert"),
|
|
73
|
+
id: z.string().min(1),
|
|
74
|
+
text: z.string().min(1),
|
|
75
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
76
|
+
});
|
|
77
|
+
/** Zod schema for the Vector "query" operation. */
|
|
78
|
+
const VectorQuerySchema = z.object({
|
|
79
|
+
op: z.literal("query"),
|
|
80
|
+
text: z.string().min(1),
|
|
81
|
+
topK: z.number().int().positive().max(100).optional(),
|
|
82
|
+
filter: z.record(z.string(), z.unknown()).optional()
|
|
83
|
+
});
|
|
84
|
+
/** Zod schema for the Vector "delete" operation. */
|
|
85
|
+
const VectorDeleteSchema = z.object({
|
|
86
|
+
op: z.literal("delete"),
|
|
87
|
+
ids: z.union([z.string().min(1), z.array(z.string().min(1)).max(1e3)])
|
|
88
|
+
});
|
|
89
|
+
/** Zod schema for Vector operation requests from the worker to the host. */
|
|
90
|
+
const VectorRequestSchema = z.discriminatedUnion("op", [
|
|
91
|
+
VectorUpsertSchema,
|
|
92
|
+
VectorQuerySchema,
|
|
93
|
+
VectorDeleteSchema
|
|
94
|
+
]);
|
|
70
95
|
/**
|
|
71
96
|
* Zod schema for session error codes.
|
|
72
97
|
* @public
|
|
@@ -163,4 +188,4 @@ function buildReadyConfig(s2sConfig) {
|
|
|
163
188
|
};
|
|
164
189
|
}
|
|
165
190
|
//#endregion
|
|
166
|
-
export { ClientEventSchema, ClientMessageSchema, KvDelSchema, KvGetSchema, KvRequestSchema, KvSetSchema, ReadyConfigSchema, ServerMessageSchema, SessionErrorCodeSchema, buildReadyConfig, lenientParse };
|
|
191
|
+
export { ClientEventSchema, ClientMessageSchema, KvDelSchema, KvGetSchema, KvRequestSchema, KvSetSchema, ReadyConfigSchema, ServerMessageSchema, SessionErrorCodeSchema, VectorDeleteSchema, VectorQuerySchema, VectorRequestSchema, VectorUpsertSchema, buildReadyConfig, lenientParse };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Filesystem KV descriptor — unstorage `fs` driver. */
|
|
2
|
+
import type { KvProvider } from "../../providers.ts";
|
|
3
|
+
export declare const FS_KV_KIND: "fs";
|
|
4
|
+
export interface FsKvOptions {
|
|
5
|
+
/** Directory to store key files under. Created on first write. */
|
|
6
|
+
base: string;
|
|
7
|
+
}
|
|
8
|
+
export type FsKvProvider = KvProvider & {
|
|
9
|
+
readonly kind: typeof FS_KV_KIND;
|
|
10
|
+
readonly options: FsKvOptions;
|
|
11
|
+
};
|
|
12
|
+
export declare function fsKv(opts: FsKvOptions): FsKvProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** In-memory KV descriptor — unstorage default driver. */
|
|
2
|
+
import type { KvProvider } from "../../providers.ts";
|
|
3
|
+
export declare const MEMORY_KV_KIND: "memory";
|
|
4
|
+
export type MemoryKvOptions = Record<string, never>;
|
|
5
|
+
export type MemoryKvProvider = KvProvider & {
|
|
6
|
+
readonly kind: typeof MEMORY_KV_KIND;
|
|
7
|
+
readonly options: MemoryKvOptions;
|
|
8
|
+
};
|
|
9
|
+
export declare function memoryKv(): MemoryKvProvider;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis KV descriptor.
|
|
3
|
+
*
|
|
4
|
+
* Resolves to unstorage's `redis` driver. Connection URL is pulled
|
|
5
|
+
* from the agent env (`REDIS_URL`) at session start.
|
|
6
|
+
*/
|
|
7
|
+
import type { KvProvider } from "../../providers.ts";
|
|
8
|
+
export declare const REDIS_KV_KIND: "redis";
|
|
9
|
+
export interface RedisKvOptions {
|
|
10
|
+
/** Force TLS. Defaults to inferring from `rediss://` URL scheme. */
|
|
11
|
+
tls?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type RedisKvProvider = KvProvider & {
|
|
14
|
+
readonly kind: typeof REDIS_KV_KIND;
|
|
15
|
+
readonly options: RedisKvOptions;
|
|
16
|
+
};
|
|
17
|
+
export declare function redisKv(opts?: RedisKvOptions): RedisKvProvider;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3-compatible KV descriptor.
|
|
3
|
+
*
|
|
4
|
+
* Resolves to unstorage's `s3` driver — works with AWS S3, Tigris,
|
|
5
|
+
* Cloudflare R2, and other S3-protocol stores. Credentials are
|
|
6
|
+
* pulled from the agent env at session start (the descriptor stays
|
|
7
|
+
* secret-free).
|
|
8
|
+
*
|
|
9
|
+
* Required agent env: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`.
|
|
10
|
+
* Optional: `AWS_SESSION_TOKEN` (for temporary credentials).
|
|
11
|
+
*/
|
|
12
|
+
import type { KvProvider } from "../../providers.ts";
|
|
13
|
+
export declare const S3_KV_KIND: "s3";
|
|
14
|
+
export interface S3KvOptions {
|
|
15
|
+
bucket: string;
|
|
16
|
+
/** Custom endpoint URL — required for non-AWS providers (Tigris, R2). */
|
|
17
|
+
endpoint?: string;
|
|
18
|
+
/** Region. Defaults to `"auto"`. */
|
|
19
|
+
region?: string;
|
|
20
|
+
}
|
|
21
|
+
export type S3KvProvider = KvProvider & {
|
|
22
|
+
readonly kind: typeof S3_KV_KIND;
|
|
23
|
+
readonly options: S3KvOptions;
|
|
24
|
+
};
|
|
25
|
+
export declare function s3Kv(opts: S3KvOptions): S3KvProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@alexkroman1/aai/kv` subpath barrel.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports KV descriptor factories. Importing this barrel does
|
|
5
|
+
* not pull in any unstorage driver — the host resolver handles that
|
|
6
|
+
* at session start.
|
|
7
|
+
*/
|
|
8
|
+
export type { Kv } from "../kv.ts";
|
|
9
|
+
export type { KvProvider } from "../providers.ts";
|
|
10
|
+
export * from "./kv/fs.ts";
|
|
11
|
+
export * from "./kv/memory.ts";
|
|
12
|
+
export * from "./kv/redis.ts";
|
|
13
|
+
export * from "./kv/s3.ts";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MISTRAL_KIND, c as groq, d as ANTHROPIC_KIND, f as anthropic, i as openai, l as GOOGLE_KIND, n as xai, o as mistral, r as OPENAI_KIND, s as GROQ_KIND, t as XAI_KIND, u as google } from "../../xai-
|
|
1
|
+
import { a as MISTRAL_KIND, c as groq, d as ANTHROPIC_KIND, f as anthropic, i as openai, l as GOOGLE_KIND, n as xai, o as mistral, r as OPENAI_KIND, s as GROQ_KIND, t as XAI_KIND, u as google } from "../../xai-BDI61Y2M.js";
|
|
2
2
|
export { ANTHROPIC_KIND, GOOGLE_KIND, GROQ_KIND, MISTRAL_KIND, OPENAI_KIND, XAI_KIND, anthropic, google, groq, mistral, openai, xai };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as DEEPGRAM_KIND, c as assemblyAI, i as elevenlabs, n as soniox, o as deepgram, r as ELEVENLABS_KIND, s as ASSEMBLYAI_KIND, t as SONIOX_KIND } from "../../soniox-BQdL0mB5.js";
|
|
2
2
|
export { ASSEMBLYAI_KIND, DEEPGRAM_KIND, ELEVENLABS_KIND, SONIOX_KIND, assemblyAI, deepgram, elevenlabs, soniox };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as CARTESIA_KIND, i as CARTESIA_DEFAULT_VOICE, n as RIME_KIND, o as cartesia, r as rime, t as RIME_DEFAULT_VOICE } from "../../rime-58p9mDR8.js";
|
|
2
2
|
export { CARTESIA_DEFAULT_VOICE, CARTESIA_KIND, RIME_DEFAULT_VOICE, RIME_KIND, cartesia, rime };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory Vector descriptor.
|
|
3
|
+
*
|
|
4
|
+
* Resolves to a process-local store with deterministic hash-based
|
|
5
|
+
* pseudo-embeddings. Quality is intentionally bad — the purpose is
|
|
6
|
+
* proving tool wiring during `aai dev`, not retrieval ranking.
|
|
7
|
+
*/
|
|
8
|
+
import type { VectorProvider } from "../../providers.ts";
|
|
9
|
+
export declare const IN_MEMORY_VECTOR_KIND: "in-memory";
|
|
10
|
+
export type InMemoryVectorOptions = Record<string, never>;
|
|
11
|
+
export type InMemoryVectorProvider = VectorProvider & {
|
|
12
|
+
readonly kind: typeof IN_MEMORY_VECTOR_KIND;
|
|
13
|
+
readonly options: InMemoryVectorOptions;
|
|
14
|
+
};
|
|
15
|
+
export declare function inMemoryVector(): InMemoryVectorProvider;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinecone Vector descriptor.
|
|
3
|
+
*
|
|
4
|
+
* The descriptor flows through bundle → server → runtime without
|
|
5
|
+
* importing `@pinecone-database/pinecone`. The host-side resolver in
|
|
6
|
+
* `host/providers/resolve-vector.ts` constructs a real client during
|
|
7
|
+
* `createRuntime`, using `PINECONE_API_KEY` from the agent's env.
|
|
8
|
+
*/
|
|
9
|
+
import type { VectorProvider } from "../../providers.ts";
|
|
10
|
+
export declare const PINECONE_VECTOR_KIND: "pinecone";
|
|
11
|
+
export interface PineconeOptions {
|
|
12
|
+
/** Pinecone index name. The index must be created with integrated-inference embed config. */
|
|
13
|
+
index: string;
|
|
14
|
+
}
|
|
15
|
+
export type PineconeProvider = VectorProvider & {
|
|
16
|
+
readonly kind: typeof PINECONE_VECTOR_KIND;
|
|
17
|
+
readonly options: PineconeOptions;
|
|
18
|
+
};
|
|
19
|
+
export declare function pinecone(opts: PineconeOptions): PineconeProvider;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@alexkroman1/aai/vector` subpath barrel.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports descriptor factories. Importing this barrel does not
|
|
5
|
+
* pull in `@pinecone-database/pinecone` — the host resolver handles
|
|
6
|
+
* that at session start.
|
|
7
|
+
*/
|
|
8
|
+
export type { VectorProvider } from "../providers.ts";
|
|
9
|
+
export type { Vector, VectorMatch, VectorQueryOptions } from "../vector.ts";
|
|
10
|
+
export * from "./vector/in-memory.ts";
|
|
11
|
+
export * from "./vector/pinecone.ts";
|
package/dist/sdk/providers.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ 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 a KV backend. Returned by factories like `redisKv()`. */
|
|
43
|
+
export type KvProvider = ProviderDescriptor<string, Record<string, unknown>>;
|
|
44
|
+
/** Descriptor for a Vector backend. Returned by factories like `pinecone(...)`. */
|
|
45
|
+
export type VectorProvider = ProviderDescriptor<string, Record<string, unknown>>;
|
|
42
46
|
/**
|
|
43
47
|
* Session mode derived from which provider triple is set.
|
|
44
48
|
*
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import type { Kv } from "./kv.ts";
|
|
6
|
-
import type { LlmProvider, SttProvider, TtsProvider } from "./providers.ts";
|
|
6
|
+
import type { KvProvider, LlmProvider, SttProvider, TtsProvider, VectorProvider } from "./providers.ts";
|
|
7
|
+
import type { Vector } from "./vector.ts";
|
|
7
8
|
/**
|
|
8
9
|
* Identifier for a built-in server-side tool.
|
|
9
10
|
*
|
|
@@ -74,6 +75,8 @@ export type ToolContext<S = Record<string, unknown>> = {
|
|
|
74
75
|
state: S;
|
|
75
76
|
/** Key-value store scoped to this agent deployment. */
|
|
76
77
|
kv: Kv;
|
|
78
|
+
/** Vector store scoped to this agent deployment. */
|
|
79
|
+
vector: Vector;
|
|
77
80
|
/** Read-only snapshot of conversation messages so far. */
|
|
78
81
|
messages: readonly Message[];
|
|
79
82
|
/** Unique identifier for the current session. Useful for correlating logs across concurrent sessions. */
|
|
@@ -204,6 +207,10 @@ export type AgentDef<S = Record<string, unknown>> = {
|
|
|
204
207
|
* pipeline mode.
|
|
205
208
|
*/
|
|
206
209
|
tts?: TtsProvider;
|
|
210
|
+
/** Pluggable KV backend. Falls back to platform default when omitted. */
|
|
211
|
+
kv?: KvProvider;
|
|
212
|
+
/** Pluggable Vector backend. Falls back to platform default when omitted. */
|
|
213
|
+
vector?: VectorProvider;
|
|
207
214
|
};
|
|
208
215
|
/** @internal Zod schema for {@link BuiltinTool}. Exported for reuse in internal schemas. */
|
|
209
216
|
export declare const BuiltinToolSchema: z.ZodEnum<{
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector storage interface used by agents.
|
|
3
|
+
*
|
|
4
|
+
* Agents access the store via `ctx.vector`. Backends embed text on
|
|
5
|
+
* write and run similarity search on read; the interface is text-in,
|
|
6
|
+
* matches-out so users never deal with embedding vectors directly.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type VectorMatch = {
|
|
11
|
+
id: string;
|
|
12
|
+
score: number;
|
|
13
|
+
text: string;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
/** @public */
|
|
17
|
+
export type VectorQueryOptions = {
|
|
18
|
+
/** Number of results to return. Default 5, max 100. */
|
|
19
|
+
topK?: number;
|
|
20
|
+
/** Backend-specific filter (Pinecone uses MongoDB-like operators). */
|
|
21
|
+
filter?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
/** @public */
|
|
24
|
+
export type Vector = {
|
|
25
|
+
upsert(id: string, text: string, metadata?: Record<string, unknown>): Promise<void>;
|
|
26
|
+
query(text: string, opts?: VectorQueryOptions): Promise<VectorMatch[]>;
|
|
27
|
+
delete(ids: string | string[]): Promise<void>;
|
|
28
|
+
close?(): void;
|
|
29
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
//#region sdk/providers/stt/
|
|
1
|
+
//#region sdk/providers/stt/assemblyai.ts
|
|
2
2
|
/** Kind tag recognised by the host-side resolver. */
|
|
3
|
-
const
|
|
3
|
+
const ASSEMBLYAI_KIND = "assemblyai";
|
|
4
4
|
/**
|
|
5
|
-
* Build
|
|
5
|
+
* Build an AssemblyAI STT descriptor.
|
|
6
6
|
*
|
|
7
7
|
* The API key is resolved host-side from the agent's env
|
|
8
|
-
* (`
|
|
8
|
+
* (`ASSEMBLYAI_API_KEY`); there is no factory-time key parameter, so the
|
|
9
9
|
* descriptor stays free of secrets and safe to serialize.
|
|
10
10
|
*/
|
|
11
|
-
function
|
|
11
|
+
function assemblyAI(opts = {}) {
|
|
12
12
|
return {
|
|
13
|
-
kind:
|
|
13
|
+
kind: ASSEMBLYAI_KIND,
|
|
14
14
|
options: { ...opts }
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region sdk/providers/stt/
|
|
18
|
+
//#region sdk/providers/stt/deepgram.ts
|
|
19
19
|
/** Kind tag recognised by the host-side resolver. */
|
|
20
|
-
const
|
|
20
|
+
const DEEPGRAM_KIND = "deepgram";
|
|
21
21
|
/**
|
|
22
|
-
* Build
|
|
22
|
+
* Build a Deepgram STT descriptor.
|
|
23
23
|
*
|
|
24
24
|
* The API key is resolved host-side from the agent's env
|
|
25
|
-
* (`
|
|
25
|
+
* (`DEEPGRAM_API_KEY`); there is no factory-time key parameter, so the
|
|
26
26
|
* descriptor stays free of secrets and safe to serialize.
|
|
27
27
|
*/
|
|
28
|
-
function
|
|
28
|
+
function deepgram(opts = {}) {
|
|
29
29
|
return {
|
|
30
|
-
kind:
|
|
30
|
+
kind: DEEPGRAM_KIND,
|
|
31
31
|
options: { ...opts }
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -66,4 +66,4 @@ function soniox(opts = {}) {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
|
-
export {
|
|
69
|
+
export { DEEPGRAM_KIND as a, assemblyAI as c, elevenlabs as i, soniox as n, deepgram as o, ELEVENLABS_KIND as r, ASSEMBLYAI_KIND as s, SONIOX_KIND as t };
|
|
@@ -83,6 +83,16 @@ export const CONFORMANCE_AGENT: AgentDef = {
|
|
|
83
83
|
return `stored:${JSON.stringify(result)}`;
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
|
+
vector_roundtrip: {
|
|
87
|
+
description: "Test Vector roundtrip via tool execution",
|
|
88
|
+
parameters: z.object({ text: z.string() }),
|
|
89
|
+
execute: async ({ text }: { text: string }, ctx) => {
|
|
90
|
+
await ctx.vector.upsert("conformance-doc", text);
|
|
91
|
+
const matches = await ctx.vector.query(text, { topK: 1 });
|
|
92
|
+
await ctx.vector.delete("conformance-doc");
|
|
93
|
+
return matches[0]?.text ?? "(none)";
|
|
94
|
+
},
|
|
95
|
+
},
|
|
86
96
|
},
|
|
87
97
|
};
|
|
88
98
|
|
|
@@ -130,6 +140,17 @@ export function testRuntime(label: string, getContext: () => RuntimeTestContext)
|
|
|
130
140
|
expect(result).toBe('stored:"abc"');
|
|
131
141
|
});
|
|
132
142
|
|
|
143
|
+
test("Vector round-trip through tool context", async () => {
|
|
144
|
+
const { executeTool } = getContext();
|
|
145
|
+
const vectorResult = await executeTool(
|
|
146
|
+
"vector_roundtrip",
|
|
147
|
+
{ text: "conformance-input" },
|
|
148
|
+
"s1",
|
|
149
|
+
[],
|
|
150
|
+
);
|
|
151
|
+
expect(vectorResult).toBe("conformance-input");
|
|
152
|
+
});
|
|
153
|
+
|
|
133
154
|
// ── Session state ────────────────────────────────────────────────
|
|
134
155
|
|
|
135
156
|
test("session state is initialized from factory", async () => {
|