@voicethere/agent 0.25.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 +26 -0
- 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 +27 -101
- 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/templates/flow-agent/agent.js +49085 -0
- package/dist/templates/llm-agent/agent.js +133 -99
- package/dist/templates/llm-docs-rag/agent.js +133 -99
- package/dist/templates/llm-mcp-service/agent.js +133 -99
- 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/eject/llm/loop.ts +28 -101
- 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
|
@@ -32250,12 +32250,14 @@ var LLM_PROVIDERS = {
|
|
|
32250
32250
|
openai: {
|
|
32251
32251
|
title: "OpenAI",
|
|
32252
32252
|
defaultModel: "gpt-4o-mini",
|
|
32253
|
+
cheapModel: "gpt-4o-mini",
|
|
32253
32254
|
apiKeyEnv: "AGENT_OPENAI_API_KEY",
|
|
32254
32255
|
docsUrl: "https://platform.openai.com/docs/api-reference/chat"
|
|
32255
32256
|
},
|
|
32256
32257
|
anthropic: {
|
|
32257
32258
|
title: "Anthropic",
|
|
32258
32259
|
defaultModel: "claude-haiku-5-5",
|
|
32260
|
+
cheapModel: "claude-haiku-5-5",
|
|
32259
32261
|
apiKeyEnv: "AGENT_ANTHROPIC_API_KEY",
|
|
32260
32262
|
docsUrl: "https://docs.anthropic.com/en/api/messages"
|
|
32261
32263
|
},
|
|
@@ -32271,6 +32273,7 @@ var LLM_PROVIDERS = {
|
|
|
32271
32273
|
// toolChoice "required-first-round"). amazon/nova-micro-v1, the previous
|
|
32272
32274
|
// default, does not list tool_choice and skipped tools it was told to call.
|
|
32273
32275
|
defaultModel: "anthropic/claude-haiku-5.5",
|
|
32276
|
+
cheapModel: "anthropic/claude-haiku-5.5",
|
|
32274
32277
|
apiKeyEnv: "AGENT_OPENROUTER_API_KEY",
|
|
32275
32278
|
docsUrl: "https://openrouter.ai/docs/api-reference/overview"
|
|
32276
32279
|
}
|
|
@@ -34926,6 +34929,101 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
|
|
|
34926
34929
|
}
|
|
34927
34930
|
};
|
|
34928
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
|
+
|
|
34929
35027
|
// dist/llm/agent/history.js
|
|
34930
35028
|
var ConversationHistory = class {
|
|
34931
35029
|
maxTurns;
|
|
@@ -35453,7 +35551,7 @@ function checkContent(content) {
|
|
|
35453
35551
|
function interruptionNote(played, unplayed) {
|
|
35454
35552
|
return `(The caller interrupted your previous reply after: "${played}". They did not hear: "${unplayed}".)`;
|
|
35455
35553
|
}
|
|
35456
|
-
function
|
|
35554
|
+
function nonEmpty2(v) {
|
|
35457
35555
|
return v !== void 0 && v.length > 0;
|
|
35458
35556
|
}
|
|
35459
35557
|
function createLlmAgent(opts) {
|
|
@@ -35751,7 +35849,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35751
35849
|
if (!emb)
|
|
35752
35850
|
return;
|
|
35753
35851
|
const apiKey = env[emb.apiKeySecret];
|
|
35754
|
-
if (!
|
|
35852
|
+
if (!nonEmpty2(apiKey)) {
|
|
35755
35853
|
agentLog("warn", `knowledge: ${emb.apiKeySecret} is not set, search_knowledge disabled`);
|
|
35756
35854
|
return;
|
|
35757
35855
|
}
|
|
@@ -35761,7 +35859,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35761
35859
|
const dims = emb.dimensions ?? DEFAULT_EMBEDDING_DIMS;
|
|
35762
35860
|
const redisUrl = env.AGENT_REDIS_URL;
|
|
35763
35861
|
if (kc.store === "redis") {
|
|
35764
|
-
if (!
|
|
35862
|
+
if (!nonEmpty2(redisUrl)) {
|
|
35765
35863
|
agentLog("info", "knowledge: AGENT_REDIS_URL unset (enable Project Redis)");
|
|
35766
35864
|
return;
|
|
35767
35865
|
}
|
|
@@ -35783,7 +35881,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35783
35881
|
const sb = kc.supabase;
|
|
35784
35882
|
const url2 = sb ? env[sb.urlSecret] : void 0;
|
|
35785
35883
|
const key = sb ? env[sb.keySecret] : void 0;
|
|
35786
|
-
if (!sb || !
|
|
35884
|
+
if (!sb || !nonEmpty2(url2) || !nonEmpty2(key)) {
|
|
35787
35885
|
agentLog("info", "knowledge: Supabase URL or key secret is not set, search_knowledge disabled");
|
|
35788
35886
|
return;
|
|
35789
35887
|
}
|
|
@@ -35803,7 +35901,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35803
35901
|
embedder: createLlmEmbedder({ provider: emb.provider, apiKey }, opts.providers ?? []),
|
|
35804
35902
|
model,
|
|
35805
35903
|
dims,
|
|
35806
|
-
cache:
|
|
35904
|
+
cache: nonEmpty2(redisUrl) ? {
|
|
35807
35905
|
redisUrl,
|
|
35808
35906
|
ttlSeconds: sb.cacheTtlSeconds,
|
|
35809
35907
|
namespace: kc.redis?.namespace
|
|
@@ -35822,99 +35920,29 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35822
35920
|
knowledgeTool = searchKnowledgeTool(base, { topK, log: logCode });
|
|
35823
35921
|
}
|
|
35824
35922
|
function buildRegistry(env) {
|
|
35825
|
-
const
|
|
35826
|
-
|
|
35827
|
-
|
|
35828
|
-
|
|
35829
|
-
|
|
35830
|
-
|
|
35831
|
-
|
|
35832
|
-
|
|
35833
|
-
|
|
35834
|
-
|
|
35835
|
-
|
|
35836
|
-
|
|
35837
|
-
|
|
35838
|
-
|
|
35839
|
-
|
|
35840
|
-
|
|
35841
|
-
|
|
35842
|
-
|
|
35843
|
-
|
|
35844
|
-
|
|
35845
|
-
|
|
35846
|
-
|
|
35847
|
-
|
|
35848
|
-
}
|
|
35849
|
-
});
|
|
35850
|
-
for (const tool of opts.tools ?? [])
|
|
35851
|
-
reg.addCustomTool(tool);
|
|
35852
|
-
if (knowledgeTool)
|
|
35853
|
-
reg.addCustomTool(knowledgeTool);
|
|
35854
|
-
const sources = [];
|
|
35855
|
-
for (const src of config2.toolSources ?? []) {
|
|
35856
|
-
if (src.kind === "service") {
|
|
35857
|
-
const base = env.AGENT_SERVICE_URL;
|
|
35858
|
-
if (!nonEmpty(base)) {
|
|
35859
|
-
agentLog("warn", "toolSources: service configured but this project has no service");
|
|
35860
|
-
continue;
|
|
35861
|
-
}
|
|
35862
|
-
const headers = {};
|
|
35863
|
-
const token = env.AGENT_SERVICE_TOKEN;
|
|
35864
|
-
if (nonEmpty(token)) {
|
|
35865
|
-
headers.Authorization = `Bearer ${token}`;
|
|
35866
|
-
} else {
|
|
35867
|
-
agentLog("warn", "toolSources: AGENT_SERVICE_TOKEN is not set");
|
|
35868
|
-
}
|
|
35869
|
-
const source = makeSource({
|
|
35870
|
-
name: "service",
|
|
35871
|
-
kind: "service",
|
|
35872
|
-
url: `${base}${src.path ?? D.servicePath}`,
|
|
35873
|
-
headers,
|
|
35874
|
-
allow: src.allow,
|
|
35875
|
-
deny: src.deny,
|
|
35876
|
-
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
35877
|
-
});
|
|
35878
|
-
serviceSource = source;
|
|
35879
|
-
sources.push(source);
|
|
35880
|
-
} else {
|
|
35881
|
-
const headers = {};
|
|
35882
|
-
let missing;
|
|
35883
|
-
const auth2 = src.auth ?? { type: "none" };
|
|
35884
|
-
if (auth2.type === "bearer") {
|
|
35885
|
-
const v = env[auth2.secret];
|
|
35886
|
-
if (nonEmpty(v))
|
|
35887
|
-
headers.Authorization = `Bearer ${v}`;
|
|
35888
|
-
else
|
|
35889
|
-
missing = auth2.secret;
|
|
35890
|
-
} else if (auth2.type === "headers") {
|
|
35891
|
-
for (const [header, envName2] of Object.entries(auth2.headers)) {
|
|
35892
|
-
const v = env[envName2];
|
|
35893
|
-
if (nonEmpty(v))
|
|
35894
|
-
headers[header] = v;
|
|
35895
|
-
else
|
|
35896
|
-
missing = envName2;
|
|
35897
|
-
}
|
|
35898
|
-
}
|
|
35899
|
-
if (missing) {
|
|
35900
|
-
agentLog("warn", `toolSources: ${src.name} skipped, environment variable ${missing} is not set`);
|
|
35901
|
-
continue;
|
|
35902
|
-
}
|
|
35903
|
-
sources.push(makeSource({
|
|
35904
|
-
name: src.name,
|
|
35905
|
-
url: src.url,
|
|
35906
|
-
headers,
|
|
35907
|
-
allow: src.allow,
|
|
35908
|
-
deny: src.deny,
|
|
35909
|
-
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
35910
|
-
}));
|
|
35911
|
-
}
|
|
35912
|
-
}
|
|
35913
|
-
for (const source of sources) {
|
|
35914
|
-
reg.addSource(source);
|
|
35915
|
-
source.start();
|
|
35916
|
-
}
|
|
35917
|
-
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;
|
|
35918
35946
|
}
|
|
35919
35947
|
async function runTools(s, t, ctx, calls) {
|
|
35920
35948
|
const signal = t.controller.signal;
|
|
@@ -36454,7 +36482,7 @@ ${t.inputText}` : t.inputText, {
|
|
|
36454
36482
|
}
|
|
36455
36483
|
const env = getEnv();
|
|
36456
36484
|
const apiKey = env[config2.apiKeySecret];
|
|
36457
|
-
if (!
|
|
36485
|
+
if (!nonEmpty2(apiKey)) {
|
|
36458
36486
|
throw configError(`environment variable ${config2.apiKeySecret} is not set`, "LLM_API_KEY_MISSING");
|
|
36459
36487
|
}
|
|
36460
36488
|
if (!provider) {
|
|
@@ -59926,6 +59954,12 @@ function createOpenAiCompatibleProvider(config2) {
|
|
|
59926
59954
|
stream_options: { include_usage: true },
|
|
59927
59955
|
...tools2.length > 0 ? { tools: tools2 } : {},
|
|
59928
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
|
+
} : {},
|
|
59929
59963
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
59930
59964
|
...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
|
|
59931
59965
|
};
|
|
@@ -32250,12 +32250,14 @@ var LLM_PROVIDERS = {
|
|
|
32250
32250
|
openai: {
|
|
32251
32251
|
title: "OpenAI",
|
|
32252
32252
|
defaultModel: "gpt-4o-mini",
|
|
32253
|
+
cheapModel: "gpt-4o-mini",
|
|
32253
32254
|
apiKeyEnv: "AGENT_OPENAI_API_KEY",
|
|
32254
32255
|
docsUrl: "https://platform.openai.com/docs/api-reference/chat"
|
|
32255
32256
|
},
|
|
32256
32257
|
anthropic: {
|
|
32257
32258
|
title: "Anthropic",
|
|
32258
32259
|
defaultModel: "claude-haiku-5-5",
|
|
32260
|
+
cheapModel: "claude-haiku-5-5",
|
|
32259
32261
|
apiKeyEnv: "AGENT_ANTHROPIC_API_KEY",
|
|
32260
32262
|
docsUrl: "https://docs.anthropic.com/en/api/messages"
|
|
32261
32263
|
},
|
|
@@ -32271,6 +32273,7 @@ var LLM_PROVIDERS = {
|
|
|
32271
32273
|
// toolChoice "required-first-round"). amazon/nova-micro-v1, the previous
|
|
32272
32274
|
// default, does not list tool_choice and skipped tools it was told to call.
|
|
32273
32275
|
defaultModel: "anthropic/claude-haiku-5.5",
|
|
32276
|
+
cheapModel: "anthropic/claude-haiku-5.5",
|
|
32274
32277
|
apiKeyEnv: "AGENT_OPENROUTER_API_KEY",
|
|
32275
32278
|
docsUrl: "https://openrouter.ai/docs/api-reference/overview"
|
|
32276
32279
|
}
|
|
@@ -34926,6 +34929,101 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
|
|
|
34926
34929
|
}
|
|
34927
34930
|
};
|
|
34928
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
|
+
|
|
34929
35027
|
// dist/llm/agent/history.js
|
|
34930
35028
|
var ConversationHistory = class {
|
|
34931
35029
|
maxTurns;
|
|
@@ -35453,7 +35551,7 @@ function checkContent(content) {
|
|
|
35453
35551
|
function interruptionNote(played, unplayed) {
|
|
35454
35552
|
return `(The caller interrupted your previous reply after: "${played}". They did not hear: "${unplayed}".)`;
|
|
35455
35553
|
}
|
|
35456
|
-
function
|
|
35554
|
+
function nonEmpty2(v) {
|
|
35457
35555
|
return v !== void 0 && v.length > 0;
|
|
35458
35556
|
}
|
|
35459
35557
|
function createLlmAgent(opts) {
|
|
@@ -35751,7 +35849,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35751
35849
|
if (!emb)
|
|
35752
35850
|
return;
|
|
35753
35851
|
const apiKey = env[emb.apiKeySecret];
|
|
35754
|
-
if (!
|
|
35852
|
+
if (!nonEmpty2(apiKey)) {
|
|
35755
35853
|
agentLog("warn", `knowledge: ${emb.apiKeySecret} is not set, search_knowledge disabled`);
|
|
35756
35854
|
return;
|
|
35757
35855
|
}
|
|
@@ -35761,7 +35859,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35761
35859
|
const dims = emb.dimensions ?? DEFAULT_EMBEDDING_DIMS;
|
|
35762
35860
|
const redisUrl = env.AGENT_REDIS_URL;
|
|
35763
35861
|
if (kc.store === "redis") {
|
|
35764
|
-
if (!
|
|
35862
|
+
if (!nonEmpty2(redisUrl)) {
|
|
35765
35863
|
agentLog("info", "knowledge: AGENT_REDIS_URL unset (enable Project Redis)");
|
|
35766
35864
|
return;
|
|
35767
35865
|
}
|
|
@@ -35783,7 +35881,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35783
35881
|
const sb = kc.supabase;
|
|
35784
35882
|
const url2 = sb ? env[sb.urlSecret] : void 0;
|
|
35785
35883
|
const key = sb ? env[sb.keySecret] : void 0;
|
|
35786
|
-
if (!sb || !
|
|
35884
|
+
if (!sb || !nonEmpty2(url2) || !nonEmpty2(key)) {
|
|
35787
35885
|
agentLog("info", "knowledge: Supabase URL or key secret is not set, search_knowledge disabled");
|
|
35788
35886
|
return;
|
|
35789
35887
|
}
|
|
@@ -35803,7 +35901,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35803
35901
|
embedder: createLlmEmbedder({ provider: emb.provider, apiKey }, opts.providers ?? []),
|
|
35804
35902
|
model,
|
|
35805
35903
|
dims,
|
|
35806
|
-
cache:
|
|
35904
|
+
cache: nonEmpty2(redisUrl) ? {
|
|
35807
35905
|
redisUrl,
|
|
35808
35906
|
ttlSeconds: sb.cacheTtlSeconds,
|
|
35809
35907
|
namespace: kc.redis?.namespace
|
|
@@ -35822,99 +35920,29 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35822
35920
|
knowledgeTool = searchKnowledgeTool(base, { topK, log: logCode });
|
|
35823
35921
|
}
|
|
35824
35922
|
function buildRegistry(env) {
|
|
35825
|
-
const
|
|
35826
|
-
|
|
35827
|
-
|
|
35828
|
-
|
|
35829
|
-
|
|
35830
|
-
|
|
35831
|
-
|
|
35832
|
-
|
|
35833
|
-
|
|
35834
|
-
|
|
35835
|
-
|
|
35836
|
-
|
|
35837
|
-
|
|
35838
|
-
|
|
35839
|
-
|
|
35840
|
-
|
|
35841
|
-
|
|
35842
|
-
|
|
35843
|
-
|
|
35844
|
-
|
|
35845
|
-
|
|
35846
|
-
|
|
35847
|
-
|
|
35848
|
-
}
|
|
35849
|
-
});
|
|
35850
|
-
for (const tool of opts.tools ?? [])
|
|
35851
|
-
reg.addCustomTool(tool);
|
|
35852
|
-
if (knowledgeTool)
|
|
35853
|
-
reg.addCustomTool(knowledgeTool);
|
|
35854
|
-
const sources = [];
|
|
35855
|
-
for (const src of config2.toolSources ?? []) {
|
|
35856
|
-
if (src.kind === "service") {
|
|
35857
|
-
const base = env.AGENT_SERVICE_URL;
|
|
35858
|
-
if (!nonEmpty(base)) {
|
|
35859
|
-
agentLog("warn", "toolSources: service configured but this project has no service");
|
|
35860
|
-
continue;
|
|
35861
|
-
}
|
|
35862
|
-
const headers = {};
|
|
35863
|
-
const token = env.AGENT_SERVICE_TOKEN;
|
|
35864
|
-
if (nonEmpty(token)) {
|
|
35865
|
-
headers.Authorization = `Bearer ${token}`;
|
|
35866
|
-
} else {
|
|
35867
|
-
agentLog("warn", "toolSources: AGENT_SERVICE_TOKEN is not set");
|
|
35868
|
-
}
|
|
35869
|
-
const source = makeSource({
|
|
35870
|
-
name: "service",
|
|
35871
|
-
kind: "service",
|
|
35872
|
-
url: `${base}${src.path ?? D.servicePath}`,
|
|
35873
|
-
headers,
|
|
35874
|
-
allow: src.allow,
|
|
35875
|
-
deny: src.deny,
|
|
35876
|
-
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
35877
|
-
});
|
|
35878
|
-
serviceSource = source;
|
|
35879
|
-
sources.push(source);
|
|
35880
|
-
} else {
|
|
35881
|
-
const headers = {};
|
|
35882
|
-
let missing;
|
|
35883
|
-
const auth2 = src.auth ?? { type: "none" };
|
|
35884
|
-
if (auth2.type === "bearer") {
|
|
35885
|
-
const v = env[auth2.secret];
|
|
35886
|
-
if (nonEmpty(v))
|
|
35887
|
-
headers.Authorization = `Bearer ${v}`;
|
|
35888
|
-
else
|
|
35889
|
-
missing = auth2.secret;
|
|
35890
|
-
} else if (auth2.type === "headers") {
|
|
35891
|
-
for (const [header, envName2] of Object.entries(auth2.headers)) {
|
|
35892
|
-
const v = env[envName2];
|
|
35893
|
-
if (nonEmpty(v))
|
|
35894
|
-
headers[header] = v;
|
|
35895
|
-
else
|
|
35896
|
-
missing = envName2;
|
|
35897
|
-
}
|
|
35898
|
-
}
|
|
35899
|
-
if (missing) {
|
|
35900
|
-
agentLog("warn", `toolSources: ${src.name} skipped, environment variable ${missing} is not set`);
|
|
35901
|
-
continue;
|
|
35902
|
-
}
|
|
35903
|
-
sources.push(makeSource({
|
|
35904
|
-
name: src.name,
|
|
35905
|
-
url: src.url,
|
|
35906
|
-
headers,
|
|
35907
|
-
allow: src.allow,
|
|
35908
|
-
deny: src.deny,
|
|
35909
|
-
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
35910
|
-
}));
|
|
35911
|
-
}
|
|
35912
|
-
}
|
|
35913
|
-
for (const source of sources) {
|
|
35914
|
-
reg.addSource(source);
|
|
35915
|
-
source.start();
|
|
35916
|
-
}
|
|
35917
|
-
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;
|
|
35918
35946
|
}
|
|
35919
35947
|
async function runTools(s, t, ctx, calls) {
|
|
35920
35948
|
const signal = t.controller.signal;
|
|
@@ -36454,7 +36482,7 @@ ${t.inputText}` : t.inputText, {
|
|
|
36454
36482
|
}
|
|
36455
36483
|
const env = getEnv();
|
|
36456
36484
|
const apiKey = env[config2.apiKeySecret];
|
|
36457
|
-
if (!
|
|
36485
|
+
if (!nonEmpty2(apiKey)) {
|
|
36458
36486
|
throw configError(`environment variable ${config2.apiKeySecret} is not set`, "LLM_API_KEY_MISSING");
|
|
36459
36487
|
}
|
|
36460
36488
|
if (!provider) {
|
|
@@ -59926,6 +59954,12 @@ function createOpenAiCompatibleProvider(config2) {
|
|
|
59926
59954
|
stream_options: { include_usage: true },
|
|
59927
59955
|
...tools2.length > 0 ? { tools: tools2 } : {},
|
|
59928
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
|
+
} : {},
|
|
59929
59963
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
59930
59964
|
...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
|
|
59931
59965
|
};
|