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.d.mts
CHANGED
|
@@ -1064,7 +1064,7 @@ declare class Terminal {
|
|
|
1064
1064
|
pty?: boolean;
|
|
1065
1065
|
}) => Promise<TerminalInstance>;
|
|
1066
1066
|
list: () => Promise<TerminalResponse[]>;
|
|
1067
|
-
retrieve: (id: string) => Promise<
|
|
1067
|
+
retrieve: (id: string) => Promise<TerminalInstance>;
|
|
1068
1068
|
destroy: (id: string) => Promise<void>;
|
|
1069
1069
|
});
|
|
1070
1070
|
/**
|
|
@@ -1089,9 +1089,9 @@ declare class Terminal {
|
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Retrieve a specific terminal by ID
|
|
1091
1091
|
* @param id - The terminal ID
|
|
1092
|
-
* @returns Terminal
|
|
1092
|
+
* @returns Terminal instance
|
|
1093
1093
|
*/
|
|
1094
|
-
retrieve(id: string): Promise<
|
|
1094
|
+
retrieve(id: string): Promise<TerminalInstance>;
|
|
1095
1095
|
/**
|
|
1096
1096
|
* Destroy a terminal by ID
|
|
1097
1097
|
* @param id - The terminal ID
|
|
@@ -2040,6 +2040,12 @@ interface WaitForCompletionOptions {
|
|
|
2040
2040
|
/** Backoff multiplier for exponential backoff (default: 1.5) */
|
|
2041
2041
|
backoffFactor?: number;
|
|
2042
2042
|
}
|
|
2043
|
+
/**
|
|
2044
|
+
* Strategy for creating an overlay
|
|
2045
|
+
* - 'copy': Full copy of all files (standard behavior)
|
|
2046
|
+
* - 'smart': Use symlinks for immutable packages (e.g. node_modules) for instant creation
|
|
2047
|
+
*/
|
|
2048
|
+
type OverlayStrategy = 'copy' | 'smart';
|
|
2043
2049
|
/**
|
|
2044
2050
|
* Options for creating an overlay
|
|
2045
2051
|
*/
|
|
@@ -2050,6 +2056,8 @@ interface CreateOverlayOptions {
|
|
|
2050
2056
|
target: string;
|
|
2051
2057
|
/** Glob patterns to ignore (e.g., ["node_modules", "*.log"]) */
|
|
2052
2058
|
ignore?: string[];
|
|
2059
|
+
/** Strategy to use (default: 'smart') */
|
|
2060
|
+
strategy?: OverlayStrategy;
|
|
2053
2061
|
/** If true, wait for background copy to complete before returning (default: false) */
|
|
2054
2062
|
waitForCompletion?: boolean | WaitForCompletionOptions;
|
|
2055
2063
|
}
|
|
@@ -2078,6 +2086,8 @@ interface OverlayInfo {
|
|
|
2078
2086
|
source: string;
|
|
2079
2087
|
/** Relative path in sandbox */
|
|
2080
2088
|
target: string;
|
|
2089
|
+
/** Strategy used for the overlay */
|
|
2090
|
+
strategy: OverlayStrategy;
|
|
2081
2091
|
/** When the overlay was created */
|
|
2082
2092
|
createdAt: string;
|
|
2083
2093
|
/** Statistics about the overlay */
|
|
@@ -2094,6 +2104,7 @@ interface OverlayResponse {
|
|
|
2094
2104
|
id: string;
|
|
2095
2105
|
source: string;
|
|
2096
2106
|
target: string;
|
|
2107
|
+
strategy?: string;
|
|
2097
2108
|
created_at: string;
|
|
2098
2109
|
stats: {
|
|
2099
2110
|
copied_files: number;
|
|
@@ -2166,6 +2177,7 @@ declare class Overlay {
|
|
|
2166
2177
|
* @param options.source - Absolute path to source directory
|
|
2167
2178
|
* @param options.target - Relative path in sandbox
|
|
2168
2179
|
* @param options.ignore - Glob patterns to ignore (e.g., ["node_modules", "*.log"])
|
|
2180
|
+
* @param options.strategy - Strategy to use ('copy' or 'smart')
|
|
2169
2181
|
* @param options.waitForCompletion - If true or options object, wait for background copy to complete
|
|
2170
2182
|
* @returns Overlay info with copy status
|
|
2171
2183
|
*/
|
|
@@ -2205,6 +2217,10 @@ declare class Overlay {
|
|
|
2205
2217
|
* Convert API response to OverlayInfo
|
|
2206
2218
|
*/
|
|
2207
2219
|
private toOverlayInfo;
|
|
2220
|
+
/**
|
|
2221
|
+
* Validate and return strategy, defaulting to 'copy' for unknown/missing values (legacy support)
|
|
2222
|
+
*/
|
|
2223
|
+
private validateStrategy;
|
|
2208
2224
|
/**
|
|
2209
2225
|
* Validate and return copy status, defaulting to 'pending' for unknown values
|
|
2210
2226
|
*/
|
|
@@ -2925,11 +2941,16 @@ declare class Sandbox {
|
|
|
2925
2941
|
private _token;
|
|
2926
2942
|
private _ws;
|
|
2927
2943
|
private WebSocketImpl;
|
|
2944
|
+
private _terminals;
|
|
2928
2945
|
constructor(config: SandboxConfig);
|
|
2929
2946
|
/**
|
|
2930
2947
|
* Get or create internal WebSocket manager
|
|
2931
2948
|
*/
|
|
2932
2949
|
private ensureWebSocket;
|
|
2950
|
+
/**
|
|
2951
|
+
* Create and configure a TerminalInstance from response data
|
|
2952
|
+
*/
|
|
2953
|
+
private hydrateTerminal;
|
|
2933
2954
|
private request;
|
|
2934
2955
|
/**
|
|
2935
2956
|
* Check service health
|
|
@@ -3231,7 +3252,7 @@ declare class Sandbox {
|
|
|
3231
3252
|
/**
|
|
3232
3253
|
* Get terminal by ID
|
|
3233
3254
|
*/
|
|
3234
|
-
getTerminal(id: string): Promise<
|
|
3255
|
+
getTerminal(id: string): Promise<TerminalInstance>;
|
|
3235
3256
|
/**
|
|
3236
3257
|
* List all commands executed in a terminal (exec mode only)
|
|
3237
3258
|
* @param terminalId - The terminal ID
|
|
@@ -3583,6 +3604,7 @@ declare const PROVIDER_AUTH: {
|
|
|
3583
3604
|
readonly e2b: readonly [readonly ["E2B_API_KEY"]];
|
|
3584
3605
|
readonly modal: readonly [readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]];
|
|
3585
3606
|
readonly railway: readonly [readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]];
|
|
3607
|
+
readonly render: readonly [readonly ["RENDER_API_KEY", "RENDER_OWNER_ID"]];
|
|
3586
3608
|
readonly daytona: readonly [readonly ["DAYTONA_API_KEY"]];
|
|
3587
3609
|
readonly vercel: readonly [readonly ["VERCEL_OIDC_TOKEN"], readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]];
|
|
3588
3610
|
readonly runloop: readonly [readonly ["RUNLOOP_API_KEY"]];
|
|
@@ -3677,6 +3699,10 @@ interface ExplicitComputeConfig {
|
|
|
3677
3699
|
projectId?: string;
|
|
3678
3700
|
environmentId?: string;
|
|
3679
3701
|
};
|
|
3702
|
+
render?: {
|
|
3703
|
+
apiKey?: string;
|
|
3704
|
+
serviceId?: string;
|
|
3705
|
+
};
|
|
3680
3706
|
daytona?: {
|
|
3681
3707
|
apiKey?: string;
|
|
3682
3708
|
};
|
|
@@ -3891,7 +3917,7 @@ declare const GATEWAY_URL = "https://gateway.computesdk.com";
|
|
|
3891
3917
|
* Provider detection priority order
|
|
3892
3918
|
* When multiple provider credentials are detected, use the first one in this list
|
|
3893
3919
|
*/
|
|
3894
|
-
declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
|
|
3920
|
+
declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "render", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
|
|
3895
3921
|
/**
|
|
3896
3922
|
* Required environment variables for each provider
|
|
3897
3923
|
* @deprecated Use PROVIDER_AUTH from provider-config instead
|
|
@@ -3899,6 +3925,7 @@ declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal",
|
|
|
3899
3925
|
declare const PROVIDER_ENV_VARS: {
|
|
3900
3926
|
readonly e2b: readonly ["E2B_API_KEY"];
|
|
3901
3927
|
readonly railway: readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"];
|
|
3928
|
+
readonly render: readonly ["RENDER_API_KEY", "RENDER_OWNER_ID"];
|
|
3902
3929
|
readonly daytona: readonly ["DAYTONA_API_KEY"];
|
|
3903
3930
|
readonly modal: readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"];
|
|
3904
3931
|
readonly runloop: readonly ["RUNLOOP_API_KEY"];
|
package/dist/index.d.ts
CHANGED
|
@@ -1064,7 +1064,7 @@ declare class Terminal {
|
|
|
1064
1064
|
pty?: boolean;
|
|
1065
1065
|
}) => Promise<TerminalInstance>;
|
|
1066
1066
|
list: () => Promise<TerminalResponse[]>;
|
|
1067
|
-
retrieve: (id: string) => Promise<
|
|
1067
|
+
retrieve: (id: string) => Promise<TerminalInstance>;
|
|
1068
1068
|
destroy: (id: string) => Promise<void>;
|
|
1069
1069
|
});
|
|
1070
1070
|
/**
|
|
@@ -1089,9 +1089,9 @@ declare class Terminal {
|
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Retrieve a specific terminal by ID
|
|
1091
1091
|
* @param id - The terminal ID
|
|
1092
|
-
* @returns Terminal
|
|
1092
|
+
* @returns Terminal instance
|
|
1093
1093
|
*/
|
|
1094
|
-
retrieve(id: string): Promise<
|
|
1094
|
+
retrieve(id: string): Promise<TerminalInstance>;
|
|
1095
1095
|
/**
|
|
1096
1096
|
* Destroy a terminal by ID
|
|
1097
1097
|
* @param id - The terminal ID
|
|
@@ -2040,6 +2040,12 @@ interface WaitForCompletionOptions {
|
|
|
2040
2040
|
/** Backoff multiplier for exponential backoff (default: 1.5) */
|
|
2041
2041
|
backoffFactor?: number;
|
|
2042
2042
|
}
|
|
2043
|
+
/**
|
|
2044
|
+
* Strategy for creating an overlay
|
|
2045
|
+
* - 'copy': Full copy of all files (standard behavior)
|
|
2046
|
+
* - 'smart': Use symlinks for immutable packages (e.g. node_modules) for instant creation
|
|
2047
|
+
*/
|
|
2048
|
+
type OverlayStrategy = 'copy' | 'smart';
|
|
2043
2049
|
/**
|
|
2044
2050
|
* Options for creating an overlay
|
|
2045
2051
|
*/
|
|
@@ -2050,6 +2056,8 @@ interface CreateOverlayOptions {
|
|
|
2050
2056
|
target: string;
|
|
2051
2057
|
/** Glob patterns to ignore (e.g., ["node_modules", "*.log"]) */
|
|
2052
2058
|
ignore?: string[];
|
|
2059
|
+
/** Strategy to use (default: 'smart') */
|
|
2060
|
+
strategy?: OverlayStrategy;
|
|
2053
2061
|
/** If true, wait for background copy to complete before returning (default: false) */
|
|
2054
2062
|
waitForCompletion?: boolean | WaitForCompletionOptions;
|
|
2055
2063
|
}
|
|
@@ -2078,6 +2086,8 @@ interface OverlayInfo {
|
|
|
2078
2086
|
source: string;
|
|
2079
2087
|
/** Relative path in sandbox */
|
|
2080
2088
|
target: string;
|
|
2089
|
+
/** Strategy used for the overlay */
|
|
2090
|
+
strategy: OverlayStrategy;
|
|
2081
2091
|
/** When the overlay was created */
|
|
2082
2092
|
createdAt: string;
|
|
2083
2093
|
/** Statistics about the overlay */
|
|
@@ -2094,6 +2104,7 @@ interface OverlayResponse {
|
|
|
2094
2104
|
id: string;
|
|
2095
2105
|
source: string;
|
|
2096
2106
|
target: string;
|
|
2107
|
+
strategy?: string;
|
|
2097
2108
|
created_at: string;
|
|
2098
2109
|
stats: {
|
|
2099
2110
|
copied_files: number;
|
|
@@ -2166,6 +2177,7 @@ declare class Overlay {
|
|
|
2166
2177
|
* @param options.source - Absolute path to source directory
|
|
2167
2178
|
* @param options.target - Relative path in sandbox
|
|
2168
2179
|
* @param options.ignore - Glob patterns to ignore (e.g., ["node_modules", "*.log"])
|
|
2180
|
+
* @param options.strategy - Strategy to use ('copy' or 'smart')
|
|
2169
2181
|
* @param options.waitForCompletion - If true or options object, wait for background copy to complete
|
|
2170
2182
|
* @returns Overlay info with copy status
|
|
2171
2183
|
*/
|
|
@@ -2205,6 +2217,10 @@ declare class Overlay {
|
|
|
2205
2217
|
* Convert API response to OverlayInfo
|
|
2206
2218
|
*/
|
|
2207
2219
|
private toOverlayInfo;
|
|
2220
|
+
/**
|
|
2221
|
+
* Validate and return strategy, defaulting to 'copy' for unknown/missing values (legacy support)
|
|
2222
|
+
*/
|
|
2223
|
+
private validateStrategy;
|
|
2208
2224
|
/**
|
|
2209
2225
|
* Validate and return copy status, defaulting to 'pending' for unknown values
|
|
2210
2226
|
*/
|
|
@@ -2925,11 +2941,16 @@ declare class Sandbox {
|
|
|
2925
2941
|
private _token;
|
|
2926
2942
|
private _ws;
|
|
2927
2943
|
private WebSocketImpl;
|
|
2944
|
+
private _terminals;
|
|
2928
2945
|
constructor(config: SandboxConfig);
|
|
2929
2946
|
/**
|
|
2930
2947
|
* Get or create internal WebSocket manager
|
|
2931
2948
|
*/
|
|
2932
2949
|
private ensureWebSocket;
|
|
2950
|
+
/**
|
|
2951
|
+
* Create and configure a TerminalInstance from response data
|
|
2952
|
+
*/
|
|
2953
|
+
private hydrateTerminal;
|
|
2933
2954
|
private request;
|
|
2934
2955
|
/**
|
|
2935
2956
|
* Check service health
|
|
@@ -3231,7 +3252,7 @@ declare class Sandbox {
|
|
|
3231
3252
|
/**
|
|
3232
3253
|
* Get terminal by ID
|
|
3233
3254
|
*/
|
|
3234
|
-
getTerminal(id: string): Promise<
|
|
3255
|
+
getTerminal(id: string): Promise<TerminalInstance>;
|
|
3235
3256
|
/**
|
|
3236
3257
|
* List all commands executed in a terminal (exec mode only)
|
|
3237
3258
|
* @param terminalId - The terminal ID
|
|
@@ -3583,6 +3604,7 @@ declare const PROVIDER_AUTH: {
|
|
|
3583
3604
|
readonly e2b: readonly [readonly ["E2B_API_KEY"]];
|
|
3584
3605
|
readonly modal: readonly [readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]];
|
|
3585
3606
|
readonly railway: readonly [readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]];
|
|
3607
|
+
readonly render: readonly [readonly ["RENDER_API_KEY", "RENDER_OWNER_ID"]];
|
|
3586
3608
|
readonly daytona: readonly [readonly ["DAYTONA_API_KEY"]];
|
|
3587
3609
|
readonly vercel: readonly [readonly ["VERCEL_OIDC_TOKEN"], readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]];
|
|
3588
3610
|
readonly runloop: readonly [readonly ["RUNLOOP_API_KEY"]];
|
|
@@ -3677,6 +3699,10 @@ interface ExplicitComputeConfig {
|
|
|
3677
3699
|
projectId?: string;
|
|
3678
3700
|
environmentId?: string;
|
|
3679
3701
|
};
|
|
3702
|
+
render?: {
|
|
3703
|
+
apiKey?: string;
|
|
3704
|
+
serviceId?: string;
|
|
3705
|
+
};
|
|
3680
3706
|
daytona?: {
|
|
3681
3707
|
apiKey?: string;
|
|
3682
3708
|
};
|
|
@@ -3891,7 +3917,7 @@ declare const GATEWAY_URL = "https://gateway.computesdk.com";
|
|
|
3891
3917
|
* Provider detection priority order
|
|
3892
3918
|
* When multiple provider credentials are detected, use the first one in this list
|
|
3893
3919
|
*/
|
|
3894
|
-
declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
|
|
3920
|
+
declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "render", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
|
|
3895
3921
|
/**
|
|
3896
3922
|
* Required environment variables for each provider
|
|
3897
3923
|
* @deprecated Use PROVIDER_AUTH from provider-config instead
|
|
@@ -3899,6 +3925,7 @@ declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal",
|
|
|
3899
3925
|
declare const PROVIDER_ENV_VARS: {
|
|
3900
3926
|
readonly e2b: readonly ["E2B_API_KEY"];
|
|
3901
3927
|
readonly railway: readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"];
|
|
3928
|
+
readonly render: readonly ["RENDER_API_KEY", "RENDER_OWNER_ID"];
|
|
3902
3929
|
readonly daytona: readonly ["DAYTONA_API_KEY"];
|
|
3903
3930
|
readonly modal: readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"];
|
|
3904
3931
|
readonly runloop: readonly ["RUNLOOP_API_KEY"];
|
package/dist/index.js
CHANGED
|
@@ -1365,7 +1365,7 @@ var Terminal = class {
|
|
|
1365
1365
|
/**
|
|
1366
1366
|
* Retrieve a specific terminal by ID
|
|
1367
1367
|
* @param id - The terminal ID
|
|
1368
|
-
* @returns Terminal
|
|
1368
|
+
* @returns Terminal instance
|
|
1369
1369
|
*/
|
|
1370
1370
|
async retrieve(id) {
|
|
1371
1371
|
return this.retrieveHandler(id);
|
|
@@ -1975,6 +1975,7 @@ var Overlay = class {
|
|
|
1975
1975
|
* @param options.source - Absolute path to source directory
|
|
1976
1976
|
* @param options.target - Relative path in sandbox
|
|
1977
1977
|
* @param options.ignore - Glob patterns to ignore (e.g., ["node_modules", "*.log"])
|
|
1978
|
+
* @param options.strategy - Strategy to use ('copy' or 'smart')
|
|
1978
1979
|
* @param options.waitForCompletion - If true or options object, wait for background copy to complete
|
|
1979
1980
|
* @returns Overlay info with copy status
|
|
1980
1981
|
*/
|
|
@@ -2064,6 +2065,7 @@ Try increasing maxRetries or check if the source directory is very large.`
|
|
|
2064
2065
|
id: response.id,
|
|
2065
2066
|
source: response.source,
|
|
2066
2067
|
target: response.target,
|
|
2068
|
+
strategy: this.validateStrategy(response.strategy),
|
|
2067
2069
|
createdAt: response.created_at,
|
|
2068
2070
|
stats: {
|
|
2069
2071
|
copiedFiles: response.stats.copied_files,
|
|
@@ -2074,6 +2076,16 @@ Try increasing maxRetries or check if the source directory is very large.`
|
|
|
2074
2076
|
copyError: response.copy_error
|
|
2075
2077
|
};
|
|
2076
2078
|
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Validate and return strategy, defaulting to 'copy' for unknown/missing values (legacy support)
|
|
2081
|
+
*/
|
|
2082
|
+
validateStrategy(strategy) {
|
|
2083
|
+
const validStrategies = ["copy", "smart"];
|
|
2084
|
+
if (strategy && validStrategies.includes(strategy)) {
|
|
2085
|
+
return strategy;
|
|
2086
|
+
}
|
|
2087
|
+
return "copy";
|
|
2088
|
+
}
|
|
2077
2089
|
/**
|
|
2078
2090
|
* Validate and return copy status, defaulting to 'pending' for unknown values
|
|
2079
2091
|
*/
|
|
@@ -2104,6 +2116,7 @@ var Sandbox = class {
|
|
|
2104
2116
|
constructor(config) {
|
|
2105
2117
|
this._token = null;
|
|
2106
2118
|
this._ws = null;
|
|
2119
|
+
this._terminals = /* @__PURE__ */ new Map();
|
|
2107
2120
|
this.sandboxId = config.sandboxId;
|
|
2108
2121
|
this.provider = config.provider;
|
|
2109
2122
|
let sandboxUrlResolved = config.sandboxUrl;
|
|
@@ -2310,6 +2323,44 @@ var Sandbox = class {
|
|
|
2310
2323
|
}
|
|
2311
2324
|
return this._ws;
|
|
2312
2325
|
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Create and configure a TerminalInstance from response data
|
|
2328
|
+
*/
|
|
2329
|
+
async hydrateTerminal(data, ws) {
|
|
2330
|
+
const terminal = new TerminalInstance(
|
|
2331
|
+
data.id,
|
|
2332
|
+
data.pty,
|
|
2333
|
+
data.status,
|
|
2334
|
+
data.channel || null,
|
|
2335
|
+
ws || null,
|
|
2336
|
+
data.encoding || "raw"
|
|
2337
|
+
);
|
|
2338
|
+
const terminalId = data.id;
|
|
2339
|
+
terminal.setExecuteHandler(async (command, background) => {
|
|
2340
|
+
return this.request(`/terminals/${terminalId}/execute`, {
|
|
2341
|
+
method: "POST",
|
|
2342
|
+
body: JSON.stringify({ command, background })
|
|
2343
|
+
});
|
|
2344
|
+
});
|
|
2345
|
+
terminal.setListCommandsHandler(async () => {
|
|
2346
|
+
return this.request(`/terminals/${terminalId}/commands`);
|
|
2347
|
+
});
|
|
2348
|
+
terminal.setRetrieveCommandHandler(async (cmdId) => {
|
|
2349
|
+
return this.request(`/terminals/${terminalId}/commands/${cmdId}`);
|
|
2350
|
+
});
|
|
2351
|
+
terminal.setWaitCommandHandler(async (cmdId, timeout) => {
|
|
2352
|
+
const params = timeout ? new URLSearchParams({ timeout: timeout.toString() }) : "";
|
|
2353
|
+
const endpoint = `/terminals/${terminalId}/commands/${cmdId}/wait${params ? `?${params}` : ""}`;
|
|
2354
|
+
return this.request(endpoint);
|
|
2355
|
+
});
|
|
2356
|
+
terminal.setDestroyHandler(async () => {
|
|
2357
|
+
await this.request(`/terminals/${terminalId}`, {
|
|
2358
|
+
method: "DELETE"
|
|
2359
|
+
});
|
|
2360
|
+
this._terminals.delete(terminalId);
|
|
2361
|
+
});
|
|
2362
|
+
return terminal;
|
|
2363
|
+
}
|
|
2313
2364
|
// ============================================================================
|
|
2314
2365
|
// Private Helper Methods
|
|
2315
2366
|
// ============================================================================
|
|
@@ -2816,37 +2867,8 @@ API request failed (${response.status}): ${error}`
|
|
|
2816
2867
|
}
|
|
2817
2868
|
});
|
|
2818
2869
|
}
|
|
2819
|
-
const terminal =
|
|
2820
|
-
|
|
2821
|
-
response.data.pty,
|
|
2822
|
-
response.data.status,
|
|
2823
|
-
response.data.channel || null,
|
|
2824
|
-
ws,
|
|
2825
|
-
response.data.encoding || "raw"
|
|
2826
|
-
);
|
|
2827
|
-
const terminalId = response.data.id;
|
|
2828
|
-
terminal.setExecuteHandler(async (command, background) => {
|
|
2829
|
-
return this.request(`/terminals/${terminalId}/execute`, {
|
|
2830
|
-
method: "POST",
|
|
2831
|
-
body: JSON.stringify({ command, background })
|
|
2832
|
-
});
|
|
2833
|
-
});
|
|
2834
|
-
terminal.setListCommandsHandler(async () => {
|
|
2835
|
-
return this.request(`/terminals/${terminalId}/commands`);
|
|
2836
|
-
});
|
|
2837
|
-
terminal.setRetrieveCommandHandler(async (cmdId) => {
|
|
2838
|
-
return this.request(`/terminals/${terminalId}/commands/${cmdId}`);
|
|
2839
|
-
});
|
|
2840
|
-
terminal.setWaitCommandHandler(async (cmdId, timeout) => {
|
|
2841
|
-
const params = timeout ? new URLSearchParams({ timeout: timeout.toString() }) : "";
|
|
2842
|
-
const endpoint = `/terminals/${terminalId}/commands/${cmdId}/wait${params ? `?${params}` : ""}`;
|
|
2843
|
-
return this.request(endpoint);
|
|
2844
|
-
});
|
|
2845
|
-
terminal.setDestroyHandler(async () => {
|
|
2846
|
-
await this.request(`/terminals/${terminalId}`, {
|
|
2847
|
-
method: "DELETE"
|
|
2848
|
-
});
|
|
2849
|
-
});
|
|
2870
|
+
const terminal = await this.hydrateTerminal(response.data, ws);
|
|
2871
|
+
this._terminals.set(terminal.id, terminal);
|
|
2850
2872
|
return terminal;
|
|
2851
2873
|
}
|
|
2852
2874
|
/**
|
|
@@ -2860,7 +2882,18 @@ API request failed (${response.status}): ${error}`
|
|
|
2860
2882
|
* Get terminal by ID
|
|
2861
2883
|
*/
|
|
2862
2884
|
async getTerminal(id) {
|
|
2863
|
-
|
|
2885
|
+
const cached = this._terminals.get(id);
|
|
2886
|
+
if (cached) {
|
|
2887
|
+
return cached;
|
|
2888
|
+
}
|
|
2889
|
+
const response = await this.request(`/terminals/${id}`);
|
|
2890
|
+
let ws = null;
|
|
2891
|
+
if (response.data.pty) {
|
|
2892
|
+
ws = await this.ensureWebSocket();
|
|
2893
|
+
}
|
|
2894
|
+
const terminal = await this.hydrateTerminal(response.data, ws);
|
|
2895
|
+
this._terminals.set(id, terminal);
|
|
2896
|
+
return terminal;
|
|
2864
2897
|
}
|
|
2865
2898
|
// ============================================================================
|
|
2866
2899
|
// Command Tracking (Exec Mode Terminals)
|
|
@@ -3464,6 +3497,7 @@ API request failed (${response.status}): ${error}`
|
|
|
3464
3497
|
this._ws.disconnect();
|
|
3465
3498
|
this._ws = null;
|
|
3466
3499
|
}
|
|
3500
|
+
this._terminals.clear();
|
|
3467
3501
|
}
|
|
3468
3502
|
};
|
|
3469
3503
|
|
|
@@ -3472,6 +3506,7 @@ var PROVIDER_AUTH = {
|
|
|
3472
3506
|
e2b: [["E2B_API_KEY"]],
|
|
3473
3507
|
modal: [["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]],
|
|
3474
3508
|
railway: [["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]],
|
|
3509
|
+
render: [["RENDER_API_KEY", "RENDER_OWNER_ID"]],
|
|
3475
3510
|
daytona: [["DAYTONA_API_KEY"]],
|
|
3476
3511
|
vercel: [
|
|
3477
3512
|
["VERCEL_OIDC_TOKEN"],
|
|
@@ -3496,6 +3531,10 @@ var PROVIDER_HEADERS = {
|
|
|
3496
3531
|
projectId: "X-Railway-Project-ID",
|
|
3497
3532
|
environmentId: "X-Railway-Environment-ID"
|
|
3498
3533
|
},
|
|
3534
|
+
render: {
|
|
3535
|
+
apiKey: "X-Render-API-Key",
|
|
3536
|
+
ownerId: "X-Render-Owner-ID"
|
|
3537
|
+
},
|
|
3499
3538
|
daytona: {
|
|
3500
3539
|
apiKey: "X-Daytona-API-Key"
|
|
3501
3540
|
},
|
|
@@ -3533,6 +3572,10 @@ var PROVIDER_ENV_MAP = {
|
|
|
3533
3572
|
RAILWAY_PROJECT_ID: "projectId",
|
|
3534
3573
|
RAILWAY_ENVIRONMENT_ID: "environmentId"
|
|
3535
3574
|
},
|
|
3575
|
+
render: {
|
|
3576
|
+
RENDER_API_KEY: "apiKey",
|
|
3577
|
+
RENDER_OWNER_ID: "ownerId"
|
|
3578
|
+
},
|
|
3536
3579
|
daytona: {
|
|
3537
3580
|
DAYTONA_API_KEY: "apiKey"
|
|
3538
3581
|
},
|
|
@@ -3561,6 +3604,7 @@ var PROVIDER_DASHBOARD_URLS = {
|
|
|
3561
3604
|
e2b: "https://e2b.dev/dashboard",
|
|
3562
3605
|
modal: "https://modal.com/settings",
|
|
3563
3606
|
railway: "https://railway.app/account/tokens",
|
|
3607
|
+
render: "https://dashboard.render.com/account",
|
|
3564
3608
|
daytona: "https://daytona.io/dashboard",
|
|
3565
3609
|
vercel: "https://vercel.com/account/tokens",
|
|
3566
3610
|
runloop: "https://runloop.ai/dashboard",
|
|
@@ -3627,6 +3671,7 @@ var GATEWAY_URL = "https://gateway.computesdk.com";
|
|
|
3627
3671
|
var PROVIDER_PRIORITY = [
|
|
3628
3672
|
"e2b",
|
|
3629
3673
|
"railway",
|
|
3674
|
+
"render",
|
|
3630
3675
|
"daytona",
|
|
3631
3676
|
"modal",
|
|
3632
3677
|
"runloop",
|
|
@@ -3638,6 +3683,7 @@ var PROVIDER_PRIORITY = [
|
|
|
3638
3683
|
var PROVIDER_ENV_VARS = {
|
|
3639
3684
|
e2b: ["E2B_API_KEY"],
|
|
3640
3685
|
railway: ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"],
|
|
3686
|
+
render: ["RENDER_API_KEY", "RENDER_OWNER_ID"],
|
|
3641
3687
|
daytona: ["DAYTONA_API_KEY"],
|
|
3642
3688
|
modal: ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"],
|
|
3643
3689
|
runloop: ["RUNLOOP_API_KEY"],
|