computer-agents 1.0.3 → 1.1.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 +253 -385
- package/dist/ComputerAgentsClient.d.ts +357 -0
- package/dist/ComputerAgentsClient.js +359 -0
- package/dist/ComputerAgentsClient.js.map +1 -0
- package/dist/cloud/ApiClient.d.ts +62 -0
- package/dist/cloud/ApiClient.js +150 -0
- package/dist/cloud/ApiClient.js.map +1 -0
- package/dist/cloud/resources/AgentsResource.d.ts +39 -0
- package/dist/cloud/resources/AgentsResource.js +58 -0
- package/dist/cloud/resources/AgentsResource.js.map +1 -0
- package/dist/cloud/resources/BudgetResource.d.ts +167 -0
- package/dist/cloud/resources/BudgetResource.js +179 -0
- package/dist/cloud/resources/BudgetResource.js.map +1 -0
- package/dist/cloud/resources/EnvironmentsResource.d.ts +167 -0
- package/dist/cloud/resources/EnvironmentsResource.js +256 -0
- package/dist/cloud/resources/EnvironmentsResource.js.map +1 -0
- package/dist/cloud/resources/FilesResource.d.ts +201 -0
- package/dist/cloud/resources/FilesResource.js +204 -0
- package/dist/cloud/resources/FilesResource.js.map +1 -0
- package/dist/cloud/resources/GitResource.d.ts +28 -0
- package/dist/cloud/resources/GitResource.js +45 -0
- package/dist/cloud/resources/GitResource.js.map +1 -0
- package/dist/cloud/resources/ProjectsResource.d.ts +78 -0
- package/dist/cloud/resources/ProjectsResource.js +117 -0
- package/dist/cloud/resources/ProjectsResource.js.map +1 -0
- package/dist/cloud/resources/RunsResource.d.ts +61 -0
- package/dist/cloud/resources/RunsResource.js +84 -0
- package/dist/cloud/resources/RunsResource.js.map +1 -0
- package/dist/cloud/resources/SchedulesResource.d.ts +58 -0
- package/dist/cloud/resources/SchedulesResource.js +82 -0
- package/dist/cloud/resources/SchedulesResource.js.map +1 -0
- package/dist/cloud/resources/ThreadsResource.d.ts +124 -0
- package/dist/cloud/resources/ThreadsResource.js +178 -0
- package/dist/cloud/resources/ThreadsResource.js.map +1 -0
- package/dist/cloud/resources/index.d.ts +17 -0
- package/dist/cloud/resources/index.js +28 -0
- package/dist/cloud/resources/index.js.map +1 -0
- package/dist/cloud/types.d.ts +665 -0
- package/dist/cloud/types.js +9 -0
- package/dist/cloud/types.js.map +1 -0
- package/dist/index.d.ts +28 -5
- package/dist/index.js +51 -194
- package/dist/index.js.map +1 -1
- package/package.json +23 -25
- package/dist/metadata.d.ts +0 -8
- package/dist/metadata.js +0 -13
- package/dist/metadata.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,511 +1,379 @@
|
|
|
1
1
|
# Computer Agents SDK
|
|
2
2
|
|
|
3
|
-
[
|
|
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.
|
|
3
|
+
Official TypeScript/JavaScript SDK for the [Computer Agents Cloud API](https://api.computer-agents.com).
|
|
31
4
|
|
|
32
5
|
## Installation
|
|
33
6
|
|
|
34
7
|
```bash
|
|
35
8
|
npm install computer-agents
|
|
9
|
+
# or
|
|
10
|
+
pnpm add computer-agents
|
|
11
|
+
# or
|
|
12
|
+
yarn add computer-agents
|
|
36
13
|
```
|
|
37
14
|
|
|
38
15
|
## Quick Start
|
|
39
16
|
|
|
40
|
-
### Local Computer Agent
|
|
41
|
-
|
|
42
17
|
```typescript
|
|
43
|
-
import {
|
|
18
|
+
import { ComputerAgentsClient } from 'computer-agents';
|
|
44
19
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
workspace: "./my-project",
|
|
48
|
-
instructions: "You are an expert developer."
|
|
20
|
+
const client = new ComputerAgentsClient({
|
|
21
|
+
apiKey: process.env.COMPUTER_AGENTS_API_KEY
|
|
49
22
|
});
|
|
50
23
|
|
|
51
|
-
|
|
52
|
-
|
|
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."
|
|
24
|
+
// Execute a task
|
|
25
|
+
const result = await client.run('Create a REST API with Flask', {
|
|
26
|
+
environmentId: 'env_xxx',
|
|
27
|
+
onEvent: (event) => console.log(event.type)
|
|
64
28
|
});
|
|
65
29
|
|
|
66
|
-
|
|
67
|
-
console.log(result.finalOutput);
|
|
30
|
+
console.log(result.content);
|
|
68
31
|
```
|
|
69
32
|
|
|
70
|
-
##
|
|
33
|
+
## Features
|
|
71
34
|
|
|
72
|
-
|
|
35
|
+
- Full TypeScript support with complete type definitions
|
|
36
|
+
- SSE streaming for real-time execution progress
|
|
37
|
+
- Simple, intuitive API that mirrors the REST API structure
|
|
38
|
+
- Zero dependencies - uses native `fetch`
|
|
73
39
|
|
|
74
|
-
|
|
75
|
-
|------|-----------|-----------|
|
|
76
|
-
| `computer` | Codex SDK | Code generation, file operations, terminal commands |
|
|
77
|
-
| `llm` | OpenAI API | Planning, reasoning, text generation |
|
|
78
|
-
|
|
79
|
-
### Computer Agents
|
|
40
|
+
## API Reference
|
|
80
41
|
|
|
81
|
-
|
|
42
|
+
### Creating a Client
|
|
82
43
|
|
|
83
44
|
```typescript
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
45
|
+
const client = new ComputerAgentsClient({
|
|
46
|
+
apiKey: 'tb_xxx', // Required
|
|
47
|
+
baseUrl: 'https://api.computer-agents.com', // Optional (default)
|
|
48
|
+
timeout: 60000, // Optional (default: 60s)
|
|
49
|
+
debug: false // Optional
|
|
88
50
|
});
|
|
89
|
-
|
|
90
|
-
await run(agent, "Add unit tests for the fibonacci module");
|
|
91
51
|
```
|
|
92
52
|
|
|
93
|
-
###
|
|
53
|
+
### Running Tasks
|
|
94
54
|
|
|
95
|
-
|
|
55
|
+
The simplest way to execute a task:
|
|
96
56
|
|
|
97
57
|
```typescript
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
instructions: "You review code for quality and security."
|
|
58
|
+
// One-shot execution
|
|
59
|
+
const result = await client.run('Fix the TypeScript errors', {
|
|
60
|
+
environmentId: 'env_xxx'
|
|
102
61
|
});
|
|
103
62
|
|
|
104
|
-
|
|
63
|
+
// With streaming progress
|
|
64
|
+
const result = await client.run('Build a REST API', {
|
|
65
|
+
environmentId: 'env_xxx',
|
|
66
|
+
onEvent: (event) => {
|
|
67
|
+
if (event.type === 'response.item.completed') {
|
|
68
|
+
console.log(event.item);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Continue a conversation
|
|
74
|
+
const followUp = await client.run('Add authentication', {
|
|
75
|
+
environmentId: 'env_xxx',
|
|
76
|
+
threadId: result.threadId
|
|
77
|
+
});
|
|
105
78
|
```
|
|
106
79
|
|
|
107
|
-
|
|
80
|
+
### Threads
|
|
108
81
|
|
|
109
|
-
|
|
82
|
+
For multi-turn conversations:
|
|
110
83
|
|
|
111
84
|
```typescript
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const planner = new Agent({
|
|
116
|
-
agentType: 'llm',
|
|
117
|
-
model: 'gpt-4o',
|
|
118
|
-
instructions: 'Create implementation plans.'
|
|
85
|
+
// Create a thread
|
|
86
|
+
const thread = await client.threads.create({
|
|
87
|
+
environmentId: 'env_xxx'
|
|
119
88
|
});
|
|
120
89
|
|
|
121
|
-
//
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
instructions: 'Execute implementation plans.'
|
|
90
|
+
// Send a message
|
|
91
|
+
const result = await client.threads.sendMessage(thread.id, {
|
|
92
|
+
content: 'Create a REST API',
|
|
93
|
+
onEvent: (event) => console.log(event)
|
|
126
94
|
});
|
|
127
95
|
|
|
128
|
-
//
|
|
129
|
-
const
|
|
130
|
-
agentType: 'llm',
|
|
131
|
-
model: 'gpt-4o',
|
|
132
|
-
instructions: 'Review code quality.'
|
|
133
|
-
});
|
|
96
|
+
// List threads
|
|
97
|
+
const threads = await client.threads.list();
|
|
134
98
|
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
99
|
+
// Get a specific thread
|
|
100
|
+
const thread = await client.threads.get('thread_xxx');
|
|
101
|
+
|
|
102
|
+
// Delete a thread
|
|
103
|
+
await client.threads.delete('thread_xxx');
|
|
139
104
|
```
|
|
140
105
|
|
|
141
|
-
|
|
106
|
+
### Environments
|
|
142
107
|
|
|
143
|
-
|
|
108
|
+
Manage isolated execution environments:
|
|
144
109
|
|
|
145
110
|
```typescript
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
111
|
+
// Create an environment with custom configuration
|
|
112
|
+
const env = await client.environments.create({
|
|
113
|
+
name: 'data-science',
|
|
114
|
+
description: 'Environment for data processing',
|
|
115
|
+
runtimes: { python: '3.12', nodejs: '20' },
|
|
116
|
+
packages: {
|
|
117
|
+
system: ['ffmpeg'],
|
|
118
|
+
python: ['pandas', 'numpy'],
|
|
119
|
+
node: ['typescript']
|
|
120
|
+
},
|
|
121
|
+
internetAccess: true
|
|
151
122
|
});
|
|
152
123
|
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
```
|
|
124
|
+
// List environments
|
|
125
|
+
const environments = await client.environments.list();
|
|
170
126
|
|
|
171
|
-
|
|
127
|
+
// Get an environment
|
|
128
|
+
const env = await client.environments.get('env_xxx');
|
|
172
129
|
|
|
173
|
-
|
|
130
|
+
// Get default environment (creates one if doesn't exist)
|
|
131
|
+
const defaultEnv = await client.environments.getDefault();
|
|
132
|
+
|
|
133
|
+
// Update an environment
|
|
134
|
+
await client.environments.update('env_xxx', {
|
|
135
|
+
description: 'Updated description'
|
|
136
|
+
});
|
|
174
137
|
|
|
175
|
-
|
|
138
|
+
// Delete an environment
|
|
139
|
+
await client.environments.delete('env_xxx');
|
|
140
|
+
```
|
|
176
141
|
|
|
177
|
-
|
|
142
|
+
#### Runtime Management
|
|
178
143
|
|
|
179
144
|
```typescript
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
145
|
+
// List all available runtimes and versions
|
|
146
|
+
const available = await client.environments.listAvailableRuntimes();
|
|
147
|
+
// { python: ['3.9', '3.10', '3.11', '3.12', '3.13'], nodejs: ['18', '20', '22'], ... }
|
|
148
|
+
|
|
149
|
+
// Get current runtimes for an environment
|
|
150
|
+
const runtimes = await client.environments.getRuntimes('env_xxx');
|
|
151
|
+
// { python: '3.12', nodejs: '20' }
|
|
152
|
+
|
|
153
|
+
// Set runtime versions (triggers rebuild)
|
|
154
|
+
await client.environments.setRuntimes('env_xxx', {
|
|
155
|
+
python: '3.12',
|
|
156
|
+
nodejs: '20',
|
|
157
|
+
go: '1.22'
|
|
185
158
|
});
|
|
159
|
+
```
|
|
186
160
|
|
|
187
|
-
|
|
188
|
-
const taskPromise = run(agent, 'Analyze all TypeScript files');
|
|
161
|
+
#### Package Management
|
|
189
162
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
163
|
+
```typescript
|
|
164
|
+
// List installed packages
|
|
165
|
+
const packages = await client.environments.listPackages('env_xxx');
|
|
166
|
+
// { system: ['ffmpeg'], python: ['pandas'], node: ['typescript'] }
|
|
194
167
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
168
|
+
// Install packages (triggers rebuild)
|
|
169
|
+
await client.environments.installPackages('env_xxx', 'python', ['requests', 'beautifulsoup4']);
|
|
170
|
+
await client.environments.installPackages('env_xxx', 'system', ['imagemagick']);
|
|
171
|
+
await client.environments.installPackages('env_xxx', 'node', ['tsx']);
|
|
199
172
|
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// { status: 'running', threadId: 'thread-123', queuedMessages: 0 }
|
|
173
|
+
// Uninstall a package (triggers rebuild)
|
|
174
|
+
await client.environments.uninstallPackage('env_xxx', 'python', 'requests');
|
|
175
|
+
```
|
|
204
176
|
|
|
205
|
-
|
|
206
|
-
await agent.sendMessage('Focus on performance issues');
|
|
177
|
+
#### Dockerfile Customization
|
|
207
178
|
|
|
208
|
-
|
|
209
|
-
|
|
179
|
+
```typescript
|
|
180
|
+
// Get Dockerfile configuration
|
|
181
|
+
const dockerfile = await client.environments.getDockerfile('env_xxx');
|
|
182
|
+
// { baseImage: '...', dockerfileExtensions: '...', effectiveDockerfile: '...' }
|
|
183
|
+
|
|
184
|
+
// Set Dockerfile extensions (triggers rebuild)
|
|
185
|
+
await client.environments.setDockerfileExtensions('env_xxx',
|
|
186
|
+
'RUN pip install custom-package\nRUN apt-get install -y custom-tool'
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// Validate Dockerfile syntax without building
|
|
190
|
+
const validation = await client.environments.validateDockerfile('env_xxx',
|
|
191
|
+
'RUN pip install something'
|
|
192
|
+
);
|
|
193
|
+
// { valid: true, warnings: [], effectiveDockerfile: '...' }
|
|
210
194
|
```
|
|
211
195
|
|
|
212
|
-
|
|
196
|
+
#### Build Management
|
|
213
197
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
```
|
|
198
|
+
```typescript
|
|
199
|
+
// Trigger a build
|
|
200
|
+
const build = await client.environments.triggerBuild('env_xxx');
|
|
201
|
+
// { buildId: 'build_xxx', status: 'building', message: 'Build started' }
|
|
243
202
|
|
|
244
|
-
|
|
203
|
+
// Force rebuild even if up to date
|
|
204
|
+
await client.environments.triggerBuild('env_xxx', true);
|
|
245
205
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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 }` |
|
|
206
|
+
// Get build status
|
|
207
|
+
const status = await client.environments.getBuildStatus('env_xxx');
|
|
208
|
+
// { buildStatus: 'ready', buildHash: '...', imageTag: '...', lastBuildAt: '...' }
|
|
253
209
|
|
|
254
|
-
|
|
210
|
+
// Get build logs
|
|
211
|
+
const logs = await client.environments.getBuildLogs('env_xxx');
|
|
212
|
+
// { logs: '...', buildStatus: 'ready' }
|
|
255
213
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
- **Interactive workflows**: Pause for user review, then resume
|
|
214
|
+
// Test build (validates without caching)
|
|
215
|
+
const test = await client.environments.testBuild('env_xxx');
|
|
216
|
+
// { success: true, logs: '...', duration: 45000 }
|
|
217
|
+
```
|
|
261
218
|
|
|
262
|
-
|
|
219
|
+
### Agents
|
|
263
220
|
|
|
264
|
-
|
|
221
|
+
Configure agent behavior:
|
|
265
222
|
|
|
266
223
|
```typescript
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
224
|
+
// Create an agent
|
|
225
|
+
const agent = await client.agents.create({
|
|
226
|
+
name: 'Code Assistant',
|
|
227
|
+
model: 'gpt-4o',
|
|
228
|
+
instructions: 'You are a helpful coding assistant.'
|
|
270
229
|
});
|
|
271
230
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
await run(agent, 'Add tests'); // Still same session
|
|
275
|
-
|
|
276
|
-
console.log(agent.currentThreadId); // Thread ID maintained
|
|
231
|
+
// List agents
|
|
232
|
+
const agents = await client.agents.list();
|
|
277
233
|
|
|
278
|
-
|
|
279
|
-
await
|
|
234
|
+
// Update an agent
|
|
235
|
+
await client.agents.update('agent_xxx', {
|
|
236
|
+
instructions: 'Updated instructions'
|
|
237
|
+
});
|
|
280
238
|
```
|
|
281
239
|
|
|
282
|
-
|
|
240
|
+
### Files
|
|
283
241
|
|
|
284
|
-
|
|
285
|
-
>
|
|
286
|
-
> Interested in early access? [Join the waitlist →](https://testbase.ai)
|
|
287
|
-
|
|
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):
|
|
242
|
+
Manage files in environment workspaces:
|
|
295
243
|
|
|
296
244
|
```typescript
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
245
|
+
// List files in an environment
|
|
246
|
+
const files = await client.files.listFiles('env_xxx');
|
|
247
|
+
|
|
248
|
+
// Upload a file
|
|
249
|
+
await client.files.uploadFile({
|
|
250
|
+
environmentId: 'env_xxx',
|
|
251
|
+
filename: 'app.py',
|
|
252
|
+
path: 'src', // optional subdirectory
|
|
253
|
+
content: 'print("hello")'
|
|
301
254
|
});
|
|
302
255
|
|
|
303
|
-
//
|
|
304
|
-
const
|
|
256
|
+
// Download file content
|
|
257
|
+
const content = await client.files.getFile('env_xxx', 'src/app.py');
|
|
305
258
|
|
|
306
|
-
//
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
259
|
+
// Download as Buffer
|
|
260
|
+
const buffer = await client.files.downloadFile('env_xxx', 'src/app.py');
|
|
261
|
+
|
|
262
|
+
// Move/rename a file
|
|
263
|
+
await client.files.moveFile({
|
|
264
|
+
environmentId: 'env_xxx',
|
|
265
|
+
sourcePath: 'old-name.py',
|
|
266
|
+
destPath: 'new-name.py'
|
|
311
267
|
});
|
|
312
268
|
|
|
313
|
-
|
|
314
|
-
|
|
269
|
+
// Delete a file
|
|
270
|
+
await client.files.deleteFile('env_xxx', 'src/app.py');
|
|
315
271
|
```
|
|
316
272
|
|
|
317
|
-
|
|
273
|
+
### Schedules
|
|
318
274
|
|
|
319
|
-
|
|
275
|
+
Automate task execution:
|
|
320
276
|
|
|
321
277
|
```typescript
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
mcpServers: [], // MCP server configurations
|
|
278
|
+
// Create a schedule
|
|
279
|
+
const schedule = await client.schedules.create({
|
|
280
|
+
name: 'Daily Report',
|
|
281
|
+
agentId: 'agent_xxx',
|
|
282
|
+
agentName: 'Reporter',
|
|
283
|
+
task: 'Generate daily report',
|
|
284
|
+
scheduleType: 'recurring',
|
|
285
|
+
cronExpression: '0 9 * * *'
|
|
331
286
|
});
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
### Environment Variables
|
|
335
287
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
OPENAI_API_KEY=your-openai-key
|
|
288
|
+
// List schedules
|
|
289
|
+
const schedules = await client.schedules.list();
|
|
339
290
|
|
|
340
|
-
|
|
341
|
-
|
|
291
|
+
// Trigger a schedule manually
|
|
292
|
+
await client.schedules.trigger('schedule_xxx');
|
|
342
293
|
```
|
|
343
294
|
|
|
344
|
-
|
|
295
|
+
### Billing
|
|
345
296
|
|
|
346
|
-
|
|
297
|
+
Track usage and manage budgets:
|
|
347
298
|
|
|
348
299
|
```typescript
|
|
349
|
-
|
|
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
|
-
];
|
|
300
|
+
// Get budget status
|
|
301
|
+
const status = await client.budget.getStatus();
|
|
365
302
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
workspace: './my-project',
|
|
369
|
-
mcpServers
|
|
370
|
-
});
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
## API Reference
|
|
303
|
+
// Check if can execute
|
|
304
|
+
const canRun = await client.budget.canExecute();
|
|
374
305
|
|
|
375
|
-
|
|
306
|
+
// Get billing records
|
|
307
|
+
const records = await client.billing.listRecords({ limit: 10 });
|
|
376
308
|
|
|
377
|
-
|
|
378
|
-
|
|
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
|
-
}
|
|
309
|
+
// Get usage stats
|
|
310
|
+
const stats = await client.billing.getStats({ period: 'month' });
|
|
393
311
|
```
|
|
394
312
|
|
|
395
|
-
###
|
|
313
|
+
### Git Operations
|
|
396
314
|
|
|
397
|
-
|
|
398
|
-
function run(
|
|
399
|
-
agent: Agent,
|
|
400
|
-
task: string,
|
|
401
|
-
options?: RunOptions
|
|
402
|
-
): Promise<RunResult>;
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
### runStreamed()
|
|
315
|
+
Manage version control:
|
|
406
316
|
|
|
407
317
|
```typescript
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
task: string,
|
|
411
|
-
options?: RunOptions
|
|
412
|
-
): AsyncGenerator<Event>;
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
### CloudClient (Coming Soon)
|
|
318
|
+
// Get diff
|
|
319
|
+
const diff = await client.git.diff('env_xxx');
|
|
416
320
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
321
|
+
// Commit changes
|
|
322
|
+
await client.git.commit('env_xxx', {
|
|
323
|
+
message: 'Add new feature'
|
|
324
|
+
});
|
|
420
325
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
async getProject(id: string): Promise<Project>;
|
|
424
|
-
async deleteProject(id: string, hard?: boolean): Promise<void>;
|
|
425
|
-
}
|
|
326
|
+
// Push to remote
|
|
327
|
+
await client.git.push('env_xxx');
|
|
426
328
|
```
|
|
427
329
|
|
|
428
|
-
|
|
330
|
+
## Error Handling
|
|
429
331
|
|
|
430
332
|
```typescript
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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;
|
|
333
|
+
import { ComputerAgentsClient, ApiClientError } from 'computer-agents';
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
await client.run('Task', { environmentId: 'env_xxx' });
|
|
337
|
+
} catch (error) {
|
|
338
|
+
if (error instanceof ApiClientError) {
|
|
339
|
+
console.error(`API Error: ${error.message}`);
|
|
340
|
+
console.error(`Status: ${error.status}`);
|
|
341
|
+
console.error(`Code: ${error.code}`);
|
|
342
|
+
}
|
|
448
343
|
}
|
|
449
344
|
```
|
|
450
345
|
|
|
451
|
-
##
|
|
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)
|
|
467
|
-
|
|
468
|
-
## Troubleshooting
|
|
469
|
-
|
|
470
|
-
### "OPENAI_API_KEY not set"
|
|
471
|
-
|
|
472
|
-
```bash
|
|
473
|
-
export OPENAI_API_KEY=sk-...
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
### "Computer agents require a workspace"
|
|
346
|
+
## Environment Variables
|
|
477
347
|
|
|
478
|
-
|
|
348
|
+
| Variable | Description |
|
|
349
|
+
|----------|-------------|
|
|
350
|
+
| `COMPUTER_AGENTS_API_KEY` | API key for authentication |
|
|
479
351
|
|
|
480
|
-
|
|
481
|
-
// Correct
|
|
482
|
-
new Agent({ agentType: 'computer', workspace: './my-project' })
|
|
483
|
-
|
|
484
|
-
// Missing workspace - Error
|
|
485
|
-
new Agent({ agentType: 'computer' })
|
|
486
|
-
```
|
|
352
|
+
## TypeScript
|
|
487
353
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
Use the same agent instance across runs:
|
|
354
|
+
Full type definitions are included:
|
|
491
355
|
|
|
492
356
|
```typescript
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
357
|
+
import type {
|
|
358
|
+
// Core types
|
|
359
|
+
Thread,
|
|
360
|
+
Environment,
|
|
361
|
+
CloudAgent,
|
|
362
|
+
Schedule,
|
|
363
|
+
BudgetStatus,
|
|
364
|
+
MessageStreamEvent,
|
|
365
|
+
|
|
366
|
+
// Environment configuration
|
|
367
|
+
RuntimeConfig,
|
|
368
|
+
PackagesConfig,
|
|
369
|
+
AvailableRuntimes,
|
|
370
|
+
PackageType,
|
|
371
|
+
BuildStatus,
|
|
372
|
+
BuildStatusResult,
|
|
373
|
+
DockerfileResult,
|
|
374
|
+
} from 'computer-agents';
|
|
496
375
|
```
|
|
497
376
|
|
|
498
377
|
## License
|
|
499
378
|
|
|
500
379
|
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)
|