ralphflow-dsh 0.1.0 → 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/README.md +227 -158
- package/lib/create.d.ts +7 -11
- package/lib/create.js +132 -83
- package/lib/engine.d.ts +667 -262
- package/lib/engine.js +3583 -2579
- package/lib/index.d.ts +3 -4
- package/lib/index.js +222 -163
- package/lib/message-source.d.ts +25 -0
- package/lib/message-source.js +2 -0
- package/lib/reset.d.ts +40 -0
- package/lib/reset.js +147 -0
- package/lib/tools.d.ts +31 -14
- package/lib/tools.js +407 -684
- package/lib/verify.d.ts +57 -0
- package/lib/verify.js +326 -0
- package/lib/voting.d.ts +63 -0
- package/lib/voting.js +131 -0
- package/package.json +24 -45
- package/workflows/loop.yaml +21 -6
- package/workflows/spec.yaml +51 -46
- package/lib/actions.d.ts +0 -37
- package/lib/actions.js +0 -55
- package/lib/check-voting.d.ts +0 -54
- package/lib/check-voting.js +0 -289
- package/lib/check.d.ts +0 -64
- package/lib/check.js +0 -329
- package/lib/client/CommandCard.d.ts +0 -24
- package/lib/client/CommandCard.js +0 -69
- package/lib/client/HeaderAction.d.ts +0 -39
- package/lib/client/HeaderAction.js +0 -509
- package/lib/client/RunCard.d.ts +0 -27
- package/lib/client/RunCard.js +0 -375
- package/lib/client/client.d.ts +0 -3
- package/lib/client/client.js +0 -275
- package/lib/client/definition.d.ts +0 -126
- package/lib/client/definition.js +0 -259
- package/lib/client/hidden-runs.d.ts +0 -6
- package/lib/client/hidden-runs.js +0 -52
- package/lib/client/http-state.d.ts +0 -67
- package/lib/client/http-state.js +0 -81
- package/lib/client/markdown.d.ts +0 -26
- package/lib/client/markdown.js +0 -174
- package/lib/client/notify-watch.d.ts +0 -38
- package/lib/client/notify-watch.js +0 -98
- package/lib/client/notify.d.ts +0 -21
- package/lib/client/notify.js +0 -168
- package/lib/client/snapshots.d.ts +0 -8
- package/lib/client/snapshots.js +0 -101
- package/lib/client.js +0 -2361
- package/lib/commands.d.ts +0 -41
- package/lib/commands.js +0 -223
- package/lib/deps.d.ts +0 -17
- package/lib/deps.js +0 -19
- package/lib/done-detect.d.ts +0 -2
- package/lib/done-detect.js +0 -28
- package/lib/driver.d.ts +0 -32
- package/lib/driver.js +0 -248
- package/lib/events.d.ts +0 -35
- package/lib/events.js +0 -52
- package/lib/jobs.d.ts +0 -56
- package/lib/jobs.js +0 -355
- package/lib/mutex.d.ts +0 -9
- package/lib/mutex.js +0 -21
- package/lib/session-hygiene.d.ts +0 -25
- package/lib/session-hygiene.js +0 -205
- package/lib/voting-progress.d.ts +0 -37
- package/lib/voting-progress.js +0 -89
package/lib/check-voting.js
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-voter CHECK (check_voting) — parallel voting + aggregation + infra retry.
|
|
3
|
-
*
|
|
4
|
-
* Semantics (design §4.3/§4.4/§5.3):
|
|
5
|
-
* - Aggregation priority: cancelled > failed > infra > all-pass.
|
|
6
|
-
* - All must pass. failed beats infra (a known work problem is never masked
|
|
7
|
-
* by infra votes; the infra vote re-runs on the next cross-round anyway).
|
|
8
|
-
* - infra auto-retry: at most 1 retry per pause-session; a vote that is still
|
|
9
|
-
* infra after retry → check_error pause (progress file kept, vote marked
|
|
10
|
-
* infra_failed). User continue resets infra_failed → pending (new pardon).
|
|
11
|
-
* - Progress is persisted per-instance via voting-progress.ts; any single
|
|
12
|
-
* vote completion updates the file. The state machine is only touched by
|
|
13
|
-
* the driver after this function returns.
|
|
14
|
-
*/
|
|
15
|
-
import { runSingleVoter } from "./check.js";
|
|
16
|
-
import { MAX_VOTERS } from "./engine.js";
|
|
17
|
-
import { writeVotingProgress, deleteVotingProgress, initVotingProgress, } from "./voting-progress.js";
|
|
18
|
-
/**
|
|
19
|
-
* Run the full voting flow for a step: decide which votes to run (fresh vs
|
|
20
|
-
* resume), run them concurrently, auto-retry infra once, aggregate.
|
|
21
|
-
* Never touches the state machine; returns an outcome for the driver.
|
|
22
|
-
*/
|
|
23
|
-
export async function runVotingCheck(deps, engine, instId, ownerSessionId, parent, step, userTask, entries, effective, opts) {
|
|
24
|
-
const count = Math.min(entries.length, MAX_VOTERS);
|
|
25
|
-
// ── Decide which votes to run ──────────────────────────────────────────────
|
|
26
|
-
let progress;
|
|
27
|
-
let runIndices;
|
|
28
|
-
if (opts.phase === "do") {
|
|
29
|
-
// Cross-round (DO just finished): fresh round, all votes.
|
|
30
|
-
progress = initVotingProgress(step.id, opts.workflowName, entries);
|
|
31
|
-
runIndices = entries.map((_, i) => i);
|
|
32
|
-
}
|
|
33
|
-
else if (opts.progress && opts.progress.stepId === step.id) {
|
|
34
|
-
// Same-round resume (check_error → continue): keep passed/failed, reset
|
|
35
|
-
// infra_failed → pending, run every non-terminal vote.
|
|
36
|
-
progress = opts.progress;
|
|
37
|
-
runIndices = [];
|
|
38
|
-
for (const e of progress.entries) {
|
|
39
|
-
// 防御:损坏/伪造的进度文件可能带越界 index——放进去会在 prompt 构建/
|
|
40
|
-
// 聚合时 TypeError → 被 allSettled 兜成 infra → 重试仍炸 → 暂停循环。
|
|
41
|
-
if (!(e.index >= 0 && e.index < entries.length))
|
|
42
|
-
continue;
|
|
43
|
-
if (e.status === "infra_failed") {
|
|
44
|
-
e.status = "pending";
|
|
45
|
-
runIndices.push(e.index);
|
|
46
|
-
}
|
|
47
|
-
else if (e.status === "pending" || e.status === "running") {
|
|
48
|
-
runIndices.push(e.index);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
// Restart (plugin load hook cleaned the file) or stale file for another
|
|
54
|
-
// step: fresh round.
|
|
55
|
-
progress = initVotingProgress(step.id, opts.workflowName, entries);
|
|
56
|
-
runIndices = entries.map((_, i) => i);
|
|
57
|
-
}
|
|
58
|
-
// ── Round 1: run the selected votes concurrently ───────────────────────────
|
|
59
|
-
const onProgress = opts.onVoteProgress;
|
|
60
|
-
const firstRound = await runVotes(deps, engine, instId, ownerSessionId, parent, step, userTask, entries, effective, progress, runIndices, count, false, onProgress);
|
|
61
|
-
const firstPassed = firstRound.filter((v) => v.status === "passed");
|
|
62
|
-
const firstFailed = firstRound.filter((v) => v.status === "failed");
|
|
63
|
-
const firstInfra = firstRound.filter((v) => v.status === "infra");
|
|
64
|
-
if (!engine.instanceExists(instId)) {
|
|
65
|
-
return { kind: "cancelled", reason: "工作流实例已被取消。", verdicts: firstRound, keepProgress: false };
|
|
66
|
-
}
|
|
67
|
-
// failed beats infra: a known work problem is never masked.
|
|
68
|
-
if (firstFailed.length > 0) {
|
|
69
|
-
deleteVotingProgress(engine, instId);
|
|
70
|
-
return { kind: "failed", reason: formatVotingFailureReason(firstRound, entries), verdicts: firstRound, keepProgress: false };
|
|
71
|
-
}
|
|
72
|
-
if (firstInfra.length === 0) {
|
|
73
|
-
deleteVotingProgress(engine, instId);
|
|
74
|
-
return { kind: "passed", reason: formatVotingPassReason(firstRound, entries), verdicts: firstRound, keepProgress: false };
|
|
75
|
-
}
|
|
76
|
-
// ── Round 2: auto-retry the infra votes (budget: one per pause-session) ────
|
|
77
|
-
const retryIndices = firstInfra.map((v) => v.index);
|
|
78
|
-
const secondRound = await runVotes(deps, engine, instId, ownerSessionId, parent, step, userTask, entries, effective, progress, retryIndices, count, true, onProgress);
|
|
79
|
-
const merged = mergeVerdicts(firstRound, secondRound);
|
|
80
|
-
const secondFailed = merged.filter((v) => v.status === "failed");
|
|
81
|
-
const secondInfra = merged.filter((v) => v.status === "infra");
|
|
82
|
-
if (!engine.instanceExists(instId)) {
|
|
83
|
-
return { kind: "cancelled", reason: "工作流实例已被取消。", verdicts: merged, keepProgress: false };
|
|
84
|
-
}
|
|
85
|
-
if (secondFailed.length > 0) {
|
|
86
|
-
deleteVotingProgress(engine, instId);
|
|
87
|
-
return { kind: "failed", reason: formatVotingFailureReason(merged, entries), verdicts: merged, keepProgress: false };
|
|
88
|
-
}
|
|
89
|
-
if (secondInfra.length > 0) {
|
|
90
|
-
// Budget exhausted → mark infra_failed (kept in file), pause the workflow.
|
|
91
|
-
for (const v of secondInfra) {
|
|
92
|
-
const e = progress.entries.find((p) => p.index === v.index);
|
|
93
|
-
if (e) {
|
|
94
|
-
e.status = "infra_failed";
|
|
95
|
-
e.reason = v.reason;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
writeVotingProgress(engine, instId, progress);
|
|
99
|
-
return { kind: "infra_pause", reason: formatVotingInfraReason(secondInfra, entries), verdicts: merged, keepProgress: true };
|
|
100
|
-
}
|
|
101
|
-
deleteVotingProgress(engine, instId);
|
|
102
|
-
return { kind: "passed", reason: formatVotingPassReason(merged, entries), verdicts: merged, keepProgress: false };
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Run the given vote indices concurrently, updating persisted progress as each
|
|
106
|
-
* vote completes. `isRetry` marks this round as the infra auto-retry (infra
|
|
107
|
-
* results become infra_pending in round 1, stay infra here → infra_failed).
|
|
108
|
-
*/
|
|
109
|
-
async function runVotes(deps, engine, instId, ownerSessionId, parent, step, userTask, entries, effective, progress, indices, count, isRetry = false, onProgress) {
|
|
110
|
-
const push = (verdict) => {
|
|
111
|
-
if (!onProgress)
|
|
112
|
-
return;
|
|
113
|
-
const summary = (entries[verdict.index]?.check ?? "").split("\n")[0].trim().substring(0, 24);
|
|
114
|
-
const tag = `${verdict.index + 1}/${count}`;
|
|
115
|
-
let mark;
|
|
116
|
-
let suffix;
|
|
117
|
-
if (verdict.status === "passed") {
|
|
118
|
-
mark = isRetry ? "✅" : "✅";
|
|
119
|
-
suffix = isRetry ? "重试通过" : "通过";
|
|
120
|
-
}
|
|
121
|
-
else if (verdict.status === "failed") {
|
|
122
|
-
mark = "❌";
|
|
123
|
-
suffix = isRetry ? "重试仍不通过" : "不通过";
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
mark = "⚠️";
|
|
127
|
-
suffix = isRetry ? "重试仍失败,工作流将暂停" : "基础设施故障,自动重试中";
|
|
128
|
-
}
|
|
129
|
-
onProgress(`${mark} 验证者 ${tag}${suffix}:${summary}`);
|
|
130
|
-
};
|
|
131
|
-
const results = await Promise.allSettled(indices.map(async (idx) => {
|
|
132
|
-
const entry = entries[idx];
|
|
133
|
-
const pEntry = progress.entries.find((p) => p.index === idx);
|
|
134
|
-
if (pEntry) {
|
|
135
|
-
pEntry.status = "running";
|
|
136
|
-
pEntry.reason = "";
|
|
137
|
-
// 本次运行起点(UI「该票已跑 Xs」);重试轮刷新为新一轮起点
|
|
138
|
-
pEntry.startedAt = Date.now();
|
|
139
|
-
}
|
|
140
|
-
writeVotingProgress(engine, instId, progress);
|
|
141
|
-
// 验证者启动帧:UI 把这一票从「排队」点亮为「运行中」并开始计时——
|
|
142
|
-
// 黑盒期可观测(「在跑」和「死了」从此长得不一样)。
|
|
143
|
-
// 注意:dsh 的 session.append 做无损 JSON 快照校验,任何 undefined 属值
|
|
144
|
-
// 都会拒收整帧——可选字段必须用条件展开而不是 undefined 值。
|
|
145
|
-
try {
|
|
146
|
-
deps.emit(instId, "tool-ralphflow/check-voter-start", {
|
|
147
|
-
runId: instId, step: step.id, voter: idx + 1, count,
|
|
148
|
-
...(typeof entry?.model === "string" && entry.model ? { model: entry.model } : {}),
|
|
149
|
-
retry: isRetry, startedAt: Date.now(),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
catch { }
|
|
153
|
-
const checkPrompt = engine.buildVotingCheckPrompt(instId, step, userTask, entry, idx + 1, count);
|
|
154
|
-
const entryConfig = {
|
|
155
|
-
...effective,
|
|
156
|
-
...(entry.model !== undefined ? { model: entry.model } : {}),
|
|
157
|
-
...(entry.timeout_ms !== undefined ? { timeout_ms: entry.timeout_ms } : {}),
|
|
158
|
-
...(entry.system_prompt !== undefined ? { system_prompt: entry.system_prompt } : {}),
|
|
159
|
-
};
|
|
160
|
-
// runSingleVoter enforces its own per-vote timeout (entry.timeout_ms →
|
|
161
|
-
// effective → global default) and returns infra on timeout; no outer race
|
|
162
|
-
// needed (a second race would leak a dangling prompt promise + timer).
|
|
163
|
-
try {
|
|
164
|
-
const result = await runSingleVoter(deps, ownerSessionId, parent, instId, step, checkPrompt, userTask, entryConfig, { index: idx + 1, count });
|
|
165
|
-
if (result.infra) {
|
|
166
|
-
if (pEntry) {
|
|
167
|
-
pEntry.status = isRetry ? "infra_failed" : "infra_pending";
|
|
168
|
-
pEntry.reason = result.reason;
|
|
169
|
-
}
|
|
170
|
-
writeVotingProgress(engine, instId, progress);
|
|
171
|
-
const verdict = { index: idx, status: "infra", reason: result.reason };
|
|
172
|
-
push(verdict);
|
|
173
|
-
return verdict;
|
|
174
|
-
}
|
|
175
|
-
if (result.passed) {
|
|
176
|
-
if (pEntry) {
|
|
177
|
-
pEntry.status = "passed";
|
|
178
|
-
pEntry.reason = result.reason;
|
|
179
|
-
}
|
|
180
|
-
writeVotingProgress(engine, instId, progress);
|
|
181
|
-
const verdict = { index: idx, status: "passed", reason: result.reason };
|
|
182
|
-
push(verdict);
|
|
183
|
-
return verdict;
|
|
184
|
-
}
|
|
185
|
-
if (pEntry) {
|
|
186
|
-
pEntry.status = "failed";
|
|
187
|
-
pEntry.reason = result.reason;
|
|
188
|
-
}
|
|
189
|
-
writeVotingProgress(engine, instId, progress);
|
|
190
|
-
const verdict = { index: idx, status: "failed", reason: result.reason };
|
|
191
|
-
push(verdict);
|
|
192
|
-
return verdict;
|
|
193
|
-
}
|
|
194
|
-
catch (err) {
|
|
195
|
-
const msg = String(err?.message ?? err);
|
|
196
|
-
if (pEntry) {
|
|
197
|
-
pEntry.status = isRetry ? "infra_failed" : "infra_pending";
|
|
198
|
-
pEntry.reason = msg;
|
|
199
|
-
}
|
|
200
|
-
writeVotingProgress(engine, instId, progress);
|
|
201
|
-
const verdict = { index: idx, status: "infra", reason: msg };
|
|
202
|
-
push(verdict);
|
|
203
|
-
return verdict;
|
|
204
|
-
}
|
|
205
|
-
}));
|
|
206
|
-
return results.map((r, i) => r.status === "fulfilled"
|
|
207
|
-
? r.value
|
|
208
|
-
: { index: indices[i], status: "infra", reason: String(r.reason ?? "vote runner failed") });
|
|
209
|
-
}
|
|
210
|
-
function mergeVerdicts(base, retry) {
|
|
211
|
-
const map = new Map();
|
|
212
|
-
for (const v of base)
|
|
213
|
-
map.set(v.index, v);
|
|
214
|
-
for (const v of retry)
|
|
215
|
-
map.set(v.index, v);
|
|
216
|
-
return [...map.values()].sort((a, b) => a.index - b.index);
|
|
217
|
-
}
|
|
218
|
-
const MAX_TOTAL_REASON = 24000;
|
|
219
|
-
const PER_FAILED_REASON = 4000;
|
|
220
|
-
/** Aggregate failure feedback for DO (design §4.5). */
|
|
221
|
-
export function formatVotingFailureReason(verdicts, entries) {
|
|
222
|
-
const failed = verdicts.filter((v) => v.status === "failed");
|
|
223
|
-
const passed = verdicts.filter((v) => v.status === "passed");
|
|
224
|
-
const lines = [];
|
|
225
|
-
lines.push(`多验证者检查 ${passed.length}/${entries.length} 通过,全过才放行:`);
|
|
226
|
-
if (failed.length > 0) {
|
|
227
|
-
lines.push("", "### ✗ 未通过的验证者(必须修复)");
|
|
228
|
-
for (const v of failed) {
|
|
229
|
-
const entry = entries[v.index];
|
|
230
|
-
if (!entry)
|
|
231
|
-
continue;
|
|
232
|
-
const model = entry.model ? ` · ${typeof entry.model === "string" ? entry.model : entry.model.providerID + "/" + entry.model.modelID}` : "";
|
|
233
|
-
lines.push("", `**验证者 ${v.index + 1}/${entries.length}${model}**`, `检查依据:${entry.check}`, `问题:`, truncate(v.reason, PER_FAILED_REASON));
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (passed.length > 0) {
|
|
237
|
-
lines.push("", "### ✓ 已通过的验证者(修复时不要破坏)");
|
|
238
|
-
for (const v of passed) {
|
|
239
|
-
const entry = entries[v.index];
|
|
240
|
-
if (!entry)
|
|
241
|
-
continue;
|
|
242
|
-
const summary = v.reason.split("\n").find((l) => l.trim())?.trim() ?? "";
|
|
243
|
-
lines.push(`验证者 ${v.index + 1}/${entries.length} ${entry.check.substring(0, 40)}:${truncate(summary, 400)}`);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
const infra = verdicts.filter((v) => v.status === "infra");
|
|
247
|
-
if (infra.length > 0) {
|
|
248
|
-
lines.push("", "### ⚠️ 基础设施故障票(本轮未出判定,下次重投)");
|
|
249
|
-
for (const v of infra) {
|
|
250
|
-
lines.push(`验证者 ${v.index + 1}/${verdicts.length}:${truncate(v.reason, 400)}`);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return truncate(lines.join("\n"), MAX_TOTAL_REASON);
|
|
254
|
-
}
|
|
255
|
-
/** Aggregate pass feedback (design §4.6). */
|
|
256
|
-
export function formatVotingPassReason(verdicts, entries) {
|
|
257
|
-
const lines = [`${verdicts.length}/${verdicts.length} 验证者全过:`];
|
|
258
|
-
for (const v of verdicts) {
|
|
259
|
-
const entry = entries[v.index];
|
|
260
|
-
if (!entry)
|
|
261
|
-
continue;
|
|
262
|
-
const summary = v.reason.split("\n").find((l) => l.trim())?.trim() ?? "";
|
|
263
|
-
lines.push(`[✓] ${v.index + 1}/${entries.length} ${entry.check.substring(0, 30)}:${truncate(summary, 160)}`);
|
|
264
|
-
}
|
|
265
|
-
return truncate(lines.join("\n"), MAX_TOTAL_REASON);
|
|
266
|
-
}
|
|
267
|
-
/** Infra pause reason for the user (design §9 scenario 3). */
|
|
268
|
-
export function formatVotingInfraReason(infraVotes, entries) {
|
|
269
|
-
const lines = [];
|
|
270
|
-
for (const v of infraVotes) {
|
|
271
|
-
lines.push(`验证者 ${v.index + 1}/${entries.length}${entries[v.index] ? `(${entries[v.index].check.substring(0, 30)})` : ""} 重试后仍无法运行:${truncate(v.reason, 800)}`);
|
|
272
|
-
}
|
|
273
|
-
return truncate(lines.join("\n"), MAX_TOTAL_REASON);
|
|
274
|
-
}
|
|
275
|
-
function truncate(text, max) {
|
|
276
|
-
return text.length > max ? text.substring(0, max) + "…" : text;
|
|
277
|
-
}
|
|
278
|
-
/** Status letter for TUI/status summaries. */
|
|
279
|
-
export function voterStatusLabel(status) {
|
|
280
|
-
switch (status) {
|
|
281
|
-
case "passed": return "✓";
|
|
282
|
-
case "failed": return "✗";
|
|
283
|
-
case "running": return "⏳";
|
|
284
|
-
case "infra_pending": return "♻";
|
|
285
|
-
case "infra_failed": return "⚠";
|
|
286
|
-
case "cancelled": return "⊘";
|
|
287
|
-
default: return "·";
|
|
288
|
-
}
|
|
289
|
-
}
|
package/lib/check.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { NormalStepDef, Engine, CheckResult, AdversarialCheckConfig } from "./engine.js";
|
|
4
|
-
export interface VoterOpts {
|
|
5
|
-
/** 1-based voter index in the voting round. */
|
|
6
|
-
index?: number;
|
|
7
|
-
/** Total voter count. */
|
|
8
|
-
count?: number;
|
|
9
|
-
}
|
|
10
|
-
export interface CheckDeps {
|
|
11
|
-
ctx: Context;
|
|
12
|
-
engine: Engine;
|
|
13
|
-
/** 事件帧发射(tool-ralphflow/check-verdict 等) */
|
|
14
|
-
emit: (instId: string, type: string, data: Record<string, unknown>) => void;
|
|
15
|
-
/** 取消信号(job 生命周期 / 实例取消) */
|
|
16
|
-
signal: AbortSignal;
|
|
17
|
-
/** 互斥段结束时释放本组信号(可选,由 driver finally 调用) */
|
|
18
|
-
dispose?: () => void;
|
|
19
|
-
}
|
|
20
|
-
export declare function registerInstanceSignal(instId: string): {
|
|
21
|
-
signal: AbortSignal;
|
|
22
|
-
dispose: () => void;
|
|
23
|
-
};
|
|
24
|
-
/** 中止某实例的全部在飞验证(cancel / destroyInstance 时调用)。 */
|
|
25
|
-
export declare function abortInstanceChecks(instId: string): void;
|
|
26
|
-
/**
|
|
27
|
-
* 「还有验证者在飞吗」的统一入口:先清理孤儿登记(进程 kill -9 后 finally 不
|
|
28
|
-
* 执行留下的 live 文件,否则 continue/status 会永远死等),再返回剩余数量。
|
|
29
|
-
*/
|
|
30
|
-
export declare function liveVerifierCount(engine: Engine, instId: string): number;
|
|
31
|
-
export declare function abortActiveCheck(deps: CheckDeps, instId: string): void;
|
|
32
|
-
export declare function isCheckSession(_sessionId: string): boolean;
|
|
33
|
-
/** 验证者工具白名单:只读 + 验证命令,无任何写工具 */
|
|
34
|
-
/**
|
|
35
|
-
* 验证者工具白名单的期望集合(opencode 同名语义:只读 + 验证命令)。
|
|
36
|
-
* 注意:dsh 的 tools.restrict 对未知工具名直接抛错——不同部署的全局工具集
|
|
37
|
-
* 不同(本仓库验证环境只有 bash/str_replace_editor/ralphflow_*),硬编码
|
|
38
|
-
* 会让验证者在启动瞬间全灭(restrict 抛错 → 全部 infra → 工作流假性暂停)。
|
|
39
|
-
* 因此运行时与宿主实际工具集求交集,交集为空时退化为「排除写类工具」启发式。
|
|
40
|
-
*/
|
|
41
|
-
export declare const VERIFIER_TOOL_ALLOW: readonly ["read", "bash", "grep", "glob", "read_image"];
|
|
42
|
-
/** 与宿主实际全局工具集求交集后的验证者白名单(每次调用实时解析) */
|
|
43
|
-
export declare function resolveVerifierToolAllow(ctx: unknown): string[];
|
|
44
|
-
/** 解析验证者最终文本中的通过标记与失败理由 */
|
|
45
|
-
export declare function parseVerdict(engine: Engine, text: string): {
|
|
46
|
-
passed: boolean;
|
|
47
|
-
reason: string;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* 运行一个独立验证者子代理。被单验证者路径(adversarialCheck)与投票路径
|
|
51
|
-
* (check-voting.ts)共用。
|
|
52
|
-
*
|
|
53
|
-
* 会话登记:启动时把验证者 id 写入 .adversarial-session(多票共存),结束/
|
|
54
|
-
* 失败/取消时移除——jobs 与 continue/rewind 以此判定「有验证正在进行」,
|
|
55
|
-
* 防止并发双重推进与误判崩溃恢复。
|
|
56
|
-
*/
|
|
57
|
-
export declare function runSingleVoter(deps: CheckDeps, ownerSessionId: string | null, parent: Agent | undefined, instId: string, step: NormalStepDef, checkPrompt: string, userTask: string | undefined, adversarialConfig?: AdversarialCheckConfig, voter?: VoterOpts): Promise<CheckResult>;
|
|
58
|
-
/** 单验证者路径(与 opencode 版 adversarialCheck 同签名语义) */
|
|
59
|
-
export declare function adversarialCheck(deps: CheckDeps, ownerSessionId: string | null, parent: Agent | undefined, instId: string, step: NormalStepDef, checkPrompt: string, userTask: string | undefined, adversarialConfig?: AdversarialCheckConfig): Promise<CheckResult>;
|
|
60
|
-
/** 从 dsh 上下文解析验证者 agent 的模型(默认链兜底) */
|
|
61
|
-
export declare function readOwnerSessionModel(ctx: Context, _ownerSessionId: string | null): Promise<{
|
|
62
|
-
providerID: string;
|
|
63
|
-
modelID: string;
|
|
64
|
-
} | undefined>;
|