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
package/dist/runner.mjs
CHANGED
|
@@ -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;
|
|
@@ -146504,8 +146504,8 @@ function status(line) {
|
|
|
146504
146504
|
}
|
|
146505
146505
|
|
|
146506
146506
|
// src/protocol.ts
|
|
146507
|
-
var VERSION = true ? "0.6.
|
|
146508
|
-
var AKB_VERSION = true ? "0.11.
|
|
146507
|
+
var VERSION = true ? "0.6.125" : "0.0.0";
|
|
146508
|
+
var AKB_VERSION = true ? "0.11.107" : "0.0.0";
|
|
146509
146509
|
var AKB_CONTRACT = true ? 41 : 0;
|
|
146510
146510
|
var EXIT_REFUSED = 10;
|
|
146511
146511
|
var EXIT_OUTDATED = 11;
|
|
@@ -148252,7 +148252,7 @@ function createTail(log) {
|
|
|
148252
148252
|
// ../cli/package.json
|
|
148253
148253
|
var package_default = {
|
|
148254
148254
|
name: "wildcrane",
|
|
148255
|
-
version: "0.11.
|
|
148255
|
+
version: "0.11.107",
|
|
148256
148256
|
akbContract: 41,
|
|
148257
148257
|
canonicalCommands: true,
|
|
148258
148258
|
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.",
|
|
@@ -153979,14 +153979,48 @@ function keepSecrets(runtime, given) {
|
|
|
153979
153979
|
}
|
|
153980
153980
|
var secretsSet = () => Object.fromEntries(Object.entries(readAll()).map(([id2, keys]) => [id2, Object.keys(keys)]));
|
|
153981
153981
|
|
|
153982
|
+
// src/sync-debug.ts
|
|
153983
|
+
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
153984
|
+
var syncDebug = process.env.WILDCRANE_DEBUG_SYNC === "1";
|
|
153985
|
+
var counts = {};
|
|
153986
|
+
function countSync(name, amount = 1) {
|
|
153987
|
+
if (syncDebug) counts[name] = (counts[name] ?? 0) + amount;
|
|
153988
|
+
}
|
|
153989
|
+
function logSync(event2, fields2 = {}) {
|
|
153990
|
+
if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
|
|
153991
|
+
}
|
|
153992
|
+
if (syncDebug) {
|
|
153993
|
+
const delay5 = monitorEventLoopDelay({ resolution: 20 });
|
|
153994
|
+
delay5.enable();
|
|
153995
|
+
let cpu = process.cpuUsage();
|
|
153996
|
+
let at2 = performance.now();
|
|
153997
|
+
setInterval(() => {
|
|
153998
|
+
const now = performance.now();
|
|
153999
|
+
const used = process.cpuUsage(cpu);
|
|
154000
|
+
logSync("health", {
|
|
154001
|
+
cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
|
|
154002
|
+
delayMaxMs: Math.round(delay5.max / 1e6),
|
|
154003
|
+
delayP99Ms: Math.round(delay5.percentile(99) / 1e6),
|
|
154004
|
+
...counts
|
|
154005
|
+
});
|
|
154006
|
+
for (const name of Object.keys(counts)) delete counts[name];
|
|
154007
|
+
cpu = process.cpuUsage();
|
|
154008
|
+
at2 = now;
|
|
154009
|
+
delay5.reset();
|
|
154010
|
+
}, 5e3).unref();
|
|
154011
|
+
}
|
|
154012
|
+
|
|
153982
154013
|
// src/api.ts
|
|
153983
154014
|
var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok", "antigravity"];
|
|
153984
154015
|
var PROTOCOL = 33;
|
|
153985
154016
|
var TIMEOUT_MS = 2e4;
|
|
153986
154017
|
async function send(method, route, body, signedIn, ms, type, extra = {}) {
|
|
154018
|
+
const started = performance.now();
|
|
154019
|
+
const endpoint = route.split("?")[0];
|
|
153987
154020
|
const headers = { accept: "application/json", ...extra };
|
|
153988
154021
|
if (signedIn) {
|
|
153989
154022
|
const token = await accessToken();
|
|
154023
|
+
logSync("http.auth", { method, endpoint, ms: Math.round(performance.now() - started), ok: token.ok });
|
|
153990
154024
|
if (!token.ok) {
|
|
153991
154025
|
return token.reason === "unreachable" ? { ok: false, error: token.error } : { ok: false, error: "Sign in again.", code: "unauthenticated" };
|
|
153992
154026
|
}
|
|
@@ -154001,8 +154035,10 @@ async function send(method, route, body, signedIn, ms, type, extra = {}) {
|
|
|
154001
154035
|
body: body === void 0 ? void 0 : raw ? body : JSON.stringify(body),
|
|
154002
154036
|
signal: AbortSignal.timeout(ms)
|
|
154003
154037
|
});
|
|
154038
|
+
logSync("http.headers", { method, endpoint, ms: Math.round(performance.now() - started), status: response.status });
|
|
154004
154039
|
return { ok: true, value: response };
|
|
154005
154040
|
} catch (e2) {
|
|
154041
|
+
logSync("http.failed", { method, endpoint, ms: Math.round(performance.now() - started) });
|
|
154006
154042
|
return { ok: false, error: e2 instanceof Error ? e2.message : String(e2) };
|
|
154007
154043
|
}
|
|
154008
154044
|
}
|
|
@@ -154020,8 +154056,11 @@ async function answerOf(response) {
|
|
|
154020
154056
|
};
|
|
154021
154057
|
}
|
|
154022
154058
|
async function request(method, route, body, signedIn = true) {
|
|
154059
|
+
const started = performance.now();
|
|
154023
154060
|
const sent = await send(method, route, body, signedIn, TIMEOUT_MS);
|
|
154024
|
-
|
|
154061
|
+
const result = sent.ok ? await answerOf(sent.value) : sent;
|
|
154062
|
+
logSync("http.done", { method, endpoint: route.split("?")[0], ms: Math.round(performance.now() - started), ok: result.ok });
|
|
154063
|
+
return result;
|
|
154025
154064
|
}
|
|
154026
154065
|
var FILE_TIMEOUT_MS = 10 * 6e4;
|
|
154027
154066
|
async function download(route, studioBytes) {
|
|
@@ -155482,6 +155521,11 @@ function numberOfCard(path90) {
|
|
|
155482
155521
|
const n = ROOT.exec(path90)?.[1] ?? CARD.exec(path90)?.[1];
|
|
155483
155522
|
return n ? Number(n) : null;
|
|
155484
155523
|
}
|
|
155524
|
+
function groupOfCard(path90) {
|
|
155525
|
+
if (ROOT.test(path90) || !CARD.test(path90)) return null;
|
|
155526
|
+
const folder2 = /(?:^|\/)(\d+)-[^/]+\/[^/]+$/.exec(path90)?.[1];
|
|
155527
|
+
return folder2 ? Number(folder2) : null;
|
|
155528
|
+
}
|
|
155485
155529
|
var assetsFile = (task) => `assets/${task}.json`;
|
|
155486
155530
|
var taskOfAssets = (path90) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path90)?.[1] ?? null;
|
|
155487
155531
|
var studioFolder = (id2) => id2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -157335,11 +157379,18 @@ function readLandArchiveOwner(file3) {
|
|
|
157335
157379
|
const saved = fs40.readFileSync(file3, "utf8");
|
|
157336
157380
|
if (/^[\w-]{1,100}$/.test(saved)) return { job: saved };
|
|
157337
157381
|
const owner2 = JSON.parse(saved);
|
|
157338
|
-
|
|
157382
|
+
const validJob = owner2?.job === null || typeof owner2?.job === "string" && !!owner2.job.trim();
|
|
157383
|
+
return validJob && Number.isSafeInteger(owner2?.number) && owner2.number > 0 ? { job: owner2.job, number: owner2.number } : null;
|
|
157339
157384
|
} catch {
|
|
157340
157385
|
return null;
|
|
157341
157386
|
}
|
|
157342
157387
|
}
|
|
157388
|
+
function writeLandArchiveOwner(file3, owner2) {
|
|
157389
|
+
fs40.mkdirSync(path42.dirname(file3), { recursive: true });
|
|
157390
|
+
const tmp = `${file3}.${process.pid}.tmp`;
|
|
157391
|
+
fs40.writeFileSync(tmp, JSON.stringify(owner2));
|
|
157392
|
+
fs40.renameSync(tmp, file3);
|
|
157393
|
+
}
|
|
157343
157394
|
function landArchiveOwners(board, pending) {
|
|
157344
157395
|
const dir = markerDirectory(board);
|
|
157345
157396
|
let entries;
|
|
@@ -179166,7 +179217,15 @@ function studioEntry(id2, name, version2, action, command = "akb studio file") {
|
|
|
179166
179217
|
return ["studio", "Studio: " + name + ". Read `" + command + " " + studioName(id2) + " STUDIO.md`" + read6 + ".", void 0, JSON.stringify([id2, name, version2, command])];
|
|
179167
179218
|
}
|
|
179168
179219
|
function compactReview(review, assigned) {
|
|
179169
|
-
if (isFlatReviewPlan(review.plan))
|
|
179220
|
+
if (isFlatReviewPlan(review.plan)) {
|
|
179221
|
+
const pending = (review.approvals ?? []).filter((approval) => "preview" in approval);
|
|
179222
|
+
return [
|
|
179223
|
+
"Review r" + review.revision + " \xB7 flat plan",
|
|
179224
|
+
"Selected Previews: " + (review.plan.previews.join(", ") || "none"),
|
|
179225
|
+
"Review rule: " + (review.plan.rule || "No extra approval."),
|
|
179226
|
+
...pending.length ? ["Pending approvals:", ...pending.map(({ preview, stage, revision, question }) => `- ${preview} \xB7 ${stage} \xB7 r${revision}: ${question}`)] : []
|
|
179227
|
+
].map((line) => line.replace(/[\r\n]+/g, " ")).join("\n");
|
|
179228
|
+
}
|
|
179170
179229
|
const authorization = reviewAuthorization(review, assigned);
|
|
179171
179230
|
if (authorization.kind === "changed") return "Review r" + review.revision + " \xB7 authorization changed. Read the task again.";
|
|
179172
179231
|
const custom2 = review.preview_definitions?.length ? "\nCustom Previews: " + review.preview_definitions.map((d2) => d2.id).join(", ") : "";
|
|
@@ -185648,37 +185707,6 @@ function retireKanbanSkill(dir) {
|
|
|
185648
185707
|
}
|
|
185649
185708
|
}
|
|
185650
185709
|
|
|
185651
|
-
// src/sync-debug.ts
|
|
185652
|
-
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
185653
|
-
var syncDebug = process.env.WILDCRANE_DEBUG_SYNC === "1";
|
|
185654
|
-
var counts = {};
|
|
185655
|
-
function countSync(name, amount = 1) {
|
|
185656
|
-
if (syncDebug) counts[name] = (counts[name] ?? 0) + amount;
|
|
185657
|
-
}
|
|
185658
|
-
function logSync(event2, fields2 = {}) {
|
|
185659
|
-
if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
|
|
185660
|
-
}
|
|
185661
|
-
if (syncDebug) {
|
|
185662
|
-
const delay5 = monitorEventLoopDelay({ resolution: 20 });
|
|
185663
|
-
delay5.enable();
|
|
185664
|
-
let cpu = process.cpuUsage();
|
|
185665
|
-
let at2 = performance.now();
|
|
185666
|
-
setInterval(() => {
|
|
185667
|
-
const now = performance.now();
|
|
185668
|
-
const used = process.cpuUsage(cpu);
|
|
185669
|
-
logSync("health", {
|
|
185670
|
-
cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
|
|
185671
|
-
delayMaxMs: Math.round(delay5.max / 1e6),
|
|
185672
|
-
delayP99Ms: Math.round(delay5.percentile(99) / 1e6),
|
|
185673
|
-
...counts
|
|
185674
|
-
});
|
|
185675
|
-
for (const name of Object.keys(counts)) delete counts[name];
|
|
185676
|
-
cpu = process.cpuUsage();
|
|
185677
|
-
at2 = now;
|
|
185678
|
-
delay5.reset();
|
|
185679
|
-
}, 5e3).unref();
|
|
185680
|
-
}
|
|
185681
|
-
|
|
185682
185710
|
// src/task-folder.ts
|
|
185683
185711
|
var validationFailure = (reason, code = "validation_failed") => makeFailure("validation", reason, { code, detail: reason });
|
|
185684
185712
|
var TASK_ID = /^[\w-]{1,100}$/;
|
|
@@ -186060,7 +186088,12 @@ function pull(ws, machineId2, stopped2, mode) {
|
|
|
186060
186088
|
const taskChat = mode === "chat" ? ws.task : void 0;
|
|
186061
186089
|
return whenPrepared(ws, { ok: false, code: "stopped", error: "Task preparation stopped." }, async () => {
|
|
186062
186090
|
if (mode === "land") return prepareTask(ws, true, void 0, ws.task);
|
|
186063
|
-
const
|
|
186091
|
+
const started = performance.now();
|
|
186092
|
+
const sent = await sendBoard(boardFolder(ws), machineId2, {
|
|
186093
|
+
taskChat,
|
|
186094
|
+
...mode === "chat" && ws.number !== null ? { taskNumber: ws.number } : {}
|
|
186095
|
+
});
|
|
186096
|
+
logSync("board.push.done", { ms: Math.round(performance.now() - started), ok: sent.ok });
|
|
186064
186097
|
let validation;
|
|
186065
186098
|
if (!sent.ok) {
|
|
186066
186099
|
const previews = sent.previews?.filter((p2) => numberOfCard(p2.file) === ws.number);
|
|
@@ -186075,12 +186108,17 @@ function pull(ws, machineId2, stopped2, mode) {
|
|
|
186075
186108
|
return { ok: false, error: `This computer's board changes could not be sent: ${refused2.error}`, ...refused2.offline ? {} : { code: sent.conflict ? "board_content_conflict" : refused2.code ?? "version_conflict" } };
|
|
186076
186109
|
}
|
|
186077
186110
|
}
|
|
186078
|
-
const
|
|
186079
|
-
|
|
186080
|
-
const
|
|
186081
|
-
if (!
|
|
186111
|
+
const readAt = performance.now();
|
|
186112
|
+
try {
|
|
186113
|
+
const read6 = await prepareTask(ws, !!validation, taskChat);
|
|
186114
|
+
if (!read6.ok && read6.code === "board_content_conflict") {
|
|
186115
|
+
const prepared = await prepareConflictTask(ws);
|
|
186116
|
+
if (!prepared.ok) return prepared;
|
|
186117
|
+
}
|
|
186118
|
+
return read6.ok && validation ? { ok: false, code: "bad_request", error: validation.summary, failure: validation } : read6;
|
|
186119
|
+
} finally {
|
|
186120
|
+
logSync("board.pull.done", { ms: Math.round(performance.now() - readAt) });
|
|
186082
186121
|
}
|
|
186083
|
-
return read6.ok && validation ? { ok: false, code: "bad_request", error: validation.summary, failure: validation } : read6;
|
|
186084
186122
|
}, stopped2);
|
|
186085
186123
|
}
|
|
186086
186124
|
async function prepareConflictTask(ws) {
|
|
@@ -186234,7 +186272,15 @@ async function reconcileBoard(ws, base, board, shared, taskChat, landTask) {
|
|
|
186234
186272
|
const held5 = pendingLandArchives(ws, base).filter(({ task }) => task !== landTask);
|
|
186235
186273
|
const numbers = new Set(held5.map(({ number: number4 }) => number4));
|
|
186236
186274
|
const manifests = new Set(held5.map(({ task }) => assetsFile(task)));
|
|
186237
|
-
|
|
186275
|
+
if (taskChat) {
|
|
186276
|
+
for (const p2 of filesUnder(path52.join(ws.board, ".archive"), ws.board)) {
|
|
186277
|
+
const n = numberOfCard(p2);
|
|
186278
|
+
if (n !== null && n !== ws.number && !base.files[root2 + p2] && archiveMeta(readText(path52.join(ws.board, p2)) ?? "")) {
|
|
186279
|
+
numbers.add(n);
|
|
186280
|
+
}
|
|
186281
|
+
}
|
|
186282
|
+
}
|
|
186283
|
+
const privateArchive = (p2) => numbers.has(numberOfCard(p2) ?? 0) || numbers.has(groupOfCard(p2) ?? 0) || manifests.has(p2);
|
|
186238
186284
|
const snapshot = base.head_seq === null ? base.files : void 0;
|
|
186239
186285
|
if (!snapshot && observeConflicts(ws, base, board.files, shared, privateArchive)) return conflict();
|
|
186240
186286
|
if (snapshot) base.files = {};
|
|
@@ -186930,8 +186976,7 @@ function protectLandArchive(ws, job, stopped2) {
|
|
|
186930
186976
|
if (stopped2() || !ws.number) return;
|
|
186931
186977
|
const file3 = landArchiveMarker(ws.board, ws.task);
|
|
186932
186978
|
if (!isDeepStrictEqual(readLandArchiveOwner(file3), { job, number: ws.number })) {
|
|
186933
|
-
|
|
186934
|
-
fs48.renameSync(`${file3}.tmp`, file3);
|
|
186979
|
+
writeLandArchiveOwner(file3, { job, number: ws.number });
|
|
186935
186980
|
}
|
|
186936
186981
|
const base = readBase(ws);
|
|
186937
186982
|
if (pendingLandArchives(ws, base).some((owner2) => owner2.task === ws.task)) {
|
|
@@ -186954,11 +186999,13 @@ async function sendBoard(ws, machineId2, scope) {
|
|
|
186954
186999
|
}
|
|
186955
187000
|
async function sendMarked(ws, job, scope = {}) {
|
|
186956
187001
|
const fields2 = { stage: "push", task: ws.number, job: job.id };
|
|
187002
|
+
const fullBoardSync = !job.id && !ws.cloudTask && !scope.taskChat;
|
|
187003
|
+
const hadUnsent = !fullBoardSync && unsent(ws.cwd);
|
|
186957
187004
|
try {
|
|
186958
187005
|
const pushed = pendingConflicts(ws.board).length ? conflictFailure(ws) : await send2(ws, job, scope);
|
|
186959
187006
|
if (!pushed.ok) logRunner("board", "failed", { ...fields2, code: pushed.code ?? (pushed.offline ? "unreachable" : "unknown_error"), status: pushed.status });
|
|
186960
187007
|
const base = readBase(ws);
|
|
186961
|
-
markUnsent(ws.cwd, !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length || !!base.pendingRemovals?.length || pendingLandArchives(ws, base).length > 0);
|
|
187008
|
+
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);
|
|
186962
187009
|
return pushed;
|
|
186963
187010
|
} catch (error62) {
|
|
186964
187011
|
logRunner("board", "failed", { ...fields2, code: errno(error62) });
|
|
@@ -187034,24 +187081,29 @@ function affectedTasks(ws, paths) {
|
|
|
187034
187081
|
}
|
|
187035
187082
|
return tasks;
|
|
187036
187083
|
}
|
|
187037
|
-
async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
187084
|
+
async function send2(ws, job, { paths, taskChat, taskNumber }, retryRestore = true) {
|
|
187038
187085
|
const record2 = readRecord(ws);
|
|
187039
187086
|
const base = readBase(ws);
|
|
187040
187087
|
const fail = (error62, conflict = false, code, status2) => ({ ok: false, conflict, error: error62, code, ...status2 === void 0 ? {} : { status: status2 }, ...temporaryCloudFailure({ code, status: status2 }) ? { offline: true } : {} });
|
|
187041
187088
|
const boardSync = !job.id && !ws.cloudTask;
|
|
187042
|
-
const
|
|
187043
|
-
|
|
187044
|
-
const
|
|
187089
|
+
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;
|
|
187090
|
+
const fullBoardSync = boardSync && !singleTask;
|
|
187091
|
+
const discoverArchives = fullBoardSync && !syncIndex(ws)?.archivesReady;
|
|
187092
|
+
if (fullBoardSync && (!syncIndex(ws)?.ready || discoverArchives)) paths = void 0;
|
|
187093
|
+
const heldTaskPreviews = (base.pendingPreviews ?? []).filter((p2) => !singleTask || numberOfCard(p2) === singleTask.number || groupOfCard(p2) === singleTask.number || taskOfAssets(p2) === singleTask.task);
|
|
187094
|
+
const selected2 = paths && /* @__PURE__ */ new Set([...paths, ...heldTaskPreviews]);
|
|
187045
187095
|
const pendingArchives = new Map(Object.entries(base.pendingArchives ?? {}));
|
|
187046
|
-
const names2 = selected2 ? /* @__PURE__ */ new Set([...base.pendingAssets ?? [], ...
|
|
187096
|
+
const names2 = selected2 ? /* @__PURE__ */ new Set([...base.pendingAssets ?? [], ...fullBoardSync ? pendingArchives.keys() : []]) : null;
|
|
187047
187097
|
if (selected2) for (const task of affectedTasks(ws, selected2)) names2.add(task);
|
|
187048
|
-
const retired = await cleanRecords(ws, base, { tasks: names2 ?? void 0, taskChat });
|
|
187049
|
-
|
|
187050
|
-
const
|
|
187098
|
+
const retired = await cleanRecords(ws, base, { tasks: singleTask ? [singleTask.task] : names2 ?? void 0, taskChat });
|
|
187099
|
+
const singleFolder = singleTask ? { ...ws, task: singleTask.task, cloudTask: singleTask.task, number: singleTask.number } : null;
|
|
187100
|
+
const singleRecord = singleFolder ? ws.cloudTask ? record2 : readRecord(singleFolder) : record2;
|
|
187101
|
+
if (retired.has(singleFolder?.task ?? ws.task)) singleRecord.deleted = true;
|
|
187102
|
+
const records = singleFolder ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
|
|
187051
187103
|
...filesUnder(path52.join(ws.board, ".sync")).filter((name) => name.endsWith(".json") && !taskOfRemoval(".sync/" + name)),
|
|
187052
187104
|
...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
|
|
187053
187105
|
])];
|
|
187054
|
-
const tasks =
|
|
187106
|
+
const tasks = singleFolder ? [{ folder: singleFolder, record: singleRecord }] : records.flatMap((name) => {
|
|
187055
187107
|
let held5;
|
|
187056
187108
|
try {
|
|
187057
187109
|
held5 = JSON.parse(fs48.readFileSync(path52.join(ws.board, ".sync", name), "utf8"));
|
|
@@ -187074,10 +187126,10 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187074
187126
|
const protectedLists = /* @__PURE__ */ new Set();
|
|
187075
187127
|
const pendingBlockers = /* @__PURE__ */ new Set();
|
|
187076
187128
|
for (const { task, file: file3, job: owner2, number: number4, archived } of pendingLandArchives(ws, base)) {
|
|
187077
|
-
const ownsArchive = owner2 === job.id &&
|
|
187078
|
-
if (!ownsArchive &&
|
|
187129
|
+
const ownsArchive = owner2 !== null && owner2 === job.id && singleTask?.task === task && !singleTask.chat;
|
|
187130
|
+
if (!ownsArchive && fullBoardSync && !task.startsWith("unowned-") && (owner2 === null || base.files[rootOf(ws) + archived])) {
|
|
187079
187131
|
const current2 = await readTask(task);
|
|
187080
|
-
if (current2.ok && current2.value.status === "done") {
|
|
187132
|
+
if (current2.ok && (current2.value.status === "done" || current2.value.status === "cancelled" && !!base.files[rootOf(ws) + archived])) {
|
|
187081
187133
|
fs48.rmSync(file3, { force: true });
|
|
187082
187134
|
continue;
|
|
187083
187135
|
}
|
|
@@ -187093,7 +187145,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187093
187145
|
const processed = /* @__PURE__ */ new Set();
|
|
187094
187146
|
const assetLists = /* @__PURE__ */ new Map();
|
|
187095
187147
|
const generatedAssets = /* @__PURE__ */ new Set();
|
|
187096
|
-
const cards = !selected2 && !
|
|
187148
|
+
const cards = !selected2 && !singleFolder ? new Map(
|
|
187097
187149
|
[".archive", "todo"].flatMap((dir) => filesUnder(path52.join(ws.board, dir), ws.board)).flatMap((p2) => {
|
|
187098
187150
|
const number4 = numberOfCard(p2);
|
|
187099
187151
|
return number4 ? [[number4, p2]] : [];
|
|
@@ -187119,7 +187171,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187119
187171
|
return false;
|
|
187120
187172
|
}
|
|
187121
187173
|
});
|
|
187122
|
-
const archive =
|
|
187174
|
+
const archive = fullBoardSync && card.startsWith(".archive/") && !item.record.deleted;
|
|
187123
187175
|
const listPath = assetsFile(item.folder.task);
|
|
187124
187176
|
const archived = !selected2 && archive && !retryAssets.has(item.folder.task) && !Object.keys(item.record.pendingVersions ?? {}).length && readText(path52.join(ws.board, listPath)) === (base.files[rootOf(ws) + listPath]?.content ?? null) && readText(path52.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
|
|
187125
187177
|
retryAssets.delete(item.folder.task);
|
|
@@ -187153,25 +187205,50 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187153
187205
|
deferredCards.add(item.folder.number);
|
|
187154
187206
|
deferredLists.add(listPath);
|
|
187155
187207
|
}
|
|
187156
|
-
if (
|
|
187208
|
+
if (fullBoardSync) syncIndex(ws).ready = true;
|
|
187157
187209
|
const scoped = selected2 && [...new Set([...selected2].flatMap((p2) => {
|
|
187158
187210
|
if (!isBoardPath(p2) && !fs48.statSync(path52.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
|
|
187159
187211
|
const file3 = path52.join(ws.board, p2);
|
|
187160
187212
|
return fs48.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
|
|
187161
187213
|
}))].filter((p2) => fs48.statSync(path52.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
|
|
187162
187214
|
for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
|
|
187163
|
-
|
|
187215
|
+
const ownCardPath = singleFolder ? path52.relative(ws.board, cardFile(singleFolder)).split(path52.sep).join("/") : null;
|
|
187216
|
+
const ownArchived = !!ownCardPath?.startsWith(".archive/");
|
|
187217
|
+
const ownGroup = singleTask ? (ownCardPath ? groupOfCard(ownCardPath) : null) ?? Object.keys(base.files).flatMap((k2) => {
|
|
187218
|
+
if (!k2.startsWith(rootOf(ws))) return [];
|
|
187219
|
+
const rel3 = k2.slice(rootOf(ws).length);
|
|
187220
|
+
return numberOfCard(rel3) === singleTask.number ? [groupOfCard(rel3)] : [];
|
|
187221
|
+
}).find((g3) => g3 !== null) ?? null : null;
|
|
187222
|
+
const outOfTaskScope = (p2) => {
|
|
187223
|
+
if (!singleTask) return false;
|
|
187224
|
+
const assetTask = taskOfAssets(p2);
|
|
187225
|
+
if (assetTask !== null) return assetTask !== singleTask.task;
|
|
187226
|
+
const cardNum = numberOfCard(p2), groupNum = groupOfCard(p2);
|
|
187227
|
+
if (cardNum === null) return false;
|
|
187228
|
+
if (cardNum === singleTask.number || groupNum === singleTask.number) return false;
|
|
187229
|
+
if (p2.startsWith(".archive/") || singleTask.chat) return true;
|
|
187230
|
+
if (!fs48.statSync(path52.join(ws.board, p2), { throwIfNoEntry: false })?.isFile()) return true;
|
|
187231
|
+
if (ownGroup !== null && cardNum === ownGroup) return false;
|
|
187232
|
+
if (ownArchived) {
|
|
187233
|
+
const before = base.files[rootOf(ws) + p2]?.content;
|
|
187234
|
+
const meta3 = before ? parseFrontmatter(before).meta : null;
|
|
187235
|
+
if (meta3 && (meta3.blocked_by.includes(singleTask.number) || meta3.related.includes(singleTask.number))) return false;
|
|
187236
|
+
}
|
|
187237
|
+
return true;
|
|
187238
|
+
};
|
|
187239
|
+
if (!singleTask?.chat) proposeItems(ws, base, scoped);
|
|
187164
187240
|
const shared = sharedMemory(ws.board);
|
|
187165
187241
|
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))));
|
|
187166
187242
|
const retiredCards = new Set(tasks.filter((item) => item.record.deleted).map((item) => item.folder.number));
|
|
187167
187243
|
const retiredLists = new Set(tasks.filter((item) => item.record.deleted).map((item) => assetsFile(item.folder.task)));
|
|
187168
187244
|
const defer = (p2) => {
|
|
187169
|
-
if (
|
|
187170
|
-
if (
|
|
187245
|
+
if (outOfTaskScope(p2)) return true;
|
|
187246
|
+
if (protectedCards.has(numberOfCard(p2) ?? 0) || protectedCards.has(groupOfCard(p2) ?? 0) || protectedLists.has(p2)) return true;
|
|
187247
|
+
if (retiredCards.has(numberOfCard(p2) ?? 0) || retiredLists.has(p2)) {
|
|
187171
187248
|
deferred.add(p2);
|
|
187172
187249
|
return true;
|
|
187173
187250
|
}
|
|
187174
|
-
if (!
|
|
187251
|
+
if (!fullBoardSync) return deferred.has(p2);
|
|
187175
187252
|
if (!deferredLists.has(p2) && !deferredCards.has(numberOfCard(p2) ?? 0)) return deferred.has(p2);
|
|
187176
187253
|
deferred.add(p2);
|
|
187177
187254
|
return true;
|
|
@@ -187185,12 +187262,13 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187185
187262
|
const refreshPending = JSON.stringify(pendingAssets) !== JSON.stringify(base.pendingAssets ?? []);
|
|
187186
187263
|
if (refreshDeferred) base.deferred = [...deferred];
|
|
187187
187264
|
if (refreshPending) base.pendingAssets = pendingAssets;
|
|
187188
|
-
const
|
|
187265
|
+
const keepPreview = (p2) => deferred.has(p2) || outOfTaskScope(p2) || protectedCards.has(numberOfCard(p2) ?? 0) || protectedCards.has(groupOfCard(p2) ?? 0) || protectedLists.has(p2) || selected2 !== void 0 && !selected2.has(p2);
|
|
187266
|
+
const pendingPreviews = [.../* @__PURE__ */ new Set([...heldPreviews, ...(base.pendingPreviews ?? []).filter(keepPreview)])];
|
|
187189
187267
|
const refreshPreviews = !isDeepStrictEqual(pendingPreviews, base.pendingPreviews ?? []);
|
|
187190
187268
|
if (refreshPreviews) base.pendingPreviews = pendingPreviews;
|
|
187191
187269
|
if (changed || refreshDeferred || refreshPending || refreshPreviews) writeBase(ws, base);
|
|
187192
187270
|
let operations = {};
|
|
187193
|
-
if (
|
|
187271
|
+
if (fullBoardSync) {
|
|
187194
187272
|
for (const task of processed) {
|
|
187195
187273
|
if (!archives.has(task) && !assetErrors[task]) pendingArchives.delete(task);
|
|
187196
187274
|
}
|
|
@@ -187200,7 +187278,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187200
187278
|
const index = syncIndex(ws);
|
|
187201
187279
|
if (index) index.archivesReady = true;
|
|
187202
187280
|
}
|
|
187203
|
-
const reported = !
|
|
187281
|
+
const reported = !singleTask ? previews : previews.filter((p2) => numberOfCard(p2.file) === singleTask.number);
|
|
187204
187282
|
const tasks2 = { ...assetErrors, ...operations };
|
|
187205
187283
|
const firstError = Object.values(tasks2)[0];
|
|
187206
187284
|
if (reported.length) {
|
|
@@ -187210,7 +187288,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187210
187288
|
if (firstError && (boardSync || firstError.failure)) return { ok: false, conflict: false, ...firstError, tasks: tasks2 };
|
|
187211
187289
|
return { ok: true, changed };
|
|
187212
187290
|
};
|
|
187213
|
-
const local = /* @__PURE__ */ new Set([...scoped ?? localFiles(ws, base), ...assetLists.keys()]);
|
|
187291
|
+
const local = /* @__PURE__ */ new Set([...scoped ?? localFiles(singleFolder ?? ws, base), ...assetLists.keys()]);
|
|
187214
187292
|
const localOf = /* @__PURE__ */ new Map();
|
|
187215
187293
|
const localBefore = /* @__PURE__ */ new Map();
|
|
187216
187294
|
const changes = [];
|
|
@@ -187234,7 +187312,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187234
187312
|
if (Buffer.byteLength(content) > BOARD_FILE_LIMIT) {
|
|
187235
187313
|
const error62 = `${p2}:1 \u2014 File exceeds ${BOARD_FILE_LIMIT / 1024} KB. Move large results to assets and link them from the card.`;
|
|
187236
187314
|
const number4 = numberOfCard(p2);
|
|
187237
|
-
if (number4 === null || number4 ===
|
|
187315
|
+
if (number4 === null || number4 === singleTask?.number) return { ok: false, conflict: false, error: error62, failure: validationFailure(error62, "card_too_large") };
|
|
187238
187316
|
previews.push({ file: p2, line: 1, column: 1, code: "card_too_large", path: "", message: error62, hint: "Shorten the card." });
|
|
187239
187317
|
oversize.add(number4);
|
|
187240
187318
|
heldPreviews.add(p2);
|
|
@@ -187282,9 +187360,75 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187282
187360
|
};
|
|
187283
187361
|
if (oversize.size) holdCards(oversize);
|
|
187284
187362
|
if (!changes.length) return success2(false);
|
|
187363
|
+
const taskOfCardNumber = (number4) => {
|
|
187364
|
+
const indexed = [...syncIndex(ws)?.tasks.values() ?? []].find((t2) => t2.number === number4)?.task;
|
|
187365
|
+
if (indexed) return indexed;
|
|
187366
|
+
for (const name of filesUnder(path52.join(ws.board, ".sync"))) {
|
|
187367
|
+
if (!name.endsWith(".json") || name.includes("/") || taskOfRemoval(".sync/" + name)) continue;
|
|
187368
|
+
try {
|
|
187369
|
+
const held5 = JSON.parse(fs48.readFileSync(path52.join(ws.board, ".sync", name), "utf8"));
|
|
187370
|
+
if (held5.number === number4 && held5.task && TASK_ID.test(held5.task)) return held5.task;
|
|
187371
|
+
} catch {
|
|
187372
|
+
}
|
|
187373
|
+
}
|
|
187374
|
+
};
|
|
187285
187375
|
const commit = async () => {
|
|
187286
187376
|
while (changes.length) {
|
|
187287
187377
|
const sent2 = await commitBoard(ws.project, job.id, job.machineId, changes);
|
|
187378
|
+
if (!sent2.ok && sent2.code === "conflict" && sent2.error === "The current Land job must synchronize this archive.") {
|
|
187379
|
+
const candidates = [...new Set(changes.flatMap((c2) => {
|
|
187380
|
+
const p2 = localOf.get(c2.path);
|
|
187381
|
+
const n = p2?.startsWith(".archive/") ? numberOfCard(p2) : null;
|
|
187382
|
+
return n !== null && !(singleTask && !singleTask.chat && job.id && n === singleTask.number && readLandArchiveOwner(landArchiveMarker(ws.board, singleTask.task))?.job === job.id) ? [n] : [];
|
|
187383
|
+
}))];
|
|
187384
|
+
const isolatedNumbers = /* @__PURE__ */ new Set();
|
|
187385
|
+
const isolatedTasks = /* @__PURE__ */ new Set();
|
|
187386
|
+
for (const n of candidates) {
|
|
187387
|
+
const task = taskOfCardNumber(n);
|
|
187388
|
+
if (candidates.length > 1 && task) {
|
|
187389
|
+
const current2 = await readTask(task);
|
|
187390
|
+
if (current2.ok && current2.value.status === "done") continue;
|
|
187391
|
+
}
|
|
187392
|
+
writeLandArchiveOwner(landArchiveMarker(ws.board, task ?? `unowned-${n}`), { job: null, number: n });
|
|
187393
|
+
isolatedNumbers.add(n);
|
|
187394
|
+
protectedCards.add(n);
|
|
187395
|
+
if (task) {
|
|
187396
|
+
isolatedTasks.add(task);
|
|
187397
|
+
protectedLists.add(assetsFile(task));
|
|
187398
|
+
pendingArchives.delete(task);
|
|
187399
|
+
retryAssets.delete(task);
|
|
187400
|
+
}
|
|
187401
|
+
}
|
|
187402
|
+
if (isolatedNumbers.size) {
|
|
187403
|
+
const repaired = /* @__PURE__ */ new Set();
|
|
187404
|
+
repairLandBlockers(ws, base, isolatedNumbers, repaired);
|
|
187405
|
+
for (let i = changes.length - 1; i >= 0; i--) {
|
|
187406
|
+
const file3 = localOf.get(changes[i].path);
|
|
187407
|
+
if (!file3) continue;
|
|
187408
|
+
const assetTask = taskOfAssets(file3);
|
|
187409
|
+
const cardNum = numberOfCard(file3), groupNum = groupOfCard(file3);
|
|
187410
|
+
if (assetTask && isolatedTasks.has(assetTask) || cardNum !== null && isolatedNumbers.has(cardNum) || groupNum !== null && isolatedNumbers.has(groupNum)) {
|
|
187411
|
+
changes.splice(i, 1);
|
|
187412
|
+
}
|
|
187413
|
+
}
|
|
187414
|
+
for (const file3 of repaired) {
|
|
187415
|
+
if (defer(file3) || heldPreviews.has(file3)) continue;
|
|
187416
|
+
const content = readText(path52.join(ws.board, file3));
|
|
187417
|
+
if (content === null || Buffer.byteLength(content) > BOARD_FILE_LIMIT) continue;
|
|
187418
|
+
const remote3 = remoteOf(ws, shared, file3);
|
|
187419
|
+
const held5 = base.files[remote3];
|
|
187420
|
+
localOf.set(remote3, file3);
|
|
187421
|
+
localBefore.set(remote3, content);
|
|
187422
|
+
const entry = { path: remote3, content: normalizeCardFrontmatter(content), base_seq: held5?.seq ?? base.deleted?.[remote3] ?? 0 };
|
|
187423
|
+
const existing = changes.findIndex((c2) => c2.path === remote3);
|
|
187424
|
+
if (held5?.content === content) {
|
|
187425
|
+
if (existing >= 0) changes.splice(existing, 1);
|
|
187426
|
+
} else if (existing >= 0) changes[existing] = entry;
|
|
187427
|
+
else changes.push(entry);
|
|
187428
|
+
}
|
|
187429
|
+
continue;
|
|
187430
|
+
}
|
|
187431
|
+
}
|
|
187288
187432
|
if (sent2.ok || !sent2.previewProblems?.length) return sent2;
|
|
187289
187433
|
logRunner("board", "failed", { stage: "push", task: ws.number, job: job.id, code: sent2.code ?? "bad_request", status: sent2.status });
|
|
187290
187434
|
const problems = sent2.previewProblems;
|
|
@@ -187293,7 +187437,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
|
187293
187437
|
const numbers = new Set(problems.map((p2) => numberOfCard(p2.file)));
|
|
187294
187438
|
for (const problem2 of problems) previews.push(problem2);
|
|
187295
187439
|
holdCards(numbers);
|
|
187296
|
-
const own4 = previews.filter((p2) => numberOfCard(p2.file) ===
|
|
187440
|
+
const own4 = previews.filter((p2) => numberOfCard(p2.file) === singleTask?.number);
|
|
187297
187441
|
if (job.id && own4.length) return { ...sent2, error: describeTaskPreviewProblems(own4) };
|
|
187298
187442
|
}
|
|
187299
187443
|
return null;
|
|
@@ -191435,7 +191579,13 @@ function runCommand(akb, ws, args2) {
|
|
|
191435
191579
|
return runAkb(akb, ["run", ...args2, "--board", ws.board, "--json"], { cwd: ws.cwd, board: ws.board });
|
|
191436
191580
|
}
|
|
191437
191581
|
async function boardRuns(akb, ws, scope) {
|
|
191438
|
-
|
|
191582
|
+
const ran = await runCommand(akb, ws, ["list", "--all", ...scope]);
|
|
191583
|
+
const parsed = answerOf2(ran);
|
|
191584
|
+
if (parsed?.runs) return parsed.runs;
|
|
191585
|
+
if (parsed?.error?.kind === "no-board" && !fs74.existsSync(path75.join(ws.board, "config.md")) && !fs74.existsSync(path75.join(ws.board, "todo")) && !fs74.existsSync(path75.join(projectStateDir(ws.board), "sessions.json"))) {
|
|
191586
|
+
return [];
|
|
191587
|
+
}
|
|
191588
|
+
return void 0;
|
|
191439
191589
|
}
|
|
191440
191590
|
var jobOwns = (run3, job, machine) => run3.cloudExecution?.job === job && run3.cloudExecution.machine === machine;
|
|
191441
191591
|
var onTask = (run3, card) => run3.cardId === card && (run3.cloudExecution?.card === void 0 || run3.cloudExecution.card === card);
|
|
@@ -191652,7 +191802,7 @@ function runsSpent(runs, since, job, io, machine, card) {
|
|
|
191652
191802
|
async function runReview(job, ws, tasks, deps, io) {
|
|
191653
191803
|
const since = Date.now();
|
|
191654
191804
|
const failed = await setUp(job, ws, deps, io);
|
|
191655
|
-
if (failed) return { ok: false, reason: failed };
|
|
191805
|
+
if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
|
|
191656
191806
|
const akb = boardAkb(job, ws, deps, io);
|
|
191657
191807
|
const args2 = io.flowRun ? recoveryArgs(io.flowRun) : ["memory", "review", "--task", ...tasks];
|
|
191658
191808
|
const ran = await akb([...args2, "--follow", "--events", "--json"], true);
|
|
@@ -191701,7 +191851,7 @@ async function runAgent(job, ws, deps, io) {
|
|
|
191701
191851
|
if (studio2) return { ok: false, reason: "Studio roles no longer run on their own." };
|
|
191702
191852
|
const since = Date.now();
|
|
191703
191853
|
const failed = await setUp(job, ws, deps, io);
|
|
191704
|
-
if (failed) return { ok: false, reason: failed };
|
|
191854
|
+
if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
|
|
191705
191855
|
if (io.flowRun) {
|
|
191706
191856
|
const args3 = recoveryArgs(io.flowRun);
|
|
191707
191857
|
const akb2 = boardAkb(job, ws, deps, io);
|
|
@@ -191852,7 +192002,7 @@ async function runFlow(job, ws, deps, io) {
|
|
|
191852
192002
|
}
|
|
191853
192003
|
}
|
|
191854
192004
|
const failed = await setUp(job, ws, deps, io);
|
|
191855
|
-
if (failed) return
|
|
192005
|
+
if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
|
|
191856
192006
|
let id2 = akbCardOf(ws);
|
|
191857
192007
|
if (flow.phase === "land") {
|
|
191858
192008
|
try {
|
|
@@ -191984,7 +192134,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
191984
192134
|
} };
|
|
191985
192135
|
};
|
|
191986
192136
|
const localArchive = () => isArchived(ws, card) && !asks(cardFile(ws)) && isSuccessfulArchive(cardFile(ws));
|
|
191987
|
-
if (localArchive() && deliveryId
|
|
192137
|
+
if (localArchive() && (deliveryId ? observed.kind === "completed" || observed.kind === "resumable" : !flow.delivery_id && observed.kind === "none")) {
|
|
191988
192138
|
if (observed.kind === "resumable") {
|
|
191989
192139
|
const saved = await akb(["task", "archive", String(card), "--json"]);
|
|
191990
192140
|
if (saved.code !== 0) return fail(refusal3(saved));
|
|
@@ -192091,6 +192241,9 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
192091
192241
|
if (io.lost()) return fail("");
|
|
192092
192242
|
const runs2 = answerOf2(await akb(["run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
|
|
192093
192243
|
const spent = spentBy([...learned, ...runsSpent(runs2, since, job, io, deps.machineId, card)], job);
|
|
192244
|
+
if (flow.phase === "implement") {
|
|
192245
|
+
return { ok: true, report: { ...spent, card, landReady: { deliveryId: reconciled.deliveryId } } };
|
|
192246
|
+
}
|
|
192094
192247
|
return {
|
|
192095
192248
|
ok: true,
|
|
192096
192249
|
report: {
|
|
@@ -192102,6 +192255,14 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
192102
192255
|
}
|
|
192103
192256
|
};
|
|
192104
192257
|
}
|
|
192258
|
+
if (flow.phase === "implement" && verb === "implement" && (!reconciled || reconciled.kind === "none") && isArchived(ws, card) && !asks(cardFile(ws)) && isSuccessfulArchive(cardFile(ws))) {
|
|
192259
|
+
const denied = await refreshReview("implement");
|
|
192260
|
+
if (denied) return fail(denied);
|
|
192261
|
+
if (io.lost()) return fail("");
|
|
192262
|
+
const runs2 = answerOf2(await akb(["run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
|
|
192263
|
+
const spent = spentBy([...learned, ...runsSpent(runs2, since, job, io, deps.machineId, card)], job);
|
|
192264
|
+
return { ok: true, report: { ...spent, card, landReady: {} } };
|
|
192265
|
+
}
|
|
192105
192266
|
const runs = await boardRuns(deps.akb, ws, ["--card", String(card)]);
|
|
192106
192267
|
if (!runs) return unverifiedResume(resumeBlocked({ stopped: false }, cloudLanguage(job) === "zh"));
|
|
192107
192268
|
if (runs.some((run3) => !jobOwns(run3, job.id, deps.machineId) && !runStopped(run3))) return fail(`#${card} is already being worked on`);
|
|
@@ -192165,6 +192326,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
192165
192326
|
return fail(mismatchedReceipt);
|
|
192166
192327
|
}
|
|
192167
192328
|
if (restored.code === 0 && resumed?.landed && resumed.deliveryId) {
|
|
192329
|
+
if (flow.phase === "implement") return { ok: true, report: { card: id3, landReady: { deliveryId: resumed.deliveryId } } };
|
|
192168
192330
|
return { ok: true, report: { card: id3, deliveryCompleted: true, deliveryId: resumed.deliveryId, ...landingOf(resumed.delivery) } };
|
|
192169
192331
|
}
|
|
192170
192332
|
const reason = restored.code === 0 ? void 0 : resumed?.error?.reason;
|
|
@@ -192356,7 +192518,15 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
192356
192518
|
report: { ...spent, ...tracked, failure: failureDetail }
|
|
192357
192519
|
};
|
|
192358
192520
|
}
|
|
192359
|
-
if (flow.phase === "implement" && effectiveVerb === "implement" && !rejected && !asked && !waiting
|
|
192521
|
+
if (flow.phase === "implement" && effectiveVerb === "implement" && !rejected && !asked && !waiting) {
|
|
192522
|
+
if (completed) return { ok: true, report: {
|
|
192523
|
+
...spent,
|
|
192524
|
+
card: id3,
|
|
192525
|
+
landReady: { deliveryId: completed },
|
|
192526
|
+
session: recent?.resumeId ?? answer?.agentSession,
|
|
192527
|
+
reply: recent?.result,
|
|
192528
|
+
...history.length ? { retries: history } : {}
|
|
192529
|
+
} };
|
|
192360
192530
|
if (!deliveryId || !recent || !runStopped(recent)) return fail("The implementation result or delivery workspace was not saved.");
|
|
192361
192531
|
return { ok: true, report: {
|
|
192362
192532
|
...spent,
|
|
@@ -193644,7 +193814,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
193644
193814
|
saved.report = report2;
|
|
193645
193815
|
}
|
|
193646
193816
|
}
|
|
193647
|
-
if (flow &&
|
|
193817
|
+
if (flow && (priorExecution || sourceId) && job.projectDir) {
|
|
193648
193818
|
const folder3 = folderFor(job);
|
|
193649
193819
|
if (folder3 && !("refused" in folder3)) {
|
|
193650
193820
|
const ws2 = openTaskFolder(job, folder3.cwd);
|
|
@@ -194909,10 +195079,11 @@ ${body}` : body;
|
|
|
194909
195079
|
if (stopped3) return finishClaimed("stopped", "", { ...result.report, ...proof });
|
|
194910
195080
|
if (!result.ok) {
|
|
194911
195081
|
const reason = result.exhausted || result.failure?.code === "retry_exhausted" ? "task_retry_exhausted: " + result.reason : result.reason;
|
|
195082
|
+
const safeToRetry = result.exhausted === true || result.safeToRetry === true;
|
|
194912
195083
|
const failureDetail2 = result.report?.failure ?? buildFailureDetail(
|
|
194913
195084
|
result.failure ?? makeFailure("runtime", result.reason || "The run failed."),
|
|
194914
|
-
result.exhausted ? "limit" : "unsafe",
|
|
194915
|
-
|
|
195085
|
+
result.exhausted ? "limit" : safeToRetry ? "manual" : "unsafe",
|
|
195086
|
+
safeToRetry,
|
|
194916
195087
|
void 0,
|
|
194917
195088
|
result.reason
|
|
194918
195089
|
);
|