@giselles-ai/sandkit 0.1.0

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +163 -0
  3. package/dist/adapters/drizzle.d.ts +83 -0
  4. package/dist/adapters/drizzle.js +9 -0
  5. package/dist/adapters/drizzle.js.map +1 -0
  6. package/dist/adapters/memory.d.ts +6 -0
  7. package/dist/adapters/memory.js +8 -0
  8. package/dist/adapters/memory.js.map +1 -0
  9. package/dist/adapters/sqlite-bun.d.ts +7 -0
  10. package/dist/adapters/sqlite-bun.js +8 -0
  11. package/dist/adapters/sqlite-bun.js.map +1 -0
  12. package/dist/bin.js +697 -0
  13. package/dist/bin.js.map +1 -0
  14. package/dist/chunk-7DLK7LOM.js +44 -0
  15. package/dist/chunk-7DLK7LOM.js.map +1 -0
  16. package/dist/chunk-BDPTYR6V.js +407 -0
  17. package/dist/chunk-BDPTYR6V.js.map +1 -0
  18. package/dist/chunk-CSOBTLWV.js +202 -0
  19. package/dist/chunk-CSOBTLWV.js.map +1 -0
  20. package/dist/chunk-DLGUA3H7.js +9 -0
  21. package/dist/chunk-DLGUA3H7.js.map +1 -0
  22. package/dist/chunk-FSDVHEEX.js +45 -0
  23. package/dist/chunk-FSDVHEEX.js.map +1 -0
  24. package/dist/chunk-HVYCAAZQ.js +25 -0
  25. package/dist/chunk-HVYCAAZQ.js.map +1 -0
  26. package/dist/chunk-LC3IYBAL.js +100 -0
  27. package/dist/chunk-LC3IYBAL.js.map +1 -0
  28. package/dist/chunk-REGOUXVI.js +58 -0
  29. package/dist/chunk-REGOUXVI.js.map +1 -0
  30. package/dist/chunk-RMMOQD5Y.js +211 -0
  31. package/dist/chunk-RMMOQD5Y.js.map +1 -0
  32. package/dist/chunk-UDFWES6J.js +486 -0
  33. package/dist/chunk-UDFWES6J.js.map +1 -0
  34. package/dist/chunk-VISDS5T7.js +202 -0
  35. package/dist/chunk-VISDS5T7.js.map +1 -0
  36. package/dist/chunk-XM4HGRXW.js +37 -0
  37. package/dist/chunk-XM4HGRXW.js.map +1 -0
  38. package/dist/cli/index.d.ts +19 -0
  39. package/dist/cli/index.js +397 -0
  40. package/dist/cli/index.js.map +1 -0
  41. package/dist/index.d.ts +78 -0
  42. package/dist/index.js +1102 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/integrations/mock.d.ts +19 -0
  45. package/dist/integrations/mock.js +207 -0
  46. package/dist/integrations/mock.js.map +1 -0
  47. package/dist/integrations/vercel.d.ts +7 -0
  48. package/dist/integrations/vercel.js +400 -0
  49. package/dist/integrations/vercel.js.map +1 -0
  50. package/dist/policies/ai-gateway.d.ts +15 -0
  51. package/dist/policies/ai-gateway.js +12 -0
  52. package/dist/policies/ai-gateway.js.map +1 -0
  53. package/dist/policies/codex.d.ts +10 -0
  54. package/dist/policies/codex.js +12 -0
  55. package/dist/policies/codex.js.map +1 -0
  56. package/dist/policies/gemini.d.ts +10 -0
  57. package/dist/policies/gemini.js +12 -0
  58. package/dist/policies/gemini.js.map +1 -0
  59. package/dist/schema/index.d.ts +60 -0
  60. package/dist/schema/index.js +31 -0
  61. package/dist/schema/index.js.map +1 -0
  62. package/dist/types-BCgprbo8.d.ts +47 -0
  63. package/dist/types-BEKQnjeb.d.ts +139 -0
  64. package/dist/types-Cy36bS1j.d.ts +138 -0
  65. package/package.json +126 -0
