deepagents 1.13.4 → 1.13.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.
- package/dist/browser.cjs +1 -1
- package/dist/browser.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/{langsmith-yA3yhBRa.cjs → langsmith-CG8px69t.cjs} +155 -56
- package/dist/langsmith-CG8px69t.cjs.map +1 -0
- package/dist/{langsmith-BAO_h4J6.js → langsmith-CY7MawjU.js} +155 -56
- package/dist/langsmith-CY7MawjU.js.map +1 -0
- package/dist/node.cjs +2 -2
- package/dist/node.js +2 -2
- package/dist/{src-CcY34Ckx.js → src-Bos_UCsK.js} +2 -2
- package/dist/{src-CcY34Ckx.js.map → src-Bos_UCsK.js.map} +1 -1
- package/dist/{src-D_XxmEak.cjs → src-C2ZohcHT.cjs} +2 -2
- package/dist/{src-D_XxmEak.cjs.map → src-C2ZohcHT.cjs.map} +1 -1
- package/package.json +2 -2
- package/dist/langsmith-BAO_h4J6.js.map +0 -1
- package/dist/langsmith-yA3yhBRa.cjs.map +0 -1
|
@@ -206,6 +206,21 @@ function formatContentWithLineNumbers(content, startLine = 1) {
|
|
|
206
206
|
return formatContentWithLineNumbersAndBoundaries(content, startLine).text;
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
|
+
* Join file content into the unmodified source body of a `read_file` result.
|
|
210
|
+
*
|
|
211
|
+
* Source lines are emitted unchanged, with no numbering. A status header
|
|
212
|
+
* carries the line-range metadata separately, so nothing here needs to
|
|
213
|
+
* encode line numbers or escape anything.
|
|
214
|
+
*/
|
|
215
|
+
function formatSourceBlock(content) {
|
|
216
|
+
let lines;
|
|
217
|
+
if (typeof content === "string") {
|
|
218
|
+
lines = content.split("\n");
|
|
219
|
+
if (lines.length > 0 && lines[lines.length - 1] === "") lines = lines.slice(0, -1);
|
|
220
|
+
} else lines = content;
|
|
221
|
+
return lines.join("\n");
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
209
224
|
* Check if content is empty and return warning message.
|
|
210
225
|
*
|
|
211
226
|
* @param content - Content to check
|
|
@@ -1539,7 +1554,6 @@ var CompositeBackend = class {
|
|
|
1539
1554
|
* - Pluggable backends (StateBackend, StoreBackend, FilesystemBackend, CompositeBackend)
|
|
1540
1555
|
* - Tool result eviction for large outputs
|
|
1541
1556
|
*/
|
|
1542
|
-
const INT_FORMATTER = new Intl.NumberFormat("en-US");
|
|
1543
1557
|
/**
|
|
1544
1558
|
* Normalizes tool input so that models sending `path` instead of `file_path`
|
|
1545
1559
|
* still work. If the input has `path` but not `file_path`, copies `path` into
|
|
@@ -1609,29 +1623,100 @@ const READ_FILE_TRUNCATION_MSG = `
|
|
|
1609
1623
|
|
|
1610
1624
|
[Output was truncated due to size limits. The file content is very large. Consider reformatting the file to make it easier to navigate. For example, if this is JSON, use execute(command='jq . {file_path}') to pretty-print it with line breaks. For other formats, you can use appropriate formatting tools to split long lines.]`;
|
|
1611
1625
|
/**
|
|
1612
|
-
*
|
|
1626
|
+
* Describe the window a read returned, as status header fields.
|
|
1613
1627
|
*
|
|
1614
1628
|
* Backends own source-level pagination because only they know how much of the
|
|
1615
|
-
* file was read. The middleware owns presentation: it
|
|
1616
|
-
* and turns optional metadata into a
|
|
1617
|
-
* optional preserves compatibility with custom backends that predate
|
|
1618
|
-
* contract
|
|
1629
|
+
* file was read. The middleware owns presentation: it renders the source
|
|
1630
|
+
* unmodified and turns optional metadata into a terse header. Keeping the
|
|
1631
|
+
* fields optional preserves compatibility with custom backends that predate
|
|
1632
|
+
* this contract — `prepareReadWindow` derives a range for those instead.
|
|
1619
1633
|
*
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1634
|
+
* Returns the `lines A-B[ of T]` field, followed by `next offset N` when the
|
|
1635
|
+
* window stopped short of the end of the file.
|
|
1622
1636
|
*/
|
|
1623
|
-
function
|
|
1637
|
+
function describeReadWindow(readResult) {
|
|
1624
1638
|
const { startLine, endLine, nextOffset, totalLines } = readResult;
|
|
1625
|
-
if (startLine === void 0 || endLine === void 0 ||
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
if (endLine
|
|
1630
|
-
|
|
1631
|
-
|
|
1639
|
+
if (startLine === void 0 || endLine === void 0 || !Number.isSafeInteger(startLine) || !Number.isSafeInteger(endLine) || startLine < 1 || endLine < startLine || totalLines !== void 0 && (!Number.isSafeInteger(totalLines) || totalLines < endLine)) return [];
|
|
1640
|
+
let span = `lines ${startLine}-${endLine}`;
|
|
1641
|
+
if (totalLines !== void 0) span += ` of ${totalLines}`;
|
|
1642
|
+
const fields = [span];
|
|
1643
|
+
if (nextOffset !== void 0 && (totalLines === void 0 || endLine < totalLines)) fields.push(`next offset ${nextOffset}`);
|
|
1644
|
+
return fields;
|
|
1645
|
+
}
|
|
1646
|
+
/** Render the status header that sits above a text `read_file` result. */
|
|
1647
|
+
function readHeader(fields) {
|
|
1648
|
+
return `@@ ${fields.join(" | ")} @@`;
|
|
1649
|
+
}
|
|
1650
|
+
/** Notice disclosing that a negative `offset` was reinterpreted as the start of the file, or `undefined` for a non-negative offset. */
|
|
1651
|
+
function clampedOffsetNotice(offset) {
|
|
1652
|
+
if (offset >= 0) return;
|
|
1653
|
+
return `[Requested offset ${offset} is before the start of the file; read from line 1 instead.]`;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Compose a read result from its notices, status header, and source body.
|
|
1657
|
+
*
|
|
1658
|
+
* Notices sit above the header, so every line below it is unmodified file
|
|
1659
|
+
* content and consumers (including `stripLineNumbers` in the quickjs
|
|
1660
|
+
* provider) can tell the two apart by position.
|
|
1661
|
+
*/
|
|
1662
|
+
function assembleRead(body, options) {
|
|
1663
|
+
const { fields, notices = [] } = options;
|
|
1664
|
+
return [
|
|
1665
|
+
...notices,
|
|
1666
|
+
readHeader(fields),
|
|
1667
|
+
body
|
|
1668
|
+
].join("\n");
|
|
1669
|
+
}
|
|
1670
|
+
/** Derives a header range from `offset` when the backend left `startLine`/`endLine` unset. */
|
|
1671
|
+
function prepareReadWindow(readResult, content, offset) {
|
|
1672
|
+
const body = formatSourceBlock(content);
|
|
1673
|
+
if (readResult.startLine !== void 0 && readResult.endLine !== void 0) return {
|
|
1674
|
+
readResult,
|
|
1675
|
+
body
|
|
1676
|
+
};
|
|
1677
|
+
const startLine = offset + 1;
|
|
1678
|
+
const endLine = startLine + body.split("\n").length - 1;
|
|
1679
|
+
return {
|
|
1680
|
+
readResult: {
|
|
1681
|
+
...readResult,
|
|
1682
|
+
startLine,
|
|
1683
|
+
endLine
|
|
1684
|
+
},
|
|
1685
|
+
body
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Assemble a read cut inside a single source line too long to fit.
|
|
1690
|
+
*
|
|
1691
|
+
* No offset reaches the remainder of such a line, so the header reports how
|
|
1692
|
+
* much of it is shown in place of a resume point.
|
|
1693
|
+
*/
|
|
1694
|
+
function midlineTruncatedRead(body, readResult, threshold, notices) {
|
|
1695
|
+
const newlineIdx = body.indexOf("\n");
|
|
1696
|
+
const oversized = newlineIdx === -1 ? body.length : newlineIdx;
|
|
1697
|
+
const clipped = {
|
|
1698
|
+
totalLines: readResult.totalLines,
|
|
1699
|
+
startLine: readResult.startLine,
|
|
1700
|
+
endLine: readResult.startLine,
|
|
1701
|
+
nextOffset: void 0
|
|
1702
|
+
};
|
|
1703
|
+
const fieldsFor = (shown) => [
|
|
1704
|
+
...describeReadWindow(clipped),
|
|
1705
|
+
"truncated mid-line",
|
|
1706
|
+
`${shown} of ${oversized} chars`
|
|
1707
|
+
];
|
|
1708
|
+
const reserved = assembleRead("", {
|
|
1709
|
+
fields: fieldsFor(oversized),
|
|
1710
|
+
notices
|
|
1711
|
+
}).length;
|
|
1712
|
+
const shown = Math.max(0, Math.min(oversized, threshold - reserved));
|
|
1713
|
+
return assembleRead(body.slice(0, shown), {
|
|
1714
|
+
fields: fieldsFor(shown),
|
|
1715
|
+
notices
|
|
1716
|
+
});
|
|
1632
1717
|
}
|
|
1633
1718
|
/**
|
|
1634
|
-
* Fit a
|
|
1719
|
+
* Fit a paginated read into the middleware's output budget without
|
|
1635
1720
|
* publishing a resume offset that skips content the model did not see.
|
|
1636
1721
|
*
|
|
1637
1722
|
* There are two independent forms of limiting:
|
|
@@ -1642,38 +1727,50 @@ function remainingLinesNotice(readResult) {
|
|
|
1642
1727
|
* If the backend returned lines 1-100 but the middleware only displayed lines
|
|
1643
1728
|
* 1-30, forwarding the backend's original `nextOffset: 100` would silently skip
|
|
1644
1729
|
* lines 31-100 on the next read. This function therefore truncates only after a
|
|
1645
|
-
* complete source line and rebuilds the
|
|
1646
|
-
* line
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
const
|
|
1658
|
-
if (!tokenLimit || content.length + notice.length < 4 * tokenLimit) return content + notice;
|
|
1659
|
-
const truncationMsg = READ_FILE_TRUNCATION_MSG.replace("{file_path}", filePath);
|
|
1730
|
+
* complete source line and rebuilds the header from the last line actually
|
|
1731
|
+
* displayed. If no complete source line fits alongside the truncation
|
|
1732
|
+
* message, it falls back to `midlineTruncatedRead`, which reports exactly how
|
|
1733
|
+
* much of the oversized line is shown rather than guessing at a resume point.
|
|
1734
|
+
*/
|
|
1735
|
+
function truncatePaginatedRead(body, readResult, options) {
|
|
1736
|
+
const { filePath, tokenLimit, notices = [] } = options;
|
|
1737
|
+
const result = assembleRead(body, {
|
|
1738
|
+
fields: describeReadWindow(readResult),
|
|
1739
|
+
notices
|
|
1740
|
+
});
|
|
1741
|
+
if (!tokenLimit || result.length < 4 * tokenLimit) return result;
|
|
1742
|
+
const truncationMsg = READ_FILE_TRUNCATION_MSG.replace("{file_path}", filePath).trim();
|
|
1660
1743
|
const threshold = 4 * tokenLimit;
|
|
1661
1744
|
if (readResult.startLine !== void 0 && readResult.endLine !== void 0) {
|
|
1662
|
-
const
|
|
1663
|
-
|
|
1745
|
+
const rows = body.split("\n");
|
|
1746
|
+
let position = 0;
|
|
1747
|
+
const boundaries = [];
|
|
1748
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
1749
|
+
const sourceLine = readResult.startLine + index;
|
|
1750
|
+
if (sourceLine > readResult.endLine) break;
|
|
1751
|
+
position += rows[index].length;
|
|
1752
|
+
boundaries.push({
|
|
1753
|
+
endOffset: position,
|
|
1754
|
+
endLine: sourceLine
|
|
1755
|
+
});
|
|
1756
|
+
position += 1;
|
|
1757
|
+
}
|
|
1664
1758
|
for (let index = boundaries.length - 1; index >= 0; index -= 1) {
|
|
1665
|
-
const
|
|
1666
|
-
const
|
|
1759
|
+
const { endOffset, endLine } = boundaries[index];
|
|
1760
|
+
const adjustedResult = {
|
|
1667
1761
|
totalLines: readResult.totalLines,
|
|
1668
1762
|
startLine: readResult.startLine,
|
|
1669
|
-
endLine
|
|
1670
|
-
nextOffset:
|
|
1763
|
+
endLine,
|
|
1764
|
+
nextOffset: endLine
|
|
1765
|
+
};
|
|
1766
|
+
const candidate = assembleRead(body.slice(0, endOffset), {
|
|
1767
|
+
fields: [...describeReadWindow(adjustedResult), "truncated due to size"],
|
|
1768
|
+
notices: [...notices, truncationMsg]
|
|
1671
1769
|
});
|
|
1672
|
-
if (
|
|
1770
|
+
if (candidate.length <= threshold) return candidate;
|
|
1673
1771
|
}
|
|
1674
1772
|
}
|
|
1675
|
-
|
|
1676
|
-
return content.substring(0, maxContentLength) + truncationMsg;
|
|
1773
|
+
return midlineTruncatedRead(body, readResult, threshold, [...notices, truncationMsg]);
|
|
1677
1774
|
}
|
|
1678
1775
|
/**
|
|
1679
1776
|
* Note appended to grep results that were cut short by the match-count cap.
|
|
@@ -2069,8 +2166,7 @@ const READ_FILE_TOOL_DESCRIPTION = context`
|
|
|
2069
2166
|
|
|
2070
2167
|
Usage:
|
|
2071
2168
|
- By default, it reads up to ${100} lines starting from the beginning of the file. Use \`offset\`/\`limit\` to page through large files instead of reading them whole.
|
|
2072
|
-
-
|
|
2073
|
-
- Lines over ${INT_FORMATTER.format(MAX_LINE_LENGTH)} characters are split with continuation markers (e.g. 5.1, 5.2); \`limit\` counts source lines, so continuation rows do not consume the budget.
|
|
2169
|
+
- A status header, \`@@ field | field | ... @@\`, sits above the file content, and every line after it is unmodified file content. When content is truncated, there may be an explanation before the header. Never include the header when editing.
|
|
2074
2170
|
- Speculatively batch multiple \`read_file\` calls in one response when several files may be useful.
|
|
2075
2171
|
- An empty file returns a system-reminder warning in place of contents.
|
|
2076
2172
|
- Large tool results may be offloaded to a file; the tool message gives the path. Read that path here, paging with \`offset\`/\`limit\`.
|
|
@@ -2090,7 +2186,7 @@ const EDIT_FILE_TOOL_DESCRIPTION = context`
|
|
|
2090
2186
|
|
|
2091
2187
|
Usage:
|
|
2092
2188
|
- You must read the file before editing; this tool errors otherwise.
|
|
2093
|
-
- Preserve the exact indentation from the read output, and never include
|
|
2189
|
+
- Preserve the exact source indentation from the read output, and never include the read status header in old_string or new_string.
|
|
2094
2190
|
- Prefer editing an existing file over creating a new one.
|
|
2095
2191
|
- Only use emojis if the user explicitly requests it.
|
|
2096
2192
|
`;
|
|
@@ -2225,6 +2321,10 @@ function createReadFileTool(backend, options) {
|
|
|
2225
2321
|
}];
|
|
2226
2322
|
}
|
|
2227
2323
|
let content = typeof readResult.content === "string" ? readResult.content : "";
|
|
2324
|
+
if (content === "System reminder: File exists but has empty contents") return [{
|
|
2325
|
+
type: "text",
|
|
2326
|
+
text: content
|
|
2327
|
+
}];
|
|
2228
2328
|
const lines = content.split("\n");
|
|
2229
2329
|
let paginationResult = readResult;
|
|
2230
2330
|
if (lines.length > limit) {
|
|
@@ -2238,9 +2338,15 @@ function createReadFileTool(backend, options) {
|
|
|
2238
2338
|
};
|
|
2239
2339
|
}
|
|
2240
2340
|
}
|
|
2341
|
+
const { readResult: preparedResult, body } = prepareReadWindow(paginationResult, content, offset);
|
|
2342
|
+
const clampNotice = clampedOffsetNotice(requestedOffset);
|
|
2241
2343
|
return [{
|
|
2242
2344
|
type: "text",
|
|
2243
|
-
text: truncatePaginatedRead(
|
|
2345
|
+
text: truncatePaginatedRead(body, preparedResult, {
|
|
2346
|
+
filePath: file_path,
|
|
2347
|
+
tokenLimit: toolTokenLimitBeforeEvict,
|
|
2348
|
+
notices: clampNotice ? [clampNotice] : []
|
|
2349
|
+
})
|
|
2244
2350
|
}];
|
|
2245
2351
|
}, {
|
|
2246
2352
|
name: "read_file",
|
|
@@ -4827,17 +4933,11 @@ function validateModulePath(raw) {
|
|
|
4827
4933
|
*/
|
|
4828
4934
|
function createSkillsMiddleware(options) {
|
|
4829
4935
|
const { backend, sources } = options;
|
|
4830
|
-
let loadedSkills = [];
|
|
4831
4936
|
return createMiddleware({
|
|
4832
4937
|
name: "SkillsMiddleware",
|
|
4833
4938
|
stateSchema: SkillsStateSchema,
|
|
4834
4939
|
async beforeAgent(state) {
|
|
4835
|
-
|
|
4836
|
-
if (loadedSkills.length > 0) return stateHasSkills ? void 0 : { skillsMetadata: loadedSkills };
|
|
4837
|
-
if (stateHasSkills) {
|
|
4838
|
-
loadedSkills = state.skillsMetadata;
|
|
4839
|
-
return;
|
|
4840
|
-
}
|
|
4940
|
+
if ("skillsMetadata" in state && Array.isArray(state.skillsMetadata) && state.skillsMetadata.length > 0) return;
|
|
4841
4941
|
const resolvedBackend = await resolveBackend(backend, { state });
|
|
4842
4942
|
const allSkills = /* @__PURE__ */ new Map();
|
|
4843
4943
|
for (const sourcePath of sources) try {
|
|
@@ -4846,11 +4946,10 @@ function createSkillsMiddleware(options) {
|
|
|
4846
4946
|
} catch (error) {
|
|
4847
4947
|
console.debug(`[BackendSkillsMiddleware] Failed to load skills from ${sourcePath}:`, error);
|
|
4848
4948
|
}
|
|
4849
|
-
|
|
4850
|
-
return { skillsMetadata: loadedSkills };
|
|
4949
|
+
return { skillsMetadata: Array.from(allSkills.values()) };
|
|
4851
4950
|
},
|
|
4852
4951
|
wrapModelCall(request, handler) {
|
|
4853
|
-
const skillsMetadata =
|
|
4952
|
+
const skillsMetadata = request.state?.skillsMetadata || [];
|
|
4854
4953
|
const skillsLocations = formatSkillsLocations(sources);
|
|
4855
4954
|
const skillsList = formatSkillsList(skillsMetadata, sources);
|
|
4856
4955
|
const skillsSection = SKILLS_SYSTEM_PROMPT.replace("{skills_locations}", skillsLocations).replace("{skills_list}", skillsList);
|
|
@@ -8754,4 +8853,4 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
8754
8853
|
//#endregion
|
|
8755
8854
|
export { DEFAULT_GENERAL_PURPOSE_DESCRIPTION as A, StateBackend as B, MAX_SKILL_DESCRIPTION_LENGTH as C, createMemoryMiddleware as D, createSkillsMiddleware as E, createSubAgentMiddleware as F, resolveBackend as G, applyGrepMaxCount as H, computeSummarizationDefaults as I, checkEmptyContent as J, adaptBackendProtocol as K, createSummarizationMiddleware as L, GENERAL_PURPOSE_SUBAGENT as M, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY as N, filesValue as O, createSubAgent as P, performStringReplacement as Q, createFilesystemMiddleware as R, createCompletionCallbackMiddleware as S, MAX_SKILL_NAME_LENGTH as T, isSandboxBackend as U, SandboxError as V, isSandboxProtocol as W, isTextMimeType as X, getMimeType as Y, normalizeReadPagination as Z, createHarnessProfile as _, ASYNC_TASK_SYSTEM_PROMPT as a, createAsyncSubAgentMiddleware as b, TASK_SYSTEM_PROMPT as c, registerHarnessProfile as d, generalPurposeSubagentConfigSchema as f, EMPTY_HARNESS_PROFILE as g, serializeProfile as h, StoreBackend as i, DEFAULT_SUBAGENT_PROMPT as j, createPatchToolCallsMiddleware as k, createDeepAgent as l, parseHarnessProfileConfig as m, BaseSandbox as n, BASE_AGENT_PROMPT as o, harnessProfileConfigSchema as p, adaptSandboxProtocol as q, ContextHubBackend as r, EXECUTION_SYSTEM_PROMPT as s, LangSmithSandbox as t, getHarnessProfile as u, REQUIRED_MIDDLEWARE_NAMES as v, MAX_SKILL_FILE_SIZE as w, isAsyncSubAgent as x, ConfigurationError as y, CompositeBackend as z };
|
|
8756
8855
|
|
|
8757
|
-
//# sourceMappingURL=langsmith-
|
|
8856
|
+
//# sourceMappingURL=langsmith-CY7MawjU.js.map
|