langchain 1.4.6-dev-1781485641139 → 1.4.6
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/CHANGELOG.md +15 -0
- package/chat_models/universal.cjs +1 -0
- package/chat_models/universal.d.cts +1 -0
- package/chat_models/universal.d.ts +1 -0
- package/chat_models/universal.js +1 -0
- package/dist/agents/ReactAgent.cjs +2 -5
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts +1 -1
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts +1 -1
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +1 -4
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/index.cjs +1 -3
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +1 -3
- package/dist/agents/index.d.cts.map +1 -1
- package/dist/agents/index.d.ts +1 -3
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -3
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/middleware/hitl.cjs +50 -3
- package/dist/agents/middleware/hitl.cjs.map +1 -1
- package/dist/agents/middleware/hitl.d.cts +105 -2
- package/dist/agents/middleware/hitl.d.cts.map +1 -1
- package/dist/agents/middleware/hitl.d.ts +105 -2
- package/dist/agents/middleware/hitl.d.ts.map +1 -1
- package/dist/agents/middleware/hitl.js +50 -3
- package/dist/agents/middleware/hitl.js.map +1 -1
- package/dist/agents/middleware/index.cjs +1 -0
- package/dist/agents/middleware/index.d.cts +2 -1
- package/dist/agents/middleware/index.d.ts +2 -1
- package/dist/agents/middleware/index.js +1 -0
- package/dist/agents/middleware/provider/aws/promptCaching.cjs +209 -0
- package/dist/agents/middleware/provider/aws/promptCaching.cjs.map +1 -0
- package/dist/agents/middleware/provider/aws/promptCaching.d.cts +207 -0
- package/dist/agents/middleware/provider/aws/promptCaching.d.cts.map +1 -0
- package/dist/agents/middleware/provider/aws/promptCaching.d.ts +207 -0
- package/dist/agents/middleware/provider/aws/promptCaching.d.ts.map +1 -0
- package/dist/agents/middleware/provider/aws/promptCaching.js +208 -0
- package/dist/agents/middleware/provider/aws/promptCaching.js.map +1 -0
- package/dist/agents/middleware/toolEmulator.cjs +1 -1
- package/dist/agents/middleware/toolEmulator.cjs.map +1 -1
- package/dist/agents/middleware/toolEmulator.js +1 -1
- package/dist/agents/middleware/toolEmulator.js.map +1 -1
- package/dist/agents/{transformers/tool-call.cjs → stream.cjs} +15 -3
- package/dist/agents/stream.cjs.map +1 -0
- package/dist/agents/{transformers/types.d.ts → stream.d.cts} +20 -50
- package/dist/agents/stream.d.cts.map +1 -0
- package/dist/agents/{transformers/types.d.cts → stream.d.ts} +20 -50
- package/dist/agents/stream.d.ts.map +1 -0
- package/dist/agents/{transformers/tool-call.js → stream.js} +14 -2
- package/dist/agents/stream.js.map +1 -0
- package/dist/browser.cjs +6 -6
- package/dist/browser.d.cts +4 -5
- package/dist/browser.d.ts +4 -5
- package/dist/browser.js +4 -4
- package/dist/chat_models/universal.cjs +23 -4
- package/dist/chat_models/universal.cjs.map +1 -1
- package/dist/chat_models/universal.d.cts +27 -2
- package/dist/chat_models/universal.d.cts.map +1 -1
- package/dist/chat_models/universal.d.ts +27 -2
- package/dist/chat_models/universal.d.ts.map +1 -1
- package/dist/chat_models/universal.js +23 -4
- package/dist/chat_models/universal.js.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +4 -4
- package/hub/node.cjs +1 -0
- package/hub/node.d.cts +1 -0
- package/hub/node.d.ts +1 -0
- package/hub/node.js +1 -0
- package/hub.cjs +1 -0
- package/hub.d.cts +1 -0
- package/hub.d.ts +1 -0
- package/hub.js +1 -0
- package/load/serializable.cjs +1 -0
- package/load/serializable.d.cts +1 -0
- package/load/serializable.d.ts +1 -0
- package/load/serializable.js +1 -0
- package/load.cjs +1 -0
- package/load.d.cts +1 -0
- package/load.d.ts +1 -0
- package/load.js +1 -0
- package/package.json +7 -6
- package/storage/encoder_backed.cjs +1 -0
- package/storage/encoder_backed.d.cts +1 -0
- package/storage/encoder_backed.d.ts +1 -0
- package/storage/encoder_backed.js +1 -0
- package/storage/file_system.cjs +1 -0
- package/storage/file_system.d.cts +1 -0
- package/storage/file_system.d.ts +1 -0
- package/storage/file_system.js +1 -0
- package/storage/in_memory.cjs +1 -0
- package/storage/in_memory.d.cts +1 -0
- package/storage/in_memory.d.ts +1 -0
- package/storage/in_memory.js +1 -0
- package/dist/agents/transformers/index.cjs +0 -2
- package/dist/agents/transformers/index.d.cts +0 -3
- package/dist/agents/transformers/index.d.ts +0 -3
- package/dist/agents/transformers/index.js +0 -3
- package/dist/agents/transformers/subagent.cjs +0 -205
- package/dist/agents/transformers/subagent.cjs.map +0 -1
- package/dist/agents/transformers/subagent.d.cts +0 -34
- package/dist/agents/transformers/subagent.d.cts.map +0 -1
- package/dist/agents/transformers/subagent.d.ts +0 -34
- package/dist/agents/transformers/subagent.d.ts.map +0 -1
- package/dist/agents/transformers/subagent.js +0 -204
- package/dist/agents/transformers/subagent.js.map +0 -1
- package/dist/agents/transformers/tool-call.cjs.map +0 -1
- package/dist/agents/transformers/tool-call.d.cts +0 -17
- package/dist/agents/transformers/tool-call.d.cts.map +0 -1
- package/dist/agents/transformers/tool-call.d.ts +0 -17
- package/dist/agents/transformers/tool-call.d.ts.map +0 -1
- package/dist/agents/transformers/tool-call.js.map +0 -1
- package/dist/agents/transformers/types.d.cts.map +0 -1
- package/dist/agents/transformers/types.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "1.4.6
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"author": "LangChain",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,14 +53,15 @@
|
|
|
53
53
|
"typescript": "~6.0.3",
|
|
54
54
|
"vitest": "^4.1.8",
|
|
55
55
|
"yaml": "^2.9.0",
|
|
56
|
-
"@langchain/anthropic": "1.
|
|
57
|
-
"@langchain/
|
|
58
|
-
"@langchain/
|
|
59
|
-
"@langchain/
|
|
56
|
+
"@langchain/anthropic": "1.5.0",
|
|
57
|
+
"@langchain/aws": "1.4.0",
|
|
58
|
+
"@langchain/core": "^1.2.0",
|
|
59
|
+
"@langchain/fireworks": "0.2.0",
|
|
60
|
+
"@langchain/openai": "1.5.0",
|
|
60
61
|
"@langchain/tsconfig": "0.0.1"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
|
-
"@langchain/core": "^1.
|
|
64
|
+
"@langchain/core": "^1.2.0"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
66
67
|
"@langchain/langgraph": "^1.3.4",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("../dist/storage/encoder_backed.cjs");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/encoder_backed.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/encoder_backed.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/encoder_backed.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("../dist/storage/file_system.cjs");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/file_system.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/file_system.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/file_system.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("../dist/storage/in_memory.cjs");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/in_memory.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/in_memory.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/storage/in_memory.js";
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_tool_call = require("./tool-call.cjs");
|
|
3
|
-
let _langchain_langgraph = require("@langchain/langgraph");
|
|
4
|
-
//#region src/agents/transformers/subagent.ts
|
|
5
|
-
function isRecord(value) {
|
|
6
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
-
}
|
|
8
|
-
/** Stable string key for a namespace. */
|
|
9
|
-
function nsKey(ns) {
|
|
10
|
-
return ns.join("\0");
|
|
11
|
-
}
|
|
12
|
-
/** Tests whether `ns` starts with every segment in `prefix`. */
|
|
13
|
-
function hasPrefix(ns, prefix) {
|
|
14
|
-
if (prefix.length > ns.length) return false;
|
|
15
|
-
for (let i = 0; i < prefix.length; i += 1) if (ns[i] !== prefix[i]) return false;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a native transformer that surfaces nested named agents on
|
|
20
|
-
* `run.subagents`.
|
|
21
|
-
*
|
|
22
|
-
* It watches `tasks` events to record each namespace's `lc_agent_name` (set by
|
|
23
|
-
* `createAgent({ name })`) and the triggering tool call, then — for any nested
|
|
24
|
-
* run one level below {@link scope} that carries an `lc_agent_name` — emits a
|
|
25
|
-
* typed {@link SubagentRunStream} handle.
|
|
26
|
-
*
|
|
27
|
-
* Each handle is backed by its own per-subagent transformer instances
|
|
28
|
-
* ({@link createMessagesTransformer}, {@link createToolCallTransformer}, and a
|
|
29
|
-
* nested {@link createSubagentTransformer}) scoped to the subagent's namespace.
|
|
30
|
-
* Every event in the subtree is fed straight into those transformers, which
|
|
31
|
-
* self-filter by namespace; the subagent's final `output` is resolved from its
|
|
32
|
-
* last `values` snapshot when its `lifecycle` completes.
|
|
33
|
-
*
|
|
34
|
-
* Marked `__native: true` — the `subagents` projection lands directly on the
|
|
35
|
-
* `GraphRunStream` instance as `run.subagents`.
|
|
36
|
-
*
|
|
37
|
-
* @param scope - Namespace prefix this transformer is scoped to. The root agent
|
|
38
|
-
* uses `[]`; nested handles use their subagent's namespace, so grandchild
|
|
39
|
-
* subagents are discovered recursively.
|
|
40
|
-
*/
|
|
41
|
-
function createSubagentTransformer(scope = []) {
|
|
42
|
-
return () => {
|
|
43
|
-
const subagentsLog = _langchain_langgraph.StreamChannel.local();
|
|
44
|
-
/** `lc_agent_name` observed per namespace (first task event wins). */
|
|
45
|
-
const lcByNs = /* @__PURE__ */ new Map();
|
|
46
|
-
/** Triggering task id -> originating LLM `tool_call_id`. */
|
|
47
|
-
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
48
|
-
/**
|
|
49
|
-
* Namespace key -> the `tool_call_id` of the most recent tool to start
|
|
50
|
-
* executing there. A tool that invokes a subagent emits its `tool-started`
|
|
51
|
-
* at the tools-node namespace (`tools:<task_id>`) where the subagent then
|
|
52
|
-
* roots, so this is the tool call that caused the subagent.
|
|
53
|
-
*/
|
|
54
|
-
const activeToolCallByNs = /* @__PURE__ */ new Map();
|
|
55
|
-
const handles = /* @__PURE__ */ new Map();
|
|
56
|
-
const depth = scope.length;
|
|
57
|
-
function recordIdentity(ns, data) {
|
|
58
|
-
const key = nsKey(ns);
|
|
59
|
-
if (lcByNs.has(key)) return;
|
|
60
|
-
const lc = (isRecord(data) && isRecord(data.metadata) ? data.metadata : void 0)?.lc_agent_name;
|
|
61
|
-
lcByNs.set(key, typeof lc === "string" ? lc : void 0);
|
|
62
|
-
}
|
|
63
|
-
function recordPendingToolCalls(data) {
|
|
64
|
-
if (!isRecord(data)) return;
|
|
65
|
-
const taskId = data.id;
|
|
66
|
-
if (typeof taskId !== "string") return;
|
|
67
|
-
const input = data.input;
|
|
68
|
-
let toolCallId;
|
|
69
|
-
if (isRecord(input) && isRecord(input.tool_call)) {
|
|
70
|
-
const candidate = input.tool_call.id;
|
|
71
|
-
if (typeof candidate === "string") toolCallId = candidate;
|
|
72
|
-
} else if (Array.isArray(input)) {
|
|
73
|
-
for (const toolCall of input) if (isRecord(toolCall) && typeof toolCall.id === "string") {
|
|
74
|
-
toolCallId = toolCall.id;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (toolCallId != null) pendingToolCalls.set(taskId, toolCallId);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Derive the `toolCall` cause for a named-subagent namespace.
|
|
82
|
-
*
|
|
83
|
-
* Primary signal: the tool whose `tool-started` event fired at the
|
|
84
|
-
* subagent's own namespace (the tools node it roots under). Fallback: the
|
|
85
|
-
* namespace segment's task id (`node:<task_id>`) joined to a tool call
|
|
86
|
-
* harvested from a `tool_call_with_context`-shaped task input, so the
|
|
87
|
-
* derivation stays correct if that shape reaches the stream in the future.
|
|
88
|
-
*/
|
|
89
|
-
function deriveCause(ns) {
|
|
90
|
-
const active = activeToolCallByNs.get(nsKey(ns));
|
|
91
|
-
if (typeof active === "string" && active.length > 0) return {
|
|
92
|
-
type: "toolCall",
|
|
93
|
-
tool_call_id: active
|
|
94
|
-
};
|
|
95
|
-
const segment = ns[ns.length - 1];
|
|
96
|
-
const colon = segment.indexOf(":");
|
|
97
|
-
if (colon === -1) return void 0;
|
|
98
|
-
const triggerCallId = segment.slice(colon + 1);
|
|
99
|
-
if (triggerCallId.length === 0) return void 0;
|
|
100
|
-
const toolCallId = pendingToolCalls.get(triggerCallId);
|
|
101
|
-
if (typeof toolCallId !== "string" || toolCallId.length === 0) return;
|
|
102
|
-
return {
|
|
103
|
-
type: "toolCall",
|
|
104
|
-
tool_call_id: toolCallId
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function maybeStartSubagent(ns) {
|
|
108
|
-
if (ns.length !== depth + 1 || !hasPrefix(ns, scope)) return;
|
|
109
|
-
const key = nsKey(ns);
|
|
110
|
-
if (handles.has(key)) return;
|
|
111
|
-
const lc = lcByNs.get(key);
|
|
112
|
-
if (typeof lc !== "string" || lc.length === 0) return;
|
|
113
|
-
const messages = (0, _langchain_langgraph.createMessagesTransformer)(ns);
|
|
114
|
-
const messagesProjection = messages.init();
|
|
115
|
-
const toolCall = require_tool_call.createToolCallTransformer(ns)();
|
|
116
|
-
const toolCallProjection = toolCall.init();
|
|
117
|
-
const nested = createSubagentTransformer(ns)();
|
|
118
|
-
const nestedProjection = nested.init();
|
|
119
|
-
let resolveOutput;
|
|
120
|
-
let rejectOutput;
|
|
121
|
-
const output = new Promise((resolve, reject) => {
|
|
122
|
-
resolveOutput = resolve;
|
|
123
|
-
rejectOutput = reject;
|
|
124
|
-
});
|
|
125
|
-
handles.set(key, {
|
|
126
|
-
key,
|
|
127
|
-
path: ns,
|
|
128
|
-
name: lc,
|
|
129
|
-
messages,
|
|
130
|
-
toolCall,
|
|
131
|
-
nested,
|
|
132
|
-
resolveOutput,
|
|
133
|
-
rejectOutput,
|
|
134
|
-
latestValues: void 0,
|
|
135
|
-
done: false
|
|
136
|
-
});
|
|
137
|
-
subagentsLog.push({
|
|
138
|
-
name: lc,
|
|
139
|
-
cause: deriveCause(ns),
|
|
140
|
-
output,
|
|
141
|
-
messages: messagesProjection.messages,
|
|
142
|
-
toolCalls: toolCallProjection.toolCalls,
|
|
143
|
-
subagents: nestedProjection.subagents
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
function finishHandle(handle, outcome) {
|
|
147
|
-
if (handle.done) return;
|
|
148
|
-
handle.done = true;
|
|
149
|
-
if (outcome.type === "resolve") handle.resolveOutput(handle.latestValues);
|
|
150
|
-
else handle.rejectOutput(outcome.error);
|
|
151
|
-
handle.messages.finalize?.();
|
|
152
|
-
handle.toolCall.finalize?.();
|
|
153
|
-
handle.nested.finalize?.();
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
__native: true,
|
|
157
|
-
init: () => ({ subagents: subagentsLog }),
|
|
158
|
-
process(event) {
|
|
159
|
-
const ns = event.params.namespace;
|
|
160
|
-
const data = event.params.data;
|
|
161
|
-
const isTaskResult = event.method === "tasks" && isRecord(data) && "result" in data;
|
|
162
|
-
if (event.method === "tools" && isRecord(data) && data.event === "tool-started" && typeof data.tool_call_id === "string" && data.tool_call_id.length > 0) activeToolCallByNs.set(nsKey(ns), data.tool_call_id);
|
|
163
|
-
if (event.method === "tasks" && !isTaskResult) {
|
|
164
|
-
recordIdentity(ns, data);
|
|
165
|
-
recordPendingToolCalls(data);
|
|
166
|
-
maybeStartSubagent(ns);
|
|
167
|
-
}
|
|
168
|
-
for (const handle of handles.values()) {
|
|
169
|
-
if (handle.done) continue;
|
|
170
|
-
if (!hasPrefix(ns, handle.path)) continue;
|
|
171
|
-
handle.messages.process(event);
|
|
172
|
-
handle.toolCall.process(event);
|
|
173
|
-
handle.nested.process(event);
|
|
174
|
-
if (nsKey(ns) === handle.key) {
|
|
175
|
-
if (event.method === "values" && isRecord(data)) handle.latestValues = data;
|
|
176
|
-
else if (event.method === "lifecycle" && isRecord(data)) {
|
|
177
|
-
const status = data.event;
|
|
178
|
-
if (status === "completed" || status === "interrupted") finishHandle(handle, { type: "resolve" });
|
|
179
|
-
else if (status === "failed") finishHandle(handle, {
|
|
180
|
-
type: "reject",
|
|
181
|
-
error: /* @__PURE__ */ new Error(`Subagent ${handle.name} failed`)
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return true;
|
|
187
|
-
},
|
|
188
|
-
finalize() {
|
|
189
|
-
for (const handle of handles.values()) finishHandle(handle, { type: "resolve" });
|
|
190
|
-
subagentsLog.close();
|
|
191
|
-
},
|
|
192
|
-
fail(err) {
|
|
193
|
-
for (const handle of handles.values()) finishHandle(handle, {
|
|
194
|
-
type: "reject",
|
|
195
|
-
error: err
|
|
196
|
-
});
|
|
197
|
-
subagentsLog.fail(err);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
|
-
exports.createSubagentTransformer = createSubagentTransformer;
|
|
204
|
-
|
|
205
|
-
//# sourceMappingURL=subagent.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.cjs","names":["StreamChannel","createToolCallTransformer"],"sources":["../../../src/agents/transformers/subagent.ts"],"sourcesContent":["import {\n StreamChannel,\n createMessagesTransformer,\n type NativeStreamTransformer,\n type ProtocolEvent,\n type Namespace,\n type LifecycleCause,\n} from \"@langchain/langgraph\";\n\nimport { createToolCallTransformer } from \"./tool-call.js\";\nimport type { SubagentRunStream } from \"./types.js\";\n\ninterface SubagentProjection {\n subagents: AsyncIterable<SubagentRunStream>;\n}\n\n/** Per-subagent transformer instances, driven manually by the parent. */\ntype MessagesTransformer = ReturnType<typeof createMessagesTransformer>;\ntype ToolCallTransformer = ReturnType<\n ReturnType<typeof createToolCallTransformer>\n>;\ntype NestedSubagentTransformer = ReturnType<\n ReturnType<typeof createSubagentTransformer>\n>;\n\ninterface SubagentHandle {\n readonly key: string;\n readonly path: Namespace;\n readonly name: string;\n readonly messages: MessagesTransformer;\n readonly toolCall: ToolCallTransformer;\n readonly nested: NestedSubagentTransformer;\n readonly resolveOutput: (value: unknown) => void;\n readonly rejectOutput: (error: unknown) => void;\n latestValues: Record<string, unknown> | undefined;\n done: boolean;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Stable string key for a namespace. */\nfunction nsKey(ns: Namespace): string {\n return ns.join(\"\\u0000\");\n}\n\n/** Tests whether `ns` starts with every segment in `prefix`. */\nfunction hasPrefix(ns: Namespace, prefix: Namespace): boolean {\n if (prefix.length > ns.length) return false;\n for (let i = 0; i < prefix.length; i += 1) {\n if (ns[i] !== prefix[i]) return false;\n }\n return true;\n}\n\n/**\n * Creates a native transformer that surfaces nested named agents on\n * `run.subagents`.\n *\n * It watches `tasks` events to record each namespace's `lc_agent_name` (set by\n * `createAgent({ name })`) and the triggering tool call, then — for any nested\n * run one level below {@link scope} that carries an `lc_agent_name` — emits a\n * typed {@link SubagentRunStream} handle.\n *\n * Each handle is backed by its own per-subagent transformer instances\n * ({@link createMessagesTransformer}, {@link createToolCallTransformer}, and a\n * nested {@link createSubagentTransformer}) scoped to the subagent's namespace.\n * Every event in the subtree is fed straight into those transformers, which\n * self-filter by namespace; the subagent's final `output` is resolved from its\n * last `values` snapshot when its `lifecycle` completes.\n *\n * Marked `__native: true` — the `subagents` projection lands directly on the\n * `GraphRunStream` instance as `run.subagents`.\n *\n * @param scope - Namespace prefix this transformer is scoped to. The root agent\n * uses `[]`; nested handles use their subagent's namespace, so grandchild\n * subagents are discovered recursively.\n */\nexport function createSubagentTransformer(\n scope: Namespace = []\n): () => NativeStreamTransformer<SubagentProjection> {\n return () => {\n const subagentsLog = StreamChannel.local<SubagentRunStream>();\n /** `lc_agent_name` observed per namespace (first task event wins). */\n const lcByNs = new Map<string, string | undefined>();\n /** Triggering task id -> originating LLM `tool_call_id`. */\n const pendingToolCalls = new Map<string, string>();\n /**\n * Namespace key -> the `tool_call_id` of the most recent tool to start\n * executing there. A tool that invokes a subagent emits its `tool-started`\n * at the tools-node namespace (`tools:<task_id>`) where the subagent then\n * roots, so this is the tool call that caused the subagent.\n */\n const activeToolCallByNs = new Map<string, string>();\n const handles = new Map<string, SubagentHandle>();\n const depth = scope.length;\n\n function recordIdentity(ns: Namespace, data: unknown): void {\n const key = nsKey(ns);\n if (lcByNs.has(key)) return;\n const metadata =\n isRecord(data) && isRecord(data.metadata) ? data.metadata : undefined;\n const lc = metadata?.lc_agent_name;\n lcByNs.set(key, typeof lc === \"string\" ? lc : undefined);\n }\n\n function recordPendingToolCalls(data: unknown): void {\n if (!isRecord(data)) return;\n const taskId = data.id;\n if (typeof taskId !== \"string\") return;\n const input = data.input;\n let toolCallId: string | undefined;\n if (isRecord(input) && isRecord(input.tool_call)) {\n const candidate = input.tool_call.id;\n if (typeof candidate === \"string\") toolCallId = candidate;\n } else if (Array.isArray(input)) {\n for (const toolCall of input) {\n if (isRecord(toolCall) && typeof toolCall.id === \"string\") {\n toolCallId = toolCall.id;\n break;\n }\n }\n }\n if (toolCallId != null) pendingToolCalls.set(taskId, toolCallId);\n }\n\n /**\n * Derive the `toolCall` cause for a named-subagent namespace.\n *\n * Primary signal: the tool whose `tool-started` event fired at the\n * subagent's own namespace (the tools node it roots under). Fallback: the\n * namespace segment's task id (`node:<task_id>`) joined to a tool call\n * harvested from a `tool_call_with_context`-shaped task input, so the\n * derivation stays correct if that shape reaches the stream in the future.\n */\n function deriveCause(ns: Namespace): LifecycleCause | undefined {\n const active = activeToolCallByNs.get(nsKey(ns));\n if (typeof active === \"string\" && active.length > 0) {\n return { type: \"toolCall\", tool_call_id: active } as LifecycleCause;\n }\n const segment = ns[ns.length - 1];\n const colon = segment.indexOf(\":\");\n if (colon === -1) return undefined;\n const triggerCallId = segment.slice(colon + 1);\n if (triggerCallId.length === 0) return undefined;\n const toolCallId = pendingToolCalls.get(triggerCallId);\n if (typeof toolCallId !== \"string\" || toolCallId.length === 0) {\n return undefined;\n }\n return { type: \"toolCall\", tool_call_id: toolCallId } as LifecycleCause;\n }\n\n function maybeStartSubagent(ns: Namespace): void {\n if (ns.length !== depth + 1 || !hasPrefix(ns, scope)) return;\n const key = nsKey(ns);\n if (handles.has(key)) return;\n const lc = lcByNs.get(key);\n // Only surface nested runs carrying an `lc_agent_name`; plain subgraphs\n // (no name) are excluded so `run.subagents` stays agent-only.\n if (typeof lc !== \"string\" || lc.length === 0) return;\n\n // Per-subagent transformers, each scoped to the subagent's namespace so\n // they pick out only the subagent's own model node / tools / nested\n // agents when fed the full event stream.\n const messages = createMessagesTransformer(ns);\n const messagesProjection = messages.init();\n const toolCall = createToolCallTransformer(ns)();\n const toolCallProjection = toolCall.init();\n const nested = createSubagentTransformer(ns)();\n const nestedProjection = nested.init();\n\n let resolveOutput!: (value: unknown) => void;\n let rejectOutput!: (error: unknown) => void;\n const output = new Promise<Record<string, unknown>>((resolve, reject) => {\n resolveOutput = resolve as (value: unknown) => void;\n rejectOutput = reject;\n });\n\n handles.set(key, {\n key,\n path: ns,\n name: lc,\n messages,\n toolCall,\n nested,\n resolveOutput,\n rejectOutput,\n latestValues: undefined,\n done: false,\n });\n\n subagentsLog.push({\n name: lc,\n cause: deriveCause(ns),\n output,\n messages: messagesProjection.messages,\n toolCalls: toolCallProjection.toolCalls,\n subagents: nestedProjection.subagents,\n });\n }\n\n function finishHandle(\n handle: SubagentHandle,\n outcome: { type: \"resolve\" } | { type: \"reject\"; error: unknown }\n ): void {\n if (handle.done) return;\n handle.done = true;\n if (outcome.type === \"resolve\") {\n handle.resolveOutput(handle.latestValues);\n } else {\n handle.rejectOutput(outcome.error);\n }\n handle.messages.finalize?.();\n handle.toolCall.finalize?.();\n handle.nested.finalize?.();\n }\n\n return {\n __native: true as const,\n\n init: () => ({ subagents: subagentsLog }),\n\n process(event: ProtocolEvent): boolean {\n const ns = event.params.namespace;\n const data = event.params.data;\n const isTaskResult =\n event.method === \"tasks\" && isRecord(data) && \"result\" in data;\n\n // Track the tool currently executing at each namespace. A subagent's\n // dispatching tool starts at the same namespace the subagent roots\n // under, so this records the cause before the subagent is discovered.\n if (\n event.method === \"tools\" &&\n isRecord(data) &&\n data.event === \"tool-started\" &&\n typeof data.tool_call_id === \"string\" &&\n data.tool_call_id.length > 0\n ) {\n activeToolCallByNs.set(nsKey(ns), data.tool_call_id);\n }\n\n // A task start: record identity / tool call, then discover a subagent\n // boundary *before* fanning out so the new handle receives its own\n // subtree events (which Pregel emits after the parent-namespace task).\n if (event.method === \"tasks\" && !isTaskResult) {\n recordIdentity(ns, data);\n recordPendingToolCalls(data);\n maybeStartSubagent(ns);\n }\n\n // Fan the event out to every active subagent whose subtree contains it.\n // The per-subagent transformers self-filter by namespace depth.\n for (const handle of handles.values()) {\n if (handle.done) continue;\n if (!hasPrefix(ns, handle.path)) continue;\n\n handle.messages.process(event);\n handle.toolCall.process(event);\n handle.nested.process(event);\n\n // Track the subagent's own (root-level) state and resolve its\n // `output` from the last snapshot when its lifecycle completes.\n if (nsKey(ns) === handle.key) {\n if (event.method === \"values\" && isRecord(data)) {\n handle.latestValues = data;\n } else if (event.method === \"lifecycle\" && isRecord(data)) {\n const status = data.event;\n if (status === \"completed\" || status === \"interrupted\") {\n finishHandle(handle, { type: \"resolve\" });\n } else if (status === \"failed\") {\n finishHandle(handle, {\n type: \"reject\",\n error: new Error(`Subagent ${handle.name} failed`),\n });\n }\n }\n }\n }\n\n return true;\n },\n\n finalize(): void {\n for (const handle of handles.values()) {\n finishHandle(handle, { type: \"resolve\" });\n }\n subagentsLog.close();\n },\n\n fail(err: unknown): void {\n for (const handle of handles.values()) {\n finishHandle(handle, { type: \"reject\", error: err });\n }\n subagentsLog.fail(err);\n },\n };\n };\n}\n"],"mappings":";;;;AAsCA,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;AAI7E,SAAS,MAAM,IAAuB;AACpC,QAAO,GAAG,KAAK,KAAS;;;AAI1B,SAAS,UAAU,IAAe,QAA4B;AAC5D,KAAI,OAAO,SAAS,GAAG,OAAQ,QAAO;AACtC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,EACtC,KAAI,GAAG,OAAO,OAAO,GAAI,QAAO;AAElC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,SAAgB,0BACd,QAAmB,EAAE,EAC8B;AACnD,cAAa;EACX,MAAM,eAAeA,qBAAAA,cAAc,OAA0B;;EAE7D,MAAM,yBAAS,IAAI,KAAiC;;EAEpD,MAAM,mCAAmB,IAAI,KAAqB;;;;;;;EAOlD,MAAM,qCAAqB,IAAI,KAAqB;EACpD,MAAM,0BAAU,IAAI,KAA6B;EACjD,MAAM,QAAQ,MAAM;EAEpB,SAAS,eAAe,IAAe,MAAqB;GAC1D,MAAM,MAAM,MAAM,GAAG;AACrB,OAAI,OAAO,IA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,KAAK,iBAAiB,YAC7B,KAAK,aAAa,SAAS,EAE3B,oBAAmB,IAAI,MAAM,GAAG,EAAE,KAAK,aAAa;AAMtD,QAAI,MAAM,WAAW,WAAW,CAAC,cAAc;AAC7C,oBAAe,IAAI,KAAK;AACxB,4BAAuB,KAAK;AAC5B,wBAAmB,GAAG;;AAKxB,SAAK,MAAM,UAAU,QAAQ,QAAQ,EAAE;AACrC,SAAI,OAAO,KAAM;AACjB,SAAI,CAAC,UAAU,IAAI,OAAO,KAAK,CAAE;AAEjC,YAAO,SAAS,QAAQ,MAAM;AAC9B,YAAO,SAAS,QAAQ,MAAM;AAC9B,YAAO,OAAO,QAAQ,MAAM;AAI5B,SAAI,MAAM,GAAG,KAAK,OAAO;UACnB,MAAM,WAAW,YAAY,SAAS,KAAK,CAC7C,QAAO,eAAe;eACb,MAAM,WAAW,eAAe,SAAS,KAAK,EAAE;OACzD,MAAM,SAAS,KAAK;AACpB,WAAI,WAAW,eAAe,WAAW,cACvC,cAAa,QAAQ,EAAE,MAAM,WAAW,CAAC;gBAChC,WAAW,SACpB,cAAa,QAAQ;QACnB,MAAM;QACN,uBAAO,IAAI,MAAM,YAAY,OAAO,KAAK,SAAS;QACnD,CAAC;;;;AAMV,WAAO;;GAGT,WAAiB;AACf,SAAK,MAAM,UAAU,QAAQ,QAAQ,CACnC,cAAa,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,iBAAa,OAAO;;GAGtB,KAAK,KAAoB;AACvB,SAAK,MAAM,UAAU,QAAQ,QAAQ,CACnC,cAAa,QAAQ;KAAE,MAAM;KAAU,OAAO;KAAK,CAAC;AAEtD,iBAAa,KAAK,IAAI;;GAEzB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SubagentRunStream } from "./types.cjs";
|
|
2
|
-
import { Namespace, NativeStreamTransformer } from "@langchain/langgraph";
|
|
3
|
-
|
|
4
|
-
//#region src/agents/transformers/subagent.d.ts
|
|
5
|
-
interface SubagentProjection {
|
|
6
|
-
subagents: AsyncIterable<SubagentRunStream>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a native transformer that surfaces nested named agents on
|
|
10
|
-
* `run.subagents`.
|
|
11
|
-
*
|
|
12
|
-
* It watches `tasks` events to record each namespace's `lc_agent_name` (set by
|
|
13
|
-
* `createAgent({ name })`) and the triggering tool call, then — for any nested
|
|
14
|
-
* run one level below {@link scope} that carries an `lc_agent_name` — emits a
|
|
15
|
-
* typed {@link SubagentRunStream} handle.
|
|
16
|
-
*
|
|
17
|
-
* Each handle is backed by its own per-subagent transformer instances
|
|
18
|
-
* ({@link createMessagesTransformer}, {@link createToolCallTransformer}, and a
|
|
19
|
-
* nested {@link createSubagentTransformer}) scoped to the subagent's namespace.
|
|
20
|
-
* Every event in the subtree is fed straight into those transformers, which
|
|
21
|
-
* self-filter by namespace; the subagent's final `output` is resolved from its
|
|
22
|
-
* last `values` snapshot when its `lifecycle` completes.
|
|
23
|
-
*
|
|
24
|
-
* Marked `__native: true` — the `subagents` projection lands directly on the
|
|
25
|
-
* `GraphRunStream` instance as `run.subagents`.
|
|
26
|
-
*
|
|
27
|
-
* @param scope - Namespace prefix this transformer is scoped to. The root agent
|
|
28
|
-
* uses `[]`; nested handles use their subagent's namespace, so grandchild
|
|
29
|
-
* subagents are discovered recursively.
|
|
30
|
-
*/
|
|
31
|
-
declare function createSubagentTransformer(scope?: Namespace): () => NativeStreamTransformer<SubagentProjection>;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { createSubagentTransformer };
|
|
34
|
-
//# sourceMappingURL=subagent.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.d.cts","names":[],"sources":["../../../src/agents/transformers/subagent.ts"],"mappings":";;;;UAYU,kBAAA;EACR,SAAA,EAAW,aAAA,CAAc,iBAAA;AAAA;;;;;;;;;AAkE3B;;;;;;;;;;;;;;;iBAAgB,yBAAA,CACd,KAAA,GAAO,SAAA,SACA,uBAAA,CAAwB,kBAAA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SubagentRunStream } from "./types.js";
|
|
2
|
-
import { Namespace, NativeStreamTransformer } from "@langchain/langgraph";
|
|
3
|
-
|
|
4
|
-
//#region src/agents/transformers/subagent.d.ts
|
|
5
|
-
interface SubagentProjection {
|
|
6
|
-
subagents: AsyncIterable<SubagentRunStream>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a native transformer that surfaces nested named agents on
|
|
10
|
-
* `run.subagents`.
|
|
11
|
-
*
|
|
12
|
-
* It watches `tasks` events to record each namespace's `lc_agent_name` (set by
|
|
13
|
-
* `createAgent({ name })`) and the triggering tool call, then — for any nested
|
|
14
|
-
* run one level below {@link scope} that carries an `lc_agent_name` — emits a
|
|
15
|
-
* typed {@link SubagentRunStream} handle.
|
|
16
|
-
*
|
|
17
|
-
* Each handle is backed by its own per-subagent transformer instances
|
|
18
|
-
* ({@link createMessagesTransformer}, {@link createToolCallTransformer}, and a
|
|
19
|
-
* nested {@link createSubagentTransformer}) scoped to the subagent's namespace.
|
|
20
|
-
* Every event in the subtree is fed straight into those transformers, which
|
|
21
|
-
* self-filter by namespace; the subagent's final `output` is resolved from its
|
|
22
|
-
* last `values` snapshot when its `lifecycle` completes.
|
|
23
|
-
*
|
|
24
|
-
* Marked `__native: true` — the `subagents` projection lands directly on the
|
|
25
|
-
* `GraphRunStream` instance as `run.subagents`.
|
|
26
|
-
*
|
|
27
|
-
* @param scope - Namespace prefix this transformer is scoped to. The root agent
|
|
28
|
-
* uses `[]`; nested handles use their subagent's namespace, so grandchild
|
|
29
|
-
* subagents are discovered recursively.
|
|
30
|
-
*/
|
|
31
|
-
declare function createSubagentTransformer(scope?: Namespace): () => NativeStreamTransformer<SubagentProjection>;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { createSubagentTransformer };
|
|
34
|
-
//# sourceMappingURL=subagent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.d.ts","names":[],"sources":["../../../src/agents/transformers/subagent.ts"],"mappings":";;;;UAYU,kBAAA;EACR,SAAA,EAAW,aAAA,CAAc,iBAAA;AAAA;;;;;;;;;AAkE3B;;;;;;;;;;;;;;;iBAAgB,yBAAA,CACd,KAAA,GAAO,SAAA,SACA,uBAAA,CAAwB,kBAAA"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { createToolCallTransformer } from "./tool-call.js";
|
|
2
|
-
import { StreamChannel, createMessagesTransformer } from "@langchain/langgraph";
|
|
3
|
-
//#region src/agents/transformers/subagent.ts
|
|
4
|
-
function isRecord(value) {
|
|
5
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
-
}
|
|
7
|
-
/** Stable string key for a namespace. */
|
|
8
|
-
function nsKey(ns) {
|
|
9
|
-
return ns.join("\0");
|
|
10
|
-
}
|
|
11
|
-
/** Tests whether `ns` starts with every segment in `prefix`. */
|
|
12
|
-
function hasPrefix(ns, prefix) {
|
|
13
|
-
if (prefix.length > ns.length) return false;
|
|
14
|
-
for (let i = 0; i < prefix.length; i += 1) if (ns[i] !== prefix[i]) return false;
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Creates a native transformer that surfaces nested named agents on
|
|
19
|
-
* `run.subagents`.
|
|
20
|
-
*
|
|
21
|
-
* It watches `tasks` events to record each namespace's `lc_agent_name` (set by
|
|
22
|
-
* `createAgent({ name })`) and the triggering tool call, then — for any nested
|
|
23
|
-
* run one level below {@link scope} that carries an `lc_agent_name` — emits a
|
|
24
|
-
* typed {@link SubagentRunStream} handle.
|
|
25
|
-
*
|
|
26
|
-
* Each handle is backed by its own per-subagent transformer instances
|
|
27
|
-
* ({@link createMessagesTransformer}, {@link createToolCallTransformer}, and a
|
|
28
|
-
* nested {@link createSubagentTransformer}) scoped to the subagent's namespace.
|
|
29
|
-
* Every event in the subtree is fed straight into those transformers, which
|
|
30
|
-
* self-filter by namespace; the subagent's final `output` is resolved from its
|
|
31
|
-
* last `values` snapshot when its `lifecycle` completes.
|
|
32
|
-
*
|
|
33
|
-
* Marked `__native: true` — the `subagents` projection lands directly on the
|
|
34
|
-
* `GraphRunStream` instance as `run.subagents`.
|
|
35
|
-
*
|
|
36
|
-
* @param scope - Namespace prefix this transformer is scoped to. The root agent
|
|
37
|
-
* uses `[]`; nested handles use their subagent's namespace, so grandchild
|
|
38
|
-
* subagents are discovered recursively.
|
|
39
|
-
*/
|
|
40
|
-
function createSubagentTransformer(scope = []) {
|
|
41
|
-
return () => {
|
|
42
|
-
const subagentsLog = StreamChannel.local();
|
|
43
|
-
/** `lc_agent_name` observed per namespace (first task event wins). */
|
|
44
|
-
const lcByNs = /* @__PURE__ */ new Map();
|
|
45
|
-
/** Triggering task id -> originating LLM `tool_call_id`. */
|
|
46
|
-
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
47
|
-
/**
|
|
48
|
-
* Namespace key -> the `tool_call_id` of the most recent tool to start
|
|
49
|
-
* executing there. A tool that invokes a subagent emits its `tool-started`
|
|
50
|
-
* at the tools-node namespace (`tools:<task_id>`) where the subagent then
|
|
51
|
-
* roots, so this is the tool call that caused the subagent.
|
|
52
|
-
*/
|
|
53
|
-
const activeToolCallByNs = /* @__PURE__ */ new Map();
|
|
54
|
-
const handles = /* @__PURE__ */ new Map();
|
|
55
|
-
const depth = scope.length;
|
|
56
|
-
function recordIdentity(ns, data) {
|
|
57
|
-
const key = nsKey(ns);
|
|
58
|
-
if (lcByNs.has(key)) return;
|
|
59
|
-
const lc = (isRecord(data) && isRecord(data.metadata) ? data.metadata : void 0)?.lc_agent_name;
|
|
60
|
-
lcByNs.set(key, typeof lc === "string" ? lc : void 0);
|
|
61
|
-
}
|
|
62
|
-
function recordPendingToolCalls(data) {
|
|
63
|
-
if (!isRecord(data)) return;
|
|
64
|
-
const taskId = data.id;
|
|
65
|
-
if (typeof taskId !== "string") return;
|
|
66
|
-
const input = data.input;
|
|
67
|
-
let toolCallId;
|
|
68
|
-
if (isRecord(input) && isRecord(input.tool_call)) {
|
|
69
|
-
const candidate = input.tool_call.id;
|
|
70
|
-
if (typeof candidate === "string") toolCallId = candidate;
|
|
71
|
-
} else if (Array.isArray(input)) {
|
|
72
|
-
for (const toolCall of input) if (isRecord(toolCall) && typeof toolCall.id === "string") {
|
|
73
|
-
toolCallId = toolCall.id;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (toolCallId != null) pendingToolCalls.set(taskId, toolCallId);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Derive the `toolCall` cause for a named-subagent namespace.
|
|
81
|
-
*
|
|
82
|
-
* Primary signal: the tool whose `tool-started` event fired at the
|
|
83
|
-
* subagent's own namespace (the tools node it roots under). Fallback: the
|
|
84
|
-
* namespace segment's task id (`node:<task_id>`) joined to a tool call
|
|
85
|
-
* harvested from a `tool_call_with_context`-shaped task input, so the
|
|
86
|
-
* derivation stays correct if that shape reaches the stream in the future.
|
|
87
|
-
*/
|
|
88
|
-
function deriveCause(ns) {
|
|
89
|
-
const active = activeToolCallByNs.get(nsKey(ns));
|
|
90
|
-
if (typeof active === "string" && active.length > 0) return {
|
|
91
|
-
type: "toolCall",
|
|
92
|
-
tool_call_id: active
|
|
93
|
-
};
|
|
94
|
-
const segment = ns[ns.length - 1];
|
|
95
|
-
const colon = segment.indexOf(":");
|
|
96
|
-
if (colon === -1) return void 0;
|
|
97
|
-
const triggerCallId = segment.slice(colon + 1);
|
|
98
|
-
if (triggerCallId.length === 0) return void 0;
|
|
99
|
-
const toolCallId = pendingToolCalls.get(triggerCallId);
|
|
100
|
-
if (typeof toolCallId !== "string" || toolCallId.length === 0) return;
|
|
101
|
-
return {
|
|
102
|
-
type: "toolCall",
|
|
103
|
-
tool_call_id: toolCallId
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function maybeStartSubagent(ns) {
|
|
107
|
-
if (ns.length !== depth + 1 || !hasPrefix(ns, scope)) return;
|
|
108
|
-
const key = nsKey(ns);
|
|
109
|
-
if (handles.has(key)) return;
|
|
110
|
-
const lc = lcByNs.get(key);
|
|
111
|
-
if (typeof lc !== "string" || lc.length === 0) return;
|
|
112
|
-
const messages = createMessagesTransformer(ns);
|
|
113
|
-
const messagesProjection = messages.init();
|
|
114
|
-
const toolCall = createToolCallTransformer(ns)();
|
|
115
|
-
const toolCallProjection = toolCall.init();
|
|
116
|
-
const nested = createSubagentTransformer(ns)();
|
|
117
|
-
const nestedProjection = nested.init();
|
|
118
|
-
let resolveOutput;
|
|
119
|
-
let rejectOutput;
|
|
120
|
-
const output = new Promise((resolve, reject) => {
|
|
121
|
-
resolveOutput = resolve;
|
|
122
|
-
rejectOutput = reject;
|
|
123
|
-
});
|
|
124
|
-
handles.set(key, {
|
|
125
|
-
key,
|
|
126
|
-
path: ns,
|
|
127
|
-
name: lc,
|
|
128
|
-
messages,
|
|
129
|
-
toolCall,
|
|
130
|
-
nested,
|
|
131
|
-
resolveOutput,
|
|
132
|
-
rejectOutput,
|
|
133
|
-
latestValues: void 0,
|
|
134
|
-
done: false
|
|
135
|
-
});
|
|
136
|
-
subagentsLog.push({
|
|
137
|
-
name: lc,
|
|
138
|
-
cause: deriveCause(ns),
|
|
139
|
-
output,
|
|
140
|
-
messages: messagesProjection.messages,
|
|
141
|
-
toolCalls: toolCallProjection.toolCalls,
|
|
142
|
-
subagents: nestedProjection.subagents
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
function finishHandle(handle, outcome) {
|
|
146
|
-
if (handle.done) return;
|
|
147
|
-
handle.done = true;
|
|
148
|
-
if (outcome.type === "resolve") handle.resolveOutput(handle.latestValues);
|
|
149
|
-
else handle.rejectOutput(outcome.error);
|
|
150
|
-
handle.messages.finalize?.();
|
|
151
|
-
handle.toolCall.finalize?.();
|
|
152
|
-
handle.nested.finalize?.();
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
__native: true,
|
|
156
|
-
init: () => ({ subagents: subagentsLog }),
|
|
157
|
-
process(event) {
|
|
158
|
-
const ns = event.params.namespace;
|
|
159
|
-
const data = event.params.data;
|
|
160
|
-
const isTaskResult = event.method === "tasks" && isRecord(data) && "result" in data;
|
|
161
|
-
if (event.method === "tools" && isRecord(data) && data.event === "tool-started" && typeof data.tool_call_id === "string" && data.tool_call_id.length > 0) activeToolCallByNs.set(nsKey(ns), data.tool_call_id);
|
|
162
|
-
if (event.method === "tasks" && !isTaskResult) {
|
|
163
|
-
recordIdentity(ns, data);
|
|
164
|
-
recordPendingToolCalls(data);
|
|
165
|
-
maybeStartSubagent(ns);
|
|
166
|
-
}
|
|
167
|
-
for (const handle of handles.values()) {
|
|
168
|
-
if (handle.done) continue;
|
|
169
|
-
if (!hasPrefix(ns, handle.path)) continue;
|
|
170
|
-
handle.messages.process(event);
|
|
171
|
-
handle.toolCall.process(event);
|
|
172
|
-
handle.nested.process(event);
|
|
173
|
-
if (nsKey(ns) === handle.key) {
|
|
174
|
-
if (event.method === "values" && isRecord(data)) handle.latestValues = data;
|
|
175
|
-
else if (event.method === "lifecycle" && isRecord(data)) {
|
|
176
|
-
const status = data.event;
|
|
177
|
-
if (status === "completed" || status === "interrupted") finishHandle(handle, { type: "resolve" });
|
|
178
|
-
else if (status === "failed") finishHandle(handle, {
|
|
179
|
-
type: "reject",
|
|
180
|
-
error: /* @__PURE__ */ new Error(`Subagent ${handle.name} failed`)
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return true;
|
|
186
|
-
},
|
|
187
|
-
finalize() {
|
|
188
|
-
for (const handle of handles.values()) finishHandle(handle, { type: "resolve" });
|
|
189
|
-
subagentsLog.close();
|
|
190
|
-
},
|
|
191
|
-
fail(err) {
|
|
192
|
-
for (const handle of handles.values()) finishHandle(handle, {
|
|
193
|
-
type: "reject",
|
|
194
|
-
error: err
|
|
195
|
-
});
|
|
196
|
-
subagentsLog.fail(err);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
export { createSubagentTransformer };
|
|
203
|
-
|
|
204
|
-
//# sourceMappingURL=subagent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.js","names":[],"sources":["../../../src/agents/transformers/subagent.ts"],"sourcesContent":["import {\n StreamChannel,\n createMessagesTransformer,\n type NativeStreamTransformer,\n type ProtocolEvent,\n type Namespace,\n type LifecycleCause,\n} from \"@langchain/langgraph\";\n\nimport { createToolCallTransformer } from \"./tool-call.js\";\nimport type { SubagentRunStream } from \"./types.js\";\n\ninterface SubagentProjection {\n subagents: AsyncIterable<SubagentRunStream>;\n}\n\n/** Per-subagent transformer instances, driven manually by the parent. */\ntype MessagesTransformer = ReturnType<typeof createMessagesTransformer>;\ntype ToolCallTransformer = ReturnType<\n ReturnType<typeof createToolCallTransformer>\n>;\ntype NestedSubagentTransformer = ReturnType<\n ReturnType<typeof createSubagentTransformer>\n>;\n\ninterface SubagentHandle {\n readonly key: string;\n readonly path: Namespace;\n readonly name: string;\n readonly messages: MessagesTransformer;\n readonly toolCall: ToolCallTransformer;\n readonly nested: NestedSubagentTransformer;\n readonly resolveOutput: (value: unknown) => void;\n readonly rejectOutput: (error: unknown) => void;\n latestValues: Record<string, unknown> | undefined;\n done: boolean;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Stable string key for a namespace. */\nfunction nsKey(ns: Namespace): string {\n return ns.join(\"\\u0000\");\n}\n\n/** Tests whether `ns` starts with every segment in `prefix`. */\nfunction hasPrefix(ns: Namespace, prefix: Namespace): boolean {\n if (prefix.length > ns.length) return false;\n for (let i = 0; i < prefix.length; i += 1) {\n if (ns[i] !== prefix[i]) return false;\n }\n return true;\n}\n\n/**\n * Creates a native transformer that surfaces nested named agents on\n * `run.subagents`.\n *\n * It watches `tasks` events to record each namespace's `lc_agent_name` (set by\n * `createAgent({ name })`) and the triggering tool call, then — for any nested\n * run one level below {@link scope} that carries an `lc_agent_name` — emits a\n * typed {@link SubagentRunStream} handle.\n *\n * Each handle is backed by its own per-subagent transformer instances\n * ({@link createMessagesTransformer}, {@link createToolCallTransformer}, and a\n * nested {@link createSubagentTransformer}) scoped to the subagent's namespace.\n * Every event in the subtree is fed straight into those transformers, which\n * self-filter by namespace; the subagent's final `output` is resolved from its\n * last `values` snapshot when its `lifecycle` completes.\n *\n * Marked `__native: true` — the `subagents` projection lands directly on the\n * `GraphRunStream` instance as `run.subagents`.\n *\n * @param scope - Namespace prefix this transformer is scoped to. The root agent\n * uses `[]`; nested handles use their subagent's namespace, so grandchild\n * subagents are discovered recursively.\n */\nexport function createSubagentTransformer(\n scope: Namespace = []\n): () => NativeStreamTransformer<SubagentProjection> {\n return () => {\n const subagentsLog = StreamChannel.local<SubagentRunStream>();\n /** `lc_agent_name` observed per namespace (first task event wins). */\n const lcByNs = new Map<string, string | undefined>();\n /** Triggering task id -> originating LLM `tool_call_id`. */\n const pendingToolCalls = new Map<string, string>();\n /**\n * Namespace key -> the `tool_call_id` of the most recent tool to start\n * executing there. A tool that invokes a subagent emits its `tool-started`\n * at the tools-node namespace (`tools:<task_id>`) where the subagent then\n * roots, so this is the tool call that caused the subagent.\n */\n const activeToolCallByNs = new Map<string, string>();\n const handles = new Map<string, SubagentHandle>();\n const depth = scope.length;\n\n function recordIdentity(ns: Namespace, data: unknown): void {\n const key = nsKey(ns);\n if (lcByNs.has(key)) return;\n const metadata =\n isRecord(data) && isRecord(data.metadata) ? data.metadata : undefined;\n const lc = metadata?.lc_agent_name;\n lcByNs.set(key, typeof lc === \"string\" ? lc : undefined);\n }\n\n function recordPendingToolCalls(data: unknown): void {\n if (!isRecord(data)) return;\n const taskId = data.id;\n if (typeof taskId !== \"string\") return;\n const input = data.input;\n let toolCallId: string | undefined;\n if (isRecord(input) && isRecord(input.tool_call)) {\n const candidate = input.tool_call.id;\n if (typeof candidate === \"string\") toolCallId = candidate;\n } else if (Array.isArray(input)) {\n for (const toolCall of input) {\n if (isRecord(toolCall) && typeof toolCall.id === \"string\") {\n toolCallId = toolCall.id;\n break;\n }\n }\n }\n if (toolCallId != null) pendingToolCalls.set(taskId, toolCallId);\n }\n\n /**\n * Derive the `toolCall` cause for a named-subagent namespace.\n *\n * Primary signal: the tool whose `tool-started` event fired at the\n * subagent's own namespace (the tools node it roots under). Fallback: the\n * namespace segment's task id (`node:<task_id>`) joined to a tool call\n * harvested from a `tool_call_with_context`-shaped task input, so the\n * derivation stays correct if that shape reaches the stream in the future.\n */\n function deriveCause(ns: Namespace): LifecycleCause | undefined {\n const active = activeToolCallByNs.get(nsKey(ns));\n if (typeof active === \"string\" && active.length > 0) {\n return { type: \"toolCall\", tool_call_id: active } as LifecycleCause;\n }\n const segment = ns[ns.length - 1];\n const colon = segment.indexOf(\":\");\n if (colon === -1) return undefined;\n const triggerCallId = segment.slice(colon + 1);\n if (triggerCallId.length === 0) return undefined;\n const toolCallId = pendingToolCalls.get(triggerCallId);\n if (typeof toolCallId !== \"string\" || toolCallId.length === 0) {\n return undefined;\n }\n return { type: \"toolCall\", tool_call_id: toolCallId } as LifecycleCause;\n }\n\n function maybeStartSubagent(ns: Namespace): void {\n if (ns.length !== depth + 1 || !hasPrefix(ns, scope)) return;\n const key = nsKey(ns);\n if (handles.has(key)) return;\n const lc = lcByNs.get(key);\n // Only surface nested runs carrying an `lc_agent_name`; plain subgraphs\n // (no name) are excluded so `run.subagents` stays agent-only.\n if (typeof lc !== \"string\" || lc.length === 0) return;\n\n // Per-subagent transformers, each scoped to the subagent's namespace so\n // they pick out only the subagent's own model node / tools / nested\n // agents when fed the full event stream.\n const messages = createMessagesTransformer(ns);\n const messagesProjection = messages.init();\n const toolCall = createToolCallTransformer(ns)();\n const toolCallProjection = toolCall.init();\n const nested = createSubagentTransformer(ns)();\n const nestedProjection = nested.init();\n\n let resolveOutput!: (value: unknown) => void;\n let rejectOutput!: (error: unknown) => void;\n const output = new Promise<Record<string, unknown>>((resolve, reject) => {\n resolveOutput = resolve as (value: unknown) => void;\n rejectOutput = reject;\n });\n\n handles.set(key, {\n key,\n path: ns,\n name: lc,\n messages,\n toolCall,\n nested,\n resolveOutput,\n rejectOutput,\n latestValues: undefined,\n done: false,\n });\n\n subagentsLog.push({\n name: lc,\n cause: deriveCause(ns),\n output,\n messages: messagesProjection.messages,\n toolCalls: toolCallProjection.toolCalls,\n subagents: nestedProjection.subagents,\n });\n }\n\n function finishHandle(\n handle: SubagentHandle,\n outcome: { type: \"resolve\" } | { type: \"reject\"; error: unknown }\n ): void {\n if (handle.done) return;\n handle.done = true;\n if (outcome.type === \"resolve\") {\n handle.resolveOutput(handle.latestValues);\n } else {\n handle.rejectOutput(outcome.error);\n }\n handle.messages.finalize?.();\n handle.toolCall.finalize?.();\n handle.nested.finalize?.();\n }\n\n return {\n __native: true as const,\n\n init: () => ({ subagents: subagentsLog }),\n\n process(event: ProtocolEvent): boolean {\n const ns = event.params.namespace;\n const data = event.params.data;\n const isTaskResult =\n event.method === \"tasks\" && isRecord(data) && \"result\" in data;\n\n // Track the tool currently executing at each namespace. A subagent's\n // dispatching tool starts at the same namespace the subagent roots\n // under, so this records the cause before the subagent is discovered.\n if (\n event.method === \"tools\" &&\n isRecord(data) &&\n data.event === \"tool-started\" &&\n typeof data.tool_call_id === \"string\" &&\n data.tool_call_id.length > 0\n ) {\n activeToolCallByNs.set(nsKey(ns), data.tool_call_id);\n }\n\n // A task start: record identity / tool call, then discover a subagent\n // boundary *before* fanning out so the new handle receives its own\n // subtree events (which Pregel emits after the parent-namespace task).\n if (event.method === \"tasks\" && !isTaskResult) {\n recordIdentity(ns, data);\n recordPendingToolCalls(data);\n maybeStartSubagent(ns);\n }\n\n // Fan the event out to every active subagent whose subtree contains it.\n // The per-subagent transformers self-filter by namespace depth.\n for (const handle of handles.values()) {\n if (handle.done) continue;\n if (!hasPrefix(ns, handle.path)) continue;\n\n handle.messages.process(event);\n handle.toolCall.process(event);\n handle.nested.process(event);\n\n // Track the subagent's own (root-level) state and resolve its\n // `output` from the last snapshot when its lifecycle completes.\n if (nsKey(ns) === handle.key) {\n if (event.method === \"values\" && isRecord(data)) {\n handle.latestValues = data;\n } else if (event.method === \"lifecycle\" && isRecord(data)) {\n const status = data.event;\n if (status === \"completed\" || status === \"interrupted\") {\n finishHandle(handle, { type: \"resolve\" });\n } else if (status === \"failed\") {\n finishHandle(handle, {\n type: \"reject\",\n error: new Error(`Subagent ${handle.name} failed`),\n });\n }\n }\n }\n }\n\n return true;\n },\n\n finalize(): void {\n for (const handle of handles.values()) {\n finishHandle(handle, { type: \"resolve\" });\n }\n subagentsLog.close();\n },\n\n fail(err: unknown): void {\n for (const handle of handles.values()) {\n finishHandle(handle, { type: \"reject\", error: err });\n }\n subagentsLog.fail(err);\n },\n };\n };\n}\n"],"mappings":";;;AAsCA,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;AAI7E,SAAS,MAAM,IAAuB;AACpC,QAAO,GAAG,KAAK,KAAS;;;AAI1B,SAAS,UAAU,IAAe,QAA4B;AAC5D,KAAI,OAAO,SAAS,GAAG,OAAQ,QAAO;AACtC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,EACtC,KAAI,GAAG,OAAO,OAAO,GAAI,QAAO;AAElC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,SAAgB,0BACd,QAAmB,EAAE,EAC8B;AACnD,cAAa;EACX,MAAM,eAAe,cAAc,OAA0B;;EAE7D,MAAM,yBAAS,IAAI,KAAiC;;EAEpD,MAAM,mCAAmB,IAAI,KAAqB;;;;;;;EAOlD,MAAM,qCAAqB,IAAI,KAAqB;EACpD,MAAM,0BAAU,IAAI,KAA6B;EACjD,MAAM,QAAQ,MAAM;EAEpB,SAAS,eAAe,IAAe,MAAqB;GA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