@voicethere/agent 0.17.0 → 0.18.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/README.md +122 -0
- package/dist/llm/agent/config.d.ts +114 -0
- package/dist/llm/agent/config.d.ts.map +1 -1
- package/dist/llm/agent/config.js +192 -0
- package/dist/llm/agent/config.js.map +1 -1
- package/dist/llm/agent/create-llm-agent.d.ts +12 -0
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +125 -1
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/bounded-embedder.d.ts +22 -0
- package/dist/llm/bounded-embedder.d.ts.map +1 -0
- package/dist/llm/bounded-embedder.js +150 -0
- package/dist/llm/bounded-embedder.js.map +1 -0
- package/dist/llm/gemini-provider.d.ts +8 -1
- package/dist/llm/gemini-provider.d.ts.map +1 -1
- package/dist/llm/gemini-provider.js +31 -0
- package/dist/llm/gemini-provider.js.map +1 -1
- package/dist/llm/gemini.d.ts +2 -2
- package/dist/llm/gemini.d.ts.map +1 -1
- package/dist/llm/gemini.js +3 -2
- package/dist/llm/gemini.js.map +1 -1
- package/dist/llm/index.d.ts +7 -3
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +3 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/knowledge/chunk-markdown.d.ts +20 -0
- package/dist/llm/knowledge/chunk-markdown.d.ts.map +1 -0
- package/dist/llm/knowledge/chunk-markdown.js +90 -0
- package/dist/llm/knowledge/chunk-markdown.js.map +1 -0
- package/dist/llm/knowledge/index.d.ts +10 -0
- package/dist/llm/knowledge/index.d.ts.map +1 -0
- package/dist/llm/knowledge/index.js +6 -0
- package/dist/llm/knowledge/index.js.map +1 -0
- package/dist/llm/knowledge/redis-knowledge-base.d.ts +3 -0
- package/dist/llm/knowledge/redis-knowledge-base.d.ts.map +1 -0
- package/dist/llm/knowledge/redis-knowledge-base.js +498 -0
- package/dist/llm/knowledge/redis-knowledge-base.js.map +1 -0
- package/dist/llm/knowledge/search-knowledge-tool.d.ts +12 -0
- package/dist/llm/knowledge/search-knowledge-tool.d.ts.map +1 -0
- package/dist/llm/knowledge/search-knowledge-tool.js +44 -0
- package/dist/llm/knowledge/search-knowledge-tool.js.map +1 -0
- package/dist/llm/knowledge/supabase-knowledge-base.d.ts +35 -0
- package/dist/llm/knowledge/supabase-knowledge-base.d.ts.map +1 -0
- package/dist/llm/knowledge/supabase-knowledge-base.js +227 -0
- package/dist/llm/knowledge/supabase-knowledge-base.js.map +1 -0
- package/dist/llm/knowledge/types.d.ts +102 -0
- package/dist/llm/knowledge/types.d.ts.map +1 -0
- package/dist/llm/knowledge/types.js +9 -0
- package/dist/llm/knowledge/types.js.map +1 -0
- package/dist/llm/openai-provider.d.ts +9 -1
- package/dist/llm/openai-provider.d.ts.map +1 -1
- package/dist/llm/openai-provider.js +36 -0
- package/dist/llm/openai-provider.js.map +1 -1
- package/dist/llm/openai.d.ts +2 -2
- package/dist/llm/openai.d.ts.map +1 -1
- package/dist/llm/openai.js +7 -2
- package/dist/llm/openai.js.map +1 -1
- package/dist/llm/providers.d.ts +5 -1
- package/dist/llm/providers.d.ts.map +1 -1
- package/dist/llm/providers.js +22 -0
- package/dist/llm/providers.js.map +1 -1
- package/dist/llm/types.d.ts +26 -1
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js.map +1 -1
- package/dist/templates/llm-agent/agent.js +12192 -193
- package/dist/templates/llm-mcp-service/agent.js +59459 -0
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +28 -0
- package/dist/templates/registry.js.map +1 -1
- package/eject/llm/loop.ts +179 -1
- package/package.json +2 -1
- package/schema/voicethere.llm.schema.json +104 -57
- package/templates/README.md +2 -0
- package/templates/llm-agent/README.md +11 -0
- package/templates/llm-agent/agent.ts +15 -1
- package/templates/llm-agent/knowledge/about.md +11 -0
- package/templates/llm-agent/voicethere.llm.json +10 -0
- package/templates/llm-mcp-service/README.md +112 -0
- package/templates/llm-mcp-service/agent.ts +31 -0
- package/templates/llm-mcp-service/hooks.ts +21 -0
- package/templates/llm-mcp-service/knowledge/about.md +11 -0
- package/templates/llm-mcp-service/md.d.ts +4 -0
- package/templates/llm-mcp-service/prompt.md +23 -0
- package/templates/llm-mcp-service/tools.ts +51 -0
- package/templates/llm-mcp-service/voicethere.llm.json +47 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,KAAK,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,MAAM,GACN,YAAY,GACZ,aAAa,GACb,OAAO,CAAC;AAEZ,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,mFAAmF;IACnF,YAAY,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,uBAAuB,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,KAAK,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,MAAM,GACN,YAAY,GACZ,aAAa,GACb,OAAO,CAAC;AAEZ,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,mFAAmF;IACnF,YAAY,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,uBAAuB,EA+SpD,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAMrE,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,eAAe,CAEnE;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,uBAAuB,CAMnE;AAED,wBAAgB,yBAAyB,IAAI,uBAAuB,EAAE,CAErE"}
|
|
@@ -187,12 +187,40 @@ export const AGENT_TEMPLATES = [
|
|
|
187
187
|
"llm-agent/tools.ts",
|
|
188
188
|
"llm-agent/hooks.ts",
|
|
189
189
|
"llm-agent/md.d.ts",
|
|
190
|
+
"llm-agent/knowledge/about.md",
|
|
190
191
|
],
|
|
191
192
|
npmDependencies: {
|
|
192
193
|
openai: "^7.43.0",
|
|
193
194
|
"@anthropic-ai/sdk": "^1.3.0",
|
|
194
195
|
"@google/genai": "^2.31.0",
|
|
195
196
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
197
|
+
ioredis: "^5.11.1",
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "llm-mcp-service",
|
|
202
|
+
entry: "llm-mcp-service/agent.ts",
|
|
203
|
+
kind: "product",
|
|
204
|
+
seedOnCreate: true,
|
|
205
|
+
title: "LLM agent + MCP tool service",
|
|
206
|
+
summary: "LLM agent that calls tools served by a project service over MCP, plus an example server image.",
|
|
207
|
+
category: "voice-data",
|
|
208
|
+
description: "Same LLM agent as llm-agent, wired to the project service as its tool source (toolSources kind service, path /mcp). The README names the public example MCP server image to run as the service and shows how to add an external MCP server.",
|
|
209
|
+
sourceFiles: [
|
|
210
|
+
"llm-mcp-service/agent.ts",
|
|
211
|
+
"llm-mcp-service/voicethere.llm.json",
|
|
212
|
+
"llm-mcp-service/prompt.md",
|
|
213
|
+
"llm-mcp-service/tools.ts",
|
|
214
|
+
"llm-mcp-service/hooks.ts",
|
|
215
|
+
"llm-mcp-service/md.d.ts",
|
|
216
|
+
"llm-mcp-service/knowledge/about.md",
|
|
217
|
+
],
|
|
218
|
+
npmDependencies: {
|
|
219
|
+
openai: "^7.43.0",
|
|
220
|
+
"@anthropic-ai/sdk": "^1.3.0",
|
|
221
|
+
"@google/genai": "^2.31.0",
|
|
222
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
223
|
+
ioredis: "^5.11.1",
|
|
196
224
|
},
|
|
197
225
|
},
|
|
198
226
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,0DAA0D;QACnE,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,8EAA8E;QAChF,WAAW,EAAE,CAAC,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BAAmB;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,0DAA0D;QACnE,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,8EAA8E;QAChF,WAAW,EAAE,CAAC,eAAe,CAAC;KAC/B;IACD;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,kBAAkB;QACzB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,6BAA6B;QACpC,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qEAAqE;QACvE,WAAW,EAAE,CAAC,kBAAkB,CAAC;KAClC;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,0BAA0B;QACjC,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,iBAAiB;QACxB,OAAO,EAAE,qIAAqI;QAC9I,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qVAAqV;QACvV,WAAW,EAAE,CAAC,0BAA0B,CAAC;KAC1C;IACD;QACE,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,wBAAwB;QAC/B,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,eAAe;QACtB,OAAO,EAAE,4CAA4C;QACrD,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,uFAAuF;QACzF,WAAW,EAAE,CAAC,wBAAwB,CAAC;KACxC;IACD;QACE,EAAE,EAAE,YAAY;QAChB,KAAK,EAAE,qBAAqB;QAC5B,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK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AAE,EAAE,QAAQ,CAAC,CAAC,CAC3D,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,OAAO,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC"}
|
package/eject/llm/loop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copied from @voicethere/agent 0.
|
|
1
|
+
// Copied from @voicethere/agent 0.18.0. Package updates no longer change this file.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import {
|
|
4
4
|
type AgentHandlers,
|
|
@@ -15,8 +15,16 @@ import {
|
|
|
15
15
|
} from "@voicethere/agent";
|
|
16
16
|
import {
|
|
17
17
|
ConversationHistory,
|
|
18
|
+
createLlmEmbedder,
|
|
18
19
|
createLlmProvider,
|
|
20
|
+
createRedisKnowledgeBase,
|
|
21
|
+
createSupabaseKnowledgeBase,
|
|
19
22
|
type CustomTool,
|
|
23
|
+
DEFAULT_EMBEDDING_DIMS,
|
|
24
|
+
DEFAULT_EMBEDDING_MODEL,
|
|
25
|
+
type KnowledgeBase,
|
|
26
|
+
type KnowledgeDocument,
|
|
27
|
+
type KnowledgeLogger,
|
|
20
28
|
LLM_AGENT_CONFIG_DEFAULTS,
|
|
21
29
|
type LlmAgentConfig,
|
|
22
30
|
type LlmAgentHooks,
|
|
@@ -29,6 +37,7 @@ import {
|
|
|
29
37
|
McpToolSource,
|
|
30
38
|
type McpToolSourceOptions,
|
|
31
39
|
resolveModel,
|
|
40
|
+
searchKnowledgeTool,
|
|
32
41
|
secretValuesFromEnv,
|
|
33
42
|
SentenceSplitter,
|
|
34
43
|
ToolRegistry,
|
|
@@ -55,6 +64,17 @@ export interface CreateLlmAgentOptions {
|
|
|
55
64
|
now?: () => number;
|
|
56
65
|
/** Test injection: random number in [0, 1) used to pick a filler phrase. */
|
|
57
66
|
random?: () => number;
|
|
67
|
+
/**
|
|
68
|
+
* Retrieval for `config.knowledge`. `documents` are the chunks' source for
|
|
69
|
+
* `store: "redis"` (import `knowledge/*.md` as strings). `base` replaces the
|
|
70
|
+
* configured store (tests, advanced use).
|
|
71
|
+
*/
|
|
72
|
+
knowledge?: {
|
|
73
|
+
documents?: KnowledgeDocument[];
|
|
74
|
+
base?: KnowledgeBase;
|
|
75
|
+
/** Tests only: allow http://127.0.0.1 and http://localhost Supabase URLs. */
|
|
76
|
+
allowInsecureLocal?: boolean;
|
|
77
|
+
};
|
|
58
78
|
/** Test injection for MCP tool sources. */
|
|
59
79
|
sourceFactory?: (opts: McpToolSourceOptions) => McpToolSource;
|
|
60
80
|
}
|
|
@@ -170,6 +190,26 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
170
190
|
"LLM_CONFIG_INVALID",
|
|
171
191
|
);
|
|
172
192
|
}
|
|
193
|
+
const knowledgeCfg = config.knowledge;
|
|
194
|
+
if (
|
|
195
|
+
knowledgeCfg &&
|
|
196
|
+
knowledgeCfg.store !== "off" &&
|
|
197
|
+
knowledgeCfg.embeddings &&
|
|
198
|
+
!opts.knowledge?.base &&
|
|
199
|
+
!(opts.providers ?? []).some((m) =>
|
|
200
|
+
m.ids.includes(knowledgeCfg.embeddings!.provider),
|
|
201
|
+
)
|
|
202
|
+
) {
|
|
203
|
+
const sub =
|
|
204
|
+
knowledgeCfg.embeddings.provider === "openrouter"
|
|
205
|
+
? "openai"
|
|
206
|
+
: knowledgeCfg.embeddings.provider;
|
|
207
|
+
const q = '"';
|
|
208
|
+
throw configError(
|
|
209
|
+
`voicethere.llm.json knowledge.embeddings selects provider ${q}${knowledgeCfg.embeddings.provider}${q}, but agent.ts does not register it. Add: import { ${sub} } from ${q}@voicethere/agent/llm/${sub}${q}; and pass it in providers`,
|
|
210
|
+
"LLM_CONFIG_INVALID",
|
|
211
|
+
);
|
|
212
|
+
}
|
|
173
213
|
const hooks = opts.hooks ?? {};
|
|
174
214
|
const now = opts.now ?? Date.now;
|
|
175
215
|
const random = opts.random ?? Math.random;
|
|
@@ -201,6 +241,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
201
241
|
: undefined;
|
|
202
242
|
|
|
203
243
|
let provider: LlmProvider | undefined = opts.provider;
|
|
244
|
+
let knowledgeTool: CustomTool | undefined;
|
|
204
245
|
let registry: ToolRegistry | undefined;
|
|
205
246
|
let serviceSource: McpToolSource | undefined;
|
|
206
247
|
let serviceWaited = false;
|
|
@@ -419,6 +460,132 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
419
460
|
|
|
420
461
|
// ---- tools -------------------------------------------------------------
|
|
421
462
|
|
|
463
|
+
/** Content-free: fields hold counts, ids and durations only. */
|
|
464
|
+
const knowledgeLogger: KnowledgeLogger = {
|
|
465
|
+
info: (message, fields) => agentLog("info", message, fields ?? {}),
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
function buildKnowledge(env: Record<string, string | undefined>): void {
|
|
469
|
+
const kc = config.knowledge;
|
|
470
|
+
if (!kc || kc.store === "off") return;
|
|
471
|
+
const injected = opts.knowledge?.base;
|
|
472
|
+
const topK = kc.topK ?? 4;
|
|
473
|
+
const logCode = (message: string, fields?: Record<string, unknown>) =>
|
|
474
|
+
agentLog("warn", message, fields ?? {});
|
|
475
|
+
let base = injected;
|
|
476
|
+
if (!base) {
|
|
477
|
+
const emb = kc.embeddings;
|
|
478
|
+
if (!emb) return;
|
|
479
|
+
const apiKey = env[emb.apiKeySecret];
|
|
480
|
+
if (!nonEmpty(apiKey)) {
|
|
481
|
+
agentLog(
|
|
482
|
+
"warn",
|
|
483
|
+
`knowledge: ${emb.apiKeySecret} is not set, search_knowledge disabled`,
|
|
484
|
+
);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
const model =
|
|
488
|
+
emb.model ??
|
|
489
|
+
(emb.provider === "openai" || emb.provider === "gemini"
|
|
490
|
+
? DEFAULT_EMBEDDING_MODEL[emb.provider]
|
|
491
|
+
: undefined);
|
|
492
|
+
if (!model) return;
|
|
493
|
+
const dims = emb.dimensions ?? DEFAULT_EMBEDDING_DIMS;
|
|
494
|
+
const redisUrl = env.AGENT_REDIS_URL;
|
|
495
|
+
if (kc.store === "redis") {
|
|
496
|
+
if (!nonEmpty(redisUrl)) {
|
|
497
|
+
agentLog(
|
|
498
|
+
"info",
|
|
499
|
+
"knowledge: AGENT_REDIS_URL unset (enable Project Redis)",
|
|
500
|
+
);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const documents = opts.knowledge?.documents ?? [];
|
|
504
|
+
if (documents.length === 0) {
|
|
505
|
+
agentLog(
|
|
506
|
+
"info",
|
|
507
|
+
"knowledge: no documents, search_knowledge disabled",
|
|
508
|
+
);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
base = createRedisKnowledgeBase({
|
|
512
|
+
redisUrl,
|
|
513
|
+
namespace: kc.redis?.namespace,
|
|
514
|
+
documents,
|
|
515
|
+
embedder: createLlmEmbedder(
|
|
516
|
+
{ provider: emb.provider, apiKey },
|
|
517
|
+
opts.providers ?? [],
|
|
518
|
+
),
|
|
519
|
+
model,
|
|
520
|
+
dims,
|
|
521
|
+
logger: knowledgeLogger,
|
|
522
|
+
});
|
|
523
|
+
} else {
|
|
524
|
+
const sb = kc.supabase;
|
|
525
|
+
const url = sb ? env[sb.urlSecret] : undefined;
|
|
526
|
+
const key = sb ? env[sb.keySecret] : undefined;
|
|
527
|
+
if (!sb || !nonEmpty(url) || !nonEmpty(key)) {
|
|
528
|
+
agentLog(
|
|
529
|
+
"info",
|
|
530
|
+
"knowledge: Supabase URL or key secret is not set, search_knowledge disabled",
|
|
531
|
+
);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (!/^https:\/\//i.test(url.trim())) {
|
|
535
|
+
const local = /^http:\/\/(127\.0\.0\.1|localhost)(:|\/|$)/i.test(
|
|
536
|
+
url.trim(),
|
|
537
|
+
);
|
|
538
|
+
if (!local || !opts.knowledge?.allowInsecureLocal) {
|
|
539
|
+
agentLog(
|
|
540
|
+
"info",
|
|
541
|
+
"knowledge: supabase url must use https; knowledge search disabled",
|
|
542
|
+
);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
base = createSupabaseKnowledgeBase({
|
|
547
|
+
allowInsecureLocal: opts.knowledge?.allowInsecureLocal,
|
|
548
|
+
url,
|
|
549
|
+
key,
|
|
550
|
+
rpc: sb.rpc,
|
|
551
|
+
matchThreshold: sb.matchThreshold,
|
|
552
|
+
embedder: createLlmEmbedder(
|
|
553
|
+
{ provider: emb.provider, apiKey },
|
|
554
|
+
opts.providers ?? [],
|
|
555
|
+
),
|
|
556
|
+
model,
|
|
557
|
+
dims,
|
|
558
|
+
cache: nonEmpty(redisUrl)
|
|
559
|
+
? {
|
|
560
|
+
redisUrl,
|
|
561
|
+
ttlSeconds: sb.cacheTtlSeconds,
|
|
562
|
+
namespace: kc.redis?.namespace,
|
|
563
|
+
}
|
|
564
|
+
: undefined,
|
|
565
|
+
logger: knowledgeLogger,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
// The agent runtime has no shutdown hook: the connection is closed with the process.
|
|
570
|
+
// Indexing never blocks agent start; search retries the index on demand.
|
|
571
|
+
void base.ensureIndexed().then(
|
|
572
|
+
(report) =>
|
|
573
|
+
agentLog("info", "knowledge indexed", {
|
|
574
|
+
status: report.status,
|
|
575
|
+
chunks: report.chunks,
|
|
576
|
+
waitedMs: report.waitedMs,
|
|
577
|
+
}),
|
|
578
|
+
(err: unknown) =>
|
|
579
|
+
agentLog("warn", "knowledge indexing failed", {
|
|
580
|
+
code:
|
|
581
|
+
typeof (err as { code?: unknown })?.code === "string"
|
|
582
|
+
? (err as { code: string }).code
|
|
583
|
+
: "KB_UNKNOWN",
|
|
584
|
+
}),
|
|
585
|
+
);
|
|
586
|
+
knowledgeTool = searchKnowledgeTool(base, { topK, log: logCode });
|
|
587
|
+
}
|
|
588
|
+
|
|
422
589
|
function buildRegistry(env: Record<string, string | undefined>): void {
|
|
423
590
|
const reg = new ToolRegistry({
|
|
424
591
|
log: (level, message, fields) => agentLog(level, message, fields ?? {}),
|
|
@@ -427,6 +594,15 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
427
594
|
secretValues: secretValuesFromEnv(env, [
|
|
428
595
|
config.apiKeySecret,
|
|
429
596
|
"AGENT_SERVICE_TOKEN",
|
|
597
|
+
...(config.knowledge?.embeddings
|
|
598
|
+
? [config.knowledge.embeddings.apiKeySecret]
|
|
599
|
+
: []),
|
|
600
|
+
...(config.knowledge?.supabase
|
|
601
|
+
? [
|
|
602
|
+
config.knowledge.supabase.keySecret,
|
|
603
|
+
config.knowledge.supabase.urlSecret,
|
|
604
|
+
]
|
|
605
|
+
: []),
|
|
430
606
|
...(config.toolSources ?? []).flatMap((src) => {
|
|
431
607
|
if (src.kind !== "mcp" || !src.auth) return [];
|
|
432
608
|
if (src.auth.type === "bearer") return [src.auth.secret];
|
|
@@ -440,6 +616,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
440
616
|
},
|
|
441
617
|
});
|
|
442
618
|
for (const tool of opts.tools ?? []) reg.addCustomTool(tool);
|
|
619
|
+
if (knowledgeTool) reg.addCustomTool(knowledgeTool);
|
|
443
620
|
const sources: McpToolSource[] = [];
|
|
444
621
|
for (const src of config.toolSources ?? []) {
|
|
445
622
|
if (src.kind === "service") {
|
|
@@ -1079,6 +1256,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1079
1256
|
opts.providers ?? [],
|
|
1080
1257
|
);
|
|
1081
1258
|
}
|
|
1259
|
+
buildKnowledge(env);
|
|
1082
1260
|
buildRegistry(env);
|
|
1083
1261
|
},
|
|
1084
1262
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicethere/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -156,6 +156,7 @@
|
|
|
156
156
|
"http-server": "14.1.1",
|
|
157
157
|
"ioredis": "5.11.1",
|
|
158
158
|
"openai": "7.43.0",
|
|
159
|
+
"prettier": "3.9.10",
|
|
159
160
|
"tsx": "4.19.2",
|
|
160
161
|
"typescript": "5.9.3",
|
|
161
162
|
"vitest": "3.2.7",
|
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
"title": "VoiceThere LLM agent config",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"additionalProperties": false,
|
|
7
|
-
"required": [
|
|
8
|
-
"version",
|
|
9
|
-
"provider",
|
|
10
|
-
"apiKeySecret"
|
|
11
|
-
],
|
|
7
|
+
"required": ["version", "provider", "apiKeySecret"],
|
|
12
8
|
"properties": {
|
|
13
9
|
"$schema": {
|
|
14
10
|
"type": "string"
|
|
@@ -17,12 +13,7 @@
|
|
|
17
13
|
"const": 1
|
|
18
14
|
},
|
|
19
15
|
"provider": {
|
|
20
|
-
"enum": [
|
|
21
|
-
"openai",
|
|
22
|
-
"anthropic",
|
|
23
|
-
"gemini",
|
|
24
|
-
"openrouter"
|
|
25
|
-
]
|
|
16
|
+
"enum": ["openai", "anthropic", "gemini", "openrouter"]
|
|
26
17
|
},
|
|
27
18
|
"model": {
|
|
28
19
|
"type": "string",
|
|
@@ -54,9 +45,7 @@
|
|
|
54
45
|
"greeting": {
|
|
55
46
|
"type": "object",
|
|
56
47
|
"additionalProperties": false,
|
|
57
|
-
"required": [
|
|
58
|
-
"text"
|
|
59
|
-
],
|
|
48
|
+
"required": ["text"],
|
|
60
49
|
"properties": {
|
|
61
50
|
"text": {
|
|
62
51
|
"type": "string",
|
|
@@ -72,16 +61,10 @@
|
|
|
72
61
|
"bargeIn": {
|
|
73
62
|
"type": "object",
|
|
74
63
|
"additionalProperties": false,
|
|
75
|
-
"required": [
|
|
76
|
-
"mode"
|
|
77
|
-
],
|
|
64
|
+
"required": ["mode"],
|
|
78
65
|
"properties": {
|
|
79
66
|
"mode": {
|
|
80
|
-
"enum": [
|
|
81
|
-
"project",
|
|
82
|
-
"on",
|
|
83
|
-
"off"
|
|
84
|
-
]
|
|
67
|
+
"enum": ["project", "on", "off"]
|
|
85
68
|
}
|
|
86
69
|
},
|
|
87
70
|
"default": {
|
|
@@ -89,10 +72,7 @@
|
|
|
89
72
|
}
|
|
90
73
|
},
|
|
91
74
|
"speechDuringNonInterruptible": {
|
|
92
|
-
"enum": [
|
|
93
|
-
"answer_after",
|
|
94
|
-
"discard"
|
|
95
|
-
],
|
|
75
|
+
"enum": ["answer_after", "discard"],
|
|
96
76
|
"default": "answer_after"
|
|
97
77
|
},
|
|
98
78
|
"history": {
|
|
@@ -138,9 +118,7 @@
|
|
|
138
118
|
"deprecated": true,
|
|
139
119
|
"description": "Deprecated: use the top-level fillers block. Ignored when fillers is set.",
|
|
140
120
|
"additionalProperties": false,
|
|
141
|
-
"required": [
|
|
142
|
-
"text"
|
|
143
|
-
],
|
|
121
|
+
"required": ["text"],
|
|
144
122
|
"properties": {
|
|
145
123
|
"text": {
|
|
146
124
|
"type": "string",
|
|
@@ -260,9 +238,7 @@
|
|
|
260
238
|
{
|
|
261
239
|
"type": "object",
|
|
262
240
|
"additionalProperties": false,
|
|
263
|
-
"required": [
|
|
264
|
-
"kind"
|
|
265
|
-
],
|
|
241
|
+
"required": ["kind"],
|
|
266
242
|
"properties": {
|
|
267
243
|
"kind": {
|
|
268
244
|
"const": "service"
|
|
@@ -293,11 +269,7 @@
|
|
|
293
269
|
{
|
|
294
270
|
"type": "object",
|
|
295
271
|
"additionalProperties": false,
|
|
296
|
-
"required": [
|
|
297
|
-
"kind",
|
|
298
|
-
"name",
|
|
299
|
-
"url"
|
|
300
|
-
],
|
|
272
|
+
"required": ["kind", "name", "url"],
|
|
301
273
|
"properties": {
|
|
302
274
|
"kind": {
|
|
303
275
|
"const": "mcp"
|
|
@@ -317,9 +289,7 @@
|
|
|
317
289
|
{
|
|
318
290
|
"type": "object",
|
|
319
291
|
"additionalProperties": false,
|
|
320
|
-
"required": [
|
|
321
|
-
"type"
|
|
322
|
-
],
|
|
292
|
+
"required": ["type"],
|
|
323
293
|
"properties": {
|
|
324
294
|
"type": {
|
|
325
295
|
"const": "none"
|
|
@@ -329,10 +299,7 @@
|
|
|
329
299
|
{
|
|
330
300
|
"type": "object",
|
|
331
301
|
"additionalProperties": false,
|
|
332
|
-
"required": [
|
|
333
|
-
"type",
|
|
334
|
-
"secret"
|
|
335
|
-
],
|
|
302
|
+
"required": ["type", "secret"],
|
|
336
303
|
"properties": {
|
|
337
304
|
"type": {
|
|
338
305
|
"const": "bearer"
|
|
@@ -347,10 +314,7 @@
|
|
|
347
314
|
{
|
|
348
315
|
"type": "object",
|
|
349
316
|
"additionalProperties": false,
|
|
350
|
-
"required": [
|
|
351
|
-
"type",
|
|
352
|
-
"headers"
|
|
353
|
-
],
|
|
317
|
+
"required": ["type", "headers"],
|
|
354
318
|
"properties": {
|
|
355
319
|
"type": {
|
|
356
320
|
"const": "headers"
|
|
@@ -392,10 +356,7 @@
|
|
|
392
356
|
}
|
|
393
357
|
},
|
|
394
358
|
"interruptPolicy": {
|
|
395
|
-
"enum": [
|
|
396
|
-
"cancel",
|
|
397
|
-
"finish"
|
|
398
|
-
],
|
|
359
|
+
"enum": ["cancel", "finish"],
|
|
399
360
|
"default": "cancel"
|
|
400
361
|
},
|
|
401
362
|
"serviceWaitMs": {
|
|
@@ -414,12 +375,98 @@
|
|
|
414
375
|
"type": "boolean",
|
|
415
376
|
"default": true
|
|
416
377
|
},
|
|
378
|
+
"knowledge": {
|
|
379
|
+
"type": "object",
|
|
380
|
+
"additionalProperties": false,
|
|
381
|
+
"required": ["store"],
|
|
382
|
+
"description": "Retrieval (RAG) behind a search_knowledge tool. store redis indexes knowledge/*.md into Project Redis; store supabase queries your own Supabase pgvector function.",
|
|
383
|
+
"properties": {
|
|
384
|
+
"store": {
|
|
385
|
+
"enum": ["redis", "supabase", "off"]
|
|
386
|
+
},
|
|
387
|
+
"topK": {
|
|
388
|
+
"type": "integer",
|
|
389
|
+
"minimum": 1,
|
|
390
|
+
"maximum": 10,
|
|
391
|
+
"default": 4
|
|
392
|
+
},
|
|
393
|
+
"embeddings": {
|
|
394
|
+
"type": "object",
|
|
395
|
+
"additionalProperties": false,
|
|
396
|
+
"required": ["provider"],
|
|
397
|
+
"description": "Required unless store is off. apiKeySecret may be omitted when provider equals the top-level provider. Anthropic has no embeddings API.",
|
|
398
|
+
"properties": {
|
|
399
|
+
"provider": {
|
|
400
|
+
"enum": ["openai", "gemini", "openrouter"]
|
|
401
|
+
},
|
|
402
|
+
"model": {
|
|
403
|
+
"type": "string",
|
|
404
|
+
"minLength": 1,
|
|
405
|
+
"maxLength": 200
|
|
406
|
+
},
|
|
407
|
+
"dimensions": {
|
|
408
|
+
"type": "integer",
|
|
409
|
+
"minimum": 64,
|
|
410
|
+
"maximum": 3072,
|
|
411
|
+
"default": 512
|
|
412
|
+
},
|
|
413
|
+
"apiKeySecret": {
|
|
414
|
+
"type": "string",
|
|
415
|
+
"pattern": "^AGENT_[A-Z0-9_]{1,57}$",
|
|
416
|
+
"description": "Name of an AGENT_* environment variable (project secret), never its value."
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
"redis": {
|
|
421
|
+
"type": "object",
|
|
422
|
+
"additionalProperties": false,
|
|
423
|
+
"properties": {
|
|
424
|
+
"namespace": {
|
|
425
|
+
"type": "string",
|
|
426
|
+
"pattern": "^[a-z0-9_-]{1,40}$",
|
|
427
|
+
"default": "default"
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
"supabase": {
|
|
432
|
+
"type": "object",
|
|
433
|
+
"additionalProperties": false,
|
|
434
|
+
"required": ["urlSecret", "keySecret"],
|
|
435
|
+
"description": "Required when store is supabase.",
|
|
436
|
+
"properties": {
|
|
437
|
+
"urlSecret": {
|
|
438
|
+
"type": "string",
|
|
439
|
+
"pattern": "^AGENT_[A-Z0-9_]{1,57}$",
|
|
440
|
+
"description": "Name of an AGENT_* environment variable (project secret), never its value."
|
|
441
|
+
},
|
|
442
|
+
"keySecret": {
|
|
443
|
+
"type": "string",
|
|
444
|
+
"pattern": "^AGENT_[A-Z0-9_]{1,57}$",
|
|
445
|
+
"description": "Name of an AGENT_* environment variable (project secret), never its value."
|
|
446
|
+
},
|
|
447
|
+
"rpc": {
|
|
448
|
+
"type": "string",
|
|
449
|
+
"pattern": "^[a-z_][a-z0-9_]{0,62}$",
|
|
450
|
+
"default": "match_documents"
|
|
451
|
+
},
|
|
452
|
+
"matchThreshold": {
|
|
453
|
+
"type": "number",
|
|
454
|
+
"minimum": 0,
|
|
455
|
+
"maximum": 1,
|
|
456
|
+
"default": 0.5
|
|
457
|
+
},
|
|
458
|
+
"cacheTtlSeconds": {
|
|
459
|
+
"type": "integer",
|
|
460
|
+
"minimum": 10,
|
|
461
|
+
"maximum": 86400,
|
|
462
|
+
"default": 600
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
},
|
|
417
468
|
"toolCallLogs": {
|
|
418
|
-
"enum": [
|
|
419
|
-
"full",
|
|
420
|
-
"redacted",
|
|
421
|
-
"off"
|
|
422
|
-
],
|
|
469
|
+
"enum": ["full", "redacted", "off"],
|
|
423
470
|
"default": "redacted",
|
|
424
471
|
"description": "Agent log line per tool call. redacted removes secret values, sensitive keys and common personal data; full removes only secret values; off writes nothing."
|
|
425
472
|
}
|
package/templates/README.md
CHANGED
|
@@ -74,6 +74,8 @@ Each folder has its own README. Summary:
|
|
|
74
74
|
| `spatial-showcase` | `spatial-showcase/` | Orbit / soundboard / proximity |
|
|
75
75
|
| `webhooks` | `webhooks/` | Inbound HMAC webhooks |
|
|
76
76
|
| `webhooks-redis` | `webhooks-redis/` | Webhooks plus Redis counter |
|
|
77
|
+
| `llm-agent` | `llm-agent/` | LLM voice and chat agent, tools, MCP, optional knowledge (RAG) |
|
|
78
|
+
| `llm-mcp-service` | `llm-mcp-service/` | `llm-agent` plus a project service that serves MCP tools |
|
|
77
79
|
|
|
78
80
|
## E2e templates
|
|
79
81
|
|
|
@@ -9,6 +9,7 @@ A voice and chat agent powered by an LLM, with custom tools and MCP servers. Sou
|
|
|
9
9
|
- `prompt.md` is the system prompt. The dashboard LLM tab edits this file too.
|
|
10
10
|
- `tools.ts` lists your own tools. It ships with `get_current_time`.
|
|
11
11
|
- `hooks.ts` is where you adjust a turn in code. It is empty by default.
|
|
12
|
+
- `knowledge/about.md` is a sample document for retrieval (off by default).
|
|
12
13
|
- `md.d.ts` lets TypeScript accept `import prompt from "./prompt.md"`.
|
|
13
14
|
|
|
14
15
|
## Set the API key
|
|
@@ -68,6 +69,16 @@ Only the provider you import in `agent.ts` is bundled. When you change `provider
|
|
|
68
69
|
|
|
69
70
|
If they do not match, `createLlmAgent` throws when the bundle loads, and the deploy check reports it.
|
|
70
71
|
|
|
72
|
+
## Knowledge (RAG)
|
|
73
|
+
|
|
74
|
+
The `knowledge` block in `voicethere.llm.json` ships with `"store": "off"`, so the template runs without Redis. Turning it on takes three steps:
|
|
75
|
+
|
|
76
|
+
1. Put your Markdown files in `knowledge/`, import each one in `agent.ts` and add it to the `documents` list. The agent splits every file by heading and indexes the pieces.
|
|
77
|
+
2. Set `"store": "redis"` and enable Project Redis for the project. Create the project secret `AGENT_OPENAI_API_KEY` for the embeddings (or change `knowledge.embeddings`; Anthropic has no embeddings API). The agent indexes in the background on start and skips files that did not change.
|
|
78
|
+
3. Redeploy. The model now has a `search_knowledge` tool and answers from the retrieved chunks.
|
|
79
|
+
|
|
80
|
+
For a large or changing data set use your own Supabase project instead: set `"store": "supabase"`, add a `supabase` block with `urlSecret` and `keySecret` (see the knowledge section of the package README for the SQL to run in your project), and fill the table yourself. Set `dimensions` to match your table. Chunk and query text never reach VoiceThere logs.
|
|
81
|
+
|
|
71
82
|
## Learn more
|
|
72
83
|
|
|
73
84
|
See the docs page `/docs/llm-agents` for the full list of settings, tools, MCP servers and hooks.
|
|
@@ -5,6 +5,7 @@ import config from "./voicethere.llm.json";
|
|
|
5
5
|
import systemPrompt from "./prompt.md";
|
|
6
6
|
import { tools } from "./tools";
|
|
7
7
|
import { hooks } from "./hooks";
|
|
8
|
+
import about from "./knowledge/about.md";
|
|
8
9
|
|
|
9
10
|
// The template runs on OpenRouter, which is served by the openai module, so
|
|
10
11
|
// switching between openai and openrouter needs no import change. Only the
|
|
@@ -12,6 +13,19 @@ import { hooks } from "./hooks";
|
|
|
12
13
|
// "provider" in voicethere.llm.json and import its module instead:
|
|
13
14
|
// anthropic → import { anthropic } from "@voicethere/agent/llm/anthropic";
|
|
14
15
|
// gemini → import { gemini } from "@voicethere/agent/llm/gemini";
|
|
16
|
+
//
|
|
17
|
+
// Knowledge (RAG) is off. To turn it on, set knowledge.store in
|
|
18
|
+
// voicethere.llm.json to "redis" (needs Project Redis) or "supabase" (see the
|
|
19
|
+
// README for the SQL). Add Markdown files under knowledge/, import each one
|
|
20
|
+
// above and list it in documents below. The embeddings provider module (openai)
|
|
21
|
+
// is already imported and registered in providers.
|
|
15
22
|
defineAgent(
|
|
16
|
-
createLlmAgent({
|
|
23
|
+
createLlmAgent({
|
|
24
|
+
config,
|
|
25
|
+
systemPrompt,
|
|
26
|
+
tools,
|
|
27
|
+
hooks,
|
|
28
|
+
providers: [openai],
|
|
29
|
+
knowledge: { documents: [{ id: "about", title: "About", text: about }] },
|
|
30
|
+
}),
|
|
17
31
|
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# About this agent
|
|
2
|
+
|
|
3
|
+
This is a sample document. It tells the agent what it is: a voice and chat assistant built from the VoiceThere llm-agent template.
|
|
4
|
+
|
|
5
|
+
## How to replace this file
|
|
6
|
+
|
|
7
|
+
Delete this text and write what your agent should know: product facts, prices, opening hours, policies. Use one heading per topic, because the agent splits every file by heading and searches the pieces. Keep each section short and self-contained, around 300 words at most.
|
|
8
|
+
|
|
9
|
+
## How to add more files
|
|
10
|
+
|
|
11
|
+
Put more Markdown files in this folder, import each one in agent.ts and add it to the documents list. When a file changes, the next start indexes it again. Files that did not change are not embedded a second time.
|