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