managed-deepagents 0.0.1 → 0.0.3-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 +95 -0
- package/bin/mda.mjs +30 -0
- package/dist/define-deep-agent.d.ts +28 -0
- package/dist/define-deep-agent.d.ts.map +1 -0
- package/dist/define-deep-agent.js +32 -0
- package/dist/define-deep-agent.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/resolve.d.ts +11 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +33 -0
- package/dist/resolve.js.map +1 -0
- package/dist/runtime/credentials.d.ts +42 -0
- package/dist/runtime/credentials.d.ts.map +1 -0
- package/dist/runtime/credentials.js +69 -0
- package/dist/runtime/credentials.js.map +1 -0
- package/dist/runtime/dev-notice.d.ts +7 -0
- package/dist/runtime/dev-notice.d.ts.map +1 -0
- package/dist/runtime/dev-notice.js +27 -0
- package/dist/runtime/dev-notice.js.map +1 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +25 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/local-dev-sandbox.d.ts +13 -0
- package/dist/runtime/local-dev-sandbox.d.ts.map +1 -0
- package/dist/runtime/local-dev-sandbox.js +39 -0
- package/dist/runtime/local-dev-sandbox.js.map +1 -0
- package/dist/runtime/sandbox-manager.d.ts +30 -0
- package/dist/runtime/sandbox-manager.d.ts.map +1 -0
- package/dist/runtime/sandbox-manager.js +143 -0
- package/dist/runtime/sandbox-manager.js.map +1 -0
- package/dist/runtime/setup-script.d.ts +23 -0
- package/dist/runtime/setup-script.d.ts.map +1 -0
- package/dist/runtime/setup-script.js +35 -0
- package/dist/runtime/setup-script.js.map +1 -0
- package/dist/runtime/types.d.ts +43 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/sandbox.d.ts +82 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +33 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +63 -7
- package/index.js +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://www.langchain.com/langsmith-managed-deep-agents-waitlist">
|
|
5
|
+
<img alt="Managed Deep Agents logo" src="https://raw.githubusercontent.com/langchain-ai/managed-deepagents-sdk/main/.github/assets/logo.png" width="70%">
|
|
6
|
+
</a>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
<h3>TypeScript authoring package and CLI launcher for Managed Deep Agents.</h3>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
> [!IMPORTANT]
|
|
14
|
+
> **Active development / private beta.** Managed Deep Agents is in active
|
|
15
|
+
> development and currently in private beta. The npm package API and managed
|
|
16
|
+
> runtime contract may change. [Join the
|
|
17
|
+
> waitlist](https://www.langchain.com/langsmith-managed-deep-agents-waitlist)
|
|
18
|
+
> for access and updates.
|
|
19
|
+
|
|
20
|
+
`managed-deepagents` is the npm package for authoring Managed Deep Agents in
|
|
21
|
+
TypeScript and Node.js. It includes:
|
|
22
|
+
|
|
23
|
+
- `defineDeepAgent`, the TypeScript authoring contract for managed agents.
|
|
24
|
+
- `mda`, the CLI used to build and deploy your agent to LangSmith.
|
|
25
|
+
- `managed-deepagents/runtime`, the runtime helper used by generated managed
|
|
26
|
+
entry modules.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install managed-deepagents
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> [!NOTE]
|
|
35
|
+
> **Private beta: dev releases only.** We currently publish under the `dev`
|
|
36
|
+
> dist-tag and have no stable `latest` version yet. Install the dev channel
|
|
37
|
+
> explicitly:
|
|
38
|
+
>
|
|
39
|
+
> ```bash
|
|
40
|
+
> npm install managed-deepagents@dev
|
|
41
|
+
> ```
|
|
42
|
+
|
|
43
|
+
This package requires Node.js 22 or newer. The `mda` binary is delivered through
|
|
44
|
+
per-platform optional dependencies, so install only downloads the binary for your
|
|
45
|
+
OS and CPU architecture.
|
|
46
|
+
|
|
47
|
+
## Define an Agent
|
|
48
|
+
|
|
49
|
+
Create an `agent.ts` that exports a named `agent` definition:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { defineDeepAgent } from "managed-deepagents";
|
|
53
|
+
import instructions from "./instructions.md" with { type: "text" };
|
|
54
|
+
import { queryDB } from "./tools/query-db";
|
|
55
|
+
|
|
56
|
+
export const agent = defineDeepAgent({
|
|
57
|
+
model: "openai:gpt-5.5",
|
|
58
|
+
systemPrompt: instructions,
|
|
59
|
+
tools: [queryDB],
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`defineDeepAgent` accepts the `createDeepAgent` configuration surface minus the
|
|
64
|
+
managed keys: `backend`, `store`, and `checkpointer`. Those are provided by the
|
|
65
|
+
managed runtime when your agent is deployed.
|
|
66
|
+
|
|
67
|
+
## Project Shape
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
my-agent/
|
|
71
|
+
agent.ts
|
|
72
|
+
instructions.md
|
|
73
|
+
tools/
|
|
74
|
+
middleware/
|
|
75
|
+
skills/
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The CLI copies your project files into the managed build and generates the entry
|
|
79
|
+
module that connects your definition to the hosted runtime.
|
|
80
|
+
|
|
81
|
+
## CLI
|
|
82
|
+
|
|
83
|
+
Build locally:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
mda build ./my-agent
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Deploy to LangSmith:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
mda deploy ./my-agent
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The generated build is written to `<root>/.mda/build` by default.
|
package/bin/mda.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Thin launcher that forwards all arguments to the prebuilt `mda` binary for
|
|
4
|
+
// the current platform. The binary is distributed via per-platform packages
|
|
5
|
+
// (see src/resolve.ts, compiled to dist/resolve.js).
|
|
6
|
+
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
|
|
9
|
+
import { resolveBinary } from "../dist/resolve.js";
|
|
10
|
+
|
|
11
|
+
function main() {
|
|
12
|
+
let binary;
|
|
13
|
+
try {
|
|
14
|
+
binary = resolveBinary();
|
|
15
|
+
} catch (error) {
|
|
16
|
+
process.stderr.write(`${error.message}\n`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
21
|
+
|
|
22
|
+
if (result.error) {
|
|
23
|
+
process.stderr.write(`failed to launch mda: ${result.error.message}\n`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DeepAgentDefinition, DefineDeepAgentConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Define a Managed Deep Agent.
|
|
4
|
+
*
|
|
5
|
+
* `defineDeepAgent` is the v0 authoring contract for MDA. It accepts the full
|
|
6
|
+
* `createDeepAgent` surface except the managed keys (`backend`, `store`,
|
|
7
|
+
* `checkpointer`, `systemPrompt`) and returns a pre-runtime spec — not a
|
|
8
|
+
* compiled graph.
|
|
9
|
+
*
|
|
10
|
+
* At deploy time, `mda` generates an entry module that hands this definition to
|
|
11
|
+
* the managed runtime, which injects the platform-owned backend/store/
|
|
12
|
+
* checkpointer, embeds the system prompt from `instructions.md`, and compiles
|
|
13
|
+
* it into a Deep Agent.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { defineDeepAgent } from "managed-deepagents";
|
|
18
|
+
* import { queryDB } from "./tools/query-db";
|
|
19
|
+
*
|
|
20
|
+
* // The system prompt comes from instructions.md next to this file.
|
|
21
|
+
* export const agent = defineDeepAgent({
|
|
22
|
+
* model: "openai:gpt-5.5",
|
|
23
|
+
* tools: [queryDB],
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function defineDeepAgent(config: DefineDeepAgentConfig): DeepAgentDefinition;
|
|
28
|
+
//# sourceMappingURL=define-deep-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-deep-agent.d.ts","sourceRoot":"","sources":["../src/define-deep-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,mBAAmB,CAKlF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Define a Managed Deep Agent.
|
|
3
|
+
*
|
|
4
|
+
* `defineDeepAgent` is the v0 authoring contract for MDA. It accepts the full
|
|
5
|
+
* `createDeepAgent` surface except the managed keys (`backend`, `store`,
|
|
6
|
+
* `checkpointer`, `systemPrompt`) and returns a pre-runtime spec — not a
|
|
7
|
+
* compiled graph.
|
|
8
|
+
*
|
|
9
|
+
* At deploy time, `mda` generates an entry module that hands this definition to
|
|
10
|
+
* the managed runtime, which injects the platform-owned backend/store/
|
|
11
|
+
* checkpointer, embeds the system prompt from `instructions.md`, and compiles
|
|
12
|
+
* it into a Deep Agent.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { defineDeepAgent } from "managed-deepagents";
|
|
17
|
+
* import { queryDB } from "./tools/query-db";
|
|
18
|
+
*
|
|
19
|
+
* // The system prompt comes from instructions.md next to this file.
|
|
20
|
+
* export const agent = defineDeepAgent({
|
|
21
|
+
* model: "openai:gpt-5.5",
|
|
22
|
+
* tools: [queryDB],
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function defineDeepAgent(config) {
|
|
27
|
+
return {
|
|
28
|
+
kind: "deep-agent",
|
|
29
|
+
config: config,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=define-deep-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-deep-agent.js","sourceRoot":"","sources":["../src/define-deep-agent.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,eAAe,CAAC,MAA6B;IAC3D,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,MAAuC;KAChD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { defineDeepAgent } from "./define-deep-agent.js";
|
|
2
|
+
export { defineSandbox } from "./sandbox.js";
|
|
3
|
+
export type { ChannelAttachment, ChannelDestination, ChannelEvent, ChannelMessage, ChannelPostOptions, DeepAgentDefinition, DefineDeepAgentConfig, ManagedDeepAgentKey, PostedChannelMessage, Runtime, RuntimeChannel, } from "./types.js";
|
|
4
|
+
export type { DefineSandboxOptions, ManagedSandboxOptionKey, SandboxDefinition, SandboxProviderClass, SandboxProviderOptions, SandboxScope, } from "./sandbox.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,OAAO,EACP,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,GACb,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface PlatformPackage {
|
|
2
|
+
pkg: string;
|
|
3
|
+
bin: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const PLATFORM_PACKAGES: Record<string, PlatformPackage>;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the absolute path to the platform-specific `mda` binary.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveBinary(): string;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AASA,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAM7D,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAqBtC"}
|
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Maps Node's process.platform/process.arch to the per-platform npm package
|
|
2
|
+
// that ships the matching prebuilt `mda` binary. These packages are published
|
|
3
|
+
// as optionalDependencies of the main `managed-deepagents` package, so npm only
|
|
4
|
+
// installs the one relevant to the host.
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
export const PLATFORM_PACKAGES = {
|
|
8
|
+
"darwin arm64": { pkg: "@langchain/managed-deepagents-darwin-arm64", bin: "mda" },
|
|
9
|
+
"darwin x64": { pkg: "@langchain/managed-deepagents-darwin-x64", bin: "mda" },
|
|
10
|
+
"linux arm64": { pkg: "@langchain/managed-deepagents-linux-arm64", bin: "mda" },
|
|
11
|
+
"linux x64": { pkg: "@langchain/managed-deepagents-linux-x64", bin: "mda" },
|
|
12
|
+
"win32 x64": { pkg: "@langchain/managed-deepagents-win32-x64", bin: "mda.exe" },
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the absolute path to the platform-specific `mda` binary.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveBinary() {
|
|
18
|
+
const key = `${process.platform} ${process.arch}`;
|
|
19
|
+
const entry = PLATFORM_PACKAGES[key];
|
|
20
|
+
if (!entry) {
|
|
21
|
+
throw new Error(`managed-deepagents does not ship a prebuilt binary for ${key}.\n` +
|
|
22
|
+
`Supported platforms: ${Object.keys(PLATFORM_PACKAGES).join(", ")}.`);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return require.resolve(`${entry.pkg}/bin/${entry.bin}`);
|
|
26
|
+
}
|
|
27
|
+
catch (cause) {
|
|
28
|
+
throw new Error(`The platform package "${entry.pkg}" is not installed.\n` +
|
|
29
|
+
`This usually means optional dependencies were skipped during install.\n` +
|
|
30
|
+
`Reinstall with optional dependencies enabled (e.g. \`npm install managed-deepagents\`).`, { cause });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,gFAAgF;AAChF,yCAAyC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAO/C,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,cAAc,EAAE,EAAE,GAAG,EAAE,4CAA4C,EAAE,GAAG,EAAE,KAAK,EAAE;IACjF,YAAY,EAAE,EAAE,GAAG,EAAE,0CAA0C,EAAE,GAAG,EAAE,KAAK,EAAE;IAC7E,aAAa,EAAE,EAAE,GAAG,EAAE,2CAA2C,EAAE,GAAG,EAAE,KAAK,EAAE;IAC/E,WAAW,EAAE,EAAE,GAAG,EAAE,yCAAyC,EAAE,GAAG,EAAE,KAAK,EAAE;IAC3E,WAAW,EAAE,EAAE,GAAG,EAAE,yCAAyC,EAAE,GAAG,EAAE,SAAS,EAAE;CAChF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAClD,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAErC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,0DAA0D,GAAG,KAAK;YAChE,wBAAwB,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACvE,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,GAAG,QAAQ,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,yBAAyB,KAAK,CAAC,GAAG,uBAAuB;YACvD,yEAAyE;YACzE,yFAAyF,EAC3F,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SandboxDefinition } from "../sandbox.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-provider environment variables MDA expects to hold the credentials each
|
|
4
|
+
* sandbox provider needs. Keyed by the provider's `providerId` (when set) or
|
|
5
|
+
* its class name.
|
|
6
|
+
*
|
|
7
|
+
* The value is a list of alternative credential *sets*: a provider is
|
|
8
|
+
* considered credentialed if **every** variable in **any one** set is present.
|
|
9
|
+
* An empty list means the provider needs no credentials (e.g. it runs locally).
|
|
10
|
+
*
|
|
11
|
+
* Sources: the deepagents sandbox docs and each provider's own SDK docs.
|
|
12
|
+
* - LangSmith: https://docs.langchain.com/langsmith/sandboxes
|
|
13
|
+
* - Daytona / E2B / Modal / Runloop / Vercel / AgentCore / Deno: provider SDK docs.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PROVIDER_CREDENTIAL_ENV_VARS: Record<string, string[][]>;
|
|
16
|
+
export interface ProviderCredentialStatus {
|
|
17
|
+
/**
|
|
18
|
+
* - `available`: required credentials are present (or none are needed).
|
|
19
|
+
* - `missing`: a known provider's credentials are absent.
|
|
20
|
+
* - `unknown`: provider is not in {@link PROVIDER_CREDENTIAL_ENV_VARS}.
|
|
21
|
+
*/
|
|
22
|
+
status: "available" | "missing" | "unknown";
|
|
23
|
+
/** The provider id / class name used for the lookup. */
|
|
24
|
+
provider: string;
|
|
25
|
+
/** Env vars from the primary credential set, surfaced when `missing`. */
|
|
26
|
+
missing: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether MDA is running under `mda dev`. The CLI sets `MDA_DEV` when it
|
|
30
|
+
* launches the local LangGraph dev server; it is never set for `mda deploy`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isDevMode(): boolean;
|
|
33
|
+
/** Resolve the lookup key for a sandbox provider (its id, else class name). */
|
|
34
|
+
export declare function providerKey(provider: SandboxDefinition["provider"]): string;
|
|
35
|
+
/** Whether every variable in a credential set is set and non-empty. */
|
|
36
|
+
export declare function credentialSetSatisfied(envVars: string[]): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Determine whether the configured provider's credentials are available so
|
|
39
|
+
* `mda dev` can decide between the real provider and the local fallback.
|
|
40
|
+
*/
|
|
41
|
+
export declare function providerCredentialStatus(provider: SandboxDefinition["provider"]): ProviderCredentialStatus;
|
|
42
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/runtime/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAsBnE,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5C,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAGnC;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,MAAM,CAG3E;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAEjE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACtC,wBAAwB,CAU1B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-provider environment variables MDA expects to hold the credentials each
|
|
3
|
+
* sandbox provider needs. Keyed by the provider's `providerId` (when set) or
|
|
4
|
+
* its class name.
|
|
5
|
+
*
|
|
6
|
+
* The value is a list of alternative credential *sets*: a provider is
|
|
7
|
+
* considered credentialed if **every** variable in **any one** set is present.
|
|
8
|
+
* An empty list means the provider needs no credentials (e.g. it runs locally).
|
|
9
|
+
*
|
|
10
|
+
* Sources: the deepagents sandbox docs and each provider's own SDK docs.
|
|
11
|
+
* - LangSmith: https://docs.langchain.com/langsmith/sandboxes
|
|
12
|
+
* - Daytona / E2B / Modal / Runloop / Vercel / AgentCore / Deno: provider SDK docs.
|
|
13
|
+
*/
|
|
14
|
+
export const PROVIDER_CREDENTIAL_ENV_VARS = {
|
|
15
|
+
// LangSmith managed sandboxes.
|
|
16
|
+
LangSmithSandbox: [["LANGSMITH_API_KEY"]],
|
|
17
|
+
// Daytona (`langchain-daytona` / deepagents `DaytonaSandbox`).
|
|
18
|
+
DaytonaSandbox: [["DAYTONA_API_KEY"]],
|
|
19
|
+
// E2B (`langchain-e2b` / deepagents `E2BSandbox`).
|
|
20
|
+
E2BSandbox: [["E2B_API_KEY"]],
|
|
21
|
+
// Modal requires both a token id and secret.
|
|
22
|
+
ModalSandbox: [["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]],
|
|
23
|
+
// Runloop devboxes.
|
|
24
|
+
RunloopSandbox: [["RUNLOOP_API_KEY"]],
|
|
25
|
+
// Vercel: either an OIDC token, or an access token + team + project ids.
|
|
26
|
+
VercelSandbox: [
|
|
27
|
+
["VERCEL_OIDC_TOKEN"],
|
|
28
|
+
["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"],
|
|
29
|
+
],
|
|
30
|
+
// AWS Bedrock AgentCore: standard AWS credential resolution.
|
|
31
|
+
AgentCoreSandbox: [["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"], ["AWS_PROFILE"]],
|
|
32
|
+
// Deno Deploy microVMs (`@langchain/deno`) need an organization token.
|
|
33
|
+
DenoSandbox: [["DENO_DEPLOY_TOKEN"]],
|
|
34
|
+
// Node VFS runs locally and needs no credentials.
|
|
35
|
+
NodeVFSSandbox: [],
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Whether MDA is running under `mda dev`. The CLI sets `MDA_DEV` when it
|
|
39
|
+
* launches the local LangGraph dev server; it is never set for `mda deploy`.
|
|
40
|
+
*/
|
|
41
|
+
export function isDevMode() {
|
|
42
|
+
const value = process.env.MDA_DEV;
|
|
43
|
+
return typeof value === "string" && value.length > 0;
|
|
44
|
+
}
|
|
45
|
+
/** Resolve the lookup key for a sandbox provider (its id, else class name). */
|
|
46
|
+
export function providerKey(provider) {
|
|
47
|
+
const p = provider;
|
|
48
|
+
return (p.providerId ?? p.name ?? "").trim();
|
|
49
|
+
}
|
|
50
|
+
/** Whether every variable in a credential set is set and non-empty. */
|
|
51
|
+
export function credentialSetSatisfied(envVars) {
|
|
52
|
+
return envVars.every((name) => (process.env[name] ?? "").trim().length > 0);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Determine whether the configured provider's credentials are available so
|
|
56
|
+
* `mda dev` can decide between the real provider and the local fallback.
|
|
57
|
+
*/
|
|
58
|
+
export function providerCredentialStatus(provider) {
|
|
59
|
+
const key = providerKey(provider);
|
|
60
|
+
const sets = PROVIDER_CREDENTIAL_ENV_VARS[key];
|
|
61
|
+
if (sets === undefined) {
|
|
62
|
+
return { status: "unknown", provider: key || "unknown", missing: [] };
|
|
63
|
+
}
|
|
64
|
+
if (sets.length === 0 || sets.some(credentialSetSatisfied)) {
|
|
65
|
+
return { status: "available", provider: key, missing: [] };
|
|
66
|
+
}
|
|
67
|
+
return { status: "missing", provider: key, missing: sets[0] ?? [] };
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/runtime/credentials.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA+B;IACtE,+BAA+B;IAC/B,gBAAgB,EAAE,CAAC,CAAC,mBAAmB,CAAC,CAAC;IACzC,+DAA+D;IAC/D,cAAc,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACrC,mDAAmD;IACnD,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;IAC7B,6CAA6C;IAC7C,YAAY,EAAE,CAAC,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACxD,oBAAoB;IACpB,cAAc,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACrC,yEAAyE;IACzE,aAAa,EAAE;QACb,CAAC,mBAAmB,CAAC;QACrB,CAAC,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,CAAC;KACxD;IACD,6DAA6D;IAC7D,gBAAgB,EAAE,CAAC,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IACnF,uEAAuE;IACvE,WAAW,EAAE,CAAC,CAAC,mBAAmB,CAAC,CAAC;IACpC,kDAAkD;IAClD,cAAc,EAAE,EAAE;CACnB,CAAC;AAeF;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,QAAuC;IACjE,MAAM,CAAC,GAAG,QAAkD,CAAC;IAC7D,OAAO,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC/C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,sBAAsB,CAAC,OAAiB;IACtD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAuC;IAEvC,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,4BAA4B,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACxE,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC7D,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function logDevSandboxNoticeOnce(message: string): void;
|
|
2
|
+
/**
|
|
3
|
+
* Reset the one-time notice guard. Test-only: the guard is module-level state
|
|
4
|
+
* that otherwise persists across test cases in the same module instance.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resetDevSandboxNoticeForTests(): void;
|
|
7
|
+
//# sourceMappingURL=dev-notice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-notice.d.ts","sourceRoot":"","sources":["../../src/runtime/dev-notice.ts"],"names":[],"mappings":"AAaA,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAK7D;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emit a one-time notice describing which dev sandbox mode is in effect.
|
|
3
|
+
*
|
|
4
|
+
* Deduped for the lifetime of the process because the managed sandbox is
|
|
5
|
+
* created once per sandbox *scope key* (thread/tenant/actor), not once per
|
|
6
|
+
* process. The `mda dev` LangGraph server is long-lived and serves many
|
|
7
|
+
* threads, so each new thread misses the sandbox cache and provisions a fresh
|
|
8
|
+
* sandbox — without this guard the banner would reprint on the first turn of
|
|
9
|
+
* every new thread (and could interleave when threads start concurrently). The
|
|
10
|
+
* message is session-level context, so once is enough.
|
|
11
|
+
*/
|
|
12
|
+
let loggedDevSandboxNotice = false;
|
|
13
|
+
export function logDevSandboxNoticeOnce(message) {
|
|
14
|
+
if (loggedDevSandboxNotice)
|
|
15
|
+
return;
|
|
16
|
+
loggedDevSandboxNotice = true;
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.log(message);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reset the one-time notice guard. Test-only: the guard is module-level state
|
|
22
|
+
* that otherwise persists across test cases in the same module instance.
|
|
23
|
+
*/
|
|
24
|
+
export function resetDevSandboxNoticeForTests() {
|
|
25
|
+
loggedDevSandboxNotice = false;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=dev-notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-notice.js","sourceRoot":"","sources":["../../src/runtime/dev-notice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,IAAI,sBAAsB,GAAG,KAAK,CAAC;AAEnC,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,IAAI,sBAAsB;QAAE,OAAO;IACnC,sBAAsB,GAAG,IAAI,CAAC;IAC9B,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IAC3C,sBAAsB,GAAG,KAAK,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DeepAgentDefinition } from "../types.js";
|
|
2
|
+
import type { ManagedAgentOptions, ManagedRunConfig } from "./types.js";
|
|
3
|
+
export type { ManagedAgentOptions, ManagedRunConfig } from "./types.js";
|
|
4
|
+
export { announceSandboxPlan } from "./sandbox-manager.js";
|
|
5
|
+
/**
|
|
6
|
+
* Compile a {@link DeepAgentDefinition} into a runnable Deep Agent.
|
|
7
|
+
*
|
|
8
|
+
* This is the seam where MDA injects the platform-owned backend (the configured
|
|
9
|
+
* sandbox), the system prompt embedded from `instructions.md`, and — in a later
|
|
10
|
+
* milestone — the managed store and checkpointer. It is consumed only by the
|
|
11
|
+
* entry module that `mda deploy` generates; agent authors never call it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function compileManagedAgent(definition: DeepAgentDefinition, config?: ManagedRunConfig, options?: ManagedAgentOptions): Promise<unknown>;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAExE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,mBAAmB,EAC/B,MAAM,CAAC,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,mBAAmB,oBAgB9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createDeepAgent } from "deepagents";
|
|
2
|
+
import { resolveManagedSandbox } from "./sandbox-manager.js";
|
|
3
|
+
export { announceSandboxPlan } from "./sandbox-manager.js";
|
|
4
|
+
/**
|
|
5
|
+
* Compile a {@link DeepAgentDefinition} into a runnable Deep Agent.
|
|
6
|
+
*
|
|
7
|
+
* This is the seam where MDA injects the platform-owned backend (the configured
|
|
8
|
+
* sandbox), the system prompt embedded from `instructions.md`, and — in a later
|
|
9
|
+
* milestone — the managed store and checkpointer. It is consumed only by the
|
|
10
|
+
* entry module that `mda deploy` generates; agent authors never call it.
|
|
11
|
+
*/
|
|
12
|
+
export async function compileManagedAgent(definition, config, options) {
|
|
13
|
+
const { systemPrompt, sandbox, setupScript } = options ?? {};
|
|
14
|
+
const params = {
|
|
15
|
+
...definition.config,
|
|
16
|
+
...(systemPrompt !== undefined ? { systemPrompt } : {}),
|
|
17
|
+
};
|
|
18
|
+
// TODO(mda): inject the managed { store, checkpointer } here, scoped by
|
|
19
|
+
// `config.configurable.identity` / `thread_id`.
|
|
20
|
+
if (sandbox) {
|
|
21
|
+
params.backend = await resolveManagedSandbox(sandbox, setupScript, config);
|
|
22
|
+
}
|
|
23
|
+
return createDeepAgent(params);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAI7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAA+B,EAC/B,MAAyB,EACzB,OAA6B;IAE7B,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE7D,MAAM,MAAM,GAA4B;QACtC,GAAG,UAAU,CAAC,MAAM;QACpB,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxD,CAAC;IAEF,wEAAwE;IACxE,gDAAgD;IAChD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,OAAO,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ManagedSandboxBackend } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Provision a local, throwaway sandbox rooted at a fresh OS temp directory.
|
|
4
|
+
*
|
|
5
|
+
* Uses `deepagents`' `LocalShellBackend`, which runs commands and file
|
|
6
|
+
* operations against the host within the temp dir — no remote sandbox, no
|
|
7
|
+
* credentials, no network. Intended only for `mda dev`.
|
|
8
|
+
*
|
|
9
|
+
* `reason` explains *why* the local sandbox is being used (missing credentials,
|
|
10
|
+
* provider creation failure, …) and is logged once alongside the temp dir path.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLocalDevSandbox(reason: string): Promise<ManagedSandboxBackend>;
|
|
13
|
+
//# sourceMappingURL=local-dev-sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-dev-sandbox.d.ts","sourceRoot":"","sources":["../../src/runtime/local-dev-sandbox.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAexD;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA+B1F"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { mkdtemp } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { logDevSandboxNoticeOnce } from "./dev-notice.js";
|
|
5
|
+
/**
|
|
6
|
+
* Provision a local, throwaway sandbox rooted at a fresh OS temp directory.
|
|
7
|
+
*
|
|
8
|
+
* Uses `deepagents`' `LocalShellBackend`, which runs commands and file
|
|
9
|
+
* operations against the host within the temp dir — no remote sandbox, no
|
|
10
|
+
* credentials, no network. Intended only for `mda dev`.
|
|
11
|
+
*
|
|
12
|
+
* `reason` explains *why* the local sandbox is being used (missing credentials,
|
|
13
|
+
* provider creation failure, …) and is logged once alongside the temp dir path.
|
|
14
|
+
*/
|
|
15
|
+
export async function createLocalDevSandbox(reason) {
|
|
16
|
+
const dir = await mkdtemp(join(tmpdir(), "mda-dev-sandbox-"));
|
|
17
|
+
logDevSandboxNoticeOnce(`[mda dev] ${reason}:\n ${dir}`);
|
|
18
|
+
// Loaded dynamically (rather than a static named import) so the build does
|
|
19
|
+
// not depend on `LocalShellBackend` being present in the resolved
|
|
20
|
+
// `deepagents` type surface; it is provided by the runtime's `deepagents`.
|
|
21
|
+
const deepagentsModule = (await import("deepagents"));
|
|
22
|
+
const LocalShellBackend = deepagentsModule.LocalShellBackend;
|
|
23
|
+
if (typeof LocalShellBackend !== "function") {
|
|
24
|
+
throw new Error("the installed `deepagents` does not export `LocalShellBackend`; upgrade " +
|
|
25
|
+
"`deepagents` to use the local `mda dev` sandbox, or set the provider credentials.");
|
|
26
|
+
}
|
|
27
|
+
const backend = new LocalShellBackend({
|
|
28
|
+
rootDir: dir,
|
|
29
|
+
virtualMode: true,
|
|
30
|
+
inheritEnv: true,
|
|
31
|
+
});
|
|
32
|
+
// Initialize eagerly when the backend supports it, mirroring how the provider
|
|
33
|
+
// `create(...)` factory hands back a ready-to-use backend.
|
|
34
|
+
if (typeof backend.initialize === "function") {
|
|
35
|
+
await backend.initialize();
|
|
36
|
+
}
|
|
37
|
+
return backend;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=local-dev-sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-dev-sandbox.js","sourceRoot":"","sources":["../../src/runtime/local-dev-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAgB1D;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAc;IACxD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAC9D,uBAAuB,CAAC,aAAa,MAAM,QAAQ,GAAG,EAAE,CAAC,CAAC;IAE1D,2EAA2E;IAC3E,kEAAkE;IAClE,2EAA2E;IAC3E,MAAM,gBAAgB,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAA4B,CAAC;IACjF,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,iBAE9B,CAAC;IACd,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,0EAA0E;YACxE,mFAAmF,CACtF,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC;QACpC,OAAO,EAAE,GAAG;QACZ,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;IAEH,8EAA8E;IAC9E,2DAA2D;IAC3D,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC7C,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,OAA2C,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SandboxDefinition } from "../sandbox.js";
|
|
2
|
+
import type { ManagedRunConfig, ManagedSandboxBackend } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve (and cache) the scoped sandbox backend for this run, provisioning it
|
|
5
|
+
* with `setup.sh` the first time it is created.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveManagedSandbox(sandbox: SandboxDefinition, setupScript: string | undefined, config: ManagedRunConfig | undefined): Promise<ManagedSandboxBackend>;
|
|
8
|
+
/**
|
|
9
|
+
* Derive the reuse key from the run. Without runtime identity, sandboxes are
|
|
10
|
+
* keyed by thread; with identity, by the configured tenant/actor scope.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sandboxScopeKey(sandbox: SandboxDefinition, config: ManagedRunConfig | undefined): string;
|
|
13
|
+
/** Clear the process-level sandbox cache. Test-only. */
|
|
14
|
+
export declare function clearManagedSandboxCacheForTests(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Eagerly resolve the `mda dev` sandbox at startup so the developer sees the
|
|
17
|
+
* definitive decision — local vs. the configured provider, and the temp dir
|
|
18
|
+
* path when local — right when the dev server boots, not on the first run.
|
|
19
|
+
*
|
|
20
|
+
* Sandboxes are otherwise created lazily (on first run), so with `--browser`
|
|
21
|
+
* off nothing would print until the agent is invoked. The generated entry
|
|
22
|
+
* calls this at module load (graph registration); because dev shares one
|
|
23
|
+
* sandbox ({@link DEV_SANDBOX_SCOPE_KEY}), the first real run reuses what is
|
|
24
|
+
* created here rather than provisioning a second sandbox. The authoritative
|
|
25
|
+
* "created" log (with the temp dir) is emitted by {@link createDevSandbox}.
|
|
26
|
+
*
|
|
27
|
+
* No-op outside `mda dev`, so the generated entry can always call it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function announceSandboxPlan(sandbox: SandboxDefinition, setupScript?: string): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=sandbox-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAoB1E;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iBAAiB,EAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,OAAO,CAAC,qBAAqB,CAAC,CAYhC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,MAAM,CAcR;AAED,wDAAwD;AACxD,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { isDevMode, providerCredentialStatus } from "./credentials.js";
|
|
2
|
+
import { logDevSandboxNoticeOnce } from "./dev-notice.js";
|
|
3
|
+
import { createLocalDevSandbox } from "./local-dev-sandbox.js";
|
|
4
|
+
import { runSetupScript, runSetupScriptInline } from "./setup-script.js";
|
|
5
|
+
/**
|
|
6
|
+
* Created sandboxes, keyed by scope, reused for the lifetime of this runtime
|
|
7
|
+
* process. Storing the in-flight promise dedupes concurrent runs and guarantees
|
|
8
|
+
* `setup.sh` is executed only once per newly created sandbox.
|
|
9
|
+
*/
|
|
10
|
+
const managedSandboxes = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Cache key for the single, process-wide sandbox used under `mda dev`.
|
|
13
|
+
*
|
|
14
|
+
* Deploys key sandboxes per scope (thread/tenant/actor) for isolation. Dev is a
|
|
15
|
+
* single developer iterating locally, so it shares one sandbox across every
|
|
16
|
+
* thread: that lets `announceSandboxPlan` create it eagerly at startup (to
|
|
17
|
+
* report local-vs-remote and the temp dir up front) and have the first real run
|
|
18
|
+
* reuse it instead of provisioning a second one.
|
|
19
|
+
*/
|
|
20
|
+
const DEV_SANDBOX_SCOPE_KEY = "__mda_dev__";
|
|
21
|
+
/**
|
|
22
|
+
* Resolve (and cache) the scoped sandbox backend for this run, provisioning it
|
|
23
|
+
* with `setup.sh` the first time it is created.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveManagedSandbox(sandbox, setupScript, config) {
|
|
26
|
+
const key = isDevMode() ? DEV_SANDBOX_SCOPE_KEY : sandboxScopeKey(sandbox, config);
|
|
27
|
+
let pending = managedSandboxes.get(key);
|
|
28
|
+
if (!pending) {
|
|
29
|
+
pending = createManagedSandbox(sandbox, setupScript).catch((error) => {
|
|
30
|
+
// Don't cache a failed provisioning attempt — let the next run retry.
|
|
31
|
+
managedSandboxes.delete(key);
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
managedSandboxes.set(key, pending);
|
|
35
|
+
}
|
|
36
|
+
return pending;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Derive the reuse key from the run. Without runtime identity, sandboxes are
|
|
40
|
+
* keyed by thread; with identity, by the configured tenant/actor scope.
|
|
41
|
+
*/
|
|
42
|
+
export function sandboxScopeKey(sandbox, config) {
|
|
43
|
+
const configurable = (config?.configurable ?? {});
|
|
44
|
+
const identity = configurable.identity;
|
|
45
|
+
const scope = sandbox.options?.scope ?? "thread";
|
|
46
|
+
let key;
|
|
47
|
+
if (scope === "tenant")
|
|
48
|
+
key = identity?.tenant?.id;
|
|
49
|
+
else if (scope === "actor")
|
|
50
|
+
key = identity?.actor?.id;
|
|
51
|
+
else
|
|
52
|
+
key = configurable.thread_id;
|
|
53
|
+
return key ?? identity?.tenant?.id ?? identity?.actor?.id ?? configurable.thread_id ?? "default";
|
|
54
|
+
}
|
|
55
|
+
/** Clear the process-level sandbox cache. Test-only. */
|
|
56
|
+
export function clearManagedSandboxCacheForTests() {
|
|
57
|
+
managedSandboxes.clear();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Eagerly resolve the `mda dev` sandbox at startup so the developer sees the
|
|
61
|
+
* definitive decision — local vs. the configured provider, and the temp dir
|
|
62
|
+
* path when local — right when the dev server boots, not on the first run.
|
|
63
|
+
*
|
|
64
|
+
* Sandboxes are otherwise created lazily (on first run), so with `--browser`
|
|
65
|
+
* off nothing would print until the agent is invoked. The generated entry
|
|
66
|
+
* calls this at module load (graph registration); because dev shares one
|
|
67
|
+
* sandbox ({@link DEV_SANDBOX_SCOPE_KEY}), the first real run reuses what is
|
|
68
|
+
* created here rather than provisioning a second sandbox. The authoritative
|
|
69
|
+
* "created" log (with the temp dir) is emitted by {@link createDevSandbox}.
|
|
70
|
+
*
|
|
71
|
+
* No-op outside `mda dev`, so the generated entry can always call it.
|
|
72
|
+
*/
|
|
73
|
+
export async function announceSandboxPlan(sandbox, setupScript) {
|
|
74
|
+
if (!isDevMode())
|
|
75
|
+
return;
|
|
76
|
+
await resolveManagedSandbox(sandbox, setupScript, undefined);
|
|
77
|
+
}
|
|
78
|
+
function createManagedSandbox(sandbox, setupScript) {
|
|
79
|
+
// `mda dev` never provisions a real provider sandbox the same way a deploy
|
|
80
|
+
// does (it builds no snapshot/image), so it gets its own resolution path with
|
|
81
|
+
// a local fallback. The flag gating ensures a real deployment can never be
|
|
82
|
+
// silently downgraded to local shell execution.
|
|
83
|
+
return isDevMode()
|
|
84
|
+
? createDevSandbox(sandbox, setupScript)
|
|
85
|
+
: createProviderSandbox(sandbox, setupScript);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Production path: construct the configured provider's sandbox and provision it.
|
|
89
|
+
* Any failure propagates — a misconfigured deployment must surface, not degrade.
|
|
90
|
+
*/
|
|
91
|
+
async function createProviderSandbox(sandbox, setupScript) {
|
|
92
|
+
const backend = await createProviderBackend(sandbox);
|
|
93
|
+
if (setupScript && setupScript.trim().length > 0) {
|
|
94
|
+
await runSetupScript(backend, setupScript);
|
|
95
|
+
}
|
|
96
|
+
return backend;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Dev path: prefer the configured provider when its credentials are present,
|
|
100
|
+
* but fall back to a local temp-directory sandbox when credentials are missing
|
|
101
|
+
* *or* the provider cannot be created (e.g. `LangSmithSandbox`, which needs a
|
|
102
|
+
* snapshot that only `mda deploy` builds). This keeps `mda dev` working offline
|
|
103
|
+
* and resilient to provider/config gaps while still exercising real providers
|
|
104
|
+
* that can spin up from an API key alone.
|
|
105
|
+
*/
|
|
106
|
+
async function createDevSandbox(sandbox, setupScript) {
|
|
107
|
+
const cred = providerCredentialStatus(sandbox.provider);
|
|
108
|
+
if (cred.status !== "missing") {
|
|
109
|
+
try {
|
|
110
|
+
const backend = await createProviderSandbox(sandbox, setupScript);
|
|
111
|
+
logDevSandboxNoticeOnce(cred.status === "available"
|
|
112
|
+
? `[mda dev] using the configured ${cred.provider} sandbox.`
|
|
113
|
+
: `[mda dev] using the configured sandbox provider (${cred.provider}).`);
|
|
114
|
+
return backend;
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return createLocalSandbox(setupScript, `the configured ${cred.provider} sandbox could not be created ` +
|
|
118
|
+
`(${errorMessage(error)}); using a local temporary directory instead`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const missing = cred.missing.join(", ") || "the provider credentials";
|
|
122
|
+
return createLocalSandbox(setupScript, `no credentials found for the configured sandbox provider (${cred.provider}); ` +
|
|
123
|
+
`using a local temporary directory instead — set ${missing} to use it`);
|
|
124
|
+
}
|
|
125
|
+
/** Provision the local dev sandbox and run `setup.sh` inline inside it. */
|
|
126
|
+
async function createLocalSandbox(setupScript, reason) {
|
|
127
|
+
const backend = await createLocalDevSandbox(reason);
|
|
128
|
+
if (setupScript && setupScript.trim().length > 0) {
|
|
129
|
+
await runSetupScriptInline(backend, setupScript);
|
|
130
|
+
}
|
|
131
|
+
return backend;
|
|
132
|
+
}
|
|
133
|
+
/** Construct the configured provider's backend, stripping MDA-managed knobs. */
|
|
134
|
+
async function createProviderBackend(sandbox) {
|
|
135
|
+
const { scope: _scope, idleTtlSeconds: _idleTtlSeconds, ...providerOptions } = sandbox.options ?? {};
|
|
136
|
+
void _scope;
|
|
137
|
+
void _idleTtlSeconds;
|
|
138
|
+
return (await sandbox.provider.create(providerOptions));
|
|
139
|
+
}
|
|
140
|
+
function errorMessage(error) {
|
|
141
|
+
return error instanceof Error ? error.message : String(error);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=sandbox-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-manager.js","sourceRoot":"","sources":["../../src/runtime/sandbox-manager.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ManagedSandboxBackend } from "./types.js";
|
|
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: ManagedSandboxBackend, script: string): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Run `setup.sh` by piping its contents straight to the backend's shell.
|
|
12
|
+
*
|
|
13
|
+
* Used for the local dev sandbox: that backend virtualizes file paths (uploads
|
|
14
|
+
* land under the temp root) but executes shell commands against the real
|
|
15
|
+
* filesystem, so an uploaded `/tmp/mda-setup.sh` would not be found by `bash`.
|
|
16
|
+
* Executed inline, the script runs with the temp root as its working directory.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runSetupScriptInline(backend: ManagedSandboxBackend, script: string): Promise<void>;
|
|
19
|
+
export declare function assertSetupSucceeded(result: {
|
|
20
|
+
output?: string;
|
|
21
|
+
exitCode?: number | null;
|
|
22
|
+
}): void;
|
|
23
|
+
//# sourceMappingURL=setup-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-script.d.ts","sourceRoot":"","sources":["../../src/runtime/setup-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAKxD;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,IAAI,CAOP"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Absolute path the provisioning script is uploaded to inside the sandbox. */
|
|
2
|
+
const SETUP_REMOTE_PATH = "/tmp/mda-setup.sh";
|
|
3
|
+
/**
|
|
4
|
+
* Provision a freshly created sandbox by running `setup.sh` inside it. Reused
|
|
5
|
+
* sandboxes never reach this path, so the script runs once per new sandbox.
|
|
6
|
+
*
|
|
7
|
+
* When the backend supports file transfer, the script is uploaded and executed
|
|
8
|
+
* by path; otherwise it is run inline (see {@link runSetupScriptInline}).
|
|
9
|
+
*/
|
|
10
|
+
export async function runSetupScript(backend, script) {
|
|
11
|
+
if (typeof backend.uploadFiles === "function") {
|
|
12
|
+
await backend.uploadFiles([[SETUP_REMOTE_PATH, new TextEncoder().encode(script)]]);
|
|
13
|
+
assertSetupSucceeded(await backend.execute(`bash ${SETUP_REMOTE_PATH}`));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
await runSetupScriptInline(backend, script);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Run `setup.sh` by piping its contents straight to the backend's shell.
|
|
20
|
+
*
|
|
21
|
+
* Used for the local dev sandbox: that backend virtualizes file paths (uploads
|
|
22
|
+
* land under the temp root) but executes shell commands against the real
|
|
23
|
+
* filesystem, so an uploaded `/tmp/mda-setup.sh` would not be found by `bash`.
|
|
24
|
+
* Executed inline, the script runs with the temp root as its working directory.
|
|
25
|
+
*/
|
|
26
|
+
export async function runSetupScriptInline(backend, script) {
|
|
27
|
+
assertSetupSucceeded(await backend.execute(script));
|
|
28
|
+
}
|
|
29
|
+
export function assertSetupSucceeded(result) {
|
|
30
|
+
if (typeof result.exitCode === "number" && result.exitCode !== 0) {
|
|
31
|
+
const detail = (result.output ?? "").trim();
|
|
32
|
+
throw new Error(`sandbox setup.sh failed with exit code ${result.exitCode}${detail ? `: ${detail}` : ""}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# 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,+EAA+E;AAC/E,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA8B,EAC9B,MAAc;IAEd,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QAC9C,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,iBAAiB,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,oBAAoB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,iBAAiB,EAAE,CAAC,CAAC,CAAC;QACzE,OAAO;IACT,CAAC;IACD,MAAM,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA8B,EAC9B,MAAc;IAEd,oBAAoB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAGpC;IACC,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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SandboxDefinition } from "../sandbox.js";
|
|
2
|
+
/**
|
|
3
|
+
* The LangGraph runnable config passed to a graph factory at invocation time.
|
|
4
|
+
*
|
|
5
|
+
* Kept loose for v0; the managed runtime reads identity and thread metadata
|
|
6
|
+
* from here to scope the store/sandbox.
|
|
7
|
+
*/
|
|
8
|
+
export interface ManagedRunConfig {
|
|
9
|
+
configurable?: Record<string, unknown>;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Managed values the CLI injects into the generated entry module.
|
|
14
|
+
*
|
|
15
|
+
* The system prompt is embedded from `instructions.md` at deploy time, and the
|
|
16
|
+
* sandbox definition + `setup.sh` come from the project's `sandbox/` folder, so
|
|
17
|
+
* they live here rather than in the authored {@link DeepAgentDefinition}.
|
|
18
|
+
*/
|
|
19
|
+
export interface ManagedAgentOptions {
|
|
20
|
+
systemPrompt?: string;
|
|
21
|
+
/** The `sandbox/index.ts` declaration, if the project configures a sandbox. */
|
|
22
|
+
sandbox?: SandboxDefinition;
|
|
23
|
+
/**
|
|
24
|
+
* Contents of `sandbox/setup.sh`, embedded by the CLI. It runs exactly once,
|
|
25
|
+
* the first time a sandbox is provisioned for a given scope.
|
|
26
|
+
*/
|
|
27
|
+
setupScript?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The subset of a created sandbox backend the managed runtime relies on to run
|
|
31
|
+
* `setup.sh`. Mirrors `deepagents`' `SandboxBackendProtocol`.
|
|
32
|
+
*/
|
|
33
|
+
export interface ManagedSandboxBackend {
|
|
34
|
+
readonly id?: string;
|
|
35
|
+
execute(command: string, options?: {
|
|
36
|
+
timeout?: number;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
output?: string;
|
|
39
|
+
exitCode?: number | null;
|
|
40
|
+
}>;
|
|
41
|
+
uploadFiles?(files: Array<[string, Uint8Array]>): Promise<unknown>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAChE,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC1B,CAAC,CAAC;IACH,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The managed `sandbox/` declaration primitive.
|
|
3
|
+
*
|
|
4
|
+
* A Managed Deep Agent declares its execution environment in `sandbox/index.ts`
|
|
5
|
+
* by importing a real provider class (e.g. `LangSmithSandbox` from `deepagents`)
|
|
6
|
+
* and handing it to {@link defineSandbox}. The options are typed straight from
|
|
7
|
+
* the provider's own `create(...)` signature — MDA invents no schema. MDA owns
|
|
8
|
+
* how the sandbox is *resolved*: construction, run-scoped naming, reuse across
|
|
9
|
+
* turns, the provisioning `setup.sh`, and lifecycle/TTL.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // sandbox/index.ts
|
|
14
|
+
* import { defineSandbox } from "managed-deepagents";
|
|
15
|
+
* import { LangSmithSandbox } from "deepagents";
|
|
16
|
+
*
|
|
17
|
+
* export const sandbox = defineSandbox(LangSmithSandbox, {
|
|
18
|
+
* defaultTimeout: 600,
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* A sandbox provider class MDA knows how to instantiate.
|
|
24
|
+
*
|
|
25
|
+
* Providers expose a static async `create(options)` factory. MDA calls it after
|
|
26
|
+
* merging the developer's typed options with managed fields. This matches the
|
|
27
|
+
* shape of `deepagents`' `LangSmithSandbox.create(...)`.
|
|
28
|
+
*/
|
|
29
|
+
export interface SandboxProviderClass<TOptions extends Record<string, any>, TInstance> {
|
|
30
|
+
create(options: TOptions): Promise<TInstance>;
|
|
31
|
+
/** Optional stable provider id for debugging, validation, and traces. */
|
|
32
|
+
readonly providerId?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Reuse boundary for a managed sandbox. Defaults to `"thread"`. */
|
|
35
|
+
export type SandboxScope = "thread" | "tenant" | "actor";
|
|
36
|
+
/**
|
|
37
|
+
* Provider options MDA owns and developers must not set directly.
|
|
38
|
+
*
|
|
39
|
+
* MDA supplies the image/snapshot (built from `sandbox/Dockerfile` or the
|
|
40
|
+
* provider default) and the run-scoped sandbox name when it calls `create(...)`.
|
|
41
|
+
*/
|
|
42
|
+
export type ManagedSandboxOptionKey = "name" | "image" | "snapshot" | "imageName";
|
|
43
|
+
/** Extracts the option type accepted by a provider's static `create(...)`. */
|
|
44
|
+
export type SandboxProviderOptions<TProvider> = TProvider extends {
|
|
45
|
+
create(options: infer TOptions): Promise<unknown>;
|
|
46
|
+
} ? TOptions extends object ? TOptions : never : never;
|
|
47
|
+
/**
|
|
48
|
+
* Developer-provided options for the selected sandbox provider.
|
|
49
|
+
*
|
|
50
|
+
* Inferred from the provider's own `create(...)` options, minus the fields MDA
|
|
51
|
+
* owns, plus the managed reuse/lifecycle knobs.
|
|
52
|
+
*/
|
|
53
|
+
export type DefineSandboxOptions<TProvider extends SandboxProviderClass<any, any>> = Omit<SandboxProviderOptions<TProvider>, ManagedSandboxOptionKey> & {
|
|
54
|
+
/**
|
|
55
|
+
* Sandbox reuse scope. Defaults to `"thread"`.
|
|
56
|
+
*
|
|
57
|
+
* - `"thread"`: one sandbox per durable thread/conversation.
|
|
58
|
+
* - `"tenant"`: one sandbox shared across threads for the current tenant.
|
|
59
|
+
* - `"actor"`: one sandbox shared across threads for the current actor.
|
|
60
|
+
*/
|
|
61
|
+
scope?: SandboxScope;
|
|
62
|
+
/**
|
|
63
|
+
* Idle TTL in seconds. MDA may reclaim the sandbox after this period of
|
|
64
|
+
* inactivity.
|
|
65
|
+
*/
|
|
66
|
+
idleTtlSeconds?: number;
|
|
67
|
+
};
|
|
68
|
+
/** The object exported from `sandbox/index.ts`. */
|
|
69
|
+
export interface SandboxDefinition<TProvider extends SandboxProviderClass<any, any> = SandboxProviderClass<any, any>> {
|
|
70
|
+
readonly kind: "sandbox";
|
|
71
|
+
readonly provider: TProvider;
|
|
72
|
+
readonly options?: DefineSandboxOptions<TProvider>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Declare the managed sandbox provider for a Managed Deep Agent.
|
|
76
|
+
*
|
|
77
|
+
* The developer chooses the provider and its typed options; MDA owns naming,
|
|
78
|
+
* scoping, lifecycle, image/snapshot construction, reuse, the provisioning
|
|
79
|
+
* `setup.sh`, and cleanup. The agent file stays clean — it never sets `backend`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function defineSandbox<TProvider extends SandboxProviderClass<any, any>>(provider: TProvider, options?: DefineSandboxOptions<TProvider>): SandboxDefinition<TProvider>;
|
|
82
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AAEH,MAAM,WAAW,oBAAoB,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS;IACnF,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,oEAAoE;AACpE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC;AAElF,8EAA8E;AAC9E,MAAM,MAAM,sBAAsB,CAAC,SAAS,IAAI,SAAS,SAAS;IAChE,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;AAEH,MAAM,MAAM,oBAAoB,CAAC,SAAS,SAAS,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,CACvF,sBAAsB,CAAC,SAAS,CAAC,EACjC,uBAAuB,CACxB,GAAG;IACF;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,mDAAmD;AAEnD,MAAM,WAAW,iBAAiB,CAAC,SAAS,SAAS,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC;IAClH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;CACpD;AAED;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,SAAS,SAAS,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC5E,QAAQ,EAAE,SAAS,EACnB,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,GACxC,iBAAiB,CAAC,SAAS,CAAC,CAE9B"}
|
package/dist/sandbox.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The managed `sandbox/` declaration primitive.
|
|
3
|
+
*
|
|
4
|
+
* A Managed Deep Agent declares its execution environment in `sandbox/index.ts`
|
|
5
|
+
* by importing a real provider class (e.g. `LangSmithSandbox` from `deepagents`)
|
|
6
|
+
* and handing it to {@link defineSandbox}. The options are typed straight from
|
|
7
|
+
* the provider's own `create(...)` signature — MDA invents no schema. MDA owns
|
|
8
|
+
* how the sandbox is *resolved*: construction, run-scoped naming, reuse across
|
|
9
|
+
* turns, the provisioning `setup.sh`, and lifecycle/TTL.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // sandbox/index.ts
|
|
14
|
+
* import { defineSandbox } from "managed-deepagents";
|
|
15
|
+
* import { LangSmithSandbox } from "deepagents";
|
|
16
|
+
*
|
|
17
|
+
* export const sandbox = defineSandbox(LangSmithSandbox, {
|
|
18
|
+
* defaultTimeout: 600,
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Declare the managed sandbox provider for a Managed Deep Agent.
|
|
24
|
+
*
|
|
25
|
+
* The developer chooses the provider and its typed options; MDA owns naming,
|
|
26
|
+
* scoping, lifecycle, image/snapshot construction, reuse, the provisioning
|
|
27
|
+
* `setup.sh`, and cleanup. The agent file stays clean — it never sets `backend`.
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
export function defineSandbox(provider, options) {
|
|
31
|
+
return { kind: "sandbox", provider, options };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAsEH;;;;;;GAMG;AACH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAC3B,QAAmB,EACnB,OAAyC;IAEzC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAChD,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { CreateDeepAgentParams } from "deepagents";
|
|
2
|
+
/**
|
|
3
|
+
* Properties the managed runtime owns. Agent authors never set these — MDA
|
|
4
|
+
* wires the backend, store, and checkpointer at deploy time, and embeds the
|
|
5
|
+
* system prompt from `instructions.md`.
|
|
6
|
+
*/
|
|
7
|
+
export type ManagedDeepAgentKey = "backend" | "store" | "checkpointer" | "systemPrompt";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration accepted by {@link defineDeepAgent}.
|
|
10
|
+
*
|
|
11
|
+
* This is the full `createDeepAgent` parameter surface minus the managed keys.
|
|
12
|
+
* Setting a managed key is a compile-time error, pointing authors at the
|
|
13
|
+
* managed `sandbox/`, store, checkpointer, and `instructions.md` wiring instead.
|
|
14
|
+
*/
|
|
15
|
+
export type DefineDeepAgentConfig = Omit<CreateDeepAgentParams, ManagedDeepAgentKey> & {
|
|
16
|
+
/** Managed: the runtime owns the backend. Configure it under `sandbox/`. */
|
|
17
|
+
backend?: never;
|
|
18
|
+
/** Managed: the runtime owns the durable store. */
|
|
19
|
+
store?: never;
|
|
20
|
+
/** Managed: the runtime owns the checkpointer. */
|
|
21
|
+
checkpointer?: never;
|
|
22
|
+
/**
|
|
23
|
+
* Managed: the system prompt is embedded from `instructions.md` next to the
|
|
24
|
+
* agent file at deploy time. Write your prompt there instead.
|
|
25
|
+
*/
|
|
26
|
+
systemPrompt?: never;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The pre-runtime spec returned by {@link defineDeepAgent}.
|
|
30
|
+
*
|
|
31
|
+
* It is intentionally *not* a compiled graph: the CLI generates an entry module
|
|
32
|
+
* that hands this definition to the managed runtime, which injects the managed
|
|
33
|
+
* backend/store/checkpointer and compiles it into a Deep Agent.
|
|
34
|
+
*/
|
|
35
|
+
export interface DeepAgentDefinition {
|
|
36
|
+
readonly kind: "deep-agent";
|
|
37
|
+
readonly config: Omit<CreateDeepAgentParams, ManagedDeepAgentKey>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Metadata about the inbound channel event that created or resumed a run.
|
|
41
|
+
*/
|
|
42
|
+
export interface ChannelEvent {
|
|
43
|
+
id?: string;
|
|
44
|
+
type: string;
|
|
45
|
+
timestamp?: string;
|
|
46
|
+
}
|
|
47
|
+
export type ChannelDestination = {
|
|
48
|
+
type: "current_thread";
|
|
49
|
+
} | {
|
|
50
|
+
type: "provider_thread";
|
|
51
|
+
providerChannelId: string;
|
|
52
|
+
providerThreadId: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: "provider_channel";
|
|
55
|
+
providerChannelId: string;
|
|
56
|
+
};
|
|
57
|
+
export interface ChannelAttachment {
|
|
58
|
+
name: string;
|
|
59
|
+
contentType?: string;
|
|
60
|
+
data: Uint8Array | string;
|
|
61
|
+
}
|
|
62
|
+
export interface ChannelMessage {
|
|
63
|
+
text: string;
|
|
64
|
+
blocks?: unknown[];
|
|
65
|
+
attachments?: ChannelAttachment[];
|
|
66
|
+
to?: ChannelDestination;
|
|
67
|
+
providerOptions?: Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
export interface ChannelPostOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Mark this post as the final agent message for the channel, used when
|
|
72
|
+
* `autoReply` is enabled.
|
|
73
|
+
*/
|
|
74
|
+
final?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface PostedChannelMessage {
|
|
77
|
+
id: string;
|
|
78
|
+
providerMessageId?: string;
|
|
79
|
+
url?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The channel that triggered the current run, available on `runtime.channel`.
|
|
83
|
+
*
|
|
84
|
+
* Tools and middleware can post back without knowing any provider specifics —
|
|
85
|
+
* the originating channel and thread ride along on the run.
|
|
86
|
+
*/
|
|
87
|
+
export interface RuntimeChannel {
|
|
88
|
+
name: string;
|
|
89
|
+
provider: "slack" | "discord" | "email" | "webhook" | "http" | "schedule";
|
|
90
|
+
event: ChannelEvent;
|
|
91
|
+
post(message: ChannelMessage, options?: ChannelPostOptions): Promise<PostedChannelMessage>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The managed runtime surface available to tools and middleware.
|
|
95
|
+
*
|
|
96
|
+
* This is intentionally narrow for v0; channels, identity, and connections grow
|
|
97
|
+
* as those parts of the spec land.
|
|
98
|
+
*/
|
|
99
|
+
export interface Runtime {
|
|
100
|
+
channel: RuntimeChannel;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,GAAG,cAAc,CAAC;AAExF;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,GAAG;IACrF,4EAA4E;IAC5E,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,mDAAmD;IACnD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,kDAAkD;IAClD,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;CACnE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;IAC1E,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC5F;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,12 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "managed-deepagents",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "0.0.3-dev.13",
|
|
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
|
+
"keywords": [
|
|
6
|
+
"langchain",
|
|
7
|
+
"langgraph",
|
|
8
|
+
"deepagents",
|
|
9
|
+
"agents",
|
|
10
|
+
"cli"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/langchain-ai/managed-deepagents-sdk",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/langchain-ai/managed-deepagents-sdk.git"
|
|
16
|
+
},
|
|
8
17
|
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./runtime": {
|
|
27
|
+
"types": "./dist/runtime/index.d.ts",
|
|
28
|
+
"default": "./dist/runtime/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"bin": {
|
|
32
|
+
"mda": "bin/mda.mjs"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"bin/mda.mjs"
|
|
37
|
+
],
|
|
9
38
|
"scripts": {
|
|
10
|
-
"
|
|
39
|
+
"build": "tsc -p tsconfig.json",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"deepagents": ">=1.10.4"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"deepagents": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"optionalDependencies": {
|
|
57
|
+
"@langchain/managed-deepagents-darwin-arm64": "0.0.3-dev.13",
|
|
58
|
+
"@langchain/managed-deepagents-darwin-x64": "0.0.3-dev.13",
|
|
59
|
+
"@langchain/managed-deepagents-linux-arm64": "0.0.3-dev.13",
|
|
60
|
+
"@langchain/managed-deepagents-linux-x64": "0.0.3-dev.13",
|
|
61
|
+
"@langchain/managed-deepagents-win32-x64": "0.0.3-dev.13"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
65
|
+
"typescript": "^5.6.0",
|
|
66
|
+
"vitest": "^4.1.9"
|
|
11
67
|
}
|
|
12
|
-
}
|
|
68
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log("Nothing to see yet, come back later!");
|