computesdk 1.11.1 → 1.12.0
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.
- package/dist/index.d.mts +151 -22
- package/dist/index.d.ts +151 -22
- package/dist/index.js +63 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1103,25 +1103,64 @@ declare class Terminal {
|
|
|
1103
1103
|
* Server - Resource namespace for managed server operations
|
|
1104
1104
|
*/
|
|
1105
1105
|
|
|
1106
|
+
/**
|
|
1107
|
+
* Options for starting a managed server
|
|
1108
|
+
*/
|
|
1109
|
+
interface ServerStartOptions {
|
|
1110
|
+
/** Unique server identifier (URL-safe) */
|
|
1111
|
+
slug: string;
|
|
1112
|
+
/** Command to start the server */
|
|
1113
|
+
command: string;
|
|
1114
|
+
/** Working directory (optional) */
|
|
1115
|
+
path?: string;
|
|
1116
|
+
/** Path to .env file relative to path (optional) */
|
|
1117
|
+
env_file?: string;
|
|
1118
|
+
/** Inline environment variables (merged with env_file if both provided) */
|
|
1119
|
+
environment?: Record<string, string>;
|
|
1120
|
+
/**
|
|
1121
|
+
* When to automatically restart the server:
|
|
1122
|
+
* - `never`: No automatic restart (default)
|
|
1123
|
+
* - `on-failure`: Restart only on non-zero exit code
|
|
1124
|
+
* - `always`: Always restart on exit (including exit code 0)
|
|
1125
|
+
*/
|
|
1126
|
+
restart_policy?: RestartPolicy;
|
|
1127
|
+
/** Maximum restart attempts (0 = unlimited, default: 0) */
|
|
1128
|
+
max_restarts?: number;
|
|
1129
|
+
/** Delay between restart attempts in milliseconds (default: 1000) */
|
|
1130
|
+
restart_delay_ms?: number;
|
|
1131
|
+
/** Graceful shutdown timeout in milliseconds - SIGTERM → wait → SIGKILL (default: 10000) */
|
|
1132
|
+
stop_timeout_ms?: number;
|
|
1133
|
+
}
|
|
1106
1134
|
/**
|
|
1107
1135
|
* Server resource namespace
|
|
1108
1136
|
*
|
|
1109
1137
|
* @example
|
|
1110
1138
|
* ```typescript
|
|
1111
|
-
* // Start a
|
|
1139
|
+
* // Start a basic server
|
|
1112
1140
|
* const server = await sandbox.server.start({
|
|
1113
1141
|
* slug: 'api',
|
|
1114
1142
|
* command: 'npm start',
|
|
1115
1143
|
* path: '/app',
|
|
1116
1144
|
* });
|
|
1117
1145
|
*
|
|
1146
|
+
* // Start with supervisor settings (auto-restart on failure)
|
|
1147
|
+
* const server = await sandbox.server.start({
|
|
1148
|
+
* slug: 'web',
|
|
1149
|
+
* command: 'node server.js',
|
|
1150
|
+
* path: '/app',
|
|
1151
|
+
* environment: { NODE_ENV: 'production', PORT: '3000' },
|
|
1152
|
+
* restart_policy: 'on-failure',
|
|
1153
|
+
* max_restarts: 5,
|
|
1154
|
+
* restart_delay_ms: 2000,
|
|
1155
|
+
* });
|
|
1156
|
+
*
|
|
1118
1157
|
* // List all servers
|
|
1119
1158
|
* const servers = await sandbox.server.list();
|
|
1120
1159
|
*
|
|
1121
1160
|
* // Retrieve a specific server
|
|
1122
1161
|
* const server = await sandbox.server.retrieve('api');
|
|
1123
1162
|
*
|
|
1124
|
-
* // Stop a server
|
|
1163
|
+
* // Stop a server (graceful shutdown with SIGTERM → SIGKILL)
|
|
1125
1164
|
* await sandbox.server.stop('api');
|
|
1126
1165
|
*
|
|
1127
1166
|
* // Restart a server
|
|
@@ -1136,12 +1175,7 @@ declare class Server {
|
|
|
1136
1175
|
private restartHandler;
|
|
1137
1176
|
private updateStatusHandler;
|
|
1138
1177
|
constructor(handlers: {
|
|
1139
|
-
start: (options:
|
|
1140
|
-
slug: string;
|
|
1141
|
-
command: string;
|
|
1142
|
-
path?: string;
|
|
1143
|
-
env_file?: string;
|
|
1144
|
-
}) => Promise<ServerResponse>;
|
|
1178
|
+
start: (options: ServerStartOptions) => Promise<ServerResponse>;
|
|
1145
1179
|
list: () => Promise<ServersListResponse>;
|
|
1146
1180
|
retrieve: (slug: string) => Promise<ServerResponse>;
|
|
1147
1181
|
stop: (slug: string) => Promise<ServerStopResponse | void>;
|
|
@@ -1149,20 +1183,40 @@ declare class Server {
|
|
|
1149
1183
|
updateStatus: (slug: string, status: ServerStatus) => Promise<void>;
|
|
1150
1184
|
});
|
|
1151
1185
|
/**
|
|
1152
|
-
* Start a new managed server
|
|
1186
|
+
* Start a new managed server with optional supervisor settings
|
|
1187
|
+
*
|
|
1188
|
+
* **Restart Policies:**
|
|
1189
|
+
* - `never` (default): No automatic restart on exit
|
|
1190
|
+
* - `on-failure`: Restart only on non-zero exit code
|
|
1191
|
+
* - `always`: Always restart on exit (including exit code 0)
|
|
1192
|
+
*
|
|
1193
|
+
* **Graceful Shutdown:**
|
|
1194
|
+
* When stopping a server, it first sends SIGTERM and waits for `stop_timeout_ms`
|
|
1195
|
+
* before sending SIGKILL if the process hasn't exited.
|
|
1196
|
+
*
|
|
1153
1197
|
* @param options - Server configuration
|
|
1154
|
-
* @param options.slug - Unique server slug (URL-safe identifier)
|
|
1155
|
-
* @param options.command - Command to start the server
|
|
1156
|
-
* @param options.path - Working directory (optional)
|
|
1157
|
-
* @param options.env_file - Path to env file (optional)
|
|
1158
1198
|
* @returns Server info
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```typescript
|
|
1202
|
+
* // Basic server
|
|
1203
|
+
* const server = await sandbox.server.start({
|
|
1204
|
+
* slug: 'web',
|
|
1205
|
+
* command: 'npm run dev',
|
|
1206
|
+
* path: '/app',
|
|
1207
|
+
* });
|
|
1208
|
+
*
|
|
1209
|
+
* // With supervisor settings
|
|
1210
|
+
* const server = await sandbox.server.start({
|
|
1211
|
+
* slug: 'api',
|
|
1212
|
+
* command: 'node server.js',
|
|
1213
|
+
* environment: { NODE_ENV: 'production' },
|
|
1214
|
+
* restart_policy: 'always',
|
|
1215
|
+
* max_restarts: 0, // unlimited
|
|
1216
|
+
* });
|
|
1217
|
+
* ```
|
|
1159
1218
|
*/
|
|
1160
|
-
start(options:
|
|
1161
|
-
slug: string;
|
|
1162
|
-
command: string;
|
|
1163
|
-
path?: string;
|
|
1164
|
-
env_file?: string;
|
|
1165
|
-
}): Promise<ServerInfo>;
|
|
1219
|
+
start(options: ServerStartOptions): Promise<ServerInfo>;
|
|
1166
1220
|
/**
|
|
1167
1221
|
* List all managed servers
|
|
1168
1222
|
* @returns Array of server info
|
|
@@ -2301,23 +2355,61 @@ interface TerminalResponse {
|
|
|
2301
2355
|
}
|
|
2302
2356
|
/**
|
|
2303
2357
|
* Server status types
|
|
2358
|
+
*
|
|
2359
|
+
* - `starting`: Initial startup of the server process
|
|
2360
|
+
* - `running`: Server process is running
|
|
2361
|
+
* - `ready`: Server is running and ready to accept traffic
|
|
2362
|
+
* - `failed`: Server failed to start or encountered a fatal error
|
|
2363
|
+
* - `stopped`: Server was intentionally stopped
|
|
2364
|
+
* - `restarting`: Server is being automatically restarted by the supervisor
|
|
2365
|
+
*/
|
|
2366
|
+
type ServerStatus = 'starting' | 'running' | 'ready' | 'failed' | 'stopped' | 'restarting';
|
|
2367
|
+
/**
|
|
2368
|
+
* Server restart policy
|
|
2369
|
+
* - `never`: No automatic restart (default)
|
|
2370
|
+
* - `on-failure`: Restart only on non-zero exit code
|
|
2371
|
+
* - `always`: Always restart on exit (including exit code 0)
|
|
2304
2372
|
*/
|
|
2305
|
-
type
|
|
2373
|
+
type RestartPolicy = 'never' | 'on-failure' | 'always';
|
|
2306
2374
|
/**
|
|
2307
2375
|
* Server information
|
|
2308
2376
|
*/
|
|
2309
2377
|
interface ServerInfo {
|
|
2378
|
+
/** Unique server identifier */
|
|
2310
2379
|
slug: string;
|
|
2380
|
+
/** Command used to start the server */
|
|
2311
2381
|
command: string;
|
|
2382
|
+
/** Working directory path */
|
|
2312
2383
|
path: string;
|
|
2384
|
+
/** Original path before resolution */
|
|
2313
2385
|
original_path?: string;
|
|
2386
|
+
/** Path to .env file */
|
|
2314
2387
|
env_file?: string;
|
|
2388
|
+
/** Inline environment variables */
|
|
2389
|
+
environment?: Record<string, string>;
|
|
2390
|
+
/** Auto-detected port number (populated when port monitor detects listening port) */
|
|
2315
2391
|
port?: number;
|
|
2392
|
+
/** Generated URL from subdomain + port (populated when port is detected) */
|
|
2316
2393
|
url?: string;
|
|
2394
|
+
/** Server lifecycle status */
|
|
2317
2395
|
status: ServerStatus;
|
|
2396
|
+
/** Process ID (direct process, not shell wrapper) */
|
|
2318
2397
|
pid?: number;
|
|
2319
|
-
|
|
2398
|
+
/** Configured restart policy */
|
|
2399
|
+
restart_policy?: RestartPolicy;
|
|
2400
|
+
/** Maximum restart attempts (0 = unlimited) */
|
|
2401
|
+
max_restarts?: number;
|
|
2402
|
+
/** Delay between restarts in nanoseconds (input uses milliseconds via restart_delay_ms) */
|
|
2403
|
+
restart_delay?: number;
|
|
2404
|
+
/** Graceful shutdown timeout in nanoseconds (input uses milliseconds via stop_timeout_ms) */
|
|
2405
|
+
stop_timeout?: number;
|
|
2406
|
+
/** Number of times the server has been automatically restarted */
|
|
2407
|
+
restart_count?: number;
|
|
2408
|
+
/** Last exit code (null if process is still running) */
|
|
2409
|
+
exit_code?: number | null;
|
|
2410
|
+
/** When the server was created */
|
|
2320
2411
|
created_at: string;
|
|
2412
|
+
/** When the server was last updated */
|
|
2321
2413
|
updated_at: string;
|
|
2322
2414
|
}
|
|
2323
2415
|
/**
|
|
@@ -2882,14 +2974,51 @@ declare class Sandbox {
|
|
|
2882
2974
|
*/
|
|
2883
2975
|
listServers(): Promise<ServersListResponse>;
|
|
2884
2976
|
/**
|
|
2885
|
-
* Start a new managed server
|
|
2977
|
+
* Start a new managed server with optional supervisor settings
|
|
2978
|
+
*
|
|
2886
2979
|
* @param options - Server configuration
|
|
2980
|
+
* @param options.slug - Unique server identifier
|
|
2981
|
+
* @param options.command - Command to start the server
|
|
2982
|
+
* @param options.path - Working directory (optional)
|
|
2983
|
+
* @param options.env_file - Path to .env file relative to path (optional)
|
|
2984
|
+
* @param options.environment - Inline environment variables (merged with env_file if both provided)
|
|
2985
|
+
* @param options.restart_policy - When to automatically restart: 'never' (default), 'on-failure', 'always'
|
|
2986
|
+
* @param options.max_restarts - Maximum restart attempts, 0 = unlimited (default: 0)
|
|
2987
|
+
* @param options.restart_delay_ms - Delay between restart attempts in milliseconds (default: 1000)
|
|
2988
|
+
* @param options.stop_timeout_ms - Graceful shutdown timeout in milliseconds (default: 10000)
|
|
2989
|
+
*
|
|
2990
|
+
* @example
|
|
2991
|
+
* ```typescript
|
|
2992
|
+
* // Basic server
|
|
2993
|
+
* await sandbox.startServer({
|
|
2994
|
+
* slug: 'web',
|
|
2995
|
+
* command: 'npm run dev',
|
|
2996
|
+
* path: '/app',
|
|
2997
|
+
* });
|
|
2998
|
+
*
|
|
2999
|
+
* // With supervisor settings
|
|
3000
|
+
* await sandbox.startServer({
|
|
3001
|
+
* slug: 'api',
|
|
3002
|
+
* command: 'node server.js',
|
|
3003
|
+
* path: '/app',
|
|
3004
|
+
* environment: { NODE_ENV: 'production', PORT: '3000' },
|
|
3005
|
+
* restart_policy: 'on-failure',
|
|
3006
|
+
* max_restarts: 5,
|
|
3007
|
+
* restart_delay_ms: 2000,
|
|
3008
|
+
* stop_timeout_ms: 5000,
|
|
3009
|
+
* });
|
|
3010
|
+
* ```
|
|
2887
3011
|
*/
|
|
2888
3012
|
startServer(options: {
|
|
2889
3013
|
slug: string;
|
|
2890
3014
|
command: string;
|
|
2891
3015
|
path?: string;
|
|
2892
3016
|
env_file?: string;
|
|
3017
|
+
environment?: Record<string, string>;
|
|
3018
|
+
restart_policy?: RestartPolicy;
|
|
3019
|
+
max_restarts?: number;
|
|
3020
|
+
restart_delay_ms?: number;
|
|
3021
|
+
stop_timeout_ms?: number;
|
|
2893
3022
|
}): Promise<ServerResponse>;
|
|
2894
3023
|
/**
|
|
2895
3024
|
* Get information about a specific server
|
package/dist/index.d.ts
CHANGED
|
@@ -1103,25 +1103,64 @@ declare class Terminal {
|
|
|
1103
1103
|
* Server - Resource namespace for managed server operations
|
|
1104
1104
|
*/
|
|
1105
1105
|
|
|
1106
|
+
/**
|
|
1107
|
+
* Options for starting a managed server
|
|
1108
|
+
*/
|
|
1109
|
+
interface ServerStartOptions {
|
|
1110
|
+
/** Unique server identifier (URL-safe) */
|
|
1111
|
+
slug: string;
|
|
1112
|
+
/** Command to start the server */
|
|
1113
|
+
command: string;
|
|
1114
|
+
/** Working directory (optional) */
|
|
1115
|
+
path?: string;
|
|
1116
|
+
/** Path to .env file relative to path (optional) */
|
|
1117
|
+
env_file?: string;
|
|
1118
|
+
/** Inline environment variables (merged with env_file if both provided) */
|
|
1119
|
+
environment?: Record<string, string>;
|
|
1120
|
+
/**
|
|
1121
|
+
* When to automatically restart the server:
|
|
1122
|
+
* - `never`: No automatic restart (default)
|
|
1123
|
+
* - `on-failure`: Restart only on non-zero exit code
|
|
1124
|
+
* - `always`: Always restart on exit (including exit code 0)
|
|
1125
|
+
*/
|
|
1126
|
+
restart_policy?: RestartPolicy;
|
|
1127
|
+
/** Maximum restart attempts (0 = unlimited, default: 0) */
|
|
1128
|
+
max_restarts?: number;
|
|
1129
|
+
/** Delay between restart attempts in milliseconds (default: 1000) */
|
|
1130
|
+
restart_delay_ms?: number;
|
|
1131
|
+
/** Graceful shutdown timeout in milliseconds - SIGTERM → wait → SIGKILL (default: 10000) */
|
|
1132
|
+
stop_timeout_ms?: number;
|
|
1133
|
+
}
|
|
1106
1134
|
/**
|
|
1107
1135
|
* Server resource namespace
|
|
1108
1136
|
*
|
|
1109
1137
|
* @example
|
|
1110
1138
|
* ```typescript
|
|
1111
|
-
* // Start a
|
|
1139
|
+
* // Start a basic server
|
|
1112
1140
|
* const server = await sandbox.server.start({
|
|
1113
1141
|
* slug: 'api',
|
|
1114
1142
|
* command: 'npm start',
|
|
1115
1143
|
* path: '/app',
|
|
1116
1144
|
* });
|
|
1117
1145
|
*
|
|
1146
|
+
* // Start with supervisor settings (auto-restart on failure)
|
|
1147
|
+
* const server = await sandbox.server.start({
|
|
1148
|
+
* slug: 'web',
|
|
1149
|
+
* command: 'node server.js',
|
|
1150
|
+
* path: '/app',
|
|
1151
|
+
* environment: { NODE_ENV: 'production', PORT: '3000' },
|
|
1152
|
+
* restart_policy: 'on-failure',
|
|
1153
|
+
* max_restarts: 5,
|
|
1154
|
+
* restart_delay_ms: 2000,
|
|
1155
|
+
* });
|
|
1156
|
+
*
|
|
1118
1157
|
* // List all servers
|
|
1119
1158
|
* const servers = await sandbox.server.list();
|
|
1120
1159
|
*
|
|
1121
1160
|
* // Retrieve a specific server
|
|
1122
1161
|
* const server = await sandbox.server.retrieve('api');
|
|
1123
1162
|
*
|
|
1124
|
-
* // Stop a server
|
|
1163
|
+
* // Stop a server (graceful shutdown with SIGTERM → SIGKILL)
|
|
1125
1164
|
* await sandbox.server.stop('api');
|
|
1126
1165
|
*
|
|
1127
1166
|
* // Restart a server
|
|
@@ -1136,12 +1175,7 @@ declare class Server {
|
|
|
1136
1175
|
private restartHandler;
|
|
1137
1176
|
private updateStatusHandler;
|
|
1138
1177
|
constructor(handlers: {
|
|
1139
|
-
start: (options:
|
|
1140
|
-
slug: string;
|
|
1141
|
-
command: string;
|
|
1142
|
-
path?: string;
|
|
1143
|
-
env_file?: string;
|
|
1144
|
-
}) => Promise<ServerResponse>;
|
|
1178
|
+
start: (options: ServerStartOptions) => Promise<ServerResponse>;
|
|
1145
1179
|
list: () => Promise<ServersListResponse>;
|
|
1146
1180
|
retrieve: (slug: string) => Promise<ServerResponse>;
|
|
1147
1181
|
stop: (slug: string) => Promise<ServerStopResponse | void>;
|
|
@@ -1149,20 +1183,40 @@ declare class Server {
|
|
|
1149
1183
|
updateStatus: (slug: string, status: ServerStatus) => Promise<void>;
|
|
1150
1184
|
});
|
|
1151
1185
|
/**
|
|
1152
|
-
* Start a new managed server
|
|
1186
|
+
* Start a new managed server with optional supervisor settings
|
|
1187
|
+
*
|
|
1188
|
+
* **Restart Policies:**
|
|
1189
|
+
* - `never` (default): No automatic restart on exit
|
|
1190
|
+
* - `on-failure`: Restart only on non-zero exit code
|
|
1191
|
+
* - `always`: Always restart on exit (including exit code 0)
|
|
1192
|
+
*
|
|
1193
|
+
* **Graceful Shutdown:**
|
|
1194
|
+
* When stopping a server, it first sends SIGTERM and waits for `stop_timeout_ms`
|
|
1195
|
+
* before sending SIGKILL if the process hasn't exited.
|
|
1196
|
+
*
|
|
1153
1197
|
* @param options - Server configuration
|
|
1154
|
-
* @param options.slug - Unique server slug (URL-safe identifier)
|
|
1155
|
-
* @param options.command - Command to start the server
|
|
1156
|
-
* @param options.path - Working directory (optional)
|
|
1157
|
-
* @param options.env_file - Path to env file (optional)
|
|
1158
1198
|
* @returns Server info
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```typescript
|
|
1202
|
+
* // Basic server
|
|
1203
|
+
* const server = await sandbox.server.start({
|
|
1204
|
+
* slug: 'web',
|
|
1205
|
+
* command: 'npm run dev',
|
|
1206
|
+
* path: '/app',
|
|
1207
|
+
* });
|
|
1208
|
+
*
|
|
1209
|
+
* // With supervisor settings
|
|
1210
|
+
* const server = await sandbox.server.start({
|
|
1211
|
+
* slug: 'api',
|
|
1212
|
+
* command: 'node server.js',
|
|
1213
|
+
* environment: { NODE_ENV: 'production' },
|
|
1214
|
+
* restart_policy: 'always',
|
|
1215
|
+
* max_restarts: 0, // unlimited
|
|
1216
|
+
* });
|
|
1217
|
+
* ```
|
|
1159
1218
|
*/
|
|
1160
|
-
start(options:
|
|
1161
|
-
slug: string;
|
|
1162
|
-
command: string;
|
|
1163
|
-
path?: string;
|
|
1164
|
-
env_file?: string;
|
|
1165
|
-
}): Promise<ServerInfo>;
|
|
1219
|
+
start(options: ServerStartOptions): Promise<ServerInfo>;
|
|
1166
1220
|
/**
|
|
1167
1221
|
* List all managed servers
|
|
1168
1222
|
* @returns Array of server info
|
|
@@ -2301,23 +2355,61 @@ interface TerminalResponse {
|
|
|
2301
2355
|
}
|
|
2302
2356
|
/**
|
|
2303
2357
|
* Server status types
|
|
2358
|
+
*
|
|
2359
|
+
* - `starting`: Initial startup of the server process
|
|
2360
|
+
* - `running`: Server process is running
|
|
2361
|
+
* - `ready`: Server is running and ready to accept traffic
|
|
2362
|
+
* - `failed`: Server failed to start or encountered a fatal error
|
|
2363
|
+
* - `stopped`: Server was intentionally stopped
|
|
2364
|
+
* - `restarting`: Server is being automatically restarted by the supervisor
|
|
2365
|
+
*/
|
|
2366
|
+
type ServerStatus = 'starting' | 'running' | 'ready' | 'failed' | 'stopped' | 'restarting';
|
|
2367
|
+
/**
|
|
2368
|
+
* Server restart policy
|
|
2369
|
+
* - `never`: No automatic restart (default)
|
|
2370
|
+
* - `on-failure`: Restart only on non-zero exit code
|
|
2371
|
+
* - `always`: Always restart on exit (including exit code 0)
|
|
2304
2372
|
*/
|
|
2305
|
-
type
|
|
2373
|
+
type RestartPolicy = 'never' | 'on-failure' | 'always';
|
|
2306
2374
|
/**
|
|
2307
2375
|
* Server information
|
|
2308
2376
|
*/
|
|
2309
2377
|
interface ServerInfo {
|
|
2378
|
+
/** Unique server identifier */
|
|
2310
2379
|
slug: string;
|
|
2380
|
+
/** Command used to start the server */
|
|
2311
2381
|
command: string;
|
|
2382
|
+
/** Working directory path */
|
|
2312
2383
|
path: string;
|
|
2384
|
+
/** Original path before resolution */
|
|
2313
2385
|
original_path?: string;
|
|
2386
|
+
/** Path to .env file */
|
|
2314
2387
|
env_file?: string;
|
|
2388
|
+
/** Inline environment variables */
|
|
2389
|
+
environment?: Record<string, string>;
|
|
2390
|
+
/** Auto-detected port number (populated when port monitor detects listening port) */
|
|
2315
2391
|
port?: number;
|
|
2392
|
+
/** Generated URL from subdomain + port (populated when port is detected) */
|
|
2316
2393
|
url?: string;
|
|
2394
|
+
/** Server lifecycle status */
|
|
2317
2395
|
status: ServerStatus;
|
|
2396
|
+
/** Process ID (direct process, not shell wrapper) */
|
|
2318
2397
|
pid?: number;
|
|
2319
|
-
|
|
2398
|
+
/** Configured restart policy */
|
|
2399
|
+
restart_policy?: RestartPolicy;
|
|
2400
|
+
/** Maximum restart attempts (0 = unlimited) */
|
|
2401
|
+
max_restarts?: number;
|
|
2402
|
+
/** Delay between restarts in nanoseconds (input uses milliseconds via restart_delay_ms) */
|
|
2403
|
+
restart_delay?: number;
|
|
2404
|
+
/** Graceful shutdown timeout in nanoseconds (input uses milliseconds via stop_timeout_ms) */
|
|
2405
|
+
stop_timeout?: number;
|
|
2406
|
+
/** Number of times the server has been automatically restarted */
|
|
2407
|
+
restart_count?: number;
|
|
2408
|
+
/** Last exit code (null if process is still running) */
|
|
2409
|
+
exit_code?: number | null;
|
|
2410
|
+
/** When the server was created */
|
|
2320
2411
|
created_at: string;
|
|
2412
|
+
/** When the server was last updated */
|
|
2321
2413
|
updated_at: string;
|
|
2322
2414
|
}
|
|
2323
2415
|
/**
|
|
@@ -2882,14 +2974,51 @@ declare class Sandbox {
|
|
|
2882
2974
|
*/
|
|
2883
2975
|
listServers(): Promise<ServersListResponse>;
|
|
2884
2976
|
/**
|
|
2885
|
-
* Start a new managed server
|
|
2977
|
+
* Start a new managed server with optional supervisor settings
|
|
2978
|
+
*
|
|
2886
2979
|
* @param options - Server configuration
|
|
2980
|
+
* @param options.slug - Unique server identifier
|
|
2981
|
+
* @param options.command - Command to start the server
|
|
2982
|
+
* @param options.path - Working directory (optional)
|
|
2983
|
+
* @param options.env_file - Path to .env file relative to path (optional)
|
|
2984
|
+
* @param options.environment - Inline environment variables (merged with env_file if both provided)
|
|
2985
|
+
* @param options.restart_policy - When to automatically restart: 'never' (default), 'on-failure', 'always'
|
|
2986
|
+
* @param options.max_restarts - Maximum restart attempts, 0 = unlimited (default: 0)
|
|
2987
|
+
* @param options.restart_delay_ms - Delay between restart attempts in milliseconds (default: 1000)
|
|
2988
|
+
* @param options.stop_timeout_ms - Graceful shutdown timeout in milliseconds (default: 10000)
|
|
2989
|
+
*
|
|
2990
|
+
* @example
|
|
2991
|
+
* ```typescript
|
|
2992
|
+
* // Basic server
|
|
2993
|
+
* await sandbox.startServer({
|
|
2994
|
+
* slug: 'web',
|
|
2995
|
+
* command: 'npm run dev',
|
|
2996
|
+
* path: '/app',
|
|
2997
|
+
* });
|
|
2998
|
+
*
|
|
2999
|
+
* // With supervisor settings
|
|
3000
|
+
* await sandbox.startServer({
|
|
3001
|
+
* slug: 'api',
|
|
3002
|
+
* command: 'node server.js',
|
|
3003
|
+
* path: '/app',
|
|
3004
|
+
* environment: { NODE_ENV: 'production', PORT: '3000' },
|
|
3005
|
+
* restart_policy: 'on-failure',
|
|
3006
|
+
* max_restarts: 5,
|
|
3007
|
+
* restart_delay_ms: 2000,
|
|
3008
|
+
* stop_timeout_ms: 5000,
|
|
3009
|
+
* });
|
|
3010
|
+
* ```
|
|
2887
3011
|
*/
|
|
2888
3012
|
startServer(options: {
|
|
2889
3013
|
slug: string;
|
|
2890
3014
|
command: string;
|
|
2891
3015
|
path?: string;
|
|
2892
3016
|
env_file?: string;
|
|
3017
|
+
environment?: Record<string, string>;
|
|
3018
|
+
restart_policy?: RestartPolicy;
|
|
3019
|
+
max_restarts?: number;
|
|
3020
|
+
restart_delay_ms?: number;
|
|
3021
|
+
stop_timeout_ms?: number;
|
|
2893
3022
|
}): Promise<ServerResponse>;
|
|
2894
3023
|
/**
|
|
2895
3024
|
* Get information about a specific server
|
package/dist/index.js
CHANGED
|
@@ -1390,13 +1390,38 @@ var Server = class {
|
|
|
1390
1390
|
this.updateStatusHandler = handlers.updateStatus;
|
|
1391
1391
|
}
|
|
1392
1392
|
/**
|
|
1393
|
-
* Start a new managed server
|
|
1393
|
+
* Start a new managed server with optional supervisor settings
|
|
1394
|
+
*
|
|
1395
|
+
* **Restart Policies:**
|
|
1396
|
+
* - `never` (default): No automatic restart on exit
|
|
1397
|
+
* - `on-failure`: Restart only on non-zero exit code
|
|
1398
|
+
* - `always`: Always restart on exit (including exit code 0)
|
|
1399
|
+
*
|
|
1400
|
+
* **Graceful Shutdown:**
|
|
1401
|
+
* When stopping a server, it first sends SIGTERM and waits for `stop_timeout_ms`
|
|
1402
|
+
* before sending SIGKILL if the process hasn't exited.
|
|
1403
|
+
*
|
|
1394
1404
|
* @param options - Server configuration
|
|
1395
|
-
* @param options.slug - Unique server slug (URL-safe identifier)
|
|
1396
|
-
* @param options.command - Command to start the server
|
|
1397
|
-
* @param options.path - Working directory (optional)
|
|
1398
|
-
* @param options.env_file - Path to env file (optional)
|
|
1399
1405
|
* @returns Server info
|
|
1406
|
+
*
|
|
1407
|
+
* @example
|
|
1408
|
+
* ```typescript
|
|
1409
|
+
* // Basic server
|
|
1410
|
+
* const server = await sandbox.server.start({
|
|
1411
|
+
* slug: 'web',
|
|
1412
|
+
* command: 'npm run dev',
|
|
1413
|
+
* path: '/app',
|
|
1414
|
+
* });
|
|
1415
|
+
*
|
|
1416
|
+
* // With supervisor settings
|
|
1417
|
+
* const server = await sandbox.server.start({
|
|
1418
|
+
* slug: 'api',
|
|
1419
|
+
* command: 'node server.js',
|
|
1420
|
+
* environment: { NODE_ENV: 'production' },
|
|
1421
|
+
* restart_policy: 'always',
|
|
1422
|
+
* max_restarts: 0, // unlimited
|
|
1423
|
+
* });
|
|
1424
|
+
* ```
|
|
1400
1425
|
*/
|
|
1401
1426
|
async start(options) {
|
|
1402
1427
|
const response = await this.startHandler(options);
|
|
@@ -2796,8 +2821,40 @@ API request failed (${response.status}): ${error}`
|
|
|
2796
2821
|
return this.request("/servers");
|
|
2797
2822
|
}
|
|
2798
2823
|
/**
|
|
2799
|
-
* Start a new managed server
|
|
2824
|
+
* Start a new managed server with optional supervisor settings
|
|
2825
|
+
*
|
|
2800
2826
|
* @param options - Server configuration
|
|
2827
|
+
* @param options.slug - Unique server identifier
|
|
2828
|
+
* @param options.command - Command to start the server
|
|
2829
|
+
* @param options.path - Working directory (optional)
|
|
2830
|
+
* @param options.env_file - Path to .env file relative to path (optional)
|
|
2831
|
+
* @param options.environment - Inline environment variables (merged with env_file if both provided)
|
|
2832
|
+
* @param options.restart_policy - When to automatically restart: 'never' (default), 'on-failure', 'always'
|
|
2833
|
+
* @param options.max_restarts - Maximum restart attempts, 0 = unlimited (default: 0)
|
|
2834
|
+
* @param options.restart_delay_ms - Delay between restart attempts in milliseconds (default: 1000)
|
|
2835
|
+
* @param options.stop_timeout_ms - Graceful shutdown timeout in milliseconds (default: 10000)
|
|
2836
|
+
*
|
|
2837
|
+
* @example
|
|
2838
|
+
* ```typescript
|
|
2839
|
+
* // Basic server
|
|
2840
|
+
* await sandbox.startServer({
|
|
2841
|
+
* slug: 'web',
|
|
2842
|
+
* command: 'npm run dev',
|
|
2843
|
+
* path: '/app',
|
|
2844
|
+
* });
|
|
2845
|
+
*
|
|
2846
|
+
* // With supervisor settings
|
|
2847
|
+
* await sandbox.startServer({
|
|
2848
|
+
* slug: 'api',
|
|
2849
|
+
* command: 'node server.js',
|
|
2850
|
+
* path: '/app',
|
|
2851
|
+
* environment: { NODE_ENV: 'production', PORT: '3000' },
|
|
2852
|
+
* restart_policy: 'on-failure',
|
|
2853
|
+
* max_restarts: 5,
|
|
2854
|
+
* restart_delay_ms: 2000,
|
|
2855
|
+
* stop_timeout_ms: 5000,
|
|
2856
|
+
* });
|
|
2857
|
+
* ```
|
|
2801
2858
|
*/
|
|
2802
2859
|
async startServer(options) {
|
|
2803
2860
|
return this.request("/servers", {
|