@alibaba-group/opensandbox 0.1.4 → 0.1.6

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-C-AZxcv6.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;
@@ -782,23 +790,61 @@ interface components$1 {
782
790
  Host: {
783
791
  /**
784
792
  * @description Absolute path on the host filesystem to mount.
785
- * Must start with '/' and be under an allowed prefix.
793
+ * Must start with '/' (Unix) or a drive letter such as 'C:\' or 'D:/'
794
+ * (Windows), and be under an allowed prefix.
786
795
  */
787
796
  path: string;
788
797
  };
789
798
  /**
790
- * @description Kubernetes PersistentVolumeClaim mount backend. References an existing
791
- * PVC in the same namespace as the sandbox pod.
799
+ * @description Platform-managed named volume backend. A runtime-neutral abstraction
800
+ * for referencing a pre-existing, platform-managed named volume.
792
801
  *
793
- * Only available in Kubernetes runtime.
802
+ * - Kubernetes: maps to a PersistentVolumeClaim in the same namespace.
803
+ * - Docker: maps to a Docker named volume (created via `docker volume create`).
804
+ *
805
+ * The volume must already exist on the target platform before sandbox
806
+ * creation.
794
807
  */
795
808
  PVC: {
796
809
  /**
797
- * @description Name of the PersistentVolumeClaim in the same namespace.
798
- * Must be a valid Kubernetes resource name.
810
+ * @description Name of the volume on the target platform.
811
+ * In Kubernetes this is the PVC name; in Docker this is the named
812
+ * volume name. Must be a valid DNS label.
799
813
  */
800
814
  claimName: string;
801
815
  };
816
+ /**
817
+ * @description Alibaba Cloud OSS mount backend via ossfs.
818
+ *
819
+ * The runtime mounts a host-side OSS path under `storage.ossfs_mount_root`
820
+ * and bind-mounts the resolved path into the sandbox container.
821
+ * Prefix selection is expressed via `Volume.subPath`.
822
+ * In Docker runtime, OSSFS backend requires OpenSandbox Server to run on a Linux host with FUSE support.
823
+ */
824
+ OSSFS: {
825
+ /** @description OSS bucket name. */
826
+ bucket: string;
827
+ /** @description OSS endpoint (e.g., `oss-cn-hangzhou.aliyuncs.com`). */
828
+ endpoint: string;
829
+ /**
830
+ * @description ossfs major version used by runtime mount integration.
831
+ * @default 2.0
832
+ * @enum {string}
833
+ */
834
+ version: "1.0" | "2.0";
835
+ /**
836
+ * @description Additional ossfs mount options.
837
+ * Runtime encodes options by `version`:
838
+ * - `1.0`: mounts with `ossfs ... -o <option>`
839
+ * - `2.0`: mounts with `ossfs2 mount ... -c <config-file>` and encodes options as `--<option>` lines in the config file
840
+ * Option values must be provided as raw payloads without leading `-`.
841
+ */
842
+ options?: string[];
843
+ /** @description OSS access key ID for inline credentials mode. */
844
+ accessKeyId: string;
845
+ /** @description OSS access key secret for inline credentials mode. */
846
+ accessKeySecret: string;
847
+ };
802
848
  };
