@agentforge/patterns 0.16.61 → 0.16.63

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
@@ -2692,10 +2692,28 @@ function getRoutingStrategy(name) {
2692
2692
  }
2693
2693
 
2694
2694
  // src/multi-agent/utils-react-detection.ts
2695
+ function isKnownCompiledGraphName(name) {
2696
+ return name === "CompiledGraph" || name === "CompiledStateGraph";
2697
+ }
2698
+ function hasFunctionProperty(value, key) {
2699
+ return key in value && typeof value[key] === "function";
2700
+ }
2701
+ function hasCompiledGraphBuilder(value) {
2702
+ if (!("builder" in value) || typeof value.builder !== "object" || value.builder === null) {
2703
+ return false;
2704
+ }
2705
+ const builder = value.builder;
2706
+ return hasFunctionProperty(builder, "addNode") && hasFunctionProperty(builder, "addEdge") && hasFunctionProperty(builder, "compile") && hasFunctionProperty(builder, "validate");
2707
+ }
2708
+ function hasCompiledGraphRuntimeShape(value) {
2709
+ return hasFunctionProperty(value, "invoke") && hasFunctionProperty(value, "stream") && hasFunctionProperty(value, "getGraph") && hasFunctionProperty(value, "getGraphAsync") && hasCompiledGraphBuilder(value);
2710
+ }
2695
2711
  function isReActAgent(obj) {
2696
- return Boolean(
2697
- obj && typeof obj === "object" && "invoke" in obj && typeof obj.invoke === "function" && "stream" in obj && typeof obj.stream === "function" && (obj.constructor?.name === "CompiledGraph" || obj.constructor?.name === "CompiledStateGraph")
2698
- );
2712
+ if (!obj || typeof obj !== "object") {
2713
+ return false;
2714
+ }
2715
+ const candidate = obj;
2716
+ return hasCompiledGraphRuntimeShape(candidate) || hasFunctionProperty(candidate, "invoke") && hasFunctionProperty(candidate, "stream") && isKnownCompiledGraphName(candidate.constructor?.name);
2699
2717
  }
2700
2718
 
2701
2719
  // src/multi-agent/utils-shared.ts
@@ -2858,9 +2876,7 @@ function wrapReActAgent(workerId, agent, verbose = false) {
2858
2876
  workerId,
2859
2877
  error: errorMessage
2860
2878
  });
2861
- const currentAssignment = state.activeAssignments.find(
2862
- (assignment) => assignment.workerId === workerId
2863
- );
2879
+ const currentAssignment = findCurrentAssignment(state, workerId);
2864
2880
  if (currentAssignment) {
2865
2881
  const errorResult = {
2866
2882
  assignmentId: currentAssignment.id,
package/dist/index.js CHANGED
@@ -2594,10 +2594,28 @@ function getRoutingStrategy(name) {
2594
2594
  }
2595
2595
 
2596
2596
  // src/multi-agent/utils-react-detection.ts
2597
+ function isKnownCompiledGraphName(name) {
2598
+ return name === "CompiledGraph" || name === "CompiledStateGraph";
2599
+ }
2600
+ function hasFunctionProperty(value, key) {
2601
+ return key in value && typeof value[key] === "function";
2602
+ }
2603
+ function hasCompiledGraphBuilder(value) {
2604
+ if (!("builder" in value) || typeof value.builder !== "object" || value.builder === null) {
2605
+ return false;
2606
+ }
2607
+ const builder = value.builder;
2608
+ return hasFunctionProperty(builder, "addNode") && hasFunctionProperty(builder, "addEdge") && hasFunctionProperty(builder, "compile") && hasFunctionProperty(builder, "validate");
2609
+ }
2610
+ function hasCompiledGraphRuntimeShape(value) {
2611
+ return hasFunctionProperty(value, "invoke") && hasFunctionProperty(value, "stream") && hasFunctionProperty(value, "getGraph") && hasFunctionProperty(value, "getGraphAsync") && hasCompiledGraphBuilder(value);
2612
+ }
2597
2613
  function isReActAgent(obj) {
2598
- return Boolean(
2599
- obj && typeof obj === "object" && "invoke" in obj && typeof obj.invoke === "function" && "stream" in obj && typeof obj.stream === "function" && (obj.constructor?.name === "CompiledGraph" || obj.constructor?.name === "CompiledStateGraph")
2600
- );
2614
+ if (!obj || typeof obj !== "object") {
2615
+ return false;
2616
+ }
2617
+ const candidate = obj;
2618
+ return hasCompiledGraphRuntimeShape(candidate) || hasFunctionProperty(candidate, "invoke") && hasFunctionProperty(candidate, "stream") && isKnownCompiledGraphName(candidate.constructor?.name);
2601
2619
  }
2602
2620
 
2603
2621
  // src/multi-agent/utils-shared.ts
@@ -2760,9 +2778,7 @@ function wrapReActAgent(workerId, agent, verbose = false) {
2760
2778
  workerId,
2761
2779
  error: errorMessage
2762
2780
  });
2763
- const currentAssignment = state.activeAssignments.find(
2764
- (assignment) => assignment.workerId === workerId
2765
- );
2781
+ const currentAssignment = findCurrentAssignment(state, workerId);
2766
2782
  if (currentAssignment) {
2767
2783
  const errorResult = {
2768
2784
  assignmentId: currentAssignment.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge/patterns",
3
- "version": "0.16.61",
3
+ "version": "0.16.63",
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.16.61",
44
+ "@agentforge/core": "0.16.63",
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.16.61",
50
+ "@agentforge/testing": "0.16.63",
51
51
  "@eslint/js": "^9.17.0",
52
52
  "@types/node": "^22.10.2",
53
53
  "eslint": "^9.17.0",