computesdk 1.17.0 → 1.18.1
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 +32 -5
- package/dist/index.d.ts +32 -5
- package/dist/index.js +79 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1312,7 +1312,7 @@ var Terminal = class {
|
|
|
1312
1312
|
/**
|
|
1313
1313
|
* Retrieve a specific terminal by ID
|
|
1314
1314
|
* @param id - The terminal ID
|
|
1315
|
-
* @returns Terminal
|
|
1315
|
+
* @returns Terminal instance
|
|
1316
1316
|
*/
|
|
1317
1317
|
async retrieve(id) {
|
|
1318
1318
|
return this.retrieveHandler(id);
|
|
@@ -1922,6 +1922,7 @@ var Overlay = class {
|
|
|
1922
1922
|
* @param options.source - Absolute path to source directory
|
|
1923
1923
|
* @param options.target - Relative path in sandbox
|
|
1924
1924
|
* @param options.ignore - Glob patterns to ignore (e.g., ["node_modules", "*.log"])
|
|
1925
|
+
* @param options.strategy - Strategy to use ('copy' or 'smart')
|
|
1925
1926
|
* @param options.waitForCompletion - If true or options object, wait for background copy to complete
|
|
1926
1927
|
* @returns Overlay info with copy status
|
|
1927
1928
|
*/
|
|
@@ -2011,6 +2012,7 @@ Try increasing maxRetries or check if the source directory is very large.`
|
|
|
2011
2012
|
id: response.id,
|
|
2012
2013
|
source: response.source,
|
|
2013
2014
|
target: response.target,
|
|
2015
|
+
strategy: this.validateStrategy(response.strategy),
|
|
2014
2016
|
createdAt: response.created_at,
|
|
2015
2017
|
stats: {
|
|
2016
2018
|
copiedFiles: response.stats.copied_files,
|
|
@@ -2021,6 +2023,16 @@ Try increasing maxRetries or check if the source directory is very large.`
|
|
|
2021
2023
|
copyError: response.copy_error
|
|
2022
2024
|
};
|
|
2023
2025
|
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Validate and return strategy, defaulting to 'copy' for unknown/missing values (legacy support)
|
|
2028
|
+
*/
|
|
2029
|
+
validateStrategy(strategy) {
|
|
2030
|
+
const validStrategies = ["copy", "smart"];
|
|
2031
|
+
if (strategy && validStrategies.includes(strategy)) {
|
|
2032
|
+
return strategy;
|
|
2033
|
+
}
|
|
2034
|
+
return "copy";
|
|
2035
|
+
}
|
|
2024
2036
|
/**
|
|
2025
2037
|
* Validate and return copy status, defaulting to 'pending' for unknown values
|
|
2026
2038
|
*/
|
|
@@ -2051,6 +2063,7 @@ var Sandbox = class {
|
|
|
2051
2063
|
constructor(config) {
|
|
2052
2064
|
this._token = null;
|
|
2053
2065
|
this._ws = null;
|
|
2066
|
+
this._terminals = /* @__PURE__ */ new Map();
|
|
2054
2067
|
this.sandboxId = config.sandboxId;
|
|
2055
2068
|
this.provider = config.provider;
|
|
2056
2069
|
let sandboxUrlResolved = config.sandboxUrl;
|
|
@@ -2257,6 +2270,44 @@ var Sandbox = class {
|
|
|
2257
2270
|
}
|
|
2258
2271
|
return this._ws;
|
|
2259
2272
|
}
|
|
2273
|
+
/**
|
|
2274
|
+
* Create and configure a TerminalInstance from response data
|
|
2275
|
+
*/
|
|
2276
|
+
async hydrateTerminal(data, ws) {
|
|
2277
|
+
const terminal = new TerminalInstance(
|
|
2278
|
+
data.id,
|
|
2279
|
+
data.pty,
|
|
2280
|
+
data.status,
|
|
2281
|
+
data.channel || null,
|
|
2282
|
+
ws || null,
|
|
2283
|
+
data.encoding || "raw"
|
|
2284
|
+
);
|
|
2285
|
+
const terminalId = data.id;
|
|
2286
|
+
terminal.setExecuteHandler(async (command, background) => {
|
|
2287
|
+
return this.request(`/terminals/${terminalId}/execute`, {
|
|
2288
|
+
method: "POST",
|
|
2289
|
+
body: JSON.stringify({ command, background })
|
|
2290
|
+
});
|
|
2291
|
+
});
|
|
2292
|
+
terminal.setListCommandsHandler(async () => {
|
|
2293
|
+
return this.request(`/terminals/${terminalId}/commands`);
|
|
2294
|
+
});
|
|
2295
|
+
terminal.setRetrieveCommandHandler(async (cmdId) => {
|
|
2296
|
+
return this.request(`/terminals/${terminalId}/commands/${cmdId}`);
|
|
2297
|
+
});
|
|
2298
|
+
terminal.setWaitCommandHandler(async (cmdId, timeout) => {
|
|
2299
|
+
const params = timeout ? new URLSearchParams({ timeout: timeout.toString() }) : "";
|
|
2300
|
+
const endpoint = `/terminals/${terminalId}/commands/${cmdId}/wait${params ? `?${params}` : ""}`;
|
|
2301
|
+
return this.request(endpoint);
|
|
2302
|
+
});
|
|
2303
|
+
terminal.setDestroyHandler(async () => {
|
|
2304
|
+
await this.request(`/terminals/${terminalId}`, {
|
|
2305
|
+
method: "DELETE"
|
|
2306
|
+
});
|
|
2307
|
+
this._terminals.delete(terminalId);
|
|
2308
|
+
});
|
|
2309
|
+
return terminal;
|
|
2310
|
+
}
|
|
2260
2311
|
// ============================================================================
|
|
2261
2312
|
// Private Helper Methods
|
|
2262
2313
|
// ============================================================================
|
|
@@ -2763,37 +2814,8 @@ API request failed (${response.status}): ${error}`
|
|
|
2763
2814
|
}
|
|
2764
2815
|
});
|
|
2765
2816
|
}
|
|
2766
|
-
const terminal =
|
|
2767
|
-
|
|
2768
|
-
response.data.pty,
|
|
2769
|
-
response.data.status,
|
|
2770
|
-
response.data.channel || null,
|
|
2771
|
-
ws,
|
|
2772
|
-
response.data.encoding || "raw"
|
|
2773
|
-
);
|
|
2774
|
-
const terminalId = response.data.id;
|
|
2775
|
-
terminal.setExecuteHandler(async (command, background) => {
|
|
2776
|
-
return this.request(`/terminals/${terminalId}/execute`, {
|
|
2777
|
-
method: "POST",
|
|
2778
|
-
body: JSON.stringify({ command, background })
|
|
2779
|
-
});
|
|
2780
|
-
});
|
|
2781
|
-
terminal.setListCommandsHandler(async () => {
|
|
2782
|
-
return this.request(`/terminals/${terminalId}/commands`);
|
|
2783
|
-
});
|
|
2784
|
-
terminal.setRetrieveCommandHandler(async (cmdId) => {
|
|
2785
|
-
return this.request(`/terminals/${terminalId}/commands/${cmdId}`);
|
|
2786
|
-
});
|
|
2787
|
-
terminal.setWaitCommandHandler(async (cmdId, timeout) => {
|
|
2788
|
-
const params = timeout ? new URLSearchParams({ timeout: timeout.toString() }) : "";
|
|
2789
|
-
const endpoint = `/terminals/${terminalId}/commands/${cmdId}/wait${params ? `?${params}` : ""}`;
|
|
2790
|
-
return this.request(endpoint);
|
|
2791
|
-
});
|
|
2792
|
-
terminal.setDestroyHandler(async () => {
|
|
2793
|
-
await this.request(`/terminals/${terminalId}`, {
|
|
2794
|
-
method: "DELETE"
|
|
2795
|
-
});
|
|
2796
|
-
});
|
|
2817
|
+
const terminal = await this.hydrateTerminal(response.data, ws);
|
|
2818
|
+
this._terminals.set(terminal.id, terminal);
|
|
2797
2819
|
return terminal;
|
|
2798
2820
|
}
|
|
2799
2821
|
/**
|
|
@@ -2807,7 +2829,18 @@ API request failed (${response.status}): ${error}`
|
|
|
2807
2829
|
* Get terminal by ID
|
|
2808
2830
|
*/
|
|
2809
2831
|
async getTerminal(id) {
|
|
2810
|
-
|
|
2832
|
+
const cached = this._terminals.get(id);
|
|
2833
|
+
if (cached) {
|
|
2834
|
+
return cached;
|
|
2835
|
+
}
|
|
2836
|
+
const response = await this.request(`/terminals/${id}`);
|
|
2837
|
+
let ws = null;
|
|
2838
|
+
if (response.data.pty) {
|
|
2839
|
+
ws = await this.ensureWebSocket();
|
|
2840
|
+
}
|
|
2841
|
+
const terminal = await this.hydrateTerminal(response.data, ws);
|
|
2842
|
+
this._terminals.set(id, terminal);
|
|
2843
|
+
return terminal;
|
|
2811
2844
|
}
|
|
2812
2845
|
// ============================================================================
|
|
2813
2846
|
// Command Tracking (Exec Mode Terminals)
|
|
@@ -3411,6 +3444,7 @@ API request failed (${response.status}): ${error}`
|
|
|
3411
3444
|
this._ws.disconnect();
|
|
3412
3445
|
this._ws = null;
|
|
3413
3446
|
}
|
|
3447
|
+
this._terminals.clear();
|
|
3414
3448
|
}
|
|
3415
3449
|
};
|
|
3416
3450
|
|
|
@@ -3419,6 +3453,7 @@ var PROVIDER_AUTH = {
|
|
|
3419
3453
|
e2b: [["E2B_API_KEY"]],
|
|
3420
3454
|
modal: [["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]],
|
|
3421
3455
|
railway: [["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]],
|
|
3456
|
+
render: [["RENDER_API_KEY", "RENDER_OWNER_ID"]],
|
|
3422
3457
|
daytona: [["DAYTONA_API_KEY"]],
|
|
3423
3458
|
vercel: [
|
|
3424
3459
|
["VERCEL_OIDC_TOKEN"],
|
|
@@ -3443,6 +3478,10 @@ var PROVIDER_HEADERS = {
|
|
|
3443
3478
|
projectId: "X-Railway-Project-ID",
|
|
3444
3479
|
environmentId: "X-Railway-Environment-ID"
|
|
3445
3480
|
},
|
|
3481
|
+
render: {
|
|
3482
|
+
apiKey: "X-Render-API-Key",
|
|
3483
|
+
ownerId: "X-Render-Owner-ID"
|
|
3484
|
+
},
|
|
3446
3485
|
daytona: {
|
|
3447
3486
|
apiKey: "X-Daytona-API-Key"
|
|
3448
3487
|
},
|
|
@@ -3480,6 +3519,10 @@ var PROVIDER_ENV_MAP = {
|
|
|
3480
3519
|
RAILWAY_PROJECT_ID: "projectId",
|
|
3481
3520
|
RAILWAY_ENVIRONMENT_ID: "environmentId"
|
|
3482
3521
|
},
|
|
3522
|
+
render: {
|
|
3523
|
+
RENDER_API_KEY: "apiKey",
|
|
3524
|
+
RENDER_OWNER_ID: "ownerId"
|
|
3525
|
+
},
|
|
3483
3526
|
daytona: {
|
|
3484
3527
|
DAYTONA_API_KEY: "apiKey"
|
|
3485
3528
|
},
|
|
@@ -3508,6 +3551,7 @@ var PROVIDER_DASHBOARD_URLS = {
|
|
|
3508
3551
|
e2b: "https://e2b.dev/dashboard",
|
|
3509
3552
|
modal: "https://modal.com/settings",
|
|
3510
3553
|
railway: "https://railway.app/account/tokens",
|
|
3554
|
+
render: "https://dashboard.render.com/account",
|
|
3511
3555
|
daytona: "https://daytona.io/dashboard",
|
|
3512
3556
|
vercel: "https://vercel.com/account/tokens",
|
|
3513
3557
|
runloop: "https://runloop.ai/dashboard",
|
|
@@ -3574,6 +3618,7 @@ var GATEWAY_URL = "https://gateway.computesdk.com";
|
|
|
3574
3618
|
var PROVIDER_PRIORITY = [
|
|
3575
3619
|
"e2b",
|
|
3576
3620
|
"railway",
|
|
3621
|
+
"render",
|
|
3577
3622
|
"daytona",
|
|
3578
3623
|
"modal",
|
|
3579
3624
|
"runloop",
|
|
@@ -3585,6 +3630,7 @@ var PROVIDER_PRIORITY = [
|
|
|
3585
3630
|
var PROVIDER_ENV_VARS = {
|
|
3586
3631
|
e2b: ["E2B_API_KEY"],
|
|
3587
3632
|
railway: ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"],
|
|
3633
|
+
render: ["RENDER_API_KEY", "RENDER_OWNER_ID"],
|
|
3588
3634
|
daytona: ["DAYTONA_API_KEY"],
|
|
3589
3635
|
modal: ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"],
|
|
3590
3636
|
runloop: ["RUNLOOP_API_KEY"],
|