@songsid/agend 2.1.2-beta.3 → 2.1.2-beta.30
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/access-path.js +15 -6
- package/dist/access-path.js.map +1 -1
- package/dist/agent-cli-instructions.md +1 -0
- package/dist/agent-cli.js +14 -0
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.d.ts +2 -0
- package/dist/agent-endpoint.js +25 -1
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/backend/antigravity.d.ts +20 -0
- package/dist/backend/antigravity.js +37 -3
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-code.d.ts +59 -0
- package/dist/backend/claude-code.js +67 -1
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex.d.ts +3 -0
- package/dist/backend/codex.js +30 -0
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/grok.d.ts +25 -0
- package/dist/backend/grok.js +51 -0
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/kiro.d.ts +22 -0
- package/dist/backend/kiro.js +85 -3
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +58 -0
- package/dist/backend/types.js +13 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +15 -0
- package/dist/channel/adapters/discord.js +100 -2
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +21 -0
- package/dist/channel/adapters/telegram.js +86 -0
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/ipc-bridge.d.ts +9 -1
- package/dist/channel/ipc-bridge.js +12 -3
- package/dist/channel/ipc-bridge.js.map +1 -1
- package/dist/channel/ipc-timeouts.d.ts +46 -0
- package/dist/channel/ipc-timeouts.js +65 -0
- package/dist/channel/ipc-timeouts.js.map +1 -0
- package/dist/channel/mcp-server.js +30 -14
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +30 -1
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/reconnect-backoff.d.ts +17 -0
- package/dist/channel/reconnect-backoff.js +21 -0
- package/dist/channel/reconnect-backoff.js.map +1 -0
- package/dist/channel/types.d.ts +29 -0
- package/dist/classic-channel-manager.js +1 -5
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/cli.js +155 -63
- package/dist/cli.js.map +1 -1
- package/dist/completion.d.ts +27 -0
- package/dist/completion.js +121 -0
- package/dist/completion.js.map +1 -0
- package/dist/config-validator.js +21 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/cost-guard.d.ts +3 -1
- package/dist/cost-guard.js +3 -1
- package/dist/cost-guard.js.map +1 -1
- package/dist/daemon.d.ts +240 -14
- package/dist/daemon.js +956 -308
- package/dist/daemon.js.map +1 -1
- package/dist/event-log.d.ts +31 -0
- package/dist/event-log.js +96 -0
- package/dist/event-log.js.map +1 -1
- package/dist/fleet-context.d.ts +9 -0
- package/dist/fleet-manager.d.ts +311 -2
- package/dist/fleet-manager.js +1369 -108
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +22 -0
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +14 -23
- package/dist/general-knowledge/skills/session-management/SKILL.md +15 -34
- package/dist/hang-detector.d.ts +19 -13
- package/dist/hang-detector.js +19 -49
- package/dist/hang-detector.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +43 -1
- package/dist/instance-lifecycle.js +155 -43
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +5 -0
- package/dist/instructions.js +9 -11
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +5 -1
- package/dist/locale.js.map +1 -1
- package/dist/logger.js +14 -0
- package/dist/logger.js.map +1 -1
- package/dist/mcp-liveness.d.ts +21 -0
- package/dist/mcp-liveness.js +27 -0
- package/dist/mcp-liveness.js.map +1 -0
- package/dist/outbound-handlers.d.ts +16 -0
- package/dist/outbound-handlers.js +151 -27
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +11 -3
- package/dist/outbound-schemas.js +16 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-write-lock.d.ts +48 -0
- package/dist/pane-write-lock.js +73 -0
- package/dist/pane-write-lock.js.map +1 -0
- package/dist/process-memory.d.ts +31 -0
- package/dist/process-memory.js +79 -0
- package/dist/process-memory.js.map +1 -0
- package/dist/quickstart.js +17 -16
- package/dist/quickstart.js.map +1 -1
- package/dist/reply-dedup.d.ts +41 -0
- package/dist/reply-dedup.js +0 -0
- package/dist/reply-dedup.js.map +1 -0
- package/dist/scheduler/db.js +3 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/sd-notify.d.ts +27 -0
- package/dist/sd-notify.js +33 -1
- package/dist/sd-notify.js.map +1 -1
- package/dist/secret-file.d.ts +33 -0
- package/dist/secret-file.js +36 -0
- package/dist/secret-file.js.map +1 -0
- package/dist/setup-wizard.js +9 -7
- package/dist/setup-wizard.js.map +1 -1
- package/dist/tmux-control.d.ts +58 -5
- package/dist/tmux-control.js +102 -14
- package/dist/tmux-control.js.map +1 -1
- package/dist/tmux-manager.d.ts +31 -1
- package/dist/tmux-manager.js +40 -11
- package/dist/tmux-manager.js.map +1 -1
- package/dist/topic-commands.d.ts +50 -10
- package/dist/topic-commands.js +269 -106
- package/dist/topic-commands.js.map +1 -1
- package/dist/tui-glyphs.d.ts +25 -0
- package/dist/tui-glyphs.js +26 -0
- package/dist/tui-glyphs.js.map +1 -0
- package/dist/types.d.ts +12 -2
- package/dist/ui/view.html +123 -2
- package/dist/update-marker.d.ts +15 -0
- package/dist/update-marker.js +69 -0
- package/dist/update-marker.js.map +1 -0
- package/dist/usage/format-rich.d.ts +11 -0
- package/dist/usage/format-rich.js +121 -0
- package/dist/usage/format-rich.js.map +1 -0
- package/dist/usage/providers.d.ts +130 -0
- package/dist/usage/providers.js +1030 -0
- package/dist/usage/providers.js.map +1 -0
- package/dist/usage/statusline-usage.d.ts +20 -0
- package/dist/usage/statusline-usage.js +120 -0
- package/dist/usage/statusline-usage.js.map +1 -0
- package/dist/usage/usage-api.d.ts +50 -0
- package/dist/usage/usage-api.js +167 -0
- package/dist/usage/usage-api.js.map +1 -0
- package/dist/view-api.d.ts +3 -0
- package/dist/view-api.js +11 -2
- package/dist/view-api.js.map +1 -1
- package/dist/web-api.js +5 -2
- package/dist/web-api.js.map +1 -1
- package/package.json +4 -1
- package/dist/channel/tool-tracker.d.ts +0 -13
- package/dist/channel/tool-tracker.js +0 -58
- package/dist/channel/tool-tracker.js.map +0 -1
- package/dist/daemon-entry.d.ts +0 -1
- package/dist/daemon-entry.js +0 -30
- package/dist/daemon-entry.js.map +0 -1
package/dist/daemon.d.ts
CHANGED
|
@@ -1,21 +1,65 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import type { InstanceConfig, RotationSnapshot } from "./types.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type Logger } from "./logger.js";
|
|
4
4
|
import { MessageBus } from "./channel/message-bus.js";
|
|
5
5
|
import type { CliBackend, InstanceState, InstanceStateSnapshot } from "./backend/types.js";
|
|
6
6
|
import { HangDetector } from "./hang-detector.js";
|
|
7
7
|
import type { TmuxControlClient } from "./tmux-control.js";
|
|
8
|
+
import type { FleetInstructionsParams } from "./instructions.js";
|
|
8
9
|
/** Point a resumed CLI at its one backend-native instruction source. */
|
|
9
10
|
export declare function buildInstructionReloadNotice(binaryName: string, instanceName: string, instanceDir: string): string;
|
|
10
11
|
export declare const DEFAULT_STUCK_TIMEOUT_MS: number;
|
|
11
12
|
export declare const DEFAULT_STATE_IDLE_DEBOUNCE_MS = 2000;
|
|
12
13
|
export declare const DEFAULT_STATE_SAFETY_SWEEP_MS = 60000;
|
|
13
|
-
/**
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Whether two working directories belong to the same project, so a fleet-scoped
|
|
16
|
+
* decision recorded in one reaches the other. Covers the worktree/checkout
|
|
17
|
+
* layout AgEnD fleets actually use — `AgEnD`, `AgEnD-dev1`, `AgEnD-dev2`,
|
|
18
|
+
* `AgEnD-reviewer`, `AgEnD-main` are one project; `DouPo_Server` is not.
|
|
19
|
+
* Nesting counts too (a subdirectory of a project belongs to it).
|
|
20
|
+
*/
|
|
21
|
+
export declare function sameProjectFamily(a: string, b: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Pick the decisions worth injecting into one instance's system prompt.
|
|
24
|
+
*
|
|
25
|
+
* `scope: "fleet"` previously bypassed the project check outright, so every
|
|
26
|
+
* instance carried every other project's playbook — measured at 8 of 14 here,
|
|
27
|
+
* resent on every API call. A fleet decision must now also be relevant: global
|
|
28
|
+
* (no project_root), the same project, or the same project family.
|
|
29
|
+
*
|
|
30
|
+
* `isDispatcher` (a general) opts out of that narrowing on purpose: it routes
|
|
31
|
+
* work across all projects, so cross-project rules ("X 文件操作由 Y 負責") are
|
|
32
|
+
* precisely what it must know. Narrowing a general would cause misrouting.
|
|
33
|
+
*/
|
|
34
|
+
export declare function selectRelevantDecisions<T extends {
|
|
35
|
+
scope?: string;
|
|
36
|
+
project_root?: string;
|
|
37
|
+
title: string;
|
|
38
|
+
}>(all: T[], workDir: string, isDispatcher?: boolean): T[];
|
|
15
39
|
/** Read the last real channel inbound timestamp persisted across daemon restarts. */
|
|
16
40
|
export declare function readLastInboundAt(instanceDir: string, now?: number): number | null;
|
|
17
41
|
/** Atomically persist the last real channel inbound timestamp. */
|
|
18
42
|
export declare function writeLastInboundAt(instanceDir: string, timestamp: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Render the handoff/routing metadata that rides along with an inbound message
|
|
45
|
+
* into the block actually pasted into the agent's pane.
|
|
46
|
+
*
|
|
47
|
+
* These fields were all populated by the sender (outbound-handlers builds them
|
|
48
|
+
* into `ipcMeta`) and delivered over IPC, but never rendered — so the receiving
|
|
49
|
+
* agent could not see them, and several documented flows could not work:
|
|
50
|
+
*
|
|
51
|
+
* - `report_result` requires a `correlation_id` the agent had no way to know, so
|
|
52
|
+
* the "correlation_id not recognized" warning fired on essentially every call.
|
|
53
|
+
* - Delegation cancel buttons are retired by correlation id, so they never retired.
|
|
54
|
+
* - `react`, `edit_message` and `reply.reply_to` need `message_id`, which the tool
|
|
55
|
+
* descriptions tell the agent to take "from the inbound block".
|
|
56
|
+
* - `download_attachment` needs `attachment_file_id`.
|
|
57
|
+
* - `requires_reply` was invisible, so a delegated task looked like an FYI.
|
|
58
|
+
*
|
|
59
|
+
* Only non-empty fields are emitted, so a plain user message gains at most a
|
|
60
|
+
* message_id line.
|
|
61
|
+
*/
|
|
62
|
+
export declare function renderHandoffMetadata(meta: Record<string, string>): string;
|
|
19
63
|
/** Headless inactivity timer used by the daemon and unit tests. */
|
|
20
64
|
export declare class AutoPauseController {
|
|
21
65
|
private readonly thresholdMs;
|
|
@@ -36,17 +80,53 @@ export declare class AutoPauseController {
|
|
|
36
80
|
* Pane motion wins over a ready match because several backends keep their ready
|
|
37
81
|
* marker in a persistent header/footer while generating. A stable ready pane is
|
|
38
82
|
* idle; changing content is working; stable non-ready content eventually sticks.
|
|
83
|
+
*
|
|
84
|
+
* ## Why an optional busy pattern exists
|
|
85
|
+
*
|
|
86
|
+
* "Motion wins" degrades badly when a backend's ready marker is *always* on
|
|
87
|
+
* screen. `stuck` requires `!ready`, so for such a backend the state can only ever
|
|
88
|
+
* be idle or working — the stuck edge, and with it `handleStuckTransition` and the
|
|
89
|
+
* hang notification, is unreachable. A frozen CLI is then reported as idle, which
|
|
90
|
+
* also clears pending work: the message the user sent is quietly booked as done.
|
|
91
|
+
*
|
|
92
|
+
* claude-code was exactly this case (see ClaudeCodeBackend.getReadyPattern). A
|
|
93
|
+
* backend that can point at a marker meaning "generating right now" supplies
|
|
94
|
+
* `getBusyPattern()`, and that match vetoes ready regardless of what the ready
|
|
95
|
+
* pattern says.
|
|
39
96
|
*/
|
|
40
97
|
export declare class PaneStateMachine {
|
|
41
98
|
private readonly stuckTimeoutMs;
|
|
42
99
|
private readonly readyPattern;
|
|
100
|
+
private readonly busyPattern;
|
|
43
101
|
private lastPaneHash;
|
|
44
102
|
private lastPaneChangeAt;
|
|
45
103
|
private lastObservedAt;
|
|
46
104
|
private stateChangedAt;
|
|
47
105
|
private currentState;
|
|
48
|
-
constructor(readyPattern: RegExp, stuckTimeoutMs?: number, now?: number);
|
|
49
|
-
|
|
106
|
+
constructor(readyPattern: RegExp, stuckTimeoutMs?: number, now?: number, busyPattern?: RegExp | null);
|
|
107
|
+
/** Ready, unless the backend can positively see that it is still generating. */
|
|
108
|
+
private isReady;
|
|
109
|
+
/**
|
|
110
|
+
* @param now when this observation is being evaluated — drives the idle and
|
|
111
|
+
* stuck decisions.
|
|
112
|
+
* @param opts.changeAt when the content is believed to have changed, if that
|
|
113
|
+
* is earlier than `now` (the tmux output timestamp). Only the elapsed-time
|
|
114
|
+
* clock uses it; defaults to `now`.
|
|
115
|
+
* @param opts.settled the caller knows no output has arrived for the debounce
|
|
116
|
+
* window, so "the content differs from the last capture" says nothing about
|
|
117
|
+
* whether the CLI is still generating — decide on the patterns instead.
|
|
118
|
+
*
|
|
119
|
+
* Captures are event-driven, not periodic: the one taken 2s after output
|
|
120
|
+
* stops is compared against a capture that may be a minute old, so it
|
|
121
|
+
* *always* differs. Without this flag that difference reads as "still
|
|
122
|
+
* working" and a finished turn would not be seen as idle until the next 60s
|
|
123
|
+
* safety sweep. Output timestamps are the honest liveness signal here, and
|
|
124
|
+
* the caller has them.
|
|
125
|
+
*/
|
|
126
|
+
observe(pane: string, now?: number, opts?: {
|
|
127
|
+
settled?: boolean;
|
|
128
|
+
changeAt?: number;
|
|
129
|
+
}): InstanceStateSnapshot;
|
|
50
130
|
/** Record pane motion from tmux control mode without capturing pane content. */
|
|
51
131
|
recordOutput(now?: number): InstanceStateSnapshot;
|
|
52
132
|
snapshot(now?: number): InstanceStateSnapshot;
|
|
@@ -83,13 +163,13 @@ export declare class Daemon extends EventEmitter {
|
|
|
83
163
|
private topicMode;
|
|
84
164
|
private backend?;
|
|
85
165
|
private controlClient?;
|
|
166
|
+
private runtimeIdentity?;
|
|
86
167
|
private logger;
|
|
87
168
|
private tmuxSessionName;
|
|
88
169
|
private tmux;
|
|
89
170
|
private ipcServer;
|
|
90
171
|
private messageBus;
|
|
91
172
|
private transcriptMonitor;
|
|
92
|
-
private toolTracker;
|
|
93
173
|
private guardian;
|
|
94
174
|
private adapter;
|
|
95
175
|
private pendingIpcRequests;
|
|
@@ -97,6 +177,8 @@ export declare class Daemon extends EventEmitter {
|
|
|
97
177
|
private lastThreadId;
|
|
98
178
|
private lastAdapterId;
|
|
99
179
|
private pendingAckMessage;
|
|
180
|
+
/** Last activity published to the fleet manager; null when nothing is running. */
|
|
181
|
+
private currentActivity;
|
|
100
182
|
private toolStatusMessageId;
|
|
101
183
|
private toolStatusLines;
|
|
102
184
|
private toolStatusDebounce;
|
|
@@ -110,9 +192,19 @@ export declare class Daemon extends EventEmitter {
|
|
|
110
192
|
private lastSpawnAt;
|
|
111
193
|
private crashTimestamps;
|
|
112
194
|
private healthCheckPaused;
|
|
195
|
+
private lastHealthErrorNotifyAt;
|
|
113
196
|
/** CLI pane availability, independent from the daemon process and tri-state. */
|
|
114
197
|
private processStatus;
|
|
115
198
|
private spawning;
|
|
199
|
+
/**
|
|
200
|
+
* Resolves when the in-flight spawn finishes; null when none is running.
|
|
201
|
+
*
|
|
202
|
+
* `spawning` alone can only be polled. Delivery needs to *wait*, and a boolean
|
|
203
|
+
* poll would either busy-loop or race the flag being cleared.
|
|
204
|
+
*/
|
|
205
|
+
private spawnSettled;
|
|
206
|
+
private resolveSpawnSettled;
|
|
207
|
+
private spawnDepth;
|
|
116
208
|
private skipResume;
|
|
117
209
|
private backgroundSessionRecoveryAttempted;
|
|
118
210
|
/** Whether the last spawn started a fresh session (not resumed). */
|
|
@@ -134,10 +226,18 @@ export declare class Daemon extends EventEmitter {
|
|
|
134
226
|
private instanceStateIdleDebounceMs;
|
|
135
227
|
private instanceStateStuckTimeoutMs;
|
|
136
228
|
private instanceStateReadyPattern;
|
|
229
|
+
private instanceStateBusyPattern;
|
|
137
230
|
private instanceStateMonitorActive;
|
|
138
231
|
private statePollInFlight;
|
|
139
232
|
private autoPauseController;
|
|
140
233
|
private pauseRequested;
|
|
234
|
+
/**
|
|
235
|
+
* Sticky "pause as soon as possible" (auth failure). Unlike pauseRequested —
|
|
236
|
+
* which the state monitor clears whenever the pane is not idle — this survives
|
|
237
|
+
* busy/stuck states, because an auth error fires mid-turn and a plain pause()
|
|
238
|
+
* would silently no-op exactly when we most need to stop feeding the CLI.
|
|
239
|
+
*/
|
|
240
|
+
private pausePending;
|
|
141
241
|
private pauseWakeState;
|
|
142
242
|
private pauseWakeTransition;
|
|
143
243
|
private modelOverride;
|
|
@@ -145,7 +245,13 @@ export declare class Daemon extends EventEmitter {
|
|
|
145
245
|
private recentEvents;
|
|
146
246
|
private recentToolActivity;
|
|
147
247
|
private snapshotConsumed;
|
|
248
|
+
/** Orders inbound channel messages against each other (queue-depth accounting
|
|
249
|
+
* and ⏳/👀/✅ reactions live here). It does NOT cover the other writers that
|
|
250
|
+
* reach the pane — {@link paneWriteLock} does. */
|
|
148
251
|
private pasteLock;
|
|
252
|
+
/** Mutual exclusion for *every* write into the pane, whichever subsystem it
|
|
253
|
+
* comes from. See PaneWriteLock for why interleaving is destructive. */
|
|
254
|
+
private readonly paneWriteLock;
|
|
149
255
|
private pendingInstructionsUpdate;
|
|
150
256
|
private pendingInstructionsNotice;
|
|
151
257
|
private warmupNeeded;
|
|
@@ -153,6 +259,10 @@ export declare class Daemon extends EventEmitter {
|
|
|
153
259
|
private pasteQueueDepth;
|
|
154
260
|
private firstDeliveryDelay;
|
|
155
261
|
private errorMonitorTimer;
|
|
262
|
+
/** Same 5-min gate the error monitor uses, so a dead MCP server alerts once. */
|
|
263
|
+
private static readonly MCP_DEATH_COOLDOWN_MS;
|
|
264
|
+
private lastMcpDeathNotifiedAt;
|
|
265
|
+
private mcpDeathNotifiedForPid;
|
|
156
266
|
/** Prevent in-flight monitor callbacks from re-arming after a pause. */
|
|
157
267
|
private runtimeMonitorsFrozen;
|
|
158
268
|
private errorWaitingForRecovery;
|
|
@@ -177,14 +287,42 @@ export declare class Daemon extends EventEmitter {
|
|
|
177
287
|
private lastDetectedErrorType;
|
|
178
288
|
private static errorPatternKey;
|
|
179
289
|
private clearErrorRecoveryGate;
|
|
180
|
-
constructor(name: string, config: InstanceConfig, instanceDir: string, topicMode?: boolean, backend?: CliBackend | undefined, controlClient?: TmuxControlClient | undefined, rootLogger?: Logger);
|
|
290
|
+
constructor(name: string, config: InstanceConfig, instanceDir: string, topicMode?: boolean, backend?: CliBackend | undefined, controlClient?: TmuxControlClient | undefined, rootLogger?: Logger, runtimeIdentity?: FleetInstructionsParams["runtimeIdentity"]);
|
|
181
291
|
start(): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Detect a CRASHED MCP server and report it once.
|
|
294
|
+
*
|
|
295
|
+
* The MCP server writes its pid to channel.mcp.pid at startup and unlinks it on
|
|
296
|
+
* a clean exit, so "file present + pid dead" specifically means it died without
|
|
297
|
+
* cleaning up (crash / OOM / SIGKILL). A missing file is either "not started
|
|
298
|
+
* yet" or "exited cleanly" — neither is an incident, and an orphan exit implies
|
|
299
|
+
* the CLI itself died, which the crash detector already covers.
|
|
300
|
+
*
|
|
301
|
+
* The daemon deliberately does NOT try to respawn it: MCP is a stdio protocol
|
|
302
|
+
* where the CLI spawns the server and owns its pipes, so a daemon-spawned
|
|
303
|
+
* process would have no client reading it. Only the CLI can restore its own
|
|
304
|
+
* tools — hence notify, and let the operator decide about restarting.
|
|
305
|
+
*/
|
|
306
|
+
private checkMcpServerAlive;
|
|
182
307
|
private startHealthCheck;
|
|
183
308
|
/**
|
|
184
309
|
* Publish pane-process availability separately from idle/working/stuck.
|
|
185
310
|
* A dead remain-on-exit pane still contains the old ready prompt, so allowing
|
|
186
311
|
* the pane monitor to capture it would re-create a false idle state.
|
|
187
312
|
*/
|
|
313
|
+
/**
|
|
314
|
+
* Announce that this instance is no longer being supervised.
|
|
315
|
+
*
|
|
316
|
+
* Four health-check exits set `healthCheckPaused = true` and returned without
|
|
317
|
+
* telling anyone: a clean CLI exit, `max_retries <= 0`, crash retries exhausted,
|
|
318
|
+
* and the instance directory being deleted. Only the crash-LOOP case emitted an
|
|
319
|
+
* event, so a fleet could quietly contain a dead instance that still looked fine
|
|
320
|
+
* on the dashboard — while messages routed to it queued or failed with a bare ❌.
|
|
321
|
+
*
|
|
322
|
+
* `crash_loop` already had this treatment; this is the same bridge for the other
|
|
323
|
+
* four, carrying a human-readable cause and the operator's next step.
|
|
324
|
+
*/
|
|
325
|
+
private emitSupervisionEnded;
|
|
188
326
|
private setProcessStatus;
|
|
189
327
|
/**
|
|
190
328
|
* Periodically scan PTY output for backend-defined error patterns.
|
|
@@ -211,6 +349,12 @@ export declare class Daemon extends EventEmitter {
|
|
|
211
349
|
* Interrupt the CLI's current generation (cancel button / `/cancel`).
|
|
212
350
|
* Direct tmux key event (not a paste) so it registers as the interrupt key.
|
|
213
351
|
* kiro-cli interrupts on Ctrl+C; the others (claude-code, codex, …) on Escape.
|
|
352
|
+
*
|
|
353
|
+
* Deliberately NOT taken through `paneWriteLock`. Cancel is the user's way out
|
|
354
|
+
* of a pane that is busy or wedged — queueing it behind the very delivery chain
|
|
355
|
+
* it exists to unblock would make the button useless exactly when it is needed.
|
|
356
|
+
* The cost is accepted: an Escape landing between a paste and its Enter discards
|
|
357
|
+
* that message, which is what the user asked for anyway.
|
|
214
358
|
*/
|
|
215
359
|
sendEscape(): Promise<void>;
|
|
216
360
|
/** Send the backend-specific graceful quit command/key sequence. */
|
|
@@ -220,6 +364,12 @@ export declare class Daemon extends EventEmitter {
|
|
|
220
364
|
getInstanceState(): InstanceState | "paused";
|
|
221
365
|
getInstanceStateSnapshot(): InstanceStateSnapshot;
|
|
222
366
|
/** Gracefully stop the CLI while keeping its remain-on-exit tmux window. */
|
|
367
|
+
/**
|
|
368
|
+
* Mark the instance to pause as soon as its pane is idle. Used for auth
|
|
369
|
+
* failures: pause() alone no-ops while the CLI is busy/stuck, which is the
|
|
370
|
+
* usual state when the error surfaces. Cleared by a successful pause or wake.
|
|
371
|
+
*/
|
|
372
|
+
requestPauseWhenIdle(): void;
|
|
223
373
|
pause(): Promise<void>;
|
|
224
374
|
/** Respawn the CLI in the preserved window and block until its prompt is ready. */
|
|
225
375
|
wake(timeoutMs?: number): Promise<void>;
|
|
@@ -239,6 +389,28 @@ export declare class Daemon extends EventEmitter {
|
|
|
239
389
|
/** Restore the same monitor objects after wake without adding event listeners. */
|
|
240
390
|
private resumeRuntimeMonitors;
|
|
241
391
|
getMessageBus(): MessageBus;
|
|
392
|
+
/**
|
|
393
|
+
* Tell the fleet manager what this instance is doing right now, for the live
|
|
394
|
+
* progress line on the cancel button.
|
|
395
|
+
*
|
|
396
|
+
* Purely cosmetic — nothing decides anything from it, so it is fine that only
|
|
397
|
+
* backends with a transcript feed report at all (claude-code today). For the
|
|
398
|
+
* rest the progress line keeps showing just elapsed time.
|
|
399
|
+
*
|
|
400
|
+
* Repeats are dropped: the ticker only edits the channel message when the text
|
|
401
|
+
* changes, and a stream of identical broadcasts would defeat that.
|
|
402
|
+
*/
|
|
403
|
+
private publishActivity;
|
|
404
|
+
/**
|
|
405
|
+
* Options for every system-initiated paste (startup notice, session snapshot,
|
|
406
|
+
* runtime-dialog keys).
|
|
407
|
+
*
|
|
408
|
+
* One place, so the three call sites cannot drift apart on it. Backends with a
|
|
409
|
+
* native input queue do not get the retry Enter: on those, a second bare Enter
|
|
410
|
+
* is not the no-op the retry assumed but a queue mutation — the same reason
|
|
411
|
+
* `deliverMessage` refuses to probe for busy with one.
|
|
412
|
+
*/
|
|
413
|
+
private systemPasteOptions;
|
|
242
414
|
private summarizeTool;
|
|
243
415
|
private addToolStatus;
|
|
244
416
|
/** Debounce tool status updates to avoid channel rate limits */
|
|
@@ -254,23 +426,52 @@ export declare class Daemon extends EventEmitter {
|
|
|
254
426
|
pushChannelMessage(content: string, meta: Record<string, string>, _targetSession?: string): void;
|
|
255
427
|
/**
|
|
256
428
|
* Deliver a single message and drive its status reactions:
|
|
257
|
-
* ⏳ message_queued — CLI busy; queued
|
|
429
|
+
* ⏳ message_queued — CLI busy; queued locally or by the backend
|
|
258
430
|
* 👀 message_delivered — pasted + Enter sent; agent now has it
|
|
259
|
-
* ✅ message_confirmed —
|
|
431
|
+
* ✅ message_confirmed — processing observed, or native queue handoff succeeded
|
|
260
432
|
* ❌ message_failed — tmux window gone, paste retries exhausted
|
|
261
433
|
* Returns true once the message is in the CLI, false only on real delivery failure.
|
|
262
434
|
*
|
|
263
435
|
* Bug A (silent message loss): paste failures retry with backoff (window recovery)
|
|
264
436
|
* and emit `message_failed` if all attempts fail.
|
|
265
|
-
* Busy handling (UX):
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
437
|
+
* Busy handling (UX): backends without a native input queue show ⏳ and wait for
|
|
438
|
+
* idle indefinitely (a genuinely hung CLI is the hang detector's job). Backends
|
|
439
|
+
* that explicitly support queued input receive one complete paste+Enter transaction
|
|
440
|
+
* immediately and own the application-level queue themselves. The pasteLock remains
|
|
441
|
+
* serial in both cases so separate PTY writes can never overlap.
|
|
269
442
|
*/
|
|
270
443
|
private deliverMessage;
|
|
444
|
+
/**
|
|
445
|
+
* The write half of a delivery: paste → Enter → confirm, with retries.
|
|
446
|
+
*
|
|
447
|
+
* Always called under {@link paneWriteLock}. Split out from `deliverMessage`
|
|
448
|
+
* precisely so the lock's scope is visible at the call site rather than being
|
|
449
|
+
* an invariant maintained by comments.
|
|
450
|
+
*/
|
|
451
|
+
private writeMessageToPane;
|
|
452
|
+
/**
|
|
453
|
+
* True when a busy native-queue paste appears to have landed: Codex shows a
|
|
454
|
+
* `↳` queue marker, or a distinctive slice of the pasted text is on screen.
|
|
455
|
+
* Used only to detect silent paste loss — not as a general ready check.
|
|
456
|
+
*/
|
|
457
|
+
private nativeQueuePasteVisible;
|
|
271
458
|
/** Re-resolve this instance's tmux window by name (stale id after crash/respawn). */
|
|
272
459
|
private recoverWindow;
|
|
273
|
-
/**
|
|
460
|
+
/**
|
|
461
|
+
* Poll up to ~2s (200ms × 10) for the pane to emit output after `since`.
|
|
462
|
+
*
|
|
463
|
+
* A `false` here is not "no output" — it is read as **"the message was pasted but
|
|
464
|
+
* never submitted"**, which re-sends Enter and then reports ❌ to the user. So a
|
|
465
|
+
* false negative costs a possible double submit and a failure notice for a
|
|
466
|
+
* message that actually arrived.
|
|
467
|
+
*
|
|
468
|
+
* That is exactly what a control-mode reconnect used to produce. `connect()`
|
|
469
|
+
* drops every output timestamp, so `hasOutputSince` answers `false` for a pane
|
|
470
|
+
* that did react — the evidence was thrown away, not absent. Blind time is
|
|
471
|
+
* therefore not counted against the budget: after a reset the poll restarts from
|
|
472
|
+
* the moment observation resumed. A hard wall-clock cap keeps a reconnect loop
|
|
473
|
+
* from extending this forever.
|
|
474
|
+
*/
|
|
274
475
|
private confirmBusyAfterEnter;
|
|
275
476
|
private getWindowId;
|
|
276
477
|
/** Find the IPC socket for a given sessionName */
|
|
@@ -288,6 +489,31 @@ export declare class Daemon extends EventEmitter {
|
|
|
288
489
|
* This replaces the old system-prompt injection approach.
|
|
289
490
|
*/
|
|
290
491
|
private injectSnapshotMessage;
|
|
492
|
+
/**
|
|
493
|
+
* Depth, not a flag: the wake path marks a spawn and then calls trySpawn, which
|
|
494
|
+
* marks another. With a plain boolean the inner one's completion would clear the
|
|
495
|
+
* latch while the outer spawn was still dismissing dialogs, releasing delivery
|
|
496
|
+
* into exactly the window this exists to close.
|
|
497
|
+
*/
|
|
498
|
+
private beginSpawn;
|
|
499
|
+
private endSpawn;
|
|
500
|
+
/**
|
|
501
|
+
* Hold until the CLI has finished starting up.
|
|
502
|
+
*
|
|
503
|
+
* Startup is not a quiet period: `dismissDialogsUntilReady` is clicking through
|
|
504
|
+
* trust prompts and session pickers. A pane showing a modal dialog produces no
|
|
505
|
+
* output, so `waitUntilIdle` reports it idle and a queued message gets pasted
|
|
506
|
+
* *into the dialog* — where the text is discarded and the Enter picks a menu
|
|
507
|
+
* item. The paste and the Enter both "succeed", so this loses the message
|
|
508
|
+
* without even a ❌.
|
|
509
|
+
*
|
|
510
|
+
* The pane write lock (#414) does not cover this: it serialises each key
|
|
511
|
+
* sequence, but it is released between one dialog and the next.
|
|
512
|
+
*
|
|
513
|
+
* Bounded, and called BEFORE the pane lock is taken — waiting on the spawn while
|
|
514
|
+
* holding the lock the spawn itself needs would deadlock.
|
|
515
|
+
*/
|
|
516
|
+
private waitForSpawnToSettle;
|
|
291
517
|
/** Spawn a CLI window. Returns true if --resume was used successfully. */
|
|
292
518
|
private spawnClaudeWindow;
|
|
293
519
|
/** Kill the entire process tree of the current tmux pane (CLI + MCP server). */
|