@agent-relay/sandbox 0.1.2 → 0.1.3

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.
Files changed (121) hide show
  1. package/README.md +226 -5
  2. package/dist/agent37/client.d.ts +115 -0
  3. package/dist/agent37/client.d.ts.map +1 -0
  4. package/dist/agent37/client.js +270 -0
  5. package/dist/agent37/client.js.map +1 -0
  6. package/dist/agent37/runtime.d.ts +415 -0
  7. package/dist/agent37/runtime.d.ts.map +1 -0
  8. package/dist/agent37/runtime.js +855 -0
  9. package/dist/agent37/runtime.js.map +1 -0
  10. package/dist/agentcore/bench.d.ts +93 -0
  11. package/dist/agentcore/bench.d.ts.map +1 -0
  12. package/dist/agentcore/bench.js +125 -0
  13. package/dist/agentcore/bench.js.map +1 -0
  14. package/dist/agentcore/capabilities.d.ts +169 -0
  15. package/dist/agentcore/capabilities.d.ts.map +1 -0
  16. package/dist/agentcore/capabilities.js +153 -0
  17. package/dist/agentcore/capabilities.js.map +1 -0
  18. package/dist/agentcore/config.d.ts +156 -0
  19. package/dist/agentcore/config.d.ts.map +1 -0
  20. package/dist/agentcore/config.js +12 -0
  21. package/dist/agentcore/config.js.map +1 -0
  22. package/dist/agentcore/internal/sdk.d.ts +181 -0
  23. package/dist/agentcore/internal/sdk.d.ts.map +1 -0
  24. package/dist/agentcore/internal/sdk.js +223 -0
  25. package/dist/agentcore/internal/sdk.js.map +1 -0
  26. package/dist/agentcore/runtime.d.ts +177 -0
  27. package/dist/agentcore/runtime.d.ts.map +1 -0
  28. package/dist/agentcore/runtime.js +706 -0
  29. package/dist/agentcore/runtime.js.map +1 -0
  30. package/dist/daytona/runtime.d.ts +23 -0
  31. package/dist/daytona/runtime.d.ts.map +1 -1
  32. package/dist/daytona/runtime.js +167 -5
  33. package/dist/daytona/runtime.js.map +1 -1
  34. package/dist/daytona/wire-supplement.d.ts +25 -0
  35. package/dist/daytona/wire-supplement.d.ts.map +1 -0
  36. package/dist/daytona/wire-supplement.js +16 -0
  37. package/dist/daytona/wire-supplement.js.map +1 -0
  38. package/dist/e2b/runtime.d.ts +107 -72
  39. package/dist/e2b/runtime.d.ts.map +1 -1
  40. package/dist/e2b/runtime.js +675 -190
  41. package/dist/e2b/runtime.js.map +1 -1
  42. package/dist/freestyle/capabilities.d.ts +28 -0
  43. package/dist/freestyle/capabilities.d.ts.map +1 -0
  44. package/dist/freestyle/capabilities.js +42 -0
  45. package/dist/freestyle/capabilities.js.map +1 -0
  46. package/dist/freestyle/config.d.ts +36 -0
  47. package/dist/freestyle/config.d.ts.map +1 -0
  48. package/dist/freestyle/config.js +2 -0
  49. package/dist/freestyle/config.js.map +1 -0
  50. package/dist/freestyle/internal/sdk.d.ts +69 -0
  51. package/dist/freestyle/internal/sdk.d.ts.map +1 -0
  52. package/dist/freestyle/internal/sdk.js +19 -0
  53. package/dist/freestyle/internal/sdk.js.map +1 -0
  54. package/dist/freestyle/runtime.d.ts +163 -0
  55. package/dist/freestyle/runtime.d.ts.map +1 -0
  56. package/dist/freestyle/runtime.js +798 -0
  57. package/dist/freestyle/runtime.js.map +1 -0
  58. package/dist/index.d.ts +35 -4
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +16 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/microsandbox/runtime.d.ts +793 -0
  63. package/dist/microsandbox/runtime.d.ts.map +1 -0
  64. package/dist/microsandbox/runtime.js +2303 -0
  65. package/dist/microsandbox/runtime.js.map +1 -0
  66. package/dist/modal/bench.d.ts +199 -0
  67. package/dist/modal/bench.d.ts.map +1 -0
  68. package/dist/modal/bench.js +450 -0
  69. package/dist/modal/bench.js.map +1 -0
  70. package/dist/modal/capabilities.d.ts +180 -0
  71. package/dist/modal/capabilities.d.ts.map +1 -0
  72. package/dist/modal/capabilities.js +159 -0
  73. package/dist/modal/capabilities.js.map +1 -0
  74. package/dist/modal/config.d.ts +192 -0
  75. package/dist/modal/config.d.ts.map +1 -0
  76. package/dist/modal/config.js +169 -0
  77. package/dist/modal/config.js.map +1 -0
  78. package/dist/modal/internal/sdk.d.ts +141 -0
  79. package/dist/modal/internal/sdk.d.ts.map +1 -0
  80. package/dist/modal/internal/sdk.js +51 -0
  81. package/dist/modal/internal/sdk.js.map +1 -0
  82. package/dist/modal/runtime.d.ts +271 -0
  83. package/dist/modal/runtime.d.ts.map +1 -0
  84. package/dist/modal/runtime.js +871 -0
  85. package/dist/modal/runtime.js.map +1 -0
  86. package/dist/mount-script.d.ts +16 -1
  87. package/dist/mount-script.d.ts.map +1 -1
  88. package/dist/mount-script.js +76 -15
  89. package/dist/mount-script.js.map +1 -1
  90. package/dist/orchestrator.d.ts +15 -0
  91. package/dist/orchestrator.d.ts.map +1 -1
  92. package/dist/orchestrator.js +13 -1
  93. package/dist/orchestrator.js.map +1 -1
  94. package/dist/port.d.ts +144 -6
  95. package/dist/port.d.ts.map +1 -1
  96. package/dist/port.js +27 -5
  97. package/dist/port.js.map +1 -1
  98. package/dist/types.d.ts +50 -1
  99. package/dist/types.d.ts.map +1 -1
  100. package/dist/vercel/bench.d.ts +169 -0
  101. package/dist/vercel/bench.d.ts.map +1 -0
  102. package/dist/vercel/bench.js +337 -0
  103. package/dist/vercel/bench.js.map +1 -0
  104. package/dist/vercel/capabilities.d.ts +106 -0
  105. package/dist/vercel/capabilities.d.ts.map +1 -0
  106. package/dist/vercel/capabilities.js +128 -0
  107. package/dist/vercel/capabilities.js.map +1 -0
  108. package/dist/vercel/config.d.ts +119 -0
  109. package/dist/vercel/config.d.ts.map +1 -0
  110. package/dist/vercel/config.js +8 -0
  111. package/dist/vercel/config.js.map +1 -0
  112. package/dist/vercel/internal/sdk.d.ts +173 -0
  113. package/dist/vercel/internal/sdk.d.ts.map +1 -0
  114. package/dist/vercel/internal/sdk.js +117 -0
  115. package/dist/vercel/internal/sdk.js.map +1 -0
  116. package/dist/vercel/runtime.d.ts +305 -0
  117. package/dist/vercel/runtime.d.ts.map +1 -0
  118. package/dist/vercel/runtime.js +1169 -0
  119. package/dist/vercel/runtime.js.map +1 -0
  120. package/docs/freestyle.md +110 -0
  121. package/package.json +35 -4
