@songsid/agend 2.1.2-beta.4 → 2.1.2-beta.41
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 +51 -4
- 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 +27 -0
- package/dist/backend/codex.js +93 -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 +79 -1
- 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 +227 -87
- 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 +282 -14
- package/dist/daemon.js +1062 -311
- 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-lock.d.ts +28 -0
- package/dist/fleet-lock.js +130 -0
- package/dist/fleet-lock.js.map +1 -0
- package/dist/fleet-manager.d.ts +315 -2
- package/dist/fleet-manager.js +1414 -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 +52 -3
- package/dist/instance-lifecycle.js +194 -48
- 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/service-installer.d.ts +16 -0
- package/dist/service-installer.js +56 -1
- package/dist/service-installer.js.map +1 -1
- 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 +49 -9
- package/dist/topic-commands.js +267 -105
- package/dist/topic-commands.js.map +1 -1
- package/dist/tui-glyphs.d.ts +5 -1
- package/dist/tui-glyphs.js +6 -2
- package/dist/tui-glyphs.js.map +1 -1
- 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/provider-alerts.d.ts +33 -0
- package/dist/usage/provider-alerts.js +57 -0
- package/dist/usage/provider-alerts.js.map +1 -0
- package/dist/usage/providers.d.ts +130 -0
- package/dist/usage/providers.js +1063 -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 +197 -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,73 @@ 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
|
*/
|
|
97
|
+
/**
|
|
98
|
+
* A shell command reduced to the part that is safe to show: the program, and a
|
|
99
|
+
* subcommand when there is one.
|
|
100
|
+
*
|
|
101
|
+
* curl -H "Bearer sk-ant-…" https://api.com → curl
|
|
102
|
+
* npm test --env=API_KEY=xxx → npm test
|
|
103
|
+
* git push origin main → git push
|
|
104
|
+
*
|
|
105
|
+
* Arguments are dropped wholesale rather than filtered, because there is no
|
|
106
|
+
* reliable way to tell a secret from an ordinary argument: tokens, bearer
|
|
107
|
+
* headers, connection strings and `--password=` values all look like text. The
|
|
108
|
+
* progress line is posted to a chat channel and, for a public one, so is
|
|
109
|
+
* anything in it — so the rule is "never the arguments", not "not the arguments
|
|
110
|
+
* that look dangerous".
|
|
111
|
+
*
|
|
112
|
+
* A second token is kept only when it is a bare word (`push`, `test`), which is
|
|
113
|
+
* what a subcommand looks like and what a flag, path, URL, assignment or quoted
|
|
114
|
+
* string does not. Everything after it goes, including `git push ORIGIN MAIN`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function shellCommandLabel(command: string): string;
|
|
40
117
|
export declare class PaneStateMachine {
|
|
41
118
|
private readonly stuckTimeoutMs;
|
|
42
119
|
private readonly readyPattern;
|
|
120
|
+
private readonly busyPattern;
|
|
43
121
|
private lastPaneHash;
|
|
44
122
|
private lastPaneChangeAt;
|
|
45
123
|
private lastObservedAt;
|
|
46
124
|
private stateChangedAt;
|
|
47
125
|
private currentState;
|
|
48
|
-
constructor(readyPattern: RegExp, stuckTimeoutMs?: number, now?: number);
|
|
49
|
-
|
|
126
|
+
constructor(readyPattern: RegExp, stuckTimeoutMs?: number, now?: number, busyPattern?: RegExp | null);
|
|
127
|
+
/** Ready, unless the backend can positively see that it is still generating. */
|
|
128
|
+
private isReady;
|
|
129
|
+
/**
|
|
130
|
+
* @param now when this observation is being evaluated — drives the idle and
|
|
131
|
+
* stuck decisions.
|
|
132
|
+
* @param opts.changeAt when the content is believed to have changed, if that
|
|
133
|
+
* is earlier than `now` (the tmux output timestamp). Only the elapsed-time
|
|
134
|
+
* clock uses it; defaults to `now`.
|
|
135
|
+
* @param opts.settled the caller knows no output has arrived for the debounce
|
|
136
|
+
* window, so "the content differs from the last capture" says nothing about
|
|
137
|
+
* whether the CLI is still generating — decide on the patterns instead.
|
|
138
|
+
*
|
|
139
|
+
* Captures are event-driven, not periodic: the one taken 2s after output
|
|
140
|
+
* stops is compared against a capture that may be a minute old, so it
|
|
141
|
+
* *always* differs. Without this flag that difference reads as "still
|
|
142
|
+
* working" and a finished turn would not be seen as idle until the next 60s
|
|
143
|
+
* safety sweep. Output timestamps are the honest liveness signal here, and
|
|
144
|
+
* the caller has them.
|
|
145
|
+
*/
|
|
146
|
+
observe(pane: string, now?: number, opts?: {
|
|
147
|
+
settled?: boolean;
|
|
148
|
+
changeAt?: number;
|
|
149
|
+
}): InstanceStateSnapshot;
|
|
50
150
|
/** Record pane motion from tmux control mode without capturing pane content. */
|
|
51
151
|
recordOutput(now?: number): InstanceStateSnapshot;
|
|
52
152
|
snapshot(now?: number): InstanceStateSnapshot;
|
|
@@ -76,6 +176,27 @@ export declare class FirstDeliveryDelay {
|
|
|
76
176
|
}
|
|
77
177
|
/** Redact likely credentials and control sequences before pane text reaches logs. */
|
|
78
178
|
export declare function sanitizePaneTail(pane: string, lineCount?: number): string[];
|
|
179
|
+
export type InteractivePromptKind = "sudo_password" | "password" | "confirmation" | "press_enter";
|
|
180
|
+
export interface InteractivePromptDetection {
|
|
181
|
+
kind: InteractivePromptKind;
|
|
182
|
+
prompt: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Detect terminal prompts that require a human, but only after the pane tail is
|
|
186
|
+
* unchanged and no control-mode output has arrived for the full grace period.
|
|
187
|
+
* This prevents prose such as "the installer asks [Y/n]" from notifying while
|
|
188
|
+
* an agent is still writing it.
|
|
189
|
+
*/
|
|
190
|
+
export declare class InteractivePromptDetector {
|
|
191
|
+
private readonly stableMs;
|
|
192
|
+
private signature;
|
|
193
|
+
private stableSince;
|
|
194
|
+
private lastOutputAt;
|
|
195
|
+
private notifiedSignature;
|
|
196
|
+
constructor(stableMs?: number);
|
|
197
|
+
observe(pane: string, now?: number, outputAt?: number): InteractivePromptDetection | null;
|
|
198
|
+
reset(): void;
|
|
199
|
+
}
|
|
79
200
|
export declare class Daemon extends EventEmitter {
|
|
80
201
|
private name;
|
|
81
202
|
private config;
|
|
@@ -83,13 +204,13 @@ export declare class Daemon extends EventEmitter {
|
|
|
83
204
|
private topicMode;
|
|
84
205
|
private backend?;
|
|
85
206
|
private controlClient?;
|
|
207
|
+
private runtimeIdentity?;
|
|
86
208
|
private logger;
|
|
87
209
|
private tmuxSessionName;
|
|
88
210
|
private tmux;
|
|
89
211
|
private ipcServer;
|
|
90
212
|
private messageBus;
|
|
91
213
|
private transcriptMonitor;
|
|
92
|
-
private toolTracker;
|
|
93
214
|
private guardian;
|
|
94
215
|
private adapter;
|
|
95
216
|
private pendingIpcRequests;
|
|
@@ -97,6 +218,8 @@ export declare class Daemon extends EventEmitter {
|
|
|
97
218
|
private lastThreadId;
|
|
98
219
|
private lastAdapterId;
|
|
99
220
|
private pendingAckMessage;
|
|
221
|
+
/** Last activity published to the fleet manager; null when nothing is running. */
|
|
222
|
+
private currentActivity;
|
|
100
223
|
private toolStatusMessageId;
|
|
101
224
|
private toolStatusLines;
|
|
102
225
|
private toolStatusDebounce;
|
|
@@ -110,9 +233,19 @@ export declare class Daemon extends EventEmitter {
|
|
|
110
233
|
private lastSpawnAt;
|
|
111
234
|
private crashTimestamps;
|
|
112
235
|
private healthCheckPaused;
|
|
236
|
+
private lastHealthErrorNotifyAt;
|
|
113
237
|
/** CLI pane availability, independent from the daemon process and tri-state. */
|
|
114
238
|
private processStatus;
|
|
115
239
|
private spawning;
|
|
240
|
+
/**
|
|
241
|
+
* Resolves when the in-flight spawn finishes; null when none is running.
|
|
242
|
+
*
|
|
243
|
+
* `spawning` alone can only be polled. Delivery needs to *wait*, and a boolean
|
|
244
|
+
* poll would either busy-loop or race the flag being cleared.
|
|
245
|
+
*/
|
|
246
|
+
private spawnSettled;
|
|
247
|
+
private resolveSpawnSettled;
|
|
248
|
+
private spawnDepth;
|
|
116
249
|
private skipResume;
|
|
117
250
|
private backgroundSessionRecoveryAttempted;
|
|
118
251
|
/** Whether the last spawn started a fresh session (not resumed). */
|
|
@@ -134,10 +267,18 @@ export declare class Daemon extends EventEmitter {
|
|
|
134
267
|
private instanceStateIdleDebounceMs;
|
|
135
268
|
private instanceStateStuckTimeoutMs;
|
|
136
269
|
private instanceStateReadyPattern;
|
|
270
|
+
private instanceStateBusyPattern;
|
|
137
271
|
private instanceStateMonitorActive;
|
|
138
272
|
private statePollInFlight;
|
|
139
273
|
private autoPauseController;
|
|
140
274
|
private pauseRequested;
|
|
275
|
+
/**
|
|
276
|
+
* Sticky "pause as soon as possible" (auth failure). Unlike pauseRequested —
|
|
277
|
+
* which the state monitor clears whenever the pane is not idle — this survives
|
|
278
|
+
* busy/stuck states, because an auth error fires mid-turn and a plain pause()
|
|
279
|
+
* would silently no-op exactly when we most need to stop feeding the CLI.
|
|
280
|
+
*/
|
|
281
|
+
private pausePending;
|
|
141
282
|
private pauseWakeState;
|
|
142
283
|
private pauseWakeTransition;
|
|
143
284
|
private modelOverride;
|
|
@@ -145,7 +286,13 @@ export declare class Daemon extends EventEmitter {
|
|
|
145
286
|
private recentEvents;
|
|
146
287
|
private recentToolActivity;
|
|
147
288
|
private snapshotConsumed;
|
|
289
|
+
/** Orders inbound channel messages against each other (queue-depth accounting
|
|
290
|
+
* and ⏳/👀/✅ reactions live here). It does NOT cover the other writers that
|
|
291
|
+
* reach the pane — {@link paneWriteLock} does. */
|
|
148
292
|
private pasteLock;
|
|
293
|
+
/** Mutual exclusion for *every* write into the pane, whichever subsystem it
|
|
294
|
+
* comes from. See PaneWriteLock for why interleaving is destructive. */
|
|
295
|
+
private readonly paneWriteLock;
|
|
149
296
|
private pendingInstructionsUpdate;
|
|
150
297
|
private pendingInstructionsNotice;
|
|
151
298
|
private warmupNeeded;
|
|
@@ -153,6 +300,11 @@ export declare class Daemon extends EventEmitter {
|
|
|
153
300
|
private pasteQueueDepth;
|
|
154
301
|
private firstDeliveryDelay;
|
|
155
302
|
private errorMonitorTimer;
|
|
303
|
+
private readonly interactivePromptDetector;
|
|
304
|
+
/** Same 5-min gate the error monitor uses, so a dead MCP server alerts once. */
|
|
305
|
+
private static readonly MCP_DEATH_COOLDOWN_MS;
|
|
306
|
+
private lastMcpDeathNotifiedAt;
|
|
307
|
+
private mcpDeathNotifiedForPid;
|
|
156
308
|
/** Prevent in-flight monitor callbacks from re-arming after a pause. */
|
|
157
309
|
private runtimeMonitorsFrozen;
|
|
158
310
|
private errorWaitingForRecovery;
|
|
@@ -177,14 +329,42 @@ export declare class Daemon extends EventEmitter {
|
|
|
177
329
|
private lastDetectedErrorType;
|
|
178
330
|
private static errorPatternKey;
|
|
179
331
|
private clearErrorRecoveryGate;
|
|
180
|
-
constructor(name: string, config: InstanceConfig, instanceDir: string, topicMode?: boolean, backend?: CliBackend | undefined, controlClient?: TmuxControlClient | undefined, rootLogger?: Logger);
|
|
332
|
+
constructor(name: string, config: InstanceConfig, instanceDir: string, topicMode?: boolean, backend?: CliBackend | undefined, controlClient?: TmuxControlClient | undefined, rootLogger?: Logger, runtimeIdentity?: FleetInstructionsParams["runtimeIdentity"]);
|
|
181
333
|
start(): Promise<void>;
|
|
334
|
+
/**
|
|
335
|
+
* Detect a CRASHED MCP server and report it once.
|
|
336
|
+
*
|
|
337
|
+
* The MCP server writes its pid to channel.mcp.pid at startup and unlinks it on
|
|
338
|
+
* a clean exit, so "file present + pid dead" specifically means it died without
|
|
339
|
+
* cleaning up (crash / OOM / SIGKILL). A missing file is either "not started
|
|
340
|
+
* yet" or "exited cleanly" — neither is an incident, and an orphan exit implies
|
|
341
|
+
* the CLI itself died, which the crash detector already covers.
|
|
342
|
+
*
|
|
343
|
+
* The daemon deliberately does NOT try to respawn it: MCP is a stdio protocol
|
|
344
|
+
* where the CLI spawns the server and owns its pipes, so a daemon-spawned
|
|
345
|
+
* process would have no client reading it. Only the CLI can restore its own
|
|
346
|
+
* tools — hence notify, and let the operator decide about restarting.
|
|
347
|
+
*/
|
|
348
|
+
private checkMcpServerAlive;
|
|
182
349
|
private startHealthCheck;
|
|
183
350
|
/**
|
|
184
351
|
* Publish pane-process availability separately from idle/working/stuck.
|
|
185
352
|
* A dead remain-on-exit pane still contains the old ready prompt, so allowing
|
|
186
353
|
* the pane monitor to capture it would re-create a false idle state.
|
|
187
354
|
*/
|
|
355
|
+
/**
|
|
356
|
+
* Announce that this instance is no longer being supervised.
|
|
357
|
+
*
|
|
358
|
+
* Four health-check exits set `healthCheckPaused = true` and returned without
|
|
359
|
+
* telling anyone: a clean CLI exit, `max_retries <= 0`, crash retries exhausted,
|
|
360
|
+
* and the instance directory being deleted. Only the crash-LOOP case emitted an
|
|
361
|
+
* event, so a fleet could quietly contain a dead instance that still looked fine
|
|
362
|
+
* on the dashboard — while messages routed to it queued or failed with a bare ❌.
|
|
363
|
+
*
|
|
364
|
+
* `crash_loop` already had this treatment; this is the same bridge for the other
|
|
365
|
+
* four, carrying a human-readable cause and the operator's next step.
|
|
366
|
+
*/
|
|
367
|
+
private emitSupervisionEnded;
|
|
188
368
|
private setProcessStatus;
|
|
189
369
|
/**
|
|
190
370
|
* Periodically scan PTY output for backend-defined error patterns.
|
|
@@ -211,6 +391,12 @@ export declare class Daemon extends EventEmitter {
|
|
|
211
391
|
* Interrupt the CLI's current generation (cancel button / `/cancel`).
|
|
212
392
|
* Direct tmux key event (not a paste) so it registers as the interrupt key.
|
|
213
393
|
* kiro-cli interrupts on Ctrl+C; the others (claude-code, codex, …) on Escape.
|
|
394
|
+
*
|
|
395
|
+
* Deliberately NOT taken through `paneWriteLock`. Cancel is the user's way out
|
|
396
|
+
* of a pane that is busy or wedged — queueing it behind the very delivery chain
|
|
397
|
+
* it exists to unblock would make the button useless exactly when it is needed.
|
|
398
|
+
* The cost is accepted: an Escape landing between a paste and its Enter discards
|
|
399
|
+
* that message, which is what the user asked for anyway.
|
|
214
400
|
*/
|
|
215
401
|
sendEscape(): Promise<void>;
|
|
216
402
|
/** Send the backend-specific graceful quit command/key sequence. */
|
|
@@ -220,6 +406,12 @@ export declare class Daemon extends EventEmitter {
|
|
|
220
406
|
getInstanceState(): InstanceState | "paused";
|
|
221
407
|
getInstanceStateSnapshot(): InstanceStateSnapshot;
|
|
222
408
|
/** Gracefully stop the CLI while keeping its remain-on-exit tmux window. */
|
|
409
|
+
/**
|
|
410
|
+
* Mark the instance to pause as soon as its pane is idle. Used for auth
|
|
411
|
+
* failures: pause() alone no-ops while the CLI is busy/stuck, which is the
|
|
412
|
+
* usual state when the error surfaces. Cleared by a successful pause or wake.
|
|
413
|
+
*/
|
|
414
|
+
requestPauseWhenIdle(): void;
|
|
223
415
|
pause(): Promise<void>;
|
|
224
416
|
/** Respawn the CLI in the preserved window and block until its prompt is ready. */
|
|
225
417
|
wake(timeoutMs?: number): Promise<void>;
|
|
@@ -239,6 +431,28 @@ export declare class Daemon extends EventEmitter {
|
|
|
239
431
|
/** Restore the same monitor objects after wake without adding event listeners. */
|
|
240
432
|
private resumeRuntimeMonitors;
|
|
241
433
|
getMessageBus(): MessageBus;
|
|
434
|
+
/**
|
|
435
|
+
* Tell the fleet manager what this instance is doing right now, for the live
|
|
436
|
+
* progress line on the cancel button.
|
|
437
|
+
*
|
|
438
|
+
* Purely cosmetic — nothing decides anything from it, so it is fine that only
|
|
439
|
+
* backends with a transcript feed report at all (claude-code today). For the
|
|
440
|
+
* rest the progress line keeps showing just elapsed time.
|
|
441
|
+
*
|
|
442
|
+
* Repeats are dropped: the ticker only edits the channel message when the text
|
|
443
|
+
* changes, and a stream of identical broadcasts would defeat that.
|
|
444
|
+
*/
|
|
445
|
+
private publishActivity;
|
|
446
|
+
/**
|
|
447
|
+
* Options for every system-initiated paste (startup notice, session snapshot,
|
|
448
|
+
* runtime-dialog keys).
|
|
449
|
+
*
|
|
450
|
+
* One place, so the three call sites cannot drift apart on it. Backends with a
|
|
451
|
+
* native input queue do not get the retry Enter: on those, a second bare Enter
|
|
452
|
+
* is not the no-op the retry assumed but a queue mutation — the same reason
|
|
453
|
+
* `deliverMessage` refuses to probe for busy with one.
|
|
454
|
+
*/
|
|
455
|
+
private systemPasteOptions;
|
|
242
456
|
private summarizeTool;
|
|
243
457
|
private addToolStatus;
|
|
244
458
|
/** Debounce tool status updates to avoid channel rate limits */
|
|
@@ -254,23 +468,52 @@ export declare class Daemon extends EventEmitter {
|
|
|
254
468
|
pushChannelMessage(content: string, meta: Record<string, string>, _targetSession?: string): void;
|
|
255
469
|
/**
|
|
256
470
|
* Deliver a single message and drive its status reactions:
|
|
257
|
-
* ⏳ message_queued — CLI busy; queued
|
|
471
|
+
* ⏳ message_queued — CLI busy; queued locally or by the backend
|
|
258
472
|
* 👀 message_delivered — pasted + Enter sent; agent now has it
|
|
259
|
-
* ✅ message_confirmed —
|
|
473
|
+
* ✅ message_confirmed — processing observed, or native queue handoff succeeded
|
|
260
474
|
* ❌ message_failed — tmux window gone, paste retries exhausted
|
|
261
475
|
* Returns true once the message is in the CLI, false only on real delivery failure.
|
|
262
476
|
*
|
|
263
477
|
* Bug A (silent message loss): paste failures retry with backoff (window recovery)
|
|
264
478
|
* and emit `message_failed` if all attempts fail.
|
|
265
|
-
* Busy handling (UX):
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
479
|
+
* Busy handling (UX): backends without a native input queue show ⏳ and wait for
|
|
480
|
+
* idle indefinitely (a genuinely hung CLI is the hang detector's job). Backends
|
|
481
|
+
* that explicitly support queued input receive one complete paste+Enter transaction
|
|
482
|
+
* immediately and own the application-level queue themselves. The pasteLock remains
|
|
483
|
+
* serial in both cases so separate PTY writes can never overlap.
|
|
269
484
|
*/
|
|
270
485
|
private deliverMessage;
|
|
486
|
+
/**
|
|
487
|
+
* The write half of a delivery: paste → Enter → confirm, with retries.
|
|
488
|
+
*
|
|
489
|
+
* Always called under {@link paneWriteLock}. Split out from `deliverMessage`
|
|
490
|
+
* precisely so the lock's scope is visible at the call site rather than being
|
|
491
|
+
* an invariant maintained by comments.
|
|
492
|
+
*/
|
|
493
|
+
private writeMessageToPane;
|
|
494
|
+
/**
|
|
495
|
+
* True when a busy native-queue paste appears to have landed: Codex shows a
|
|
496
|
+
* `↳` queue marker, or a distinctive slice of the pasted text is on screen.
|
|
497
|
+
* Used only to detect silent paste loss — not as a general ready check.
|
|
498
|
+
*/
|
|
499
|
+
private nativeQueuePasteVisible;
|
|
271
500
|
/** Re-resolve this instance's tmux window by name (stale id after crash/respawn). */
|
|
272
501
|
private recoverWindow;
|
|
273
|
-
/**
|
|
502
|
+
/**
|
|
503
|
+
* Poll up to ~2s (200ms × 10) for the pane to emit output after `since`.
|
|
504
|
+
*
|
|
505
|
+
* A `false` here is not "no output" — it is read as **"the message was pasted but
|
|
506
|
+
* never submitted"**, which re-sends Enter and then reports ❌ to the user. So a
|
|
507
|
+
* false negative costs a possible double submit and a failure notice for a
|
|
508
|
+
* message that actually arrived.
|
|
509
|
+
*
|
|
510
|
+
* That is exactly what a control-mode reconnect used to produce. `connect()`
|
|
511
|
+
* drops every output timestamp, so `hasOutputSince` answers `false` for a pane
|
|
512
|
+
* that did react — the evidence was thrown away, not absent. Blind time is
|
|
513
|
+
* therefore not counted against the budget: after a reset the poll restarts from
|
|
514
|
+
* the moment observation resumed. A hard wall-clock cap keeps a reconnect loop
|
|
515
|
+
* from extending this forever.
|
|
516
|
+
*/
|
|
274
517
|
private confirmBusyAfterEnter;
|
|
275
518
|
private getWindowId;
|
|
276
519
|
/** Find the IPC socket for a given sessionName */
|
|
@@ -288,6 +531,31 @@ export declare class Daemon extends EventEmitter {
|
|
|
288
531
|
* This replaces the old system-prompt injection approach.
|
|
289
532
|
*/
|
|
290
533
|
private injectSnapshotMessage;
|
|
534
|
+
/**
|
|
535
|
+
* Depth, not a flag: the wake path marks a spawn and then calls trySpawn, which
|
|
536
|
+
* marks another. With a plain boolean the inner one's completion would clear the
|
|
537
|
+
* latch while the outer spawn was still dismissing dialogs, releasing delivery
|
|
538
|
+
* into exactly the window this exists to close.
|
|
539
|
+
*/
|
|
540
|
+
private beginSpawn;
|
|
541
|
+
private endSpawn;
|
|
542
|
+
/**
|
|
543
|
+
* Hold until the CLI has finished starting up.
|
|
544
|
+
*
|
|
545
|
+
* Startup is not a quiet period: `dismissDialogsUntilReady` is clicking through
|
|
546
|
+
* trust prompts and session pickers. A pane showing a modal dialog produces no
|
|
547
|
+
* output, so `waitUntilIdle` reports it idle and a queued message gets pasted
|
|
548
|
+
* *into the dialog* — where the text is discarded and the Enter picks a menu
|
|
549
|
+
* item. The paste and the Enter both "succeed", so this loses the message
|
|
550
|
+
* without even a ❌.
|
|
551
|
+
*
|
|
552
|
+
* The pane write lock (#414) does not cover this: it serialises each key
|
|
553
|
+
* sequence, but it is released between one dialog and the next.
|
|
554
|
+
*
|
|
555
|
+
* Bounded, and called BEFORE the pane lock is taken — waiting on the spawn while
|
|
556
|
+
* holding the lock the spawn itself needs would deadlock.
|
|
557
|
+
*/
|
|
558
|
+
private waitForSpawnToSettle;
|
|
291
559
|
/** Spawn a CLI window. Returns true if --resume was used successfully. */
|
|
292
560
|
private spawnClaudeWindow;
|
|
293
561
|
/** Kill the entire process tree of the current tmux pane (CLI + MCP server). */
|