@agentionai/agents 0.3.0-beta

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.
Files changed (91) hide show
  1. package/README.md +517 -0
  2. package/dist/agents/Agent.d.ts +29 -0
  3. package/dist/agents/Agent.js +28 -0
  4. package/dist/agents/AgentConfig.d.ts +118 -0
  5. package/dist/agents/AgentConfig.js +3 -0
  6. package/dist/agents/AgentEvent.d.ts +18 -0
  7. package/dist/agents/AgentEvent.js +26 -0
  8. package/dist/agents/BaseAgent.d.ts +82 -0
  9. package/dist/agents/BaseAgent.js +121 -0
  10. package/dist/agents/anthropic/ClaudeAgent.d.ts +46 -0
  11. package/dist/agents/anthropic/ClaudeAgent.js +262 -0
  12. package/dist/agents/errors/AgentError.d.ts +47 -0
  13. package/dist/agents/errors/AgentError.js +74 -0
  14. package/dist/agents/google/GeminiAgent.d.ts +63 -0
  15. package/dist/agents/google/GeminiAgent.js +395 -0
  16. package/dist/agents/mistral/MistralAgent.d.ts +47 -0
  17. package/dist/agents/mistral/MistralAgent.js +313 -0
  18. package/dist/agents/model-types.d.ts +30 -0
  19. package/dist/agents/model-types.js +8 -0
  20. package/dist/agents/openai/OpenAiAgent.d.ts +48 -0
  21. package/dist/agents/openai/OpenAiAgent.js +338 -0
  22. package/dist/chunkers/Chunker.d.ts +53 -0
  23. package/dist/chunkers/Chunker.js +174 -0
  24. package/dist/chunkers/RecursiveChunker.d.ts +52 -0
  25. package/dist/chunkers/RecursiveChunker.js +166 -0
  26. package/dist/chunkers/TextChunker.d.ts +27 -0
  27. package/dist/chunkers/TextChunker.js +50 -0
  28. package/dist/chunkers/TokenChunker.d.ts +60 -0
  29. package/dist/chunkers/TokenChunker.js +176 -0
  30. package/dist/chunkers/index.d.ts +6 -0
  31. package/dist/chunkers/index.js +14 -0
  32. package/dist/chunkers/types.d.ts +95 -0
  33. package/dist/chunkers/types.js +3 -0
  34. package/dist/graph/AgentGraph.d.ts +99 -0
  35. package/dist/graph/AgentGraph.js +115 -0
  36. package/dist/graph/BaseExecutor.d.ts +86 -0
  37. package/dist/graph/BaseExecutor.js +61 -0
  38. package/dist/graph/GraphMetrics.d.ts +143 -0
  39. package/dist/graph/GraphMetrics.js +264 -0
  40. package/dist/graph/MapExecutor.d.ts +39 -0
  41. package/dist/graph/MapExecutor.js +123 -0
  42. package/dist/graph/ParallelExecutor.d.ts +51 -0
  43. package/dist/graph/ParallelExecutor.js +103 -0
  44. package/dist/graph/Pipeline.d.ts +44 -0
  45. package/dist/graph/Pipeline.js +109 -0
  46. package/dist/graph/RouterExecutor.d.ts +89 -0
  47. package/dist/graph/RouterExecutor.js +209 -0
  48. package/dist/graph/SequentialExecutor.d.ts +44 -0
  49. package/dist/graph/SequentialExecutor.js +115 -0
  50. package/dist/graph/VotingSystem.d.ts +54 -0
  51. package/dist/graph/VotingSystem.js +106 -0
  52. package/dist/history/History.d.ts +107 -0
  53. package/dist/history/History.js +166 -0
  54. package/dist/history/RedisHistory.d.ts +27 -0
  55. package/dist/history/RedisHistory.js +55 -0
  56. package/dist/history/transformers.d.ts +102 -0
  57. package/dist/history/transformers.js +415 -0
  58. package/dist/history/types.d.ts +130 -0
  59. package/dist/history/types.js +55 -0
  60. package/dist/index.d.ts +16 -0
  61. package/dist/index.js +48 -0
  62. package/dist/ingestion/IngestionPipeline.d.ts +86 -0
  63. package/dist/ingestion/IngestionPipeline.js +266 -0
  64. package/dist/ingestion/index.d.ts +3 -0
  65. package/dist/ingestion/index.js +7 -0
  66. package/dist/ingestion/types.d.ts +74 -0
  67. package/dist/ingestion/types.js +3 -0
  68. package/dist/team/Team.d.ts +46 -0
  69. package/dist/team/Team.js +104 -0
  70. package/dist/tools/Tool.d.ts +75 -0
  71. package/dist/tools/Tool.js +137 -0
  72. package/dist/vectorstore/Embeddings.d.ts +67 -0
  73. package/dist/vectorstore/Embeddings.js +54 -0
  74. package/dist/vectorstore/LanceDBVectorStore.d.ts +149 -0
  75. package/dist/vectorstore/LanceDBVectorStore.js +338 -0
  76. package/dist/vectorstore/OpenAIEmbeddings.d.ts +45 -0
  77. package/dist/vectorstore/OpenAIEmbeddings.js +109 -0
  78. package/dist/vectorstore/VectorStore.d.ts +255 -0
  79. package/dist/vectorstore/VectorStore.js +216 -0
  80. package/dist/vectorstore/index.d.ts +28 -0
  81. package/dist/vectorstore/index.js +35 -0
  82. package/dist/viz/VizConfig.d.ts +54 -0
  83. package/dist/viz/VizConfig.js +100 -0
  84. package/dist/viz/VizReporter.d.ts +127 -0
  85. package/dist/viz/VizReporter.js +595 -0
  86. package/dist/viz/index.d.ts +31 -0
  87. package/dist/viz/index.js +51 -0
  88. package/dist/viz/types.d.ts +105 -0
  89. package/dist/viz/types.js +7 -0
  90. package/package.json +109 -0
  91. package/readme.md +1 -0
