@voicethere/agent 0.24.0 → 0.26.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 +28 -0
- package/dist/agent.js +11 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -1
- package/dist/flow/classify.d.ts +12 -0
- package/dist/flow/classify.d.ts.map +1 -0
- package/dist/flow/classify.js +37 -0
- package/dist/flow/classify.js.map +1 -0
- package/dist/flow/cli-flow.d.ts +19 -0
- package/dist/flow/cli-flow.d.ts.map +1 -0
- package/dist/flow/cli-flow.js +566 -0
- package/dist/flow/cli-flow.js.map +1 -0
- package/dist/flow/core/compile.d.ts +131 -0
- package/dist/flow/core/compile.d.ts.map +1 -0
- package/dist/flow/core/compile.js +197 -0
- package/dist/flow/core/compile.js.map +1 -0
- package/dist/flow/core/conditions.d.ts +5 -0
- package/dist/flow/core/conditions.d.ts.map +1 -0
- package/dist/flow/core/conditions.js +70 -0
- package/dist/flow/core/conditions.js.map +1 -0
- package/dist/flow/core/effects.d.ts +105 -0
- package/dist/flow/core/effects.d.ts.map +1 -0
- package/dist/flow/core/effects.js +2 -0
- package/dist/flow/core/effects.js.map +1 -0
- package/dist/flow/core/generate-mock.d.ts +16 -0
- package/dist/flow/core/generate-mock.d.ts.map +1 -0
- package/dist/flow/core/generate-mock.js +206 -0
- package/dist/flow/core/generate-mock.js.map +1 -0
- package/dist/flow/core/host.d.ts +9 -0
- package/dist/flow/core/host.d.ts.map +1 -0
- package/dist/flow/core/host.js +99 -0
- package/dist/flow/core/host.js.map +1 -0
- package/dist/flow/core/index.d.ts +17 -0
- package/dist/flow/core/index.d.ts.map +1 -0
- package/dist/flow/core/index.js +17 -0
- package/dist/flow/core/index.js.map +1 -0
- package/dist/flow/core/interpreter.d.ts +69 -0
- package/dist/flow/core/interpreter.d.ts.map +1 -0
- package/dist/flow/core/interpreter.js +738 -0
- package/dist/flow/core/interpreter.js.map +1 -0
- package/dist/flow/core/json-pointer.d.ts +6 -0
- package/dist/flow/core/json-pointer.d.ts.map +1 -0
- package/dist/flow/core/json-pointer.js +28 -0
- package/dist/flow/core/json-pointer.js.map +1 -0
- package/dist/flow/core/migrate.d.ts +16 -0
- package/dist/flow/core/migrate.d.ts.map +1 -0
- package/dist/flow/core/migrate.js +29 -0
- package/dist/flow/core/migrate.js.map +1 -0
- package/dist/flow/core/mock-effects.d.ts +14 -0
- package/dist/flow/core/mock-effects.d.ts.map +1 -0
- package/dist/flow/core/mock-effects.js +90 -0
- package/dist/flow/core/mock-effects.js.map +1 -0
- package/dist/flow/core/mocks.d.ts +55 -0
- package/dist/flow/core/mocks.d.ts.map +1 -0
- package/dist/flow/core/mocks.js +73 -0
- package/dist/flow/core/mocks.js.map +1 -0
- package/dist/flow/core/route.d.ts +29 -0
- package/dist/flow/core/route.d.ts.map +1 -0
- package/dist/flow/core/route.js +61 -0
- package/dist/flow/core/route.js.map +1 -0
- package/dist/flow/core/schema.d.ts +19 -0
- package/dist/flow/core/schema.d.ts.map +1 -0
- package/dist/flow/core/schema.js +317 -0
- package/dist/flow/core/schema.js.map +1 -0
- package/dist/flow/core/template.d.ts +16 -0
- package/dist/flow/core/template.d.ts.map +1 -0
- package/dist/flow/core/template.js +65 -0
- package/dist/flow/core/template.js.map +1 -0
- package/dist/flow/core/trace.d.ts +26 -0
- package/dist/flow/core/trace.d.ts.map +1 -0
- package/dist/flow/core/trace.js +2 -0
- package/dist/flow/core/trace.js.map +1 -0
- package/dist/flow/core/types.d.ts +159 -0
- package/dist/flow/core/types.d.ts.map +1 -0
- package/dist/flow/core/types.js +2 -0
- package/dist/flow/core/types.js.map +1 -0
- package/dist/flow/core/validate.d.ts +3 -0
- package/dist/flow/core/validate.d.ts.map +1 -0
- package/dist/flow/core/validate.js +550 -0
- package/dist/flow/core/validate.js.map +1 -0
- package/dist/flow/create-flow-agent.d.ts +36 -0
- package/dist/flow/create-flow-agent.d.ts.map +1 -0
- package/dist/flow/create-flow-agent.js +175 -0
- package/dist/flow/create-flow-agent.js.map +1 -0
- package/dist/flow/effects-node.d.ts +21 -0
- package/dist/flow/effects-node.d.ts.map +1 -0
- package/dist/flow/effects-node.js +189 -0
- package/dist/flow/effects-node.js.map +1 -0
- package/dist/flow/index.d.ts +12 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +7 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/llm-node.d.ts +24 -0
- package/dist/flow/llm-node.d.ts.map +1 -0
- package/dist/flow/llm-node.js +251 -0
- package/dist/flow/llm-node.js.map +1 -0
- package/dist/flow/record.d.ts +22 -0
- package/dist/flow/record.d.ts.map +1 -0
- package/dist/flow/record.js +126 -0
- package/dist/flow/record.js.map +1 -0
- package/dist/llm/agent/build-tool-registry.d.ts +26 -0
- package/dist/llm/agent/build-tool-registry.d.ts.map +1 -0
- package/dist/llm/agent/build-tool-registry.js +106 -0
- package/dist/llm/agent/build-tool-registry.js.map +1 -0
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +45 -106
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/anthropic-provider.d.ts.map +1 -1
- package/dist/llm/anthropic-provider.js +10 -0
- package/dist/llm/anthropic-provider.js.map +1 -1
- package/dist/llm/catalog.d.ts +4 -0
- package/dist/llm/catalog.d.ts.map +1 -1
- package/dist/llm/catalog.js +7 -0
- package/dist/llm/catalog.js.map +1 -1
- package/dist/llm/gemini-provider.d.ts.map +1 -1
- package/dist/llm/gemini-provider.js +12 -0
- package/dist/llm/gemini-provider.js.map +1 -1
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/openai-provider.d.ts.map +1 -1
- package/dist/llm/openai-provider.js +10 -0
- package/dist/llm/openai-provider.js.map +1 -1
- package/dist/llm/types.d.ts +7 -2
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js.map +1 -1
- package/dist/protocol.d.ts +4 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime.d.ts +4 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +10 -0
- package/dist/runtime.js.map +1 -1
- package/dist/templates/echo/agent.js +12 -2
- package/dist/templates/flow-agent/agent.js +49085 -0
- package/dist/templates/language-switch/agent.js +12 -2
- package/dist/templates/llm-agent/agent.js +156 -106
- package/dist/templates/llm-docs-rag/agent.js +156 -106
- package/dist/templates/llm-mcp-service/agent.js +156 -106
- package/dist/templates/positional-tts/agent.js +12 -2
- package/dist/templates/recording-consent/agent.js +12 -2
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +23 -0
- package/dist/templates/registry.js.map +1 -1
- package/dist/templates/spatial-showcase/agent.js +12 -2
- package/dist/templates/voice-showcase/agent.js +12 -2
- package/dist/templates/voice-starter/agent.js +12 -2
- package/dist/templates/webhooks/agent.js +12 -2
- package/eject/llm/loop.ts +51 -104
- package/package.json +19 -2
- package/schema/voicethere.flow.schema.json +681 -0
- package/templates/flow-agent/README.md +38 -0
- package/templates/flow-agent/agent.ts +14 -0
- package/templates/flow-agent/tools.ts +5 -0
- package/templates/flow-agent/voicethere.flow.json +80 -0
- package/templates/flow-agent/voicethere.flow.mocks.json +17 -0
- package/templates/llm-agent/README.md +4 -2
|
@@ -1154,6 +1154,14 @@ function buildIdleEnv(sessionId) {
|
|
|
1154
1154
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1155
1155
|
};
|
|
1156
1156
|
}
|
|
1157
|
+
function speakKindFields(options) {
|
|
1158
|
+
if (options?.kind !== "filler")
|
|
1159
|
+
return {};
|
|
1160
|
+
return {
|
|
1161
|
+
kind: "filler",
|
|
1162
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1157
1165
|
function speakControlAvailableFor(sessionId) {
|
|
1158
1166
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
1159
1167
|
}
|
|
@@ -1191,7 +1199,8 @@ function speak(sessionId, text, options) {
|
|
|
1191
1199
|
type: "speak",
|
|
1192
1200
|
sessionId,
|
|
1193
1201
|
text,
|
|
1194
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
1202
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1203
|
+
...speakKindFields(options)
|
|
1195
1204
|
});
|
|
1196
1205
|
warnSpeakControlUnavailable(sessionId);
|
|
1197
1206
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -1223,7 +1232,8 @@ function speak(sessionId, text, options) {
|
|
|
1223
1232
|
requestId,
|
|
1224
1233
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1225
1234
|
...turnId ? { turnId } : {},
|
|
1226
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
1235
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
1236
|
+
...speakKindFields(options)
|
|
1227
1237
|
});
|
|
1228
1238
|
return {
|
|
1229
1239
|
requestId,
|
|
@@ -31724,6 +31724,14 @@ function buildIdleEnv(sessionId) {
|
|
|
31724
31724
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
31725
31725
|
};
|
|
31726
31726
|
}
|
|
31727
|
+
function speakKindFields(options) {
|
|
31728
|
+
if (options?.kind !== "filler")
|
|
31729
|
+
return {};
|
|
31730
|
+
return {
|
|
31731
|
+
kind: "filler",
|
|
31732
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
31733
|
+
};
|
|
31734
|
+
}
|
|
31727
31735
|
function speakControlAvailableFor(sessionId) {
|
|
31728
31736
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
31729
31737
|
}
|
|
@@ -31761,7 +31769,8 @@ function speak(sessionId, text, options) {
|
|
|
31761
31769
|
type: "speak",
|
|
31762
31770
|
sessionId,
|
|
31763
31771
|
text,
|
|
31764
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
31772
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
31773
|
+
...speakKindFields(options)
|
|
31765
31774
|
});
|
|
31766
31775
|
warnSpeakControlUnavailable(sessionId);
|
|
31767
31776
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -31793,7 +31802,8 @@ function speak(sessionId, text, options) {
|
|
|
31793
31802
|
requestId,
|
|
31794
31803
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
31795
31804
|
...turnId ? { turnId } : {},
|
|
31796
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
31805
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
31806
|
+
...speakKindFields(options)
|
|
31797
31807
|
});
|
|
31798
31808
|
return {
|
|
31799
31809
|
requestId,
|
|
@@ -32240,12 +32250,14 @@ var LLM_PROVIDERS = {
|
|
|
32240
32250
|
openai: {
|
|
32241
32251
|
title: "OpenAI",
|
|
32242
32252
|
defaultModel: "gpt-4o-mini",
|
|
32253
|
+
cheapModel: "gpt-4o-mini",
|
|
32243
32254
|
apiKeyEnv: "AGENT_OPENAI_API_KEY",
|
|
32244
32255
|
docsUrl: "https://platform.openai.com/docs/api-reference/chat"
|
|
32245
32256
|
},
|
|
32246
32257
|
anthropic: {
|
|
32247
32258
|
title: "Anthropic",
|
|
32248
32259
|
defaultModel: "claude-haiku-5-5",
|
|
32260
|
+
cheapModel: "claude-haiku-5-5",
|
|
32249
32261
|
apiKeyEnv: "AGENT_ANTHROPIC_API_KEY",
|
|
32250
32262
|
docsUrl: "https://docs.anthropic.com/en/api/messages"
|
|
32251
32263
|
},
|
|
@@ -32261,6 +32273,7 @@ var LLM_PROVIDERS = {
|
|
|
32261
32273
|
// toolChoice "required-first-round"). amazon/nova-micro-v1, the previous
|
|
32262
32274
|
// default, does not list tool_choice and skipped tools it was told to call.
|
|
32263
32275
|
defaultModel: "anthropic/claude-haiku-5.5",
|
|
32276
|
+
cheapModel: "anthropic/claude-haiku-5.5",
|
|
32264
32277
|
apiKeyEnv: "AGENT_OPENROUTER_API_KEY",
|
|
32265
32278
|
docsUrl: "https://openrouter.ai/docs/api-reference/overview"
|
|
32266
32279
|
}
|
|
@@ -34916,6 +34929,101 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
|
|
|
34916
34929
|
}
|
|
34917
34930
|
};
|
|
34918
34931
|
|
|
34932
|
+
// dist/llm/agent/build-tool-registry.js
|
|
34933
|
+
function nonEmpty(v) {
|
|
34934
|
+
return v !== void 0 && v.length > 0;
|
|
34935
|
+
}
|
|
34936
|
+
function buildToolRegistry(o) {
|
|
34937
|
+
const { env } = o;
|
|
34938
|
+
const makeSource = o.makeSource ?? ((x) => new McpToolSource(x));
|
|
34939
|
+
const reg = new ToolRegistry({
|
|
34940
|
+
log: (level, message, fields) => agentLog(level, message, fields ?? {}),
|
|
34941
|
+
toolCallLog: {
|
|
34942
|
+
mode: o.toolCallLogs,
|
|
34943
|
+
secretValues: secretValuesFromEnv(env, [
|
|
34944
|
+
...o.secretNames,
|
|
34945
|
+
...o.toolSources.flatMap((src) => {
|
|
34946
|
+
if (src.kind !== "mcp" || !src.auth)
|
|
34947
|
+
return [];
|
|
34948
|
+
if (src.auth.type === "bearer")
|
|
34949
|
+
return [src.auth.secret];
|
|
34950
|
+
if (src.auth.type === "headers")
|
|
34951
|
+
return Object.values(src.auth.headers);
|
|
34952
|
+
return [];
|
|
34953
|
+
})
|
|
34954
|
+
]),
|
|
34955
|
+
emit: (fields, sid) => agentLog("info", "llm tool call", { ...fields }, sid)
|
|
34956
|
+
}
|
|
34957
|
+
});
|
|
34958
|
+
for (const tool of o.customTools)
|
|
34959
|
+
reg.addCustomTool(tool);
|
|
34960
|
+
let serviceSource;
|
|
34961
|
+
const sources = [];
|
|
34962
|
+
for (const src of o.toolSources) {
|
|
34963
|
+
if (src.kind === "service") {
|
|
34964
|
+
const base = env.AGENT_SERVICE_URL;
|
|
34965
|
+
if (!nonEmpty(base)) {
|
|
34966
|
+
agentLog("warn", "toolSources: service configured but this project has no service");
|
|
34967
|
+
continue;
|
|
34968
|
+
}
|
|
34969
|
+
const headers = {};
|
|
34970
|
+
const token = env.AGENT_SERVICE_TOKEN;
|
|
34971
|
+
if (nonEmpty(token)) {
|
|
34972
|
+
headers.Authorization = `Bearer ${token}`;
|
|
34973
|
+
} else {
|
|
34974
|
+
agentLog("warn", "toolSources: AGENT_SERVICE_TOKEN is not set");
|
|
34975
|
+
}
|
|
34976
|
+
const source = makeSource({
|
|
34977
|
+
name: "service",
|
|
34978
|
+
kind: "service",
|
|
34979
|
+
url: `${base}${src.path ?? o.servicePath}`,
|
|
34980
|
+
headers,
|
|
34981
|
+
allow: src.allow,
|
|
34982
|
+
deny: src.deny,
|
|
34983
|
+
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
34984
|
+
});
|
|
34985
|
+
serviceSource = source;
|
|
34986
|
+
sources.push(source);
|
|
34987
|
+
} else {
|
|
34988
|
+
const headers = {};
|
|
34989
|
+
let missing;
|
|
34990
|
+
const auth2 = src.auth ?? { type: "none" };
|
|
34991
|
+
if (auth2.type === "bearer") {
|
|
34992
|
+
const v = env[auth2.secret];
|
|
34993
|
+
if (nonEmpty(v))
|
|
34994
|
+
headers.Authorization = `Bearer ${v}`;
|
|
34995
|
+
else
|
|
34996
|
+
missing = auth2.secret;
|
|
34997
|
+
} else if (auth2.type === "headers") {
|
|
34998
|
+
for (const [header, envName2] of Object.entries(auth2.headers)) {
|
|
34999
|
+
const v = env[envName2];
|
|
35000
|
+
if (nonEmpty(v))
|
|
35001
|
+
headers[header] = v;
|
|
35002
|
+
else
|
|
35003
|
+
missing = envName2;
|
|
35004
|
+
}
|
|
35005
|
+
}
|
|
35006
|
+
if (missing) {
|
|
35007
|
+
agentLog("warn", `toolSources: ${src.name} skipped, environment variable ${missing} is not set`);
|
|
35008
|
+
continue;
|
|
35009
|
+
}
|
|
35010
|
+
sources.push(makeSource({
|
|
35011
|
+
name: src.name,
|
|
35012
|
+
url: src.url,
|
|
35013
|
+
headers,
|
|
35014
|
+
allow: src.allow,
|
|
35015
|
+
deny: src.deny,
|
|
35016
|
+
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
35017
|
+
}));
|
|
35018
|
+
}
|
|
35019
|
+
}
|
|
35020
|
+
for (const source of sources) {
|
|
35021
|
+
reg.addSource(source);
|
|
35022
|
+
source.start();
|
|
35023
|
+
}
|
|
35024
|
+
return { registry: reg, serviceSource };
|
|
35025
|
+
}
|
|
35026
|
+
|
|
34919
35027
|
// dist/llm/agent/history.js
|
|
34920
35028
|
var ConversationHistory = class {
|
|
34921
35029
|
maxTurns;
|
|
@@ -35443,7 +35551,7 @@ function checkContent(content) {
|
|
|
35443
35551
|
function interruptionNote(played, unplayed) {
|
|
35444
35552
|
return `(The caller interrupted your previous reply after: "${played}". They did not hear: "${unplayed}".)`;
|
|
35445
35553
|
}
|
|
35446
|
-
function
|
|
35554
|
+
function nonEmpty2(v) {
|
|
35447
35555
|
return v !== void 0 && v.length > 0;
|
|
35448
35556
|
}
|
|
35449
35557
|
function createLlmAgent(opts) {
|
|
@@ -35583,11 +35691,15 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35583
35691
|
}
|
|
35584
35692
|
}
|
|
35585
35693
|
}
|
|
35586
|
-
function
|
|
35694
|
+
function sendFillerMessage(s, turnId, text) {
|
|
35695
|
+
sendToClient(s.sessionId, { type: "assistant_filler", turnId, text });
|
|
35696
|
+
}
|
|
35697
|
+
function speakAnnouncement(s, turnId, text, interruptible, fillerKind) {
|
|
35698
|
+
const opts2 = fillerKind ? { turnId, kind: "filler", fillerKind } : { turnId };
|
|
35587
35699
|
if (interruptible) {
|
|
35588
|
-
return speak(s.sessionId, text,
|
|
35700
|
+
return speak(s.sessionId, text, opts2);
|
|
35589
35701
|
}
|
|
35590
|
-
const h = announce(s.sessionId, text,
|
|
35702
|
+
const h = announce(s.sessionId, text, opts2);
|
|
35591
35703
|
trackAnnouncement(s, h.done);
|
|
35592
35704
|
return h;
|
|
35593
35705
|
}
|
|
@@ -35656,7 +35768,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35656
35768
|
t.toolCallSpoken = true;
|
|
35657
35769
|
if (kind === "toolWait")
|
|
35658
35770
|
t.toolWaitSpoken += 1;
|
|
35659
|
-
speakAnnouncement(s, t.turnId, text, fillersInterruptible);
|
|
35771
|
+
speakAnnouncement(s, t.turnId, text, fillersInterruptible, kind);
|
|
35772
|
+
sendFillerMessage(s, t.turnId, text);
|
|
35660
35773
|
return void 0;
|
|
35661
35774
|
}
|
|
35662
35775
|
function armFiller(s, t, kind, delayMs, afterMs) {
|
|
@@ -35736,7 +35849,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35736
35849
|
if (!emb)
|
|
35737
35850
|
return;
|
|
35738
35851
|
const apiKey = env[emb.apiKeySecret];
|
|
35739
|
-
if (!
|
|
35852
|
+
if (!nonEmpty2(apiKey)) {
|
|
35740
35853
|
agentLog("warn", `knowledge: ${emb.apiKeySecret} is not set, search_knowledge disabled`);
|
|
35741
35854
|
return;
|
|
35742
35855
|
}
|
|
@@ -35746,7 +35859,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35746
35859
|
const dims = emb.dimensions ?? DEFAULT_EMBEDDING_DIMS;
|
|
35747
35860
|
const redisUrl = env.AGENT_REDIS_URL;
|
|
35748
35861
|
if (kc.store === "redis") {
|
|
35749
|
-
if (!
|
|
35862
|
+
if (!nonEmpty2(redisUrl)) {
|
|
35750
35863
|
agentLog("info", "knowledge: AGENT_REDIS_URL unset (enable Project Redis)");
|
|
35751
35864
|
return;
|
|
35752
35865
|
}
|
|
@@ -35768,7 +35881,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35768
35881
|
const sb = kc.supabase;
|
|
35769
35882
|
const url2 = sb ? env[sb.urlSecret] : void 0;
|
|
35770
35883
|
const key = sb ? env[sb.keySecret] : void 0;
|
|
35771
|
-
if (!sb || !
|
|
35884
|
+
if (!sb || !nonEmpty2(url2) || !nonEmpty2(key)) {
|
|
35772
35885
|
agentLog("info", "knowledge: Supabase URL or key secret is not set, search_knowledge disabled");
|
|
35773
35886
|
return;
|
|
35774
35887
|
}
|
|
@@ -35788,7 +35901,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35788
35901
|
embedder: createLlmEmbedder({ provider: emb.provider, apiKey }, opts.providers ?? []),
|
|
35789
35902
|
model,
|
|
35790
35903
|
dims,
|
|
35791
|
-
cache:
|
|
35904
|
+
cache: nonEmpty2(redisUrl) ? {
|
|
35792
35905
|
redisUrl,
|
|
35793
35906
|
ttlSeconds: sb.cacheTtlSeconds,
|
|
35794
35907
|
namespace: kc.redis?.namespace
|
|
@@ -35807,99 +35920,29 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35807
35920
|
knowledgeTool = searchKnowledgeTool(base, { topK, log: logCode });
|
|
35808
35921
|
}
|
|
35809
35922
|
function buildRegistry(env) {
|
|
35810
|
-
const
|
|
35811
|
-
|
|
35812
|
-
|
|
35813
|
-
|
|
35814
|
-
|
|
35815
|
-
|
|
35816
|
-
|
|
35817
|
-
|
|
35818
|
-
|
|
35819
|
-
|
|
35820
|
-
|
|
35821
|
-
|
|
35822
|
-
|
|
35823
|
-
|
|
35824
|
-
|
|
35825
|
-
|
|
35826
|
-
|
|
35827
|
-
|
|
35828
|
-
|
|
35829
|
-
|
|
35830
|
-
|
|
35831
|
-
|
|
35832
|
-
|
|
35833
|
-
}
|
|
35834
|
-
});
|
|
35835
|
-
for (const tool of opts.tools ?? [])
|
|
35836
|
-
reg.addCustomTool(tool);
|
|
35837
|
-
if (knowledgeTool)
|
|
35838
|
-
reg.addCustomTool(knowledgeTool);
|
|
35839
|
-
const sources = [];
|
|
35840
|
-
for (const src of config2.toolSources ?? []) {
|
|
35841
|
-
if (src.kind === "service") {
|
|
35842
|
-
const base = env.AGENT_SERVICE_URL;
|
|
35843
|
-
if (!nonEmpty(base)) {
|
|
35844
|
-
agentLog("warn", "toolSources: service configured but this project has no service");
|
|
35845
|
-
continue;
|
|
35846
|
-
}
|
|
35847
|
-
const headers = {};
|
|
35848
|
-
const token = env.AGENT_SERVICE_TOKEN;
|
|
35849
|
-
if (nonEmpty(token)) {
|
|
35850
|
-
headers.Authorization = `Bearer ${token}`;
|
|
35851
|
-
} else {
|
|
35852
|
-
agentLog("warn", "toolSources: AGENT_SERVICE_TOKEN is not set");
|
|
35853
|
-
}
|
|
35854
|
-
const source = makeSource({
|
|
35855
|
-
name: "service",
|
|
35856
|
-
kind: "service",
|
|
35857
|
-
url: `${base}${src.path ?? D.servicePath}`,
|
|
35858
|
-
headers,
|
|
35859
|
-
allow: src.allow,
|
|
35860
|
-
deny: src.deny,
|
|
35861
|
-
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
35862
|
-
});
|
|
35863
|
-
serviceSource = source;
|
|
35864
|
-
sources.push(source);
|
|
35865
|
-
} else {
|
|
35866
|
-
const headers = {};
|
|
35867
|
-
let missing;
|
|
35868
|
-
const auth2 = src.auth ?? { type: "none" };
|
|
35869
|
-
if (auth2.type === "bearer") {
|
|
35870
|
-
const v = env[auth2.secret];
|
|
35871
|
-
if (nonEmpty(v))
|
|
35872
|
-
headers.Authorization = `Bearer ${v}`;
|
|
35873
|
-
else
|
|
35874
|
-
missing = auth2.secret;
|
|
35875
|
-
} else if (auth2.type === "headers") {
|
|
35876
|
-
for (const [header, envName2] of Object.entries(auth2.headers)) {
|
|
35877
|
-
const v = env[envName2];
|
|
35878
|
-
if (nonEmpty(v))
|
|
35879
|
-
headers[header] = v;
|
|
35880
|
-
else
|
|
35881
|
-
missing = envName2;
|
|
35882
|
-
}
|
|
35883
|
-
}
|
|
35884
|
-
if (missing) {
|
|
35885
|
-
agentLog("warn", `toolSources: ${src.name} skipped, environment variable ${missing} is not set`);
|
|
35886
|
-
continue;
|
|
35887
|
-
}
|
|
35888
|
-
sources.push(makeSource({
|
|
35889
|
-
name: src.name,
|
|
35890
|
-
url: src.url,
|
|
35891
|
-
headers,
|
|
35892
|
-
allow: src.allow,
|
|
35893
|
-
deny: src.deny,
|
|
35894
|
-
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
35895
|
-
}));
|
|
35896
|
-
}
|
|
35897
|
-
}
|
|
35898
|
-
for (const source of sources) {
|
|
35899
|
-
reg.addSource(source);
|
|
35900
|
-
source.start();
|
|
35901
|
-
}
|
|
35902
|
-
registry2 = reg;
|
|
35923
|
+
const built = buildToolRegistry({
|
|
35924
|
+
env,
|
|
35925
|
+
toolSources: config2.toolSources ?? [],
|
|
35926
|
+
customTools: [
|
|
35927
|
+
...opts.tools ?? [],
|
|
35928
|
+
...knowledgeTool ? [knowledgeTool] : []
|
|
35929
|
+
],
|
|
35930
|
+
secretNames: [
|
|
35931
|
+
config2.apiKeySecret,
|
|
35932
|
+
"AGENT_SERVICE_TOKEN",
|
|
35933
|
+
...config2.knowledge?.embeddings ? [config2.knowledge.embeddings.apiKeySecret] : [],
|
|
35934
|
+
...config2.knowledge?.supabase ? [
|
|
35935
|
+
config2.knowledge.supabase.keySecret,
|
|
35936
|
+
config2.knowledge.supabase.urlSecret
|
|
35937
|
+
] : []
|
|
35938
|
+
],
|
|
35939
|
+
toolCallLogs: config2.toolCallLogs ?? D.toolCallLogs,
|
|
35940
|
+
servicePath: D.servicePath,
|
|
35941
|
+
makeSource
|
|
35942
|
+
});
|
|
35943
|
+
if (built.serviceSource)
|
|
35944
|
+
serviceSource = built.serviceSource;
|
|
35945
|
+
registry2 = built.registry;
|
|
35903
35946
|
}
|
|
35904
35947
|
async function runTools(s, t, ctx, calls) {
|
|
35905
35948
|
const signal = t.controller.signal;
|
|
@@ -36183,7 +36226,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
36183
36226
|
if (t.fillerSpoken || signal.aborted)
|
|
36184
36227
|
return;
|
|
36185
36228
|
t.fillerSpoken = true;
|
|
36186
|
-
speakAnnouncement(s, t.turnId, fillerLegacy.text, fillerLegacy.interruptible ?? D.fillerInterruptible);
|
|
36229
|
+
speakAnnouncement(s, t.turnId, fillerLegacy.text, fillerLegacy.interruptible ?? D.fillerInterruptible, "toolWait");
|
|
36230
|
+
sendFillerMessage(s, t.turnId, fillerLegacy.text);
|
|
36187
36231
|
}, fillerLegacy.afterMs ?? D.fillerAfterMs);
|
|
36188
36232
|
}
|
|
36189
36233
|
let results;
|
|
@@ -36438,7 +36482,7 @@ ${t.inputText}` : t.inputText, {
|
|
|
36438
36482
|
}
|
|
36439
36483
|
const env = getEnv();
|
|
36440
36484
|
const apiKey = env[config2.apiKeySecret];
|
|
36441
|
-
if (!
|
|
36485
|
+
if (!nonEmpty2(apiKey)) {
|
|
36442
36486
|
throw configError(`environment variable ${config2.apiKeySecret} is not set`, "LLM_API_KEY_MISSING");
|
|
36443
36487
|
}
|
|
36444
36488
|
if (!provider) {
|
|
@@ -59910,6 +59954,12 @@ function createOpenAiCompatibleProvider(config2) {
|
|
|
59910
59954
|
stream_options: { include_usage: true },
|
|
59911
59955
|
...tools2.length > 0 ? { tools: tools2 } : {},
|
|
59912
59956
|
...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
|
|
59957
|
+
...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
|
|
59958
|
+
tool_choice: {
|
|
59959
|
+
type: "function",
|
|
59960
|
+
function: { name: req.toolChoice.name }
|
|
59961
|
+
}
|
|
59962
|
+
} : {},
|
|
59913
59963
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
59914
59964
|
...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
|
|
59915
59965
|
};
|