tensorlake 0.4.39

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,581 @@
1
+ declare enum SandboxStatus {
2
+ PENDING = "pending",
3
+ RUNNING = "running",
4
+ SNAPSHOTTING = "snapshotting",
5
+ SUSPENDED = "suspended",
6
+ TERMINATED = "terminated"
7
+ }
8
+ declare enum SnapshotStatus {
9
+ IN_PROGRESS = "in_progress",
10
+ COMPLETED = "completed",
11
+ FAILED = "failed"
12
+ }
13
+ declare enum ProcessStatus {
14
+ RUNNING = "running",
15
+ EXITED = "exited",
16
+ SIGNALED = "signaled"
17
+ }
18
+ declare enum StdinMode {
19
+ CLOSED = "closed",
20
+ PIPE = "pipe"
21
+ }
22
+ declare enum OutputMode {
23
+ CAPTURE = "capture",
24
+ DISCARD = "discard"
25
+ }
26
+ declare enum ContainerState {
27
+ IDLE = "Idle",
28
+ RUNNING = "Running"
29
+ }
30
+ interface ContainerResourcesInfo {
31
+ cpus: number;
32
+ memoryMb: number;
33
+ ephemeralDiskMb: number;
34
+ }
35
+ interface NetworkConfig {
36
+ allowInternetAccess: boolean;
37
+ allowOut: string[];
38
+ denyOut: string[];
39
+ }
40
+ interface CreateSandboxOptions {
41
+ image?: string;
42
+ cpus?: number;
43
+ memoryMb?: number;
44
+ ephemeralDiskMb?: number;
45
+ secretNames?: string[];
46
+ timeoutSecs?: number;
47
+ entrypoint?: string[];
48
+ allowInternetAccess?: boolean;
49
+ allowOut?: string[];
50
+ denyOut?: string[];
51
+ snapshotId?: string;
52
+ /** Optional name for the sandbox. Named sandboxes support suspend/resume. When absent the sandbox is ephemeral. */
53
+ name?: string;
54
+ }
55
+ interface UpdateSandboxOptions {
56
+ /** New name for the sandbox. Naming an ephemeral sandbox enables suspend/resume. */
57
+ name?: string;
58
+ }
59
+ interface CreateSandboxResponse {
60
+ sandboxId: string;
61
+ status: SandboxStatus;
62
+ }
63
+ interface SandboxInfo {
64
+ sandboxId: string;
65
+ namespace: string;
66
+ status: SandboxStatus;
67
+ image?: string;
68
+ resources: ContainerResourcesInfo;
69
+ secretNames: string[];
70
+ timeoutSecs?: number;
71
+ entrypoint?: string[];
72
+ network?: NetworkConfig;
73
+ poolId?: string;
74
+ outcome?: string;
75
+ createdAt?: Date;
76
+ terminatedAt?: Date;
77
+ name?: string;
78
+ }
79
+ interface CreateSnapshotResponse {
80
+ snapshotId: string;
81
+ status: SnapshotStatus;
82
+ }
83
+ interface SnapshotInfo {
84
+ snapshotId: string;
85
+ namespace: string;
86
+ sandboxId: string;
87
+ baseImage: string;
88
+ status: SnapshotStatus;
89
+ error?: string;
90
+ snapshotUri?: string;
91
+ sizeBytes?: number;
92
+ createdAt?: Date;
93
+ }
94
+ interface SnapshotAndWaitOptions {
95
+ timeout?: number;
96
+ pollInterval?: number;
97
+ }
98
+ interface CreatePoolOptions {
99
+ image: string;
100
+ cpus?: number;
101
+ memoryMb?: number;
102
+ ephemeralDiskMb?: number;
103
+ secretNames?: string[];
104
+ timeoutSecs?: number;
105
+ entrypoint?: string[];
106
+ maxContainers?: number;
107
+ warmContainers?: number;
108
+ }
109
+ interface UpdatePoolOptions {
110
+ image: string;
111
+ cpus?: number;
112
+ memoryMb?: number;
113
+ ephemeralDiskMb?: number;
114
+ secretNames?: string[];
115
+ timeoutSecs?: number;
116
+ entrypoint?: string[];
117
+ maxContainers?: number;
118
+ warmContainers?: number;
119
+ }
120
+ interface CreateSandboxPoolResponse {
121
+ poolId: string;
122
+ namespace: string;
123
+ }
124
+ interface PoolContainerInfo {
125
+ id: string;
126
+ state: string;
127
+ sandboxId?: string;
128
+ executorId: string;
129
+ }
130
+ interface SandboxPoolInfo {
131
+ poolId: string;
132
+ namespace: string;
133
+ image: string;
134
+ resources: ContainerResourcesInfo;
135
+ secretNames: string[];
136
+ timeoutSecs: number;
137
+ entrypoint?: string[];
138
+ maxContainers?: number;
139
+ warmContainers?: number;
140
+ containers?: PoolContainerInfo[];
141
+ createdAt?: Date;
142
+ updatedAt?: Date;
143
+ }
144
+ interface StartProcessOptions {
145
+ args?: string[];
146
+ env?: Record<string, string>;
147
+ workingDir?: string;
148
+ stdinMode?: StdinMode;
149
+ stdoutMode?: OutputMode;
150
+ stderrMode?: OutputMode;
151
+ }
152
+ interface ProcessInfo {
153
+ pid: number;
154
+ status: ProcessStatus;
155
+ exitCode?: number;
156
+ signal?: number;
157
+ stdinWritable: boolean;
158
+ command: string;
159
+ args: string[];
160
+ startedAt: Date;
161
+ endedAt?: Date;
162
+ }
163
+ interface SendSignalResponse {
164
+ success: boolean;
165
+ }
166
+ interface OutputResponse {
167
+ pid: number;
168
+ lines: string[];
169
+ lineCount: number;
170
+ }
171
+ interface OutputEvent {
172
+ line: string;
173
+ timestamp: Date;
174
+ stream?: string;
175
+ }
176
+ interface RunOptions {
177
+ args?: string[];
178
+ env?: Record<string, string>;
179
+ workingDir?: string;
180
+ timeout?: number;
181
+ }
182
+ interface CommandResult {
183
+ exitCode: number;
184
+ stdout: string;
185
+ stderr: string;
186
+ }
187
+ interface DirectoryEntry {
188
+ name: string;
189
+ isDir: boolean;
190
+ size?: number;
191
+ modifiedAt?: Date;
192
+ }
193
+ interface ListDirectoryResponse {
194
+ path: string;
195
+ entries: DirectoryEntry[];
196
+ }
197
+ interface CreatePtySessionOptions {
198
+ command: string;
199
+ args?: string[];
200
+ env?: Record<string, string>;
201
+ workingDir?: string;
202
+ rows?: number;
203
+ cols?: number;
204
+ }
205
+ interface PtySessionInfo {
206
+ sessionId: string;
207
+ token: string;
208
+ }
209
+ interface HealthResponse {
210
+ healthy: boolean;
211
+ }
212
+ interface DaemonInfo {
213
+ version: string;
214
+ uptimeSecs: number;
215
+ runningProcesses: number;
216
+ totalProcesses: number;
217
+ }
218
+ interface SandboxClientOptions {
219
+ apiUrl?: string;
220
+ apiKey?: string;
221
+ organizationId?: string;
222
+ projectId?: string;
223
+ namespace?: string;
224
+ maxRetries?: number;
225
+ retryBackoffMs?: number;
226
+ }
227
+ interface SandboxOptions {
228
+ sandboxId: string;
229
+ proxyUrl?: string;
230
+ apiKey?: string;
231
+ organizationId?: string;
232
+ projectId?: string;
233
+ }
234
+ interface CreateAndConnectOptions extends CreateSandboxOptions {
235
+ poolId?: string;
236
+ proxyUrl?: string;
237
+ startupTimeout?: number;
238
+ }
239
+
240
+ /**
241
+ * Client for interacting with a running sandbox.
242
+ *
243
+ * Provides process management, file operations, and I/O streaming
244
+ * through the sandbox proxy.
245
+ */
246
+ declare class Sandbox {
247
+ readonly sandboxId: string;
248
+ private readonly http;
249
+ private readonly baseUrl;
250
+ private ownsSandbox;
251
+ private lifecycleClient;
252
+ constructor(options: SandboxOptions);
253
+ /** @internal Used by SandboxClient.createAndConnect to set ownership. */
254
+ _setOwner(client: SandboxClient): void;
255
+ close(): void;
256
+ terminate(): Promise<void>;
257
+ run(command: string, options?: RunOptions): Promise<CommandResult>;
258
+ startProcess(command: string, options?: StartProcessOptions): Promise<ProcessInfo>;
259
+ listProcesses(): Promise<ProcessInfo[]>;
260
+ getProcess(pid: number): Promise<ProcessInfo>;
261
+ killProcess(pid: number): Promise<void>;
262
+ sendSignal(pid: number, signal: number): Promise<SendSignalResponse>;
263
+ writeStdin(pid: number, data: Uint8Array): Promise<void>;
264
+ closeStdin(pid: number): Promise<void>;
265
+ getStdout(pid: number): Promise<OutputResponse>;
266
+ getStderr(pid: number): Promise<OutputResponse>;
267
+ getOutput(pid: number): Promise<OutputResponse>;
268
+ followStdout(pid: number, options?: {
269
+ signal?: AbortSignal;
270
+ }): AsyncIterable<OutputEvent>;
271
+ followStderr(pid: number, options?: {
272
+ signal?: AbortSignal;
273
+ }): AsyncIterable<OutputEvent>;
274
+ followOutput(pid: number, options?: {
275
+ signal?: AbortSignal;
276
+ }): AsyncIterable<OutputEvent>;
277
+ readFile(path: string): Promise<Uint8Array>;
278
+ writeFile(path: string, content: Uint8Array): Promise<void>;
279
+ deleteFile(path: string): Promise<void>;
280
+ listDirectory(path: string): Promise<ListDirectoryResponse>;
281
+ createPtySession(options: CreatePtySessionOptions): Promise<PtySessionInfo>;
282
+ ptyWsUrl(sessionId: string, token: string): string;
283
+ health(): Promise<HealthResponse>;
284
+ info(): Promise<DaemonInfo>;
285
+ }
286
+
287
+ /**
288
+ * Client for managing TensorLake sandboxes, pools, and snapshots.
289
+ *
290
+ * Use `SandboxClient.forCloud()` or `SandboxClient.forLocalhost()` for
291
+ * clearer construction depending on your deployment target.
292
+ */
293
+ declare class SandboxClient {
294
+ private readonly http;
295
+ private readonly apiUrl;
296
+ private readonly apiKey;
297
+ private readonly organizationId;
298
+ private readonly projectId;
299
+ private readonly namespace;
300
+ private readonly local;
301
+ constructor(options?: SandboxClientOptions);
302
+ /** Create a client for the TensorLake cloud platform. */
303
+ static forCloud(options?: {
304
+ apiKey?: string;
305
+ organizationId?: string;
306
+ projectId?: string;
307
+ apiUrl?: string;
308
+ }): SandboxClient;
309
+ /** Create a client for a local Indexify server. */
310
+ static forLocalhost(options?: {
311
+ apiUrl?: string;
312
+ namespace?: string;
313
+ }): SandboxClient;
314
+ close(): void;
315
+ private path;
316
+ create(options?: CreateSandboxOptions): Promise<CreateSandboxResponse>;
317
+ get(sandboxId: string): Promise<SandboxInfo>;
318
+ list(): Promise<SandboxInfo[]>;
319
+ update(sandboxId: string, options: UpdateSandboxOptions): Promise<SandboxInfo>;
320
+ delete(sandboxId: string): Promise<void>;
321
+ claim(poolId: string): Promise<CreateSandboxResponse>;
322
+ snapshot(sandboxId: string): Promise<CreateSnapshotResponse>;
323
+ getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
324
+ listSnapshots(): Promise<SnapshotInfo[]>;
325
+ deleteSnapshot(snapshotId: string): Promise<void>;
326
+ snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<SnapshotInfo>;
327
+ createPool(options: CreatePoolOptions): Promise<CreateSandboxPoolResponse>;
328
+ getPool(poolId: string): Promise<SandboxPoolInfo>;
329
+ listPools(): Promise<SandboxPoolInfo[]>;
330
+ updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
331
+ deletePool(poolId: string): Promise<void>;
332
+ connect(sandboxId: string, proxyUrl?: string): Sandbox;
333
+ createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
334
+ }
335
+
336
+ type BinaryPayload = Uint8Array | ArrayBuffer | Blob | string;
337
+ interface CloudClientOptions {
338
+ apiUrl?: string;
339
+ apiKey?: string;
340
+ organizationId?: string;
341
+ projectId?: string;
342
+ namespace?: string;
343
+ maxRetries?: number;
344
+ retryBackoffMs?: number;
345
+ }
346
+ interface RequestInput {
347
+ name: string;
348
+ data: BinaryPayload;
349
+ contentType: string;
350
+ }
351
+ interface ApplicationSummary {
352
+ createdAt?: Date;
353
+ description: string;
354
+ entrypoint?: Record<string, unknown>;
355
+ functions?: Record<string, unknown>;
356
+ name: string;
357
+ namespace?: string;
358
+ state?: unknown;
359
+ tags: Record<string, string>;
360
+ tombstoned?: boolean;
361
+ version: string;
362
+ }
363
+ type ApplicationManifest = Record<string, unknown>;
364
+ interface RequestErrorInfo {
365
+ functionName: string;
366
+ message: string;
367
+ }
368
+ interface RequestMetadata {
369
+ id: string;
370
+ outcome?: Record<string, unknown> | string;
371
+ applicationVersion: string;
372
+ createdAt: Date;
373
+ requestError?: RequestErrorInfo;
374
+ functionRuns?: Record<string, unknown>[];
375
+ progressUpdates?: Record<string, unknown>[];
376
+ updatesPaginationToken?: string;
377
+ }
378
+ interface RequestOutput {
379
+ serializedValue: Uint8Array;
380
+ contentType: string;
381
+ }
382
+ type ApiKeyIntrospection = Record<string, unknown>;
383
+ interface NewSecret {
384
+ name: string;
385
+ value: string;
386
+ }
387
+ interface Secret {
388
+ id: string;
389
+ name: string;
390
+ createdAt?: Date;
391
+ }
392
+ interface SecretsPagination {
393
+ next?: string;
394
+ prev?: string;
395
+ total: number;
396
+ }
397
+ interface SecretsList {
398
+ items: Secret[];
399
+ pagination: SecretsPagination;
400
+ }
401
+ type UpsertSecretResponse = Secret | Secret[];
402
+ interface BuildInfo {
403
+ id: string;
404
+ status: string;
405
+ createdAt?: Date;
406
+ updatedAt?: Date;
407
+ finishedAt?: Date;
408
+ errorMessage?: string;
409
+ imageHash?: string;
410
+ imageName?: string;
411
+ }
412
+ interface BuildLogEntry {
413
+ buildId: string;
414
+ timestamp?: Date;
415
+ stream: string;
416
+ message: string;
417
+ sequenceNumber: number;
418
+ buildStatus: string;
419
+ }
420
+ interface StartImageBuildRequest {
421
+ applicationName: string;
422
+ applicationVersion: string;
423
+ functionName: string;
424
+ imageName: string;
425
+ imageId: string;
426
+ buildContext: BinaryPayload;
427
+ }
428
+ interface CreateApplicationBuildImageRequest {
429
+ key: string;
430
+ name?: string;
431
+ description?: string;
432
+ contextTarPartName: string;
433
+ contextSha256: string;
434
+ functionNames: string[];
435
+ }
436
+ interface CreateApplicationBuildRequest {
437
+ name: string;
438
+ version: string;
439
+ images: CreateApplicationBuildImageRequest[];
440
+ }
441
+ interface ApplicationBuildContext {
442
+ contextTarPartName: string;
443
+ contextTarGz: BinaryPayload;
444
+ }
445
+ interface ApplicationBuildImageResult {
446
+ id: string;
447
+ appVersionId?: string;
448
+ key?: string;
449
+ name?: string;
450
+ description?: string;
451
+ contextSha256?: string;
452
+ status: string;
453
+ errorMessage?: string;
454
+ imageUri?: string;
455
+ imageDigest?: string;
456
+ createdAt?: Date;
457
+ updatedAt?: Date;
458
+ finishedAt?: Date;
459
+ functionNames?: string[];
460
+ }
461
+ interface ApplicationBuildResponse {
462
+ id: string;
463
+ organizationId: string;
464
+ projectId: string;
465
+ name: string;
466
+ version: string;
467
+ status?: string;
468
+ createdAt?: Date;
469
+ updatedAt?: Date;
470
+ finishedAt?: Date;
471
+ imageBuilds: ApplicationBuildImageResult[];
472
+ }
473
+
474
+ declare class CloudClient {
475
+ private readonly http;
476
+ private readonly organizationId?;
477
+ private readonly projectId?;
478
+ private readonly namespace;
479
+ constructor(options?: CloudClientOptions);
480
+ static forCloud(options?: CloudClientOptions): CloudClient;
481
+ close(): void;
482
+ upsertApplication(manifest: ApplicationManifest, codeZip: BinaryPayload, upgradeRunningRequests?: boolean): Promise<void>;
483
+ deleteApplication(applicationName: string): Promise<void>;
484
+ applications(): Promise<ApplicationSummary[]>;
485
+ applicationManifest(applicationName: string): Promise<ApplicationManifest>;
486
+ runRequest(applicationName: string, inputs?: RequestInput[]): Promise<string>;
487
+ waitOnRequestCompletion(applicationName: string, requestId: string): Promise<void>;
488
+ requestMetadata(applicationName: string, requestId: string): Promise<RequestMetadata>;
489
+ requestOutput(applicationName: string, requestId: string): Promise<RequestOutput>;
490
+ introspectApiKey(): Promise<ApiKeyIntrospection>;
491
+ listSecrets(options?: {
492
+ organizationId?: string;
493
+ projectId?: string;
494
+ pageSize?: number;
495
+ }): Promise<SecretsList>;
496
+ getSecret(secretId: string, options?: {
497
+ organizationId?: string;
498
+ projectId?: string;
499
+ }): Promise<Secret>;
500
+ upsertSecrets(secrets: NewSecret | NewSecret[], options?: {
501
+ organizationId?: string;
502
+ projectId?: string;
503
+ }): Promise<UpsertSecretResponse>;
504
+ deleteSecret(secretId: string, options?: {
505
+ organizationId?: string;
506
+ projectId?: string;
507
+ }): Promise<void>;
508
+ startImageBuild(buildServicePath: string, request: StartImageBuildRequest): Promise<BuildInfo>;
509
+ createApplicationBuild(buildServicePath: string, request: CreateApplicationBuildRequest, imageContexts: ApplicationBuildContext[]): Promise<ApplicationBuildResponse>;
510
+ applicationBuildInfo(buildServicePath: string, applicationBuildId: string): Promise<ApplicationBuildResponse>;
511
+ cancelApplicationBuild(buildServicePath: string, applicationBuildId: string): Promise<ApplicationBuildResponse>;
512
+ buildInfo(buildServicePath: string, buildId: string): Promise<BuildInfo>;
513
+ cancelBuild(buildServicePath: string, buildId: string): Promise<void>;
514
+ streamBuildLogs(buildServicePath: string, buildId: string, signal?: AbortSignal): AsyncIterable<BuildLogEntry>;
515
+ private runMultipartRequest;
516
+ private namespacePath;
517
+ private resolveScope;
518
+ }
519
+
520
+ declare class APIClient {
521
+ private readonly cloudClient;
522
+ constructor(options?: CloudClientOptions);
523
+ close(): void;
524
+ upsertApplication(manifest: ApplicationManifest, codeZip: Uint8Array | ArrayBuffer | Blob | string, upgradeRunningRequests?: boolean): Promise<void>;
525
+ deleteApplication(applicationName: string): Promise<void>;
526
+ applications(): Promise<ApplicationSummary[]>;
527
+ application(applicationName: string): Promise<ApplicationManifest>;
528
+ runRequest(applicationName: string, inputs: RequestInput[]): Promise<string>;
529
+ waitOnRequestCompletion(applicationName: string, requestId: string): Promise<void>;
530
+ requestOutput(applicationName: string, requestId: string): Promise<RequestOutput>;
531
+ }
532
+
533
+ /** Base exception for all sandbox-related errors. */
534
+ declare class SandboxException extends Error {
535
+ constructor(message: string);
536
+ }
537
+ /** General sandbox operation error. */
538
+ declare class SandboxError extends SandboxException {
539
+ constructor(message: string);
540
+ }
541
+ /** Raised when the client cannot connect to the API server. */
542
+ declare class SandboxConnectionError extends SandboxError {
543
+ constructor(message: string);
544
+ }
545
+ /** Raised when a sandbox is not found. */
546
+ declare class SandboxNotFoundError extends SandboxError {
547
+ readonly sandboxId: string;
548
+ constructor(sandboxId: string);
549
+ }
550
+ /** Raised when a sandbox pool is not found. */
551
+ declare class PoolNotFoundError extends SandboxError {
552
+ readonly poolId: string;
553
+ constructor(poolId: string);
554
+ }
555
+ /** Raised when attempting to delete a pool that is in use. */
556
+ declare class PoolInUseError extends SandboxError {
557
+ readonly poolId: string;
558
+ constructor(poolId: string, message?: string);
559
+ }
560
+ /** Raised when the remote API returns an error. */
561
+ declare class RemoteAPIError extends SandboxError {
562
+ readonly statusCode: number;
563
+ readonly responseMessage: string;
564
+ constructor(statusCode: number, message: string);
565
+ }
566
+ /** Raised when request output is fetched before the request has completed. */
567
+ declare class RequestNotFinishedError extends Error {
568
+ constructor();
569
+ }
570
+ /** Raised when a request completed unsuccessfully. */
571
+ declare class RequestFailedError extends Error {
572
+ readonly failure: string;
573
+ constructor(failure: string);
574
+ }
575
+ /** Raised when a request surfaced an application-level error. */
576
+ declare class RequestExecutionError extends Error {
577
+ readonly functionName?: string;
578
+ constructor(message: string, functionName?: string);
579
+ }
580
+
581
+ export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CloudClient, type CloudClientOptions, type CommandResult, type ContainerResourcesInfo, ContainerState, type CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, type CreatePoolOptions, type CreatePtySessionOptions, type CreateSandboxOptions, type CreateSandboxPoolResponse, type CreateSandboxResponse, type CreateSnapshotResponse, type DaemonInfo, type DirectoryEntry, type HealthResponse, type ListDirectoryResponse, type NetworkConfig, type NewSecret, type OutputEvent, OutputMode, type OutputResponse, type PoolContainerInfo, PoolInUseError, PoolNotFoundError, type ProcessInfo, ProcessStatus, type PtySessionInfo, RemoteAPIError, type RequestErrorInfo, RequestExecutionError, RequestFailedError, type RequestInput, type RequestMetadata, RequestNotFinishedError, type RequestOutput, type RunOptions, Sandbox, SandboxClient, type SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, type SandboxInfo, SandboxNotFoundError, type SandboxOptions, type SandboxPoolInfo, SandboxStatus, type Secret, type SecretsList, type SecretsPagination, type SendSignalResponse, type SnapshotAndWaitOptions, type SnapshotInfo, SnapshotStatus, type StartImageBuildRequest, type StartProcessOptions, StdinMode, type UpdatePoolOptions, type UpsertSecretResponse };