@songsid/agend 2.3.5-alpha.11 → 2.3.5-alpha.13
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/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/accounts-view.d.ts +3 -0
- package/dist/accounts-view.js +2 -2
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-workspace.d.ts +1 -2
- package/dist/agent-workspace.js +8 -29
- package/dist/agent-workspace.js.map +1 -1
- package/dist/auth-api.js +15 -29
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.js +16 -3
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex.d.ts +7 -14
- package/dist/backend/codex.js +25 -29
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/credential-profile.d.ts +16 -0
- package/dist/backend/credential-profile.js +44 -0
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/backend/grok-mcp.d.ts +5 -0
- package/dist/backend/grok-mcp.js +221 -0
- package/dist/backend/grok-mcp.js.map +1 -0
- package/dist/backend/grok.d.ts +0 -10
- package/dist/backend/grok.js +5 -82
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/muse.d.ts +3 -1
- package/dist/backend/muse.js +31 -1
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/types.d.ts +18 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -1
- package/dist/codex-pane-ownership.d.ts +13 -0
- package/dist/codex-pane-ownership.js +192 -0
- package/dist/codex-pane-ownership.js.map +1 -0
- package/dist/create-host-account.d.ts +17 -0
- package/dist/create-host-account.js +47 -0
- package/dist/create-host-account.js.map +1 -0
- package/dist/daemon.d.ts +25 -0
- package/dist/daemon.js +203 -16
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.js +7 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +40 -9
- package/dist/fleet-manager.js +198 -47
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +1 -1
- package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +1 -1
- package/dist/hub/client.d.ts +1 -1
- package/dist/hub/client.js +11 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +2 -2
- package/dist/hub/compose/member.js +11 -3
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/member/exposure-api.d.ts +2 -0
- package/dist/hub/member/exposure-api.js +4 -2
- package/dist/hub/member/exposure-api.js.map +1 -1
- package/dist/hub/member/pairing-api.d.ts +2 -2
- package/dist/hub/member/pairing-api.js +2 -2
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/server.js +8 -0
- package/dist/hub/server.js.map +1 -1
- package/dist/hub-pairing-summary.d.ts +3 -1
- package/dist/hub-pairing-summary.js +6 -3
- package/dist/hub-pairing-summary.js.map +1 -1
- package/dist/instance-lifecycle.js +29 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +13 -9
- package/dist/locale.js.map +1 -1
- package/dist/public-web-link.d.ts +5 -0
- package/dist/public-web-link.js +8 -0
- package/dist/public-web-link.js.map +1 -1
- package/dist/runtime-client-store.js +5 -0
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-pane-private.d.ts +2 -0
- package/dist/runtime-pane-private.js +25 -0
- package/dist/runtime-pane-private.js.map +1 -1
- package/dist/runtime-pane-private.ps1 +74 -7
- package/dist/selection-card.d.ts +4 -3
- package/dist/selection-card.js +2 -1
- package/dist/selection-card.js.map +1 -1
- package/dist/settings-api.js +5 -17
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.d.ts +2 -0
- package/dist/settings-change.js +74 -31
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +23 -0
- package/dist/settings-confirmation.js +13 -2
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +4 -0
- package/dist/settings-effect.js +14 -14
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +3 -1
- package/dist/settings-http-confirmation.js +12 -7
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-summary.d.ts +24 -0
- package/dist/settings-summary.js +42 -0
- package/dist/settings-summary.js.map +1 -0
- package/dist/signin-keepalive.d.ts +25 -1
- package/dist/signin-keepalive.js +44 -1
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/transcript-delta-reader.d.ts +9 -1
- package/dist/transcript-delta-reader.js +37 -8
- package/dist/transcript-delta-reader.js.map +1 -1
- package/dist/ui/accounts-view.js +9 -7
- package/dist/ui/agent-details-settings.js +253 -0
- package/dist/ui/agent-instructions-field.js +69 -0
- package/dist/ui/agent-page-strings.js +148 -0
- package/dist/ui/chat-quote.js +12 -17
- package/dist/ui/hub-client.js +1 -1
- package/dist/ui/hub-company-join-strings.js +1 -1
- package/dist/ui/hub-company-join.js +7 -0
- package/dist/ui/hub-strings.js +10 -6
- package/dist/ui/native-instance-settings.js +47 -14
- package/dist/ui/panel-chat.js +2 -1
- package/dist/ui/panel-details.js +38 -14
- package/dist/ui/panel-fleet.js +9 -3
- package/dist/ui/panel-settings.js +17 -8
- package/dist/ui/settings-access-overview.js +188 -0
- package/dist/ui/settings-access-strings.js +1 -1
- package/dist/ui/settings-confirm.js +5 -5
- package/dist/ui/settings-devices.js +5 -5
- package/dist/ui/settings-dialogs.js +208 -100
- package/dist/ui/settings-hub-company-join.js +69 -14
- package/dist/ui/settings-hub.js +13 -5
- package/dist/ui/settings-layout.js +1 -1
- package/dist/ui/settings-model.js +15 -0
- package/dist/ui/settings-strings.js +8 -8
- package/dist/ui/shared/access-overview.css +48 -0
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-shell.js +145 -4
- package/dist/ui/shared/app-store.js +2 -0
- package/dist/ui/shared/app.css +69 -7
- package/dist/ui/shared/chat-render.js +17 -5
- package/dist/ui/shared/device-roles.js +1 -1
- package/dist/ui/shared/instance-nav.js +5 -1
- package/dist/ui/shared/signin.js +130 -43
- package/dist/ui/shared/usage-dialog.js +27 -15
- package/dist/ui/shared/view-strings.js +2 -0
- package/dist/ui/shared/web-authorize.js +2 -2
- package/dist/ui/signin.html +19 -8
- package/dist/update-dispatch.d.ts +50 -0
- package/dist/update-dispatch.js +58 -2
- package/dist/update-dispatch.js.map +1 -1
- package/dist/usage/format-rich.js +1 -1
- package/dist/usage/format-rich.js.map +1 -1
- package/dist/usage/usage-api.d.ts +8 -2
- package/dist/usage/usage-api.js +12 -5
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +5 -0
- package/dist/web-api.js +58 -0
- package/dist/web-api.js.map +1 -1
- package/dist/web-backend-login.d.ts +2 -0
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-remote-access.d.ts +71 -3
- package/dist/web-remote-access.js +197 -6
- package/dist/web-remote-access.js.map +1 -1
- package/dist/web-session.d.ts +4 -2
- package/dist/web-session.js +5 -2
- package/dist/web-session.js.map +1 -1
- package/dist/workspace-file-policy.d.ts +2 -0
- package/dist/workspace-file-policy.js +31 -0
- package/dist/workspace-file-policy.js.map +1 -0
- package/dist/workspace-follow.js +2 -1
- package/dist/workspace-follow.js.map +1 -1
- package/package.json +2 -2
- package/templates/runtime-assets/runtime-pane-private.ps1 +74 -7
- package/dist/ui/shared/signin-authenticator.js +0 -60
- package/dist/ui/signin-authenticator.html +0 -60
package/dist/daemon.js
CHANGED
|
@@ -75,6 +75,7 @@ import { markerConsumed, scanTranscriptForDeliveryMarker } from "./delivery-reco
|
|
|
75
75
|
import { QUEUED_HANDOFF_MAX_REDELIVERIES, QueuedHandoffStore } from "./queued-handoffs.js";
|
|
76
76
|
import { measureSyncWork, noteSyncWork } from "./sync-work-attribution.js";
|
|
77
77
|
import { TranscriptDeltaReader } from "./transcript-delta-reader.js";
|
|
78
|
+
import { checkpointCodexPane } from "./codex-pane-ownership.js";
|
|
78
79
|
import { buildResumeContinuation, clearInFlightTurnMarker, consumeInFlightTurnMarker, decideTurnResume, normalizeResumeBackend, readResumeFingerprint, RESUME_BLOCKING_DELIVERY_STATES, writeInFlightTurnMarker, } from "./turn-resume.js";
|
|
79
80
|
import { codexLiveRowMatches } from "./backend/codex.js";
|
|
80
81
|
import { codexPackageProblemMessage } from "./backend/codex-package.js";
|
|
@@ -1388,6 +1389,8 @@ export class Daemon extends EventEmitter {
|
|
|
1388
1389
|
/** Generation/signature fence for safety dialogs while their screen is still visible. */
|
|
1389
1390
|
autoResolvedDialogKey = null;
|
|
1390
1391
|
autoResolvedDialogGeneration = 0;
|
|
1392
|
+
/** RuntimeDialog.retrySafe: the sends made to the visible dialog of that key, in this spawn (monotonic time of the last). */
|
|
1393
|
+
retrySafeSends = null;
|
|
1391
1394
|
/** Per-launch safety phases survive startup handoff, redraws and failed/uncertain key ACKs. */
|
|
1392
1395
|
launchDialogClaims = null;
|
|
1393
1396
|
/**
|
|
@@ -1589,6 +1592,8 @@ export class Daemon extends EventEmitter {
|
|
|
1589
1592
|
pauseAllowStuck = false;
|
|
1590
1593
|
pauseWakeState = "active";
|
|
1591
1594
|
pauseWakeTransition = null;
|
|
1595
|
+
/** Includes a pause's pane admission, before it publishes pausing. */
|
|
1596
|
+
pauseAdmissions = new Set();
|
|
1592
1597
|
// Model failover: override model on next spawn when rate-limited
|
|
1593
1598
|
modelOverride;
|
|
1594
1599
|
// Context rotation v3: ring buffers for daemon-side snapshot
|
|
@@ -2298,13 +2303,15 @@ export class Daemon extends EventEmitter {
|
|
|
2298
2303
|
return outcome === "begun";
|
|
2299
2304
|
}
|
|
2300
2305
|
async durableAttemptEvidence(windowId, handingOffToNativeQueue, steer, rawPaste = false) {
|
|
2306
|
+
const backend = this.config.backend ?? this.backend?.binaryName ?? "unknown";
|
|
2301
2307
|
let checkpoint = null, runtimeTranscript = null;
|
|
2302
2308
|
if (this.nativePaneLifecycle) {
|
|
2303
2309
|
runtimeTranscript = await this.transcriptMonitor?.reconciliationRuntimeCheckpoint() ?? null;
|
|
2304
2310
|
if (!runtimeTranscript || !this.nativePaneLifecycle.current(runtimeTranscript))
|
|
2305
2311
|
throw Error("Native transcript checkpoint is not current; no delivery was written");
|
|
2306
2312
|
}
|
|
2307
|
-
else {
|
|
2313
|
+
else if (!(rawPaste && backend === "codex")) {
|
|
2314
|
+
// Local raw Codex uses only the bounded exact-UUID checkpoint acquired below.
|
|
2308
2315
|
try {
|
|
2309
2316
|
checkpoint = await this.transcriptMonitor?.reconciliationCheckpoint() ?? null;
|
|
2310
2317
|
}
|
|
@@ -2315,7 +2322,6 @@ export class Daemon extends EventEmitter {
|
|
|
2315
2322
|
const submissionMode = rawPaste ? "raw_paste" : steer
|
|
2316
2323
|
? "steer"
|
|
2317
2324
|
: handingOffToNativeQueue ? "native_queue_handoff" : "idle_submit";
|
|
2318
|
-
const backend = this.config.backend ?? this.backend?.binaryName ?? "unknown";
|
|
2319
2325
|
// The daemon does not synchronously probe CLI versions on the delivery
|
|
2320
2326
|
// path. Until lifecycle supplies a version tied to this exact process,
|
|
2321
2327
|
// queue handoffs persist an unknown resume contract and reconciliation
|
|
@@ -2716,6 +2722,8 @@ export class Daemon extends EventEmitter {
|
|
|
2716
2722
|
// #1647: a raw paste has no marker; its text is the needle, and its pane proof already failed — so without the turn
|
|
2717
2723
|
// in the transcript it stays uncertain (with the pane's reason), never the output-edge outcome.
|
|
2718
2724
|
const needle = rawPaste ? { rawText: rawPaste.text } : delivery.deliveryId;
|
|
2725
|
+
const bound = checkpoint.ownedCodex;
|
|
2726
|
+
const reader = !checkpoint.runtime && bound ? new TranscriptDeltaReader(checkpoint.path, checkpoint.offset, checkpoint.backend, needle, bound.identity, bound.retire) : null;
|
|
2719
2727
|
let found = false;
|
|
2720
2728
|
try {
|
|
2721
2729
|
if (this.nativePaneLifecycle && !checkpoint.runtime)
|
|
@@ -2724,13 +2732,18 @@ export class Daemon extends EventEmitter {
|
|
|
2724
2732
|
for (let polls = 0; polls <= TRANSCRIPT_PROOF_WINDOW_MS / TRANSCRIPT_PROOF_POLL_MS; polls++) {
|
|
2725
2733
|
if (this.deliveryWritesStopping)
|
|
2726
2734
|
return; // reconciliation owns the row now
|
|
2727
|
-
|
|
2735
|
+
if (bound && (!bound.current() || !await bound.validate()))
|
|
2736
|
+
break;
|
|
2737
|
+
const look = nativeReader ? await nativeReader.look() : reader ? await reader.look()
|
|
2738
|
+
: await scanTranscriptForDeliveryMarker(checkpoint.path, checkpoint.offset, checkpoint.backend, needle);
|
|
2728
2739
|
if (this.deliveryWritesStopping)
|
|
2729
2740
|
return;
|
|
2730
2741
|
if (spawn !== this.spawnGeneration || fence !== this.launchFenceEpoch) {
|
|
2731
2742
|
last = "unavailable";
|
|
2732
2743
|
break;
|
|
2733
2744
|
}
|
|
2745
|
+
if (bound && (!await bound.validate() || !bound.current()))
|
|
2746
|
+
break;
|
|
2734
2747
|
if (look === "user" || look === "absorbed" || look === "queued") {
|
|
2735
2748
|
found = true;
|
|
2736
2749
|
outcome = "delivered";
|
|
@@ -2768,6 +2781,10 @@ export class Daemon extends EventEmitter {
|
|
|
2768
2781
|
try {
|
|
2769
2782
|
if (this.deliveryWritesStopping)
|
|
2770
2783
|
return;
|
|
2784
|
+
if (bound && (!await bound.validate() || !bound.current())) {
|
|
2785
|
+
outcome = "uncertain";
|
|
2786
|
+
evidence = "raw-paste-submit-proof:codex-session-binding-lost; not re-pasted";
|
|
2787
|
+
}
|
|
2771
2788
|
this.finishDurableDelivery(delivery, outcome, evidence);
|
|
2772
2789
|
}
|
|
2773
2790
|
catch (err) {
|
|
@@ -4384,9 +4401,11 @@ export class Daemon extends EventEmitter {
|
|
|
4384
4401
|
continue;
|
|
4385
4402
|
}
|
|
4386
4403
|
const autoKey = dialog.autoResolutionKey;
|
|
4387
|
-
if (dialog.verifyAfterKeys && autoKey
|
|
4404
|
+
if (dialog.verifyAfterKeys && autoKey
|
|
4405
|
+
&& ((this.hasAutoDialogClaim(dialog) && !this.retrySafeDue(dialog)) || this.retrySafeHeld(dialog))) {
|
|
4388
4406
|
// A previous poll sent the safety choice but the CLI has not
|
|
4389
|
-
// repainted yet. Never send another Enter into the same screen
|
|
4407
|
+
// repainted yet. Never send another Enter into the same screen
|
|
4408
|
+
// (a retrySafe dialog's keys may be re-sent: retrySafeDue).
|
|
4390
4409
|
continue;
|
|
4391
4410
|
}
|
|
4392
4411
|
// These keys go straight into the pane. Sent while a message delivery is
|
|
@@ -4427,10 +4446,12 @@ export class Daemon extends EventEmitter {
|
|
|
4427
4446
|
// not evidence that the old request was answered, and the one-minute fallback must keep running.
|
|
4428
4447
|
if (this.dialogAnswers?.key === Daemon.answerKey(dialog) && this.dialogAnswers.screen !== before)
|
|
4429
4448
|
this.endDialogEpisode(dialog.requestIdentity !== undefined);
|
|
4430
|
-
if (dialog.verifyAfterKeys && autoKey
|
|
4449
|
+
if (dialog.verifyAfterKeys && autoKey
|
|
4450
|
+
&& ((this.hasAutoDialogClaim(dialog) && !this.retrySafeDue(dialog)) || this.retrySafeHeld(dialog)))
|
|
4431
4451
|
return;
|
|
4432
4452
|
if (dialog.verifyAfterKeys && autoKey)
|
|
4433
4453
|
this.claimAutoDialog(dialog);
|
|
4454
|
+
this.noteRetrySafeSend(dialog);
|
|
4434
4455
|
this.logger.info(Daemon.answerDetailOf(dialog, currentPane), `Auto-dismissing runtime dialog: ${dialog.description}`);
|
|
4435
4456
|
const SPECIAL_KEYS = new Set(["Up", "Down", "Enter", "Escape", "Right", "Left"]);
|
|
4436
4457
|
for (const key of dialog.keys) {
|
|
@@ -5006,7 +5027,7 @@ export class Daemon extends EventEmitter {
|
|
|
5006
5027
|
else if (durableAttempt && verdict.paneWriteStarted) {
|
|
5007
5028
|
const unproven = `${verdict.phase ?? "raw-paste"}:${verdict.proof ?? "unverified"}`;
|
|
5008
5029
|
const checkpoint = verdict.transcriptCheckpoint;
|
|
5009
|
-
if (checkpoint && RAW_TEXT_TRANSCRIPT_BACKENDS.includes(checkpoint.backend)) {
|
|
5030
|
+
if (checkpoint && (checkpoint.ownedCodex || RAW_TEXT_TRANSCRIPT_BACKENDS.includes(checkpoint.backend))) {
|
|
5010
5031
|
// #1647: the pane could not show it, but the CLI's transcript records the turn the paste started — later
|
|
5011
5032
|
// than the pane window sometimes. Wait for it there (bounded), off the paste lock.
|
|
5012
5033
|
this.logger.info({ deliveryId: durableAttempt.deliveryId, unproven }, "Raw paste not proven on the pane — asking the CLI's transcript for the turn it started");
|
|
@@ -6001,6 +6022,17 @@ export class Daemon extends EventEmitter {
|
|
|
6001
6022
|
async pause(reason = "operator", admission) {
|
|
6002
6023
|
if (this.nativePaneLifecycle)
|
|
6003
6024
|
throw Error("Native pause is owned by its Fleet lifecycle transition");
|
|
6025
|
+
const flight = this.pauseInner(reason, admission);
|
|
6026
|
+
const admissions = this.pauseAdmissions ??= new Set();
|
|
6027
|
+
admissions.add(flight);
|
|
6028
|
+
try {
|
|
6029
|
+
await flight;
|
|
6030
|
+
}
|
|
6031
|
+
finally {
|
|
6032
|
+
admissions.delete(flight);
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
6035
|
+
async pauseInner(reason, admission) {
|
|
6004
6036
|
if (admission && !admission.current())
|
|
6005
6037
|
return;
|
|
6006
6038
|
if (this.pauseWakeState === "paused")
|
|
@@ -6010,7 +6042,7 @@ export class Daemon extends EventEmitter {
|
|
|
6010
6042
|
if (this.getPauseWakeState() !== "active")
|
|
6011
6043
|
return;
|
|
6012
6044
|
}
|
|
6013
|
-
if (admission && !admission.current())
|
|
6045
|
+
if (this.deliveryWritesStopping || this.startupAborted || (admission && !admission.current()))
|
|
6014
6046
|
return;
|
|
6015
6047
|
// `pauseAllowStuck` is consumed here, not merely read: it authorises exactly
|
|
6016
6048
|
// one pause from a stuck pane (the auth-deferred one) and must never leak
|
|
@@ -6043,7 +6075,8 @@ export class Daemon extends EventEmitter {
|
|
|
6043
6075
|
// #1730 P2-2: the await yields — the pane read is only valid for the
|
|
6044
6076
|
// world it was taken from. Revalidate owner, phase, state and queue
|
|
6045
6077
|
// before acting on it; anything that moved defers this cycle.
|
|
6046
|
-
if (
|
|
6078
|
+
if (this.deliveryWritesStopping || this.startupAborted
|
|
6079
|
+
|| (admission && (!admission.current() || pane === null || !admission.accepts(pane)))
|
|
6047
6080
|
|| this.tmux !== tmux
|
|
6048
6081
|
|| this.tmux?.getWindowId?.() !== windowId
|
|
6049
6082
|
|| this.spawnGeneration !== generation
|
|
@@ -6118,6 +6151,17 @@ export class Daemon extends EventEmitter {
|
|
|
6118
6151
|
this.pauseWakeTransition = null;
|
|
6119
6152
|
}
|
|
6120
6153
|
}
|
|
6154
|
+
/** Whether an admitted pause or published pause/wake still owns this launch. */
|
|
6155
|
+
get hasPendingPauseWake() {
|
|
6156
|
+
return !!this.pauseAdmissions?.size
|
|
6157
|
+
|| !!this.pauseWakeTransition && (this.pauseWakeState === "pausing" || this.pauseWakeState === "waking");
|
|
6158
|
+
}
|
|
6159
|
+
/** Settle pane admission as well as the published pause/wake transition. */
|
|
6160
|
+
async waitForPauseWakeTransition() {
|
|
6161
|
+
while (this.hasPendingPauseWake) {
|
|
6162
|
+
await Promise.all([...this.pauseAdmissions ?? [], ...(this.pauseWakeTransition ? [this.pauseWakeTransition] : [])]);
|
|
6163
|
+
}
|
|
6164
|
+
}
|
|
6121
6165
|
/** Respawn the CLI in the preserved window and block until its prompt is ready. */
|
|
6122
6166
|
async wake(timeoutMs = 30_000) {
|
|
6123
6167
|
this.assertSessionOomAdmission();
|
|
@@ -8981,6 +9025,9 @@ export class Daemon extends EventEmitter {
|
|
|
8981
9025
|
this.autoResolvedDialogKey = null;
|
|
8982
9026
|
this.autoResolvedDialogGeneration = 0;
|
|
8983
9027
|
}
|
|
9028
|
+
// A retrySafe dialog that is gone and comes back (Claude's idle cold-resume timer) is a new episode: a fresh budget.
|
|
9029
|
+
if (!active)
|
|
9030
|
+
this.retrySafeSends = null;
|
|
8984
9031
|
return active;
|
|
8985
9032
|
}
|
|
8986
9033
|
hasAutoDialogClaim(dialog) {
|
|
@@ -8994,6 +9041,40 @@ export class Daemon extends EventEmitter {
|
|
|
8994
9041
|
}
|
|
8995
9042
|
return this.autoResolvedDialogGeneration === this.spawnGeneration && this.autoResolvedDialogKey === key;
|
|
8996
9043
|
}
|
|
9044
|
+
/**
|
|
9045
|
+
* RuntimeDialog.retrySafe: may the claimed answer to this dialog — still on screen — be sent again now? Only for a
|
|
9046
|
+
* dialog that declares its keys safe to repeat, within its send budget, and once `afterMs` has passed since the last
|
|
9047
|
+
* send to it in this spawn.
|
|
9048
|
+
*/
|
|
9049
|
+
retrySafeDue(dialog) {
|
|
9050
|
+
const retry = dialog.retrySafe, key = dialog.autoResolutionKey;
|
|
9051
|
+
if (!retry || !key || dialog.oncePerLaunch || !dialog.verifyAfterKeys)
|
|
9052
|
+
return false;
|
|
9053
|
+
const sends = this.retrySafeSends;
|
|
9054
|
+
if (!sends || sends.key !== key || sends.spawn !== this.spawnGeneration)
|
|
9055
|
+
return false; // no send of ours to repeat
|
|
9056
|
+
return sends.count < retry.max && performance.now() - sends.lastMono >= retry.afterMs;
|
|
9057
|
+
}
|
|
9058
|
+
/**
|
|
9059
|
+
* RuntimeDialog.retrySafe: a send to this dialog is on record in this spawn and the next one is not due (its budget
|
|
9060
|
+
* is spent, or `afterMs` has not passed). Holds even when the one-shot claim was released — a failed or uncertain key
|
|
9061
|
+
* ACK releases it — so the budget can never be bypassed (#3589 review).
|
|
9062
|
+
*/
|
|
9063
|
+
retrySafeHeld(dialog) {
|
|
9064
|
+
const key = dialog.autoResolutionKey, sends = this.retrySafeSends;
|
|
9065
|
+
if (!dialog.retrySafe || !key || !sends || sends.key !== key || sends.spawn !== this.spawnGeneration)
|
|
9066
|
+
return false;
|
|
9067
|
+
return !this.retrySafeDue(dialog);
|
|
9068
|
+
}
|
|
9069
|
+
/** Count one send of a retrySafe dialog's keys (the first one included). */
|
|
9070
|
+
noteRetrySafeSend(dialog) {
|
|
9071
|
+
const key = dialog.autoResolutionKey;
|
|
9072
|
+
if (!dialog.retrySafe || !key)
|
|
9073
|
+
return;
|
|
9074
|
+
const sends = this.retrySafeSends;
|
|
9075
|
+
const same = sends !== null && sends.key === key && sends.spawn === this.spawnGeneration;
|
|
9076
|
+
this.retrySafeSends = { key, spawn: this.spawnGeneration, count: (same ? sends.count : 0) + 1, lastMono: performance.now() };
|
|
9077
|
+
}
|
|
8997
9078
|
claimAutoDialog(dialog) {
|
|
8998
9079
|
const key = dialog.autoResolutionKey;
|
|
8999
9080
|
if (!key)
|
|
@@ -10778,6 +10859,7 @@ export class Daemon extends EventEmitter {
|
|
|
10778
10859
|
// first side effect; a crash during those waits remains safely replayable.
|
|
10779
10860
|
if (durableAttempt && !beginChecked) {
|
|
10780
10861
|
beginChecked = true;
|
|
10862
|
+
const proofOwner = this.interactionOwner();
|
|
10781
10863
|
const attemptEvidence = {
|
|
10782
10864
|
...await this.durableAttemptEvidence(windowId, handingOffToNativeQueue, steer, durableAttempt.submissionMode === "raw_paste"),
|
|
10783
10865
|
// #856: what arrived vs what is about to be written, taken at the
|
|
@@ -10785,7 +10867,15 @@ export class Daemon extends EventEmitter {
|
|
|
10785
10867
|
pastedContentSha256: durableAttempt.contentSha256 ?? null,
|
|
10786
10868
|
pastedBytesSha256: deliveryContentDigest(formatted),
|
|
10787
10869
|
};
|
|
10788
|
-
|
|
10870
|
+
const codexCheckpoint = !this.nativePaneLifecycle && rawPaste && attemptEvidence.backend === "codex" && windowId
|
|
10871
|
+
? await this.bindCodexRawPaste(windowId, steerCurrent) : null;
|
|
10872
|
+
if (codexCheckpoint) {
|
|
10873
|
+
attemptEvidence.transcriptPath = codexCheckpoint.path;
|
|
10874
|
+
attemptEvidence.transcriptOffset = codexCheckpoint.offset;
|
|
10875
|
+
attemptEvidence.transcriptSessionId = codexCheckpoint.sessionId;
|
|
10876
|
+
}
|
|
10877
|
+
if ((stillCurrent && !stillCurrent()) || (!this.nativePaneLifecycle && rawPaste && attemptEvidence.backend === "codex"
|
|
10878
|
+
&& (!sameInteractionOwner(proofOwner, this.interactionOwner()) || !steerCurrent()))) {
|
|
10789
10879
|
verdict.fenced = true;
|
|
10790
10880
|
return false;
|
|
10791
10881
|
}
|
|
@@ -10802,12 +10892,13 @@ export class Daemon extends EventEmitter {
|
|
|
10802
10892
|
backend: attemptEvidence.backend,
|
|
10803
10893
|
path: attemptEvidence.transcriptPath,
|
|
10804
10894
|
offset: attemptEvidence.transcriptOffset,
|
|
10895
|
+
...(codexCheckpoint ? { ownedCodex: codexCheckpoint.ownedCodex } : {}),
|
|
10805
10896
|
};
|
|
10806
10897
|
// From here every proof of this write may also ask the CLI's transcript (the pane can lose the echo to the
|
|
10807
10898
|
// reply, or still be painting the paste) — this delivery's exact marker only, or a raw paste's exact text (#1647).
|
|
10808
10899
|
// A raw paste's text only where the transcript is this instance's alone (RAW_TEXT_TRANSCRIPT_BACKENDS).
|
|
10809
10900
|
if (["claude-code", "codex"].includes(attemptEvidence.backend)
|
|
10810
|
-
&& (!rawPaste || RAW_TEXT_TRANSCRIPT_BACKENDS.includes(attemptEvidence.backend))) {
|
|
10901
|
+
&& (!rawPaste || codexCheckpoint || RAW_TEXT_TRANSCRIPT_BACKENDS.includes(attemptEvidence.backend))) {
|
|
10811
10902
|
signature.transcript = this.transcriptProofFor(verdict.transcriptCheckpoint, rawPaste ? { rawText: formatted } : durableAttempt.deliveryId, spawnAtWrite, stillCurrent, kind => { verdict.transcriptProof = kind; });
|
|
10812
10903
|
}
|
|
10813
10904
|
}
|
|
@@ -11463,7 +11554,32 @@ export class Daemon extends EventEmitter {
|
|
|
11463
11554
|
}
|
|
11464
11555
|
if (proof !== "stranded" || !allowRecoveryEnter)
|
|
11465
11556
|
return false;
|
|
11466
|
-
|
|
11557
|
+
// A retained post-Enter frame can still hold the paste while Codex is already
|
|
11558
|
+
// submitting it. Readiness may stay false for the whole new turn (#3578):
|
|
11559
|
+
// keep asking the same positive judge rather than waiting out its 30s cap.
|
|
11560
|
+
// A strand, output alone or an unreadable frame never stops this wait, and
|
|
11561
|
+
// only actual readiness can authorize the existing recovery Enter below.
|
|
11562
|
+
let waiting = true;
|
|
11563
|
+
const observed = { proof: proof };
|
|
11564
|
+
let ready;
|
|
11565
|
+
try {
|
|
11566
|
+
ready = await this.waitForPaneReadyForDelivery(windowId, STRANDED_RETRY_READY_WAIT_MS, async () => {
|
|
11567
|
+
if (!current())
|
|
11568
|
+
return true;
|
|
11569
|
+
observed.proof = await this.confirmSubmitted(signature, baseline, () => waiting && current());
|
|
11570
|
+
return !current() || observed.proof === "submitted";
|
|
11571
|
+
});
|
|
11572
|
+
}
|
|
11573
|
+
finally {
|
|
11574
|
+
// An in-flight read can outlive the wait deadline. It must not settle a
|
|
11575
|
+
// receipt or retire an input guard after this observation was abandoned.
|
|
11576
|
+
waiting = false;
|
|
11577
|
+
}
|
|
11578
|
+
if (!current())
|
|
11579
|
+
return false;
|
|
11580
|
+
if (observed.proof === "submitted")
|
|
11581
|
+
return true;
|
|
11582
|
+
if (ready !== true)
|
|
11467
11583
|
return false;
|
|
11468
11584
|
proof = await proofNow();
|
|
11469
11585
|
if (!current())
|
|
@@ -11523,6 +11639,10 @@ export class Daemon extends EventEmitter {
|
|
|
11523
11639
|
pane = await this.tmux.capturePane();
|
|
11524
11640
|
}
|
|
11525
11641
|
catch { /* the transcript may still say */ }
|
|
11642
|
+
if (owned && !owned())
|
|
11643
|
+
return "unproven";
|
|
11644
|
+
if (signature.transcript?.validate && !await signature.transcript.validate())
|
|
11645
|
+
return "unproven";
|
|
11526
11646
|
if (owned && !owned())
|
|
11527
11647
|
return "unproven";
|
|
11528
11648
|
const onPane = pane === null ? "unproven" : this.judgeSubmission(pane, signature, baseline);
|
|
@@ -11530,6 +11650,8 @@ export class Daemon extends EventEmitter {
|
|
|
11530
11650
|
return onPane;
|
|
11531
11651
|
const t = signature.transcript;
|
|
11532
11652
|
const found = await this.transcriptLook(signature);
|
|
11653
|
+
if (t?.validate && !await t.validate())
|
|
11654
|
+
return "unproven";
|
|
11533
11655
|
// One synchronous stretch from here: the fence is asked after the last await, and only then is the hit kept and the
|
|
11534
11656
|
// spawn's guard retired — a stop or respawn that lands between the look and this line leaves both untouched.
|
|
11535
11657
|
if (!found || !t?.current() || (owned && !owned()))
|
|
@@ -11565,10 +11687,13 @@ export class Daemon extends EventEmitter {
|
|
|
11565
11687
|
throw Error("Native proof cannot read a coordinator-local transcript path");
|
|
11566
11688
|
const launchAtWrite = this.launchFenceEpoch;
|
|
11567
11689
|
return {
|
|
11568
|
-
reader: checkpoint.runtime ? this.nativeTranscriptReader(checkpoint.runtime, needle)
|
|
11690
|
+
reader: checkpoint.runtime ? this.nativeTranscriptReader(checkpoint.runtime, needle)
|
|
11691
|
+
: new TranscriptDeltaReader(checkpoint.path, checkpoint.offset, checkpoint.backend, needle, checkpoint.ownedCodex?.identity, checkpoint.ownedCodex?.retire),
|
|
11569
11692
|
current: () => !this.deliveryWritesStopping && this.spawnGeneration === spawnAtWrite
|
|
11570
11693
|
&& this.launchFenceEpoch === launchAtWrite && (stillCurrent?.() ?? true)
|
|
11571
|
-
&& (!checkpoint.runtime || this.nativePaneLifecycle?.current(checkpoint.runtime) === true)
|
|
11694
|
+
&& (!checkpoint.runtime || this.nativePaneLifecycle?.current(checkpoint.runtime) === true)
|
|
11695
|
+
&& (checkpoint.ownedCodex?.current() ?? true),
|
|
11696
|
+
validate: checkpoint.ownedCodex?.validate,
|
|
11572
11697
|
onProof,
|
|
11573
11698
|
};
|
|
11574
11699
|
}
|
|
@@ -11577,6 +11702,55 @@ export class Daemon extends EventEmitter {
|
|
|
11577
11702
|
throw Error("Native delivery transcript owner is unavailable");
|
|
11578
11703
|
return this.nativePaneLifecycle.proofReader(reference, needle);
|
|
11579
11704
|
}
|
|
11705
|
+
/** A footer observation authorizes only this pre-write delta under this exact pane/launch. No persisted lease. */
|
|
11706
|
+
async bindCodexRawPaste(windowId, stillCurrent) {
|
|
11707
|
+
const tmux = this.tmux, backend = this.backend, owner = this.interactionOwner();
|
|
11708
|
+
if (this.nativePaneLifecycle || !tmux || !backend?.readRawPasteSession)
|
|
11709
|
+
return null;
|
|
11710
|
+
let retired = false;
|
|
11711
|
+
const current = () => {
|
|
11712
|
+
if (!retired && stillCurrent() && this.tmux === tmux && this.backend === backend && tmux.getWindowId() === windowId
|
|
11713
|
+
&& sameInteractionOwner(owner, this.interactionOwner()) && !this.deliveryWritesStopping)
|
|
11714
|
+
return true;
|
|
11715
|
+
retired = true;
|
|
11716
|
+
return false;
|
|
11717
|
+
};
|
|
11718
|
+
const observe = async () => {
|
|
11719
|
+
if (!current() || await tmux.paneInMode?.() === true || !current())
|
|
11720
|
+
return null;
|
|
11721
|
+
const pane = await tmux.capturePane().catch(() => null);
|
|
11722
|
+
if (!current() || pane === null || this.ownSwitch
|
|
11723
|
+
|| this.deliveryBlockingDialogs().some(dialog => Daemon.dialogMatches(dialog, pane)))
|
|
11724
|
+
return null;
|
|
11725
|
+
return backend.readRawPasteSession(pane);
|
|
11726
|
+
};
|
|
11727
|
+
const before = await observe();
|
|
11728
|
+
if (!before || !current())
|
|
11729
|
+
return null;
|
|
11730
|
+
const file = await checkpointCodexPane(before.sessionsDir, before.sessionId, this.config.working_directory || process.cwd());
|
|
11731
|
+
if (!file || !current())
|
|
11732
|
+
return null;
|
|
11733
|
+
const validate = async () => {
|
|
11734
|
+
if (!current())
|
|
11735
|
+
return false;
|
|
11736
|
+
const first = await observe();
|
|
11737
|
+
if (!first || first.sessionId !== before.sessionId || first.sessionsDir !== before.sessionsDir || !current()
|
|
11738
|
+
|| !await file.validateFile() || !current()) {
|
|
11739
|
+
retired = true;
|
|
11740
|
+
return false;
|
|
11741
|
+
}
|
|
11742
|
+
const last = await observe();
|
|
11743
|
+
if (!last || last.sessionId !== before.sessionId || last.sessionsDir !== before.sessionsDir || !current()) {
|
|
11744
|
+
retired = true;
|
|
11745
|
+
return false;
|
|
11746
|
+
}
|
|
11747
|
+
return true;
|
|
11748
|
+
};
|
|
11749
|
+
if (!await validate())
|
|
11750
|
+
return null;
|
|
11751
|
+
return { backend: "codex", path: file.path, offset: file.offset, sessionId: file.sessionId,
|
|
11752
|
+
ownedCodex: { identity: file.identity, current, validate, retire: () => { retired = true; } } };
|
|
11753
|
+
}
|
|
11580
11754
|
/** The CLI this daemon drives, for log lines shared by every backend ("claude-code", "codex", …). */
|
|
11581
11755
|
cliLabel() {
|
|
11582
11756
|
return this.config.backend ?? this.backend?.binaryName ?? "CLI";
|
|
@@ -14345,12 +14519,17 @@ export class Daemon extends EventEmitter {
|
|
|
14345
14519
|
// Try each startup dialog pattern before checking ready state
|
|
14346
14520
|
let matched = false;
|
|
14347
14521
|
lastDialog = null;
|
|
14522
|
+
// A safety choice already sent whose dialog is still on screen (the CLI dropped the key, or has not repainted
|
|
14523
|
+
// yet): it is never read as ready below — its own menu row can carry the ready glyph (`❯`).
|
|
14524
|
+
let answeredStillVisible = null;
|
|
14348
14525
|
for (const dialog of startupDialogs) {
|
|
14349
14526
|
if (Daemon.dialogMatches(dialog, pane)) {
|
|
14350
14527
|
if (dialog.autoResolutionKey
|
|
14351
|
-
&& (attemptedSafetyChoices.has(dialog.autoResolutionKey)
|
|
14352
|
-
|| this.
|
|
14528
|
+
&& (((attemptedSafetyChoices.has(dialog.autoResolutionKey) || this.hasAutoDialogClaim(dialog))
|
|
14529
|
+
&& !this.retrySafeDue(dialog)) || this.retrySafeHeld(dialog))) {
|
|
14530
|
+
answeredStillVisible ??= dialog;
|
|
14353
14531
|
continue;
|
|
14532
|
+
}
|
|
14354
14533
|
lastDialog = dialog;
|
|
14355
14534
|
this.noteCodexReserveDialog(dialog, pane);
|
|
14356
14535
|
this.noteLiveIncidentDialog(dialog, pane);
|
|
@@ -14424,6 +14603,7 @@ export class Daemon extends EventEmitter {
|
|
|
14424
14603
|
attemptedSafetyChoices.add(dialog.autoResolutionKey);
|
|
14425
14604
|
this.claimAutoDialog(dialog);
|
|
14426
14605
|
}
|
|
14606
|
+
this.noteRetrySafeSend(dialog);
|
|
14427
14607
|
for (const key of dialog.keys) {
|
|
14428
14608
|
this.startupAdmission?.();
|
|
14429
14609
|
// Before every key, synchronously: the lock wait, the capture and the gap after the previous key can
|
|
@@ -14470,6 +14650,13 @@ export class Daemon extends EventEmitter {
|
|
|
14470
14650
|
await sleep();
|
|
14471
14651
|
continue;
|
|
14472
14652
|
}
|
|
14653
|
+
if (answeredStillVisible) {
|
|
14654
|
+
// Answered, still up: wait for it to go (or, for a retrySafe one, for its next send to fall due).
|
|
14655
|
+
lastDialog = answeredStillVisible;
|
|
14656
|
+
cleanReadyPolls = 0;
|
|
14657
|
+
await sleep();
|
|
14658
|
+
continue;
|
|
14659
|
+
}
|
|
14473
14660
|
if (this.dialogParkedSince !== 0 && !this.deliveryBlockingDialogs().some(d => Daemon.dialogMatches(d, pane)))
|
|
14474
14661
|
this.trackDialogParked(null);
|
|
14475
14662
|
// A sign-in screen that carries the ready pattern's own glyph (Claude's
|