@amitdeshmukh/ax-crew 8.0.2 → 8.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/index.js +5 -1
- package/package.json +1 -1
- package/src/agents/index.ts +8 -1
package/dist/agents/index.js
CHANGED
|
@@ -513,10 +513,14 @@ class AxCrew {
|
|
|
513
513
|
uniqueFunctions.push(fn);
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
+
// Resolve factory functions (e.g., () => new Foo(state).toFunction()) into
|
|
517
|
+
// AxFunction objects before instrumenting, since spreading a JS function
|
|
518
|
+
// does not copy non-enumerable properties like `name`.
|
|
519
|
+
const resolvedFunctions = uniqueFunctions.map(fn => typeof fn === 'function' ? fn() : fn);
|
|
516
520
|
// Wrap each function handler to record call count and latency in MetricsRegistry
|
|
517
521
|
const crewId = this.crewId;
|
|
518
522
|
const agentNameForMetrics = name;
|
|
519
|
-
const instrumentedFunctions =
|
|
523
|
+
const instrumentedFunctions = resolvedFunctions.map(fn => ({
|
|
520
524
|
...fn,
|
|
521
525
|
func: async (args, extra) => {
|
|
522
526
|
const fnStart = performance.now();
|
package/package.json
CHANGED
package/src/agents/index.ts
CHANGED
|
@@ -651,10 +651,17 @@ class AxCrew {
|
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
// Resolve factory functions (e.g., () => new Foo(state).toFunction()) into
|
|
655
|
+
// AxFunction objects before instrumenting, since spreading a JS function
|
|
656
|
+
// does not copy non-enumerable properties like `name`.
|
|
657
|
+
const resolvedFunctions: AxFunction[] = uniqueFunctions.map(fn =>
|
|
658
|
+
typeof fn === 'function' ? (fn as () => AxFunction)() : fn
|
|
659
|
+
);
|
|
660
|
+
|
|
654
661
|
// Wrap each function handler to record call count and latency in MetricsRegistry
|
|
655
662
|
const crewId = this.crewId;
|
|
656
663
|
const agentNameForMetrics = name;
|
|
657
|
-
const instrumentedFunctions: AxFunction[] =
|
|
664
|
+
const instrumentedFunctions: AxFunction[] = resolvedFunctions.map(fn => ({
|
|
658
665
|
...fn,
|
|
659
666
|
func: async (args?: any, extra?: any) => {
|
|
660
667
|
const fnStart = performance.now();
|