deepagents 1.16.0 → 1.16.1
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-BErEClzV.d.cts} +15 -1
- package/dist/{agent-ByjpS5OX.d.ts → agent-DIft4yNY.d.ts} +15 -1
- 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-WS8VrZxE.js → langsmith-B1pbrx3y.js} +87 -24
- package/dist/langsmith-B1pbrx3y.js.map +1 -0
- package/dist/{langsmith-Bf4pcnIO.cjs → langsmith-aH3Gwzii.cjs} +87 -24
- package/dist/langsmith-aH3Gwzii.cjs.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-B1Lvbh_S.js} +2 -2
- package/dist/{src-Wn1LjkCI.js.map → src-B1Lvbh_S.js.map} +1 -1
- package/dist/{src-OuZaf_eC.cjs → src-B2jjteSM.cjs} +2 -2
- package/dist/{src-OuZaf_eC.cjs.map → src-B2jjteSM.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/langsmith-Bf4pcnIO.cjs.map +0 -1
- package/dist/langsmith-WS8VrZxE.js.map +0 -1
|
@@ -832,6 +832,45 @@ function trimTrailingSlashes$2(path) {
|
|
|
832
832
|
}
|
|
833
833
|
const PREGEL_SEND_KEY = "__pregel_send";
|
|
834
834
|
const PREGEL_READ_KEY = "__pregel_read";
|
|
835
|
+
function isBase64Encoded(data) {
|
|
836
|
+
return !isFileDataV1(data) && data.encoding === "base64" && typeof data.content === "string";
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Store binary content as base64 text. State is checkpointed as JSON, which
|
|
840
|
+
* turns a Uint8Array into an object of numeric keys that fails the files
|
|
841
|
+
* schema on the next run.
|
|
842
|
+
*/
|
|
843
|
+
function toStoredFileData(data) {
|
|
844
|
+
if (!isFileDataBinary(data)) return data;
|
|
845
|
+
return {
|
|
846
|
+
...data,
|
|
847
|
+
content: Buffer.from(data.content).toString("base64"),
|
|
848
|
+
encoding: "base64"
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
/** Decode base64-stored content so readers keep getting Uint8Array bytes. */
|
|
852
|
+
function fromStoredFileData(data) {
|
|
853
|
+
if (!isBase64Encoded(data)) return data;
|
|
854
|
+
return {
|
|
855
|
+
content: new Uint8Array(Buffer.from(data.content, "base64")),
|
|
856
|
+
mimeType: data.mimeType,
|
|
857
|
+
created_at: data.created_at,
|
|
858
|
+
modified_at: data.modified_at
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function fileSize(data) {
|
|
862
|
+
if (isFileDataV1(data)) return data.content.join("\n").length;
|
|
863
|
+
if (typeof data.content !== "string") return data.content.byteLength;
|
|
864
|
+
return data.encoding === "base64" ? Buffer.byteLength(data.content, "base64") : data.content.length;
|
|
865
|
+
}
|
|
866
|
+
/** Strict UTF-8 decode; undefined when the bytes are not valid UTF-8. */
|
|
867
|
+
function decodeUtf8(bytes) {
|
|
868
|
+
try {
|
|
869
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
870
|
+
} catch {
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
835
874
|
/**
|
|
836
875
|
* Backend that stores files in agent state (ephemeral).
|
|
837
876
|
*
|
|
@@ -919,11 +958,10 @@ var StateBackend = class {
|
|
|
919
958
|
subdirs.add(normalizedPath + subdirName + "/");
|
|
920
959
|
continue;
|
|
921
960
|
}
|
|
922
|
-
const size = isFileDataV1(fd) ? fd.content.join("\n").length : isFileDataBinary(fd) ? fd.content.byteLength : fd.content.length;
|
|
923
961
|
infos.push({
|
|
924
962
|
path: k,
|
|
925
963
|
is_dir: false,
|
|
926
|
-
size,
|
|
964
|
+
size: fileSize(fd),
|
|
927
965
|
modified_at: fd.modified_at
|
|
928
966
|
});
|
|
929
967
|
}
|
|
@@ -950,7 +988,7 @@ var StateBackend = class {
|
|
|
950
988
|
read(filePath, offset = 0, limit = 500) {
|
|
951
989
|
const fileData = this.files[filePath];
|
|
952
990
|
if (!fileData) return { error: `File '${filePath}' not found` };
|
|
953
|
-
const fileDataV2 = migrateToFileDataV2(fileData, filePath);
|
|
991
|
+
const fileDataV2 = migrateToFileDataV2(fromStoredFileData(fileData), filePath);
|
|
954
992
|
if (!isTextMimeType(fileDataV2.mimeType)) return {
|
|
955
993
|
content: fileDataV2.content,
|
|
956
994
|
mimeType: fileDataV2.mimeType
|
|
@@ -983,15 +1021,19 @@ var StateBackend = class {
|
|
|
983
1021
|
readRaw(filePath) {
|
|
984
1022
|
const fileData = this.files[filePath];
|
|
985
1023
|
if (!fileData) return { error: `File '${filePath}' not found` };
|
|
986
|
-
return { data: fileData };
|
|
1024
|
+
return { data: fromStoredFileData(fileData) };
|
|
987
1025
|
}
|
|
988
1026
|
/**
|
|
989
1027
|
* Write content to a file, creating it or overwriting it if it already exists.
|
|
990
1028
|
* Returns WriteResult with filesUpdate to update LangGraph state.
|
|
991
1029
|
*/
|
|
992
1030
|
write(filePath, content) {
|
|
993
|
-
const
|
|
994
|
-
const
|
|
1031
|
+
const stored = this.files[filePath];
|
|
1032
|
+
const existing = stored && isBase64Encoded(stored) ? {
|
|
1033
|
+
...stored,
|
|
1034
|
+
mimeType: getMimeType(filePath)
|
|
1035
|
+
} : stored;
|
|
1036
|
+
const newFileData = toStoredFileData(createWriteFileData(filePath, content, this.fileFormat, existing));
|
|
995
1037
|
const update = { [filePath]: newFileData };
|
|
996
1038
|
if (!this.isLegacy) {
|
|
997
1039
|
this.sendFilesUpdate(update);
|
|
@@ -1030,7 +1072,7 @@ var StateBackend = class {
|
|
|
1030
1072
|
edit(filePath, oldString, newString, replaceAll = false) {
|
|
1031
1073
|
const fileData = this.files[filePath];
|
|
1032
1074
|
if (!fileData) return { error: `Error: File '${filePath}' not found` };
|
|
1033
|
-
const result = performStringReplacement(fileDataToString(fileData), oldString, newString, replaceAll);
|
|
1075
|
+
const result = performStringReplacement(fileDataToString(fromStoredFileData(fileData)), oldString, newString, replaceAll);
|
|
1034
1076
|
if (typeof result === "string") return { error: result };
|
|
1035
1077
|
const [newContent, occurrences] = result;
|
|
1036
1078
|
const newFileData = updateFileData(fileData, newContent);
|
|
@@ -1070,11 +1112,10 @@ var StateBackend = class {
|
|
|
1070
1112
|
const infos = [];
|
|
1071
1113
|
for (const p of paths) {
|
|
1072
1114
|
const fd = files[p];
|
|
1073
|
-
const size = fd ? isFileDataV1(fd) ? fd.content.join("\n").length : isFileDataBinary(fd) ? fd.content.byteLength : fd.content.length : 0;
|
|
1074
1115
|
infos.push({
|
|
1075
1116
|
path: p,
|
|
1076
1117
|
is_dir: false,
|
|
1077
|
-
size,
|
|
1118
|
+
size: fd ? fileSize(fd) : 0,
|
|
1078
1119
|
modified_at: fd?.modified_at || ""
|
|
1079
1120
|
});
|
|
1080
1121
|
}
|
|
@@ -1093,9 +1134,7 @@ var StateBackend = class {
|
|
|
1093
1134
|
const responses = [];
|
|
1094
1135
|
const updates = {};
|
|
1095
1136
|
for (const [path, content] of files) try {
|
|
1096
|
-
|
|
1097
|
-
if (this.fileFormat === "v2" && !isTextMimeType(mimeType)) updates[path] = createFileData(content, void 0, "v2", mimeType);
|
|
1098
|
-
else updates[path] = createFileData(new TextDecoder().decode(content), void 0, this.fileFormat, mimeType);
|
|
1137
|
+
updates[path] = toStoredFileData(this.createUploadFileData(path, content));
|
|
1099
1138
|
responses.push({
|
|
1100
1139
|
path,
|
|
1101
1140
|
error: null
|
|
@@ -1115,6 +1154,20 @@ var StateBackend = class {
|
|
|
1115
1154
|
return result;
|
|
1116
1155
|
}
|
|
1117
1156
|
/**
|
|
1157
|
+
* Build FileData for an uploaded file.
|
|
1158
|
+
*
|
|
1159
|
+
* In v2, bytes at a binary MIME type stay binary, and bytes at a text MIME
|
|
1160
|
+
* type that are not valid UTF-8 are kept as application/octet-stream rather
|
|
1161
|
+
* than lossily decoded. v1 cannot hold binary, so it always decodes as text.
|
|
1162
|
+
*/
|
|
1163
|
+
createUploadFileData(path, content) {
|
|
1164
|
+
const mimeType = getMimeType(path);
|
|
1165
|
+
if (this.fileFormat === "v1") return createFileData(new TextDecoder().decode(content), void 0, "v1", mimeType);
|
|
1166
|
+
if (!isTextMimeType(mimeType)) return createFileData(content, void 0, "v2", mimeType);
|
|
1167
|
+
const text = decodeUtf8(content);
|
|
1168
|
+
return text === void 0 ? createFileData(content, void 0, "v2", "application/octet-stream") : createFileData(text, void 0, "v2", mimeType);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1118
1171
|
* Download multiple files.
|
|
1119
1172
|
*
|
|
1120
1173
|
* @param paths - List of file paths to download
|
|
@@ -1133,7 +1186,7 @@ var StateBackend = class {
|
|
|
1133
1186
|
});
|
|
1134
1187
|
continue;
|
|
1135
1188
|
}
|
|
1136
|
-
const fileDataV2 = migrateToFileDataV2(fileData, path);
|
|
1189
|
+
const fileDataV2 = migrateToFileDataV2(fromStoredFileData(fileData), path);
|
|
1137
1190
|
if (typeof fileDataV2.content === "string") {
|
|
1138
1191
|
const content = new TextEncoder().encode(fileDataV2.content);
|
|
1139
1192
|
responses.push({
|
|
@@ -2376,30 +2429,39 @@ function extractTextFromMessage(message) {
|
|
|
2376
2429
|
if (Array.isArray(message.content)) return message.content.filter((block) => block.type === "text" && typeof block.text === "string").map((block) => block.text).join("\n");
|
|
2377
2430
|
return String(message.content);
|
|
2378
2431
|
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Whether a content block is an image. Tool-result eviction skips images when
|
|
2434
|
+
* sizing a result and keeps them when evicting it: base64 length says little
|
|
2435
|
+
* about what a provider charges for an image.
|
|
2436
|
+
*/
|
|
2437
|
+
function isImageBlock(block) {
|
|
2438
|
+
return typeof block === "object" && block !== null && "type" in block && (block.type === "image" || block.type === "image_url");
|
|
2439
|
+
}
|
|
2379
2440
|
function stringifyToolContent(content) {
|
|
2380
2441
|
if (typeof content === "string") return content;
|
|
2381
|
-
if (Array.isArray(content)) return content.map((block) => {
|
|
2442
|
+
if (Array.isArray(content)) return content.filter((block) => !isImageBlock(block)).map((block) => {
|
|
2382
2443
|
if (typeof block === "object" && block !== null && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string") return block.text;
|
|
2383
2444
|
return JSON.stringify(block);
|
|
2384
2445
|
}).join("\n");
|
|
2385
2446
|
return String(content);
|
|
2386
2447
|
}
|
|
2387
2448
|
/**
|
|
2388
|
-
* Build replacement content for an evicted
|
|
2449
|
+
* Build replacement content for an evicted message, preserving the blocks `keep` selects.
|
|
2389
2450
|
*
|
|
2390
2451
|
* For plain string content, returns the replacement text directly. For list content
|
|
2391
|
-
* with mixed block types (e.g., text + image), replaces
|
|
2392
|
-
* text block containing the replacement text while keeping
|
|
2452
|
+
* with mixed block types (e.g., text + image), replaces the other blocks with a single
|
|
2453
|
+
* text block containing the replacement text while keeping the selected blocks intact.
|
|
2454
|
+
* By default every non-text block is kept.
|
|
2393
2455
|
*/
|
|
2394
|
-
function
|
|
2456
|
+
function buildEvictedContent(message, replacementText, keep = (block) => block.type !== "text") {
|
|
2395
2457
|
if (typeof message.content === "string") return replacementText;
|
|
2396
2458
|
if (Array.isArray(message.content)) {
|
|
2397
|
-
const
|
|
2398
|
-
if (
|
|
2459
|
+
const keptBlocks = message.content.filter((block) => typeof block === "object" && block !== null && keep(block));
|
|
2460
|
+
if (keptBlocks.length === 0) return replacementText;
|
|
2399
2461
|
return [{
|
|
2400
2462
|
type: "text",
|
|
2401
2463
|
text: replacementText
|
|
2402
|
-
}, ...
|
|
2464
|
+
}, ...keptBlocks];
|
|
2403
2465
|
}
|
|
2404
2466
|
return replacementText;
|
|
2405
2467
|
}
|
|
@@ -2412,7 +2474,7 @@ function buildEvictedHumanContent(message, replacementText) {
|
|
|
2412
2474
|
*/
|
|
2413
2475
|
function buildTruncatedHumanMessage(message, filePath) {
|
|
2414
2476
|
const contentSample = createContentPreview(extractTextFromMessage(message));
|
|
2415
|
-
const evictedContent =
|
|
2477
|
+
const evictedContent = buildEvictedContent(message, TOO_LARGE_HUMAN_MSG.replace("{file_path}", filePath).replace("{content_sample}", contentSample));
|
|
2416
2478
|
return new langchain.HumanMessage({
|
|
2417
2479
|
content: evictedContent,
|
|
2418
2480
|
id: message.id,
|
|
@@ -2452,6 +2514,7 @@ const FileDataV1Schema = zod_v4.z.object({
|
|
|
2452
2514
|
const FileDataV2Schema = zod_v4.z.object({
|
|
2453
2515
|
content: zod_v4.z.union([zod_v4.z.string(), zod_v4.z.instanceof(Uint8Array)]),
|
|
2454
2516
|
mimeType: zod_v4.z.string(),
|
|
2517
|
+
encoding: zod_v4.z.enum(["utf-8", "base64"]).optional(),
|
|
2455
2518
|
created_at: zod_v4.z.string(),
|
|
2456
2519
|
modified_at: zod_v4.z.string()
|
|
2457
2520
|
});
|
|
@@ -3338,7 +3401,7 @@ function createFilesystemMiddleware(options = {}) {
|
|
|
3338
3401
|
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);
|
|
3339
3402
|
return {
|
|
3340
3403
|
message: new langchain.ToolMessage({
|
|
3341
|
-
content: replacementText,
|
|
3404
|
+
content: buildEvictedContent(msg, replacementText, isImageBlock),
|
|
3342
3405
|
tool_call_id: msg.tool_call_id,
|
|
3343
3406
|
name: msg.name,
|
|
3344
3407
|
id: msg.id,
|
|
@@ -11143,4 +11206,4 @@ Object.defineProperty(exports, "skillsMetadataValue", {
|
|
|
11143
11206
|
}
|
|
11144
11207
|
});
|
|
11145
11208
|
|
|
11146
|
-
//# sourceMappingURL=langsmith-
|
|
11209
|
+
//# sourceMappingURL=langsmith-aH3Gwzii.cjs.map
|