@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
|
@@ -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,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
|
+
}
|