computesdk 2.5.0 → 2.5.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 +46 -3
- package/dist/index.d.ts +46 -3
- package/dist/index.js +69 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -89,6 +89,19 @@ interface RunCommandOptions {
|
|
|
89
89
|
timeout?: number;
|
|
90
90
|
background?: boolean;
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Snapshot information
|
|
94
|
+
*/
|
|
95
|
+
interface Snapshot {
|
|
96
|
+
/** Unique identifier for the snapshot */
|
|
97
|
+
id: string;
|
|
98
|
+
/** Provider hosting the snapshot */
|
|
99
|
+
provider: string;
|
|
100
|
+
/** When the snapshot was created */
|
|
101
|
+
createdAt: Date;
|
|
102
|
+
/** Additional provider-specific metadata */
|
|
103
|
+
metadata?: Record<string, any>;
|
|
104
|
+
}
|
|
92
105
|
/**
|
|
93
106
|
* Filesystem operations interface
|
|
94
107
|
*/
|
|
@@ -3833,7 +3846,7 @@ declare const PROVIDER_AUTH: {
|
|
|
3833
3846
|
readonly daytona: readonly [readonly ["DAYTONA_API_KEY"]];
|
|
3834
3847
|
readonly vercel: readonly [readonly ["VERCEL_OIDC_TOKEN"], readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]];
|
|
3835
3848
|
readonly runloop: readonly [readonly ["RUNLOOP_API_KEY"]];
|
|
3836
|
-
readonly cloudflare: readonly [readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]];
|
|
3849
|
+
readonly cloudflare: readonly [readonly ["CLOUDFLARE_SANDBOX_URL", "CLOUDFLARE_SANDBOX_SECRET"], readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]];
|
|
3837
3850
|
readonly codesandbox: readonly [readonly ["CSB_API_KEY"]];
|
|
3838
3851
|
readonly blaxel: readonly [readonly ["BL_API_KEY", "BL_WORKSPACE"]];
|
|
3839
3852
|
readonly namespace: readonly [readonly ["NSC_TOKEN"], readonly ["NSC_TOKEN_FILE"]];
|
|
@@ -4101,6 +4114,36 @@ declare class ComputeManager {
|
|
|
4101
4114
|
*/
|
|
4102
4115
|
extendTimeout: (sandboxId: string, options?: ExtendTimeoutOptions) => Promise<void>;
|
|
4103
4116
|
};
|
|
4117
|
+
snapshot: {
|
|
4118
|
+
/**
|
|
4119
|
+
* Create a snapshot from a running sandbox
|
|
4120
|
+
*
|
|
4121
|
+
* @param sandboxId ID of the sandbox to snapshot
|
|
4122
|
+
* @param options Snapshot options (name, metadata)
|
|
4123
|
+
*/
|
|
4124
|
+
create: (sandboxId: string, options?: {
|
|
4125
|
+
name?: string;
|
|
4126
|
+
metadata?: Record<string, any>;
|
|
4127
|
+
}) => Promise<{
|
|
4128
|
+
id: string;
|
|
4129
|
+
provider: string;
|
|
4130
|
+
createdAt: Date;
|
|
4131
|
+
metadata?: Record<string, any>;
|
|
4132
|
+
}>;
|
|
4133
|
+
/**
|
|
4134
|
+
* List all snapshots
|
|
4135
|
+
*/
|
|
4136
|
+
list: () => Promise<Array<{
|
|
4137
|
+
id: string;
|
|
4138
|
+
provider: string;
|
|
4139
|
+
createdAt: Date;
|
|
4140
|
+
metadata?: Record<string, any>;
|
|
4141
|
+
}>>;
|
|
4142
|
+
/**
|
|
4143
|
+
* Delete a snapshot
|
|
4144
|
+
*/
|
|
4145
|
+
delete: (snapshotId: string) => Promise<void>;
|
|
4146
|
+
};
|
|
4104
4147
|
}
|
|
4105
4148
|
/**
|
|
4106
4149
|
* Callable compute interface - dual nature as both singleton and factory
|
|
@@ -4190,7 +4233,7 @@ declare function autoConfigureCompute(): GatewayConfig | null;
|
|
|
4190
4233
|
/**
|
|
4191
4234
|
* Default gateway URL for sandbox lifecycle operations
|
|
4192
4235
|
*/
|
|
4193
|
-
declare const
|
|
4236
|
+
declare const TRIBUTARY_URL = "https://tributary.edge.computesdk.com";
|
|
4194
4237
|
/**
|
|
4195
4238
|
* Provider detection priority order
|
|
4196
4239
|
* When multiple provider credentials are detected, use the first one in this list
|
|
@@ -4218,4 +4261,4 @@ declare const PROVIDER_ENV_VARS: {
|
|
|
4218
4261
|
readonly 'just-bash': readonly [];
|
|
4219
4262
|
};
|
|
4220
4263
|
|
|
4221
|
-
export { type CallableCompute, type CodeResult$1 as CodeResult, CommandExitError, type CommandResult$1 as CommandResult, type CreateSandboxOptions$1 as CreateSandboxOptions, type ExplicitComputeConfig, type FileEntry, FileWatcher,
|
|
4264
|
+
export { type CallableCompute, type CodeResult$1 as CodeResult, CommandExitError, type CommandResult$1 as CommandResult, type CreateSandboxOptions$1 as CreateSandboxOptions, type ExplicitComputeConfig, type FileEntry, FileWatcher, Sandbox as GatewaySandbox, MessageType, PROVIDER_AUTH, PROVIDER_DASHBOARD_URLS, PROVIDER_ENV_MAP, PROVIDER_ENV_VARS, PROVIDER_HEADERS, PROVIDER_NAMES, PROVIDER_PRIORITY, type ProviderName, type ProviderSandboxInfo, type RunCommandOptions, type Runtime, Sandbox, type SandboxFileSystem, type SandboxInfo$1 as SandboxInfo, type Sandbox$1 as SandboxInterface, type SandboxStatus, type SetupOverlayConfig, type SetupPayload, SignalService, type Snapshot, TRIBUTARY_URL, TerminalInstance, type WebSocketConstructor, autoConfigureCompute, buildProviderHeaders, buildSetupPayload, compute, decodeBinaryMessage, detectProvider, encodeBinaryMessage, encodeSetupPayload, getMissingEnvVars, getProviderConfigFromEnv, getProviderHeaders, isCommandExitError, isGatewayModeEnabled, isProviderAuthComplete, isValidProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,19 @@ interface RunCommandOptions {
|
|
|
89
89
|
timeout?: number;
|
|
90
90
|
background?: boolean;
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Snapshot information
|
|
94
|
+
*/
|
|
95
|
+
interface Snapshot {
|
|
96
|
+
/** Unique identifier for the snapshot */
|
|
97
|
+
id: string;
|
|
98
|
+
/** Provider hosting the snapshot */
|
|
99
|
+
provider: string;
|
|
100
|
+
/** When the snapshot was created */
|
|
101
|
+
createdAt: Date;
|
|
102
|
+
/** Additional provider-specific metadata */
|
|
103
|
+
metadata?: Record<string, any>;
|
|
104
|
+
}
|
|
92
105
|
/**
|
|
93
106
|
* Filesystem operations interface
|
|
94
107
|
*/
|
|
@@ -3833,7 +3846,7 @@ declare const PROVIDER_AUTH: {
|
|
|
3833
3846
|
readonly daytona: readonly [readonly ["DAYTONA_API_KEY"]];
|
|
3834
3847
|
readonly vercel: readonly [readonly ["VERCEL_OIDC_TOKEN"], readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]];
|
|
3835
3848
|
readonly runloop: readonly [readonly ["RUNLOOP_API_KEY"]];
|
|
3836
|
-
readonly cloudflare: readonly [readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]];
|
|
3849
|
+
readonly cloudflare: readonly [readonly ["CLOUDFLARE_SANDBOX_URL", "CLOUDFLARE_SANDBOX_SECRET"], readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]];
|
|
3837
3850
|
readonly codesandbox: readonly [readonly ["CSB_API_KEY"]];
|
|
3838
3851
|
readonly blaxel: readonly [readonly ["BL_API_KEY", "BL_WORKSPACE"]];
|
|
3839
3852
|
readonly namespace: readonly [readonly ["NSC_TOKEN"], readonly ["NSC_TOKEN_FILE"]];
|
|
@@ -4101,6 +4114,36 @@ declare class ComputeManager {
|
|
|
4101
4114
|
*/
|
|
4102
4115
|
extendTimeout: (sandboxId: string, options?: ExtendTimeoutOptions) => Promise<void>;
|
|
4103
4116
|
};
|
|
4117
|
+
snapshot: {
|
|
4118
|
+
/**
|
|
4119
|
+
* Create a snapshot from a running sandbox
|
|
4120
|
+
*
|
|
4121
|
+
* @param sandboxId ID of the sandbox to snapshot
|
|
4122
|
+
* @param options Snapshot options (name, metadata)
|
|
4123
|
+
*/
|
|
4124
|
+
create: (sandboxId: string, options?: {
|
|
4125
|
+
name?: string;
|
|
4126
|
+
metadata?: Record<string, any>;
|
|
4127
|
+
}) => Promise<{
|
|
4128
|
+
id: string;
|
|
4129
|
+
provider: string;
|
|
4130
|
+
createdAt: Date;
|
|
4131
|
+
metadata?: Record<string, any>;
|
|
4132
|
+
}>;
|
|
4133
|
+
/**
|
|
4134
|
+
* List all snapshots
|
|
4135
|
+
*/
|
|
4136
|
+
list: () => Promise<Array<{
|
|
4137
|
+
id: string;
|
|
4138
|
+
provider: string;
|
|
4139
|
+
createdAt: Date;
|
|
4140
|
+
metadata?: Record<string, any>;
|
|
4141
|
+
}>>;
|
|
4142
|
+
/**
|
|
4143
|
+
* Delete a snapshot
|
|
4144
|
+
*/
|
|
4145
|
+
delete: (snapshotId: string) => Promise<void>;
|
|
4146
|
+
};
|
|
4104
4147
|
}
|
|
4105
4148
|
/**
|
|
4106
4149
|
* Callable compute interface - dual nature as both singleton and factory
|
|
@@ -4190,7 +4233,7 @@ declare function autoConfigureCompute(): GatewayConfig | null;
|
|
|
4190
4233
|
/**
|
|
4191
4234
|
* Default gateway URL for sandbox lifecycle operations
|
|
4192
4235
|
*/
|
|
4193
|
-
declare const
|
|
4236
|
+
declare const TRIBUTARY_URL = "https://tributary.edge.computesdk.com";
|
|
4194
4237
|
/**
|
|
4195
4238
|
* Provider detection priority order
|
|
4196
4239
|
* When multiple provider credentials are detected, use the first one in this list
|
|
@@ -4218,4 +4261,4 @@ declare const PROVIDER_ENV_VARS: {
|
|
|
4218
4261
|
readonly 'just-bash': readonly [];
|
|
4219
4262
|
};
|
|
4220
4263
|
|
|
4221
|
-
export { type CallableCompute, type CodeResult$1 as CodeResult, CommandExitError, type CommandResult$1 as CommandResult, type CreateSandboxOptions$1 as CreateSandboxOptions, type ExplicitComputeConfig, type FileEntry, FileWatcher,
|
|
4264
|
+
export { type CallableCompute, type CodeResult$1 as CodeResult, CommandExitError, type CommandResult$1 as CommandResult, type CreateSandboxOptions$1 as CreateSandboxOptions, type ExplicitComputeConfig, type FileEntry, FileWatcher, Sandbox as GatewaySandbox, MessageType, PROVIDER_AUTH, PROVIDER_DASHBOARD_URLS, PROVIDER_ENV_MAP, PROVIDER_ENV_VARS, PROVIDER_HEADERS, PROVIDER_NAMES, PROVIDER_PRIORITY, type ProviderName, type ProviderSandboxInfo, type RunCommandOptions, type Runtime, Sandbox, type SandboxFileSystem, type SandboxInfo$1 as SandboxInfo, type Sandbox$1 as SandboxInterface, type SandboxStatus, type SetupOverlayConfig, type SetupPayload, SignalService, type Snapshot, TRIBUTARY_URL, TerminalInstance, type WebSocketConstructor, autoConfigureCompute, buildProviderHeaders, buildSetupPayload, compute, decodeBinaryMessage, detectProvider, encodeBinaryMessage, encodeSetupPayload, getMissingEnvVars, getProviderConfigFromEnv, getProviderHeaders, isCommandExitError, isGatewayModeEnabled, isProviderAuthComplete, isValidProvider };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
CommandExitError: () => CommandExitError,
|
|
24
24
|
FileWatcher: () => FileWatcher,
|
|
25
|
-
GATEWAY_URL: () => GATEWAY_URL,
|
|
26
25
|
GatewaySandbox: () => Sandbox,
|
|
27
26
|
MessageType: () => MessageType,
|
|
28
27
|
PROVIDER_AUTH: () => PROVIDER_AUTH,
|
|
@@ -34,6 +33,7 @@ __export(index_exports, {
|
|
|
34
33
|
PROVIDER_PRIORITY: () => PROVIDER_PRIORITY,
|
|
35
34
|
Sandbox: () => Sandbox,
|
|
36
35
|
SignalService: () => SignalService,
|
|
36
|
+
TRIBUTARY_URL: () => TRIBUTARY_URL,
|
|
37
37
|
TerminalInstance: () => TerminalInstance,
|
|
38
38
|
autoConfigureCompute: () => autoConfigureCompute,
|
|
39
39
|
buildProviderHeaders: () => buildProviderHeaders,
|
|
@@ -3641,7 +3641,10 @@ var PROVIDER_AUTH = {
|
|
|
3641
3641
|
["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]
|
|
3642
3642
|
],
|
|
3643
3643
|
runloop: [["RUNLOOP_API_KEY"]],
|
|
3644
|
-
cloudflare: [
|
|
3644
|
+
cloudflare: [
|
|
3645
|
+
["CLOUDFLARE_SANDBOX_URL", "CLOUDFLARE_SANDBOX_SECRET"],
|
|
3646
|
+
["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]
|
|
3647
|
+
],
|
|
3645
3648
|
codesandbox: [["CSB_API_KEY"]],
|
|
3646
3649
|
blaxel: [["BL_API_KEY", "BL_WORKSPACE"]],
|
|
3647
3650
|
namespace: [["NSC_TOKEN"], ["NSC_TOKEN_FILE"]],
|
|
@@ -3681,6 +3684,8 @@ var PROVIDER_HEADERS = {
|
|
|
3681
3684
|
apiKey: "X-Runloop-API-Key"
|
|
3682
3685
|
},
|
|
3683
3686
|
cloudflare: {
|
|
3687
|
+
sandboxUrl: "X-Cloudflare-Sandbox-Url",
|
|
3688
|
+
sandboxSecret: "X-Cloudflare-Sandbox-Secret",
|
|
3684
3689
|
apiToken: "X-Cloudflare-API-Token",
|
|
3685
3690
|
accountId: "X-Cloudflare-Account-Id"
|
|
3686
3691
|
},
|
|
@@ -3736,6 +3741,8 @@ var PROVIDER_ENV_MAP = {
|
|
|
3736
3741
|
RUNLOOP_API_KEY: "apiKey"
|
|
3737
3742
|
},
|
|
3738
3743
|
cloudflare: {
|
|
3744
|
+
CLOUDFLARE_SANDBOX_URL: "sandboxUrl",
|
|
3745
|
+
CLOUDFLARE_SANDBOX_SECRET: "sandboxSecret",
|
|
3739
3746
|
CLOUDFLARE_API_TOKEN: "apiToken",
|
|
3740
3747
|
CLOUDFLARE_ACCOUNT_ID: "accountId"
|
|
3741
3748
|
},
|
|
@@ -3834,7 +3841,7 @@ function getMissingEnvVars(provider) {
|
|
|
3834
3841
|
}
|
|
3835
3842
|
|
|
3836
3843
|
// src/constants.ts
|
|
3837
|
-
var
|
|
3844
|
+
var TRIBUTARY_URL = "https://tributary.edge.computesdk.com";
|
|
3838
3845
|
var PROVIDER_PRIORITY = [
|
|
3839
3846
|
"e2b",
|
|
3840
3847
|
"railway",
|
|
@@ -4065,7 +4072,7 @@ Or set COMPUTESDK_PROVIDER to specify explicitly:
|
|
|
4065
4072
|
Docs: https://computesdk.com/docs/quickstart`
|
|
4066
4073
|
);
|
|
4067
4074
|
}
|
|
4068
|
-
const gatewayUrl = process.env.
|
|
4075
|
+
const gatewayUrl = process.env.COMPUTESDK_TRIBUTARY_URL || TRIBUTARY_URL;
|
|
4069
4076
|
const computesdkApiKey = process.env.COMPUTESDK_API_KEY;
|
|
4070
4077
|
const providerHeaders = getProviderHeaders(provider);
|
|
4071
4078
|
try {
|
|
@@ -4075,7 +4082,7 @@ Docs: https://computesdk.com/docs/quickstart`
|
|
|
4075
4082
|
`Invalid gateway URL: "${gatewayUrl}"
|
|
4076
4083
|
|
|
4077
4084
|
The URL must be a valid HTTP/HTTPS URL.
|
|
4078
|
-
Check your
|
|
4085
|
+
Check your COMPUTESDK_TRIBUTARY_URL environment variable.`
|
|
4079
4086
|
);
|
|
4080
4087
|
}
|
|
4081
4088
|
if (process.env.COMPUTESDK_DEBUG) {
|
|
@@ -4171,7 +4178,7 @@ Get your API key at: https://computesdk.com/dashboard`
|
|
|
4171
4178
|
const providerHeaders = buildProviderHeaders2(config);
|
|
4172
4179
|
return {
|
|
4173
4180
|
apiKey: computesdkApiKey,
|
|
4174
|
-
gatewayUrl: config.gatewayUrl || process.env.
|
|
4181
|
+
gatewayUrl: config.gatewayUrl || process.env.COMPUTESDK_TRIBUTARY_URL || TRIBUTARY_URL,
|
|
4175
4182
|
provider: config.provider,
|
|
4176
4183
|
providerHeaders,
|
|
4177
4184
|
requestTimeoutMs: config.requestTimeoutMs,
|
|
@@ -4221,7 +4228,7 @@ Troubleshooting:
|
|
|
4221
4228
|
}
|
|
4222
4229
|
|
|
4223
4230
|
// src/compute.ts
|
|
4224
|
-
async function
|
|
4231
|
+
async function tributaryFetch(url, config, options = {}) {
|
|
4225
4232
|
const timeout = config.requestTimeoutMs ?? 3e4;
|
|
4226
4233
|
const controller = new AbortController();
|
|
4227
4234
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
@@ -4268,7 +4275,7 @@ async function waitForSandboxStatus(config, endpoint, body, options = {}) {
|
|
|
4268
4275
|
const startTime = Date.now();
|
|
4269
4276
|
let currentDelay = initialDelayMs;
|
|
4270
4277
|
while (Date.now() - startTime < maxWaitMs) {
|
|
4271
|
-
const result = await
|
|
4278
|
+
const result = await tributaryFetch(endpoint, config, {
|
|
4272
4279
|
method: "POST",
|
|
4273
4280
|
body: JSON.stringify(body)
|
|
4274
4281
|
});
|
|
@@ -4319,7 +4326,7 @@ var ComputeManager = class {
|
|
|
4319
4326
|
*/
|
|
4320
4327
|
create: async (options) => {
|
|
4321
4328
|
const config = this.getGatewayConfig();
|
|
4322
|
-
const result = await
|
|
4329
|
+
const result = await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes`, config, {
|
|
4323
4330
|
method: "POST",
|
|
4324
4331
|
body: JSON.stringify(options || {})
|
|
4325
4332
|
});
|
|
@@ -4341,7 +4348,7 @@ var ComputeManager = class {
|
|
|
4341
4348
|
},
|
|
4342
4349
|
WebSocket: config.WebSocket || globalThis.WebSocket,
|
|
4343
4350
|
destroyHandler: async () => {
|
|
4344
|
-
await
|
|
4351
|
+
await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes/${sandboxId}`, config, {
|
|
4345
4352
|
method: "DELETE"
|
|
4346
4353
|
});
|
|
4347
4354
|
}
|
|
@@ -4354,7 +4361,7 @@ var ComputeManager = class {
|
|
|
4354
4361
|
*/
|
|
4355
4362
|
getById: async (sandboxId) => {
|
|
4356
4363
|
const config = this.getGatewayConfig();
|
|
4357
|
-
const result = await
|
|
4364
|
+
const result = await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes/${sandboxId}`, config);
|
|
4358
4365
|
if (!result.success || !result.data) {
|
|
4359
4366
|
return null;
|
|
4360
4367
|
}
|
|
@@ -4367,7 +4374,7 @@ var ComputeManager = class {
|
|
|
4367
4374
|
metadata,
|
|
4368
4375
|
WebSocket: config.WebSocket || globalThis.WebSocket,
|
|
4369
4376
|
destroyHandler: async () => {
|
|
4370
|
-
await
|
|
4377
|
+
await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes/${sandboxId}`, config, {
|
|
4371
4378
|
method: "DELETE"
|
|
4372
4379
|
});
|
|
4373
4380
|
}
|
|
@@ -4388,7 +4395,7 @@ var ComputeManager = class {
|
|
|
4388
4395
|
*/
|
|
4389
4396
|
destroy: async (sandboxId) => {
|
|
4390
4397
|
const config = this.getGatewayConfig();
|
|
4391
|
-
await
|
|
4398
|
+
await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes/${sandboxId}`, config, {
|
|
4392
4399
|
method: "DELETE"
|
|
4393
4400
|
});
|
|
4394
4401
|
},
|
|
@@ -4423,7 +4430,7 @@ var ComputeManager = class {
|
|
|
4423
4430
|
},
|
|
4424
4431
|
WebSocket: config.WebSocket || globalThis.WebSocket,
|
|
4425
4432
|
destroyHandler: async () => {
|
|
4426
|
-
await
|
|
4433
|
+
await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes/${sandboxId}`, config, {
|
|
4427
4434
|
method: "DELETE"
|
|
4428
4435
|
});
|
|
4429
4436
|
}
|
|
@@ -4460,7 +4467,7 @@ var ComputeManager = class {
|
|
|
4460
4467
|
},
|
|
4461
4468
|
WebSocket: config.WebSocket || globalThis.WebSocket,
|
|
4462
4469
|
destroyHandler: async () => {
|
|
4463
|
-
await
|
|
4470
|
+
await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes/${sandboxId}`, config, {
|
|
4464
4471
|
method: "DELETE"
|
|
4465
4472
|
});
|
|
4466
4473
|
}
|
|
@@ -4474,12 +4481,57 @@ var ComputeManager = class {
|
|
|
4474
4481
|
extendTimeout: async (sandboxId, options) => {
|
|
4475
4482
|
const config = this.getGatewayConfig();
|
|
4476
4483
|
const duration = options?.duration ?? 9e5;
|
|
4477
|
-
await
|
|
4484
|
+
await tributaryFetch(`${config.gatewayUrl}/v1/sandboxes/${sandboxId}/extend`, config, {
|
|
4478
4485
|
method: "POST",
|
|
4479
4486
|
body: JSON.stringify({ duration })
|
|
4480
4487
|
});
|
|
4481
4488
|
}
|
|
4482
4489
|
};
|
|
4490
|
+
this.snapshot = {
|
|
4491
|
+
/**
|
|
4492
|
+
* Create a snapshot from a running sandbox
|
|
4493
|
+
*
|
|
4494
|
+
* @param sandboxId ID of the sandbox to snapshot
|
|
4495
|
+
* @param options Snapshot options (name, metadata)
|
|
4496
|
+
*/
|
|
4497
|
+
create: async (sandboxId, options) => {
|
|
4498
|
+
const config = this.getGatewayConfig();
|
|
4499
|
+
const result = await tributaryFetch(`${config.gatewayUrl}/v1/snapshots`, config, {
|
|
4500
|
+
method: "POST",
|
|
4501
|
+
body: JSON.stringify({ sandboxId, ...options })
|
|
4502
|
+
});
|
|
4503
|
+
if (!result.success || !result.data) {
|
|
4504
|
+
throw new Error(`Gateway returned invalid response`);
|
|
4505
|
+
}
|
|
4506
|
+
return {
|
|
4507
|
+
...result.data,
|
|
4508
|
+
createdAt: new Date(result.data.createdAt)
|
|
4509
|
+
};
|
|
4510
|
+
},
|
|
4511
|
+
/**
|
|
4512
|
+
* List all snapshots
|
|
4513
|
+
*/
|
|
4514
|
+
list: async () => {
|
|
4515
|
+
const config = this.getGatewayConfig();
|
|
4516
|
+
const result = await tributaryFetch(`${config.gatewayUrl}/v1/snapshots`, config);
|
|
4517
|
+
if (!result.success || !result.data) {
|
|
4518
|
+
return [];
|
|
4519
|
+
}
|
|
4520
|
+
return result.data.map((s) => ({
|
|
4521
|
+
...s,
|
|
4522
|
+
createdAt: new Date(s.createdAt)
|
|
4523
|
+
}));
|
|
4524
|
+
},
|
|
4525
|
+
/**
|
|
4526
|
+
* Delete a snapshot
|
|
4527
|
+
*/
|
|
4528
|
+
delete: async (snapshotId) => {
|
|
4529
|
+
const config = this.getGatewayConfig();
|
|
4530
|
+
await tributaryFetch(`${config.gatewayUrl}/v1/snapshots/${snapshotId}`, config, {
|
|
4531
|
+
method: "DELETE"
|
|
4532
|
+
});
|
|
4533
|
+
}
|
|
4534
|
+
};
|
|
4483
4535
|
}
|
|
4484
4536
|
/**
|
|
4485
4537
|
* Lazy auto-configure from environment if not explicitly configured
|
|
@@ -4561,7 +4613,6 @@ var compute = new Proxy(
|
|
|
4561
4613
|
0 && (module.exports = {
|
|
4562
4614
|
CommandExitError,
|
|
4563
4615
|
FileWatcher,
|
|
4564
|
-
GATEWAY_URL,
|
|
4565
4616
|
GatewaySandbox,
|
|
4566
4617
|
MessageType,
|
|
4567
4618
|
PROVIDER_AUTH,
|
|
@@ -4573,6 +4624,7 @@ var compute = new Proxy(
|
|
|
4573
4624
|
PROVIDER_PRIORITY,
|
|
4574
4625
|
Sandbox,
|
|
4575
4626
|
SignalService,
|
|
4627
|
+
TRIBUTARY_URL,
|
|
4576
4628
|
TerminalInstance,
|
|
4577
4629
|
autoConfigureCompute,
|
|
4578
4630
|
buildProviderHeaders,
|