@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
package/eject/llm/loop.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copied from @voicethere/agent 0.24.0. Package updates no longer change this file.
1
+ // Copied from @voicethere/agent 0.26.0. Package updates no longer change this file.
2
2
  import { randomUUID } from "node:crypto";
3
3
  import {
4
4
  type AgentHandlers,
@@ -17,6 +17,7 @@ import {
17
17
  } from "@voicethere/agent";
18
18
  import {
19
19
  type AgentContent,
20
+ buildToolRegistry,
20
21
  cleanLinkSentence,
21
22
  ConversationHistory,
22
23
  countLinkMarks,
@@ -50,7 +51,7 @@ import {
50
51
  SentenceSplitter,
51
52
  stripThinking,
52
53
  ThinkingStripper,
53
- ToolRegistry,
54
+ type ToolRegistry,
54
55
  type TurnContext,
55
56
  type TurnSummary,
56
57
  validateLlmAgentConfig,
@@ -448,16 +449,33 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
448
449
  }
449
450
  }
450
451
 
452
+ /**
453
+ * The one place where a filler reaches the client as text. Fillers are not
454
+ * reply text: never `assistant_delta`, never in `chat_reply`, never in history.
455
+ */
456
+ function sendFillerMessage(
457
+ s: SessionState,
458
+ turnId: string,
459
+ text: string,
460
+ ): void {
461
+ sendToClient(s.sessionId, { type: "assistant_filler", turnId, text });
462
+ }
463
+
464
+ /** Speak options for a filler; replies carry no `kind`. */
451
465
  function speakAnnouncement(
452
466
  s: SessionState,
453
467
  turnId: string,
454
468
  text: string,
455
469
  interruptible: boolean,
470
+ fillerKind?: FillerKind,
456
471
  ): SpeakHandle {
472
+ const opts = fillerKind
473
+ ? { turnId, kind: "filler" as const, fillerKind }
474
+ : { turnId };
457
475
  if (interruptible) {
458
- return speak(s.sessionId, text, { turnId });
476
+ return speak(s.sessionId, text, opts);
459
477
  }
460
- const h = announce(s.sessionId, text, { turnId });
478
+ const h = announce(s.sessionId, text, opts);
461
479
  trackAnnouncement(s, h.done);
462
480
  return h;
463
481
  }
@@ -540,7 +558,8 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
540
558
  if (kind === "thinking") t.thinkingSpoken = true;
541
559
  if (kind === "toolCall") t.toolCallSpoken = true;
542
560
  if (kind === "toolWait") t.toolWaitSpoken += 1;
543
- speakAnnouncement(s, t.turnId, text, fillersInterruptible);
561
+ speakAnnouncement(s, t.turnId, text, fillersInterruptible, kind);
562
+ sendFillerMessage(s, t.turnId, text);
544
563
  return undefined;
545
564
  }
546
565
 
@@ -742,106 +761,32 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
742
761
  }
743
762
 
