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.
@@ -1,5 +1,5 @@
1
1
  import { AIMessage, HumanMessage, SystemMessage, ToolMessage, anthropicPromptCachingMiddleware, context, countTokensApproximately, createAgent, createMiddleware, humanInTheLoopMiddleware, todoListMiddleware, tool } from "langchain";
2
- import { ChatModelStreamImpl, Command, REMOVE_ALL_MESSAGES, ReducedValue, StateSchema, StreamChannel, getConfig, getCurrentTaskInput, getStore, isCommand } from "@langchain/langgraph";
2
+ import { Command, REMOVE_ALL_MESSAGES, ReducedValue, StateSchema, getConfig, getCurrentTaskInput, getStore, isCommand } from "@langchain/langgraph";
3
3
  import { z } from "zod/v4";
4
4
  import micromatch from "micromatch";
5
5
  import { AIMessage as AIMessage$1, HumanMessage as HumanMessage$1, RemoveMessage, getBufferString } from "@langchain/core/messages";
@@ -4474,7 +4474,7 @@ const ASYNC_TASK_TOOL_NAMES = [
4474
4474
  "cancel_async_task",
4475
4475
  "list_async_tasks"
4476
4476
  ];
4477
- const TERMINAL_STATUSES = new Set([
4477
+ const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
4478
4478
  "cancelled",
4479
4479
  "success",
4480
4480
  "error",
@@ -5000,271 +5000,6 @@ function createCacheBreakpointMiddleware() {
5000
5000
  });
5001
5001
  }
5002
5002
  //#endregion
