cubepod 0.0.0-stage → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,522 @@
1
+ export interface RequestOptions {
2
+ signal?: AbortSignal;
3
+ }
4
+
5
+ export interface CubePodClientOptions {
6
+ baseUrl?: string;
7
+ apiKey?: string;
8
+ timeoutMs?: number;
9
+ maxRetries?: number;
10
+ retryDelayMs?: number;
11
+ fetch?: typeof globalThis.fetch;
12
+ headers?: Record<string, string>;
13
+ }
14
+
15
+ export interface HealthStatus {
16
+ status: string;
17
+ service: string;
18
+ sandboxes: number;
19
+ autoResumeCount: number;
20
+ }
21
+
22
+ export interface SecretBinding {
23
+ envName: string;
24
+ placeholder?: string;
25
+ rawSecret?: string;
26
+ allowedHosts?: string[];
27
+ allowedHeaders?: string[];
28
+ }
29
+
30
+ export interface NetworkEgressRule {
31
+ action: 'allow' | 'deny';
32
+ target: string;
33
+ }
34
+
35
+ export interface NetworkPolicySpec {
36
+ defaultAction?: 'Allow' | 'Deny';
37
+ allowHosts?: string[];
38
+ denyHosts?: string[];
39
+ egress?: NetworkEgressRule[];
40
+ upstreamProxy?: string;
41
+ secretBindings?: SecretBinding[];
42
+ }
43
+
44
+ export interface CreateSandboxOptions extends RequestOptions {
45
+ templateId?: string;
46
+ timeout?: number;
47
+ timeoutSeconds?: number;
48
+ metadata?: Record<string, string>;
49
+ envVars?: Record<string, string>;
50
+ autoPause?: boolean;
51
+ autoResume?: boolean;
52
+ warmPoolRef?: string;
53
+ volumeKey?: string;
54
+ rootfsSize?: string;
55
+ workspaceSize?: string;
56
+ networkPolicy?: NetworkPolicySpec;
57
+ secretBindings?: SecretBinding[];
58
+ }
59
+
60
+ export type SandboxState =
61
+ | 'Running'
62
+ | 'Paused'
63
+ | 'Provisioning'
64
+ | 'Pausing'
65
+ | 'Resuming'
66
+ | 'Failed'
67
+ | 'Terminated'
68
+ | (string & {});
69
+
70
+ export interface SandboxInfo {
71
+ sandboxId: string;
72
+ templateId: string;
73
+ state: SandboxState;
74
+ clientId?: string;
75
+ envdVersion?: string;
76
+ startedAt?: string;
77
+ endAt?: string;
78
+ cpuCount?: number;
79
+ memoryMB?: number;
80
+ diskSizeMB?: number;
81
+ envdPort: number;
82
+ poddUrl?: string;
83
+ rootfsGeneration: number;
84
+ volumeKey?: string;
85
+ metadata?: Record<string, string>;
86
+ createdAt?: string;
87
+ timeoutSeconds?: number;
88
+ leaseSeconds?: number;
89
+ autoResumeCount?: number;
90
+ reason?: string;
91
+ }
92
+
93
+ export interface ListSandboxesOptions extends RequestOptions {
94
+ state?: SandboxState;
95
+ templateId?: string;
96
+ }
97
+
98
+ export interface ForkSandboxOptions extends RequestOptions {
99
+ volumeKey?: string;
100
+ metadata?: Record<string, string>;
101
+ }
102
+
103
+ export interface DeleteSandboxOptions extends RequestOptions {
104
+ deleteVolumes?: boolean;
105
+ }
106
+
107
+ export interface EndpointHost {
108
+ host: string;
109
+ url: string;
110
+ endpoint: string;
111
+ port: number;
112
+ sandboxId: string;
113
+ }
114
+
115
+ export interface CreateEndpointOptions extends RequestOptions {
116
+ expiresInSeconds?: number;
117
+ targetUrl?: string;
118
+ }
119
+
120
+ export interface PanelEndpoint {
121
+ url: string;
122
+ token: string;
123
+ expiresAt?: string;
124
+ }
125
+
126
+ export interface RunCommandOptions extends RequestOptions {
127
+ background?: boolean;
128
+ workdir?: string;
129
+ envs?: Record<string, string>;
130
+ uid?: number;
131
+ gid?: number;
132
+ }
133
+
134
+ export interface CommandResult {
135
+ id: string;
136
+ cmdId: string;
137
+ running: boolean;
138
+ pid?: number;
139
+ exitCode?: number;
140
+ stdout: string;
141
+ stderr: string;
142
+ output: string;
143
+ cursor: number;
144
+ }
145
+
146
+ export interface GetCommandLogsOptions extends RequestOptions {
147
+ cursor?: number;
148
+ }
149
+
150
+ export interface CommandLogs {
151
+ id: string;
152
+ cmdId: string;
153
+ content: string;
154
+ cursor: number;
155
+ running: boolean;
156
+ exitCode?: number;
157
+ }
158
+
159
+ export interface CodeOutputMessage {
160
+ text: string;
161
+ line: string;
162
+ timestamp?: number;
163
+ error: boolean;
164
+ }
165
+
166
+ export interface CodeResult {
167
+ text?: string;
168
+ png?: string;
169
+ html?: string;
170
+ isMainResult: boolean;
171
+ raw: Record<string, unknown>;
172
+ }
173
+
174
+ export interface CodeExecutionError {
175
+ name: string;
176
+ value: string;
177
+ traceback: string;
178
+ exitCode?: number;
179
+ }
180
+
181
+ export interface RunCodeOptions extends RequestOptions {
182
+ contextId?: string;
183
+ language?: string;
184
+ envVars?: Record<string, string>;
185
+ onStdout?: (msg: CodeOutputMessage) => void | Promise<void>;
186
+ onStderr?: (msg: CodeOutputMessage) => void | Promise<void>;
187
+ onResult?: (result: CodeResult) => void | Promise<void>;
188
+ onError?: (error: CodeExecutionError) => void | Promise<void>;
189
+ }
190
+
191
+ export interface ExecutionResult {
192
+ logs: {
193
+ stdout: string[];
194
+ stderr: string[];
195
+ };
196
+ stdout: string;
197
+ stderr: string;
198
+ results: CodeResult[];
199
+ error?: CodeExecutionError;
200
+ executionCount?: number;
201
+ text?: string;
202
+ }
203
+
204
+ export interface CreateContextOptions extends RequestOptions {
205
+ id?: string;
206
+ language?: string;
207
+ cwd?: string;
208
+ }
209
+
210
+ export interface CodeContext {
211
+ id: string;
212
+ language: string;
213
+ cwd: string;
214
+ }
215
+
216
+ export interface WriteFileOptions extends RequestOptions {
217
+ uid?: number;
218
+ gid?: number;
219
+ mode?: string;
220
+ }
221
+
222
+ export interface FileEntry {
223
+ name: string;
224
+ path: string;
225
+ isDir: boolean;
226
+ size: number;
227
+ mode: string;
228
+ }
229
+
230
+ export interface ArchiveSyncOptions extends RequestOptions {
231
+ dest?: string;
232
+ removePaths?: string[];
233
+ uid?: number;
234
+ gid?: number;
235
+ }
236
+
237
+ export type TemplateBuildStatus = 'waiting' | 'building' | 'ready' | 'error';
238
+
239
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
240
+
241
+ export interface BuildLogEntry {
242
+ timestamp: string;
243
+ level: LogLevel;
244
+ message: string;
245
+ }
246
+
247
+ export interface BuildStatusReason {
248
+ message: string;
249
+ step?: string;
250
+ logEntries?: BuildLogEntry[];
251
+ }
252
+
253
+ export interface E2BTemplate {
254
+ templateID: string;
255
+ buildID: string;
256
+ cpuCount: number;
257
+ memoryMB: number;
258
+ diskSizeMB: number;
259
+ public: boolean;
260
+ aliases: string[];
261
+ names: string[];
262
+ createdAt: string;
263
+ updatedAt: string;
264
+ createdBy: string | null;
265
+ lastSpawnedAt: string | null;
266
+ spawnCount: number;
267
+ buildCount: number;
268
+ envdVersion: string;
269
+ buildStatus: TemplateBuildStatus;
270
+ }
271
+
272
+ export interface E2BTemplateBuildSummary {
273
+ buildID: string;
274
+ templateID?: string;
275
+ status: TemplateBuildStatus;
276
+ createdAt: string;
277
+ updatedAt: string;
278
+ cpuCount: number;
279
+ memoryMB: number;
280
+ reason?: BuildStatusReason;
281
+ }
282
+
283
+ export interface TemplateWithBuilds extends E2BTemplate {
284
+ builds: E2BTemplateBuildSummary[];
285
+ }
286
+
287
+ export interface ListTemplatesOptions extends RequestOptions {
288
+ teamId?: string;
289
+ }
290
+
291
+ export interface ListTemplatesV2Options extends RequestOptions {
292
+ limit?: number;
293
+ nextToken?: string;
294
+ }
295
+
296
+ export interface ListTemplatesV2Response {
297
+ templates: E2BTemplate[];
298
+ nextToken?: string;
299
+ }
300
+
301
+ export interface GetTemplateOptions extends RequestOptions {
302
+ byAlias?: boolean;
303
+ }
304
+
305
+ export interface CreateTemplateRequest {
306
+ name?: string;
307
+ alias?: string;
308
+ tags?: string[];
309
+ cpuCount?: number;
310
+ memoryMB?: number;
311
+ minFreeDiskMb?: number;
312
+ }
313
+
314
+ export interface CreateTemplateOptions extends RequestOptions {
315
+ idempotencyKey?: string;
316
+ }
317
+
318
+ export interface TemplateRequestBuildResponse {
319
+ templateID: string;
320
+ buildID: string;
321
+ public: boolean;
322
+ aliases: string[];
323
+ names: string[];
324
+ tags: string[];
325
+ }
326
+
327
+ export interface TemplateBuildStep {
328
+ type: 'RUN' | 'COPY' | 'ADD' | 'WORKDIR' | 'USER' | 'ENV';
329
+ args: string[];
330
+ filesHash?: string;
331
+ force?: boolean;
332
+ }
333
+
334
+ export interface FromImageRegistry {
335
+ type?: string;
336
+ username?: string;
337
+ password?: string;
338
+ }
339
+
340
+ export interface StartTemplateBuildRequest {
341
+ fromImage?: string;
342
+ fromTemplate?: string;
343
+ fromImageRegistry?: FromImageRegistry;
344
+ force?: boolean;
345
+ startCmd?: string;
346
+ readyCmd?: string;
347
+ steps?: TemplateBuildStep[];
348
+ }
349
+
350
+ export interface GetTemplateBuildStatusOptions extends RequestOptions {
351
+ logsOffset?: number;
352
+ limit?: number;
353
+ level?: LogLevel;
354
+ }
355
+
356
+ export interface TemplateBuildInfo {
357
+ templateID: string;
358
+ buildID: string;
359
+ status: TemplateBuildStatus;
360
+ reason?: BuildStatusReason;
361
+ logs: string[];
362
+ logEntries: BuildLogEntry[];
363
+ }
364
+
365
+ export interface GetTemplateBuildLogsOptions extends RequestOptions {
366
+ cursor?: number;
367
+ limit?: number;
368
+ direction?: 'forward' | 'backward';
369
+ level?: LogLevel;
370
+ }
371
+
372
+ export interface TemplateBuildFileUpload {
373
+ present: boolean;
374
+ url?: string;
375
+ headers?: Record<string, string>;
376
+ }
377
+
378
+ export interface DeleteTemplateOptions extends RequestOptions {
379
+ force?: boolean;
380
+ }
381
+
382
+ export interface TemplateTagInfo {
383
+ tag: string;
384
+ buildID: string;
385
+ }
386
+
387
+ export interface CreateWarmPoolRequest {
388
+ name?: string;
389
+ templateRef?: string;
390
+ templateId?: string;
391
+ replicas?: number;
392
+ }
393
+
394
+ export interface WarmPoolInfo {
395
+ name: string;
396
+ poolName?: string;
397
+ templateRef: string;
398
+ replicas: number;
399
+ readyReplicas?: number;
400
+ availableReplicas?: number;
401
+ }
402
+
403
+ export function normalizeSandboxInfo(raw: Record<string, unknown>): SandboxInfo;
404
+
405
+ export class CubePodClient {
406
+ readonly baseUrl: string;
407
+ readonly apiKey?: string;
408
+ readonly timeoutMs: number;
409
+ readonly maxRetries: number;
410
+ readonly retryDelayMs: number;
411
+
412
+ constructor(options?: CubePodClientOptions);
413
+
414
+ health(options?: RequestOptions): Promise<HealthStatus>;
415
+
416
+ createSandbox(options?: CreateSandboxOptions): Promise<SandboxInfo>;
417
+ getSandbox(sandboxId: string, options?: RequestOptions): Promise<SandboxInfo>;
418
+ listSandboxes(filter?: ListSandboxesOptions, options?: RequestOptions): Promise<SandboxInfo[]>;
419
+ connectSandbox(sandboxId: string, options?: RequestOptions): Promise<SandboxInfo>;
420
+ pauseSandbox(sandboxId: string, options?: RequestOptions): Promise<SandboxInfo>;
421
+ setSandboxTimeout(sandboxId: string, timeoutSeconds?: number, options?: RequestOptions): Promise<SandboxInfo>;
422
+ refreshSandbox(sandboxId: string, durationSeconds?: number, options?: RequestOptions): Promise<void>;
423
+ acquireLease(sandboxId: string, leaseSeconds?: number, options?: RequestOptions): Promise<SandboxInfo>;
424
+ resetRootfs(sandboxId: string, options?: RequestOptions): Promise<SandboxInfo>;
425
+ forkSandbox(sandboxId: string, forkOptions?: ForkSandboxOptions, options?: RequestOptions): Promise<SandboxInfo>;
426
+ deleteSandbox(sandboxId: string, deleteOptions?: DeleteSandboxOptions, options?: RequestOptions): Promise<void>;
427
+ getEndpointHost(sandboxId: string, port: number, options?: RequestOptions): Promise<EndpointHost>;
428
+ getHost(sandboxId: string, port: number, options?: RequestOptions): Promise<string>;
429
+ createEndpoint(
430
+ sandboxId: string,
431
+ port: number,
432
+ endpointOptions?: CreateEndpointOptions,
433
+ options?: RequestOptions,
434
+ ): Promise<PanelEndpoint>;
435
+
436
+ runCommand(sandboxId: string, command: string, options?: RunCommandOptions): Promise<CommandResult>;
437
+ getCommandStatus(sandboxId: string, cmdId: string, options?: RequestOptions): Promise<CommandResult>;
438
+ getCommandLogs(
439
+ sandboxId: string,
440
+ cmdId: string,
441
+ options?: number | GetCommandLogsOptions,
442
+ ): Promise<CommandLogs>;
443
+ killCommand(sandboxId: string, cmdId: string, options?: RequestOptions): Promise<{ id: string; killed: boolean }>;
444
+
445
+ runCode(sandboxId: string, code: string, options?: RunCodeOptions): Promise<ExecutionResult>;
446
+ createContext(
447
+ sandboxId: string,
448
+ contextOptions?: CreateContextOptions,
449
+ options?: RequestOptions,
450
+ ): Promise<CodeContext>;
451
+ listContexts(sandboxId: string, options?: RequestOptions): Promise<CodeContext[]>;
452
+ getContext(sandboxId: string, contextId: string, options?: RequestOptions): Promise<CodeContext>;
453
+ restartContext(sandboxId: string, contextId: string, options?: RequestOptions): Promise<CodeContext>;
454
+ deleteContext(sandboxId: string, contextId: string, options?: RequestOptions): Promise<void>;
455
+
456
+ writeFile(
457
+ sandboxId: string,
458
+ path: string,
459
+ content: string | Uint8Array | ArrayBuffer,
460
+ options?: WriteFileOptions,
461
+ ): Promise<{ status?: string; path: string; size: number }>;
462
+ readFileBytes(sandboxId: string, path: string, options?: RequestOptions): Promise<Uint8Array>;
463
+ readFileText(sandboxId: string, path: string, options?: RequestOptions): Promise<string>;
464
+ removeFile(
465
+ sandboxId: string,
466
+ path: string,
467
+ options?: RequestOptions,
468
+ ): Promise<{ status?: string; deleted?: string }>;
469
+ listFiles(sandboxId: string, path?: string, options?: RequestOptions): Promise<FileEntry[]>;
470
+ archiveSync(
471
+ sandboxId: string,
472
+ archiveOrFiles: Uint8Array | ArrayBuffer | Record<string, string | Uint8Array | ArrayBuffer>,
473
+ options?: ArchiveSyncOptions,
474
+ ): Promise<{ status: string; extracted?: number }>;
475
+
476
+ listTemplates(options?: ListTemplatesOptions): Promise<E2BTemplate[]>;
477
+ listTemplatesV2(options?: ListTemplatesV2Options): Promise<ListTemplatesV2Response>;
478
+ getTemplate(templateIdOrAlias: string, options?: GetTemplateOptions): Promise<TemplateWithBuilds>;
479
+ getTemplateByAlias(alias: string, options?: RequestOptions): Promise<E2BTemplate>;
480
+ createTemplate(
481
+ request: CreateTemplateRequest,
482
+ options?: CreateTemplateOptions,
483
+ ): Promise<TemplateRequestBuildResponse>;
484
+ startTemplateBuild(
485
+ templateId: string,
486
+ buildId: string,
487
+ request: StartTemplateBuildRequest,
488
+ options?: RequestOptions,
489
+ ): Promise<void>;
490
+ getTemplateBuildStatus(
491
+ templateId: string,
492
+ buildId: string,
493
+ options?: GetTemplateBuildStatusOptions,
494
+ ): Promise<TemplateBuildInfo>;
495
+ getTemplateBuildLogs(
496
+ templateId: string,
497
+ buildId: string,
498
+ options?: GetTemplateBuildLogsOptions,
499
+ ): Promise<{ logs: BuildLogEntry[] }>;
500
+ getTemplateFileUploadLink(
501
+ templateId: string,
502
+ hash: string,
503
+ options?: RequestOptions,
504
+ ): Promise<TemplateBuildFileUpload>;
505
+ uploadTemplateFileContext(
506
+ uploadUrl: string,
507
+ tarBytes: Uint8Array | ArrayBuffer,
508
+ options?: { headers?: Record<string, string>; signal?: AbortSignal },
509
+ ): Promise<void>;
510
+ deleteTemplate(templateId: string, options?: DeleteTemplateOptions): Promise<void>;
511
+ updateTemplateVisibility(
512
+ templateId: string,
513
+ isPublic: boolean,
514
+ options?: RequestOptions,
515
+ ): Promise<{ names: string[] }>;
516
+ assignTemplateTags(target: string, tags: string[], options?: RequestOptions): Promise<void>;
517
+ deleteTemplateTags(name: string, tags: string[], options?: RequestOptions): Promise<void>;
518
+ getTemplateTags(templateId: string, options?: RequestOptions): Promise<TemplateTagInfo[]>;
519
+
520
+ createWarmPool(request: CreateWarmPoolRequest, options?: RequestOptions): Promise<WarmPoolInfo>;
521
+ listWarmPools(options?: RequestOptions): Promise<WarmPoolInfo[]>;
522
+ }