@computesdk/vercel 1.7.46 → 1.7.48
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _computesdk_provider from '@computesdk/provider';
|
|
2
|
+
import * as computesdk from 'computesdk';
|
|
2
3
|
import { Sandbox } from '@vercel/sandbox';
|
|
3
4
|
export { Sandbox as VercelSandbox, Snapshot as VercelSnapshot } from '@vercel/sandbox';
|
|
4
5
|
|
|
@@ -10,6 +11,6 @@ interface VercelConfig {
|
|
|
10
11
|
ports?: number[];
|
|
11
12
|
daemonSsePort?: number | false;
|
|
12
13
|
}
|
|
13
|
-
declare const vercel: (config: VercelConfig) => _computesdk_provider.Provider<Sandbox, any, any>;
|
|
14
|
+
declare const vercel: (config: VercelConfig) => _computesdk_provider.Provider<Sandbox, any, any, computesdk.Volume>;
|
|
14
15
|
|
|
15
16
|
export { type VercelConfig, vercel };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _computesdk_provider from '@computesdk/provider';
|
|
2
|
+
import * as computesdk from 'computesdk';
|
|
2
3
|
import { Sandbox } from '@vercel/sandbox';
|
|
3
4
|
export { Sandbox as VercelSandbox, Snapshot as VercelSnapshot } from '@vercel/sandbox';
|
|
4
5
|
|
|
@@ -10,6 +11,6 @@ interface VercelConfig {
|
|
|
10
11
|
ports?: number[];
|
|
11
12
|
daemonSsePort?: number | false;
|
|
12
13
|
}
|
|
13
|
-
declare const vercel: (config: VercelConfig) => _computesdk_provider.Provider<Sandbox, any, any>;
|
|
14
|
+
declare const vercel: (config: VercelConfig) => _computesdk_provider.Provider<Sandbox, any, any, computesdk.Volume>;
|
|
14
15
|
|
|
15
16
|
export { type VercelConfig, vercel };
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ var vercel = (0, import_provider.defineProvider)({
|
|
|
83
83
|
sandboxId: _sandboxId,
|
|
84
84
|
namespace: _namespace,
|
|
85
85
|
directory: _directory,
|
|
86
|
+
volumes,
|
|
86
87
|
...providerOptions
|
|
87
88
|
} = options || {};
|
|
88
89
|
const optRuntime = options?.runtime;
|
|
@@ -102,6 +103,12 @@ var vercel = (0, import_provider.defineProvider)({
|
|
|
102
103
|
} else if (optSource) {
|
|
103
104
|
params.source = optSource;
|
|
104
105
|
}
|
|
106
|
+
if (Array.isArray(volumes) && volumes.length > 0) {
|
|
107
|
+
params.mounts = Object.fromEntries(volumes.map((m) => {
|
|
108
|
+
const ref = (0, import_provider.resolveVolumeRef)(m.volume);
|
|
109
|
+
return [m.mountPath, { drive: ref.name ?? ref.id, mode: m.readOnly ? "snapshot" : "read-write" }];
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
105
112
|
if (!creds.useOidc) {
|
|
106
113
|
params.token = creds.token;
|
|
107
114
|
params.teamId = creds.teamId;
|
|
@@ -249,6 +256,44 @@ var vercel = (0, import_provider.defineProvider)({
|
|
|
249
256
|
const snapshot = creds.useOidc ? await import_sandbox.Snapshot.get({ snapshotId: templateId }) : await import_sandbox.Snapshot.get({ snapshotId: templateId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });
|
|
250
257
|
await snapshot.delete();
|
|
251
258
|
}
|
|
259
|
+
},
|
|
260
|
+
volume: {
|
|
261
|
+
create: async (config, options) => {
|
|
262
|
+
const creds = resolveCredentials(config);
|
|
263
|
+
validateCredentials(creds);
|
|
264
|
+
const params = creds.useOidc ? { name: options.name } : { name: options.name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
265
|
+
const drive = await import_sandbox.Drive.getOrCreate(params);
|
|
266
|
+
return { id: drive.driveId, name: drive.name, native: drive };
|
|
267
|
+
},
|
|
268
|
+
get: async (config, name) => {
|
|
269
|
+
const creds = resolveCredentials(config);
|
|
270
|
+
validateCredentials(creds);
|
|
271
|
+
try {
|
|
272
|
+
const params = creds.useOidc ? { name } : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
273
|
+
const drive = await import_sandbox.Drive.get(params);
|
|
274
|
+
return { id: drive.driveId, name: drive.name, native: drive };
|
|
275
|
+
} catch {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
list: async (config) => {
|
|
280
|
+
const creds = resolveCredentials(config);
|
|
281
|
+
validateCredentials(creds);
|
|
282
|
+
const params = creds.useOidc ? {} : { token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
283
|
+
const page = await import_sandbox.Drive.list(params);
|
|
284
|
+
const out = [];
|
|
285
|
+
for await (const drive of page) {
|
|
286
|
+
out.push({ id: drive.driveId, name: drive.name, native: drive });
|
|
287
|
+
}
|
|
288
|
+
return out;
|
|
289
|
+
},
|
|
290
|
+
delete: async (config, name) => {
|
|
291
|
+
const creds = resolveCredentials(config);
|
|
292
|
+
validateCredentials(creds);
|
|
293
|
+
const params = creds.useOidc ? { name } : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
294
|
+
const drive = await import_sandbox.Drive.get(params);
|
|
295
|
+
await (0, import_provider.withVolumeSettle)(() => drive.delete());
|
|
296
|
+
}
|
|
252
297
|
}
|
|
253
298
|
}
|
|
254
299
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Vercel Provider - Factory-based Implementation\n */\n\nimport { Sandbox as VercelSandbox, Snapshot as VercelSnapshot } from '@vercel/sandbox';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\nimport { Writable } from 'node:stream';\n\nexport type { VercelSandbox, VercelSnapshot };\n\nimport type { CommandResult, InstanceInfo, CreateInstanceOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\n\nexport interface VercelConfig {\n token?: string;\n teamId?: string;\n projectId?: string;\n timeout?: number;\n ports?: number[];\n daemonSsePort?: number | false;\n}\n\nconst DEFAULT_DAEMON_SSE_PORT = 38989;\n\nfunction mergeExposedPorts(primary?: number[], fallback?: number[], daemonSsePort?: number | false): number[] {\n const daemonPort = daemonSsePort === false ? undefined : (daemonSsePort ?? DEFAULT_DAEMON_SSE_PORT);\n const merged = [...(primary ?? fallback ?? [])];\n if (typeof daemonPort === 'number') merged.push(daemonPort);\n return Array.from(new Set(merged.filter((port) => Number.isInteger(port) && port > 0 && port <= 65535)));\n}\n\ninterface ResolvedCredentials {\n useOidc: boolean;\n token: string;\n teamId: string;\n projectId: string;\n}\n\nfunction resolveCredentials(config: VercelConfig): ResolvedCredentials {\n const token = config.token || (typeof process !== 'undefined' && process.env?.VERCEL_TOKEN) || '';\n const teamId = config.teamId || (typeof process !== 'undefined' && process.env?.VERCEL_TEAM_ID) || '';\n const projectId = config.projectId || (typeof process !== 'undefined' && process.env?.VERCEL_PROJECT_ID) || '';\n const hasConfigCredentials = !!(config.token || config.teamId || config.projectId);\n const oidcToken = typeof process !== 'undefined' && process.env?.VERCEL_OIDC_TOKEN;\n const useOidc = !hasConfigCredentials && !!oidcToken;\n return { useOidc, token, teamId, projectId };\n}\n\nfunction validateCredentials(creds: ResolvedCredentials): void {\n if (creds.useOidc) return;\n if (!creds.token) {\n throw new Error(\n `Missing Vercel authentication. Either:\\n` +\n `1. Use OIDC token: Run 'vercel env pull' to get VERCEL_OIDC_TOKEN, or\\n` +\n `2. Use traditional method: Provide 'token' in config or set VERCEL_TOKEN environment variable.`\n );\n }\n if (!creds.teamId) throw new Error(`Missing Vercel team ID. Provide 'teamId' in config or set VERCEL_TEAM_ID.`);\n if (!creds.projectId) throw new Error(`Missing Vercel project ID. Provide 'projectId' in config or set VERCEL_PROJECT_ID.`);\n}\n\nfunction getUtf8Sink() {\n const chunks: string[] = [];\n const sink = new Writable({\n write(chunk, _enc, cb) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk.toString(\"utf8\") : String(chunk));\n cb();\n },\n });\n return { sink, value: () => chunks.join(\"\") };\n}\n\nexport const vercel = defineProvider<VercelSandbox, VercelConfig>({\n name: 'vercel',\n methods: {\n instances: {\n create: async (config: VercelConfig, options?: CreateInstanceOptions) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const timeout = options?.timeout ?? config.timeout ?? 300000;\n try {\n const {\n timeout: _timeout, envs: _envs, name: _name, metadata: _metadata,\n templateId, snapshotId: optSnapshotId, sandboxId: _sandboxId,\n namespace: _namespace, directory: _directory,\n ...providerOptions\n } = options || {};\n const optRuntime = (options as any)?.runtime;\n const optPorts = (options as any)?.ports;\n const optSource = (options as any)?.source;\n\n const params: any = { timeout, ...providerOptions };\n // Vercel sandboxes are persistent by default, which auto-snapshots the\n // filesystem on every stop() and accrues Snapshot Storage. ComputeSDK\n // sandboxes default to non-persistent unless the caller opts in via\n // `persistent: true` or asks for the durable surface (`ephemeral: false`).\n params.persistent = providerOptions.persistent ?? (providerOptions.ephemeral === false);\n const optDaemonSsePort = (options as any)?.daemonSsePort as number | false | undefined;\n const ports = mergeExposedPorts(optPorts, config.ports, optDaemonSsePort ?? config.daemonSsePort);\n if (ports && ports.length > 0) params.ports = ports;\n\n if (optRuntime) {\n params.runtime =\n optRuntime === 'node' ? 'node24' :\n optRuntime === 'python' ? 'python3.13' :\n optRuntime;\n }\n\n const snapshotId = optSnapshotId || templateId ||\n (optSource?.type === 'snapshot' && optSource?.snapshotId);\n if (snapshotId) {\n params.source = { type: 'snapshot', snapshotId };\n } else if (optSource) {\n params.source = optSource;\n }\n\n if (!creds.useOidc) {\n params.token = creds.token;\n params.teamId = creds.teamId;\n params.projectId = creds.projectId;\n }\n\n const sandbox = await VercelSandbox.create(params);\n return { instance: sandbox, instanceId: sandbox.name };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('token')) {\n throw new Error(`Vercel authentication failed. Please check your VERCEL_TOKEN environment variable.`);\n }\n if (error.message.includes('team') || error.message.includes('project')) {\n throw new Error(`Vercel team/project configuration failed. Check VERCEL_TEAM_ID and VERCEL_PROJECT_ID.`);\n }\n }\n throw new Error(`Failed to create Vercel sandbox: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getById: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n return { instance: sandbox, instanceId: sandboxId };\n } catch { return null; }\n },\n\n list: async (_config: VercelConfig) => {\n throw new Error(`Vercel provider does not support listing sandboxes.`);\n },\n\n destroy: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await sandbox.stop();\n } catch { /* already destroyed or doesn't exist */ }\n },\n\n runCommand: async (sandbox: VercelSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`).join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n const stdout = options?.background ? undefined : getUtf8Sink();\n const stderr = options?.background ? undefined : getUtf8Sink();\n const result = await sandbox.runCommand({\n cmd: 'sh', args: ['-c', fullCommand],\n cwd: options?.cwd, detached: options?.background,\n stdout: stdout?.sink, stderr: stderr?.sink,\n timeoutMs: options?.timeout,\n });\n return { stdout: stdout?.value() ?? '', stderr: stderr?.value() ?? '', exitCode: result.exitCode ?? 0, durationMs: Date.now() - startTime };\n } catch (error) {\n return { stdout: '', stderr: error instanceof Error ? error.message : String(error), exitCode: 127, durationMs: Date.now() - startTime };\n }\n },\n\n getInfo: async (_sandbox: VercelSandbox): Promise<InstanceInfo> => ({\n id: 'vercel-unknown',\n provider: 'vercel',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: { vercelSandboxId: 'vercel-unknown' }\n }),\n\n getUrl: async (sandbox: VercelSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n let url = sandbox.domain(options.port);\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n return url;\n } catch (error) {\n throw new Error(`Failed to get Vercel domain for port ${options.port}: ${error instanceof Error ? error.message : String(error)}.`);\n }\n },\n\n filesystem: {\n readFile: async (sandbox: VercelSandbox, path: string): Promise<string> => {\n const stream = await sandbox.readFile({ path });\n if (!stream) throw new Error(`File not found: ${path}`);\n const chunks: Buffer[] = [];\n for await (const chunk of stream) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n return Buffer.concat(chunks).toString('utf-8');\n },\n writeFile: async (sandbox: VercelSandbox, path: string, content: string): Promise<void> => {\n await sandbox.writeFiles([{ path, content: Buffer.from(content) }]);\n },\n mkdir: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.mkdir(path, { recursive: true });\n },\n readdir: async (sandbox: VercelSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.fs.readdir(path, { withFileTypes: true });\n return entries.map((entry) => ({\n name: entry.name,\n type: entry.isDirectory() ? 'directory' : 'file',\n }));\n },\n exists: async (sandbox: VercelSandbox, path: string): Promise<boolean> => {\n return sandbox.fs.exists(path);\n },\n remove: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.rm(path, { recursive: true, force: true });\n }\n },\n\n getInstance: (sandbox: VercelSandbox): VercelSandbox => sandbox,\n },\n\n snapshot: {\n create: async (config: VercelConfig, sandboxId: string, options?: { name?: string }) => {\n const creds = resolveCredentials(config);\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n const snapshot = await sandbox.snapshot();\n // @vercel/sandbox's Snapshot class exposes `snapshotId`, not `id` —\n // map it to the ComputeSDK Snapshot shape ({ id }) consumers rely on.\n return {\n id: snapshot.snapshotId,\n provider: 'vercel',\n createdAt: snapshot.createdAt,\n metadata: { name: options?.name, sourceSessionId: snapshot.sourceSessionId },\n };\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing snapshots.`); },\n delete: async (config: VercelConfig, snapshotId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId })\n : await VercelSnapshot.get({ snapshotId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n },\n\n template: {\n create: async (_config: VercelConfig, _options: { name: string }) => {\n throw new Error(`Vercel does not support creating templates directly. Use snapshot.create() instead.`);\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing templates.`); },\n delete: async (config: VercelConfig, templateId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId: templateId })\n : await VercelSnapshot.get({ snapshotId: templateId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAAqE;AACrE,sBAA+C;AAC/C,yBAAyB;AAezB,IAAM,0BAA0B;AAEhC,SAAS,kBAAkB,SAAoB,UAAqB,eAA0C;AAC5G,QAAM,aAAa,kBAAkB,QAAQ,SAAa,iBAAiB;AAC3E,QAAM,SAAS,CAAC,GAAI,WAAW,YAAY,CAAC,CAAE;AAC9C,MAAI,OAAO,eAAe,SAAU,QAAO,KAAK,UAAU;AAC1D,SAAO,MAA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B;AAC1D,cAAM,QAAQ,mBAAmB,MAAM;AACvC,cAAM,WAAW,MAAM,UACnB,MAAM,eAAAA,SAAe,IAAI,EAAE,YAAY,WAAW,CAAC,IACnD,MAAM,eAAAA,SAAe,IAAI,EAAE,YAAY,YAAY,OAAO,MAAM,OAAO,QAAQ,MAAM,QAAQ,WAAW,MAAM,UAAU,CAAC;AAC7H,cAAM,SAAS,OAAO;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["VercelSandbox","VercelSnapshot"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Vercel Provider - Factory-based Implementation\n */\n\nimport { Sandbox as VercelSandbox, Snapshot as VercelSnapshot, Drive as VercelDrive } from '@vercel/sandbox';\nimport { defineProvider, escapeShellArg, resolveVolumeRef, withVolumeSettle } from '@computesdk/provider';\nimport { Writable } from 'node:stream';\n\nexport type { VercelSandbox, VercelSnapshot };\n\nimport type { CommandResult, InstanceInfo, CreateInstanceOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\n\nexport interface VercelConfig {\n token?: string;\n teamId?: string;\n projectId?: string;\n timeout?: number;\n ports?: number[];\n daemonSsePort?: number | false;\n}\n\nconst DEFAULT_DAEMON_SSE_PORT = 38989;\n\nfunction mergeExposedPorts(primary?: number[], fallback?: number[], daemonSsePort?: number | false): number[] {\n const daemonPort = daemonSsePort === false ? undefined : (daemonSsePort ?? DEFAULT_DAEMON_SSE_PORT);\n const merged = [...(primary ?? fallback ?? [])];\n if (typeof daemonPort === 'number') merged.push(daemonPort);\n return Array.from(new Set(merged.filter((port) => Number.isInteger(port) && port > 0 && port <= 65535)));\n}\n\ninterface ResolvedCredentials {\n useOidc: boolean;\n token: string;\n teamId: string;\n projectId: string;\n}\n\nfunction resolveCredentials(config: VercelConfig): ResolvedCredentials {\n const token = config.token || (typeof process !== 'undefined' && process.env?.VERCEL_TOKEN) || '';\n const teamId = config.teamId || (typeof process !== 'undefined' && process.env?.VERCEL_TEAM_ID) || '';\n const projectId = config.projectId || (typeof process !== 'undefined' && process.env?.VERCEL_PROJECT_ID) || '';\n const hasConfigCredentials = !!(config.token || config.teamId || config.projectId);\n const oidcToken = typeof process !== 'undefined' && process.env?.VERCEL_OIDC_TOKEN;\n const useOidc = !hasConfigCredentials && !!oidcToken;\n return { useOidc, token, teamId, projectId };\n}\n\nfunction validateCredentials(creds: ResolvedCredentials): void {\n if (creds.useOidc) return;\n if (!creds.token) {\n throw new Error(\n `Missing Vercel authentication. Either:\\n` +\n `1. Use OIDC token: Run 'vercel env pull' to get VERCEL_OIDC_TOKEN, or\\n` +\n `2. Use traditional method: Provide 'token' in config or set VERCEL_TOKEN environment variable.`\n );\n }\n if (!creds.teamId) throw new Error(`Missing Vercel team ID. Provide 'teamId' in config or set VERCEL_TEAM_ID.`);\n if (!creds.projectId) throw new Error(`Missing Vercel project ID. Provide 'projectId' in config or set VERCEL_PROJECT_ID.`);\n}\n\nfunction getUtf8Sink() {\n const chunks: string[] = [];\n const sink = new Writable({\n write(chunk, _enc, cb) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk.toString(\"utf8\") : String(chunk));\n cb();\n },\n });\n return { sink, value: () => chunks.join(\"\") };\n}\n\nexport const vercel = defineProvider<VercelSandbox, VercelConfig>({\n name: 'vercel',\n methods: {\n instances: {\n create: async (config: VercelConfig, options?: CreateInstanceOptions) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const timeout = options?.timeout ?? config.timeout ?? 300000;\n try {\n const {\n timeout: _timeout, envs: _envs, name: _name, metadata: _metadata,\n templateId, snapshotId: optSnapshotId, sandboxId: _sandboxId,\n namespace: _namespace, directory: _directory,\n volumes,\n ...providerOptions\n } = options || {};\n const optRuntime = (options as any)?.runtime;\n const optPorts = (options as any)?.ports;\n const optSource = (options as any)?.source;\n\n const params: any = { timeout, ...providerOptions };\n // Vercel sandboxes are persistent by default, which auto-snapshots the\n // filesystem on every stop() and accrues Snapshot Storage. ComputeSDK\n // sandboxes default to non-persistent unless the caller opts in via\n // `persistent: true` or asks for the durable surface (`ephemeral: false`).\n params.persistent = providerOptions.persistent ?? (providerOptions.ephemeral === false);\n const optDaemonSsePort = (options as any)?.daemonSsePort as number | false | undefined;\n const ports = mergeExposedPorts(optPorts, config.ports, optDaemonSsePort ?? config.daemonSsePort);\n if (ports && ports.length > 0) params.ports = ports;\n\n if (optRuntime) {\n params.runtime =\n optRuntime === 'node' ? 'node24' :\n optRuntime === 'python' ? 'python3.13' :\n optRuntime;\n }\n\n const snapshotId = optSnapshotId || templateId ||\n (optSource?.type === 'snapshot' && optSource?.snapshotId);\n if (snapshotId) {\n params.source = { type: 'snapshot', snapshotId };\n } else if (optSource) {\n params.source = optSource;\n }\n\n // Unified mounts → vercel's {path: {drive, mode}} wire shape.\n if (Array.isArray(volumes) && volumes.length > 0) {\n params.mounts = Object.fromEntries((volumes as any[]).map((m) => {\n const ref = resolveVolumeRef(m.volume);\n // The `drive` field serializes verbatim and the API resolves it\n // by NAME (a Drive object mounts as mount.name) — sending\n // driveId yields \"Drive not found\".\n return [m.mountPath, { drive: ref.name ?? ref.id, mode: m.readOnly ? 'snapshot' : 'read-write' }];\n }));\n }\n\n if (!creds.useOidc) {\n params.token = creds.token;\n params.teamId = creds.teamId;\n params.projectId = creds.projectId;\n }\n\n const sandbox = await VercelSandbox.create(params);\n return { instance: sandbox, instanceId: sandbox.name };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('token')) {\n throw new Error(`Vercel authentication failed. Please check your VERCEL_TOKEN environment variable.`);\n }\n if (error.message.includes('team') || error.message.includes('project')) {\n throw new Error(`Vercel team/project configuration failed. Check VERCEL_TEAM_ID and VERCEL_PROJECT_ID.`);\n }\n }\n throw new Error(`Failed to create Vercel sandbox: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getById: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n return { instance: sandbox, instanceId: sandboxId };\n } catch { return null; }\n },\n\n list: async (_config: VercelConfig) => {\n throw new Error(`Vercel provider does not support listing sandboxes.`);\n },\n\n destroy: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await sandbox.stop();\n } catch { /* already destroyed or doesn't exist */ }\n },\n\n runCommand: async (sandbox: VercelSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`).join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n const stdout = options?.background ? undefined : getUtf8Sink();\n const stderr = options?.background ? undefined : getUtf8Sink();\n const result = await sandbox.runCommand({\n cmd: 'sh', args: ['-c', fullCommand],\n cwd: options?.cwd, detached: options?.background,\n stdout: stdout?.sink, stderr: stderr?.sink,\n timeoutMs: options?.timeout,\n });\n return { stdout: stdout?.value() ?? '', stderr: stderr?.value() ?? '', exitCode: result.exitCode ?? 0, durationMs: Date.now() - startTime };\n } catch (error) {\n return { stdout: '', stderr: error instanceof Error ? error.message : String(error), exitCode: 127, durationMs: Date.now() - startTime };\n }\n },\n\n getInfo: async (_sandbox: VercelSandbox): Promise<InstanceInfo> => ({\n id: 'vercel-unknown',\n provider: 'vercel',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: { vercelSandboxId: 'vercel-unknown' }\n }),\n\n getUrl: async (sandbox: VercelSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n let url = sandbox.domain(options.port);\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n return url;\n } catch (error) {\n throw new Error(`Failed to get Vercel domain for port ${options.port}: ${error instanceof Error ? error.message : String(error)}.`);\n }\n },\n\n filesystem: {\n readFile: async (sandbox: VercelSandbox, path: string): Promise<string> => {\n const stream = await sandbox.readFile({ path });\n if (!stream) throw new Error(`File not found: ${path}`);\n const chunks: Buffer[] = [];\n for await (const chunk of stream) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n return Buffer.concat(chunks).toString('utf-8');\n },\n writeFile: async (sandbox: VercelSandbox, path: string, content: string): Promise<void> => {\n await sandbox.writeFiles([{ path, content: Buffer.from(content) }]);\n },\n mkdir: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.mkdir(path, { recursive: true });\n },\n readdir: async (sandbox: VercelSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.fs.readdir(path, { withFileTypes: true });\n return entries.map((entry) => ({\n name: entry.name,\n type: entry.isDirectory() ? 'directory' : 'file',\n }));\n },\n exists: async (sandbox: VercelSandbox, path: string): Promise<boolean> => {\n return sandbox.fs.exists(path);\n },\n remove: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.rm(path, { recursive: true, force: true });\n }\n },\n\n getInstance: (sandbox: VercelSandbox): VercelSandbox => sandbox,\n },\n\n snapshot: {\n create: async (config: VercelConfig, sandboxId: string, options?: { name?: string }) => {\n const creds = resolveCredentials(config);\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n const snapshot = await sandbox.snapshot();\n // @vercel/sandbox's Snapshot class exposes `snapshotId`, not `id` —\n // map it to the ComputeSDK Snapshot shape ({ id }) consumers rely on.\n return {\n id: snapshot.snapshotId,\n provider: 'vercel',\n createdAt: snapshot.createdAt,\n metadata: { name: options?.name, sourceSessionId: snapshot.sourceSessionId },\n };\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing snapshots.`); },\n delete: async (config: VercelConfig, snapshotId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId })\n : await VercelSnapshot.get({ snapshotId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n },\n\n template: {\n create: async (_config: VercelConfig, _options: { name: string }) => {\n throw new Error(`Vercel does not support creating templates directly. Use snapshot.create() instead.`);\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing templates.`); },\n delete: async (config: VercelConfig, templateId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId: templateId })\n : await VercelSnapshot.get({ snapshotId: templateId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n },\n\n volume: {\n create: async (config: VercelConfig, options) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const params = creds.useOidc\n ? { name: options.name }\n : { name: options.name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const drive = await VercelDrive.getOrCreate(params as any);\n return { id: drive.driveId, name: drive.name, native: drive };\n },\n get: async (config: VercelConfig, name: string) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n try {\n const params = creds.useOidc\n ? { name }\n : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const drive = await VercelDrive.get(params as any);\n return { id: drive.driveId, name: drive.name, native: drive };\n } catch { return null; }\n },\n list: async (config: VercelConfig) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const params = creds.useOidc\n ? {}\n : { token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const page = await VercelDrive.list(params as any);\n const out: any[] = [];\n for await (const drive of page as any) {\n out.push({ id: drive.driveId, name: drive.name, native: drive });\n }\n return out;\n },\n delete: async (config: VercelConfig, name: string) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const params = creds.useOidc\n ? { name }\n : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const drive = await VercelDrive.get(params as any);\n await withVolumeSettle(() => drive.delete());\n },\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAA2F;AAC3F,sBAAmF;AACnF,yBAAyB;AAezB,IAAM,0BAA0B;AAEhC,SAAS,kBAAkB,SAAoB,UAAqB,eAA0C;AAC5G,QAAM,aAAa,kBAAkB,QAAQ,SAAa,iBAAiB;AAC3E,QAAM,SAAS,CAAC,GAAI,WAAW,YAAY,CAAC,CAAE;AAC9C,MAAI,OAAO,eAAe,SAAU,QAAO,KAAK,UAAU;AAC1D,SAAO,MAAM,KAAK,IAAI,IAAI,OAAO,OAAO,CAAC,SAAS,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG;AASA,SAAS,mBAAmB,QAA2C;AACrE,QAAM,QAAQ,OAAO,SAAU,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAiB;AAC/F,QAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,kBAAmB;AACnG,QAAM,YAAY,OAAO,aAAc,OAAO,YAAY,eAAe,QAAQ,KAAK,qBAAsB;AAC5G,QAAM,uBAAuB,CAAC,EAAE,OAAO,SAAS,OAAO,UAAU,OAAO;AACxE,QAAM,YAAY,OAAO,YAAY,eAAe,QAAQ,KAAK;AACjE,QAAM,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC3C,SAAO,EAAE,SAAS,OAAO,QAAQ,UAAU;AAC7C;AAEA,SAAS,oBAAoB,OAAkC;AAC7D,MAAI,MAAM,QAAS;AACnB,MAAI,CAAC,MAAM,OAAO;AAChB,UAAM,IAAI;AAAA,MACR;AAAA;AAAA;AAAA,IAGF;AAAA,EACF;AACA,MAAI,CAAC,MAAM,OAAQ,OA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,UAAU;AACjF,cAAM,QAAQ,MAAM,eAAAA,MAAY,IAAI,MAAa;AACjD,kBAAM,kCAAiB,MAAM,MAAM,OAAO,CAAC;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["VercelSandbox","VercelSnapshot","VercelDrive"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { Sandbox as VercelSandbox, Snapshot as VercelSnapshot } from "@vercel/sandbox";
|
|
3
|
-
import { defineProvider, escapeShellArg } from "@computesdk/provider";
|
|
2
|
+
import { Sandbox as VercelSandbox, Snapshot as VercelSnapshot, Drive as VercelDrive } from "@vercel/sandbox";
|
|
3
|
+
import { defineProvider, escapeShellArg, resolveVolumeRef, withVolumeSettle } from "@computesdk/provider";
|
|
4
4
|
import { Writable } from "stream";
|
|
5
5
|
var DEFAULT_DAEMON_SSE_PORT = 38989;
|
|
6
6
|
function mergeExposedPorts(primary, fallback, daemonSsePort) {
|
|
@@ -59,6 +59,7 @@ var vercel = defineProvider({
|
|
|
59
59
|
sandboxId: _sandboxId,
|
|
60
60
|
namespace: _namespace,
|
|
61
61
|
directory: _directory,
|
|
62
|
+
volumes,
|
|
62
63
|
...providerOptions
|
|
63
64
|
} = options || {};
|
|
64
65
|
const optRuntime = options?.runtime;
|
|
@@ -78,6 +79,12 @@ var vercel = defineProvider({
|
|
|
78
79
|
} else if (optSource) {
|
|
79
80
|
params.source = optSource;
|
|
80
81
|
}
|
|
82
|
+
if (Array.isArray(volumes) && volumes.length > 0) {
|
|
83
|
+
params.mounts = Object.fromEntries(volumes.map((m) => {
|
|
84
|
+
const ref = resolveVolumeRef(m.volume);
|
|
85
|
+
return [m.mountPath, { drive: ref.name ?? ref.id, mode: m.readOnly ? "snapshot" : "read-write" }];
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
81
88
|
if (!creds.useOidc) {
|
|
82
89
|
params.token = creds.token;
|
|
83
90
|
params.teamId = creds.teamId;
|
|
@@ -225,6 +232,44 @@ var vercel = defineProvider({
|
|
|
225
232
|
const snapshot = creds.useOidc ? await VercelSnapshot.get({ snapshotId: templateId }) : await VercelSnapshot.get({ snapshotId: templateId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });
|
|
226
233
|
await snapshot.delete();
|
|
227
234
|
}
|
|
235
|
+
},
|
|
236
|
+
volume: {
|
|
237
|
+
create: async (config, options) => {
|
|
238
|
+
const creds = resolveCredentials(config);
|
|
239
|
+
validateCredentials(creds);
|
|
240
|
+
const params = creds.useOidc ? { name: options.name } : { name: options.name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
241
|
+
const drive = await VercelDrive.getOrCreate(params);
|
|
242
|
+
return { id: drive.driveId, name: drive.name, native: drive };
|
|
243
|
+
},
|
|
244
|
+
get: async (config, name) => {
|
|
245
|
+
const creds = resolveCredentials(config);
|
|
246
|
+
validateCredentials(creds);
|
|
247
|
+
try {
|
|
248
|
+
const params = creds.useOidc ? { name } : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
249
|
+
const drive = await VercelDrive.get(params);
|
|
250
|
+
return { id: drive.driveId, name: drive.name, native: drive };
|
|
251
|
+
} catch {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
list: async (config) => {
|
|
256
|
+
const creds = resolveCredentials(config);
|
|
257
|
+
validateCredentials(creds);
|
|
258
|
+
const params = creds.useOidc ? {} : { token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
259
|
+
const page = await VercelDrive.list(params);
|
|
260
|
+
const out = [];
|
|
261
|
+
for await (const drive of page) {
|
|
262
|
+
out.push({ id: drive.driveId, name: drive.name, native: drive });
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
},
|
|
266
|
+
delete: async (config, name) => {
|
|
267
|
+
const creds = resolveCredentials(config);
|
|
268
|
+
validateCredentials(creds);
|
|
269
|
+
const params = creds.useOidc ? { name } : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };
|
|
270
|
+
const drive = await VercelDrive.get(params);
|
|
271
|
+
await withVolumeSettle(() => drive.delete());
|
|
272
|
+
}
|
|
228
273
|
}
|
|
229
274
|
}
|
|
230
275
|
});
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Vercel Provider - Factory-based Implementation\n */\n\nimport { Sandbox as VercelSandbox, Snapshot as VercelSnapshot } from '@vercel/sandbox';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\nimport { Writable } from 'node:stream';\n\nexport type { VercelSandbox, VercelSnapshot };\n\nimport type { CommandResult, InstanceInfo, CreateInstanceOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\n\nexport interface VercelConfig {\n token?: string;\n teamId?: string;\n projectId?: string;\n timeout?: number;\n ports?: number[];\n daemonSsePort?: number | false;\n}\n\nconst DEFAULT_DAEMON_SSE_PORT = 38989;\n\nfunction mergeExposedPorts(primary?: number[], fallback?: number[], daemonSsePort?: number | false): number[] {\n const daemonPort = daemonSsePort === false ? undefined : (daemonSsePort ?? DEFAULT_DAEMON_SSE_PORT);\n const merged = [...(primary ?? fallback ?? [])];\n if (typeof daemonPort === 'number') merged.push(daemonPort);\n return Array.from(new Set(merged.filter((port) => Number.isInteger(port) && port > 0 && port <= 65535)));\n}\n\ninterface ResolvedCredentials {\n useOidc: boolean;\n token: string;\n teamId: string;\n projectId: string;\n}\n\nfunction resolveCredentials(config: VercelConfig): ResolvedCredentials {\n const token = config.token || (typeof process !== 'undefined' && process.env?.VERCEL_TOKEN) || '';\n const teamId = config.teamId || (typeof process !== 'undefined' && process.env?.VERCEL_TEAM_ID) || '';\n const projectId = config.projectId || (typeof process !== 'undefined' && process.env?.VERCEL_PROJECT_ID) || '';\n const hasConfigCredentials = !!(config.token || config.teamId || config.projectId);\n const oidcToken = typeof process !== 'undefined' && process.env?.VERCEL_OIDC_TOKEN;\n const useOidc = !hasConfigCredentials && !!oidcToken;\n return { useOidc, token, teamId, projectId };\n}\n\nfunction validateCredentials(creds: ResolvedCredentials): void {\n if (creds.useOidc) return;\n if (!creds.token) {\n throw new Error(\n `Missing Vercel authentication. Either:\\n` +\n `1. Use OIDC token: Run 'vercel env pull' to get VERCEL_OIDC_TOKEN, or\\n` +\n `2. Use traditional method: Provide 'token' in config or set VERCEL_TOKEN environment variable.`\n );\n }\n if (!creds.teamId) throw new Error(`Missing Vercel team ID. Provide 'teamId' in config or set VERCEL_TEAM_ID.`);\n if (!creds.projectId) throw new Error(`Missing Vercel project ID. Provide 'projectId' in config or set VERCEL_PROJECT_ID.`);\n}\n\nfunction getUtf8Sink() {\n const chunks: string[] = [];\n const sink = new Writable({\n write(chunk, _enc, cb) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk.toString(\"utf8\") : String(chunk));\n cb();\n },\n });\n return { sink, value: () => chunks.join(\"\") };\n}\n\nexport const vercel = defineProvider<VercelSandbox, VercelConfig>({\n name: 'vercel',\n methods: {\n instances: {\n create: async (config: VercelConfig, options?: CreateInstanceOptions) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const timeout = options?.timeout ?? config.timeout ?? 300000;\n try {\n const {\n timeout: _timeout, envs: _envs, name: _name, metadata: _metadata,\n templateId, snapshotId: optSnapshotId, sandboxId: _sandboxId,\n namespace: _namespace, directory: _directory,\n ...providerOptions\n } = options || {};\n const optRuntime = (options as any)?.runtime;\n const optPorts = (options as any)?.ports;\n const optSource = (options as any)?.source;\n\n const params: any = { timeout, ...providerOptions };\n // Vercel sandboxes are persistent by default, which auto-snapshots the\n // filesystem on every stop() and accrues Snapshot Storage. ComputeSDK\n // sandboxes default to non-persistent unless the caller opts in via\n // `persistent: true` or asks for the durable surface (`ephemeral: false`).\n params.persistent = providerOptions.persistent ?? (providerOptions.ephemeral === false);\n const optDaemonSsePort = (options as any)?.daemonSsePort as number | false | undefined;\n const ports = mergeExposedPorts(optPorts, config.ports, optDaemonSsePort ?? config.daemonSsePort);\n if (ports && ports.length > 0) params.ports = ports;\n\n if (optRuntime) {\n params.runtime =\n optRuntime === 'node' ? 'node24' :\n optRuntime === 'python' ? 'python3.13' :\n optRuntime;\n }\n\n const snapshotId = optSnapshotId || templateId ||\n (optSource?.type === 'snapshot' && optSource?.snapshotId);\n if (snapshotId) {\n params.source = { type: 'snapshot', snapshotId };\n } else if (optSource) {\n params.source = optSource;\n }\n\n if (!creds.useOidc) {\n params.token = creds.token;\n params.teamId = creds.teamId;\n params.projectId = creds.projectId;\n }\n\n const sandbox = await VercelSandbox.create(params);\n return { instance: sandbox, instanceId: sandbox.name };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('token')) {\n throw new Error(`Vercel authentication failed. Please check your VERCEL_TOKEN environment variable.`);\n }\n if (error.message.includes('team') || error.message.includes('project')) {\n throw new Error(`Vercel team/project configuration failed. Check VERCEL_TEAM_ID and VERCEL_PROJECT_ID.`);\n }\n }\n throw new Error(`Failed to create Vercel sandbox: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getById: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n return { instance: sandbox, instanceId: sandboxId };\n } catch { return null; }\n },\n\n list: async (_config: VercelConfig) => {\n throw new Error(`Vercel provider does not support listing sandboxes.`);\n },\n\n destroy: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await sandbox.stop();\n } catch { /* already destroyed or doesn't exist */ }\n },\n\n runCommand: async (sandbox: VercelSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`).join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n const stdout = options?.background ? undefined : getUtf8Sink();\n const stderr = options?.background ? undefined : getUtf8Sink();\n const result = await sandbox.runCommand({\n cmd: 'sh', args: ['-c', fullCommand],\n cwd: options?.cwd, detached: options?.background,\n stdout: stdout?.sink, stderr: stderr?.sink,\n timeoutMs: options?.timeout,\n });\n return { stdout: stdout?.value() ?? '', stderr: stderr?.value() ?? '', exitCode: result.exitCode ?? 0, durationMs: Date.now() - startTime };\n } catch (error) {\n return { stdout: '', stderr: error instanceof Error ? error.message : String(error), exitCode: 127, durationMs: Date.now() - startTime };\n }\n },\n\n getInfo: async (_sandbox: VercelSandbox): Promise<InstanceInfo> => ({\n id: 'vercel-unknown',\n provider: 'vercel',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: { vercelSandboxId: 'vercel-unknown' }\n }),\n\n getUrl: async (sandbox: VercelSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n let url = sandbox.domain(options.port);\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n return url;\n } catch (error) {\n throw new Error(`Failed to get Vercel domain for port ${options.port}: ${error instanceof Error ? error.message : String(error)}.`);\n }\n },\n\n filesystem: {\n readFile: async (sandbox: VercelSandbox, path: string): Promise<string> => {\n const stream = await sandbox.readFile({ path });\n if (!stream) throw new Error(`File not found: ${path}`);\n const chunks: Buffer[] = [];\n for await (const chunk of stream) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n return Buffer.concat(chunks).toString('utf-8');\n },\n writeFile: async (sandbox: VercelSandbox, path: string, content: string): Promise<void> => {\n await sandbox.writeFiles([{ path, content: Buffer.from(content) }]);\n },\n mkdir: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.mkdir(path, { recursive: true });\n },\n readdir: async (sandbox: VercelSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.fs.readdir(path, { withFileTypes: true });\n return entries.map((entry) => ({\n name: entry.name,\n type: entry.isDirectory() ? 'directory' : 'file',\n }));\n },\n exists: async (sandbox: VercelSandbox, path: string): Promise<boolean> => {\n return sandbox.fs.exists(path);\n },\n remove: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.rm(path, { recursive: true, force: true });\n }\n },\n\n getInstance: (sandbox: VercelSandbox): VercelSandbox => sandbox,\n },\n\n snapshot: {\n create: async (config: VercelConfig, sandboxId: string, options?: { name?: string }) => {\n const creds = resolveCredentials(config);\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n const snapshot = await sandbox.snapshot();\n // @vercel/sandbox's Snapshot class exposes `snapshotId`, not `id` —\n // map it to the ComputeSDK Snapshot shape ({ id }) consumers rely on.\n return {\n id: snapshot.snapshotId,\n provider: 'vercel',\n createdAt: snapshot.createdAt,\n metadata: { name: options?.name, sourceSessionId: snapshot.sourceSessionId },\n };\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing snapshots.`); },\n delete: async (config: VercelConfig, snapshotId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId })\n : await VercelSnapshot.get({ snapshotId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n },\n\n template: {\n create: async (_config: VercelConfig, _options: { name: string }) => {\n throw new Error(`Vercel does not support creating templates directly. Use snapshot.create() instead.`);\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing templates.`); },\n delete: async (config: VercelConfig, templateId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId: templateId })\n : await VercelSnapshot.get({ snapshotId: templateId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n }\n }\n});\n"],"mappings":";AAIA,SAAS,WAAW,eAAe,YAAY,sBAAsB;AACrE,SAAS,gBAAgB,sBAAsB;AAC/C,SAAS,gBAAgB;AAezB,IAAM,0BAA0B;AAEhC,SAAS,kBAAkB,SAAoB,UAAqB,eAA0C;AAC5G,QAAM,aAAa,kBAAkB,QAAQ,SAAa,iBAAiB;AAC3E,QAAM,SAAS,CAAC,GAAI,WAAW,YAAY,CAAC,CAAE;AAC9C,MAAI,OAAO,eAAe,SAAU,QAAO,KAAK,UAAU;AAC1D,SAAO,MAAM,KAAK,IAAI,IAAI,OAAO,OAAO,CAAC,SAAS,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG;AASA,SAAS,mBAAmB,QAA2C;AACrE,QAAM,QAAQ,OAAO,SAAU,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAiB;AAC/F,QAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,kBAAmB;AACnG,QAAM,YAAY,OAAO,aAAc,OAAO,YAAY,eAAe,QAAQ,KAAK,qBAAsB;AAC5G,QAAM,uBAAuB,CAAC,EAAE,OAAO,SAAS,OAAO,UAAU,OAAO;AACxE,QAAM,YAAY,OAAO,YAAY,eAAe,QAAQ,KAAK;AACjE,QAAM,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC3C,SAAO,EAAE,SAAS,OAAO,QAAQ,UAAU;AAC7C;AAEA,SAAS,oBAAoB,OAAkC;AAC7D,MAAI,MAAM,QAAS;AACnB,MAAI,CAAC,MAAM,OAAO;AAChB,UAAM,IAAI;AAAA,MACR;AAAA;AAAA;AAAA,IAGF;AAAA,EACF;AACA,MAAI,CAAC,MAAM,OAAQ,OAAM,IAAI,MAAM,2EAA2E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,UACnB,MAAM,eAAe,IAAI,EAAE,WAAW,CAAC,IACvC,MAAM,eAAe,IAAI,EAAE,YAAY,OAAO,MAAM,OAAO,QAAQ,MAAM,QAAQ,WAAW,MAAM,UAAU,CAAC;AACjH,cAAM,SAAS,OAAO;AAAA,MACxB;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,QAAQ,OAAO,SAAuB,aAA+B;AACnE,cAAM,IAAI,MAAM,qFAAqF;AAAA,MACvG;AAAA,MACA,MAAM,OAAO,YAA0B;AAAE,cAAM,IAAI,MAAM,qDAAqD;AAAA,MAAG;AAAA,MACjH,QAAQ,OAAO,QAAsB,eAAuB;AAC1D,cAAM,QAAQ,mBAAmB,MAAM;AACvC,cAAM,WAAW,MAAM,UACnB,MAAM,eAAe,IAAI,EAAE,YAAY,WAAW,CAAC,IACnD,MAAM,eAAe,IAAI,EAAE,YAAY,YAAY,OAAO,MAAM,OAAO,QAAQ,MAAM,QAAQ,WAAW,MAAM,UAAU,CAAC;AAC7H,cAAM,SAAS,OAAO;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Vercel Provider - Factory-based Implementation\n */\n\nimport { Sandbox as VercelSandbox, Snapshot as VercelSnapshot, Drive as VercelDrive } from '@vercel/sandbox';\nimport { defineProvider, escapeShellArg, resolveVolumeRef, withVolumeSettle } from '@computesdk/provider';\nimport { Writable } from 'node:stream';\n\nexport type { VercelSandbox, VercelSnapshot };\n\nimport type { CommandResult, InstanceInfo, CreateInstanceOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\n\nexport interface VercelConfig {\n token?: string;\n teamId?: string;\n projectId?: string;\n timeout?: number;\n ports?: number[];\n daemonSsePort?: number | false;\n}\n\nconst DEFAULT_DAEMON_SSE_PORT = 38989;\n\nfunction mergeExposedPorts(primary?: number[], fallback?: number[], daemonSsePort?: number | false): number[] {\n const daemonPort = daemonSsePort === false ? undefined : (daemonSsePort ?? DEFAULT_DAEMON_SSE_PORT);\n const merged = [...(primary ?? fallback ?? [])];\n if (typeof daemonPort === 'number') merged.push(daemonPort);\n return Array.from(new Set(merged.filter((port) => Number.isInteger(port) && port > 0 && port <= 65535)));\n}\n\ninterface ResolvedCredentials {\n useOidc: boolean;\n token: string;\n teamId: string;\n projectId: string;\n}\n\nfunction resolveCredentials(config: VercelConfig): ResolvedCredentials {\n const token = config.token || (typeof process !== 'undefined' && process.env?.VERCEL_TOKEN) || '';\n const teamId = config.teamId || (typeof process !== 'undefined' && process.env?.VERCEL_TEAM_ID) || '';\n const projectId = config.projectId || (typeof process !== 'undefined' && process.env?.VERCEL_PROJECT_ID) || '';\n const hasConfigCredentials = !!(config.token || config.teamId || config.projectId);\n const oidcToken = typeof process !== 'undefined' && process.env?.VERCEL_OIDC_TOKEN;\n const useOidc = !hasConfigCredentials && !!oidcToken;\n return { useOidc, token, teamId, projectId };\n}\n\nfunction validateCredentials(creds: ResolvedCredentials): void {\n if (creds.useOidc) return;\n if (!creds.token) {\n throw new Error(\n `Missing Vercel authentication. Either:\\n` +\n `1. Use OIDC token: Run 'vercel env pull' to get VERCEL_OIDC_TOKEN, or\\n` +\n `2. Use traditional method: Provide 'token' in config or set VERCEL_TOKEN environment variable.`\n );\n }\n if (!creds.teamId) throw new Error(`Missing Vercel team ID. Provide 'teamId' in config or set VERCEL_TEAM_ID.`);\n if (!creds.projectId) throw new Error(`Missing Vercel project ID. Provide 'projectId' in config or set VERCEL_PROJECT_ID.`);\n}\n\nfunction getUtf8Sink() {\n const chunks: string[] = [];\n const sink = new Writable({\n write(chunk, _enc, cb) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk.toString(\"utf8\") : String(chunk));\n cb();\n },\n });\n return { sink, value: () => chunks.join(\"\") };\n}\n\nexport const vercel = defineProvider<VercelSandbox, VercelConfig>({\n name: 'vercel',\n methods: {\n instances: {\n create: async (config: VercelConfig, options?: CreateInstanceOptions) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const timeout = options?.timeout ?? config.timeout ?? 300000;\n try {\n const {\n timeout: _timeout, envs: _envs, name: _name, metadata: _metadata,\n templateId, snapshotId: optSnapshotId, sandboxId: _sandboxId,\n namespace: _namespace, directory: _directory,\n volumes,\n ...providerOptions\n } = options || {};\n const optRuntime = (options as any)?.runtime;\n const optPorts = (options as any)?.ports;\n const optSource = (options as any)?.source;\n\n const params: any = { timeout, ...providerOptions };\n // Vercel sandboxes are persistent by default, which auto-snapshots the\n // filesystem on every stop() and accrues Snapshot Storage. ComputeSDK\n // sandboxes default to non-persistent unless the caller opts in via\n // `persistent: true` or asks for the durable surface (`ephemeral: false`).\n params.persistent = providerOptions.persistent ?? (providerOptions.ephemeral === false);\n const optDaemonSsePort = (options as any)?.daemonSsePort as number | false | undefined;\n const ports = mergeExposedPorts(optPorts, config.ports, optDaemonSsePort ?? config.daemonSsePort);\n if (ports && ports.length > 0) params.ports = ports;\n\n if (optRuntime) {\n params.runtime =\n optRuntime === 'node' ? 'node24' :\n optRuntime === 'python' ? 'python3.13' :\n optRuntime;\n }\n\n const snapshotId = optSnapshotId || templateId ||\n (optSource?.type === 'snapshot' && optSource?.snapshotId);\n if (snapshotId) {\n params.source = { type: 'snapshot', snapshotId };\n } else if (optSource) {\n params.source = optSource;\n }\n\n // Unified mounts → vercel's {path: {drive, mode}} wire shape.\n if (Array.isArray(volumes) && volumes.length > 0) {\n params.mounts = Object.fromEntries((volumes as any[]).map((m) => {\n const ref = resolveVolumeRef(m.volume);\n // The `drive` field serializes verbatim and the API resolves it\n // by NAME (a Drive object mounts as mount.name) — sending\n // driveId yields \"Drive not found\".\n return [m.mountPath, { drive: ref.name ?? ref.id, mode: m.readOnly ? 'snapshot' : 'read-write' }];\n }));\n }\n\n if (!creds.useOidc) {\n params.token = creds.token;\n params.teamId = creds.teamId;\n params.projectId = creds.projectId;\n }\n\n const sandbox = await VercelSandbox.create(params);\n return { instance: sandbox, instanceId: sandbox.name };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('token')) {\n throw new Error(`Vercel authentication failed. Please check your VERCEL_TOKEN environment variable.`);\n }\n if (error.message.includes('team') || error.message.includes('project')) {\n throw new Error(`Vercel team/project configuration failed. Check VERCEL_TEAM_ID and VERCEL_PROJECT_ID.`);\n }\n }\n throw new Error(`Failed to create Vercel sandbox: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getById: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n return { instance: sandbox, instanceId: sandboxId };\n } catch { return null; }\n },\n\n list: async (_config: VercelConfig) => {\n throw new Error(`Vercel provider does not support listing sandboxes.`);\n },\n\n destroy: async (config: VercelConfig, sandboxId: string) => {\n const creds = resolveCredentials(config);\n try {\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await sandbox.stop();\n } catch { /* already destroyed or doesn't exist */ }\n },\n\n runCommand: async (sandbox: VercelSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`).join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n const stdout = options?.background ? undefined : getUtf8Sink();\n const stderr = options?.background ? undefined : getUtf8Sink();\n const result = await sandbox.runCommand({\n cmd: 'sh', args: ['-c', fullCommand],\n cwd: options?.cwd, detached: options?.background,\n stdout: stdout?.sink, stderr: stderr?.sink,\n timeoutMs: options?.timeout,\n });\n return { stdout: stdout?.value() ?? '', stderr: stderr?.value() ?? '', exitCode: result.exitCode ?? 0, durationMs: Date.now() - startTime };\n } catch (error) {\n return { stdout: '', stderr: error instanceof Error ? error.message : String(error), exitCode: 127, durationMs: Date.now() - startTime };\n }\n },\n\n getInfo: async (_sandbox: VercelSandbox): Promise<InstanceInfo> => ({\n id: 'vercel-unknown',\n provider: 'vercel',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: { vercelSandboxId: 'vercel-unknown' }\n }),\n\n getUrl: async (sandbox: VercelSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n let url = sandbox.domain(options.port);\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n return url;\n } catch (error) {\n throw new Error(`Failed to get Vercel domain for port ${options.port}: ${error instanceof Error ? error.message : String(error)}.`);\n }\n },\n\n filesystem: {\n readFile: async (sandbox: VercelSandbox, path: string): Promise<string> => {\n const stream = await sandbox.readFile({ path });\n if (!stream) throw new Error(`File not found: ${path}`);\n const chunks: Buffer[] = [];\n for await (const chunk of stream) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n return Buffer.concat(chunks).toString('utf-8');\n },\n writeFile: async (sandbox: VercelSandbox, path: string, content: string): Promise<void> => {\n await sandbox.writeFiles([{ path, content: Buffer.from(content) }]);\n },\n mkdir: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.mkdir(path, { recursive: true });\n },\n readdir: async (sandbox: VercelSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.fs.readdir(path, { withFileTypes: true });\n return entries.map((entry) => ({\n name: entry.name,\n type: entry.isDirectory() ? 'directory' : 'file',\n }));\n },\n exists: async (sandbox: VercelSandbox, path: string): Promise<boolean> => {\n return sandbox.fs.exists(path);\n },\n remove: async (sandbox: VercelSandbox, path: string): Promise<void> => {\n await sandbox.fs.rm(path, { recursive: true, force: true });\n }\n },\n\n getInstance: (sandbox: VercelSandbox): VercelSandbox => sandbox,\n },\n\n snapshot: {\n create: async (config: VercelConfig, sandboxId: string, options?: { name?: string }) => {\n const creds = resolveCredentials(config);\n const sandbox = creds.useOidc\n ? await VercelSandbox.get({ name: sandboxId })\n : await VercelSandbox.get({ name: sandboxId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n const snapshot = await sandbox.snapshot();\n // @vercel/sandbox's Snapshot class exposes `snapshotId`, not `id` —\n // map it to the ComputeSDK Snapshot shape ({ id }) consumers rely on.\n return {\n id: snapshot.snapshotId,\n provider: 'vercel',\n createdAt: snapshot.createdAt,\n metadata: { name: options?.name, sourceSessionId: snapshot.sourceSessionId },\n };\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing snapshots.`); },\n delete: async (config: VercelConfig, snapshotId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId })\n : await VercelSnapshot.get({ snapshotId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n },\n\n template: {\n create: async (_config: VercelConfig, _options: { name: string }) => {\n throw new Error(`Vercel does not support creating templates directly. Use snapshot.create() instead.`);\n },\n list: async (_config: VercelConfig) => { throw new Error(`Vercel provider does not support listing templates.`); },\n delete: async (config: VercelConfig, templateId: string) => {\n const creds = resolveCredentials(config);\n const snapshot = creds.useOidc\n ? await VercelSnapshot.get({ snapshotId: templateId })\n : await VercelSnapshot.get({ snapshotId: templateId, token: creds.token, teamId: creds.teamId, projectId: creds.projectId });\n await snapshot.delete();\n }\n },\n\n volume: {\n create: async (config: VercelConfig, options) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const params = creds.useOidc\n ? { name: options.name }\n : { name: options.name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const drive = await VercelDrive.getOrCreate(params as any);\n return { id: drive.driveId, name: drive.name, native: drive };\n },\n get: async (config: VercelConfig, name: string) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n try {\n const params = creds.useOidc\n ? { name }\n : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const drive = await VercelDrive.get(params as any);\n return { id: drive.driveId, name: drive.name, native: drive };\n } catch { return null; }\n },\n list: async (config: VercelConfig) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const params = creds.useOidc\n ? {}\n : { token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const page = await VercelDrive.list(params as any);\n const out: any[] = [];\n for await (const drive of page as any) {\n out.push({ id: drive.driveId, name: drive.name, native: drive });\n }\n return out;\n },\n delete: async (config: VercelConfig, name: string) => {\n const creds = resolveCredentials(config);\n validateCredentials(creds);\n const params = creds.useOidc\n ? { name }\n : { name, token: creds.token, teamId: creds.teamId, projectId: creds.projectId };\n const drive = await VercelDrive.get(params as any);\n await withVolumeSettle(() => drive.delete());\n },\n }\n }\n});\n"],"mappings":";AAIA,SAAS,WAAW,eAAe,YAAY,gBAAgB,SAAS,mBAAmB;AAC3F,SAAS,gBAAgB,gBAAgB,kBAAkB,wBAAwB;AACnF,SAAS,gBAAgB;AAezB,IAAM,0BAA0B;AAEhC,SAAS,kBAAkB,SAAoB,UAAqB,eAA0C;AAC5G,QAAM,aAAa,kBAAkB,QAAQ,SAAa,iBAAiB;AAC3E,QAAM,SAAS,CAAC,GAAI,WAAW,YAAY,CAAC,CAAE;AAC9C,MAAI,OAAO,eAAe,SAAU,QAAO,KAAK,UAAU;AAC1D,SAAO,MAAM,KAAK,IAAI,IAAI,OAAO,OAAO,CAAC,SAAS,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG;AASA,SAAS,mBAAmB,QAA2C;AACrE,QAAM,QAAQ,OAAO,SAAU,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAiB;AAC/F,QAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,kBAAmB;AACnG,QAAM,YAAY,OAAO,aAAc,OAAO,YAAY,eAAe,QAAQ,KAAK,qBAAsB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,MAAM,SAAS,MAAM,MAAM,MAAM,QAAQ,MAAM,CAAC;AAAA,QACjE;AACA,eAAO;AAAA,MACT;AAAA,MACA,QAAQ,OAAO,QAAsB,SAAiB;AACpD,cAAM,QAAQ,mBAAmB,MAAM;AACvC,4BAAoB,KAAK;AACzB,cAAM,SAAS,MAAM,UACjB,EAAE,KAAK,IACP,EAAE,MAAM,OAAO,MAAM,OAAO,QAAQ,MAAM,QAAQ,WAAW,MAAM,UAAU;AACjF,cAAM,QAAQ,MAAM,YAAY,IAAI,MAAa;AACjD,cAAM,iBAAiB,MAAM,MAAM,OAAO,CAAC;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/vercel",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.48",
|
|
4
4
|
"description": "Vercel Sandbox provider for ComputeSDK - serverless code execution for Python and Node.js on Vercel's edge network",
|
|
5
5
|
"author": "Garrison",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@vercel/sandbox": "^3.
|
|
21
|
+
"@vercel/sandbox": "^3.8.0",
|
|
22
22
|
"ms": "^2.1.3",
|
|
23
|
-
"
|
|
24
|
-
"computesdk": "
|
|
23
|
+
"computesdk": "4.1.13",
|
|
24
|
+
"@computesdk/provider": "2.1.16"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"computesdk",
|