@voicethere/agent 0.11.0 → 0.12.1
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/dist/build-bundle.d.ts.map +1 -1
- package/dist/build-bundle.js +1 -0
- package/dist/build-bundle.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/agent/config.d.ts +376 -0
- package/dist/llm/agent/config.d.ts.map +1 -0
- package/dist/llm/agent/config.js +679 -0
- package/dist/llm/agent/config.js.map +1 -0
- package/dist/llm/agent/create-llm-agent.d.ts +22 -0
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -0
- package/dist/llm/agent/create-llm-agent.js +720 -0
- package/dist/llm/agent/create-llm-agent.js.map +1 -0
- package/dist/llm/agent/define-tool.d.ts +8 -0
- package/dist/llm/agent/define-tool.d.ts.map +1 -0
- package/dist/llm/agent/define-tool.js +9 -0
- package/dist/llm/agent/define-tool.js.map +1 -0
- package/dist/llm/agent/history.d.ts +35 -0
- package/dist/llm/agent/history.d.ts.map +1 -0
- package/dist/llm/agent/history.js +79 -0
- package/dist/llm/agent/history.js.map +1 -0
- package/dist/llm/agent/hooks.d.ts +50 -0
- package/dist/llm/agent/hooks.d.ts.map +1 -0
- package/dist/llm/agent/hooks.js +2 -0
- package/dist/llm/agent/hooks.js.map +1 -0
- package/dist/llm/agent/sentence-splitter.d.ts +10 -0
- package/dist/llm/agent/sentence-splitter.d.ts.map +1 -0
- package/dist/llm/agent/sentence-splitter.js +92 -0
- package/dist/llm/agent/sentence-splitter.js.map +1 -0
- package/dist/llm/anthropic-provider.d.ts +7 -0
- package/dist/llm/anthropic-provider.d.ts.map +1 -0
- package/dist/llm/anthropic-provider.js +115 -0
- package/dist/llm/anthropic-provider.js.map +1 -0
- package/dist/llm/bounded-provider.d.ts +12 -0
- package/dist/llm/bounded-provider.d.ts.map +1 -0
- package/dist/llm/bounded-provider.js +132 -0
- package/dist/llm/bounded-provider.js.map +1 -0
- package/dist/llm/catalog.d.ts +9 -0
- package/dist/llm/catalog.d.ts.map +1 -0
- package/dist/llm/catalog.js +35 -0
- package/dist/llm/catalog.js.map +1 -0
- package/dist/llm/gemini-provider.d.ts +7 -0
- package/dist/llm/gemini-provider.d.ts.map +1 -0
- package/dist/llm/gemini-provider.js +120 -0
- package/dist/llm/gemini-provider.js.map +1 -0
- package/dist/llm/index.d.ts +18 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +11 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/mcp/index.d.ts +5 -0
- package/dist/llm/mcp/index.d.ts.map +1 -0
- package/dist/llm/mcp/index.js +3 -0
- package/dist/llm/mcp/index.js.map +1 -0
- package/dist/llm/mcp/mcp-tool-source.d.ts +65 -0
- package/dist/llm/mcp/mcp-tool-source.d.ts.map +1 -0
- package/dist/llm/mcp/mcp-tool-source.js +328 -0
- package/dist/llm/mcp/mcp-tool-source.js.map +1 -0
- package/dist/llm/mcp/tool-registry.d.ts +44 -0
- package/dist/llm/mcp/tool-registry.d.ts.map +1 -0
- package/dist/llm/mcp/tool-registry.js +147 -0
- package/dist/llm/mcp/tool-registry.js.map +1 -0
- package/dist/llm/openai-provider.d.ts +8 -0
- package/dist/llm/openai-provider.d.ts.map +1 -0
- package/dist/llm/openai-provider.js +146 -0
- package/dist/llm/openai-provider.js.map +1 -0
- package/dist/llm/providers.d.ts +10 -0
- package/dist/llm/providers.d.ts.map +1 -0
- package/dist/llm/providers.js +32 -0
- package/dist/llm/providers.js.map +1 -0
- package/dist/llm/types.d.ts +70 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +11 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +24 -0
- package/dist/runtime.js.map +1 -1
- package/dist/templates/llm-agent/agent.js +121379 -0
- package/dist/templates/registry.d.ts +1 -1
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +24 -0
- package/dist/templates/registry.js.map +1 -1
- package/eject/llm/loop.ts +913 -0
- package/package.json +48 -4
- package/schema/voicethere.llm.schema.json +325 -0
- package/templates/llm-agent/README.md +24 -0
- package/templates/llm-agent/agent.ts +8 -0
- package/templates/llm-agent/hooks.ts +21 -0
- package/templates/llm-agent/md.d.ts +4 -0
- package/templates/llm-agent/prompt.md +11 -0
- package/templates/llm-agent/tools.ts +51 -0
- package/templates/llm-agent/voicethere.llm.json +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicethere/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,6 +22,17 @@
|
|
|
22
22
|
"require": "./dist/host/index.js",
|
|
23
23
|
"default": "./dist/host/index.js"
|
|
24
24
|
},
|
|
25
|
+
"./llm": {
|
|
26
|
+
"types": "./dist/llm/index.d.ts",
|
|
27
|
+
"import": "./dist/llm/index.js",
|
|
28
|
+
"require": "./dist/llm/index.js",
|
|
29
|
+
"default": "./dist/llm/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./llm/schema.json": {
|
|
32
|
+
"import": "./schema/voicethere.llm.schema.json",
|
|
33
|
+
"require": "./schema/voicethere.llm.schema.json",
|
|
34
|
+
"default": "./schema/voicethere.llm.schema.json"
|
|
35
|
+
},
|
|
25
36
|
"./verify": {
|
|
26
37
|
"types": "./dist/verify/run-verify.d.ts",
|
|
27
38
|
"import": "./dist/verify/run-verify.js",
|
|
@@ -45,20 +56,30 @@
|
|
|
45
56
|
"import": "./templates/redis-sync/world-layout.ts",
|
|
46
57
|
"require": "./templates/redis-sync/world-layout.ts",
|
|
47
58
|
"default": "./templates/redis-sync/world-layout.ts"
|
|
59
|
+
},
|
|
60
|
+
"./llm/eject/loop.ts": {
|
|
61
|
+
"types": "./eject/llm/loop.ts",
|
|
62
|
+
"import": "./eject/llm/loop.ts",
|
|
63
|
+
"require": "./eject/llm/loop.ts",
|
|
64
|
+
"default": "./eject/llm/loop.ts"
|
|
48
65
|
}
|
|
49
66
|
},
|
|
50
67
|
"bin": "./dist/cli.js",
|
|
51
68
|
"files": [
|
|
52
69
|
"dist",
|
|
70
|
+
"schema",
|
|
53
71
|
"templates",
|
|
72
|
+
"eject",
|
|
54
73
|
"README.md",
|
|
55
74
|
"LICENSE"
|
|
56
75
|
],
|
|
57
76
|
"scripts": {
|
|
58
77
|
"build:lib": "tsc -p tsconfig.json && mkdir -p dist/sandbox && cp src/sandbox/loader-entry.js dist/sandbox/",
|
|
78
|
+
"build:schema": "node scripts/build-llm-schema.mjs",
|
|
79
|
+
"build:eject": "node scripts/build-llm-eject.mjs",
|
|
59
80
|
"build:templates": "node dist/templates/build-seed-bundles-cli.js",
|
|
60
81
|
"build:example": "node dist/cli.js build --entry examples/agent.ts --outfile dist/agent.js",
|
|
61
|
-
"build": "npm run build:lib && npm run build:templates && npm run build:example",
|
|
82
|
+
"build": "npm run build:lib && npm run build:schema && npm run build:eject && npm run build:templates && npm run build:example",
|
|
62
83
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
63
84
|
"test": "vitest run",
|
|
64
85
|
"test:ci": "npm run typecheck && npm run build && npm run test && node scripts/ci/verify-package-exports.mjs",
|
|
@@ -99,17 +120,40 @@
|
|
|
99
120
|
"esbuild": "0.25.12"
|
|
100
121
|
},
|
|
101
122
|
"peerDependencies": {
|
|
102
|
-
"@node-webrtc-rust/sdk": ">=0.9.0"
|
|
123
|
+
"@node-webrtc-rust/sdk": ">=0.9.0",
|
|
124
|
+
"openai": "7.43.0",
|
|
125
|
+
"@anthropic-ai/sdk": "1.3.0",
|
|
126
|
+
"@google/genai": "2.31.0",
|
|
127
|
+
"@modelcontextprotocol/sdk": "1.32.2"
|
|
103
128
|
},
|
|
104
129
|
"devDependencies": {
|
|
130
|
+
"@anthropic-ai/sdk": "1.3.0",
|
|
131
|
+
"@google/genai": "2.31.0",
|
|
132
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
105
133
|
"@node-webrtc-rust/helpers": "0.9.9",
|
|
106
134
|
"@node-webrtc-rust/sdk": "0.9.9",
|
|
107
135
|
"@node-webrtc-rust/signaling": "0.9.9",
|
|
108
136
|
"@types/node": "22.20.1",
|
|
109
137
|
"http-server": "14.1.1",
|
|
110
138
|
"ioredis": "5.11.1",
|
|
139
|
+
"openai": "7.43.0",
|
|
111
140
|
"tsx": "4.19.2",
|
|
112
141
|
"typescript": "5.9.3",
|
|
113
|
-
"vitest": "3.2.7"
|
|
142
|
+
"vitest": "3.2.7",
|
|
143
|
+
"zod": "4.6.7"
|
|
144
|
+
},
|
|
145
|
+
"peerDependenciesMeta": {
|
|
146
|
+
"openai": {
|
|
147
|
+
"optional": true
|
|
148
|
+
},
|
|
149
|
+
"@anthropic-ai/sdk": {
|
|
150
|
+
"optional": true
|
|
151
|
+
},
|
|
152
|
+
"@google/genai": {
|
|
153
|
+
"optional": true
|
|
154
|
+
},
|
|
155
|
+
"@modelcontextprotocol/sdk": {
|
|
156
|
+
"optional": true
|
|
157
|
+
}
|
|
114
158
|
}
|
|
115
159
|
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://voicethere.io/schema/voicethere.llm.schema.json",
|
|
4
|
+
"title": "VoiceThere LLM agent config",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"version",
|
|
9
|
+
"provider",
|
|
10
|
+
"apiKeySecret"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"$schema": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"version": {
|
|
17
|
+
"const": 1
|
|
18
|
+
},
|
|
19
|
+
"provider": {
|
|
20
|
+
"enum": [
|
|
21
|
+
"openai",
|
|
22
|
+
"anthropic",
|
|
23
|
+
"gemini",
|
|
24
|
+
"openrouter"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"model": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"minLength": 1,
|
|
30
|
+
"maxLength": 200
|
|
31
|
+
},
|
|
32
|
+
"apiKeySecret": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"pattern": "^AGENT_[A-Z0-9_]{1,57}$",
|
|
35
|
+
"description": "Name of an AGENT_* environment variable (project secret), never its value."
|
|
36
|
+
},
|
|
37
|
+
"baseUrl": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"format": "uri",
|
|
40
|
+
"pattern": "^https?://",
|
|
41
|
+
"description": "Only allowed when provider is \"openai\"."
|
|
42
|
+
},
|
|
43
|
+
"temperature": {
|
|
44
|
+
"type": "number",
|
|
45
|
+
"minimum": 0,
|
|
46
|
+
"maximum": 2
|
|
47
|
+
},
|
|
48
|
+
"maxOutputTokens": {
|
|
49
|
+
"type": "integer",
|
|
50
|
+
"minimum": 1,
|
|
51
|
+
"maximum": 8192,
|
|
52
|
+
"default": 512
|
|
53
|
+
},
|
|
54
|
+
"greeting": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"required": [
|
|
58
|
+
"text"
|
|
59
|
+
],
|
|
60
|
+
"properties": {
|
|
61
|
+
"text": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"minLength": 1,
|
|
64
|
+
"maxLength": 500
|
|
65
|
+
},
|
|
66
|
+
"interruptible": {
|
|
67
|
+
"type": "boolean",
|
|
68
|
+
"default": false
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"bargeIn": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": false,
|
|
75
|
+
"required": [
|
|
76
|
+
"mode"
|
|
77
|
+
],
|
|
78
|
+
"properties": {
|
|
79
|
+
"mode": {
|
|
80
|
+
"enum": [
|
|
81
|
+
"project",
|
|
82
|
+
"on",
|
|
83
|
+
"off"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"default": {
|
|
88
|
+
"mode": "project"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"speechDuringNonInterruptible": {
|
|
92
|
+
"enum": [
|
|
93
|
+
"answer_after",
|
|
94
|
+
"discard"
|
|
95
|
+
],
|
|
96
|
+
"default": "answer_after"
|
|
97
|
+
},
|
|
98
|
+
"history": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"properties": {
|
|
102
|
+
"turns": {
|
|
103
|
+
"type": "integer",
|
|
104
|
+
"minimum": 1,
|
|
105
|
+
"maximum": 100,
|
|
106
|
+
"default": 20
|
|
107
|
+
},
|
|
108
|
+
"interruptionNote": {
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"default": true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"tools": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"additionalProperties": false,
|
|
117
|
+
"properties": {
|
|
118
|
+
"maxRounds": {
|
|
119
|
+
"type": "integer",
|
|
120
|
+
"minimum": 1,
|
|
121
|
+
"maximum": 10,
|
|
122
|
+
"default": 5
|
|
123
|
+
},
|
|
124
|
+
"timeoutMs": {
|
|
125
|
+
"type": "integer",
|
|
126
|
+
"minimum": 1000,
|
|
127
|
+
"maximum": 60000,
|
|
128
|
+
"default": 15000
|
|
129
|
+
},
|
|
130
|
+
"maxResultBytes": {
|
|
131
|
+
"type": "integer",
|
|
132
|
+
"minimum": 1024,
|
|
133
|
+
"maximum": 65536,
|
|
134
|
+
"default": 16384
|
|
135
|
+
},
|
|
136
|
+
"filler": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"additionalProperties": false,
|
|
139
|
+
"required": [
|
|
140
|
+
"text"
|
|
141
|
+
],
|
|
142
|
+
"properties": {
|
|
143
|
+
"text": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"minLength": 1,
|
|
146
|
+
"maxLength": 500
|
|
147
|
+
},
|
|
148
|
+
"afterMs": {
|
|
149
|
+
"type": "integer",
|
|
150
|
+
"minimum": 500,
|
|
151
|
+
"maximum": 10000,
|
|
152
|
+
"default": 1500
|
|
153
|
+
},
|
|
154
|
+
"interruptible": {
|
|
155
|
+
"type": "boolean",
|
|
156
|
+
"default": false
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"toolSources": {
|
|
163
|
+
"type": "array",
|
|
164
|
+
"maxItems": 8,
|
|
165
|
+
"items": {
|
|
166
|
+
"oneOf": [
|
|
167
|
+
{
|
|
168
|
+
"type": "object",
|
|
169
|
+
"additionalProperties": false,
|
|
170
|
+
"required": [
|
|
171
|
+
"kind"
|
|
172
|
+
],
|
|
173
|
+
"properties": {
|
|
174
|
+
"kind": {
|
|
175
|
+
"const": "service"
|
|
176
|
+
},
|
|
177
|
+
"path": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"pattern": "^/",
|
|
180
|
+
"default": "/mcp"
|
|
181
|
+
},
|
|
182
|
+
"allow": {
|
|
183
|
+
"type": "array",
|
|
184
|
+
"items": {
|
|
185
|
+
"type": "string",
|
|
186
|
+
"minLength": 1,
|
|
187
|
+
"maxLength": 128
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"deny": {
|
|
191
|
+
"type": "array",
|
|
192
|
+
"items": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"minLength": 1,
|
|
195
|
+
"maxLength": 128
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"type": "object",
|
|
202
|
+
"additionalProperties": false,
|
|
203
|
+
"required": [
|
|
204
|
+
"kind",
|
|
205
|
+
"name",
|
|
206
|
+
"url"
|
|
207
|
+
],
|
|
208
|
+
"properties": {
|
|
209
|
+
"kind": {
|
|
210
|
+
"const": "mcp"
|
|
211
|
+
},
|
|
212
|
+
"name": {
|
|
213
|
+
"type": "string",
|
|
214
|
+
"pattern": "^[a-z0-9-]{1,40}$"
|
|
215
|
+
},
|
|
216
|
+
"url": {
|
|
217
|
+
"type": "string",
|
|
218
|
+
"format": "uri",
|
|
219
|
+
"pattern": "^https://",
|
|
220
|
+
"description": "https only; local and private addresses are rejected."
|
|
221
|
+
},
|
|
222
|
+
"auth": {
|
|
223
|
+
"oneOf": [
|
|
224
|
+
{
|
|
225
|
+
"type": "object",
|
|
226
|
+
"additionalProperties": false,
|
|
227
|
+
"required": [
|
|
228
|
+
"type"
|
|
229
|
+
],
|
|
230
|
+
"properties": {
|
|
231
|
+
"type": {
|
|
232
|
+
"const": "none"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"type": "object",
|
|
238
|
+
"additionalProperties": false,
|
|
239
|
+
"required": [
|
|
240
|
+
"type",
|
|
241
|
+
"secret"
|
|
242
|
+
],
|
|
243
|
+
"properties": {
|
|
244
|
+
"type": {
|
|
245
|
+
"const": "bearer"
|
|
246
|
+
},
|
|
247
|
+
"secret": {
|
|
248
|
+
"type": "string",
|
|
249
|
+
"pattern": "^AGENT_[A-Z0-9_]{1,57}$",
|
|
250
|
+
"description": "Name of an AGENT_* environment variable (project secret), never its value."
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"type": "object",
|
|
256
|
+
"additionalProperties": false,
|
|
257
|
+
"required": [
|
|
258
|
+
"type",
|
|
259
|
+
"headers"
|
|
260
|
+
],
|
|
261
|
+
"properties": {
|
|
262
|
+
"type": {
|
|
263
|
+
"const": "headers"
|
|
264
|
+
},
|
|
265
|
+
"headers": {
|
|
266
|
+
"type": "object",
|
|
267
|
+
"propertyNames": {
|
|
268
|
+
"pattern": "^[A-Za-z0-9-]{1,64}$"
|
|
269
|
+
},
|
|
270
|
+
"additionalProperties": {
|
|
271
|
+
"type": "string",
|
|
272
|
+
"pattern": "^AGENT_[A-Z0-9_]{1,57}$",
|
|
273
|
+
"description": "Name of an AGENT_* environment variable (project secret), never its value."
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
"allow": {
|
|
281
|
+
"type": "array",
|
|
282
|
+
"items": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"minLength": 1,
|
|
285
|
+
"maxLength": 128
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
"deny": {
|
|
289
|
+
"type": "array",
|
|
290
|
+
"items": {
|
|
291
|
+
"type": "string",
|
|
292
|
+
"minLength": 1,
|
|
293
|
+
"maxLength": 128
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"interruptPolicy": {
|
|
302
|
+
"enum": [
|
|
303
|
+
"cancel",
|
|
304
|
+
"finish"
|
|
305
|
+
],
|
|
306
|
+
"default": "cancel"
|
|
307
|
+
},
|
|
308
|
+
"serviceWaitMs": {
|
|
309
|
+
"type": "integer",
|
|
310
|
+
"minimum": 0,
|
|
311
|
+
"maximum": 60000,
|
|
312
|
+
"default": 20000
|
|
313
|
+
},
|
|
314
|
+
"fallbackText": {
|
|
315
|
+
"type": "string",
|
|
316
|
+
"minLength": 1,
|
|
317
|
+
"maxLength": 500,
|
|
318
|
+
"default": "Sorry, something went wrong. Please try again."
|
|
319
|
+
},
|
|
320
|
+
"speakChatReplies": {
|
|
321
|
+
"type": "boolean",
|
|
322
|
+
"default": true
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# llm-agent
|
|
2
|
+
|
|
3
|
+
A voice and chat agent powered by an LLM, with custom tools and MCP servers. Source: `templates/llm-agent/agent.ts`.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- `agent.ts` wires the pieces together. You rarely need to change it.
|
|
8
|
+
- `voicethere.llm.json` holds the provider, model, greeting, barge-in, history and tool settings. The dashboard LLM tab edits this file.
|
|
9
|
+
- `prompt.md` is the system prompt. The dashboard LLM tab edits this file too.
|
|
10
|
+
- `tools.ts` lists your own tools. It ships with `get_current_time`.
|
|
11
|
+
- `hooks.ts` is where you adjust a turn in code. It is empty by default.
|
|
12
|
+
- `md.d.ts` lets TypeScript accept `import prompt from "./prompt.md"`.
|
|
13
|
+
|
|
14
|
+
## Set the API key
|
|
15
|
+
|
|
16
|
+
The default provider is OpenAI. Add a project secret named `AGENT_OPENAI_API_KEY` with your key, then deploy. The key is read by name from `apiKeySecret` in `voicethere.llm.json`; it is never stored in the file. Only project secrets whose names start with `AGENT_` reach the agent.
|
|
17
|
+
|
|
18
|
+
## Switch providers
|
|
19
|
+
|
|
20
|
+
Change `provider`, `model` and `apiKeySecret` in `voicethere.llm.json`. For example, `anthropic` with `AGENT_ANTHROPIC_API_KEY`, `gemini` with `AGENT_GEMINI_API_KEY`, or `openrouter` with `AGENT_OPENROUTER_API_KEY`. Create the matching project secret before you deploy.
|
|
21
|
+
|
|
22
|
+
## Learn more
|
|
23
|
+
|
|
24
|
+
See the docs page `/docs/llm-agents` for the full list of settings, tools, MCP servers and hooks.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineAgent } from "@voicethere/agent";
|
|
2
|
+
import { createLlmAgent } from "@voicethere/agent/llm";
|
|
3
|
+
import config from "./voicethere.llm.json";
|
|
4
|
+
import systemPrompt from "./prompt.md";
|
|
5
|
+
import { tools } from "./tools";
|
|
6
|
+
import { hooks } from "./hooks";
|
|
7
|
+
|
|
8
|
+
defineAgent(createLlmAgent({ config, systemPrompt, tools, hooks }));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LlmAgentHooks } from "@voicethere/agent/llm";
|
|
2
|
+
|
|
3
|
+
export const hooks: LlmAgentHooks = {};
|
|
4
|
+
|
|
5
|
+
// Example: rewrite or drop a sentence before it is spoken.
|
|
6
|
+
//
|
|
7
|
+
// export const hooks: LlmAgentHooks = {
|
|
8
|
+
// onAssistantText: (text) => text.replace(/\*+/g, ""),
|
|
9
|
+
// };
|
|
10
|
+
//
|
|
11
|
+
// Example: take over a turn, then fall back to the model.
|
|
12
|
+
//
|
|
13
|
+
// export const hooks: LlmAgentHooks = {
|
|
14
|
+
// respond: async (ctx, next) => {
|
|
15
|
+
// if (/^(bye|goodbye)\b/i.test(ctx.inputText)) {
|
|
16
|
+
// ctx.speak("Goodbye!");
|
|
17
|
+
// return;
|
|
18
|
+
// }
|
|
19
|
+
// return next();
|
|
20
|
+
// },
|
|
21
|
+
// };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
You are a helpful voice assistant for your company. People talk to you by voice, so everything you say is read aloud.
|
|
2
|
+
|
|
3
|
+
Answer in short, spoken sentences. Two or three sentences are usually enough. Do not use markdown, bullet lists, headings, emoji or special characters, because they sound wrong when spoken.
|
|
4
|
+
|
|
5
|
+
Ask one question at a time and wait for the answer before asking the next one.
|
|
6
|
+
|
|
7
|
+
If you do not know something, say so plainly instead of guessing. Offer to help with what you can do.
|
|
8
|
+
|
|
9
|
+
Use your tools when they help. For example, call get_current_time when someone asks what time or date it is, and pass the time zone if they name one.
|
|
10
|
+
|
|
11
|
+
Keep numbers and dates easy to say. Say "March third" instead of "03/03", and round long numbers when the exact value does not matter.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineTool } from "@voicethere/agent/llm";
|
|
2
|
+
|
|
3
|
+
const getCurrentTime = defineTool<{ timeZone?: string }>({
|
|
4
|
+
name: "get_current_time",
|
|
5
|
+
description: "Current date and time in a time zone.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
timeZone: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "IANA time zone, e.g. Europe/Berlin",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
additionalProperties: false,
|
|
15
|
+
},
|
|
16
|
+
handler: ({ timeZone }) => {
|
|
17
|
+
const zone = timeZone || "UTC";
|
|
18
|
+
try {
|
|
19
|
+
return new Date().toLocaleString("en-US", {
|
|
20
|
+
timeZone: zone,
|
|
21
|
+
dateStyle: "full",
|
|
22
|
+
timeStyle: "short",
|
|
23
|
+
});
|
|
24
|
+
} catch {
|
|
25
|
+
return `Unknown time zone: ${zone}`;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Example: a tool that calls an HTTP API. Keep every request bounded.
|
|
31
|
+
//
|
|
32
|
+
// const lookupOrder = defineTool<{ orderId: string }>({
|
|
33
|
+
// name: "lookup_order",
|
|
34
|
+
// description: "Status of an order by its id.",
|
|
35
|
+
// inputSchema: {
|
|
36
|
+
// type: "object",
|
|
37
|
+
// properties: { orderId: { type: "string" } },
|
|
38
|
+
// required: ["orderId"],
|
|
39
|
+
// additionalProperties: false,
|
|
40
|
+
// },
|
|
41
|
+
// handler: async ({ orderId }) => {
|
|
42
|
+
// const res = await fetch(
|
|
43
|
+
// `https://api.example.com/orders/${encodeURIComponent(orderId)}`,
|
|
44
|
+
// { signal: AbortSignal.timeout(5000) },
|
|
45
|
+
// );
|
|
46
|
+
// if (!res.ok) return `Order lookup failed with status ${res.status}`;
|
|
47
|
+
// return await res.text();
|
|
48
|
+
// },
|
|
49
|
+
// });
|
|
50
|
+
|
|
51
|
+
export const tools = [getCurrentTime];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@voicethere/agent/schema/voicethere.llm.schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"provider": "openai",
|
|
5
|
+
"model": "gpt-4o-mini",
|
|
6
|
+
"apiKeySecret": "AGENT_OPENAI_API_KEY",
|
|
7
|
+
"maxOutputTokens": 300,
|
|
8
|
+
"greeting": {
|
|
9
|
+
"text": "Hi! How can I help you today?",
|
|
10
|
+
"interruptible": true
|
|
11
|
+
},
|
|
12
|
+
"bargeIn": { "mode": "project" },
|
|
13
|
+
"history": { "turns": 20, "interruptionNote": true },
|
|
14
|
+
"tools": {
|
|
15
|
+
"maxRounds": 5,
|
|
16
|
+
"timeoutMs": 15000,
|
|
17
|
+
"filler": { "text": "One moment." }
|
|
18
|
+
},
|
|
19
|
+
"toolSources": [],
|
|
20
|
+
"interruptPolicy": "cancel"
|
|
21
|
+
}
|