agent-supervisor-mcp 0.0.0-stage → 2.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/LICENSE +21 -0
- package/README.en.md +208 -0
- package/README.md +206 -2
- package/package.json +76 -4
- package/skills/agent-supervisor/SKILL.md +139 -0
- package/src/app/acceptance.js +263 -0
- package/src/app/auto-cleanup.js +91 -0
- package/src/app/cancel.js +57 -0
- package/src/app/cleanup-facts.js +101 -0
- package/src/app/cleanup-plan.js +166 -0
- package/src/app/compose.js +17 -0
- package/src/app/context-compiler.js +83 -0
- package/src/app/dispatch.js +398 -0
- package/src/app/followup.js +104 -0
- package/src/app/land-chain.js +134 -0
- package/src/app/landing.js +357 -0
- package/src/app/ownership.js +57 -0
- package/src/app/rebase.js +216 -0
- package/src/app/restore-worktree.js +51 -0
- package/src/app/resume.js +179 -0
- package/src/app/run-state.js +26 -0
- package/src/app/settled.js +28 -0
- package/src/app/side-chat.js +370 -0
- package/src/app/sse.js +20 -0
- package/src/app/start-run.js +77 -0
- package/src/app/verify-push.js +114 -0
- package/src/app/worktree-setup.js +218 -0
- package/src/domain/acceptance-baseline.js +65 -0
- package/src/domain/acceptance-spec.js +30 -0
- package/src/domain/cleanup-policy.js +44 -0
- package/src/domain/command-outcome.js +6 -0
- package/src/domain/failure-class.js +63 -0
- package/src/domain/owned-changes.js +27 -0
- package/src/domain/prompt.js +161 -0
- package/src/domain/side-turn-view.js +73 -0
- package/src/domain/status.js +50 -0
- package/src/domain/thread-health.js +33 -0
- package/src/domain/truncate.js +148 -0
- package/src/domain/worker-branch.js +6 -0
- package/src/domain/worker-changes.js +58 -0
- package/src/domain/worker-env.js +14 -0
- package/src/domain/worker-preflight.js +167 -0
- package/src/domain/worker-report.js +85 -0
- package/src/domain/worker-report.schema.json +10 -0
- package/src/infra/bin-resolver.js +287 -0
- package/src/infra/cleanup-hint.js +29 -0
- package/src/infra/crash-guard.js +44 -0
- package/src/infra/external-output.js +29 -0
- package/src/infra/git.js +61 -0
- package/src/infra/handoff.js +38 -0
- package/src/infra/paths.js +34 -0
- package/src/infra/process.js +59 -0
- package/src/infra/sandbox-roots.js +106 -0
- package/src/infra/skill-sync.js +109 -0
- package/src/infra/stage-store.js +39 -0
- package/src/infra/store/db.js +265 -0
- package/src/infra/store/event-body.js +82 -0
- package/src/infra/store/events.js +149 -0
- package/src/infra/store/facts.js +338 -0
- package/src/infra/store/reconcile.js +173 -0
- package/src/infra/store/records.js +171 -0
- package/src/infra/store/runner-readers.js +16 -0
- package/src/infra/store/schema.js +306 -0
- package/src/infra/store/sessions.js +138 -0
- package/src/infra/store/tasks.js +351 -0
- package/src/infra/update/auto-update-worker.js +186 -0
- package/src/infra/update/auto-update.js +143 -0
- package/src/infra/update/update-check.js +246 -0
- package/src/infra/workspace-kind.js +165 -0
- package/src/infra/worktree.js +361 -0
- package/src/interface/bin/acceptance-cli.js +62 -0
- package/src/interface/bin/cleanup.js +81 -0
- package/src/interface/bin/monitor.jsx +301 -0
- package/src/interface/bin/setup.js +342 -0
- package/src/interface/bin/stage.js +17 -0
- package/src/interface/bin/web-server.js +53 -0
- package/src/interface/mcp/handlers/delivery.js +165 -0
- package/src/interface/mcp/handlers/dispatch.js +236 -0
- package/src/interface/mcp/handlers/facts.js +204 -0
- package/src/interface/mcp/handlers/overview.js +106 -0
- package/src/interface/mcp/handlers/results.js +262 -0
- package/src/interface/mcp/handlers/review.js +115 -0
- package/src/interface/mcp/handlers/wait.js +141 -0
- package/src/interface/mcp/meta.js +7 -0
- package/src/interface/mcp/result.js +34 -0
- package/src/interface/mcp/schemas.js +24 -0
- package/src/interface/mcp/server.js +64 -0
- package/src/interface/mcp/tools/deliver.js +48 -0
- package/src/interface/mcp/tools/dispatch.js +90 -0
- 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 +67 -0
- package/src/interface/mcp/tools/track.js +84 -0
- package/src/interface/mcp/update-state.js +34 -0
- package/src/interface/mcp/views/overview.js +183 -0
- package/src/interface/mcp/views/task.js +224 -0
- package/src/interface/web/app.js +226 -0
- package/src/interface/web/views.js +227 -0
- package/src/mcp-server.js +4 -0
- package/src/run-host/entry.js +26 -0
- package/src/run-host/finalize.js +243 -0
- package/src/run-host/launch.js +49 -0
- package/src/run-host/live-run.js +76 -0
- package/src/run-host/outcome-facts.js +61 -0
- package/src/run-host/streams.js +102 -0
- package/src/run-host/track.js +132 -0
- package/src/runners/claude/adapter.js +118 -0
- package/src/runners/claude/events.js +100 -0
- package/src/runners/claude/tool-guard.js +48 -0
- package/src/runners/codex/adapter.js +157 -0
- package/src/runners/codex/chat-chunks.js +97 -0
- package/src/runners/codex/event-parser.js +266 -0
- package/src/runners/codex/goal-store.js +54 -0
- package/src/runners/codex/mcp-config.js +39 -0
- package/src/runners/codex/tool-guard.js +184 -0
- package/src/runners/contract-check.js +82 -0
- package/src/runners/contract.js +53 -0
- package/src/runners/registry.js +45 -0
- package/web/dist/assets/index-D-A2xlpx.js +154 -0
- package/web/dist/assets/index-f8esISCp.css +2 -0
- package/web/dist/index.html +15 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Entry for `agent-supervisor-web`. Decides which store to open, then starts
|
|
3
|
+
// the board (web/app.js).
|
|
4
|
+
//
|
|
5
|
+
// agent-supervisor-web # http://127.0.0.1:7877
|
|
6
|
+
// SUPERVISOR_WEB_PORT=8080 agent-supervisor-web
|
|
7
|
+
// SUPERVISOR_HOME=/path/to/state agent-supervisor-web
|
|
8
|
+
//
|
|
9
|
+
// The store has to be the one the MCP server writes. Without SUPERVISOR_HOME
|
|
10
|
+
// in the environment, the nearest .mcp.json above the current directory is
|
|
11
|
+
// read: a project that configures agent-supervisor with its own
|
|
12
|
+
// SUPERVISOR_HOME gets a board on that store without retyping the path.
|
|
13
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
14
|
+
import { dirname, join, resolve } from "node:path";
|
|
15
|
+
|
|
16
|
+
export function storeFromMcpConfig(startDir) {
|
|
17
|
+
let dir = resolve(startDir);
|
|
18
|
+
for (;;) {
|
|
19
|
+
const file = join(dir, ".mcp.json");
|
|
20
|
+
if (existsSync(file)) {
|
|
21
|
+
try {
|
|
22
|
+
const config = JSON.parse(readFileSync(file, "utf8"));
|
|
23
|
+
// The entry may still be under the package's former name.
|
|
24
|
+
const servers = config?.mcpServers ?? {};
|
|
25
|
+
const home = (servers["agent-supervisor"] ?? servers["codex-supervisor"])?.env?.SUPERVISOR_HOME;
|
|
26
|
+
if (typeof home === "string" && home.trim()) return { home: resolve(dir, home.trim()), file };
|
|
27
|
+
} catch {
|
|
28
|
+
// an unreadable .mcp.json is somebody else's problem; keep walking
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const parent = dirname(dir);
|
|
32
|
+
if (parent === dir) return null;
|
|
33
|
+
dir = parent;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let storeOrigin = "SUPERVISOR_HOME";
|
|
38
|
+
if (!process.env.SUPERVISOR_HOME?.trim()) {
|
|
39
|
+
const found = storeFromMcpConfig(process.cwd());
|
|
40
|
+
if (found) {
|
|
41
|
+
process.env.SUPERVISOR_HOME = found.home;
|
|
42
|
+
storeOrigin = `from ${found.file}`;
|
|
43
|
+
} else {
|
|
44
|
+
storeOrigin = "default, no SUPERVISOR_HOME and no .mcp.json above the current directory";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// paths.js reads SUPERVISOR_HOME when it is first imported, so the import
|
|
49
|
+
// has to come after the detection above.
|
|
50
|
+
const { installCrashGuard } = await import("../../infra/crash-guard.js");
|
|
51
|
+
installCrashGuard("web");
|
|
52
|
+
const { startWebServer } = await import("../web/app.js");
|
|
53
|
+
startWebServer({ storeOrigin });
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { verifyDeliveryPush } from "../../../app/verify-push.js";
|
|
2
|
+
import { applyCleanupPlan, createCleanupPlan } from "../../../app/cleanup-plan.js";
|
|
3
|
+
import { followupChainIds, git, landOneWorkerTask } from "../../../app/land-chain.js";
|
|
4
|
+
import { cancelCodexWorker } from "../../../app/cancel.js";
|
|
5
|
+
import { ACTIVE_STATUSES } from "../../../domain/status.js";
|
|
6
|
+
import { getCleanupPlan, readCleanupHistory, saveCleanupPlan } from "../../../infra/store/records.js";
|
|
7
|
+
import { getTask, upsertTask } from "../../../infra/store/tasks.js";
|
|
8
|
+
import { errorResult, textResult } from "../result.js";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
export const landCodexWorkerOp = {
|
|
12
|
+
input: z.object({
|
|
13
|
+
task_id: z.string().min(1),
|
|
14
|
+
onto: z.string().min(1).optional(),
|
|
15
|
+
commitMessage: z.string().min(1).optional(),
|
|
16
|
+
includeFollowupParents: z.boolean().default(false),
|
|
17
|
+
commitMessages: z.record(z.string(), z.string().min(1)).optional(),
|
|
18
|
+
ignoreAcceptance: z.boolean().default(false),
|
|
19
|
+
allowOutsideOwned: z.boolean().default(false)
|
|
20
|
+
}),
|
|
21
|
+
handler: async ({ task_id, onto, commitMessage, includeFollowupParents, commitMessages, ignoreAcceptance, allowOutsideOwned }) => {
|
|
22
|
+
if (!includeFollowupParents) {
|
|
23
|
+
const task = await getTask(task_id);
|
|
24
|
+
if (task?.followup_of) {
|
|
25
|
+
let ids;
|
|
26
|
+
try { ids = await followupChainIds(task_id); }
|
|
27
|
+
catch (error) { return textResult({ error: "invalid_followup_chain", task_id, reason: error.message }); }
|
|
28
|
+
const unlanded = [];
|
|
29
|
+
for (const id of ids.slice(0, -1)) {
|
|
30
|
+
const ancestor = await getTask(id);
|
|
31
|
+
if (ancestor) {
|
|
32
|
+
try {
|
|
33
|
+
if (!ancestor.landed_at || !ancestor.landed_head) throw new Error("parent not landed");
|
|
34
|
+
git(task.project_root, ["merge-base", "--is-ancestor", ancestor.landed_head, "HEAD"]);
|
|
35
|
+
} catch { unlanded.push(id); }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (unlanded.length) {
|
|
39
|
+
return textResult({
|
|
40
|
+
error: "followup_parents_not_landed",
|
|
41
|
+
task_id,
|
|
42
|
+
unlanded,
|
|
43
|
+
reason: "this follow-up starts from its parent branch; landing only the leaf would integrate a partial chain. Use include_followup_parents: true after reviewing every task's acceptance and diff."
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return textResult(await landOneWorkerTask(task_id, { onto, commitMessage, ignoreAcceptance, allowOutsideOwned }));
|
|
48
|
+
}
|
|
49
|
+
let ids;
|
|
50
|
+
try { ids = await followupChainIds(task_id); }
|
|
51
|
+
catch (error) { return textResult({ error: "invalid_followup_chain", task_id, reason: error.message }); }
|
|
52
|
+
const chain = [];
|
|
53
|
+
for (const id of ids) {
|
|
54
|
+
let result;
|
|
55
|
+
try { result = await landOneWorkerTask(id, {
|
|
56
|
+
onto,
|
|
57
|
+
commitMessage: commitMessages?.[id] ?? (id === task_id ? commitMessage : null),
|
|
58
|
+
ignoreAcceptance: id === task_id && ignoreAcceptance,
|
|
59
|
+
allowOutsideOwned: id === task_id && allowOutsideOwned,
|
|
60
|
+
skipAlreadyLanded: true
|
|
61
|
+
}); } catch (error) {
|
|
62
|
+
result = { task_id: id, error: "landing_failed", reason: error.message };
|
|
63
|
+
}
|
|
64
|
+
if (id !== task_id && result.error === "nothing_to_land"
|
|
65
|
+
&& (result.uncommitted ?? []).length === 0 && !(result.already_landed?.length)) {
|
|
66
|
+
chain.push({ ...result, error: null, skipped: "no_changes" });
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (result.skipped === "already_in_target" && (result.uncommitted ?? []).length === 0) {
|
|
70
|
+
chain.push({ ...result, error: null, skipped: "already_in_target" });
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
chain.push(result);
|
|
74
|
+
if (result.error) {
|
|
75
|
+
return textResult({ error: "followup_chain_land_failed", task_id, failed_task_id: id, chain });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return textResult({ task_id, chain });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const verifyDeliveryPushOp = {
|
|
83
|
+
input: z.object({
|
|
84
|
+
task_id: z.string().min(1),
|
|
85
|
+
remote: z.string().min(1).default("origin"),
|
|
86
|
+
branch: z.string().min(1).optional()
|
|
87
|
+
}),
|
|
88
|
+
handler: async ({ task_id, remote, branch }) => textResult(await verifyDeliveryPush({ taskId: task_id, remote, branch }))
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const cleanupPlanOp = {
|
|
92
|
+
input: z.object({
|
|
93
|
+
task_ids: z.array(z.string().min(1)).max(200).optional(),
|
|
94
|
+
project_root: z.string().min(1).optional()
|
|
95
|
+
}),
|
|
96
|
+
handler: async ({ task_ids, project_root }) => {
|
|
97
|
+
try {
|
|
98
|
+
const plan = await createCleanupPlan({ taskIds: task_ids ?? null, projectRoot: project_root ?? null });
|
|
99
|
+
await saveCleanupPlan(plan);
|
|
100
|
+
return textResult({
|
|
101
|
+
plan_id: plan.id,
|
|
102
|
+
generated_at: plan.generated_at,
|
|
103
|
+
expires_at: plan.expires_at,
|
|
104
|
+
policy: plan.policy,
|
|
105
|
+
summary: plan.summary,
|
|
106
|
+
items: plan.items
|
|
107
|
+
});
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return errorResult(error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const applyCleanupOp = {
|
|
115
|
+
input: z.object({
|
|
116
|
+
plan_id: z.string().uuid(),
|
|
117
|
+
item_ids: z.array(z.string().uuid()).min(1).max(200)
|
|
118
|
+
}),
|
|
119
|
+
handler: async ({ plan_id, item_ids }) => {
|
|
120
|
+
const plan = await getCleanupPlan(plan_id);
|
|
121
|
+
if (!plan) return textResult({ error: "cleanup_plan_not_found", plan_id });
|
|
122
|
+
if (Date.parse(plan.expires_at) <= Date.now()) return textResult({ error: "cleanup_plan_expired", plan_id, expires_at: plan.expires_at });
|
|
123
|
+
return textResult(await applyCleanupPlan({ plan, itemIds: item_ids, actor: "main_thread" }));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const cleanupHistoryOp = {
|
|
128
|
+
input: z.object({ task_id: z.string().min(1).optional(), limit: z.number().int().min(1).max(500).default(100) }),
|
|
129
|
+
handler: async ({ task_id, limit }) => textResult({ items: await readCleanupHistory(task_id ?? null, limit) })
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const cancelCodexWorkerOp = {
|
|
133
|
+
input: z.object({
|
|
134
|
+
task_id: z.string().min(1)
|
|
135
|
+
}),
|
|
136
|
+
handler: async ({ task_id }) => {
|
|
137
|
+
const now = new Date().toISOString();
|
|
138
|
+
const task = await getTask(task_id);
|
|
139
|
+
// The marker is persisted before the signal is sent so the process that
|
|
140
|
+
// owns the worker reports "cancelled" instead of "lost" when it exits.
|
|
141
|
+
if (task && ACTIVE_STATUSES.has(task.status)) {
|
|
142
|
+
await upsertTask({ ...task, cancel_requested_at: now, updated_at: now });
|
|
143
|
+
}
|
|
144
|
+
const result = await cancelCodexWorker(task_id);
|
|
145
|
+
// A cancel that stopped an acceptance run leaves the worker's own
|
|
146
|
+
// terminal status in place; the exit handler records the verdict.
|
|
147
|
+
if (result.cancelled && task && result.via !== "acceptance") {
|
|
148
|
+
// The run host may have written the terminal row while the signal was
|
|
149
|
+
// being delivered. Read the row again and only close one that is still
|
|
150
|
+
// open; writing the earlier snapshot back would undo that final write.
|
|
151
|
+
const current = await getTask(task_id);
|
|
152
|
+
if (current && ACTIVE_STATUSES.has(current.status)) {
|
|
153
|
+
await upsertTask({
|
|
154
|
+
...current,
|
|
155
|
+
status: "cancelled",
|
|
156
|
+
phase: null,
|
|
157
|
+
cancel_requested_at: now,
|
|
158
|
+
updated_at: now,
|
|
159
|
+
completed_at: current.completed_at ?? now
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return textResult(result);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
@@ -0,0 +1,236 @@
|
|
|
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
|
+
import { z } from "zod";
|
|
15
|
+
|
|
16
|
+
export const checkAcceptanceOp = {
|
|
17
|
+
input: z.object({
|
|
18
|
+
cwd: z.string().min(1), acceptance: acceptanceInput,
|
|
19
|
+
baseRef: z.string().min(1).optional(), timeoutMs: z.number().int().min(1000).max(1800000).default(600000)
|
|
20
|
+
}),
|
|
21
|
+
handler: async ({ cwd, acceptance, baseRef = "HEAD", timeoutMs }) => {
|
|
22
|
+
let base;
|
|
23
|
+
try {
|
|
24
|
+
base = runGit(cwd, ["rev-parse", "--verify", `${baseRef}^{commit}`], { timeout: 10000 });
|
|
25
|
+
} catch {
|
|
26
|
+
return textResult({ error: "invalid_base_ref", phase: "preflight", reason: `workspace.base_ref does not resolve in ${cwd}`, proves_worker_completion: false });
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const commands = Array.isArray(acceptance) ? acceptance : [acceptance];
|
|
30
|
+
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");
|
|
31
|
+
const result = await runAcceptance(commands, { cwd, timeoutMs, baseCommit: base, taskId: `preflight-${randomUUID()}` });
|
|
32
|
+
return textResult({ ...result, phase: "preflight", base_commit: base, proves_worker_completion: false, warnings });
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return errorResult(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const preflightCodexWorkerOp = {
|
|
40
|
+
input: z.object({
|
|
41
|
+
title: z.string().optional(),
|
|
42
|
+
runner: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/).optional(),
|
|
43
|
+
cwd: z.string().min(1),
|
|
44
|
+
sandbox: z.enum(["read-only", "workspace-write", "danger-full-access"]).default("workspace-write"),
|
|
45
|
+
model: z.string().optional(),
|
|
46
|
+
reasoningEffort: z.enum(["minimal", "low", "medium", "high"]).default("high"),
|
|
47
|
+
skipGitRepoCheck: z.boolean().default(true),
|
|
48
|
+
ownedPaths: z.array(z.string().min(1)),
|
|
49
|
+
forbid: z.array(z.string().min(1)).max(100).optional(),
|
|
50
|
+
allowedCommands: z.array(z.string().min(1)).max(100).optional(),
|
|
51
|
+
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
52
|
+
contracts: z.array(z.string().min(1).max(2000)).max(20).optional(),
|
|
53
|
+
networkAccess: z.boolean().default(false),
|
|
54
|
+
writableRoots: z.array(z.string().min(1)).max(20).optional(),
|
|
55
|
+
maxRunMs: z.number().int().min(1000).max(86400000).optional(),
|
|
56
|
+
maxTotalMs: z.number().int().min(1000).max(604800000).optional(),
|
|
57
|
+
baseRef: z.string().min(1).optional(),
|
|
58
|
+
workspaceKind: z.enum(["git_worktree", "read_only_in_place", "scratch", "in_place_write"]).optional(),
|
|
59
|
+
inPlaceAuthorization: z.string().min(1).max(2000).optional(),
|
|
60
|
+
workspaceSetup: workspaceSetupInput.optional(),
|
|
61
|
+
probeCommands: z.array(z.string().min(1)).min(1).max(20)
|
|
62
|
+
}),
|
|
63
|
+
handler: async (input) => {
|
|
64
|
+
try {
|
|
65
|
+
const task = [
|
|
66
|
+
"Runtime environment preflight. Do not edit files, create files, install packages, dispatch workers or call MCP tools.",
|
|
67
|
+
"Run every command below exactly once, in the listed order, without wrapping it in another shell command.",
|
|
68
|
+
"If any command is denied, missing, times out or exits nonzero, stop and quote the raw error under Not done / risks.",
|
|
69
|
+
"Commands:",
|
|
70
|
+
...input.probeCommands.map((command) => `- ${command}`)
|
|
71
|
+
].join("\n");
|
|
72
|
+
const record = await createCodexWorker({
|
|
73
|
+
...input,
|
|
74
|
+
title: input.title ? `Preflight: ${input.title}` : "Runtime environment preflight",
|
|
75
|
+
task,
|
|
76
|
+
goal: { objective: `Prove the requested Codex worker runtime environment before dispatching ${input.title ?? "the dependent worker"}` },
|
|
77
|
+
acceptance: null,
|
|
78
|
+
preflight: { probeCommands: input.probeCommands }
|
|
79
|
+
});
|
|
80
|
+
return textResult(withUpdate({ ...receipt(record), preflight: { status: "running", probe_commands: input.probeCommands } }));
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return errorResult(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const getWorkerPreflightOp = {
|
|
88
|
+
input: z.object({ task_id: z.string().min(1) }),
|
|
89
|
+
handler: async ({ task_id }) => {
|
|
90
|
+
const task = await getTask(task_id);
|
|
91
|
+
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
92
|
+
return textResult(readPreflightResult(task));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const createCodexWorkerOp = {
|
|
97
|
+
input: z.object({
|
|
98
|
+
title: z.string().optional(),
|
|
99
|
+
runner: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/).optional(),
|
|
100
|
+
task: z.string().min(1),
|
|
101
|
+
cwd: z.string().min(1),
|
|
102
|
+
session_id: z.string().min(1).optional(),
|
|
103
|
+
// What this batch is about, in one line, so a reader of the store sees
|
|
104
|
+
// "给 12 个接口补单测" instead of a bare session id. Set it on
|
|
105
|
+
// the first dispatch of a session; later dispatches may omit it.
|
|
106
|
+
session_title: z.string().min(1).max(120).optional(),
|
|
107
|
+
session_note: z.string().min(1).max(2000).optional(),
|
|
108
|
+
sandbox: z.enum(["read-only", "workspace-write", "danger-full-access"]).default("workspace-write"),
|
|
109
|
+
model: z.string().optional(),
|
|
110
|
+
reasoningEffort: z.enum(["minimal", "low", "medium", "high"]).default("high"),
|
|
111
|
+
skipGitRepoCheck: z.boolean().default(true),
|
|
112
|
+
// Empty is the promise that nothing lands: a read-only verifier, or a
|
|
113
|
+
// research worker that reads, fetches and reports but merges nothing.
|
|
114
|
+
ownedPaths: z.array(z.string().min(1)),
|
|
115
|
+
forbid: z.array(z.string().min(1)).max(100).optional(),
|
|
116
|
+
allowedCommands: z.array(z.string().min(1)).max(100).optional(),
|
|
117
|
+
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
118
|
+
contracts: z.array(z.string().min(1).max(2000)).max(20).optional(),
|
|
119
|
+
externalOutputs: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
120
|
+
networkAccess: z.boolean().default(false),
|
|
121
|
+
// Extra absolute directories the sandbox may write. The OS cache
|
|
122
|
+
// directory is already writable; this is for toolchains that keep a
|
|
123
|
+
// cache somewhere else (~/.m2, ~/.gradle, a vendored mirror).
|
|
124
|
+
writableRoots: z.array(z.string().min(1)).max(20).optional(),
|
|
125
|
+
maxRunMs: z.number().int().min(1000).max(86400000).optional(),
|
|
126
|
+
maxTotalMs: z.number().int().min(1000).max(604800000).optional(),
|
|
127
|
+
goal: z.object({
|
|
128
|
+
objective: z.string().min(1),
|
|
129
|
+
tokenBudget: z.number().int().positive().optional()
|
|
130
|
+
}),
|
|
131
|
+
dependsOn: z.array(z.string().min(1)).optional(),
|
|
132
|
+
// Which commit the worktree is cut from. Defaults to the repository's
|
|
133
|
+
// HEAD; pass a branch, tag or sha to build on work that is not on the
|
|
134
|
+
// main line yet (for example another worker's branch).
|
|
135
|
+
baseRef: z.string().min(1).optional(),
|
|
136
|
+
workspaceKind: z.enum(["git_worktree", "read_only_in_place", "scratch", "in_place_write"]).optional(),
|
|
137
|
+
inPlaceAuthorization: z.string().min(1).max(2000).optional(),
|
|
138
|
+
workspaceSetup: workspaceSetupInput.optional(),
|
|
139
|
+
// A successful preflight_worker task id. When present, this worker
|
|
140
|
+
// is refused unless base commit and the complete runtime contract match.
|
|
141
|
+
preflight_id: z.string().min(1).optional(),
|
|
142
|
+
// Shell commands that decide whether the work is done. The supervisor
|
|
143
|
+
// runs them in the worktree after codex exits; each must exit 0.
|
|
144
|
+
acceptance: acceptanceInput.optional(),
|
|
145
|
+
acceptanceTimeoutMs: z.number().int().min(1000).max(1800000).optional()
|
|
146
|
+
}),
|
|
147
|
+
handler: async (input) => {
|
|
148
|
+
try {
|
|
149
|
+
const record = await createCodexWorker({
|
|
150
|
+
...input,
|
|
151
|
+
preflightId: input.preflight_id ?? null,
|
|
152
|
+
sessionId: input.session_id ?? null,
|
|
153
|
+
sessionTitle: input.session_title ?? null,
|
|
154
|
+
sessionNote: input.session_note ?? null
|
|
155
|
+
});
|
|
156
|
+
return textResult(withUpdate(receipt(record)));
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return errorResult(error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const createCodexFollowupWorkerOp = {
|
|
164
|
+
input: z.object({
|
|
165
|
+
task_id: z.string().min(1),
|
|
166
|
+
followup_prompt: z.string().min(1),
|
|
167
|
+
session_id: z.string().min(1).optional(),
|
|
168
|
+
session_title: z.string().min(1).max(120).optional(),
|
|
169
|
+
session_note: z.string().min(1).max(2000).optional(),
|
|
170
|
+
title: z.string().optional(),
|
|
171
|
+
runner: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/).optional(),
|
|
172
|
+
cwd: z.string().optional(),
|
|
173
|
+
sandbox: z.enum(["read-only", "workspace-write", "danger-full-access"]).optional(),
|
|
174
|
+
model: z.string().optional(),
|
|
175
|
+
reasoningEffort: z.enum(["minimal", "low", "medium", "high"]).default("high"),
|
|
176
|
+
ownedPaths: z.array(z.string().min(1)).optional(),
|
|
177
|
+
forbid: z.array(z.string().min(1)).max(100).optional(),
|
|
178
|
+
allowedCommands: z.array(z.string().min(1)).max(100).optional(),
|
|
179
|
+
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
180
|
+
contracts: z.array(z.string().min(1).max(2000)).max(20).optional(),
|
|
181
|
+
externalOutputs: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
182
|
+
networkAccess: z.boolean().optional(),
|
|
183
|
+
writableRoots: z.array(z.string().min(1)).max(20).optional(),
|
|
184
|
+
maxRunMs: z.number().int().min(1000).max(86400000).optional(),
|
|
185
|
+
maxTotalMs: z.number().int().min(1000).max(604800000).optional(),
|
|
186
|
+
workspaceKind: z.enum(["git_worktree", "read_only_in_place", "scratch", "in_place_write"]).optional(),
|
|
187
|
+
inPlaceAuthorization: z.string().min(1).max(2000).optional(),
|
|
188
|
+
workspaceSetup: workspaceSetupInput.optional(),
|
|
189
|
+
goal: z
|
|
190
|
+
.object({
|
|
191
|
+
objective: z.string().min(1),
|
|
192
|
+
tokenBudget: z.number().int().positive().optional()
|
|
193
|
+
})
|
|
194
|
+
.optional(),
|
|
195
|
+
baseRef: z.string().min(1).optional(),
|
|
196
|
+
// Left out, the parent's acceptance commands are inherited; given, they
|
|
197
|
+
// replace them, and an empty list clears them.
|
|
198
|
+
acceptance: acceptanceInput.optional(),
|
|
199
|
+
acceptanceTimeoutMs: z.number().int().min(1000).max(1800000).optional()
|
|
200
|
+
}),
|
|
201
|
+
handler: async ({ task_id, followup_prompt, session_id, session_title, session_note, ...options }) => {
|
|
202
|
+
try {
|
|
203
|
+
const record = await createFollowupWorker({
|
|
204
|
+
taskId: task_id,
|
|
205
|
+
followupPrompt: followup_prompt,
|
|
206
|
+
sessionId: session_id ?? null,
|
|
207
|
+
sessionTitle: session_title ?? null,
|
|
208
|
+
sessionNote: session_note ?? null,
|
|
209
|
+
...options
|
|
210
|
+
});
|
|
211
|
+
return textResult(receipt(record));
|
|
212
|
+
} catch (error) {
|
|
213
|
+
return errorResult(error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export const resumeCodexWorkerOp = {
|
|
219
|
+
input: z.object({
|
|
220
|
+
task_id: z.string().min(1),
|
|
221
|
+
prompt: z.string().min(1),
|
|
222
|
+
rebaseOnto: z.string().min(1).optional(),
|
|
223
|
+
context: z.array(z.object({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional() })).max(20).optional(),
|
|
224
|
+
// Replaces the stored acceptance commands for this and later runs; an
|
|
225
|
+
// empty list clears them. Left out, the stored commands stay.
|
|
226
|
+
acceptance: acceptanceInput.optional()
|
|
227
|
+
}),
|
|
228
|
+
handler: async ({ task_id, prompt, rebaseOnto, acceptance, context }) => {
|
|
229
|
+
try {
|
|
230
|
+
const record = await resumeCodexWorker({ taskId: task_id, prompt, rebaseOnto: rebaseOnto ?? null, acceptance, context });
|
|
231
|
+
return textResult({ ...receipt(record), rebase: record.rebase ?? null, base_behind: baseBehind(record.project_root, record.base_commit) });
|
|
232
|
+
} catch (error) {
|
|
233
|
+
return errorResult(error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { git } from "../../../app/land-chain.js";
|
|
2
|
+
import { appendTaskEvent, readTaskEventRecords } from "../../../infra/store/events.js";
|
|
3
|
+
import { countVerifiedFacts, getFact, getFactEffectiveState, getTaskForWorkItem, isFactRevoked, latestContextSnapshotForTask, listContextFacts, promoteCandidateFact, revokeFact } from "../../../infra/store/facts.js";
|
|
4
|
+
import { getArtifact, listArtifactsForTask, readArtifact } from "../../../infra/store/records.js";
|
|
5
|
+
import { getTask } from "../../../infra/store/tasks.js";
|
|
6
|
+
import { runIdFor } from "../../../infra/store/db.js";
|
|
7
|
+
import { clip, errorResult, textResult } from "../result.js";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
export const getContextSnapshotMetaOp = {
|
|
11
|
+
input: z.object({ task_id: z.string().min(1) }),
|
|
12
|
+
handler: async ({ task_id }) => {
|
|
13
|
+
const task = await getTask(task_id);
|
|
14
|
+
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
15
|
+
const snapshot = await latestContextSnapshotForTask(task_id);
|
|
16
|
+
if (!snapshot) return textResult({ task_id, snapshot: null });
|
|
17
|
+
return textResult({
|
|
18
|
+
task_id,
|
|
19
|
+
snapshot: {
|
|
20
|
+
id: snapshot.id,
|
|
21
|
+
run_id: snapshot.run_id,
|
|
22
|
+
recipient: snapshot.recipient,
|
|
23
|
+
fact_ids: JSON.parse(snapshot.fact_versions),
|
|
24
|
+
base_sha: snapshot.base_sha,
|
|
25
|
+
prompt_sha256: snapshot.prompt_sha256,
|
|
26
|
+
estimated_tokens: snapshot.estimated_tokens,
|
|
27
|
+
excluded: JSON.parse(snapshot.excluded_json),
|
|
28
|
+
created_at: snapshot.created_at
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const getFactOp = {
|
|
35
|
+
input: z.object({ fact_id: z.string().uuid() }),
|
|
36
|
+
handler: async ({ fact_id }) => {
|
|
37
|
+
const fact = await getFact(fact_id);
|
|
38
|
+
if (!fact) return textResult({ error: "fact_not_found", fact_id });
|
|
39
|
+
return textResult({ fact, effective_state: await getFactEffectiveState(fact_id) ?? fact.state });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const getArtifactOp = {
|
|
44
|
+
input: z.object({ artifact_id: z.string().uuid(), maxChars: z.number().int().min(0).max(100000).default(12000) }),
|
|
45
|
+
handler: async ({ artifact_id, maxChars }) => {
|
|
46
|
+
const artifact = await getArtifact(artifact_id);
|
|
47
|
+
if (!artifact) return textResult({ error: "artifact_not_found", artifact_id });
|
|
48
|
+
return textResult({ artifact: await readArtifact(artifact_id, maxChars) });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const promoteWorkerFactOp = {
|
|
53
|
+
input: z.object({
|
|
54
|
+
fact_id: z.string().uuid(),
|
|
55
|
+
scope: z.enum(["work_item", "repo_verified"]).default("work_item"),
|
|
56
|
+
watchedPaths: z.array(z.string().min(1)).max(100).optional(),
|
|
57
|
+
expiresAt: z.string().datetime().optional()
|
|
58
|
+
}),
|
|
59
|
+
handler: async ({ fact_id, scope, watchedPaths, expiresAt }) => {
|
|
60
|
+
try {
|
|
61
|
+
const source = await getFact(fact_id);
|
|
62
|
+
if (!source) return textResult({ error: "fact_not_found", fact_id });
|
|
63
|
+
if (await isFactRevoked(fact_id)) return textResult({ error: "fact_already_revoked", fact_id });
|
|
64
|
+
const task = await getTaskForWorkItem(source.work_item_id);
|
|
65
|
+
if (!task) return textResult({ error: "fact_task_not_found", fact_id });
|
|
66
|
+
const event = await appendTaskEvent(task.id, { type: "supervisor.fact_promoted", source_fact_id: fact_id, scope, watched_paths: watchedPaths ?? source.watched_paths ?? [], expires_at: expiresAt ?? null }, {
|
|
67
|
+
runId: runIdFor(task.id, task.run_count ?? 1), actor: "main_thread"
|
|
68
|
+
});
|
|
69
|
+
const fact = await promoteCandidateFact({
|
|
70
|
+
factId: fact_id,
|
|
71
|
+
scopeType: scope,
|
|
72
|
+
watchedPaths,
|
|
73
|
+
expiresAt: expiresAt ?? null,
|
|
74
|
+
sourceEventId: event.id,
|
|
75
|
+
verifiedBy: "main_thread"
|
|
76
|
+
});
|
|
77
|
+
return textResult({ fact, source_fact_id: fact_id });
|
|
78
|
+
} catch (error) {
|
|
79
|
+
return errorResult(error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const revokeWorkerFactOp = {
|
|
85
|
+
input: z.object({ fact_id: z.string().uuid(), reason: z.string().min(1).max(2000) }),
|
|
86
|
+
handler: async ({ fact_id, reason }) => {
|
|
87
|
+
try {
|
|
88
|
+
const source = await getFact(fact_id);
|
|
89
|
+
if (!source) return textResult({ error: "fact_not_found", fact_id });
|
|
90
|
+
const task = await getTaskForWorkItem(source.work_item_id);
|
|
91
|
+
if (!task) return textResult({ error: "fact_task_not_found", fact_id });
|
|
92
|
+
const revoked = await revokeFact(fact_id);
|
|
93
|
+
await appendTaskEvent(task.id, { type: "supervisor.fact_revoked", fact_id, reason }, {
|
|
94
|
+
runId: runIdFor(task.id, task.run_count ?? 1), actor: "main_thread"
|
|
95
|
+
});
|
|
96
|
+
return textResult({ fact: revoked, reason });
|
|
97
|
+
} catch (error) {
|
|
98
|
+
return errorResult(error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const getWorkerEvidenceOp = {
|
|
104
|
+
input: z.object({ task_id: z.string().min(1), limit: z.number().int().min(1).max(100).default(30) }),
|
|
105
|
+
handler: async ({ task_id, limit }) => {
|
|
106
|
+
const task = await getTask(task_id);
|
|
107
|
+
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
108
|
+
const events = await readTaskEventRecords(task_id, limit);
|
|
109
|
+
const artifacts = await listArtifactsForTask(task_id, limit);
|
|
110
|
+
return textResult({
|
|
111
|
+
task_id,
|
|
112
|
+
events: events.map((event) => ({
|
|
113
|
+
id: event.id, run_id: event.run_id, type: event.event_type, actor: event.actor,
|
|
114
|
+
payload_sha256: event.payload_sha256, created_at: event.created_at
|
|
115
|
+
})),
|
|
116
|
+
artifacts: artifacts.map((artifact) => ({
|
|
117
|
+
id: artifact.id, run_id: artifact.run_id, type: artifact.type, sha256: artifact.sha256,
|
|
118
|
+
security_class: artifact.security_class, retention: artifact.retention, created_at: artifact.created_at
|
|
119
|
+
}))
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
function decodeFactCursor(cursor, taskId, query) {
|
|
125
|
+
if (!cursor) return 0;
|
|
126
|
+
try {
|
|
127
|
+
const payload = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
128
|
+
if (payload.task_id !== taskId || payload.query !== query || !Number.isInteger(payload.offset) || payload.offset < 0) throw new Error("mismatch");
|
|
129
|
+
return payload.offset;
|
|
130
|
+
} catch {
|
|
131
|
+
const error = new Error("fact cursor does not match this task and query");
|
|
132
|
+
error.code = "invalid_fact_cursor";
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function encodeFactCursor(taskId, query, offset) {
|
|
138
|
+
return Buffer.from(JSON.stringify({ task_id: taskId, query, offset })).toString("base64url");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function factFreshForTask(task, fact) {
|
|
142
|
+
if (!fact.valid_for_sha || !task.base_commit) return true;
|
|
143
|
+
try {
|
|
144
|
+
git(task.project_root, ["merge-base", "--is-ancestor", fact.valid_for_sha, task.base_commit]);
|
|
145
|
+
return true;
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const searchWorkerFactsOp = {
|
|
152
|
+
input: z.object({
|
|
153
|
+
task_id: z.string().min(1),
|
|
154
|
+
query: z.string().max(500).default(""),
|
|
155
|
+
limit: z.number().int().min(1).max(50).default(20),
|
|
156
|
+
cursor: z.string().min(1).optional()
|
|
157
|
+
}),
|
|
158
|
+
handler: async ({ task_id, query, limit, cursor }) => {
|
|
159
|
+
const task = await getTask(task_id);
|
|
160
|
+
if (!task) return textResult({ error: "task_not_found", task_id });
|
|
161
|
+
try {
|
|
162
|
+
const normalizedQuery = query.trim().toLocaleLowerCase();
|
|
163
|
+
const offset = decodeFactCursor(cursor, task_id, normalizedQuery);
|
|
164
|
+
const scoped = (await listContextFacts({
|
|
165
|
+
taskId: task_id,
|
|
166
|
+
baseSha: task.base_commit ?? null,
|
|
167
|
+
ownedPaths: task.owned_paths ?? [],
|
|
168
|
+
dependencyTaskIds: task.depends_on ?? []
|
|
169
|
+
})).filter((fact) => factFreshForTask(task, fact));
|
|
170
|
+
const matching = scoped.filter((fact) => !normalizedQuery || `${fact.key}\n${JSON.stringify(fact.value)}`.toLocaleLowerCase().includes(normalizedQuery));
|
|
171
|
+
const page = matching.slice(offset, offset + limit);
|
|
172
|
+
const nextOffset = offset + page.length;
|
|
173
|
+
const totalVerified = await countVerifiedFacts();
|
|
174
|
+
return textResult({
|
|
175
|
+
task_id,
|
|
176
|
+
facts: page.map((fact) => ({
|
|
177
|
+
id: fact.id,
|
|
178
|
+
key: fact.key,
|
|
179
|
+
summary: clip(typeof fact.value === "string" ? fact.value : JSON.stringify(fact.value), 360),
|
|
180
|
+
state: fact.state,
|
|
181
|
+
scope: fact.scope_type,
|
|
182
|
+
valid_for_sha: fact.valid_for_sha ?? null,
|
|
183
|
+
freshness: "current",
|
|
184
|
+
source_refs: [
|
|
185
|
+
...(fact.source_event_id ? [`event:${fact.source_event_id}`] : []),
|
|
186
|
+
...(fact.source_artifact_id ? [`artifact:${fact.source_artifact_id}`] : [])
|
|
187
|
+
]
|
|
188
|
+
})),
|
|
189
|
+
coverage: {
|
|
190
|
+
scope: "current_work+explicit_dependencies+path_matched_repo_facts",
|
|
191
|
+
included_count: scoped.length,
|
|
192
|
+
matched_count: matching.length,
|
|
193
|
+
omitted: [
|
|
194
|
+
{ reason: "other_verified_scopes_excluded", count: Math.max(0, totalVerified - scoped.length) },
|
|
195
|
+
{ reason: "candidate_and_nonverified_facts_excluded", count: null }
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
next_cursor: nextOffset < matching.length ? encodeFactCursor(task_id, normalizedQuery, nextOffset) : null
|
|
199
|
+
});
|
|
200
|
+
} catch (error) {
|
|
201
|
+
return errorResult(error);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|