@agentchatme/codex 0.7.0 → 0.7.2
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/README.md +11 -0
- package/dist/daemon-main.js +384 -79
- package/dist/daemon-main.js.map +1 -1
- package/dist/index.js +405 -81
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4244,7 +4244,7 @@ var init_wrapper = __esm({
|
|
|
4244
4244
|
import * as fs10 from "fs";
|
|
4245
4245
|
import { parseArgs } from "util";
|
|
4246
4246
|
|
|
4247
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.7.
|
|
4247
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-5KMQ23O6.js
|
|
4248
4248
|
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
4249
4249
|
import { randomBytes } from "crypto";
|
|
4250
4250
|
import * as fs from "fs";
|
|
@@ -4252,6 +4252,7 @@ import * as path from "path";
|
|
|
4252
4252
|
import * as fs2 from "fs";
|
|
4253
4253
|
import * as os from "os";
|
|
4254
4254
|
import * as path2 from "path";
|
|
4255
|
+
import { spawn as nodeSpawn } from "child_process";
|
|
4255
4256
|
var __defProp2 = Object.defineProperty;
|
|
4256
4257
|
var __export2 = (target, all) => {
|
|
4257
4258
|
for (var name in all)
|
|
@@ -4607,7 +4608,7 @@ function runSpawned(spec, captureBytes) {
|
|
|
4607
4608
|
} catch {
|
|
4608
4609
|
}
|
|
4609
4610
|
};
|
|
4610
|
-
const classify = (code, signal, note) => {
|
|
4611
|
+
const classify = (code, signal, note, exitedAt) => {
|
|
4611
4612
|
const tail = redactDiagnostic(stderrTail);
|
|
4612
4613
|
const extra = `${note ? ` (${note})` : ""}${tail ? `: ${tail}` : ""}`;
|
|
4613
4614
|
if (timedOut) {
|
|
@@ -4620,9 +4621,10 @@ function runSpawned(spec, captureBytes) {
|
|
|
4620
4621
|
if (code === 0) return note ? { state: "ok", exitCode: 0, detail: note } : { state: "ok", exitCode: 0 };
|
|
4621
4622
|
const exit = code === null ? `signal ${signal ?? "unknown"}` : `exit ${code}`;
|
|
4622
4623
|
if (stdoutBytes === 0) {
|
|
4623
|
-
const ranMs = spawnedAt === null ? 0 :
|
|
4624
|
+
const ranMs = spawnedAt === null ? 0 : Math.max(0, exitedAt - spawnedAt);
|
|
4624
4625
|
if (spawnedAt !== null && ranMs >= notStartedWithinMs) {
|
|
4625
|
-
|
|
4626
|
+
const refused = tail.includes("API Error");
|
|
4627
|
+
return { state: "failed", ...refused ? {} : { silent: true }, exitCode: code, detail: `${exit} after ${Math.round(ranMs / 1e3)} s with nothing on stdout (it ran, then ended)${extra}` };
|
|
4626
4628
|
}
|
|
4627
4629
|
return { state: "not_started", exitCode: code, detail: `${exit} with nothing on stdout${extra}` };
|
|
4628
4630
|
}
|
|
@@ -4633,7 +4635,8 @@ function runSpawned(spec, captureBytes) {
|
|
|
4633
4635
|
return;
|
|
4634
4636
|
}
|
|
4635
4637
|
try {
|
|
4636
|
-
|
|
4638
|
+
const spawner = spec.shell === true ? nodeSpawn : spawnCommand;
|
|
4639
|
+
child = spawner(spec.command, [...spec.args], {
|
|
4637
4640
|
cwd: spec.cwd,
|
|
4638
4641
|
env: spec.env,
|
|
4639
4642
|
stdio: [spec.stdin === null ? "ignore" : "pipe", "pipe", "pipe"],
|
|
@@ -4726,21 +4729,22 @@ function runSpawned(spec, captureBytes) {
|
|
|
4726
4729
|
classify(
|
|
4727
4730
|
exited.code,
|
|
4728
4731
|
exited.signal,
|
|
4729
|
-
process.platform === "win32" ? "a process the run started kept its output open after it exited; its children were swept (taskkill) and the run detached from it \u2014 a process the sweep cannot see can survive" : "a process the run started kept its output open after it exited; the run's process group was signalled (SIGKILL) and the run detached from it \u2014 a process that left the group can survive"
|
|
4732
|
+
process.platform === "win32" ? "a process the run started kept its output open after it exited; its children were swept (taskkill) and the run detached from it \u2014 a process the sweep cannot see can survive" : "a process the run started kept its output open after it exited; the run's process group was signalled (SIGKILL) and the run detached from it \u2014 a process that left the group can survive",
|
|
4733
|
+
exited.at
|
|
4730
4734
|
)
|
|
4731
4735
|
);
|
|
4732
4736
|
});
|
|
4733
4737
|
});
|
|
4734
4738
|
proc.on("close", (code, signal) => {
|
|
4735
|
-
finish(classify(code, signal, null));
|
|
4739
|
+
finish(classify(code, signal, null, exited?.at ?? Date.now()));
|
|
4736
4740
|
});
|
|
4737
4741
|
});
|
|
4738
4742
|
}
|
|
4739
4743
|
|
|
4740
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.7.
|
|
4744
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-AQTRC7G4.js
|
|
4741
4745
|
import * as path3 from "path";
|
|
4742
4746
|
|
|
4743
|
-
// node_modules/.pnpm/agentchatme@1.5.
|
|
4747
|
+
// node_modules/.pnpm/agentchatme@1.5.1_ws@8.21.1/node_modules/agentchatme/dist/index.js
|
|
4744
4748
|
var __defProp3 = Object.defineProperty;
|
|
4745
4749
|
var __export3 = (target, all) => {
|
|
4746
4750
|
for (var name in all)
|
|
@@ -5046,7 +5050,7 @@ function createAgentChatError(body, status, headers) {
|
|
|
5046
5050
|
return new AgentChatError(body, status, requestId);
|
|
5047
5051
|
}
|
|
5048
5052
|
}
|
|
5049
|
-
var VERSION = "1.5.
|
|
5053
|
+
var VERSION = "1.5.1";
|
|
5050
5054
|
function detectRuntime() {
|
|
5051
5055
|
const g = globalThis;
|
|
5052
5056
|
if (typeof g.Bun?.version === "string") return `bun/${g.Bun.version}`;
|
|
@@ -9553,6 +9557,7 @@ function readResult(text2) {
|
|
|
9553
9557
|
}
|
|
9554
9558
|
var TRAY_LIMIT = 50;
|
|
9555
9559
|
var SILENT_MEMORY = 1e3;
|
|
9560
|
+
var CONVERSATION_KEY = "conversation:";
|
|
9556
9561
|
var PACE_MS = 6e4;
|
|
9557
9562
|
var TURN_OVERDUE_MS = 30 * 6e4;
|
|
9558
9563
|
var NO_PROGRESS_BACKOFF_MS = 1e3;
|
|
@@ -9575,30 +9580,98 @@ var Pacer = class {
|
|
|
9575
9580
|
paceMs;
|
|
9576
9581
|
now;
|
|
9577
9582
|
until = /* @__PURE__ */ new Map();
|
|
9583
|
+
/** Orders holds and tray reads: a read lifts only holds older than its start. */
|
|
9584
|
+
seq = 0;
|
|
9585
|
+
/** A D5 pace. It never replaces a could-not-process hold at the same anchor (that input stays held). */
|
|
9578
9586
|
hold(key, anchor) {
|
|
9579
|
-
this.until.
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9587
|
+
const prior = this.until.get(key);
|
|
9588
|
+
if (prior?.failure !== void 0 && prior.anchor === anchor) return;
|
|
9589
|
+
this.set(key, { anchor, until: this.now() + this.paceMs });
|
|
9590
|
+
}
|
|
9591
|
+
/** Could not process: hold the key at this anchor until a newer message moves it (held again at it: since the first time). */
|
|
9592
|
+
holdFailed(key, anchor, reason) {
|
|
9593
|
+
const prior = this.until.get(key);
|
|
9594
|
+
const since = prior?.failure !== void 0 && prior.anchor === anchor ? prior.failure.since : this.now();
|
|
9595
|
+
this.set(key, { anchor, until: Number.POSITIVE_INFINITY, failure: { reason, since, seq: ++this.seq } });
|
|
9596
|
+
}
|
|
9597
|
+
/** What holds the key at this anchor now: a pace, a could-not-process hold, or nothing (a stale entry goes). */
|
|
9598
|
+
check(key, anchor) {
|
|
9588
9599
|
const entry = this.until.get(key);
|
|
9589
|
-
if (!entry) return
|
|
9600
|
+
if (!entry) return null;
|
|
9590
9601
|
if (entry.anchor !== anchor || this.now() >= entry.until) {
|
|
9591
9602
|
this.until.delete(key);
|
|
9592
|
-
return
|
|
9603
|
+
return null;
|
|
9593
9604
|
}
|
|
9594
|
-
return
|
|
9605
|
+
return entry.failure ? "failed" : "paced";
|
|
9606
|
+
}
|
|
9607
|
+
held(key, anchor) {
|
|
9608
|
+
return this.check(key, anchor) !== null;
|
|
9609
|
+
}
|
|
9610
|
+
/** A could-not-process hold on the key at exactly this anchor; changes nothing (a queued run's anchor may be older than the card's). */
|
|
9611
|
+
heldFailedAt(key, anchor) {
|
|
9612
|
+
const entry = this.until.get(key);
|
|
9613
|
+
return entry?.failure !== void 0 && entry.anchor === anchor;
|
|
9595
9614
|
}
|
|
9615
|
+
/** Lift whatever holds the key (a pace or a could-not-process hold). */
|
|
9596
9616
|
release(key) {
|
|
9597
9617
|
this.until.delete(key);
|
|
9598
9618
|
}
|
|
9619
|
+
/** Lift a pace; a could-not-process hold stays. */
|
|
9620
|
+
releasePace(key) {
|
|
9621
|
+
if (this.until.get(key)?.failure === void 0) this.until.delete(key);
|
|
9622
|
+
}
|
|
9599
9623
|
releaseInvites() {
|
|
9600
9624
|
for (const key of [...this.until.keys()]) if (key.startsWith("invite:")) this.until.delete(key);
|
|
9601
9625
|
}
|
|
9626
|
+
/** Taken before a tray read: `keepFailedOn` lifts only holds made before it. */
|
|
9627
|
+
mark() {
|
|
9628
|
+
return this.seq;
|
|
9629
|
+
}
|
|
9630
|
+
/**
|
|
9631
|
+
* After a tray read from `mark` (`anchors`: each card's key and anchor):
|
|
9632
|
+
* a hold whose card shows another anchor is over (a newer message came),
|
|
9633
|
+
* and, on a complete tray (`complete`: not truncated), so is one whose
|
|
9634
|
+
* card is gone (read meanwhile: a verdict, a mark-read). Only holds made
|
|
9635
|
+
* before the read started: a read that began earlier says nothing of a
|
|
9636
|
+
* later hold.
|
|
9637
|
+
*/
|
|
9638
|
+
keepFailedOn(anchors, mark, complete) {
|
|
9639
|
+
for (const [key, entry] of this.until) {
|
|
9640
|
+
if (entry.failure === void 0 || entry.failure.seq > mark) continue;
|
|
9641
|
+
const shown = anchors.get(key);
|
|
9642
|
+
if (shown === void 0 ? complete : shown !== entry.anchor) this.until.delete(key);
|
|
9643
|
+
}
|
|
9644
|
+
}
|
|
9645
|
+
/** The could-not-process holds, oldest first (by `since`). */
|
|
9646
|
+
failed() {
|
|
9647
|
+
const out = [];
|
|
9648
|
+
for (const [key, entry] of this.until) {
|
|
9649
|
+
if (entry.failure !== void 0 && entry.anchor !== null) {
|
|
9650
|
+
out.push({ key, anchor: entry.anchor, reason: entry.failure.reason, since: entry.failure.since });
|
|
9651
|
+
}
|
|
9652
|
+
}
|
|
9653
|
+
return out.sort((a, b) => a.since - b.since);
|
|
9654
|
+
}
|
|
9655
|
+
set(key, entry) {
|
|
9656
|
+
this.until.delete(key);
|
|
9657
|
+
this.until.set(key, entry);
|
|
9658
|
+
let paces = 0;
|
|
9659
|
+
let holds = 0;
|
|
9660
|
+
for (const held of this.until.values()) {
|
|
9661
|
+
if (held.failure === void 0) paces += 1;
|
|
9662
|
+
else holds += 1;
|
|
9663
|
+
}
|
|
9664
|
+
for (const [key2, held] of this.until) {
|
|
9665
|
+
if (paces <= SILENT_MEMORY && holds <= SILENT_MEMORY) break;
|
|
9666
|
+
if (held.failure === void 0 && paces > SILENT_MEMORY) {
|
|
9667
|
+
this.until.delete(key2);
|
|
9668
|
+
paces -= 1;
|
|
9669
|
+
} else if (held.failure !== void 0 && holds > SILENT_MEMORY) {
|
|
9670
|
+
this.until.delete(key2);
|
|
9671
|
+
holds -= 1;
|
|
9672
|
+
}
|
|
9673
|
+
}
|
|
9674
|
+
}
|
|
9602
9675
|
};
|
|
9603
9676
|
function clears(completion, failure) {
|
|
9604
9677
|
return completion.kind === failure.source && completion.conversations.has(failure.conversationId);
|
|
@@ -9683,16 +9756,25 @@ var ReceiveLoop = class {
|
|
|
9683
9756
|
rerunsCapped: 0,
|
|
9684
9757
|
runtimeChecksOk: 0,
|
|
9685
9758
|
runtimeChecksFailed: 0,
|
|
9686
|
-
splitsStopped: 0
|
|
9759
|
+
splitsStopped: 0,
|
|
9760
|
+
startsHeld: 0
|
|
9687
9761
|
};
|
|
9688
9762
|
/** Conversations whose verdict a gate call is recording right now (an abandoned cycle's included). */
|
|
9689
9763
|
recordsInFlight = /* @__PURE__ */ new Set();
|
|
9764
|
+
/**
|
|
9765
|
+
* Could not process: conversations whose report is out on another's
|
|
9766
|
+
* completion (`takeDue`): held out of the gate and of new runs, and a run
|
|
9767
|
+
* or turn of theirs waiting for a slot waits, until the server answers.
|
|
9768
|
+
*/
|
|
9769
|
+
reporting = /* @__PURE__ */ new Map();
|
|
9690
9770
|
/** Turns holding a slot (admitted, not yet ended or released). */
|
|
9691
9771
|
slotted = /* @__PURE__ */ new Set();
|
|
9692
9772
|
handle;
|
|
9693
9773
|
started = false;
|
|
9694
9774
|
stopped = false;
|
|
9695
9775
|
heldWhileRunning = false;
|
|
9776
|
+
/** A cycle left a card out because its could-not-process report was out: `letGo` reads the tray again. */
|
|
9777
|
+
heldWhileReporting = false;
|
|
9696
9778
|
activeTurns = 0;
|
|
9697
9779
|
noProgressStreak = 0;
|
|
9698
9780
|
moreTimer = null;
|
|
@@ -9890,7 +9972,13 @@ var ReceiveLoop = class {
|
|
|
9890
9972
|
processingFailures: {
|
|
9891
9973
|
...this.failureCounts,
|
|
9892
9974
|
awaitingEvidence: this.awaitingEvidence.size,
|
|
9893
|
-
lastRuntimeCheck: this.lastRuntimeCheck === null ? null : { ...this.lastRuntimeCheck }
|
|
9975
|
+
lastRuntimeCheck: this.lastRuntimeCheck === null ? null : { ...this.lastRuntimeCheck },
|
|
9976
|
+
held: this.pacer.failed().map(({ key, anchor, reason, since }) => ({
|
|
9977
|
+
conversationId: key.slice(CONVERSATION_KEY.length),
|
|
9978
|
+
anchor,
|
|
9979
|
+
since: new Date(since).toISOString(),
|
|
9980
|
+
reason
|
|
9981
|
+
}))
|
|
9894
9982
|
},
|
|
9895
9983
|
lastError: this.lastError
|
|
9896
9984
|
};
|
|
@@ -9920,7 +10008,7 @@ var ReceiveLoop = class {
|
|
|
9920
10008
|
const id = typeof payload.conversation_id === "string" ? payload.conversation_id : void 0;
|
|
9921
10009
|
const named = Array.isArray(payload.conversation_ids) ? payload.conversation_ids.filter((x) => typeof x === "string") : [];
|
|
9922
10010
|
if (reason === "unanswered") {
|
|
9923
|
-
for (const conversationId of named) this.pacer.
|
|
10011
|
+
for (const conversationId of named) this.pacer.releasePace(`${CONVERSATION_KEY}${conversationId}`);
|
|
9924
10012
|
this.pacer.releaseInvites();
|
|
9925
10013
|
}
|
|
9926
10014
|
this.wakeFrom("wake_frame", id, {
|
|
@@ -10100,20 +10188,22 @@ var ReceiveLoop = class {
|
|
|
10100
10188
|
}
|
|
10101
10189
|
}
|
|
10102
10190
|
async gateCallCycle(run32) {
|
|
10191
|
+
const mark = this.pacer.mark();
|
|
10103
10192
|
const tray = await this.readTray();
|
|
10104
10193
|
if (run32.stale()) return this.summary("abandoned");
|
|
10105
10194
|
if (tray === null) return this.summary("tray_failed", { failure: this.lastError });
|
|
10106
10195
|
const cards = cardsOf(tray);
|
|
10196
|
+
this.forgetCleared(tray, mark);
|
|
10107
10197
|
const invites = trayInvites(tray);
|
|
10108
10198
|
const unheld = this.unheld(cards);
|
|
10109
10199
|
const heldByTurns = cards.length - unheld.length;
|
|
10110
10200
|
if (heldByTurns > 0) this.heldWhileRunning = true;
|
|
10111
|
-
const gateCards
|
|
10201
|
+
const { open: gateCards, paced: pacedCards, heldAfterFailure } = this.paceCards(unheld);
|
|
10112
10202
|
const openInvites = invites.filter((invite) => !this.tracker.inviteRunning(invite.invite_id));
|
|
10113
10203
|
const owedInvites = openInvites.filter((invite) => !this.pacer.held(`invite:${invite.invite_id}`, null));
|
|
10114
|
-
const paced =
|
|
10204
|
+
const paced = pacedCards + (openInvites.length - owedInvites.length);
|
|
10115
10205
|
const owedCards = gateCards.filter((card) => card.muted !== true);
|
|
10116
|
-
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, truncated: tray.truncated === true };
|
|
10206
|
+
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, heldAfterFailure, truncated: tray.truncated === true };
|
|
10117
10207
|
if (cards.length === 0 && invites.length === 0) return this.summary("empty", base);
|
|
10118
10208
|
if (owedCards.length === 0 && owedInvites.length === 0) return this.summary("nothing_owed", base);
|
|
10119
10209
|
const texts = await this.options.texts.ensure();
|
|
@@ -10136,7 +10226,8 @@ var ReceiveLoop = class {
|
|
|
10136
10226
|
chunksOk: 0,
|
|
10137
10227
|
chunksFailed: 0,
|
|
10138
10228
|
splitCallsOk: 0,
|
|
10139
|
-
splitCallsFailed: 0
|
|
10229
|
+
splitCallsFailed: 0,
|
|
10230
|
+
heldAfterFailure
|
|
10140
10231
|
};
|
|
10141
10232
|
let heldDuringGate = 0;
|
|
10142
10233
|
let splitStopped = false;
|
|
@@ -10145,6 +10236,7 @@ var ReceiveLoop = class {
|
|
|
10145
10236
|
if (owedCards.length > 0) {
|
|
10146
10237
|
const gate = await this.gateInChunks(run32, tray, gateCards, texts);
|
|
10147
10238
|
heldDuringGate = gate.held;
|
|
10239
|
+
tally.heldAfterFailure += gate.heldAfterFailure;
|
|
10148
10240
|
tally.gated = gate.gated;
|
|
10149
10241
|
tally.reply = gate.verdicts.reply;
|
|
10150
10242
|
tally.dismiss = gate.verdicts.dismiss;
|
|
@@ -10167,7 +10259,7 @@ var ReceiveLoop = class {
|
|
|
10167
10259
|
} else if (tally.chunksFailed + tally.splitCallsFailed > 0) {
|
|
10168
10260
|
outcome = "fail_closed";
|
|
10169
10261
|
} else if (owedInvites.length === 0 && !run32.stale()) {
|
|
10170
|
-
return this.summary("nothing_owed", { ...base, heldByTurns: heldByTurns + heldDuringGate });
|
|
10262
|
+
return this.summary("nothing_owed", { ...base, heldByTurns: heldByTurns + heldDuringGate, heldAfterFailure: tally.heldAfterFailure });
|
|
10171
10263
|
}
|
|
10172
10264
|
}
|
|
10173
10265
|
for (const invite of owedInvites) {
|
|
@@ -10184,10 +10276,54 @@ var ReceiveLoop = class {
|
|
|
10184
10276
|
/**
|
|
10185
10277
|
* Held out of the gate: a running or waiting turn, or a verdict still being
|
|
10186
10278
|
* recorded (an abandoned cycle's last call): gating it again could record
|
|
10187
|
-
* the same verdict twice (a second defer climbs the ladder).
|
|
10279
|
+
* the same verdict twice (a second defer climbs the ladder). Also a
|
|
10280
|
+
* conversation whose could-not-process report is out (`reporting`): its
|
|
10281
|
+
* answer may hold it.
|
|
10188
10282
|
*/
|
|
10189
10283
|
unheld(cards) {
|
|
10190
|
-
return this.tracker.withoutRunning(cards).filter((card) =>
|
|
10284
|
+
return this.tracker.withoutRunning(cards).filter((card) => {
|
|
10285
|
+
if (this.recordsInFlight.has(card.conversation_id)) return false;
|
|
10286
|
+
if (!this.reporting.has(card.conversation_id)) return true;
|
|
10287
|
+
this.heldWhileReporting = true;
|
|
10288
|
+
return false;
|
|
10289
|
+
});
|
|
10290
|
+
}
|
|
10291
|
+
/**
|
|
10292
|
+
* The cards neither paced (D5) nor held after a could-not-process answer
|
|
10293
|
+
* (`none` / `paused` through the anchor they still show), and how many of
|
|
10294
|
+
* each were left out. A card whose anchor moved is no longer held.
|
|
10295
|
+
*/
|
|
10296
|
+
paceCards(cards) {
|
|
10297
|
+
const open = [];
|
|
10298
|
+
let paced = 0;
|
|
10299
|
+
let heldAfterFailure = 0;
|
|
10300
|
+
for (const card of cards) {
|
|
10301
|
+
const state = this.pacer.check(`${CONVERSATION_KEY}${card.conversation_id}`, anchorFrom(card));
|
|
10302
|
+
if (state === "paced") paced += 1;
|
|
10303
|
+
else if (state === "failed") heldAfterFailure += 1;
|
|
10304
|
+
else open.push(card);
|
|
10305
|
+
}
|
|
10306
|
+
return { open, paced, heldAfterFailure };
|
|
10307
|
+
}
|
|
10308
|
+
/** Held after a could-not-process answer, at the anchor this card still shows. */
|
|
10309
|
+
heldAfterFailure(card) {
|
|
10310
|
+
return this.pacer.check(`${CONVERSATION_KEY}${card.conversation_id}`, anchorFrom(card)) === "failed";
|
|
10311
|
+
}
|
|
10312
|
+
/**
|
|
10313
|
+
* A tray read after `mark`, every card on it (a turn's included): a held
|
|
10314
|
+
* conversation whose card shows a newer anchor is no longer held, and on
|
|
10315
|
+
* a complete tray (not truncated) neither is one whose card is gone (read
|
|
10316
|
+
* meanwhile: a verdict, a mark-read). A truncated tray proves nothing
|
|
10317
|
+
* about the cards it does not show.
|
|
10318
|
+
*/
|
|
10319
|
+
forgetCleared(tray, mark) {
|
|
10320
|
+
const anchors = new Map(cardsOf(tray).map((card) => [`${CONVERSATION_KEY}${card.conversation_id}`, anchorFrom(card)]));
|
|
10321
|
+
this.pacer.keepFailedOn(anchors, mark, tray.truncated !== true);
|
|
10322
|
+
}
|
|
10323
|
+
/** The start of a run or reply turn: held after a could-not-process answer at the anchor it was started for. */
|
|
10324
|
+
failureHeld(handle) {
|
|
10325
|
+
const turn = handle.turn;
|
|
10326
|
+
return turn.kind === "reply" && this.pacer.heldFailedAt(`${CONVERSATION_KEY}${turn.conversationId}`, turn.anchor);
|
|
10191
10327
|
}
|
|
10192
10328
|
/**
|
|
10193
10329
|
* The gate in chunks (contract v1 §3.6): the cards, in tray order, split
|
|
@@ -10221,6 +10357,7 @@ var ReceiveLoop = class {
|
|
|
10221
10357
|
const out = {
|
|
10222
10358
|
gated: 0,
|
|
10223
10359
|
held: 0,
|
|
10360
|
+
heldAfterFailure: 0,
|
|
10224
10361
|
reply: [],
|
|
10225
10362
|
verdicts: { reply: 0, dismiss: 0, defer: 0 },
|
|
10226
10363
|
undecided: 0,
|
|
@@ -10266,7 +10403,9 @@ var ReceiveLoop = class {
|
|
|
10266
10403
|
const of = Math.ceil(chunked.length / size);
|
|
10267
10404
|
for (let index2 = 1; index2 <= of; index2++) {
|
|
10268
10405
|
if (run32.stale()) break;
|
|
10269
|
-
const
|
|
10406
|
+
const slice = chunked.slice((index2 - 1) * size, index2 * size);
|
|
10407
|
+
const planned = slice.filter((card) => !this.heldAfterFailure(card));
|
|
10408
|
+
out.heldAfterFailure += slice.length - planned.length;
|
|
10270
10409
|
const chunk = this.unheld(planned);
|
|
10271
10410
|
out.held += planned.length - chunk.length;
|
|
10272
10411
|
if (chunk.length < planned.length) this.heldWhileRunning = true;
|
|
@@ -10300,7 +10439,7 @@ var ReceiveLoop = class {
|
|
|
10300
10439
|
if (report.outcome === "decided") {
|
|
10301
10440
|
const through = decidedBy(result);
|
|
10302
10441
|
for (const id of through) this.gateAlone.delete(id);
|
|
10303
|
-
await run32.exclude(() => this.reportDue(this.completed("gate", through)));
|
|
10442
|
+
await run32.exclude(() => this.reportDue(this.takeDue(this.completed("gate", through))));
|
|
10304
10443
|
continue;
|
|
10305
10444
|
}
|
|
10306
10445
|
this.failedAttempt("gate", chunk.filter((card) => card.muted !== true).map((card) => card.conversation_id));
|
|
@@ -10321,7 +10460,7 @@ var ReceiveLoop = class {
|
|
|
10321
10460
|
if (run32.stale()) break splitting;
|
|
10322
10461
|
const { card, reruns } = queue.shift();
|
|
10323
10462
|
const id = card.conversation_id;
|
|
10324
|
-
if (decided.has(id) || split.skip.has(id)) continue;
|
|
10463
|
+
if (decided.has(id) || split.skip.has(id) || this.heldAfterFailure(card)) continue;
|
|
10325
10464
|
if (this.unheld([card]).length === 0) {
|
|
10326
10465
|
if (!gated.has(id)) out.held += 1;
|
|
10327
10466
|
this.heldWhileRunning = true;
|
|
@@ -10352,7 +10491,7 @@ var ReceiveLoop = class {
|
|
|
10352
10491
|
if (report.outcome === "decided") {
|
|
10353
10492
|
failuresInARow = 0;
|
|
10354
10493
|
this.gateAlone.delete(id);
|
|
10355
|
-
await run32.exclude(() => this.reportDue(this.completed("gate", decidedBy(result))));
|
|
10494
|
+
await run32.exclude(() => this.reportDue(this.takeDue(this.completed("gate", decidedBy(result)))));
|
|
10356
10495
|
continue;
|
|
10357
10496
|
}
|
|
10358
10497
|
this.rememberGateAlone(id);
|
|
@@ -10417,12 +10556,14 @@ var ReceiveLoop = class {
|
|
|
10417
10556
|
}
|
|
10418
10557
|
}
|
|
10419
10558
|
async singleRunCycle(run32) {
|
|
10559
|
+
const mark = this.pacer.mark();
|
|
10420
10560
|
const tray = await this.readTray();
|
|
10421
10561
|
if (run32.stale()) return this.summary("abandoned");
|
|
10422
10562
|
let cards = null;
|
|
10423
10563
|
let invites = null;
|
|
10424
10564
|
let base = { cards: 0, invites: 0, heldByTurns: 0, truncated: false };
|
|
10425
10565
|
if (tray !== null) {
|
|
10566
|
+
this.forgetCleared(tray, mark);
|
|
10426
10567
|
cards = cardsOf(tray).filter((card) => card.muted !== true).length;
|
|
10427
10568
|
invites = trayInvites(tray).length;
|
|
10428
10569
|
base = { cards: cardsOf(tray).length, invites, heldByTurns: 0, truncated: tray.truncated === true };
|
|
@@ -10470,17 +10611,17 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10470
10611
|
const unheld = this.unheld(cards);
|
|
10471
10612
|
const heldByTurns = cards.length - unheld.length;
|
|
10472
10613
|
if (heldByTurns > 0) this.heldWhileRunning = true;
|
|
10473
|
-
const runCards
|
|
10614
|
+
const { open: runCards, paced: pacedCards, heldAfterFailure } = this.paceCards(unheld);
|
|
10474
10615
|
const openInvites = invites.filter((invite) => !this.tracker.inviteRunning(invite.invite_id));
|
|
10475
10616
|
const owedInvites = openInvites.filter((invite) => !this.pacer.held(`invite:${invite.invite_id}`, null));
|
|
10476
|
-
const paced =
|
|
10617
|
+
const paced = pacedCards + (openInvites.length - owedInvites.length);
|
|
10477
10618
|
const owedCards = runCards.filter((card) => card.muted !== true && card.preview != null);
|
|
10478
|
-
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, truncated: tray.truncated === true };
|
|
10619
|
+
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, heldAfterFailure, truncated: tray.truncated === true };
|
|
10479
10620
|
if (owedCards.length === 0 && owedInvites.length === 0) return this.summary("nothing_owed", base);
|
|
10480
10621
|
const unready = await this.checkReady();
|
|
10481
10622
|
if (run32.stale()) return this.summary("abandoned", base);
|
|
10482
10623
|
if (unready !== null) return this.summary("tools_unavailable", { ...base, failure: unready });
|
|
10483
|
-
const tally = { turnsStarted: 0, turnsRefused: 0, turnsQueued: 0 };
|
|
10624
|
+
const tally = { turnsStarted: 0, turnsRefused: 0, turnsQueued: 0, heldAfterFailure };
|
|
10484
10625
|
const failedLast = owedCards.filter((card) => this.awaitingEvidence.has(card.conversation_id));
|
|
10485
10626
|
for (const card of owedCards.filter((card2) => !failedLast.includes(card2))) {
|
|
10486
10627
|
if (run32.stale()) break;
|
|
@@ -10524,6 +10665,8 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10524
10665
|
const held = this.tracker.holds(handle);
|
|
10525
10666
|
let completion = null;
|
|
10526
10667
|
let failure = null;
|
|
10668
|
+
let due = [];
|
|
10669
|
+
let ended = false;
|
|
10527
10670
|
try {
|
|
10528
10671
|
this.countRunEnd(end);
|
|
10529
10672
|
this.emit({ type: "run", end, kind: "conversation", conversationId: attempt.conversationId });
|
|
@@ -10537,8 +10680,10 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10537
10680
|
failure = { ...attempt, outcome: end.timedOut === true ? "timed_out" : "failed", failedAt: this.now(), holding: handle };
|
|
10538
10681
|
}
|
|
10539
10682
|
}
|
|
10683
|
+
ended = true;
|
|
10540
10684
|
} finally {
|
|
10541
10685
|
if (failure === null) this.tracker.end(handle);
|
|
10686
|
+
if (ended && !this.stopped && completion !== null) due = this.takeDue(completion);
|
|
10542
10687
|
this.releaseSlot(handle);
|
|
10543
10688
|
if (failure === null) this.afterTurnEnded();
|
|
10544
10689
|
}
|
|
@@ -10550,7 +10695,7 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10550
10695
|
this.afterTurnEnded();
|
|
10551
10696
|
}
|
|
10552
10697
|
}
|
|
10553
|
-
|
|
10698
|
+
await this.reportDue(due);
|
|
10554
10699
|
await this.checkParked("run");
|
|
10555
10700
|
}
|
|
10556
10701
|
/** The invite run: one run for the pending invites, holding each of them until it ends. */
|
|
@@ -10590,6 +10735,8 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10590
10735
|
const end = await done;
|
|
10591
10736
|
const held = this.tracker.holds(slot);
|
|
10592
10737
|
let completion = null;
|
|
10738
|
+
let due = [];
|
|
10739
|
+
let ended = false;
|
|
10593
10740
|
try {
|
|
10594
10741
|
this.countRunEnd(end);
|
|
10595
10742
|
this.emit({ type: "run", end, kind: "invite" });
|
|
@@ -10599,12 +10746,14 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10599
10746
|
for (const invite of invites) this.pacer.hold(`invite:${invite.invite_id}`, null);
|
|
10600
10747
|
}
|
|
10601
10748
|
if (this.options.dismissIgnoredInvites !== false) await this.afterRunInvites(invites, end);
|
|
10749
|
+
ended = true;
|
|
10602
10750
|
} finally {
|
|
10603
10751
|
endAll();
|
|
10752
|
+
if (ended && !this.stopped && completion !== null) due = this.takeDue(completion);
|
|
10604
10753
|
this.releaseSlot(slot);
|
|
10605
10754
|
this.afterTurnEnded();
|
|
10606
10755
|
}
|
|
10607
|
-
|
|
10756
|
+
await this.reportDue(due);
|
|
10608
10757
|
await this.checkParked("run");
|
|
10609
10758
|
}
|
|
10610
10759
|
/** The runtime's `startRun`, never rejecting: a throw is a run that did not start. */
|
|
@@ -10697,7 +10846,13 @@ invite_id: ${invite.invite_id}`,
|
|
|
10697
10846
|
* hands its slot on the same way.
|
|
10698
10847
|
*/
|
|
10699
10848
|
async launch(handle, admit, drop) {
|
|
10700
|
-
if (this.
|
|
10849
|
+
if (this.failureHeld(handle)) {
|
|
10850
|
+
this.tracker.end(handle);
|
|
10851
|
+
drop?.();
|
|
10852
|
+
this.failureCounts.startsHeld += 1;
|
|
10853
|
+
return "held";
|
|
10854
|
+
}
|
|
10855
|
+
if (this.waiting.length > 0 || this.activeTurns >= this.maxTurns || this.awaitsAnswer(handle)) {
|
|
10701
10856
|
this.waiting.push({ handle, admit, ...drop ? { drop } : {} });
|
|
10702
10857
|
this.counts.turnsQueued += 1;
|
|
10703
10858
|
if (this.activeTurns < this.maxTurns) void this.pump();
|
|
@@ -10722,16 +10877,29 @@ invite_id: ${invite.invite_id}`,
|
|
|
10722
10877
|
if (options.pump !== false) void this.pump();
|
|
10723
10878
|
}
|
|
10724
10879
|
async pump() {
|
|
10725
|
-
while (this.
|
|
10726
|
-
const
|
|
10880
|
+
while (this.activeTurns < this.maxTurns && !this.stopped) {
|
|
10881
|
+
const index = this.waiting.findIndex((w) => !this.awaitsAnswer(w.handle));
|
|
10882
|
+
if (index < 0) break;
|
|
10883
|
+
const next = this.waiting.splice(index, 1)[0];
|
|
10727
10884
|
if (!this.tracker.holds(next.handle)) continue;
|
|
10885
|
+
if (this.failureHeld(next.handle)) {
|
|
10886
|
+
this.tracker.end(next.handle);
|
|
10887
|
+
next.drop?.();
|
|
10888
|
+
this.failureCounts.startsHeld += 1;
|
|
10889
|
+
continue;
|
|
10890
|
+
}
|
|
10728
10891
|
await this.admitInSlot(next.handle, next.admit);
|
|
10729
10892
|
}
|
|
10730
10893
|
}
|
|
10894
|
+
awaitsAnswer(handle) {
|
|
10895
|
+
return handle.turn.kind === "reply" && this.reporting.has(handle.turn.conversationId);
|
|
10896
|
+
}
|
|
10731
10897
|
async afterReplyTurn(handle, attempt, done) {
|
|
10732
10898
|
const reply = attempt.reply;
|
|
10733
10899
|
let completion = null;
|
|
10734
10900
|
let failure = null;
|
|
10901
|
+
let due = [];
|
|
10902
|
+
let ended = false;
|
|
10735
10903
|
try {
|
|
10736
10904
|
const end = await this.tracker.confirmedEnd(handle, done);
|
|
10737
10905
|
if (end === null || !this.tracker.holds(handle)) return;
|
|
@@ -10741,8 +10909,10 @@ invite_id: ${invite.invite_id}`,
|
|
|
10741
10909
|
if (end.status === "failed" && recorded?.freshRead === true && recorded.outcome.reason === "turn_failed") {
|
|
10742
10910
|
failure = { ...attempt, outcome: end.timedOut === true ? "timed_out" : "failed", failedAt: this.now(), holding: handle };
|
|
10743
10911
|
}
|
|
10912
|
+
ended = true;
|
|
10744
10913
|
} finally {
|
|
10745
10914
|
if (failure === null) this.tracker.end(handle);
|
|
10915
|
+
if (ended && !this.stopped && completion !== null) due = this.takeDue(completion);
|
|
10746
10916
|
this.releaseSlot(handle);
|
|
10747
10917
|
if (failure === null) this.afterTurnEnded();
|
|
10748
10918
|
}
|
|
@@ -10754,7 +10924,7 @@ invite_id: ${invite.invite_id}`,
|
|
|
10754
10924
|
this.afterTurnEnded();
|
|
10755
10925
|
}
|
|
10756
10926
|
}
|
|
10757
|
-
|
|
10927
|
+
await this.track(this.reportDue(due));
|
|
10758
10928
|
await this.track(this.checkParked("turn"));
|
|
10759
10929
|
}
|
|
10760
10930
|
async recordReplyOutcome(handle, reply, end) {
|
|
@@ -10876,11 +11046,15 @@ invite_id: ${invite.invite_id}`,
|
|
|
10876
11046
|
return completion;
|
|
10877
11047
|
}
|
|
10878
11048
|
/**
|
|
10879
|
-
*
|
|
10880
|
-
*
|
|
10881
|
-
*
|
|
11049
|
+
* The failures this completion is the evidence for (each once), taken off
|
|
11050
|
+
* the waiting list. Their conversations are held from now until the
|
|
11051
|
+
* server has answered (`reporting`): no gate, and a run or turn of theirs
|
|
11052
|
+
* waiting for a slot waits for the answer, so it never starts on the input
|
|
11053
|
+
* the answer is about. Take them before the completed work's slot frees.
|
|
11054
|
+
* One that waited past `AWAITING_EVIDENCE_MS` is dropped instead: a
|
|
11055
|
+
* completion that late says little about the runtime when it failed.
|
|
10882
11056
|
*/
|
|
10883
|
-
|
|
11057
|
+
takeDue(completion) {
|
|
10884
11058
|
const now2 = this.now();
|
|
10885
11059
|
const due = [];
|
|
10886
11060
|
for (const failure of [...this.awaitingEvidence.values()]) {
|
|
@@ -10890,10 +11064,49 @@ invite_id: ${invite.invite_id}`,
|
|
|
10890
11064
|
}
|
|
10891
11065
|
if (evidences(completion, failure)) {
|
|
10892
11066
|
this.awaitingEvidence.delete(failure.conversationId);
|
|
11067
|
+
this.holdForReport(failure);
|
|
10893
11068
|
due.push(failure);
|
|
10894
11069
|
}
|
|
10895
11070
|
}
|
|
10896
|
-
|
|
11071
|
+
return due;
|
|
11072
|
+
}
|
|
11073
|
+
/** Report what `takeDue` took, letting go of each conversation once its answer is in: what waits for it goes on (or was dropped). */
|
|
11074
|
+
async reportDue(due) {
|
|
11075
|
+
const held = [...due];
|
|
11076
|
+
try {
|
|
11077
|
+
while (held.length > 0) {
|
|
11078
|
+
const failure = held[0];
|
|
11079
|
+
await this.reportFailure(failure, "other_run_completed");
|
|
11080
|
+
held.shift();
|
|
11081
|
+
this.letGo([failure]);
|
|
11082
|
+
}
|
|
11083
|
+
} finally {
|
|
11084
|
+
this.letGo(held);
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
11087
|
+
/** A report for this failure is due: its conversation is held until `letGo` (counted: two reports out hold it until both are answered). */
|
|
11088
|
+
holdForReport(failure) {
|
|
11089
|
+
this.reporting.set(failure.conversationId, (this.reporting.get(failure.conversationId) ?? 0) + 1);
|
|
11090
|
+
}
|
|
11091
|
+
/**
|
|
11092
|
+
* The answers are in (or the report is off): those conversations are no
|
|
11093
|
+
* longer held for it, what waits for them goes on, and a card a cycle left
|
|
11094
|
+
* out meanwhile for a report is read again (only then: a wake for
|
|
11095
|
+
* anything else could spin while a turn runs).
|
|
11096
|
+
*/
|
|
11097
|
+
letGo(failures) {
|
|
11098
|
+
if (failures.length === 0) return;
|
|
11099
|
+
for (const { conversationId } of failures) {
|
|
11100
|
+
const left = (this.reporting.get(conversationId) ?? 0) - 1;
|
|
11101
|
+
if (left > 0) this.reporting.set(conversationId, left);
|
|
11102
|
+
else this.reporting.delete(conversationId);
|
|
11103
|
+
}
|
|
11104
|
+
if (this.stopped) return;
|
|
11105
|
+
if (this.waiting.length > 0) void this.pump();
|
|
11106
|
+
if (this.heldWhileReporting) {
|
|
11107
|
+
this.heldWhileReporting = false;
|
|
11108
|
+
this.wakeFrom("more");
|
|
11109
|
+
}
|
|
10897
11110
|
}
|
|
10898
11111
|
/** An attempt of this kind failed for these conversations (whatever comes of it): see `failingSince`. */
|
|
10899
11112
|
failedAttempt(kind, conversations) {
|
|
@@ -10946,17 +11159,24 @@ invite_id: ${invite.invite_id}`,
|
|
|
10946
11159
|
failure.outcome !== "timed_out" && !this.checkedFailures.has(failure) && this.now() - failure.failedAt <= AWAITING_EVIDENCE_MS && [...failing].every((id) => id === failure.conversationId)
|
|
10947
11160
|
);
|
|
10948
11161
|
if (due.length === 0) return;
|
|
10949
|
-
for (const failure of due) this.checkedFailures.add(failure);
|
|
10950
|
-
const ok = await this.runtimeCheck();
|
|
10951
11162
|
for (const failure of due) {
|
|
10952
|
-
|
|
10953
|
-
|
|
11163
|
+
this.checkedFailures.add(failure);
|
|
11164
|
+
this.holdForReport(failure);
|
|
11165
|
+
}
|
|
11166
|
+
try {
|
|
11167
|
+
const ok = await this.runtimeCheck();
|
|
11168
|
+
for (const failure of due) {
|
|
11169
|
+
if (this.stopped || this.awaitingEvidence.get(failure.conversationId) !== failure) continue;
|
|
11170
|
+
if (!ok) {
|
|
11171
|
+
this.awaitingEvidence.delete(failure.conversationId);
|
|
11172
|
+
continue;
|
|
11173
|
+
}
|
|
11174
|
+
if (![...failing].every((id) => id === failure.conversationId)) continue;
|
|
10954
11175
|
this.awaitingEvidence.delete(failure.conversationId);
|
|
10955
|
-
|
|
11176
|
+
await this.reportFailure(failure, "runtime_check");
|
|
10956
11177
|
}
|
|
10957
|
-
|
|
10958
|
-
this.
|
|
10959
|
-
await this.reportFailure(failure, "runtime_check");
|
|
11178
|
+
} finally {
|
|
11179
|
+
this.letGo(due);
|
|
10960
11180
|
}
|
|
10961
11181
|
}
|
|
10962
11182
|
/** Nothing of this kind is running or queued: the runtime check may be asked now. */
|
|
@@ -11030,10 +11250,29 @@ invite_id: ${invite.invite_id}`,
|
|
|
11030
11250
|
next = this.rerun(failure, result.action === "hidden");
|
|
11031
11251
|
}
|
|
11032
11252
|
}
|
|
11033
|
-
if (result.action === "paused") this.
|
|
11253
|
+
if (result.action === "none" || result.action === "paused") this.holdFailed(failure, result.action);
|
|
11034
11254
|
if (next === "stop" || next === "rerun_capped") this.activeSplit?.skip.add(failure.conversationId);
|
|
11035
11255
|
this.emit({ type: "processing_failure", ...base, result, next });
|
|
11036
11256
|
}
|
|
11257
|
+
/**
|
|
11258
|
+
* The server answered `none` or `paused`: the conversation is held at the
|
|
11259
|
+
* anchor the report read through, so no later cycle (a message elsewhere,
|
|
11260
|
+
* a wake frame, a reconnect, an `unanswered` re-wake, a turn's end) runs it
|
|
11261
|
+
* again on the same input. A newer message moves its anchor and lifts the
|
|
11262
|
+
* hold (`paceCards`); a card read meanwhile leaves the tray, and the hold
|
|
11263
|
+
* with it (`forgetCleared`). What waits for it does not start: a run or
|
|
11264
|
+
* reply turn queued at that anchor (after `paused`, the server's mute, any),
|
|
11265
|
+
* and a reply turn to start again after the gate.
|
|
11266
|
+
*/
|
|
11267
|
+
holdFailed(failure, reason) {
|
|
11268
|
+
const id = failure.conversationId;
|
|
11269
|
+
const anchor = failure.anchor;
|
|
11270
|
+
this.pacer.holdFailed(`${CONVERSATION_KEY}${id}`, anchor, reason);
|
|
11271
|
+
this.dropWaiting(id, reason === "paused" ? null : anchor);
|
|
11272
|
+
this.turnRerunsAfterGate = this.turnRerunsAfterGate.filter(
|
|
11273
|
+
({ reply }) => reply.conversationId !== id || reason !== "paused" && anchorFrom(reply.card) !== anchor
|
|
11274
|
+
);
|
|
11275
|
+
}
|
|
11037
11276
|
/**
|
|
11038
11277
|
* Run the conversation again after a `retry` or `hidden` answer, after the
|
|
11039
11278
|
* others already queued, and say what was done. Its run or reply turn takes
|
|
@@ -11091,14 +11330,20 @@ invite_id: ${invite.invite_id}`,
|
|
|
11091
11330
|
else void this.startReplyTurn(reply, texts, reruns);
|
|
11092
11331
|
}
|
|
11093
11332
|
}
|
|
11094
|
-
/**
|
|
11095
|
-
|
|
11333
|
+
/**
|
|
11334
|
+
* A held conversation: a run or turn still waiting for a slot for it does
|
|
11335
|
+
* not start; with an `anchor`, only one for that anchor (one queued for a
|
|
11336
|
+
* newer message is new input, and goes on).
|
|
11337
|
+
*/
|
|
11338
|
+
dropWaiting(conversationId, anchor) {
|
|
11096
11339
|
for (const entry of [...this.waiting]) {
|
|
11097
11340
|
const turn = entry.handle.turn;
|
|
11098
11341
|
if (turn.kind !== "reply" || turn.conversationId !== conversationId) continue;
|
|
11342
|
+
if (anchor !== null && turn.anchor !== anchor) continue;
|
|
11099
11343
|
this.waiting.splice(this.waiting.indexOf(entry), 1);
|
|
11100
11344
|
this.tracker.end(entry.handle);
|
|
11101
11345
|
entry.drop?.();
|
|
11346
|
+
this.failureCounts.startsHeld += 1;
|
|
11102
11347
|
}
|
|
11103
11348
|
}
|
|
11104
11349
|
rememberGateAlone(conversationId) {
|
|
@@ -11147,6 +11392,7 @@ invite_id: ${invite.invite_id}`,
|
|
|
11147
11392
|
turnsQueued: 0,
|
|
11148
11393
|
heldByTurns: 0,
|
|
11149
11394
|
paced: 0,
|
|
11395
|
+
heldAfterFailure: 0,
|
|
11150
11396
|
chunksOk: 0,
|
|
11151
11397
|
chunksFailed: 0,
|
|
11152
11398
|
splitCallsOk: 0,
|
|
@@ -11242,6 +11488,7 @@ function timeoutOption(value, fallback, name) {
|
|
|
11242
11488
|
return value;
|
|
11243
11489
|
}
|
|
11244
11490
|
function launchKey(launch) {
|
|
11491
|
+
if (launch === "held") return "heldAfterFailure";
|
|
11245
11492
|
return launch === "started" ? "turnsStarted" : launch === "queued" ? "turnsQueued" : "turnsRefused";
|
|
11246
11493
|
}
|
|
11247
11494
|
function trayInvites(tray) {
|
|
@@ -11727,7 +11974,7 @@ var DAY = 24 * HOUR;
|
|
|
11727
11974
|
var INBOX_TRAY_MAX_LIMIT = 50;
|
|
11728
11975
|
var MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
|
|
11729
11976
|
|
|
11730
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.7.
|
|
11977
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-AQTRC7G4.js
|
|
11731
11978
|
import * as fs3 from "fs";
|
|
11732
11979
|
import * as path22 from "path";
|
|
11733
11980
|
import { createHash } from "crypto";
|
|
@@ -16206,6 +16453,21 @@ function integrationStatusAge(status, now2 = Date.now()) {
|
|
|
16206
16453
|
const t = Date.parse(status.updated_at);
|
|
16207
16454
|
return Number.isNaN(t) ? null : Math.max(0, now2 - t);
|
|
16208
16455
|
}
|
|
16456
|
+
var INTEGRATION_STATUS_STALE_MS = 3 * 6e4;
|
|
16457
|
+
function integrationStatusFresh(status, now2 = Date.now()) {
|
|
16458
|
+
const age = integrationStatusAge(status, now2);
|
|
16459
|
+
return age !== null && age <= INTEGRATION_STATUS_STALE_MS;
|
|
16460
|
+
}
|
|
16461
|
+
function integrationStatusStaleFor(status, now2 = Date.now()) {
|
|
16462
|
+
const age = integrationStatusAge(status, now2);
|
|
16463
|
+
return age === null ? "an unknown time" : forWhile(age);
|
|
16464
|
+
}
|
|
16465
|
+
function forWhile(ms) {
|
|
16466
|
+
if (ms < 9e4) return "about a minute";
|
|
16467
|
+
if (ms < 45 * 6e4) return `${Math.round(ms / 6e4)} minutes`;
|
|
16468
|
+
if (ms < 36 * 36e5) return `${Math.round(ms / 36e5)} hour(s)`;
|
|
16469
|
+
return `${Math.round(ms / 864e5)} day(s)`;
|
|
16470
|
+
}
|
|
16209
16471
|
function ago(ms) {
|
|
16210
16472
|
if (ms < 45e3) return "just now";
|
|
16211
16473
|
if (ms < 9e4) return "1 minute ago";
|
|
@@ -16272,7 +16534,7 @@ function textsLine(texts, now2) {
|
|
|
16272
16534
|
function formatIntegrationStatus(status, now2 = Date.now()) {
|
|
16273
16535
|
if (status === null) return ["Integration: no status recorded yet (the daemon has not run, or is still starting)"];
|
|
16274
16536
|
const age = integrationStatusAge(status, now2);
|
|
16275
|
-
const stale = age !== null && age >
|
|
16537
|
+
const stale = age !== null && age > INTEGRATION_STATUS_STALE_MS;
|
|
16276
16538
|
const standby = status.standby ?? null;
|
|
16277
16539
|
const failing = status.runs_failing ?? null;
|
|
16278
16540
|
const unservable = status.unservable ?? null;
|
|
@@ -16476,8 +16738,8 @@ function agentLockDir(env = process.env, system = process.platform, home = os22.
|
|
|
16476
16738
|
return p.join(home, ".local", "state", "agentchat", "locks");
|
|
16477
16739
|
}
|
|
16478
16740
|
|
|
16479
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.7.
|
|
16480
|
-
var VERSION2 = "0.7.
|
|
16741
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-4PCDVXAR.js
|
|
16742
|
+
var VERSION2 = "0.7.1";
|
|
16481
16743
|
var HOSTED_MCP_PATH2 = integration_exports.HOSTED_MCP_PATH;
|
|
16482
16744
|
function hostedMcpUrl2(apiBase) {
|
|
16483
16745
|
return integration_exports.hostedMcpUrl(apiBase);
|
|
@@ -16553,7 +16815,7 @@ function runProbe(command, args, options) {
|
|
|
16553
16815
|
});
|
|
16554
16816
|
}
|
|
16555
16817
|
|
|
16556
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.7.
|
|
16818
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/index.js
|
|
16557
16819
|
import * as fs5 from "fs";
|
|
16558
16820
|
import * as path6 from "path";
|
|
16559
16821
|
import * as readline from "readline";
|
|
@@ -17517,11 +17779,17 @@ The key was not saved.`);
|
|
|
17517
17779
|
if (paused !== null) {
|
|
17518
17780
|
checks.push({ name: "could-not-process", verdict: "WARN", detail: paused.replace(/^could not process: /, "") });
|
|
17519
17781
|
} else if (lastCheck !== null && runtimeCheckFailingNow(integration)) {
|
|
17520
|
-
checks.push(
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17782
|
+
checks.push(
|
|
17783
|
+
integrationStatusFresh(integration) ? {
|
|
17784
|
+
name: "could-not-process",
|
|
17785
|
+
verdict: "WARN",
|
|
17786
|
+
detail: `the runtime check failed (${lastCheck.detail ?? "no detail"}; ${lastCheck.at}): while it fails, a conversation whose run fails is not reported, its card stays on the tray and the server wakes the agent again`
|
|
17787
|
+
} : {
|
|
17788
|
+
name: "could-not-process",
|
|
17789
|
+
verdict: "WARN",
|
|
17790
|
+
detail: `the daemon has not written its status for ${integrationStatusStaleFor(integration)} \u2014 it may be down (a running daemon rewrites it every 30 s); the runtime check that failed at ${lastCheck.at} says nothing about now`
|
|
17791
|
+
}
|
|
17792
|
+
);
|
|
17525
17793
|
} else if (counts !== null) {
|
|
17526
17794
|
checks.push({ name: "could-not-process", verdict: "PASS", detail: counts.replace(/^could not process: /, "") });
|
|
17527
17795
|
}
|
|
@@ -18179,7 +18447,7 @@ import * as os4 from "os";
|
|
|
18179
18447
|
import * as path7 from "path";
|
|
18180
18448
|
|
|
18181
18449
|
// src/version.ts
|
|
18182
|
-
var VERSION3 = "0.7.
|
|
18450
|
+
var VERSION3 = "0.7.2";
|
|
18183
18451
|
|
|
18184
18452
|
// src/host.ts
|
|
18185
18453
|
function codexHome() {
|
|
@@ -18841,7 +19109,7 @@ function formatPlacement(steps) {
|
|
|
18841
19109
|
// src/identity.ts
|
|
18842
19110
|
import * as path13 from "path";
|
|
18843
19111
|
|
|
18844
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.7.
|
|
19112
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/presets.js
|
|
18845
19113
|
import * as fs24 from "fs";
|
|
18846
19114
|
import * as os5 from "os";
|
|
18847
19115
|
import * as path11 from "path";
|
|
@@ -19175,8 +19443,18 @@ function claudeProfileArgs(profile2, workdir) {
|
|
|
19175
19443
|
}
|
|
19176
19444
|
var RUNTIME_CHECK_SETTINGS = JSON.stringify({
|
|
19177
19445
|
env: { CLAUDE_CODE_DISABLE_CLAUDE_MDS: "1", CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" },
|
|
19178
|
-
disableAllHooks: true
|
|
19446
|
+
disableAllHooks: true,
|
|
19447
|
+
verbose: false,
|
|
19448
|
+
viewMode: "default",
|
|
19449
|
+
language: "english"
|
|
19179
19450
|
});
|
|
19451
|
+
function lastResultMessage(messages) {
|
|
19452
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
19453
|
+
const m = messages[i];
|
|
19454
|
+
if (m !== null && typeof m === "object" && !Array.isArray(m) && m["type"] === "result") return m;
|
|
19455
|
+
}
|
|
19456
|
+
return null;
|
|
19457
|
+
}
|
|
19180
19458
|
function claudeRuntimeCheckJudge(stdout) {
|
|
19181
19459
|
const text2 = stdout.trim();
|
|
19182
19460
|
let parsed = null;
|
|
@@ -19188,9 +19466,22 @@ function claudeRuntimeCheckJudge(stdout) {
|
|
|
19188
19466
|
parsed = null;
|
|
19189
19467
|
}
|
|
19190
19468
|
}
|
|
19469
|
+
if (Array.isArray(parsed)) {
|
|
19470
|
+
parsed = lastResultMessage(parsed);
|
|
19471
|
+
if (parsed === null) return "its answer is a list of messages with no result";
|
|
19472
|
+
}
|
|
19191
19473
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return "its answer is not a JSON result";
|
|
19192
19474
|
const r = parsed;
|
|
19193
|
-
if (r["type"] === "result" && r["subtype"] === "success" && r["is_error"] === false)
|
|
19475
|
+
if (r["type"] === "result" && r["subtype"] === "success" && r["is_error"] === false) {
|
|
19476
|
+
const turns = r["num_turns"];
|
|
19477
|
+
if (typeof turns !== "number" || !(turns >= 1)) return `the result has no turn (num_turns ${typeof turns === "number" ? turns : "?"})`;
|
|
19478
|
+
const usage = r["usage"];
|
|
19479
|
+
if (usage !== void 0 && usage !== null) {
|
|
19480
|
+
const tokens = typeof usage === "object" && !Array.isArray(usage) ? usage["output_tokens"] : void 0;
|
|
19481
|
+
if (typeof tokens !== "number" || !(tokens >= 1)) return `the result has no output (usage.output_tokens ${typeof tokens === "number" ? tokens : "?"})`;
|
|
19482
|
+
}
|
|
19483
|
+
return null;
|
|
19484
|
+
}
|
|
19194
19485
|
const facts = [
|
|
19195
19486
|
`type ${typeof r["type"] === "string" ? r["type"] : "?"}`,
|
|
19196
19487
|
`subtype ${typeof r["subtype"] === "string" ? r["subtype"] : "?"}`,
|
|
@@ -19676,8 +19967,6 @@ function codexRuntimeCheckArgs(dir, agentchatUrl) {
|
|
|
19676
19967
|
"--sandbox",
|
|
19677
19968
|
"read-only",
|
|
19678
19969
|
"-c",
|
|
19679
|
-
'model_reasoning_effort="low"',
|
|
19680
|
-
"-c",
|
|
19681
19970
|
'web_search="disabled"',
|
|
19682
19971
|
...CODEX_RUNTIME_CHECK_DISABLED_FEATURES.flatMap((feature) => ["--disable", feature]),
|
|
19683
19972
|
...agentchatUrl !== void 0 ? ["-c", `${table}.url=${JSON.stringify(agentchatUrl)}`] : [],
|
|
@@ -19689,6 +19978,37 @@ function codexRuntimeCheckArgs(dir, agentchatUrl) {
|
|
|
19689
19978
|
function codexRuntimeCheckWorkdir(codexHome2) {
|
|
19690
19979
|
return path24.join(codexHome2, RUNTIME_CHECK_DIR);
|
|
19691
19980
|
}
|
|
19981
|
+
function jsonObject(value) {
|
|
19982
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
19983
|
+
}
|
|
19984
|
+
function codexRuntimeCheckJudge(stdout) {
|
|
19985
|
+
let events = 0;
|
|
19986
|
+
let completed = false;
|
|
19987
|
+
let failed = false;
|
|
19988
|
+
let answered = false;
|
|
19989
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
19990
|
+
if (line.trim().length === 0) continue;
|
|
19991
|
+
let event;
|
|
19992
|
+
try {
|
|
19993
|
+
event = jsonObject(JSON.parse(line));
|
|
19994
|
+
} catch {
|
|
19995
|
+
continue;
|
|
19996
|
+
}
|
|
19997
|
+
if (event === null) continue;
|
|
19998
|
+
events += 1;
|
|
19999
|
+
if (event["type"] === "turn.completed") completed = true;
|
|
20000
|
+
else if (event["type"] === "turn.failed") failed = true;
|
|
20001
|
+
else if (event["type"] === "item.completed") {
|
|
20002
|
+
const item = jsonObject(event["item"]);
|
|
20003
|
+
if (item !== null && item["type"] === "agent_message" && typeof item["text"] === "string" && item["text"].trim().length > 0) answered = true;
|
|
20004
|
+
}
|
|
20005
|
+
}
|
|
20006
|
+
if (events === 0) return "its answer holds no JSON event";
|
|
20007
|
+
if (failed) return "the turn failed (turn.failed)";
|
|
20008
|
+
if (!completed) return "the turn did not complete (no turn.completed)";
|
|
20009
|
+
if (!answered) return "the turn completed with no agent message";
|
|
20010
|
+
return null;
|
|
20011
|
+
}
|
|
19692
20012
|
function codexClientHeadersToml(clientVersion = VERSION2) {
|
|
19693
20013
|
const pairs = Object.entries(clientHeadersOf({ runtime: "codex", version: clientVersion })).map(([name, value]) => `${JSON.stringify(name)} = ${JSON.stringify(value)}`);
|
|
19694
20014
|
return `{ ${pairs.join(", ")} }`;
|
|
@@ -20014,9 +20334,11 @@ var CodexRunner = class {
|
|
|
20014
20334
|
/**
|
|
20015
20335
|
* Does the model answer right now, through this runner's binary, sign-in,
|
|
20016
20336
|
* CODEX_HOME and environment? One `codex exec` with a fixed prompt in its
|
|
20017
|
-
* own empty folder, read-only, with the hosted AgentChat server switched
|
|
20018
|
-
*
|
|
20019
|
-
*
|
|
20337
|
+
* own empty folder, read-only, with the hosted AgentChat server switched
|
|
20338
|
+
* off and the user's hooks on, as in the runs (`codexRuntimeCheckArgs`),
|
|
20339
|
+
* and no key in its environment; ok only on exit 0 with a completed turn
|
|
20340
|
+
* that holds an agent message (`codexRuntimeCheckJudge`). Its output is
|
|
20341
|
+
* read for that alone and never logged. Never throws.
|
|
20020
20342
|
*/
|
|
20021
20343
|
async checkRuntime(options = {}) {
|
|
20022
20344
|
if (this.options.refuse !== void 0) return { ok: false, detail: this.options.refuse };
|
|
@@ -20029,6 +20351,8 @@ var CodexRunner = class {
|
|
|
20029
20351
|
// The runs' environment; runRuntimeCheck takes every key variable out, this runner's own included.
|
|
20030
20352
|
env: this.env(),
|
|
20031
20353
|
keyEnv: this.options.keyEnv,
|
|
20354
|
+
// Exit 0 is not enough: the events must show a completed turn with the model's answer.
|
|
20355
|
+
judge: codexRuntimeCheckJudge,
|
|
20032
20356
|
...options.signal !== void 0 ? { signal: options.signal } : {}
|
|
20033
20357
|
});
|
|
20034
20358
|
}
|