@fastgpt-sdk/sandbox-adapter 0.0.30 → 0.0.32

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.
@@ -1,2862 +0,0 @@
1
- import { Client } from 'openapi-fetch';
2
- import { S as Sandboxes, p as CreateSandboxRequest, q as CreateSandboxResponse, e as SandboxId, f as SandboxInfo, x as ListSandboxesParams, L as ListSandboxesResponse, G as RenewSandboxExpirationRequest, R as RenewSandboxExpirationResponse, k as Endpoint, c as ExecdHealth, d as ExecdMetrics, j as SandboxMetrics, b as SandboxFiles, F as FileInfo, W as WriteEntry, T as SetPermissionEntry, y as MoveEntry, o as ContentReplaceEntry, K as SearchEntry, Q as SearchFilesResponse, E as ExecdCommands, n as CommandStatus, m as CommandLogs, J as RunCommandOpts, i as ServerStreamEvent, h as ExecutionHandlers, l as CommandExecution } from './sandboxes-pbhLrfFS.js';
3
-
4
- /**
5
- * This file was auto-generated by openapi-typescript.
6
- * Do not make direct changes to the file.
7
- */
8
- interface paths$1 {
9
- "/sandboxes": {
10
- parameters: {
11
- query?: never;
12
- header?: never;
13
- path?: never;
14
- cookie?: never;
15
- };
16
- /**
17
- * List sandboxes
18
- * @description List all sandboxes with optional filtering and pagination using query parameters.
19
- * All filter conditions use AND logic. Multiple `state` parameters use OR logic within states.
20
- */
21
- get: {
22
- parameters: {
23
- query?: {
24
- /**
25
- * @description Filter by lifecycle state. Pass multiple times for OR logic.
26
- * Example: `?state=Running&state=Paused`
27
- */
28
- state?: string[];
29
- /**
30
- * @description Arbitrary metadata key-value pairs for filtering,keys and values must be url encoded
31
- * Example: To filter by `project=Apollo` and `note=Demo Test`: `?metadata=project%3DApollo%26note%3DDemo%252520Test`
32
- */
33
- metadata?: string;
34
- /** @description Page number for pagination */
35
- page?: number;
36
- /** @description Number of items per page */
37
- pageSize?: number;
38
- };
39
- header?: never;
40
- path?: never;
41
- cookie?: never;
42
- };
43
- requestBody?: never;
44
- responses: {
45
- /** @description Paginated collection of sandboxes */
46
- 200: {
47
- headers: {
48
- "X-Request-ID": components$1["headers"]["XRequestId"];
49
- [name: string]: unknown;
50
- };
51
- content: {
52
- "application/json": components$1["schemas"]["ListSandboxesResponse"];
53
- };
54
- };
55
- 400: components$1["responses"]["BadRequest"];
56
- 401: components$1["responses"]["Unauthorized"];
57
- 500: components$1["responses"]["InternalServerError"];
58
- };
59
- };
60
- put?: never;
61
- /**
62
- * Create a sandbox from a container image
63
- * @description Creates a new sandbox from a container image with optional resource limits,
64
- * environment variables, and metadata. Sandboxes are provisioned directly from
65
- * the specified image without requiring a pre-created template.
66
- *
67
- * ## Authentication
68
- *
69
- * API Key authentication is required via:
70
- * - `OPEN-SANDBOX-API-KEY: <api-key>` header
71
- */
72
- post: {
73
- parameters: {
74
- query?: never;
75
- header?: never;
76
- path?: never;
77
- cookie?: never;
78
- };
79
- requestBody: {
80
- content: {
81
- "application/json": components$1["schemas"]["CreateSandboxRequest"];
82
- };
83
- };
84
- responses: {
85
- /**
86
- * @description Sandbox created and accepted for provisioning.
87
- *
88
- * The returned sandbox includes:
89
- * - `id`: Unique sandbox identifier
90
- * - `status.state: "Pending"` (auto-starting provisioning)
91
- * - `status.reason` and `status.message` indicating initialization stage
92
- * - `metadata`, `expiresAt`, `createdAt`: Core sandbox information
93
- *
94
- * Note: `image` and `updatedAt` are not included in the create response.
95
- * Use GET /sandboxes/{sandboxId} to retrieve the complete sandbox information including image spec.
96
- *
97
- * To track provisioning progress, poll GET /sandboxes/{sandboxId}.
98
- * The sandbox will automatically transition to `Running` state once provisioning completes.
99
- */
100
- 202: {
101
- headers: {
102
- "X-Request-ID": components$1["headers"]["XRequestId"];
103
- Location: components$1["headers"]["Location"];
104
- [name: string]: unknown;
105
- };
106
- content: {
107
- "application/json": components$1["schemas"]["CreateSandboxResponse"];
108
- };
109
- };
110
- 400: components$1["responses"]["BadRequest"];
111
- 401: components$1["responses"]["Unauthorized"];
112
- 409: components$1["responses"]["Conflict"];
113
- 500: components$1["responses"]["InternalServerError"];
114
- };
115
- };
116
- delete?: never;
117
- options?: never;
118
- head?: never;
119
- patch?: never;
120
- trace?: never;
121
- };
122
- "/sandboxes/{sandboxId}": {
123
- parameters: {
124
- query?: never;
125
- header?: never;
126
- path: {
127
- /** @description Unique sandbox identifier */
128
- sandboxId: components$1["parameters"]["SandboxId"];
129
- };
130
- cookie?: never;
131
- };
132
- /**
133
- * Fetch a sandbox by id
134
- * @description Returns the complete sandbox information including:
135
- * - `id`, `status`, `metadata`, `expiresAt`, `createdAt`: Core information
136
- * - `image`: Container image specification (not included in create response)
137
- * - `entrypoint`: Entry process specification
138
- *
139
- * This is the complete representation of the sandbox resource.
140
- */
141
- get: {
142
- parameters: {
143
- query?: never;
144
- header?: never;
145
- path: {
146
- /** @description Unique sandbox identifier */
147
- sandboxId: components$1["parameters"]["SandboxId"];
148
- };
149
- cookie?: never;
150
- };
151
- requestBody?: never;
152
- responses: {
153
- /** @description Sandbox current state and metadata */
154
- 200: {
155
- headers: {
156
- "X-Request-ID": components$1["headers"]["XRequestId"];
157
- [name: string]: unknown;
158
- };
159
- content: {
160
- "application/json": components$1["schemas"]["Sandbox"];
161
- };
162
- };
163
- 401: components$1["responses"]["Unauthorized"];
164
- 403: components$1["responses"]["Forbidden"];
165
- 404: components$1["responses"]["NotFound"];
166
- 500: components$1["responses"]["InternalServerError"];
167
- };
168
- };
169
- put?: never;
170
- post?: never;
171
- /**
172
- * Delete a sandbox
173
- * @description Delete a sandbox, terminating its execution. The sandbox will transition through Stopping state to Terminated.
174
- */
175
- delete: {
176
- parameters: {
177
- query?: never;
178
- header?: never;
179
- path: {
180
- /** @description Unique sandbox identifier */
181
- sandboxId: components$1["parameters"]["SandboxId"];
182
- };
183
- cookie?: never;
184
- };
185
- requestBody?: never;
186
- responses: {
187
- /**
188
- * @description Sandbox successfully deleted.
189
- *
190
- * Sandbox has been scheduled for termination and will transition to Stopping state, then Terminated.
191
- */
192
- 204: {
193
- headers: {
194
- "X-Request-ID": components$1["headers"]["XRequestId"];
195
- [name: string]: unknown;
196
- };
197
- content?: never;
198
- };
199
- 401: components$1["responses"]["Unauthorized"];
200
- 403: components$1["responses"]["Forbidden"];
201
- 404: components$1["responses"]["NotFound"];
202
- 409: components$1["responses"]["Conflict"];
203
- 500: components$1["responses"]["InternalServerError"];
204
- };
205
- };
206
- options?: never;
207
- head?: never;
208
- patch?: never;
209
- trace?: never;
210
- };
211
- "/sandboxes/{sandboxId}/pause": {
212
- parameters: {
213
- query?: never;
214
- header?: never;
215
- path?: never;
216
- cookie?: never;
217
- };
218
- get?: never;
219
- put?: never;
220
- /**
221
- * Pause execution while retaining state
222
- * @description Pause a running sandbox while preserving its state. Poll GET /sandboxes/{sandboxId} to track state transition to Paused.
223
- */
224
- post: {
225
- parameters: {
226
- query?: never;
227
- header?: never;
228
- path: {
229
- /** @description Unique sandbox identifier */
230
- sandboxId: components$1["parameters"]["SandboxId"];
231
- };
232
- cookie?: never;
233
- };
234
- requestBody?: never;
235
- responses: {
236
- /**
237
- * @description Pause operation accepted.
238
- *
239
- * Sandbox will transition to Pausing state.
240
- * Poll GET /sandboxes/{sandboxId} to track progress.
241
- */
242
- 202: {
243
- headers: {
244
- "X-Request-ID": components$1["headers"]["XRequestId"];
245
- [name: string]: unknown;
246
- };
247
- content?: never;
248
- };
249
- 401: components$1["responses"]["Unauthorized"];
250
- 403: components$1["responses"]["Forbidden"];
251
- 404: components$1["responses"]["NotFound"];
252
- 409: components$1["responses"]["Conflict"];
253
- 500: components$1["responses"]["InternalServerError"];
254
- };
255
- };
256
- delete?: never;
257
- options?: never;
258
- head?: never;
259
- patch?: never;
260
- trace?: never;
261
- };
262
- "/sandboxes/{sandboxId}/resume": {
263
- parameters: {
264
- query?: never;
265
- header?: never;
266
- path?: never;
267
- cookie?: never;
268
- };
269
- get?: never;
270
- put?: never;
271
- /**
272
- * Resume a paused sandbox
273
- * @description Resume execution of a paused sandbox. Poll GET /sandboxes/{sandboxId} to track state transition to Running.
274
- */
275
- post: {
276
- parameters: {
277
- query?: never;
278
- header?: never;
279
- path: {
280
- /** @description Unique sandbox identifier */
281
- sandboxId: components$1["parameters"]["SandboxId"];
282
- };
283
- cookie?: never;
284
- };
285
- requestBody?: never;
286
- responses: {
287
- /**
288
- * @description Resume operation accepted.
289
- *
290
- * Sandbox will transition from Paused → Running.
291
- * Poll GET /sandboxes/{sandboxId} to track progress.
292
- */
293
- 202: {
294
- headers: {
295
- "X-Request-ID": components$1["headers"]["XRequestId"];
296
- [name: string]: unknown;
297
- };
298
- content?: never;
299
- };
300
- 401: components$1["responses"]["Unauthorized"];
301
- 403: components$1["responses"]["Forbidden"];
302
- 404: components$1["responses"]["NotFound"];
303
- 409: components$1["responses"]["Conflict"];
304
- 500: components$1["responses"]["InternalServerError"];
305
- };
306
- };
307
- delete?: never;
308
- options?: never;
309
- head?: never;
310
- patch?: never;
311
- trace?: never;
312
- };
313
- "/sandboxes/{sandboxId}/renew-expiration": {
314
- parameters: {
315
- query?: never;
316
- header?: never;
317
- path?: never;
318
- cookie?: never;
319
- };
320
- get?: never;
321
- put?: never;
322
- /**
323
- * Renew sandbox expiration
324
- * @description Renew the absolute expiration time of a sandbox.
325
- */
326
- post: {
327
- parameters: {
328
- query?: never;
329
- header?: never;
330
- path: {
331
- /** @description Unique sandbox identifier */
332
- sandboxId: components$1["parameters"]["SandboxId"];
333
- };
334
- cookie?: never;
335
- };
336
- requestBody: {
337
- content: {
338
- "application/json": components$1["schemas"]["RenewSandboxExpirationRequest"];
339
- };
340
- };
341
- responses: {
342
- /**
343
- * @description Sandbox expiration updated successfully.
344
- *
345
- * Returns only the updated expiresAt field.
346
- */
347
- 200: {
348
- headers: {
349
- "X-Request-ID": components$1["headers"]["XRequestId"];
350
- [name: string]: unknown;
351
- };
352
- content: {
353
- "application/json": components$1["schemas"]["RenewSandboxExpirationResponse"];
354
- };
355
- };
356
- 400: components$1["responses"]["BadRequest"];
357
- 401: components$1["responses"]["Unauthorized"];
358
- 403: components$1["responses"]["Forbidden"];
359
- 404: components$1["responses"]["NotFound"];
360
- 409: components$1["responses"]["Conflict"];
361
- 500: components$1["responses"]["InternalServerError"];
362
- };
363
- };
364
- delete?: never;
365
- options?: never;
366
- head?: never;
367
- patch?: never;
368
- trace?: never;
369
- };
370
- "/sandboxes/{sandboxId}/endpoints/{port}": {
371
- parameters: {
372
- query?: never;
373
- header?: never;
374
- path?: never;
375
- cookie?: never;
376
- };
377
- /**
378
- * Get sandbox access endpoint
379
- * @description Get the public access endpoint URL for accessing a service running on a specific port
380
- * within the sandbox. The service must be listening on the specified port inside
381
- * the sandbox for the endpoint to be available.
382
- */
383
- get: {
384
- parameters: {
385
- query?: {
386
- /** @description Whether to return a server-proxied URL */
387
- use_server_proxy?: boolean;
388
- };
389
- header?: never;
390
- path: {
391
- /** @description Unique sandbox identifier */
392
- sandboxId: components$1["parameters"]["SandboxId"];
393
- /** @description Port number where the service is listening inside the sandbox */
394
- port: number;
395
- };
396
- cookie?: never;
397
- };
398
- requestBody?: never;
399
- responses: {
400
- /**
401
- * @description Endpoint retrieved successfully.
402
- *
403
- * Returns the public URL for accessing the service on the specified port.
404
- */
405
- 200: {
406
- headers: {
407
- "X-Request-ID": components$1["headers"]["XRequestId"];
408
- [name: string]: unknown;
409
- };
410
- content: {
411
- "application/json": components$1["schemas"]["Endpoint"];
412
- };
413
- };
414
- 401: components$1["responses"]["Unauthorized"];
415
- 403: components$1["responses"]["Forbidden"];
416
- 404: components$1["responses"]["NotFound"];
417
- 500: components$1["responses"]["InternalServerError"];
418
- };
419
- };
420
- put?: never;
421
- post?: never;
422
- delete?: never;
423
- options?: never;
424
- head?: never;
425
- patch?: never;
426
- trace?: never;
427
- };
428
- }
429
- interface components$1 {
430
- schemas: {
431
- ListSandboxesResponse: {
432
- items: components$1["schemas"]["Sandbox"][];
433
- pagination: components$1["schemas"]["PaginationInfo"];
434
- };
435
- /** @description Pagination metadata for list responses */
436
- PaginationInfo: {
437
- /** @description Current page number */
438
- page: number;
439
- /** @description Number of items per page */
440
- pageSize: number;
441
- /** @description Total number of items matching the filter */
442
- totalItems: number;
443
- /** @description Total number of pages */
444
- totalPages: number;
445
- /** @description Whether there are more pages after the current one */
446
- hasNextPage: boolean;
447
- };
448
- /** @description Response from creating a new sandbox. Contains essential information without image and updatedAt. */
449
- CreateSandboxResponse: {
450
- /** @description Unique sandbox identifier */
451
- id: string;
452
- /** @description Current lifecycle status and detailed state information */
453
- status: components$1["schemas"]["SandboxStatus"];
454
- /** @description Custom metadata from creation request */
455
- metadata?: {
456
- [key: string]: string;
457
- };
458
- /** @description Timestamp when sandbox will auto-terminate. Null when manual cleanup is enabled. */
459
- expiresAt?: string | null;
460
- /**
461
- * Format: date-time
462
- * @description Sandbox creation timestamp
463
- */
464
- createdAt: string;
465
- /** @description Entry process specification from creation request */
466
- entrypoint: string[];
467
- };
468
- /** @description Runtime execution environment provisioned from a container image */
469
- Sandbox: {
470
- /** @description Unique sandbox identifier */
471
- id: string;
472
- /**
473
- * @description Container image specification used to provision this sandbox.
474
- * Only present in responses for GET/LIST operations. Not returned in createSandbox response.
475
- */
476
- image: components$1["schemas"]["ImageSpec"];
477
- /** @description Current lifecycle status and detailed state information */
478
- status: components$1["schemas"]["SandboxStatus"];
479
- /** @description Custom metadata from creation request */
480
- metadata?: {
481
- [key: string]: string;
482
- };
483
- /**
484
- * @description The command to execute as the sandbox's entry process.
485
- * Always present in responses since entrypoint is required in creation requests.
486
- */
487
- entrypoint: string[];
488
- /** @description Timestamp when sandbox will auto-terminate. Null when manual cleanup is enabled. */
489
- expiresAt?: string | null;
490
- /**
491
- * Format: date-time
492
- * @description Sandbox creation timestamp
493
- */
494
- createdAt: string;
495
- };
496
- /**
497
- * @description High-level lifecycle state of the sandbox.
498
- *
499
- * Common state values:
500
- * - Pending: Sandbox is being provisioned
501
- * - Running: Sandbox is running and ready to accept requests
502
- * - Pausing: Sandbox is in the process of pausing
503
- * - Paused: Sandbox has been paused while retaining its state
504
- * - Stopping: Sandbox is being terminated
505
- * - Terminated: Sandbox has been successfully terminated
506
- * - Failed: Sandbox encountered a critical error
507
- *
508
- * State transitions:
509
- * - Pending → Running (after creation completes)
510
- * - Running → Pausing (when pause is requested)
511
- * - Pausing → Paused (pause operation completes)
512
- * - Paused → Running (when resume is requested)
513
- * - Running/Paused → Stopping (when kill is requested or TTL expires)
514
- * - Stopping → Terminated (kill/timeout operation completes)
515
- * - Pending/Running/Paused → Failed (on error)
516
- *
517
- * Note: New state values may be added in future versions.
518
- * Clients should handle unknown state values gracefully.
519
- */
520
- SandboxState: string;
521
- /** @description Detailed status information with lifecycle state and transition details */
522
- SandboxStatus: {
523
- /** @description Current lifecycle state of the sandbox */
524
- state: components$1["schemas"]["SandboxState"];
525
- /**
526
- * @description Short machine-readable reason code for the current state.
527
- * Examples: "user_delete", "ttl_expiry", "provision_timeout", "runtime_error"
528
- */
529
- reason?: string;
530
- /** @description Human-readable message describing the current state or reason for state transition */
531
- message?: string;
532
- /**
533
- * Format: date-time
534
- * @description Timestamp of the last state transition
535
- */
536
- lastTransitionAt?: string;
537
- };
538
- /**
539
- * @description Container image specification for sandbox provisioning.
540
- *
541
- * Supports public registry images and private registry images with authentication.
542
- */
543
- ImageSpec: {
544
- /**
545
- * @description Container image URI in standard format.
546
- *
547
- * Examples:
548
- * - "python:3.11" (Docker Hub)
549
- * - "ubuntu:22.04"
550
- * - "gcr.io/my-project/model-server:v1.0"
551
- * - "private-registry.company.com:5000/app:latest"
552
- */
553
- uri: string;
554
- /** @description Registry authentication credentials (required for private registries) */
555
- auth?: {
556
- /** @description Registry username or service account */
557
- username?: string;
558
- /** @description Registry password or authentication token */
559
- password?: string;
560
- };
561
- };
562
- /**
563
- * @description Request to create a new sandbox from a container image.
564
- *
565
- * **Note**: API Key authentication is required via the `OPEN-SANDBOX-API-KEY` header.
566
- */
567
- CreateSandboxRequest: {
568
- /** @description Container image specification for the sandbox */
569
- image: components$1["schemas"]["ImageSpec"];
570
- /**
571
- * @description Sandbox timeout in seconds. The sandbox will automatically terminate after this duration.
572
- * The maximum is controlled by the server configuration (`server.max_sandbox_timeout_seconds`).
573
- * Omit or set null to disable automatic expiration and require explicit cleanup.
574
- * Note: manual cleanup support is runtime-dependent; Kubernetes providers may reject
575
- * null timeout when the underlying workload provider does not support non-expiring sandboxes.
576
- */
577
- timeout?: number | null;
578
- /**
579
- * @description Runtime resource constraints for the sandbox instance.
580
- * SDK clients should provide sensible defaults (e.g., cpu: "500m", memory: "512Mi").
581
- */
582
- resourceLimits: components$1["schemas"]["ResourceLimits"];
583
- /**
584
- * @description Environment variables to inject into the sandbox runtime.
585
- * @example {
586
- * "API_KEY": "secret-key",
587
- * "DEBUG": "true",
588
- * "LOG_LEVEL": "info"
589
- * }
590
- */
591
- env?: {
592
- [key: string]: string;
593
- };
594
- /**
595
- * @description Custom key-value metadata for management, filtering, and tagging.
596
- * Use "name" key for a human-readable identifier.
597
- * @example {
598
- * "name": "Data Processing Sandbox",
599
- * "project": "data-processing",
600
- * "team": "ml",
601
- * "environment": "staging"
602
- * }
603
- */
604
- metadata?: {
605
- [key: string]: string;
606
- };
607
- /**
608
- * @description The command to execute as the sandbox's entry process (required).
609
- *
610
- * Explicitly specifies the user's expected main process, allowing the sandbox management
611
- * service to reliably inject control processes before executing this command.
612
- *
613
- * Format: [executable, arg1, arg2, ...]
614
- *
615
- * Examples:
616
- * - ["python", "/app/main.py"]
617
- * - ["/bin/bash"]
618
- * - ["java", "-jar", "/app/app.jar"]
619
- * - ["node", "server.js"]
620
- * @example [
621
- * "python",
622
- * "/app/main.py"
623
- * ]
624
- */
625
- entrypoint: string[];
626
- /**
627
- * @description Optional outbound network policy for the sandbox.
628
- * Shape matches the sidecar `/policy` endpoint. If omitted or empty,
629
- * the sidecar starts in allow-all mode until updated.
630
- */
631
- networkPolicy?: components$1["schemas"]["NetworkPolicy"];
632
- /**
633
- * @description Storage mounts for the sandbox. Each volume entry specifies a named backend-specific
634
- * storage source and common mount settings. Exactly one backend type must be specified
635
- * per volume entry.
636
- */
637
- volumes?: components$1["schemas"]["Volume"][];
638
- /**
639
- * @description Opaque container for provider-specific or transient parameters not supported by the core API.
640
- *
641
- * **Note**: This field is reserved for internal features, experimental flags, or temporary behaviors. Standard parameters should be proposed as core API fields.
642
- *
643
- * **Best Practices**:
644
- * - **Namespacing**: Use prefixed keys (e.g., `storage.id`) to prevent collisions.
645
- * - **Pass-through**: SDKs and middleware must treat this object as opaque and pass it through transparently.
646
- *
647
- * **Well-known keys**:
648
- * - `access.renew.extend.seconds` (optional): Decimal integer string from **300** to **86400** (5 minutes to 24 hours inclusive). Opts the sandbox into OSEP-0009 renew-on-access and sets per-renewal extension seconds. Omit to disable. Invalid values are rejected at creation with HTTP 400 (validated on the lifecycle create endpoint via `validate_extensions` in server `src/extensions/validation.py`).
649
- */
650
- extensions?: {
651
- [key: string]: string;
652
- };
653
- };
654
- /**
655
- * @description Runtime resource constraints as key-value pairs. Similar to Kubernetes resource specifications,
656
- * allows flexible definition of resource limits. Common resource types include:
657
- * - `cpu`: CPU allocation in millicores (e.g., "250m" for 0.25 CPU cores)
658
- * - `memory`: Memory allocation in bytes or human-readable format (e.g., "512Mi", "1Gi")
659
- * - `gpu`: Number of GPU devices (e.g., "1")
660
- *
661
- * New resource types can be added without API changes.
662
- * @example {
663
- * "cpu": "500m",
664
- * "memory": "512Mi",
665
- * "gpu": "1"
666
- * }
667
- */
668
- ResourceLimits: {
669
- [key: string]: string;
670
- };
671
- RenewSandboxExpirationRequest: {
672
- /**
673
- * Format: date-time
674
- * @description New absolute expiration time in UTC (RFC 3339 format).
675
- * Must be in the future and after the current expiresAt time.
676
- *
677
- * Example: "2025-11-16T14:30:45Z"
678
- */
679
- expiresAt: string;
680
- };
681
- RenewSandboxExpirationResponse: {
682
- /**
683
- * Format: date-time
684
- * @description The new absolute expiration time in UTC (RFC 3339 format).
685
- *
686
- * Example: "2025-11-16T14:30:45Z"
687
- */
688
- expiresAt: string;
689
- };
690
- /**
691
- * @description Standard error response for all non-2xx HTTP responses.
692
- * HTTP status code indicates the error category; code and message provide details.
693
- */
694
- ErrorResponse: {
695
- /**
696
- * @description Machine-readable error code (e.g., INVALID_REQUEST, NOT_FOUND, INTERNAL_ERROR).
697
- * Use this for programmatic error handling.
698
- */
699
- code: string;
700
- /** @description Human-readable error message describing what went wrong and how to fix it. */
701
- message: string;
702
- };
703
- /**
704
- * @description Endpoint for accessing a service running in the sandbox.
705
- * The service must be listening on the specified port inside the sandbox for the endpoint to be available.
706
- */
707
- Endpoint: {
708
- /**
709
- * @description Public URL to access the service from outside the sandbox.
710
- * Format: {endpoint-host}/sandboxes/{sandboxId}/port/{port}
711
- * Example: endpoint.opensandbox.io/sandboxes/abc123/port/8080
712
- */
713
- endpoint: string;
714
- /** @description Requests targeting the sandbox must include the corresponding header(s). */
715
- headers?: {
716
- [key: string]: string;
717
- };
718
- };
719
- /**
720
- * @description Egress network policy matching the sidecar `/policy` request body.
721
- * If `defaultAction` is omitted, the sidecar defaults to "deny"; passing an empty
722
- * object or null results in allow-all behavior at startup.
723
- */
724
- NetworkPolicy: {
725
- /**
726
- * @description Default action when no egress rule matches. Defaults to "deny".
727
- * @enum {string}
728
- */
729
- defaultAction?: "allow" | "deny";
730
- /** @description List of egress rules evaluated in order. */
731
- egress?: components$1["schemas"]["NetworkRule"][];
732
- };
733
- NetworkRule: {
734
- /**
735
- * @description Whether to allow or deny matching targets.
736
- * @enum {string}
737
- */
738
- action: "allow" | "deny";
739
- /**
740
- * @description FQDN or wildcard domain (e.g., "example.com", "*.example.com").
741
- * IP/CIDR not yet supported in the egress MVP.
742
- */
743
- target: string;
744
- };
745
- /**
746
- * @description Storage mount definition for a sandbox. Each volume entry contains:
747
- * - A unique name identifier
748
- * - Exactly one backend struct (host, pvc, ossfs, etc.) with backend-specific fields
749
- * - Common mount settings (mountPath, readOnly, subPath)
750
- */
751
- Volume: {
752
- /**
753
- * @description Unique identifier for the volume within the sandbox.
754
- * Must be a valid DNS label (lowercase alphanumeric, hyphens allowed, max 63 chars).
755
- */
756
- name: string;
757
- host?: components$1["schemas"]["Host"];
758
- pvc?: components$1["schemas"]["PVC"];
759
- ossfs?: components$1["schemas"]["OSSFS"];
760
- /**
761
- * @description Absolute path inside the container where the volume is mounted.
762
- * Must start with '/'.
763
- */
764
- mountPath: string;
765
- /**
766
- * @description If true, the volume is mounted as read-only. Defaults to false (read-write).
767
- * @default false
768
- */
769
- readOnly: boolean;
770
- /**
771
- * @description Optional subdirectory under the backend path to mount.
772
- * For `ossfs` backend, this field is used as the bucket prefix.
773
- * Must be a relative path without '..' components.
774
- */
775
- subPath?: string;
776
- };
777
- /**
778
- * @description Host path bind mount backend. Maps a directory on the host filesystem
779
- * into the container. Only available when the runtime supports host mounts.
780
- *
781
- * Security note: Host paths are restricted by server-side allowlist.
782
- * Users must specify paths under permitted prefixes.
783
- */
784
- Host: {
785
- /**
786
- * @description Absolute path on the host filesystem to mount.
787
- * Must start with '/' and be under an allowed prefix.
788
- */
789
- path: string;
790
- };
791
- /**
792
- * @description Platform-managed named volume backend. A runtime-neutral abstraction
793
- * for referencing a pre-existing, platform-managed named volume.
794
- *
795
- * - Kubernetes: maps to a PersistentVolumeClaim in the same namespace.
796
- * - Docker: maps to a Docker named volume (created via `docker volume create`).
797
- *
798
- * The volume must already exist on the target platform before sandbox
799
- * creation.
800
- */
801
- PVC: {
802
- /**
803
- * @description Name of the volume on the target platform.
804
- * In Kubernetes this is the PVC name; in Docker this is the named
805
- * volume name. Must be a valid DNS label.
806
- */
807
- claimName: string;
808
- };
809
- /**
810
- * @description Alibaba Cloud OSS mount backend via ossfs.
811
- *
812
- * The runtime mounts a host-side OSS path under `storage.ossfs_mount_root`
813
- * and bind-mounts the resolved path into the sandbox container.
814
- * Prefix selection is expressed via `Volume.subPath`.
815
- * In Docker runtime, OSSFS backend requires OpenSandbox Server to run on a Linux host with FUSE support.
816
- */
817
- OSSFS: {
818
- /** @description OSS bucket name. */
819
- bucket: string;
820
- /** @description OSS endpoint (e.g., `oss-cn-hangzhou.aliyuncs.com`). */
821
- endpoint: string;
822
- /**
823
- * @description ossfs major version used by runtime mount integration.
824
- * @default 2.0
825
- * @enum {string}
826
- */
827
- version: "1.0" | "2.0";
828
- /**
829
- * @description Additional ossfs mount options.
830
- * Runtime encodes options by `version`:
831
- * - `1.0`: mounts with `ossfs ... -o <option>`
832
- * - `2.0`: mounts with `ossfs2 mount ... -c <config-file>` and encodes options as `--<option>` lines in the config file
833
- * Option values must be provided as raw payloads without leading `-`.
834
- */
835
- options?: string[];
836
- /** @description OSS access key ID for inline credentials mode. */
837
- accessKeyId: string;
838
- /** @description OSS access key secret for inline credentials mode. */
839
- accessKeySecret: string;
840
- };
841
- };
842
- responses: {
843
- /** @description Error response envelope */
844
- Error: {
845
- headers: {
846
- [name: string]: unknown;
847
- };
848
- content: {
849
- "application/json": components$1["schemas"]["ErrorResponse"];
850
- };
851
- };
852
- /** @description The request was invalid or malformed */
853
- BadRequest: {
854
- headers: {
855
- "X-Request-ID": components$1["headers"]["XRequestId"];
856
- [name: string]: unknown;
857
- };
858
- content: {
859
- "application/json": components$1["schemas"]["ErrorResponse"];
860
- };
861
- };
862
- /** @description Authentication credentials are missing or invalid */
863
- Unauthorized: {
864
- headers: {
865
- "X-Request-ID": components$1["headers"]["XRequestId"];
866
- [name: string]: unknown;
867
- };
868
- content: {
869
- "application/json": components$1["schemas"]["ErrorResponse"];
870
- };
871
- };
872
- /** @description The authenticated user lacks permission for this operation */
873
- Forbidden: {
874
- headers: {
875
- "X-Request-ID": components$1["headers"]["XRequestId"];
876
- [name: string]: unknown;
877
- };
878
- content: {
879
- "application/json": components$1["schemas"]["ErrorResponse"];
880
- };
881
- };
882
- /** @description The requested resource does not exist */
883
- NotFound: {
884
- headers: {
885
- "X-Request-ID": components$1["headers"]["XRequestId"];
886
- [name: string]: unknown;
887
- };
888
- content: {
889
- "application/json": components$1["schemas"]["ErrorResponse"];
890
- };
891
- };
892
- /** @description The operation conflicts with the current state */
893
- Conflict: {
894
- headers: {
895
- "X-Request-ID": components$1["headers"]["XRequestId"];
896
- [name: string]: unknown;
897
- };
898
- content: {
899
- "application/json": components$1["schemas"]["ErrorResponse"];
900
- };
901
- };
902
- /** @description An unexpected server error occurred */
903
- InternalServerError: {
904
- headers: {
905
- "X-Request-ID": components$1["headers"]["XRequestId"];
906
- [name: string]: unknown;
907
- };
908
- content: {
909
- "application/json": components$1["schemas"]["ErrorResponse"];
910
- };
911
- };
912
- };
913
- parameters: {
914
- /** @description Unique sandbox identifier */
915
- SandboxId: string;
916
- };
917
- requestBodies: never;
918
- headers: {
919
- /** @description Unique request identifier for tracing */
920
- XRequestId: string;
921
- /** @description URI of the newly created or related resource */
922
- Location: string;
923
- /** @description Suggested delay in seconds before retrying */
924
- RetryAfter: number;
925
- };
926
- pathItems: never;
927
- }
928
-
929
- type LifecycleClient = Client<paths$1>;
930
- interface CreateLifecycleClientOptions {
931
- /**
932
- * Base URL to OpenSandbox Lifecycle API, including the `/v1` prefix.
933
- * Example: `http://localhost:8080/v1`
934
- */
935
- baseUrl?: string;
936
- /**
937
- * API key for `OPEN-SANDBOX-API-KEY` header.
938
- * If omitted, reads from `process.env.OPEN_SANDBOX_API_KEY` when available.
939
- */
940
- apiKey?: string;
941
- /**
942
- * Extra headers applied to every request.
943
- */
944
- headers?: Record<string, string>;
945
- /**
946
- * Custom fetch implementation.
947
- *
948
- * Useful for proxies, custom TLS, request tracing, retries, or running in environments
949
- * where a global `fetch` is not available.
950
- */
951
- fetch?: typeof fetch;
952
- }
953
- declare function createLifecycleClient(opts?: CreateLifecycleClientOptions): LifecycleClient;
954
-
955
- /**
956
- * This file was auto-generated by openapi-typescript.
957
- * Do not make direct changes to the file.
958
- */
959
- /**
960
- * NOTE: The session-related path types and operations in this file (e.g. /session, runInSession)
961
- * are generated from the execd OpenAPI spec. They are not the recommended runtime entry point.
962
- * Use `sandbox.commands.createSession()`, `sandbox.commands.runInSession()`, and
963
- * `sandbox.commands.deleteSession()` instead.
964
- */
965
- interface paths {
966
- "/ping": {
967
- parameters: {
968
- query?: never;
969
- header?: never;
970
- path?: never;
971
- cookie?: never;
972
- };
973
- /**
974
- * Health check endpoint
975
- * @description Performs a simple health check to verify that the server is running and responsive.
976
- * Returns HTTP 200 OK status if the server is healthy. This endpoint is typically used
977
- * by load balancers, monitoring systems, and orchestration platforms (like Kubernetes)
978
- * to check service availability.
979
- */
980
- get: operations["ping"];
981
- put?: never;
982
- post?: never;
983
- delete?: never;
984
- options?: never;
985
- head?: never;
986
- patch?: never;
987
- trace?: never;
988
- };
989
- "/code/contexts": {
990
- parameters: {
991
- query?: never;
992
- header?: never;
993
- path?: never;
994
- cookie?: never;
995
- };
996
- /**
997
- * List active code execution contexts
998
- * @description Lists all active/available code execution contexts.
999
- * If `language` is provided, only contexts under that language/runtime are returned.
1000
- */
1001
- get: operations["listContexts"];
1002
- put?: never;
1003
- post?: never;
1004
- /**
1005
- * Delete all contexts under a language
1006
- * @description Deletes all existing code execution contexts under the specified `language`/runtime.
1007
- * This is a bulk operation intended for code-interpreter context cleanup.
1008
- */
1009
- delete: operations["deleteContextsByLanguage"];
1010
- options?: never;
1011
- head?: never;
1012
- patch?: never;
1013
- trace?: never;
1014
- };
1015
- "/code/contexts/{context_id}": {
1016
- parameters: {
1017
- query?: never;
1018
- header?: never;
1019
- path?: never;
1020
- cookie?: never;
1021
- };
1022
- /**
1023
- * Get a code execution context by id
1024
- * @description Retrieves the details of an existing code execution context (session) by id.
1025
- * Returns the context ID, language, and any associated metadata.
1026
- */
1027
- get: operations["getContext"];
1028
- put?: never;
1029
- post?: never;
1030
- /**
1031
- * Delete a code execution context by id
1032
- * @description Deletes an existing code execution context (session) by id.
1033
- * This should terminate the underlying context thread/process and release resources.
1034
- */
1035
- delete: operations["deleteContext"];
1036
- options?: never;
1037
- head?: never;
1038
- patch?: never;
1039
- trace?: never;
1040
- };
1041
- "/code/context": {
1042
- parameters: {
1043
- query?: never;
1044
- header?: never;
1045
- path?: never;
1046
- cookie?: never;
1047
- };
1048
- get?: never;
1049
- put?: never;
1050
- /**
1051
- * Create code execution context
1052
- * @description Creates a new code execution environment and returns a session ID that can be used
1053
- * for subsequent code execution requests. The context maintains state across multiple
1054
- * code executions within the same session.
1055
- */
1056
- post: operations["createCodeContext"];
1057
- delete?: never;
1058
- options?: never;
1059
- head?: never;
1060
- patch?: never;
1061
- trace?: never;
1062
- };
1063
- "/code": {
1064
- parameters: {
1065
- query?: never;
1066
- header?: never;
1067
- path?: never;
1068
- cookie?: never;
1069
- };
1070
- get?: never;
1071
- put?: never;
1072
- /**
1073
- * Execute code in context
1074
- * @description Executes code using Jupyter kernel in a specified execution context and streams
1075
- * the output in real-time using SSE (Server-Sent Events). Supports multiple programming
1076
- * languages (Python, JavaScript, etc.) and maintains execution state within the session.
1077
- * Returns execution results, output streams, execution count, and any errors.
1078
- */
1079
- post: operations["runCode"];
1080
- /**
1081
- * Interrupt code execution
1082
- * @description Interrupts the currently running code execution in the specified context.
1083
- * This sends a signal to terminate the execution process and releases associated resources.
1084
- */
1085
- delete: operations["interruptCode"];
1086
- options?: never;
1087
- head?: never;
1088
- patch?: never;
1089
- trace?: never;
1090
- };
1091
- "/session": {
1092
- parameters: {
1093
- query?: never;
1094
- header?: never;
1095
- path?: never;
1096
- cookie?: never;
1097
- };
1098
- get?: never;
1099
- put?: never;
1100
- /**
1101
- * Create bash session (create_session)
1102
- * @description Creates a new bash session and returns a session ID for subsequent run_in_session requests.
1103
- * The session maintains shell state (e.g. working directory, environment) across multiple
1104
- * code executions. Request body is optional; an empty body uses default options (no cwd override).
1105
- */
1106
- post: operations["createSession"];
1107
- delete?: never;
1108
- options?: never;
1109
- head?: never;
1110
- patch?: never;
1111
- trace?: never;
1112
- };
1113
- "/session/{sessionId}/run": {
1114
- parameters: {
1115
- query?: never;
1116
- header?: never;
1117
- path?: never;
1118
- cookie?: never;
1119
- };
1120
- get?: never;
1121
- put?: never;
1122
- /**
1123
- * Run code in bash session (run_in_session)
1124
- * @description Executes code in an existing bash session and streams the output in real-time via SSE
1125
- * (Server-Sent Events). The session must have been created by create_session. Supports
1126
- * optional working directory override and timeout (milliseconds).
1127
- */
1128
- post: operations["runInSession"];
1129
- delete?: never;
1130
- options?: never;
1131
- head?: never;
1132
- patch?: never;
1133
- trace?: never;
1134
- };
1135
- "/session/{sessionId}": {
1136
- parameters: {
1137
- query?: never;
1138
- header?: never;
1139
- path?: never;
1140
- cookie?: never;
1141
- };
1142
- get?: never;
1143
- put?: never;
1144
- post?: never;
1145
- /**
1146
- * Delete bash session (delete_session)
1147
- * @description Deletes an existing bash session by ID. Terminates the underlying shell process
1148
- * and releases resources. The session ID must have been returned by create_session.
1149
- */
1150
- delete: operations["deleteSession"];
1151
- options?: never;
1152
- head?: never;
1153
- patch?: never;
1154
- trace?: never;
1155
- };
1156
- "/command": {
1157
- parameters: {
1158
- query?: never;
1159
- header?: never;
1160
- path?: never;
1161
- cookie?: never;
1162
- };
1163
- get?: never;
1164
- put?: never;
1165
- /**
1166
- * Execute shell command
1167
- * @description Executes a shell command and streams the output in real-time using SSE (Server-Sent Events).
1168
- * The command can run in foreground or background mode. The response includes stdout, stderr,
1169
- * execution status, and completion events.
1170
- * Optionally specify `timeout` (milliseconds) to enforce a maximum runtime; the server will
1171
- * terminate the process when the timeout is reached. You can also pass `uid`/`gid` to run
1172
- * with specific user/group IDs, and `envs` to inject environment variables.
1173
- */
1174
- post: operations["runCommand"];
1175
- /**
1176
- * Interrupt command execution
1177
- * @description Interrupts the currently running command execution in the specified context.
1178
- * This sends a signal to terminate the execution process and releases associated resources.
1179
- */
1180
- delete: operations["interruptCommand"];
1181
- options?: never;
1182
- head?: never;
1183
- patch?: never;
1184
- trace?: never;
1185
- };
1186
- "/command/status/{id}": {
1187
- parameters: {
1188
- query?: never;
1189
- header?: never;
1190
- path?: never;
1191
- cookie?: never;
1192
- };
1193
- /**
1194
- * Get command running status
1195
- * @description Returns the current status of a command (foreground or background) by command ID.
1196
- * Includes running flag, exit code, error (if any), and start/finish timestamps.
1197
- */
1198
- get: operations["getCommandStatus"];
1199
- put?: never;
1200
- post?: never;
1201
- delete?: never;
1202
- options?: never;
1203
- head?: never;
1204
- patch?: never;
1205
- trace?: never;
1206
- };
1207
- "/command/{id}/logs": {
1208
- parameters: {
1209
- query?: never;
1210
- header?: never;
1211
- path?: never;
1212
- cookie?: never;
1213
- };
1214
- /**
1215
- * Get background command stdout/stderr (non-streamed)
1216
- * @description Returns stdout and stderr for a background (detached) command by command ID.
1217
- * Foreground commands should be consumed via SSE; this endpoint is intended for
1218
- * polling logs of background commands. Supports incremental reads similar to a file seek:
1219
- * pass a starting line via query to fetch output after that line and receive the latest
1220
- * tail cursor for the next poll. When no starting line is provided, the full logs are returned.
1221
- * Response body is plain text so it can be rendered directly in browsers; the latest line index
1222
- * is provided via response header `EXECD-COMMANDS-TAIL-CURSOR` for subsequent incremental requests.
1223
- */
1224
- get: operations["getBackgroundCommandLogs"];
1225
- put?: never;
1226
- post?: never;
1227
- delete?: never;
1228
- options?: never;
1229
- head?: never;
1230
- patch?: never;
1231
- trace?: never;
1232
- };
1233
- "/files/info": {
1234
- parameters: {
1235
- query?: never;
1236
- header?: never;
1237
- path?: never;
1238
- cookie?: never;
1239
- };
1240
- /**
1241
- * Get file metadata
1242
- * @description Retrieves detailed metadata for one or multiple files including permissions, owner,
1243
- * group, size, and modification time. Returns a map of file paths to their corresponding
1244
- * FileInfo objects.
1245
- */
1246
- get: operations["getFilesInfo"];
1247
- put?: never;
1248
- post?: never;
1249
- delete?: never;
1250
- options?: never;
1251
- head?: never;
1252
- patch?: never;
1253
- trace?: never;
1254
- };
1255
- "/files": {
1256
- parameters: {
1257
- query?: never;
1258
- header?: never;
1259
- path?: never;
1260
- cookie?: never;
1261
- };
1262
- get?: never;
1263
- put?: never;
1264
- post?: never;
1265
- /**
1266
- * Delete files
1267
- * @description Deletes one or multiple files from the sandbox. Only removes files, not directories.
1268
- * Use RemoveDirs for directory removal.
1269
- */
1270
- delete: operations["removeFiles"];
1271
- options?: never;
1272
- head?: never;
1273
- patch?: never;
1274
- trace?: never;
1275
- };
1276
- "/files/permissions": {
1277
- parameters: {
1278
- query?: never;
1279
- header?: never;
1280
- path?: never;
1281
- cookie?: never;
1282
- };
1283
- get?: never;
1284
- put?: never;
1285
- /**
1286
- * Change file permissions
1287
- * @description Changes permissions (mode), owner, and group for one or multiple files.
1288
- * Accepts a map of file paths to permission settings including octal mode,
1289
- * owner username, and group name.
1290
- */
1291
- post: operations["chmodFiles"];
1292
- delete?: never;
1293
- options?: never;
1294
- head?: never;
1295
- patch?: never;
1296
- trace?: never;
1297
- };
1298
- "/files/mv": {
1299
- parameters: {
1300
- query?: never;
1301
- header?: never;
1302
- path?: never;
1303
- cookie?: never;
1304
- };
1305
- get?: never;
1306
- put?: never;
1307
- /**
1308
- * Rename or move files
1309
- * @description Renames or moves one or multiple files to new paths. Can be used for both
1310
- * renaming within the same directory and moving to different directories.
1311
- * Target directory must exist.
1312
- */
1313
- post: operations["renameFiles"];
1314
- delete?: never;
1315
- options?: never;
1316
- head?: never;
1317
- patch?: never;
1318
- trace?: never;
1319
- };
1320
- "/files/search": {
1321
- parameters: {
1322
- query?: never;
1323
- header?: never;
1324
- path?: never;
1325
- cookie?: never;
1326
- };
1327
- /**
1328
- * Search for files
1329
- * @description Searches for files matching a glob pattern within a specified directory and
1330
- * its subdirectories. Returns file metadata including path, permissions, owner,
1331
- * and group. Supports glob patterns like **, *.txt, etc. Default pattern is ** (all files).
1332
- */
1333
- get: operations["searchFiles"];
1334
- put?: never;
1335
- post?: never;
1336
- delete?: never;
1337
- options?: never;
1338
- head?: never;
1339
- patch?: never;
1340
- trace?: never;
1341
- };
1342
- "/files/replace": {
1343
- parameters: {
1344
- query?: never;
1345
- header?: never;
1346
- path?: never;
1347
- cookie?: never;
1348
- };
1349
- get?: never;
1350
- put?: never;
1351
- /**
1352
- * Replace file content
1353
- * @description Performs text replacement in one or multiple files. Replaces all occurrences
1354
- * of the old string with the new string (similar to strings.ReplaceAll).
1355
- * Preserves file permissions. Useful for batch text substitution across files.
1356
- */
1357
- post: operations["replaceContent"];
1358
- delete?: never;
1359
- options?: never;
1360
- head?: never;
1361
- patch?: never;
1362
- trace?: never;
1363
- };
1364
- "/files/upload": {
1365
- parameters: {
1366
- query?: never;
1367
- header?: never;
1368
- path?: never;
1369
- cookie?: never;
1370
- };
1371
- get?: never;
1372
- put?: never;
1373
- /**
1374
- * Upload files to sandbox
1375
- * @description Uploads one or multiple files to specified paths within the sandbox.
1376
- * Reads metadata and file content from multipart form parts in sequence.
1377
- * Each file upload consists of two parts: a metadata part (JSON) followed
1378
- * by the actual file part.
1379
- */
1380
- post: operations["uploadFile"];
1381
- delete?: never;
1382
- options?: never;
1383
- head?: never;
1384
- patch?: never;
1385
- trace?: never;
1386
- };
1387
- "/files/download": {
1388
- parameters: {
1389
- query?: never;
1390
- header?: never;
1391
- path?: never;
1392
- cookie?: never;
1393
- };
1394
- /**
1395
- * Download file from sandbox
1396
- * @description Downloads a file from the specified path within the sandbox. Supports HTTP
1397
- * range requests for resumable downloads and partial content retrieval.
1398
- * Returns file as octet-stream with appropriate headers.
1399
- */
1400
- get: operations["downloadFile"];
1401
- put?: never;
1402
- post?: never;
1403
- delete?: never;
1404
- options?: never;
1405
- head?: never;
1406
- patch?: never;
1407
- trace?: never;
1408
- };
1409
- "/directories": {
1410
- parameters: {
1411
- query?: never;
1412
- header?: never;
1413
- path?: never;
1414
- cookie?: never;
1415
- };
1416
- get?: never;
1417
- put?: never;
1418
- /**
1419
- * Create directories
1420
- * @description Creates one or multiple directories with specified permissions. Creates parent
1421
- * directories as needed (similar to mkdir -p). Accepts a map of directory paths
1422
- * to permission objects.
1423
- */
1424
- post: operations["makeDirs"];
1425
- /**
1426
- * Delete directories
1427
- * @description Recursively deletes one or multiple directories and all their contents.
1428
- * Similar to rm -rf. Use with caution as this operation cannot be undone.
1429
- */
1430
- delete: operations["removeDirs"];
1431
- options?: never;
1432
- head?: never;
1433
- patch?: never;
1434
- trace?: never;
1435
- };
1436
- "/metrics": {
1437
- parameters: {
1438
- query?: never;
1439
- header?: never;
1440
- path?: never;
1441
- cookie?: never;
1442
- };
1443
- /**
1444
- * Get system metrics
1445
- * @description Retrieves current system resource metrics including CPU usage percentage,
1446
- * CPU core count, total memory, used memory, and timestamp. Provides a snapshot
1447
- * of system resource utilization at the time of request.
1448
- */
1449
- get: operations["getMetrics"];
1450
- put?: never;
1451
- post?: never;
1452
- delete?: never;
1453
- options?: never;
1454
- head?: never;
1455
- patch?: never;
1456
- trace?: never;
1457
- };
1458
- "/metrics/watch": {
1459
- parameters: {
1460
- query?: never;
1461
- header?: never;
1462
- path?: never;
1463
- cookie?: never;
1464
- };
1465
- /**
1466
- * Watch system metrics in real-time
1467
- * @description Streams system resource metrics in real-time using Server-Sent Events (SSE).
1468
- * Updates are sent every second, providing continuous monitoring of CPU usage,
1469
- * memory usage, and other system metrics. The connection remains open until
1470
- * the client disconnects.
1471
- */
1472
- get: operations["watchMetrics"];
1473
- put?: never;
1474
- post?: never;
1475
- delete?: never;
1476
- options?: never;
1477
- head?: never;
1478
- patch?: never;
1479
- trace?: never;
1480
- };
1481
- }
1482
- interface components {
1483
- schemas: {
1484
- /** @description Request to create a bash session (optional body; empty treated as defaults) */
1485
- CreateSessionRequest: {
1486
- /**
1487
- * @description Working directory for the session (optional)
1488
- * @example /workspace
1489
- */
1490
- cwd?: string;
1491
- };
1492
- /** @description Response for create_session */
1493
- CreateSessionResponse: {
1494
- /**
1495
- * @description Unique session ID for run_in_session and delete_session
1496
- * @example session-abc123
1497
- */
1498
- session_id: string;
1499
- };
1500
- /** @description Request to run code in an existing bash session */
1501
- RunInSessionRequest: {
1502
- /**
1503
- * @description Shell code to execute in the session
1504
- * @example echo "Hello"
1505
- */
1506
- code: string;
1507
- /**
1508
- * @description Working directory override for this run (optional)
1509
- * @example /workspace
1510
- */
1511
- cwd?: string;
1512
- /**
1513
- * Format: int64
1514
- * @description Maximum execution time in milliseconds (optional; server may not enforce if omitted)
1515
- * @example 30000
1516
- */
1517
- timeout_ms?: number;
1518
- };
1519
- /** @description Request to create a code execution context */
1520
- CodeContextRequest: {
1521
- /**
1522
- * @description Execution runtime (python, bash, java, etc.)
1523
- * @example python
1524
- */
1525
- language?: string;
1526
- };
1527
- /** @description Code execution context with session identifier */
1528
- CodeContext: {
1529
- /**
1530
- * @description Unique session identifier returned by CreateContext
1531
- * @example session-abc123
1532
- */
1533
- id?: string;
1534
- /**
1535
- * @description Execution runtime
1536
- * @example python
1537
- */
1538
- language: string;
1539
- };
1540
- /** @description Request to execute code in a context */
1541
- RunCodeRequest: {
1542
- context?: components["schemas"]["CodeContext"];
1543
- /**
1544
- * @description Source code to execute
1545
- * @example import numpy as np
1546
- * result = np.array([1, 2, 3])
1547
- * print(result)
1548
- */
1549
- code: string;
1550
- };
1551
- /** @description Request to execute a shell command */
1552
- RunCommandRequest: {
1553
- /**
1554
- * @description Shell command to execute
1555
- * @example ls -la /workspace
1556
- */
1557
- command: string;
1558
- /**
1559
- * @description Working directory for command execution
1560
- * @example /workspace
1561
- */
1562
- cwd?: string;
1563
- /**
1564
- * @description Whether to run command in detached mode
1565
- * @default false
1566
- * @example false
1567
- */
1568
- background: boolean;
1569
- /**
1570
- * Format: int64
1571
- * @description Maximum allowed execution time in milliseconds before the command is forcefully terminated by the server. If omitted, the server will not enforce any timeout.
1572
- * @example 60000
1573
- */
1574
- timeout?: number;
1575
- /**
1576
- * Format: int32
1577
- * @description Unix user ID used to run the command. If `gid` is provided, `uid` is required.
1578
- * @example 1000
1579
- */
1580
- uid?: number;
1581
- /**
1582
- * Format: int32
1583
- * @description Unix group ID used to run the command. Requires `uid` to be provided.
1584
- * @example 1000
1585
- */
1586
- gid?: number;
1587
- /**
1588
- * @description Environment variables injected into the command process.
1589
- * @example {
1590
- * "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
1591
- * "PYTHONUNBUFFERED": "1"
1592
- * }
1593
- */
1594
- envs?: {
1595
- [key: string]: string;
1596
- };
1597
- };
1598
- /** @description Command execution status (foreground or background) */
1599
- CommandStatusResponse: {
1600
- /**
1601
- * @description Command ID returned by RunCommand
1602
- * @example cmd-abc123
1603
- */
1604
- id?: string;
1605
- /**
1606
- * @description Original command content
1607
- * @example ls -la
1608
- */
1609
- content?: string;
1610
- /**
1611
- * @description Whether the command is still running
1612
- * @example false
1613
- */
1614
- running?: boolean;
1615
- /**
1616
- * Format: int32
1617
- * @description Exit code if the command has finished
1618
- * @example 0
1619
- */
1620
- exit_code?: number | null;
1621
- /**
1622
- * @description Error message if the command failed
1623
- * @example permission denied
1624
- */
1625
- error?: string;
1626
- /**
1627
- * Format: date-time
1628
- * @description Start time in RFC3339 format
1629
- * @example 2025-12-22T09:08:05Z
1630
- */
1631
- started_at?: string;
1632
- /**
1633
- * Format: date-time
1634
- * @description Finish time in RFC3339 format (null if still running)
1635
- * @example 2025-12-22T09:08:09Z
1636
- */
1637
- finished_at?: string | null;
1638
- };
1639
- /** @description Server-sent event for streaming execution output */
1640
- ServerStreamEvent: {
1641
- /**
1642
- * @description Event type for client-side handling
1643
- * @example stdout
1644
- * @enum {string}
1645
- */
1646
- type?: "init" | "status" | "error" | "stdout" | "stderr" | "result" | "execution_complete" | "execution_count" | "ping";
1647
- /**
1648
- * @description Textual data for status, init, and stream events
1649
- * @example Hello, World!
1650
- */
1651
- text?: string;
1652
- /**
1653
- * @description Cell execution number in the session
1654
- * @example 1
1655
- */
1656
- execution_count?: number;
1657
- /**
1658
- * Format: int64
1659
- * @description Execution duration in milliseconds
1660
- * @example 150
1661
- */
1662
- execution_time?: number;
1663
- /**
1664
- * Format: int64
1665
- * @description When the event was generated (Unix milliseconds)
1666
- * @example 1700000000000
1667
- */
1668
- timestamp?: number;
1669
- /**
1670
- * @description Execution output in various MIME types (e.g., "text/plain", "text/html")
1671
- * @example {
1672
- * "text/plain": "4"
1673
- * }
1674
- */
1675
- results?: {
1676
- [key: string]: unknown;
1677
- };
1678
- /** @description Execution error details if an error occurred */
1679
- error?: {
1680
- /**
1681
- * @description Error name/type
1682
- * @example NameError
1683
- */
1684
- ename?: string;
1685
- /**
1686
- * @description Error value/message
1687
- * @example name 'undefined_var' is not defined
1688
- */
1689
- evalue?: string;
1690
- /**
1691
- * @description Stack trace lines
1692
- * @example [
1693
- * "Traceback (most recent call last):",
1694
- * " File \"<stdin>\", line 1, in <module>",
1695
- * "NameError: name 'undefined_var' is not defined"
1696
- * ]
1697
- */
1698
- traceback?: string[];
1699
- };
1700
- };
1701
- /** @description File metadata including path and permissions */
1702
- FileInfo: {
1703
- /**
1704
- * @description Absolute file path
1705
- * @example /workspace/file.txt
1706
- */
1707
- path: string;
1708
- /**
1709
- * Format: int64
1710
- * @description File size in bytes
1711
- * @example 2048
1712
- */
1713
- size: number;
1714
- /**
1715
- * Format: date-time
1716
- * @description Last modification time
1717
- * @example 2025-11-16T14:30:45Z
1718
- */
1719
- modified_at: string;
1720
- /**
1721
- * Format: date-time
1722
- * @description File creation time
1723
- * @example 2025-11-16T14:30:45Z
1724
- */
1725
- created_at: string;
1726
- /**
1727
- * @description File owner username
1728
- * @example admin
1729
- */
1730
- owner: string;
1731
- /**
1732
- * @description File group name
1733
- * @example admin
1734
- */
1735
- group: string;
1736
- /**
1737
- * @description File permissions in octal format
1738
- * @example 755
1739
- */
1740
- mode: number;
1741
- };
1742
- /** @description File ownership and mode settings */
1743
- Permission: {
1744
- /**
1745
- * @description Owner username
1746
- * @example root
1747
- */
1748
- owner?: string;
1749
- /**
1750
- * @description Group name
1751
- * @example root
1752
- */
1753
- group?: string;
1754
- /**
1755
- * @description Permission mode in octal format (e.g., 644, 755)
1756
- * @default 755
1757
- * @example 755
1758
- */
1759
- mode: number;
1760
- };
1761
- /** @description File metadata for upload operations */
1762
- FileMetadata: {
1763
- /**
1764
- * @description Target file path
1765
- * @example /workspace/upload.txt
1766
- */
1767
- path?: string;
1768
- /**
1769
- * @description File owner
1770
- * @example admin
1771
- */
1772
- owner?: string;
1773
- /**
1774
- * @description File group
1775
- * @example admin
1776
- */
1777
- group?: string;
1778
- /**
1779
- * @description File permissions in octal
1780
- * @example 755
1781
- */
1782
- mode?: number;
1783
- };
1784
- /** @description File rename/move operation */
1785
- RenameFileItem: {
1786
- /**
1787
- * @description Source file path
1788
- * @example /workspace/old.txt
1789
- */
1790
- src: string;
1791
- /**
1792
- * @description Destination file path
1793
- * @example /workspace/new.txt
1794
- */
1795
- dest: string;
1796
- };
1797
- /** @description Content replacement operation */
1798
- ReplaceFileContentItem: {
1799
- /**
1800
- * @description String to be replaced
1801
- * @example localhost
1802
- */
1803
- old: string;
1804
- /**
1805
- * @description Replacement string
1806
- * @example 0.0.0.0
1807
- */
1808
- new: string;
1809
- };
1810
- /** @description System resource usage metrics */
1811
- Metrics: {
1812
- /**
1813
- * Format: float
1814
- * @description Number of CPU cores
1815
- * @example 4
1816
- */
1817
- cpu_count: number;
1818
- /**
1819
- * Format: float
1820
- * @description CPU usage percentage
1821
- * @example 45.5
1822
- */
1823
- cpu_used_pct: number;
1824
- /**
1825
- * Format: float
1826
- * @description Total memory in MiB
1827
- * @example 8192
1828
- */
1829
- mem_total_mib: number;
1830
- /**
1831
- * Format: float
1832
- * @description Used memory in MiB
1833
- * @example 4096
1834
- */
1835
- mem_used_mib: number;
1836
- /**
1837
- * Format: int64
1838
- * @description Timestamp when metrics were collected (Unix milliseconds)
1839
- * @example 1700000000000
1840
- */
1841
- timestamp: number;
1842
- };
1843
- /** @description Standard error response format */
1844
- ErrorResponse: {
1845
- /**
1846
- * @description Error code for programmatic handling
1847
- * @example INVALID_REQUEST_BODY
1848
- */
1849
- code: string;
1850
- /**
1851
- * @description Human-readable error message
1852
- * @example error parsing request, MAYBE invalid body format
1853
- */
1854
- message: string;
1855
- };
1856
- };
1857
- responses: {
1858
- /** @description Invalid request body format or missing required fields */
1859
- BadRequest: {
1860
- headers: {
1861
- [name: string]: unknown;
1862
- };
1863
- content: {
1864
- /**
1865
- * @example {
1866
- * "code": "INVALID_REQUEST_BODY",
1867
- * "message": "error parsing request, MAYBE invalid body format"
1868
- * }
1869
- */
1870
- "application/json": components["schemas"]["ErrorResponse"];
1871
- };
1872
- };
1873
- /** @description File or resource not found */
1874
- NotFound: {
1875
- headers: {
1876
- [name: string]: unknown;
1877
- };
1878
- content: {
1879
- /**
1880
- * @example {
1881
- * "code": "FILE_NOT_FOUND",
1882
- * "message": "file not found"
1883
- * }
1884
- */
1885
- "application/json": components["schemas"]["ErrorResponse"];
1886
- };
1887
- };
1888
- /** @description Runtime server error during operation */
1889
- InternalServerError: {
1890
- headers: {
1891
- [name: string]: unknown;
1892
- };
1893
- content: {
1894
- /**
1895
- * @example {
1896
- * "code": "RUNTIME_ERROR",
1897
- * "message": "error running code execution"
1898
- * }
1899
- */
1900
- "application/json": components["schemas"]["ErrorResponse"];
1901
- };
1902
- };
1903
- };
1904
- parameters: never;
1905
- requestBodies: never;
1906
- headers: never;
1907
- pathItems: never;
1908
- }
1909
- interface operations {
1910
- ping: {
1911
- parameters: {
1912
- query?: never;
1913
- header?: never;
1914
- path?: never;
1915
- cookie?: never;
1916
- };
1917
- requestBody?: never;
1918
- responses: {
1919
- /** @description Server is alive and healthy */
1920
- 200: {
1921
- headers: {
1922
- [name: string]: unknown;
1923
- };
1924
- content?: never;
1925
- };
1926
- };
1927
- };
1928
- listContexts: {
1929
- parameters: {
1930
- query: {
1931
- /**
1932
- * @description Filter contexts by execution runtime (python, bash, java, etc.)
1933
- * @example python
1934
- */
1935
- language: string;
1936
- };
1937
- header?: never;
1938
- path?: never;
1939
- cookie?: never;
1940
- };
1941
- requestBody?: never;
1942
- responses: {
1943
- /** @description Array of active contexts */
1944
- 200: {
1945
- headers: {
1946
- [name: string]: unknown;
1947
- };
1948
- content: {
1949
- "application/json": components["schemas"]["CodeContext"][];
1950
- };
1951
- };
1952
- 400: components["responses"]["BadRequest"];
1953
- 500: components["responses"]["InternalServerError"];
1954
- };
1955
- };
1956
- deleteContextsByLanguage: {
1957
- parameters: {
1958
- query: {
1959
- /**
1960
- * @description Target execution runtime whose contexts should be deleted
1961
- * @example python
1962
- */
1963
- language: string;
1964
- };
1965
- header?: never;
1966
- path?: never;
1967
- cookie?: never;
1968
- };
1969
- requestBody?: never;
1970
- responses: {
1971
- /** @description Contexts deleted successfully */
1972
- 200: {
1973
- headers: {
1974
- [name: string]: unknown;
1975
- };
1976
- content?: never;
1977
- };
1978
- 400: components["responses"]["BadRequest"];
1979
- 500: components["responses"]["InternalServerError"];
1980
- };
1981
- };
1982
- getContext: {
1983
- parameters: {
1984
- query?: never;
1985
- header?: never;
1986
- path: {
1987
- /**
1988
- * @description Session/context id to get
1989
- * @example session-abc123
1990
- */
1991
- context_id: string;
1992
- };
1993
- cookie?: never;
1994
- };
1995
- requestBody?: never;
1996
- responses: {
1997
- /** @description Context details retrieved successfully */
1998
- 200: {
1999
- headers: {
2000
- [name: string]: unknown;
2001
- };
2002
- content: {
2003
- "application/json": components["schemas"]["CodeContext"];
2004
- };
2005
- };
2006
- 404: components["responses"]["NotFound"];
2007
- 500: components["responses"]["InternalServerError"];
2008
- };
2009
- };
2010
- deleteContext: {
2011
- parameters: {
2012
- query?: never;
2013
- header?: never;
2014
- path: {
2015
- /**
2016
- * @description Session/context id to delete
2017
- * @example session-abc123
2018
- */
2019
- context_id: string;
2020
- };
2021
- cookie?: never;
2022
- };
2023
- requestBody?: never;
2024
- responses: {
2025
- /** @description Context deleted successfully */
2026
- 200: {
2027
- headers: {
2028
- [name: string]: unknown;
2029
- };
2030
- content?: never;
2031
- };
2032
- 400: components["responses"]["BadRequest"];
2033
- 404: components["responses"]["NotFound"];
2034
- 500: components["responses"]["InternalServerError"];
2035
- };
2036
- };
2037
- createCodeContext: {
2038
- parameters: {
2039
- query?: never;
2040
- header?: never;
2041
- path?: never;
2042
- cookie?: never;
2043
- };
2044
- requestBody: {
2045
- content: {
2046
- "application/json": components["schemas"]["CodeContextRequest"];
2047
- };
2048
- };
2049
- responses: {
2050
- /** @description Successfully created context with session ID */
2051
- 200: {
2052
- headers: {
2053
- [name: string]: unknown;
2054
- };
2055
- content: {
2056
- "application/json": components["schemas"]["CodeContext"];
2057
- };
2058
- };
2059
- 400: components["responses"]["BadRequest"];
2060
- 500: components["responses"]["InternalServerError"];
2061
- };
2062
- };
2063
- runCode: {
2064
- parameters: {
2065
- query?: never;
2066
- header?: never;
2067
- path?: never;
2068
- cookie?: never;
2069
- };
2070
- requestBody: {
2071
- content: {
2072
- "application/json": components["schemas"]["RunCodeRequest"];
2073
- };
2074
- };
2075
- responses: {
2076
- /** @description Stream of code execution events */
2077
- 200: {
2078
- headers: {
2079
- [name: string]: unknown;
2080
- };
2081
- content: {
2082
- "text/event-stream": components["schemas"]["ServerStreamEvent"];
2083
- };
2084
- };
2085
- 400: components["responses"]["BadRequest"];
2086
- 500: components["responses"]["InternalServerError"];
2087
- };
2088
- };
2089
- interruptCode: {
2090
- parameters: {
2091
- query: {
2092
- /**
2093
- * @description Session ID of the execution context to interrupt
2094
- * @example session-123
2095
- */
2096
- id: string;
2097
- };
2098
- header?: never;
2099
- path?: never;
2100
- cookie?: never;
2101
- };
2102
- requestBody?: never;
2103
- responses: {
2104
- /** @description Code execution successfully interrupted */
2105
- 200: {
2106
- headers: {
2107
- [name: string]: unknown;
2108
- };
2109
- content?: never;
2110
- };
2111
- 400: components["responses"]["BadRequest"];
2112
- 500: components["responses"]["InternalServerError"];
2113
- };
2114
- };
2115
- createSession: {
2116
- parameters: {
2117
- query?: never;
2118
- header?: never;
2119
- path?: never;
2120
- cookie?: never;
2121
- };
2122
- requestBody?: {
2123
- content: {
2124
- "application/json": components["schemas"]["CreateSessionRequest"];
2125
- };
2126
- };
2127
- responses: {
2128
- /** @description Session created successfully */
2129
- 200: {
2130
- headers: {
2131
- [name: string]: unknown;
2132
- };
2133
- content: {
2134
- "application/json": components["schemas"]["CreateSessionResponse"];
2135
- };
2136
- };
2137
- 400: components["responses"]["BadRequest"];
2138
- 500: components["responses"]["InternalServerError"];
2139
- };
2140
- };
2141
- runInSession: {
2142
- parameters: {
2143
- query?: never;
2144
- header?: never;
2145
- path: {
2146
- /**
2147
- * @description Session ID returned by create_session
2148
- * @example session-abc123
2149
- */
2150
- sessionId: string;
2151
- };
2152
- cookie?: never;
2153
- };
2154
- requestBody: {
2155
- content: {
2156
- "application/json": components["schemas"]["RunInSessionRequest"];
2157
- };
2158
- };
2159
- responses: {
2160
- /** @description Stream of execution events */
2161
- 200: {
2162
- headers: {
2163
- [name: string]: unknown;
2164
- };
2165
- content: {
2166
- "text/event-stream": components["schemas"]["ServerStreamEvent"];
2167
- };
2168
- };
2169
- 400: components["responses"]["BadRequest"];
2170
- 500: components["responses"]["InternalServerError"];
2171
- };
2172
- };
2173
- deleteSession: {
2174
- parameters: {
2175
- query?: never;
2176
- header?: never;
2177
- path: {
2178
- /**
2179
- * @description Session ID to delete
2180
- * @example session-abc123
2181
- */
2182
- sessionId: string;
2183
- };
2184
- cookie?: never;
2185
- };
2186
- requestBody?: never;
2187
- responses: {
2188
- /** @description Session deleted successfully */
2189
- 200: {
2190
- headers: {
2191
- [name: string]: unknown;
2192
- };
2193
- content?: never;
2194
- };
2195
- 400: components["responses"]["BadRequest"];
2196
- 404: components["responses"]["NotFound"];
2197
- 500: components["responses"]["InternalServerError"];
2198
- };
2199
- };
2200
- runCommand: {
2201
- parameters: {
2202
- query?: never;
2203
- header?: never;
2204
- path?: never;
2205
- cookie?: never;
2206
- };
2207
- requestBody: {
2208
- content: {
2209
- "application/json": components["schemas"]["RunCommandRequest"];
2210
- };
2211
- };
2212
- responses: {
2213
- /** @description Stream of command execution events */
2214
- 200: {
2215
- headers: {
2216
- [name: string]: unknown;
2217
- };
2218
- content: {
2219
- "text/event-stream": components["schemas"]["ServerStreamEvent"];
2220
- };
2221
- };
2222
- 400: components["responses"]["BadRequest"];
2223
- 500: components["responses"]["InternalServerError"];
2224
- };
2225
- };
2226
- interruptCommand: {
2227
- parameters: {
2228
- query: {
2229
- /**
2230
- * @description Session ID of the execution context to interrupt
2231
- * @example session-456
2232
- */
2233
- id: string;
2234
- };
2235
- header?: never;
2236
- path?: never;
2237
- cookie?: never;
2238
- };
2239
- requestBody?: never;
2240
- responses: {
2241
- /** @description Command execution successfully interrupted */
2242
- 200: {
2243
- headers: {
2244
- [name: string]: unknown;
2245
- };
2246
- content?: never;
2247
- };
2248
- 400: components["responses"]["BadRequest"];
2249
- 500: components["responses"]["InternalServerError"];
2250
- };
2251
- };
2252
- getCommandStatus: {
2253
- parameters: {
2254
- query?: never;
2255
- header?: never;
2256
- path: {
2257
- /**
2258
- * @description Command ID returned by RunCommand
2259
- * @example cmd-abc123
2260
- */
2261
- id: string;
2262
- };
2263
- cookie?: never;
2264
- };
2265
- requestBody?: never;
2266
- responses: {
2267
- /** @description Command status */
2268
- 200: {
2269
- headers: {
2270
- [name: string]: unknown;
2271
- };
2272
- content: {
2273
- "application/json": components["schemas"]["CommandStatusResponse"];
2274
- };
2275
- };
2276
- 400: components["responses"]["BadRequest"];
2277
- 404: components["responses"]["NotFound"];
2278
- 500: components["responses"]["InternalServerError"];
2279
- };
2280
- };
2281
- getBackgroundCommandLogs: {
2282
- parameters: {
2283
- query?: {
2284
- /**
2285
- * @description Optional 0-based line cursor (behaves like a file seek). When provided, only
2286
- * stdout/stderr lines after this line are returned. The response includes the
2287
- * latest line index (`cursor`) so the client can request incremental output
2288
- * on subsequent calls. If omitted, the full log is returned.
2289
- * @example 120
2290
- */
2291
- cursor?: number;
2292
- };
2293
- header?: never;
2294
- path: {
2295
- /**
2296
- * @description Command ID returned by RunCommand
2297
- * @example cmd-abc123
2298
- */
2299
- id: string;
2300
- };
2301
- cookie?: never;
2302
- };
2303
- requestBody?: never;
2304
- responses: {
2305
- /** @description Command output (plain text) and status metadata via headers */
2306
- 200: {
2307
- headers: {
2308
- /** @description Highest available 0-based line index after applying the request cursor (use as the next cursor for incremental reads) */
2309
- "EXECD-COMMANDS-TAIL-CURSOR"?: number;
2310
- [name: string]: unknown;
2311
- };
2312
- content: {
2313
- /**
2314
- * @example line1
2315
- * line2
2316
- * warn: something on stderr
2317
- */
2318
- "text/plain": string;
2319
- };
2320
- };
2321
- 400: components["responses"]["BadRequest"];
2322
- 404: components["responses"]["NotFound"];
2323
- 500: components["responses"]["InternalServerError"];
2324
- };
2325
- };
2326
- getFilesInfo: {
2327
- parameters: {
2328
- query: {
2329
- /** @description File path(s) to get info for (can be specified multiple times) */
2330
- path: string[];
2331
- };
2332
- header?: never;
2333
- path?: never;
2334
- cookie?: never;
2335
- };
2336
- requestBody?: never;
2337
- responses: {
2338
- /** @description Map of file paths to FileInfo objects */
2339
- 200: {
2340
- headers: {
2341
- [name: string]: unknown;
2342
- };
2343
- content: {
2344
- "application/json": {
2345
- [key: string]: components["schemas"]["FileInfo"];
2346
- };
2347
- };
2348
- };
2349
- 404: components["responses"]["NotFound"];
2350
- 500: components["responses"]["InternalServerError"];
2351
- };
2352
- };
2353
- removeFiles: {
2354
- parameters: {
2355
- query: {
2356
- /**
2357
- * @description File path(s) to delete (can be specified multiple times)
2358
- * @example [
2359
- * "/workspace/temp.txt"
2360
- * ]
2361
- */
2362
- path: string[];
2363
- };
2364
- header?: never;
2365
- path?: never;
2366
- cookie?: never;
2367
- };
2368
- requestBody?: never;
2369
- responses: {
2370
- /** @description Files deleted successfully */
2371
- 200: {
2372
- headers: {
2373
- [name: string]: unknown;
2374
- };
2375
- content?: never;
2376
- };
2377
- 500: components["responses"]["InternalServerError"];
2378
- };
2379
- };
2380
- chmodFiles: {
2381
- parameters: {
2382
- query?: never;
2383
- header?: never;
2384
- path?: never;
2385
- cookie?: never;
2386
- };
2387
- requestBody: {
2388
- content: {
2389
- /**
2390
- * @example {
2391
- * "/workspace/script.sh": {
2392
- * "owner": "admin",
2393
- * "group": "admin",
2394
- * "mode": 755
2395
- * },
2396
- * "/workspace/config.json": {
2397
- * "owner": "admin",
2398
- * "group": "admin",
2399
- * "mode": 755
2400
- * }
2401
- * }
2402
- */
2403
- "application/json": {
2404
- [key: string]: components["schemas"]["Permission"];
2405
- };
2406
- };
2407
- };
2408
- responses: {
2409
- /** @description Permissions changed successfully */
2410
- 200: {
2411
- headers: {
2412
- [name: string]: unknown;
2413
- };
2414
- content?: never;
2415
- };
2416
- 400: components["responses"]["BadRequest"];
2417
- 500: components["responses"]["InternalServerError"];
2418
- };
2419
- };
2420
- renameFiles: {
2421
- parameters: {
2422
- query?: never;
2423
- header?: never;
2424
- path?: never;
2425
- cookie?: never;
2426
- };
2427
- requestBody: {
2428
- content: {
2429
- /**
2430
- * @example [
2431
- * {
2432
- * "src": "/workspace/old_name.txt",
2433
- * "dest": "/workspace/new_name.txt"
2434
- * },
2435
- * {
2436
- * "src": "/workspace/file.py",
2437
- * "dest": "/archive/file.py"
2438
- * }
2439
- * ]
2440
- */
2441
- "application/json": components["schemas"]["RenameFileItem"][];
2442
- };
2443
- };
2444
- responses: {
2445
- /** @description Files renamed/moved successfully */
2446
- 200: {
2447
- headers: {
2448
- [name: string]: unknown;
2449
- };
2450
- content?: never;
2451
- };
2452
- 400: components["responses"]["BadRequest"];
2453
- 404: components["responses"]["NotFound"];
2454
- 500: components["responses"]["InternalServerError"];
2455
- };
2456
- };
2457
- searchFiles: {
2458
- parameters: {
2459
- query: {
2460
- /** @description Root directory path to search in */
2461
- path: string;
2462
- /** @description Glob pattern to match files (default is **) */
2463
- pattern?: string;
2464
- };
2465
- header?: never;
2466
- path?: never;
2467
- cookie?: never;
2468
- };
2469
- requestBody?: never;
2470
- responses: {
2471
- /** @description Array of matching files with metadata */
2472
- 200: {
2473
- headers: {
2474
- [name: string]: unknown;
2475
- };
2476
- content: {
2477
- "application/json": components["schemas"]["FileInfo"][];
2478
- };
2479
- };
2480
- 400: components["responses"]["BadRequest"];
2481
- 404: components["responses"]["NotFound"];
2482
- 500: components["responses"]["InternalServerError"];
2483
- };
2484
- };
2485
- replaceContent: {
2486
- parameters: {
2487
- query?: never;
2488
- header?: never;
2489
- path?: never;
2490
- cookie?: never;
2491
- };
2492
- requestBody: {
2493
- content: {
2494
- /**
2495
- * @example {
2496
- * "/workspace/config.yaml": {
2497
- * "old": "localhost:8080",
2498
- * "new": "0.0.0.0:9090"
2499
- * },
2500
- * "/workspace/app.py": {
2501
- * "old": "DEBUG = True",
2502
- * "new": "DEBUG = False"
2503
- * }
2504
- * }
2505
- */
2506
- "application/json": {
2507
- [key: string]: components["schemas"]["ReplaceFileContentItem"];
2508
- };
2509
- };
2510
- };
2511
- responses: {
2512
- /** @description Content replaced successfully */
2513
- 200: {
2514
- headers: {
2515
- [name: string]: unknown;
2516
- };
2517
- content?: never;
2518
- };
2519
- 400: components["responses"]["BadRequest"];
2520
- 500: components["responses"]["InternalServerError"];
2521
- };
2522
- };
2523
- uploadFile: {
2524
- parameters: {
2525
- query?: never;
2526
- header?: never;
2527
- path?: never;
2528
- cookie?: never;
2529
- };
2530
- requestBody: {
2531
- content: {
2532
- "multipart/form-data": {
2533
- /**
2534
- * @description JSON-encoded file metadata (FileMetadata object)
2535
- * @example {"path":"/workspace/file.txt","owner":"admin","group":"admin","mode":755}
2536
- */
2537
- metadata?: string;
2538
- /**
2539
- * Format: binary
2540
- * @description File to upload
2541
- */
2542
- file?: string;
2543
- };
2544
- };
2545
- };
2546
- responses: {
2547
- /** @description Files uploaded successfully */
2548
- 200: {
2549
- headers: {
2550
- [name: string]: unknown;
2551
- };
2552
- content?: never;
2553
- };
2554
- 400: components["responses"]["BadRequest"];
2555
- 500: components["responses"]["InternalServerError"];
2556
- };
2557
- };
2558
- downloadFile: {
2559
- parameters: {
2560
- query: {
2561
- /**
2562
- * @description Absolute or relative path of the file to download
2563
- * @example /workspace/data.csv
2564
- */
2565
- path: string;
2566
- };
2567
- header?: {
2568
- /**
2569
- * @description HTTP Range header for partial content requests
2570
- * @example bytes=0-1023
2571
- */
2572
- Range?: string;
2573
- };
2574
- path?: never;
2575
- cookie?: never;
2576
- };
2577
- requestBody?: never;
2578
- responses: {
2579
- /** @description File content */
2580
- 200: {
2581
- headers: {
2582
- /** @description Attachment header with filename */
2583
- "Content-Disposition"?: string;
2584
- /** @description File size in bytes */
2585
- "Content-Length"?: number;
2586
- [name: string]: unknown;
2587
- };
2588
- content: {
2589
- "application/octet-stream": string;
2590
- };
2591
- };
2592
- /** @description Partial file content (when Range header is provided) */
2593
- 206: {
2594
- headers: {
2595
- /** @description Range of bytes being returned */
2596
- "Content-Range"?: string;
2597
- /** @description Length of the returned range */
2598
- "Content-Length"?: number;
2599
- [name: string]: unknown;
2600
- };
2601
- content: {
2602
- "application/octet-stream": string;
2603
- };
2604
- };
2605
- 400: components["responses"]["BadRequest"];
2606
- 404: components["responses"]["NotFound"];
2607
- /** @description Requested range not satisfiable */
2608
- 416: {
2609
- headers: {
2610
- [name: string]: unknown;
2611
- };
2612
- content: {
2613
- "application/json": components["schemas"]["ErrorResponse"];
2614
- };
2615
- };
2616
- 500: components["responses"]["InternalServerError"];
2617
- };
2618
- };
2619
- makeDirs: {
2620
- parameters: {
2621
- query?: never;
2622
- header?: never;
2623
- path?: never;
2624
- cookie?: never;
2625
- };
2626
- requestBody: {
2627
- content: {
2628
- /**
2629
- * @example {
2630
- * "/workspace/project": {
2631
- * "owner": "admin",
2632
- * "group": "admin",
2633
- * "mode": 755
2634
- * },
2635
- * "/workspace/logs": {
2636
- * "owner": "admin",
2637
- * "group": "admin",
2638
- * "mode": 755
2639
- * }
2640
- * }
2641
- */
2642
- "application/json": {
2643
- [key: string]: components["schemas"]["Permission"];
2644
- };
2645
- };
2646
- };
2647
- responses: {
2648
- /** @description Directories created successfully */
2649
- 200: {
2650
- headers: {
2651
- [name: string]: unknown;
2652
- };
2653
- content?: never;
2654
- };
2655
- 400: components["responses"]["BadRequest"];
2656
- 500: components["responses"]["InternalServerError"];
2657
- };
2658
- };
2659
- removeDirs: {
2660
- parameters: {
2661
- query: {
2662
- /**
2663
- * @description Directory path(s) to delete (can be specified multiple times)
2664
- * @example [
2665
- * "/workspace/temp"
2666
- * ]
2667
- */
2668
- path: string[];
2669
- };
2670
- header?: never;
2671
- path?: never;
2672
- cookie?: never;
2673
- };
2674
- requestBody?: never;
2675
- responses: {
2676
- /** @description Directories deleted successfully */
2677
- 200: {
2678
- headers: {
2679
- [name: string]: unknown;
2680
- };
2681
- content?: never;
2682
- };
2683
- 500: components["responses"]["InternalServerError"];
2684
- };
2685
- };
2686
- getMetrics: {
2687
- parameters: {
2688
- query?: never;
2689
- header?: never;
2690
- path?: never;
2691
- cookie?: never;
2692
- };
2693
- requestBody?: never;
2694
- responses: {
2695
- /** @description Current system metrics including CPU and memory usage */
2696
- 200: {
2697
- headers: {
2698
- [name: string]: unknown;
2699
- };
2700
- content: {
2701
- "application/json": components["schemas"]["Metrics"];
2702
- };
2703
- };
2704
- 500: components["responses"]["InternalServerError"];
2705
- };
2706
- };
2707
- watchMetrics: {
2708
- parameters: {
2709
- query?: never;
2710
- header?: never;
2711
- path?: never;
2712
- cookie?: never;
2713
- };
2714
- requestBody?: never;
2715
- responses: {
2716
- /** @description Stream of system metrics updated every second */
2717
- 200: {
2718
- headers: {
2719
- [name: string]: unknown;
2720
- };
2721
- content: {
2722
- "text/event-stream": components["schemas"]["Metrics"];
2723
- };
2724
- };
2725
- 500: components["responses"]["InternalServerError"];
2726
- };
2727
- };
2728
- }
2729
-
2730
- type ExecdClient = Client<paths>;
2731
- interface CreateExecdClientOptions {
2732
- /**
2733
- * Base URL to the Execd API (no `/v1` prefix).
2734
- * Examples:
2735
- * - `http://localhost:44772`
2736
- * - `http://api.opensandbox.io/sandboxes/<id>/port/44772`
2737
- */
2738
- baseUrl: string;
2739
- /**
2740
- * Extra headers applied to every request.
2741
- */
2742
- headers?: Record<string, string>;
2743
- /**
2744
- * Custom fetch implementation.
2745
- *
2746
- * Useful for proxies, custom TLS, request tracing, retries, or running in environments
2747
- * where a global `fetch` is not available.
2748
- */
2749
- fetch?: typeof fetch;
2750
- }
2751
- declare function createExecdClient(opts: CreateExecdClientOptions): ExecdClient;
2752
-
2753
- declare class SandboxesAdapter implements Sandboxes {
2754
- private readonly client;
2755
- constructor(client: LifecycleClient);
2756
- private parseIsoDate;
2757
- private parseOptionalIsoDate;
2758
- private mapSandboxInfo;
2759
- createSandbox(req: CreateSandboxRequest): Promise<CreateSandboxResponse>;
2760
- getSandbox(sandboxId: SandboxId): Promise<SandboxInfo>;
2761
- listSandboxes(params?: ListSandboxesParams): Promise<ListSandboxesResponse>;
2762
- deleteSandbox(sandboxId: SandboxId): Promise<void>;
2763
- pauseSandbox(sandboxId: SandboxId): Promise<void>;
2764
- resumeSandbox(sandboxId: SandboxId): Promise<void>;
2765
- renewSandboxExpiration(sandboxId: SandboxId, req: RenewSandboxExpirationRequest): Promise<RenewSandboxExpirationResponse>;
2766
- getSandboxEndpoint(sandboxId: SandboxId, port: number, useServerProxy?: boolean): Promise<Endpoint>;
2767
- }
2768
-
2769
- declare class HealthAdapter implements ExecdHealth {
2770
- private readonly client;
2771
- constructor(client: ExecdClient);
2772
- ping(): Promise<boolean>;
2773
- }
2774
-
2775
- declare class MetricsAdapter implements ExecdMetrics {
2776
- private readonly client;
2777
- constructor(client: ExecdClient);
2778
- getMetrics(): Promise<SandboxMetrics>;
2779
- }
2780
-
2781
- interface FilesystemAdapterOptions {
2782
- /**
2783
- * Must match the baseUrl used by the ExecdClient, used for binary endpoints
2784
- * like download/upload where we bypass JSON parsing.
2785
- */
2786
- baseUrl: string;
2787
- fetch?: typeof fetch;
2788
- headers?: Record<string, string>;
2789
- }
2790
- /**
2791
- * Filesystem adapter that exposes user-facing file APIs (`sandbox.files`).
2792
- *
2793
- * This adapter owns all request/response conversions:
2794
- * - Maps friendly method shapes to API payloads
2795
- * - Parses timestamps into `Date`
2796
- * - Implements streaming upload/download helpers
2797
- */
2798
- declare class FilesystemAdapter implements SandboxFiles {
2799
- private readonly client;
2800
- private readonly opts;
2801
- private readonly fetch;
2802
- private static readonly Api;
2803
- constructor(client: ExecdClient, opts: FilesystemAdapterOptions);
2804
- private parseIsoDate;
2805
- private static readonly _ApiFileInfo;
2806
- private mapApiFileInfo;
2807
- getFileInfo(paths: string[]): Promise<Record<string, FileInfo>>;
2808
- deleteFiles(paths: string[]): Promise<void>;
2809
- createDirectories(entries: Pick<WriteEntry, "path" | "mode" | "owner" | "group">[]): Promise<void>;
2810
- deleteDirectories(paths: string[]): Promise<void>;
2811
- setPermissions(entries: SetPermissionEntry[]): Promise<void>;
2812
- moveFiles(entries: MoveEntry[]): Promise<void>;
2813
- replaceContents(entries: ContentReplaceEntry[]): Promise<void>;
2814
- search(entry: SearchEntry): Promise<SearchFilesResponse>;
2815
- private uploadFile;
2816
- readBytes(path: string, opts?: {
2817
- range?: string;
2818
- }): Promise<Uint8Array>;
2819
- readBytesStream(path: string, opts?: {
2820
- range?: string;
2821
- }): AsyncIterable<Uint8Array>;
2822
- private downloadStream;
2823
- readFile(path: string, opts?: {
2824
- encoding?: string;
2825
- range?: string;
2826
- }): Promise<string>;
2827
- writeFiles(entries: WriteEntry[]): Promise<void>;
2828
- }
2829
-
2830
- interface CommandsAdapterOptions {
2831
- /**
2832
- * Must match the baseUrl used by the ExecdClient.
2833
- */
2834
- baseUrl: string;
2835
- fetch?: typeof fetch;
2836
- headers?: Record<string, string>;
2837
- }
2838
- declare class CommandsAdapter implements ExecdCommands {
2839
- private readonly client;
2840
- private readonly opts;
2841
- private readonly fetch;
2842
- constructor(client: ExecdClient, opts: CommandsAdapterOptions);
2843
- interrupt(sessionId: string): Promise<void>;
2844
- getCommandStatus(commandId: string): Promise<CommandStatus>;
2845
- getBackgroundCommandLogs(commandId: string, cursor?: number): Promise<CommandLogs>;
2846
- runStream(command: string, opts?: RunCommandOpts, signal?: AbortSignal): AsyncIterable<ServerStreamEvent>;
2847
- run(command: string, opts?: RunCommandOpts, handlers?: ExecutionHandlers, signal?: AbortSignal): Promise<CommandExecution>;
2848
- createSession(options?: {
2849
- cwd?: string;
2850
- }): Promise<string>;
2851
- runInSessionStream(sessionId: string, code: string, opts?: {
2852
- cwd?: string;
2853
- timeoutMs?: number;
2854
- }, signal?: AbortSignal): AsyncIterable<ServerStreamEvent>;
2855
- runInSession(sessionId: string, code: string, options?: {
2856
- cwd?: string;
2857
- timeoutMs?: number;
2858
- }, handlers?: ExecutionHandlers, signal?: AbortSignal): Promise<CommandExecution>;
2859
- deleteSession(sessionId: string): Promise<void>;
2860
- }
2861
-
2862
- export { CommandsAdapter, type ExecdClient, type paths as ExecdPaths, FilesystemAdapter, HealthAdapter, type LifecycleClient, type paths$1 as LifecyclePaths, MetricsAdapter, SandboxesAdapter, createExecdClient, createLifecycleClient };