@agentforge/patterns 0.15.7 → 0.15.9

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 CHANGED
@@ -1039,7 +1039,7 @@ function createPlannerNode(config) {
1039
1039
  plannerLogger.info("Plan created", {
1040
1040
  stepCount: plan.steps.length,
1041
1041
  goal: plan.goal.substring(0, 100),
1042
- confidence: plan.confidence,
1042
+ ...plan.confidence !== void 0 ? { confidence: plan.confidence } : {},
1043
1043
  duration: Date.now() - startTime
1044
1044
  });
1045
1045
  return {
@@ -1129,7 +1129,10 @@ function createExecutorNode(config) {
1129
1129
  executorLogger.info("Duplicate step execution prevented", {
1130
1130
  stepId: currentStep.id,
1131
1131
  toolName: currentStep.tool,
1132
- arguments: currentStep.args,
1132
+ ...currentStep.args ? {
1133
+ argumentKeys: Object.keys(currentStep.args),
1134
+ argumentCount: Object.keys(currentStep.args).length
1135
+ } : {},
1133
1136
  iteration,
1134
1137
  cacheHit: true
1135
1138
  });
@@ -1165,7 +1168,7 @@ function createExecutorNode(config) {
1165
1168
  result = null;
1166
1169
  executorLogger.warn("Step execution failed", {
1167
1170
  stepId: currentStep.id,
1168
- toolName: currentStep.tool,
1171
+ ...currentStep.tool ? { toolName: currentStep.tool } : {},
1169
1172
  error,
1170
1173
  iteration
1171
1174
  });
@@ -1243,7 +1246,7 @@ function createReplannerNode(config) {
1243
1246
  if (decision.shouldReplan) {
1244
1247
  replannerLogger.info("Replanning triggered", {
1245
1248
  reason: decision.reason,
1246
- newGoal: decision.newGoal?.substring(0, 100),
1249
+ ...decision.newGoal ? { newGoal: decision.newGoal.substring(0, 100) } : {},
1247
1250
  duration: Date.now() - startTime
1248
1251
  });
1249
1252
  return {
@@ -1745,7 +1748,7 @@ function createReflectorNode(config) {
1745
1748
  }
1746
1749
  reflectorLogger.info("Reflection complete", {
1747
1750
  attempt: state.iteration,
1748
- score: reflection.score,
1751
+ ...reflection.score !== void 0 ? { score: reflection.score } : {},
1749
1752
  meetsStandards: reflection.meetsStandards,
1750
1753
  issueCount: reflection.issues.length,
1751
1754
  suggestionCount: reflection.suggestions.length,
@@ -1787,7 +1790,7 @@ function createReviserNode(config) {
1787
1790
  const lastReflection = state.reflections[state.reflections.length - 1];
1788
1791
  reviserLogger.debug("Revising response", {
1789
1792
  attempt: state.iteration,
1790
- previousScore: lastReflection.score,
1793
+ ...lastReflection.score !== void 0 ? { previousScore: lastReflection.score } : {},
1791
1794
  issueCount: lastReflection.issues.length,
1792
1795
  suggestionCount: lastReflection.suggestions.length
1793
1796
  });
@@ -1815,7 +1818,7 @@ ${revisionsText}`;
1815
1818
  reviserLogger.info("Revision complete", {
1816
1819
  attempt: state.iteration,
1817
1820
  revisionLength: content.length,
1818
- basedOnScore: lastReflection.score,
1821
+ ...lastReflection.score !== void 0 ? { basedOnScore: lastReflection.score } : {},
1819
1822
  duration: Date.now() - startTime
1820
1823
  });
1821
1824
  return {
@@ -2507,8 +2510,8 @@ function wrapReActAgent(workerId, agent, verbose = false) {
2507
2510
  } : runnableConfig;
2508
2511
  logger.debug("Invoking ReAct agent with worker-specific config", {
2509
2512
  workerId,
2510
- parentThreadId: runnableConfig?.configurable?.thread_id,
2511
- workerThreadId,
2513
+ ...runnableConfig?.configurable?.thread_id !== void 0 ? { parentThreadId: String(runnableConfig.configurable.thread_id) } : {},
2514
+ ...workerThreadId ? { workerThreadId } : {},
2512
2515
  hasConfig: !!workerConfig
2513
2516
  });
2514
2517
  const result = await agent.invoke(
@@ -2741,7 +2744,7 @@ function createSupervisorNode(config) {
2741
2744
  } catch (error) {
2742
2745
  logger2.error("Supervisor node error", {
2743
2746
  error: error instanceof Error ? error.message : String(error),
2744
- stack: error instanceof Error ? error.stack : void 0,
2747
+ ...error instanceof Error && error.stack ? { stack: error.stack } : {},
2745
2748
  iteration: state.iteration
2746
2749
  });
2747
2750
  return {
@@ -3017,7 +3020,7 @@ Please synthesize these results into a comprehensive response that addresses the
3017
3020
  } catch (error) {
3018
3021
  logger2.error("Aggregator node error", {
3019
3022
  error: error instanceof Error ? error.message : String(error),
3020
- stack: error instanceof Error ? error.stack : void 0,
3023
+ ...error instanceof Error && error.stack ? { stack: error.stack } : {},
3021
3024
  completedTasks: state.completedTasks.length
3022
3025
  });
3023
3026
  return {
@@ -3083,7 +3086,7 @@ function createMultiAgentSystem(config) {
3083
3086
  const supervisorRouter = (state) => {
3084
3087
  logger3.debug("Supervisor router executing", {
3085
3088
  status: state.status,
3086
- currentAgent: state.currentAgent,
3089
+ ...state.currentAgent ? { currentAgent: state.currentAgent } : {},
3087
3090
  iteration: state.iteration
3088
3091
  });
3089
3092
  if (state.status === "completed" || state.status === "failed") {
package/dist/index.d.cts CHANGED
@@ -131,7 +131,70 @@ type ScratchpadEntry = z.infer<typeof ScratchpadEntrySchema>;
131
131
  *
132
132
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
133
133
  */
134
- declare const ReActState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
134
+ declare const ReActState: _langchain_langgraph.AnnotationRoot<{
135
+ messages: _langchain_langgraph.BaseChannel<{
136
+ role: "system" | "user" | "assistant" | "tool";
137
+ content: string;
138
+ name?: string | undefined;
139
+ tool_call_id?: string | undefined;
140
+ metadata?: Record<string, any> | undefined;
141
+ }[], {
142
+ role: "system" | "user" | "assistant" | "tool";
143
+ content: string;
144
+ name?: string | undefined;
145
+ tool_call_id?: string | undefined;
146
+ metadata?: Record<string, any> | undefined;
147
+ }[], unknown>;
148
+ thoughts: _langchain_langgraph.BaseChannel<{
149
+ content: string;
150
+ metadata?: Record<string, any> | undefined;
151
+ timestamp?: number | undefined;
152
+ }[], {
153
+ content: string;
154
+ metadata?: Record<string, any> | undefined;
155
+ timestamp?: number | undefined;
156
+ }[], unknown>;
157
+ actions: _langchain_langgraph.BaseChannel<{
158
+ name: string;
159
+ id: string;
160
+ arguments: Record<string, any>;
161
+ timestamp?: number | undefined;
162
+ }[], {
163
+ name: string;
164
+ id: string;
165
+ arguments: Record<string, any>;
166
+ timestamp?: number | undefined;
167
+ }[], unknown>;
168
+ observations: _langchain_langgraph.BaseChannel<{
169
+ toolCallId: string;
170
+ timestamp?: number | undefined;
171
+ result?: any;
172
+ error?: string | undefined;
173
+ isDuplicate?: boolean | undefined;
174
+ }[], {
175
+ toolCallId: string;
176
+ timestamp?: number | undefined;
177
+ result?: any;
178
+ error?: string | undefined;
179
+ isDuplicate?: boolean | undefined;
180
+ }[], unknown>;
181
+ scratchpad: _langchain_langgraph.BaseChannel<{
182
+ step: number;
183
+ timestamp?: number | undefined;
184
+ thought?: string | undefined;
185
+ action?: string | undefined;
186
+ observation?: string | undefined;
187
+ }[], {
188
+ step: number;
189
+ timestamp?: number | undefined;
190
+ thought?: string | undefined;
191
+ action?: string | undefined;
192
+ observation?: string | undefined;
193
+ }[], unknown>;
194
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
195
+ shouldContinue: _langchain_langgraph.BaseChannel<boolean | undefined, boolean | undefined, unknown>;
196
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
197
+ }>;
135
198
  /**
136
199
  * TypeScript type for ReAct state
137
200
  */
@@ -905,7 +968,63 @@ declare const PlanExecuteStateConfig: {
905
968
  *
906
969
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
907
970
  */
908
- declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
971
+ declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<{
972
+ input: _langchain_langgraph.BaseChannel<string, string, unknown>;
973
+ plan: _langchain_langgraph.BaseChannel<{
974
+ steps: {
975
+ id: string;
976
+ description: string;
977
+ tool?: string | undefined;
978
+ args?: Record<string, any> | undefined;
979
+ dependencies?: string[] | undefined;
980
+ }[];
981
+ goal: string;
982
+ createdAt: string;
983
+ confidence?: number | undefined;
984
+ } | undefined, {
985
+ steps: {
986
+ id: string;
987
+ description: string;
988
+ tool?: string | undefined;
989
+ args?: Record<string, any> | undefined;
990
+ dependencies?: string[] | undefined;
991
+ }[];
992
+ goal: string;
993
+ createdAt: string;
994
+ confidence?: number | undefined;
995
+ } | undefined, unknown>;
996
+ pastSteps: _langchain_langgraph.BaseChannel<{
997
+ timestamp: string;
998
+ step: {
999
+ id: string;
1000
+ description: string;
1001
+ tool?: string | undefined;
1002
+ args?: Record<string, any> | undefined;
1003
+ dependencies?: string[] | undefined;
1004
+ };
1005
+ success: boolean;
1006
+ result?: any;
1007
+ error?: string | undefined;
1008
+ }[], {
1009
+ timestamp: string;
1010
+ step: {
1011
+ id: string;
1012
+ description: string;
1013
+ tool?: string | undefined;
1014
+ args?: Record<string, any> | undefined;
1015
+ dependencies?: string[] | undefined;
1016
+ };
1017
+ success: boolean;
1018
+ result?: any;
1019
+ error?: string | undefined;
1020
+ }[], unknown>;
1021
+ currentStepIndex: _langchain_langgraph.BaseChannel<number | undefined, number | undefined, unknown>;
1022
+ status: _langchain_langgraph.BaseChannel<"failed" | "planning" | "executing" | "replanning" | "completed", "failed" | "planning" | "executing" | "replanning" | "completed", unknown>;
1023
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1024
+ error: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1025
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
1026
+ maxIterations: _langchain_langgraph.BaseChannel<number, number, unknown>;
1027
+ }>;
909
1028
  /**
910
1029
  * TypeScript type for Plan-Execute state
911
1030
  *
@@ -1595,7 +1714,64 @@ declare const ReflectionStateConfig: {
1595
1714
  *
1596
1715
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
1597
1716
  */
1598
- declare const ReflectionState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
1717
+ declare const ReflectionState: _langchain_langgraph.AnnotationRoot<{
1718
+ input: _langchain_langgraph.BaseChannel<string, string, unknown>;
1719
+ currentResponse: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1720
+ reflections: _langchain_langgraph.BaseChannel<{
1721
+ issues: string[];
1722
+ critique: string;
1723
+ suggestions: string[];
1724
+ meetsStandards: boolean;
1725
+ timestamp?: Date | undefined;
1726
+ score?: number | undefined;
1727
+ }[], {
1728
+ issues: string[];
1729
+ critique: string;
1730
+ suggestions: string[];
1731
+ meetsStandards: boolean;
1732
+ timestamp?: Date | undefined;
1733
+ score?: number | undefined;
1734
+ }[], unknown>;
1735
+ revisions: _langchain_langgraph.BaseChannel<{
1736
+ content: string;
1737
+ iteration: number;
1738
+ timestamp?: Date | undefined;
1739
+ basedOn?: {
1740
+ issues: string[];
1741
+ critique: string;
1742
+ suggestions: string[];
1743
+ meetsStandards: boolean;
1744
+ timestamp?: Date | undefined;
1745
+ score?: number | undefined;
1746
+ } | undefined;
1747
+ }[], {
1748
+ content: string;
1749
+ iteration: number;
1750
+ timestamp?: Date | undefined;
1751
+ basedOn?: {
1752
+ issues: string[];
1753
+ critique: string;
1754
+ suggestions: string[];
1755
+ meetsStandards: boolean;
1756
+ timestamp?: Date | undefined;
1757
+ score?: number | undefined;
1758
+ } | undefined;
1759
+ }[], unknown>;
1760
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
1761
+ status: _langchain_langgraph.BaseChannel<"failed" | "completed" | "generating" | "reflecting" | "revising", "failed" | "completed" | "generating" | "reflecting" | "revising", unknown>;
1762
+ qualityCriteria: _langchain_langgraph.BaseChannel<{
1763
+ minScore: number;
1764
+ requireAll: boolean;
1765
+ criteria?: string[] | undefined;
1766
+ } | undefined, {
1767
+ minScore: number;
1768
+ requireAll: boolean;
1769
+ criteria?: string[] | undefined;
1770
+ } | undefined, unknown>;
1771
+ maxIterations: _langchain_langgraph.BaseChannel<number, number, unknown>;
1772
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1773
+ error: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1774
+ }>;
1599
1775
  /**
1600
1776
  * TypeScript type for Reflection state
1601
1777
  *
@@ -2497,7 +2673,103 @@ declare const MultiAgentStateConfig: {
2497
2673
  *
2498
2674
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
2499
2675
  */
2500
- declare const MultiAgentState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
2676
+ declare const MultiAgentState: _langchain_langgraph.AnnotationRoot<{
2677
+ input: _langchain_langgraph.BaseChannel<string, string, unknown>;
2678
+ messages: _langchain_langgraph.BaseChannel<{
2679
+ content: string;
2680
+ type: "error" | "user_input" | "task_assignment" | "task_result" | "handoff" | "completion";
2681
+ timestamp: number;
2682
+ id: string;
2683
+ from: string;
2684
+ to: string | string[];
2685
+ metadata?: Record<string, any> | undefined;
2686
+ }[], {
2687
+ content: string;
2688
+ type: "error" | "user_input" | "task_assignment" | "task_result" | "handoff" | "completion";
2689
+ timestamp: number;
2690
+ id: string;
2691
+ from: string;
2692
+ to: string | string[];
2693
+ metadata?: Record<string, any> | undefined;
2694
+ }[], unknown>;
2695
+ workers: _langchain_langgraph.BaseChannel<Record<string, {
2696
+ tools: string[];
2697
+ skills: string[];
2698
+ available: boolean;
2699
+ currentWorkload: number;
2700
+ }>, Record<string, {
2701
+ tools: string[];
2702
+ skills: string[];
2703
+ available: boolean;
2704
+ currentWorkload: number;
2705
+ }>, unknown>;
2706
+ currentAgent: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
2707
+ routingHistory: _langchain_langgraph.BaseChannel<{
2708
+ timestamp: number;
2709
+ reasoning: string;
2710
+ confidence: number;
2711
+ targetAgent: string | null;
2712
+ targetAgents: string[] | null;
2713
+ strategy: "llm-based" | "rule-based" | "round-robin" | "skill-based" | "load-balanced";
2714
+ }[], {
2715
+ timestamp: number;
2716
+ reasoning: string;
2717
+ confidence: number;
2718
+ targetAgent: string | null;
2719
+ targetAgents: string[] | null;
2720
+ strategy: "llm-based" | "rule-based" | "round-robin" | "skill-based" | "load-balanced";
2721
+ }[], unknown>;
2722
+ activeAssignments: _langchain_langgraph.BaseChannel<{
2723
+ id: string;
2724
+ workerId: string;
2725
+ task: string;
2726
+ priority: number;
2727
+ assignedAt: number;
2728
+ deadline?: number | undefined;
2729
+ }[], {
2730
+ id: string;
2731
+ workerId: string;
2732
+ task: string;
2733
+ priority: number;
2734
+ assignedAt: number;
2735
+ deadline?: number | undefined;
2736
+ }[], unknown>;
2737
+ completedTasks: _langchain_langgraph.BaseChannel<{
2738
+ result: string;
2739
+ success: boolean;
2740
+ workerId: string;
2741
+ assignmentId: string;
2742
+ completedAt: number;
2743
+ metadata?: Record<string, any> | undefined;
2744
+ error?: string | undefined;
2745
+ }[], {
2746
+ result: string;
2747
+ success: boolean;
2748
+ workerId: string;
2749
+ assignmentId: string;
2750
+ completedAt: number;
2751
+ metadata?: Record<string, any> | undefined;
2752
+ error?: string | undefined;
2753
+ }[], unknown>;
2754
+ handoffs: _langchain_langgraph.BaseChannel<{
2755
+ timestamp: string;
2756
+ reason: string;
2757
+ from: string;
2758
+ to: string;
2759
+ context?: any;
2760
+ }[], {
2761
+ timestamp: string;
2762
+ reason: string;
2763
+ from: string;
2764
+ to: string;
2765
+ context?: any;
2766
+ }[], unknown>;
2767
+ status: _langchain_langgraph.BaseChannel<"failed" | "executing" | "completed" | "initializing" | "routing" | "coordinating" | "aggregating", "failed" | "executing" | "completed" | "initializing" | "routing" | "coordinating" | "aggregating", unknown>;
2768
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
2769
+ maxIterations: _langchain_langgraph.BaseChannel<number, number, unknown>;
2770
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
2771
+ error: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
2772
+ }>;
2501
2773
  /**
2502
2774
  * TypeScript type for Multi-Agent state
2503
2775
  *
package/dist/index.d.ts CHANGED
@@ -131,7 +131,70 @@ type ScratchpadEntry = z.infer<typeof ScratchpadEntrySchema>;
131
131
  *
132
132
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
133
133
  */
134
- declare const ReActState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
134
+ declare const ReActState: _langchain_langgraph.AnnotationRoot<{
135
+ messages: _langchain_langgraph.BaseChannel<{
136
+ role: "system" | "user" | "assistant" | "tool";
137
+ content: string;
138
+ name?: string | undefined;
139
+ tool_call_id?: string | undefined;
140
+ metadata?: Record<string, any> | undefined;
141
+ }[], {
142
+ role: "system" | "user" | "assistant" | "tool";
143
+ content: string;
144
+ name?: string | undefined;
145
+ tool_call_id?: string | undefined;
146
+ metadata?: Record<string, any> | undefined;
147
+ }[], unknown>;
148
+ thoughts: _langchain_langgraph.BaseChannel<{
149
+ content: string;
150
+ metadata?: Record<string, any> | undefined;
151
+ timestamp?: number | undefined;
152
+ }[], {
153
+ content: string;
154
+ metadata?: Record<string, any> | undefined;
155
+ timestamp?: number | undefined;
156
+ }[], unknown>;
157
+ actions: _langchain_langgraph.BaseChannel<{
158
+ name: string;
159
+ id: string;
160
+ arguments: Record<string, any>;
161
+ timestamp?: number | undefined;
162
+ }[], {
163
+ name: string;
164
+ id: string;
165
+ arguments: Record<string, any>;
166
+ timestamp?: number | undefined;
167
+ }[], unknown>;
168
+ observations: _langchain_langgraph.BaseChannel<{
169
+ toolCallId: string;
170
+ timestamp?: number | undefined;
171
+ result?: any;
172
+ error?: string | undefined;
173
+ isDuplicate?: boolean | undefined;
174
+ }[], {
175
+ toolCallId: string;
176
+ timestamp?: number | undefined;
177
+ result?: any;
178
+ error?: string | undefined;
179
+ isDuplicate?: boolean | undefined;
180
+ }[], unknown>;
181
+ scratchpad: _langchain_langgraph.BaseChannel<{
182
+ step: number;
183
+ timestamp?: number | undefined;
184
+ thought?: string | undefined;
185
+ action?: string | undefined;
186
+ observation?: string | undefined;
187
+ }[], {
188
+ step: number;
189
+ timestamp?: number | undefined;
190
+ thought?: string | undefined;
191
+ action?: string | undefined;
192
+ observation?: string | undefined;
193
+ }[], unknown>;
194
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
195
+ shouldContinue: _langchain_langgraph.BaseChannel<boolean | undefined, boolean | undefined, unknown>;
196
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
197
+ }>;
135
198
  /**
136
199
  * TypeScript type for ReAct state
137
200
  */
@@ -905,7 +968,63 @@ declare const PlanExecuteStateConfig: {
905
968
  *
906
969
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
907
970
  */
908
- declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
971
+ declare const PlanExecuteState: _langchain_langgraph.AnnotationRoot<{
972
+ input: _langchain_langgraph.BaseChannel<string, string, unknown>;
973
+ plan: _langchain_langgraph.BaseChannel<{
974
+ steps: {
975
+ id: string;
976
+ description: string;
977
+ tool?: string | undefined;
978
+ args?: Record<string, any> | undefined;
979
+ dependencies?: string[] | undefined;
980
+ }[];
981
+ goal: string;
982
+ createdAt: string;
983
+ confidence?: number | undefined;
984
+ } | undefined, {
985
+ steps: {
986
+ id: string;
987
+ description: string;
988
+ tool?: string | undefined;
989
+ args?: Record<string, any> | undefined;
990
+ dependencies?: string[] | undefined;
991
+ }[];
992
+ goal: string;
993
+ createdAt: string;
994
+ confidence?: number | undefined;
995
+ } | undefined, unknown>;
996
+ pastSteps: _langchain_langgraph.BaseChannel<{
997
+ timestamp: string;
998
+ step: {
999
+ id: string;
1000
+ description: string;
1001
+ tool?: string | undefined;
1002
+ args?: Record<string, any> | undefined;
1003
+ dependencies?: string[] | undefined;
1004
+ };
1005
+ success: boolean;
1006
+ result?: any;
1007
+ error?: string | undefined;
1008
+ }[], {
1009
+ timestamp: string;
1010
+ step: {
1011
+ id: string;
1012
+ description: string;
1013
+ tool?: string | undefined;
1014
+ args?: Record<string, any> | undefined;
1015
+ dependencies?: string[] | undefined;
1016
+ };
1017
+ success: boolean;
1018
+ result?: any;
1019
+ error?: string | undefined;
1020
+ }[], unknown>;
1021
+ currentStepIndex: _langchain_langgraph.BaseChannel<number | undefined, number | undefined, unknown>;
1022
+ status: _langchain_langgraph.BaseChannel<"failed" | "planning" | "executing" | "replanning" | "completed", "failed" | "planning" | "executing" | "replanning" | "completed", unknown>;
1023
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1024
+ error: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1025
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
1026
+ maxIterations: _langchain_langgraph.BaseChannel<number, number, unknown>;
1027
+ }>;
909
1028
  /**
910
1029
  * TypeScript type for Plan-Execute state
911
1030
  *
@@ -1595,7 +1714,64 @@ declare const ReflectionStateConfig: {
1595
1714
  *
1596
1715
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
1597
1716
  */
1598
- declare const ReflectionState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
1717
+ declare const ReflectionState: _langchain_langgraph.AnnotationRoot<{
1718
+ input: _langchain_langgraph.BaseChannel<string, string, unknown>;
1719
+ currentResponse: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1720
+ reflections: _langchain_langgraph.BaseChannel<{
1721
+ issues: string[];
1722
+ critique: string;
1723
+ suggestions: string[];
1724
+ meetsStandards: boolean;
1725
+ timestamp?: Date | undefined;
1726
+ score?: number | undefined;
1727
+ }[], {
1728
+ issues: string[];
1729
+ critique: string;
1730
+ suggestions: string[];
1731
+ meetsStandards: boolean;
1732
+ timestamp?: Date | undefined;
1733
+ score?: number | undefined;
1734
+ }[], unknown>;
1735
+ revisions: _langchain_langgraph.BaseChannel<{
1736
+ content: string;
1737
+ iteration: number;
1738
+ timestamp?: Date | undefined;
1739
+ basedOn?: {
1740
+ issues: string[];
1741
+ critique: string;
1742
+ suggestions: string[];
1743
+ meetsStandards: boolean;
1744
+ timestamp?: Date | undefined;
1745
+ score?: number | undefined;
1746
+ } | undefined;
1747
+ }[], {
1748
+ content: string;
1749
+ iteration: number;
1750
+ timestamp?: Date | undefined;
1751
+ basedOn?: {
1752
+ issues: string[];
1753
+ critique: string;
1754
+ suggestions: string[];
1755
+ meetsStandards: boolean;
1756
+ timestamp?: Date | undefined;
1757
+ score?: number | undefined;
1758
+ } | undefined;
1759
+ }[], unknown>;
1760
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
1761
+ status: _langchain_langgraph.BaseChannel<"failed" | "completed" | "generating" | "reflecting" | "revising", "failed" | "completed" | "generating" | "reflecting" | "revising", unknown>;
1762
+ qualityCriteria: _langchain_langgraph.BaseChannel<{
1763
+ minScore: number;
1764
+ requireAll: boolean;
1765
+ criteria?: string[] | undefined;
1766
+ } | undefined, {
1767
+ minScore: number;
1768
+ requireAll: boolean;
1769
+ criteria?: string[] | undefined;
1770
+ } | undefined, unknown>;
1771
+ maxIterations: _langchain_langgraph.BaseChannel<number, number, unknown>;
1772
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1773
+ error: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
1774
+ }>;
1599
1775
  /**
1600
1776
  * TypeScript type for Reflection state
1601
1777
  *
@@ -2497,7 +2673,103 @@ declare const MultiAgentStateConfig: {
2497
2673
  *
2498
2674
  * This uses LangGraph's Annotation.Root() under the hood, with optional Zod validation.
2499
2675
  */
2500
- declare const MultiAgentState: _langchain_langgraph.AnnotationRoot<_langchain_langgraph.StateDefinition>;
2676
+ declare const MultiAgentState: _langchain_langgraph.AnnotationRoot<{
2677
+ input: _langchain_langgraph.BaseChannel<string, string, unknown>;
2678
+ messages: _langchain_langgraph.BaseChannel<{
2679
+ content: string;
2680
+ type: "error" | "user_input" | "task_assignment" | "task_result" | "handoff" | "completion";
2681
+ timestamp: number;
2682
+ id: string;
2683
+ from: string;
2684
+ to: string | string[];
2685
+ metadata?: Record<string, any> | undefined;
2686
+ }[], {
2687
+ content: string;
2688
+ type: "error" | "user_input" | "task_assignment" | "task_result" | "handoff" | "completion";
2689
+ timestamp: number;
2690
+ id: string;
2691
+ from: string;
2692
+ to: string | string[];
2693
+ metadata?: Record<string, any> | undefined;
2694
+ }[], unknown>;
2695
+ workers: _langchain_langgraph.BaseChannel<Record<string, {
2696
+ tools: string[];
2697
+ skills: string[];
2698
+ available: boolean;
2699
+ currentWorkload: number;
2700
+ }>, Record<string, {
2701
+ tools: string[];
2702
+ skills: string[];
2703
+ available: boolean;
2704
+ currentWorkload: number;
2705
+ }>, unknown>;
2706
+ currentAgent: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
2707
+ routingHistory: _langchain_langgraph.BaseChannel<{
2708
+ timestamp: number;
2709
+ reasoning: string;
2710
+ confidence: number;
2711
+ targetAgent: string | null;
2712
+ targetAgents: string[] | null;
2713
+ strategy: "llm-based" | "rule-based" | "round-robin" | "skill-based" | "load-balanced";
2714
+ }[], {
2715
+ timestamp: number;
2716
+ reasoning: string;
2717
+ confidence: number;
2718
+ targetAgent: string | null;
2719
+ targetAgents: string[] | null;
2720
+ strategy: "llm-based" | "rule-based" | "round-robin" | "skill-based" | "load-balanced";
2721
+ }[], unknown>;
2722
+ activeAssignments: _langchain_langgraph.BaseChannel<{
2723
+ id: string;
2724
+ workerId: string;
2725
+ task: string;
2726
+ priority: number;
2727
+ assignedAt: number;
2728
+ deadline?: number | undefined;
2729
+ }[], {
2730
+ id: string;
2731
+ workerId: string;
2732
+ task: string;
2733
+ priority: number;
2734
+ assignedAt: number;
2735
+ deadline?: number | undefined;
2736
+ }[], unknown>;
2737
+ completedTasks: _langchain_langgraph.BaseChannel<{
2738
+ result: string;
2739
+ success: boolean;
2740
+ workerId: string;
2741
+ assignmentId: string;
2742
+ completedAt: number;
2743
+ metadata?: Record<string, any> | undefined;
2744
+ error?: string | undefined;
2745
+ }[], {
2746
+ result: string;
2747
+ success: boolean;
2748
+ workerId: string;
2749
+ assignmentId: string;
2750
+ completedAt: number;
2751
+ metadata?: Record<string, any> | undefined;
2752
+ error?: string | undefined;
2753
+ }[], unknown>;
2754
+ handoffs: _langchain_langgraph.BaseChannel<{
2755
+ timestamp: string;
2756
+ reason: string;
2757
+ from: string;
2758
+ to: string;
2759
+ context?: any;
2760
+ }[], {
2761
+ timestamp: string;
2762
+ reason: string;
2763
+ from: string;
2764
+ to: string;
2765
+ context?: any;
2766
+ }[], unknown>;
2767
+ status: _langchain_langgraph.BaseChannel<"failed" | "executing" | "completed" | "initializing" | "routing" | "coordinating" | "aggregating", "failed" | "executing" | "completed" | "initializing" | "routing" | "coordinating" | "aggregating", unknown>;
2768
+ iteration: _langchain_langgraph.BaseChannel<number, number, unknown>;
2769
+ maxIterations: _langchain_langgraph.BaseChannel<number, number, unknown>;
2770
+ response: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
2771
+ error: _langchain_langgraph.BaseChannel<string | undefined, string | undefined, unknown>;
2772
+ }>;
2501
2773
  /**
2502
2774
  * TypeScript type for Multi-Agent state
2503
2775
  *
package/dist/index.js CHANGED
@@ -936,7 +936,7 @@ function createPlannerNode(config) {
936
936
  plannerLogger.info("Plan created", {
937
937
  stepCount: plan.steps.length,
938
938
  goal: plan.goal.substring(0, 100),
939
- confidence: plan.confidence,
939
+ ...plan.confidence !== void 0 ? { confidence: plan.confidence } : {},
940
940
  duration: Date.now() - startTime
941
941
  });
942
942
  return {
@@ -1026,7 +1026,10 @@ function createExecutorNode(config) {
1026
1026
  executorLogger.info("Duplicate step execution prevented", {
1027
1027
  stepId: currentStep.id,
1028
1028
  toolName: currentStep.tool,
1029
- arguments: currentStep.args,
1029
+ ...currentStep.args ? {
1030
+ argumentKeys: Object.keys(currentStep.args),
1031
+ argumentCount: Object.keys(currentStep.args).length
1032
+ } : {},
1030
1033
  iteration,
1031
1034
  cacheHit: true
1032
1035
  });
@@ -1062,7 +1065,7 @@ function createExecutorNode(config) {
1062
1065
  result = null;
1063
1066
  executorLogger.warn("Step execution failed", {
1064
1067
  stepId: currentStep.id,
1065
- toolName: currentStep.tool,
1068
+ ...currentStep.tool ? { toolName: currentStep.tool } : {},
1066
1069
  error,
1067
1070
  iteration
1068
1071
  });
@@ -1140,7 +1143,7 @@ function createReplannerNode(config) {
1140
1143
  if (decision.shouldReplan) {
1141
1144
  replannerLogger.info("Replanning triggered", {
1142
1145
  reason: decision.reason,
1143
- newGoal: decision.newGoal?.substring(0, 100),
1146
+ ...decision.newGoal ? { newGoal: decision.newGoal.substring(0, 100) } : {},
1144
1147
  duration: Date.now() - startTime
1145
1148
  });
1146
1149
  return {
@@ -1642,7 +1645,7 @@ function createReflectorNode(config) {
1642
1645
  }
1643
1646
  reflectorLogger.info("Reflection complete", {
1644
1647
  attempt: state.iteration,
1645
- score: reflection.score,
1648
+ ...reflection.score !== void 0 ? { score: reflection.score } : {},
1646
1649
  meetsStandards: reflection.meetsStandards,
1647
1650
  issueCount: reflection.issues.length,
1648
1651
  suggestionCount: reflection.suggestions.length,
@@ -1684,7 +1687,7 @@ function createReviserNode(config) {
1684
1687
  const lastReflection = state.reflections[state.reflections.length - 1];
1685
1688
  reviserLogger.debug("Revising response", {
1686
1689
  attempt: state.iteration,
1687
- previousScore: lastReflection.score,
1690
+ ...lastReflection.score !== void 0 ? { previousScore: lastReflection.score } : {},
1688
1691
  issueCount: lastReflection.issues.length,
1689
1692
  suggestionCount: lastReflection.suggestions.length
1690
1693
  });
@@ -1712,7 +1715,7 @@ ${revisionsText}`;
1712
1715
  reviserLogger.info("Revision complete", {
1713
1716
  attempt: state.iteration,
1714
1717
  revisionLength: content.length,
1715
- basedOnScore: lastReflection.score,
1718
+ ...lastReflection.score !== void 0 ? { basedOnScore: lastReflection.score } : {},
1716
1719
  duration: Date.now() - startTime
1717
1720
  });
1718
1721
  return {
@@ -2404,8 +2407,8 @@ function wrapReActAgent(workerId, agent, verbose = false) {
2404
2407
  } : runnableConfig;
2405
2408
  logger.debug("Invoking ReAct agent with worker-specific config", {
2406
2409
  workerId,
2407
- parentThreadId: runnableConfig?.configurable?.thread_id,
2408
- workerThreadId,
2410
+ ...runnableConfig?.configurable?.thread_id !== void 0 ? { parentThreadId: String(runnableConfig.configurable.thread_id) } : {},
2411
+ ...workerThreadId ? { workerThreadId } : {},
2409
2412
  hasConfig: !!workerConfig
2410
2413
  });
2411
2414
  const result = await agent.invoke(
@@ -2638,7 +2641,7 @@ function createSupervisorNode(config) {
2638
2641
  } catch (error) {
2639
2642
  logger2.error("Supervisor node error", {
2640
2643
  error: error instanceof Error ? error.message : String(error),
2641
- stack: error instanceof Error ? error.stack : void 0,
2644
+ ...error instanceof Error && error.stack ? { stack: error.stack } : {},
2642
2645
  iteration: state.iteration
2643
2646
  });
2644
2647
  return {
@@ -2914,7 +2917,7 @@ Please synthesize these results into a comprehensive response that addresses the
2914
2917
  } catch (error) {
2915
2918
  logger2.error("Aggregator node error", {
2916
2919
  error: error instanceof Error ? error.message : String(error),
2917
- stack: error instanceof Error ? error.stack : void 0,
2920
+ ...error instanceof Error && error.stack ? { stack: error.stack } : {},
2918
2921
  completedTasks: state.completedTasks.length
2919
2922
  });
2920
2923
  return {
@@ -2980,7 +2983,7 @@ function createMultiAgentSystem(config) {
2980
2983
  const supervisorRouter = (state) => {
2981
2984
  logger3.debug("Supervisor router executing", {
2982
2985
  status: state.status,
2983
- currentAgent: state.currentAgent,
2986
+ ...state.currentAgent ? { currentAgent: state.currentAgent } : {},
2984
2987
  iteration: state.iteration
2985
2988
  });
2986
2989
  if (state.status === "completed" || state.status === "failed") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge/patterns",
3
- "version": "0.15.7",
3
+ "version": "0.15.9",
4
4
  "description": "Production-ready agent workflow patterns for TypeScript including ReAct and Planner-Executor, built on LangGraph.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -41,13 +41,13 @@
41
41
  "url": "https://github.com/TVScoundrel/agentforge/issues"
42
42
  },
43
43
  "dependencies": {
44
- "@agentforge/core": "0.15.7",
44
+ "@agentforge/core": "0.15.9",
45
45
  "@langchain/core": "^1.1.17",
46
46
  "@langchain/langgraph": "^1.1.2",
47
47
  "zod": "^3.23.8"
48
48
  },
49
49
  "devDependencies": {
50
- "@agentforge/testing": "0.15.7",
50
+ "@agentforge/testing": "0.15.9",
51
51
  "@eslint/js": "^9.17.0",
52
52
  "@types/node": "^22.10.2",
53
53
  "eslint": "^9.17.0",