computer-agents 1.0.1 → 1.0.3
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 +399 -170
- package/dist/index.d.ts +5 -28
- package/dist/index.js +194 -51
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +8 -0
- package/dist/metadata.js +13 -0
- package/dist/metadata.js.map +1 -0
- package/package.json +25 -23
- package/dist/ComputerAgentsClient.d.ts +0 -357
- package/dist/ComputerAgentsClient.js +0 -359
- package/dist/ComputerAgentsClient.js.map +0 -1
- package/dist/cloud/ApiClient.d.ts +0 -62
- package/dist/cloud/ApiClient.js +0 -150
- package/dist/cloud/ApiClient.js.map +0 -1
- package/dist/cloud/resources/AgentsResource.d.ts +0 -39
- package/dist/cloud/resources/AgentsResource.js +0 -58
- package/dist/cloud/resources/AgentsResource.js.map +0 -1
- package/dist/cloud/resources/BudgetResource.d.ts +0 -167
- package/dist/cloud/resources/BudgetResource.js +0 -179
- package/dist/cloud/resources/BudgetResource.js.map +0 -1
- package/dist/cloud/resources/EnvironmentsResource.d.ts +0 -78
- package/dist/cloud/resources/EnvironmentsResource.js +0 -118
- package/dist/cloud/resources/EnvironmentsResource.js.map +0 -1
- package/dist/cloud/resources/FilesResource.d.ts +0 -177
- package/dist/cloud/resources/FilesResource.js +0 -180
- package/dist/cloud/resources/FilesResource.js.map +0 -1
- package/dist/cloud/resources/GitResource.d.ts +0 -28
- package/dist/cloud/resources/GitResource.js +0 -45
- package/dist/cloud/resources/GitResource.js.map +0 -1
- package/dist/cloud/resources/ProjectsResource.d.ts +0 -78
- package/dist/cloud/resources/ProjectsResource.js +0 -117
- package/dist/cloud/resources/ProjectsResource.js.map +0 -1
- package/dist/cloud/resources/RunsResource.d.ts +0 -61
- package/dist/cloud/resources/RunsResource.js +0 -84
- package/dist/cloud/resources/RunsResource.js.map +0 -1
- package/dist/cloud/resources/SchedulesResource.d.ts +0 -58
- package/dist/cloud/resources/SchedulesResource.js +0 -82
- package/dist/cloud/resources/SchedulesResource.js.map +0 -1
- package/dist/cloud/resources/ThreadsResource.d.ts +0 -124
- package/dist/cloud/resources/ThreadsResource.js +0 -178
- package/dist/cloud/resources/ThreadsResource.js.map +0 -1
- package/dist/cloud/resources/index.d.ts +0 -16
- package/dist/cloud/resources/index.js +0 -28
- package/dist/cloud/resources/index.js.map +0 -1
- package/dist/cloud/types.d.ts +0 -573
- package/dist/cloud/types.js +0 -9
- package/dist/cloud/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,282 +1,511 @@
|
|
|
1
1
|
# Computer Agents SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/computer-agents)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
Build agents that write code, run tests, and modify files. Orchestrate unlimited agents in parallel with seamless local and cloud execution.
|
|
7
|
+
|
|
8
|
+
## Why Computer Agents?
|
|
9
|
+
|
|
10
|
+
Traditional agent frameworks limit you to single-agent workflows or rigid orchestration patterns. Computer Agents is designed for programmatic multi-agent orchestration at scale.
|
|
11
|
+
|
|
12
|
+
**Unlimited Parallel Orchestration**
|
|
13
|
+
Compose and run unlimited agents concurrently. Build custom multi-agent workflows programmatically—you control execution flow and agent communication. No framework constraints, just code.
|
|
14
|
+
|
|
15
|
+
**Seamless Local ↔ Cloud Execution**
|
|
16
|
+
Develop locally, scale to cloud by changing workspace configuration. Runtime abstraction handles the complexity while your code remains identical. Switch execution environments without rewriting workflows.
|
|
17
|
+
|
|
18
|
+
**Two Powerful Agent Types**
|
|
19
|
+
- **LLM agents** (OpenAI API) for planning, reasoning, and code review
|
|
20
|
+
- **Computer agents** (Codex SDK) for code generation and file operations
|
|
21
|
+
|
|
22
|
+
Mix agent types to build sophisticated workflows. Computer agents bypass LLM for tool selection, providing faster execution and lower costs.
|
|
23
|
+
|
|
24
|
+
**Production-Ready Infrastructure**
|
|
25
|
+
- Automatic session continuity across runs
|
|
26
|
+
- Efficient workspace synchronization
|
|
27
|
+
- Built on OpenAI Codex SDK
|
|
28
|
+
- Type-safe TypeScript with comprehensive documentation
|
|
29
|
+
|
|
30
|
+
**Use cases:** Parallel test generation, distributed code review, large-scale refactoring, automated debugging workflows, multi-repository updates.
|
|
4
31
|
|
|
5
32
|
## Installation
|
|
6
33
|
|
|
7
34
|
```bash
|
|
8
35
|
npm install computer-agents
|
|
9
|
-
# or
|
|
10
|
-
pnpm add computer-agents
|
|
11
|
-
# or
|
|
12
|
-
yarn add computer-agents
|
|
13
36
|
```
|
|
14
37
|
|
|
15
38
|
## Quick Start
|
|
16
39
|
|
|
40
|
+
### Local Computer Agent
|
|
41
|
+
|
|
17
42
|
```typescript
|
|
18
|
-
import {
|
|
43
|
+
import { Agent, run } from 'computer-agents';
|
|
19
44
|
|
|
20
|
-
const
|
|
21
|
-
|
|
45
|
+
const agent = new Agent({
|
|
46
|
+
agentType: "computer",
|
|
47
|
+
workspace: "./my-project",
|
|
48
|
+
instructions: "You are an expert developer."
|
|
22
49
|
});
|
|
23
50
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
const result = await run(agent, "Create a Python script that calculates fibonacci numbers");
|
|
52
|
+
console.log(result.finalOutput);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### LLM Agent
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Agent, run } from 'computer-agents';
|
|
59
|
+
|
|
60
|
+
const agent = new Agent({
|
|
61
|
+
agentType: "llm",
|
|
62
|
+
model: "gpt-4o",
|
|
63
|
+
instructions: "You create detailed implementation plans."
|
|
28
64
|
});
|
|
29
65
|
|
|
30
|
-
|
|
66
|
+
const result = await run(agent, "Plan how to add user authentication");
|
|
67
|
+
console.log(result.finalOutput);
|
|
31
68
|
```
|
|
32
69
|
|
|
33
|
-
##
|
|
70
|
+
## Agent Types
|
|
34
71
|
|
|
35
|
-
|
|
36
|
-
- SSE streaming for real-time execution progress
|
|
37
|
-
- Simple, intuitive API that mirrors the REST API structure
|
|
38
|
-
- Zero dependencies - uses native `fetch`
|
|
72
|
+
The SDK supports two agent types:
|
|
39
73
|
|
|
40
|
-
|
|
74
|
+
| Type | Execution | Use Cases |
|
|
75
|
+
|------|-----------|-----------|
|
|
76
|
+
| `computer` | Codex SDK | Code generation, file operations, terminal commands |
|
|
77
|
+
| `llm` | OpenAI API | Planning, reasoning, text generation |
|
|
78
|
+
|
|
79
|
+
### Computer Agents
|
|
41
80
|
|
|
42
|
-
|
|
81
|
+
Computer agents execute code changes using the Codex SDK. They can create files, run commands, and modify codebases.
|
|
43
82
|
|
|
44
83
|
```typescript
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
debug: false // Optional
|
|
84
|
+
const agent = new Agent({
|
|
85
|
+
agentType: "computer",
|
|
86
|
+
workspace: "./my-project",
|
|
87
|
+
instructions: "You are a Python developer."
|
|
50
88
|
});
|
|
89
|
+
|
|
90
|
+
await run(agent, "Add unit tests for the fibonacci module");
|
|
51
91
|
```
|
|
52
92
|
|
|
53
|
-
###
|
|
93
|
+
### LLM Agents
|
|
54
94
|
|
|
55
|
-
|
|
95
|
+
LLM agents use the OpenAI API for text generation and reasoning tasks.
|
|
56
96
|
|
|
57
97
|
```typescript
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
98
|
+
const agent = new Agent({
|
|
99
|
+
agentType: "llm",
|
|
100
|
+
model: "gpt-4o",
|
|
101
|
+
instructions: "You review code for quality and security."
|
|
61
102
|
});
|
|
62
103
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
await run(agent, "Review the authentication implementation");
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Multi-Agent Workflows
|
|
108
|
+
|
|
109
|
+
Compose multiple agents for complex tasks:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { Agent, run } from 'computer-agents';
|
|
113
|
+
|
|
114
|
+
// LLM creates plan
|
|
115
|
+
const planner = new Agent({
|
|
116
|
+
agentType: 'llm',
|
|
117
|
+
model: 'gpt-4o',
|
|
118
|
+
instructions: 'Create implementation plans.'
|
|
71
119
|
});
|
|
72
120
|
|
|
73
|
-
//
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
121
|
+
// Computer agent executes
|
|
122
|
+
const executor = new Agent({
|
|
123
|
+
agentType: 'computer',
|
|
124
|
+
workspace: './my-project',
|
|
125
|
+
instructions: 'Execute implementation plans.'
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// LLM reviews result
|
|
129
|
+
const reviewer = new Agent({
|
|
130
|
+
agentType: 'llm',
|
|
131
|
+
model: 'gpt-4o',
|
|
132
|
+
instructions: 'Review code quality.'
|
|
77
133
|
});
|
|
134
|
+
|
|
135
|
+
const task = "Add user authentication";
|
|
136
|
+
const plan = await run(planner, `Plan: ${task}`);
|
|
137
|
+
const code = await run(executor, plan.finalOutput);
|
|
138
|
+
const review = await run(reviewer, `Review: ${code.finalOutput}`);
|
|
78
139
|
```
|
|
79
140
|
|
|
80
|
-
|
|
141
|
+
## Streaming Events
|
|
81
142
|
|
|
82
|
-
|
|
143
|
+
Monitor agent execution in real-time:
|
|
83
144
|
|
|
84
145
|
```typescript
|
|
85
|
-
|
|
86
|
-
const thread = await client.threads.create({
|
|
87
|
-
environmentId: 'env_xxx'
|
|
88
|
-
});
|
|
146
|
+
import { Agent, runStreamed } from 'computer-agents';
|
|
89
147
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
onEvent: (event) => console.log(event)
|
|
148
|
+
const agent = new Agent({
|
|
149
|
+
agentType: "computer",
|
|
150
|
+
workspace: "./my-project"
|
|
94
151
|
});
|
|
95
152
|
|
|
96
|
-
|
|
97
|
-
|
|
153
|
+
for await (const event of runStreamed(agent, 'Create a web scraper')) {
|
|
154
|
+
switch (event.type) {
|
|
155
|
+
case 'thread.started':
|
|
156
|
+
console.log(`Thread: ${event.thread_id}`);
|
|
157
|
+
break;
|
|
158
|
+
case 'item.completed':
|
|
159
|
+
if (event.item.type === 'file_change') {
|
|
160
|
+
const files = event.item.changes.map(c => `${c.kind} ${c.path}`).join(', ');
|
|
161
|
+
console.log(`Files: ${files}`);
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case 'turn.completed':
|
|
165
|
+
console.log(`Completed (${event.usage.input_tokens + event.usage.output_tokens} tokens)`);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
98
170
|
|
|
99
|
-
|
|
100
|
-
const thread = await client.threads.get('thread_xxx');
|
|
171
|
+
## Task Control
|
|
101
172
|
|
|
102
|
-
|
|
103
|
-
await client.threads.delete('thread_xxx');
|
|
104
|
-
```
|
|
173
|
+
Control running agents with pause, resume, abort, and messaging capabilities:
|
|
105
174
|
|
|
106
|
-
###
|
|
175
|
+
### Local Control
|
|
107
176
|
|
|
108
|
-
|
|
177
|
+
Control agents running in the same process:
|
|
109
178
|
|
|
110
179
|
```typescript
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
180
|
+
import { Agent, run } from 'computer-agents';
|
|
181
|
+
|
|
182
|
+
const agent = new Agent({
|
|
183
|
+
agentType: 'computer',
|
|
184
|
+
workspace: './my-project'
|
|
115
185
|
});
|
|
116
186
|
|
|
117
|
-
//
|
|
118
|
-
const
|
|
187
|
+
// Start a long-running task
|
|
188
|
+
const taskPromise = run(agent, 'Analyze all TypeScript files');
|
|
119
189
|
|
|
120
|
-
//
|
|
121
|
-
|
|
190
|
+
// Pause after 5 seconds
|
|
191
|
+
setTimeout(async () => {
|
|
192
|
+
await agent.pause();
|
|
193
|
+
console.log('Agent paused');
|
|
122
194
|
|
|
123
|
-
//
|
|
124
|
-
await
|
|
125
|
-
|
|
126
|
-
});
|
|
195
|
+
// Resume later
|
|
196
|
+
await agent.resume();
|
|
197
|
+
await run(agent, 'Continue analysis');
|
|
198
|
+
}, 5000);
|
|
199
|
+
|
|
200
|
+
// Check status
|
|
201
|
+
const status = agent.getStatus();
|
|
202
|
+
console.log(status);
|
|
203
|
+
// { status: 'running', threadId: 'thread-123', queuedMessages: 0 }
|
|
127
204
|
|
|
128
|
-
//
|
|
129
|
-
await
|
|
205
|
+
// Send messages
|
|
206
|
+
await agent.sendMessage('Focus on performance issues');
|
|
207
|
+
|
|
208
|
+
// Abort permanently
|
|
209
|
+
await agent.abort();
|
|
130
210
|
```
|
|
131
211
|
|
|
132
|
-
###
|
|
212
|
+
### Cloud Control API
|
|
213
|
+
|
|
214
|
+
Control cloud agents remotely via HTTP endpoints:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Get execution status
|
|
218
|
+
curl -X GET https://api.testbase.ai/control/status/thread-abc-123 \
|
|
219
|
+
-H "X-API-Key: your-api-key"
|
|
220
|
+
|
|
221
|
+
# Pause execution
|
|
222
|
+
curl -X POST https://api.testbase.ai/control/pause/thread-abc-123 \
|
|
223
|
+
-H "X-API-Key: your-api-key"
|
|
224
|
+
|
|
225
|
+
# Resume execution
|
|
226
|
+
curl -X POST https://api.testbase.ai/control/resume/thread-abc-123 \
|
|
227
|
+
-H "X-API-Key: your-api-key"
|
|
228
|
+
|
|
229
|
+
# Abort execution
|
|
230
|
+
curl -X POST https://api.testbase.ai/control/abort/thread-abc-123 \
|
|
231
|
+
-H "X-API-Key: your-api-key"
|
|
232
|
+
|
|
233
|
+
# Send message
|
|
234
|
+
curl -X POST https://api.testbase.ai/control/message/thread-abc-123 \
|
|
235
|
+
-H "X-API-Key: your-api-key" \
|
|
236
|
+
-H "Content-Type: application/json" \
|
|
237
|
+
-d '{"message": "Focus on critical files only"}'
|
|
238
|
+
|
|
239
|
+
# List all running executions
|
|
240
|
+
curl -X GET https://api.testbase.ai/control/executions \
|
|
241
|
+
-H "X-API-Key: your-api-key"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Control Methods
|
|
245
|
+
|
|
246
|
+
| Method | Description | Returns |
|
|
247
|
+
|--------|-------------|---------|
|
|
248
|
+
| `agent.pause()` | Pause execution (can be resumed) | `Promise<void>` |
|
|
249
|
+
| `agent.resume()` | Resume paused execution | `Promise<void>` |
|
|
250
|
+
| `agent.abort()` | Stop permanently (cannot resume) | `Promise<void>` |
|
|
251
|
+
| `agent.sendMessage(msg)` | Queue message for agent | `Promise<void>` |
|
|
252
|
+
| `agent.getStatus()` | Get current status | `{ status, threadId, queuedMessages }` |
|
|
253
|
+
|
|
254
|
+
### Use Cases
|
|
133
255
|
|
|
134
|
-
|
|
256
|
+
- **Long-running tasks**: Pause agents that exceed time limits
|
|
257
|
+
- **User intervention**: Send messages to guide agent behavior
|
|
258
|
+
- **Error recovery**: Abort stuck or misbehaving agents
|
|
259
|
+
- **Resource management**: Control multiple cloud executions
|
|
260
|
+
- **Interactive workflows**: Pause for user review, then resume
|
|
261
|
+
|
|
262
|
+
## Session Continuity
|
|
263
|
+
|
|
264
|
+
Agents automatically maintain context across multiple runs:
|
|
135
265
|
|
|
136
266
|
```typescript
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
model: 'gpt-4o',
|
|
141
|
-
instructions: 'You are a helpful coding assistant.'
|
|
267
|
+
const agent = new Agent({
|
|
268
|
+
agentType: 'computer',
|
|
269
|
+
workspace: './my-project'
|
|
142
270
|
});
|
|
143
271
|
|
|
144
|
-
|
|
145
|
-
|
|
272
|
+
await run(agent, 'Create app.py');
|
|
273
|
+
await run(agent, 'Add error handling'); // Continues same session
|
|
274
|
+
await run(agent, 'Add tests'); // Still same session
|
|
146
275
|
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
276
|
+
console.log(agent.currentThreadId); // Thread ID maintained
|
|
277
|
+
|
|
278
|
+
agent.resetSession(); // Start fresh
|
|
279
|
+
await run(agent, 'New project'); // New session
|
|
151
280
|
```
|
|
152
281
|
|
|
153
|
-
|
|
282
|
+
## Cloud Execution (Coming Soon)
|
|
283
|
+
|
|
284
|
+
> **Note**: Cloud execution with `CloudClient` and `Project` management is currently in private beta. Public access coming soon.
|
|
285
|
+
>
|
|
286
|
+
> Interested in early access? [Join the waitlist →](https://testbase.ai)
|
|
154
287
|
|
|
155
|
-
|
|
288
|
+
Cloud execution will enable:
|
|
289
|
+
- Run agents in isolated cloud environments
|
|
290
|
+
- Project-based workspace management with bidirectional sync
|
|
291
|
+
- Seamless transition from local to cloud with workspace configuration
|
|
292
|
+
- Parallel execution at scale without local resource constraints
|
|
293
|
+
|
|
294
|
+
Example (available in private beta):
|
|
156
295
|
|
|
157
296
|
```typescript
|
|
158
|
-
|
|
159
|
-
const files = await client.files.listFiles('env_xxx');
|
|
160
|
-
|
|
161
|
-
// Upload a file
|
|
162
|
-
await client.files.uploadFile({
|
|
163
|
-
environmentId: 'env_xxx',
|
|
164
|
-
filename: 'app.py',
|
|
165
|
-
path: 'src', // optional subdirectory
|
|
166
|
-
content: 'print("hello")'
|
|
167
|
-
});
|
|
297
|
+
import { Agent, run, CloudClient } from 'computer-agents';
|
|
168
298
|
|
|
169
|
-
|
|
170
|
-
|
|
299
|
+
const client = new CloudClient({
|
|
300
|
+
apiKey: process.env.TESTBASE_API_KEY
|
|
301
|
+
});
|
|
171
302
|
|
|
172
|
-
//
|
|
173
|
-
const
|
|
303
|
+
// Create a cloud project
|
|
304
|
+
const project = await client.createProject({ name: 'my-app' });
|
|
174
305
|
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
306
|
+
// Cloud agent
|
|
307
|
+
const agent = new Agent({
|
|
308
|
+
agentType: "computer",
|
|
309
|
+
workspace: project, // Use cloud project as workspace
|
|
310
|
+
instructions: "You are an expert developer."
|
|
180
311
|
});
|
|
181
312
|
|
|
182
|
-
|
|
183
|
-
|
|
313
|
+
const result = await run(agent, "Add error handling to the API");
|
|
314
|
+
console.log(result.finalOutput);
|
|
184
315
|
```
|
|
185
316
|
|
|
186
|
-
|
|
317
|
+
## Configuration
|
|
187
318
|
|
|
188
|
-
|
|
319
|
+
### Agent Configuration
|
|
189
320
|
|
|
190
321
|
```typescript
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
322
|
+
const agent = new Agent({
|
|
323
|
+
name: "My Agent", // Optional, auto-generated if omitted
|
|
324
|
+
agentType: 'computer', // 'llm' | 'computer'
|
|
325
|
+
workspace: './my-project', // Required for computer agents
|
|
326
|
+
model: 'gpt-4o', // Required for LLM agents
|
|
327
|
+
instructions: "You are helpful.", // System prompt
|
|
328
|
+
debug: false, // Show detailed logs
|
|
329
|
+
timeout: 600000, // 10 minutes (default)
|
|
330
|
+
mcpServers: [], // MCP server configurations
|
|
199
331
|
});
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Environment Variables
|
|
200
335
|
|
|
201
|
-
|
|
202
|
-
|
|
336
|
+
```bash
|
|
337
|
+
# Required for all agents
|
|
338
|
+
OPENAI_API_KEY=your-openai-key
|
|
203
339
|
|
|
204
|
-
|
|
205
|
-
|
|
340
|
+
# Required for CloudClient (private beta)
|
|
341
|
+
TESTBASE_API_KEY=your-testbase-key
|
|
206
342
|
```
|
|
207
343
|
|
|
208
|
-
|
|
344
|
+
## MCP Server Integration
|
|
209
345
|
|
|
210
|
-
|
|
346
|
+
Use Model Context Protocol servers with your agents:
|
|
211
347
|
|
|
212
348
|
```typescript
|
|
213
|
-
|
|
214
|
-
|
|
349
|
+
import type { McpServerConfig } from 'computer-agents';
|
|
350
|
+
|
|
351
|
+
const mcpServers: McpServerConfig[] = [
|
|
352
|
+
{
|
|
353
|
+
type: 'stdio',
|
|
354
|
+
name: 'filesystem',
|
|
355
|
+
command: 'npx',
|
|
356
|
+
args: ['@modelcontextprotocol/server-filesystem', '/workspace']
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
type: 'http',
|
|
360
|
+
name: 'notion',
|
|
361
|
+
url: 'https://notion-mcp.example.com/mcp',
|
|
362
|
+
bearerToken: process.env.NOTION_TOKEN
|
|
363
|
+
}
|
|
364
|
+
];
|
|
365
|
+
|
|
366
|
+
const agent = new Agent({
|
|
367
|
+
agentType: 'computer',
|
|
368
|
+
workspace: './my-project',
|
|
369
|
+
mcpServers
|
|
370
|
+
});
|
|
371
|
+
```
|
|
215
372
|
|
|
216
|
-
|
|
217
|
-
const canRun = await client.budget.canExecute();
|
|
373
|
+
## API Reference
|
|
218
374
|
|
|
219
|
-
|
|
220
|
-
const records = await client.billing.listRecords({ limit: 10 });
|
|
375
|
+
### Agent
|
|
221
376
|
|
|
222
|
-
|
|
223
|
-
|
|
377
|
+
```typescript
|
|
378
|
+
class Agent {
|
|
379
|
+
constructor(config: AgentConfiguration);
|
|
380
|
+
|
|
381
|
+
currentThreadId: string | undefined;
|
|
382
|
+
resetSession(): void;
|
|
383
|
+
workspace: string;
|
|
384
|
+
agentType: 'llm' | 'computer';
|
|
385
|
+
|
|
386
|
+
// Task control
|
|
387
|
+
async pause(): Promise<void>;
|
|
388
|
+
async resume(): Promise<void>;
|
|
389
|
+
async abort(): Promise<void>;
|
|
390
|
+
async sendMessage(message: string): Promise<void>;
|
|
391
|
+
getStatus(): { status: 'idle' | 'running' | 'paused' | 'aborted', threadId?: string, queuedMessages: number };
|
|
392
|
+
}
|
|
224
393
|
```
|
|
225
394
|
|
|
226
|
-
###
|
|
395
|
+
### run()
|
|
227
396
|
|
|
228
|
-
|
|
397
|
+
```typescript
|
|
398
|
+
function run(
|
|
399
|
+
agent: Agent,
|
|
400
|
+
task: string,
|
|
401
|
+
options?: RunOptions
|
|
402
|
+
): Promise<RunResult>;
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### runStreamed()
|
|
229
406
|
|
|
230
407
|
```typescript
|
|
231
|
-
|
|
232
|
-
|
|
408
|
+
function runStreamed(
|
|
409
|
+
agent: Agent,
|
|
410
|
+
task: string,
|
|
411
|
+
options?: RunOptions
|
|
412
|
+
): AsyncGenerator<Event>;
|
|
413
|
+
```
|
|
233
414
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
415
|
+
### CloudClient (Coming Soon)
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
class CloudClient {
|
|
419
|
+
constructor(config?: CloudClientConfig);
|
|
238
420
|
|
|
239
|
-
|
|
240
|
-
|
|
421
|
+
async createProject(config: CreateProjectConfig): Promise<Project>;
|
|
422
|
+
async listProjects(): Promise<Project[]>;
|
|
423
|
+
async getProject(id: string): Promise<Project>;
|
|
424
|
+
async deleteProject(id: string, hard?: boolean): Promise<void>;
|
|
425
|
+
}
|
|
241
426
|
```
|
|
242
427
|
|
|
243
|
-
|
|
428
|
+
### Project (Coming Soon)
|
|
244
429
|
|
|
245
430
|
```typescript
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
431
|
+
class Project {
|
|
432
|
+
readonly id: string;
|
|
433
|
+
readonly name: string;
|
|
434
|
+
readonly localPath: string | undefined;
|
|
435
|
+
readonly cloudPath: string;
|
|
436
|
+
|
|
437
|
+
async sync(options?: SyncOptions): Promise<SyncResult>;
|
|
438
|
+
async listFiles(pattern?: string): Promise<ProjectFile[]>;
|
|
439
|
+
async readFile(path: string): Promise<string>;
|
|
440
|
+
async writeFile(path: string, content: string): Promise<void>;
|
|
441
|
+
async upload(files: string[]): Promise<void>;
|
|
442
|
+
async download(files: string[]): Promise<void>;
|
|
443
|
+
async delete(hard?: boolean): Promise<void>;
|
|
444
|
+
async getStats(): Promise<ProjectStats>;
|
|
445
|
+
async getSyncStats(): Promise<SyncStats>;
|
|
446
|
+
|
|
447
|
+
getWorkspacePath(): string;
|
|
256
448
|
}
|
|
257
449
|
```
|
|
258
450
|
|
|
259
|
-
##
|
|
451
|
+
## Examples
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Clone the repository
|
|
455
|
+
git clone https://github.com/TestBase-ai/computer-agents.git
|
|
456
|
+
cd computer-agents
|
|
457
|
+
npm install
|
|
458
|
+
npm run build
|
|
459
|
+
|
|
460
|
+
# Run examples
|
|
461
|
+
node examples/testbase/hello-world.mjs
|
|
462
|
+
node examples/testbase/multi-agent-workflow.mjs
|
|
463
|
+
node examples/testbase/streaming-progress.cjs
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
[View all examples →](https://github.com/TestBase-ai/computer-agents/tree/main/examples/testbase)
|
|
260
467
|
|
|
261
|
-
|
|
262
|
-
|----------|-------------|
|
|
263
|
-
| `COMPUTER_AGENTS_API_KEY` | API key for authentication |
|
|
468
|
+
## Troubleshooting
|
|
264
469
|
|
|
265
|
-
|
|
470
|
+
### "OPENAI_API_KEY not set"
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
export OPENAI_API_KEY=sk-...
|
|
474
|
+
```
|
|
266
475
|
|
|
267
|
-
|
|
476
|
+
### "Computer agents require a workspace"
|
|
477
|
+
|
|
478
|
+
Computer agents need a workspace parameter:
|
|
268
479
|
|
|
269
480
|
```typescript
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
481
|
+
// Correct
|
|
482
|
+
new Agent({ agentType: 'computer', workspace: './my-project' })
|
|
483
|
+
|
|
484
|
+
// Missing workspace - Error
|
|
485
|
+
new Agent({ agentType: 'computer' })
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Session continuity not working
|
|
489
|
+
|
|
490
|
+
Use the same agent instance across runs:
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
493
|
+
const agent = new Agent({ agentType: 'computer', workspace: './project' });
|
|
494
|
+
await run(agent, 'Task 1');
|
|
495
|
+
await run(agent, 'Task 2'); // Same instance = session continues
|
|
278
496
|
```
|
|
279
497
|
|
|
280
498
|
## License
|
|
281
499
|
|
|
282
500
|
MIT
|
|
501
|
+
|
|
502
|
+
## Links
|
|
503
|
+
|
|
504
|
+
- **GitHub**: [https://github.com/TestBase-ai/computer-agents](https://github.com/TestBase-ai/computer-agents)
|
|
505
|
+
- **npm**: [https://www.npmjs.com/package/computer-agents](https://www.npmjs.com/package/computer-agents)
|
|
506
|
+
- **Documentation**: [https://github.com/TestBase-ai/computer-agents/tree/main/examples/testbase](https://github.com/TestBase-ai/computer-agents/tree/main/examples/testbase)
|
|
507
|
+
|
|
508
|
+
## Support
|
|
509
|
+
|
|
510
|
+
- **Issues**: [GitHub Issues](https://github.com/TestBase-ai/computer-agents/issues)
|
|
511
|
+
- **Website**: [testbase.ai](https://testbase.ai)
|