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.mjs
CHANGED
|
@@ -1335,10 +1335,15 @@ var Server = class {
|
|
|
1335
1335
|
this.stopHandler = handlers.stop;
|
|
1336
1336
|
this.restartHandler = handlers.restart;
|
|
1337
1337
|
this.updateStatusHandler = handlers.updateStatus;
|
|
1338
|
+
this.logsHandler = handlers.logs;
|
|
1338
1339
|
}
|
|
1339
1340
|
/**
|
|
1340
1341
|
* Start a new managed server with optional supervisor settings
|
|
1341
1342
|
*
|
|
1343
|
+
* **Install Phase:**
|
|
1344
|
+
* If `install` is provided, it runs blocking before `start` (e.g., "npm install").
|
|
1345
|
+
* The server status will be `installing` during this phase.
|
|
1346
|
+
*
|
|
1342
1347
|
* **Restart Policies:**
|
|
1343
1348
|
* - `never` (default): No automatic restart on exit
|
|
1344
1349
|
* - `on-failure`: Restart only on non-zero exit code
|
|
@@ -1356,14 +1361,15 @@ var Server = class {
|
|
|
1356
1361
|
* // Basic server
|
|
1357
1362
|
* const server = await sandbox.server.start({
|
|
1358
1363
|
* slug: 'web',
|
|
1359
|
-
*
|
|
1364
|
+
* start: 'npm run dev',
|
|
1360
1365
|
* path: '/app',
|
|
1361
1366
|
* });
|
|
1362
1367
|
*
|
|
1363
|
-
* // With
|
|
1368
|
+
* // With install command
|
|
1364
1369
|
* const server = await sandbox.server.start({
|
|
1365
1370
|
* slug: 'api',
|
|
1366
|
-
*
|
|
1371
|
+
* install: 'npm install',
|
|
1372
|
+
* start: 'node server.js',
|
|
1367
1373
|
* environment: { NODE_ENV: 'production' },
|
|
1368
1374
|
* restart_policy: 'always',
|
|
1369
1375
|
* max_restarts: 0, // unlimited
|
|
@@ -1415,6 +1421,29 @@ var Server = class {
|
|
|
1415
1421
|
async updateStatus(slug, status) {
|
|
1416
1422
|
await this.updateStatusHandler(slug, status);
|
|
1417
1423
|
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Retrieve captured output (logs) for a managed server
|
|
1426
|
+
* @param slug - The server slug
|
|
1427
|
+
* @param options - Options for log retrieval
|
|
1428
|
+
* @returns Server logs info
|
|
1429
|
+
*
|
|
1430
|
+
* @example
|
|
1431
|
+
* ```typescript
|
|
1432
|
+
* // Get combined logs (default)
|
|
1433
|
+
* const logs = await sandbox.server.logs('api');
|
|
1434
|
+
* console.log(logs.logs);
|
|
1435
|
+
*
|
|
1436
|
+
* // Get only stdout
|
|
1437
|
+
* const stdout = await sandbox.server.logs('api', { stream: 'stdout' });
|
|
1438
|
+
*
|
|
1439
|
+
* // Get only stderr
|
|
1440
|
+
* const stderr = await sandbox.server.logs('api', { stream: 'stderr' });
|
|
1441
|
+
* ```
|
|
1442
|
+
*/
|
|
1443
|
+
async logs(slug, options) {
|
|
1444
|
+
const response = await this.logsHandler(slug, options);
|
|
1445
|
+
return response.data;
|
|
1446
|
+
}
|
|
1418
1447
|
};
|
|
1419
1448
|
|
|
1420
1449
|
// src/client/resources/watcher.ts
|
|
@@ -1856,13 +1885,14 @@ var Overlay = class {
|
|
|
1856
1885
|
/**
|
|
1857
1886
|
* Create a new overlay from a template directory
|
|
1858
1887
|
*
|
|
1859
|
-
* The overlay
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
1888
|
+
* The overlay copies files from the source directory into the target path
|
|
1889
|
+
* for better isolation. Heavy directories (node_modules, .venv, etc.) are
|
|
1890
|
+
* copied in the background. Use the `ignore` option to exclude files/directories.
|
|
1862
1891
|
*
|
|
1863
1892
|
* @param options - Overlay creation options
|
|
1864
1893
|
* @param options.source - Absolute path to source directory
|
|
1865
1894
|
* @param options.target - Relative path in sandbox
|
|
1895
|
+
* @param options.ignore - Glob patterns to ignore (e.g., ["node_modules", "*.log"])
|
|
1866
1896
|
* @returns Overlay info with copy status
|
|
1867
1897
|
*/
|
|
1868
1898
|
async create(options) {
|
|
@@ -1906,8 +1936,8 @@ var Overlay = class {
|
|
|
1906
1936
|
target: response.target,
|
|
1907
1937
|
createdAt: response.created_at,
|
|
1908
1938
|
stats: {
|
|
1909
|
-
|
|
1910
|
-
|
|
1939
|
+
copiedFiles: response.stats.copied_files,
|
|
1940
|
+
copiedDirs: response.stats.copied_dirs,
|
|
1911
1941
|
skipped: response.stats.skipped
|
|
1912
1942
|
},
|
|
1913
1943
|
copyStatus: this.validateCopyStatus(response.copy_status),
|
|
@@ -2071,7 +2101,8 @@ var Sandbox = class {
|
|
|
2071
2101
|
restart: async (slug) => this.restartServer(slug),
|
|
2072
2102
|
updateStatus: async (slug, status) => {
|
|
2073
2103
|
await this.updateServerStatus(slug, status);
|
|
2074
|
-
}
|
|
2104
|
+
},
|
|
2105
|
+
logs: async (slug, options) => this.getServerLogs(slug, options)
|
|
2075
2106
|
});
|
|
2076
2107
|
this.watcher = new Watcher({
|
|
2077
2108
|
create: async (path, options) => this.createWatcher(path, options),
|
|
@@ -2916,7 +2947,8 @@ API request failed (${response.status}): ${error}`
|
|
|
2916
2947
|
*
|
|
2917
2948
|
* @param options - Server configuration
|
|
2918
2949
|
* @param options.slug - Unique server identifier
|
|
2919
|
-
* @param options.
|
|
2950
|
+
* @param options.install - Install command (optional, runs blocking before start, e.g., "npm install")
|
|
2951
|
+
* @param options.start - Command to start the server (e.g., "npm run dev")
|
|
2920
2952
|
* @param options.path - Working directory (optional)
|
|
2921
2953
|
* @param options.env_file - Path to .env file relative to path (optional)
|
|
2922
2954
|
* @param options.environment - Inline environment variables (merged with env_file if both provided)
|
|
@@ -2930,14 +2962,15 @@ API request failed (${response.status}): ${error}`
|
|
|
2930
2962
|
* // Basic server
|
|
2931
2963
|
* await sandbox.startServer({
|
|
2932
2964
|
* slug: 'web',
|
|
2933
|
-
*
|
|
2965
|
+
* start: 'npm run dev',
|
|
2934
2966
|
* path: '/app',
|
|
2935
2967
|
* });
|
|
2936
2968
|
*
|
|
2937
|
-
* // With supervisor settings
|
|
2969
|
+
* // With install command and supervisor settings
|
|
2938
2970
|
* await sandbox.startServer({
|
|
2939
2971
|
* slug: 'api',
|
|
2940
|
-
*
|
|
2972
|
+
* install: 'npm install',
|
|
2973
|
+
* start: 'node server.js',
|
|
2941
2974
|
* path: '/app',
|
|
2942
2975
|
* environment: { NODE_ENV: 'production', PORT: '3000' },
|
|
2943
2976
|
* restart_policy: 'on-failure',
|
|
@@ -2984,6 +3017,21 @@ API request failed (${response.status}): ${error}`
|
|
|
2984
3017
|
}
|
|
2985
3018
|
);
|
|
2986
3019
|
}
|
|
3020
|
+
/**
|
|
3021
|
+
* Get logs for a managed server
|
|
3022
|
+
* @param slug - Server slug
|
|
3023
|
+
* @param options - Options for log retrieval
|
|
3024
|
+
*/
|
|
3025
|
+
async getServerLogs(slug, options) {
|
|
3026
|
+
const params = new URLSearchParams();
|
|
3027
|
+
if (options?.stream) {
|
|
3028
|
+
params.set("stream", options.stream);
|
|
3029
|
+
}
|
|
3030
|
+
const queryString = params.toString();
|
|
3031
|
+
return this.request(
|
|
3032
|
+
`/servers/${encodeURIComponent(slug)}/logs${queryString ? `?${queryString}` : ""}`
|
|
3033
|
+
);
|
|
3034
|
+
}
|
|
2987
3035
|
/**
|
|
2988
3036
|
* Update server status (internal use)
|
|
2989
3037
|
* @param slug - Server slug
|
|
@@ -3265,7 +3313,9 @@ var PROVIDER_HEADERS = {
|
|
|
3265
3313
|
tokenSecret: "X-Modal-Token-Secret"
|
|
3266
3314
|
},
|
|
3267
3315
|
railway: {
|
|
3268
|
-
apiToken: "X-Railway-API-
|
|
3316
|
+
apiToken: "X-Railway-API-Key",
|
|
3317
|
+
projectId: "X-Railway-Project-ID",
|
|
3318
|
+
environmentId: "X-Railway-Environment-ID"
|
|
3269
3319
|
},
|
|
3270
3320
|
daytona: {
|
|
3271
3321
|
apiKey: "X-Daytona-API-Key"
|