@agentforge/patterns 0.16.0 → 0.16.2
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 +425 -287
- package/dist/index.d.cts +103 -109
- package/dist/index.d.ts +103 -109
- package/dist/index.js +425 -287
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _langchain_langgraph from '@langchain/langgraph';
|
|
|
3
3
|
import { BaseCheckpointSaver, CompiledStateGraph } from '@langchain/langgraph';
|
|
4
4
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
5
5
|
import * as _agentforge_core from '@agentforge/core';
|
|
6
|
-
import { ToolRegistry, Tool, LogLevel } from '@agentforge/core';
|
|
6
|
+
import { ToolRegistry, Tool, ToolMetadata, LogLevel } from '@agentforge/core';
|
|
7
7
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -549,6 +549,8 @@ declare function createReActAgentBuilder(): ReActAgentBuilder;
|
|
|
549
549
|
* @module patterns/plan-execute/schemas
|
|
550
550
|
*/
|
|
551
551
|
|
|
552
|
+
type PlanStepArguments = Record<string, unknown>;
|
|
553
|
+
type PlanStepResult = unknown;
|
|
552
554
|
/**
|
|
553
555
|
* Schema for a single step in the plan
|
|
554
556
|
*/
|
|
@@ -572,18 +574,18 @@ declare const PlanStepSchema: z.ZodObject<{
|
|
|
572
574
|
/**
|
|
573
575
|
* Optional arguments for the tool
|
|
574
576
|
*/
|
|
575
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
577
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
576
578
|
}, "strip", z.ZodTypeAny, {
|
|
577
579
|
id: string;
|
|
578
580
|
description: string;
|
|
579
581
|
tool?: string | undefined;
|
|
580
|
-
args?: Record<string,
|
|
582
|
+
args?: Record<string, unknown> | undefined;
|
|
581
583
|
dependencies?: string[] | undefined;
|
|
582
584
|
}, {
|
|
583
585
|
id: string;
|
|
584
586
|
description: string;
|
|
585
587
|
tool?: string | undefined;
|
|
586
|
-
args?: Record<string,
|
|
588
|
+
args?: Record<string, unknown> | undefined;
|
|
587
589
|
dependencies?: string[] | undefined;
|
|
588
590
|
}>;
|
|
589
591
|
type PlanStep = z.infer<typeof PlanStepSchema>;
|
|
@@ -614,24 +616,24 @@ declare const CompletedStepSchema: z.ZodObject<{
|
|
|
614
616
|
/**
|
|
615
617
|
* Optional arguments for the tool
|
|
616
618
|
*/
|
|
617
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
619
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
618
620
|
}, "strip", z.ZodTypeAny, {
|
|
619
621
|
id: string;
|
|
620
622
|
description: string;
|
|
621
623
|
tool?: string | undefined;
|
|
622
|
-
args?: Record<string,
|
|
624
|
+
args?: Record<string, unknown> | undefined;
|
|
623
625
|
dependencies?: string[] | undefined;
|
|
624
626
|
}, {
|
|
625
627
|
id: string;
|
|
626
628
|
description: string;
|
|
627
629
|
tool?: string | undefined;
|
|
628
|
-
args?: Record<string,
|
|
630
|
+
args?: Record<string, unknown> | undefined;
|
|
629
631
|
dependencies?: string[] | undefined;
|
|
630
632
|
}>;
|
|
631
633
|
/**
|
|
632
634
|
* The result of executing the step
|
|
633
635
|
*/
|
|
634
|
-
result: z.
|
|
636
|
+
result: z.ZodUnknown;
|
|
635
637
|
/**
|
|
636
638
|
* Whether the step succeeded
|
|
637
639
|
*/
|
|
@@ -650,11 +652,11 @@ declare const CompletedStepSchema: z.ZodObject<{
|
|
|
650
652
|
id: string;
|
|
651
653
|
description: string;
|
|
652
654
|
tool?: string | undefined;
|
|
653
|
-
args?: Record<string,
|
|
655
|
+
args?: Record<string, unknown> | undefined;
|
|
654
656
|
dependencies?: string[] | undefined;
|
|
655
657
|
};
|
|
656
658
|
success: boolean;
|
|
657
|
-
result?:
|
|
659
|
+
result?: unknown;
|
|
658
660
|
error?: string | undefined;
|
|
659
661
|
}, {
|
|
660
662
|
timestamp: string;
|
|
@@ -662,11 +664,11 @@ declare const CompletedStepSchema: z.ZodObject<{
|
|
|
662
664
|
id: string;
|
|
663
665
|
description: string;
|
|
664
666
|
tool?: string | undefined;
|
|
665
|
-
args?: Record<string,
|
|
667
|
+
args?: Record<string, unknown> | undefined;
|
|
666
668
|
dependencies?: string[] | undefined;
|
|
667
669
|
};
|
|
668
670
|
success: boolean;
|
|
669
|
-
result?:
|
|
671
|
+
result?: unknown;
|
|
670
672
|
error?: string | undefined;
|
|
671
673
|
}>;
|
|
672
674
|
type CompletedStep = z.infer<typeof CompletedStepSchema>;
|
|
@@ -697,18 +699,18 @@ declare const PlanSchema: z.ZodObject<{
|
|
|
697
699
|
/**
|
|
698
700
|
* Optional arguments for the tool
|
|
699
701
|
*/
|
|
700
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
702
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
701
703
|
}, "strip", z.ZodTypeAny, {
|
|
702
704
|
id: string;
|
|
703
705
|
description: string;
|
|
704
706
|
tool?: string | undefined;
|
|
705
|
-
args?: Record<string,
|
|
707
|
+
args?: Record<string, unknown> | undefined;
|
|
706
708
|
dependencies?: string[] | undefined;
|
|
707
709
|
}, {
|
|
708
710
|
id: string;
|
|
709
711
|
description: string;
|
|
710
712
|
tool?: string | undefined;
|
|
711
|
-
args?: Record<string,
|
|
713
|
+
args?: Record<string, unknown> | undefined;
|
|
712
714
|
dependencies?: string[] | undefined;
|
|
713
715
|
}>, "many">;
|
|
714
716
|
/**
|
|
@@ -728,7 +730,7 @@ declare const PlanSchema: z.ZodObject<{
|
|
|
728
730
|
id: string;
|
|
729
731
|
description: string;
|
|
730
732
|
tool?: string | undefined;
|
|
731
|
-
args?: Record<string,
|
|
733
|
+
args?: Record<string, unknown> | undefined;
|
|
732
734
|
dependencies?: string[] | undefined;
|
|
733
735
|
}[];
|
|
734
736
|
goal: string;
|
|
@@ -739,7 +741,7 @@ declare const PlanSchema: z.ZodObject<{
|
|
|
739
741
|
id: string;
|
|
740
742
|
description: string;
|
|
741
743
|
tool?: string | undefined;
|
|
742
|
-
args?: Record<string,
|
|
744
|
+
args?: Record<string, unknown> | undefined;
|
|
743
745
|
dependencies?: string[] | undefined;
|
|
744
746
|
}[];
|
|
745
747
|
goal: string;
|
|
@@ -804,18 +806,18 @@ declare const PlanExecuteStateConfig: {
|
|
|
804
806
|
description: z.ZodString;
|
|
805
807
|
dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
806
808
|
tool: z.ZodOptional<z.ZodString>;
|
|
807
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
809
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
808
810
|
}, "strip", z.ZodTypeAny, {
|
|
809
811
|
id: string;
|
|
810
812
|
description: string;
|
|
811
813
|
tool?: string | undefined;
|
|
812
|
-
args?: Record<string,
|
|
814
|
+
args?: Record<string, unknown> | undefined;
|
|
813
815
|
dependencies?: string[] | undefined;
|
|
814
816
|
}, {
|
|
815
817
|
id: string;
|
|
816
818
|
description: string;
|
|
817
819
|
tool?: string | undefined;
|
|
818
|
-
args?: Record<string,
|
|
820
|
+
args?: Record<string, unknown> | undefined;
|
|
819
821
|
dependencies?: string[] | undefined;
|
|
820
822
|
}>, "many">;
|
|
821
823
|
goal: z.ZodString;
|
|
@@ -826,7 +828,7 @@ declare const PlanExecuteStateConfig: {
|
|
|
826
828
|
id: string;
|
|
827
829
|
description: string;
|
|
828
830
|
tool?: string | undefined;
|
|
829
|
-
args?: Record<string,
|
|
831
|
+
args?: Record<string, unknown> | undefined;
|
|
830
832
|
dependencies?: string[] | undefined;
|
|
831
833
|
}[];
|
|
832
834
|
goal: string;
|
|
@@ -837,7 +839,7 @@ declare const PlanExecuteStateConfig: {
|
|
|
837
839
|
id: string;
|
|
838
840
|
description: string;
|
|
839
841
|
tool?: string | undefined;
|
|
840
|
-
args?: Record<string,
|
|
842
|
+
args?: Record<string, unknown> | undefined;
|
|
841
843
|
dependencies?: string[] | undefined;
|
|
842
844
|
}[];
|
|
843
845
|
goal: string;
|
|
@@ -857,21 +859,21 @@ declare const PlanExecuteStateConfig: {
|
|
|
857
859
|
description: z.ZodString;
|
|
858
860
|
dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
859
861
|
tool: z.ZodOptional<z.ZodString>;
|
|
860
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
862
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
861
863
|
}, "strip", z.ZodTypeAny, {
|
|
862
864
|
id: string;
|
|
863
865
|
description: string;
|
|
864
866
|
tool?: string | undefined;
|
|
865
|
-
args?: Record<string,
|
|
867
|
+
args?: Record<string, unknown> | undefined;
|
|
866
868
|
dependencies?: string[] | undefined;
|
|
867
869
|
}, {
|
|
868
870
|
id: string;
|
|
869
871
|
description: string;
|
|
870
872
|
tool?: string | undefined;
|
|
871
|
-
args?: Record<string,
|
|
873
|
+
args?: Record<string, unknown> | undefined;
|
|
872
874
|
dependencies?: string[] | undefined;
|
|
873
875
|
}>;
|
|
874
|
-
result: z.
|
|
876
|
+
result: z.ZodUnknown;
|
|
875
877
|
success: z.ZodBoolean;
|
|
876
878
|
error: z.ZodOptional<z.ZodString>;
|
|
877
879
|
timestamp: z.ZodString;
|
|
@@ -881,11 +883,11 @@ declare const PlanExecuteStateConfig: {
|
|
|
881
883
|
id: string;
|
|
882
884
|
description: string;
|
|
883
885
|
tool?: string | undefined;
|
|
884
|
-
args?: Record<string,
|
|
886
|
+
args?: Record<string, unknown> | undefined;
|
|
885
887
|
dependencies?: string[] | undefined;
|
|
886
888
|
};
|
|
887
889
|
success: boolean;
|
|
888
|
-
result?:
|
|
890
|
+
result?: unknown;
|
|
889
891
|
error?: string | undefined;
|
|
890
892
|
}, {
|
|
891
893
|
timestamp: string;
|
|
@@ -893,11 +895,11 @@ declare const PlanExecuteStateConfig: {
|
|
|
893
895
|
id: string;
|
|
894
896
|
description: string;
|
|
895
897
|
tool?: string | undefined;
|
|
896
|
-
args?: Record<string,
|
|
898
|
+
args?: Record<string, unknown> | undefined;
|
|
897
899
|
dependencies?: string[] | undefined;
|
|
898
900
|
};
|
|
899
901
|
success: boolean;
|
|
900
|
-
result?:
|
|
902
|
+
result?: unknown;
|
|
901
903
|
error?: string | undefined;
|
|
902
904
|
}>, "many">;
|
|
903
905
|
reducer: (left: CompletedStep[], right: CompletedStep[]) => {
|
|
@@ -906,11 +908,11 @@ declare const PlanExecuteStateConfig: {
|
|
|
906
908
|
id: string;
|
|
907
909
|
description: string;
|
|
908
910
|
tool?: string | undefined;
|
|
909
|
-
args?: Record<string,
|
|
911
|
+
args?: Record<string, unknown> | undefined;
|
|
910
912
|
dependencies?: string[] | undefined;
|
|
911
913
|
};
|
|
912
914
|
success: boolean;
|
|
913
|
-
result?:
|
|
915
|
+
result?: unknown;
|
|
914
916
|
error?: string | undefined;
|
|
915
917
|
}[];
|
|
916
918
|
default: () => never[];
|
|
@@ -975,7 +977,7 @@ declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<{
|
|
|
975
977
|
id: string;
|
|
976
978
|
description: string;
|
|
977
979
|
tool?: string | undefined;
|
|
978
|
-
args?: Record<string,
|
|
980
|
+
args?: Record<string, unknown> | undefined;
|
|
979
981
|
dependencies?: string[] | undefined;
|
|
980
982
|
}[];
|
|
981
983
|
goal: string;
|
|
@@ -986,7 +988,7 @@ declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<{
|
|
|
986
988
|
id: string;
|
|
987
989
|
description: string;
|
|
988
990
|
tool?: string | undefined;
|
|
989
|
-
args?: Record<string,
|
|
991
|
+
args?: Record<string, unknown> | undefined;
|
|
990
992
|
dependencies?: string[] | undefined;
|
|
991
993
|
}[];
|
|
992
994
|
goal: string;
|
|
@@ -999,11 +1001,11 @@ declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<{
|
|
|
999
1001
|
id: string;
|
|
1000
1002
|
description: string;
|
|
1001
1003
|
tool?: string | undefined;
|
|
1002
|
-
args?: Record<string,
|
|
1004
|
+
args?: Record<string, unknown> | undefined;
|
|
1003
1005
|
dependencies?: string[] | undefined;
|
|
1004
1006
|
};
|
|
1005
1007
|
success: boolean;
|
|
1006
|
-
result?:
|
|
1008
|
+
result?: unknown;
|
|
1007
1009
|
error?: string | undefined;
|
|
1008
1010
|
}[], {
|
|
1009
1011
|
timestamp: string;
|
|
@@ -1011,11 +1013,11 @@ declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<{
|
|
|
1011
1013
|
id: string;
|
|
1012
1014
|
description: string;
|
|
1013
1015
|
tool?: string | undefined;
|
|
1014
|
-
args?: Record<string,
|
|
1016
|
+
args?: Record<string, unknown> | undefined;
|
|
1015
1017
|
dependencies?: string[] | undefined;
|
|
1016
1018
|
};
|
|
1017
1019
|
success: boolean;
|
|
1018
|
-
result?:
|
|
1020
|
+
result?: unknown;
|
|
1019
1021
|
error?: string | undefined;
|
|
1020
1022
|
}[], unknown>;
|
|
1021
1023
|
currentStepIndex: _langchain_langgraph.BaseChannel<number | undefined, number | undefined, unknown>;
|
|
@@ -1050,6 +1052,10 @@ type PlanExecuteStateType = {
|
|
|
1050
1052
|
* @module patterns/plan-execute/types
|
|
1051
1053
|
*/
|
|
1052
1054
|
|
|
1055
|
+
interface PlanExecuteTool {
|
|
1056
|
+
metadata: ToolMetadata;
|
|
1057
|
+
invoke(input: PlanStepArguments): Promise<PlanStepResult>;
|
|
1058
|
+
}
|
|
1053
1059
|
/**
|
|
1054
1060
|
* Configuration for the planner node
|
|
1055
1061
|
*/
|
|
@@ -1074,17 +1080,19 @@ interface PlannerConfig {
|
|
|
1074
1080
|
/**
|
|
1075
1081
|
* Configuration for the executor node
|
|
1076
1082
|
*/
|
|
1077
|
-
interface ExecutorConfig {
|
|
1083
|
+
interface ExecutorConfig<TTool extends PlanExecuteTool = PlanExecuteTool> {
|
|
1078
1084
|
/**
|
|
1079
1085
|
* Available tools for execution
|
|
1080
1086
|
*/
|
|
1081
|
-
tools:
|
|
1087
|
+
tools: readonly TTool[];
|
|
1082
1088
|
/**
|
|
1083
|
-
* Optional language model for sub-tasks
|
|
1089
|
+
* Optional language model for sub-tasks.
|
|
1090
|
+
* Currently unsupported and ignored by the runtime executor node.
|
|
1084
1091
|
*/
|
|
1085
1092
|
model?: BaseChatModel;
|
|
1086
1093
|
/**
|
|
1087
|
-
* Enable parallel execution of independent steps
|
|
1094
|
+
* Enable parallel execution of independent steps.
|
|
1095
|
+
* Currently unsupported and ignored by the runtime executor node.
|
|
1088
1096
|
*/
|
|
1089
1097
|
parallel?: boolean;
|
|
1090
1098
|
/**
|
|
@@ -1106,8 +1114,9 @@ interface ReplannerConfig {
|
|
|
1106
1114
|
*/
|
|
1107
1115
|
model: BaseChatModel;
|
|
1108
1116
|
/**
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1117
|
+
* Intended confidence threshold for replanning (0-1).
|
|
1118
|
+
* This is a forward-compatibility option and is currently ignored by the runtime replanner node.
|
|
1119
|
+
* Future versions may use this to decide when to trigger replanning.
|
|
1111
1120
|
*/
|
|
1112
1121
|
replanThreshold?: number;
|
|
1113
1122
|
/**
|
|
@@ -1118,7 +1127,7 @@ interface ReplannerConfig {
|
|
|
1118
1127
|
/**
|
|
1119
1128
|
* Configuration for creating a Plan-Execute agent
|
|
1120
1129
|
*/
|
|
1121
|
-
interface PlanExecuteAgentConfig {
|
|
1130
|
+
interface PlanExecuteAgentConfig<TTool extends PlanExecuteTool = PlanExecuteTool> {
|
|
1122
1131
|
/**
|
|
1123
1132
|
* Planner configuration
|
|
1124
1133
|
*/
|
|
@@ -1126,7 +1135,7 @@ interface PlanExecuteAgentConfig {
|
|
|
1126
1135
|
/**
|
|
1127
1136
|
* Executor configuration
|
|
1128
1137
|
*/
|
|
1129
|
-
executor: ExecutorConfig
|
|
1138
|
+
executor: ExecutorConfig<TTool>;
|
|
1130
1139
|
/**
|
|
1131
1140
|
* Optional replanner configuration
|
|
1132
1141
|
* If not provided, no replanning will occur
|
|
@@ -1196,12 +1205,10 @@ type PlanExecuteRouter = (state: PlanExecuteStateType) => PlanExecuteRoute;
|
|
|
1196
1205
|
* maxSteps: 5
|
|
1197
1206
|
* },
|
|
1198
1207
|
* executor: {
|
|
1199
|
-
* tools: [searchTool, calculatorTool]
|
|
1200
|
-
* parallel: false
|
|
1208
|
+
* tools: [searchTool, calculatorTool]
|
|
1201
1209
|
* },
|
|
1202
1210
|
* replanner: {
|
|
1203
|
-
* model: new ChatOpenAI({ model: 'gpt-4' })
|
|
1204
|
-
* replanThreshold: 0.7
|
|
1211
|
+
* model: new ChatOpenAI({ model: 'gpt-4' })
|
|
1205
1212
|
* }
|
|
1206
1213
|
* });
|
|
1207
1214
|
*
|
|
@@ -1234,14 +1241,14 @@ type PlanExecuteRouter = (state: PlanExecuteStateType) => PlanExecuteRoute;
|
|
|
1234
1241
|
* );
|
|
1235
1242
|
* ```
|
|
1236
1243
|
*/
|
|
1237
|
-
declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langchain_langgraph.CompiledStateGraph<{
|
|
1244
|
+
declare function createPlanExecuteAgent<TTool extends PlanExecuteTool = PlanExecuteTool>(config: PlanExecuteAgentConfig<TTool>): _langchain_langgraph.CompiledStateGraph<{
|
|
1238
1245
|
input: string;
|
|
1239
1246
|
plan: {
|
|
1240
1247
|
steps: {
|
|
1241
1248
|
id: string;
|
|
1242
1249
|
description: string;
|
|
1243
1250
|
tool?: string | undefined;
|
|
1244
|
-
args?: Record<string,
|
|
1251
|
+
args?: Record<string, unknown> | undefined;
|
|
1245
1252
|
dependencies?: string[] | undefined;
|
|
1246
1253
|
}[];
|
|
1247
1254
|
goal: string;
|
|
@@ -1254,11 +1261,11 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1254
1261
|
id: string;
|
|
1255
1262
|
description: string;
|
|
1256
1263
|
tool?: string | undefined;
|
|
1257
|
-
args?: Record<string,
|
|
1264
|
+
args?: Record<string, unknown> | undefined;
|
|
1258
1265
|
dependencies?: string[] | undefined;
|
|
1259
1266
|
};
|
|
1260
1267
|
success: boolean;
|
|
1261
|
-
result?:
|
|
1268
|
+
result?: unknown;
|
|
1262
1269
|
error?: string | undefined;
|
|
1263
1270
|
}[];
|
|
1264
1271
|
currentStepIndex: number | undefined;
|
|
@@ -1274,7 +1281,7 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1274
1281
|
id: string;
|
|
1275
1282
|
description: string;
|
|
1276
1283
|
tool?: string | undefined;
|
|
1277
|
-
args?: Record<string,
|
|
1284
|
+
args?: Record<string, unknown> | undefined;
|
|
1278
1285
|
dependencies?: string[] | undefined;
|
|
1279
1286
|
}[];
|
|
1280
1287
|
goal: string;
|
|
@@ -1287,11 +1294,11 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1287
1294
|
id: string;
|
|
1288
1295
|
description: string;
|
|
1289
1296
|
tool?: string | undefined;
|
|
1290
|
-
args?: Record<string,
|
|
1297
|
+
args?: Record<string, unknown> | undefined;
|
|
1291
1298
|
dependencies?: string[] | undefined;
|
|
1292
1299
|
};
|
|
1293
1300
|
success: boolean;
|
|
1294
|
-
result?:
|
|
1301
|
+
result?: unknown;
|
|
1295
1302
|
error?: string | undefined;
|
|
1296
1303
|
}[] | undefined;
|
|
1297
1304
|
currentStepIndex?: number | undefined;
|
|
@@ -1307,7 +1314,7 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1307
1314
|
id: string;
|
|
1308
1315
|
description: string;
|
|
1309
1316
|
tool?: string | undefined;
|
|
1310
|
-
args?: Record<string,
|
|
1317
|
+
args?: Record<string, unknown> | undefined;
|
|
1311
1318
|
dependencies?: string[] | undefined;
|
|
1312
1319
|
}[];
|
|
1313
1320
|
goal: string;
|
|
@@ -1318,7 +1325,7 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1318
1325
|
id: string;
|
|
1319
1326
|
description: string;
|
|
1320
1327
|
tool?: string | undefined;
|
|
1321
|
-
args?: Record<string,
|
|
1328
|
+
args?: Record<string, unknown> | undefined;
|
|
1322
1329
|
dependencies?: string[] | undefined;
|
|
1323
1330
|
}[];
|
|
1324
1331
|
goal: string;
|
|
@@ -1331,11 +1338,11 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1331
1338
|
id: string;
|
|
1332
1339
|
description: string;
|
|
1333
1340
|
tool?: string | undefined;
|
|
1334
|
-
args?: Record<string,
|
|
1341
|
+
args?: Record<string, unknown> | undefined;
|
|
1335
1342
|
dependencies?: string[] | undefined;
|
|
1336
1343
|
};
|
|
1337
1344
|
success: boolean;
|
|
1338
|
-
result?:
|
|
1345
|
+
result?: unknown;
|
|
1339
1346
|
error?: string | undefined;
|
|
1340
1347
|
}[], {
|
|
1341
1348
|
timestamp: string;
|
|
@@ -1343,11 +1350,11 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1343
1350
|
id: string;
|
|
1344
1351
|
description: string;
|
|
1345
1352
|
tool?: string | undefined;
|
|
1346
|
-
args?: Record<string,
|
|
1353
|
+
args?: Record<string, unknown> | undefined;
|
|
1347
1354
|
dependencies?: string[] | undefined;
|
|
1348
1355
|
};
|
|
1349
1356
|
success: boolean;
|
|
1350
|
-
result?:
|
|
1357
|
+
result?: unknown;
|
|
1351
1358
|
error?: string | undefined;
|
|
1352
1359
|
}[], unknown>;
|
|
1353
1360
|
currentStepIndex: _langchain_langgraph.BaseChannel<number | undefined, number | undefined, unknown>;
|
|
@@ -1363,7 +1370,7 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1363
1370
|
id: string;
|
|
1364
1371
|
description: string;
|
|
1365
1372
|
tool?: string | undefined;
|
|
1366
|
-
args?: Record<string,
|
|
1373
|
+
args?: Record<string, unknown> | undefined;
|
|
1367
1374
|
dependencies?: string[] | undefined;
|
|
1368
1375
|
}[];
|
|
1369
1376
|
goal: string;
|
|
@@ -1374,7 +1381,7 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1374
1381
|
id: string;
|
|
1375
1382
|
description: string;
|
|
1376
1383
|
tool?: string | undefined;
|
|
1377
|
-
args?: Record<string,
|
|
1384
|
+
args?: Record<string, unknown> | undefined;
|
|
1378
1385
|
dependencies?: string[] | undefined;
|
|
1379
1386
|
}[];
|
|
1380
1387
|
goal: string;
|
|
@@ -1387,11 +1394,11 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1387
1394
|
id: string;
|
|
1388
1395
|
description: string;
|
|
1389
1396
|
tool?: string | undefined;
|
|
1390
|
-
args?: Record<string,
|
|
1397
|
+
args?: Record<string, unknown> | undefined;
|
|
1391
1398
|
dependencies?: string[] | undefined;
|
|
1392
1399
|
};
|
|
1393
1400
|
success: boolean;
|
|
1394
|
-
result?:
|
|
1401
|
+
result?: unknown;
|
|
1395
1402
|
error?: string | undefined;
|
|
1396
1403
|
}[], {
|
|
1397
1404
|
timestamp: string;
|
|
@@ -1399,11 +1406,11 @@ declare function createPlanExecuteAgent(config: PlanExecuteAgentConfig): _langch
|
|
|
1399
1406
|
id: string;
|
|
1400
1407
|
description: string;
|
|
1401
1408
|
tool?: string | undefined;
|
|
1402
|
-
args?: Record<string,
|
|
1409
|
+
args?: Record<string, unknown> | undefined;
|
|
1403
1410
|
dependencies?: string[] | undefined;
|
|
1404
1411
|
};
|
|
1405
1412
|
success: boolean;
|
|
1406
|
-
result?:
|
|
1413
|
+
result?: unknown;
|
|
1407
1414
|
error?: string | undefined;
|
|
1408
1415
|
}[], unknown>;
|
|
1409
1416
|
currentStepIndex: _langchain_langgraph.BaseChannel<number | undefined, number | undefined, unknown>;
|
|
@@ -3255,57 +3262,44 @@ declare const ruleBasedRouting: RoutingStrategyImpl;
|
|
|
3255
3262
|
*/
|
|
3256
3263
|
declare function getRoutingStrategy(name: string): RoutingStrategyImpl;
|
|
3257
3264
|
|
|
3265
|
+
declare const DEFAULT_AGGREGATOR_SYSTEM_PROMPT = "You are an aggregator agent responsible for combining results from multiple worker agents.\n\nYour job is to:\n1. Review all completed task results\n2. Synthesize the information into a coherent response\n3. Ensure all aspects of the original query are addressed\n4. Provide a clear, comprehensive final answer\n\nBe concise but thorough in your aggregation.";
|
|
3258
3266
|
/**
|
|
3259
|
-
*
|
|
3267
|
+
* Creates the aggregator node for the multi-agent workflow.
|
|
3260
3268
|
*
|
|
3261
|
-
*
|
|
3269
|
+
* Aggregation precedence is:
|
|
3270
|
+
* 1. `aggregateFn` when provided
|
|
3271
|
+
* 2. `model`-based synthesis when no custom aggregator is configured
|
|
3272
|
+
* 3. simple concatenation of successful worker results as a fallback
|
|
3262
3273
|
*
|
|
3263
|
-
*
|
|
3274
|
+
* The node always returns a partial state with `status: 'completed'` on
|
|
3275
|
+
* success, or `status: 'failed'` plus an error message when aggregation fails.
|
|
3264
3276
|
*/
|
|
3277
|
+
declare function createAggregatorNode(config?: AggregatorConfig): (state: MultiAgentStateType) => Promise<Partial<MultiAgentStateType>>;
|
|
3265
3278
|
|
|
3266
3279
|
/**
|
|
3267
|
-
*
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
*
|
|
3280
|
+
* Creates the supervisor node for the multi-agent workflow.
|
|
3281
|
+
*
|
|
3282
|
+
* The supervisor owns orchestration concerns: it enforces `maxIterations`,
|
|
3283
|
+
* chooses the next worker or workers through the configured routing strategy,
|
|
3284
|
+
* increments framework-managed `currentWorkload` counters for each new
|
|
3285
|
+
* assignment, and routes to the aggregator once all active assignments have
|
|
3286
|
+
* completed. Routing strategies may return a single `targetAgent` or multiple
|
|
3287
|
+
* `targetAgents` for parallel fan-out.
|
|
3272
3288
|
*/
|
|
3273
3289
|
declare function createSupervisorNode(config: SupervisorConfig): (state: MultiAgentStateType) => Promise<Partial<MultiAgentStateType>>;
|
|
3290
|
+
|
|
3274
3291
|
/**
|
|
3275
|
-
*
|
|
3292
|
+
* Creates a worker node for the multi-agent workflow.
|
|
3276
3293
|
*
|
|
3277
|
-
*
|
|
3278
|
-
*
|
|
3279
|
-
*
|
|
3280
|
-
*
|
|
3281
|
-
*
|
|
3282
|
-
*
|
|
3283
|
-
*
|
|
3284
|
-
*
|
|
3285
|
-
* Custom `executeFn` CAN modify other worker properties (skills, tools,
|
|
3286
|
-
* availability, etc.) and these changes will be preserved and merged with
|
|
3287
|
-
* the workload decrement.
|
|
3288
|
-
*
|
|
3289
|
-
* @example
|
|
3290
|
-
* ```typescript
|
|
3291
|
-
* // ✅ CORRECT: Custom executeFn modifies skills, framework handles workload
|
|
3292
|
-
* const executeFn = async (state) => ({
|
|
3293
|
-
* completedTasks: [...],
|
|
3294
|
-
* workers: {
|
|
3295
|
-
* 'worker1': {
|
|
3296
|
-
* ...state.workers['worker1'],
|
|
3297
|
-
* skills: [...state.workers['worker1'].skills, 'new-skill'], // ✅ OK
|
|
3298
|
-
* // currentWorkload: ... // ❌ DON'T - framework manages this
|
|
3299
|
-
* }
|
|
3300
|
-
* }
|
|
3301
|
-
* });
|
|
3302
|
-
* ```
|
|
3294
|
+
* Worker workload is framework-managed. The node decrements
|
|
3295
|
+
* `state.workers[workerId].currentWorkload` after either a successful execution
|
|
3296
|
+
* result or an error result, so custom `executeFn` implementations should not
|
|
3297
|
+
* adjust workloads themselves. Custom execution results are merged into the
|
|
3298
|
+
* returned partial state first, then the decremented worker snapshot is applied
|
|
3299
|
+
* on top to keep handoff and worker state updates while preserving workload
|
|
3300
|
+
* ownership inside the framework.
|
|
3303
3301
|
*/
|
|
3304
|
-
declare function createWorkerNode(config: WorkerConfig): (state: MultiAgentStateType, runConfig?:
|
|
3305
|
-
/**
|
|
3306
|
-
* Create an aggregator node that combines worker results
|
|
3307
|
-
*/
|
|
3308
|
-
declare function createAggregatorNode(config?: AggregatorConfig): (state: MultiAgentStateType) => Promise<Partial<MultiAgentStateType>>;
|
|
3302
|
+
declare function createWorkerNode(config: WorkerConfig): (state: MultiAgentStateType, runConfig?: WorkerExecutionConfig) => Promise<Partial<MultiAgentStateType>>;
|
|
3309
3303
|
|
|
3310
3304
|
/**
|
|
3311
3305
|
* Multi-Agent System Factory
|