codex-supervisor-mcp 0.13.6 → 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 +35 -46
- package/README.md +35 -46
- package/package.json +3 -2
- package/skills/codex-supervisor/SKILL.md +86 -89
- package/src/app/acceptance.js +5 -5
- package/src/app/auto-cleanup.js +91 -0
- package/src/app/cleanup-facts.js +99 -0
- package/src/app/cleanup-plan.js +108 -100
- 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 +14 -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 +51 -0
- package/src/app/resume.js +24 -6
- package/src/app/side-chat.js +3 -0
- package/src/app/verify-push.js +2 -7
- package/src/app/worktree-setup.js +15 -14
- package/src/domain/acceptance-spec.js +1 -1
- package/src/domain/cleanup-policy.js +44 -0
- 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 +7 -8
- 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/records.js +18 -7
- package/src/infra/store/tasks.js +31 -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/cleanup.js +1 -1
- 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 +45 -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 -62
|
@@ -1,267 +1,88 @@
|
|
|
1
|
-
import { runAcceptance } from "../../../app/acceptance.js";
|
|
2
|
-
import { createCodexWorker } from "../../../app/dispatch.js";
|
|
3
|
-
import { createFollowupWorker } from "../../../app/followup.js";
|
|
4
|
-
import { resumeCodexWorker } from "../../../app/resume.js";
|
|
5
|
-
import { readPreflightResult } from "../../../domain/worker-preflight.js";
|
|
6
|
-
import { runGit } from "../../../infra/git.js";
|
|
7
|
-
import { getTask } from "../../../infra/store/tasks.js";
|
|
8
|
-
import { baseBehind } from "../../../infra/worktree.js";
|
|
9
|
-
import { errorResult, textResult } from "../result.js";
|
|
10
|
-
import { acceptanceInput, workspaceSetupInput } from "../schemas.js";
|
|
11
|
-
import { withUpdate } from "../update-state.js";
|
|
12
|
-
import { receipt } from "../views/task.js";
|
|
13
|
-
import { randomUUID } from "node:crypto";
|
|
14
1
|
import { z } from "zod";
|
|
2
|
+
import { cancelCodexWorkerOp } from "../handlers/delivery.js";
|
|
3
|
+
import { checkAcceptanceOp, createCodexFollowupWorkerOp, createCodexWorkerOp, preflightCodexWorkerOp, resumeCodexWorkerOp } from "../handlers/dispatch.js";
|
|
4
|
+
import { defineTool, run } from "./run.js";
|
|
5
|
+
import { acceptanceCommands, acceptanceShape, contextShape, dispatchOptions, group, limitsShape, only, sandboxShape, workspaceShape } from "./shapes.js";
|
|
15
6
|
|
|
16
|
-
|
|
17
|
-
"check_acceptance",
|
|
18
|
-
{
|
|
19
|
-
title: "Check acceptance commands",
|
|
20
|
-
description: "Run explicitly supplied acceptance commands in the requested project before dispatch. This executes the commands with supervisor privileges and can have their side effects; it creates no worker and does not prove worker completion. Structured checks require fresh execution evidence, while failure-count greps are flagged as insufficient baseline evidence.",
|
|
21
|
-
inputSchema: {
|
|
22
|
-
cwd: z.string().min(1), acceptance: acceptanceInput,
|
|
23
|
-
baseRef: z.string().min(1).optional(), timeoutMs: z.number().int().min(1000).max(1800000).default(600000)
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
async ({ cwd, acceptance, baseRef = "HEAD", timeoutMs }) => {
|
|
27
|
-
let base;
|
|
28
|
-
try {
|
|
29
|
-
base = runGit(cwd, ["rev-parse", "--verify", `${baseRef}^{commit}`], { timeout: 10000 });
|
|
30
|
-
} catch {
|
|
31
|
-
return textResult({ error: "invalid_base_ref", phase: "preflight", reason: `baseRef does not resolve in ${cwd}`, proves_worker_completion: false });
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
const commands = Array.isArray(acceptance) ? acceptance : [acceptance];
|
|
35
|
-
const warnings = commands.filter((check) => typeof check === "string" && /(?:failures|errors)\s*=\s*\d/.test(check)).map(() => "failure-count checks do not prove baseline test identities or required execution; use structured evidence");
|
|
36
|
-
const result = await runAcceptance(commands, { cwd, timeoutMs, baseCommit: base, taskId: `preflight-${randomUUID()}` });
|
|
37
|
-
return textResult({ ...result, phase: "preflight", base_commit: base, proves_worker_completion: false, warnings });
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return errorResult(error);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
];
|
|
7
|
+
const effort = z.enum(["minimal", "low", "medium", "high"]).optional();
|
|
43
8
|
|
|
44
|
-
export const
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
allowedCommands: z.array(z.string().min(1)).max(100).optional(),
|
|
60
|
-
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
61
|
-
contracts: z.array(z.string().min(1).max(2000)).max(20).optional(),
|
|
62
|
-
networkAccess: z.boolean().default(false),
|
|
63
|
-
writableRoots: z.array(z.string().min(1)).max(20).optional(),
|
|
64
|
-
maxRunMs: z.number().int().min(1000).max(86400000).optional(),
|
|
65
|
-
maxTotalMs: z.number().int().min(1000).max(604800000).optional(),
|
|
66
|
-
baseRef: z.string().min(1).optional(),
|
|
67
|
-
workspaceKind: z.enum(["git_worktree", "read_only_in_place", "scratch", "in_place_write"]).optional(),
|
|
68
|
-
inPlaceAuthorization: z.string().min(1).max(2000).optional(),
|
|
69
|
-
workspaceSetup: workspaceSetupInput.optional(),
|
|
70
|
-
probeCommands: z.array(z.string().min(1)).min(1).max(20)
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
async (input) => {
|
|
74
|
-
try {
|
|
75
|
-
const task = [
|
|
76
|
-
"Runtime environment preflight. Do not edit files, create files, install packages, dispatch workers or call MCP tools.",
|
|
77
|
-
"Run every command below exactly once, in the listed order, without wrapping it in another shell command.",
|
|
78
|
-
"If any command is denied, missing, times out or exits nonzero, stop and quote the raw error under Not done / risks.",
|
|
79
|
-
"Commands:",
|
|
80
|
-
...input.probeCommands.map((command) => `- ${command}`)
|
|
81
|
-
].join("\n");
|
|
82
|
-
const record = await createCodexWorker({
|
|
83
|
-
...input,
|
|
84
|
-
title: input.title ? `Preflight: ${input.title}` : "Runtime environment preflight",
|
|
85
|
-
task,
|
|
86
|
-
goal: { objective: `Prove the requested Codex worker runtime environment before dispatching ${input.title ?? "the dependent worker"}` },
|
|
87
|
-
acceptance: null,
|
|
88
|
-
preflight: { probeCommands: input.probeCommands }
|
|
89
|
-
});
|
|
90
|
-
return textResult(withUpdate({ ...receipt(record), preflight: { status: "running", probe_commands: input.probeCommands } }));
|
|
91
|
-
} catch (error) {
|
|
92
|
-
return errorResult(error);
|
|
93
|
-
}
|
|
9
|
+
export const preflightWorkerTool = defineTool("preflight_worker", {
|
|
10
|
+
title: "Check a worker's environment before dispatch",
|
|
11
|
+
description: "Prove the environment before spending a worker. probe_commands starts a short probe worker under the same workspace, sandbox and guard and returns its id: read it with get_worker include preflight, then pass it as preflight_id to create_worker with the same arguments. acceptance alone runs those commands in cwd now and returns their results.",
|
|
12
|
+
inputSchema: {
|
|
13
|
+
cwd: z.string(),
|
|
14
|
+
probe_commands: z.array(z.string()).min(1).max(20).optional().describe("Commands the probe must run"),
|
|
15
|
+
acceptance: acceptanceShape,
|
|
16
|
+
owned_paths: z.array(z.string()).optional().describe("Required with probe_commands"),
|
|
17
|
+
title: z.string().optional(),
|
|
18
|
+
model: z.string().optional(),
|
|
19
|
+
reasoning_effort: effort,
|
|
20
|
+
workspace: workspaceShape,
|
|
21
|
+
sandbox: sandboxShape,
|
|
22
|
+
context: contextShape,
|
|
23
|
+
limits: limitsShape
|
|
94
24
|
}
|
|
95
|
-
|
|
25
|
+
}, async (args) => {
|
|
26
|
+
const check = args.acceptance
|
|
27
|
+
? await run(checkAcceptanceOp, {
|
|
28
|
+
cwd: args.cwd, acceptance: acceptanceCommands(args.acceptance.commands), baseRef: args.workspace?.base_ref, timeoutMs: args.acceptance.timeout_ms
|
|
29
|
+
})
|
|
30
|
+
: null;
|
|
31
|
+
if (!args.probe_commands) return check ?? { error: "invalid_arguments", message: "give probe_commands, acceptance, or both" };
|
|
32
|
+
if (check?.error) return check;
|
|
33
|
+
const probe = await run(preflightCodexWorkerOp, only(preflightCodexWorkerOp, { ...dispatchOptions(args), probeCommands: args.probe_commands }));
|
|
34
|
+
return check ? { ...probe, acceptance_check: check } : probe;
|
|
35
|
+
});
|
|
96
36
|
|
|
97
|
-
export const
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
37
|
+
export const createWorkerTool = defineTool("create_worker", {
|
|
38
|
+
title: "Dispatch a worker",
|
|
39
|
+
description: "Start a worker on one independently verifiable piece of work in its own git worktree and branch. It never commits or pushes. Put the whole brief in task: background, spec, write set, verify command, output format. followup_of continues a finished worker from its branch with its settings.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
task: z.string(),
|
|
42
|
+
cwd: z.string().optional().describe("Repository. Required unless followup_of"),
|
|
43
|
+
owned_paths: z.array(z.string()).optional().describe("Paths the worker may change; overlap with an active worker is refused. Required unless followup_of"),
|
|
44
|
+
goal: group("{objective, token_budget}. Required unless followup_of"),
|
|
45
|
+
title: z.string().optional(),
|
|
46
|
+
followup_of: z.string().optional().describe("Task to continue"),
|
|
47
|
+
depends_on: z.array(z.string()).optional().describe("Task ids that must land first"),
|
|
48
|
+
preflight_id: z.string().optional().describe("A passed preflight_worker id"),
|
|
49
|
+
model: z.string().optional(),
|
|
50
|
+
reasoning_effort: effort,
|
|
51
|
+
session: group("{id, title, note}: one id per batch"),
|
|
52
|
+
workspace: workspaceShape,
|
|
53
|
+
sandbox: sandboxShape,
|
|
54
|
+
context: contextShape,
|
|
55
|
+
acceptance: acceptanceShape,
|
|
56
|
+
limits: limitsShape
|
|
108
57
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
title: "Create Codex worker",
|
|
115
|
-
description:
|
|
116
|
-
"Launch a Codex CLI worker with codex exec --json and track its events. workspaceKind controls where it runs: Git work writes only in an isolated git_worktree; read_only_in_place cannot write or use network; scratch writes only under SUPERVISOR_HOME and never lands; in_place_write is only for an explicitly authorized non-Git directory with ownedPaths and acceptance. A non-Git worker may never write the user directory by default. ownedPaths reserves files a landable worker may write; reading is never exclusive. acceptance is the list of shell commands that decide whether the work is done: the supervisor runs them after Codex exits, and workers run the same contract with codex-supervisor-accept. In a Git package project, acceptance using local JavaScript tooling requires workspaceSetup so node_modules and generated prepare files exist before dispatch. The worker's sandbox may write its execution directory, the temp directory and the OS cache directory; a toolchain whose cache lives elsewhere needs writableRoots, a list of existing absolute directories.",
|
|
117
|
-
inputSchema: {
|
|
118
|
-
title: z.string().optional(),
|
|
119
|
-
task: z.string().min(1),
|
|
120
|
-
cwd: z.string().min(1),
|
|
121
|
-
session_id: z.string().min(1).optional(),
|
|
122
|
-
// What this batch is about, in one line, so a reader of the store sees
|
|
123
|
-
// "给 12 个接口补单测" instead of a bare session id. Set it on
|
|
124
|
-
// the first dispatch of a session; later dispatches may omit it.
|
|
125
|
-
session_title: z.string().min(1).max(120).optional(),
|
|
126
|
-
session_note: z.string().min(1).max(2000).optional(),
|
|
127
|
-
sandbox: z.enum(["read-only", "workspace-write", "danger-full-access"]).default("workspace-write"),
|
|
128
|
-
model: z.string().optional(),
|
|
129
|
-
reasoningEffort: z.enum(["minimal", "low", "medium", "high"]).default("high"),
|
|
130
|
-
skipGitRepoCheck: z.boolean().default(true),
|
|
131
|
-
// Empty is the promise that nothing lands: a read-only verifier, or a
|
|
132
|
-
// research worker that reads, fetches and reports but merges nothing.
|
|
133
|
-
ownedPaths: z.array(z.string().min(1)),
|
|
134
|
-
forbid: z.array(z.string().min(1)).max(100).optional(),
|
|
135
|
-
allowedCommands: z.array(z.string().min(1)).max(100).optional(),
|
|
136
|
-
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
137
|
-
contracts: z.array(z.string().min(1).max(2000)).max(20).optional(),
|
|
138
|
-
externalOutputs: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
139
|
-
networkAccess: z.boolean().default(false),
|
|
140
|
-
// Extra absolute directories the sandbox may write. The OS cache
|
|
141
|
-
// directory is already writable; this is for toolchains that keep a
|
|
142
|
-
// cache somewhere else (~/.m2, ~/.gradle, a vendored mirror).
|
|
143
|
-
writableRoots: z.array(z.string().min(1)).max(20).optional(),
|
|
144
|
-
maxRunMs: z.number().int().min(1000).max(86400000).optional(),
|
|
145
|
-
maxTotalMs: z.number().int().min(1000).max(604800000).optional(),
|
|
146
|
-
goal: z.object({
|
|
147
|
-
objective: z.string().min(1),
|
|
148
|
-
tokenBudget: z.number().int().positive().optional()
|
|
149
|
-
}),
|
|
150
|
-
dependsOn: z.array(z.string().min(1)).optional(),
|
|
151
|
-
// Which commit the worktree is cut from. Defaults to the repository's
|
|
152
|
-
// HEAD; pass a branch, tag or sha to build on work that is not on the
|
|
153
|
-
// main line yet (for example another worker's codex/<id> branch).
|
|
154
|
-
baseRef: z.string().min(1).optional(),
|
|
155
|
-
workspaceKind: z.enum(["git_worktree", "read_only_in_place", "scratch", "in_place_write"]).optional(),
|
|
156
|
-
inPlaceAuthorization: z.string().min(1).max(2000).optional(),
|
|
157
|
-
workspaceSetup: workspaceSetupInput.optional(),
|
|
158
|
-
// A successful preflight_codex_worker task id. When present, this worker
|
|
159
|
-
// is refused unless base commit and the complete runtime contract match.
|
|
160
|
-
preflight_id: z.string().min(1).optional(),
|
|
161
|
-
// Shell commands that decide whether the work is done. The supervisor
|
|
162
|
-
// runs them in the worktree after codex exits; each must exit 0.
|
|
163
|
-
acceptance: acceptanceInput.optional(),
|
|
164
|
-
acceptanceTimeoutMs: z.number().int().min(1000).max(1800000).optional()
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
async (input) => {
|
|
168
|
-
try {
|
|
169
|
-
const record = await createCodexWorker({
|
|
170
|
-
...input,
|
|
171
|
-
preflightId: input.preflight_id ?? null,
|
|
172
|
-
sessionId: input.session_id ?? null,
|
|
173
|
-
sessionTitle: input.session_title ?? null,
|
|
174
|
-
sessionNote: input.session_note ?? null
|
|
175
|
-
});
|
|
176
|
-
return textResult(withUpdate(receipt(record)));
|
|
177
|
-
} catch (error) {
|
|
178
|
-
return errorResult(error);
|
|
179
|
-
}
|
|
58
|
+
}, async (args) => {
|
|
59
|
+
const options = dispatchOptions(args);
|
|
60
|
+
if (args.followup_of) {
|
|
61
|
+
return run(createCodexFollowupWorkerOp, only(createCodexFollowupWorkerOp, { ...options, task_id: args.followup_of, followup_prompt: args.task }));
|
|
180
62
|
}
|
|
181
|
-
]
|
|
182
|
-
|
|
183
|
-
export const createCodexFollowupWorkerTool = [
|
|
184
|
-
"create_codex_followup_worker",
|
|
185
|
-
{
|
|
186
|
-
title: "Create Codex follow-up worker",
|
|
187
|
-
description:
|
|
188
|
-
"Start a NEW Codex session seeded with the previous worker's prompt, status, and recent events. Unlanded parents contribute their current codex/<parent> checkpoint; landed parents use the current target HEAD. Explicit baseRef overrides either; uncommitted parent edits are not copied. To continue the same session instead, use resume_codex_worker.",
|
|
189
|
-
inputSchema: {
|
|
190
|
-
task_id: z.string().min(1),
|
|
191
|
-
followup_prompt: z.string().min(1),
|
|
192
|
-
session_id: z.string().min(1).optional(),
|
|
193
|
-
session_title: z.string().min(1).max(120).optional(),
|
|
194
|
-
session_note: z.string().min(1).max(2000).optional(),
|
|
195
|
-
title: z.string().optional(),
|
|
196
|
-
cwd: z.string().optional(),
|
|
197
|
-
sandbox: z.enum(["read-only", "workspace-write", "danger-full-access"]).optional(),
|
|
198
|
-
model: z.string().optional(),
|
|
199
|
-
reasoningEffort: z.enum(["minimal", "low", "medium", "high"]).default("high"),
|
|
200
|
-
ownedPaths: z.array(z.string().min(1)).optional(),
|
|
201
|
-
forbid: z.array(z.string().min(1)).max(100).optional(),
|
|
202
|
-
allowedCommands: z.array(z.string().min(1)).max(100).optional(),
|
|
203
|
-
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
204
|
-
contracts: z.array(z.string().min(1).max(2000)).max(20).optional(),
|
|
205
|
-
externalOutputs: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
206
|
-
networkAccess: z.boolean().optional(),
|
|
207
|
-
writableRoots: z.array(z.string().min(1)).max(20).optional(),
|
|
208
|
-
maxRunMs: z.number().int().min(1000).max(86400000).optional(),
|
|
209
|
-
maxTotalMs: z.number().int().min(1000).max(604800000).optional(),
|
|
210
|
-
workspaceKind: z.enum(["git_worktree", "read_only_in_place", "scratch", "in_place_write"]).optional(),
|
|
211
|
-
inPlaceAuthorization: z.string().min(1).max(2000).optional(),
|
|
212
|
-
workspaceSetup: workspaceSetupInput.optional(),
|
|
213
|
-
goal: z
|
|
214
|
-
.object({
|
|
215
|
-
objective: z.string().min(1),
|
|
216
|
-
tokenBudget: z.number().int().positive().optional()
|
|
217
|
-
})
|
|
218
|
-
.optional(),
|
|
219
|
-
baseRef: z.string().min(1).optional(),
|
|
220
|
-
// Left out, the parent's acceptance commands are inherited; given, they
|
|
221
|
-
// replace them, and an empty list clears them.
|
|
222
|
-
acceptance: acceptanceInput.optional(),
|
|
223
|
-
acceptanceTimeoutMs: z.number().int().min(1000).max(1800000).optional()
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
async ({ task_id, followup_prompt, session_id, session_title, session_note, ...options }) => {
|
|
227
|
-
try {
|
|
228
|
-
const record = await createFollowupWorker({
|
|
229
|
-
taskId: task_id,
|
|
230
|
-
followupPrompt: followup_prompt,
|
|
231
|
-
sessionId: session_id ?? null,
|
|
232
|
-
sessionTitle: session_title ?? null,
|
|
233
|
-
sessionNote: session_note ?? null,
|
|
234
|
-
...options
|
|
235
|
-
});
|
|
236
|
-
return textResult(receipt(record));
|
|
237
|
-
} catch (error) {
|
|
238
|
-
return errorResult(error);
|
|
239
|
-
}
|
|
63
|
+
for (const name of ["cwd", "owned_paths", "goal"]) {
|
|
64
|
+
if (args[name] === undefined) return { error: "invalid_arguments", message: `${name} is required unless followup_of is given` };
|
|
240
65
|
}
|
|
241
|
-
|
|
66
|
+
return run(createCodexWorkerOp, only(createCodexWorkerOp, { ...options, task: args.task, preflight_id: args.preflight_id, dependsOn: args.depends_on }));
|
|
67
|
+
});
|
|
242
68
|
|
|
243
|
-
export const
|
|
244
|
-
"
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
rebaseOnto: z.string().min(1).optional(),
|
|
253
|
-
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
254
|
-
// Replaces the stored acceptance commands for this and later runs; an
|
|
255
|
-
// empty list clears them. Left out, the stored commands stay.
|
|
256
|
-
acceptance: acceptanceInput.optional()
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
async ({ task_id, prompt, rebaseOnto, acceptance, context }) => {
|
|
260
|
-
try {
|
|
261
|
-
const record = await resumeCodexWorker({ taskId: task_id, prompt, rebaseOnto: rebaseOnto ?? null, acceptance, context });
|
|
262
|
-
return textResult({ ...receipt(record), rebase: record.rebase ?? null, base_behind: baseBehind(record.project_root, record.base_commit) });
|
|
263
|
-
} catch (error) {
|
|
264
|
-
return errorResult(error);
|
|
265
|
-
}
|
|
69
|
+
export const resumeWorkerTool = defineTool("resume_worker", {
|
|
70
|
+
title: "Continue a worker",
|
|
71
|
+
description: "Continue the same worker session with a new instruction, in its worktree; the thread keeps its history. Use it to fix what review found before landing. rebase_onto first moves the worktree onto a newer commit and refuses on conflict. A worktree removed by cleanup is restored from the worker's branch.",
|
|
72
|
+
inputSchema: {
|
|
73
|
+
task_id: z.string(),
|
|
74
|
+
prompt: z.string(),
|
|
75
|
+
rebase_onto: z.string().optional().describe("Commit or branch to rebase the worktree onto before continuing"),
|
|
76
|
+
context_files: z.array(z.object({ path: z.string(), sha256: z.string().optional() })).max(20).optional().describe("Replaces the worker's context files"),
|
|
77
|
+
acceptance: acceptanceShape.describe("Replaces the stored acceptance commands; an empty list clears them")
|
|
266
78
|
}
|
|
267
|
-
|
|
79
|
+
}, (args) => run(resumeCodexWorkerOp, {
|
|
80
|
+
task_id: args.task_id, prompt: args.prompt, rebaseOnto: args.rebase_onto, context: args.context_files,
|
|
81
|
+
acceptance: acceptanceCommands(args.acceptance?.commands)
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
export const cancelWorkerTool = defineTool("cancel_worker", {
|
|
85
|
+
title: "Stop a worker",
|
|
86
|
+
description: "Stop a running worker or its acceptance run. Its worktree and what it changed so far stay.",
|
|
87
|
+
inputSchema: { task_id: z.string() }
|
|
88
|
+
}, (args) => run(cancelCodexWorkerOp, { task_id: args.task_id }));
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Tools most batches never need: the fact ledger, independent review and raw
|
|
2
|
+
// artifacts. They are registered only when AGENT_SUPERVISOR_TOOLS=all.
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { getArtifactOp, getFactOp, promoteWorkerFactOp, revokeWorkerFactOp, searchWorkerFactsOp } from "../handlers/facts.js";
|
|
5
|
+
import { createIndependentVerifierOp, getIndependentReviewOp, recordIndependentFindingOp, resolveIndependentFindingOp } from "../handlers/review.js";
|
|
6
|
+
import { defineTool, run } from "./run.js";
|
|
7
|
+
|
|
8
|
+
const FACT_ACTIONS = {
|
|
9
|
+
search: (args) => run(searchWorkerFactsOp, { task_id: args.task_id, query: args.query, limit: args.limit, cursor: args.cursor }),
|
|
10
|
+
get: (args) => run(getFactOp, { fact_id: args.fact_id }),
|
|
11
|
+
promote: (args) => run(promoteWorkerFactOp, { fact_id: args.fact_id, scope: args.scope, watchedPaths: args.watched_paths, expiresAt: args.expires_at }),
|
|
12
|
+
revoke: (args) => run(revokeWorkerFactOp, { fact_id: args.fact_id, reason: args.reason })
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const factsTool = defineTool("facts", {
|
|
16
|
+
title: "Read and manage verified facts",
|
|
17
|
+
description: "The ledger of what workers established. search: verified facts visible to a worker (its own, its dependencies', and repository facts whose watched paths and base still match). get: one fact with its versions. promote: the main thread turns a worker's candidate into a verified fact. revoke: withdraw one, with a reason. A worker cannot promote its own claims.",
|
|
18
|
+
inputSchema: {
|
|
19
|
+
action: z.enum(["search", "get", "promote", "revoke"]),
|
|
20
|
+
task_id: z.string().optional().describe("search"),
|
|
21
|
+
fact_id: z.string().optional().describe("get, promote, revoke"),
|
|
22
|
+
query: z.string().optional(),
|
|
23
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
24
|
+
cursor: z.string().optional(),
|
|
25
|
+
scope: z.enum(["work_item", "repo_verified"]).optional().describe("promote"),
|
|
26
|
+
watched_paths: z.array(z.string()).optional().describe("promote to repo_verified: paths whose change expires the fact"),
|
|
27
|
+
expires_at: z.string().optional(),
|
|
28
|
+
reason: z.string().optional().describe("revoke")
|
|
29
|
+
}
|
|
30
|
+
}, (args) => FACT_ACTIONS[args.action](args));
|
|
31
|
+
|
|
32
|
+
const REVIEW_ACTIONS = {
|
|
33
|
+
start: (args) => run(createIndependentVerifierOp, { task_id: args.task_id, title: args.title }),
|
|
34
|
+
record: (args) => run(recordIndependentFindingOp, { verifier_task_id: args.verifier_task_id, verdict: args.verdict, reason: args.reason }),
|
|
35
|
+
resolve: (args) => run(resolveIndependentFindingOp, { verifier_task_id: args.verifier_task_id, resolution: args.resolution }),
|
|
36
|
+
get: (args) => run(getIndependentReviewOp, { verifier_task_id: args.verifier_task_id })
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const reviewTool = defineTool("review", {
|
|
40
|
+
title: "Have settled work checked independently",
|
|
41
|
+
description: "start: dispatch a read-only, offline verifier that sees the goal and the worktree but not the worker's own report. record: store its verdict. resolve: store how a finding was closed. get: the whole trail.",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
action: z.enum(["start", "record", "resolve", "get"]),
|
|
44
|
+
task_id: z.string().optional().describe("start: the worker to verify"),
|
|
45
|
+
verifier_task_id: z.string().optional().describe("record, resolve, get"),
|
|
46
|
+
title: z.string().optional(),
|
|
47
|
+
verdict: z.enum(["passes", "fails", "inconclusive"]).optional(),
|
|
48
|
+
reason: z.string().optional(),
|
|
49
|
+
resolution: z.string().optional()
|
|
50
|
+
}
|
|
51
|
+
}, (args) => REVIEW_ACTIONS[args.action](args));
|
|
52
|
+
|
|
53
|
+
export const getArtifactTool = defineTool("get_artifact", {
|
|
54
|
+
title: "Read a stored evidence artifact",
|
|
55
|
+
description: "One artifact the supervisor kept (a push proof, a review finding), by the id found in get_worker evidence.",
|
|
56
|
+
inputSchema: { artifact_id: z.string(), max_chars: z.number().int().min(0).max(1000000).optional() }
|
|
57
|
+
}, (args) => run(getArtifactOp, { artifact_id: args.artifact_id, maxChars: args.max_chars }));
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getWorkerPreflightOp } from "../handlers/dispatch.js";
|
|
3
|
+
import { getContextSnapshotMetaOp, getWorkerEvidenceOp } from "../handlers/facts.js";
|
|
4
|
+
import { describeSessionOp, getCodexWorkerEventsOp, getCodexWorkerStatusOp, getSessionWorksOp, searchWorksOp } from "../handlers/overview.js";
|
|
5
|
+
import { askCodexWorkerOp, getWorkerDiffOp, getWorkerGoalOp, getWorkerResultOp, getWorkerSummaryOp } from "../handlers/results.js";
|
|
6
|
+
import { asData, defineTool, isFailure, run } from "./run.js";
|
|
7
|
+
import { acceptanceCommands } from "./shapes.js";
|
|
8
|
+
|
|
9
|
+
const PARTS = ["status", "result", "goal", "events", "evidence", "context", "preflight", "prompt"];
|
|
10
|
+
|
|
11
|
+
// A read that found the worker returns its row, which always has a status;
|
|
12
|
+
// "task_not_found" and the like do not. Only the former is data.
|
|
13
|
+
const row = async (reading) => {
|
|
14
|
+
const payload = await reading;
|
|
15
|
+
return payload?.status === undefined ? payload : asData(payload);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Each part of a worker and the operation that reads it.
|
|
19
|
+
const READERS = {
|
|
20
|
+
status: (args) => row(run(getCodexWorkerStatusOp, { task_id: args.task_id, includePrompt: args.include.includes("prompt") })),
|
|
21
|
+
result: (args) => row(run(getWorkerResultOp, {
|
|
22
|
+
task_id: args.task_id, maxChars: args.max_chars, limit: args.result_limit, includeFiles: args.include_files
|
|
23
|
+
})),
|
|
24
|
+
goal: (args) => run(getWorkerGoalOp, { task_id: args.task_id }),
|
|
25
|
+
events: (args) => run(getCodexWorkerEventsOp, { task_id: args.task_id, limit: args.event_limit, kinds: args.event_kinds, maxChars: args.max_chars }),
|
|
26
|
+
evidence: (args) => run(getWorkerEvidenceOp, { task_id: args.task_id }),
|
|
27
|
+
context: (args) => run(getContextSnapshotMetaOp, { task_id: args.task_id }),
|
|
28
|
+
preflight: (args) => row(run(getWorkerPreflightOp, { task_id: args.task_id }))
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getWorkerTool = defineTool("get_worker", {
|
|
32
|
+
title: "Read one worker",
|
|
33
|
+
description: "One worker, in the parts you ask for. No include: a one-paragraph summary; one part: that part; several: an object keyed by part. result: its report, the supervisor's acceptance verdict and the commands it really ran. status: live state. events: the raw stream. goal: objective and token use. preflight: a probe's verdict. evidence, context: what was recorded and given. prompt: the task text. A report is a claim; acceptance and get_worker_diff are the evidence.",
|
|
34
|
+
inputSchema: {
|
|
35
|
+
task_id: z.string(),
|
|
36
|
+
include: z.array(z.enum(PARTS)).default([]),
|
|
37
|
+
max_chars: z.number().int().min(0).max(1000000).optional().describe("Cap on report or event text; default 6000 for result"),
|
|
38
|
+
event_limit: z.number().int().min(1).max(1000).optional(),
|
|
39
|
+
event_kinds: z.array(z.string()).optional(),
|
|
40
|
+
result_limit: z.number().int().min(1).max(20).optional().describe("Earlier runs too"),
|
|
41
|
+
include_files: z.boolean().optional().describe("List changed files")
|
|
42
|
+
}
|
|
43
|
+
}, async (args) => {
|
|
44
|
+
const wanted = args.include.includes("prompt") && !args.include.includes("status") ? [...args.include, "status"] : args.include;
|
|
45
|
+
const parts = wanted.filter((part) => READERS[part]);
|
|
46
|
+
if (parts.length === 0) return row(run(getWorkerSummaryOp, { task_id: args.task_id }));
|
|
47
|
+
// One part comes back as itself; several come back keyed by part.
|
|
48
|
+
if (parts.length === 1) return READERS[parts[0]]({ ...args, include: wanted });
|
|
49
|
+
const out = { task_id: args.task_id };
|
|
50
|
+
for (const part of parts) {
|
|
51
|
+
const payload = await READERS[part]({ ...args, include: wanted });
|
|
52
|
+
if (isFailure(payload)) return payload;
|
|
53
|
+
out[part] = payload;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const getWorkerDiffTool = defineTool("get_worker_diff", {
|
|
59
|
+
title: "Read what a worker changed",
|
|
60
|
+
description: "The worker's actual changes against its base, committed or not. Without file: the list of files with line counts and hunk counts. With file: that file's patch, paged by hunk (cursor from the previous page). Read this before landing; it is what the worker did, whatever it reported.",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
task_id: z.string(),
|
|
63
|
+
file: z.string().optional(),
|
|
64
|
+
hunk: z.number().int().min(0).optional().describe("Start at this hunk of the file"),
|
|
65
|
+
page_size: z.number().int().min(1).max(20).default(4).describe("Hunks per page"),
|
|
66
|
+
cursor: z.string().optional(),
|
|
67
|
+
max_chars: z.number().int().min(0).max(1000000).optional().describe("With no file: return every patch in one reply, capped at this size"),
|
|
68
|
+
paths: z.array(z.string()).optional().describe("Limit the diff to these paths")
|
|
69
|
+
}
|
|
70
|
+
}, (args) => run(getWorkerDiffOp, {
|
|
71
|
+
task_id: args.task_id, file: args.file, hunk: args.hunk, pageSize: args.page_size, cursor: args.cursor, maxChars: args.max_chars, paths: args.paths
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
export const askWorkerTool = defineTool("ask_worker", {
|
|
75
|
+
title: "Ask a worker a side question",
|
|
76
|
+
description: "Ask the worker why it did something without touching its work: its thread is forked into a read-only session with no network and no MCP tools, and the fork answers. Follow-up questions continue that fork; fresh starts a new one from the worker's current thread, end deletes it.",
|
|
77
|
+
inputSchema: {
|
|
78
|
+
task_id: z.string(),
|
|
79
|
+
question: z.string().optional(),
|
|
80
|
+
timeout_ms: z.number().int().min(1000).max(600000).default(110000),
|
|
81
|
+
max_chars: z.number().int().min(0).max(1000000).default(8000),
|
|
82
|
+
fresh: z.boolean().default(false),
|
|
83
|
+
end: z.boolean().default(false)
|
|
84
|
+
}
|
|
85
|
+
}, (args) => run(askCodexWorkerOp, {
|
|
86
|
+
task_id: args.task_id, question: args.question, timeoutMs: args.timeout_ms, maxChars: args.max_chars, fresh: args.fresh, end: args.end
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
export const findWorksTool = defineTool("find_works", {
|
|
90
|
+
title: "Find earlier work",
|
|
91
|
+
description: "Every worker of one session, or a substring search over titles, goals, prompts and last messages, newest first. Use it before dispatching to see whether the work was already done, and after a restart to pick a batch up again.",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
session_id: z.string().optional(),
|
|
94
|
+
query: z.string().optional(),
|
|
95
|
+
limit: z.number().int().min(1).max(100).optional()
|
|
96
|
+
}
|
|
97
|
+
}, (args) => {
|
|
98
|
+
if (args.session_id) return run(getSessionWorksOp, { session_id: args.session_id });
|
|
99
|
+
if (args.query) return run(searchWorksOp, { query: args.query, limit: args.limit });
|
|
100
|
+
return { error: "invalid_arguments", message: "give session_id or query" };
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const describeSessionTool = defineTool("describe_session", {
|
|
104
|
+
title: "Describe a batch",
|
|
105
|
+
description: "Record what a session is for and the rules its workers share: a title and note, an objective, acceptance commands added to every worker of the session, and an approval state. waiting_user stops dispatch, resume and landing in the session until it is approved again.",
|
|
106
|
+
inputSchema: {
|
|
107
|
+
session_id: z.string(),
|
|
108
|
+
title: z.string().max(120).optional(),
|
|
109
|
+
note: z.string().max(2000).optional(),
|
|
110
|
+
objective: z.string().max(5000).optional(),
|
|
111
|
+
default_acceptance: z.array(z.union([z.string(), z.record(z.string(), z.unknown())])).max(10).optional(),
|
|
112
|
+
approval_state: z.enum(["approved", "waiting_user"]).optional(),
|
|
113
|
+
expected_revision: z.number().int().nonnegative().optional().describe("Refuse the change if the session policy moved past this revision")
|
|
114
|
+
}
|
|
115
|
+
}, (args) => run(describeSessionOp, { ...args, default_acceptance: acceptanceCommands(args.default_acceptance) }));
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// How a public tool reaches the operation behind it. An operation validates
|
|
2
|
+
// its own input and answers with a text result; a tool maps the public
|
|
3
|
+
// arguments onto it and shapes the reply.
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { textResult } from "../result.js";
|
|
6
|
+
|
|
7
|
+
const defined = (object) => Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined));
|
|
8
|
+
|
|
9
|
+
// Runs one operation and returns its payload as a plain value.
|
|
10
|
+
export async function run(op, args, extra) {
|
|
11
|
+
const parsed = op.input.safeParse(defined(args));
|
|
12
|
+
if (!parsed.success) {
|
|
13
|
+
const issue = parsed.error.issues[0];
|
|
14
|
+
return { error: "invalid_arguments", message: `${issue.path.join(".") || "arguments"}: ${issue.message}` };
|
|
15
|
+
}
|
|
16
|
+
const result = await op.handler(parsed.data, extra);
|
|
17
|
+
const text = result?.content?.[0]?.text ?? "null";
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(text);
|
|
20
|
+
} catch {
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// A worker's row has an `error` field of its own: the text of what went wrong
|
|
26
|
+
// with the worker. Reading a failed worker is a successful call, so a payload
|
|
27
|
+
// that is such a row is marked as data and its `error` is left alone.
|
|
28
|
+
const DATA = Symbol("data");
|
|
29
|
+
|
|
30
|
+
export function asData(payload) {
|
|
31
|
+
if (payload && typeof payload === "object") Object.defineProperty(payload, DATA, { value: true });
|
|
32
|
+
return payload;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const isFailure = (payload) => Boolean(payload) && typeof payload === "object" && typeof payload.error === "string" && !payload[DATA];
|
|
36
|
+
|
|
37
|
+
// A payload whose top level carries `error` is a failed call, and says so in
|
|
38
|
+
// the protocol as well as in the text.
|
|
39
|
+
export function reply(payload) {
|
|
40
|
+
const result = textResult(payload);
|
|
41
|
+
if (isFailure(payload)) result.isError = true;
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Unknown arguments are refused, not dropped: a caller still using a name from
|
|
46
|
+
// an older version gets told so instead of running with a silent default.
|
|
47
|
+
export function defineTool(name, config, handler) {
|
|
48
|
+
return [name, { ...config, inputSchema: z.strictObject(config.inputSchema) }, async (args, extra) => {
|
|
49
|
+
try {
|
|
50
|
+
return reply(await handler(args ?? {}, extra));
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return reply({ error: error.code ?? "internal_error", message: error.message });
|
|
53
|
+
}
|
|
54
|
+
}];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { defined };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The argument groups dispatch and preflight share, and the mapping from the
|
|
2
|
+
// public names onto the operations' own.
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
// The public schema describes each group in one line instead of spelling out
|
|
6
|
+
// every nested field: the nested JSON Schema cost more context than every
|
|
7
|
+
// other tool put together. The operation behind the tool validates the
|
|
8
|
+
// fields strictly, so a wrong key or value still comes back as a clear error.
|
|
9
|
+
export const group = (text) => z.looseObject({}).optional().describe(text);
|
|
10
|
+
|
|
11
|
+
export const sandboxShape = group("{mode: read-only | workspace-write (default) | danger-full-access, network_access, writable_roots: [abs dirs], allowed_commands: [commands; trailing * = prefix], forbid: [paths or commands]}");
|
|
12
|
+
|
|
13
|
+
export const workspaceShape = group("{kind: git_worktree (default) | read_only_in_place | scratch | in_place_write, base_ref, setup: {links: [{path, source}], submodules, commands} run first, in_place_authorization, external_outputs: [{path}]}");
|
|
14
|
+
|
|
15
|
+
export const contextShape = group("{files: [{path}] abs paths to read, contracts: [binding statements]}");
|
|
16
|
+
|
|
17
|
+
export const acceptanceShape = group("{commands, timeout_ms}: shell commands the supervisor runs in the worktree after the worker exits; all must exit 0");
|
|
18
|
+
|
|
19
|
+
export const limitsShape = group("{max_run_ms, max_total_ms}");
|
|
20
|
+
|
|
21
|
+
const check = (entry) => (typeof entry === "string" ? entry : { command: entry.command, reportPath: entry.report_path ?? entry.reportPath, baseline: entry.baseline });
|
|
22
|
+
|
|
23
|
+
// Public acceptance commands -> the operations' shape.
|
|
24
|
+
export function acceptanceCommands(commands) {
|
|
25
|
+
if (commands === undefined) return undefined;
|
|
26
|
+
return Array.isArray(commands) ? commands.map(check) : commands;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Public dispatch arguments -> the flat names the operations take.
|
|
30
|
+
export function dispatchOptions(args) {
|
|
31
|
+
const { sandbox = {}, workspace = {}, context = {}, acceptance, limits = {}, session = {}, goal } = args;
|
|
32
|
+
return {
|
|
33
|
+
title: args.title,
|
|
34
|
+
cwd: args.cwd,
|
|
35
|
+
model: args.model,
|
|
36
|
+
reasoningEffort: args.reasoning_effort,
|
|
37
|
+
ownedPaths: args.owned_paths,
|
|
38
|
+
goal: goal ? { objective: goal.objective, tokenBudget: goal.token_budget } : undefined,
|
|
39
|
+
session_id: session.id,
|
|
40
|
+
session_title: session.title,
|
|
41
|
+
session_note: session.note,
|
|
42
|
+
sandbox: sandbox.mode,
|
|
43
|
+
networkAccess: sandbox.network_access,
|
|
44
|
+
writableRoots: sandbox.writable_roots,
|
|
45
|
+
allowedCommands: sandbox.allowed_commands,
|
|
46
|
+
forbid: sandbox.forbid,
|
|
47
|
+
workspaceKind: workspace.kind,
|
|
48
|
+
baseRef: workspace.base_ref,
|
|
49
|
+
workspaceSetup: workspace.setup,
|
|
50
|
+
inPlaceAuthorization: workspace.in_place_authorization,
|
|
51
|
+
skipGitRepoCheck: workspace.skip_git_repo_check,
|
|
52
|
+
externalOutputs: workspace.external_outputs,
|
|
53
|
+
context: context.files,
|
|
54
|
+
contracts: context.contracts,
|
|
55
|
+
acceptance: acceptanceCommands(acceptance?.commands),
|
|
56
|
+
acceptanceTimeoutMs: acceptance?.timeout_ms,
|
|
57
|
+
maxRunMs: limits.max_run_ms,
|
|
58
|
+
maxTotalMs: limits.max_total_ms
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Keeps only the names an operation knows, so one mapping serves several.
|
|
63
|
+
export function only(op, options) {
|
|
64
|
+
const known = new Set(Object.keys(op.input.shape));
|
|
65
|
+
return Object.fromEntries(Object.entries(options).filter(([key, value]) => known.has(key) && value !== undefined));
|
|
66
|
+
}
|