@songsid/agend 2.3.5-beta.1 → 2.3.5-beta.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/dist/agent-cli-instructions.md +1 -1
- 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 +1 -1
- package/dist/auth-api.js +1 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +1 -0
- package/dist/backend/claude-code.js +56 -10
- package/dist/backend/claude-code.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 +4 -0
- package/dist/backend/types.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 +2 -2
- 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 +43 -1
- package/dist/daemon.js +176 -27
- 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 +24 -0
- package/dist/fleet-manager.js +98 -21
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +17 -6
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
- package/dist/general-knowledge/steering/core-rules.md +6 -4
- package/dist/instance-lifecycle.d.ts +3 -0
- package/dist/instance-lifecycle.js +4 -0
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +44 -34
- package/dist/locale.js.map +1 -1
- package/dist/outbound-handlers.js +1 -1
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +2 -0
- package/dist/outbound-schemas.js +4 -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/structured-signin.js +3 -1
- package/dist/structured-signin.js.map +1 -1
- 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/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 +1 -1
- package/dist/ui/chat-strings.js +7 -7
- package/dist/ui/settings-dialogs.js +3 -1
- package/dist/ui/settings-quota-notice.js +8 -6
- package/dist/ui/settings-strings.js +6 -4
- package/dist/ui/shared/app-i18n.js +4 -2
- package/dist/ui/shared/app-shell.js +8 -3
- package/dist/ui/shared/setup-host-text.js +4 -1
- package/dist/ui/shared/signin.js +3 -1
- package/dist/ui/shared/view-strings.js +4 -4
- package/dist/ui/shared/web-authorize.js +4 -4
- 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/usage/providers.d.ts +1 -0
- package/dist/usage/providers.js +13 -9
- package/dist/usage/providers.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/package.json +2 -1
package/dist/daemon.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeMinimumError, cliVersionBelow } from "./claude-model-minimum.js";
|
|
1
2
|
import { quotaNoticeProblem } from "./quota-notice-config.js";
|
|
2
3
|
import { quotaHistoryCount, quotaAfterInput } from "./pane-quota-history.js";
|
|
3
4
|
import { dialogScreenText } from "./dialog-screen-text.js";
|
|
@@ -192,20 +193,20 @@ export function sameProjectFamily(a, b) {
|
|
|
192
193
|
const fx = family(x), fy = family(y);
|
|
193
194
|
return fx.length > 0 && fx === fy;
|
|
194
195
|
}
|
|
196
|
+
/** At most this many fleet decisions, and this many team + directory ones, in one instance's Active Decisions. */
|
|
197
|
+
export const ACTIVE_DECISION_CAPS = { fleet: 20, scoped: 20 };
|
|
195
198
|
/**
|
|
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.
|
|
199
|
+
* Bound an instance's already-selected decisions (newest first, as the store orders them): fleet ones and its own team
|
|
200
|
+
* and directory ones are capped apart, AFTER selection, so nobody else's rows take an instance's places.
|
|
206
201
|
*/
|
|
207
|
-
export function
|
|
202
|
+
export function capActiveDecisions(selected) {
|
|
203
|
+
let fleet = 0, scoped = 0;
|
|
204
|
+
return selected.filter(d => d.scope === "fleet" ? fleet++ < ACTIVE_DECISION_CAPS.fleet : scoped++ < ACTIVE_DECISION_CAPS.scoped);
|
|
205
|
+
}
|
|
206
|
+
export function selectRelevantDecisions(all, workDir, isDispatcher = false, teams = []) {
|
|
208
207
|
return all.filter(d => {
|
|
208
|
+
if (d.scope === "team")
|
|
209
|
+
return !!d.team && teams.includes(d.team);
|
|
209
210
|
if (d.project_root === workDir)
|
|
210
211
|
return true; // own project, any scope
|
|
211
212
|
if (d.scope !== "fleet")
|
|
@@ -1544,6 +1545,12 @@ export class Daemon extends EventEmitter {
|
|
|
1544
1545
|
* when a startup scan reaches a real ready prompt, or on wake().
|
|
1545
1546
|
*/
|
|
1546
1547
|
fatalStartupBlocked = false;
|
|
1548
|
+
/** #3441: one repair budget survives every automatic spawn on this daemon. */
|
|
1549
|
+
modelMinimumRepairUsed = false;
|
|
1550
|
+
modelMinimumFlight = null;
|
|
1551
|
+
modelMinimumBlocked = false;
|
|
1552
|
+
modelMinimumUpdateNotified = false;
|
|
1553
|
+
cliRepairSessionId;
|
|
1547
1554
|
/** model_error seen mid-turn: notify only if it survives to the idle screen. */
|
|
1548
1555
|
pendingModelErrorKey = null;
|
|
1549
1556
|
/** Optional per-instance localhost relay used to observe Muse usage events. */
|
|
@@ -2120,6 +2127,12 @@ export class Daemon extends EventEmitter {
|
|
|
2120
2127
|
}
|
|
2121
2128
|
/** The fleet's other same-backend instances' working directories, read at spawn (#984). */
|
|
2122
2129
|
peerWorkingDirectories;
|
|
2130
|
+
/** This instance's teams (fleet.yaml), read at each spawn: their team decisions join its Active Decisions. */
|
|
2131
|
+
decisionTeams;
|
|
2132
|
+
setDecisionTeams(teams) { this.decisionTeams = teams; }
|
|
2133
|
+
/** The fleet's active decisions (startup snapshot), read at each spawn; absent: the AGEND_DECISIONS env (tests). */
|
|
2134
|
+
decisionSource;
|
|
2135
|
+
setDecisionSource(source) { this.decisionSource = source; }
|
|
2123
2136
|
setPeerWorkingDirectories(peers) {
|
|
2124
2137
|
this.peerWorkingDirectories = peers;
|
|
2125
2138
|
}
|
|
@@ -4525,6 +4538,14 @@ export class Daemon extends EventEmitter {
|
|
|
4525
4538
|
}
|
|
4526
4539
|
/** Arm the recovery gates and emit one detected error pattern. */
|
|
4527
4540
|
emitErrorPattern(ep, key, pane, now) {
|
|
4541
|
+
const minimum = this.backend?.binaryName === "claude" && ep.type === "outdated_cli" ? claudeMinimumError(pane) : null;
|
|
4542
|
+
if (minimum) {
|
|
4543
|
+
this.lastErrorNotifiedAt.set(key, now);
|
|
4544
|
+
void this.handleClaudeModelMinimum(minimum).catch(err => {
|
|
4545
|
+
this.logger.warn({ reason: String(err) }, "CLI launch repair failed");
|
|
4546
|
+
});
|
|
4547
|
+
return;
|
|
4548
|
+
}
|
|
4528
4549
|
// #2795: auth text on the pane proves nothing about the credentials (22 of 22 such matches on the main host were
|
|
4529
4550
|
// conversation text). It arms nothing here; it only asks the lifecycle's token-free check, and a failing check
|
|
4530
4551
|
// arms the auth state through confirmAuthFailure().
|
|
@@ -9912,9 +9933,9 @@ export class Daemon extends EventEmitter {
|
|
|
9912
9933
|
* moment the flag clears.
|
|
9913
9934
|
*/
|
|
9914
9935
|
refuseFatalStartupDelivery(verdict, status) {
|
|
9915
|
-
if (!this.fatalStartupBlocked)
|
|
9936
|
+
if (!this.fatalStartupBlocked && !this.modelMinimumBlocked)
|
|
9916
9937
|
return false;
|
|
9917
|
-
this.logger.error("Delivery refused — CLI
|
|
9938
|
+
this.logger.error("Delivery refused — CLI startup or model-version repair is held");
|
|
9918
9939
|
this.failDelivery(verdict, status, "fatal-startup", "blocked-before-write");
|
|
9919
9940
|
return true;
|
|
9920
9941
|
}
|
|
@@ -11916,9 +11937,10 @@ export class Daemon extends EventEmitter {
|
|
|
11916
11937
|
// Comma-separated parts (`file:role.md, file:rules.md`) only when a part is a file ref; otherwise one inline prompt.
|
|
11917
11938
|
const resolvedCustomPrompt = this.config.systemPrompt ? assembleSystemPrompt(this.config.systemPrompt, promptFiles) : undefined;
|
|
11918
11939
|
let decisions;
|
|
11919
|
-
|
|
11940
|
+
const source = this.decisionSource;
|
|
11941
|
+
if (source || process.env.AGEND_DECISIONS) {
|
|
11920
11942
|
try {
|
|
11921
|
-
const all = JSON.parse(process.env.AGEND_DECISIONS);
|
|
11943
|
+
const all = source ? source() : JSON.parse(process.env.AGEND_DECISIONS);
|
|
11922
11944
|
const workDir = this.config.working_directory;
|
|
11923
11945
|
// `scope: "fleet"` used to bypass the project check entirely, so a
|
|
11924
11946
|
// single-project worker inherited every other project's playbook (8 of
|
|
@@ -11927,7 +11949,12 @@ export class Daemon extends EventEmitter {
|
|
|
11927
11949
|
// same project, or the same project family (worktrees/checkouts of one
|
|
11928
11950
|
// repo). A general is exempt: it dispatches across all projects, so
|
|
11929
11951
|
// cross-project routing rules are exactly what it needs.
|
|
11930
|
-
|
|
11952
|
+
let teams = [];
|
|
11953
|
+
try {
|
|
11954
|
+
teams = this.decisionTeams?.() ?? [];
|
|
11955
|
+
}
|
|
11956
|
+
catch { /* no team list: fleet and project decisions only */ }
|
|
11957
|
+
decisions = capActiveDecisions(selectRelevantDecisions([...all], workDir, this.config.general_topic === true, teams));
|
|
11931
11958
|
// Stable ordering so identical decision sets always build byte-identical
|
|
11932
11959
|
// instructions — otherwise source ordering jitter flips the warmup hash.
|
|
11933
11960
|
decisions.sort((a, b) => a.title.localeCompare(b.title));
|
|
@@ -12047,6 +12074,7 @@ export class Daemon extends EventEmitter {
|
|
|
12047
12074
|
effort: this.config.effort,
|
|
12048
12075
|
kiroUi: this.config.kiro_ui,
|
|
12049
12076
|
skipResume: this.skipResume,
|
|
12077
|
+
...(this.cliRepairSessionId ? { resumeSessionId: this.cliRepairSessionId } : {}),
|
|
12050
12078
|
instructions,
|
|
12051
12079
|
agentMode: isCliMode ? "cli" : "mcp",
|
|
12052
12080
|
agentPort: isCliMode ? agentPort : undefined,
|
|
@@ -12971,14 +12999,14 @@ export class Daemon extends EventEmitter {
|
|
|
12971
12999
|
* Handles confirmation dialogs (trust folder, bypass permissions).
|
|
12972
13000
|
* Returns true if CLI is ready, false if it failed or got stuck.
|
|
12973
13001
|
*/
|
|
12974
|
-
async trySpawn(reuseWindow = false, startupTimeoutMs) {
|
|
13002
|
+
async trySpawn(reuseWindow = false, startupTimeoutMs, repairAdmission) {
|
|
12975
13003
|
const recoveryOwner = this.collateralOomRecovery ? this.interactionOwner() : null;
|
|
12976
13004
|
const enter = () => {
|
|
12977
13005
|
if (recoveryOwner && (!sameInteractionOwner(recoveryOwner, this.interactionOwner())
|
|
12978
13006
|
|| this.startupAborted || this.deliveryWritesStopping || this.runtimeMonitorsFrozen || this.healthCheckPaused)) {
|
|
12979
13007
|
throw new Error("OOM recovery cancelled: the instance was stopped, paused or replaced while memory was unavailable");
|
|
12980
13008
|
}
|
|
12981
|
-
return this.trySpawnInsideGate(reuseWindow, startupTimeoutMs).catch(err => {
|
|
13009
|
+
return this.trySpawnInsideGate(reuseWindow, startupTimeoutMs, repairAdmission).catch(err => {
|
|
12982
13010
|
// Includes an in-place binary replacement during asynchronous launch preparation.
|
|
12983
13011
|
if (err instanceof KiroCompatibilityError)
|
|
12984
13012
|
this.emit("kiro_compatibility_hold", err.message);
|
|
@@ -13003,6 +13031,122 @@ export class Daemon extends EventEmitter {
|
|
|
13003
13031
|
this.startupAdmission?.();
|
|
13004
13032
|
return ready;
|
|
13005
13033
|
}
|
|
13034
|
+
/** Resolve the installed launcher; never run Claude to discover its version. */
|
|
13035
|
+
async resolveClaudeInstallPath() {
|
|
13036
|
+
const { binaryProbe } = await import("./binary-probe.js");
|
|
13037
|
+
const { resolveBackendBinary } = await import("./backend-availability.js");
|
|
13038
|
+
binaryProbe.invalidate("claude");
|
|
13039
|
+
return await resolveBackendBinary("claude-code") ?? null;
|
|
13040
|
+
}
|
|
13041
|
+
async installedClaudeVersion(path) {
|
|
13042
|
+
const { staticBackendVersion } = await import("./backend-availability.js");
|
|
13043
|
+
return staticBackendVersion("claude-code", path);
|
|
13044
|
+
}
|
|
13045
|
+
/** #3441: only the CLI's own refusal can request this one, non-renewable repair. */
|
|
13046
|
+
handleClaudeModelMinimum(minimum) {
|
|
13047
|
+
if (this.modelMinimumRepairUsed || this.modelMinimumBlocked || this.spawning || this.healthCheckPaused
|
|
13048
|
+
|| this.pauseWakeState !== "active" || this.backend?.binaryName !== "claude"
|
|
13049
|
+
|| !this.backend.refreshLaunchBinary)
|
|
13050
|
+
return Promise.resolve();
|
|
13051
|
+
if (this.modelMinimumFlight)
|
|
13052
|
+
return this.modelMinimumFlight;
|
|
13053
|
+
const flight = this.repairClaudeModelMinimum(minimum).finally(() => {
|
|
13054
|
+
if (this.modelMinimumFlight === flight)
|
|
13055
|
+
this.modelMinimumFlight = null;
|
|
13056
|
+
});
|
|
13057
|
+
this.modelMinimumFlight = flight;
|
|
13058
|
+
return flight;
|
|
13059
|
+
}
|
|
13060
|
+
async repairClaudeModelMinimum(minimum) {
|
|
13061
|
+
const tmux = this.tmux, backend = this.backend, window = tmux?.getWindowId();
|
|
13062
|
+
let spawn = this.spawnGeneration, claimed = false;
|
|
13063
|
+
const fence = this.launchFenceEpoch, attempt = this.launchAttempt, phase = this.pauseWakeState;
|
|
13064
|
+
const baseCurrent = () => this.tmux === tmux && this.backend === backend && tmux?.getWindowId() === window
|
|
13065
|
+
&& this.spawnGeneration === spawn && this.launchFenceEpoch === fence && this.pauseWakeState === phase
|
|
13066
|
+
&& !this.startupAborted && !this.deliveryWritesStopping && !this.runtimeMonitorsFrozen && !this.healthCheckPaused;
|
|
13067
|
+
const current = () => baseCurrent() && this.launchAttempt === attempt;
|
|
13068
|
+
const failed = () => new Error(t("inst.cli_repair_failed"));
|
|
13069
|
+
try {
|
|
13070
|
+
// Read the newly resolved install, not a cached old prefix or the running image.
|
|
13071
|
+
const path = await this.resolveClaudeInstallPath();
|
|
13072
|
+
if (!current())
|
|
13073
|
+
return;
|
|
13074
|
+
const version = path ? await this.installedClaudeVersion(path) : null;
|
|
13075
|
+
if (!current())
|
|
13076
|
+
return;
|
|
13077
|
+
if (!version || cliVersionBelow(version, minimum.required)) {
|
|
13078
|
+
if (!this.modelMinimumUpdateNotified) {
|
|
13079
|
+
this.modelMinimumUpdateNotified = true;
|
|
13080
|
+
this.logger.warn({ required: minimum.required, installed: version }, "Claude Code needs an update for this model");
|
|
13081
|
+
this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_update_needed", minimum.required) });
|
|
13082
|
+
}
|
|
13083
|
+
return;
|
|
13084
|
+
}
|
|
13085
|
+
await this.paneWriteLock.run(async () => {
|
|
13086
|
+
if (!current())
|
|
13087
|
+
return;
|
|
13088
|
+
if (!await this.isPaneAuthoritativelyIdle())
|
|
13089
|
+
throw failed();
|
|
13090
|
+
if (!current())
|
|
13091
|
+
return;
|
|
13092
|
+
// Claim before yielding the write lock; queued delivery remains held until readiness settles.
|
|
13093
|
+
this.modelMinimumRepairUsed = true;
|
|
13094
|
+
this.beginSpawn();
|
|
13095
|
+
claimed = true;
|
|
13096
|
+
spawn = this.spawnGeneration;
|
|
13097
|
+
});
|
|
13098
|
+
if (!claimed || !current())
|
|
13099
|
+
return;
|
|
13100
|
+
await this.checkpointSessionId();
|
|
13101
|
+
if (!current())
|
|
13102
|
+
return;
|
|
13103
|
+
let session;
|
|
13104
|
+
if (!this.skipResume) {
|
|
13105
|
+
try {
|
|
13106
|
+
const value = readFileSync(join(this.instanceDir, "session-id"), "utf8").trim();
|
|
13107
|
+
if (/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(value))
|
|
13108
|
+
session = value;
|
|
13109
|
+
}
|
|
13110
|
+
catch { /* Unknown is not permission to select another conversation. */ }
|
|
13111
|
+
}
|
|
13112
|
+
if (!session)
|
|
13113
|
+
throw failed();
|
|
13114
|
+
// Recheck disk evidence after checkpointing; an update may have changed it while we waited.
|
|
13115
|
+
const finalVersion = await this.installedClaudeVersion(path);
|
|
13116
|
+
if (!current())
|
|
13117
|
+
return;
|
|
13118
|
+
if (!finalVersion || cliVersionBelow(finalVersion, minimum.required))
|
|
13119
|
+
throw failed();
|
|
13120
|
+
if (!await this.isPaneAuthoritativelyIdle())
|
|
13121
|
+
throw failed();
|
|
13122
|
+
if (!current())
|
|
13123
|
+
return;
|
|
13124
|
+
this.logger.warn({ running: minimum.running, required: minimum.required, installed: finalVersion }, "Claude model-version refusal — attempting one same-session restart");
|
|
13125
|
+
backend.refreshLaunchBinary(path);
|
|
13126
|
+
this.cliRepairSessionId = session;
|
|
13127
|
+
const ready = await this.trySpawn(true, this.startupBudgetFor(true), next => baseCurrent() && this.launchAttempt === next && next >= attempt && next <= attempt + 1);
|
|
13128
|
+
this.cliRepairSessionId = undefined;
|
|
13129
|
+
if (!baseCurrent() || this.launchAttempt !== attempt + 1)
|
|
13130
|
+
return;
|
|
13131
|
+
if (!ready)
|
|
13132
|
+
throw failed();
|
|
13133
|
+
this.logger.info("Claude model-version restart completed; session retained");
|
|
13134
|
+
this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_repaired") });
|
|
13135
|
+
}
|
|
13136
|
+
catch (error) {
|
|
13137
|
+
if (!baseCurrent() || this.launchAttempt > attempt + 1)
|
|
13138
|
+
return;
|
|
13139
|
+
this.modelMinimumBlocked = true;
|
|
13140
|
+
this.healthCheckPaused = true;
|
|
13141
|
+
this.logger.error({ reason: error instanceof Error ? error.message : String(error) }, "Claude model-version repair held; no automatic retry");
|
|
13142
|
+
this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_repair_failed") });
|
|
13143
|
+
}
|
|
13144
|
+
finally {
|
|
13145
|
+
this.cliRepairSessionId = undefined;
|
|
13146
|
+
if (claimed)
|
|
13147
|
+
this.endSpawn();
|
|
13148
|
+
}
|
|
13149
|
+
}
|
|
13006
13150
|
/**
|
|
13007
13151
|
* One fresh pane capture judged as ready && !busy && !dialog. Transcript
|
|
13008
13152
|
* silence is deliberately NOT the gate: its monitor is inert for muse, so a
|
|
@@ -13201,9 +13345,12 @@ export class Daemon extends EventEmitter {
|
|
|
13201
13345
|
this.logger.debug({ err }, "what's-new not prepared");
|
|
13202
13346
|
}
|
|
13203
13347
|
}
|
|
13204
|
-
async trySpawnInsideGate(reuseWindow = false, startupTimeoutMs) {
|
|
13348
|
+
async trySpawnInsideGate(reuseWindow = false, startupTimeoutMs, repairAdmission) {
|
|
13349
|
+
let expectedAttempt = this.launchAttempt;
|
|
13350
|
+
const admit = () => { this.startupAdmission?.(); if (repairAdmission && !repairAdmission(expectedAttempt))
|
|
13351
|
+
throw new Error("CLI repair superseded by another launch, pause or stop"); };
|
|
13205
13352
|
this.assertSessionOomAdmission();
|
|
13206
|
-
|
|
13353
|
+
admit();
|
|
13207
13354
|
const launchFence = this.launchFenceEpoch;
|
|
13208
13355
|
const backendConfig = this.buildBackendConfig();
|
|
13209
13356
|
// A compatibility refusal is not a failed resume: no configuration, pin, history or pane may change.
|
|
@@ -13229,7 +13376,7 @@ export class Daemon extends EventEmitter {
|
|
|
13229
13376
|
catch { /* unknown capability → the backend's conservative form */ }
|
|
13230
13377
|
// Thrown, not `false`: a false verdict reads as "the CLI failed to start" and sends the startup path
|
|
13231
13378
|
// into its resume-retry / set-the-session-aside handling, for an instance somebody just stopped.
|
|
13232
|
-
|
|
13379
|
+
admit();
|
|
13233
13380
|
this.assertSessionOomAdmission();
|
|
13234
13381
|
if (launchFence !== this.launchFenceEpoch)
|
|
13235
13382
|
throw new Error("Launch cancelled: the instance was stopped or paused while the launch was being prepared");
|
|
@@ -13288,13 +13435,14 @@ export class Daemon extends EventEmitter {
|
|
|
13288
13435
|
// The CLI's own shell sets a zero coredump_filter first (#1113): this pane
|
|
13289
13436
|
// may belong to a tmux server the fleet did not start, which would hand
|
|
13290
13437
|
// the CLI its own (full) filter instead of the fleet's.
|
|
13291
|
-
|
|
13438
|
+
admit();
|
|
13292
13439
|
const cmd = coredumpFilterLaunchPrefix() + `${envPrefix} ` + this.backend.buildCommand(launchConfig);
|
|
13293
13440
|
// Every launched command re-arms the passive-transient check, including a
|
|
13294
13441
|
// retry inside the same spawn: its load is a new one.
|
|
13295
|
-
this.launchAttempt
|
|
13442
|
+
expectedAttempt = ++this.launchAttempt;
|
|
13443
|
+
admit();
|
|
13296
13444
|
await this.prepareQuotaReplayHistory(reuseWindow);
|
|
13297
|
-
|
|
13445
|
+
admit();
|
|
13298
13446
|
this.interactionObservation.reset(this.interactionOwner());
|
|
13299
13447
|
this.clearInteractionConfirmation();
|
|
13300
13448
|
// A launch that cannot paint a passive transient (Codex: a fresh start
|
|
@@ -13318,12 +13466,12 @@ export class Daemon extends EventEmitter {
|
|
|
13318
13466
|
if (this.stormWindow?.observeServerAlive(await TmuxManager.getServerPid(this.tmuxSessionName))) {
|
|
13319
13467
|
this.emit("tmux_server_crash", this.name);
|
|
13320
13468
|
}
|
|
13321
|
-
|
|
13469
|
+
admit();
|
|
13322
13470
|
let windowId;
|
|
13323
13471
|
this.assertSessionOomAdmission();
|
|
13324
13472
|
if (reuseWindow) {
|
|
13325
13473
|
this.controlClient?.unregisterWindow(this.tmux.getWindowId());
|
|
13326
|
-
await this.tmux.respawnWindow(cmd, resolvedCwd);
|
|
13474
|
+
await this.tmux.respawnWindow(cmd, resolvedCwd, repairAdmission ? admit : undefined);
|
|
13327
13475
|
windowId = this.tmux.getWindowId();
|
|
13328
13476
|
}
|
|
13329
13477
|
else {
|
|
@@ -13334,7 +13482,7 @@ export class Daemon extends EventEmitter {
|
|
|
13334
13482
|
if (retired && retired !== windowId)
|
|
13335
13483
|
this.controlClient?.unregisterWindow(retired);
|
|
13336
13484
|
}
|
|
13337
|
-
|
|
13485
|
+
admit();
|
|
13338
13486
|
writeFileSync(join(this.instanceDir, "window-id"), windowId);
|
|
13339
13487
|
// Enable remain-on-exit to capture exit codes on crash
|
|
13340
13488
|
await this.tmux.setRemainOnExit().catch(err => {
|
|
@@ -13369,6 +13517,7 @@ export class Daemon extends EventEmitter {
|
|
|
13369
13517
|
else {
|
|
13370
13518
|
await new Promise(r => setTimeout(r, 10_000));
|
|
13371
13519
|
}
|
|
13520
|
+
admit();
|
|
13372
13521
|
// Dismiss confirmation dialogs and verify CLI reached prompt.
|
|
13373
13522
|
// With remain-on-exit, isWindowAlive() returns true even for dead panes,
|
|
13374
13523
|
// but a startup crash would already be caught by waitForOutput/waitForIdle above.
|