wildcrane 0.11.73 → 0.11.74
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/kanban.mjs +297 -122
- package/package.json +2 -2
package/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.74 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
|
|
3
3
|
// Do not edit: every change belongs in cli/src/, and a build overwrites this file.
|
|
4
4
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
5
5
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
@@ -20849,6 +20849,9 @@ function parseReviewPlan(value, previews) {
|
|
|
20849
20849
|
}
|
|
20850
20850
|
return plan;
|
|
20851
20851
|
}
|
|
20852
|
+
function readReviewPlan(plan) {
|
|
20853
|
+
return plan?.map(({ id: id2, after: after2, previews }) => ({ id: id2, after: after2, previews })) ?? null;
|
|
20854
|
+
}
|
|
20852
20855
|
function reviewBoundary(review, assigned) {
|
|
20853
20856
|
const allowed = review.pending_plan ? [] : review.stages.filter((s) => (s.status === "available" || s.status === "running") && (!assigned || assigned.includes(s.id)));
|
|
20854
20857
|
return [
|
|
@@ -20865,7 +20868,6 @@ var init_review_plan = __esm({
|
|
|
20865
20868
|
id = external_exports.string().trim().min(1).max(100);
|
|
20866
20869
|
reviewNodeSchema = external_exports.object({
|
|
20867
20870
|
id,
|
|
20868
|
-
title: external_exports.string().trim().min(1).max(200),
|
|
20869
20871
|
after: external_exports.array(id).max(50).default([]),
|
|
20870
20872
|
previews: external_exports.array(id).max(50).default([])
|
|
20871
20873
|
}).strict();
|
|
@@ -20932,8 +20934,8 @@ function deferRefresh(session, error62, after2) {
|
|
|
20932
20934
|
const attempt2 = Math.min((readRetry(session)?.attempt ?? 0) + 1, 4);
|
|
20933
20935
|
const seconds = after2?.trim() ? Number(after2) : NaN;
|
|
20934
20936
|
const serverDelay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(after2 ?? "") - Date.now();
|
|
20935
|
-
const
|
|
20936
|
-
const retry2 = { key: refreshKey(session), until: Date.now() +
|
|
20937
|
+
const delay3 = Math.max(Math.min(REFRESH_BACKOFF_MS * 2 ** (attempt2 - 1), 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
|
|
20938
|
+
const retry2 = { key: refreshKey(session), until: Date.now() + delay3, attempt: attempt2, error: error62 };
|
|
20937
20939
|
const temporary = `${retryFile()}.${process.pid}.tmp`;
|
|
20938
20940
|
fs3.writeFileSync(temporary, JSON.stringify(retry2), { mode: 384 });
|
|
20939
20941
|
fs3.renameSync(temporary, retryFile());
|
|
@@ -36765,7 +36767,7 @@ var init_preview_blocks = __esm({
|
|
|
36765
36767
|
});
|
|
36766
36768
|
|
|
36767
36769
|
// src/lib/agent/studio-def.ts
|
|
36768
|
-
function parseStudioFile(id2, source2, from) {
|
|
36770
|
+
function parseStudioFile(id2, source2, from, requirePreviewCopy = false) {
|
|
36769
36771
|
const problems = [];
|
|
36770
36772
|
const fail = (offset, path86, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path86, code, message, hint: hint2 });
|
|
36771
36773
|
const result = () => ({ problem: problems.map((p) => `${p.file}:${p.line}:${p.column} ${p.path}: ${p.code} \u2014 ${p.message}. ${p.hint}`).join("\n"), problems });
|
|
@@ -36793,7 +36795,7 @@ function parseStudioFile(id2, source2, from) {
|
|
|
36793
36795
|
const key = error62.params.additionalProperty ?? error62.params.missingProperty;
|
|
36794
36796
|
if (key) parts.push(String(key));
|
|
36795
36797
|
const node2 = parts.length ? document.getIn(parts, true) : document.contents;
|
|
36796
|
-
fail(metaOffset + (node2?.range?.[0] ?? 0), parts.join("."), "studio-schema", `${parts.join(".") || "metadata"} ${error62.message}`, "Use only Studio metadata and previews: {id: {title?, icon?}} with the declared field types.");
|
|
36798
|
+
fail(metaOffset + (node2?.range?.[0] ?? 0), parts.join("."), "studio-schema", `${parts.join(".") || "metadata"} ${error62.message}`, "Use only Studio metadata and previews: {id: {title?, description?, icon?}} with the declared field types.");
|
|
36797
36799
|
}
|
|
36798
36800
|
}
|
|
36799
36801
|
const body = source2.slice(bodyOffset);
|
|
@@ -36803,6 +36805,20 @@ function parseStudioFile(id2, source2, from) {
|
|
|
36803
36805
|
const map3 = raw.previews ?? {};
|
|
36804
36806
|
for (const block of parsed.blocks) if (!Object.hasOwn(map3, block.id)) fail(bodyOffset + block.start, `previews.${block.id}`, "preview-metadata-missing", `Preview ${block.id} has no metadata entry`, "Add the ID under previews, using {} if needed.");
|
|
36805
36807
|
for (const key of Object.keys(map3)) if (!parsed.blocks.some((b) => b.id === key)) fail(metaOffset + (document.getIn(["previews", key], true)?.range?.[0] ?? 0), `previews.${key}`, "preview-body-missing", `Preview ${key} has no body`, "Add its block or remove unused metadata.");
|
|
36808
|
+
if (requirePreviewCopy) for (const block of parsed.blocks) {
|
|
36809
|
+
const metadata = Object.hasOwn(map3, block.id) ? map3[block.id] : void 0;
|
|
36810
|
+
if (!metadata) continue;
|
|
36811
|
+
for (const field2 of ["title", "description"]) for (const lang of ["en", "zh"]) {
|
|
36812
|
+
if (metadata[field2]?.[lang]) continue;
|
|
36813
|
+
fail(
|
|
36814
|
+
bodyOffset + block.start,
|
|
36815
|
+
`previews.${block.id}.${field2}.${lang}`,
|
|
36816
|
+
"preview-display-missing",
|
|
36817
|
+
`Preview ${block.id} needs a ${lang} ${field2}`,
|
|
36818
|
+
"Add non-blank en and zh display text in the Preview metadata."
|
|
36819
|
+
);
|
|
36820
|
+
}
|
|
36821
|
+
}
|
|
36806
36822
|
if (problems.length) return result();
|
|
36807
36823
|
let rules = "", at = 0;
|
|
36808
36824
|
for (const block of parsed.blocks) {
|
|
@@ -36855,7 +36871,7 @@ var init_studio_def = __esm({
|
|
|
36855
36871
|
previews: { type: "object", propertyNames: { pattern: PREVIEW_ID.source }, additionalProperties: {
|
|
36856
36872
|
type: "object",
|
|
36857
36873
|
additionalProperties: false,
|
|
36858
|
-
properties: { title: titles, icon }
|
|
36874
|
+
properties: { title: titles, description: titles, icon }
|
|
36859
36875
|
} }
|
|
36860
36876
|
}
|
|
36861
36877
|
};
|
|
@@ -36897,12 +36913,12 @@ function mcpProblem(text5) {
|
|
|
36897
36913
|
}
|
|
36898
36914
|
return null;
|
|
36899
36915
|
}
|
|
36900
|
-
function checkStudioFiles(value, official = false) {
|
|
36901
|
-
const read5 = inspect(value, official);
|
|
36916
|
+
function checkStudioFiles(value, official = false, allowLegacyPreviewCopy = false) {
|
|
36917
|
+
const read5 = inspect(value, official, allowLegacyPreviewCopy);
|
|
36902
36918
|
const first = read5.problems[0];
|
|
36903
36919
|
return first ? { ok: false, ...first, problems: read5.problems } : { ok: true, def: read5.def, files: read5.files };
|
|
36904
36920
|
}
|
|
36905
|
-
function inspect(value, official) {
|
|
36921
|
+
function inspect(value, official, allowLegacyPreviewCopy = false) {
|
|
36906
36922
|
const problems = [];
|
|
36907
36923
|
const fail = (file2, reason, tooLarge = false) => {
|
|
36908
36924
|
problems.push({ file: file2, reason, ...tooLarge ? { tooLarge } : {} });
|
|
@@ -36947,7 +36963,7 @@ function inspect(value, official) {
|
|
|
36947
36963
|
if (files[`skills/${name}/SKILL.md`] === void 0) fail(`skills/${name}/SKILL.md`, "is missing");
|
|
36948
36964
|
}
|
|
36949
36965
|
const source2 = files[STUDIO_FILE];
|
|
36950
|
-
const read5 = typeof source2 === "string" ? parseStudioFile("studio", source2, STUDIO_FILE) : null;
|
|
36966
|
+
const read5 = typeof source2 === "string" ? parseStudioFile("studio", source2, STUDIO_FILE, !official && !allowLegacyPreviewCopy) : null;
|
|
36951
36967
|
if (!read5) fail(STUDIO_FILE, "is missing");
|
|
36952
36968
|
else if ("problem" in read5) for (const problem of read5.problems) problems.push({ ...problem, reason: problem.message });
|
|
36953
36969
|
if (!read5 || "problem" in read5) return { problems };
|
|
@@ -37532,6 +37548,7 @@ function loadGoals() {
|
|
|
37532
37548
|
if (held4.goals !== void 0 && held4.ideas !== void 0 && JSON.stringify(held4.goals) !== JSON.stringify(held4.ideas)) die("goals and ideas do not match.");
|
|
37533
37549
|
const goals = held4.goals ?? held4.ideas;
|
|
37534
37550
|
if (!Array.isArray(goals)) die("The goals array is missing or invalid.");
|
|
37551
|
+
for (const goal of goals) if (goal.review_plan !== void 0) goal.review_plan = readReviewPlan(goal.review_plan);
|
|
37535
37552
|
return { file: file2, held: { ...held4, studios: held4.studios ?? [], goals } };
|
|
37536
37553
|
}
|
|
37537
37554
|
function studioOf(held4, asked) {
|
|
@@ -41157,6 +41174,16 @@ var init_card_studio_backfill = __esm({
|
|
|
41157
41174
|
}
|
|
41158
41175
|
});
|
|
41159
41176
|
|
|
41177
|
+
// src/lib/agent/wire/codex-background-types.ts
|
|
41178
|
+
function idleStopConfirmed(cleanup, session) {
|
|
41179
|
+
return !!session && cleanup?.status === "confirmed" && !!cleanup.instance && Array.isArray(cleanup.kept) && cleanup.kept.length === 0 && cleanup.idleStop?.threadId === session && typeof cleanup.idleStop.turnId === "string" && !!cleanup.idleStop.turnId;
|
|
41180
|
+
}
|
|
41181
|
+
var init_codex_background_types = __esm({
|
|
41182
|
+
"src/lib/agent/wire/codex-background-types.ts"() {
|
|
41183
|
+
"use strict";
|
|
41184
|
+
}
|
|
41185
|
+
});
|
|
41186
|
+
|
|
41160
41187
|
// src/lib/lock.ts
|
|
41161
41188
|
import { randomUUID } from "node:crypto";
|
|
41162
41189
|
import fs18 from "node:fs";
|
|
@@ -41375,17 +41402,17 @@ function planRetry(failure2, attempt2, now = Date.now(), backoff = backoffMs) {
|
|
|
41375
41402
|
if (!Number.isSafeInteger(attempt2) || attempt2 < 1 || failure2.level === 3) return { pause: "needs-review" };
|
|
41376
41403
|
const of = failure2.level === 1 ? 2 : 4;
|
|
41377
41404
|
if (attempt2 >= of) return { pause: "limit" };
|
|
41378
|
-
const
|
|
41379
|
-
const valid =
|
|
41380
|
-
const wait = valid ?
|
|
41405
|
+
const delay3 = failure2.retryAfterMs;
|
|
41406
|
+
const valid = delay3 !== void 0 && !Number.isNaN(delay3) && delay3 >= 0;
|
|
41407
|
+
const wait = valid ? delay3 : failure2.level === 1 ? 0 : backoff(attempt2 + 1);
|
|
41381
41408
|
if (wait > CAP_MS) return { pause: "wait-too-long" };
|
|
41382
41409
|
return { plan: { at: now + wait, of, failure: failure2 } };
|
|
41383
41410
|
}
|
|
41384
41411
|
function readFailure(raw) {
|
|
41385
41412
|
if (!raw || typeof raw !== "object") return;
|
|
41386
|
-
const { code, level: level2, reason, retryAfterMs: retryAfterMs2 } = raw;
|
|
41413
|
+
const { code, level: level2, reason, source: source2, retryAfterMs: retryAfterMs2 } = raw;
|
|
41387
41414
|
if (typeof code !== "string" || !code || typeof reason !== "string" || level2 !== 1 && level2 !== 2 && level2 !== 3) return;
|
|
41388
|
-
return { code, level: level2, reason, ...typeof retryAfterMs2 === "number" && retryAfterMs2 >= 0 ? { retryAfterMs: retryAfterMs2 } : {} };
|
|
41415
|
+
return { code, level: level2, reason, ...["validation", "provider", "harness", "invariant"].some((value) => value === source2) ? { source: source2 } : {}, ...typeof retryAfterMs2 === "number" && retryAfterMs2 >= 0 ? { retryAfterMs: retryAfterMs2 } : {} };
|
|
41389
41416
|
}
|
|
41390
41417
|
function readRetryPlan(raw, attempt2) {
|
|
41391
41418
|
if (!raw || typeof raw !== "object") return;
|
|
@@ -41413,6 +41440,11 @@ function retryLine(plan, attempt2, now = Date.now()) {
|
|
|
41413
41440
|
const seconds = Math.max(0, Math.ceil((plan.at - now) / 1e3));
|
|
41414
41441
|
return `${plan.failure.reason} \u2014 retrying ${seconds ? `in ${seconds}s` : "now"} (attempt ${attempt2 + 1} of ${plan.of}).`;
|
|
41415
41442
|
}
|
|
41443
|
+
function syncRepairPrompt(reason) {
|
|
41444
|
+
return `The Harness could not synchronize the saved result. Correct the diagnostics below, verify the original result and its attachments, then continue from the saved work. Preserve completed work and archive state. Read the task review before changing an approved output and revise its stage first.
|
|
41445
|
+
|
|
41446
|
+
${reason}`;
|
|
41447
|
+
}
|
|
41416
41448
|
var BASE_MS, CAP_MS;
|
|
41417
41449
|
var init_retry = __esm({
|
|
41418
41450
|
"src/lib/agent/retry.ts"() {
|
|
@@ -41740,8 +41772,8 @@ var init_package = __esm({
|
|
|
41740
41772
|
"package.json"() {
|
|
41741
41773
|
package_default = {
|
|
41742
41774
|
name: "wildcrane",
|
|
41743
|
-
version: "0.11.
|
|
41744
|
-
akbContract:
|
|
41775
|
+
version: "0.11.74",
|
|
41776
|
+
akbContract: 21,
|
|
41745
41777
|
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.",
|
|
41746
41778
|
keywords: [
|
|
41747
41779
|
"kanban",
|
|
@@ -43502,6 +43534,7 @@ function executionFailure(error62) {
|
|
|
43502
43534
|
return {
|
|
43503
43535
|
code: NETWORK.has(code) ? "connection_lost" : code === "ENOENT" ? "executable_missing" : "execution_failed",
|
|
43504
43536
|
level: NETWORK.has(code) ? 2 : 3,
|
|
43537
|
+
source: "harness",
|
|
43505
43538
|
reason
|
|
43506
43539
|
};
|
|
43507
43540
|
}
|
|
@@ -43519,17 +43552,19 @@ function providerFailure(error62, reason) {
|
|
|
43519
43552
|
const headers = obj2(info.headers);
|
|
43520
43553
|
const wait = retryAfterMs(headers["retry-after"] ?? headers["Retry-After"]);
|
|
43521
43554
|
const code = info.code ?? info.type;
|
|
43522
|
-
if (code === "session_not_found") return { code, level: 3, reason };
|
|
43555
|
+
if (code === "session_not_found") return { code, source: "provider", level: 3, reason };
|
|
43523
43556
|
if (status === 401 || status === 403 || ["authentication_error", "permission_error", "invalid_request_error"].includes(str2(code))) {
|
|
43524
|
-
return { code: "provider_refused", level: 3, reason };
|
|
43557
|
+
return { code: "provider_refused", source: "provider", level: 3, reason };
|
|
43525
43558
|
}
|
|
43526
|
-
if (code === "rate_limit_error") return { code: "rate_limited", level: 2, reason, retryAfterMs: wait };
|
|
43527
|
-
if (TEMPORARY_HTTP.has(status ?? 0) || code === "overloaded_error") return { code: "service_overloaded", level: 2, reason, retryAfterMs: wait };
|
|
43528
|
-
if (NETWORK.has(str2(code))) return { code: "connection_lost", level: 2, reason, retryAfterMs: wait };
|
|
43529
|
-
return { code: "provider_failed", level: 3, reason };
|
|
43559
|
+
if (code === "rate_limit_error") return { code: "rate_limited", source: "provider", level: 2, reason, retryAfterMs: wait };
|
|
43560
|
+
if (TEMPORARY_HTTP.has(status ?? 0) || code === "overloaded_error") return { code: "service_overloaded", source: "provider", level: 2, reason, retryAfterMs: wait };
|
|
43561
|
+
if (NETWORK.has(str2(code))) return { code: "connection_lost", source: "provider", level: 2, reason, retryAfterMs: wait };
|
|
43562
|
+
return { code: "provider_failed", source: "provider", level: 3, reason };
|
|
43530
43563
|
}
|
|
43531
43564
|
function codexFailure(raw, fallback) {
|
|
43532
43565
|
const error62 = obj2(raw);
|
|
43566
|
+
const failure2 = readFailure(error62.wildcraneFailure);
|
|
43567
|
+
if (failure2?.source === "harness" || failure2?.source === "invariant") return failure2;
|
|
43533
43568
|
const reason = str2(error62.message) || fallback;
|
|
43534
43569
|
const info = error62.codexErrorInfo;
|
|
43535
43570
|
if (info === "serverOverloaded") return providerFailure({ ...error62, type: "overloaded_error" }, reason);
|
|
@@ -43547,6 +43582,7 @@ var ExecutionError, NETWORK, TEMPORARY_HTTP;
|
|
|
43547
43582
|
var init_failures = __esm({
|
|
43548
43583
|
"src/lib/agent/wire/failures.ts"() {
|
|
43549
43584
|
"use strict";
|
|
43585
|
+
init_retry();
|
|
43550
43586
|
init_json();
|
|
43551
43587
|
ExecutionError = class extends Error {
|
|
43552
43588
|
constructor(failure2) {
|
|
@@ -43696,7 +43732,7 @@ function createStreamRenderer() {
|
|
|
43696
43732
|
const turnUsage = usageOf2(ev.usage);
|
|
43697
43733
|
if (turnUsage) usage3 = usage3 ? addUsage(usage3, turnUsage) : turnUsage;
|
|
43698
43734
|
failure2 = ev.is_error === true ? whyItFailed(ev) : void 0;
|
|
43699
|
-
classified = failure2 ? ev.subtype === "error_max_structured_output_retries" ? { code: "validation_failed", level: 1, reason: failure2 } : { ...apiFailure ?? providerFailure(ev.error, failure2), reason: failure2 } : void 0;
|
|
43735
|
+
classified = failure2 ? ev.subtype === "error_max_structured_output_retries" ? { code: "validation_failed", level: 1, source: "validation", reason: failure2 } : { ...apiFailure ?? providerFailure(ev.error, failure2), reason: failure2 } : void 0;
|
|
43700
43736
|
apiFailure = void 0;
|
|
43701
43737
|
if (failure2) events.error(failure2);
|
|
43702
43738
|
turns.push({
|
|
@@ -44807,6 +44843,8 @@ async function oneTurn(io, options) {
|
|
|
44807
44843
|
const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
|
|
44808
44844
|
let started = false;
|
|
44809
44845
|
let contentAt = 0;
|
|
44846
|
+
let thinkingAt = 0;
|
|
44847
|
+
let thinking = false;
|
|
44810
44848
|
let currentSession = "";
|
|
44811
44849
|
const events = createEventCollector();
|
|
44812
44850
|
const emit = () => {
|
|
@@ -44836,7 +44874,20 @@ async function oneTurn(io, options) {
|
|
|
44836
44874
|
}
|
|
44837
44875
|
if (live && (!obj2(msg.params).sessionId || obj2(msg.params).sessionId === currentSession)) {
|
|
44838
44876
|
const kind = str2(obj2(obj2(msg.params).update).sessionUpdate);
|
|
44839
|
-
if (["agent_message_chunk", "agent_thought_chunk"].includes(kind)
|
|
44877
|
+
if (["agent_message_chunk", "agent_thought_chunk"].includes(kind) && str2(obj2(obj2(obj2(msg.params).update).content).text)) {
|
|
44878
|
+
io.activity?.();
|
|
44879
|
+
if (kind === "agent_thought_chunk") {
|
|
44880
|
+
if (!thinking || Date.now() - thinkingAt >= 1e3) {
|
|
44881
|
+
io.event?.({ kind: "status", data: { state: "thinking", source: "acp" } });
|
|
44882
|
+
thinkingAt = Date.now();
|
|
44883
|
+
}
|
|
44884
|
+
thinking = true;
|
|
44885
|
+
}
|
|
44886
|
+
}
|
|
44887
|
+
if (thinking && ["agent_message_chunk", "tool_call", "plan"].includes(kind)) {
|
|
44888
|
+
thinking = false;
|
|
44889
|
+
io.event?.({ kind: "status", data: { state: "running", source: "acp" } });
|
|
44890
|
+
}
|
|
44840
44891
|
if (!started && ["agent_message_chunk", "tool_call", "plan"].includes(kind)) {
|
|
44841
44892
|
started = true;
|
|
44842
44893
|
phase("started");
|
|
@@ -45349,6 +45400,90 @@ var init_zcode = __esm({
|
|
|
45349
45400
|
}
|
|
45350
45401
|
});
|
|
45351
45402
|
|
|
45403
|
+
// src/lib/agent/idle.ts
|
|
45404
|
+
function createIdleWatchdog(expired, busy = () => false, milliseconds = IDLE_TIMEOUT.milliseconds, now = Date.now) {
|
|
45405
|
+
const calls = /* @__PURE__ */ new Set();
|
|
45406
|
+
const local = /* @__PURE__ */ new Set();
|
|
45407
|
+
const seen = /* @__PURE__ */ new Map();
|
|
45408
|
+
let last = now();
|
|
45409
|
+
let working = false;
|
|
45410
|
+
let closed2 = false;
|
|
45411
|
+
let recoveringAt;
|
|
45412
|
+
let retryUntil = 0;
|
|
45413
|
+
const touch = () => {
|
|
45414
|
+
if (!closed2) {
|
|
45415
|
+
last = now();
|
|
45416
|
+
recoveringAt = void 0;
|
|
45417
|
+
retryUntil = 0;
|
|
45418
|
+
}
|
|
45419
|
+
};
|
|
45420
|
+
const check2 = () => {
|
|
45421
|
+
if (closed2) return;
|
|
45422
|
+
if (retryUntil > now()) return;
|
|
45423
|
+
const active3 = calls.size > 0 || busy();
|
|
45424
|
+
if (active3 || working) last = now();
|
|
45425
|
+
working = active3;
|
|
45426
|
+
if (!active3 && now() - last >= milliseconds) {
|
|
45427
|
+
close();
|
|
45428
|
+
expired();
|
|
45429
|
+
}
|
|
45430
|
+
};
|
|
45431
|
+
const timer = setInterval(check2, Math.min(1e3, milliseconds));
|
|
45432
|
+
timer.unref?.();
|
|
45433
|
+
const close = () => {
|
|
45434
|
+
closed2 = true;
|
|
45435
|
+
clearInterval(timer);
|
|
45436
|
+
calls.clear();
|
|
45437
|
+
local.clear();
|
|
45438
|
+
seen.clear();
|
|
45439
|
+
};
|
|
45440
|
+
return {
|
|
45441
|
+
touch,
|
|
45442
|
+
check: check2,
|
|
45443
|
+
close,
|
|
45444
|
+
event(e) {
|
|
45445
|
+
if (closed2) return;
|
|
45446
|
+
if (e.kind === "status") {
|
|
45447
|
+
if (e.data.state !== "retrying") touch();
|
|
45448
|
+
else {
|
|
45449
|
+
recoveringAt ??= now();
|
|
45450
|
+
retryUntil = Math.min(now() + PROVIDER_RETRY_MS.announcement, recoveringAt + PROVIDER_RETRY_MS.episode);
|
|
45451
|
+
}
|
|
45452
|
+
check2();
|
|
45453
|
+
return;
|
|
45454
|
+
}
|
|
45455
|
+
if (e.kind === "log" || e.kind === "context") return;
|
|
45456
|
+
if (e.kind === "phase" && !e.data.contentAt) return;
|
|
45457
|
+
const key = e.kind === "tool_call" || e.kind === "tool_call_update" ? `${e.kind}:${e.data.toolCallId}` : e.kind;
|
|
45458
|
+
const value = JSON.stringify(e.data);
|
|
45459
|
+
if (seen.get(key) === value) return;
|
|
45460
|
+
seen.set(key, value);
|
|
45461
|
+
if (e.kind === "tool_call" && (e.data.kind === "execute" || e.data.subagent)) local.add(e.data.toolCallId);
|
|
45462
|
+
if (e.kind === "tool_call" || e.kind === "tool_call_update") {
|
|
45463
|
+
const { toolCallId, status } = e.data;
|
|
45464
|
+
if (local.has(toolCallId) && ["in_progress", "running"].includes(status)) calls.add(toolCallId);
|
|
45465
|
+
if (["completed", "failed"].includes(status)) {
|
|
45466
|
+
calls.delete(toolCallId);
|
|
45467
|
+
local.delete(toolCallId);
|
|
45468
|
+
}
|
|
45469
|
+
}
|
|
45470
|
+
touch();
|
|
45471
|
+
check2();
|
|
45472
|
+
}
|
|
45473
|
+
};
|
|
45474
|
+
}
|
|
45475
|
+
var IDLE_MS, IDLE_TIMEOUT, IDLE_ERROR, IDLE_FAILURE, PROVIDER_RETRY_MS;
|
|
45476
|
+
var init_idle = __esm({
|
|
45477
|
+
"src/lib/agent/idle.ts"() {
|
|
45478
|
+
"use strict";
|
|
45479
|
+
IDLE_MS = 5 * 6e4;
|
|
45480
|
+
IDLE_TIMEOUT = { milliseconds: IDLE_MS };
|
|
45481
|
+
IDLE_ERROR = "No response for 5 minutes (idle timeout).";
|
|
45482
|
+
IDLE_FAILURE = { code: "idle_timeout", level: 2, reason: IDLE_ERROR };
|
|
45483
|
+
PROVIDER_RETRY_MS = { announcement: 10 * 6e4, episode: 30 * 6e4 };
|
|
45484
|
+
}
|
|
45485
|
+
});
|
|
45486
|
+
|
|
45352
45487
|
// src/guide/settle-background.md
|
|
45353
45488
|
var settle_background_default;
|
|
45354
45489
|
var init_settle_background = __esm({
|
|
@@ -45558,6 +45693,7 @@ var init_codex_work = __esm({
|
|
|
45558
45693
|
|
|
45559
45694
|
// src/lib/agent/wire/codex.ts
|
|
45560
45695
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
45696
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
45561
45697
|
function createCodexConnection(argv) {
|
|
45562
45698
|
const execAt = argv.indexOf("exec");
|
|
45563
45699
|
if (execAt < 1) return void 0;
|
|
@@ -45610,6 +45746,7 @@ function createCodexClient(options = { images: [] }) {
|
|
|
45610
45746
|
return {
|
|
45611
45747
|
structured: true,
|
|
45612
45748
|
managedProcess: true,
|
|
45749
|
+
idleRecovery: true,
|
|
45613
45750
|
background: () => background,
|
|
45614
45751
|
turn: (io) => run(io, options, (count3) => {
|
|
45615
45752
|
background = count3;
|
|
@@ -45619,11 +45756,26 @@ function createCodexClient(options = { images: [] }) {
|
|
|
45619
45756
|
async function run(io, options, count3) {
|
|
45620
45757
|
const since = Date.now();
|
|
45621
45758
|
const renderer = createCodexStreamRenderer();
|
|
45622
|
-
|
|
45759
|
+
let idling = false;
|
|
45760
|
+
let preparingUntil = Math.min(io.prepareUntil ?? Infinity, Date.now() + CONVERSATION_MS.prepare);
|
|
45623
45761
|
const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
|
|
45624
45762
|
let submitted = false;
|
|
45625
45763
|
let started = false;
|
|
45626
45764
|
let contentAt = 0;
|
|
45765
|
+
let status;
|
|
45766
|
+
let statusAt = 0;
|
|
45767
|
+
const thinking = () => {
|
|
45768
|
+
if (status !== "thinking" || Date.now() - statusAt >= 1e3) {
|
|
45769
|
+
io.event?.({ kind: "status", data: { state: "thinking", source: "codex" } });
|
|
45770
|
+
statusAt = Date.now();
|
|
45771
|
+
}
|
|
45772
|
+
status = "thinking";
|
|
45773
|
+
};
|
|
45774
|
+
const recovered = () => {
|
|
45775
|
+
if (!status) return;
|
|
45776
|
+
io.event?.({ kind: "status", data: { state: "running", source: "codex" } });
|
|
45777
|
+
status = void 0;
|
|
45778
|
+
};
|
|
45627
45779
|
let startupTimer;
|
|
45628
45780
|
const began = () => {
|
|
45629
45781
|
if (!submitted || started || ended) return;
|
|
@@ -45674,11 +45826,12 @@ async function run(io, options, count3) {
|
|
|
45674
45826
|
clearTimeout(startupTimer);
|
|
45675
45827
|
clearTimeout(settleTimer);
|
|
45676
45828
|
io.signal?.removeEventListener("abort", cancelled);
|
|
45829
|
+
io.idleSignal?.removeEventListener("abort", idle);
|
|
45677
45830
|
count3(0);
|
|
45678
45831
|
io.stdout.off("close", closed2);
|
|
45679
45832
|
io.stdin.off("error", inputFailed);
|
|
45680
45833
|
if (settlement) flushMessages(work.work().some((w) => !w.intentionalStop && !["running", "unknown"].includes(w.status) && presented.get(w.id) !== snapshot2(w)));
|
|
45681
|
-
cleanup.items = work.work().map(({ id: id2, threadId: threadId2, processId, status, disposition }) => ({ id: id2, threadId: threadId2, processId, status, disposition }));
|
|
45834
|
+
cleanup.items = work.work().map(({ id: id2, threadId: threadId2, processId, status: status2, disposition }) => ({ id: id2, threadId: threadId2, processId, status: status2, disposition }));
|
|
45682
45835
|
io.log(renderer.flush());
|
|
45683
45836
|
const usage3 = ownUsage(total, baseline);
|
|
45684
45837
|
const child = childSpend(children, since);
|
|
@@ -45708,10 +45861,32 @@ async function run(io, options, count3) {
|
|
|
45708
45861
|
};
|
|
45709
45862
|
const cancelled = () => {
|
|
45710
45863
|
work.freeze();
|
|
45711
|
-
note("Execution stopped; no further cleanup turn was submitted.");
|
|
45864
|
+
if (submitted || threadId) note("Execution stopped; no further cleanup turn was submitted.");
|
|
45712
45865
|
end2("Codex execution stopped.");
|
|
45713
45866
|
};
|
|
45714
45867
|
io.signal?.addEventListener("abort", cancelled, { once: true });
|
|
45868
|
+
const idle = async () => {
|
|
45869
|
+
if (ended || idling) return;
|
|
45870
|
+
idling = true;
|
|
45871
|
+
const unknownWork = () => [...work.entries.values()].some((item2) => ["running", "unknown", "interrupted"].includes(item2.status));
|
|
45872
|
+
const uncertain = unknownWork();
|
|
45873
|
+
const ownedTurn = currentTurn2;
|
|
45874
|
+
try {
|
|
45875
|
+
if (host2.idleRecovery !== true || !threadId || !ownedTurn || !active3 || settlement) throw Error("Codex did not confirm that this turn can be interrupted for recovery.");
|
|
45876
|
+
const receipt = await bounded(
|
|
45877
|
+
rpc.call("wildcrane/stopForRetry", { threadId, turnId: ownedTurn, instance: host2.instance, lease: host2.lease }),
|
|
45878
|
+
CONVERSATION_MS.prepare,
|
|
45879
|
+
"Codex did not confirm stopping the idle turn."
|
|
45880
|
+
);
|
|
45881
|
+
if (receipt.instance !== host2.instance || receipt.lease !== host2.lease || receipt.threadId !== threadId || receipt.turnId !== ownedTurn) throw Error("Codex returned a different turn or owner.");
|
|
45882
|
+
if (uncertain || unknownWork()) throw Error("Codex has operations with unconfirmed results.");
|
|
45883
|
+
cleanup.idleStop = { threadId, turnId: ownedTurn };
|
|
45884
|
+
} catch (error62) {
|
|
45885
|
+
if (!ended) note(error62 instanceof Error ? error62.message : String(error62));
|
|
45886
|
+
}
|
|
45887
|
+
if (!ended) end2(IDLE_FAILURE.reason, IDLE_FAILURE);
|
|
45888
|
+
};
|
|
45889
|
+
io.idleSignal?.addEventListener("abort", idle, { once: true });
|
|
45715
45890
|
const childUpdates = () => {
|
|
45716
45891
|
for (const w of work.entries.values()) {
|
|
45717
45892
|
if (w.kind !== "agent" || childEvents.get(w.id) === w.status) continue;
|
|
@@ -45925,9 +46100,13 @@ async function run(io, options, count3) {
|
|
|
45925
46100
|
childUpdates();
|
|
45926
46101
|
return;
|
|
45927
46102
|
}
|
|
45928
|
-
if (submitted && /\/delta$/.test(msg.method ?? "") && str2(p.delta)) io.activity?.();
|
|
45929
46103
|
const turnId = str2(p.turnId) || str2(obj2(p.turn).id);
|
|
45930
46104
|
if (historicalTurns.has(turnId) || currentTurn2 && turnId && currentTurn2 !== turnId) return;
|
|
46105
|
+
if (submitted && ["item/agentMessage/delta", "item/plan/delta", "item/reasoning/summaryTextDelta", "item/reasoning/textDelta"].includes(msg.method ?? "") && str2(p.delta)) {
|
|
46106
|
+
if (msg.method?.startsWith("item/reasoning/")) thinking();
|
|
46107
|
+
else recovered();
|
|
46108
|
+
io.activity?.();
|
|
46109
|
+
}
|
|
45931
46110
|
if (msg.method === "turn/started") {
|
|
45932
46111
|
if (!submitted || completedTurns.has(turnId)) return;
|
|
45933
46112
|
currentTurn2 = turnId;
|
|
@@ -45940,7 +46119,10 @@ async function run(io, options, count3) {
|
|
|
45940
46119
|
contentAt = Date.now();
|
|
45941
46120
|
io.event?.({ kind: "phase", data: { phase: "started", at: (/* @__PURE__ */ new Date()).toISOString(), contentAt: new Date(contentAt).toISOString() } });
|
|
45942
46121
|
}
|
|
45943
|
-
if (msg.method === "item/started" || msg.method === "item/completed")
|
|
46122
|
+
if (msg.method === "item/started" || msg.method === "item/completed") {
|
|
46123
|
+
recovered();
|
|
46124
|
+
item(obj2(p.item), msg.method === "item/completed", !completedTurns.has(turnId));
|
|
46125
|
+
}
|
|
45944
46126
|
if (msg.method === "thread/tokenUsage/updated") {
|
|
45945
46127
|
if (!submitted) return;
|
|
45946
46128
|
const token2 = obj2(p.tokenUsage);
|
|
@@ -45958,9 +46140,14 @@ async function run(io, options, count3) {
|
|
|
45958
46140
|
context = { used: (Number(last.inputTokens) || 0) + (Number(last.outputTokens) || 0), ...Number(token2.modelContextWindow) > 0 ? { limit: Number(token2.modelContextWindow) } : {} };
|
|
45959
46141
|
io.gotContext?.(context);
|
|
45960
46142
|
}
|
|
45961
|
-
if (msg.method === "error"
|
|
46143
|
+
if (msg.method === "error") {
|
|
45962
46144
|
const failure2 = codexFailure(p.error, "Codex failed.");
|
|
45963
|
-
|
|
46145
|
+
if (p.willRetry === true && submitted && active3 && !idling) {
|
|
46146
|
+
status = "retrying";
|
|
46147
|
+
io.log(`[Codex recovery] ${failure2.code}: ${failure2.reason}
|
|
46148
|
+
`);
|
|
46149
|
+
io.event?.({ kind: "status", data: { state: "retrying", source: "codex", code: failure2.code } });
|
|
46150
|
+
} else if (p.willRetry !== true) end2(failure2.reason, failure2);
|
|
45964
46151
|
}
|
|
45965
46152
|
if (msg.method === "turn/completed") {
|
|
45966
46153
|
const turn2 = obj2(p.turn);
|
|
@@ -45971,6 +46158,7 @@ async function run(io, options, count3) {
|
|
|
45971
46158
|
work.observe(threadId, raw);
|
|
45972
46159
|
item(raw, true);
|
|
45973
46160
|
}
|
|
46161
|
+
if (idling) return;
|
|
45974
46162
|
if (turn2.status !== "completed") {
|
|
45975
46163
|
const reason = str2(obj2(turn2.error).message) || `Codex turn ${str2(turn2.status)}.`;
|
|
45976
46164
|
const failure2 = turn2.status === "failed" ? codexFailure(turn2.error, reason) : { code: "turn_stopped", level: 3, reason };
|
|
@@ -45991,6 +46179,10 @@ async function run(io, options, count3) {
|
|
|
45991
46179
|
cancelled();
|
|
45992
46180
|
return done;
|
|
45993
46181
|
}
|
|
46182
|
+
if (io.idleSignal?.aborted) {
|
|
46183
|
+
void idle();
|
|
46184
|
+
return done;
|
|
46185
|
+
}
|
|
45994
46186
|
phase("preparing");
|
|
45995
46187
|
const initialized = await bounded(rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } }), preparingUntil - Date.now(), "Codex initialize timed out.");
|
|
45996
46188
|
host2 = obj2(initialized.wildcrane);
|
|
@@ -45998,11 +46190,31 @@ async function run(io, options, count3) {
|
|
|
45998
46190
|
phase("initialized");
|
|
45999
46191
|
rpc.notify("initialized");
|
|
46000
46192
|
const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
|
|
46001
|
-
const
|
|
46193
|
+
const method = `thread/${mode ?? "start"}`;
|
|
46194
|
+
const params = { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} };
|
|
46195
|
+
let response;
|
|
46196
|
+
let waiting = false;
|
|
46197
|
+
while (!ended && !response) {
|
|
46198
|
+
try {
|
|
46199
|
+
response = await bounded(rpc.call(method, params), preparingUntil - Date.now(), `Codex ${method} timed out.`);
|
|
46200
|
+
} catch (error62) {
|
|
46201
|
+
const failure2 = error62 instanceof RpcError ? codexFailure(error62.data, error62.message) : void 0;
|
|
46202
|
+
if (mode !== "fork" || failure2?.source !== "harness" || failure2.code !== "codex_source_busy") throw error62;
|
|
46203
|
+
if (!waiting) {
|
|
46204
|
+
waiting = true;
|
|
46205
|
+
io.event?.({ kind: "log", data: { text: failure2.reason } });
|
|
46206
|
+
}
|
|
46207
|
+
io.activity?.();
|
|
46208
|
+
await delay(500, void 0, { signal: io.signal });
|
|
46209
|
+
preparingUntil = Date.now() + CONVERSATION_MS.prepare;
|
|
46210
|
+
}
|
|
46211
|
+
}
|
|
46212
|
+
if (ended || !response) return done;
|
|
46002
46213
|
const thread = obj2(response.thread);
|
|
46003
46214
|
for (const turn2 of list2(thread.turns)) historicalTurns.add(str2(turn2.id));
|
|
46004
46215
|
threadId = str2(thread.id);
|
|
46005
46216
|
if (!threadId) throw Error("Codex did not return a thread id.");
|
|
46217
|
+
if (mode === "resume" && threadId !== params.threadId) throw Error("Codex did not return the requested session.");
|
|
46006
46218
|
work.root(threadId, list2(response.retainedThreads).map((t) => str2(t.id)));
|
|
46007
46219
|
for (const terminal of list2(response.retainedTerminals)) retained.set(`terminal:${str2(terminal.threadId)}:${str2(terminal.itemId)}`, str2(terminal.processId));
|
|
46008
46220
|
provider = str2(thread.modelProvider) || void 0;
|
|
@@ -46024,6 +46236,7 @@ var list2;
|
|
|
46024
46236
|
var init_codex = __esm({
|
|
46025
46237
|
"src/lib/agent/wire/codex.ts"() {
|
|
46026
46238
|
"use strict";
|
|
46239
|
+
init_idle();
|
|
46027
46240
|
init_failures();
|
|
46028
46241
|
init_conversation();
|
|
46029
46242
|
init_codex_background();
|
|
@@ -52160,7 +52373,10 @@ async function openResume(id2, options) {
|
|
|
52160
52373
|
if (pending) {
|
|
52161
52374
|
const root2 = prev.agentPid ? { pid: prev.agentPid, since: prev.agentStartedAt ?? prev.startedAt, identity: prev.agentIdentity } : void 0;
|
|
52162
52375
|
const stopped2 = prev.managedProcess ? connectionStopped(root2) : processesStopped(runMark(prev.sessionId, prev.agentStartedAt), root2);
|
|
52163
|
-
|
|
52376
|
+
const session2 = resumeSessionId(prev);
|
|
52377
|
+
if (!stopped2 || !session2 || prev.managedProcess && pending.failure.code === "idle_timeout" && !idleStopConfirmed(prev.cleanup, session2)) {
|
|
52378
|
+
return retryRefusal(prev, "unsafe");
|
|
52379
|
+
}
|
|
52164
52380
|
await new Promise((resolve2) => setTimeout(resolve2, Math.max(0, pending.at - Date.now())));
|
|
52165
52381
|
if (!await executionHeld(executionOf())) return retryRefusal(prev, "authorization");
|
|
52166
52382
|
}
|
|
@@ -52540,6 +52756,7 @@ var INDEX_ACTIONS, SINGLETON_ACTIONS, VERB, SINGLETON_BUSY, RUN_STATUS, specPath
|
|
|
52540
52756
|
var init_sessions = __esm({
|
|
52541
52757
|
"src/lib/agent/sessions.ts"() {
|
|
52542
52758
|
"use strict";
|
|
52759
|
+
init_codex_background_types();
|
|
52543
52760
|
init_connection_process();
|
|
52544
52761
|
init_retry();
|
|
52545
52762
|
init_execution();
|
|
@@ -52838,8 +53055,8 @@ var init_inbox = __esm({
|
|
|
52838
53055
|
META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
|
|
52839
53056
|
slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
|
|
52840
53057
|
fileName = (title, slug = "") => `${slugOf(slug) || slugOf(title) || "item"}.md`;
|
|
52841
|
-
readArchived = () => readFolder(
|
|
52842
|
-
readAllDismissed = () => readFolder(
|
|
53058
|
+
readArchived = (dir = SIGNALS_ARCHIVED) => readFolder(dir);
|
|
53059
|
+
readAllDismissed = (dir = SIGNALS_DISMISSED) => readFolder(dir, true);
|
|
52843
53060
|
}
|
|
52844
53061
|
});
|
|
52845
53062
|
|
|
@@ -55472,7 +55689,7 @@ function cmdValidate(id2) {
|
|
|
55472
55689
|
const reason = errors.length ? formatContractErrors(errors) : void 0;
|
|
55473
55690
|
const session = insideRun();
|
|
55474
55691
|
if (session) patch(session, (run3) => {
|
|
55475
|
-
run3.validationFailure = reason ? { code: "validation_failed", level: 1, reason } : void 0;
|
|
55692
|
+
run3.validationFailure = reason ? { code: "validation_failed", level: 1, source: "validation", reason } : void 0;
|
|
55476
55693
|
});
|
|
55477
55694
|
if (reason) die(reason, { kind: "spec-contract", errors });
|
|
55478
55695
|
say(`Spec format valid (${cards.length} card${cards.length === 1 ? "" : "s"}).`);
|
|
@@ -61502,7 +61719,7 @@ var init_reply_log = __esm({
|
|
|
61502
61719
|
});
|
|
61503
61720
|
|
|
61504
61721
|
// src/commands/task-chat.ts
|
|
61505
|
-
import { setTimeout as
|
|
61722
|
+
import { setTimeout as delay2 } from "node:timers/promises";
|
|
61506
61723
|
function validateChatOptions(message, opts) {
|
|
61507
61724
|
if (opts.limit !== void 0 && opts.all || message.length && (opts.limit !== void 0 || opts.all || opts.follow || opts.stop) || opts.stop && (opts.limit !== void 0 || opts.all || opts.follow)) {
|
|
61508
61725
|
throw new BoardError("Use a message, history options [--limit <n> | --all] [--follow], or --stop separately.", { kind: "bad-args" });
|
|
@@ -61638,7 +61855,7 @@ async function taskChatFollow(id2, opts) {
|
|
|
61638
61855
|
if (!active2(reply)) {
|
|
61639
61856
|
break;
|
|
61640
61857
|
}
|
|
61641
|
-
await
|
|
61858
|
+
await delay2(1e3, void 0, { signal: controller.signal });
|
|
61642
61859
|
}
|
|
61643
61860
|
} else {
|
|
61644
61861
|
body = first.chat.messages.at(-1)?.role === "agent" ? first.chat.messages.at(-1).body : null;
|
|
@@ -61736,7 +61953,7 @@ var init_describe_project = __esm({
|
|
|
61736
61953
|
var discuss_goal_default;
|
|
61737
61954
|
var init_discuss_goal = __esm({
|
|
61738
61955
|
"src/guide/discuss-goal.md"() {
|
|
61739
|
-
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 with a title, outcome (at most 150 words), and verifiable `## Done when` criteria. 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. Its Preview IDs name outputs, not agents.\n- **Review**: before saving a Goal, choose the human review points and save them with the Goal using `--review-file <json>` (`{id,
|
|
61956
|
+
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 with a title, outcome (at most 150 words), and verifiable `## Done when` criteria. 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. Its Preview IDs name outputs, not agents.\n- **Review**: before saving a Goal, choose the human review points and save them with the Goal using `--review-file <json>` (`{id,after?,previews?}`). Use the Studio\u2019s Preview IDs, stable node IDs and `after` for dependencies. Require approval only where downstream work needs it.\n- **Review state**: save `[]` when no extra review is needed and `null` only while a decision is missing. Keep the saved arrangement when editing other details.\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; starting accepts its arrangement, never skips its review gates. Changing the arrangement after starting requires plan confirmation.\n- **Communication**: the remote user sees tasks and previews. Use plain words and button labels, omitting internal paths, commands and tools.\n";
|
|
61740
61957
|
}
|
|
61741
61958
|
});
|
|
61742
61959
|
|
|
@@ -62588,7 +62805,8 @@ var init_memory_review = __esm({
|
|
|
62588
62805
|
import fs77 from "node:fs";
|
|
62589
62806
|
import path78 from "node:path";
|
|
62590
62807
|
function rejectionsToReview() {
|
|
62591
|
-
const
|
|
62808
|
+
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
62809
|
+
const dir = path78.join(scratch ? path78.join(scratch, ".archive") : ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
62592
62810
|
if (!fs77.existsSync(dir)) return [];
|
|
62593
62811
|
const found2 = [];
|
|
62594
62812
|
for (const file2 of walkMd(dir)) {
|
|
@@ -62605,7 +62823,7 @@ function rejectionsToReview() {
|
|
|
62605
62823
|
return found2.sort((a, b) => a.rejectedAt.localeCompare(b.rejectedAt) || a.id - b.id);
|
|
62606
62824
|
}
|
|
62607
62825
|
function dismissalsToReview() {
|
|
62608
|
-
return
|
|
62826
|
+
return reviewDismissed().filter((s) => s.dismissedBy === "user" && s.dismissedReason.trim()).sort((a, b) => a.dismissedAt.localeCompare(b.dismissedAt)).map((s) => ({
|
|
62609
62827
|
sourceId: s.sourceId,
|
|
62610
62828
|
title: s.title,
|
|
62611
62829
|
file: s.relPath,
|
|
@@ -62631,11 +62849,12 @@ function withdrawnSources() {
|
|
|
62631
62849
|
}
|
|
62632
62850
|
}))];
|
|
62633
62851
|
if (cited.length === 0) return [];
|
|
62634
|
-
const
|
|
62635
|
-
const
|
|
62852
|
+
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
62853
|
+
const dismissed = new Set(reviewDismissed().map((s) => s.sourceId));
|
|
62854
|
+
const restored = new Set([...readInbox(), ...readArchived(scratch ? path78.join(scratch, "triage", "archived") : void 0)].map((s) => s.sourceId));
|
|
62636
62855
|
return cited.filter((id2) => restored.has(id2) && !dismissed.has(id2));
|
|
62637
62856
|
}
|
|
62638
|
-
var SOURCES;
|
|
62857
|
+
var reviewDismissed, SOURCES;
|
|
62639
62858
|
var init_dismissal_review = __esm({
|
|
62640
62859
|
"src/lib/agent/dismissal-review.ts"() {
|
|
62641
62860
|
"use strict";
|
|
@@ -62645,6 +62864,10 @@ var init_dismissal_review = __esm({
|
|
|
62645
62864
|
init_paths();
|
|
62646
62865
|
init_inbox();
|
|
62647
62866
|
init_archive();
|
|
62867
|
+
reviewDismissed = () => {
|
|
62868
|
+
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
62869
|
+
return readAllDismissed(scratch ? path78.join(scratch, "triage", "dismissed") : void 0);
|
|
62870
|
+
};
|
|
62648
62871
|
SOURCES = /\(([^()]+)\)\s*$/;
|
|
62649
62872
|
}
|
|
62650
62873
|
});
|
|
@@ -63405,72 +63628,6 @@ var init_propose = __esm({
|
|
|
63405
63628
|
}
|
|
63406
63629
|
});
|
|
63407
63630
|
|
|
63408
|
-
// src/lib/agent/idle.ts
|
|
63409
|
-
function createIdleWatchdog(expired, busy = () => false, milliseconds = IDLE_TIMEOUT.milliseconds, now = Date.now) {
|
|
63410
|
-
const calls = /* @__PURE__ */ new Set();
|
|
63411
|
-
const local = /* @__PURE__ */ new Set();
|
|
63412
|
-
const seen = /* @__PURE__ */ new Map();
|
|
63413
|
-
let last = now();
|
|
63414
|
-
let working = false;
|
|
63415
|
-
let closed2 = false;
|
|
63416
|
-
const touch = () => {
|
|
63417
|
-
if (!closed2) last = now();
|
|
63418
|
-
};
|
|
63419
|
-
const check2 = () => {
|
|
63420
|
-
if (closed2) return;
|
|
63421
|
-
const active3 = calls.size > 0 || busy();
|
|
63422
|
-
if (active3 || working) last = now();
|
|
63423
|
-
working = active3;
|
|
63424
|
-
if (!active3 && now() - last >= milliseconds) {
|
|
63425
|
-
close();
|
|
63426
|
-
expired();
|
|
63427
|
-
}
|
|
63428
|
-
};
|
|
63429
|
-
const timer = setInterval(check2, Math.min(1e3, milliseconds));
|
|
63430
|
-
timer.unref?.();
|
|
63431
|
-
const close = () => {
|
|
63432
|
-
closed2 = true;
|
|
63433
|
-
clearInterval(timer);
|
|
63434
|
-
calls.clear();
|
|
63435
|
-
local.clear();
|
|
63436
|
-
seen.clear();
|
|
63437
|
-
};
|
|
63438
|
-
return {
|
|
63439
|
-
touch,
|
|
63440
|
-
check: check2,
|
|
63441
|
-
close,
|
|
63442
|
-
event(e) {
|
|
63443
|
-
if (closed2 || e.kind === "log" || e.kind === "context") return;
|
|
63444
|
-
if (e.kind === "phase" && !e.data.contentAt) return;
|
|
63445
|
-
const key = e.kind === "tool_call" || e.kind === "tool_call_update" ? `${e.kind}:${e.data.toolCallId}` : e.kind;
|
|
63446
|
-
const value = JSON.stringify(e.data);
|
|
63447
|
-
if (seen.get(key) === value) return;
|
|
63448
|
-
seen.set(key, value);
|
|
63449
|
-
if (e.kind === "tool_call" && (e.data.kind === "execute" || e.data.subagent)) local.add(e.data.toolCallId);
|
|
63450
|
-
if (e.kind === "tool_call" || e.kind === "tool_call_update") {
|
|
63451
|
-
const { toolCallId, status } = e.data;
|
|
63452
|
-
if (local.has(toolCallId) && ["in_progress", "running"].includes(status)) calls.add(toolCallId);
|
|
63453
|
-
if (["completed", "failed"].includes(status)) {
|
|
63454
|
-
calls.delete(toolCallId);
|
|
63455
|
-
local.delete(toolCallId);
|
|
63456
|
-
}
|
|
63457
|
-
}
|
|
63458
|
-
touch();
|
|
63459
|
-
check2();
|
|
63460
|
-
}
|
|
63461
|
-
};
|
|
63462
|
-
}
|
|
63463
|
-
var IDLE_MS, IDLE_TIMEOUT, IDLE_ERROR, IDLE_FAILURE;
|
|
63464
|
-
var init_idle = __esm({
|
|
63465
|
-
"src/lib/agent/idle.ts"() {
|
|
63466
|
-
"use strict";
|
|
63467
|
-
IDLE_MS = 5 * 6e4;
|
|
63468
|
-
IDLE_TIMEOUT = { milliseconds: IDLE_MS };
|
|
63469
|
-
IDLE_ERROR = "No response for 5 minutes (idle timeout).";
|
|
63470
|
-
IDLE_FAILURE = { code: "idle_timeout", level: 2, reason: IDLE_ERROR };
|
|
63471
|
-
}
|
|
63472
|
-
});
|
|
63473
|
-
|
|
63474
63631
|
// src/lib/agent/watch.ts
|
|
63475
63632
|
var watch_exports = {};
|
|
63476
63633
|
__export(watch_exports, {
|
|
@@ -63478,7 +63635,7 @@ __export(watch_exports, {
|
|
|
63478
63635
|
});
|
|
63479
63636
|
import { spawn as spawn3 } from "node:child_process";
|
|
63480
63637
|
import fs79 from "node:fs";
|
|
63481
|
-
async function watchRun(sessionId, resume = startResume) {
|
|
63638
|
+
async function watchRun(sessionId, resume = startResume, retryBackoff = backoffMs) {
|
|
63482
63639
|
const spec = readSpec(sessionId);
|
|
63483
63640
|
const run3 = peekRun(sessionId);
|
|
63484
63641
|
if (!run3 || !spec) {
|
|
@@ -63548,7 +63705,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63548
63705
|
const basePrompt = record2.resumedFrom ? spec.prompt || resumePrompt(record2.deliveryId, record2.action) : spec.prompt;
|
|
63549
63706
|
const recoveryPrompt = record2.harness === "antigravity" && record2.resumedFrom ? "First verify existing progress and operation results. Preserve user decisions and completed work; do not repeat completed operations. Check actual state before continuing any operation whose result is uncertain." : "";
|
|
63550
63707
|
const boundary = process.env.AI4KANBAN_TASK_REVIEW ? reviewBoundary(JSON.parse(process.env.AI4KANBAN_TASK_REVIEW), process.env.AI4KANBAN_REVIEW_STAGES ? JSON.parse(process.env.AI4KANBAN_REVIEW_STAGES) : void 0) : "";
|
|
63551
|
-
const prompt = [record2.retry ? `Previous execution failed: ${record2.retry.reason}. Check existing results before continuing; do not repeat completed operations.` : "", conflictPrompt(KANBAN), boundary, basePrompt, recoveryPrompt, discardedCardsPrompt(record2.discardedCards)].filter(Boolean).join("\n\n");
|
|
63708
|
+
const prompt = [process.env.AI4KANBAN_SYNC_DIAGNOSTIC ? syncRepairPrompt(process.env.AI4KANBAN_SYNC_DIAGNOSTIC) : "", record2.retry ? `Previous execution failed: ${record2.retry.reason}. Check existing results before continuing; do not repeat completed operations.` : "", conflictPrompt(KANBAN), boundary, basePrompt, recoveryPrompt, discardedCardsPrompt(record2.discardedCards)].filter(Boolean).join("\n\n");
|
|
63552
63709
|
const before = markBoard();
|
|
63553
63710
|
const takes = active3.images;
|
|
63554
63711
|
active3.renderer?.setRequiredImages?.(record2.pictures ?? []);
|
|
@@ -63716,6 +63873,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63716
63873
|
let done = false;
|
|
63717
63874
|
let spoken;
|
|
63718
63875
|
let silent = false;
|
|
63876
|
+
let uncertainAtIdle = false;
|
|
63719
63877
|
let watchdog;
|
|
63720
63878
|
let wakeUp;
|
|
63721
63879
|
const sleep4 = (ms) => new Promise((wake) => {
|
|
@@ -63768,9 +63926,9 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63768
63926
|
let retrying = false;
|
|
63769
63927
|
if (failure2 && !sub && !taskCompleted) {
|
|
63770
63928
|
const attempt2 = held4.retry?.attempt ?? 1;
|
|
63771
|
-
const decision = planRetry(failure2, attempt2);
|
|
63929
|
+
const decision = planRetry(failure2, attempt2, Date.now(), retryBackoff);
|
|
63772
63930
|
if ("pause" in decision) retryPause = decision.pause;
|
|
63773
|
-
else if (blocker || pendingOperations.size || !structured || !resumeSessionId(held4) || spoken?.cleanup?.status === "unconfirmed" || client?.managedProcess && silent) retryPause = "unsafe";
|
|
63931
|
+
else if (blocker || pendingOperations.size || !structured || !resumeSessionId(held4) || spoken?.cleanup?.status === "unconfirmed" || client?.managedProcess && silent && (uncertainAtIdle || !idleStopConfirmed(spoken?.cleanup, resumeSessionId(held4)))) retryPause = "unsafe";
|
|
63774
63932
|
else {
|
|
63775
63933
|
const mark = runMark(sessionId, agentStartedAt);
|
|
63776
63934
|
const root2 = child.pid ? { pid: child.pid, since: agentStartedAt, identity: held4.agentIdentity } : void 0;
|
|
@@ -63795,7 +63953,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63795
63953
|
}
|
|
63796
63954
|
asked ||= stoppedByUser();
|
|
63797
63955
|
retrying &&= !asked;
|
|
63798
|
-
const error62 = asked ? void 0 : joinNotes(said2 ?? failure2?.reason, retryPause ? pauseLine(retryPause) : void 0);
|
|
63956
|
+
const error62 = asked ? void 0 : joinNotes(said2 ?? failure2?.reason, retryPause && failure2?.source !== "invariant" ? pauseLine(retryPause) : void 0);
|
|
63799
63957
|
const status = asked ? "stopped" : failed2 || code !== 0 ? "error" : "done";
|
|
63800
63958
|
const reported = spoken ? spoken.costUsd : renderer?.costUsd?.();
|
|
63801
63959
|
const totals = reportsSessionTotal(record2.harness);
|
|
@@ -63844,7 +64002,7 @@ ${result}
|
|
|
63844
64002
|
errorWhy,
|
|
63845
64003
|
endedAt
|
|
63846
64004
|
});
|
|
63847
|
-
|
|
64005
|
+
finishWatch(status === "done" ? 0 : 1);
|
|
63848
64006
|
return;
|
|
63849
64007
|
}
|
|
63850
64008
|
await closeRun(sessionId, {
|
|
@@ -63875,7 +64033,7 @@ ${result}
|
|
|
63875
64033
|
}
|
|
63876
64034
|
if (status === "done") queueCompleted(before.keys());
|
|
63877
64035
|
if (status === "done") await followUp(sessionId, record2.flowId, settled?.runs ?? []);
|
|
63878
|
-
|
|
64036
|
+
finishWatch(status === "done" ? 0 : 1);
|
|
63879
64037
|
};
|
|
63880
64038
|
let ending = false;
|
|
63881
64039
|
const endChild = () => {
|
|
@@ -63895,6 +64053,7 @@ ${result}
|
|
|
63895
64053
|
const giveUp = (asked) => {
|
|
63896
64054
|
endChild();
|
|
63897
64055
|
after(STOP_GRACE_MS + STOP_CLOSE_MS, () => {
|
|
64056
|
+
if (done) return;
|
|
63898
64057
|
after(STOP_FINISH_MS, () => process.exit(0));
|
|
63899
64058
|
void finish(null, asked).finally(() => process.exit(0));
|
|
63900
64059
|
});
|
|
@@ -63904,6 +64063,7 @@ ${result}
|
|
|
63904
64063
|
giveUp(false);
|
|
63905
64064
|
};
|
|
63906
64065
|
const cancellation = new AbortController();
|
|
64066
|
+
const idle = new AbortController();
|
|
63907
64067
|
let stopped2 = false;
|
|
63908
64068
|
const stoppedByUser = () => stopped2 || peekRun(sessionId)?.stopping === true;
|
|
63909
64069
|
const askToStop = () => {
|
|
@@ -63917,6 +64077,11 @@ ${result}
|
|
|
63917
64077
|
if (done) return;
|
|
63918
64078
|
giveUp(true);
|
|
63919
64079
|
};
|
|
64080
|
+
const finishWatch = (code) => {
|
|
64081
|
+
process.off("SIGTERM", askToStop);
|
|
64082
|
+
process.off("SIGINT", askToStop);
|
|
64083
|
+
resolve2(code);
|
|
64084
|
+
};
|
|
63920
64085
|
process.on("SIGTERM", askToStop);
|
|
63921
64086
|
process.on("SIGINT", askToStop);
|
|
63922
64087
|
watchdog = createIdleWatchdog(() => {
|
|
@@ -63925,7 +64090,15 @@ ${result}
|
|
|
63925
64090
|
log.write(`
|
|
63926
64091
|
[board] ${silenceSaid(silenceFor)}
|
|
63927
64092
|
`);
|
|
63928
|
-
|
|
64093
|
+
if (!client?.idleRecovery) {
|
|
64094
|
+
giveUp(false);
|
|
64095
|
+
return;
|
|
64096
|
+
}
|
|
64097
|
+
uncertainAtIdle = pendingOperations.size > 0;
|
|
64098
|
+
patch(sessionId, (run4) => {
|
|
64099
|
+
run4.cleanup = { status: "unconfirmed", execution: sessionId, kept: [] };
|
|
64100
|
+
});
|
|
64101
|
+
idle.abort();
|
|
63929
64102
|
}, () => !!(client?.background?.() ?? renderer?.background?.()) || liveSubRuns(sessionId).length > 0);
|
|
63930
64103
|
touch = watchdog.touch;
|
|
63931
64104
|
observeActivity = watchdog.event;
|
|
@@ -63953,12 +64126,13 @@ ${result}
|
|
|
63953
64126
|
gotContext,
|
|
63954
64127
|
completed,
|
|
63955
64128
|
activity: touch,
|
|
63956
|
-
signal: cancellation.signal
|
|
64129
|
+
signal: cancellation.signal,
|
|
64130
|
+
idleSignal: idle.signal
|
|
63957
64131
|
}).then((end2) => {
|
|
63958
64132
|
if (done) return;
|
|
63959
64133
|
spoken = end2;
|
|
63960
64134
|
if (end2.cleanup) patch(sessionId, (r) => {
|
|
63961
|
-
r.cleanup = end2.cleanup;
|
|
64135
|
+
r.cleanup = uncertainAtIdle || silent && pendingOperations.size ? { ...end2.cleanup, status: "unconfirmed" } : end2.cleanup;
|
|
63962
64136
|
});
|
|
63963
64137
|
endChild();
|
|
63964
64138
|
void finish(end2.ok ? 0 : 1, peekRun(sessionId)?.stopping === true || stopped2);
|
|
@@ -64032,6 +64206,7 @@ var init_watch = __esm({
|
|
|
64032
64206
|
init_prompts();
|
|
64033
64207
|
init_resolve();
|
|
64034
64208
|
init_idle();
|
|
64209
|
+
init_codex_background_types();
|
|
64035
64210
|
init_retry();
|
|
64036
64211
|
init_failures();
|
|
64037
64212
|
init_execution();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wildcrane",
|
|
3
|
-
"version": "0.11.
|
|
4
|
-
"akbContract":
|
|
3
|
+
"version": "0.11.74",
|
|
4
|
+
"akbContract": 21,
|
|
5
5
|
"description": "WildCrane's `akb` command — scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"kanban",
|