@alibaba-group/opensandbox 0.1.4 → 0.1.5

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,5 +1,5 @@
1
1
  import { Client } from 'openapi-fetch';
2
- import { S as Sandboxes, o as CreateSandboxRequest, p as CreateSandboxResponse, d as SandboxId, e as SandboxInfo, w as ListSandboxesParams, L as ListSandboxesResponse, G 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, T as SetPermissionEntry, x as MoveEntry, n as ContentReplaceEntry, K as SearchEntry, Q as SearchFilesResponse, E as ExecdCommands, m as CommandStatus, l as CommandLogs, J as RunCommandOpts, h as ServerStreamEvent, g as ExecutionHandlers, k as CommandExecution } from './sandboxes-Dc0G4ShU.js';
2
+ import { S as Sandboxes, p as CreateSandboxRequest, q as CreateSandboxResponse, e as SandboxId, f as SandboxInfo, x as ListSandboxesParams, L as ListSandboxesResponse, I as RenewSandboxExpirationRequest, R as RenewSandboxExpirationResponse, k as Endpoint, c as ExecdHealth, d as ExecdMetrics, j as SandboxMetrics, b as SandboxFiles, F as FileInfo, X as WriteEntry, U as SetPermissionEntry, y as MoveEntry, o as ContentReplaceEntry, Q as SearchEntry, T as SearchFilesResponse, E as ExecdCommands, n as CommandStatus, m as CommandLogs, K as RunCommandOpts, i as ServerStreamEvent, h as ExecutionHandlers, l as CommandExecution } from './sandboxes-DL9uUHGR.js';
3
3
 
4
4
  /**
5
5
  * This file was auto-generated by openapi-typescript.
@@ -457,9 +457,9 @@ interface components$1 {
457
457
  };
458
458
  /**
459
459
  * Format: date-time
460
- * @description Timestamp when sandbox will auto-terminate
460
+ * @description Timestamp when sandbox will auto-terminate. Omitted when manual cleanup is enabled.
461
461
  */
462
- expiresAt: string;
462
+ expiresAt?: string;
463
463
  /**
464
464
  * Format: date-time
465
465
  * @description Sandbox creation timestamp
@@ -490,9 +490,9 @@ interface components$1 {
490
490
  entrypoint: string[];
491
491
  /**
492
492
  * Format: date-time
493
- * @description Timestamp when sandbox will auto-terminate
493
+ * @description Timestamp when sandbox will auto-terminate. Omitted when manual cleanup is enabled.
494
494
  */
495
- expiresAt: string;
495
+ expiresAt?: string;
496
496
  /**
497
497
  * Format: date-time
498
498
  * @description Sandbox creation timestamp
@@ -575,9 +575,12 @@ interface components$1 {
575
575
  image: components$1["schemas"]["ImageSpec"];
576
576
  /**
577
577
  * @description Sandbox timeout in seconds. The sandbox will automatically terminate after this duration.
578
- * SDK clients should provide a default value (e.g., 3600 seconds / 1 hour).
578
+ * The maximum is controlled by the server configuration (`server.max_sandbox_timeout_seconds`).
579
+ * Omit this field or set it to null to disable automatic expiration and require explicit cleanup.
580
+ * Note: manual cleanup support is runtime-dependent; Kubernetes providers may reject
581
+ * omitted or null timeout when the underlying workload provider does not support non-expiring sandboxes.
579
582
  */
580
- timeout: number;
583
+ timeout?: number | null;
581
584
  /**
582
585
  * @description Runtime resource constraints for the sandbox instance.
583
586
  * SDK clients should provide sensible defaults (e.g., cpu: "500m", memory: "512Mi").
@@ -646,6 +649,9 @@ interface components$1 {
646
649
  * **Best Practices**:
647
650
  * - **Namespacing**: Use prefixed keys (e.g., `storage.id`) to prevent collisions.
648
651
  * - **Pass-through**: SDKs and middleware must treat this object as opaque and pass it through transparently.
652
+ *
653
+ * **Well-known keys**:
654
+ * - `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
655
  */
