@alibaba-group/opensandbox 0.1.1-dev0 → 0.1.2-dev0

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.
Files changed (131) hide show
  1. package/dist/chunk-NFNOESEY.js +926 -0
  2. package/dist/chunk-NFNOESEY.js.map +1 -0
  3. package/dist/cjs/index.cjs +1625 -0
  4. package/dist/cjs/index.cjs.map +1 -0
  5. package/dist/cjs/internal.cjs +920 -0
  6. package/dist/cjs/internal.cjs.map +1 -0
  7. package/dist/index.d.ts +367 -22
  8. package/dist/index.js +678 -20
  9. package/dist/index.js.map +1 -1
  10. package/dist/internal.d.ts +2513 -19
  11. package/dist/internal.js +18 -30
  12. package/dist/internal.js.map +1 -1
  13. package/dist/sandboxes-HBCO9ttf.d.ts +352 -0
  14. package/package.json +7 -2
  15. package/src/api/lifecycle.ts +32 -0
  16. package/src/config/connection.ts +3 -1
  17. package/src/core/constants.ts +1 -1
  18. package/dist/adapters/commandsAdapter.d.ts +0 -22
  19. package/dist/adapters/commandsAdapter.d.ts.map +0 -1
  20. package/dist/adapters/commandsAdapter.js +0 -77
  21. package/dist/adapters/commandsAdapter.js.map +0 -1
  22. package/dist/adapters/filesystemAdapter.d.ts +0 -52
  23. package/dist/adapters/filesystemAdapter.d.ts.map +0 -1
  24. package/dist/adapters/filesystemAdapter.js +0 -443
  25. package/dist/adapters/filesystemAdapter.js.map +0 -1
  26. package/dist/adapters/healthAdapter.d.ts +0 -8
  27. package/dist/adapters/healthAdapter.d.ts.map +0 -1
  28. package/dist/adapters/healthAdapter.js +0 -26
  29. package/dist/adapters/healthAdapter.js.map +0 -1
  30. package/dist/adapters/metricsAdapter.d.ts +0 -9
  31. package/dist/adapters/metricsAdapter.d.ts.map +0 -1
  32. package/dist/adapters/metricsAdapter.js +0 -44
  33. package/dist/adapters/metricsAdapter.js.map +0 -1
  34. package/dist/adapters/openapiError.d.ts +0 -5
  35. package/dist/adapters/openapiError.d.ts.map +0 -1
  36. package/dist/adapters/openapiError.js +0 -34
  37. package/dist/adapters/openapiError.js.map +0 -1
  38. package/dist/adapters/sandboxesAdapter.d.ts +0 -18
  39. package/dist/adapters/sandboxesAdapter.d.ts.map +0 -1
  40. package/dist/adapters/sandboxesAdapter.js +0 -147
  41. package/dist/adapters/sandboxesAdapter.js.map +0 -1
  42. package/dist/adapters/sse.d.ts +0 -9
  43. package/dist/adapters/sse.d.ts.map +0 -1
  44. package/dist/adapters/sse.js +0 -87
  45. package/dist/adapters/sse.js.map +0 -1
  46. package/dist/api/execd.d.ts +0 -1555
  47. package/dist/api/execd.d.ts.map +0 -1
  48. package/dist/api/execd.js +0 -15
  49. package/dist/api/execd.js.map +0 -1
  50. package/dist/api/lifecycle.d.ts +0 -787
  51. package/dist/api/lifecycle.d.ts.map +0 -1
  52. package/dist/api/lifecycle.js +0 -15
  53. package/dist/api/lifecycle.js.map +0 -1
  54. package/dist/config/connection.d.ts +0 -69
  55. package/dist/config/connection.d.ts.map +0 -1
  56. package/dist/config/connection.js +0 -281
  57. package/dist/config/connection.js.map +0 -1
  58. package/dist/core/constants.d.ts +0 -9
  59. package/dist/core/constants.d.ts.map +0 -1
  60. package/dist/core/constants.js +0 -25
  61. package/dist/core/constants.js.map +0 -1
  62. package/dist/core/exceptions.d.ts +0 -74
  63. package/dist/core/exceptions.d.ts.map +0 -1
  64. package/dist/core/exceptions.js +0 -104
  65. package/dist/core/exceptions.js.map +0 -1
  66. package/dist/factory/adapterFactory.d.ts +0 -33
  67. package/dist/factory/adapterFactory.d.ts.map +0 -1
  68. package/dist/factory/adapterFactory.js +0 -15
  69. package/dist/factory/adapterFactory.js.map +0 -1
  70. package/dist/factory/defaultAdapterFactory.d.ts +0 -7
  71. package/dist/factory/defaultAdapterFactory.d.ts.map +0 -1
  72. package/dist/factory/defaultAdapterFactory.js +0 -61
  73. package/dist/factory/defaultAdapterFactory.js.map +0 -1
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/internal.d.ts.map +0 -1
  76. package/dist/manager.d.ts +0 -42
  77. package/dist/manager.d.ts.map +0 -1
  78. package/dist/manager.js +0 -86
  79. package/dist/manager.js.map +0 -1
  80. package/dist/models/execd.d.ts +0 -54
  81. package/dist/models/execd.d.ts.map +0 -1
  82. package/dist/models/execd.js +0 -15
  83. package/dist/models/execd.js.map +0 -1
  84. package/dist/models/execution.d.ts +0 -52
  85. package/dist/models/execution.d.ts.map +0 -1
  86. package/dist/models/execution.js +0 -15
  87. package/dist/models/execution.js.map +0 -1
  88. package/dist/models/executionEventDispatcher.d.ts +0 -15
  89. package/dist/models/executionEventDispatcher.d.ts.map +0 -1
  90. package/dist/models/executionEventDispatcher.js +0 -96
  91. package/dist/models/executionEventDispatcher.js.map +0 -1
  92. package/dist/models/filesystem.d.ts +0 -77
  93. package/dist/models/filesystem.d.ts.map +0 -1
  94. package/dist/models/filesystem.js +0 -15
  95. package/dist/models/filesystem.js.map +0 -1
  96. package/dist/models/sandboxes.d.ts +0 -105
  97. package/dist/models/sandboxes.d.ts.map +0 -1
  98. package/dist/models/sandboxes.js +0 -16
  99. package/dist/models/sandboxes.js.map +0 -1
  100. package/dist/openapi/execdClient.d.ts +0 -25
  101. package/dist/openapi/execdClient.d.ts.map +0 -1
  102. package/dist/openapi/execdClient.js +0 -22
  103. package/dist/openapi/execdClient.js.map +0 -1
  104. package/dist/openapi/lifecycleClient.d.ts +0 -28
  105. package/dist/openapi/lifecycleClient.d.ts.map +0 -1
  106. package/dist/openapi/lifecycleClient.js +0 -36
  107. package/dist/openapi/lifecycleClient.js.map +0 -1
  108. package/dist/sandbox.d.ts +0 -136
  109. package/dist/sandbox.d.ts.map +0 -1
  110. package/dist/sandbox.js +0 -303
  111. package/dist/sandbox.js.map +0 -1
  112. package/dist/services/execdCommands.d.ts +0 -19
  113. package/dist/services/execdCommands.d.ts.map +0 -1
  114. package/dist/services/execdCommands.js +0 -15
  115. package/dist/services/execdCommands.js.map +0 -1
  116. package/dist/services/execdHealth.d.ts +0 -4
  117. package/dist/services/execdHealth.d.ts.map +0 -1
  118. package/dist/services/execdHealth.js +0 -15
  119. package/dist/services/execdHealth.js.map +0 -1
  120. package/dist/services/execdMetrics.d.ts +0 -5
  121. package/dist/services/execdMetrics.d.ts.map +0 -1
  122. package/dist/services/execdMetrics.js +0 -15
  123. package/dist/services/execdMetrics.js.map +0 -1
  124. package/dist/services/filesystem.d.ts +0 -30
  125. package/dist/services/filesystem.d.ts.map +0 -1
  126. package/dist/services/filesystem.js +0 -15
  127. package/dist/services/filesystem.js.map +0 -1
  128. package/dist/services/sandboxes.d.ts +0 -12
  129. package/dist/services/sandboxes.d.ts.map +0 -1
  130. package/dist/services/sandboxes.js +0 -15
  131. package/dist/services/sandboxes.js.map +0 -1
