@xmoon76/dsh-pi-tui 0.3.6 → 0.4.0-alpha.2

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.
@@ -4,15 +4,35 @@ import { D as PiTuiApiInfo, _ as ExtensionTier, ot as TuiOverlayOptions } from "
4
4
  /** API level of the unstable tier. Bumped only on unstable breaking changes. */
5
5
  declare const UNSTABLE_API_LEVEL: 1;
6
6
  /**
7
- * One raw terminal input chunk (plan §5). The plugin receives the RAW
8
- * bytes exactly as the terminal delivered them — no decoding, no
9
- * sanitization. `surfaceId` identifies the surface generation the chunk
10
- * arrived on.
7
+ * One normalized terminal input sequence (plan §5). The plugin receives
8
+ * the input AFTER the terminal pipeline has reassembled and normalized it
9
+ * — NOT the raw OS byte stream. The Host's input path is:
10
+ *
11
+ * ```text
12
+ * OS stdin
13
+ * → ProcessTerminal / StdinBuffer (batched chunks split into individual
14
+ * sequences; bracketed-paste content re-wrapped in its markers)
15
+ * → keyboard-protocol negotiation (Kitty flags / DA replies filtered)
16
+ * → native modifier normalization (Windows / Apple Terminal Return →
17
+ * CSI-u Shift+Enter)
18
+ * → TUI-owned query replies filtered (OSC11 background, color-scheme
19
+ * reports, cell-size responses)
20
+ * → TUI input listeners
21
+ * → THIS capture (BEFORE Host semantic routing)
22
+ * ```
23
+ *
24
+ * So the sequence is a `preHostInput` event: it can see, consume or
25
+ * rewrite anything the Host router would otherwise decode — Enter, Esc,
26
+ * Ctrl+C, bracketed paste (markers preserved), CSI-u sequences — but it
27
+ * CANNOT see the terminal-negotiation replies the TUI itself consumes
28
+ * (Kitty/DA, OSC11, color-scheme, cell-size), and it never sees raw
29
+ * multi-byte chunks mid-sequence. `surfaceId` identifies the surface
30
+ * generation the sequence arrived on.
11
31
  */
12
32
  interface UnstableRawInputEvent {
13
- /** The raw terminal data (a chunk, not necessarily one key). */
33
+ /** The normalized terminal input sequence (a sequence, not a raw chunk). */
14
34
  readonly data: string;
15
- /** The surface generation the chunk arrived on. */
35
+ /** The surface generation the sequence arrived on. */
16
36
  readonly surfaceId: string;
17
37
  }
18
38
  /** The outcome of one raw interception (plan §5). */
@@ -33,12 +53,17 @@ type UnstableRawInputResult = /** Pass the chunk through unchanged (the Host con
33
53
  type UnstableRawCaptureMode = 'observe' | 'capture' | 'exclusive';
34
54
  /**
35
55
  * One raw input capture registration (plan §5/§8). The capture is
36
- * consulted by the Host BEFORE terminal protocol decoding — it can see,
37
- * consume or rewrite ANY raw chunk, including Enter, Esc, Ctrl+C, paste,
38
- * CSI-u sequences and terminal-specific protocols. This is the Unstable
39
- * contract: a broken capture can make Host shortcuts stop working. The
40
- * ONLY Host-owned recovery is the emergency fail-safe (triple-Esc), which
41
- * the Unstable API cannot rewrite.
56
+ * consulted by the Host BEFORE semantic routing — after the terminal
57
+ * pipeline has reassembled and normalized the input (see
58
+ * {@link UnstableRawInputEvent}): it can see, consume or rewrite any
59
+ * sequence that would otherwise reach the Host router, including Enter,
60
+ * Esc, Ctrl+C, paste and CSI-u sequences. It is NOT consulted before
61
+ * terminal protocol decoding: the TUI's own negotiation replies (Kitty
62
+ * flags, DA, OSC11, color-scheme, cell-size) never reach a capture, and
63
+ * a capture cannot break the terminal negotiation. This is the Unstable
64
+ * contract: a broken capture can still make Host shortcuts stop working.
65
+ * The ONLY Host-owned recovery is the emergency fail-safe (triple-Esc),
66
+ * which the Unstable API cannot rewrite.
42
67
  *
43
68
  * Modes:
44
69
  * - `observe` — never consumes or rewrites; a pure observer.
@@ -48,8 +73,8 @@ type UnstableRawCaptureMode = 'observe' | 'capture' | 'exclusive';
48
73
  * registration is an explicit error, never a load-order winner.
49
74
  *
50
75
  * Ordering is deterministic: `priority` ASC, then `id` ASC. A throwing
51
- * handler is isolated (health ledger) and FAILS OPEN — the chunk passes
52
- * through, so a broken capture can never stall the TUI.
76
+ * handler is isolated (health ledger) and FAILS OPEN — the sequence
77
+ * passes through, so a broken capture can never stall the TUI.
53
78
  */
