computer-agents 0.7.1 → 1.0.1

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.
Files changed (47) hide show
  1. package/README.md +170 -399
  2. package/dist/ComputerAgentsClient.d.ts +357 -0
  3. package/dist/ComputerAgentsClient.js +359 -0
  4. package/dist/ComputerAgentsClient.js.map +1 -0
  5. package/dist/cloud/ApiClient.d.ts +62 -0
  6. package/dist/cloud/ApiClient.js +150 -0
  7. package/dist/cloud/ApiClient.js.map +1 -0
  8. package/dist/cloud/resources/AgentsResource.d.ts +39 -0
  9. package/dist/cloud/resources/AgentsResource.js +58 -0
  10. package/dist/cloud/resources/AgentsResource.js.map +1 -0
  11. package/dist/cloud/resources/BudgetResource.d.ts +167 -0
  12. package/dist/cloud/resources/BudgetResource.js +179 -0
  13. package/dist/cloud/resources/BudgetResource.js.map +1 -0
  14. package/dist/cloud/resources/EnvironmentsResource.d.ts +78 -0
  15. package/dist/cloud/resources/EnvironmentsResource.js +118 -0
  16. package/dist/cloud/resources/EnvironmentsResource.js.map +1 -0
  17. package/dist/cloud/resources/FilesResource.d.ts +177 -0
  18. package/dist/cloud/resources/FilesResource.js +180 -0
  19. package/dist/cloud/resources/FilesResource.js.map +1 -0
  20. package/dist/cloud/resources/GitResource.d.ts +28 -0
  21. package/dist/cloud/resources/GitResource.js +45 -0
  22. package/dist/cloud/resources/GitResource.js.map +1 -0
  23. package/dist/cloud/resources/ProjectsResource.d.ts +78 -0
  24. package/dist/cloud/resources/ProjectsResource.js +117 -0
  25. package/dist/cloud/resources/ProjectsResource.js.map +1 -0
  26. package/dist/cloud/resources/RunsResource.d.ts +61 -0
  27. package/dist/cloud/resources/RunsResource.js +84 -0
  28. package/dist/cloud/resources/RunsResource.js.map +1 -0
  29. package/dist/cloud/resources/SchedulesResource.d.ts +58 -0
  30. package/dist/cloud/resources/SchedulesResource.js +82 -0
  31. package/dist/cloud/resources/SchedulesResource.js.map +1 -0
  32. package/dist/cloud/resources/ThreadsResource.d.ts +124 -0
  33. package/dist/cloud/resources/ThreadsResource.js +178 -0
  34. package/dist/cloud/resources/ThreadsResource.js.map +1 -0
  35. package/dist/cloud/resources/index.d.ts +16 -0
  36. package/dist/cloud/resources/index.js +28 -0
  37. package/dist/cloud/resources/index.js.map +1 -0
  38. package/dist/cloud/types.d.ts +573 -0
  39. package/dist/cloud/types.js +9 -0
  40. package/dist/cloud/types.js.map +1 -0
  41. package/dist/index.d.ts +28 -5
  42. package/dist/index.js +51 -194
  43. package/dist/index.js.map +1 -1
  44. package/package.json +23 -25
  45. package/dist/metadata.d.ts +0 -8
  46. package/dist/metadata.js +0 -13
  47. package/dist/metadata.js.map +0 -1
