managed-deepagents 0.0.3-dev.25 → 0.0.3-dev.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/identity.d.ts +273 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +358 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/auth.d.ts +44 -0
- package/dist/runtime/auth.d.ts.map +1 -0
- package/dist/runtime/auth.js +168 -0
- package/dist/runtime/auth.js.map +1 -0
- package/dist/runtime/credentials.d.ts +50 -32
- package/dist/runtime/credentials.d.ts.map +1 -1
- package/dist/runtime/credentials.js +174 -57
- package/dist/runtime/credentials.js.map +1 -1
- package/dist/runtime/identity-http.d.ts +8 -0
- package/dist/runtime/identity-http.d.ts.map +1 -0
- package/dist/runtime/identity-http.js +23 -0
- package/dist/runtime/identity-http.js.map +1 -0
- package/dist/runtime/identity-runtime.d.ts +54 -0
- package/dist/runtime/identity-runtime.d.ts.map +1 -0
- package/dist/runtime/identity-runtime.js +151 -0
- package/dist/runtime/identity-runtime.js.map +1 -0
- package/dist/runtime/index.d.ts +11 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +90 -69
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/managed-middleware.d.ts +25 -0
- package/dist/runtime/managed-middleware.d.ts.map +1 -0
- package/dist/runtime/managed-middleware.js +76 -0
- package/dist/runtime/managed-middleware.js.map +1 -0
- package/dist/runtime/managed-tools.d.ts +61 -0
- package/dist/runtime/managed-tools.d.ts.map +1 -0
- package/dist/runtime/managed-tools.js +102 -0
- package/dist/runtime/managed-tools.js.map +1 -0
- package/dist/runtime/sandbox-manager.d.ts +3 -21
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +41 -125
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/setup-script.d.ts +2 -4
- package/dist/runtime/setup-script.d.ts.map +1 -1
- package/dist/runtime/setup-script.js +2 -4
- package/dist/runtime/setup-script.js.map +1 -1
- package/dist/runtime/types.d.ts +21 -5
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/validated-token.d.ts +25 -0
- package/dist/runtime/validated-token.d.ts.map +1 -0
- package/dist/runtime/validated-token.js +260 -0
- package/dist/runtime/validated-token.js.map +1 -0
- package/dist/sandbox.d.ts +18 -18
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +37 -9
- package/dist/sandbox.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -9
- package/dist/runtime/dev-notice.d.ts +0 -7
- package/dist/runtime/dev-notice.d.ts.map +0 -1
- package/dist/runtime/dev-notice.js +0 -27
- package/dist/runtime/dev-notice.js.map +0 -1
- package/dist/runtime/local-dev-sandbox.d.ts +0 -13
- package/dist/runtime/local-dev-sandbox.d.ts.map +0 -1
- package/dist/runtime/local-dev-sandbox.js +0 -39
- package/dist/runtime/local-dev-sandbox.js.map +0 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { HTTPException } from "@langchain/langgraph-sdk/auth";
|
|
2
|
+
import { createRemoteJWKSet, decodeJwt, jwtVerify, SignJWT, } from "jose";
|
|
3
|
+
/** Issuer stamped on MDA-minted guest tokens, used to route them at selection. */
|
|
4
|
+
const GUEST_ISSUER = "mda:guest";
|
|
5
|
+
/** Deployment env var carrying the HS256 key MDA signs/verifies guest tokens with. */
|
|
6
|
+
const GUEST_KEY_ENV = "MDA_GUEST_SIGNING_KEY";
|
|
7
|
+
/** Remote JWKS key sets, cached per resolved JWKS URI for the process lifetime. */
|
|
8
|
+
const jwksCache = new Map();
|
|
9
|
+
/** OIDC `discover` results (issuer → jwks_uri), cached for the process lifetime. */
|
|
10
|
+
const discoverCache = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the caller identity for the `validated_token` ingress mode (§6.2): pick
|
|
13
|
+
* the provider by token issuer, verify the token (JWKS / introspection / guest),
|
|
14
|
+
* then map its claims into the identity envelope. Fail-closed (401) throughout.
|
|
15
|
+
*/
|
|
16
|
+
export async function resolveValidatedTokenUser(cfg, ingress, request) {
|
|
17
|
+
const token = bearerToken(request);
|
|
18
|
+
const provider = selectProvider(ingress.providers, token);
|
|
19
|
+
const claims = await verifyProviderClaims(provider, token, request.headers);
|
|
20
|
+
const user = claimsToUser(provider, claims);
|
|
21
|
+
if (cfg.tenancy === "multi" && !user.mda_tenant_id) {
|
|
22
|
+
throw new HTTPException(401, {
|
|
23
|
+
message: "missing tenant for multi-tenant deployment",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return user;
|
|
27
|
+
}
|
|
28
|
+
/** Extract the bearer token from the `Authorization` header, or 401. */
|
|
29
|
+
export function bearerToken(request) {
|
|
30
|
+
const header = request.headers.get("authorization") ?? "";
|
|
31
|
+
const match = /^Bearer\s+(.+)$/i.exec(header);
|
|
32
|
+
const token = match?.[1];
|
|
33
|
+
if (!token) {
|
|
34
|
+
throw new HTTPException(401, { message: "missing bearer token" });
|
|
35
|
+
}
|
|
36
|
+
return token.trim();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Select the provider that should verify `token`. A single-provider deployment
|
|
40
|
+
* always uses its one entry; otherwise selection is by the token's `iss` claim
|
|
41
|
+
* (guest tokens carry MDA's own issuer). Fail-closed on no match (401).
|
|
42
|
+
*/
|
|
43
|
+
export function selectProvider(providers, token) {
|
|
44
|
+
const [only] = providers;
|
|
45
|
+
if (only && providers.length === 1) {
|
|
46
|
+
return only;
|
|
47
|
+
}
|
|
48
|
+
let issuer;
|
|
49
|
+
try {
|
|
50
|
+
issuer = decodeJwt(token).iss;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new HTTPException(401, { message: "malformed token" });
|
|
54
|
+
}
|
|
55
|
+
const match = providers.find((p) => p.issuer && p.issuer === issuer);
|
|
56
|
+
if (match) {
|
|
57
|
+
return match;
|
|
58
|
+
}
|
|
59
|
+
if (issuer === GUEST_ISSUER) {
|
|
60
|
+
const guest = providers.find((p) => p.guest);
|
|
61
|
+
if (guest) {
|
|
62
|
+
return guest;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw new HTTPException(401, { message: "no provider matches token issuer" });
|
|
66
|
+
}
|
|
67
|
+
/** Map verified token claims into the managed user envelope, per `provider.claims`. */
|
|
68
|
+
export function claimsToUser(provider, claims) {
|
|
69
|
+
const actor = claims[provider.claims.actor];
|
|
70
|
+
if (actor == null || actor === "") {
|
|
71
|
+
throw new HTTPException(401, {
|
|
72
|
+
message: `token missing actor claim "${provider.claims.actor}"`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const user = {
|
|
76
|
+
identity: String(actor),
|
|
77
|
+
permissions: [],
|
|
78
|
+
mda_actor_id: String(actor),
|
|
79
|
+
mda_claims: { ...claims },
|
|
80
|
+
};
|
|
81
|
+
const tenant = provider.claims.tenant
|
|
82
|
+
? claims[provider.claims.tenant]
|
|
83
|
+
: undefined;
|
|
84
|
+
if (tenant != null && tenant !== "") {
|
|
85
|
+
user.mda_tenant_id = String(tenant);
|
|
86
|
+
}
|
|
87
|
+
const email = provider.claims.email
|
|
88
|
+
? claims[provider.claims.email]
|
|
89
|
+
: undefined;
|
|
90
|
+
if (email) {
|
|
91
|
+
user.mda_actor_email = String(email);
|
|
92
|
+
}
|
|
93
|
+
return user;
|
|
94
|
+
}
|
|
95
|
+
async function verifyProviderClaims(provider, token, headers) {
|
|
96
|
+
if (provider.introspect) {
|
|
97
|
+
return introspectClaims(provider, token, headers);
|
|
98
|
+
}
|
|
99
|
+
if (provider.guest) {
|
|
100
|
+
return verifyGuestToken(token);
|
|
101
|
+
}
|
|
102
|
+
return jwksVerifyClaims(provider, token);
|
|
103
|
+
}
|
|
104
|
+
async function jwksVerifyClaims(provider, token) {
|
|
105
|
+
const keySet = await providerKeySet(provider);
|
|
106
|
+
try {
|
|
107
|
+
const { payload } = await jwtVerify(token, keySet, {
|
|
108
|
+
issuer: provider.issuer,
|
|
109
|
+
audience: provider.audience,
|
|
110
|
+
algorithms: provider.algorithms,
|
|
111
|
+
});
|
|
112
|
+
return payload;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
throw new HTTPException(401, {
|
|
116
|
+
message: "token signature verification failed",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function providerKeySet(provider) {
|
|
121
|
+
const uri = await resolveJwksUri(provider);
|
|
122
|
+
let keySet = jwksCache.get(uri);
|
|
123
|
+
if (!keySet) {
|
|
124
|
+
keySet = createRemoteJWKSet(new URL(uri));
|
|
125
|
+
jwksCache.set(uri, keySet);
|
|
126
|
+
}
|
|
127
|
+
return keySet;
|
|
128
|
+
}
|
|
129
|
+
async function resolveJwksUri(provider) {
|
|
130
|
+
if (provider.jwks) {
|
|
131
|
+
return provider.jwks;
|
|
132
|
+
}
|
|
133
|
+
if (provider.discover && provider.issuer) {
|
|
134
|
+
const cached = discoverCache.get(provider.issuer);
|
|
135
|
+
if (cached) {
|
|
136
|
+
return cached;
|
|
137
|
+
}
|
|
138
|
+
const base = provider.issuer.replace(/\/$/, "");
|
|
139
|
+
const response = await fetch(`${base}/.well-known/openid-configuration`);
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
throw new HTTPException(401, {
|
|
142
|
+
message: "failed to resolve OIDC configuration",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const config = (await response.json());
|
|
146
|
+
if (!config.jwks_uri) {
|
|
147
|
+
throw new HTTPException(401, {
|
|
148
|
+
message: "OIDC configuration has no jwks_uri",
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
discoverCache.set(provider.issuer, config.jwks_uri);
|
|
152
|
+
return config.jwks_uri;
|
|
153
|
+
}
|
|
154
|
+
throw new HTTPException(500, {
|
|
155
|
+
message: "validated_token provider declares neither jwks nor discover",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
async function introspectClaims(provider, token, headers) {
|
|
159
|
+
const introspect = provider.introspect;
|
|
160
|
+
const target = resolveIntrospection(provider, headers);
|
|
161
|
+
const requestHeaders = {};
|
|
162
|
+
// Base headers first, then the selected region's headers so a region can
|
|
163
|
+
// override the shared default (e.g. a per-region Supabase `apikey`).
|
|
164
|
+
for (const [key, value] of Object.entries(introspect.headers ?? {})) {
|
|
165
|
+
requestHeaders[key] = expandEnv(value);
|
|
166
|
+
}
|
|
167
|
+
for (const [key, value] of Object.entries(target.headers ?? {})) {
|
|
168
|
+
requestHeaders[key] = expandEnv(value);
|
|
169
|
+
}
|
|
170
|
+
if ((introspect.tokenIn ?? "authorization") === "authorization") {
|
|
171
|
+
requestHeaders.authorization = `Bearer ${token}`;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
requestHeaders[introspect.header ?? "authorization"] = token;
|
|
175
|
+
}
|
|
176
|
+
// Expand `${ENV}` in the endpoint so region URLs can stay deployment-driven
|
|
177
|
+
// (e.g. `${SUPABASE_EU_URL}/auth/v1/user`) rather than baked in at authoring.
|
|
178
|
+
const response = await fetch(expandEnv(target.url), {
|
|
179
|
+
headers: requestHeaders,
|
|
180
|
+
});
|
|
181
|
+
if (!response.ok) {
|
|
182
|
+
throw new HTTPException(401, { message: "token introspection failed" });
|
|
183
|
+
}
|
|
184
|
+
return (await response.json());
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Resolve the introspection endpoint (and any region-specific headers) for the
|
|
188
|
+
* request. A single-endpoint provider uses `introspect.url`; a multi-region
|
|
189
|
+
* provider selects by the `regionHeader` value, where each region maps either to
|
|
190
|
+
* a bare URL (shared headers) or a `{ url, headers }` object carrying its own
|
|
191
|
+
* credential (e.g. a per-region Supabase `apikey`). Fail-closed (401/500).
|
|
192
|
+
*/
|
|
193
|
+
function resolveIntrospection(provider, headers) {
|
|
194
|
+
const introspect = provider.introspect;
|
|
195
|
+
if (introspect.url) {
|
|
196
|
+
return { url: introspect.url };
|
|
197
|
+
}
|
|
198
|
+
if (introspect.regionHeader && introspect.regions) {
|
|
199
|
+
const region = headers.get(introspect.regionHeader);
|
|
200
|
+
const entry = region ? introspect.regions[region] : undefined;
|
|
201
|
+
if (!entry) {
|
|
202
|
+
throw new HTTPException(401, {
|
|
203
|
+
message: "unknown or missing region for introspection",
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return typeof entry === "string" ? { url: entry } : entry;
|
|
207
|
+
}
|
|
208
|
+
throw new HTTPException(500, {
|
|
209
|
+
message: "introspection provider declares neither url nor regions",
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** Verify an MDA-minted guest token (HS256, signed with the deployment key). */
|
|
213
|
+
async function verifyGuestToken(token) {
|
|
214
|
+
try {
|
|
215
|
+
const { payload } = await jwtVerify(token, guestSigningKey(), {
|
|
216
|
+
issuer: GUEST_ISSUER,
|
|
217
|
+
algorithms: ["HS256"],
|
|
218
|
+
});
|
|
219
|
+
return payload;
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
throw new HTTPException(401, { message: "invalid guest token" });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Mint a short-lived guest token for an anonymous caller. Exposed for the guest
|
|
227
|
+
* issue/reissue route; the same deployment key verifies it on later calls.
|
|
228
|
+
*/
|
|
229
|
+
export async function issueGuestToken(provider, subject) {
|
|
230
|
+
const guest = provider.guest;
|
|
231
|
+
if (!guest?.issue) {
|
|
232
|
+
throw new HTTPException(400, {
|
|
233
|
+
message: "provider does not allow guest issuance",
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const sub = `${guest.actorPrefix ?? ""}${subject ?? crypto.randomUUID()}`;
|
|
237
|
+
return new SignJWT({})
|
|
238
|
+
.setProtectedHeader({ alg: "HS256" })
|
|
239
|
+
.setIssuer(GUEST_ISSUER)
|
|
240
|
+
.setSubject(sub)
|
|
241
|
+
.setIssuedAt()
|
|
242
|
+
.setExpirationTime(guest.ttl ?? "24h")
|
|
243
|
+
.sign(guestSigningKey());
|
|
244
|
+
}
|
|
245
|
+
function guestSigningKey() {
|
|
246
|
+
const key = process.env[GUEST_KEY_ENV];
|
|
247
|
+
if (!key) {
|
|
248
|
+
throw new HTTPException(500, {
|
|
249
|
+
message: `guest tokens require ${GUEST_KEY_ENV}`,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return new TextEncoder().encode(key);
|
|
253
|
+
}
|
|
254
|
+
/** Expand a single `${ENV_VAR}` reference in a header value (e.g. Supabase apikey). */
|
|
255
|
+
function expandEnv(value) {
|
|
256
|
+
return value.replace(/\$\{([A-Z0-9_]+)\}/g, (_match, name) => {
|
|
257
|
+
return process.env[name] ?? "";
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=validated-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validated-token.js","sourceRoot":"","sources":["../../src/runtime/validated-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,SAAS,EAET,SAAS,EACT,OAAO,GACR,MAAM,MAAM,CAAC;AASd,kFAAkF;AAClF,MAAM,YAAY,GAAG,WAAW,CAAC;AACjC,sFAAsF;AACtF,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAI9C,mFAAmF;AACnF,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;AAClD,oFAAoF;AACpF,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,GAAmB,EACnB,OAA8B,EAC9B,OAAgB;IAEhB,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAA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,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACvC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE;YAC3B,OAAO,EAAE,wBAAwB,aAAa,EAAE;SACjD,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,uFAAuF;AACvF,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,MAAM,EAAE,IAAY,EAAE,EAAE;QACnE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* The managed `sandbox/` declaration primitive.
|
|
3
3
|
*
|
|
4
4
|
* A Managed Deep Agent declares its execution environment in `sandbox/index.ts`
|
|
5
|
-
* by importing
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* by importing `LangSmithSandbox` from `deepagents` and handing it to
|
|
6
|
+
* {@link defineSandbox}. The options are typed straight from the provider's own
|
|
7
|
+
* `create(...)` signature — MDA invents no schema. MDA owns how the sandbox is
|
|
8
|
+
* *resolved*: construction, scoped reuse across turns, the provisioning
|
|
9
|
+
* `setup.sh`, and lifecycle/TTL.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
@@ -19,25 +19,26 @@
|
|
|
19
19
|
* });
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
+
import { LangSmithSandbox } from "deepagents";
|
|
22
23
|
/**
|
|
23
24
|
* A sandbox provider class MDA knows how to instantiate.
|
|
24
25
|
*
|
|
25
|
-
* Providers expose a static async `create(options)` factory. MDA
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Providers expose a static async `create(options)` factory. MDA types options
|
|
27
|
+
* from that factory signature (matching `deepagents`' `LangSmithSandbox.create(...)`)
|
|
28
|
+
* and constructs the backend with `new Provider({ sandbox, ... })` at runtime.
|
|
28
29
|
*/
|
|
29
30
|
export interface SandboxProviderClass<TOptions extends Record<string, any>, TInstance> {
|
|
30
31
|
create(options: TOptions): Promise<TInstance>;
|
|
31
|
-
/** Optional stable provider id for
|
|
32
|
+
/** Optional stable provider id for validation and diagnostics. */
|
|
32
33
|
readonly providerId?: string;
|
|
33
34
|
}
|
|
34
35
|
/** Reuse boundary for a managed sandbox. Defaults to `"thread"`. */
|
|
35
|
-
export type SandboxScope = "thread" | "
|
|
36
|
+
export type SandboxScope = "thread" | "agent";
|
|
36
37
|
/**
|
|
37
38
|
* Provider options MDA owns and developers must not set directly.
|
|
38
39
|
*
|
|
39
|
-
* MDA
|
|
40
|
-
*
|
|
40
|
+
* MDA owns sandbox identity and managed runtime safety knobs. Use
|
|
41
|
+
* `templateName` or `snapshotId` when an explicit LangSmith source is needed.
|
|
41
42
|
*/
|
|
42
43
|
export type ManagedSandboxOptionKey = "name" | "image" | "snapshot" | "imageName";
|
|
43
44
|
/** Extracts the option type accepted by a provider's static `create(...)`. */
|
|
@@ -55,8 +56,7 @@ export type DefineSandboxOptions<TProvider extends SandboxProviderClass<any, any
|
|
|
55
56
|
* Sandbox reuse scope. Defaults to `"thread"`.
|
|
56
57
|
*
|
|
57
58
|
* - `"thread"`: one sandbox per durable thread/conversation.
|
|
58
|
-
* - `"
|
|
59
|
-
* - `"actor"`: one sandbox shared across threads for the current actor.
|
|
59
|
+
* - `"agent"`: one sandbox shared by all threads handled by this agent process.
|
|
60
60
|
*/
|
|
61
61
|
scope?: SandboxScope;
|
|
62
62
|
/**
|
|
@@ -74,9 +74,9 @@ export interface SandboxDefinition<TProvider extends SandboxProviderClass<any, a
|
|
|
74
74
|
/**
|
|
75
75
|
* Declare the managed sandbox provider for a Managed Deep Agent.
|
|
76
76
|
*
|
|
77
|
-
* The
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* The provider must be `LangSmithSandbox`; MDA owns naming, scoping, lifecycle,
|
|
78
|
+
* reuse, the provisioning `setup.sh`, and cleanup. The agent file stays clean —
|
|
79
|
+
* it never sets `backend`.
|
|
80
80
|
*/
|
|
81
|
-
export declare function defineSandbox<TProvider extends
|
|
81
|
+
export declare function defineSandbox<TProvider extends typeof LangSmithSandbox = typeof LangSmithSandbox>(provider: TProvider, options?: DefineSandboxOptions<TProvider>): SandboxDefinition<TProvider>;
|
|
82
82
|
//# sourceMappingURL=sandbox.d.ts.map
|
package/dist/sandbox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AAEH,MAAM,WAAW,oBAAoB,CACnC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpC,SAAS;IAET,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9C,
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;GAMG;AAEH,MAAM,WAAW,oBAAoB,CACnC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpC,SAAS;IAET,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9C,kEAAkE;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,oEAAoE;AACpE,MAAM,MAAM,YAAY,GAAG,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
|
3
3
|
*
|
|
4
4
|
* A Managed Deep Agent declares its execution environment in `sandbox/index.ts`
|
|
5
|
-
* by importing
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* by importing `LangSmithSandbox` from `deepagents` and handing it to
|
|
6
|
+
* {@link defineSandbox}. The options are typed straight from the provider's own
|
|
7
|
+
* `create(...)` signature — MDA invents no schema. MDA owns how the sandbox is
|
|
8
|
+
* *resolved*: construction, scoped reuse across turns, the provisioning
|
|
9
|
+
* `setup.sh`, and lifecycle/TTL.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
@@ -19,15 +19,43 @@
|
|
|
19
19
|
* });
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
+
import { LangSmithSandbox } from "deepagents";
|
|
22
23
|
/**
|
|
23
24
|
* Declare the managed sandbox provider for a Managed Deep Agent.
|
|
24
25
|
*
|
|
25
|
-
* The
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* The provider must be `LangSmithSandbox`; MDA owns naming, scoping, lifecycle,
|
|
27
|
+
* reuse, the provisioning `setup.sh`, and cleanup. The agent file stays clean —
|
|
28
|
+
* it never sets `backend`.
|
|
28
29
|
*/
|
|
29
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
31
|
export function defineSandbox(provider, options) {
|
|
31
|
-
|
|
32
|
+
if (providerKey(provider) !== "LangSmithSandbox") {
|
|
33
|
+
throw new TypeError("defineSandbox(...) only supports deepagents' LangSmithSandbox provider");
|
|
34
|
+
}
|
|
35
|
+
const scope = options?.scope ?? "thread";
|
|
36
|
+
if (scope !== "thread" && scope !== "agent") {
|
|
37
|
+
throw new TypeError('sandbox scope must be "thread" or "agent"');
|
|
38
|
+
}
|
|
39
|
+
const managed = managedOptionKeys(options);
|
|
40
|
+
if (managed.length > 0) {
|
|
41
|
+
throw new TypeError(`${managed.join(", ")} ${managed.length === 1 ? "is" : "are"} owned by the managed runtime and cannot be set in defineSandbox(...).`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
kind: "sandbox",
|
|
45
|
+
provider,
|
|
46
|
+
options: { ...options, scope },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function providerKey(provider) {
|
|
50
|
+
const providerId = provider.providerId;
|
|
51
|
+
if (typeof providerId === "string" && providerId.trim()) {
|
|
52
|
+
return providerId.trim();
|
|
53
|
+
}
|
|
54
|
+
return typeof provider.name === "string" ? provider.name.trim() : "";
|
|
55
|
+
}
|
|
56
|
+
function managedOptionKeys(options) {
|
|
57
|
+
if (!options)
|
|
58
|
+
return [];
|
|
59
|
+
return ["name", "image", "snapshot", "imageName"].filter((key) => Object.prototype.hasOwnProperty.call(options, key));
|
|
32
60
|
}
|
|
33
61
|
//# 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;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgF9C;;;;;;GAMG;AACH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAG3B,QAAmB,EACnB,OAAyC;IAEzC,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,kBAAkB,EAAE,CAAC;QACjD,MAAM,IAAI,SAAS,CACjB,wEAAwE,CACzE,CAAC;IACJ,CAAC;IACD,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,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./identity.js";
|
|
2
3
|
/**
|
|
3
4
|
* Properties the managed runtime owns. Agent authors never set these — MDA
|
|
4
5
|
* wires the backend, store, checkpointer, memory, skills, and system prompt at
|
|
@@ -107,5 +108,13 @@ export interface RuntimeChannel {
|
|
|
107
108
|
*/
|
|
108
109
|
export interface Runtime {
|
|
109
110
|
channel: RuntimeChannel;
|
|
111
|
+
/**
|
|
112
|
+
* The frozen identity envelope for the current run, resolved at ingress.
|
|
113
|
+
*
|
|
114
|
+
* Optional because identity is opt-in: a project without an `identity.ts`
|
|
115
|
+
* runs as a service principal with no end-user scoping (§6.5). Present once
|
|
116
|
+
* the deployment declares identity and the runtime seam populates it.
|
|
117
|
+
*/
|
|
118
|
+
identity?: RuntimeIdentity;
|
|
110
119
|
}
|
|
111
120
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,OAAO,GACP,cAAc,GACd,cAAc,GACd,QAAQ,GACR,QAAQ,CAAC;AAEb;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,qBAAqB,EACrB,mBAAmB,CACpB,GAAG;IACF,4EAA4E;IAC5E,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,mDAAmD;IACnD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,kDAAkD;IAClD,YAAY,CAAC,EAAE,KAAK,CAAC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;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,CACF,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "managed-deepagents",
|
|
3
|
-
"version": "0.0.3-dev.
|
|
3
|
+
"version": "0.0.3-dev.29",
|
|
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",
|
|
@@ -43,23 +43,26 @@
|
|
|
43
43
|
"lint": "oxlint --config ../../.oxlintrc.jsonc src",
|
|
44
44
|
"lint:fix": "oxlint --config ../../.oxlintrc.jsonc src --fix",
|
|
45
45
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
46
|
-
"test": "vitest run",
|
|
46
|
+
"test": "vitest run --typecheck",
|
|
47
47
|
"test:watch": "vitest"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=22"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@langchain/langgraph-sdk": "^1.9.25",
|
|
53
54
|
"@langchain/mcp-adapters": "^1.1.3",
|
|
54
|
-
"deepagents": "^1.10.4"
|
|
55
|
+
"deepagents": "^1.10.4",
|
|
56
|
+
"hono": "^4.12.28",
|
|
57
|
+
"jose": "^6.2.3"
|
|
55
58
|
},
|
|
56
59
|
"optionalDependencies": {
|
|
57
|
-
"@langchain/managed-deepagents-darwin-arm64": "0.0.3-dev.
|
|
58
|
-
"@langchain/managed-deepagents-darwin-x64": "0.0.3-dev.
|
|
59
|
-
"@langchain/managed-deepagents-linux-arm64": "0.0.3-dev.
|
|
60
|
-
"@langchain/managed-deepagents-linux-x64": "0.0.3-dev.
|
|
61
|
-
"@langchain/managed-deepagents-win32-arm64": "0.0.3-dev.
|
|
62
|
-
"@langchain/managed-deepagents-win32-x64": "0.0.3-dev.
|
|
60
|
+
"@langchain/managed-deepagents-darwin-arm64": "0.0.3-dev.29",
|
|
61
|
+
"@langchain/managed-deepagents-darwin-x64": "0.0.3-dev.29",
|
|
62
|
+
"@langchain/managed-deepagents-linux-arm64": "0.0.3-dev.29",
|
|
63
|
+
"@langchain/managed-deepagents-linux-x64": "0.0.3-dev.29",
|
|
64
|
+
"@langchain/managed-deepagents-win32-arm64": "0.0.3-dev.29",
|
|
65
|
+
"@langchain/managed-deepagents-win32-x64": "0.0.3-dev.29"
|
|
63
66
|
},
|
|
64
67
|
"devDependencies": {
|
|
65
68
|
"@types/node": "^26.0.1",
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CACzC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,qBAAqB,CAAC,CAkChC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CACzC,MAAc;IAEd,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,CAGnD,CAAC;IACF,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"}
|