@finalai/computers 0.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.
Potentially problematic release.
This version of @finalai/computers might be problematic. Click here for more details.
- package/README.md +16 -0
- package/dist/modules/browser-access.d.mts +18 -0
- package/dist/modules/browser-access.mjs +22 -0
- package/dist/modules/browser-access.mjs.map +7 -0
- package/dist/modules/client.d.mts +5 -0
- package/dist/modules/client.mjs +764 -0
- package/dist/modules/client.mjs.map +7 -0
- package/dist/modules/file-snapshots.d.mts +69 -0
- package/dist/modules/file-snapshots.mjs +64 -0
- package/dist/modules/file-snapshots.mjs.map +7 -0
- package/dist/modules/index.d.mts +11 -0
- package/dist/modules/index.mjs +63 -0
- package/dist/modules/index.mjs.map +7 -0
- package/dist/modules/json.d.mts +5 -0
- package/dist/modules/json.mjs +8 -0
- package/dist/modules/json.mjs.map +7 -0
- package/dist/modules/normalize.d.mts +7 -0
- package/dist/modules/normalize.mjs +210 -0
- package/dist/modules/normalize.mjs.map +7 -0
- package/dist/modules/result.d.mts +13 -0
- package/dist/modules/result.mjs +14 -0
- package/dist/modules/result.mjs.map +7 -0
- package/dist/modules/screen.d.mts +41 -0
- package/dist/modules/screen.mjs +37 -0
- package/dist/modules/screen.mjs.map +7 -0
- package/dist/modules/shell.d.mts +1 -0
- package/dist/modules/shell.mjs +5 -0
- package/dist/modules/shell.mjs.map +7 -0
- package/dist/modules/transport-api.d.mts +2 -0
- package/dist/modules/transport-api.mjs +7 -0
- package/dist/modules/transport-api.mjs.map +7 -0
- package/dist/modules/transport.d.mts +15 -0
- package/dist/modules/transport.mjs +67 -0
- package/dist/modules/transport.mjs.map +7 -0
- package/dist/modules/types.d.mts +467 -0
- package/dist/modules/types.mjs +69 -0
- package/dist/modules/types.mjs.map +7 -0
- package/package.json +52 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import type { ComputerScreenOpenOptionsIface, ComputerScreenSessionIface } from "./screen.mjs";
|
|
2
|
+
import type { ComputerBrowserAccessIface, ComputerBrowserAccessOptionsIface } from "./browser-access.mjs";
|
|
3
|
+
import type { ResultIface } from "./result.mjs";
|
|
4
|
+
import type { ComputerSnapshotRequestIface, ComputerSnapshotResponseIface } from "./file-snapshots.mjs";
|
|
5
|
+
import type { JsonObject } from "./json.mjs";
|
|
6
|
+
export declare enum ComputerState {
|
|
7
|
+
Unknown = 0,
|
|
8
|
+
Pending = 1,
|
|
9
|
+
Creating = 2,
|
|
10
|
+
Running = 3,
|
|
11
|
+
Paused = 4,
|
|
12
|
+
Stopped = 5,
|
|
13
|
+
Resuming = 6,
|
|
14
|
+
Error = 8,
|
|
15
|
+
Deleted = 9,
|
|
16
|
+
Shelved = 10
|
|
17
|
+
}
|
|
18
|
+
export declare enum ComputerCommandMode {
|
|
19
|
+
Auto = 1,
|
|
20
|
+
None = 2,
|
|
21
|
+
Custom = 3
|
|
22
|
+
}
|
|
23
|
+
export declare enum ComputerIdlePolicy {
|
|
24
|
+
Shelve = "shelve",
|
|
25
|
+
Pause = "pause",
|
|
26
|
+
Delete = "delete"
|
|
27
|
+
}
|
|
28
|
+
export declare enum ComputerImageState {
|
|
29
|
+
Pending = "pending",
|
|
30
|
+
Building = "building",
|
|
31
|
+
Ready = "ready",
|
|
32
|
+
Failed = "failed",
|
|
33
|
+
Expired = "expired"
|
|
34
|
+
}
|
|
35
|
+
export declare enum ComputerImageSource {
|
|
36
|
+
Platform = "platform",
|
|
37
|
+
Customer = "customer"
|
|
38
|
+
}
|
|
39
|
+
export declare enum ComputerEgressPolicy {
|
|
40
|
+
Internet = "internet",
|
|
41
|
+
None = "none",
|
|
42
|
+
Allowlist = "allowlist"
|
|
43
|
+
}
|
|
44
|
+
export declare enum ComputerBaseState {
|
|
45
|
+
Capturing = "capturing",
|
|
46
|
+
Ready = "ready",
|
|
47
|
+
Failed = "failed",
|
|
48
|
+
Expired = "expired"
|
|
49
|
+
}
|
|
50
|
+
export interface ComputerApiKeyAuthIface {
|
|
51
|
+
apiKey: string;
|
|
52
|
+
}
|
|
53
|
+
export type ComputerClientAuth = ComputerApiKeyAuthIface;
|
|
54
|
+
export interface LifecycleActionOptionsIface {
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
}
|
|
57
|
+
export interface CreateComputerClientArgsIface {
|
|
58
|
+
baseUrl: string;
|
|
59
|
+
auth: ComputerClientAuth;
|
|
60
|
+
requestTimeoutMs?: number;
|
|
61
|
+
fetch?: typeof fetch;
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
}
|
|
64
|
+
export interface ComputerInfoIface {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
teamId: string | null;
|
|
68
|
+
ownerUserId: string | null;
|
|
69
|
+
state: ComputerState;
|
|
70
|
+
stateName: string | null;
|
|
71
|
+
desiredState: number | null;
|
|
72
|
+
image: string | null;
|
|
73
|
+
imageVersionId: string | null;
|
|
74
|
+
regionSlug: string | null;
|
|
75
|
+
vcpu: number | null;
|
|
76
|
+
memoryMb: number | null;
|
|
77
|
+
diskGb: number | null;
|
|
78
|
+
httpPort: number | null;
|
|
79
|
+
httpPublic: boolean;
|
|
80
|
+
ephemeral: boolean;
|
|
81
|
+
idleTimeoutSeconds: number | null;
|
|
82
|
+
autoResume: boolean;
|
|
83
|
+
tags: string[];
|
|
84
|
+
comment: string | null;
|
|
85
|
+
errorMessage: string | null;
|
|
86
|
+
hostname: string | null;
|
|
87
|
+
createdAt: string | null;
|
|
88
|
+
lastActiveAt: string | null;
|
|
89
|
+
startupTimings: JsonObject;
|
|
90
|
+
legacyBackupCheckpoint: JsonObject | null;
|
|
91
|
+
storageCheckpointCompletedAtMs: number | null;
|
|
92
|
+
}
|
|
93
|
+
export interface CreateComputerBaseOptsIface {
|
|
94
|
+
name?: string;
|
|
95
|
+
/** Create a team-owned computer. Omit to create a private computer for the acting user. */
|
|
96
|
+
teamId?: string;
|
|
97
|
+
regionSlug?: string;
|
|
98
|
+
vcpu?: number;
|
|
99
|
+
memoryMb?: number;
|
|
100
|
+
diskGb?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Size of the user volume holding /home/user and /workspaces. Omit for the
|
|
103
|
+
* tier default on computers that retain state; null for none.
|
|
104
|
+
*/
|
|
105
|
+
userVolumeGb?: number | null;
|
|
106
|
+
env?: Record<string, string>;
|
|
107
|
+
setupScript?: string;
|
|
108
|
+
commandMode?: ComputerCommandMode;
|
|
109
|
+
customCommand?: string;
|
|
110
|
+
httpPort?: number;
|
|
111
|
+
httpPublic?: boolean;
|
|
112
|
+
ephemeral?: boolean;
|
|
113
|
+
idleTimeoutSeconds?: number;
|
|
114
|
+
/**
|
|
115
|
+
* What happens after idleTimeoutSeconds: shelve (default), pause, or delete.
|
|
116
|
+
*/
|
|
117
|
+
idlePolicy?: ComputerIdlePolicy;
|
|
118
|
+
/** Outbound network: internet, none, or an exact DNS/IPv4/CIDR allowlist. */
|
|
119
|
+
network?: {
|
|
120
|
+
egress: ComputerEgressPolicy;
|
|
121
|
+
allow?: string[];
|
|
122
|
+
};
|
|
123
|
+
terminationGraceSeconds?: number;
|
|
124
|
+
autoResume?: boolean;
|
|
125
|
+
tags?: string[];
|
|
126
|
+
comment?: string;
|
|
127
|
+
/** Sent as the Idempotency-Key header, never in the body. */
|
|
128
|
+
idempotencyKey?: string;
|
|
129
|
+
}
|
|
130
|
+
/** Create from a ready image version (`cimv_…`), registered with `registerImage`. */
|
|
131
|
+
export interface CreateComputerFromImageVersionOptsIface extends CreateComputerBaseOptsIface {
|
|
132
|
+
imageVersionId: string;
|
|
133
|
+
baseId?: never;
|
|
134
|
+
image?: never;
|
|
135
|
+
lineage?: never;
|
|
136
|
+
registryCredentialId?: never;
|
|
137
|
+
}
|
|
138
|
+
/** API keys: create from a ready base (`part_…`), captured with `captureComputer`. */
|
|
139
|
+
export interface CreateComputerFromBaseOptsIface extends CreateComputerBaseOptsIface {
|
|
140
|
+
baseId: string;
|
|
141
|
+
imageVersionId?: never;
|
|
142
|
+
image?: never;
|
|
143
|
+
lineage?: never;
|
|
144
|
+
registryCredentialId?: never;
|
|
145
|
+
projectArtifact?: never;
|
|
146
|
+
}
|
|
147
|
+
export type CreateComputerOptsIface = CreateComputerFromImageVersionOptsIface | CreateComputerFromBaseOptsIface;
|
|
148
|
+
export interface ComputerImageIface {
|
|
149
|
+
id: string;
|
|
150
|
+
/** Platform images are built by each release; customer ones by registerImage. */
|
|
151
|
+
source: ComputerImageSource;
|
|
152
|
+
reference: string;
|
|
153
|
+
lineage: string;
|
|
154
|
+
digest: string;
|
|
155
|
+
state: ComputerImageState;
|
|
156
|
+
error: string | null;
|
|
157
|
+
sizes: string[];
|
|
158
|
+
registryCredentialId: string | null;
|
|
159
|
+
createdAt: string | null;
|
|
160
|
+
readyAt: string | null;
|
|
161
|
+
lastUsedAt: string | null;
|
|
162
|
+
}
|
|
163
|
+
export interface ComputerBaseIface {
|
|
164
|
+
id: string;
|
|
165
|
+
state: ComputerBaseState;
|
|
166
|
+
error: string | null;
|
|
167
|
+
computerId: string | null;
|
|
168
|
+
image: string;
|
|
169
|
+
digest: string;
|
|
170
|
+
diskGb: number | null;
|
|
171
|
+
createdAt: string | null;
|
|
172
|
+
readyAt: string | null;
|
|
173
|
+
lastUsedAt: string | null;
|
|
174
|
+
/** Remains available until retention is released explicitly. */
|
|
175
|
+
retained: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface RegisterImageOptsIface {
|
|
178
|
+
reference: string;
|
|
179
|
+
/** A stored credential for the image's registry. */
|
|
180
|
+
registryCredentialId?: string;
|
|
181
|
+
/** Stored for the registration; deleted once nothing uses it. */
|
|
182
|
+
registryCredential?: {
|
|
183
|
+
username: string;
|
|
184
|
+
password: string;
|
|
185
|
+
};
|
|
186
|
+
/** Machine tier names to build for; defaults to ['standard']. */
|
|
187
|
+
sizes?: string[];
|
|
188
|
+
/** Sent as the Idempotency-Key header (API keys only), never in the body. */
|
|
189
|
+
idempotencyKey?: string;
|
|
190
|
+
}
|
|
191
|
+
export interface ListImagesOptsIface {
|
|
192
|
+
lineage?: string;
|
|
193
|
+
state?: ComputerImageState;
|
|
194
|
+
}
|
|
195
|
+
export interface ComputerUseStatusIface {
|
|
196
|
+
available: boolean;
|
|
197
|
+
installed: boolean;
|
|
198
|
+
}
|
|
199
|
+
export interface ComputerUseOpenOptsIface {
|
|
200
|
+
cwd?: string;
|
|
201
|
+
readyTimeoutMs?: number;
|
|
202
|
+
}
|
|
203
|
+
export interface ExecProcessOptsIface {
|
|
204
|
+
/** False refuses a sleeping computer instead of automatically waking it. */
|
|
205
|
+
autoResume?: boolean;
|
|
206
|
+
env?: Record<string, string>;
|
|
207
|
+
cwd?: string;
|
|
208
|
+
user?: string;
|
|
209
|
+
pty?: boolean;
|
|
210
|
+
cols?: number;
|
|
211
|
+
rows?: number;
|
|
212
|
+
/** Explicit process lifetime timeout. Waiting for output has its own timeout. */
|
|
213
|
+
timeoutMs?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface ProcessWaitResultIface {
|
|
216
|
+
exitCode: number | null;
|
|
217
|
+
signal: string | null;
|
|
218
|
+
}
|
|
219
|
+
export interface ComputerProcessIface {
|
|
220
|
+
id: string;
|
|
221
|
+
bootId: string;
|
|
222
|
+
command: string;
|
|
223
|
+
leaderPid: number | null;
|
|
224
|
+
state: 'running' | 'exited';
|
|
225
|
+
keepsAwake: boolean;
|
|
226
|
+
createdAtMs: number;
|
|
227
|
+
updatedAtMs: number;
|
|
228
|
+
endedAtMs: number | null;
|
|
229
|
+
cpuUsec: number;
|
|
230
|
+
memoryBytes: number;
|
|
231
|
+
memoryPeakBytes: number;
|
|
232
|
+
ioReadBytes: number;
|
|
233
|
+
ioWriteBytes: number;
|
|
234
|
+
processCount: number;
|
|
235
|
+
descendantCount?: number;
|
|
236
|
+
}
|
|
237
|
+
export interface ProcessOutputChunkIface {
|
|
238
|
+
data: string;
|
|
239
|
+
/** Raw output bytes for incremental decoding across UTF-8 chunk boundaries. */
|
|
240
|
+
dataBytes: Uint8Array;
|
|
241
|
+
offset: number;
|
|
242
|
+
nextOffset: number;
|
|
243
|
+
eof: boolean;
|
|
244
|
+
state: 'running' | 'exited';
|
|
245
|
+
}
|
|
246
|
+
export interface ProcessOutputIface {
|
|
247
|
+
read: (opts?: {
|
|
248
|
+
offset?: number;
|
|
249
|
+
waitMs?: number;
|
|
250
|
+
}) => Promise<ResultIface<ProcessOutputChunkIface>>;
|
|
251
|
+
}
|
|
252
|
+
export interface ReadProcessOutputOptsIface {
|
|
253
|
+
stdoutOffset: number;
|
|
254
|
+
stderrOffset: number;
|
|
255
|
+
waitMs?: number;
|
|
256
|
+
}
|
|
257
|
+
export interface ProcessOutputBatchIface {
|
|
258
|
+
stdout: ProcessOutputChunkIface;
|
|
259
|
+
stderr: ProcessOutputChunkIface;
|
|
260
|
+
state: 'running' | 'exited';
|
|
261
|
+
result: ProcessWaitResultIface | null;
|
|
262
|
+
}
|
|
263
|
+
export interface RunCommandOptsIface {
|
|
264
|
+
/** False refuses a sleeping computer instead of automatically waking it. */
|
|
265
|
+
autoResume?: boolean;
|
|
266
|
+
env?: Record<string, string>;
|
|
267
|
+
cwd?: string;
|
|
268
|
+
user?: string;
|
|
269
|
+
/** Process lifetime timeout, enforced in the computer. */
|
|
270
|
+
timeoutMs?: number;
|
|
271
|
+
/** How long the request waits for the exit; at most 30 seconds, the default. */
|
|
272
|
+
waitMs?: number;
|
|
273
|
+
/** How long the service waits for the computer to be able to start the process. */
|
|
274
|
+
readyTimeoutMs?: number;
|
|
275
|
+
}
|
|
276
|
+
export interface ComputerRunIface {
|
|
277
|
+
/** The process, for reading more output or terminating it. */
|
|
278
|
+
process: ProcessHandleIface;
|
|
279
|
+
/**
|
|
280
|
+
* Output from offset zero. It is complete when `state` is `exited` and both streams
|
|
281
|
+
* are at `eof`; otherwise read on with `process.readOutput` from each `nextOffset`.
|
|
282
|
+
*/
|
|
283
|
+
output: ProcessOutputBatchIface;
|
|
284
|
+
/** The computer killed the process at its `timeoutMs`. */
|
|
285
|
+
timedOut: boolean;
|
|
286
|
+
/** How long the process had been running when this answer was made. */
|
|
287
|
+
elapsedMs: number;
|
|
288
|
+
}
|
|
289
|
+
export interface ProcessHandleIface {
|
|
290
|
+
id: string;
|
|
291
|
+
bootId: string;
|
|
292
|
+
pid: number | null;
|
|
293
|
+
state: 'running' | 'exited';
|
|
294
|
+
/** Stateless read of both streams and the exit result, using byte offsets. */
|
|
295
|
+
readOutput: (opts: ReadProcessOutputOptsIface) => Promise<ResultIface<ProcessOutputBatchIface>>;
|
|
296
|
+
stdout: ProcessOutputIface;
|
|
297
|
+
stderr: ProcessOutputIface;
|
|
298
|
+
wait: (opts?: {
|
|
299
|
+
timeoutMs?: number;
|
|
300
|
+
}) => Promise<ResultIface<ProcessWaitResultIface>>;
|
|
301
|
+
write: (data: string | Uint8Array) => Promise<ResultIface<{
|
|
302
|
+
ok: true;
|
|
303
|
+
}>>;
|
|
304
|
+
eof: () => Promise<ResultIface<{
|
|
305
|
+
ok: true;
|
|
306
|
+
}>>;
|
|
307
|
+
resize: (cols: number, rows: number) => Promise<ResultIface<{
|
|
308
|
+
ok: true;
|
|
309
|
+
}>>;
|
|
310
|
+
signal: (signal: string) => Promise<ResultIface<{
|
|
311
|
+
ok: true;
|
|
312
|
+
}>>;
|
|
313
|
+
terminate: () => Promise<ResultIface<{
|
|
314
|
+
ok: true;
|
|
315
|
+
}>>;
|
|
316
|
+
}
|
|
317
|
+
export interface ComputerFileWriteResultIface {
|
|
318
|
+
bytesWritten: number;
|
|
319
|
+
}
|
|
320
|
+
export interface ComputerSettingsPatchIface {
|
|
321
|
+
network?: {
|
|
322
|
+
egress: ComputerEgressPolicy;
|
|
323
|
+
allow?: string[];
|
|
324
|
+
};
|
|
325
|
+
name?: string;
|
|
326
|
+
vcpu?: number;
|
|
327
|
+
memoryMb?: number;
|
|
328
|
+
diskGb?: number;
|
|
329
|
+
httpPort?: number | null;
|
|
330
|
+
httpPublic?: boolean;
|
|
331
|
+
idleTimeoutSeconds?: number | null;
|
|
332
|
+
autoResume?: boolean;
|
|
333
|
+
tags?: string[];
|
|
334
|
+
comment?: string | null;
|
|
335
|
+
env?: Record<string, string>;
|
|
336
|
+
}
|
|
337
|
+
export interface ComputerProcessesIface {
|
|
338
|
+
list: () => Promise<ResultIface<ComputerProcessIface[]>>;
|
|
339
|
+
get: (id: string, bootId: string) => Promise<ResultIface<ProcessHandleIface>>;
|
|
340
|
+
}
|
|
341
|
+
export interface ComputerFilesIface {
|
|
342
|
+
/** Read a committed sleeping workspace without waking it. Pin subsequent reads by generation. */
|
|
343
|
+
snapshot: (request: ComputerSnapshotRequestIface) => Promise<ResultIface<ComputerSnapshotResponseIface>>;
|
|
344
|
+
/** Reads the whole file as UTF-8 text, in ranged requests. */
|
|
345
|
+
read: (path: string, options?: {
|
|
346
|
+
autoResume?: boolean;
|
|
347
|
+
}) => Promise<ResultIface<string>>;
|
|
348
|
+
/** Reads the whole file as bytes, in ranged requests. */
|
|
349
|
+
readBytes: (path: string, options?: {
|
|
350
|
+
autoResume?: boolean;
|
|
351
|
+
}) => Promise<ResultIface<Uint8Array>>;
|
|
352
|
+
/** Replaces the file. Data over one chunk is appended in order, so a failure can leave a prefix. */
|
|
353
|
+
write: (path: string, data: string | Uint8Array) => Promise<ResultIface<ComputerFileWriteResultIface>>;
|
|
354
|
+
}
|
|
355
|
+
export declare enum ComputerTokenScope {
|
|
356
|
+
/** The public API, within the token's organization or computer. */
|
|
357
|
+
Api = "api",
|
|
358
|
+
/** The computer's HTTP ports through the gateway, never the API. */
|
|
359
|
+
Http = "http",
|
|
360
|
+
Screen = "screen",
|
|
361
|
+
ScreenControl = "screen:control"
|
|
362
|
+
}
|
|
363
|
+
export interface CreateTokenOptsIface {
|
|
364
|
+
name: string;
|
|
365
|
+
/** Confines the token to one computer. Without it the token covers the organization. */
|
|
366
|
+
computerId?: string;
|
|
367
|
+
/** Omit for a full-access token. */
|
|
368
|
+
scopes?: ComputerTokenScope[];
|
|
369
|
+
expiresAt?: Date;
|
|
370
|
+
}
|
|
371
|
+
export interface ComputerTokenIface {
|
|
372
|
+
id: string;
|
|
373
|
+
/** Returned once; send as `Authorization: Bearer <token>`. */
|
|
374
|
+
token: string;
|
|
375
|
+
}
|
|
376
|
+
export interface CreatePreviewTokenOptsIface {
|
|
377
|
+
name?: string;
|
|
378
|
+
/** Defaults to one hour from now. */
|
|
379
|
+
expiresAt?: Date;
|
|
380
|
+
}
|
|
381
|
+
export interface ComputerHandleIface {
|
|
382
|
+
browserAccess: {
|
|
383
|
+
open(options: ComputerBrowserAccessOptionsIface): Promise<ResultIface<ComputerBrowserAccessIface>>;
|
|
384
|
+
close(tokenId: string): Promise<ResultIface<{
|
|
385
|
+
ok: boolean;
|
|
386
|
+
}>>;
|
|
387
|
+
};
|
|
388
|
+
screen: {
|
|
389
|
+
status: () => Promise<ResultIface<{
|
|
390
|
+
available: boolean;
|
|
391
|
+
}>>;
|
|
392
|
+
open: (options?: ComputerScreenOpenOptionsIface) => Promise<ResultIface<ComputerScreenSessionIface>>;
|
|
393
|
+
};
|
|
394
|
+
computerUse: {
|
|
395
|
+
status(): Promise<ResultIface<ComputerUseStatusIface>>;
|
|
396
|
+
available(): Promise<ResultIface<boolean>>;
|
|
397
|
+
open(options?: ComputerUseOpenOptsIface): Promise<ResultIface<ProcessHandleIface>>;
|
|
398
|
+
};
|
|
399
|
+
id: string;
|
|
400
|
+
name: string;
|
|
401
|
+
getInfo: () => ComputerInfoIface;
|
|
402
|
+
refresh: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
403
|
+
refreshActivity: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
404
|
+
exec: (command: string, opts?: ExecProcessOptsIface) => Promise<ResultIface<ProcessHandleIface>>;
|
|
405
|
+
/**
|
|
406
|
+
* Runs a command with stdin closed and returns its output and exit in one request. Use
|
|
407
|
+
* `exec` for a process that reads stdin, needs a terminal, or outlives the call.
|
|
408
|
+
*/
|
|
409
|
+
run: (command: string, opts?: RunCommandOptsIface) => Promise<ResultIface<ComputerRunIface>>;
|
|
410
|
+
processes: ComputerProcessesIface;
|
|
411
|
+
files: ComputerFilesIface;
|
|
412
|
+
/** `hostname[:port]` from the computer's hostname; port 443 → bare hostname. Null until the computer has a hostname. */
|
|
413
|
+
getHost: (port: number) => string | null;
|
|
414
|
+
/**
|
|
415
|
+
* Mints a token that opens this computer's HTTP ports and nothing else: the API refuses
|
|
416
|
+
* it. Send it as `Authorization: Bearer <token>` to a `getHost` URL of a private computer.
|
|
417
|
+
*/
|
|
418
|
+
createPreviewToken: (opts?: CreatePreviewTokenOptsIface) => Promise<ResultIface<ComputerTokenIface>>;
|
|
419
|
+
pause: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
420
|
+
resume: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
421
|
+
start: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
422
|
+
stop: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
423
|
+
restart: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
424
|
+
/** Convenience alias: kill performs the delete lifecycle action. */
|
|
425
|
+
kill: () => Promise<ResultIface<ComputerInfoIface>>;
|
|
426
|
+
settings: (patch: ComputerSettingsPatchIface) => Promise<ResultIface<ComputerInfoIface>>;
|
|
427
|
+
}
|
|
428
|
+
export type ComputerConnectTarget = ({
|
|
429
|
+
id: string;
|
|
430
|
+
} | {
|
|
431
|
+
name: string;
|
|
432
|
+
}) & {
|
|
433
|
+
/**
|
|
434
|
+
* Resume paused, stopped, or shelved computers before returning a handle.
|
|
435
|
+
* Defaults to true. Set false for background work that must never wake a VM.
|
|
436
|
+
*/
|
|
437
|
+
resumeIfNeeded?: boolean;
|
|
438
|
+
};
|
|
439
|
+
export interface ComputerClientIface {
|
|
440
|
+
stopComputerRetained: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;
|
|
441
|
+
createComputer: (opts: CreateComputerOptsIface) => Promise<ResultIface<ComputerHandleIface>>;
|
|
442
|
+
connectComputer: (target: ComputerConnectTarget) => Promise<ResultIface<ComputerHandleIface>>;
|
|
443
|
+
pauseComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;
|
|
444
|
+
resumeComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;
|
|
445
|
+
stopComputer: (idOrName: string, options?: LifecycleActionOptionsIface) => Promise<ResultIface<ComputerInfoIface>>;
|
|
446
|
+
refreshComputerActivity: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;
|
|
447
|
+
listComputers: () => Promise<ResultIface<ComputerInfoIface[]>>;
|
|
448
|
+
getComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;
|
|
449
|
+
deleteComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;
|
|
450
|
+
/** Registers an image; poll getImage until it is ready, then create from its id. */
|
|
451
|
+
registerImage: (opts: RegisterImageOptsIface) => Promise<ResultIface<ComputerImageIface>>;
|
|
452
|
+
getImage: (id: string) => Promise<ResultIface<ComputerImageIface>>;
|
|
453
|
+
listImages: (opts?: ListImagesOptsIface) => Promise<ResultIface<ComputerImageIface[]>>;
|
|
454
|
+
/**
|
|
455
|
+
* API keys: captures a running computer (created with userVolumeGb: null) as a
|
|
456
|
+
* base; poll getBase until it is ready, then create with its id as baseId.
|
|
457
|
+
* The computer stops for the capture.
|
|
458
|
+
*/
|
|
459
|
+
captureComputer: (idOrName: string, options?: {
|
|
460
|
+
retained?: boolean;
|
|
461
|
+
}) => Promise<ResultIface<ComputerBaseIface>>;
|
|
462
|
+
setBaseRetention: (id: string, retained: boolean) => Promise<ResultIface<ComputerBaseIface>>;
|
|
463
|
+
getBase: (id: string) => Promise<ResultIface<ComputerBaseIface>>;
|
|
464
|
+
createToken: (opts: CreateTokenOptsIface) => Promise<ResultIface<ComputerTokenIface>>;
|
|
465
|
+
revokeToken: (id: string) => Promise<ResultIface<void>>;
|
|
466
|
+
withEphemeralComputer: <T>(opts: CreateComputerOptsIface, fn: (computer: ComputerHandleIface) => Promise<T>) => Promise<T>;
|
|
467
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var ComputerState = /* @__PURE__ */ ((ComputerState2) => {
|
|
2
|
+
ComputerState2[ComputerState2["Unknown"] = 0] = "Unknown";
|
|
3
|
+
ComputerState2[ComputerState2["Pending"] = 1] = "Pending";
|
|
4
|
+
ComputerState2[ComputerState2["Creating"] = 2] = "Creating";
|
|
5
|
+
ComputerState2[ComputerState2["Running"] = 3] = "Running";
|
|
6
|
+
ComputerState2[ComputerState2["Paused"] = 4] = "Paused";
|
|
7
|
+
ComputerState2[ComputerState2["Stopped"] = 5] = "Stopped";
|
|
8
|
+
ComputerState2[ComputerState2["Resuming"] = 6] = "Resuming";
|
|
9
|
+
ComputerState2[ComputerState2["Error"] = 8] = "Error";
|
|
10
|
+
ComputerState2[ComputerState2["Deleted"] = 9] = "Deleted";
|
|
11
|
+
ComputerState2[ComputerState2["Shelved"] = 10] = "Shelved";
|
|
12
|
+
return ComputerState2;
|
|
13
|
+
})(ComputerState || {});
|
|
14
|
+
var ComputerCommandMode = /* @__PURE__ */ ((ComputerCommandMode2) => {
|
|
15
|
+
ComputerCommandMode2[ComputerCommandMode2["Auto"] = 1] = "Auto";
|
|
16
|
+
ComputerCommandMode2[ComputerCommandMode2["None"] = 2] = "None";
|
|
17
|
+
ComputerCommandMode2[ComputerCommandMode2["Custom"] = 3] = "Custom";
|
|
18
|
+
return ComputerCommandMode2;
|
|
19
|
+
})(ComputerCommandMode || {});
|
|
20
|
+
var ComputerIdlePolicy = /* @__PURE__ */ ((ComputerIdlePolicy2) => {
|
|
21
|
+
ComputerIdlePolicy2["Shelve"] = "shelve";
|
|
22
|
+
ComputerIdlePolicy2["Pause"] = "pause";
|
|
23
|
+
ComputerIdlePolicy2["Delete"] = "delete";
|
|
24
|
+
return ComputerIdlePolicy2;
|
|
25
|
+
})(ComputerIdlePolicy || {});
|
|
26
|
+
var ComputerImageState = /* @__PURE__ */ ((ComputerImageState2) => {
|
|
27
|
+
ComputerImageState2["Pending"] = "pending";
|
|
28
|
+
ComputerImageState2["Building"] = "building";
|
|
29
|
+
ComputerImageState2["Ready"] = "ready";
|
|
30
|
+
ComputerImageState2["Failed"] = "failed";
|
|
31
|
+
ComputerImageState2["Expired"] = "expired";
|
|
32
|
+
return ComputerImageState2;
|
|
33
|
+
})(ComputerImageState || {});
|
|
34
|
+
var ComputerImageSource = /* @__PURE__ */ ((ComputerImageSource2) => {
|
|
35
|
+
ComputerImageSource2["Platform"] = "platform";
|
|
36
|
+
ComputerImageSource2["Customer"] = "customer";
|
|
37
|
+
return ComputerImageSource2;
|
|
38
|
+
})(ComputerImageSource || {});
|
|
39
|
+
var ComputerEgressPolicy = /* @__PURE__ */ ((ComputerEgressPolicy2) => {
|
|
40
|
+
ComputerEgressPolicy2["Internet"] = "internet";
|
|
41
|
+
ComputerEgressPolicy2["None"] = "none";
|
|
42
|
+
ComputerEgressPolicy2["Allowlist"] = "allowlist";
|
|
43
|
+
return ComputerEgressPolicy2;
|
|
44
|
+
})(ComputerEgressPolicy || {});
|
|
45
|
+
var ComputerBaseState = /* @__PURE__ */ ((ComputerBaseState2) => {
|
|
46
|
+
ComputerBaseState2["Capturing"] = "capturing";
|
|
47
|
+
ComputerBaseState2["Ready"] = "ready";
|
|
48
|
+
ComputerBaseState2["Failed"] = "failed";
|
|
49
|
+
ComputerBaseState2["Expired"] = "expired";
|
|
50
|
+
return ComputerBaseState2;
|
|
51
|
+
})(ComputerBaseState || {});
|
|
52
|
+
var ComputerTokenScope = /* @__PURE__ */ ((ComputerTokenScope2) => {
|
|
53
|
+
ComputerTokenScope2["Api"] = "api";
|
|
54
|
+
ComputerTokenScope2["Http"] = "http";
|
|
55
|
+
ComputerTokenScope2["Screen"] = "screen";
|
|
56
|
+
ComputerTokenScope2["ScreenControl"] = "screen:control";
|
|
57
|
+
return ComputerTokenScope2;
|
|
58
|
+
})(ComputerTokenScope || {});
|
|
59
|
+
export {
|
|
60
|
+
ComputerBaseState,
|
|
61
|
+
ComputerCommandMode,
|
|
62
|
+
ComputerEgressPolicy,
|
|
63
|
+
ComputerIdlePolicy,
|
|
64
|
+
ComputerImageSource,
|
|
65
|
+
ComputerImageState,
|
|
66
|
+
ComputerState,
|
|
67
|
+
ComputerTokenScope
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ComputerScreenOpenOptionsIface, ComputerScreenSessionIface } from \"./screen.mjs\";\n\nimport type {\n ComputerBrowserAccessIface,\n ComputerBrowserAccessOptionsIface,\n} from \"./browser-access.mjs\";\n\nimport type { ResultIface } from \"./result.mjs\";\n\nimport type { ComputerSnapshotRequestIface, ComputerSnapshotResponseIface } from \"./file-snapshots.mjs\";\n\nimport type { JsonObject } from \"./json.mjs\";\n\n// Stable values returned by the public Computers API.\nexport enum ComputerState {\n Unknown = 0,\n Pending = 1,\n Creating = 2,\n Running = 3,\n Paused = 4,\n Stopped = 5,\n Resuming = 6,\n // 7 was Migrating (the retired v2 -> v3 storage migration); never reuse it.\n Error = 8,\n Deleted = 9,\n Shelved = 10,\n}\n\nexport enum ComputerCommandMode {\n Auto = 1,\n None = 2,\n Custom = 3,\n}\n\nexport enum ComputerIdlePolicy {\n Shelve = 'shelve',\n Pause = 'pause',\n Delete = 'delete',\n}\n\nexport enum ComputerImageState {\n Pending = 'pending',\n Building = 'building',\n Ready = 'ready',\n Failed = 'failed',\n Expired = 'expired',\n}\n\nexport enum ComputerImageSource {\n Platform = 'platform',\n Customer = 'customer',\n}\n\nexport enum ComputerEgressPolicy {\n Internet = 'internet',\n None = 'none',\n Allowlist = 'allowlist',\n}\n\nexport enum ComputerBaseState {\n Capturing = 'capturing',\n Ready = 'ready',\n Failed = 'failed',\n Expired = 'expired',\n}\n\nexport interface ComputerApiKeyAuthIface {\n apiKey: string;\n}\n\nexport type ComputerClientAuth = ComputerApiKeyAuthIface;\n\nexport interface LifecycleActionOptionsIface {\n signal?: AbortSignal;\n}\n\nexport interface CreateComputerClientArgsIface {\n baseUrl: string;\n auth: ComputerClientAuth;\n // Aborts each request after this long; unbounded when omitted.\n requestTimeoutMs?: number;\n fetch?: typeof fetch;\n signal?: AbortSignal;\n}\n\n// Normalized computer information returned by the public API.\nexport interface ComputerInfoIface {\n id: string;\n name: string;\n teamId: string | null;\n ownerUserId: string | null;\n state: ComputerState;\n stateName: string | null;\n desiredState: number | null;\n image: string | null;\n imageVersionId: string | null;\n regionSlug: string | null;\n vcpu: number | null;\n memoryMb: number | null;\n diskGb: number | null;\n httpPort: number | null;\n httpPublic: boolean;\n ephemeral: boolean;\n idleTimeoutSeconds: number | null;\n autoResume: boolean;\n tags: string[];\n comment: string | null;\n errorMessage: string | null;\n hostname: string | null;\n createdAt: string | null;\n lastActiveAt: string | null;\n startupTimings: JsonObject;\n legacyBackupCheckpoint: JsonObject | null;\n storageCheckpointCompletedAtMs: number | null;\n}\n\nexport interface CreateComputerBaseOptsIface {\n name?: string;\n /** Create a team-owned computer. Omit to create a private computer for the acting user. */\n teamId?: string;\n regionSlug?: string;\n vcpu?: number;\n memoryMb?: number;\n diskGb?: number;\n /**\n * Size of the user volume holding /home/user and /workspaces. Omit for the\n * tier default on computers that retain state; null for none.\n */\n userVolumeGb?: number | null;\n env?: Record<string, string>;\n setupScript?: string;\n commandMode?: ComputerCommandMode;\n customCommand?: string;\n httpPort?: number;\n httpPublic?: boolean;\n ephemeral?: boolean;\n idleTimeoutSeconds?: number;\n /**\n * What happens after idleTimeoutSeconds: shelve (default), pause, or delete.\n */\n idlePolicy?: ComputerIdlePolicy;\n /** Outbound network: internet, none, or an exact DNS/IPv4/CIDR allowlist. */\n network?: { egress: ComputerEgressPolicy; allow?: string[] };\n terminationGraceSeconds?: number;\n autoResume?: boolean;\n tags?: string[];\n comment?: string;\n /** Sent as the Idempotency-Key header, never in the body. */\n idempotencyKey?: string;\n}\n\n/** Create from a ready image version (`cimv_\u2026`), registered with `registerImage`. */\nexport interface CreateComputerFromImageVersionOptsIface extends CreateComputerBaseOptsIface {\n imageVersionId: string;\n baseId?: never;\n image?: never;\n lineage?: never;\n registryCredentialId?: never;\n}\n\n/** API keys: create from a ready base (`part_\u2026`), captured with `captureComputer`. */\nexport interface CreateComputerFromBaseOptsIface extends CreateComputerBaseOptsIface {\n baseId: string;\n imageVersionId?: never;\n image?: never;\n lineage?: never;\n registryCredentialId?: never;\n projectArtifact?: never;\n}\n\nexport type CreateComputerOptsIface =\n | CreateComputerFromImageVersionOptsIface\n | CreateComputerFromBaseOptsIface;\n\n// A registered image version. Computers are created from ready ones.\nexport interface ComputerImageIface {\n id: string;\n /** Platform images are built by each release; customer ones by registerImage. */\n source: ComputerImageSource;\n reference: string;\n lineage: string;\n digest: string;\n state: ComputerImageState;\n error: string | null;\n sizes: string[];\n registryCredentialId: string | null;\n createdAt: string | null;\n readyAt: string | null;\n lastUsedAt: string | null;\n}\n\n// A computer's disk captured with captureComputer. Computers are created from ready ones.\nexport interface ComputerBaseIface {\n id: string;\n state: ComputerBaseState;\n error: string | null;\n // The captured computer.\n computerId: string | null;\n // The image the captured computer ran.\n image: string;\n digest: string;\n diskGb: number | null;\n createdAt: string | null;\n readyAt: string | null;\n lastUsedAt: string | null;\n /** Remains available until retention is released explicitly. */\n retained: boolean;\n}\n\nexport interface RegisterImageOptsIface {\n reference: string;\n /** A stored credential for the image's registry. */\n registryCredentialId?: string;\n /** Stored for the registration; deleted once nothing uses it. */\n registryCredential?: { username: string; password: string };\n /** Machine tier names to build for; defaults to ['standard']. */\n sizes?: string[];\n /** Sent as the Idempotency-Key header (API keys only), never in the body. */\n idempotencyKey?: string;\n}\n\nexport interface ListImagesOptsIface {\n lineage?: string;\n state?: ComputerImageState;\n}\n\nexport interface ComputerUseStatusIface {\n available: boolean;\n installed: boolean;\n}\n\nexport interface ComputerUseOpenOptsIface {\n cwd?: string;\n readyTimeoutMs?: number;\n}\n\nexport interface ExecProcessOptsIface {\n /** False refuses a sleeping computer instead of automatically waking it. */\n autoResume?: boolean;\n env?: Record<string, string>;\n cwd?: string;\n user?: string;\n pty?: boolean;\n cols?: number;\n rows?: number;\n /** Explicit process lifetime timeout. Waiting for output has its own timeout. */\n timeoutMs?: number;\n}\n\nexport interface ProcessWaitResultIface {\n exitCode: number | null;\n signal: string | null;\n}\n\nexport interface ComputerProcessIface {\n id: string;\n bootId: string;\n command: string;\n leaderPid: number | null;\n state: 'running' | 'exited';\n keepsAwake: boolean;\n createdAtMs: number;\n updatedAtMs: number;\n endedAtMs: number | null;\n cpuUsec: number;\n memoryBytes: number;\n memoryPeakBytes: number;\n ioReadBytes: number;\n ioWriteBytes: number;\n processCount: number;\n descendantCount?: number;\n}\n\nexport interface ProcessOutputChunkIface {\n data: string;\n /** Raw output bytes for incremental decoding across UTF-8 chunk boundaries. */\n dataBytes: Uint8Array;\n offset: number;\n nextOffset: number;\n eof: boolean;\n state: 'running' | 'exited';\n}\n\nexport interface ProcessOutputIface {\n read: (opts?: {\n offset?: number;\n waitMs?: number;\n }) => Promise<ResultIface<ProcessOutputChunkIface>>;\n}\n\nexport interface ReadProcessOutputOptsIface {\n stdoutOffset: number;\n stderrOffset: number;\n waitMs?: number;\n}\n\nexport interface ProcessOutputBatchIface {\n stdout: ProcessOutputChunkIface;\n stderr: ProcessOutputChunkIface;\n state: 'running' | 'exited';\n result: ProcessWaitResultIface | null;\n}\n\nexport interface RunCommandOptsIface {\n /** False refuses a sleeping computer instead of automatically waking it. */\n autoResume?: boolean;\n env?: Record<string, string>;\n cwd?: string;\n user?: string;\n /** Process lifetime timeout, enforced in the computer. */\n timeoutMs?: number;\n /** How long the request waits for the exit; at most 30 seconds, the default. */\n waitMs?: number;\n /** How long the service waits for the computer to be able to start the process. */\n readyTimeoutMs?: number;\n}\n\nexport interface ComputerRunIface {\n /** The process, for reading more output or terminating it. */\n process: ProcessHandleIface;\n /**\n * Output from offset zero. It is complete when `state` is `exited` and both streams\n * are at `eof`; otherwise read on with `process.readOutput` from each `nextOffset`.\n */\n output: ProcessOutputBatchIface;\n /** The computer killed the process at its `timeoutMs`. */\n timedOut: boolean;\n /** How long the process had been running when this answer was made. */\n elapsedMs: number;\n}\n\nexport interface ProcessHandleIface {\n id: string;\n bootId: string;\n pid: number | null;\n state: 'running' | 'exited';\n /** Stateless read of both streams and the exit result, using byte offsets. */\n readOutput: (opts: ReadProcessOutputOptsIface) => Promise<ResultIface<ProcessOutputBatchIface>>;\n stdout: ProcessOutputIface;\n stderr: ProcessOutputIface;\n wait: (opts?: { timeoutMs?: number }) => Promise<ResultIface<ProcessWaitResultIface>>;\n write: (data: string | Uint8Array) => Promise<ResultIface<{ ok: true }>>;\n eof: () => Promise<ResultIface<{ ok: true }>>;\n resize: (cols: number, rows: number) => Promise<ResultIface<{ ok: true }>>;\n signal: (signal: string) => Promise<ResultIface<{ ok: true }>>;\n terminate: () => Promise<ResultIface<{ ok: true }>>;\n}\n\nexport interface ComputerFileWriteResultIface {\n bytesWritten: number;\n}\n\nexport interface ComputerSettingsPatchIface {\n network?: { egress: ComputerEgressPolicy; allow?: string[] };\n name?: string;\n vcpu?: number;\n memoryMb?: number;\n diskGb?: number;\n httpPort?: number | null;\n httpPublic?: boolean;\n idleTimeoutSeconds?: number | null;\n autoResume?: boolean;\n tags?: string[];\n comment?: string | null;\n env?: Record<string, string>;\n}\n\nexport interface ComputerProcessesIface {\n list: () => Promise<ResultIface<ComputerProcessIface[]>>;\n get: (id: string, bootId: string) => Promise<ResultIface<ProcessHandleIface>>;\n}\n\nexport interface ComputerFilesIface {\n /** Read a committed sleeping workspace without waking it. Pin subsequent reads by generation. */\n snapshot: (\n request: ComputerSnapshotRequestIface,\n ) => Promise<ResultIface<ComputerSnapshotResponseIface>>;\n /** Reads the whole file as UTF-8 text, in ranged requests. */\n read: (path: string, options?: { autoResume?: boolean }) => Promise<ResultIface<string>>;\n /** Reads the whole file as bytes, in ranged requests. */\n readBytes: (path: string, options?: { autoResume?: boolean }) => Promise<ResultIface<Uint8Array>>;\n /** Replaces the file. Data over one chunk is appended in order, so a failure can leave a prefix. */\n write: (\n path: string,\n data: string | Uint8Array,\n ) => Promise<ResultIface<ComputerFileWriteResultIface>>;\n}\n\nexport enum ComputerTokenScope {\n /** The public API, within the token's organization or computer. */\n Api = 'api',\n /** The computer's HTTP ports through the gateway, never the API. */\n Http = 'http',\n Screen = 'screen',\n ScreenControl = 'screen:control',\n}\n\nexport interface CreateTokenOptsIface {\n name: string;\n /** Confines the token to one computer. Without it the token covers the organization. */\n computerId?: string;\n /** Omit for a full-access token. */\n scopes?: ComputerTokenScope[];\n expiresAt?: Date;\n}\n\nexport interface ComputerTokenIface {\n id: string;\n /** Returned once; send as `Authorization: Bearer <token>`. */\n token: string;\n}\n\nexport interface CreatePreviewTokenOptsIface {\n name?: string;\n /** Defaults to one hour from now. */\n expiresAt?: Date;\n}\n\nexport interface ComputerHandleIface {\n browserAccess: {\n open(\n options: ComputerBrowserAccessOptionsIface,\n ): Promise<ResultIface<ComputerBrowserAccessIface>>;\n close(tokenId: string): Promise<ResultIface<{ ok: boolean }>>;\n };\n screen: {\n status: () => Promise<ResultIface<{ available: boolean }>>;\n open: (\n options?: ComputerScreenOpenOptionsIface,\n ) => Promise<ResultIface<ComputerScreenSessionIface>>;\n };\n computerUse: {\n status(): Promise<ResultIface<ComputerUseStatusIface>>;\n available(): Promise<ResultIface<boolean>>;\n // A newline-delimited JSON-RPC MCP process. Use write/output/signal as with exec.\n open(options?: ComputerUseOpenOptsIface): Promise<ResultIface<ProcessHandleIface>>;\n };\n id: string;\n name: string;\n getInfo: () => ComputerInfoIface;\n refresh: () => Promise<ResultIface<ComputerInfoIface>>;\n refreshActivity: () => Promise<ResultIface<ComputerInfoIface>>;\n exec: (command: string, opts?: ExecProcessOptsIface) => Promise<ResultIface<ProcessHandleIface>>;\n /**\n * Runs a command with stdin closed and returns its output and exit in one request. Use\n * `exec` for a process that reads stdin, needs a terminal, or outlives the call.\n */\n run: (command: string, opts?: RunCommandOptsIface) => Promise<ResultIface<ComputerRunIface>>;\n processes: ComputerProcessesIface;\n files: ComputerFilesIface;\n /** `hostname[:port]` from the computer's hostname; port 443 \u2192 bare hostname. Null until the computer has a hostname. */\n getHost: (port: number) => string | null;\n /**\n * Mints a token that opens this computer's HTTP ports and nothing else: the API refuses\n * it. Send it as `Authorization: Bearer <token>` to a `getHost` URL of a private computer.\n */\n createPreviewToken: (\n opts?: CreatePreviewTokenOptsIface,\n ) => Promise<ResultIface<ComputerTokenIface>>;\n pause: () => Promise<ResultIface<ComputerInfoIface>>;\n resume: () => Promise<ResultIface<ComputerInfoIface>>;\n start: () => Promise<ResultIface<ComputerInfoIface>>;\n stop: () => Promise<ResultIface<ComputerInfoIface>>;\n restart: () => Promise<ResultIface<ComputerInfoIface>>;\n /** Convenience alias: kill performs the delete lifecycle action. */\n kill: () => Promise<ResultIface<ComputerInfoIface>>;\n settings: (patch: ComputerSettingsPatchIface) => Promise<ResultIface<ComputerInfoIface>>;\n}\n\nexport type ComputerConnectTarget = ({ id: string } | { name: string }) & {\n /**\n * Resume paused, stopped, or shelved computers before returning a handle.\n * Defaults to true. Set false for background work that must never wake a VM.\n */\n resumeIfNeeded?: boolean;\n};\n\nexport interface ComputerClientIface {\n stopComputerRetained: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;\n createComputer: (opts: CreateComputerOptsIface) => Promise<ResultIface<ComputerHandleIface>>;\n connectComputer: (target: ComputerConnectTarget) => Promise<ResultIface<ComputerHandleIface>>;\n pauseComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;\n resumeComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;\n stopComputer: (\n idOrName: string,\n options?: LifecycleActionOptionsIface,\n ) => Promise<ResultIface<ComputerInfoIface>>;\n refreshComputerActivity: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;\n listComputers: () => Promise<ResultIface<ComputerInfoIface[]>>;\n getComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;\n deleteComputer: (idOrName: string) => Promise<ResultIface<ComputerInfoIface>>;\n /** Registers an image; poll getImage until it is ready, then create from its id. */\n registerImage: (opts: RegisterImageOptsIface) => Promise<ResultIface<ComputerImageIface>>;\n getImage: (id: string) => Promise<ResultIface<ComputerImageIface>>;\n listImages: (opts?: ListImagesOptsIface) => Promise<ResultIface<ComputerImageIface[]>>;\n /**\n * API keys: captures a running computer (created with userVolumeGb: null) as a\n * base; poll getBase until it is ready, then create with its id as baseId.\n * The computer stops for the capture.\n */\n captureComputer: (\n idOrName: string,\n options?: { retained?: boolean },\n ) => Promise<ResultIface<ComputerBaseIface>>;\n setBaseRetention: (id: string, retained: boolean) => Promise<ResultIface<ComputerBaseIface>>;\n getBase: (id: string) => Promise<ResultIface<ComputerBaseIface>>;\n createToken: (opts: CreateTokenOptsIface) => Promise<ResultIface<ComputerTokenIface>>;\n revokeToken: (id: string) => Promise<ResultIface<void>>;\n withEphemeralComputer: <T>(\n opts: CreateComputerOptsIface,\n fn: (computer: ComputerHandleIface) => Promise<T>,\n ) => Promise<T>;\n}\n"],
|
|
5
|
+
"mappings": "AAcO,IAAK,gBAAL,kBAAKA,mBAAL;AACL,EAAAA,8BAAA,aAAU,KAAV;AACA,EAAAA,8BAAA,aAAU,KAAV;AACA,EAAAA,8BAAA,cAAW,KAAX;AACA,EAAAA,8BAAA,aAAU,KAAV;AACA,EAAAA,8BAAA,YAAS,KAAT;AACA,EAAAA,8BAAA,aAAU,KAAV;AACA,EAAAA,8BAAA,cAAW,KAAX;AAEA,EAAAA,8BAAA,WAAQ,KAAR;AACA,EAAAA,8BAAA,aAAU,KAAV;AACA,EAAAA,8BAAA,aAAU,MAAV;AAXU,SAAAA;AAAA,GAAA;AAcL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,0CAAA,UAAO,KAAP;AACA,EAAAA,0CAAA,UAAO,KAAP;AACA,EAAAA,0CAAA,YAAS,KAAT;AAHU,SAAAA;AAAA,GAAA;AAML,IAAK,qBAAL,kBAAKC,wBAAL;AACL,EAAAA,oBAAA,YAAS;AACT,EAAAA,oBAAA,WAAQ;AACR,EAAAA,oBAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAK,qBAAL,kBAAKC,wBAAL;AACL,EAAAA,oBAAA,aAAU;AACV,EAAAA,oBAAA,cAAW;AACX,EAAAA,oBAAA,WAAQ;AACR,EAAAA,oBAAA,YAAS;AACT,EAAAA,oBAAA,aAAU;AALA,SAAAA;AAAA,GAAA;AAQL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AAFD,SAAAA;AAAA,GAAA;AAKL,IAAK,uBAAL,kBAAKC,0BAAL;AACL,EAAAA,sBAAA,cAAW;AACX,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,eAAY;AAHF,SAAAA;AAAA,GAAA;AAML,IAAK,oBAAL,kBAAKC,uBAAL;AACL,EAAAA,mBAAA,eAAY;AACZ,EAAAA,mBAAA,WAAQ;AACR,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,aAAU;AAJA,SAAAA;AAAA,GAAA;AAyUL,IAAK,qBAAL,kBAAKC,wBAAL;AAEL,EAAAA,oBAAA,SAAM;AAEN,EAAAA,oBAAA,UAAO;AACP,EAAAA,oBAAA,YAAS;AACT,EAAAA,oBAAA,mBAAgB;AANN,SAAAA;AAAA,GAAA;",
|
|
6
|
+
"names": ["ComputerState", "ComputerCommandMode", "ComputerIdlePolicy", "ComputerImageState", "ComputerImageSource", "ComputerEgressPolicy", "ComputerBaseState", "ComputerTokenScope"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@finalai/computers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Client for the Final Computers public API, including files, processes, and exec WebSockets.",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"THIRD_PARTY_NOTICES.md"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/modules/index.d.mts",
|
|
17
|
+
"import": "./dist/modules/index.mjs",
|
|
18
|
+
"default": "./dist/modules/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
"./transport": {
|
|
22
|
+
"types": "./dist/modules/transport-api.d.mts",
|
|
23
|
+
"import": "./dist/modules/transport-api.mjs",
|
|
24
|
+
"default": "./dist/modules/transport-api.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./json": {
|
|
27
|
+
"types": "./dist/modules/json.d.mts",
|
|
28
|
+
"import": "./dist/modules/json.mjs",
|
|
29
|
+
"default": "./dist/modules/json.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./shell": {
|
|
32
|
+
"types": "./dist/modules/shell.d.mts",
|
|
33
|
+
"import": "./dist/modules/shell.mjs",
|
|
34
|
+
"default": "./dist/modules/shell.mjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "restricted",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"zod": "4.6.5"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=26"
|
|
46
|
+
},
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/final-company/packages-typescript.git",
|
|
50
|
+
"directory": "packages/@finalai/computers"
|
|
51
|
+
}
|
|
52
|
+
}
|