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