computer-agents 2.3.0 → 2.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 +61 -18
- package/dist/ComputerAgentsClient.d.ts +63 -41
- package/dist/ComputerAgentsClient.js +84 -44
- package/dist/ComputerAgentsClient.js.map +1 -1
- package/dist/cloud/resources/AgentsResource.d.ts +12 -1
- package/dist/cloud/resources/AgentsResource.js +16 -0
- package/dist/cloud/resources/AgentsResource.js.map +1 -1
- package/dist/cloud/resources/DatabasesResource.d.ts +36 -0
- package/dist/cloud/resources/DatabasesResource.js +68 -0
- package/dist/cloud/resources/DatabasesResource.js.map +1 -0
- package/dist/cloud/resources/EnvironmentsResource.d.ts +110 -0
- package/dist/cloud/resources/EnvironmentsResource.js +75 -0
- package/dist/cloud/resources/EnvironmentsResource.js.map +1 -1
- package/dist/cloud/resources/GitResource.d.ts +60 -2
- package/dist/cloud/resources/GitResource.js +86 -10
- package/dist/cloud/resources/GitResource.js.map +1 -1
- package/dist/cloud/resources/ResourcesResource.d.ts +92 -0
- package/dist/cloud/resources/ResourcesResource.js +151 -0
- package/dist/cloud/resources/ResourcesResource.js.map +1 -0
- package/dist/cloud/resources/SkillsResource.d.ts +17 -0
- package/dist/cloud/resources/SkillsResource.js +36 -0
- package/dist/cloud/resources/SkillsResource.js.map +1 -0
- package/dist/cloud/resources/ThreadsResource.d.ts +78 -0
- package/dist/cloud/resources/ThreadsResource.js +64 -0
- package/dist/cloud/resources/ThreadsResource.js.map +1 -1
- package/dist/cloud/resources/index.d.ts +7 -1
- package/dist/cloud/resources/index.js +9 -3
- package/dist/cloud/resources/index.js.map +1 -1
- package/dist/cloud/types.d.ts +185 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/computer-agents)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
Official TypeScript/JavaScript SDK for the [Computer Agents Cloud API](https://computer-agents.com).
|
|
6
|
+
Official TypeScript/JavaScript SDK for the [Computer Agents Cloud API](https://computer-agents.com). Build against the Agentic Compute Platform with threads, computers, resources, databases, skills, and agents.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -30,12 +30,12 @@ console.log(result.content);
|
|
|
30
30
|
|
|
31
31
|
## Features
|
|
32
32
|
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
33
|
+
- **Managed and external models** — use built-in Claude and Gemini models or connect external models on Team and Enterprise plans
|
|
34
|
+
- **Persistent computers** — isolated execution environments with stateful workspaces
|
|
35
35
|
- **SSE streaming** — real-time execution progress and tool calls
|
|
36
36
|
- **Session continuity** — multi-turn conversations via threads
|
|
37
37
|
- **MCP integration** — extend capabilities with Model Context Protocol servers
|
|
38
|
-
- **Skills** —
|
|
38
|
+
- **Skills and resources** — connect system skills, custom skills, and published resources
|
|
39
39
|
- **Zero dependencies** — uses native `fetch`
|
|
40
40
|
- **Full TypeScript support** — complete type definitions
|
|
41
41
|
|
|
@@ -44,8 +44,12 @@ console.log(result.content);
|
|
|
44
44
|
| Model | ID | Use Case |
|
|
45
45
|
|-------|-----|----------|
|
|
46
46
|
| Claude 4.6 Opus | `claude-opus-4-6` | Most capable, complex tasks |
|
|
47
|
-
| Claude 4.5 Sonnet | `claude-sonnet-4-5` | Balanced
|
|
47
|
+
| Claude 4.5 Sonnet | `claude-sonnet-4-5` | Balanced default |
|
|
48
48
|
| Claude 4.5 Haiku | `claude-haiku-4-5` | Fast, efficient |
|
|
49
|
+
| Gemini 3 Flash | `gemini-3-flash` | Low-latency general workflows |
|
|
50
|
+
| Gemini 3.1 Pro | `gemini-3-1-pro` | Broader reasoning and research tasks |
|
|
51
|
+
|
|
52
|
+
Team and Enterprise plans can also connect external models with IDs in the form `external:{provider}:{model}`.
|
|
49
53
|
|
|
50
54
|
## API Reference
|
|
51
55
|
|
|
@@ -65,7 +69,7 @@ const client = new ComputerAgentsClient({
|
|
|
65
69
|
```typescript
|
|
66
70
|
// One-shot execution
|
|
67
71
|
const result = await client.run('Fix the TypeScript errors', {
|
|
68
|
-
|
|
72
|
+
computerId: 'env_xxx'
|
|
69
73
|
});
|
|
70
74
|
|
|
71
75
|
// With streaming
|
|
@@ -85,7 +89,7 @@ Multi-turn conversations with persistent context:
|
|
|
85
89
|
```typescript
|
|
86
90
|
// Create a thread
|
|
87
91
|
const thread = await client.threads.create({
|
|
88
|
-
|
|
92
|
+
computerId: 'env_xxx'
|
|
89
93
|
});
|
|
90
94
|
|
|
91
95
|
// Send messages — the agent remembers the full context
|
|
@@ -134,30 +138,30 @@ const agent = await client.agents.create({
|
|
|
134
138
|
|
|
135
139
|
// Use the agent in a thread
|
|
136
140
|
const thread = await client.threads.create({
|
|
137
|
-
|
|
141
|
+
computerId: 'env_xxx',
|
|
138
142
|
agentId: agent.id
|
|
139
143
|
});
|
|
140
144
|
```
|
|
141
145
|
|
|
142
|
-
###
|
|
146
|
+
### Computers
|
|
143
147
|
|
|
144
|
-
|
|
148
|
+
Persistent execution environments with custom runtimes, packages, secrets, and MCP setup:
|
|
145
149
|
|
|
146
150
|
```typescript
|
|
147
|
-
// Create
|
|
148
|
-
const
|
|
151
|
+
// Create a computer (same manager is also available as client.environments)
|
|
152
|
+
const computer = await client.computers.create({
|
|
149
153
|
name: 'python-dev',
|
|
150
154
|
internetAccess: true
|
|
151
155
|
});
|
|
152
156
|
|
|
153
157
|
// Configure runtimes
|
|
154
|
-
await client.
|
|
158
|
+
await client.computers.setRuntimes(computer.id, {
|
|
155
159
|
python: '3.12',
|
|
156
160
|
nodejs: '20'
|
|
157
161
|
});
|
|
158
162
|
|
|
159
163
|
// Install packages
|
|
160
|
-
await client.
|
|
164
|
+
await client.computers.installPackages(computer.id, {
|
|
161
165
|
packages: [
|
|
162
166
|
{ type: 'python', name: 'flask' },
|
|
163
167
|
{ type: 'python', name: 'pytest' },
|
|
@@ -166,7 +170,7 @@ await client.environments.installPackages(env.id, {
|
|
|
166
170
|
});
|
|
167
171
|
|
|
168
172
|
// Add MCP servers
|
|
169
|
-
await client.
|
|
173
|
+
await client.computers.update(computer.id, {
|
|
170
174
|
mcpServers: [
|
|
171
175
|
{
|
|
172
176
|
type: 'stdio',
|
|
@@ -184,12 +188,12 @@ await client.environments.update(env.id, {
|
|
|
184
188
|
});
|
|
185
189
|
|
|
186
190
|
// Trigger a build
|
|
187
|
-
await client.
|
|
191
|
+
await client.computers.build(computer.id);
|
|
188
192
|
```
|
|
189
193
|
|
|
190
194
|
### Files
|
|
191
195
|
|
|
192
|
-
Manage files in
|
|
196
|
+
Manage files in computer workspaces:
|
|
193
197
|
|
|
194
198
|
```typescript
|
|
195
199
|
// Upload a file
|
|
@@ -209,9 +213,48 @@ const files = await client.files.listFiles('env_xxx');
|
|
|
209
213
|
await client.files.deleteFile('env_xxx', 'src/app.py');
|
|
210
214
|
```
|
|
211
215
|
|
|
216
|
+
### Resources
|
|
217
|
+
|
|
218
|
+
Publish web apps, functions, auth modules, and agent runtimes:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
const resource = await client.resources.create({
|
|
222
|
+
name: 'crm-web',
|
|
223
|
+
kind: 'web_app',
|
|
224
|
+
authMode: 'public',
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
await client.resources.deploy(resource.id);
|
|
228
|
+
const analytics = await client.resources.getAnalytics(resource.id);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Databases
|
|
232
|
+
|
|
233
|
+
Create Firestore-backed data surfaces and work with collections/documents:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
const database = await client.databases.create({
|
|
237
|
+
name: 'crm-data',
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
await client.databases.createCollection(database.id, { name: 'leads' });
|
|
241
|
+
await client.databases.createDocument(database.id, 'leads', {
|
|
242
|
+
data: { company: 'Acme', stage: 'new' },
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Skills
|
|
247
|
+
|
|
248
|
+
Manage custom ACP skills:
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const skills = await client.skills.list();
|
|
252
|
+
console.log(skills.map((skill) => skill.name));
|
|
253
|
+
```
|
|
254
|
+
|
|
212
255
|
### Git
|
|
213
256
|
|
|
214
|
-
Version control on workspaces:
|
|
257
|
+
Version control on computer workspaces:
|
|
215
258
|
|
|
216
259
|
```typescript
|
|
217
260
|
// View uncommitted changes
|
|
@@ -8,31 +8,27 @@
|
|
|
8
8
|
* ```typescript
|
|
9
9
|
* import { ComputerAgentsClient } from 'computer-agents';
|
|
10
10
|
*
|
|
11
|
-
* const client = new ComputerAgentsClient(
|
|
12
|
-
* apiKey: process.env.COMPUTER_AGENTS_API_KEY
|
|
13
|
-
* });
|
|
11
|
+
* const client = new ComputerAgentsClient();
|
|
14
12
|
*
|
|
15
|
-
* // Execute a task
|
|
16
|
-
* const result = await client.run('Create a REST API with Flask'
|
|
17
|
-
*
|
|
18
|
-
* onEvent: (event) => console.log(event.type)
|
|
19
|
-
* });
|
|
13
|
+
* // Execute a task — that's it. No setup needed.
|
|
14
|
+
* const result = await client.run('Create a REST API with Flask');
|
|
15
|
+
* console.log(result.content);
|
|
20
16
|
*
|
|
21
|
-
* //
|
|
22
|
-
* const
|
|
23
|
-
*
|
|
17
|
+
* // With streaming events
|
|
18
|
+
* const result2 = await client.run('Build a web scraper', {
|
|
19
|
+
* onEvent: (event) => console.log(event.type)
|
|
24
20
|
* });
|
|
25
21
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
22
|
+
* // Continue the conversation
|
|
23
|
+
* const followUp = await client.run('Add error handling', {
|
|
24
|
+
* threadId: result2.threadId
|
|
29
25
|
* });
|
|
30
26
|
* ```
|
|
31
27
|
*/
|
|
32
28
|
import { ApiClientError } from './cloud/ApiClient';
|
|
33
29
|
import type { ApiClientConfig } from './cloud/ApiClient';
|
|
34
|
-
import { EnvironmentsResource, ThreadsResource, AgentsResource, BudgetResource, BillingResource, SchedulesResource, TriggersResource, OrchestrationsResource, GitResource, FilesResource } from './cloud/resources';
|
|
35
|
-
import type { HealthCheck, Metrics, Project, Environment, MessageStreamEvent } from './cloud/types';
|
|
30
|
+
import { EnvironmentsResource, ThreadsResource, AgentsResource, ResourcesResource, DatabasesResource, SkillsResource, BudgetResource, BillingResource, SchedulesResource, TriggersResource, OrchestrationsResource, GitResource, FilesResource } from './cloud/resources';
|
|
31
|
+
import type { HealthCheck, Metrics, Project, Environment, MessageStreamEvent, AgentModel } from './cloud/types';
|
|
36
32
|
export { ApiClientError };
|
|
37
33
|
export type { ApiClientConfig };
|
|
38
34
|
/**
|
|
@@ -65,9 +61,14 @@ export interface ComputerAgentsClientConfig {
|
|
|
65
61
|
*/
|
|
66
62
|
export interface RunOptions {
|
|
67
63
|
/**
|
|
68
|
-
*
|
|
64
|
+
* Computer ID to execute in.
|
|
65
|
+
* The raw API route still uses `environmentId`.
|
|
66
|
+
*/
|
|
67
|
+
environmentId?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Product-level alias for `environmentId`.
|
|
69
70
|
*/
|
|
70
|
-
|
|
71
|
+
computerId?: string;
|
|
71
72
|
/**
|
|
72
73
|
* Thread ID to continue (optional - creates new thread if not provided)
|
|
73
74
|
*/
|
|
@@ -76,7 +77,7 @@ export interface RunOptions {
|
|
|
76
77
|
* Agent configuration override
|
|
77
78
|
*/
|
|
78
79
|
agentConfig?: {
|
|
79
|
-
model?:
|
|
80
|
+
model?: AgentModel;
|
|
80
81
|
instructions?: string;
|
|
81
82
|
reasoningEffort?: 'minimal' | 'low' | 'medium' | 'high';
|
|
82
83
|
};
|
|
@@ -121,12 +122,15 @@ export interface RunResult {
|
|
|
121
122
|
* resources through typed methods:
|
|
122
123
|
*
|
|
123
124
|
* - `threads` - Conversation management with SSE streaming
|
|
124
|
-
* - `environments` -
|
|
125
|
+
* - `environments` / `computers` - Computer configuration and lifecycle
|
|
126
|
+
* - `resources` - Deployable apps, functions, auth modules, and runtimes
|
|
127
|
+
* - `databases` - Managed database surfaces
|
|
128
|
+
* - `skills` - Custom ACP skills
|
|
125
129
|
* - `agents` - Agent configuration
|
|
126
|
-
* - `files` - File management
|
|
130
|
+
* - `files` - File management in computer workspaces
|
|
127
131
|
* - `schedules` - Scheduled task management
|
|
128
132
|
* - `billing` - Budget and usage tracking
|
|
129
|
-
* - `git` - Git operations on
|
|
133
|
+
* - `git` - Git operations on computers (compatibility helper)
|
|
130
134
|
*
|
|
131
135
|
* For simple use cases, use the `run()` method which handles thread
|
|
132
136
|
* creation and streaming automatically.
|
|
@@ -166,11 +170,15 @@ export declare class ComputerAgentsClient {
|
|
|
166
170
|
* ```
|
|
167
171
|
*/
|
|
168
172
|
readonly environments: EnvironmentsResource;
|
|
173
|
+
/**
|
|
174
|
+
* Product-level alias for `environments`.
|
|
175
|
+
*/
|
|
176
|
+
readonly computers: EnvironmentsResource;
|
|
169
177
|
/**
|
|
170
178
|
* Agent configuration
|
|
171
179
|
*
|
|
172
|
-
* Create and manage agent configurations with
|
|
173
|
-
*
|
|
180
|
+
* Create and manage agent configurations with built-in or external models,
|
|
181
|
+
* instructions, and enabled skills.
|
|
174
182
|
*
|
|
175
183
|
* @example
|
|
176
184
|
* ```typescript
|
|
@@ -182,6 +190,18 @@ export declare class ComputerAgentsClient {
|
|
|
182
190
|
* ```
|
|
183
191
|
*/
|
|
184
192
|
readonly agents: AgentsResource;
|
|
193
|
+
/**
|
|
194
|
+
* Managed resource surfaces such as web apps, functions, auth modules, and agent runtimes.
|
|
195
|
+
*/
|
|
196
|
+
readonly resources: ResourcesResource;
|
|
197
|
+
/**
|
|
198
|
+
* Managed database surfaces and document operations.
|
|
199
|
+
*/
|
|
200
|
+
readonly databases: DatabasesResource;
|
|
201
|
+
/**
|
|
202
|
+
* Custom skill management.
|
|
203
|
+
*/
|
|
204
|
+
readonly skills: SkillsResource;
|
|
185
205
|
/**
|
|
186
206
|
* File operations
|
|
187
207
|
*
|
|
@@ -316,25 +336,23 @@ export declare class ComputerAgentsClient {
|
|
|
316
336
|
* Execute a task with automatic thread management
|
|
317
337
|
*
|
|
318
338
|
* This is the simplest way to run an agent task. It handles:
|
|
339
|
+
* - Auto-creating a default computer (if no computer/environment ID is provided)
|
|
319
340
|
* - Creating a thread (if threadId not provided)
|
|
320
341
|
* - Sending the message with SSE streaming
|
|
321
342
|
* - Returning the result with thread ID for follow-ups
|
|
322
343
|
*
|
|
323
344
|
* @param task - The task to execute (e.g., "Create a REST API with Flask")
|
|
324
|
-
* @param options - Execution options
|
|
345
|
+
* @param options - Execution options (all optional)
|
|
325
346
|
* @returns The execution result with content and thread ID
|
|
326
347
|
*
|
|
327
348
|
* @example
|
|
328
349
|
* ```typescript
|
|
329
|
-
* //
|
|
330
|
-
* const result = await client.run('Create hello.py'
|
|
331
|
-
* environmentId: 'env_xxx'
|
|
332
|
-
* });
|
|
350
|
+
* // Simplest usage — no setup needed
|
|
351
|
+
* const result = await client.run('Create hello.py');
|
|
333
352
|
* console.log(result.content);
|
|
334
353
|
*
|
|
335
354
|
* // With streaming progress
|
|
336
355
|
* const result = await client.run('Build a REST API', {
|
|
337
|
-
* environmentId: 'env_xxx',
|
|
338
356
|
* onEvent: (event) => {
|
|
339
357
|
* if (event.type === 'response.item.completed') {
|
|
340
358
|
* console.log(event.item);
|
|
@@ -344,36 +362,40 @@ export declare class ComputerAgentsClient {
|
|
|
344
362
|
*
|
|
345
363
|
* // Continue the conversation
|
|
346
364
|
* const followUp = await client.run('Add authentication', {
|
|
347
|
-
* environmentId: 'env_xxx',
|
|
348
365
|
* threadId: result.threadId
|
|
349
366
|
* });
|
|
367
|
+
*
|
|
368
|
+
* // Explicit computer
|
|
369
|
+
* const result = await client.run('Deploy', {
|
|
370
|
+
* computerId: 'env_xxx'
|
|
371
|
+
* });
|
|
350
372
|
* ```
|
|
351
373
|
*/
|
|
352
|
-
run(task: string, options
|
|
374
|
+
run(task: string, options?: RunOptions): Promise<RunResult>;
|
|
353
375
|
/**
|
|
354
|
-
* Quick setup with default
|
|
376
|
+
* Quick setup with default computer
|
|
377
|
+
*
|
|
378
|
+
* Creates a default computer if none exists, returning both
|
|
379
|
+
* the project and computer ready for execution.
|
|
355
380
|
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
381
|
+
* Note: You usually don't need to call this directly. `run()` auto-creates
|
|
382
|
+
* a default environment when `environmentId` is omitted.
|
|
358
383
|
*
|
|
359
384
|
* @example
|
|
360
385
|
* ```typescript
|
|
361
|
-
* const { project,
|
|
386
|
+
* const { project, computer } = await client.quickSetup({
|
|
362
387
|
* internetAccess: true
|
|
363
388
|
* });
|
|
364
|
-
*
|
|
365
|
-
* // Ready to execute
|
|
366
|
-
* await client.run('Hello world!', {
|
|
367
|
-
* environmentId: environment.id
|
|
368
|
-
* });
|
|
369
389
|
* ```
|
|
370
390
|
*/
|
|
371
391
|
quickSetup(options?: {
|
|
372
392
|
internetAccess?: boolean;
|
|
373
393
|
environmentName?: string;
|
|
394
|
+
computerName?: string;
|
|
374
395
|
}): Promise<{
|
|
375
396
|
project: Project;
|
|
376
397
|
environment: Environment;
|
|
398
|
+
computer: Environment;
|
|
377
399
|
}>;
|
|
378
400
|
/**
|
|
379
401
|
* Check API health status
|
|
@@ -9,24 +9,20 @@
|
|
|
9
9
|
* ```typescript
|
|
10
10
|
* import { ComputerAgentsClient } from 'computer-agents';
|
|
11
11
|
*
|
|
12
|
-
* const client = new ComputerAgentsClient(
|
|
13
|
-
* apiKey: process.env.COMPUTER_AGENTS_API_KEY
|
|
14
|
-
* });
|
|
12
|
+
* const client = new ComputerAgentsClient();
|
|
15
13
|
*
|
|
16
|
-
* // Execute a task
|
|
17
|
-
* const result = await client.run('Create a REST API with Flask'
|
|
18
|
-
*
|
|
19
|
-
* onEvent: (event) => console.log(event.type)
|
|
20
|
-
* });
|
|
14
|
+
* // Execute a task — that's it. No setup needed.
|
|
15
|
+
* const result = await client.run('Create a REST API with Flask');
|
|
16
|
+
* console.log(result.content);
|
|
21
17
|
*
|
|
22
|
-
* //
|
|
23
|
-
* const
|
|
24
|
-
*
|
|
18
|
+
* // With streaming events
|
|
19
|
+
* const result2 = await client.run('Build a web scraper', {
|
|
20
|
+
* onEvent: (event) => console.log(event.type)
|
|
25
21
|
* });
|
|
26
22
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
23
|
+
* // Continue the conversation
|
|
24
|
+
* const followUp = await client.run('Add error handling', {
|
|
25
|
+
* threadId: result2.threadId
|
|
30
26
|
* });
|
|
31
27
|
* ```
|
|
32
28
|
*/
|
|
@@ -42,12 +38,15 @@ const resources_1 = require("./cloud/resources");
|
|
|
42
38
|
* resources through typed methods:
|
|
43
39
|
*
|
|
44
40
|
* - `threads` - Conversation management with SSE streaming
|
|
45
|
-
* - `environments` -
|
|
41
|
+
* - `environments` / `computers` - Computer configuration and lifecycle
|
|
42
|
+
* - `resources` - Deployable apps, functions, auth modules, and runtimes
|
|
43
|
+
* - `databases` - Managed database surfaces
|
|
44
|
+
* - `skills` - Custom ACP skills
|
|
46
45
|
* - `agents` - Agent configuration
|
|
47
|
-
* - `files` - File management
|
|
46
|
+
* - `files` - File management in computer workspaces
|
|
48
47
|
* - `schedules` - Scheduled task management
|
|
49
48
|
* - `billing` - Budget and usage tracking
|
|
50
|
-
* - `git` - Git operations on
|
|
49
|
+
* - `git` - Git operations on computers (compatibility helper)
|
|
51
50
|
*
|
|
52
51
|
* For simple use cases, use the `run()` method which handles thread
|
|
53
52
|
* creation and streaming automatically.
|
|
@@ -92,11 +91,15 @@ class ComputerAgentsClient {
|
|
|
92
91
|
* ```
|
|
93
92
|
*/
|
|
94
93
|
environments;
|
|
94
|
+
/**
|
|
95
|
+
* Product-level alias for `environments`.
|
|
96
|
+
*/
|
|
97
|
+
computers;
|
|
95
98
|
/**
|
|
96
99
|
* Agent configuration
|
|
97
100
|
*
|
|
98
|
-
* Create and manage agent configurations with
|
|
99
|
-
*
|
|
101
|
+
* Create and manage agent configurations with built-in or external models,
|
|
102
|
+
* instructions, and enabled skills.
|
|
100
103
|
*
|
|
101
104
|
* @example
|
|
102
105
|
* ```typescript
|
|
@@ -108,6 +111,18 @@ class ComputerAgentsClient {
|
|
|
108
111
|
* ```
|
|
109
112
|
*/
|
|
110
113
|
agents;
|
|
114
|
+
/**
|
|
115
|
+
* Managed resource surfaces such as web apps, functions, auth modules, and agent runtimes.
|
|
116
|
+
*/
|
|
117
|
+
resources;
|
|
118
|
+
/**
|
|
119
|
+
* Managed database surfaces and document operations.
|
|
120
|
+
*/
|
|
121
|
+
databases;
|
|
122
|
+
/**
|
|
123
|
+
* Custom skill management.
|
|
124
|
+
*/
|
|
125
|
+
skills;
|
|
111
126
|
/**
|
|
112
127
|
* File operations
|
|
113
128
|
*
|
|
@@ -238,15 +253,15 @@ class ComputerAgentsClient {
|
|
|
238
253
|
*/
|
|
239
254
|
git;
|
|
240
255
|
/**
|
|
241
|
-
*
|
|
256
|
+
* Project access (internal - use files/resources/databases for data operations)
|
|
242
257
|
* @internal
|
|
243
258
|
*/
|
|
244
|
-
|
|
259
|
+
projects;
|
|
245
260
|
/**
|
|
246
|
-
*
|
|
261
|
+
* Cached default environment ID (populated on first run without environmentId)
|
|
247
262
|
* @internal
|
|
248
263
|
*/
|
|
249
|
-
|
|
264
|
+
_defaultEnvironmentId = null;
|
|
250
265
|
constructor(config = {}) {
|
|
251
266
|
// Get API key from config or environment variable
|
|
252
267
|
const apiKey = config.apiKey
|
|
@@ -267,7 +282,11 @@ class ComputerAgentsClient {
|
|
|
267
282
|
// Initialize all resource managers
|
|
268
283
|
this.threads = new resources_1.ThreadsResource(this.api);
|
|
269
284
|
this.environments = new resources_1.EnvironmentsResource(this.api);
|
|
285
|
+
this.computers = this.environments;
|
|
270
286
|
this.agents = new resources_1.AgentsResource(this.api);
|
|
287
|
+
this.resources = new resources_1.ResourcesResource(this.api);
|
|
288
|
+
this.databases = new resources_1.DatabasesResource(this.api);
|
|
289
|
+
this.skills = new resources_1.SkillsResource(this.api);
|
|
271
290
|
this.files = new resources_1.FilesResource(this.api);
|
|
272
291
|
this.schedules = new resources_1.SchedulesResource(this.api);
|
|
273
292
|
this.triggers = new resources_1.TriggersResource(this.api);
|
|
@@ -275,7 +294,6 @@ class ComputerAgentsClient {
|
|
|
275
294
|
this.budget = new resources_1.BudgetResource(this.api);
|
|
276
295
|
this.billing = new resources_1.BillingResource(this.api);
|
|
277
296
|
this.git = new resources_1.GitResource(this.api);
|
|
278
|
-
this.runs = new resources_1.RunsResource(this.api);
|
|
279
297
|
this.projects = new resources_1.ProjectsResource(this.api);
|
|
280
298
|
}
|
|
281
299
|
// =========================================================================
|
|
@@ -285,25 +303,23 @@ class ComputerAgentsClient {
|
|
|
285
303
|
* Execute a task with automatic thread management
|
|
286
304
|
*
|
|
287
305
|
* This is the simplest way to run an agent task. It handles:
|
|
306
|
+
* - Auto-creating a default computer (if no computer/environment ID is provided)
|
|
288
307
|
* - Creating a thread (if threadId not provided)
|
|
289
308
|
* - Sending the message with SSE streaming
|
|
290
309
|
* - Returning the result with thread ID for follow-ups
|
|
291
310
|
*
|
|
292
311
|
* @param task - The task to execute (e.g., "Create a REST API with Flask")
|
|
293
|
-
* @param options - Execution options
|
|
312
|
+
* @param options - Execution options (all optional)
|
|
294
313
|
* @returns The execution result with content and thread ID
|
|
295
314
|
*
|
|
296
315
|
* @example
|
|
297
316
|
* ```typescript
|
|
298
|
-
* //
|
|
299
|
-
* const result = await client.run('Create hello.py'
|
|
300
|
-
* environmentId: 'env_xxx'
|
|
301
|
-
* });
|
|
317
|
+
* // Simplest usage — no setup needed
|
|
318
|
+
* const result = await client.run('Create hello.py');
|
|
302
319
|
* console.log(result.content);
|
|
303
320
|
*
|
|
304
321
|
* // With streaming progress
|
|
305
322
|
* const result = await client.run('Build a REST API', {
|
|
306
|
-
* environmentId: 'env_xxx',
|
|
307
323
|
* onEvent: (event) => {
|
|
308
324
|
* if (event.type === 'response.item.completed') {
|
|
309
325
|
* console.log(event.item);
|
|
@@ -313,17 +329,23 @@ class ComputerAgentsClient {
|
|
|
313
329
|
*
|
|
314
330
|
* // Continue the conversation
|
|
315
331
|
* const followUp = await client.run('Add authentication', {
|
|
316
|
-
* environmentId: 'env_xxx',
|
|
317
332
|
* threadId: result.threadId
|
|
318
333
|
* });
|
|
334
|
+
*
|
|
335
|
+
* // Explicit computer
|
|
336
|
+
* const result = await client.run('Deploy', {
|
|
337
|
+
* computerId: 'env_xxx'
|
|
338
|
+
* });
|
|
319
339
|
* ```
|
|
320
340
|
*/
|
|
321
|
-
async run(task, options) {
|
|
341
|
+
async run(task, options = {}) {
|
|
342
|
+
// Auto-resolve environment if not provided
|
|
343
|
+
const environmentId = options.computerId || options.environmentId || await this._ensureDefaultEnvironment();
|
|
322
344
|
// Create or reuse thread
|
|
323
345
|
let threadId = options.threadId;
|
|
324
346
|
if (!threadId) {
|
|
325
347
|
const thread = await this.threads.create({
|
|
326
|
-
environmentId
|
|
348
|
+
environmentId,
|
|
327
349
|
});
|
|
328
350
|
threadId = thread.id;
|
|
329
351
|
}
|
|
@@ -341,21 +363,39 @@ class ComputerAgentsClient {
|
|
|
341
363
|
};
|
|
342
364
|
}
|
|
343
365
|
/**
|
|
344
|
-
*
|
|
366
|
+
* Return the cached default environment ID, creating one if needed.
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
async _ensureDefaultEnvironment() {
|
|
370
|
+
if (this._defaultEnvironmentId) {
|
|
371
|
+
return this._defaultEnvironmentId;
|
|
372
|
+
}
|
|
373
|
+
const environments = await this.environments.list();
|
|
374
|
+
let environment = environments.find(e => e.isDefault);
|
|
375
|
+
if (!environment) {
|
|
376
|
+
environment = await this.environments.create({
|
|
377
|
+
name: 'default',
|
|
378
|
+
internetAccess: true,
|
|
379
|
+
isDefault: true,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
this._defaultEnvironmentId = environment.id;
|
|
383
|
+
return this._defaultEnvironmentId;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Quick setup with default computer
|
|
387
|
+
*
|
|
388
|
+
* Creates a default computer if none exists, returning both
|
|
389
|
+
* the project and computer ready for execution.
|
|
345
390
|
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
391
|
+
* Note: You usually don't need to call this directly. `run()` auto-creates
|
|
392
|
+
* a default environment when `environmentId` is omitted.
|
|
348
393
|
*
|
|
349
394
|
* @example
|
|
350
395
|
* ```typescript
|
|
351
|
-
* const { project,
|
|
396
|
+
* const { project, computer } = await client.quickSetup({
|
|
352
397
|
* internetAccess: true
|
|
353
398
|
* });
|
|
354
|
-
*
|
|
355
|
-
* // Ready to execute
|
|
356
|
-
* await client.run('Hello world!', {
|
|
357
|
-
* environmentId: environment.id
|
|
358
|
-
* });
|
|
359
399
|
* ```
|
|
360
400
|
*/
|
|
361
401
|
async quickSetup(options = {}) {
|
|
@@ -367,12 +407,12 @@ class ComputerAgentsClient {
|
|
|
367
407
|
// Create default environment if none exists
|
|
368
408
|
if (!environment) {
|
|
369
409
|
environment = await this.environments.create({
|
|
370
|
-
name: options.environmentName || 'default',
|
|
410
|
+
name: options.computerName || options.environmentName || 'default',
|
|
371
411
|
internetAccess: options.internetAccess ?? true,
|
|
372
412
|
isDefault: true,
|
|
373
413
|
});
|
|
374
414
|
}
|
|
375
|
-
return { project, environment };
|
|
415
|
+
return { project, environment, computer: environment };
|
|
376
416
|
}
|
|
377
417
|
// =========================================================================
|
|
378
418
|
// Health & Monitoring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComputerAgentsClient.js","sourceRoot":"","sources":["../src/ComputerAgentsClient.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"ComputerAgentsClient.js","sourceRoot":"","sources":["../src/ComputerAgentsClient.ts"],"names":[],"mappings":";AAAA;;;;;;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