@agentorg/computer 0.0.0-stage → 0.0.2

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.
@@ -0,0 +1,479 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+
6
+ export interface paths {
7
+ "/v1/info": {
8
+ parameters: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ /** What this service is and how it isolates its computers. */
15
+ get: operations["getInfo"];
16
+ put?: never;
17
+ post?: never;
18
+ delete?: never;
19
+ options?: never;
20
+ head?: never;
21
+ patch?: never;
22
+ trace?: never;
23
+ };
24
+ "/v1/computers": {
25
+ parameters: {
26
+ query?: never;
27
+ header?: never;
28
+ path?: never;
29
+ cookie?: never;
30
+ };
31
+ /** List the computers. */
32
+ get: operations["listComputers"];
33
+ put?: never;
34
+ /** Create a computer. It answers once the computer is running. */
35
+ post: operations["createComputer"];
36
+ delete?: never;
37
+ options?: never;
38
+ head?: never;
39
+ patch?: never;
40
+ trace?: never;
41
+ };
42
+ "/v1/computers/{computerID}": {
43
+ parameters: {
44
+ query?: never;
45
+ header?: never;
46
+ path: {
47
+ computerID: components["parameters"]["computerID"];
48
+ };
49
+ cookie?: never;
50
+ };
51
+ /** One computer, with how long it has run and the tools it offers. */
52
+ get: operations["getComputer"];
53
+ put?: never;
54
+ post?: never;
55
+ /** Stop it for good and remove what the service made. A folder someone named stays. */
56
+ delete: operations["killComputer"];
57
+ options?: never;
58
+ head?: never;
59
+ patch?: never;
60
+ trace?: never;
61
+ };
62
+ "/v1/computers/{computerID}/timeout": {
63
+ parameters: {
64
+ query?: never;
65
+ header?: never;
66
+ path: {
67
+ computerID: components["parameters"]["computerID"];
68
+ };
69
+ cookie?: never;
70
+ };
71
+ get?: never;
72
+ put?: never;
73
+ /** It now stops this many seconds from now, replacing any earlier timeout. */
74
+ post: operations["setComputerTimeout"];
75
+ delete?: never;
76
+ options?: never;
77
+ head?: never;
78
+ patch?: never;
79
+ trace?: never;
80
+ };
81
+ "/v1/computers/{computerID}/stop": {
82
+ parameters: {
83
+ query?: never;
84
+ header?: never;
85
+ path: {
86
+ computerID: components["parameters"]["computerID"];
87
+ };
88
+ cookie?: never;
89
+ };
90
+ get?: never;
91
+ put?: never;
92
+ /** Stop what it is running. Its folder and its token stay, and it can start again. */
93
+ post: operations["stopComputer"];
94
+ delete?: never;
95
+ options?: never;
96
+ head?: never;
97
+ patch?: never;
98
+ trace?: never;
99
+ };
100
+ "/v1/computers/{computerID}/start": {
101
+ parameters: {
102
+ query?: never;
103
+ header?: never;
104
+ path: {
105
+ computerID: components["parameters"]["computerID"];
106
+ };
107
+ cookie?: never;
108
+ };
109
+ get?: never;
110
+ put?: never;
111
+ /** Start a stopped computer again, with the same token and folder. */
112
+ post: operations["startComputer"];
113
+ delete?: never;
114
+ options?: never;
115
+ head?: never;
116
+ patch?: never;
117
+ trace?: never;
118
+ };
119
+ "/v1/computers/{computerID}/logs": {
120
+ parameters: {
121
+ query?: never;
122
+ header?: never;
123
+ path: {
124
+ computerID: components["parameters"]["computerID"];
125
+ };
126
+ cookie?: never;
127
+ };
128
+ /** What its servers wrote, and each request it was sent. */
129
+ get: operations["getComputerLogs"];
130
+ put?: never;
131
+ post?: never;
132
+ delete?: never;
133
+ options?: never;
134
+ head?: never;
135
+ patch?: never;
136
+ trace?: never;
137
+ };
138
+ }
139
+ export type webhooks = Record<string, never>;
140
+ export interface components {
141
+ schemas: {
142
+ Error: {
143
+ code: number;
144
+ message: string;
145
+ };
146
+ /**
147
+ * @description How far it reaches into files and commands, each level containing the one before: `read` has read, list and search; `files` adds edit; `terminal` adds exec_command and write_stdin. Below terminal, the browser's code-running tool is hidden.
148
+ * @enum {string}
149
+ */
150
+ Access: "none" | "read" | "files" | "terminal";
151
+ /** @enum {string} */
152
+ ComputerState: "running" | "stopped" | "failed";
153
+ /** @description Seconds from now until the computer stops. */
154
+ Timeout: number;
155
+ /** @description Your own labels, kept and returned as given. */
156
+ Metadata: {
157
+ [key: string]: string;
158
+ };
159
+ NewComputer: {
160
+ name?: string;
161
+ access: components["schemas"]["Access"];
162
+ /**
163
+ * @description Whether it has a browser. With access none, it must.
164
+ * @default false
165
+ */
166
+ browser: boolean;
167
+ /** @description The full path of a folder that exists, on the service's machine. With none, the service makes a folder, which goes when the computer is killed. A folder named here never does. */
168
+ workspace?: string;
169
+ timeout?: components["schemas"]["Timeout"];
170
+ metadata?: components["schemas"]["Metadata"];
171
+ };
172
+ /** @description MCP over Streamable HTTP, each taking the computer's access token as a bearer. */
173
+ Endpoints: {
174
+ /** @description The terminal and files. */
175
+ computer: string | null;
176
+ /** @description The browser. */
177
+ browser: string | null;
178
+ };
179
+ Computer: {
180
+ computerID: string;
181
+ name: string;
182
+ state: components["schemas"]["ComputerState"];
183
+ access: components["schemas"]["Access"];
184
+ browser: boolean;
185
+ workspace: string | null;
186
+ /**
187
+ * Format: date-time
188
+ * @description When it last started.
189
+ */
190
+ startedAt: string;
191
+ /**
192
+ * Format: date-time
193
+ * @description When it will stop; null if it has no timeout.
194
+ */
195
+ endAt: string | null;
196
+ metadata: components["schemas"]["Metadata"];
197
+ endpoints: components["schemas"]["Endpoints"];
198
+ };
199
+ CreatedComputer: components["schemas"]["Computer"] & {
200
+ /** @description Good only for this computer's endpoints. Shown only now. */
201
+ accessToken: string;
202
+ };
203
+ ComputerDetail: components["schemas"]["Computer"] & {
204
+ uptimeSeconds: number;
205
+ tools: {
206
+ computer: string[];
207
+ browser: string[];
208
+ };
209
+ };
210
+ ComputerLogs: {
211
+ logs: {
212
+ /** Format: date-time */
213
+ timestamp: string;
214
+ line: string;
215
+ }[];
216
+ };
217
+ ServiceInfo: {
218
+ version: string;
219
+ /**
220
+ * @description How this service isolates its computers, chosen when it is started.
221
+ * @enum {string}
222
+ */
223
+ isolation: "none" | "container";
224
+ };
225
+ };
226
+ responses: {
227
+ /** @description It was refused. */
228
+ Error: {
229
+ headers: {
230
+ [name: string]: unknown;
231
+ };
232
+ content: {
233
+ "application/json": components["schemas"]["Error"];
234
+ };
235
+ };
236
+ /** @description No valid token. */
237
+ Unauthorized: {
238
+ headers: {
239
+ [name: string]: unknown;
240
+ };
241
+ content?: never;
242
+ };
243
+ };
244
+ parameters: {
245
+ computerID: string;
246
+ };
247
+ requestBodies: never;
248
+ headers: never;
249
+ pathItems: never;
250
+ }
251
+ export type $defs = Record<string, never>;
252
+ export interface operations {
253
+ getInfo: {
254
+ parameters: {
255
+ query?: never;
256
+ header?: never;
257
+ path?: never;
258
+ cookie?: never;
259
+ };
260
+ requestBody?: never;
261
+ responses: {
262
+ /** @description The service. */
263
+ 200: {
264
+ headers: {
265
+ [name: string]: unknown;
266
+ };
267
+ content: {
268
+ "application/json": components["schemas"]["ServiceInfo"];
269
+ };
270
+ };
271
+ 401: components["responses"]["Unauthorized"];
272
+ };
273
+ };
274
+ listComputers: {
275
+ parameters: {
276
+ query?: {
277
+ /** @description Only computers in this state. */
278
+ state?: components["schemas"]["ComputerState"];
279
+ };
280
+ header?: never;
281
+ path?: never;
282
+ cookie?: never;
283
+ };
284
+ requestBody?: never;
285
+ responses: {
286
+ /** @description The computers, newest first. */
287
+ 200: {
288
+ headers: {
289
+ [name: string]: unknown;
290
+ };
291
+ content: {
292
+ "application/json": components["schemas"]["Computer"][];
293
+ };
294
+ };
295
+ 401: components["responses"]["Unauthorized"];
296
+ };
297
+ };
298
+ createComputer: {
299
+ parameters: {
300
+ query?: never;
301
+ header?: never;
302
+ path?: never;
303
+ cookie?: never;
304
+ };
305
+ requestBody: {
306
+ content: {
307
+ "application/json": components["schemas"]["NewComputer"];
308
+ };
309
+ };
310
+ responses: {
311
+ /** @description The computer, with its access token, shown only now. */
312
+ 201: {
313
+ headers: {
314
+ [name: string]: unknown;
315
+ };
316
+ content: {
317
+ "application/json": components["schemas"]["CreatedComputer"];
318
+ };
319
+ };
320
+ 400: components["responses"]["Error"];
321
+ 401: components["responses"]["Unauthorized"];
322
+ };
323
+ };
324
+ getComputer: {
325
+ parameters: {
326
+ query?: never;
327
+ header?: never;
328
+ path: {
329
+ computerID: components["parameters"]["computerID"];
330
+ };
331
+ cookie?: never;
332
+ };
333
+ requestBody?: never;
334
+ responses: {
335
+ /** @description The computer. */
336
+ 200: {
337
+ headers: {
338
+ [name: string]: unknown;
339
+ };
340
+ content: {
341
+ "application/json": components["schemas"]["ComputerDetail"];
342
+ };
343
+ };
344
+ 401: components["responses"]["Unauthorized"];
345
+ 404: components["responses"]["Error"];
346
+ };
347
+ };
348
+ killComputer: {
349
+ parameters: {
350
+ query?: never;
351
+ header?: never;
352
+ path: {
353
+ computerID: components["parameters"]["computerID"];
354
+ };
355
+ cookie?: never;
356
+ };
357
+ requestBody?: never;
358
+ responses: {
359
+ /** @description Gone. */
360
+ 204: {
361
+ headers: {
362
+ [name: string]: unknown;
363
+ };
364
+ content?: never;
365
+ };
366
+ 401: components["responses"]["Unauthorized"];
367
+ 404: components["responses"]["Error"];
368
+ };
369
+ };
370
+ setComputerTimeout: {
371
+ parameters: {
372
+ query?: never;
373
+ header?: never;
374
+ path: {
375
+ computerID: components["parameters"]["computerID"];
376
+ };
377
+ cookie?: never;
378
+ };
379
+ requestBody: {
380
+ content: {
381
+ "application/json": {
382
+ timeout: components["schemas"]["Timeout"];
383
+ };
384
+ };
385
+ };
386
+ responses: {
387
+ /** @description The computer. */
388
+ 200: {
389
+ headers: {
390
+ [name: string]: unknown;
391
+ };
392
+ content: {
393
+ "application/json": components["schemas"]["Computer"];
394
+ };
395
+ };
396
+ 401: components["responses"]["Unauthorized"];
397
+ 404: components["responses"]["Error"];
398
+ 409: components["responses"]["Error"];
399
+ };
400
+ };
401
+ stopComputer: {
402
+ parameters: {
403
+ query?: never;
404
+ header?: never;
405
+ path: {
406
+ computerID: components["parameters"]["computerID"];
407
+ };
408
+ cookie?: never;
409
+ };
410
+ requestBody?: never;
411
+ responses: {
412
+ /** @description The computer. */
413
+ 200: {
414
+ headers: {
415
+ [name: string]: unknown;
416
+ };
417
+ content: {
418
+ "application/json": components["schemas"]["Computer"];
419
+ };
420
+ };
421
+ 401: components["responses"]["Unauthorized"];
422
+ 404: components["responses"]["Error"];
423
+ };
424
+ };
425
+ startComputer: {
426
+ parameters: {
427
+ query?: never;
428
+ header?: never;
429
+ path: {
430
+ computerID: components["parameters"]["computerID"];
431
+ };
432
+ cookie?: never;
433
+ };
434
+ requestBody?: {
435
+ content: {
436
+ "application/json": {
437
+ timeout?: components["schemas"]["Timeout"];
438
+ };
439
+ };
440
+ };
441
+ responses: {
442
+ /** @description The computer. */
443
+ 200: {
444
+ headers: {
445
+ [name: string]: unknown;
446
+ };
447
+ content: {
448
+ "application/json": components["schemas"]["Computer"];
449
+ };
450
+ };
451
+ 401: components["responses"]["Unauthorized"];
452
+ 404: components["responses"]["Error"];
453
+ };
454
+ };
455
+ getComputerLogs: {
456
+ parameters: {
457
+ query?: never;
458
+ header?: never;
459
+ path: {
460
+ computerID: components["parameters"]["computerID"];
461
+ };
462
+ cookie?: never;
463
+ };
464
+ requestBody?: never;
465
+ responses: {
466
+ /** @description The logs. */
467
+ 200: {
468
+ headers: {
469
+ [name: string]: unknown;
470
+ };
471
+ content: {
472
+ "application/json": components["schemas"]["ComputerLogs"];
473
+ };
474
+ };
475
+ 401: components["responses"]["Unauthorized"];
476
+ 404: components["responses"]["Error"];
477
+ };
478
+ };
479
+ }
@@ -0,0 +1,189 @@
1
+ import type { components } from "./generated/schema.js";
2
+ type Schemas = components["schemas"];
3
+ export type ComputerInfo = Schemas["Computer"];
4
+ export type ComputerDetail = Schemas["ComputerDetail"];
5
+ export type ServiceInfo = Schemas["ServiceInfo"];
6
+ export type ComputerLog = Schemas["ComputerLogs"]["logs"][number];
7
+ export interface ConnectionOpts {
8
+ /** The control token; `AGENTCOMPUTER_API_KEY` by default. */
9
+ apiKey?: string;
10
+ /** The service's address; `AGENTCOMPUTER_API_URL`, else `http://127.0.0.1:7878`. */
11
+ apiUrl?: string;
12
+ }
13
+ export interface CreateOpts extends ConnectionOpts {
14
+ access: Schemas["Access"];
15
+ browser?: boolean;
16
+ workspace?: string;
17
+ name?: string;
18
+ /** How long until it stops, in milliseconds. By default it doesn't. */
19
+ timeoutMs?: number;
20
+ metadata?: Record<string, string>;
21
+ }
22
+ export interface CommandResult {
23
+ exitCode: number;
24
+ output: string;
25
+ seconds: number;
26
+ }
27
+ export interface RunningCommand {
28
+ sessionId: string;
29
+ output: string;
30
+ }
31
+ /** The service refused, or a computer's tool failed. */
32
+ export declare class ComputerError extends Error {
33
+ readonly code: number;
34
+ constructor(code: number, message: string);
35
+ }
36
+ /** What the command tools answer. */
37
+ interface CommandAnswer {
38
+ exit_code: number | null;
39
+ seconds: number;
40
+ session_id: string | null;
41
+ text: string;
42
+ }
43
+ /** An MCP client for one endpoint, connected when first used. */
44
+ declare class Endpoint {
45
+ #private;
46
+ constructor(url: string | null, token: string);
47
+ text(name: string, args: Record<string, unknown>): Promise<string>;
48
+ command(name: string, args: Record<string, unknown>): Promise<CommandAnswer>;
49
+ close(): Promise<void>;
50
+ }
51
+ /** Commands on a computer with the terminal level. */
52
+ declare class Commands {
53
+ #private;
54
+ constructor(endpoint: Endpoint);
55
+ /** Run a command to its end. */
56
+ run(cmd: string, opts?: {
57
+ cwd?: string;
58
+ }): Promise<CommandResult>;
59
+ /** Start a command and return while it runs, unless it ends at once. */
60
+ run(cmd: string, opts: {
61
+ cwd?: string;
62
+ background: true;
63
+ }): Promise<RunningCommand | CommandResult>;
64
+ /** Type into a running command, and return what it wrote since. */
65
+ sendStdin(sessionId: string, data: string): Promise<string>;
66
+ }
67
+ /** Files in a computer's workspace. */
68
+ declare class Files {
69
+ #private;
70
+ constructor(endpoint: Endpoint);
71
+ /** A text file's content, whole: a line too long for the tool to return is an error. */
72
+ read(path: string): Promise<string>;
73
+ /** Make a new file, or fill an empty one. */
74
+ write(path: string, content: string): Promise<void>;
75
+ /** Replace exact text, and return the unified diff. */
76
+ edit(path: string, oldText: string, newText: string, opts?: {
77
+ replaceAll?: boolean;
78
+ }): Promise<string>;
79
+ /** A folder's entries, the first thousand. */
80
+ list(path?: string): Promise<({
81
+ name: string;
82
+ type: "dir";
83
+ size?: undefined;
84
+ } | {
85
+ name: string;
86
+ type: "file";
87
+ size: number;
88
+ })[]>;
89
+ /** Lines matching text under a folder, as `path:line:text`. */
90
+ search(pattern: string, opts?: {
91
+ path?: string;
92
+ regex?: boolean;
93
+ }): Promise<string[]>;
94
+ }
95
+ /** One computer. Make one with `Computer.create`. */
96
+ export declare class Computer {
97
+ #private;
98
+ readonly computerID: string;
99
+ readonly commands: Commands;
100
+ readonly files: Files;
101
+ private constructor();
102
+ static create(opts: CreateOpts): Promise<Computer>;
103
+ /** A computer made earlier. Its token was shown when it was made, and only then. */
104
+ static connect(computerID: string, opts: ConnectionOpts & {
105
+ accessToken: string;
106
+ }): Promise<Computer>;
107
+ static list(opts?: ConnectionOpts & {
108
+ state?: Schemas["ComputerState"];
109
+ }): Promise<ComputerInfo[]>;
110
+ static serviceInfo(opts?: ConnectionOpts): Promise<ServiceInfo>;
111
+ static getInfo(computerID: string, opts?: ConnectionOpts): Promise<ComputerDetail>;
112
+ /** It now stops this long from now, replacing any earlier timeout. */
113
+ static setTimeout(computerID: string, timeoutMs: number, opts?: ConnectionOpts): Promise<ComputerInfo>;
114
+ static stop(computerID: string, opts?: ConnectionOpts): Promise<ComputerInfo>;
115
+ static start(computerID: string, opts?: ConnectionOpts & {
116
+ timeoutMs?: number;
117
+ }): Promise<ComputerInfo>;
118
+ static getLogs(computerID: string, opts?: ConnectionOpts): Promise<ComputerLog[]>;
119
+ static kill(computerID: string, opts?: ConnectionOpts): Promise<void>;
120
+ /** The endpoint to give an MCP client. */
121
+ getMcpUrl(endpoint?: "computer" | "browser"): string;
122
+ /** The token for those endpoints. */
123
+ getMcpToken(): string;
124
+ getInfo(): Promise<{
125
+ computerID: string;
126
+ name: string;
127
+ state: components["schemas"]["ComputerState"];
128
+ access: components["schemas"]["Access"];
129
+ browser: boolean;
130
+ workspace: string | null;
131
+ startedAt: string;
132
+ endAt: string | null;
133
+ metadata: components["schemas"]["Metadata"];
134
+ endpoints: components["schemas"]["Endpoints"];
135
+ } & {
136
+ uptimeSeconds: number;
137
+ tools: {
138
+ computer: string[];
139
+ browser: string[];
140
+ };
141
+ }>;
142
+ isRunning(): Promise<boolean>;
143
+ setTimeout(timeoutMs: number): Promise<{
144
+ computerID: string;
145
+ name: string;
146
+ state: components["schemas"]["ComputerState"];
147
+ access: components["schemas"]["Access"];
148
+ browser: boolean;
149
+ workspace: string | null;
150
+ startedAt: string;
151
+ endAt: string | null;
152
+ metadata: components["schemas"]["Metadata"];
153
+ endpoints: components["schemas"]["Endpoints"];
154
+ }>;
155
+ stop(): Promise<{
156
+ computerID: string;
157
+ name: string;
158
+ state: components["schemas"]["ComputerState"];
159
+ access: components["schemas"]["Access"];
160
+ browser: boolean;
161
+ workspace: string | null;
162
+ startedAt: string;
163
+ endAt: string | null;
164
+ metadata: components["schemas"]["Metadata"];
165
+ endpoints: components["schemas"]["Endpoints"];
166
+ }>;
167
+ start(opts?: {
168
+ timeoutMs?: number;
169
+ }): Promise<{
170
+ computerID: string;
171
+ name: string;
172
+ state: components["schemas"]["ComputerState"];
173
+ access: components["schemas"]["Access"];
174
+ browser: boolean;
175
+ workspace: string | null;
176
+ startedAt: string;
177
+ endAt: string | null;
178
+ metadata: components["schemas"]["Metadata"];
179
+ endpoints: components["schemas"]["Endpoints"];
180
+ }>;
181
+ getLogs(): Promise<{
182
+ timestamp: string;
183
+ line: string;
184
+ }[]>;
185
+ kill(): Promise<void>;
186
+ /** Close this object's connection. The computer keeps running. */
187
+ close(): Promise<void>;
188
+ }
189
+ export {};