managed-deepagents 0.10.2-dev.9 → 0.10.2
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 +12 -2
- package/dist/cached-agent.d.ts +68 -0
- package/dist/cached-agent.d.ts.map +1 -0
- package/dist/cached-agent.js +74 -0
- package/dist/cached-agent.js.map +1 -0
- package/dist/channels/trigger/http.d.ts.map +1 -1
- package/dist/channels/trigger/http.js +5 -0
- package/dist/channels/trigger/http.js.map +1 -1
- package/dist/channels/trigger/ingress.d.ts +1 -0
- package/dist/channels/trigger/ingress.d.ts.map +1 -1
- package/dist/channels/trigger/ingress.js +2 -2
- package/dist/channels/trigger/ingress.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/ingress/runs.d.ts +8 -4
- package/dist/ingress/runs.d.ts.map +1 -1
- package/dist/ingress/runs.js +24 -3
- package/dist/ingress/runs.js.map +1 -1
- package/dist/memory/instructions-middleware.d.ts.map +1 -1
- package/dist/memory/instructions-middleware.js +24 -3
- package/dist/memory/instructions-middleware.js.map +1 -1
- package/dist/runtime/async-subagents.d.ts +0 -2
- package/dist/runtime/async-subagents.d.ts.map +1 -1
- package/dist/runtime/async-subagents.js +0 -8
- package/dist/runtime/async-subagents.js.map +1 -1
- package/dist/runtime/auth.d.ts +1 -1
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +52 -10
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/backend.d.ts +5 -2
- package/dist/runtime/backend.d.ts.map +1 -1
- package/dist/runtime/backend.js +24 -8
- package/dist/runtime/backend.js.map +1 -1
- package/dist/runtime/cached-graphs.d.ts +69 -0
- package/dist/runtime/cached-graphs.d.ts.map +1 -0
- package/dist/runtime/cached-graphs.js +192 -0
- package/dist/runtime/cached-graphs.js.map +1 -0
- package/dist/runtime/graph-build-timing.d.ts +5 -0
- package/dist/runtime/graph-build-timing.d.ts.map +1 -1
- package/dist/runtime/graph-build-timing.js +13 -4
- package/dist/runtime/graph-build-timing.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +174 -49
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/managed-tools.d.ts +19 -3
- package/dist/runtime/managed-tools.d.ts.map +1 -1
- package/dist/runtime/managed-tools.js.map +1 -1
- package/dist/runtime/memory/user-memory.d.ts +3 -2
- package/dist/runtime/memory/user-memory.d.ts.map +1 -1
- package/dist/runtime/memory/user-memory.js +22 -5
- package/dist/runtime/memory/user-memory.js.map +1 -1
- package/dist/runtime/run-input.d.ts +1 -1
- package/dist/runtime/run-input.d.ts.map +1 -1
- package/dist/runtime/run-input.js +17 -4
- package/dist/runtime/run-input.js.map +1 -1
- package/dist/runtime/run-local.d.ts +34 -0
- package/dist/runtime/run-local.d.ts.map +1 -0
- package/dist/runtime/run-local.js +79 -0
- package/dist/runtime/run-local.js.map +1 -0
- package/dist/runtime/run-scoped-backend.d.ts +33 -0
- package/dist/runtime/run-scoped-backend.d.ts.map +1 -0
- package/dist/runtime/run-scoped-backend.js +65 -0
- package/dist/runtime/run-scoped-backend.js.map +1 -0
- package/dist/runtime/sandbox-manager.d.ts +8 -0
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +91 -22
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/schedule-auth.d.ts +2 -0
- package/dist/runtime/schedule-auth.d.ts.map +1 -1
- package/dist/runtime/schedule-auth.js +43 -5
- package/dist/runtime/schedule-auth.js.map +1 -1
- package/dist/runtime/steering.d.ts +22 -0
- package/dist/runtime/steering.d.ts.map +1 -0
- package/dist/runtime/steering.js +208 -0
- package/dist/runtime/steering.js.map +1 -0
- package/dist/sandbox.d.ts +0 -7
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +0 -17
- package/dist/sandbox.js.map +1 -1
- package/dist/schedules.d.ts +3 -2
- package/dist/schedules.d.ts.map +1 -1
- package/dist/schedules.js +2 -2
- package/dist/schedules.js.map +1 -1
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/run-listener.d.ts.map +1 -1
- package/dist/telemetry/run-listener.js +5 -1
- package/dist/telemetry/run-listener.js.map +1 -1
- package/dist/telemetry/transport/fanout.d.ts +14 -0
- package/dist/telemetry/transport/fanout.d.ts.map +1 -0
- package/dist/telemetry/transport/fanout.js +19 -0
- package/dist/telemetry/transport/fanout.js.map +1 -0
- package/dist/telemetry/transport/segment.d.ts +35 -0
- package/dist/telemetry/transport/segment.d.ts.map +1 -0
- package/dist/telemetry/transport/segment.js +137 -0
- package/dist/telemetry/transport/segment.js.map +1 -0
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-memory.js","sourceRoot":"","sources":["../../../src/runtime/memory/user-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"user-memory.js","sourceRoot":"","sources":["../../../src/runtime/memory/user-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,K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AAC,OAAO,CAAC,SAAS,CAAC,CACnD,CAAC;QACF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC;QACnC,4EAA4E;QAC5E,+EAA+E;QAC/E,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;QACxC,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IACxE,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,MAAc;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS;YACpC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC9B,CAAC,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAClC,yEAAyE;QACzE,wEAAwE;QACxE,iDAAiD;QACjD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,MAAc;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QACnE,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -56,6 +56,6 @@ export declare function resolveRunId(config?: {
|
|
|
56
56
|
metadata?: Record<string, unknown>;
|
|
57
57
|
configurable?: Record<string, unknown>;
|
|
58
58
|
}): string | undefined;
|
|
59
|
-
export declare function adaptChannelExecution(agent: Agent, leadThread?: LeadThread): Agent;
|
|
59
|
+
export declare function adaptChannelExecution(agent: Agent, leadThread?: LeadThread, approvedUser?: string): Agent;
|
|
60
60
|
export {};
|
|
61
61
|
//# sourceMappingURL=run-input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-input.d.ts","sourceRoot":"","sources":["../../src/runtime/run-input.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAazB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"run-input.d.ts","sourceRoot":"","sources":["../../src/runtime/run-input.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAazB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,wBAAgB,cAAc,CAC5B,MAAM,CAAC,EAAE,gBAAgB,GACxB,MAAM,IAAI,gBAAgB,CAE5B;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAYrE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAOvE;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB;;aAMxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDpE;AAED,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AA+HhD,+BAA+B;AAC/B,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC,GAAG,MAAM,GAAG,SAAS,CASrB;AA8CD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,KAAK,EACZ,UAAU,CAAC,EAAE,UAAU,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,KAAK,CAcP"}
|
|
@@ -7,6 +7,8 @@ import { resolveRunThread } from "./managed-thread.js";
|
|
|
7
7
|
import { launchingParent, leadThreadId, threadSource, } from "./parent-run.js";
|
|
8
8
|
import { deliverRunFailure, deliverRunResult, } from "../channels/delivery.js";
|
|
9
9
|
import { createLogContext, currentLogContext, runInLogContext, traceIdFromMetadata, } from "../telemetry/otel/index.js";
|
|
10
|
+
import { withLeadSandbox } from "./sandbox-manager.js";
|
|
11
|
+
import { withApprovedUser } from "./memory/user-memory.js";
|
|
10
12
|
export function isRunExecution(config) {
|
|
11
13
|
return !!config && Object.hasOwn(config, "context");
|
|
12
14
|
}
|
|
@@ -77,9 +79,12 @@ export function executionContext(config) {
|
|
|
77
79
|
}
|
|
78
80
|
/** Graph property holding the lead thread a verified async subagent run shares. */
|
|
79
81
|
const LEAD_THREAD = Symbol("mda.leadThread");
|
|
82
|
+
/** Graph property holding the user this call may reach user memory as. */
|
|
83
|
+
const APPROVED_USER = Symbol("mda.approvedUser");
|
|
80
84
|
/** Keep the adapter on native graph copies without binding an old instance. */
|
|
81
85
|
class ManagedCompiledGraph extends CompiledStateGraph {
|
|
82
86
|
[LEAD_THREAD];
|
|
87
|
+
[APPROVED_USER];
|
|
83
88
|
async *_streamIterator(input, options) {
|
|
84
89
|
const ambient = getConfig();
|
|
85
90
|
const config = {
|
|
@@ -120,9 +125,16 @@ class ManagedCompiledGraph extends CompiledStateGraph {
|
|
|
120
125
|
setRunLogAttributes(log, config);
|
|
121
126
|
}
|
|
122
127
|
// Each step runs bound to its channel, in the run's log context, and nested
|
|
123
|
-
// under the async subagent call that launched it, if any.
|
|
128
|
+
// under the async subagent call that launched it, if any. An async subagent
|
|
129
|
+
// run whose lead thread was verified also uses its lead's sandbox: the lead
|
|
130
|
+
// thread is set here, per call, because a cached graph's sandbox backend is
|
|
131
|
+
// compiled without one (see cached-graphs.ts). Likewise the user this run
|
|
132
|
+
// may reach user memory as; a nested managed graph has none of its own and
|
|
133
|
+
// keeps its parent's.
|
|
134
|
+
const leadThread = this[LEAD_THREAD]?.id;
|
|
135
|
+
const approvedUser = this[APPROVED_USER];
|
|
124
136
|
const within = (fn) => {
|
|
125
|
-
const step = () => currentChannelBinding.run(scope, () => runInLogContext(log, fn));
|
|
137
|
+
const step = () => currentChannelBinding.run(scope, () => withLeadSandbox(leadThread, () => withApprovedUser(approvedUser, () => runInLogContext(log, fn))));
|
|
126
138
|
return parent ? withRunTree(parent, step) : step();
|
|
127
139
|
};
|
|
128
140
|
const topLevel = isTopLevelRun(config, this);
|
|
@@ -223,14 +235,15 @@ function setRunLogAttributes(log, config) {
|
|
|
223
235
|
log.attributes[key] = value;
|
|
224
236
|
}
|
|
225
237
|
}
|
|
226
|
-
export function adaptChannelExecution(agent, leadThread) {
|
|
238
|
+
export function adaptChannelExecution(agent, leadThread, approvedUser) {
|
|
227
239
|
if (!(agent.graph instanceof CompiledStateGraph))
|
|
228
240
|
return agent;
|
|
229
241
|
Object.setPrototypeOf(agent.graph, ManagedCompiledGraph.prototype);
|
|
230
242
|
agent.graph[LEAD_THREAD] = leadThread;
|
|
243
|
+
agent.graph[APPROVED_USER] = approvedUser;
|
|
231
244
|
const configure = agent.withConfig;
|
|
232
245
|
agent.withConfig = function (config) {
|
|
233
|
-
return adaptChannelExecution(configure.call(this, config), leadThread);
|
|
246
|
+
return adaptChannelExecution(configure.call(this, config), leadThread, approvedUser);
|
|
234
247
|
};
|
|
235
248
|
return agent;
|
|
236
249
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-input.js","sourceRoot":"","sources":["../../src/runtime/run-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,YAAY,GAEb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"run-input.js","sourceRoot":"","sources":["../../src/runtime/run-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,E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,CAAC,MAAM,CAAC,YAAY,EAAE,aAAa,IAAI,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;AACrE,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAe,EAAE,MAAwB;IACpE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI;QACzB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;QACnC,CAAC,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC;KACrC,EAAE,CAAC;QACX,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK;YAAE,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAAY,EACZ,UAAuB,EACvB,YAAqB;IAErB,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,YAAY,kBAAkB,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/D,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAClE,KAAK,CAAC,KAA8B,CAAC,WAAW,CAAC,GAAG,UAAU,CAAC;IAC/D,KAAK,CAAC,KAA8B,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;IACpE,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC;IACnC,KAAK,CAAC,UAAU,GAAG,UAAU,MAAuC;QAClE,OAAO,qBAAqB,CAC1B,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAC5B,UAAU,EACV,YAAY,CACb,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many runs' values one RunLocal keeps. Past this, the oldest run's value is
|
|
3
|
+
* dropped; if that run is still going, its next `get()` makes a fresh value.
|
|
4
|
+
*/
|
|
5
|
+
export declare const RUNS_KEPT = 256;
|
|
6
|
+
/**
|
|
7
|
+
* Return the Agent Server run_id of the run in progress.
|
|
8
|
+
*
|
|
9
|
+
* Returns undefined when there is no run_id: when called outside a LangGraph run
|
|
10
|
+
* (for example in unit tests), or when the caller did not set `metadata.run_id`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function currentRunId(): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* One value per run, created on the run's first `get()`.
|
|
15
|
+
*
|
|
16
|
+
* Calls made outside a run (no run_id) all share one value, which is how the
|
|
17
|
+
* state behaved before graphs were cached.
|
|
18
|
+
*
|
|
19
|
+
* `first`, when given, is used as the first run's value instead of calling
|
|
20
|
+
* `make`. An uncached graph serves exactly one run, so passing the object built
|
|
21
|
+
* at compile time as `first` means that run reuses it, as it did before.
|
|
22
|
+
*/
|
|
23
|
+
export declare class RunLocal<T> {
|
|
24
|
+
private readonly make;
|
|
25
|
+
private readonly values;
|
|
26
|
+
private first;
|
|
27
|
+
constructor(make: () => T, options?: {
|
|
28
|
+
first?: T;
|
|
29
|
+
});
|
|
30
|
+
get(): T;
|
|
31
|
+
/** Forget the current run's value, so its next `get()` makes a new one. */
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=run-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-local.d.ts","sourceRoot":"","sources":["../../src/runtime/run-local.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAQjD;AAID;;;;;;;;;GASG;AACH,qBAAa,QAAQ,CAAC,CAAC;IAKnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,KAAK,CAAmB;IAEhC,YACmB,IAAI,EAAE,MAAM,CAAC,EAC9B,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,CAAA;KAAO,EAG5B;IAED,GAAG,IAAI,CAAC,CAqBP;IAED,2EAA2E;IAC3E,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values that belong to the run in progress, not to the graph that holds them.
|
|
3
|
+
*
|
|
4
|
+
* A cached graph (see `cachedAgent`) is compiled once and serves many runs, so
|
|
5
|
+
* any object it holds is shared by all of them. State that belongs to one run,
|
|
6
|
+
* such as a Context Hub snapshot or which proxy config a run already applied, goes
|
|
7
|
+
* in a `RunLocal` instead: the graph holds the `RunLocal`, and each run gets its
|
|
8
|
+
* own value from it.
|
|
9
|
+
*/
|
|
10
|
+
import { getConfig } from "@langchain/langgraph";
|
|
11
|
+
/**
|
|
12
|
+
* How many runs' values one RunLocal keeps. Past this, the oldest run's value is
|
|
13
|
+
* dropped; if that run is still going, its next `get()` makes a fresh value.
|
|
14
|
+
*/
|
|
15
|
+
export const RUNS_KEPT = 256;
|
|
16
|
+
/**
|
|
17
|
+
* Return the Agent Server run_id of the run in progress.
|
|
18
|
+
*
|
|
19
|
+
* Returns undefined when there is no run_id: when called outside a LangGraph run
|
|
20
|
+
* (for example in unit tests), or when the caller did not set `metadata.run_id`.
|
|
21
|
+
*/
|
|
22
|
+
export function currentRunId() {
|
|
23
|
+
let runId;
|
|
24
|
+
try {
|
|
25
|
+
runId = getConfig()?.metadata?.run_id;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return typeof runId === "string" && runId ? runId : undefined;
|
|
31
|
+
}
|
|
32
|
+
const UNSET = Symbol("unset");
|
|
33
|
+
/**
|
|
34
|
+
* One value per run, created on the run's first `get()`.
|
|
35
|
+
*
|
|
36
|
+
* Calls made outside a run (no run_id) all share one value, which is how the
|
|
37
|
+
* state behaved before graphs were cached.
|
|
38
|
+
*
|
|
39
|
+
* `first`, when given, is used as the first run's value instead of calling
|
|
40
|
+
* `make`. An uncached graph serves exactly one run, so passing the object built
|
|
41
|
+
* at compile time as `first` means that run reuses it, as it did before.
|
|
42
|
+
*/
|
|
43
|
+
export class RunLocal {
|
|
44
|
+
make;
|
|
45
|
+
values = new Map();
|
|
46
|
+
first;
|
|
47
|
+
constructor(make, options = {}) {
|
|
48
|
+
this.make = make;
|
|
49
|
+
this.first = "first" in options ? options.first : UNSET;
|
|
50
|
+
}
|
|
51
|
+
get() {
|
|
52
|
+
const runId = currentRunId();
|
|
53
|
+
if (this.values.has(runId)) {
|
|
54
|
+
const value = this.values.get(runId);
|
|
55
|
+
// Move to the end, so the oldest entry is the least recently used.
|
|
56
|
+
this.values.delete(runId);
|
|
57
|
+
this.values.set(runId, value);
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
let value;
|
|
61
|
+
if (this.first !== UNSET) {
|
|
62
|
+
value = this.first;
|
|
63
|
+
this.first = UNSET;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
value = this.make();
|
|
67
|
+
}
|
|
68
|
+
this.values.set(runId, value);
|
|
69
|
+
while (this.values.size > RUNS_KEPT) {
|
|
70
|
+
this.values.delete(this.values.keys().next().value);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
/** Forget the current run's value, so its next `get()` makes a new one. */
|
|
75
|
+
clear() {
|
|
76
|
+
this.values.delete(currentRunId());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=run-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-local.js","sourceRoot":"","sources":["../../src/runtime/run-local.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAE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rB,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2EAA2E;IAC3E,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BackendProtocolV2 } from "deepagents";
|
|
2
|
+
type Args<K extends keyof BackendProtocolV2> = Parameters<NonNullable<BackendProtocolV2[K]>>;
|
|
3
|
+
/**
|
|
4
|
+
* A Context Hub backend that each run opens for itself.
|
|
5
|
+
*
|
|
6
|
+
* `ContextHubBackend` loads the repo tree once and keeps it, reloading only after
|
|
7
|
+
* a write conflict. A cached graph serves many runs, so a backend held by the
|
|
8
|
+
* graph would keep serving the first run's snapshot: memory written since, by
|
|
9
|
+
* another replica or another graph, would never show up. This forwards every
|
|
10
|
+
* call to the current run's own backend instead.
|
|
11
|
+
*
|
|
12
|
+
* `compiled` is the backend opened at compile time. Calls outside a run (the
|
|
13
|
+
* compile itself) use it, and the first run adopts it, so an uncached graph,
|
|
14
|
+
* which serves one run, opens one backend as before.
|
|
15
|
+
*/
|
|
16
|
+
export declare class RunScopedBackend implements BackendProtocolV2 {
|
|
17
|
+
private readonly compiled;
|
|
18
|
+
private readonly runs;
|
|
19
|
+
constructor(compiled: BackendProtocolV2, open: () => BackendProtocolV2);
|
|
20
|
+
private backend;
|
|
21
|
+
ls(...args: Args<"ls">): import("deepagents").MaybePromise<import("deepagents").LsResult>;
|
|
22
|
+
read(...args: Args<"read">): import("deepagents").MaybePromise<import("deepagents").ReadResult>;
|
|
23
|
+
readRaw(...args: Args<"readRaw">): import("deepagents").MaybePromise<import("deepagents").ReadRawResult>;
|
|
24
|
+
write(...args: Args<"write">): import("deepagents").MaybePromise<import("deepagents").WriteResult>;
|
|
25
|
+
edit(...args: Args<"edit">): import("deepagents").MaybePromise<import("deepagents").EditResult>;
|
|
26
|
+
grep(...args: Args<"grep">): import("deepagents").MaybePromise<import("deepagents").GrepResult>;
|
|
27
|
+
glob(...args: Args<"glob">): import("deepagents").MaybePromise<import("deepagents").GlobResult>;
|
|
28
|
+
delete(...args: Args<"delete">): import("deepagents").MaybePromise<import("deepagents").DeleteResult>;
|
|
29
|
+
uploadFiles(...args: Args<"uploadFiles">): import("deepagents").MaybePromise<import("deepagents").FileUploadResponse[]>;
|
|
30
|
+
downloadFiles(...args: Args<"downloadFiles">): import("deepagents").MaybePromise<import("deepagents").FileDownloadResponse[]>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=run-scoped-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-scoped-backend.d.ts","sourceRoot":"","sources":["../../src/runtime/run-scoped-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD,KAAK,IAAI,CAAC,CAAC,SAAS,MAAM,iBAAiB,IAAI,UAAU,CACvD,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAClC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;IAItD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAH3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8B;IAEnD,YACmB,QAAQ,EAAE,iBAAiB,EAC5C,IAAI,EAAE,MAAM,iBAAiB,EAG9B;IAED,OAAO,CAAC,OAAO;IAIf,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,oEAErB;IAED,IAAI,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,sEAEzB;IAED,OAAO,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,yEAE/B;IAED,KAAK,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,uEAE3B;IAED,IAAI,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,sEAEzB;IAED,IAAI,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,sEAEzB;IAED,IAAI,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,sEAEzB;IAED,MAAM,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,wEAI7B;IAED,WAAW,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,gFAKvC;IAED,aAAa,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,kFAK3C;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RunLocal, currentRunId } from "./run-local.js";
|
|
2
|
+
/**
|
|
3
|
+
* A Context Hub backend that each run opens for itself.
|
|
4
|
+
*
|
|
5
|
+
* `ContextHubBackend` loads the repo tree once and keeps it, reloading only after
|
|
6
|
+
* a write conflict. A cached graph serves many runs, so a backend held by the
|
|
7
|
+
* graph would keep serving the first run's snapshot: memory written since, by
|
|
8
|
+
* another replica or another graph, would never show up. This forwards every
|
|
9
|
+
* call to the current run's own backend instead.
|
|
10
|
+
*
|
|
11
|
+
* `compiled` is the backend opened at compile time. Calls outside a run (the
|
|
12
|
+
* compile itself) use it, and the first run adopts it, so an uncached graph,
|
|
13
|
+
* which serves one run, opens one backend as before.
|
|
14
|
+
*/
|
|
15
|
+
export class RunScopedBackend {
|
|
16
|
+
compiled;
|
|
17
|
+
runs;
|
|
18
|
+
constructor(compiled, open) {
|
|
19
|
+
this.compiled = compiled;
|
|
20
|
+
this.runs = new RunLocal(open, { first: compiled });
|
|
21
|
+
}
|
|
22
|
+
backend() {
|
|
23
|
+
return currentRunId() === undefined ? this.compiled : this.runs.get();
|
|
24
|
+
}
|
|
25
|
+
ls(...args) {
|
|
26
|
+
return this.backend().ls(...args);
|
|
27
|
+
}
|
|
28
|
+
read(...args) {
|
|
29
|
+
return this.backend().read(...args);
|
|
30
|
+
}
|
|
31
|
+
readRaw(...args) {
|
|
32
|
+
return this.backend().readRaw(...args);
|
|
33
|
+
}
|
|
34
|
+
write(...args) {
|
|
35
|
+
return this.backend().write(...args);
|
|
36
|
+
}
|
|
37
|
+
edit(...args) {
|
|
38
|
+
return this.backend().edit(...args);
|
|
39
|
+
}
|
|
40
|
+
grep(...args) {
|
|
41
|
+
return this.backend().grep(...args);
|
|
42
|
+
}
|
|
43
|
+
glob(...args) {
|
|
44
|
+
return this.backend().glob(...args);
|
|
45
|
+
}
|
|
46
|
+
delete(...args) {
|
|
47
|
+
const backend = this.backend();
|
|
48
|
+
if (!backend.delete)
|
|
49
|
+
throw new Error("backend does not support delete");
|
|
50
|
+
return backend.delete(...args);
|
|
51
|
+
}
|
|
52
|
+
uploadFiles(...args) {
|
|
53
|
+
const backend = this.backend();
|
|
54
|
+
if (!backend.uploadFiles)
|
|
55
|
+
throw new Error("backend does not support uploadFiles");
|
|
56
|
+
return backend.uploadFiles(...args);
|
|
57
|
+
}
|
|
58
|
+
downloadFiles(...args) {
|
|
59
|
+
const backend = this.backend();
|
|
60
|
+
if (!backend.downloadFiles)
|
|
61
|
+
throw new Error("backend does not support downloadFiles");
|
|
62
|
+
return backend.downloadFiles(...args);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=run-scoped-backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-scoped-backend.js","sourceRoot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ACtC,CAAC;IAED,IAAI,CAAC,GAAG,IAAkB;QACxB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,GAAG,IAAoB;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACxE,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,WAAW,CAAC,GAAG,IAAyB;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,WAAW;YACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,aAAa,CAAC,GAAG,IAA2B;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,aAAa;YACxB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,OAAO,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -17,6 +17,8 @@ export declare const SANDBOX_API_ENDPOINT_ENV = "MDA_SANDBOX_API_ENDPOINT";
|
|
|
17
17
|
* resolves `snapshotName` in the wrong workspace and 404s on the recipe.
|
|
18
18
|
*/
|
|
19
19
|
export declare const WORKSPACE_ID_ENV = "LANGSMITH_WORKSPACE_ID";
|
|
20
|
+
/** The lead thread whose sandbox the current call shares, if any. */
|
|
21
|
+
export declare function currentLeadThread(): string | undefined;
|
|
20
22
|
/** Run `fn` with sandbox scope keys resolving to `leadThread`'s sandbox, if set. */
|
|
21
23
|
export declare function withLeadSandbox<T>(leadThread: string | undefined, fn: () => T): T;
|
|
22
24
|
/** Optional runtime inputs that drive connector sandbox provisioning. */
|
|
@@ -36,6 +38,12 @@ export interface ResolveManagedSandboxOptions {
|
|
|
36
38
|
* messages in an already-synced thread (mode `"credentials"`).
|
|
37
39
|
*/
|
|
38
40
|
export declare function resolveManagedSandbox(sandbox: SandboxDefinition, config: ManagedRunConfig | undefined, options?: ResolveManagedSandboxOptions): Promise<SandboxBackendProtocolV2>;
|
|
41
|
+
/**
|
|
42
|
+
* Adopt the per-thread sandbox, or create it without waiting for it to boot,
|
|
43
|
+
* and return its name. {@link resolveManagedSandbox} waits for the sandbox,
|
|
44
|
+
* and runs the connectors' hooks, on its first use.
|
|
45
|
+
*/
|
|
46
|
+
export declare function claimManagedSandbox(sandbox: SandboxDefinition, config: ManagedRunConfig | undefined, options?: ResolveManagedSandboxOptions): Promise<string | undefined>;
|
|
39
47
|
/**
|
|
40
48
|
* The thread's sandbox if this process has opened it, by any caller; never
|
|
41
49
|
* opens one. A sandbox being recreated reads as unopened until its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAS7E,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKvD,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AAEjE,oEAAoE;AACpE,eAAO,MAAM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AClC,OAAO,EAAE,iBAAiB,GACzB,mBAAmB,GAAG,SAAS,CAYjC;AA0TD,iFAAiF;AACjF,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,OAAO,mBAAmB,EAAE,kBAAkB,GAC1D,OAAO,CAAC,IAAI,CAAC,CAmCf"}
|
|
@@ -31,6 +31,12 @@ const TENANT_HEADER = "X-Tenant-Id";
|
|
|
31
31
|
* bake, not on thread create.
|
|
32
32
|
*/
|
|
33
33
|
const managedSandboxes = new Map();
|
|
34
|
+
/**
|
|
35
|
+
* Sandboxes `runtime.backend.open({ wait: false })` claimed, by the same key,
|
|
36
|
+
* until their first use waits for them to boot and moves them to
|
|
37
|
+
* `managedSandboxes`.
|
|
38
|
+
*/
|
|
39
|
+
const claimedSandboxes = new Map();
|
|
34
40
|
/** Host box names that must not be re-adopted after invalidate until recreate. */
|
|
35
41
|
const invalidatedSandboxNames = new Set();
|
|
36
42
|
/** Host box name for a resolved backend instance (survives cache replacement). */
|
|
@@ -61,10 +67,14 @@ const SANDBOX_DEPLOYMENT_DIGEST_LENGTH = 8;
|
|
|
61
67
|
const ADOPTABLE_STATUS = new Set(["ready", "running"]);
|
|
62
68
|
/** Sandbox status for one that is stopped but restartable. */
|
|
63
69
|
const STOPPED_STATUS = "stopped";
|
|
64
|
-
/** Sandbox status for one still booting: adopted,
|
|
70
|
+
/** Sandbox status for one still booting: adopted, and waited for on first use. */
|
|
65
71
|
const PROVISIONING_STATUS = "provisioning";
|
|
66
72
|
/** Lead thread whose sandbox this run shares; set only by the verified backend, never from config. */
|
|
67
73
|
const sharedLeadThread = new AsyncLocalStorage();
|
|
74
|
+
/** The lead thread whose sandbox the current call shares, if any. */
|
|
75
|
+
export function currentLeadThread() {
|
|
76
|
+
return sharedLeadThread.getStore();
|
|
77
|
+
}
|
|
68
78
|
/** Run `fn` with sandbox scope keys resolving to `leadThread`'s sandbox, if set. */
|
|
69
79
|
export function withLeadSandbox(leadThread, fn) {
|
|
70
80
|
return leadThread ? sharedLeadThread.run(leadThread, fn) : fn();
|
|
@@ -88,13 +98,16 @@ export function resolveManagedSandbox(sandbox, config, options) {
|
|
|
88
98
|
warnSelectionChanged(entry, options?.selection, config);
|
|
89
99
|
}
|
|
90
100
|
else {
|
|
101
|
+
// A claimed sandbox that fails to boot is claimed afresh by the next use.
|
|
102
|
+
const claim = claimedSandboxes.get(key);
|
|
103
|
+
claimedSandboxes.delete(key);
|
|
91
104
|
const created = {
|
|
92
105
|
syncedThreads: new Set(),
|
|
93
106
|
syncChain: Promise.resolve(),
|
|
94
107
|
freshlyCreated: true,
|
|
95
108
|
selectionFingerprint: options?.selection?.fingerprint,
|
|
96
109
|
ready: Promise.resolve().then(async () => {
|
|
97
|
-
const { backend, hostName, sandboxId } = await createLangSmithSandbox(sandbox, config, options, "create", key, { adoptedMode: sharesLeadSandbox ? "credentials" : "reuse" });
|
|
110
|
+
const { backend, hostName, sandboxId } = await createLangSmithSandbox(sandbox, config, options, "create", key, { adoptedMode: sharesLeadSandbox ? "credentials" : "reuse", claim });
|
|
98
111
|
created.hostName = hostName;
|
|
99
112
|
created.sandboxId = sandboxId;
|
|
100
113
|
const id = backend.id;
|
|
@@ -152,6 +165,30 @@ export function resolveManagedSandbox(sandbox, config, options) {
|
|
|
152
165
|
return backend;
|
|
153
166
|
});
|
|
154
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Adopt the per-thread sandbox, or create it without waiting for it to boot,
|
|
170
|
+
* and return its name. {@link resolveManagedSandbox} waits for the sandbox,
|
|
171
|
+
* and runs the connectors' hooks, on its first use.
|
|
172
|
+
*/
|
|
173
|
+
export async function claimManagedSandbox(sandbox, config, options) {
|
|
174
|
+
const key = sandboxScopeKey(config, options?.selection);
|
|
175
|
+
const entry = managedSandboxes.get(key);
|
|
176
|
+
if (entry) {
|
|
177
|
+
const backend = await entry.ready;
|
|
178
|
+
return entry.hostName ?? backend.id;
|
|
179
|
+
}
|
|
180
|
+
let claim = claimedSandboxes.get(key);
|
|
181
|
+
if (!claim) {
|
|
182
|
+
const claiming = claimLangSmithSandbox(sandbox, config, options?.selection, { wait: false }).catch((error) => {
|
|
183
|
+
if (claimedSandboxes.get(key) === claiming)
|
|
184
|
+
claimedSandboxes.delete(key);
|
|
185
|
+
throw error;
|
|
186
|
+
});
|
|
187
|
+
claimedSandboxes.set(key, claiming);
|
|
188
|
+
claim = claiming;
|
|
189
|
+
}
|
|
190
|
+
return (await claim).hostName;
|
|
191
|
+
}
|
|
155
192
|
/**
|
|
156
193
|
* The thread's sandbox if this process has opened it, by any caller; never
|
|
157
194
|
* opens one. A sandbox being recreated reads as unopened until its
|
|
@@ -332,6 +369,7 @@ function canonicalSandboxValue(value, ancestors) {
|
|
|
332
369
|
/** Clear the process-level sandbox cache. @internal Test-only. */
|
|
333
370
|
export function clearManagedSandboxCacheForTests() {
|
|
334
371
|
managedSandboxes.clear();
|
|
372
|
+
claimedSandboxes.clear();
|
|
335
373
|
invalidatedSandboxNames.clear();
|
|
336
374
|
}
|
|
337
375
|
/**
|
|
@@ -373,6 +411,7 @@ export async function invalidateManagedSandbox(sandbox, config, options = {}) {
|
|
|
373
411
|
}
|
|
374
412
|
if (popCache) {
|
|
375
413
|
managedSandboxes.delete(key);
|
|
414
|
+
claimedSandboxes.delete(key);
|
|
376
415
|
}
|
|
377
416
|
if (entry?.hostName) {
|
|
378
417
|
names.add(entry.hostName);
|
|
@@ -556,8 +595,12 @@ function managedSandboxLookupNames(deployment, sandbox, config, selection) {
|
|
|
556
595
|
names.push(legacyManagedSandboxName(deployment, scopeKey, legacySandboxCreateOptions(sandbox)));
|
|
557
596
|
return [...new Set(names)];
|
|
558
597
|
}
|
|
559
|
-
async function createLangSmithSandbox(sandbox, config, options, mode, scopeKey, { recoveryName, existingSandbox, adoptedMode = "reuse", } = {}) {
|
|
560
|
-
const { backend, adopted, hostName, sandboxId } = await createLangSmithSandboxBackend(sandbox,
|
|
598
|
+
async function createLangSmithSandbox(sandbox, config, options, mode, scopeKey, { recoveryName, existingSandbox, adoptedMode = "reuse", claim, } = {}) {
|
|
599
|
+
const { backend, adopted, hostName, sandboxId } = await createLangSmithSandboxBackend(sandbox, scopeKey, await (claim ??
|
|
600
|
+
claimLangSmithSandbox(sandbox, config, options?.selection, {
|
|
601
|
+
recoveryName,
|
|
602
|
+
existingSandbox,
|
|
603
|
+
})));
|
|
561
604
|
await runConnectorSandboxHooks(options?.connectors, {
|
|
562
605
|
backend,
|
|
563
606
|
// An adopted sandbox already ran create-time provisioning in an earlier
|
|
@@ -696,9 +739,44 @@ async function deleteHostSandbox(sandbox, name) {
|
|
|
696
739
|
logger.error(`sandbox invalidate: delete failed name=${JSON.stringify(logger.logIdentifier(name))} err=${logger.safeErrorLabel(error)}`, error, { sandbox: name });
|
|
697
740
|
}
|
|
698
741
|
}
|
|
699
|
-
async function createLangSmithSandboxBackend(sandbox,
|
|
742
|
+
async function createLangSmithSandboxBackend(sandbox, scopeKey, claim) {
|
|
700
743
|
const { defaultTimeout } = sandbox.options ?? {};
|
|
744
|
+
const langSmithSandbox = await readySandbox(claim);
|
|
745
|
+
const { adopted } = claim;
|
|
746
|
+
const hostName = stringOption(langSmithSandbox.name) ?? claim.hostName;
|
|
747
|
+
console.info(`[mda] sandbox resolve: ${adopted ? "adopted" : "created"} ` +
|
|
748
|
+
`name=${JSON.stringify(hostName ?? null)} ` +
|
|
749
|
+
`id=${JSON.stringify(langSmithSandbox.id ?? null)} ` +
|
|
750
|
+
`scope=${JSON.stringify(scopeKey)}`);
|
|
751
|
+
return {
|
|
752
|
+
backend: new LangSmithSandbox({
|
|
753
|
+
sandbox: langSmithSandbox,
|
|
754
|
+
defaultTimeout,
|
|
755
|
+
}),
|
|
756
|
+
adopted,
|
|
757
|
+
hostName,
|
|
758
|
+
sandboxId: langSmithSandbox.id,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
/** The claimed sandbox once it has booted; throws if it fails to boot. */
|
|
762
|
+
async function readySandbox(claim) {
|
|
763
|
+
const status = stringOption(claim.sandbox.status)?.toLowerCase();
|
|
764
|
+
const name = stringOption(claim.sandbox.name) ?? claim.hostName;
|
|
765
|
+
if (status !== PROVISIONING_STATUS || name === undefined) {
|
|
766
|
+
return claim.sandbox;
|
|
767
|
+
}
|
|
768
|
+
return await claim.client.waitForSandbox(name);
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Adopt this scope's LangSmith sandbox or create it; without `wait`, before it
|
|
772
|
+
* boots. A stopped sandbox still restarts here and waits: the SDK's start
|
|
773
|
+
* always waits.
|
|
774
|
+
*/
|
|
775
|
+
async function claimLangSmithSandbox(sandbox, config, selection, { recoveryName, existingSandbox, wait = true, } = {}) {
|
|
701
776
|
const createRequest = sandboxCreateOptions(sandbox, selection);
|
|
777
|
+
if (!wait) {
|
|
778
|
+
createRequest.options.waitForReady = false;
|
|
779
|
+
}
|
|
702
780
|
const client = new SandboxClient(sandboxClientOptions(sandbox));
|
|
703
781
|
const deployment = managedDeploymentName();
|
|
704
782
|
const lookupNames = deployment
|
|
@@ -710,19 +788,11 @@ async function createLangSmithSandboxBackend(sandbox, config, scopeKey, selectio
|
|
|
710
788
|
: recoveryName
|
|
711
789
|
? await createReplacementSandbox(client, createRequest, recoveryName)
|
|
712
790
|
: await resolveSandboxInstance(client, createRequest, sandboxName, lookupNames.slice(1));
|
|
713
|
-
const hostName = stringOption(langSmithSandbox.name) ?? sandboxName;
|
|
714
|
-
console.info(`[mda] sandbox resolve: ${adopted ? "adopted" : "created"} ` +
|
|
715
|
-
`name=${JSON.stringify(hostName ?? null)} ` +
|
|
716
|
-
`id=${JSON.stringify(langSmithSandbox.id ?? null)} ` +
|
|
717
|
-
`scope=${JSON.stringify(scopeKey)}`);
|
|
718
791
|
return {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
defaultTimeout,
|
|
722
|
-
}),
|
|
792
|
+
client,
|
|
793
|
+
sandbox: langSmithSandbox,
|
|
723
794
|
adopted,
|
|
724
|
-
hostName,
|
|
725
|
-
sandboxId: langSmithSandbox.id,
|
|
795
|
+
hostName: stringOption(langSmithSandbox.name) ?? sandboxName,
|
|
726
796
|
};
|
|
727
797
|
}
|
|
728
798
|
async function createReplacementSandbox(client, request, name) {
|
|
@@ -812,14 +882,13 @@ async function adoptSandbox(client, name) {
|
|
|
812
882
|
throw new Error(`Could not look up sandbox ${JSON.stringify(name)}; retry the run: ${errorMessage(error)}`, { cause: error });
|
|
813
883
|
}
|
|
814
884
|
const status = stringOption(existing.status)?.toLowerCase();
|
|
815
|
-
// No status reported: assume the SDK handed back a usable sandbox.
|
|
816
|
-
|
|
885
|
+
// No status reported: assume the SDK handed back a usable sandbox. One still
|
|
886
|
+
// provisioning is another create's; `readySandbox` waits for it to boot.
|
|
887
|
+
if (status === undefined ||
|
|
888
|
+
ADOPTABLE_STATUS.has(status) ||
|
|
889
|
+
status === PROVISIONING_STATUS) {
|
|
817
890
|
return existing;
|
|
818
891
|
}
|
|
819
|
-
if (status === PROVISIONING_STATUS) {
|
|
820
|
-
// Another container's create is still booting it. Throws if it fails to boot.
|
|
821
|
-
return await client.waitForSandbox(name);
|
|
822
|
-
}
|
|
823
892
|
if (status === STOPPED_STATUS) {
|
|
824
893
|
if (typeof client.startSandbox !== "function") {
|
|
825
894
|
throw new Error(`Sandbox ${JSON.stringify(name)} is stopped and this client cannot start it`);
|