deepagents 1.16.1 → 1.16.3
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-DIft4yNY.d.ts → agent-BAuGxPZn.d.ts} +19 -87
- package/dist/{agent-BErEClzV.d.cts → agent-DOFzksfM.d.cts} +19 -87
- 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 -2
- 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-B1pbrx3y.js → langsmith-BCgECepG.js} +186 -175
- package/dist/langsmith-BCgECepG.js.map +1 -0
- package/dist/{langsmith-aH3Gwzii.cjs → langsmith-CAjAu64d.cjs} +186 -176
- package/dist/langsmith-CAjAu64d.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-B1Lvbh_S.js → src-0lJMqL6V.js} +8 -10
- package/dist/src-0lJMqL6V.js.map +1 -0
- package/dist/{src-B2jjteSM.cjs → src-BB1S1Jfy.cjs} +8 -10
- package/dist/src-BB1S1Jfy.cjs.map +1 -0
- package/package.json +12 -12
- package/dist/langsmith-B1pbrx3y.js.map +0 -1
- package/dist/langsmith-aH3Gwzii.cjs.map +0 -1
- package/dist/src-B1Lvbh_S.js.map +0 -1
- package/dist/src-B2jjteSM.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -19,8 +19,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
22
|
let langchain = require("langchain");
|
|
23
|
+
let _langchain_core_tracers_tracer_langchain = require("@langchain/core/tracers/tracer_langchain");
|
|
24
24
|
let _langchain_core_errors = require("@langchain/core/errors");
|
|
25
25
|
let _langchain_langgraph = require("@langchain/langgraph");
|
|
26
26
|
let zod_v4 = require("zod/v4");
|
|
@@ -43,7 +43,7 @@ let _langchain_langgraph_sdk = require("@langchain/langgraph-sdk");
|
|
|
43
43
|
let langsmith_traceable = require("langsmith/traceable");
|
|
44
44
|
let langsmith = require("langsmith");
|
|
45
45
|
let langsmith_experimental_sandbox = require("langsmith/experimental/sandbox");
|
|
46
|
-
|
|
46
|
+
// src/backends/realpath.ts
|
|
47
47
|
const REALPATH = Symbol.for("deepagents.realpath");
|
|
48
48
|
function getRealpath(backend) {
|
|
49
49
|
if (typeof backend !== "object" || backend === null) return;
|
|
@@ -57,8 +57,7 @@ function setRealpath(target, fn) {
|
|
|
57
57
|
configurable: true
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
//#region src/backends/utils.ts
|
|
60
|
+
// src/backends/utils.ts
|
|
62
61
|
/**
|
|
63
62
|
* Shared utility functions for memory backend implementations.
|
|
64
63
|
*
|
|
@@ -718,8 +717,7 @@ function adaptSandboxProtocol(sandbox) {
|
|
|
718
717
|
});
|
|
719
718
|
return adapted;
|
|
720
719
|
}
|
|
721
|
-
|
|
722
|
-
//#region src/backends/protocol.ts
|
|
720
|
+
// src/backends/protocol.ts
|
|
723
721
|
/**
|
|
724
722
|
* Enforce a match cap after a backend grep has completed.
|
|
725
723
|
*
|
|
@@ -823,8 +821,7 @@ async function resolveBackend(backend, runtime) {
|
|
|
823
821
|
}
|
|
824
822
|
return isSandboxProtocol(backend) ? adaptSandboxProtocol(backend) : adaptBackendProtocol(backend);
|
|
825
823
|
}
|
|
826
|
-
|
|
827
|
-
//#region src/backends/state.ts
|
|
824
|
+
// src/backends/state.ts
|
|
828
825
|
function trimTrailingSlashes$2(path) {
|
|
829
826
|
let end = path.length;
|
|
830
827
|
while (end > 1 && path[end - 1] === "/") end--;
|
|
@@ -1203,8 +1200,7 @@ var StateBackend = class {
|
|
|
1203
1200
|
return responses;
|
|
1204
1201
|
}
|
|
1205
1202
|
};
|
|
1206
|
-
|
|
1207
|
-
//#region src/middleware/blobOffload.ts
|
|
1203
|
+
// src/middleware/blobOffload.ts
|
|
1208
1204
|
/**
|
|
1209
1205
|
* Content-addressed offload of binary `read_file` and inline `HumanMessage`
|
|
1210
1206
|
* blocks to the backend.
|
|
@@ -1510,15 +1506,17 @@ function restorePayloads(messages, payloads) {
|
|
|
1510
1506
|
async function hydrateMessages(messages, backend, prefix, cache) {
|
|
1511
1507
|
if (!messages.some(messageHasRefs)) return [...messages];
|
|
1512
1508
|
const { payloads, missing } = cachedPayloads(referencedDigests(messages), cache);
|
|
1513
|
-
if (missing.length > 0)
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1509
|
+
if (missing.length > 0) {
|
|
1510
|
+
if (typeof backend.downloadFiles !== "function") console.warn("Backend does not support downloadFiles; offloaded read_file content is unavailable");
|
|
1511
|
+
else {
|
|
1512
|
+
let responses = [];
|
|
1513
|
+
try {
|
|
1514
|
+
responses = await backend.downloadFiles(missing.map((digest) => blobPath(prefix, digest)));
|
|
1515
|
+
} catch (error) {
|
|
1516
|
+
console.warn("Failed to load offloaded read_file content", error);
|
|
1517
|
+
}
|
|
1518
|
+
acceptDownloads(missing, responses, payloads, cache);
|
|
1520
1519
|
}
|
|
1521
|
-
acceptDownloads(missing, responses, payloads, cache);
|
|
1522
1520
|
}
|
|
1523
1521
|
return restorePayloads(messages, payloads);
|
|
1524
1522
|
}
|
|
@@ -1530,8 +1528,7 @@ async function hydrateMessages(messages, backend, prefix, cache) {
|
|
|
1530
1528
|
function withoutBlobRefs(messages) {
|
|
1531
1529
|
return messages.some(messageHasRefs) ? restorePayloads(messages, /* @__PURE__ */ new Map()) : messages;
|
|
1532
1530
|
}
|
|
1533
|
-
|
|
1534
|
-
//#region src/middleware/unsupportedContent.ts
|
|
1531
|
+
// src/middleware/unsupportedContent.ts
|
|
1535
1532
|
const PDF_MIME_TYPE = "application/pdf";
|
|
1536
1533
|
/** Content block types `read_file` may emit that require multimodal model support. */
|
|
1537
1534
|
const MULTIMODAL_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1671,8 +1668,7 @@ function createUnsupportedContentMiddleware() {
|
|
|
1671
1668
|
}
|
|
1672
1669
|
});
|
|
1673
1670
|
}
|
|
1674
|
-
|
|
1675
|
-
//#region src/permissions/enforce.ts
|
|
1671
|
+
// src/permissions/enforce.ts
|
|
1676
1672
|
/**
|
|
1677
1673
|
* Validate permission rule paths at setup time. Throws if any path is
|
|
1678
1674
|
* relative, contains `..`, or contains `~`.
|
|
@@ -1727,8 +1723,7 @@ function decidePathAccess(rules, operation, path) {
|
|
|
1727
1723
|
}
|
|
1728
1724
|
return "allow";
|
|
1729
1725
|
}
|
|
1730
|
-
|
|
1731
|
-
//#region src/backends/composite.ts
|
|
1726
|
+
// src/backends/composite.ts
|
|
1732
1727
|
/**
|
|
1733
1728
|
* Backend that routes file operations to different backends based on path prefix.
|
|
1734
1729
|
*
|
|
@@ -2155,8 +2150,7 @@ var CompositeBackend = class {
|
|
|
2155
2150
|
return results;
|
|
2156
2151
|
}
|
|
2157
2152
|
};
|
|
2158
|
-
|
|
2159
|
-
//#region src/middleware/fs.ts
|
|
2153
|
+
// src/middleware/fs.ts
|
|
2160
2154
|
/**
|
|
2161
2155
|
* Middleware for providing filesystem tools to an agent.
|
|
2162
2156
|
*
|
|
@@ -2387,6 +2381,25 @@ function truncatePaginatedRead(body, readResult, options) {
|
|
|
2387
2381
|
*/
|
|
2388
2382
|
const GREP_TRUNCATION_NOTE = "Note: the search stopped early because it hit the maximum match count. The matches above are valid but incomplete. Narrow the search (a more specific pattern or a narrower path), or raise max_count, to see the rest.";
|
|
2389
2383
|
/**
|
|
2384
|
+
* Characters of a grep line shown to the model. Longer lines (minified JSON,
|
|
2385
|
+
* offloaded tool results) show a window around the match instead, so one hit
|
|
2386
|
+
* can't return the whole line.
|
|
2387
|
+
*/
|
|
2388
|
+
const GREP_LINE_CHAR_LIMIT = 2e3;
|
|
2389
|
+
/**
|
|
2390
|
+
* Clip `text` to a `GREP_LINE_CHAR_LIMIT` window centered on `pattern`,
|
|
2391
|
+
* falling back to the head of the line when `pattern` isn't found in it.
|
|
2392
|
+
*/
|
|
2393
|
+
function clipGrepLine(text, pattern) {
|
|
2394
|
+
if (text.length <= 2e3) return text;
|
|
2395
|
+
const center = Math.max(text.indexOf(pattern), 0) + Math.floor(pattern.length / 2);
|
|
2396
|
+
const start = Math.min(Math.max(center - GREP_LINE_CHAR_LIMIT / 2, 0), text.length - GREP_LINE_CHAR_LIMIT);
|
|
2397
|
+
const end = start + GREP_LINE_CHAR_LIMIT;
|
|
2398
|
+
const before = start > 0 ? `[${start} chars clipped] ` : "";
|
|
2399
|
+
const after = end < text.length ? ` [${text.length - end} chars clipped]` : "";
|
|
2400
|
+
return `${before}${text.slice(start, end)}${after}`;
|
|
2401
|
+
}
|
|
2402
|
+
/**
|
|
2390
2403
|
* Default cap on the number of matches the grep tool returns.
|
|
2391
2404
|
* Set to null to disable the cap.
|
|
2392
2405
|
*/
|
|
@@ -2602,11 +2615,11 @@ async function checkPermission(backend, rules, operation, path) {
|
|
|
2602
2615
|
return { path: canonical };
|
|
2603
2616
|
}
|
|
2604
2617
|
/**
|
|
2605
|
-
* Build an error {@link ToolMessage} for a
|
|
2606
|
-
* bare string would be wrapped as a `status: "success"`
|
|
2607
|
-
* merely starts with "Error:"; marking `status: "error"`
|
|
2608
|
-
* accurately so callers and the model can distinguish a
|
|
2609
|
-
* successful result.
|
|
2618
|
+
* Build an error {@link ToolMessage} for a denied path or a failed backend
|
|
2619
|
+
* operation. Returning a bare string would be wrapped as a `status: "success"`
|
|
2620
|
+
* message whose content merely starts with "Error:"; marking `status: "error"`
|
|
2621
|
+
* reports the failure accurately so callers and the model can distinguish a
|
|
2622
|
+
* real failure from a successful result.
|
|
2610
2623
|
*/
|
|
2611
2624
|
function toolError(runtime, toolName, message) {
|
|
2612
2625
|
return new langchain.ToolMessage({
|
|
@@ -3028,7 +3041,7 @@ function createWriteFileTool(backend, options) {
|
|
|
3028
3041
|
if (permission.error !== void 0) return toolError(runtime, "write_file", permission.error);
|
|
3029
3042
|
const { file_path, content } = input;
|
|
3030
3043
|
const result = await resolvedBackend.write(permission.path, content);
|
|
3031
|
-
if (result.error) return result.error;
|
|
3044
|
+
if (result.error) return toolError(runtime, "write_file", result.error);
|
|
3032
3045
|
const message = new langchain.ToolMessage({
|
|
3033
3046
|
content: `Successfully wrote to '${file_path}'`,
|
|
3034
3047
|
tool_call_id: runtime.toolCall?.id,
|
|
@@ -3060,7 +3073,7 @@ function createEditFileTool(backend, options) {
|
|
|
3060
3073
|
if (permission.error !== void 0) return toolError(runtime, "edit_file", permission.error);
|
|
3061
3074
|
const { file_path, old_string, new_string, replace_all = false } = input;
|
|
3062
3075
|
const result = await resolvedBackend.edit(permission.path, old_string, new_string, replace_all);
|
|
3063
|
-
if (result.error) return result.error;
|
|
3076
|
+
if (result.error) return toolError(runtime, "edit_file", result.error);
|
|
3064
3077
|
const message = new langchain.ToolMessage({
|
|
3065
3078
|
content: `Successfully replaced ${result.occurrences} occurrence(s) in '${file_path}'`,
|
|
3066
3079
|
tool_call_id: runtime.toolCall?.id,
|
|
@@ -3141,7 +3154,7 @@ function createGlobTool(backend, options) {
|
|
|
3141
3154
|
const permission = await checkPermission(resolvedBackend, permissions, "read", input.path ?? "/");
|
|
3142
3155
|
if (permission.error !== void 0) return toolError(runtime, "glob", permission.error);
|
|
3143
3156
|
const globResult = await resolvedBackend.glob(pattern, input.path === void 0 ? void 0 : permission.path);
|
|
3144
|
-
if (globResult.error) return `Error finding files: ${globResult.error}
|
|
3157
|
+
if (globResult.error) return toolError(runtime, "glob", `Error finding files: ${globResult.error}`);
|
|
3145
3158
|
const infos = await filterByPermissions(resolvedBackend, globResult.files ?? [], permissions, "read", (info) => info.path);
|
|
3146
3159
|
if (infos.length === 0) return `No files found matching pattern '${pattern}'`;
|
|
3147
3160
|
const result = truncateIfTooLong(infos.map((info) => info.path));
|
|
@@ -3168,10 +3181,13 @@ function createGrepTool(backend, options) {
|
|
|
3168
3181
|
if (permission.error !== void 0) return toolError(runtime, "grep", permission.error);
|
|
3169
3182
|
const maxCount = input.max_count ?? grepMaxCount;
|
|
3170
3183
|
const result = await resolvedBackend.grep(pattern, permission.path, glob, maxCount);
|
|
3171
|
-
if (result.error) return result.error;
|
|
3184
|
+
if (result.error) return toolError(runtime, "grep", result.error);
|
|
3172
3185
|
const matches = await filterByPermissions(resolvedBackend, result.matches ?? [], permissions, "read", (m) => m.path);
|
|
3173
3186
|
if (matches.length === 0) return `No matches found for pattern '${pattern}'`;
|
|
3174
|
-
const truncated = truncateIfTooLong(formatGrepMatches(matches
|
|
3187
|
+
const truncated = truncateIfTooLong(formatGrepMatches(matches.map((m) => ({
|
|
3188
|
+
...m,
|
|
3189
|
+
text: clipGrepLine(m.text, pattern)
|
|
3190
|
+
})), output_mode));
|
|
3175
3191
|
let content = typeof truncated === "string" ? truncated : truncated.join("\n");
|
|
3176
3192
|
if (result.truncated) content += `\n\n${GREP_TRUNCATION_NOTE}`;
|
|
3177
3193
|
return content;
|
|
@@ -3416,6 +3432,7 @@ function createFilesystemMiddleware(options = {}) {
|
|
|
3416
3432
|
}
|
|
3417
3433
|
return (0, langchain.createMiddleware)({
|
|
3418
3434
|
name: "FilesystemMiddleware",
|
|
3435
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
3419
3436
|
stateSchema: FilesystemStateSchema,
|
|
3420
3437
|
tools: allTools,
|
|
3421
3438
|
async beforeAgent(state) {
|
|
@@ -3546,8 +3563,7 @@ function createFilesystemMiddleware(options = {}) {
|
|
|
3546
3563
|
}
|
|
3547
3564
|
});
|
|
3548
3565
|
}
|
|
3549
|
-
|
|
3550
|
-
//#region src/middleware/summarization.ts
|
|
3566
|
+
// src/middleware/summarization.ts
|
|
3551
3567
|
/**
|
|
3552
3568
|
* Summarization middleware with backend support for conversation history offloading.
|
|
3553
3569
|
*
|
|
@@ -4105,10 +4121,7 @@ function createSummarizationMiddleware(options) {
|
|
|
4105
4121
|
</summary>
|
|
4106
4122
|
`;
|
|
4107
4123
|
else content = `Here is a summary of the conversation to date:\n\n${summary}`;
|
|
4108
|
-
return new langchain.HumanMessage({
|
|
4109
|
-
content,
|
|
4110
|
-
additional_kwargs: { lc_source: "summarization" }
|
|
4111
|
-
});
|
|
4124
|
+
return (0, _langchain_core_messages.addNotificationMetadata)(new langchain.HumanMessage({ content }), { source: "summarization" });
|
|
4112
4125
|
}
|
|
4113
4126
|
/**
|
|
4114
4127
|
* Summarize a set of messages using the given model and build the
|
|
@@ -4196,6 +4209,7 @@ function createSummarizationMiddleware(options) {
|
|
|
4196
4209
|
}
|
|
4197
4210
|
return (0, langchain.createMiddleware)({
|
|
4198
4211
|
name: "SummarizationMiddleware",
|
|
4212
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
4199
4213
|
stateSchema: SummarizationStateSchema,
|
|
4200
4214
|
async wrapModelCall(request, handler) {
|
|
4201
4215
|
const effectiveMessages = getEffectiveMessages(request.messages ?? [], request.state);
|
|
@@ -4240,8 +4254,7 @@ function createSummarizationMiddleware(options) {
|
|
|
4240
4254
|
}
|
|
4241
4255
|
});
|
|
4242
4256
|
}
|
|
4243
|
-
|
|
4244
|
-
//#region src/middleware/utils.ts
|
|
4257
|
+
// src/middleware/utils.ts
|
|
4245
4258
|
/**
|
|
4246
4259
|
* Utility functions for middleware.
|
|
4247
4260
|
*
|
|
@@ -4317,8 +4330,7 @@ function appendToSystemMessage(systemMessage, text) {
|
|
|
4317
4330
|
}
|
|
4318
4331
|
return new _langchain_core_messages.SystemMessage({ content: text });
|
|
4319
4332
|
}
|
|
4320
|
-
|
|
4321
|
-
//#region src/middleware/subagents.ts
|
|
4333
|
+
// src/middleware/subagents.ts
|
|
4322
4334
|
/**
|
|
4323
4335
|
* Config key used by task-tool callers to request dynamic response format.
|
|
4324
4336
|
*
|
|
@@ -4538,6 +4550,7 @@ const ForkedContextStateSchema = zod_v4.z.object({ [FORKED_CONTEXT_KEY]: zod_v4.
|
|
|
4538
4550
|
function createForkTaskToolMiddleware(taskTool) {
|
|
4539
4551
|
return (0, langchain.createMiddleware)({
|
|
4540
4552
|
name: "forkTaskToolMiddleware",
|
|
4553
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
4541
4554
|
stateSchema: ForkedContextStateSchema,
|
|
4542
4555
|
tools: [taskTool],
|
|
4543
4556
|
beforeAgent: () => ({ [FORKED_CONTEXT_KEY]: true })
|
|
@@ -4774,6 +4787,7 @@ function createSubAgentMiddleware(options) {
|
|
|
4774
4787
|
});
|
|
4775
4788
|
return (0, langchain.createMiddleware)({
|
|
4776
4789
|
name: "subAgentMiddleware",
|
|
4790
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
4777
4791
|
tools: [taskTool],
|
|
4778
4792
|
wrapModelCall: async (request, handler) => {
|
|
4779
4793
|
if (systemPrompt !== null) return handler({
|
|
@@ -4784,8 +4798,7 @@ function createSubAgentMiddleware(options) {
|
|
|
4784
4798
|
}
|
|
4785
4799
|
});
|
|
4786
4800
|
}
|
|
4787
|
-
|
|
4788
|
-
//#region src/middleware/patch_tool_calls.ts
|
|
4801
|
+
// src/middleware/patch_tool_calls.ts
|
|
4789
4802
|
/**
|
|
4790
4803
|
* Patch tool call / tool response parity in a messages array.
|
|
4791
4804
|
*
|
|
@@ -4879,6 +4892,7 @@ function patchDanglingToolCalls(messages) {
|
|
|
4879
4892
|
function createPatchToolCallsMiddleware() {
|
|
4880
4893
|
return (0, langchain.createMiddleware)({
|
|
4881
4894
|
name: "patchToolCallsMiddleware",
|
|
4895
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
4882
4896
|
beforeAgent: async (state) => {
|
|
4883
4897
|
const messages = state.messages;
|
|
4884
4898
|
if (!messages || messages.length === 0) return;
|
|
@@ -4908,8 +4922,7 @@ function createPatchToolCallsMiddleware() {
|
|
|
4908
4922
|
}
|
|
4909
4923
|
});
|
|
4910
4924
|
}
|
|
4911
|
-
|
|
4912
|
-
//#region src/values.ts
|
|
4925
|
+
// src/values.ts
|
|
4913
4926
|
/**
|
|
4914
4927
|
* Shared state values for use in StateSchema definitions.
|
|
4915
4928
|
*
|
|
@@ -4942,8 +4955,7 @@ const filesValue = new _langchain_langgraph.ReducedValue(zod.z.record(zod.z.stri
|
|
|
4942
4955
|
inputSchema: zod.z.record(zod.z.string(), FileDataSchema.nullable()).optional(),
|
|
4943
4956
|
reducer: fileDataReducer
|
|
4944
4957
|
});
|
|
4945
|
-
|
|
4946
|
-
//#region src/utils.ts
|
|
4958
|
+
// src/utils.ts
|
|
4947
4959
|
/**
|
|
4948
4960
|
* Detect whether a model is an Anthropic model.
|
|
4949
4961
|
*
|
|
@@ -5053,8 +5065,7 @@ function getModelProvider(model) {
|
|
|
5053
5065
|
function getModelIdentifier(model) {
|
|
5054
5066
|
return (model.getName() === "ConfigurableModel" ? model._defaultConfig : void 0)?.model ?? model.model_name ?? model.modelName ?? void 0;
|
|
5055
5067
|
}
|
|
5056
|
-
|
|
5057
|
-
//#region src/middleware/memory.ts
|
|
5068
|
+
// src/middleware/memory.ts
|
|
5058
5069
|
/**
|
|
5059
5070
|
* Middleware for loading agent memory/context from AGENTS.md files.
|
|
5060
5071
|
*
|
|
@@ -5240,6 +5251,7 @@ function createMemoryMiddleware(options) {
|
|
|
5240
5251
|
const { backend, sources, addCacheControl = false } = options;
|
|
5241
5252
|
return (0, langchain.createMiddleware)({
|
|
5242
5253
|
name: "MemoryMiddleware",
|
|
5254
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
5243
5255
|
stateSchema: MemoryStateSchema,
|
|
5244
5256
|
async beforeAgent(state) {
|
|
5245
5257
|
if ("memoryContents" in state && state.memoryContents != null) return;
|
|
@@ -5274,8 +5286,7 @@ function createMemoryMiddleware(options) {
|
|
|
5274
5286
|
}
|
|
5275
5287
|
});
|
|
5276
5288
|
}
|
|
5277
|
-
|
|
5278
|
-
//#region src/errors.ts
|
|
5289
|
+
// src/errors.ts
|
|
5279
5290
|
const CONFIGURATION_ERROR_SYMBOL = Symbol.for("deepagents.configuration_error");
|
|
5280
5291
|
/**
|
|
5281
5292
|
* Thrown when `createDeepAgent` receives invalid configuration.
|
|
@@ -5314,8 +5325,7 @@ var ConfigurationError = class ConfigurationError extends Error {
|
|
|
5314
5325
|
return typeof error === "object" && error !== null && error[CONFIGURATION_ERROR_SYMBOL] === true;
|
|
5315
5326
|
}
|
|
5316
5327
|
};
|
|
5317
|
-
|
|
5318
|
-
//#region src/middleware/skills.ts
|
|
5328
|
+
// src/middleware/skills.ts
|
|
5319
5329
|
/**
|
|
5320
5330
|
* Backend-agnostic skills middleware for loading agent skills from any backend.
|
|
5321
5331
|
*
|
|
@@ -5649,9 +5659,10 @@ function parseSkillMetadataFromContent(content, skillPath, directoryName) {
|
|
|
5649
5659
|
}
|
|
5650
5660
|
const rawTools = frontmatterData["allowed-tools"];
|
|
5651
5661
|
let allowedTools;
|
|
5652
|
-
if (rawTools)
|
|
5653
|
-
|
|
5654
|
-
|
|
5662
|
+
if (rawTools) {
|
|
5663
|
+
if (Array.isArray(rawTools)) allowedTools = rawTools.map((t) => String(t).trim()).filter(Boolean);
|
|
5664
|
+
else allowedTools = String(rawTools).split(/\s+/).filter(Boolean);
|
|
5665
|
+
} else allowedTools = [];
|
|
5655
5666
|
let compatibilityStr = String(frontmatterData.compatibility ?? "").trim() || null;
|
|
5656
5667
|
if (compatibilityStr && compatibilityStr.length > 500) {
|
|
5657
5668
|
console.warn(`Compatibility exceeds 500 characters in ${skillPath}, truncating`);
|
|
@@ -5774,17 +5785,15 @@ function buildPinnedSkillMessage(skill, content) {
|
|
|
5774
5785
|
const body = content.replace(FRONTMATTER_PATTERN, "").trimEnd();
|
|
5775
5786
|
const name = escapeXmlAttribute(skill.name);
|
|
5776
5787
|
const path = escapeXmlAttribute(skill.path);
|
|
5777
|
-
|
|
5788
|
+
const message = new _langchain_core_messages.HumanMessage({
|
|
5778
5789
|
content: `<skill name="${name}" path="${path}">\n${body}\n</skill>`,
|
|
5779
|
-
additional_kwargs: {
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
description: skill.description
|
|
5785
|
-
}
|
|
5786
|
-
}
|
|
5790
|
+
additional_kwargs: { skill: {
|
|
5791
|
+
name: skill.name,
|
|
5792
|
+
path: skill.path,
|
|
5793
|
+
description: skill.description
|
|
5794
|
+
} }
|
|
5787
5795
|
});
|
|
5796
|
+
return (0, _langchain_core_messages.addNotificationMetadata)(message, { source: "pinned_skill" });
|
|
5788
5797
|
}
|
|
5789
5798
|
/** Escape `value` for a double-quoted XML attribute. */
|
|
5790
5799
|
function escapeXmlAttribute(value) {
|
|
@@ -5852,20 +5861,6 @@ function validateModulePath(raw) {
|
|
|
5852
5861
|
}
|
|
5853
5862
|
/** Tool `extras` key (and provider field) that withholds a tool's schema until searched for. */
|
|
5854
5863
|
const DEFER_LOADING = "defer_loading";
|
|
5855
|
-
/**
|
|
5856
|
-
* Model ID prefixes that accept an inline `tool_definition` mid-conversation.
|
|
5857
|
-
*
|
|
5858
|
-
* `@langchain/anthropic` sends any mid-conversation system message in place,
|
|
5859
|
-
* without gating on the model, so this list is the only guard.
|
|
5860
|
-
*/
|
|
5861
|
-
const ANTHROPIC_INLINE_TOOL_MODELS = [
|
|
5862
|
-
"claude-opus-5",
|
|
5863
|
-
"claude-fable-5",
|
|
5864
|
-
"claude-mythos-5",
|
|
5865
|
-
"claude-opus-4-8"
|
|
5866
|
-
];
|
|
5867
|
-
/** Models whose Responses API accepts an `additional_tools` input item, matched with or without a `-` suffix such as a snapshot date. */
|
|
5868
|
-
const OPENAI_INLINE_TOOL_MODELS = ["gpt-6", "gpt-5.6"];
|
|
5869
5864
|
/** Root `input_schema` keys the Anthropic API rejects, failing the whole request. */
|
|
5870
5865
|
const ANTHROPIC_ROOT_COMBINATORS = [
|
|
5871
5866
|
"oneOf",
|
|
@@ -5980,14 +5975,14 @@ async function discloseSkillTools(request, reads, resolver) {
|
|
|
5980
5975
|
record: {}
|
|
5981
5976
|
};
|
|
5982
5977
|
const chatModel = await resolveChatModel(request.model, request.runtime);
|
|
5983
|
-
if (
|
|
5978
|
+
if (chatModel && getModelProvider(chatModel) === "anthropic") withholdRootCombinatorTools(disclosed);
|
|
5984
5979
|
const gatedNames = [...disclosed.keys()].filter((name) => disclosed.get(name).includeName !== void 0).sort();
|
|
5985
5980
|
const record = Object.fromEntries(gatedNames.map((name) => [name, disclosed.get(name).includeName]));
|
|
5986
5981
|
if (disclosed.size === 0) return {
|
|
5987
5982
|
request,
|
|
5988
5983
|
record
|
|
5989
5984
|
};
|
|
5990
|
-
const build = inlineBlockBuilder(chatModel);
|
|
5985
|
+
const build = chatModel && inlineBlockBuilder(chatModel);
|
|
5991
5986
|
if (build !== void 0) return {
|
|
5992
5987
|
request: {
|
|
5993
5988
|
...request,
|
|
@@ -6111,7 +6106,8 @@ function unwrapBinding(model) {
|
|
|
6111
6106
|
return _langchain_core_runnables.RunnableBinding.isRunnableBinding(model) ? model.bound : model;
|
|
6112
6107
|
}
|
|
6113
6108
|
/**
|
|
6114
|
-
* Return the concrete chat model a request will call
|
|
6109
|
+
* Return the concrete chat model a request will call, or `undefined` if it
|
|
6110
|
+
* isn't a chat model.
|
|
6115
6111
|
*
|
|
6116
6112
|
* Resolves a `ConfigurableModel`, which a string `model` always becomes, to
|
|
6117
6113
|
* the instance it will call with this run's `configurable`. Without
|
|
@@ -6121,29 +6117,40 @@ function unwrapBinding(model) {
|
|
|
6121
6117
|
*/
|
|
6122
6118
|
async function resolveChatModel(model, runtime) {
|
|
6123
6119
|
const current = unwrapBinding(model);
|
|
6124
|
-
if (current
|
|
6120
|
+
if (!isConfigurableModel(current)) return isBaseChatModel(current) ? current : void 0;
|
|
6125
6121
|
const configurable = runtime.configurable ?? {};
|
|
6126
|
-
const overrides = current._modelParams
|
|
6127
|
-
|
|
6122
|
+
const overrides = current._modelParams({ configurable });
|
|
6123
|
+
const instance = unwrapBinding(Object.keys(overrides).length > 0 ? await current._getModelInstance({ configurable }) : await current._getModelInstance());
|
|
6124
|
+
return isBaseChatModel(instance) ? instance : void 0;
|
|
6128
6125
|
}
|
|
6129
|
-
/**
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6126
|
+
/**
|
|
6127
|
+
* Duck-typed as langchain's own (unexported) `isConfigurableModel`, since an
|
|
6128
|
+
* `instanceof` check fails across copies of the package.
|
|
6129
|
+
*/
|
|
6130
|
+
function isConfigurableModel(model) {
|
|
6131
|
+
return typeof model === "object" && model !== null && "_queuedMethodOperations" in model && "_getModelInstance" in model && typeof model._getModelInstance === "function";
|
|
6132
|
+
}
|
|
6133
|
+
/**
|
|
6134
|
+
* Duck-typed as langchain's own (unexported) `isBaseChatModel`, since an
|
|
6135
|
+
* `instanceof` check fails across copies of `@langchain/core`.
|
|
6136
|
+
*/
|
|
6137
|
+
function isBaseChatModel(model) {
|
|
6138
|
+
return typeof model === "object" && model !== null && "_streamResponseChunks" in model && "_llmType" in model && typeof model._llmType === "function";
|
|
6133
6139
|
}
|
|
6134
6140
|
/**
|
|
6135
6141
|
* Return how `chatModel` is given a tool mid-conversation, or `undefined` if
|
|
6136
6142
|
* it can't be.
|
|
6137
6143
|
*
|
|
6138
|
-
* The
|
|
6139
|
-
*
|
|
6144
|
+
* The profile's `midConversationTools` decides whether, and the provider
|
|
6145
|
+
* decides the block.
|
|
6140
6146
|
*/
|
|
6141
6147
|
function inlineBlockBuilder(chatModel) {
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6148
|
+
if (!chatModel.profile.midConversationTools) return void 0;
|
|
6149
|
+
switch (getModelProvider(chatModel)) {
|
|
6150
|
+
case "anthropic": return anthropicToolAddition;
|
|
6151
|
+
case "openai": return openaiAdditionalTools;
|
|
6152
|
+
default: return;
|
|
6153
|
+
}
|
|
6147
6154
|
}
|
|
6148
6155
|
/**
|
|
6149
6156
|
* Return the definition `ChatAnthropic` sends in `tools` for `tool`, without
|
|
@@ -6274,6 +6281,7 @@ function createSkillsMiddleware(options) {
|
|
|
6274
6281
|
const hasSkillTools = typeof options.tools === "function" || Array.isArray(options.tools) && options.tools.length > 0;
|
|
6275
6282
|
return (0, langchain.createMiddleware)({
|
|
6276
6283
|
name: "SkillsMiddleware",
|
|
6284
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
6277
6285
|
stateSchema: SkillsStateSchema,
|
|
6278
6286
|
async beforeModel(state) {
|
|
6279
6287
|
const needsLoad = state.skillsMetadata === null || state.skillsMetadata === void 0;
|
|
@@ -6328,8 +6336,7 @@ function createSkillsMiddleware(options) {
|
|
|
6328
6336
|
}
|
|
6329
6337
|
});
|
|
6330
6338
|
}
|
|
6331
|
-
|
|
6332
|
-
//#region src/middleware/completion_callback.ts
|
|
6339
|
+
// src/middleware/completion_callback.ts
|
|
6333
6340
|
/**
|
|
6334
6341
|
* Callback middleware for async subagents.
|
|
6335
6342
|
*
|
|
@@ -6546,6 +6553,7 @@ function createCompletionCallbackMiddleware(options) {
|
|
|
6546
6553
|
}
|
|
6547
6554
|
return (0, langchain.createMiddleware)({
|
|
6548
6555
|
name: "CompletionCallbackMiddleware",
|
|
6556
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
6549
6557
|
stateSchema: CompletionCallbackStateSchema,
|
|
6550
6558
|
/**
|
|
6551
6559
|
* After-agent hook: fires when the subagent completes successfully.
|
|
@@ -6577,8 +6585,7 @@ function createCompletionCallbackMiddleware(options) {
|
|
|
6577
6585
|
}
|
|
6578
6586
|
});
|
|
6579
6587
|
}
|
|
6580
|
-
|
|
6581
|
-
//#region src/middleware/async_subagents.ts
|
|
6588
|
+
// src/middleware/async_subagents.ts
|
|
6582
6589
|
function toolCallIdFromRuntime(runtime) {
|
|
6583
6590
|
return runtime.toolCall?.id ?? runtime.toolCallId ?? "";
|
|
6584
6591
|
}
|
|
@@ -7051,8 +7058,15 @@ function launchingAgent(config) {
|
|
|
7051
7058
|
if (metadata.parent_assistant_id) fallback.assistant_id = String(metadata.parent_assistant_id);
|
|
7052
7059
|
return fallback;
|
|
7053
7060
|
}
|
|
7054
|
-
/**
|
|
7061
|
+
/** `lc_source` of a task notification; its `lc_data` is the {@link TaskEvent}. */
|
|
7062
|
+
const NOTIFICATION_SOURCE = "async_subagent";
|
|
7063
|
+
/**
|
|
7064
|
+
* `additional_kwargs` key carrying a notification's {@link TaskEvent}; still written, and read when a message has no `async_subagent` event.
|
|
7065
|
+
*
|
|
7066
|
+
* @deprecated Read `getNotificationMetadata(message)?.data` where `source` is `"async_subagent"`.
|
|
7067
|
+
*/
|
|
7055
7068
|
const NOTIFICATION_KEY = "deepagents_notification";
|
|
7069
|
+
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.";
|
|
7056
7070
|
/** Results longer than this are cut in notifications, matching the limit for large tool results. */
|
|
7057
7071
|
const MAX_RESULT_CHARS = 8e4;
|
|
7058
7072
|
const NEXT_STEP = {
|
|
@@ -7094,23 +7108,24 @@ function resultBlocks(blocks) {
|
|
|
7094
7108
|
else if (MEDIA_BLOCK_TYPES.has(block.type)) kept.push({ ...block });
|
|
7095
7109
|
return kept;
|
|
7096
7110
|
}
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
*
|
|
7100
|
-
* The result keeps its own content blocks, so an image reaches the model as an image.
|
|
7101
|
-
*/
|
|
7102
|
-
function notificationContent(update) {
|
|
7103
|
-
const blocks = [notificationHeader(update)];
|
|
7111
|
+
function notificationBody(update) {
|
|
7112
|
+
const blocks = [taskHeader(update)];
|
|
7104
7113
|
if (update.result) blocks.push(textBlock("<result>\n"), ...resultBlocks(update.result), textBlock("\n</result>\n"));
|
|
7105
7114
|
const details = Object.fromEntries(["error", "interrupts"].filter((key) => update[key] !== void 0).map((key) => [key, update[key]]));
|
|
7106
7115
|
if (Object.keys(details).length > 0) blocks.push(textBlock(`<details>${escape(clip(JSON.stringify(details)))}</details>\n`));
|
|
7107
7116
|
blocks.push(textBlock(`</task-notification>\n${NEXT_STEP[update.status]}`));
|
|
7108
7117
|
return blocks;
|
|
7109
7118
|
}
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7119
|
+
/** `blocks` under the note and task header, labeled with `event`. */
|
|
7120
|
+
function labeled(blocks, event) {
|
|
7121
|
+
const header = textBlock(`${NOTIFICATION_NOTE}\n`);
|
|
7122
|
+
return (0, _langchain_core_messages.addNotificationMetadata)(new _langchain_core_messages.HumanMessage({ content: [header, ...blocks] }), {
|
|
7123
|
+
source: NOTIFICATION_SOURCE,
|
|
7124
|
+
data: { ...event }
|
|
7125
|
+
});
|
|
7126
|
+
}
|
|
7127
|
+
function taskHeader(event) {
|
|
7128
|
+
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`);
|
|
7114
7129
|
}
|
|
7115
7130
|
/**
|
|
7116
7131
|
* Reframe an earlier run's notification so the model doesn't think the queued follow-up finished.
|
|
@@ -7120,7 +7135,7 @@ An async subagent task you started has an update. This is not a message from the
|
|
|
7120
7135
|
function supersededNotificationContent(message, event) {
|
|
7121
7136
|
const content = message.content;
|
|
7122
7137
|
const closing = Array.isArray(content) ? content.at(-1) : void 0;
|
|
7123
|
-
return [...closing?.type === "text" && String(closing.text).startsWith("</task-notification>") ? content.slice(0, -1) : [
|
|
7138
|
+
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.")];
|
|
7124
7139
|
}
|
|
7125
7140
|
/** Describe a failure without its message, which can carry internals into the parent's conversation. */
|
|
7126
7141
|
function failureText(error) {
|
|
@@ -7173,21 +7188,32 @@ function finalContent(values) {
|
|
|
7173
7188
|
}
|
|
7174
7189
|
/** The task event a notification message carries, or `null` for any other message. */
|
|
7175
7190
|
function notificationEvent(message) {
|
|
7176
|
-
|
|
7191
|
+
if (message === void 0) return null;
|
|
7192
|
+
const metadata = (0, _langchain_core_messages.getNotificationMetadata)(message);
|
|
7193
|
+
const event = (metadata?.source === NOTIFICATION_SOURCE ? metadata.data : void 0) ?? message.additional_kwargs?.["deepagents_notification"];
|
|
7177
7194
|
return event && typeof event === "object" && !Array.isArray(event) ? event : null;
|
|
7178
7195
|
}
|
|
7179
|
-
/**
|
|
7180
|
-
function
|
|
7196
|
+
/** The {@link TaskEvent} fields of a task update. */
|
|
7197
|
+
function eventOf(update) {
|
|
7181
7198
|
const event = {
|
|
7182
7199
|
task_id: update.task_id,
|
|
7183
7200
|
agent_name: update.agent_name,
|
|
7184
7201
|
status: update.status
|
|
7185
7202
|
};
|
|
7186
7203
|
if (update.run_id) event.run_id = update.run_id;
|
|
7204
|
+
return event;
|
|
7205
|
+
}
|
|
7206
|
+
/** A task update as the message the parent's model sees, labeled with its {@link TaskEvent}. */
|
|
7207
|
+
function notificationMessage(update) {
|
|
7208
|
+
const event = eventOf(update);
|
|
7209
|
+
const message = labeled(notificationBody(update), event);
|
|
7187
7210
|
return {
|
|
7188
7211
|
role: "user",
|
|
7189
|
-
content:
|
|
7190
|
-
additional_kwargs: {
|
|
7212
|
+
content: message.content,
|
|
7213
|
+
additional_kwargs: {
|
|
7214
|
+
...message.additional_kwargs,
|
|
7215
|
+
[NOTIFICATION_KEY]: event
|
|
7216
|
+
}
|
|
7191
7217
|
};
|
|
7192
7218
|
}
|
|
7193
7219
|
/** Parent thread statuses a notification run can start on: neither running nor waiting for a human. */
|
|
@@ -7646,6 +7672,7 @@ function createAsyncSubAgentMiddleware(options) {
|
|
|
7646
7672
|
const fullSystemPrompt = systemPrompt ? `${systemPrompt}\n\nAvailable async subagent types:\n${agentsDescription}` : null;
|
|
7647
7673
|
return (0, langchain.createMiddleware)({
|
|
7648
7674
|
name: "asyncSubAgentMiddleware",
|
|
7675
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
7649
7676
|
stateSchema: AsyncTaskStateSchema,
|
|
7650
7677
|
tools,
|
|
7651
7678
|
beforeAgent: async (state) => {
|
|
@@ -7692,8 +7719,7 @@ function createAsyncSubAgentMiddleware(options) {
|
|
|
7692
7719
|
}
|
|
7693
7720
|
});
|
|
7694
7721
|
}
|
|
7695
|
-
|
|
7696
|
-
//#region src/middleware/cache.ts
|
|
7722
|
+
// src/middleware/cache.ts
|
|
7697
7723
|
/**
|
|
7698
7724
|
* Creates a middleware that places a cache breakpoint at the end of the static
|
|
7699
7725
|
* system prompt content.
|
|
@@ -7723,6 +7749,7 @@ function createAsyncSubAgentMiddleware(options) {
|
|
|
7723
7749
|
function createCacheBreakpointMiddleware() {
|
|
7724
7750
|
return (0, langchain.createMiddleware)({
|
|
7725
7751
|
name: "CacheBreakpointMiddleware",
|
|
7752
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
7726
7753
|
wrapModelCall(request, handler) {
|
|
7727
7754
|
if (!isAnthropicModel(request.model)) return handler(request);
|
|
7728
7755
|
const existingContent = request.systemMessage.content;
|
|
@@ -7742,8 +7769,7 @@ function createCacheBreakpointMiddleware() {
|
|
|
7742
7769
|
}
|
|
7743
7770
|
});
|
|
7744
7771
|
}
|
|
7745
|
-
|
|
7746
|
-
//#region src/middleware/parent_notifier.ts
|
|
7772
|
+
// src/middleware/parent_notifier.ts
|
|
7747
7773
|
/** Whether this is the outermost graph of a task run, not a graph nested in it. */
|
|
7748
7774
|
function isTopLevelGraph(config) {
|
|
7749
7775
|
const configurable = config.configurable ?? {};
|
|
@@ -7776,6 +7802,7 @@ function createParentNotifierMiddleware() {
|
|
|
7776
7802
|
}
|
|
7777
7803
|
return (0, langchain.createMiddleware)({
|
|
7778
7804
|
name: "parentNotifierMiddleware",
|
|
7805
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
7779
7806
|
afterAgent: async (state) => {
|
|
7780
7807
|
await report("success", { result: finalContent(state) });
|
|
7781
7808
|
},
|
|
@@ -7789,8 +7816,7 @@ function createParentNotifierMiddleware() {
|
|
|
7789
7816
|
}
|
|
7790
7817
|
});
|
|
7791
7818
|
}
|
|
7792
|
-
|
|
7793
|
-
//#region src/middleware/tool_exclusion.ts
|
|
7819
|
+
// src/middleware/tool_exclusion.ts
|
|
7794
7820
|
function hasToolName(tool) {
|
|
7795
7821
|
return tool !== null && typeof tool === "object" && "name" in tool && typeof tool.name === "string";
|
|
7796
7822
|
}
|
|
@@ -7804,6 +7830,7 @@ function hasToolName(tool) {
|
|
|
7804
7830
|
function createToolExclusionMiddleware(excludedTools) {
|
|
7805
7831
|
return (0, langchain.createMiddleware)({
|
|
7806
7832
|
name: "_ToolExclusionMiddleware",
|
|
7833
|
+
tracePolicy: { processInputs: _langchain_core_tracers_tracer_langchain.omitPayload },
|
|
7807
7834
|
wrapModelCall(request, handler) {
|
|
7808
7835
|
return handler({
|
|
7809
7836
|
...request,
|
|
@@ -7822,8 +7849,7 @@ function createToolExclusionMiddleware(excludedTools) {
|
|
|
7822
7849
|
}
|
|
7823
7850
|
});
|
|
7824
7851
|
}
|
|
7825
|
-
|
|
7826
|
-
//#region src/profiles/keys.ts
|
|
7852
|
+
// src/profiles/keys.ts
|
|
7827
7853
|
/**
|
|
7828
7854
|
* Normalize and validate a profile registry key.
|
|
7829
7855
|
*
|
|
@@ -7853,8 +7879,7 @@ function validateProfileKey(key) {
|
|
|
7853
7879
|
}
|
|
7854
7880
|
return trimmed;
|
|
7855
7881
|
}
|
|
7856
|
-
|
|
7857
|
-
//#region src/profiles/harness/types.ts
|
|
7882
|
+
// src/profiles/harness/types.ts
|
|
7858
7883
|
/**
|
|
7859
7884
|
* Middleware names that provide essential agent capabilities and cannot
|
|
7860
7885
|
* be excluded via `excludedMiddleware`.
|
|
@@ -7885,8 +7910,7 @@ function resolveMiddleware(middleware) {
|
|
|
7885
7910
|
if (typeof middleware === "function") return middleware();
|
|
7886
7911
|
return middleware;
|
|
7887
7912
|
}
|
|
7888
|
-
|
|
7889
|
-
//#region src/profiles/harness/create.ts
|
|
7913
|
+
// src/profiles/harness/create.ts
|
|
7890
7914
|
/**
|
|
7891
7915
|
* Validate the grammar of an `excludedMiddleware` entry.
|
|
7892
7916
|
*
|
|
@@ -7948,8 +7972,7 @@ function createHarnessProfile(options = {}) {
|
|
|
7948
7972
|
* profile matches. Avoids creating a new object on every miss.
|
|
7949
7973
|
*/
|
|
7950
7974
|
const EMPTY_HARNESS_PROFILE = createHarnessProfile();
|
|
7951
|
-
|
|
7952
|
-
//#region src/profiles/harness/serialization.ts
|
|
7975
|
+
// src/profiles/harness/serialization.ts
|
|
7953
7976
|
const POISONED_KEYS = /* @__PURE__ */ new Set([
|
|
7954
7977
|
"__proto__",
|
|
7955
7978
|
"constructor",
|
|
@@ -8055,8 +8078,7 @@ function serializeProfile(profile) {
|
|
|
8055
8078
|
}
|
|
8056
8079
|
return result;
|
|
8057
8080
|
}
|
|
8058
|
-
|
|
8059
|
-
//#region src/profiles/harness/merge.ts
|
|
8081
|
+
// src/profiles/harness/merge.ts
|
|
8060
8082
|
/**
|
|
8061
8083
|
* Merge two middleware sequences by `.name`.
|
|
8062
8084
|
*
|
|
@@ -8141,8 +8163,7 @@ function mergeProfiles(base, override) {
|
|
|
8141
8163
|
generalPurposeSubagent: mergeGeneralPurposeSubagentConfigs(base.generalPurposeSubagent, override.generalPurposeSubagent)
|
|
8142
8164
|
});
|
|
8143
8165
|
}
|
|
8144
|
-
|
|
8145
|
-
//#region src/profiles/harness/builtins/anthropic-opus-4-7.ts
|
|
8166
|
+
// src/profiles/harness/builtins/anthropic-opus-4-7.ts
|
|
8146
8167
|
const SYSTEM_PROMPT_SUFFIX$3 = `\
|
|
8147
8168
|
<use_parallel_tool_calls>
|
|
8148
8169
|
If you intend to call multiple tools and there are no dependencies between the tool calls, make all of the independent tool calls in parallel. Prioritize calling tools simultaneously whenever the actions can be done in parallel rather than sequentially. For example, when reading 3 files, run 3 tool calls in parallel to read all 3 files into context at the same time. Maximize use of parallel tool calls where possible to increase speed and efficiency. However, if some tool calls depend on previous calls to inform dependent values like the parameters, do NOT call these tools in parallel and instead call them sequentially. Never use placeholders or guess missing parameters in tool calls.
|
|
@@ -8178,8 +8199,7 @@ Spawn multiple subagents in the same turn when fanning out across items or readi
|
|
|
8178
8199
|
function register$3() {
|
|
8179
8200
|
registerHarnessProfileImpl("anthropic:claude-opus-4-7", createHarnessProfile({ systemPromptSuffix: SYSTEM_PROMPT_SUFFIX$3 }));
|
|
8180
8201
|
}
|
|
8181
|
-
|
|
8182
|
-
//#region src/profiles/harness/builtins/anthropic-sonnet-4-6.ts
|
|
8202
|
+
// src/profiles/harness/builtins/anthropic-sonnet-4-6.ts
|
|
8183
8203
|
const SYSTEM_PROMPT_SUFFIX$2 = `\
|
|
8184
8204
|
<use_parallel_tool_calls>
|
|
8185
8205
|
If you intend to call multiple tools and there are no dependencies between the tool calls, make all of the independent tool calls in parallel. Prioritize calling tools simultaneously whenever the actions can be done in parallel rather than sequentially. For example, when reading 3 files, run 3 tool calls in parallel to read all 3 files into context at the same time. Maximize use of parallel tool calls where possible to increase speed and efficiency. However, if some tool calls depend on previous calls to inform dependent values like the parameters, do NOT call these tools in parallel and instead call them sequentially. Never use placeholders or guess missing parameters in tool calls.
|
|
@@ -8209,8 +8229,7 @@ After receiving tool results, carefully reflect on their quality and determine o
|
|
|
8209
8229
|
function register$2() {
|
|
8210
8230
|
registerHarnessProfileImpl("anthropic:claude-sonnet-4-6", createHarnessProfile({ systemPromptSuffix: SYSTEM_PROMPT_SUFFIX$2 }));
|
|
8211
8231
|
}
|
|
8212
|
-
|
|
8213
|
-
//#region src/profiles/harness/builtins/anthropic-haiku-4-5.ts
|
|
8232
|
+
// src/profiles/harness/builtins/anthropic-haiku-4-5.ts
|
|
8214
8233
|
const SYSTEM_PROMPT_SUFFIX$1 = `\
|
|
8215
8234
|
<use_parallel_tool_calls>
|
|
8216
8235
|
If you intend to call multiple tools and there are no dependencies between the tool calls, make all of the independent tool calls in parallel. Prioritize calling tools simultaneously whenever the actions can be done in parallel rather than sequentially. For example, when reading 3 files, run 3 tool calls in parallel to read all 3 files into context at the same time. Maximize use of parallel tool calls where possible to increase speed and efficiency. However, if some tool calls depend on previous calls to inform dependent values like the parameters, do NOT call these tools in parallel and instead call them sequentially. Never use placeholders or guess missing parameters in tool calls.
|
|
@@ -8234,8 +8253,7 @@ After receiving tool results, carefully reflect on their quality and determine o
|
|
|
8234
8253
|
function register$1() {
|
|
8235
8254
|
registerHarnessProfileImpl("anthropic:claude-haiku-4-5", createHarnessProfile({ systemPromptSuffix: SYSTEM_PROMPT_SUFFIX$1 }));
|
|
8236
8255
|
}
|
|
8237
|
-
|
|
8238
|
-
//#region src/profiles/harness/builtins/openai-codex.ts
|
|
8256
|
+
// src/profiles/harness/builtins/openai-codex.ts
|
|
8239
8257
|
/**
|
|
8240
8258
|
* Model specs that receive the Codex harness profile.
|
|
8241
8259
|
*
|
|
@@ -8292,8 +8310,7 @@ function register() {
|
|
|
8292
8310
|
});
|
|
8293
8311
|
for (const spec of CODEX_MODEL_SPECS) registerHarnessProfileImpl(spec, profile);
|
|
8294
8312
|
}
|
|
8295
|
-
|
|
8296
|
-
//#region src/profiles/harness/builtins/index.ts
|
|
8313
|
+
// src/profiles/harness/builtins/index.ts
|
|
8297
8314
|
/**
|
|
8298
8315
|
* Register all built-in harness profiles and snapshot the resulting
|
|
8299
8316
|
* registry keys as the builtin baseline.
|
|
@@ -8311,8 +8328,7 @@ function loadBuiltinProfiles() {
|
|
|
8311
8328
|
register();
|
|
8312
8329
|
snapshotBuiltinKeys();
|
|
8313
8330
|
}
|
|
8314
|
-
|
|
8315
|
-
//#region src/profiles/harness/registry.ts
|
|
8331
|
+
// src/profiles/harness/registry.ts
|
|
8316
8332
|
/**
|
|
8317
8333
|
* Process-global symbol key for the harness profile registry. The `.v1`
|
|
8318
8334
|
* suffix is a version gate — bump it when the {@link HarnessProfileRegistry}
|
|
@@ -8495,8 +8511,7 @@ function applyProfilePrompt(profile, basePrompt) {
|
|
|
8495
8511
|
if (profile.systemPromptSuffix !== void 0) return prompt ? `${prompt}\n\n${profile.systemPromptSuffix}` : profile.systemPromptSuffix;
|
|
8496
8512
|
return prompt;
|
|
8497
8513
|
}
|
|
8498
|
-
|
|
8499
|
-
//#region src/agent.ts
|
|
8514
|
+
// src/agent.ts
|
|
8500
8515
|
function normalizeSystemPrompt(systemPrompt) {
|
|
8501
8516
|
if (systemPrompt === void 0) return {};
|
|
8502
8517
|
if (typeof systemPrompt === "string" || langchain.SystemMessage.isInstance(systemPrompt)) return { prefix: systemPrompt };
|
|
@@ -8744,8 +8759,7 @@ function createDeepAgent(params = {}) {
|
|
|
8744
8759
|
}
|
|
8745
8760
|
});
|
|
8746
8761
|
}
|
|
8747
|
-
|
|
8748
|
-
//#region src/compat.ts
|
|
8762
|
+
// src/compat.ts
|
|
8749
8763
|
/**
|
|
8750
8764
|
* @deprecated Legacy prompt compatibility exports.
|
|
8751
8765
|
*
|
|
@@ -8878,8 +8892,7 @@ const EXECUTION_SYSTEM_PROMPT = langchain.context`
|
|
|
8878
8892
|
|
|
8879
8893
|
- execute: run a shell command in the sandbox (returns output and exit code)
|
|
8880
8894
|
`;
|
|
8881
|
-
|
|
8882
|
-
//#region src/backends/store.ts
|
|
8895
|
+
// src/backends/store.ts
|
|
8883
8896
|
/**
|
|
8884
8897
|
* StoreBackend: Adapter for LangGraph's BaseStore (persistent, cross-thread).
|
|
8885
8898
|
*/
|
|
@@ -9378,8 +9391,7 @@ var StoreBackend = class {
|
|
|
9378
9391
|
return responses;
|
|
9379
9392
|
}
|
|
9380
9393
|
};
|
|
9381
|
-
|
|
9382
|
-
//#region src/backends/context-hub.ts
|
|
9394
|
+
// src/backends/context-hub.ts
|
|
9383
9395
|
/**
|
|
9384
9396
|
* ContextHubBackend: Store files in a LangSmith Hub agent repo (persistent).
|
|
9385
9397
|
*/
|
|
@@ -10149,8 +10161,7 @@ var ContextHubBackend = class ContextHubBackend {
|
|
|
10149
10161
|
});
|
|
10150
10162
|
}
|
|
10151
10163
|
};
|
|
10152
|
-
|
|
10153
|
-
//#region src/backends/sandbox.ts
|
|
10164
|
+
// src/backends/sandbox.ts
|
|
10154
10165
|
/**
|
|
10155
10166
|
* Shell-quote a string using single quotes (POSIX).
|
|
10156
10167
|
* Escapes embedded single quotes with the '\'' technique.
|
|
@@ -10172,17 +10183,18 @@ function globToPathRegex(pattern) {
|
|
|
10172
10183
|
let i = 0;
|
|
10173
10184
|
while (i < pattern.length) {
|
|
10174
10185
|
const c = pattern[i];
|
|
10175
|
-
if (c === "*")
|
|
10176
|
-
i
|
|
10177
|
-
|
|
10178
|
-
|
|
10186
|
+
if (c === "*") {
|
|
10187
|
+
if (i + 1 < pattern.length && pattern[i + 1] === "*") {
|
|
10188
|
+
i += 2;
|
|
10189
|
+
if (i < pattern.length && pattern[i] === "/") {
|
|
10190
|
+
regex += "(.*/)?";
|
|
10191
|
+
i++;
|
|
10192
|
+
} else regex += ".*";
|
|
10193
|
+
} else {
|
|
10194
|
+
regex += "[^/]*";
|
|
10179
10195
|
i++;
|
|
10180
|
-
}
|
|
10181
|
-
} else {
|
|
10182
|
-
regex += "[^/]*";
|
|
10183
|
-
i++;
|
|
10184
|
-
}
|
|
10185
|
-
else if (c === "?") {
|
|
10196
|
+
}
|
|
10197
|
+
} else if (c === "?") {
|
|
10186
10198
|
regex += "[^/]";
|
|
10187
10199
|
i++;
|
|
10188
10200
|
} else if (c === "[") {
|
|
@@ -10644,8 +10656,7 @@ var BaseSandbox = class {
|
|
|
10644
10656
|
};
|
|
10645
10657
|
}
|
|
10646
10658
|
};
|
|
10647
|
-
|
|
10648
|
-
//#region src/backends/langsmith.ts
|
|
10659
|
+
// src/backends/langsmith.ts
|
|
10649
10660
|
/**
|
|
10650
10661
|
* LangSmith Sandbox backend for deepagents.
|
|
10651
10662
|
*
|
|
@@ -10844,7 +10855,6 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
10844
10855
|
});
|
|
10845
10856
|
}
|
|
10846
10857
|
};
|
|
10847
|
-
//#endregion
|
|
10848
10858
|
Object.defineProperty(exports, "ASYNC_TASK_SYSTEM_PROMPT", {
|
|
10849
10859
|
enumerable: true,
|
|
10850
10860
|
get: function() {
|
|
@@ -11206,4 +11216,4 @@ Object.defineProperty(exports, "skillsMetadataValue", {
|
|
|
11206
11216
|
}
|
|
11207
11217
|
});
|
|
11208
11218
|
|
|
11209
|
-
//# sourceMappingURL=langsmith-
|
|
11219
|
+
//# sourceMappingURL=langsmith-CAjAu64d.cjs.map
|