@runblackcat/sdk 0.1.0-alpha.44
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/LICENSE +202 -0
- package/README.md +341 -0
- package/package.json +28 -0
- package/sdk/dist/index.d.ts +503 -0
- package/sdk/dist/index.js +642 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side TypeScript client for the Blackcat gateway.
|
|
3
|
+
*
|
|
4
|
+
* The SDK intentionally contains transport primitives only. Workload-specific
|
|
5
|
+
* workflows (a consumer's dirty-worktree sync, say) compose file and exec
|
|
6
|
+
* operations in their own repository.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CAPABILITY_OPS: {
|
|
9
|
+
readonly EXEC: 1;
|
|
10
|
+
readonly READ: 2;
|
|
11
|
+
readonly WRITE: 4;
|
|
12
|
+
readonly SNAPSHOT: 8;
|
|
13
|
+
readonly DESTROY: 16;
|
|
14
|
+
readonly INSPECT: 32;
|
|
15
|
+
readonly SANDBOX_CREATE: 64;
|
|
16
|
+
readonly TEMPLATE_RW: 128;
|
|
17
|
+
readonly PUBLISH: 256;
|
|
18
|
+
readonly PROCESS_START: 512;
|
|
19
|
+
readonly PROCESS_INSPECT: 1024;
|
|
20
|
+
readonly PROCESS_CANCEL: 2048;
|
|
21
|
+
readonly RENEW: 4096;
|
|
22
|
+
};
|
|
23
|
+
export type CapabilityOps = number;
|
|
24
|
+
export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit & {
|
|
25
|
+
tls?: {
|
|
26
|
+
ca: string;
|
|
27
|
+
};
|
|
28
|
+
timeout?: false;
|
|
29
|
+
}) => Promise<Response>;
|
|
30
|
+
export interface BlackcatClientOptions {
|
|
31
|
+
baseUrl: string;
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
token?: string;
|
|
34
|
+
/** Capability identity and expiry, using idiomatic TypeScript names. */
|
|
35
|
+
tokenId?: string;
|
|
36
|
+
tokenExpiresAt?: number;
|
|
37
|
+
/** Backward-compatible aliases retained for pre-publication callers. */
|
|
38
|
+
token_id?: string;
|
|
39
|
+
token_expires_at?: number;
|
|
40
|
+
/** Re-mint a capability when renewal must replace the token secret. */
|
|
41
|
+
renewCapability?: () => Promise<MintTokenResponse>;
|
|
42
|
+
/** Private gateway trust root. Bun forwards this through its fetch TLS option. */
|
|
43
|
+
caPem?: string;
|
|
44
|
+
fetch?: FetchFunction;
|
|
45
|
+
}
|
|
46
|
+
export interface TemplateDefaults {
|
|
47
|
+
vcpus: number;
|
|
48
|
+
memory_mib: number;
|
|
49
|
+
hibernate?: HibernateMode;
|
|
50
|
+
on_interruption?: "evacuate" | "destroy";
|
|
51
|
+
}
|
|
52
|
+
export type HibernateMode = "memory";
|
|
53
|
+
export type TemplateEgressPolicy = {
|
|
54
|
+
mode: "deny_all";
|
|
55
|
+
} | {
|
|
56
|
+
mode: "allow_public";
|
|
57
|
+
} | {
|
|
58
|
+
mode: "rules";
|
|
59
|
+
rules: ReadonlyArray<{
|
|
60
|
+
protocol: "tcp" | "udp";
|
|
61
|
+
port: number;
|
|
62
|
+
target: {
|
|
63
|
+
kind: "cidr";
|
|
64
|
+
value: string;
|
|
65
|
+
} | {
|
|
66
|
+
kind: "dns_name";
|
|
67
|
+
value: string;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "dns_suffix";
|
|
70
|
+
value: string;
|
|
71
|
+
};
|
|
72
|
+
}>;
|
|
73
|
+
};
|
|
74
|
+
export type TemplatePreparationValue = {
|
|
75
|
+
from: "literal";
|
|
76
|
+
value: string;
|
|
77
|
+
} | {
|
|
78
|
+
from: "parameter";
|
|
79
|
+
name: string;
|
|
80
|
+
} | {
|
|
81
|
+
from: "secret";
|
|
82
|
+
name: string;
|
|
83
|
+
};
|
|
84
|
+
export interface TemplateRestoreHealth {
|
|
85
|
+
command: string;
|
|
86
|
+
args: readonly string[];
|
|
87
|
+
cwd: string;
|
|
88
|
+
timeout_ms: number;
|
|
89
|
+
}
|
|
90
|
+
interface TemplateDockerSourceBase {
|
|
91
|
+
/** A prepared filesystem; each sandbox starts a fresh process tree. */
|
|
92
|
+
docker: {
|
|
93
|
+
image: string;
|
|
94
|
+
};
|
|
95
|
+
defaults: TemplateDefaults;
|
|
96
|
+
egress: TemplateEgressPolicy;
|
|
97
|
+
restore_health: TemplateRestoreHealth;
|
|
98
|
+
}
|
|
99
|
+
interface TemplatePreparation {
|
|
100
|
+
parameters: Record<string, {
|
|
101
|
+
min_length: number;
|
|
102
|
+
max_length: number;
|
|
103
|
+
charset: "printable_ascii" | "lower_hex";
|
|
104
|
+
}>;
|
|
105
|
+
prepare: {
|
|
106
|
+
command: string;
|
|
107
|
+
args: TemplatePreparationValue[];
|
|
108
|
+
cwd: string;
|
|
109
|
+
environment: Record<string, TemplatePreparationValue>;
|
|
110
|
+
timeout_ms: number;
|
|
111
|
+
output_limit_bytes: number;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export type TemplateDockerSource = TemplateDockerSourceBase & (TemplatePreparation | {
|
|
115
|
+
parameters?: never;
|
|
116
|
+
prepare?: never;
|
|
117
|
+
});
|
|
118
|
+
export interface TemplateSandboxSource {
|
|
119
|
+
sandbox: {
|
|
120
|
+
id: string;
|
|
121
|
+
};
|
|
122
|
+
/** The gateway derives these from the source sandbox when omitted. */
|
|
123
|
+
defaults?: TemplateDefaults;
|
|
124
|
+
/** The gateway derives this from the source template when omitted. */
|
|
125
|
+
egress?: TemplateEgressPolicy;
|
|
126
|
+
}
|
|
127
|
+
export type TemplateSource = TemplateDockerSource | TemplateSandboxSource;
|
|
128
|
+
export type CreateTemplateInput = {
|
|
129
|
+
name: string;
|
|
130
|
+
source: TemplateDockerSource;
|
|
131
|
+
} | {
|
|
132
|
+
name?: string;
|
|
133
|
+
source: TemplateSandboxSource;
|
|
134
|
+
};
|
|
135
|
+
export interface Template {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
version: number;
|
|
139
|
+
/** The gateway stores the complete source manifest as JSON text. */
|
|
140
|
+
source: string;
|
|
141
|
+
current: boolean;
|
|
142
|
+
}
|
|
143
|
+
/** Public record name retained for consumers that distinguish it from creation input. */
|
|
144
|
+
export type TemplateRecord = Template;
|
|
145
|
+
export interface CreateTemplateBuildInput {
|
|
146
|
+
name: string;
|
|
147
|
+
content_key: string;
|
|
148
|
+
activate_on_ready: boolean;
|
|
149
|
+
source: TemplateDockerSource;
|
|
150
|
+
}
|
|
151
|
+
export type TemplateBuildPhase = "queued" | "building" | "validating" | "ready" | "failed";
|
|
152
|
+
export interface TemplateBuildRecord {
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
content_key: string;
|
|
156
|
+
phase: TemplateBuildPhase;
|
|
157
|
+
attempt: number;
|
|
158
|
+
template_version_id: string | null;
|
|
159
|
+
error: string | null;
|
|
160
|
+
}
|
|
161
|
+
export interface PrepareSandboxResponse {
|
|
162
|
+
prepared?: boolean;
|
|
163
|
+
process: Pick<ProcessRecord, "id" | "state" | "exit_code">;
|
|
164
|
+
}
|
|
165
|
+
export interface CreateTemplateResponse {
|
|
166
|
+
id: string;
|
|
167
|
+
version: number;
|
|
168
|
+
}
|
|
169
|
+
export type CreateSandboxInput = ({
|
|
170
|
+
template: string;
|
|
171
|
+
vcpus?: never;
|
|
172
|
+
memory_mib?: never;
|
|
173
|
+
} | {
|
|
174
|
+
template: string;
|
|
175
|
+
vcpus: number;
|
|
176
|
+
memory_mib: number;
|
|
177
|
+
}) & {
|
|
178
|
+
/** Stable across retries of one acquisition; never reuse for another request. */
|
|
179
|
+
request_id: string;
|
|
180
|
+
ssh_public_key?: string;
|
|
181
|
+
lease: SandboxLeaseInput;
|
|
182
|
+
};
|
|
183
|
+
export interface SandboxLeaseInput {
|
|
184
|
+
/** Initial lease duration, between 60 seconds and 24 hours. */
|
|
185
|
+
ttl_secs: number;
|
|
186
|
+
/** Hard lifetime from acquisition, at least ttl_secs and at most 30 days. */
|
|
187
|
+
renewable_for_secs: number;
|
|
188
|
+
}
|
|
189
|
+
export interface WarmInventoryMember {
|
|
190
|
+
id: string;
|
|
191
|
+
tenant: string;
|
|
192
|
+
template: string;
|
|
193
|
+
memory_mib: number;
|
|
194
|
+
vcpus: number;
|
|
195
|
+
node: string | null;
|
|
196
|
+
state: "Warming" | "Warm" | "Retiring";
|
|
197
|
+
snapshot: string | null;
|
|
198
|
+
last_active: SystemTimeValue;
|
|
199
|
+
}
|
|
200
|
+
export interface WarmTargetResponse {
|
|
201
|
+
enabled: boolean;
|
|
202
|
+
fleet_ready_limit: number;
|
|
203
|
+
}
|
|
204
|
+
export interface WarmInventoryResponse extends WarmTargetResponse {
|
|
205
|
+
members: WarmInventoryMember[];
|
|
206
|
+
}
|
|
207
|
+
/** Response returned by POST /v1/sandboxes (the gateway has no template field). */
|
|
208
|
+
export type CreateSandboxResponse = {
|
|
209
|
+
request_id: string;
|
|
210
|
+
id: string;
|
|
211
|
+
tier: "boot" | "warm_pool" | "restore";
|
|
212
|
+
expires_at: SystemTimeValue;
|
|
213
|
+
renewable_until: SystemTimeValue;
|
|
214
|
+
} & ({
|
|
215
|
+
state: "placed";
|
|
216
|
+
node: string;
|
|
217
|
+
} | {
|
|
218
|
+
state: "pending";
|
|
219
|
+
node: string | null;
|
|
220
|
+
});
|
|
221
|
+
export interface Sandbox {
|
|
222
|
+
id: string;
|
|
223
|
+
template: string;
|
|
224
|
+
state: string;
|
|
225
|
+
node?: string;
|
|
226
|
+
expires_at: SystemTimeValue;
|
|
227
|
+
renewable_until: SystemTimeValue;
|
|
228
|
+
}
|
|
229
|
+
export interface RenewSandboxResponse {
|
|
230
|
+
id: string;
|
|
231
|
+
expires_at: SystemTimeValue;
|
|
232
|
+
renewable_until: SystemTimeValue;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Tenant-scoped view returned by GET /v1/fleet. Residents and cached snapshots
|
|
236
|
+
* are already filtered by the gateway to the caller's tenant.
|
|
237
|
+
*/
|
|
238
|
+
export interface FleetNode {
|
|
239
|
+
id: string;
|
|
240
|
+
addr: string;
|
|
241
|
+
total_mib: number;
|
|
242
|
+
reserved_mib: number;
|
|
243
|
+
vcpus: number;
|
|
244
|
+
health: string;
|
|
245
|
+
schedulable: boolean;
|
|
246
|
+
lease_until: SystemTimeValue;
|
|
247
|
+
committed_mib: number;
|
|
248
|
+
residents: string[];
|
|
249
|
+
cached_snapshots: string[];
|
|
250
|
+
interruption: FleetInterruption | null;
|
|
251
|
+
}
|
|
252
|
+
export interface FleetInterruption {
|
|
253
|
+
reason: string;
|
|
254
|
+
deadline: SystemTimeValue;
|
|
255
|
+
}
|
|
256
|
+
export interface FleetResponse {
|
|
257
|
+
nodes: FleetNode[];
|
|
258
|
+
}
|
|
259
|
+
export interface ExecInput {
|
|
260
|
+
command: string;
|
|
261
|
+
args: string[];
|
|
262
|
+
cwd: string;
|
|
263
|
+
/** Positive guest execution budget; effects before timeout are not undone. */
|
|
264
|
+
timeout_ms: number;
|
|
265
|
+
/** Optional bounded stdin for the streaming EXEC endpoint. */
|
|
266
|
+
stdin?: number[];
|
|
267
|
+
}
|
|
268
|
+
export interface ExecResult {
|
|
269
|
+
exit_code: number | null;
|
|
270
|
+
timed_out: boolean;
|
|
271
|
+
stdout: Uint8Array;
|
|
272
|
+
stderr: Uint8Array;
|
|
273
|
+
}
|
|
274
|
+
export interface ExecStreamChunk {
|
|
275
|
+
stdout: Uint8Array;
|
|
276
|
+
stderr: Uint8Array;
|
|
277
|
+
done: boolean;
|
|
278
|
+
exit_code: number | null;
|
|
279
|
+
timed_out: boolean;
|
|
280
|
+
}
|
|
281
|
+
export type ProcessState = "starting" | "running" | "succeeded" | "failed" | "timed_out" | "cancelled" | "interrupted";
|
|
282
|
+
export interface ProcessStartInput {
|
|
283
|
+
command: string;
|
|
284
|
+
args: string[];
|
|
285
|
+
cwd: string;
|
|
286
|
+
env: Array<[string, string]>;
|
|
287
|
+
timeout_ms: number;
|
|
288
|
+
output_limit_bytes: number;
|
|
289
|
+
/** Optional payload delivered once and followed by EOF. Maximum 512 KiB. */
|
|
290
|
+
stdin?: Uint8Array;
|
|
291
|
+
}
|
|
292
|
+
export interface ProcessRecord {
|
|
293
|
+
id: string;
|
|
294
|
+
sandbox_id: string;
|
|
295
|
+
state: ProcessState;
|
|
296
|
+
exit_code: number | null;
|
|
297
|
+
stdout_bytes: number;
|
|
298
|
+
stderr_bytes: number;
|
|
299
|
+
stdout_truncated: boolean;
|
|
300
|
+
stderr_truncated: boolean;
|
|
301
|
+
failure: string | null;
|
|
302
|
+
created_at: number;
|
|
303
|
+
updated_at: number;
|
|
304
|
+
terminal_at: number | null;
|
|
305
|
+
}
|
|
306
|
+
export interface ProcessLogs {
|
|
307
|
+
stdout: Uint8Array;
|
|
308
|
+
stderr: Uint8Array;
|
|
309
|
+
next_stdout_offset: number;
|
|
310
|
+
next_stderr_offset: number;
|
|
311
|
+
stdout_truncated: boolean;
|
|
312
|
+
stderr_truncated: boolean;
|
|
313
|
+
state: ProcessState;
|
|
314
|
+
}
|
|
315
|
+
export interface ProcessLogsResponse {
|
|
316
|
+
process: ProcessRecord;
|
|
317
|
+
logs: ProcessLogs;
|
|
318
|
+
}
|
|
319
|
+
export interface FileReadChunk {
|
|
320
|
+
data: Uint8Array;
|
|
321
|
+
offset: number;
|
|
322
|
+
eof: boolean;
|
|
323
|
+
}
|
|
324
|
+
export interface ReadFileInput {
|
|
325
|
+
path: string;
|
|
326
|
+
offset?: number;
|
|
327
|
+
/** Total bytes to read. Omit to read through EOF. */
|
|
328
|
+
length?: number;
|
|
329
|
+
/** Per-request chunk size; defaults to the gateway's maximum. */
|
|
330
|
+
chunk_size?: number;
|
|
331
|
+
}
|
|
332
|
+
export interface WriteFileInput {
|
|
333
|
+
path: string;
|
|
334
|
+
data: Uint8Array;
|
|
335
|
+
offset?: number;
|
|
336
|
+
truncate?: boolean;
|
|
337
|
+
}
|
|
338
|
+
export interface WriteFileStreamInput {
|
|
339
|
+
path: string;
|
|
340
|
+
data: AsyncIterable<Uint8Array>;
|
|
341
|
+
offset?: number;
|
|
342
|
+
truncate?: boolean;
|
|
343
|
+
}
|
|
344
|
+
export interface MintTokenInput {
|
|
345
|
+
sandbox?: string;
|
|
346
|
+
ops: CapabilityOps;
|
|
347
|
+
ttl_secs: number;
|
|
348
|
+
}
|
|
349
|
+
/** JSON representation emitted by serde for Rust's SystemTime. */
|
|
350
|
+
export interface SystemTimeValue {
|
|
351
|
+
secs_since_epoch: number;
|
|
352
|
+
nanos_since_epoch: number;
|
|
353
|
+
}
|
|
354
|
+
export interface MintTokenResponse {
|
|
355
|
+
token: string;
|
|
356
|
+
token_id: string;
|
|
357
|
+
/** Capability timestamps are epoch milliseconds. */
|
|
358
|
+
expires_at: number;
|
|
359
|
+
renewable_until: number;
|
|
360
|
+
}
|
|
361
|
+
export interface RenewTokenResponse {
|
|
362
|
+
expires_at: number;
|
|
363
|
+
}
|
|
364
|
+
export declare class BlackcatApiError extends Error {
|
|
365
|
+
readonly status: number;
|
|
366
|
+
readonly retryAfter?: number;
|
|
367
|
+
readonly requestId?: string;
|
|
368
|
+
readonly details: unknown;
|
|
369
|
+
constructor(status: number, message: string, details: unknown, retryAfter?: number, requestId?: string);
|
|
370
|
+
}
|
|
371
|
+
declare const MAX_FILE_CHUNK: number;
|
|
372
|
+
declare const MAX_FILE_READ_CHUNK = 1000000;
|
|
373
|
+
declare const MAX_PROCESS_STDIN: number;
|
|
374
|
+
declare const MAX_EXEC_STDIN: number;
|
|
375
|
+
export declare function epochMillis(value: unknown, field: string): number;
|
|
376
|
+
export declare function parseCreateSandboxResponse(value: unknown, requestId: string): CreateSandboxResponse;
|
|
377
|
+
export declare function assertSecureBlackcatGatewayUrl(baseUrl: string): void;
|
|
378
|
+
declare class GatewayClient {
|
|
379
|
+
readonly baseUrl: string;
|
|
380
|
+
readonly apiKey?: string;
|
|
381
|
+
token?: string;
|
|
382
|
+
tokenId?: string;
|
|
383
|
+
tokenExpiresAt?: number;
|
|
384
|
+
readonly renewCapability?: () => Promise<MintTokenResponse>;
|
|
385
|
+
readonly caPem?: string;
|
|
386
|
+
readonly fetcher: FetchFunction;
|
|
387
|
+
private renewalInFlight?;
|
|
388
|
+
constructor(options: BlackcatClientOptions);
|
|
389
|
+
credential(kind: "apiKey" | "token" | "either"): string;
|
|
390
|
+
json<T>(method: string, path: string, body?: unknown, kind?: "apiKey" | "token" | "either", timeout?: false, signal?: AbortSignal, extraHeaders?: HeadersInit): Promise<T>;
|
|
391
|
+
raw(method: string, path: string, body?: BodyInit, kind?: "apiKey" | "token" | "either", contentType?: string, timeout?: false, signal?: AbortSignal): Promise<Response>;
|
|
392
|
+
renewIfNeeded(signal?: AbortSignal): Promise<void>;
|
|
393
|
+
stream(method: string, path: string, body?: BodyInit, kind?: "apiKey" | "token" | "either", contentType?: string, renew?: boolean, signal?: AbortSignal): AsyncGenerator<Uint8Array>;
|
|
394
|
+
}
|
|
395
|
+
declare class TemplatesResource {
|
|
396
|
+
private readonly client;
|
|
397
|
+
constructor(client: GatewayClient);
|
|
398
|
+
create(input: CreateTemplateInput): Promise<CreateTemplateResponse>;
|
|
399
|
+
list(): Promise<Template[]>;
|
|
400
|
+
activate(id: string): Promise<{
|
|
401
|
+
id: string;
|
|
402
|
+
name: string;
|
|
403
|
+
version: number;
|
|
404
|
+
}>;
|
|
405
|
+
configureWarm(id: string, input: {
|
|
406
|
+
enabled: boolean;
|
|
407
|
+
}): Promise<WarmTargetResponse>;
|
|
408
|
+
inspectWarm(id: string): Promise<WarmInventoryResponse>;
|
|
409
|
+
}
|
|
410
|
+
declare class TemplateBuildsResource {
|
|
411
|
+
private readonly client;
|
|
412
|
+
constructor(client: GatewayClient);
|
|
413
|
+
create(input: CreateTemplateBuildInput): Promise<{
|
|
414
|
+
build: TemplateBuildRecord;
|
|
415
|
+
}>;
|
|
416
|
+
get(id: string): Promise<{
|
|
417
|
+
build: TemplateBuildRecord;
|
|
418
|
+
}>;
|
|
419
|
+
retry(id: string): Promise<{
|
|
420
|
+
build: TemplateBuildRecord;
|
|
421
|
+
}>;
|
|
422
|
+
}
|
|
423
|
+
declare class TokensResource {
|
|
424
|
+
private readonly client;
|
|
425
|
+
constructor(client: GatewayClient);
|
|
426
|
+
mint(input: MintTokenInput): Promise<MintTokenResponse>;
|
|
427
|
+
renew(id: string): Promise<RenewTokenResponse>;
|
|
428
|
+
revoke(id: string): Promise<void>;
|
|
429
|
+
}
|
|
430
|
+
declare class FleetResource {
|
|
431
|
+
private readonly client;
|
|
432
|
+
constructor(client: GatewayClient);
|
|
433
|
+
/** List the nodes and this tenant's residents/snapshots visible to INSPECT. */
|
|
434
|
+
list(): Promise<FleetResponse>;
|
|
435
|
+
}
|
|
436
|
+
declare class SandboxesResource {
|
|
437
|
+
private readonly client;
|
|
438
|
+
constructor(client: GatewayClient);
|
|
439
|
+
/** List all of this tenant's non-destroyed sandboxes, including hibernated ones. */
|
|
440
|
+
list(): Promise<Sandbox[]>;
|
|
441
|
+
/**
|
|
442
|
+
* Acquire once under a caller-owned request ID. Repeat the exact request to
|
|
443
|
+
* recover a lost response. A pending receipt is not an executable sandbox;
|
|
444
|
+
* no automatic retry, new ID, or replacement allocation is synthesized here.
|
|
445
|
+
*/
|
|
446
|
+
create(input: CreateSandboxInput): Promise<CreateSandboxResponse>;
|
|
447
|
+
acquisition(requestId: string): Promise<CreateSandboxResponse>;
|
|
448
|
+
get(id: string): Promise<Sandbox>;
|
|
449
|
+
/** Extend the soft expiry without moving the immutable hard deadline. */
|
|
450
|
+
renew(id: string, ttl_secs: number): Promise<RenewSandboxResponse>;
|
|
451
|
+
exec(id: string, input: ExecInput): Promise<ExecResult>;
|
|
452
|
+
execStream(id: string, input: ExecInput): AsyncGenerator<ExecStreamChunk>;
|
|
453
|
+
startProcess(id: string, requestId: string, input: ProcessStartInput): Promise<ProcessRecord>;
|
|
454
|
+
getProcess(id: string, processId: string): Promise<ProcessRecord>;
|
|
455
|
+
processLogs(id: string, processId: string, input?: number | {
|
|
456
|
+
stdout_offset?: number;
|
|
457
|
+
stderr_offset?: number;
|
|
458
|
+
max_bytes?: number;
|
|
459
|
+
}): Promise<ProcessLogsResponse>;
|
|
460
|
+
cancelProcess(id: string, processId: string): Promise<ProcessRecord>;
|
|
461
|
+
prepare(id: string, input: {
|
|
462
|
+
parameters: Record<string, string>;
|
|
463
|
+
secrets: Record<string, string>;
|
|
464
|
+
}, idempotencyKey: string): Promise<PrepareSandboxResponse>;
|
|
465
|
+
logs(id: string): AsyncGenerator<Uint8Array>;
|
|
466
|
+
readFileChunk(id: string, input: {
|
|
467
|
+
path: string;
|
|
468
|
+
offset: number;
|
|
469
|
+
length: number;
|
|
470
|
+
}): Promise<FileReadChunk>;
|
|
471
|
+
readFileStream(id: string, input: ReadFileInput): AsyncGenerator<FileReadChunk>;
|
|
472
|
+
readFile(id: string, input: ReadFileInput): Promise<Uint8Array>;
|
|
473
|
+
writeFileChunk(id: string, input: {
|
|
474
|
+
path: string;
|
|
475
|
+
offset: number;
|
|
476
|
+
data: Uint8Array;
|
|
477
|
+
truncate: boolean;
|
|
478
|
+
}): Promise<void>;
|
|
479
|
+
writeFileStream(id: string, input: WriteFileStreamInput): Promise<number>;
|
|
480
|
+
writeFile(id: string, input: WriteFileInput): Promise<number>;
|
|
481
|
+
snapshot(id: string): Promise<{
|
|
482
|
+
snapshot: string;
|
|
483
|
+
}>;
|
|
484
|
+
hibernate(id: string, input?: {
|
|
485
|
+
mode: HibernateMode;
|
|
486
|
+
}): Promise<void>;
|
|
487
|
+
resume(id: string): Promise<void>;
|
|
488
|
+
destroy(id: string): Promise<void>;
|
|
489
|
+
}
|
|
490
|
+
export declare class BlackcatClient extends GatewayClient {
|
|
491
|
+
readonly templates: TemplatesResource;
|
|
492
|
+
readonly templateBuilds: TemplateBuildsResource;
|
|
493
|
+
readonly sandboxes: SandboxesResource;
|
|
494
|
+
readonly tokens: TokensResource;
|
|
495
|
+
readonly fleet: FleetResource;
|
|
496
|
+
constructor(options: BlackcatClientOptions);
|
|
497
|
+
/**
|
|
498
|
+
* Create a client that uses a sandbox capability for resource operations.
|
|
499
|
+
* Passing the complete mint response enables renewal during long streams.
|
|
500
|
+
*/
|
|
501
|
+
withToken(token: string | MintTokenResponse, renewCapability?: () => Promise<MintTokenResponse>): BlackcatClient;
|
|
502
|
+
}
|
|
503
|
+
export { MAX_EXEC_STDIN, MAX_FILE_CHUNK, MAX_FILE_CHUNK as MAX_FILE_WRITE_CHUNK, MAX_FILE_READ_CHUNK, MAX_PROCESS_STDIN, };
|