import { t as Config } from "./schema-BTGYn8_X.mjs"; import { t as Diag } from "./diagnostics-D5jwc-q1.mjs"; import { H as TuiAction } from "./public-types-C1YgFtwC.mjs"; import { SessionId } from "@deepseek-ai/dsh-session"; import { ContentBlock } from "@deepseek-ai/dsh-llm"; import { Context } from "@deepseek-ai/cordis"; import { Agent } from "@deepseek-ai/dsh-agent"; //#region src/domain/communication/policy.d.ts type ProgressUpdates = 'off' | 'milestones' | 'frequent'; type ResponseStyle = 'default' | 'concise' | 'explanatory'; interface ProgressUpdatesState { mode: ProgressUpdates; } interface ResponseStyleState { style: ResponseStyle; } //#endregion //#region src/domain/catalog/skill.d.ts /** * Neutral skill catalog vocabulary (TS8-E): the human-facing skill summary * shape, the detached catalog (with its completeness flag) and the official * user-invocation policy guard. * * This module is the transport/UI-neutral semantic owner: it consumes only the * official `@deepseek-ai/dsh-skill` policy helper. It never resolves ctx * services, acquires standing scopes, holds revision leases, reads a live * Agent, or imports a Direct/Remote adapter — the structural Direct Host read * lives in `runtime/direct/skill-catalog.ts`. * @module @xmoon76/dsh-pi-tui/domain/catalog/skill */ /** The human-facing slice of one skill: display fields only. */ interface HumanSkillSummary { readonly name: string; readonly description: string; readonly whenToUse?: string; /** Official model-invocation capability; Host-local paths are omitted. */ readonly modelInvocable?: boolean; } /** The detached human skill catalog one observation produced. */ interface HumanSkillCatalog { readonly skills: readonly HumanSkillSummary[]; /** Whether discovery completed within a stable revision (an incomplete * observation must not replace a last-good catalog). */ readonly complete: boolean; } //#endregion //#region src/domain/catalog/surface.d.ts /** Local structural command face, compatible with both npm and Source Mode DSH. * The optional identity is part of the official 0.1.6 descriptor; an older * runtime's descriptor may omit it. */ interface SurfaceCommandDescriptor { readonly definitionId?: string; readonly name: string; readonly description: string; readonly input?: { readonly hint: string; readonly attachments?: boolean; }; } /** One effective command's discovery metadata (the official descriptor's * display fields and optional stable identity; never a handler or definition). */ interface SurfaceCommandSummary { /** Stable plugin-owned identity from the official command descriptor. */ readonly definitionId?: string; readonly name: string; readonly description: string; readonly input?: { readonly hint: string; /** The descriptor's attachment declaration (DSH * `CommandInputDescriptor.attachments`): ONLY a command declaring it may * be invoked with composer attachments (the composer-side half of the * contract — the host executor enforces the other half at admission). */ readonly attachments?: boolean; }; } /** One provider's detached failure text (never the thrown value itself). */ interface SurfaceCatalogIssue { readonly provider: 'commands' | 'skills'; readonly message: string; } /** * The complete frozen catalog view installed before the first input: * - `commands` — the full effective view at read time (diagnostics/tests); * - `scopedCommands` — effective entries absent from, or shadowing, the * read-time global baseline (completion overrides while sessionless); * - `skills` — human-invocable skill summaries (official policy applied); * - `issues` — per-provider failures; an absent service is NOT an issue. */ interface SurfaceCatalogSnapshot { readonly commands: readonly SurfaceCommandSummary[]; readonly scopedCommands: readonly SurfaceCommandSummary[]; readonly skills: readonly HumanSkillSummary[]; readonly issues: readonly SurfaceCatalogIssue[]; } /** The pre-mount catalog resolution result: the resume prefetch snapshot or * the cold standing-scope skill catalog, plus an optional degradation notice. */ interface InitialCatalogResolution { /** The resume prefetch snapshot to install at mount. */ readonly snapshot?: SurfaceCatalogSnapshot; /** The cold standing-scope human skill catalog (deferred start). */ readonly skills?: HumanSkillCatalog; /** A user-facing notice when the prefetch/standing read degraded. */ readonly notice?: string; } //#endregion //#region src/runtime/direct/surface-catalog.d.ts /** Minimal live-agent face consumed by the effective catalog readers — and by * {@link import('../../app/direct/initial-catalog.ts').SurfaceCatalogResolutionOptions}, so the * published option type stays structural instead of inlining the Host Agent. */ interface SurfaceCatalogAgent { readonly ctx: object; readonly session: { readonly header: { readonly cwd?: string; }; }; } /** The commands-service surface the collector reads. */ interface SurfaceCommandsService { list(agent: SurfaceCatalogAgent): readonly SurfaceCommandDescriptor[]; } /** The narrow context surface {@link readSurfaceCatalog} consumes. The * SKILL services are NOT reached here: every dsh skill/agent-presets * access goes through `runtime/direct/skill-catalog.ts` (the single-point * adapter, plan appendix B.1). `workingDirectory` is the official Session * directory owner the skill scan scope resolves from — absent in a minimal * composition, where the immutable header cwd remains the read. */ interface SurfaceCatalogContext { get(name: 'commands'): SurfaceCommandsService | undefined; /** The official Session directory owner (`workingDirectory.get(session)`), * declared STRUCTURALLY here so this public interface never pulls a Direct * adapter module into the shipped declaration graph. */ get(name: 'workingDirectory'): { get(session: unknown): string; } | undefined; } //#endregion //#region src/domain/command/policy.d.ts /** * The transport/UI-neutral command-line policy (plan §27 / TS8-F3): which slash * lines the TUI owns locally, which need no session, which lines are local for * attachment purposes, and the ONE semantic line classification every dispatch * gate consumes. * * Pure and Host-free (structural inputs plus DSH's own `parseCommand`), so the * dispatch gates are testable headless and the presentation/submission paths * share ONE classification. The application/submission-facing half (the * image-rejection gate and the delivery resolver) lives in * `app/submission/command-policy.ts`; the destructive-shell predicate lives in * `domain/shell/danger.ts`. * * The AUTHORITATIVE Host-name fact stays an explicit input * ({@link CommandLineClassificationFacts.hostOriginClaim}); this domain never * derives Host authority from the effective claim union (which also carries the * Client's own TUI registrations). * @module @xmoon76/dsh-pi-tui/domain/command/policy */ /** * Slash commands that need no session: before the first user message * (deferred start) they run locally without creating one. Everything else * dispatches through `commands.execute`, which creates the session lazily * (the command line IS the first user input). Commands in this set must * tolerate `liveAgent === undefined` in their handlers. * * Exported for the headless suite: the gate is exactly where a sessionless * command silently starts creating sessions again. */ declare const SESSIONLESS_COMMANDS: Set; /** * The LOCAL-execute command set (PR5 v2 §1C-6 narrows its semantic role): * TUI-owned UI/control names AND core control names the TUI dispatches but * does not register (/kill). It remains the STATIC policy surface — * reserved-name validation, the extension collision catalog * (HOST_COMMAND_CATALOG), and the fallback term of the line classifier * when no LIVE Client-registry test was supplied. It is NOT by itself an * answer to "who owns this production line": ownership comes from the * live sources (the genuine Host-origin descriptors, the Client registry, * the extension registry, the skill-wrapper state) through * {@link classifyCommandLine}. * * `/kill` is the explicit example of the rule and its DISPOSITION is * deliberate: it has NO live Client registration (and no handler anywhere in * this surface), so it is NOT a TUI-owned line and this set must never be * consulted to decide ownership. What actually happens to a typed `/kill ...` * follows the ordinary precedence, in this order: a genuine Host claim decides * per that descriptor; a genuine Host NAME that resolves while its exact line * is NOT claimed makes the line an ordinary submission; and only a name * nothing owns keeps the command plane's resolution chance (the final, * session-scoped catalog may still provide it). It stays in this set for * reserved-name validation and the extension collision catalog only. */ declare const LOCAL_COMMANDS: Set; /** * The STATIC host-owned command catalog (P1-04): the ownership sets * (LOCAL_COMMANDS and SESSIONLESS_COMMANDS — the TUI's own local/UI command * names, including the ones `registerTuiCommands` registers, plus core * commands such as /kill that the TUI does not register but dispatches * locally) and `/plan`. A plugin command contribution is validated against * this fixed catalog at register time: an exact or near-synonym collision is * rejected loudly, so a plugin can never shadow a built-in command. Names * that only the CURRENT host catalog owns (session-scoped or dynamically * registered commands) are not in this set — those collisions surface at * candidate synthesis time instead. */ declare const HOST_COMMAND_CATALOG: ReadonlySet; /** * The TUI-local classification the attachment gate uses: a TUI/core local * command or a live client command contribution is LOCAL (its line is a UI * control — attachments are refused), while a LIVE skill wrapper is * AGENT-FACING input (multimodal) even when a client contribution shares its * name: the wrapper route outranks the contribution everywhere. * @param name - the slash name. * @param isSkillWrapper - the live skill-wrapper test (absent = none). * @param isDynamicLocal - the live client-contribution test (absent = none). * @param hostResolvesName - whether the AUTHORITATIVE HOST CATALOG resolves * the NAME (PR5 supplement: derived from `hostCatalogResolves`, NEVER from * the effective line claim — the claim-set union also carries this * Client's own TUI registrations, so a self-claim must not disqualify the * TUI's own local commands). A Host-resolved name is never a client-local * line: when the catalog claims the line the host's own * `input.attachments` declaration decides, and when it does not (an argued * line of an execute-kind command) the line is an ordinary submission — * never a same-named client contribution's. */ declare function isLocalCommandLine(name: string, isSkillWrapper: ((name: string) => boolean) | undefined, isDynamicLocal: ((name: string) => boolean) | undefined, hostResolvesName: boolean): boolean; /** * Whether one parsed line is the BARE slash token (DSH `matchEnter`'s `bare`: * no input follows the name — trailing whitespace is not input). It is the * whole difference between a command invocation and an ordinary submission * for the NAME-keyed client routes: a client command contribution claims the * bare token only, exactly like an execute-kind host command. * @param parsed - the parsed slash command. * @returns whether the line carries no input after the command name. */ declare function isBareCommandLine(parsed: { name: string; rawInput?: string; }): boolean; /** * The attachment gate's local-command classification for ONE parsed line — * the SINGLE classification the dispatch and its regression tests share, and * the DSH client namespace order applied to a LINE: * - a TUI/core local command is local; * - `/skill ...` and a LIVE skill wrapper are agent-facing * (multimodal) even when a client contribution shares the name; * - a name the HOST catalog RESOLVES is never local: when the catalog claims * the line, the claiming descriptor's `input.attachments` declaration * decides (`/goal ` is claimed), and when it does not (an argued * line of an execute-kind command, `/compact extra`) the line is an * ordinary submission — never a command and never a same-named client * contribution's; * - everything else follows the live client contribution of that name — for * the BARE token only: a contribution claims `/name`, so an argued line * (`/deploy explain`) is an ordinary multimodal submission that keeps its * attachments. * @param parsed - the parsed slash command (undefined = plain prompt). * @param isSkillWrapper - the live skill-wrapper test (absent = none). * @param isDynamicLocal - the live client-contribution test (absent = none). * @param hostResolvesName - whether the AUTHORITATIVE HOST CATALOG resolves * the name (`hostCatalogResolves` — PR5 supplement: never derived from the * effective line claim, whose union carries the Client's own TUI * registrations). * @returns whether the line is a local command line. */ declare function commandIsLocalForAttachments(parsed: { name: string; rawInput?: string; } | undefined, isSkillWrapper: ((name: string) => boolean) | undefined, isDynamicLocal: ((name: string) => boolean) | undefined, hostResolvesName: boolean): boolean; /** * Normalize an explicit `/skill ` invocation to the skill's * own slash line `/ ` (review finding 2). The harness's * explicit skill gesture scans for `/` — it would extract * `skill` from a raw `/skill grilling ...` line and never inject the * grilling body. The command handler already performs this conversion * (`loadSkill` builds `'/' + skill.name + ' ' + args`); the busy-Enter * steer path must use the SAME normalized line so the body injects and * any image placeholders ride along. * @param text - the submitted line. * @returns the normalized `/ ` line, or undefined when the * line is not an explicit skill invocation (plain prompt, other * commands, or the bare `/skill` picker). */ declare function normalizeSkillInvocation(text: string): string | undefined; /** * The advertised-claim miss decision (pure, exported for the headless * suite): a slash input whose name was advertised by the completion list at * submit time but that the REAL session's catalog lacks is CONSUMED with an * explicit error — never sent to the model as a plain user message. An * unadvertised miss keeps the existing plain-input fallback (the user may * deliberately send slash text to the model). * @param execution - the settled `commands.execute` outcome. * @param wasAdvertised - whether the submission was an advertised command * INVOCATION: the submit-time name claim AND the command plane's final * ownership of the line (an argued line of an execute-kind command never * reached the plane, so it is an ordinary submission). * @returns whether the miss must be consumed as an advertised miss. */ declare function shouldConsumeAdvertisedMiss(execution: { readonly result: unknown; } | undefined, wasAdvertised: boolean): boolean; /** * Whether a plain submitted draft is the quit word: exactly `exit` (trimmed, * lowercase). The runner intercepts this BEFORE any session creation or * submission (shell muscle memory); anything else — `exit!`, `Exit`, or a * draft with a recalled entry still in it — is an ordinary message. * @param text - the submitted draft. */ declare function isPlainExitPrompt(text: string): boolean; //#endregion //#region src/domain/shell/danger.d.ts /** * The destructive-shell predicate the approval dialog uses (kimi-inspired). * Transport/UI-neutral: it answers exactly one question — whether one shell * command matches a known destructive pattern — and owns nothing else. * @module @xmoon76/dsh-pi-tui/domain/shell/danger */ /** * Whether a shell command matches a destructive pattern. `rm` is treated * specially: any spelling of recursive + force flags (`rm -rf`, `rm -r -f`, * `rm -rf /`) is dangerous; the remaining patterns are verbatim matches. */ declare function dangerCommand(command: string): boolean; //#endregion //#region src/domain/media/types.d.ts /** * Neutral media vocabulary shared by Client-local media capability, Direct * application preparation, the transport-neutral prepared prompt and TUI * presentation (TS8-C). * * Every shape here is a DETACHED structural fact — the accepted raster media * types, one durable attachment reference and one deployment's image policy — * that crosses several layers without carrying service, `Context`, `Agent` or * Session authority. They deliberately mirror the `@deepseek-ai/dsh-attachment` * shapes structurally, so no module needs a runtime dependency on that package * (AGENTS.md decision 7). * * Host service interfaces (`saveImages`, `saveFileStream`, `resolveModelInfo`) * MUST NOT enter this module: those are injected at the composition root and * owned by the Direct application preparation. * @module @xmoon76/dsh-pi-tui/domain/media/types */ /** Raster media types accepted by the TUI image intake. */ type ImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif'; /** Structural subset of `ImageAttachmentRef`. */ interface ImageAttachmentRefLike { readonly attachmentId: string; readonly mediaType: ImageMediaType; readonly bytes: number; readonly width: number; readonly height: number; readonly name?: string; /** Input dimensions after EXIF orientation and before normalization * scaling; present only when normalization reduced the image. */ readonly originalDimensions?: { readonly width: number; readonly height: number; }; } //#endregion //#region src/client/media/image/types.d.ts /** Per-TUI draft image identity; only meaningful inside one TUI run. */ type DraftImageId = number; /** Where a staged image's bytes came from. */ type DraftImageSource = { readonly type: 'clipboard'; } | { readonly type: 'path'; readonly path: string; } /** The image was pulled back from a queued message: its bytes are ALREADY * durable with the harness (the recalled ref) — the draft holds no local * copy and re-submitting reuses the ref instead of re-uploading. */ | { readonly type: 'recalled'; }; /** * One image staged in the editor draft. The draft holds the raw bytes so * clipboard and path entries share one shape and a submit never depends on * the source file still existing (plan §5.1). A RECALLED draft (pulled * back from the queue) instead carries the durable `ImageAttachmentRef` * and NO local bytes — the bytes stay in harness storage and re-submitting * reuses the ref. */ interface DraftImage { /** Per-TUI draft identity (the `#N` of the placeholder). */ readonly id: DraftImageId; readonly kind: 'image'; readonly source: DraftImageSource; /** Exact encoded bytes, held only for the draft lifetime. Empty for a * recalled draft (its bytes live in harness storage). */ readonly bytes: Uint8Array; readonly mediaType: ImageMediaType; /** Intrinsic encoded width in pixels. */ readonly width: number; /** Intrinsic encoded height in pixels. */ readonly height: number; /** Exact encoded byte length (`bytes.byteLength` for local drafts; the * durable ref's recorded `bytes` for recalled drafts). */ readonly byteLength: number; /** Optional display name (basename for path sources), never a path. */ readonly name?: string; /** The canonical editor placeholder text for this draft. */ readonly placeholder: string; /** The durable ref this draft reuses on submit; present ONLY for * recalled drafts (already-durable images are never re-uploaded). */ readonly recalledRef?: ImageAttachmentRefLike; } /** The store surface the placeholder expansion needs (structural). */ interface DraftImageStoreLike { values(): readonly DraftImage[]; } //#endregion //#region src/app/surface/compaction-presentation.d.ts /** * The compaction/context presentation module (A4-7, plan §16/§27): the pure * compaction/context presentation folds consumed by the surface routing. * * These are the PURE presentation folds the `session/event` routing applies: * compaction lifecycle pairing, the matched-settle surface effects, the * turn-boundary busy rule, the context re-measure classification, and the * resumed-session-log bootstrap folds (`workingFromLog`, `compactingFromLog`). * They read no Host identity and no persistence, so they are an application-owned * surface presentation module under `app/surface/**` (TS8-F5 moved them out of * the top-level root). * * `src/index.ts` re-exports them unchanged to keep the public entry point * byte-compatible (the published package and the regression suites import them * from the package root). * * @module @xmoon76/dsh-pi-tui/app/surface/compaction-presentation */ /** The canonical compaction phase the mounted surface renders (TS8-F5 moved * the union out of the tui-app.ts stable root; the root type-re-exports it). */ type CompactionPhase = 'idle' | 'summarizing' | 'applying'; /** One fold of a compaction lifecycle event over the in-flight compaction * state. Pure (the routing applies the returned surface effects): * dsh-compaction is not a peer, so the event is read structurally. */ interface CompactionFold { /** The updated in-flight compaction id (the newest start wins). */ id: string | undefined; /** compaction/start: the compacting flag turns ON (footer/working row). */ active: boolean; /** A MATCHED compaction/end: the compacting flag turns OFF and busy is * re-derived from the turn log (a stale end never clears a newer * compaction's state). */ clear: boolean; /** The compaction phase the event implies: compaction/start → * 'summarizing', a MATCHED compaction/summary → 'applying'. Undefined * when the event does not advance the phase (a stale summary, any * compaction/end — the settle clears via {@link clear}). */ phase?: Exclude; /** The settle notification for compaction/end, when one fires. */ notify: { text: string; kind: 'info' | 'error'; } | undefined; } /** Fold one compaction lifecycle event over the in-flight state. */ declare function foldCompactionEvent(state: { id: string | undefined; }, event: { type: string; data: { compactionId?: unknown; error?: unknown; }; }): CompactionFold; /** The minimal compaction-settle surface the routing passes in — STRUCTURAL * on purpose: referencing the full {@link TuiApp} class from a public * export would inline the whole surface (and its internal registry/ * presentation dependencies) into the published declaration bundle. The * settle contract needs the three phase/busy/working setters; PR3-A keeps * this PUBLIC shape unchanged (it is re-exported from the package entry) * and adapts it internally onto the display seam's aggregated commit. */ interface CompactionSettleSurface { setCompactionPhase(phase: 'idle'): void; setBusy(busy: boolean): void; setWorking(busy: boolean): void; } /** The UI side effects of a MATCHED compaction settle: clear the phase, * hand the working row back to the turn state, and re-measure the session * surface so the footer context reflects the compacted log IMMEDIATELY — * the next step/start or turn/end would otherwise delay the refresh. * Exported as a seam so the settle contract is testable without a full * runner driver (the firehose closure is not). */ declare function settleCompactionSurface(app: CompactionSettleSurface, refreshStatus: () => void, busyNow: boolean): void; /** The busy flag after a turn-boundary event: a turn end must NOT clear * the busy state while a compaction is still in flight — an interrupted * turn can close (turn/end) before its compaction settles, and the * single-Esc cancel must stay armed until compaction/end. */ declare function busyAfterTurnBoundary(eventType: 'turn/start' | 'turn/end', compacting: boolean): boolean; /** PR D2 test seam: whether a session event type marks the model-visible * context dirty (re-measure through the SessionReader port) or only * repaints cheaply (cached measurement). The firehose routes every event * through this classification — the single source of truth for the * status/measurement split. `compaction/end` is classified 'measure' but * the firehose deliberately SKIPS it here: a matched compaction settle * re-measures through the fold-outcome path (settleCompactionSurface), so * a STALE compaction/end can never trigger a measurement. */ declare function contextRefreshKind(eventType: string): 'measure' | 'cheap'; declare function compactingFromLog(events: readonly { type: unknown; data?: unknown; }[]): { active: boolean; id: string | undefined; }; //#endregion //#region src/app/submission/pending-input.d.ts /** One semantic pending-input item as the queue mirror sees it. */ interface QueueInboxMessage { readonly id: string; readonly content: readonly ContentBlock[]; } //#endregion //#region src/app/surface/pending-presentation.d.ts /** One semantic queued pending-input row for the queue pane. */ interface QueueItem { /** The pending message id (agent inbox identity), or a local request id. */ id: string; /** The message text, single-line display form. */ text: string; /** next-turn followup vs next-step steer. */ mode: 'followup' | 'steer'; /** The correlation identity (authoritative rpc id or local request id). */ rpcId?: string; /** A client-local echo not yet backed by an authoritative occurrence. */ local?: boolean; } /** The queue-pane rows for one semantic pending-input batch. */ interface QueueFoldResult { readonly rows: QueueItem[]; } /** Build queue-pane rows from semantic pending-input occurrences, preserving * their order and content without inspecting backend-specific metadata. */ declare function foldQueueRows(messages: readonly QueueInboxMessage[], mode: 'followup' | 'steer'): QueueFoldResult; //#endregion //#region src/app/surface/task-presentation.d.ts declare function subagentJobTranscriptId(snapshot: unknown): string | undefined; /** * The Task Center row-selection disposition (plan §4.3/§4.4). A subagent * transcript opens a session/viewer surface that REPLACES the browser; a * Job row's detail keeps it mounted (the caller passes {@link openJobView}'s * disposition). An UNKNOWN row — a stale panel selection after a live * re-projection — also keeps the parent usable instead of dismissing it. */ declare function taskRowSelectionDisposition(row: { readonly kind: 'job' | 'subagent'; } | undefined, jobDetail: 'close' | 'keep-open'): 'close' | 'keep-open'; /** Viewer body for a subagent job with no uniquely matched child. */ declare function subagentJobViewHint(status: string, detail: string | undefined): string; //#endregion //#region src/app/session/interrupt.d.ts /** * The public live-turn interrupt helper (web Stop parity): abort the current * turn/tool run while PRESERVING the pending queue. Kept out of the * composition root so the rule is testable headless, and its structural * faces keep the internal runtime port module out of the published entry. * * This is the PUBLIC, session-id-addressed writer convenience. The TUI's own * Busy Esc / extension `cancel-activity` path does NOT use it: that path goes * through `SessionRuntime.interrupt`, which addresses the EXACT captured owner * generation under the session control admission (so a navigation transition * that froze the ordinary writers cannot refuse it, and a same-id owner * rollover cannot receive the wrong generation's cancel). * @module @xmoon76/dsh-pi-tui/app/session/interrupt */ /** Public settlement shape for the interrupt helper. Kept local so the * entry-point declaration does not expose the internal runtime port module. */ type InterruptWriteOutcome = { readonly kind: 'committed'; readonly value: undefined; } | { readonly kind: 'rejected'; readonly error: { readonly code: string; readonly message: string; readonly details?: Readonly>; }; } | { readonly kind: 'cancelled'; } | { readonly kind: 'indeterminate'; readonly error: { readonly code: string; readonly message: string; readonly details?: Readonly>; }; } | { readonly kind: 'unsupported'; readonly reason: string; }; /** The live-agent surface {@link interruptAgent} needs (structural — the * TUI never imports the agent runtime for this call). */ interface InterruptAgentLike { readonly session: { readonly id: string; }; readonly status: string; cancel(cause: { kind: 'user'; }, options?: { keepInbox?: boolean; }): void; } /** The writer surface {@link interruptAgent} needs (structural — a LOCAL * type so the public declaration never inlines internal runtime modules; * the runner's SessionWriter satisfies it). */ interface InterruptWriterLike { cancel(sessionId: string): Promise; } /** * Interrupt the live agent (web Stop parity): abort the current * turn/tool run while PRESERVING the pending queue. dsh's DEFAULT * `cancel()` clears queued AND steering input, so a bare cancel would * destroy everything the user queued with Ctrl+S / queue-mode Enter — * the Esc-interrupt semantic is "stop the current thinking", never * "drop the queue". `keepInbox: true` parks the preserved work; dsh's * cancel is a documented no-op when nothing is active, so an idle * interrupt (double-Esc while idle) is harmless and still aborts a * local shell / maintenance task through the caller. * * NOTE (upstream dependency): dsh currently PARKS the preserved queue * after an abort — the "Esc with a queue continues immediately" UX * needs an upstream `wakePending`/`continueInbox` capability (not yet * in dsh). A TUI-side emulation (remove + re-send a queue message) * would fabricate durable discarded/inserted events in the session * log, which the design explicitly rejects — the parked queue is the * agreed web-parity behavior until upstream lands the capability. */ declare function interruptAgent(agent: InterruptAgentLike | undefined, writer: InterruptWriterLike): Promise; //#endregion //#region src/tui-app.d.ts /** * The WEB composer submit gestures (DSH `ComposerSubmitGesture`): plain * Enter, or the Cmd/Ctrl-accelerated chord. The busy-Enter policy resolves * each to a delivery mode — plain Enter to the preferred mode, the * accelerated chord to its OPPOSITE — so the chord is never a fixed mode. */ type ComposerSubmitGesture = 'enter' | 'accelerated'; //#endregion //#region src/commands.d.ts /** * The effective mode ONE submission resolved at the submit boundary: whether * an agent-facing delivery steers into the running turn or queues behind it * (web `ComposerSubmissionPolicy` parity — an idle agent queues, plain Enter * takes the preference, and the accelerated chord takes its OPPOSITE). * * It is a property of the GESTURE, not of the persisted settings: a one-shot * gesture exists only inside the dispatch that resolved it, so every * downstream consumer (the TUI skill delivery) accepts this value instead of * re-deriving the mode from `busyEnter`. */ type SubmitDelivery = 'steer' | 'queue'; //#endregion //#region src/app/submission/command-policy.d.ts /** * Command semantics matrix (plan §19.3/M12): a LOCAL command line carrying a * staged image placeholder is REJECTED — local commands are pure UI * controls, never LLM prompts. AGENT-FACING input (plain prompts AND * per-skill slash invocations like `/grilling`) SUPPORTS images: the skill * wrapper builds its message through the same prepared-input path, so an * image-bearing skill line is a real multimodal prompt (review finding 4). * There is never a silent drop. * @param parsed - the parsed slash command, undefined for a plain prompt. * @param text - the submission text. * @param store - the live draft store. * @param isLocal - whether THIS LINE is a LOCAL (TUI-owned/UI) command; skill * names answer false. Never derived from the name alone: a host command's * input KIND decides which line it claims (see * {@link commandIsLocalForAttachments}). */ declare function commandRejectsImages(parsed: { name: string; rawInput?: string; } | undefined, text: string, store: DraftImageStoreLike, isLocal: boolean): boolean; /** * The TUI dispatch boundary's delivery resolution: the WEB composer policy * ({@link resolveComposerDelivery}) applied to agent-facing input, with the * TUI's own ownership terms on top. Pure so the dispatch gate (inside the * runner closure) is testable headless. * @param parsed - the parsed slash command, undefined for a plain prompt. * @param running - whether the live agent reports running. * @param gesture - the composer gesture that raised the submission. * @param busyEnter - the persisted preference value (''/undefined = queue). * @param isTuiLocalLine - whether the line is a TUI-LOCAL command line by * the §D3 line authority ({@link isLocalCommandLine}'s order: a * HOST-RESOLVED name — claimed or merely resolved — is never local). The * caller derives it once and shares it with every gate, so an argued * `/export foo` of an execute-kind Host command follows the ORDINARY * queue/steer busy policy instead of a local-command placeholder. * Absent = fall back to the legacy LOCAL_COMMANDS set (callers that have * no host view yet, e.g. the pre-parse echo path). */ declare function resolveSubmitDelivery(parsed: { name: string; rawInput?: string; } | undefined, running: boolean, gesture: ComposerSubmitGesture, busyEnter: string | undefined, isTuiLocalLine?: boolean): SubmitDelivery; //#endregion //#region src/app/surface/viewer-policy.d.ts /** One unsettled subagent delegation, in tool/call order. */ interface PendingSubagentCall { readonly callId: string; readonly description: string; } /** * The async viewer-OPEN invalidation token (pure, exported for the headless * suite — the runner closure itself is not drivable in the headless tests, * so the lifecycle rule is tested through these token semantics). An open * request captures a token; EVERY viewer session change — opening another * child, leaving the viewer (Esc), or a session swap (which routes through * exitView) — invalidates the token, so a slow transcript inspection can * never commit an obsolete child over the current surface. Invalidation is * unconditional: an exit that finds NO mounted viewer still invalidates, * because the open is exactly then still in flight (round-5 finding). */ interface ViewerOpenToken { /** The current token value (bumped by every open and every invalidate). */ readonly current: number; /** Start one async open; returns the request's token. */ open(): number; /** Invalidate every in-flight open (a viewer session change). */ invalidate(): void; /** Whether a request may still commit. */ isCurrent(request: number): boolean; } declare function createViewerOpenToken(): ViewerOpenToken; /** * Session-swap viewer teardown (pure, exported for the headless suite — * the runner closure is not headless-drivable, so the rule is pinned * through this seam). A session swap must do BOTH: invalidate any * in-flight viewer OPEN — UNCONDITIONALLY, because the open may still be * loading when nothing is mounted yet, and the swap must still cancel it * (round-6 finding) — and close a MOUNTED viewer when there is one. * @param token - the shared viewer-open token. * @param mounted - whether a viewer is currently mounted. * @param closeMounted - closes the mounted viewer (a no-op when unmounted). * @returns whether a mounted viewer was closed. */ declare function teardownViewerForSessionSwap(token: ViewerOpenToken, mounted: boolean, closeMounted: () => void): boolean; /** * The viewer capability gate for SEMANTIC plugin actions (pure, exported * for the headless suite — the runner closure is not drivable there). * While a subagent viewer is open, only actions that stay CHILD- or * SURFACE-local are allowed; every action with PARENT-session side * effects (steer, cancel/interrupt, permission cycling, the main * transcript search) is blocked, so a plugin keybinding can never * interrupt/steer/reconfigure the parent from inside the viewer. The * raw-key viewer guard already consumes the parent chords — this gate * closes the plugin-keybinding path, the only other way a semantic * action reaches the runner. * @param action - the semantic action the plugin requested. * @param viewer - the open viewer (mode), or undefined when no viewer. * @returns whether the runner may execute the action. */ declare function viewerActionCapability(action: TuiAction, viewer: { mode: 'one-shot' | 'continuable'; } | undefined): boolean; /** * Match the child a user is about to view against the unsettled subagent * calls (pure, exported for the headless suite). The child's durable label * is the delegation's `description`; duplicate descriptions take the MOST * RECENT call (the one the user is most likely watching), an empty/absent * label falls back to a LONE pending call, and no match disables the * auto-pop (the user exits the viewer with Esc as before — never a wrong * pop). Mutates `pending` by removing the matched call. * @param pending - the unsettled calls, in order (oldest first). * @param label - the child's durable label; '' or undefined = no description. * @returns the matched call, or undefined when nothing matches. */ declare function matchPendingSubagentCall(pending: PendingSubagentCall[], label: string | undefined): PendingSubagentCall | undefined; //#endregion //#region src/client/launcher/profile.d.ts /** * The Client-local DSH launcher PROFILE reads: the `--profile` argv scrape and * the interactive-quit resume hint. * * Deliberately NOT part of `src/startup.ts`: the startup row is a * zero-dependency island that must not share a bundle chunk with the runner, * so these runner-side helpers live in their own module. The authoritative * Host profile identity (`hostRunningProfile`) is application bootstrap * ownership (`app/bootstrap/profile.ts`) and consumes this argv fallback. * @module @xmoon76/dsh-pi-tui/client/launcher/profile */ /** * The dsh profile named by the `--profile` flag in `argv`, in both spellings. * This is the ARGV-ONLY fallback: it cannot see the positional `dsh ` * launch form, because the launcher consumes that bare name by synthesizing * `['--profile', ...argv]` for its OWN commander parse and leaves * `process.argv` untouched. Prefer `hostRunningProfile`, which reads the Host's * profile identity instead of scraping the command line. * @param argv - the process argument vector. * @param fallback - the default profile. */ declare function runningProfile(argv?: readonly string[], fallback?: string): string; /** * The interactive-quit resume hint (pi parity): `dsh --profile

