deepagents 1.10.4 → 1.10.5

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.
@@ -4505,7 +4505,7 @@ const ASYNC_TASK_TOOL_NAMES = [
4505
4505
  "cancel_async_task",
4506
4506
  "list_async_tasks"
4507
4507
  ];
4508
- const TERMINAL_STATUSES = new Set([
4508
+ const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
4509
4509
  "cancelled",
4510
4510
  "success",
4511
4511
  "error",
@@ -5031,271 +5031,6 @@ function createCacheBreakpointMiddleware() {
5031
5031
  });
5032
5032
  }
5033
5033
  //#endregion
5034
- //#region src/stream.ts
5035
- /**
5036
- * Deep Agent streaming support (experimental).
5037
- *
5038
- * Provides:
5039
- * - `DeepAgentRunStream` — type overlay that adds `.subagents` to the
5040
- * `AgentRunStream` shape
5041
- * - `createSubagentTransformer` — a `__native` transformer whose
5042
- * projection (`subagents`) lands directly on the `GraphRunStream`
5043
- * instance via langgraph-core's native transformer support
5044
- *
5045
- * See protocol proposal §15 (In-Process Streaming Interface) and §16
5046
- * (Native Stream Transformers).
5047
- */
5048
- function hasPrefix(ns, prefix) {
5049
- if (prefix.length > ns.length) return false;
5050
- for (let i = 0; i < prefix.length; i += 1) if (ns[i] !== prefix[i]) return false;
5051
- return true;
5052
- }
5053
- /**
5054
- * Native transformer that correlates `task` tool calls into
5055
- * {@link SubagentRunStream} objects and routes child-namespace
5056
- * `tools` and `messages` events into per-subagent channels.
5057
- *
5058
- * Marked `__native: true` — the `subagents` projection key lands
5059
- * directly on the `GraphRunStream` instance as `run.subagents`.
5060
- */
5061
- function createSubagentTransformer(path) {
5062
- return () => {
5063
- const subagentsLog = _langchain_langgraph.StreamChannel.local();
5064
- const pendingByCallId = /* @__PURE__ */ new Map();
5065
- const pendingByNamespaceSegment = /* @__PURE__ */ new Map();
5066
- const latestValuesByNamespaceSegment = /* @__PURE__ */ new Map();
5067
- const subagentsByName = /* @__PURE__ */ new Map();
5068
- /** Maps tools-node namespace segment to subagent name. */
5069
- const toolsNodeToName = /* @__PURE__ */ new Map();
5070
- const childToolCalls = /* @__PURE__ */ new Map();
5071
- /** Active ChatModelStreamImpl per subagent (keyed by subagent name). */
5072
- const activeMessages = /* @__PURE__ */ new Map();
5073
- function deletePendingSubagent(pending) {
5074
- pendingByCallId.delete(pending.callId);
5075
- for (const [segment, entry] of pendingByNamespaceSegment) if (entry === pending) {
5076
- pendingByNamespaceSegment.delete(segment);
5077
- latestValuesByNamespaceSegment.delete(segment);
5078
- }
5079
- }
5080
- function subagentSegment(ns) {
5081
- return ns.length === path.length + 1 ? ns[path.length] : void 0;
5082
- }
5083
- function getOrCreateSubagentLogs(name) {
5084
- let logs = subagentsByName.get(name);
5085
- if (!logs) {
5086
- logs = {
5087
- messagesLog: _langchain_langgraph.StreamChannel.local(),
5088
- toolCallsLog: _langchain_langgraph.StreamChannel.local(),
5089
- nestedSubagentsLog: _langchain_langgraph.StreamChannel.local()
5090
- };
5091
- subagentsByName.set(name, logs);
5092
- }
5093
- return logs;
5094
- }
5095
- return {
5096
- __native: true,
5097
- init: () => ({ subagents: subagentsLog }),
5098
- process(event) {
5099
- if (!hasPrefix(event.params.namespace, path)) return true;
5100
- const ns = event.params.namespace;
5101
- const depth = ns.length - path.length;
5102
- if (depth <= 1 && event.method === "tools") {
5103
- const data = event.params.data;
5104
- const toolCallId = data.tool_call_id;
5105
- const toolName = data.tool_name;
5106
- if (toolName === "task" && data.event === "tool-started") {
5107
- const rawInput = data.input;
5108
- const input = typeof rawInput === "string" ? JSON.parse(rawInput) : rawInput ?? {};
5109
- const subagentName = input.subagent_type ?? "unknown";
5110
- const taskDescription = input.description ?? "";
5111
- let resolveTaskInput;
5112
- let resolveOutput;
5113
- let rejectOutput;
5114
- const taskInput = new Promise((res) => {
5115
- resolveTaskInput = res;
5116
- });
5117
- const output = new Promise((res, rej) => {
5118
- resolveOutput = res;
5119
- rejectOutput = rej;
5120
- });
5121
- const pending = {
5122
- name: subagentName,
5123
- callId: toolCallId,
5124
- resolveTaskInput,
5125
- resolveOutput,
5126
- rejectOutput
5127
- };
5128
- if (toolCallId) pendingByCallId.set(toolCallId, pending);
5129
- resolveTaskInput(taskDescription);
5130
- if (depth === 1) {
5131
- toolsNodeToName.set(ns[path.length], subagentName);
5132
- pendingByNamespaceSegment.set(ns[path.length], pending);
5133
- }
5134
- if (toolCallId) {
5135
- const taskSegment = `tools:${toolCallId}`;
5136
- toolsNodeToName.set(taskSegment, subagentName);
5137
- pendingByNamespaceSegment.set(taskSegment, pending);
5138
- }
5139
- const logs = getOrCreateSubagentLogs(subagentName);
5140
- subagentsLog.push({
5141
- name: subagentName,
5142
- taskInput,
5143
- output,
5144
- messages: logs.messagesLog,
5145
- toolCalls: logs.toolCallsLog,
5146
- subagents: logs.nestedSubagentsLog
5147
- });
5148
- }
5149
- if (toolName === "task" && toolCallId) {
5150
- const pending = pendingByCallId.get(toolCallId);
5151
- if (pending) {
5152
- if (data.event === "tool-finished") {
5153
- pending.resolveOutput(data.output);
5154
- deletePendingSubagent(pending);
5155
- } else if (data.event === "tool-error") {
5156
- const message = data.message ?? "unknown error";
5157
- pending.rejectOutput(new Error(message));
5158
- deletePendingSubagent(pending);
5159
- }
5160
- }
5161
- }
5162
- }
5163
- const segment = subagentSegment(ns);
5164
- const pending = segment ? pendingByNamespaceSegment.get(segment) : void 0;
5165
- if (pending) {
5166
- if (event.method === "values") latestValuesByNamespaceSegment.set(segment, event.params.data);
5167
- else if (event.method === "lifecycle") {
5168
- const data = event.params.data;
5169
- if (data.event === "completed" || data.event === "interrupted") {
5170
- pending.resolveOutput(latestValuesByNamespaceSegment.get(segment));
5171
- deletePendingSubagent(pending);
5172
- } else if (data.event === "failed") {
5173
- pending.rejectOutput(/* @__PURE__ */ new Error(`Subagent ${pending.name} failed`));
5174
- deletePendingSubagent(pending);
5175
- }
5176
- }
5177
- }
5178
- if (depth >= 2) {
5179
- const parentSegment = ns[path.length];
5180
- const subagentName = toolsNodeToName.get(parentSegment);
5181
- const logs = subagentName ? subagentsByName.get(subagentName) : void 0;
5182
- if (logs && subagentName) {
5183
- if (event.method === "tools") {
5184
- const data = event.params.data;
5185
- const toolCallId = data.tool_call_id;
5186
- const toolName = data.tool_name;
5187
- if (data.event === "tool-started") {
5188
- let resolveOutput;
5189
- let rejectOutput;
5190
- let resolveStatus;
5191
- let resolveError;
5192
- const output = new Promise((res, rej) => {
5193
- resolveOutput = res;
5194
- rejectOutput = rej;
5195
- });
5196
- const status = new Promise((res) => {
5197
- resolveStatus = res;
5198
- });
5199
- const error = new Promise((res) => {
5200
- resolveError = res;
5201
- });
5202
- childToolCalls.set(toolCallId, {
5203
- resolveOutput,
5204
- rejectOutput,
5205
- resolveStatus,
5206
- resolveError
5207
- });
5208
- const rawInput = data.input;
5209
- const parsedInput = typeof rawInput === "string" ? JSON.parse(rawInput) : rawInput;
5210
- logs.toolCallsLog.push({
5211
- name: toolName ?? "unknown",
5212
- callId: toolCallId,
5213
- input: parsedInput,
5214
- output,
5215
- status,
5216
- error
5217
- });
5218
- }
5219
- const pending = toolCallId ? childToolCalls.get(toolCallId) : void 0;
5220
- if (pending) {
5221
- if (data.event === "tool-finished") {
5222
- pending.resolveOutput(data.output);
5223
- pending.resolveStatus("finished");
5224
- pending.resolveError(void 0);
5225
- childToolCalls.delete(toolCallId);
5226
- } else if (data.event === "tool-error") {
5227
- const message = data.message ?? "unknown error";
5228
- pending.rejectOutput(new Error(message));
5229
- pending.resolveStatus("error");
5230
- pending.resolveError(message);
5231
- childToolCalls.delete(toolCallId);
5232
- }
5233
- }
5234
- }
5235
- if (event.method === "messages") {
5236
- const data = event.params.data;
5237
- if (data.event === "message-start") {
5238
- const eventsLog = _langchain_langgraph.StreamChannel.local();
5239
- const stream = new _langchain_langgraph.ChatModelStreamImpl(eventsLog);
5240
- eventsLog.push(data);
5241
- activeMessages.set(subagentName, {
5242
- stream,
5243
- eventsLog
5244
- });
5245
- logs.messagesLog.push(stream);
5246
- } else if (data.event === "message-finish") {
5247
- const active = activeMessages.get(subagentName);
5248
- if (active) {
5249
- active.eventsLog.push(data);
5250
- active.eventsLog.close();
5251
- activeMessages.delete(subagentName);
5252
- }
5253
- } else activeMessages.get(subagentName)?.eventsLog.push(data);
5254
- }
5255
- }
5256
- }
5257
- return true;
5258
- },
5259
- finalize() {
5260
- for (const pending of pendingByCallId.values()) pending.resolveOutput(void 0);
5261
- pendingByCallId.clear();
5262
- for (const pending of childToolCalls.values()) {
5263
- pending.resolveOutput(void 0);
5264
- pending.resolveStatus("finished");
5265
- pending.resolveError(void 0);
5266
- }
5267
- childToolCalls.clear();
5268
- for (const active of activeMessages.values()) active.eventsLog.fail(/* @__PURE__ */ new Error("run finalized before message completed"));
5269
- activeMessages.clear();
5270
- subagentsLog.close();
5271
- for (const logs of subagentsByName.values()) {
5272
- logs.toolCallsLog.close();
5273
- logs.messagesLog.close();
5274
- logs.nestedSubagentsLog.close();
5275
- }
5276
- },
5277
- fail(err) {
5278
- for (const pending of pendingByCallId.values()) pending.rejectOutput(err);
5279
- pendingByCallId.clear();
5280
- for (const pending of childToolCalls.values()) {
5281
- pending.rejectOutput(err);
5282
- pending.resolveStatus("error");
5283
- pending.resolveError(err instanceof Error ? err.message : String(err));
5284
- }
5285
- childToolCalls.clear();
5286
- for (const active of activeMessages.values()) active.eventsLog.fail(err);
5287
- activeMessages.clear();
5288
- subagentsLog.fail(err);
5289
- for (const logs of subagentsByName.values()) {
5290
- logs.toolCallsLog.fail(err);
5291
- logs.messagesLog.fail(err);
5292
- logs.nestedSubagentsLog.fail(err);
5293
- }
5294
- }
5295
- };
5296
- };
5297
- }
5298
- //#endregion
5299
5034
  //#region src/profiles/keys.ts