@@ -0,0 +1,99 @@
1
+ import { BaseAgent } from "../agents/BaseAgent";
2
+ import { GraphNode } from "./BaseExecutor";
3
+ import { MapExecutor, MapExecutorOptions } from "./MapExecutor";
4
+ import { ParallelExecutor, ParallelExecutorOptions } from "./ParallelExecutor";
5
+ import { Pipeline } from "./Pipeline";
6
+ import { RouterExecutor, RouterExecutorOptions, Route } from "./RouterExecutor";
7
+ import { SequentialExecutor, SequentialExecutorOptions } from "./SequentialExecutor";
8
+ import { VotingSystem, VotingSystemOptions } from "./VotingSystem";
9
+ export { GraphNode } from "./BaseExecutor";
10
+ export { SequentialExecutor, SequentialExecutorOptions, } from "./SequentialExecutor";
11
+ export { ParallelExecutor, ParallelExecutorOptions } from "./ParallelExecutor";
12
+ export { Pipeline } from "./Pipeline";
13
+ export { MapExecutor, MapExecutorOptions } from "./MapExecutor";
14
+ export { VotingSystem, VotingSystemOptions, VotingInput } from "./VotingSystem";
15
+ export { RouterExecutor, RouterExecutorOptions, Route } from "./RouterExecutor";
16
+ export { BaseExecutor, PipelineContext, ContextualInput, NodeInput, NodeOutput, MetricsCollector, NodeExecutionMetrics, MetricsTokenUsage, GraphNodeType, } from "./BaseExecutor";
17
+ export { PipelineMetrics, PipelineStructure, getMetricsCollector, setMetricsCollector, createMetricsCollector, } from "./GraphMetrics";
18
+ /**
19
+ * Factory class for building agent graphs and workflows.
20
+ * Provides static methods to create various execution patterns.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Simple sequential workflow
25
+ * const workflow = AgentGraph.sequential(researchAgent, summaryAgent);
26
+ *
27
+ * // Parallel experts with voting
28
+ * const pipeline = AgentGraph.pipeline(
29
+ * AgentGraph.parallel({}, expertA, expertB, expertC),
30
+ * { execute: async (results) => ({ originalInput: query, solutions: results }) },
31
+ * AgentGraph.votingSystem(judgeAgent)
32
+ * );
33
+ * ```
34
+ */
35
+ export declare class AgentGraph {
36
+ /**
37
+ * Creates a sequential executor that chains agents together.
38
+ * Output of each agent becomes input to the next.
39
+ *
40
+ * @param agents - Agents to execute in sequence
41
+ * @returns SequentialExecutor instance
42
+ */
43
+ static sequential(...agents: BaseAgent[]): SequentialExecutor;
44
+ static sequential(options: SequentialExecutorOptions, ...agents: BaseAgent[]): SequentialExecutor;
45
+ /**
46
+ * Creates a parallel executor that runs agents concurrently.
47
+ * All agents receive the same input and results are collected.
48
+ *
49
+ * @param options - Configuration options
50
+ * @param agents - Agents to execute in parallel
51
+ * @returns ParallelExecutor instance
52
+ */
53
+ static parallel(options?: ParallelExecutorOptions, ...agents: BaseAgent[]): ParallelExecutor;
54
+ /**
55
+ * Creates a voting system with a judge agent.
56
+ * Used to select or synthesize the best answer from multiple solutions.
57
+ *
58
+ * @param judge - Agent that will evaluate and select the best answer
59
+ * @param options - Configuration options
60
+ * @returns VotingSystem instance
61
+ */
62
+ static votingSystem(judge: BaseAgent, options?: VotingSystemOptions): VotingSystem;
63
+ /**
64
+ * Creates a map executor that applies a processor to each item in an array.
65
+ *
66
+ * @param processor - GraphNode to apply to each item
67
+ * @param options - Configuration options
68
+ * @returns MapExecutor instance
69
+ */
70
+ static map<TItem = string, TResult = string>(processor: GraphNode<TItem, TResult>, options?: MapExecutorOptions): MapExecutor<TItem, TResult>;
71
+ /**
72
+ * Creates a pipeline that chains multiple graph nodes together.
73
+ * Output of each stage becomes input to the next.
74
+ *
75
+ * @param stages - GraphNodes to execute in sequence
76
+ * @returns Pipeline instance
77
+ */
78
+ static pipeline<TInput = unknown, TOutput = unknown>(...stages: GraphNode<unknown, unknown>[]): Pipeline<TInput, TOutput>;
79
+ /**
80
+ * Creates a router executor that routes input to one of several handlers.
81
+ * A router agent analyzes the input and selects the most appropriate route.
82
+ *
83
+ * @param router - Agent that decides which route to select
84
+ * @param routes - Array of available routes with names, descriptions, and handlers
85
+ * @param options - Configuration options
86
+ * @returns RouterExecutor instance
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * const router = AgentGraph.router(routerAgent, [
91
+ * { name: "technical", description: "Technical questions", handler: techAgent },
92
+ * { name: "general", description: "General questions", handler: generalAgent },
93
+ * ]);
94
+ * const result = await router.execute("How do I fix this bug?");
95
+ * ```
96
+ */
97
+ static router(router: BaseAgent, routes: Route[], options?: RouterExecutorOptions): RouterExecutor;
98
+ }
99
+ //# sourceMappingURL=AgentGraph.d.ts.map
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentGraph = exports.createMetricsCollector = exports.setMetricsCollector = exports.getMetricsCollector = exports.MetricsCollector = exports.BaseExecutor = exports.RouterExecutor = exports.VotingSystem = exports.MapExecutor = exports.Pipeline = exports.ParallelExecutor = exports.SequentialExecutor = void 0;
4
+ const MapExecutor_1 = require("./MapExecutor");
5
+ const ParallelExecutor_1 = require("./ParallelExecutor");
6
+ const Pipeline_1 = require("./Pipeline");
7
+ const RouterExecutor_1 = require("./RouterExecutor");
8
+ const SequentialExecutor_1 = require("./SequentialExecutor");
9
+ const VotingSystem_1 = require("./VotingSystem");
10
+ var SequentialExecutor_2 = require("./SequentialExecutor");
11
+ Object.defineProperty(exports, "SequentialExecutor", { enumerable: true, get: function () { return SequentialExecutor_2.SequentialExecutor; } });
12
+ var ParallelExecutor_2 = require("./ParallelExecutor");
13
+ Object.defineProperty(exports, "ParallelExecutor", { enumerable: true, get: function () { return ParallelExecutor_2.ParallelExecutor; } });
14
+ var Pipeline_2 = require("./Pipeline");
15
+ Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return Pipeline_2.Pipeline; } });
16
+ var MapExecutor_2 = require("./MapExecutor");
17
+ Object.defineProperty(exports, "MapExecutor", { enumerable: true, get: function () { return MapExecutor_2.MapExecutor; } });
18
+ var VotingSystem_2 = require("./VotingSystem");
19
+ Object.defineProperty(exports, "VotingSystem", { enumerable: true, get: function () { return VotingSystem_2.VotingSystem; } });
20
+ var RouterExecutor_2 = require("./RouterExecutor");
21
+ Object.defineProperty(exports, "RouterExecutor", { enumerable: true, get: function () { return RouterExecutor_2.RouterExecutor; } });
22
+ var BaseExecutor_1 = require("./BaseExecutor");
23
+ Object.defineProperty(exports, "BaseExecutor", { enumerable: true, get: function () { return BaseExecutor_1.BaseExecutor; } });
24
+ Object.defineProperty(exports, "MetricsCollector", { enumerable: true, get: function () { return BaseExecutor_1.MetricsCollector; } });
25
+ var GraphMetrics_1 = require("./GraphMetrics");
26
+ Object.defineProperty(exports, "getMetricsCollector", { enumerable: true, get: function () { return GraphMetrics_1.getMetricsCollector; } });
27
+ Object.defineProperty(exports, "setMetricsCollector", { enumerable: true, get: function () { return GraphMetrics_1.setMetricsCollector; } });
28
+ Object.defineProperty(exports, "createMetricsCollector", { enumerable: true, get: function () { return GraphMetrics_1.createMetricsCollector; } });
29
+ /**
30
+ * Factory class for building agent graphs and workflows.
31
+ * Provides static methods to create various execution patterns.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Simple sequential workflow
36
+ * const workflow = AgentGraph.sequential(researchAgent, summaryAgent);
37
+ *
38
+ * // Parallel experts with voting
39
+ * const pipeline = AgentGraph.pipeline(
40
+ * AgentGraph.parallel({}, expertA, expertB, expertC),
41
+ * { execute: async (results) => ({ originalInput: query, solutions: results }) },
42
+ * AgentGraph.votingSystem(judgeAgent)
43
+ * );
44
+ * ```
45
+ */
46
+ class AgentGraph {
47
+ static sequential(...args) {
48
+ return new SequentialExecutor_1.SequentialExecutor(...args);
49
+ }
50
+ /**
51
+ * Creates a parallel executor that runs agents concurrently.
52
+ * All agents receive the same input and results are collected.
53
+ *
54
+ * @param options - Configuration options
55
+ * @param agents - Agents to execute in parallel
56
+ * @returns ParallelExecutor instance
57
+ */
58
+ static parallel(options = {}, ...agents) {
59
+ return new ParallelExecutor_1.ParallelExecutor(options, ...agents);
60
+ }
61
+ /**
62
+ * Creates a voting system with a judge agent.
63
+ * Used to select or synthesize the best answer from multiple solutions.
64
+ *
65
+ * @param judge - Agent that will evaluate and select the best answer
66
+ * @param options - Configuration options
67
+ * @returns VotingSystem instance
68
+ */
69
+ static votingSystem(judge, options = {}) {
70
+ return new VotingSystem_1.VotingSystem(judge, options);
71
+ }
72
+ /**
73
+ * Creates a map executor that applies a processor to each item in an array.
74
+ *
75
+ * @param processor - GraphNode to apply to each item
76
+ * @param options - Configuration options
77
+ * @returns MapExecutor instance
78
+ */
79
+ static map(processor, options = {}) {
80
+ return new MapExecutor_1.MapExecutor(processor, options);
81
+ }
82
+ /**
83
+ * Creates a pipeline that chains multiple graph nodes together.
84
+ * Output of each stage becomes input to the next.
85
+ *
86
+ * @param stages - GraphNodes to execute in sequence
87
+ * @returns Pipeline instance
88
+ */
89
+ static pipeline(...stages) {
90
+ return new Pipeline_1.Pipeline(...stages);
91
+ }
92
+ /**
93
+ * Creates a router executor that routes input to one of several handlers.
94
+ * A router agent analyzes the input and selects the most appropriate route.
95
+ *
96
+ * @param router - Agent that decides which route to select
97
+ * @param routes - Array of available routes with names, descriptions, and handlers
98
+ * @param options - Configuration options
99
+ * @returns RouterExecutor instance
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const router = AgentGraph.router(routerAgent, [
104
+ * { name: "technical", description: "Technical questions", handler: techAgent },
105
+ * { name: "general", description: "General questions", handler: generalAgent },
106
+ * ]);
107
+ * const result = await router.execute("How do I fix this bug?");
108
+ * ```
109
+ */
110
+ static router(router, routes, options = {}) {
111
+ return new RouterExecutor_1.RouterExecutor(router, routes, options);
112
+ }
113
+ }
114
+ exports.AgentGraph = AgentGraph;
115
+ //# sourceMappingURL=AgentGraph.js.map
@@ -0,0 +1,86 @@
1
+ import { MetricsCollector, NodeExecutionMetrics } from "./GraphMetrics";
2
+ /**
3
+ * Type identifier for graph nodes.
4
+ */
5
+ export type GraphNodeType = "sequential" | "parallel" | "pipeline" | "map" | "voting" | "router" | "agent" | "custom";
6
+ /**
7
+ * Represents a node in the agent graph that can process inputs and produce outputs.
8
+ * Uses generics for type-safe input/output handling.
9
+ */
10
+ export interface GraphNode<TInput = unknown, TOutput = unknown> {
11
+ execute(input: TInput): Promise<TOutput>;
12
+ /** Optional name for the node (used in metrics) */
13
+ name?: string;
14
+ /** Type of the node (used in metrics and visualization) */
15
+ nodeType?: GraphNodeType;
16
+ }
17
+ /**
18
+ * Options for executor execution with metrics tracking.
19
+ */
20
+ export interface ExecutorOptions {
21
+ /** Metrics collector for tracking execution data */
22
+ metrics?: MetricsCollector;
23
+ /** Whether to collect metrics (default: false) */
24
+ collectMetrics?: boolean;
25
+ }
26
+ /**
27
+ * Base class for executors that implement the GraphNode interface.
28
+ * Provides a foundation for building type-safe graph executors with optional metrics.
29
+ */
30
+ export declare abstract class BaseExecutor<TInput = unknown, TOutput = unknown> implements GraphNode<TInput, TOutput> {
31
+ /** Display name for this executor */
32
+ name: string;
33
+ /** Type of this node for metrics and visualization */
34
+ nodeType: GraphNodeType;
35
+ /** Metrics collector for this executor */
36
+ protected metricsCollector?: MetricsCollector;
37
+ /** Whether metrics collection is enabled */
38
+ protected collectMetrics: boolean;
39
+ /**
40
+ * Enable metrics collection for this executor.
41
+ */
42
+ withMetrics(collector?: MetricsCollector): this;
43
+ /**
44
+ * Set a custom name for this executor (used in metrics).
45
+ */
46
+ withName(name: string): this;
47
+ /**
48
+ * Get the metrics collector (creates one if needed and metrics enabled).
49
+ */
50
+ protected getCollector(): MetricsCollector | undefined;
51
+ /**
52
+ * Get collected metrics (if metrics collection is enabled).
53
+ */
54
+ getMetrics(): NodeExecutionMetrics[] | undefined;
55
+ /**
56
+ * Get the metrics collector instance.
57
+ */
58
+ getMetricsCollector(): MetricsCollector | undefined;
59
+ abstract execute(input: TInput): Promise<TOutput>;
60
+ }
61
+ /**
62
+ * Configuration for passing context through pipeline stages.
63
+ */
64
+ export interface PipelineContext {
65
+ /** The original input that started the pipeline */
66
+ originalInput?: unknown;
67
+ /** Metadata that can be passed between stages */
68
+ metadata?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Input wrapper that includes both the value and pipeline context.
72
+ */
73
+ export interface ContextualInput<T = unknown> {
74
+ value: T;
75
+ context: PipelineContext;
76
+ }
77
+ /**
78
+ * Helper type for extracting input type from a GraphNode
79
+ */
80
+ export type NodeInput<T> = T extends GraphNode<infer I, unknown> ? I : never;
81
+ /**
82
+ * Helper type for extracting output type from a GraphNode
83
+ */
84
+ export type NodeOutput<T> = T extends GraphNode<unknown, infer O> ? O : never;
85
+ export { MetricsCollector, NodeExecutionMetrics, MetricsTokenUsage, } from "./GraphMetrics";
86
+ //# sourceMappingURL=BaseExecutor.d.ts.map
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetricsCollector = exports.BaseExecutor = void 0;
4
+ const GraphMetrics_1 = require("./GraphMetrics");
5
+ /**
6
+ * Base class for executors that implement the GraphNode interface.
7
+ * Provides a foundation for building type-safe graph executors with optional metrics.
8
+ */
9
+ class BaseExecutor {
10
+ constructor() {
11
+ /** Display name for this executor */
12
+ this.name = this.constructor.name;
13
+ /** Type of this node for metrics and visualization */
14
+ this.nodeType = "custom";
15
+ /** Whether metrics collection is enabled */
16
+ this.collectMetrics = false;
17
+ }
18
+ /**
19
+ * Enable metrics collection for this executor.
20
+ */
21
+ withMetrics(collector) {
22
+ this.collectMetrics = true;
23
+ this.metricsCollector = collector;
24
+ return this;
25
+ }
26
+ /**
27
+ * Set a custom name for this executor (used in metrics).
28
+ */
29
+ withName(name) {
30
+ this.name = name;
31
+ return this;
32
+ }
33
+ /**
34
+ * Get the metrics collector (creates one if needed and metrics enabled).
35
+ */
36
+ getCollector() {
37
+ if (!this.collectMetrics)
38
+ return undefined;
39
+ if (!this.metricsCollector) {
40
+ this.metricsCollector = new GraphMetrics_1.MetricsCollector();
41
+ }
42
+ return this.metricsCollector;
43
+ }
44
+ /**
45
+ * Get collected metrics (if metrics collection is enabled).
46
+ */
47
+ getMetrics() {
48
+ return this.metricsCollector?.getExecutions();
49
+ }
50
+ /**
51
+ * Get the metrics collector instance.
52
+ */
53
+ getMetricsCollector() {
54
+ return this.metricsCollector;
55
+ }
56
+ }
57
+ exports.BaseExecutor = BaseExecutor;
58
+ // Re-export metrics types for convenience
59
+ var GraphMetrics_2 = require("./GraphMetrics");
60
+ Object.defineProperty(exports, "MetricsCollector", { enumerable: true, get: function () { return GraphMetrics_2.MetricsCollector; } });
61
+ //# sourceMappingURL=BaseExecutor.js.map
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Metrics and observability for graph execution.
3
+ * Tracks timing, token usage, and pipeline structure for analysis and visualization.
4
+ */
5
+ /**
6
+ * Token usage statistics from an LLM call (for metrics tracking).
7
+ */
8
+ export interface MetricsTokenUsage {
9
+ inputTokens: number;
10
+ outputTokens: number;
11
+ totalTokens: number;
12
+ }
13
+ /**
14
+ * Metrics for a single node execution.
15
+ */
16
+ export interface NodeExecutionMetrics {
17
+ /** Unique identifier for this execution */
18
+ id: string;
19
+ /** Name of the node/agent */
20
+ name: string;
21
+ /** Type of executor (sequential, parallel, pipeline, map, voting, router, agent) */
22
+ type: "sequential" | "parallel" | "pipeline" | "map" | "voting" | "router" | "agent" | "custom";
23
+ /** Start timestamp */
24
+ startTime: number;
25
+ /** End timestamp */
26
+ endTime: number;
27
+ /** Duration in milliseconds */
28
+ durationMs: number;
29
+ /** Token usage if applicable */
30
+ tokenUsage?: MetricsTokenUsage;
31
+ /** Whether execution succeeded */
32
+ success: boolean;
33
+ /** Error message if failed */
34
+ error?: string;
35
+ /** Input summary (truncated for large inputs) */
36
+ inputSummary?: string;
37
+ /** Output summary (truncated for large outputs) */
38
+ outputSummary?: string;
39
+ /** Child node metrics (for composite executors) */
40
+ children?: NodeExecutionMetrics[];
41
+ /** Execution order within parent (for sequential/parallel) */
42
+ order?: number;
43
+ }
44
+ /**
45
+ * Aggregate metrics for a complete pipeline execution.
46
+ */
47
+ export interface PipelineMetrics {
48
+ /** Total execution time in milliseconds */
49
+ totalDurationMs: number;
50
+ /** Total tokens used across all nodes */
51
+ totalTokens: MetricsTokenUsage;
52
+ /** Number of nodes executed */
53
+ nodeCount: number;
54
+ /** Number of successful executions */
55
+ successCount: number;
56
+ /** Number of failed executions */
57
+ failureCount: number;
58
+ /** Detailed metrics for each stage */
59
+ stages: NodeExecutionMetrics[];
60
+ /** Pipeline structure for visualization */
61
+ structure: PipelineStructure;
62
+ }
63
+ /**
64
+ * Represents the structure of a pipeline for visualization.
65
+ */
66
+ export interface PipelineStructure {
67
+ /** Type of this node */
68
+ type: "sequential" | "parallel" | "pipeline" | "map" | "voting" | "router" | "agent" | "custom";
69
+ /** Display name */
70
+ name: string;
71
+ /** Child nodes */
72
+ children?: PipelineStructure[];
73
+ }
74
+ /**
75
+ * Collector for gathering metrics during graph execution.
76
+ */
77
+ export declare class MetricsCollector {
78
+ private executions;
79
+ private currentExecution;
80
+ private executionStack;
81
+ private idCounter;
82
+ /**
83
+ * Generate a unique execution ID.
84
+ */
85
+ private generateId;
86
+ /**
87
+ * Truncate a string for summary display.
88
+ */
89
+ private truncate;
90
+ /**
91
+ * Start tracking a node execution.
92
+ */
93
+ startExecution(name: string, type: NodeExecutionMetrics["type"], input?: unknown): string;
94
+ /**
95
+ * Complete a node execution.
96
+ */
97
+ endExecution(id: string, success: boolean, output?: unknown, tokenUsage?: MetricsTokenUsage, error?: string): void;
98
+ /**
99
+ * Find an execution by ID.
100
+ */
101
+ private findExecution;
102
+ /**
103
+ * Add token usage to the current execution.
104
+ */
105
+ addTokenUsage(usage: MetricsTokenUsage): void;
106
+ /**
107
+ * Get all collected metrics.
108
+ */
109
+ getExecutions(): NodeExecutionMetrics[];
110
+ /**
111
+ * Calculate aggregate metrics.
112
+ */
113
+ getAggregateMetrics(): PipelineMetrics;
114
+ /**
115
+ * Build pipeline structure for visualization.
116
+ */
117
+ private buildStructure;
118
+ /**
119
+ * Reset all collected metrics.
120
+ */
121
+ reset(): void;
122
+ /**
123
+ * Generate a simple text-based visualization of the pipeline.
124
+ */
125
+ toTextVisualization(): string;
126
+ /**
127
+ * Generate a JSON representation suitable for external visualization tools.
128
+ */
129
+ toJSON(): string;
130
+ }
131
+ /**
132
+ * Get or create the global metrics collector.
133
+ */
134
+ export declare function getMetricsCollector(): MetricsCollector;
135
+ /**
136
+ * Set a custom global metrics collector.
137
+ */
138
+ export declare function setMetricsCollector(collector: MetricsCollector): void;
139
+ /**
140
+ * Create a new metrics collector (for isolated tracking).
141
+ */
142
+ export declare function createMetricsCollector(): MetricsCollector;
143
+ //# sourceMappingURL=GraphMetrics.d.ts.map