5003
- //#region src/stream.ts
5004
- /**
5005
- * Deep Agent streaming support (experimental).
5006
- *
5007
- * Provides:
5008
- * - `DeepAgentRunStream` — type overlay that adds `.subagents` to the
5009
- * `AgentRunStream` shape
5010
- * - `createSubagentTransformer` — a `__native` transformer whose
5011
- * projection (`subagents`) lands directly on the `GraphRunStream`
5012
- * instance via langgraph-core's native transformer support
5013
- *
5014
- * See protocol proposal §15 (In-Process Streaming Interface) and §16
5015
- * (Native Stream Transformers).
5016
- */
5017
- function hasPrefix(ns, prefix) {
5018
- if (prefix.length > ns.length) return false;
5019
- for (let i = 0; i < prefix.length; i += 1) if (ns[i] !== prefix[i]) return false;
5020
- return true;
5021
- }
5022
- /**
5023
- * Native transformer that correlates `task` tool calls into
5024
- * {@link SubagentRunStream} objects and routes child-namespace
5025
- * `tools` and `messages` events into per-subagent channels.
5026
- *
5027
- * Marked `__native: true` — the `subagents` projection key lands
5028
- * directly on the `GraphRunStream` instance as `run.subagents`.
5029
- */
5030
- function createSubagentTransformer(path) {
5031
- return () => {
5032
- const subagentsLog = StreamChannel.local();
5033
- const pendingByCallId = /* @__PURE__ */ new Map();
5034
- const pendingByNamespaceSegment = /* @__PURE__ */ new Map();
5035
- const latestValuesByNamespaceSegment = /* @__PURE__ */ new Map();
5036
- const subagentsByName = /* @__PURE__ */ new Map();
5037
- /** Maps tools-node namespace segment to subagent name. */
5038
- const toolsNodeToName = /* @__PURE__ */ new Map();
5039
- const childToolCalls = /* @__PURE__ */ new Map();
5040
- /** Active ChatModelStreamImpl per subagent (keyed by subagent name). */
5041
- const activeMessages = /* @__PURE__ */ new Map();
5042
- function deletePendingSubagent(pending) {
5043
- pendingByCallId.delete(pending.callId);
5044
- for (const [segment, entry] of pendingByNamespaceSegment) if (entry === pending) {
5045
- pendingByNamespaceSegment.delete(segment);
5046
- latestValuesByNamespaceSegment.delete(segment);
5047
- }
5048
- }
5049
- function subagentSegment(ns) {
5050
- return ns.length === path.length + 1 ? ns[path.length] : void 0;
5051
- }
5052
- function getOrCreateSubagentLogs(name) {
5053
- let logs = subagentsByName.get(name);
5054
- if (!logs) {
5055
- logs = {
5056
- messagesLog: StreamChannel.local(),
5057
- toolCallsLog: StreamChannel.local(),
5058
- nestedSubagentsLog: StreamChannel.local()
5059
- };
5060
- subagentsByName.set(name, logs);
5061
- }
5062
- return logs;
5063
- }
5064
- return {
5065
- __native: true,
5066
- init: () => ({ subagents: subagentsLog }),
5067
- process(event) {
5068
- if (!hasPrefix(event.params.namespace, path)) return true;
5069
- const ns = event.params.namespace;
5070
- const depth = ns.length - path.length;
5071
- if (depth <= 1 && event.method === "tools") {
5072
- const data = event.params.data;
5073
- const toolCallId = data.tool_call_id;
5074
- const toolName = data.tool_name;
5075
- if (toolName === "task" && data.event === "tool-started") {
5076
- const rawInput = data.input;
5077
- const input = typeof rawInput === "string" ? JSON.parse(rawInput) : rawInput ?? {};
5078
- const subagentName = input.subagent_type ?? "unknown";
5079
- const taskDescription = input.description ?? "";
5080
- let resolveTaskInput;
5081
- let resolveOutput;
5082
- let rejectOutput;
5083
- const taskInput = new Promise((res) => {
5084
- resolveTaskInput = res;
5085
- });
5086
- const output = new Promise((res, rej) => {
5087
- resolveOutput = res;
5088
- rejectOutput = rej;
5089
- });
5090
- const pending = {
5091
- name: subagentName,
5092
- callId: toolCallId,
5093
- resolveTaskInput,
5094
- resolveOutput,
5095
- rejectOutput
5096
- };
5097
- if (toolCallId) pendingByCallId.set(toolCallId, pending);
5098
- resolveTaskInput(taskDescription);
5099
- if (depth === 1) {
5100
- toolsNodeToName.set(ns[path.length], subagentName);
5101
- pendingByNamespaceSegment.set(ns[path.length], pending);
5102
- }
5103
- if (toolCallId) {
5104
- const taskSegment = `tools:${toolCallId}`;
5105
- toolsNodeToName.set(taskSegment, subagentName);
5106
- pendingByNamespaceSegment.set(taskSegment, pending);
5107
- }
5108
- const logs = getOrCreateSubagentLogs(subagentName);
5109
- subagentsLog.push({
5110
- name: subagentName,
5111
- taskInput,
5112
- output,
5113
- messages: logs.messagesLog,
5114
- toolCalls: logs.toolCallsLog,
5115
- subagents: logs.nestedSubagentsLog
5116
- });
5117
- }
5118
- if (toolName === "task" && toolCallId) {
5119
- const pending = pendingByCallId.get(toolCallId);
5120
- if (pending) {
5121
- if (data.event === "tool-finished") {
5122
- pending.resolveOutput(data.output);
5123
- deletePendingSubagent(pending);
5124
- } else if (data.event === "tool-error") {
5125
- const message = data.message ?? "unknown error";
5126
- pending.rejectOutput(new Error(message));
5127
- deletePendingSubagent(pending);
5128
- }
5129
- }
5130
- }
5131
- }
5132
- const segment = subagentSegment(ns);
5133
- const pending = segment ? pendingByNamespaceSegment.get(segment) : void 0;
5134
- if (pending) {
5135
- if (event.method === "values") latestValuesByNamespaceSegment.set(segment, event.params.data);
5136
- else if (event.method === "lifecycle") {
5137
- const data = event.params.data;
5138
- if (data.event === "completed" || data.event === "interrupted") {
5139
- pending.resolveOutput(latestValuesByNamespaceSegment.get(segment));
5140
- deletePendingSubagent(pending);
5141
- } else if (data.event === "failed") {
5142
- pending.rejectOutput(/* @__PURE__ */ new Error(`Subagent ${pending.name} failed`));
5143
- deletePendingSubagent(pending);
5144
- }
5145
- }
5146
- }
5147
- if (depth >= 2) {
5148
- const parentSegment = ns[path.length];
5149
- const subagentName = toolsNodeToName.get(parentSegment);
5150
- const logs = subagentName ? subagentsByName.get(subagentName) : void 0;
5151
- if (logs && subagentName) {
5152
- if (event.method === "tools") {
5153
- const data = event.params.data;
5154
- const toolCallId = data.tool_call_id;
5155
- const toolName = data.tool_name;
5156
- if (data.event === "tool-started") {
5157
- let resolveOutput;
5158
- let rejectOutput;
5159
- let resolveStatus;
5160
- let resolveError;
5161
- const output = new Promise((res, rej) => {
5162
- resolveOutput = res;
5163
- rejectOutput = rej;
5164
- });
5165
- const status = new Promise((res) => {
5166
- resolveStatus = res;
5167
- });
5168
- const error = new Promise((res) => {
5169
- resolveError = res;
5170
- });
5171
- childToolCalls.set(toolCallId, {
5172
- resolveOutput,
5173
- rejectOutput,
5174
- resolveStatus,
5175
- resolveError
5176
- });
5177
- const rawInput = data.input;
5178
- const parsedInput = typeof rawInput === "string" ? JSON.parse(rawInput) : rawInput;
5179
- logs.toolCallsLog.push({
5180
- name: toolName ?? "unknown",
5181
- callId: toolCallId,
5182
- input: parsedInput,
5183
- output,
5184
- status,
5185
- error
5186
- });
5187
- }
5188
- const pending = toolCallId ? childToolCalls.get(toolCallId) : void 0;
5189
- if (pending) {
5190
- if (data.event === "tool-finished") {
5191
- pending.resolveOutput(data.output);
5192
- pending.resolveStatus("finished");
5193
- pending.resolveError(void 0);
5194
- childToolCalls.delete(toolCallId);
5195
- } else if (data.event === "tool-error") {
5196
- const message = data.message ?? "unknown error";
5197
- pending.rejectOutput(new Error(message));
5198
- pending.resolveStatus("error");
5199
- pending.resolveError(message);
5200
- childToolCalls.delete(toolCallId);
5201
- }
5202
- }
5203
- }
5204
- if (event.method === "messages") {
5205
- const data = event.params.data;
5206
- if (data.event === "message-start") {
5207
- const eventsLog = StreamChannel.local();
5208
- const stream = new ChatModelStreamImpl(eventsLog);
5209
- eventsLog.push(data);
5210
- activeMessages.set(subagentName, {
5211
- stream,
5212
- eventsLog
5213
- });
5214
- logs.messagesLog.push(stream);
5215
- } else if (data.event === "message-finish") {
5216
- const active = activeMessages.get(subagentName);
5217
- if (active) {
5218
- active.eventsLog.push(data);
5219
- active.eventsLog.close();
5220
- activeMessages.delete(subagentName);
5221
- }
5222
- } else activeMessages.get(subagentName)?.eventsLog.push(data);
5223
- }
5224
- }
5225
- }
5226
- return true;
5227
- },
5228
- finalize() {
5229
- for (const pending of pendingByCallId.values()) pending.resolveOutput(void 0);
5230
- pendingByCallId.clear();
5231
- for (const pending of childToolCalls.values()) {
5232
- pending.resolveOutput(void 0);
5233
- pending.resolveStatus("finished");
5234
- pending.resolveError(void 0);
5235
- }
5236
- childToolCalls.clear();
5237
- for (const active of activeMessages.values()) active.eventsLog.fail(/* @__PURE__ */ new Error("run finalized before message completed"));
5238
- activeMessages.clear();
5239
- subagentsLog.close();
5240
- for (const logs of subagentsByName.values()) {
5241
- logs.toolCallsLog.close();
5242
- logs.messagesLog.close();
5243
- logs.nestedSubagentsLog.close();
5244
- }
5245
- },
5246
- fail(err) {
5247
- for (const pending of pendingByCallId.values()) pending.rejectOutput(err);
5248
- pendingByCallId.clear();
5249
- for (const pending of childToolCalls.values()) {
5250
- pending.rejectOutput(err);
5251
- pending.resolveStatus("error");
5252
- pending.resolveError(err instanceof Error ? err.message : String(err));
5253
- }
5254
- childToolCalls.clear();
5255
- for (const active of activeMessages.values()) active.eventsLog.fail(err);
5256
- activeMessages.clear();
5257
- subagentsLog.fail(err);
5258
- for (const logs of subagentsByName.values()) {
5259
- logs.toolCallsLog.fail(err);
5260
- logs.messagesLog.fail(err);
5261
- logs.nestedSubagentsLog.fail(err);
5262
- }
5263
- }
5264
- };
5265
- };
5266
- }
5267
- //#endregion
5268
5003
  //#region src/profiles/keys.ts
