@songsid/agend 2.1.12-beta.1 → 2.1.12-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/agent-cli.js +36 -4
  2. package/dist/agent-cli.js.map +1 -1
  3. package/dist/agent-endpoint.d.ts +3 -1
  4. package/dist/agent-endpoint.js +7 -1
  5. package/dist/agent-endpoint.js.map +1 -1
  6. package/dist/backend/claude-code.d.ts +22 -0
  7. package/dist/backend/claude-code.js +86 -27
  8. package/dist/backend/claude-code.js.map +1 -1
  9. package/dist/backend/codex.d.ts +20 -0
  10. package/dist/backend/codex.js +55 -5
  11. package/dist/backend/codex.js.map +1 -1
  12. package/dist/backend/muse.d.ts +6 -0
  13. package/dist/backend/muse.js +8 -0
  14. package/dist/backend/muse.js.map +1 -1
  15. package/dist/backend/session-signals.d.ts +154 -0
  16. package/dist/backend/session-signals.js +430 -0
  17. package/dist/backend/session-signals.js.map +1 -0
  18. package/dist/backend/types.d.ts +14 -0
  19. package/dist/backend/types.js.map +1 -1
  20. package/dist/channel/adapters/discord.d.ts +38 -1
  21. package/dist/channel/adapters/discord.js +131 -8
  22. package/dist/channel/adapters/discord.js.map +1 -1
  23. package/dist/channel/adapters/telegram.d.ts +19 -1
  24. package/dist/channel/adapters/telegram.js +55 -0
  25. package/dist/channel/adapters/telegram.js.map +1 -1
  26. package/dist/channel/mcp-tools.js +5 -1
  27. package/dist/channel/mcp-tools.js.map +1 -1
  28. package/dist/channel/message-queue.d.ts +6 -0
  29. package/dist/channel/message-queue.js +21 -0
  30. package/dist/channel/message-queue.js.map +1 -1
  31. package/dist/channel/sticker-download.d.ts +14 -0
  32. package/dist/channel/sticker-download.js +42 -0
  33. package/dist/channel/sticker-download.js.map +1 -0
  34. package/dist/channel/tool-router.js +12 -5
  35. package/dist/channel/tool-router.js.map +1 -1
  36. package/dist/channel/types.d.ts +52 -0
  37. package/dist/cli-flags.d.ts +8 -0
  38. package/dist/cli-flags.js +22 -0
  39. package/dist/cli-flags.js.map +1 -0
  40. package/dist/config-validator.js +25 -0
  41. package/dist/config-validator.js.map +1 -1
  42. package/dist/daemon.d.ts +91 -2
  43. package/dist/daemon.js +462 -22
  44. package/dist/daemon.js.map +1 -1
  45. package/dist/delivery-outbox.d.ts +8 -0
  46. package/dist/delivery-outbox.js.map +1 -1
  47. package/dist/event-loop-watch.d.ts +25 -0
  48. package/dist/event-loop-watch.js +40 -0
  49. package/dist/event-loop-watch.js.map +1 -0
  50. package/dist/fleet-manager.d.ts +38 -3
  51. package/dist/fleet-manager.js +248 -12
  52. package/dist/fleet-manager.js.map +1 -1
  53. package/dist/general-knowledge/skills/persona-emoji/SKILL.md +4 -2
  54. package/dist/locale.js +6 -2
  55. package/dist/locale.js.map +1 -1
  56. package/dist/outbound-handlers.js +11 -2
  57. package/dist/outbound-handlers.js.map +1 -1
  58. package/dist/outbound-schemas.d.ts +15 -1
  59. package/dist/outbound-schemas.js +19 -1
  60. package/dist/outbound-schemas.js.map +1 -1
  61. package/dist/tool-permissions.js +8 -1
  62. package/dist/tool-permissions.js.map +1 -1
  63. package/dist/transcript-jsonl.d.ts +8 -0
  64. package/dist/transcript-jsonl.js +27 -0
  65. package/dist/transcript-jsonl.js.map +1 -0
  66. package/dist/transcript-monitor.js +13 -24
  67. package/dist/transcript-monitor.js.map +1 -1
  68. package/dist/transcript-sources.js +2 -17
  69. package/dist/transcript-sources.js.map +1 -1
  70. package/dist/turn-reply-guard.d.ts +32 -1
  71. package/dist/turn-reply-guard.js +47 -1
  72. package/dist/turn-reply-guard.js.map +1 -1
  73. package/dist/turn-resume.d.ts +80 -0
  74. package/dist/turn-resume.js +217 -0
  75. package/dist/turn-resume.js.map +1 -0
  76. package/dist/ui/view.html +17 -4
  77. package/dist/ui/web-terminal/terminal.css +1 -1
  78. package/dist/ui/web-terminal/terminal.js +5 -1
  79. package/dist/usage/format-rich.js +3 -2
  80. package/dist/usage/format-rich.js.map +1 -1
  81. package/dist/usage/i18n-keys.d.ts +1 -1
  82. package/dist/usage/i18n-keys.js +1 -1
  83. package/dist/usage/i18n-keys.js.map +1 -1
  84. package/dist/usage/i18n.d.ts +5 -0
  85. package/dist/usage/i18n.js +18 -1
  86. package/dist/usage/i18n.js.map +1 -1
  87. package/dist/usage/providers.d.ts +16 -0
  88. package/dist/usage/providers.js +57 -1
  89. package/dist/usage/providers.js.map +1 -1
  90. package/dist/usage/usage-api.js +6 -2
  91. package/dist/usage/usage-api.js.map +1 -1
  92. package/package.json +1 -1
