agentic-orchestrator 0.1.25 → 0.1.26
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/agentic/orchestrator/defaults/policy.defaults.yaml +1 -0
- package/agentic/orchestrator/policy.yaml +1 -0
- package/agentic/orchestrator/schemas/policy.schema.json +4 -0
- package/agentic/orchestrator/schemas/policy.user.schema.json +4 -0
- package/apps/control-plane/src/application/services/activity-monitor-service.ts +42 -0
- package/apps/control-plane/src/application/services/collision-queue-service.ts +48 -0
- package/apps/control-plane/src/application/services/cost-tracking-service.ts +80 -0
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +57 -0
- package/apps/control-plane/src/application/services/feature-lifecycle-service.ts +65 -0
- package/apps/control-plane/src/application/services/feature-state-service.ts +87 -0
- package/apps/control-plane/src/application/services/gate-selection-service.ts +28 -0
- package/apps/control-plane/src/application/services/gate-service.ts +148 -0
- package/apps/control-plane/src/application/services/issue-tracker-service.ts +28 -0
- package/apps/control-plane/src/application/services/lock-service.ts +88 -0
- package/apps/control-plane/src/application/services/merge-service.ts +63 -0
- package/apps/control-plane/src/application/services/notifier-service.ts +70 -0
- package/apps/control-plane/src/application/services/patch-service.ts +95 -0
- package/apps/control-plane/src/application/services/performance-analytics-service.ts +90 -0
- package/apps/control-plane/src/application/services/plan-service.ts +184 -0
- package/apps/control-plane/src/application/services/pr-monitor-service.ts +58 -0
- package/apps/control-plane/src/application/services/qa-index-service.ts +68 -0
- package/apps/control-plane/src/application/services/reactions-service.ts +77 -0
- package/apps/control-plane/src/application/services/reporting-service.ts +79 -0
- package/apps/control-plane/src/application/services/run-lease-service.ts +79 -0
- package/apps/control-plane/src/application/tools/tool-router.ts +76 -0
- package/apps/control-plane/src/mcp/tool-runtime.ts +4 -0
- package/apps/control-plane/src/providers/providers.ts +96 -0
- package/apps/control-plane/src/providers/worker-provider-factory.ts +4 -0
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +4 -0
- package/apps/control-plane/src/supervisor/planning-wave-executor.ts +4 -0
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +4 -0
- package/apps/control-plane/src/supervisor/run-coordinator.ts +4 -0
- package/apps/control-plane/src/supervisor/runtime.ts +4 -0
- package/apps/control-plane/src/supervisor/session-orchestrator.ts +4 -0
- package/apps/control-plane/test/dashboard-api.integration.spec.ts +310 -1
- package/apps/control-plane/test/dashboard-client.spec.ts +136 -1
- package/apps/control-plane/test/dashboard-live-feed.spec.ts +153 -0
- package/apps/control-plane/test/dashboard-ui-utils.spec.ts +132 -0
- package/apps/control-plane/test/mcp.spec.ts +96 -0
- package/apps/control-plane/test/tool-runtime.spec.ts +68 -0
- package/config/agentic/orchestrator/policy.yaml +1 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.d.ts +42 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.js +42 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/collision-queue-service.d.ts +48 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js +48 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/cost-tracking-service.d.ts +79 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js +76 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +57 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +57 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.d.ts +64 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js +61 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-state-service.d.ts +86 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js +83 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/gate-selection-service.d.ts +28 -0
- package/dist/apps/control-plane/application/services/gate-selection-service.js +28 -0
- package/dist/apps/control-plane/application/services/gate-selection-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/gate-service.d.ts +148 -0
- package/dist/apps/control-plane/application/services/gate-service.js +120 -0
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/issue-tracker-service.d.ts +28 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.js +28 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/lock-service.d.ts +88 -0
- package/dist/apps/control-plane/application/services/lock-service.js +64 -0
- package/dist/apps/control-plane/application/services/lock-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/merge-service.d.ts +62 -0
- package/dist/apps/control-plane/application/services/merge-service.js +59 -0
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/notifier-service.d.ts +70 -0
- package/dist/apps/control-plane/application/services/notifier-service.js +70 -0
- package/dist/apps/control-plane/application/services/notifier-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/patch-service.d.ts +94 -0
- package/dist/apps/control-plane/application/services/patch-service.js +91 -0
- package/dist/apps/control-plane/application/services/patch-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/performance-analytics-service.d.ts +89 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js +86 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/plan-service.d.ts +287 -0
- package/dist/apps/control-plane/application/services/plan-service.js +207 -0
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/pr-monitor-service.d.ts +58 -0
- package/dist/apps/control-plane/application/services/pr-monitor-service.js +58 -0
- package/dist/apps/control-plane/application/services/pr-monitor-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/qa-index-service.d.ts +67 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js +64 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/reactions-service.d.ts +76 -0
- package/dist/apps/control-plane/application/services/reactions-service.js +73 -0
- package/dist/apps/control-plane/application/services/reactions-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/reporting-service.d.ts +78 -0
- package/dist/apps/control-plane/application/services/reporting-service.js +75 -0
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/run-lease-service.d.ts +79 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js +79 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -1
- package/dist/apps/control-plane/application/tools/tool-router.d.ts +76 -0
- package/dist/apps/control-plane/application/tools/tool-router.js +62 -0
- package/dist/apps/control-plane/application/tools/tool-router.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-runtime.d.ts +3 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js +3 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js.map +1 -1
- package/dist/apps/control-plane/providers/providers.d.ts +88 -0
- package/dist/apps/control-plane/providers/providers.js.map +1 -1
- package/dist/apps/control-plane/providers/worker-provider-factory.d.ts +3 -0
- package/dist/apps/control-plane/providers/worker-provider-factory.js.map +1 -1
- package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +3 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/planning-wave-executor.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js +3 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +3 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js +3 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -1
- package/dist/apps/control-plane/supervisor/runtime.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/runtime.js +3 -0
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -1
- package/dist/apps/control-plane/supervisor/session-orchestrator.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js +3 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js.map +1 -1
- package/package.json +1 -1
- package/packages/web-dashboard/src/app/analytics/page.tsx +451 -0
- package/packages/web-dashboard/src/app/api/analytics/route.ts +62 -0
- package/packages/web-dashboard/src/app/api/collisions/route.ts +63 -0
- package/packages/web-dashboard/src/app/api/features/[id]/cost/route.ts +29 -0
- package/packages/web-dashboard/src/app/api/features/[id]/review-brief/route.ts +31 -0
- package/packages/web-dashboard/src/app/api/features/[id]/route.ts +5 -8
- package/packages/web-dashboard/src/app/api/features/[id]/test-index/route.ts +31 -0
- package/packages/web-dashboard/src/app/api/flaky/route.ts +20 -0
- package/packages/web-dashboard/src/app/api/policy/budget/route.ts +31 -0
- package/packages/web-dashboard/src/app/api/run/route.ts +162 -0
- package/packages/web-dashboard/src/app/api/status/route.ts +2 -5
- package/packages/web-dashboard/src/app/feature/[id]/page.tsx +112 -0
- package/packages/web-dashboard/src/app/page.tsx +379 -77
- package/packages/web-dashboard/src/components/agent-pipeline-stepper.tsx +100 -0
- package/packages/web-dashboard/src/components/dependency-chains.tsx +58 -0
- package/packages/web-dashboard/src/components/detail-panel.tsx +215 -5
- package/packages/web-dashboard/src/components/feature-card.tsx +5 -0
- package/packages/web-dashboard/src/components/feature-cost-panel.tsx +66 -0
- package/packages/web-dashboard/src/components/feature-list-view.tsx +336 -0
- package/packages/web-dashboard/src/components/gate-step-drilldown.tsx +92 -0
- package/packages/web-dashboard/src/components/kanban-board.tsx +3 -0
- package/packages/web-dashboard/src/components/live-event-feed.tsx +60 -0
- package/packages/web-dashboard/src/components/lock-resource-map.tsx +73 -0
- package/packages/web-dashboard/src/components/plan-revision-timeline.tsx +55 -0
- package/packages/web-dashboard/src/components/plan-risk-annotations.tsx +63 -0
- package/packages/web-dashboard/src/components/plan-scope-tree.tsx +285 -0
- package/packages/web-dashboard/src/components/qa-coverage-map.tsx +174 -0
- package/packages/web-dashboard/src/components/quick-launch-panel.tsx +70 -0
- package/packages/web-dashboard/src/components/review-brief-panel.tsx +75 -0
- package/packages/web-dashboard/src/components/run-health-panel.tsx +85 -0
- package/packages/web-dashboard/src/components/summary-bar.tsx +59 -2
- package/packages/web-dashboard/src/components/verification-signals.tsx +167 -0
- package/packages/web-dashboard/src/lib/analytics-utils.ts +3 -0
- package/packages/web-dashboard/src/lib/aop-client.ts +510 -11
- package/packages/web-dashboard/src/lib/api-envelope.ts +48 -0
- package/packages/web-dashboard/src/lib/authz-adapter.ts +33 -0
- package/packages/web-dashboard/src/lib/dashboard-utils.ts +304 -0
- package/packages/web-dashboard/src/lib/live-feed.ts +218 -0
- package/packages/web-dashboard/src/lib/policy-reader.ts +22 -0
- package/packages/web-dashboard/src/lib/types.ts +114 -0
- package/packages/web-dashboard/src/styles/dashboard.module.css +341 -1
- package/spec-files/{outstanding → completed}/agentic_orchestrator_dashboard_advanced_ux_spec.md +1 -1
- package/spec-files/outstanding/agentic_orchestrator_evidence_integrity_doctor_spec.md +561 -0
- package/spec-files/outstanding/agentic_orchestrator_kernel_simplification_spec.md +834 -0
- package/spec-files/outstanding/agentic_orchestrator_observability_integrity_diagnostics_spec.md +12 -5
- package/spec-files/outstanding/agentic_orchestrator_observability_replay_spec.md +442 -0
- package/spec-files/progress.md +174 -1
|
@@ -19,6 +19,10 @@ function createCollisionFingerprint(collisions: unknown): string {
|
|
|
19
19
|
return stableHash(JSON.stringify(collisions));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @fileoverview Dashboard and feature summary reporting service.
|
|
24
|
+
*/
|
|
25
|
+
|
|
22
26
|
export interface ReportingServicePort {
|
|
23
27
|
collectAcceptedPlans(excludeFeatureId?: string | null): Promise<AnyRecord[]>;
|
|
24
28
|
getPolicySnapshot(): AnyRecord;
|
|
@@ -31,6 +35,44 @@ export interface ReportingServicePort {
|
|
|
31
35
|
qaTestIndexGet(featureId: string): Promise<{ data: AnyRecord }>;
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Manages dashboard and feature summary generation.
|
|
40
|
+
*
|
|
41
|
+
* ## Responsibilities
|
|
42
|
+
* - Generate report.dashboard with global index snapshot
|
|
43
|
+
* - Generate report.feature_summary with per-feature details
|
|
44
|
+
* - Aggregate cost and PR metadata
|
|
45
|
+
* - Provide gate profile summaries
|
|
46
|
+
*
|
|
47
|
+
* ## Dependencies
|
|
48
|
+
* Depends on {@link ReportingServicePort} for:
|
|
49
|
+
* - Index and state access
|
|
50
|
+
* - Cost and analytics data
|
|
51
|
+
* - PR monitor integration
|
|
52
|
+
* - Collision detection
|
|
53
|
+
*
|
|
54
|
+
* ## Key Methods
|
|
55
|
+
* - `reportDashboard()` - generate global dashboard
|
|
56
|
+
* - `reportFeatureSummary()` - generate per-feature summary
|
|
57
|
+
* - `collisionsScan()` - detect collisions across features
|
|
58
|
+
*
|
|
59
|
+
* ## Error Conditions
|
|
60
|
+
* - FILE_NOT_FOUND - feature state or index missing
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const reportingService = new ReportingService(port);
|
|
65
|
+
* const dashboard = await reportingService.reportDashboard();
|
|
66
|
+
* const summary = await reportingService.reportFeatureSummary('my_feature');
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* ## Dashboard Contents
|
|
70
|
+
* - Active/blocked/merged feature counts
|
|
71
|
+
* - Lock ownership
|
|
72
|
+
* - Runtime session metadata
|
|
73
|
+
* - Cost analytics
|
|
74
|
+
* - PR status (if integrated)
|
|
75
|
+
*/
|
|
34
76
|
export class ReportingService {
|
|
35
77
|
private readonly port: ReportingServicePort;
|
|
36
78
|
|
|
@@ -38,6 +80,17 @@ export class ReportingService {
|
|
|
38
80
|
this.port = port;
|
|
39
81
|
}
|
|
40
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Detects collisions across all accepted plans.
|
|
85
|
+
*
|
|
86
|
+
* @returns Collision matrix with conflicts by feature
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const collisions = await reportingService.collisionsScan();
|
|
91
|
+
* console.log(collisions.data.has_collisions);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
41
94
|
async collisionsScan() {
|
|
42
95
|
const plans = await this.port.collectAcceptedPlans();
|
|
43
96
|
const matrix = [];
|
|
@@ -69,6 +122,18 @@ export class ReportingService {
|
|
|
69
122
|
};
|
|
70
123
|
}
|
|
71
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Generates global orchestration dashboard.
|
|
127
|
+
*
|
|
128
|
+
* @returns Dashboard with active/blocked/merged features, locks, costs, PR metadata
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const dashboard = await reportingService.reportDashboard();
|
|
133
|
+
* console.log(dashboard.data.active);
|
|
134
|
+
* console.log(dashboard.data.locks);
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
72
137
|
async reportDashboard() {
|
|
73
138
|
const index = await this.port.readIndex();
|
|
74
139
|
const featureIds = normalizeSet([
|
|
@@ -120,6 +185,20 @@ export class ReportingService {
|
|
|
120
185
|
};
|
|
121
186
|
}
|
|
122
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Generates per-feature summary report.
|
|
190
|
+
*
|
|
191
|
+
* @param featureId - feature identifier
|
|
192
|
+
* @returns Feature summary with state, diff, evidence, costs, QA index
|
|
193
|
+
* @throws FILE_NOT_FOUND - feature does not exist
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const summary = await reportingService.reportFeatureSummary('my_feature');
|
|
198
|
+
* console.log(summary.data.state);
|
|
199
|
+
* console.log(summary.data.diff);
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
123
202
|
async reportFeatureSummary(featureId: string | null) {
|
|
124
203
|
const state = await this.port.featureStateGet(featureId as unknown as string);
|
|
125
204
|
const bundle = await this.port.repoDiffBundle(featureId as unknown as string);
|
|
@@ -43,6 +43,45 @@ export interface RunLeaseServicePort {
|
|
|
43
43
|
emptyRuntimeSessions(at?: string): RuntimeSessionsSnapshot;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Manages run lease acquisition, renewal, and release.
|
|
48
|
+
*
|
|
49
|
+
* ## Responsibilities
|
|
50
|
+
* - Acquire exclusive run lease for orchestrator instance
|
|
51
|
+
* - Renew lease heartbeat to prevent staleness
|
|
52
|
+
* - Release lease on shutdown
|
|
53
|
+
* - Track orchestrator and feature session assignments
|
|
54
|
+
* - Prune stale session assignments
|
|
55
|
+
*
|
|
56
|
+
* ## Dependencies
|
|
57
|
+
* Depends on {@link RunLeaseServicePort} for:
|
|
58
|
+
* - Run lease file operations
|
|
59
|
+
* - Index operations
|
|
60
|
+
* - Lease TTL configuration
|
|
61
|
+
*
|
|
62
|
+
* ## Key Methods
|
|
63
|
+
* - `acquireRunLease()` - acquire exclusive run lease
|
|
64
|
+
* - `renewRunLease()` - renew lease heartbeat
|
|
65
|
+
* - `releaseRunLease()` - release lease
|
|
66
|
+
* - `updateOrchestratorSession()` - update orchestrator session metadata
|
|
67
|
+
* - `updateFeatureSessionAssignment()` - assign feature to sessions
|
|
68
|
+
* - `pruneFeatureSessionAssignments()` - remove stale assignments
|
|
69
|
+
*
|
|
70
|
+
* ## Error Conditions
|
|
71
|
+
* - RUN_ALREADY_ACTIVE - another instance holds fresh lease
|
|
72
|
+
* - STALE_LEASE - lease expired (can be taken over)
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const leaseService = new RunLeaseService(port);
|
|
77
|
+
* const lease = await leaseService.acquireRunLease({
|
|
78
|
+
* run_id: 'run_123',
|
|
79
|
+
* owner_instance_id: 'instance_abc',
|
|
80
|
+
* takeover_stale: false
|
|
81
|
+
* });
|
|
82
|
+
* await leaseService.renewRunLease(lease.data.run_id, lease.data.owner_instance_id);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
46
85
|
export class RunLeaseService {
|
|
47
86
|
private readonly port: RunLeaseServicePort;
|
|
48
87
|
|
|
@@ -50,6 +89,22 @@ export class RunLeaseService {
|
|
|
50
89
|
this.port = port;
|
|
51
90
|
}
|
|
52
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Acquires exclusive run lease for orchestrator instance.
|
|
94
|
+
*
|
|
95
|
+
* @param input - acquisition parameters (run_id, owner_instance_id, takeover_stale)
|
|
96
|
+
* @returns Lease acquisition result
|
|
97
|
+
* @throws RUN_ALREADY_ACTIVE - another instance holds fresh lease
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const lease = await leaseService.acquireRunLease({
|
|
102
|
+
* run_id: 'run_123',
|
|
103
|
+
* owner_instance_id: 'instance_abc',
|
|
104
|
+
* takeover_stale: false
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
53
108
|
async acquireRunLease(input: AcquireRunLeaseInput): Promise<{
|
|
54
109
|
data: {
|
|
55
110
|
runtime_sessions: RuntimeSessionsSnapshot;
|
|
@@ -152,6 +207,18 @@ export class RunLeaseService {
|
|
|
152
207
|
});
|
|
153
208
|
}
|
|
154
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Renews run lease heartbeat to prevent staleness.
|
|
212
|
+
*
|
|
213
|
+
* @param runId - run identifier
|
|
214
|
+
* @param ownerInstanceId - instance identifier
|
|
215
|
+
* @returns Renewal result
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* await leaseService.renewRunLease('run_123', 'instance_abc');
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
155
222
|
async renewRunLease(
|
|
156
223
|
runId: string,
|
|
157
224
|
ownerInstanceId: string,
|
|
@@ -204,6 +271,18 @@ export class RunLeaseService {
|
|
|
204
271
|
});
|
|
205
272
|
}
|
|
206
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Releases run lease on shutdown.
|
|
276
|
+
*
|
|
277
|
+
* @param runId - run identifier
|
|
278
|
+
* @param ownerInstanceId - instance identifier
|
|
279
|
+
* @returns Release result
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```typescript
|
|
283
|
+
* await leaseService.releaseRunLease('run_123', 'instance_abc');
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
207
286
|
async releaseRunLease(
|
|
208
287
|
runId: string,
|
|
209
288
|
ownerInstanceId: string,
|
|
@@ -1,29 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context provided to tool handlers during execution.
|
|
3
|
+
*
|
|
4
|
+
* Contains actor identity information for authorization and logging.
|
|
5
|
+
*/
|
|
1
6
|
export interface ToolHandlerContext {
|
|
7
|
+
/** Actor type (e.g., 'orchestrator', 'planner', 'builder', 'qa', 'system') */
|
|
2
8
|
actorType: string;
|
|
9
|
+
/** Unique actor identifier (e.g., session ID) */
|
|
3
10
|
actorId: string;
|
|
4
11
|
}
|
|
5
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Tool handler function signature.
|
|
15
|
+
*
|
|
16
|
+
* @param args - tool arguments (validated against input schema)
|
|
17
|
+
* @param context - execution context with actor identity
|
|
18
|
+
* @returns tool response (validated against output schema)
|
|
19
|
+
*/
|
|
6
20
|
export type ToolHandler = (
|
|
7
21
|
args: Record<string, unknown>,
|
|
8
22
|
context: ToolHandlerContext,
|
|
9
23
|
) => Promise<unknown>;
|
|
10
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Registry for tool handlers using Map-based dispatch.
|
|
27
|
+
*
|
|
28
|
+
* ## Purpose
|
|
29
|
+
* Provides O(1) handler lookup without switch statements.
|
|
30
|
+
* Enables dynamic tool registration and metadata-driven routing.
|
|
31
|
+
*
|
|
32
|
+
* ## Usage
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const registry = new ToolHandlerRegistry();
|
|
35
|
+
* registry.register('feature.init', async (args, context) => {
|
|
36
|
+
* return await featureInit(args);
|
|
37
|
+
* });
|
|
38
|
+
* const handler = registry.lookup('feature.init');
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
11
41
|
export class ToolHandlerRegistry {
|
|
12
42
|
private readonly handlers = new Map<string, ToolHandler>();
|
|
13
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Registers a tool handler.
|
|
46
|
+
*
|
|
47
|
+
* @param toolName - tool identifier (e.g., 'feature.init')
|
|
48
|
+
* @param handler - handler function
|
|
49
|
+
*/
|
|
14
50
|
register(toolName: string, handler: ToolHandler): void {
|
|
15
51
|
this.handlers.set(toolName, handler);
|
|
16
52
|
}
|
|
17
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Looks up a tool handler.
|
|
56
|
+
*
|
|
57
|
+
* @param toolName - tool identifier
|
|
58
|
+
* @returns handler function or undefined if not registered
|
|
59
|
+
*/
|
|
18
60
|
lookup(toolName: string): ToolHandler | undefined {
|
|
19
61
|
return this.handlers.get(toolName);
|
|
20
62
|
}
|
|
21
63
|
}
|
|
22
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Routes tool calls to registered handlers.
|
|
67
|
+
*
|
|
68
|
+
* ## Responsibilities
|
|
69
|
+
* - Look up handler in registry
|
|
70
|
+
* - Invoke handler with args and context
|
|
71
|
+
* - Delegate to unknown tool handler if not found
|
|
72
|
+
*
|
|
73
|
+
* ## Error Handling
|
|
74
|
+
* Unknown tools are handled by the provided unknownToolHandler,
|
|
75
|
+
* which typically returns a normalized error response.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const router = new ToolRouter(registry, async (toolName) => {
|
|
80
|
+
* return fail(ERROR_CODES.INVALID_ARGUMENT, `Unknown tool ${toolName}`);
|
|
81
|
+
* });
|
|
82
|
+
* const result = await router.route('feature.init', args, context);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
23
85
|
export class ToolRouter {
|
|
24
86
|
private readonly registry: ToolHandlerRegistry;
|
|
25
87
|
private readonly unknownToolHandler: (toolName: string) => Promise<unknown>;
|
|
26
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new tool router.
|
|
91
|
+
*
|
|
92
|
+
* @param registry - handler registry
|
|
93
|
+
* @param unknownToolHandler - fallback for unknown tools
|
|
94
|
+
*/
|
|
27
95
|
constructor(
|
|
28
96
|
registry: ToolHandlerRegistry,
|
|
29
97
|
unknownToolHandler: (toolName: string) => Promise<unknown>,
|
|
@@ -32,6 +100,14 @@ export class ToolRouter {
|
|
|
32
100
|
this.unknownToolHandler = unknownToolHandler;
|
|
33
101
|
}
|
|
34
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Routes a tool call to the appropriate handler.
|
|
105
|
+
*
|
|
106
|
+
* @param toolName - tool identifier
|
|
107
|
+
* @param args - tool arguments
|
|
108
|
+
* @param context - execution context
|
|
109
|
+
* @returns tool response
|
|
110
|
+
*/
|
|
35
111
|
async route(
|
|
36
112
|
toolName: string,
|
|
37
113
|
args: Record<string, unknown>,
|
|
@@ -78,6 +78,10 @@ function isFailResponse(response: ToolResponse): response is FailResponse {
|
|
|
78
78
|
return response.ok === false;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @fileoverview MCP tool execution runtime with schema validation and authorization.
|
|
83
|
+
*/
|
|
84
|
+
|
|
81
85
|
export class ToolRuntime {
|
|
82
86
|
readonly registry: LoadedToolRegistry;
|
|
83
87
|
readonly loader: ToolRegistryLoader;
|
|
@@ -4,6 +4,10 @@ import { ERROR_CODES } from '../core/error-codes.js';
|
|
|
4
4
|
import { REGISTERED_PROVIDER_NAMES } from '../application/adapters/adapter-registry.js';
|
|
5
5
|
import { PROVIDER_CLI_DEFAULTS, type ProviderCommandTemplate } from './provider-defaults.js';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview Worker provider interfaces and credential resolution.
|
|
9
|
+
*/
|
|
10
|
+
|
|
7
11
|
export interface AppError extends Error {
|
|
8
12
|
code?: string;
|
|
9
13
|
details?: Record<string, unknown>;
|
|
@@ -205,23 +209,90 @@ export const resolveProviderSelection: ProviderSelectionResolver = ({ cli, env,
|
|
|
205
209
|
};
|
|
206
210
|
};
|
|
207
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Worker session metadata.
|
|
214
|
+
*
|
|
215
|
+
* Represents an active agent session with role and feature assignment.
|
|
216
|
+
*/
|
|
208
217
|
export interface WorkerSession {
|
|
218
|
+
/** Unique session identifier */
|
|
209
219
|
session_id: string;
|
|
220
|
+
/** Agent role (orchestrator, planner, builder, qa) */
|
|
210
221
|
role: string;
|
|
222
|
+
/** Feature identifier (empty for orchestrator) */
|
|
211
223
|
feature_id: string;
|
|
224
|
+
/** Whether system prompt was loaded */
|
|
212
225
|
system_prompt_loaded: boolean;
|
|
213
226
|
}
|
|
214
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Worker provider interface for agent session management.
|
|
230
|
+
*
|
|
231
|
+
* ## Contract
|
|
232
|
+
* All providers must implement:
|
|
233
|
+
* - Session lifecycle (create, close, reattach)
|
|
234
|
+
* - Worker execution with tool support
|
|
235
|
+
* - Optional message sending and session attachment
|
|
236
|
+
*
|
|
237
|
+
* ## Session Management
|
|
238
|
+
* - createSession: initialize new agent session with system prompt
|
|
239
|
+
* - closeSession: terminate session and cleanup resources
|
|
240
|
+
* - reattachSession: reconnect to existing session (if supported)
|
|
241
|
+
*
|
|
242
|
+
* ## Worker Execution
|
|
243
|
+
* - runWorker: execute agent with context and instructions
|
|
244
|
+
* - Returns tool calls and text responses
|
|
245
|
+
* - Supports iterative execution with last_tool_results
|
|
246
|
+
*
|
|
247
|
+
* ## Optional Features
|
|
248
|
+
* - sendMessage: send message to active session (interactive mode)
|
|
249
|
+
* - attachToSession: attach to session for real-time interaction
|
|
250
|
+
* - getSessionInfo: query session status
|
|
251
|
+
*
|
|
252
|
+
* @see CliWorkerProvider - CLI-based implementation
|
|
253
|
+
* @see ApiWorkerProvider - API-based implementation
|
|
254
|
+
*/
|
|
215
255
|
export interface WorkerProvider {
|
|
256
|
+
/** Provider mode (live or stub for testing) */
|
|
216
257
|
mode: 'live' | 'stub';
|
|
258
|
+
/** Provider selection (provider, model, credentials) */
|
|
217
259
|
selection: ProviderSelection;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Creates a new agent session.
|
|
263
|
+
*
|
|
264
|
+
* @param role - agent role (orchestrator, planner, builder, qa)
|
|
265
|
+
* @param featureId - feature identifier (empty for orchestrator)
|
|
266
|
+
* @param systemPrompt - role-specific system prompt (null = no prompt)
|
|
267
|
+
* @returns Session metadata
|
|
268
|
+
*/
|
|
218
269
|
createSession(
|
|
219
270
|
role: string,
|
|
220
271
|
featureId: string,
|
|
221
272
|
systemPrompt: string | null,
|
|
222
273
|
): Promise<WorkerSession>;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Reattaches to an existing session.
|
|
277
|
+
*
|
|
278
|
+
* @param sessionId - session identifier
|
|
279
|
+
* @returns Session metadata or null if not found
|
|
280
|
+
*/
|
|
223
281
|
reattachSession(sessionId: string): Promise<WorkerSession | null>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Closes a session and cleans up resources.
|
|
285
|
+
*
|
|
286
|
+
* @param sessionId - session identifier
|
|
287
|
+
*/
|
|
224
288
|
closeSession(sessionId: string): Promise<{ closed: true }>;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Executes worker with context and instructions.
|
|
292
|
+
*
|
|
293
|
+
* @param input - execution input with role, feature, context, instructions
|
|
294
|
+
* @returns Worker output with tool calls and text
|
|
295
|
+
*/
|
|
225
296
|
runWorker(input: {
|
|
226
297
|
role: string;
|
|
227
298
|
feature_id: string;
|
|
@@ -234,11 +305,36 @@ export interface WorkerProvider {
|
|
|
234
305
|
provider_config_ref: string | null;
|
|
235
306
|
};
|
|
236
307
|
}): Promise<Record<string, unknown>>;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Sends a message to an active session (optional).
|
|
311
|
+
*
|
|
312
|
+
* @param sessionId - session identifier
|
|
313
|
+
* @param message - message text
|
|
314
|
+
*/
|
|
237
315
|
sendMessage?(sessionId: string, message: string): Promise<void>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Attaches to a session for interactive mode (optional).
|
|
319
|
+
*
|
|
320
|
+
* @param sessionId - session identifier
|
|
321
|
+
*/
|
|
238
322
|
attachToSession?(sessionId: string): Promise<void>;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Queries session status (optional).
|
|
326
|
+
*
|
|
327
|
+
* @param sessionId - session identifier
|
|
328
|
+
* @returns Session status
|
|
329
|
+
*/
|
|
239
330
|
getSessionInfo?(sessionId: string): Promise<{ active: boolean; provider: string }>;
|
|
240
331
|
}
|
|
241
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Provider capability flags.
|
|
335
|
+
*
|
|
336
|
+
* Indicates which optional features a provider supports.
|
|
337
|
+
*/
|
|
242
338
|
export interface WorkerCapabilities {
|
|
243
339
|
supportsIdleDetection: boolean;
|
|
244
340
|
supportsSpawnDetection: boolean;
|
|
@@ -15,6 +15,10 @@ import {
|
|
|
15
15
|
GenericCliOutputParser,
|
|
16
16
|
} from './output-parsers/index.js';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @fileoverview Worker provider factory for instantiating CLI and API providers.
|
|
20
|
+
*/
|
|
21
|
+
|
|
18
22
|
export type WorkerProviderMode = 'live' | 'stub';
|
|
19
23
|
export type ProviderCommandContext = 'run' | 'resume' | 'send' | 'attach';
|
|
20
24
|
|
|
@@ -71,6 +71,10 @@ const TIMEOUT_RUNTIME_ERROR_CODES = new Set<string>([
|
|
|
71
71
|
ERROR_CODES.PROVIDER_HARD_TIMEOUT,
|
|
72
72
|
]);
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @fileoverview Build phase wave executor.
|
|
76
|
+
*/
|
|
77
|
+
|
|
74
78
|
export class BuildWaveExecutor {
|
|
75
79
|
private readonly toolCaller: SupervisorToolCaller;
|
|
76
80
|
private readonly workerDecisionRunner: WorkerDecisionRunner;
|
|
@@ -139,6 +139,10 @@ const TIMEOUT_RUNTIME_ERROR_CODES = new Set<string>([
|
|
|
139
139
|
ERROR_CODES.PROVIDER_HARD_TIMEOUT,
|
|
140
140
|
]);
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* @fileoverview Planning phase wave executor.
|
|
144
|
+
*/
|
|
145
|
+
|
|
142
146
|
export class PlanningWaveExecutor {
|
|
143
147
|
private readonly toolCaller: SupervisorToolCaller;
|
|
144
148
|
private readonly planGenerator: InitialPlanGenerator;
|
|
@@ -85,6 +85,10 @@ const TIMEOUT_RUNTIME_ERROR_CODES = new Set<string>([
|
|
|
85
85
|
ERROR_CODES.PROVIDER_HARD_TIMEOUT,
|
|
86
86
|
]);
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* @fileoverview QA phase wave executor.
|
|
90
|
+
*/
|
|
91
|
+
|
|
88
92
|
export class QaWaveExecutor {
|
|
89
93
|
private readonly kernel: FeatureOrchestrationPort;
|
|
90
94
|
private readonly provider: WorkerProvider;
|
|
@@ -39,6 +39,10 @@ interface RunCoordinatorDependencies {
|
|
|
39
39
|
issueTracker?: IssueTracker;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @fileoverview Feature queue coordination and status transition detection.
|
|
44
|
+
*/
|
|
45
|
+
|
|
42
46
|
export class RunCoordinator {
|
|
43
47
|
private readonly kernel: FeatureOrchestrationPort & RuntimeStateReader;
|
|
44
48
|
private readonly provider: WorkerProvider;
|
|
@@ -79,6 +79,10 @@ function resolveAdapterName(
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @fileoverview Multi-agent supervisor runtime for orchestrating feature development.
|
|
84
|
+
*/
|
|
85
|
+
|
|
82
86
|
export class SupervisorRuntime
|
|
83
87
|
implements SupervisorToolCaller, AgentPromptProvider, InitialPlanGenerator, FeatureClusterPatcher
|
|
84
88
|
{
|
|
@@ -20,6 +20,10 @@ interface SessionOrchestratorDependencies {
|
|
|
20
20
|
state: SupervisorRuntimeState;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @fileoverview Session lifecycle management for agent clusters.
|
|
25
|
+
*/
|
|
26
|
+
|
|
23
27
|
export class SessionOrchestrator {
|
|
24
28
|
private readonly kernel: SupervisorKernelPort;
|
|
25
29
|
private readonly runtimeStateReader: RuntimeStateReader;
|