oxe-cc 1.0.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/commands/oxe-ask.md +3 -3
- package/.cursor/commands/oxe-capabilities.md +3 -3
- package/.cursor/commands/oxe-checkpoint.md +3 -3
- package/.cursor/commands/oxe-compact.md +3 -3
- package/.cursor/commands/oxe-dashboard.md +3 -3
- package/.cursor/commands/oxe-debug.md +3 -3
- package/.cursor/commands/oxe-discuss.md +3 -3
- package/.cursor/commands/oxe-execute.md +7 -4
- package/.cursor/commands/oxe-forensics.md +3 -3
- package/.cursor/commands/oxe-help.md +3 -3
- package/.cursor/commands/oxe-loop.md +3 -3
- package/.cursor/commands/oxe-milestone.md +3 -3
- package/.cursor/commands/oxe-next.md +3 -3
- package/.cursor/commands/oxe-obs.md +3 -3
- package/.cursor/commands/oxe-plan-agent.md +3 -3
- package/.cursor/commands/oxe-plan.md +3 -3
- package/.cursor/commands/oxe-project.md +3 -3
- package/.cursor/commands/oxe-quick.md +3 -3
- package/.cursor/commands/oxe-research.md +3 -3
- package/.cursor/commands/oxe-retro.md +3 -3
- package/.cursor/commands/oxe-review-pr.md +3 -3
- package/.cursor/commands/oxe-route.md +3 -3
- package/.cursor/commands/oxe-scan.md +3 -3
- package/.cursor/commands/oxe-security.md +3 -3
- package/.cursor/commands/oxe-session.md +4 -4
- package/.cursor/commands/oxe-ship.md +45 -0
- package/.cursor/commands/oxe-skill.md +3 -3
- package/.cursor/commands/oxe-spec.md +3 -3
- package/.cursor/commands/oxe-ui-review.md +3 -3
- package/.cursor/commands/oxe-ui-spec.md +3 -3
- package/.cursor/commands/oxe-update.md +3 -3
- package/.cursor/commands/oxe-validate-gaps.md +3 -3
- package/.cursor/commands/oxe-verify.md +6 -3
- package/.cursor/commands/oxe-workstream.md +3 -3
- package/.cursor/commands/oxe.md +6 -6
- package/.github/copilot-instructions.md +94 -4
- package/.github/prompts/oxe-ask.prompt.md +3 -3
- package/.github/prompts/oxe-capabilities.prompt.md +3 -3
- package/.github/prompts/oxe-checkpoint.prompt.md +3 -3
- package/.github/prompts/oxe-compact.prompt.md +3 -3
- package/.github/prompts/oxe-dashboard.prompt.md +3 -3
- package/.github/prompts/oxe-debug.prompt.md +3 -3
- package/.github/prompts/oxe-discuss.prompt.md +3 -3
- package/.github/prompts/oxe-execute.prompt.md +7 -4
- package/.github/prompts/oxe-forensics.prompt.md +3 -3
- package/.github/prompts/oxe-help.prompt.md +3 -3
- package/.github/prompts/oxe-loop.prompt.md +3 -3
- package/.github/prompts/oxe-milestone.prompt.md +3 -3
- package/.github/prompts/oxe-next.prompt.md +3 -3
- package/.github/prompts/oxe-obs.prompt.md +3 -3
- package/.github/prompts/oxe-plan-agent.prompt.md +3 -3
- package/.github/prompts/oxe-plan.prompt.md +3 -3
- package/.github/prompts/oxe-project.prompt.md +3 -3
- package/.github/prompts/oxe-quick.prompt.md +3 -3
- package/.github/prompts/oxe-research.prompt.md +3 -3
- package/.github/prompts/oxe-retro.prompt.md +3 -3
- package/.github/prompts/oxe-review-pr.prompt.md +3 -3
- package/.github/prompts/oxe-route.prompt.md +3 -3
- package/.github/prompts/oxe-scan.prompt.md +3 -3
- package/.github/prompts/oxe-security.prompt.md +3 -3
- package/.github/prompts/oxe-session.prompt.md +4 -4
- package/.github/prompts/oxe-ship.prompt.md +45 -0
- package/.github/prompts/oxe-skill.prompt.md +3 -3
- package/.github/prompts/oxe-spec.prompt.md +3 -3
- package/.github/prompts/oxe-ui-review.prompt.md +3 -3
- package/.github/prompts/oxe-ui-spec.prompt.md +3 -3
- package/.github/prompts/oxe-update.prompt.md +3 -3
- package/.github/prompts/oxe-validate-gaps.prompt.md +3 -3
- package/.github/prompts/oxe-verify.prompt.md +6 -3
- package/.github/prompts/oxe-workstream.prompt.md +3 -3
- package/.github/prompts/oxe.prompt.md +5 -5
- package/AGENTS.md +43 -28
- package/CHANGELOG.md +193 -0
- package/README.md +610 -529
- package/bin/banner.txt +1 -1
- package/bin/lib/oxe-agent-install.cjs +69 -69
- package/bin/lib/oxe-azure.cjs +1445 -1445
- package/bin/lib/oxe-context-engine.cjs +867 -867
- package/bin/lib/oxe-dashboard.cjs +76 -28
- package/bin/lib/oxe-operational.cjs +2144 -1340
- package/bin/lib/oxe-project-health.cjs +483 -1
- package/bin/lib/oxe-runtime-semantics.cjs +12 -0
- package/bin/oxe-cc.js +554 -152
- package/commands/oxe/ask.md +7 -3
- package/commands/oxe/capabilities.md +2 -2
- package/commands/oxe/checkpoint.md +3 -3
- package/commands/oxe/compact.md +3 -3
- package/commands/oxe/dashboard.md +2 -2
- package/commands/oxe/debug.md +3 -3
- package/commands/oxe/discuss.md +2 -2
- package/commands/oxe/execute.md +7 -4
- package/commands/oxe/forensics.md +3 -3
- package/commands/oxe/help.md +2 -2
- package/commands/oxe/loop.md +3 -3
- package/commands/oxe/milestone.md +3 -3
- package/commands/oxe/next.md +3 -3
- package/commands/oxe/obs.md +3 -3
- package/commands/oxe/oxe.md +5 -5
- package/commands/oxe/plan-agent.md +2 -2
- package/commands/oxe/plan.md +2 -2
- package/commands/oxe/project.md +3 -3
- package/commands/oxe/quick.md +2 -2
- package/commands/oxe/research.md +3 -3
- package/commands/oxe/retro.md +3 -3
- package/commands/oxe/review-pr.md +3 -3
- package/commands/oxe/route.md +3 -3
- package/commands/oxe/scan.md +3 -3
- package/commands/oxe/security.md +3 -3
- package/commands/oxe/session.md +4 -4
- package/commands/oxe/ship.md +49 -0
- package/commands/oxe/skill.md +2 -2
- package/commands/oxe/spec.md +4 -4
- package/commands/oxe/ui-review.md +3 -3
- package/commands/oxe/ui-spec.md +3 -3
- package/commands/oxe/update.md +2 -2
- package/commands/oxe/validate-gaps.md +3 -3
- package/commands/oxe/verify.md +7 -4
- package/commands/oxe/workstream.md +3 -3
- package/lib/runtime/audit/audit-trail.d.ts +71 -0
- package/lib/runtime/audit/audit-trail.js +154 -0
- package/lib/runtime/audit/index.d.ts +2 -0
- package/lib/runtime/audit/index.js +18 -0
- package/lib/runtime/audit/policy-pack.d.ts +15 -0
- package/lib/runtime/audit/policy-pack.js +57 -0
- package/lib/runtime/context/context-pack-builder.d.ts +15 -0
- package/lib/runtime/context/context-pack-builder.js +42 -0
- package/lib/runtime/context/context-pack-store.d.ts +38 -0
- package/lib/runtime/context/context-pack-store.js +142 -0
- package/lib/runtime/context/context-profiles.d.ts +11 -0
- package/lib/runtime/context/context-profiles.js +51 -0
- package/lib/runtime/context/index.d.ts +2 -0
- package/lib/runtime/context/index.js +2 -0
- package/lib/runtime/decision/decision-engine.d.ts +43 -0
- package/lib/runtime/decision/decision-engine.js +127 -0
- package/lib/runtime/decision/decision-memo.d.ts +53 -0
- package/lib/runtime/decision/decision-memo.js +173 -0
- package/lib/runtime/decision/index.d.ts +2 -0
- package/lib/runtime/decision/index.js +18 -0
- package/lib/runtime/delivery/branch-manager.d.ts +1 -0
- package/lib/runtime/delivery/branch-manager.js +7 -0
- package/lib/runtime/delivery/ci-checks.js +34 -1
- package/lib/runtime/delivery/delivery-records.d.ts +34 -0
- package/lib/runtime/delivery/delivery-records.js +48 -0
- package/lib/runtime/delivery/index.d.ts +2 -0
- package/lib/runtime/delivery/index.js +2 -0
- package/lib/runtime/delivery/promotion-pipeline.d.ts +63 -0
- package/lib/runtime/delivery/promotion-pipeline.js +224 -0
- package/lib/runtime/gate/gate-manager.d.ts +41 -0
- package/lib/runtime/gate/gate-manager.js +108 -1
- package/lib/runtime/index.d.ts +5 -2
- package/lib/runtime/index.js +7 -1
- package/lib/runtime/models/gate-decision.d.ts +4 -1
- package/lib/runtime/models/workspace.d.ts +3 -0
- package/lib/runtime/plugins/capability-adapter.d.ts +12 -0
- package/lib/runtime/plugins/capability-adapter.js +204 -0
- package/lib/runtime/plugins/capability-matrix.d.ts +25 -0
- package/lib/runtime/plugins/capability-matrix.js +90 -0
- package/lib/runtime/plugins/index.d.ts +3 -0
- package/lib/runtime/plugins/index.js +3 -0
- package/lib/runtime/plugins/plugin-abi.d.ts +2 -0
- package/lib/runtime/plugins/plugin-manifest.d.ts +22 -0
- package/lib/runtime/plugins/plugin-manifest.js +95 -0
- package/lib/runtime/plugins/plugin-registry.d.ts +46 -0
- package/lib/runtime/plugins/plugin-registry.js +84 -2
- package/lib/runtime/policy/policy-engine.d.ts +47 -1
- package/lib/runtime/policy/policy-engine.js +172 -9
- package/lib/runtime/projection/projection-engine.d.ts +9 -1
- package/lib/runtime/projection/projection-engine.js +73 -3
- package/lib/runtime/reducers/run-state-reducer.d.ts +26 -0
- package/lib/runtime/reducers/run-state-reducer.js +117 -1
- package/lib/runtime/scheduler/agent-registry.d.ts +44 -0
- package/lib/runtime/scheduler/agent-registry.js +96 -0
- package/lib/runtime/scheduler/agent-roles.d.ts +54 -0
- package/lib/runtime/scheduler/agent-roles.js +62 -0
- package/lib/runtime/scheduler/index.d.ts +3 -0
- package/lib/runtime/scheduler/index.js +3 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +45 -1
- package/lib/runtime/scheduler/multi-agent-coordinator.js +234 -35
- package/lib/runtime/scheduler/run-journal.d.ts +18 -0
- package/lib/runtime/scheduler/run-journal.js +54 -0
- package/lib/runtime/scheduler/scheduler.d.ts +29 -1
- package/lib/runtime/scheduler/scheduler.js +387 -14
- package/lib/runtime/verification/index.d.ts +1 -0
- package/lib/runtime/verification/index.js +1 -0
- package/lib/runtime/verification/verification-compiler.d.ts +43 -0
- package/lib/runtime/verification/verification-compiler.js +137 -0
- package/lib/runtime/verification/verification-manifest.d.ts +67 -0
- package/lib/runtime/verification/verification-manifest.js +179 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +1 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.js +4 -0
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +1 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +2 -0
- package/lib/runtime/workspace/strategies/inplace.d.ts +1 -0
- package/lib/runtime/workspace/strategies/inplace.js +2 -0
- package/lib/runtime/workspace/workspace-manager.d.ts +2 -1
- package/lib/sdk/README.md +9 -9
- package/lib/sdk/index.cjs +33 -24
- package/lib/sdk/index.d.ts +149 -14
- package/oxe/templates/ACTIVE-RUN.template.json +32 -32
- package/oxe/templates/CAPABILITIES.template.md +7 -7
- package/oxe/templates/CAPABILITY.template.md +45 -45
- package/oxe/templates/CHECKPOINTS.template.md +7 -7
- package/oxe/templates/EXECUTION-RUNTIME.template.md +68 -68
- package/oxe/templates/HYPOTHESES.template.md +33 -33
- package/oxe/templates/LESSONS-METRICS.template.json +13 -13
- package/oxe/templates/NOTES.template.md +16 -16
- package/oxe/templates/PLAN-REVIEW.template.md +31 -31
- package/oxe/templates/SESSION.template.md +34 -34
- package/oxe/templates/SKILL.template.md +26 -26
- package/oxe/templates/STATE.md +55 -55
- package/oxe/templates/WORKFLOW_AUTHORING.md +18 -18
- package/oxe/workflows/ask.md +96 -92
- package/oxe/workflows/capabilities.md +25 -25
- package/oxe/workflows/checkpoint.md +14 -10
- package/oxe/workflows/dashboard.md +33 -33
- package/oxe/workflows/debug.md +19 -15
- package/oxe/workflows/discuss.md +12 -12
- package/oxe/workflows/execute.md +44 -2
- package/oxe/workflows/forensics.md +13 -9
- package/oxe/workflows/help.md +352 -304
- package/oxe/workflows/loop.md +17 -13
- package/oxe/workflows/next.md +22 -22
- package/oxe/workflows/obs.md +4 -0
- package/oxe/workflows/oxe.md +64 -31
- package/oxe/workflows/plan-agent.md +9 -9
- package/oxe/workflows/project.md +6 -1
- package/oxe/workflows/quick.md +10 -10
- package/oxe/workflows/references/reasoning-discovery.md +28 -28
- package/oxe/workflows/references/reasoning-execution.md +29 -29
- package/oxe/workflows/references/reasoning-planning.md +32 -32
- package/oxe/workflows/references/reasoning-review.md +29 -29
- package/oxe/workflows/references/reasoning-status.md +24 -24
- package/oxe/workflows/references/robustness-elevation.md +295 -295
- package/oxe/workflows/references/workflow-runtime-contracts.json +952 -907
- package/oxe/workflows/research.md +32 -28
- package/oxe/workflows/retro.md +4 -0
- package/oxe/workflows/review-pr.md +15 -11
- package/oxe/workflows/route.md +16 -16
- package/oxe/workflows/scan.md +4 -0
- package/oxe/workflows/security.md +14 -10
- package/oxe/workflows/session.md +213 -197
- package/oxe/workflows/ship.md +142 -0
- package/oxe/workflows/skill.md +44 -44
- package/oxe/workflows/spec.md +15 -0
- package/oxe/workflows/ui-review.md +20 -16
- package/oxe/workflows/ui-spec.md +7 -3
- package/oxe/workflows/validate-gaps.md +13 -9
- package/oxe/workflows/verify-audit.md +73 -73
- package/oxe/workflows/verify.md +52 -3
- package/package.json +92 -92
- package/packages/runtime/package.json +17 -17
- package/packages/runtime/src/audit/audit-trail.ts +243 -0
- package/packages/runtime/src/audit/index.ts +2 -0
- package/packages/runtime/src/audit/policy-pack.ts +62 -0
- package/packages/runtime/src/compiler/graph-compiler.ts +245 -245
- package/packages/runtime/src/compiler/index.ts +1 -1
- package/packages/runtime/src/context/context-pack-builder.ts +259 -193
- package/packages/runtime/src/context/context-pack-store.ts +197 -0
- package/packages/runtime/src/context/context-profiles.ts +60 -0
- package/packages/runtime/src/context/index.ts +3 -1
- package/packages/runtime/src/decision/decision-engine.ts +174 -0
- package/packages/runtime/src/decision/decision-memo.ts +211 -0
- package/packages/runtime/src/decision/index.ts +2 -0
- package/packages/runtime/src/delivery/branch-manager.ts +91 -84
- package/packages/runtime/src/delivery/ci-checks.ts +285 -252
- package/packages/runtime/src/delivery/delivery-records.ts +75 -0
- package/packages/runtime/src/delivery/index.ts +5 -3
- package/packages/runtime/src/delivery/pr-manager.ts +112 -112
- package/packages/runtime/src/delivery/promotion-pipeline.ts +334 -0
- package/packages/runtime/src/events/bus.ts +92 -92
- package/packages/runtime/src/events/catalog.ts +29 -29
- package/packages/runtime/src/events/envelope.ts +14 -14
- package/packages/runtime/src/events/index.ts +3 -3
- package/packages/runtime/src/evidence/evidence-store.ts +130 -130
- package/packages/runtime/src/evidence/index.ts +1 -1
- package/packages/runtime/src/gate/gate-manager.ts +289 -137
- package/packages/runtime/src/gate/index.ts +1 -1
- package/packages/runtime/src/index.ts +41 -32
- package/packages/runtime/src/models/attempt.ts +19 -19
- package/packages/runtime/src/models/evidence.ts +21 -21
- package/packages/runtime/src/models/gate-decision.ts +25 -21
- package/packages/runtime/src/models/index.ts +8 -8
- package/packages/runtime/src/models/run.ts +24 -24
- package/packages/runtime/src/models/session.ts +11 -11
- package/packages/runtime/src/models/verification-result.ts +10 -10
- package/packages/runtime/src/models/work-item.ts +25 -25
- package/packages/runtime/src/models/workspace.ts +31 -28
- package/packages/runtime/src/plugins/capability-adapter.ts +206 -0
- package/packages/runtime/src/plugins/capability-matrix.ts +126 -0
- package/packages/runtime/src/plugins/index.ts +5 -2
- package/packages/runtime/src/plugins/plugin-abi.ts +97 -95
- package/packages/runtime/src/plugins/plugin-manifest.ts +118 -0
- package/packages/runtime/src/plugins/plugin-registry.ts +232 -119
- package/packages/runtime/src/policy/index.ts +1 -1
- package/packages/runtime/src/policy/policy-engine.ts +330 -113
- package/packages/runtime/src/projection/index.ts +1 -1
- package/packages/runtime/src/projection/projection-engine.ts +328 -249
- package/packages/runtime/src/reducers/debug-reducer.ts +36 -36
- package/packages/runtime/src/reducers/index.ts +2 -2
- package/packages/runtime/src/reducers/run-state-reducer.ts +269 -127
- package/packages/runtime/src/scheduler/agent-registry.ts +132 -0
- package/packages/runtime/src/scheduler/agent-roles.ts +109 -0
- package/packages/runtime/src/scheduler/index.ts +4 -1
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +521 -231
- package/packages/runtime/src/scheduler/run-journal.ts +62 -0
- package/packages/runtime/src/scheduler/scheduler.ts +722 -281
- package/packages/runtime/src/verification/index.ts +2 -1
- package/packages/runtime/src/verification/verification-compiler.ts +436 -225
- package/packages/runtime/src/verification/verification-manifest.ts +252 -0
- package/packages/runtime/src/workspace/index.ts +5 -5
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +126 -121
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +79 -77
- package/packages/runtime/src/workspace/strategies/inplace.ts +38 -35
- package/packages/runtime/src/workspace/workspace-manager.ts +16 -15
- package/packages/runtime/tsconfig.json +17 -17
- package/vscode-extension/.vscodeignore +7 -7
- package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
- package/vscode-extension/package.json +185 -185
- package/vscode-extension/src/extension.js +310 -310
- package/vscode-extension/src/shared/contextLoader.js +137 -137
- package/vscode-extension/src/shared/contractBuilder.js +159 -159
- package/vscode-extension/src/shared/stateReader.js +101 -101
|
@@ -66,7 +66,7 @@ class ProjectionEngine {
|
|
|
66
66
|
}
|
|
67
67
|
return lines.join('\n');
|
|
68
68
|
}
|
|
69
|
-
projectVerify(state, results, checkResults) {
|
|
69
|
+
projectVerify(state, results, checkResults, manifest, riskLedger, evidenceCoverage) {
|
|
70
70
|
const run = state.run;
|
|
71
71
|
const lines = [
|
|
72
72
|
'# OXE — Verificação',
|
|
@@ -92,6 +92,33 @@ class ProjectionEngine {
|
|
|
92
92
|
}
|
|
93
93
|
lines.push('');
|
|
94
94
|
}
|
|
95
|
+
if (manifest) {
|
|
96
|
+
lines.push('## Verification Manifest');
|
|
97
|
+
lines.push('');
|
|
98
|
+
lines.push(`- **Checks:** ${manifest.summary.total}`);
|
|
99
|
+
lines.push(`- **Pass:** ${manifest.summary.pass}`);
|
|
100
|
+
lines.push(`- **Fail:** ${manifest.summary.fail}`);
|
|
101
|
+
lines.push(`- **Skip:** ${manifest.summary.skip}`);
|
|
102
|
+
lines.push(`- **Errors:** ${manifest.summary.error}`);
|
|
103
|
+
lines.push(`- **All passed:** ${manifest.summary.all_passed ? 'sim' : 'não'}`);
|
|
104
|
+
lines.push('');
|
|
105
|
+
}
|
|
106
|
+
if (evidenceCoverage) {
|
|
107
|
+
lines.push('## Evidence Coverage');
|
|
108
|
+
lines.push('');
|
|
109
|
+
lines.push(`- **Checks com evidência:** ${evidenceCoverage.checks_with_evidence}/${evidenceCoverage.total_checks}`);
|
|
110
|
+
lines.push(`- **Refs totais:** ${evidenceCoverage.total_evidence_refs}`);
|
|
111
|
+
lines.push(`- **Cobertura:** ${evidenceCoverage.coverage_percent}%`);
|
|
112
|
+
lines.push('');
|
|
113
|
+
}
|
|
114
|
+
if (riskLedger && riskLedger.risks.length > 0) {
|
|
115
|
+
lines.push('## Residual Risks');
|
|
116
|
+
lines.push('');
|
|
117
|
+
for (const risk of riskLedger.risks) {
|
|
118
|
+
lines.push(`- [${risk.severity.toUpperCase()}] ${risk.description}`);
|
|
119
|
+
}
|
|
120
|
+
lines.push('');
|
|
121
|
+
}
|
|
95
122
|
if (checkResults && checkResults.length > 0) {
|
|
96
123
|
lines.push('## Resultados dos checks executados');
|
|
97
124
|
lines.push('');
|
|
@@ -181,11 +208,50 @@ class ProjectionEngine {
|
|
|
181
208
|
return lines.join('\n');
|
|
182
209
|
}
|
|
183
210
|
projectPRSummary(state, graph) {
|
|
211
|
+
return this.projectPromotionSummary(state, graph);
|
|
212
|
+
}
|
|
213
|
+
projectCommitSummary(state, graph) {
|
|
184
214
|
const run = state.run;
|
|
185
215
|
const completed = [...state.completedWorkItems];
|
|
186
216
|
const failed = [...state.failedWorkItems];
|
|
217
|
+
const blocked = [...state.blockedWorkItems];
|
|
187
218
|
const lines = [
|
|
188
|
-
'## Summary',
|
|
219
|
+
'## Commit Summary',
|
|
220
|
+
'',
|
|
221
|
+
`**Run:** \`${run?.run_id ?? '—'}\``,
|
|
222
|
+
`**Status:** ${run?.status ?? '—'}`,
|
|
223
|
+
'',
|
|
224
|
+
'### Included work items',
|
|
225
|
+
'',
|
|
226
|
+
];
|
|
227
|
+
for (const id of completed) {
|
|
228
|
+
const node = graph.nodes.get(id);
|
|
229
|
+
lines.push(`- ✓ ${node?.title ?? id} (\`${id}\`)`);
|
|
230
|
+
}
|
|
231
|
+
if (failed.length || blocked.length) {
|
|
232
|
+
lines.push('');
|
|
233
|
+
lines.push('### Attention points');
|
|
234
|
+
lines.push('');
|
|
235
|
+
for (const id of failed) {
|
|
236
|
+
const node = graph.nodes.get(id);
|
|
237
|
+
lines.push(`- ✗ ${node?.title ?? id} (\`${id}\`)`);
|
|
238
|
+
}
|
|
239
|
+
for (const id of blocked) {
|
|
240
|
+
const node = graph.nodes.get(id);
|
|
241
|
+
lines.push(`- ⊘ ${node?.title ?? id} (\`${id}\`)`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
lines.push('');
|
|
245
|
+
lines.push('Generated by OXE Runtime.');
|
|
246
|
+
return lines.join('\n');
|
|
247
|
+
}
|
|
248
|
+
projectPromotionSummary(state, graph) {
|
|
249
|
+
const run = state.run;
|
|
250
|
+
const completed = [...state.completedWorkItems];
|
|
251
|
+
const failed = [...state.failedWorkItems];
|
|
252
|
+
const blocked = [...state.blockedWorkItems];
|
|
253
|
+
const lines = [
|
|
254
|
+
'## Promotion Summary',
|
|
189
255
|
'',
|
|
190
256
|
];
|
|
191
257
|
if (completed.length > 0) {
|
|
@@ -194,13 +260,17 @@ class ProjectionEngine {
|
|
|
194
260
|
lines.push(`- ✓ ${node?.title ?? id} (\`${id}\`)`);
|
|
195
261
|
}
|
|
196
262
|
}
|
|
197
|
-
if (failed.length > 0) {
|
|
263
|
+
if (failed.length > 0 || blocked.length > 0) {
|
|
198
264
|
lines.push('');
|
|
199
265
|
lines.push('**⚠️ Incomplete tasks:**');
|
|
200
266
|
for (const id of failed) {
|
|
201
267
|
const node = graph.nodes.get(id);
|
|
202
268
|
lines.push(`- ✗ ${node?.title ?? id} (\`${id}\`)`);
|
|
203
269
|
}
|
|
270
|
+
for (const id of blocked) {
|
|
271
|
+
const node = graph.nodes.get(id);
|
|
272
|
+
lines.push(`- ⊘ ${node?.title ?? id} (\`${id}\`)`);
|
|
273
|
+
}
|
|
204
274
|
}
|
|
205
275
|
lines.push('');
|
|
206
276
|
lines.push('## Test plan');
|
|
@@ -3,6 +3,17 @@ import type { Run } from '../models/run';
|
|
|
3
3
|
import type { WorkItem } from '../models/work-item';
|
|
4
4
|
import type { Attempt } from '../models/attempt';
|
|
5
5
|
import type { Workspace } from '../models/workspace';
|
|
6
|
+
export interface PolicyDecisionRecord {
|
|
7
|
+
allowed: boolean;
|
|
8
|
+
gate_required: boolean;
|
|
9
|
+
reason: string;
|
|
10
|
+
rule_id: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolFailureRecord {
|
|
13
|
+
tool: string;
|
|
14
|
+
error: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
}
|
|
6
17
|
export interface RunState {
|
|
7
18
|
run: Run | null;
|
|
8
19
|
workItems: Map<string, WorkItem>;
|
|
@@ -11,6 +22,16 @@ export interface RunState {
|
|
|
11
22
|
completedWorkItems: Set<string>;
|
|
12
23
|
failedWorkItems: Set<string>;
|
|
13
24
|
blockedWorkItems: Set<string>;
|
|
25
|
+
retryCounts: Map<string, number>;
|
|
26
|
+
policyDecisions: Map<string, PolicyDecisionRecord>;
|
|
27
|
+
pendingGates: Set<string>;
|
|
28
|
+
resolvedGates: Map<string, {
|
|
29
|
+
decision: string;
|
|
30
|
+
actor?: string;
|
|
31
|
+
}>;
|
|
32
|
+
verificationStatus: Map<string, 'started' | 'completed' | 'failed'>;
|
|
33
|
+
evidenceRefs: Map<string, string[]>;
|
|
34
|
+
toolFailures: Map<string, ToolFailureRecord[]>;
|
|
14
35
|
}
|
|
15
36
|
export declare function createEmptyRunState(): RunState;
|
|
16
37
|
export declare function reduce(events: OxeEvent[]): RunState;
|
|
@@ -18,3 +39,8 @@ export { applyEvent as applyEventExported };
|
|
|
18
39
|
declare function applyEvent(state: RunState, event: OxeEvent): RunState;
|
|
19
40
|
export declare function getWorkItemStatus(state: RunState, workItemId: string): WorkItem['status'] | null;
|
|
20
41
|
export declare function getAttemptCount(state: RunState, workItemId: string): number;
|
|
42
|
+
export declare function getRetryCount(state: RunState, workItemId: string): number;
|
|
43
|
+
export declare function getPolicyDecision(state: RunState, workItemId: string): PolicyDecisionRecord | null;
|
|
44
|
+
export declare function getVerificationStatus(state: RunState, workItemId: string): 'started' | 'completed' | 'failed' | null;
|
|
45
|
+
export declare function getEvidenceRefs(state: RunState, workItemId: string): string[];
|
|
46
|
+
export declare function getToolFailures(state: RunState, workItemId: string): ToolFailureRecord[];
|
|
@@ -5,6 +5,11 @@ exports.reduce = reduce;
|
|
|
5
5
|
exports.applyEventExported = applyEvent;
|
|
6
6
|
exports.getWorkItemStatus = getWorkItemStatus;
|
|
7
7
|
exports.getAttemptCount = getAttemptCount;
|
|
8
|
+
exports.getRetryCount = getRetryCount;
|
|
9
|
+
exports.getPolicyDecision = getPolicyDecision;
|
|
10
|
+
exports.getVerificationStatus = getVerificationStatus;
|
|
11
|
+
exports.getEvidenceRefs = getEvidenceRefs;
|
|
12
|
+
exports.getToolFailures = getToolFailures;
|
|
8
13
|
function createEmptyRunState() {
|
|
9
14
|
return {
|
|
10
15
|
run: null,
|
|
@@ -14,6 +19,13 @@ function createEmptyRunState() {
|
|
|
14
19
|
completedWorkItems: new Set(),
|
|
15
20
|
failedWorkItems: new Set(),
|
|
16
21
|
blockedWorkItems: new Set(),
|
|
22
|
+
retryCounts: new Map(),
|
|
23
|
+
policyDecisions: new Map(),
|
|
24
|
+
pendingGates: new Set(),
|
|
25
|
+
resolvedGates: new Map(),
|
|
26
|
+
verificationStatus: new Map(),
|
|
27
|
+
evidenceRefs: new Map(),
|
|
28
|
+
toolFailures: new Map(),
|
|
17
29
|
};
|
|
18
30
|
}
|
|
19
31
|
function reduce(events) {
|
|
@@ -43,7 +55,6 @@ function applyEvent(state, event) {
|
|
|
43
55
|
workItems.set(event.work_item_id, { ...existing, status: 'ready' });
|
|
44
56
|
}
|
|
45
57
|
else {
|
|
46
|
-
// First time we see this work item — create from payload
|
|
47
58
|
const item = event.payload;
|
|
48
59
|
workItems.set(event.work_item_id, { ...item, work_item_id: event.work_item_id, status: 'ready' });
|
|
49
60
|
}
|
|
@@ -85,6 +96,14 @@ function applyEvent(state, event) {
|
|
|
85
96
|
workItems.set(event.work_item_id, { ...item, status: 'completed' });
|
|
86
97
|
const completedWorkItems = new Set(state.completedWorkItems);
|
|
87
98
|
completedWorkItems.add(event.work_item_id);
|
|
99
|
+
// Collect evidence refs from payload
|
|
100
|
+
const evidence = event.payload.evidence ?? [];
|
|
101
|
+
if (evidence.length > 0) {
|
|
102
|
+
const evidenceRefs = new Map(state.evidenceRefs);
|
|
103
|
+
const existing = evidenceRefs.get(event.work_item_id) ?? [];
|
|
104
|
+
evidenceRefs.set(event.work_item_id, [...existing, ...evidence]);
|
|
105
|
+
return { ...state, workItems, completedWorkItems, evidenceRefs };
|
|
106
|
+
}
|
|
88
107
|
return { ...state, workItems, completedWorkItems };
|
|
89
108
|
}
|
|
90
109
|
case 'WorkItemBlocked': {
|
|
@@ -98,6 +117,88 @@ function applyEvent(state, event) {
|
|
|
98
117
|
blockedWorkItems.add(event.work_item_id);
|
|
99
118
|
return { ...state, workItems, blockedWorkItems };
|
|
100
119
|
}
|
|
120
|
+
case 'RetryScheduled': {
|
|
121
|
+
if (!event.work_item_id)
|
|
122
|
+
return state;
|
|
123
|
+
const retryCounts = new Map(state.retryCounts);
|
|
124
|
+
const current = retryCounts.get(event.work_item_id) ?? 0;
|
|
125
|
+
retryCounts.set(event.work_item_id, current + 1);
|
|
126
|
+
return { ...state, retryCounts };
|
|
127
|
+
}
|
|
128
|
+
case 'PolicyEvaluated': {
|
|
129
|
+
const p = event.payload;
|
|
130
|
+
const key = p.work_item_id ?? event.work_item_id;
|
|
131
|
+
if (!key)
|
|
132
|
+
return state;
|
|
133
|
+
const policyDecisions = new Map(state.policyDecisions);
|
|
134
|
+
policyDecisions.set(key, {
|
|
135
|
+
allowed: p.allowed ?? true,
|
|
136
|
+
gate_required: p.gate_required ?? false,
|
|
137
|
+
reason: p.reason ?? '',
|
|
138
|
+
rule_id: p.rule_id ?? null,
|
|
139
|
+
});
|
|
140
|
+
return { ...state, policyDecisions };
|
|
141
|
+
}
|
|
142
|
+
case 'GateRequested': {
|
|
143
|
+
const gateId = event.payload.gate_id;
|
|
144
|
+
if (!gateId)
|
|
145
|
+
return state;
|
|
146
|
+
const pendingGates = new Set(state.pendingGates);
|
|
147
|
+
pendingGates.add(gateId);
|
|
148
|
+
return { ...state, pendingGates };
|
|
149
|
+
}
|
|
150
|
+
case 'GateResolved': {
|
|
151
|
+
const p = event.payload;
|
|
152
|
+
if (!p.gate_id)
|
|
153
|
+
return state;
|
|
154
|
+
const pendingGates = new Set(state.pendingGates);
|
|
155
|
+
pendingGates.delete(p.gate_id);
|
|
156
|
+
const resolvedGates = new Map(state.resolvedGates);
|
|
157
|
+
resolvedGates.set(p.gate_id, { decision: p.decision ?? 'approved', actor: p.actor });
|
|
158
|
+
return { ...state, pendingGates, resolvedGates };
|
|
159
|
+
}
|
|
160
|
+
case 'VerificationStarted': {
|
|
161
|
+
const key = event.work_item_id ?? event.payload.work_item_id;
|
|
162
|
+
if (!key)
|
|
163
|
+
return state;
|
|
164
|
+
const verificationStatus = new Map(state.verificationStatus);
|
|
165
|
+
verificationStatus.set(key, 'started');
|
|
166
|
+
return { ...state, verificationStatus };
|
|
167
|
+
}
|
|
168
|
+
case 'VerificationCompleted': {
|
|
169
|
+
const p = event.payload;
|
|
170
|
+
const key = event.work_item_id ?? p.work_item_id;
|
|
171
|
+
if (!key)
|
|
172
|
+
return state;
|
|
173
|
+
const verificationStatus = new Map(state.verificationStatus);
|
|
174
|
+
verificationStatus.set(key, p.status ?? 'completed');
|
|
175
|
+
return { ...state, verificationStatus };
|
|
176
|
+
}
|
|
177
|
+
case 'ToolFailed': {
|
|
178
|
+
if (!event.work_item_id)
|
|
179
|
+
return state;
|
|
180
|
+
const p = event.payload;
|
|
181
|
+
const toolFailures = new Map(state.toolFailures);
|
|
182
|
+
const existing = toolFailures.get(event.work_item_id) ?? [];
|
|
183
|
+
toolFailures.set(event.work_item_id, [
|
|
184
|
+
...existing,
|
|
185
|
+
{ tool: p.tool ?? 'unknown', error: p.error ?? '', timestamp: event.timestamp },
|
|
186
|
+
]);
|
|
187
|
+
return { ...state, toolFailures };
|
|
188
|
+
}
|
|
189
|
+
case 'EvidenceCollected': {
|
|
190
|
+
const p = event.payload;
|
|
191
|
+
const key = event.work_item_id ?? p.work_item_id;
|
|
192
|
+
if (!key)
|
|
193
|
+
return state;
|
|
194
|
+
const refs = p.refs ?? (p.ref ? [p.ref] : []);
|
|
195
|
+
if (refs.length === 0)
|
|
196
|
+
return state;
|
|
197
|
+
const evidenceRefs = new Map(state.evidenceRefs);
|
|
198
|
+
const existing = evidenceRefs.get(key) ?? [];
|
|
199
|
+
evidenceRefs.set(key, [...existing, ...refs]);
|
|
200
|
+
return { ...state, evidenceRefs };
|
|
201
|
+
}
|
|
101
202
|
default:
|
|
102
203
|
return state;
|
|
103
204
|
}
|
|
@@ -108,3 +209,18 @@ function getWorkItemStatus(state, workItemId) {
|
|
|
108
209
|
function getAttemptCount(state, workItemId) {
|
|
109
210
|
return state.attempts.get(workItemId)?.length ?? 0;
|
|
110
211
|
}
|
|
212
|
+
function getRetryCount(state, workItemId) {
|
|
213
|
+
return state.retryCounts.get(workItemId) ?? 0;
|
|
214
|
+
}
|
|
215
|
+
function getPolicyDecision(state, workItemId) {
|
|
216
|
+
return state.policyDecisions.get(workItemId) ?? null;
|
|
217
|
+
}
|
|
218
|
+
function getVerificationStatus(state, workItemId) {
|
|
219
|
+
return state.verificationStatus.get(workItemId) ?? null;
|
|
220
|
+
}
|
|
221
|
+
function getEvidenceRefs(state, workItemId) {
|
|
222
|
+
return state.evidenceRefs.get(workItemId) ?? [];
|
|
223
|
+
}
|
|
224
|
+
function getToolFailures(state, workItemId) {
|
|
225
|
+
return state.toolFailures.get(workItemId) ?? [];
|
|
226
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TaskExecutor } from './scheduler';
|
|
2
|
+
import type { WorkspaceManager } from '../workspace/workspace-manager';
|
|
3
|
+
import type { AgentRole, AgentActionLog } from './agent-roles';
|
|
4
|
+
export type AgentStatus = 'idle' | 'running' | 'paused' | 'failed' | 'timeout';
|
|
5
|
+
export interface AgentHeartbeat {
|
|
6
|
+
agent_id: string;
|
|
7
|
+
last_seen: string;
|
|
8
|
+
current_task: string | null;
|
|
9
|
+
status: AgentStatus;
|
|
10
|
+
}
|
|
11
|
+
export interface RegisteredAgent {
|
|
12
|
+
id: string;
|
|
13
|
+
executor: TaskExecutor;
|
|
14
|
+
workspaceManager: WorkspaceManager;
|
|
15
|
+
assignedTaskIds: string[];
|
|
16
|
+
heartbeat: AgentHeartbeat;
|
|
17
|
+
role?: AgentRole;
|
|
18
|
+
actionLog: AgentActionLog[];
|
|
19
|
+
}
|
|
20
|
+
export declare class AgentRegistry {
|
|
21
|
+
private agents;
|
|
22
|
+
private readonly heartbeatTimeoutMs;
|
|
23
|
+
constructor(heartbeatTimeoutMs?: number);
|
|
24
|
+
register(id: string, executor: TaskExecutor, workspaceManager: WorkspaceManager, assignedTaskIds?: string[], role?: AgentRole): RegisteredAgent;
|
|
25
|
+
unregister(id: string): void;
|
|
26
|
+
beat(id: string, currentTask?: string | null): void;
|
|
27
|
+
setStatus(id: string, status: AgentStatus): void;
|
|
28
|
+
isAlive(id: string): boolean;
|
|
29
|
+
/** Returns agents that haven't sent a heartbeat within the timeout window */
|
|
30
|
+
timedOut(): RegisteredAgent[];
|
|
31
|
+
liveAgents(): RegisteredAgent[];
|
|
32
|
+
get(id: string): RegisteredAgent | null;
|
|
33
|
+
list(): RegisteredAgent[];
|
|
34
|
+
/**
|
|
35
|
+
* Reassign orphaned tasks from timed-out agents to a fallback agent.
|
|
36
|
+
* Returns the list of task IDs that were reassigned.
|
|
37
|
+
*/
|
|
38
|
+
failover(fallbackAgentId: string): string[];
|
|
39
|
+
/** Return all agents assigned to a given role */
|
|
40
|
+
getByRole(role: AgentRole): RegisteredAgent[];
|
|
41
|
+
/** Append an action log entry for a registered agent (no-op if unknown) */
|
|
42
|
+
logAction(agentId: string, log: AgentActionLog): void;
|
|
43
|
+
clear(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentRegistry = void 0;
|
|
4
|
+
class AgentRegistry {
|
|
5
|
+
constructor(heartbeatTimeoutMs = 30000) {
|
|
6
|
+
this.agents = new Map();
|
|
7
|
+
this.heartbeatTimeoutMs = heartbeatTimeoutMs;
|
|
8
|
+
}
|
|
9
|
+
register(id, executor, workspaceManager, assignedTaskIds = [], role) {
|
|
10
|
+
if (this.agents.has(id))
|
|
11
|
+
throw new Error(`Agent "${id}" is already registered`);
|
|
12
|
+
const agent = {
|
|
13
|
+
id,
|
|
14
|
+
executor,
|
|
15
|
+
workspaceManager,
|
|
16
|
+
assignedTaskIds,
|
|
17
|
+
heartbeat: {
|
|
18
|
+
agent_id: id,
|
|
19
|
+
last_seen: new Date().toISOString(),
|
|
20
|
+
current_task: null,
|
|
21
|
+
status: 'idle',
|
|
22
|
+
},
|
|
23
|
+
role,
|
|
24
|
+
actionLog: [],
|
|
25
|
+
};
|
|
26
|
+
this.agents.set(id, agent);
|
|
27
|
+
return agent;
|
|
28
|
+
}
|
|
29
|
+
unregister(id) {
|
|
30
|
+
this.agents.delete(id);
|
|
31
|
+
}
|
|
32
|
+
beat(id, currentTask = null) {
|
|
33
|
+
const agent = this.agents.get(id);
|
|
34
|
+
if (!agent)
|
|
35
|
+
return;
|
|
36
|
+
agent.heartbeat.last_seen = new Date().toISOString();
|
|
37
|
+
agent.heartbeat.current_task = currentTask;
|
|
38
|
+
agent.heartbeat.status = currentTask ? 'running' : 'idle';
|
|
39
|
+
}
|
|
40
|
+
setStatus(id, status) {
|
|
41
|
+
const agent = this.agents.get(id);
|
|
42
|
+
if (agent)
|
|
43
|
+
agent.heartbeat.status = status;
|
|
44
|
+
}
|
|
45
|
+
isAlive(id) {
|
|
46
|
+
const agent = this.agents.get(id);
|
|
47
|
+
if (!agent)
|
|
48
|
+
return false;
|
|
49
|
+
const elapsed = Date.now() - new Date(agent.heartbeat.last_seen).getTime();
|
|
50
|
+
return elapsed < this.heartbeatTimeoutMs;
|
|
51
|
+
}
|
|
52
|
+
/** Returns agents that haven't sent a heartbeat within the timeout window */
|
|
53
|
+
timedOut() {
|
|
54
|
+
return [...this.agents.values()].filter((a) => !this.isAlive(a.id));
|
|
55
|
+
}
|
|
56
|
+
liveAgents() {
|
|
57
|
+
return [...this.agents.values()].filter((a) => this.isAlive(a.id));
|
|
58
|
+
}
|
|
59
|
+
get(id) {
|
|
60
|
+
return this.agents.get(id) ?? null;
|
|
61
|
+
}
|
|
62
|
+
list() {
|
|
63
|
+
return [...this.agents.values()];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Reassign orphaned tasks from timed-out agents to a fallback agent.
|
|
67
|
+
* Returns the list of task IDs that were reassigned.
|
|
68
|
+
*/
|
|
69
|
+
failover(fallbackAgentId) {
|
|
70
|
+
const fallback = this.agents.get(fallbackAgentId);
|
|
71
|
+
if (!fallback)
|
|
72
|
+
throw new Error(`Fallback agent "${fallbackAgentId}" not found`);
|
|
73
|
+
const orphaned = [];
|
|
74
|
+
for (const agent of this.timedOut()) {
|
|
75
|
+
orphaned.push(...agent.assignedTaskIds);
|
|
76
|
+
agent.assignedTaskIds = [];
|
|
77
|
+
agent.heartbeat.status = 'failed';
|
|
78
|
+
}
|
|
79
|
+
fallback.assignedTaskIds = [...fallback.assignedTaskIds, ...orphaned];
|
|
80
|
+
return orphaned;
|
|
81
|
+
}
|
|
82
|
+
/** Return all agents assigned to a given role */
|
|
83
|
+
getByRole(role) {
|
|
84
|
+
return [...this.agents.values()].filter((a) => a.role === role);
|
|
85
|
+
}
|
|
86
|
+
/** Append an action log entry for a registered agent (no-op if unknown) */
|
|
87
|
+
logAction(agentId, log) {
|
|
88
|
+
const agent = this.agents.get(agentId);
|
|
89
|
+
if (agent)
|
|
90
|
+
agent.actionLog.push(log);
|
|
91
|
+
}
|
|
92
|
+
clear() {
|
|
93
|
+
this.agents.clear();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.AgentRegistry = AgentRegistry;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TaskResult } from './scheduler';
|
|
2
|
+
export type AgentRole = 'planner' | 'executor' | 'reviewer' | 'verifier';
|
|
3
|
+
export interface AgentBudget {
|
|
4
|
+
max_tokens: number;
|
|
5
|
+
max_time_ms: number;
|
|
6
|
+
max_retries: number;
|
|
7
|
+
consumed_tokens: number;
|
|
8
|
+
consumed_time_ms: number;
|
|
9
|
+
consumed_retries: number;
|
|
10
|
+
}
|
|
11
|
+
export interface CooperativeHandoff {
|
|
12
|
+
handoff_id: string;
|
|
13
|
+
from_agent_id: string;
|
|
14
|
+
to_agent_id: string;
|
|
15
|
+
from_role: AgentRole;
|
|
16
|
+
to_role: AgentRole;
|
|
17
|
+
work_item_id: string;
|
|
18
|
+
context_pack_ref: string | null;
|
|
19
|
+
transferred_at: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentActionLog {
|
|
22
|
+
agent_id: string;
|
|
23
|
+
role: AgentRole;
|
|
24
|
+
work_item_id: string;
|
|
25
|
+
action: 'execute' | 'verify' | 'review' | 'plan';
|
|
26
|
+
result: 'success' | 'failure';
|
|
27
|
+
duration_ms: number;
|
|
28
|
+
timestamp: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function createBudget(opts?: Partial<Omit<AgentBudget, 'consumed_tokens' | 'consumed_time_ms' | 'consumed_retries'>>): AgentBudget;
|
|
31
|
+
export declare function consumeBudget(budget: AgentBudget, delta: {
|
|
32
|
+
tokens?: number;
|
|
33
|
+
time_ms?: number;
|
|
34
|
+
retries?: number;
|
|
35
|
+
}): AgentBudget;
|
|
36
|
+
export declare function isBudgetExhausted(budget: AgentBudget): boolean;
|
|
37
|
+
export declare function buildHandoff(opts: {
|
|
38
|
+
from_agent_id: string;
|
|
39
|
+
to_agent_id: string;
|
|
40
|
+
from_role: AgentRole;
|
|
41
|
+
to_role: AgentRole;
|
|
42
|
+
work_item_id: string;
|
|
43
|
+
context_pack_ref?: string | null;
|
|
44
|
+
}): CooperativeHandoff;
|
|
45
|
+
export declare class ArbitrationEngine {
|
|
46
|
+
/**
|
|
47
|
+
* Choose the best result from multiple competing agents.
|
|
48
|
+
* Prefers success; among successes prefers more evidence; falls back to first.
|
|
49
|
+
*/
|
|
50
|
+
arbitrate(results: Array<{
|
|
51
|
+
agent_id: string;
|
|
52
|
+
result: TaskResult;
|
|
53
|
+
}>): TaskResult;
|
|
54
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArbitrationEngine = void 0;
|
|
4
|
+
exports.createBudget = createBudget;
|
|
5
|
+
exports.consumeBudget = consumeBudget;
|
|
6
|
+
exports.isBudgetExhausted = isBudgetExhausted;
|
|
7
|
+
exports.buildHandoff = buildHandoff;
|
|
8
|
+
function createBudget(opts = {}) {
|
|
9
|
+
return {
|
|
10
|
+
max_tokens: opts.max_tokens ?? Infinity,
|
|
11
|
+
max_time_ms: opts.max_time_ms ?? Infinity,
|
|
12
|
+
max_retries: opts.max_retries ?? Infinity,
|
|
13
|
+
consumed_tokens: 0,
|
|
14
|
+
consumed_time_ms: 0,
|
|
15
|
+
consumed_retries: 0,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function consumeBudget(budget, delta) {
|
|
19
|
+
return {
|
|
20
|
+
...budget,
|
|
21
|
+
consumed_tokens: budget.consumed_tokens + (delta.tokens ?? 0),
|
|
22
|
+
consumed_time_ms: budget.consumed_time_ms + (delta.time_ms ?? 0),
|
|
23
|
+
consumed_retries: budget.consumed_retries + (delta.retries ?? 0),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function isBudgetExhausted(budget) {
|
|
27
|
+
return (budget.consumed_tokens >= budget.max_tokens ||
|
|
28
|
+
budget.consumed_time_ms >= budget.max_time_ms ||
|
|
29
|
+
budget.consumed_retries >= budget.max_retries);
|
|
30
|
+
}
|
|
31
|
+
function buildHandoff(opts) {
|
|
32
|
+
return {
|
|
33
|
+
handoff_id: `hoff-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
34
|
+
from_agent_id: opts.from_agent_id,
|
|
35
|
+
to_agent_id: opts.to_agent_id,
|
|
36
|
+
from_role: opts.from_role,
|
|
37
|
+
to_role: opts.to_role,
|
|
38
|
+
work_item_id: opts.work_item_id,
|
|
39
|
+
context_pack_ref: opts.context_pack_ref ?? null,
|
|
40
|
+
transferred_at: new Date().toISOString(),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// ─── ArbitrationEngine ────────────────────────────────────────────────────────
|
|
44
|
+
class ArbitrationEngine {
|
|
45
|
+
/**
|
|
46
|
+
* Choose the best result from multiple competing agents.
|
|
47
|
+
* Prefers success; among successes prefers more evidence; falls back to first.
|
|
48
|
+
*/
|
|
49
|
+
arbitrate(results) {
|
|
50
|
+
if (results.length === 0) {
|
|
51
|
+
return { success: false, failure_class: null, evidence: [], output: 'no results to arbitrate' };
|
|
52
|
+
}
|
|
53
|
+
const successes = results.filter((r) => r.result.success);
|
|
54
|
+
if (successes.length === 0) {
|
|
55
|
+
return results[0].result;
|
|
56
|
+
}
|
|
57
|
+
// Among successes, prefer the one with most evidence
|
|
58
|
+
successes.sort((a, b) => b.result.evidence.length - a.result.evidence.length);
|
|
59
|
+
return successes[0].result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ArbitrationEngine = ArbitrationEngine;
|
|
@@ -15,3 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./scheduler"), exports);
|
|
18
|
+
__exportStar(require("./run-journal"), exports);
|
|
19
|
+
__exportStar(require("./agent-registry"), exports);
|
|
20
|
+
__exportStar(require("./agent-roles"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExecutionGraph } from '../compiler/graph-compiler';
|
|
2
2
|
import type { WorkspaceManager } from '../workspace/workspace-manager';
|
|
3
|
-
import type { TaskExecutor, SchedulerContext } from './scheduler';
|
|
3
|
+
import type { TaskExecutor, TaskResult, SchedulerContext } from './scheduler';
|
|
4
|
+
import type { CooperativeHandoff } from './agent-roles';
|
|
4
5
|
export type CoordinationMode = 'parallel' | 'competitive' | 'cooperative';
|
|
5
6
|
export interface AgentSpec {
|
|
6
7
|
id: string;
|
|
@@ -17,6 +18,44 @@ export interface CoordinationOptions {
|
|
|
17
18
|
runId: string;
|
|
18
19
|
onEvent?: SchedulerContext['onEvent'];
|
|
19
20
|
}
|
|
21
|
+
export interface ArbitrationRecord {
|
|
22
|
+
work_item_id: string;
|
|
23
|
+
mode: CoordinationMode;
|
|
24
|
+
winner_agent_id: string | null;
|
|
25
|
+
participant_agent_ids: string[];
|
|
26
|
+
success: boolean;
|
|
27
|
+
failure_class: TaskResult['failure_class'];
|
|
28
|
+
evidence_count: number;
|
|
29
|
+
recorded_at: string;
|
|
30
|
+
}
|
|
31
|
+
export interface MultiAgentOwnership {
|
|
32
|
+
work_item_id: string;
|
|
33
|
+
owner_agent_id: string;
|
|
34
|
+
}
|
|
35
|
+
export interface MultiAgentStatusSnapshot {
|
|
36
|
+
run_id: string;
|
|
37
|
+
mode: CoordinationMode;
|
|
38
|
+
workspace_isolation_required: 'isolated';
|
|
39
|
+
workspace_isolation_enforced: boolean;
|
|
40
|
+
agent_count: number;
|
|
41
|
+
ownership: MultiAgentOwnership[];
|
|
42
|
+
completed: string[];
|
|
43
|
+
failed: string[];
|
|
44
|
+
blocked: string[];
|
|
45
|
+
agent_results: Array<{
|
|
46
|
+
agent_id: string;
|
|
47
|
+
isolation_level: 'shared' | 'isolated';
|
|
48
|
+
assigned_task_ids: string[];
|
|
49
|
+
completed: string[];
|
|
50
|
+
failed: string[];
|
|
51
|
+
}>;
|
|
52
|
+
orphan_reassignments: Array<{
|
|
53
|
+
from_agent_id: string;
|
|
54
|
+
to_agent_id: string;
|
|
55
|
+
work_item_ids: string[];
|
|
56
|
+
}>;
|
|
57
|
+
updated_at: string;
|
|
58
|
+
}
|
|
20
59
|
export interface CoordinationResult {
|
|
21
60
|
mode: CoordinationMode;
|
|
22
61
|
run_id: string;
|
|
@@ -28,7 +67,12 @@ export interface CoordinationResult {
|
|
|
28
67
|
completed: string[];
|
|
29
68
|
failed: string[];
|
|
30
69
|
}>;
|
|
70
|
+
handoffs?: CooperativeHandoff[];
|
|
71
|
+
arbitration_results?: ArbitrationRecord[];
|
|
72
|
+
state?: MultiAgentStatusSnapshot;
|
|
31
73
|
}
|
|
32
74
|
export declare class MultiAgentCoordinator {
|
|
33
75
|
run(graph: ExecutionGraph, opts: CoordinationOptions): Promise<CoordinationResult>;
|
|
34
76
|
}
|
|
77
|
+
export declare function multiAgentStatePath(projectRoot: string, runId: string): string;
|
|
78
|
+
export declare function loadMultiAgentState(projectRoot: string, runId: string): MultiAgentStatusSnapshot | null;
|