@ekairos/sandbox 1.22.39-beta.development.0 → 1.22.39
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/action-steps.d.ts +156 -0
- package/dist/action-steps.d.ts.map +1 -0
- package/dist/action-steps.js +153 -0
- package/dist/action-steps.js.map +1 -0
- package/dist/actions.d.ts +259 -169
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +176 -269
- package/dist/actions.js.map +1 -1
- package/dist/contract.d.ts +86 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +83 -0
- package/dist/contract.js.map +1 -0
- package/dist/domain.d.ts +2 -0
- package/dist/domain.d.ts.map +1 -0
- package/dist/domain.js +2 -0
- package/dist/domain.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/daytona.d.ts +14 -0
- package/dist/providers/daytona.d.ts.map +1 -0
- package/dist/providers/daytona.js +153 -0
- package/dist/providers/daytona.js.map +1 -0
- package/dist/providers/provider.d.ts +3 -0
- package/dist/providers/provider.d.ts.map +1 -0
- package/dist/providers/provider.js +18 -0
- package/dist/providers/provider.js.map +1 -0
- package/dist/providers/sprites.d.ts +39 -0
- package/dist/providers/sprites.d.ts.map +1 -0
- package/dist/providers/sprites.js +234 -0
- package/dist/providers/sprites.js.map +1 -0
- package/dist/providers/types.d.ts +15 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +9 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/vercel.d.ts +26 -0
- package/dist/providers/vercel.d.ts.map +1 -0
- package/dist/providers/vercel.js +182 -0
- package/dist/providers/vercel.js.map +1 -0
- package/dist/public.d.ts +55 -3
- package/dist/public.d.ts.map +1 -1
- package/dist/public.js +2 -5
- package/dist/public.js.map +1 -1
- package/dist/sandbox.d.ts +76 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +154 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/schema.d.ts +18 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +66 -1
- package/dist/schema.js.map +1 -1
- package/dist/service.d.ts +10 -44
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +38 -565
- package/dist/service.js.map +1 -1
- package/package.json +25 -5
package/dist/contract.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const SANDBOX_EXECUTE_COMMAND_ACTION_NAME = "executeCommand";
|
|
3
|
+
export const SANDBOX_PROCESS_KINDS = [
|
|
4
|
+
"command",
|
|
5
|
+
"service",
|
|
6
|
+
"codex-app-server",
|
|
7
|
+
"dev-server",
|
|
8
|
+
"test-runner",
|
|
9
|
+
"watcher",
|
|
10
|
+
];
|
|
11
|
+
export const SANDBOX_PROCESS_MODES = ["foreground", "background"];
|
|
12
|
+
export const SANDBOX_PROCESS_STATUSES = [
|
|
13
|
+
"starting",
|
|
14
|
+
"running",
|
|
15
|
+
"detached",
|
|
16
|
+
"exited",
|
|
17
|
+
"failed",
|
|
18
|
+
"killed",
|
|
19
|
+
"lost",
|
|
20
|
+
];
|
|
21
|
+
export const SANDBOX_PROCESS_STREAM_CHUNK_TYPES = [
|
|
22
|
+
"stdout",
|
|
23
|
+
"stderr",
|
|
24
|
+
"status",
|
|
25
|
+
"exit",
|
|
26
|
+
"error",
|
|
27
|
+
"heartbeat",
|
|
28
|
+
"metadata",
|
|
29
|
+
];
|
|
30
|
+
export const sandboxCommandResultSchema = z
|
|
31
|
+
.object({
|
|
32
|
+
success: z.boolean(),
|
|
33
|
+
exitCode: z.number().optional(),
|
|
34
|
+
output: z.string().optional(),
|
|
35
|
+
error: z.string().optional(),
|
|
36
|
+
streamingLogs: z.array(z.unknown()).optional(),
|
|
37
|
+
command: z.string().optional(),
|
|
38
|
+
})
|
|
39
|
+
.passthrough();
|
|
40
|
+
export const sandboxProcessStreamChunkSchema = z
|
|
41
|
+
.object({
|
|
42
|
+
version: z.literal(1),
|
|
43
|
+
at: z.string(),
|
|
44
|
+
seq: z.number(),
|
|
45
|
+
type: z.enum(SANDBOX_PROCESS_STREAM_CHUNK_TYPES),
|
|
46
|
+
sandboxId: z.string(),
|
|
47
|
+
processId: z.string(),
|
|
48
|
+
data: z.record(z.string(), z.unknown()).optional(),
|
|
49
|
+
})
|
|
50
|
+
.passthrough();
|
|
51
|
+
export const sandboxProcessRunResultSchema = z
|
|
52
|
+
.object({
|
|
53
|
+
processId: z.string(),
|
|
54
|
+
streamId: z.string(),
|
|
55
|
+
streamClientId: z.string(),
|
|
56
|
+
result: sandboxCommandResultSchema.optional(),
|
|
57
|
+
})
|
|
58
|
+
.passthrough();
|
|
59
|
+
export const sandboxExecuteCommandInputSchema = z
|
|
60
|
+
.object({
|
|
61
|
+
command: z.string().min(1),
|
|
62
|
+
args: z.array(z.string()).optional(),
|
|
63
|
+
cwd: z.string().min(1).optional(),
|
|
64
|
+
env: z.record(z.string(), z.unknown()).optional(),
|
|
65
|
+
kind: z.enum(SANDBOX_PROCESS_KINDS).optional(),
|
|
66
|
+
mode: z.enum(SANDBOX_PROCESS_MODES).optional(),
|
|
67
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
68
|
+
})
|
|
69
|
+
.strict();
|
|
70
|
+
export const sandboxExecuteCommandOutputSchema = z.object({
|
|
71
|
+
sandboxId: z.string().min(1).optional(),
|
|
72
|
+
processId: z.string().min(1).optional(),
|
|
73
|
+
streamId: z.string().min(1).optional(),
|
|
74
|
+
streamClientId: z.string().min(1).optional(),
|
|
75
|
+
success: z.boolean(),
|
|
76
|
+
exitCode: z.number().int().optional(),
|
|
77
|
+
output: z.string().optional(),
|
|
78
|
+
error: z.string().optional(),
|
|
79
|
+
command: z.string().optional(),
|
|
80
|
+
status: z.string().optional(),
|
|
81
|
+
durationMs: z.number().optional(),
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=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Aa,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/domain.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.js","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export type { SandboxConfig, SandboxId, SandboxProvider, SandboxRunCommandResult, } from "./types.js";
|
|
2
2
|
export { sandboxDomain } from "./actions.js";
|
|
3
3
|
export { sandboxDomain as sandboxSchemaDomain } from "./schema.js";
|
|
4
|
-
export {
|
|
4
|
+
export { SANDBOX_EXECUTE_COMMAND_ACTION_NAME, SANDBOX_PROCESS_KINDS, SANDBOX_PROCESS_MODES, SANDBOX_PROCESS_STATUSES, SANDBOX_PROCESS_STREAM_CHUNK_TYPES, sandboxCommandResultSchema, sandboxExecuteCommandInputSchema, sandboxExecuteCommandOutputSchema, sandboxProcessRunResultSchema, sandboxProcessStreamChunkSchema, } from "./contract.js";
|
|
5
|
+
export type { SandboxCommandResult, SandboxExecuteCommandInput, SandboxExecuteCommandOutput, SandboxProcessStreamChunkType, } from "./contract.js";
|
|
6
|
+
export { sandboxDomain as publicSandboxDomain, } from "./public.js";
|
|
7
|
+
export { Sandbox } from "./sandbox.js";
|
|
8
|
+
export type { SandboxActions, SerializedSandbox, SerializedSandboxState, } from "./sandbox.js";
|
|
5
9
|
export { SandboxService } from "./service.js";
|
|
6
10
|
export type { CommandResult } from "./commands.js";
|
|
7
11
|
export type { SandboxCommandRunData, SandboxProcessKind, SandboxProcessMode, SandboxProcessRunResult, SandboxProcessStatus, SandboxProcessStreamChunk, } from "./service.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,SAAS,EACT,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EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAC3F,YAAY,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE5F,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACvD,YAAY,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzF,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,cAAc,EACd,OAAO,EACP,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { sandboxDomain } from "./actions.js";
|
|
2
2
|
export { sandboxDomain as sandboxSchemaDomain } from "./schema.js";
|
|
3
|
-
export {
|
|
3
|
+
export { SANDBOX_EXECUTE_COMMAND_ACTION_NAME, SANDBOX_PROCESS_KINDS, SANDBOX_PROCESS_MODES, SANDBOX_PROCESS_STATUSES, SANDBOX_PROCESS_STREAM_CHUNK_TYPES, sandboxCommandResultSchema, sandboxExecuteCommandInputSchema, sandboxExecuteCommandOutputSchema, sandboxProcessRunResultSchema, sandboxProcessStreamChunkSchema, } from "./contract.js";
|
|
4
|
+
export { sandboxDomain as publicSandboxDomain, } from "./public.js";
|
|
5
|
+
export { Sandbox } from "./sandbox.js";
|
|
4
6
|
export { SandboxService } from "./service.js";
|
|
5
7
|
export { SandboxCommandRun } from "./service.js";
|
|
6
8
|
export { runCommandInSandbox } from "./commands.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EACL,mCAAmC,EACnC,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,kCAAkC,EAClC,0BAA0B,EAC1B,gCAAgC,EAChC,iCAAiC,EACjC,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,eAAe,CAAA;AAOtB,OAAO,EACL,aAAa,IAAI,mBAAmB,GACrC,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAU7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAG3F,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAGvD,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,cAAc,EACd,OAAO,EACP,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Daytona, Image, type DaytonaConfig } from "@daytonaio/sdk";
|
|
2
|
+
import type { SandboxConfig } from "../types.js";
|
|
3
|
+
export declare function getDaytonaConfig(): DaytonaConfig;
|
|
4
|
+
export declare function resolveDaytonaLanguage(config: SandboxConfig): "python" | "typescript" | "javascript" | undefined;
|
|
5
|
+
export declare function resolveDaytonaVolumes(daytona: Daytona, volumes: Array<{
|
|
6
|
+
volumeId?: string;
|
|
7
|
+
volumeName?: string;
|
|
8
|
+
mountPath: string;
|
|
9
|
+
}>): Promise<Array<{
|
|
10
|
+
volumeId: string;
|
|
11
|
+
mountPath: string;
|
|
12
|
+
}>>;
|
|
13
|
+
export declare function buildDeclarativeImage(config: SandboxConfig): Image | undefined;
|
|
14
|
+
//# sourceMappingURL=daytona.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daytona.d.ts","sourceRoot":"","sources":["../../src/providers/daytona.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,wBAAgB,gBAAgB,IAAI,aAAa,CAyBhD;AAiBD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,GACpB,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,CAOpD;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,KAAK,CAAC;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,GAC5E,OAAO,CAAC,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAkEzD;AAYD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,KAAK,GAAG,SAAS,CAkC9E"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Image } from "@daytonaio/sdk";
|
|
2
|
+
export function getDaytonaConfig() {
|
|
3
|
+
const apiKey = String(process.env.DAYTONA_API_KEY ?? "").trim();
|
|
4
|
+
const apiUrl = String(process.env.DAYTONA_API_URL ?? "").trim() ||
|
|
5
|
+
String(process.env.DAYTONA_SERVER_URL ?? "").trim();
|
|
6
|
+
const jwtToken = String(process.env.DAYTONA_JWT_TOKEN ?? "").trim();
|
|
7
|
+
const organizationId = String(process.env.DAYTONA_ORGANIZATION_ID ?? "").trim();
|
|
8
|
+
const target = String(process.env.DAYTONA_TARGET ?? "").trim();
|
|
9
|
+
if (!apiUrl) {
|
|
10
|
+
throw new Error("Missing required Daytona env var: DAYTONA_API_URL (or DAYTONA_SERVER_URL)");
|
|
11
|
+
}
|
|
12
|
+
if (!apiKey && !(jwtToken && organizationId)) {
|
|
13
|
+
throw new Error("Missing required Daytona env vars: DAYTONA_API_KEY or DAYTONA_JWT_TOKEN + DAYTONA_ORGANIZATION_ID");
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
apiUrl,
|
|
17
|
+
target: target || undefined,
|
|
18
|
+
apiKey: apiKey || undefined,
|
|
19
|
+
jwtToken: jwtToken || undefined,
|
|
20
|
+
organizationId: organizationId || undefined,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function parseOptionalBoolean(value) {
|
|
24
|
+
const normalized = String(value ?? "").trim().toLowerCase();
|
|
25
|
+
if (!normalized)
|
|
26
|
+
return undefined;
|
|
27
|
+
if (["1", "true", "yes", "y", "on"].includes(normalized))
|
|
28
|
+
return true;
|
|
29
|
+
if (["0", "false", "no", "n", "off"].includes(normalized))
|
|
30
|
+
return false;
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
function parseCsvList(value) {
|
|
34
|
+
return String(value ?? "")
|
|
35
|
+
.split(",")
|
|
36
|
+
.map((entry) => entry.trim())
|
|
37
|
+
.filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
export function resolveDaytonaLanguage(config) {
|
|
40
|
+
if (config.daytona?.language)
|
|
41
|
+
return config.daytona.language;
|
|
42
|
+
const runtime = String(config.runtime ?? "").toLowerCase();
|
|
43
|
+
if (runtime.startsWith("python"))
|
|
44
|
+
return "python";
|
|
45
|
+
if (runtime.startsWith("node"))
|
|
46
|
+
return "javascript";
|
|
47
|
+
if (runtime.startsWith("ts") || runtime.includes("typescript"))
|
|
48
|
+
return "typescript";
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
export async function resolveDaytonaVolumes(daytona, volumes) {
|
|
52
|
+
if (!volumes || volumes.length === 0)
|
|
53
|
+
return [];
|
|
54
|
+
const resolved = [];
|
|
55
|
+
const shouldLog = parseOptionalBoolean(process.env.SANDBOX_DAYTONA_LOG_VOLUMES) ?? false;
|
|
56
|
+
for (const volume of volumes) {
|
|
57
|
+
const mountPath = String(volume.mountPath ?? "").trim();
|
|
58
|
+
if (!mountPath)
|
|
59
|
+
continue;
|
|
60
|
+
const volumeId = String(volume.volumeId ?? "").trim();
|
|
61
|
+
if (volumeId) {
|
|
62
|
+
resolved.push({ volumeId, mountPath });
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const volumeName = String(volume.volumeName ?? "").trim();
|
|
66
|
+
if (!volumeName) {
|
|
67
|
+
throw new Error("Daytona volume requires volumeId or volumeName");
|
|
68
|
+
}
|
|
69
|
+
let resolvedVolume = await daytona.volume.get(volumeName, true);
|
|
70
|
+
const stateRaw = String(resolvedVolume?.state ?? "").trim().toLowerCase();
|
|
71
|
+
const waitStates = new Set([
|
|
72
|
+
"creating",
|
|
73
|
+
"provisioning",
|
|
74
|
+
"pending",
|
|
75
|
+
"pending_create",
|
|
76
|
+
"pending-create",
|
|
77
|
+
"initializing",
|
|
78
|
+
]);
|
|
79
|
+
const readyStates = new Set(["available", "active", "ready"]);
|
|
80
|
+
if (waitStates.has(stateRaw)) {
|
|
81
|
+
const maxAttempts = 12;
|
|
82
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
83
|
+
await new Promise((r) => setTimeout(r, 1000 * attempt));
|
|
84
|
+
resolvedVolume = await daytona.volume.get(volumeName, true);
|
|
85
|
+
const state = String(resolvedVolume?.state ?? "").trim().toLowerCase();
|
|
86
|
+
if (shouldLog) {
|
|
87
|
+
console.log(`[daytona:volume] name=${volumeName} state=${state} attempt=${attempt}/${maxAttempts}`);
|
|
88
|
+
}
|
|
89
|
+
if (readyStates.has(state))
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const finalState = String(resolvedVolume?.state ?? "").trim().toLowerCase();
|
|
94
|
+
if (finalState && !readyStates.has(finalState)) {
|
|
95
|
+
if (shouldLog) {
|
|
96
|
+
console.log(`[daytona:volume] name=${volumeName} state=${finalState} mountPath=${mountPath} (not ready)`);
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Daytona volume not ready: ${volumeName} (state=${finalState})`);
|
|
99
|
+
}
|
|
100
|
+
const resolvedId = String(resolvedVolume?.id ?? "").trim();
|
|
101
|
+
if (!resolvedId) {
|
|
102
|
+
throw new Error(`Daytona volume not resolved: ${volumeName}`);
|
|
103
|
+
}
|
|
104
|
+
if (shouldLog) {
|
|
105
|
+
console.log(`[daytona:volume] name=${volumeName} id=${resolvedId} mountPath=${mountPath}`);
|
|
106
|
+
}
|
|
107
|
+
resolved.push({ volumeId: resolvedId, mountPath });
|
|
108
|
+
}
|
|
109
|
+
return resolved;
|
|
110
|
+
}
|
|
111
|
+
function resolvePythonVersion(runtime) {
|
|
112
|
+
const fromEnv = String(process.env.SANDBOX_DAYTONA_DECLARATIVE_PYTHON ?? "").trim() ||
|
|
113
|
+
String(process.env.STRUCTURE_DAYTONA_DECLARATIVE_PYTHON ?? "").trim();
|
|
114
|
+
if (fromEnv)
|
|
115
|
+
return fromEnv;
|
|
116
|
+
const match = String(runtime ?? "").match(/python\s*([0-9]+\.[0-9]+)/i);
|
|
117
|
+
if (match?.[1])
|
|
118
|
+
return match[1];
|
|
119
|
+
return "3.12";
|
|
120
|
+
}
|
|
121
|
+
export function buildDeclarativeImage(config) {
|
|
122
|
+
const imageFlag = String(config.daytona?.image ?? "").trim();
|
|
123
|
+
const envFlag = parseOptionalBoolean(process.env.SANDBOX_DAYTONA_DECLARATIVE_IMAGE) ??
|
|
124
|
+
parseOptionalBoolean(process.env.STRUCTURE_DAYTONA_DECLARATIVE_IMAGE) ??
|
|
125
|
+
false;
|
|
126
|
+
const useDeclarative = envFlag || imageFlag.startsWith("declarative");
|
|
127
|
+
if (!useDeclarative)
|
|
128
|
+
return undefined;
|
|
129
|
+
const baseImage = String(process.env.SANDBOX_DAYTONA_DECLARATIVE_BASE ?? "").trim() ||
|
|
130
|
+
String(process.env.STRUCTURE_DAYTONA_DECLARATIVE_BASE ?? "").trim();
|
|
131
|
+
const pythonVersion = resolvePythonVersion(config.runtime);
|
|
132
|
+
const isStructureDataset = config.purpose === "structure.dataset" || typeof config.params?.datasetId === "string";
|
|
133
|
+
const defaultPackages = isStructureDataset ? ["pandas", "openpyxl"] : [];
|
|
134
|
+
const packages = [
|
|
135
|
+
...parseCsvList(process.env.SANDBOX_DAYTONA_DECLARATIVE_PIP),
|
|
136
|
+
...parseCsvList(process.env.STRUCTURE_DAYTONA_DECLARATIVE_PIP),
|
|
137
|
+
...defaultPackages,
|
|
138
|
+
];
|
|
139
|
+
const uniquePackages = Array.from(new Set(packages));
|
|
140
|
+
let image;
|
|
141
|
+
if (baseImage) {
|
|
142
|
+
image = Image.base(baseImage);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
image = Image.debianSlim(pythonVersion);
|
|
146
|
+
}
|
|
147
|
+
if (uniquePackages.length > 0) {
|
|
148
|
+
image = image.pipInstall(uniquePackages);
|
|
149
|
+
}
|
|
150
|
+
image = image.workdir("/home/daytona");
|
|
151
|
+
return image;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=daytona.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daytona.js","sourceRoot":"","sources":["../../src/providers/daytona.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAsB,MAAM,gBAAgB,CAAA;AAInE,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAA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file":"provider.d.ts","sourceRoot":"","sources":["../../src/providers/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEjE,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAYtE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function resolveProvider(config) {
|
|
2
|
+
const explicit = String(config.provider ?? "").trim().toLowerCase();
|
|
3
|
+
if (explicit === "daytona")
|
|
4
|
+
return "daytona";
|
|
5
|
+
if (explicit === "vercel")
|
|
6
|
+
return "vercel";
|
|
7
|
+
if (explicit === "sprites")
|
|
8
|
+
return "sprites";
|
|
9
|
+
const env = String(process.env.SANDBOX_PROVIDER ?? "").trim().toLowerCase();
|
|
10
|
+
if (env === "daytona")
|
|
11
|
+
return "daytona";
|
|
12
|
+
if (env === "vercel")
|
|
13
|
+
return "vercel";
|
|
14
|
+
if (env === "sprites")
|
|
15
|
+
return "sprites";
|
|
16
|
+
return "sprites";
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/providers/provider.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACnE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC5C,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAC1C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAE5C,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAC3E,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACvC,IAAI,GAAG,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAA;IACrC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAEvC,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SandboxConfig } from "../types.js";
|
|
2
|
+
import type { SpritesSandbox } from "./types.js";
|
|
3
|
+
export declare function spritesFetch(path: string, init?: any): Promise<any>;
|
|
4
|
+
export declare function spritesJson<T = any>(path: string, init?: any): Promise<T>;
|
|
5
|
+
export declare function spritesText(path: string, init?: any): Promise<{
|
|
6
|
+
status: number;
|
|
7
|
+
ok: boolean;
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function toSpritesPreviewUrl(spriteUrl: string, port: number): string;
|
|
11
|
+
export declare function asSpritesSandbox(sprite: {
|
|
12
|
+
name: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}): SpritesSandbox;
|
|
16
|
+
export declare function getSpritesByName(name: string): Promise<{
|
|
17
|
+
ok: true;
|
|
18
|
+
sprite: any;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
status: number;
|
|
22
|
+
error: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function provisionSpritesSandbox(params: {
|
|
25
|
+
sandboxId: string;
|
|
26
|
+
config: SandboxConfig;
|
|
27
|
+
}): Promise<SpritesSandbox>;
|
|
28
|
+
export declare function spritesExec(params: {
|
|
29
|
+
spriteName: string;
|
|
30
|
+
command: string;
|
|
31
|
+
args?: string[];
|
|
32
|
+
stdin?: string | Buffer;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
exitCode: number;
|
|
35
|
+
stdout: string;
|
|
36
|
+
stderr: string;
|
|
37
|
+
}>;
|
|
38
|
+
export declare function parseSpritesCheckpointIdFromNdjson(text: string): string | null;
|
|
39
|
+
//# sourceMappingURL=sprites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../src/providers/sprites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AA0BhD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAiBzE;AAED,wBAAsB,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAe/E;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAIxD;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAc3E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,cAAc,CAkBjB;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBnF;AAED,wBAAsB,uBAAuB,CAAC,MAAM,EAAE;IACpD,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,aAAa,CAAA;CACtB,GAAG,OAAO,CAAC,cAAc,CAAC,CAiC1B;AA6CD,wBAAsB,WAAW,CAAC,MAAM,EAAE;IACxC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAyChE;AAED,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwB9E"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
function normalizeBaseUrl(raw) {
|
|
2
|
+
const trimmed = String(raw ?? "").trim();
|
|
3
|
+
if (!trimmed)
|
|
4
|
+
return "";
|
|
5
|
+
return trimmed.endsWith("/") ? trimmed.slice(0, -1) : trimmed;
|
|
6
|
+
}
|
|
7
|
+
function sanitizeSpritesString(value) {
|
|
8
|
+
return value.includes("\0") ? value.replace(/\0/g, "") : value;
|
|
9
|
+
}
|
|
10
|
+
function getSpritesConfig() {
|
|
11
|
+
const token = String(process.env.SPRITES_API_TOKEN ?? process.env.SPRITE_TOKEN ?? "").trim();
|
|
12
|
+
if (!token) {
|
|
13
|
+
throw new Error("Missing required Sprites token env var: SPRITES_API_TOKEN (or SPRITE_TOKEN)");
|
|
14
|
+
}
|
|
15
|
+
const baseUrl = normalizeBaseUrl(String(process.env.SPRITES_API_BASE_URL ?? process.env.SPRITES_API_URL ?? "").trim()) || "https://api.sprites.dev";
|
|
16
|
+
return { baseUrl, token };
|
|
17
|
+
}
|
|
18
|
+
export async function spritesFetch(path, init) {
|
|
19
|
+
const { baseUrl, token } = getSpritesConfig();
|
|
20
|
+
const fetchFn = globalThis?.fetch;
|
|
21
|
+
if (typeof fetchFn !== "function") {
|
|
22
|
+
throw new Error("fetch_not_available");
|
|
23
|
+
}
|
|
24
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
25
|
+
const url = `${baseUrl}${normalizedPath}`;
|
|
26
|
+
return await fetchFn(url, {
|
|
27
|
+
...init,
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${token}`,
|
|
30
|
+
...(init?.headers ?? {}),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export async function spritesJson(path, init) {
|
|
35
|
+
const res = await spritesFetch(path, {
|
|
36
|
+
...init,
|
|
37
|
+
headers: {
|
|
38
|
+
Accept: "application/json",
|
|
39
|
+
...(init?.headers ?? {}),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (!res?.ok) {
|
|
43
|
+
const text = await res?.text?.().catch(() => "");
|
|
44
|
+
throw new Error(`sprites_http_${res?.status ?? "unknown"}: ${text || "request_failed"}`);
|
|
45
|
+
}
|
|
46
|
+
return (await res.json().catch(() => ({})));
|
|
47
|
+
}
|
|
48
|
+
export async function spritesText(path, init) {
|
|
49
|
+
const res = await spritesFetch(path, init);
|
|
50
|
+
const text = await res?.text?.().catch(() => "");
|
|
51
|
+
return { ok: Boolean(res?.ok), status: Number(res?.status ?? 0), text: String(text ?? "") };
|
|
52
|
+
}
|
|
53
|
+
export function toSpritesPreviewUrl(spriteUrl, port) {
|
|
54
|
+
const base = String(spriteUrl ?? "").trim();
|
|
55
|
+
if (!base)
|
|
56
|
+
return "";
|
|
57
|
+
try {
|
|
58
|
+
const u = new URL(base);
|
|
59
|
+
if (Number.isFinite(port) && port > 0) {
|
|
60
|
+
u.port = String(Math.floor(port));
|
|
61
|
+
}
|
|
62
|
+
const next = u.toString();
|
|
63
|
+
return next.endsWith("/") ? next.slice(0, -1) : next;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
if (!port)
|
|
67
|
+
return base;
|
|
68
|
+
return base.replace(/\/+$/, "") + ":" + String(Math.floor(port));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export function asSpritesSandbox(sprite) {
|
|
72
|
+
const name = String(sprite?.name ?? "").trim();
|
|
73
|
+
const url = typeof sprite?.url === "string" ? sprite.url : undefined;
|
|
74
|
+
return {
|
|
75
|
+
__provider: "sprites",
|
|
76
|
+
name,
|
|
77
|
+
id: sprite?.id ? String(sprite.id) : undefined,
|
|
78
|
+
url,
|
|
79
|
+
getPreviewLink: async (port) => {
|
|
80
|
+
const base = url ?? "";
|
|
81
|
+
const next = toSpritesPreviewUrl(base, port);
|
|
82
|
+
return { url: next };
|
|
83
|
+
},
|
|
84
|
+
domain: async (port) => {
|
|
85
|
+
const base = url ?? "";
|
|
86
|
+
return toSpritesPreviewUrl(base, port);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export async function getSpritesByName(name) {
|
|
91
|
+
const safeName = String(name ?? "").trim();
|
|
92
|
+
if (!safeName)
|
|
93
|
+
return { ok: false, status: 400, error: "sprites_name_required" };
|
|
94
|
+
const res = await spritesFetch(`/v1/sprites/${encodeURIComponent(safeName)}`, {
|
|
95
|
+
method: "GET",
|
|
96
|
+
headers: { Accept: "application/json" },
|
|
97
|
+
});
|
|
98
|
+
if (!res?.ok) {
|
|
99
|
+
const text = await res?.text?.().catch(() => "");
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
status: Number(res?.status ?? 0),
|
|
103
|
+
error: text || `sprites_http_${res?.status ?? "unknown"}`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const json = await res.json().catch(() => ({}));
|
|
107
|
+
return { ok: true, sprite: json };
|
|
108
|
+
}
|
|
109
|
+
export async function provisionSpritesSandbox(params) {
|
|
110
|
+
const requestedName = String(params.config?.sprites?.name ?? "").trim();
|
|
111
|
+
const name = requestedName || `ekairos-${params.sandboxId}`;
|
|
112
|
+
const existing = await getSpritesByName(name);
|
|
113
|
+
if (existing.ok) {
|
|
114
|
+
const sprite = existing.sprite ?? {};
|
|
115
|
+
return asSpritesSandbox({
|
|
116
|
+
name: String(sprite?.name ?? name),
|
|
117
|
+
id: sprite?.id ? String(sprite.id) : undefined,
|
|
118
|
+
url: typeof sprite?.url === "string" ? sprite.url : undefined,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const waitForCapacity = params.config?.sprites?.waitForCapacity ?? true;
|
|
122
|
+
const auth = params.config?.sprites?.urlSettings?.auth ?? "public";
|
|
123
|
+
const body = {
|
|
124
|
+
name,
|
|
125
|
+
wait_for_capacity: Boolean(waitForCapacity),
|
|
126
|
+
url_settings: { auth },
|
|
127
|
+
};
|
|
128
|
+
const created = await spritesJson("/v1/sprites", {
|
|
129
|
+
method: "POST",
|
|
130
|
+
headers: { "Content-Type": "application/json" },
|
|
131
|
+
body: JSON.stringify(body),
|
|
132
|
+
});
|
|
133
|
+
return asSpritesSandbox({
|
|
134
|
+
name: String(created?.name ?? name),
|
|
135
|
+
id: created?.id ? String(created.id) : undefined,
|
|
136
|
+
url: typeof created?.url === "string" ? created.url : undefined,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function normalizeSpritesExecResult(payload) {
|
|
140
|
+
const exitCodeRaw = payload?.exit_code ??
|
|
141
|
+
payload?.exitCode ??
|
|
142
|
+
payload?.code ??
|
|
143
|
+
payload?.status ??
|
|
144
|
+
payload?.result?.exit_code ??
|
|
145
|
+
payload?.result?.exitCode;
|
|
146
|
+
const exitCode = Number(exitCodeRaw ?? 0);
|
|
147
|
+
const stdout = typeof payload?.stdout === "string"
|
|
148
|
+
? payload.stdout
|
|
149
|
+
: typeof payload?.output === "string"
|
|
150
|
+
? payload.output
|
|
151
|
+
: typeof payload?.out === "string"
|
|
152
|
+
? payload.out
|
|
153
|
+
: typeof payload?.result?.stdout === "string"
|
|
154
|
+
? payload.result.stdout
|
|
155
|
+
: "";
|
|
156
|
+
const stderr = typeof payload?.stderr === "string"
|
|
157
|
+
? payload.stderr
|
|
158
|
+
: typeof payload?.error === "string"
|
|
159
|
+
? payload.error
|
|
160
|
+
: typeof payload?.err === "string"
|
|
161
|
+
? payload.err
|
|
162
|
+
: typeof payload?.result?.stderr === "string"
|
|
163
|
+
? payload.result.stderr
|
|
164
|
+
: "";
|
|
165
|
+
return {
|
|
166
|
+
exitCode: Number.isFinite(exitCode) ? exitCode : 0,
|
|
167
|
+
stdout: sanitizeSpritesString(stdout),
|
|
168
|
+
stderr: sanitizeSpritesString(stderr),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export async function spritesExec(params) {
|
|
172
|
+
const spriteName = String(params.spriteName ?? "").trim();
|
|
173
|
+
if (!spriteName)
|
|
174
|
+
throw new Error("sprites_name_required");
|
|
175
|
+
const parts = [String(params.command ?? "").trim(), ...(Array.isArray(params.args) ? params.args : [])].filter(Boolean);
|
|
176
|
+
if (parts.length === 0)
|
|
177
|
+
throw new Error("sprites_command_required");
|
|
178
|
+
const search = new URLSearchParams();
|
|
179
|
+
for (const part of parts) {
|
|
180
|
+
search.append("cmd", String(part));
|
|
181
|
+
}
|
|
182
|
+
const hasStdin = typeof params.stdin === "string" || Buffer.isBuffer(params.stdin);
|
|
183
|
+
if (hasStdin) {
|
|
184
|
+
search.set("stdin", "true");
|
|
185
|
+
}
|
|
186
|
+
const path = `/v1/sprites/${encodeURIComponent(spriteName)}/exec?${search.toString()}`;
|
|
187
|
+
const init = {
|
|
188
|
+
method: "POST",
|
|
189
|
+
};
|
|
190
|
+
if (hasStdin) {
|
|
191
|
+
init.body = params.stdin;
|
|
192
|
+
}
|
|
193
|
+
const res = await spritesFetch(path, init);
|
|
194
|
+
const text = await res?.text?.().catch(() => "");
|
|
195
|
+
const parsed = (() => {
|
|
196
|
+
try {
|
|
197
|
+
return text ? JSON.parse(text) : {};
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return { stdout: String(text ?? "") };
|
|
201
|
+
}
|
|
202
|
+
})();
|
|
203
|
+
if (!res?.ok) {
|
|
204
|
+
const err = typeof parsed?.error === "string" ? parsed.error : text;
|
|
205
|
+
throw new Error(err || `sprites_exec_http_${res?.status ?? "unknown"}`);
|
|
206
|
+
}
|
|
207
|
+
return normalizeSpritesExecResult(parsed);
|
|
208
|
+
}
|
|
209
|
+
export function parseSpritesCheckpointIdFromNdjson(text) {
|
|
210
|
+
const lines = String(text ?? "")
|
|
211
|
+
.split("\n")
|
|
212
|
+
.map((l) => l.trim())
|
|
213
|
+
.filter(Boolean);
|
|
214
|
+
const candidates = [];
|
|
215
|
+
for (const line of lines) {
|
|
216
|
+
try {
|
|
217
|
+
const evt = JSON.parse(line);
|
|
218
|
+
const data = typeof evt?.data === "string" ? evt.data : "";
|
|
219
|
+
if (!data)
|
|
220
|
+
continue;
|
|
221
|
+
const m = data.match(/\bID:\s*(v[0-9]+)\b/i) || data.match(/\bCheckpoint\s+(v[0-9]+)\b/i);
|
|
222
|
+
if (m?.[1]) {
|
|
223
|
+
candidates.push(String(m[1]));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
// ignore invalid ndjson lines
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (candidates.length === 0)
|
|
231
|
+
return null;
|
|
232
|
+
return candidates[candidates.length - 1] ?? null;
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=sprites.js.map
|