@voicethere/agent 0.17.0 → 0.18.1
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 +147 -3
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/agent/thinking-stripper.d.ts +26 -0
- package/dist/llm/agent/thinking-stripper.d.ts.map +1 -0
- package/dist/llm/agent/thinking-stripper.js +78 -0
- package/dist/llm/agent/thinking-stripper.js.map +1 -0
- 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 +8 -3
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -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 +12275 -196
- package/dist/templates/llm-mcp-service/agent.js +59539 -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 +203 -3
- 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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AAQ,EAAE,YAAY;QACtB,WAAW,EACT,2PAA2P;QAC7P,WAAW,EAAE;YACX,oBAAoB;YACpB,+BAA+B;YAC/B,qBAAqB;YACrB,oBAAoB;YACpB,oBAAoB;YACpB,mBAAmB;
|
|
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,EAA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CAAC;KACpC;CACO,CAAC;AAIX,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,eAAe,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,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.1. 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,8 +37,11 @@ import {
|
|
|
29
37
|
McpToolSource,
|
|
30
38
|
type McpToolSourceOptions,
|
|
31
39
|
resolveModel,
|
|
40
|
+
searchKnowledgeTool,
|
|
32
41
|
secretValuesFromEnv,
|
|
33
42
|
SentenceSplitter,
|
|
43
|
+
stripThinking,
|
|
44
|
+
ThinkingStripper,
|
|
34
45
|
ToolRegistry,
|
|
35
46
|
type TurnContext,
|
|
36
47
|
type TurnSummary,
|
|
@@ -55,6 +66,17 @@ export interface CreateLlmAgentOptions {
|
|
|
55
66
|
now?: () => number;
|
|
56
67
|
/** Test injection: random number in [0, 1) used to pick a filler phrase. */
|
|
57
68
|
random?: () => number;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieval for `config.knowledge`. `documents` are the chunks' source for
|
|
71
|
+
* `store: "redis"` (import `knowledge/*.md` as strings). `base` replaces the
|
|
72
|
+
* configured store (tests, advanced use).
|
|
73
|
+
*/
|
|
74
|
+
knowledge?: {
|
|
75
|
+
documents?: KnowledgeDocument[];
|
|
76
|
+
base?: KnowledgeBase;
|
|
77
|
+
/** Tests only: allow http://127.0.0.1 and http://localhost Supabase URLs. */
|
|
78
|
+
allowInsecureLocal?: boolean;
|
|
79
|
+
};
|
|
58
80
|
/** Test injection for MCP tool sources. */
|
|
59
81
|
sourceFactory?: (opts: McpToolSourceOptions) => McpToolSource;
|
|
60
82
|
}
|
|
@@ -100,6 +122,8 @@ interface TurnState {
|
|
|
100
122
|
pendingChars: number;
|
|
101
123
|
coalesceTimer?: ReturnType<typeof setTimeout>;
|
|
102
124
|
fallbackSpoken: boolean;
|
|
125
|
+
/** Characters of `<thinking>` blocks removed from the reply this turn. */
|
|
126
|
+
thinkingCharsStripped: number;
|
|
103
127
|
status: TurnSummary["status"];
|
|
104
128
|
}
|
|
105
129
|
|
|
@@ -170,6 +194,26 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
170
194
|
"LLM_CONFIG_INVALID",
|
|
171
195
|
);
|
|
172
196
|
}
|
|
197
|
+
const knowledgeCfg = config.knowledge;
|
|
198
|
+
if (
|
|
199
|
+
knowledgeCfg &&
|
|
200
|
+
knowledgeCfg.store !== "off" &&
|
|
201
|
+
knowledgeCfg.embeddings &&
|
|
202
|
+
!opts.knowledge?.base &&
|
|
203
|
+
!(opts.providers ?? []).some((m) =>
|
|
204
|
+
m.ids.includes(knowledgeCfg.embeddings!.provider),
|
|
205
|
+
)
|
|
206
|
+
) {
|
|
207
|
+
const sub =
|
|
208
|
+
knowledgeCfg.embeddings.provider === "openrouter"
|
|
209
|
+
? "openai"
|
|
210
|
+
: knowledgeCfg.embeddings.provider;
|
|
211
|
+
const q = '"';
|
|
212
|
+
throw configError(
|
|
213
|
+
`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`,
|
|
214
|
+
"LLM_CONFIG_INVALID",
|
|
215
|
+
);
|
|
216
|
+
}
|
|
173
217
|
const hooks = opts.hooks ?? {};
|
|
174
218
|
const now = opts.now ?? Date.now;
|
|
175
219
|
const random = opts.random ?? Math.random;
|
|
@@ -201,6 +245,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
201
245
|
: undefined;
|
|
202
246
|
|
|
203
247
|
let provider: LlmProvider | undefined = opts.provider;
|
|
248
|
+
let knowledgeTool: CustomTool | undefined;
|
|
204
249
|
let registry: ToolRegistry | undefined;
|
|
205
250
|
let serviceSource: McpToolSource | undefined;
|
|
206
251
|
let serviceWaited = false;
|
|
@@ -419,6 +464,132 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
419
464
|
|
|
420
465
|
// ---- tools -------------------------------------------------------------
|
|
421
466
|
|
|
467
|
+
/** Content-free: fields hold counts, ids and durations only. */
|
|
468
|
+
const knowledgeLogger: KnowledgeLogger = {
|
|
469
|
+
info: (message, fields) => agentLog("info", message, fields ?? {}),
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
function buildKnowledge(env: Record<string, string | undefined>): void {
|
|
473
|
+
const kc = config.knowledge;
|
|
474
|
+
if (!kc || kc.store === "off") return;
|
|
475
|
+
const injected = opts.knowledge?.base;
|
|
476
|
+
const topK = kc.topK ?? 4;
|
|
477
|
+
const logCode = (message: string, fields?: Record<string, unknown>) =>
|
|
478
|
+
agentLog("warn", message, fields ?? {});
|
|
479
|
+
let base = injected;
|
|
480
|
+
if (!base) {
|
|
481
|
+
const emb = kc.embeddings;
|
|
482
|
+
if (!emb) return;
|
|
483
|
+
const apiKey = env[emb.apiKeySecret];
|
|
484
|
+
if (!nonEmpty(apiKey)) {
|
|
485
|
+
agentLog(
|
|
486
|
+
"warn",
|
|
487
|
+
`knowledge: ${emb.apiKeySecret} is not set, search_knowledge disabled`,
|
|
488
|
+
);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
const model =
|
|
492
|
+
emb.model ??
|
|
493
|
+
(emb.provider === "openai" || emb.provider === "gemini"
|
|
494
|
+
? DEFAULT_EMBEDDING_MODEL[emb.provider]
|
|
495
|
+
: undefined);
|
|
496
|
+
if (!model) return;
|
|
497
|
+
const dims = emb.dimensions ?? DEFAULT_EMBEDDING_DIMS;
|
|
498
|
+
const redisUrl = env.AGENT_REDIS_URL;
|
|
499
|
+
if (kc.store === "redis") {
|
|
500
|
+
if (!nonEmpty(redisUrl)) {
|
|
501
|
+
agentLog(
|
|
502
|
+
"info",
|
|
503
|
+
"knowledge: AGENT_REDIS_URL unset (enable Project Redis)",
|
|
504
|
+
);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const documents = opts.knowledge?.documents ?? [];
|
|
508
|
+
if (documents.length === 0) {
|
|
509
|
+
agentLog(
|
|
510
|
+
"info",
|
|
511
|
+
"knowledge: no documents, search_knowledge disabled",
|
|
512
|
+
);
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
base = createRedisKnowledgeBase({
|
|
516
|
+
redisUrl,
|
|
517
|
+
namespace: kc.redis?.namespace,
|
|
518
|
+
documents,
|
|
519
|
+
embedder: createLlmEmbedder(
|
|
520
|
+
{ provider: emb.provider, apiKey },
|
|
521
|
+
opts.providers ?? [],
|
|
522
|
+
),
|
|
523
|
+
model,
|
|
524
|
+
dims,
|
|
525
|
+
logger: knowledgeLogger,
|
|
526
|
+
});
|
|
527
|
+
} else {
|
|
528
|
+
const sb = kc.supabase;
|
|
529
|
+
const url = sb ? env[sb.urlSecret] : undefined;
|
|
530
|
+
const key = sb ? env[sb.keySecret] : undefined;
|
|
531
|
+
if (!sb || !nonEmpty(url) || !nonEmpty(key)) {
|
|
532
|
+
agentLog(
|
|
533
|
+
"info",
|
|
534
|
+
"knowledge: Supabase URL or key secret is not set, search_knowledge disabled",
|
|
535
|
+
);
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (!/^https:\/\//i.test(url.trim())) {
|
|
539
|
+
const local = /^http:\/\/(127\.0\.0\.1|localhost)(:|\/|$)/i.test(
|
|
540
|
+
url.trim(),
|
|
541
|
+
);
|
|
542
|
+
if (!local || !opts.knowledge?.allowInsecureLocal) {
|
|
543
|
+
agentLog(
|
|
544
|
+
"info",
|
|
545
|
+
"knowledge: supabase url must use https; knowledge search disabled",
|
|
546
|
+
);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
base = createSupabaseKnowledgeBase({
|
|
551
|
+
allowInsecureLocal: opts.knowledge?.allowInsecureLocal,
|
|
552
|
+
url,
|
|
553
|
+
key,
|
|
554
|
+
rpc: sb.rpc,
|
|
555
|
+
matchThreshold: sb.matchThreshold,
|
|
556
|
+
embedder: createLlmEmbedder(
|
|
557
|
+
{ provider: emb.provider, apiKey },
|
|
558
|
+
opts.providers ?? [],
|
|
559
|
+
),
|
|
560
|
+
model,
|
|
561
|
+
dims,
|
|
562
|
+
cache: nonEmpty(redisUrl)
|
|
563
|
+
? {
|
|
564
|
+
redisUrl,
|
|
565
|
+
ttlSeconds: sb.cacheTtlSeconds,
|
|
566
|
+
namespace: kc.redis?.namespace,
|
|
567
|
+
}
|
|
568
|
+
: undefined,
|
|
569
|
+
logger: knowledgeLogger,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
// The agent runtime has no shutdown hook: the connection is closed with the process.
|
|
574
|
+
// Indexing never blocks agent start; search retries the index on demand.
|
|
575
|
+
void base.ensureIndexed().then(
|
|
576
|
+
(report) =>
|
|
577
|
+
agentLog("info", "knowledge indexed", {
|
|
578
|
+
status: report.status,
|
|
579
|
+
chunks: report.chunks,
|
|
580
|
+
waitedMs: report.waitedMs,
|
|
581
|
+
}),
|
|
582
|
+
(err: unknown) =>
|
|
583
|
+
agentLog("warn", "knowledge indexing failed", {
|
|
584
|
+
code:
|
|
585
|
+
typeof (err as { code?: unknown })?.code === "string"
|
|
586
|
+
? (err as { code: string }).code
|
|
587
|
+
: "KB_UNKNOWN",
|
|
588
|
+
}),
|
|
589
|
+
);
|
|
590
|
+
knowledgeTool = searchKnowledgeTool(base, { topK, log: logCode });
|
|
591
|
+
}
|
|
592
|
+
|
|
422
593
|
function buildRegistry(env: Record<string, string | undefined>): void {
|
|
423
594
|
const reg = new ToolRegistry({
|
|
424
595
|
log: (level, message, fields) => agentLog(level, message, fields ?? {}),
|
|
@@ -427,6 +598,15 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
427
598
|
secretValues: secretValuesFromEnv(env, [
|
|
428
599
|
config.apiKeySecret,
|
|
429
600
|
"AGENT_SERVICE_TOKEN",
|
|
601
|
+
...(config.knowledge?.embeddings
|
|
602
|
+
? [config.knowledge.embeddings.apiKeySecret]
|
|
603
|
+
: []),
|
|
604
|
+
...(config.knowledge?.supabase
|
|
605
|
+
? [
|
|
606
|
+
config.knowledge.supabase.keySecret,
|
|
607
|
+
config.knowledge.supabase.urlSecret,
|
|
608
|
+
]
|
|
609
|
+
: []),
|
|
430
610
|
...(config.toolSources ?? []).flatMap((src) => {
|
|
431
611
|
if (src.kind !== "mcp" || !src.auth) return [];
|
|
432
612
|
if (src.auth.type === "bearer") return [src.auth.secret];
|
|
@@ -440,6 +620,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
440
620
|
},
|
|
441
621
|
});
|
|
442
622
|
for (const tool of opts.tools ?? []) reg.addCustomTool(tool);
|
|
623
|
+
if (knowledgeTool) reg.addCustomTool(knowledgeTool);
|
|
443
624
|
const sources: McpToolSource[] = [];
|
|
444
625
|
for (const src of config.toolSources ?? []) {
|
|
445
626
|
if (src.kind === "service") {
|
|
@@ -645,6 +826,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
645
826
|
t.roundOpen = true;
|
|
646
827
|
t.roundText = "";
|
|
647
828
|
const splitter = new SentenceSplitter();
|
|
829
|
+
const stripper = new ThinkingStripper();
|
|
648
830
|
let done: Extract<LlmStreamEvent, { type: "done" }> | undefined;
|
|
649
831
|
const stream = provider!.stream({
|
|
650
832
|
model: resolveModel(config.provider, config.model),
|
|
@@ -659,7 +841,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
659
841
|
if (signal.aborted) break;
|
|
660
842
|
if (ev.type === "text_delta") {
|
|
661
843
|
if (t.firstTokenMs === undefined) t.firstTokenMs = now() - t.startedAt;
|
|
662
|
-
for (const sentence of splitter.push(ev.text)) {
|
|
844
|
+
for (const sentence of splitter.push(stripper.push(ev.text))) {
|
|
663
845
|
await emitSentence(s, t, ctx, sentence);
|
|
664
846
|
}
|
|
665
847
|
} else {
|
|
@@ -673,9 +855,24 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
673
855
|
"stream ended without done",
|
|
674
856
|
);
|
|
675
857
|
}
|
|
676
|
-
|
|
858
|
+
const tail = stripper.end();
|
|
859
|
+
const sentences = tail
|
|
860
|
+
? [...splitter.push(tail), ...splitter.end()]
|
|
861
|
+
: splitter.end();
|
|
862
|
+
for (const sentence of sentences) {
|
|
677
863
|
await emitSentence(s, t, ctx, sentence);
|
|
678
864
|
}
|
|
865
|
+
t.thinkingCharsStripped += stripper.strippedChars;
|
|
866
|
+
// History keeps what was spoken, not the model's private reasoning.
|
|
867
|
+
const cleaned = stripThinking(done.text);
|
|
868
|
+
if (cleaned.strippedChars > 0) {
|
|
869
|
+
// Anthropic/Gemini resend providerState instead of text, so drop it when
|
|
870
|
+
// text was stripped (same as history.replaceAssistantText).
|
|
871
|
+
const { providerState: _drop, ...rest } = done;
|
|
872
|
+
done = { ...rest, text: cleaned.text };
|
|
873
|
+
} else {
|
|
874
|
+
done = { ...done, text: cleaned.text };
|
|
875
|
+
}
|
|
679
876
|
flushSpeech(s, t);
|
|
680
877
|
if (done.usage) {
|
|
681
878
|
if (done.usage.inputTokens !== undefined) {
|
|
@@ -915,6 +1112,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
915
1112
|
firstTokenMs: summary.firstTokenMs,
|
|
916
1113
|
inputTokens: summary.inputTokens,
|
|
917
1114
|
outputTokens: summary.outputTokens,
|
|
1115
|
+
thinkingCharsStripped: t.thinkingCharsStripped,
|
|
918
1116
|
},
|
|
919
1117
|
s.sessionId,
|
|
920
1118
|
);
|
|
@@ -945,6 +1143,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
945
1143
|
pending: [],
|
|
946
1144
|
pendingChars: 0,
|
|
947
1145
|
fallbackSpoken: false,
|
|
1146
|
+
thinkingCharsStripped: 0,
|
|
948
1147
|
status: "completed",
|
|
949
1148
|
};
|
|
950
1149
|
const ctx: TurnContext = {
|
|
@@ -1079,6 +1278,7 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1079
1278
|
opts.providers ?? [],
|
|
1080
1279
|
);
|
|
1081
1280
|
}
|
|
1281
|
+
buildKnowledge(env);
|
|
1082
1282
|
buildRegistry(env);
|
|
1083
1283
|
},
|
|
1084
1284
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicethere/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
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
|
|