deepagents 1.13.4 → 1.14.0
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-D7nWARfg.d.cts → agent-CrQgOsbl.d.cts} +111 -27
- package/dist/{agent-CVBXKZAu.d.ts → agent-DGkf2K7U.d.ts} +111 -27
- package/dist/browser.cjs +2 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/{langsmith-BAO_h4J6.js → langsmith-3LzYb-m7.js} +202 -76
- package/dist/langsmith-3LzYb-m7.js.map +1 -0
- package/dist/{langsmith-yA3yhBRa.cjs → langsmith-C9zNPKIz.cjs} +207 -75
- package/dist/langsmith-C9zNPKIz.cjs.map +1 -0
- package/dist/node.cjs +3 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/{src-D_XxmEak.cjs → src-Nhlq1O0Y.cjs} +2 -2
- package/dist/{src-D_XxmEak.cjs.map → src-Nhlq1O0Y.cjs.map} +1 -1
- package/dist/{src-CcY34Ckx.js → src-gIoHrhh3.js} +2 -2
- package/dist/{src-CcY34Ckx.js.map → src-gIoHrhh3.js.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
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as AsyncTaskStatus, $t as
|
|
2
|
-
export { ASYNC_TASK_SYSTEM_PROMPT, type AgentMemoryMiddlewareOptions, type AnyBackendProtocol, type AnySubAgent, type AsyncSubAgent, type AsyncSubAgentMiddlewareOptions, type AsyncTask, type AsyncTaskStatus, BASE_AGENT_PROMPT, type BackendFactory, type BackendProtocol, type BackendProtocolV1, type BackendProtocolV2, type BackendRuntime, BaseSandbox, type CompiledSubAgent, type CompletionCallbackOptions, CompositeBackend, ConfigurationError, type ConfigurationErrorCode, ContextHubBackend, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentRunStream, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type DeleteResult, EMPTY_HARNESS_PROFILE, EXECUTION_SYSTEM_PROMPT, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FilesystemOperation, type FilesystemPermission, type FlattenSubAgentMiddleware, type ForkedSubAgent, type FsToolName, GENERAL_PURPOSE_SUBAGENT, type GeneralPurposeSubagentConfig, type GlobResult, type GrepMatch, type GrepResult, type HarnessProfile, type HarnessProfileConfigData, type HarnessProfileOptions, type InferDeepAgentSubagents, type InferDeepAgentType, type InferStructuredResponse, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, type LangSmithCaptureSnapshotOptions, LangSmithSandbox, type LangSmithSandboxCreateOptions, type LangSmithSandboxOptions, type LangSmithSnapshot, type LangSmithStartSandboxOptions, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, LocalShellBackend, type LocalShellBackendOptions, type LsResult, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type PermissionMode, REQUIRED_MIDDLEWARE_NAMES, type ReadRawResult, type ReadResult, type ResolveDeepAgentTypeConfig, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY, type SandboxBackendProtocol, type SandboxBackendProtocolV1, type SandboxBackendProtocolV2, type SandboxDeleteOptions, SandboxError, type SandboxErrorCode, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, type StateAndStore, StateBackend, StoreBackend, type StoreBackendContext, type StoreBackendNamespaceFactory, type StoreBackendOptions, type SubAgent, type SubAgentMiddlewareOptions, type SubagentRunStream, type SupportedResponseFormat, type SystemPromptConfig, TASK_SYSTEM_PROMPT, type WriteResult, adaptBackendProtocol, adaptSandboxProtocol, applyGrepMaxCount, computeSummarizationDefaults, createAgentMemoryMiddleware, createAsyncSubAgentMiddleware, createCompletionCallbackMiddleware, createDeepAgent, createFilesystemMiddleware, createHarnessProfile, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgent, createSubAgentMiddleware, createSummarizationMiddleware, filesValue, findProjectRoot, generalPurposeSubagentConfigSchema, getHarnessProfile, harnessProfileConfigSchema, isAsyncSubAgent, isSandboxBackend, isSandboxProtocol, listSkills, normalizeReadPagination, parseHarnessProfileConfig, parseSkillMetadata, registerHarnessProfile, resolveBackend, serializeProfile };
|
|
1
|
+
import { $ as AsyncTaskStatus, $t as PermissionMode, A as createSettings, An as isSandboxBackend, At as HarnessProfileConfigData, B as FlattenSubAgentMiddleware, Bt as REQUIRED_MIDDLEWARE_NAMES, C as listSkills, Cn as SandboxGetOrCreateOptions, Ct as SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY, D as filesValue, Dn as StateAndStore, Dt as createSubAgentMiddleware, E as createAgentMemoryMiddleware, En as SandboxListResponse, Et as createSubAgent, F as CreateDeepAgentParams, Fn as BackendProtocolV1, Ft as EMPTY_HARNESS_PROFILE, G as InferSubagentByName, Gt as EXECUTION_SYSTEM_PROMPT, H as InferDeepAgentType, Ht as ConfigurationErrorCode, I as DeepAgent, In as SandboxBackendProtocolV1, It as createHarnessProfile, J as ResolveDeepAgentTypeConfig, Jt as FilesystemMiddlewareOptions, K as InferSubagentReactAgentType, Kt as SystemPromptConfig, L as DeepAgentTypeConfig, Lt as GeneralPurposeSubagentConfig, M as DeepAgentRunStream, Mn as resolveBackend, Mt as harnessProfileConfigSchema, N as SubagentRunStream, Nn as BackendProtocolV2, Nt as parseHarnessProfileConfig, O as Settings, On as WriteResult, Ot as getHarnessProfile, P as AnySubAgent, Pn as SandboxBackendProtocolV2, Pt as serializeProfile, Q as AsyncTask, Qt as FilesystemPermission, R as DefaultDeepAgentTypeConfig, Rt as HarnessProfile, S as SkillMetadata, Sn as SandboxErrorCode, St as GENERAL_PURPOSE_SUBAGENT, T as AgentMemoryMiddlewareOptions, Tn as SandboxListOptions, Tt as SubAgentMiddlewareOptions, U as InferStructuredResponse, Ut as ASYNC_TASK_SYSTEM_PROMPT, V as InferDeepAgentSubagents, Vt as ConfigurationError, W as InferSubAgentMiddlewareStates, Wt as BASE_AGENT_PROMPT, X as AsyncSubAgent, Xt as createFilesystemMiddleware, Y as SupportedResponseFormat, Yt as FsToolName, Z as AsyncSubAgentMiddlewareOptions, Zt as FilesystemOperation, _ as StoreBackend, _n as ReadRawResult, _t as createPatchToolCallsMiddleware, a as adaptBackendProtocol, an as EditResult, at as createCompletionCallbackMiddleware, b as StoreBackendOptions, bn as SandboxDeleteOptions, bt as DEFAULT_SUBAGENT_PROMPT, c as LangSmithSandbox, cn as FileDownloadResponse, ct as MAX_SKILL_NAME_LENGTH, d as BaseSandbox, dn as FileUploadResponse, dt as SkillsMiddlewareOptions, en as AnyBackendProtocol, et as createAsyncSubAgentMiddleware, f as LocalShellBackend, fn as GlobResult, ft as createSkillsMiddleware, g as FilesystemBackend, gn as MaybePromise, gt as StateBackend, h as CompositeBackend, hn as LsResult, ht as createMemoryMiddleware, i as LangSmithStartSandboxOptions, in as DeleteResult, it as CompletionCallbackOptions, j as findProjectRoot, jn as isSandboxProtocol, jt as generalPurposeSubagentConfigSchema, k as SettingsOptions, kn as applyGrepMaxCount, kt as registerHarnessProfile, l as LangSmithSandboxCreateOptions, ln as FileInfo, lt as SkillMetadata$1, m as ContextHubBackend, mn as GrepResult, mt as MemoryMiddlewareOptions, n as LangSmithCaptureSnapshotOptions, nn as BackendProtocol, nt as computeSummarizationDefaults, o as adaptSandboxProtocol, on as ExecuteResponse, ot as MAX_SKILL_DESCRIPTION_LENGTH, p as LocalShellBackendOptions, pn as GrepMatch, pt as skillsMetadataValue, q as MergedDeepAgentState, qt as TASK_SYSTEM_PROMPT, r as LangSmithSnapshot, rn as BackendRuntime, rt as createSummarizationMiddleware, s as normalizeReadPagination, sn as FileData, st as MAX_SKILL_FILE_SIZE, t as createDeepAgent, tn as BackendFactory, tt as isAsyncSubAgent, u as LangSmithSandboxOptions, un as FileOperationError, ut as SkillMetadataEntry, v as StoreBackendContext, vn as ReadResult, vt as CompiledSubAgent, w as parseSkillMetadata, wn as SandboxInfo, wt as SubAgent, x as ListSkillsOptions, xn as SandboxError, xt as ForkedSubAgent, y as StoreBackendNamespaceFactory, yn as SandboxBackendProtocol, yt as DEFAULT_GENERAL_PURPOSE_DESCRIPTION, z as ExtractSubAgentMiddleware, zt as HarnessProfileOptions } from "./agent-DGkf2K7U.js";
|
|
2
|
+
export { ASYNC_TASK_SYSTEM_PROMPT, type AgentMemoryMiddlewareOptions, type AnyBackendProtocol, type AnySubAgent, type AsyncSubAgent, type AsyncSubAgentMiddlewareOptions, type AsyncTask, type AsyncTaskStatus, BASE_AGENT_PROMPT, type BackendFactory, type BackendProtocol, type BackendProtocolV1, type BackendProtocolV2, type BackendRuntime, BaseSandbox, type CompiledSubAgent, type CompletionCallbackOptions, CompositeBackend, ConfigurationError, type ConfigurationErrorCode, ContextHubBackend, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentRunStream, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type DeleteResult, EMPTY_HARNESS_PROFILE, EXECUTION_SYSTEM_PROMPT, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FilesystemOperation, type FilesystemPermission, type FlattenSubAgentMiddleware, type ForkedSubAgent, type FsToolName, GENERAL_PURPOSE_SUBAGENT, type GeneralPurposeSubagentConfig, type GlobResult, type GrepMatch, type GrepResult, type HarnessProfile, type HarnessProfileConfigData, type HarnessProfileOptions, type InferDeepAgentSubagents, type InferDeepAgentType, type InferStructuredResponse, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, type LangSmithCaptureSnapshotOptions, LangSmithSandbox, type LangSmithSandboxCreateOptions, type LangSmithSandboxOptions, type LangSmithSnapshot, type LangSmithStartSandboxOptions, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, LocalShellBackend, type LocalShellBackendOptions, type LsResult, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type PermissionMode, REQUIRED_MIDDLEWARE_NAMES, type ReadRawResult, type ReadResult, type ResolveDeepAgentTypeConfig, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY, type SandboxBackendProtocol, type SandboxBackendProtocolV1, type SandboxBackendProtocolV2, type SandboxDeleteOptions, SandboxError, type SandboxErrorCode, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillMetadataEntry, type SkillsMiddlewareOptions, type StateAndStore, StateBackend, StoreBackend, type StoreBackendContext, type StoreBackendNamespaceFactory, type StoreBackendOptions, type SubAgent, type SubAgentMiddlewareOptions, type SubagentRunStream, type SupportedResponseFormat, type SystemPromptConfig, TASK_SYSTEM_PROMPT, type WriteResult, adaptBackendProtocol, adaptSandboxProtocol, applyGrepMaxCount, computeSummarizationDefaults, createAgentMemoryMiddleware, createAsyncSubAgentMiddleware, createCompletionCallbackMiddleware, createDeepAgent, createFilesystemMiddleware, createHarnessProfile, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgent, createSubAgentMiddleware, createSummarizationMiddleware, filesValue, findProjectRoot, generalPurposeSubagentConfigSchema, getHarnessProfile, harnessProfileConfigSchema, isAsyncSubAgent, isSandboxBackend, isSandboxProtocol, listSkills, normalizeReadPagination, parseHarnessProfileConfig, parseSkillMetadata, registerHarnessProfile, resolveBackend, serializeProfile, skillsMetadataValue };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as createAgentMemoryMiddleware, i as parseSkillMetadata, n as FilesystemBackend, o as createSettings, r as listSkills, s as findProjectRoot, t as LocalShellBackend } from "./src-
|
|
3
|
-
export { ASYNC_TASK_SYSTEM_PROMPT, BASE_AGENT_PROMPT, BaseSandbox, CompositeBackend, ConfigurationError, ContextHubBackend, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, EMPTY_HARNESS_PROFILE, EXECUTION_SYSTEM_PROMPT, FilesystemBackend, GENERAL_PURPOSE_SUBAGENT, LangSmithSandbox, LocalShellBackend, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, REQUIRED_MIDDLEWARE_NAMES, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY, SandboxError, StateBackend, StoreBackend, TASK_SYSTEM_PROMPT, adaptBackendProtocol, adaptSandboxProtocol, applyGrepMaxCount, computeSummarizationDefaults, createAgentMemoryMiddleware, createAsyncSubAgentMiddleware, createCompletionCallbackMiddleware, createDeepAgent, createFilesystemMiddleware, createHarnessProfile, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgent, createSubAgentMiddleware, createSummarizationMiddleware, filesValue, findProjectRoot, generalPurposeSubagentConfigSchema, getHarnessProfile, harnessProfileConfigSchema, isAsyncSubAgent, isSandboxBackend, isSandboxProtocol, listSkills, normalizeReadPagination, parseHarnessProfileConfig, parseSkillMetadata, registerHarnessProfile, resolveBackend, serializeProfile };
|
|
1
|
+
import { A as createPatchToolCallsMiddleware, B as CompositeBackend, C as MAX_SKILL_DESCRIPTION_LENGTH, D as skillsMetadataValue, E as createSkillsMiddleware, F as createSubAgent, G as isSandboxProtocol, H as SandboxError, I as createSubAgentMiddleware, J as adaptSandboxProtocol, K as resolveBackend, L as computeSummarizationDefaults, M as DEFAULT_SUBAGENT_PROMPT, N as GENERAL_PURPOSE_SUBAGENT, O as createMemoryMiddleware, P as SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY, Q as normalizeReadPagination, R as createSummarizationMiddleware, S as createCompletionCallbackMiddleware, T as MAX_SKILL_NAME_LENGTH, U as applyGrepMaxCount, V as StateBackend, W as isSandboxBackend, _ as createHarnessProfile, a as ASYNC_TASK_SYSTEM_PROMPT, b as createAsyncSubAgentMiddleware, c as TASK_SYSTEM_PROMPT, d as registerHarnessProfile, f as generalPurposeSubagentConfigSchema, g as EMPTY_HARNESS_PROFILE, h as serializeProfile, i as StoreBackend, j as DEFAULT_GENERAL_PURPOSE_DESCRIPTION, k as filesValue, l as createDeepAgent, m as parseHarnessProfileConfig, n as BaseSandbox, o as BASE_AGENT_PROMPT, p as harnessProfileConfigSchema, q as adaptBackendProtocol, r as ContextHubBackend, s as EXECUTION_SYSTEM_PROMPT, t as LangSmithSandbox, u as getHarnessProfile, v as REQUIRED_MIDDLEWARE_NAMES, w as MAX_SKILL_FILE_SIZE, x as isAsyncSubAgent, y as ConfigurationError, z as createFilesystemMiddleware } from "./langsmith-3LzYb-m7.js";
|
|
2
|
+
import { a as createAgentMemoryMiddleware, i as parseSkillMetadata, n as FilesystemBackend, o as createSettings, r as listSkills, s as findProjectRoot, t as LocalShellBackend } from "./src-gIoHrhh3.js";
|
|
3
|
+
export { ASYNC_TASK_SYSTEM_PROMPT, BASE_AGENT_PROMPT, BaseSandbox, CompositeBackend, ConfigurationError, ContextHubBackend, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, EMPTY_HARNESS_PROFILE, EXECUTION_SYSTEM_PROMPT, FilesystemBackend, GENERAL_PURPOSE_SUBAGENT, LangSmithSandbox, LocalShellBackend, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, REQUIRED_MIDDLEWARE_NAMES, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY, SandboxError, StateBackend, StoreBackend, TASK_SYSTEM_PROMPT, adaptBackendProtocol, adaptSandboxProtocol, applyGrepMaxCount, computeSummarizationDefaults, createAgentMemoryMiddleware, createAsyncSubAgentMiddleware, createCompletionCallbackMiddleware, createDeepAgent, createFilesystemMiddleware, createHarnessProfile, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgent, createSubAgentMiddleware, createSummarizationMiddleware, filesValue, findProjectRoot, generalPurposeSubagentConfigSchema, getHarnessProfile, harnessProfileConfigSchema, isAsyncSubAgent, isSandboxBackend, isSandboxProtocol, listSkills, normalizeReadPagination, parseHarnessProfileConfig, parseSkillMetadata, registerHarnessProfile, resolveBackend, serializeProfile, skillsMetadataValue };
|
|
@@ -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",
|
|
@@ -3490,6 +3596,11 @@ const EXCLUDED_STATE_KEYS = [
|
|
|
3490
3596
|
* the parent's private channels (skills metadata, memory contents, etc.)
|
|
3491
3597
|
* to rebuild an equivalent prompt.
|
|
3492
3598
|
*
|
|
3599
|
+
* A pending invalidation propagates: a fork spawned in the same iteration
|
|
3600
|
+
* that set `skillsMetadata` to `null` inherits the `null`, so its mirrored
|
|
3601
|
+
* skills middleware reloads from its own sources rather than seeing the
|
|
3602
|
+
* parent's last loaded list.
|
|
3603
|
+
*
|
|
3493
3604
|
* Call counts stay excluded: a fork inherits the parent's middleware, so
|
|
3494
3605
|
* sharing them collides on the parent's channel.
|
|
3495
3606
|
*/
|
|
@@ -4454,30 +4565,37 @@ const SkillMetadataEntrySchema = z$1.object({
|
|
|
4454
4565
|
module: z$1.string().optional()
|
|
4455
4566
|
});
|
|
4456
4567
|
/**
|
|
4457
|
-
*
|
|
4458
|
-
*
|
|
4568
|
+
* State value for a middleware's `skillsMetadata` field.
|
|
4569
|
+
*
|
|
4570
|
+
* A middleware can only read and write the fields declared on its own state
|
|
4571
|
+
* schema. A middleware that needs `skillsMetadata` — to inspect the skills
|
|
4572
|
+
* loaded for the thread, or to set the field to `null` and make the next model
|
|
4573
|
+
* call reload every source — declares it with this value.
|
|
4574
|
+
*
|
|
4575
|
+
* Treat the value as opaque: it is meant to be passed to `StateSchema`, and
|
|
4576
|
+
* its concrete type is an implementation detail that may change. To type an
|
|
4577
|
+
* individual entry, use {@link SkillMetadataEntry}.
|
|
4578
|
+
*
|
|
4579
|
+
* @example
|
|
4580
|
+
* ```typescript
|
|
4581
|
+
* import { createMiddleware } from "langchain";
|
|
4582
|
+
* import { StateSchema } from "@langchain/langgraph";
|
|
4583
|
+
* import { skillsMetadataValue } from "deepagents";
|
|
4459
4584
|
*
|
|
4460
|
-
*
|
|
4461
|
-
*
|
|
4462
|
-
*
|
|
4585
|
+
* const reloadEditedSkills = createMiddleware({
|
|
4586
|
+
* name: "ReloadEditedSkills",
|
|
4587
|
+
* stateSchema: new StateSchema({ skillsMetadata: skillsMetadataValue }),
|
|
4588
|
+
* afterAgent: (state) =>
|
|
4589
|
+
* agentEditedSkills(state) ? { skillsMetadata: null } : undefined,
|
|
4590
|
+
* });
|
|
4591
|
+
* ```
|
|
4463
4592
|
*/
|
|
4464
|
-
|
|
4465
|
-
if (!update || update.length === 0) return current || [];
|
|
4466
|
-
if (!current || current.length === 0) return update;
|
|
4467
|
-
const merged = /* @__PURE__ */ new Map();
|
|
4468
|
-
for (const skill of current) merged.set(skill.name, skill);
|
|
4469
|
-
for (const skill of update) merged.set(skill.name, skill);
|
|
4470
|
-
return Array.from(merged.values());
|
|
4471
|
-
}
|
|
4593
|
+
const skillsMetadataValue = z$1.array(SkillMetadataEntrySchema).nullish();
|
|
4472
4594
|
/**
|
|
4473
4595
|
* State schema for skills middleware.
|
|
4474
|
-
* Uses ReducedValue for skillsMetadata to allow concurrent updates from parallel subagents.
|
|
4475
4596
|
*/
|
|
4476
4597
|
const SkillsStateSchema = new StateSchema({
|
|
4477
|
-
skillsMetadata:
|
|
4478
|
-
inputSchema: z$1.array(SkillMetadataEntrySchema).optional(),
|
|
4479
|
-
reducer: skillsMetadataReducer
|
|
4480
|
-
}),
|
|
4598
|
+
skillsMetadata: skillsMetadataValue,
|
|
4481
4599
|
files: filesValue
|
|
4482
4600
|
});
|
|
4483
4601
|
/**
|
|
@@ -4814,6 +4932,21 @@ function validateModulePath(raw) {
|
|
|
4814
4932
|
* pattern: skill names and descriptions are shown in the prompt, but the agent
|
|
4815
4933
|
* reads full SKILL.md content only when needed.
|
|
4816
4934
|
*
|
|
4935
|
+
* Skills are loaded once per thread and stored in state. To pick up skills
|
|
4936
|
+
* added, edited, or deleted since then, set `skillsMetadata` to `null`; the
|
|
4937
|
+
* next model call reloads every source:
|
|
4938
|
+
*
|
|
4939
|
+
* ```ts
|
|
4940
|
+
* await agent.updateState(config, { skillsMetadata: null });
|
|
4941
|
+
* // or as part of the next run's input
|
|
4942
|
+
* await agent.invoke({ messages, skillsMetadata: null }, config);
|
|
4943
|
+
* ```
|
|
4944
|
+
*
|
|
4945
|
+
* Loading happens in `beforeModel`, so the reload is served by the next model
|
|
4946
|
+
* call rather than the next run. A middleware of your own can therefore
|
|
4947
|
+
* invalidate from any hook — including mid-run, from `afterModel` — and see
|
|
4948
|
+
* the fresh list on the following call. See {@link skillsMetadataValue}.
|
|
4949
|
+
*
|
|
4817
4950
|
* @param options - Configuration options
|
|
4818
4951
|
* @returns AgentMiddleware for skills loading and injection
|
|
4819
4952
|
*
|
|
@@ -4827,17 +4960,11 @@ function validateModulePath(raw) {
|
|
|
4827
4960
|
*/
|
|
4828
4961
|
function createSkillsMiddleware(options) {
|
|
4829
4962
|
const { backend, sources } = options;
|
|
4830
|
-
let loadedSkills = [];
|
|
4831
4963
|
return createMiddleware({
|
|
4832
4964
|
name: "SkillsMiddleware",
|
|
4833
4965
|
stateSchema: SkillsStateSchema,
|
|
4834
|
-
async
|
|
4835
|
-
|
|
4836
|
-
if (loadedSkills.length > 0) return stateHasSkills ? void 0 : { skillsMetadata: loadedSkills };
|
|
4837
|
-
if (stateHasSkills) {
|
|
4838
|
-
loadedSkills = state.skillsMetadata;
|
|
4839
|
-
return;
|
|
4840
|
-
}
|
|
4966
|
+
async beforeModel(state) {
|
|
4967
|
+
if (state.skillsMetadata !== null && state.skillsMetadata !== void 0) return;
|
|
4841
4968
|
const resolvedBackend = await resolveBackend(backend, { state });
|
|
4842
4969
|
const allSkills = /* @__PURE__ */ new Map();
|
|
4843
4970
|
for (const sourcePath of sources) try {
|
|
@@ -4846,11 +4973,10 @@ function createSkillsMiddleware(options) {
|
|
|
4846
4973
|
} catch (error) {
|
|
4847
4974
|
console.debug(`[BackendSkillsMiddleware] Failed to load skills from ${sourcePath}:`, error);
|
|
4848
4975
|
}
|
|
4849
|
-
|
|
4850
|
-
return { skillsMetadata: loadedSkills };
|
|
4976
|
+
return { skillsMetadata: Array.from(allSkills.values()) };
|
|
4851
4977
|
},
|
|
4852
4978
|
wrapModelCall(request, handler) {
|
|
4853
|
-
const skillsMetadata =
|
|
4979
|
+
const skillsMetadata = request.state?.skillsMetadata || [];
|
|
4854
4980
|
const skillsLocations = formatSkillsLocations(sources);
|
|
4855
4981
|
const skillsList = formatSkillsList(skillsMetadata, sources);
|
|
4856
4982
|
const skillsSection = SKILLS_SYSTEM_PROMPT.replace("{skills_locations}", skillsLocations).replace("{skills_list}", skillsList);
|
|
@@ -8752,6 +8878,6 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
8752
8878
|
}
|
|
8753
8879
|
};
|
|
8754
8880
|
//#endregion
|
|
8755
|
-
export {
|
|
8881
|
+
export { performStringReplacement as $, createPatchToolCallsMiddleware as A, CompositeBackend as B, MAX_SKILL_DESCRIPTION_LENGTH as C, skillsMetadataValue as D, createSkillsMiddleware as E, createSubAgent as F, isSandboxProtocol as G, SandboxError as H, createSubAgentMiddleware as I, adaptSandboxProtocol as J, resolveBackend as K, computeSummarizationDefaults as L, DEFAULT_SUBAGENT_PROMPT as M, GENERAL_PURPOSE_SUBAGENT as N, createMemoryMiddleware as O, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY as P, normalizeReadPagination as Q, createSummarizationMiddleware as R, createCompletionCallbackMiddleware as S, MAX_SKILL_NAME_LENGTH as T, applyGrepMaxCount as U, StateBackend as V, isSandboxBackend as W, getMimeType as X, checkEmptyContent as Y, isTextMimeType 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_GENERAL_PURPOSE_DESCRIPTION as j, filesValue as k, createDeepAgent as l, parseHarnessProfileConfig as m, BaseSandbox as n, BASE_AGENT_PROMPT as o, harnessProfileConfigSchema as p, adaptBackendProtocol 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, createFilesystemMiddleware as z };
|
|
8756
8882
|
|
|
8757
|
-
//# sourceMappingURL=langsmith-
|
|
8883
|
+
//# sourceMappingURL=langsmith-3LzYb-m7.js.map
|