5269
5004
  /**
5270
5005
  * Normalize and validate a profile registry key.
@@ -5305,7 +5040,7 @@ function validateProfileKey(key) {
5305
5040
  * filesystem permissions.
5306
5041
  * - `SubAgentMiddleware` backs the `task` tool for subagent delegation.
5307
5042
  */
5308
- const REQUIRED_MIDDLEWARE_NAMES = new Set(["FilesystemMiddleware", "SubAgentMiddleware"]);
5043
+ const REQUIRED_MIDDLEWARE_NAMES = /* @__PURE__ */ new Set(["FilesystemMiddleware", "SubAgentMiddleware"]);
5309
5044
  /**
5310
5045
  * Type guard: is this a fully-constructed HarnessProfile (frozen with
5311
5046
  * Set fields) or raw options?
@@ -5392,7 +5127,7 @@ function createHarnessProfile(options = {}) {
5392
5127
  const EMPTY_HARNESS_PROFILE = createHarnessProfile();
5393
5128
  //#endregion
5394
5129
  //#region src/profiles/harness/serialization.ts
5395
- const POISONED_KEYS = new Set([
5130
+ const POISONED_KEYS = /* @__PURE__ */ new Set([
5396
5131
  "__proto__",
5397
5132
  "constructor",
5398
5133
  "prototype"
@@ -5968,7 +5703,7 @@ const BASE_AGENT_PROMPT = context`
5968
5703
 
5969
5704
  For longer tasks, provide brief progress updates at reasonable intervals — a concise sentence recapping what you've done and what's next.
5970
5705
  `;
5971
- const BUILTIN_TOOL_NAMES = new Set([
5706
+ const BUILTIN_TOOL_NAMES = /* @__PURE__ */ new Set([
5972
5707
  ...FILESYSTEM_TOOL_NAMES,
5973
5708
  ...ASYNC_TASK_TOOL_NAMES,
5974
5709
  "task",
@@ -6161,7 +5896,7 @@ function createDeepAgent(params = {}) {
6161
5896
  checkpointer,
6162
5897
  store,
6163
5898
  name,
6164
- streamTransformers: [createSubagentTransformer([]), ...streamTransformers]
5899
+ streamTransformers
6165
5900
  }).withConfig({
6166
5901
  recursionLimit: 1e4,
6167
5902
  metadata: {
@@ -7581,6 +7316,6 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
7581
7316
  }
7582
7317
  };
7583
7318
  //#endregion
7584
- export { DEFAULT_SUBAGENT_PROMPT as A, isSandboxBackend as B, MAX_SKILL_FILE_SIZE as C, filesValue as D, createMemoryMiddleware as E, createSubAgentMiddleware as F, checkEmptyContent as G, resolveBackend as H, createFilesystemMiddleware as I, performStringReplacement as J, getMimeType as K, CompositeBackend as L, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY as M, TASK_SYSTEM_PROMPT as N, createPatchToolCallsMiddleware as O, createSubAgent as P, StateBackend as R, MAX_SKILL_DESCRIPTION_LENGTH as S, createSkillsMiddleware as T, adaptBackendProtocol as U, isSandboxProtocol as V, adaptSandboxProtocol as W, createAsyncSubAgentMiddleware as _, createDeepAgent as a, createSummarizationMiddleware as b, generalPurposeSubagentConfigSchema as c, serializeProfile as d, EMPTY_HARNESS_PROFILE as f, ConfigurationError as g, createSubagentTransformer as h, StoreBackend as i, GENERAL_PURPOSE_SUBAGENT as j, DEFAULT_GENERAL_PURPOSE_DESCRIPTION as k, harnessProfileConfigSchema as l, REQUIRED_MIDDLEWARE_NAMES as m, BaseSandbox as n, getHarnessProfile as o, createHarnessProfile as p, isTextMimeType as q, ContextHubBackend as r, registerHarnessProfile as s, LangSmithSandbox as t, parseHarnessProfileConfig as u, isAsyncSubAgent as v, MAX_SKILL_NAME_LENGTH as w, createCompletionCallbackMiddleware as x, computeSummarizationDefaults as y, SandboxError as z };
7319
+ export { GENERAL_PURPOSE_SUBAGENT as A, isSandboxProtocol as B, MAX_SKILL_NAME_LENGTH as C, createPatchToolCallsMiddleware as D, filesValue as E, createFilesystemMiddleware as F, getMimeType as G, adaptBackendProtocol as H, CompositeBackend as I, isTextMimeType as K, StateBackend as L, TASK_SYSTEM_PROMPT as M, createSubAgent as N, DEFAULT_GENERAL_PURPOSE_DESCRIPTION as O, createSubAgentMiddleware as P, SandboxError as R, MAX_SKILL_FILE_SIZE as S, createMemoryMiddleware as T, adaptSandboxProtocol as U, resolveBackend as V, checkEmptyContent as W, isAsyncSubAgent as _, createDeepAgent as a, createCompletionCallbackMiddleware as b, generalPurposeSubagentConfigSchema as c, serializeProfile as d, EMPTY_HARNESS_PROFILE as f, createAsyncSubAgentMiddleware as g, ConfigurationError as h, StoreBackend as i, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY as j, DEFAULT_SUBAGENT_PROMPT as k, harnessProfileConfigSchema as l, REQUIRED_MIDDLEWARE_NAMES as m, BaseSandbox as n, getHarnessProfile as o, createHarnessProfile as p, performStringReplacement as q, ContextHubBackend as r, registerHarnessProfile as s, LangSmithSandbox as t, parseHarnessProfileConfig as u, computeSummarizationDefaults as v, createSkillsMiddleware as w, MAX_SKILL_DESCRIPTION_LENGTH as x, createSummarizationMiddleware as y, isSandboxBackend as z };
7585
7320
 
7586
- //# sourceMappingURL=langsmith-agEHKB-W.js.map
7321
+ //# sourceMappingURL=langsmith-wdF8zG42.js.map