@renseiai/agentfactory 0.8.7 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/config/index.d.ts +1 -1
- package/dist/src/config/index.d.ts.map +1 -1
- package/dist/src/config/index.js +1 -1
- package/dist/src/config/repository-config.d.ts +37 -0
- package/dist/src/config/repository-config.d.ts.map +1 -1
- package/dist/src/config/repository-config.js +47 -0
- package/dist/src/config/repository-config.test.js +140 -1
- package/dist/src/governor/decision-engine.d.ts +3 -0
- package/dist/src/governor/decision-engine.d.ts.map +1 -1
- package/dist/src/governor/decision-engine.js +11 -0
- package/dist/src/governor/decision-engine.test.js +33 -0
- package/dist/src/governor/event-types.d.ts +18 -1
- package/dist/src/governor/event-types.d.ts.map +1 -1
- package/dist/src/governor/event-types.js +4 -0
- package/dist/src/governor/governor-types.d.ts +1 -1
- package/dist/src/governor/governor-types.d.ts.map +1 -1
- package/dist/src/governor/governor.d.ts +17 -1
- package/dist/src/governor/governor.d.ts.map +1 -1
- package/dist/src/governor/governor.js +112 -1
- package/dist/src/governor/governor.test.js +155 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/merge-queue/adapters/github-native.d.ts +22 -0
- package/dist/src/merge-queue/adapters/github-native.d.ts.map +1 -0
- package/dist/src/merge-queue/adapters/github-native.js +243 -0
- package/dist/src/merge-queue/adapters/github-native.test.d.ts +2 -0
- package/dist/src/merge-queue/adapters/github-native.test.d.ts.map +1 -0
- package/dist/src/merge-queue/adapters/github-native.test.js +384 -0
- package/dist/src/merge-queue/index.d.ts +18 -0
- package/dist/src/merge-queue/index.d.ts.map +1 -0
- package/dist/src/merge-queue/index.js +28 -0
- package/dist/src/merge-queue/merge-queue.integration.test.d.ts +2 -0
- package/dist/src/merge-queue/merge-queue.integration.test.d.ts.map +1 -0
- package/dist/src/merge-queue/merge-queue.integration.test.js +128 -0
- package/dist/src/merge-queue/types.d.ts +48 -0
- package/dist/src/merge-queue/types.d.ts.map +1 -0
- package/dist/src/merge-queue/types.js +8 -0
- package/dist/src/orchestrator/artifact-tracker.d.ts +93 -0
- package/dist/src/orchestrator/artifact-tracker.d.ts.map +1 -0
- package/dist/src/orchestrator/artifact-tracker.js +235 -0
- package/dist/src/orchestrator/artifact-tracker.test.d.ts +2 -0
- package/dist/src/orchestrator/artifact-tracker.test.d.ts.map +1 -0
- package/dist/src/orchestrator/artifact-tracker.test.js +189 -0
- package/dist/src/orchestrator/context-manager.d.ts +72 -0
- package/dist/src/orchestrator/context-manager.d.ts.map +1 -0
- package/dist/src/orchestrator/context-manager.js +120 -0
- package/dist/src/orchestrator/context-manager.test.d.ts +2 -0
- package/dist/src/orchestrator/context-manager.test.d.ts.map +1 -0
- package/dist/src/orchestrator/context-manager.test.js +137 -0
- package/dist/src/orchestrator/index.d.ts +8 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +8 -1
- package/dist/src/orchestrator/issue-tracker-client.d.ts +4 -0
- package/dist/src/orchestrator/issue-tracker-client.d.ts.map +1 -1
- package/dist/src/orchestrator/orchestrator.d.ts +12 -0
- package/dist/src/orchestrator/orchestrator.d.ts.map +1 -1
- package/dist/src/orchestrator/orchestrator.js +282 -2
- package/dist/src/orchestrator/parse-work-result.d.ts.map +1 -1
- package/dist/src/orchestrator/parse-work-result.js +6 -0
- package/dist/src/orchestrator/parse-work-result.test.js +19 -0
- package/dist/src/orchestrator/state-recovery.d.ts +21 -2
- package/dist/src/orchestrator/state-recovery.d.ts.map +1 -1
- package/dist/src/orchestrator/state-recovery.js +54 -2
- package/dist/src/orchestrator/state-recovery.test.js +106 -2
- package/dist/src/orchestrator/state-types.d.ts +62 -0
- package/dist/src/orchestrator/state-types.d.ts.map +1 -1
- package/dist/src/orchestrator/state-types.js +5 -1
- package/dist/src/orchestrator/summary-builder.d.ts +47 -0
- package/dist/src/orchestrator/summary-builder.d.ts.map +1 -0
- package/dist/src/orchestrator/summary-builder.js +240 -0
- package/dist/src/orchestrator/summary-builder.test.d.ts +2 -0
- package/dist/src/orchestrator/summary-builder.test.d.ts.map +1 -0
- package/dist/src/orchestrator/summary-builder.test.js +236 -0
- package/dist/src/orchestrator/types.d.ts +2 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/work-types.d.ts +1 -1
- package/dist/src/orchestrator/work-types.d.ts.map +1 -1
- package/dist/src/providers/index.d.ts +64 -1
- package/dist/src/providers/index.d.ts.map +1 -1
- package/dist/src/providers/index.js +132 -1
- package/dist/src/providers/index.test.js +340 -2
- package/dist/src/routing/index.d.ts +7 -0
- package/dist/src/routing/index.d.ts.map +1 -0
- package/dist/src/routing/index.js +6 -0
- package/dist/src/routing/observation-recorder.d.ts +19 -0
- package/dist/src/routing/observation-recorder.d.ts.map +1 -0
- package/dist/src/routing/observation-recorder.js +73 -0
- package/dist/src/routing/observation-recorder.test.d.ts +2 -0
- package/dist/src/routing/observation-recorder.test.d.ts.map +1 -0
- package/dist/src/routing/observation-recorder.test.js +322 -0
- package/dist/src/routing/observation-store.d.ts +40 -0
- package/dist/src/routing/observation-store.d.ts.map +1 -0
- package/dist/src/routing/observation-store.js +1 -0
- package/dist/src/routing/observation-store.test.d.ts +2 -0
- package/dist/src/routing/observation-store.test.d.ts.map +1 -0
- package/dist/src/routing/observation-store.test.js +138 -0
- package/dist/src/routing/posterior-store.d.ts +12 -0
- package/dist/src/routing/posterior-store.d.ts.map +1 -0
- package/dist/src/routing/posterior-store.js +13 -0
- package/dist/src/routing/posterior-store.test.d.ts +2 -0
- package/dist/src/routing/posterior-store.test.d.ts.map +1 -0
- package/dist/src/routing/posterior-store.test.js +37 -0
- package/dist/src/routing/reward.d.ts +16 -0
- package/dist/src/routing/reward.d.ts.map +1 -0
- package/dist/src/routing/reward.js +29 -0
- package/dist/src/routing/reward.test.d.ts +2 -0
- package/dist/src/routing/reward.test.d.ts.map +1 -0
- package/dist/src/routing/reward.test.js +210 -0
- package/dist/src/routing/routing-engine.d.ts +20 -0
- package/dist/src/routing/routing-engine.d.ts.map +1 -0
- package/dist/src/routing/routing-engine.js +113 -0
- package/dist/src/routing/routing-engine.test.d.ts +2 -0
- package/dist/src/routing/routing-engine.test.d.ts.map +1 -0
- package/dist/src/routing/routing-engine.test.js +310 -0
- package/dist/src/routing/types.d.ts +157 -0
- package/dist/src/routing/types.d.ts.map +1 -0
- package/dist/src/routing/types.js +68 -0
- package/dist/src/routing/types.test.d.ts +2 -0
- package/dist/src/routing/types.test.d.ts.map +1 -0
- package/dist/src/routing/types.test.js +184 -0
- package/dist/src/templates/registry.test.js +2 -2
- package/dist/src/templates/types.d.ts +5 -0
- package/dist/src/templates/types.d.ts.map +1 -1
- package/dist/src/templates/types.js +3 -0
- package/dist/src/workflow/agent-cancellation.d.ts +37 -0
- package/dist/src/workflow/agent-cancellation.d.ts.map +1 -0
- package/dist/src/workflow/agent-cancellation.js +41 -0
- package/dist/src/workflow/agent-cancellation.test.d.ts +2 -0
- package/dist/src/workflow/agent-cancellation.test.d.ts.map +1 -0
- package/dist/src/workflow/agent-cancellation.test.js +86 -0
- package/dist/src/workflow/branching-router.d.ts +38 -0
- package/dist/src/workflow/branching-router.d.ts.map +1 -0
- package/dist/src/workflow/branching-router.js +52 -0
- package/dist/src/workflow/branching-router.test.d.ts +2 -0
- package/dist/src/workflow/branching-router.test.d.ts.map +1 -0
- package/dist/src/workflow/branching-router.test.js +209 -0
- package/dist/src/workflow/concurrency-semaphore.d.ts +21 -0
- package/dist/src/workflow/concurrency-semaphore.d.ts.map +1 -0
- package/dist/src/workflow/concurrency-semaphore.js +46 -0
- package/dist/src/workflow/concurrency-semaphore.test.d.ts +2 -0
- package/dist/src/workflow/concurrency-semaphore.test.d.ts.map +1 -0
- package/dist/src/workflow/concurrency-semaphore.test.js +183 -0
- package/dist/src/workflow/duration.d.ts +28 -0
- package/dist/src/workflow/duration.d.ts.map +1 -0
- package/dist/src/workflow/duration.js +57 -0
- package/dist/src/workflow/duration.test.d.ts +2 -0
- package/dist/src/workflow/duration.test.d.ts.map +1 -0
- package/dist/src/workflow/duration.test.js +74 -0
- package/dist/src/workflow/expression/ast.d.ts +53 -0
- package/dist/src/workflow/expression/ast.d.ts.map +1 -0
- package/dist/src/workflow/expression/ast.js +8 -0
- package/dist/src/workflow/expression/context.d.ts +40 -0
- package/dist/src/workflow/expression/context.d.ts.map +1 -0
- package/dist/src/workflow/expression/context.js +37 -0
- package/dist/src/workflow/expression/evaluator.d.ts +28 -0
- package/dist/src/workflow/expression/evaluator.d.ts.map +1 -0
- package/dist/src/workflow/expression/evaluator.js +165 -0
- package/dist/src/workflow/expression/evaluator.test.d.ts +2 -0
- package/dist/src/workflow/expression/evaluator.test.d.ts.map +1 -0
- package/dist/src/workflow/expression/evaluator.test.js +792 -0
- package/dist/src/workflow/expression/expression.test.d.ts +2 -0
- package/dist/src/workflow/expression/expression.test.d.ts.map +1 -0
- package/dist/src/workflow/expression/expression.test.js +516 -0
- package/dist/src/workflow/expression/helpers.d.ts +21 -0
- package/dist/src/workflow/expression/helpers.d.ts.map +1 -0
- package/dist/src/workflow/expression/helpers.js +56 -0
- package/dist/src/workflow/expression/index.d.ts +55 -0
- package/dist/src/workflow/expression/index.d.ts.map +1 -0
- package/dist/src/workflow/expression/index.js +71 -0
- package/dist/src/workflow/expression/lexer.d.ts +37 -0
- package/dist/src/workflow/expression/lexer.d.ts.map +1 -0
- package/dist/src/workflow/expression/lexer.js +166 -0
- package/dist/src/workflow/expression/parser.d.ts +23 -0
- package/dist/src/workflow/expression/parser.d.ts.map +1 -0
- package/dist/src/workflow/expression/parser.js +181 -0
- package/dist/src/workflow/gate-state.d.ts +115 -0
- package/dist/src/workflow/gate-state.d.ts.map +1 -0
- package/dist/src/workflow/gate-state.js +185 -0
- package/dist/src/workflow/gate-state.test.d.ts +2 -0
- package/dist/src/workflow/gate-state.test.d.ts.map +1 -0
- package/dist/src/workflow/gate-state.test.js +251 -0
- package/dist/src/workflow/gates/gate-evaluator.d.ts +119 -0
- package/dist/src/workflow/gates/gate-evaluator.d.ts.map +1 -0
- package/dist/src/workflow/gates/gate-evaluator.js +243 -0
- package/dist/src/workflow/gates/gate-evaluator.test.d.ts +2 -0
- package/dist/src/workflow/gates/gate-evaluator.test.d.ts.map +1 -0
- package/dist/src/workflow/gates/gate-evaluator.test.js +240 -0
- package/dist/src/workflow/gates/signal-gate.d.ts +114 -0
- package/dist/src/workflow/gates/signal-gate.d.ts.map +1 -0
- package/dist/src/workflow/gates/signal-gate.js +216 -0
- package/dist/src/workflow/gates/signal-gate.test.d.ts +2 -0
- package/dist/src/workflow/gates/signal-gate.test.d.ts.map +1 -0
- package/dist/src/workflow/gates/signal-gate.test.js +199 -0
- package/dist/src/workflow/gates/timeout-engine.d.ts +96 -0
- package/dist/src/workflow/gates/timeout-engine.d.ts.map +1 -0
- package/dist/src/workflow/gates/timeout-engine.js +162 -0
- package/dist/src/workflow/gates/timeout-engine.test.d.ts +2 -0
- package/dist/src/workflow/gates/timeout-engine.test.d.ts.map +1 -0
- package/dist/src/workflow/gates/timeout-engine.test.js +186 -0
- package/dist/src/workflow/gates/timer-gate.d.ts +125 -0
- package/dist/src/workflow/gates/timer-gate.d.ts.map +1 -0
- package/dist/src/workflow/gates/timer-gate.js +381 -0
- package/dist/src/workflow/gates/timer-gate.test.d.ts +2 -0
- package/dist/src/workflow/gates/timer-gate.test.d.ts.map +1 -0
- package/dist/src/workflow/gates/timer-gate.test.js +211 -0
- package/dist/src/workflow/gates/webhook-gate.d.ts +132 -0
- package/dist/src/workflow/gates/webhook-gate.d.ts.map +1 -0
- package/dist/src/workflow/gates/webhook-gate.js +216 -0
- package/dist/src/workflow/gates/webhook-gate.test.d.ts +2 -0
- package/dist/src/workflow/gates/webhook-gate.test.d.ts.map +1 -0
- package/dist/src/workflow/gates/webhook-gate.test.js +182 -0
- package/dist/src/workflow/index.d.ts +31 -3
- package/dist/src/workflow/index.d.ts.map +1 -1
- package/dist/src/workflow/index.js +20 -1
- package/dist/src/workflow/parallelism-executor.d.ts +25 -0
- package/dist/src/workflow/parallelism-executor.d.ts.map +1 -0
- package/dist/src/workflow/parallelism-executor.js +53 -0
- package/dist/src/workflow/parallelism-executor.test.d.ts +2 -0
- package/dist/src/workflow/parallelism-executor.test.d.ts.map +1 -0
- package/dist/src/workflow/parallelism-executor.test.js +191 -0
- package/dist/src/workflow/parallelism-types.d.ts +80 -0
- package/dist/src/workflow/parallelism-types.d.ts.map +1 -0
- package/dist/src/workflow/parallelism-types.js +8 -0
- package/dist/src/workflow/phase-context-injector.d.ts +29 -0
- package/dist/src/workflow/phase-context-injector.d.ts.map +1 -0
- package/dist/src/workflow/phase-context-injector.js +43 -0
- package/dist/src/workflow/phase-context-injector.test.d.ts +2 -0
- package/dist/src/workflow/phase-context-injector.test.d.ts.map +1 -0
- package/dist/src/workflow/phase-context-injector.test.js +123 -0
- package/dist/src/workflow/phase-output-collector.d.ts +39 -0
- package/dist/src/workflow/phase-output-collector.d.ts.map +1 -0
- package/dist/src/workflow/phase-output-collector.js +141 -0
- package/dist/src/workflow/phase-output-collector.test.d.ts +2 -0
- package/dist/src/workflow/phase-output-collector.test.d.ts.map +1 -0
- package/dist/src/workflow/phase-output-collector.test.js +179 -0
- package/dist/src/workflow/retry-resolver.d.ts +51 -0
- package/dist/src/workflow/retry-resolver.d.ts.map +1 -0
- package/dist/src/workflow/retry-resolver.js +70 -0
- package/dist/src/workflow/retry-resolver.test.d.ts +2 -0
- package/dist/src/workflow/retry-resolver.test.d.ts.map +1 -0
- package/dist/src/workflow/retry-resolver.test.js +149 -0
- package/dist/src/workflow/strategies/fan-in-strategy.d.ts +21 -0
- package/dist/src/workflow/strategies/fan-in-strategy.d.ts.map +1 -0
- package/dist/src/workflow/strategies/fan-in-strategy.js +92 -0
- package/dist/src/workflow/strategies/fan-in-strategy.test.d.ts +2 -0
- package/dist/src/workflow/strategies/fan-in-strategy.test.d.ts.map +1 -0
- package/dist/src/workflow/strategies/fan-in-strategy.test.js +182 -0
- package/dist/src/workflow/strategies/fan-out-strategy.d.ts +16 -0
- package/dist/src/workflow/strategies/fan-out-strategy.d.ts.map +1 -0
- package/dist/src/workflow/strategies/fan-out-strategy.js +47 -0
- package/dist/src/workflow/strategies/fan-out-strategy.test.d.ts +2 -0
- package/dist/src/workflow/strategies/fan-out-strategy.test.d.ts.map +1 -0
- package/dist/src/workflow/strategies/fan-out-strategy.test.js +97 -0
- package/dist/src/workflow/strategies/index.d.ts +4 -0
- package/dist/src/workflow/strategies/index.d.ts.map +1 -0
- package/dist/src/workflow/strategies/index.js +3 -0
- package/dist/src/workflow/strategies/race-strategy.d.ts +19 -0
- package/dist/src/workflow/strategies/race-strategy.d.ts.map +1 -0
- package/dist/src/workflow/strategies/race-strategy.js +92 -0
- package/dist/src/workflow/strategies/race-strategy.test.d.ts +2 -0
- package/dist/src/workflow/strategies/race-strategy.test.d.ts.map +1 -0
- package/dist/src/workflow/strategies/race-strategy.test.js +318 -0
- package/dist/src/workflow/transition-engine.d.ts +3 -1
- package/dist/src/workflow/transition-engine.d.ts.map +1 -1
- package/dist/src/workflow/transition-engine.js +26 -7
- package/dist/src/workflow/transition-engine.test.js +215 -11
- package/dist/src/workflow/workflow-registry.d.ts +46 -1
- package/dist/src/workflow/workflow-registry.d.ts.map +1 -1
- package/dist/src/workflow/workflow-registry.js +74 -0
- package/dist/src/workflow/workflow-registry.test.js +54 -0
- package/dist/src/workflow/workflow-types.d.ts +330 -12
- package/dist/src/workflow/workflow-types.d.ts.map +1 -1
- package/dist/src/workflow/workflow-types.js +100 -5
- package/dist/src/workflow/workflow-types.test.js +293 -2
- package/package.json +2 -2
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { SummaryBuilder } from './summary-builder.js';
|
|
3
|
+
import { SUMMARY_SCHEMA_VERSION } from './state-types.js';
|
|
4
|
+
function makeToolUse(toolName, input) {
|
|
5
|
+
return { type: 'tool_use', toolName, input, raw: {} };
|
|
6
|
+
}
|
|
7
|
+
function makeAssistantText(text) {
|
|
8
|
+
return { type: 'assistant_text', text, raw: {} };
|
|
9
|
+
}
|
|
10
|
+
function makeEmptyArtifacts() {
|
|
11
|
+
return { files: {}, totalReads: 0, totalWrites: 0, lastUpdatedAt: 0 };
|
|
12
|
+
}
|
|
13
|
+
function makeSummary(overrides = {}) {
|
|
14
|
+
return {
|
|
15
|
+
schemaVersion: SUMMARY_SCHEMA_VERSION,
|
|
16
|
+
sessionIntent: 'Test session intent',
|
|
17
|
+
fileModifications: [],
|
|
18
|
+
decisionsMade: [],
|
|
19
|
+
nextSteps: [],
|
|
20
|
+
compactionCount: 1,
|
|
21
|
+
lastCompactedAt: 1000,
|
|
22
|
+
tokenEstimate: 100,
|
|
23
|
+
...overrides,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
describe('SummaryBuilder — summarizeSpan', () => {
|
|
27
|
+
it('extracts file modifications from tool_use events', () => {
|
|
28
|
+
const builder = new SummaryBuilder();
|
|
29
|
+
const events = [
|
|
30
|
+
makeToolUse('Read', { file_path: '/src/foo.ts' }),
|
|
31
|
+
makeToolUse('Edit', { file_path: '/src/bar.ts' }),
|
|
32
|
+
makeToolUse('Write', { file_path: '/src/new.ts' }),
|
|
33
|
+
];
|
|
34
|
+
const summary = builder.summarizeSpan(events, null, makeEmptyArtifacts());
|
|
35
|
+
expect(summary.fileModifications).toHaveLength(3);
|
|
36
|
+
expect(summary.fileModifications.map(m => m.action)).toEqual(['read', 'modified', 'created']);
|
|
37
|
+
});
|
|
38
|
+
it('extracts session intent from assistant text', () => {
|
|
39
|
+
const builder = new SummaryBuilder();
|
|
40
|
+
const events = [
|
|
41
|
+
makeAssistantText('I will implement the authentication system for the admin dashboard. This involves creating JWT tokens and middleware.'),
|
|
42
|
+
];
|
|
43
|
+
const summary = builder.summarizeSpan(events, null, makeEmptyArtifacts());
|
|
44
|
+
expect(summary.sessionIntent).toContain('authentication system');
|
|
45
|
+
});
|
|
46
|
+
it('preserves existing session intent when no new intent found', () => {
|
|
47
|
+
const builder = new SummaryBuilder();
|
|
48
|
+
const existing = makeSummary({ sessionIntent: 'Original intent' });
|
|
49
|
+
const events = [
|
|
50
|
+
makeToolUse('Read', { file_path: '/src/foo.ts' }),
|
|
51
|
+
];
|
|
52
|
+
const summary = builder.summarizeSpan(events, existing, makeEmptyArtifacts());
|
|
53
|
+
expect(summary.sessionIntent).toBe('Original intent');
|
|
54
|
+
});
|
|
55
|
+
it('increments compaction count from existing summary', () => {
|
|
56
|
+
const builder = new SummaryBuilder();
|
|
57
|
+
const existing = makeSummary({ compactionCount: 2 });
|
|
58
|
+
const summary = builder.summarizeSpan([], existing, makeEmptyArtifacts());
|
|
59
|
+
expect(summary.compactionCount).toBe(3);
|
|
60
|
+
});
|
|
61
|
+
it('starts compaction count at 1 when no existing summary', () => {
|
|
62
|
+
const builder = new SummaryBuilder();
|
|
63
|
+
const summary = builder.summarizeSpan([], null, makeEmptyArtifacts());
|
|
64
|
+
expect(summary.compactionCount).toBe(1);
|
|
65
|
+
});
|
|
66
|
+
it('estimates token count', () => {
|
|
67
|
+
const builder = new SummaryBuilder();
|
|
68
|
+
const summary = builder.summarizeSpan([], null, makeEmptyArtifacts());
|
|
69
|
+
expect(summary.tokenEstimate).toBeGreaterThan(0);
|
|
70
|
+
});
|
|
71
|
+
it('deduplicates file modifications for same path', () => {
|
|
72
|
+
const builder = new SummaryBuilder();
|
|
73
|
+
const events = [
|
|
74
|
+
makeToolUse('Read', { file_path: '/src/foo.ts' }),
|
|
75
|
+
makeToolUse('Edit', { file_path: '/src/foo.ts' }),
|
|
76
|
+
];
|
|
77
|
+
const summary = builder.summarizeSpan(events, null, makeEmptyArtifacts());
|
|
78
|
+
expect(summary.fileModifications).toHaveLength(1);
|
|
79
|
+
expect(summary.fileModifications[0].action).toBe('modified'); // Latest action wins
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('SummaryBuilder — mergeSummaries', () => {
|
|
83
|
+
it('keeps existing session intent when incoming is empty', () => {
|
|
84
|
+
const builder = new SummaryBuilder();
|
|
85
|
+
const existing = makeSummary({ sessionIntent: 'Original intent' });
|
|
86
|
+
const incoming = makeSummary({ sessionIntent: '' });
|
|
87
|
+
const merged = builder.mergeSummaries(existing, incoming);
|
|
88
|
+
expect(merged.sessionIntent).toBe('Original intent');
|
|
89
|
+
});
|
|
90
|
+
it('uses incoming session intent when provided', () => {
|
|
91
|
+
const builder = new SummaryBuilder();
|
|
92
|
+
const existing = makeSummary({ sessionIntent: 'Old intent' });
|
|
93
|
+
const incoming = makeSummary({ sessionIntent: 'New intent' });
|
|
94
|
+
const merged = builder.mergeSummaries(existing, incoming);
|
|
95
|
+
expect(merged.sessionIntent).toBe('New intent');
|
|
96
|
+
});
|
|
97
|
+
it('unions file modifications by path', () => {
|
|
98
|
+
const builder = new SummaryBuilder();
|
|
99
|
+
const existing = makeSummary({
|
|
100
|
+
fileModifications: [
|
|
101
|
+
{ path: '/src/a.ts', action: 'read', reason: 'Initial read', lastModifiedAt: 1000 },
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
const incoming = makeSummary({
|
|
105
|
+
fileModifications: [
|
|
106
|
+
{ path: '/src/a.ts', action: 'modified', reason: 'Updated logic', lastModifiedAt: 2000 },
|
|
107
|
+
{ path: '/src/b.ts', action: 'created', reason: 'New file', lastModifiedAt: 2000 },
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
const merged = builder.mergeSummaries(existing, incoming);
|
|
111
|
+
expect(merged.fileModifications).toHaveLength(2);
|
|
112
|
+
const fileA = merged.fileModifications.find(m => m.path === '/src/a.ts');
|
|
113
|
+
expect(fileA?.action).toBe('modified');
|
|
114
|
+
expect(fileA?.reason).toContain('Initial read');
|
|
115
|
+
expect(fileA?.reason).toContain('Updated logic');
|
|
116
|
+
expect(fileA?.lastModifiedAt).toBe(2000);
|
|
117
|
+
});
|
|
118
|
+
it('appends decisions chronologically', () => {
|
|
119
|
+
const builder = new SummaryBuilder();
|
|
120
|
+
const existing = makeSummary({
|
|
121
|
+
decisionsMade: [
|
|
122
|
+
{ description: 'First decision', rationale: 'Because', madeAt: 1000 },
|
|
123
|
+
],
|
|
124
|
+
});
|
|
125
|
+
const incoming = makeSummary({
|
|
126
|
+
decisionsMade: [
|
|
127
|
+
{ description: 'Second decision', rationale: 'Also because', madeAt: 2000 },
|
|
128
|
+
],
|
|
129
|
+
});
|
|
130
|
+
const merged = builder.mergeSummaries(existing, incoming);
|
|
131
|
+
expect(merged.decisionsMade).toHaveLength(2);
|
|
132
|
+
expect(merged.decisionsMade[0].description).toBe('First decision');
|
|
133
|
+
expect(merged.decisionsMade[1].description).toBe('Second decision');
|
|
134
|
+
});
|
|
135
|
+
it('merges next steps, removing duplicates', () => {
|
|
136
|
+
const builder = new SummaryBuilder();
|
|
137
|
+
const existing = makeSummary({ nextSteps: ['Step A', 'Step B'] });
|
|
138
|
+
const incoming = makeSummary({ nextSteps: ['Step C'] });
|
|
139
|
+
const merged = builder.mergeSummaries(existing, incoming);
|
|
140
|
+
expect(merged.nextSteps).toContain('Step A');
|
|
141
|
+
expect(merged.nextSteps).toContain('Step B');
|
|
142
|
+
expect(merged.nextSteps).toContain('Step C');
|
|
143
|
+
});
|
|
144
|
+
it('uses incoming compaction count', () => {
|
|
145
|
+
const builder = new SummaryBuilder();
|
|
146
|
+
const existing = makeSummary({ compactionCount: 2 });
|
|
147
|
+
const incoming = makeSummary({ compactionCount: 3 });
|
|
148
|
+
const merged = builder.mergeSummaries(existing, incoming);
|
|
149
|
+
expect(merged.compactionCount).toBe(3);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
describe('SummaryBuilder — toPromptSection', () => {
|
|
153
|
+
it('generates context-summary tags', () => {
|
|
154
|
+
const builder = new SummaryBuilder();
|
|
155
|
+
const summary = makeSummary();
|
|
156
|
+
const output = builder.toPromptSection(summary, makeEmptyArtifacts());
|
|
157
|
+
expect(output).toContain('<context-summary>');
|
|
158
|
+
expect(output).toContain('</context-summary>');
|
|
159
|
+
});
|
|
160
|
+
it('includes session intent', () => {
|
|
161
|
+
const builder = new SummaryBuilder();
|
|
162
|
+
const summary = makeSummary({ sessionIntent: 'Implement auth flow' });
|
|
163
|
+
const output = builder.toPromptSection(summary, makeEmptyArtifacts());
|
|
164
|
+
expect(output).toContain('## Session Intent');
|
|
165
|
+
expect(output).toContain('Implement auth flow');
|
|
166
|
+
});
|
|
167
|
+
it('includes file modifications', () => {
|
|
168
|
+
const builder = new SummaryBuilder();
|
|
169
|
+
const summary = makeSummary({
|
|
170
|
+
fileModifications: [
|
|
171
|
+
{ path: 'src/auth.ts', action: 'created', reason: 'New auth module', lastModifiedAt: 1000 },
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
const output = builder.toPromptSection(summary, makeEmptyArtifacts());
|
|
175
|
+
expect(output).toContain('## Files Modified');
|
|
176
|
+
expect(output).toContain('src/auth.ts');
|
|
177
|
+
expect(output).toContain('Created');
|
|
178
|
+
});
|
|
179
|
+
it('includes decisions with alternatives', () => {
|
|
180
|
+
const builder = new SummaryBuilder();
|
|
181
|
+
const summary = makeSummary({
|
|
182
|
+
decisionsMade: [
|
|
183
|
+
{
|
|
184
|
+
description: 'Use JWT',
|
|
185
|
+
rationale: 'Stateless API',
|
|
186
|
+
alternatives: ['session cookies'],
|
|
187
|
+
madeAt: 1000,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
});
|
|
191
|
+
const output = builder.toPromptSection(summary, makeEmptyArtifacts());
|
|
192
|
+
expect(output).toContain('## Key Decisions');
|
|
193
|
+
expect(output).toContain('Use JWT');
|
|
194
|
+
expect(output).toContain('Stateless API');
|
|
195
|
+
expect(output).toContain('rejected: session cookies');
|
|
196
|
+
});
|
|
197
|
+
it('includes next steps as checklist', () => {
|
|
198
|
+
const builder = new SummaryBuilder();
|
|
199
|
+
const summary = makeSummary({ nextSteps: ['Write tests', 'Deploy'] });
|
|
200
|
+
const output = builder.toPromptSection(summary, makeEmptyArtifacts());
|
|
201
|
+
expect(output).toContain('## Next Steps');
|
|
202
|
+
expect(output).toContain('- [ ] Write tests');
|
|
203
|
+
expect(output).toContain('- [ ] Deploy');
|
|
204
|
+
});
|
|
205
|
+
it('includes tracked files from artifact index', () => {
|
|
206
|
+
const builder = new SummaryBuilder();
|
|
207
|
+
const summary = makeSummary();
|
|
208
|
+
const artifacts = {
|
|
209
|
+
files: {
|
|
210
|
+
'/abs/src/foo.ts': {
|
|
211
|
+
path: '/abs/src/foo.ts',
|
|
212
|
+
relativePath: 'src/foo.ts',
|
|
213
|
+
actions: ['modified'],
|
|
214
|
+
firstSeenAt: 1000,
|
|
215
|
+
lastTouchedAt: 2000,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
totalReads: 0,
|
|
219
|
+
totalWrites: 1,
|
|
220
|
+
lastUpdatedAt: 2000,
|
|
221
|
+
};
|
|
222
|
+
const output = builder.toPromptSection(summary, artifacts);
|
|
223
|
+
expect(output).toContain('## Tracked Files');
|
|
224
|
+
expect(output).toContain('src/foo.ts');
|
|
225
|
+
});
|
|
226
|
+
it('does not expose token counts or compaction count (context anxiety prevention)', () => {
|
|
227
|
+
const builder = new SummaryBuilder();
|
|
228
|
+
const summary = makeSummary({ compactionCount: 5, tokenEstimate: 5000 });
|
|
229
|
+
const output = builder.toPromptSection(summary, makeEmptyArtifacts());
|
|
230
|
+
expect(output).not.toContain('5000');
|
|
231
|
+
expect(output).not.toContain('compaction');
|
|
232
|
+
expect(output).not.toContain('token');
|
|
233
|
+
expect(output).not.toContain('compressed');
|
|
234
|
+
expect(output).not.toContain('limit');
|
|
235
|
+
});
|
|
236
|
+
});
|
|
@@ -113,6 +113,8 @@ export interface OrchestratorConfig {
|
|
|
113
113
|
* at startup and before spawning agents. Supports both HTTPS and SSH URL formats.
|
|
114
114
|
*/
|
|
115
115
|
repository?: string;
|
|
116
|
+
/** Merge queue adapter for automated merge operations */
|
|
117
|
+
mergeQueueAdapter?: import('../merge-queue/types.js').MergeQueueAdapter;
|
|
116
118
|
}
|
|
117
119
|
export interface OrchestratorIssue {
|
|
118
120
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,kEAAkE;IAClE,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,sGAAsG;IACtG,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC;;;OAGG;IACH,cAAc,CAAC,EAAE,sBAAsB,CAAA;IACvC;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,EAAE,CAAA;IAC1B,8DAA8D;IAC9D,cAAc,CAAC,EAAE,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KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,aAAa,GAAG,UAAU,GAAG,kBAAkB,CAAA;IACxD,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,yGAAyG;IACzG,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,+FAA+F;IAC/F,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Agent work type — determines prompt template, status transitions,
|
|
10
10
|
* and whether a git worktree is needed.
|
|
11
11
|
*/
|
|
12
|
-
export type AgentWorkType = 'research' | 'backlog-creation' | 'development' | 'inflight' | 'inflight-coordination' | 'qa' | 'acceptance' | 'refinement' | 'refinement-coordination' | 'coordination' | 'qa-coordination' | 'acceptance-coordination';
|
|
12
|
+
export type AgentWorkType = 'research' | 'backlog-creation' | 'development' | 'inflight' | 'inflight-coordination' | 'qa' | 'acceptance' | 'refinement' | 'refinement-coordination' | 'coordination' | 'qa-coordination' | 'acceptance-coordination' | 'merge';
|
|
13
13
|
/**
|
|
14
14
|
* Workflow status — platform-agnostic string (e.g., 'Started', 'Finished').
|
|
15
15
|
* Concrete values are defined by the issue tracker plugin.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-types.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/work-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,kBAAkB,GAClB,aAAa,GACb,UAAU,GACV,uBAAuB,GACvB,IAAI,GACJ,YAAY,GACZ,YAAY,GACZ,yBAAyB,GACzB,cAAc,GACd,iBAAiB,GACjB,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"work-types.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/work-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,kBAAkB,GAClB,aAAa,GACb,UAAU,GACV,uBAAuB,GACvB,IAAI,GACJ,YAAY,GACZ,YAAY,GACZ,yBAAyB,GACzB,cAAc,GACd,iBAAiB,GACjB,yBAAyB,GACzB,OAAO,CAAA;AAEX;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AAEnC;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC/C,6EAA6E;IAC7E,mBAAmB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;IACzD,sEAAsE;IACtE,sBAAsB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;IAC5D,qDAAqD;IACrD,kBAAkB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;IACxD,oEAAoE;IACpE,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,6CAA6C;IAC7C,0BAA0B,EAAE,WAAW,CAAC,aAAa,CAAC,CAAA;CACvD;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;CAS1B,CAAA;AAEV,MAAM,MAAM,oBAAoB,GAC9B,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAA"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Creates provider instances based on name.
|
|
5
5
|
* Supports provider selection via env vars, config, labels, and mentions.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Sync resolution order (highest → lowest):
|
|
8
8
|
* 1. Issue label override (provider:codex)
|
|
9
9
|
* 2. Mention context override ("use codex", "@codex")
|
|
10
10
|
* 3. Config providers.byWorkType
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
* 7. Config providers.default
|
|
15
15
|
* 8. Env var AGENT_PROVIDER
|
|
16
16
|
* 9. Hardcoded 'claude'
|
|
17
|
+
*
|
|
18
|
+
* Async resolution order (with MAB routing):
|
|
19
|
+
* 1. Issue label override (provider:codex) — explicit human override
|
|
20
|
+
* 2. Mention context override ("use codex") — explicit human override
|
|
21
|
+
* 3. Config providers.byWorkType — static config
|
|
22
|
+
* 4. Config providers.byProject — static config
|
|
23
|
+
* 5. MAB-based intelligent routing — learned routing (feature-flagged)
|
|
24
|
+
* 6. Env var AGENT_PROVIDER_{WORKTYPE} — static fallback
|
|
25
|
+
* 7. Env var AGENT_PROVIDER_{PROJECT} — static fallback
|
|
26
|
+
* 8. Config providers.default — static fallback
|
|
27
|
+
* 9. Env var AGENT_PROVIDER — static fallback
|
|
28
|
+
* 10. Hardcoded 'claude' — ultimate fallback
|
|
17
29
|
*/
|
|
18
30
|
export type { AgentProviderName, AgentProvider, AgentSpawnConfig, AgentHandle, AgentEvent } from './types.js';
|
|
19
31
|
export type { AgentInitEvent, AgentSystemEvent, AgentAssistantTextEvent, AgentToolUseEvent, AgentToolResultEvent, AgentToolProgressEvent, AgentResultEvent, AgentErrorEvent, AgentCostData, } from './types.js';
|
|
@@ -23,6 +35,8 @@ export { AmpProvider, createAmpProvider } from './amp-provider.js';
|
|
|
23
35
|
export { SpringAiProvider, createSpringAiProvider } from './spring-ai-provider.js';
|
|
24
36
|
export { A2aProvider, createA2aProvider } from './a2a-provider.js';
|
|
25
37
|
import type { AgentProvider, AgentProviderName } from './types.js';
|
|
38
|
+
import type { PosteriorStore } from '../routing/posterior-store.js';
|
|
39
|
+
import type { RoutingConfig } from '../routing/types.js';
|
|
26
40
|
/** Provider configuration from .agentfactory/config.yaml */
|
|
27
41
|
export interface ProvidersConfig {
|
|
28
42
|
/** Default provider for all agents */
|
|
@@ -50,6 +64,20 @@ export interface ProviderResolutionResult {
|
|
|
50
64
|
name: AgentProviderName;
|
|
51
65
|
source: string;
|
|
52
66
|
}
|
|
67
|
+
/** Context for MAB-based routing in async provider resolution */
|
|
68
|
+
export interface RoutingContext {
|
|
69
|
+
/** Posterior store instance (from server) for reading MAB posteriors */
|
|
70
|
+
posteriorStore?: PosteriorStore;
|
|
71
|
+
/** Routing configuration (from repo config) */
|
|
72
|
+
routingConfig?: RoutingConfig;
|
|
73
|
+
/** Providers to consider for MAB selection (defaults to all valid providers) */
|
|
74
|
+
availableProviders?: AgentProviderName[];
|
|
75
|
+
}
|
|
76
|
+
/** Extended resolution context for async provider resolution with MAB routing */
|
|
77
|
+
export interface AsyncProviderResolutionContext extends ProviderResolutionContext {
|
|
78
|
+
/** Optional routing context for MAB-based intelligent routing */
|
|
79
|
+
routingContext?: RoutingContext;
|
|
80
|
+
}
|
|
53
81
|
export declare const PROVIDER_ALIASES: Record<string, AgentProviderName>;
|
|
54
82
|
/**
|
|
55
83
|
* Create a provider instance by name.
|
|
@@ -96,5 +124,40 @@ export declare function resolveProviderWithSource(context?: ProviderResolutionCo
|
|
|
96
124
|
* @returns The resolved provider name
|
|
97
125
|
*/
|
|
98
126
|
export declare function resolveProviderName(options?: ProviderResolutionContext): AgentProviderName;
|
|
127
|
+
/**
|
|
128
|
+
* Async version of resolveProviderWithSource() that includes MAB-based
|
|
129
|
+
* intelligent routing as tier 5 in the cascade.
|
|
130
|
+
*
|
|
131
|
+
* Resolution order (highest → lowest):
|
|
132
|
+
* 1. Issue label override (provider:codex) — explicit human override
|
|
133
|
+
* 2. Mention context override ("use codex") — explicit human override
|
|
134
|
+
* 3. Config providers.byWorkType — static config
|
|
135
|
+
* 4. Config providers.byProject — static config
|
|
136
|
+
* 5. MAB-based intelligent routing — learned routing (feature-flagged)
|
|
137
|
+
* 6. Env var AGENT_PROVIDER_{WORKTYPE} — static fallback
|
|
138
|
+
* 7. Env var AGENT_PROVIDER_{PROJECT} — static fallback
|
|
139
|
+
* 8. Config providers.default — static fallback
|
|
140
|
+
* 9. Env var AGENT_PROVIDER — static fallback
|
|
141
|
+
* 10. Hardcoded 'claude' — ultimate fallback
|
|
142
|
+
*
|
|
143
|
+
* MAB routing (tier 5) only activates when:
|
|
144
|
+
* - routingContext.posteriorStore is provided
|
|
145
|
+
* - routingContext.routingConfig?.enabled is true
|
|
146
|
+
* - context.workType is defined
|
|
147
|
+
*
|
|
148
|
+
* If selectProvider() throws or returns low confidence, falls through silently.
|
|
149
|
+
*
|
|
150
|
+
* @param context - Full resolution context including optional routing context
|
|
151
|
+
* @returns The resolved provider name and its source
|
|
152
|
+
*/
|
|
153
|
+
export declare function resolveProviderWithSourceAsync(context?: AsyncProviderResolutionContext): Promise<ProviderResolutionResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Async version of resolveProviderName() that includes MAB-based
|
|
156
|
+
* intelligent routing.
|
|
157
|
+
*
|
|
158
|
+
* @param options - Resolution context including optional routing context
|
|
159
|
+
* @returns The resolved provider name
|
|
160
|
+
*/
|
|
161
|
+
export declare function resolveProviderNameAsync(options?: AsyncProviderResolutionContext): Promise<AgentProviderName>;
|
|
99
162
|
export declare function isValidProviderName(name: string): name is AgentProviderName;
|
|
100
163
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC7G,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAClF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAYxD,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAC9C,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;CAC9C;AAED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BAAmB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,iBAAiB,CAE1F;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC,wBAAwB,CAAC,CA8FnC;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAQD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,iBAAiB,CAE3E"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Creates provider instances based on name.
|
|
5
5
|
* Supports provider selection via env vars, config, labels, and mentions.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Sync resolution order (highest → lowest):
|
|
8
8
|
* 1. Issue label override (provider:codex)
|
|
9
9
|
* 2. Mention context override ("use codex", "@codex")
|
|
10
10
|
* 3. Config providers.byWorkType
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
* 7. Config providers.default
|
|
15
15
|
* 8. Env var AGENT_PROVIDER
|
|
16
16
|
* 9. Hardcoded 'claude'
|
|
17
|
+
*
|
|
18
|
+
* Async resolution order (with MAB routing):
|
|
19
|
+
* 1. Issue label override (provider:codex) — explicit human override
|
|
20
|
+
* 2. Mention context override ("use codex") — explicit human override
|
|
21
|
+
* 3. Config providers.byWorkType — static config
|
|
22
|
+
* 4. Config providers.byProject — static config
|
|
23
|
+
* 5. MAB-based intelligent routing — learned routing (feature-flagged)
|
|
24
|
+
* 6. Env var AGENT_PROVIDER_{WORKTYPE} — static fallback
|
|
25
|
+
* 7. Env var AGENT_PROVIDER_{PROJECT} — static fallback
|
|
26
|
+
* 8. Config providers.default — static fallback
|
|
27
|
+
* 9. Env var AGENT_PROVIDER — static fallback
|
|
28
|
+
* 10. Hardcoded 'claude' — ultimate fallback
|
|
17
29
|
*/
|
|
18
30
|
export { ClaudeProvider, createClaudeProvider } from './claude-provider.js';
|
|
19
31
|
export { CodexProvider, createCodexProvider } from './codex-provider.js';
|
|
@@ -25,6 +37,7 @@ import { CodexProvider } from './codex-provider.js';
|
|
|
25
37
|
import { AmpProvider } from './amp-provider.js';
|
|
26
38
|
import { SpringAiProvider } from './spring-ai-provider.js';
|
|
27
39
|
import { A2aProvider } from './a2a-provider.js';
|
|
40
|
+
import { logger } from '../logger.js';
|
|
28
41
|
// ---------------------------------------------------------------------------
|
|
29
42
|
// Aliases — friendly names that map to real provider names
|
|
30
43
|
// ---------------------------------------------------------------------------
|
|
@@ -200,6 +213,124 @@ export function resolveProviderName(options) {
|
|
|
200
213
|
return resolveProviderWithSource(options).name;
|
|
201
214
|
}
|
|
202
215
|
// ---------------------------------------------------------------------------
|
|
216
|
+
// Async provider resolution (with MAB routing)
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
/**
|
|
219
|
+
* Async version of resolveProviderWithSource() that includes MAB-based
|
|
220
|
+
* intelligent routing as tier 5 in the cascade.
|
|
221
|
+
*
|
|
222
|
+
* Resolution order (highest → lowest):
|
|
223
|
+
* 1. Issue label override (provider:codex) — explicit human override
|
|
224
|
+
* 2. Mention context override ("use codex") — explicit human override
|
|
225
|
+
* 3. Config providers.byWorkType — static config
|
|
226
|
+
* 4. Config providers.byProject — static config
|
|
227
|
+
* 5. MAB-based intelligent routing — learned routing (feature-flagged)
|
|
228
|
+
* 6. Env var AGENT_PROVIDER_{WORKTYPE} — static fallback
|
|
229
|
+
* 7. Env var AGENT_PROVIDER_{PROJECT} — static fallback
|
|
230
|
+
* 8. Config providers.default — static fallback
|
|
231
|
+
* 9. Env var AGENT_PROVIDER — static fallback
|
|
232
|
+
* 10. Hardcoded 'claude' — ultimate fallback
|
|
233
|
+
*
|
|
234
|
+
* MAB routing (tier 5) only activates when:
|
|
235
|
+
* - routingContext.posteriorStore is provided
|
|
236
|
+
* - routingContext.routingConfig?.enabled is true
|
|
237
|
+
* - context.workType is defined
|
|
238
|
+
*
|
|
239
|
+
* If selectProvider() throws or returns low confidence, falls through silently.
|
|
240
|
+
*
|
|
241
|
+
* @param context - Full resolution context including optional routing context
|
|
242
|
+
* @returns The resolved provider name and its source
|
|
243
|
+
*/
|
|
244
|
+
export async function resolveProviderWithSourceAsync(context) {
|
|
245
|
+
// 1. Issue label override
|
|
246
|
+
if (context?.labels?.length) {
|
|
247
|
+
const fromLabel = extractProviderFromLabels(context.labels);
|
|
248
|
+
if (fromLabel) {
|
|
249
|
+
return { name: fromLabel, source: `label provider:${fromLabel}` };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// 2. Mention context override
|
|
253
|
+
if (context?.mentionContext) {
|
|
254
|
+
const fromMention = extractProviderFromMention(context.mentionContext);
|
|
255
|
+
if (fromMention) {
|
|
256
|
+
return { name: fromMention, source: `mention "${context.mentionContext.substring(0, 30)}"` };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// 3. Config byWorkType
|
|
260
|
+
if (context?.workType && context?.configProviders?.byWorkType) {
|
|
261
|
+
const configWorkType = context.configProviders.byWorkType[context.workType];
|
|
262
|
+
if (configWorkType && isValidProviderName(configWorkType)) {
|
|
263
|
+
return { name: configWorkType, source: `config providers.byWorkType.${context.workType}` };
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// 4. Config byProject
|
|
267
|
+
if (context?.project && context?.configProviders?.byProject) {
|
|
268
|
+
const configProject = context.configProviders.byProject[context.project];
|
|
269
|
+
if (configProject && isValidProviderName(configProject)) {
|
|
270
|
+
return { name: configProject, source: `config providers.byProject.${context.project}` };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// 5. MAB-based intelligent routing (feature-flagged)
|
|
274
|
+
if (context?.routingContext?.posteriorStore &&
|
|
275
|
+
context?.routingContext?.routingConfig?.enabled &&
|
|
276
|
+
context?.workType) {
|
|
277
|
+
try {
|
|
278
|
+
const { selectProvider } = await import('../routing/routing-engine.js');
|
|
279
|
+
const availableProviders = context.routingContext.availableProviders ?? VALID_PROVIDER_NAMES;
|
|
280
|
+
const decision = await selectProvider(context.routingContext.posteriorStore, context.workType, availableProviders, context.routingContext.routingConfig);
|
|
281
|
+
// Only use MAB decision if confidence exceeds a meaningful threshold
|
|
282
|
+
// and it's not purely exploratory due to uncertainty
|
|
283
|
+
if (decision.confidence > 0 && decision.explorationReason !== 'uncertainty') {
|
|
284
|
+
return { name: decision.selectedProvider, source: 'mab-routing' };
|
|
285
|
+
}
|
|
286
|
+
// Low confidence or uncertainty-driven exploration — fall through to static fallbacks
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
logger.warn('MAB routing failed, falling through to static fallbacks', {
|
|
290
|
+
error: err instanceof Error ? err.message : String(err),
|
|
291
|
+
workType: context.workType,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// 6. Env var AGENT_PROVIDER_{WORKTYPE}
|
|
296
|
+
if (context?.workType) {
|
|
297
|
+
const workTypeKey = `AGENT_PROVIDER_${context.workType.toUpperCase().replace(/-/g, '_')}`;
|
|
298
|
+
const workTypeProvider = process.env[workTypeKey];
|
|
299
|
+
if (workTypeProvider && isValidProviderName(workTypeProvider)) {
|
|
300
|
+
return { name: workTypeProvider, source: `env ${workTypeKey}` };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// 7. Env var AGENT_PROVIDER_{PROJECT}
|
|
304
|
+
if (context?.project) {
|
|
305
|
+
const projectKey = `AGENT_PROVIDER_${context.project.toUpperCase()}`;
|
|
306
|
+
const projectProvider = process.env[projectKey];
|
|
307
|
+
if (projectProvider && isValidProviderName(projectProvider)) {
|
|
308
|
+
return { name: projectProvider, source: `env ${projectKey}` };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// 8. Config providers.default
|
|
312
|
+
if (context?.configProviders?.default && isValidProviderName(context.configProviders.default)) {
|
|
313
|
+
return { name: context.configProviders.default, source: 'config providers.default' };
|
|
314
|
+
}
|
|
315
|
+
// 9. Env var AGENT_PROVIDER
|
|
316
|
+
const globalProvider = process.env.AGENT_PROVIDER;
|
|
317
|
+
if (globalProvider && isValidProviderName(globalProvider)) {
|
|
318
|
+
return { name: globalProvider, source: 'env AGENT_PROVIDER' };
|
|
319
|
+
}
|
|
320
|
+
// 10. Hardcoded fallback
|
|
321
|
+
return { name: 'claude', source: 'default' };
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Async version of resolveProviderName() that includes MAB-based
|
|
325
|
+
* intelligent routing.
|
|
326
|
+
*
|
|
327
|
+
* @param options - Resolution context including optional routing context
|
|
328
|
+
* @returns The resolved provider name
|
|
329
|
+
*/
|
|
330
|
+
export async function resolveProviderNameAsync(options) {
|
|
331
|
+
return (await resolveProviderWithSourceAsync(options)).name;
|
|
332
|
+
}
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
203
334
|
// Internal helpers
|
|
204
335
|
// ---------------------------------------------------------------------------
|
|
205
336
|
const VALID_PROVIDER_NAMES = ['claude', 'codex', 'amp', 'spring-ai', 'a2a'];
|