@songsid/agend 2.3.5-beta.1 → 2.3.5-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-cli-instructions.md +3 -3
- package/dist/agent-cli.js +5 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-whats-new.js +4 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/auth-api.d.ts +3 -1
- package/dist/auth-api.js +6 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +3 -0
- package/dist/backend/claude-code.js +72 -13
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/cli-env-probe.js +6 -2
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/backend/codex.d.ts +5 -3
- package/dist/backend/codex.js +31 -13
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/kiro.js +1 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +9 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/bundled-tmux-guard.d.ts +4 -0
- package/dist/bundled-tmux-guard.js +7 -0
- package/dist/bundled-tmux-guard.js.map +1 -1
- package/dist/cache-service.d.ts +6 -0
- package/dist/cache-service.js +105 -0
- package/dist/cache-service.js.map +1 -1
- package/dist/channel/access-manager.d.ts +1 -6
- package/dist/channel/access-manager.js +4 -94
- package/dist/channel/access-manager.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +0 -2
- package/dist/channel/adapters/discord.js +0 -8
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +0 -3
- package/dist/channel/adapters/telegram.js +1 -30
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-tools.js +4 -4
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/types.d.ts +0 -2
- package/dist/claude-model-minimum.d.ts +7 -0
- package/dist/claude-model-minimum.js +16 -0
- package/dist/claude-model-minimum.js.map +1 -0
- package/dist/cli.js +1 -19
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +2 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/daemon.d.ts +46 -1
- package/dist/daemon.js +193 -29
- package/dist/daemon.js.map +1 -1
- package/dist/decision-list.d.ts +2 -0
- package/dist/decision-list.js +1 -1
- package/dist/decision-list.js.map +1 -1
- package/dist/fleet-manager.d.ts +95 -0
- package/dist/fleet-manager.js +491 -113
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-process-handlers.d.ts +1 -1
- package/dist/fleet-process-handlers.js +3 -2
- package/dist/fleet-process-handlers.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +28 -18
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +9 -1
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +12 -0
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +1 -1
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +4 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -11
- package/dist/general-knowledge/steering/core-rules.md +6 -4
- package/dist/instance-lifecycle.d.ts +4 -1
- package/dist/instance-lifecycle.js +20 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.js +29 -6
- package/dist/instructions.js.map +1 -1
- package/dist/kiro-history-scan.d.ts +26 -0
- package/dist/kiro-history-scan.js +141 -0
- package/dist/kiro-history-scan.js.map +1 -0
- package/dist/kiro-history-worker.d.ts +1 -0
- package/dist/kiro-history-worker.js +9 -0
- package/dist/kiro-history-worker.js.map +1 -0
- package/dist/kiro-history.d.ts +20 -0
- package/dist/kiro-history.js +96 -0
- package/dist/kiro-history.js.map +1 -0
- package/dist/kiro-usage-run.d.ts +2 -0
- package/dist/kiro-usage-run.js +4 -1
- package/dist/kiro-usage-run.js.map +1 -1
- package/dist/locale.js +107 -97
- package/dist/locale.js.map +1 -1
- package/dist/login-flows.d.ts +4 -0
- package/dist/login-flows.js +8 -4
- package/dist/login-flows.js.map +1 -1
- package/dist/office-levels.d.ts +4 -3
- package/dist/office-levels.js +3 -3
- package/dist/office-levels.js.map +1 -1
- package/dist/outbound-handlers.js +33 -13
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +16 -0
- package/dist/outbound-schemas.js +8 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/quickstart-api.js +2 -2
- package/dist/quickstart-api.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +5 -1
- package/dist/reply-buttons-controller.js +8 -4
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-buttons.d.ts +6 -2
- package/dist/reply-buttons.js +7 -3
- package/dist/reply-buttons.js.map +1 -1
- package/dist/scheduler/db.d.ts +10 -0
- package/dist/scheduler/db.js +38 -11
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/types.d.ts +6 -1
- package/dist/setup-i18n.js +4 -4
- package/dist/setup-i18n.js.map +1 -1
- package/dist/structured-signin.js +3 -1
- package/dist/structured-signin.js.map +1 -1
- package/dist/subagent-records.d.ts +42 -0
- package/dist/subagent-records.js +159 -0
- package/dist/subagent-records.js.map +1 -0
- package/dist/subagent-service.d.ts +27 -0
- package/dist/subagent-service.js +199 -0
- package/dist/subagent-service.js.map +1 -0
- package/dist/team-membership.d.ts +7 -0
- package/dist/team-membership.js +10 -0
- package/dist/team-membership.js.map +1 -0
- package/dist/tips.js +4 -4
- package/dist/tips.js.map +1 -1
- package/dist/tmux-manager.d.ts +1 -1
- package/dist/tmux-manager.js +4 -1
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tool-permissions.d.ts +2 -3
- package/dist/tool-permissions.js +3 -3
- package/dist/tool-permissions.js.map +1 -1
- package/dist/topic-commands.js +1 -1
- package/dist/topic-commands.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js.map +1 -1
- package/dist/ui/backend-signin.js +62 -62
- package/dist/ui/chat-commands.js +7 -0
- package/dist/ui/chat-store.js +9 -4
- package/dist/ui/chat-strings.js +25 -25
- package/dist/ui/fleet-cache.js +3 -3
- package/dist/ui/fleet-canvas.js +2 -2
- package/dist/ui/fleet-office-editor.js +1 -1
- package/dist/ui/fleet-office.js +1 -1
- package/dist/ui/fleet-org.js +2 -2
- package/dist/ui/fleet-task-card.js +1 -1
- package/dist/ui/fleet-task-common.js +7 -7
- package/dist/ui/model-picker.js +64 -0
- package/dist/ui/panel-chat.js +47 -16
- package/dist/ui/panel-fleet.js +8 -8
- package/dist/ui/panel-needs.js +3 -3
- package/dist/ui/panel-settings.js +16 -6
- package/dist/ui/settings-catalog.js +19 -4
- package/dist/ui/settings-dialogs.js +28 -9
- package/dist/ui/settings-guests.js +1 -1
- package/dist/ui/settings-quota-notice.js +8 -6
- package/dist/ui/settings-registry.js +3 -1
- package/dist/ui/settings-strings.js +36 -30
- package/dist/ui/settings-update.js +69 -0
- package/dist/ui/shared/app-i18n.js +12 -6
- package/dist/ui/shared/app-shell.js +10 -3
- package/dist/ui/shared/app-update.js +215 -0
- package/dist/ui/shared/app.css +48 -2
- package/dist/ui/shared/instance-nav.js +1 -1
- package/dist/ui/shared/model-picker.css +21 -0
- package/dist/ui/shared/setup-host-text.js +8 -5
- package/dist/ui/shared/signin.js +35 -17
- package/dist/ui/shared/subagent-row.css +15 -0
- package/dist/ui/shared/view-strings.js +17 -17
- package/dist/ui/shared/web-authorize.js +4 -4
- package/dist/ui/structured-signin.js +26 -26
- package/dist/ui/subagent-row.js +64 -0
- package/dist/ui/web-terminal/terminal.js +9 -9
- package/dist/update-dispatch.d.ts +32 -4
- package/dist/update-dispatch.js +146 -16
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-launch.d.ts +1 -1
- package/dist/update-launch.js +2 -2
- package/dist/update-launch.js.map +1 -1
- package/dist/update-marker.d.ts +2 -2
- package/dist/update-marker.js +4 -3
- package/dist/update-marker.js.map +1 -1
- package/dist/usage/providers.d.ts +1 -0
- package/dist/usage/providers.js +13 -9
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage-rollup.d.ts +3 -0
- package/dist/usage-rollup.js +2 -0
- package/dist/usage-rollup.js.map +1 -1
- package/dist/view-api.d.ts +2 -8
- package/dist/view-api.js +3 -9
- package/dist/view-api.js.map +1 -1
- package/dist/web-api.d.ts +14 -0
- package/dist/web-api.js +216 -2
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.js +2 -1
- package/dist/web-auth.js.map +1 -1
- package/dist/web-commands.d.ts +8 -0
- package/dist/web-commands.js +6 -0
- package/dist/web-commands.js.map +1 -1
- package/dist/web-update.d.ts +77 -0
- package/dist/web-update.js +102 -0
- package/dist/web-update.js.map +1 -0
- package/package.json +3 -2
package/dist/daemon.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { codexMetadataHomes } from "./backend/codex-metadata.js";
|
|
2
|
+
import { claudeMinimumError, cliVersionBelow } from "./claude-model-minimum.js";
|
|
1
3
|
import { quotaNoticeProblem } from "./quota-notice-config.js";
|
|
2
4
|
import { quotaHistoryCount, quotaAfterInput } from "./pane-quota-history.js";
|
|
3
5
|
import { dialogScreenText } from "./dialog-screen-text.js";
|
|
@@ -5,7 +7,7 @@ import { readActiveKiroModel } from "./backend/kiro.js";
|
|
|
5
7
|
import { dashboardAccessOf } from "./dashboard-permissions.js";
|
|
6
8
|
import { sendPackSources } from "./web-office-pack-read.js";
|
|
7
9
|
import { agendVersion, planWhatsNew, readWhatsNewRecord, recordWhatsNew, withWhatsNew } from "./agent-whats-new.js";
|
|
8
|
-
import { join, dirname, resolve } from "node:path";
|
|
10
|
+
import { join, dirname, basename, resolve } from "node:path";
|
|
9
11
|
import { checkoutTarget, readCheckouts, releaseCandidate, reposRoot, verifyWorktree, writeCheckouts } from "./repo-worktree-guard.js";
|
|
10
12
|
import { mkdirSync, writeFileSync, readFileSync, readdirSync, existsSync, unlinkSync, rmSync, appendFileSync, statSync, renameSync } from "node:fs";
|
|
11
13
|
import { COMPACT_WATCH_TIMEOUT_MS, launchIdentity } from "./compact-watch.js";
|
|
@@ -69,7 +71,7 @@ import { TranscriptDeltaReader } from "./transcript-delta-reader.js";
|
|
|
69
71
|
import { buildResumeContinuation, clearInFlightTurnMarker, consumeInFlightTurnMarker, decideTurnResume, normalizeResumeBackend, readResumeFingerprint, RESUME_BLOCKING_DELIVERY_STATES, writeInFlightTurnMarker, } from "./turn-resume.js";
|
|
70
72
|
import { codexLiveRowMatches } from "./backend/codex.js";
|
|
71
73
|
import { codexPackageProblemMessage } from "./backend/codex-package.js";
|
|
72
|
-
import { claudeConfigDirFor, claudeProfileConfigDir, claudeSwitchDialog, claudeSwitchTargetMatches } from "./backend/claude-code.js";
|
|
74
|
+
import { claudeConfigDirFor, claudeProfileConfigDir, claudeProjectKey, claudeSwitchDialog, claudeSwitchTargetMatches } from "./backend/claude-code.js";
|
|
73
75
|
import { MuseBackend } from "./backend/muse.js";
|
|
74
76
|
import { BACKEND_LABELS, InteractionObservation, INTERACTION_CONFIRM_MS, sameInteractionOwner } from "./interaction-observation.js";
|
|
75
77
|
import { unrecognisedPromptShape } from "./unrecognised-prompt.js";
|
|
@@ -192,20 +194,20 @@ export function sameProjectFamily(a, b) {
|
|
|
192
194
|
const fx = family(x), fy = family(y);
|
|
193
195
|
return fx.length > 0 && fx === fy;
|
|
194
196
|
}
|
|
197
|
+
/** At most this many fleet decisions, and this many team + directory ones, in one instance's Active Decisions. */
|
|
198
|
+
export const ACTIVE_DECISION_CAPS = { fleet: 20, scoped: 20 };
|
|
195
199
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* `scope: "fleet"` previously bypassed the project check outright, so every
|
|
199
|
-
* instance carried every other project's playbook — measured at 8 of 14 here,
|
|
200
|
-
* resent on every API call. A fleet decision must now also be relevant: global
|
|
201
|
-
* (no project_root), the same project, or the same project family.
|
|
202
|
-
*
|
|
203
|
-
* `isDispatcher` (a general) opts out of that narrowing on purpose: it routes
|
|
204
|
-
* work across all projects, so cross-project rules ("X 文件操作由 Y 負責") are
|
|
205
|
-
* precisely what it must know. Narrowing a general would cause misrouting.
|
|
200
|
+
* Bound an instance's already-selected decisions (newest first, as the store orders them): fleet ones and its own team
|
|
201
|
+
* and directory ones are capped apart, AFTER selection, so nobody else's rows take an instance's places.
|
|
206
202
|
*/
|
|
207
|
-
export function
|
|
203
|
+
export function capActiveDecisions(selected) {
|
|
204
|
+
let fleet = 0, scoped = 0;
|
|
205
|
+
return selected.filter(d => d.scope === "fleet" ? fleet++ < ACTIVE_DECISION_CAPS.fleet : scoped++ < ACTIVE_DECISION_CAPS.scoped);
|
|
206
|
+
}
|
|
207
|
+
export function selectRelevantDecisions(all, workDir, isDispatcher = false, teams = []) {
|
|
208
208
|
return all.filter(d => {
|
|
209
|
+
if (d.scope === "team")
|
|
210
|
+
return !!d.team && teams.includes(d.team);
|
|
209
211
|
if (d.project_root === workDir)
|
|
210
212
|
return true; // own project, any scope
|
|
211
213
|
if (d.scope !== "fleet")
|
|
@@ -1131,6 +1133,20 @@ export class Daemon extends EventEmitter {
|
|
|
1131
1133
|
transcriptMonitor = null;
|
|
1132
1134
|
/** #1218: the transcript this instance's monitor follows now (the Log tab reads it on demand; nothing runs for it here). */
|
|
1133
1135
|
logTranscriptPath() { return this.transcriptMonitor?.currentPath() ?? null; }
|
|
1136
|
+
/** Optional read-only child lane: only a current owned tmux launch, never stopped/native/cwd discovery. */
|
|
1137
|
+
subagentSource() {
|
|
1138
|
+
const backend = this.config.backend ?? "claude-code", path = this.logTranscriptPath();
|
|
1139
|
+
if ((backend !== "claude-code" && backend !== "codex") || !path || !this.tmux || this.processStatus !== "running"
|
|
1140
|
+
|| this.spawning || this.runtimeMonitorsFrozen)
|
|
1141
|
+
return null;
|
|
1142
|
+
const cwd = this.config.working_directory || process.cwd();
|
|
1143
|
+
const match = /([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})\.jsonl$/i.exec(path);
|
|
1144
|
+
if (!match || (backend === "claude-code" && basename(path) !== match[1] + ".jsonl"))
|
|
1145
|
+
return null;
|
|
1146
|
+
return { backend, path, sessionId: match[1], cwd,
|
|
1147
|
+
root: backend === "claude-code" ? join(this.claudeConfigDir(), "projects", claudeProjectKey(cwd)) : join(codexMetadataHomes(this.instanceDir).sharedHome, "sessions"),
|
|
1148
|
+
owner: JSON.stringify(this.getInteractionSnapshot().owner) };
|
|
1149
|
+
}
|
|
1134
1150
|
/** #1218 (kiro): the launch this daemon's backend last built, for the Log's reason only (kiro-log-gate.ts). */
|
|
1135
1151
|
logLaunch() { return this.backend?.logLaunch?.() ?? null; }
|
|
1136
1152
|
async kiroMigrationIdle() {
|
|
@@ -1544,6 +1560,12 @@ export class Daemon extends EventEmitter {
|
|
|
1544
1560
|
* when a startup scan reaches a real ready prompt, or on wake().
|
|
1545
1561
|
*/
|
|
1546
1562
|
fatalStartupBlocked = false;
|
|
1563
|
+
/** #3441: one repair budget survives every automatic spawn on this daemon. */
|
|
1564
|
+
modelMinimumRepairUsed = false;
|
|
1565
|
+
modelMinimumFlight = null;
|
|
1566
|
+
modelMinimumBlocked = false;
|
|
1567
|
+
modelMinimumUpdateNotified = false;
|
|
1568
|
+
cliRepairSessionId;
|
|
1547
1569
|
/** model_error seen mid-turn: notify only if it survives to the idle screen. */
|
|
1548
1570
|
pendingModelErrorKey = null;
|
|
1549
1571
|
/** Optional per-instance localhost relay used to observe Muse usage events. */
|
|
@@ -2120,6 +2142,12 @@ export class Daemon extends EventEmitter {
|
|
|
2120
2142
|
}
|
|
2121
2143
|
/** The fleet's other same-backend instances' working directories, read at spawn (#984). */
|
|
2122
2144
|
peerWorkingDirectories;
|
|
2145
|
+
/** This instance's teams (fleet.yaml), read at each spawn: their team decisions join its Active Decisions. */
|
|
2146
|
+
decisionTeams;
|
|
2147
|
+
setDecisionTeams(teams) { this.decisionTeams = teams; }
|
|
2148
|
+
/** The fleet's active decisions (startup snapshot), read at each spawn; absent: the AGEND_DECISIONS env (tests). */
|
|
2149
|
+
decisionSource;
|
|
2150
|
+
setDecisionSource(source) { this.decisionSource = source; }
|
|
2123
2151
|
setPeerWorkingDirectories(peers) {
|
|
2124
2152
|
this.peerWorkingDirectories = peers;
|
|
2125
2153
|
}
|
|
@@ -4525,6 +4553,14 @@ export class Daemon extends EventEmitter {
|
|
|
4525
4553
|
}
|
|
4526
4554
|
/** Arm the recovery gates and emit one detected error pattern. */
|
|
4527
4555
|
emitErrorPattern(ep, key, pane, now) {
|
|
4556
|
+
const minimum = this.backend?.binaryName === "claude" && ep.type === "outdated_cli" ? claudeMinimumError(pane) : null;
|
|
4557
|
+
if (minimum) {
|
|
4558
|
+
this.lastErrorNotifiedAt.set(key, now);
|
|
4559
|
+
void this.handleClaudeModelMinimum(minimum).catch(err => {
|
|
4560
|
+
this.logger.warn({ reason: String(err) }, "CLI launch repair failed");
|
|
4561
|
+
});
|
|
4562
|
+
return;
|
|
4563
|
+
}
|
|
4528
4564
|
// #2795: auth text on the pane proves nothing about the credentials (22 of 22 such matches on the main host were
|
|
4529
4565
|
// conversation text). It arms nothing here; it only asks the lifecycle's token-free check, and a failing check
|
|
4530
4566
|
// arms the auth state through confirmAuthFailure().
|
|
@@ -9912,9 +9948,9 @@ export class Daemon extends EventEmitter {
|
|
|
9912
9948
|
* moment the flag clears.
|
|
9913
9949
|
*/
|
|
9914
9950
|
refuseFatalStartupDelivery(verdict, status) {
|
|
9915
|
-
if (!this.fatalStartupBlocked)
|
|
9951
|
+
if (!this.fatalStartupBlocked && !this.modelMinimumBlocked)
|
|
9916
9952
|
return false;
|
|
9917
|
-
this.logger.error("Delivery refused — CLI
|
|
9953
|
+
this.logger.error("Delivery refused — CLI startup or model-version repair is held");
|
|
9918
9954
|
this.failDelivery(verdict, status, "fatal-startup", "blocked-before-write");
|
|
9919
9955
|
return true;
|
|
9920
9956
|
}
|
|
@@ -11916,9 +11952,10 @@ export class Daemon extends EventEmitter {
|
|
|
11916
11952
|
// Comma-separated parts (`file:role.md, file:rules.md`) only when a part is a file ref; otherwise one inline prompt.
|
|
11917
11953
|
const resolvedCustomPrompt = this.config.systemPrompt ? assembleSystemPrompt(this.config.systemPrompt, promptFiles) : undefined;
|
|
11918
11954
|
let decisions;
|
|
11919
|
-
|
|
11955
|
+
const source = this.decisionSource;
|
|
11956
|
+
if (source || process.env.AGEND_DECISIONS) {
|
|
11920
11957
|
try {
|
|
11921
|
-
const all = JSON.parse(process.env.AGEND_DECISIONS);
|
|
11958
|
+
const all = source ? source() : JSON.parse(process.env.AGEND_DECISIONS);
|
|
11922
11959
|
const workDir = this.config.working_directory;
|
|
11923
11960
|
// `scope: "fleet"` used to bypass the project check entirely, so a
|
|
11924
11961
|
// single-project worker inherited every other project's playbook (8 of
|
|
@@ -11927,7 +11964,12 @@ export class Daemon extends EventEmitter {
|
|
|
11927
11964
|
// same project, or the same project family (worktrees/checkouts of one
|
|
11928
11965
|
// repo). A general is exempt: it dispatches across all projects, so
|
|
11929
11966
|
// cross-project routing rules are exactly what it needs.
|
|
11930
|
-
|
|
11967
|
+
let teams = [];
|
|
11968
|
+
try {
|
|
11969
|
+
teams = this.decisionTeams?.() ?? [];
|
|
11970
|
+
}
|
|
11971
|
+
catch { /* no team list: fleet and project decisions only */ }
|
|
11972
|
+
decisions = capActiveDecisions(selectRelevantDecisions([...all], workDir, this.config.general_topic === true, teams));
|
|
11931
11973
|
// Stable ordering so identical decision sets always build byte-identical
|
|
11932
11974
|
// instructions — otherwise source ordering jitter flips the warmup hash.
|
|
11933
11975
|
decisions.sort((a, b) => a.title.localeCompare(b.title));
|
|
@@ -12047,6 +12089,7 @@ export class Daemon extends EventEmitter {
|
|
|
12047
12089
|
effort: this.config.effort,
|
|
12048
12090
|
kiroUi: this.config.kiro_ui,
|
|
12049
12091
|
skipResume: this.skipResume,
|
|
12092
|
+
...(this.cliRepairSessionId ? { resumeSessionId: this.cliRepairSessionId } : {}),
|
|
12050
12093
|
instructions,
|
|
12051
12094
|
agentMode: isCliMode ? "cli" : "mcp",
|
|
12052
12095
|
agentPort: isCliMode ? agentPort : undefined,
|
|
@@ -12971,14 +13014,14 @@ export class Daemon extends EventEmitter {
|
|
|
12971
13014
|
* Handles confirmation dialogs (trust folder, bypass permissions).
|
|
12972
13015
|
* Returns true if CLI is ready, false if it failed or got stuck.
|
|
12973
13016
|
*/
|
|
12974
|
-
async trySpawn(reuseWindow = false, startupTimeoutMs) {
|
|
13017
|
+
async trySpawn(reuseWindow = false, startupTimeoutMs, repairAdmission) {
|
|
12975
13018
|
const recoveryOwner = this.collateralOomRecovery ? this.interactionOwner() : null;
|
|
12976
13019
|
const enter = () => {
|
|
12977
13020
|
if (recoveryOwner && (!sameInteractionOwner(recoveryOwner, this.interactionOwner())
|
|
12978
13021
|
|| this.startupAborted || this.deliveryWritesStopping || this.runtimeMonitorsFrozen || this.healthCheckPaused)) {
|
|
12979
13022
|
throw new Error("OOM recovery cancelled: the instance was stopped, paused or replaced while memory was unavailable");
|
|
12980
13023
|
}
|
|
12981
|
-
return this.trySpawnInsideGate(reuseWindow, startupTimeoutMs).catch(err => {
|
|
13024
|
+
return this.trySpawnInsideGate(reuseWindow, startupTimeoutMs, repairAdmission).catch(err => {
|
|
12982
13025
|
// Includes an in-place binary replacement during asynchronous launch preparation.
|
|
12983
13026
|
if (err instanceof KiroCompatibilityError)
|
|
12984
13027
|
this.emit("kiro_compatibility_hold", err.message);
|
|
@@ -13003,6 +13046,122 @@ export class Daemon extends EventEmitter {
|
|
|
13003
13046
|
this.startupAdmission?.();
|
|
13004
13047
|
return ready;
|
|
13005
13048
|
}
|
|
13049
|
+
/** Resolve the installed launcher; never run Claude to discover its version. */
|
|
13050
|
+
async resolveClaudeInstallPath() {
|
|
13051
|
+
const { binaryProbe } = await import("./binary-probe.js");
|
|
13052
|
+
const { resolveBackendBinary } = await import("./backend-availability.js");
|
|
13053
|
+
binaryProbe.invalidate("claude");
|
|
13054
|
+
return await resolveBackendBinary("claude-code") ?? null;
|
|
13055
|
+
}
|
|
13056
|
+
async installedClaudeVersion(path) {
|
|
13057
|
+
const { staticBackendVersion } = await import("./backend-availability.js");
|
|
13058
|
+
return staticBackendVersion("claude-code", path);
|
|
13059
|
+
}
|
|
13060
|
+
/** #3441: only the CLI's own refusal can request this one, non-renewable repair. */
|
|
13061
|
+
handleClaudeModelMinimum(minimum) {
|
|
13062
|
+
if (this.modelMinimumRepairUsed || this.modelMinimumBlocked || this.spawning || this.healthCheckPaused
|
|
13063
|
+
|| this.pauseWakeState !== "active" || this.backend?.binaryName !== "claude"
|
|
13064
|
+
|| !this.backend.refreshLaunchBinary)
|
|
13065
|
+
return Promise.resolve();
|
|
13066
|
+
if (this.modelMinimumFlight)
|
|
13067
|
+
return this.modelMinimumFlight;
|
|
13068
|
+
const flight = this.repairClaudeModelMinimum(minimum).finally(() => {
|
|
13069
|
+
if (this.modelMinimumFlight === flight)
|
|
13070
|
+
this.modelMinimumFlight = null;
|
|
13071
|
+
});
|
|
13072
|
+
this.modelMinimumFlight = flight;
|
|
13073
|
+
return flight;
|
|
13074
|
+
}
|
|
13075
|
+
async repairClaudeModelMinimum(minimum) {
|
|
13076
|
+
const tmux = this.tmux, backend = this.backend, window = tmux?.getWindowId();
|
|
13077
|
+
let spawn = this.spawnGeneration, claimed = false;
|
|
13078
|
+
const fence = this.launchFenceEpoch, attempt = this.launchAttempt, phase = this.pauseWakeState;
|
|
13079
|
+
const baseCurrent = () => this.tmux === tmux && this.backend === backend && tmux?.getWindowId() === window
|
|
13080
|
+
&& this.spawnGeneration === spawn && this.launchFenceEpoch === fence && this.pauseWakeState === phase
|
|
13081
|
+
&& !this.startupAborted && !this.deliveryWritesStopping && !this.runtimeMonitorsFrozen && !this.healthCheckPaused;
|
|
13082
|
+
const current = () => baseCurrent() && this.launchAttempt === attempt;
|
|
13083
|
+
const failed = () => new Error(t("inst.cli_repair_failed"));
|
|
13084
|
+
try {
|
|
13085
|
+
// Read the newly resolved install, not a cached old prefix or the running image.
|
|
13086
|
+
const path = await this.resolveClaudeInstallPath();
|
|
13087
|
+
if (!current())
|
|
13088
|
+
return;
|
|
13089
|
+
const version = path ? await this.installedClaudeVersion(path) : null;
|
|
13090
|
+
if (!current())
|
|
13091
|
+
return;
|
|
13092
|
+
if (!version || cliVersionBelow(version, minimum.required)) {
|
|
13093
|
+
if (!this.modelMinimumUpdateNotified) {
|
|
13094
|
+
this.modelMinimumUpdateNotified = true;
|
|
13095
|
+
this.logger.warn({ required: minimum.required, installed: version }, "Claude Code needs an update for this model");
|
|
13096
|
+
this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_update_needed", minimum.required) });
|
|
13097
|
+
}
|
|
13098
|
+
return;
|
|
13099
|
+
}
|
|
13100
|
+
await this.paneWriteLock.run(async () => {
|
|
13101
|
+
if (!current())
|
|
13102
|
+
return;
|
|
13103
|
+
if (!await this.isPaneAuthoritativelyIdle())
|
|
13104
|
+
throw failed();
|
|
13105
|
+
if (!current())
|
|
13106
|
+
return;
|
|
13107
|
+
// Claim before yielding the write lock; queued delivery remains held until readiness settles.
|
|
13108
|
+
this.modelMinimumRepairUsed = true;
|
|
13109
|
+
this.beginSpawn();
|
|
13110
|
+
claimed = true;
|
|
13111
|
+
spawn = this.spawnGeneration;
|
|
13112
|
+
});
|
|
13113
|
+
if (!claimed || !current())
|
|
13114
|
+
return;
|
|
13115
|
+
await this.checkpointSessionId();
|
|
13116
|
+
if (!current())
|
|
13117
|
+
return;
|
|
13118
|
+
let session;
|
|
13119
|
+
if (!this.skipResume) {
|
|
13120
|
+
try {
|
|
13121
|
+
const value = readFileSync(join(this.instanceDir, "session-id"), "utf8").trim();
|
|
13122
|
+
if (/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(value))
|
|
13123
|
+
session = value;
|
|
13124
|
+
}
|
|
13125
|
+
catch { /* Unknown is not permission to select another conversation. */ }
|
|
13126
|
+
}
|
|
13127
|
+
if (!session)
|
|
13128
|
+
throw failed();
|
|
13129
|
+
// Recheck disk evidence after checkpointing; an update may have changed it while we waited.
|
|
13130
|
+
const finalVersion = await this.installedClaudeVersion(path);
|
|
13131
|
+
if (!current())
|
|
13132
|
+
return;
|
|
13133
|
+
if (!finalVersion || cliVersionBelow(finalVersion, minimum.required))
|
|
13134
|
+
throw failed();
|
|
13135
|
+
if (!await this.isPaneAuthoritativelyIdle())
|
|
13136
|
+
throw failed();
|
|
13137
|
+
if (!current())
|
|
13138
|
+
return;
|
|
13139
|
+
this.logger.warn({ running: minimum.running, required: minimum.required, installed: finalVersion }, "Claude model-version refusal — attempting one same-session restart");
|
|
13140
|
+
backend.refreshLaunchBinary(path);
|
|
13141
|
+
this.cliRepairSessionId = session;
|
|
13142
|
+
const ready = await this.trySpawn(true, this.startupBudgetFor(true), next => baseCurrent() && this.launchAttempt === next && next >= attempt && next <= attempt + 1);
|
|
13143
|
+
this.cliRepairSessionId = undefined;
|
|
13144
|
+
if (!baseCurrent() || this.launchAttempt !== attempt + 1)
|
|
13145
|
+
return;
|
|
13146
|
+
if (!ready)
|
|
13147
|
+
throw failed();
|
|
13148
|
+
this.logger.info("Claude model-version restart completed; session retained");
|
|
13149
|
+
this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_repaired") });
|
|
13150
|
+
}
|
|
13151
|
+
catch (error) {
|
|
13152
|
+
if (!baseCurrent() || this.launchAttempt > attempt + 1)
|
|
13153
|
+
return;
|
|
13154
|
+
this.modelMinimumBlocked = true;
|
|
13155
|
+
this.healthCheckPaused = true;
|
|
13156
|
+
this.logger.error({ reason: error instanceof Error ? error.message : String(error) }, "Claude model-version repair held; no automatic retry");
|
|
13157
|
+
this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_repair_failed") });
|
|
13158
|
+
}
|
|
13159
|
+
finally {
|
|
13160
|
+
this.cliRepairSessionId = undefined;
|
|
13161
|
+
if (claimed)
|
|
13162
|
+
this.endSpawn();
|
|
13163
|
+
}
|
|
13164
|
+
}
|
|
13006
13165
|
/**
|
|
13007
13166
|
* One fresh pane capture judged as ready && !busy && !dialog. Transcript
|
|
13008
13167
|
* silence is deliberately NOT the gate: its monitor is inert for muse, so a
|
|
@@ -13201,9 +13360,12 @@ export class Daemon extends EventEmitter {
|
|
|
13201
13360
|
this.logger.debug({ err }, "what's-new not prepared");
|
|
13202
13361
|
}
|
|
13203
13362
|
}
|
|
13204
|
-
async trySpawnInsideGate(reuseWindow = false, startupTimeoutMs) {
|
|
13363
|
+
async trySpawnInsideGate(reuseWindow = false, startupTimeoutMs, repairAdmission) {
|
|
13364
|
+
let expectedAttempt = this.launchAttempt;
|
|
13365
|
+
const admit = () => { this.startupAdmission?.(); if (repairAdmission && !repairAdmission(expectedAttempt))
|
|
13366
|
+
throw new Error("CLI repair superseded by another launch, pause or stop"); };
|
|
13205
13367
|
this.assertSessionOomAdmission();
|
|
13206
|
-
|
|
13368
|
+
admit();
|
|
13207
13369
|
const launchFence = this.launchFenceEpoch;
|
|
13208
13370
|
const backendConfig = this.buildBackendConfig();
|
|
13209
13371
|
// A compatibility refusal is not a failed resume: no configuration, pin, history or pane may change.
|
|
@@ -13229,7 +13391,7 @@ export class Daemon extends EventEmitter {
|
|
|
13229
13391
|
catch { /* unknown capability → the backend's conservative form */ }
|
|
13230
13392
|
// Thrown, not `false`: a false verdict reads as "the CLI failed to start" and sends the startup path
|
|
13231
13393
|
// into its resume-retry / set-the-session-aside handling, for an instance somebody just stopped.
|
|
13232
|
-
|
|
13394
|
+
admit();
|
|
13233
13395
|
this.assertSessionOomAdmission();
|
|
13234
13396
|
if (launchFence !== this.launchFenceEpoch)
|
|
13235
13397
|
throw new Error("Launch cancelled: the instance was stopped or paused while the launch was being prepared");
|
|
@@ -13288,13 +13450,14 @@ export class Daemon extends EventEmitter {
|
|
|
13288
13450
|
// The CLI's own shell sets a zero coredump_filter first (#1113): this pane
|
|
13289
13451
|
// may belong to a tmux server the fleet did not start, which would hand
|
|
13290
13452
|
// the CLI its own (full) filter instead of the fleet's.
|
|
13291
|
-
|
|
13453
|
+
admit();
|
|
13292
13454
|
const cmd = coredumpFilterLaunchPrefix() + `${envPrefix} ` + this.backend.buildCommand(launchConfig);
|
|
13293
13455
|
// Every launched command re-arms the passive-transient check, including a
|
|
13294
13456
|
// retry inside the same spawn: its load is a new one.
|
|
13295
|
-
this.launchAttempt
|
|
13457
|
+
expectedAttempt = ++this.launchAttempt;
|
|
13458
|
+
admit();
|
|
13296
13459
|
await this.prepareQuotaReplayHistory(reuseWindow);
|
|
13297
|
-
|
|
13460
|
+
admit();
|
|
13298
13461
|
this.interactionObservation.reset(this.interactionOwner());
|
|
13299
13462
|
this.clearInteractionConfirmation();
|
|
13300
13463
|
// A launch that cannot paint a passive transient (Codex: a fresh start
|
|
@@ -13318,12 +13481,12 @@ export class Daemon extends EventEmitter {
|
|
|
13318
13481
|
if (this.stormWindow?.observeServerAlive(await TmuxManager.getServerPid(this.tmuxSessionName))) {
|
|
13319
13482
|
this.emit("tmux_server_crash", this.name);
|
|
13320
13483
|
}
|
|
13321
|
-
|
|
13484
|
+
admit();
|
|
13322
13485
|
let windowId;
|
|
13323
13486
|
this.assertSessionOomAdmission();
|
|
13324
13487
|
if (reuseWindow) {
|
|
13325
13488
|
this.controlClient?.unregisterWindow(this.tmux.getWindowId());
|
|
13326
|
-
await this.tmux.respawnWindow(cmd, resolvedCwd);
|
|
13489
|
+
await this.tmux.respawnWindow(cmd, resolvedCwd, repairAdmission ? admit : undefined);
|
|
13327
13490
|
windowId = this.tmux.getWindowId();
|
|
13328
13491
|
}
|
|
13329
13492
|
else {
|
|
@@ -13334,7 +13497,7 @@ export class Daemon extends EventEmitter {
|
|
|
13334
13497
|
if (retired && retired !== windowId)
|
|
13335
13498
|
this.controlClient?.unregisterWindow(retired);
|
|
13336
13499
|
}
|
|
13337
|
-
|
|
13500
|
+
admit();
|
|
13338
13501
|
writeFileSync(join(this.instanceDir, "window-id"), windowId);
|
|
13339
13502
|
// Enable remain-on-exit to capture exit codes on crash
|
|
13340
13503
|
await this.tmux.setRemainOnExit().catch(err => {
|
|
@@ -13369,6 +13532,7 @@ export class Daemon extends EventEmitter {
|
|
|
13369
13532
|
else {
|
|
13370
13533
|
await new Promise(r => setTimeout(r, 10_000));
|
|
13371
13534
|
}
|
|
13535
|
+
admit();
|
|
13372
13536
|
// Dismiss confirmation dialogs and verify CLI reached prompt.
|
|
13373
13537
|
// With remain-on-exit, isWindowAlive() returns true even for dead panes,
|
|
13374
13538
|
// but a startup crash would already be caught by waitForOutput/waitForIdle above.
|