wildcrane 0.11.72 → 0.11.73
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 +340 -241
- 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.73 — 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)
|
|
@@ -41366,6 +41366,63 @@ var init_connection_process = __esm({
|
|
|
41366
41366
|
}
|
|
41367
41367
|
});
|
|
41368
41368
|
|
|
41369
|
+
// src/lib/agent/retry.ts
|
|
41370
|
+
function backoffMs(attempt2, random = Math.random) {
|
|
41371
|
+
const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt2 - 2));
|
|
41372
|
+
return Math.round(step * (1 - 0.25 * random()));
|
|
41373
|
+
}
|
|
41374
|
+
function planRetry(failure2, attempt2, now = Date.now(), backoff = backoffMs) {
|
|
41375
|
+
if (!Number.isSafeInteger(attempt2) || attempt2 < 1 || failure2.level === 3) return { pause: "needs-review" };
|
|
41376
|
+
const of = failure2.level === 1 ? 2 : 4;
|
|
41377
|
+
if (attempt2 >= of) return { pause: "limit" };
|
|
41378
|
+
const delay2 = failure2.retryAfterMs;
|
|
41379
|
+
const valid = delay2 !== void 0 && !Number.isNaN(delay2) && delay2 >= 0;
|
|
41380
|
+
const wait = valid ? delay2 : failure2.level === 1 ? 0 : backoff(attempt2 + 1);
|
|
41381
|
+
if (wait > CAP_MS) return { pause: "wait-too-long" };
|
|
41382
|
+
return { plan: { at: now + wait, of, failure: failure2 } };
|
|
41383
|
+
}
|
|
41384
|
+
function readFailure(raw) {
|
|
41385
|
+
if (!raw || typeof raw !== "object") return;
|
|
41386
|
+
const { code, level: level2, reason, retryAfterMs: retryAfterMs2 } = raw;
|
|
41387
|
+
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 } : {} };
|
|
41389
|
+
}
|
|
41390
|
+
function readRetryPlan(raw, attempt2) {
|
|
41391
|
+
if (!raw || typeof raw !== "object") return;
|
|
41392
|
+
const { at, of, failure: rawFailure } = raw;
|
|
41393
|
+
const failure2 = readFailure(rawFailure);
|
|
41394
|
+
if (!failure2 || typeof at !== "number" || !Number.isFinite(at)) return;
|
|
41395
|
+
const decision = planRetry(failure2, attempt2);
|
|
41396
|
+
if ("plan" in decision && of === decision.plan.of) return { at, of, failure: failure2 };
|
|
41397
|
+
}
|
|
41398
|
+
function pauseLine(pause2, zh = translating()) {
|
|
41399
|
+
switch (pause2) {
|
|
41400
|
+
case "needs-review":
|
|
41401
|
+
return zh ? "\u5DF2\u6682\u505C\uFF0C\u8BF7\u68C0\u67E5\u5931\u8D25\u539F\u56E0\u540E\u7EED\u8DD1\u3002" : "Paused. Review the failure before resuming.";
|
|
41402
|
+
case "limit":
|
|
41403
|
+
return zh ? "\u5DF2\u8FBE\u5230\u81EA\u52A8\u91CD\u8BD5\u6B21\u6570\u4E0A\u9650\u3002" : "The automatic retry limit was reached.";
|
|
41404
|
+
case "wait-too-long":
|
|
41405
|
+
return zh ? "\u6240\u9700\u7B49\u5F85\u65F6\u95F4\u8D85\u8FC7\u4E24\u5206\u949F\uFF0C\u5DF2\u6682\u505C\u3002" : "Paused because the required wait exceeds two minutes.";
|
|
41406
|
+
case "unsafe":
|
|
41407
|
+
return zh ? "\u65E0\u6CD5\u786E\u8BA4\u53EF\u4EE5\u5B89\u5168\u7EED\u8DD1\uFF0C\u8BF7\u5148\u6838\u5BF9\u5DF2\u6709\u8FDB\u5EA6\u548C\u64CD\u4F5C\u7ED3\u679C\u3002" : "Check saved progress and operation results before resuming safely.";
|
|
41408
|
+
case "authorization":
|
|
41409
|
+
return zh ? "\u65E0\u6CD5\u786E\u8BA4\u7EED\u8DD1\u6388\u6743\uFF0C\u5DF2\u6682\u505C\u3002" : "Paused because authorization to resume could not be confirmed.";
|
|
41410
|
+
}
|
|
41411
|
+
}
|
|
41412
|
+
function retryLine(plan, attempt2, now = Date.now()) {
|
|
41413
|
+
const seconds = Math.max(0, Math.ceil((plan.at - now) / 1e3));
|
|
41414
|
+
return `${plan.failure.reason} \u2014 retrying ${seconds ? `in ${seconds}s` : "now"} (attempt ${attempt2 + 1} of ${plan.of}).`;
|
|
41415
|
+
}
|
|
41416
|
+
var BASE_MS, CAP_MS;
|
|
41417
|
+
var init_retry = __esm({
|
|
41418
|
+
"src/lib/agent/retry.ts"() {
|
|
41419
|
+
"use strict";
|
|
41420
|
+
init_language();
|
|
41421
|
+
BASE_MS = 15e3;
|
|
41422
|
+
CAP_MS = 12e4;
|
|
41423
|
+
}
|
|
41424
|
+
});
|
|
41425
|
+
|
|
41369
41426
|
// src/lib/cloud/execution.ts
|
|
41370
41427
|
function executionOf(value = process.env.AI4KANBAN_EXECUTION) {
|
|
41371
41428
|
try {
|
|
@@ -41683,8 +41740,8 @@ var init_package = __esm({
|
|
|
41683
41740
|
"package.json"() {
|
|
41684
41741
|
package_default = {
|
|
41685
41742
|
name: "wildcrane",
|
|
41686
|
-
version: "0.11.
|
|
41687
|
-
akbContract:
|
|
41743
|
+
version: "0.11.73",
|
|
41744
|
+
akbContract: 20,
|
|
41688
41745
|
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.",
|
|
41689
41746
|
keywords: [
|
|
41690
41747
|
"kanban",
|
|
@@ -42696,71 +42753,6 @@ var init_types3 = __esm({
|
|
|
42696
42753
|
}
|
|
42697
42754
|
});
|
|
42698
42755
|
|
|
42699
|
-
// src/lib/agent/harnesses/transient.ts
|
|
42700
|
-
function reasonLine(text5, rule) {
|
|
42701
|
-
const line = text5.split("\n").find((l) => rule.test(l.toLowerCase())) ?? text5;
|
|
42702
|
-
const said2 = line.trim().replace(/\s+/g, " ");
|
|
42703
|
-
return said2.length > REASON_MAX ? `${said2.slice(0, REASON_MAX - 1)}\u2026` : said2;
|
|
42704
|
-
}
|
|
42705
|
-
function manualFailure(text5) {
|
|
42706
|
-
return MANUAL.some((rule) => rule.test(text5.toLowerCase()));
|
|
42707
|
-
}
|
|
42708
|
-
function providerBlip(...said2) {
|
|
42709
|
-
for (const text5 of said2) {
|
|
42710
|
-
if (!text5?.trim()) continue;
|
|
42711
|
-
const lower = text5.toLowerCase();
|
|
42712
|
-
if (manualFailure(text5)) return void 0;
|
|
42713
|
-
const limited2 = /\b429\b|rate[ _-]?limit/.test(lower);
|
|
42714
|
-
const hit = limited2 && RETRY_AFTER.test(text5) ? RETRY_AFTER : limited2 ? void 0 : PASSING.find((rule) => rule.test(lower));
|
|
42715
|
-
if (!hit) continue;
|
|
42716
|
-
const asked = RETRY_AFTER.exec(text5);
|
|
42717
|
-
const seconds = asked ? Number(asked[1]) : NaN;
|
|
42718
|
-
return {
|
|
42719
|
-
reason: reasonLine(text5, hit),
|
|
42720
|
-
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
42721
|
-
};
|
|
42722
|
-
}
|
|
42723
|
-
return void 0;
|
|
42724
|
-
}
|
|
42725
|
-
function recoveryFailure(text5) {
|
|
42726
|
-
const temporary = providerBlip(text5);
|
|
42727
|
-
if (temporary) return { ...temporary, handler: "execution" };
|
|
42728
|
-
if (!manualFailure(text5) && /(?:verification|validation|test|compilation|build) failed|syntax error|type error/i.test(text5)) {
|
|
42729
|
-
return { reason: text5, handler: "agent", retryAfterMs: 0 };
|
|
42730
|
-
}
|
|
42731
|
-
return void 0;
|
|
42732
|
-
}
|
|
42733
|
-
var MANUAL, PASSING, RETRY_AFTER, REASON_MAX;
|
|
42734
|
-
var init_transient = __esm({
|
|
42735
|
-
"src/lib/agent/harnesses/transient.ts"() {
|
|
42736
|
-
"use strict";
|
|
42737
|
-
MANUAL = [
|
|
42738
|
-
/\b(401|403)\b/,
|
|
42739
|
-
/unauthorized|forbidden|permission (?:denied|required|check failed)|permission_denied|soft.denied|auto-denied|权限拒绝/,
|
|
42740
|
-
/authenticat|invalid api key|api[_ ]key|not (?:logged|signed) in|please (?:log|sign) in|\/login|oauth/,
|
|
42741
|
-
/usage limit|quota|balance|credits?|insufficient|out of tokens|resource[ _-]?exhausted/,
|
|
42742
|
-
/cancell?ed|aborted by|interrupted by the user/,
|
|
42743
|
-
/maximum budget|max(imum)? turns|exceeded the budget/,
|
|
42744
|
-
/model not found|unknown model|invalid model|model (?:is )?unavailable|model[^\n]+ is (?:unavailable|not recognized)|unsupported|invalid[_ ]request/
|
|
42745
|
-
];
|
|
42746
|
-
PASSING = [
|
|
42747
|
-
// 502/503/529 are distinctive enough to read as a status wherever they appear. A bare
|
|
42748
|
-
// 500 is not — a failure line counting something would match it — so it is left to the
|
|
42749
|
-
// words below, which is how that status is actually written out.
|
|
42750
|
-
/\b(502|503|529)\b/,
|
|
42751
|
-
/at capacity|overloaded|service unavailable|bad gateway|internal server error|server_error/,
|
|
42752
|
-
/connection (lost|dropped|reset|error|closed)|socket hang up|stream (error|disconnected)/,
|
|
42753
|
-
/econnreset|econnrefused|etimedout|enetunreach|enotfound|eai_again/,
|
|
42754
|
-
/fetch failed|request timed out|network (?:error|failure)|temporary network failure/,
|
|
42755
|
-
/(?:initialize|connection|connect|response)[^\n]*timed out|idle[_ -]?timeout|stream[^\n]*timed out|no (?:response|events?) for 5 minutes/,
|
|
42756
|
-
/request failed:[^\n]*\b(?:unexpected )?eof\b/,
|
|
42757
|
-
/rpc error: code = (?:unavailable|deadlineexceeded)\b|deadline_exceeded|dial tcp[^\n]*(?:timeout|refused|no such host)/
|
|
42758
|
-
];
|
|
42759
|
-
RETRY_AFTER = /retry[-_\s]?after["':=\s]+(\d+)/i;
|
|
42760
|
-
REASON_MAX = 140;
|
|
42761
|
-
}
|
|
42762
|
-
});
|
|
42763
|
-
|
|
42764
42756
|
// src/lib/agent/prices.ts
|
|
42765
42757
|
function antigravityPrices(at) {
|
|
42766
42758
|
const pro = at < Date.parse("2026-12-01T00:00:00Z") ? 2 : 4;
|
|
@@ -43083,7 +43075,7 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
|
43083
43075
|
let partial2 = "";
|
|
43084
43076
|
let final;
|
|
43085
43077
|
let failure2;
|
|
43086
|
-
let
|
|
43078
|
+
let classified;
|
|
43087
43079
|
let imageFailure;
|
|
43088
43080
|
let requiredImages = [];
|
|
43089
43081
|
const readImages = /* @__PURE__ */ new Set();
|
|
@@ -43115,24 +43107,22 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
|
43115
43107
|
const calls = /* @__PURE__ */ new Set();
|
|
43116
43108
|
const closed2 = /* @__PURE__ */ new Set();
|
|
43117
43109
|
const events = createEventCollector();
|
|
43118
|
-
const fail = (reason) => {
|
|
43119
|
-
if (limited(reason)) rateLimit = failureHint(reason);
|
|
43120
|
-
if (failure2 && manualFailure(failure2) && !(limited(failure2) && limited(reason))) return;
|
|
43110
|
+
const fail = (reason, code = "provider_failed") => {
|
|
43121
43111
|
failure2 = failureHint(reason);
|
|
43112
|
+
classified = { code, level: 3, reason: failure2 };
|
|
43122
43113
|
events.error(failure2);
|
|
43123
43114
|
};
|
|
43124
43115
|
const reader = createLineReader((line) => {
|
|
43125
43116
|
const e = frame(line);
|
|
43126
43117
|
if (!e) {
|
|
43127
43118
|
offStream = line.trim() || offStream;
|
|
43128
|
-
if (/^(?:error:|rpc error:)/i.test(line.trim()) && limited(line)) fail(line.trim());
|
|
43129
43119
|
return `${line}
|
|
43130
43120
|
`;
|
|
43131
43121
|
}
|
|
43132
43122
|
if (e.event === "init") {
|
|
43133
43123
|
const got = str2(e.conversation_id);
|
|
43134
43124
|
if (expectedSession && got !== expectedSession) {
|
|
43135
|
-
fail(translating() ? "Antigravity \u672A\u7EED\u63A5\u6307\u5B9A\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u539F\u4F1A\u8BDD\u540E\u91CD\u8BD5\u3002" : "Antigravity did not resume the requested conversation.");
|
|
43125
|
+
fail(translating() ? "Antigravity \u672A\u7EED\u63A5\u6307\u5B9A\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u539F\u4F1A\u8BDD\u540E\u91CD\u8BD5\u3002" : "Antigravity did not resume the requested conversation.", "session_mismatch");
|
|
43136
43126
|
return "";
|
|
43137
43127
|
}
|
|
43138
43128
|
session = got || session;
|
|
@@ -43179,7 +43169,6 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
|
43179
43169
|
}
|
|
43180
43170
|
const error62 = obj2(tool.error);
|
|
43181
43171
|
const reason = str2(error62.message) || str2(error62.type);
|
|
43182
|
-
if (reason && /permission|denied|soft.den/i.test(reason)) fail(reason);
|
|
43183
43172
|
if (["DONE", "ERROR", "CANCELED", "INTERRUPTED"].includes(str2(step.state)) && !closed2.has(id2)) {
|
|
43184
43173
|
closed2.add(id2);
|
|
43185
43174
|
const failed2 = !!reason || step.state !== "DONE";
|
|
@@ -43204,7 +43193,7 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43204
43193
|
if (e.event === "result") {
|
|
43205
43194
|
const result = obj2(e.result);
|
|
43206
43195
|
if (expectedSession && str2(result.conversation_id) && result.conversation_id !== expectedSession) {
|
|
43207
|
-
fail(translating() ? "Antigravity \u672A\u7EED\u63A5\u6307\u5B9A\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u539F\u4F1A\u8BDD\u540E\u91CD\u8BD5\u3002" : "Antigravity did not resume the requested conversation.");
|
|
43196
|
+
fail(translating() ? "Antigravity \u672A\u7EED\u63A5\u6307\u5B9A\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u539F\u4F1A\u8BDD\u540E\u91CD\u8BD5\u3002" : "Antigravity did not resume the requested conversation.", "session_mismatch");
|
|
43208
43197
|
terminal = true;
|
|
43209
43198
|
return "";
|
|
43210
43199
|
}
|
|
@@ -43220,8 +43209,8 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43220
43209
|
if (imageFailure) events.error(imageFailure);
|
|
43221
43210
|
readImages.clear();
|
|
43222
43211
|
imageErrors.clear();
|
|
43223
|
-
if (Array.isArray(result.denied_actions) && result.denied_actions.length) fail(translating() ? "Antigravity \u6743\u9650\u62D2\u7EDD\uFF0C\u8BF7\u68C0\u67E5\u6743\u9650\u89C4\u5219\u540E\u91CD\u8BD5\u3002" : "Antigravity permission denied. Check permission rules, then retry.");
|
|
43224
|
-
if (typeof result.response !== "string" || result.status !== "SUCCESS" || str2(result.error) || result.finished_reason && result.finished_reason !== "completed" && result.finished_reason !== "success") {
|
|
43212
|
+
if (Array.isArray(result.denied_actions) && result.denied_actions.length) fail(translating() ? "Antigravity \u6743\u9650\u62D2\u7EDD\uFF0C\u8BF7\u68C0\u67E5\u6743\u9650\u89C4\u5219\u540E\u91CD\u8BD5\u3002" : "Antigravity permission denied. Check permission rules, then retry.", "permission_denied");
|
|
43213
|
+
else if (!failure2 && (typeof result.response !== "string" || result.status !== "SUCCESS" || str2(result.error) || result.finished_reason && result.finished_reason !== "completed" && result.finished_reason !== "success")) {
|
|
43225
43214
|
fail(result.status === "CANCELED" ? `Antigravity: CANCELED${result.error ? `: ${str2(result.error)}` : ""}` : str2(result.error) || `Antigravity: ${str2(result.status) || "missing status"}`);
|
|
43226
43215
|
}
|
|
43227
43216
|
events.end();
|
|
@@ -43243,17 +43232,13 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43243
43232
|
if (!terminal) {
|
|
43244
43233
|
incomplete = true;
|
|
43245
43234
|
const diagnostics = [stderr.trim(), offStream?.match(/^(?:error:|rpc error:|API error\b)/i) ? offStream : void 0];
|
|
43246
|
-
|
|
43247
|
-
if (diagnostic) fail(diagnostic);
|
|
43248
|
-
if (!failure2) fail(translating() ? "Antigravity \u672A\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C\uFF0C\u8BF7\u68C0\u67E5\u65E5\u5FD7\u540E\u91CD\u8BD5\u3002" : "Antigravity returned no final result. Check the log, then retry.");
|
|
43235
|
+
if (!failure2) fail(diagnostics.find(Boolean) || (translating() ? "Antigravity \u672A\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C\uFF0C\u8BF7\u68C0\u67E5\u65E5\u5FD7\u540E\u91CD\u8BD5\u3002" : "Antigravity returned no final result. Check the log, then retry."), "result_missing");
|
|
43249
43236
|
}
|
|
43250
43237
|
events.end();
|
|
43251
43238
|
return text5;
|
|
43252
43239
|
},
|
|
43253
43240
|
stderr(chunk) {
|
|
43254
43241
|
stderr = (stderr + chunk).slice(-16e3);
|
|
43255
|
-
if (limited(stderr)) fail(stderr.trim());
|
|
43256
|
-
if (/soft.denied|auto-denied|permission (?:denied|required)|denied by.*(?:policy|rule)|requires? (?:user )?(?:approval|permission)/i.test(stderr)) fail(stderr.trim());
|
|
43257
43242
|
},
|
|
43258
43243
|
result: () => final || (failure2 ? partial2 || void 0 : final),
|
|
43259
43244
|
resumeId: () => session,
|
|
@@ -43263,17 +43248,16 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
43263
43248
|
costIncomplete: () => incomplete || void 0,
|
|
43264
43249
|
context: () => context,
|
|
43265
43250
|
failure: () => failure2 || imageFailure,
|
|
43266
|
-
|
|
43267
|
-
|
|
43251
|
+
terminalFailure: () => terminal && !!classified,
|
|
43252
|
+
executionFailure: () => classified ?? (imageFailure ? { code: "image_read_failed", level: 3, reason: imageFailure } : void 0),
|
|
43268
43253
|
events: events.events,
|
|
43269
43254
|
activity: events.activity
|
|
43270
43255
|
};
|
|
43271
43256
|
}
|
|
43272
|
-
var KINDS, zero, usageOf, add,
|
|
43257
|
+
var KINDS, zero, usageOf, add, imagePath;
|
|
43273
43258
|
var init_antigravity = __esm({
|
|
43274
43259
|
"src/lib/agent/wire/antigravity.ts"() {
|
|
43275
43260
|
"use strict";
|
|
43276
|
-
init_transient();
|
|
43277
43261
|
init_prices();
|
|
43278
43262
|
init_language();
|
|
43279
43263
|
init_events();
|
|
@@ -43301,7 +43285,6 @@ var init_antigravity = __esm({
|
|
|
43301
43285
|
return { input: num2(u.input_tokens), output: num2(u.output_tokens), cacheRead: num2(u.cache_read_tokens), cacheCreation: 0 };
|
|
43302
43286
|
};
|
|
43303
43287
|
add = (a, b) => ({ input: a.input + b.input, output: a.output + b.output, cacheRead: a.cacheRead + b.cacheRead, cacheCreation: 0 });
|
|
43304
|
-
limited = (reason) => /\b429\b|rate[ _-]?limit|resource[ _-]?exhausted|quota[^\n]*\b(?:exceeded|exhausted|depleted|reached)\b|(?:exceed|exhaust|deplet)[^\n]*quota|(?:insufficient|exhausted|out of|no remaining) (?:credits?|quota)|credits?[^\n]*(?:exhaust|deplet|exceed)/i.test(reason);
|
|
43305
43288
|
imagePath = (target) => /\.(?:png|jpe?g|gif|webp|bmp|tiff?|svg)$/i.test(target);
|
|
43306
43289
|
}
|
|
43307
43290
|
});
|
|
@@ -43343,7 +43326,6 @@ var init_antigravity2 = __esm({
|
|
|
43343
43326
|
init_spawnable();
|
|
43344
43327
|
init_models();
|
|
43345
43328
|
init_types3();
|
|
43346
|
-
init_transient();
|
|
43347
43329
|
init_language();
|
|
43348
43330
|
init_antigravity();
|
|
43349
43331
|
EFFORT_ID = /-(?:low|medium|high|xhigh|max)$/i;
|
|
@@ -43410,11 +43392,10 @@ ${rule}
|
|
|
43410
43392
|
`);
|
|
43411
43393
|
return { args: ["--add-dir", root2] };
|
|
43412
43394
|
},
|
|
43413
|
-
transient: ({ failure: failure2 }) => providerBlip(failure2),
|
|
43414
43395
|
reports: ["cost", "tokens", "model", "context"],
|
|
43415
43396
|
adoptsSessionId: false,
|
|
43416
43397
|
savesSessionAtOpen: true,
|
|
43417
|
-
stopsOnRateLimit:
|
|
43398
|
+
stopsOnRateLimit: false,
|
|
43418
43399
|
// `models` is read-only. Only explicit authentication errors mean signed out.
|
|
43419
43400
|
login: {
|
|
43420
43401
|
args: ["models"],
|
|
@@ -43513,6 +43494,72 @@ var init_check = __esm({
|
|
|
43513
43494
|
}
|
|
43514
43495
|
});
|
|
43515
43496
|
|
|
43497
|
+
// src/lib/agent/wire/failures.ts
|
|
43498
|
+
function executionFailure(error62) {
|
|
43499
|
+
if (error62 instanceof ExecutionError) return error62.failure;
|
|
43500
|
+
const code = str2(obj2(error62).code);
|
|
43501
|
+
const reason = error62 instanceof Error ? error62.message : String(error62);
|
|
43502
|
+
return {
|
|
43503
|
+
code: NETWORK.has(code) ? "connection_lost" : code === "ENOENT" ? "executable_missing" : "execution_failed",
|
|
43504
|
+
level: NETWORK.has(code) ? 2 : 3,
|
|
43505
|
+
reason
|
|
43506
|
+
};
|
|
43507
|
+
}
|
|
43508
|
+
function retryAfterMs(value, now = Date.now()) {
|
|
43509
|
+
if (typeof value !== "string") return;
|
|
43510
|
+
const header = value.trim();
|
|
43511
|
+
if (/^\d+$/.test(header)) return Math.min(Number(header) * 1e3, Number.MAX_SAFE_INTEGER);
|
|
43512
|
+
if (!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(header)) return;
|
|
43513
|
+
const date5 = Date.parse(header);
|
|
43514
|
+
if (Number.isFinite(date5)) return Math.max(0, date5 - now);
|
|
43515
|
+
}
|
|
43516
|
+
function providerFailure(error62, reason) {
|
|
43517
|
+
const info = obj2(error62);
|
|
43518
|
+
const status = typeof info.status === "number" ? info.status : void 0;
|
|
43519
|
+
const headers = obj2(info.headers);
|
|
43520
|
+
const wait = retryAfterMs(headers["retry-after"] ?? headers["Retry-After"]);
|
|
43521
|
+
const code = info.code ?? info.type;
|
|
43522
|
+
if (code === "session_not_found") return { code, level: 3, reason };
|
|
43523
|
+
if (status === 401 || status === 403 || ["authentication_error", "permission_error", "invalid_request_error"].includes(str2(code))) {
|
|
43524
|
+
return { code: "provider_refused", level: 3, reason };
|
|
43525
|
+
}
|
|
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 };
|
|
43530
|
+
}
|
|
43531
|
+
function codexFailure(raw, fallback) {
|
|
43532
|
+
const error62 = obj2(raw);
|
|
43533
|
+
const reason = str2(error62.message) || fallback;
|
|
43534
|
+
const info = error62.codexErrorInfo;
|
|
43535
|
+
if (info === "serverOverloaded") return providerFailure({ ...error62, type: "overloaded_error" }, reason);
|
|
43536
|
+
if (info === "rateLimitExceeded") return providerFailure({ ...error62, type: "rate_limit_error" }, reason);
|
|
43537
|
+
const types = obj2(info);
|
|
43538
|
+
for (const kind of ["httpConnectionFailed", "responseStreamConnectionFailed", "responseStreamDisconnected", "responseTooManyFailedAttempts"]) {
|
|
43539
|
+
if (!(kind in types)) continue;
|
|
43540
|
+
const status = obj2(types[kind]).httpStatusCode;
|
|
43541
|
+
if (typeof status === "number") return providerFailure({ ...error62, status }, reason);
|
|
43542
|
+
if (kind !== "responseTooManyFailedAttempts") return providerFailure({ ...error62, code: "ECONNRESET" }, reason);
|
|
43543
|
+
}
|
|
43544
|
+
return providerFailure(error62, reason);
|
|
43545
|
+
}
|
|
43546
|
+
var ExecutionError, NETWORK, TEMPORARY_HTTP;
|
|
43547
|
+
var init_failures = __esm({
|
|
43548
|
+
"src/lib/agent/wire/failures.ts"() {
|
|
43549
|
+
"use strict";
|
|
43550
|
+
init_json();
|
|
43551
|
+
ExecutionError = class extends Error {
|
|
43552
|
+
constructor(failure2) {
|
|
43553
|
+
super(failure2.reason);
|
|
43554
|
+
this.failure = failure2;
|
|
43555
|
+
}
|
|
43556
|
+
failure;
|
|
43557
|
+
};
|
|
43558
|
+
NETWORK = /* @__PURE__ */ new Set(["ECONNRESET", "ECONNREFUSED", "EPIPE", "ETIMEDOUT", "ENETUNREACH", "EAI_AGAIN", "UND_ERR_SOCKET"]);
|
|
43559
|
+
TEMPORARY_HTTP = /* @__PURE__ */ new Set([502, 503, 504, 529]);
|
|
43560
|
+
}
|
|
43561
|
+
});
|
|
43562
|
+
|
|
43516
43563
|
// src/lib/agent/wire/claude-stream.ts
|
|
43517
43564
|
function targetOf2(input2) {
|
|
43518
43565
|
const args2 = obj2(input2);
|
|
@@ -43572,7 +43619,8 @@ function createStreamRenderer() {
|
|
|
43572
43619
|
let context;
|
|
43573
43620
|
let limit;
|
|
43574
43621
|
let failure2;
|
|
43575
|
-
let
|
|
43622
|
+
let apiFailure;
|
|
43623
|
+
let classified;
|
|
43576
43624
|
let background;
|
|
43577
43625
|
const turns = [];
|
|
43578
43626
|
const backgrounded = /* @__PURE__ */ new Set();
|
|
@@ -43588,16 +43636,14 @@ function createStreamRenderer() {
|
|
|
43588
43636
|
const renderLine = (line) => {
|
|
43589
43637
|
if (!line.trim()) return "";
|
|
43590
43638
|
const ev = frame(line);
|
|
43591
|
-
if (!ev) {
|
|
43592
|
-
offStream = line.trim();
|
|
43593
|
-
return `${line}
|
|
43639
|
+
if (!ev) return `${line}
|
|
43594
43640
|
`;
|
|
43595
|
-
}
|
|
43596
43641
|
if (model === void 0) model = eventModel(ev);
|
|
43597
43642
|
if (str2(ev.parent_tool_use_id)) return "";
|
|
43598
43643
|
if (ev.type === "assistant" || ev.type === "stream_event" && obj2(ev.event).type === "content_block_delta") events.progress();
|
|
43599
43644
|
switch (ev.type) {
|
|
43600
43645
|
case "assistant": {
|
|
43646
|
+
apiFailure = typeof ev.error === "string" ? providerFailure({ type: ev.error }, "Claude could not complete the request.") : void 0;
|
|
43601
43647
|
const msg = ev.message;
|
|
43602
43648
|
const holding = promptSize(msg?.usage);
|
|
43603
43649
|
if (holding) context = { used: holding };
|
|
@@ -43650,6 +43696,8 @@ function createStreamRenderer() {
|
|
|
43650
43696
|
const turnUsage = usageOf2(ev.usage);
|
|
43651
43697
|
if (turnUsage) usage3 = usage3 ? addUsage(usage3, turnUsage) : turnUsage;
|
|
43652
43698
|
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;
|
|
43700
|
+
apiFailure = void 0;
|
|
43653
43701
|
if (failure2) events.error(failure2);
|
|
43654
43702
|
turns.push({
|
|
43655
43703
|
...typeof ev.result === "string" ? { result: ev.result } : {},
|
|
@@ -43684,7 +43732,7 @@ function createStreamRenderer() {
|
|
|
43684
43732
|
context: () => context && limit ? { ...context, limit } : context,
|
|
43685
43733
|
model: () => model,
|
|
43686
43734
|
failure: () => failure2,
|
|
43687
|
-
|
|
43735
|
+
executionFailure: () => classified,
|
|
43688
43736
|
background: () => background,
|
|
43689
43737
|
turns: () => turns,
|
|
43690
43738
|
events: events.events,
|
|
@@ -43706,6 +43754,7 @@ var ARG_KEYS, TOOL_KINDS2, SUBAGENT_TOOLS, USER_FIXES, addUsage;
|
|
|
43706
43754
|
var init_claude_stream = __esm({
|
|
43707
43755
|
"src/lib/agent/wire/claude-stream.ts"() {
|
|
43708
43756
|
"use strict";
|
|
43757
|
+
init_failures();
|
|
43709
43758
|
init_events();
|
|
43710
43759
|
init_json();
|
|
43711
43760
|
init_stream();
|
|
@@ -44133,15 +44182,15 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
44133
44182
|
return "";
|
|
44134
44183
|
// 最终失败保留;连接提示只在没有后续成功完成时才作为失败。
|
|
44135
44184
|
case "turn.failed": {
|
|
44136
|
-
const said2 = str2(obj2(ev.error).message) || failure2 || "Codex
|
|
44137
|
-
failure2 = said2;
|
|
44185
|
+
const said2 = str2(obj2(ev.error).message) || failure2?.reason || "Codex execution failed.";
|
|
44186
|
+
failure2 = codexFailure(ev.error, said2);
|
|
44138
44187
|
events.error(said2);
|
|
44139
44188
|
return `[error] ${said2}
|
|
44140
44189
|
`;
|
|
44141
44190
|
}
|
|
44142
44191
|
case "error": {
|
|
44143
44192
|
const said2 = str2(ev.message);
|
|
44144
|
-
failure2 =
|
|
44193
|
+
if (ev.willRetry !== true && ev.will_retry !== true && said2) failure2 = codexFailure(ev.error ?? ev, said2);
|
|
44145
44194
|
events.log(`[Codex] ${said2}
|
|
44146
44195
|
`);
|
|
44147
44196
|
return `[Codex] ${said2}
|
|
@@ -44188,7 +44237,8 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
44188
44237
|
},
|
|
44189
44238
|
costIncomplete: () => childSpend(subagents, since).costIncomplete || childSpend(subagents, since).costUsd !== void 0 && priceUsd(facts?.provider, turn2()?.model ?? facts?.model, own2()) === void 0 || void 0,
|
|
44190
44239
|
resumeId: () => threadId,
|
|
44191
|
-
failure: () => failure2 ?? background.failure(),
|
|
44240
|
+
failure: () => failure2?.reason ?? background.failure(),
|
|
44241
|
+
executionFailure: () => failure2,
|
|
44192
44242
|
background: () => subagents.size ? background.count() : void 0,
|
|
44193
44243
|
events: events.events,
|
|
44194
44244
|
activity: events.activity
|
|
@@ -44198,6 +44248,7 @@ var imageSafeText, CALLS, LOOK_EVERY_MS;
|
|
|
44198
44248
|
var init_codex_stream = __esm({
|
|
44199
44249
|
"src/lib/agent/wire/codex-stream.ts"() {
|
|
44200
44250
|
"use strict";
|
|
44251
|
+
init_failures();
|
|
44201
44252
|
init_background();
|
|
44202
44253
|
init_codex_session();
|
|
44203
44254
|
init_events();
|
|
@@ -44546,7 +44597,7 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
44546
44597
|
const closed2 = (why2) => {
|
|
44547
44598
|
if (gone) return;
|
|
44548
44599
|
gone = why2;
|
|
44549
|
-
for (const { fail } of waiting.values()) fail(
|
|
44600
|
+
for (const { fail } of waiting.values()) fail(why2);
|
|
44550
44601
|
waiting.clear();
|
|
44551
44602
|
};
|
|
44552
44603
|
stdout.on("data", (chunk) => {
|
|
@@ -44571,17 +44622,17 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
44571
44622
|
waiting.delete(String(msg.id));
|
|
44572
44623
|
if (msg.error) {
|
|
44573
44624
|
const said2 = [str2(msg.error.message), str2(obj2(msg.error.data).message)].filter(Boolean).join(": ");
|
|
44574
|
-
pending.fail(new RpcError(said2 || `the agent refused (${msg.error.code ?? "no code"})`, msg.error.code));
|
|
44625
|
+
pending.fail(new RpcError(said2 || `the agent refused (${msg.error.code ?? "no code"})`, msg.error.code, msg.error.data));
|
|
44575
44626
|
} else pending.ok(obj2(msg.result));
|
|
44576
44627
|
}
|
|
44577
44628
|
});
|
|
44578
|
-
stdout.on("close", () => closed2("
|
|
44579
|
-
stdout.on("error", (err) => closed2(
|
|
44580
|
-
stdin.on("error", (err) => closed2(
|
|
44629
|
+
stdout.on("close", () => closed2(new ExecutionError({ code: "connection_lost", level: 2, reason: "The agent closed the connection." })));
|
|
44630
|
+
stdout.on("error", (err) => closed2(new ExecutionError(executionFailure(err))));
|
|
44631
|
+
stdin.on("error", (err) => closed2(new ExecutionError(executionFailure(err))));
|
|
44581
44632
|
return {
|
|
44582
44633
|
/** Ask the agent something. Rejects with the agent's own words when it says no. */
|
|
44583
44634
|
call(method, params) {
|
|
44584
|
-
if (gone) return Promise.reject(
|
|
44635
|
+
if (gone) return Promise.reject(gone);
|
|
44585
44636
|
const id2 = dialect.stringIds ? String(nextId++) : nextId++;
|
|
44586
44637
|
return new Promise((ok, fail) => {
|
|
44587
44638
|
waiting.set(String(id2), { ok, fail });
|
|
@@ -44606,14 +44657,17 @@ var RpcError;
|
|
|
44606
44657
|
var init_rpc = __esm({
|
|
44607
44658
|
"src/lib/agent/wire/rpc.ts"() {
|
|
44608
44659
|
"use strict";
|
|
44660
|
+
init_failures();
|
|
44609
44661
|
init_json();
|
|
44610
44662
|
RpcError = class extends Error {
|
|
44611
|
-
constructor(message, code) {
|
|
44663
|
+
constructor(message, code, data) {
|
|
44612
44664
|
super(message);
|
|
44613
44665
|
this.code = code;
|
|
44666
|
+
this.data = data;
|
|
44614
44667
|
this.name = "RpcError";
|
|
44615
44668
|
}
|
|
44616
44669
|
code;
|
|
44670
|
+
data;
|
|
44617
44671
|
};
|
|
44618
44672
|
}
|
|
44619
44673
|
});
|
|
@@ -44722,9 +44776,6 @@ function usageOf3(value, grossInput = false) {
|
|
|
44722
44776
|
const sum = counts.input + counts.cacheCreation + counts.cacheRead + counts.output;
|
|
44723
44777
|
return sum > 0 ? counts : void 0;
|
|
44724
44778
|
}
|
|
44725
|
-
function sessionGone(e) {
|
|
44726
|
-
return e instanceof RpcError && e.code === INVALID_PARAMS && /session\b.*\bnot found/i.test(e.message);
|
|
44727
|
-
}
|
|
44728
44779
|
async function newSession(rpc, cwd, mcpServers) {
|
|
44729
44780
|
const opened = await rpc.call("session/new", { cwd, mcpServers });
|
|
44730
44781
|
const sessionId = str2(opened.sessionId);
|
|
@@ -44835,7 +44886,10 @@ async function oneTurn(io, options) {
|
|
|
44835
44886
|
try {
|
|
44836
44887
|
opened = await bounded(rpc.call("session/load", { sessionId, cwd: io.cwd, mcpServers }), preparingUntil - Date.now(), "ACP session/load timed out.");
|
|
44837
44888
|
} catch (e) {
|
|
44838
|
-
|
|
44889
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
44890
|
+
const failure2 = e instanceof RpcError ? providerFailure(e.data, reason) : executionFailure(e);
|
|
44891
|
+
if (failure2.code !== "session_not_found") throw e;
|
|
44892
|
+
if (!io.restartPrompt) throw new ExecutionError(failure2);
|
|
44839
44893
|
const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
|
|
44840
44894
|
opened = fresh.opened;
|
|
44841
44895
|
sessionId = fresh.sessionId;
|
|
@@ -44882,7 +44936,7 @@ async function oneTurn(io, options) {
|
|
|
44882
44936
|
`);
|
|
44883
44937
|
events.error(why2);
|
|
44884
44938
|
emit();
|
|
44885
|
-
return { ok: false, result, error: why2, usage: usage3, context, costUsd };
|
|
44939
|
+
return { ok: false, result, error: why2, failure: { code: stopReason2, level: 3, reason: why2 }, usage: usage3, context, costUsd };
|
|
44886
44940
|
}
|
|
44887
44941
|
emit();
|
|
44888
44942
|
return { ok: true, result, usage: usage3, context, costUsd };
|
|
@@ -44895,7 +44949,7 @@ async function oneTurn(io, options) {
|
|
|
44895
44949
|
events.error(error62);
|
|
44896
44950
|
emit();
|
|
44897
44951
|
if (currentSession) saveAcpCost(acpCostFile(options.tool ?? "acp", io.cwd, currentSession), costUsd);
|
|
44898
|
-
return { ok: false, result, error: error62, usage: void 0, costUsd: costUsd === void 0 || costBefore === void 0 ? void 0 : costUsd < costBefore ? costUsd : costUsd - costBefore };
|
|
44952
|
+
return { ok: false, result, error: error62, failure: e instanceof RpcError ? providerFailure(e.data, error62) : executionFailure(e), usage: void 0, costUsd: costUsd === void 0 || costBefore === void 0 ? void 0 : costUsd < costBefore ? costUsd : costUsd - costBefore };
|
|
44899
44953
|
} finally {
|
|
44900
44954
|
io.signal?.removeEventListener("abort", cancelled);
|
|
44901
44955
|
}
|
|
@@ -44946,10 +45000,11 @@ function decide(params, tail, events) {
|
|
|
44946
45000
|
if (!no) return { outcome: { outcome: "cancelled" } };
|
|
44947
45001
|
return { outcome: { outcome: "selected", optionId: no.optionId } };
|
|
44948
45002
|
}
|
|
44949
|
-
var PROTOCOL_VERSION, CLIENT_CAPABILITIES,
|
|
45003
|
+
var PROTOCOL_VERSION, CLIENT_CAPABILITIES, RESTARTED, TICKS_PER_USD, STOPPED;
|
|
44950
45004
|
var init_acp = __esm({
|
|
44951
45005
|
"src/lib/agent/wire/acp.ts"() {
|
|
44952
45006
|
"use strict";
|
|
45007
|
+
init_failures();
|
|
44953
45008
|
init_acp_cost();
|
|
44954
45009
|
init_conversation();
|
|
44955
45010
|
init_events();
|
|
@@ -44962,7 +45017,6 @@ var init_acp = __esm({
|
|
|
44962
45017
|
fs: { readTextFile: false, writeTextFile: false },
|
|
44963
45018
|
terminal: false
|
|
44964
45019
|
};
|
|
44965
|
-
INVALID_PARAMS = -32602;
|
|
44966
45020
|
RESTARTED = "[board] that conversation is gone \u2014 the task was restarted in a new session\n";
|
|
44967
45021
|
TICKS_PER_USD = 1e10;
|
|
44968
45022
|
STOPPED = {
|
|
@@ -45198,14 +45252,14 @@ async function oneTurn2(io, options) {
|
|
|
45198
45252
|
if (!done.ok) {
|
|
45199
45253
|
const why2 = done.error ?? "the agent stopped without saying why";
|
|
45200
45254
|
stopped(io, why2);
|
|
45201
|
-
return { ok: false, result, error: why2, usage: usage3, context };
|
|
45255
|
+
return { ok: false, result, error: why2, failure: done.failure, usage: usage3, context };
|
|
45202
45256
|
}
|
|
45203
45257
|
return { ok: true, result, usage: usage3, context };
|
|
45204
45258
|
} catch (e) {
|
|
45205
45259
|
const error62 = e instanceof Error ? e.message : String(e);
|
|
45206
45260
|
const result = tail.end();
|
|
45207
45261
|
stopped(io, error62);
|
|
45208
|
-
return { ok: false, result, error: error62 };
|
|
45262
|
+
return { ok: false, result, error: error62, failure: executionFailure(e) };
|
|
45209
45263
|
} finally {
|
|
45210
45264
|
io.signal?.removeEventListener("abort", cancelled);
|
|
45211
45265
|
}
|
|
@@ -45253,7 +45307,8 @@ function event(envelope2, parts, tail, live, ended) {
|
|
|
45253
45307
|
}
|
|
45254
45308
|
case "turn.failed": {
|
|
45255
45309
|
const error62 = obj2(payload.error);
|
|
45256
|
-
|
|
45310
|
+
const failure2 = providerFailure(error62, str2(error62.message) || "the turn failed");
|
|
45311
|
+
return ended({ ok: false, error: failure2.reason, failure: failure2 });
|
|
45257
45312
|
}
|
|
45258
45313
|
case "session.closed":
|
|
45259
45314
|
return ended({ ok: false, error: str2(payload.reason) || "the agent closed the session" });
|
|
@@ -45270,6 +45325,7 @@ var STOPPED2, MODE, RUNTIME_PREFERENCES, MISSING_KEY;
|
|
|
45270
45325
|
var init_zcode = __esm({
|
|
45271
45326
|
"src/lib/agent/wire/zcode.ts"() {
|
|
45272
45327
|
"use strict";
|
|
45328
|
+
init_failures();
|
|
45273
45329
|
init_usage2();
|
|
45274
45330
|
init_events();
|
|
45275
45331
|
init_json();
|
|
@@ -45611,7 +45667,7 @@ async function run(io, options, count3) {
|
|
|
45611
45667
|
io.log(renderer.push(JSON.stringify({ type, ...extra }) + "\n"));
|
|
45612
45668
|
for (const event2 of renderer.events?.() ?? []) io.event?.(event2);
|
|
45613
45669
|
};
|
|
45614
|
-
const end2 = (error62) => {
|
|
45670
|
+
const end2 = (error62, classified) => {
|
|
45615
45671
|
if (ended) return;
|
|
45616
45672
|
ended = true;
|
|
45617
45673
|
clearTimeout(timer);
|
|
@@ -45631,15 +45687,16 @@ async function run(io, options, count3) {
|
|
|
45631
45687
|
const costUsd = cost === void 0 ? child.costUsd : cost + (child.costUsd ?? 0);
|
|
45632
45688
|
const failure2 = error62 || (cleanup.status === "unconfirmed" ? cleanup.detail : void 0) || work.work().filter((w) => !w.intentionalStop && ["failed", "interrupted"].includes(w.status)).map((w) => w.result || `Background work ${w.id} ${w.status}.`).join("\n") || void 0;
|
|
45633
45689
|
if (failure2) io.event?.({ kind: "error", data: { text: failure2 } });
|
|
45634
|
-
resolve2({ ok: !failure2, error: failure2, cleanup, result: renderer.result(), replyParts: renderer.replyParts?.(), usage: combinedUsage, context, costUsd, costIncomplete: child.costIncomplete || cost === void 0 && child.costUsd !== void 0 || void 0 });
|
|
45690
|
+
resolve2({ ok: !failure2, error: failure2, failure: failure2 ? classified ?? { code: "execution_failed", level: 3, reason: failure2 } : void 0, cleanup, result: renderer.result(), replyParts: renderer.replyParts?.(), usage: combinedUsage, context, costUsd, costIncomplete: child.costIncomplete || cost === void 0 && child.costUsd !== void 0 || void 0 });
|
|
45635
45691
|
};
|
|
45636
45692
|
const closed2 = () => {
|
|
45637
|
-
|
|
45638
|
-
|
|
45693
|
+
const reason = "Codex connection closed before all work and results finished.";
|
|
45694
|
+
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection lost; managed cleanup is unconfirmed.");
|
|
45695
|
+
end2(reason, { code: "connection_lost", level: 2, reason });
|
|
45639
45696
|
};
|
|
45640
45697
|
const inputFailed = (e) => {
|
|
45641
|
-
note("Connection input failed; managed cleanup is unconfirmed.");
|
|
45642
|
-
end2(e.message);
|
|
45698
|
+
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection input failed; managed cleanup is unconfirmed.");
|
|
45699
|
+
end2(e.message, executionFailure(e));
|
|
45643
45700
|
};
|
|
45644
45701
|
io.stdout.once("close", closed2);
|
|
45645
45702
|
io.stdin.once("error", inputFailed);
|
|
@@ -45901,7 +45958,10 @@ async function run(io, options, count3) {
|
|
|
45901
45958
|
context = { used: (Number(last.inputTokens) || 0) + (Number(last.outputTokens) || 0), ...Number(token2.modelContextWindow) > 0 ? { limit: Number(token2.modelContextWindow) } : {} };
|
|
45902
45959
|
io.gotContext?.(context);
|
|
45903
45960
|
}
|
|
45904
|
-
if (msg.method === "error" && p.willRetry !== true)
|
|
45961
|
+
if (msg.method === "error" && p.willRetry !== true) {
|
|
45962
|
+
const failure2 = codexFailure(p.error, "Codex failed.");
|
|
45963
|
+
end2(failure2.reason, failure2);
|
|
45964
|
+
}
|
|
45905
45965
|
if (msg.method === "turn/completed") {
|
|
45906
45966
|
const turn2 = obj2(p.turn);
|
|
45907
45967
|
const id2 = str2(turn2.id);
|
|
@@ -45912,7 +45972,9 @@ async function run(io, options, count3) {
|
|
|
45912
45972
|
item(raw, true);
|
|
45913
45973
|
}
|
|
45914
45974
|
if (turn2.status !== "completed") {
|
|
45915
|
-
|
|
45975
|
+
const reason = str2(obj2(turn2.error).message) || `Codex turn ${str2(turn2.status)}.`;
|
|
45976
|
+
const failure2 = turn2.status === "failed" ? codexFailure(turn2.error, reason) : { code: "turn_stopped", level: 3, reason };
|
|
45977
|
+
end2(reason, failure2);
|
|
45916
45978
|
return;
|
|
45917
45979
|
}
|
|
45918
45980
|
active3 = false;
|
|
@@ -45936,13 +45998,7 @@ async function run(io, options, count3) {
|
|
|
45936
45998
|
phase("initialized");
|
|
45937
45999
|
rpc.notify("initialized");
|
|
45938
46000
|
const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
|
|
45939
|
-
|
|
45940
|
-
try {
|
|
45941
|
-
response = await bounded(rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} }), preparingUntil - Date.now(), `Codex thread/${mode ?? "start"} timed out.`);
|
|
45942
|
-
} catch (e) {
|
|
45943
|
-
if (mode && e instanceof RpcError && /no rollout found for thread id/i.test(e.message)) throw Error(`Thread not found: ${e.message}`);
|
|
45944
|
-
throw e;
|
|
45945
|
-
}
|
|
46001
|
+
const response = await bounded(rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} }), preparingUntil - Date.now(), `Codex thread/${mode ?? "start"} timed out.`);
|
|
45946
46002
|
const thread = obj2(response.thread);
|
|
45947
46003
|
for (const turn2 of list2(thread.turns)) historicalTurns.add(str2(turn2.id));
|
|
45948
46004
|
threadId = str2(thread.id);
|
|
@@ -45959,7 +46015,8 @@ async function run(io, options, count3) {
|
|
|
45959
46015
|
phase("ready");
|
|
45960
46016
|
await start(io.prompt, options.images);
|
|
45961
46017
|
} catch (e) {
|
|
45962
|
-
|
|
46018
|
+
const failure2 = e instanceof RpcError ? codexFailure(e.data, e.message) : executionFailure(e);
|
|
46019
|
+
end2(failure2.reason, failure2);
|
|
45963
46020
|
}
|
|
45964
46021
|
return done;
|
|
45965
46022
|
}
|
|
@@ -45967,6 +46024,7 @@ var list2;
|
|
|
45967
46024
|
var init_codex = __esm({
|
|
45968
46025
|
"src/lib/agent/wire/codex.ts"() {
|
|
45969
46026
|
"use strict";
|
|
46027
|
+
init_failures();
|
|
45970
46028
|
init_conversation();
|
|
45971
46029
|
init_codex_background();
|
|
45972
46030
|
init_codex_work();
|
|
@@ -46016,16 +46074,14 @@ function claudeOnWindows() {
|
|
|
46016
46074
|
])
|
|
46017
46075
|
);
|
|
46018
46076
|
}
|
|
46019
|
-
var
|
|
46077
|
+
var MODEL_ALIASES, readsStdin, userMessage, CLAUDE_CODE;
|
|
46020
46078
|
var init_claude_code = __esm({
|
|
46021
46079
|
"src/lib/agent/harnesses/claude-code.ts"() {
|
|
46022
46080
|
"use strict";
|
|
46023
46081
|
init_locate();
|
|
46024
46082
|
init_wire();
|
|
46025
46083
|
init_models();
|
|
46026
|
-
init_transient();
|
|
46027
46084
|
init_types3();
|
|
46028
|
-
cliSaid = (said2) => /^\s*API Error\b/i.test(said2 ?? "") ? said2 : void 0;
|
|
46029
46085
|
MODEL_ALIASES = ["opus", "sonnet", "haiku", "fable"];
|
|
46030
46086
|
readsStdin = (argv) => argv.includes("--input-format=stream-json") || argv[argv.indexOf("--input-format") + 1] === "stream-json";
|
|
46031
46087
|
userMessage = (prompt) => `${JSON.stringify({ type: "user", message: { role: "user", content: prompt } })}
|
|
@@ -46246,18 +46302,6 @@ var init_claude_code = __esm({
|
|
|
46246
46302
|
reports: ["cost", "tokens", "model", "context"],
|
|
46247
46303
|
// The variable above is the switch: the first 429 exits non-zero and the card is free.
|
|
46248
46304
|
stopsOnRateLimit: true,
|
|
46249
|
-
// A provider that stumbled, in the three ways `claude -p` reports one (#525).
|
|
46250
|
-
//
|
|
46251
|
-
// `failure` is a `result` event marked `is_error`, which the renderer already reads for
|
|
46252
|
-
// its own reason. `offStream` is a line the CLI printed outside its events, and it is how
|
|
46253
|
-
// BOTH failures this board captured arrived — "API Error: Connection dropped
|
|
46254
|
-
// (ECONNRESET)" and "API Error: Connection lost mid-response.": the connection goes and
|
|
46255
|
-
// no `result` event is ever written. `result` is the agent's own last message, read for
|
|
46256
|
-
// the same words in case a future CLI puts them there.
|
|
46257
|
-
//
|
|
46258
|
-
// The last two only behind the `API Error:` prefix the CLI writes them under: everything
|
|
46259
|
-
// else on those two is the agent's prose, and prose quoting an error is not a failure.
|
|
46260
|
-
transient: ({ failure: failure2, result, offStream }) => providerBlip(failure2, cliSaid(offStream), cliSaid(result)),
|
|
46261
46305
|
renderer: createStreamRenderer,
|
|
46262
46306
|
stdinPrompt: (argv) => readsStdin(argv) ? userMessage : void 0,
|
|
46263
46307
|
// `--session-id` above makes Claude Code run under the id we generated, so our key IS
|
|
@@ -46446,7 +46490,6 @@ var init_codex2 = __esm({
|
|
|
46446
46490
|
init_locate();
|
|
46447
46491
|
init_models();
|
|
46448
46492
|
init_worktree();
|
|
46449
|
-
init_transient();
|
|
46450
46493
|
init_types3();
|
|
46451
46494
|
QUIET_CONFIG = ["check_for_update_on_startup=false", "notice.hide_rate_limit_model_nudge=true"];
|
|
46452
46495
|
ARCHES = ["x86_64", "aarch64", "i686", "x64", "arm64", "x86"];
|
|
@@ -46625,7 +46668,6 @@ var init_codex2 = __esm({
|
|
|
46625
46668
|
// failed: its `turn.failed` and `error` events, which the renderer keeps as this run's
|
|
46626
46669
|
// failure (#525). Its final message is not read the way Claude Code's is — Codex puts the
|
|
46627
46670
|
// reason on the stream, so a message that merely mentions one is the agent's prose.
|
|
46628
|
-
transient: ({ failure: failure2 }) => providerBlip(failure2),
|
|
46629
46671
|
// resumeArgs/forkArgs end on the subcommand and the thread id.
|
|
46630
46672
|
renderer: (_cwd, _binary, argv = []) => createCodexStreamRenderer(["resume", "fork"].includes(argv.at(-2) ?? "")),
|
|
46631
46673
|
// Codex re-reads its model list on a timer and traces the attempt to stderr every time,
|
|
@@ -48500,6 +48542,9 @@ function parseStore() {
|
|
|
48500
48542
|
ok: typeof entry.ok === "boolean" ? entry.ok : void 0,
|
|
48501
48543
|
code: entry.code ?? null,
|
|
48502
48544
|
error: typeof entry.error === "string" ? entry.error : void 0,
|
|
48545
|
+
failure: readFailure(entry.failure),
|
|
48546
|
+
validationFailure: readFailure(entry.validationFailure),
|
|
48547
|
+
retryPause: entry.retryPause,
|
|
48503
48548
|
blocker: readBlocker(entry.blocker),
|
|
48504
48549
|
// A run that never reported a cost shows none, rather than a zero it didn't earn.
|
|
48505
48550
|
costUsd: typeof entry.costUsd === "number" && entry.costUsd >= 0 ? entry.costUsd : void 0,
|
|
@@ -48580,7 +48625,7 @@ function readRetry2(raw) {
|
|
|
48580
48625
|
if (!raw || typeof raw !== "object") return void 0;
|
|
48581
48626
|
const r = raw;
|
|
48582
48627
|
const whole2 = Number.isInteger(r.attempt) && r.attempt > 0 && Number.isInteger(r.of) && r.of > 0 && typeof r.reason === "string" && !!r.reason && typeof r.at === "number" && typeof r.since === "number";
|
|
48583
|
-
return whole2 ? { attempt: r.attempt, of: r.of, reason: r.reason, at: r.at, since: r.since } : void 0;
|
|
48628
|
+
return whole2 ? { attempt: r.attempt, of: r.of, reason: r.reason, at: r.at, since: r.since, pending: readRetryPlan(r.pending, r.attempt), launching: r.launching === true || void 0 } : void 0;
|
|
48584
48629
|
}
|
|
48585
48630
|
function readMarks(raw) {
|
|
48586
48631
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
@@ -48865,6 +48910,7 @@ var KEEP_RUNS, KEEP_DELIVERIES, logPathOf, eventsPathOf, WAS_CLARIFY, RETIRED_AC
|
|
|
48865
48910
|
var init_store = __esm({
|
|
48866
48911
|
"src/lib/agent/store.ts"() {
|
|
48867
48912
|
"use strict";
|
|
48913
|
+
init_retry();
|
|
48868
48914
|
init_execution();
|
|
48869
48915
|
init_file_memo();
|
|
48870
48916
|
init_lock();
|
|
@@ -49267,8 +49313,7 @@ function openPlan(plan) {
|
|
|
49267
49313
|
// Read off the argv, so a plan written before the CLI took its turns on stdin still runs.
|
|
49268
49314
|
stdinPrompt: harness.stdinPrompt?.(argv),
|
|
49269
49315
|
quietStderr: harness.quietStderr,
|
|
49270
|
-
images: harness.images
|
|
49271
|
-
transient: harness.transient?.bind(harness)
|
|
49316
|
+
images: harness.images
|
|
49272
49317
|
};
|
|
49273
49318
|
}
|
|
49274
49319
|
function resumesUnder(harnessName) {
|
|
@@ -51625,6 +51670,11 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
51625
51670
|
if (r.status !== "running" || runIsLive(r)) continue;
|
|
51626
51671
|
r.status = r.stopping ? "stopped" : "interrupted";
|
|
51627
51672
|
r.code = null;
|
|
51673
|
+
if (r.status === "stopped" && r.retry) delete r.retry.pending;
|
|
51674
|
+
if (r.retry?.launching) {
|
|
51675
|
+
r.retryPause = "unsafe";
|
|
51676
|
+
r.error = [r.retry.reason, pauseLine("unsafe")].filter(Boolean).join("\n");
|
|
51677
|
+
}
|
|
51628
51678
|
if (r.managedProcess) void stopConnection(r.agentPid ? { pid: r.agentPid, identity: r.agentIdentity } : void 0, 12e3);
|
|
51629
51679
|
else if (r.pid) killMarked(runMark(r.sessionId), r.agentPid && r.agentStartedAt ? { pid: r.agentPid, since: r.agentStartedAt } : void 0);
|
|
51630
51680
|
r.endedAt = now;
|
|
@@ -52104,6 +52154,16 @@ async function openResume(id2, options) {
|
|
|
52104
52154
|
}
|
|
52105
52155
|
const ended = endedDeliveryRefusal(prev);
|
|
52106
52156
|
if (ended) return ended;
|
|
52157
|
+
const automatic = typeof options === "object" && options.automatic === true;
|
|
52158
|
+
const pending = !forced && prev.status !== "stopped" ? prev.retry?.pending : void 0;
|
|
52159
|
+
if (automatic && !pending) return refusal("runContinued", "The automatic retry is no longer pending.");
|
|
52160
|
+
if (pending) {
|
|
52161
|
+
const root2 = prev.agentPid ? { pid: prev.agentPid, since: prev.agentStartedAt ?? prev.startedAt, identity: prev.agentIdentity } : void 0;
|
|
52162
|
+
const stopped2 = prev.managedProcess ? connectionStopped(root2) : processesStopped(runMark(prev.sessionId, prev.agentStartedAt), root2);
|
|
52163
|
+
if (!stopped2 || !resumeSessionId(prev)) return retryRefusal(prev, "unsafe");
|
|
52164
|
+
await new Promise((resolve2) => setTimeout(resolve2, Math.max(0, pending.at - Date.now())));
|
|
52165
|
+
if (!await executionHeld(executionOf())) return retryRefusal(prev, "authorization");
|
|
52166
|
+
}
|
|
52107
52167
|
const resuming = prev.deliveryId ? findDelivery(prev.deliveryId) : void 0;
|
|
52108
52168
|
const cwd = deliveryCwd(resuming ?? {});
|
|
52109
52169
|
const sessionId = randomUUID6();
|
|
@@ -52118,7 +52178,7 @@ async function openResume(id2, options) {
|
|
|
52118
52178
|
plan = planResume({ harness: prev.harness, resumeId: session, cwd }, prev.agent, prev.runtime ? { pin: prev.runtime } : {});
|
|
52119
52179
|
} else {
|
|
52120
52180
|
const ask2 = retryAsk(prev) ?? requestOf(prev);
|
|
52121
|
-
const started = await
|
|
52181
|
+
const started = await planRetry2(prev, ask2, sessionId, cwd);
|
|
52122
52182
|
if ("error" in started) return started;
|
|
52123
52183
|
({ plan, fresh } = started);
|
|
52124
52184
|
const restart = prev.action === "spec" ? void 0 : restartPrompt({ ...requestOf(prev), runtime: plan.runtime }, prev.deliveryId);
|
|
@@ -52130,14 +52190,14 @@ async function openResume(id2, options) {
|
|
|
52130
52190
|
return refusal("runForeign", `this version can't continue a conversation ${agent} opened`, { agent });
|
|
52131
52191
|
}
|
|
52132
52192
|
const buildResume = prev.action === "implement" && prev.deliveryId ? resumePrompt(prev.deliveryId, prev.action) : void 0;
|
|
52133
|
-
const opened = await resumeHeld(prev, plan, sessionId, resuming, fresh);
|
|
52193
|
+
const opened = await resumeHeld(prev, plan, sessionId, resuming, fresh, !!pending);
|
|
52134
52194
|
if ("error" in opened) return opened;
|
|
52135
52195
|
if (!opened.spec.prompt && buildResume) opened.spec.prompt = buildResume;
|
|
52136
52196
|
if (build?.notes?.trim()) opened.spec.prompt = [opened.spec.prompt || resumePrompt(prev.deliveryId, prev.action), build.notes.trim()].join("\n\n");
|
|
52137
52197
|
if (build || buildResume) writeSpec(opened.spec);
|
|
52138
52198
|
return opened;
|
|
52139
52199
|
}
|
|
52140
|
-
async function
|
|
52200
|
+
async function planRetry2(prev, ask2, sessionId, cwd) {
|
|
52141
52201
|
const runtime = prev.runtime && runtimeById(prev.runtime) ? prev.runtime : void 0;
|
|
52142
52202
|
const { note, ...plan } = planRun(sessionId, cwd, prev.agent ?? agentForRun(ask2), {
|
|
52143
52203
|
...runtime ? { pin: runtime } : {},
|
|
@@ -52146,7 +52206,16 @@ async function planRetry(prev, ask2, sessionId, cwd) {
|
|
|
52146
52206
|
const { prompt, notes } = buildRun({ ...ask2, title: titleOf(ask2.id), runtime: plan.runtime, pictures: prev.pictures });
|
|
52147
52207
|
return { plan, fresh: { prompt, notes: note ? [...notes, note] : notes, retry: true } };
|
|
52148
52208
|
}
|
|
52149
|
-
|
|
52209
|
+
function retryRefusal(prev, pause2) {
|
|
52210
|
+
const reason = pauseLine(pause2);
|
|
52211
|
+
patch(prev.sessionId, (run3) => {
|
|
52212
|
+
if (run3.retry) delete run3.retry.pending;
|
|
52213
|
+
run3.retryPause = pause2;
|
|
52214
|
+
run3.error = [run3.error ?? run3.retry?.reason, reason].filter(Boolean).join("\n");
|
|
52215
|
+
});
|
|
52216
|
+
return refusal("runContinued", reason);
|
|
52217
|
+
}
|
|
52218
|
+
async function resumeHeld(prev, plan, sessionId, resuming, fresh, automatic = false) {
|
|
52150
52219
|
const retry2 = fresh?.retry === true;
|
|
52151
52220
|
const record2 = {
|
|
52152
52221
|
sessionId,
|
|
@@ -52174,12 +52243,10 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
52174
52243
|
resumedFrom: prev.sessionId,
|
|
52175
52244
|
// Taken now: the run being continued is dropped once this one starts (#1483).
|
|
52176
52245
|
sessionCostFrom: reportsSessionTotal(prev.harness) ? prev.sessionCostUsd ?? prev.sessionCostFrom : void 0,
|
|
52177
|
-
// The retry chain carries on rather than starting over (#525): this run IS the attempt
|
|
52178
|
-
// the failed one scheduled, so its count and its window come with it.
|
|
52179
|
-
retry: prev.retry,
|
|
52180
52246
|
...prev.retry && prev.result ? { result: prev.result } : {}
|
|
52181
52247
|
},
|
|
52182
|
-
|
|
52248
|
+
failure: automatic ? prev.retry?.pending?.failure : void 0,
|
|
52249
|
+
retry: prev.retry ? { ...prev.retry, pending: void 0, launching: automatic ? true : void 0 } : void 0,
|
|
52183
52250
|
logPath: logPathOf(sessionId),
|
|
52184
52251
|
specAgent: prev.specAgent,
|
|
52185
52252
|
...prev.action === "scheduled" ? { studio: prev.studio } : {},
|
|
@@ -52193,6 +52260,9 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
52193
52260
|
const all2 = store.runs;
|
|
52194
52261
|
const latest = all2.find((r) => r.sessionId === prev.sessionId);
|
|
52195
52262
|
if (!latest) return refusal("runContinued", "that run has already been continued");
|
|
52263
|
+
if (automatic && (latest.stopping || latest.status === "stopped" || !latest.retry?.pending)) {
|
|
52264
|
+
return refusal("runContinued", "The automatic retry is no longer pending.");
|
|
52265
|
+
}
|
|
52196
52266
|
if (latest.discardedCards?.some((c) => c.pending || locate(c.id))) {
|
|
52197
52267
|
return refusal("discardUnfinished", "A card discard did not finish. Retry discarding it before resuming creation.");
|
|
52198
52268
|
}
|
|
@@ -52304,6 +52374,12 @@ async function closeRun(sessionId, res) {
|
|
|
52304
52374
|
if (res.ok !== void 0) run3.ok = res.ok;
|
|
52305
52375
|
run3.code = res.code ?? null;
|
|
52306
52376
|
if (res.error) run3.error = res.error;
|
|
52377
|
+
run3.failure = res.failure;
|
|
52378
|
+
run3.retryPause = res.retryPause;
|
|
52379
|
+
if (run3.retry) {
|
|
52380
|
+
delete run3.retry.launching;
|
|
52381
|
+
if (res.status === "stopped") delete run3.retry.pending;
|
|
52382
|
+
}
|
|
52307
52383
|
if (res.note) run3.note = res.note;
|
|
52308
52384
|
if (res.errorWhy?.length) run3.errorWhy = res.errorWhy;
|
|
52309
52385
|
if (res.noteWhy?.length) run3.noteWhy = res.noteWhy;
|
|
@@ -52465,6 +52541,7 @@ var init_sessions = __esm({
|
|
|
52465
52541
|
"src/lib/agent/sessions.ts"() {
|
|
52466
52542
|
"use strict";
|
|
52467
52543
|
init_connection_process();
|
|
52544
|
+
init_retry();
|
|
52468
52545
|
init_execution();
|
|
52469
52546
|
init_cards();
|
|
52470
52547
|
init_frontmatter();
|
|
@@ -55392,13 +55469,20 @@ function cmdValidate(id2) {
|
|
|
55392
55469
|
const cards = [...snapshotSpecs()].filter(([, card]) => id2 === void 0 || card.id === id2);
|
|
55393
55470
|
if (id2 !== void 0 && !cards.length) die(`no task with id ${id2}`, { kind: "card-not-found", id: id2 });
|
|
55394
55471
|
const errors = cards.flatMap(([file2, card]) => validateSpec(file2, card.text, card.id));
|
|
55395
|
-
|
|
55472
|
+
const reason = errors.length ? formatContractErrors(errors) : void 0;
|
|
55473
|
+
const session = insideRun();
|
|
55474
|
+
if (session) patch(session, (run3) => {
|
|
55475
|
+
run3.validationFailure = reason ? { code: "validation_failed", level: 1, reason } : void 0;
|
|
55476
|
+
});
|
|
55477
|
+
if (reason) die(reason, { kind: "spec-contract", errors });
|
|
55396
55478
|
say(`Spec format valid (${cards.length} card${cards.length === 1 ? "" : "s"}).`);
|
|
55397
55479
|
return { valid: true, checked: cards.length, errors: [] };
|
|
55398
55480
|
}
|
|
55399
55481
|
var init_validate2 = __esm({
|
|
55400
55482
|
"src/commands/validate.ts"() {
|
|
55401
55483
|
"use strict";
|
|
55484
|
+
init_env();
|
|
55485
|
+
init_sessions();
|
|
55402
55486
|
init_io();
|
|
55403
55487
|
init_paths();
|
|
55404
55488
|
init_spec_contract();
|
|
@@ -61652,7 +61736,7 @@ var init_describe_project = __esm({
|
|
|
61652
61736
|
var discuss_goal_default;
|
|
61653
61737
|
var init_discuss_goal = __esm({
|
|
61654
61738
|
"src/guide/discuss-goal.md"() {
|
|
61655
|
-
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**: save `--review-file <json>`
|
|
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,title,after?,previews?}`). Use stable 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";
|
|
61656
61740
|
}
|
|
61657
61741
|
});
|
|
61658
61742
|
|
|
@@ -61708,7 +61792,7 @@ var init_review_rejections = __esm({
|
|
|
61708
61792
|
var refine_default;
|
|
61709
61793
|
var init_refine = __esm({
|
|
61710
61794
|
"src/guide/refine.md"() {
|
|
61711
|
-
refine_default = '# Refine a card\n\nPlan one card until it is buildable.\n\n- **Unchecked cards**: check cards with `triage:` and empty `## Scope` against the project, rejecting obsolete or completed work with `akb raw reject <id> --reason "<evidence>"` and stopping.\n- **Other obsolete or completed cards**: ask whether to discard, run no previews, and stop.\n- **Groups**: preserve subtask coverage and progress, fill gaps without duplication, and do not mark the parent ready merely because its split is complete.\n- **Verification**: plan representative checks for the outcome, project rules and material risks, confirm prerequisites, and keep optional coverage optional.\n- **Review**: read `akb task review <id>`. If the arrangement is undecided, propose it with `--file <json> --revision <n>` and wait for confirmation. Work only on dispatched, unlocked nodes; keep independent work moving while other nodes await review.\n- **Previews**: prepare only the unlocked nodes\u2019 outputs per the Studio\u2019s `<Preview>` blocks. Before revising an approved output, use `--revise-from <stage> --revision <n>`; preserve unrelated outputs and approvals.\n- **Submit**: synchronize body and assets, then report `--stage <id> --status done --revision <n>`. Re-read after conflicts; never treat submission, question answers or plan confirmation as product approval.\n- **References**: rewrite mentions of cards no longer on the board.\n- **Decisions**: settle choices supported by evidence and ask only as `akb guide update-questions` allows.\n- **Card**: follow studio rules and `akb guide writing`, fixing all errors from `akb raw validate <id>`.\n- **Ready**: when validated and buildable with prerequisites settled, run `akb raw update <id> --status ready`; otherwise leave blockers as open questions.\n\nFollow the printed closing steps. Wait only for required approvals; completion still requires Studio delivery checks.\n';
|
|
61795
|
+
refine_default = '# Refine a card\n\nPlan one card until it is buildable.\n\n- **Unchecked cards**: check cards with `triage:` and empty `## Scope` against the project, rejecting obsolete or completed work with `akb raw reject <id> --reason "<evidence>"` and stopping.\n- **Other obsolete or completed cards**: ask whether to discard, run no previews, and stop.\n- **Groups**: preserve subtask coverage and progress, fill gaps without duplication, and do not mark the parent ready merely because its split is complete.\n- **Verification**: plan representative checks for the outcome, project rules and material risks, confirm prerequisites, and keep optional coverage optional.\n- **Review**: read `akb task review <id>`. If the arrangement is undecided, propose it with `--file <json> --revision <n>` and wait for confirmation. Work only on dispatched, unlocked nodes; keep independent work moving while other nodes await review.\n- **Previews**: prepare only the unlocked nodes\u2019 outputs per the Studio\u2019s `<Preview>` blocks. Before revising an approved output, use `--revise-from <stage> --revision <n>`; preserve unrelated outputs and approvals.\n- **Submit**: synchronize body and assets, then report `--stage <id> --status done --revision <n>`. Re-read after conflicts; never treat submission, question answers or plan confirmation as product approval.\n- **Delivery handoff**: for Studios with separate delivery, finish the review plan with a handoff; implementation and its checks run in delivery.\n- **References**: rewrite mentions of cards no longer on the board.\n- **Decisions**: settle choices supported by evidence and ask only as `akb guide update-questions` allows.\n- **Card**: follow studio rules and `akb guide writing`, fixing all errors from `akb raw validate <id>`.\n- **Ready**: when validated and buildable with prerequisites settled, run `akb raw update <id> --status ready`; otherwise leave blockers as open questions.\n\nFollow the printed closing steps. Wait only for required approvals; completion still requires Studio delivery checks.\n';
|
|
61712
61796
|
}
|
|
61713
61797
|
});
|
|
61714
61798
|
|
|
@@ -63131,7 +63215,11 @@ function refinementStep(card) {
|
|
|
63131
63215
|
function refinementRequest(req) {
|
|
63132
63216
|
const card = req.id === void 0 ? null : currentCard(req.id);
|
|
63133
63217
|
if (!card) return { error: `task #${req.id} does not exist` };
|
|
63134
|
-
const
|
|
63218
|
+
const context = process.env.AI4KANBAN_TASK_REVIEW;
|
|
63219
|
+
const review = context ? JSON.parse(context) : void 0;
|
|
63220
|
+
const assigned = process.env.AI4KANBAN_REVIEW_STAGES ? JSON.parse(process.env.AI4KANBAN_REVIEW_STAGES) : void 0;
|
|
63221
|
+
const authorized = review && !review.pending_plan && (review.plan === null || review.stages.some((s) => ["available", "running"].includes(s.status) && (!assigned || assigned.includes(s.id))));
|
|
63222
|
+
const step = review ? authorized && !card.questions.some((q) => q.options?.length) ? "clarify" : "done" : refinementStep(card);
|
|
63135
63223
|
if (step === "done") {
|
|
63136
63224
|
const waiting = card.questions.length > 0 && canRefine({ ...card, questions: [] });
|
|
63137
63225
|
return {
|
|
@@ -63372,41 +63460,14 @@ function createIdleWatchdog(expired, busy = () => false, milliseconds = IDLE_TIM
|
|
|
63372
63460
|
}
|
|
63373
63461
|
};
|
|
63374
63462
|
}
|
|
63375
|
-
var IDLE_MS, IDLE_TIMEOUT;
|
|
63463
|
+
var IDLE_MS, IDLE_TIMEOUT, IDLE_ERROR, IDLE_FAILURE;
|
|
63376
63464
|
var init_idle = __esm({
|
|
63377
63465
|
"src/lib/agent/idle.ts"() {
|
|
63378
63466
|
"use strict";
|
|
63379
63467
|
IDLE_MS = 5 * 6e4;
|
|
63380
63468
|
IDLE_TIMEOUT = { milliseconds: IDLE_MS };
|
|
63381
|
-
|
|
63382
|
-
}
|
|
63383
|
-
|
|
63384
|
-
// src/lib/agent/retry.ts
|
|
63385
|
-
function backoffMs(attempt2, random = Math.random) {
|
|
63386
|
-
const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt2 - 2));
|
|
63387
|
-
return Math.round(step * (1 - JITTER * random()));
|
|
63388
|
-
}
|
|
63389
|
-
function planRetry2(prev, failure2, startedAt, now = Date.now(), random = Math.random) {
|
|
63390
|
-
const attempt2 = (prev?.attempt ?? 1) + 1;
|
|
63391
|
-
if (attempt2 > RETRY_ATTEMPTS) return null;
|
|
63392
|
-
const since = prev?.since ?? startedAt;
|
|
63393
|
-
const wait = failure2.retryAfterMs ?? backoffMs(attempt2, random);
|
|
63394
|
-
const at = now + wait;
|
|
63395
|
-
if (wait > CAP_MS || wait < 0 || !Number.isFinite(wait)) return null;
|
|
63396
|
-
return { attempt: attempt2, of: RETRY_ATTEMPTS, reason: failure2.reason, at, since };
|
|
63397
|
-
}
|
|
63398
|
-
function retryLine(retry2, now = Date.now()) {
|
|
63399
|
-
const seconds = Math.max(1, Math.round((retry2.at - now) / 1e3));
|
|
63400
|
-
return `${retry2.reason} \u2014 this run tries again in ${seconds}s (attempt ${retry2.attempt} of ${retry2.of}).`;
|
|
63401
|
-
}
|
|
63402
|
-
var RETRY_ATTEMPTS, BASE_MS, CAP_MS, JITTER;
|
|
63403
|
-
var init_retry = __esm({
|
|
63404
|
-
"src/lib/agent/retry.ts"() {
|
|
63405
|
-
"use strict";
|
|
63406
|
-
RETRY_ATTEMPTS = 2;
|
|
63407
|
-
BASE_MS = 15e3;
|
|
63408
|
-
CAP_MS = 12e4;
|
|
63409
|
-
JITTER = 0.25;
|
|
63469
|
+
IDLE_ERROR = "No response for 5 minutes (idle timeout).";
|
|
63470
|
+
IDLE_FAILURE = { code: "idle_timeout", level: 2, reason: IDLE_ERROR };
|
|
63410
63471
|
}
|
|
63411
63472
|
});
|
|
63412
63473
|
|
|
@@ -63498,11 +63559,23 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63498
63559
|
void refreshCatalog();
|
|
63499
63560
|
const client = active3.client;
|
|
63500
63561
|
if (active3.harness === "codex" && !client) log.write("[Codex] Custom command preserved; managed background cleanup is unavailable for this command shape.\n");
|
|
63501
|
-
const restartBase = !client || record2.cardId !== null ? void 0 : record2.resumedFrom ? restartPrompt(requestOf(record2), record2.deliveryId) : record2.continues && !record2.continues.fork ? spec.prompt : void 0;
|
|
63562
|
+
const restartBase = !client || record2.cardId !== null || record2.retry?.launching ? void 0 : record2.resumedFrom ? restartPrompt(requestOf(record2), record2.deliveryId) : record2.continues && !record2.continues.fork ? spec.prompt : void 0;
|
|
63502
63563
|
const restart = restartBase ? [restartBase, discardedCardsPrompt(record2.discardedCards)].filter(Boolean).join("\n\n") : void 0;
|
|
63503
63564
|
const stdinPrompt = client ? void 0 : active3.stdinPrompt;
|
|
63504
63565
|
const stdio = [client || stdinPrompt ? "pipe" : "ignore", "pipe", "pipe"];
|
|
63505
63566
|
let child;
|
|
63567
|
+
if (record2.retry?.launching && !await executionHeld(executionOf())) {
|
|
63568
|
+
log.end();
|
|
63569
|
+
await closeRun(sessionId, { status: "error", code: null, error: joinNotes(record2.retry.reason, pauseLine("authorization")), retryPause: "authorization", failure: record2.failure });
|
|
63570
|
+
letGo();
|
|
63571
|
+
return 1;
|
|
63572
|
+
}
|
|
63573
|
+
if (record2.retry?.launching && peekRun(sessionId)?.stopping) {
|
|
63574
|
+
log.end();
|
|
63575
|
+
await closeRun(sessionId, { status: "stopped", code: null });
|
|
63576
|
+
letGo();
|
|
63577
|
+
return 1;
|
|
63578
|
+
}
|
|
63506
63579
|
try {
|
|
63507
63580
|
const start = spawnable(cmd, client || stdinPrompt ? args2 : [...args2, prompt], {
|
|
63508
63581
|
// Where this run works: the project, or — inside a delivery with a worktree of its
|
|
@@ -63526,13 +63599,17 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63526
63599
|
patch(sessionId, (r) => {
|
|
63527
63600
|
r.unspawned = true;
|
|
63528
63601
|
});
|
|
63529
|
-
await closeRun(sessionId, { status: "error", ok: false, code: null, error: String(e) });
|
|
63602
|
+
await closeRun(sessionId, { status: "error", ok: false, code: null, error: String(e), failure: executionFailure(e) });
|
|
63530
63603
|
letGo();
|
|
63531
63604
|
return 1;
|
|
63532
63605
|
}
|
|
63533
63606
|
const agentStartedAt = Date.now();
|
|
63534
63607
|
if (child.pid) {
|
|
63535
63608
|
patch(sessionId, (r) => {
|
|
63609
|
+
if (r.retry?.launching) {
|
|
63610
|
+
r.retry.attempt++;
|
|
63611
|
+
delete r.retry.launching;
|
|
63612
|
+
}
|
|
63536
63613
|
r.agentPid = child.pid;
|
|
63537
63614
|
r.agentStartedAt = agentStartedAt;
|
|
63538
63615
|
r.managedProcess = client?.managedProcess;
|
|
@@ -63595,7 +63672,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63595
63672
|
let touch = () => {
|
|
63596
63673
|
};
|
|
63597
63674
|
let activityVersion = 0;
|
|
63598
|
-
let
|
|
63675
|
+
let endTerminal = () => {
|
|
63599
63676
|
};
|
|
63600
63677
|
child.stdout.on("data", (d) => {
|
|
63601
63678
|
if (renderer) {
|
|
@@ -63605,7 +63682,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63605
63682
|
gotModel(renderer.model?.());
|
|
63606
63683
|
gotContext(renderer.context?.());
|
|
63607
63684
|
afterTurn();
|
|
63608
|
-
if (renderer.
|
|
63685
|
+
if (renderer.terminalFailure?.()) endTerminal();
|
|
63609
63686
|
}
|
|
63610
63687
|
const version2 = renderer?.activity?.() ?? 0;
|
|
63611
63688
|
if (version2 !== activityVersion) {
|
|
@@ -63616,13 +63693,14 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63616
63693
|
const errs = createStderrFilter(active3.quietStderr);
|
|
63617
63694
|
child.stderr.on("data", (d) => {
|
|
63618
63695
|
renderer?.stderr?.(d.toString());
|
|
63619
|
-
if (renderer?.rateLimit?.()) endLimited();
|
|
63620
63696
|
const text5 = errs.push(d.toString());
|
|
63621
63697
|
if (text5) log.write(text5);
|
|
63622
63698
|
});
|
|
63623
63699
|
let spawnError;
|
|
63700
|
+
let spawnFailure;
|
|
63624
63701
|
let spawnWhy;
|
|
63625
63702
|
child.on("error", (err) => {
|
|
63703
|
+
spawnFailure = executionFailure(err);
|
|
63626
63704
|
const missing = err?.code === "ENOENT";
|
|
63627
63705
|
spawnError = missing ? `${cmd} isn't installed, or isn't on this run's PATH. Install it with: ${active3.install}` : String(err);
|
|
63628
63706
|
spawnWhy = missing ? { kind: "notInstalled", args: { cmd, install: active3.install } } : void 0;
|
|
@@ -63680,41 +63758,45 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
63680
63758
|
if (errRest) log.write(errRest);
|
|
63681
63759
|
const endedAt = Date.now();
|
|
63682
63760
|
const blocker = peekRun(sessionId)?.blocker;
|
|
63683
|
-
let failure2 = renderer?.failure?.() ?? (!taskCompleted && renderer?.background?.() ? "The agent exited with unfinished background tasks." : void 0);
|
|
63684
|
-
if (!asked && pendingOperations.size > 0 && (code !== 0 || spoken?.ok === false || renderer?.failure?.())) {
|
|
63685
|
-
failure2 = `${failure2 ?? spoken?.error ?? "Agent exited."} Operation results are unconfirmed; automatic recovery was skipped.`;
|
|
63686
|
-
}
|
|
63687
|
-
const unfinished = blocker || failure2;
|
|
63688
|
-
const result = spoken ? spoken.result : renderer?.result();
|
|
63689
63761
|
const held4 = peekRun(sessionId) ?? record2;
|
|
63690
|
-
const
|
|
63691
|
-
const said2 =
|
|
63692
|
-
const
|
|
63693
|
-
const
|
|
63694
|
-
|
|
63695
|
-
|
|
63696
|
-
|
|
63697
|
-
|
|
63698
|
-
const
|
|
63699
|
-
|
|
63700
|
-
if (
|
|
63701
|
-
|
|
63702
|
-
|
|
63703
|
-
|
|
63704
|
-
|
|
63705
|
-
|
|
63706
|
-
|
|
63707
|
-
|
|
63708
|
-
|
|
63762
|
+
const rendered = renderer?.failure?.() ?? (!taskCompleted && renderer?.background?.() ? "The agent exited with unfinished background tasks." : void 0);
|
|
63763
|
+
const said2 = spawnError ?? (silent ? silenceSaid(silenceFor) : spoken?.error ?? rendered);
|
|
63764
|
+
const failed2 = code !== 0 || spoken?.ok === false || !!rendered || silent || !!blocker;
|
|
63765
|
+
const failure2 = failed2 && !asked ? silent ? { ...IDLE_FAILURE, reason: said2 ?? IDLE_FAILURE.reason } : spawnFailure ?? spoken?.failure ?? renderer?.executionFailure?.() ?? (!blocker ? held4.validationFailure : void 0) ?? { code: blocker ? "execution_blocked" : "execution_failed", level: 3, reason: said2 ?? blocker?.cause ?? `Agent exited with code ${code}.` } : void 0;
|
|
63766
|
+
const result = spoken ? spoken.result : renderer?.result();
|
|
63767
|
+
let retryPause;
|
|
63768
|
+
let retrying = false;
|
|
63769
|
+
if (failure2 && !sub && !taskCompleted) {
|
|
63770
|
+
const attempt2 = held4.retry?.attempt ?? 1;
|
|
63771
|
+
const decision = planRetry(failure2, attempt2);
|
|
63772
|
+
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";
|
|
63774
|
+
else {
|
|
63775
|
+
const mark = runMark(sessionId, agentStartedAt);
|
|
63776
|
+
const root2 = child.pid ? { pid: child.pid, since: agentStartedAt, identity: held4.agentIdentity } : void 0;
|
|
63777
|
+
const stopped3 = () => client?.managedProcess ? connectionStopped(root2) : processesStopped(mark, root2);
|
|
63778
|
+
const until = Date.now() + STOP_GRACE_MS + STOP_CLOSE_MS;
|
|
63779
|
+
while (!stopped3() && Date.now() < until) await sleep4(100);
|
|
63780
|
+
if (!stopped3()) retryPause = "unsafe";
|
|
63781
|
+
else {
|
|
63782
|
+
const pending = decision.plan;
|
|
63783
|
+
patch(sessionId, (r) => {
|
|
63784
|
+
r.failure = failure2;
|
|
63785
|
+
r.error = said2 ?? failure2.reason;
|
|
63786
|
+
r.retry = { attempt: attempt2, of: pending.of, reason: failure2.reason, at: pending.at, since: held4.retry?.since ?? held4.startedAt, pending };
|
|
63787
|
+
});
|
|
63788
|
+
log.write(`
|
|
63789
|
+
[board] ${retryLine(pending, attempt2)}
|
|
63709
63790
|
`);
|
|
63710
|
-
|
|
63711
|
-
|
|
63712
|
-
|
|
63713
|
-
|
|
63714
|
-
if (stopped2 || peekRun(sessionId)?.stopping === true) asked = true;
|
|
63791
|
+
if (!stoppedByUser()) await sleep4(Math.max(0, pending.at - Date.now()));
|
|
63792
|
+
retrying = true;
|
|
63793
|
+
}
|
|
63794
|
+
}
|
|
63715
63795
|
}
|
|
63716
|
-
|
|
63717
|
-
|
|
63796
|
+
asked ||= stoppedByUser();
|
|
63797
|
+
retrying &&= !asked;
|
|
63798
|
+
const error62 = asked ? void 0 : joinNotes(said2 ?? failure2?.reason, retryPause ? pauseLine(retryPause) : void 0);
|
|
63799
|
+
const status = asked ? "stopped" : failed2 || code !== 0 ? "error" : "done";
|
|
63718
63800
|
const reported = spoken ? spoken.costUsd : renderer?.costUsd?.();
|
|
63719
63801
|
const totals = reportsSessionTotal(record2.harness);
|
|
63720
63802
|
const sessionTotal = totals ? reported : void 0;
|
|
@@ -63752,13 +63834,13 @@ ${result}
|
|
|
63752
63834
|
...spawnWhy ? [spawnWhy] : [],
|
|
63753
63835
|
...saidOurs ? [{ kind: "silent", args: { n: String(silenceFor) } }] : []
|
|
63754
63836
|
];
|
|
63755
|
-
const quietSaid = silenceSaid(silenceFor);
|
|
63756
63837
|
if (sub) {
|
|
63757
63838
|
await closeRun(sessionId, {
|
|
63758
63839
|
status,
|
|
63759
63840
|
ok: asked ? void 0 : status === "done",
|
|
63760
63841
|
code: asked ? null : code,
|
|
63761
|
-
error:
|
|
63842
|
+
error: error62,
|
|
63843
|
+
failure: failure2,
|
|
63762
63844
|
errorWhy,
|
|
63763
63845
|
endedAt
|
|
63764
63846
|
});
|
|
@@ -63774,7 +63856,9 @@ ${result}
|
|
|
63774
63856
|
// What went wrong, in whoever's words know: ours when the command wouldn't start or
|
|
63775
63857
|
// when it went quiet, the agent's own when the conversation ended badly or its
|
|
63776
63858
|
// stream said so. That cause leads; a card it left half-written follows.
|
|
63777
|
-
error:
|
|
63859
|
+
error: error62,
|
|
63860
|
+
failure: failure2,
|
|
63861
|
+
retryPause,
|
|
63778
63862
|
note,
|
|
63779
63863
|
errorWhy,
|
|
63780
63864
|
noteWhy,
|
|
@@ -63782,8 +63866,9 @@ ${result}
|
|
|
63782
63866
|
});
|
|
63783
63867
|
letGo();
|
|
63784
63868
|
if (retrying) {
|
|
63785
|
-
const next = await resume(sessionId);
|
|
63869
|
+
const next = await resume(sessionId, { automatic: true });
|
|
63786
63870
|
if ("error" in next) patch(sessionId, (r) => {
|
|
63871
|
+
if (r.retry) delete r.retry.pending;
|
|
63787
63872
|
r.error = joinNotes(r.error, `Could not try again: ${next.error}`);
|
|
63788
63873
|
r.errorWhy = [...r.errorWhy ?? [], { kind: "retryUnstarted", refusals: [next] }];
|
|
63789
63874
|
});
|
|
@@ -63814,9 +63899,13 @@ ${result}
|
|
|
63814
63899
|
void finish(null, asked).finally(() => process.exit(0));
|
|
63815
63900
|
});
|
|
63816
63901
|
};
|
|
63817
|
-
|
|
63902
|
+
endTerminal = () => {
|
|
63903
|
+
watchdog?.close();
|
|
63904
|
+
giveUp(false);
|
|
63905
|
+
};
|
|
63818
63906
|
const cancellation = new AbortController();
|
|
63819
63907
|
let stopped2 = false;
|
|
63908
|
+
const stoppedByUser = () => stopped2 || peekRun(sessionId)?.stopping === true;
|
|
63820
63909
|
const askToStop = () => {
|
|
63821
63910
|
if (stopped2) return;
|
|
63822
63911
|
stopped2 = true;
|
|
@@ -63942,9 +64031,10 @@ var init_watch = __esm({
|
|
|
63942
64031
|
init_wire();
|
|
63943
64032
|
init_prompts();
|
|
63944
64033
|
init_resolve();
|
|
63945
|
-
init_transient();
|
|
63946
64034
|
init_idle();
|
|
63947
64035
|
init_retry();
|
|
64036
|
+
init_failures();
|
|
64037
|
+
init_execution();
|
|
63948
64038
|
init_refine2();
|
|
63949
64039
|
init_sessions();
|
|
63950
64040
|
init_start();
|
|
@@ -64295,7 +64385,16 @@ async function followRun(sessionId, already = "", program2 = "akb", events = fal
|
|
|
64295
64385
|
seen.add(current.sessionId);
|
|
64296
64386
|
printed = 0;
|
|
64297
64387
|
const deliveryId2 = first.deliveryId ?? last.deliveryId;
|
|
64298
|
-
|
|
64388
|
+
let following = nextInFlow(first, current.sessionId, seen);
|
|
64389
|
+
if (!following && last.retry?.pending) {
|
|
64390
|
+
const resumed = await startResume(last.sessionId, { automatic: true });
|
|
64391
|
+
if ("run" in resumed) following = resumed.run;
|
|
64392
|
+
else {
|
|
64393
|
+
last = await getRun(last.sessionId) ?? last;
|
|
64394
|
+
following = nextInFlow(first, current.sessionId, seen);
|
|
64395
|
+
}
|
|
64396
|
+
}
|
|
64397
|
+
const next = following ?? (deliveryId2 ? await moveDelivery(deliveryId2, idle) : void 0);
|
|
64299
64398
|
if (next === void 0) break;
|
|
64300
64399
|
if (next === null) {
|
|
64301
64400
|
await pause(follow.pollMs);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wildcrane",
|
|
3
|
-
"version": "0.11.
|
|
4
|
-
"akbContract":
|
|
3
|
+
"version": "0.11.73",
|
|
4
|
+
"akbContract": 20,
|
|
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",
|