@voicethere/agent 0.12.1 → 0.13.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/dist/llm/agent/create-llm-agent.d.ts +3 -1
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +8 -1
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/anthropic.d.ts +6 -0
- package/dist/llm/anthropic.d.ts.map +1 -0
- package/dist/llm/anthropic.js +8 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/gemini.d.ts +6 -0
- package/dist/llm/gemini.d.ts.map +1 -0
- package/dist/llm/gemini.js +8 -0
- package/dist/llm/gemini.js.map +1 -0
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/openai.d.ts +6 -0
- package/dist/llm/openai.d.ts.map +1 -0
- package/dist/llm/openai.js +12 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/providers.d.ts +4 -2
- package/dist/llm/providers.d.ts.map +1 -1
- package/dist/llm/providers.js +20 -22
- package/dist/llm/providers.js.map +1 -1
- package/dist/llm/types.d.ts +10 -0
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/templates/llm-agent/agent.js +25550 -100177
- package/eject/llm/loop.ts +24 -6
- package/package.json +19 -1
- package/templates/llm-agent/README.md +10 -0
- package/templates/llm-agent/agent.ts +9 -1
package/eject/llm/loop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copied from @voicethere/agent 0.
|
|
1
|
+
// Copied from @voicethere/agent 0.13.0. Package updates no longer change this file.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import {
|
|
4
4
|
type AgentHandlers,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type LlmMessage,
|
|
24
24
|
type LlmProvider,
|
|
25
25
|
LlmProviderError,
|
|
26
|
+
type LlmProviderModule,
|
|
26
27
|
type LlmStreamEvent,
|
|
27
28
|
type LlmToolResult,
|
|
28
29
|
McpToolSource,
|
|
@@ -48,6 +49,8 @@ export interface CreateLlmAgentOptions {
|
|
|
48
49
|
env?: () => Record<string, string | undefined>;
|
|
49
50
|
/** Test injection. */
|
|
50
51
|
provider?: LlmProvider;
|
|
52
|
+
/** Provider SDK modules this agent may use, e.g. `[openai]` from `@voicethere/agent/llm/openai`. Must include the one `config.provider` selects. */
|
|
53
|
+
providers?: readonly LlmProviderModule[];
|
|
51
54
|
now?: () => number;
|
|
52
55
|
/** Test injection for MCP tool sources. */
|
|
53
56
|
sourceFactory?: (opts: McpToolSourceOptions) => McpToolSource;
|
|
@@ -132,6 +135,18 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
132
135
|
);
|
|
133
136
|
}
|
|
134
137
|
const config: LlmAgentConfig = validated.config;
|
|
138
|
+
if (
|
|
139
|
+
!opts.provider &&
|
|
140
|
+
!(opts.providers ?? []).some((m) => m.ids.includes(config.provider))
|
|
141
|
+
) {
|
|
142
|
+
// Quotes are interpolated so the eject copy's import scan sees no specifier here.
|
|
143
|
+
const sub = config.provider === "openrouter" ? "openai" : config.provider;
|
|
144
|
+
const q = '"';
|
|
145
|
+
throw configError(
|
|
146
|
+
`voicethere.llm.json selects provider ${q}${config.provider}${q}, but agent.ts does not register it. Add: import { ${sub} } from ${q}@voicethere/agent/llm/${sub}${q}; and pass providers: [${sub}]`,
|
|
147
|
+
"LLM_CONFIG_INVALID",
|
|
148
|
+
);
|
|
149
|
+
}
|
|
135
150
|
const hooks = opts.hooks ?? {};
|
|
136
151
|
const now = opts.now ?? Date.now;
|
|
137
152
|
const getEnv = opts.env ?? (() => process.env);
|
|
@@ -822,11 +837,14 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
822
837
|
);
|
|
823
838
|
}
|
|
824
839
|
if (!provider) {
|
|
825
|
-
provider = createLlmProvider(
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
840
|
+
provider = createLlmProvider(
|
|
841
|
+
{
|
|
842
|
+
provider: config.provider,
|
|
843
|
+
apiKey,
|
|
844
|
+
baseUrl: config.baseUrl,
|
|
845
|
+
},
|
|
846
|
+
opts.providers ?? [],
|
|
847
|
+
);
|
|
830
848
|
}
|
|
831
849
|
buildRegistry(env);
|
|
832
850
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicethere/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
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,24 @@
|
|
|
22
22
|
"require": "./dist/host/index.js",
|
|
23
23
|
"default": "./dist/host/index.js"
|
|
24
24
|
},
|
|
25
|
+
"./llm/openai": {
|
|
26
|
+
"types": "./dist/llm/openai.d.ts",
|
|
27
|
+
"import": "./dist/llm/openai.js",
|
|
28
|
+
"require": "./dist/llm/openai.js",
|
|
29
|
+
"default": "./dist/llm/openai.js"
|
|
30
|
+
},
|
|
31
|
+
"./llm/anthropic": {
|
|
32
|
+
"types": "./dist/llm/anthropic.d.ts",
|
|
33
|
+
"import": "./dist/llm/anthropic.js",
|
|
34
|
+
"require": "./dist/llm/anthropic.js",
|
|
35
|
+
"default": "./dist/llm/anthropic.js"
|
|
36
|
+
},
|
|
37
|
+
"./llm/gemini": {
|
|
38
|
+
"types": "./dist/llm/gemini.d.ts",
|
|
39
|
+
"import": "./dist/llm/gemini.js",
|
|
40
|
+
"require": "./dist/llm/gemini.js",
|
|
41
|
+
"default": "./dist/llm/gemini.js"
|
|
42
|
+
},
|
|
25
43
|
"./llm": {
|
|
26
44
|
"types": "./dist/llm/index.d.ts",
|
|
27
45
|
"import": "./dist/llm/index.js",
|
|
@@ -19,6 +19,16 @@ The default provider is OpenAI. Add a project secret named `AGENT_OPENAI_API_KEY
|
|
|
19
19
|
|
|
20
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
21
|
|
|
22
|
+
## Switching provider
|
|
23
|
+
|
|
24
|
+
Only the provider you import in `agent.ts` is bundled. When you change `provider` in `voicethere.llm.json`, also change the import and the `providers` list:
|
|
25
|
+
|
|
26
|
+
- `anthropic`: `import { anthropic } from "@voicethere/agent/llm/anthropic";` and `providers: [anthropic]`
|
|
27
|
+
- `gemini`: `import { gemini } from "@voicethere/agent/llm/gemini";` and `providers: [gemini]`
|
|
28
|
+
- `openrouter` uses the `openai` module.
|
|
29
|
+
|
|
30
|
+
If they do not match, `createLlmAgent` throws when the bundle loads, and the deploy check reports it.
|
|
31
|
+
|
|
22
32
|
## Learn more
|
|
23
33
|
|
|
24
34
|
See the docs page `/docs/llm-agents` for the full list of settings, tools, MCP servers and hooks.
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { defineAgent } from "@voicethere/agent";
|
|
2
2
|
import { createLlmAgent } from "@voicethere/agent/llm";
|
|
3
|
+
import { openai } from "@voicethere/agent/llm/openai";
|
|
3
4
|
import config from "./voicethere.llm.json";
|
|
4
5
|
import systemPrompt from "./prompt.md";
|
|
5
6
|
import { tools } from "./tools";
|
|
6
7
|
import { hooks } from "./hooks";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// Only the provider you import here is bundled. To switch provider, change
|
|
10
|
+
// "provider" in voicethere.llm.json and import its module instead:
|
|
11
|
+
// anthropic → import { anthropic } from "@voicethere/agent/llm/anthropic";
|
|
12
|
+
// gemini → import { gemini } from "@voicethere/agent/llm/gemini";
|
|
13
|
+
// openrouter uses the openai module.
|
|
14
|
+
defineAgent(
|
|
15
|
+
createLlmAgent({ config, systemPrompt, tools, hooks, providers: [openai] }),
|
|
16
|
+
);
|