computesdk 1.13.0 → 1.15.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 +114 -26
- package/dist/index.d.ts +114 -26
- package/dist/index.js +64 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1388,10 +1388,15 @@ var Server = class {
|
|
|
1388
1388
|
this.stopHandler = handlers.stop;
|
|
1389
1389
|
this.restartHandler = handlers.restart;
|
|
1390
1390
|
this.updateStatusHandler = handlers.updateStatus;
|
|
1391
|
+
this.logsHandler = handlers.logs;
|
|
1391
1392
|
}
|
|
1392
1393
|
/**
|
|
1393
1394
|
* Start a new managed server with optional supervisor settings
|
|
1394
1395
|
*
|
|
1396
|
+
* **Install Phase:**
|
|
1397
|
+
* If `install` is provided, it runs blocking before `start` (e.g., "npm install").
|
|
1398
|
+
* The server status will be `installing` during this phase.
|
|
1399
|
+
*
|
|
1395
1400
|
* **Restart Policies:**
|
|
1396
1401
|
* - `never` (default): No automatic restart on exit
|
|
1397
1402
|
* - `on-failure`: Restart only on non-zero exit code
|
|
@@ -1409,14 +1414,15 @@ var Server = class {
|
|
|
1409
1414
|
* // Basic server
|
|
1410
1415
|
* const server = await sandbox.server.start({
|
|
1411
1416
|
* slug: 'web',
|
|
1412
|
-
*
|
|
1417
|
+
* start: 'npm run dev',
|
|
1413
1418
|
* path: '/app',
|
|
1414
1419
|
* });
|
|
1415
1420
|
*
|
|
1416
|
-
* // With
|
|
1421
|
+
* // With install command
|
|
1417
1422
|
* const server = await sandbox.server.start({
|
|
1418
1423
|
* slug: 'api',
|
|
1419
|
-
*
|
|
1424
|
+
* install: 'npm install',
|
|
1425
|
+
* start: 'node server.js',
|
|
1420
1426
|
* environment: { NODE_ENV: 'production' },
|
|
1421
1427
|
* restart_policy: 'always',
|
|
1422
1428
|
* max_restarts: 0, // unlimited
|
|
@@ -1468,6 +1474,29 @@ var Server = class {
|
|
|
1468
1474
|
async updateStatus(slug, status) {
|
|
1469
1475
|
await this.updateStatusHandler(slug, status);
|
|
1470
1476
|
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Retrieve captured output (logs) for a managed server
|
|
1479
|
+
* @param slug - The server slug
|
|
1480
|
+
* @param options - Options for log retrieval
|
|
1481
|
+
* @returns Server logs info
|
|
1482
|
+
*
|
|
1483
|
+
* @example
|
|
1484
|
+
* ```typescript
|
|
1485
|
+
* // Get combined logs (default)
|
|
1486
|
+
* const logs = await sandbox.server.logs('api');
|
|
1487
|
+
* console.log(logs.logs);
|
|
1488
|
+
*
|
|
1489
|
+
* // Get only stdout
|
|
1490
|
+
* const stdout = await sandbox.server.logs('api', { stream: 'stdout' });
|
|
1491
|
+
*
|
|
1492
|
+
* // Get only stderr
|
|
1493
|
+
* const stderr = await sandbox.server.logs('api', { stream: 'stderr' });
|
|
1494
|
+
* ```
|
|
1495
|
+
*/
|
|
1496
|
+
async logs(slug, options) {
|
|
1497
|
+
const response = await this.logsHandler(slug, options);
|
|
1498
|
+
return response.data;
|
|
1499
|
+
}
|
|
1471
1500
|
};
|
|
1472
1501
|
|
|
1473
1502
|
// src/client/resources/watcher.ts
|
|
@@ -1909,13 +1938,14 @@ var Overlay = class {
|
|
|
1909
1938
|
/**
|
|
1910
1939
|
* Create a new overlay from a template directory
|
|
1911
1940
|
*
|
|
1912
|
-
* The overlay
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1941
|
+
* The overlay copies files from the source directory into the target path
|
|
1942
|
+
* for better isolation. Heavy directories (node_modules, .venv, etc.) are
|
|
1943
|
+
* copied in the background. Use the `ignore` option to exclude files/directories.
|
|
1915
1944
|
*
|
|
1916
1945
|
* @param options - Overlay creation options
|
|
1917
1946
|
* @param options.source - Absolute path to source directory
|
|
1918
1947
|
* @param options.target - Relative path in sandbox
|
|
1948
|
+
* @param options.ignore - Glob patterns to ignore (e.g., ["node_modules", "*.log"])
|
|
1919
1949
|
* @returns Overlay info with copy status
|
|
1920
1950
|
*/
|
|
1921
1951
|
async create(options) {
|
|
@@ -1959,8 +1989,8 @@ var Overlay = class {
|
|
|
1959
1989
|
target: response.target,
|
|
1960
1990
|
createdAt: response.created_at,
|
|
1961
1991
|
stats: {
|
|
1962
|
-
|
|
1963
|
-
|
|
1992
|
+
copiedFiles: response.stats.copied_files,
|
|
1993
|
+
copiedDirs: response.stats.copied_dirs,
|
|
1964
1994
|
skipped: response.stats.skipped
|
|
1965
1995
|
},
|
|
1966
1996
|
copyStatus: this.validateCopyStatus(response.copy_status),
|
|
@@ -2124,7 +2154,8 @@ var Sandbox = class {
|
|
|
2124
2154
|
restart: async (slug) => this.restartServer(slug),
|
|
2125
2155
|
updateStatus: async (slug, status) => {
|
|
2126
2156
|
await this.updateServerStatus(slug, status);
|
|
2127
|
-
}
|
|
2157
|
+
},
|
|
2158
|
+
logs: async (slug, options) => this.getServerLogs(slug, options)
|
|
2128
2159
|
});
|
|
2129
2160
|
this.watcher = new Watcher({
|
|
2130
2161
|
create: async (path, options) => this.createWatcher(path, options),
|
|
@@ -2969,7 +3000,8 @@ API request failed (${response.status}): ${error}`
|
|
|
2969
3000
|
*
|
|
2970
3001
|
* @param options - Server configuration
|
|
2971
3002
|
* @param options.slug - Unique server identifier
|
|
2972
|
-
* @param options.
|
|
3003
|
+
* @param options.install - Install command (optional, runs blocking before start, e.g., "npm install")
|
|
3004
|
+
* @param options.start - Command to start the server (e.g., "npm run dev")
|
|
2973
3005
|
* @param options.path - Working directory (optional)
|
|
2974
3006
|
* @param options.env_file - Path to .env file relative to path (optional)
|
|
2975
3007
|
* @param options.environment - Inline environment variables (merged with env_file if both provided)
|
|
@@ -2983,14 +3015,15 @@ API request failed (${response.status}): ${error}`
|
|
|
2983
3015
|
* // Basic server
|
|
2984
3016
|
* await sandbox.startServer({
|
|
2985
3017
|
* slug: 'web',
|
|
2986
|
-
*
|
|
3018
|
+
* start: 'npm run dev',
|
|
2987
3019
|
* path: '/app',
|
|
2988
3020
|
* });
|
|
2989
3021
|
*
|
|
2990
|
-
* // With supervisor settings
|
|
3022
|
+
* // With install command and supervisor settings
|
|
2991
3023
|
* await sandbox.startServer({
|
|
2992
3024
|
* slug: 'api',
|
|
2993
|
-
*
|
|
3025
|
+
* install: 'npm install',
|
|
3026
|
+
* start: 'node server.js',
|
|
2994
3027
|
* path: '/app',
|
|
2995
3028
|
* environment: { NODE_ENV: 'production', PORT: '3000' },
|
|
2996
3029
|
* restart_policy: 'on-failure',
|
|
@@ -3037,6 +3070,21 @@ API request failed (${response.status}): ${error}`
|
|
|
3037
3070
|
}
|
|
3038
3071
|
);
|
|
3039
3072
|
}
|
|
3073
|
+
/**
|
|
3074
|
+
* Get logs for a managed server
|
|
3075
|
+
* @param slug - Server slug
|
|
3076
|
+
* @param options - Options for log retrieval
|
|
3077
|
+
*/
|
|
3078
|
+
async getServerLogs(slug, options) {
|
|
3079
|
+
const params = new URLSearchParams();
|
|
3080
|
+
if (options?.stream) {
|
|
3081
|
+
params.set("stream", options.stream);
|
|
3082
|
+
}
|
|
3083
|
+
const queryString = params.toString();
|
|
3084
|
+
return this.request(
|
|
3085
|
+
`/servers/${encodeURIComponent(slug)}/logs${queryString ? `?${queryString}` : ""}`
|
|
3086
|
+
);
|
|
3087
|
+
}
|
|
3040
3088
|
/**
|
|
3041
3089
|
* Update server status (internal use)
|
|
3042
3090
|
* @param slug - Server slug
|
|
@@ -3318,7 +3366,9 @@ var PROVIDER_HEADERS = {
|
|
|
3318
3366
|
tokenSecret: "X-Modal-Token-Secret"
|
|
3319
3367
|
},
|
|
3320
3368
|
railway: {
|
|
3321
|
-
apiToken: "X-Railway-API-
|
|
3369
|
+
apiToken: "X-Railway-API-Key",
|
|
3370
|
+
projectId: "X-Railway-Project-ID",
|
|
3371
|
+
environmentId: "X-Railway-Environment-ID"
|
|
3322
3372
|
},
|
|
3323
3373
|
daytona: {
|
|
3324
3374
|
apiKey: "X-Daytona-API-Key"
|