wildcrane-runner 0.6.124 → 0.6.125
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/dist/akb/dist/kanban.mjs +14 -5
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +1 -1
- package/dist/codex-retained.mjs +1 -1
- package/dist/flow-worker-main.mjs +253 -82
- package/dist/launcher.mjs +54 -18
- package/dist/plugin.mjs +54 -18
- package/dist/runner.mjs +253 -82
- package/dist/settings.mjs +54 -18
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.125 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|
|
@@ -147115,8 +147115,8 @@ function goalRoute(discussion, goal) {
|
|
|
147115
147115
|
}
|
|
147116
147116
|
|
|
147117
147117
|
// src/protocol.ts
|
|
147118
|
-
var VERSION = true ? "0.6.
|
|
147119
|
-
var AKB_VERSION = true ? "0.11.
|
|
147118
|
+
var VERSION = true ? "0.6.125" : "0.0.0";
|
|
147119
|
+
var AKB_VERSION = true ? "0.11.107" : "0.0.0";
|
|
147120
147120
|
var AKB_CONTRACT = true ? 41 : 0;
|
|
147121
147121
|
|
|
147122
147122
|
// src/secrets.ts
|
|
@@ -148360,7 +148360,7 @@ function createTail(log) {
|
|
|
148360
148360
|
// ../cli/package.json
|
|
148361
148361
|
var package_default = {
|
|
148362
148362
|
name: "wildcrane",
|
|
148363
|
-
version: "0.11.
|
|
148363
|
+
version: "0.11.107",
|
|
148364
148364
|
akbContract: 41,
|
|
148365
148365
|
canonicalCommands: true,
|
|
148366
148366
|
description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
|
|
@@ -153029,14 +153029,48 @@ function keepSecrets(runtime, given) {
|
|
|
153029
153029
|
}
|
|
153030
153030
|
var secretsSet = () => Object.fromEntries(Object.entries(readAll()).map(([id2, keys]) => [id2, Object.keys(keys)]));
|
|
153031
153031
|
|
|
153032
|
+
// src/sync-debug.ts
|
|
153033
|
+
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
153034
|
+
var syncDebug = process.env.WILDCRANE_DEBUG_SYNC === "1";
|
|
153035
|
+
var counts = {};
|
|
153036
|
+
function countSync(name, amount = 1) {
|
|
153037
|
+
if (syncDebug) counts[name] = (counts[name] ?? 0) + amount;
|
|
153038
|
+
}
|
|
153039
|
+
function logSync(event2, fields2 = {}) {
|
|
153040
|
+
if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
|
|
153041
|
+
}
|
|
153042
|
+
if (syncDebug) {
|
|
153043
|
+
const delay4 = monitorEventLoopDelay({ resolution: 20 });
|
|
153044
|
+
delay4.enable();
|
|
153045
|
+
let cpu = process.cpuUsage();
|
|
153046
|
+
let at2 = performance.now();
|
|
153047
|
+
setInterval(() => {
|
|
153048
|
+
const now = performance.now();
|
|
153049
|
+
const used = process.cpuUsage(cpu);
|
|
153050
|
+
logSync("health", {
|
|
153051
|
+
cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
|
|
153052
|
+
delayMaxMs: Math.round(delay4.max / 1e6),
|
|
153053
|
+
delayP99Ms: Math.round(delay4.percentile(99) / 1e6),
|
|
153054
|
+
...counts
|
|
153055
|
+
});
|
|
153056
|
+
for (const name of Object.keys(counts)) delete counts[name];
|
|
153057
|
+
cpu = process.cpuUsage();
|
|
153058
|
+
at2 = now;
|
|
153059
|
+
delay4.reset();
|
|
153060
|
+
}, 5e3).unref();
|
|
153061
|
+
}
|
|
153062
|
+
|
|
153032
153063
|
// src/api.ts
|
|
153033
153064
|
var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok", "antigravity"];
|
|
153034
153065
|
var PROTOCOL = 33;
|
|
153035
153066
|
var TIMEOUT_MS = 2e4;
|
|
153036
153067
|
async function send(method, route, body, signedIn, ms, type, extra = {}) {
|
|
153068
|
+
const started = performance.now();
|
|
153069
|
+
const endpoint = route.split("?")[0];
|
|
153037
153070
|
const headers = { accept: "application/json", ...extra };
|
|
153038
153071
|
if (signedIn) {
|
|
153039
153072
|
const token = await accessToken();
|
|
153073
|
+
logSync("http.auth", { method, endpoint, ms: Math.round(performance.now() - started), ok: token.ok });
|
|
153040
153074
|
if (!token.ok) {
|
|
153041
153075
|
return token.reason === "unreachable" ? { ok: false, error: token.error } : { ok: false, error: "Sign in again.", code: "unauthenticated" };
|
|
153042
153076
|
}
|
|
@@ -153051,8 +153085,10 @@ async function send(method, route, body, signedIn, ms, type, extra = {}) {
|
|
|
153051
153085
|
body: body === void 0 ? void 0 : raw ? body : JSON.stringify(body),
|
|
153052
153086
|
signal: AbortSignal.timeout(ms)
|
|
153053
153087
|
});
|
|
153088
|
+
logSync("http.headers", { method, endpoint, ms: Math.round(performance.now() - started), status: response.status });
|
|
153054
153089
|
return { ok: true, value: response };
|
|
153055
153090
|
} catch (e2) {
|
|
153091
|
+
logSync("http.failed", { method, endpoint, ms: Math.round(performance.now() - started) });
|
|
153056
153092
|
return { ok: false, error: e2 instanceof Error ? e2.message : String(e2) };
|
|
153057
153093
|
}
|
|
153058
153094
|
}
|
|
@@ -153070,8 +153106,11 @@ async function answerOf(response) {
|
|
|
153070
153106
|
};
|
|
153071
153107
|
}
|
|
153072
153108
|
async function request(method, route, body, signedIn = true) {
|
|
153109
|
+
const started = performance.now();
|
|
153073
153110
|
const sent = await send(method, route, body, signedIn, TIMEOUT_MS);
|
|
153074
|
-
|
|
153111
|
+
const result = sent.ok ? await answerOf(sent.value) : sent;
|
|
153112
|
+
logSync("http.done", { method, endpoint: route.split("?")[0], ms: Math.round(performance.now() - started), ok: result.ok });
|
|
153113
|
+
return result;
|
|
153075
153114
|
}
|
|
153076
153115
|
var FILE_TIMEOUT_MS = 10 * 6e4;
|
|
153077
153116
|
async function download(route, studioBytes) {
|
|
@@ -153482,6 +153521,11 @@ function numberOfCard(path78) {
|
|
|
153482
153521
|
const n = ROOT.exec(path78)?.[1] ?? CARD.exec(path78)?.[1];
|
|
153483
153522
|
return n ? Number(n) : null;
|
|
153484
153523
|
}
|
|
153524
|
+
function groupOfCard(path78) {
|
|
153525
|
+
if (ROOT.test(path78) || !CARD.test(path78)) return null;
|
|
153526
|
+
const folder2 = /(?:^|\/)(\d+)-[^/]+\/[^/]+$/.exec(path78)?.[1];
|
|
153527
|
+
return folder2 ? Number(folder2) : null;
|
|
153528
|
+
}
|
|
153485
153529
|
var assetsFile = (task) => `assets/${task}.json`;
|
|
153486
153530
|
var taskOfAssets = (path78) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path78)?.[1] ?? null;
|
|
153487
153531
|
var studioFolder = (id2) => id2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -154540,11 +154584,18 @@ function readLandArchiveOwner(file2) {
|
|
|
154540
154584
|
const saved = fs30.readFileSync(file2, "utf8");
|
|
154541
154585
|
if (/^[\w-]{1,100}$/.test(saved)) return { job: saved };
|
|
154542
154586
|
const owner2 = JSON.parse(saved);
|
|
154543
|
-
|
|
154587
|
+
const validJob = owner2?.job === null || typeof owner2?.job === "string" && !!owner2.job.trim();
|
|
154588
|
+
return validJob && Number.isSafeInteger(owner2?.number) && owner2.number > 0 ? { job: owner2.job, number: owner2.number } : null;
|
|
154544
154589
|
} catch {
|
|
154545
154590
|
return null;
|
|
154546
154591
|
}
|
|
154547
154592
|
}
|
|
154593
|
+
function writeLandArchiveOwner(file2, owner2) {
|
|
154594
|
+
fs30.mkdirSync(path31.dirname(file2), { recursive: true });
|
|
154595
|
+
const tmp = `${file2}.${process.pid}.tmp`;
|
|
154596
|
+
fs30.writeFileSync(tmp, JSON.stringify(owner2));
|
|
154597
|
+
fs30.renameSync(tmp, file2);
|
|
154598
|
+
}
|
|
154548
154599
|
function landArchiveOwners(board, pending) {
|
|
154549
154600
|
const dir = markerDirectory(board);
|
|
154550
154601
|
let entries;
|
|
@@ -176332,7 +176383,15 @@ function studioEntry(id2, name, version2, action, command = "akb studio file") {
|
|
|
176332
176383
|
return ["studio", "Studio: " + name + ". Read `" + command + " " + studioName(id2) + " STUDIO.md`" + read5 + ".", void 0, JSON.stringify([id2, name, version2, command])];
|
|
176333
176384
|
}
|
|
176334
176385
|
function compactReview(review, assigned) {
|
|
176335
|
-
if (isFlatReviewPlan(review.plan))
|
|
176386
|
+
if (isFlatReviewPlan(review.plan)) {
|
|
176387
|
+
const pending = (review.approvals ?? []).filter((approval) => "preview" in approval);
|
|
176388
|
+
return [
|
|
176389
|
+
"Review r" + review.revision + " \xB7 flat plan",
|
|
176390
|
+
"Selected Previews: " + (review.plan.previews.join(", ") || "none"),
|
|
176391
|
+
"Review rule: " + (review.plan.rule || "No extra approval."),
|
|
176392
|
+
...pending.length ? ["Pending approvals:", ...pending.map(({ preview, stage, revision, question }) => `- ${preview} \xB7 ${stage} \xB7 r${revision}: ${question}`)] : []
|
|
176393
|
+
].map((line) => line.replace(/[\r\n]+/g, " ")).join("\n");
|
|
176394
|
+
}
|
|
176336
176395
|
const authorization = reviewAuthorization(review, assigned);
|
|
176337
176396
|
if (authorization.kind === "changed") return "Review r" + review.revision + " \xB7 authorization changed. Read the task again.";
|
|
176338
176397
|
const custom2 = review.preview_definitions?.length ? "\nCustom Previews: " + review.preview_definitions.map((d2) => d2.id).join(", ") : "";
|
|
@@ -182999,37 +183058,6 @@ function logRunner(component, event2, fields2 = {}) {
|
|
|
182999
183058
|
});
|
|
183000
183059
|
}
|
|
183001
183060
|
|
|
183002
|
-
// src/sync-debug.ts
|
|
183003
|
-
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
183004
|
-
var syncDebug = process.env.WILDCRANE_DEBUG_SYNC === "1";
|
|
183005
|
-
var counts = {};
|
|
183006
|
-
function countSync(name, amount = 1) {
|
|
183007
|
-
if (syncDebug) counts[name] = (counts[name] ?? 0) + amount;
|
|
183008
|
-
}
|
|
183009
|
-
function logSync(event2, fields2 = {}) {
|
|
183010
|
-
if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
|
|
183011
|
-
}
|
|
183012
|
-
if (syncDebug) {
|
|
183013
|
-
const delay4 = monitorEventLoopDelay({ resolution: 20 });
|
|
183014
|
-
delay4.enable();
|
|
183015
|
-
let cpu = process.cpuUsage();
|
|
183016
|
-
let at2 = performance.now();
|
|
183017
|
-
setInterval(() => {
|
|
183018
|
-
const now = performance.now();
|
|
183019
|
-
const used = process.cpuUsage(cpu);
|
|
183020
|
-
logSync("health", {
|
|
183021
|
-
cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
|
|
183022
|
-
delayMaxMs: Math.round(delay4.max / 1e6),
|
|
183023
|
-
delayP99Ms: Math.round(delay4.percentile(99) / 1e6),
|
|
183024
|
-
...counts
|
|
183025
|
-
});
|
|
183026
|
-
for (const name of Object.keys(counts)) delete counts[name];
|
|
183027
|
-
cpu = process.cpuUsage();
|
|
183028
|
-
at2 = now;
|
|
183029
|
-
delay4.reset();
|
|
183030
|
-
}, 5e3).unref();
|
|
183031
|
-
}
|
|
183032
|
-
|
|
183033
183061
|
// src/task-folder.ts
|
|
183034
183062
|
var validationFailure = (reason, code = "validation_failed") => makeFailure("validation", reason, { code, detail: reason });
|
|
183035
183063
|
var TASK_ID = /^[\w-]{1,100}$/;
|
|
@@ -183405,7 +183433,12 @@ function pull(ws, machineId, stopped2, mode) {
|
|
|
183405
183433
|
const taskChat = mode === "chat" ? ws.task : void 0;
|
|
183406
183434
|
return whenPrepared(ws, { ok: false, code: "stopped", error: "Task preparation stopped." }, async () => {
|
|
183407
183435
|
if (mode === "land") return prepareTask(ws, true, void 0, ws.task);
|
|
183408
|
-
const
|
|
183436
|
+
const started = performance.now();
|
|
183437
|
+
const sent = await sendBoard(boardFolder(ws), machineId, {
|
|
183438
|
+
taskChat,
|
|
183439
|
+
...mode === "chat" && ws.number !== null ? { taskNumber: ws.number } : {}
|
|
183440
|
+
});
|
|
183441
|
+
logSync("board.push.done", { ms: Math.round(performance.now() - started), ok: sent.ok });
|
|
183409
183442
|
let validation;
|
|
183410
183443
|
if (!sent.ok) {
|
|
183411
183444
|
const previews = sent.previews?.filter((p2) => numberOfCard(p2.file) === ws.number);
|
|
@@ -183420,12 +183453,17 @@ function pull(ws, machineId, stopped2, mode) {
|
|
|
183420
183453
|
return { ok: false, error: `This computer's board changes could not be sent: ${refused.error}`, ...refused.offline ? {} : { code: sent.conflict ? "board_content_conflict" : refused.code ?? "version_conflict" } };
|
|
183421
183454
|
}
|
|
183422
183455
|
}
|
|
183423
|
-
const
|
|
183424
|
-
|
|
183425
|
-
const
|
|
183426
|
-
if (!
|
|
183456
|
+
const readAt = performance.now();
|
|
183457
|
+
try {
|
|
183458
|
+
const read5 = await prepareTask(ws, !!validation, taskChat);
|
|
183459
|
+
if (!read5.ok && read5.code === "board_content_conflict") {
|
|
183460
|
+
const prepared = await prepareConflictTask(ws);
|
|
183461
|
+
if (!prepared.ok) return prepared;
|
|
183462
|
+
}
|
|
183463
|
+
return read5.ok && validation ? { ok: false, code: "bad_request", error: validation.summary, failure: validation } : read5;
|
|
183464
|
+
} finally {
|
|
183465
|
+
logSync("board.pull.done", { ms: Math.round(performance.now() - readAt) });
|
|
183427
183466
|
}
|
|
183428
|
-
return read5.ok && validation ? { ok: false, code: "bad_request", error: validation.summary, failure: validation } : read5;
|
|
183429
183467
|
}, stopped2);
|
|
183430
183468
|
}
|
|
183431
183469
|
async function prepareConflictTask(ws) {
|
|
@@ -183569,7 +183607,15 @@ async function reconcileBoard(ws, base, board, shared, taskChat, landTask) {
|
|
|
183569
183607
|
const held5 = pendingLandArchives(ws, base).filter(({ task }) => task !== landTask);
|
|
183570
183608
|
const numbers = new Set(held5.map(({ number: number4 }) => number4));
|
|
183571
183609
|
const manifests = new Set(held5.map(({ task }) => assetsFile(task)));
|
|
183572
|
-
|
|
183610
|
+
if (taskChat) {
|
|
183611
|
+
for (const p2 of filesUnder(path42.join(ws.board, ".archive"), ws.board)) {
|
|
183612
|
+
const n = numberOfCard(p2);
|
|
183613
|
+
if (n !== null && n !== ws.number && !base.files[root2 + p2] && archiveMeta(readText(path42.join(ws.board, p2)) ?? "")) {
|
|
183614
|
+
numbers.add(n);
|
|
183615
|
+
}
|
|
183616
|
+
}
|
|
183617
|
+
}
|
|
183618
|
+
const privateArchive = (p2) => numbers.has(numberOfCard(p2) ?? 0) || numbers.has(groupOfCard(p2) ?? 0) || manifests.has(p2);
|
|
183573
183619
|
const snapshot = base.head_seq === null ? base.files : void 0;
|
|
183574
183620
|
if (!snapshot && observeConflicts(ws, base, board.files, shared, privateArchive)) return conflict();
|
|
183575
183621
|
if (snapshot) base.files = {};
|
|
@@ -184258,8 +184304,7 @@ function protectLandArchive(ws, job, stopped2) {
|
|
|
184258
184304
|
if (stopped2() || !ws.number) return;
|
|
184259
184305
|
const file2 = landArchiveMarker(ws.board, ws.task);
|
|
184260
184306
|
if (!isDeepStrictEqual(readLandArchiveOwner(file2), { job, number: ws.number })) {
|
|
184261
|
-
|
|
184262
|
-
fs39.renameSync(`${file2}.tmp`, file2);
|
|
184307
|
+
writeLandArchiveOwner(file2, { job, number: ws.number });
|
|
184263
184308
|
}
|
|
184264
184309
|
const base = readBase(ws);
|
|
184265
184310
|
if (pendingLandArchives(ws, base).some((owner2) => owner2.task === ws.task)) {
|
|
@@ -184282,11 +184327,13 @@ async function sendBoard(ws, machineId, scope) {
|
|
|
184282
184327
|
}
|
|
184283
184328
|
async function sendMarked(ws, job, scope = {}) {
|
|
184284
184329
|
const fields2 = { stage: "push", task: ws.number, job: job.id };
|
|
184330
|
+
const fullBoardSync = !job.id && !ws.cloudTask && !scope.taskChat;
|
|
184331
|
+
const hadUnsent = !fullBoardSync && unsent(ws.cwd);
|
|
184285
184332
|
try {
|
|
184286
184333
|
const pushed = pendingConflicts(ws.board).length ? conflictFailure(ws) : await send2(ws, job, scope);
|
|
184287
184334
|
if (!pushed.ok) logRunner("board", "failed", { ...fields2, code: pushed.code ?? (pushed.offline ? "unreachable" : "unknown_error"), status: pushed.status });
|
|
184288
184335
|
const base = readBase(ws);
|
|
184289
|
-
markUnsent(ws.cwd, !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length || !!base.pendingRemovals?.length || pendingLandArchives(ws, base).length > 0);
|
|
184336
|
+
markUnsent(ws.cwd, hadUnsent || !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length || !!base.pendingRemovals?.length || pendingLandArchives(ws, base).length > 0);
|
|
184290
184337
|
return pushed;
|
|
184291
184338
|
} catch (error62) {
|
|
184292
184339
|
logRunner("board", "failed", { ...fields2, code: errno(error62) });
|
|
@@ -184362,24 +184409,29 @@ function affectedTasks(ws, paths) {
|
|
|
184362
184409
|
}
|
|
184363
184410
|
return tasks;
|
|
184364
184411
|
}
|
|
184365
|
-
async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
184412
|
+
async function send2(ws, job, { paths, taskChat, taskNumber }, retryRestore = true) {
|
|
184366
184413
|
const record2 = readRecord(ws);
|
|
184367
184414
|
const base = readBase(ws);
|
|
184368
184415
|
const fail = (error62, conflict = false, code, status) => ({ ok: false, conflict, error: error62, code, ...status === void 0 ? {} : { status }, ...temporaryCloudFailure({ code, status }) ? { offline: true } : {} });
|
|
184369
184416
|
const boardSync = !job.id && !ws.cloudTask;
|
|
184370
|
-
const
|
|
184371
|
-
|
|
184372
|
-
const
|
|
184417
|
+
const singleTask = ws.cloudTask && ws.number !== null ? { task: ws.cloudTask, number: ws.number, chat: false } : taskChat && taskNumber !== void 0 ? { task: taskChat, number: taskNumber, chat: true } : null;
|
|
184418
|
+
const fullBoardSync = boardSync && !singleTask;
|
|
184419
|
+
const discoverArchives = fullBoardSync && !syncIndex(ws)?.archivesReady;
|
|
184420
|
+
if (fullBoardSync && (!syncIndex(ws)?.ready || discoverArchives)) paths = void 0;
|
|
184421
|
+
const heldTaskPreviews = (base.pendingPreviews ?? []).filter((p2) => !singleTask || numberOfCard(p2) === singleTask.number || groupOfCard(p2) === singleTask.number || taskOfAssets(p2) === singleTask.task);
|
|
184422
|
+
const selected = paths && /* @__PURE__ */ new Set([...paths, ...heldTaskPreviews]);
|
|
184373
184423
|
const pendingArchives = new Map(Object.entries(base.pendingArchives ?? {}));
|
|
184374
|
-
const names2 = selected ? /* @__PURE__ */ new Set([...base.pendingAssets ?? [], ...
|
|
184424
|
+
const names2 = selected ? /* @__PURE__ */ new Set([...base.pendingAssets ?? [], ...fullBoardSync ? pendingArchives.keys() : []]) : null;
|
|
184375
184425
|
if (selected) for (const task of affectedTasks(ws, selected)) names2.add(task);
|
|
184376
|
-
const retired = await cleanRecords(ws, base, { tasks: names2 ?? void 0, taskChat });
|
|
184377
|
-
|
|
184378
|
-
const
|
|
184426
|
+
const retired = await cleanRecords(ws, base, { tasks: singleTask ? [singleTask.task] : names2 ?? void 0, taskChat });
|
|
184427
|
+
const singleFolder = singleTask ? { ...ws, task: singleTask.task, cloudTask: singleTask.task, number: singleTask.number } : null;
|
|
184428
|
+
const singleRecord = singleFolder ? ws.cloudTask ? record2 : readRecord(singleFolder) : record2;
|
|
184429
|
+
if (retired.has(singleFolder?.task ?? ws.task)) singleRecord.deleted = true;
|
|
184430
|
+
const records = singleFolder ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
|
|
184379
184431
|
...filesUnder(path42.join(ws.board, ".sync")).filter((name) => name.endsWith(".json") && !taskOfRemoval(".sync/" + name)),
|
|
184380
184432
|
...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
|
|
184381
184433
|
])];
|
|
184382
|
-
const tasks =
|
|
184434
|
+
const tasks = singleFolder ? [{ folder: singleFolder, record: singleRecord }] : records.flatMap((name) => {
|
|
184383
184435
|
let held5;
|
|
184384
184436
|
try {
|
|
184385
184437
|
held5 = JSON.parse(fs39.readFileSync(path42.join(ws.board, ".sync", name), "utf8"));
|
|
@@ -184402,10 +184454,10 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184402
184454
|
const protectedLists = /* @__PURE__ */ new Set();
|
|
184403
184455
|
const pendingBlockers = /* @__PURE__ */ new Set();
|
|
184404
184456
|
for (const { task, file: file2, job: owner2, number: number4, archived } of pendingLandArchives(ws, base)) {
|
|
184405
|
-
const ownsArchive = owner2 === job.id &&
|
|
184406
|
-
if (!ownsArchive &&
|
|
184457
|
+
const ownsArchive = owner2 !== null && owner2 === job.id && singleTask?.task === task && !singleTask.chat;
|
|
184458
|
+
if (!ownsArchive && fullBoardSync && !task.startsWith("unowned-") && (owner2 === null || base.files[rootOf(ws) + archived])) {
|
|
184407
184459
|
const current2 = await readTask(task);
|
|
184408
|
-
if (current2.ok && current2.value.status === "done") {
|
|
184460
|
+
if (current2.ok && (current2.value.status === "done" || current2.value.status === "cancelled" && !!base.files[rootOf(ws) + archived])) {
|
|
184409
184461
|
fs39.rmSync(file2, { force: true });
|
|
184410
184462
|
continue;
|
|
184411
184463
|
}
|
|
@@ -184421,7 +184473,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184421
184473
|
const processed = /* @__PURE__ */ new Set();
|
|
184422
184474
|
const assetLists = /* @__PURE__ */ new Map();
|
|
184423
184475
|
const generatedAssets = /* @__PURE__ */ new Set();
|
|
184424
|
-
const cards = !selected && !
|
|
184476
|
+
const cards = !selected && !singleFolder ? new Map(
|
|
184425
184477
|
[".archive", "todo"].flatMap((dir) => filesUnder(path42.join(ws.board, dir), ws.board)).flatMap((p2) => {
|
|
184426
184478
|
const number4 = numberOfCard(p2);
|
|
184427
184479
|
return number4 ? [[number4, p2]] : [];
|
|
@@ -184447,7 +184499,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184447
184499
|
return false;
|
|
184448
184500
|
}
|
|
184449
184501
|
});
|
|
184450
|
-
const archive =
|
|
184502
|
+
const archive = fullBoardSync && card.startsWith(".archive/") && !item.record.deleted;
|
|
184451
184503
|
const listPath = assetsFile(item.folder.task);
|
|
184452
184504
|
const archived = !selected && archive && !retryAssets.has(item.folder.task) && !Object.keys(item.record.pendingVersions ?? {}).length && readText(path42.join(ws.board, listPath)) === (base.files[rootOf(ws) + listPath]?.content ?? null) && readText(path42.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
|
|
184453
184505
|
retryAssets.delete(item.folder.task);
|
|
@@ -184481,25 +184533,50 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184481
184533
|
deferredCards.add(item.folder.number);
|
|
184482
184534
|
deferredLists.add(listPath);
|
|
184483
184535
|
}
|
|
184484
|
-
if (
|
|
184536
|
+
if (fullBoardSync) syncIndex(ws).ready = true;
|
|
184485
184537
|
const scoped = selected && [...new Set([...selected].flatMap((p2) => {
|
|
184486
184538
|
if (!isBoardPath(p2) && !fs39.statSync(path42.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
|
|
184487
184539
|
const file2 = path42.join(ws.board, p2);
|
|
184488
184540
|
return fs39.statSync(file2, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file2, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
|
|
184489
184541
|
}))].filter((p2) => fs39.statSync(path42.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
|
|
184490
184542
|
for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
|
|
184491
|
-
|
|
184543
|
+
const ownCardPath = singleFolder ? path42.relative(ws.board, cardFile(singleFolder)).split(path42.sep).join("/") : null;
|
|
184544
|
+
const ownArchived = !!ownCardPath?.startsWith(".archive/");
|
|
184545
|
+
const ownGroup = singleTask ? (ownCardPath ? groupOfCard(ownCardPath) : null) ?? Object.keys(base.files).flatMap((k2) => {
|
|
184546
|
+
if (!k2.startsWith(rootOf(ws))) return [];
|
|
184547
|
+
const rel3 = k2.slice(rootOf(ws).length);
|
|
184548
|
+
return numberOfCard(rel3) === singleTask.number ? [groupOfCard(rel3)] : [];
|
|
184549
|
+
}).find((g3) => g3 !== null) ?? null : null;
|
|
184550
|
+
const outOfTaskScope = (p2) => {
|
|
184551
|
+
if (!singleTask) return false;
|
|
184552
|
+
const assetTask = taskOfAssets(p2);
|
|
184553
|
+
if (assetTask !== null) return assetTask !== singleTask.task;
|
|
184554
|
+
const cardNum = numberOfCard(p2), groupNum = groupOfCard(p2);
|
|
184555
|
+
if (cardNum === null) return false;
|
|
184556
|
+
if (cardNum === singleTask.number || groupNum === singleTask.number) return false;
|
|
184557
|
+
if (p2.startsWith(".archive/") || singleTask.chat) return true;
|
|
184558
|
+
if (!fs39.statSync(path42.join(ws.board, p2), { throwIfNoEntry: false })?.isFile()) return true;
|
|
184559
|
+
if (ownGroup !== null && cardNum === ownGroup) return false;
|
|
184560
|
+
if (ownArchived) {
|
|
184561
|
+
const before = base.files[rootOf(ws) + p2]?.content;
|
|
184562
|
+
const meta3 = before ? parseFrontmatter(before).meta : null;
|
|
184563
|
+
if (meta3 && (meta3.blocked_by.includes(singleTask.number) || meta3.related.includes(singleTask.number))) return false;
|
|
184564
|
+
}
|
|
184565
|
+
return true;
|
|
184566
|
+
};
|
|
184567
|
+
if (!singleTask?.chat) proposeItems(ws, base, scoped);
|
|
184492
184568
|
const shared = sharedMemory(ws.board);
|
|
184493
184569
|
const deferred = new Set((base.deferred ?? []).filter((p2) => !tasks.some((item) => processed.has(item.folder.task) && !deferredCards.has(item.folder.number) && (p2 === assetsFile(item.folder.task) || numberOfCard(p2) === item.folder.number))));
|
|
184494
184570
|
const retiredCards = new Set(tasks.filter((item) => item.record.deleted).map((item) => item.folder.number));
|
|
184495
184571
|
const retiredLists = new Set(tasks.filter((item) => item.record.deleted).map((item) => assetsFile(item.folder.task)));
|
|
184496
184572
|
const defer = (p2) => {
|
|
184497
|
-
if (
|
|
184498
|
-
if (
|
|
184573
|
+
if (outOfTaskScope(p2)) return true;
|
|
184574
|
+
if (protectedCards.has(numberOfCard(p2) ?? 0) || protectedCards.has(groupOfCard(p2) ?? 0) || protectedLists.has(p2)) return true;
|
|
184575
|
+
if (retiredCards.has(numberOfCard(p2) ?? 0) || retiredLists.has(p2)) {
|
|
184499
184576
|
deferred.add(p2);
|
|
184500
184577
|
return true;
|
|
184501
184578
|
}
|
|
184502
|
-
if (!
|
|
184579
|
+
if (!fullBoardSync) return deferred.has(p2);
|
|
184503
184580
|
if (!deferredLists.has(p2) && !deferredCards.has(numberOfCard(p2) ?? 0)) return deferred.has(p2);
|
|
184504
184581
|
deferred.add(p2);
|
|
184505
184582
|
return true;
|
|
@@ -184513,12 +184590,13 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184513
184590
|
const refreshPending = JSON.stringify(pendingAssets) !== JSON.stringify(base.pendingAssets ?? []);
|
|
184514
184591
|
if (refreshDeferred) base.deferred = [...deferred];
|
|
184515
184592
|
if (refreshPending) base.pendingAssets = pendingAssets;
|
|
184516
|
-
const
|
|
184593
|
+
const keepPreview = (p2) => deferred.has(p2) || outOfTaskScope(p2) || protectedCards.has(numberOfCard(p2) ?? 0) || protectedCards.has(groupOfCard(p2) ?? 0) || protectedLists.has(p2) || selected !== void 0 && !selected.has(p2);
|
|
184594
|
+
const pendingPreviews = [.../* @__PURE__ */ new Set([...heldPreviews, ...(base.pendingPreviews ?? []).filter(keepPreview)])];
|
|
184517
184595
|
const refreshPreviews = !isDeepStrictEqual(pendingPreviews, base.pendingPreviews ?? []);
|
|
184518
184596
|
if (refreshPreviews) base.pendingPreviews = pendingPreviews;
|
|
184519
184597
|
if (changed || refreshDeferred || refreshPending || refreshPreviews) writeBase(ws, base);
|
|
184520
184598
|
let operations = {};
|
|
184521
|
-
if (
|
|
184599
|
+
if (fullBoardSync) {
|
|
184522
184600
|
for (const task of processed) {
|
|
184523
184601
|
if (!archives.has(task) && !assetErrors[task]) pendingArchives.delete(task);
|
|
184524
184602
|
}
|
|
@@ -184528,7 +184606,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184528
184606
|
const index = syncIndex(ws);
|
|
184529
184607
|
if (index) index.archivesReady = true;
|
|
184530
184608
|
}
|
|
184531
|
-
const reported = !
|
|
184609
|
+
const reported = !singleTask ? previews : previews.filter((p2) => numberOfCard(p2.file) === singleTask.number);
|
|
184532
184610
|
const tasks2 = { ...assetErrors, ...operations };
|
|
184533
184611
|
const firstError = Object.values(tasks2)[0];
|
|
184534
184612
|
if (reported.length) {
|
|
@@ -184538,7 +184616,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184538
184616
|
if (firstError && (boardSync || firstError.failure)) return { ok: false, conflict: false, ...firstError, tasks: tasks2 };
|
|
184539
184617
|
return { ok: true, changed };
|
|
184540
184618
|
};
|
|
184541
|
-
const local = /* @__PURE__ */ new Set([...scoped ?? localFiles(ws, base), ...assetLists.keys()]);
|
|
184619
|
+
const local = /* @__PURE__ */ new Set([...scoped ?? localFiles(singleFolder ?? ws, base), ...assetLists.keys()]);
|
|
184542
184620
|
const localOf = /* @__PURE__ */ new Map();
|
|
184543
184621
|
const localBefore = /* @__PURE__ */ new Map();
|
|
184544
184622
|
const changes = [];
|
|
@@ -184562,7 +184640,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184562
184640
|
if (Buffer.byteLength(content) > BOARD_FILE_LIMIT) {
|
|
184563
184641
|
const error62 = `${p2}:1 \u2014 File exceeds ${BOARD_FILE_LIMIT / 1024} KB. Move large results to assets and link them from the card.`;
|
|
184564
184642
|
const number4 = numberOfCard(p2);
|
|
184565
|
-
if (number4 === null || number4 ===
|
|
184643
|
+
if (number4 === null || number4 === singleTask?.number) return { ok: false, conflict: false, error: error62, failure: validationFailure(error62, "card_too_large") };
|
|
184566
184644
|
previews.push({ file: p2, line: 1, column: 1, code: "card_too_large", path: "", message: error62, hint: "Shorten the card." });
|
|
184567
184645
|
oversize.add(number4);
|
|
184568
184646
|
heldPreviews.add(p2);
|
|
@@ -184610,9 +184688,75 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184610
184688
|
};
|
|
184611
184689
|
if (oversize.size) holdCards(oversize);
|
|
184612
184690
|
if (!changes.length) return success2(false);
|
|
184691
|
+
const taskOfCardNumber = (number4) => {
|
|
184692
|
+
const indexed = [...syncIndex(ws)?.tasks.values() ?? []].find((t) => t.number === number4)?.task;
|
|
184693
|
+
if (indexed) return indexed;
|
|
184694
|
+
for (const name of filesUnder(path42.join(ws.board, ".sync"))) {
|
|
184695
|
+
if (!name.endsWith(".json") || name.includes("/") || taskOfRemoval(".sync/" + name)) continue;
|
|
184696
|
+
try {
|
|
184697
|
+
const held5 = JSON.parse(fs39.readFileSync(path42.join(ws.board, ".sync", name), "utf8"));
|
|
184698
|
+
if (held5.number === number4 && held5.task && TASK_ID.test(held5.task)) return held5.task;
|
|
184699
|
+
} catch {
|
|
184700
|
+
}
|
|
184701
|
+
}
|
|
184702
|
+
};
|
|
184613
184703
|
const commit = async () => {
|
|
184614
184704
|
while (changes.length) {
|
|
184615
184705
|
const sent2 = await commitBoard(ws.project, job.id, job.machineId, changes);
|
|
184706
|
+
if (!sent2.ok && sent2.code === "conflict" && sent2.error === "The current Land job must synchronize this archive.") {
|
|
184707
|
+
const candidates = [...new Set(changes.flatMap((c2) => {
|
|
184708
|
+
const p2 = localOf.get(c2.path);
|
|
184709
|
+
const n = p2?.startsWith(".archive/") ? numberOfCard(p2) : null;
|
|
184710
|
+
return n !== null && !(singleTask && !singleTask.chat && job.id && n === singleTask.number && readLandArchiveOwner(landArchiveMarker(ws.board, singleTask.task))?.job === job.id) ? [n] : [];
|
|
184711
|
+
}))];
|
|
184712
|
+
const isolatedNumbers = /* @__PURE__ */ new Set();
|
|
184713
|
+
const isolatedTasks = /* @__PURE__ */ new Set();
|
|
184714
|
+
for (const n of candidates) {
|
|
184715
|
+
const task = taskOfCardNumber(n);
|
|
184716
|
+
if (candidates.length > 1 && task) {
|
|
184717
|
+
const current2 = await readTask(task);
|
|
184718
|
+
if (current2.ok && current2.value.status === "done") continue;
|
|
184719
|
+
}
|
|
184720
|
+
writeLandArchiveOwner(landArchiveMarker(ws.board, task ?? `unowned-${n}`), { job: null, number: n });
|
|
184721
|
+
isolatedNumbers.add(n);
|
|
184722
|
+
protectedCards.add(n);
|
|
184723
|
+
if (task) {
|
|
184724
|
+
isolatedTasks.add(task);
|
|
184725
|
+
protectedLists.add(assetsFile(task));
|
|
184726
|
+
pendingArchives.delete(task);
|
|
184727
|
+
retryAssets.delete(task);
|
|
184728
|
+
}
|
|
184729
|
+
}
|
|
184730
|
+
if (isolatedNumbers.size) {
|
|
184731
|
+
const repaired = /* @__PURE__ */ new Set();
|
|
184732
|
+
repairLandBlockers(ws, base, isolatedNumbers, repaired);
|
|
184733
|
+
for (let i = changes.length - 1; i >= 0; i--) {
|
|
184734
|
+
const file2 = localOf.get(changes[i].path);
|
|
184735
|
+
if (!file2) continue;
|
|
184736
|
+
const assetTask = taskOfAssets(file2);
|
|
184737
|
+
const cardNum = numberOfCard(file2), groupNum = groupOfCard(file2);
|
|
184738
|
+
if (assetTask && isolatedTasks.has(assetTask) || cardNum !== null && isolatedNumbers.has(cardNum) || groupNum !== null && isolatedNumbers.has(groupNum)) {
|
|
184739
|
+
changes.splice(i, 1);
|
|
184740
|
+
}
|
|
184741
|
+
}
|
|
184742
|
+
for (const file2 of repaired) {
|
|
184743
|
+
if (defer(file2) || heldPreviews.has(file2)) continue;
|
|
184744
|
+
const content = readText(path42.join(ws.board, file2));
|
|
184745
|
+
if (content === null || Buffer.byteLength(content) > BOARD_FILE_LIMIT) continue;
|
|
184746
|
+
const remote3 = remoteOf(ws, shared, file2);
|
|
184747
|
+
const held5 = base.files[remote3];
|
|
184748
|
+
localOf.set(remote3, file2);
|
|
184749
|
+
localBefore.set(remote3, content);
|
|
184750
|
+
const entry = { path: remote3, content: normalizeCardFrontmatter(content), base_seq: held5?.seq ?? base.deleted?.[remote3] ?? 0 };
|
|
184751
|
+
const existing = changes.findIndex((c2) => c2.path === remote3);
|
|
184752
|
+
if (held5?.content === content) {
|
|
184753
|
+
if (existing >= 0) changes.splice(existing, 1);
|
|
184754
|
+
} else if (existing >= 0) changes[existing] = entry;
|
|
184755
|
+
else changes.push(entry);
|
|
184756
|
+
}
|
|
184757
|
+
continue;
|
|
184758
|
+
}
|
|
184759
|
+
}
|
|
184616
184760
|
if (sent2.ok || !sent2.previewProblems?.length) return sent2;
|
|
184617
184761
|
logRunner("board", "failed", { stage: "push", task: ws.number, job: job.id, code: sent2.code ?? "bad_request", status: sent2.status });
|
|
184618
184762
|
const problems = sent2.previewProblems;
|
|
@@ -184621,7 +184765,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
184621
184765
|
const numbers = new Set(problems.map((p2) => numberOfCard(p2.file)));
|
|
184622
184766
|
for (const problem2 of problems) previews.push(problem2);
|
|
184623
184767
|
holdCards(numbers);
|
|
184624
|
-
const own3 = previews.filter((p2) => numberOfCard(p2.file) ===
|
|
184768
|
+
const own3 = previews.filter((p2) => numberOfCard(p2.file) === singleTask?.number);
|
|
184625
184769
|
if (job.id && own3.length) return { ...sent2, error: describeTaskPreviewProblems(own3) };
|
|
184626
184770
|
}
|
|
184627
184771
|
return null;
|
|
@@ -189046,7 +189190,13 @@ function runCommand(akb, ws, args2) {
|
|
|
189046
189190
|
return runAkb(akb, ["run", ...args2, "--board", ws.board, "--json"], { cwd: ws.cwd, board: ws.board });
|
|
189047
189191
|
}
|
|
189048
189192
|
async function boardRuns(akb, ws, scope) {
|
|
189049
|
-
|
|
189193
|
+
const ran = await runCommand(akb, ws, ["list", "--all", ...scope]);
|
|
189194
|
+
const parsed = answerOf2(ran);
|
|
189195
|
+
if (parsed?.runs) return parsed.runs;
|
|
189196
|
+
if (parsed?.error?.kind === "no-board" && !fs64.existsSync(path66.join(ws.board, "config.md")) && !fs64.existsSync(path66.join(ws.board, "todo")) && !fs64.existsSync(path66.join(projectStateDir(ws.board), "sessions.json"))) {
|
|
189197
|
+
return [];
|
|
189198
|
+
}
|
|
189199
|
+
return void 0;
|
|
189050
189200
|
}
|
|
189051
189201
|
var jobOwns = (run3, job, machine) => run3.cloudExecution?.job === job && run3.cloudExecution.machine === machine;
|
|
189052
189202
|
var onTask = (run3, card) => run3.cardId === card && (run3.cloudExecution?.card === void 0 || run3.cloudExecution.card === card);
|
|
@@ -189263,7 +189413,7 @@ function runsSpent(runs, since, job, io, machine, card) {
|
|
|
189263
189413
|
async function runReview(job, ws, tasks, deps, io) {
|
|
189264
189414
|
const since = Date.now();
|
|
189265
189415
|
const failed = await setUp(job, ws, deps, io);
|
|
189266
|
-
if (failed) return { ok: false, reason: failed };
|
|
189416
|
+
if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
|
|
189267
189417
|
const akb = boardAkb(job, ws, deps, io);
|
|
189268
189418
|
const args2 = io.flowRun ? recoveryArgs(io.flowRun) : ["memory", "review", "--task", ...tasks];
|
|
189269
189419
|
const ran = await akb([...args2, "--follow", "--events", "--json"], true);
|
|
@@ -189312,7 +189462,7 @@ async function runAgent(job, ws, deps, io) {
|
|
|
189312
189462
|
if (studio2) return { ok: false, reason: "Studio roles no longer run on their own." };
|
|
189313
189463
|
const since = Date.now();
|
|
189314
189464
|
const failed = await setUp(job, ws, deps, io);
|
|
189315
|
-
if (failed) return { ok: false, reason: failed };
|
|
189465
|
+
if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
|
|
189316
189466
|
if (io.flowRun) {
|
|
189317
189467
|
const args3 = recoveryArgs(io.flowRun);
|
|
189318
189468
|
const akb2 = boardAkb(job, ws, deps, io);
|
|
@@ -189463,7 +189613,7 @@ async function runFlow(job, ws, deps, io) {
|
|
|
189463
189613
|
}
|
|
189464
189614
|
}
|
|
189465
189615
|
const failed = await setUp(job, ws, deps, io);
|
|
189466
|
-
if (failed) return
|
|
189616
|
+
if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
|
|
189467
189617
|
let id2 = akbCardOf(ws);
|
|
189468
189618
|
if (flow.phase === "land") {
|
|
189469
189619
|
try {
|
|
@@ -189595,7 +189745,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
189595
189745
|
} };
|
|
189596
189746
|
};
|
|
189597
189747
|
const localArchive = () => isArchived(ws, card) && !asks(cardFile(ws)) && isSuccessfulArchive(cardFile(ws));
|
|
189598
|
-
if (localArchive() && deliveryId
|
|
189748
|
+
if (localArchive() && (deliveryId ? observed.kind === "completed" || observed.kind === "resumable" : !flow.delivery_id && observed.kind === "none")) {
|
|
189599
189749
|
if (observed.kind === "resumable") {
|
|
189600
189750
|
const saved = await akb(["task", "archive", String(card), "--json"]);
|
|
189601
189751
|
if (saved.code !== 0) return fail(refusal2(saved));
|
|
@@ -189702,6 +189852,9 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
189702
189852
|
if (io.lost()) return fail("");
|
|
189703
189853
|
const runs2 = answerOf2(await akb(["run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
|
|
189704
189854
|
const spent = spentBy([...learned, ...runsSpent(runs2, since, job, io, deps.machineId, card)], job);
|
|
189855
|
+
if (flow.phase === "implement") {
|
|
189856
|
+
return { ok: true, report: { ...spent, card, landReady: { deliveryId: reconciled.deliveryId } } };
|
|
189857
|
+
}
|
|
189705
189858
|
return {
|
|
189706
189859
|
ok: true,
|
|
189707
189860
|
report: {
|
|
@@ -189713,6 +189866,14 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
189713
189866
|
}
|
|
189714
189867
|
};
|
|
189715
189868
|
}
|
|
189869
|
+
if (flow.phase === "implement" && verb === "implement" && (!reconciled || reconciled.kind === "none") && isArchived(ws, card) && !asks(cardFile(ws)) && isSuccessfulArchive(cardFile(ws))) {
|
|
189870
|
+
const denied = await refreshReview("implement");
|
|
189871
|
+
if (denied) return fail(denied);
|
|
189872
|
+
if (io.lost()) return fail("");
|
|
189873
|
+
const runs2 = answerOf2(await akb(["run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
|
|
189874
|
+
const spent = spentBy([...learned, ...runsSpent(runs2, since, job, io, deps.machineId, card)], job);
|
|
189875
|
+
return { ok: true, report: { ...spent, card, landReady: {} } };
|
|
189876
|
+
}
|
|
189716
189877
|
const runs = await boardRuns(deps.akb, ws, ["--card", String(card)]);
|
|
189717
189878
|
if (!runs) return unverifiedResume(resumeBlocked({ stopped: false }, cloudLanguage(job) === "zh"));
|
|
189718
189879
|
if (runs.some((run3) => !jobOwns(run3, job.id, deps.machineId) && !runStopped(run3))) return fail(`#${card} is already being worked on`);
|
|
@@ -189776,6 +189937,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
189776
189937
|
return fail(mismatchedReceipt);
|
|
189777
189938
|
}
|
|
189778
189939
|
if (restored.code === 0 && resumed?.landed && resumed.deliveryId) {
|
|
189940
|
+
if (flow.phase === "implement") return { ok: true, report: { card: id3, landReady: { deliveryId: resumed.deliveryId } } };
|
|
189779
189941
|
return { ok: true, report: { card: id3, deliveryCompleted: true, deliveryId: resumed.deliveryId, ...landingOf(resumed.delivery) } };
|
|
189780
189942
|
}
|
|
189781
189943
|
const reason = restored.code === 0 ? void 0 : resumed?.error?.reason;
|
|
@@ -189967,7 +190129,15 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
189967
190129
|
report: { ...spent, ...tracked, failure: failureDetail }
|
|
189968
190130
|
};
|
|
189969
190131
|
}
|
|
189970
|
-
if (flow.phase === "implement" && effectiveVerb === "implement" && !rejected && !asked && !waiting
|
|
190132
|
+
if (flow.phase === "implement" && effectiveVerb === "implement" && !rejected && !asked && !waiting) {
|
|
190133
|
+
if (completed) return { ok: true, report: {
|
|
190134
|
+
...spent,
|
|
190135
|
+
card: id3,
|
|
190136
|
+
landReady: { deliveryId: completed },
|
|
190137
|
+
session: recent?.resumeId ?? answer?.agentSession,
|
|
190138
|
+
reply: recent?.result,
|
|
190139
|
+
...history.length ? { retries: history } : {}
|
|
190140
|
+
} };
|
|
189971
190141
|
if (!deliveryId || !recent || !runStopped(recent)) return fail("The implementation result or delivery workspace was not saved.");
|
|
189972
190142
|
return { ok: true, report: {
|
|
189973
190143
|
...spent,
|
|
@@ -191430,7 +191600,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
191430
191600
|
saved.report = report2;
|
|
191431
191601
|
}
|
|
191432
191602
|
}
|
|
191433
|
-
if (flow &&
|
|
191603
|
+
if (flow && (priorExecution || sourceId) && job.projectDir) {
|
|
191434
191604
|
const folder3 = folderFor(job);
|
|
191435
191605
|
if (folder3 && !("refused" in folder3)) {
|
|
191436
191606
|
const ws2 = openTaskFolder(job, folder3.cwd);
|
|
@@ -192695,10 +192865,11 @@ ${body}` : body;
|
|
|
192695
192865
|
if (stopped3) return finishClaimed("stopped", "", { ...result.report, ...proof });
|
|
192696
192866
|
if (!result.ok) {
|
|
192697
192867
|
const reason = result.exhausted || result.failure?.code === "retry_exhausted" ? "task_retry_exhausted: " + result.reason : result.reason;
|
|
192868
|
+
const safeToRetry = result.exhausted === true || result.safeToRetry === true;
|
|
192698
192869
|
const failureDetail2 = result.report?.failure ?? buildFailureDetail(
|
|
192699
192870
|
result.failure ?? makeFailure("runtime", result.reason || "The run failed."),
|
|
192700
|
-
result.exhausted ? "limit" : "unsafe",
|
|
192701
|
-
|
|
192871
|
+
result.exhausted ? "limit" : safeToRetry ? "manual" : "unsafe",
|
|
192872
|
+
safeToRetry,
|
|
192702
192873
|
void 0,
|
|
192703
192874
|
result.reason
|
|
192704
192875
|
);
|