@lucascouts/claude-agent-tui 0.14.13 → 0.15.1

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.
@@ -10,11 +10,13 @@ import { SessionEngine } from "./engine-lifecycle.js";
10
10
  import type { SessionWatcher } from "./engine-lifecycle.js";
11
11
  import type { JsonlWatcher, GetMessages, SessionMessage } from "./engine-watcher.js";
12
12
  import type { LocateOptions } from "./jsonl.js";
13
+ import { type BackgroundTaskEnd } from "./background-task-end.js";
13
14
  import type { DiffEnrichedReaderOptions } from "./diff-enriched-reader.js";
14
15
  import type { ListSubagents, GetSubagentMessages } from "./subagent-source.js";
15
16
  import { type SidechainToolUse } from "./subagent-gate.js";
16
17
  import type { SubagentWatcher } from "./subagent-watcher.js";
17
18
  import type { DetectorSchedule, EndOfTurnDetector } from "./end-of-turn.js";
19
+ import { type SupportedModelsSource } from "./live-model-catalog.js";
18
20
  import { type AgentCatalogEntry } from "./agent-catalog.js";
19
21
  import type { SessionGate, SessionGateOptions } from "./permissions/gate-wiring.js";
20
22
  export declare const CLAUDE_CONFIG_DIR: string;
@@ -51,6 +53,19 @@ type Session = {
51
53
  * was surfaced in an earlier pump). Per-session — sub-agent row uuids are session-scoped.
52
54
  */
53
55
  emittedNested: Set<string>;
56
+ /**
57
+ * Item 92 (upstream #1312) — ended background tasks, keyed by the `tool_use_id` of the Bash call that
58
+ * started them, re-derived from the raw transcript on every read (`backgroundTaskEnds`). Absent when
59
+ * the raw transcript is not read (`liveDiff` off), which is also when no result is known to be
60
+ * backgrounded.
61
+ */
62
+ backgroundTaskEnds?: Map<string, BackgroundTaskEnd>;
63
+ /**
64
+ * Item 92 — terminals of backgrounded commands whose exit the live pump held back at the tool result
65
+ * because the command was still running; {@link ClaudeAcpAgent.flushBackgroundExits} sends each exit
66
+ * once the task's notification reaches the transcript.
67
+ */
68
+ heldBackgroundExits?: Set<string>;
54
69
  /**
55
70
  * Story 056 (#812) — the last session title pushed to the client via `session_info_update` at the
56
71
  * story-024 turn boundary. Used to DEDUP: `emitSessionTitleUpdate` skips the push when the freshly
@@ -169,12 +184,28 @@ type Session = {
169
184
  */
170
185
  pendingEffortInjection?: string;
171
186
  /**
172
- * Story 060 (R2.1/R2.2) — true WHILE the "ultracode" effort-selector sentinel is selected for this
173
- * session. The LIVE activation it drives is a keyword prefix on the OUTGOING prompt (the binary's
174
- * documented per-turn Workflow opt-in) — Option A, no re-spawn. Cleared when a real effort level (or
175
- * `default`) is re-selected. The declarative spawn-time complement is {@link applyUltracodeSettings}.
187
+ * Item 84 — the user's Ultracode intent for this session (default off), set by
188
+ * {@link applyUltracodeChange} and cleared when the CLI refuses it. It survives a model switch: the
189
+ * option hides on a model that cannot run Ultracode and shows again, still on, when switching back —
190
+ * the CLI keeps the request the same way. Independent of the effort level.
191
+ */
192
+ ultracodeOn?: boolean;
193
+ /**
194
+ * Item 84 — the CLI's reason for refusing the last `/effort ultracode on`, shown in the option's
195
+ * description. `scope: "model"` (the model cannot run it) is cleared by a model switch;
196
+ * `scope: "workflows"` (dynamic workflows are disabled) is not, because a switch does not change it.
176
197
  */
