@songsid/agend 2.1.4-beta.6 → 2.1.4-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-TW.md +1 -1
- package/dist/agent-cli-instructions.md +2 -2
- package/dist/agent-endpoint.js +1 -1
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/backend/antigravity.d.ts +12 -8
- package/dist/backend/antigravity.js +189 -42
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-code.d.ts +87 -23
- package/dist/backend/claude-code.js +361 -46
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex.d.ts +18 -0
- package/dist/backend/codex.js +143 -7
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/gemini-cli.js +2 -2
- package/dist/backend/gemini-cli.js.map +1 -1
- package/dist/backend/grok.js +2 -2
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/kiro.d.ts +52 -2
- package/dist/backend/kiro.js +267 -12
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/opencode.js +17 -4
- package/dist/backend/opencode.js.map +1 -1
- package/dist/backend/types.d.ts +122 -3
- package/dist/backend/types.js +5 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-outage.d.ts +61 -0
- package/dist/backend-outage.js +71 -0
- package/dist/backend-outage.js.map +1 -0
- package/dist/channel/adapters/discord.d.ts +44 -2
- package/dist/channel/adapters/discord.js +529 -89
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +30 -0
- package/dist/channel/adapters/telegram.js +221 -19
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/agy-mcp-launcher.d.ts +2 -0
- package/dist/channel/agy-mcp-launcher.js +28 -0
- package/dist/channel/agy-mcp-launcher.js.map +1 -0
- package/dist/channel/ipc-bridge.d.ts +2 -1
- package/dist/channel/ipc-bridge.js +33 -4
- package/dist/channel/ipc-bridge.js.map +1 -1
- package/dist/channel/markdown-chunk.d.ts +42 -0
- package/dist/channel/markdown-chunk.js +205 -0
- package/dist/channel/markdown-chunk.js.map +1 -0
- package/dist/channel/mcp-server.js +28 -25
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +6 -4
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/message-queue.js +64 -8
- package/dist/channel/message-queue.js.map +1 -1
- package/dist/channel/types.d.ts +31 -1
- package/dist/classic-channel-manager.d.ts +65 -0
- package/dist/classic-channel-manager.js +172 -3
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/cli.js +124 -83
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +16 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +12 -1
- package/dist/config.js.map +1 -1
- package/dist/cross-instance-envelope.d.ts +6 -0
- package/dist/cross-instance-envelope.js +30 -0
- package/dist/cross-instance-envelope.js.map +1 -0
- package/dist/daemon.d.ts +506 -11
- package/dist/daemon.js +2162 -313
- package/dist/daemon.js.map +1 -1
- package/dist/doctor.d.ts +41 -0
- package/dist/doctor.js +267 -0
- package/dist/doctor.js.map +1 -0
- package/dist/fleet-context.d.ts +63 -0
- package/dist/fleet-context.js.map +1 -1
- package/dist/fleet-manager.d.ts +422 -12
- package/dist/fleet-manager.js +2961 -635
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-yaml-slim.d.ts +10 -0
- package/dist/fleet-yaml-slim.js +59 -0
- package/dist/fleet-yaml-slim.js.map +1 -0
- package/dist/general-knowledge/skills/backend-providers/SKILL.md +114 -0
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +4 -1
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +52 -0
- package/dist/general-knowledge/skills/development-workflow/SKILL.md +28 -0
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +1 -0
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +1 -0
- package/dist/general-knowledge/skills/fleet-restart/SKILL.md +1 -0
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -0
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +64 -16
- package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -0
- package/dist/general-knowledge/skills/scheduling/SKILL.md +1 -0
- package/dist/general-knowledge/skills/session-management/SKILL.md +172 -8
- package/dist/general-knowledge/skills/tui-effort/SKILL.md +1 -0
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +30 -0
- package/dist/instance-lifecycle.d.ts +99 -0
- package/dist/instance-lifecycle.js +357 -11
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +12 -0
- package/dist/instructions.js +74 -3
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +1022 -310
- package/dist/locale.js.map +1 -1
- package/dist/login-flows.d.ts +91 -0
- package/dist/login-flows.js +170 -0
- package/dist/login-flows.js.map +1 -0
- package/dist/login-manager.d.ts +63 -0
- package/dist/login-manager.js +134 -0
- package/dist/login-manager.js.map +1 -0
- package/dist/network-family.d.ts +18 -0
- package/dist/network-family.js +20 -0
- package/dist/network-family.js.map +1 -0
- package/dist/outbound-handlers.d.ts +16 -1
- package/dist/outbound-handlers.js +174 -40
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +11 -3
- package/dist/outbound-schemas.js +11 -0
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-input-residue.d.ts +52 -0
- package/dist/pane-input-residue.js +107 -0
- package/dist/pane-input-residue.js.map +1 -0
- package/dist/process-memory.d.ts +6 -0
- package/dist/process-memory.js +45 -0
- package/dist/process-memory.js.map +1 -1
- package/dist/reply-dedup.d.ts +7 -8
- package/dist/reply-dedup.js +0 -0
- package/dist/reply-dedup.js.map +1 -1
- package/dist/restart-progress.d.ts +2 -0
- package/dist/restart-progress.js +3 -0
- package/dist/restart-progress.js.map +1 -1
- package/dist/scheduler/db.d.ts +12 -0
- package/dist/scheduler/db.js +59 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/service-installer.d.ts +11 -0
- package/dist/service-installer.js +84 -18
- package/dist/service-installer.js.map +1 -1
- package/dist/settings-api.js +1 -1
- package/dist/settings-api.js.map +1 -1
- package/dist/setup-wizard.js +2 -2
- package/dist/setup-wizard.js.map +1 -1
- package/dist/spawn-gate.d.ts +30 -0
- package/dist/spawn-gate.js +79 -0
- package/dist/spawn-gate.js.map +1 -0
- package/dist/steer-capability.d.ts +1 -0
- package/dist/steer-capability.js +6 -0
- package/dist/steer-capability.js.map +1 -0
- package/dist/storm-window.d.ts +83 -0
- package/dist/storm-window.js +251 -0
- package/dist/storm-window.js.map +1 -0
- package/dist/tips.d.ts +44 -0
- package/dist/tips.js +355 -0
- package/dist/tips.js.map +1 -0
- package/dist/tmux-manager.d.ts +16 -0
- package/dist/tmux-manager.js +110 -25
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tool-progress.d.ts +40 -0
- package/dist/tool-progress.js +289 -0
- package/dist/tool-progress.js.map +1 -0
- package/dist/topic-commands.d.ts +45 -6
- package/dist/topic-commands.js +394 -66
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.d.ts +15 -2
- package/dist/transcript-monitor.js +63 -17
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-sources.d.ts +131 -0
- package/dist/transcript-sources.js +580 -0
- package/dist/transcript-sources.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/ui/dashboard.html +55 -32
- package/dist/ui/settings.html +200 -60
- package/dist/ui/view.html +147 -30
- package/dist/usage/format-rich.d.ts +1 -1
- package/dist/usage/format-rich.js +28 -24
- package/dist/usage/format-rich.js.map +1 -1
- package/dist/usage/i18n-keys.d.ts +7 -0
- package/dist/usage/i18n-keys.js +34 -0
- package/dist/usage/i18n-keys.js.map +1 -0
- package/dist/usage/i18n.d.ts +5 -0
- package/dist/usage/i18n.js +27 -0
- package/dist/usage/i18n.js.map +1 -0
- package/dist/usage/providers.d.ts +21 -0
- package/dist/usage/providers.js +153 -75
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.d.ts +11 -3
- package/dist/usage/usage-api.js +61 -24
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/workflow-templates/default.md +2 -1
- package/package.json +2 -2
package/dist/daemon.d.ts
CHANGED
|
@@ -6,11 +6,18 @@ import type { CliBackend, InstanceState, InstanceStateSnapshot } from "./backend
|
|
|
6
6
|
import { HangDetector } from "./hang-detector.js";
|
|
7
7
|
import type { TmuxControlClient } from "./tmux-control.js";
|
|
8
8
|
import type { FleetInstructionsParams } from "./instructions.js";
|
|
9
|
+
import type { SpawnGate } from "./spawn-gate.js";
|
|
10
|
+
import type { StormWindow } from "./storm-window.js";
|
|
11
|
+
import type { BackendOutageView } from "./backend-outage.js";
|
|
9
12
|
/** Point a resumed CLI at its one backend-native instruction source. */
|
|
10
13
|
export declare function buildInstructionReloadNotice(binaryName: string, instanceName: string, instanceDir: string): string;
|
|
11
14
|
export declare const DEFAULT_STUCK_TIMEOUT_MS: number;
|
|
12
15
|
export declare const DEFAULT_STATE_IDLE_DEBOUNCE_MS = 2000;
|
|
13
16
|
export declare const DEFAULT_STATE_SAFETY_SWEEP_MS = 60000;
|
|
17
|
+
/** Coalesce one cosmetic-redraw burst before comparing the visible pane. */
|
|
18
|
+
export declare const PERIODIC_REDRAW_PROBE_MS = 25;
|
|
19
|
+
/** A foreground server/port-forward should hand control back or be acknowledged. */
|
|
20
|
+
export declare const DEFAULT_BLOCKING_PROCESS_GRACE_MS: number;
|
|
14
21
|
/**
|
|
15
22
|
* Whether two working directories belong to the same project, so a fleet-scoped
|
|
16
23
|
* decision recorded in one reaches the other. Covers the worktree/checkout
|
|
@@ -62,11 +69,13 @@ export declare function writeLastInboundAt(instanceDir: string, timestamp: numbe
|
|
|
62
69
|
export declare function renderHandoffMetadata(meta: Record<string, string>): string;
|
|
63
70
|
/** Headless inactivity timer used by the daemon and unit tests. */
|
|
64
71
|
export declare class AutoPauseController {
|
|
65
|
-
private
|
|
72
|
+
private thresholdMs;
|
|
66
73
|
private lastActivityAt;
|
|
67
74
|
private pausedAt;
|
|
68
75
|
constructor(thresholdMs: number, lastActivityAt?: number);
|
|
69
76
|
recordActivity(now?: number): void;
|
|
77
|
+
/** Apply a new idle threshold and start a fresh countdown from this update. */
|
|
78
|
+
reconfigure(thresholdMs: number, now?: number): void;
|
|
70
79
|
observe(state: InstanceState, now?: number): boolean;
|
|
71
80
|
markPaused(now?: number): void;
|
|
72
81
|
markAwake(now?: number): void;
|
|
@@ -142,10 +151,13 @@ export declare class PaneStateMachine {
|
|
|
142
151
|
* working" and a finished turn would not be seen as idle until the next 60s
|
|
143
152
|
* safety sweep. Output timestamps are the honest liveness signal here, and
|
|
144
153
|
* the caller has them.
|
|
154
|
+
* @param opts.forceBusy the backend has positively identified a still-running
|
|
155
|
+
* foreground tool even though its TUI keeps an old ready footer visible.
|
|
145
156
|
*/
|
|
146
157
|
observe(pane: string, now?: number, opts?: {
|
|
147
158
|
settled?: boolean;
|
|
148
159
|
changeAt?: number;
|
|
160
|
+
forceBusy?: boolean;
|
|
149
161
|
}): InstanceStateSnapshot;
|
|
150
162
|
/** Record pane motion from tmux control mode without capturing pane content. */
|
|
151
163
|
recordOutput(now?: number): InstanceStateSnapshot;
|
|
@@ -163,6 +175,14 @@ export declare class PendingWorkTracker {
|
|
|
163
175
|
recordIdle(now?: number): void;
|
|
164
176
|
hasPendingWork(): boolean;
|
|
165
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Startup failed because the CLI's backend is unreachable (see backend-outage.ts).
|
|
180
|
+
* The session-id is deliberately KEPT; the fleet schedules a delayed retry.
|
|
181
|
+
*/
|
|
182
|
+
export declare class BackendUnreachableStartupError extends Error {
|
|
183
|
+
readonly backend: string;
|
|
184
|
+
constructor(backend: string);
|
|
185
|
+
}
|
|
166
186
|
/**
|
|
167
187
|
* One-shot timing gate for the first paste after a CLI reaches its ready
|
|
168
188
|
* prompt. A TUI that is still completing its first redraw can swallow Enter.
|
|
@@ -237,6 +257,26 @@ export declare function extractProxyReplyText(pane: string, opts?: {
|
|
|
237
257
|
maxLines?: number;
|
|
238
258
|
maxChars?: number;
|
|
239
259
|
}): string | null;
|
|
260
|
+
export interface MalformedClaudeToolCallDetection {
|
|
261
|
+
/** Stable, non-secret fingerprint used to suppress a stale pane fragment. */
|
|
262
|
+
signature: string;
|
|
263
|
+
/** Sanitized reply argument, or null when only a dangling closing tag survived. */
|
|
264
|
+
text: string | null;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Find the narrow Claude XML failure signature reported in #648.
|
|
268
|
+
*
|
|
269
|
+
* This intentionally runs only at the daemon's busy→idle edge (the caller
|
|
270
|
+
* enforces that) and only scans output after the current inbound marker. A
|
|
271
|
+
* partial tool call while Claude is still streaming is therefore never acted
|
|
272
|
+
* on. The extracted argument goes through the same credential redaction as the
|
|
273
|
+
* dead-MCP pane proxy before it can leave the host.
|
|
274
|
+
*/
|
|
275
|
+
export declare function detectMalformedClaudeToolCall(pane: string, opts?: {
|
|
276
|
+
inboundMarker?: string;
|
|
277
|
+
maxLines?: number;
|
|
278
|
+
maxChars?: number;
|
|
279
|
+
}): MalformedClaudeToolCallDetection | null;
|
|
240
280
|
export type InteractivePromptKind = "sudo_password" | "password" | "confirmation" | "press_enter";
|
|
241
281
|
export interface InteractivePromptDetection {
|
|
242
282
|
kind: InteractivePromptKind;
|
|
@@ -258,6 +298,30 @@ export declare class InteractivePromptDetector {
|
|
|
258
298
|
observe(pane: string, now?: number, outputAt?: number): InteractivePromptDetection | null;
|
|
259
299
|
reset(): void;
|
|
260
300
|
}
|
|
301
|
+
export interface BlockingProcessDetection {
|
|
302
|
+
activity: string;
|
|
303
|
+
evidence: string;
|
|
304
|
+
blockedForMs: number;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Detect a foreground shell tool which has become a long-lived server.
|
|
308
|
+
*
|
|
309
|
+
* Unlike the generic pane-stuck clock, this clock deliberately survives new
|
|
310
|
+
* output: access logs and `Handling connection` lines are exactly why a
|
|
311
|
+
* foreground server can remain blocked forever without ever looking silent.
|
|
312
|
+
* Once a server marker is seen, the still-running tool identity is the stable
|
|
313
|
+
* signal; the marker may scroll out of the 32-row pane.
|
|
314
|
+
*/
|
|
315
|
+
export declare class BlockingProcessDetector {
|
|
316
|
+
private readonly graceMs;
|
|
317
|
+
private activity;
|
|
318
|
+
private evidence;
|
|
319
|
+
private detectedAt;
|
|
320
|
+
private notified;
|
|
321
|
+
constructor(graceMs?: number);
|
|
322
|
+
observe(pane: string, activity: string | null, now?: number): BlockingProcessDetection | null;
|
|
323
|
+
reset(): void;
|
|
324
|
+
}
|
|
261
325
|
export declare class Daemon extends EventEmitter {
|
|
262
326
|
private name;
|
|
263
327
|
private config;
|
|
@@ -266,6 +330,10 @@ export declare class Daemon extends EventEmitter {
|
|
|
266
330
|
private backend?;
|
|
267
331
|
private controlClient?;
|
|
268
332
|
private runtimeIdentity?;
|
|
333
|
+
private spawnGate?;
|
|
334
|
+
private stormWindow?;
|
|
335
|
+
/** Fleet-level "is this CLI's backend down?" memory — see backend-outage.ts. */
|
|
336
|
+
private backendOutage?;
|
|
269
337
|
private logger;
|
|
270
338
|
private tmuxSessionName;
|
|
271
339
|
private tmux;
|
|
@@ -275,6 +343,13 @@ export declare class Daemon extends EventEmitter {
|
|
|
275
343
|
private guardian;
|
|
276
344
|
private adapter;
|
|
277
345
|
private pendingIpcRequests;
|
|
346
|
+
/**
|
|
347
|
+
* Daemon-global request sequence. MCP request ids are only process-local:
|
|
348
|
+
* Claude can have more than one MCP child connected to the same daemon and
|
|
349
|
+
* each starts at 1, so using requestId alone lets one caller steal another's
|
|
350
|
+
* response.
|
|
351
|
+
*/
|
|
352
|
+
private fleetRequestSeq;
|
|
278
353
|
private lastChatId;
|
|
279
354
|
private lastThreadId;
|
|
280
355
|
private lastAdapterId;
|
|
@@ -282,9 +357,6 @@ export declare class Daemon extends EventEmitter {
|
|
|
282
357
|
/** Last activity published to the fleet manager; null when nothing is running. */
|
|
283
358
|
private currentActivity;
|
|
284
359
|
private socketSessionNames;
|
|
285
|
-
private static tmuxServerCrashTimestamps;
|
|
286
|
-
private static tmuxServerPaused;
|
|
287
|
-
private static tmuxServerRecoveryTimer;
|
|
288
360
|
private healthCheckTimer;
|
|
289
361
|
private crashCount;
|
|
290
362
|
private lastCrashAt;
|
|
@@ -305,6 +377,12 @@ export declare class Daemon extends EventEmitter {
|
|
|
305
377
|
private resolveSpawnSettled;
|
|
306
378
|
private spawnDepth;
|
|
307
379
|
private skipResume;
|
|
380
|
+
private startupAborted;
|
|
381
|
+
/** First time the current on-screen blocking dialog was seen (0 = none); drives the parked report. */
|
|
382
|
+
private dialogParkedSince;
|
|
383
|
+
/** Identity of that dialog: its pattern, not its description (two tables may describe one screen differently). */
|
|
384
|
+
private dialogParkedKey;
|
|
385
|
+
private dialogParkedReported;
|
|
308
386
|
private backgroundSessionRecoveryAttempted;
|
|
309
387
|
/** Whether the last spawn started a fresh session (not resumed). */
|
|
310
388
|
isNewSession: boolean;
|
|
@@ -317,6 +395,7 @@ export declare class Daemon extends EventEmitter {
|
|
|
317
395
|
/** Fallback safety sweep used only when no shared tmux control client exists. */
|
|
318
396
|
private instanceStateMonitorTimer;
|
|
319
397
|
private instanceStateIdleTimer;
|
|
398
|
+
private instanceStateOutputProbeTimer;
|
|
320
399
|
private instanceStateStuckTimer;
|
|
321
400
|
private instanceStateOutputListener;
|
|
322
401
|
private instanceStateOutputEventName;
|
|
@@ -331,8 +410,12 @@ export declare class Daemon extends EventEmitter {
|
|
|
331
410
|
private statePollInFlight;
|
|
332
411
|
private turnHadInbound;
|
|
333
412
|
private turnOutboundDelivered;
|
|
413
|
+
/** Successful `reply` specifically; cross-instance tools do not satisfy #648. */
|
|
414
|
+
private turnReplyDelivered;
|
|
334
415
|
private turnCorrelationId;
|
|
335
416
|
private turnInboundMarker;
|
|
417
|
+
/** Prevent a visible stale XML fragment from being recovered on later turns. */
|
|
418
|
+
private lastMalformedToolCallSignature;
|
|
336
419
|
private proxyReplySeq;
|
|
337
420
|
private autoPauseController;
|
|
338
421
|
private pauseRequested;
|
|
@@ -343,6 +426,35 @@ export declare class Daemon extends EventEmitter {
|
|
|
343
426
|
* would silently no-op exactly when we most need to stop feeding the CLI.
|
|
344
427
|
*/
|
|
345
428
|
private pausePending;
|
|
429
|
+
/**
|
|
430
|
+
* An auth failure was detected and nothing has resolved it yet.
|
|
431
|
+
*
|
|
432
|
+
* Separate from `pausePending` because it must outlive it: the deferred pause
|
|
433
|
+
* clears `pausePending` as soon as it fires, but if that pause is refused the
|
|
434
|
+
* instance is still auth-broken and must not resume raising alarms.
|
|
435
|
+
*/
|
|
436
|
+
private authFailureUnresolved;
|
|
437
|
+
/** One login-screen auth report per spawn — the screen persists across polls. */
|
|
438
|
+
private loginScreenReported;
|
|
439
|
+
/** A fatal startup screen (see StartupDialog.fatal) was already reported this run. */
|
|
440
|
+
private fatalStartupReported;
|
|
441
|
+
/**
|
|
442
|
+
* The CLI is parked on a fatal startup screen and every pane write must be
|
|
443
|
+
* refused. This is deliberately separate from the pause that the reported
|
|
444
|
+
* pty_error triggers: the pause is applied by an async handler, and a queued
|
|
445
|
+
* delivery would race it into the modal (where paste+Enter can confirm
|
|
446
|
+
* "Exit and fix manually"). Set synchronously at dialog-match time; cleared
|
|
447
|
+
* when a startup scan reaches a real ready prompt, or on wake().
|
|
448
|
+
*/
|
|
449
|
+
private fatalStartupBlocked;
|
|
450
|
+
/** model_error seen mid-turn: notify only if it survives to the idle screen. */
|
|
451
|
+
private pendingModelErrorKey;
|
|
452
|
+
/**
|
|
453
|
+
* Let the next pause() proceed from a stuck pane. Set only for the auth-deferred
|
|
454
|
+
* pause — see the pausePending consumption site for why waiting for idle there
|
|
455
|
+
* is waiting forever.
|
|
456
|
+
*/
|
|
457
|
+
private pauseAllowStuck;
|
|
346
458
|
private pauseWakeState;
|
|
347
459
|
private pauseWakeTransition;
|
|
348
460
|
private modelOverride;
|
|
@@ -354,6 +466,12 @@ export declare class Daemon extends EventEmitter {
|
|
|
354
466
|
* and ⏳/👀/✅ reactions live here). It does NOT cover the other writers that
|
|
355
467
|
* reach the pane — {@link paneWriteLock} does. */
|
|
356
468
|
private pasteLock;
|
|
469
|
+
/**
|
|
470
|
+
* Fleet cancellation epoch. Queue entries retain the epoch they arrived with;
|
|
471
|
+
* advancing it invalidates only work received before the cancel, never a new
|
|
472
|
+
* user message which arrives immediately afterwards.
|
|
473
|
+
*/
|
|
474
|
+
private deliveryEpoch;
|
|
357
475
|
/** Mutual exclusion for *every* write into the pane, whichever subsystem it
|
|
358
476
|
* comes from. See PaneWriteLock for why interleaving is destructive. */
|
|
359
477
|
private readonly paneWriteLock;
|
|
@@ -363,8 +481,20 @@ export declare class Daemon extends EventEmitter {
|
|
|
363
481
|
private lastBuiltInstructions;
|
|
364
482
|
private pasteQueueDepth;
|
|
365
483
|
private firstDeliveryDelay;
|
|
484
|
+
/** Orders /steer pastes against each other. Deliberately NOT pasteLock:
|
|
485
|
+
* a steer must not queue behind the normal deliveries it exists to
|
|
486
|
+
* overtake. Pane-level exclusion still comes from paneWriteLock inside
|
|
487
|
+
* deliverMessage, so a steer and a normal delivery can never interleave
|
|
488
|
+
* their PTY writes — the steer just doesn't wait for idle. */
|
|
489
|
+
private steerLock;
|
|
490
|
+
/** Tool lines shown in the channel processing bubble for the current turn. */
|
|
491
|
+
private readonly turnProgress;
|
|
492
|
+
private lastProgressBroadcast;
|
|
493
|
+
private progressBroadcastTimer;
|
|
494
|
+
private lastProgressBroadcastAt;
|
|
366
495
|
private errorMonitorTimer;
|
|
367
496
|
private readonly interactivePromptDetector;
|
|
497
|
+
private readonly blockingProcessDetector;
|
|
368
498
|
/** Same 5-min gate the error monitor uses, so a dead MCP server alerts once. */
|
|
369
499
|
private static readonly MCP_DEATH_COOLDOWN_MS;
|
|
370
500
|
private lastMcpDeathNotifiedAt;
|
|
@@ -376,6 +506,16 @@ export declare class Daemon extends EventEmitter {
|
|
|
376
506
|
* past this point interrupting the turn costs less than staying mute.
|
|
377
507
|
*/
|
|
378
508
|
private static readonly MCP_RESTART_MAX_WAIT_MS;
|
|
509
|
+
/**
|
|
510
|
+
* How long the revival restart waits, at the point of firing, for a
|
|
511
|
+
* CLI-respawned MCP server to announce itself.
|
|
512
|
+
*
|
|
513
|
+
* Codex <0.146 tears down and recreates ALL MCP connections on an auth/config
|
|
514
|
+
* change — healthy ones included — so the daemon sees the old pid die while
|
|
515
|
+
* the CLI is fine and a replacement is seconds away. Module load measured
|
|
516
|
+
* ~0.36s, so 2s is roughly 5x headroom without making a genuine loss wait.
|
|
517
|
+
*/
|
|
518
|
+
private static readonly MCP_REPLACEMENT_GRACE_MS;
|
|
379
519
|
/**
|
|
380
520
|
* Sticky "restart to revive the MCP server as soon as the pane idles" — same
|
|
381
521
|
* shape as pausePending, because the death is usually detected mid-turn when
|
|
@@ -384,6 +524,25 @@ export declare class Daemon extends EventEmitter {
|
|
|
384
524
|
*/
|
|
385
525
|
private mcpRestartPending;
|
|
386
526
|
private mcpRestartStaleTimer;
|
|
527
|
+
/** In-flight replacement grace; also the guard against three triggers stacking. */
|
|
528
|
+
private mcpRestartGraceTimer;
|
|
529
|
+
/**
|
|
530
|
+
* Which trigger the in-flight grace will commit under.
|
|
531
|
+
*
|
|
532
|
+
* The single-timer guard would otherwise SWALLOW a stale_timeout that lands
|
|
533
|
+
* during an idle-gated grace — and because the stale timer is one-shot and
|
|
534
|
+
* already cleared itself, the 30-minute backstop would be gone for good on an
|
|
535
|
+
* instance that never idles, which is the exact case it exists for.
|
|
536
|
+
*/
|
|
537
|
+
private mcpRestartGraceTrigger;
|
|
538
|
+
/**
|
|
539
|
+
* A dead-MCP sighting held back once, pending a possible replacement.
|
|
540
|
+
*
|
|
541
|
+
* Deliberately NOT the same field as `mcpDeathNotifiedForPid`: deferring must
|
|
542
|
+
* not consume the once-per-pid budget, or a suspicion that turns out to be a
|
|
543
|
+
* real loss could never be reported at all.
|
|
544
|
+
*/
|
|
545
|
+
private mcpDeathDeferredForPid;
|
|
387
546
|
/** Prevent in-flight monitor callbacks from re-arming after a pause. */
|
|
388
547
|
private runtimeMonitorsFrozen;
|
|
389
548
|
private errorWaitingForRecovery;
|
|
@@ -410,7 +569,9 @@ export declare class Daemon extends EventEmitter {
|
|
|
410
569
|
private lastDetectedErrorType;
|
|
411
570
|
private static errorPatternKey;
|
|
412
571
|
private clearErrorRecoveryGate;
|
|
413
|
-
constructor(name: string, config: InstanceConfig, instanceDir: string, topicMode?: boolean, backend?: CliBackend | undefined, controlClient?: TmuxControlClient | undefined, rootLogger?: Logger, runtimeIdentity?: FleetInstructionsParams["runtimeIdentity"]
|
|
572
|
+
constructor(name: string, config: InstanceConfig, instanceDir: string, topicMode?: boolean, backend?: CliBackend | undefined, controlClient?: TmuxControlClient | undefined, rootLogger?: Logger, runtimeIdentity?: FleetInstructionsParams["runtimeIdentity"], spawnGate?: SpawnGate | undefined, stormWindow?: StormWindow | undefined,
|
|
573
|
+
/** Fleet-level "is this CLI's backend down?" memory — see backend-outage.ts. */
|
|
574
|
+
backendOutage?: BackendOutageView | undefined);
|
|
414
575
|
start(): Promise<void>;
|
|
415
576
|
/**
|
|
416
577
|
* Detect a CRASHED MCP server and report it once.
|
|
@@ -426,7 +587,22 @@ export declare class Daemon extends EventEmitter {
|
|
|
426
587
|
* process would have no client reading it. Only the CLI can restore its own
|
|
427
588
|
* tools — hence notify, and let the operator decide about restarting.
|
|
428
589
|
*/
|
|
590
|
+
/**
|
|
591
|
+
* An MCP server has connected and announced itself.
|
|
592
|
+
*
|
|
593
|
+
* Beyond the existing session bookkeeping this is the earliest evidence that
|
|
594
|
+
* tools are back — roughly 30s ahead of the next health tick, which is
|
|
595
|
+
* exactly the window #663's false restarts fired in.
|
|
596
|
+
*/
|
|
597
|
+
private handleMcpReady;
|
|
429
598
|
private checkMcpServerAlive;
|
|
599
|
+
/**
|
|
600
|
+
* Whether a dead MCP pid on this backend is more likely a CLI-driven
|
|
601
|
+
* replacement than a real loss. Codex only, and deliberately narrow: it is
|
|
602
|
+
* the backend whose released fix (0.146) confirms it tore down healthy MCP
|
|
603
|
+
* connections alongside the one it meant to restart.
|
|
604
|
+
*/
|
|
605
|
+
private suspectsTransientMcpReplacement;
|
|
430
606
|
/**
|
|
431
607
|
* Arm an automatic instance restart to revive a dead MCP server. Fires on the
|
|
432
608
|
* next busy→idle edge — or immediately when the pane is already idle, which is
|
|
@@ -435,7 +611,36 @@ export declare class Daemon extends EventEmitter {
|
|
|
435
611
|
* force-restarted: see that constant for why staying mute costs more.
|
|
436
612
|
*/
|
|
437
613
|
private armMcpRestartWhenIdle;
|
|
614
|
+
/**
|
|
615
|
+
* Single chokepoint for all three revival triggers (already_idle, idle_edge,
|
|
616
|
+
* stale_timeout) — and therefore the one place worth re-checking reality.
|
|
617
|
+
*
|
|
618
|
+
* The pending flag is armed by a health tick that saw the OLD pid die, and
|
|
619
|
+
* was previously fired without ever looking again. When a CLI legitimately
|
|
620
|
+
* respawns its own MCP child, the replacement is already serving by the time
|
|
621
|
+
* the turn ends — but the idle edge fires inside the ~30s before the next
|
|
622
|
+
* health tick can stand the request down, restarting a healthy instance. One
|
|
623
|
+
* external user was restarted 18 times in two days this way (#663).
|
|
624
|
+
*
|
|
625
|
+
* Re-reading here is safe for every backend: worst case it clears a pending
|
|
626
|
+
* restart that should not have existed.
|
|
627
|
+
*/
|
|
438
628
|
private fireMcpRestartRequest;
|
|
629
|
+
/**
|
|
630
|
+
* A recovery is already reshaping the CLI: crash-loop handling
|
|
631
|
+
* (healthCheckPaused), a respawn in flight (spawning), or a pause
|
|
632
|
+
* (isPaused / frozen monitors). Each ends in a fresh CLI — and with it a
|
|
633
|
+
* fresh MCP server — or in supervision ending, where a restart on top would
|
|
634
|
+
* fight the recovery. Either way the revival restart is moot.
|
|
635
|
+
*/
|
|
636
|
+
private mcpRestartCancelledByRecovery;
|
|
637
|
+
/**
|
|
638
|
+
* Emit a dead-MCP report that was held back as a suspected replacement, once
|
|
639
|
+
* it is clear no replacement is coming. Consumes the once-per-pid budget
|
|
640
|
+
* here — deferring was to avoid spending it on a false alarm, not to drop
|
|
641
|
+
* the incident.
|
|
642
|
+
*/
|
|
643
|
+
private reportDeferredMcpDeath;
|
|
439
644
|
private clearMcpRestartRequest;
|
|
440
645
|
private startHealthCheck;
|
|
441
646
|
/**
|
|
@@ -469,6 +674,8 @@ export declare class Daemon extends EventEmitter {
|
|
|
469
674
|
private startErrorMonitor;
|
|
470
675
|
/** Evaluate one pane snapshot. Kept synchronous so state-machine edges are unit-testable. */
|
|
471
676
|
private evaluateErrorPatterns;
|
|
677
|
+
/** Arm the recovery gates and emit one detected error pattern. */
|
|
678
|
+
private emitErrorPattern;
|
|
472
679
|
/**
|
|
473
680
|
* Notification text for a detected pattern. `formatMessage` patterns build it
|
|
474
681
|
* from the match so the user gets the specifics (e.g. which period and what
|
|
@@ -490,12 +697,37 @@ export declare class Daemon extends EventEmitter {
|
|
|
490
697
|
* that message, which is what the user asked for anyway.
|
|
491
698
|
*/
|
|
492
699
|
sendEscape(): Promise<void>;
|
|
700
|
+
/**
|
|
701
|
+
* Drop every not-yet-started pane delivery which predates a user cancel.
|
|
702
|
+
* Promise chains cannot be removed, so entries become generation-checked
|
|
703
|
+
* no-ops. An entry already past its check is allowed to finish its current PTY
|
|
704
|
+
* transaction; the interrupt key still cancels the CLI generation.
|
|
705
|
+
*/
|
|
706
|
+
clearPendingDeliveries(fleetEpoch?: number): void;
|
|
707
|
+
private captureDeliveryEpoch;
|
|
708
|
+
private isDeliveryEpochCurrent;
|
|
709
|
+
private queueRawPaste;
|
|
710
|
+
/**
|
|
711
|
+
* Confirm a backend's terminal-level /clear prompt after the channel-level
|
|
712
|
+
* admin confirmation has already succeeded. Poll instead of pasting `/clear\ny`
|
|
713
|
+
* as one buffer: Kiro versions that clear immediately interpret that queued
|
|
714
|
+
* `y` as a brand-new user message.
|
|
715
|
+
*/
|
|
716
|
+
private confirmBackendClearDialog;
|
|
493
717
|
/** Send the backend-specific graceful quit command/key sequence. */
|
|
494
718
|
private sendQuitSequence;
|
|
495
719
|
stop(): Promise<void>;
|
|
496
720
|
getHangDetector(): HangDetector | null;
|
|
497
721
|
getInstanceState(): InstanceState | "paused";
|
|
498
722
|
getInstanceStateSnapshot(): InstanceStateSnapshot;
|
|
723
|
+
/**
|
|
724
|
+
* Answer a FleetManager state query. Most callers only need the cached state,
|
|
725
|
+
* but lifecycle decisions such as post-reply Cancel retirement need an
|
|
726
|
+
* authoritative pane observation: after startup the last transition can stay
|
|
727
|
+
* "working" even though the CLI has since settled without emitting another
|
|
728
|
+
* control-mode output record.
|
|
729
|
+
*/
|
|
730
|
+
private respondToInstanceStateQuery;
|
|
499
731
|
/** Gracefully stop the CLI while keeping its remain-on-exit tmux window. */
|
|
500
732
|
/**
|
|
501
733
|
* Mark the instance to pause as soon as its pane is idle. Used for auth
|
|
@@ -522,9 +754,21 @@ export declare class Daemon extends EventEmitter {
|
|
|
522
754
|
* here (edge-triggered, then reset) is what makes it at most once per turn.
|
|
523
755
|
*/
|
|
524
756
|
private maybeProxyReplyOnTurnEnd;
|
|
757
|
+
private isClaudeCodeBackend;
|
|
525
758
|
/** Relay the pane's final text to the channel, marked as a daemon proxy reply. */
|
|
526
759
|
private sendProxyReply;
|
|
760
|
+
/** Send a narrowly extracted #648 reply; operator notification is a separate event. */
|
|
761
|
+
private sendRecoveredMalformedReply;
|
|
762
|
+
/** Context-bound reply path shared by dead-MCP and malformed-call recovery. */
|
|
763
|
+
private deliverDaemonReply;
|
|
527
764
|
private clearInstanceStateIdleTimer;
|
|
765
|
+
private clearInstanceStateOutputProbeTimer;
|
|
766
|
+
/**
|
|
767
|
+
* Periodic status-line hooks can generate `%output` without changing a single
|
|
768
|
+
* visible cell. Probe the pane once per burst: a changed capture is real work;
|
|
769
|
+
* an identical ready capture remains idle and emits no state edge.
|
|
770
|
+
*/
|
|
771
|
+
private scheduleInstanceStateOutputProbe;
|
|
528
772
|
private clearInstanceStateStuckTimer;
|
|
529
773
|
private scheduleInstanceStateStuckDeadline;
|
|
530
774
|
private scheduleInstanceStateIdleCapture;
|
|
@@ -543,14 +787,48 @@ export declare class Daemon extends EventEmitter {
|
|
|
543
787
|
* Tell the fleet manager what this instance is doing right now, for the live
|
|
544
788
|
* progress line on the cancel button.
|
|
545
789
|
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
790
|
+
* Primarily cosmetic. The foreground-process detector also uses a current
|
|
791
|
+
* shell activity as one of several positive signals, but never makes a state
|
|
792
|
+
* decision from an arbitrary activity label alone.
|
|
549
793
|
*
|
|
550
794
|
* Repeats are dropped: the ticker only edits the channel message when the text
|
|
551
795
|
* changes, and a stream of identical broadcasts would defeat that.
|
|
552
796
|
*/
|
|
553
797
|
private publishActivity;
|
|
798
|
+
/** Effective tool_progress level, hardened against junk config values.
|
|
799
|
+
* Off unless explicitly enabled: an update must never make bubbles start
|
|
800
|
+
* listing tool activity the operator did not ask to broadcast. */
|
|
801
|
+
private toolProgressLevel;
|
|
802
|
+
/**
|
|
803
|
+
* Apply a tool-progress setting without restarting the CLI session.
|
|
804
|
+
*
|
|
805
|
+
* Drop the current accumulator at the boundary: verbose entries may contain
|
|
806
|
+
* command previews which must not survive a downgrade to standard/off, and a
|
|
807
|
+
* newly enabled level should start with a clean, internally consistent list.
|
|
808
|
+
*/
|
|
809
|
+
updateToolProgress(level: InstanceConfig["tool_progress"]): void;
|
|
810
|
+
/** Snapshot the configuration actually owned by this live daemon. */
|
|
811
|
+
getConfigSnapshot(): InstanceConfig;
|
|
812
|
+
/**
|
|
813
|
+
* Apply the whitelisted hot configuration carried by FleetManager IPC.
|
|
814
|
+
* null removes an optional value; invalid/unlisted fields are ignored rather
|
|
815
|
+
* than allowing another client on the per-instance socket to mutate cold
|
|
816
|
+
* process/session settings.
|
|
817
|
+
*/
|
|
818
|
+
applyConfigUpdate(value: unknown): void;
|
|
819
|
+
/**
|
|
820
|
+
* Accumulate one semantic progress line for the channel bubble and schedule
|
|
821
|
+
* a coalesced broadcast. Separate from publishActivity on purpose: that one
|
|
822
|
+
* is the single-line statusline detail (terse, operator-facing), this is the
|
|
823
|
+
* multi-line channel list (semantic, argument-free at `standard`) — see
|
|
824
|
+
* tool-progress.ts for why the two labellers must not merge.
|
|
825
|
+
*/
|
|
826
|
+
private recordToolProgress;
|
|
827
|
+
/** Coalesce progress broadcasts: at most one per 3s, trailing edge kept. */
|
|
828
|
+
private scheduleProgressBroadcast;
|
|
829
|
+
private broadcastToolProgress;
|
|
830
|
+
/** New turn (or turn over): drop the list and tell the fleet to clear it. */
|
|
831
|
+
private resetToolProgress;
|
|
554
832
|
/**
|
|
555
833
|
* Options for every system-initiated paste (startup notice, session snapshot,
|
|
556
834
|
* runtime-dialog keys).
|
|
@@ -562,12 +840,46 @@ export declare class Daemon extends EventEmitter {
|
|
|
562
840
|
*/
|
|
563
841
|
private systemPasteOptions;
|
|
564
842
|
private summarizeTool;
|
|
843
|
+
/**
|
|
844
|
+
* The one place an inbound message grows its metadata wrapper ([user:]/
|
|
845
|
+
* [from:] prefix, pending reactions, handoff metadata, reply instructions).
|
|
846
|
+
* Both the normal queued path (pushChannelMessage) and /steer go through
|
|
847
|
+
* here — a steered message must read EXACTLY like a queued one to the
|
|
848
|
+
* agent, or the two drift apart in what the agent is told about replying.
|
|
849
|
+
*/
|
|
850
|
+
private formatInboundMessage;
|
|
851
|
+
/** Tell the fleet when an already-accepted cross-instance pane write failed. */
|
|
852
|
+
private reportCrossInstanceDeliveryFailure;
|
|
853
|
+
/**
|
|
854
|
+
* /steer: interject into the CURRENT turn instead of queueing for idle.
|
|
855
|
+
*
|
|
856
|
+
* Differences from pushChannelMessage, and nothing else:
|
|
857
|
+
* - serialized on steerLock, not pasteLock — it may overtake current work,
|
|
858
|
+
* but never an ordinary delivery already queued ahead of it
|
|
859
|
+
* - deliverMessage runs with { steer: true }, which takes the busy branch
|
|
860
|
+
* that pastes immediately (the codex native-queue transaction) instead of
|
|
861
|
+
* waiting for idle. Verification and silent-loss fallback are the ones
|
|
862
|
+
* that path already has: pane-capture visibility check, then one
|
|
863
|
+
* idle-gated redelivery — so on a TUI that swallows busy input the steer
|
|
864
|
+
* degrades to "next message after this turn", never silently vanishes.
|
|
865
|
+
*
|
|
866
|
+
* The steered text goes through formatInboundMessage so the agent sees a
|
|
867
|
+
* normal inbound message, with a steering notice prepended for context.
|
|
868
|
+
*/
|
|
869
|
+
steerMessage(content: string, meta: Record<string, string>, deliveryEpoch?: number): void;
|
|
870
|
+
/**
|
|
871
|
+
* /btw: submit a separately-labelled side question immediately while asking
|
|
872
|
+
* the agent not to change the active task. Claude's native `/btw` opens a
|
|
873
|
+
* branchAndResume panel whose answer never reaches the channel or transcript,
|
|
874
|
+
* so channel delivery intentionally uses a normal wrapped inbound instead.
|
|
875
|
+
*/
|
|
876
|
+
btwMessage(content: string, meta: Record<string, string>, deliveryEpoch?: number): void;
|
|
565
877
|
/**
|
|
566
878
|
* Push an inbound channel message to a specific MCP session.
|
|
567
879
|
* If targetSession is provided, only send to the matching socket.
|
|
568
880
|
* Otherwise send to the instance's own session (this.name).
|
|
569
881
|
*/
|
|
570
|
-
pushChannelMessage(content: string, meta: Record<string, string>, _targetSession?: string): void;
|
|
882
|
+
pushChannelMessage(content: string, meta: Record<string, string>, _targetSession?: string, deliveryEpoch?: number): void;
|
|
571
883
|
/**
|
|
572
884
|
* Deliver a single message and drive its status reactions:
|
|
573
885
|
* ⏳ message_queued — CLI busy; queued locally or by the backend
|
|
@@ -585,6 +897,121 @@ export declare class Daemon extends EventEmitter {
|
|
|
585
897
|
* serial in both cases so separate PTY writes can never overlap.
|
|
586
898
|
*/
|
|
587
899
|
private deliverMessage;
|
|
900
|
+
/**
|
|
901
|
+
* The runtime dialogs that hold delivery while on screen (`blocksDelivery`
|
|
902
|
+
* or `holdOnly`). One canonical list and order, shared by the delivery gate
|
|
903
|
+
* and the runtime scanner, so both observers agree on which dialog they see.
|
|
904
|
+
* Startup-only patterns are deliberately excluded: several of them are loose
|
|
905
|
+
* on purpose ("I trust", "Yes, continue") and would match ordinary prose.
|
|
906
|
+
*/
|
|
907
|
+
private deliveryBlockingDialogs;
|
|
908
|
+
private static dialogKey;
|
|
909
|
+
/** A dialog counts only when it is the CURRENT interactive region, if the backend can tell; else by pattern. */
|
|
910
|
+
private static dialogMatches;
|
|
911
|
+
/**
|
|
912
|
+
* Tri-state liveness. tmux's own isWindowAlive folds every query failure
|
|
913
|
+
* into `false`, so a transient tmux hiccup would read as "the CLI died" —
|
|
914
|
+
* and callers that clear the session on death must not act on that.
|
|
915
|
+
* getPaneStatus returns null on a failed/ambiguous query and a definite
|
|
916
|
+
* `{alive:false}` for a dead pane; only the latter is evidence.
|
|
917
|
+
*/
|
|
918
|
+
private paneLiveness;
|
|
919
|
+
/**
|
|
920
|
+
* Capture the pane and classify it. "unknown" (capture failed) is a distinct
|
|
921
|
+
* outcome on purpose: the resume dialog is silent, so silence cannot vouch
|
|
922
|
+
* for the pane, and treating an unreadable pane as clear is exactly the
|
|
923
|
+
* fail-open that answers a dialog with its default. Callers retry unknown
|
|
924
|
+
* within a bound and then fail loudly.
|
|
925
|
+
*/
|
|
926
|
+
private probeBlockingDialog;
|
|
927
|
+
/**
|
|
928
|
+
* Remember how long a blocking dialog has been on screen. Once it has
|
|
929
|
+
* outlived DIALOG_PARKED_NOTIFY_MS — the auto-dismiss did not take, or the
|
|
930
|
+
* dialog is a hold-only variant — report it ONCE so a human answers it.
|
|
931
|
+
* Never presses a key: the whole point is that we do not know which option
|
|
932
|
+
* is safe. Identity is the pattern, so the delivery gate and the runtime
|
|
933
|
+
* scanner (same canonical list) never reset each other's clock.
|
|
934
|
+
*/
|
|
935
|
+
private trackDialogParked;
|
|
936
|
+
/**
|
|
937
|
+
* Bottom-anchored readiness for TUIs that drop Enter while busy (see
|
|
938
|
+
* CliBackend.dropsEnterWhileBusy). Output silence is necessary but not
|
|
939
|
+
* sufficient for them: Kiro paints nothing for the whole duration of a shell
|
|
940
|
+
* or MCP tool call (and for each 10s backend retry), yet an Enter arriving
|
|
941
|
+
* then is discarded. Reproduced deterministically: `sleep 9` tool, paste at
|
|
942
|
+
* t+6s → text stranded in the prompt row, next message submitted both.
|
|
943
|
+
* Other backends keep the silence-based gate byte-for-byte.
|
|
944
|
+
*/
|
|
945
|
+
private isPaneReadyForDelivery;
|
|
946
|
+
/**
|
|
947
|
+
* Why a pane is not deliverable matters. "busy" may be handed to a native
|
|
948
|
+
* input queue or steered (after its own dialog probe); "dialog" and "unknown"
|
|
949
|
+
* must never be — a paste + Enter into a dialog answers it with its default,
|
|
950
|
+
* and an unreadable pane proves nothing. The silence gate comes first and
|
|
951
|
+
* costs no capture, so a CLI that is simply working never pays for the probe.
|
|
952
|
+
*/
|
|
953
|
+
private paneReadinessForDelivery;
|
|
954
|
+
/**
|
|
955
|
+
* Like waitForPaneIdleForDelivery, plus the bottom-anchored prompt check for
|
|
956
|
+
* Enter-dropping TUIs. Polls at a coarse cadence (each poll is a capture-pane)
|
|
957
|
+
* only after the pane is already quiet, so the common fast-idle delivery still
|
|
958
|
+
* costs a single capture.
|
|
959
|
+
*/
|
|
960
|
+
private waitForPaneReadyForDelivery;
|
|
961
|
+
/**
|
|
962
|
+
* F3: if an AgEnD message is sitting unsubmitted in the input row (a previous
|
|
963
|
+
* delivery's Enter was dropped), submit it with one bare Enter under the pane
|
|
964
|
+
* lock. Only acts on a positive signature — the `[user:`/`[from:` marker every
|
|
965
|
+
* pasted message carries — never on Kiro's own placeholder hints.
|
|
966
|
+
*
|
|
967
|
+
* Outcomes: "idle" = positively verified nothing stranded (the caller may
|
|
968
|
+
* paste); "submitted" = an Enter went out for the stranded text; "busy" = the
|
|
969
|
+
* pane is not at its prompt or could not be read (the caller must wait for
|
|
970
|
+
* the prompt and run this check AGAIN before pasting — never assume someone
|
|
971
|
+
* else submitted it); "failed" = the Enter could not be sent (the delivery
|
|
972
|
+
* must fail rather than paste on top of the stranded text).
|
|
973
|
+
*/
|
|
974
|
+
private submitStrandedInputIfAny;
|
|
975
|
+
/**
|
|
976
|
+
* "stranded": an AgEnD message sits in the input row; "clear": the prompt is
|
|
977
|
+
* at the bottom with no stranded text; "busy": generating, or the prompt is
|
|
978
|
+
* not at the bottom (incl. a blank frame); "unknown": the pane could not be
|
|
979
|
+
* read. Only "clear" is positive evidence.
|
|
980
|
+
*/
|
|
981
|
+
private strandedInputState;
|
|
982
|
+
/**
|
|
983
|
+
* F2: for Enter-dropping TUIs, "some output after Enter" proves nothing — the
|
|
984
|
+
* turn that made the pane look idle keeps producing output. Confirm the
|
|
985
|
+
* SUBMISSION instead: the pasted text is gone from the input row ("absent"),
|
|
986
|
+
* or the TUI's own busy marker is up. "unknown" = the pane could not be read;
|
|
987
|
+
* it never counts as confirmed.
|
|
988
|
+
*/
|
|
989
|
+
private pasteResidue;
|
|
990
|
+
/**
|
|
991
|
+
* Submission = the legacy idle→busy output signal AND the pasted text has
|
|
992
|
+
* verifiably left the input row. The first alone is what produced false ✅s:
|
|
993
|
+
* the turn that made the pane look idle keeps emitting output after our
|
|
994
|
+
* (dropped) Enter — and an unreadable pane is not a verified absence either.
|
|
995
|
+
*/
|
|
996
|
+
private confirmSubmittedAfterEnter;
|
|
997
|
+
/**
|
|
998
|
+
* While the CLI is parked on a fatal startup screen (see fatalStartupBlocked),
|
|
999
|
+
* no pane write may happen: paste+Enter into the corrupt-config modal would
|
|
1000
|
+
* confirm "Exit and fix manually" and exit the CLI. The message is failed (❌)
|
|
1001
|
+
* rather than held — the accompanying config_error notification tells the user
|
|
1002
|
+
* what to fix, and holding would only build a queue that floods the pane the
|
|
1003
|
+
* moment the flag clears.
|
|
1004
|
+
*/
|
|
1005
|
+
private refuseFatalStartupDelivery;
|
|
1006
|
+
/**
|
|
1007
|
+
* A raw `%output` silence check is authoritative for ordinary TUIs. It is not
|
|
1008
|
+
* for a backend such as agy whose status-line hook periodically redraws an
|
|
1009
|
+
* identical screen. In that case trust an idle pane-state snapshot only when
|
|
1010
|
+
* it was captured after both the latest output and the latest control-client
|
|
1011
|
+
* observation reset.
|
|
1012
|
+
*/
|
|
1013
|
+
private isPaneIdleForDelivery;
|
|
1014
|
+
private waitForPaneIdleForDelivery;
|
|
588
1015
|
/**
|
|
589
1016
|
* The write half of a delivery: paste → Enter → confirm, with retries.
|
|
590
1017
|
*
|
|
@@ -661,6 +1088,49 @@ export declare class Daemon extends EventEmitter {
|
|
|
661
1088
|
private waitForSpawnToSettle;
|
|
662
1089
|
/** Spawn a CLI window. Returns true if --resume was used successfully. */
|
|
663
1090
|
private spawnClaudeWindow;
|
|
1091
|
+
/**
|
|
1092
|
+
* Startup budget for this launch: the backend's override (resume-aware), never
|
|
1093
|
+
* below a user-configured startup_timeout_ms; undefined = trySpawn's default.
|
|
1094
|
+
*/
|
|
1095
|
+
private startupBudgetFor;
|
|
1096
|
+
/** Effective wake budget = max(caller timeout, backend resume override, configured startup_timeout_ms). */
|
|
1097
|
+
wakeBudgetMs(timeoutMs: number): number;
|
|
1098
|
+
/** The fleet-level backend key this instance runs on (matches the lifecycle's backendOf). */
|
|
1099
|
+
private backendKey;
|
|
1100
|
+
/**
|
|
1101
|
+
* After a failed launch, read the pane for the backend's fleet-wide outage
|
|
1102
|
+
* text (e.g. kiro's `dispatch failure (timeout) … kiro.dev`) and record it.
|
|
1103
|
+
* The lifecycle only learns about outages from RUNNING instances; during a
|
|
1104
|
+
* post-update herd nothing is running yet, so the startup path must report
|
|
1105
|
+
* what it sees or the first instance in would clear its session for nothing.
|
|
1106
|
+
*/
|
|
1107
|
+
private noteStartupPaneForBackendOutage;
|
|
1108
|
+
/**
|
|
1109
|
+
* Fail the startup WITHOUT touching the session while the backend is known to
|
|
1110
|
+
* be down. The failed window is torn down first: the alternative — a live but
|
|
1111
|
+
* never-ready CLI left behind while the daemon reports `crashed` — would keep
|
|
1112
|
+
* the health monitor from ever seeing a dead pane and retrying.
|
|
1113
|
+
*/
|
|
1114
|
+
private failStartupIfBackendUnreachable;
|
|
1115
|
+
/**
|
|
1116
|
+
* Crash-respawn ran into the backend outage: the ordinary path would leave
|
|
1117
|
+
* `crashed` + a paused monitor + nothing scheduled (and count it as a crash).
|
|
1118
|
+
* Hand the instance to the fleet instead — the lifecycle stops this daemon
|
|
1119
|
+
* and the fleet's delayed startup retry re-creates it later with the session
|
|
1120
|
+
* intact. Returns true when someone took the hand-off.
|
|
1121
|
+
*/
|
|
1122
|
+
private handOffBackendUnreachableRespawn;
|
|
1123
|
+
/**
|
|
1124
|
+
* Dispose a Daemon whose start() rejected. The lifecycle registers a daemon
|
|
1125
|
+
* only after start() resolves, so nothing else owns this object — and by the
|
|
1126
|
+
* time the spawn fails it has already bound its IPC server (channel.sock),
|
|
1127
|
+
* written daemon.pid and possibly created a window. Left alone, each failed
|
|
1128
|
+
* start leaks one live-but-unreachable server handle (the next start unlinks
|
|
1129
|
+
* the socket path and binds a new one), multiplied by the automatic startup
|
|
1130
|
+
* retries. Idempotent, and fast: no graceful CLI quit, the CLI never reached
|
|
1131
|
+
* its prompt.
|
|
1132
|
+
*/
|
|
1133
|
+
abortStartup(): Promise<void>;
|
|
664
1134
|
/** Kill the entire process tree of the current tmux pane (CLI + MCP server). */
|
|
665
1135
|
private killProcessTree;
|
|
666
1136
|
/**
|
|
@@ -670,9 +1140,34 @@ export declare class Daemon extends EventEmitter {
|
|
|
670
1140
|
* Returns true if CLI is ready, false if it failed or got stuck.
|
|
671
1141
|
*/
|
|
672
1142
|
private trySpawn;
|
|
1143
|
+
private trySpawnInsideGate;
|
|
1144
|
+
/**
|
|
1145
|
+
* The last leg of a spawn: confirm the pane is not positively dead, then run
|
|
1146
|
+
* the dialog scan. The old pre-check used tmux's isWindowAlive(), which folds
|
|
1147
|
+
* every query failure into `false` — so one transient tmux error right here
|
|
1148
|
+
* read as "the CLI died", the caller abandoned --resume and cleared the
|
|
1149
|
+
* session, before the tri-state scanner ever got a look. Only a POSITIVE
|
|
1150
|
+
* dead pane fails; an unknown liveness is the scanner's problem (bounded,
|
|
1151
|
+
* session-preserving).
|
|
1152
|
+
*/
|
|
1153
|
+
private finishStartupScan;
|
|
673
1154
|
/**
|
|
674
|
-
*
|
|
675
|
-
* and return true once CLI
|
|
1155
|
+
* Poll the pane within a wall-clock budget, dismiss the confirmation dialogs
|
|
1156
|
+
* the backend knows, and return true once the CLI shows a ready prompt with
|
|
1157
|
+
* no dialog on screen for two consecutive polls.
|
|
1158
|
+
*
|
|
1159
|
+
* Polls are spaced by `pollMs` and every key sequence / render wait counts
|
|
1160
|
+
* against the budget: Claude paints its session-resume prompt only after
|
|
1161
|
+
* loading the session, i.e. AFTER the first quiet moment, and three
|
|
1162
|
+
* back-to-back captures used to miss it — the scan then "assumed ok", the
|
|
1163
|
+
* `❯` inside the dialog satisfied the ready pattern, and the instance sat on
|
|
1164
|
+
* the dialog with deliveries free to press Enter into it.
|
|
1165
|
+
*
|
|
1166
|
+
* Only hard evidence returns false: a dead window or "command not found".
|
|
1167
|
+
* A transient capture failure is logged and retried; exhausting the budget is
|
|
1168
|
+
* logged at WARN and returns true — false makes the caller abandon --resume
|
|
1169
|
+
* and clear the session, which is the loss this code exists to prevent. The
|
|
1170
|
+
* delivery gate keeps refusing pastes while a blocking dialog is visible.
|
|
676
1171
|
*/
|
|
677
1172
|
private dismissDialogsUntilReady;
|
|
678
1173
|
/**
|