@@ -0,0 +1,357 @@
1
+ /**
2
+ * ComputerAgentsClient - The Official Computer Agents SDK
3
+ *
4
+ * A clean, simple SDK for interacting with the Computer Agents Cloud API.
5
+ * This SDK provides typed access to all API resources with streaming support.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { ComputerAgentsClient } from 'computer-agents';
10
+ *
11
+ * const client = new ComputerAgentsClient({
12
+ * apiKey: process.env.COMPUTER_AGENTS_API_KEY
13
+ * });
14
+ *
15
+ * // Execute a task (simplest usage)
16
+ * const result = await client.run('Create a REST API with Flask', {
17
+ * environmentId: 'env_xxx',
18
+ * onEvent: (event) => console.log(event.type)
19
+ * });
20
+ *
21
+ * // Or use the thread API for multi-turn conversations
22
+ * const thread = await client.threads.create({
23
+ * environmentId: 'env_xxx'
24
+ * });
25
+ *
26
+ * const response = await client.threads.sendMessage(thread.id, {
27
+ * content: 'Create a REST API',
28
+ * onEvent: (event) => console.log(event)
29
+ * });
30
+ * ```
31
+ */
32
+ import { ApiClientError } from './cloud/ApiClient';
33
+ import type { ApiClientConfig } from './cloud/ApiClient';
34
+ import { EnvironmentsResource, ThreadsResource, AgentsResource, BudgetResource, BillingResource, SchedulesResource, GitResource, FilesResource } from './cloud/resources';
35
+ import type { HealthCheck, Metrics, Project, Environment, MessageStreamEvent } from './cloud/types';
36
+ export { ApiClientError };
37
+ export type { ApiClientConfig };
38
+ /**
39
+ * Configuration for ComputerAgentsClient
40
+ */
41
+ export interface ComputerAgentsClientConfig {
42
+ /**
43
+ * API key for authentication (required)
44
+ * Can also be set via COMPUTER_AGENTS_API_KEY environment variable
45
+ */
46
+ apiKey?: string;
47
+ /**
48
+ * Base URL for the API
49
+ * @default 'https://api.computer-agents.com'
50
+ */
51
+ baseUrl?: string;
52
+ /**
53
+ * Enable debug logging
54
+ * @default false
55
+ */
56
+ debug?: boolean;
57
+ /**
58
+ * Request timeout in milliseconds
59
+ * @default 60000 (1 minute)
60
+ */
61
+ timeout?: number;
62
+ }
63
+ /**
64
+ * Options for the run() convenience method
65
+ */
66
+ export interface RunOptions {
67
+ /**
68
+ * Environment ID to execute in (required)
69
+ */
70
+ environmentId: string;
71
+ /**
72
+ * Thread ID to continue (optional - creates new thread if not provided)
73
+ */
74
+ threadId?: string;
75
+ /**
76
+ * Agent configuration override
77
+ */
78
+ agentConfig?: {
79
+ model?: string;
80
+ instructions?: string;
81
+ reasoningEffort?: 'none' | 'low' | 'medium' | 'high';
82
+ };
83
+ /**
84
+ * Callback for streaming events
85
+ */
86
+ onEvent?: (event: MessageStreamEvent) => void;
87
+ /**
88
+ * Execution timeout in milliseconds
89
+ * @default 600000 (10 minutes)
90
+ */
91
+ timeout?: number;
92
+ }
93
+ /**
94
+ * Result from the run() method
95
+ */
96
+ export interface RunResult {
97
+ /**
98
+ * The final response content
99
+ */
100
+ content: string;
101
+ /**
102
+ * The thread ID (for continuing conversations)
103
+ */
104
+ threadId: string;
105
+ /**
106
+ * Run details if available
107
+ */
108
+ run?: {
109
+ id: string;
110
+ status: string;
111
+ tokens?: {
112
+ input: number;
113
+ output: number;
114
+ };
115
+ };
116
+ }
117
+ /**
118
+ * ComputerAgentsClient - Complete SDK for Computer Agents Cloud API
119
+ *
120
+ * This is the main entry point for the SDK. It provides access to all API
121
+ * resources through typed methods:
122
+ *
123
+ * - `threads` - Conversation management with SSE streaming
124
+ * - `environments` - Environment configuration and container lifecycle
125
+ * - `agents` - Agent configuration
126
+ * - `files` - File management (via projects resource)
127
+ * - `schedules` - Scheduled task management
128
+ * - `billing` - Budget and usage tracking
129
+ * - `git` - Git operations on workspaces
130
+ *
131
+ * For simple use cases, use the `run()` method which handles thread
132
+ * creation and streaming automatically.
133
+ */
134
+ export declare class ComputerAgentsClient {
135
+ /**
136
+ * Thread (conversation) management
137
+ *
138
+ * Create threads for multi-turn conversations with agents.
139
+ * Use sendMessage() for SSE streaming execution.
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const thread = await client.threads.create({
144
+ * environmentId: 'env_xxx'
145
+ * });
146
+ *
147
+ * const result = await client.threads.sendMessage(thread.id, {
148
+ * content: 'Fix the TypeScript errors',
149
+ * onEvent: (event) => console.log(event)
150
+ * });
151
+ * ```
152
+ */
153
+ readonly threads: ThreadsResource;
154
+ /**
155
+ * Environment management
156
+ *
157
+ * Create and manage isolated execution environments.
158
+ * Environments define variables, secrets, MCP servers, and setup scripts.
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * const env = await client.environments.create({
163
+ * name: 'production',
164
+ * internetAccess: true
165
+ * });
166
+ * ```
167
+ */
168
+ readonly environments: EnvironmentsResource;
169
+ /**
170
+ * Agent configuration
171
+ *
172
+ * Create and manage agent configurations with models, instructions, and skills.
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * const agent = await client.agents.create({
177
+ * name: 'Code Assistant',
178
+ * model: 'gpt-4o',
179
+ * instructions: 'You are a helpful coding assistant.'
180
+ * });
181
+ * ```
182
+ */
183
+ readonly agents: AgentsResource;
184
+ /**
185
+ * File operations
186
+ *
187
+ * Upload, download, and manage files in environment workspaces.
188
+ * Files are scoped to environments.
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * // List files in an environment
193
+ * const files = await client.files.listFiles('env_xxx');
194
+ *
195
+ * // Upload a file
196
+ * await client.files.uploadFile({
197
+ * environmentId: 'env_xxx',
198
+ * filename: 'app.py',
199
+ * path: 'src',
200
+ * content: 'print("hello")'
201
+ * });
202
+ *
203
+ * // Download a file
204
+ * const content = await client.files.getFile('env_xxx', 'src/app.py');
205
+ *
206
+ * // Delete a file
207
+ * await client.files.deleteFile('env_xxx', 'src/app.py');
208
+ *
209
+ * // Move/rename a file
210
+ * await client.files.moveFile({
211
+ * environmentId: 'env_xxx',
212
+ * sourcePath: 'old.py',
213
+ * destPath: 'new.py'
214
+ * });
215
+ * ```
216
+ */
217
+ readonly files: FilesResource;
218
+ /**
219
+ * Scheduled tasks
220
+ *
221
+ * Create and manage scheduled task execution.
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * const schedule = await client.schedules.create({
226
+ * name: 'Daily Report',
227
+ * agentId: 'agent_xxx',
228
+ * agentName: 'Reporter',
229
+ * task: 'Generate daily report',
230
+ * scheduleType: 'recurring',
231
+ * cronExpression: '0 9 * * *'
232
+ * });
233
+ * ```
234
+ */
235
+ readonly schedules: SchedulesResource;
236
+ /**
237
+ * Budget management
238
+ *
239
+ * Check and manage execution budgets.
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * const status = await client.budget.getStatus();
244
+ * const canRun = await client.budget.canExecute();
245
+ * ```
246
+ */
247
+ readonly budget: BudgetResource;
248
+ /**
249
+ * Billing and usage
250
+ *
251
+ * Access billing records and usage statistics.
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * const stats = await client.billing.getStats({ period: 'month' });
256
+ * const records = await client.billing.listRecords({ limit: 10 });
257
+ * ```
258
+ */
259
+ readonly billing: BillingResource;
260
+ /**
261
+ * Git operations
262
+ *
263
+ * Perform git operations on cloud workspaces.
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * const diff = await client.git.diff('env_xxx');
268
+ * await client.git.commit('env_xxx', { message: 'Add feature' });
269
+ * await client.git.push('env_xxx');
270
+ * ```
271
+ */
272
+ readonly git: GitResource;
273
+ constructor(config?: ComputerAgentsClientConfig);
274
+ /**
275
+ * Execute a task with automatic thread management
276
+ *
277
+ * This is the simplest way to run an agent task. It handles:
278
+ * - Creating a thread (if threadId not provided)
279
+ * - Sending the message with SSE streaming
280
+ * - Returning the result with thread ID for follow-ups
281
+ *
282
+ * @param task - The task to execute (e.g., "Create a REST API with Flask")
283
+ * @param options - Execution options including environmentId (required)
284
+ * @returns The execution result with content and thread ID
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * // Simple one-shot execution
289
+ * const result = await client.run('Create hello.py', {
290
+ * environmentId: 'env_xxx'
291
+ * });
292
+ * console.log(result.content);
293
+ *
294
+ * // With streaming progress
295
+ * const result = await client.run('Build a REST API', {
296
+ * environmentId: 'env_xxx',
297
+ * onEvent: (event) => {
298
+ * if (event.type === 'response.item.completed') {
299
+ * console.log(event.item);
300
+ * }
301
+ * }
302
+ * });
303
+ *
304
+ * // Continue the conversation
305
+ * const followUp = await client.run('Add authentication', {
306
+ * environmentId: 'env_xxx',
307
+ * threadId: result.threadId
308
+ * });
309
+ * ```
310
+ */
311
+ run(task: string, options: RunOptions): Promise<RunResult>;
312
+ /**
313
+ * Quick setup with default environment
314
+ *
315
+ * Creates a default environment if none exists, returning both
316
+ * the project and environment ready for execution.
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * const { project, environment } = await client.quickSetup({
321
+ * internetAccess: true
322
+ * });
323
+ *
324
+ * // Ready to execute
325
+ * await client.run('Hello world!', {
326
+ * environmentId: environment.id
327
+ * });
328
+ * ```
329
+ */
330
+ quickSetup(options?: {
331
+ internetAccess?: boolean;
332
+ environmentName?: string;
333
+ }): Promise<{
334
+ project: Project;
335
+ environment: Environment;
336
+ }>;
337
+ /**
338
+ * Check API health status
339
+ */
340
+ health(): Promise<HealthCheck>;
341
+ /**
342
+ * Get API metrics
343
+ */
344
+ metrics(): Promise<Metrics>;
345
+ /**
346
+ * Get API base URL
347
+ */
348
+ getBaseUrl(): string;
349
+ }
350
+ /**
351
+ * @deprecated Use ComputerAgentsClient instead
352
+ */
353
+ export { ComputerAgentsClient as CloudClient };
354
+ /**
355
+ * @deprecated Use ComputerAgentsClient instead
356
+ */
357
+ export { ComputerAgentsClient as TestbaseClient };
@@ -0,0 +1,359 @@
1
+ "use strict";
2
+ /**
3
+ * ComputerAgentsClient - The Official Computer Agents SDK
4
+ *
5
+ * A clean, simple SDK for interacting with the Computer Agents Cloud API.
6
+ * This SDK provides typed access to all API resources with streaming support.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { ComputerAgentsClient } from 'computer-agents';
11
+ *
12
+ * const client = new ComputerAgentsClient({
13
+ * apiKey: process.env.COMPUTER_AGENTS_API_KEY
14
+ * });
15
+ *
16
+ * // Execute a task (simplest usage)
17
+ * const result = await client.run('Create a REST API with Flask', {
18
+ * environmentId: 'env_xxx',
19
+ * onEvent: (event) => console.log(event.type)
20
+ * });
21
+ *
22
+ * // Or use the thread API for multi-turn conversations
23
+ * const thread = await client.threads.create({
24
+ * environmentId: 'env_xxx'
25
+ * });
26
+ *
27
+ * const response = await client.threads.sendMessage(thread.id, {
28
+ * content: 'Create a REST API',
29
+ * onEvent: (event) => console.log(event)
30
+ * });
31
+ * ```
32
+ */
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.TestbaseClient = exports.CloudClient = exports.ComputerAgentsClient = exports.ApiClientError = void 0;
35
+ const ApiClient_1 = require("./cloud/ApiClient");
36
+ Object.defineProperty(exports, "ApiClientError", { enumerable: true, get: function () { return ApiClient_1.ApiClientError; } });
37
+ const resources_1 = require("./cloud/resources");
38
+ /**
39
+ * ComputerAgentsClient - Complete SDK for Computer Agents Cloud API
40
+ *
41
+ * This is the main entry point for the SDK. It provides access to all API
42
+ * resources through typed methods:
43
+ *
44
+ * - `threads` - Conversation management with SSE streaming
45
+ * - `environments` - Environment configuration and container lifecycle
46
+ * - `agents` - Agent configuration
47
+ * - `files` - File management (via projects resource)
48
+ * - `schedules` - Scheduled task management
49
+ * - `billing` - Budget and usage tracking
50
+ * - `git` - Git operations on workspaces
51
+ *
52
+ * For simple use cases, use the `run()` method which handles thread
53
+ * creation and streaming automatically.
54
+ */
55
+ class ComputerAgentsClient {
56
+ /**
57
+ * Low-level API client (for advanced usage)
58
+ * @internal
59
+ */
60
+ api;
61
+ /**
62
+ * Thread (conversation) management
63
+ *
64
+ * Create threads for multi-turn conversations with agents.
65
+ * Use sendMessage() for SSE streaming execution.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const thread = await client.threads.create({
70
+ * environmentId: 'env_xxx'
71
+ * });
72
+ *
73
+ * const result = await client.threads.sendMessage(thread.id, {
74
+ * content: 'Fix the TypeScript errors',
75
+ * onEvent: (event) => console.log(event)
76
+ * });
77
+ * ```
78
+ */
79
+ threads;
80
+ /**
81
+ * Environment management
82
+ *
83
+ * Create and manage isolated execution environments.
84
+ * Environments define variables, secrets, MCP servers, and setup scripts.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const env = await client.environments.create({
89
+ * name: 'production',
90
+ * internetAccess: true
91
+ * });
92
+ * ```
93
+ */
94
+ environments;
95
+ /**
96
+ * Agent configuration
97
+ *
98
+ * Create and manage agent configurations with models, instructions, and skills.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const agent = await client.agents.create({
103
+ * name: 'Code Assistant',
104
+ * model: 'gpt-4o',
105
+ * instructions: 'You are a helpful coding assistant.'
106
+ * });
107
+ * ```
108
+ */
109
+ agents;
110
+ /**
111
+ * File operations
112
+ *
113
+ * Upload, download, and manage files in environment workspaces.
114
+ * Files are scoped to environments.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * // List files in an environment
119
+ * const files = await client.files.listFiles('env_xxx');
120
+ *
121
+ * // Upload a file
122
+ * await client.files.uploadFile({
123
+ * environmentId: 'env_xxx',
124
+ * filename: 'app.py',
125
+ * path: 'src',
126
+ * content: 'print("hello")'
127
+ * });
128
+ *
129
+ * // Download a file
130
+ * const content = await client.files.getFile('env_xxx', 'src/app.py');
131
+ *
132
+ * // Delete a file
133
+ * await client.files.deleteFile('env_xxx', 'src/app.py');
134
+ *
135
+ * // Move/rename a file
136
+ * await client.files.moveFile({
137
+ * environmentId: 'env_xxx',
138
+ * sourcePath: 'old.py',
139
+ * destPath: 'new.py'
140
+ * });
141
+ * ```
142
+ */
143
+ files;
144
+ /**
145
+ * Scheduled tasks
146
+ *
147
+ * Create and manage scheduled task execution.
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const schedule = await client.schedules.create({
152
+ * name: 'Daily Report',
153
+ * agentId: 'agent_xxx',
154
+ * agentName: 'Reporter',
155
+ * task: 'Generate daily report',
156
+ * scheduleType: 'recurring',
157
+ * cronExpression: '0 9 * * *'
158
+ * });
159
+ * ```
160
+ */
161
+ schedules;
162
+ /**
163
+ * Budget management
164
+ *
165
+ * Check and manage execution budgets.
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * const status = await client.budget.getStatus();
170
+ * const canRun = await client.budget.canExecute();
171
+ * ```
172
+ */
173
+ budget;
174
+ /**
175
+ * Billing and usage
176
+ *
177
+ * Access billing records and usage statistics.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const stats = await client.billing.getStats({ period: 'month' });
182
+ * const records = await client.billing.listRecords({ limit: 10 });
183
+ * ```
184
+ */
185
+ billing;
186
+ /**
187
+ * Git operations
188
+ *
189
+ * Perform git operations on cloud workspaces.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * const diff = await client.git.diff('env_xxx');
194
+ * await client.git.commit('env_xxx', { message: 'Add feature' });
195
+ * await client.git.push('env_xxx');
196
+ * ```
197
+ */
198
+ git;
199
+ /**
200
+ * Run tracking (internal)
201
+ * @internal
202
+ */
203
+ runs;
204
+ /**
205
+ * Project access (internal - use files for file operations)
206
+ * @internal
207
+ */
208
+ projects;
209
+ constructor(config = {}) {
210
+ // Get API key from config or environment variable
211
+ const apiKey = config.apiKey
212
+ || process.env.COMPUTER_AGENTS_API_KEY
213
+ || process.env.TESTBASE_API_KEY;
214
+ if (!apiKey) {
215
+ throw new Error('ComputerAgentsClient requires an API key. Provide it via:\n' +
216
+ '1. Constructor: new ComputerAgentsClient({ apiKey: "..." })\n' +
217
+ '2. Environment variable: COMPUTER_AGENTS_API_KEY');
218
+ }
219
+ // Create low-level API client
220
+ this.api = new ApiClient_1.ApiClient({
221
+ apiKey,
222
+ baseUrl: config.baseUrl,
223
+ timeout: config.timeout,
224
+ debug: config.debug,
225
+ });
226
+ // Initialize all resource managers
227
+ this.threads = new resources_1.ThreadsResource(this.api);
228
+ this.environments = new resources_1.EnvironmentsResource(this.api);
229
+ this.agents = new resources_1.AgentsResource(this.api);
230
+ this.files = new resources_1.FilesResource(this.api);
231
+ this.schedules = new resources_1.SchedulesResource(this.api);
232
+ this.budget = new resources_1.BudgetResource(this.api);
233
+ this.billing = new resources_1.BillingResource(this.api);
234
+ this.git = new resources_1.GitResource(this.api);
235
+ this.runs = new resources_1.RunsResource(this.api);
236
+ this.projects = new resources_1.ProjectsResource(this.api);
237
+ }
238
+ // =========================================================================
239
+ // High-Level Convenience Methods
240
+ // =========================================================================
241
+ /**
242
+ * Execute a task with automatic thread management
243
+ *
244
+ * This is the simplest way to run an agent task. It handles:
245
+ * - Creating a thread (if threadId not provided)
246
+ * - Sending the message with SSE streaming
247
+ * - Returning the result with thread ID for follow-ups
248
+ *
249
+ * @param task - The task to execute (e.g., "Create a REST API with Flask")
250
+ * @param options - Execution options including environmentId (required)
251
+ * @returns The execution result with content and thread ID
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * // Simple one-shot execution
256
+ * const result = await client.run('Create hello.py', {
257
+ * environmentId: 'env_xxx'
258
+ * });
259
+ * console.log(result.content);
260
+ *
261
+ * // With streaming progress
262
+ * const result = await client.run('Build a REST API', {
263
+ * environmentId: 'env_xxx',
264
+ * onEvent: (event) => {
265
+ * if (event.type === 'response.item.completed') {
266
+ * console.log(event.item);
267
+ * }
268
+ * }
269
+ * });
270
+ *
271
+ * // Continue the conversation
272
+ * const followUp = await client.run('Add authentication', {
273
+ * environmentId: 'env_xxx',
274
+ * threadId: result.threadId
275
+ * });
276
+ * ```
277
+ */
278
+ async run(task, options) {
279
+ // Create or reuse thread
280
+ let threadId = options.threadId;
281
+ if (!threadId) {
282
+ const thread = await this.threads.create({
283
+ environmentId: options.environmentId,
284
+ });
285
+ threadId = thread.id;
286
+ }
287
+ // Send message and stream response
288
+ const result = await this.threads.sendMessage(threadId, {
289
+ content: task,
290
+ agentConfig: options.agentConfig,
291
+ onEvent: options.onEvent,
292
+ timeout: options.timeout,
293
+ });
294
+ return {
295
+ content: result.content,
296
+ threadId,
297
+ run: result.run,
298
+ };
299
+ }
300
+ /**
301
+ * Quick setup with default environment
302
+ *
303
+ * Creates a default environment if none exists, returning both
304
+ * the project and environment ready for execution.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * const { project, environment } = await client.quickSetup({
309
+ * internetAccess: true
310
+ * });
311
+ *
312
+ * // Ready to execute
313
+ * await client.run('Hello world!', {
314
+ * environmentId: environment.id
315
+ * });
316
+ * ```
317
+ */
318
+ async quickSetup(options = {}) {
319
+ // Get the project (bound to API key)
320
+ const project = await this.projects.get();
321
+ // Check for existing default environment
322
+ const environments = await this.environments.list();
323
+ let environment = environments.find(e => e.isDefault);
324
+ // Create default environment if none exists
325
+ if (!environment) {
326
+ environment = await this.environments.create({
327
+ name: options.environmentName || 'default',
328
+ internetAccess: options.internetAccess ?? true,
329
+ isDefault: true,
330
+ });
331
+ }
332
+ return { project, environment };
333
+ }
334
+ // =========================================================================
335
+ // Health & Monitoring
336
+ // =========================================================================
337
+ /**
338
+ * Check API health status
339
+ */
340
+ async health() {
341
+ return this.api.get('/health');
342
+ }
343
+ /**
344
+ * Get API metrics
345
+ */
346
+ async metrics() {
347
+ return this.api.get('/metrics');
348
+ }
349
+ /**
350
+ * Get API base URL
351
+ */
352
+ getBaseUrl() {
353
+ return this.api.getBaseUrl();
354
+ }
355
+ }
356
+ exports.ComputerAgentsClient = ComputerAgentsClient;
357
+ exports.CloudClient = ComputerAgentsClient;
358
+ exports.TestbaseClient = ComputerAgentsClient;
359
+ //# sourceMappingURL=ComputerAgentsClient.js.map