54
79
  interface UnstableRawInputSpec {
55
80
  /** Stable diagnostic identity, unique per owner. */
@@ -83,7 +108,9 @@ interface UnstableRawInputHandle {
83
108
  interface UnstableMountedComponent {
84
109
  /** Render the current state as raw terminal lines at the given width. */
85
110
  render(width: number): string[];
86
- /** Receive one raw input chunk while this component owns focus. */
111
+ /** Receive one normalized terminal input sequence while this component
112
+ * owns focus (the same preHostInput contract as
113
+ * {@link UnstableRawInputEvent} — never raw OS bytes). */
87
114
  handleInput?(raw: string): void;
88
115
  /** The component was disposed (mount closed / surface died). */
89
116
  dispose?(): void;
@@ -133,9 +160,10 @@ interface UnstableSurfaceHandle {
133
160
  requestRender(): void;
134
161
  /**
135
162
  * Mount a low-level component (plan §9 option A) as a capturing overlay.
136
- * The plugin renders RAW lines and receives RAW input; the Host owns
137
- * the physical mount, focus, stacking, fullscreen migration and
138
- * teardown. Caller-fiber-owned lease.
163
+ * The plugin renders RAW lines and receives the normalized input
164
+ * sequence (the preHostInput contract — see UnstableRawInputEvent;
165
+ * never raw OS bytes); the Host owns the physical mount, focus,
166
+ * stacking, fullscreen migration and teardown. Caller-fiber-owned lease.
139
167
  */
140
168
  mountComponent(component: UnstableMountedComponent, options?: TuiOverlayOptions): UnstableMountLease;
141
169
  }
@@ -1,3 +1,3 @@
1
+ import { B as inject, H as PI_TUI_EXTENSIONS_SERVICE, U as API_VERSION, V as name, W as describeKey, z as apply } from "./src-zkySYmLZ.mjs";
1
2
  import "./startup.mjs";
2
- import { B as name, H as API_VERSION, R as apply, U as describeKey, V as PI_TUI_EXTENSIONS_SERVICE, z as inject } from "./src-Bk66X6NR.mjs";
3
3
  export { API_VERSION, PI_TUI_EXTENSIONS_SERVICE, apply, describeKey, inject, name };
package/dist/index.d.mts CHANGED
@@ -5,6 +5,7 @@ import { ContentBlock } from "@deepseek-ai/dsh-llm";
5
5
  import { SessionEvent, SessionId } from "@deepseek-ai/dsh-session";
6
6
  import { CommandDescriptor } from "@deepseek-ai/dsh-commands";
7
7
  import { Context } from "@deepseek-ai/cordis";
8
+ import { SessionEvent as SessionEvent$1 } from "@deepseek-ai/dsh-session/types";
8
9
  //#region src/image/admission.d.ts
9
10
  /** Structural subset of `ImageAttachmentRef`. */
10
11
  interface ImageAttachmentRefLike {
@@ -210,6 +211,16 @@ declare const inject: string[];
210
211
  interface Config {
211
212
  /** Resumed session id; a fresh session is created when absent. */
212
213
  sessionId?: string;
214
+ /** Test seam: the pre-mount status output (defaults to process.stdout,
215
+ * TTY-gated). Injectable so the runner tests capture the status writes
216
+ * without patching the global stdout (which would fight the test
217
+ * reporter's own writes). STRUCTURAL on purpose: the public Config type
218
+ * must not reference the internal startup-status module (the public
219
+ * .d.mts leak gate). */
220
+ startupStatusOutput?: {
221
+ readonly isTTY?: boolean;
222
+ write(text: string): unknown;
223
+ };
213
224
  }
214
225
  declare const Config: z<Config>;
215
226
  /**
@@ -467,6 +478,11 @@ interface ResolveInitialCatalogOptions {
467
478
  /** The context surface the collectors read services from. */
468
479
  readonly ctx: SurfaceCatalogContext;
469
480
  readonly diag: Diag;
481
+ /** Suspend the pre-mount startup status before an ordinary log write
482
+ * (the status owns the current terminal line; a TTY shares one cursor
483
+ * between stdout and stderr). Called right before every diag.warn this
484
+ * function may emit. */
485
+ readonly onLog?: () => void;
470
486
  }
471
487
  declare function resolveInitialCatalog(options: ResolveInitialCatalogOptions): Promise<InitialCatalogResolution>;
472
488
  declare function subagentJobTranscriptId(snapshot: unknown): string | undefined;
@@ -635,6 +651,15 @@ declare function settleCompactionSurface(app: CompactionSettleSurface, refreshSt
635
651
  * turn can close (turn/end) before its compaction settles, and the
636
652
  * single-Esc cancel must stay armed until compaction/end. */
637
653
  declare function busyAfterTurnBoundary(eventType: 'turn/start' | 'turn/end', compacting: boolean): boolean;
654
+ /** PR D2 test seam: whether a session event type marks the model-visible
655
+ * context dirty (re-measure through the SessionReader port) or only
656
+ * repaints cheaply (cached measurement). The firehose routes every event
657
+ * through this classification — the single source of truth for the
658
+ * status/measurement split. `compaction/end` is classified 'measure' but
659
+ * the firehose deliberately SKIPS it here: a matched compaction settle
660
+ * re-measures through the fold-outcome path (settleCompactionSurface), so
661
+ * a STALE compaction/end can never trigger a measurement. */
662
+ declare function contextRefreshKind(eventType: string): 'measure' | 'cheap';
638
663
  /**
639
664
  * The in-flight compaction state a resumed session log implies: the newest
640
665
  * compaction bracket decides. A `session/end-seed` boundary makes any
@@ -670,7 +695,10 @@ interface AgentComposition {
670
695
  * A deployment with no roster composes nothing and every session shares the
671
696
  * host composition, which is the behavior before presets existed.
672
697
  * @param ctx - the runner context (services read through `ctx.get`).
673
- * @param selected - the mutable model selection every setup installs.
698
+ * @param installSelection - installs a fresh Agent-local model selection ref
699
+ * during setup. A ModelSelectionRef is still accepted for source
700
+ * compatibility with standalone composition callers; the runner always
701
+ * supplies the Agent-local installer.
674
702
  * @param presetId - the requested preset, or `undefined` for the default.
675
703
  * @param focusState - the shared Focus runtime state (STRUCTURAL on
676
704
  * purpose: the public declaration bundle must not inline src/focus.ts —
@@ -683,13 +711,12 @@ interface AgentComposition {
683
711
  * @returns the id to record on the header (absent without a roster) and the setup callback.
684
712
  * @throws when the roster supplies no such preset.
685
713
  */
686
- declare function composeAgent(ctx: Context, selected: ModelSelectionRef, presetId?: string, focusState?: {
714
+ declare function composeAgent(ctx: Context, installSelection: ((agentCtx: Context) => void) | ModelSelectionRef, presetId?: string, focusState?: {
687
715
  enabled: boolean;
688
716
  }, diag?: Diag): Promise<AgentComposition>;
689
717
  /**
690
- * The preset a persisted session actually runs, from its log (newest
691
- * selection winning), or undefined when persistence is absent, the session is
692
- * unknown, or its log predates the roster.
718
+ * The preset a persisted session actually runs, resolved by the DSH 0.1.2+
719
+ * session projection (header initialization plus the latest selection event).
693
720
  * @param ctx - the runner context.
694
721
  * @param sessionId - the persisted session id.
695
722
  * @returns the recorded preset id, or undefined to compose the default.
@@ -698,7 +725,7 @@ declare function recordedPreset(ctx: Context, sessionId: string): Promise<string
698
725
  /** The session surface {@link recomposeBlank} needs: its log and the append seam. */
699
726
  interface RecomposableSession {
700
727
  readonly id: string;
701
- readonly events: readonly SessionEvent[];
728
+ snapshotEvents(): readonly SessionEvent$1[];
702
729
  append(type: 'agent-preset/selected', data: {
703
730
  agentPreset: string;
704
731
  }): unknown;
@@ -735,4 +762,4 @@ declare function recomposeBlank(ctx: Context, agent: {
735
762
  */
736
763
  declare function apply(ctx: Context, config: Config): void;
737
764
  //#endregion
738
- export { AgentComposition, CompactionFold, CompactionSettleSurface, Config, HOST_COMMAND_CATALOG, InitialCatalogResolution, InterruptAgentLike, InterruptWriterLike, LOCAL_COMMANDS, PendingSubagentCall, QueueFoldResult, QueueInboxMessage, QueueNoticeSource, RecomposableSession, RecomposeOutcome, ResolveInitialCatalogOptions, SESSIONLESS_COMMANDS, SessionLockRefusedError, ViewerOpenToken, apply, busyAfterTurnBoundary, commandRejectsImages, compactingFromLog, composeAgent, createViewerOpenToken, dangerCommand, foldCompactionEvent, foldQueueRows, forkSeed, inject, interruptAgent, isPlainExitPrompt, isSubagentSettlementNotice, isUserQueueInput, matchPendingSubagentCall, name, normalizeSkillInvocation, recomposeBlank, recordedPreset, resolveInitialCatalog, resumeCommand, runningProfile, settleCompactionSurface, shouldConsumeAdvertisedMiss, shouldSteerOnEnter, subagentJobTranscriptId, subagentJobViewHint, subagentNoticeIsFailure, teardownViewerForSessionSwap, viewerActionCapability };
765
+ export { AgentComposition, CompactionFold, CompactionSettleSurface, Config, HOST_COMMAND_CATALOG, InitialCatalogResolution, InterruptAgentLike, InterruptWriterLike, LOCAL_COMMANDS, PendingSubagentCall, QueueFoldResult, QueueInboxMessage, QueueNoticeSource, RecomposableSession, RecomposeOutcome, ResolveInitialCatalogOptions, SESSIONLESS_COMMANDS, SessionLockRefusedError, ViewerOpenToken, apply, busyAfterTurnBoundary, commandRejectsImages, compactingFromLog, composeAgent, contextRefreshKind, createViewerOpenToken, dangerCommand, foldCompactionEvent, foldQueueRows, forkSeed, inject, interruptAgent, isPlainExitPrompt, isSubagentSettlementNotice, isUserQueueInput, matchPendingSubagentCall, name, normalizeSkillInvocation, recomposeBlank, recordedPreset, resolveInitialCatalog, resumeCommand, runningProfile, settleCompactionSurface, shouldConsumeAdvertisedMiss, shouldSteerOnEnter, subagentJobTranscriptId, subagentJobViewHint, subagentNoticeIsFailure, teardownViewerForSessionSwap, viewerActionCapability };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
+ import { A as shouldConsumeAdvertisedMiss, C as normalizeSkillInvocation, D as resumeCommand, E as resolveInitialCatalog, F as teardownViewerForSessionSwap, I as viewerActionCapability, M as subagentJobTranscriptId, N as subagentJobViewHint, O as runningProfile, P as subagentNoticeIsFailure, R as forkSeed, S as name, T as recordedPreset, _ as interruptAgent, a as SessionLockRefusedError, b as isUserQueueInput, c as commandRejectsImages, d as contextRefreshKind, f as createViewerOpenToken, g as inject, h as foldQueueRows, i as SESSIONLESS_COMMANDS, j as shouldSteerOnEnter, k as settleCompactionSurface, l as compactingFromLog, m as foldCompactionEvent, n as HOST_COMMAND_CATALOG, o as apply, p as dangerCommand, r as LOCAL_COMMANDS, s as busyAfterTurnBoundary, t as Config, u as composeAgent, v as isPlainExitPrompt, w as recomposeBlank, x as matchPendingSubagentCall, y as isSubagentSettlementNotice } from "./src-zkySYmLZ.mjs";
1
2
  import "./startup.mjs";
2
- import { A as shouldSteerOnEnter, C as recomposeBlank, D as runningProfile, E as resumeCommand, F as viewerActionCapability, L as forkSeed, M as subagentJobViewHint, N as subagentNoticeIsFailure, O as settleCompactionSurface, P as teardownViewerForSessionSwap, S as normalizeSkillInvocation, T as resolveInitialCatalog, _ as isPlainExitPrompt, a as SessionLockRefusedError, b as matchPendingSubagentCall, c as commandRejectsImages, d as createViewerOpenToken, f as dangerCommand, g as interruptAgent, h as inject, i as SESSIONLESS_COMMANDS, j as subagentJobTranscriptId, k as shouldConsumeAdvertisedMiss, l as compactingFromLog, m as foldQueueRows, n as HOST_COMMAND_CATALOG, o as apply, p as foldCompactionEvent, r as LOCAL_COMMANDS, s as busyAfterTurnBoundary, t as Config, u as composeAgent, v as isSubagentSettlementNotice, w as recordedPreset, x as name, y as isUserQueueInput } from "./src-Bk66X6NR.mjs";
3
- export { Config, HOST_COMMAND_CATALOG, LOCAL_COMMANDS, SESSIONLESS_COMMANDS, SessionLockRefusedError, apply, busyAfterTurnBoundary, commandRejectsImages, compactingFromLog, composeAgent, createViewerOpenToken, dangerCommand, foldCompactionEvent, foldQueueRows, forkSeed, inject, interruptAgent, isPlainExitPrompt, isSubagentSettlementNotice, isUserQueueInput, matchPendingSubagentCall, name, normalizeSkillInvocation, recomposeBlank, recordedPreset, resolveInitialCatalog, resumeCommand, runningProfile, settleCompactionSurface, shouldConsumeAdvertisedMiss, shouldSteerOnEnter, subagentJobTranscriptId, subagentJobViewHint, subagentNoticeIsFailure, teardownViewerForSessionSwap, viewerActionCapability };
3
+ export { Config, HOST_COMMAND_CATALOG, LOCAL_COMMANDS, SESSIONLESS_COMMANDS, SessionLockRefusedError, apply, busyAfterTurnBoundary, commandRejectsImages, compactingFromLog, composeAgent, contextRefreshKind, createViewerOpenToken, dangerCommand, foldCompactionEvent, foldQueueRows, forkSeed, inject, interruptAgent, isPlainExitPrompt, isSubagentSettlementNotice, isUserQueueInput, matchPendingSubagentCall, name, normalizeSkillInvocation, recomposeBlank, recordedPreset, resolveInitialCatalog, resumeCommand, runningProfile, settleCompactionSurface, shouldConsumeAdvertisedMiss, shouldSteerOnEnter, subagentJobTranscriptId, subagentJobViewHint, subagentNoticeIsFailure, teardownViewerForSessionSwap, viewerActionCapability };