agentic-qe 3.7.6 → 3.7.8
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/helpers/statusline-v3.cjs +13 -1
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +39 -0
- package/README.md +36 -0
- package/dist/cli/bundle.js +2052 -183
- package/dist/coordination/complexity-composition/index.d.ts +2 -0
- package/dist/coordination/complexity-composition/index.d.ts.map +1 -0
- package/dist/coordination/complexity-composition/index.js +2 -0
- package/dist/coordination/complexity-composition/index.js.map +1 -0
- package/dist/coordination/complexity-composition/team-composer.d.ts +72 -0
- package/dist/coordination/complexity-composition/team-composer.d.ts.map +1 -0
- package/dist/coordination/complexity-composition/team-composer.js +221 -0
- package/dist/coordination/complexity-composition/team-composer.js.map +1 -0
- package/dist/coordination/consensus/consensus-engine.d.ts +10 -1
- package/dist/coordination/consensus/consensus-engine.d.ts.map +1 -1
- package/dist/coordination/consensus/consensus-engine.js +31 -1
- package/dist/coordination/consensus/consensus-engine.js.map +1 -1
- package/dist/coordination/consensus/index.d.ts +1 -0
- package/dist/coordination/consensus/index.d.ts.map +1 -1
- package/dist/coordination/consensus/index.js +4 -0
- package/dist/coordination/consensus/index.js.map +1 -1
- package/dist/coordination/consensus/interfaces.d.ts +5 -0
- package/dist/coordination/consensus/interfaces.d.ts.map +1 -1
- package/dist/coordination/consensus/interfaces.js +1 -0
- package/dist/coordination/consensus/interfaces.js.map +1 -1
- package/dist/coordination/consensus/sycophancy-scorer.d.ts +62 -0
- package/dist/coordination/consensus/sycophancy-scorer.d.ts.map +1 -0
- package/dist/coordination/consensus/sycophancy-scorer.js +200 -0
- package/dist/coordination/consensus/sycophancy-scorer.js.map +1 -0
- package/dist/coordination/fleet-tiers/tier-selector.d.ts +20 -0
- package/dist/coordination/fleet-tiers/tier-selector.d.ts.map +1 -1
- package/dist/coordination/fleet-tiers/tier-selector.js +31 -0
- package/dist/coordination/fleet-tiers/tier-selector.js.map +1 -1
- package/dist/coordination/fleet-tiers/types.d.ts +2 -0
- package/dist/coordination/fleet-tiers/types.d.ts.map +1 -1
- package/dist/domains/test-execution/services/e2e/adaptive-locator-service.d.ts +71 -0
- package/dist/domains/test-execution/services/e2e/adaptive-locator-service.d.ts.map +1 -0
- package/dist/domains/test-execution/services/e2e/adaptive-locator-service.js +456 -0
- package/dist/domains/test-execution/services/e2e/adaptive-locator-service.js.map +1 -0
- package/dist/domains/test-execution/services/e2e/adaptive-locator-types.d.ts +81 -0
- package/dist/domains/test-execution/services/e2e/adaptive-locator-types.d.ts.map +1 -0
- package/dist/domains/test-execution/services/e2e/adaptive-locator-types.js +20 -0
- package/dist/domains/test-execution/services/e2e/adaptive-locator-types.js.map +1 -0
- package/dist/domains/test-execution/services/e2e/browser-orchestrator.d.ts +19 -0
- package/dist/domains/test-execution/services/e2e/browser-orchestrator.d.ts.map +1 -1
- package/dist/domains/test-execution/services/e2e/browser-orchestrator.js +82 -0
- package/dist/domains/test-execution/services/e2e/browser-orchestrator.js.map +1 -1
- package/dist/domains/test-execution/services/e2e/index.d.ts +2 -0
- package/dist/domains/test-execution/services/e2e/index.d.ts.map +1 -1
- package/dist/domains/test-execution/services/e2e/index.js +5 -0
- package/dist/domains/test-execution/services/e2e/index.js.map +1 -1
- package/dist/domains/test-execution/services/e2e/step-executors.d.ts +6 -0
- package/dist/domains/test-execution/services/e2e/step-executors.d.ts.map +1 -1
- package/dist/domains/test-execution/services/e2e/step-executors.js +17 -2
- package/dist/domains/test-execution/services/e2e/step-executors.js.map +1 -1
- package/dist/domains/test-execution/services/e2e/types.d.ts +18 -1
- package/dist/domains/test-execution/services/e2e/types.d.ts.map +1 -1
- package/dist/domains/test-execution/services/e2e/types.js.map +1 -1
- package/dist/domains/test-generation/blind-review/blind-review-orchestrator.d.ts +65 -0
- package/dist/domains/test-generation/blind-review/blind-review-orchestrator.d.ts.map +1 -0
- package/dist/domains/test-generation/blind-review/blind-review-orchestrator.js +189 -0
- package/dist/domains/test-generation/blind-review/blind-review-orchestrator.js.map +1 -0
- package/dist/domains/test-generation/blind-review/index.d.ts +2 -0
- package/dist/domains/test-generation/blind-review/index.d.ts.map +1 -0
- package/dist/domains/test-generation/blind-review/index.js +2 -0
- package/dist/domains/test-generation/blind-review/index.js.map +1 -0
- package/dist/domains/test-generation/gates/index.d.ts +2 -0
- package/dist/domains/test-generation/gates/index.d.ts.map +1 -0
- package/dist/domains/test-generation/gates/index.js +2 -0
- package/dist/domains/test-generation/gates/index.js.map +1 -0
- package/dist/domains/test-generation/gates/test-quality-gate.d.ts +85 -0
- package/dist/domains/test-generation/gates/test-quality-gate.d.ts.map +1 -0
- package/dist/domains/test-generation/gates/test-quality-gate.js +320 -0
- package/dist/domains/test-generation/gates/test-quality-gate.js.map +1 -0
- package/dist/domains/test-generation/interfaces.d.ts +3 -0
- package/dist/domains/test-generation/interfaces.d.ts.map +1 -1
- package/dist/domains/test-generation/pattern-injection/edge-case-injector.d.ts +68 -0
- package/dist/domains/test-generation/pattern-injection/edge-case-injector.d.ts.map +1 -0
- package/dist/domains/test-generation/pattern-injection/edge-case-injector.js +225 -0
- package/dist/domains/test-generation/pattern-injection/edge-case-injector.js.map +1 -0
- package/dist/domains/test-generation/pattern-injection/index.d.ts +2 -0
- package/dist/domains/test-generation/pattern-injection/index.d.ts.map +1 -0
- package/dist/domains/test-generation/pattern-injection/index.js +2 -0
- package/dist/domains/test-generation/pattern-injection/index.js.map +1 -0
- package/dist/domains/test-generation/services/test-generator.d.ts +6 -0
- package/dist/domains/test-generation/services/test-generator.d.ts.map +1 -1
- package/dist/domains/test-generation/services/test-generator.js +29 -0
- package/dist/domains/test-generation/services/test-generator.js.map +1 -1
- package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.d.ts +8 -2
- package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.d.ts.map +1 -1
- package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.js +62 -38
- package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.js.map +1 -1
- package/dist/integrations/browser/client-factory.d.ts +6 -1
- package/dist/integrations/browser/client-factory.d.ts.map +1 -1
- package/dist/integrations/browser/client-factory.js +37 -2
- package/dist/integrations/browser/client-factory.js.map +1 -1
- package/dist/integrations/browser/index.d.ts +5 -1
- package/dist/integrations/browser/index.d.ts.map +1 -1
- package/dist/integrations/browser/index.js +8 -1
- package/dist/integrations/browser/index.js.map +1 -1
- package/dist/integrations/browser/page-pool-types.d.ts +70 -0
- package/dist/integrations/browser/page-pool-types.d.ts.map +1 -0
- package/dist/integrations/browser/page-pool-types.js +19 -0
- package/dist/integrations/browser/page-pool-types.js.map +1 -0
- package/dist/integrations/browser/page-pool.d.ts +79 -0
- package/dist/integrations/browser/page-pool.d.ts.map +1 -0
- package/dist/integrations/browser/page-pool.js +288 -0
- package/dist/integrations/browser/page-pool.js.map +1 -0
- package/dist/integrations/browser/resource-blocking.d.ts +47 -0
- package/dist/integrations/browser/resource-blocking.d.ts.map +1 -0
- package/dist/integrations/browser/resource-blocking.js +195 -0
- package/dist/integrations/browser/resource-blocking.js.map +1 -0
- package/dist/integrations/browser/stealth/index.d.ts +8 -0
- package/dist/integrations/browser/stealth/index.d.ts.map +1 -0
- package/dist/integrations/browser/stealth/index.js +7 -0
- package/dist/integrations/browser/stealth/index.js.map +1 -0
- package/dist/integrations/browser/stealth/stealth-client.d.ts +51 -0
- package/dist/integrations/browser/stealth/stealth-client.d.ts.map +1 -0
- package/dist/integrations/browser/stealth/stealth-client.js +359 -0
- package/dist/integrations/browser/stealth/stealth-client.js.map +1 -0
- package/dist/integrations/browser/stealth/stealth-types.d.ts +35 -0
- package/dist/integrations/browser/stealth/stealth-types.d.ts.map +1 -0
- package/dist/integrations/browser/stealth/stealth-types.js +17 -0
- package/dist/integrations/browser/stealth/stealth-types.js.map +1 -0
- package/dist/integrations/browser/types.d.ts +13 -10
- package/dist/integrations/browser/types.d.ts.map +1 -1
- package/dist/integrations/browser/types.js.map +1 -1
- package/dist/learning/experience-capture.d.ts +12 -2
- package/dist/learning/experience-capture.d.ts.map +1 -1
- package/dist/learning/experience-capture.js +28 -35
- package/dist/learning/experience-capture.js.map +1 -1
- package/dist/learning/experience-consolidation.d.ts +74 -0
- package/dist/learning/experience-consolidation.d.ts.map +1 -0
- package/dist/learning/experience-consolidation.js +403 -0
- package/dist/learning/experience-consolidation.js.map +1 -0
- package/dist/mcp/bundle.js +3050 -341
- package/dist/routing/calibration/ema-calibrator.d.ts +93 -0
- package/dist/routing/calibration/ema-calibrator.d.ts.map +1 -0
- package/dist/routing/calibration/ema-calibrator.js +140 -0
- package/dist/routing/calibration/ema-calibrator.js.map +1 -0
- package/dist/routing/calibration/index.d.ts +2 -0
- package/dist/routing/calibration/index.d.ts.map +1 -0
- package/dist/routing/calibration/index.js +2 -0
- package/dist/routing/calibration/index.js.map +1 -0
- package/dist/routing/escalation/auto-escalation-tracker.d.ts +62 -0
- package/dist/routing/escalation/auto-escalation-tracker.d.ts.map +1 -0
- package/dist/routing/escalation/auto-escalation-tracker.js +116 -0
- package/dist/routing/escalation/auto-escalation-tracker.js.map +1 -0
- package/dist/routing/escalation/index.d.ts +2 -0
- package/dist/routing/escalation/index.d.ts.map +1 -0
- package/dist/routing/escalation/index.js +2 -0
- package/dist/routing/escalation/index.js.map +1 -0
- package/dist/routing/index.d.ts +4 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +4 -0
- package/dist/routing/index.js.map +1 -1
- package/dist/routing/routing-config.d.ts +4 -0
- package/dist/routing/routing-config.d.ts.map +1 -1
- package/dist/routing/routing-config.js +2 -0
- package/dist/routing/routing-config.js.map +1 -1
- package/dist/routing/routing-feedback.d.ts +35 -2
- package/dist/routing/routing-feedback.d.ts.map +1 -1
- package/dist/routing/routing-feedback.js +97 -3
- package/dist/routing/routing-feedback.js.map +1 -1
- package/dist/routing/types.d.ts +2 -0
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/routing/types.js.map +1 -1
- package/dist/workers/workers/learning-consolidation.d.ts.map +1 -1
- package/dist/workers/workers/learning-consolidation.js +32 -0
- package/dist/workers/workers/learning-consolidation.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMA-based Reviewer Calibration
|
|
3
|
+
* Inspired by loki-mode reviewer calibration
|
|
4
|
+
*
|
|
5
|
+
* Tracks per-agent accuracy using Exponential Moving Average (alpha=0.1),
|
|
6
|
+
* derives dynamic voting weights for multi-agent consensus.
|
|
7
|
+
* Agents with consistent accuracy get higher influence.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Calibration record for a single agent
|
|
11
|
+
*/
|
|
12
|
+
export interface CalibrationRecord {
|
|
13
|
+
agentId: string;
|
|
14
|
+
/** EMA of success rate (0-1) */
|
|
15
|
+
emaAccuracy: number;
|
|
16
|
+
/** EMA of quality score (0-1) */
|
|
17
|
+
emaQuality: number;
|
|
18
|
+
/** Derived voting weight (0.2-2.0) */
|
|
19
|
+
calibratedWeight: number;
|
|
20
|
+
/** Total outcomes recorded */
|
|
21
|
+
totalOutcomes: number;
|
|
22
|
+
/** Last update timestamp */
|
|
23
|
+
lastUpdated: Date;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for the EMA calibrator
|
|
27
|
+
*/
|
|
28
|
+
export interface EMAConfig {
|
|
29
|
+
/** Smoothing factor for EMA (default: 0.1) */
|
|
30
|
+
alpha: number;
|
|
31
|
+
/** Minimum outcomes before applying calibrated weight (default: 10) */
|
|
32
|
+
minOutcomes: number;
|
|
33
|
+
/** Minimum allowed weight (default: 0.2) */
|
|
34
|
+
weightFloor: number;
|
|
35
|
+
/** Maximum allowed weight (default: 2.0) */
|
|
36
|
+
weightCeiling: number;
|
|
37
|
+
}
|
|
38
|
+
export declare const DEFAULT_EMA_CONFIG: EMAConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Calibrates per-agent voting weights using Exponential Moving Average.
|
|
41
|
+
*
|
|
42
|
+
* Agents that consistently produce successful, high-quality outcomes
|
|
43
|
+
* receive higher voting weights in multi-agent consensus decisions.
|
|
44
|
+
* New agents (below minOutcomes) receive a neutral weight of 1.0.
|
|
45
|
+
*/
|
|
46
|
+
export declare class EMACalibrator {
|
|
47
|
+
private records;
|
|
48
|
+
private readonly config;
|
|
49
|
+
constructor(config?: Partial<EMAConfig>);
|
|
50
|
+
/**
|
|
51
|
+
* Record an outcome for an agent and update its EMA calibration.
|
|
52
|
+
*
|
|
53
|
+
* @param agentId - The agent identifier
|
|
54
|
+
* @param success - Whether the task succeeded
|
|
55
|
+
* @param qualityScore - Quality score (0-1)
|
|
56
|
+
* @returns Updated calibration record
|
|
57
|
+
*/
|
|
58
|
+
recordOutcome(agentId: string, success: boolean, qualityScore: number): CalibrationRecord;
|
|
59
|
+
/**
|
|
60
|
+
* Get the calibration record for an agent.
|
|
61
|
+
*
|
|
62
|
+
* @param agentId - The agent identifier
|
|
63
|
+
* @returns Calibration record or null if not found
|
|
64
|
+
*/
|
|
65
|
+
getCalibration(agentId: string): CalibrationRecord | null;
|
|
66
|
+
/**
|
|
67
|
+
* Get the calibrated weight for an agent.
|
|
68
|
+
* Returns 1.0 (neutral) for unknown agents or those below minOutcomes.
|
|
69
|
+
*
|
|
70
|
+
* @param agentId - The agent identifier
|
|
71
|
+
* @returns Calibrated voting weight (0.2-2.0, or 1.0 if uncalibrated)
|
|
72
|
+
*/
|
|
73
|
+
getCalibratedWeight(agentId: string): number;
|
|
74
|
+
/**
|
|
75
|
+
* Get all calibration records.
|
|
76
|
+
*/
|
|
77
|
+
getAllCalibrations(): CalibrationRecord[];
|
|
78
|
+
/**
|
|
79
|
+
* Reset calibration data.
|
|
80
|
+
*
|
|
81
|
+
* @param agentId - If provided, reset only this agent. Otherwise reset all.
|
|
82
|
+
*/
|
|
83
|
+
reset(agentId?: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Serialize all records for persistence.
|
|
86
|
+
*/
|
|
87
|
+
serialize(): Record<string, CalibrationRecord>;
|
|
88
|
+
/**
|
|
89
|
+
* Load previously serialized records.
|
|
90
|
+
*/
|
|
91
|
+
deserialize(data: Record<string, CalibrationRecord>): void;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ema-calibrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ema-calibrator.d.ts","sourceRoot":"","sources":["../../../src/routing/calibration/ema-calibrator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,gBAAgB,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,WAAW,EAAE,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,kBAAkB,EAAE,SAKhC,CAAC;AAMF;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAA6C;IAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC;IAIvC;;;;;;;OAOG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB;IA0CzF;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAIzD;;;;;;OAMG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAQ5C;;OAEG;IACH,kBAAkB,IAAI,iBAAiB,EAAE;IAIzC;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ7B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAQ9C;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,IAAI;CAS3D"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMA-based Reviewer Calibration
|
|
3
|
+
* Inspired by loki-mode reviewer calibration
|
|
4
|
+
*
|
|
5
|
+
* Tracks per-agent accuracy using Exponential Moving Average (alpha=0.1),
|
|
6
|
+
* derives dynamic voting weights for multi-agent consensus.
|
|
7
|
+
* Agents with consistent accuracy get higher influence.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_EMA_CONFIG = {
|
|
10
|
+
alpha: 0.1,
|
|
11
|
+
minOutcomes: 10,
|
|
12
|
+
weightFloor: 0.2,
|
|
13
|
+
weightCeiling: 2.0,
|
|
14
|
+
};
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// EMA Calibrator
|
|
17
|
+
// ============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Calibrates per-agent voting weights using Exponential Moving Average.
|
|
20
|
+
*
|
|
21
|
+
* Agents that consistently produce successful, high-quality outcomes
|
|
22
|
+
* receive higher voting weights in multi-agent consensus decisions.
|
|
23
|
+
* New agents (below minOutcomes) receive a neutral weight of 1.0.
|
|
24
|
+
*/
|
|
25
|
+
export class EMACalibrator {
|
|
26
|
+
records = new Map();
|
|
27
|
+
config;
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this.config = { ...DEFAULT_EMA_CONFIG, ...config };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Record an outcome for an agent and update its EMA calibration.
|
|
33
|
+
*
|
|
34
|
+
* @param agentId - The agent identifier
|
|
35
|
+
* @param success - Whether the task succeeded
|
|
36
|
+
* @param qualityScore - Quality score (0-1)
|
|
37
|
+
* @returns Updated calibration record
|
|
38
|
+
*/
|
|
39
|
+
recordOutcome(agentId, success, qualityScore) {
|
|
40
|
+
const { alpha, minOutcomes, weightFloor, weightCeiling } = this.config;
|
|
41
|
+
const existing = this.records.get(agentId);
|
|
42
|
+
const successValue = success ? 1 : 0;
|
|
43
|
+
const clampedQuality = Math.max(0, Math.min(1, qualityScore));
|
|
44
|
+
let emaAccuracy;
|
|
45
|
+
let emaQuality;
|
|
46
|
+
if (existing) {
|
|
47
|
+
emaAccuracy = alpha * successValue + (1 - alpha) * existing.emaAccuracy;
|
|
48
|
+
emaQuality = alpha * clampedQuality + (1 - alpha) * existing.emaQuality;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// First outcome: initialize directly
|
|
52
|
+
emaAccuracy = successValue;
|
|
53
|
+
emaQuality = clampedQuality;
|
|
54
|
+
}
|
|
55
|
+
const totalOutcomes = (existing?.totalOutcomes ?? 0) + 1;
|
|
56
|
+
// Only apply calibrated weight after sufficient outcomes
|
|
57
|
+
let calibratedWeight;
|
|
58
|
+
if (totalOutcomes >= minOutcomes) {
|
|
59
|
+
calibratedWeight = Math.max(weightFloor, Math.min(weightCeiling, emaAccuracy * 2));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
calibratedWeight = 1.0;
|
|
63
|
+
}
|
|
64
|
+
const record = {
|
|
65
|
+
agentId,
|
|
66
|
+
emaAccuracy,
|
|
67
|
+
emaQuality,
|
|
68
|
+
calibratedWeight,
|
|
69
|
+
totalOutcomes,
|
|
70
|
+
lastUpdated: new Date(),
|
|
71
|
+
};
|
|
72
|
+
this.records.set(agentId, record);
|
|
73
|
+
return record;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get the calibration record for an agent.
|
|
77
|
+
*
|
|
78
|
+
* @param agentId - The agent identifier
|
|
79
|
+
* @returns Calibration record or null if not found
|
|
80
|
+
*/
|
|
81
|
+
getCalibration(agentId) {
|
|
82
|
+
return this.records.get(agentId) ?? null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the calibrated weight for an agent.
|
|
86
|
+
* Returns 1.0 (neutral) for unknown agents or those below minOutcomes.
|
|
87
|
+
*
|
|
88
|
+
* @param agentId - The agent identifier
|
|
89
|
+
* @returns Calibrated voting weight (0.2-2.0, or 1.0 if uncalibrated)
|
|
90
|
+
*/
|
|
91
|
+
getCalibratedWeight(agentId) {
|
|
92
|
+
const record = this.records.get(agentId);
|
|
93
|
+
if (!record || record.totalOutcomes < this.config.minOutcomes) {
|
|
94
|
+
return 1.0;
|
|
95
|
+
}
|
|
96
|
+
return record.calibratedWeight;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get all calibration records.
|
|
100
|
+
*/
|
|
101
|
+
getAllCalibrations() {
|
|
102
|
+
return Array.from(this.records.values());
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Reset calibration data.
|
|
106
|
+
*
|
|
107
|
+
* @param agentId - If provided, reset only this agent. Otherwise reset all.
|
|
108
|
+
*/
|
|
109
|
+
reset(agentId) {
|
|
110
|
+
if (agentId !== undefined) {
|
|
111
|
+
this.records.delete(agentId);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.records.clear();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Serialize all records for persistence.
|
|
119
|
+
*/
|
|
120
|
+
serialize() {
|
|
121
|
+
const result = {};
|
|
122
|
+
for (const [key, record] of this.records) {
|
|
123
|
+
result[key] = { ...record };
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Load previously serialized records.
|
|
129
|
+
*/
|
|
130
|
+
deserialize(data) {
|
|
131
|
+
this.records.clear();
|
|
132
|
+
for (const [key, record] of Object.entries(data)) {
|
|
133
|
+
this.records.set(key, {
|
|
134
|
+
...record,
|
|
135
|
+
lastUpdated: new Date(record.lastUpdated),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=ema-calibrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ema-calibrator.js","sourceRoot":"","sources":["../../../src/routing/calibration/ema-calibrator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqCH,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,KAAK,EAAE,GAAG;IACV,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,GAAG;CACnB,CAAC;AAEF,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IAChB,OAAO,GAAmC,IAAI,GAAG,EAAE,CAAC;IAC3C,MAAM,CAAY;IAEnC,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAAC;IACrD,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,OAAe,EAAE,OAAgB,EAAE,YAAoB;QACnE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE3C,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAA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0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routing/calibration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routing/calibration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0C,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Escalation Tracker
|
|
3
|
+
* Inspired by loki-mode model selection with automatic escalation
|
|
4
|
+
*
|
|
5
|
+
* Tracks consecutive failures/successes per agent and recommends
|
|
6
|
+
* tier escalation (after N failures) or de-escalation (after M successes).
|
|
7
|
+
* Uses existing AgentTier and FallbackConfig.chain for tier ordering.
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentTier } from '../routing-config.js';
|
|
10
|
+
export interface EscalationConfig {
|
|
11
|
+
/** Consecutive failures before escalation (default: 2) */
|
|
12
|
+
escalateAfterFailures: number;
|
|
13
|
+
/** Consecutive successes before de-escalation (default: 5) */
|
|
14
|
+
deEscalateAfterSuccesses: number;
|
|
15
|
+
/** Maximum tier to escalate to (default: 'opus') */
|
|
16
|
+
maxTier: AgentTier;
|
|
17
|
+
/** Minimum tier to de-escalate to (default: 'haiku') */
|
|
18
|
+
minTier: AgentTier;
|
|
19
|
+
}
|
|
20
|
+
export declare const DEFAULT_ESCALATION_CONFIG: EscalationConfig;
|
|
21
|
+
export interface EscalationState {
|
|
22
|
+
agentId: string;
|
|
23
|
+
currentTier: AgentTier;
|
|
24
|
+
baseTier: AgentTier;
|
|
25
|
+
consecutiveFailures: number;
|
|
26
|
+
consecutiveSuccesses: number;
|
|
27
|
+
escalationCount: number;
|
|
28
|
+
deEscalationCount: number;
|
|
29
|
+
lastAction: 'escalate' | 'de-escalate' | 'none';
|
|
30
|
+
lastActionTimestamp: Date;
|
|
31
|
+
}
|
|
32
|
+
export type EscalationAction = {
|
|
33
|
+
action: 'escalate' | 'de-escalate' | 'none';
|
|
34
|
+
previousTier: AgentTier;
|
|
35
|
+
newTier: AgentTier;
|
|
36
|
+
};
|
|
37
|
+
export declare class AutoEscalationTracker {
|
|
38
|
+
private readonly config;
|
|
39
|
+
private states;
|
|
40
|
+
constructor(config?: Partial<EscalationConfig>);
|
|
41
|
+
/**
|
|
42
|
+
* Record an outcome for an agent and determine escalation action.
|
|
43
|
+
*/
|
|
44
|
+
recordOutcome(agentId: string, success: boolean, baseTier: AgentTier): EscalationAction;
|
|
45
|
+
/**
|
|
46
|
+
* Get the current tier for an agent, or null if not tracked.
|
|
47
|
+
*/
|
|
48
|
+
getCurrentTier(agentId: string): AgentTier | null;
|
|
49
|
+
/**
|
|
50
|
+
* Get full escalation state for an agent, or null if not tracked.
|
|
51
|
+
*/
|
|
52
|
+
getState(agentId: string): EscalationState | null;
|
|
53
|
+
/**
|
|
54
|
+
* Get all tracked escalation states.
|
|
55
|
+
*/
|
|
56
|
+
getAllStates(): EscalationState[];
|
|
57
|
+
/**
|
|
58
|
+
* Reset state for a specific agent, or all agents if no ID provided.
|
|
59
|
+
*/
|
|
60
|
+
reset(agentId?: string): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=auto-escalation-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-escalation-tracker.d.ts","sourceRoot":"","sources":["../../../src/routing/escalation/auto-escalation-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMtD,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,qBAAqB,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,wBAAw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|
+
/**
|
|
2
|
+
* Auto-Escalation Tracker
|
|
3
|
+
* Inspired by loki-mode model selection with automatic escalation
|
|
4
|
+
*
|
|
5
|
+
* Tracks consecutive failures/successes per agent and recommends
|
|
6
|
+
* tier escalation (after N failures) or de-escalation (after M successes).
|
|
7
|
+
* Uses existing AgentTier and FallbackConfig.chain for tier ordering.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_ESCALATION_CONFIG = {
|
|
10
|
+
escalateAfterFailures: 2,
|
|
11
|
+
deEscalateAfterSuccesses: 5,
|
|
12
|
+
maxTier: 'opus',
|
|
13
|
+
minTier: 'haiku',
|
|
14
|
+
};
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Tier Ordering
|
|
17
|
+
// ============================================================================
|
|
18
|
+
/** Tiers in ascending order of capability/cost */
|
|
19
|
+
const TIER_ORDER = ['booster', 'haiku', 'sonnet', 'opus'];
|
|
20
|
+
function tierIndex(tier) {
|
|
21
|
+
return TIER_ORDER.indexOf(tier);
|
|
22
|
+
}
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Auto-Escalation Tracker
|
|
25
|
+
// ============================================================================
|
|
26
|
+
export class AutoEscalationTracker {
|
|
27
|
+
config;
|
|
28
|
+
states = new Map();
|
|
29
|
+
constructor(config) {
|
|
30
|
+
this.config = { ...DEFAULT_ESCALATION_CONFIG, ...config };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Record an outcome for an agent and determine escalation action.
|
|
34
|
+
*/
|
|
35
|
+
recordOutcome(agentId, success, baseTier) {
|
|
36
|
+
let state = this.states.get(agentId);
|
|
37
|
+
if (!state) {
|
|
38
|
+
state = {
|
|
39
|
+
agentId,
|
|
40
|
+
currentTier: baseTier,
|
|
41
|
+
baseTier,
|
|
42
|
+
consecutiveFailures: 0,
|
|
43
|
+
consecutiveSuccesses: 0,
|
|
44
|
+
escalationCount: 0,
|
|
45
|
+
deEscalationCount: 0,
|
|
46
|
+
lastAction: 'none',
|
|
47
|
+
lastActionTimestamp: new Date(),
|
|
48
|
+
};
|
|
49
|
+
this.states.set(agentId, state);
|
|
50
|
+
}
|
|
51
|
+
const previousTier = state.currentTier;
|
|
52
|
+
if (!success) {
|
|
53
|
+
state.consecutiveFailures++;
|
|
54
|
+
state.consecutiveSuccesses = 0;
|
|
55
|
+
if (state.consecutiveFailures >= this.config.escalateAfterFailures) {
|
|
56
|
+
const currentIdx = tierIndex(state.currentTier);
|
|
57
|
+
const maxIdx = tierIndex(this.config.maxTier);
|
|
58
|
+
if (currentIdx < maxIdx) {
|
|
59
|
+
state.currentTier = TIER_ORDER[currentIdx + 1];
|
|
60
|
+
state.escalationCount++;
|
|
61
|
+
state.consecutiveFailures = 0;
|
|
62
|
+
state.lastAction = 'escalate';
|
|
63
|
+
state.lastActionTimestamp = new Date();
|
|
64
|
+
return { action: 'escalate', previousTier, newTier: state.currentTier };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
state.consecutiveSuccesses++;
|
|
70
|
+
state.consecutiveFailures = 0;
|
|
71
|
+
if (state.consecutiveSuccesses >= this.config.deEscalateAfterSuccesses) {
|
|
72
|
+
const currentIdx = tierIndex(state.currentTier);
|
|
73
|
+
const minIdx = tierIndex(this.config.minTier);
|
|
74
|
+
if (currentIdx > minIdx) {
|
|
75
|
+
state.currentTier = TIER_ORDER[currentIdx - 1];
|
|
76
|
+
state.deEscalationCount++;
|
|
77
|
+
state.consecutiveSuccesses = 0;
|
|
78
|
+
state.lastAction = 'de-escalate';
|
|
79
|
+
state.lastActionTimestamp = new Date();
|
|
80
|
+
return { action: 'de-escalate', previousTier, newTier: state.currentTier };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { action: 'none', previousTier, newTier: state.currentTier };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get the current tier for an agent, or null if not tracked.
|
|
88
|
+
*/
|
|
89
|
+
getCurrentTier(agentId) {
|
|
90
|
+
return this.states.get(agentId)?.currentTier ?? null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get full escalation state for an agent, or null if not tracked.
|
|
94
|
+
*/
|
|
95
|
+
getState(agentId) {
|
|
96
|
+
return this.states.get(agentId) ?? null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get all tracked escalation states.
|
|
100
|
+
*/
|
|
101
|
+
getAllStates() {
|
|
102
|
+
return Array.from(this.states.values());
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Reset state for a specific agent, or all agents if no ID provided.
|
|
106
|
+
*/
|
|
107
|
+
reset(agentId) {
|
|
108
|
+
if (agentId) {
|
|
109
|
+
this.states.delete(agentId);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.states.clear();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=auto-escalation-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-escalation-tracker.js","sourceRoot":"","sources":["../../../src/routing/escalation/auto-escalation-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IACzD,qBAAqB,EAAE,CAAC;IACxB,wBAAwB,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,OAAO;CACjB,CAAC;AAoBF,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,kDAAkD;AAClD,MAAM,UAAU,GAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEvE,SAAS,SAAS,CAAC,IAAe;IAChC,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,MAAM,OAAO,qBAAqB;IACf,MAAM,CA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,CAAC,OAAO,CAAC,EAAE,WAAW,IAAI,IAAI,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAe;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAgB;QACpB,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routing/escalation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routing/escalation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAsE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/routing/index.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ export { TinyDancerRouter, createTinyDancerRouter, } from './tiny-dancer-router.
|
|
|
18
18
|
export type { RouteResult, TinyDancerConfig, RoutingOutcome as TinyDancerRoutingOutcome, RouterStats, } from './tiny-dancer-router.js';
|
|
19
19
|
export { DEFAULT_ROUTING_CONFIG, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_TIER_MAPPING, DEFAULT_COST_OPTIMIZATION, DEFAULT_FALLBACK_CONFIG, loadRoutingConfigFromEnv, mapComplexityToTier, getNextFallbackTier, tierToModel, estimateTaskCost, validateRoutingConfig, } from './routing-config.js';
|
|
20
20
|
export type { AgentTier, ConfidenceThresholds, ComplexityTierMapping, CostOptimizationConfig, FallbackConfig, RoutingConfig, } from './routing-config.js';
|
|
21
|
+
export { EMACalibrator, DEFAULT_EMA_CONFIG, } from './calibration/index.js';
|
|
22
|
+
export type { CalibrationRecord, EMAConfig, } from './calibration/index.js';
|
|
23
|
+
export { AutoEscalationTracker, DEFAULT_ESCALATION_CONFIG, } from './escalation/index.js';
|
|
24
|
+
export type { EscalationConfig, EscalationState, EscalationAction, } from './escalation/index.js';
|
|
21
25
|
export { QueenRouterAdapter, createQueenRouterAdapter, } from './queen-integration.js';
|
|
22
26
|
export type { QueenRouteDecision, TaskOutcome, CostStats, QueenRouterConfig, } from './queen-integration.js';
|
|
23
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EACV,cAAc,EACd,MAAM,EACN,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,YAAY,EACZ,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,IAAI,wBAAwB,EAC1C,WAAW,GACZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EACV,cAAc,EACd,MAAM,EACN,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MA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M,uBAAuB,CAAC;AAE/B,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,wBAAwB,CAAC"}
|
package/dist/routing/index.js
CHANGED
|
@@ -20,6 +20,10 @@ export { classifyTask, isSimpleTask, requiresOpus, getRecommendedModel, getCompl
|
|
|
20
20
|
export { TinyDancerRouter, createTinyDancerRouter, } from './tiny-dancer-router.js';
|
|
21
21
|
// Routing Configuration (TD-004)
|
|
22
22
|
export { DEFAULT_ROUTING_CONFIG, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_TIER_MAPPING, DEFAULT_COST_OPTIMIZATION, DEFAULT_FALLBACK_CONFIG, loadRoutingConfigFromEnv, mapComplexityToTier, getNextFallbackTier, tierToModel, estimateTaskCost, validateRoutingConfig, } from './routing-config.js';
|
|
23
|
+
// EMA Calibration (loki-mode inspired)
|
|
24
|
+
export { EMACalibrator, DEFAULT_EMA_CONFIG, } from './calibration/index.js';
|
|
25
|
+
// Auto-Escalation Tracker (loki-mode inspired)
|
|
26
|
+
export { AutoEscalationTracker, DEFAULT_ESCALATION_CONFIG, } from './escalation/index.js';
|
|
23
27
|
// Queen Integration (TD-005)
|
|
24
28
|
export { QueenRouterAdapter, createQueenRouterAdapter, } from './queen-integration.js';
|
|
25
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkBH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,WAAW;AACX,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,SAAS;AACT,OAAO,EACL,YAAY,EACZ,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,WAAW;AACX,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,2BAA2B;AAC3B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAU9B,6BAA6B;AAC7B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AASjC,iCAAiC;AACjC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAW7B,6BAA6B;AAC7B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkBH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,WAAW;AACX,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,SAAS;AACT,OAAO,EACL,YAAY,EACZ,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,WAAW;AACX,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,2BAA2B;AAC3B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAU9B,6BAA6B;AAC7B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AASjC,iCAAiC;AACjC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAW7B,uCAAuC;AACvC,OAAO,EACL,aAAa,EACb,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAOhC,+CAA+C;AAC/C,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAQ/B,6BAA6B;AAC7B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
|
|
@@ -83,6 +83,10 @@ export interface RoutingConfig {
|
|
|
83
83
|
fallback: FallbackConfig;
|
|
84
84
|
/** Enable verbose logging (default: false) */
|
|
85
85
|
verbose: boolean;
|
|
86
|
+
/** Enable EMA-based agent calibration for voting weights (default: true) */
|
|
87
|
+
enableEMACalibration: boolean;
|
|
88
|
+
/** Enable automatic tier escalation/de-escalation on consecutive outcomes (default: true) */
|
|
89
|
+
enableAutoEscalation: boolean;
|
|
86
90
|
}
|
|
87
91
|
/**
|
|
88
92
|
* Default confidence thresholds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-config.d.ts","sourceRoot":"","sources":["../../src/routing/routing-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cA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,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,UAAU,EAAE,oBAAoB,CAAC;IACjC,iCAAiC;IACjC,WAAW,EAAE,qBAAqB,CAAC;IACnC,iCAAiC;IACjC,gBAAgB,EAAE,sBAAsB,CAAC;IACzC,wBAAwB;IACxB,QAAQ,EAAE,cAAc,CAAC;IACzB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"routing-config.d.ts","sourceRoot":"","sources":["../../src/routing/routing-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,qCAAqC;IACrC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,mDAAmD;IACnD,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,qCAAqC;IACrC,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,mBAA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;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,aAAsC,GACjD,aAAa,CAwCf;AAMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,aAAsC,GAC7C,SAAS,EAAE,CAoBb;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,SAAS,EACtB,MAAM,GAAE,aAAsC,GAC7C,SAAS,GAAG,IAAI,CAMlB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAUxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,MAAM,GAAE,aAAsC,GAC7C,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAkCjE"}
|
|
@@ -82,6 +82,8 @@ export const DEFAULT_ROUTING_CONFIG = {
|
|
|
82
82
|
costOptimization: DEFAULT_COST_OPTIMIZATION,
|
|
83
83
|
fallback: DEFAULT_FALLBACK_CONFIG,
|
|
84
84
|
verbose: false,
|
|
85
|
+
enableEMACalibration: true,
|
|
86
|
+
enableAutoEscalation: true,
|
|
85
87
|
};
|
|
86
88
|
// ============================================================================
|
|
87
89
|
// Environment Variable Overrides
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-config.js","sourceRoot":"","sources":["../../src/routing/routing-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"routing-config.js","sourceRoot":"","sources":["../../src/routing/routing-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6FH,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;GAEG;AACH,MAAM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|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { RoutingOutcome, QETask, QERoutingDecision, AgentPerformanceMetrics } from './types.js';
|
|
9
9
|
import type { QETaskRouter } from './qe-task-router.js';
|
|
10
|
+
import { type EMAConfig } from './calibration/index.js';
|
|
11
|
+
import { type EscalationConfig, type EscalationState } from './escalation/index.js';
|
|
12
|
+
import type { RoutingConfig } from './routing-config.js';
|
|
10
13
|
/**
|
|
11
14
|
* Collects and processes routing feedback for continuous learning
|
|
12
15
|
*/
|
|
@@ -14,10 +17,12 @@ export declare class RoutingFeedbackCollector {
|
|
|
14
17
|
private outcomeStore;
|
|
15
18
|
private router;
|
|
16
19
|
private db;
|
|
20
|
+
private calibrator;
|
|
21
|
+
private escalationTracker;
|
|
17
22
|
private persistCount;
|
|
18
23
|
private readonly maxOutcomes;
|
|
19
24
|
private static readonly RETENTION_CLEANUP_INTERVAL;
|
|
20
|
-
constructor(maxOutcomes?: number);
|
|
25
|
+
constructor(maxOutcomes?: number, routingConfig?: Partial<RoutingConfig>);
|
|
21
26
|
/**
|
|
22
27
|
* Initialize DB persistence for routing outcomes.
|
|
23
28
|
* Falls back to memory-only if DB is unavailable.
|
|
@@ -35,10 +40,38 @@ export declare class RoutingFeedbackCollector {
|
|
|
35
40
|
* Delete oldest rows beyond retention limit
|
|
36
41
|
*/
|
|
37
42
|
private enforceRetention;
|
|
43
|
+
/**
|
|
44
|
+
* Load persisted EMA calibrator state from the database
|
|
45
|
+
*/
|
|
46
|
+
private loadCalibratorState;
|
|
47
|
+
/**
|
|
48
|
+
* Persist EMA calibrator state to the database
|
|
49
|
+
*/
|
|
50
|
+
private persistCalibratorState;
|
|
38
51
|
/**
|
|
39
52
|
* Connect to router for automatic performance updates
|
|
40
53
|
*/
|
|
41
54
|
connectRouter(router: QETaskRouter): void;
|
|
55
|
+
/**
|
|
56
|
+
* Enable EMA-based agent calibration for deriving voting weights.
|
|
57
|
+
* Once enabled, every recorded outcome updates the agent's EMA calibration.
|
|
58
|
+
*/
|
|
59
|
+
enableCalibration(config?: Partial<EMAConfig>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get the EMA-calibrated voting weight for an agent.
|
|
62
|
+
* Returns 1.0 (neutral) if calibration is not enabled or agent has insufficient data.
|
|
63
|
+
*/
|
|
64
|
+
getCalibratedWeight(agentId: string): number;
|
|
65
|
+
/**
|
|
66
|
+
* Enable auto-escalation tracking for tier promotion/demotion.
|
|
67
|
+
* Once enabled, every recorded outcome updates the agent's escalation state.
|
|
68
|
+
*/
|
|
69
|
+
enableAutoEscalation(config?: Partial<EscalationConfig>): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get the current escalation state for an agent.
|
|
72
|
+
* Returns null if auto-escalation is not enabled or agent has no state.
|
|
73
|
+
*/
|
|
74
|
+
getEscalationState(agentId: string): EscalationState | null;
|
|
42
75
|
/**
|
|
43
76
|
* Record a routing outcome
|
|
44
77
|
*/
|
|
@@ -99,5 +132,5 @@ export declare class RoutingFeedbackCollector {
|
|
|
99
132
|
/**
|
|
100
133
|
* Create a new routing feedback collector
|
|
101
134
|
*/
|
|
102
|
-
export declare function createRoutingFeedbackCollector(maxOutcomes?: number): RoutingFeedbackCollector;
|
|
135
|
+
export declare function createRoutingFeedbackCollector(maxOutcomes?: number, routingConfig?: Partial<RoutingConfig>): RoutingFeedbackCollector;
|
|
103
136
|
//# sourceMappingURL=routing-feedback.d.ts.map
|