deepagents 1.16.1 → 1.16.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/dist/{agent-BErEClzV.d.cts → agent-Dkx5TFNW.d.cts} +9 -7
- package/dist/{agent-DIft4yNY.d.ts → agent-NWukGdxN.d.ts} +9 -7
- package/dist/browser.cjs +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{langsmith-aH3Gwzii.cjs → langsmith-9ilIzQAp.cjs} +47 -28
- package/dist/langsmith-9ilIzQAp.cjs.map +1 -0
- package/dist/{langsmith-B1pbrx3y.js → langsmith-BsXCKa99.js} +48 -29
- package/dist/langsmith-BsXCKa99.js.map +1 -0
- package/dist/node.cjs +2 -2
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/dist/{src-B1Lvbh_S.js → src-DkSAwRPY.js} +2 -2
- package/dist/{src-B1Lvbh_S.js.map → src-DkSAwRPY.js.map} +1 -1
- package/dist/{src-B2jjteSM.cjs → src-nyyR-RIy.cjs} +2 -2
- package/dist/{src-B2jjteSM.cjs.map → src-nyyR-RIy.cjs.map} +1 -1
- package/package.json +3 -3
- package/dist/langsmith-B1pbrx3y.js.map +0 -1
- package/dist/langsmith-aH3Gwzii.cjs.map +0 -1
|
@@ -4,7 +4,7 @@ import { Command, Overwrite, REMOVE_ALL_MESSAGES, ReducedValue, StateSchema, get
|
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
import micromatch from "micromatch";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
|
-
import { AIMessage as AIMessage$1, BaseMessage, HumanMessage as HumanMessage$1, RemoveMessage, SystemMessage as SystemMessage$1, ToolMessage as ToolMessage$1, coerceMessageLikeToMessage, getBufferString } from "@langchain/core/messages";
|
|
7
|
+
import { AIMessage as AIMessage$1, BaseMessage, HumanMessage as HumanMessage$1, RemoveMessage, SystemMessage as SystemMessage$1, ToolMessage as ToolMessage$1, addNotificationMetadata, coerceMessageLikeToMessage, getBufferString, getNotificationMetadata } from "@langchain/core/messages";
|
|
8
8
|
import * as z$2 from "zod";
|
|
9
9
|
import { z as z$1 } from "zod";
|
|
10
10
|
import { initChatModel } from "langchain/chat_models/universal";
|
|
@@ -2578,11 +2578,11 @@ async function checkPermission(backend, rules, operation, path) {
|
|
|
2578
2578
|
return { path: canonical };
|
|
2579
2579
|
}
|
|
2580
2580
|
/**
|
|
2581
|
-
* Build an error {@link ToolMessage} for a
|
|
2582
|
-
* bare string would be wrapped as a `status: "success"`
|
|
2583
|
-
* merely starts with "Error:"; marking `status: "error"`
|
|
2584
|
-
* accurately so callers and the model can distinguish a
|
|
2585
|
-
* successful result.
|
|
2581
|
+
* Build an error {@link ToolMessage} for a denied path or a failed backend
|
|
2582
|
+
* operation. Returning a bare string would be wrapped as a `status: "success"`
|
|
2583
|
+
* message whose content merely starts with "Error:"; marking `status: "error"`
|
|
2584
|
+
* reports the failure accurately so callers and the model can distinguish a
|
|
2585
|
+
* real failure from a successful result.
|
|
2586
2586
|
*/
|
|
2587
2587
|
function toolError(runtime, toolName, message) {
|
|
2588
2588
|
return new ToolMessage({
|
|
@@ -3004,7 +3004,7 @@ function createWriteFileTool(backend, options) {
|
|
|
3004
3004
|
if (permission.error !== void 0) return toolError(runtime, "write_file", permission.error);
|
|
3005
3005
|
const { file_path, content } = input;
|
|
3006
3006
|
const result = await resolvedBackend.write(permission.path, content);
|
|
3007
|
-
if (result.error) return result.error;
|
|
3007
|
+
if (result.error) return toolError(runtime, "write_file", result.error);
|
|
3008
3008
|
const message = new ToolMessage({
|
|
3009
3009
|
content: `Successfully wrote to '${file_path}'`,
|
|
3010
3010
|
tool_call_id: runtime.toolCall?.id,
|
|
@@ -3036,7 +3036,7 @@ function createEditFileTool(backend, options) {
|
|
|
3036
3036
|
if (permission.error !== void 0) return toolError(runtime, "edit_file", permission.error);
|
|
3037
3037
|
const { file_path, old_string, new_string, replace_all = false } = input;
|
|
3038
3038
|
const result = await resolvedBackend.edit(permission.path, old_string, new_string, replace_all);
|
|
3039
|
-
if (result.error) return result.error;
|
|
3039
|
+
if (result.error) return toolError(runtime, "edit_file", result.error);
|
|
3040
3040
|
const message = new ToolMessage({
|
|
3041
3041
|
content: `Successfully replaced ${result.occurrences} occurrence(s) in '${file_path}'`,
|
|
3042
3042
|
tool_call_id: runtime.toolCall?.id,
|
|
@@ -3117,7 +3117,7 @@ function createGlobTool(backend, options) {
|
|
|
3117
3117
|
const permission = await checkPermission(resolvedBackend, permissions, "read", input.path ?? "/");
|
|
3118
3118
|
if (permission.error !== void 0) return toolError(runtime, "glob", permission.error);
|
|
3119
3119
|
const globResult = await resolvedBackend.glob(pattern, input.path === void 0 ? void 0 : permission.path);
|
|
3120
|
-
if (globResult.error) return `Error finding files: ${globResult.error}
|
|
3120
|
+
if (globResult.error) return toolError(runtime, "glob", `Error finding files: ${globResult.error}`);
|
|
3121
3121
|
const infos = await filterByPermissions(resolvedBackend, globResult.files ?? [], permissions, "read", (info) => info.path);
|
|
3122
3122
|
if (infos.length === 0) return `No files found matching pattern '${pattern}'`;
|
|
3123
3123
|
const result = truncateIfTooLong(infos.map((info) => info.path));
|
|
@@ -3144,7 +3144,7 @@ function createGrepTool(backend, options) {
|
|
|
3144
3144
|
if (permission.error !== void 0) return toolError(runtime, "grep", permission.error);
|
|
3145
3145
|
const maxCount = input.max_count ?? grepMaxCount;
|
|
3146
3146
|
const result = await resolvedBackend.grep(pattern, permission.path, glob, maxCount);
|
|
3147
|
-
if (result.error) return result.error;
|
|
3147
|
+
if (result.error) return toolError(runtime, "grep", result.error);
|
|
3148
3148
|
const matches = await filterByPermissions(resolvedBackend, result.matches ?? [], permissions, "read", (m) => m.path);
|
|
3149
3149
|
if (matches.length === 0) return `No matches found for pattern '${pattern}'`;
|
|
3150
3150
|
const truncated = truncateIfTooLong(formatGrepMatches(matches, output_mode));
|
|
@@ -7027,8 +7027,15 @@ function launchingAgent(config) {
|
|
|
7027
7027
|
if (metadata.parent_assistant_id) fallback.assistant_id = String(metadata.parent_assistant_id);
|
|
7028
7028
|
return fallback;
|
|
7029
7029
|
}
|
|
7030
|
-
/**
|
|
7030
|
+
/** `lc_source` of a task notification; its `lc_data` is the {@link TaskEvent}. */
|
|
7031
|
+
const NOTIFICATION_SOURCE = "async_subagent";
|
|
7032
|
+
/**
|
|
7033
|
+
* `additional_kwargs` key carrying a notification's {@link TaskEvent}; still written, and read when a message has no `async_subagent` event.
|
|
7034
|
+
*
|
|
7035
|
+
* @deprecated Read `getNotificationMetadata(message)?.data` where `source` is `"async_subagent"`.
|
|
7036
|
+
*/
|
|
7031
7037
|
const NOTIFICATION_KEY = "deepagents_notification";
|
|
7038
|
+
const NOTIFICATION_NOTE = "An async subagent task you started has an update. This is not a message from the user: don't treat it as their answer to any question.";
|
|
7032
7039
|
/** Results longer than this are cut in notifications, matching the limit for large tool results. */
|
|
7033
7040
|
const MAX_RESULT_CHARS = 8e4;
|
|
7034
7041
|
const NEXT_STEP = {
|
|
@@ -7070,23 +7077,24 @@ function resultBlocks(blocks) {
|
|
|
7070
7077
|
else if (MEDIA_BLOCK_TYPES.has(block.type)) kept.push({ ...block });
|
|
7071
7078
|
return kept;
|
|
7072
7079
|
}
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
*
|
|
7076
|
-
* The result keeps its own content blocks, so an image reaches the model as an image.
|
|
7077
|
-
*/
|
|
7078
|
-
function notificationContent(update) {
|
|
7079
|
-
const blocks = [notificationHeader(update)];
|
|
7080
|
+
function notificationBody(update) {
|
|
7081
|
+
const blocks = [taskHeader(update)];
|
|
7080
7082
|
if (update.result) blocks.push(textBlock("<result>\n"), ...resultBlocks(update.result), textBlock("\n</result>\n"));
|
|
7081
7083
|
const details = Object.fromEntries(["error", "interrupts"].filter((key) => update[key] !== void 0).map((key) => [key, update[key]]));
|
|
7082
7084
|
if (Object.keys(details).length > 0) blocks.push(textBlock(`<details>${escape(clip(JSON.stringify(details)))}</details>\n`));
|
|
7083
7085
|
blocks.push(textBlock(`</task-notification>\n${NEXT_STEP[update.status]}`));
|
|
7084
7086
|
return blocks;
|
|
7085
7087
|
}
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7088
|
+
/** `blocks` under the note and task header, labeled with `event`. */
|
|
7089
|
+
function labeled(blocks, event) {
|
|
7090
|
+
const header = textBlock(`${NOTIFICATION_NOTE}\n`);
|
|
7091
|
+
return addNotificationMetadata(new HumanMessage$1({ content: [header, ...blocks] }), {
|
|
7092
|
+
source: NOTIFICATION_SOURCE,
|
|
7093
|
+
data: { ...event }
|
|
7094
|
+
});
|
|
7095
|
+
}
|
|
7096
|
+
function taskHeader(event) {
|
|
7097
|
+
return textBlock(`<task-notification>\n<task-id>${escape(event.task_id)}</task-id>\n<agent-name>${escape(event.agent_name)}</agent-name>\n<status>${escape(event.status)}</status>\n`);
|
|
7090
7098
|
}
|
|
7091
7099
|
/**
|
|
7092
7100
|
* Reframe an earlier run's notification so the model doesn't think the queued follow-up finished.
|
|
@@ -7096,7 +7104,7 @@ An async subagent task you started has an update. This is not a message from the
|
|
|
7096
7104
|
function supersededNotificationContent(message, event) {
|
|
7097
7105
|
const content = message.content;
|
|
7098
7106
|
const closing = Array.isArray(content) ? content.at(-1) : void 0;
|
|
7099
|
-
return [...closing?.type === "text" && String(closing.text).startsWith("</task-notification>") ? content.slice(0, -1) : [
|
|
7107
|
+
return [...closing?.type === "text" && String(closing.text).startsWith("</task-notification>") ? content.slice(0, -1) : labeled([taskHeader(event)], event).content, textBlock("</task-notification>\nThis update is from an earlier run of this task, before your latest follow-up. It is not the result of the follow-up. Use `check_async_task` to get the current status of the task.")];
|
|
7100
7108
|
}
|
|
7101
7109
|
/** Describe a failure without its message, which can carry internals into the parent's conversation. */
|
|
7102
7110
|
function failureText(error) {
|
|
@@ -7149,21 +7157,32 @@ function finalContent(values) {
|
|
|
7149
7157
|
}
|
|
7150
7158
|
/** The task event a notification message carries, or `null` for any other message. */
|
|
7151
7159
|
function notificationEvent(message) {
|
|
7152
|
-
|
|
7160
|
+
if (message === void 0) return null;
|
|
7161
|
+
const metadata = getNotificationMetadata(message);
|
|
7162
|
+
const event = (metadata?.source === NOTIFICATION_SOURCE ? metadata.data : void 0) ?? message.additional_kwargs?.["deepagents_notification"];
|
|
7153
7163
|
return event && typeof event === "object" && !Array.isArray(event) ? event : null;
|
|
7154
7164
|
}
|
|
7155
|
-
/**
|
|
7156
|
-
function
|
|
7165
|
+
/** The {@link TaskEvent} fields of a task update. */
|
|
7166
|
+
function eventOf(update) {
|
|
7157
7167
|
const event = {
|
|
7158
7168
|
task_id: update.task_id,
|
|
7159
7169
|
agent_name: update.agent_name,
|
|
7160
7170
|
status: update.status
|
|
7161
7171
|
};
|
|
7162
7172
|
if (update.run_id) event.run_id = update.run_id;
|
|
7173
|
+
return event;
|
|
7174
|
+
}
|
|
7175
|
+
/** A task update as the message the parent's model sees, labeled with its {@link TaskEvent}. */
|
|
7176
|
+
function notificationMessage(update) {
|
|
7177
|
+
const event = eventOf(update);
|
|
7178
|
+
const message = labeled(notificationBody(update), event);
|
|
7163
7179
|
return {
|
|
7164
7180
|
role: "user",
|
|
7165
|
-
content:
|
|
7166
|
-
additional_kwargs: {
|
|
7181
|
+
content: message.content,
|
|
7182
|
+
additional_kwargs: {
|
|
7183
|
+
...message.additional_kwargs,
|
|
7184
|
+
[NOTIFICATION_KEY]: event
|
|
7185
|
+
}
|
|
7167
7186
|
};
|
|
7168
7187
|
}
|
|
7169
7188
|
/** Parent thread statuses a notification run can start on: neither running nor waiting for a human. */
|
|
@@ -10823,4 +10842,4 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
10823
10842
|
//#endregion
|
|
10824
10843
|
export { adaptSandboxProtocol as $, filesValue as A, createFilesystemMiddleware as B, MAX_SKILL_FILE_SIZE as C, skillsMetadataValue as D, pinnedSkillsValue as E, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY as F, scrubUnsupportedMultimodalContent as G, MULTIMODAL_BLOCK_TYPES as H, createSubAgent as I, applyGrepMaxCount as J, StateBackend as K, createSubAgentMiddleware as L, DEFAULT_GENERAL_PURPOSE_DESCRIPTION as M, DEFAULT_SUBAGENT_PROMPT as N, ConfigurationError as O, GENERAL_PURPOSE_SUBAGENT as P, adaptBackendProtocol as Q, computeSummarizationDefaults as R, MAX_SKILL_DESCRIPTION_LENGTH as S, createSkillsMiddleware as T, createUnsupportedContentMiddleware as U, CompositeBackend as V, multimodalBlockSupported as W, isSandboxProtocol as X, isSandboxBackend as Y, resolveBackend as Z, createHarnessProfile as _, ASYNC_TASK_SYSTEM_PROMPT as a, setRealpath as at, isAsyncSubAgent as b, TASK_SYSTEM_PROMPT as c, registerHarnessProfile as d, checkEmptyContent as et, generalPurposeSubagentConfigSchema as f, EMPTY_HARNESS_PROFILE as g, serializeProfile as h, StoreBackend as i, performStringReplacement as it, createPatchToolCallsMiddleware as j, createMemoryMiddleware as k, createDeepAgent as l, parseHarnessProfileConfig as m, BaseSandbox as n, isTextMimeType as nt, BASE_AGENT_PROMPT as o, harnessProfileConfigSchema as p, SandboxError as q, ContextHubBackend as r, normalizeReadPagination as rt, EXECUTION_SYSTEM_PROMPT as s, LangSmithSandbox as t, getMimeType as tt, getHarnessProfile as u, REQUIRED_MIDDLEWARE_NAMES as v, MAX_SKILL_NAME_LENGTH as w, createCompletionCallbackMiddleware as x, createAsyncSubAgentMiddleware as y, createSummarizationMiddleware as z };
|
|
10825
10844
|
|
|
10826
|
-
//# sourceMappingURL=langsmith-
|
|
10845
|
+
//# sourceMappingURL=langsmith-BsXCKa99.js.map
|