@@ -0,0 +1,119 @@
1
+ /**
2
+ * SDK-free configuration for the Vercel Sandbox adapter.
3
+ *
4
+ * Nothing in this module imports `@vercel/sandbox`. Consumers can construct and
5
+ * type-check a configuration without the optional peer dependency installed.
6
+ */
7
+ /**
8
+ * Credentials for the Vercel Sandbox API.
9
+ *
10
+ * Vercel Sandbox cannot be addressed with a bare API key: every request is
11
+ * scoped to a team and a project. `token` accepts either a personal access
12
+ * token or an OIDC token; the other two fields are required in both cases.
13
+ *
14
+ * These are always injected. The adapter never reads `VERCEL_TOKEN`,
15
+ * `VERCEL_TEAM_ID`, `VERCEL_PROJECT_ID`, or `VERCEL_OIDC_TOKEN` from ambient
16
+ * process state, because a runtime that silently picks up an operator's shell
17
+ * credentials cannot be reasoned about by its caller.
18
+ */
19
+ export interface VercelCredentials {
20
+ /** Personal access token or OIDC token. */
21
+ token: string;
22
+ /** Team that owns the project. */
23
+ teamId: string;
24
+ /** Project the sandboxes are created under. */
25
+ projectId: string;
26
+ }
27
+ /**
28
+ * Sandbox environment selection. Exactly one of the three forms — a
29
+ * caller-chosen image, the deprecated legacy runtime, or the provider default
30
+ * — mirroring the provider's own mutual exclusion between them.
31
+ */
32
+ export type VercelSandboxSource = {
33
+ type: "image";
34
+ image: string;
35
+ }
36
+ /** Legacy Vercel-managed runtime. Deprecated upstream; accepted for parity. */
37
+ | {
38
+ type: "runtime";
39
+ runtime: string;
40
+ }
41
+ /** Provider default (`vercel/sandbox/universal:latest` at time of writing). */
42
+ | {
43
+ type: "default";
44
+ };
45
+ export interface VercelRuntimeOptions extends VercelCredentials {
46
+ /**
47
+ * Prefix used to identify sandboxes this runtime is allowed to own.
48
+ *
49
+ * Ownership is by name, because a Vercel sandbox's name *is* its identity
50
+ * within a project. Every created sandbox is named `<prefix>-<suffix>`, and
51
+ * the adapter refuses to mutate or delete anything outside that prefix.
52
+ */
53
+ namePrefix: string;
54
+ /**
55
+ * Image-specific home directory. Required because no default is correct for
56
+ * every image; the managed universal image uses `/vercel/sandbox`.
57
+ */
58
+ defaultHomeDir: string;
59
+ /** Explicit environment selection; the adapter never picks an image itself. */
60
+ source?: VercelSandboxSource;
61
+ /**
62
+ * vCPUs per sandbox. The provider allocates 2048 MB of memory per vCPU, so
63
+ * memory is not separately configurable. Omitted means the provider default.
64
+ */
65
+ vcpus?: number;
66
+ /**
67
+ * Wall-clock lifetime in milliseconds after which the provider terminates
68
+ * the sandbox. Vercel has no never-idle tier: a sandbox always carries a
69
+ * termination deadline, so this is a real bound and not a hint.
70
+ */
71
+ sandboxTimeoutMs?: number;
72
+ /**
73
+ * Whether the provider restores the filesystem across sessions. Explicit
74
+ * because the durability contract differs materially between the two.
75
+ */
76
+ persistent?: boolean;
77
+ /** Ports to expose. The provider caps this at 15. */
78
+ ports?: readonly number[];
79
+ /**
80
+ * Default environment variables baked into the sandbox at create time and
81
+ * inherited by every command.
82
+ */
83
+ env?: Readonly<Record<string, string>>;
84
+ /** Fallback per-request deadline for operations without a specific one. */
85
+ requestTimeoutMs?: number;
86
+ /** Total deadline for sandbox creation. */
87
+ createTimeoutMs?: number;
88
+ /** Total deadline for list/get lookups. */
89
+ lookupTimeoutMs?: number;
90
+ /** Default total deadline for a command when the caller supplies none. */
91
+ execTimeoutMs?: number;
92
+ /** Total deadline for a single file read/write/mkdir. */
93
+ fileTimeoutMs?: number;
94
+ /** Deadline for a lifecycle transition to reach a settled state. */
95
+ lifecycleTimeoutMs?: number;
96
+ /** Deadline for delete submission plus verification of absence. */
97
+ deleteTimeoutMs?: number;
98
+ /** Lifecycle and delete-verification polling interval. */
99
+ pollIntervalMs?: number;
100
+ /**
101
+ * Absolute ceiling on any single SDK call including the SDK's own internal
102
+ * retries.
103
+ *
104
+ * The vendor SDK retries some failures internally (it depends on
105
+ * `async-retry`). Without an absolute signal that spans the whole call, a
106
+ * request that is retried N times can outlive the caller's deadline by a
107
+ * multiple of it. This value caps the entire retry chain, not one attempt.
108
+ */
109
+ retryDeadlineMs?: number;
110
+ /** Page size used when listing sandboxes. */
111
+ listPageSize?: number;
112
+ /**
113
+ * Hard cap on pages walked during a single listing, so a large or
114
+ * pathologically paginated project cannot turn a lookup into an unbounded
115
+ * crawl. Exceeding it is an error, never a silently truncated result.
116
+ */
117
+ maxListPages?: number;
118
+ }
119
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/vercel/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAClC,+EAA+E;GAC7E;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACtC,+EAA+E;GAC7E;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAExB,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAQvC,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2CAA2C;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * SDK-free configuration for the Vercel Sandbox adapter.
3
+ *
4
+ * Nothing in this module imports `@vercel/sandbox`. Consumers can construct and
5
+ * type-check a configuration without the optional peer dependency installed.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/vercel/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,173 @@
1
+ import type { Buffer } from "node:buffer";
2
+ import type { VercelCredentials } from "../config.js";
3
+ /**
4
+ * The vendor SDK boundary.
5
+ *
6
+ * This is the only module in the package that imports `@vercel/sandbox`, and
7
+ * the import is dynamic so the dependency stays genuinely optional. Everything
8
+ * above this file talks to the structural `*Like` interfaces below, which is
9
+ * what makes the adapter testable without the SDK and pinnable to one version.
10
+ */
11
+ /** Session status as reported by the provider. */
12
+ export type VercelSandboxStatus = "pending" | "running" | "stopping" | "stopped" | "failed" | "aborted" | "snapshotting" | (string & {});
13
+ /** A row from `Sandbox.list`. */
14
+ export interface VercelSandboxListItem {
15
+ name: string;
16
+ status: VercelSandboxStatus;
17
+ createdAt: number;
18
+ updatedAt?: number;
19
+ persistent?: boolean;
20
+ region?: string;
21
+ vcpus?: number;
22
+ memory?: number;
23
+ image?: string;
24
+ runtime?: string;
25
+ timeout?: number;
26
+ tags?: Record<string, string>;
27
+ expiresAt?: number;
28
+ totalActiveCpuDurationMs?: number;
29
+ totalDurationMs?: number;
30
+ totalEgressBytes?: number;
31
+ totalIngressBytes?: number;
32
+ }
33
+ export interface VercelSandboxListPage {
34
+ sandboxes: VercelSandboxListItem[];
35
+ pagination: {
36
+ count: number;
37
+ next: string | null;
38
+ };
39
+ }
40
+ export interface VercelListParams {
41
+ namePrefix?: string;
42
+ tags?: Record<string, string>;
43
+ limit?: number;
44
+ cursor?: string;
45
+ signal?: AbortSignal;
46
+ }
47
+ export interface VercelCreateParams {
48
+ name: string;
49
+ tags?: Record<string, string>;
50
+ env?: Record<string, string>;
51
+ ports?: number[];
52
+ timeout?: number;
53
+ persistent?: boolean;
54
+ resources?: {
55
+ vcpus: number;
56
+ };
57
+ image?: string;
58
+ runtime?: string;
59
+ signal?: AbortSignal;
60
+ }
61
+ export interface VercelRunCommandParams {
62
+ cmd: string;
63
+ args?: string[];
64
+ cwd?: string;
65
+ env?: Record<string, string>;
66
+ sudo?: boolean;
67
+ detached?: boolean;
68
+ timeoutMs?: number;
69
+ signal?: AbortSignal;
70
+ }
71
+ /**
72
+ * A command in a sandbox.
73
+ *
74
+ * `exitCode` is `null` while a detached command is still running and after a
75
+ * re-resolution that has not observed an exit yet. It is never a stand-in for
76
+ * success.
77
+ */
78
+ export interface VercelCommandLike {
79
+ readonly cmdId: string;
80
+ readonly exitCode: number | null;
81
+ output(stream?: "stdout" | "stderr" | "both", opts?: {
82
+ signal?: AbortSignal;
83
+ }): Promise<string>;
84
+ }
85
+ export interface VercelSessionLike {
86
+ readonly sessionId: string;
87
+ }
88
+ export interface VercelSandboxLike {
89
+ readonly name: string;
90
+ readonly status: VercelSandboxStatus;
91
+ readonly createdAt: Date;
92
+ readonly updatedAt: Date;
93
+ readonly vcpus?: number;
94
+ readonly memory?: number;
95
+ readonly timeout?: number;
96
+ readonly tags?: Record<string, string>;
97
+ readonly expiresAt?: Date;
98
+ readonly totalActiveCpuDurationMs?: number;
99
+ readonly totalDurationMs?: number;
100
+ currentSession(): VercelSessionLike;
101
+ runCommand(params: VercelRunCommandParams): Promise<VercelCommandLike>;
102
+ getCommand(cmdId: string, opts?: {
103
+ signal?: AbortSignal;
104
+ }): Promise<VercelCommandLike>;
105
+ writeFiles(files: Array<{
106
+ path: string;
107
+ content: string | Uint8Array;
108
+ mode?: number;
109
+ }>, opts?: {
110
+ signal?: AbortSignal;
111
+ }): Promise<void>;
112
+ readFileToBuffer(file: {
113
+ path: string;
114
+ cwd?: string;
115
+ }, opts?: {
116
+ signal?: AbortSignal;
117
+ }): Promise<Buffer | null>;
118
+ mkDir(path: string, opts?: {
119
+ signal?: AbortSignal;
120
+ }): Promise<void>;
121
+ stop(opts?: {
122
+ signal?: AbortSignal;
123
+ }): Promise<unknown>;
124
+ delete(opts?: {
125
+ signal?: AbortSignal;
126
+ }): Promise<void>;
127
+ }
128
+ /** The provider surface this adapter depends on, and nothing more. */
129
+ export interface VercelSandboxApiLike {
130
+ create(params: VercelCreateParams): Promise<VercelSandboxLike>;
131
+ get(params: {
132
+ name: string;
133
+ resume?: boolean;
134
+ signal?: AbortSignal;
135
+ }): Promise<VercelSandboxLike>;
136
+ list(params: VercelListParams): Promise<VercelSandboxListPage>;
137
+ }
138
+ export type VercelSandboxApiFactory = () => Promise<VercelSandboxApiLike> | VercelSandboxApiLike;
139
+ /**
140
+ * True when the provider reports the named sandbox as absent.
141
+ *
142
+ * Delete verification and reattach both need to tell "gone" apart from "the
143
+ * lookup failed", and treating a transport error as absence is how a leaked
144
+ * sandbox gets reported as cleaned up.
145
+ */
146
+ export declare function isVercelNotFoundError(error: unknown): boolean;
147
+ /** Run `fn` with an absolute deadline applied to every request it triggers. */
148
+ export declare function withRequestDeadline<T>(timeoutMs: number, fn: () => Promise<T>): Promise<T>;
149
+ /** The deadline signal in force, if any. Exported for the adapter's callers. */
150
+ export declare function currentRequestDeadlineSignal(): AbortSignal | undefined;
151
+ /**
152
+ * Wrap `fetch` so every request also observes the ambient operation deadline.
153
+ *
154
+ * `AbortSignal.any` keeps the caller's own per-request signal intact instead of
155
+ * replacing it, so an explicit cancellation and a deadline expiry both work.
156
+ */
157
+ export declare function deadlineBoundFetch(baseFetch?: typeof globalThis.fetch): typeof globalThis.fetch;
158
+ /**
159
+ * The official client, bound to injected credentials and the deadline-aware
160
+ * fetch.
161
+ *
162
+ * Credentials are passed explicitly on every static call rather than left to
163
+ * the SDK's ambient resolution, which would otherwise fall back to the
164
+ * operator's environment or an on-disk OAuth token.
165
+ *
166
+ * Note what this function does *not* do: cast. Each vendor result is assigned
167
+ * **through** the structural type above, so if the SDK changes a signature the
168
+ * build breaks here, in the one file that owns the boundary. An
169
+ * `as unknown as` would accept the drift silently and surface it later as a
170
+ * runtime failure against a live sandbox.
171
+ */
172
+ export declare function createOfficialVercelSandboxApi(credentials: VercelCredentials): Promise<VercelSandboxApiLike>;
173
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/vercel/internal/sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;;GAOG;AAEH,kDAAkD;AAClD,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,SAAS,GACT,UAAU,GACV,SAAS,GACT,QAAQ,GACR,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AwB,GACpD,OAAO,UAAU,CAAC,KAAK,CAWzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CA0C/B"}
@@ -0,0 +1,117 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ /**
3
+ * True when the provider reports the named sandbox as absent.
4
+ *
5
+ * Delete verification and reattach both need to tell "gone" apart from "the
6
+ * lookup failed", and treating a transport error as absence is how a leaked
7
+ * sandbox gets reported as cleaned up.
8
+ */
9
+ export function isVercelNotFoundError(error) {
10
+ if (!error || typeof error !== "object") {
11
+ return false;
12
+ }
13
+ const status = error.response?.status;
14
+ if (status === 404) {
15
+ return true;
16
+ }
17
+ const code = error.json?.error
18
+ ?.code;
19
+ return code === "not_found" || code === "sandbox_not_found";
20
+ }
21
+ /**
22
+ * Absolute deadline for one logical operation, including SDK-internal retries.
23
+ *
24
+ * The vendor SDK retries some failures itself. A per-attempt timeout therefore
25
+ * bounds nothing: N retries multiply it. This store carries a single signal for
26
+ * the whole operation, and the fetch wrapper below joins it onto every request
27
+ * the SDK makes inside that operation — retries included.
28
+ *
29
+ * `AsyncLocalStorage` rather than a mutable field because operations on one
30
+ * runtime run concurrently, and a shared cell would let a short lookup abort a
31
+ * long exec that happened to overlap it.
32
+ */
33
+ const operationDeadline = new AsyncLocalStorage();
34
+ /** Run `fn` with an absolute deadline applied to every request it triggers. */
35
+ export function withRequestDeadline(timeoutMs, fn) {
36
+ return operationDeadline.run(AbortSignal.timeout(timeoutMs), fn);
37
+ }
38
+ /** The deadline signal in force, if any. Exported for the adapter's callers. */
39
+ export function currentRequestDeadlineSignal() {
40
+ return operationDeadline.getStore();
41
+ }
42
+ /**
43
+ * Wrap `fetch` so every request also observes the ambient operation deadline.
44
+ *
45
+ * `AbortSignal.any` keeps the caller's own per-request signal intact instead of
46
+ * replacing it, so an explicit cancellation and a deadline expiry both work.
47
+ */
48
+ export function deadlineBoundFetch(baseFetch = globalThis.fetch) {
49
+ return (input, init) => {
50
+ const deadline = operationDeadline.getStore();
51
+ if (!deadline) {
52
+ return baseFetch(input, init);
53
+ }
54
+ const signal = init?.signal
55
+ ? AbortSignal.any([init.signal, deadline])
56
+ : deadline;
57
+ return baseFetch(input, { ...init, signal });
58
+ };
59
+ }
60
+ /**
61
+ * The official client, bound to injected credentials and the deadline-aware
62
+ * fetch.
63
+ *
64
+ * Credentials are passed explicitly on every static call rather than left to
65
+ * the SDK's ambient resolution, which would otherwise fall back to the
66
+ * operator's environment or an on-disk OAuth token.
67
+ *
68
+ * Note what this function does *not* do: cast. Each vendor result is assigned
69
+ * **through** the structural type above, so if the SDK changes a signature the
70
+ * build breaks here, in the one file that owns the boundary. An
71
+ * `as unknown as` would accept the drift silently and surface it later as a
72
+ * runtime failure against a live sandbox.
73
+ */
74
+ export async function createOfficialVercelSandboxApi(credentials) {
75
+ const { Sandbox } = await import("@vercel/sandbox");
76
+ const fetch = deadlineBoundFetch();
77
+ const auth = {
78
+ token: credentials.token,
79
+ teamId: credentials.teamId,
80
+ projectId: credentials.projectId,
81
+ };
82
+ return {
83
+ create: async (params) => {
84
+ const { image, runtime, ...rest } = params;
85
+ // `image` and `runtime` are mutually exclusive upstream, so the call is
86
+ // narrowed to one branch instead of handing over an object that claims
87
+ // both are possible.
88
+ const created = runtime
89
+ ? await Sandbox.create({ ...rest, runtime, ...auth, fetch })
90
+ : await Sandbox.create({
91
+ ...rest,
92
+ ...(image ? { image } : {}),
93
+ ...auth,
94
+ fetch,
95
+ });
96
+ const checked = created;
97
+ return checked;
98
+ },
99
+ get: async (params) => {
100
+ const checked = await Sandbox.get({
101
+ ...params,
102
+ ...auth,
103
+ fetch,
104
+ });
105
+ return checked;
106
+ },
107
+ list: async (params) => {
108
+ const checked = await Sandbox.list({
109
+ ...params,
110
+ ...auth,
111
+ fetch,
112
+ });
113
+ return checked;
114
+ },
115
+ };
116
+ }
117
+ //# sourceMappingURL=sdk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