agent-worker 0.1.0 → 0.2.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 +392 -0
- package/dist/{backends-BklSbwcH.mjs → backends-BGJk-onJ.mjs} +181 -3
- package/dist/{backends-BqaAh6cC.mjs → backends-bvhx4Wb6.mjs} +1 -2
- package/dist/cli/index.mjs +351 -48
- package/dist/index.d.mts +170 -2
- package/dist/index.mjs +4 -5
- package/dist/skills-B8z8tFaH.mjs +874 -0
- package/package.json +4 -2
- package/dist/models-FOOpWB91.mjs +0 -182
- package/dist/session-DQQAmPf-.mjs +0 -419
package/README.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# agent-worker
|
|
2
|
+
|
|
3
|
+
CLI and SDK for creating and managing AI agent sessions with multiple backends.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g agent-worker
|
|
9
|
+
# or
|
|
10
|
+
bun add -g agent-worker
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## CLI Usage
|
|
14
|
+
|
|
15
|
+
### Session Management
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Create a session (SDK backend, default)
|
|
19
|
+
agent-worker session new -m anthropic/claude-sonnet-4-5
|
|
20
|
+
|
|
21
|
+
# Create with system prompt
|
|
22
|
+
agent-worker session new -s "You are a code reviewer."
|
|
23
|
+
|
|
24
|
+
# Create with system prompt from file
|
|
25
|
+
agent-worker session new -f ./prompts/reviewer.txt
|
|
26
|
+
|
|
27
|
+
# Create named session
|
|
28
|
+
agent-worker session new -n my-session
|
|
29
|
+
|
|
30
|
+
# Create with Claude CLI backend
|
|
31
|
+
agent-worker session new -b claude
|
|
32
|
+
|
|
33
|
+
# List all sessions
|
|
34
|
+
agent-worker session list
|
|
35
|
+
|
|
36
|
+
# Switch default session
|
|
37
|
+
agent-worker session use my-session
|
|
38
|
+
|
|
39
|
+
# Check session status
|
|
40
|
+
agent-worker session status
|
|
41
|
+
|
|
42
|
+
# End session
|
|
43
|
+
agent-worker session end
|
|
44
|
+
|
|
45
|
+
# End specific session
|
|
46
|
+
agent-worker session end my-session
|
|
47
|
+
|
|
48
|
+
# End all sessions
|
|
49
|
+
agent-worker session end --all
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Sending Messages
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Send to current session
|
|
56
|
+
agent-worker send "What is 2+2?"
|
|
57
|
+
|
|
58
|
+
# Send to specific session
|
|
59
|
+
agent-worker send "Explain recursion" --to my-session
|
|
60
|
+
|
|
61
|
+
# View conversation history
|
|
62
|
+
agent-worker history
|
|
63
|
+
agent-worker history --last 5
|
|
64
|
+
|
|
65
|
+
# View token usage
|
|
66
|
+
agent-worker stats
|
|
67
|
+
|
|
68
|
+
# Export transcript
|
|
69
|
+
agent-worker export > transcript.json
|
|
70
|
+
|
|
71
|
+
# Clear history (keep session)
|
|
72
|
+
agent-worker clear
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Tool Management (SDK Backend Only)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Add a tool
|
|
79
|
+
agent-worker tool add get_weather \
|
|
80
|
+
-d "Get weather for a location" \
|
|
81
|
+
-p "location:string:City name"
|
|
82
|
+
|
|
83
|
+
# Add tool requiring approval
|
|
84
|
+
agent-worker tool add delete_file \
|
|
85
|
+
-d "Delete a file" \
|
|
86
|
+
-p "path:string:File path" \
|
|
87
|
+
--needs-approval
|
|
88
|
+
|
|
89
|
+
# Import tools from file
|
|
90
|
+
agent-worker tool import ./my-tools.ts
|
|
91
|
+
|
|
92
|
+
# Mock tool response (for testing)
|
|
93
|
+
agent-worker tool mock get_weather '{"temp": 72, "condition": "sunny"}'
|
|
94
|
+
|
|
95
|
+
# List registered tools
|
|
96
|
+
agent-worker tool list
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Approval Workflow
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Check pending approvals
|
|
103
|
+
agent-worker pending
|
|
104
|
+
|
|
105
|
+
# Approve a tool call
|
|
106
|
+
agent-worker approve <approval-id>
|
|
107
|
+
|
|
108
|
+
# Deny with reason
|
|
109
|
+
agent-worker deny <approval-id> -r "Path not allowed"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Agent Skills
|
|
113
|
+
|
|
114
|
+
Agent skills provide reusable instructions and methodologies that agents can access on demand. Compatible with the [Agent Skills](https://agentskills.io) ecosystem.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Load skills from default directories (.agents/skills, .claude/skills, ~/.agents/skills)
|
|
118
|
+
agent-worker session new
|
|
119
|
+
|
|
120
|
+
# Add a specific skill directory
|
|
121
|
+
agent-worker session new --skill ./my-skills/custom-skill
|
|
122
|
+
|
|
123
|
+
# Scan additional directories for skills
|
|
124
|
+
agent-worker session new --skill-dir ./team-skills --skill-dir ~/shared-skills
|
|
125
|
+
|
|
126
|
+
# Combine multiple options
|
|
127
|
+
agent-worker session new \
|
|
128
|
+
--skill ./my-skills/dive \
|
|
129
|
+
--skill-dir ~/company-skills
|
|
130
|
+
|
|
131
|
+
# Import skills from Git repositories (temporary, session-scoped)
|
|
132
|
+
agent-worker session new --import-skill vercel-labs/agent-skills:dive
|
|
133
|
+
agent-worker session new --import-skill lidessen/skills:{memory,orientation}
|
|
134
|
+
agent-worker session new --import-skill gitlab:myorg/skills@v1.0.0:custom
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Import Skill Spec Format:**
|
|
138
|
+
|
|
139
|
+
The `--import-skill` option supports temporary skill imports from Git repositories. Skills are cloned to a session-specific temp directory and cleaned up when the session ends.
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
[provider:]owner/repo[@ref]:{skill1,skill2,...}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Examples:
|
|
146
|
+
- `vercel-labs/agent-skills` - Import all skills from GitHub main branch
|
|
147
|
+
- `vercel-labs/agent-skills:dive` - Import single skill
|
|
148
|
+
- `vercel-labs/agent-skills:{dive,memory}` - Import multiple skills (brace expansion)
|
|
149
|
+
- `vercel-labs/agent-skills@v1.0.0:dive` - Import from specific tag/branch
|
|
150
|
+
- `gitlab:myorg/skills:custom` - Import from GitLab
|
|
151
|
+
- `gitee:org/repo@dev:{a,b}` - Import from Gitee dev branch
|
|
152
|
+
|
|
153
|
+
Supported providers: `github` (default), `gitlab`, `gitee`
|
|
154
|
+
|
|
155
|
+
**Skills Support by Backend:**
|
|
156
|
+
|
|
157
|
+
| Backend | Skills Support | How It Works | `--import-skill` |
|
|
158
|
+
|---------|----------------|--------------|------------------|
|
|
159
|
+
| **SDK** (default) | ✅ Full | Skills loaded as a tool that agents can call | ✅ Supported |
|
|
160
|
+
| **Claude CLI** | ✅ Full | Loads from `.claude/skills/` and `~/.claude/skills/` | ⚠️ Manual install required |
|
|
161
|
+
| **Codex CLI** | ✅ Full | Loads from `.agents/skills/`, `~/.codex/skills/`, `~/.agents/skills/` | ⚠️ Manual install required |
|
|
162
|
+
| **Cursor CLI** | ✅ Full | Loads from `.agents/skills/` and `~/.cursor/skills/` | ⚠️ Manual install required |
|
|
163
|
+
|
|
164
|
+
**Notes:**
|
|
165
|
+
- **SDK Backend**: Skills work through the Skills tool, allowing dynamic file reading. `--import-skill` is fully supported.
|
|
166
|
+
- **CLI Backends** (claude, codex, cursor): Skills are loaded from filesystem locations by the CLI tool itself. To use `--import-skill` with these backends, install skills manually using `npx skills add <repo> --global`.
|
|
167
|
+
- If you specify `--import-skill` with a CLI backend, agent-worker will show a warning and suggest using SDK backend or manual installation.
|
|
168
|
+
|
|
169
|
+
**Default Skill Directories:**
|
|
170
|
+
- `.agents/skills/` - Project-level skills (all backends)
|
|
171
|
+
- `.claude/skills/` - Claude Code project skills
|
|
172
|
+
- `.cursor/skills/` - Cursor project skills
|
|
173
|
+
- `~/.agents/skills/` - User-level global skills (all backends)
|
|
174
|
+
- `~/.claude/skills/` - User-level Claude skills
|
|
175
|
+
- `~/.codex/skills/` - User-level Codex skills
|
|
176
|
+
|
|
177
|
+
**Using Skills in Sessions:**
|
|
178
|
+
|
|
179
|
+
Once loaded, agents can interact with skills via the `Skills` tool:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// List available skills
|
|
183
|
+
Skills({ operation: 'list' })
|
|
184
|
+
|
|
185
|
+
// View a skill's complete instructions
|
|
186
|
+
Skills({ operation: 'view', skillName: 'dive' })
|
|
187
|
+
|
|
188
|
+
// Read skill reference files
|
|
189
|
+
Skills({
|
|
190
|
+
operation: 'readFile',
|
|
191
|
+
skillName: 'dive',
|
|
192
|
+
filePath: 'references/search-strategies.md'
|
|
193
|
+
})
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Installing Skills:**
|
|
197
|
+
|
|
198
|
+
Use the [skills CLI](https://github.com/vercel-labs/skills) to install skills:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Install from GitHub
|
|
202
|
+
npx skills add vercel-labs/agent-skills
|
|
203
|
+
|
|
204
|
+
# Or use the official skills tool
|
|
205
|
+
npm install -g @agentskills/cli
|
|
206
|
+
skills add vercel-labs/agent-skills
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Backends
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Check available backends
|
|
213
|
+
agent-worker backends
|
|
214
|
+
|
|
215
|
+
# Check SDK providers
|
|
216
|
+
agent-worker providers
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
| Backend | Command | Best For |
|
|
220
|
+
|---------|---------|----------|
|
|
221
|
+
| SDK (default) | `session new -m provider/model` | Full control, tool injection, mocking |
|
|
222
|
+
| Claude CLI | `session new -b claude` | Use existing Claude installation |
|
|
223
|
+
| Codex | `session new -b codex` | OpenAI Codex workflows |
|
|
224
|
+
| Cursor | `session new -b cursor` | Cursor Agent integration |
|
|
225
|
+
|
|
226
|
+
> **⚠️ Important:** Different backends have different capabilities. CLI backends (claude, codex, cursor) don't support:
|
|
227
|
+
> - Dynamic tool management (`tool_add`, `tool_mock`, `tool_import`)
|
|
228
|
+
> - Approval system (`approve`, `deny`)
|
|
229
|
+
> - `--import-skill` (use `npx skills add --global` instead)
|
|
230
|
+
>
|
|
231
|
+
> See [BACKEND_COMPATIBILITY.md](./BACKEND_COMPATIBILITY.md) for a complete feature comparison.
|
|
232
|
+
|
|
233
|
+
### Model Formats (SDK Backend)
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Gateway format (recommended)
|
|
237
|
+
agent-worker session new -m anthropic/claude-sonnet-4-5
|
|
238
|
+
agent-worker session new -m openai/gpt-5.2
|
|
239
|
+
|
|
240
|
+
# Provider-only (uses frontier model)
|
|
241
|
+
agent-worker session new -m anthropic
|
|
242
|
+
agent-worker session new -m openai
|
|
243
|
+
|
|
244
|
+
# Direct provider format
|
|
245
|
+
agent-worker session new -m deepseek:deepseek-chat
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## SDK Usage
|
|
249
|
+
|
|
250
|
+
### Basic Session
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
import { AgentSession } from 'agent-worker'
|
|
254
|
+
|
|
255
|
+
const session = new AgentSession({
|
|
256
|
+
model: 'anthropic/claude-sonnet-4-5',
|
|
257
|
+
system: 'You are a helpful assistant.',
|
|
258
|
+
tools: [/* your tools */]
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
// Send message
|
|
262
|
+
const response = await session.send('Hello')
|
|
263
|
+
console.log(response.content)
|
|
264
|
+
console.log(response.toolCalls)
|
|
265
|
+
console.log(response.usage)
|
|
266
|
+
|
|
267
|
+
// Stream response
|
|
268
|
+
for await (const chunk of session.sendStream('Tell me a story')) {
|
|
269
|
+
process.stdout.write(chunk)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Get state for persistence
|
|
273
|
+
const state = session.getState()
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### With Skills
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
import {
|
|
280
|
+
AgentSession,
|
|
281
|
+
SkillsProvider,
|
|
282
|
+
createSkillsTool
|
|
283
|
+
} from 'agent-worker'
|
|
284
|
+
|
|
285
|
+
// Setup skills
|
|
286
|
+
const skillsProvider = new SkillsProvider()
|
|
287
|
+
await skillsProvider.scanDirectory('.agents/skills')
|
|
288
|
+
await skillsProvider.scanDirectory('~/my-skills')
|
|
289
|
+
|
|
290
|
+
// Or add individual skills
|
|
291
|
+
await skillsProvider.addSkill('./custom-skills/my-skill')
|
|
292
|
+
|
|
293
|
+
// Create session with Skills tool
|
|
294
|
+
const session = new AgentSession({
|
|
295
|
+
model: 'anthropic/claude-sonnet-4-5',
|
|
296
|
+
system: 'You are a helpful assistant.',
|
|
297
|
+
tools: [
|
|
298
|
+
createSkillsTool(skillsProvider),
|
|
299
|
+
// ... other tools
|
|
300
|
+
]
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
// Agent can now access skills
|
|
304
|
+
const response = await session.send(
|
|
305
|
+
'What skills are available? Use the dive skill to analyze this codebase.'
|
|
306
|
+
)
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### With Imported Skills
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
import {
|
|
313
|
+
AgentSession,
|
|
314
|
+
SkillsProvider,
|
|
315
|
+
SkillImporter,
|
|
316
|
+
createSkillsTool
|
|
317
|
+
} from 'agent-worker'
|
|
318
|
+
|
|
319
|
+
// Setup skills provider
|
|
320
|
+
const skillsProvider = new SkillsProvider()
|
|
321
|
+
|
|
322
|
+
// Import skills from Git repositories
|
|
323
|
+
const sessionId = 'my-session-123'
|
|
324
|
+
const importer = new SkillImporter(sessionId)
|
|
325
|
+
|
|
326
|
+
// Import from GitHub
|
|
327
|
+
await importer.import('vercel-labs/agent-skills:dive')
|
|
328
|
+
await importer.import('lidessen/skills:{memory,orientation}')
|
|
329
|
+
|
|
330
|
+
// Or import multiple specs at once
|
|
331
|
+
await importer.importMultiple([
|
|
332
|
+
'vercel-labs/agent-skills:{dive,react}',
|
|
333
|
+
'gitlab:myorg/skills@v1.0.0:custom'
|
|
334
|
+
])
|
|
335
|
+
|
|
336
|
+
// Add imported skills to provider
|
|
337
|
+
await skillsProvider.addImportedSkills(importer)
|
|
338
|
+
|
|
339
|
+
// Create session
|
|
340
|
+
const session = new AgentSession({
|
|
341
|
+
model: 'anthropic/claude-sonnet-4-5',
|
|
342
|
+
system: 'You are a helpful assistant.',
|
|
343
|
+
tools: [createSkillsTool(skillsProvider)]
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
// Don't forget cleanup when done
|
|
347
|
+
process.on('exit', async () => {
|
|
348
|
+
await importer.cleanup()
|
|
349
|
+
})
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## Common Patterns
|
|
353
|
+
|
|
354
|
+
### Prompt Testing
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
agent-worker session new -f ./my-prompt.txt -n test
|
|
358
|
+
agent-worker send "Test case 1: ..." --to test
|
|
359
|
+
agent-worker send "Test case 2: ..." --to test
|
|
360
|
+
agent-worker history --to test
|
|
361
|
+
agent-worker session end test
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Tool Development with Mocks
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
agent-worker session new -n dev
|
|
368
|
+
agent-worker tool add my_api -d "Call my API" -p "endpoint:string"
|
|
369
|
+
agent-worker tool mock my_api '{"status": "ok"}'
|
|
370
|
+
agent-worker send "Call my API at /users"
|
|
371
|
+
# Update mock, test error handling
|
|
372
|
+
agent-worker tool mock my_api '{"status": "error", "code": 500}'
|
|
373
|
+
agent-worker send "Call my API at /users"
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Multi-Model Comparison
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
agent-worker session new -m anthropic/claude-sonnet-4-5 -n claude
|
|
380
|
+
agent-worker session new -m openai/gpt-5.2 -n gpt
|
|
381
|
+
agent-worker send "Explain recursion" --to claude
|
|
382
|
+
agent-worker send "Explain recursion" --to gpt
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Requirements
|
|
386
|
+
|
|
387
|
+
- Node.js 18+ or Bun
|
|
388
|
+
- API key for chosen provider (e.g., `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`)
|
|
389
|
+
|
|
390
|
+
## License
|
|
391
|
+
|
|
392
|
+
MIT
|
|
@@ -1,7 +1,185 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { generateText } from "ai";
|
|
1
|
+
import { gateway, generateText } from "ai";
|
|
3
2
|
import { spawn } from "node:child_process";
|
|
4
3
|
|
|
4
|
+
//#region src/models.ts
|
|
5
|
+
const providerCache = {};
|
|
6
|
+
/**
|
|
7
|
+
* Lazy load a provider, caching the result
|
|
8
|
+
* Supports custom baseURL and apiKey for providers using compatible APIs (e.g., MiniMax using Claude API)
|
|
9
|
+
*/
|
|
10
|
+
async function loadProvider(name, packageName, exportName, options) {
|
|
11
|
+
if (name in providerCache) return providerCache[name];
|
|
12
|
+
try {
|
|
13
|
+
const module = await import(packageName);
|
|
14
|
+
if (options?.baseURL || options?.apiKeyEnvVar) {
|
|
15
|
+
const createProvider = module[`create${exportName.charAt(0).toUpperCase() + exportName.slice(1)}`];
|
|
16
|
+
if (createProvider) {
|
|
17
|
+
const providerOptions = {};
|
|
18
|
+
if (options.baseURL) providerOptions.baseURL = options.baseURL;
|
|
19
|
+
if (options.apiKeyEnvVar) providerOptions.apiKey = process.env[options.apiKeyEnvVar];
|
|
20
|
+
providerCache[name] = createProvider(providerOptions);
|
|
21
|
+
return providerCache[name];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
providerCache[name] = module[exportName];
|
|
25
|
+
return providerCache[name];
|
|
26
|
+
} catch {
|
|
27
|
+
providerCache[name] = null;
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse model identifier and return the appropriate provider model
|
|
33
|
+
*
|
|
34
|
+
* Supports three formats:
|
|
35
|
+
*
|
|
36
|
+
* 1. Provider-only format: provider
|
|
37
|
+
* Uses first model from FRONTIER_MODELS via gateway
|
|
38
|
+
* Examples: anthropic → anthropic/claude-sonnet-4-5, openai → openai/gpt-5.2
|
|
39
|
+
*
|
|
40
|
+
* 2. Gateway format: provider/model-name
|
|
41
|
+
* Uses Vercel AI Gateway (requires AI_GATEWAY_API_KEY)
|
|
42
|
+
* Examples: anthropic/claude-sonnet-4-5, openai/gpt-5.2, deepseek/deepseek-chat
|
|
43
|
+
*
|
|
44
|
+
* 3. Direct provider format: provider:model-name
|
|
45
|
+
* Requires installing the specific @ai-sdk/provider package
|
|
46
|
+
* Examples: anthropic:claude-sonnet-4-5, openai:gpt-5.2, deepseek:deepseek-chat
|
|
47
|
+
*/
|
|
48
|
+
function createModel(modelId) {
|
|
49
|
+
if (modelId.includes("/")) return gateway(modelId);
|
|
50
|
+
if (!modelId.includes(":")) {
|
|
51
|
+
const provider = modelId;
|
|
52
|
+
if (provider in FRONTIER_MODELS) {
|
|
53
|
+
const defaultModel = FRONTIER_MODELS[provider][0];
|
|
54
|
+
return gateway(`${provider}/${defaultModel}`);
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Unknown provider: ${modelId}. Supported: ${Object.keys(FRONTIER_MODELS).join(", ")}`);
|
|
57
|
+
}
|
|
58
|
+
const colonIndex = modelId.indexOf(":");
|
|
59
|
+
const provider = modelId.slice(0, colonIndex);
|
|
60
|
+
const modelName = modelId.slice(colonIndex + 1);
|
|
61
|
+
if (!modelName) throw new Error(`Invalid model identifier: ${modelId}. Model name is required.`);
|
|
62
|
+
if (provider in providerCache && providerCache[provider]) return providerCache[provider](modelName);
|
|
63
|
+
throw new Error(`Provider '${provider}' not loaded. Use gateway format (${provider}/${modelName}) or call createModelAsync() for direct provider access.`);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Async version of createModel - supports lazy loading of direct providers
|
|
67
|
+
* Use this when you need direct provider access (provider:model format)
|
|
68
|
+
*/
|
|
69
|
+
async function createModelAsync(modelId) {
|
|
70
|
+
if (modelId.includes("/")) return gateway(modelId);
|
|
71
|
+
if (!modelId.includes(":")) {
|
|
72
|
+
const provider = modelId;
|
|
73
|
+
if (provider in FRONTIER_MODELS) {
|
|
74
|
+
const defaultModel = FRONTIER_MODELS[provider][0];
|
|
75
|
+
return gateway(`${provider}/${defaultModel}`);
|
|
76
|
+
}
|
|
77
|
+
throw new Error(`Unknown provider: ${modelId}. Supported: ${Object.keys(FRONTIER_MODELS).join(", ")}`);
|
|
78
|
+
}
|
|
79
|
+
const colonIndex = modelId.indexOf(":");
|
|
80
|
+
const provider = modelId.slice(0, colonIndex);
|
|
81
|
+
const modelName = modelId.slice(colonIndex + 1);
|
|
82
|
+
if (!modelName) throw new Error(`Invalid model identifier: ${modelId}. Model name is required.`);
|
|
83
|
+
const providerConfigs = {
|
|
84
|
+
anthropic: {
|
|
85
|
+
package: "@ai-sdk/anthropic",
|
|
86
|
+
export: "anthropic"
|
|
87
|
+
},
|
|
88
|
+
openai: {
|
|
89
|
+
package: "@ai-sdk/openai",
|
|
90
|
+
export: "openai"
|
|
91
|
+
},
|
|
92
|
+
deepseek: {
|
|
93
|
+
package: "@ai-sdk/deepseek",
|
|
94
|
+
export: "deepseek"
|
|
95
|
+
},
|
|
96
|
+
google: {
|
|
97
|
+
package: "@ai-sdk/google",
|
|
98
|
+
export: "google"
|
|
99
|
+
},
|
|
100
|
+
groq: {
|
|
101
|
+
package: "@ai-sdk/groq",
|
|
102
|
+
export: "groq"
|
|
103
|
+
},
|
|
104
|
+
mistral: {
|
|
105
|
+
package: "@ai-sdk/mistral",
|
|
106
|
+
export: "mistral"
|
|
107
|
+
},
|
|
108
|
+
xai: {
|
|
109
|
+
package: "@ai-sdk/xai",
|
|
110
|
+
export: "xai"
|
|
111
|
+
},
|
|
112
|
+
minimax: {
|
|
113
|
+
package: "@ai-sdk/anthropic",
|
|
114
|
+
export: "anthropic",
|
|
115
|
+
options: {
|
|
116
|
+
baseURL: "https://api.minimax.chat/v1",
|
|
117
|
+
apiKeyEnvVar: "MINIMAX_API_KEY"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const config = providerConfigs[provider];
|
|
122
|
+
if (!config) throw new Error(`Unknown provider: ${provider}. Supported: ${Object.keys(providerConfigs).join(", ")}. Or use gateway format: provider/model (e.g., openai/gpt-5.2)`);
|
|
123
|
+
const providerFn = await loadProvider(provider, config.package, config.export, config.options);
|
|
124
|
+
if (!providerFn) throw new Error(`Install ${config.package} to use ${provider} models directly`);
|
|
125
|
+
return providerFn(modelName);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* List of supported providers for direct access
|
|
129
|
+
* Note: minimax uses Claude-compatible API via @ai-sdk/anthropic with custom baseURL
|
|
130
|
+
*/
|
|
131
|
+
const SUPPORTED_PROVIDERS = [
|
|
132
|
+
"anthropic",
|
|
133
|
+
"openai",
|
|
134
|
+
"deepseek",
|
|
135
|
+
"google",
|
|
136
|
+
"groq",
|
|
137
|
+
"mistral",
|
|
138
|
+
"xai",
|
|
139
|
+
"minimax"
|
|
140
|
+
];
|
|
141
|
+
/**
|
|
142
|
+
* Default provider when none specified
|
|
143
|
+
*/
|
|
144
|
+
const DEFAULT_PROVIDER = "anthropic";
|
|
145
|
+
/**
|
|
146
|
+
* Get the default model identifier (provider/model format)
|
|
147
|
+
* Uses the first model from the default provider
|
|
148
|
+
*/
|
|
149
|
+
function getDefaultModel() {
|
|
150
|
+
return `${DEFAULT_PROVIDER}/${FRONTIER_MODELS[DEFAULT_PROVIDER][0]}`;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Frontier models for each provider (as of 2026-02)
|
|
154
|
+
* Only includes the latest/best models, no legacy versions
|
|
155
|
+
*
|
|
156
|
+
* Note: Some models may be placeholders for testing or future releases.
|
|
157
|
+
* Always verify model availability with the provider before production use.
|
|
158
|
+
*/
|
|
159
|
+
const FRONTIER_MODELS = {
|
|
160
|
+
anthropic: [
|
|
161
|
+
"claude-sonnet-4-5",
|
|
162
|
+
"claude-haiku-4-5",
|
|
163
|
+
"claude-opus-4-5"
|
|
164
|
+
],
|
|
165
|
+
openai: ["gpt-5.2", "gpt-5.2-codex"],
|
|
166
|
+
google: [
|
|
167
|
+
"gemini-3-pro-preview",
|
|
168
|
+
"gemini-2.5-flash",
|
|
169
|
+
"gemini-2.5-pro"
|
|
170
|
+
],
|
|
171
|
+
deepseek: ["deepseek-chat", "deepseek-reasoner"],
|
|
172
|
+
groq: ["meta-llama/llama-4-scout-17b-16e-instruct", "deepseek-r1-distill-llama-70b"],
|
|
173
|
+
mistral: [
|
|
174
|
+
"mistral-large-latest",
|
|
175
|
+
"pixtral-large-latest",
|
|
176
|
+
"magistral-medium-2506"
|
|
177
|
+
],
|
|
178
|
+
xai: ["grok-4", "grok-4-fast-reasoning"],
|
|
179
|
+
minimax: ["MiniMax-M2"]
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
5
183
|
//#region src/backends/claude-cli.ts
|
|
6
184
|
/**
|
|
7
185
|
* Claude Code CLI backend
|
|
@@ -378,4 +556,4 @@ async function listBackends() {
|
|
|
378
556
|
}
|
|
379
557
|
|
|
380
558
|
//#endregion
|
|
381
|
-
export { CursorCliBackend as a, SdkBackend as i, createBackend as n, CodexCliBackend as o, listBackends as r, ClaudeCliBackend as s, checkBackends as t };
|
|
559
|
+
export { CursorCliBackend as a, FRONTIER_MODELS as c, createModelAsync as d, getDefaultModel as f, SdkBackend as i, SUPPORTED_PROVIDERS as l, createBackend as n, CodexCliBackend as o, listBackends as r, ClaudeCliBackend as s, checkBackends as t, createModel as u };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { a as CursorCliBackend, i as SdkBackend, n as createBackend, o as CodexCliBackend, r as listBackends, s as ClaudeCliBackend, t as checkBackends } from "./backends-BklSbwcH.mjs";
|
|
1
|
+
import { a as CursorCliBackend, i as SdkBackend, n as createBackend, o as CodexCliBackend, r as listBackends, s as ClaudeCliBackend, t as checkBackends } from "./backends-BGJk-onJ.mjs";
|
|
3
2
|
|
|
4
3
|
export { listBackends };
|