5300
5035
  /**
5301
5036
  * Normalize and validate a profile registry key.
@@ -5336,7 +5071,7 @@ function validateProfileKey(key) {
5336
5071
  * filesystem permissions.
5337
5072
  * - `SubAgentMiddleware` backs the `task` tool for subagent delegation.
5338
5073
  */
5339
- const REQUIRED_MIDDLEWARE_NAMES = new Set(["FilesystemMiddleware", "SubAgentMiddleware"]);
5074
+ const REQUIRED_MIDDLEWARE_NAMES = /* @__PURE__ */ new Set(["FilesystemMiddleware", "SubAgentMiddleware"]);
5340
5075
  /**
5341
5076
  * Type guard: is this a fully-constructed HarnessProfile (frozen with
5342
5077
  * Set fields) or raw options?
@@ -5423,7 +5158,7 @@ function createHarnessProfile(options = {}) {
5423
5158
  const EMPTY_HARNESS_PROFILE = createHarnessProfile();
5424
5159
  //#endregion
5425
5160
  //#region src/profiles/harness/serialization.ts
5426
- const POISONED_KEYS = new Set([
5161
+ const POISONED_KEYS = /* @__PURE__ */ new Set([
5427
5162
  "__proto__",
5428
5163
  "constructor",
5429
5164
  "prototype"
@@ -5999,7 +5734,7 @@ const BASE_AGENT_PROMPT = langchain.context`
5999
5734
 
6000
5735
  For longer tasks, provide brief progress updates at reasonable intervals — a concise sentence recapping what you've done and what's next.
6001
5736
  `;
6002
- const BUILTIN_TOOL_NAMES = new Set([
5737
+ const BUILTIN_TOOL_NAMES = /* @__PURE__ */ new Set([
6003
5738
  ...FILESYSTEM_TOOL_NAMES,
6004
5739
  ...ASYNC_TASK_TOOL_NAMES,
6005
5740
  "task",
@@ -6192,7 +5927,7 @@ function createDeepAgent(params = {}) {
6192
5927
  checkpointer,
6193
5928
  store,
6194
5929
  name,
6195
- streamTransformers: [createSubagentTransformer([]), ...streamTransformers]
5930
+ streamTransformers
6196
5931
  }).withConfig({
6197
5932
  recursionLimit: 1e4,
6198
5933
  metadata: {
@@ -7810,12 +7545,6 @@ Object.defineProperty(exports, "createSubAgentMiddleware", {
7810
7545
  return createSubAgentMiddleware;
7811
7546
  }
7812
7547
  });
7813
- Object.defineProperty(exports, "createSubagentTransformer", {
7814
- enumerable: true,
7815
- get: function() {
7816
- return createSubagentTransformer;
7817
- }
7818
- });
7819
7548
  Object.defineProperty(exports, "createSummarizationMiddleware", {
7820
7549
  enumerable: true,
7821
7550
  get: function() {
@@ -7907,4 +7636,4 @@ Object.defineProperty(exports, "serializeProfile", {
7907
7636
  }
7908
7637
  });
7909
7638
 
7910
- //# sourceMappingURL=langsmith-D-SD2NFy.cjs.map
7639
+ //# sourceMappingURL=langsmith-ZfNZ_Pyb.cjs.map