@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.
Files changed (160) hide show
  1. package/README.md +28 -0
  2. package/dist/agent.js +11 -2
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +11 -0
  6. package/dist/cli.js.map +1 -1
  7. package/dist/flow/classify.d.ts +12 -0
  8. package/dist/flow/classify.d.ts.map +1 -0
  9. package/dist/flow/classify.js +37 -0
  10. package/dist/flow/classify.js.map +1 -0
  11. package/dist/flow/cli-flow.d.ts +19 -0
  12. package/dist/flow/cli-flow.d.ts.map +1 -0
  13. package/dist/flow/cli-flow.js +566 -0
  14. package/dist/flow/cli-flow.js.map +1 -0
  15. package/dist/flow/core/compile.d.ts +131 -0
  16. package/dist/flow/core/compile.d.ts.map +1 -0
  17. package/dist/flow/core/compile.js +197 -0
  18. package/dist/flow/core/compile.js.map +1 -0
  19. package/dist/flow/core/conditions.d.ts +5 -0
  20. package/dist/flow/core/conditions.d.ts.map +1 -0
  21. package/dist/flow/core/conditions.js +70 -0
  22. package/dist/flow/core/conditions.js.map +1 -0
  23. package/dist/flow/core/effects.d.ts +105 -0
  24. package/dist/flow/core/effects.d.ts.map +1 -0
  25. package/dist/flow/core/effects.js +2 -0
  26. package/dist/flow/core/effects.js.map +1 -0
  27. package/dist/flow/core/generate-mock.d.ts +16 -0
  28. package/dist/flow/core/generate-mock.d.ts.map +1 -0
  29. package/dist/flow/core/generate-mock.js +206 -0
  30. package/dist/flow/core/generate-mock.js.map +1 -0
  31. package/dist/flow/core/host.d.ts +9 -0
  32. package/dist/flow/core/host.d.ts.map +1 -0
  33. package/dist/flow/core/host.js +99 -0
  34. package/dist/flow/core/host.js.map +1 -0
  35. package/dist/flow/core/index.d.ts +17 -0
  36. package/dist/flow/core/index.d.ts.map +1 -0
  37. package/dist/flow/core/index.js +17 -0
  38. package/dist/flow/core/index.js.map +1 -0
  39. package/dist/flow/core/interpreter.d.ts +69 -0
  40. package/dist/flow/core/interpreter.d.ts.map +1 -0
  41. package/dist/flow/core/interpreter.js +738 -0
  42. package/dist/flow/core/interpreter.js.map +1 -0
  43. package/dist/flow/core/json-pointer.d.ts +6 -0
  44. package/dist/flow/core/json-pointer.d.ts.map +1 -0
  45. package/dist/flow/core/json-pointer.js +28 -0
  46. package/dist/flow/core/json-pointer.js.map +1 -0
  47. package/dist/flow/core/migrate.d.ts +16 -0
  48. package/dist/flow/core/migrate.d.ts.map +1 -0
  49. package/dist/flow/core/migrate.js +29 -0
  50. package/dist/flow/core/migrate.js.map +1 -0
  51. package/dist/flow/core/mock-effects.d.ts +14 -0
  52. package/dist/flow/core/mock-effects.d.ts.map +1 -0
  53. package/dist/flow/core/mock-effects.js +90 -0
  54. package/dist/flow/core/mock-effects.js.map +1 -0
  55. package/dist/flow/core/mocks.d.ts +55 -0
  56. package/dist/flow/core/mocks.d.ts.map +1 -0
  57. package/dist/flow/core/mocks.js +73 -0
  58. package/dist/flow/core/mocks.js.map +1 -0
  59. package/dist/flow/core/route.d.ts +29 -0
  60. package/dist/flow/core/route.d.ts.map +1 -0
  61. package/dist/flow/core/route.js +61 -0
  62. package/dist/flow/core/route.js.map +1 -0
  63. package/dist/flow/core/schema.d.ts +19 -0
  64. package/dist/flow/core/schema.d.ts.map +1 -0
  65. package/dist/flow/core/schema.js +317 -0
  66. package/dist/flow/core/schema.js.map +1 -0
  67. package/dist/flow/core/template.d.ts +16 -0
  68. package/dist/flow/core/template.d.ts.map +1 -0
  69. package/dist/flow/core/template.js +65 -0
  70. package/dist/flow/core/template.js.map +1 -0
  71. package/dist/flow/core/trace.d.ts +26 -0
  72. package/dist/flow/core/trace.d.ts.map +1 -0
  73. package/dist/flow/core/trace.js +2 -0
  74. package/dist/flow/core/trace.js.map +1 -0
  75. package/dist/flow/core/types.d.ts +159 -0
  76. package/dist/flow/core/types.d.ts.map +1 -0
  77. package/dist/flow/core/types.js +2 -0
  78. package/dist/flow/core/types.js.map +1 -0
  79. package/dist/flow/core/validate.d.ts +3 -0
  80. package/dist/flow/core/validate.d.ts.map +1 -0
  81. package/dist/flow/core/validate.js +550 -0
  82. package/dist/flow/core/validate.js.map +1 -0
  83. package/dist/flow/create-flow-agent.d.ts +36 -0
  84. package/dist/flow/create-flow-agent.d.ts.map +1 -0
  85. package/dist/flow/create-flow-agent.js +175 -0
  86. package/dist/flow/create-flow-agent.js.map +1 -0
  87. package/dist/flow/effects-node.d.ts +21 -0
  88. package/dist/flow/effects-node.d.ts.map +1 -0
  89. package/dist/flow/effects-node.js +189 -0
  90. package/dist/flow/effects-node.js.map +1 -0
  91. package/dist/flow/index.d.ts +12 -0
  92. package/dist/flow/index.d.ts.map +1 -0
  93. package/dist/flow/index.js +7 -0
  94. package/dist/flow/index.js.map +1 -0
  95. package/dist/flow/llm-node.d.ts +24 -0
  96. package/dist/flow/llm-node.d.ts.map +1 -0
  97. package/dist/flow/llm-node.js +251 -0
  98. package/dist/flow/llm-node.js.map +1 -0
  99. package/dist/flow/record.d.ts +22 -0
  100. package/dist/flow/record.d.ts.map +1 -0
  101. package/dist/flow/record.js +126 -0
  102. package/dist/flow/record.js.map +1 -0
  103. package/dist/llm/agent/build-tool-registry.d.ts +26 -0
  104. package/dist/llm/agent/build-tool-registry.d.ts.map +1 -0
  105. package/dist/llm/agent/build-tool-registry.js +106 -0
  106. package/dist/llm/agent/build-tool-registry.js.map +1 -0
  107. package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
  108. package/dist/llm/agent/create-llm-agent.js +45 -106
  109. package/dist/llm/agent/create-llm-agent.js.map +1 -1
  110. package/dist/llm/anthropic-provider.d.ts.map +1 -1
  111. package/dist/llm/anthropic-provider.js +10 -0
  112. package/dist/llm/anthropic-provider.js.map +1 -1
  113. package/dist/llm/catalog.d.ts +4 -0
  114. package/dist/llm/catalog.d.ts.map +1 -1
  115. package/dist/llm/catalog.js +7 -0
  116. package/dist/llm/catalog.js.map +1 -1
  117. package/dist/llm/gemini-provider.d.ts.map +1 -1
  118. package/dist/llm/gemini-provider.js +12 -0
  119. package/dist/llm/gemini-provider.js.map +1 -1
  120. package/dist/llm/index.d.ts +2 -0
  121. package/dist/llm/index.d.ts.map +1 -1
  122. package/dist/llm/index.js +1 -0
  123. package/dist/llm/index.js.map +1 -1
  124. package/dist/llm/openai-provider.d.ts.map +1 -1
  125. package/dist/llm/openai-provider.js +10 -0
  126. package/dist/llm/openai-provider.js.map +1 -1
  127. package/dist/llm/types.d.ts +7 -2
  128. package/dist/llm/types.d.ts.map +1 -1
  129. package/dist/llm/types.js.map +1 -1
  130. package/dist/protocol.d.ts +4 -0
  131. package/dist/protocol.d.ts.map +1 -1
  132. package/dist/protocol.js.map +1 -1
  133. package/dist/runtime.d.ts +4 -0
  134. package/dist/runtime.d.ts.map +1 -1
  135. package/dist/runtime.js +10 -0
  136. package/dist/runtime.js.map +1 -1
  137. package/dist/templates/echo/agent.js +12 -2
  138. package/dist/templates/flow-agent/agent.js +49085 -0
  139. package/dist/templates/language-switch/agent.js +12 -2
  140. package/dist/templates/llm-agent/agent.js +156 -106
  141. package/dist/templates/llm-docs-rag/agent.js +156 -106
  142. package/dist/templates/llm-mcp-service/agent.js +156 -106
  143. package/dist/templates/positional-tts/agent.js +12 -2
  144. package/dist/templates/recording-consent/agent.js +12 -2
  145. package/dist/templates/registry.d.ts.map +1 -1
  146. package/dist/templates/registry.js +23 -0
  147. package/dist/templates/registry.js.map +1 -1
  148. package/dist/templates/spatial-showcase/agent.js +12 -2
  149. package/dist/templates/voice-showcase/agent.js +12 -2
  150. package/dist/templates/voice-starter/agent.js +12 -2
  151. package/dist/templates/webhooks/agent.js +12 -2
  152. package/eject/llm/loop.ts +51 -104
  153. package/package.json +19 -2
  154. package/schema/voicethere.flow.schema.json +681 -0
  155. package/templates/flow-agent/README.md +38 -0
  156. package/templates/flow-agent/agent.ts +14 -0
  157. package/templates/flow-agent/tools.ts +5 -0
  158. package/templates/flow-agent/voicethere.flow.json +80 -0
  159. package/templates/flow-agent/voicethere.flow.mocks.json +17 -0
  160. package/templates/llm-agent/README.md +4 -2