177
- ultracodeActive?: boolean;
198
+ ultracodeRefusal?: {
199
+ scope: "model" | "workflows";
200
+ reason: string;
201
+ };
202
+ /**
203
+ * Item 84 — a `/effort ultracode on|off` requested WHILE a turn is in flight is deferred here
204
+ * (last-write-wins) and flushed once the turn settles (mirrors {@link pendingEffortInjection}).
205
+ */
206
+ pendingUltracodeInjection?: boolean;
207
+ /** Item 84 — stops the reply watch of the last `/effort ultracode on`, while one is running. */
208
+ ultracodeReplyStop?: () => void;
178
209
  /**
179
210
  * Story 073 (R2.3/R3.2) — the session's CURRENT fast-mode on/off state (default off). Set by
180
211
  * {@link applyFastModeChange} and read by {@link buildConfigOptions} for the `fast` option's
@@ -252,6 +283,11 @@ export interface StartedEngine {
252
283
  watcher?: JsonlWatcher | SessionWatcher;
253
284
  engine?: SessionEngine;
254
285
  cwd?: string;
286
+ /**
287
+ * Item 107: the located transcript, set by the replay-only load path so `createSession` can read
288
+ * the permission mode it last recorded. Absent on the spawning paths.
289
+ */
290
+ transcriptPath?: string;
255
291
  }
256
292
  /** Arguments passed to {@link StartEngine}. `sessionId` is the requested id for resume/fork; for a
257
293
  * fresh session it is undefined and the engine's spawn generates the authoritative id. */
@@ -511,6 +547,12 @@ export interface AgentDeps {
511
547
  * `true`/`false` to exercise the toggle's advertise/apply/reconcile paths hermetically.
512
548
  */
513
549
  fastModeProbe?: FastModeProbe;
550
+ /**
551
+ * Item 93 — override where `createSession` reads the model picker from (default: the PATH `claude`'s
552
+ * `supportedModels()`, see live-model-catalog.ts). Tests inject a fixed catalogue so they assert this
553
+ * adapter's behaviour, not whatever the host CLI serves that day.
554
+ */
555
+ modelCatalogSource?: SupportedModelsSource;
514
556
  }
515
557
  /**
516
558
  * Production default for the {@link StartEngine} seam. Spawns the subscription `claude` TUI under a
@@ -608,7 +650,7 @@ export type ToolUpdateMeta = {
608
650
  };
609
651
  terminal_exit?: {
610
652
  terminal_id: string;
611
- exit_code: number;
653
+ exit_code: number | null;
612
654
  signal: string | null;
613
655
  };
614
656
  };
@@ -699,6 +741,8 @@ export declare class ClaudeAcpAgent implements Agent {
699
741
  private readonly getSessionInfo;
700
742
  /** Story 073 (R1) — fast-mode availability probe seam; see {@link AgentDeps.fastModeProbe}. */
701
743
  private readonly fastModeProbe;
744
+ /** Item 93 — model-picker source seam; see {@link AgentDeps.modelCatalogSource}. */
745
+ private readonly modelCatalogSource;
702
746
  /** Live PTY-engine registry shared with the per-session engines (story 014 cleanup map). */
703
747
  private readonly engines;
704
748
  constructor(client: AgentSideConnection, logger?: Logger, engine?: Engine, deps?: AgentDeps);