803
849
  responses: {
804
850
  /** @description Error response envelope */
@@ -917,6 +963,12 @@ declare function createLifecycleClient(opts?: CreateLifecycleClientOptions): Lif
917
963
  * This file was auto-generated by openapi-typescript.
918
964
  * Do not make direct changes to the file.
919
965
  */
966
+ /**
967
+ * NOTE: The session-related path types and operations in this file (e.g. /session, runInSession)
968
+ * are generated from the execd OpenAPI spec. They are not the recommended runtime entry point.
969
+ * Use `sandbox.commands.createSession()`, `sandbox.commands.runInSession()`, and
970
+ * `sandbox.commands.deleteSession()` instead.
971
+ */
920
972
  interface paths {
921
973
  "/ping": {
922
974
  parameters: {
@@ -1043,6 +1095,71 @@ interface paths {
1043
1095
  patch?: never;
1044
1096
  trace?: never;
1045
1097
  };
1098
+ "/session": {
1099
+ parameters: {
1100
+ query?: never;
1101
+ header?: never;
1102
+ path?: never;
1103
+ cookie?: never;
1104
+ };
1105
+ get?: never;
1106
+ put?: never;
1107
+ /**
1108
+ * Create bash session (create_session)
1109
+ * @description Creates a new bash session and returns a session ID for subsequent run_in_session requests.
1110
+ * The session maintains shell state (e.g. working directory, environment) across multiple
1111
+ * code executions. Request body is optional; an empty body uses default options (no cwd override).
1112
+ */
1113
+ post: operations["createSession"];
1114
+ delete?: never;
1115
+ options?: never;
1116
+ head?: never;
1117
+ patch?: never;
1118
+ trace?: never;
1119
+ };
1120
+ "/session/{sessionId}/run": {
1121
+ parameters: {
1122
+ query?: never;
1123
+ header?: never;
1124
+ path?: never;
1125
+ cookie?: never;
1126
+ };
1127
+ get?: never;
1128
+ put?: never;
1129
+ /**
1130
+ * Run command in bash session (run_in_session)
1131
+ * @description Executes a shell command in an existing bash session and streams the output in real-time via SSE
1132
+ * (Server-Sent Events). The session must have been created by create_session. Supports
1133
+ * optional working directory override and timeout (milliseconds).
1134
+ */
1135
+ post: operations["runInSession"];
1136
+ delete?: never;
1137
+ options?: never;
1138
+ head?: never;
1139
+ patch?: never;
1140
+ trace?: never;
1141
+ };
1142
+ "/session/{sessionId}": {
1143
+ parameters: {
1144
+ query?: never;
1145
+ header?: never;
1146
+ path?: never;
1147
+ cookie?: never;
1148
+ };
1149
+ get?: never;
1150
+ put?: never;
1151
+ post?: never;
1152
+ /**
1153
+ * Delete bash session (delete_session)
1154
+ * @description Deletes an existing bash session by ID. Terminates the underlying shell process
1155
+ * and releases resources. The session ID must have been returned by create_session.
1156
+ */
1157
+ delete: operations["deleteSession"];
1158
+ options?: never;
1159
+ head?: never;
1160
+ patch?: never;
1161
+ trace?: never;
1162
+ };
1046
1163
  "/command": {
1047
1164
  parameters: {
1048
1165
  query?: never;
@@ -1058,7 +1175,8 @@ interface paths {
1058
1175
  * The command can run in foreground or background mode. The response includes stdout, stderr,
1059
1176
  * execution status, and completion events.
1060
1177
  * Optionally specify `timeout` (milliseconds) to enforce a maximum runtime; the server will
1061
- * terminate the process when the timeout is reached.
1178
+ * terminate the process when the timeout is reached. You can also pass `uid`/`gid` to run
1179
+ * with specific user/group IDs, and `envs` to inject environment variables.
1062
1180
  */
1063
1181
  post: operations["runCommand"];
1064
1182
  /**
@@ -1370,6 +1488,41 @@ interface paths {
1370
1488
  }
1371
1489
  interface components {
1372
1490
  schemas: {
1491
+ /** @description Request to create a bash session (optional body; empty treated as defaults) */
1492
+ CreateSessionRequest: {
1493
+ /**
1494
+ * @description Working directory for the session (optional)
1495
+ * @example /workspace
1496
+ */
1497
+ cwd?: string;
1498
+ };
1499
+ /** @description Response for create_session */
1500
+ CreateSessionResponse: {
1501
+ /**
1502
+ * @description Unique session ID for run_in_session and delete_session
1503
+ * @example session-abc123
1504
+ */
1505
+ session_id: string;
1506
+ };
1507
+ /** @description Request to run a command in an existing bash session */
1508
+ RunInSessionRequest: {
1509
+ /**
1510
+ * @description Shell command to execute in the session
1511
+ * @example echo "Hello"
1512
+ */
1513
+ command: string;
1514
+ /**
1515
+ * @description Working directory override for this run (optional)
1516
+ * @example /workspace
1517
+ */
1518
+ cwd?: string;
1519
+ /**
1520
+ * Format: int64
1521
+ * @description Maximum execution time in milliseconds (optional; server may not enforce if omitted)
1522
+ * @example 30000
1523
+ */
1524
+ timeout?: number;
1525
+ };
1373
1526
  /** @description Request to create a code execution context */
1374
1527
  CodeContextRequest: {
1375
1528
  /**
@@ -1426,6 +1579,28 @@ interface components {
1426
1579
  * @example 60000
1427
1580
  */
1428
1581
  timeout?: number;
1582
+ /**
1583
+ * Format: int32
1584
+ * @description Unix user ID used to run the command. If `gid` is provided, `uid` is required.
1585
+ * @example 1000
1586
+ */
1587
+ uid?: number;
1588
+ /**
1589
+ * Format: int32
1590
+ * @description Unix group ID used to run the command. Requires `uid` to be provided.
1591
+ * @example 1000
1592
+ */
1593
+ gid?: number;
1594
+ /**
1595
+ * @description Environment variables injected into the command process.
1596
+ * @example {
1597
+ * "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
1598
+ * "PYTHONUNBUFFERED": "1"
1599
+ * }
1600
+ */
1601
+ envs?: {
1602
+ [key: string]: string;
1603
+ };
1429
1604
  };
1430
1605
  /** @description Command execution status (foreground or background) */
1431
1606
  CommandStatusResponse: {
@@ -1944,6 +2119,91 @@ interface operations {
1944
2119
  500: components["responses"]["InternalServerError"];
1945
2120
  };
1946
2121
  };
2122
+ createSession: {
2123
+ parameters: {
2124
+ query?: never;
2125
+ header?: never;
2126
+ path?: never;
2127
+ cookie?: never;
2128
+ };
2129
+ requestBody?: {
2130
+ content: {
2131
+ "application/json": components["schemas"]["CreateSessionRequest"];
2132
+ };
2133
+ };
2134
+ responses: {
2135
+ /** @description Session created successfully */
2136
+ 200: {
2137
+ headers: {
2138
+ [name: string]: unknown;
2139
+ };
2140
+ content: {
2141
+ "application/json": components["schemas"]["CreateSessionResponse"];
2142
+ };
2143
+ };
2144
+ 400: components["responses"]["BadRequest"];
2145
+ 500: components["responses"]["InternalServerError"];
2146
+ };
2147
+ };
2148
+ runInSession: {
2149
+ parameters: {
2150
+ query?: never;
2151
+ header?: never;
2152
+ path: {
2153
+ /**
2154
+ * @description Session ID returned by create_session
2155
+ * @example session-abc123
2156
+ */
2157
+ sessionId: string;
2158
+ };
2159
+ cookie?: never;
2160
+ };
2161
+ requestBody: {
2162
+ content: {
2163
+ "application/json": components["schemas"]["RunInSessionRequest"];
2164
+ };
2165
+ };
2166
+ responses: {
2167
+ /** @description Stream of execution events */
2168
+ 200: {
2169
+ headers: {
2170
+ [name: string]: unknown;
2171
+ };
2172
+ content: {
2173
+ "text/event-stream": components["schemas"]["ServerStreamEvent"];
2174
+ };
2175
+ };
2176
+ 400: components["responses"]["BadRequest"];
2177
+ 500: components["responses"]["InternalServerError"];
2178
+ };
2179
+ };
2180
+ deleteSession: {
2181
+ parameters: {
2182
+ query?: never;
2183
+ header?: never;
2184
+ path: {
2185
+ /**
2186
+ * @description Session ID to delete
2187
+ * @example session-abc123
2188
+ */
2189
+ sessionId: string;
2190
+ };
2191
+ cookie?: never;
2192
+ };
2193
+ requestBody?: never;
2194
+ responses: {
2195
+ /** @description Session deleted successfully */
2196
+ 200: {
2197
+ headers: {
2198
+ [name: string]: unknown;
2199
+ };
2200
+ content?: never;
2201
+ };
2202
+ 400: components["responses"]["BadRequest"];
2203
+ 404: components["responses"]["NotFound"];
2204
+ 500: components["responses"]["InternalServerError"];
2205
+ };
2206
+ };
1947
2207
  runCommand: {
1948
2208
  parameters: {
1949
2209
  query?: never;
@@ -2501,6 +2761,7 @@ declare class SandboxesAdapter implements Sandboxes {
2501
2761
  private readonly client;
2502
2762
  constructor(client: LifecycleClient);
2503
2763
  private parseIsoDate;
2764
+ private parseOptionalIsoDate;
2504
2765
  private mapSandboxInfo;
2505
2766
  createSandbox(req: CreateSandboxRequest): Promise<CreateSandboxResponse>;
2506
2767
  getSandbox(sandboxId: SandboxId): Promise<SandboxInfo>;
@@ -2586,11 +2847,27 @@ declare class CommandsAdapter implements ExecdCommands {
2586
2847
  private readonly opts;
2587
2848
  private readonly fetch;
2588
2849
  constructor(client: ExecdClient, opts: CommandsAdapterOptions);
2850
+ private buildRunStreamSpec;
2851
+ private buildRunInSessionStreamSpec;
2852
+ private streamExecution;
2853
+ private consumeExecutionStream;
2589
2854
  interrupt(sessionId: string): Promise<void>;
2590
2855
  getCommandStatus(commandId: string): Promise<CommandStatus>;
2591
2856
  getBackgroundCommandLogs(commandId: string, cursor?: number): Promise<CommandLogs>;
2592
2857
  runStream(command: string, opts?: RunCommandOpts, signal?: AbortSignal): AsyncIterable<ServerStreamEvent>;
2593
2858
  run(command: string, opts?: RunCommandOpts, handlers?: ExecutionHandlers, signal?: AbortSignal): Promise<CommandExecution>;
2859
+ createSession(options?: {
2860
+ workingDirectory?: string;
2861
+ }): Promise<string>;
2862
+ runInSessionStream(sessionId: string, command: string, opts?: {
2863
+ workingDirectory?: string;
2864
+ timeoutSeconds?: number;
2865
+ }, signal?: AbortSignal): AsyncIterable<ServerStreamEvent>;
2866
+ runInSession(sessionId: string, command: string, options?: {
2867
+ workingDirectory?: string;
2868
+ timeoutSeconds?: number;
2869
+ }, handlers?: ExecutionHandlers, signal?: AbortSignal): Promise<CommandExecution>;
2870
+ deleteSession(sessionId: string): Promise<void>;
2594
2871
  }
2595
2872
 
2596
2873
  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-AFWIGM3C.js";
10
10
  export {
11
11
  CommandsAdapter,
12
12
  FilesystemAdapter,