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,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MultiAgentCoordinator = void 0;
|
|
4
|
+
const bus_1 = require("../events/bus");
|
|
5
|
+
const scheduler_1 = require("./scheduler");
|
|
6
|
+
const agent_roles_1 = require("./agent-roles");
|
|
7
|
+
// ─── Parallel mode ───────────────────────────────────────────────────────────
|
|
8
|
+
// Tasks are partitioned across agents. Each agent runs its own Scheduler
|
|
9
|
+
// on a sub-graph. Results are merged.
|
|
10
|
+
async function runParallel(graph, opts) {
|
|
11
|
+
const { agents, projectRoot, sessionId, runId } = opts;
|
|
12
|
+
// Partition tasks across agents (round-robin if assignedTaskIds not set)
|
|
13
|
+
const partitions = agents.map((a) => a.assignedTaskIds ?? []);
|
|
14
|
+
if (partitions.every((p) => p.length === 0)) {
|
|
15
|
+
const allIds = [...graph.nodes.keys()];
|
|
16
|
+
allIds.forEach((id, i) => {
|
|
17
|
+
partitions[i % agents.length].push(id);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
21
|
+
type: 'RunStarted',
|
|
22
|
+
run_id: runId,
|
|
23
|
+
payload: { mode: 'parallel', agent_count: agents.length },
|
|
24
|
+
});
|
|
25
|
+
const agentResults = await Promise.all(agents.map(async (agent, idx) => {
|
|
26
|
+
const subGraph = subGraphFor(graph, partitions[idx]);
|
|
27
|
+
if (subGraph.nodes.size === 0) {
|
|
28
|
+
return { agent_id: agent.id, completed: [], failed: [] };
|
|
29
|
+
}
|
|
30
|
+
const ctx = {
|
|
31
|
+
projectRoot,
|
|
32
|
+
sessionId,
|
|
33
|
+
runId: `${runId}-agent${idx}`,
|
|
34
|
+
executor: agent.executor,
|
|
35
|
+
workspaceManager: agent.workspaceManager,
|
|
36
|
+
onEvent: opts.onEvent,
|
|
37
|
+
};
|
|
38
|
+
const scheduler = new scheduler_1.Scheduler();
|
|
39
|
+
const result = await scheduler.run(subGraph, ctx);
|
|
40
|
+
return { agent_id: agent.id, completed: result.completed, failed: result.failed };
|
|
41
|
+
}));
|
|
42
|
+
const completed = agentResults.flatMap((r) => r.completed);
|
|
43
|
+
const failed = agentResults.flatMap((r) => r.failed);
|
|
44
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
45
|
+
type: 'RunCompleted',
|
|
46
|
+
run_id: runId,
|
|
47
|
+
payload: { mode: 'parallel', completed: completed.length, failed: failed.length },
|
|
48
|
+
});
|
|
49
|
+
return { mode: 'parallel', run_id: runId, completed, failed, blocked: [], agent_results: agentResults };
|
|
50
|
+
}
|
|
51
|
+
// ─── Competitive mode ────────────────────────────────────────────────────────
|
|
52
|
+
// Two agents attempt the same task. First success wins; the loser's workspace
|
|
53
|
+
// is disposed. Requires exactly 2 agents.
|
|
54
|
+
async function runCompetitive(graph, opts) {
|
|
55
|
+
if (opts.agents.length < 2) {
|
|
56
|
+
throw new Error('Competitive mode requires at least 2 agents');
|
|
57
|
+
}
|
|
58
|
+
const [agentA, agentB] = opts.agents;
|
|
59
|
+
const { projectRoot, sessionId, runId } = opts;
|
|
60
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
61
|
+
type: 'RunStarted',
|
|
62
|
+
run_id: runId,
|
|
63
|
+
payload: { mode: 'competitive' },
|
|
64
|
+
});
|
|
65
|
+
const completed = [];
|
|
66
|
+
const failed = [];
|
|
67
|
+
for (const wave of graph.waves) {
|
|
68
|
+
for (const nodeId of wave.node_ids) {
|
|
69
|
+
const node = graph.nodes.get(nodeId);
|
|
70
|
+
const result = await competeTwoAgents(nodeId, node, agentA, agentB, opts);
|
|
71
|
+
if (result.success)
|
|
72
|
+
completed.push(nodeId);
|
|
73
|
+
else
|
|
74
|
+
failed.push(nodeId);
|
|
75
|
+
if (failed.length > 0)
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
if (failed.length > 0)
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
82
|
+
type: 'RunCompleted',
|
|
83
|
+
run_id: runId,
|
|
84
|
+
payload: { mode: 'competitive', completed: completed.length },
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
mode: 'competitive',
|
|
88
|
+
run_id: runId,
|
|
89
|
+
completed,
|
|
90
|
+
failed,
|
|
91
|
+
blocked: [],
|
|
92
|
+
agent_results: [
|
|
93
|
+
{ agent_id: agentA.id, completed, failed },
|
|
94
|
+
{ agent_id: agentB.id, completed: [], failed: [] },
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function competeTwoAgents(nodeId, node, agentA, agentB, opts) {
|
|
99
|
+
const { projectRoot, sessionId, runId } = opts;
|
|
100
|
+
const allocA = await agentA.workspaceManager.allocate({
|
|
101
|
+
work_item_id: nodeId, attempt_number: 1, strategy: node.workspace_strategy, mutation_scope: node.mutation_scope,
|
|
102
|
+
});
|
|
103
|
+
const allocB = await agentB.workspaceManager.allocate({
|
|
104
|
+
work_item_id: nodeId, attempt_number: 1, strategy: node.workspace_strategy, mutation_scope: node.mutation_scope,
|
|
105
|
+
});
|
|
106
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
107
|
+
type: 'AttemptStarted',
|
|
108
|
+
run_id: runId,
|
|
109
|
+
work_item_id: nodeId,
|
|
110
|
+
payload: { mode: 'competitive', agents: [agentA.id, agentB.id] },
|
|
111
|
+
});
|
|
112
|
+
// Race both agents — first success wins
|
|
113
|
+
const [resultA, resultB] = await Promise.all([
|
|
114
|
+
agentA.executor.execute(node, allocA, runId, 1).catch((e) => ({
|
|
115
|
+
success: false, failure_class: 'env', evidence: [], output: String(e),
|
|
116
|
+
})),
|
|
117
|
+
agentB.executor.execute(node, allocB, runId, 1).catch((e) => ({
|
|
118
|
+
success: false, failure_class: 'env', evidence: [], output: String(e),
|
|
119
|
+
})),
|
|
120
|
+
]);
|
|
121
|
+
// Clean up both workspaces
|
|
122
|
+
await Promise.all([
|
|
123
|
+
agentA.workspaceManager.dispose(allocA.workspace_id).catch(() => { }),
|
|
124
|
+
agentB.workspaceManager.dispose(allocB.workspace_id).catch(() => { }),
|
|
125
|
+
]);
|
|
126
|
+
// Pick winner: prefer success; if both succeed, prefer A (primary agent)
|
|
127
|
+
const winner = resultA.success ? resultA : resultB.success ? resultB : resultA;
|
|
128
|
+
if (winner.success) {
|
|
129
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, { type: 'WorkItemCompleted', run_id: runId, work_item_id: nodeId, payload: { mode: 'competitive' } });
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, { type: 'WorkItemBlocked', run_id: runId, work_item_id: nodeId, payload: { mode: 'competitive', failure_class: winner.failure_class } });
|
|
133
|
+
}
|
|
134
|
+
return winner;
|
|
135
|
+
}
|
|
136
|
+
// ─── Cooperative mode ────────────────────────────────────────────────────────
|
|
137
|
+
// planner (agent[0]) does a dry-run to collect context, then hands off to
|
|
138
|
+
// executor (agent[1]) which performs the real run. Handoffs are recorded.
|
|
139
|
+
async function runCooperative(graph, opts) {
|
|
140
|
+
if (opts.agents.length < 2) {
|
|
141
|
+
throw new Error('Cooperative mode requires at least 2 agents');
|
|
142
|
+
}
|
|
143
|
+
const [planner, executor] = opts.agents;
|
|
144
|
+
const { projectRoot, sessionId, runId } = opts;
|
|
145
|
+
const handoffs = [];
|
|
146
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
147
|
+
type: 'RunStarted',
|
|
148
|
+
run_id: runId,
|
|
149
|
+
payload: { mode: 'cooperative', planner: planner.id, executor: executor.id },
|
|
150
|
+
});
|
|
151
|
+
const completed = [];
|
|
152
|
+
const failed = [];
|
|
153
|
+
for (const wave of graph.waves) {
|
|
154
|
+
for (const nodeId of wave.node_ids) {
|
|
155
|
+
const node = graph.nodes.get(nodeId);
|
|
156
|
+
// Phase 1: planner allocates workspace + signals readiness (no output used)
|
|
157
|
+
const planAlloc = await planner.workspaceManager.allocate({
|
|
158
|
+
work_item_id: nodeId,
|
|
159
|
+
attempt_number: 1,
|
|
160
|
+
strategy: node.workspace_strategy,
|
|
161
|
+
mutation_scope: node.mutation_scope,
|
|
162
|
+
});
|
|
163
|
+
await planner.workspaceManager.dispose(planAlloc.workspace_id).catch(() => { });
|
|
164
|
+
const handoff = (0, agent_roles_1.buildHandoff)({
|
|
165
|
+
from_agent_id: planner.id,
|
|
166
|
+
to_agent_id: executor.id,
|
|
167
|
+
from_role: 'planner',
|
|
168
|
+
to_role: 'executor',
|
|
169
|
+
work_item_id: nodeId,
|
|
170
|
+
context_pack_ref: null,
|
|
171
|
+
});
|
|
172
|
+
handoffs.push(handoff);
|
|
173
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
174
|
+
type: 'AttemptStarted',
|
|
175
|
+
run_id: runId,
|
|
176
|
+
work_item_id: nodeId,
|
|
177
|
+
payload: { mode: 'cooperative', handoff_id: handoff.handoff_id },
|
|
178
|
+
});
|
|
179
|
+
// Phase 2: executor performs the real task
|
|
180
|
+
const execAlloc = await executor.workspaceManager.allocate({
|
|
181
|
+
work_item_id: nodeId,
|
|
182
|
+
attempt_number: 1,
|
|
183
|
+
strategy: node.workspace_strategy,
|
|
184
|
+
mutation_scope: node.mutation_scope,
|
|
185
|
+
});
|
|
186
|
+
let result;
|
|
187
|
+
try {
|
|
188
|
+
result = await executor.executor.execute(node, execAlloc, runId, 1);
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
result = { success: false, failure_class: 'env', evidence: [], output: String(e) };
|
|
192
|
+
}
|
|
193
|
+
await executor.workspaceManager.dispose(execAlloc.workspace_id).catch(() => { });
|
|
194
|
+
if (result.success) {
|
|
195
|
+
completed.push(nodeId);
|
|
196
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, { type: 'WorkItemCompleted', run_id: runId, work_item_id: nodeId, payload: { mode: 'cooperative' } });
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
failed.push(nodeId);
|
|
200
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, { type: 'WorkItemBlocked', run_id: runId, work_item_id: nodeId, payload: { mode: 'cooperative', failure_class: result.failure_class } });
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (failed.length > 0)
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
(0, bus_1.appendEvent)(projectRoot, sessionId, {
|
|
208
|
+
type: 'RunCompleted',
|
|
209
|
+
run_id: runId,
|
|
210
|
+
payload: { mode: 'cooperative', completed: completed.length, failed: failed.length },
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
mode: 'cooperative',
|
|
214
|
+
run_id: runId,
|
|
215
|
+
completed,
|
|
216
|
+
failed,
|
|
217
|
+
blocked: [],
|
|
218
|
+
agent_results: [
|
|
219
|
+
{ agent_id: planner.id, completed: [], failed: [] },
|
|
220
|
+
{ agent_id: executor.id, completed, failed },
|
|
221
|
+
],
|
|
222
|
+
handoffs,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// ─── Public API ──────────────────────────────────────────────────────────────
|
|
226
|
+
class MultiAgentCoordinator {
|
|
227
|
+
async run(graph, opts) {
|
|
228
|
+
switch (opts.mode) {
|
|
229
|
+
case 'parallel': return runParallel(graph, opts);
|
|
230
|
+
case 'competitive': return runCompetitive(graph, opts);
|
|
231
|
+
case 'cooperative': return runCooperative(graph, opts);
|
|
232
|
+
default:
|
|
233
|
+
throw new Error(`Unknown coordination mode: ${opts.mode}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.MultiAgentCoordinator = MultiAgentCoordinator;
|
|
238
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
239
|
+
function subGraphFor(graph, nodeIds) {
|
|
240
|
+
const ids = new Set(nodeIds);
|
|
241
|
+
const nodes = new Map([...graph.nodes].filter(([id]) => ids.has(id)));
|
|
242
|
+
const edges = graph.edges.filter((e) => ids.has(e.from) && ids.has(e.to));
|
|
243
|
+
const waves = graph.waves.map((w) => ({
|
|
244
|
+
wave_number: w.wave_number,
|
|
245
|
+
node_ids: w.node_ids.filter((id) => ids.has(id)),
|
|
246
|
+
})).filter((w) => w.node_ids.length > 0);
|
|
247
|
+
return {
|
|
248
|
+
nodes,
|
|
249
|
+
edges,
|
|
250
|
+
waves,
|
|
251
|
+
metadata: { ...graph.metadata, node_count: nodes.size, wave_count: waves.length },
|
|
252
|
+
};
|
|
253
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RunResult } from './scheduler';
|
|
2
|
+
export interface RunJournal {
|
|
3
|
+
run_id: string;
|
|
4
|
+
paused_at: string | null;
|
|
5
|
+
cancelled: boolean;
|
|
6
|
+
eligible_work_items: string[];
|
|
7
|
+
completed_work_items: string[];
|
|
8
|
+
failed_work_items: string[];
|
|
9
|
+
blocked_work_items: string[];
|
|
10
|
+
pending_gates: string[];
|
|
11
|
+
replay_cursor: string | null;
|
|
12
|
+
scheduler_state: 'running' | 'paused' | 'cancelled' | 'completed';
|
|
13
|
+
partial_result: Omit<RunResult, 'status'> | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function saveJournal(projectRoot: string, runId: string, journal: RunJournal): void;
|
|
16
|
+
export declare function loadJournal(projectRoot: string, runId: string): RunJournal | null;
|
|
17
|
+
export declare function deleteJournal(projectRoot: string, runId: string): void;
|
|
18
|
+
export declare function createJournal(runId: string): RunJournal;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.saveJournal = saveJournal;
|
|
7
|
+
exports.loadJournal = loadJournal;
|
|
8
|
+
exports.deleteJournal = deleteJournal;
|
|
9
|
+
exports.createJournal = createJournal;
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
function journalPath(projectRoot, runId) {
|
|
13
|
+
return path_1.default.join(projectRoot, '.oxe', 'runs', runId, 'journal.json');
|
|
14
|
+
}
|
|
15
|
+
function saveJournal(projectRoot, runId, journal) {
|
|
16
|
+
const p = journalPath(projectRoot, runId);
|
|
17
|
+
fs_1.default.mkdirSync(path_1.default.dirname(p), { recursive: true });
|
|
18
|
+
fs_1.default.writeFileSync(p, JSON.stringify(journal, null, 2), 'utf8');
|
|
19
|
+
}
|
|
20
|
+
function loadJournal(projectRoot, runId) {
|
|
21
|
+
const p = journalPath(projectRoot, runId);
|
|
22
|
+
if (!fs_1.default.existsSync(p))
|
|
23
|
+
return null;
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function deleteJournal(projectRoot, runId) {
|
|
32
|
+
const p = journalPath(projectRoot, runId);
|
|
33
|
+
try {
|
|
34
|
+
fs_1.default.unlinkSync(p);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// ignore if not found
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function createJournal(runId) {
|
|
41
|
+
return {
|
|
42
|
+
run_id: runId,
|
|
43
|
+
paused_at: null,
|
|
44
|
+
cancelled: false,
|
|
45
|
+
eligible_work_items: [],
|
|
46
|
+
completed_work_items: [],
|
|
47
|
+
failed_work_items: [],
|
|
48
|
+
blocked_work_items: [],
|
|
49
|
+
pending_gates: [],
|
|
50
|
+
replay_cursor: null,
|
|
51
|
+
scheduler_state: 'running',
|
|
52
|
+
partial_result: null,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { OxeEvent } from '../events/envelope';
|
|
2
|
+
import type { ExecutionGraph, GraphNode } from '../compiler/graph-compiler';
|
|
3
|
+
import type { WorkspaceManager } from '../workspace/workspace-manager';
|
|
4
|
+
import type { WorkspaceLease } from '../models/workspace';
|
|
5
|
+
import type { RunJournal } from './run-journal';
|
|
6
|
+
export interface TaskResult {
|
|
7
|
+
success: boolean;
|
|
8
|
+
failure_class: 'env' | 'policy' | 'test' | 'timeout' | null;
|
|
9
|
+
evidence: string[];
|
|
10
|
+
output: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TaskExecutor {
|
|
13
|
+
execute(node: GraphNode, lease: WorkspaceLease, runId: string, attemptNumber: number): Promise<TaskResult>;
|
|
14
|
+
}
|
|
15
|
+
export interface SchedulerContext {
|
|
16
|
+
projectRoot: string;
|
|
17
|
+
sessionId: string | null;
|
|
18
|
+
runId: string;
|
|
19
|
+
executor: TaskExecutor;
|
|
20
|
+
workspaceManager: WorkspaceManager;
|
|
21
|
+
onEvent?: (event: OxeEvent) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface RunResult {
|
|
24
|
+
run_id: string;
|
|
25
|
+
status: 'completed' | 'failed' | 'cancelled' | 'paused';
|
|
26
|
+
completed: string[];
|
|
27
|
+
failed: string[];
|
|
28
|
+
blocked: string[];
|
|
29
|
+
}
|
|
30
|
+
export declare class Scheduler {
|
|
31
|
+
private cancelled;
|
|
32
|
+
private paused;
|
|
33
|
+
private journal;
|
|
34
|
+
private ctx;
|
|
35
|
+
run(graph: ExecutionGraph, ctx: SchedulerContext): Promise<RunResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Recover a previously paused run by loading its journal and re-running
|
|
38
|
+
* only the work items that haven't completed yet.
|
|
39
|
+
*/
|
|
40
|
+
recover(runId: string, ctx: SchedulerContext, graph: ExecutionGraph): Promise<RunResult | null>;
|
|
41
|
+
private runWave;
|
|
42
|
+
private runNode;
|
|
43
|
+
pause(): void;
|
|
44
|
+
resume(): void;
|
|
45
|
+
cancel(): void;
|
|
46
|
+
getJournal(): RunJournal | null;
|
|
47
|
+
static loadJournal(projectRoot: string, runId: string): RunJournal | null;
|
|
48
|
+
private emit;
|
|
49
|
+
}
|