@@ -0,0 +1,154 @@
1
+ /** Which backend's journal a kind filter applies to. */
2
+ export type TurnBackend = "claude" | "codex" | "muse";
3
+ /** One read-only snapshot of a backend's session store for one session. */
4
+ export interface TurnFingerprint {
5
+ /** Session id discovered in the store itself (never caller-supplied). */
6
+ sessionId: string | null;
7
+ /** Newest store mtime observed (grace bookkeeping; never drives the verdict alone). */
8
+ storeMtimeMs: number;
9
+ /** Newest TURN entry timestamp the journal carries, else null. */
10
+ tailTimestampMs: number | null;
11
+ /** Best-effort tail turn-entry kind, else null. */
12
+ tailKind: string | null;
13
+ }
14
+ export type ReengagementVerdict = "reengaged" | "quiet" | "unknown";
15
+ /** Busyness from a store alone: always unknown — the pane stays authoritative. */
16
+ export type StoreReadiness = "ready" | "busy" | "unknown";
17
+ /**
18
+ * How long after the daemon's own store write a `quiet` read is untrustworthy.
19
+ * 10 s matches the transcript-marker wait bound (#758): a journal flush lands
20
+ * well inside it, while the window stays short enough to schedule around.
21
+ */
22
+ export declare const DEFAULT_FLUSH_GRACE_MS = 10000;
23
+ /**
24
+ * Entry-ts vs daemon-mtime skew bound (ms). A daemon-caused tail must clear
25
+ * the daemon's own mtime by more than this to count as someone else's turn.
26
+ */
27
+ export declare const DEFAULT_TAIL_SKEW_MS = 2000;
28
+ /**
29
+ * Parse an ISO instant, epoch millis, or epoch micros (muse `recorded_at`);
30
+ * anything else is null. Numbers below the micros floor pass through as
31
+ * millis; what no tailed store emits (e.g. epoch seconds) is out of scope.
32
+ */
33
+ export declare function asTimestampMs(v: unknown): number | null;
34
+ /**
35
+ * Best-effort kind of one journal entry across the three store shapes:
36
+ * claude `type`/`subtype`, codex `type` + `payload.type`, muse `payload_type`
37
+ * (+ inner `payload.kind` for the `runtime.session` envelope).
38
+ */
39
+ export declare function entryKind(entry: Record<string, unknown>): string | null;
40
+ /** Newest timestamp one journal entry carries across the three store shapes. */
41
+ export declare function entryTimestampMs(entry: Record<string, unknown>): number | null;
42
+ /**
43
+ * Whether a tail kind proves a turn ran (as opposed to CLI bookkeeping).
44
+ * Unrecognised kinds default to bookkeeping: a new turn vocabulary delays
45
+ * detection instead of blocking legitimate resumes on false positives.
46
+ */
47
+ export declare function isTurnKind(backend: TurnBackend, kind: string | null): boolean;
48
+ /** Newest parseable entries of a JSONL journal, newest first, plus file mtime. */
49
+ export interface TailRead {
50
+ entries: Array<Record<string, unknown>>;
51
+ mtimeMs: number;
52
+ }
53
+ /**
54
+ * Read-only tail of a JSONL journal: the newest `want` parseable entries
55
+ * within the last 1 MB, newest first. A truncated line at the window edge or
56
+ * a corrupt line is skipped, never fatal. Windowed by design: when the tail
57
+ * itself is one entry larger than the window, the read still returns the
58
+ * file mtime with an empty entry list (detection delayed, never fabricated).
59
+ * Synchronous blocking I/O — see the module warning.
60
+ */
61
+ export declare function readJsonlTailEntries(path: string, want?: number): TailRead | null;
62
+ /**
63
+ * Newest timestamped TURN entry of a tail: skips timestamp-less bookkeeping
64
+ * (claude `cost-state`/`last-prompt`, muse `retained_frame`) AND timestamped
65
+ * non-turn writes (codex `token_count`, muse `workspace_branch.observed`).
66
+ * Null when no turn entry carries time.
67
+ */
68
+ export declare function tailEvidence(entries: readonly Record<string, unknown>[], backend: TurnBackend): {
69
+ timestampMs: number;
70
+ kind: string | null;
71
+ } | null;
72
+ export interface CompareOptions {
73
+ /**
74
+ * Newest store write the daemon can attribute to its own action (e.g. the
75
+ * resume it just performed). A turn tail counts only past
76
+ * `max(before.tail, daemonCausedMtimeMs) + tailSkewMs`; anything at or
77
+ * below it does not count. -1 (default) = no daemon write to exclude.
78
+ */
79
+ daemonCausedMtimeMs?: number;
80
+ /** Clock for the flush-grace window; defaults to Date.now(), injectable. */
81
+ nowMs?: number;
82
+ /** See DEFAULT_FLUSH_GRACE_MS; injectable per caller. */
83
+ flushGraceMs?: number;
84
+ /** See DEFAULT_TAIL_SKEW_MS; injectable per caller. */
85
+ tailSkewMs?: number;
86
+ }
87
+ /**
88
+ * Backend-agnostic re-engagement verdict. A changed session id means the
89
+ * store now belongs to a different conversation (feeds #1217a). Otherwise
90
+ * only a TURN-tail advance past the daemon's own writes (plus skew) means
91
+ * the CLI wrote on its own — plain mtime movement is bookkeeping until a
92
+ * turn entry says otherwise. Inside the flush-grace window after a daemon
93
+ * write, `quiet` is withheld as `unknown` (see module doc).
94
+ */
95
+ export declare function compareFingerprints(before: TurnFingerprint | null, after: TurnFingerprint | null, options?: CompareOptions): ReengagementVerdict;
96
+ /**
97
+ * Store-corroborated busyness, by design always unknown: append-only journals
98
+ * carry no verified completion semantics, so a store alone cannot say "busy"
99
+ * vs "ready" — it can only say "wrote recently". The pane stays authoritative;
100
+ * this seam MUST NOT feed the idle/busy state machine.
101
+ */
102
+ export declare function readinessFromStore(_fp: TurnFingerprint | null): {
103
+ readiness: StoreReadiness;
104
+ reason: string;
105
+ };
106
+ export interface ClaudeRoots {
107
+ /** Honors CLAUDE_CONFIG_DIR at the call site; tests inject a tmp dir. */
108
+ configDir: string;
109
+ cwd: string;
110
+ }
111
+ /**
112
+ * Newest `<sessionId>.jsonl` of `~/.claude/projects/<key>/` plus its newest
113
+ * timestamped TURN tail entry. The session id is discovered from the store,
114
+ * never caller-supplied, so a conversation switch surfaces as an id change.
115
+ */
116
+ export declare function claudeFingerprint(r: ClaudeRoots): TurnFingerprint | null;
117
+ /** Minimal database surface the codex adapter needs; production passes better-sqlite3. */
118
+ export interface CodexDb {
119
+ prepare: (sql: string) => {
120
+ get: (...args: never[]) => unknown;
121
+ };
122
+ close: () => void;
123
+ }
124
+ export interface CodexRoots {
125
+ stateDbPath: string;
126
+ cwd: string;
127
+ /** Defaults to the #984 read-only opener (never creates the file). */
128
+ openDb?: (path: string) => CodexDb | null;
129
+ /** Defaults to the windowed JSONL tail; injectable for tests. */
130
+ rolloutTail?: (path: string) => TailRead | null;
131
+ /** Defaults to the production rollout turn check; injectable for tests. */
132
+ rolloutHasTurn?: (path: string) => boolean;
133
+ }
134
+ /**
135
+ * The exact-cwd session from `state_5.sqlite` (same lookup as #984: newest
136
+ * interactive thread of this directory, never `--last`), then its threads
137
+ * row (`updated_at_ms`/`recency_at_ms`) plus rollout tail. The database is
138
+ * opened read-only (never created, checkpointed, or migrated); an unknown
139
+ * session or a schema that no longer matches is null (unknown), never a
140
+ * guess. The session id is discovered from the store, never caller-supplied.
141
+ */
142
+ export declare function codexFingerprint(r: CodexRoots): TurnFingerprint | null;
143
+ export interface MuseRoots {
144
+ sessionsRoot: string;
145
+ cwd: string;
146
+ }
147
+ /**
148
+ * The most recently active session started in this working directory,
149
+ * mirroring MuseBackend.getSessionId (workspace read out of each session's
150
+ * own log, activity = newest inner-file mtime), plus its newest timestamped
151
+ * TURN tail entry. The session id is discovered from the store, never
152
+ * caller-supplied, so a conversation switch surfaces as an id change.
153
+ */
154
+ export declare function museFingerprint(r: MuseRoots): TurnFingerprint | null;
@@ -0,0 +1,430 @@
1
+ /**
2
+ * Detection-signal seam: the shared base for #1209 / #1217a / #1210 / #1215.
3
+ *
4
+ * A read-only, query-only observation layer answering ONE question without
5
+ * pane pixels: did the CLI itself re-engage a turn since the checkpoint
6
+ * (double-drive guard)? Per-backend adapters discover the workspace's session
7
+ * in the CLI's own session store and produce a `TurnFingerprint`; the
8
+ * backend-agnostic `compareFingerprints` diffs a pre-action checkpoint
9
+ * against a post-action read.
10
+ *
11
+ * RED LINE: this seam never touches the idle/busy state machine.
12
+ * `readinessFromStore` always returns `unknown` — the pane stays the
13
+ * busyness authority, exactly as today. Nothing here drives, resumes, or
14
+ * writes any CLI state; every read is out-of-band and defensive (an absent
15
+ * field is null, never an exception).
16
+ *
17
+ * SYNC I/O WARNING: every read below is synchronous blocking file/database
18
+ * I/O. Never resolve fingerprints on the fleet event loop or inside a tool
19
+ * handler — use a bounded worker context.
20
+ *
21
+ * What counts as re-engagement: a new TURN, not a store write. CLIs
22
+ * bookkeep without turns (claude `cost-state`/`ai-title`, codex threads-row
23
+ * touches, muse `session.workspace_branch.observed`), so both the mtime and
24
+ * the tail path are gated on turn-shaped journal entries (`isTurnKind`):
25
+ * file mtime is recorded for grace bookkeeping but never drives the verdict
26
+ * alone. Kinds this seam does not recognise default to bookkeeping — a new
27
+ * turn vocabulary delays detection to the next recognised write instead of
28
+ * fabricating or blocking on it.
29
+ *
30
+ * Daemon exclusion covers BOTH paths: the daemon's own action (e.g. a resume)
31
+ * writes tail entries too, so a turn tail counts only past
32
+ * `max(before.tail, daemonCausedMtimeMs) + tailSkewMs`. The skew (default 2s:
33
+ * filesystem timestamp granularity plus entry-ts vs flush-mtime reorder —
34
+ * a live codex tail was observed 2ms AFTER its row mtime) keeps a
35
+ * daemon-caused tail from reading as someone else's turn.
36
+ *
37
+ * Tail-timestamp fields were verified against live stores, not assumed:
38
+ * - claude-code 2.1.289 transcript JSONL: user/assistant/system entries carry
39
+ * ISO `timestamp`, but the tail is usually bookkeeping (`cost-state`,
40
+ * `last-prompt`, `mode`, `ai-title`, …) with NO timestamp — so the reader
41
+ * scans backwards for the newest timestamped TURN entry instead of taking
42
+ * the last line.
43
+ * - codex rollout JSONL: every line of a lived-in 53k-line rollout carries
44
+ * top-level ISO `timestamp`; `type` + `payload.type` name the kind
45
+ * (`response_item:message`, `event_msg:task_started`, `turn_context`,
46
+ * `token_usage_record`, …). threads row verified with `updated_at_ms` /
47
+ * `recency_at_ms` epoch millis.
48
+ * - muse 1.4.x `session.jsonl`: entries carry NO `timestamp` at all — time is
49
+ * `recorded_at` in epoch MICROseconds, kind is `payload_type` (plus inner
50
+ * `payload.kind` for the `runtime.session` envelope: `task`/`run` are the
51
+ * turn frames, surveyed live over 49k lines); the first line is a
52
+ * `retained_frame` wrapper with neither.
53
+ *
54
+ * Flush grace and its residual: a CLI that just re-engaged may not have
55
+ * flushed its store yet, so a checkpoint taken too early reads `quiet` for a
56
+ * live turn. Inside `flushGraceMs` after the daemon's own write the seam
57
+ * answers `unknown` instead of `quiet`. Residual, by design and bounded: a
58
+ * re-engagement that flushes after this compare is caught by the NEXT
59
+ * checkpoint compare (at most one grace period of delayed detection, never a
60
+ * fabricated verdict). A re-engagement that never writes to the session store
61
+ * is invisible to this seam. Callers MUST re-compare across checkpoints; a
62
+ * single `quiet` inside the grace window must never authorize driving.
63
+ *
64
+ * kiro-classic `data.sqlite3` and KAS are deliberately NOT covered here: the
65
+ * classic schema needs its own round (see #1210) and the spike's KAS field
66
+ * assumptions were never verified against a live store.
67
+ */
68
+ import { closeSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
69
+ import { join } from "node:path";
70
+ import { claudeProjectKey } from "./claude-code.js";
71
+ import { findExactCwdCodexSession, openCodexStateReadonly, rolloutRecordsTurn } from "./codex-session-lookup.js";
72
+ import { museSessionCwd, museSessionDirs } from "./muse.js";
73
+ /**
74
+ * How long after the daemon's own store write a `quiet` read is untrustworthy.
75
+ * 10 s matches the transcript-marker wait bound (#758): a journal flush lands
76
+ * well inside it, while the window stays short enough to schedule around.
77
+ */
78
+ export const DEFAULT_FLUSH_GRACE_MS = 10_000;
79
+ /**
80
+ * Entry-ts vs daemon-mtime skew bound (ms). A daemon-caused tail must clear
81
+ * the daemon's own mtime by more than this to count as someone else's turn.
82
+ */
83
+ export const DEFAULT_TAIL_SKEW_MS = 2_000;
84
+ /** Epoch microseconds at or above this are muse `recorded_at`, not millis. */
85
+ const MICROSECONDS_FLOOR = 1e14;
86
+ /**
87
+ * Parse an ISO instant, epoch millis, or epoch micros (muse `recorded_at`);
88
+ * anything else is null. Numbers below the micros floor pass through as
89
+ * millis; what no tailed store emits (e.g. epoch seconds) is out of scope.
90
+ */
91
+ export function asTimestampMs(v) {
92
+ if (typeof v === "number") {
93
+ if (!Number.isFinite(v))
94
+ return null;
95
+ return v >= MICROSECONDS_FLOOR ? v / 1000 : v;
96
+ }
97
+ if (typeof v === "string") {
98
+ const ms = Date.parse(v);
99
+ return Number.isFinite(ms) ? ms : null;
100
+ }
101
+ return null;
102
+ }
103
+ function str(v) {
104
+ return typeof v === "string" && v !== "" ? v : null;
105
+ }
106
+ /**
107
+ * Best-effort kind of one journal entry across the three store shapes:
108
+ * claude `type`/`subtype`, codex `type` + `payload.type`, muse `payload_type`
109
+ * (+ inner `payload.kind` for the `runtime.session` envelope).
110
+ */
111
+ export function entryKind(entry) {
112
+ const payload = entry.payload;
113
+ const payloadObj = payload && typeof payload === "object" && !Array.isArray(payload)
114
+ ? payload
115
+ : null;
116
+ const base = str(entry.type) ?? str(entry.kind) ?? str(entry.payload_type)
117
+ ?? str(payloadObj?.type) ?? str(payloadObj?.payload_type) ?? str(payloadObj?.kind);
118
+ if (!base)
119
+ return null;
120
+ const detail = str(entry.subtype) ?? str(payloadObj?.kind) ?? str(entry.payload_type)
121
+ ?? str(payloadObj?.type) ?? str(payloadObj?.payload_type);
122
+ return detail && detail !== base ? `${base}:${detail}` : base;
123
+ }
124
+ /** Newest timestamp one journal entry carries across the three store shapes. */
125
+ export function entryTimestampMs(entry) {
126
+ return asTimestampMs(entry.recorded_at ?? entry.timestamp ?? entry.time ?? entry.createdAt ?? entry.lastModifiedAt);
127
+ }
128
+ /**
129
+ * Whether a tail kind proves a turn ran (as opposed to CLI bookkeeping).
130
+ * Unrecognised kinds default to bookkeeping: a new turn vocabulary delays
131
+ * detection instead of blocking legitimate resumes on false positives.
132
+ */
133
+ export function isTurnKind(backend, kind) {
134
+ if (!kind)
135
+ return false;
136
+ if (backend === "claude")
137
+ return kind === "user" || kind === "assistant";
138
+ if (backend === "codex") {
139
+ return kind === "response_item" || kind.startsWith("response_item:")
140
+ || kind.startsWith("event_msg:task_");
141
+ }
142
+ if (kind === "command.invoked" || kind === "session.resumed")
143
+ return true;
144
+ if (kind.startsWith("runtime.user_intent."))
145
+ return true;
146
+ if (kind.startsWith("tool_batch.effect."))
147
+ return true;
148
+ return kind === "runtime.session.task" || kind === "runtime.session.task_source_committed"
149
+ || kind === "runtime.session:task" || kind === "runtime.session:run";
150
+ }
151
+ /** Bytes scanned back from the end of a journal looking for tail entries. */
152
+ const TAIL_SCAN_BYTES = 1024 * 1024;
153
+ /**
154
+ * Read-only tail of a JSONL journal: the newest `want` parseable entries
155
+ * within the last 1 MB, newest first. A truncated line at the window edge or
156
+ * a corrupt line is skipped, never fatal. Windowed by design: when the tail
157
+ * itself is one entry larger than the window, the read still returns the
158
+ * file mtime with an empty entry list (detection delayed, never fabricated).
159
+ * Synchronous blocking I/O — see the module warning.
160
+ */
161
+ export function readJsonlTailEntries(path, want = 8) {
162
+ if (!(want >= 1))
163
+ want = 1;
164
+ try {
165
+ const st = statSync(path);
166
+ if (!st.isFile())
167
+ return null;
168
+ const window = Math.min(st.size, TAIL_SCAN_BYTES);
169
+ const buf = Buffer.alloc(window);
170
+ const fd = openSync(path, "r");
171
+ try {
172
+ readSync(fd, buf, 0, window, st.size - window);
173
+ }
174
+ finally {
175
+ try {
176
+ closeSync(fd);
177
+ }
178
+ catch { /* already closed */ }
179
+ }
180
+ const lines = buf.toString("utf8").split("\n");
181
+ const entries = [];
182
+ for (let i = lines.length - 1; i >= 0 && entries.length < want; i--) {
183
+ const line = lines[i].trim();
184
+ if (!line)
185
+ continue;
186
+ try {
187
+ const parsed = JSON.parse(line);
188
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
189
+ entries.push(parsed);
190
+ }
191
+ }
192
+ catch { /* partial line at the window edge or corrupt: skip */ }
193
+ }
194
+ return { entries, mtimeMs: st.mtimeMs };
195
+ }
196
+ catch {
197
+ return null;
198
+ }
199
+ }
200
+ /**
201
+ * Newest timestamped TURN entry of a tail: skips timestamp-less bookkeeping
202
+ * (claude `cost-state`/`last-prompt`, muse `retained_frame`) AND timestamped
203
+ * non-turn writes (codex `token_count`, muse `workspace_branch.observed`).
204
+ * Null when no turn entry carries time.
205
+ */
206
+ export function tailEvidence(entries, backend) {
207
+ for (const entry of entries) {
208
+ const kind = entryKind(entry);
209
+ if (!isTurnKind(backend, kind))
210
+ continue;
211
+ const timestampMs = entryTimestampMs(entry);
212
+ if (timestampMs !== null)
213
+ return { timestampMs, kind };
214
+ }
215
+ return null;
216
+ }
217
+ /**
218
+ * Backend-agnostic re-engagement verdict. A changed session id means the
219
+ * store now belongs to a different conversation (feeds #1217a). Otherwise
220
+ * only a TURN-tail advance past the daemon's own writes (plus skew) means
221
+ * the CLI wrote on its own — plain mtime movement is bookkeeping until a
222
+ * turn entry says otherwise. Inside the flush-grace window after a daemon
223
+ * write, `quiet` is withheld as `unknown` (see module doc).
224
+ */
225
+ export function compareFingerprints(before, after, options = {}) {
226
+ if (!before || !after || before.storeMtimeMs < 0 || after.storeMtimeMs < 0)
227
+ return "unknown";
228
+ if (before.sessionId && after.sessionId && before.sessionId !== after.sessionId)
229
+ return "reengaged";
230
+ const daemonCausedMtimeMs = options.daemonCausedMtimeMs ?? -1;
231
+ const tailSkewMs = Math.max(0, options.tailSkewMs ?? DEFAULT_TAIL_SKEW_MS);
232
+ const afterTail = after.tailTimestampMs;
233
+ const pastBefore = afterTail !== null
234
+ && (before.tailTimestampMs === null || afterTail > before.tailTimestampMs);
235
+ const pastDaemon = afterTail !== null
236
+ && (daemonCausedMtimeMs < 0 || afterTail > daemonCausedMtimeMs + tailSkewMs);
237
+ if (pastBefore && pastDaemon)
238
+ return "reengaged";
239
+ if (daemonCausedMtimeMs >= 0) {
240
+ const nowMs = options.nowMs ?? Date.now();
241
+ const flushGraceMs = options.flushGraceMs ?? DEFAULT_FLUSH_GRACE_MS;
242
+ if (nowMs - daemonCausedMtimeMs <= flushGraceMs)
243
+ return "unknown";
244
+ }
245
+ return "quiet";
246
+ }
247
+ /**
248
+ * Store-corroborated busyness, by design always unknown: append-only journals
249
+ * carry no verified completion semantics, so a store alone cannot say "busy"
250
+ * vs "ready" — it can only say "wrote recently". The pane stays authoritative;
251
+ * this seam MUST NOT feed the idle/busy state machine.
252
+ */
253
+ export function readinessFromStore(_fp) {
254
+ return {
255
+ readiness: "unknown",
256
+ reason: "append-only journal without verified completion entries; pane stays authoritative",
257
+ };
258
+ }
259
+ /**
260
+ * Newest `<sessionId>.jsonl` of `~/.claude/projects/<key>/` plus its newest
261
+ * timestamped TURN tail entry. The session id is discovered from the store,
262
+ * never caller-supplied, so a conversation switch surfaces as an id change.
263
+ */
264
+ export function claudeFingerprint(r) {
265
+ const dir = join(r.configDir, "projects", claudeProjectKey(r.cwd));
266
+ let names;
267
+ try {
268
+ names = readdirSync(dir);
269
+ }
270
+ catch {
271
+ return null;
272
+ }
273
+ let bestFile = null;
274
+ let bestMtime = -1;
275
+ for (const name of names) {
276
+ if (!name.endsWith(".jsonl"))
277
+ continue;
278
+ try {
279
+ const m = statSync(join(dir, name)).mtimeMs;
280
+ if (m > bestMtime) {
281
+ bestMtime = m;
282
+ bestFile = name;
283
+ }
284
+ }
285
+ catch { /* raced with deletion */ }
286
+ }
287
+ if (!bestFile)
288
+ return null;
289
+ const tail = readJsonlTailEntries(join(dir, bestFile));
290
+ const evidence = tail && tailEvidence(tail.entries, "claude");
291
+ return {
292
+ sessionId: bestFile.slice(0, -".jsonl".length),
293
+ storeMtimeMs: tail?.mtimeMs ?? bestMtime,
294
+ tailTimestampMs: evidence?.timestampMs ?? null,
295
+ tailKind: evidence?.kind ?? null,
296
+ };
297
+ }
298
+ /**
299
+ * The exact-cwd session from `state_5.sqlite` (same lookup as #984: newest
300
+ * interactive thread of this directory, never `--last`), then its threads
301
+ * row (`updated_at_ms`/`recency_at_ms`) plus rollout tail. The database is
302
+ * opened read-only (never created, checkpointed, or migrated); an unknown
303
+ * session or a schema that no longer matches is null (unknown), never a
304
+ * guess. The session id is discovered from the store, never caller-supplied.
305
+ */
306
+ export function codexFingerprint(r) {
307
+ const openDb = r.openDb ?? ((path) => openCodexStateReadonly(path));
308
+ const rolloutTail = r.rolloutTail ?? ((path) => readJsonlTailEntries(path));
309
+ const rolloutHasTurn = r.rolloutHasTurn ?? rolloutRecordsTurn;
310
+ const discoveryOpen = (path) => {
311
+ let db = null;
312
+ try {
313
+ db = openDb(path);
314
+ }
315
+ catch { /* fall through to throw */ }
316
+ if (!db)
317
+ throw new Error(`codex state unreadable: ${path}`);
318
+ return db;
319
+ };
320
+ let sessionId;
321
+ try {
322
+ const lookup = findExactCwdCodexSession(r.stateDbPath, r.cwd, discoveryOpen, rolloutHasTurn);
323
+ if (lookup.kind !== "found")
324
+ return null;
325
+ sessionId = lookup.id;
326
+ }
327
+ catch {
328
+ return null;
329
+ }
330
+ let db = null;
331
+ try {
332
+ try {
333
+ db = openDb(r.stateDbPath);
334
+ }
335
+ catch {
336
+ return null;
337
+ }
338
+ if (!db)
339
+ return null;
340
+ const row = db.prepare("SELECT updated_at_ms, recency_at_ms, rollout_path FROM threads WHERE id = ?").get(sessionId);
341
+ if (!row)
342
+ return null;
343
+ let tailTimestampMs = null;
344
+ let tailKind = null;
345
+ let fileMtime = -1;
346
+ if (typeof row.rollout_path === "string") {
347
+ const tail = rolloutTail(row.rollout_path);
348
+ if (tail) {
349
+ fileMtime = tail.mtimeMs;
350
+ const evidence = tailEvidence(tail.entries, "codex");
351
+ tailTimestampMs = evidence?.timestampMs ?? null;
352
+ tailKind = evidence?.kind ?? null;
353
+ }
354
+ }
355
+ const storeMtimeMs = Math.max(typeof row.updated_at_ms === "number" ? row.updated_at_ms : -1, typeof row.recency_at_ms === "number" ? row.recency_at_ms : -1, fileMtime);
356
+ return storeMtimeMs < 0
357
+ ? null
358
+ : { sessionId, storeMtimeMs, tailTimestampMs, tailKind };
359
+ }
360
+ catch {
361
+ return null;
362
+ }
363
+ finally {
364
+ try {
365
+ db?.close();
366
+ }
367
+ catch { /* already closed */ }
368
+ }
369
+ }
370
+ /** Session-id pattern, mirroring muse.ts (MuseBackend session ids are UUIDs). */
371
+ const MUSE_SESSION_ID_RE = /^[0-9a-fA-F-]{8,}$/;
372
+ /** Log head scanned for the workspace marker, mirroring muse.ts. */
373
+ const MUSE_SESSION_HEAD_BYTES = 65_536;
374
+ /**
375
+ * The most recently active session started in this working directory,
376
+ * mirroring MuseBackend.getSessionId (workspace read out of each session's
377
+ * own log, activity = newest inner-file mtime), plus its newest timestamped
378
+ * TURN tail entry. The session id is discovered from the store, never
379
+ * caller-supplied, so a conversation switch surfaces as an id change.
380
+ */
381
+ export function museFingerprint(r) {
382
+ if (!r.cwd)
383
+ return null;
384
+ let bestId = null;
385
+ let bestDir = "";
386
+ let bestActivity = -1;
387
+ for (const sessionDir of museSessionDirs(r.sessionsRoot)) {
388
+ const name = sessionDir.slice(sessionDir.lastIndexOf("/") + 1);
389
+ if (!MUSE_SESSION_ID_RE.test(name))
390
+ continue;
391
+ let head;
392
+ try {
393
+ head = readFileSync(join(sessionDir, "session.jsonl"), { encoding: "utf-8", flag: "r" })
394
+ .slice(0, MUSE_SESSION_HEAD_BYTES);
395
+ }
396
+ catch {
397
+ continue;
398
+ }
399
+ if (museSessionCwd(head) !== r.cwd)
400
+ continue;
401
+ let activity = -1;
402
+ try {
403
+ for (const f of readdirSync(sessionDir)) {
404
+ try {
405
+ const m = statSync(join(sessionDir, f)).mtimeMs;
406
+ if (m > activity)
407
+ activity = m;
408
+ }
409
+ catch { /* raced with deletion */ }
410
+ }
411
+ }
412
+ catch { /* unreadable */ }
413
+ if (activity > bestActivity) {
414
+ bestActivity = activity;
415
+ bestId = name;
416
+ bestDir = sessionDir;
417
+ }
418
+ }
419
+ if (!bestId)
420
+ return null;
421
+ const tail = readJsonlTailEntries(join(bestDir, "session.jsonl"));
422
+ const evidence = tail && tailEvidence(tail.entries, "muse");
423
+ return {
424
+ sessionId: bestId,
425
+ storeMtimeMs: bestActivity,
426
+ tailTimestampMs: evidence?.timestampMs ?? null,
427
+ tailKind: evidence?.kind ?? null,
428
+ };
429
+ }
430
+ //# sourceMappingURL=session-signals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-signals.js","sourceRoot":"","sources":["../../src/backend/session-signals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAsB5D;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,8EAA8E;AAC9E,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU;IACtC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACrC,OAAO,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAA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AE,CAAC;YAAC,YAAY,GAAG,QAAQ,CAAC;YAAC,MAAM,GAAG,IAAI,CAAC;YAAC,OAAO,GAAG,UAAU,CAAC;QAAC,CAAC;IAChG,CAAC;IACD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5D,OAAO;QACL,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,YAAY;QAC1B,eAAe,EAAE,QAAQ,EAAE,WAAW,IAAI,IAAI;QAC9C,QAAQ,EAAE,QAAQ,EAAE,IAAI,IAAI,IAAI;KACjC,CAAC;AACJ,CAAC"}
@@ -386,6 +386,20 @@ export interface CliBackend {
386
386
  * cost users their history. Backends override to false only with a reason.
387
387
  */
388
388
  retriesResumeOnStartupFailure?(): boolean;
389
+ /**
390
+ * #1217: what this CLI prints when the session it was told to resume does
391
+ * not exist — positive proof the stored session id can be set aside. Each
392
+ * CLI words it differently; a backend that names none is judged by the Claude
393
+ * phrasing AgEnD always used. Must match only the CLI's own message.
394
+ */
395
+ resumeMissingPattern?(): RegExp;
396
+ /**
397
+ * #1217: a dialog the CLI shows in answer to its quit command that must not
398
+ * be answered by a stray key (Claude's "Background work is running": Enter
399
+ * picks "Exit and stop tasks"). When the stop flow sees it, it presses
400
+ * Escape (cancel, never a choice) and stops the process itself.
401
+ */
402
+ quitBlockedByDialog?(pane: string): boolean;
389
403
  /**
390
404
  * Whether the TUI can emit terminal output while its visible pane is
391
405
  * unchanged (for example, rerunning and repainting a status-line hook).
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,E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