wildcrane-runner 0.6.111 → 0.6.112
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 -10
- 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 +266 -95
- package/dist/launcher.mjs +16 -18
- package/dist/plugin.mjs +20 -22
- package/dist/runner.mjs +378 -255
- package/dist/settings.mjs +6 -14
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.112 — 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;
|
|
@@ -172524,7 +172524,7 @@ function cloudProblem(response, body) {
|
|
|
172524
172524
|
}
|
|
172525
172525
|
|
|
172526
172526
|
// ../runner/src/protocol.ts
|
|
172527
|
-
var AKB_VERSION = true ? "0.11.
|
|
172527
|
+
var AKB_VERSION = true ? "0.11.92" : "0.0.0";
|
|
172528
172528
|
var AKB_CONTRACT = true ? 30 : 0;
|
|
172529
172529
|
|
|
172530
172530
|
// ../runner/src/secrets.ts
|
|
@@ -173048,23 +173048,27 @@ function retryBudget(file2, initialAttempt = 1) {
|
|
|
173048
173048
|
try {
|
|
173049
173049
|
const saved = fs12.readFileSync(file2, "utf8");
|
|
173050
173050
|
const used = Number(saved);
|
|
173051
|
-
return /^\d+$/.test(saved) && Number.isSafeInteger(used) && used <= MAX_RETRY_ATTEMPTS ?
|
|
173051
|
+
return /^\d+$/.test(saved) && Number.isSafeInteger(used) && used <= MAX_RETRY_ATTEMPTS ? used + 1 : MAX_RETRY_ATTEMPTS + 1;
|
|
173052
173052
|
} catch (error62) {
|
|
173053
|
-
if (error62.code === "ENOENT") return
|
|
173053
|
+
if (error62.code === "ENOENT") return 1;
|
|
173054
173054
|
throw error62;
|
|
173055
173055
|
}
|
|
173056
173056
|
};
|
|
173057
|
-
const
|
|
173057
|
+
const update2 = (advance) => {
|
|
173058
173058
|
fs12.mkdirSync(path12.dirname(file2), { recursive: true, mode: 448 });
|
|
173059
173059
|
return withLock(file2 + ".lock", "recording a task retry", () => {
|
|
173060
|
-
const
|
|
173060
|
+
const current2 = attempt();
|
|
173061
|
+
const next = advance(current2);
|
|
173061
173062
|
if (next > MAX_RETRY_ATTEMPTS + 1) return;
|
|
173062
|
-
|
|
173063
|
-
|
|
173063
|
+
if (next !== current2) {
|
|
173064
|
+
fs12.writeFileSync(file2 + ".tmp", String(next - 1), { mode: 384 });
|
|
173065
|
+
fs12.renameSync(file2 + ".tmp", file2);
|
|
173066
|
+
}
|
|
173064
173067
|
return next;
|
|
173065
173068
|
});
|
|
173066
173069
|
};
|
|
173067
|
-
|
|
173070
|
+
if (initialAttempt > 1) update2((current2) => Math.max(current2, initialAttempt));
|
|
173071
|
+
return { attempt, take: () => update2((current2) => current2 + 1) };
|
|
173068
173072
|
}
|
|
173069
173073
|
function retryRecord(failure2, attempt, runtime, sessionAction) {
|
|
173070
173074
|
const { source: source2, summary: summary2, detail, code } = failure2;
|
|
@@ -173733,7 +173737,7 @@ function createTail(log) {
|
|
|
173733
173737
|
// ../cli/package.json
|
|
173734
173738
|
var package_default = {
|
|
173735
173739
|
name: "wildcrane",
|
|
173736
|
-
version: "0.11.
|
|
173740
|
+
version: "0.11.92",
|
|
173737
173741
|
akbContract: 30,
|
|
173738
173742
|
canonicalCommands: true,
|
|
173739
173743
|
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.",
|
|
@@ -178296,7 +178300,7 @@ var secretsSet = () => Object.fromEntries(Object.entries(readAll()).map(([id2, k
|
|
|
178296
178300
|
|
|
178297
178301
|
// ../runner/src/api.ts
|
|
178298
178302
|
var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok", "antigravity"];
|
|
178299
|
-
var PROTOCOL =
|
|
178303
|
+
var PROTOCOL = 31;
|
|
178300
178304
|
var TIMEOUT_MS = 2e4;
|
|
178301
178305
|
async function send(method, route, body, signedIn, ms, type, extra = {}) {
|
|
178302
178306
|
const headers = { accept: "application/json", ...extra };
|
|
@@ -185447,7 +185451,7 @@ function pull(ws, machineId, stopped2, mode) {
|
|
|
185447
185451
|
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" } };
|
|
185448
185452
|
}
|
|
185449
185453
|
}
|
|
185450
|
-
const read5 = await
|
|
185454
|
+
const read5 = await prepareTask(ws, !!validation, taskChat);
|
|
185451
185455
|
if (!read5.ok && read5.code === "board_content_conflict") {
|
|
185452
185456
|
const prepared = await prepareConflictTask(ws);
|
|
185453
185457
|
if (!prepared.ok) return prepared;
|
|
@@ -185502,41 +185506,53 @@ function syncedCardVersion(ws) {
|
|
|
185502
185506
|
const card = Object.entries(base.files).find(([p2]) => p2.startsWith(rootOf(ws) + "todo/") && numberOfCard(p2.slice(rootOf(ws).length)) === ws.number);
|
|
185503
185507
|
return card?.[1].seq ?? null;
|
|
185504
185508
|
}
|
|
185509
|
+
function syncedArchive(ws) {
|
|
185510
|
+
const p2 = path59.relative(ws.board, cardFile3(ws));
|
|
185511
|
+
if (!p2.startsWith(".archive/")) return;
|
|
185512
|
+
const base = readBase(ws);
|
|
185513
|
+
const root2 = rootOf(ws);
|
|
185514
|
+
const card = base.files[root2 + p2];
|
|
185515
|
+
const list3 = assetsFile(ws.task);
|
|
185516
|
+
const assets = base.files[root2 + list3];
|
|
185517
|
+
if (!card || !archiveMeta(card.content) || card.content !== readText(path59.join(ws.board, p2)) || (assets?.content ?? null) !== readText(path59.join(ws.board, list3)) || base.pendingAssets?.includes(ws.task) || base.pendingPreviews?.some((held5) => held5 === p2 || held5 === list3)) return;
|
|
185518
|
+
return { path: p2, seq: card.seq, assets_seq: assets?.seq ?? 0 };
|
|
185519
|
+
}
|
|
185520
|
+
function restoredCards(ws, base, files) {
|
|
185521
|
+
const root2 = rootOf(ws);
|
|
185522
|
+
return files.flatMap(({ path: remote3, content, seq }) => {
|
|
185523
|
+
if (!remote3.startsWith(root2 + "todo/") || !content) return [];
|
|
185524
|
+
const p2 = remote3.slice(root2.length);
|
|
185525
|
+
const number4 = numberOfCard(p2);
|
|
185526
|
+
const stamp3 = /^restored:\s*(.+)$/m.exec(content)?.[1];
|
|
185527
|
+
const before = base.files[remote3]?.content;
|
|
185528
|
+
if (number4 === null || !stamp3 || before && /^restored:\s*(.+)$/m.exec(before)?.[1] === stamp3) return [];
|
|
185529
|
+
return [{ path: p2, number: number4, content, seq }];
|
|
185530
|
+
});
|
|
185531
|
+
}
|
|
185505
185532
|
function applyRestorations(ws, base, files) {
|
|
185506
185533
|
const restored = /* @__PURE__ */ new Set();
|
|
185507
185534
|
const root2 = rootOf(ws);
|
|
185508
|
-
const
|
|
185509
|
-
for (const f2 of files) {
|
|
185510
|
-
if (protectedPaths.has(f2.path.startsWith(root2) ? f2.path.slice(root2.length) : f2.path)) continue;
|
|
185511
|
-
if (!f2.path.startsWith(root2 + "todo/") || !f2.content) continue;
|
|
185512
|
-
const p2 = f2.path.slice(root2.length);
|
|
185513
|
-
const number4 = numberOfCard(p2);
|
|
185514
|
-
const stamp3 = /^restored:\s*(.+)$/m.exec(f2.content)?.[1];
|
|
185515
|
-
if (number4 === null || !stamp3 || base.files[f2.path]?.content === f2.content) continue;
|
|
185516
|
-
const old = Object.entries(base.files).find(([name]) => name.startsWith(root2) && numberOfCard(name.slice(root2.length)) === number4);
|
|
185517
|
-
if (old && old[0] === f2.path && /^restored:\s*(.+)$/m.exec(old[1].content)?.[1] === stamp3) continue;
|
|
185535
|
+
for (const { path: p2, number: number4, content, seq } of restoredCards(ws, base, files)) {
|
|
185518
185536
|
for (const local of ["todo", ".archive"].flatMap((dir) => filesUnder(path59.join(ws.board, dir), ws.board))) {
|
|
185519
185537
|
if (numberOfCard(local) !== number4) continue;
|
|
185520
185538
|
const here = readText(path59.join(ws.board, local));
|
|
185521
|
-
if (here !== null && here !== base.files[root2 + local]?.content && here !==
|
|
185522
|
-
write(path59.join(ws.board, ".sync", "restored", String(
|
|
185539
|
+
if (here !== null && here !== base.files[root2 + local]?.content && here !== content) {
|
|
185540
|
+
write(path59.join(ws.board, ".sync", "restored", String(seq), local), here);
|
|
185523
185541
|
}
|
|
185524
185542
|
restored.add(local);
|
|
185525
185543
|
if (local !== p2) fs57.rmSync(path59.join(ws.board, local), { force: true });
|
|
185526
185544
|
}
|
|
185527
|
-
write(path59.join(ws.board, p2),
|
|
185545
|
+
write(path59.join(ws.board, p2), content);
|
|
185528
185546
|
restored.add(p2);
|
|
185529
185547
|
}
|
|
185530
185548
|
return restored;
|
|
185531
185549
|
}
|
|
185532
|
-
function observeConflicts(ws, base, files) {
|
|
185533
|
-
const shared = sharedMemory(ws.board);
|
|
185550
|
+
function observeConflicts(ws, base, files, shared) {
|
|
185534
185551
|
const root2 = rootOf(ws);
|
|
185535
185552
|
const pending = new Set(base.pendingPreviews);
|
|
185536
185553
|
const conflicting = files.some((f2) => {
|
|
185537
|
-
const
|
|
185538
|
-
|
|
185539
|
-
if (pending.has(p2) || !kept3(p2) || (p2.startsWith(MEMORY2) && shared(p2.slice(MEMORY2.length))) !== !own3) return false;
|
|
185554
|
+
const p2 = f2.path.startsWith(root2) ? f2.path.slice(root2.length) : f2.path;
|
|
185555
|
+
if (pending.has(p2) || !kept3(p2) || remoteOf(ws, shared, p2) !== f2.path) return false;
|
|
185540
185556
|
return !!mergeFile(base.files[f2.path]?.content ?? null, readText(path59.join(ws.board, p2)), f2.content).conflict;
|
|
185541
185557
|
});
|
|
185542
185558
|
if (!conflicting) return false;
|
|
@@ -185567,67 +185583,96 @@ function observeConflicts(ws, base, files) {
|
|
|
185567
185583
|
markUnsent(ws.cwd, true);
|
|
185568
185584
|
return true;
|
|
185569
185585
|
}
|
|
185570
|
-
async function
|
|
185586
|
+
async function reconcileBoard2(ws, base, board, shared, taskChat) {
|
|
185587
|
+
const root2 = rootOf(ws);
|
|
185571
185588
|
if (pendingConflicts(ws.board).length) return { ok: false, code: "board_content_conflict", error: "Resolve the saved board content conflicts before refreshing." };
|
|
185572
|
-
const
|
|
185573
|
-
const
|
|
185574
|
-
|
|
185575
|
-
|
|
185576
|
-
|
|
185577
|
-
|
|
185578
|
-
|
|
185579
|
-
|
|
185580
|
-
|
|
185581
|
-
|
|
185582
|
-
|
|
185583
|
-
|
|
185584
|
-
|
|
185585
|
-
|
|
185586
|
-
|
|
185587
|
-
|
|
185588
|
-
|
|
185589
|
-
|
|
185590
|
-
|
|
185589
|
+
const restored = applyRestorations(ws, base, board.files);
|
|
185590
|
+
const snapshot = base.head_seq === null ? base.files : void 0;
|
|
185591
|
+
if (!snapshot && observeConflicts(ws, base, board.files, shared)) return { ok: false, code: "board_content_conflict", error: "Resolve the saved board content conflicts before refreshing." };
|
|
185592
|
+
if (snapshot) base.files = {};
|
|
185593
|
+
const index = syncIndex(ws);
|
|
185594
|
+
const paths = [];
|
|
185595
|
+
const removed = [];
|
|
185596
|
+
let skipped = false;
|
|
185597
|
+
for (const f2 of board.files) {
|
|
185598
|
+
const p2 = f2.path.startsWith(root2) ? f2.path.slice(root2.length) : f2.path;
|
|
185599
|
+
paths.push(p2);
|
|
185600
|
+
if (index) rememberDirectories(index.directories, p2);
|
|
185601
|
+
if (!snapshot && kept3(p2) && remoteOf(ws, shared, p2) === f2.path) {
|
|
185602
|
+
const file2 = path59.join(ws.board, p2);
|
|
185603
|
+
const here = readText(file2);
|
|
185604
|
+
if (here !== f2.content) {
|
|
185605
|
+
if (!restored.has(p2) && here !== (base.files[f2.path]?.content ?? null)) {
|
|
185606
|
+
skipped = true;
|
|
185607
|
+
continue;
|
|
185608
|
+
}
|
|
185609
|
+
if (f2.content === null) fs57.rmSync(file2, { force: true });
|
|
185610
|
+
else write(file2, f2.content);
|
|
185611
|
+
}
|
|
185612
|
+
}
|
|
185591
185613
|
base.deleted ??= {};
|
|
185592
185614
|
if (f2.content === null) {
|
|
185593
185615
|
delete base.files[f2.path];
|
|
185594
185616
|
base.deleted[f2.path] = f2.seq;
|
|
185617
|
+
removed.push(f2.path);
|
|
185595
185618
|
} else {
|
|
185596
185619
|
base.files[f2.path] = { seq: f2.seq, content: f2.content };
|
|
185597
185620
|
delete base.deleted[f2.path];
|
|
185598
185621
|
}
|
|
185599
185622
|
}
|
|
185600
|
-
|
|
185601
|
-
|
|
185602
|
-
|
|
185603
|
-
if (local.startsWith(".archive/") && readText(path59.join(ws.board, local)) !== null && readText(path59.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
|
|
185623
|
+
if (snapshot) {
|
|
185624
|
+
for (const p2 of Object.keys(snapshot)) if (!base.files[p2]) removed.push(p2);
|
|
185625
|
+
resetBoardSnapshot(ws, base, snapshot, shared);
|
|
185604
185626
|
}
|
|
185605
|
-
if (!
|
|
185627
|
+
if (!skipped) base.head_seq = board.head_seq;
|
|
185606
185628
|
base.project = ws.project;
|
|
185607
185629
|
writeBase(ws, base);
|
|
185608
|
-
|
|
185609
|
-
|
|
185610
|
-
|
|
185611
|
-
|
|
185612
|
-
|
|
185613
|
-
|
|
185614
|
-
const
|
|
185615
|
-
const
|
|
185616
|
-
|
|
185617
|
-
|
|
185618
|
-
|
|
185619
|
-
|
|
185620
|
-
|
|
185621
|
-
|
|
185630
|
+
writeIndex(ws.board);
|
|
185631
|
+
const tasks = index?.ready ? affectedTasks(ws, paths) : void 0;
|
|
185632
|
+
if (ws.cloudTask === ws.task) tasks?.add(ws.task);
|
|
185633
|
+
return { ok: true, value: await cleanRecords(ws, base, { removed, tasks, taskChat }) };
|
|
185634
|
+
}
|
|
185635
|
+
function resetBoardSnapshot(ws, base, before, shared) {
|
|
185636
|
+
const root2 = rootOf(ws);
|
|
185637
|
+
const deferred = new Set(base.deferred);
|
|
185638
|
+
const view = viewOf(ws, base, shared);
|
|
185639
|
+
for (const p2 of /* @__PURE__ */ new Set([...localFiles(ws, base), ...view.keys()])) {
|
|
185640
|
+
if (!kept3(p2)) continue;
|
|
185641
|
+
const file2 = path59.join(ws.board, p2);
|
|
185642
|
+
const here = readText(file2);
|
|
185643
|
+
const content = view.get(p2) ?? null;
|
|
185644
|
+
const previous = before[root2 + p2];
|
|
185645
|
+
if (here === content || here !== (previous?.content ?? null) && (deferred.has(p2) || previous && content === null && p2.startsWith(".archive/"))) continue;
|
|
185646
|
+
if (content !== null) write(file2, content);
|
|
185647
|
+
else if (previous || !isSettingsPath(p2)) fs57.rmSync(file2, { force: true });
|
|
185648
|
+
}
|
|
185649
|
+
}
|
|
185650
|
+
async function prepareTask(ws, preserveAssets, taskChat) {
|
|
185651
|
+
const base = readBase(ws);
|
|
185652
|
+
if (base.workspace === void 0) {
|
|
185653
|
+
const project = await readProject(ws.project);
|
|
185654
|
+
if (!project.ok) return project;
|
|
185655
|
+
base.workspace = project.value.workspace ?? null;
|
|
185622
185656
|
}
|
|
185657
|
+
const read5 = await readBoard(ws.project, base.head_seq);
|
|
185658
|
+
if (!read5.ok) return read5;
|
|
185659
|
+
const shared = sharedMemory(ws.board);
|
|
185660
|
+
const refreshed = await reconcileBoard2(ws, base, read5.value, shared, taskChat);
|
|
185661
|
+
if (!refreshed.ok) return refreshed;
|
|
185662
|
+
if (refreshed.value.has(ws.task)) return { ok: true, value: void 0 };
|
|
185623
185663
|
const record2 = readRecord(ws);
|
|
185624
185664
|
const studio = await pullStudio(ws, record2);
|
|
185625
185665
|
if (!studio.ok) return studio;
|
|
185626
|
-
|
|
185666
|
+
const studioShared = sharedMemory(ws.board);
|
|
185667
|
+
const previousView = viewOf(ws, base, shared);
|
|
185668
|
+
for (const [p2, content] of viewOf(ws, base, studioShared)) {
|
|
185669
|
+
if (!kept3(p2) || !p2.startsWith(MEMORY2) || remoteOf(ws, studioShared, p2) === remoteOf(ws, shared, p2)) continue;
|
|
185670
|
+
const file2 = path59.join(ws.board, p2);
|
|
185671
|
+
if (readText(file2) === (previousView.get(p2) ?? null) && previousView.get(p2) !== content) write(file2, content);
|
|
185672
|
+
}
|
|
185627
185673
|
const assets = await pullAssets(ws, record2, assetsOf(assetsListOf(ws, base)), preserveAssets);
|
|
185628
185674
|
if (!assets.ok) return assets;
|
|
185629
185675
|
writeRecord(ws, record2);
|
|
185630
|
-
writeIndex(ws.board);
|
|
185631
185676
|
return { ok: true, value: void 0 };
|
|
185632
185677
|
}
|
|
185633
185678
|
function writeIndex(board) {
|
|
@@ -186247,7 +186292,7 @@ function affectedTasks(ws, paths) {
|
|
|
186247
186292
|
}
|
|
186248
186293
|
return tasks;
|
|
186249
186294
|
}
|
|
186250
|
-
async function send2(ws, job, { paths, taskChat }) {
|
|
186295
|
+
async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
|
|
186251
186296
|
const record2 = readRecord(ws);
|
|
186252
186297
|
const base = readBase(ws);
|
|
186253
186298
|
const fail = (error62, conflict = false, code, status) => ({ ok: false, conflict, error: error62, code, ...temporaryCloudFailure({ code, status }) ? { offline: true } : {} });
|
|
@@ -186487,6 +186532,16 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
186487
186532
|
let sent = await commit();
|
|
186488
186533
|
if (sent === null) return success2(false);
|
|
186489
186534
|
if (!sent.ok && sent.files) {
|
|
186535
|
+
const root2 = rootOf(ws);
|
|
186536
|
+
const deletedCards = new Set(sent.files.filter((f2) => f2.content === null && f2.path.startsWith(root2)).map((f2) => numberOfCard(f2.path.slice(root2.length))).filter((number4) => number4 !== null));
|
|
186537
|
+
if (boardSync && retryRestore && deletedCards.size) {
|
|
186538
|
+
const read5 = await readBoard(ws.project, base.head_seq);
|
|
186539
|
+
if (read5.ok && restoredCards(ws, base, read5.value.files).some((card) => deletedCards.has(card.number))) {
|
|
186540
|
+
const refreshed = await reconcileBoard2(ws, base, read5.value, shared, taskChat);
|
|
186541
|
+
if (!refreshed.ok) return conflictFailure(ws);
|
|
186542
|
+
return send2(ws, job, { paths, taskChat }, false);
|
|
186543
|
+
}
|
|
186544
|
+
}
|
|
186490
186545
|
for (const f2 of sent.files) if (stale2.has(f2.path)) {
|
|
186491
186546
|
const at2 = changes.findIndex((c2) => c2.path === f2.path);
|
|
186492
186547
|
if (at2 >= 0) changes.splice(at2, 1);
|
|
@@ -186736,6 +186791,10 @@ function syncRefusal(job, failure2) {
|
|
|
186736
186791
|
}
|
|
186737
186792
|
}
|
|
186738
186793
|
var retryableSync = (failure2) => !failure2.failure && temporaryCloudFailure(failure2);
|
|
186794
|
+
function writeBlock(failure2) {
|
|
186795
|
+
if (failure2.code === "daily_write_budget_reached") return "allowance";
|
|
186796
|
+
if (failure2.code === "storage_limit_reached" || failure2.code === "quota_exceeded" && failure2.status !== 413 && /free up space/i.test(failure2.error)) return "storage";
|
|
186797
|
+
}
|
|
186739
186798
|
|
|
186740
186799
|
// ../runner/src/saved-previews.ts
|
|
186741
186800
|
var remote2 = /^(?:[a-z][\w+.-]*:|\/|#)/i;
|
|
@@ -187240,8 +187299,15 @@ function boardAkb(job, ws, deps, io, task) {
|
|
|
187240
187299
|
async function setUp(job, ws, deps, io) {
|
|
187241
187300
|
const akb = boardAkb(job, ws, deps, io);
|
|
187242
187301
|
const runtime = job.runtime;
|
|
187243
|
-
const
|
|
187244
|
-
if (
|
|
187302
|
+
const replayingReceipt = job.flow?.verify_delivery?.confirmed === true;
|
|
187303
|
+
if (!io.flowRun?.finished && !replayingReceipt) {
|
|
187304
|
+
let missing = unavailable(runtime, await deps.runtimes());
|
|
187305
|
+
if (missing?.endsWith(" is not signed in on this computer.") && io.waitForLogin) {
|
|
187306
|
+
if (!await io.waitForLogin()) return stopping(io) ? "" : missing;
|
|
187307
|
+
missing = unavailable(runtime, await deps.runtimes());
|
|
187308
|
+
}
|
|
187309
|
+
if (missing) return missing;
|
|
187310
|
+
}
|
|
187245
187311
|
if (!fs61.existsSync(path63.join(ws.board, "config.md"))) {
|
|
187246
187312
|
const init = await akb(["raw", "init"]);
|
|
187247
187313
|
if (init.code !== 0) return refusal2(init);
|
|
@@ -187464,7 +187530,7 @@ async function runFlow(job, ws, deps, io) {
|
|
|
187464
187530
|
}
|
|
187465
187531
|
if (action === "implement") {
|
|
187466
187532
|
if (!reviewAllows(authorization, action)) return "Finish the agreed review stages before delivery.";
|
|
187467
|
-
if (
|
|
187533
|
+
if (flow.review_revision !== void 0 && (flow.verify_delivery ? flow.review_revision !== current2.value.review?.revision : !dispatchedReview && flow.review_revision !== review.revision)) {
|
|
187468
187534
|
return "Review authorization changed. Read the task again.";
|
|
187469
187535
|
}
|
|
187470
187536
|
}
|
|
@@ -187579,8 +187645,37 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
187579
187645
|
const held5 = working.get(key) ?? 0;
|
|
187580
187646
|
working.set(key, held5 + 1);
|
|
187581
187647
|
try {
|
|
187582
|
-
const
|
|
187648
|
+
const verification = flow.verify_delivery;
|
|
187649
|
+
if (verification) {
|
|
187650
|
+
const denied = await refreshReview("implement");
|
|
187651
|
+
if (denied) return fail(denied);
|
|
187652
|
+
if (stopping(io)) return fail("");
|
|
187653
|
+
if (verification.confirmed && verification.id) {
|
|
187654
|
+
return { ok: true, report: {
|
|
187655
|
+
card,
|
|
187656
|
+
deliveryId: verification.id,
|
|
187657
|
+
deliveryCompleted: true,
|
|
187658
|
+
...verification.landing ? { landing: verification.landing } : {}
|
|
187659
|
+
} };
|
|
187660
|
+
}
|
|
187661
|
+
}
|
|
187662
|
+
const reconciled = (!io.flowRun || verification) && !held5 && existedBeforeCreate ? await reconcileDelivery(card) : void 0;
|
|
187583
187663
|
if (io.lost()) return fail("");
|
|
187664
|
+
if (verification) {
|
|
187665
|
+
const saved = await flowRunEvidence(ws, job, deps, flow.sync_recovery_of, io.flowRun);
|
|
187666
|
+
const receipt = reconciled && "deliveryId" in reconciled ? reconciled.deliveryId : void 0;
|
|
187667
|
+
const expected = verification.id ?? saved.run?.deliveryId;
|
|
187668
|
+
if (!saved.stopped || !expected || receipt !== expected || reconciled?.kind !== "completed" && (reconciled?.kind !== "resumable" || !saved.run || saved.run.id !== reconciled.sessionId || !reconciled.hasSession)) {
|
|
187669
|
+
const reason = reconciled?.kind === "unverified" ? reconciled.diagnostic : "No delivery receipt or safe session matches the original run.";
|
|
187670
|
+
return { ok: false, reason, failure: makeFailure("sync", reason, { code: "task_delivery_unverified" }) };
|
|
187671
|
+
}
|
|
187672
|
+
if (reconciled.kind === "resumable") {
|
|
187673
|
+
io.flowRun = saved.run;
|
|
187674
|
+
io.repairDelivery = true;
|
|
187675
|
+
io.diagnostic = "Verify the original delivery using the Studio delivery requirements and the saved results. Record the existing result once you confirm it. Do not repeat land or publish when the earlier result is already in place.";
|
|
187676
|
+
return workOn(card, reconciled);
|
|
187677
|
+
}
|
|
187678
|
+
}
|
|
187584
187679
|
if (reconciled?.kind === "unverified") {
|
|
187585
187680
|
io.show(`[recovery] delivery reconciliation unverified${reconciled.deliveryId ? ` (delivery ${reconciled.deliveryId})` : ""}: ${reconciled.diagnostic}
|
|
187586
187681
|
`);
|
|
@@ -189239,10 +189334,18 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189239
189334
|
delete checkpoint.ending;
|
|
189240
189335
|
delete checkpoint.retryHistory;
|
|
189241
189336
|
}
|
|
189337
|
+
const verification = job.flow?.verify_delivery;
|
|
189338
|
+
if (verification && !local) {
|
|
189339
|
+
delete checkpoint.ending;
|
|
189340
|
+
delete checkpoint.syncFailure;
|
|
189341
|
+
if (checkpoint.completed?.outcome !== "done" || !verification.confirmed || checkpoint.completed.report.deliveryId !== verification.id) {
|
|
189342
|
+
delete checkpoint.completed;
|
|
189343
|
+
}
|
|
189344
|
+
}
|
|
189242
189345
|
checkpoint.retryRound ??= manual && !local ? id2 : sourceId ?? id2;
|
|
189243
189346
|
const retryFile2 = retryFileOf(checkpoint.retryRound);
|
|
189244
189347
|
const legacyAttempt = Math.max(
|
|
189245
|
-
1,
|
|
189348
|
+
1 + Math.max(job.flow?.recovery_attempts ?? 0, manual ? 0 : verification?.attempts ?? 0),
|
|
189246
189349
|
manual && !local ? 1 : checkpoint.retry?.attempt ?? 1,
|
|
189247
189350
|
...Object.values(checkpoint.syncRetries ?? {}).map((retry3) => retry3?.attempt ?? 1),
|
|
189248
189351
|
checkpoint.reconcileRetry?.attempt ?? 1
|
|
@@ -189314,6 +189417,10 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189314
189417
|
}
|
|
189315
189418
|
const retries2 = retryHistory(report2);
|
|
189316
189419
|
if (outcome === "done" && retries2.length) report2 = { ...report2, retries: retries2 };
|
|
189420
|
+
const recoveryAttempts = budget.attempt() - 1;
|
|
189421
|
+
if (flow && report2 && !report2.review && (report2.deliveryId && report2.deliveryCompleted === false || recoveryAttempts > 0 && (report2.deliveryId || report2.deliveryCompleted === false || flow.verify_delivery))) {
|
|
189422
|
+
report2 = { ...report2, recoveryAttempts };
|
|
189423
|
+
}
|
|
189317
189424
|
const draft = report2;
|
|
189318
189425
|
if (job.discussion && draft?.goals !== void 0) {
|
|
189319
189426
|
const unsaved = unsavedGoals(draft);
|
|
@@ -189413,6 +189520,20 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189413
189520
|
if (renewed.ok && renewed.value.renewed && state?.code !== "allowance") Object.assign(lease, sentAt);
|
|
189414
189521
|
if (renewed.ok && renewed.value.stop) stream2.requestStop();
|
|
189415
189522
|
if (renewed.ok && renewed.value.projectDir && !job.projectDir) job = { ...job, projectDir: renewed.value.projectDir };
|
|
189523
|
+
return renewed;
|
|
189524
|
+
};
|
|
189525
|
+
const waitForAccess = async (code, ready) => {
|
|
189526
|
+
const stream2 = watching();
|
|
189527
|
+
while (!stream2.asked() && !stream2.lost()) {
|
|
189528
|
+
if (await ready()) {
|
|
189529
|
+
if (checkpoint.taskRecovery?.code === code) await recoveryState(null);
|
|
189530
|
+
return !stream2.asked() && !stream2.lost();
|
|
189531
|
+
}
|
|
189532
|
+
const status = await recoveryState({ code });
|
|
189533
|
+
if (status.ok && !status.value.renewed) return false;
|
|
189534
|
+
await waitForRetry(Date.now() + deps.retryMs, stream2.whenAsked);
|
|
189535
|
+
}
|
|
189536
|
+
return false;
|
|
189416
189537
|
};
|
|
189417
189538
|
function retryEvent(stream2, record2, state, attempt2, at2) {
|
|
189418
189539
|
stream2.event({ kind: "retry", data: {
|
|
@@ -189440,6 +189561,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189440
189561
|
const reportsStop = step === "finish" && (checkpoint.ending?.outcome === "stopped" || checkpoint.ending?.report?.stopped);
|
|
189441
189562
|
const stopped3 = () => stream2.lost() || stream2.asked() && !reportsStop;
|
|
189442
189563
|
let recovered;
|
|
189564
|
+
let showedRecovery = false;
|
|
189443
189565
|
while (!stopped3()) {
|
|
189444
189566
|
const pending = checkpoint.syncRetries?.[step];
|
|
189445
189567
|
let renewalFailure;
|
|
@@ -189470,6 +189592,14 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189470
189592
|
}
|
|
189471
189593
|
Object.assign(lease, requestedAt);
|
|
189472
189594
|
if (renewed.value.stop) stream2.requestStop();
|
|
189595
|
+
if (flow && !stopped3() && !verification && !writeBlock({ code: record3?.code, error: record3?.summary ?? "" })) {
|
|
189596
|
+
await recoveryState({
|
|
189597
|
+
code: "recovering",
|
|
189598
|
+
attempt: next - 1,
|
|
189599
|
+
...step === "publish" || step === "prepare" ? { step: "sync" } : {}
|
|
189600
|
+
});
|
|
189601
|
+
showedRecovery = true;
|
|
189602
|
+
}
|
|
189473
189603
|
}
|
|
189474
189604
|
if (stopped3()) return syncStopped;
|
|
189475
189605
|
}
|
|
@@ -189481,6 +189611,9 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189481
189611
|
}
|
|
189482
189612
|
if (stopped3()) return syncStopped;
|
|
189483
189613
|
if (result.ok) {
|
|
189614
|
+
if (showedRecovery || checkpoint.taskRecovery?.code === "storage" || checkpoint.taskRecovery?.code === "allowance") {
|
|
189615
|
+
await recoveryState(null);
|
|
189616
|
+
}
|
|
189484
189617
|
if (recovered) {
|
|
189485
189618
|
retryEvent(stream2, recovered, "recovered", budget.attempt() - 1);
|
|
189486
189619
|
stream2.event({ kind: "status", data: { state: "running", source: "sync" } });
|
|
@@ -189488,12 +189621,14 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189488
189621
|
return result;
|
|
189489
189622
|
}
|
|
189490
189623
|
const failure3 = result.failure ?? makeFailure("sync", result.error, { code: result.code });
|
|
189491
|
-
|
|
189624
|
+
const blocked = flow && !reportsStop ? writeBlock(result) : void 0;
|
|
189625
|
+
if (!retryableSync(result) && !blocked) {
|
|
189492
189626
|
checkpoint.retryHistory = [...checkpoint.retryHistory ?? [], retryRecord(failure3, budget.attempt(), runtimeInfo())];
|
|
189493
189627
|
persist();
|
|
189494
189628
|
return result;
|
|
189495
189629
|
}
|
|
189496
|
-
|
|
189630
|
+
if (blocked) await recoveryState({ code: blocked });
|
|
189631
|
+
const { decision, record: record2, attempt: attempt2 } = schedule(step, failure3, blocked || step === "finish" ? () => deps.retryMs : void 0);
|
|
189497
189632
|
if ("pause" in decision) {
|
|
189498
189633
|
retryEvent(stream2, record2, "paused", attempt2 - 1);
|
|
189499
189634
|
return decision.pause === "limit" ? { ...result, code: "retry_exhausted" } : result;
|
|
@@ -189656,14 +189791,37 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189656
189791
|
if (stream2?.asked()) return finishClaimed("stopped", "", report2);
|
|
189657
189792
|
return finishClaimed("failed", allowed2.ok ? cloudLanguage(job) === "en" ? "Project folder access changed. Confirm access and retry." : "\u9879\u76EE\u76EE\u5F55\u6388\u6743\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u786E\u8BA4\u540E\u91CD\u8BD5\u3002" : syncRefusal(job, allowed2), report2);
|
|
189658
189793
|
};
|
|
189794
|
+
const folderReady = () => !!job.projectDir && !("refused" in folderFor(job));
|
|
189795
|
+
if (flow?.review_revision !== void 0 && flow.verb !== "discard" && job.task && !await waitForAccess("folder", folderReady)) {
|
|
189796
|
+
if (watching().asked()) return finishClaimed("stopped");
|
|
189797
|
+
return unauthorized({ ok: true, value: false });
|
|
189798
|
+
}
|
|
189659
189799
|
const allowed = await authorize();
|
|
189660
189800
|
if (!allowed.ok || !allowed.value) return unauthorized(allowed);
|
|
189661
|
-
if (job.flow && job.flow.verb !== "discard") {
|
|
189662
|
-
|
|
189801
|
+
if (job.flow && job.flow.verb !== "discard" && job.task && !folderReady()) {
|
|
189802
|
+
return unauthorized({ ok: true, value: false });
|
|
189663
189803
|
}
|
|
189664
189804
|
if (job.secret) return runSecret(job, deps);
|
|
189665
189805
|
if (job.test) return runTest(job, deps, lease);
|
|
189666
189806
|
const waitingStream = pendingRetry || job.task || reply ? watching() : replyStream;
|
|
189807
|
+
if (verification && job.task) {
|
|
189808
|
+
const current2 = await sync("review", () => deps.api.readTask(job.task));
|
|
189809
|
+
if (!current2.ok) return unauthorized(current2);
|
|
189810
|
+
const review = current2.value.review;
|
|
189811
|
+
if (!review || flow?.review_revision !== review.revision || !reviewAllows(reviewAuthorization(review), "implement")) {
|
|
189812
|
+
return finishClaimed("failed", "This execution no longer has review authorization.");
|
|
189813
|
+
}
|
|
189814
|
+
}
|
|
189815
|
+
if (verification && !checkpoint.verifyingDelivery && !manual) {
|
|
189816
|
+
await recoveryState({ code: "recovering", attempt: Math.min(budget.attempt(), MAX_RETRY_ATTEMPTS) });
|
|
189817
|
+
const failure3 = makeFailure("sync", "Checking the saved delivery and archive.", { code: "task_delivery_unverified" });
|
|
189818
|
+
const ready = await recover(failure3, async () => {
|
|
189819
|
+
checkpoint.verifyingDelivery = true;
|
|
189820
|
+
persist();
|
|
189821
|
+
return { ok: true, value: void 0 };
|
|
189822
|
+
});
|
|
189823
|
+
if (!ready.ok) return finishClaimed(watching().asked() ? "stopped" : "failed", ready.error);
|
|
189824
|
+
}
|
|
189667
189825
|
if (pendingRetry && waitingStream) {
|
|
189668
189826
|
const stream2 = waitingStream;
|
|
189669
189827
|
track(stream2.stop);
|
|
@@ -189710,7 +189868,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189710
189868
|
Object.assign(lease, requestedAt);
|
|
189711
189869
|
}
|
|
189712
189870
|
if (recovering && !pendingRetry) {
|
|
189713
|
-
if (job.flow && !Object.keys(checkpoint.syncRetries ?? {}).length) await recoveryState({ code: "recovering", attempt:
|
|
189871
|
+
if (job.flow && !verification && !Object.keys(checkpoint.syncRetries ?? {}).length) await recoveryState({ code: "recovering", attempt: Math.min(MAX_RETRY_ATTEMPTS, Math.max(1, budget.attempt() - 1)) });
|
|
189714
189872
|
let requestedAt = leaseNow();
|
|
189715
189873
|
const renewed = await sync("renew", () => {
|
|
189716
189874
|
requestedAt = leaseNow();
|
|
@@ -189863,7 +190021,7 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
189863
190021
|
ws = openTaskFolder({ ...job, task }, folder2?.cwd ?? null);
|
|
189864
190022
|
cwd = ws.cwd;
|
|
189865
190023
|
keep2(cwd);
|
|
189866
|
-
if (usesBoardRun(job, checkpoint) && !await recoverBoard(ws)) {
|
|
190024
|
+
if (usesBoardRun(job, checkpoint) && !verification && !await recoverBoard(ws)) {
|
|
189867
190025
|
return finishClaimed("failed", job.flow?.historical_conflict ? "Board content conflicts could not be resolved. Saved work was preserved." : recoveryBlocked(job));
|
|
189868
190026
|
}
|
|
189869
190027
|
if (!job.flow && !job.review && !checkpoint.completed && !checkpoint.boardContinuation?.report.deliveryCompleted) {
|
|
@@ -190184,6 +190342,15 @@ ${body}` : body;
|
|
|
190184
190342
|
sync,
|
|
190185
190343
|
retryFile: retryFile2,
|
|
190186
190344
|
recover,
|
|
190345
|
+
waitForLogin: flow?.review_revision === void 0 ? void 0 : async () => {
|
|
190346
|
+
const ready = await waitForAccess("login", async () => {
|
|
190347
|
+
const runtime = (await deps.runtimes()).find((r2) => r2.name === job.runtime);
|
|
190348
|
+
return runtime?.loggedIn !== false || !runtime.installed;
|
|
190349
|
+
});
|
|
190350
|
+
if (!ready) return false;
|
|
190351
|
+
const allowed2 = await authorize();
|
|
190352
|
+
return allowed2.ok && allowed2.value;
|
|
190353
|
+
},
|
|
190187
190354
|
starting: async () => {
|
|
190188
190355
|
if (checkpoint.taskRecovery?.code === "recovering") await recoveryState(null);
|
|
190189
190356
|
if (!stream.lost() && !stream.asked()) starting();
|
|
@@ -190232,18 +190399,20 @@ ${body}` : body;
|
|
|
190232
190399
|
}
|
|
190233
190400
|
}
|
|
190234
190401
|
let result = await runFlow(job, ws, deps, io);
|
|
190235
|
-
|
|
190402
|
+
if (!result.ok && !verification && result.failure?.code === "delivery_incomplete" && !stream.asked() && !stream.lost()) {
|
|
190236
190403
|
const saved = await flowRunEvidence(ws, job, deps, id2, checkpoint.flowRun);
|
|
190237
|
-
if (
|
|
190238
|
-
|
|
190239
|
-
|
|
190240
|
-
|
|
190241
|
-
|
|
190242
|
-
|
|
190243
|
-
|
|
190244
|
-
|
|
190245
|
-
|
|
190246
|
-
|
|
190404
|
+
if (saved.stopped && saved.run?.finished && await stream.confirmed()) {
|
|
190405
|
+
const failure3 = result.failure;
|
|
190406
|
+
checkpoint.flowRun = saved.run;
|
|
190407
|
+
checkpoint.boardRepair = { reason: failure3.summary, run: saved.run.id };
|
|
190408
|
+
const ready = await recover(failure3, async () => ({ ok: true, value: void 0 }));
|
|
190409
|
+
if (ready.ok) {
|
|
190410
|
+
io.flowRun = saved.run;
|
|
190411
|
+
io.repairDelivery = true;
|
|
190412
|
+
io.diagnostic = failure3.summary;
|
|
190413
|
+
result = await runFlow(job, ws, deps, io);
|
|
190414
|
+
}
|
|
190415
|
+
}
|
|
190247
190416
|
}
|
|
190248
190417
|
if (result.ok) complete("done", result.report);
|
|
190249
190418
|
const stopped3 = !result.ok && (stream.asked() || result.stopped === true);
|
|
@@ -190620,6 +190789,7 @@ async function sendBack(job, deps, ws, report2, sync, stream, finish, landed, re
|
|
|
190620
190789
|
const result = await sync("publish", async () => {
|
|
190621
190790
|
const pushed2 = await push(ws, { id: job.id, machineId: deps.machineId }, () => stream.asked() || stream.lost());
|
|
190622
190791
|
if (pushed2.ok && closesTask && !taskAssetsSynced(ws)) return { ok: false, code: "service_unavailable", error: "Office preview uploads are pending." };
|
|
190792
|
+
if (!pushed2.ok && writeBlock(pushed2)) return pushed2;
|
|
190623
190793
|
return !pushed2.ok && pushed2.offline ? { ok: false, error: pushed2.error, code: "service_unavailable" } : { ok: true, value: pushed2 };
|
|
190624
190794
|
});
|
|
190625
190795
|
const pushed = result.ok ? result.value : result;
|
|
@@ -190639,7 +190809,8 @@ async function sendBack(job, deps, ws, report2, sync, stream, finish, landed, re
|
|
|
190639
190809
|
console.error("runner: task sync refused", { job: job.id, code: denied.code, error: denied.error });
|
|
190640
190810
|
return finish("failed", syncRefusal(job, denied), report2);
|
|
190641
190811
|
}
|
|
190642
|
-
|
|
190812
|
+
const archive = closesTask && report2.deliveryId ? syncedArchive(ws) : void 0;
|
|
190813
|
+
return finish("done", "", { ...report2, ...archive ? { archive } : {}, ...readCheckpoint(job.id)?.approvalRequested ? { replyApprovalSynced: report2.replyApprovalSynced !== false && taskAssetsSynced(ws) } : {} }, landed);
|
|
190643
190814
|
}
|
|
190644
190815
|
var settingsOf = (job) => ({ settings: job.settings, secrets: secretsOf(job.runtimeId) });
|
|
190645
190816
|
async function runSecret(job, deps) {
|