650
656
  extensions?: {
651
657
  [key: string]: string;
@@ -745,7 +751,7 @@ interface components$1 {
745
751
  /**
746
752
  * @description Storage mount definition for a sandbox. Each volume entry contains:
747
753
  * - A unique name identifier
748
- * - Exactly one backend struct (host, pvc, etc.) with backend-specific fields
754
+ * - Exactly one backend struct (host, pvc, ossfs, etc.) with backend-specific fields
749
755
  * - Common mount settings (mountPath, readOnly, subPath)
750
756
  */
751
757
  Volume: {
@@ -756,6 +762,7 @@ interface components$1 {
756
762
  name: string;
757
763
  host?: components$1["schemas"]["Host"];
758
764
  pvc?: components$1["schemas"]["PVC"];
765
+ ossfs?: components$1["schemas"]["OSSFS"];
759
766
  /**
760
767
  * @description Absolute path inside the container where the volume is mounted.
761
768
  * Must start with '/'.
@@ -768,6 +775,7 @@ interface components$1 {
768
775
  readOnly: boolean;
769
776
  /**
770
777
  * @description Optional subdirectory under the backend path to mount.
778
+ * For `ossfs` backend, this field is used as the bucket prefix.
771
779
  * Must be a relative path without '..' components.
772
780
  */
773
781
  subPath?: string;
@@ -787,18 +795,55 @@ interface components$1 {
787
795
  path: string;
788
796
  };
789
797
  /**
790
- * @description Kubernetes PersistentVolumeClaim mount backend. References an existing
791
- * PVC in the same namespace as the sandbox pod.
798
+ * @description Platform-managed named volume backend. A runtime-neutral abstraction
799
+ * for referencing a pre-existing, platform-managed named volume.
792
800
  *
793
- * Only available in Kubernetes runtime.
801
+ * - Kubernetes: maps to a PersistentVolumeClaim in the same namespace.
802
+ * - Docker: maps to a Docker named volume (created via `docker volume create`).
803
+ *
804
+ * The volume must already exist on the target platform before sandbox
805
+ * creation.
794
806
  */
795
807
  PVC: {
796
808
  /**
797
- * @description Name of the PersistentVolumeClaim in the same namespace.
798
- * Must be a valid Kubernetes resource name.
809
+ * @description Name of the volume on the target platform.
810
+ * In Kubernetes this is the PVC name; in Docker this is the named
811
+ * volume name. Must be a valid DNS label.
799
812
  */
800
813
  claimName: string;
801
814
  };
815
+ /**
816
+ * @description Alibaba Cloud OSS mount backend via ossfs.
817
+ *
818
+ * The runtime mounts a host-side OSS path under `storage.ossfs_mount_root`
819
+ * and bind-mounts the resolved path into the sandbox container.
820
+ * Prefix selection is expressed via `Volume.subPath`.
821
+ * In Docker runtime, OSSFS backend requires OpenSandbox Server to run on a Linux host with FUSE support.
822
+ */
823
+ OSSFS: {
824
+ /** @description OSS bucket name. */
825
+ bucket: string;
826
+ /** @description OSS endpoint (e.g., `oss-cn-hangzhou.aliyuncs.com`). */
827
+ endpoint: string;
828
+ /**
829
+ * @description ossfs major version used by runtime mount integration.
830
+ * @default 2.0
831
+ * @enum {string}
832
+ */
833
+ version: "1.0" | "2.0";
834
+ /**
835
+ * @description Additional ossfs mount options.
836
+ * Runtime encodes options by `version`:
837
+ * - `1.0`: mounts with `ossfs ... -o <option>`
838
+ * - `2.0`: mounts with `ossfs2 mount ... -c <config-file>` and encodes options as `--<option>` lines in the config file
839
+ * Option values must be provided as raw payloads without leading `-`.
840
+ */
841
+ options?: string[];
842
+ /** @description OSS access key ID for inline credentials mode. */
843
+ accessKeyId: string;
844
+ /** @description OSS access key secret for inline credentials mode. */
845
+ accessKeySecret: string;
846
+ };
802
847
  };
803
848
  responses: {
804
849
  /** @description Error response envelope */
@@ -917,6 +962,12 @@ declare function createLifecycleClient(opts?: CreateLifecycleClientOptions): Lif
917
962
  * This file was auto-generated by openapi-typescript.
918
963
  * Do not make direct changes to the file.
919
964
  */
965
+ /**
966
+ * NOTE: The session-related path types and operations in this file (e.g. /session, runInSession)
967
+ * are generated from the execd OpenAPI spec. They are not the recommended runtime entry point.
968
+ * Use `sandbox.commands.createSession()`, `sandbox.commands.runInSession()`, and
969
+ * `sandbox.commands.deleteSession()` instead.
970
+ */
920
971
  interface paths {
921
972
  "/ping": {
922
973
  parameters: {
@@ -1043,6 +1094,71 @@ interface paths {
1043
1094
  patch?: never;
1044
1095
  trace?: never;
1045
1096
  };
1097
+ "/session": {
1098
+ parameters: {
1099
+ query?: never;
1100
+ header?: never;
1101
+ path?: never;
1102
+ cookie?: never;
1103
+ };
1104
+ get?: never;
1105
+ put?: never;
1106
+ /**
1107
+ * Create bash session (create_session)
1108
+ * @description Creates a new bash session and returns a session ID for subsequent run_in_session requests.
1109
+ * The session maintains shell state (e.g. working directory, environment) across multiple
1110
+ * code executions. Request body is optional; an empty body uses default options (no cwd override).
1111
+ */
1112
+ post: operations["createSession"];
1113
+ delete?: never;
1114
+ options?: never;
1115
+ head?: never;
1116
+ patch?: never;
1117
+ trace?: never;
1118
+ };
1119
+ "/session/{sessionId}/run": {
1120
+ parameters: {
1121
+ query?: never;
1122
+ header?: never;
1123
+ path?: never;
1124
+ cookie?: never;
1125
+ };
1126
+ get?: never;
1127
+ put?: never;
1128
+ /**
1129
+ * Run command in bash session (run_in_session)
1130
+ * @description Executes a shell command in an existing bash session and streams the output in real-time via SSE
1131
+ * (Server-Sent Events). The session must have been created by create_session. Supports
1132
+ * optional working directory override and timeout (milliseconds).
1133
+ */
1134
+ post: operations["runInSession"];
1135
+ delete?: never;
1136
+ options?: never;
1137
+ head?: never;
1138
+ patch?: never;
1139
+ trace?: never;
1140
+ };
1141
+ "/session/{sessionId}": {
1142
+ parameters: {
1143
+ query?: never;
1144
+ header?: never;
1145
+ path?: never;
1146
+ cookie?: never;
1147
+ };
1148
+ get?: never;
1149
+ put?: never;
1150
+ post?: never;
1151
+ /**
1152
+ * Delete bash session (delete_session)
1153
+ * @description Deletes an existing bash session by ID. Terminates the underlying shell process
1154
+ * and releases resources. The session ID must have been returned by create_session.
1155
+ */
1156
+ delete: operations["deleteSession"];
1157
+ options?: never;
1158
+ head?: never;
1159
+ patch?: never;
1160
+ trace?: never;
1161
+ };
1046
1162
  "/command": {
1047
1163
  parameters: {
1048
1164
  query?: never;
@@ -1058,7 +1174,8 @@ interface paths {
1058
1174
  * The command can run in foreground or background mode. The response includes stdout, stderr,
1059
1175
  * execution status, and completion events.
1060
1176
  * Optionally specify `timeout` (milliseconds) to enforce a maximum runtime; the server will
1061
- * terminate the process when the timeout is reached.
1177
+ * terminate the process when the timeout is reached. You can also pass `uid`/`gid` to run
1178
+ * with specific user/group IDs, and `envs` to inject environment variables.
1062
1179
  */
1063
1180
  post: operations["runCommand"];
1064
1181
  /**
@@ -1370,6 +1487,41 @@ interface paths {
1370
1487
  }
1371
1488
  interface components {
1372
1489
  schemas: {
1490
+ /** @description Request to create a bash session (optional body; empty treated as defaults) */
1491
+ CreateSessionRequest: {
1492
+ /**
1493
+ * @description Working directory for the session (optional)
1494
+ * @example /workspace
1495
+ */
1496
+ cwd?: string;
1497
+ };
1498
+ /** @description Response for create_session */
1499
+ CreateSessionResponse: {
1500
+ /**
1501
+ * @description Unique session ID for run_in_session and delete_session
1502
+ * @example session-abc123
1503
+ */
1504
+ session_id: string;
1505
+ };
1506
+ /** @description Request to run a command in an existing bash session */
1507
+ RunInSessionRequest: {
1508
+ /**
1509
+ * @description Shell command to execute in the session
1510
+ * @example echo "Hello"
1511
+ */
1512
+ command: string;
1513
+ /**
1514
+ * @description Working directory override for this run (optional)
1515
+ * @example /workspace
1516
+ */
1517
+ cwd?: string;
1518
+ /**
1519
+ * Format: int64
1520
+ * @description Maximum execution time in milliseconds (optional; server may not enforce if omitted)
1521
+ * @example 30000
1522
+ */
1523
+ timeout?: number;
1524
+ };
1373
1525
  /** @description Request to create a code execution context */
1374
1526
  CodeContextRequest: {
1375
1527
  /**
@@ -1426,6 +1578,28 @@ interface components {
1426
1578
  * @example 60000
1427
1579
  */
1428
1580
  timeout?: number;
1581
+ /**
1582
+ * Format: int32
1583
+ * @description Unix user ID used to run the command. If `gid` is provided, `uid` is required.
1584
+ * @example 1000
1585
+ */
1586
+ uid?: number;
1587
+ /**
1588
+ * Format: int32
1589
+ * @description Unix group ID used to run the command. Requires `uid` to be provided.
1590
+ * @example 1000
1591
+ */
1592
+ gid?: number;
1593
+ /**
1594
+ * @description Environment variables injected into the command process.
1595
+ * @example {
1596
+ * "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
1597
+ * "PYTHONUNBUFFERED": "1"
1598
+ * }
1599
+ */
1600
+ envs?: {
1601
+ [key: string]: string;
1602
+ };
1429
1603
  };
1430
1604
  /** @description Command execution status (foreground or background) */
1431
1605
  CommandStatusResponse: {
@@ -1944,6 +2118,91 @@ interface operations {
1944
2118
  500: components["responses"]["InternalServerError"];
1945
2119
  };
1946
2120
  };
2121
+ createSession: {
2122
+ parameters: {
2123
+ query?: never;
2124
+ header?: never;
2125
+ path?: never;
2126
+ cookie?: never;
2127
+ };
2128
+ requestBody?: {
2129
+ content: {
2130
+ "application/json": components["schemas"]["CreateSessionRequest"];
2131
+ };
2132
+ };
2133
+ responses: {
2134
+ /** @description Session created successfully */
2135
+ 200: {
2136
+ headers: {
2137
+ [name: string]: unknown;
2138
+ };
2139
+ content: {
2140
+ "application/json": components["schemas"]["CreateSessionResponse"];
2141
+ };
2142
+ };
2143
+ 400: components["responses"]["BadRequest"];
2144
+ 500: components["responses"]["InternalServerError"];
2145
+ };
2146
+ };
2147
+ runInSession: {
2148
+ parameters: {
2149
+ query?: never;
2150
+ header?: never;
2151
+ path: {
2152
+ /**
2153
+ * @description Session ID returned by create_session
2154
+ * @example session-abc123
2155
+ */
2156
+ sessionId: string;
2157
+ };
2158
+ cookie?: never;
2159
+ };
2160
+ requestBody: {
2161
+ content: {
2162
+ "application/json": components["schemas"]["RunInSessionRequest"];
2163
+ };
2164
+ };
2165
+ responses: {
2166
+ /** @description Stream of execution events */
2167
+ 200: {
2168
+ headers: {
2169
+ [name: string]: unknown;
2170
+ };
2171
+ content: {
2172
+ "text/event-stream": components["schemas"]["ServerStreamEvent"];
2173
+ };
2174
+ };
2175
+ 400: components["responses"]["BadRequest"];
2176
+ 500: components["responses"]["InternalServerError"];
2177
+ };
2178
+ };
2179
+ deleteSession: {
2180
+ parameters: {
2181
+ query?: never;
2182
+ header?: never;
2183
+ path: {
2184
+ /**
2185
+ * @description Session ID to delete
2186
+ * @example session-abc123
2187
+ */
2188
+ sessionId: string;
2189
+ };
2190
+ cookie?: never;
2191
+ };
2192
+ requestBody?: never;
2193
+ responses: {
2194
+ /** @description Session deleted successfully */
2195
+ 200: {
2196
+ headers: {
2197
+ [name: string]: unknown;
2198
+ };
2199
+ content?: never;
2200
+ };
2201
+ 400: components["responses"]["BadRequest"];
2202
+ 404: components["responses"]["NotFound"];
2203
+ 500: components["responses"]["InternalServerError"];
2204
+ };
2205
+ };
1947
2206
  runCommand: {
1948
2207
  parameters: {
1949
2208
  query?: never;
@@ -2501,6 +2760,7 @@ declare class SandboxesAdapter implements Sandboxes {
2501
2760
  private readonly client;
2502
2761
  constructor(client: LifecycleClient);
2503
2762
  private parseIsoDate;
2763
+ private parseOptionalIsoDate;
2504
2764
  private mapSandboxInfo;
2505
2765
  createSandbox(req: CreateSandboxRequest): Promise<CreateSandboxResponse>;
2506
2766
  getSandbox(sandboxId: SandboxId): Promise<SandboxInfo>;
@@ -2586,11 +2846,27 @@ declare class CommandsAdapter implements ExecdCommands {
2586
2846
  private readonly opts;
2587
2847
  private readonly fetch;
2588
2848
  constructor(client: ExecdClient, opts: CommandsAdapterOptions);
2849
+ private buildRunStreamSpec;
2850
+ private buildRunInSessionStreamSpec;
2851
+ private streamExecution;
2852
+ private consumeExecutionStream;
2589
2853
  interrupt(sessionId: string): Promise<void>;
2590
2854
  getCommandStatus(commandId: string): Promise<CommandStatus>;
2591
2855
  getBackgroundCommandLogs(commandId: string, cursor?: number): Promise<CommandLogs>;
2592
2856
  runStream(command: string, opts?: RunCommandOpts, signal?: AbortSignal): AsyncIterable<ServerStreamEvent>;
2593
2857
  run(command: string, opts?: RunCommandOpts, handlers?: ExecutionHandlers, signal?: AbortSignal): Promise<CommandExecution>;
2858
+ createSession(options?: {
2859
+ workingDirectory?: string;
2860
+ }): Promise<string>;
2861
+ runInSessionStream(sessionId: string, command: string, opts?: {
2862
+ workingDirectory?: string;
2863
+ timeout?: number;
2864
+ }, signal?: AbortSignal): AsyncIterable<ServerStreamEvent>;
2865
+ runInSession(sessionId: string, command: string, options?: {
2866
+ workingDirectory?: string;
2867
+ timeout?: number;
2868
+ }, handlers?: ExecutionHandlers, signal?: AbortSignal): Promise<CommandExecution>;
2869
+ deleteSession(sessionId: string): Promise<void>;
2594
2870
  }
2595
2871
 
2596
2872
  export { CommandsAdapter, type ExecdClient, type paths as ExecdPaths, FilesystemAdapter, HealthAdapter, type LifecycleClient, type paths$1 as LifecyclePaths, MetricsAdapter, SandboxesAdapter, createExecdClient, createLifecycleClient };
package/dist/internal.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  SandboxesAdapter,
7
7
  createExecdClient,
8
8
  createLifecycleClient
9
- } from "./chunk-OYTPXLWE.js";
9
+ } from "./chunk-XHEWHFQ6.js";
10
10
  export {
11
11
  CommandsAdapter,
12
12
  FilesystemAdapter,