@@ -814,24 +858,31 @@ export declare class ClaudeAcpAgent implements Agent {
814
858
  private currentEffort;
815
859
  /** Story 056 — the session's current agent configOption value (undefined when no agent option). */
816
860
  private currentAgent;
861
+ /** Item 84 — the session's current model configOption value (`default` when absent). */
862
+ private currentModel;
817
863
  /**
818
- * Story 060 (R2/R3.2) — apply an effort-selector choice, special-casing the `ultracode` sentinel.
819
- *
820
- * Selecting `ultracode` (Option A — keyword + scratch, NO re-spawn): activate the session flag (which
821
- * makes {@link prompt} prefix the OUTGOING prompt with the `ultracode` keyword — the binary's per-turn
822
- * Workflow opt-in, the effective live mechanism), write the scratch ultracode keys via
823
- * {@link applyUltracodeSettings} (the declarative spawn-time complement), and set the effort to xhigh
824
- * through the SAME live `/effort` inject as every other level — NEVER `/effort ultracode` (R1.2). The
825
- * `already` guard suppresses a redundant `/effort xhigh` re-inject when ultracode is re-selected while
826
- * already active.
827
- *
828
- * Selecting a real level (or `default`) DEACTIVATES ultracode: clear the flag, remove the scratch keys,
829
- * then apply that level through {@link applyEffortChange} (whose own no-op guard handles a same-level
830
- * pick). `applyConfigOptionValue` (the caller, after this returns) commits the selector's currentValue,
831
- * which for `ultracode` correctly stays `"ultracode"` (the {@link buildConfigOptions} `includes` guard
832
- * keeps it valid across rebuilds).
864
+ * Item 84 — turn the Ultracode switch on or off, LIVE via `/effort ultracode on|off` through the
865
+ * session's terminal, exactly as {@link applyFastModeChange} drives `/fast`: no re-spawn, no turn,
866
+ * works before the first prompt, deferred while a turn is in flight. Turning it on clears a previous
867
+ * refusal (the user is retrying). The scratch settings mirror the intent so a re-spawn keeps it.
868
+ * A no-op change sends nothing.
869
+ */
870
+ private applyUltracodeChange;
871
+ /** Item 84 — keep `ultracode:true` in the scratch `--settings` file only while the switch is on. */
872
+ private mirrorUltracodeIntoScratch;
873
+ /**
874
+ * Item 84 — side-channel `/effort ultracode on|off` write (synchronous, never a turn; `/effort`
875
+ * applies inline, no confirmation panel). After an `on`, watch the terminal for a bounded window
876
+ * for the CLI's answer: one of its two refusals turns the switch back off with the reason
877
+ * ({@link handleUltracodeRefusal}); its confirmation, or silence, ends the watch.
833
878
  */
834
- private applyEffortSelection;
879
+ private injectUltracodeCommand;
880
+ private watchUltracodeReply;
881
+ /**
882
+ * Item 84 — the CLI refused `/effort ultracode on`: the switch goes back off, the reason is kept for
883
+ * the option's description, the scratch key is removed, and the client gets the new options.
884
+ */
885
+ private handleUltracodeRefusal;
835
886
  /**
836
887
  * Story 046 (R2.2) + Story 056 v4 — apply a reasoning-effort change LIVE via `/effort <level>`.
837
888
  * SUPERSEDES the 046 Probe-B re-spawn: `claude` 2.1.195 DOES have a live `/effort <level>` local TUI
@@ -962,6 +1013,13 @@ export declare class ClaudeAcpAgent implements Agent {
962
1013
  * is NO SDK message stream. The end-of-turn predicate is story 024; this only consumes the signal.
963
1014
  */
964
1015
  private pumpUpdates;
1016
+ /**
1017
+ * Item 92 (upstream #1312) — send the terminal exit of each backgrounded command whose task has now
1018
+ * ended. The live pump held that exit back at the tool result (the command was still running); the
1019
+ * task's `<task-notification>` in the raw transcript is its end, and its summary the code. Each held
1020
+ * exit is sent once. Live-only: replay never holds an exit, so it has nothing to flush.
1021
+ */
1022
+ private flushBackgroundExits;
965
1023
  /**
966
1024
  * Story 041 (R3.1, R3.2) — the SHARED source+merge+linearize+emit loop run by BOTH the live tail pump
967
1025
  * ({@link pumpUpdates}) and the `session/load` replay ({@link replaySessionHistory}), so a LOADED
@@ -1052,6 +1110,10 @@ export declare function toAcpNotifications(content: string | ContentBlockParam[]
1052
1110
  cwd?: string;
1053
1111
  taskState?: TaskState;
1054
1112
  toolUseResult?: unknown;
1113
+ background?: {
1114
+ ended: (toolUseId: string) => BackgroundTaskEnd | undefined;
1115
+ held?: Set<string>;
1116
+ };
1055
1117
  }): SessionNotification[];
1056
1118
  export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger, options?: {
1057
1119
  clientCapabilities?: ClientCapabilities;
@@ -1082,7 +1144,7 @@ export declare function inferContextWindowFromModel(model: string): number | nul
1082
1144
  * field), used by the pump to refine the alias seed once the model is known. Exact-ID lookup first
1083
1145
  * (MODEL_ID_CONTEXT_WINDOWS), then a family+version heuristic for dated snapshots / future variants
1084
1146
  * (Opus is NOT uniform: 4.6 and earlier = 200K, 4.7+ = 1M; Sonnet 4.x = 200K but Sonnet 5+ = 1M;
1085
- * haiku = 200K; fable = 1M — story 071), then a
1147
+ * Haiku 4.x = 200K but Haiku 5+ = 1M — item 93; fable = 1M — story 071), then a
1086
1148
  * `\b1m\b` suffix, then null (R1.3: a missing / non-string id never refines). */
1087
1149
  export declare function inferContextWindowFromModelId(id: string): number | null;
1088
1150
  export {};