agent-worker 0.3.0 → 0.5.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 +335 -296
- package/dist/backends-B8rYTNqn.mjs +3 -0
- package/dist/backends-CEYiMUgC.mjs +1037 -0
- package/dist/cli/index.mjs +2085 -829
- package/dist/context-C7nBmU5D.mjs +4 -0
- package/dist/index.d.mts +279 -178
- package/dist/index.mjs +27 -36
- package/dist/mcp-server-DtIApaBD.mjs +549 -0
- package/dist/{skills-CVdxwuvV.mjs → skills-iya7NbH7.mjs} +263 -136
- package/dist/workflow-K1Zd655A.mjs +1792 -0
- package/package.json +10 -4
- package/dist/backends-BZ866Ij9.mjs +0 -564
- package/dist/backends-DXpJ7FJI.mjs +0 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# agent-worker
|
|
2
2
|
|
|
3
|
-
CLI and SDK for
|
|
3
|
+
CLI and SDK for running AI agents — from standalone instances to collaborative workflows.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -10,300 +10,385 @@ npm install -g agent-worker
|
|
|
10
10
|
bun add -g agent-worker
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Two Modes of Operation
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
agent-worker supports two distinct usage patterns:
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Create with system prompt
|
|
22
|
-
agent-worker session new -s "You are a code reviewer."
|
|
17
|
+
| Mode | Use Case | Entry Point | Coordination |
|
|
18
|
+
|------|----------|-------------|--------------|
|
|
19
|
+
| **Agent** | Single AI assistant | CLI commands | Direct interaction |
|
|
20
|
+
| **Workflow** | Multi-agent collaboration | YAML workflow file | @mention-based |
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
agent-worker session new -f ./prompts/reviewer.txt
|
|
22
|
+
---
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
agent-worker session new -n my-session
|
|
24
|
+
## 🤖 Agent Mode
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
agent-worker session new -b claude
|
|
26
|
+
**Run individual AI agents as standalone instances.**
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
agent-worker session list
|
|
28
|
+
Perfect for: testing, prototyping, interactive Q&A, code assistance.
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
agent-worker session use my-session
|
|
30
|
+
### Quick Start
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
```bash
|
|
33
|
+
# Start an agent
|
|
34
|
+
agent-worker new alice -m anthropic/claude-sonnet-4-5
|
|
41
35
|
|
|
42
|
-
#
|
|
43
|
-
agent-worker
|
|
36
|
+
# Send a message
|
|
37
|
+
agent-worker send alice "Analyze this codebase"
|
|
44
38
|
|
|
45
|
-
#
|
|
46
|
-
agent-worker
|
|
39
|
+
# View conversation
|
|
40
|
+
agent-worker peek
|
|
47
41
|
|
|
48
|
-
#
|
|
49
|
-
agent-worker
|
|
42
|
+
# Check status
|
|
43
|
+
agent-worker status alice
|
|
50
44
|
```
|
|
51
45
|
|
|
52
|
-
###
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# Send to current session (async by default - returns immediately)
|
|
56
|
-
agent-worker send "Analyze this codebase"
|
|
46
|
+
### Organizing Agents
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
agent-worker send "Explain recursion" --to my-session
|
|
48
|
+
Agents can be grouped into **workflows** by defining them in YAML:
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
```yaml
|
|
51
|
+
# review.yaml
|
|
52
|
+
agents:
|
|
53
|
+
reviewer:
|
|
54
|
+
backend: claude
|
|
55
|
+
system_prompt: You are a code reviewer.
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
agent-worker peek # Show last 10 messages (default)
|
|
69
|
-
agent-worker peek --last 5 # Show last 5 messages
|
|
70
|
-
agent-worker peek --all # Show all messages
|
|
71
|
-
agent-worker peek --find "error" # Search messages containing "error"
|
|
72
|
-
|
|
73
|
-
# View token usage
|
|
74
|
-
agent-worker stats
|
|
57
|
+
coder:
|
|
58
|
+
backend: cursor
|
|
59
|
+
system_prompt: You are a code implementer.
|
|
60
|
+
```
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
```bash
|
|
63
|
+
# Run workflow agents (workflow name from YAML)
|
|
64
|
+
agent-worker run review.yaml
|
|
78
65
|
|
|
79
|
-
#
|
|
80
|
-
agent-worker
|
|
66
|
+
# Send to specific agent in workflow
|
|
67
|
+
agent-worker send reviewer@review "Check this code"
|
|
81
68
|
```
|
|
82
69
|
|
|
83
|
-
**
|
|
70
|
+
**Note**: Agent Mode (`agent-worker new`) only creates standalone agents in the global workflow. For coordinated agents in named workflows, use Workflow Mode (YAML files).
|
|
84
71
|
|
|
85
|
-
|
|
72
|
+
### Multiple Instances (workflow:tag)
|
|
86
73
|
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# Send message (returns immediately)
|
|
90
|
-
agent-worker send "Analyze this large codebase"
|
|
91
|
-
# Output: "Message sent. Use 'peek' command to view response."
|
|
74
|
+
Run multiple isolated instances of the same workflow using **tags**:
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
76
|
+
```bash
|
|
77
|
+
# Different PRs, isolated contexts
|
|
78
|
+
agent-worker run review.yaml --tag pr-123
|
|
79
|
+
agent-worker run review.yaml --tag pr-456
|
|
96
80
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
```
|
|
81
|
+
# Each has its own conversation history
|
|
82
|
+
agent-worker send reviewer@review:pr-123 "LGTM"
|
|
83
|
+
agent-worker peek @review:pr-123 # Only sees pr-123 messages
|
|
84
|
+
```
|
|
102
85
|
|
|
103
|
-
**
|
|
86
|
+
**Target syntax** (used in send/peek/ls/stop commands):
|
|
87
|
+
- `alice` → alice@global:main (standalone agent)
|
|
88
|
+
- `alice@review` → alice@review:main (agent in review workflow)
|
|
89
|
+
- `alice@review:pr-123` → full specification
|
|
90
|
+
- `@review` → review workflow (for broadcast or listing)
|
|
91
|
+
- `@review:pr-123` → specific workflow instance
|
|
104
92
|
|
|
105
|
-
|
|
93
|
+
### Agent Commands
|
|
106
94
|
|
|
107
95
|
```bash
|
|
108
|
-
|
|
96
|
+
# Lifecycle
|
|
97
|
+
agent-worker new <name> [options] # Create standalone agent
|
|
98
|
+
agent-worker stop <target> # Stop agent
|
|
99
|
+
agent-worker ls [target] # List agents (default: global)
|
|
100
|
+
agent-worker ls --all # List all agents from all workflows
|
|
101
|
+
agent-worker status <target> # Check agent status
|
|
102
|
+
|
|
103
|
+
# Interaction
|
|
104
|
+
agent-worker send <target> <message> # Send to agent or workflow
|
|
105
|
+
agent-worker peek [target] [options] # View messages (default: @global)
|
|
106
|
+
|
|
107
|
+
# Scheduling (periodic wakeup when idle)
|
|
108
|
+
agent-worker schedule <target> set <interval> [--prompt "Task"]
|
|
109
|
+
agent-worker schedule <target> get
|
|
110
|
+
agent-worker schedule <target> clear
|
|
111
|
+
|
|
112
|
+
# Shared documents
|
|
113
|
+
agent-worker doc read <target>
|
|
114
|
+
agent-worker doc write <target> --content "..."
|
|
115
|
+
agent-worker doc append <target> --file notes.txt
|
|
116
|
+
|
|
117
|
+
# Testing & Debugging
|
|
118
|
+
agent-worker mock tool <name> <response> # Mock tool response
|
|
119
|
+
agent-worker feedback [target] # View agent feedback/observations
|
|
109
120
|
```
|
|
110
121
|
|
|
111
|
-
|
|
112
|
-
- Session lookup and connection status
|
|
113
|
-
- Socket communication
|
|
114
|
-
- Request/response timing
|
|
115
|
-
- Error details
|
|
116
|
-
|
|
117
|
-
**Backend Limitations:**
|
|
118
|
-
|
|
119
|
-
The CLI supports two backend types:
|
|
120
|
-
|
|
121
|
-
1. **SDK Backend (default)**: Full-featured, works in all environments. Requires `ANTHROPIC_API_KEY` environment variable.
|
|
122
|
-
|
|
123
|
-
2. **Claude CLI Backend (`-b claude`)**: Uses `claude -p` for non-interactive mode.
|
|
124
|
-
- **Known limitation**: May not work properly within Claude Code environment itself due to command interception
|
|
125
|
-
- **Timeout**: Async requests timeout after 60 seconds to prevent indefinite hangs
|
|
126
|
-
- **Recommended use**: Normal terminal environments outside Claude Code
|
|
127
|
-
- **For testing**: Use SDK backend instead when developing within Claude Code
|
|
128
|
-
|
|
129
|
-
If you see messages stuck in `(processing...)` state for more than 60 seconds, it indicates a backend issue. The message will automatically update to show a timeout error.
|
|
130
|
-
|
|
131
|
-
### Tool Management (SDK Backend Only)
|
|
122
|
+
### Backend Options
|
|
132
123
|
|
|
133
124
|
```bash
|
|
134
|
-
#
|
|
135
|
-
agent-worker
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
agent-worker new alice -m anthropic/claude-sonnet-4-5 # SDK (default)
|
|
126
|
+
agent-worker new alice -b claude # Claude CLI
|
|
127
|
+
agent-worker new alice -b cursor # Cursor Agent
|
|
128
|
+
agent-worker new alice -b mock # Testing (no API)
|
|
129
|
+
|
|
130
|
+
# Specify tools at creation (SDK backend only)
|
|
131
|
+
agent-worker new alice --tool ./custom-tools.ts
|
|
132
|
+
agent-worker new alice --skill ./skills --tool ./tools.ts
|
|
133
|
+
```
|
|
138
134
|
|
|
139
|
-
|
|
140
|
-
agent-worker tool add delete_file \
|
|
141
|
-
-d "Delete a file" \
|
|
142
|
-
-p "path:string:File path" \
|
|
143
|
-
--needs-approval
|
|
135
|
+
### Examples
|
|
144
136
|
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
**Quick testing without API keys:**
|
|
138
|
+
```bash
|
|
139
|
+
agent-worker new -b mock
|
|
140
|
+
agent-worker send a0 "Hello"
|
|
141
|
+
```
|
|
147
142
|
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
**Scheduled agent (runs every 30s when idle):**
|
|
144
|
+
```bash
|
|
145
|
+
# Standalone agent with wakeup schedule
|
|
146
|
+
agent-worker new monitor --wakeup 30s --prompt "Check CI status"
|
|
150
147
|
|
|
151
|
-
#
|
|
152
|
-
agent-worker
|
|
148
|
+
# Or schedule existing agent
|
|
149
|
+
agent-worker schedule monitor set 30s --prompt "Check CI status"
|
|
153
150
|
```
|
|
154
151
|
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
**Send to workflow (broadcast or @mention):**
|
|
157
153
|
```bash
|
|
158
|
-
#
|
|
159
|
-
agent-worker
|
|
154
|
+
# Broadcast to entire workflow
|
|
155
|
+
agent-worker send @review "Status update"
|
|
160
156
|
|
|
161
|
-
#
|
|
162
|
-
agent-worker
|
|
157
|
+
# @mention specific agents in workflow
|
|
158
|
+
agent-worker send @review "@alice @bob discuss this"
|
|
159
|
+
```
|
|
163
160
|
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
**Feedback-enabled agent (reports observations):**
|
|
162
|
+
```bash
|
|
163
|
+
agent-worker new -m anthropic/claude-sonnet-4-5 --feedback
|
|
166
164
|
```
|
|
167
165
|
|
|
168
|
-
|
|
166
|
+
---
|
|
169
167
|
|
|
170
|
-
|
|
168
|
+
## 📋 Workflow Mode
|
|
171
169
|
|
|
172
|
-
|
|
173
|
-
# Load skills from default directories (.agents/skills, .claude/skills, ~/.agents/skills)
|
|
174
|
-
agent-worker session new
|
|
170
|
+
**Define multi-agent collaboration through YAML workflows.**
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
agent-worker session new --skill ./my-skills/custom-skill
|
|
172
|
+
Perfect for: structured tasks, agent orchestration, reproducible pipelines.
|
|
178
173
|
|
|
179
|
-
|
|
180
|
-
agent-worker session new --skill-dir ./team-skills --skill-dir ~/shared-skills
|
|
174
|
+
### Quick Start
|
|
181
175
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
```yaml
|
|
177
|
+
# review.yaml
|
|
178
|
+
agents:
|
|
179
|
+
reviewer:
|
|
180
|
+
backend: claude
|
|
181
|
+
system_prompt: You are a code reviewer. Provide constructive feedback.
|
|
186
182
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
coder:
|
|
184
|
+
backend: cursor
|
|
185
|
+
model: sonnet-4.5
|
|
186
|
+
system_prompt: You implement code changes based on feedback.
|
|
187
|
+
|
|
188
|
+
kickoff: |
|
|
189
|
+
@reviewer Review the recent changes and provide feedback.
|
|
190
|
+
@coder Implement the suggested improvements.
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
```bash
|
|
194
|
+
# Run once and exit
|
|
195
|
+
agent-worker run review.yaml
|
|
194
196
|
|
|
195
|
-
|
|
197
|
+
# Run and keep agents alive
|
|
198
|
+
agent-worker start review.yaml
|
|
196
199
|
|
|
200
|
+
# Run in background
|
|
201
|
+
agent-worker start review.yaml --background
|
|
197
202
|
```
|
|
198
|
-
[provider:]owner/repo[@ref]:{skill1,skill2,...}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
Examples:
|
|
202
|
-
- `vercel-labs/agent-skills` - Import all skills from GitHub main branch
|
|
203
|
-
- `vercel-labs/agent-skills:dive` - Import single skill
|
|
204
|
-
- `vercel-labs/agent-skills:{dive,memory}` - Import multiple skills (brace expansion)
|
|
205
|
-
- `vercel-labs/agent-skills@v1.0.0:dive` - Import from specific tag/branch
|
|
206
|
-
- `gitlab:myorg/skills:custom` - Import from GitLab
|
|
207
|
-
- `gitee:org/repo@dev:{a,b}` - Import from Gitee dev branch
|
|
208
203
|
|
|
209
|
-
|
|
204
|
+
### Workflow Instances (Tags)
|
|
210
205
|
|
|
211
|
-
|
|
206
|
+
Run the same workflow definition with different contexts:
|
|
212
207
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
208
|
+
```bash
|
|
209
|
+
# Each PR gets its own isolated instance (workflow name from YAML)
|
|
210
|
+
agent-worker run review.yaml --tag pr-123
|
|
211
|
+
agent-worker run review.yaml --tag pr-456
|
|
212
|
+
|
|
213
|
+
# Context isolation
|
|
214
|
+
├── .workflow/
|
|
215
|
+
│ └── review/
|
|
216
|
+
│ ├── pr-123/ # Independent channel + documents
|
|
217
|
+
│ └── pr-456/ # Independent channel + documents
|
|
218
|
+
```
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
### Workflow Structure
|
|
221
|
+
|
|
222
|
+
```yaml
|
|
223
|
+
# Full workflow structure
|
|
224
|
+
name: code-review # Optional, defaults to filename
|
|
225
|
+
|
|
226
|
+
agents:
|
|
227
|
+
alice:
|
|
228
|
+
backend: sdk | claude | cursor | codex | mock
|
|
229
|
+
model: anthropic/claude-sonnet-4-5 # Required for SDK
|
|
230
|
+
system_prompt: |
|
|
231
|
+
You are Alice, a senior code reviewer.
|
|
232
|
+
tools: [bash, read, write] # CLI backend tool names
|
|
233
|
+
max_tokens: 8000
|
|
234
|
+
max_steps: 20
|
|
235
|
+
|
|
236
|
+
bob:
|
|
237
|
+
backend: claude
|
|
238
|
+
system_prompt_file: ./prompts/bob.txt # Load from file
|
|
239
|
+
|
|
240
|
+
# Context configuration (shared channel + documents)
|
|
241
|
+
context:
|
|
242
|
+
provider: file
|
|
243
|
+
config:
|
|
244
|
+
dir: ./.workflow/${{ workflow.name }}/${{ workflow.tag }}/ # Ephemeral
|
|
245
|
+
# OR
|
|
246
|
+
bind: ./data/${{ workflow.tag }}/ # Persistent (survives shutdown)
|
|
247
|
+
|
|
248
|
+
# Setup commands (run before kickoff)
|
|
249
|
+
setup:
|
|
250
|
+
- shell: git log --oneline -10
|
|
251
|
+
as: recent_commits # Store output as variable
|
|
252
|
+
|
|
253
|
+
- shell: git diff main...HEAD
|
|
254
|
+
as: changes
|
|
255
|
+
|
|
256
|
+
# Kickoff message (starts the workflow)
|
|
257
|
+
kickoff: |
|
|
258
|
+
@alice Review these changes:
|
|
259
|
+
|
|
260
|
+
Recent commits:
|
|
261
|
+
${{ recent_commits }}
|
|
262
|
+
|
|
263
|
+
Diff:
|
|
264
|
+
${{ changes }}
|
|
265
|
+
|
|
266
|
+
@bob Stand by for implementation tasks.
|
|
267
|
+
```
|
|
224
268
|
|
|
225
|
-
|
|
226
|
-
- `.agents/skills/` - Project-level skills (all backends)
|
|
227
|
-
- `.claude/skills/` - Claude Code project skills
|
|
228
|
-
- `.cursor/skills/` - Cursor project skills
|
|
229
|
-
- `~/.agents/skills/` - User-level global skills (all backends)
|
|
230
|
-
- `~/.claude/skills/` - User-level Claude skills
|
|
231
|
-
- `~/.codex/skills/` - User-level Codex skills
|
|
269
|
+
### Workflow Commands
|
|
232
270
|
|
|
233
|
-
|
|
271
|
+
```bash
|
|
272
|
+
# Execution (workflow name inferred from YAML)
|
|
273
|
+
agent-worker run <file> [--tag tag] [--json] # Run once
|
|
274
|
+
agent-worker start <file> [--tag tag] # Keep alive
|
|
275
|
+
agent-worker start <file> --background # Daemon mode
|
|
276
|
+
agent-worker stop @<workflow:tag> # Stop workflow
|
|
277
|
+
|
|
278
|
+
# Monitoring
|
|
279
|
+
agent-worker ls @<workflow:tag> # List agents in workflow
|
|
280
|
+
agent-worker peek @<workflow:tag> # View channel messages
|
|
281
|
+
agent-worker doc read @<workflow:tag> # Read shared document
|
|
282
|
+
|
|
283
|
+
# Debug
|
|
284
|
+
agent-worker run <file> --debug # Show internal logs
|
|
285
|
+
agent-worker run <file> --feedback # Enable observation tool
|
|
286
|
+
```
|
|
234
287
|
|
|
235
|
-
|
|
288
|
+
### Variable Interpolation
|
|
236
289
|
|
|
237
|
-
|
|
238
|
-
// List available skills
|
|
239
|
-
Skills({ operation: 'list' })
|
|
290
|
+
Templates support `${{ variable }}` syntax:
|
|
240
291
|
|
|
241
|
-
|
|
242
|
-
|
|
292
|
+
```yaml
|
|
293
|
+
setup:
|
|
294
|
+
- shell: echo "pr-${{ env.PR_NUMBER }}"
|
|
295
|
+
as: branch_name
|
|
243
296
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
filePath: 'references/search-strategies.md'
|
|
249
|
-
})
|
|
297
|
+
kickoff: |
|
|
298
|
+
Workflow: ${{ workflow.name }}
|
|
299
|
+
Tag: ${{ workflow.tag }}
|
|
300
|
+
Branch: ${{ branch_name }}
|
|
250
301
|
```
|
|
251
302
|
|
|
252
|
-
|
|
303
|
+
Available variables:
|
|
304
|
+
- `${{ workflow.name }}` - Workflow name
|
|
305
|
+
- `${{ workflow.tag }}` - Instance tag
|
|
306
|
+
- `${{ env.VAR }}` - Environment variable
|
|
307
|
+
- `${{ task_output }}` - Setup task output (via `as:` field)
|
|
253
308
|
|
|
254
|
-
|
|
309
|
+
### Coordination Patterns
|
|
255
310
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
311
|
+
**Sequential handoff:**
|
|
312
|
+
```yaml
|
|
313
|
+
kickoff: |
|
|
314
|
+
@alice Start the task.
|
|
315
|
+
```
|
|
316
|
+
Alice's message: "Done! @bob your turn"
|
|
259
317
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
318
|
+
**Parallel broadcast:**
|
|
319
|
+
```yaml
|
|
320
|
+
kickoff: |
|
|
321
|
+
@alice @bob @charlie All review this code.
|
|
263
322
|
```
|
|
264
323
|
|
|
265
|
-
|
|
324
|
+
**Document-based:**
|
|
325
|
+
```yaml
|
|
326
|
+
agents:
|
|
327
|
+
writer:
|
|
328
|
+
system_prompt: Write analysis to the shared document.
|
|
266
329
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
agent-worker backends
|
|
330
|
+
reviewer:
|
|
331
|
+
system_prompt: Read the document and provide feedback.
|
|
270
332
|
|
|
271
|
-
|
|
272
|
-
|
|
333
|
+
context:
|
|
334
|
+
provider: file
|
|
335
|
+
config:
|
|
336
|
+
bind: ./results/ # Persistent across runs
|
|
273
337
|
```
|
|
274
338
|
|
|
275
|
-
|
|
276
|
-
|---------|---------|----------|
|
|
277
|
-
| SDK (default) | `session new -m provider/model` | Full control, tool injection, mocking |
|
|
278
|
-
| Claude CLI | `session new -b claude` | Use existing Claude installation |
|
|
279
|
-
| Codex | `session new -b codex` | OpenAI Codex workflows |
|
|
280
|
-
| Cursor | `session new -b cursor` | Cursor Agent integration |
|
|
339
|
+
### Examples
|
|
281
340
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
341
|
+
**PR Review Workflow:**
|
|
342
|
+
```yaml
|
|
343
|
+
# review.yaml
|
|
344
|
+
agents:
|
|
345
|
+
reviewer:
|
|
346
|
+
backend: claude
|
|
347
|
+
system_prompt: Review code for bugs, style, performance.
|
|
288
348
|
|
|
289
|
-
|
|
349
|
+
setup:
|
|
350
|
+
- shell: gh pr diff ${{ env.PR_NUMBER }}
|
|
351
|
+
as: diff
|
|
290
352
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
agent-worker session new -m anthropic/claude-sonnet-4-5
|
|
294
|
-
agent-worker session new -m openai/gpt-5.2
|
|
353
|
+
kickoff: |
|
|
354
|
+
@reviewer Review this PR:
|
|
295
355
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
agent-worker session new -m openai
|
|
356
|
+
${{ diff }}
|
|
357
|
+
```
|
|
299
358
|
|
|
300
|
-
|
|
301
|
-
agent-worker
|
|
359
|
+
```bash
|
|
360
|
+
PR_NUMBER=123 agent-worker run review.yaml --tag pr-123
|
|
302
361
|
```
|
|
303
362
|
|
|
304
|
-
|
|
363
|
+
**Research & Summarize:**
|
|
364
|
+
```yaml
|
|
365
|
+
# research.yaml
|
|
366
|
+
agents:
|
|
367
|
+
researcher:
|
|
368
|
+
backend: sdk
|
|
369
|
+
model: anthropic/claude-sonnet-4-5
|
|
370
|
+
system_prompt: Research topics and write findings to document.
|
|
371
|
+
|
|
372
|
+
summarizer:
|
|
373
|
+
backend: sdk
|
|
374
|
+
model: anthropic/claude-haiku-4-5
|
|
375
|
+
system_prompt: Read document and create concise summary.
|
|
376
|
+
|
|
377
|
+
context:
|
|
378
|
+
provider: file
|
|
379
|
+
config:
|
|
380
|
+
bind: ./research-output/
|
|
381
|
+
|
|
382
|
+
kickoff: |
|
|
383
|
+
@researcher Research "${{ env.TOPIC }}" and document findings.
|
|
384
|
+
@summarizer Wait for research to complete, then summarize.
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
---
|
|
305
388
|
|
|
306
|
-
|
|
389
|
+
## 🔧 SDK Usage
|
|
390
|
+
|
|
391
|
+
For programmatic control (TypeScript/JavaScript):
|
|
307
392
|
|
|
308
393
|
```typescript
|
|
309
394
|
import { AgentSession } from 'agent-worker'
|
|
@@ -325,123 +410,77 @@ for await (const chunk of session.sendStream('Tell me a story')) {
|
|
|
325
410
|
process.stdout.write(chunk)
|
|
326
411
|
}
|
|
327
412
|
|
|
328
|
-
//
|
|
413
|
+
// State management
|
|
329
414
|
const state = session.getState()
|
|
415
|
+
// Later: restore from state
|
|
330
416
|
```
|
|
331
417
|
|
|
332
418
|
### With Skills
|
|
333
419
|
|
|
334
420
|
```typescript
|
|
335
|
-
import {
|
|
336
|
-
AgentSession,
|
|
337
|
-
SkillsProvider,
|
|
338
|
-
createSkillsTool
|
|
339
|
-
} from 'agent-worker'
|
|
421
|
+
import { AgentSession, SkillsProvider, createSkillsTool } from 'agent-worker'
|
|
340
422
|
|
|
341
|
-
// Setup skills
|
|
342
423
|
const skillsProvider = new SkillsProvider()
|
|
343
424
|
await skillsProvider.scanDirectory('.agents/skills')
|
|
344
|
-
await skillsProvider.scanDirectory('~/my-skills')
|
|
345
|
-
|
|
346
|
-
// Or add individual skills
|
|
347
|
-
await skillsProvider.addSkill('./custom-skills/my-skill')
|
|
348
425
|
|
|
349
|
-
// Create session with Skills tool
|
|
350
426
|
const session = new AgentSession({
|
|
351
427
|
model: 'anthropic/claude-sonnet-4-5',
|
|
352
428
|
system: 'You are a helpful assistant.',
|
|
353
|
-
tools: [
|
|
354
|
-
createSkillsTool(skillsProvider),
|
|
355
|
-
// ... other tools
|
|
356
|
-
]
|
|
429
|
+
tools: [createSkillsTool(skillsProvider)]
|
|
357
430
|
})
|
|
358
|
-
|
|
359
|
-
// Agent can now access skills
|
|
360
|
-
const response = await session.send(
|
|
361
|
-
'What skills are available? Use the dive skill to analyze this codebase.'
|
|
362
|
-
)
|
|
363
431
|
```
|
|
364
432
|
|
|
365
|
-
|
|
433
|
+
---
|
|
366
434
|
|
|
367
|
-
|
|
368
|
-
import {
|
|
369
|
-
AgentSession,
|
|
370
|
-
SkillsProvider,
|
|
371
|
-
SkillImporter,
|
|
372
|
-
createSkillsTool
|
|
373
|
-
} from 'agent-worker'
|
|
374
|
-
|
|
375
|
-
// Setup skills provider
|
|
376
|
-
const skillsProvider = new SkillsProvider()
|
|
435
|
+
## 📊 Comparison: Agent vs Workflow
|
|
377
436
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
437
|
+
| Feature | Agent Mode | Workflow Mode |
|
|
438
|
+
|---------|------------|---------------|
|
|
439
|
+
| **Definition** | CLI commands | YAML file |
|
|
440
|
+
| **Agents** | One at a time | Multiple (orchestrated) |
|
|
441
|
+
| **Coordination** | Manual (via commands) | Automatic (@mentions) |
|
|
442
|
+
| **Context** | Shared channel + docs | Shared channel + docs |
|
|
443
|
+
| **Isolation** | workflow:tag namespace | workflow:tag namespace |
|
|
444
|
+
| **Setup** | Start agents manually | Declarative setup tasks |
|
|
445
|
+
| **Best For** | Interactive tasks, testing | Structured workflows, automation |
|
|
381
446
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
'vercel-labs/agent-skills:{dive,react}',
|
|
389
|
-
'gitlab:myorg/skills@v1.0.0:custom'
|
|
390
|
-
])
|
|
391
|
-
|
|
392
|
-
// Add imported skills to provider
|
|
393
|
-
await skillsProvider.addImportedSkills(importer)
|
|
394
|
-
|
|
395
|
-
// Create session
|
|
396
|
-
const session = new AgentSession({
|
|
397
|
-
model: 'anthropic/claude-sonnet-4-5',
|
|
398
|
-
system: 'You are a helpful assistant.',
|
|
399
|
-
tools: [createSkillsTool(skillsProvider)]
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
// Don't forget cleanup when done
|
|
403
|
-
process.on('exit', async () => {
|
|
404
|
-
await importer.cleanup()
|
|
405
|
-
})
|
|
447
|
+
Both modes share the same underlying context system:
|
|
448
|
+
```
|
|
449
|
+
.workflow/
|
|
450
|
+
├── global/main/ # Standalone agents (default)
|
|
451
|
+
├── review/main/ # review workflow, main tag
|
|
452
|
+
└── review/pr-123/ # review workflow, pr-123 tag
|
|
406
453
|
```
|
|
407
454
|
|
|
408
|
-
|
|
455
|
+
---
|
|
409
456
|
|
|
410
|
-
|
|
457
|
+
## 🎯 Model Formats
|
|
411
458
|
|
|
412
459
|
```bash
|
|
413
|
-
agent-worker
|
|
414
|
-
agent-worker
|
|
415
|
-
agent-worker
|
|
416
|
-
agent-worker peek --to test
|
|
417
|
-
agent-worker session end test
|
|
460
|
+
agent-worker new -m anthropic/claude-sonnet-4-5 # Gateway (recommended)
|
|
461
|
+
agent-worker new -m anthropic # Provider-only (frontier)
|
|
462
|
+
agent-worker new -m deepseek:deepseek-chat # Direct format
|
|
418
463
|
```
|
|
419
464
|
|
|
420
|
-
|
|
465
|
+
---
|
|
421
466
|
|
|
422
|
-
|
|
423
|
-
agent-worker session new -n dev
|
|
424
|
-
agent-worker tool add my_api -d "Call my API" -p "endpoint:string"
|
|
425
|
-
agent-worker tool mock my_api '{"status": "ok"}'
|
|
426
|
-
agent-worker send "Call my API at /users"
|
|
427
|
-
# Update mock, test error handling
|
|
428
|
-
agent-worker tool mock my_api '{"status": "error", "code": 500}'
|
|
429
|
-
agent-worker send "Call my API at /users"
|
|
430
|
-
```
|
|
467
|
+
## 📚 Documentation
|
|
431
468
|
|
|
432
|
-
|
|
469
|
+
| Doc | Description |
|
|
470
|
+
|-----|-------------|
|
|
471
|
+
| [ARCHITECTURE.md](./ARCHITECTURE.md) | System architecture and modules |
|
|
472
|
+
| [docs/backends.md](./docs/backends.md) | Backend feature matrix |
|
|
473
|
+
| [docs/workflow/](./docs/workflow/) | Workflow system design |
|
|
474
|
+
| [TEST-ARCHITECTURE.md](./TEST-ARCHITECTURE.md) | Testing strategy |
|
|
433
475
|
|
|
434
|
-
|
|
435
|
-
agent-worker session new -m anthropic/claude-sonnet-4-5 -n claude
|
|
436
|
-
agent-worker session new -m openai/gpt-5.2 -n gpt
|
|
437
|
-
agent-worker send "Explain recursion" --to claude
|
|
438
|
-
agent-worker send "Explain recursion" --to gpt
|
|
439
|
-
```
|
|
476
|
+
---
|
|
440
477
|
|
|
441
478
|
## Requirements
|
|
442
479
|
|
|
443
480
|
- Node.js 18+ or Bun
|
|
444
|
-
- API key for chosen provider (e.g., `ANTHROPIC_API_KEY
|
|
481
|
+
- API key for chosen provider (e.g., `ANTHROPIC_API_KEY`)
|
|
482
|
+
|
|
483
|
+
---
|
|
445
484
|
|
|
446
485
|
## License
|
|
447
486
|
|