agentic-qe 1.8.3 → 1.9.0
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/.claude/skills/agentic-jujutsu/SKILL.md +645 -0
- package/.claude/skills/cicd-pipeline-qe-orchestrator/README.md +2 -2
- package/.claude/skills/cicd-pipeline-qe-orchestrator/SKILL.md +6 -6
- package/CHANGELOG.md +595 -0
- package/README.md +117 -16
- package/config/constitution.schema.json +423 -0
- package/config/otel-collector.yaml +234 -0
- package/dist/App.d.ts +5 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +15 -0
- package/dist/App.js.map +1 -0
- package/dist/cli/commands/constitution.d.ts +34 -0
- package/dist/cli/commands/constitution.d.ts.map +1 -0
- package/dist/cli/commands/constitution.js +679 -0
- package/dist/cli/commands/constitution.js.map +1 -0
- package/dist/cli/commands/init-claude-md-template.js +3 -3
- package/dist/cli/commands/init.d.ts +8 -75
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +22 -2292
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/telemetry.d.ts +36 -0
- package/dist/cli/commands/telemetry.d.ts.map +1 -0
- package/dist/cli/commands/telemetry.js +364 -0
- package/dist/cli/commands/telemetry.js.map +1 -0
- package/dist/cli/index.js +66 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/agents.d.ts +22 -0
- package/dist/cli/init/agents.d.ts.map +1 -0
- package/dist/cli/init/agents.js +522 -0
- package/dist/cli/init/agents.js.map +1 -0
- package/dist/cli/init/bash-wrapper.d.ts +14 -0
- package/dist/cli/init/bash-wrapper.d.ts.map +1 -0
- package/dist/cli/init/bash-wrapper.js +47 -0
- package/dist/cli/init/bash-wrapper.js.map +1 -0
- package/dist/cli/init/claude-config.d.ts +24 -0
- package/dist/cli/init/claude-config.d.ts.map +1 -0
- package/dist/cli/init/claude-config.js +275 -0
- package/dist/cli/init/claude-config.js.map +1 -0
- package/dist/cli/init/claude-md.d.ts +19 -0
- package/dist/cli/init/claude-md.d.ts.map +1 -0
- package/dist/cli/init/claude-md.js +153 -0
- package/dist/cli/init/claude-md.js.map +1 -0
- package/dist/cli/init/commands.d.ts +6 -0
- package/dist/cli/init/commands.d.ts.map +1 -0
- package/dist/cli/init/commands.js +83 -0
- package/dist/cli/init/commands.js.map +1 -0
- package/dist/cli/init/database-init.d.ts +15 -0
- package/dist/cli/init/database-init.d.ts.map +1 -0
- package/dist/cli/init/database-init.js +203 -0
- package/dist/cli/init/database-init.js.map +1 -0
- package/dist/cli/init/directory-structure.d.ts +14 -0
- package/dist/cli/init/directory-structure.d.ts.map +1 -0
- package/dist/cli/init/directory-structure.js +107 -0
- package/dist/cli/init/directory-structure.js.map +1 -0
- package/dist/cli/init/documentation.d.ts +14 -0
- package/dist/cli/init/documentation.d.ts.map +1 -0
- package/dist/cli/init/documentation.js +195 -0
- package/dist/cli/init/documentation.js.map +1 -0
- package/dist/cli/init/fleet-config.d.ts +34 -0
- package/dist/cli/init/fleet-config.d.ts.map +1 -0
- package/dist/cli/init/fleet-config.js +269 -0
- package/dist/cli/init/fleet-config.js.map +1 -0
- package/dist/cli/init/helpers.d.ts +6 -0
- package/dist/cli/init/helpers.d.ts.map +1 -0
- package/dist/cli/init/helpers.js +94 -0
- package/dist/cli/init/helpers.js.map +1 -0
- package/dist/cli/init/index.d.ts +32 -0
- package/dist/cli/init/index.d.ts.map +1 -0
- package/dist/cli/init/index.js +294 -0
- package/dist/cli/init/index.js.map +1 -0
- package/dist/cli/init/skills.d.ts +6 -0
- package/dist/cli/init/skills.d.ts.map +1 -0
- package/dist/cli/init/skills.js +138 -0
- package/dist/cli/init/skills.js.map +1 -0
- package/dist/cli/init/utils/file-utils.d.ts +74 -0
- package/dist/cli/init/utils/file-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/file-utils.js +187 -0
- package/dist/cli/init/utils/file-utils.js.map +1 -0
- package/dist/cli/init/utils/index.d.ts +18 -0
- package/dist/cli/init/utils/index.d.ts.map +1 -0
- package/dist/cli/init/utils/index.js +48 -0
- package/dist/cli/init/utils/index.js.map +1 -0
- package/dist/cli/init/utils/log-utils.d.ts +47 -0
- package/dist/cli/init/utils/log-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/log-utils.js +68 -0
- package/dist/cli/init/utils/log-utils.js.map +1 -0
- package/dist/cli/init/utils/path-utils.d.ts +91 -0
- package/dist/cli/init/utils/path-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/path-utils.js +208 -0
- package/dist/cli/init/utils/path-utils.js.map +1 -0
- package/dist/cli/init/utils/validation-utils.d.ts +44 -0
- package/dist/cli/init/utils/validation-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/validation-utils.js +68 -0
- package/dist/cli/init/utils/validation-utils.js.map +1 -0
- package/dist/cli/init/utils.d.ts +183 -0
- package/dist/cli/init/utils.d.ts.map +1 -0
- package/dist/cli/init/utils.js +354 -0
- package/dist/cli/init/utils.js.map +1 -0
- package/dist/components/Dashboard/Dashboard.d.ts +4 -0
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
- package/dist/components/Dashboard/Dashboard.js +148 -0
- package/dist/components/Dashboard/Dashboard.js.map +1 -0
- package/dist/components/Dashboard/DashboardHeader.d.ts +4 -0
- package/dist/components/Dashboard/DashboardHeader.d.ts.map +1 -0
- package/dist/components/Dashboard/DashboardHeader.js +138 -0
- package/dist/components/Dashboard/DashboardHeader.js.map +1 -0
- package/dist/constitution/evaluators/ast-evaluator.d.ts +42 -0
- package/dist/constitution/evaluators/ast-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/ast-evaluator.js +303 -0
- package/dist/constitution/evaluators/ast-evaluator.js.map +1 -0
- package/dist/constitution/evaluators/base.d.ts +144 -0
- package/dist/constitution/evaluators/base.d.ts.map +1 -0
- package/dist/constitution/evaluators/base.js +144 -0
- package/dist/constitution/evaluators/base.js.map +1 -0
- package/dist/constitution/evaluators/index.d.ts +19 -0
- package/dist/constitution/evaluators/index.d.ts.map +1 -0
- package/dist/constitution/evaluators/index.js +56 -0
- package/dist/constitution/evaluators/index.js.map +1 -0
- package/dist/constitution/evaluators/metric-evaluator.d.ts +59 -0
- package/dist/constitution/evaluators/metric-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/metric-evaluator.js +195 -0
- package/dist/constitution/evaluators/metric-evaluator.js.map +1 -0
- package/dist/constitution/evaluators/pattern-evaluator.d.ts +66 -0
- package/dist/constitution/evaluators/pattern-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/pattern-evaluator.js +221 -0
- package/dist/constitution/evaluators/pattern-evaluator.js.map +1 -0
- package/dist/constitution/evaluators/semantic-evaluator.d.ts +68 -0
- package/dist/constitution/evaluators/semantic-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/semantic-evaluator.js +250 -0
- package/dist/constitution/evaluators/semantic-evaluator.js.map +1 -0
- package/dist/constitution/index.d.ts +105 -0
- package/dist/constitution/index.d.ts.map +1 -0
- package/dist/constitution/index.js +207 -0
- package/dist/constitution/index.js.map +1 -0
- package/dist/constitution/loader.d.ts +141 -0
- package/dist/constitution/loader.d.ts.map +1 -0
- package/dist/constitution/loader.js +515 -0
- package/dist/constitution/loader.js.map +1 -0
- package/dist/constitution/schema.d.ts +409 -0
- package/dist/constitution/schema.d.ts.map +1 -0
- package/dist/constitution/schema.js +71 -0
- package/dist/constitution/schema.js.map +1 -0
- package/dist/contexts/DashboardContext.d.ts +41 -0
- package/dist/contexts/DashboardContext.d.ts.map +1 -0
- package/dist/contexts/DashboardContext.js +187 -0
- package/dist/contexts/DashboardContext.js.map +1 -0
- package/dist/core/memory/MemoryManagerFactory.d.ts +77 -0
- package/dist/core/memory/MemoryManagerFactory.d.ts.map +1 -0
- package/dist/core/memory/MemoryManagerFactory.js +270 -0
- package/dist/core/memory/MemoryManagerFactory.js.map +1 -0
- package/dist/core/memory/SwarmMemoryManager.d.ts +58 -0
- package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.js +375 -131
- package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
- package/dist/core/memory/index.d.ts +1 -0
- package/dist/core/memory/index.d.ts.map +1 -1
- package/dist/core/memory/index.js +12 -1
- package/dist/core/memory/index.js.map +1 -1
- package/dist/hooks/useKeyboardShortcuts.d.ts +12 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/hooks/useKeyboardShortcuts.js +69 -0
- package/dist/hooks/useKeyboardShortcuts.js.map +1 -0
- package/dist/mcp/handlers/memory/memory-backup.js +6 -6
- package/dist/mcp/handlers/memory/memory-backup.js.map +1 -1
- package/dist/mcp/handlers/phase2/Phase2Tools.d.ts.map +1 -1
- package/dist/mcp/handlers/phase2/Phase2Tools.js +4 -2
- package/dist/mcp/handlers/phase2/Phase2Tools.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +4 -38
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
- package/dist/mcp/services/AgentRegistry.js +4 -4
- package/dist/mcp/services/AgentRegistry.js.map +1 -1
- package/dist/persistence/event-store.d.ts +162 -0
- package/dist/persistence/event-store.d.ts.map +1 -0
- package/dist/persistence/event-store.js +315 -0
- package/dist/persistence/event-store.js.map +1 -0
- package/dist/persistence/index.d.ts +145 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +227 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/metrics-aggregator.d.ts +187 -0
- package/dist/persistence/metrics-aggregator.d.ts.map +1 -0
- package/dist/persistence/metrics-aggregator.js +495 -0
- package/dist/persistence/metrics-aggregator.js.map +1 -0
- package/dist/persistence/reasoning-store.d.ts +178 -0
- package/dist/persistence/reasoning-store.d.ts.map +1 -0
- package/dist/persistence/reasoning-store.js +440 -0
- package/dist/persistence/reasoning-store.js.map +1 -0
- package/dist/persistence/schema.d.ts +181 -0
- package/dist/persistence/schema.d.ts.map +1 -0
- package/dist/persistence/schema.js +186 -0
- package/dist/persistence/schema.js.map +1 -0
- package/dist/telemetry/bootstrap.d.ts +67 -0
- package/dist/telemetry/bootstrap.d.ts.map +1 -0
- package/dist/telemetry/bootstrap.js +320 -0
- package/dist/telemetry/bootstrap.js.map +1 -0
- package/dist/telemetry/index.d.ts +16 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +84 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/instrumentation/agent.d.ts +158 -0
- package/dist/telemetry/instrumentation/agent.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/agent.js +372 -0
- package/dist/telemetry/instrumentation/agent.js.map +1 -0
- package/dist/telemetry/instrumentation/index.d.ts +24 -0
- package/dist/telemetry/instrumentation/index.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/index.js +54 -0
- package/dist/telemetry/instrumentation/index.js.map +1 -0
- package/dist/telemetry/instrumentation/memory.d.ts +313 -0
- package/dist/telemetry/instrumentation/memory.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/memory.js +552 -0
- package/dist/telemetry/instrumentation/memory.js.map +1 -0
- package/dist/telemetry/instrumentation/task.d.ts +146 -0
- package/dist/telemetry/instrumentation/task.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/task.js +305 -0
- package/dist/telemetry/instrumentation/task.js.map +1 -0
- package/dist/telemetry/metrics/agent-metrics.d.ts +109 -0
- package/dist/telemetry/metrics/agent-metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics/agent-metrics.js +213 -0
- package/dist/telemetry/metrics/agent-metrics.js.map +1 -0
- package/dist/telemetry/metrics/collectors/cost.d.ts +246 -0
- package/dist/telemetry/metrics/collectors/cost.d.ts.map +1 -0
- package/dist/telemetry/metrics/collectors/cost.js +526 -0
- package/dist/telemetry/metrics/collectors/cost.js.map +1 -0
- package/dist/telemetry/metrics/collectors/pricing-config.d.ts +87 -0
- package/dist/telemetry/metrics/collectors/pricing-config.d.ts.map +1 -0
- package/dist/telemetry/metrics/collectors/pricing-config.js +207 -0
- package/dist/telemetry/metrics/collectors/pricing-config.js.map +1 -0
- package/dist/telemetry/metrics/index.d.ts +54 -0
- package/dist/telemetry/metrics/index.d.ts.map +1 -0
- package/dist/telemetry/metrics/index.js +116 -0
- package/dist/telemetry/metrics/index.js.map +1 -0
- package/dist/telemetry/metrics/quality-metrics.d.ts +171 -0
- package/dist/telemetry/metrics/quality-metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics/quality-metrics.js +259 -0
- package/dist/telemetry/metrics/quality-metrics.js.map +1 -0
- package/dist/telemetry/metrics/system-metrics.d.ts +129 -0
- package/dist/telemetry/metrics/system-metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics/system-metrics.js +380 -0
- package/dist/telemetry/metrics/system-metrics.js.map +1 -0
- package/dist/telemetry/types.d.ts +195 -0
- package/dist/telemetry/types.d.ts.map +1 -0
- package/dist/telemetry/types.js +90 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/visualization/api/RestEndpoints.d.ts +136 -0
- package/dist/visualization/api/RestEndpoints.d.ts.map +1 -0
- package/dist/visualization/api/RestEndpoints.js +428 -0
- package/dist/visualization/api/RestEndpoints.js.map +1 -0
- package/dist/visualization/api/WebSocketServer.d.ts +165 -0
- package/dist/visualization/api/WebSocketServer.d.ts.map +1 -0
- package/dist/visualization/api/WebSocketServer.js +518 -0
- package/dist/visualization/api/WebSocketServer.js.map +1 -0
- package/dist/visualization/core/DataTransformer.d.ts +89 -0
- package/dist/visualization/core/DataTransformer.d.ts.map +1 -0
- package/dist/visualization/core/DataTransformer.js +478 -0
- package/dist/visualization/core/DataTransformer.js.map +1 -0
- package/dist/visualization/index.d.ts +92 -0
- package/dist/visualization/index.d.ts.map +1 -0
- package/dist/visualization/index.js +121 -0
- package/dist/visualization/index.js.map +1 -0
- package/dist/visualization/types.d.ts +148 -0
- package/dist/visualization/types.d.ts.map +1 -0
- package/dist/visualization/types.js +7 -0
- package/dist/visualization/types.js.map +1 -0
- package/dist/voting/consensus.d.ts +87 -0
- package/dist/voting/consensus.d.ts.map +1 -0
- package/dist/voting/consensus.js +568 -0
- package/dist/voting/consensus.js.map +1 -0
- package/dist/voting/index.d.ts +12 -0
- package/dist/voting/index.d.ts.map +1 -0
- package/dist/voting/index.js +36 -0
- package/dist/voting/index.js.map +1 -0
- package/dist/voting/orchestrator.d.ts +65 -0
- package/dist/voting/orchestrator.d.ts.map +1 -0
- package/dist/voting/orchestrator.js +306 -0
- package/dist/voting/orchestrator.js.map +1 -0
- package/dist/voting/panel-assembly.d.ts +54 -0
- package/dist/voting/panel-assembly.d.ts.map +1 -0
- package/dist/voting/panel-assembly.js +192 -0
- package/dist/voting/panel-assembly.js.map +1 -0
- package/dist/voting/protocol.d.ts +119 -0
- package/dist/voting/protocol.d.ts.map +1 -0
- package/dist/voting/protocol.js +18 -0
- package/dist/voting/protocol.js.map +1 -0
- package/dist/voting/types.d.ts +125 -0
- package/dist/voting/types.d.ts.map +1 -0
- package/dist/voting/types.js +7 -0
- package/dist/voting/types.js.map +1 -0
- package/package.json +43 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Instrumentation - OpenTelemetry spans for task lifecycle
|
|
3
|
+
*
|
|
4
|
+
* Provides comprehensive tracing for task orchestration, distribution,
|
|
5
|
+
* and execution across the agent fleet. Supports parent-child task
|
|
6
|
+
* relationships and distributed tracing.
|
|
7
|
+
*
|
|
8
|
+
* @module telemetry/instrumentation/task
|
|
9
|
+
*/
|
|
10
|
+
import { Span, Context } from '@opentelemetry/api';
|
|
11
|
+
import { QEAttributes } from '../types';
|
|
12
|
+
import { QETask } from '../../types';
|
|
13
|
+
/**
|
|
14
|
+
* Task span configuration
|
|
15
|
+
*/
|
|
16
|
+
export interface TaskSpanConfig {
|
|
17
|
+
/** Task to trace */
|
|
18
|
+
task: QETask;
|
|
19
|
+
/** Parent span context */
|
|
20
|
+
parentContext?: Context;
|
|
21
|
+
/** Additional QE-specific attributes */
|
|
22
|
+
qeAttributes?: Partial<QEAttributes>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Task result metadata
|
|
26
|
+
*/
|
|
27
|
+
export interface TaskResult {
|
|
28
|
+
/** Execution time in milliseconds */
|
|
29
|
+
executionTime?: number;
|
|
30
|
+
/** Tokens used by LLM */
|
|
31
|
+
tokensUsed?: number;
|
|
32
|
+
/** Cost in USD */
|
|
33
|
+
cost?: number;
|
|
34
|
+
/** Test framework used */
|
|
35
|
+
framework?: string;
|
|
36
|
+
/** Coverage percentage */
|
|
37
|
+
coverage?: number;
|
|
38
|
+
/** Quality score */
|
|
39
|
+
qualityScore?: number;
|
|
40
|
+
/** Additional metrics */
|
|
41
|
+
metrics?: Record<string, number>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Task lifecycle span manager
|
|
45
|
+
*
|
|
46
|
+
* Manages OpenTelemetry spans for task orchestration and execution
|
|
47
|
+
* with support for hierarchical task relationships and distributed tracing.
|
|
48
|
+
*/
|
|
49
|
+
export declare class TaskSpanManager {
|
|
50
|
+
private readonly tracer;
|
|
51
|
+
private activeSpans;
|
|
52
|
+
/**
|
|
53
|
+
* Start task orchestration span
|
|
54
|
+
*
|
|
55
|
+
* Records task distribution and coordination across the fleet.
|
|
56
|
+
*
|
|
57
|
+
* @param task - Task being orchestrated
|
|
58
|
+
* @param fleetId - Fleet identifier
|
|
59
|
+
* @param agentCount - Number of agents involved
|
|
60
|
+
* @returns Active span with context
|
|
61
|
+
*/
|
|
62
|
+
startOrchestrationSpan(task: QETask, fleetId?: string, agentCount?: number): {
|
|
63
|
+
span: Span;
|
|
64
|
+
context: Context;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Complete task orchestration span
|
|
68
|
+
*
|
|
69
|
+
* @param taskId - Task identifier
|
|
70
|
+
* @param success - Whether orchestration was successful
|
|
71
|
+
* @param agentsAssigned - Number of agents assigned
|
|
72
|
+
* @param error - Error if orchestration failed
|
|
73
|
+
*/
|
|
74
|
+
completeOrchestrationSpan(taskId: string, success: boolean, agentsAssigned?: number, error?: Error): void;
|
|
75
|
+
/**
|
|
76
|
+
* Start task execution span
|
|
77
|
+
*
|
|
78
|
+
* Records task execution with semantic attributes for task type,
|
|
79
|
+
* priority, and QE-specific metadata.
|
|
80
|
+
*
|
|
81
|
+
* @param config - Task span configuration
|
|
82
|
+
* @returns Active span with context
|
|
83
|
+
*/
|
|
84
|
+
startExecutionSpan(config: TaskSpanConfig): {
|
|
85
|
+
span: Span;
|
|
86
|
+
context: Context;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Complete task execution span
|
|
90
|
+
*
|
|
91
|
+
* @param taskId - Task identifier
|
|
92
|
+
* @param success - Whether execution was successful
|
|
93
|
+
* @param result - Task execution result
|
|
94
|
+
* @param error - Error if execution failed
|
|
95
|
+
*/
|
|
96
|
+
completeExecutionSpan(taskId: string, success: boolean, result?: TaskResult, error?: Error): void;
|
|
97
|
+
/**
|
|
98
|
+
* Record task status change
|
|
99
|
+
*
|
|
100
|
+
* @param taskId - Task identifier
|
|
101
|
+
* @param oldStatus - Previous status
|
|
102
|
+
* @param newStatus - New status
|
|
103
|
+
*/
|
|
104
|
+
recordStatusChange(taskId: string, oldStatus: string, newStatus: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Record task retry
|
|
107
|
+
*
|
|
108
|
+
* @param taskId - Task identifier
|
|
109
|
+
* @param attempt - Retry attempt number
|
|
110
|
+
* @param reason - Reason for retry
|
|
111
|
+
*/
|
|
112
|
+
recordRetry(taskId: string, attempt: number, reason?: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Record task cancellation
|
|
115
|
+
*
|
|
116
|
+
* @param taskId - Task identifier
|
|
117
|
+
* @param reason - Cancellation reason
|
|
118
|
+
*/
|
|
119
|
+
recordCancellation(taskId: string, reason?: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Cleanup all active spans
|
|
122
|
+
*/
|
|
123
|
+
cleanup(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Build task semantic attributes
|
|
126
|
+
*/
|
|
127
|
+
private buildTaskAttributes;
|
|
128
|
+
/**
|
|
129
|
+
* Get appropriate span name for task type
|
|
130
|
+
*/
|
|
131
|
+
private getSpanNameForTaskType;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Global task span manager instance
|
|
135
|
+
*/
|
|
136
|
+
export declare const taskSpanManager: TaskSpanManager;
|
|
137
|
+
/**
|
|
138
|
+
* Execute function within task span context
|
|
139
|
+
*
|
|
140
|
+
* @param task - Task being executed
|
|
141
|
+
* @param fn - Function to execute
|
|
142
|
+
* @param qeAttributes - QE-specific attributes
|
|
143
|
+
* @returns Function result
|
|
144
|
+
*/
|
|
145
|
+
export declare function withTaskSpan<T>(task: QETask, fn: (context: Context) => Promise<T>, qeAttributes?: Partial<QEAttributes>): Promise<T>;
|
|
146
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/telemetry/instrumentation/task.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAkC,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,EAA8B,YAAY,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wCAAwC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;I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AAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAWnE;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAgBzD;;OAEG;IACH,OAAO,IAAI,IAAI;IAYf;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAW/B;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,iBAAwB,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,EACpC,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GACnC,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Task Instrumentation - OpenTelemetry spans for task lifecycle
|
|
4
|
+
*
|
|
5
|
+
* Provides comprehensive tracing for task orchestration, distribution,
|
|
6
|
+
* and execution across the agent fleet. Supports parent-child task
|
|
7
|
+
* relationships and distributed tracing.
|
|
8
|
+
*
|
|
9
|
+
* @module telemetry/instrumentation/task
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.taskSpanManager = exports.TaskSpanManager = void 0;
|
|
13
|
+
exports.withTaskSpan = withTaskSpan;
|
|
14
|
+
const api_1 = require("@opentelemetry/api");
|
|
15
|
+
const bootstrap_1 = require("../bootstrap");
|
|
16
|
+
const types_1 = require("../types");
|
|
17
|
+
/**
|
|
18
|
+
* Task lifecycle span manager
|
|
19
|
+
*
|
|
20
|
+
* Manages OpenTelemetry spans for task orchestration and execution
|
|
21
|
+
* with support for hierarchical task relationships and distributed tracing.
|
|
22
|
+
*/
|
|
23
|
+
class TaskSpanManager {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.tracer = (0, bootstrap_1.getTracer)();
|
|
26
|
+
this.activeSpans = new Map();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Start task orchestration span
|
|
30
|
+
*
|
|
31
|
+
* Records task distribution and coordination across the fleet.
|
|
32
|
+
*
|
|
33
|
+
* @param task - Task being orchestrated
|
|
34
|
+
* @param fleetId - Fleet identifier
|
|
35
|
+
* @param agentCount - Number of agents involved
|
|
36
|
+
* @returns Active span with context
|
|
37
|
+
*/
|
|
38
|
+
startOrchestrationSpan(task, fleetId, agentCount) {
|
|
39
|
+
const span = this.tracer.startSpan(types_1.SPAN_NAMES.FLEET_DISTRIBUTE_TASK, {
|
|
40
|
+
attributes: {
|
|
41
|
+
...this.buildTaskAttributes(task),
|
|
42
|
+
...(fleetId && { 'fleet.id': fleetId }),
|
|
43
|
+
...(agentCount && { 'fleet.agent_count': agentCount }),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
this.activeSpans.set(`orchestrate:${task.id}`, span);
|
|
47
|
+
span.addEvent('task.orchestration.started', {
|
|
48
|
+
'task.id': task.id,
|
|
49
|
+
'task.type': task.type,
|
|
50
|
+
});
|
|
51
|
+
const spanContext = api_1.trace.setSpan(api_1.context.active(), span);
|
|
52
|
+
return { span, context: spanContext };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Complete task orchestration span
|
|
56
|
+
*
|
|
57
|
+
* @param taskId - Task identifier
|
|
58
|
+
* @param success - Whether orchestration was successful
|
|
59
|
+
* @param agentsAssigned - Number of agents assigned
|
|
60
|
+
* @param error - Error if orchestration failed
|
|
61
|
+
*/
|
|
62
|
+
completeOrchestrationSpan(taskId, success, agentsAssigned, error) {
|
|
63
|
+
const span = this.activeSpans.get(`orchestrate:${taskId}`);
|
|
64
|
+
if (!span) {
|
|
65
|
+
console.warn(`[TaskSpanManager] No orchestration span found for task ${taskId}`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (agentsAssigned !== undefined) {
|
|
69
|
+
span.setAttribute('task.agents_assigned', agentsAssigned);
|
|
70
|
+
}
|
|
71
|
+
if (success) {
|
|
72
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
73
|
+
span.addEvent('task.orchestration.completed', {
|
|
74
|
+
'task.id': taskId,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
span.setStatus({
|
|
79
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
80
|
+
message: error?.message || 'Task orchestration failed',
|
|
81
|
+
});
|
|
82
|
+
if (error) {
|
|
83
|
+
span.recordException(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
span.end();
|
|
87
|
+
this.activeSpans.delete(`orchestrate:${taskId}`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Start task execution span
|
|
91
|
+
*
|
|
92
|
+
* Records task execution with semantic attributes for task type,
|
|
93
|
+
* priority, and QE-specific metadata.
|
|
94
|
+
*
|
|
95
|
+
* @param config - Task span configuration
|
|
96
|
+
* @returns Active span with context
|
|
97
|
+
*/
|
|
98
|
+
startExecutionSpan(config) {
|
|
99
|
+
const { task, parentContext, qeAttributes } = config;
|
|
100
|
+
const spanContext = parentContext || api_1.context.active();
|
|
101
|
+
const span = this.tracer.startSpan(this.getSpanNameForTaskType(task.type), {
|
|
102
|
+
attributes: {
|
|
103
|
+
...this.buildTaskAttributes(task),
|
|
104
|
+
...qeAttributes,
|
|
105
|
+
},
|
|
106
|
+
}, spanContext);
|
|
107
|
+
this.activeSpans.set(`execute:${task.id}`, span);
|
|
108
|
+
span.addEvent('task.execution.started', {
|
|
109
|
+
'task.id': task.id,
|
|
110
|
+
'task.type': task.type,
|
|
111
|
+
});
|
|
112
|
+
const execContext = api_1.trace.setSpan(api_1.context.active(), span);
|
|
113
|
+
return { span, context: execContext };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Complete task execution span
|
|
117
|
+
*
|
|
118
|
+
* @param taskId - Task identifier
|
|
119
|
+
* @param success - Whether execution was successful
|
|
120
|
+
* @param result - Task execution result
|
|
121
|
+
* @param error - Error if execution failed
|
|
122
|
+
*/
|
|
123
|
+
completeExecutionSpan(taskId, success, result, error) {
|
|
124
|
+
const span = this.activeSpans.get(`execute:${taskId}`);
|
|
125
|
+
if (!span) {
|
|
126
|
+
console.warn(`[TaskSpanManager] No execution span found for task ${taskId}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// Add result metrics
|
|
130
|
+
if (result) {
|
|
131
|
+
if (result.executionTime !== undefined) {
|
|
132
|
+
span.setAttribute('task.execution_time_ms', result.executionTime);
|
|
133
|
+
}
|
|
134
|
+
if (result.tokensUsed !== undefined) {
|
|
135
|
+
span.setAttribute('task.tokens_used', result.tokensUsed);
|
|
136
|
+
}
|
|
137
|
+
if (result.cost !== undefined) {
|
|
138
|
+
span.setAttribute('task.cost_usd', result.cost);
|
|
139
|
+
}
|
|
140
|
+
if (result.framework) {
|
|
141
|
+
span.setAttribute('qe.test_framework', result.framework);
|
|
142
|
+
}
|
|
143
|
+
if (result.coverage !== undefined) {
|
|
144
|
+
span.setAttribute('qe.coverage_percent', result.coverage);
|
|
145
|
+
}
|
|
146
|
+
if (result.qualityScore !== undefined) {
|
|
147
|
+
span.setAttribute('qe.quality_score', result.qualityScore);
|
|
148
|
+
}
|
|
149
|
+
if (result.metrics) {
|
|
150
|
+
for (const [key, value] of Object.entries(result.metrics)) {
|
|
151
|
+
span.setAttribute(`task.metric.${key}`, value);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (success) {
|
|
156
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
157
|
+
span.addEvent('task.execution.completed', {
|
|
158
|
+
'task.id': taskId,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
span.setStatus({
|
|
163
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
164
|
+
message: error?.message || 'Task execution failed',
|
|
165
|
+
});
|
|
166
|
+
if (error) {
|
|
167
|
+
span.recordException(error);
|
|
168
|
+
}
|
|
169
|
+
span.addEvent('task.execution.failed', {
|
|
170
|
+
'task.id': taskId,
|
|
171
|
+
'error.message': error?.message || 'Unknown error',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
span.end();
|
|
175
|
+
this.activeSpans.delete(`execute:${taskId}`);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Record task status change
|
|
179
|
+
*
|
|
180
|
+
* @param taskId - Task identifier
|
|
181
|
+
* @param oldStatus - Previous status
|
|
182
|
+
* @param newStatus - New status
|
|
183
|
+
*/
|
|
184
|
+
recordStatusChange(taskId, oldStatus, newStatus) {
|
|
185
|
+
const span = api_1.trace.getActiveSpan();
|
|
186
|
+
if (span) {
|
|
187
|
+
span.addEvent('task.status.changed', {
|
|
188
|
+
'task.id': taskId,
|
|
189
|
+
'task.status.old': oldStatus,
|
|
190
|
+
'task.status.new': newStatus,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Record task retry
|
|
196
|
+
*
|
|
197
|
+
* @param taskId - Task identifier
|
|
198
|
+
* @param attempt - Retry attempt number
|
|
199
|
+
* @param reason - Reason for retry
|
|
200
|
+
*/
|
|
201
|
+
recordRetry(taskId, attempt, reason) {
|
|
202
|
+
const span = api_1.trace.getActiveSpan();
|
|
203
|
+
if (span) {
|
|
204
|
+
span.addEvent('task.retry', {
|
|
205
|
+
'task.id': taskId,
|
|
206
|
+
'task.retry.attempt': attempt,
|
|
207
|
+
...(reason && { 'task.retry.reason': reason }),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Record task cancellation
|
|
213
|
+
*
|
|
214
|
+
* @param taskId - Task identifier
|
|
215
|
+
* @param reason - Cancellation reason
|
|
216
|
+
*/
|
|
217
|
+
recordCancellation(taskId, reason) {
|
|
218
|
+
const span = this.activeSpans.get(`execute:${taskId}`);
|
|
219
|
+
if (span) {
|
|
220
|
+
span.setStatus({
|
|
221
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
222
|
+
message: reason || 'Task cancelled',
|
|
223
|
+
});
|
|
224
|
+
span.addEvent('task.cancelled', {
|
|
225
|
+
'task.id': taskId,
|
|
226
|
+
...(reason && { 'task.cancellation.reason': reason }),
|
|
227
|
+
});
|
|
228
|
+
span.end();
|
|
229
|
+
this.activeSpans.delete(`execute:${taskId}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Cleanup all active spans
|
|
234
|
+
*/
|
|
235
|
+
cleanup() {
|
|
236
|
+
for (const [key, span] of this.activeSpans.entries()) {
|
|
237
|
+
console.warn(`[TaskSpanManager] Force-ending orphaned span: ${key}`);
|
|
238
|
+
span.setStatus({
|
|
239
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
240
|
+
message: 'Span ended during cleanup',
|
|
241
|
+
});
|
|
242
|
+
span.end();
|
|
243
|
+
}
|
|
244
|
+
this.activeSpans.clear();
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Build task semantic attributes
|
|
248
|
+
*/
|
|
249
|
+
buildTaskAttributes(task) {
|
|
250
|
+
return {
|
|
251
|
+
'task.id': task.id,
|
|
252
|
+
'task.type': task.type,
|
|
253
|
+
'task.status': task.status,
|
|
254
|
+
'task.priority': task.priority,
|
|
255
|
+
'task.parent_id': task.parentId || '',
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get appropriate span name for task type
|
|
260
|
+
*/
|
|
261
|
+
getSpanNameForTaskType(taskType) {
|
|
262
|
+
const spanMap = {
|
|
263
|
+
'unit-test': types_1.SPAN_NAMES.AGENT_GENERATE_TESTS,
|
|
264
|
+
'integration-test': types_1.SPAN_NAMES.AGENT_GENERATE_TESTS,
|
|
265
|
+
'coverage-analysis': types_1.SPAN_NAMES.AGENT_ANALYZE_COVERAGE,
|
|
266
|
+
'quality-gate': types_1.SPAN_NAMES.AGENT_VALIDATE_QUALITY,
|
|
267
|
+
'security-scan': types_1.SPAN_NAMES.AGENT_SCAN_SECURITY,
|
|
268
|
+
};
|
|
269
|
+
return spanMap[taskType] || types_1.SPAN_NAMES.AGENT_EXECUTE_TASK;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.TaskSpanManager = TaskSpanManager;
|
|
273
|
+
/**
|
|
274
|
+
* Global task span manager instance
|
|
275
|
+
*/
|
|
276
|
+
exports.taskSpanManager = new TaskSpanManager();
|
|
277
|
+
/**
|
|
278
|
+
* Execute function within task span context
|
|
279
|
+
*
|
|
280
|
+
* @param task - Task being executed
|
|
281
|
+
* @param fn - Function to execute
|
|
282
|
+
* @param qeAttributes - QE-specific attributes
|
|
283
|
+
* @returns Function result
|
|
284
|
+
*/
|
|
285
|
+
async function withTaskSpan(task, fn, qeAttributes) {
|
|
286
|
+
const { span, context: spanContext } = exports.taskSpanManager.startExecutionSpan({
|
|
287
|
+
task,
|
|
288
|
+
qeAttributes,
|
|
289
|
+
});
|
|
290
|
+
const startTime = Date.now();
|
|
291
|
+
try {
|
|
292
|
+
const result = await fn(spanContext);
|
|
293
|
+
const executionTime = Date.now() - startTime;
|
|
294
|
+
exports.taskSpanManager.completeExecutionSpan(task.id, true, {
|
|
295
|
+
executionTime,
|
|
296
|
+
});
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
const executionTime = Date.now() - startTime;
|
|
301
|
+
exports.taskSpanManager.completeExecutionSpan(task.id, false, { executionTime }, error);
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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AkSC;AAED;;GAEG;AACU,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAErD;;;;;;;GAOG;AACI,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,EAAoC,EACpC,YAAoC;IAEpC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,uBAAe,CAAC,kBAAkB,CAAC;QACxE,IAAI;QACJ,YAAY;KACb,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC;QACrC,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAE7C,uBAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE;YACnD,aAAa;SACd,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAE7C,uBAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,KAAc,CAAC,CAAC;QACzF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Performance Metrics for Agentic QE Fleet
|
|
3
|
+
*
|
|
4
|
+
* Metrics for tracking agent task execution, performance, and resource usage.
|
|
5
|
+
*/
|
|
6
|
+
import { Meter, Counter, Histogram, UpDownCounter, Attributes } from '@opentelemetry/api';
|
|
7
|
+
import { MetricRecordOptions } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Agent metrics registry
|
|
10
|
+
*/
|
|
11
|
+
export interface AgentMetrics {
|
|
12
|
+
/** Total number of tasks executed by agents */
|
|
13
|
+
taskCount: Counter;
|
|
14
|
+
/** Distribution of task durations in milliseconds */
|
|
15
|
+
taskDuration: Histogram;
|
|
16
|
+
/** Number of successful tasks */
|
|
17
|
+
successCount: Counter;
|
|
18
|
+
/** Number of failed tasks */
|
|
19
|
+
errorCount: Counter;
|
|
20
|
+
/** Total tokens consumed by agents */
|
|
21
|
+
tokenUsage: Counter;
|
|
22
|
+
/** Total cost incurred by agents */
|
|
23
|
+
costTotal: Counter;
|
|
24
|
+
/** Number of currently active agents */
|
|
25
|
+
activeAgents: UpDownCounter;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Initialize agent metrics
|
|
29
|
+
*
|
|
30
|
+
* @param meter - OpenTelemetry Meter instance
|
|
31
|
+
* @returns Agent metrics registry
|
|
32
|
+
*/
|
|
33
|
+
export declare function createAgentMetrics(meter?: Meter): AgentMetrics;
|
|
34
|
+
/**
|
|
35
|
+
* Get initialized agent metrics
|
|
36
|
+
*
|
|
37
|
+
* @returns Agent metrics registry
|
|
38
|
+
*/
|
|
39
|
+
export declare function getAgentMetrics(): AgentMetrics;
|
|
40
|
+
/**
|
|
41
|
+
* Record a completed agent task
|
|
42
|
+
*
|
|
43
|
+
* @param agentType - Type of agent (e.g., test-generator, coverage-analyzer)
|
|
44
|
+
* @param taskType - Type of task executed
|
|
45
|
+
* @param durationMs - Task duration in milliseconds
|
|
46
|
+
* @param success - Whether the task succeeded
|
|
47
|
+
* @param options - Additional recording options
|
|
48
|
+
*/
|
|
49
|
+
export declare function recordAgentTask(agentType: string, taskType: string, durationMs: number, success: boolean, options?: {
|
|
50
|
+
agentId?: string;
|
|
51
|
+
taskId?: string;
|
|
52
|
+
priority?: string;
|
|
53
|
+
tokensUsed?: number;
|
|
54
|
+
cost?: number;
|
|
55
|
+
}): void;
|
|
56
|
+
/**
|
|
57
|
+
* Record agent spawn/despawn
|
|
58
|
+
*
|
|
59
|
+
* @param agentType - Type of agent
|
|
60
|
+
* @param delta - Change in agent count (+1 for spawn, -1 for despawn)
|
|
61
|
+
* @param attributes - Additional attributes
|
|
62
|
+
*/
|
|
63
|
+
export declare function recordAgentCount(agentType: string, delta: number, attributes?: Attributes): void;
|
|
64
|
+
/**
|
|
65
|
+
* Record model routing decision
|
|
66
|
+
*/
|
|
67
|
+
export interface ModelRoutingRecord {
|
|
68
|
+
/** Model provider (anthropic, openai, etc.) */
|
|
69
|
+
provider: string;
|
|
70
|
+
/** Model name/ID */
|
|
71
|
+
model: string;
|
|
72
|
+
/** Model tier (fast, balanced, quality) */
|
|
73
|
+
tier: string;
|
|
74
|
+
/** Task complexity score */
|
|
75
|
+
complexity: number;
|
|
76
|
+
/** Routing latency in ms */
|
|
77
|
+
routingLatencyMs: number;
|
|
78
|
+
/** Tokens used for routing */
|
|
79
|
+
tokensUsed?: number;
|
|
80
|
+
/** Cost of the routed call */
|
|
81
|
+
cost?: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create model routing metrics
|
|
85
|
+
*
|
|
86
|
+
* @param meter - OpenTelemetry Meter instance
|
|
87
|
+
* @returns Model routing metrics
|
|
88
|
+
*/
|
|
89
|
+
export declare function createModelRoutingMetrics(meter?: Meter): {
|
|
90
|
+
routingCount: Counter<Attributes>;
|
|
91
|
+
routingLatency: Histogram<Attributes>;
|
|
92
|
+
modelInvocationCount: Counter<Attributes>;
|
|
93
|
+
modelTokensInput: Counter<Attributes>;
|
|
94
|
+
modelTokensOutput: Counter<Attributes>;
|
|
95
|
+
modelCost: Counter<Attributes>;
|
|
96
|
+
modelLatency: Histogram<Attributes>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Learning and pattern metrics for agents
|
|
100
|
+
*/
|
|
101
|
+
export declare function createLearningMetrics(meter?: Meter): {
|
|
102
|
+
patternMatchCount: Counter<Attributes>;
|
|
103
|
+
patternMatchScore: Histogram<Attributes>;
|
|
104
|
+
learningEpisodeCount: Counter<Attributes>;
|
|
105
|
+
rewardScore: Histogram<Attributes>;
|
|
106
|
+
experienceBufferSize: UpDownCounter<Attributes>;
|
|
107
|
+
};
|
|
108
|
+
export type { MetricRecordOptions };
|
|
109
|
+
//# sourceMappingURL=agent-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-metrics.d.ts","sourceRoot":"","sources":["../../../src/telemetry/metrics/agent-metrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAsC,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,qDAAqD;IACrD,YAAY,EAAE,SAAS,CAAC;IACxB,iCAAiC;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,6BAA6B;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,YAAY,EAAE,aAAa,CAAC;CAC7B;AAKD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,YAAY,CAgD9D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAK9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IA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