codex-supervisor-mcp 0.14.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +34 -45
- package/README.md +34 -45
- package/package.json +1 -1
- package/skills/codex-supervisor/SKILL.md +86 -90
- package/src/app/acceptance.js +5 -5
- package/src/app/auto-cleanup.js +6 -5
- package/src/app/cleanup-facts.js +7 -4
- package/src/app/cleanup-plan.js +3 -2
- package/src/app/context-compiler.js +2 -1
- package/src/app/dispatch.js +17 -15
- package/src/app/followup.js +5 -4
- package/src/app/land-chain.js +5 -4
- package/src/app/landing.js +8 -8
- package/src/app/ownership.js +1 -1
- package/src/app/rebase.js +1 -1
- package/src/app/restore-worktree.js +2 -1
- package/src/app/resume.js +6 -5
- package/src/app/worktree-setup.js +15 -14
- package/src/domain/acceptance-spec.js +1 -1
- package/src/domain/failure-class.js +2 -2
- package/src/domain/prompt.js +7 -7
- package/src/domain/status.js +9 -0
- package/src/domain/thread-health.js +2 -2
- package/src/domain/worker-branch.js +6 -0
- package/src/domain/worker-changes.js +3 -3
- package/src/infra/cleanup-hint.js +1 -1
- package/src/infra/external-output.js +2 -2
- package/src/infra/sandbox-roots.js +1 -1
- package/src/infra/store/events.js +2 -1
- package/src/infra/store/reconcile.js +4 -3
- package/src/infra/store/tasks.js +1 -1
- package/src/infra/update/auto-update-worker.js +3 -3
- package/src/infra/update/auto-update.js +4 -4
- package/src/infra/update/update-check.js +3 -3
- package/src/infra/workspace-kind.js +8 -8
- package/src/infra/worktree.js +4 -3
- package/src/interface/bin/acceptance-cli.js +4 -4
- package/src/interface/bin/monitor.jsx +6 -6
- package/src/interface/bin/setup.js +3 -3
- package/src/interface/bin/stage.js +2 -2
- package/src/interface/mcp/{tools → handlers}/delivery.js +30 -62
- package/src/interface/mcp/handlers/dispatch.js +233 -0
- package/src/interface/mcp/{tools → handlers}/facts.js +30 -65
- package/src/interface/mcp/handlers/overview.js +103 -0
- package/src/interface/mcp/{tools → handlers}/results.js +31 -60
- package/src/interface/mcp/{tools → handlers}/review.js +16 -36
- package/src/interface/mcp/{tools → handlers}/wait.js +8 -14
- package/src/interface/mcp/server.js +18 -51
- package/src/interface/mcp/tools/deliver.js +48 -0
- package/src/interface/mcp/tools/dispatch.js +78 -257
- package/src/interface/mcp/tools/optional.js +57 -0
- package/src/interface/mcp/tools/read.js +115 -0
- package/src/interface/mcp/tools/run.js +57 -0
- package/src/interface/mcp/tools/shapes.js +66 -0
- package/src/interface/mcp/tools/track.js +84 -0
- package/src/interface/mcp/views/task.js +8 -7
- package/src/interface/web/views.js +2 -1
- package/src/run-host/launch.js +7 -7
- package/src/runners/codex/tool-guard.js +6 -6
- package/src/domain/overview-delta.js +0 -77
- package/src/interface/mcp/tools/overview.js +0 -202
- package/src/interface/mcp/tools/poll.js +0 -58
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { branchOf } from "../../../domain/worker-branch.js";
|
|
1
2
|
import { ensureTaskWorktree } from "../../../app/restore-worktree.js";
|
|
2
3
|
import { askWorker, endSideSession, latestSideTurn } from "../../../app/side-chat.js";
|
|
3
4
|
import { isGoalNeedingAttention, TERMINAL_STATUSES } from "../../../domain/status.js";
|
|
@@ -12,17 +13,11 @@ import { buildWorkerSummary, externalOutputView, reportView, runEvidenceView } f
|
|
|
12
13
|
import { acceptanceView } from "../views/task.js";
|
|
13
14
|
import { z } from "zod";
|
|
14
15
|
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
title: "Get worker goal",
|
|
19
|
-
description:
|
|
20
|
-
"Read the goal recorded for a worker, plus the native Codex thread goal when the thread has one (status, tokens used, time used).",
|
|
21
|
-
inputSchema: {
|
|
16
|
+
export const getWorkerGoalOp = {
|
|
17
|
+
input: z.object({
|
|
22
18
|
task_id: z.string().min(1)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async ({ task_id }) => {
|
|
19
|
+
}),
|
|
20
|
+
handler: async ({ task_id }) => {
|
|
26
21
|
const task = await getTask(task_id);
|
|
27
22
|
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
28
23
|
return textResult({
|
|
@@ -37,19 +32,13 @@ export const getWorkerGoalTool = [
|
|
|
37
32
|
native_goal_read: readNativeGoalState(task.thread_id)
|
|
38
33
|
});
|
|
39
34
|
}
|
|
40
|
-
|
|
35
|
+
};
|
|
41
36
|
|
|
42
|
-
export const
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
title: "Get worker summary",
|
|
46
|
-
description:
|
|
47
|
-
"One compact summary per worker: goal, status, changed files, last command, last message. Cheap enough for a main thread to read every worker at the end of a run.",
|
|
48
|
-
inputSchema: {
|
|
37
|
+
export const getWorkerSummaryOp = {
|
|
38
|
+
input: z.object({
|
|
49
39
|
task_id: z.string().min(1)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async ({ task_id }) => {
|
|
40
|
+
}),
|
|
41
|
+
handler: async ({ task_id }) => {
|
|
53
42
|
const task = await getTask(task_id);
|
|
54
43
|
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
55
44
|
const summary = buildWorkerSummary(task, readNativeGoal(task.thread_id));
|
|
@@ -60,23 +49,17 @@ export const getWorkerSummaryTool = [
|
|
|
60
49
|
}
|
|
61
50
|
return textResult(summary);
|
|
62
51
|
}
|
|
63
|
-
|
|
52
|
+
};
|
|
64
53
|
|
|
65
|
-
export const
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
title: "Get worker result",
|
|
69
|
-
description:
|
|
70
|
-
"Read a worker's own final report. The overview and the wait response clip the last message; this is the door for the actual conclusion. Returns the last N agent messages (each clipped past maxChars, default 6000 bytes, with truncated: true and the full size so you can re-read it whole), the status fields that tell a real finish from a crash, verification (the commands the worker ran, their exit codes and the tail of any failing output, to hold its report against), acceptance (the supervisor's own run of the dispatch-time acceptance commands, independent of the report: configured, passed, and each check's exit code and output tail; passed: false means resume the worker with that output instead of reading its report, passed: true against a report that says blocked or not done means trust the checks and read the diff), changed_file_count, and base_behind (how many commits the project's HEAD is past the worktree's base; resume with rebaseOnto when it is not 0). includeFiles: true adds the changed_files list; get_worker_diff is the ground truth for what changed.",
|
|
71
|
-
inputSchema: {
|
|
54
|
+
export const getWorkerResultOp = {
|
|
55
|
+
input: z.object({
|
|
72
56
|
task_id: z.string().min(1),
|
|
73
57
|
limit: z.number().int().min(1).max(20).default(1),
|
|
74
58
|
// Per report, UTF-8 bytes. 0 means no clipping.
|
|
75
59
|
maxChars: z.number().int().min(0).max(1000000).default(6000),
|
|
76
60
|
includeFiles: z.boolean().default(false)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async ({ task_id, limit, maxChars, includeFiles }) => {
|
|
61
|
+
}),
|
|
62
|
+
handler: async ({ task_id, limit, maxChars, includeFiles }) => {
|
|
80
63
|
const task = await getTask(task_id);
|
|
81
64
|
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
82
65
|
let reports = await readAgentMessages(task_id, limit);
|
|
@@ -122,7 +105,7 @@ export const getWorkerResultTool = [
|
|
|
122
105
|
report_bytes: reportBytes,
|
|
123
106
|
truncated,
|
|
124
107
|
next_step: truncated
|
|
125
|
-
? `a report was clipped to ${maxChars} bytes; call again with
|
|
108
|
+
? `a report was clipped to ${maxChars} bytes; call again with max_chars: ${Math.max(...reportBytes)} (or 0) to read it whole`
|
|
126
109
|
: null,
|
|
127
110
|
reports: clipped,
|
|
128
111
|
source,
|
|
@@ -130,7 +113,7 @@ export const getWorkerResultTool = [
|
|
|
130
113
|
completed_at: task.completed_at ?? null
|
|
131
114
|
});
|
|
132
115
|
}
|
|
133
|
-
|
|
116
|
+
};
|
|
134
117
|
|
|
135
118
|
// Cleanup keeps the branch; the diff is read from a worktree cut from it
|
|
136
119
|
// again. Null when the worktree is there, a refusal when it cannot come back.
|
|
@@ -143,13 +126,8 @@ async function restoreRefusal(task) {
|
|
|
143
126
|
}
|
|
144
127
|
}
|
|
145
128
|
|
|
146
|
-
export const
|
|
147
|
-
|
|
148
|
-
{
|
|
149
|
-
title: "Get worker diff",
|
|
150
|
-
description:
|
|
151
|
-
"The worker's actual changes. By default this is a complete file/hunk index; request one file to page through hunks with pageSize or cursor. Supplying maxChars without file preserves the legacy bounded full-diff response. This is the ground truth to check a worker's report against.",
|
|
152
|
-
inputSchema: {
|
|
129
|
+
export const getWorkerDiffOp = {
|
|
130
|
+
input: z.object({
|
|
153
131
|
task_id: z.string().min(1),
|
|
154
132
|
maxChars: z.number().int().min(0).max(1000000).optional(),
|
|
155
133
|
file: z.string().min(1).optional(),
|
|
@@ -157,13 +135,12 @@ export const getWorkerDiffTool = [
|
|
|
157
135
|
pageSize: z.number().int().min(1).max(20).default(4),
|
|
158
136
|
cursor: z.string().min(1).optional(),
|
|
159
137
|
paths: z.array(z.string().min(1)).optional()
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async ({ task_id, maxChars, file, hunk, pageSize, cursor, paths }) => {
|
|
138
|
+
}),
|
|
139
|
+
handler: async ({ task_id, maxChars, file, hunk, pageSize, cursor, paths }) => {
|
|
163
140
|
const task = await getTask(task_id);
|
|
164
141
|
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
165
142
|
if (!task.worktree_path) {
|
|
166
|
-
return textResult({ error: "no_worktree", task_id, external_outputs: externalOutputView(task, maxChars), reason: "this worker ran in place (its cwd is not a git repository or the worktree could not be created), so there is no isolated diff to read; call
|
|
143
|
+
return textResult({ error: "no_worktree", task_id, external_outputs: externalOutputView(task, maxChars), reason: "this worker ran in place (its cwd is not a git repository or the worktree could not be created), so there is no isolated diff to read; call get_worker with include result and include_files: true for the files it touched" });
|
|
167
144
|
}
|
|
168
145
|
const refusal = await restoreRefusal(task);
|
|
169
146
|
if (refusal) return refusal;
|
|
@@ -174,7 +151,7 @@ export const getWorkerDiffTool = [
|
|
|
174
151
|
title: task.title,
|
|
175
152
|
status: task.status,
|
|
176
153
|
worktree_path: task.worktree_path,
|
|
177
|
-
branch:
|
|
154
|
+
branch: branchOf(task),
|
|
178
155
|
...diff,
|
|
179
156
|
external_outputs: externalOutputView(task, maxChars)
|
|
180
157
|
});
|
|
@@ -192,7 +169,7 @@ export const getWorkerDiffTool = [
|
|
|
192
169
|
title: task.title,
|
|
193
170
|
status: task.status,
|
|
194
171
|
worktree_path: task.worktree_path,
|
|
195
|
-
branch:
|
|
172
|
+
branch: branchOf(task),
|
|
196
173
|
...diff,
|
|
197
174
|
files,
|
|
198
175
|
external_outputs: externalOutputView(task, maxChars || 6000)
|
|
@@ -237,24 +214,18 @@ export const getWorkerDiffTool = [
|
|
|
237
214
|
summary_only: false
|
|
238
215
|
});
|
|
239
216
|
}
|
|
240
|
-
|
|
217
|
+
};
|
|
241
218
|
|
|
242
|
-
export const
|
|
243
|
-
|
|
244
|
-
{
|
|
245
|
-
title: "Ask a worker on the side",
|
|
246
|
-
description:
|
|
247
|
-
"Ask a finished or running worker a question without touching its thread: the worker's Codex thread is forked once into a read-only side session (like Codex's own /btw), the question is asked there, and later questions resume that fork. The fork carries everything the worker saw and did, so 'why did you change X' or 'where is Y handled' costs one short answer instead of a read of the event stream. The fork has no network and no MCP tools and is told so; it answers from its context and the worktree. Once the worker has been resumed, the next question automatically takes a new fork from the updated thread (refreshed: \"worker_resumed\"); fresh: true forces a new fork. Changes still go through resume_codex_worker. Without a question it returns the latest side turn (for an answer that outran timeoutMs). end: true deletes the fork.",
|
|
248
|
-
inputSchema: {
|
|
219
|
+
export const askCodexWorkerOp = {
|
|
220
|
+
input: z.object({
|
|
249
221
|
task_id: z.string().min(1),
|
|
250
222
|
question: z.string().min(1).optional(),
|
|
251
223
|
timeoutMs: z.number().int().min(1000).max(600000).default(110000),
|
|
252
224
|
maxChars: z.number().int().min(0).max(1000000).default(8000),
|
|
253
225
|
fresh: z.boolean().default(false),
|
|
254
226
|
end: z.boolean().default(false)
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
async ({ task_id, question, timeoutMs, maxChars, fresh, end }) => {
|
|
227
|
+
}),
|
|
228
|
+
handler: async ({ task_id, question, timeoutMs, maxChars, fresh, end }) => {
|
|
258
229
|
const task = await getTask(task_id);
|
|
259
230
|
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
260
231
|
const clipAnswer = (state) => {
|
|
@@ -271,7 +242,7 @@ export const askCodexWorkerTool = [
|
|
|
271
242
|
try {
|
|
272
243
|
const state = clipAnswer(await askWorker({ task, question, timeoutMs, fresh }));
|
|
273
244
|
const next = state.timed_out
|
|
274
|
-
? `The side turn is still running; call
|
|
245
|
+
? `The side turn is still running; call ask_worker again with only task_id to read the answer when it lands.`
|
|
275
246
|
: null;
|
|
276
247
|
return textResult({ task_id, ...state, next_step: next });
|
|
277
248
|
} catch (error) {
|
|
@@ -281,4 +252,4 @@ export const askCodexWorkerTool = [
|
|
|
281
252
|
return textResult({ task_id, error: error.code ?? "side_turn_failed", reason: error.message });
|
|
282
253
|
}
|
|
283
254
|
}
|
|
284
|
-
|
|
255
|
+
};
|
|
@@ -9,14 +9,9 @@ import { receipt } from "../views/task.js";
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
title: "Create an independent read-only verifier",
|
|
16
|
-
description: "Create a fresh read-only verifier for one settled worker. It receives the target objective and current worktree path, never the target report or candidate facts, has no network and cannot dispatch workers. The review relation is persisted for later finding and resolution.",
|
|
17
|
-
inputSchema: { task_id: z.string().min(1), title: z.string().min(1).max(120).optional() }
|
|
18
|
-
},
|
|
19
|
-
async ({ task_id, title }) => {
|
|
12
|
+
export const createIndependentVerifierOp = {
|
|
13
|
+
input: z.object({ task_id: z.string().min(1), title: z.string().min(1).max(120).optional() }),
|
|
14
|
+
handler: async ({ task_id, title }) => {
|
|
20
15
|
try {
|
|
21
16
|
const subject = await getTask(task_id);
|
|
22
17
|
if (!subject) return textResult({ error: "task_not_found", task_id });
|
|
@@ -59,16 +54,11 @@ export const createIndependentVerifierTool = [
|
|
|
59
54
|
return errorResult(error);
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
|
-
|
|
57
|
+
};
|
|
63
58
|
|
|
64
|
-
export const
|
|
65
|
-
"
|
|
66
|
-
{
|
|
67
|
-
title: "Record an independent verifier finding",
|
|
68
|
-
description: "After a verifier settles, record its passes/fails/inconclusive verdict with a concise reason. The supervisor stores a retained finding artifact and appends an event to the reviewed worker; this does not change the reviewed worker's delivery state automatically.",
|
|
69
|
-
inputSchema: { verifier_task_id: z.string().min(1), verdict: z.enum(["passes", "fails", "inconclusive"]), reason: z.string().min(1).max(4000) }
|
|
70
|
-
},
|
|
71
|
-
async ({ verifier_task_id, verdict, reason }) => {
|
|
59
|
+
export const recordIndependentFindingOp = {
|
|
60
|
+
input: z.object({ verifier_task_id: z.string().min(1), verdict: z.enum(["passes", "fails", "inconclusive"]), reason: z.string().min(1).max(4000) }),
|
|
61
|
+
handler: async ({ verifier_task_id, verdict, reason }) => {
|
|
72
62
|
try {
|
|
73
63
|
const review = await getReviewByVerifierTask(verifier_task_id);
|
|
74
64
|
if (!review) return textResult({ error: "review_not_found", verifier_task_id });
|
|
@@ -97,16 +87,11 @@ export const recordIndependentFindingTool = [
|
|
|
97
87
|
return errorResult(error);
|
|
98
88
|
}
|
|
99
89
|
}
|
|
100
|
-
|
|
90
|
+
};
|
|
101
91
|
|
|
102
|
-
export const
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
title: "Resolve an independent verifier finding",
|
|
106
|
-
description: "Record how a previously recorded independent finding was resolved. This is an audit transition only; it does not hide the finding or alter worker code.",
|
|
107
|
-
inputSchema: { verifier_task_id: z.string().min(1), resolution: z.string().min(1).max(4000) }
|
|
108
|
-
},
|
|
109
|
-
async ({ verifier_task_id, resolution }) => {
|
|
92
|
+
export const resolveIndependentFindingOp = {
|
|
93
|
+
input: z.object({ verifier_task_id: z.string().min(1), resolution: z.string().min(1).max(4000) }),
|
|
94
|
+
handler: async ({ verifier_task_id, resolution }) => {
|
|
110
95
|
try {
|
|
111
96
|
const review = await resolveReviewFinding({ verifierTaskId: verifier_task_id, resolution });
|
|
112
97
|
if (!review) return textResult({ error: "review_not_recorded", verifier_task_id });
|
|
@@ -119,17 +104,12 @@ export const resolveIndependentFindingTool = [
|
|
|
119
104
|
return errorResult(error);
|
|
120
105
|
}
|
|
121
106
|
}
|
|
122
|
-
|
|
107
|
+
};
|
|
123
108
|
|
|
124
|
-
export const
|
|
125
|
-
|
|
126
|
-
{
|
|
127
|
-
title: "Get one independent review relation",
|
|
128
|
-
description: "Read the persisted subject/verifier/finding/resolution relation for a verifier task. Use get_artifact for the retained finding evidence.",
|
|
129
|
-
inputSchema: { verifier_task_id: z.string().min(1) }
|
|
130
|
-
},
|
|
131
|
-
async ({ verifier_task_id }) => {
|
|
109
|
+
export const getIndependentReviewOp = {
|
|
110
|
+
input: z.object({ verifier_task_id: z.string().min(1) }),
|
|
111
|
+
handler: async ({ verifier_task_id }) => {
|
|
132
112
|
const review = await getReviewByVerifierTask(verifier_task_id);
|
|
133
113
|
return textResult(review ? { review } : { error: "review_not_found", verifier_task_id });
|
|
134
114
|
}
|
|
135
|
-
|
|
115
|
+
};
|
|
@@ -41,7 +41,7 @@ function budgetExhaustedHint(effectiveTimeoutMs) {
|
|
|
41
41
|
effectiveTimeoutMs >= 60000
|
|
42
42
|
? `${Math.round(effectiveTimeoutMs / 60000)}-minute`
|
|
43
43
|
: `${Math.round(effectiveTimeoutMs / 1000)}-second`;
|
|
44
|
-
return `Workers are still running; the ${budgetLabel} wait budget ran out. Reuse the same task_ids for a short wait, or schedule
|
|
44
|
+
return `Workers are still running; the ${budgetLabel} wait budget ran out. Reuse the same task_ids for a short wait, or schedule poll_workers for long monitoring. Set allow_long_wait only after verifying the client's MCP timeout supports the requested budget; do not start another long wait while a background wait is active.`;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function compactWorkerRow(task) {
|
|
@@ -109,13 +109,8 @@ async function waitForWorkers(input, extra) {
|
|
|
109
109
|
}));
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export const
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
title: "Wait for Codex workers",
|
|
116
|
-
description:
|
|
117
|
-
"Block until selected Codex workers reach a terminal status, then return summaries. Each call is capped at 60 seconds unless allowLongWait is explicitly true and the caller has verified its MCP timeout supports the requested budget. A spent wait budget returns a snapshot while workers continue; reuse the same task_ids or schedule check_workers for longer monitoring. compact: true returns one line per worker with status, phase, exit_code, changed_file_count, acceptance and liveness. command_running means a command may still be working despite a long idle interval.",
|
|
118
|
-
inputSchema: {
|
|
112
|
+
export const waitCodexWorkersOp = {
|
|
113
|
+
input: z.object({
|
|
119
114
|
task_ids: z.array(z.string().min(1)).min(1),
|
|
120
115
|
mode: z.enum(["any", "all"]).default("all"),
|
|
121
116
|
timeoutMinutes: z.number().int().min(1).max(360).default(1),
|
|
@@ -126,7 +121,7 @@ export const waitCodexWorkersTool = [
|
|
|
126
121
|
// Off by default. A wait is the call clients background and then replay
|
|
127
122
|
// as a notification, so its payload has to stay small; ten events per
|
|
128
123
|
// worker was the bulk of it. Ask for events explicitly, or read
|
|
129
|
-
//
|
|
124
|
+
// get_worker (include events) for one worker.
|
|
130
125
|
includeEvents: z.boolean().default(false),
|
|
131
126
|
eventLimit: z.number().int().min(1).max(50).default(10),
|
|
132
127
|
// Events used to come back whole: one command event can carry a heredoc
|
|
@@ -137,9 +132,8 @@ export const waitCodexWorkersTool = [
|
|
|
137
132
|
eventKinds: z.array(z.string().min(1)).optional(),
|
|
138
133
|
// The smallest useful answer: one line per worker, for a caller that
|
|
139
134
|
// only wants to know who is done. Everything else comes from
|
|
140
|
-
//
|
|
135
|
+
// get_worker (include result) / get_worker_diff afterwards.
|
|
141
136
|
compact: z.boolean().optional()
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
];
|
|
137
|
+
}),
|
|
138
|
+
handler: waitForWorkers
|
|
139
|
+
};
|
|
@@ -5,15 +5,11 @@ import { packageVersion } from "./meta.js";
|
|
|
5
5
|
import { refreshUpdateState, UPDATE_RECHECK_MS } from "./update-state.js";
|
|
6
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { getContextSnapshotMetaTool, getFactTool, getArtifactTool, promoteWorkerFactTool, revokeWorkerFactTool, getWorkerEvidenceTool, searchWorkerFactsTool } from "./tools/facts.js";
|
|
14
|
-
import { createIndependentVerifierTool, recordIndependentFindingTool, resolveIndependentFindingTool, getIndependentReviewTool } from "./tools/review.js";
|
|
15
|
-
import { getWorkerGoalTool, getWorkerSummaryTool, getWorkerResultTool, getWorkerDiffTool, askCodexWorkerTool } from "./tools/results.js";
|
|
16
|
-
import { landCodexWorkerTool, verifyDeliveryPushTool, cleanupPlanTool, applyCleanupTool, cleanupHistoryTool, cancelCodexWorkerTool } from "./tools/delivery.js";
|
|
8
|
+
import { cancelWorkerTool, createWorkerTool, preflightWorkerTool, resumeWorkerTool } from "./tools/dispatch.js";
|
|
9
|
+
import { cleanupTool, landWorkerTool, verifyPushTool } from "./tools/deliver.js";
|
|
10
|
+
import { factsTool, getArtifactTool, reviewTool } from "./tools/optional.js";
|
|
11
|
+
import { askWorkerTool, describeSessionTool, findWorksTool, getWorkerDiffTool, getWorkerTool } from "./tools/read.js";
|
|
12
|
+
import { pollWorkersTool, waitWorkersTool } from "./tools/track.js";
|
|
17
13
|
|
|
18
14
|
const server = new McpServer({
|
|
19
15
|
name: "codex-supervisor",
|
|
@@ -28,7 +24,7 @@ setInterval(() => refreshUpdateState({ force: true }), UPDATE_RECHECK_MS).unref(
|
|
|
28
24
|
// and a global install only synced the skill on the day it was installed.
|
|
29
25
|
// Runs in the background; a client that cannot write its skill directory
|
|
30
26
|
// only costs a line on stderr.
|
|
31
|
-
if (!process.env.
|
|
27
|
+
if (!process.env.AGENT_SUPERVISOR_SKIP_SKILL_SYNC) {
|
|
32
28
|
syncSkills()
|
|
33
29
|
.then((result) => {
|
|
34
30
|
const changed = [...result.installed, ...result.updated];
|
|
@@ -46,49 +42,20 @@ if (!process.env.CODEX_SUPERVISOR_SKIP_SKILL_SYNC) {
|
|
|
46
42
|
});
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
//
|
|
45
|
+
// The order is the order tools/list returns, which is the order a model reads
|
|
46
|
+
// them in: the path of a batch from preflight to cleanup.
|
|
50
47
|
const TOOLS = [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
createCodexWorkerTool,
|
|
57
|
-
createCodexFollowupWorkerTool,
|
|
58
|
-
resumeCodexWorkerTool,
|
|
59
|
-
listCodexWorkersTool,
|
|
60
|
-
getOrchestrationOverviewTool,
|
|
61
|
-
waitCodexWorkersTool,
|
|
62
|
-
getSessionWorksTool,
|
|
63
|
-
checkForUpdateTool,
|
|
64
|
-
describeSessionTool,
|
|
65
|
-
searchWorksTool,
|
|
66
|
-
getCodexWorkerStatusTool,
|
|
67
|
-
getCodexWorkerEventsTool,
|
|
68
|
-
getContextSnapshotMetaTool,
|
|
69
|
-
getFactTool,
|
|
70
|
-
getArtifactTool,
|
|
71
|
-
promoteWorkerFactTool,
|
|
72
|
-
revokeWorkerFactTool,
|
|
73
|
-
getWorkerEvidenceTool,
|
|
74
|
-
searchWorkerFactsTool,
|
|
75
|
-
createIndependentVerifierTool,
|
|
76
|
-
recordIndependentFindingTool,
|
|
77
|
-
resolveIndependentFindingTool,
|
|
78
|
-
getIndependentReviewTool,
|
|
79
|
-
getWorkerGoalTool,
|
|
80
|
-
getWorkerSummaryTool,
|
|
81
|
-
getWorkerResultTool,
|
|
82
|
-
getWorkerDiffTool,
|
|
83
|
-
askCodexWorkerTool,
|
|
84
|
-
landCodexWorkerTool,
|
|
85
|
-
verifyDeliveryPushTool,
|
|
86
|
-
cleanupPlanTool,
|
|
87
|
-
applyCleanupTool,
|
|
88
|
-
cleanupHistoryTool,
|
|
89
|
-
cancelCodexWorkerTool
|
|
48
|
+
preflightWorkerTool, createWorkerTool, resumeWorkerTool, cancelWorkerTool,
|
|
49
|
+
pollWorkersTool, waitWorkersTool,
|
|
50
|
+
getWorkerTool, getWorkerDiffTool, askWorkerTool,
|
|
51
|
+
landWorkerTool, verifyPushTool, cleanupTool,
|
|
52
|
+
findWorksTool, describeSessionTool
|
|
90
53
|
];
|
|
91
|
-
|
|
54
|
+
// The fact ledger, independent review and raw artifacts are rarely needed and
|
|
55
|
+
// cost context in every session, so they are opt-in.
|
|
56
|
+
const OPTIONAL_TOOLS = [factsTool, reviewTool, getArtifactTool];
|
|
57
|
+
const enabled = process.env.AGENT_SUPERVISOR_TOOLS === "all" ? [...TOOLS, ...OPTIONAL_TOOLS] : TOOLS;
|
|
58
|
+
for (const tool of enabled) server.registerTool(...tool);
|
|
92
59
|
|
|
93
60
|
const transport = new StdioServerTransport();
|
|
94
61
|
await server.connect(transport);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { applyCleanupOp, cleanupHistoryOp, cleanupPlanOp, landCodexWorkerOp, verifyDeliveryPushOp } from "../handlers/delivery.js";
|
|
3
|
+
import { defineTool, run } from "./run.js";
|
|
4
|
+
|
|
5
|
+
export const landWorkerTool = defineTool("land_worker", {
|
|
6
|
+
title: "Land a worker's commits",
|
|
7
|
+
description: "Cherry-pick the worker's commits onto the branch checked out where it was dispatched. commit_message first commits its uncommitted edits, which is how a sandboxed worker's work gets committed. Refused when acceptance failed or has not run, the target is dirty, or the diff leaves owned_paths; a conflict leaves the target as it was. Read get_worker_diff first.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
task_id: z.string(),
|
|
10
|
+
commit_message: z.string().optional(),
|
|
11
|
+
onto: z.string().optional().describe("Refuse unless the target is on this branch"),
|
|
12
|
+
include_followup_parents: z.boolean().default(false).describe("Land the whole follow-up chain, root first"),
|
|
13
|
+
commit_messages: z.record(z.string(), z.string()).optional().describe("Task id to commit message, for the chain"),
|
|
14
|
+
ignore_acceptance: z.boolean().default(false).describe("Only when the user said so"),
|
|
15
|
+
allow_outside_owned: z.boolean().default(false).describe("Only when the user said so")
|
|
16
|
+
}
|
|
17
|
+
}, (args) => run(landCodexWorkerOp, {
|
|
18
|
+
task_id: args.task_id, onto: args.onto, commitMessage: args.commit_message, includeFollowupParents: args.include_followup_parents,
|
|
19
|
+
commitMessages: args.commit_messages, ignoreAcceptance: args.ignore_acceptance, allowOutsideOwned: args.allow_outside_owned
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
export const verifyPushTool = defineTool("verify_push", {
|
|
23
|
+
title: "Prove landed work is on the remote",
|
|
24
|
+
description: "Fetch a remote branch and check the landed commit is reachable from it. It only verifies: it never pushes or deploys. Landing is local; this is the proof the work left the machine.",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
task_id: z.string(),
|
|
27
|
+
remote: z.string().default("origin"),
|
|
28
|
+
branch: z.string().optional().describe("Default: the branch the work landed on")
|
|
29
|
+
}
|
|
30
|
+
}, (args) => run(verifyDeliveryPushOp, args));
|
|
31
|
+
|
|
32
|
+
export const cleanupTool = defineTool("cleanup", {
|
|
33
|
+
title: "Inspect or force worktree cleanup",
|
|
34
|
+
description: "Cleanup is automatic during poll_workers: landed or unchanged work goes at once, unlanded work after a hold period, with uncommitted edits committed to the worker's branch first; branches and evidence stay. Use this to see why a worktree is still there (plan), remove SAFE ones now (apply, with plan_id and item_ids), or read what was removed (history).",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
action: z.enum(["plan", "apply", "history"]),
|
|
37
|
+
task_ids: z.array(z.string()).max(200).optional().describe("plan: limit to these workers; history: the first one"),
|
|
38
|
+
project_root: z.string().optional(),
|
|
39
|
+
plan_id: z.string().optional(),
|
|
40
|
+
item_ids: z.array(z.string()).max(200).optional(),
|
|
41
|
+
limit: z.number().int().min(1).max(500).optional()
|
|
42
|
+
}
|
|
43
|
+
}, (args) => {
|
|
44
|
+
if (args.action === "plan") return run(cleanupPlanOp, { task_ids: args.task_ids, project_root: args.project_root });
|
|
45
|
+
if (args.action === "history") return run(cleanupHistoryOp, { task_id: args.task_ids?.[0], limit: args.limit });
|
|
46
|
+
if (!args.plan_id || !args.item_ids?.length) return { error: "invalid_arguments", message: "apply needs plan_id and item_ids from a plan" };
|
|
47
|
+
return run(applyCleanupOp, { plan_id: args.plan_id, item_ids: args.item_ids });
|
|
48
|
+
});
|