@@ -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 nonEmpty(v) {
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 speakAnnouncement(s, turnId, text, interruptible) {
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, { turnId });
35700
+ return speak(s.sessionId, text, opts2);
35589
35701
  }
35590
- const h = announce(s.sessionId, text, { turnId });
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 (!nonEmpty(apiKey)) {
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 (!nonEmpty(redisUrl)) {
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 || !nonEmpty(url2) || !nonEmpty(key)) {
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: nonEmpty(redisUrl) ? {
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 reg = new ToolRegistry({
35811
- log: (level, message, fields) => agentLog(level, message, fields ?? {}),
35812
- toolCallLog: {
35813
- mode: config2.toolCallLogs ?? D.toolCallLogs,
35814
- secretValues: secretValuesFromEnv(env, [
35815
- config2.apiKeySecret,
35816
- "AGENT_SERVICE_TOKEN",
35817
- ...config2.knowledge?.embeddings ? [config2.knowledge.embeddings.apiKeySecret] : [],
35818
- ...config2.knowledge?.supabase ? [
35819
- config2.knowledge.supabase.keySecret,
35820
- config2.knowledge.supabase.urlSecret
35821
- ] : [],
35822
- ...(config2.toolSources ?? []).flatMap((src) => {
35823
- if (src.kind !== "mcp" || !src.auth)
35824
- return [];
35825
- if (src.auth.type === "bearer")
35826
- return [src.auth.secret];
35827
- if (src.auth.type === "headers")
35828
- return Object.values(src.auth.headers);
35829
- return [];
35830
- })
35831
- ]),
35832
- emit: (fields, sid) => agentLog("info", "llm tool call", { ...fields }, sid)
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 (!nonEmpty(apiKey)) {
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
  };