@kernlang/agon 0.1.6 → 0.1.7

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.
Files changed (55) hide show
  1. package/dist/{chunk-XWHC6VAH.js → chunk-45YTXJWJ.js} +1 -1
  2. package/dist/chunk-45YTXJWJ.js.map +1 -0
  3. package/dist/{chunk-6IF2AV4Y.js → chunk-6WWOJXG4.js} +104 -47
  4. package/dist/chunk-6WWOJXG4.js.map +1 -0
  5. package/dist/{chunk-3PDYVGRS.js → chunk-AONHRJRW.js} +172 -14
  6. package/dist/chunk-AONHRJRW.js.map +1 -0
  7. package/dist/{chunk-TMNHJOKU.js → chunk-BPKY4OF2.js} +74 -3
  8. package/dist/chunk-BPKY4OF2.js.map +1 -0
  9. package/dist/{chunk-NBV37VMW.js → chunk-I2PMSXJ3.js} +2 -2
  10. package/dist/chunk-I2PMSXJ3.js.map +1 -0
  11. package/dist/{chunk-PUNBDLQO.js → chunk-RKXVKX25.js} +42 -8
  12. package/dist/chunk-RKXVKX25.js.map +1 -0
  13. package/dist/{chunk-HSPQEDHX.js → chunk-SUT2HDOY.js} +1 -1
  14. package/dist/chunk-SUT2HDOY.js.map +1 -0
  15. package/dist/{chunk-7WZ2O5WZ.js → chunk-WDT5NJOA.js} +4 -4
  16. package/dist/chunk-WDT5NJOA.js.map +1 -0
  17. package/dist/{dispatch-S3CR5HKX.js → dispatch-J4RSWLXM.js} +2 -2
  18. package/dist/dispatch-J4RSWLXM.js.map +1 -0
  19. package/dist/{forge-GUOEJ5DJ.js → forge-O2SJ5JIQ.js} +6 -6
  20. package/dist/forge-O2SJ5JIQ.js.map +1 -0
  21. package/dist/index.js +385 -53
  22. package/dist/index.js.map +1 -1
  23. package/dist/mcp/engines/agy.json +43 -0
  24. package/dist/mcp/engines/aider.json +40 -0
  25. package/dist/mcp/engines/claude.json +79 -0
  26. package/dist/mcp/engines/codex.json +77 -0
  27. package/dist/mcp/engines/minimax-coding-plan-minimax-m3.json +27 -0
  28. package/dist/mcp/engines/mistral.json +44 -0
  29. package/dist/mcp/engines/ollama.json +35 -0
  30. package/dist/mcp/engines/opencode.json +55 -0
  31. package/dist/mcp/engines/openrouter.json +54 -0
  32. package/dist/mcp/engines/qwen.json +40 -0
  33. package/dist/mcp/index.js +464 -0
  34. package/dist/mcp/index.js.map +1 -0
  35. package/dist/plan-mode-PFLUPGSY.js +17 -0
  36. package/dist/plan-mode-PFLUPGSY.js.map +1 -0
  37. package/dist/{src-3NWTITZM.js → src-253BUXEF.js} +5 -3
  38. package/dist/src-253BUXEF.js.map +1 -0
  39. package/dist/{update-H3LE4ZSI.js → update-ODAAXWOD.js} +6 -6
  40. package/dist/update-ODAAXWOD.js.map +1 -0
  41. package/package.json +2 -3
  42. package/dist/chunk-3PDYVGRS.js.map +0 -1
  43. package/dist/chunk-6IF2AV4Y.js.map +0 -1
  44. package/dist/chunk-7WZ2O5WZ.js.map +0 -1
  45. package/dist/chunk-HSPQEDHX.js.map +0 -1
  46. package/dist/chunk-NBV37VMW.js.map +0 -1
  47. package/dist/chunk-PUNBDLQO.js.map +0 -1
  48. package/dist/chunk-TMNHJOKU.js.map +0 -1
  49. package/dist/chunk-XWHC6VAH.js.map +0 -1
  50. package/dist/dispatch-S3CR5HKX.js.map +0 -1
  51. package/dist/forge-GUOEJ5DJ.js.map +0 -1
  52. package/dist/plan-mode-35BONR7S.js +0 -17
  53. package/dist/plan-mode-35BONR7S.js.map +0 -1
  54. package/dist/src-3NWTITZM.js.map +0 -1
  55. package/dist/update-H3LE4ZSI.js.map +0 -1