@@ -1,22 +1,2516 @@
1
+ import { Client } from 'openapi-fetch';
2
+ import { S as Sandboxes, m as CreateSandboxRequest, n as CreateSandboxResponse, d as SandboxId, e as SandboxInfo, u as ListSandboxesParams, L as ListSandboxesResponse, y as RenewSandboxExpirationRequest, R as RenewSandboxExpirationResponse, j as Endpoint, b as ExecdHealth, c as ExecdMetrics, i as SandboxMetrics, a as SandboxFiles, F as FileInfo, W as WriteEntry, H as SetPermissionEntry, v as MoveEntry, l as ContentReplaceEntry, D as SearchEntry, G as SearchFilesResponse, E as ExecdCommands, A as RunCommandOpts, h as ServerStreamEvent, g as ExecutionHandlers, k as CommandExecution } from './sandboxes-HBCO9ttf.js';
3
+
1
4
  /**
2
- * INTERNAL / ADVANCED ENTRYPOINT
3
- *
4
- * This subpath exposes low-level OpenAPI clients and adapters for advanced integrations.
5
- * It is intentionally NOT exported from the root entrypoint (`@alibaba-group/opensandbox`),
6
- * because generated OpenAPI types are not considered stable public API.
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?: never;
386
+ header?: never;
387
+ path: {
388
+ /** @description Unique sandbox identifier */
389
+ sandboxId: components$1["parameters"]["SandboxId"];
390
+ /** @description Port number where the service is listening inside the sandbox */
391
+ port: number;
392
+ };
393
+ cookie?: never;
394
+ };
395
+ requestBody?: never;
396
+ responses: {
397
+ /**
398
+ * @description Endpoint retrieved successfully.
399
+ *
400
+ * Returns the public URL for accessing the service on the specified port.
401
+ */
402
+ 200: {
403
+ headers: {
404
+ "X-Request-ID": components$1["headers"]["XRequestId"];
405
+ [name: string]: unknown;
406
+ };
407
+ content: {
408
+ "application/json": components$1["schemas"]["Endpoint"];
409
+ };
410
+ };
411
+ 401: components$1["responses"]["Unauthorized"];
412
+ 403: components$1["responses"]["Forbidden"];
413
+ 404: components$1["responses"]["NotFound"];
414
+ 500: components$1["responses"]["InternalServerError"];
415
+ };
416
+ };
417
+ put?: never;
418
+ post?: never;
419
+ delete?: never;
420
+ options?: never;
421
+ head?: never;
422
+ patch?: never;
423
+ trace?: never;
424
+ };
425
+ }
426
+ interface components$1 {
427
+ schemas: {
428
+ ListSandboxesResponse: {
429
+ items: components$1["schemas"]["Sandbox"][];
430
+ pagination: components$1["schemas"]["PaginationInfo"];
431
+ };
432
+ /** @description Pagination metadata for list responses */
433
+ PaginationInfo: {
434
+ /** @description Current page number */
435
+ page: number;
436
+ /** @description Number of items per page */
437
+ pageSize: number;
438
+ /** @description Total number of items matching the filter */
439
+ totalItems: number;
440
+ /** @description Total number of pages */
441
+ totalPages: number;
442
+ /** @description Whether there are more pages after the current one */
443
+ hasNextPage: boolean;
444
+ };
445
+ /** @description Response from creating a new sandbox. Contains essential information without image and updatedAt. */
446
+ CreateSandboxResponse: {
447
+ /** @description Unique sandbox identifier */
448
+ id: string;
449
+ /** @description Current lifecycle status and detailed state information */
450
+ status: components$1["schemas"]["SandboxStatus"];
451
+ /** @description Custom metadata from creation request */
452
+ metadata?: {
453
+ [key: string]: string;
454
+ };
455
+ /**
456
+ * Format: date-time
457
+ * @description Timestamp when sandbox will auto-terminate
458
+ */
459
+ expiresAt: string;
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
+ /**
489
+ * Format: date-time
490
+ * @description Timestamp when sandbox will auto-terminate
491
+ */
492
+ expiresAt: string;
493
+ /**
494
+ * Format: date-time
495
+ * @description Sandbox creation timestamp
496
+ */
497
+ createdAt: string;
498
+ };
499
+ /**
500
+ * @description High-level lifecycle state of the sandbox.
501
+ *
502
+ * Common state values:
503
+ * - Pending: Sandbox is being provisioned
504
+ * - Running: Sandbox is running and ready to accept requests
505
+ * - Pausing: Sandbox is in the process of pausing
506
+ * - Paused: Sandbox has been paused while retaining its state
507
+ * - Stopping: Sandbox is being terminated
508
+ * - Terminated: Sandbox has been successfully terminated
509
+ * - Failed: Sandbox encountered a critical error
510
+ *
511
+ * State transitions:
512
+ * - Pending → Running (after creation completes)
513
+ * - Running → Pausing (when pause is requested)
514
+ * - Pausing → Paused (pause operation completes)
515
+ * - Paused → Running (when resume is requested)
516
+ * - Running/Paused → Stopping (when kill is requested or TTL expires)
517
+ * - Stopping → Terminated (kill/timeout operation completes)
518
+ * - Pending/Running/Paused → Failed (on error)
519
+ *
520
+ * Note: New state values may be added in future versions.
521
+ * Clients should handle unknown state values gracefully.
522
+ */
523
+ SandboxState: string;
524
+ /** @description Detailed status information with lifecycle state and transition details */
525
+ SandboxStatus: {
526
+ /** @description Current lifecycle state of the sandbox */
527
+ state: components$1["schemas"]["SandboxState"];
528
+ /**
529
+ * @description Short machine-readable reason code for the current state.
530
+ * Examples: "user_delete", "ttl_expiry", "provision_timeout", "runtime_error"
531
+ */
532
+ reason?: string;
533
+ /** @description Human-readable message describing the current state or reason for state transition */
534
+ message?: string;
535
+ /**
536
+ * Format: date-time
537
+ * @description Timestamp of the last state transition
538
+ */
539
+ lastTransitionAt?: string;
540
+ };
541
+ /**
542
+ * @description Container image specification for sandbox provisioning.
543
+ *
544
+ * Supports public registry images and private registry images with authentication.
545
+ */
546
+ ImageSpec: {
547
+ /**
548
+ * @description Container image URI in standard format.
549
+ *
550
+ * Examples:
551
+ * - "python:3.11" (Docker Hub)
552
+ * - "ubuntu:22.04"
553
+ * - "gcr.io/my-project/model-server:v1.0"
554
+ * - "private-registry.company.com:5000/app:latest"
555
+ */
556
+ uri: string;
557
+ /** @description Registry authentication credentials (required for private registries) */
558
+ auth?: {
559
+ /** @description Registry username or service account */
560
+ username?: string;
561
+ /** @description Registry password or authentication token */
562
+ password?: string;
563
+ };
564
+ };
565
+ /**
566
+ * @description Request to create a new sandbox from a container image.
567
+ *
568
+ * **Note**: API Key authentication is required via the `OPEN-SANDBOX-API-KEY` header.
569
+ */
570
+ CreateSandboxRequest: {
571
+ /** @description Container image specification for the sandbox */
572
+ image: components$1["schemas"]["ImageSpec"];
573
+ /**
574
+ * @description Sandbox timeout in seconds. The sandbox will automatically terminate after this duration.
575
+ * SDK clients should provide a default value (e.g., 3600 seconds / 1 hour).
576
+ */
577
+ timeout: number;
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 Opaque container for provider-specific or transient parameters not supported by the core API.
634
+ *
635
+ * **Note**: This field is reserved for internal features, experimental flags, or temporary behaviors. Standard parameters should be proposed as core API fields.
636
+ *
637
+ * **Best Practices**:
638
+ * - **Namespacing**: Use prefixed keys (e.g., `storage.id`) to prevent collisions.
639
+ * - **Pass-through**: SDKs and middleware must treat this object as opaque and pass it through transparently.
640
+ */
641
+ extensions?: {
642
+ [key: string]: string;
643
+ };
644
+ };
645
+ /**
646
+ * @description Runtime resource constraints as key-value pairs. Similar to Kubernetes resource specifications,
647
+ * allows flexible definition of resource limits. Common resource types include:
648
+ * - `cpu`: CPU allocation in millicores (e.g., "250m" for 0.25 CPU cores)
649
+ * - `memory`: Memory allocation in bytes or human-readable format (e.g., "512Mi", "1Gi")
650
+ * - `gpu`: Number of GPU devices (e.g., "1")
651
+ *
652
+ * New resource types can be added without API changes.
653
+ * @example {
654
+ * "cpu": "500m",
655
+ * "memory": "512Mi",
656
+ * "gpu": "1"
657
+ * }
658
+ */
659
+ ResourceLimits: {
660
+ [key: string]: string;
661
+ };
662
+ RenewSandboxExpirationRequest: {
663
+ /**
664
+ * Format: date-time
665
+ * @description New absolute expiration time in UTC (RFC 3339 format).
666
+ * Must be in the future and after the current expiresAt time.
667
+ *
668
+ * Example: "2025-11-16T14:30:45Z"
669
+ */
670
+ expiresAt: string;
671
+ };
672
+ RenewSandboxExpirationResponse: {
673
+ /**
674
+ * Format: date-time
675
+ * @description The new absolute expiration time in UTC (RFC 3339 format).
676
+ *
677
+ * Example: "2025-11-16T14:30:45Z"
678
+ */
679
+ expiresAt: string;
680
+ };
681
+ /**
682
+ * @description Standard error response for all non-2xx HTTP responses.
683
+ * HTTP status code indicates the error category; code and message provide details.
684
+ */
685
+ ErrorResponse: {
686
+ /**
687
+ * @description Machine-readable error code (e.g., INVALID_REQUEST, NOT_FOUND, INTERNAL_ERROR).
688
+ * Use this for programmatic error handling.
689
+ */
690
+ code: string;
691
+ /** @description Human-readable error message describing what went wrong and how to fix it. */
692
+ message: string;
693
+ };
694
+ /**
695
+ * @description Endpoint for accessing a service running in the sandbox.
696
+ * The service must be listening on the specified port inside the sandbox for the endpoint to be available.
697
+ */
698
+ Endpoint: {
699
+ /**
700
+ * @description Public URL to access the service from outside the sandbox.
701
+ * Format: {endpoint-host}/sandboxes/{sandboxId}/port/{port}
702
+ * Example: endpoint.opensandbox.io/sandboxes/abc123/port/8080
703
+ */
704
+ endpoint: string;
705
+ };
706
+ /**
707
+ * @description Egress network policy matching the sidecar `/policy` request body.
708
+ * If `default_action` is omitted, the sidecar defaults to "deny"; passing an empty
709
+ * object or null results in allow-all behavior at startup.
710
+ */
711
+ NetworkPolicy: {
712
+ /**
713
+ * @description Default action when no egress rule matches. Defaults to "deny".
714
+ * @enum {string}
715
+ */
716
+ default_action?: "allow" | "deny";
717
+ /** @description List of egress rules evaluated in order. */
718
+ egress?: components$1["schemas"]["NetworkRule"][];
719
+ };
720
+ NetworkRule: {
721
+ /**
722
+ * @description Whether to allow or deny matching targets.
723
+ * @enum {string}
724
+ */
725
+ action: "allow" | "deny";
726
+ /**
727
+ * @description FQDN or wildcard domain (e.g., "example.com", "*.example.com").
728
+ * IP/CIDR not yet supported in the egress MVP.
729
+ */
730
+ target: string;
731
+ };
732
+ };
733
+ responses: {
734
+ /** @description Error response envelope */
735
+ Error: {
736
+ headers: {
737
+ [name: string]: unknown;
738
+ };
739
+ content: {
740
+ "application/json": components$1["schemas"]["ErrorResponse"];
741
+ };
742
+ };
743
+ /** @description The request was invalid or malformed */
744
+ BadRequest: {
745
+ headers: {
746
+ "X-Request-ID": components$1["headers"]["XRequestId"];
747
+ [name: string]: unknown;
748
+ };
749
+ content: {
750
+ "application/json": components$1["schemas"]["ErrorResponse"];
751
+ };
752
+ };
753
+ /** @description Authentication credentials are missing or invalid */
754
+ Unauthorized: {
755
+ headers: {
756
+ "X-Request-ID": components$1["headers"]["XRequestId"];
757
+ [name: string]: unknown;
758
+ };
759
+ content: {
760
+ "application/json": components$1["schemas"]["ErrorResponse"];
761
+ };
762
+ };
763
+ /** @description The authenticated user lacks permission for this operation */
764
+ Forbidden: {
765
+ headers: {
766
+ "X-Request-ID": components$1["headers"]["XRequestId"];
767
+ [name: string]: unknown;
768
+ };
769
+ content: {
770
+ "application/json": components$1["schemas"]["ErrorResponse"];
771
+ };
772
+ };
773
+ /** @description The requested resource does not exist */
774
+ NotFound: {
775
+ headers: {
776
+ "X-Request-ID": components$1["headers"]["XRequestId"];
777
+ [name: string]: unknown;
778
+ };
779
+ content: {
780
+ "application/json": components$1["schemas"]["ErrorResponse"];
781
+ };
782
+ };
783
+ /** @description The operation conflicts with the current state */
784
+ Conflict: {
785
+ headers: {
786
+ "X-Request-ID": components$1["headers"]["XRequestId"];
787
+ [name: string]: unknown;
788
+ };
789
+ content: {
790
+ "application/json": components$1["schemas"]["ErrorResponse"];
791
+ };
792
+ };
793
+ /** @description An unexpected server error occurred */
794
+ InternalServerError: {
795
+ headers: {
796
+ "X-Request-ID": components$1["headers"]["XRequestId"];
797
+ [name: string]: unknown;
798
+ };
799
+ content: {
800
+ "application/json": components$1["schemas"]["ErrorResponse"];
801
+ };
802
+ };
803
+ };
804
+ parameters: {
805
+ /** @description Unique sandbox identifier */
806
+ SandboxId: string;
807
+ };
808
+ requestBodies: never;
809
+ headers: {
810
+ /** @description Unique request identifier for tracing */
811
+ XRequestId: string;
812
+ /** @description URI of the newly created or related resource */
813
+ Location: string;
814
+ /** @description Suggested delay in seconds before retrying */
815
+ RetryAfter: number;
816
+ };
817
+ pathItems: never;
818
+ }
819
+
820
+ type LifecycleClient = Client<paths$1>;
821
+ interface CreateLifecycleClientOptions {
822
+ /**
823
+ * Base URL to OpenSandbox Lifecycle API, including the `/v1` prefix.
824
+ * Example: `http://localhost:8080/v1`
825
+ */
826
+ baseUrl?: string;
827
+ /**
828
+ * API key for `OPEN-SANDBOX-API-KEY` header.
829
+ * If omitted, reads from `process.env.OPEN_SANDBOX_API_KEY` when available.
830
+ */
831
+ apiKey?: string;
832
+ /**
833
+ * Extra headers applied to every request.
834
+ */
835
+ headers?: Record<string, string>;
836
+ /**
837
+ * Custom fetch implementation.
838
+ *
839
+ * Useful for proxies, custom TLS, request tracing, retries, or running in environments
840
+ * where a global `fetch` is not available.
841
+ */
842
+ fetch?: typeof fetch;
843
+ }
844
+ declare function createLifecycleClient(opts?: CreateLifecycleClientOptions): LifecycleClient;
845
+
846
+ /**
847
+ * This file was auto-generated by openapi-typescript.
848
+ * Do not make direct changes to the file.
849
+ */
850
+ interface paths {
851
+ "/ping": {
852
+ parameters: {
853
+ query?: never;
854
+ header?: never;
855
+ path?: never;
856
+ cookie?: never;
857
+ };
858
+ /**
859
+ * Health check endpoint
860
+ * @description Performs a simple health check to verify that the server is running and responsive.
861
+ * Returns HTTP 200 OK status if the server is healthy. This endpoint is typically used
862
+ * by load balancers, monitoring systems, and orchestration platforms (like Kubernetes)
863
+ * to check service availability.
864
+ */
865
+ get: operations["ping"];
866
+ put?: never;
867
+ post?: never;
868
+ delete?: never;
869
+ options?: never;
870
+ head?: never;
871
+ patch?: never;
872
+ trace?: never;
873
+ };
874
+ "/code/contexts": {
875
+ parameters: {
876
+ query?: never;
877
+ header?: never;
878
+ path?: never;
879
+ cookie?: never;
880
+ };
881
+ /**
882
+ * List active code execution contexts
883
+ * @description Lists all active/available code execution contexts.
884
+ * If `language` is provided, only contexts under that language/runtime are returned.
885
+ */
886
+ get: operations["listContexts"];
887
+ put?: never;
888
+ post?: never;
889
+ /**
890
+ * Delete all contexts under a language
891
+ * @description Deletes all existing code execution contexts under the specified `language`/runtime.
892
+ * This is a bulk operation intended for code-interpreter context cleanup.
893
+ */
894
+ delete: operations["deleteContextsByLanguage"];
895
+ options?: never;
896
+ head?: never;
897
+ patch?: never;
898
+ trace?: never;
899
+ };
900
+ "/code/contexts/{context_id}": {
901
+ parameters: {
902
+ query?: never;
903
+ header?: never;
904
+ path?: never;
905
+ cookie?: never;
906
+ };
907
+ /**
908
+ * Get a code execution context by id
909
+ * @description Retrieves the details of an existing code execution context (session) by id.
910
+ * Returns the context ID, language, and any associated metadata.
911
+ */
912
+ get: operations["getContext"];
913
+ put?: never;
914
+ post?: never;
915
+ /**
916
+ * Delete a code execution context by id
917
+ * @description Deletes an existing code execution context (session) by id.
918
+ * This should terminate the underlying context thread/process and release resources.
919
+ */
920
+ delete: operations["deleteContext"];
921
+ options?: never;
922
+ head?: never;
923
+ patch?: never;
924
+ trace?: never;
925
+ };
926
+ "/code/context": {
927
+ parameters: {
928
+ query?: never;
929
+ header?: never;
930
+ path?: never;
931
+ cookie?: never;
932
+ };
933
+ get?: never;
934
+ put?: never;
935
+ /**
936
+ * Create code execution context
937
+ * @description Creates a new code execution environment and returns a session ID that can be used
938
+ * for subsequent code execution requests. The context maintains state across multiple
939
+ * code executions within the same session.
940
+ */
941
+ post: operations["createCodeContext"];
942
+ delete?: never;
943
+ options?: never;
944
+ head?: never;
945
+ patch?: never;
946
+ trace?: never;
947
+ };
948
+ "/code": {
949
+ parameters: {
950
+ query?: never;
951
+ header?: never;
952
+ path?: never;
953
+ cookie?: never;
954
+ };
955
+ get?: never;
956
+ put?: never;
957
+ /**
958
+ * Execute code in context
959
+ * @description Executes code using Jupyter kernel in a specified execution context and streams
960
+ * the output in real-time using SSE (Server-Sent Events). Supports multiple programming
961
+ * languages (Python, JavaScript, etc.) and maintains execution state within the session.
962
+ * Returns execution results, output streams, execution count, and any errors.
963
+ */
964
+ post: operations["runCode"];
965
+ /**
966
+ * Interrupt code execution
967
+ * @description Interrupts the currently running code execution in the specified context.
968
+ * This sends a signal to terminate the execution process and releases associated resources.
969
+ */
970
+ delete: operations["interruptCode"];
971
+ options?: never;
972
+ head?: never;
973
+ patch?: never;
974
+ trace?: never;
975
+ };
976
+ "/command": {
977
+ parameters: {
978
+ query?: never;
979
+ header?: never;
980
+ path?: never;
981
+ cookie?: never;
982
+ };
983
+ get?: never;
984
+ put?: never;
985
+ /**
986
+ * Execute shell command
987
+ * @description Executes a shell command and streams the output in real-time using SSE (Server-Sent Events).
988
+ * The command can run in foreground or background mode. The response includes stdout, stderr,
989
+ * execution status, and completion events.
990
+ */
991
+ post: operations["runCommand"];
992
+ /**
993
+ * Interrupt command execution
994
+ * @description Interrupts the currently running command execution in the specified context.
995
+ * This sends a signal to terminate the execution process and releases associated resources.
996
+ */
997
+ delete: operations["interruptCommand"];
998
+ options?: never;
999
+ head?: never;
1000
+ patch?: never;
1001
+ trace?: never;
1002
+ };
1003
+ "/command/status/{id}": {
1004
+ parameters: {
1005
+ query?: never;
1006
+ header?: never;
1007
+ path?: never;
1008
+ cookie?: never;
1009
+ };
1010
+ /**
1011
+ * Get command running status
1012
+ * @description Returns the current status of a command (foreground or background) by command ID.
1013
+ * Includes running flag, exit code, error (if any), and start/finish timestamps.
1014
+ */
1015
+ get: operations["getCommandStatus"];
1016
+ put?: never;
1017
+ post?: never;
1018
+ delete?: never;
1019
+ options?: never;
1020
+ head?: never;
1021
+ patch?: never;
1022
+ trace?: never;
1023
+ };
1024
+ "/command/{id}/logs": {
1025
+ parameters: {
1026
+ query?: never;
1027
+ header?: never;
1028
+ path?: never;
1029
+ cookie?: never;
1030
+ };
1031
+ /**
1032
+ * Get background command stdout/stderr (non-streamed)
1033
+ * @description Returns stdout and stderr for a background (detached) command by command ID.
1034
+ * Foreground commands should be consumed via SSE; this endpoint is intended for
1035
+ * polling logs of background commands. Supports incremental reads similar to a file seek:
1036
+ * pass a starting line via query to fetch output after that line and receive the latest
1037
+ * tail cursor for the next poll. When no starting line is provided, the full logs are returned.
1038
+ * Response body is plain text so it can be rendered directly in browsers; the latest line index
1039
+ * is provided via response header `EXECD-COMMANDS-TAIL-CURSOR` for subsequent incremental requests.
1040
+ */
1041
+ get: operations["getBackgroundCommandLogs"];
1042
+ put?: never;
1043
+ post?: never;
1044
+ delete?: never;
1045
+ options?: never;
1046
+ head?: never;
1047
+ patch?: never;
1048
+ trace?: never;
1049
+ };
1050
+ "/files/info": {
1051
+ parameters: {
1052
+ query?: never;
1053
+ header?: never;
1054
+ path?: never;
1055
+ cookie?: never;
1056
+ };
1057
+ /**
1058
+ * Get file metadata
1059
+ * @description Retrieves detailed metadata for one or multiple files including permissions, owner,
1060
+ * group, size, and modification time. Returns a map of file paths to their corresponding
1061
+ * FileInfo objects.
1062
+ */
1063
+ get: operations["getFilesInfo"];
1064
+ put?: never;
1065
+ post?: never;
1066
+ delete?: never;
1067
+ options?: never;
1068
+ head?: never;
1069
+ patch?: never;
1070
+ trace?: never;
1071
+ };
1072
+ "/files": {
1073
+ parameters: {
1074
+ query?: never;
1075
+ header?: never;
1076
+ path?: never;
1077
+ cookie?: never;
1078
+ };
1079
+ get?: never;
1080
+ put?: never;
1081
+ post?: never;
1082
+ /**
1083
+ * Delete files
1084
+ * @description Deletes one or multiple files from the sandbox. Only removes files, not directories.
1085
+ * Use RemoveDirs for directory removal.
1086
+ */
1087
+ delete: operations["removeFiles"];
1088
+ options?: never;
1089
+ head?: never;
1090
+ patch?: never;
1091
+ trace?: never;
1092
+ };
1093
+ "/files/permissions": {
1094
+ parameters: {
1095
+ query?: never;
1096
+ header?: never;
1097
+ path?: never;
1098
+ cookie?: never;
1099
+ };
1100
+ get?: never;
1101
+ put?: never;
1102
+ /**
1103
+ * Change file permissions
1104
+ * @description Changes permissions (mode), owner, and group for one or multiple files.
1105
+ * Accepts a map of file paths to permission settings including octal mode,
1106
+ * owner username, and group name.
1107
+ */
1108
+ post: operations["chmodFiles"];
1109
+ delete?: never;
1110
+ options?: never;
1111
+ head?: never;
1112
+ patch?: never;
1113
+ trace?: never;
1114
+ };
1115
+ "/files/mv": {
1116
+ parameters: {
1117
+ query?: never;
1118
+ header?: never;
1119
+ path?: never;
1120
+ cookie?: never;
1121
+ };
1122
+ get?: never;
1123
+ put?: never;
1124
+ /**
1125
+ * Rename or move files
1126
+ * @description Renames or moves one or multiple files to new paths. Can be used for both
1127
+ * renaming within the same directory and moving to different directories.
1128
+ * Target directory must exist.
1129
+ */
1130
+ post: operations["renameFiles"];
1131
+ delete?: never;
1132
+ options?: never;
1133
+ head?: never;
1134
+ patch?: never;
1135
+ trace?: never;
1136
+ };
1137
+ "/files/search": {
1138
+ parameters: {
1139
+ query?: never;
1140
+ header?: never;
1141
+ path?: never;
1142
+ cookie?: never;
1143
+ };
1144
+ /**
1145
+ * Search for files
1146
+ * @description Searches for files matching a glob pattern within a specified directory and
1147
+ * its subdirectories. Returns file metadata including path, permissions, owner,
1148
+ * and group. Supports glob patterns like **, *.txt, etc. Default pattern is ** (all files).
1149
+ */
1150
+ get: operations["searchFiles"];
1151
+ put?: never;
1152
+ post?: never;
1153
+ delete?: never;
1154
+ options?: never;
1155
+ head?: never;
1156
+ patch?: never;
1157
+ trace?: never;
1158
+ };
1159
+ "/files/replace": {
1160
+ parameters: {
1161
+ query?: never;
1162
+ header?: never;
1163
+ path?: never;
1164
+ cookie?: never;
1165
+ };
1166
+ get?: never;
1167
+ put?: never;
1168
+ /**
1169
+ * Replace file content
1170
+ * @description Performs text replacement in one or multiple files. Replaces all occurrences
1171
+ * of the old string with the new string (similar to strings.ReplaceAll).
1172
+ * Preserves file permissions. Useful for batch text substitution across files.
1173
+ */
1174
+ post: operations["replaceContent"];
1175
+ delete?: never;
1176
+ options?: never;
1177
+ head?: never;
1178
+ patch?: never;
1179
+ trace?: never;
1180
+ };
1181
+ "/files/upload": {
1182
+ parameters: {
1183
+ query?: never;
1184
+ header?: never;
1185
+ path?: never;
1186
+ cookie?: never;
1187
+ };
1188
+ get?: never;
1189
+ put?: never;
1190
+ /**
1191
+ * Upload files to sandbox
1192
+ * @description Uploads one or multiple files to specified paths within the sandbox.
1193
+ * Reads metadata and file content from multipart form parts in sequence.
1194
+ * Each file upload consists of two parts: a metadata part (JSON) followed
1195
+ * by the actual file part.
1196
+ */
1197
+ post: operations["uploadFile"];
1198
+ delete?: never;
1199
+ options?: never;
1200
+ head?: never;
1201
+ patch?: never;
1202
+ trace?: never;
1203
+ };
1204
+ "/files/download": {
1205
+ parameters: {
1206
+ query?: never;
1207
+ header?: never;
1208
+ path?: never;
1209
+ cookie?: never;
1210
+ };
1211
+ /**
1212
+ * Download file from sandbox
1213
+ * @description Downloads a file from the specified path within the sandbox. Supports HTTP
1214
+ * range requests for resumable downloads and partial content retrieval.
1215
+ * Returns file as octet-stream with appropriate headers.
1216
+ */
1217
+ get: operations["downloadFile"];
1218
+ put?: never;
1219
+ post?: never;
1220
+ delete?: never;
1221
+ options?: never;
1222
+ head?: never;
1223
+ patch?: never;
1224
+ trace?: never;
1225
+ };
1226
+ "/directories": {
1227
+ parameters: {
1228
+ query?: never;
1229
+ header?: never;
1230
+ path?: never;
1231
+ cookie?: never;
1232
+ };
1233
+ get?: never;
1234
+ put?: never;
1235
+ /**
1236
+ * Create directories
1237
+ * @description Creates one or multiple directories with specified permissions. Creates parent
1238
+ * directories as needed (similar to mkdir -p). Accepts a map of directory paths
1239
+ * to permission objects.
1240
+ */
1241
+ post: operations["makeDirs"];
1242
+ /**
1243
+ * Delete directories
1244
+ * @description Recursively deletes one or multiple directories and all their contents.
1245
+ * Similar to rm -rf. Use with caution as this operation cannot be undone.
1246
+ */
1247
+ delete: operations["removeDirs"];
1248
+ options?: never;
1249
+ head?: never;
1250
+ patch?: never;
1251
+ trace?: never;
1252
+ };
1253
+ "/metrics": {
1254
+ parameters: {
1255
+ query?: never;
1256
+ header?: never;
1257
+ path?: never;
1258
+ cookie?: never;
1259
+ };
1260
+ /**
1261
+ * Get system metrics
1262
+ * @description Retrieves current system resource metrics including CPU usage percentage,
1263
+ * CPU core count, total memory, used memory, and timestamp. Provides a snapshot
1264
+ * of system resource utilization at the time of request.
1265
+ */
1266
+ get: operations["getMetrics"];
1267
+ put?: never;
1268
+ post?: never;
1269
+ delete?: never;
1270
+ options?: never;
1271
+ head?: never;
1272
+ patch?: never;
1273
+ trace?: never;
1274
+ };
1275
+ "/metrics/watch": {
1276
+ parameters: {
1277
+ query?: never;
1278
+ header?: never;
1279
+ path?: never;
1280
+ cookie?: never;
1281
+ };
1282
+ /**
1283
+ * Watch system metrics in real-time
1284
+ * @description Streams system resource metrics in real-time using Server-Sent Events (SSE).
1285
+ * Updates are sent every second, providing continuous monitoring of CPU usage,
1286
+ * memory usage, and other system metrics. The connection remains open until
1287
+ * the client disconnects.
1288
+ */
1289
+ get: operations["watchMetrics"];
1290
+ put?: never;
1291
+ post?: never;
1292
+ delete?: never;
1293
+ options?: never;
1294
+ head?: never;
1295
+ patch?: never;
1296
+ trace?: never;
1297
+ };
1298
+ }
1299
+ interface components {
1300
+ schemas: {
1301
+ /** @description Request to create a code execution context */
1302
+ CodeContextRequest: {
1303
+ /**
1304
+ * @description Execution runtime (python, bash, java, etc.)
1305
+ * @example python
1306
+ */
1307
+ language?: string;
1308
+ };
1309
+ /** @description Code execution context with session identifier */
1310
+ CodeContext: {
1311
+ /**
1312
+ * @description Unique session identifier returned by CreateContext
1313
+ * @example session-abc123
1314
+ */
1315
+ id?: string;
1316
+ /**
1317
+ * @description Execution runtime
1318
+ * @example python
1319
+ */
1320
+ language: string;
1321
+ };
1322
+ /** @description Request to execute code in a context */
1323
+ RunCodeRequest: {
1324
+ context?: components["schemas"]["CodeContext"];
1325
+ /**
1326
+ * @description Source code to execute
1327
+ * @example import numpy as np
1328
+ * result = np.array([1, 2, 3])
1329
+ * print(result)
1330
+ */
1331
+ code: string;
1332
+ };
1333
+ /** @description Request to execute a shell command */
1334
+ RunCommandRequest: {
1335
+ /**
1336
+ * @description Shell command to execute
1337
+ * @example ls -la /workspace
1338
+ */
1339
+ command: string;
1340
+ /**
1341
+ * @description Working directory for command execution
1342
+ * @example /workspace
1343
+ */
1344
+ cwd?: string;
1345
+ /**
1346
+ * @description Whether to run command in detached mode
1347
+ * @default false
1348
+ * @example false
1349
+ */
1350
+ background: boolean;
1351
+ };
1352
+ /** @description Command execution status (foreground or background) */
1353
+ CommandStatusResponse: {
1354
+ /**
1355
+ * @description Command ID returned by RunCommand
1356
+ * @example cmd-abc123
1357
+ */
1358
+ id?: string;
1359
+ /**
1360
+ * @description Original command content
1361
+ * @example ls -la
1362
+ */
1363
+ content?: string;
1364
+ /**
1365
+ * @description Whether the command is still running
1366
+ * @example false
1367
+ */
1368
+ running?: boolean;
1369
+ /**
1370
+ * Format: int32
1371
+ * @description Exit code if the command has finished
1372
+ * @example 0
1373
+ */
1374
+ exit_code?: number | null;
1375
+ /**
1376
+ * @description Error message if the command failed
1377
+ * @example permission denied
1378
+ */
1379
+ error?: string;
1380
+ /**
1381
+ * Format: date-time
1382
+ * @description Start time in RFC3339 format
1383
+ * @example 2025-12-22T09:08:05Z
1384
+ */
1385
+ started_at?: string;
1386
+ /**
1387
+ * Format: date-time
1388
+ * @description Finish time in RFC3339 format (null if still running)
1389
+ * @example 2025-12-22T09:08:09Z
1390
+ */
1391
+ finished_at?: string | null;
1392
+ };
1393
+ /** @description Server-sent event for streaming execution output */
1394
+ ServerStreamEvent: {
1395
+ /**
1396
+ * @description Event type for client-side handling
1397
+ * @example stdout
1398
+ * @enum {string}
1399
+ */
1400
+ type?: "init" | "status" | "error" | "stdout" | "stderr" | "result" | "execution_complete" | "execution_count" | "ping";
1401
+ /**
1402
+ * @description Textual data for status, init, and stream events
1403
+ * @example Hello, World!
1404
+ */
1405
+ text?: string;
1406
+ /**
1407
+ * @description Cell execution number in the session
1408
+ * @example 1
1409
+ */
1410
+ execution_count?: number;
1411
+ /**
1412
+ * Format: int64
1413
+ * @description Execution duration in milliseconds
1414
+ * @example 150
1415
+ */
1416
+ execution_time?: number;
1417
+ /**
1418
+ * Format: int64
1419
+ * @description When the event was generated (Unix milliseconds)
1420
+ * @example 1700000000000
1421
+ */
1422
+ timestamp?: number;
1423
+ /**
1424
+ * @description Execution output in various MIME types (e.g., "text/plain", "text/html")
1425
+ * @example {
1426
+ * "text/plain": "4"
1427
+ * }
1428
+ */
1429
+ results?: {
1430
+ [key: string]: unknown;
1431
+ };
1432
+ /** @description Execution error details if an error occurred */
1433
+ error?: {
1434
+ /**
1435
+ * @description Error name/type
1436
+ * @example NameError
1437
+ */
1438
+ ename?: string;
1439
+ /**
1440
+ * @description Error value/message
1441
+ * @example name 'undefined_var' is not defined
1442
+ */
1443
+ evalue?: string;
1444
+ /**
1445
+ * @description Stack trace lines
1446
+ * @example [
1447
+ * "Traceback (most recent call last):",
1448
+ * " File \"<stdin>\", line 1, in <module>",
1449
+ * "NameError: name 'undefined_var' is not defined"
1450
+ * ]
1451
+ */
1452
+ traceback?: string[];
1453
+ };
1454
+ };
1455
+ /** @description File metadata including path and permissions */
1456
+ FileInfo: {
1457
+ /**
1458
+ * @description Absolute file path
1459
+ * @example /workspace/file.txt
1460
+ */
1461
+ path: string;
1462
+ /**
1463
+ * Format: int64
1464
+ * @description File size in bytes
1465
+ * @example 2048
1466
+ */
1467
+ size: number;
1468
+ /**
1469
+ * Format: date-time
1470
+ * @description Last modification time
1471
+ * @example 2025-11-16T14:30:45Z
1472
+ */
1473
+ modified_at: string;
1474
+ /**
1475
+ * Format: date-time
1476
+ * @description File creation time
1477
+ * @example 2025-11-16T14:30:45Z
1478
+ */
1479
+ created_at: string;
1480
+ /**
1481
+ * @description File owner username
1482
+ * @example admin
1483
+ */
1484
+ owner: string;
1485
+ /**
1486
+ * @description File group name
1487
+ * @example admin
1488
+ */
1489
+ group: string;
1490
+ /**
1491
+ * @description File permissions in octal format
1492
+ * @example 755
1493
+ */
1494
+ mode: number;
1495
+ };
1496
+ /** @description File ownership and mode settings */
1497
+ Permission: {
1498
+ /**
1499
+ * @description Owner username
1500
+ * @example root
1501
+ */
1502
+ owner?: string;
1503
+ /**
1504
+ * @description Group name
1505
+ * @example root
1506
+ */
1507
+ group?: string;
1508
+ /**
1509
+ * @description Permission mode in octal format (e.g., 644, 755)
1510
+ * @default 755
1511
+ * @example 755
1512
+ */
1513
+ mode: number;
1514
+ };
1515
+ /** @description File metadata for upload operations */
1516
+ FileMetadata: {
1517
+ /**
1518
+ * @description Target file path
1519
+ * @example /workspace/upload.txt
1520
+ */
1521
+ path?: string;
1522
+ /**
1523
+ * @description File owner
1524
+ * @example admin
1525
+ */
1526
+ owner?: string;
1527
+ /**
1528
+ * @description File group
1529
+ * @example admin
1530
+ */
1531
+ group?: string;
1532
+ /**
1533
+ * @description File permissions in octal
1534
+ * @example 755
1535
+ */
1536
+ mode?: number;
1537
+ };
1538
+ /** @description File rename/move operation */
1539
+ RenameFileItem: {
1540
+ /**
1541
+ * @description Source file path
1542
+ * @example /workspace/old.txt
1543
+ */
1544
+ src: string;
1545
+ /**
1546
+ * @description Destination file path
1547
+ * @example /workspace/new.txt
1548
+ */
1549
+ dest: string;
1550
+ };
1551
+ /** @description Content replacement operation */
1552
+ ReplaceFileContentItem: {
1553
+ /**
1554
+ * @description String to be replaced
1555
+ * @example localhost
1556
+ */
1557
+ old: string;
1558
+ /**
1559
+ * @description Replacement string
1560
+ * @example 0.0.0.0
1561
+ */
1562
+ new: string;
1563
+ };
1564
+ /** @description System resource usage metrics */
1565
+ Metrics: {
1566
+ /**
1567
+ * Format: float
1568
+ * @description Number of CPU cores
1569
+ * @example 4
1570
+ */
1571
+ cpu_count: number;
1572
+ /**
1573
+ * Format: float
1574
+ * @description CPU usage percentage
1575
+ * @example 45.5
1576
+ */
1577
+ cpu_used_pct: number;
1578
+ /**
1579
+ * Format: float
1580
+ * @description Total memory in MiB
1581
+ * @example 8192
1582
+ */
1583
+ mem_total_mib: number;
1584
+ /**
1585
+ * Format: float
1586
+ * @description Used memory in MiB
1587
+ * @example 4096
1588
+ */
1589
+ mem_used_mib: number;
1590
+ /**
1591
+ * Format: int64
1592
+ * @description Timestamp when metrics were collected (Unix milliseconds)
1593
+ * @example 1700000000000
1594
+ */
1595
+ timestamp: number;
1596
+ };
1597
+ /** @description Standard error response format */
1598
+ ErrorResponse: {
1599
+ /**
1600
+ * @description Error code for programmatic handling
1601
+ * @example INVALID_REQUEST_BODY
1602
+ */
1603
+ code: string;
1604
+ /**
1605
+ * @description Human-readable error message
1606
+ * @example error parsing request, MAYBE invalid body format
1607
+ */
1608
+ message: string;
1609
+ };
1610
+ };
1611
+ responses: {
1612
+ /** @description Invalid request body format or missing required fields */
1613
+ BadRequest: {
1614
+ headers: {
1615
+ [name: string]: unknown;
1616
+ };
1617
+ content: {
1618
+ /**
1619
+ * @example {
1620
+ * "code": "INVALID_REQUEST_BODY",
1621
+ * "message": "error parsing request, MAYBE invalid body format"
1622
+ * }
1623
+ */
1624
+ "application/json": components["schemas"]["ErrorResponse"];
1625
+ };
1626
+ };
1627
+ /** @description File or resource not found */
1628
+ NotFound: {
1629
+ headers: {
1630
+ [name: string]: unknown;
1631
+ };
1632
+ content: {
1633
+ /**
1634
+ * @example {
1635
+ * "code": "FILE_NOT_FOUND",
1636
+ * "message": "file not found"
1637
+ * }
1638
+ */
1639
+ "application/json": components["schemas"]["ErrorResponse"];
1640
+ };
1641
+ };
1642
+ /** @description Runtime server error during operation */
1643
+ InternalServerError: {
1644
+ headers: {
1645
+ [name: string]: unknown;
1646
+ };
1647
+ content: {
1648
+ /**
1649
+ * @example {
1650
+ * "code": "RUNTIME_ERROR",
1651
+ * "message": "error running code execution"
1652
+ * }
1653
+ */
1654
+ "application/json": components["schemas"]["ErrorResponse"];
1655
+ };
1656
+ };
1657
+ };
1658
+ parameters: never;
1659
+ requestBodies: never;
1660
+ headers: never;
1661
+ pathItems: never;
1662
+ }
1663
+ interface operations {
1664
+ ping: {
1665
+ parameters: {
1666
+ query?: never;
1667
+ header?: never;
1668
+ path?: never;
1669
+ cookie?: never;
1670
+ };
1671
+ requestBody?: never;
1672
+ responses: {
1673
+ /** @description Server is alive and healthy */
1674
+ 200: {
1675
+ headers: {
1676
+ [name: string]: unknown;
1677
+ };
1678
+ content?: never;
1679
+ };
1680
+ };
1681
+ };
1682
+ listContexts: {
1683
+ parameters: {
1684
+ query: {
1685
+ /**
1686
+ * @description Filter contexts by execution runtime (python, bash, java, etc.)
1687
+ * @example python
1688
+ */
1689
+ language: string;
1690
+ };
1691
+ header?: never;
1692
+ path?: never;
1693
+ cookie?: never;
1694
+ };
1695
+ requestBody?: never;
1696
+ responses: {
1697
+ /** @description Array of active contexts */
1698
+ 200: {
1699
+ headers: {
1700
+ [name: string]: unknown;
1701
+ };
1702
+ content: {
1703
+ "application/json": components["schemas"]["CodeContext"][];
1704
+ };
1705
+ };
1706
+ 400: components["responses"]["BadRequest"];
1707
+ 500: components["responses"]["InternalServerError"];
1708
+ };
1709
+ };
1710
+ deleteContextsByLanguage: {
1711
+ parameters: {
1712
+ query: {
1713
+ /**
1714
+ * @description Target execution runtime whose contexts should be deleted
1715
+ * @example python
1716
+ */
1717
+ language: string;
1718
+ };
1719
+ header?: never;
1720
+ path?: never;
1721
+ cookie?: never;
1722
+ };
1723
+ requestBody?: never;
1724
+ responses: {
1725
+ /** @description Contexts deleted successfully */
1726
+ 200: {
1727
+ headers: {
1728
+ [name: string]: unknown;
1729
+ };
1730
+ content?: never;
1731
+ };
1732
+ 400: components["responses"]["BadRequest"];
1733
+ 500: components["responses"]["InternalServerError"];
1734
+ };
1735
+ };
1736
+ getContext: {
1737
+ parameters: {
1738
+ query?: never;
1739
+ header?: never;
1740
+ path: {
1741
+ /**
1742
+ * @description Session/context id to get
1743
+ * @example session-abc123
1744
+ */
1745
+ context_id: string;
1746
+ };
1747
+ cookie?: never;
1748
+ };
1749
+ requestBody?: never;
1750
+ responses: {
1751
+ /** @description Context details retrieved successfully */
1752
+ 200: {
1753
+ headers: {
1754
+ [name: string]: unknown;
1755
+ };
1756
+ content: {
1757
+ "application/json": components["schemas"]["CodeContext"];
1758
+ };
1759
+ };
1760
+ 404: components["responses"]["NotFound"];
1761
+ 500: components["responses"]["InternalServerError"];
1762
+ };
1763
+ };
1764
+ deleteContext: {
1765
+ parameters: {
1766
+ query?: never;
1767
+ header?: never;
1768
+ path: {
1769
+ /**
1770
+ * @description Session/context id to delete
1771
+ * @example session-abc123
1772
+ */
1773
+ context_id: string;
1774
+ };
1775
+ cookie?: never;
1776
+ };
1777
+ requestBody?: never;
1778
+ responses: {
1779
+ /** @description Context deleted successfully */
1780
+ 200: {
1781
+ headers: {
1782
+ [name: string]: unknown;
1783
+ };
1784
+ content?: never;
1785
+ };
1786
+ 400: components["responses"]["BadRequest"];
1787
+ 404: components["responses"]["NotFound"];
1788
+ 500: components["responses"]["InternalServerError"];
1789
+ };
1790
+ };
1791
+ createCodeContext: {
1792
+ parameters: {
1793
+ query?: never;
1794
+ header?: never;
1795
+ path?: never;
1796
+ cookie?: never;
1797
+ };
1798
+ requestBody: {
1799
+ content: {
1800
+ "application/json": components["schemas"]["CodeContextRequest"];
1801
+ };
1802
+ };
1803
+ responses: {
1804
+ /** @description Successfully created context with session ID */
1805
+ 200: {
1806
+ headers: {
1807
+ [name: string]: unknown;
1808
+ };
1809
+ content: {
1810
+ "application/json": components["schemas"]["CodeContext"];
1811
+ };
1812
+ };
1813
+ 400: components["responses"]["BadRequest"];
1814
+ 500: components["responses"]["InternalServerError"];
1815
+ };
1816
+ };
1817
+ runCode: {
1818
+ parameters: {
1819
+ query?: never;
1820
+ header?: never;
1821
+ path?: never;
1822
+ cookie?: never;
1823
+ };
1824
+ requestBody: {
1825
+ content: {
1826
+ "application/json": components["schemas"]["RunCodeRequest"];
1827
+ };
1828
+ };
1829
+ responses: {
1830
+ /** @description Stream of code execution events */
1831
+ 200: {
1832
+ headers: {
1833
+ [name: string]: unknown;
1834
+ };
1835
+ content: {
1836
+ "text/event-stream": components["schemas"]["ServerStreamEvent"];
1837
+ };
1838
+ };
1839
+ 400: components["responses"]["BadRequest"];
1840
+ 500: components["responses"]["InternalServerError"];
1841
+ };
1842
+ };
1843
+ interruptCode: {
1844
+ parameters: {
1845
+ query: {
1846
+ /**
1847
+ * @description Session ID of the execution context to interrupt
1848
+ * @example session-123
1849
+ */
1850
+ id: string;
1851
+ };
1852
+ header?: never;
1853
+ path?: never;
1854
+ cookie?: never;
1855
+ };
1856
+ requestBody?: never;
1857
+ responses: {
1858
+ /** @description Code execution successfully interrupted */
1859
+ 200: {
1860
+ headers: {
1861
+ [name: string]: unknown;
1862
+ };
1863
+ content?: never;
1864
+ };
1865
+ 400: components["responses"]["BadRequest"];
1866
+ 500: components["responses"]["InternalServerError"];
1867
+ };
1868
+ };
1869
+ runCommand: {
1870
+ parameters: {
1871
+ query?: never;
1872
+ header?: never;
1873
+ path?: never;
1874
+ cookie?: never;
1875
+ };
1876
+ requestBody: {
1877
+ content: {
1878
+ "application/json": components["schemas"]["RunCommandRequest"];
1879
+ };
1880
+ };
1881
+ responses: {
1882
+ /** @description Stream of command execution events */
1883
+ 200: {
1884
+ headers: {
1885
+ [name: string]: unknown;
1886
+ };
1887
+ content: {
1888
+ "text/event-stream": components["schemas"]["ServerStreamEvent"];
1889
+ };
1890
+ };
1891
+ 400: components["responses"]["BadRequest"];
1892
+ 500: components["responses"]["InternalServerError"];
1893
+ };
1894
+ };
1895
+ interruptCommand: {
1896
+ parameters: {
1897
+ query: {
1898
+ /**
1899
+ * @description Session ID of the execution context to interrupt
1900
+ * @example session-456
1901
+ */
1902
+ id: string;
1903
+ };
1904
+ header?: never;
1905
+ path?: never;
1906
+ cookie?: never;
1907
+ };
1908
+ requestBody?: never;
1909
+ responses: {
1910
+ /** @description Command execution successfully interrupted */
1911
+ 200: {
1912
+ headers: {
1913
+ [name: string]: unknown;
1914
+ };
1915
+ content?: never;
1916
+ };
1917
+ 400: components["responses"]["BadRequest"];
1918
+ 500: components["responses"]["InternalServerError"];
1919
+ };
1920
+ };
1921
+ getCommandStatus: {
1922
+ parameters: {
1923
+ query?: never;
1924
+ header?: never;
1925
+ path: {
1926
+ /**
1927
+ * @description Command ID returned by RunCommand
1928
+ * @example cmd-abc123
1929
+ */
1930
+ id: string;
1931
+ };
1932
+ cookie?: never;
1933
+ };
1934
+ requestBody?: never;
1935
+ responses: {
1936
+ /** @description Command status */
1937
+ 200: {
1938
+ headers: {
1939
+ [name: string]: unknown;
1940
+ };
1941
+ content: {
1942
+ "application/json": components["schemas"]["CommandStatusResponse"];
1943
+ };
1944
+ };
1945
+ 400: components["responses"]["BadRequest"];
1946
+ 404: components["responses"]["NotFound"];
1947
+ 500: components["responses"]["InternalServerError"];
1948
+ };
1949
+ };
1950
+ getBackgroundCommandLogs: {
1951
+ parameters: {
1952
+ query?: {
1953
+ /**
1954
+ * @description Optional 0-based line cursor (behaves like a file seek). When provided, only
1955
+ * stdout/stderr lines after this line are returned. The response includes the
1956
+ * latest line index (`cursor`) so the client can request incremental output
1957
+ * on subsequent calls. If omitted, the full log is returned.
1958
+ * @example 120
1959
+ */
1960
+ cursor?: number;
1961
+ };
1962
+ header?: never;
1963
+ path: {
1964
+ /**
1965
+ * @description Command ID returned by RunCommand
1966
+ * @example cmd-abc123
1967
+ */
1968
+ id: string;
1969
+ };
1970
+ cookie?: never;
1971
+ };
1972
+ requestBody?: never;
1973
+ responses: {
1974
+ /** @description Command output (plain text) and status metadata via headers */
1975
+ 200: {
1976
+ headers: {
1977
+ /** @description Highest available 0-based line index after applying the request cursor (use as the next cursor for incremental reads) */
1978
+ "EXECD-COMMANDS-TAIL-CURSOR"?: number;
1979
+ [name: string]: unknown;
1980
+ };
1981
+ content: {
1982
+ /**
1983
+ * @example line1
1984
+ * line2
1985
+ * warn: something on stderr
1986
+ */
1987
+ "text/plain": string;
1988
+ };
1989
+ };
1990
+ 400: components["responses"]["BadRequest"];
1991
+ 404: components["responses"]["NotFound"];
1992
+ 500: components["responses"]["InternalServerError"];
1993
+ };
1994
+ };
1995
+ getFilesInfo: {
1996
+ parameters: {
1997
+ query: {
1998
+ /** @description File path(s) to get info for (can be specified multiple times) */
1999
+ path: string[];
2000
+ };
2001
+ header?: never;
2002
+ path?: never;
2003
+ cookie?: never;
2004
+ };
2005
+ requestBody?: never;
2006
+ responses: {
2007
+ /** @description Map of file paths to FileInfo objects */
2008
+ 200: {
2009
+ headers: {
2010
+ [name: string]: unknown;
2011
+ };
2012
+ content: {
2013
+ "application/json": {
2014
+ [key: string]: components["schemas"]["FileInfo"];
2015
+ };
2016
+ };
2017
+ };
2018
+ 404: components["responses"]["NotFound"];
2019
+ 500: components["responses"]["InternalServerError"];
2020
+ };
2021
+ };
2022
+ removeFiles: {
2023
+ parameters: {
2024
+ query: {
2025
+ /**
2026
+ * @description File path(s) to delete (can be specified multiple times)
2027
+ * @example [
2028
+ * "/workspace/temp.txt"
2029
+ * ]
2030
+ */
2031
+ path: string[];
2032
+ };
2033
+ header?: never;
2034
+ path?: never;
2035
+ cookie?: never;
2036
+ };
2037
+ requestBody?: never;
2038
+ responses: {
2039
+ /** @description Files deleted successfully */
2040
+ 200: {
2041
+ headers: {
2042
+ [name: string]: unknown;
2043
+ };
2044
+ content?: never;
2045
+ };
2046
+ 500: components["responses"]["InternalServerError"];
2047
+ };
2048
+ };
2049
+ chmodFiles: {
2050
+ parameters: {
2051
+ query?: never;
2052
+ header?: never;
2053
+ path?: never;
2054
+ cookie?: never;
2055
+ };
2056
+ requestBody: {
2057
+ content: {
2058
+ /**
2059
+ * @example {
2060
+ * "/workspace/script.sh": {
2061
+ * "owner": "admin",
2062
+ * "group": "admin",
2063
+ * "mode": 755
2064
+ * },
2065
+ * "/workspace/config.json": {
2066
+ * "owner": "admin",
2067
+ * "group": "admin",
2068
+ * "mode": 755
2069
+ * }
2070
+ * }
2071
+ */
2072
+ "application/json": {
2073
+ [key: string]: components["schemas"]["Permission"];
2074
+ };
2075
+ };
2076
+ };
2077
+ responses: {
2078
+ /** @description Permissions changed successfully */
2079
+ 200: {
2080
+ headers: {
2081
+ [name: string]: unknown;
2082
+ };
2083
+ content?: never;
2084
+ };
2085
+ 400: components["responses"]["BadRequest"];
2086
+ 500: components["responses"]["InternalServerError"];
2087
+ };
2088
+ };
2089
+ renameFiles: {
2090
+ parameters: {
2091
+ query?: never;
2092
+ header?: never;
2093
+ path?: never;
2094
+ cookie?: never;
2095
+ };
2096
+ requestBody: {
2097
+ content: {
2098
+ /**
2099
+ * @example [
2100
+ * {
2101
+ * "src": "/workspace/old_name.txt",
2102
+ * "dest": "/workspace/new_name.txt"
2103
+ * },
2104
+ * {
2105
+ * "src": "/workspace/file.py",
2106
+ * "dest": "/archive/file.py"
2107
+ * }
2108
+ * ]
2109
+ */
2110
+ "application/json": components["schemas"]["RenameFileItem"][];
2111
+ };
2112
+ };
2113
+ responses: {
2114
+ /** @description Files renamed/moved successfully */
2115
+ 200: {
2116
+ headers: {
2117
+ [name: string]: unknown;
2118
+ };
2119
+ content?: never;
2120
+ };
2121
+ 400: components["responses"]["BadRequest"];
2122
+ 404: components["responses"]["NotFound"];
2123
+ 500: components["responses"]["InternalServerError"];
2124
+ };
2125
+ };
2126
+ searchFiles: {
2127
+ parameters: {
2128
+ query: {
2129
+ /** @description Root directory path to search in */
2130
+ path: string;
2131
+ /** @description Glob pattern to match files (default is **) */
2132
+ pattern?: string;
2133
+ };
2134
+ header?: never;
2135
+ path?: never;
2136
+ cookie?: never;
2137
+ };
2138
+ requestBody?: never;
2139
+ responses: {
2140
+ /** @description Array of matching files with metadata */
2141
+ 200: {
2142
+ headers: {
2143
+ [name: string]: unknown;
2144
+ };
2145
+ content: {
2146
+ "application/json": components["schemas"]["FileInfo"][];
2147
+ };
2148
+ };
2149
+ 400: components["responses"]["BadRequest"];
2150
+ 404: components["responses"]["NotFound"];
2151
+ 500: components["responses"]["InternalServerError"];
2152
+ };
2153
+ };
2154
+ replaceContent: {
2155
+ parameters: {
2156
+ query?: never;
2157
+ header?: never;
2158
+ path?: never;
2159
+ cookie?: never;
2160
+ };
2161
+ requestBody: {
2162
+ content: {
2163
+ /**
2164
+ * @example {
2165
+ * "/workspace/config.yaml": {
2166
+ * "old": "localhost:8080",
2167
+ * "new": "0.0.0.0:9090"
2168
+ * },
2169
+ * "/workspace/app.py": {
2170
+ * "old": "DEBUG = True",
2171
+ * "new": "DEBUG = False"
2172
+ * }
2173
+ * }
2174
+ */
2175
+ "application/json": {
2176
+ [key: string]: components["schemas"]["ReplaceFileContentItem"];
2177
+ };
2178
+ };
2179
+ };
2180
+ responses: {
2181
+ /** @description Content replaced successfully */
2182
+ 200: {
2183
+ headers: {
2184
+ [name: string]: unknown;
2185
+ };
2186
+ content?: never;
2187
+ };
2188
+ 400: components["responses"]["BadRequest"];
2189
+ 500: components["responses"]["InternalServerError"];
2190
+ };
2191
+ };
2192
+ uploadFile: {
2193
+ parameters: {
2194
+ query?: never;
2195
+ header?: never;
2196
+ path?: never;
2197
+ cookie?: never;
2198
+ };
2199
+ requestBody: {
2200
+ content: {
2201
+ "multipart/form-data": {
2202
+ /**
2203
+ * @description JSON-encoded file metadata (FileMetadata object)
2204
+ * @example {"path":"/workspace/file.txt","owner":"admin","group":"admin","mode":755}
2205
+ */
2206
+ metadata?: string;
2207
+ /**
2208
+ * Format: binary
2209
+ * @description File to upload
2210
+ */
2211
+ file?: string;
2212
+ };
2213
+ };
2214
+ };
2215
+ responses: {
2216
+ /** @description Files uploaded successfully */
2217
+ 200: {
2218
+ headers: {
2219
+ [name: string]: unknown;
2220
+ };
2221
+ content?: never;
2222
+ };
2223
+ 400: components["responses"]["BadRequest"];
2224
+ 500: components["responses"]["InternalServerError"];
2225
+ };
2226
+ };
2227
+ downloadFile: {
2228
+ parameters: {
2229
+ query: {
2230
+ /**
2231
+ * @description Absolute or relative path of the file to download
2232
+ * @example /workspace/data.csv
2233
+ */
2234
+ path: string;
2235
+ };
2236
+ header?: {
2237
+ /**
2238
+ * @description HTTP Range header for partial content requests
2239
+ * @example bytes=0-1023
2240
+ */
2241
+ Range?: string;
2242
+ };
2243
+ path?: never;
2244
+ cookie?: never;
2245
+ };
2246
+ requestBody?: never;
2247
+ responses: {
2248
+ /** @description File content */
2249
+ 200: {
2250
+ headers: {
2251
+ /** @description Attachment header with filename */
2252
+ "Content-Disposition"?: string;
2253
+ /** @description File size in bytes */
2254
+ "Content-Length"?: number;
2255
+ [name: string]: unknown;
2256
+ };
2257
+ content: {
2258
+ "application/octet-stream": string;
2259
+ };
2260
+ };
2261
+ /** @description Partial file content (when Range header is provided) */
2262
+ 206: {
2263
+ headers: {
2264
+ /** @description Range of bytes being returned */
2265
+ "Content-Range"?: string;
2266
+ /** @description Length of the returned range */
2267
+ "Content-Length"?: number;
2268
+ [name: string]: unknown;
2269
+ };
2270
+ content: {
2271
+ "application/octet-stream": string;
2272
+ };
2273
+ };
2274
+ 400: components["responses"]["BadRequest"];
2275
+ 404: components["responses"]["NotFound"];
2276
+ /** @description Requested range not satisfiable */
2277
+ 416: {
2278
+ headers: {
2279
+ [name: string]: unknown;
2280
+ };
2281
+ content: {
2282
+ "application/json": components["schemas"]["ErrorResponse"];
2283
+ };
2284
+ };
2285
+ 500: components["responses"]["InternalServerError"];
2286
+ };
2287
+ };
2288
+ makeDirs: {
2289
+ parameters: {
2290
+ query?: never;
2291
+ header?: never;
2292
+ path?: never;
2293
+ cookie?: never;
2294
+ };
2295
+ requestBody: {
2296
+ content: {
2297
+ /**
2298
+ * @example {
2299
+ * "/workspace/project": {
2300
+ * "owner": "admin",
2301
+ * "group": "admin",
2302
+ * "mode": 755
2303
+ * },
2304
+ * "/workspace/logs": {
2305
+ * "owner": "admin",
2306
+ * "group": "admin",
2307
+ * "mode": 755
2308
+ * }
2309
+ * }
2310
+ */
2311
+ "application/json": {
2312
+ [key: string]: components["schemas"]["Permission"];
2313
+ };
2314
+ };
2315
+ };
2316
+ responses: {
2317
+ /** @description Directories created successfully */
2318
+ 200: {
2319
+ headers: {
2320
+ [name: string]: unknown;
2321
+ };
2322
+ content?: never;
2323
+ };
2324
+ 400: components["responses"]["BadRequest"];
2325
+ 500: components["responses"]["InternalServerError"];
2326
+ };
2327
+ };
2328
+ removeDirs: {
2329
+ parameters: {
2330
+ query: {
2331
+ /**
2332
+ * @description Directory path(s) to delete (can be specified multiple times)
2333
+ * @example [
2334
+ * "/workspace/temp"
2335
+ * ]
2336
+ */
2337
+ path: string[];
2338
+ };
2339
+ header?: never;
2340
+ path?: never;
2341
+ cookie?: never;
2342
+ };
2343
+ requestBody?: never;
2344
+ responses: {
2345
+ /** @description Directories deleted successfully */
2346
+ 200: {
2347
+ headers: {
2348
+ [name: string]: unknown;
2349
+ };
2350
+ content?: never;
2351
+ };
2352
+ 500: components["responses"]["InternalServerError"];
2353
+ };
2354
+ };
2355
+ getMetrics: {
2356
+ parameters: {
2357
+ query?: never;
2358
+ header?: never;
2359
+ path?: never;
2360
+ cookie?: never;
2361
+ };
2362
+ requestBody?: never;
2363
+ responses: {
2364
+ /** @description Current system metrics including CPU and memory usage */
2365
+ 200: {
2366
+ headers: {
2367
+ [name: string]: unknown;
2368
+ };
2369
+ content: {
2370
+ "application/json": components["schemas"]["Metrics"];
2371
+ };
2372
+ };
2373
+ 500: components["responses"]["InternalServerError"];
2374
+ };
2375
+ };
2376
+ watchMetrics: {
2377
+ parameters: {
2378
+ query?: never;
2379
+ header?: never;
2380
+ path?: never;
2381
+ cookie?: never;
2382
+ };
2383
+ requestBody?: never;
2384
+ responses: {
2385
+ /** @description Stream of system metrics updated every second */
2386
+ 200: {
2387
+ headers: {
2388
+ [name: string]: unknown;
2389
+ };
2390
+ content: {
2391
+ "text/event-stream": components["schemas"]["Metrics"];
2392
+ };
2393
+ };
2394
+ 500: components["responses"]["InternalServerError"];
2395
+ };
2396
+ };
2397
+ }
2398
+
2399
+ type ExecdClient = Client<paths>;
2400
+ interface CreateExecdClientOptions {
2401
+ /**
2402
+ * Base URL to the Execd API (no `/v1` prefix).
2403
+ * Examples:
2404
+ * - `http://localhost:44772`
2405
+ * - `http://api.opensandbox.io/sandboxes/<id>/port/44772`
2406
+ */
2407
+ baseUrl: string;
2408
+ /**
2409
+ * Extra headers applied to every request.
2410
+ */
2411
+ headers?: Record<string, string>;
2412
+ /**
2413
+ * Custom fetch implementation.
2414
+ *
2415
+ * Useful for proxies, custom TLS, request tracing, retries, or running in environments
2416
+ * where a global `fetch` is not available.
2417
+ */
2418
+ fetch?: typeof fetch;
2419
+ }
2420
+ declare function createExecdClient(opts: CreateExecdClientOptions): ExecdClient;
2421
+
2422
+ declare class SandboxesAdapter implements Sandboxes {
2423
+ private readonly client;
2424
+ constructor(client: LifecycleClient);
2425
+ private parseIsoDate;
2426
+ private mapSandboxInfo;
2427
+ createSandbox(req: CreateSandboxRequest): Promise<CreateSandboxResponse>;
2428
+ getSandbox(sandboxId: SandboxId): Promise<SandboxInfo>;
2429
+ listSandboxes(params?: ListSandboxesParams): Promise<ListSandboxesResponse>;
2430
+ deleteSandbox(sandboxId: SandboxId): Promise<void>;
2431
+ pauseSandbox(sandboxId: SandboxId): Promise<void>;
2432
+ resumeSandbox(sandboxId: SandboxId): Promise<void>;
2433
+ renewSandboxExpiration(sandboxId: SandboxId, req: RenewSandboxExpirationRequest): Promise<RenewSandboxExpirationResponse>;
2434
+ getSandboxEndpoint(sandboxId: SandboxId, port: number): Promise<Endpoint>;
2435
+ }
2436
+
2437
+ declare class HealthAdapter implements ExecdHealth {
2438
+ private readonly client;
2439
+ constructor(client: ExecdClient);
2440
+ ping(): Promise<boolean>;
2441
+ }
2442
+
2443
+ declare class MetricsAdapter implements ExecdMetrics {
2444
+ private readonly client;
2445
+ constructor(client: ExecdClient);
2446
+ getMetrics(): Promise<SandboxMetrics>;
2447
+ }
2448
+
2449
+ interface FilesystemAdapterOptions {
2450
+ /**
2451
+ * Must match the baseUrl used by the ExecdClient, used for binary endpoints
2452
+ * like download/upload where we bypass JSON parsing.
2453
+ */
2454
+ baseUrl: string;
2455
+ fetch?: typeof fetch;
2456
+ headers?: Record<string, string>;
2457
+ }
2458
+ /**
2459
+ * Filesystem adapter that exposes user-facing file APIs (`sandbox.files`).
7
2460
  *
8
- * Import path:
9
- * - `@alibaba-group/opensandbox/internal`
2461
+ * This adapter owns all request/response conversions:
2462
+ * - Maps friendly method shapes to API payloads
2463
+ * - Parses timestamps into `Date`
2464
+ * - Implements streaming upload/download helpers
10
2465
  */
