wildcrane-runner 0.6.99 → 0.6.101
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 +409 -102
- 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 +1247 -781
- package/dist/launcher.mjs +111 -22
- package/dist/plugin.mjs +111 -22
- package/dist/runner.mjs +1316 -842
- package/dist/settings.mjs +111 -22
- package/package.json +1 -1
package/dist/akb/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.81 — built by runner/scripts/build.mjs. Do not edit.
|
|
3
3
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
4
4
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
5
5
|
var __create = Object.create;
|
|
@@ -20942,41 +20942,61 @@ function reviewLayers(plan) {
|
|
|
20942
20942
|
}
|
|
20943
20943
|
return layers;
|
|
20944
20944
|
}
|
|
20945
|
-
function parseReviewPlan(value
|
|
20946
|
-
|
|
20947
|
-
|
|
20948
|
-
|
|
20945
|
+
function parseReviewPlan(value) {
|
|
20946
|
+
return reviewPlanSchema.parse(value);
|
|
20947
|
+
}
|
|
20948
|
+
function reviewNames(catalog) {
|
|
20949
|
+
return catalog.map(({ id: id2, title }) => {
|
|
20950
|
+
const labels = Object.values(title ?? {}).map((label2) => label2.trim()).filter(Boolean);
|
|
20951
|
+
return { id: id2, labels: labels.length ? [...new Set(labels)] : [id2] };
|
|
20952
|
+
});
|
|
20953
|
+
}
|
|
20954
|
+
function previewError(message, names2) {
|
|
20955
|
+
const available = names2.map(({ labels, id: id2 }) => `${labels.join(" / ")} (${id2})`).join(", ") || "none";
|
|
20956
|
+
return new Error(`${message} Available Previews: ${available}. Use a listed name in a flow or its ID in a JSON plan. Define custom Previews before using them. A Preview is a draft or result for review. Keep task context in the card body.`);
|
|
20957
|
+
}
|
|
20958
|
+
function validateReviewPreviews(plan, catalog, { saved = false } = {}) {
|
|
20959
|
+
const prerequisites = new Set((plan ?? []).flatMap((node2) => node2.after));
|
|
20960
|
+
const ids = new Set(catalog?.map((p) => p.id));
|
|
20961
|
+
for (const node2 of plan ?? []) {
|
|
20962
|
+
if (node2.previews.length) {
|
|
20963
|
+
if (!catalog) throw new Error("Preview outputs are unavailable; update Runner and try again.");
|
|
20964
|
+
const unknown2 = node2.previews.find((preview) => !ids.has(preview));
|
|
20965
|
+
if (unknown2) throw previewError(`Preview ${unknown2} is not defined for review node "${node2.id}".`, reviewNames(catalog));
|
|
20966
|
+
} else if (!saved && node2.kind !== "work") {
|
|
20967
|
+
const handoff2 = (node2.id === HANDOFF || node2.id === HANDOFF_WITH_COLLISION) && node2.after.length && !prerequisites.has(node2.id);
|
|
20968
|
+
if (!handoff2) throw previewError(
|
|
20969
|
+
`Review node "${node2.id}" needs at least one Preview. Use an empty plan for no extra review.`,
|
|
20970
|
+
reviewNames(catalog ?? [])
|
|
20971
|
+
);
|
|
20972
|
+
}
|
|
20949
20973
|
}
|
|
20950
20974
|
return plan;
|
|
20951
20975
|
}
|
|
20952
20976
|
function parseReviewFlow(flow, catalog) {
|
|
20953
20977
|
if (flow === "") return [];
|
|
20954
20978
|
if (!catalog) throw new Error("Preview outputs are unavailable; update Runner and try again.");
|
|
20955
|
-
const names2 = catalog
|
|
20956
|
-
const labels = Object.values(title ?? {}).map((label2) => label2.trim()).filter(Boolean);
|
|
20957
|
-
return { id: id2, labels: labels.length ? [...new Set(labels)] : [id2] };
|
|
20958
|
-
});
|
|
20959
|
-
const available = names2.map(({ labels }) => labels.join(" / ")).join(", ") || "none";
|
|
20979
|
+
const names2 = reviewNames(catalog);
|
|
20960
20980
|
const seen = /* @__PURE__ */ new Set();
|
|
20961
20981
|
const nodes = [];
|
|
20962
20982
|
let after2 = [];
|
|
20963
|
-
for (const group of flow.split("->")) {
|
|
20983
|
+
for (const [index, group] of flow.split("->").entries()) {
|
|
20964
20984
|
const current = group.split("+").map((entry) => {
|
|
20965
20985
|
const name = entry.trim();
|
|
20966
|
-
if (!name) throw
|
|
20986
|
+
if (!name) throw previewError(`Review flow group ${index + 1} contains an empty Preview name.`, names2);
|
|
20967
20987
|
const matches = names2.filter(({ labels }) => labels.includes(name));
|
|
20968
20988
|
if (matches.length !== 1) {
|
|
20969
|
-
throw
|
|
20989
|
+
throw previewError(`${matches.length ? "Ambiguous" : "Unknown"} Preview "${name}" in review flow group ${index + 1}.`, names2);
|
|
20970
20990
|
}
|
|
20971
20991
|
const { id: id2 } = matches[0];
|
|
20972
|
-
if (seen.has(id2)) throw
|
|
20992
|
+
if (seen.has(id2)) throw previewError(`Repeated Preview "${name}" in review flow group ${index + 1}.`, names2);
|
|
20973
20993
|
seen.add(id2);
|
|
20974
20994
|
nodes.push({ id: id2, after: after2, previews: [id2] });
|
|
20975
20995
|
return id2;
|
|
20976
20996
|
});
|
|
20977
20997
|
after2 = current;
|
|
20978
20998
|
}
|
|
20979
|
-
nodes.push({ id: seen.has(
|
|
20999
|
+
nodes.push({ id: seen.has(HANDOFF) ? HANDOFF_WITH_COLLISION : HANDOFF, after: after2, previews: [] });
|
|
20980
21000
|
return parseReviewPlan(nodes);
|
|
20981
21001
|
}
|
|
20982
21002
|
function readReviewPlan(plan) {
|
|
@@ -21012,7 +21032,7 @@ function reviewInstruction(authorization) {
|
|
|
21012
21032
|
case "stages":
|
|
21013
21033
|
return [
|
|
21014
21034
|
"Work only on these unlocked stages: " + authorization.nodes.map((node2) => node2.id).join(", "),
|
|
21015
|
-
...authorization.nodes.map((node2) => `- ${node2.id}: ${node2.previews.length ? node2.previews.join(", ") : "
|
|
21035
|
+
...authorization.nodes.map((node2) => `- ${node2.id}: ${node2.previews.length ? node2.previews.join(", ") : "no Preview"}`)
|
|
21016
21036
|
].join("\n");
|
|
21017
21037
|
case "delivery":
|
|
21018
21038
|
return "Stages complete. Follow Studio delivery checks.";
|
|
@@ -21038,7 +21058,7 @@ function reviewBoundary(review, assigned) {
|
|
|
21038
21058
|
"Read akb task review before reporting running/done with its revision. Sync content and assets before done. Revise a stage before changing its approved output. Only stage approval accepts reviewable outputs."
|
|
21039
21059
|
].join("\n");
|
|
21040
21060
|
}
|
|
21041
|
-
var id, reviewNodeSchema, reviewPlanSchema;
|
|
21061
|
+
var id, reviewNodeSchema, reviewPlanSchema, HANDOFF, HANDOFF_WITH_COLLISION;
|
|
21042
21062
|
var init_review_plan = __esm({
|
|
21043
21063
|
"../cli/src/lib/shared/review-plan.ts"() {
|
|
21044
21064
|
"use strict";
|
|
@@ -21057,6 +21077,8 @@ var init_review_plan = __esm({
|
|
|
21057
21077
|
ctx.addIssue({ code: "custom", message: e.message });
|
|
21058
21078
|
}
|
|
21059
21079
|
}).nullable();
|
|
21080
|
+
HANDOFF = "delivery-handoff";
|
|
21081
|
+
HANDOFF_WITH_COLLISION = "delivery-handoff:flow";
|
|
21060
21082
|
}
|
|
21061
21083
|
});
|
|
21062
21084
|
|
|
@@ -37814,23 +37836,15 @@ function goalCatalog(held4, studio, definitions) {
|
|
|
37814
37836
|
if (!builtIn && definitions.length) die("Preview outputs are unavailable; update Runner and try again.");
|
|
37815
37837
|
return builtIn && effectivePreviewCatalog(builtIn, definitions);
|
|
37816
37838
|
}
|
|
37817
|
-
function checkGoalReview(held4, studio, value, definitions = []) {
|
|
37818
|
-
const catalog = goalCatalog(held4, studio, definitions);
|
|
37819
|
-
try {
|
|
37820
|
-
const plan = parseReviewPlan(value);
|
|
37821
|
-
if (plan?.some((n) => n.previews.length) && !catalog) die("Preview outputs are unavailable; update Runner and try again.");
|
|
37822
|
-
return parseReviewPlan(plan, catalog?.map((p) => p.id));
|
|
37823
|
-
} catch (e) {
|
|
37824
|
-
return die(e.message);
|
|
37825
|
-
}
|
|
37826
|
-
}
|
|
37827
37839
|
function goalReview(held4, studio, opts, previous, definitions) {
|
|
37840
|
+
const catalog = goalCatalog(held4, studio, definitions);
|
|
37828
37841
|
if (opts.review !== void 0) {
|
|
37829
37842
|
if (opts.reviewFile !== void 0) die("Use either --review or --review-file.");
|
|
37830
|
-
return parseReviewFlow(opts.review,
|
|
37843
|
+
return parseReviewFlow(opts.review, catalog);
|
|
37831
37844
|
}
|
|
37832
|
-
const value = opts.reviewFile === void 0 ? previous : JSON.parse(fs16.readFileSync(opts.reviewFile, "utf8"));
|
|
37833
|
-
|
|
37845
|
+
const value = opts.reviewFile === void 0 ? readReviewPlan(previous) : JSON.parse(fs16.readFileSync(opts.reviewFile, "utf8"));
|
|
37846
|
+
const saved = opts.reviewFile === void 0 && opts.previewDefinitionsFile === void 0 && opts.studio === void 0;
|
|
37847
|
+
return validateReviewPreviews(parseReviewPlan(value), catalog, { saved });
|
|
37834
37848
|
}
|
|
37835
37849
|
function cmdGoalPreviews(studio, held4 = loadGoals().held) {
|
|
37836
37850
|
const id2 = studioOf(held4, studio);
|
|
@@ -41546,14 +41560,15 @@ function backoffMs(attempt2, random = Math.random) {
|
|
|
41546
41560
|
const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt2 - 2));
|
|
41547
41561
|
return Math.round(step * (1 - 0.25 * random()));
|
|
41548
41562
|
}
|
|
41549
|
-
function planRetry(failure2, attempt2, now = Date.now(), backoff = backoffMs) {
|
|
41563
|
+
function planRetry(failure2, attempt2, now = Date.now(), backoff = backoffMs, task = false) {
|
|
41550
41564
|
if (!Number.isSafeInteger(attempt2) || attempt2 < 1 || failure2.level === 3) return { pause: "needs-review" };
|
|
41551
41565
|
const of = failure2.level === 1 ? 2 : 4;
|
|
41552
41566
|
if (attempt2 >= of) return { pause: "limit" };
|
|
41553
41567
|
const delay3 = failure2.retryAfterMs;
|
|
41554
41568
|
const valid = delay3 !== void 0 && !Number.isNaN(delay3) && delay3 >= 0;
|
|
41555
41569
|
const wait = valid ? delay3 : failure2.level === 1 ? 0 : backoff(attempt2 + 1);
|
|
41556
|
-
|
|
41570
|
+
const cap = task && failure2.code === "rate_limited" && valid ? 24 * 60 * 6e4 : CAP_MS;
|
|
41571
|
+
if (wait > cap) return { pause: "wait-too-long" };
|
|
41557
41572
|
return { plan: { at: now + wait, of, failure: failure2 } };
|
|
41558
41573
|
}
|
|
41559
41574
|
function readFailure(raw) {
|
|
@@ -41562,12 +41577,12 @@ function readFailure(raw) {
|
|
|
41562
41577
|
if (typeof code !== "string" || !code || typeof reason !== "string" || level2 !== 1 && level2 !== 2 && level2 !== 3) return;
|
|
41563
41578
|
return { code, level: level2, reason, ...["validation", "provider", "harness", "invariant"].some((value) => value === source2) ? { source: source2 } : {}, ...typeof retryAfterMs2 === "number" && retryAfterMs2 >= 0 ? { retryAfterMs: retryAfterMs2 } : {} };
|
|
41564
41579
|
}
|
|
41565
|
-
function readRetryPlan(raw, attempt2) {
|
|
41580
|
+
function readRetryPlan(raw, attempt2, task = false) {
|
|
41566
41581
|
if (!raw || typeof raw !== "object") return;
|
|
41567
41582
|
const { at, of, failure: rawFailure } = raw;
|
|
41568
41583
|
const failure2 = readFailure(rawFailure);
|
|
41569
41584
|
if (!failure2 || typeof at !== "number" || !Number.isFinite(at)) return;
|
|
41570
|
-
const decision = planRetry(failure2, attempt2);
|
|
41585
|
+
const decision = planRetry(failure2, attempt2, Date.now(), backoffMs, task);
|
|
41571
41586
|
if ("plan" in decision && of === decision.plan.of) return { at, of, failure: failure2 };
|
|
41572
41587
|
}
|
|
41573
41588
|
function pauseLine(pause2, zh = translating()) {
|
|
@@ -41921,7 +41936,7 @@ var init_package = __esm({
|
|
|
41921
41936
|
"../cli/package.json"() {
|
|
41922
41937
|
package_default = {
|
|
41923
41938
|
name: "wildcrane",
|
|
41924
|
-
version: "0.11.
|
|
41939
|
+
version: "0.11.81",
|
|
41925
41940
|
akbContract: 27,
|
|
41926
41941
|
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.",
|
|
41927
41942
|
keywords: [
|
|
@@ -42941,6 +42956,7 @@ function antigravityPrices(at) {
|
|
|
42941
42956
|
return {
|
|
42942
42957
|
"gemini-4-carbon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
|
|
42943
42958
|
"gemini-4-argon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
|
|
42959
|
+
"gemini-4-neon": { input: 3, cachedInput: 0.15, output: 15 },
|
|
42944
42960
|
"gemini-4-hydrogen": { input: 1.5, cachedInput: 0.075, output: 7.5 },
|
|
42945
42961
|
"gemini-3.8-flash": { input: flash, cachedInput: flash / 10, output: flash * 5 }
|
|
42946
42962
|
};
|
|
@@ -43282,8 +43298,36 @@ function bytesField(data, field2) {
|
|
|
43282
43298
|
if (number4 === field2 && value instanceof Uint8Array) return value;
|
|
43283
43299
|
}
|
|
43284
43300
|
}
|
|
43301
|
+
function varintField(data, field2) {
|
|
43302
|
+
if (!(data instanceof Uint8Array)) return;
|
|
43303
|
+
for (const [number4, value] of fields(data)) {
|
|
43304
|
+
if (number4 === field2 && typeof value === "number") return value;
|
|
43305
|
+
}
|
|
43306
|
+
}
|
|
43307
|
+
function stepIndices(data) {
|
|
43308
|
+
const out = [];
|
|
43309
|
+
for (const [field2, value] of fields(data)) {
|
|
43310
|
+
if (field2 !== 2) continue;
|
|
43311
|
+
if (typeof value === "number") out.push(value);
|
|
43312
|
+
else {
|
|
43313
|
+
const offset = { value: 0 };
|
|
43314
|
+
while (offset.value < value.length) out.push(varint(value, offset));
|
|
43315
|
+
}
|
|
43316
|
+
}
|
|
43317
|
+
return out;
|
|
43318
|
+
}
|
|
43319
|
+
function recordedContextLimit(data) {
|
|
43320
|
+
const limit = varintField(bytesField(bytesField(bytesField(data, 1), 9), 10), 4);
|
|
43321
|
+
return limit !== void 0 && Number.isSafeInteger(limit) && limit > 0 ? limit : void 0;
|
|
43322
|
+
}
|
|
43323
|
+
function stepUuid(stepRow, index) {
|
|
43324
|
+
if (!Number.isSafeInteger(index) || index < 0) return;
|
|
43325
|
+
const id2 = bytesField(stepRow.get(index)?.metadata, 12);
|
|
43326
|
+
return id2?.length === 36 ? id2 : void 0;
|
|
43327
|
+
}
|
|
43285
43328
|
function antigravityRecordedModels(session, steps) {
|
|
43286
43329
|
const found2 = /* @__PURE__ */ new Map();
|
|
43330
|
+
if (!steps.size) return found2;
|
|
43287
43331
|
const file2 = antigravityConversationFile(session);
|
|
43288
43332
|
if (!file2 || !existsSync(file2)) return found2;
|
|
43289
43333
|
try {
|
|
@@ -43291,26 +43335,31 @@ function antigravityRecordedModels(session, steps) {
|
|
|
43291
43335
|
if (!sqlite) return found2;
|
|
43292
43336
|
const db = new sqlite.DatabaseSync(file2, { readOnly: true });
|
|
43293
43337
|
try {
|
|
43294
|
-
const
|
|
43338
|
+
const stepRow = db.prepare("SELECT metadata FROM steps WHERE idx = ?");
|
|
43339
|
+
const promptIds = /* @__PURE__ */ new Map();
|
|
43340
|
+
const promptUuid = (prompt) => {
|
|
43341
|
+
if (!promptIds.has(prompt)) promptIds.set(prompt, stepUuid(stepRow, prompt));
|
|
43342
|
+
return promptIds.get(prompt);
|
|
43343
|
+
};
|
|
43344
|
+
const groups = /* @__PURE__ */ new Map();
|
|
43345
|
+
for (const [index, { prompt }] of steps) {
|
|
43346
|
+
if (!Number.isSafeInteger(index) || index < 0) continue;
|
|
43347
|
+
const id2 = stepUuid(stepRow, index) ?? promptUuid(prompt);
|
|
43348
|
+
if (!id2) continue;
|
|
43349
|
+
const uuid3 = utf8(id2);
|
|
43350
|
+
let group = groups.get(uuid3);
|
|
43351
|
+
if (!group) groups.set(uuid3, group = { id: id2, steps: /* @__PURE__ */ new Set() });
|
|
43352
|
+
group.steps.add(index);
|
|
43353
|
+
}
|
|
43295
43354
|
const generations = db.prepare("SELECT data FROM gen_metadata WHERE instr(data, ?) > 0");
|
|
43296
|
-
for (const
|
|
43297
|
-
const id2 = bytesField(prompt.get(index)?.metadata, 12);
|
|
43298
|
-
if (id2?.length !== 36) continue;
|
|
43355
|
+
for (const [uuid3, { id: id2, steps: groupSteps }] of groups) {
|
|
43299
43356
|
const key = Buffer.concat([Buffer.from([34, 36]), id2]);
|
|
43300
43357
|
for (const { data } of generations.iterate(key)) {
|
|
43301
|
-
if (!(data instanceof Uint8Array) || utf8(bytesField(data, 4)) !==
|
|
43358
|
+
if (!(data instanceof Uint8Array) || utf8(bytesField(data, 4)) !== uuid3) continue;
|
|
43302
43359
|
const model = utf8(bytesField(bytesField(data, 1), 19)) || void 0;
|
|
43303
|
-
const
|
|
43304
|
-
if (
|
|
43360
|
+
for (const step of stepIndices(data)) {
|
|
43361
|
+
if (!groupSteps.has(step)) continue;
|
|
43305
43362
|
found2.set(step, found2.has(step) && found2.get(step) !== model ? void 0 : model);
|
|
43306
|
-
};
|
|
43307
|
-
for (const [field2, value] of fields(data)) {
|
|
43308
|
-
if (field2 !== 2) continue;
|
|
43309
|
-
if (typeof value === "number") record2(value);
|
|
43310
|
-
else {
|
|
43311
|
-
const offset = { value: 0 };
|
|
43312
|
-
while (offset.value < value.length) record2(varint(value, offset));
|
|
43313
|
-
}
|
|
43314
43363
|
}
|
|
43315
43364
|
}
|
|
43316
43365
|
}
|
|
@@ -43322,6 +43371,38 @@ function antigravityRecordedModels(session, steps) {
|
|
|
43322
43371
|
return /* @__PURE__ */ new Map();
|
|
43323
43372
|
}
|
|
43324
43373
|
}
|
|
43374
|
+
function antigravityRecordedContextLimit(session, step, prompt) {
|
|
43375
|
+
if (!Number.isSafeInteger(step) || step < 0) return;
|
|
43376
|
+
const file2 = antigravityConversationFile(session);
|
|
43377
|
+
if (!file2 || !existsSync(file2)) return;
|
|
43378
|
+
try {
|
|
43379
|
+
const sqlite = process.getBuiltinModule?.("node:sqlite");
|
|
43380
|
+
if (!sqlite) return;
|
|
43381
|
+
const db = new sqlite.DatabaseSync(file2, { readOnly: true });
|
|
43382
|
+
try {
|
|
43383
|
+
const stepRow = db.prepare("SELECT metadata FROM steps WHERE idx = ?");
|
|
43384
|
+
const id2 = stepUuid(stepRow, step) ?? stepUuid(stepRow, prompt);
|
|
43385
|
+
if (!id2) return;
|
|
43386
|
+
const key = Buffer.concat([Buffer.from([34, 36]), id2]);
|
|
43387
|
+
const generations = db.prepare("SELECT data FROM gen_metadata WHERE instr(data, ?) > 0");
|
|
43388
|
+
let found2;
|
|
43389
|
+
let matched = false;
|
|
43390
|
+
for (const { data } of generations.iterate(key)) {
|
|
43391
|
+
if (!(data instanceof Uint8Array) || utf8(bytesField(data, 4)) !== utf8(id2)) continue;
|
|
43392
|
+
if (!stepIndices(data).includes(step)) continue;
|
|
43393
|
+
const limit = recordedContextLimit(data);
|
|
43394
|
+
if (matched && found2 !== limit) return;
|
|
43395
|
+
found2 = limit;
|
|
43396
|
+
matched = true;
|
|
43397
|
+
}
|
|
43398
|
+
return found2;
|
|
43399
|
+
} finally {
|
|
43400
|
+
db.close();
|
|
43401
|
+
}
|
|
43402
|
+
} catch {
|
|
43403
|
+
return;
|
|
43404
|
+
}
|
|
43405
|
+
}
|
|
43325
43406
|
var utf8;
|
|
43326
43407
|
var init_antigravity_session = __esm({
|
|
43327
43408
|
"../cli/src/lib/agent/wire/antigravity-session.ts"() {
|
|
@@ -43356,6 +43437,20 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
|
43356
43437
|
let stderr = "";
|
|
43357
43438
|
let context;
|
|
43358
43439
|
let contextStep = -1;
|
|
43440
|
+
let contextPrompt = -1;
|
|
43441
|
+
let contextLimitStep = -1;
|
|
43442
|
+
let contextLimitLookedAt = 0;
|
|
43443
|
+
const resolveContextLimit = (now) => {
|
|
43444
|
+
if (!context || !session || contextStep < 0 || contextLimitStep === contextStep) return;
|
|
43445
|
+
const at = Date.now();
|
|
43446
|
+
if (!now && at - contextLimitLookedAt < CONTEXT_LOOK_EVERY_MS) return;
|
|
43447
|
+
contextLimitLookedAt = at;
|
|
43448
|
+
const limit = antigravityRecordedContextLimit(session, contextStep, contextPrompt);
|
|
43449
|
+
if (limit !== void 0) {
|
|
43450
|
+
context = { used: context.used, limit };
|
|
43451
|
+
contextLimitStep = contextStep;
|
|
43452
|
+
}
|
|
43453
|
+
};
|
|
43359
43454
|
const started = Date.now();
|
|
43360
43455
|
let cost;
|
|
43361
43456
|
let incomplete = false;
|
|
@@ -43421,10 +43516,13 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
|
43421
43516
|
const index = num2(step.step_index);
|
|
43422
43517
|
if (step.state === "DONE" && Number.isSafeInteger(index) && step.step_index === index && index > contextStep) {
|
|
43423
43518
|
contextStep = index;
|
|
43519
|
+
contextPrompt = prompt;
|
|
43520
|
+
contextLimitStep = -1;
|
|
43521
|
+
contextLimitLookedAt = 0;
|
|
43424
43522
|
const u = obj2(step.usage);
|
|
43425
43523
|
const counts = [u.input_tokens, u.cache_read_tokens];
|
|
43426
|
-
const
|
|
43427
|
-
context =
|
|
43524
|
+
const promptTokens = counts.every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0) ? num2(u.input_tokens) + num2(u.cache_read_tokens) : 0;
|
|
43525
|
+
context = promptTokens > 0 && Number.isFinite(promptTokens) ? { used: promptTokens } : void 0;
|
|
43428
43526
|
}
|
|
43429
43527
|
if (step.state === "DONE" && step.usage && !counted.has(index)) {
|
|
43430
43528
|
counted.add(index);
|
|
@@ -43477,6 +43575,7 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43477
43575
|
return "";
|
|
43478
43576
|
}
|
|
43479
43577
|
session ||= str2(result.conversation_id) || void 0;
|
|
43578
|
+
resolveContextLimit(true);
|
|
43480
43579
|
terminal = true;
|
|
43481
43580
|
final = typeof result.response === "string" ? result.response : void 0;
|
|
43482
43581
|
const total = usageOf(result.usage);
|
|
@@ -43508,6 +43607,7 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43508
43607
|
},
|
|
43509
43608
|
flush() {
|
|
43510
43609
|
const text5 = reader.flush();
|
|
43610
|
+
resolveContextLimit(true);
|
|
43511
43611
|
if (pendingCosts.size) {
|
|
43512
43612
|
const models = session ? antigravityRecordedModels(session, pendingCosts) : void 0;
|
|
43513
43613
|
for (const [index, { usage: usage3 }] of pendingCosts) estimate(models?.get(index), usage3);
|
|
@@ -43530,7 +43630,10 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43530
43630
|
usage: () => used,
|
|
43531
43631
|
costUsd: () => cost,
|
|
43532
43632
|
costIncomplete: () => incomplete || void 0,
|
|
43533
|
-
context: () =>
|
|
43633
|
+
context: () => {
|
|
43634
|
+
resolveContextLimit(false);
|
|
43635
|
+
return context;
|
|
43636
|
+
},
|
|
43534
43637
|
failure: () => failure2 || imageFailure,
|
|
43535
43638
|
terminalFailure: () => terminal && !!classified,
|
|
43536
43639
|
executionFailure: () => classified ?? (imageFailure ? { code: "image_read_failed", level: 3, reason: imageFailure } : void 0),
|
|
@@ -43538,7 +43641,7 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43538
43641
|
activity: events.activity
|
|
43539
43642
|
};
|
|
43540
43643
|
}
|
|
43541
|
-
var KINDS, zero, usageOf, add, imagePath;
|
|
43644
|
+
var CONTEXT_LOOK_EVERY_MS, KINDS, zero, usageOf, add, imagePath;
|
|
43542
43645
|
var init_antigravity = __esm({
|
|
43543
43646
|
"../cli/src/lib/agent/wire/antigravity.ts"() {
|
|
43544
43647
|
"use strict";
|
|
@@ -43548,6 +43651,7 @@ var init_antigravity = __esm({
|
|
|
43548
43651
|
init_json();
|
|
43549
43652
|
init_stream();
|
|
43550
43653
|
init_antigravity_session();
|
|
43654
|
+
CONTEXT_LOOK_EVERY_MS = 250;
|
|
43551
43655
|
KINDS = {
|
|
43552
43656
|
run_command: "execute",
|
|
43553
43657
|
command_status: "execute",
|
|
@@ -49239,6 +49343,47 @@ var init_roster = __esm({
|
|
|
49239
49343
|
}
|
|
49240
49344
|
});
|
|
49241
49345
|
|
|
49346
|
+
// ../cli/src/lib/shared/delivery-evidence.ts
|
|
49347
|
+
function approvedCardRequirements(text5) {
|
|
49348
|
+
const { meta: meta3, body } = parseFrontmatter(text5);
|
|
49349
|
+
const out = [];
|
|
49350
|
+
if (meta3?.title) out.push(`# ${meta3.title}`, "");
|
|
49351
|
+
const opening = [];
|
|
49352
|
+
const sections = [];
|
|
49353
|
+
let keeping = false;
|
|
49354
|
+
let started = false;
|
|
49355
|
+
for (const line of body.split("\n")) {
|
|
49356
|
+
if (/^##(?!#)\s/.test(line)) {
|
|
49357
|
+
started = true;
|
|
49358
|
+
keeping = isApproved(line);
|
|
49359
|
+
if (keeping) sections.push("", line);
|
|
49360
|
+
continue;
|
|
49361
|
+
}
|
|
49362
|
+
if (line.trim() === "<!-- agent -->") continue;
|
|
49363
|
+
if (!started) opening.push(line);
|
|
49364
|
+
else if (keeping) sections.push(line);
|
|
49365
|
+
}
|
|
49366
|
+
out.push(opening.join("\n").trim());
|
|
49367
|
+
out.push(sections.join("\n").trim());
|
|
49368
|
+
return out.filter(Boolean).join("\n\n").replace(/\n{3,}/g, "\n\n").trim() + "\n";
|
|
49369
|
+
}
|
|
49370
|
+
var APPROVED, isApproved;
|
|
49371
|
+
var init_delivery_evidence = __esm({
|
|
49372
|
+
"../cli/src/lib/shared/delivery-evidence.ts"() {
|
|
49373
|
+
"use strict";
|
|
49374
|
+
init_frontmatter();
|
|
49375
|
+
APPROVED = [
|
|
49376
|
+
/^##\s+Worth noting\s*$/i,
|
|
49377
|
+
/^##\s+Scope\s*$/i,
|
|
49378
|
+
/^##\s+Scope out\s*$/i,
|
|
49379
|
+
// `skill` is the word a spec section carries now; `agent` is the word it carried before
|
|
49380
|
+
// #403, and a card written by an older release still has to travel whole.
|
|
49381
|
+
/^##\s+By\s+`[^`]+`\s+(skill|agent)\s*$/i
|
|
49382
|
+
];
|
|
49383
|
+
isApproved = (heading) => APPROVED.some((re) => re.test(heading));
|
|
49384
|
+
}
|
|
49385
|
+
});
|
|
49386
|
+
|
|
49242
49387
|
// ../cli/src/lib/agent/candidate.ts
|
|
49243
49388
|
function candidateBase() {
|
|
49244
49389
|
return git(["rev-parse", "HEAD"])?.trim() || null;
|
|
@@ -49553,6 +49698,7 @@ function parseStore() {
|
|
|
49553
49698
|
runs.push({
|
|
49554
49699
|
sessionId: entry.sessionId,
|
|
49555
49700
|
cloudExecution: executionOf(entry.cloudExecution ?? null),
|
|
49701
|
+
pendingWrites: entry.pendingWrites === true || void 0,
|
|
49556
49702
|
cardId: typeof entry.cardId === "number" ? entry.cardId : null,
|
|
49557
49703
|
createdCardIds: Array.isArray(entry.createdCardIds) ? [...new Set(entry.createdCardIds.filter((id2) => Number.isInteger(id2) && id2 > 0))] : void 0,
|
|
49558
49704
|
discard: entry.discard === true || void 0,
|
|
@@ -49608,7 +49754,7 @@ function parseStore() {
|
|
|
49608
49754
|
resumedFrom: typeof entry.resumedFrom === "string" ? entry.resumedFrom : void 0,
|
|
49609
49755
|
continues: typeof entry.continues?.resumeId === "string" && entry.continues.resumeId ? { resumeId: entry.continues.resumeId, ...entry.continues.fork === true ? { fork: true } : {} } : void 0,
|
|
49610
49756
|
formatRepair: entry.formatRepair && typeof entry.formatRepair === "object" && Number.isInteger(entry.formatRepair.attempt) && entry.formatRepair.attempt >= 0 && typeof entry.formatRepair.errors === "string" && [entry.formatRepair.cardIds, entry.formatRepair.changedIds, entry.formatRepair.existingIds].every((ids) => Array.isArray(ids) && ids.every(Number.isInteger)) ? entry.formatRepair : void 0,
|
|
49611
|
-
retry: readRetry2(entry.retry),
|
|
49757
|
+
retry: readRetry2(entry.retry, !!executionOf(entry.cloudExecution ?? null)),
|
|
49612
49758
|
priorStatus: typeof entry.priorStatus === "string" ? entry.priorStatus : void 0,
|
|
49613
49759
|
// The pictures the create sheet handed this run (#517), as paths in its own folder.
|
|
49614
49760
|
pictures: readPictures(entry.pictures),
|
|
@@ -49650,11 +49796,11 @@ function readReasons(raw) {
|
|
|
49650
49796
|
});
|
|
49651
49797
|
return reasons.length ? reasons : void 0;
|
|
49652
49798
|
}
|
|
49653
|
-
function readRetry2(raw) {
|
|
49799
|
+
function readRetry2(raw, task) {
|
|
49654
49800
|
if (!raw || typeof raw !== "object") return void 0;
|
|
49655
49801
|
const r = raw;
|
|
49656
49802
|
const whole2 = Number.isInteger(r.attempt) && r.attempt > 0 && Number.isInteger(r.of) && r.of > 0 && typeof r.reason === "string" && !!r.reason && typeof r.at === "number" && typeof r.since === "number";
|
|
49657
|
-
return whole2 ? { attempt: r.attempt, of: r.of, reason: r.reason, at: r.at, since: r.since, pending: readRetryPlan(r.pending, r.attempt), launching: r.launching === true || void 0 } : void 0;
|
|
49803
|
+
return whole2 ? { attempt: r.attempt, of: r.of, reason: r.reason, at: r.at, since: r.since, pending: readRetryPlan(r.pending, r.attempt, task), launching: r.launching === true || void 0 } : void 0;
|
|
49658
49804
|
}
|
|
49659
49805
|
function readMarks(raw) {
|
|
49660
49806
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
@@ -50281,6 +50427,12 @@ function allAudits() {
|
|
|
50281
50427
|
}
|
|
50282
50428
|
return out;
|
|
50283
50429
|
}
|
|
50430
|
+
function cardAudits(cardId2) {
|
|
50431
|
+
return allAudits().filter((a) => a.cardId === cardId2).flatMap((a) => {
|
|
50432
|
+
const row = auditRow(a);
|
|
50433
|
+
return row ? [row] : [];
|
|
50434
|
+
}).sort((a, b) => a.startedAt - b.startedAt);
|
|
50435
|
+
}
|
|
50284
50436
|
function landedDeliveries(filter = {}) {
|
|
50285
50437
|
const out = [];
|
|
50286
50438
|
for (const audit of allAudits()) {
|
|
@@ -50442,27 +50594,7 @@ function approvedRequirements(cardId2) {
|
|
|
50442
50594
|
} catch {
|
|
50443
50595
|
return "";
|
|
50444
50596
|
}
|
|
50445
|
-
|
|
50446
|
-
const out = [];
|
|
50447
|
-
if (meta3?.title) out.push(`# ${meta3.title}`, "");
|
|
50448
|
-
const opening = [];
|
|
50449
|
-
const sections = [];
|
|
50450
|
-
let keeping = false;
|
|
50451
|
-
let started = false;
|
|
50452
|
-
for (const line of body.split("\n")) {
|
|
50453
|
-
if (/^##(?!#)\s/.test(line)) {
|
|
50454
|
-
started = true;
|
|
50455
|
-
keeping = isApproved(line);
|
|
50456
|
-
if (keeping) sections.push("", line);
|
|
50457
|
-
continue;
|
|
50458
|
-
}
|
|
50459
|
-
if (line.trim() === "<!-- agent -->") continue;
|
|
50460
|
-
if (!started) opening.push(line);
|
|
50461
|
-
else if (keeping) sections.push(line);
|
|
50462
|
-
}
|
|
50463
|
-
out.push(opening.join("\n").trim());
|
|
50464
|
-
out.push(sections.join("\n").trim());
|
|
50465
|
-
return out.filter(Boolean).join("\n\n").replace(/\n{3,}/g, "\n\n").trim() + "\n";
|
|
50597
|
+
return approvedCardRequirements(text5);
|
|
50466
50598
|
}
|
|
50467
50599
|
function cardMeta2(cardId2) {
|
|
50468
50600
|
try {
|
|
@@ -50601,7 +50733,7 @@ function heldByDelivery(cardId2, program2) {
|
|
|
50601
50733
|
const doing = state.paused ? `is waiting on you on #${cardId2} \u2014 ${state.line} \u2014 so the board won't change the card. ${answer2} Or take the card back with ` : `is in flight on #${cardId2} \u2014 it is building the card as it was approved when it started, so the board won't change it. Take the card back with `;
|
|
50602
50734
|
return `delivery ${delivery.deliveryId} ${doing}Discard on the card page, or \`${cmd} raw delivery cancel ${delivery.deliveryId}\` to end it here.`;
|
|
50603
50735
|
}
|
|
50604
|
-
var auditPath, activeAudits, auditRow, lastSessionRunning, localAudit, unknownDelivery, isResumable,
|
|
50736
|
+
var auditPath, activeAudits, auditRow, lastSessionRunning, localAudit, unknownDelivery, isResumable, cardStatus, openQuestions, activeIn, listDeliveries, withStudio;
|
|
50605
50737
|
var init_deliveries = __esm({
|
|
50606
50738
|
"../cli/src/lib/agent/deliveries.ts"() {
|
|
50607
50739
|
"use strict";
|
|
@@ -50609,6 +50741,7 @@ var init_deliveries = __esm({
|
|
|
50609
50741
|
init_cards();
|
|
50610
50742
|
init_revision();
|
|
50611
50743
|
init_frontmatter();
|
|
50744
|
+
init_delivery_evidence();
|
|
50612
50745
|
init_paths();
|
|
50613
50746
|
init_candidate();
|
|
50614
50747
|
init_command();
|
|
@@ -50629,15 +50762,6 @@ var init_deliveries = __esm({
|
|
|
50629
50762
|
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path48.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs47.existsSync(logPathOf(session.sessionId)));
|
|
50630
50763
|
unknownDelivery = (id2) => refusal("deliveryNotFound", `no delivery here answers to "${id2}"`, { id: id2 });
|
|
50631
50764
|
isResumable = (delivery) => !resumeRefusal(delivery);
|
|
50632
|
-
APPROVED = [
|
|
50633
|
-
/^##\s+Worth noting\s*$/i,
|
|
50634
|
-
/^##\s+Scope\s*$/i,
|
|
50635
|
-
/^##\s+Scope out\s*$/i,
|
|
50636
|
-
// `skill` is the word a spec section carries now; `agent` is the word it carried before
|
|
50637
|
-
// #403, and a card written by an older release still has to travel whole.
|
|
50638
|
-
/^##\s+By\s+`[^`]+`\s+(skill|agent)\s*$/i
|
|
50639
|
-
];
|
|
50640
|
-
isApproved = (heading) => APPROVED.some((re) => re.test(heading));
|
|
50641
50765
|
cardStatus = (cardId2) => cardMeta2(cardId2)?.status || "todo";
|
|
50642
50766
|
openQuestions = (cardId2) => cardMeta2(cardId2)?.questions.length ?? 0;
|
|
50643
50767
|
activeIn = (store, cardId2) => store.deliveries.find((d) => d.status === "active" && d.cardId === cardId2);
|
|
@@ -52022,21 +52146,27 @@ function endAgent(child, mark, graceMs) {
|
|
|
52022
52146
|
round(KILL_ROUNDS);
|
|
52023
52147
|
});
|
|
52024
52148
|
}
|
|
52025
|
-
function
|
|
52149
|
+
function probeProcesses(mark, root2) {
|
|
52026
52150
|
try {
|
|
52027
52151
|
if (WINDOWS3) {
|
|
52028
52152
|
const list3 = procsOnWindows();
|
|
52029
|
-
if (!list3
|
|
52153
|
+
if (!list3) return { ok: false, error: "\u65E0\u6CD5\u67E5\u8BE2\u8FDB\u7A0B\u5217\u8868\u3002" };
|
|
52154
|
+
if (!root2) return { ok: false, error: "\u7F3A\u5C11\u8FDB\u7A0B\u8D77\u70B9\uFF0C\u65E0\u6CD5\u6838\u5BF9\u9000\u51FA\u72B6\u6001\u3002" };
|
|
52030
52155
|
const current = list3.procs.find((p) => p.pid === root2.pid);
|
|
52031
|
-
if (current && current.startedAt > root2.since) return false;
|
|
52032
|
-
return startedUnder(list3, root2.pid, root2.since).length
|
|
52156
|
+
if (current && current.startedAt > root2.since) return { ok: false, error: "\u8FDB\u7A0B\u53F7\u5DF2\u88AB\u590D\u7528\u3002" };
|
|
52157
|
+
return { ok: true, alive: startedUnder(list3, root2.pid, root2.since).length > 0 };
|
|
52033
52158
|
}
|
|
52034
52159
|
const entry = `${mark.name}=${mark.value}`;
|
|
52035
|
-
|
|
52036
|
-
|
|
52037
|
-
|
|
52160
|
+
const pids = process.platform === "linux" ? markedInProc(entry, true, mark.since) : markedInPs(entry, root2 ? [root2.pid] : []);
|
|
52161
|
+
return { ok: true, alive: pids.length > 0 };
|
|
52162
|
+
} catch (e) {
|
|
52163
|
+
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
52038
52164
|
}
|
|
52039
52165
|
}
|
|
52166
|
+
function processesStopped(mark, root2) {
|
|
52167
|
+
const probed = probeProcesses(mark, root2);
|
|
52168
|
+
return probed.ok && !probed.alive;
|
|
52169
|
+
}
|
|
52040
52170
|
var runMark, WINDOWS3, KILL_ROUND_MS, KILL_ROUNDS, LIST_PROCS;
|
|
52041
52171
|
var init_stop = __esm({
|
|
52042
52172
|
"../cli/src/lib/agent/stop.ts"() {
|
|
@@ -52556,7 +52686,7 @@ async function openResume(id2, options) {
|
|
|
52556
52686
|
stopped: stopped2,
|
|
52557
52687
|
session,
|
|
52558
52688
|
replayable: !requireSession && neverStarted(prev),
|
|
52559
|
-
unconfirmedCleanup: prev.cleanup?.status === "unconfirmed" || prev.managedProcess && (pending?.failure ?? prev.failure)?.code === "idle_timeout" && !idleStopConfirmed(prev.cleanup, session)
|
|
52689
|
+
unconfirmedCleanup: prev.pendingWrites || prev.cleanup?.status === "unconfirmed" || prev.managedProcess && (pending?.failure ?? prev.failure)?.code === "idle_timeout" && !idleStopConfirmed(prev.cleanup, session)
|
|
52560
52690
|
});
|
|
52561
52691
|
if (recovery === "unsafe") {
|
|
52562
52692
|
if (pending) return retryRefusal(prev, "unsafe");
|
|
@@ -52863,6 +52993,152 @@ async function runIsDown(sessionId) {
|
|
|
52863
52993
|
await sleep3(STOP_POLL_MS);
|
|
52864
52994
|
}
|
|
52865
52995
|
}
|
|
52996
|
+
function verifyDeliveryRunsStopped(runs, deliveryId, cardId2) {
|
|
52997
|
+
const related = runs.filter(
|
|
52998
|
+
(r) => r.action !== "sub" && (r.deliveryId === deliveryId || r.cardId === cardId2 && holdsCard(r.action))
|
|
52999
|
+
);
|
|
53000
|
+
for (const r of related) {
|
|
53001
|
+
if (r.managedProcess) {
|
|
53002
|
+
if (!connectionStopped(r.agentPid ? { pid: r.agentPid, identity: r.agentIdentity } : void 0)) {
|
|
53003
|
+
return `Associated managed agent process for run ${r.sessionId} is still alive without an active watcher.`;
|
|
53004
|
+
}
|
|
53005
|
+
continue;
|
|
53006
|
+
}
|
|
53007
|
+
if (r.pid || r.agentPid) {
|
|
53008
|
+
const probed = probeProcesses(
|
|
53009
|
+
runMark(r.sessionId, r.agentStartedAt ?? r.startedAt),
|
|
53010
|
+
r.agentPid && r.agentStartedAt ? { pid: r.agentPid, since: r.agentStartedAt } : void 0
|
|
53011
|
+
);
|
|
53012
|
+
if (!probed.ok) return probed.error;
|
|
53013
|
+
if (probed.alive) {
|
|
53014
|
+
return `Associated delivery process for run ${r.sessionId} is still alive without an active watcher.`;
|
|
53015
|
+
}
|
|
53016
|
+
}
|
|
53017
|
+
}
|
|
53018
|
+
return void 0;
|
|
53019
|
+
}
|
|
53020
|
+
async function reconcileCardDelivery(cardId2) {
|
|
53021
|
+
const reaped = [];
|
|
53022
|
+
const restore = [];
|
|
53023
|
+
let result;
|
|
53024
|
+
try {
|
|
53025
|
+
result = withStore((store) => {
|
|
53026
|
+
reap(store.runs, reaped, restore);
|
|
53027
|
+
const file2 = cardFile(cardId2);
|
|
53028
|
+
const restoredRaw = file2 ? parseFrontmatter(fs51.readFileSync(file2, "utf8")).meta?.restored : void 0;
|
|
53029
|
+
const restoredAt = restoredRaw ? Date.parse(restoredRaw) : Number.NaN;
|
|
53030
|
+
const merged = /* @__PURE__ */ new Map();
|
|
53031
|
+
for (const audit of cardAudits(cardId2)) merged.set(audit.deliveryId, audit);
|
|
53032
|
+
for (const row of store.deliveries) {
|
|
53033
|
+
if (row.cardId === cardId2) merged.set(row.deliveryId, row);
|
|
53034
|
+
}
|
|
53035
|
+
const deliveries = [...merged.values()].filter((d) => !(Number.isFinite(restoredAt) && restoredAt > d.startedAt)).sort((a, b) => a.startedAt - b.startedAt);
|
|
53036
|
+
const activeOrLatest = deliveries.find((d) => d.status === "active") ?? deliveries.filter((d) => d.status !== "cancelled").pop();
|
|
53037
|
+
const liveRun = store.runs.find(
|
|
53038
|
+
(r) => r.status === "running" && r.action !== "sub" && !!r.deliveryId && (r.cardId === cardId2 || activeOrLatest && r.deliveryId === activeOrLatest.deliveryId)
|
|
53039
|
+
);
|
|
53040
|
+
if (liveRun) {
|
|
53041
|
+
return {
|
|
53042
|
+
kind: "running",
|
|
53043
|
+
deliveryId: liveRun.deliveryId ?? activeOrLatest?.deliveryId,
|
|
53044
|
+
sessionId: liveRun.sessionId,
|
|
53045
|
+
action: liveRun.action
|
|
53046
|
+
};
|
|
53047
|
+
}
|
|
53048
|
+
if (!activeOrLatest) return { kind: "none" };
|
|
53049
|
+
if (activeOrLatest.status === "finished" || activeOrLatest.completions?.some((c) => c.finished)) {
|
|
53050
|
+
const lastSession = activeOrLatest.sessions[activeOrLatest.sessions.length - 1];
|
|
53051
|
+
const code = activeOrLatest.completions?.slice().reverse().find((c) => c.commit);
|
|
53052
|
+
return {
|
|
53053
|
+
kind: "completed",
|
|
53054
|
+
deliveryId: activeOrLatest.deliveryId,
|
|
53055
|
+
sessionId: lastSession,
|
|
53056
|
+
commit: activeOrLatest.landing?.commit ?? code?.commit,
|
|
53057
|
+
branch: activeOrLatest.targetBranch ?? code?.branch
|
|
53058
|
+
};
|
|
53059
|
+
}
|
|
53060
|
+
const refused = resumeRefusal(activeOrLatest, store);
|
|
53061
|
+
if (refused) {
|
|
53062
|
+
return {
|
|
53063
|
+
kind: "unverified",
|
|
53064
|
+
deliveryId: activeOrLatest.deliveryId,
|
|
53065
|
+
diagnostic: refused.error
|
|
53066
|
+
};
|
|
53067
|
+
}
|
|
53068
|
+
const processError = verifyDeliveryRunsStopped(store.runs, activeOrLatest.deliveryId, cardId2);
|
|
53069
|
+
if (processError) {
|
|
53070
|
+
return {
|
|
53071
|
+
kind: "unverified",
|
|
53072
|
+
deliveryId: activeOrLatest.deliveryId,
|
|
53073
|
+
diagnostic: processError
|
|
53074
|
+
};
|
|
53075
|
+
}
|
|
53076
|
+
const lastRun = store.runs.filter((r) => r.deliveryId === activeOrLatest.deliveryId && r.action !== "sub").sort((a, b) => a.startedAt - b.startedAt).pop();
|
|
53077
|
+
return {
|
|
53078
|
+
kind: "resumable",
|
|
53079
|
+
deliveryId: activeOrLatest.deliveryId,
|
|
53080
|
+
status: activeOrLatest.status,
|
|
53081
|
+
sessionId: lastRun?.sessionId,
|
|
53082
|
+
hasSession: !!(lastRun && resumeSessionId(lastRun)),
|
|
53083
|
+
worktree: activeOrLatest.worktree,
|
|
53084
|
+
branch: activeOrLatest.branch,
|
|
53085
|
+
base: activeOrLatest.base
|
|
53086
|
+
};
|
|
53087
|
+
});
|
|
53088
|
+
} catch (error62) {
|
|
53089
|
+
return {
|
|
53090
|
+
kind: "unverified",
|
|
53091
|
+
diagnostic: error62 instanceof Error ? error62.message : String(error62)
|
|
53092
|
+
};
|
|
53093
|
+
}
|
|
53094
|
+
for (const run3 of restore) await restoreCardStatus(run3);
|
|
53095
|
+
for (const run3 of reaped) await settleDelivery(run3);
|
|
53096
|
+
return result;
|
|
53097
|
+
}
|
|
53098
|
+
async function releaseCardDelivery(cardId2) {
|
|
53099
|
+
const execution = executionOf();
|
|
53100
|
+
if (execution && !await executionHeld(execution)) {
|
|
53101
|
+
return { ok: false, error: "\u65E0\u6CD5\u786E\u8BA4\u5F53\u524D\u6267\u884C\u7684 Cloud \u6388\u6743\uFF0C\u65E0\u6CD5\u91CA\u653E\u539F\u4EA4\u4ED8\u5199\u9501\u3002" };
|
|
53102
|
+
}
|
|
53103
|
+
const reaped = [];
|
|
53104
|
+
const restore = [];
|
|
53105
|
+
let releasedDelivery;
|
|
53106
|
+
let outcome;
|
|
53107
|
+
try {
|
|
53108
|
+
outcome = withStore((store) => {
|
|
53109
|
+
reap(store.runs, reaped, restore);
|
|
53110
|
+
const active3 = activeIn(store, cardId2);
|
|
53111
|
+
if (!active3) return { ok: true, released: false };
|
|
53112
|
+
const liveRun = store.runs.find(
|
|
53113
|
+
(r) => r.status === "running" && r.action !== "sub" && (r.cardId === cardId2 || r.deliveryId === active3.deliveryId)
|
|
53114
|
+
);
|
|
53115
|
+
if (liveRun) {
|
|
53116
|
+
return {
|
|
53117
|
+
ok: false,
|
|
53118
|
+
deliveryId: active3.deliveryId,
|
|
53119
|
+
error: `\u539F\u4EA4\u4ED8\u4ECD\u6709\u8FD0\u884C\u4E2D\u7684\u8FDB\u7A0B (${liveRun.sessionId})\uFF0C\u65E0\u6CD5\u91CA\u653E\u5199\u9501\u3002`
|
|
53120
|
+
};
|
|
53121
|
+
}
|
|
53122
|
+
const processError = verifyDeliveryRunsStopped(store.runs, active3.deliveryId, cardId2);
|
|
53123
|
+
if (processError) {
|
|
53124
|
+
return { ok: false, deliveryId: active3.deliveryId, error: processError };
|
|
53125
|
+
}
|
|
53126
|
+
const at = Date.now();
|
|
53127
|
+
active3.status = "failed";
|
|
53128
|
+
active3.endedAt = at;
|
|
53129
|
+
active3.steps.push({ step: "released", at });
|
|
53130
|
+
writeAudit(active3, store.runs);
|
|
53131
|
+
releasedDelivery = { ...active3 };
|
|
53132
|
+
return { ok: true, released: true, deliveryId: active3.deliveryId };
|
|
53133
|
+
});
|
|
53134
|
+
} catch (error62) {
|
|
53135
|
+
return { ok: false, error: error62 instanceof Error ? error62.message : String(error62) };
|
|
53136
|
+
}
|
|
53137
|
+
for (const run3 of restore) await restoreCardStatus(run3);
|
|
53138
|
+
for (const run3 of reaped) await settleDelivery(run3);
|
|
53139
|
+
if (releasedDelivery) await releaseCard(releasedDelivery);
|
|
53140
|
+
return outcome;
|
|
53141
|
+
}
|
|
52866
53142
|
async function resumeDelivery(id2) {
|
|
52867
53143
|
if (!id2.trim()) return { ok: false, ...refusal("deliveryUnnamed", "name the delivery to carry on", { action: "resume" }) };
|
|
52868
53144
|
const execution = executionOf();
|
|
@@ -62075,7 +62351,7 @@ var init_describe_project = __esm({
|
|
|
62075
62351
|
var discuss_goal_default;
|
|
62076
62352
|
var init_discuss_goal = __esm({
|
|
62077
62353
|
"../cli/src/guide/discuss-goal.md"() {
|
|
62078
|
-
discuss_goal_default = '# Discuss a goal\n\nExplain feasible options and key tradeoffs, then save the result the user can choose to start.\n\n- **Investigations**: finish checks and diagnosis here; save a change only when findings establish it. Report unverified work plainly.\n- **Goals**: save independent deliverables separately. Update existing goals rather than duplicate them.\n- **Studio**: choose the fitting installed Studio, preferring the user\'s choice; read its Additional Notes with `akb studio rule <studio>` and honor their scope.\n- **Select Previews**:
|
|
62354
|
+
discuss_goal_default = '# Discuss a goal\n\nExplain feasible options and key tradeoffs, then save the result the user can choose to start.\n\n- **Investigations**: finish checks and diagnosis here; save a change only when findings establish it. Report unverified work plainly.\n- **Goals**: save independent deliverables separately. Update existing goals rather than duplicate them.\n- **Studio**: choose the fitting installed Studio, preferring the user\'s choice; read its Additional Notes with `akb studio rule <studio>` and honor their scope.\n- **Select Previews**: choose Studio Previews for drafts or results that need review. Define a Goal Preview for a requested result the Studio lacks. Keep task context in the Goal body.\n- **Review** independent Previews in parallel by default. Use Studio or Goal Preview names, e.g. `--review \'Tech choices + UI design\'`. Add `->` when the next group needs the previous group\'s approvals. Verify the saved plan.\n- **Review state**: pass `--review \'\'` for no extra approval, leave the plan undecided while a decision is missing, and omit the option when keeping a saved plan.\n- **Decisions**: explain the proposed outcome and review arrangement before saving. Ask only for choices the user must make, with a recommendation.\n- **Start**: the user starts each Goal from the page; its effective review arrangement governs output approval. Confirm changes to task-specific Preview definitions before making the affected output.\n- **Communication**: the remote user sees tasks and previews. Use plain words and button labels, omitting internal paths, commands and tools.\n\n## Goal format\n\nUse exactly these three fields on create and update. Include only what the user requested or confirmed.\n\nPass the one-line title separately with `--title`. Use this template for `--body-file`:\n\n```markdown\n<The requested outcome in at most 150 words.>\n\n## Done when\n\n- <A verifiable condition for the requested outcome.>\n```\n\n\n## Custom Preview definitions\n\nPass a JSON array with `--preview-definitions-file`. Use a stable ID, English and Chinese titles, and concise requirements. Omit the file to keep definitions, or pass `[]` to clear them.\n\n```json\n[{\n "id": "accessibility-report",\n "title": {"en": "Accessibility report", "zh": "\u65E0\u969C\u788D\u68C0\u67E5\u62A5\u544A"},\n "instructions": "Check keyboard navigation, visible focus and contrast. Include steps to reproduce issues."\n}]\n```\n\nUse the title in a Flow such as `--review \'UI design -> Accessibility report\'` when preparation requires an earlier approval.\n';
|
|
62079
62355
|
}
|
|
62080
62356
|
});
|
|
62081
62357
|
|
|
@@ -62091,7 +62367,7 @@ var init_follow_up = __esm({
|
|
|
62091
62367
|
var implement_default;
|
|
62092
62368
|
var init_implement = __esm({
|
|
62093
62369
|
"../cli/src/guide/implement.md"() {
|
|
62094
|
-
implement_default = "# Implement the approved requirements\n\nBuild the approved requirements without reopening settled decisions or unrelated questions; without a card, create none.\n\nDo not push, publish or deploy.\n\nOnce a task meets its Studio's delivery conditions, follow `akb guide archive` to record\ndelivery completion before ending the run.\n\n- **Verification**: run required and minimal representative checks, reuse valid results, distinguish defects from environment or tool limits, stop retries that add no evidence, and finish when acceptance is proven.\n- **Authorization**: carry approval for necessary in-scope operations across tools and stages without asking again.\n- **Blockers**: resolve routine problems and use `akb guide update-questions` only for user-action blockers or out-of-scope decisions, stating attempts, impact and recommendation while continuing independent work.\n- **Defer**: follow `akb guide follow-up` for unrelated work and keep it from blocking delivery.\n- **Decisions**: record material, reversible build decisions under `## Worth noting after implementation`.\n";
|
|
62370
|
+
implement_default = "# Implement the approved requirements\n\nBuild the approved requirements without reopening settled decisions or unrelated questions; without a card, create none.\n\nFor Git deliveries, adapt the approved work to the current target branch and preserve changes\nit made since approval, including removals. Stop the affected work and use\n`akb guide update-questions` only if those changes conflict with the task's core intent.\n\nDo not push, publish or deploy.\n\nOnce a task meets its Studio's delivery conditions, follow `akb guide archive` to record\ndelivery completion before ending the run.\n\n- **Verification**: run required and minimal representative checks, reuse valid results, distinguish defects from environment or tool limits, stop retries that add no evidence, and finish when acceptance is proven.\n- **Authorization**: carry approval for necessary in-scope operations across tools and stages without asking again.\n- **Blockers**: resolve routine problems and use `akb guide update-questions` only for user-action blockers or out-of-scope decisions, stating attempts, impact and recommendation while continuing independent work.\n- **Defer**: follow `akb guide follow-up` for unrelated work and keep it from blocking delivery.\n- **Decisions**: record material, reversible build decisions under `## Worth noting after implementation`.\n";
|
|
62095
62371
|
}
|
|
62096
62372
|
});
|
|
62097
62373
|
|
|
@@ -62131,7 +62407,7 @@ var init_review_rejections = __esm({
|
|
|
62131
62407
|
var refine_default;
|
|
62132
62408
|
var init_refine = __esm({
|
|
62133
62409
|
"../cli/src/guide/refine.md"() {
|
|
62134
|
-
refine_default =
|
|
62410
|
+
refine_default = "# Refine a card\n\nPlan one card until it is buildable.\n\n- **Unchecked cards**: check cards with `triage:` and empty `## Scope` against the project, rejecting obsolete or completed work with `akb raw reject <id> --reason \"<evidence>\"` and stopping.\n- **Other obsolete or completed cards**: ask whether to discard, run no previews, and stop.\n- **Groups**: preserve subtask coverage and progress, fill gaps without duplication, and do not mark the parent ready merely because its split is complete.\n- **Verification**: plan representative checks for the outcome, project rules and material risks, confirm prerequisites, and keep optional coverage optional.\n- **Review**: read `akb task review <id>`. If undecided, submit `--review <flow>` with Preview names or `--file <json>` with Preview IDs, plus `--revision <n>`. Use `--review ''` when no extra review is needed. Work only on dispatched, unlocked nodes and continue independent work during review.\n- **Preview selection**: choose Studio Previews for drafts or results that need review. For a requested result the Studio lacks, attach its definition with `--preview-definitions-file`. Keep task context in the card body.\n- **Previews**: prepare only the unlocked nodes\u2019 outputs per the Studio\u2019s `<Preview>` blocks. Before revising an approved output, use `--revise-from <stage> --revision <n>`; preserve unrelated outputs and approvals.\n- **Submit**: synchronize body and assets, then report `--stage <id> --status done --revision <n>`. Re-read after conflicts; obtain output approval at the required stages.\n- **Delivery**: the Studio's delivery flow handles separate implementation and its checks.\n- **References**: rewrite mentions of cards no longer on the board.\n- **Decisions**: settle choices supported by evidence and ask only as `akb guide update-questions` allows.\n- **Card**: follow studio rules and `akb guide writing`, fixing all errors from `akb raw validate <id>`.\n- **Ready**: when validated and buildable with prerequisites settled, run `akb raw update <id> --status ready`; otherwise leave blockers as open questions.\n\nFollow the printed closing steps. Wait only for required approvals; completion still requires Studio delivery checks.\n";
|
|
62135
62411
|
}
|
|
62136
62412
|
});
|
|
62137
62413
|
|
|
@@ -63719,7 +63995,7 @@ var init_approved_ui = __esm({
|
|
|
63719
63995
|
init_preview_blocks();
|
|
63720
63996
|
init_review_plan();
|
|
63721
63997
|
APPROVED_UI_DIR_ENV = "AI4KANBAN_APPROVED_UI_DIR";
|
|
63722
|
-
APPROVED_UI_RULE = "Open the approved mockups and
|
|
63998
|
+
APPROVED_UI_RULE = "Open the approved mockups and follow the Coding Studio delivery requirements for matching the task's intended UI changes.";
|
|
63723
63999
|
UI_PREVIEW = "ui-design";
|
|
63724
64000
|
historicalUiIds = Object.keys(CODING_PREVIEWS).filter((id2) => id2 !== UI_PREVIEW && CODING_PREVIEWS[id2] === UI_PREVIEW);
|
|
63725
64001
|
object2 = (value) => isObject2(value) ? value : {};
|
|
@@ -63839,8 +64115,14 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
63839
64115
|
const pendingOperations = /* @__PURE__ */ new Set();
|
|
63840
64116
|
const event2 = (e) => {
|
|
63841
64117
|
observeActivity(e);
|
|
64118
|
+
const hadPending = pendingOperations.size > 0;
|
|
63842
64119
|
if (e.kind === "tool_call" && !["read", "search", "fetch"].includes(e.data.kind) && !["completed", "failed"].includes(e.data.status)) pendingOperations.add(e.data.toolCallId);
|
|
63843
64120
|
if ((e.kind === "tool_call" || e.kind === "tool_call_update") && ["completed", "failed"].includes(e.data.status ?? "")) pendingOperations.delete(e.data.toolCallId);
|
|
64121
|
+
if (record2.cloudExecution && hadPending !== pendingOperations.size > 0) {
|
|
64122
|
+
patch(sessionId, (run4) => {
|
|
64123
|
+
run4.pendingWrites = pendingOperations.size > 0;
|
|
64124
|
+
});
|
|
64125
|
+
}
|
|
63844
64126
|
eventsFile.write(`${JSON.stringify(e)}
|
|
63845
64127
|
`);
|
|
63846
64128
|
};
|
|
@@ -64098,7 +64380,7 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64098
64380
|
let retrying = false;
|
|
64099
64381
|
if (failure2 && !sub && !taskCompleted) {
|
|
64100
64382
|
const attempt2 = held4.retry?.attempt ?? 1;
|
|
64101
|
-
const decision = planRetry(failure2, attempt2, Date.now(), retryBackoff);
|
|
64383
|
+
const decision = planRetry(failure2, attempt2, Date.now(), retryBackoff, !!held4.cloudExecution);
|
|
64102
64384
|
if ("pause" in decision) retryPause = decision.pause;
|
|
64103
64385
|
else {
|
|
64104
64386
|
const mark = runMark(sessionId, agentStartedAt);
|
|
@@ -64111,7 +64393,7 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64111
64393
|
stopped: stopped3(),
|
|
64112
64394
|
session,
|
|
64113
64395
|
replayable: held4.unspawned === true && !pendingOperations.size,
|
|
64114
|
-
unconfirmedCleanup: !!blocker || spoken?.cleanup?.status === "unconfirmed" || client?.managedProcess && silent && (uncertainAtIdle || !idleStopConfirmed(spoken?.cleanup, session))
|
|
64396
|
+
unconfirmedCleanup: pendingOperations.size > 0 || !!blocker || spoken?.cleanup?.status === "unconfirmed" || client?.managedProcess && silent && (uncertainAtIdle || !idleStopConfirmed(spoken?.cleanup, session))
|
|
64115
64397
|
});
|
|
64116
64398
|
if (recovery === "unsafe") retryPause = "unsafe";
|
|
64117
64399
|
else {
|
|
@@ -64563,6 +64845,23 @@ async function cmdCancel(named2) {
|
|
|
64563
64845
|
say(`delivery ${res.deliveryId} cancelled \u2014 files, branches and directories are preserved.`);
|
|
64564
64846
|
return { deliveryId: res.deliveryId };
|
|
64565
64847
|
}
|
|
64848
|
+
async function cmdReconcileDelivery(cardId2) {
|
|
64849
|
+
const result = await reconcileCardDelivery(cardId2);
|
|
64850
|
+
if (result.kind === "unverified") {
|
|
64851
|
+
say(`delivery${result.deliveryId ? ` ${result.deliveryId}` : ""}: unverified \u2014 ${result.diagnostic}`);
|
|
64852
|
+
} else if (result.kind === "none") {
|
|
64853
|
+
say(`#${cardId2}: no delivery to reconcile`);
|
|
64854
|
+
} else {
|
|
64855
|
+
say(`#${cardId2}: ${result.kind}${result.deliveryId ? ` (${result.deliveryId})` : ""}`);
|
|
64856
|
+
}
|
|
64857
|
+
return result;
|
|
64858
|
+
}
|
|
64859
|
+
async function cmdReleaseDelivery(cardId2) {
|
|
64860
|
+
const res = await releaseCardDelivery(cardId2);
|
|
64861
|
+
if (!res.ok) die(res.error, { kind: "run-refused", ...res.deliveryId ? { deliveryId: res.deliveryId } : {} });
|
|
64862
|
+
say(res.released ? `delivery ${res.deliveryId} lock released \u2014 files and branch preserved.` : `#${cardId2}: no active delivery lock to release.`);
|
|
64863
|
+
return res;
|
|
64864
|
+
}
|
|
64566
64865
|
async function cmdResumeDelivery(named2) {
|
|
64567
64866
|
const res = await resumeBoardDelivery(named2);
|
|
64568
64867
|
if (!res.ok) die(res.error ?? "that delivery could not be carried on", {
|
|
@@ -65901,6 +66200,14 @@ function declareDelivery(delivery, cli) {
|
|
|
65901
66200
|
const [named2] = positional(vals);
|
|
65902
66201
|
await onBoard(this, cli, () => cmdResumeDelivery(named2));
|
|
65903
66202
|
});
|
|
66203
|
+
verb("reconcile").argument("<card>", "card number", cardId).summary("reconcile local delivery state for a card before recovery").action(async function(...vals) {
|
|
66204
|
+
const [id2] = positional(vals);
|
|
66205
|
+
await onBoard(this, cli, () => cmdReconcileDelivery(id2));
|
|
66206
|
+
});
|
|
66207
|
+
verb("release").argument("<card>", "card number", cardId).summary("safely release an active delivery write lock while preserving saved work").action(async function(...vals) {
|
|
66208
|
+
const [id2] = positional(vals);
|
|
66209
|
+
await onBoard(this, cli, () => cmdReleaseDelivery(id2));
|
|
66210
|
+
});
|
|
65904
66211
|
}
|
|
65905
66212
|
function declareFlow(parent, flow, cli) {
|
|
65906
66213
|
const byDelivery = flow.group === "delivery";
|