@agentchatme/codex 0.7.1 → 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 +298 -55
- package/dist/daemon-main.js.map +1 -1
- package/dist/index.js +298 -55
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/daemon-main.js
CHANGED
|
@@ -4709,7 +4709,7 @@ function runSpawned(spec, captureBytes) {
|
|
|
4709
4709
|
// node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-AQTRC7G4.js
|
|
4710
4710
|
import * as path3 from "path";
|
|
4711
4711
|
|
|
4712
|
-
// node_modules/.pnpm/agentchatme@1.5.
|
|
4712
|
+
// node_modules/.pnpm/agentchatme@1.5.1_ws@8.21.1/node_modules/agentchatme/dist/index.js
|
|
4713
4713
|
var __defProp3 = Object.defineProperty;
|
|
4714
4714
|
var __export3 = (target, all) => {
|
|
4715
4715
|
for (var name in all)
|
|
@@ -5015,7 +5015,7 @@ function createAgentChatError(body, status, headers) {
|
|
|
5015
5015
|
return new AgentChatError(body, status, requestId);
|
|
5016
5016
|
}
|
|
5017
5017
|
}
|
|
5018
|
-
var VERSION = "1.5.
|
|
5018
|
+
var VERSION = "1.5.1";
|
|
5019
5019
|
function detectRuntime() {
|
|
5020
5020
|
const g = globalThis;
|
|
5021
5021
|
if (typeof g.Bun?.version === "string") return `bun/${g.Bun.version}`;
|
|
@@ -9522,6 +9522,7 @@ function readResult(text2) {
|
|
|
9522
9522
|
}
|
|
9523
9523
|
var TRAY_LIMIT = 50;
|
|
9524
9524
|
var SILENT_MEMORY = 1e3;
|
|
9525
|
+
var CONVERSATION_KEY = "conversation:";
|
|
9525
9526
|
var PACE_MS = 6e4;
|
|
9526
9527
|
var TURN_OVERDUE_MS = 30 * 6e4;
|
|
9527
9528
|
var NO_PROGRESS_BACKOFF_MS = 1e3;
|
|
@@ -9544,30 +9545,98 @@ var Pacer = class {
|
|
|
9544
9545
|
paceMs;
|
|
9545
9546
|
now;
|
|
9546
9547
|
until = /* @__PURE__ */ new Map();
|
|
9548
|
+
/** Orders holds and tray reads: a read lifts only holds older than its start. */
|
|
9549
|
+
seq = 0;
|
|
9550
|
+
/** A D5 pace. It never replaces a could-not-process hold at the same anchor (that input stays held). */
|
|
9547
9551
|
hold(key, anchor) {
|
|
9548
|
-
this.until.
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9552
|
+
const prior = this.until.get(key);
|
|
9553
|
+
if (prior?.failure !== void 0 && prior.anchor === anchor) return;
|
|
9554
|
+
this.set(key, { anchor, until: this.now() + this.paceMs });
|
|
9555
|
+
}
|
|
9556
|
+
/** Could not process: hold the key at this anchor until a newer message moves it (held again at it: since the first time). */
|
|
9557
|
+
holdFailed(key, anchor, reason) {
|
|
9558
|
+
const prior = this.until.get(key);
|
|
9559
|
+
const since = prior?.failure !== void 0 && prior.anchor === anchor ? prior.failure.since : this.now();
|
|
9560
|
+
this.set(key, { anchor, until: Number.POSITIVE_INFINITY, failure: { reason, since, seq: ++this.seq } });
|
|
9561
|
+
}
|
|
9562
|
+
/** What holds the key at this anchor now: a pace, a could-not-process hold, or nothing (a stale entry goes). */
|
|
9563
|
+
check(key, anchor) {
|
|
9557
9564
|
const entry = this.until.get(key);
|
|
9558
|
-
if (!entry) return
|
|
9565
|
+
if (!entry) return null;
|
|
9559
9566
|
if (entry.anchor !== anchor || this.now() >= entry.until) {
|
|
9560
9567
|
this.until.delete(key);
|
|
9561
|
-
return
|
|
9568
|
+
return null;
|
|
9562
9569
|
}
|
|
9563
|
-
return
|
|
9570
|
+
return entry.failure ? "failed" : "paced";
|
|
9564
9571
|
}
|
|
9572
|
+
held(key, anchor) {
|
|
9573
|
+
return this.check(key, anchor) !== null;
|
|
9574
|
+
}
|
|
9575
|
+
/** 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). */
|
|
9576
|
+
heldFailedAt(key, anchor) {
|
|
9577
|
+
const entry = this.until.get(key);
|
|
9578
|
+
return entry?.failure !== void 0 && entry.anchor === anchor;
|
|
9579
|
+
}
|
|
9580
|
+
/** Lift whatever holds the key (a pace or a could-not-process hold). */
|
|
9565
9581
|
release(key) {
|
|
9566
9582
|
this.until.delete(key);
|
|
9567
9583
|
}
|
|
9584
|
+
/** Lift a pace; a could-not-process hold stays. */
|
|
9585
|
+
releasePace(key) {
|
|
9586
|
+
if (this.until.get(key)?.failure === void 0) this.until.delete(key);
|
|
9587
|
+
}
|
|
9568
9588
|
releaseInvites() {
|
|
9569
9589
|
for (const key of [...this.until.keys()]) if (key.startsWith("invite:")) this.until.delete(key);
|
|
9570
9590
|
}
|
|
9591
|
+
/** Taken before a tray read: `keepFailedOn` lifts only holds made before it. */
|
|
9592
|
+
mark() {
|
|
9593
|
+
return this.seq;
|
|
9594
|
+
}
|
|
9595
|
+
/**
|
|
9596
|
+
* After a tray read from `mark` (`anchors`: each card's key and anchor):
|
|
9597
|
+
* a hold whose card shows another anchor is over (a newer message came),
|
|
9598
|
+
* and, on a complete tray (`complete`: not truncated), so is one whose
|
|
9599
|
+
* card is gone (read meanwhile: a verdict, a mark-read). Only holds made
|
|
9600
|
+
* before the read started: a read that began earlier says nothing of a
|
|
9601
|
+
* later hold.
|
|
9602
|
+
*/
|
|
9603
|
+
keepFailedOn(anchors, mark, complete) {
|
|
9604
|
+
for (const [key, entry] of this.until) {
|
|
9605
|
+
if (entry.failure === void 0 || entry.failure.seq > mark) continue;
|
|
9606
|
+
const shown = anchors.get(key);
|
|
9607
|
+
if (shown === void 0 ? complete : shown !== entry.anchor) this.until.delete(key);
|
|
9608
|
+
}
|
|
9609
|
+
}
|
|
9610
|
+
/** The could-not-process holds, oldest first (by `since`). */
|
|
9611
|
+
failed() {
|
|
9612
|
+
const out = [];
|
|
9613
|
+
for (const [key, entry] of this.until) {
|
|
9614
|
+
if (entry.failure !== void 0 && entry.anchor !== null) {
|
|
9615
|
+
out.push({ key, anchor: entry.anchor, reason: entry.failure.reason, since: entry.failure.since });
|
|
9616
|
+
}
|
|
9617
|
+
}
|
|
9618
|
+
return out.sort((a, b) => a.since - b.since);
|
|
9619
|
+
}
|
|
9620
|
+
set(key, entry) {
|
|
9621
|
+
this.until.delete(key);
|
|
9622
|
+
this.until.set(key, entry);
|
|
9623
|
+
let paces = 0;
|
|
9624
|
+
let holds = 0;
|
|
9625
|
+
for (const held of this.until.values()) {
|
|
9626
|
+
if (held.failure === void 0) paces += 1;
|
|
9627
|
+
else holds += 1;
|
|
9628
|
+
}
|
|
9629
|
+
for (const [key2, held] of this.until) {
|
|
9630
|
+
if (paces <= SILENT_MEMORY && holds <= SILENT_MEMORY) break;
|
|
9631
|
+
if (held.failure === void 0 && paces > SILENT_MEMORY) {
|
|
9632
|
+
this.until.delete(key2);
|
|
9633
|
+
paces -= 1;
|
|
9634
|
+
} else if (held.failure !== void 0 && holds > SILENT_MEMORY) {
|
|
9635
|
+
this.until.delete(key2);
|
|
9636
|
+
holds -= 1;
|
|
9637
|
+
}
|
|
9638
|
+
}
|
|
9639
|
+
}
|
|
9571
9640
|
};
|
|
9572
9641
|
function clears(completion, failure) {
|
|
9573
9642
|
return completion.kind === failure.source && completion.conversations.has(failure.conversationId);
|
|
@@ -9652,16 +9721,25 @@ var ReceiveLoop = class {
|
|
|
9652
9721
|
rerunsCapped: 0,
|
|
9653
9722
|
runtimeChecksOk: 0,
|
|
9654
9723
|
runtimeChecksFailed: 0,
|
|
9655
|
-
splitsStopped: 0
|
|
9724
|
+
splitsStopped: 0,
|
|
9725
|
+
startsHeld: 0
|
|
9656
9726
|
};
|
|
9657
9727
|
/** Conversations whose verdict a gate call is recording right now (an abandoned cycle's included). */
|
|
9658
9728
|
recordsInFlight = /* @__PURE__ */ new Set();
|
|
9729
|
+
/**
|
|
9730
|
+
* Could not process: conversations whose report is out on another's
|
|
9731
|
+
* completion (`takeDue`): held out of the gate and of new runs, and a run
|
|
9732
|
+
* or turn of theirs waiting for a slot waits, until the server answers.
|
|
9733
|
+
*/
|
|
9734
|
+
reporting = /* @__PURE__ */ new Map();
|
|
9659
9735
|
/** Turns holding a slot (admitted, not yet ended or released). */
|
|
9660
9736
|
slotted = /* @__PURE__ */ new Set();
|
|
9661
9737
|
handle;
|
|
9662
9738
|
started = false;
|
|
9663
9739
|
stopped = false;
|
|
9664
9740
|
heldWhileRunning = false;
|
|
9741
|
+
/** A cycle left a card out because its could-not-process report was out: `letGo` reads the tray again. */
|
|
9742
|
+
heldWhileReporting = false;
|
|
9665
9743
|
activeTurns = 0;
|
|
9666
9744
|
noProgressStreak = 0;
|
|
9667
9745
|
moreTimer = null;
|
|
@@ -9859,7 +9937,13 @@ var ReceiveLoop = class {
|
|
|
9859
9937
|
processingFailures: {
|
|
9860
9938
|
...this.failureCounts,
|
|
9861
9939
|
awaitingEvidence: this.awaitingEvidence.size,
|
|
9862
|
-
lastRuntimeCheck: this.lastRuntimeCheck === null ? null : { ...this.lastRuntimeCheck }
|
|
9940
|
+
lastRuntimeCheck: this.lastRuntimeCheck === null ? null : { ...this.lastRuntimeCheck },
|
|
9941
|
+
held: this.pacer.failed().map(({ key, anchor, reason, since }) => ({
|
|
9942
|
+
conversationId: key.slice(CONVERSATION_KEY.length),
|
|
9943
|
+
anchor,
|
|
9944
|
+
since: new Date(since).toISOString(),
|
|
9945
|
+
reason
|
|
9946
|
+
}))
|
|
9863
9947
|
},
|
|
9864
9948
|
lastError: this.lastError
|
|
9865
9949
|
};
|
|
@@ -9889,7 +9973,7 @@ var ReceiveLoop = class {
|
|
|
9889
9973
|
const id = typeof payload.conversation_id === "string" ? payload.conversation_id : void 0;
|
|
9890
9974
|
const named = Array.isArray(payload.conversation_ids) ? payload.conversation_ids.filter((x) => typeof x === "string") : [];
|
|
9891
9975
|
if (reason === "unanswered") {
|
|
9892
|
-
for (const conversationId of named) this.pacer.
|
|
9976
|
+
for (const conversationId of named) this.pacer.releasePace(`${CONVERSATION_KEY}${conversationId}`);
|
|
9893
9977
|
this.pacer.releaseInvites();
|
|
9894
9978
|
}
|
|
9895
9979
|
this.wakeFrom("wake_frame", id, {
|
|
@@ -10069,20 +10153,22 @@ var ReceiveLoop = class {
|
|
|
10069
10153
|
}
|
|
10070
10154
|
}
|
|
10071
10155
|
async gateCallCycle(run3) {
|
|
10156
|
+
const mark = this.pacer.mark();
|
|
10072
10157
|
const tray = await this.readTray();
|
|
10073
10158
|
if (run3.stale()) return this.summary("abandoned");
|
|
10074
10159
|
if (tray === null) return this.summary("tray_failed", { failure: this.lastError });
|
|
10075
10160
|
const cards = cardsOf(tray);
|
|
10161
|
+
this.forgetCleared(tray, mark);
|
|
10076
10162
|
const invites = trayInvites(tray);
|
|
10077
10163
|
const unheld = this.unheld(cards);
|
|
10078
10164
|
const heldByTurns = cards.length - unheld.length;
|
|
10079
10165
|
if (heldByTurns > 0) this.heldWhileRunning = true;
|
|
10080
|
-
const gateCards
|
|
10166
|
+
const { open: gateCards, paced: pacedCards, heldAfterFailure } = this.paceCards(unheld);
|
|
10081
10167
|
const openInvites = invites.filter((invite) => !this.tracker.inviteRunning(invite.invite_id));
|
|
10082
10168
|
const owedInvites = openInvites.filter((invite) => !this.pacer.held(`invite:${invite.invite_id}`, null));
|
|
10083
|
-
const paced =
|
|
10169
|
+
const paced = pacedCards + (openInvites.length - owedInvites.length);
|
|
10084
10170
|
const owedCards = gateCards.filter((card) => card.muted !== true);
|
|
10085
|
-
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, truncated: tray.truncated === true };
|
|
10171
|
+
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, heldAfterFailure, truncated: tray.truncated === true };
|
|
10086
10172
|
if (cards.length === 0 && invites.length === 0) return this.summary("empty", base);
|
|
10087
10173
|
if (owedCards.length === 0 && owedInvites.length === 0) return this.summary("nothing_owed", base);
|
|
10088
10174
|
const texts = await this.options.texts.ensure();
|
|
@@ -10105,7 +10191,8 @@ var ReceiveLoop = class {
|
|
|
10105
10191
|
chunksOk: 0,
|
|
10106
10192
|
chunksFailed: 0,
|
|
10107
10193
|
splitCallsOk: 0,
|
|
10108
|
-
splitCallsFailed: 0
|
|
10194
|
+
splitCallsFailed: 0,
|
|
10195
|
+
heldAfterFailure
|
|
10109
10196
|
};
|
|
10110
10197
|
let heldDuringGate = 0;
|
|
10111
10198
|
let splitStopped = false;
|
|
@@ -10114,6 +10201,7 @@ var ReceiveLoop = class {
|
|
|
10114
10201
|
if (owedCards.length > 0) {
|
|
10115
10202
|
const gate = await this.gateInChunks(run3, tray, gateCards, texts);
|
|
10116
10203
|
heldDuringGate = gate.held;
|
|
10204
|
+
tally.heldAfterFailure += gate.heldAfterFailure;
|
|
10117
10205
|
tally.gated = gate.gated;
|
|
10118
10206
|
tally.reply = gate.verdicts.reply;
|
|
10119
10207
|
tally.dismiss = gate.verdicts.dismiss;
|
|
@@ -10136,7 +10224,7 @@ var ReceiveLoop = class {
|
|
|
10136
10224
|
} else if (tally.chunksFailed + tally.splitCallsFailed > 0) {
|
|
10137
10225
|
outcome = "fail_closed";
|
|
10138
10226
|
} else if (owedInvites.length === 0 && !run3.stale()) {
|
|
10139
|
-
return this.summary("nothing_owed", { ...base, heldByTurns: heldByTurns + heldDuringGate });
|
|
10227
|
+
return this.summary("nothing_owed", { ...base, heldByTurns: heldByTurns + heldDuringGate, heldAfterFailure: tally.heldAfterFailure });
|
|
10140
10228
|
}
|
|
10141
10229
|
}
|
|
10142
10230
|
for (const invite of owedInvites) {
|
|
@@ -10153,10 +10241,54 @@ var ReceiveLoop = class {
|
|
|
10153
10241
|
/**
|
|
10154
10242
|
* Held out of the gate: a running or waiting turn, or a verdict still being
|
|
10155
10243
|
* recorded (an abandoned cycle's last call): gating it again could record
|
|
10156
|
-
* the same verdict twice (a second defer climbs the ladder).
|
|
10244
|
+
* the same verdict twice (a second defer climbs the ladder). Also a
|
|
10245
|
+
* conversation whose could-not-process report is out (`reporting`): its
|
|
10246
|
+
* answer may hold it.
|
|
10157
10247
|
*/
|
|
10158
10248
|
unheld(cards) {
|
|
10159
|
-
return this.tracker.withoutRunning(cards).filter((card) =>
|
|
10249
|
+
return this.tracker.withoutRunning(cards).filter((card) => {
|
|
10250
|
+
if (this.recordsInFlight.has(card.conversation_id)) return false;
|
|
10251
|
+
if (!this.reporting.has(card.conversation_id)) return true;
|
|
10252
|
+
this.heldWhileReporting = true;
|
|
10253
|
+
return false;
|
|
10254
|
+
});
|
|
10255
|
+
}
|
|
10256
|
+
/**
|
|
10257
|
+
* The cards neither paced (D5) nor held after a could-not-process answer
|
|
10258
|
+
* (`none` / `paused` through the anchor they still show), and how many of
|
|
10259
|
+
* each were left out. A card whose anchor moved is no longer held.
|
|
10260
|
+
*/
|
|
10261
|
+
paceCards(cards) {
|
|
10262
|
+
const open = [];
|
|
10263
|
+
let paced = 0;
|
|
10264
|
+
let heldAfterFailure = 0;
|
|
10265
|
+
for (const card of cards) {
|
|
10266
|
+
const state = this.pacer.check(`${CONVERSATION_KEY}${card.conversation_id}`, anchorFrom(card));
|
|
10267
|
+
if (state === "paced") paced += 1;
|
|
10268
|
+
else if (state === "failed") heldAfterFailure += 1;
|
|
10269
|
+
else open.push(card);
|
|
10270
|
+
}
|
|
10271
|
+
return { open, paced, heldAfterFailure };
|
|
10272
|
+
}
|
|
10273
|
+
/** Held after a could-not-process answer, at the anchor this card still shows. */
|
|
10274
|
+
heldAfterFailure(card) {
|
|
10275
|
+
return this.pacer.check(`${CONVERSATION_KEY}${card.conversation_id}`, anchorFrom(card)) === "failed";
|
|
10276
|
+
}
|
|
10277
|
+
/**
|
|
10278
|
+
* A tray read after `mark`, every card on it (a turn's included): a held
|
|
10279
|
+
* conversation whose card shows a newer anchor is no longer held, and on
|
|
10280
|
+
* a complete tray (not truncated) neither is one whose card is gone (read
|
|
10281
|
+
* meanwhile: a verdict, a mark-read). A truncated tray proves nothing
|
|
10282
|
+
* about the cards it does not show.
|
|
10283
|
+
*/
|
|
10284
|
+
forgetCleared(tray, mark) {
|
|
10285
|
+
const anchors = new Map(cardsOf(tray).map((card) => [`${CONVERSATION_KEY}${card.conversation_id}`, anchorFrom(card)]));
|
|
10286
|
+
this.pacer.keepFailedOn(anchors, mark, tray.truncated !== true);
|
|
10287
|
+
}
|
|
10288
|
+
/** The start of a run or reply turn: held after a could-not-process answer at the anchor it was started for. */
|
|
10289
|
+
failureHeld(handle) {
|
|
10290
|
+
const turn = handle.turn;
|
|
10291
|
+
return turn.kind === "reply" && this.pacer.heldFailedAt(`${CONVERSATION_KEY}${turn.conversationId}`, turn.anchor);
|
|
10160
10292
|
}
|
|
10161
10293
|
/**
|
|
10162
10294
|
* The gate in chunks (contract v1 §3.6): the cards, in tray order, split
|
|
@@ -10190,6 +10322,7 @@ var ReceiveLoop = class {
|
|
|
10190
10322
|
const out = {
|
|
10191
10323
|
gated: 0,
|
|
10192
10324
|
held: 0,
|
|
10325
|
+
heldAfterFailure: 0,
|
|
10193
10326
|
reply: [],
|
|
10194
10327
|
verdicts: { reply: 0, dismiss: 0, defer: 0 },
|
|
10195
10328
|
undecided: 0,
|
|
@@ -10235,7 +10368,9 @@ var ReceiveLoop = class {
|
|
|
10235
10368
|
const of = Math.ceil(chunked.length / size);
|
|
10236
10369
|
for (let index2 = 1; index2 <= of; index2++) {
|
|
10237
10370
|
if (run3.stale()) break;
|
|
10238
|
-
const
|
|
10371
|
+
const slice = chunked.slice((index2 - 1) * size, index2 * size);
|
|
10372
|
+
const planned = slice.filter((card) => !this.heldAfterFailure(card));
|
|
10373
|
+
out.heldAfterFailure += slice.length - planned.length;
|
|
10239
10374
|
const chunk = this.unheld(planned);
|
|
10240
10375
|
out.held += planned.length - chunk.length;
|
|
10241
10376
|
if (chunk.length < planned.length) this.heldWhileRunning = true;
|
|
@@ -10269,7 +10404,7 @@ var ReceiveLoop = class {
|
|
|
10269
10404
|
if (report.outcome === "decided") {
|
|
10270
10405
|
const through = decidedBy(result);
|
|
10271
10406
|
for (const id of through) this.gateAlone.delete(id);
|
|
10272
|
-
await run3.exclude(() => this.reportDue(this.completed("gate", through)));
|
|
10407
|
+
await run3.exclude(() => this.reportDue(this.takeDue(this.completed("gate", through))));
|
|
10273
10408
|
continue;
|
|
10274
10409
|
}
|
|
10275
10410
|
this.failedAttempt("gate", chunk.filter((card) => card.muted !== true).map((card) => card.conversation_id));
|
|
@@ -10290,7 +10425,7 @@ var ReceiveLoop = class {
|
|
|
10290
10425
|
if (run3.stale()) break splitting;
|
|
10291
10426
|
const { card, reruns } = queue.shift();
|
|
10292
10427
|
const id = card.conversation_id;
|
|
10293
|
-
if (decided.has(id) || split.skip.has(id)) continue;
|
|
10428
|
+
if (decided.has(id) || split.skip.has(id) || this.heldAfterFailure(card)) continue;
|
|
10294
10429
|
if (this.unheld([card]).length === 0) {
|
|
10295
10430
|
if (!gated.has(id)) out.held += 1;
|
|
10296
10431
|
this.heldWhileRunning = true;
|
|
@@ -10321,7 +10456,7 @@ var ReceiveLoop = class {
|
|
|
10321
10456
|
if (report.outcome === "decided") {
|
|
10322
10457
|
failuresInARow = 0;
|
|
10323
10458
|
this.gateAlone.delete(id);
|
|
10324
|
-
await run3.exclude(() => this.reportDue(this.completed("gate", decidedBy(result))));
|
|
10459
|
+
await run3.exclude(() => this.reportDue(this.takeDue(this.completed("gate", decidedBy(result)))));
|
|
10325
10460
|
continue;
|
|
10326
10461
|
}
|
|
10327
10462
|
this.rememberGateAlone(id);
|
|
@@ -10386,12 +10521,14 @@ var ReceiveLoop = class {
|
|
|
10386
10521
|
}
|
|
10387
10522
|
}
|
|
10388
10523
|
async singleRunCycle(run3) {
|
|
10524
|
+
const mark = this.pacer.mark();
|
|
10389
10525
|
const tray = await this.readTray();
|
|
10390
10526
|
if (run3.stale()) return this.summary("abandoned");
|
|
10391
10527
|
let cards = null;
|
|
10392
10528
|
let invites = null;
|
|
10393
10529
|
let base = { cards: 0, invites: 0, heldByTurns: 0, truncated: false };
|
|
10394
10530
|
if (tray !== null) {
|
|
10531
|
+
this.forgetCleared(tray, mark);
|
|
10395
10532
|
cards = cardsOf(tray).filter((card) => card.muted !== true).length;
|
|
10396
10533
|
invites = trayInvites(tray).length;
|
|
10397
10534
|
base = { cards: cardsOf(tray).length, invites, heldByTurns: 0, truncated: tray.truncated === true };
|
|
@@ -10439,17 +10576,17 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10439
10576
|
const unheld = this.unheld(cards);
|
|
10440
10577
|
const heldByTurns = cards.length - unheld.length;
|
|
10441
10578
|
if (heldByTurns > 0) this.heldWhileRunning = true;
|
|
10442
|
-
const runCards
|
|
10579
|
+
const { open: runCards, paced: pacedCards, heldAfterFailure } = this.paceCards(unheld);
|
|
10443
10580
|
const openInvites = invites.filter((invite) => !this.tracker.inviteRunning(invite.invite_id));
|
|
10444
10581
|
const owedInvites = openInvites.filter((invite) => !this.pacer.held(`invite:${invite.invite_id}`, null));
|
|
10445
|
-
const paced =
|
|
10582
|
+
const paced = pacedCards + (openInvites.length - owedInvites.length);
|
|
10446
10583
|
const owedCards = runCards.filter((card) => card.muted !== true && card.preview != null);
|
|
10447
|
-
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, truncated: tray.truncated === true };
|
|
10584
|
+
const base = { cards: cards.length, invites: invites.length, heldByTurns, paced, heldAfterFailure, truncated: tray.truncated === true };
|
|
10448
10585
|
if (owedCards.length === 0 && owedInvites.length === 0) return this.summary("nothing_owed", base);
|
|
10449
10586
|
const unready = await this.checkReady();
|
|
10450
10587
|
if (run3.stale()) return this.summary("abandoned", base);
|
|
10451
10588
|
if (unready !== null) return this.summary("tools_unavailable", { ...base, failure: unready });
|
|
10452
|
-
const tally = { turnsStarted: 0, turnsRefused: 0, turnsQueued: 0 };
|
|
10589
|
+
const tally = { turnsStarted: 0, turnsRefused: 0, turnsQueued: 0, heldAfterFailure };
|
|
10453
10590
|
const failedLast = owedCards.filter((card) => this.awaitingEvidence.has(card.conversation_id));
|
|
10454
10591
|
for (const card of owedCards.filter((card2) => !failedLast.includes(card2))) {
|
|
10455
10592
|
if (run3.stale()) break;
|
|
@@ -10493,6 +10630,8 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10493
10630
|
const held = this.tracker.holds(handle);
|
|
10494
10631
|
let completion = null;
|
|
10495
10632
|
let failure = null;
|
|
10633
|
+
let due = [];
|
|
10634
|
+
let ended = false;
|
|
10496
10635
|
try {
|
|
10497
10636
|
this.countRunEnd(end);
|
|
10498
10637
|
this.emit({ type: "run", end, kind: "conversation", conversationId: attempt.conversationId });
|
|
@@ -10506,8 +10645,10 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10506
10645
|
failure = { ...attempt, outcome: end.timedOut === true ? "timed_out" : "failed", failedAt: this.now(), holding: handle };
|
|
10507
10646
|
}
|
|
10508
10647
|
}
|
|
10648
|
+
ended = true;
|
|
10509
10649
|
} finally {
|
|
10510
10650
|
if (failure === null) this.tracker.end(handle);
|
|
10651
|
+
if (ended && !this.stopped && completion !== null) due = this.takeDue(completion);
|
|
10511
10652
|
this.releaseSlot(handle);
|
|
10512
10653
|
if (failure === null) this.afterTurnEnded();
|
|
10513
10654
|
}
|
|
@@ -10519,7 +10660,7 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10519
10660
|
this.afterTurnEnded();
|
|
10520
10661
|
}
|
|
10521
10662
|
}
|
|
10522
|
-
|
|
10663
|
+
await this.reportDue(due);
|
|
10523
10664
|
await this.checkParked("run");
|
|
10524
10665
|
}
|
|
10525
10666
|
/** The invite run: one run for the pending invites, holding each of them until it ends. */
|
|
@@ -10559,6 +10700,8 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10559
10700
|
const end = await done;
|
|
10560
10701
|
const held = this.tracker.holds(slot);
|
|
10561
10702
|
let completion = null;
|
|
10703
|
+
let due = [];
|
|
10704
|
+
let ended = false;
|
|
10562
10705
|
try {
|
|
10563
10706
|
this.countRunEnd(end);
|
|
10564
10707
|
this.emit({ type: "run", end, kind: "invite" });
|
|
@@ -10568,12 +10711,14 @@ ${texts.invite_prompt.trim()}` : texts.wake_instruction.trim();
|
|
|
10568
10711
|
for (const invite of invites) this.pacer.hold(`invite:${invite.invite_id}`, null);
|
|
10569
10712
|
}
|
|
10570
10713
|
if (this.options.dismissIgnoredInvites !== false) await this.afterRunInvites(invites, end);
|
|
10714
|
+
ended = true;
|
|
10571
10715
|
} finally {
|
|
10572
10716
|
endAll();
|
|
10717
|
+
if (ended && !this.stopped && completion !== null) due = this.takeDue(completion);
|
|
10573
10718
|
this.releaseSlot(slot);
|
|
10574
10719
|
this.afterTurnEnded();
|
|
10575
10720
|
}
|
|
10576
|
-
|
|
10721
|
+
await this.reportDue(due);
|
|
10577
10722
|
await this.checkParked("run");
|
|
10578
10723
|
}
|
|
10579
10724
|
/** The runtime's `startRun`, never rejecting: a throw is a run that did not start. */
|
|
@@ -10666,7 +10811,13 @@ invite_id: ${invite.invite_id}`,
|
|
|
10666
10811
|
* hands its slot on the same way.
|
|
10667
10812
|
*/
|
|
10668
10813
|
async launch(handle, admit, drop) {
|
|
10669
|
-
if (this.
|
|
10814
|
+
if (this.failureHeld(handle)) {
|
|
10815
|
+
this.tracker.end(handle);
|
|
10816
|
+
drop?.();
|
|
10817
|
+
this.failureCounts.startsHeld += 1;
|
|
10818
|
+
return "held";
|
|
10819
|
+
}
|
|
10820
|
+
if (this.waiting.length > 0 || this.activeTurns >= this.maxTurns || this.awaitsAnswer(handle)) {
|
|
10670
10821
|
this.waiting.push({ handle, admit, ...drop ? { drop } : {} });
|
|
10671
10822
|
this.counts.turnsQueued += 1;
|
|
10672
10823
|
if (this.activeTurns < this.maxTurns) void this.pump();
|
|
@@ -10691,16 +10842,29 @@ invite_id: ${invite.invite_id}`,
|
|
|
10691
10842
|
if (options.pump !== false) void this.pump();
|
|
10692
10843
|
}
|
|
10693
10844
|
async pump() {
|
|
10694
|
-
while (this.
|
|
10695
|
-
const
|
|
10845
|
+
while (this.activeTurns < this.maxTurns && !this.stopped) {
|
|
10846
|
+
const index = this.waiting.findIndex((w) => !this.awaitsAnswer(w.handle));
|
|
10847
|
+
if (index < 0) break;
|
|
10848
|
+
const next = this.waiting.splice(index, 1)[0];
|
|
10696
10849
|
if (!this.tracker.holds(next.handle)) continue;
|
|
10850
|
+
if (this.failureHeld(next.handle)) {
|
|
10851
|
+
this.tracker.end(next.handle);
|
|
10852
|
+
next.drop?.();
|
|
10853
|
+
this.failureCounts.startsHeld += 1;
|
|
10854
|
+
continue;
|
|
10855
|
+
}
|
|
10697
10856
|
await this.admitInSlot(next.handle, next.admit);
|
|
10698
10857
|
}
|
|
10699
10858
|
}
|
|
10859
|
+
awaitsAnswer(handle) {
|
|
10860
|
+
return handle.turn.kind === "reply" && this.reporting.has(handle.turn.conversationId);
|
|
10861
|
+
}
|
|
10700
10862
|
async afterReplyTurn(handle, attempt, done) {
|
|
10701
10863
|
const reply = attempt.reply;
|
|
10702
10864
|
let completion = null;
|
|
10703
10865
|
let failure = null;
|
|
10866
|
+
let due = [];
|
|
10867
|
+
let ended = false;
|
|
10704
10868
|
try {
|
|
10705
10869
|
const end = await this.tracker.confirmedEnd(handle, done);
|
|
10706
10870
|
if (end === null || !this.tracker.holds(handle)) return;
|
|
@@ -10710,8 +10874,10 @@ invite_id: ${invite.invite_id}`,
|
|
|
10710
10874
|
if (end.status === "failed" && recorded?.freshRead === true && recorded.outcome.reason === "turn_failed") {
|
|
10711
10875
|
failure = { ...attempt, outcome: end.timedOut === true ? "timed_out" : "failed", failedAt: this.now(), holding: handle };
|
|
10712
10876
|
}
|
|
10877
|
+
ended = true;
|
|
10713
10878
|
} finally {
|
|
10714
10879
|
if (failure === null) this.tracker.end(handle);
|
|
10880
|
+
if (ended && !this.stopped && completion !== null) due = this.takeDue(completion);
|
|
10715
10881
|
this.releaseSlot(handle);
|
|
10716
10882
|
if (failure === null) this.afterTurnEnded();
|
|
10717
10883
|
}
|
|
@@ -10723,7 +10889,7 @@ invite_id: ${invite.invite_id}`,
|
|
|
10723
10889
|
this.afterTurnEnded();
|
|
10724
10890
|
}
|
|
10725
10891
|
}
|
|
10726
|
-
|
|
10892
|
+
await this.track(this.reportDue(due));
|
|
10727
10893
|
await this.track(this.checkParked("turn"));
|
|
10728
10894
|
}
|
|
10729
10895
|
async recordReplyOutcome(handle, reply, end) {
|
|
@@ -10845,11 +11011,15 @@ invite_id: ${invite.invite_id}`,
|
|
|
10845
11011
|
return completion;
|
|
10846
11012
|
}
|
|
10847
11013
|
/**
|
|
10848
|
-
*
|
|
10849
|
-
*
|
|
10850
|
-
*
|
|
11014
|
+
* The failures this completion is the evidence for (each once), taken off
|
|
11015
|
+
* the waiting list. Their conversations are held from now until the
|
|
11016
|
+
* server has answered (`reporting`): no gate, and a run or turn of theirs
|
|
11017
|
+
* waiting for a slot waits for the answer, so it never starts on the input
|
|
11018
|
+
* the answer is about. Take them before the completed work's slot frees.
|
|
11019
|
+
* One that waited past `AWAITING_EVIDENCE_MS` is dropped instead: a
|
|
11020
|
+
* completion that late says little about the runtime when it failed.
|
|
10851
11021
|
*/
|
|
10852
|
-
|
|
11022
|
+
takeDue(completion) {
|
|
10853
11023
|
const now2 = this.now();
|
|
10854
11024
|
const due = [];
|
|
10855
11025
|
for (const failure of [...this.awaitingEvidence.values()]) {
|
|
@@ -10859,10 +11029,49 @@ invite_id: ${invite.invite_id}`,
|
|
|
10859
11029
|
}
|
|
10860
11030
|
if (evidences(completion, failure)) {
|
|
10861
11031
|
this.awaitingEvidence.delete(failure.conversationId);
|
|
11032
|
+
this.holdForReport(failure);
|
|
10862
11033
|
due.push(failure);
|
|
10863
11034
|
}
|
|
10864
11035
|
}
|
|
10865
|
-
|
|
11036
|
+
return due;
|
|
11037
|
+
}
|
|
11038
|
+
/** Report what `takeDue` took, letting go of each conversation once its answer is in: what waits for it goes on (or was dropped). */
|
|
11039
|
+
async reportDue(due) {
|
|
11040
|
+
const held = [...due];
|
|
11041
|
+
try {
|
|
11042
|
+
while (held.length > 0) {
|
|
11043
|
+
const failure = held[0];
|
|
11044
|
+
await this.reportFailure(failure, "other_run_completed");
|
|
11045
|
+
held.shift();
|
|
11046
|
+
this.letGo([failure]);
|
|
11047
|
+
}
|
|
11048
|
+
} finally {
|
|
11049
|
+
this.letGo(held);
|
|
11050
|
+
}
|
|
11051
|
+
}
|
|
11052
|
+
/** A report for this failure is due: its conversation is held until `letGo` (counted: two reports out hold it until both are answered). */
|
|
11053
|
+
holdForReport(failure) {
|
|
11054
|
+
this.reporting.set(failure.conversationId, (this.reporting.get(failure.conversationId) ?? 0) + 1);
|
|
11055
|
+
}
|
|
11056
|
+
/**
|
|
11057
|
+
* The answers are in (or the report is off): those conversations are no
|
|
11058
|
+
* longer held for it, what waits for them goes on, and a card a cycle left
|
|
11059
|
+
* out meanwhile for a report is read again (only then: a wake for
|
|
11060
|
+
* anything else could spin while a turn runs).
|
|
11061
|
+
*/
|
|
11062
|
+
letGo(failures) {
|
|
11063
|
+
if (failures.length === 0) return;
|
|
11064
|
+
for (const { conversationId } of failures) {
|
|
11065
|
+
const left = (this.reporting.get(conversationId) ?? 0) - 1;
|
|
11066
|
+
if (left > 0) this.reporting.set(conversationId, left);
|
|
11067
|
+
else this.reporting.delete(conversationId);
|
|
11068
|
+
}
|
|
11069
|
+
if (this.stopped) return;
|
|
11070
|
+
if (this.waiting.length > 0) void this.pump();
|
|
11071
|
+
if (this.heldWhileReporting) {
|
|
11072
|
+
this.heldWhileReporting = false;
|
|
11073
|
+
this.wakeFrom("more");
|
|
11074
|
+
}
|
|
10866
11075
|
}
|
|
10867
11076
|
/** An attempt of this kind failed for these conversations (whatever comes of it): see `failingSince`. */
|
|
10868
11077
|
failedAttempt(kind, conversations) {
|
|
@@ -10915,17 +11124,24 @@ invite_id: ${invite.invite_id}`,
|
|
|
10915
11124
|
failure.outcome !== "timed_out" && !this.checkedFailures.has(failure) && this.now() - failure.failedAt <= AWAITING_EVIDENCE_MS && [...failing].every((id) => id === failure.conversationId)
|
|
10916
11125
|
);
|
|
10917
11126
|
if (due.length === 0) return;
|
|
10918
|
-
for (const failure of due) this.checkedFailures.add(failure);
|
|
10919
|
-
const ok = await this.runtimeCheck();
|
|
10920
11127
|
for (const failure of due) {
|
|
10921
|
-
|
|
10922
|
-
|
|
11128
|
+
this.checkedFailures.add(failure);
|
|
11129
|
+
this.holdForReport(failure);
|
|
11130
|
+
}
|
|
11131
|
+
try {
|
|
11132
|
+
const ok = await this.runtimeCheck();
|
|
11133
|
+
for (const failure of due) {
|
|
11134
|
+
if (this.stopped || this.awaitingEvidence.get(failure.conversationId) !== failure) continue;
|
|
11135
|
+
if (!ok) {
|
|
11136
|
+
this.awaitingEvidence.delete(failure.conversationId);
|
|
11137
|
+
continue;
|
|
11138
|
+
}
|
|
11139
|
+
if (![...failing].every((id) => id === failure.conversationId)) continue;
|
|
10923
11140
|
this.awaitingEvidence.delete(failure.conversationId);
|
|
10924
|
-
|
|
11141
|
+
await this.reportFailure(failure, "runtime_check");
|
|
10925
11142
|
}
|
|
10926
|
-
|
|
10927
|
-
this.
|
|
10928
|
-
await this.reportFailure(failure, "runtime_check");
|
|
11143
|
+
} finally {
|
|
11144
|
+
this.letGo(due);
|
|
10929
11145
|
}
|
|
10930
11146
|
}
|
|
10931
11147
|
/** Nothing of this kind is running or queued: the runtime check may be asked now. */
|
|
@@ -10999,10 +11215,29 @@ invite_id: ${invite.invite_id}`,
|
|
|
10999
11215
|
next = this.rerun(failure, result.action === "hidden");
|
|
11000
11216
|
}
|
|
11001
11217
|
}
|
|
11002
|
-
if (result.action === "paused") this.
|
|
11218
|
+
if (result.action === "none" || result.action === "paused") this.holdFailed(failure, result.action);
|
|
11003
11219
|
if (next === "stop" || next === "rerun_capped") this.activeSplit?.skip.add(failure.conversationId);
|
|
11004
11220
|
this.emit({ type: "processing_failure", ...base, result, next });
|
|
11005
11221
|
}
|
|
11222
|
+
/**
|
|
11223
|
+
* The server answered `none` or `paused`: the conversation is held at the
|
|
11224
|
+
* anchor the report read through, so no later cycle (a message elsewhere,
|
|
11225
|
+
* a wake frame, a reconnect, an `unanswered` re-wake, a turn's end) runs it
|
|
11226
|
+
* again on the same input. A newer message moves its anchor and lifts the
|
|
11227
|
+
* hold (`paceCards`); a card read meanwhile leaves the tray, and the hold
|
|
11228
|
+
* with it (`forgetCleared`). What waits for it does not start: a run or
|
|
11229
|
+
* reply turn queued at that anchor (after `paused`, the server's mute, any),
|
|
11230
|
+
* and a reply turn to start again after the gate.
|
|
11231
|
+
*/
|
|
11232
|
+
holdFailed(failure, reason) {
|
|
11233
|
+
const id = failure.conversationId;
|
|
11234
|
+
const anchor = failure.anchor;
|
|
11235
|
+
this.pacer.holdFailed(`${CONVERSATION_KEY}${id}`, anchor, reason);
|
|
11236
|
+
this.dropWaiting(id, reason === "paused" ? null : anchor);
|
|
11237
|
+
this.turnRerunsAfterGate = this.turnRerunsAfterGate.filter(
|
|
11238
|
+
({ reply }) => reply.conversationId !== id || reason !== "paused" && anchorFrom(reply.card) !== anchor
|
|
11239
|
+
);
|
|
11240
|
+
}
|
|
11006
11241
|
/**
|
|
11007
11242
|
* Run the conversation again after a `retry` or `hidden` answer, after the
|
|
11008
11243
|
* others already queued, and say what was done. Its run or reply turn takes
|
|
@@ -11060,14 +11295,20 @@ invite_id: ${invite.invite_id}`,
|
|
|
11060
11295
|
else void this.startReplyTurn(reply, texts, reruns);
|
|
11061
11296
|
}
|
|
11062
11297
|
}
|
|
11063
|
-
/**
|
|
11064
|
-
|
|
11298
|
+
/**
|
|
11299
|
+
* A held conversation: a run or turn still waiting for a slot for it does
|
|
11300
|
+
* not start; with an `anchor`, only one for that anchor (one queued for a
|
|
11301
|
+
* newer message is new input, and goes on).
|
|
11302
|
+
*/
|
|
11303
|
+
dropWaiting(conversationId, anchor) {
|
|
11065
11304
|
for (const entry of [...this.waiting]) {
|
|
11066
11305
|
const turn = entry.handle.turn;
|
|
11067
11306
|
if (turn.kind !== "reply" || turn.conversationId !== conversationId) continue;
|
|
11307
|
+
if (anchor !== null && turn.anchor !== anchor) continue;
|
|
11068
11308
|
this.waiting.splice(this.waiting.indexOf(entry), 1);
|
|
11069
11309
|
this.tracker.end(entry.handle);
|
|
11070
11310
|
entry.drop?.();
|
|
11311
|
+
this.failureCounts.startsHeld += 1;
|
|
11071
11312
|
}
|
|
11072
11313
|
}
|
|
11073
11314
|
rememberGateAlone(conversationId) {
|
|
@@ -11116,6 +11357,7 @@ invite_id: ${invite.invite_id}`,
|
|
|
11116
11357
|
turnsQueued: 0,
|
|
11117
11358
|
heldByTurns: 0,
|
|
11118
11359
|
paced: 0,
|
|
11360
|
+
heldAfterFailure: 0,
|
|
11119
11361
|
chunksOk: 0,
|
|
11120
11362
|
chunksFailed: 0,
|
|
11121
11363
|
splitCallsOk: 0,
|
|
@@ -11211,6 +11453,7 @@ function timeoutOption(value, fallback, name) {
|
|
|
11211
11453
|
return value;
|
|
11212
11454
|
}
|
|
11213
11455
|
function launchKey(launch) {
|
|
11456
|
+
if (launch === "held") return "heldAfterFailure";
|
|
11214
11457
|
return launch === "started" ? "turnsStarted" : launch === "queued" ? "turnsQueued" : "turnsRefused";
|
|
11215
11458
|
}
|
|
11216
11459
|
function trayInvites(tray) {
|
|
@@ -17475,7 +17718,7 @@ import * as os3 from "os";
|
|
|
17475
17718
|
import * as path10 from "path";
|
|
17476
17719
|
|
|
17477
17720
|
// src/version.ts
|
|
17478
|
-
var VERSION3 = "0.7.
|
|
17721
|
+
var VERSION3 = "0.7.2";
|
|
17479
17722
|
|
|
17480
17723
|
// src/host.ts
|
|
17481
17724
|
function codexHome() {
|