744
763
  function buildRegistry(env: Record<string, string | undefined>): void {
745
- const reg = new ToolRegistry({
746
- log: (level, message, fields) => agentLog(level, message, fields ?? {}),
747
- toolCallLog: {
748
- mode: config.toolCallLogs ?? D.toolCallLogs,
749
- secretValues: secretValuesFromEnv(env, [
750
- config.apiKeySecret,
751
- "AGENT_SERVICE_TOKEN",
752
- ...(config.knowledge?.embeddings
753
- ? [config.knowledge.embeddings.apiKeySecret]
754
- : []),
755
- ...(config.knowledge?.supabase
756
- ? [
757
- config.knowledge.supabase.keySecret,
758
- config.knowledge.supabase.urlSecret,
759
- ]
760
- : []),
761
- ...(config.toolSources ?? []).flatMap((src) => {
762
- if (src.kind !== "mcp" || !src.auth) return [];
763
- if (src.auth.type === "bearer") return [src.auth.secret];
764
- if (src.auth.type === "headers")
765
- return Object.values(src.auth.headers);
766
- return [];
767
- }),
768
- ]),
769
- emit: (fields, sid) =>
770
- agentLog("info", "llm tool call", { ...fields }, sid),
771
- },
764
+ const built = buildToolRegistry({
765
+ env,
766
+ toolSources: config.toolSources ?? [],
767
+ customTools: [
768
+ ...(opts.tools ?? []),
769
+ ...(knowledgeTool ? [knowledgeTool] : []),
770
+ ],
771
+ secretNames: [
772
+ config.apiKeySecret,
773
+ "AGENT_SERVICE_TOKEN",
774
+ ...(config.knowledge?.embeddings
775
+ ? [config.knowledge.embeddings.apiKeySecret]
776
+ : []),
777
+ ...(config.knowledge?.supabase
778
+ ? [
779
+ config.knowledge.supabase.keySecret,
780
+ config.knowledge.supabase.urlSecret,
781
+ ]
782
+ : []),
783
+ ],
784
+ toolCallLogs: config.toolCallLogs ?? D.toolCallLogs,
785
+ servicePath: D.servicePath,
786
+ makeSource,
772
787
  });
773
- for (const tool of opts.tools ?? []) reg.addCustomTool(tool);
774
- if (knowledgeTool) reg.addCustomTool(knowledgeTool);
775
- const sources: McpToolSource[] = [];
776
- for (const src of config.toolSources ?? []) {
777
- if (src.kind === "service") {
778
- const base = env.AGENT_SERVICE_URL;
779
- if (!nonEmpty(base)) {
780
- agentLog(
781
- "warn",
782
- "toolSources: service configured but this project has no service",
783
- );
784
- continue;
785
- }
786
- const headers: Record<string, string> = {};
787
- const token = env.AGENT_SERVICE_TOKEN;
788
- if (nonEmpty(token)) {
789
- headers.Authorization = `Bearer ${token}`;
790
- } else {
791
- agentLog("warn", "toolSources: AGENT_SERVICE_TOKEN is not set");
792
- }
793
- const source = makeSource({
794
- name: "service",
795
- kind: "service",
796
- url: `${base}${src.path ?? D.servicePath}`,
797
- headers,
798
- allow: src.allow,
799
- deny: src.deny,
800
- log: (level, message, fields) =>
801
- agentLog(level, message, fields ?? {}),
802
- });
803
- serviceSource = source;
804
- sources.push(source);
805
- } else {
806
- const headers: Record<string, string> = {};
807
- let missing: string | undefined;
808
- const auth = src.auth ?? { type: "none" as const };
809
- if (auth.type === "bearer") {
810
- const v = env[auth.secret];
811
- if (nonEmpty(v)) headers.Authorization = `Bearer ${v}`;
812
- else missing = auth.secret;
813
- } else if (auth.type === "headers") {
814
- for (const [header, envName] of Object.entries(auth.headers)) {
815
- const v = env[envName];
816
- if (nonEmpty(v)) headers[header] = v;
817
- else missing = envName;
818
- }
819
- }
820
- if (missing) {
821
- agentLog(
822
- "warn",
823
- `toolSources: ${src.name} skipped, environment variable ${missing} is not set`,
824
- );
825
- continue;
826
- }
827
- sources.push(
828
- makeSource({
829
- name: src.name,
830
- url: src.url,
831
- headers,
832
- allow: src.allow,
833
- deny: src.deny,
834
- log: (level, message, fields) =>
835
- agentLog(level, message, fields ?? {}),
836
- }),
837
- );
838
- }
839
- }
840
- for (const source of sources) {
841
- reg.addSource(source);
842
- source.start();
843
- }
844
- registry = reg;
788
+ if (built.serviceSource) serviceSource = built.serviceSource;
789
+ registry = built.registry;
845
790
  }
846
791
 
847
792
  async function runTools(
@@ -1212,7 +1157,9 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
1212
1157
  t.turnId,
1213
1158
  fillerLegacy.text,
1214
1159
  fillerLegacy.interruptible ?? D.fillerInterruptible,
1160
+ "toolWait",
1215
1161
  );
1162
+ sendFillerMessage(s, t.turnId, fillerLegacy.text);
1216
1163
  }, fillerLegacy.afterMs ?? D.fillerAfterMs);
1217
1164
  }
1218
1165
  let results: LlmToolResult[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicethere/agent",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
5
5
  "type": "module",
6
6
  "exports": {
@@ -46,11 +46,28 @@
46
46
  "require": "./dist/llm/index.js",
47
47
  "default": "./dist/llm/index.js"
48
48
  },
49
+ "./flow": {
50
+ "types": "./dist/flow/index.d.ts",
51
+ "import": "./dist/flow/index.js",
52
+ "require": "./dist/flow/index.js",
53
+ "default": "./dist/flow/index.js"
54
+ },
55
+ "./flow/core": {
56
+ "types": "./dist/flow/core/index.d.ts",
57
+ "import": "./dist/flow/core/index.js",
58
+ "require": "./dist/flow/core/index.js",
59
+ "default": "./dist/flow/core/index.js"
60
+ },
49
61
  "./llm/schema.json": {
50
62
  "import": "./schema/voicethere.llm.schema.json",
51
63
  "require": "./schema/voicethere.llm.schema.json",
52
64
  "default": "./schema/voicethere.llm.schema.json"
53
65
  },
66
+ "./flow/schema.json": {
67
+ "import": "./schema/voicethere.flow.schema.json",
68
+ "require": "./schema/voicethere.flow.schema.json",
69
+ "default": "./schema/voicethere.flow.schema.json"
70
+ },
54
71
  "./verify": {
55
72
  "types": "./dist/verify/run-verify.d.ts",
56
73
  "import": "./dist/verify/run-verify.js",
@@ -93,7 +110,7 @@
93
110
  ],
94
111
  "scripts": {
95
112
  "build:lib": "tsc -p tsconfig.json && mkdir -p dist/sandbox && cp src/sandbox/loader-entry.js src/sandbox/warning-forwarder.cjs dist/sandbox/",
96
- "build:schema": "node scripts/build-llm-schema.mjs",
113
+ "build:schema": "node scripts/build-llm-schema.mjs && node scripts/build-flow-schema.mjs",
97
114
  "build:eject": "node scripts/build-llm-eject.mjs",
98
115
  "build:templates": "node dist/templates/build-seed-bundles-cli.js",
99
116
  "build:example": "node dist/cli.js build --entry examples/agent.ts --outfile dist/agent.js",