oxe-cc 0.9.3 → 1.2.1
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 +1 -1
- package/.cursor/commands/oxe-capabilities.md +1 -1
- package/.cursor/commands/oxe-checkpoint.md +1 -1
- package/.cursor/commands/oxe-compact.md +1 -1
- package/.cursor/commands/oxe-dashboard.md +1 -1
- package/.cursor/commands/oxe-debug.md +1 -1
- package/.cursor/commands/oxe-discuss.md +1 -1
- package/.cursor/commands/oxe-execute.md +2 -2
- package/.cursor/commands/oxe-forensics.md +1 -1
- package/.cursor/commands/oxe-help.md +1 -1
- package/.cursor/commands/oxe-loop.md +1 -1
- package/.cursor/commands/oxe-milestone.md +1 -1
- package/.cursor/commands/oxe-next.md +1 -1
- package/.cursor/commands/oxe-obs.md +1 -1
- package/.cursor/commands/oxe-plan-agent.md +1 -1
- package/.cursor/commands/oxe-plan.md +1 -1
- package/.cursor/commands/oxe-project.md +1 -1
- package/.cursor/commands/oxe-quick.md +1 -1
- package/.cursor/commands/oxe-research.md +1 -1
- package/.cursor/commands/oxe-retro.md +1 -1
- package/.cursor/commands/oxe-review-pr.md +1 -1
- package/.cursor/commands/oxe-route.md +1 -1
- package/.cursor/commands/oxe-scan.md +1 -1
- package/.cursor/commands/oxe-security.md +1 -1
- package/.cursor/commands/oxe-session.md +2 -2
- package/.cursor/commands/oxe-ship.md +45 -0
- package/.cursor/commands/oxe-skill.md +1 -1
- package/.cursor/commands/oxe-spec.md +1 -1
- package/.cursor/commands/oxe-ui-review.md +1 -1
- package/.cursor/commands/oxe-ui-spec.md +1 -1
- package/.cursor/commands/oxe-update.md +1 -1
- package/.cursor/commands/oxe-validate-gaps.md +1 -1
- package/.cursor/commands/oxe-verify.md +1 -1
- package/.cursor/commands/oxe-workstream.md +1 -1
- package/.cursor/commands/oxe.md +4 -4
- package/.github/copilot-instructions.md +91 -1
- package/.github/prompts/oxe-ask.prompt.md +1 -1
- package/.github/prompts/oxe-capabilities.prompt.md +1 -1
- package/.github/prompts/oxe-checkpoint.prompt.md +1 -1
- package/.github/prompts/oxe-compact.prompt.md +1 -1
- package/.github/prompts/oxe-dashboard.prompt.md +1 -1
- package/.github/prompts/oxe-debug.prompt.md +1 -1
- package/.github/prompts/oxe-discuss.prompt.md +1 -1
- package/.github/prompts/oxe-execute.prompt.md +2 -2
- package/.github/prompts/oxe-forensics.prompt.md +1 -1
- package/.github/prompts/oxe-help.prompt.md +1 -1
- package/.github/prompts/oxe-loop.prompt.md +1 -1
- package/.github/prompts/oxe-milestone.prompt.md +1 -1
- package/.github/prompts/oxe-next.prompt.md +1 -1
- package/.github/prompts/oxe-obs.prompt.md +1 -1
- package/.github/prompts/oxe-plan-agent.prompt.md +1 -1
- package/.github/prompts/oxe-plan.prompt.md +1 -1
- package/.github/prompts/oxe-project.prompt.md +1 -1
- package/.github/prompts/oxe-quick.prompt.md +1 -1
- package/.github/prompts/oxe-research.prompt.md +1 -1
- package/.github/prompts/oxe-retro.prompt.md +1 -1
- package/.github/prompts/oxe-review-pr.prompt.md +1 -1
- package/.github/prompts/oxe-route.prompt.md +1 -1
- package/.github/prompts/oxe-scan.prompt.md +1 -1
- package/.github/prompts/oxe-security.prompt.md +1 -1
- package/.github/prompts/oxe-session.prompt.md +2 -2
- package/.github/prompts/oxe-ship.prompt.md +45 -0
- package/.github/prompts/oxe-skill.prompt.md +1 -1
- package/.github/prompts/oxe-spec.prompt.md +1 -1
- package/.github/prompts/oxe-ui-review.prompt.md +1 -1
- package/.github/prompts/oxe-ui-spec.prompt.md +1 -1
- package/.github/prompts/oxe-update.prompt.md +1 -1
- package/.github/prompts/oxe-validate-gaps.prompt.md +1 -1
- package/.github/prompts/oxe-verify.prompt.md +1 -1
- package/.github/prompts/oxe-workstream.prompt.md +1 -1
- package/.github/prompts/oxe.prompt.md +3 -3
- package/AGENTS.md +43 -28
- package/CHANGELOG.md +158 -0
- package/README.md +72 -50
- package/bin/banner.txt +1 -1
- package/bin/lib/oxe-dashboard.cjs +9 -7
- package/bin/lib/oxe-operational.cjs +569 -4
- package/bin/lib/oxe-project-health.cjs +1 -1
- package/bin/oxe-cc.js +141 -57
- package/commands/oxe/ask.md +5 -1
- package/commands/oxe/checkpoint.md +1 -1
- package/commands/oxe/compact.md +1 -1
- package/commands/oxe/debug.md +1 -1
- package/commands/oxe/execute.md +2 -2
- package/commands/oxe/forensics.md +1 -1
- package/commands/oxe/loop.md +1 -1
- package/commands/oxe/milestone.md +1 -1
- package/commands/oxe/next.md +1 -1
- package/commands/oxe/obs.md +1 -1
- package/commands/oxe/oxe.md +3 -3
- package/commands/oxe/project.md +1 -1
- package/commands/oxe/research.md +1 -1
- package/commands/oxe/retro.md +1 -1
- package/commands/oxe/review-pr.md +1 -1
- package/commands/oxe/route.md +1 -1
- package/commands/oxe/scan.md +1 -1
- package/commands/oxe/security.md +1 -1
- package/commands/oxe/session.md +2 -2
- package/commands/oxe/ship.md +49 -0
- package/commands/oxe/spec.md +2 -2
- package/commands/oxe/ui-review.md +1 -1
- package/commands/oxe/ui-spec.md +1 -1
- package/commands/oxe/validate-gaps.md +1 -1
- package/commands/oxe/verify.md +2 -2
- package/commands/oxe/workstream.md +1 -1
- 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/compiler/graph-compiler.d.ts +83 -0
- package/lib/runtime/compiler/graph-compiler.js +135 -0
- package/lib/runtime/compiler/index.d.ts +1 -0
- package/lib/runtime/compiler/index.js +17 -0
- package/lib/runtime/context/context-pack-builder.d.ts +51 -0
- package/lib/runtime/context/context-pack-builder.js +178 -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 +3 -0
- package/lib/runtime/context/index.js +19 -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 +19 -0
- package/lib/runtime/delivery/branch-manager.js +78 -0
- package/lib/runtime/delivery/ci-checks.d.ts +34 -0
- package/lib/runtime/delivery/ci-checks.js +209 -0
- package/lib/runtime/delivery/index.d.ts +4 -0
- package/lib/runtime/delivery/index.js +20 -0
- package/lib/runtime/delivery/pr-manager.d.ts +30 -0
- package/lib/runtime/delivery/pr-manager.js +82 -0
- package/lib/runtime/delivery/promotion-pipeline.d.ts +39 -0
- package/lib/runtime/delivery/promotion-pipeline.js +127 -0
- package/lib/runtime/events/bus.d.ts +9 -0
- package/lib/runtime/events/bus.js +63 -0
- package/lib/runtime/events/catalog.d.ts +3 -0
- package/lib/runtime/events/catalog.js +30 -0
- package/lib/runtime/events/envelope.d.ts +13 -0
- package/lib/runtime/events/envelope.js +2 -0
- package/lib/runtime/events/index.d.ts +3 -0
- package/lib/runtime/events/index.js +19 -0
- package/lib/runtime/evidence/evidence-store.d.ts +22 -0
- package/lib/runtime/evidence/evidence-store.js +106 -0
- package/lib/runtime/evidence/index.d.ts +1 -0
- package/lib/runtime/evidence/index.js +17 -0
- package/lib/runtime/gate/gate-manager.d.ts +39 -0
- package/lib/runtime/gate/gate-manager.js +104 -0
- package/lib/runtime/gate/index.d.ts +1 -0
- package/lib/runtime/gate/index.js +17 -0
- package/lib/runtime/index.d.ts +19 -0
- package/lib/runtime/index.js +44 -0
- package/lib/runtime/models/attempt.d.ts +12 -0
- package/lib/runtime/models/attempt.js +2 -0
- package/lib/runtime/models/evidence.d.ts +9 -0
- package/lib/runtime/models/evidence.js +2 -0
- package/lib/runtime/models/gate-decision.d.ts +10 -0
- package/lib/runtime/models/gate-decision.js +2 -0
- package/lib/runtime/models/index.d.ts +8 -0
- package/lib/runtime/models/index.js +24 -0
- package/lib/runtime/models/run.d.ts +13 -0
- package/lib/runtime/models/run.js +2 -0
- package/lib/runtime/models/session.d.ts +10 -0
- package/lib/runtime/models/session.js +2 -0
- package/lib/runtime/models/verification-result.d.ts +9 -0
- package/lib/runtime/models/verification-result.js +2 -0
- package/lib/runtime/models/work-item.d.ts +15 -0
- package/lib/runtime/models/work-item.js +2 -0
- package/lib/runtime/models/workspace.d.ts +25 -0
- package/lib/runtime/models/workspace.js +2 -0
- package/lib/runtime/plugins/capability-matrix.d.ts +20 -0
- package/lib/runtime/plugins/capability-matrix.js +59 -0
- package/lib/runtime/plugins/index.d.ts +4 -0
- package/lib/runtime/plugins/index.js +20 -0
- package/lib/runtime/plugins/plugin-abi.d.ts +76 -0
- package/lib/runtime/plugins/plugin-abi.js +2 -0
- package/lib/runtime/plugins/plugin-manifest.d.ts +22 -0
- package/lib/runtime/plugins/plugin-manifest.js +91 -0
- package/lib/runtime/plugins/plugin-registry.d.ts +21 -0
- package/lib/runtime/plugins/plugin-registry.js +119 -0
- package/lib/runtime/policy/index.d.ts +1 -0
- package/lib/runtime/policy/index.js +17 -0
- package/lib/runtime/policy/policy-engine.d.ts +67 -0
- package/lib/runtime/policy/policy-engine.js +171 -0
- package/lib/runtime/projection/index.d.ts +1 -0
- package/lib/runtime/projection/index.js +17 -0
- package/lib/runtime/projection/projection-engine.d.ts +11 -0
- package/lib/runtime/projection/projection-engine.js +218 -0
- package/lib/runtime/reducers/debug-reducer.d.ts +10 -0
- package/lib/runtime/reducers/debug-reducer.js +30 -0
- package/lib/runtime/reducers/index.d.ts +2 -0
- package/lib/runtime/reducers/index.js +18 -0
- package/lib/runtime/reducers/run-state-reducer.d.ts +46 -0
- package/lib/runtime/reducers/run-state-reducer.js +226 -0
- 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 +4 -0
- package/lib/runtime/scheduler/index.js +20 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +36 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.js +253 -0
- 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 +49 -0
- package/lib/runtime/scheduler/scheduler.js +324 -0
- package/lib/runtime/verification/index.d.ts +2 -0
- package/lib/runtime/verification/index.js +18 -0
- package/lib/runtime/verification/verification-compiler.d.ts +56 -0
- package/lib/runtime/verification/verification-compiler.js +147 -0
- package/lib/runtime/verification/verification-manifest.d.ts +58 -0
- package/lib/runtime/verification/verification-manifest.js +129 -0
- package/lib/runtime/workspace/index.d.ts +5 -0
- package/lib/runtime/workspace/index.js +24 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +22 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.js +109 -0
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +12 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +79 -0
- package/lib/runtime/workspace/strategies/inplace.d.ts +10 -0
- package/lib/runtime/workspace/strategies/inplace.js +37 -0
- package/lib/runtime/workspace/workspace-manager.d.ts +13 -0
- package/lib/runtime/workspace/workspace-manager.js +2 -0
- package/lib/sdk/index.cjs +24 -7
- package/lib/sdk/index.d.ts +17 -7
- package/oxe/workflows/ask.md +4 -0
- package/oxe/workflows/checkpoint.md +14 -10
- package/oxe/workflows/debug.md +19 -15
- package/oxe/workflows/execute.md +30 -2
- package/oxe/workflows/forensics.md +13 -9
- package/oxe/workflows/help.md +97 -49
- package/oxe/workflows/loop.md +17 -13
- package/oxe/workflows/obs.md +4 -0
- package/oxe/workflows/oxe.md +64 -31
- package/oxe/workflows/project.md +6 -1
- package/oxe/workflows/references/workflow-runtime-contracts.json +23 -0
- 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/scan.md +4 -0
- package/oxe/workflows/security.md +14 -10
- package/oxe/workflows/session.md +17 -1
- package/oxe/workflows/ship.md +142 -0
- 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.md +42 -3
- package/package.json +9 -3
- package/packages/runtime/package.json +17 -0
- 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 -0
- package/packages/runtime/src/compiler/index.ts +1 -0
- package/packages/runtime/src/context/context-pack-builder.ts +259 -0
- 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 -0
- 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 +84 -0
- package/packages/runtime/src/delivery/ci-checks.ts +252 -0
- package/packages/runtime/src/delivery/index.ts +4 -0
- package/packages/runtime/src/delivery/pr-manager.ts +112 -0
- package/packages/runtime/src/delivery/promotion-pipeline.ts +180 -0
- package/packages/runtime/src/events/bus.ts +92 -0
- package/packages/runtime/src/events/catalog.ts +29 -0
- package/packages/runtime/src/events/envelope.ts +14 -0
- package/packages/runtime/src/events/index.ts +3 -0
- package/packages/runtime/src/evidence/evidence-store.ts +130 -0
- package/packages/runtime/src/evidence/index.ts +1 -0
- package/packages/runtime/src/gate/gate-manager.ts +137 -0
- package/packages/runtime/src/gate/index.ts +1 -0
- package/packages/runtime/src/index.ts +37 -0
- package/packages/runtime/src/models/attempt.ts +19 -0
- package/packages/runtime/src/models/evidence.ts +21 -0
- package/packages/runtime/src/models/gate-decision.ts +21 -0
- package/packages/runtime/src/models/index.ts +8 -0
- package/packages/runtime/src/models/run.ts +24 -0
- package/packages/runtime/src/models/session.ts +11 -0
- package/packages/runtime/src/models/verification-result.ts +10 -0
- package/packages/runtime/src/models/work-item.ts +25 -0
- package/packages/runtime/src/models/workspace.ts +28 -0
- package/packages/runtime/src/plugins/capability-matrix.ts +83 -0
- package/packages/runtime/src/plugins/index.ts +4 -0
- package/packages/runtime/src/plugins/plugin-abi.ts +95 -0
- package/packages/runtime/src/plugins/plugin-manifest.ts +113 -0
- package/packages/runtime/src/plugins/plugin-registry.ts +124 -0
- package/packages/runtime/src/policy/index.ts +1 -0
- package/packages/runtime/src/policy/policy-engine.ts +244 -0
- package/packages/runtime/src/projection/index.ts +1 -0
- package/packages/runtime/src/projection/projection-engine.ts +249 -0
- package/packages/runtime/src/reducers/debug-reducer.ts +36 -0
- package/packages/runtime/src/reducers/index.ts +2 -0
- package/packages/runtime/src/reducers/run-state-reducer.ts +269 -0
- 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 -0
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +333 -0
- package/packages/runtime/src/scheduler/run-journal.ts +62 -0
- package/packages/runtime/src/scheduler/scheduler.ts +441 -0
- package/packages/runtime/src/verification/index.ts +2 -0
- package/packages/runtime/src/verification/verification-compiler.ts +225 -0
- package/packages/runtime/src/verification/verification-manifest.ts +192 -0
- package/packages/runtime/src/workspace/index.ts +5 -0
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +121 -0
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +77 -0
- package/packages/runtime/src/workspace/strategies/inplace.ts +35 -0
- package/packages/runtime/src/workspace/workspace-manager.ts +15 -0
- package/packages/runtime/tsconfig.json +17 -0
- package/vscode-extension/oxe-agents-0.9.2.vsix +0 -0
- package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
- package/vscode-extension/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./run-state-reducer"), exports);
|
|
18
|
+
__exportStar(require("./debug-reducer"), exports);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { OxeEvent } from '../events/envelope';
|
|
2
|
+
import type { Run } from '../models/run';
|
|
3
|
+
import type { WorkItem } from '../models/work-item';
|
|
4
|
+
import type { Attempt } from '../models/attempt';
|
|
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
|
+
}
|
|
17
|
+
export interface RunState {
|
|
18
|
+
run: Run | null;
|
|
19
|
+
workItems: Map<string, WorkItem>;
|
|
20
|
+
attempts: Map<string, Attempt[]>;
|
|
21
|
+
workspaces: Map<string, Workspace>;
|
|
22
|
+
completedWorkItems: Set<string>;
|
|
23
|
+
failedWorkItems: Set<string>;
|
|
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[]>;
|
|
35
|
+
}
|
|
36
|
+
export declare function createEmptyRunState(): RunState;
|
|
37
|
+
export declare function reduce(events: OxeEvent[]): RunState;
|
|
38
|
+
export { applyEvent as applyEventExported };
|
|
39
|
+
declare function applyEvent(state: RunState, event: OxeEvent): RunState;
|
|
40
|
+
export declare function getWorkItemStatus(state: RunState, workItemId: string): WorkItem['status'] | null;
|
|
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[];
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEmptyRunState = createEmptyRunState;
|
|
4
|
+
exports.reduce = reduce;
|
|
5
|
+
exports.applyEventExported = applyEvent;
|
|
6
|
+
exports.getWorkItemStatus = getWorkItemStatus;
|
|
7
|
+
exports.getAttemptCount = getAttemptCount;
|
|
8
|
+
exports.getRetryCount = getRetryCount;
|
|
9
|
+
exports.getPolicyDecision = getPolicyDecision;
|
|
10
|
+
exports.getVerificationStatus = getVerificationStatus;
|
|
11
|
+
exports.getEvidenceRefs = getEvidenceRefs;
|
|
12
|
+
exports.getToolFailures = getToolFailures;
|
|
13
|
+
function createEmptyRunState() {
|
|
14
|
+
return {
|
|
15
|
+
run: null,
|
|
16
|
+
workItems: new Map(),
|
|
17
|
+
attempts: new Map(),
|
|
18
|
+
workspaces: new Map(),
|
|
19
|
+
completedWorkItems: new Set(),
|
|
20
|
+
failedWorkItems: new Set(),
|
|
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(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function reduce(events) {
|
|
32
|
+
return events.reduce(applyEvent, createEmptyRunState());
|
|
33
|
+
}
|
|
34
|
+
function applyEvent(state, event) {
|
|
35
|
+
switch (event.type) {
|
|
36
|
+
case 'RunStarted': {
|
|
37
|
+
const run = event.payload;
|
|
38
|
+
return { ...state, run };
|
|
39
|
+
}
|
|
40
|
+
case 'RunCompleted': {
|
|
41
|
+
if (!state.run)
|
|
42
|
+
return state;
|
|
43
|
+
const status = event.payload.status ?? 'completed';
|
|
44
|
+
return {
|
|
45
|
+
...state,
|
|
46
|
+
run: { ...state.run, status, ended_at: event.timestamp },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
case 'WorkItemReady': {
|
|
50
|
+
if (!event.work_item_id)
|
|
51
|
+
return state;
|
|
52
|
+
const workItems = new Map(state.workItems);
|
|
53
|
+
const existing = workItems.get(event.work_item_id);
|
|
54
|
+
if (existing) {
|
|
55
|
+
workItems.set(event.work_item_id, { ...existing, status: 'ready' });
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const item = event.payload;
|
|
59
|
+
workItems.set(event.work_item_id, { ...item, work_item_id: event.work_item_id, status: 'ready' });
|
|
60
|
+
}
|
|
61
|
+
return { ...state, workItems };
|
|
62
|
+
}
|
|
63
|
+
case 'AttemptStarted': {
|
|
64
|
+
if (!event.work_item_id || !event.attempt_id)
|
|
65
|
+
return state;
|
|
66
|
+
const attempts = new Map(state.attempts);
|
|
67
|
+
const attempt = {
|
|
68
|
+
attempt_id: event.attempt_id,
|
|
69
|
+
work_item_id: event.work_item_id,
|
|
70
|
+
attempt_number: event.payload.attempt_number ?? 1,
|
|
71
|
+
workspace_id: null,
|
|
72
|
+
agent_profile: null,
|
|
73
|
+
model: null,
|
|
74
|
+
started_at: event.timestamp,
|
|
75
|
+
ended_at: null,
|
|
76
|
+
outcome: null,
|
|
77
|
+
};
|
|
78
|
+
const existing = attempts.get(event.work_item_id) ?? [];
|
|
79
|
+
attempts.set(event.work_item_id, [...existing, attempt]);
|
|
80
|
+
return { ...state, attempts };
|
|
81
|
+
}
|
|
82
|
+
case 'WorkspaceAllocated': {
|
|
83
|
+
const ws = event.payload;
|
|
84
|
+
if (!ws.workspace_id)
|
|
85
|
+
return state;
|
|
86
|
+
const workspaces = new Map(state.workspaces);
|
|
87
|
+
workspaces.set(ws.workspace_id, { ...ws, status: 'ready' });
|
|
88
|
+
return { ...state, workspaces };
|
|
89
|
+
}
|
|
90
|
+
case 'WorkItemCompleted': {
|
|
91
|
+
if (!event.work_item_id)
|
|
92
|
+
return state;
|
|
93
|
+
const workItems = new Map(state.workItems);
|
|
94
|
+
const item = workItems.get(event.work_item_id);
|
|
95
|
+
if (item)
|
|
96
|
+
workItems.set(event.work_item_id, { ...item, status: 'completed' });
|
|
97
|
+
const completedWorkItems = new Set(state.completedWorkItems);
|
|
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
|
+
}
|
|
107
|
+
return { ...state, workItems, completedWorkItems };
|
|
108
|
+
}
|
|
109
|
+
case 'WorkItemBlocked': {
|
|
110
|
+
if (!event.work_item_id)
|
|
111
|
+
return state;
|
|
112
|
+
const workItems = new Map(state.workItems);
|
|
113
|
+
const item = workItems.get(event.work_item_id);
|
|
114
|
+
if (item)
|
|
115
|
+
workItems.set(event.work_item_id, { ...item, status: 'blocked' });
|
|
116
|
+
const blockedWorkItems = new Set(state.blockedWorkItems);
|
|
117
|
+
blockedWorkItems.add(event.work_item_id);
|
|
118
|
+
return { ...state, workItems, blockedWorkItems };
|
|
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
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
return state;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function getWorkItemStatus(state, workItemId) {
|
|
207
|
+
return state.workItems.get(workItemId)?.status ?? null;
|
|
208
|
+
}
|
|
209
|
+
function getAttemptCount(state, workItemId) {
|
|
210
|
+
return state.attempts.get(workItemId)?.length ?? 0;
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./scheduler"), exports);
|
|
18
|
+
__exportStar(require("./run-journal"), exports);
|
|
19
|
+
__exportStar(require("./agent-registry"), exports);
|
|
20
|
+
__exportStar(require("./agent-roles"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ExecutionGraph } from '../compiler/graph-compiler';
|
|
2
|
+
import type { WorkspaceManager } from '../workspace/workspace-manager';
|
|
3
|
+
import type { TaskExecutor, SchedulerContext } from './scheduler';
|
|
4
|
+
import type { CooperativeHandoff } from './agent-roles';
|
|
5
|
+
export type CoordinationMode = 'parallel' | 'competitive' | 'cooperative';
|
|
6
|
+
export interface AgentSpec {
|
|
7
|
+
id: string;
|
|
8
|
+
executor: TaskExecutor;
|
|
9
|
+
workspaceManager: WorkspaceManager;
|
|
10
|
+
/** Task IDs this agent is responsible for (used in parallel mode) */
|
|
11
|
+
assignedTaskIds?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface CoordinationOptions {
|
|
14
|
+
mode: CoordinationMode;
|
|
15
|
+
agents: AgentSpec[];
|
|
16
|
+
projectRoot: string;
|
|
17
|
+
sessionId: string | null;
|
|
18
|
+
runId: string;
|
|
19
|
+
onEvent?: SchedulerContext['onEvent'];
|
|
20
|
+
}
|
|
21
|
+
export interface CoordinationResult {
|
|
22
|
+
mode: CoordinationMode;
|
|
23
|
+
run_id: string;
|
|
24
|
+
completed: string[];
|
|
25
|
+
failed: string[];
|
|
26
|
+
blocked: string[];
|
|
27
|
+
agent_results: Array<{
|
|
28
|
+
agent_id: string;
|
|
29
|
+
completed: string[];
|
|
30
|
+
failed: string[];
|
|
31
|
+
}>;
|
|
32
|
+
handoffs?: CooperativeHandoff[];
|
|
33
|
+
}
|
|
34
|
+
export declare class MultiAgentCoordinator {
|
|
35
|
+
run(graph: ExecutionGraph, opts: CoordinationOptions): Promise<CoordinationResult>;
|
|
36
|
+
}
|