deepagents 1.8.6 → 1.8.8
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/index.cjs +91 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -26
- package/dist/index.d.ts +28 -26
- package/dist/index.js +91 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as zod_v30 from "zod/v3";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _langchain from "langchain";
|
|
3
3
|
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, CreateAgentParams, HumanMessage, InferMiddlewareStates, InterruptOnConfig, ProviderStrategy, ReactAgent, ResponseFormat, ResponseFormatUndefined, Runtime, StructuredTool, SystemMessage, ToolMessage, ToolStrategy } from "langchain";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _langgraph from "@langchain/langgraph";
|
|
5
5
|
import { AnnotationRoot, Command, ReducedValue, StateSchema } from "@langchain/langgraph";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
7
|
import * as _langchain_core_tools0 from "@langchain/core/tools";
|
|
@@ -475,19 +475,21 @@ interface FilesystemMiddlewareOptions {
|
|
|
475
475
|
customToolDescriptions?: Record<string, string> | null;
|
|
476
476
|
/** Optional token limit before evicting a tool result to the filesystem (default: 20000 tokens, ~80KB) */
|
|
477
477
|
toolTokenLimitBeforeEvict?: number | null;
|
|
478
|
+
/** Optional token limit before evicting a HumanMessage to the filesystem (default: 50000 tokens, ~200KB) */
|
|
479
|
+
humanMessageTokenLimitBeforeEvict?: number | null;
|
|
478
480
|
}
|
|
479
481
|
/**
|
|
480
482
|
* Create filesystem middleware with all tools and features.
|
|
481
483
|
*/
|
|
482
484
|
declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOptions): AgentMiddleware<StateSchema<{
|
|
483
485
|
files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
484
|
-
}>, undefined, unknown, (
|
|
486
|
+
}>, undefined, unknown, (_langchain.DynamicStructuredTool<z.ZodObject<{
|
|
485
487
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
486
488
|
}, z.core.$strip>, {
|
|
487
489
|
path: string;
|
|
488
490
|
}, {
|
|
489
491
|
path?: string | undefined;
|
|
490
|
-
}, string, unknown, "ls"> |
|
|
492
|
+
}, string, unknown, "ls"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
491
493
|
file_path: z.ZodString;
|
|
492
494
|
offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
493
495
|
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
@@ -499,7 +501,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
499
501
|
file_path: string;
|
|
500
502
|
offset?: unknown;
|
|
501
503
|
limit?: unknown;
|
|
502
|
-
}, string, unknown, "read_file"> |
|
|
504
|
+
}, string, unknown, "read_file"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
503
505
|
file_path: z.ZodString;
|
|
504
506
|
content: z.ZodDefault<z.ZodString>;
|
|
505
507
|
}, z.core.$strip>, {
|
|
@@ -511,7 +513,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
511
513
|
}, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
|
|
512
514
|
files: Record<string, FileData>;
|
|
513
515
|
messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
514
|
-
}, string>, unknown, "write_file"> |
|
|
516
|
+
}, string>, unknown, "write_file"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
515
517
|
file_path: z.ZodString;
|
|
516
518
|
old_string: z.ZodString;
|
|
517
519
|
new_string: z.ZodString;
|
|
@@ -529,7 +531,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
529
531
|
}, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
|
|
530
532
|
files: Record<string, FileData>;
|
|
531
533
|
messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
532
|
-
}, string>, unknown, "edit_file"> |
|
|
534
|
+
}, string>, unknown, "edit_file"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
533
535
|
pattern: z.ZodString;
|
|
534
536
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
535
537
|
}, z.core.$strip>, {
|
|
@@ -538,7 +540,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
538
540
|
}, {
|
|
539
541
|
pattern: string;
|
|
540
542
|
path?: string | undefined;
|
|
541
|
-
}, string, unknown, "glob"> |
|
|
543
|
+
}, string, unknown, "glob"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
542
544
|
pattern: z.ZodString;
|
|
543
545
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
544
546
|
glob: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -550,7 +552,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
550
552
|
pattern: string;
|
|
551
553
|
path?: string | undefined;
|
|
552
554
|
glob?: string | null | undefined;
|
|
553
|
-
}, string, unknown, "grep"> |
|
|
555
|
+
}, string, unknown, "grep"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
554
556
|
command: z.ZodString;
|
|
555
557
|
}, z.core.$strip>, {
|
|
556
558
|
command: string;
|
|
@@ -759,7 +761,7 @@ interface SubAgentMiddlewareOptions {
|
|
|
759
761
|
/**
|
|
760
762
|
* Create subagent middleware with task tool
|
|
761
763
|
*/
|
|
762
|
-
declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [
|
|
764
|
+
declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [_langchain.DynamicStructuredTool<z.ZodObject<{
|
|
763
765
|
description: z.ZodString;
|
|
764
766
|
subagent_type: z.ZodString;
|
|
765
767
|
}, z.core.$strip>, {
|
|
@@ -941,7 +943,7 @@ declare function createMemoryMiddleware(options: MemoryMiddlewareOptions): Agent
|
|
|
941
943
|
* Marked as private so it's not included in the final agent state.
|
|
942
944
|
*/
|
|
943
945
|
memoryContents: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
944
|
-
files:
|
|
946
|
+
files: _langgraph.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
945
947
|
}>, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
|
|
946
948
|
//#endregion
|
|
947
949
|
//#region src/middleware/skills.d.ts
|
|
@@ -2224,7 +2226,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2224
2226
|
content: string;
|
|
2225
2227
|
status: "completed" | "in_progress" | "pending";
|
|
2226
2228
|
}[] | undefined;
|
|
2227
|
-
}>, undefined, unknown, readonly [
|
|
2229
|
+
}>, undefined, unknown, readonly [_langchain.DynamicStructuredTool<zod_v30.ZodObject<{
|
|
2228
2230
|
todos: zod_v30.ZodArray<zod_v30.ZodObject<{
|
|
2229
2231
|
content: zod_v30.ZodString;
|
|
2230
2232
|
status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
@@ -2255,21 +2257,21 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2255
2257
|
content: string;
|
|
2256
2258
|
status: "completed" | "in_progress" | "pending";
|
|
2257
2259
|
}[];
|
|
2258
|
-
},
|
|
2260
|
+
}, _langgraph.Command<unknown, {
|
|
2259
2261
|
todos: {
|
|
2260
2262
|
content: string;
|
|
2261
2263
|
status: "completed" | "in_progress" | "pending";
|
|
2262
2264
|
}[];
|
|
2263
2265
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
2264
|
-
}, string>, unknown, "write_todos">]>, AgentMiddleware<
|
|
2265
|
-
files:
|
|
2266
|
-
}>, undefined, unknown, (
|
|
2266
|
+
}, string>, unknown, "write_todos">]>, AgentMiddleware<_langgraph.StateSchema<{
|
|
2267
|
+
files: _langgraph.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
2268
|
+
}>, undefined, unknown, (_langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2267
2269
|
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
2268
2270
|
}, zod_v4_core0.$strip>, {
|
|
2269
2271
|
path: string;
|
|
2270
2272
|
}, {
|
|
2271
2273
|
path?: string | undefined;
|
|
2272
|
-
}, string, unknown, "ls"> |
|
|
2274
|
+
}, string, unknown, "ls"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2273
2275
|
file_path: zod.ZodString;
|
|
2274
2276
|
offset: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
|
|
2275
2277
|
limit: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
|
|
@@ -2281,7 +2283,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2281
2283
|
file_path: string;
|
|
2282
2284
|
offset?: unknown;
|
|
2283
2285
|
limit?: unknown;
|
|
2284
|
-
}, string, unknown, "read_file"> |
|
|
2286
|
+
}, string, unknown, "read_file"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2285
2287
|
file_path: zod.ZodString;
|
|
2286
2288
|
content: zod.ZodDefault<zod.ZodString>;
|
|
2287
2289
|
}, zod_v4_core0.$strip>, {
|
|
@@ -2290,10 +2292,10 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2290
2292
|
}, {
|
|
2291
2293
|
file_path: string;
|
|
2292
2294
|
content?: string | undefined;
|
|
2293
|
-
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> |
|
|
2295
|
+
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langgraph.Command<unknown, {
|
|
2294
2296
|
files: Record<string, FileData>;
|
|
2295
2297
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
2296
|
-
}, string>, unknown, "write_file"> |
|
|
2298
|
+
}, string>, unknown, "write_file"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2297
2299
|
file_path: zod.ZodString;
|
|
2298
2300
|
old_string: zod.ZodString;
|
|
2299
2301
|
new_string: zod.ZodString;
|
|
@@ -2308,10 +2310,10 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2308
2310
|
old_string: string;
|
|
2309
2311
|
new_string: string;
|
|
2310
2312
|
replace_all?: boolean | undefined;
|
|
2311
|
-
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> |
|
|
2313
|
+
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langgraph.Command<unknown, {
|
|
2312
2314
|
files: Record<string, FileData>;
|
|
2313
2315
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
2314
|
-
}, string>, unknown, "edit_file"> |
|
|
2316
|
+
}, string>, unknown, "edit_file"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2315
2317
|
pattern: zod.ZodString;
|
|
2316
2318
|
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
2317
2319
|
}, zod_v4_core0.$strip>, {
|
|
@@ -2320,7 +2322,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2320
2322
|
}, {
|
|
2321
2323
|
pattern: string;
|
|
2322
2324
|
path?: string | undefined;
|
|
2323
|
-
}, string, unknown, "glob"> |
|
|
2325
|
+
}, string, unknown, "glob"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2324
2326
|
pattern: zod.ZodString;
|
|
2325
2327
|
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
2326
2328
|
glob: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
|
|
@@ -2332,13 +2334,13 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2332
2334
|
pattern: string;
|
|
2333
2335
|
path?: string | undefined;
|
|
2334
2336
|
glob?: string | null | undefined;
|
|
2335
|
-
}, string, unknown, "grep"> |
|
|
2337
|
+
}, string, unknown, "grep"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2336
2338
|
command: zod.ZodString;
|
|
2337
2339
|
}, zod_v4_core0.$strip>, {
|
|
2338
2340
|
command: string;
|
|
2339
2341
|
}, {
|
|
2340
2342
|
command: string;
|
|
2341
|
-
}, string, unknown, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [
|
|
2343
|
+
}, string, unknown, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [_langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2342
2344
|
description: zod.ZodString;
|
|
2343
2345
|
subagent_type: zod.ZodString;
|
|
2344
2346
|
}, zod_v4_core0.$strip>, {
|
|
@@ -2347,7 +2349,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2347
2349
|
}, {
|
|
2348
2350
|
description: string;
|
|
2349
2351
|
subagent_type: string;
|
|
2350
|
-
}, string |
|
|
2352
|
+
}, string | _langgraph.Command<unknown, Record<string, unknown>, string>, unknown, "task">]>, AgentMiddleware<zod.ZodObject<{
|
|
2351
2353
|
_summarizationSessionId: zod.ZodOptional<zod.ZodString>;
|
|
2352
2354
|
_summarizationEvent: zod.ZodOptional<zod.ZodObject<{
|
|
2353
2355
|
cutoffIndex: zod.ZodNumber;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _langchain from "langchain";
|
|
2
2
|
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, CreateAgentParams, HumanMessage, InferMiddlewareStates, InterruptOnConfig, ProviderStrategy, ReactAgent, ResponseFormat, ResponseFormatUndefined, Runtime, StructuredTool, SystemMessage, ToolMessage, ToolStrategy } from "langchain";
|
|
3
3
|
import { Runnable } from "@langchain/core/runnables";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _langgraph from "@langchain/langgraph";
|
|
5
5
|
import { AnnotationRoot, Command, ReducedValue, StateSchema } from "@langchain/langgraph";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
7
|
import * as _messages from "@langchain/core/messages";
|
|
@@ -475,19 +475,21 @@ interface FilesystemMiddlewareOptions {
|
|
|
475
475
|
customToolDescriptions?: Record<string, string> | null;
|
|
476
476
|
/** Optional token limit before evicting a tool result to the filesystem (default: 20000 tokens, ~80KB) */
|
|
477
477
|
toolTokenLimitBeforeEvict?: number | null;
|
|
478
|
+
/** Optional token limit before evicting a HumanMessage to the filesystem (default: 50000 tokens, ~200KB) */
|
|
479
|
+
humanMessageTokenLimitBeforeEvict?: number | null;
|
|
478
480
|
}
|
|
479
481
|
/**
|
|
480
482
|
* Create filesystem middleware with all tools and features.
|
|
481
483
|
*/
|
|
482
484
|
declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOptions): AgentMiddleware<StateSchema<{
|
|
483
485
|
files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
484
|
-
}>, undefined, unknown, (
|
|
486
|
+
}>, undefined, unknown, (_langchain.DynamicStructuredTool<z.ZodObject<{
|
|
485
487
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
486
488
|
}, z.core.$strip>, {
|
|
487
489
|
path: string;
|
|
488
490
|
}, {
|
|
489
491
|
path?: string | undefined;
|
|
490
|
-
}, string, unknown, "ls"> |
|
|
492
|
+
}, string, unknown, "ls"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
491
493
|
file_path: z.ZodString;
|
|
492
494
|
offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
493
495
|
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
@@ -499,7 +501,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
499
501
|
file_path: string;
|
|
500
502
|
offset?: unknown;
|
|
501
503
|
limit?: unknown;
|
|
502
|
-
}, string, unknown, "read_file"> |
|
|
504
|
+
}, string, unknown, "read_file"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
503
505
|
file_path: z.ZodString;
|
|
504
506
|
content: z.ZodDefault<z.ZodString>;
|
|
505
507
|
}, z.core.$strip>, {
|
|
@@ -511,7 +513,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
511
513
|
}, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
|
|
512
514
|
files: Record<string, FileData>;
|
|
513
515
|
messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
514
|
-
}, string>, unknown, "write_file"> |
|
|
516
|
+
}, string>, unknown, "write_file"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
515
517
|
file_path: z.ZodString;
|
|
516
518
|
old_string: z.ZodString;
|
|
517
519
|
new_string: z.ZodString;
|
|
@@ -529,7 +531,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
529
531
|
}, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
|
|
530
532
|
files: Record<string, FileData>;
|
|
531
533
|
messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
532
|
-
}, string>, unknown, "edit_file"> |
|
|
534
|
+
}, string>, unknown, "edit_file"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
533
535
|
pattern: z.ZodString;
|
|
534
536
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
535
537
|
}, z.core.$strip>, {
|
|
@@ -538,7 +540,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
538
540
|
}, {
|
|
539
541
|
pattern: string;
|
|
540
542
|
path?: string | undefined;
|
|
541
|
-
}, string, unknown, "glob"> |
|
|
543
|
+
}, string, unknown, "glob"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
542
544
|
pattern: z.ZodString;
|
|
543
545
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
544
546
|
glob: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -550,7 +552,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
550
552
|
pattern: string;
|
|
551
553
|
path?: string | undefined;
|
|
552
554
|
glob?: string | null | undefined;
|
|
553
|
-
}, string, unknown, "grep"> |
|
|
555
|
+
}, string, unknown, "grep"> | _langchain.DynamicStructuredTool<z.ZodObject<{
|
|
554
556
|
command: z.ZodString;
|
|
555
557
|
}, z.core.$strip>, {
|
|
556
558
|
command: string;
|
|
@@ -759,7 +761,7 @@ interface SubAgentMiddlewareOptions {
|
|
|
759
761
|
/**
|
|
760
762
|
* Create subagent middleware with task tool
|
|
761
763
|
*/
|
|
762
|
-
declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [
|
|
764
|
+
declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [_langchain.DynamicStructuredTool<z.ZodObject<{
|
|
763
765
|
description: z.ZodString;
|
|
764
766
|
subagent_type: z.ZodString;
|
|
765
767
|
}, z.core.$strip>, {
|
|
@@ -941,7 +943,7 @@ declare function createMemoryMiddleware(options: MemoryMiddlewareOptions): Agent
|
|
|
941
943
|
* Marked as private so it's not included in the final agent state.
|
|
942
944
|
*/
|
|
943
945
|
memoryContents: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
944
|
-
files:
|
|
946
|
+
files: _langgraph.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
945
947
|
}>, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
|
|
946
948
|
//#endregion
|
|
947
949
|
//#region src/middleware/skills.d.ts
|
|
@@ -2224,7 +2226,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2224
2226
|
content: string;
|
|
2225
2227
|
status: "completed" | "in_progress" | "pending";
|
|
2226
2228
|
}[] | undefined;
|
|
2227
|
-
}>, undefined, unknown, readonly [
|
|
2229
|
+
}>, undefined, unknown, readonly [_langchain.DynamicStructuredTool<zod_v30.ZodObject<{
|
|
2228
2230
|
todos: zod_v30.ZodArray<zod_v30.ZodObject<{
|
|
2229
2231
|
content: zod_v30.ZodString;
|
|
2230
2232
|
status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
@@ -2255,21 +2257,21 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2255
2257
|
content: string;
|
|
2256
2258
|
status: "completed" | "in_progress" | "pending";
|
|
2257
2259
|
}[];
|
|
2258
|
-
},
|
|
2260
|
+
}, _langgraph.Command<unknown, {
|
|
2259
2261
|
todos: {
|
|
2260
2262
|
content: string;
|
|
2261
2263
|
status: "completed" | "in_progress" | "pending";
|
|
2262
2264
|
}[];
|
|
2263
2265
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
2264
|
-
}, string>, unknown, "write_todos">]>, AgentMiddleware<
|
|
2265
|
-
files:
|
|
2266
|
-
}>, undefined, unknown, (
|
|
2266
|
+
}, string>, unknown, "write_todos">]>, AgentMiddleware<_langgraph.StateSchema<{
|
|
2267
|
+
files: _langgraph.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
2268
|
+
}>, undefined, unknown, (_langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2267
2269
|
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
2268
2270
|
}, zod_v4_core0.$strip>, {
|
|
2269
2271
|
path: string;
|
|
2270
2272
|
}, {
|
|
2271
2273
|
path?: string | undefined;
|
|
2272
|
-
}, string, unknown, "ls"> |
|
|
2274
|
+
}, string, unknown, "ls"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2273
2275
|
file_path: zod.ZodString;
|
|
2274
2276
|
offset: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
|
|
2275
2277
|
limit: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
|
|
@@ -2281,7 +2283,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2281
2283
|
file_path: string;
|
|
2282
2284
|
offset?: unknown;
|
|
2283
2285
|
limit?: unknown;
|
|
2284
|
-
}, string, unknown, "read_file"> |
|
|
2286
|
+
}, string, unknown, "read_file"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2285
2287
|
file_path: zod.ZodString;
|
|
2286
2288
|
content: zod.ZodDefault<zod.ZodString>;
|
|
2287
2289
|
}, zod_v4_core0.$strip>, {
|
|
@@ -2290,10 +2292,10 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2290
2292
|
}, {
|
|
2291
2293
|
file_path: string;
|
|
2292
2294
|
content?: string | undefined;
|
|
2293
|
-
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> |
|
|
2295
|
+
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langgraph.Command<unknown, {
|
|
2294
2296
|
files: Record<string, FileData>;
|
|
2295
2297
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
2296
|
-
}, string>, unknown, "write_file"> |
|
|
2298
|
+
}, string>, unknown, "write_file"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2297
2299
|
file_path: zod.ZodString;
|
|
2298
2300
|
old_string: zod.ZodString;
|
|
2299
2301
|
new_string: zod.ZodString;
|
|
@@ -2308,10 +2310,10 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2308
2310
|
old_string: string;
|
|
2309
2311
|
new_string: string;
|
|
2310
2312
|
replace_all?: boolean | undefined;
|
|
2311
|
-
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> |
|
|
2313
|
+
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langgraph.Command<unknown, {
|
|
2312
2314
|
files: Record<string, FileData>;
|
|
2313
2315
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
2314
|
-
}, string>, unknown, "edit_file"> |
|
|
2316
|
+
}, string>, unknown, "edit_file"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2315
2317
|
pattern: zod.ZodString;
|
|
2316
2318
|
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
2317
2319
|
}, zod_v4_core0.$strip>, {
|
|
@@ -2320,7 +2322,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2320
2322
|
}, {
|
|
2321
2323
|
pattern: string;
|
|
2322
2324
|
path?: string | undefined;
|
|
2323
|
-
}, string, unknown, "glob"> |
|
|
2325
|
+
}, string, unknown, "glob"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2324
2326
|
pattern: zod.ZodString;
|
|
2325
2327
|
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
2326
2328
|
glob: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
|
|
@@ -2332,13 +2334,13 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2332
2334
|
pattern: string;
|
|
2333
2335
|
path?: string | undefined;
|
|
2334
2336
|
glob?: string | null | undefined;
|
|
2335
|
-
}, string, unknown, "grep"> |
|
|
2337
|
+
}, string, unknown, "grep"> | _langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2336
2338
|
command: zod.ZodString;
|
|
2337
2339
|
}, zod_v4_core0.$strip>, {
|
|
2338
2340
|
command: string;
|
|
2339
2341
|
}, {
|
|
2340
2342
|
command: string;
|
|
2341
|
-
}, string, unknown, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [
|
|
2343
|
+
}, string, unknown, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [_langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
2342
2344
|
description: zod.ZodString;
|
|
2343
2345
|
subagent_type: zod.ZodString;
|
|
2344
2346
|
}, zod_v4_core0.$strip>, {
|
|
@@ -2347,7 +2349,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
2347
2349
|
}, {
|
|
2348
2350
|
description: string;
|
|
2349
2351
|
subagent_type: string;
|
|
2350
|
-
}, string |
|
|
2352
|
+
}, string | _langgraph.Command<unknown, Record<string, unknown>, string>, unknown, "task">]>, AgentMiddleware<zod.ZodObject<{
|
|
2351
2353
|
_summarizationSessionId: zod.ZodOptional<zod.ZodString>;
|
|
2352
2354
|
_summarizationEvent: zod.ZodOptional<zod.ZodObject<{
|
|
2353
2355
|
cutoffIndex: zod.ZodNumber;
|
package/dist/index.js
CHANGED
|
@@ -627,6 +627,62 @@ indicate omitted lines in the middle of the content):
|
|
|
627
627
|
|
|
628
628
|
{content_sample}`;
|
|
629
629
|
/**
|
|
630
|
+
* Message template for evicted HumanMessages.
|
|
631
|
+
*/
|
|
632
|
+
const TOO_LARGE_HUMAN_MSG = `Message content too large and was saved to the filesystem at: {file_path}
|
|
633
|
+
|
|
634
|
+
You can read the full content using the read_file tool with pagination (offset and limit parameters).
|
|
635
|
+
|
|
636
|
+
Here is a preview showing the head and tail of the content:
|
|
637
|
+
|
|
638
|
+
{content_sample}`;
|
|
639
|
+
/**
|
|
640
|
+
* Extract text content from a message.
|
|
641
|
+
*
|
|
642
|
+
* For string content, returns it directly. For array content (mixed block types
|
|
643
|
+
* like text + image), joins all text blocks. Returns empty string if no text found.
|
|
644
|
+
*/
|
|
645
|
+
function extractTextFromMessage(message) {
|
|
646
|
+
if (typeof message.content === "string") return message.content;
|
|
647
|
+
if (Array.isArray(message.content)) return message.content.filter((block) => block.type === "text" && typeof block.text === "string").map((block) => block.text).join("\n");
|
|
648
|
+
return String(message.content);
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Build replacement content for an evicted HumanMessage, preserving non-text blocks.
|
|
652
|
+
*
|
|
653
|
+
* For plain string content, returns the replacement text directly. For list content
|
|
654
|
+
* with mixed block types (e.g., text + image), replaces all text blocks with a single
|
|
655
|
+
* text block containing the replacement text while keeping non-text blocks intact.
|
|
656
|
+
*/
|
|
657
|
+
function buildEvictedHumanContent(message, replacementText) {
|
|
658
|
+
if (typeof message.content === "string") return replacementText;
|
|
659
|
+
if (Array.isArray(message.content)) {
|
|
660
|
+
const mediaBlocks = message.content.filter((block) => typeof block === "object" && block !== null && block.type !== "text");
|
|
661
|
+
if (mediaBlocks.length === 0) return replacementText;
|
|
662
|
+
return [{
|
|
663
|
+
type: "text",
|
|
664
|
+
text: replacementText
|
|
665
|
+
}, ...mediaBlocks];
|
|
666
|
+
}
|
|
667
|
+
return replacementText;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Build a truncated HumanMessage for the model request.
|
|
671
|
+
*
|
|
672
|
+
* Computes a preview from the full content still in state and returns a
|
|
673
|
+
* lightweight replacement the model will see. Pure string computation — no
|
|
674
|
+
* backend I/O.
|
|
675
|
+
*/
|
|
676
|
+
function buildTruncatedHumanMessage(message, filePath) {
|
|
677
|
+
const contentSample = createContentPreview(extractTextFromMessage(message));
|
|
678
|
+
return new HumanMessage({
|
|
679
|
+
content: buildEvictedHumanContent(message, TOO_LARGE_HUMAN_MSG.replace("{file_path}", filePath).replace("{content_sample}", contentSample)),
|
|
680
|
+
id: message.id,
|
|
681
|
+
additional_kwargs: { ...message.additional_kwargs },
|
|
682
|
+
response_metadata: { ...message.response_metadata }
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
630
686
|
* Create a preview of content showing head and tail with truncation marker.
|
|
631
687
|
*
|
|
632
688
|
* @param contentStr - The full content string to preview.
|
|
@@ -995,7 +1051,7 @@ function createExecuteTool(backend, options) {
|
|
|
995
1051
|
* Create filesystem middleware with all tools and features.
|
|
996
1052
|
*/
|
|
997
1053
|
function createFilesystemMiddleware(options = {}) {
|
|
998
|
-
const { backend = (runtime) => new StateBackend(runtime), systemPrompt: customSystemPrompt = null, customToolDescriptions = null, toolTokenLimitBeforeEvict = 2e4 } = options;
|
|
1054
|
+
const { backend = (runtime) => new StateBackend(runtime), systemPrompt: customSystemPrompt = null, customToolDescriptions = null, toolTokenLimitBeforeEvict = 2e4, humanMessageTokenLimitBeforeEvict = 5e4 } = options;
|
|
999
1055
|
const baseSystemPrompt = customSystemPrompt || FILESYSTEM_SYSTEM_PROMPT;
|
|
1000
1056
|
const allToolsByName = {
|
|
1001
1057
|
ls: createLsTool(backend, { customDescription: customToolDescriptions?.ls }),
|
|
@@ -1013,6 +1069,32 @@ function createFilesystemMiddleware(options = {}) {
|
|
|
1013
1069
|
name: "FilesystemMiddleware",
|
|
1014
1070
|
stateSchema: FilesystemStateSchema,
|
|
1015
1071
|
tools: Object.values(allToolsByName),
|
|
1072
|
+
async beforeAgent(state) {
|
|
1073
|
+
if (!humanMessageTokenLimitBeforeEvict) return;
|
|
1074
|
+
const messages = state.messages;
|
|
1075
|
+
if (!messages || messages.length === 0) return;
|
|
1076
|
+
const last = messages[messages.length - 1];
|
|
1077
|
+
if (!HumanMessage.isInstance(last)) return;
|
|
1078
|
+
if (last.additional_kwargs?.lc_evicted_to) return;
|
|
1079
|
+
const contentStr = extractTextFromMessage(last);
|
|
1080
|
+
const threshold = 4 * humanMessageTokenLimitBeforeEvict;
|
|
1081
|
+
if (contentStr.length <= threshold) return;
|
|
1082
|
+
const resolvedBackend = await resolveBackend(backend, { state: state || {} });
|
|
1083
|
+
const filePath = `/conversation_history/${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}`;
|
|
1084
|
+
const writeResult = await resolvedBackend.write(filePath, contentStr);
|
|
1085
|
+
if (writeResult.error) return;
|
|
1086
|
+
const result = { messages: [new HumanMessage({
|
|
1087
|
+
content: last.content,
|
|
1088
|
+
id: last.id,
|
|
1089
|
+
additional_kwargs: {
|
|
1090
|
+
...last.additional_kwargs,
|
|
1091
|
+
lc_evicted_to: filePath
|
|
1092
|
+
},
|
|
1093
|
+
response_metadata: { ...last.response_metadata }
|
|
1094
|
+
})] };
|
|
1095
|
+
if (writeResult.filesUpdate) result.files = writeResult.filesUpdate;
|
|
1096
|
+
return result;
|
|
1097
|
+
},
|
|
1016
1098
|
wrapModelCall: async (request, handler) => {
|
|
1017
1099
|
const supportsExecution = isSandboxBackend(await resolveBackend(backend, {
|
|
1018
1100
|
...request.runtime,
|
|
@@ -1023,9 +1105,17 @@ function createFilesystemMiddleware(options = {}) {
|
|
|
1023
1105
|
let filesystemPrompt = baseSystemPrompt;
|
|
1024
1106
|
if (supportsExecution) filesystemPrompt = `${filesystemPrompt}\n\n${EXECUTION_SYSTEM_PROMPT}`;
|
|
1025
1107
|
const newSystemMessage = request.systemMessage.concat(filesystemPrompt);
|
|
1108
|
+
let messages = request.messages;
|
|
1109
|
+
if (humanMessageTokenLimitBeforeEvict && messages) {
|
|
1110
|
+
if (messages.some((msg) => HumanMessage.isInstance(msg) && msg.additional_kwargs?.lc_evicted_to)) messages = messages.map((msg) => {
|
|
1111
|
+
if (HumanMessage.isInstance(msg) && msg.additional_kwargs?.lc_evicted_to) return buildTruncatedHumanMessage(msg, msg.additional_kwargs.lc_evicted_to);
|
|
1112
|
+
return msg;
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1026
1115
|
return handler({
|
|
1027
1116
|
...request,
|
|
1028
1117
|
tools,
|
|
1118
|
+
messages,
|
|
1029
1119
|
systemMessage: newSystemMessage
|
|
1030
1120
|
});
|
|
1031
1121
|
},
|