* --session `, printed after the terminal restores so the user can * re-enter the session later. Returns undefined when there is no session * to resume (deferred start never created one). * @param profile - the running profile (`hostRunningProfile`). * @param sessionId - the live session id. * @returns the resume command line, or undefined without a session. */ declare function resumeCommand(profile: string, sessionId: string): string | undefined; //#endregion //#region src/app/bootstrap/profile.d.ts /** * The authoritative running-profile read for this process — the official Host * `profileContext.name` when it is composed, else the Client-local argv scrape * (`client/launcher/profile.ts`). * * `profileContext.name` is the launcher's own profile identity, so it is * correct for EVERY launch form: `--profile `, `--profile=`, the * positional `dsh `, and `--from-default-profile `. The argv scrape * only knows the flag form, which is why it is the fallback for a profile-less * mount (tests, an embedded surface) rather than the primary source. Bootstrap * composition ownership: it reads one Host context service and nothing else. * @module @xmoon76/dsh-pi-tui/app/bootstrap/profile */ /** The one context read {@link hostRunningProfile} needs (a cordis Context satisfies it). */ interface ProfileContextReadLike { get(name: string): unknown; } /** * The profile this process actually runs. * @param ctx - the plugin context (or any structural `get`-only stand-in). * @param argv - the process argument vector for the fallback path. * @param fallback - the default profile for the fallback path. * @returns the running profile name. */ declare function hostRunningProfile(ctx: ProfileContextReadLike, argv?: readonly string[], fallback?: string): string; //#endregion //#region src/index.d.ts /** Stable Cordis plugin name. */ declare const name = "tui-runner"; /** Core services required before the TUI can mount. `piTuiPreferences` is the * canonical profile-owned preference authority: the TUI must not start from a * missing/default schema while the real user document has not settled. */ declare const inject: string[]; /** * Options for {@link resolveInitialCatalog}. * * The public declaration stays here (A5a review P1): `liveAgent` keeps the Host * `Agent` type it has always had, so consumers that READ the property keep * compiling. The implementation consumes the structural * `SurfaceCatalogResolutionOptions` in `app/direct/initial-catalog.ts`. */ interface ResolveInitialCatalogOptions { /** The resumed live agent, if any (prefetch path). */ readonly liveAgent?: Agent; /** The effective preset id for the cold standing read (undefined = the * deployment default; only consulted for the deferred start). */ readonly presetId?: string; readonly signal: AbortSignal; /** The context surface the collectors read services from. */ readonly ctx: SurfaceCatalogContext; readonly diag: Diag; /** Suspend the pre-mount startup status before an ordinary log write * (the status owns the current terminal line; a TTY shares one cursor * between stdout and stderr). Called right before every diag.warn this * function may emit. */ readonly onLog?: () => void; } /** * The pre-mount surface catalog resolution (plan §27): the published entry for * {@link ResolveInitialCatalogOptions}. An explicit `--session` start * prefetches the resumed agent's effective catalog; the deferred start reads the * cold HUMAN SKILL catalog through the preset's STANDING SCOPE — no Agent, no * session, no turn — so the first input sees human-invocable skills without any * durable side effect. The implementation and its pre-mount failure taxonomy * live in `app/direct/initial-catalog.ts`. * @param options - injected dependencies (see {@link ResolveInitialCatalogOptions}). * @returns the snapshot / skill catalog to install and an optional notice. */ declare function resolveInitialCatalog(options: ResolveInitialCatalogOptions): Promise; /** * The PUBLIC structural shape of the shared mutable display authority. The * canonical owner is `src/domain/display/preset.ts` (`DisplayState`); the * published `composeAgent` signature stays STRUCTURAL so the internal source * path never leaks into the declaration bundle (TS8-D). */ type DisplayState = { preset: 'focus' | 'compact' | 'full'; }; /** One agent's preset composition: the id to record and the setup that installs it. */ interface AgentComposition { /** Preset id for the session header, absent when the deployment composes no roster. */ agentPreset?: string; /** Agent-factory setup: model selection, then the preset mount when composed. */ setup: (agentCtx: Context, agent: Agent) => Promise | void; } /** * Resolve the preset an agent will be composed from, and the setup that * installs it. * * The id is resolved BEFORE the session exists because the session boundary * snapshots `meta` before asynchronous setup begins — a preset discovered * during setup could never reach the header. Mounting still happens in setup, * where a failure rolls the whole creation back rather than leaving a * published session whose capabilities are half-installed. * * A deployment with no roster composes nothing and every session shares the * host composition, which is the behavior before presets existed. * @param ctx - the runner context (services read through `ctx.get`). * @param installSelection - installs the Agent-scoped runtime contributions * during setup using the explicit Agent identity supplied by DSH. DSH 0.2.2 * owns model selection inside the Agent (`AgentModel` + the `modelSelection` * projection), so there is no caller-owned selection ref to install. * @param presetId - the requested preset, or `undefined` for the default. * @param displayState - the shared canonical DisplayState. When provided, the * setup also installs the dynamic Focus system-prompt * section exactly once per composed agent (plan §9 — every composed * root TUI agent gets it; /focus toggles never re-register). * @param diag - the diagnostics channel, when the caller has one. * @param progressUpdatesState - optional live mid-turn update cadence. The * effective text is derived from this state AND `displayState` (Focus * suppresses the progress section without mutating this state), so a * progress state without a display state is not installable. * @param responseStyleState - optional live visible-answer style guidance, * independent of display. * @returns the id to record on the header (absent without a roster) and the setup callback. * @throws when the roster supplies no such preset. */ declare function composeAgent(ctx: Context, installSelection: (agentCtx: Context, agent: Agent) => void, presetId?: string, displayState?: DisplayState, diag?: Diag, progressUpdatesState?: ProgressUpdatesState, responseStyleState?: ResponseStyleState): Promise; /** * The preset a persisted session actually runs, read from the DSH 0.1.6 V3 * session projection (header initialization plus the latest selection event). * @param ctx - the runner context. * @param sessionId - the persisted session id. * @returns the recorded preset id, or undefined to compose the default. */ declare function recordedPreset(ctx: Context, sessionId: string): Promise; /** * Mount the TUI: resolve the model selection, create or resume the agent, * wire the surface to the agent, and subscribe to the session firehose. * @param ctx - plugin context carrying core services. * @param config - validated config with the optional resumed session id. */ declare function apply(ctx: Context, config: Config): void; //#endregion export { AgentComposition, type CompactionFold, type CompactionSettleSurface, Config, HOST_COMMAND_CATALOG, type InitialCatalogResolution, type InterruptAgentLike, type InterruptWriteOutcome, type InterruptWriterLike, LOCAL_COMMANDS, type PendingSubagentCall, type ProfileContextReadLike, type QueueFoldResult, type QueueInboxMessage, ResolveInitialCatalogOptions, SESSIONLESS_COMMANDS, type ViewerOpenToken, apply, busyAfterTurnBoundary, commandIsLocalForAttachments, commandRejectsImages, compactingFromLog, composeAgent, contextRefreshKind, createViewerOpenToken, dangerCommand, foldCompactionEvent, foldQueueRows, hostRunningProfile, inject, interruptAgent, isBareCommandLine, isLocalCommandLine, isPlainExitPrompt, matchPendingSubagentCall, name, normalizeSkillInvocation, recordedPreset, resolveInitialCatalog, resolveSubmitDelivery, resumeCommand, runningProfile, settleCompactionSurface, shouldConsumeAdvertisedMiss, subagentJobTranscriptId, subagentJobViewHint, taskRowSelectionDisposition, teardownViewerForSessionSwap, viewerActionCapability };