managed-deepagents 0.5.4-dev.12 → 0.5.4-dev.13
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 +43 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/runtime/backend.d.ts +1 -0
- package/dist/runtime/backend.d.ts.map +1 -1
- package/dist/runtime/backend.js +8 -39
- package/dist/runtime/backend.js.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/sandbox-manager.d.ts +45 -41
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +132 -134
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/sandbox-stream-retry.d.ts +18 -0
- package/dist/runtime/sandbox-stream-retry.d.ts.map +1 -0
- package/dist/runtime/sandbox-stream-retry.js +90 -0
- package/dist/runtime/sandbox-stream-retry.js.map +1 -0
- package/dist/runtime/setup-script.d.ts +18 -0
- package/dist/runtime/setup-script.d.ts.map +1 -0
- package/dist/runtime/setup-script.js +49 -0
- package/dist/runtime/setup-script.js.map +1 -0
- package/dist/runtime/types.d.ts +5 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandbox.d.ts +15 -61
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +7 -25
- package/dist/sandbox.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
//# sourceMappingURL=setup-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-script.js","sourceRoot":"","sources":["../../src/runtime/setup-script.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,+EAA+E;AAC/E,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAiC,EACjC,MAAc;IAEd,MAAM,SAAS,GACb,IAAI,IAAI,OAAO,IAAI,OAAQ,OAA4B,CAAC,EAAE,KAAK,QAAQ;QACrE,CAAC,CAAE,OAA0B,CAAC,EAAE;QAChC,CAAC,CAAC,IAAI,CAAC;IACX,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QAC9C,OAAO,CAAC,IAAI,CACV,2CAA2C;YACzC,cAAc,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,iBAAiB,EAAE,CACtE,CAAC;QACF,MAAM,OAAO,CAAC,WAAW,CAAC;YACxB,CAAC,iBAAiB,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACtD,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CACV,2CAA2C;YACzC,cAAc,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG;YAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,iBAAiB,EAAE,CAAC,EAAE,CACvD,CAAC;QACF,4EAA4E;QAC5E,oBAAoB,CAClB,MAAM,sBAAsB,CAC1B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EACrC,QAAQ,iBAAiB,EAAE,EAC3B,EAAE,KAAK,EAAE,UAAU,EAAE,CACtB,CACF,CAAC;QACF,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CACV,kDAAkD;QAChD,cAAc,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAC5C,CAAC;IACF,MAAM,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAiC,EACjC,MAAc;IAEd,oBAAoB,CAClB,MAAM,sBAAsB,CAC1B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EACrC,MAAM,EACN;QACE,KAAK,EAAE,mBAAmB;KAC3B,CACF,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAoD;IAEpD,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,0CAA0C,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1F,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -45,6 +45,11 @@ export interface ManagedAgentOptions {
|
|
|
45
45
|
hasSkills?: boolean;
|
|
46
46
|
/** The `sandbox/index.ts` declaration, if the project configures a sandbox. */
|
|
47
47
|
sandbox?: SandboxDefinition;
|
|
48
|
+
/**
|
|
49
|
+
* Contents of `sandbox/setup.sh`, embedded by the CLI. It runs exactly once,
|
|
50
|
+
* the first time a sandbox is provisioned for a given scope.
|
|
51
|
+
*/
|
|
52
|
+
setupScript?: string;
|
|
48
53
|
/**
|
|
49
54
|
* The connectors discovered under `connectors/`, already validated by
|
|
50
55
|
* `collectConnectors`. Each connector's `tools` hook (if any) contributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/sandbox.d.ts
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
|
+
* scoped reuse across turns, the provisioning `setup.sh`, and lifecycle/TTL.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
@@ -14,14 +14,15 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
import type { LangSmithSandbox } from "deepagents";
|
|
17
|
+
/** Reuse boundary for a managed sandbox. Defaults to `"thread"`. */
|
|
18
|
+
export type SandboxScope = "thread" | "agent";
|
|
17
19
|
/**
|
|
18
20
|
* Provider options MDA owns and developers must not set directly.
|
|
19
21
|
*
|
|
20
22
|
* MDA owns sandbox identity and managed runtime safety knobs. Use
|
|
21
|
-
* `
|
|
22
|
-
* bake base is needed.
|
|
23
|
+
* `templateName` or `snapshotId` when an explicit LangSmith source is needed.
|
|
23
24
|
*/
|
|
24
|
-
type ManagedSandboxOptionKey = "name" | "image" | "snapshot" | "imageName"
|
|
25
|
+
type ManagedSandboxOptionKey = "name" | "image" | "snapshot" | "imageName";
|
|
25
26
|
type LangSmithCreateOptions = typeof LangSmithSandbox extends {
|
|
26
27
|
create(options: infer TOptions): Promise<unknown>;
|
|
27
28
|
} ? TOptions extends object ? TOptions : never : never;
|
|
@@ -29,68 +30,21 @@ type LangSmithCreateOptions = typeof LangSmithSandbox extends {
|
|
|
29
30
|
* Developer-provided options for the managed sandbox.
|
|
30
31
|
*
|
|
31
32
|
* Mirrors the supported LangSmith creation options, minus the fields MDA owns,
|
|
32
|
-
* plus
|
|
33
|
+
* plus the managed reuse/lifecycle knobs.
|
|
33
34
|
*/
|
|
34
|
-
export type SandboxOptions =
|
|
35
|
-
/**
|
|
36
|
-
* Lifecycle and LangSmith create knobs that are always allowed, regardless of
|
|
37
|
-
* which bake base (if any) the author picks.
|
|
38
|
-
*/
|
|
39
|
-
type SandboxSharedOptions = Omit<LangSmithCreateOptions, ManagedSandboxOptionKey> & {
|
|
40
|
-
/**
|
|
41
|
-
* Idle TTL in seconds. MDA may reclaim the sandbox after this period of
|
|
42
|
-
* inactivity.
|
|
43
|
-
*/
|
|
44
|
-
idleTtlSeconds?: number;
|
|
45
|
-
};
|
|
46
|
-
/** Credentials for a private Docker registry, reconciled by MDA at bake time. */
|
|
47
|
-
export interface SandboxRegistry {
|
|
48
|
-
/** Registry host, for example `ghcr.io`. */
|
|
49
|
-
url: string;
|
|
50
|
-
/** Registry username (for GHCR, the GitHub account or organization user). */
|
|
51
|
-
username: string;
|
|
35
|
+
export type SandboxOptions = Omit<LangSmithCreateOptions, ManagedSandboxOptionKey> & {
|
|
52
36
|
/**
|
|
53
|
-
*
|
|
37
|
+
* Sandbox reuse scope. Defaults to `"thread"`.
|
|
54
38
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* build or recipe snapshot.
|
|
39
|
+
* - `"thread"`: one sandbox per durable thread/conversation.
|
|
40
|
+
* - `"agent"`: one sandbox shared by all threads handled by this agent process.
|
|
58
41
|
*/
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Deploy-time bake base. At most one of `snapshotName`, `snapshotId`, or
|
|
63
|
-
* `dockerImage` may be set — combining them is a type error.
|
|
64
|
-
*
|
|
65
|
-
* `registry` is only valid with `dockerImage`. MDA creates or updates a
|
|
66
|
-
* deployment-owned Host registry before pulling the private image.
|
|
67
|
-
*/
|
|
68
|
-
export type SandboxBakeBase = {
|
|
69
|
-
snapshotName?: undefined;
|
|
70
|
-
snapshotId?: undefined;
|
|
71
|
-
dockerImage?: undefined;
|
|
72
|
-
registry?: undefined;
|
|
73
|
-
} | {
|
|
74
|
-
/** LangSmith snapshot name used as the bake base (supports tags). */
|
|
75
|
-
snapshotName: string;
|
|
76
|
-
snapshotId?: never;
|
|
77
|
-
dockerImage?: never;
|
|
78
|
-
registry?: never;
|
|
79
|
-
} | {
|
|
80
|
-
/** LangSmith snapshot id used as the bake base. */
|
|
81
|
-
snapshotId: string;
|
|
82
|
-
snapshotName?: never;
|
|
83
|
-
dockerImage?: never;
|
|
84
|
-
registry?: never;
|
|
85
|
-
} | {
|
|
86
|
-
/** Docker image used as the bake base. */
|
|
87
|
-
dockerImage: string;
|
|
88
|
-
snapshotName?: never;
|
|
89
|
-
snapshotId?: never;
|
|
42
|
+
scope?: SandboxScope;
|
|
90
43
|
/**
|
|
91
|
-
*
|
|
44
|
+
* Idle TTL in seconds. MDA may reclaim the sandbox after this period of
|
|
45
|
+
* inactivity.
|
|
92
46
|
*/
|
|
93
|
-
|
|
47
|
+
idleTtlSeconds?: number;
|
|
94
48
|
};
|
|
95
49
|
/** The object exported from `sandbox/index.ts`. */
|
|
96
50
|
export interface SandboxDefinition {
|
|
@@ -98,7 +52,7 @@ export interface SandboxDefinition {
|
|
|
98
52
|
readonly options: SandboxOptions;
|
|
99
53
|
}
|
|
100
54
|
/**
|
|
101
|
-
*
|
|
55
|
+
* Apply the default scope and reject the provider options MDA owns.
|
|
102
56
|
*
|
|
103
57
|
* Used by `defineSandbox`, so runtime-owned keys never enter a definition.
|
|
104
58
|
*/
|
package/dist/sandbox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,oEAAoE;AACpE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE9C;;;;;GAKG;AACH,KAAK,uBAAuB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC;AAE3E,KAAK,sBAAsB,GAAG,OAAO,gBAAgB,SAAS;IAC5D,MAAM,CAAC,OAAO,EAAE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD,GACG,QAAQ,SAAS,MAAM,GACrB,QAAQ,GACR,KAAK,GACP,KAAK,CAAC;AAEV;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,sBAAsB,EACtB,uBAAuB,CACxB,GAAG;IACF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,cAAc,GACvB,cAAc,CAchB;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAEzE"}
|
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
|
+
* scoped reuse across turns, the provisioning `setup.sh`, and lifecycle/TTL.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
@@ -14,38 +14,20 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Apply the default scope and reject the provider options MDA owns.
|
|
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
|
-
|
|
22
|
+
const scope = options?.scope ?? "thread";
|
|
23
|
+
if (scope !== "thread" && scope !== "agent") {
|
|
24
|
+
throw new TypeError('sandbox scope must be "thread" or "agent"');
|
|
24
25
|
}
|
|
25
26
|
const managed = managedOptionKeys(options);
|
|
26
27
|
if (managed.length > 0) {
|
|
27
28
|
throw new TypeError(`${managed.join(", ")} ${managed.length === 1 ? "is" : "are"} owned by the managed runtime and cannot be set on a sandbox.`);
|
|
28
29
|
}
|
|
29
|
-
|
|
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 ?? {}) };
|
|
30
|
+
return { ...options, scope };
|
|
49
31
|
}
|
|
50
32
|
/** Declare the managed execution environment for an agent. */
|
|
51
33
|
export function defineSandbox(options) {
|
|
@@ -54,6 +36,6 @@ export function defineSandbox(options) {
|
|
|
54
36
|
function managedOptionKeys(options) {
|
|
55
37
|
if (!options)
|
|
56
38
|
return [];
|
|
57
|
-
return ["name", "image", "snapshot", "imageName"
|
|
39
|
+
return ["name", "image", "snapshot", "imageName"].filter((key) => Object.prototype.hasOwnProperty.call(options, key));
|
|
58
40
|
}
|
|
59
41
|
//# 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;AAqDH;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAwB;IAExB,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,QAAQ,CAAC;IACzC,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3C,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,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAoB,CAAC;AACjD,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,OAAwB;IACpD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,CAAC,OAAO,CAAC,EAAE,CAAC;AACxE,CAAC;AAED,SAAS,iBAAiB,CACxB,OAA4C;IAE5C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAC/D,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CACnD,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.13",
|
|
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.13",
|
|
69
|
+
"@langchain/managed-deepagents-darwin-x64": "0.5.4-dev.13",
|
|
70
|
+
"@langchain/managed-deepagents-linux-arm64": "0.5.4-dev.13",
|
|
71
|
+
"@langchain/managed-deepagents-linux-x64": "0.5.4-dev.13",
|
|
72
|
+
"@langchain/managed-deepagents-win32-arm64": "0.5.4-dev.13",
|
|
73
|
+
"@langchain/managed-deepagents-win32-x64": "0.5.4-dev.13"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/node": "^26.1.1",
|