@@ -0,0 +1,400 @@
1
+ import {
2
+ resolveGithubDefaultApiKey
3
+ } from "../chunk-XM4HGRXW.js";
4
+ import {
5
+ resolveCodexDefaultApiKey
6
+ } from "../chunk-FSDVHEEX.js";
7
+ import {
8
+ resolveGeminiDefaultApiKey
9
+ } from "../chunk-7DLK7LOM.js";
10
+ import {
11
+ resolveAiGatewayDefaultApiKey
12
+ } from "../chunk-REGOUXVI.js";
13
+ import {
14
+ createSandboxProvider
15
+ } from "../chunk-HVYCAAZQ.js";
16
+ import "../chunk-VISDS5T7.js";
17
+
18
+ // src/drivers/vercel-sandbox.ts
19
+ import { Sandbox } from "@vercel/sandbox";
20
+
21
+ // src/policies/default-credentials.ts
22
+ function resolveDefaultCredentialValue(serviceId) {
23
+ switch (serviceId) {
24
+ case "codex":
25
+ return resolveCodexDefaultApiKey();
26
+ case "gemini":
27
+ return resolveGeminiDefaultApiKey();
28
+ case "github":
29
+ return resolveGithubDefaultApiKey();
30
+ case "aiGateway":
31
+ return resolveAiGatewayDefaultApiKey();
32
+ default:
33
+ return void 0;
34
+ }
35
+ }
36
+ function describeDefaultCredentialSource(serviceId) {
37
+ switch (serviceId) {
38
+ case "codex":
39
+ return "CODEX_API_KEY";
40
+ case "gemini":
41
+ return "GEMINI_API_KEY";
42
+ case "github":
43
+ return "GITHUB_TOKEN";
44
+ case "aiGateway":
45
+ return "AI_GATEWAY_API_KEY";
46
+ default:
47
+ return `default credential for service "${serviceId}"`;
48
+ }
49
+ }
50
+
51
+ // src/drivers/vercel-network-policy.ts
52
+ function resolveCredentialValue(serviceId, header) {
53
+ if (header.credential.kind === "value") {
54
+ return header.credential.value;
55
+ }
56
+ if (header.credential.kind === "default") {
57
+ const value = resolveDefaultCredentialValue(serviceId);
58
+ if (!value) {
59
+ throw new Error(
60
+ `Workspace policy for service "${serviceId}" requires ${describeDefaultCredentialSource(serviceId)}.`
61
+ );
62
+ }
63
+ return value;
64
+ }
65
+ throw new Error(
66
+ `Workspace policy for service "${serviceId}" contains a redacted credential and cannot be applied.`
67
+ );
68
+ }
69
+ function compileHeaderRules(serviceId, headers) {
70
+ if (!headers || headers.length === 0) {
71
+ return [];
72
+ }
73
+ const resolvedHeaders = Object.fromEntries(
74
+ headers.map((header) => [
75
+ header.headerName,
76
+ `${header.valuePrefix ?? ""}${resolveCredentialValue(serviceId, header)}`
77
+ ])
78
+ );
79
+ return [
80
+ {
81
+ transform: [
82
+ {
83
+ headers: resolvedHeaders
84
+ }
85
+ ]
86
+ }
87
+ ];
88
+ }
89
+ function compileVercelNetworkPolicy(policy) {
90
+ switch (policy.mode) {
91
+ case "allow-all":
92
+ return "allow-all";
93
+ case "deny-all":
94
+ return "deny-all";
95
+ case "allow-services": {
96
+ const allow = {};
97
+ for (const service of policy.services) {
98
+ const rules = compileHeaderRules(service.id, service.headers);
99
+ for (const domain of service.domains) {
100
+ const existing = allow[domain] ?? [];
101
+ allow[domain] = [...existing, ...rules];
102
+ }
103
+ }
104
+ return { allow };
105
+ }
106
+ }
107
+ }
108
+
109
+ // src/drivers/vercel-sandbox.ts
110
+ var VercelSandboxDriver = class {
111
+ #sandbox;
112
+ provider = "vercel-sandbox";
113
+ constructor(sandbox) {
114
+ this.#sandbox = sandbox;
115
+ }
116
+ get id() {
117
+ return this.#sandbox.sandboxId;
118
+ }
119
+ async applyPolicy(policy) {
120
+ await this.#sandbox.updateNetworkPolicy(compileVercelNetworkPolicy(policy));
121
+ }
122
+ async getSessionLease() {
123
+ const sandbox = this.#sandbox;
124
+ const observedAt = (/* @__PURE__ */ new Date()).toISOString();
125
+ const timeoutMs = typeof sandbox.timeout === "number" && Number.isFinite(sandbox.timeout) && sandbox.timeout > 0 ? sandbox.timeout : 6e4;
126
+ return {
127
+ sandboxId: sandbox.sandboxId,
128
+ observedAt,
129
+ expiresAt: new Date(Date.parse(observedAt) + timeoutMs).toISOString()
130
+ };
131
+ }
132
+ async runCommand(command, args) {
133
+ const result = await this.#sandbox.runCommand(command, args);
134
+ const finished = await this.#toCommandFinished(result);
135
+ return {
136
+ exitCode: finished.exitCode,
137
+ stdout: await finished.stdout(),
138
+ stderr: await finished.stderr()
139
+ };
140
+ }
141
+ async startProcess(input) {
142
+ const started = await this.#sandbox.runCommand({
143
+ cmd: input.command,
144
+ args: [...input.args],
145
+ detached: true
146
+ });
147
+ if (!isVercelCommandHandle(started)) {
148
+ throw new Error("Unexpected Vercel sandbox startProcess() response shape.");
149
+ }
150
+ const processId = started.cmdId ?? `${this.#sandbox.sandboxId}-${Date.now()}`;
151
+ const commandLogBroadcast = createCommandLogBroadcaster(
152
+ getCommandLogIterator(started),
153
+ input.onStdout,
154
+ input.onStderr
155
+ );
156
+ return {
157
+ processId,
158
+ wait: async () => {
159
+ const finished = await started.wait();
160
+ return {
161
+ exitCode: finished.exitCode,
162
+ stdout: await finished.stdout(),
163
+ stderr: await finished.stderr()
164
+ };
165
+ },
166
+ logs: commandLogBroadcast ? () => commandLogBroadcast() : void 0
167
+ };
168
+ }
169
+ async url(port) {
170
+ try {
171
+ return this.#sandbox.domain(port);
172
+ } catch (error) {
173
+ if (!(error instanceof Error) || !error.message.includes("No route for port")) {
174
+ throw error;
175
+ }
176
+ const refreshed = await Sandbox.get({ sandboxId: this.#sandbox.sandboxId });
177
+ return refreshed.domain(port);
178
+ }
179
+ }
180
+ async extendTimeout(durationMs) {
181
+ const extendTimeout = this.#sandbox.extendTimeout;
182
+ if (!extendTimeout) {
183
+ throw new Error("This Vercel sandbox does not support extendTimeout().");
184
+ }
185
+ await extendTimeout.call(this.#sandbox, durationMs);
186
+ }
187
+ async snapshot() {
188
+ const snapshot = await this.#sandbox.snapshot();
189
+ return {
190
+ kind: "vercel-sandbox-snapshot",
191
+ sessionId: this.#sandbox.sandboxId,
192
+ state: {
193
+ snapshotId: snapshot.snapshotId
194
+ }
195
+ };
196
+ }
197
+ async #toCommandFinished(raw) {
198
+ if (typeof raw !== "object" || raw === null) {
199
+ throw new Error("Unexpected Vercel sandbox command response");
200
+ }
201
+ const candidate = raw;
202
+ if (candidate.wait) {
203
+ return candidate.wait();
204
+ }
205
+ return raw;
206
+ }
207
+ };
208
+ function isVercelCommandHandle(value) {
209
+ if (typeof value !== "object" || value === null) {
210
+ return false;
211
+ }
212
+ const candidate = value;
213
+ if (typeof candidate.wait !== "function") {
214
+ return false;
215
+ }
216
+ return candidate.cmdId === void 0 || typeof candidate.cmdId === "string";
217
+ }
218
+ function isIterable(value) {
219
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value[Symbol.iterator] === "function";
220
+ }
221
+ function isAsyncIterable(value) {
222
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value[Symbol.asyncIterator] === "function";
223
+ }
224
+ function getCommandLogIterator(raw) {
225
+ const rawLogs = raw.logs?.();
226
+ if (rawLogs === void 0) {
227
+ return void 0;
228
+ }
229
+ if (isAsyncIterable(rawLogs)) {
230
+ return rawLogs;
231
+ }
232
+ if (isIterable(rawLogs)) {
233
+ return toAsyncIterableFromSync(rawLogs);
234
+ }
235
+ return void 0;
236
+ }
237
+ function toAsyncIterableFromSync(iterable) {
238
+ return {
239
+ async *[Symbol.asyncIterator]() {
240
+ for (const value of iterable) {
241
+ yield value;
242
+ }
243
+ }
244
+ };
245
+ }
246
+ function createCommandLogBroadcaster(logs, onStdout, onStderr) {
247
+ if (!logs) {
248
+ return void 0;
249
+ }
250
+ const bufferedLogs = [];
251
+ const waiters = [];
252
+ let completed = false;
253
+ let error = null;
254
+ let pumpStarted = false;
255
+ const notifyWaiters = () => {
256
+ while (waiters.length > 0) {
257
+ waiters.pop()?.();
258
+ }
259
+ };
260
+ const run = async () => {
261
+ if (pumpStarted) {
262
+ return;
263
+ }
264
+ pumpStarted = true;
265
+ try {
266
+ for await (const log of logs) {
267
+ const normalized = normalizeCommandLog(log);
268
+ if (!normalized) {
269
+ continue;
270
+ }
271
+ bufferedLogs.push(normalized);
272
+ if (normalized.stream === "stderr") {
273
+ onStderr?.(normalized.chunk);
274
+ } else {
275
+ onStdout?.(normalized.chunk);
276
+ }
277
+ notifyWaiters();
278
+ }
279
+ } catch (cause) {
280
+ error = cause;
281
+ } finally {
282
+ completed = true;
283
+ notifyWaiters();
284
+ }
285
+ };
286
+ void run().catch(() => {
287
+ });
288
+ const waitForWork = () => {
289
+ return new Promise((resolve) => {
290
+ waiters.push(resolve);
291
+ });
292
+ };
293
+ const createLogIterable = () => {
294
+ return {
295
+ async *[Symbol.asyncIterator]() {
296
+ let index = 0;
297
+ while (true) {
298
+ if (index < bufferedLogs.length) {
299
+ yield bufferedLogs[index++];
300
+ continue;
301
+ }
302
+ if (error !== null) {
303
+ throw error instanceof Error ? error : new Error("startProcess logs failed.");
304
+ }
305
+ if (completed) {
306
+ return;
307
+ }
308
+ await waitForWork();
309
+ }
310
+ }
311
+ };
312
+ };
313
+ return createLogIterable;
314
+ }
315
+ function normalizeCommandLog(log) {
316
+ if (typeof log === "string") {
317
+ return { stream: "stdout", chunk: log };
318
+ }
319
+ if (typeof log !== "object" || log === null) {
320
+ return null;
321
+ }
322
+ const candidate = log;
323
+ const streamValue = candidate.stream;
324
+ const stream = streamValue === "stderr" || streamValue === "stdout" ? streamValue : "stdout";
325
+ const rawChunk = candidate.data ?? candidate.output ?? candidate.chunk ?? candidate.text ?? candidate.message ?? null;
326
+ if (typeof rawChunk !== "string") {
327
+ return null;
328
+ }
329
+ return { stream, chunk: rawChunk };
330
+ }
331
+ var VercelSandboxDriverFactory = class {
332
+ #runtime;
333
+ #defaultTimeout;
334
+ constructor(options = {}) {
335
+ this.#runtime = options.runtime ?? "node24";
336
+ this.#defaultTimeout = normalizeSandboxTimeout(
337
+ options.defaultTimeout ?? options.timeout,
338
+ "Vercel sandbox default timeout"
339
+ );
340
+ }
341
+ isSessionUnavailableError(error) {
342
+ if (!(error instanceof Error)) {
343
+ return false;
344
+ }
345
+ const message = error.message.toLowerCase();
346
+ return message.includes("not found") || message.includes("does not exist") || message.includes("sandbox_stopped") || message.includes("sandbox stopped");
347
+ }
348
+ async createSandbox(_workspace, options) {
349
+ const timeout = this.#defaultTimeoutForCreate(options);
350
+ const sandbox = await Sandbox.create({
351
+ runtime: this.#runtime,
352
+ timeout,
353
+ ports: options.exposedPorts,
354
+ networkPolicy: compileVercelNetworkPolicy(options.policy)
355
+ });
356
+ return new VercelSandboxDriver(sandbox);
357
+ }
358
+ async resumeSandbox(workspace, snapshot, options) {
359
+ const timeout = this.#defaultTimeoutForCreate(options);
360
+ const state = snapshot.state;
361
+ const snapshotId = state?.snapshotId;
362
+ const fallbackSandboxId = workspace.sandboxId ?? snapshot.sessionId;
363
+ const sandbox = snapshotId === void 0 || typeof snapshotId !== "string" ? await (fallbackSandboxId === void 0 ? (() => {
364
+ throw new Error("Persisted sandbox state is missing restore information");
365
+ })() : Sandbox.get({ sandboxId: fallbackSandboxId })) : await Sandbox.create({
366
+ source: {
367
+ type: "snapshot",
368
+ snapshotId
369
+ },
370
+ timeout,
371
+ ports: options.exposedPorts,
372
+ networkPolicy: compileVercelNetworkPolicy(options.policy)
373
+ });
374
+ return new VercelSandboxDriver(sandbox);
375
+ }
376
+ #defaultTimeoutForCreate(options) {
377
+ return normalizeSandboxTimeout(options.timeoutMs ?? this.#defaultTimeout, "runtime timeout");
378
+ }
379
+ };
380
+ function normalizeSandboxTimeout(value, label) {
381
+ if (value === void 0) {
382
+ return 6e4;
383
+ }
384
+ if (typeof value !== "number" || !Number.isInteger(value) || !Number.isFinite(value) || value <= 0) {
385
+ throw new Error(`${label} must be a positive integer in milliseconds.`);
386
+ }
387
+ return value;
388
+ }
389
+ function createVercelSandboxDriverFactory(options = {}) {
390
+ return new VercelSandboxDriverFactory(options);
391
+ }
392
+
393
+ // src/integrations/vercel.ts
394
+ function vercelSandbox(options = {}) {
395
+ return createSandboxProvider("vercel", createVercelSandboxDriverFactory(options));
396
+ }
397
+ export {
398
+ vercelSandbox
399
+ };
400
+ //# sourceMappingURL=vercel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drivers/vercel-sandbox.ts","../../src/policies/default-credentials.ts","../../src/drivers/vercel-network-policy.ts","../../src/integrations/vercel.ts"],"sourcesContent":["import { Sandbox } from \"@vercel/sandbox\";\n\nimport type { WorkspacePolicy } from \"../policies/types.ts\";\nimport type {\n CommandResult,\n PersistedSandboxState,\n SandboxSessionLease,\n SandboxDriver,\n WorkspaceSessionLog,\n WorkspaceSessionProcess,\n WorkspaceSessionProcessStartInput,\n SandboxCreateOptions,\n SandboxDriverFactory,\n WorkspaceRecord,\n VercelSandboxOptions,\n} from \"../types.ts\";\nimport { compileVercelNetworkPolicy } from \"./vercel-network-policy.ts\";\n\ninterface VercelCommandFinished {\n exitCode: number;\n stdout(): Promise<string>;\n stderr(): Promise<string>;\n}\n\ninterface VercelCommandHandle {\n wait(): Promise<VercelCommandFinished>;\n readonly cmdId?: string;\n readonly logs?: () => unknown;\n}\n\ninterface VercelPersistedState {\n snapshotId?: string;\n}\n\nclass VercelSandboxDriver implements SandboxDriver {\n readonly #sandbox: Awaited<ReturnType<typeof Sandbox.get>>;\n readonly provider = \"vercel-sandbox\";\n\n constructor(sandbox: Awaited<ReturnType<typeof Sandbox.get>>) {\n this.#sandbox = sandbox;\n }\n\n get id(): string {\n return this.#sandbox.sandboxId;\n }\n\n async applyPolicy(policy: WorkspacePolicy): Promise<void> {\n await this.#sandbox.updateNetworkPolicy(compileVercelNetworkPolicy(policy));\n }\n\n async getSessionLease(): Promise<SandboxSessionLease> {\n const sandbox = this.#sandbox;\n const observedAt = new Date().toISOString();\n const timeoutMs =\n typeof sandbox.timeout === \"number\" && Number.isFinite(sandbox.timeout) && sandbox.timeout > 0\n ? sandbox.timeout\n : 60_000;\n\n return {\n sandboxId: sandbox.sandboxId,\n observedAt,\n expiresAt: new Date(Date.parse(observedAt) + timeoutMs).toISOString(),\n };\n }\n\n async runCommand(command: string, args: string[]): Promise<CommandResult> {\n const result = await this.#sandbox.runCommand(command, args);\n const finished = await this.#toCommandFinished(result);\n\n return {\n exitCode: finished.exitCode,\n stdout: await finished.stdout(),\n stderr: await finished.stderr(),\n };\n }\n\n async startProcess(input: WorkspaceSessionProcessStartInput): Promise<WorkspaceSessionProcess> {\n const started = await this.#sandbox.runCommand({\n cmd: input.command,\n args: [...input.args],\n detached: true,\n });\n if (!isVercelCommandHandle(started)) {\n throw new Error(\"Unexpected Vercel sandbox startProcess() response shape.\");\n }\n\n const processId = started.cmdId ?? `${this.#sandbox.sandboxId}-${Date.now()}`;\n const commandLogBroadcast = createCommandLogBroadcaster(\n getCommandLogIterator(started),\n input.onStdout,\n input.onStderr,\n );\n\n return {\n processId,\n wait: async (): Promise<CommandResult> => {\n const finished = await started.wait();\n return {\n exitCode: finished.exitCode,\n stdout: await finished.stdout(),\n stderr: await finished.stderr(),\n };\n },\n logs: commandLogBroadcast ? () => commandLogBroadcast() : undefined,\n };\n }\n\n async url(port: number): Promise<string> {\n try {\n return this.#sandbox.domain(port);\n } catch (error) {\n if (!(error instanceof Error) || !error.message.includes(\"No route for port\")) {\n throw error;\n }\n\n const refreshed = await Sandbox.get({ sandboxId: this.#sandbox.sandboxId });\n return refreshed.domain(port);\n }\n }\n\n async extendTimeout(durationMs: number): Promise<void> {\n const extendTimeout = (\n this.#sandbox as { extendTimeout?: (durationMs: number) => Promise<unknown> }\n ).extendTimeout;\n if (!extendTimeout) {\n throw new Error(\"This Vercel sandbox does not support extendTimeout().\");\n }\n\n await extendTimeout.call(this.#sandbox, durationMs);\n }\n\n async snapshot(): Promise<PersistedSandboxState> {\n // Vercel sandbox snapshot() restores through a new sandbox and implicitly stops the source sandbox.\n // Keep this behavior as a provider detail in the driver implementation.\n const snapshot = await this.#sandbox.snapshot();\n\n return {\n kind: \"vercel-sandbox-snapshot\",\n sessionId: this.#sandbox.sandboxId,\n state: {\n snapshotId: snapshot.snapshotId,\n },\n };\n }\n\n async #toCommandFinished(raw: unknown): Promise<VercelCommandFinished> {\n if (typeof raw !== \"object\" || raw === null) {\n throw new Error(\"Unexpected Vercel sandbox command response\");\n }\n\n const candidate = raw as { wait?: () => Promise<VercelCommandFinished> };\n if (candidate.wait) {\n return candidate.wait();\n }\n\n return raw as VercelCommandFinished;\n }\n}\n\nfunction isVercelCommandHandle(value: unknown): value is VercelCommandHandle {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const candidate = value as { wait?: unknown; cmdId?: unknown };\n if (typeof candidate.wait !== \"function\") {\n return false;\n }\n\n return candidate.cmdId === undefined || typeof candidate.cmdId === \"string\";\n}\n\nfunction isIterable<T = unknown>(value: unknown): value is Iterable<T> {\n return (\n value !== null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n typeof (value as Iterable<T>)[Symbol.iterator] === \"function\"\n );\n}\n\nfunction isAsyncIterable<T = unknown>(value: unknown): value is AsyncIterable<T> {\n return (\n value !== null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n typeof (value as AsyncIterable<T>)[Symbol.asyncIterator] === \"function\"\n );\n}\n\nfunction getCommandLogIterator(raw: VercelCommandHandle): AsyncIterable<unknown> | undefined {\n const rawLogs = raw.logs?.();\n if (rawLogs === undefined) {\n return undefined;\n }\n if (isAsyncIterable<unknown>(rawLogs)) {\n return rawLogs;\n }\n if (isIterable<unknown>(rawLogs)) {\n return toAsyncIterableFromSync(rawLogs);\n }\n return undefined;\n}\n\nfunction toAsyncIterableFromSync<T>(iterable: Iterable<T>): AsyncIterable<T> {\n return {\n async *[Symbol.asyncIterator]() {\n for (const value of iterable) {\n yield value;\n }\n },\n };\n}\n\nfunction createCommandLogBroadcaster(\n logs: AsyncIterable<unknown> | undefined,\n onStdout?: (chunk: string) => void,\n onStderr?: (chunk: string) => void,\n): (() => AsyncIterable<WorkspaceSessionLog>) | undefined {\n if (!logs) {\n return undefined;\n }\n\n const bufferedLogs: WorkspaceSessionLog[] = [];\n const waiters: Array<() => void> = [];\n let completed = false;\n let error: unknown = null;\n let pumpStarted = false;\n\n const notifyWaiters = () => {\n while (waiters.length > 0) {\n waiters.pop()?.();\n }\n };\n\n const run = async (): Promise<void> => {\n if (pumpStarted) {\n return;\n }\n pumpStarted = true;\n\n try {\n for await (const log of logs) {\n const normalized = normalizeCommandLog(log);\n if (!normalized) {\n continue;\n }\n\n bufferedLogs.push(normalized);\n if (normalized.stream === \"stderr\") {\n onStderr?.(normalized.chunk);\n } else {\n onStdout?.(normalized.chunk);\n }\n notifyWaiters();\n }\n } catch (cause) {\n error = cause;\n } finally {\n completed = true;\n notifyWaiters();\n }\n };\n\n void run().catch(() => {});\n\n const waitForWork = (): Promise<void> => {\n return new Promise<void>((resolve) => {\n waiters.push(resolve);\n });\n };\n\n const createLogIterable = (): AsyncIterable<WorkspaceSessionLog> => {\n return {\n async *[Symbol.asyncIterator]() {\n let index = 0;\n while (true) {\n if (index < bufferedLogs.length) {\n yield bufferedLogs[index++]!;\n continue;\n }\n if (error !== null) {\n throw error instanceof Error ? error : new Error(\"startProcess logs failed.\");\n }\n if (completed) {\n return;\n }\n await waitForWork();\n }\n },\n };\n };\n\n return createLogIterable;\n}\n\nexport function normalizeCommandLog(log: unknown): WorkspaceSessionLog | null {\n if (typeof log === \"string\") {\n return { stream: \"stdout\", chunk: log };\n }\n if (typeof log !== \"object\" || log === null) {\n return null;\n }\n\n const candidate = log as {\n stream?: unknown;\n output?: unknown;\n chunk?: unknown;\n text?: unknown;\n message?: unknown;\n data?: unknown;\n };\n const streamValue = candidate.stream;\n const stream = streamValue === \"stderr\" || streamValue === \"stdout\" ? streamValue : \"stdout\";\n const rawChunk =\n candidate.data ??\n candidate.output ??\n candidate.chunk ??\n candidate.text ??\n candidate.message ??\n null;\n\n if (typeof rawChunk !== \"string\") {\n return null;\n }\n\n return { stream, chunk: rawChunk };\n}\n\nclass VercelSandboxDriverFactory implements SandboxDriverFactory {\n readonly #runtime: string;\n readonly #defaultTimeout: number;\n\n constructor(options: VercelSandboxOptions = {}) {\n this.#runtime = options.runtime ?? \"node24\";\n this.#defaultTimeout = normalizeSandboxTimeout(\n options.defaultTimeout ?? options.timeout,\n \"Vercel sandbox default timeout\",\n );\n }\n\n isSessionUnavailableError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n const message = error.message.toLowerCase();\n return (\n message.includes(\"not found\") ||\n message.includes(\"does not exist\") ||\n message.includes(\"sandbox_stopped\") ||\n message.includes(\"sandbox stopped\")\n );\n }\n\n async createSandbox(\n _workspace: WorkspaceRecord,\n options: SandboxCreateOptions,\n ): Promise<SandboxDriver> {\n const timeout = this.#defaultTimeoutForCreate(options);\n\n const sandbox = await Sandbox.create({\n runtime: this.#runtime,\n timeout,\n ports: options.exposedPorts,\n networkPolicy: compileVercelNetworkPolicy(options.policy),\n });\n\n return new VercelSandboxDriver(sandbox);\n }\n\n async resumeSandbox(\n workspace: WorkspaceRecord,\n snapshot: PersistedSandboxState,\n options: SandboxCreateOptions,\n ): Promise<SandboxDriver> {\n const timeout = this.#defaultTimeoutForCreate(options);\n const state = snapshot.state as VercelPersistedState | undefined;\n const snapshotId = state?.snapshotId;\n const fallbackSandboxId = workspace.sandboxId ?? snapshot.sessionId;\n\n const sandbox =\n snapshotId === undefined || typeof snapshotId !== \"string\"\n ? await (fallbackSandboxId === undefined\n ? (() => {\n throw new Error(\"Persisted sandbox state is missing restore information\");\n })()\n : Sandbox.get({ sandboxId: fallbackSandboxId }))\n : await Sandbox.create({\n source: {\n type: \"snapshot\",\n snapshotId,\n },\n timeout,\n ports: options.exposedPorts,\n networkPolicy: compileVercelNetworkPolicy(options.policy),\n });\n\n // Reattaching to an existing live sandbox should not mutate provider state.\n // Updating the network policy here races with commit/snapshot shutdown and can\n // fail on otherwise read-only flows like getActiveLease().\n return new VercelSandboxDriver(sandbox);\n }\n\n #defaultTimeoutForCreate(options: SandboxCreateOptions): number {\n return normalizeSandboxTimeout(options.timeoutMs ?? this.#defaultTimeout, \"runtime timeout\");\n }\n}\n\nfunction normalizeSandboxTimeout(value: unknown, label: string): number {\n if (value === undefined) {\n return 60_000;\n }\n\n if (\n typeof value !== \"number\" ||\n !Number.isInteger(value) ||\n !Number.isFinite(value) ||\n value <= 0\n ) {\n throw new Error(`${label} must be a positive integer in milliseconds.`);\n }\n\n return value;\n}\n\nexport function createVercelSandboxDriverFactory(\n options: VercelSandboxOptions = {},\n): SandboxDriverFactory {\n return new VercelSandboxDriverFactory(options);\n}\n","import { resolveAiGatewayDefaultApiKey } from \"./ai-gateway.ts\";\nimport { resolveCodexDefaultApiKey } from \"./codex.ts\";\nimport { resolveGeminiDefaultApiKey } from \"./gemini.ts\";\nimport { resolveGithubDefaultApiKey } from \"./github.ts\";\n\nexport function resolveDefaultCredentialValue(serviceId: string): string | undefined {\n switch (serviceId) {\n case \"codex\":\n return resolveCodexDefaultApiKey();\n case \"gemini\":\n return resolveGeminiDefaultApiKey();\n case \"github\":\n return resolveGithubDefaultApiKey();\n case \"aiGateway\":\n return resolveAiGatewayDefaultApiKey();\n default:\n return undefined;\n }\n}\n\nexport function describeDefaultCredentialSource(serviceId: string): string {\n switch (serviceId) {\n case \"codex\":\n return \"CODEX_API_KEY\";\n case \"gemini\":\n return \"GEMINI_API_KEY\";\n case \"github\":\n return \"GITHUB_TOKEN\";\n case \"aiGateway\":\n return \"AI_GATEWAY_API_KEY\";\n default:\n return `default credential for service \"${serviceId}\"`;\n }\n}\n","import type {\n NetworkPolicy as VercelNetworkPolicy,\n NetworkPolicyRule as VercelNetworkPolicyRule,\n} from \"@vercel/sandbox\";\n\nimport {\n describeDefaultCredentialSource,\n resolveDefaultCredentialValue,\n} from \"../policies/default-credentials.ts\";\nimport type { PolicyServiceHeaderTransform, WorkspacePolicy } from \"../policies/types.ts\";\n\nfunction resolveCredentialValue(serviceId: string, header: PolicyServiceHeaderTransform): string {\n if (header.credential.kind === \"value\") {\n return header.credential.value;\n }\n\n if (header.credential.kind === \"default\") {\n const value = resolveDefaultCredentialValue(serviceId);\n if (!value) {\n throw new Error(\n `Workspace policy for service \"${serviceId}\" requires ${describeDefaultCredentialSource(serviceId)}.`,\n );\n }\n return value;\n }\n\n throw new Error(\n `Workspace policy for service \"${serviceId}\" contains a redacted credential and cannot be applied.`,\n );\n}\n\nfunction compileHeaderRules(\n serviceId: string,\n headers: readonly PolicyServiceHeaderTransform[] | undefined,\n): VercelNetworkPolicyRule[] {\n if (!headers || headers.length === 0) {\n return [];\n }\n\n const resolvedHeaders = Object.fromEntries(\n headers.map((header) => [\n header.headerName,\n `${header.valuePrefix ?? \"\"}${resolveCredentialValue(serviceId, header)}`,\n ]),\n );\n\n return [\n {\n transform: [\n {\n headers: resolvedHeaders,\n },\n ],\n },\n ];\n}\n\nexport function compileVercelNetworkPolicy(policy: WorkspacePolicy): VercelNetworkPolicy {\n switch (policy.mode) {\n case \"allow-all\":\n return \"allow-all\";\n case \"deny-all\":\n return \"deny-all\";\n case \"allow-services\": {\n const allow: Record<string, VercelNetworkPolicyRule[]> = {};\n\n for (const service of policy.services) {\n const rules = compileHeaderRules(service.id, service.headers);\n for (const domain of service.domains) {\n const existing = allow[domain] ?? [];\n allow[domain] = [...existing, ...rules];\n }\n }\n\n return { allow };\n }\n }\n}\n","import { createVercelSandboxDriverFactory } from \"../drivers/vercel-sandbox.ts\";\nimport { createSandboxProvider } from \"../types.ts\";\nimport type { SandkitSandboxProvider, VercelSandboxOptions } from \"../types.ts\";\n\nexport type { SandkitSandboxProvider, VercelSandboxOptions } from \"../types.ts\";\n\nexport function vercelSandbox(options: VercelSandboxOptions = {}): SandkitSandboxProvider {\n return createSandboxProvider(\"vercel\", createVercelSandboxDriverFactory(options));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;;;ACKjB,SAAS,8BAA8B,WAAuC;AACnF,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO,0BAA0B;AAAA,IACnC,KAAK;AACH,aAAO,2BAA2B;AAAA,IACpC,KAAK;AACH,aAAO,2BAA2B;AAAA,IACpC,KAAK;AACH,aAAO,8BAA8B;AAAA,IACvC;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,gCAAgC,WAA2B;AACzE,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO,mCAAmC,SAAS;AAAA,EACvD;AACF;;;ACtBA,SAAS,uBAAuB,WAAmB,QAA8C;AAC/F,MAAI,OAAO,WAAW,SAAS,SAAS;AACtC,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,MAAI,OAAO,WAAW,SAAS,WAAW;AACxC,UAAM,QAAQ,8BAA8B,SAAS;A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,MACA;AAAA,MACA,OAAO,QAAQ;AAAA,MACf,eAAe,2BAA2B,QAAQ,MAAM;AAAA,IAC1D,CAAC;AAKP,WAAO,IAAI,oBAAoB,OAAO;AAAA,EACxC;AAAA,EAEA,yBAAyB,SAAuC;AAC9D,WAAO,wBAAwB,QAAQ,aAAa,KAAK,iBAAiB,iBAAiB;AAAA,EAC7F;AACF;AAEA,SAAS,wBAAwB,OAAgB,OAAuB;AACtE,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AAEA,MACE,OAAO,UAAU,YACjB,CAAC,OAAO,UAAU,KAAK,KACvB,CAAC,OAAO,SAAS,KAAK,KACtB,SAAS,GACT;AACA,UAAM,IAAI,MAAM,GAAG,KAAK,8CAA8C;AAAA,EACxE;AAEA,SAAO;AACT;AAEO,SAAS,iCACd,UAAgC,CAAC,GACX;AACtB,SAAO,IAAI,2BAA2B,OAAO;AAC/C;;;AGtaO,SAAS,cAAc,UAAgC,CAAC,GAA2B;AACxF,SAAO,sBAAsB,UAAU,iCAAiC,OAAO,CAAC;AAClF;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { P as PolicyServiceDescriptor, W as WorkspacePolicy } from '../types-BCgprbo8.js';
2
+
3
+ interface AiGatewayOptions {
4
+ readonly baseUrl?: string;
5
+ }
6
+ declare function resolveAiGatewayDefaultApiKey(): string | undefined;
7
+ /**
8
+ * Allow outbound access to the currently configured AI Gateway endpoint host/domain.
9
+ * The configured endpoint is not treated as a generic capability; it follows
10
+ * `AI_GATEWAY_BASE_URL` and derives allowed host/domain entries from its hostname.
11
+ */
12
+ declare function aiGateway(options?: AiGatewayOptions): PolicyServiceDescriptor;
13
+ declare function allowAiGateway(): WorkspacePolicy;
14
+
15
+ export { type AiGatewayOptions, aiGateway, allowAiGateway, resolveAiGatewayDefaultApiKey };
@@ -0,0 +1,12 @@
1
+ import {
2
+ aiGateway,
3
+ allowAiGateway,
4
+ resolveAiGatewayDefaultApiKey
5
+ } from "../chunk-REGOUXVI.js";
6
+ import "../chunk-VISDS5T7.js";
7
+ export {
8
+ aiGateway,
9
+ allowAiGateway,
10
+ resolveAiGatewayDefaultApiKey
11
+ };
12
+ //# sourceMappingURL=ai-gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,10 @@
1
+ import { P as PolicyServiceDescriptor, W as WorkspacePolicy } from '../types-BCgprbo8.js';
2
+
3
+ interface CodexOptions {
4
+ readonly apiKey?: string;
5
+ }
6
+ declare function resolveCodexDefaultApiKey(): string | undefined;
7
+ declare function codex(options?: CodexOptions): PolicyServiceDescriptor;
8
+ declare function allowCodex(): WorkspacePolicy;
9
+
10
+ export { type CodexOptions, allowCodex, codex, resolveCodexDefaultApiKey };
@@ -0,0 +1,12 @@
1
+ import {
2
+ allowCodex,
3
+ codex,
4
+ resolveCodexDefaultApiKey
5
+ } from "../chunk-FSDVHEEX.js";
6
+ import "../chunk-VISDS5T7.js";
7
+ export {
8
+ allowCodex,
9
+ codex,
10
+ resolveCodexDefaultApiKey
11
+ };
12
+ //# sourceMappingURL=codex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,10 @@
1
+ import { P as PolicyServiceDescriptor, W as WorkspacePolicy } from '../types-BCgprbo8.js';
2
+
3
+ interface GeminiOptions {
4
+ readonly apiKey?: string;
5
+ }
6
+ declare function resolveGeminiDefaultApiKey(): string | undefined;
7
+ declare function gemini(options?: GeminiOptions): PolicyServiceDescriptor;
8
+ declare function allowGemini(): WorkspacePolicy;
9
+
10
+ export { type GeminiOptions, allowGemini, gemini, resolveGeminiDefaultApiKey };
@@ -0,0 +1,12 @@
1
+ import {
2
+ allowGemini,
3
+ gemini,
4
+ resolveGeminiDefaultApiKey
5
+ } from "../chunk-7DLK7LOM.js";
6
+ import "../chunk-VISDS5T7.js";
7
+ export {
8
+ allowGemini,
9
+ gemini,
10
+ resolveGeminiDefaultApiKey
11
+ };
12
+ //# sourceMappingURL=gemini.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,60 @@
1
+ type SandkitDialect = "sqlite" | "postgresql" | "mysql";
2
+ type SandkitColumnType = "text" | "integer" | "boolean" | "json" | "timestamp";
3
+ interface SandkitColumn {
4
+ name: string;
5
+ type: SandkitColumnType;
6
+ nullable?: boolean;
7
+ primaryKey?: boolean;
8
+ unique?: boolean;
9
+ defaultValue?: string | number | boolean | null;
10
+ comment?: string;
11
+ references?: {
12
+ table: string;
13
+ field: string;
14
+ };
15
+ }
16
+ interface SandkitIndex {
17
+ name: string;
18
+ columns: string[];
19
+ unique?: boolean;
20
+ }
21
+ interface SandkitTable {
22
+ name: string;
23
+ schema?: string;
24
+ comment?: string;
25
+ exportName?: string;
26
+ columns: SandkitColumn[];
27
+ indexes?: SandkitIndex[];
28
+ }
29
+ interface SandkitSchemaModel {
30
+ name: string;
31
+ version: number;
32
+ dialect: SandkitDialect;
33
+ tables: SandkitTable[];
34
+ }
35
+ declare const sandkitWorkspaceExport = "sandkitWorkspaces";
36
+ declare const sandkitRunExport = "sandkitRuns";
37
+ declare const sandkitPolicyExport = "sandkitPolicies";
38
+ declare const sandkitSetupStateExport = "sandkitSetupStates";
39
+ declare const sandkitWorkspaceTable: SandkitTable;
40
+ declare const sandkitRunTable: SandkitTable;
41
+ declare const sandkitPolicyTable: SandkitTable;
42
+ declare const sandkitSetupStateTable: SandkitTable;
43
+ declare function createSandkitSchemaModel(dialect?: SandkitDialect): SandkitSchemaModel;
44
+ declare function createModelSnapshot(dialect?: SandkitDialect): {
45
+ model: SandkitSchemaModel;
46
+ generatedAt: string;
47
+ };
48
+
49
+ declare function renderTextSchema(model: SandkitSchemaModel): string;
50
+ declare function createGeneratePayload(dialect: SandkitDialect, model: SandkitSchemaModel): {
51
+ dialect: SandkitDialect;
52
+ generatedAt: string;
53
+ summary: {
54
+ tableCount: number;
55
+ tableNames: string[];
56
+ };
57
+ schemaText: string;
58
+ };
59
+
60
+ export { type SandkitColumn, type SandkitColumnType, type SandkitDialect, type SandkitIndex, type SandkitSchemaModel, type SandkitTable, createGeneratePayload, createModelSnapshot, createSandkitSchemaModel, renderTextSchema, sandkitPolicyExport, sandkitPolicyTable, sandkitRunExport, sandkitRunTable, sandkitSetupStateExport, sandkitSetupStateTable, sandkitWorkspaceExport, sandkitWorkspaceTable };
@@ -0,0 +1,31 @@
1
+ import {
2
+ createGeneratePayload,
3
+ renderTextSchema
4
+ } from "../chunk-LC3IYBAL.js";
5
+ import {
6
+ createModelSnapshot,
7
+ createSandkitSchemaModel,
8
+ sandkitPolicyExport,
9
+ sandkitPolicyTable,
10
+ sandkitRunExport,
11
+ sandkitRunTable,
12
+ sandkitSetupStateExport,
13
+ sandkitSetupStateTable,
14
+ sandkitWorkspaceExport,
15
+ sandkitWorkspaceTable
16
+ } from "../chunk-RMMOQD5Y.js";
17
+ export {
18
+ createGeneratePayload,
19
+ createModelSnapshot,
20
+ createSandkitSchemaModel,
21
+ renderTextSchema,
22
+ sandkitPolicyExport,
23
+ sandkitPolicyTable,
24
+ sandkitRunExport,
25
+ sandkitRunTable,
26
+ sandkitSetupStateExport,
27
+ sandkitSetupStateTable,
28
+ sandkitWorkspaceExport,
29
+ sandkitWorkspaceTable
30
+ };
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}