@@ -0,0 +1,464 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ appendEvent,
4
+ createRoom,
5
+ defaultFinalizeOnScoreForTask,
6
+ isRoomClosed,
7
+ listPresence,
8
+ listRooms,
9
+ parseMentions,
10
+ readEvents,
11
+ recordPresence,
12
+ removePresence,
13
+ roomExists,
14
+ slugifyRoomId
15
+ } from "../chunk-BPKY4OF2.js";
16
+ import "../chunk-45YTXJWJ.js";
17
+
18
+ // ../mcp/src/generated/agon-orchestration.ts
19
+ import { writeFileSync, readFileSync, mkdirSync, existsSync, unlinkSync } from "fs";
20
+ import { join, dirname } from "path";
21
+ import { createInterface } from "readline";
22
+ import { execSync, spawnSync } from "child_process";
23
+
24
+ // ../mcp/src/generated/rooms.ts
25
+ import { basename } from "path";
26
+ var ROOM_TOOLS = [
27
+ { name: "RoomJoin", description: "Join a shared Agon room (created if new) to chat with other live CLIs/agents over one persistent transcript. Returns the recent transcript so you have context. Human-mediated: post when prompted.", inputSchema: { type: "object", properties: { room: { type: "string", description: "Room name or id" }, callsign: { type: "string", description: "Your handle in the room, e.g. codex, claude" }, engine: { type: "string", description: "Optional engine/CLI id (codex | claude | agy | agon); identifies you in presence. Defaults to mcp." } }, required: ["room", "callsign"] } },
28
+ { name: "RoomPost", description: "Post a message to a room. Use @callsign to mention someone. Returns the assigned sequence number.", inputSchema: { type: "object", properties: { room: { type: "string", description: "Room name or id" }, callsign: { type: "string", description: "Your handle in the room" }, text: { type: "string", description: "Message text (use @callsign to mention)" }, engine: { type: "string", description: "Optional engine/CLI id (codex | claude | agy | agon); identifies you in presence. Defaults to mcp." } }, required: ["room", "callsign", "text"] } },
29
+ { name: "RoomRead", description: "Read a room transcript as JSON events after `since` (0 = all). Poll this with the last seq you saw to follow the room \u2014 MCP has no live stream.", inputSchema: { type: "object", properties: { room: { type: "string", description: "Room name or id" }, since: { type: "number", description: "Only events with seq greater than this (default 0)" }, limit: { type: "number", description: "Max events to return (default 50)" } }, required: ["room"] } },
30
+ { name: "RoomWho", description: "List who is present in a room (here / stale / left).", inputSchema: { type: "object", properties: { room: { type: "string", description: "Room name or id" } }, required: ["room"] } },
31
+ { name: "RoomLeave", description: "Leave a room \u2014 clears your presence immediately instead of waiting for the TTL.", inputSchema: { type: "object", properties: { room: { type: "string", description: "Room name or id" }, callsign: { type: "string", description: "Your handle in the room" }, engine: { type: "string", description: "Optional engine/CLI id (codex | claude | agy | agon); identifies you in presence. Defaults to mcp." } }, required: ["room", "callsign"] } },
32
+ { name: "RoomList", description: "List all rooms.", inputSchema: { type: "object", properties: {} } }
33
+ ];
34
+ function isRoomTool(name) {
35
+ return ROOM_TOOLS.some((t) => t.name === name);
36
+ }
37
+ function handleRoomTool(name, args) {
38
+ try {
39
+ if (name === "RoomList") return JSON.stringify(listRooms(), null, 2);
40
+ const room = String(args.room ?? "").trim();
41
+ if (!room) return 'Error: "room" is required.';
42
+ const roomId = slugifyRoomId(room);
43
+ if (name === "RoomRead") {
44
+ if (!roomExists(roomId)) return `Error: no room "${roomId}".`;
45
+ const since = Number(args.since ?? 0) || 0;
46
+ const limit = Number(args.limit ?? 50) || 50;
47
+ const events = readEvents(roomId, since, limit).map((e) => ({ seq: e.seq, kind: e.kind, from: e.actor.callsign, body: e.body, mentions: e.mentions, at: e.createdAt }));
48
+ return JSON.stringify({ room: roomId, events }, null, 2);
49
+ }
50
+ if (name === "RoomWho") {
51
+ if (!roomExists(roomId)) return `Error: no room "${roomId}".`;
52
+ return JSON.stringify({ room: roomId, present: listPresence(roomId) }, null, 2);
53
+ }
54
+ const callsign = String(args.callsign ?? "").trim().toLowerCase();
55
+ if (!callsign) return 'Error: "callsign" is required.';
56
+ const engine = args.engine ? String(args.engine) : void 0;
57
+ const cli = engine || "mcp";
58
+ const actor = { actorId: `${cli}:${callsign}`, callsign, kind: "external-cli", engineId: engine, cli, humanOwner: process.env.USER || "local" };
59
+ const repoHint = basename(process.cwd());
60
+ if (name === "RoomJoin") {
61
+ if (roomExists(roomId) && isRoomClosed(roomId)) return `Error: room "${roomId}" is closed.`;
62
+ createRoom(room);
63
+ recordPresence(roomId, actor, 0, false);
64
+ appendEvent(roomId, { kind: "join", actor, body: "", mentions: [], replyTo: null, repoHint });
65
+ const transcript = readEvents(roomId, 0, 20).map((e) => ({ seq: e.seq, kind: e.kind, from: e.actor.callsign, body: e.body, at: e.createdAt }));
66
+ return JSON.stringify({ joined: roomId, as: callsign, transcript }, null, 2);
67
+ }
68
+ if (name === "RoomPost") {
69
+ const text = String(args.text ?? "");
70
+ if (!text.trim()) return 'Error: "text" is required.';
71
+ if (!roomExists(roomId)) return `Error: no room "${roomId}". Join it first.`;
72
+ if (isRoomClosed(roomId)) return `Error: room "${roomId}" is closed.`;
73
+ const ev = appendEvent(roomId, { kind: "post", actor, body: text, mentions: parseMentions(text), replyTo: null, repoHint });
74
+ recordPresence(roomId, actor, ev.seq, false);
75
+ return JSON.stringify({ posted: roomId, seq: ev.seq, mentions: ev.mentions }, null, 2);
76
+ }
77
+ if (name === "RoomLeave") {
78
+ if (!roomExists(roomId)) return `Error: no room "${roomId}".`;
79
+ appendEvent(roomId, { kind: "leave", actor, body: "", mentions: [], replyTo: null, repoHint });
80
+ removePresence(roomId, callsign);
81
+ return JSON.stringify({ left: roomId, callsign }, null, 2);
82
+ }
83
+ return `Error: unknown room tool "${name}".`;
84
+ } catch (err) {
85
+ return `Error: ${err?.message ?? String(err)}`;
86
+ }
87
+ }
88
+
89
+ // ../mcp/src/generated/agon-orchestration.ts
90
+ var ORCHESTRATION_TOOLS = [{ name: "Tribunal", description: "Run or delegate an AI tribunal debate. Outside an active Agon session this executes agon tribunal/team-tribunal and returns JSON output; inside Agon it signals Cesar, then you STOP responding.", inputSchema: { type: "object", properties: { question: { type: "string", description: "The question to debate" }, mode: { type: "string", description: "Debate mode: adversarial, synthesis, steelman, socratic, red-team, or postmortem", enum: ["adversarial", "synthesis", "steelman", "socratic", "red-team", "postmortem"] }, team: { type: "boolean", description: "Solo (false) or team-tribunal (true). Defaults to false." }, engines: { type: "array", items: { type: "string" }, description: 'Optional engine IDs, e.g. ["codex","claude","agy"].' }, rounds: { type: "number", description: "Optional number of debate rounds. Defaults to 2." }, members: { type: "number", description: "Team members per side when team is true. Defaults to 2." }, cwd: { type: "string", description: "Working directory for direct external calls. Defaults to current directory." }, timeout: { type: "number", description: "Overall direct-call timeout in seconds. Defaults to 900." }, engineTimeout: { type: "number", description: "Per-engine timeout in seconds." } }, required: ["question"] } }, { name: "Brainstorm", description: "Run or delegate multi-AI brainstorm. Outside an active Agon session this executes agon brainstorm/team-brainstorm and returns JSON output; inside Agon it signals Cesar, then you STOP responding.", inputSchema: { type: "object", properties: { question: { type: "string", description: "The question to brainstorm on" }, team: { type: "boolean", description: "Solo (false) or team-brainstorm (true). Defaults to false." }, engines: { type: "array", items: { type: "string" }, description: 'Optional engine IDs, e.g. ["codex","claude","agy"].' }, members: { type: "number", description: "Team members per side when team is true. Defaults to 2." }, cwd: { type: "string", description: "Working directory for direct external calls. Defaults to current directory." }, timeout: { type: "number", description: "Overall direct-call timeout in seconds. Defaults to 900." }, engineTimeout: { type: "number", description: "Per-engine timeout in seconds." } }, required: ["question"] } }, { name: "Campfire", description: "Run or delegate campfire discussion. Outside an active Agon session this executes agon campfire and returns JSON output; inside Agon it signals Cesar, then you STOP responding.", inputSchema: { type: "object", properties: { topic: { type: "string", description: "The topic for open discussion" }, engines: { type: "array", items: { type: "string" }, description: 'Optional engine IDs, e.g. ["codex","claude","agy"].' }, strategy: { type: "string", description: "Campfire strategy: lead-first or all-respond", enum: ["lead-first", "all-respond"] }, lead: { type: "string", description: "Lead engine for lead-first strategy." }, cwd: { type: "string", description: "Working directory for direct external calls. Defaults to current directory." }, timeout: { type: "number", description: "Overall direct-call timeout in seconds. Defaults to 900." }, engineTimeout: { type: "number", description: "Per-engine timeout in seconds." } }, required: ["topic"] } }, { name: "Forge", description: "Run or delegate competitive forge. Outside an active Agon session this executes agon forge/team-forge and returns JSON output; inside Agon it signals Cesar, then you STOP responding.", inputSchema: { type: "object", properties: { task: { type: "string", description: "The task to forge" }, fitnessCmd: { type: "string", description: "Test command for fitness evaluation" }, hardened: { type: "boolean", description: "Set true for gauntlet verification" }, team: { type: "boolean", description: "Solo (false) or team-forge (true). Defaults to false." }, engines: { type: "array", items: { type: "string" }, description: 'Optional engine IDs, e.g. ["codex","claude","agy"].' }, members: { type: "number", description: "Team members per side when team is true. Defaults to 2." }, cwd: { type: "string", description: "Working directory for direct external calls. Defaults to current directory." }, timeout: { type: "number", description: "Overall direct-call timeout in seconds. Defaults to 900." }, engineTimeout: { type: "number", description: "Per-engine timeout in seconds." }, finalizeOnScore: { type: "number", description: "V1 caller-driven finalize: stop the forge as soon as any engine PASSES with score >= this threshold (0-100). Aborts in-flight stage-2 engines to save cost/time. Ignored for team-forge." }, cesarSmart: { type: "boolean", description: "When true AND finalizeOnScore is not explicitly set, derive a recommended threshold from the task class (docs/test=75, bugfix/refactor=85, algorithm/feature/other=no early finalize). Lets Cesar pick a sensible cutoff when the external caller does not want to hardcode one." } }, required: ["task"] } }, { name: "Synthesis", description: "Run or delegate competitive synthesis - engines draft, then swap and improve on the other drafts, and a judge picks the best evolved artifact. Outside an active Agon session this executes agon synthesis and returns JSON output; inside Agon it signals Cesar, then you STOP responding. Use when you want one polished artifact that blends the best ideas and no clean pass/fail test exists.", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "The task or prompt to synthesize" }, swaps: { type: "number", description: "Number of swap rounds where engines improve on the other drafts (0 = draft-only). Defaults to 1." }, engines: { type: "array", items: { type: "string" }, description: 'Optional engine IDs, e.g. ["codex","claude","agy"].' }, cwd: { type: "string", description: "Working directory for direct external calls. Defaults to current directory." }, timeout: { type: "number", description: "Overall direct-call timeout in seconds. Defaults to 900." }, engineTimeout: { type: "number", description: "Per-engine timeout in seconds." } }, required: ["prompt"] } }, { name: "Pipeline", description: "Run or delegate the full pipeline: brainstorm \u2192 forge \u2192 tribunal. Outside an active Agon session this executes the CLI stages and returns JSON output; inside Agon it signals Cesar, then you STOP responding.", inputSchema: { type: "object", properties: { task: { type: "string", description: "The task description" }, fitnessCmd: { type: "string", description: "Test command for fitness evaluation" }, engines: { type: "array", items: { type: "string" }, description: 'Optional engine IDs, e.g. ["codex","claude","agy"].' }, mode: { type: "string", description: "Tribunal mode for the final pipeline review.", enum: ["adversarial", "synthesis", "steelman", "socratic", "red-team", "postmortem"] }, cwd: { type: "string", description: "Working directory for direct external calls. Defaults to current directory." }, timeout: { type: "number", description: "Overall direct-call timeout in seconds. Defaults to 900." }, engineTimeout: { type: "number", description: "Per-engine timeout in seconds." } }, required: ["task"] } }, { name: "Review", description: "Run or delegate code review. Outside an active Agon session this executes agon review and returns JSON output; inside Agon it signals Cesar, then you STOP responding. Set engine/engines only when explicitly requested.", inputSchema: { type: "object", properties: { target: { type: "string", description: 'Review target: "uncommitted", "branch:NAME", or "commit:SHA"' }, engine: { type: "string", description: "Specific engine for review, only when explicitly requested by the user" }, engines: { type: "array", items: { type: "string" }, description: "Multiple specific engines for review, only when explicitly requested by the user" }, cwd: { type: "string", description: "Working directory for direct external calls. Defaults to current directory." }, timeout: { type: "number", description: "Overall direct-call timeout in seconds. Defaults to 900." } } } }, { name: "Agent", description: "Delegate to autonomous agent mode. Solo runs one engine through a multi-turn tool loop; team:true runs multiple API engines in isolated worktrees and synthesizes the best result. Always set taskKind to edit or investigate. After calling: STOP responding.", inputSchema: { type: "object", properties: { task: { type: "string", description: "The concrete task for the agent to perform" }, team: { type: "boolean", description: "Set true for parallel team-agent mode" }, engines: { type: "array", items: { type: "string" }, description: "Optional engine IDs for team mode" }, taskKind: { type: "string", description: "edit or investigate", enum: ["edit", "investigate"] }, maxTurns: { type: "number", description: "Optional turn budget per engine" } }, required: ["task"] } }, { name: "Delegate", description: "Send a subtask to a specific engine and get the result back. After calling: STOP responding.", inputSchema: { type: "object", properties: { engine: { type: "string", description: "Engine ID to delegate to" }, task: { type: "string", description: "The subtask prompt" }, mode: { type: "string", description: "Dispatch mode: exec, review, or agent", enum: ["exec", "review", "agent"] } }, required: ["engine", "task"] } }, { name: "ReportConfidence", description: "Report your confidence level (0-100). Call this FIRST on every turn. Does NOT stop your turn \u2014 continue after calling.", inputSchema: { type: "object", properties: { value: { type: "number", description: "Confidence 0-100" }, reasoning: { type: "string", description: "Brief reason for this confidence level" } }, required: ["value"] } }, { name: "QuickNero", description: "Request a structured self-challenge on your current response. Pokes at assumptions before you commit to staying local. Use when you are midway between sure and unsure and want a gut-check. The self-check runs after the tool loop. Does NOT stop your turn \u2014 continue after calling.", inputSchema: { type: "object", properties: { reason: { type: "string", description: "Brief reason for requesting the self-check. Optional." } } } }, { name: "ProposePlan", description: "Submit a structured Cesar execution plan for user approval. Use in plan mode or when staged execution is genuinely useful. After calling: STOP responding.", inputSchema: { type: "object", properties: { intent: { type: "string", description: "1-3 sentences describing the user task and overall approach" }, autoApprove: { type: "boolean", description: "Set true only for clearly requested autonomous multi-stage workflows with high confidence" }, selfReview: { type: "boolean", description: "Whether to auto-append review after mutating steps. Defaults true." }, steps: { type: "array", items: { type: "object", properties: { id: { type: "string" }, type: { type: "string", enum: ["self", "forge", "teamforge", "delegate", "brainstorm", "campfire", "tribunal", "pipeline", "review", "agent", "team-agent"] }, description: { type: "string" }, engines: { type: "array", items: { type: "string" } }, engine: { type: "string" }, fitnessCmd: { type: "string" }, tribunalMode: { type: "string" }, parallel: { type: "boolean" }, dependsOn: { type: "array", items: { type: "string" } }, exports: { type: "array", items: { type: "string" } }, imports: { type: "array", items: { type: "string" } }, estimatedTokens: { type: "number" }, estimatedCostUsd: { type: "number" }, rationale: { type: "string" }, verifyCmd: { type: "string" } }, required: ["id", "type", "description", "estimatedTokens", "estimatedCostUsd"] } } }, required: ["intent", "steps"] } }, { name: "ExitPlanMode", description: "Leave plan mode and return to live work. Inside Agon it signals Cesar to archive the pending plan and clear plan state, then you CONTINUE responding and work live. Call when a plan is NOT the right approach: the task is simple enough to do live, the pending plan is wrong/too-broad, or planning is blocking progress. You are never trapped in plan mode \u2014 this is your escape hatch. Not for a RUNNING plan (use the cancel flow for that).", inputSchema: { type: "object", properties: { reason: { type: "string", description: "REQUIRED. One sentence on why a plan is not the right approach here. Surfaced to the user." } }, required: ["reason"] } }, { name: "AgonBash", description: "Execute a shell command. Agon manages permissions \u2014 the user will be asked to approve write commands (git commit, npm install, etc.). Read-only commands are auto-approved. Use this instead of your native Bash tool for all shell commands.", inputSchema: { type: "object", properties: { command: { type: "string", description: "The shell command to execute" }, timeout: { type: "number", description: "Timeout in seconds (default 30)" } }, required: ["command"] } }, { name: "AgonEdit", description: "Edit a file by replacing text. Agon manages permissions \u2014 the user will be asked to approve. Use this instead of your native Edit tool.", inputSchema: { type: "object", properties: { file_path: { type: "string", description: "Absolute path to the file" }, old_string: { type: "string", description: "Text to find and replace" }, new_string: { type: "string", description: "Replacement text" } }, required: ["file_path", "old_string", "new_string"] } }, { name: "AgonWrite", description: "Create or overwrite a file. Agon manages permissions \u2014 the user will be asked to approve. Use this instead of your native Write tool.", inputSchema: { type: "object", properties: { file_path: { type: "string", description: "Absolute path to the file" }, content: { type: "string", description: "File content to write" } }, required: ["file_path", "content"] } }, { name: "DeliverAnswer", description: "Deliver your final response to the user. When the host runs you under a PTY answer-channel (AGON_ANSWER_CHANNEL=1) you MUST call this exactly once at the end of every turn with your complete answer as markdown \u2014 it is the ONLY reliable way the user sees your response; printed text is treated as a draft preview only. After calling, STOP responding. No approval is required and it does not dispatch anything.", inputSchema: { type: "object", properties: { text: { type: "string", description: "Your complete final response to the user, as markdown." } }, required: ["text"] } }];
91
+ function writeSignal(tool, args) {
92
+ const signalDir = process.env.AGON_SIGNAL_DIR;
93
+ const sessionId = process.env.AGON_SESSION_ID;
94
+ if (!signalDir || !sessionId) return;
95
+ try {
96
+ mkdirSync(signalDir, { recursive: true });
97
+ const signalPath = join(signalDir, `${sessionId}.json`);
98
+ let signals = [];
99
+ if (existsSync(signalPath)) {
100
+ try {
101
+ signals = JSON.parse(readFileSync(signalPath, "utf-8"));
102
+ } catch {
103
+ signals = [];
104
+ }
105
+ }
106
+ signals.push({ tool, args, timestamp: Date.now() });
107
+ writeFileSync(signalPath, JSON.stringify(signals));
108
+ } catch {
109
+ }
110
+ }
111
+ function hasSignalTransport() {
112
+ return !!(process.env.AGON_SIGNAL_DIR && process.env.AGON_SESSION_ID);
113
+ }
114
+ function writeAnswer(text) {
115
+ if (process.env.AGON_ANSWER_CHANNEL !== "1") return false;
116
+ const signalDir = process.env.AGON_SIGNAL_DIR;
117
+ const sessionId = process.env.AGON_SESSION_ID;
118
+ if (!signalDir || !sessionId) return false;
119
+ try {
120
+ mkdirSync(signalDir, { recursive: true });
121
+ const answerPath = join(signalDir, `${sessionId}-answer.json`);
122
+ writeFileSync(answerPath, JSON.stringify({ type: "answer", text: String(text ?? ""), timestamp: Date.now() }));
123
+ return true;
124
+ } catch {
125
+ return false;
126
+ }
127
+ }
128
+ function parseOptionalStringList(value) {
129
+ if (!value) {
130
+ return [];
131
+ }
132
+ if (Array.isArray(value)) {
133
+ return value.map((v) => String(v).trim()).filter(Boolean);
134
+ }
135
+ return String(value).split(",").map((v) => v.trim()).filter(Boolean);
136
+ }
137
+ function parseOptionalBoolean(value) {
138
+ if (value === true) {
139
+ return true;
140
+ }
141
+ if (value === false || value == null) {
142
+ return false;
143
+ }
144
+ return ["1", "true", "yes", "team"].includes(String(value).trim().toLowerCase());
145
+ }
146
+ function optionalFlag(flag, value) {
147
+ const text = value == null ? "" : String(value).trim();
148
+ return text ? [flag, text] : [];
149
+ }
150
+ function buildDirectAgonCommand(tool, args) {
151
+ const cwd = String(args.cwd ?? process.env.AGON_CWD ?? process.cwd());
152
+ const timeoutSec = Number(args.timeout ?? 900);
153
+ const timeoutMs = Math.max(1, timeoutSec) * 1e3;
154
+ const engines = parseOptionalStringList(args.engines ?? args.engine);
155
+ const engineArgs = engines.length > 0 ? ["--engines", engines.join(",")] : [];
156
+ const team = parseOptionalBoolean(args.team);
157
+ const membersArgs = optionalFlag("--members", args.members ?? args.membersPerSide);
158
+ const roundsArgs = optionalFlag("--rounds", args.rounds);
159
+ const modeArgs = optionalFlag("--tribunalMode", args.mode);
160
+ const engineTimeoutArgs = optionalFlag("--timeout", args.engineTimeout ?? args.timeoutPerEngine);
161
+ const cwdArgs = optionalFlag("--cwd", cwd);
162
+ const jsonlArgs = ["--jsonl"];
163
+ const commands = [];
164
+ if (tool === "Forge") {
165
+ const task = String(args.task ?? "").trim();
166
+ const fitness = String(args.fitnessCmd ?? args.fitness ?? "true").trim() || "true";
167
+ const explicitFinalize = args.finalizeOnScore;
168
+ const cesarSmart = parseOptionalBoolean(args.cesarSmart);
169
+ const derivedFinalize = cesarSmart && explicitFinalize == null && !team ? defaultFinalizeOnScoreForTask(task) : void 0;
170
+ const finalizeValue = explicitFinalize ?? derivedFinalize;
171
+ const finalizeOnScoreArgs = team ? [] : optionalFlag("--finalize-on-score", finalizeValue);
172
+ commands.push(["call", team ? "team-forge" : "forge", task, "--test", fitness, ...cwdArgs, ...membersArgs, ...engineTimeoutArgs, ...engineArgs, ...finalizeOnScoreArgs, ...jsonlArgs]);
173
+ } else if (tool === "Synthesis") {
174
+ const prompt = String(args.prompt ?? args.task ?? "").trim();
175
+ const swapsArgs = optionalFlag("--swaps", args.swaps);
176
+ commands.push(["call", "synthesis", prompt, ...cwdArgs, ...swapsArgs, ...engineTimeoutArgs, ...engineArgs, ...jsonlArgs]);
177
+ } else if (tool === "Brainstorm") {
178
+ const question = String(args.question ?? "").trim();
179
+ commands.push(["call", team ? "team-brainstorm" : "brainstorm", question, ...cwdArgs, ...membersArgs, ...engineTimeoutArgs, ...engineArgs, ...jsonlArgs]);
180
+ } else if (tool === "Tribunal") {
181
+ const question = String(args.question ?? "").trim();
182
+ commands.push(["call", team ? "team-tribunal" : "tribunal", question, ...cwdArgs, ...roundsArgs, ...modeArgs, ...membersArgs, ...engineTimeoutArgs, ...engineArgs, ...jsonlArgs]);
183
+ } else if (tool === "Campfire") {
184
+ const topic = String(args.topic ?? "").trim();
185
+ commands.push(["call", "campfire", topic, ...cwdArgs, ...optionalFlag("--strategy", args.strategy), ...optionalFlag("--lead", args.lead), ...engineTimeoutArgs, ...engineArgs, ...jsonlArgs]);
186
+ } else if (tool === "Pipeline") {
187
+ const task = String(args.task ?? "").trim();
188
+ const fitness = String(args.fitnessCmd ?? args.fitness ?? "true").trim() || "true";
189
+ commands.push(["call", "pipeline", task, "--test", fitness, ...cwdArgs, ...roundsArgs, ...modeArgs, ...engineTimeoutArgs, ...engineArgs, ...jsonlArgs]);
190
+ } else if (tool === "Review") {
191
+ const target = String(args.target ?? "uncommitted").trim();
192
+ commands.push(["call", "review", target, ...cwdArgs, ...engineArgs, ...jsonlArgs]);
193
+ } else {
194
+ throw new Error(`Tool ${tool} cannot run directly outside Agon yet`);
195
+ }
196
+ return { commands, cwd, timeoutMs };
197
+ }
198
+ function runAgonCliDirect(tool, args) {
199
+ const depth = Number(process.env.AGON_CALL_DEPTH ?? "0");
200
+ if (Number.isFinite(depth) && depth > 0) {
201
+ return JSON.stringify({
202
+ ok: false,
203
+ tool,
204
+ error: "Refusing recursive Agon call: this MCP server is already running inside an Agon-dispatched engine."
205
+ }, null, 2);
206
+ }
207
+ const direct = buildDirectAgonCommand(tool, args);
208
+ const nodeScript = process.env.AGON_CLI_NODE_SCRIPT;
209
+ const command = nodeScript ? process.execPath : process.env.AGON_CLI_COMMAND || "agon";
210
+ const prefixArgs = nodeScript ? [nodeScript] : [];
211
+ const results = [];
212
+ for (const cliArgs of direct.commands) {
213
+ const runArgs = [...prefixArgs, ...cliArgs];
214
+ const startedAt = Date.now();
215
+ const result = spawnSync(command, runArgs, {
216
+ cwd: direct.cwd,
217
+ timeout: direct.timeoutMs,
218
+ encoding: "utf-8",
219
+ env: {
220
+ ...process.env,
221
+ AGON_CALL_DEPTH: String(depth + 1),
222
+ AGON_CWD: direct.cwd
223
+ },
224
+ maxBuffer: 1024 * 1024 * 8
225
+ });
226
+ const stdout = String(result.stdout ?? "");
227
+ const stderr = String(result.stderr ?? "");
228
+ results.push({
229
+ command: [command, ...runArgs].join(" "),
230
+ cwd: direct.cwd,
231
+ exitCode: result.status,
232
+ signal: result.signal,
233
+ timedOut: !!result.error && /timed out/i.test(String(result.error.message ?? result.error)),
234
+ durationMs: Date.now() - startedAt,
235
+ stdout: stdout.slice(-6e4),
236
+ stderr: stderr.slice(-1e4),
237
+ error: result.error ? String(result.error.message ?? result.error) : void 0
238
+ });
239
+ if (result.status !== 0 || result.error) break;
240
+ }
241
+ return JSON.stringify({
242
+ ok: results.every((r) => r.exitCode === 0 && !r.error),
243
+ tool,
244
+ mode: "direct-cli",
245
+ results
246
+ }, null, 2);
247
+ }
248
+ function handleToolCall(name, args) {
249
+ const NON_BREAKING = /* @__PURE__ */ new Set(["ReportConfidence", "QuickNero"]);
250
+ const BREAK_AND_RESUME = /* @__PURE__ */ new Set(["Delegate"]);
251
+ const DIRECT_WORKFLOWS = /* @__PURE__ */ new Set(["Forge", "Synthesis", "Brainstorm", "Tribunal", "Campfire", "Pipeline", "Review"]);
252
+ if (!hasSignalTransport() && DIRECT_WORKFLOWS.has(name)) {
253
+ return runAgonCliDirect(name, args);
254
+ }
255
+ writeSignal(name, args);
256
+ if (NON_BREAKING.has(name)) {
257
+ if (name === "QuickNero") {
258
+ return "Quick Nero self-check scheduled. Continue responding \u2014 the self-check runs after the tool loop.";
259
+ }
260
+ return `Confidence ${args.value}% recorded. Continue responding.`;
261
+ }
262
+ if (name === "ExitPlanMode") {
263
+ return "Left plan mode \u2014 Agon is clearing the plan state now. STOP responding; you will continue live on your next turn (do not propose a plan again).";
264
+ }
265
+ if (BREAK_AND_RESUME.has(name)) {
266
+ return `Delegation to ${args.engine} accepted. The orchestrator will execute the subtask and feed the result back to you. STOP responding now \u2014 you will receive the result in your next turn.`;
267
+ }
268
+ return "Delegation accepted. The orchestrator will handle the rest. STOP responding now \u2014 do not continue after this tool call.";
269
+ }
270
+ function writePermissionRequest(id, tool, args) {
271
+ const signalDir = process.env.AGON_SIGNAL_DIR;
272
+ const sessionId = process.env.AGON_SESSION_ID;
273
+ if (!signalDir || !sessionId) return;
274
+ mkdirSync(signalDir, { recursive: true });
275
+ const requestPath = join(signalDir, `${sessionId}-perm-${id}.json`);
276
+ writeFileSync(requestPath, JSON.stringify({ type: "permission-request", id, tool, args, timestamp: Date.now() }));
277
+ }
278
+ function writeToolCompletion(id, tool, args, status, output) {
279
+ const signalDir = process.env.AGON_SIGNAL_DIR;
280
+ const sessionId = process.env.AGON_SESSION_ID;
281
+ if (!signalDir || !sessionId) return;
282
+ try {
283
+ mkdirSync(signalDir, { recursive: true });
284
+ const completionPath = join(signalDir, `${sessionId}-tool-${id}.json`);
285
+ const cappedOutput = String(output ?? "").slice(0, 12e3);
286
+ writeFileSync(completionPath, JSON.stringify({
287
+ type: "tool-completion",
288
+ id,
289
+ tool,
290
+ args,
291
+ status: status === "error" ? "error" : "done",
292
+ output: cappedOutput,
293
+ timestamp: Date.now()
294
+ }));
295
+ } catch {
296
+ }
297
+ }
298
+ async function pollPermissionResponse(id, timeoutMs) {
299
+ const signalDir = process.env.AGON_SIGNAL_DIR;
300
+ const sessionId = process.env.AGON_SESSION_ID;
301
+ if (!signalDir || !sessionId) return { approved: false, reason: "No signal dir" };
302
+ const requestPath = join(signalDir, `${sessionId}-perm-${id}.json`);
303
+ const responsePath = join(signalDir, `${sessionId}-perm-${id}-response.json`);
304
+ const start = Date.now();
305
+ while (Date.now() - start < timeoutMs) {
306
+ if (existsSync(responsePath)) {
307
+ try {
308
+ const data = JSON.parse(readFileSync(responsePath, "utf-8"));
309
+ try {
310
+ unlinkSync(responsePath);
311
+ } catch {
312
+ }
313
+ try {
314
+ unlinkSync(requestPath);
315
+ } catch {
316
+ }
317
+ return { approved: !!data.approved, reason: data.reason };
318
+ } catch {
319
+ }
320
+ }
321
+ await new Promise((r) => setTimeout(r, 100));
322
+ }
323
+ try {
324
+ unlinkSync(requestPath);
325
+ } catch {
326
+ }
327
+ return { approved: false, reason: "Permission request timed out" };
328
+ }
329
+ async function handleWriteToolCall(name, args) {
330
+ const requestId = `pr-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
331
+ const toolMap = { AgonBash: "Bash", AgonEdit: "Edit", AgonWrite: "Write" };
332
+ const kernTool = toolMap[name] ?? name;
333
+ writePermissionRequest(requestId, kernTool, args);
334
+ const response = await pollPermissionResponse(requestId, 6e4);
335
+ if (!response.approved) {
336
+ const denied = `Permission denied: ${response.reason ?? "User declined"}. Do NOT retry this command \u2014 ask the user what they want instead.`;
337
+ writeToolCompletion(requestId, name, args, "error", denied);
338
+ return denied;
339
+ }
340
+ try {
341
+ if (name === "AgonBash") {
342
+ const cmd = args.command;
343
+ const timeout = (args.timeout ?? 30) * 1e3;
344
+ const cwd = process.env.AGON_CWD || process.cwd();
345
+ const result = execSync(cmd, { cwd, timeout, encoding: "utf-8", maxBuffer: 1024 * 1024, stdio: ["pipe", "pipe", "pipe"] });
346
+ const output = result || "(command completed with no output)";
347
+ writeToolCompletion(requestId, name, args, "done", output);
348
+ return output;
349
+ }
350
+ if (name === "AgonEdit") {
351
+ const filePath = args.file_path;
352
+ const oldStr = args.old_string;
353
+ const newStr = args.new_string;
354
+ const content = readFileSync(filePath, "utf-8");
355
+ if (!content.includes(oldStr)) {
356
+ const output2 = `Error: old_string not found in ${filePath}`;
357
+ writeToolCompletion(requestId, name, args, "error", output2);
358
+ return output2;
359
+ }
360
+ const updated = content.replace(oldStr, newStr);
361
+ writeFileSync(filePath, updated);
362
+ const output = `File edited: ${filePath}`;
363
+ writeToolCompletion(requestId, name, args, "done", output);
364
+ return output;
365
+ }
366
+ if (name === "AgonWrite") {
367
+ const filePath = args.file_path;
368
+ const fileContent = args.content;
369
+ mkdirSync(dirname(filePath), { recursive: true });
370
+ writeFileSync(filePath, fileContent);
371
+ const output = `File written: ${filePath}`;
372
+ writeToolCompletion(requestId, name, args, "done", output);
373
+ return output;
374
+ }
375
+ writeToolCompletion(requestId, name, args, "error", "Unknown write tool");
376
+ return "Unknown write tool";
377
+ } catch (err) {
378
+ const output = `Error: ${err.message ?? String(err)}`;
379
+ writeToolCompletion(requestId, name, args, "error", output);
380
+ return output;
381
+ }
382
+ }
383
+ function startMcpServer() {
384
+ const rl = createInterface({ input: process.stdin, terminal: false });
385
+ function respond(id, result) {
386
+ if (id === null) return;
387
+ process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, result }) + "\n");
388
+ }
389
+ function respondError(id, code, message) {
390
+ if (id === null) return;
391
+ process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } }) + "\n");
392
+ }
393
+ rl.on("line", (line) => {
394
+ let msg;
395
+ try {
396
+ msg = JSON.parse(line);
397
+ } catch {
398
+ return;
399
+ }
400
+ const { id, method, params } = msg;
401
+ if (method === "initialize") {
402
+ respond(id, {
403
+ protocolVersion: "2024-11-05",
404
+ capabilities: { tools: { listChanged: false } },
405
+ serverInfo: { name: "agon-orchestration", version: "1.0.0" }
406
+ });
407
+ return;
408
+ }
409
+ if (method === "notifications/initialized" || method === "initialized") {
410
+ return;
411
+ }
412
+ if (method === "tools/list") {
413
+ respond(id, {
414
+ tools: [...ORCHESTRATION_TOOLS, ...ROOM_TOOLS].map((t) => ({
415
+ name: t.name,
416
+ description: t.description,
417
+ inputSchema: t.inputSchema
418
+ }))
419
+ });
420
+ return;
421
+ }
422
+ if (method === "tools/call") {
423
+ const toolName = params?.name;
424
+ const toolArgs = params?.arguments ?? {};
425
+ if (isRoomTool(toolName)) {
426
+ const roomResult = handleRoomTool(toolName, toolArgs);
427
+ respond(id, { content: [{ type: "text", text: roomResult }] });
428
+ return;
429
+ }
430
+ const tool = ORCHESTRATION_TOOLS.find((t) => t.name === toolName);
431
+ if (!tool) {
432
+ respondError(id, -32602, `Unknown tool: ${toolName}`);
433
+ return;
434
+ }
435
+ if (toolName === "DeliverAnswer") {
436
+ const ok = writeAnswer(toolArgs.text);
437
+ respond(id, { content: [{ type: "text", text: ok ? "Answer delivered. STOP responding now." : "No answer-channel configured \u2014 just print your answer as text." }] });
438
+ return;
439
+ }
440
+ const WRITE_TOOLS = /* @__PURE__ */ new Set(["AgonBash", "AgonEdit", "AgonWrite"]);
441
+ if (WRITE_TOOLS.has(toolName)) {
442
+ handleWriteToolCall(toolName, toolArgs).then((result2) => {
443
+ respond(id, { content: [{ type: "text", text: result2 }] });
444
+ }).catch((err) => {
445
+ respondError(id, -32603, `Tool execution failed: ${err.message ?? String(err)}`);
446
+ });
447
+ return;
448
+ }
449
+ const result = handleToolCall(toolName, toolArgs);
450
+ respond(id, {
451
+ content: [{ type: "text", text: result }]
452
+ });
453
+ return;
454
+ }
455
+ if (id !== void 0 && id !== null) {
456
+ respondError(id, -32601, `Method not found: ${method}`);
457
+ }
458
+ });
459
+ rl.on("close", () => process.exit(0));
460
+ }
461
+
462
+ // ../mcp/src/index.ts
463
+ startMcpServer();
464
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../mcp/src/generated/agon-orchestration.ts","../../../mcp/src/generated/rooms.ts","../../../mcp/src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,SAAS,eAAe,cAAc,WAAW,YAAY,kBAAkB;AAE/E,SAAS,MAAM,eAAe;AAE9B,SAAS,uBAAuB;AAEhC,SAAS,UAAU,iBAAiB;;;ACNpC,SAAS,gBAAgB;AAOlB,IAAM,aAAyF;AAAA,EACpG,EAAE,MAAM,YAAY,aAAa,uMAAuM,aAAa,EAAE,MAAM,UAAU,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,aAAa,kBAAkB,GAAG,UAAU,EAAE,MAAM,UAAU,aAAa,8CAA8C,GAAG,QAAQ,EAAE,MAAM,UAAU,aAAa,qGAAqG,EAAE,GAAG,UAAU,CAAC,QAAQ,UAAU,EAAE,EAAE;AAAA,EAC3lB,EAAE,MAAM,YAAY,aAAa,qGAAqG,aAAa,EAAE,MAAM,UAAU,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,aAAa,kBAAkB,GAAG,UAAU,EAAE,MAAM,UAAU,aAAa,0BAA0B,GAAG,MAAM,EAAE,MAAM,UAAU,aAAa,0CAA0C,GAAG,QAAQ,EAAE,MAAM,UAAU,aAAa,qGAAqG,EAAE,GAAG,UAAU,CAAC,QAAQ,YAAY,MAAM,EAAE,EAAE;AAAA,EAC/jB,EAAE,MAAM,YAAY,aAAa,wJAAmJ,a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AAQ,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAMA,QAAO,CAAC,EAAE,CAAC;AAAA,QAC3D,CAAC,EAAE,MAAM,CAAC,QAAa;AACrB,uBAAa,IAAI,QAAQ,0BAA0B,IAAI,WAAW,OAAO,GAAG,CAAC,EAAE;AAAA,QACjF,CAAC;AACD;AAAA,MACF;AACA,YAAM,SAAS,eAAe,UAAU,QAAQ;AAChD,cAAQ,IAAI;AAAA,QACV,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,OAAO,CAAC;AAAA,MAC1C,CAAC;AACD;AAAA,IACF;AAGA,QAAI,OAAO,UAAa,OAAO,MAAM;AACnC,mBAAa,IAAI,QAAQ,qBAAqB,MAAM,EAAE;AAAA,IACxD;AAAA,EACF,CAAC;AAED,KAAG,GAAG,SAAS,MAAM,QAAQ,KAAK,CAAC,CAAC;AACtC;;;AE9aA,eAAe;","names":["output","result"]}
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ buildStepExecutors,
4
+ handleExitPlanMode,
5
+ handleProposePlan
6
+ } from "./chunk-RKXVKX25.js";
7
+ import "./chunk-SUT2HDOY.js";
8
+ import "./chunk-AONHRJRW.js";
9
+ import "./chunk-I2PMSXJ3.js";
10
+ import "./chunk-BPKY4OF2.js";
11
+ import "./chunk-45YTXJWJ.js";
12
+ export {
13
+ buildStepExecutors,
14
+ handleExitPlanMode,
15
+ handleProposePlan
16
+ };
17
+ //# sourceMappingURL=plan-mode-PFLUPGSY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"mappings":"","names":[]}
@@ -432,16 +432,17 @@ import {
432
432
  worktreePathFor,
433
433
  worktreePrune,
434
434
  worktreePruneAll,
435
+ worktreePruneOrphaned,
435
436
  worktreeRemove,
436
437
  worktreeRemoveBestEffort,
437
438
  writeProvenanceReport,
438
439
  writeRunStatus
439
- } from "./chunk-TMNHJOKU.js";
440
+ } from "./chunk-BPKY4OF2.js";
440
441
  import {
441
442
  apiDispatch,
442
443
  apiStreamDispatch,
443
444
  apiStreamDispatchWithHistory
444
- } from "./chunk-XWHC6VAH.js";
445
+ } from "./chunk-45YTXJWJ.js";
445
446
  export {
446
447
  AGON_HOME,
447
448
  AGON_MODE_NAMES,
@@ -878,9 +879,10 @@ export {
878
879
  worktreePathFor,
879
880
  worktreePrune,
880
881
  worktreePruneAll,
882
+ worktreePruneOrphaned,
881
883
  worktreeRemove,
882
884
  worktreeRemoveBestEffort,
883
885
  writeProvenanceReport,
884
886
  writeRunStatus
885
887
  };
886
- //# sourceMappingURL=src-3NWTITZM.js.map
888
+ //# sourceMappingURL=src-253BUXEF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"mappings":"","names":[]}
@@ -10,11 +10,11 @@ import {
10
10
  runUpdate,
11
11
  suggestPermissionFix,
12
12
  updateCommand
13
- } from "./chunk-6IF2AV4Y.js";
14
- import "./chunk-HSPQEDHX.js";
15
- import "./chunk-NBV37VMW.js";
16
- import "./chunk-TMNHJOKU.js";
17
- import "./chunk-XWHC6VAH.js";
13
+ } from "./chunk-6WWOJXG4.js";
14
+ import "./chunk-SUT2HDOY.js";
15
+ import "./chunk-I2PMSXJ3.js";
16
+ import "./chunk-BPKY4OF2.js";
17
+ import "./chunk-45YTXJWJ.js";
18
18
  export {
19
19
  DEFAULT_PACKAGE,
20
20
  DEFAULT_TIMEOUT_MS,
@@ -27,4 +27,4 @@ export {
27
27
  suggestPermissionFix,
28
28
  updateCommand
29
29
  };
30
- //# sourceMappingURL=update-H3LE4ZSI.js.map
30
+ //# sourceMappingURL=update-ODAAXWOD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernlang/agon",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "description": "The competitive multi-AI orchestration CLI. Engines compete in isolated git worktrees on the same task, the best test-passing solution is applied, and Glicko-2 ratings track each model over time. Modes: forge, brainstorm, synthesis, tribunal, council, campfire, think, nero, goal, conquer.",
6
6
  "keywords": [
@@ -55,8 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@kernlang/agon-engines": "^0.1.1",
58
- "@kernlang/agon-dedup": "^0.1.6",
59
- "@kernlang/agon-mcp": "^0.1.6",
58
+ "@kernlang/agon-dedup": "^0.1.7",
60
59
  "@ai-sdk/anthropic": "^3.0.67",
61
60
  "@ai-sdk/openai-compatible": "^2.0.40",
62
61
  "@kernlang/protocol": "~3.5.8",