@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.
Files changed (143) hide show
  1. package/README.md +26 -0
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +11 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/flow/classify.d.ts +12 -0
  7. package/dist/flow/classify.d.ts.map +1 -0
  8. package/dist/flow/classify.js +37 -0
  9. package/dist/flow/classify.js.map +1 -0
  10. package/dist/flow/cli-flow.d.ts +19 -0
  11. package/dist/flow/cli-flow.d.ts.map +1 -0
  12. package/dist/flow/cli-flow.js +566 -0
  13. package/dist/flow/cli-flow.js.map +1 -0
  14. package/dist/flow/core/compile.d.ts +131 -0
  15. package/dist/flow/core/compile.d.ts.map +1 -0
  16. package/dist/flow/core/compile.js +197 -0
  17. package/dist/flow/core/compile.js.map +1 -0
  18. package/dist/flow/core/conditions.d.ts +5 -0
  19. package/dist/flow/core/conditions.d.ts.map +1 -0
  20. package/dist/flow/core/conditions.js +70 -0
  21. package/dist/flow/core/conditions.js.map +1 -0
  22. package/dist/flow/core/effects.d.ts +105 -0
  23. package/dist/flow/core/effects.d.ts.map +1 -0
  24. package/dist/flow/core/effects.js +2 -0
  25. package/dist/flow/core/effects.js.map +1 -0
  26. package/dist/flow/core/generate-mock.d.ts +16 -0
  27. package/dist/flow/core/generate-mock.d.ts.map +1 -0
  28. package/dist/flow/core/generate-mock.js +206 -0
  29. package/dist/flow/core/generate-mock.js.map +1 -0
  30. package/dist/flow/core/host.d.ts +9 -0
  31. package/dist/flow/core/host.d.ts.map +1 -0
  32. package/dist/flow/core/host.js +99 -0
  33. package/dist/flow/core/host.js.map +1 -0
  34. package/dist/flow/core/index.d.ts +17 -0
  35. package/dist/flow/core/index.d.ts.map +1 -0
  36. package/dist/flow/core/index.js +17 -0
  37. package/dist/flow/core/index.js.map +1 -0
  38. package/dist/flow/core/interpreter.d.ts +69 -0
  39. package/dist/flow/core/interpreter.d.ts.map +1 -0
  40. package/dist/flow/core/interpreter.js +738 -0
  41. package/dist/flow/core/interpreter.js.map +1 -0
  42. package/dist/flow/core/json-pointer.d.ts +6 -0
  43. package/dist/flow/core/json-pointer.d.ts.map +1 -0
  44. package/dist/flow/core/json-pointer.js +28 -0
  45. package/dist/flow/core/json-pointer.js.map +1 -0
  46. package/dist/flow/core/migrate.d.ts +16 -0
  47. package/dist/flow/core/migrate.d.ts.map +1 -0
  48. package/dist/flow/core/migrate.js +29 -0
  49. package/dist/flow/core/migrate.js.map +1 -0
  50. package/dist/flow/core/mock-effects.d.ts +14 -0
  51. package/dist/flow/core/mock-effects.d.ts.map +1 -0
  52. package/dist/flow/core/mock-effects.js +90 -0
  53. package/dist/flow/core/mock-effects.js.map +1 -0
  54. package/dist/flow/core/mocks.d.ts +55 -0
  55. package/dist/flow/core/mocks.d.ts.map +1 -0
  56. package/dist/flow/core/mocks.js +73 -0
  57. package/dist/flow/core/mocks.js.map +1 -0
  58. package/dist/flow/core/route.d.ts +29 -0
  59. package/dist/flow/core/route.d.ts.map +1 -0
  60. package/dist/flow/core/route.js +61 -0
  61. package/dist/flow/core/route.js.map +1 -0
  62. package/dist/flow/core/schema.d.ts +19 -0
  63. package/dist/flow/core/schema.d.ts.map +1 -0
  64. package/dist/flow/core/schema.js +317 -0
  65. package/dist/flow/core/schema.js.map +1 -0
  66. package/dist/flow/core/template.d.ts +16 -0
  67. package/dist/flow/core/template.d.ts.map +1 -0
  68. package/dist/flow/core/template.js +65 -0
  69. package/dist/flow/core/template.js.map +1 -0
  70. package/dist/flow/core/trace.d.ts +26 -0
  71. package/dist/flow/core/trace.d.ts.map +1 -0
  72. package/dist/flow/core/trace.js +2 -0
  73. package/dist/flow/core/trace.js.map +1 -0
  74. package/dist/flow/core/types.d.ts +159 -0
  75. package/dist/flow/core/types.d.ts.map +1 -0
  76. package/dist/flow/core/types.js +2 -0
  77. package/dist/flow/core/types.js.map +1 -0
  78. package/dist/flow/core/validate.d.ts +3 -0
  79. package/dist/flow/core/validate.d.ts.map +1 -0
  80. package/dist/flow/core/validate.js +550 -0
  81. package/dist/flow/core/validate.js.map +1 -0
  82. package/dist/flow/create-flow-agent.d.ts +36 -0
  83. package/dist/flow/create-flow-agent.d.ts.map +1 -0
  84. package/dist/flow/create-flow-agent.js +175 -0
  85. package/dist/flow/create-flow-agent.js.map +1 -0
  86. package/dist/flow/effects-node.d.ts +21 -0
  87. package/dist/flow/effects-node.d.ts.map +1 -0
  88. package/dist/flow/effects-node.js +189 -0
  89. package/dist/flow/effects-node.js.map +1 -0
  90. package/dist/flow/index.d.ts +12 -0
  91. package/dist/flow/index.d.ts.map +1 -0
  92. package/dist/flow/index.js +7 -0
  93. package/dist/flow/index.js.map +1 -0
  94. package/dist/flow/llm-node.d.ts +24 -0
  95. package/dist/flow/llm-node.d.ts.map +1 -0
  96. package/dist/flow/llm-node.js +251 -0
  97. package/dist/flow/llm-node.js.map +1 -0
  98. package/dist/flow/record.d.ts +22 -0
  99. package/dist/flow/record.d.ts.map +1 -0
  100. package/dist/flow/record.js +126 -0
  101. package/dist/flow/record.js.map +1 -0
  102. package/dist/llm/agent/build-tool-registry.d.ts +26 -0
  103. package/dist/llm/agent/build-tool-registry.d.ts.map +1 -0
  104. package/dist/llm/agent/build-tool-registry.js +106 -0
  105. package/dist/llm/agent/build-tool-registry.js.map +1 -0
  106. package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
  107. package/dist/llm/agent/create-llm-agent.js +27 -101
  108. package/dist/llm/agent/create-llm-agent.js.map +1 -1
  109. package/dist/llm/anthropic-provider.d.ts.map +1 -1
  110. package/dist/llm/anthropic-provider.js +10 -0
  111. package/dist/llm/anthropic-provider.js.map +1 -1
  112. package/dist/llm/catalog.d.ts +4 -0
  113. package/dist/llm/catalog.d.ts.map +1 -1
  114. package/dist/llm/catalog.js +7 -0
  115. package/dist/llm/catalog.js.map +1 -1
  116. package/dist/llm/gemini-provider.d.ts.map +1 -1
  117. package/dist/llm/gemini-provider.js +12 -0
  118. package/dist/llm/gemini-provider.js.map +1 -1
  119. package/dist/llm/index.d.ts +2 -0
  120. package/dist/llm/index.d.ts.map +1 -1
  121. package/dist/llm/index.js +1 -0
  122. package/dist/llm/index.js.map +1 -1
  123. package/dist/llm/openai-provider.d.ts.map +1 -1
  124. package/dist/llm/openai-provider.js +10 -0
  125. package/dist/llm/openai-provider.js.map +1 -1
  126. package/dist/llm/types.d.ts +7 -2
  127. package/dist/llm/types.d.ts.map +1 -1
  128. package/dist/llm/types.js.map +1 -1
  129. package/dist/templates/flow-agent/agent.js +49085 -0
  130. package/dist/templates/llm-agent/agent.js +133 -99
  131. package/dist/templates/llm-docs-rag/agent.js +133 -99
  132. package/dist/templates/llm-mcp-service/agent.js +133 -99
  133. package/dist/templates/registry.d.ts.map +1 -1
  134. package/dist/templates/registry.js +23 -0
  135. package/dist/templates/registry.js.map +1 -1
  136. package/eject/llm/loop.ts +28 -101
  137. package/package.json +19 -2
  138. package/schema/voicethere.flow.schema.json +681 -0
  139. package/templates/flow-agent/README.md +38 -0
  140. package/templates/flow-agent/agent.ts +14 -0
  141. package/templates/flow-agent/tools.ts +5 -0
  142. package/templates/flow-agent/voicethere.flow.json +80 -0
  143. package/templates/flow-agent/voicethere.flow.mocks.json +17 -0
