managed-deepagents 0.5.4-dev.2 → 0.5.4-dev.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.
- package/README.md +25 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/runtime/backend.d.ts +0 -1
- package/dist/runtime/backend.d.ts.map +1 -1
- package/dist/runtime/backend.js +38 -8
- package/dist/runtime/backend.js.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/sandbox-manager.d.ts +40 -45
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +113 -132
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/types.d.ts +0 -5
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandbox.d.ts +61 -15
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +25 -7
- package/dist/sandbox.js.map +1 -1
- package/package.json +7 -7
- package/dist/runtime/sandbox-stream-retry.d.ts +0 -18
- package/dist/runtime/sandbox-stream-retry.d.ts.map +0 -1
- package/dist/runtime/sandbox-stream-retry.js +0 -90
- package/dist/runtime/sandbox-stream-retry.js.map +0 -1
- package/dist/runtime/setup-script.d.ts +0 -18
- package/dist/runtime/setup-script.d.ts.map +0 -1
- package/dist/runtime/setup-script.js +0 -49
- package/dist/runtime/setup-script.js.map +0 -1
package/dist/sandbox.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A Managed Deep Agent declares its execution environment in `sandbox/index.ts`
|
|
5
5
|
* with `defineSandbox`. MDA owns how the sandbox is *resolved*: construction,
|
|
6
|
-
*
|
|
6
|
+
* per-thread reuse, deploy-time snapshot bake from `setup.sh`, and lifecycle/TTL.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
@@ -14,20 +14,38 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Reject provider options MDA owns and enforce bake-base mutual exclusion.
|
|
18
18
|
*
|
|
19
19
|
* Used by `defineSandbox`, so runtime-owned keys never enter a definition.
|
|
20
20
|
*/
|
|
21
21
|
export function normalizeSandboxOptions(options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw new TypeError('sandbox scope must be "thread" or "agent"');
|
|
22
|
+
if (options && "scope" in options) {
|
|
23
|
+
throw new TypeError('sandbox scope is owned by the managed runtime (always "thread") and cannot be set on a sandbox.');
|
|
25
24
|
}
|
|
26
25
|
const managed = managedOptionKeys(options);
|
|
27
26
|
if (managed.length > 0) {
|
|
28
27
|
throw new TypeError(`${managed.join(", ")} ${managed.length === 1 ? "is" : "are"} owned by the managed runtime and cannot be set on a sandbox.`);
|
|
29
28
|
}
|
|
30
|
-
|
|
29
|
+
const bases = [
|
|
30
|
+
options?.snapshotName ? "snapshotName" : null,
|
|
31
|
+
options?.snapshotId ? "snapshotId" : null,
|
|
32
|
+
options?.dockerImage ? "dockerImage" : null,
|
|
33
|
+
].filter((value) => value !== null);
|
|
34
|
+
if (bases.length > 1) {
|
|
35
|
+
throw new TypeError(`${bases.join(", ")} are mutually exclusive. Pass only one bake base.`);
|
|
36
|
+
}
|
|
37
|
+
if (options?.registry && !options?.dockerImage) {
|
|
38
|
+
throw new TypeError("registry requires dockerImage. Pass both when pulling a private image.");
|
|
39
|
+
}
|
|
40
|
+
if (options?.registry) {
|
|
41
|
+
for (const field of ["url", "username", "passwordEnv"]) {
|
|
42
|
+
if (typeof options.registry[field] !== "string" ||
|
|
43
|
+
!options.registry[field].trim()) {
|
|
44
|
+
throw new TypeError(`registry.${field} must be a non-empty string.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { ...(options ?? {}) };
|
|
31
49
|
}
|
|
32
50
|
/** Declare the managed execution environment for an agent. */
|
|
33
51
|
export function defineSandbox(options) {
|
|
@@ -36,6 +54,6 @@ export function defineSandbox(options) {
|
|
|
36
54
|
function managedOptionKeys(options) {
|
|
37
55
|
if (!options)
|
|
38
56
|
return [];
|
|
39
|
-
return ["name", "image", "snapshot", "imageName"].filter((key) => Object.prototype.hasOwnProperty.call(options, key));
|
|
57
|
+
return ["name", "image", "snapshot", "imageName", "templateName"].filter((key) => Object.prototype.hasOwnProperty.call(options, key));
|
|
40
58
|
}
|
|
41
59
|
//# sourceMappingURL=sandbox.js.map
|
package/dist/sandbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA+GH;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAwB;IAExB,IAAI,OAAO,IAAI,OAAO,IAAK,OAAmC,EAAE,CAAC;QAC/D,MAAM,IAAI,SAAS,CACjB,iGAAiG,CAClG,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,iBAAiB,CAC/B,OAA8C,CAC/C,CAAC;IACF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,SAAS,CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IACnB,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAChC,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG;QACZ,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI;QAC7C,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CA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AC,MAAM,CACtE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAC5D,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "managed-deepagents",
|
|
3
|
-
"version": "0.5.4-dev.
|
|
3
|
+
"version": "0.5.4-dev.3",
|
|
4
4
|
"description": "Managed Deep Agents — the `defineDeepAgent` authoring interface plus the CLI that compiles and deploys a code-first Deep Agent repository to a managed LangGraph runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"langchain",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"zod": "^4.4.3"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
|
-
"@langchain/managed-deepagents-darwin-arm64": "0.5.4-dev.
|
|
69
|
-
"@langchain/managed-deepagents-darwin-x64": "0.5.4-dev.
|
|
70
|
-
"@langchain/managed-deepagents-linux-arm64": "0.5.4-dev.
|
|
71
|
-
"@langchain/managed-deepagents-linux-x64": "0.5.4-dev.
|
|
72
|
-
"@langchain/managed-deepagents-win32-arm64": "0.5.4-dev.
|
|
73
|
-
"@langchain/managed-deepagents-win32-x64": "0.5.4-dev.
|
|
68
|
+
"@langchain/managed-deepagents-darwin-arm64": "0.5.4-dev.3",
|
|
69
|
+
"@langchain/managed-deepagents-darwin-x64": "0.5.4-dev.3",
|
|
70
|
+
"@langchain/managed-deepagents-linux-arm64": "0.5.4-dev.3",
|
|
71
|
+
"@langchain/managed-deepagents-linux-x64": "0.5.4-dev.3",
|
|
72
|
+
"@langchain/managed-deepagents-win32-arm64": "0.5.4-dev.3",
|
|
73
|
+
"@langchain/managed-deepagents-win32-x64": "0.5.4-dev.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/node": "^26.1.1",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retry sandbox `execute` when the command stream dies before start.
|
|
3
|
-
*
|
|
4
|
-
* LangSmith sandboxes can return HTTP 201 / accept uploads while the websocket
|
|
5
|
-
* command channel is not ready yet. The first `execute` then fails with
|
|
6
|
-
* `Command stream ended before 'started' message`. Cold GitHub provision and
|
|
7
|
-
* `setup.sh` hit this path immediately after create; retrying the same execute
|
|
8
|
-
* with backoff is cheaper (and more reliable) than throwing away the box.
|
|
9
|
-
*/
|
|
10
|
-
export declare function isSandboxStreamError(error: unknown): boolean;
|
|
11
|
-
export declare function executeWithStreamRetry<T>(execute: (command: string) => Promise<T> | T, command: string, options?: {
|
|
12
|
-
/** Fixed operation name for Host logs. Never pass command contents. */
|
|
13
|
-
label?: string;
|
|
14
|
-
attempts?: number;
|
|
15
|
-
baseDelayMs?: number;
|
|
16
|
-
sleep?: (ms: number) => Promise<void>;
|
|
17
|
-
}): Promise<T>;
|
|
18
|
-
//# sourceMappingURL=sandbox-stream-retry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-stream-retry.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-stream-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwBH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAoB5D;AAED,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAC5C,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,GACL,OAAO,CAAC,CAAC,CAAC,CAsDZ"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retry sandbox `execute` when the command stream dies before start.
|
|
3
|
-
*
|
|
4
|
-
* LangSmith sandboxes can return HTTP 201 / accept uploads while the websocket
|
|
5
|
-
* command channel is not ready yet. The first `execute` then fails with
|
|
6
|
-
* `Command stream ended before 'started' message`. Cold GitHub provision and
|
|
7
|
-
* `setup.sh` hit this path immediately after create; retrying the same execute
|
|
8
|
-
* with backoff is cheaper (and more reliable) than throwing away the box.
|
|
9
|
-
*/
|
|
10
|
-
const STREAM_EXECUTE_ATTEMPTS = 6;
|
|
11
|
-
// Cold boxes often need several seconds after HTTP 201 before the websocket
|
|
12
|
-
// command channel is ready — a 1s base burned through attempts too quickly.
|
|
13
|
-
const STREAM_EXECUTE_BASE_DELAY_MS = 2_000;
|
|
14
|
-
// Only the "never started" race is safe to retry in place. Broader transport
|
|
15
|
-
// errors (bare SandboxOperationError, truncated HTTP bodies) can arrive after
|
|
16
|
-
// the command began or finished — those belong on the invalidate/recreate path.
|
|
17
|
-
const STREAM_NEVER_STARTED_RE = /Command stream ended before ['"]started['"] message/i;
|
|
18
|
-
const STREAM_NEVER_STARTED_NAMES = new Set([
|
|
19
|
-
"_StreamEndedBeforeStarted",
|
|
20
|
-
"StreamEndedBeforeStarted",
|
|
21
|
-
]);
|
|
22
|
-
function errorLabel(error) {
|
|
23
|
-
if (error instanceof Error) {
|
|
24
|
-
return `${error.name}: ${error.message}`;
|
|
25
|
-
}
|
|
26
|
-
return String(error);
|
|
27
|
-
}
|
|
28
|
-
export function isSandboxStreamError(error) {
|
|
29
|
-
if (error instanceof Error && STREAM_NEVER_STARTED_NAMES.has(error.name)) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
if (error !== null &&
|
|
33
|
-
typeof error === "object" &&
|
|
34
|
-
STREAM_NEVER_STARTED_NAMES.has(error.constructor?.name ?? "")) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
const message = error instanceof Error
|
|
38
|
-
? `${error.name}: ${error.message}`
|
|
39
|
-
: typeof error === "string"
|
|
40
|
-
? error
|
|
41
|
-
: String(error);
|
|
42
|
-
return STREAM_NEVER_STARTED_RE.test(message);
|
|
43
|
-
}
|
|
44
|
-
export async function executeWithStreamRetry(execute, command, options = {}) {
|
|
45
|
-
const attempts = options.attempts ?? STREAM_EXECUTE_ATTEMPTS;
|
|
46
|
-
const baseDelayMs = options.baseDelayMs ?? STREAM_EXECUTE_BASE_DELAY_MS;
|
|
47
|
-
const sleep = options.sleep ??
|
|
48
|
-
((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
49
|
-
if (attempts < 1) {
|
|
50
|
-
throw new Error("attempts must be >= 1");
|
|
51
|
-
}
|
|
52
|
-
let lastError;
|
|
53
|
-
const op = options.label?.trim() || "execute";
|
|
54
|
-
const started = Date.now();
|
|
55
|
-
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
56
|
-
const attemptStarted = Date.now();
|
|
57
|
-
try {
|
|
58
|
-
const result = await execute(command);
|
|
59
|
-
if (attempt > 0) {
|
|
60
|
-
console.warn(`[mda] sandbox stream execute recovered after ${attempt + 1} attempt(s) ` +
|
|
61
|
-
`(${((Date.now() - started) / 1000).toFixed(1)}s total) op=${JSON.stringify(op)}`);
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
lastError = error;
|
|
67
|
-
const elapsedAttempt = (Date.now() - attemptStarted) / 1000;
|
|
68
|
-
if (!isSandboxStreamError(error)) {
|
|
69
|
-
console.warn(`[mda] sandbox execute failed (not stream-retryable) ` +
|
|
70
|
-
`attempt=${attempt + 1}/${attempts} elapsed=${elapsedAttempt.toFixed(1)}s ` +
|
|
71
|
-
`op=${JSON.stringify(op)} err=${errorLabel(error)}`);
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
if (attempt >= attempts - 1) {
|
|
75
|
-
console.warn(`[mda] sandbox stream execute exhausted retries ` +
|
|
76
|
-
`attempts=${attempts} elapsed=${((Date.now() - started) / 1000).toFixed(1)}s ` +
|
|
77
|
-
`op=${JSON.stringify(op)} err=${errorLabel(error)}`);
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
const delayMs = baseDelayMs * 2 ** attempt;
|
|
81
|
-
console.warn(`[mda] sandbox stream not ready; retrying execute ` +
|
|
82
|
-
`attempt=${attempt + 1}/${attempts} elapsed=${elapsedAttempt.toFixed(1)}s ` +
|
|
83
|
-
`sleep=${(delayMs / 1000).toFixed(1)}s op=${JSON.stringify(op)} ` +
|
|
84
|
-
`err=${errorLabel(error)}`);
|
|
85
|
-
await sleep(delayMs);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
throw lastError;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=sandbox-stream-retry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-stream-retry.js","sourceRoot":"","sources":["../../src/runtime/sandbox-stream-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,4EAA4E;AAC5E,4EAA4E;AAC5E,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAE3C,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAChF,MAAM,uBAAuB,GAC3B,sDAAsD,CAAC;AACzD,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IACzC,2BAA2B;IAC3B,0BAA0B;CAC3B,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,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,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;oBAC9E,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,UAAU,CAAC,KAAK,CAAC,EAAE,CACtD,CAAC;gBACF,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,OAAO,GAAG,WAAW,GAAG,CAAC,IAAI,OAAO,CAAC;YAC3C,OAAO,CAAC,IAAI,CACV,mDAAmD;gBACjD,WAAW,OAAO,GAAG,CAAC,IAAI,QAAQ,YAAY,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;gBAC3E,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG;gBACjE,OAAO,UAAU,CAAC,KAAK,CAAC,EAAE,CAC7B,CAAC;YACF,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,MAAM,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ExecuteResponse, SandboxBackendProtocolV2 } from "deepagents";
|
|
2
|
-
/**
|
|
3
|
-
* Provision a freshly created sandbox by running `setup.sh` inside it. Reused
|
|
4
|
-
* sandboxes never reach this path, so the script runs once per new sandbox.
|
|
5
|
-
*
|
|
6
|
-
* When the backend supports file transfer, the script is uploaded and executed
|
|
7
|
-
* by path; otherwise it is run inline (see {@link runSetupScriptInline}).
|
|
8
|
-
*/
|
|
9
|
-
export declare function runSetupScript(backend: SandboxBackendProtocolV2, script: string): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Run `setup.sh` by piping its contents straight to the backend's shell.
|
|
12
|
-
*
|
|
13
|
-
* Kept as a compatibility fallback for sandbox backend implementations that
|
|
14
|
-
* conform to the execute surface but do not expose upload support.
|
|
15
|
-
*/
|
|
16
|
-
export declare function runSetupScriptInline(backend: SandboxBackendProtocolV2, script: string): Promise<void>;
|
|
17
|
-
export declare function assertSetupSucceeded(result: Pick<ExecuteResponse, "exitCode" | "output">): void;
|
|
18
|
-
//# sourceMappingURL=setup-script.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup-script.d.ts","sourceRoot":"","sources":["../../src/runtime/setup-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAO5E;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAiCf;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,QAAQ,CAAC,GACnD,IAAI,CAON"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { executeWithStreamRetry } from "./sandbox-stream-retry.js";
|
|
2
|
-
/** Absolute path the provisioning script is uploaded to inside the sandbox. */
|
|
3
|
-
const SETUP_REMOTE_PATH = "/tmp/mda-setup.sh";
|
|
4
|
-
/**
|
|
5
|
-
* Provision a freshly created sandbox by running `setup.sh` inside it. Reused
|
|
6
|
-
* sandboxes never reach this path, so the script runs once per new sandbox.
|
|
7
|
-
*
|
|
8
|
-
* When the backend supports file transfer, the script is uploaded and executed
|
|
9
|
-
* by path; otherwise it is run inline (see {@link runSetupScriptInline}).
|
|
10
|
-
*/
|
|
11
|
-
export async function runSetupScript(backend, script) {
|
|
12
|
-
const sandboxId = "id" in backend && typeof backend.id === "string"
|
|
13
|
-
? backend.id
|
|
14
|
-
: null;
|
|
15
|
-
if (typeof backend.uploadFiles === "function") {
|
|
16
|
-
console.info(`[mda] sandbox setup.sh: uploading script ` +
|
|
17
|
-
`sandbox_id=${JSON.stringify(sandboxId)} path=${SETUP_REMOTE_PATH}`);
|
|
18
|
-
await backend.uploadFiles([
|
|
19
|
-
[SETUP_REMOTE_PATH, new TextEncoder().encode(script)],
|
|
20
|
-
]);
|
|
21
|
-
console.info(`[mda] sandbox setup.sh: starting execute ` +
|
|
22
|
-
`sandbox_id=${JSON.stringify(sandboxId)} ` +
|
|
23
|
-
`cmd=${JSON.stringify(`bash ${SETUP_REMOTE_PATH}`)}`);
|
|
24
|
-
// Fresh sandboxes often reject the first websocket execute; retry in place.
|
|
25
|
-
assertSetupSucceeded(await executeWithStreamRetry((command) => backend.execute(command), `bash ${SETUP_REMOTE_PATH}`, { label: "setup.sh" }));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
console.info(`[mda] sandbox setup.sh: starting inline execute ` +
|
|
29
|
-
`sandbox_id=${JSON.stringify(sandboxId)}`);
|
|
30
|
-
await runSetupScriptInline(backend, script);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Run `setup.sh` by piping its contents straight to the backend's shell.
|
|
34
|
-
*
|
|
35
|
-
* Kept as a compatibility fallback for sandbox backend implementations that
|
|
36
|
-
* conform to the execute surface but do not expose upload support.
|
|
37
|
-
*/
|
|
38
|
-
export async function runSetupScriptInline(backend, script) {
|
|
39
|
-
assertSetupSucceeded(await executeWithStreamRetry((command) => backend.execute(command), script, {
|
|
40
|
-
label: "setup.sh (inline)",
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
export function assertSetupSucceeded(result) {
|
|
44
|
-
if (typeof result.exitCode === "number" && result.exitCode !== 0) {
|
|
45
|
-
const detail = (result.output ?? "").trim();
|
|
46
|
-
throw new Error(`sandbox setup.sh failed with exit code ${result.exitCode}${detail ? `: ${detail}` : ""}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingUR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