11
- export { createLifecycleClient } from "./openapi/lifecycleClient.js";
12
- export type { LifecycleClient } from "./openapi/lifecycleClient.js";
13
- export { createExecdClient } from "./openapi/execdClient.js";
14
- export type { ExecdClient } from "./openapi/execdClient.js";
15
- export type { paths as LifecyclePaths } from "./api/lifecycle.js";
16
- export type { paths as ExecdPaths } from "./api/execd.js";
17
- export { SandboxesAdapter } from "./adapters/sandboxesAdapter.js";
18
- export { HealthAdapter } from "./adapters/healthAdapter.js";
19
- export { MetricsAdapter } from "./adapters/metricsAdapter.js";
20
- export { FilesystemAdapter } from "./adapters/filesystemAdapter.js";
21
- export { CommandsAdapter } from "./adapters/commandsAdapter.js";
22
- //# sourceMappingURL=internal.d.ts.map
2466
+ declare class FilesystemAdapter implements SandboxFiles {
2467
+ private readonly client;
2468
+ private readonly opts;
2469
+ private readonly fetch;
2470
+ private static readonly Api;
2471
+ constructor(client: ExecdClient, opts: FilesystemAdapterOptions);
2472
+ private parseIsoDate;
2473
+ private static readonly _ApiFileInfo;
2474
+ private mapApiFileInfo;
2475
+ getFileInfo(paths: string[]): Promise<Record<string, FileInfo>>;
2476
+ deleteFiles(paths: string[]): Promise<void>;
2477
+ createDirectories(entries: Pick<WriteEntry, "path" | "mode" | "owner" | "group">[]): Promise<void>;
2478
+ deleteDirectories(paths: string[]): Promise<void>;
2479
+ setPermissions(entries: SetPermissionEntry[]): Promise<void>;
2480
+ moveFiles(entries: MoveEntry[]): Promise<void>;
2481
+ replaceContents(entries: ContentReplaceEntry[]): Promise<void>;
2482
+ search(entry: SearchEntry): Promise<SearchFilesResponse>;
2483
+ private uploadFile;
2484
+ readBytes(path: string, opts?: {
2485
+ range?: string;
2486
+ }): Promise<Uint8Array>;
2487
+ readBytesStream(path: string, opts?: {
2488
+ range?: string;
2489
+ }): AsyncIterable<Uint8Array>;
2490
+ private downloadStream;
2491
+ readFile(path: string, opts?: {
2492
+ encoding?: string;
2493
+ range?: string;
2494
+ }): Promise<string>;
2495
+ writeFiles(entries: WriteEntry[]): Promise<void>;
2496
+ }
2497
+
2498
+ interface CommandsAdapterOptions {
2499
+ /**
2500
+ * Must match the baseUrl used by the ExecdClient.
2501
+ */
2502
+ baseUrl: string;
2503
+ fetch?: typeof fetch;
2504
+ headers?: Record<string, string>;
2505
+ }
2506
+ declare class CommandsAdapter implements ExecdCommands {
2507
+ private readonly client;
2508
+ private readonly opts;
2509
+ private readonly fetch;
2510
+ constructor(client: ExecdClient, opts: CommandsAdapterOptions);
2511
+ interrupt(sessionId: string): Promise<void>;
2512
+ runStream(command: string, opts?: RunCommandOpts, signal?: AbortSignal): AsyncIterable<ServerStreamEvent>;
2513
+ run(command: string, opts?: RunCommandOpts, handlers?: ExecutionHandlers, signal?: AbortSignal): Promise<CommandExecution>;
2514
+ }
2515
+
2516
+ export { CommandsAdapter, type ExecdClient, type paths as ExecdPaths, FilesystemAdapter, HealthAdapter, type LifecycleClient, type paths$1 as LifecyclePaths, MetricsAdapter, SandboxesAdapter, createExecdClient, createLifecycleClient };