@@ -0,0 +1,38 @@
1
+ # flow-agent
2
+
3
+ A scripted voice and chat conversation built from nodes: speak, listen, route by example sentences, call an API or an MCP tool, ask an LLM, branch on variables, end. Source: `templates/flow-agent/agent.ts`.
4
+
5
+ ## Files
6
+
7
+ - `agent.ts` wires the flow to the agent runtime. You rarely need to change it.
8
+ - `voicethere.flow.json` is the conversation. The dashboard Flow tab edits this file; you can edit it by hand too.
9
+ - `voicethere.flow.mocks.json` holds mock answers for `route`, `llm`, `http` and `mcp` nodes. It is for local runs only, and the deployed agent never reads it.
10
+ - `tools.ts` lists your own tools for `llm` nodes. It is empty by default.
11
+
12
+ ## Set the API key
13
+
14
+ The flow starts on OpenRouter with the model `anthropic/claude-haiku-5.5`, which supports the forced tool call the route classifier makes. Create a key at openrouter.ai, add it as a project secret named `AGENT_OPENROUTER_API_KEY`, then deploy. The key is read by name from `apiKeySecret` in `voicethere.flow.json`; it is never stored in the file. Only project secrets whose names start with `AGENT_` reach the agent.
15
+
16
+ To use another provider, change `provider`, `model` and `apiKeySecret` in the `models` block and import that provider's module in `agent.ts` (the comment there shows how).
17
+
18
+ ## Test it locally
19
+
20
+ Check the flow file:
21
+
22
+ ```bash
23
+ npx @voicethere/agent flow validate
24
+ ```
25
+
26
+ Talk to it in the terminal with mock answers, so no key and no network are needed:
27
+
28
+ ```bash
29
+ npx @voicethere/agent flow run --mock
30
+ ```
31
+
32
+ Run it with real calls, reading keys from an env file you name:
33
+
34
+ ```bash
35
+ npx @voicethere/agent flow run --env my-keys.env
36
+ ```
37
+
38
+ Add `--record` to save the real HTTP, MCP and LLM answers as mock cases, `--trace out.json` to write the steps, and `--step` to pause before each node. `npx @voicethere/agent flow mock generate` fills the mocks file with generated data. Press Ctrl-C to stop a run: the recording and the trace collected so far are written first, then it exits with code 130. In `--step` mode, Ctrl-C exits without saving the trace or recording.
@@ -0,0 +1,14 @@
1
+ import { defineAgent } from "@voicethere/agent";
2
+ import { createFlowAgent } from "@voicethere/agent/flow";
3
+ import { openai } from "@voicethere/agent/llm/openai";
4
+ import flow from "./voicethere.flow.json";
5
+ import { tools } from "./tools";
6
+
7
+ // The template runs on OpenRouter, which is served by the openai module, so
8
+ // switching between openai and openrouter needs no import change. Only the
9
+ // provider you import here is bundled. To use another provider, change
10
+ // "provider" in the "models" block of voicethere.flow.json and import its
11
+ // module instead:
12
+ // anthropic → import { anthropic } from "@voicethere/agent/llm/anthropic";
13
+ // gemini → import { gemini } from "@voicethere/agent/llm/gemini";
14
+ defineAgent(createFlowAgent({ flow, tools, providers: [openai] }));
@@ -0,0 +1,5 @@
1
+ import type { CustomTool } from "@voicethere/agent/llm";
2
+
3
+ // Custom tools that `llm` nodes can offer (list their names in the node's
4
+ // "tools" field). Build each one with defineTool from "@voicethere/agent/llm".
5
+ export const tools: CustomTool[] = [];
@@ -0,0 +1,80 @@
1
+ {
2
+ "version": 1,
3
+ "start": "greet",
4
+ "models": {
5
+ "default": {
6
+ "provider": "openrouter",
7
+ "model": "anthropic/claude-haiku-5.5",
8
+ "apiKeySecret": "AGENT_OPENROUTER_API_KEY"
9
+ },
10
+ "classifier": { "use": "default" }
11
+ },
12
+ "nodes": [
13
+ {
14
+ "id": "greet",
15
+ "type": "speak",
16
+ "text": "Hi! Is this about billing or support?",
17
+ "interruptible": true,
18
+ "next": "ask"
19
+ },
20
+ {
21
+ "id": "ask",
22
+ "type": "listen",
23
+ "timeoutMs": 8000,
24
+ "next": "topic",
25
+ "onNoInput": "reprompt"
26
+ },
27
+ {
28
+ "id": "reprompt",
29
+ "type": "speak",
30
+ "text": "Sorry, I did not catch that. Is it billing or support?",
31
+ "next": "ask"
32
+ },
33
+ {
34
+ "id": "topic",
35
+ "type": "route",
36
+ "input": "{{last.transcript}}",
37
+ "paths": [
38
+ {
39
+ "id": "billing",
40
+ "examples": [
41
+ "I have a question about my invoice",
42
+ "why was I charged twice",
43
+ "billing"
44
+ ],
45
+ "next": "billingReply"
46
+ },
47
+ {
48
+ "id": "support",
49
+ "examples": [
50
+ "my app is not working",
51
+ "I need help with setup",
52
+ "technical problem"
53
+ ],
54
+ "next": "supportHelp"
55
+ }
56
+ ],
57
+ "onNone": "reprompt",
58
+ "onError": "reprompt",
59
+ "timeoutMs": 3000
60
+ },
61
+ {
62
+ "id": "billingReply",
63
+ "type": "speak",
64
+ "text": "Thanks. A billing specialist will follow up on your invoice by email.",
65
+ "next": "end"
66
+ },
67
+ {
68
+ "id": "supportHelp",
69
+ "type": "llm",
70
+ "instructions": "Help with the caller's support question in two short spoken sentences.",
71
+ "send": "conversation",
72
+ "historyTurns": 6,
73
+ "speak": true,
74
+ "saveAs": "answer",
75
+ "next": "end",
76
+ "onError": "reprompt"
77
+ },
78
+ { "id": "end", "type": "end", "reason": "done" }
79
+ ]
80
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 1,
3
+ "nodes": {
4
+ "topic": [
5
+ { "name": "billing", "route": { "path": "billing" } },
6
+ { "name": "support", "route": { "path": "support" } }
7
+ ],
8
+ "supportHelp": [
9
+ {
10
+ "name": "answer",
11
+ "llm": {
12
+ "text": "Try restarting the app. If that does not help, I will send you the setup guide."
13
+ }
14
+ }
15
+ ]
16
+ }
17
+ }