deepagents 1.16.0 → 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-ICdNmGjy.d.cts → agent-Dkx5TFNW.d.cts} +23 -7
- package/dist/{agent-ByjpS5OX.d.ts → agent-NWukGdxN.d.ts} +23 -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-Bf4pcnIO.cjs → langsmith-9ilIzQAp.cjs} +133 -51
- package/dist/langsmith-9ilIzQAp.cjs.map +1 -0
- package/dist/{langsmith-WS8VrZxE.js → langsmith-BsXCKa99.js} +134 -52
- 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-Wn1LjkCI.js → src-DkSAwRPY.js} +2 -2
- package/dist/{src-Wn1LjkCI.js.map → src-DkSAwRPY.js.map} +1 -1
- package/dist/{src-OuZaf_eC.cjs → src-nyyR-RIy.cjs} +2 -2
- package/dist/{src-OuZaf_eC.cjs.map → src-nyyR-RIy.cjs.map} +1 -1
- package/package.json +3 -3
- package/dist/langsmith-Bf4pcnIO.cjs.map +0 -1
- package/dist/langsmith-WS8VrZxE.js.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";
|
|
@@ -808,6 +808,45 @@ function trimTrailingSlashes$2(path) {
|
|
|
808
808
|
}
|
|
809
809
|
const PREGEL_SEND_KEY = "__pregel_send";
|
|
810
810
|
const PREGEL_READ_KEY = "__pregel_read";
|
|
811
|
+
function isBase64Encoded(data) {
|
|
812
|
+
return !isFileDataV1(data) && data.encoding === "base64" && typeof data.content === "string";
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Store binary content as base64 text. State is checkpointed as JSON, which
|
|
816
|
+
* turns a Uint8Array into an object of numeric keys that fails the files
|
|
817
|
+
* schema on the next run.
|
|
818
|
+
*/
|
|
819
|
+
function toStoredFileData(data) {
|
|
820
|
+
if (!isFileDataBinary(data)) return data;
|
|
821
|
+
return {
|
|
822
|
+
...data,
|
|
823
|
+
content: Buffer.from(data.content).toString("base64"),
|
|
824
|
+
encoding: "base64"
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
/** Decode base64-stored content so readers keep getting Uint8Array bytes. */
|
|
828
|
+
function fromStoredFileData(data) {
|
|
829
|
+
if (!isBase64Encoded(data)) return data;
|
|
830
|
+
return {
|
|
831
|
+
content: new Uint8Array(Buffer.from(data.content, "base64")),
|
|
832
|
+
mimeType: data.mimeType,
|
|
833
|
+
created_at: data.created_at,
|
|
834
|
+
modified_at: data.modified_at
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
function fileSize(data) {
|
|
838
|
+
if (isFileDataV1(data)) return data.content.join("\n").length;
|
|
839
|
+
if (typeof data.content !== "string") return data.content.byteLength;
|
|
840
|
+
return data.encoding === "base64" ? Buffer.byteLength(data.content, "base64") : data.content.length;
|
|
841
|
+
}
|
|
842
|
+
/** Strict UTF-8 decode; undefined when the bytes are not valid UTF-8. */
|
|
843
|
+
function decodeUtf8(bytes) {
|
|
844
|
+
try {
|
|
845
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
846
|
+
} catch {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
811
850
|
/**
|
|
812
851
|
* Backend that stores files in agent state (ephemeral).
|
|
813
852
|
*
|
|
@@ -895,11 +934,10 @@ var StateBackend = class {
|
|
|
895
934
|
subdirs.add(normalizedPath + subdirName + "/");
|
|
896
935
|
continue;
|
|
897
936
|
}
|
|
898
|
-
const size = isFileDataV1(fd) ? fd.content.join("\n").length : isFileDataBinary(fd) ? fd.content.byteLength : fd.content.length;
|
|
899
937
|
infos.push({
|
|
900
938
|
path: k,
|
|
901
939
|
is_dir: false,
|
|
902
|
-
size,
|
|
940
|
+
size: fileSize(fd),
|
|
903
941
|
modified_at: fd.modified_at
|
|
904
942
|
});
|
|
905
943
|
}
|
|
@@ -926,7 +964,7 @@ var StateBackend = class {
|
|
|
926
964
|
read(filePath, offset = 0, limit = 500) {
|
|
927
965
|
const fileData = this.files[filePath];
|
|
928
966
|
if (!fileData) return { error: `File '${filePath}' not found` };
|
|
929
|
-
const fileDataV2 = migrateToFileDataV2(fileData, filePath);
|
|
967
|
+
const fileDataV2 = migrateToFileDataV2(fromStoredFileData(fileData), filePath);
|
|
930
968
|
if (!isTextMimeType(fileDataV2.mimeType)) return {
|
|
931
969
|
content: fileDataV2.content,
|
|
932
970
|
mimeType: fileDataV2.mimeType
|
|
@@ -959,15 +997,19 @@ var StateBackend = class {
|
|
|
959
997
|
readRaw(filePath) {
|
|
960
998
|
const fileData = this.files[filePath];
|
|
961
999
|
if (!fileData) return { error: `File '${filePath}' not found` };
|
|
962
|
-
return { data: fileData };
|
|
1000
|
+
return { data: fromStoredFileData(fileData) };
|
|
963
1001
|
}
|
|
964
1002
|
/**
|
|
965
1003
|
* Write content to a file, creating it or overwriting it if it already exists.
|
|
966
1004
|
* Returns WriteResult with filesUpdate to update LangGraph state.
|
|
967
1005
|
*/
|
|
968
1006
|
write(filePath, content) {
|
|
969
|
-
const
|
|
970
|
-
const
|
|
1007
|
+
const stored = this.files[filePath];
|
|
1008
|
+
const existing = stored && isBase64Encoded(stored) ? {
|
|
1009
|
+
...stored,
|
|
1010
|
+
mimeType: getMimeType(filePath)
|
|
1011
|
+
} : stored;
|
|
1012
|
+
const newFileData = toStoredFileData(createWriteFileData(filePath, content, this.fileFormat, existing));
|
|
971
1013
|
const update = { [filePath]: newFileData };
|
|
972
1014
|
if (!this.isLegacy) {
|
|
973
1015
|
this.sendFilesUpdate(update);
|
|
@@ -1006,7 +1048,7 @@ var StateBackend = class {
|
|
|
1006
1048
|
edit(filePath, oldString, newString, replaceAll = false) {
|
|
1007
1049
|
const fileData = this.files[filePath];
|
|
1008
1050
|
if (!fileData) return { error: `Error: File '${filePath}' not found` };
|
|
1009
|
-
const result = performStringReplacement(fileDataToString(fileData), oldString, newString, replaceAll);
|
|
1051
|
+
const result = performStringReplacement(fileDataToString(fromStoredFileData(fileData)), oldString, newString, replaceAll);
|
|
1010
1052
|
if (typeof result === "string") return { error: result };
|
|
1011
1053
|
const [newContent, occurrences] = result;
|
|
1012
1054
|
const newFileData = updateFileData(fileData, newContent);
|
|
@@ -1046,11 +1088,10 @@ var StateBackend = class {
|
|
|
1046
1088
|
const infos = [];
|
|
1047
1089
|
for (const p of paths) {
|
|
1048
1090
|
const fd = files[p];
|
|
1049
|
-
const size = fd ? isFileDataV1(fd) ? fd.content.join("\n").length : isFileDataBinary(fd) ? fd.content.byteLength : fd.content.length : 0;
|
|
1050
1091
|
infos.push({
|
|
1051
1092
|
path: p,
|
|
1052
1093
|
is_dir: false,
|
|
1053
|
-
size,
|
|
1094
|
+
size: fd ? fileSize(fd) : 0,
|
|
1054
1095
|
modified_at: fd?.modified_at || ""
|
|
1055
1096
|
});
|
|
1056
1097
|
}
|
|
@@ -1069,9 +1110,7 @@ var StateBackend = class {
|
|
|
1069
1110
|
const responses = [];
|
|
1070
1111
|
const updates = {};
|
|
1071
1112
|
for (const [path, content] of files) try {
|
|
1072
|
-
|
|
1073
|
-
if (this.fileFormat === "v2" && !isTextMimeType(mimeType)) updates[path] = createFileData(content, void 0, "v2", mimeType);
|
|
1074
|
-
else updates[path] = createFileData(new TextDecoder().decode(content), void 0, this.fileFormat, mimeType);
|
|
1113
|
+
updates[path] = toStoredFileData(this.createUploadFileData(path, content));
|
|
1075
1114
|
responses.push({
|
|
1076
1115
|
path,
|
|
1077
1116
|
error: null
|
|
@@ -1091,6 +1130,20 @@ var StateBackend = class {
|
|
|
1091
1130
|
return result;
|
|
1092
1131
|
}
|
|
1093
1132
|
/**
|
|
1133
|
+
* Build FileData for an uploaded file.
|
|
1134
|
+
*
|
|
1135
|
+
* In v2, bytes at a binary MIME type stay binary, and bytes at a text MIME
|
|
1136
|
+
* type that are not valid UTF-8 are kept as application/octet-stream rather
|
|
1137
|
+
* than lossily decoded. v1 cannot hold binary, so it always decodes as text.
|
|
1138
|
+
*/
|
|
1139
|
+
createUploadFileData(path, content) {
|
|
1140
|
+
const mimeType = getMimeType(path);
|
|
1141
|
+
if (this.fileFormat === "v1") return createFileData(new TextDecoder().decode(content), void 0, "v1", mimeType);
|
|
1142
|
+
if (!isTextMimeType(mimeType)) return createFileData(content, void 0, "v2", mimeType);
|
|
1143
|
+
const text = decodeUtf8(content);
|
|
1144
|
+
return text === void 0 ? createFileData(content, void 0, "v2", "application/octet-stream") : createFileData(text, void 0, "v2", mimeType);
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1094
1147
|
* Download multiple files.
|
|
1095
1148
|
*
|
|
1096
1149
|
* @param paths - List of file paths to download
|
|
@@ -1109,7 +1162,7 @@ var StateBackend = class {
|
|
|
1109
1162
|
});
|
|
1110
1163
|
continue;
|
|
1111
1164
|
}
|
|
1112
|
-
const fileDataV2 = migrateToFileDataV2(fileData, path);
|
|
1165
|
+
const fileDataV2 = migrateToFileDataV2(fromStoredFileData(fileData), path);
|
|
1113
1166
|
if (typeof fileDataV2.content === "string") {
|
|
1114
1167
|
const content = new TextEncoder().encode(fileDataV2.content);
|
|
1115
1168
|
responses.push({
|
|
@@ -2352,30 +2405,39 @@ function extractTextFromMessage(message) {
|
|
|
2352
2405
|
if (Array.isArray(message.content)) return message.content.filter((block) => block.type === "text" && typeof block.text === "string").map((block) => block.text).join("\n");
|
|
2353
2406
|
return String(message.content);
|
|
2354
2407
|
}
|
|
2408
|
+
/**
|
|
2409
|
+
* Whether a content block is an image. Tool-result eviction skips images when
|
|
2410
|
+
* sizing a result and keeps them when evicting it: base64 length says little
|
|
2411
|
+
* about what a provider charges for an image.
|
|
2412
|
+
*/
|
|
2413
|
+
function isImageBlock(block) {
|
|
2414
|
+
return typeof block === "object" && block !== null && "type" in block && (block.type === "image" || block.type === "image_url");
|
|
2415
|
+
}
|
|
2355
2416
|
function stringifyToolContent(content) {
|
|
2356
2417
|
if (typeof content === "string") return content;
|
|
2357
|
-
if (Array.isArray(content)) return content.map((block) => {
|
|
2418
|
+
if (Array.isArray(content)) return content.filter((block) => !isImageBlock(block)).map((block) => {
|
|
2358
2419
|
if (typeof block === "object" && block !== null && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string") return block.text;
|
|
2359
2420
|
return JSON.stringify(block);
|
|
2360
2421
|
}).join("\n");
|
|
2361
2422
|
return String(content);
|
|
2362
2423
|
}
|
|
2363
2424
|
/**
|
|
2364
|
-
* Build replacement content for an evicted
|
|
2425
|
+
* Build replacement content for an evicted message, preserving the blocks `keep` selects.
|
|
2365
2426
|
*
|
|
2366
2427
|
* For plain string content, returns the replacement text directly. For list content
|
|
2367
|
-
* with mixed block types (e.g., text + image), replaces
|
|
2368
|
-
* text block containing the replacement text while keeping
|
|
2428
|
+
* with mixed block types (e.g., text + image), replaces the other blocks with a single
|
|
2429
|
+
* text block containing the replacement text while keeping the selected blocks intact.
|
|
2430
|
+
* By default every non-text block is kept.
|
|
2369
2431
|
*/
|
|
2370
|
-
function
|
|
2432
|
+
function buildEvictedContent(message, replacementText, keep = (block) => block.type !== "text") {
|
|
2371
2433
|
if (typeof message.content === "string") return replacementText;
|
|
2372
2434
|
if (Array.isArray(message.content)) {
|
|
2373
|
-
const
|
|
2374
|
-
if (
|
|
2435
|
+
const keptBlocks = message.content.filter((block) => typeof block === "object" && block !== null && keep(block));
|
|
2436
|
+
if (keptBlocks.length === 0) return replacementText;
|
|
2375
2437
|
return [{
|
|
2376
2438
|
type: "text",
|
|
2377
2439
|
text: replacementText
|
|
2378
|
-
}, ...
|
|
2440
|
+
}, ...keptBlocks];
|
|
2379
2441
|
}
|
|
2380
2442
|
return replacementText;
|
|
2381
2443
|
}
|
|
@@ -2388,7 +2450,7 @@ function buildEvictedHumanContent(message, replacementText) {
|
|
|
2388
2450
|
*/
|
|
2389
2451
|
function buildTruncatedHumanMessage(message, filePath) {
|
|
2390
2452
|
const contentSample = createContentPreview(extractTextFromMessage(message));
|
|
2391
|
-
const evictedContent =
|
|
2453
|
+
const evictedContent = buildEvictedContent(message, TOO_LARGE_HUMAN_MSG.replace("{file_path}", filePath).replace("{content_sample}", contentSample));
|
|
2392
2454
|
return new HumanMessage({
|
|
2393
2455
|
content: evictedContent,
|
|
2394
2456
|
id: message.id,
|
|
@@ -2428,6 +2490,7 @@ const FileDataV1Schema = z.object({
|
|
|
2428
2490
|
const FileDataV2Schema = z.object({
|
|
2429
2491
|
content: z.union([z.string(), z.instanceof(Uint8Array)]),
|
|
2430
2492
|
mimeType: z.string(),
|
|
2493
|
+
encoding: z.enum(["utf-8", "base64"]).optional(),
|
|
2431
2494
|
created_at: z.string(),
|
|
2432
2495
|
modified_at: z.string()
|
|
2433
2496
|
});
|
|
@@ -2515,11 +2578,11 @@ async function checkPermission(backend, rules, operation, path) {
|
|
|
2515
2578
|
return { path: canonical };
|
|
2516
2579
|
}
|
|
2517
2580
|
/**
|
|
2518
|
-
* Build an error {@link ToolMessage} for a
|
|
2519
|
-
* bare string would be wrapped as a `status: "success"`
|
|
2520
|
-
* merely starts with "Error:"; marking `status: "error"`
|
|
2521
|
-
* accurately so callers and the model can distinguish a
|
|
2522
|
-
* 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.
|
|
2523
2586
|
*/
|
|
2524
2587
|
function toolError(runtime, toolName, message) {
|
|
2525
2588
|
return new ToolMessage({
|
|
@@ -2941,7 +3004,7 @@ function createWriteFileTool(backend, options) {
|
|
|
2941
3004
|
if (permission.error !== void 0) return toolError(runtime, "write_file", permission.error);
|
|
2942
3005
|
const { file_path, content } = input;
|
|
2943
3006
|
const result = await resolvedBackend.write(permission.path, content);
|
|
2944
|
-
if (result.error) return result.error;
|
|
3007
|
+
if (result.error) return toolError(runtime, "write_file", result.error);
|
|
2945
3008
|
const message = new ToolMessage({
|
|
2946
3009
|
content: `Successfully wrote to '${file_path}'`,
|
|
2947
3010
|
tool_call_id: runtime.toolCall?.id,
|
|
@@ -2973,7 +3036,7 @@ function createEditFileTool(backend, options) {
|
|
|
2973
3036
|
if (permission.error !== void 0) return toolError(runtime, "edit_file", permission.error);
|
|
2974
3037
|
const { file_path, old_string, new_string, replace_all = false } = input;
|
|
2975
3038
|
const result = await resolvedBackend.edit(permission.path, old_string, new_string, replace_all);
|
|
2976
|
-
if (result.error) return result.error;
|
|
3039
|
+
if (result.error) return toolError(runtime, "edit_file", result.error);
|
|
2977
3040
|
const message = new ToolMessage({
|
|
2978
3041
|
content: `Successfully replaced ${result.occurrences} occurrence(s) in '${file_path}'`,
|
|
2979
3042
|
tool_call_id: runtime.toolCall?.id,
|
|
@@ -3054,7 +3117,7 @@ function createGlobTool(backend, options) {
|
|
|
3054
3117
|
const permission = await checkPermission(resolvedBackend, permissions, "read", input.path ?? "/");
|
|
3055
3118
|
if (permission.error !== void 0) return toolError(runtime, "glob", permission.error);
|
|
3056
3119
|
const globResult = await resolvedBackend.glob(pattern, input.path === void 0 ? void 0 : permission.path);
|
|
3057
|
-
if (globResult.error) return `Error finding files: ${globResult.error}
|
|
3120
|
+
if (globResult.error) return toolError(runtime, "glob", `Error finding files: ${globResult.error}`);
|
|
3058
3121
|
const infos = await filterByPermissions(resolvedBackend, globResult.files ?? [], permissions, "read", (info) => info.path);
|
|
3059
3122
|
if (infos.length === 0) return `No files found matching pattern '${pattern}'`;
|
|
3060
3123
|
const result = truncateIfTooLong(infos.map((info) => info.path));
|
|
@@ -3081,7 +3144,7 @@ function createGrepTool(backend, options) {
|
|
|
3081
3144
|
if (permission.error !== void 0) return toolError(runtime, "grep", permission.error);
|
|
3082
3145
|
const maxCount = input.max_count ?? grepMaxCount;
|
|
3083
3146
|
const result = await resolvedBackend.grep(pattern, permission.path, glob, maxCount);
|
|
3084
|
-
if (result.error) return result.error;
|
|
3147
|
+
if (result.error) return toolError(runtime, "grep", result.error);
|
|
3085
3148
|
const matches = await filterByPermissions(resolvedBackend, result.matches ?? [], permissions, "read", (m) => m.path);
|
|
3086
3149
|
if (matches.length === 0) return `No matches found for pattern '${pattern}'`;
|
|
3087
3150
|
const truncated = truncateIfTooLong(formatGrepMatches(matches, output_mode));
|
|
@@ -3314,7 +3377,7 @@ function createFilesystemMiddleware(options = {}) {
|
|
|
3314
3377
|
const replacementText = writeResult.error ? `Tool result too large, but the result could not be saved to the filesystem: ${writeResult.error}` : TOO_LARGE_TOOL_MSG.replace("{tool_call_id}", msg.tool_call_id.length > 32 ? `${msg.tool_call_id.slice(0, 32)}...` : msg.tool_call_id).replace("{file_path}", evictPath).replace("{content_sample}", contentSample);
|
|
3315
3378
|
return {
|
|
3316
3379
|
message: new ToolMessage({
|
|
3317
|
-
content: replacementText,
|
|
3380
|
+
content: buildEvictedContent(msg, replacementText, isImageBlock),
|
|
3318
3381
|
tool_call_id: msg.tool_call_id,
|
|
3319
3382
|
name: msg.name,
|
|
3320
3383
|
id: msg.id,
|
|
@@ -6964,8 +7027,15 @@ function launchingAgent(config) {
|
|
|
6964
7027
|
if (metadata.parent_assistant_id) fallback.assistant_id = String(metadata.parent_assistant_id);
|
|
6965
7028
|
return fallback;
|
|
6966
7029
|
}
|
|
6967
|
-
/**
|
|
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
|
+
*/
|
|
6968
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.";
|
|
6969
7039
|
/** Results longer than this are cut in notifications, matching the limit for large tool results. */
|
|
6970
7040
|
const MAX_RESULT_CHARS = 8e4;
|
|
6971
7041
|
const NEXT_STEP = {
|
|
@@ -7007,23 +7077,24 @@ function resultBlocks(blocks) {
|
|
|
7007
7077
|
else if (MEDIA_BLOCK_TYPES.has(block.type)) kept.push({ ...block });
|
|
7008
7078
|
return kept;
|
|
7009
7079
|
}
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
*
|
|
7013
|
-
* The result keeps its own content blocks, so an image reaches the model as an image.
|
|
7014
|
-
*/
|
|
7015
|
-
function notificationContent(update) {
|
|
7016
|
-
const blocks = [notificationHeader(update)];
|
|
7080
|
+
function notificationBody(update) {
|
|
7081
|
+
const blocks = [taskHeader(update)];
|
|
7017
7082
|
if (update.result) blocks.push(textBlock("<result>\n"), ...resultBlocks(update.result), textBlock("\n</result>\n"));
|
|
7018
7083
|
const details = Object.fromEntries(["error", "interrupts"].filter((key) => update[key] !== void 0).map((key) => [key, update[key]]));
|
|
7019
7084
|
if (Object.keys(details).length > 0) blocks.push(textBlock(`<details>${escape(clip(JSON.stringify(details)))}</details>\n`));
|
|
7020
7085
|
blocks.push(textBlock(`</task-notification>\n${NEXT_STEP[update.status]}`));
|
|
7021
7086
|
return blocks;
|
|
7022
7087
|
}
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
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`);
|
|
7027
7098
|
}
|
|
7028
7099
|
/**
|
|
7029
7100
|
* Reframe an earlier run's notification so the model doesn't think the queued follow-up finished.
|
|
@@ -7033,7 +7104,7 @@ An async subagent task you started has an update. This is not a message from the
|
|
|
7033
7104
|
function supersededNotificationContent(message, event) {
|
|
7034
7105
|
const content = message.content;
|
|
7035
7106
|
const closing = Array.isArray(content) ? content.at(-1) : void 0;
|
|
7036
|
-
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.")];
|
|
7037
7108
|
}
|
|
7038
7109
|
/** Describe a failure without its message, which can carry internals into the parent's conversation. */
|
|
7039
7110
|
function failureText(error) {
|
|
@@ -7086,21 +7157,32 @@ function finalContent(values) {
|
|
|
7086
7157
|
}
|
|
7087
7158
|
/** The task event a notification message carries, or `null` for any other message. */
|
|
7088
7159
|
function notificationEvent(message) {
|
|
7089
|
-
|
|
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"];
|
|
7090
7163
|
return event && typeof event === "object" && !Array.isArray(event) ? event : null;
|
|
7091
7164
|
}
|
|
7092
|
-
/**
|
|
7093
|
-
function
|
|
7165
|
+
/** The {@link TaskEvent} fields of a task update. */
|
|
7166
|
+
function eventOf(update) {
|
|
7094
7167
|
const event = {
|
|
7095
7168
|
task_id: update.task_id,
|
|
7096
7169
|
agent_name: update.agent_name,
|
|
7097
7170
|
status: update.status
|
|
7098
7171
|
};
|
|
7099
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);
|
|
7100
7179
|
return {
|
|
7101
7180
|
role: "user",
|
|
7102
|
-
content:
|
|
7103
|
-
additional_kwargs: {
|
|
7181
|
+
content: message.content,
|
|
7182
|
+
additional_kwargs: {
|
|
7183
|
+
...message.additional_kwargs,
|
|
7184
|
+
[NOTIFICATION_KEY]: event
|
|
7185
|
+
}
|
|
7104
7186
|
};
|
|
7105
7187
|
}
|
|
7106
7188
|
/** Parent thread statuses a notification run can start on: neither running nor waiting for a human. */
|
|
@@ -10760,4 +10842,4 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
10760
10842
|
//#endregion
|
|
10761
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 };
|
|
10762
10844
|
|
|
10763
|
-
//# sourceMappingURL=langsmith-
|
|
10845
|
+
//# sourceMappingURL=langsmith-BsXCKa99.js.map
|