@arker-ai/sdk 0.2.1 → 0.3.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 +109 -83
- package/dist/index.cjs +393 -1216
- package/dist/index.d.cts +495 -82
- package/dist/index.d.ts +495 -82
- package/dist/index.js +393 -1212
- package/package.json +7 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,120 +1,533 @@
|
|
|
1
|
+
interface components {
|
|
2
|
+
schemas: {
|
|
3
|
+
/** @description Standard API error. Backends use code "unsupported_operation" when the request is valid but names an operation or option this backend cannot support. */
|
|
4
|
+
ErrorResponse: {
|
|
5
|
+
/**
|
|
6
|
+
* @description Stable machine-readable error code. "unsupported_operation" means the backend does not implement the requested optional feature.
|
|
7
|
+
* @example unsupported_operation
|
|
8
|
+
*/
|
|
9
|
+
code: string;
|
|
10
|
+
/** @description Human-readable error message. */
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
NetworkPolicy: components["schemas"]["NetworkPolicyOpen"] | components["schemas"]["NetworkPolicyBlocked"] | components["schemas"]["NetworkPolicyAllow"] | components["schemas"]["NetworkPolicyBlock"];
|
|
14
|
+
NetworkPolicyOpen: {
|
|
15
|
+
/** @constant */
|
|
16
|
+
type: "open";
|
|
17
|
+
};
|
|
18
|
+
NetworkPolicyBlocked: {
|
|
19
|
+
/** @constant */
|
|
20
|
+
type: "blocked";
|
|
21
|
+
};
|
|
22
|
+
NetworkPolicyAllow: {
|
|
23
|
+
/** @constant */
|
|
24
|
+
type: "allow";
|
|
25
|
+
allow: string[];
|
|
26
|
+
};
|
|
27
|
+
NetworkPolicyBlock: {
|
|
28
|
+
/** @constant */
|
|
29
|
+
type: "block";
|
|
30
|
+
block: string[];
|
|
31
|
+
};
|
|
32
|
+
NetworkPolicyInput: boolean | string | components["schemas"]["NetworkPolicy"];
|
|
33
|
+
ForkRequest: {
|
|
34
|
+
name?: string | null;
|
|
35
|
+
image?: string | null;
|
|
36
|
+
network?: components["schemas"]["NetworkPolicyInput"] | null;
|
|
37
|
+
/** @default true */
|
|
38
|
+
disk?: boolean;
|
|
39
|
+
vcpu_count?: number | null;
|
|
40
|
+
memory_mib?: number | null;
|
|
41
|
+
max_memory_mib?: number | null;
|
|
42
|
+
disk_mib?: number | null;
|
|
43
|
+
/**
|
|
44
|
+
* @description Request a durable VM. If the underlying host fails mid-run, the run resumes on a healthy host with the VM's filesystem state preserved. Use for long-running or non-idempotent work. Forked children default to non-durable. Backends without durability support return ErrorResponse code "unsupported_operation".
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
durable?: boolean | null;
|
|
48
|
+
};
|
|
49
|
+
SessionInfo: {
|
|
50
|
+
session_id: string;
|
|
51
|
+
state: string;
|
|
52
|
+
cwd: string;
|
|
53
|
+
};
|
|
54
|
+
ListSessionsResponse: components["schemas"]["SessionInfo"][];
|
|
55
|
+
GoldenInfo: {
|
|
56
|
+
vm_id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
source_golden: string;
|
|
59
|
+
memory_mib?: number | null;
|
|
60
|
+
vcpu_count?: number | null;
|
|
61
|
+
disk_mib?: number | null;
|
|
62
|
+
};
|
|
63
|
+
ListGoldensResponse: {
|
|
64
|
+
goldens: components["schemas"]["GoldenInfo"][];
|
|
65
|
+
};
|
|
66
|
+
VmInfo: {
|
|
67
|
+
vm_id: string;
|
|
68
|
+
owner_id: string;
|
|
69
|
+
created_at: string;
|
|
70
|
+
name?: string | null;
|
|
71
|
+
source_golden?: string | null;
|
|
72
|
+
state: string;
|
|
73
|
+
last_activity?: string | null;
|
|
74
|
+
vcpu_count?: number | null;
|
|
75
|
+
memory_mib?: number | null;
|
|
76
|
+
disk_mib?: number | null;
|
|
77
|
+
sessions: components["schemas"]["SessionInfo"][];
|
|
78
|
+
};
|
|
79
|
+
ListVmsResponse: {
|
|
80
|
+
vms: components["schemas"]["VmInfo"][];
|
|
81
|
+
};
|
|
82
|
+
ForkVmResponse: {
|
|
83
|
+
vm_id: string;
|
|
84
|
+
owner_id: string;
|
|
85
|
+
created_at: string;
|
|
86
|
+
sessions: components["schemas"]["SessionInfo"][];
|
|
87
|
+
ssh_private_key?: string | null;
|
|
88
|
+
tunnels?: components["schemas"]["RunTunnelStatus"][];
|
|
89
|
+
network?: components["schemas"]["RunNetworkStatus"] | null;
|
|
90
|
+
};
|
|
91
|
+
DeleteVmResponse: {
|
|
92
|
+
deleted: boolean;
|
|
93
|
+
};
|
|
94
|
+
DeleteSessionResponse: {
|
|
95
|
+
deleted: boolean;
|
|
96
|
+
};
|
|
97
|
+
MountRequest: {
|
|
98
|
+
uri: string;
|
|
99
|
+
mount_point: string;
|
|
100
|
+
/** @default dir */
|
|
101
|
+
format?: string;
|
|
102
|
+
};
|
|
103
|
+
/** @description Foreground command execution is the portable baseline. Optional session, background, mount, resource, network, signal, release, and runtime fields may return ErrorResponse code "unsupported_operation" on backends that do not support them. */
|
|
104
|
+
RunRequest: {
|
|
105
|
+
/** @description Optional persistent session id. Backends without persistent sessions return unsupported_operation when this is requested. */
|
|
106
|
+
session_id?: string | null;
|
|
107
|
+
command: string;
|
|
108
|
+
/**
|
|
109
|
+
* @description Run asynchronously. Backends without background execution return unsupported_operation and must not silently run the command synchronously.
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
background?: boolean;
|
|
113
|
+
timeout?: number | null;
|
|
114
|
+
/** @default auto */
|
|
115
|
+
end_symbol?: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* @description Optional external mounts. Backends without mount support return unsupported_operation when this is non-empty.
|
|
118
|
+
* @default []
|
|
119
|
+
*/
|
|
120
|
+
mounts?: components["schemas"]["MountRequest"][];
|
|
121
|
+
/** @description Optional per-run resource override. Backends without resource override support return unsupported_operation when this is requested. */
|
|
122
|
+
vcpu_count?: number | null;
|
|
123
|
+
/** @description Optional per-run resource override. Backends without resource override support return unsupported_operation when this is requested. */
|
|
124
|
+
memory_mib?: number | null;
|
|
125
|
+
/** @description Optional per-run resource override. Backends without resource override support return unsupported_operation when this is requested. */
|
|
126
|
+
disk_mib?: number | null;
|
|
127
|
+
/** @description Optional network/tunnel request. Backends without networking support return unsupported_operation when this is requested. */
|
|
128
|
+
network?: components["schemas"]["RunNetworkRequest"] | null;
|
|
129
|
+
/** @description Optional release selection. Backends without release selection support return unsupported_operation when this is requested. */
|
|
130
|
+
release?: string | null;
|
|
131
|
+
/** @description Optional session signal. Backends without signal support return unsupported_operation when this is requested. */
|
|
132
|
+
signal?: string | null;
|
|
133
|
+
/** @description Optional runtime selection. Backends without runtime selection support return unsupported_operation when this is requested. */
|
|
134
|
+
runtime?: string | null;
|
|
135
|
+
/** @description Optional runtime override. Backends without runtime overrides return unsupported_operation when this is requested. */
|
|
136
|
+
runtime_override?: string | null;
|
|
137
|
+
};
|
|
138
|
+
RunNetworkRequest: {
|
|
139
|
+
inbound?: components["schemas"]["RunInboundRequest"] | null;
|
|
140
|
+
};
|
|
141
|
+
RunInboundRequest: {
|
|
142
|
+
/** @default {} */
|
|
143
|
+
ports?: {
|
|
144
|
+
[key: string]: components["schemas"]["RunInboundPortRequest"];
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
RunInboundPortRequest: {
|
|
148
|
+
/** @default private */
|
|
149
|
+
visibility?: string;
|
|
150
|
+
/** @default http */
|
|
151
|
+
protocol?: string;
|
|
152
|
+
};
|
|
153
|
+
/** @description Successful run result. BackgroundRunResponse and PtyRunResponse are returned only by backends that support those modes; unsupported modes return ErrorResponse code "unsupported_operation". */
|
|
154
|
+
RunResponse: components["schemas"]["CompletedRunResponse"] | components["schemas"]["BackgroundRunResponse"] | components["schemas"]["PtyRunResponse"];
|
|
155
|
+
CompletedRunResponse: {
|
|
156
|
+
stdout: string;
|
|
157
|
+
stdout_encoding: string;
|
|
158
|
+
stderr: string;
|
|
159
|
+
stderr_encoding: string;
|
|
160
|
+
exit_code: number;
|
|
161
|
+
completed: boolean;
|
|
162
|
+
};
|
|
163
|
+
BackgroundRunResponse: {
|
|
164
|
+
run_id: string;
|
|
165
|
+
completed: boolean;
|
|
166
|
+
/** @default [] */
|
|
167
|
+
tunnels?: components["schemas"]["RunTunnelStatus"][];
|
|
168
|
+
network?: components["schemas"]["RunNetworkStatus"] | null;
|
|
169
|
+
};
|
|
170
|
+
PtyRunResponse: {
|
|
171
|
+
/** @constant */
|
|
172
|
+
pty: true;
|
|
173
|
+
session_id: string;
|
|
174
|
+
ws_url: string;
|
|
175
|
+
};
|
|
176
|
+
RunStatusResponse: {
|
|
177
|
+
run_id: string;
|
|
178
|
+
stdout: string;
|
|
179
|
+
stdout_encoding: string;
|
|
180
|
+
stderr: string;
|
|
181
|
+
stderr_encoding: string;
|
|
182
|
+
exit_code: number | null;
|
|
183
|
+
completed: boolean;
|
|
184
|
+
tunnels: components["schemas"]["RunTunnelStatus"][];
|
|
185
|
+
network?: components["schemas"]["RunNetworkStatus"] | null;
|
|
186
|
+
/**
|
|
187
|
+
* @description Number of times this run has been automatically retried after an infrastructure failure. 0 for runs that completed without interruption. Backends without durability support omit this field; clients should treat it as 0 when absent.
|
|
188
|
+
* @default 0
|
|
189
|
+
*/
|
|
190
|
+
retry_count?: number;
|
|
191
|
+
};
|
|
192
|
+
RunNetworkStatus: {
|
|
193
|
+
inbound: components["schemas"]["RunInboundStatus"];
|
|
194
|
+
};
|
|
195
|
+
RunInboundStatus: {
|
|
196
|
+
ports: {
|
|
197
|
+
[key: string]: components["schemas"]["RunInboundPortStatus"];
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
RunInboundPortStatus: {
|
|
201
|
+
requested: string;
|
|
202
|
+
observed: string;
|
|
203
|
+
effective: string;
|
|
204
|
+
protocol: string;
|
|
205
|
+
url?: string | null;
|
|
206
|
+
};
|
|
207
|
+
RunTunnelStatus: {
|
|
208
|
+
/** @default */
|
|
209
|
+
run_id?: string;
|
|
210
|
+
port: number;
|
|
211
|
+
visibility: string;
|
|
212
|
+
protocol: string;
|
|
213
|
+
url?: string | null;
|
|
214
|
+
status: string;
|
|
215
|
+
message?: string | null;
|
|
216
|
+
};
|
|
217
|
+
CancelRunResponse: {
|
|
218
|
+
cancelled: boolean;
|
|
219
|
+
};
|
|
220
|
+
/** @description Create a persistent session. Backends without persistent sessions return unsupported_operation. */
|
|
221
|
+
CreateSessionRequest: {
|
|
222
|
+
env?: {
|
|
223
|
+
[key: string]: string;
|
|
224
|
+
} | null;
|
|
225
|
+
cwd?: string | null;
|
|
226
|
+
};
|
|
227
|
+
/** @description Resize a PTY session. Backends without PTY sessions return unsupported_operation. */
|
|
228
|
+
ResizePtyRequest: {
|
|
229
|
+
cols: number;
|
|
230
|
+
rows: number;
|
|
231
|
+
};
|
|
232
|
+
ResizePtyResponse: {
|
|
233
|
+
resized: boolean;
|
|
234
|
+
};
|
|
235
|
+
/** @description Resize VM resources. Backends without VM resize support return unsupported_operation. */
|
|
236
|
+
ResizeRequest: {
|
|
237
|
+
vcpu_count?: number | null;
|
|
238
|
+
memory_mib?: number | null;
|
|
239
|
+
disk_mib?: number | null;
|
|
240
|
+
};
|
|
241
|
+
ResizeResponse: {
|
|
242
|
+
ok: boolean;
|
|
243
|
+
};
|
|
244
|
+
SyncRequest: components["schemas"]["SyncReadRequest"] | components["schemas"]["SyncWriteRequest"];
|
|
245
|
+
SyncReadRequest: {
|
|
246
|
+
/** @constant */
|
|
247
|
+
op: "read";
|
|
248
|
+
path: string;
|
|
249
|
+
};
|
|
250
|
+
SyncWriteRequest: {
|
|
251
|
+
/** @constant */
|
|
252
|
+
op: "write";
|
|
253
|
+
writes: components["schemas"]["SyncWriteEntry"][];
|
|
254
|
+
};
|
|
255
|
+
SyncWriteEntry: components["schemas"]["SyncChunkWrite"] | components["schemas"]["SyncPresignedWriteRequest"] | components["schemas"]["SyncPresignedWriteCommit"];
|
|
256
|
+
SyncChunkWrite: {
|
|
257
|
+
path: string;
|
|
258
|
+
size: number;
|
|
259
|
+
upload_id: string;
|
|
260
|
+
content: string;
|
|
261
|
+
start: number;
|
|
262
|
+
end: number;
|
|
263
|
+
sha256?: string | null;
|
|
264
|
+
/** @default false */
|
|
265
|
+
is_secret?: boolean;
|
|
266
|
+
};
|
|
267
|
+
SyncPresignedWriteRequest: {
|
|
268
|
+
path: string;
|
|
269
|
+
size: number;
|
|
270
|
+
presigned: boolean;
|
|
271
|
+
/** @default false */
|
|
272
|
+
is_secret?: boolean;
|
|
273
|
+
};
|
|
274
|
+
SyncPresignedWriteCommit: {
|
|
275
|
+
path: string;
|
|
276
|
+
size: number;
|
|
277
|
+
upload_id: string;
|
|
278
|
+
sha256?: string | null;
|
|
279
|
+
};
|
|
280
|
+
SyncResponse: components["schemas"]["SyncReadResponse"] | components["schemas"]["SyncWriteResponse"];
|
|
281
|
+
SyncReadResponse: components["schemas"]["SyncReadInlineResponse"] | components["schemas"]["SyncReadPresignedResponse"];
|
|
282
|
+
SyncReadInlineResponse: {
|
|
283
|
+
ok: boolean;
|
|
284
|
+
/** @constant */
|
|
285
|
+
op: "read";
|
|
286
|
+
path: string;
|
|
287
|
+
size: number;
|
|
288
|
+
content: string;
|
|
289
|
+
encoding: string;
|
|
290
|
+
};
|
|
291
|
+
SyncReadPresignedResponse: {
|
|
292
|
+
ok: boolean;
|
|
293
|
+
/** @constant */
|
|
294
|
+
op: "read";
|
|
295
|
+
path: string;
|
|
296
|
+
size: number;
|
|
297
|
+
presigned_url: string;
|
|
298
|
+
expires_in: number;
|
|
299
|
+
method: string;
|
|
300
|
+
};
|
|
301
|
+
SyncWriteResponse: {
|
|
302
|
+
ok: boolean;
|
|
303
|
+
/** @constant */
|
|
304
|
+
op: "write";
|
|
305
|
+
results: components["schemas"]["SyncWriteResult"][];
|
|
306
|
+
};
|
|
307
|
+
SyncWriteResult: components["schemas"]["SyncChunkWriteResult"] | components["schemas"]["SyncPresignedWriteRequestResult"] | components["schemas"]["SyncCommitWriteResult"];
|
|
308
|
+
SyncChunkWriteResult: {
|
|
309
|
+
path: string;
|
|
310
|
+
size: number;
|
|
311
|
+
received_bytes: number;
|
|
312
|
+
ranges: components["schemas"]["SyncByteRange"][];
|
|
313
|
+
complete: boolean;
|
|
314
|
+
written: boolean;
|
|
315
|
+
error?: components["schemas"]["SyncEntryError"] | null;
|
|
316
|
+
};
|
|
317
|
+
SyncPresignedWriteRequestResult: {
|
|
318
|
+
path: string;
|
|
319
|
+
size: number;
|
|
320
|
+
presigned_url: string;
|
|
321
|
+
upload_id: string;
|
|
322
|
+
expires_in: number;
|
|
323
|
+
method: string;
|
|
324
|
+
complete: boolean;
|
|
325
|
+
written: boolean;
|
|
326
|
+
error?: components["schemas"]["SyncEntryError"] | null;
|
|
327
|
+
};
|
|
328
|
+
SyncCommitWriteResult: {
|
|
329
|
+
path: string;
|
|
330
|
+
size: number;
|
|
331
|
+
complete: boolean;
|
|
332
|
+
written: boolean;
|
|
333
|
+
error?: components["schemas"]["SyncEntryError"] | null;
|
|
334
|
+
};
|
|
335
|
+
SyncByteRange: {
|
|
336
|
+
start: number;
|
|
337
|
+
end: number;
|
|
338
|
+
};
|
|
339
|
+
SyncEntryError: {
|
|
340
|
+
code: string;
|
|
341
|
+
message: string;
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
responses: {
|
|
345
|
+
/** @description API error. */
|
|
346
|
+
Error: {
|
|
347
|
+
headers: {
|
|
348
|
+
[name: string]: unknown;
|
|
349
|
+
};
|
|
350
|
+
content: {
|
|
351
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
/** @description The request is valid, but this backend does not support the requested operation or option. The response body uses ErrorResponse with code "unsupported_operation". */
|
|
355
|
+
UnsupportedOperation: {
|
|
356
|
+
headers: {
|
|
357
|
+
[name: string]: unknown;
|
|
358
|
+
};
|
|
359
|
+
content: {
|
|
360
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
parameters: {
|
|
365
|
+
VmId: string;
|
|
366
|
+
RunId: string;
|
|
367
|
+
SessionId: string;
|
|
368
|
+
/** @description Optional idempotency key for safe retries of POST /v1/vms/{id}/run. A retry with the same key and the same request returns the original run. A different request under the same key returns ErrorResponse code "conflict" with the original run_id. Keys expire 24h after the run completes. */
|
|
369
|
+
IdempotencyKey: string;
|
|
370
|
+
};
|
|
371
|
+
requestBodies: never;
|
|
372
|
+
headers: never;
|
|
373
|
+
pathItems: never;
|
|
374
|
+
}
|
|
375
|
+
|
|
1
376
|
/**
|
|
2
|
-
* Arker
|
|
3
|
-
*
|
|
4
|
-
* Quickstart:
|
|
5
|
-
*
|
|
6
|
-
* import { Arker } from "@arker-ai/sdk";
|
|
7
|
-
* const arker = new Arker({ apiKey: "ark_live_..." });
|
|
8
|
-
* const vm = await arker.vm("arkuntu").fork({ name: "hello" });
|
|
9
|
-
*
|
|
10
|
-
* const result = await vm.run("echo hi");
|
|
11
|
-
* console.log(new TextDecoder().decode(result.stdout)); // → "hi\n"
|
|
12
|
-
*
|
|
13
|
-
* await vm.sync.writeFile("/home/user/data.bin", new Uint8Array([1, 2, 3]));
|
|
14
|
-
* const blob = await vm.sync.readFile("/home/user/data.bin");
|
|
377
|
+
* Arker TypeScript SDK.
|
|
15
378
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* await vm.delete();
|
|
19
|
-
*
|
|
20
|
-
* // List your VMs (paginated):
|
|
21
|
-
* const page = await arker.list({ limit: 10 });
|
|
22
|
-
* for (const summary of page.items) {
|
|
23
|
-
* console.log(summary.vm_id, summary.name, summary.created_at);
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* Errors are thrown as `ArkerError(code, message, status)`.
|
|
379
|
+
* A small wrapper around the VM API. Configure a region for the standard
|
|
380
|
+
* Arker endpoints, or pass baseUrl directly for internal/dev targets.
|
|
27
381
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
declare const LIST_BASE_URL = "https://arker.ai";
|
|
31
|
-
/** 1000 pre-forked public VMs (snapshots of `arkuntu`). The SDK picks one
|
|
32
|
-
* at random per `vm("arkuntu").fork()` call so concurrent fork bursts
|
|
33
|
-
* fan out across distinct source state.log keys, avoiding per-key
|
|
34
|
-
* throttling under load. */
|
|
35
|
-
declare const ARKUNTU_POOL: readonly string[];
|
|
36
|
-
/** Source-VM aliases. `arkuntu` resolves to the 1000-VM pool above. */
|
|
37
|
-
declare const SOURCE_ALIASES: Record<string, readonly string[] | string>;
|
|
38
|
-
/** Files above this size go through a direct upload path. */
|
|
382
|
+
|
|
383
|
+
type ApiSchema<Name extends keyof components["schemas"]> = components["schemas"][Name];
|
|
39
384
|
declare const CHUNK_SIZE: number;
|
|
385
|
+
type FetchLike = typeof fetch;
|
|
386
|
+
type HttpMethod = "GET" | "POST" | "DELETE";
|
|
387
|
+
interface RetryOptions {
|
|
388
|
+
attempts?: number;
|
|
389
|
+
baseDelayMs?: number;
|
|
390
|
+
maxDelayMs?: number;
|
|
391
|
+
jitterMs?: number;
|
|
392
|
+
}
|
|
40
393
|
interface ArkerOptions {
|
|
41
|
-
apiKey
|
|
394
|
+
apiKey?: string;
|
|
42
395
|
baseUrl?: string;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
name?: string;
|
|
46
|
-
isPublic?: boolean;
|
|
396
|
+
burstBaseUrl?: string;
|
|
397
|
+
fetch?: FetchLike;
|
|
47
398
|
region?: string;
|
|
399
|
+
retry?: RetryOptions | false;
|
|
48
400
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
401
|
+
type NetworkPolicy = ApiSchema<"NetworkPolicy">;
|
|
402
|
+
type NetworkPolicyInput = ApiSchema<"NetworkPolicyInput">;
|
|
403
|
+
type ForkRequest = ApiSchema<"ForkRequest">;
|
|
404
|
+
type ForkOptions = ForkRequest;
|
|
405
|
+
type SessionInfo = ApiSchema<"SessionInfo">;
|
|
406
|
+
type GoldenInfo = ApiSchema<"GoldenInfo">;
|
|
407
|
+
type ListGoldensResponse = ApiSchema<"ListGoldensResponse">;
|
|
408
|
+
type VmInfo = ApiSchema<"VmInfo">;
|
|
409
|
+
type ListVmsResponse = ApiSchema<"ListVmsResponse">;
|
|
410
|
+
type ListSessionsResponse = ApiSchema<"ListSessionsResponse">;
|
|
411
|
+
type VmSummary = VmInfo;
|
|
412
|
+
type VmList = ListVmsResponse;
|
|
413
|
+
type ForkVmResponse = ApiSchema<"ForkVmResponse">;
|
|
414
|
+
type DeleteVmResponse = ApiSchema<"DeleteVmResponse">;
|
|
415
|
+
type DeleteSessionResponse = ApiSchema<"DeleteSessionResponse">;
|
|
416
|
+
type MountRequest = ApiSchema<"MountRequest">;
|
|
417
|
+
type RunRequest = ApiSchema<"RunRequest">;
|
|
418
|
+
type RunOptions = Omit<RunRequest, "command"> & {
|
|
419
|
+
/**
|
|
420
|
+
* Optional idempotency key for retrying POST /v1/vms/{id}/run.
|
|
421
|
+
* Sent as the `Idempotency-Key` HTTP header. Retries with the same
|
|
422
|
+
* key and the same semantic request return the original run; a
|
|
423
|
+
* different semantic request under the same key returns
|
|
424
|
+
* ArkerError code "conflict" with the original run_id.
|
|
425
|
+
*/
|
|
426
|
+
idempotencyKey?: string;
|
|
427
|
+
};
|
|
428
|
+
type RunInboundPortRequest = ApiSchema<"RunInboundPortRequest">;
|
|
429
|
+
type RunNetworkRequest = ApiSchema<"RunNetworkRequest">;
|
|
430
|
+
type RunTunnelStatus = ApiSchema<"RunTunnelStatus">;
|
|
431
|
+
type RunNetworkStatus = ApiSchema<"RunNetworkStatus">;
|
|
432
|
+
type RunResponse = ApiSchema<"RunResponse">;
|
|
433
|
+
type CompletedRunResponse = ApiSchema<"CompletedRunResponse">;
|
|
434
|
+
type BackgroundRunResponse = ApiSchema<"BackgroundRunResponse">;
|
|
435
|
+
type PtyRunResponse = ApiSchema<"PtyRunResponse">;
|
|
436
|
+
type RawRunResponse = RunResponse;
|
|
437
|
+
interface CompletedRunResult {
|
|
438
|
+
type: "completed";
|
|
439
|
+
completed: true;
|
|
54
440
|
stdout: Uint8Array;
|
|
441
|
+
stdoutEncoding: string;
|
|
55
442
|
stderr: Uint8Array;
|
|
443
|
+
stderrEncoding: string;
|
|
56
444
|
exitCode: number;
|
|
57
|
-
durationMs: number;
|
|
58
|
-
sessionId: string;
|
|
59
|
-
cwd: string;
|
|
60
|
-
}
|
|
61
|
-
interface VmSummary {
|
|
62
|
-
vm_id: string;
|
|
63
|
-
name: string | null;
|
|
64
|
-
base_image: string;
|
|
65
|
-
region: string;
|
|
66
|
-
/** ISO 8601 UTC. */
|
|
67
|
-
created_at: string;
|
|
68
445
|
}
|
|
69
|
-
interface
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
446
|
+
interface BackgroundRunResult {
|
|
447
|
+
type: "background";
|
|
448
|
+
completed: boolean;
|
|
449
|
+
runId: string;
|
|
450
|
+
tunnels: RunTunnelStatus[];
|
|
451
|
+
network?: RunNetworkStatus | null;
|
|
73
452
|
}
|
|
74
|
-
interface
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
sort?: string;
|
|
453
|
+
interface PtyRunResult {
|
|
454
|
+
type: "pty";
|
|
455
|
+
pty: true;
|
|
456
|
+
sessionId: string;
|
|
457
|
+
wsUrl: string;
|
|
80
458
|
}
|
|
459
|
+
type RunResult = CompletedRunResult | BackgroundRunResult | PtyRunResult;
|
|
460
|
+
type RunStatusResponse = ApiSchema<"RunStatusResponse">;
|
|
461
|
+
type CancelRunResponse = ApiSchema<"CancelRunResponse">;
|
|
462
|
+
type CreateSessionRequest = ApiSchema<"CreateSessionRequest">;
|
|
463
|
+
type ResizePtyRequest = ApiSchema<"ResizePtyRequest">;
|
|
464
|
+
type ResizePtyResponse = ApiSchema<"ResizePtyResponse">;
|
|
465
|
+
type ResizeRequest = ApiSchema<"ResizeRequest">;
|
|
466
|
+
type ResizeResponse = ApiSchema<"ResizeResponse">;
|
|
467
|
+
type SyncRequest = ApiSchema<"SyncRequest">;
|
|
468
|
+
type SyncResponse = ApiSchema<"SyncResponse">;
|
|
469
|
+
type SyncReadResponse = ApiSchema<"SyncReadResponse">;
|
|
470
|
+
type SyncReadInlineResponse = ApiSchema<"SyncReadInlineResponse">;
|
|
471
|
+
type SyncReadPresignedResponse = ApiSchema<"SyncReadPresignedResponse">;
|
|
472
|
+
type SyncByteRange = ApiSchema<"SyncByteRange">;
|
|
473
|
+
type ErrorResponse = ApiSchema<"ErrorResponse">;
|
|
474
|
+
type SyncChunkWriteResult = ApiSchema<"SyncChunkWriteResult">;
|
|
475
|
+
type SyncPresignedWriteRequestResult = ApiSchema<"SyncPresignedWriteRequestResult">;
|
|
476
|
+
type SyncCommitWriteResult = ApiSchema<"SyncCommitWriteResult">;
|
|
477
|
+
type SyncWriteResult = ApiSchema<"SyncWriteResult">;
|
|
478
|
+
type SyncWriteResponse = ApiSchema<"SyncWriteResponse">;
|
|
81
479
|
declare class ArkerError extends Error {
|
|
82
480
|
readonly code: string;
|
|
83
481
|
readonly status: number;
|
|
84
482
|
constructor(code: string, message: string, status: number);
|
|
85
483
|
}
|
|
86
484
|
declare class Arker {
|
|
485
|
+
readonly baseUrl: string;
|
|
486
|
+
readonly burstBaseUrl?: string;
|
|
487
|
+
readonly region?: string;
|
|
87
488
|
private readonly apiKey;
|
|
88
|
-
private readonly
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
_request<T = any>(method: string, path: string, body?: unknown, overrideBaseUrl?: string): Promise<T>;
|
|
92
|
-
/** Open a handle to a VM by ULID *or* template name. No network call. */
|
|
489
|
+
private readonly fetchImpl;
|
|
490
|
+
private readonly retry;
|
|
491
|
+
constructor(opts?: ArkerOptions);
|
|
93
492
|
vm(vmId: string): Computer;
|
|
94
|
-
|
|
95
|
-
list(
|
|
493
|
+
goldens(): Promise<ListGoldensResponse>;
|
|
494
|
+
list(): Promise<ListVmsResponse>;
|
|
495
|
+
get(vmId: string): Promise<VmInfo>;
|
|
496
|
+
/** @internal */
|
|
497
|
+
_request<T>(method: HttpMethod, path: string, body?: unknown, baseUrl?: string, extraHeaders?: Record<string, string | undefined>): Promise<T>;
|
|
498
|
+
/** @internal */
|
|
499
|
+
_fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
500
|
+
/** @internal */
|
|
501
|
+
_retryAttempts(): number;
|
|
502
|
+
/** @internal */
|
|
503
|
+
_retryDelay(attempt: number): number;
|
|
504
|
+
/** @internal */
|
|
505
|
+
_baseUrlFor(ref: string): string;
|
|
96
506
|
}
|
|
97
507
|
declare class Computer {
|
|
98
508
|
readonly id: string;
|
|
509
|
+
readonly baseUrl: string;
|
|
99
510
|
readonly sync: Sync;
|
|
100
511
|
/** @internal */
|
|
101
512
|
readonly _client: Arker;
|
|
102
|
-
constructor(client: Arker, vmId: string);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
513
|
+
constructor(client: Arker, vmId: string, baseUrl?: string);
|
|
514
|
+
fork(request?: ForkOptions): Promise<Computer>;
|
|
515
|
+
run(command: string, options?: RunOptions): Promise<RunResult>;
|
|
516
|
+
runStatus(runId: string): Promise<RunStatusResponse>;
|
|
517
|
+
cancelRun(runId: string): Promise<CancelRunResponse>;
|
|
518
|
+
delete(): Promise<DeleteVmResponse>;
|
|
107
519
|
}
|
|
108
520
|
declare class Sync {
|
|
109
521
|
/** @internal */
|
|
110
522
|
readonly _vm: Computer;
|
|
111
523
|
constructor(vm: Computer);
|
|
112
|
-
private path;
|
|
113
524
|
readFile(path: string): Promise<Uint8Array>;
|
|
114
525
|
writeFile(path: string, data: Uint8Array | string): Promise<void>;
|
|
115
|
-
private
|
|
116
|
-
private
|
|
526
|
+
private path;
|
|
527
|
+
private writeInline;
|
|
528
|
+
private writePresigned;
|
|
529
|
+
private putPresigned;
|
|
117
530
|
private sendOneWrite;
|
|
118
531
|
}
|
|
119
532
|
|
|
120
|
-
export {
|
|
533
|
+
export { Arker, ArkerError, type ArkerOptions, type BackgroundRunResponse, type BackgroundRunResult, CHUNK_SIZE, type CancelRunResponse, type CompletedRunResponse, type CompletedRunResult, Computer, type CreateSessionRequest, type DeleteSessionResponse, type DeleteVmResponse, type ErrorResponse, type ForkOptions, type ForkRequest, type ForkVmResponse, type GoldenInfo, type ListGoldensResponse, type ListSessionsResponse, type ListVmsResponse, type MountRequest, type NetworkPolicy, type NetworkPolicyInput, type PtyRunResponse, type PtyRunResult, type RawRunResponse, type ResizePtyRequest, type ResizePtyResponse, type ResizeRequest, type ResizeResponse, type RetryOptions, type RunInboundPortRequest, type RunNetworkRequest, type RunNetworkStatus, type RunOptions, type RunRequest, type RunResponse, type RunResult, type RunStatusResponse, type RunTunnelStatus, type SessionInfo, Sync, type SyncByteRange, type SyncChunkWriteResult, type SyncCommitWriteResult, type SyncPresignedWriteRequestResult, type SyncReadInlineResponse, type SyncReadPresignedResponse, type SyncReadResponse, type SyncRequest, type SyncResponse, type SyncWriteResponse, type SyncWriteResult, type VmInfo, type VmList, type VmSummary };
|