dsh-code 1.3.0 → 1.5.0

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 (103) hide show
  1. package/README.en.md +10 -8
  2. package/README.md +10 -8
  3. package/lib/index.mjs +6980 -5942
  4. package/lib/session-query.mjs +18 -1
  5. package/lib/types/app.d.ts +38 -65
  6. package/lib/types/completion.d.ts +29 -0
  7. package/lib/types/composer.d.ts +150 -0
  8. package/lib/types/git-workflow.d.ts +6 -0
  9. package/lib/types/index.d.ts +6 -188
  10. package/lib/types/locales/en.d.ts +20 -8
  11. package/lib/types/{authorization-panel.d.ts → panels/authorization-panel.d.ts} +6 -1
  12. package/lib/types/panels/completion-panel.d.ts +13 -0
  13. package/lib/types/panels/interaction-bars.d.ts +38 -0
  14. package/lib/types/{kernel-panels.d.ts → panels/kernel-panels.d.ts} +16 -37
  15. package/lib/types/{language-panel.d.ts → panels/language-panel.d.ts} +1 -1
  16. package/lib/types/panels/model-panels.d.ts +86 -0
  17. package/lib/types/{theme-panel.d.ts → panels/theme-panel.d.ts} +1 -1
  18. package/lib/types/{update-panel.d.ts → panels/update-panel.d.ts} +1 -1
  19. package/lib/types/provider-settings.d.ts +11 -0
  20. package/lib/types/render/inspector.d.ts +16 -0
  21. package/lib/types/render/projection-events.d.ts +33 -0
  22. package/lib/types/render/text.d.ts +4 -0
  23. package/lib/types/render/transcript-viewport.d.ts +32 -0
  24. package/lib/types/runner/harness-gate.d.ts +83 -0
  25. package/lib/types/runner/input-history.d.ts +31 -0
  26. package/lib/types/runner/mode-cycle.d.ts +44 -0
  27. package/lib/types/runner/preferences.d.ts +40 -0
  28. package/lib/types/runner/quit.d.ts +27 -0
  29. package/lib/types/runner/search-rows.d.ts +38 -0
  30. package/lib/types/runner/session-io.d.ts +57 -0
  31. package/lib/types/runner/session-target.d.ts +42 -0
  32. package/lib/types/runner/startup-config.d.ts +33 -0
  33. package/lib/types/runner/submissions.d.ts +87 -0
  34. package/lib/types/session/attach.d.ts +39 -0
  35. package/lib/types/{store.d.ts → session/store.d.ts} +1 -1
  36. package/lib/types/{subagents.d.ts → session/subagents.d.ts} +8 -1
  37. package/lib/types/session-query.d.ts +11 -0
  38. package/lib/types/settings-file.d.ts +10 -0
  39. package/lib/types/{panel-accent.d.ts → ui/panel-accent.d.ts} +1 -1
  40. package/lib/types/ui/panel-gap.d.ts +6 -0
  41. package/lib/types/ui/query-editor.d.ts +10 -0
  42. package/lib/types/ui/styled-rows.d.ts +8 -0
  43. package/lib/types/{terminal-title.d.ts → ui/terminal-title.d.ts} +1 -1
  44. package/lib/types/ui/ui-contract.d.ts +12 -0
  45. package/lib/types/ui/use-frames.d.ts +6 -0
  46. package/lib/types/ui/use-stable-input.d.ts +7 -0
  47. package/package.json +3 -2
  48. package/src/app.ts +802 -4162
  49. package/src/completion.ts +117 -0
  50. package/src/composer.ts +1956 -0
  51. package/src/git-workflow.ts +18 -0
  52. package/src/index.ts +113 -633
  53. package/src/internals.ts +1 -1
  54. package/src/locales/en.ts +20 -8
  55. package/src/locales/zh.ts +20 -8
  56. package/src/{authorization-panel.ts → panels/authorization-panel.ts} +25 -6
  57. package/src/panels/completion-panel.ts +79 -0
  58. package/src/panels/interaction-bars.ts +567 -0
  59. package/src/{kernel-panels.ts → panels/kernel-panels.ts} +84 -65
  60. package/src/{language-panel.ts → panels/language-panel.ts} +4 -4
  61. package/src/panels/model-panels.ts +1021 -0
  62. package/src/{theme-panel.ts → panels/theme-panel.ts} +5 -5
  63. package/src/{update-panel.ts → panels/update-panel.ts} +6 -6
  64. package/src/provider-settings.ts +38 -0
  65. package/src/render/inspector.ts +35 -0
  66. package/src/render/lines.ts +45 -18
  67. package/src/render/projection-events.ts +109 -0
  68. package/src/render/projection.ts +11 -2
  69. package/src/render/text.ts +8 -0
  70. package/src/render/tool-preview.ts +35 -2
  71. package/src/render/transcript-viewport.ts +61 -0
  72. package/src/render/usage.ts +1 -2
  73. package/src/runner/harness-gate.ts +168 -0
  74. package/src/runner/input-history.ts +77 -0
  75. package/src/runner/mode-cycle.ts +49 -0
  76. package/src/runner/preferences.ts +67 -0
  77. package/src/runner/quit.ts +53 -0
  78. package/src/runner/search-rows.ts +55 -0
  79. package/src/runner/session-io.ts +245 -0
  80. package/src/runner/session-target.ts +81 -0
  81. package/src/runner/startup-config.ts +54 -0
  82. package/src/runner/submissions.ts +157 -0
  83. package/src/session/attach.ts +87 -0
  84. package/src/{session-directory.ts → session/session-directory.ts} +1 -1
  85. package/src/{store.ts → session/store.ts} +1 -1
  86. package/src/{subagents.ts → session/subagents.ts} +12 -1
  87. package/src/session-query.ts +22 -0
  88. package/src/settings-file.ts +19 -1
  89. package/src/{panel-accent.ts → ui/panel-accent.ts} +1 -1
  90. package/src/ui/panel-gap.ts +9 -0
  91. package/src/ui/query-editor.ts +16 -0
  92. package/src/ui/styled-rows.ts +124 -0
  93. package/src/{terminal-title.ts → ui/terminal-title.ts} +1 -1
  94. package/src/ui/ui-contract.ts +10 -0
  95. package/src/ui/use-frames.ts +23 -0
  96. package/src/ui/use-stable-input.ts +17 -0
  97. /package/lib/types/{fork.d.ts → session/fork.d.ts} +0 -0
  98. /package/lib/types/{history.d.ts → session/history.d.ts} +0 -0
  99. /package/lib/types/{session-directory.d.ts → session/session-directory.d.ts} +0 -0
  100. /package/lib/types/{session-switch.d.ts → session/session-switch.d.ts} +0 -0
  101. /package/src/{fork.ts → session/fork.ts} +0 -0
  102. /package/src/{history.ts → session/history.ts} +0 -0
  103. /package/src/{session-switch.ts → session/session-switch.ts} +0 -0
@@ -0,0 +1,44 @@
1
+ /** Shift+Tab mode-cycle stations for the terminal runner.
2
+ *
3
+ * Pure decision over the preset table and the committed plan fold: the runner
4
+ * applies the returned station, so the whole cycle is testable without a
5
+ * session.
6
+ *
7
+ * @module @deepseek-ai/dsh-code/mode-cycle
8
+ */
9
+ /** One Shift+Tab station decision for the mode cycle. */
10
+ export type ModeCycleDecision = {
11
+ readonly kind: 'permission';
12
+ readonly preset: string;
13
+ } | {
14
+ readonly kind: 'plan-on';
15
+ } | {
16
+ readonly kind: 'plan-off';
17
+ readonly preset: string;
18
+ };
19
+ /**
20
+ * Decide the next Shift+Tab station. The cycle keeps the preset table's
21
+ * own order (most restrictive first) and inserts ONE plan station between
22
+ * the most restrictive preset and the wrap target: with the shipped three
23
+ * presets the user sees workspace-write → danger-full-access → read-only
24
+ * → plan → workspace-write. Plan IS the most restrictive preset plus the
25
+ * plan prompt layer — entering it switches nothing (the cycle is already
26
+ * parked on read-only), and leaving it lands on the next preset after the
27
+ * most restrictive one. Without the /plan command the cycle is exactly the
28
+ * preset table.
29
+ *
30
+ * `planIntent` covers the committed fold's commit lag: upstream queues a
31
+ * plan switch during an open turn (and the command pipeline is async even
32
+ * idle), so the durable plan/mode event lands AFTER the press that chose
33
+ * it. While an intent from an earlier press is in flight it — not the
34
+ * stale committed fold — decides the station, so repeated presses advance
35
+ * the cycle instead of re-issuing the same plan transition (the stuck
36
+ * plan-on/plan-off toggle). Undefined falls back to the committed fold.
37
+ */
38
+ export declare function planCycleDecision(input: {
39
+ readonly names: readonly string[];
40
+ readonly current: string;
41
+ readonly inPlan: boolean;
42
+ readonly planAvailable: boolean;
43
+ readonly planIntent?: boolean;
44
+ }): ModeCycleDecision | undefined;
@@ -0,0 +1,40 @@
1
+ /** User-level preference files under the DSH home.
2
+ *
3
+ * The statusline, theme, language, and animations customizations each live in
4
+ * one small JSON file. They share exactly two policies: a missing file is the
5
+ * default and stays silent while a corrupt one degrades to the default with a
6
+ * surfaced warning (a user-authored customization must never fail silently),
7
+ * and every save goes through the serialized crash-atomic writer.
8
+ *
9
+ * @module @deepseek-ai/dsh-code/preferences
10
+ */
11
+ import { type UserSettingsPersistence } from '../settings-file.ts';
12
+ /** Absolute path of one preference file under the DSH home. */
13
+ export declare function preferencePath(fileName: string): string;
14
+ /** Outcome of reading one preference file. */
15
+ export interface PreferenceRead<T> {
16
+ /** Parsed value; undefined when the file is missing or corrupt (keep the default). */
17
+ readonly value?: T;
18
+ /** Corruption message to surface; undefined for a missing or clean file. */
19
+ readonly warning?: string;
20
+ }
21
+ /**
22
+ * Read one field of a preference file. A missing file is silence — the default
23
+ * stands and nothing is reported — while unreadable JSON or a non-object
24
+ * document both warn and keep the default.
25
+ * @param path - absolute path of the preference file.
26
+ * @param field - the JSON field the file carries.
27
+ * @param parse - narrows the raw field to the usable value.
28
+ * @returns the parsed value and/or the warning to surface.
29
+ */
30
+ export declare function readPreference<T>(path: string, field: string, parse: (raw: unknown) => T): PreferenceRead<T>;
31
+ /**
32
+ * Persist one preference field through the serialized crash-atomic writer.
33
+ * A failed write is reported through `onFailure` instead of rejecting.
34
+ * @param persistence - the shared user-settings writer.
35
+ * @param path - absolute path of the preference file.
36
+ * @param field - the JSON field the file carries.
37
+ * @param value - the value to store under `field`.
38
+ * @param onFailure - receives the failure message for a bounded notice.
39
+ */
40
+ export declare function savePreference(persistence: UserSettingsPersistence, path: string, field: string, value: unknown, onFailure: (message: string) => void): void;
@@ -0,0 +1,27 @@
1
+ /** Ordered terminal quit cleanup.
2
+ *
3
+ * Pure sequencing: every step rejection is contained and the exit request is
4
+ * always reached exactly once, so a failing flush never strands the process.
5
+ *
6
+ * @module @deepseek-ai/dsh-code/quit
7
+ */
8
+ /** One ordered step of the terminal quit cleanup. */
9
+ export interface QuitCleanupStep {
10
+ /** Step label used in diagnostics and tests. */
11
+ readonly name: string;
12
+ /** The step's async work; a rejection is contained by the sequence. */
13
+ readonly run: () => Promise<void>;
14
+ }
15
+ /**
16
+ * Run the ordered quit cleanup, then request exit. Every step rejection is
17
+ * contained (reported through `onError`) so a failed flush or dispose never
18
+ * skips the remaining cleanup; the exit request is always reached exactly
19
+ * once.
20
+ * @param steps - the cleanup steps in dependency order (settle the visible
21
+ * session, await the final in-flight composition, await durable recall).
22
+ * @param exit - the terminal exit request (code 0).
23
+ * @param onError - optional failure sink; called once per failing step and
24
+ * itself contained, so a throwing sink cannot abort the sequence.
25
+ * @returns the names of the steps that started, in order (for tests).
26
+ */
27
+ export declare function runQuitSequence(steps: readonly QuitCleanupStep[], exit: (code: number) => void, onError?: (name: string, error: unknown) => void): Promise<readonly string[]>;
@@ -0,0 +1,38 @@
1
+ /** Cross-session search rows for the /search panel.
2
+ *
3
+ * Owns the panel row shape and the pure mapping from a session-query hit, so
4
+ * the row contract does not live inside the panel component that renders it
5
+ * and the runner can build rows without importing the panel module.
6
+ *
7
+ * @module @deepseek-ai/dsh-code/search-rows
8
+ */
9
+ import type { SessionHeader } from '@deepseek-ai/dsh-session';
10
+ /** One cross-session full-text search hit mapped from the session-query engine. */
11
+ export interface SearchRow {
12
+ /** Session id (Enter resumes it through the switch machinery). */
13
+ readonly id: string;
14
+ /** Display label: session title or the short id form. */
15
+ readonly label: string;
16
+ /** Secondary facts line (workspace · preset markers). */
17
+ readonly detail: string;
18
+ /** Bounded plain-text excerpt around the strongest match. */
19
+ readonly snippet: string;
20
+ /** Match timestamp (relative labels derive from it). */
21
+ readonly updatedAt: number;
22
+ /** Whether the hit is a delegated subagent conversation (not resumable). */
23
+ readonly subagent: boolean;
24
+ /** Whether Enter may switch into it. */
25
+ readonly resumable: boolean;
26
+ }
27
+ /**
28
+ * Map one cross-session full-text hit onto the /search panel's row (pure).
29
+ * Labels fall back to the short id form — the engine's hit carries the
30
+ * strongest matching event, not the title observation.
31
+ */
32
+ export declare function searchHitToRow(hit: {
33
+ header: SessionHeader;
34
+ bestMatch: {
35
+ snippet: string;
36
+ time: number;
37
+ };
38
+ }): SearchRow;
@@ -0,0 +1,57 @@
1
+ /** Session directory IO exposed to the picker, /delete, and /export.
2
+ *
3
+ * The kernel persistence seam has NO deletion API by design — logs accumulate
4
+ * "until removed externally" — so removal is planned, layout-checked, and
5
+ * lease-guarded here before any file is touched. Every read goes through the
6
+ * in-process session-query engine, so this module stays free of `app.ts` and
7
+ * of the Ink tree.
8
+ *
9
+ * @module @deepseek-ai/dsh-code/runner/session-io
10
+ */
11
+ import { type SessionDeletionPersistence, type SessionDirectoryOptions, type SessionQueryService, type SessionRow } from '../session/session-directory.ts';
12
+ /**
13
+ * The persistence surface this module needs: the JSONL backend's public
14
+ * session root plus its per-session write handles. Typing the narrow shape
15
+ * instead of the upstream service keeps the IO injectable from a test double.
16
+ */
17
+ export interface SessionIoPersistence extends SessionDeletionPersistence {
18
+ /** JSONL backend plugin config carrying the session root, when exposed. */
19
+ readonly config?: {
20
+ readonly root?: unknown;
21
+ };
22
+ }
23
+ /** Services the session IO closes over. */
24
+ export interface SessionIoServices {
25
+ /** In-process session-query engine; absent in profiles without one. */
26
+ readonly sessionQuery?: SessionQueryService;
27
+ /** The durable persistence service; absent in profiles without one. */
28
+ readonly persistence?: SessionIoPersistence;
29
+ /** The session currently visible in the UI (self-deletion guard). */
30
+ readonly activeSessionId: () => string | undefined;
31
+ }
32
+ /** Session directory reads and the guarded /delete operation. */
33
+ export interface SessionIo {
34
+ /** Project the session directory for the picker (query-filtered). */
35
+ readonly loadSessions: (options: SessionDirectoryOptions, signal?: AbortSignal) => Promise<readonly SessionRow[]>;
36
+ /** Delete one session subtree, returning the outcome line. */
37
+ readonly deleteSession: (id: string) => Promise<string>;
38
+ /** Render one session's whole transcript as export Markdown. */
39
+ readonly loadSessionTranscript: (id: string, signal?: AbortSignal) => Promise<string>;
40
+ }
41
+ /** Maximum session artifact directories inspected at once by the picker. */
42
+ export declare const SESSION_ARTIFACT_READ_CONCURRENCY = 16;
43
+ /**
44
+ * Map a collection with a fixed worker count while preserving input order.
45
+ * The picker may own thousands of persisted sessions; an unbounded
46
+ * `Promise.all` turns those into one filesystem burst and can exhaust handles
47
+ * on Windows or remote filesystems.
48
+ *
49
+ * @internal Exported for the deterministic concurrency regression.
50
+ */
51
+ export declare function mapConcurrent<T, R>(items: readonly T[], concurrency: number, mapper: (item: T, index: number) => Promise<R>): Promise<R[]>;
52
+ /**
53
+ * Bind the session IO to one runner's services.
54
+ * @param services - the query engine, persistence, and the live-session probe.
55
+ * @returns the picker/delete/export reads used by the app bridge.
56
+ */
57
+ export declare function createSessionIo(services: SessionIoServices): SessionIo;
@@ -0,0 +1,42 @@
1
+ /** Session identity resolution for one terminal runner invocation.
2
+ *
3
+ * Turns parsed startup flags into the session this process will run, and maps
4
+ * a session id onto a filename-safe export default. Resolution reads persisted
5
+ * headers, so it is the runner's only pre-composition persistence IO; the
6
+ * remaining helpers are pure.
7
+ *
8
+ * @module @deepseek-ai/dsh-code/session-target
9
+ */
10
+ import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session';
11
+ import type { SessionPersistence } from '@deepseek-ai/dsh-session-persistence';
12
+ import type { TuiStartup } from '../startup.ts';
13
+ /** The session identity this invocation will run, plus whether it is resumed. */
14
+ export interface Target {
15
+ sessionId: string;
16
+ resume: boolean;
17
+ mode?: string;
18
+ cwd?: string;
19
+ seed?: readonly SessionEvent[];
20
+ parentSession?: SessionId;
21
+ /** Marks the session as a subagent conversation in the durable header. */
22
+ origin?: 'subagent';
23
+ seedLength?: number;
24
+ }
25
+ /**
26
+ * Reduce a session id to a filename-safe /export default-name suffix. Session
27
+ * ids are normally minted `session-<uuid>`, but `--session` accepts arbitrary
28
+ * user text: path separators must never leak into the default export filename
29
+ * (which would escape the session cwd).
30
+ * @param id - the session id.
31
+ * @returns at most the last 8 filename-safe characters.
32
+ */
33
+ export declare function exportSessionIdSuffix(id: string): string;
34
+ /**
35
+ * Resolve the invocation's target session against the persisted headers.
36
+ * @param startup - the parsed startup flags.
37
+ * @param persistence - the persistence service; required for resume/latest.
38
+ * @param cwd - the working directory `--continue` filters by.
39
+ * @returns the target identity.
40
+ * @throws with a user-facing message when the flags name nothing resolvable.
41
+ */
42
+ export declare function resolveTarget(startup: TuiStartup, persistence: SessionPersistence | undefined, cwd: string): Promise<Target>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Resolve the runner's startup flags from the loose plugin config.
3
+ *
4
+ * The Cordis config schema is deliberately loose (`kind` is an unvalidated
5
+ * string, narrowed here), so this is the single place that maps a config row
6
+ * onto the `TuiStartup` the runner consumes — pure, and unit-testable without
7
+ * a plugin context.
8
+ *
9
+ * @module @deepseek-ai/dsh-code/runner/startup-config
10
+ */
11
+ import type { TuiStartup } from '../startup.ts';
12
+ /** The config row shape this resolver narrows; satisfied by the plugin schema. */
13
+ export interface StartupConfigRow {
14
+ /** How this invocation obtains its session identity. */
15
+ readonly kind: string;
16
+ readonly sessionId?: string;
17
+ readonly mode?: string;
18
+ readonly theme?: string;
19
+ readonly prompt?: string;
20
+ readonly images?: readonly string[];
21
+ }
22
+ /**
23
+ * Narrow one config row to a startup.
24
+ *
25
+ * `resume`/`named` without a session id degrade to a fresh launch, an invalid
26
+ * theme string narrows to the dark default (and is therefore still present),
27
+ * and `mode` only survives on the kinds that can pre-compose a session.
28
+ * @param config - the validated plugin config.
29
+ * @returns the startup the runner will resolve a target from.
30
+ */
31
+ export declare function resolveStartupConfig(config: {
32
+ readonly startup: StartupConfigRow;
33
+ }): TuiStartup;
@@ -0,0 +1,87 @@
1
+ /** Submission vocabulary and the startup input gate for the terminal runner.
2
+ *
3
+ * Pure over the handles they are given: the queue mutations and the session
4
+ * guard are decisions the runner applies, and the gate only orders deliveries,
5
+ * so every branch is testable without composing an Agent.
6
+ *
7
+ * @module @deepseek-ai/dsh-code/submissions
8
+ */
9
+ import { type ContentBlock } from '@deepseek-ai/dsh-llm';
10
+ import type { Agent, AgentStatus, Inbox } from '@deepseek-ai/dsh-agent';
11
+ import type { UserMessage } from '@deepseek-ai/dsh-session';
12
+ import type { QueueMutation } from '../ui/ui-contract.ts';
13
+ /** One composer submission waiting behind the startup delivery. */
14
+ export interface QueuedSubmission {
15
+ readonly text: string;
16
+ /** `steer` inserts into the running turn; `followup` waits for the next one. */
17
+ readonly mode: 'followup' | 'steer';
18
+ readonly images: readonly ContentBlock[];
19
+ }
20
+ /** What one requested queue mutation did; the runner maps it to one notice. */
21
+ export type QueueMutationOutcome = 'removed' | 'edited' | 'steered' | 'unavailable' | 'empty' | 'steerUnavailable';
22
+ /**
23
+ * Replace one queued message's text while keeping its attachments. A queue
24
+ * edit rewrites what the user typed, not what they attached: image and file
25
+ * blocks ride through in delivery order (text first, then attachments, the
26
+ * shape {@link deliverLine} submits). Dropping them here would silently strip
27
+ * an attachment the user already confirmed, so this is the edit's single
28
+ * definition and the panel's read-only marker only mirrors it.
29
+ */
30
+ export declare function queueEditContent(content: readonly ContentBlock[], text: string): ContentBlock[];
31
+ /**
32
+ * Apply one terminal queue mutation to the live inbox. The decision and the
33
+ * inbox change are pure over the supplied handles so every branch is testable
34
+ * without an agent; steering itself is injected because it wakes the driver
35
+ * rather than mutating the inbox. The durable inbox splices remain the UI's
36
+ * single source of truth — this helper never reports a state the inbox did not
37
+ * actually reach.
38
+ * @param inbox - the live agent inbox (pending lists plus its mutators).
39
+ * @param status - the agent's lifecycle status; steering needs `running`.
40
+ * @param messageId - identity of the queued message to mutate.
41
+ * @param action - the requested mutation.
42
+ * @param steer - submits the removed message as next-step steering.
43
+ * @returns the outcome the caller reports.
44
+ */
45
+ export declare function applyQueueMutation(inbox: Pick<Inbox, 'nextTurn' | 'append' | 'remove' | 'replace'>, status: AgentStatus, messageId: string, action: QueueMutation, steer: (message: UserMessage) => void): QueueMutationOutcome;
46
+ /**
47
+ * Cancel the active turn while keeping the next-turn queue, then wake the
48
+ * driver again so the preserved messages actually run. `cancel` clears
49
+ * pending work by default and never wakes the driver on its own, so the queue
50
+ * is captured first and re-submitted afterwards: a waking submission latches
51
+ * the wake while the aborted activity converges to idle, which is what turns
52
+ * "preserved" into "sent next" instead of "parked forever". Next-step
53
+ * steering is deliberately dropped — it belonged to the cancelled turn.
54
+ * @param agent - the live agent handle.
55
+ * @returns how many queued messages were preserved across the abort.
56
+ */
57
+ export declare function cancelPreservingQueue(agent: Pick<Agent, 'inbox' | 'cancel' | 'followup'>): number;
58
+ /**
59
+ * Whether a tagged submission still belongs to the active session. Attachment
60
+ * prepares resolve on the microtask timeline, while a queued session switch
61
+ * remounts the app asynchronously — the composing instance's unmount cleanup
62
+ * runs too late to abort, so the delivery itself carries the composing
63
+ * session's full id and the runner drops it here when the world moved on.
64
+ * An untagged (synchronous) or pending-session ('') submission always passes.
65
+ */
66
+ export declare function submissionBelongsToSession(origin: string | undefined, activeSessionId: string | undefined): boolean;
67
+ /**
68
+ * Order-preserving gate for composer input while the startup prompt/images
69
+ * are still preparing. Anything submitted before the startup delivery settles
70
+ * queues and flushes afterwards in submit order, so the initial request can
71
+ * never be overtaken by typing that raced a slow image preparation. The flush
72
+ * also runs when the startup delivery fails: user input is never stranded.
73
+ */
74
+ export declare class StartupInputGate {
75
+ private readonly deliver;
76
+ private readonly queued;
77
+ private pending;
78
+ constructor(deliver: (submission: QueuedSubmission) => void);
79
+ /** Submit one line: delivered now while idle, queued behind the startup delivery otherwise. */
80
+ submit(submission: QueuedSubmission): void;
81
+ /**
82
+ * Run the startup delivery — the callback receives the direct-delivery sink
83
+ * for the startup prompt itself — then flush everything that queued behind
84
+ * it, in order, even when the callback rejects.
85
+ */
86
+ run(startup: (deliver: (submission: QueuedSubmission) => void) => Promise<void>): Promise<void>;
87
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * One live attachment to a subagent conversation: a transcript store seeded
3
+ * from the child's durable log and then fed by the process-local event and
4
+ * stream buses in real time. The parent's own store is never touched.
5
+ *
6
+ * @module @deepseek-ai/dsh-code/session/attach
7
+ */
8
+ import type { SessionEvent } from '@deepseek-ai/dsh-session';
9
+ import { type TranscriptStore } from './store.ts';
10
+ /** The bus surfaces one attachment reads; the runner wires these to ctx. */
11
+ export interface SubagentAttachmentServices {
12
+ /** Seed: the child's full durable event log, oldest first. */
13
+ load(id: string, signal?: AbortSignal): Promise<readonly SessionEvent[]>;
14
+ /** Durable events for exactly this child session, live. */
15
+ subscribeEvents(id: string, onEvent: (event: SessionEvent) => void): () => void;
16
+ /** Token stream frames for exactly this child agent, live. */
17
+ subscribeStream(id: string, onFrame: (frame: Parameters<TranscriptStore['applyStreamFrame']>[0]) => void): () => void;
18
+ }
19
+ /** A live child view handed to the App while attached. */
20
+ export interface SubagentAttachment {
21
+ readonly id: string;
22
+ readonly label: string;
23
+ readonly store: TranscriptStore;
24
+ /** Whether the durable seed has landed (frames are held back until then). */
25
+ seeded(): boolean;
26
+ /** Drop the bus subscriptions; the store freezes at its last state. */
27
+ dispose(): void;
28
+ }
29
+ /** An inert empty store keeps the App's external-store hook unconditional. */
30
+ export declare const EMPTY_ATTACH_STORE: TranscriptStore;
31
+ /**
32
+ * Attach to one subagent conversation.
33
+ *
34
+ * Ordering contract: durable events carry a per-session sequence, so the seed
35
+ * sets a watermark and live events at or below it are dropped as duplicates;
36
+ * stream frames are held until the seed lands so a frame whose settlement
37
+ * already arrived cannot resurrect a stale tail.
38
+ */
39
+ export declare function createSubagentAttachment(services: SubagentAttachmentServices, id: string, label: string): SubagentAttachment;
@@ -31,7 +31,7 @@
31
31
  */
32
32
  import type { AssistantStreamFrame } from '@deepseek-ai/dsh-agent';
33
33
  import type { SessionEvent } from '@deepseek-ai/dsh-session';
34
- import { type TranscriptView } from './render/projection.ts';
34
+ import { type TranscriptView } from '../render/projection.ts';
35
35
  /** The externally readable, event-fed transcript store for one session. */
36
36
  export interface TranscriptStore {
37
37
  /** The current view; the same object identity until an event changes it. */
@@ -18,7 +18,7 @@
18
18
  * microtask notify chained SyncLane rerenders past React's nested update
19
19
  * limit; a bare macrotask merge repaints a whole turn's bursts at once).
20
20
  *
21
- * @module @deepseek-ai/dsh-code/subagents
21
+ * @module @deepseek-ai/dsh-code/session/subagents
22
22
  */
23
23
  import type { SessionEvent } from '@deepseek-ai/dsh-session';
24
24
  /** Hard row cap: overflow evicts the oldest settled row; a fully busy feed waits. */
@@ -68,3 +68,10 @@ export declare function createSubagentFeed(): SubagentFeedView & {
68
68
  apply(sessionId: string, event: SessionEvent): void;
69
69
  reset(): void;
70
70
  };
71
+ /**
72
+ * Root-log catalog facts a resumed session must replay into the subagent
73
+ * feed: constructor seeds never fire on the live bus, so without this the
74
+ * children of a resumed session vanish behind a restart. The empty-child
75
+ * placeholder row (childId '') is a placeholder, not a child, and stays out.
76
+ */
77
+ export declare function subagentCatalogSeed(events: readonly SessionEvent[]): readonly SessionEvent<'subagent/catalog'>[];
@@ -81,6 +81,17 @@ export declare function observeStableWithSkip(engine: EngineSurface, indexed: Re
81
81
  persisted: Map<SessionId, ObservedPersistedSession>;
82
82
  live: Map<SessionId, ObservedSession>;
83
83
  }>;
84
+ /**
85
+ * Assert the private override seam this compatibility engine relies on.
86
+ * Harness keeps `_observeStable` private, so TypeScript cannot protect this
87
+ * subclass when upstream renames the method or changes its call signature.
88
+ * The exact-version launcher gate prevents unsupported hosts; this import-time
89
+ * check additionally prevents a newly built bundle from silently mounting an
90
+ * override the installed base will never call.
91
+ *
92
+ * @internal Exported for the compatibility regression.
93
+ */
94
+ export declare function assertSessionQueryOverrideContract(candidate: unknown): void;
84
95
  declare const EngineBase: abstract new (ctx: never, config: Config) => EngineSurface & object;
85
96
  /** The engine this bundle mounts in place of the base `session-query-sqlite` row. */
86
97
  export declare class SkipTolerantSessionQueryEngine extends EngineBase {
@@ -39,3 +39,13 @@ export interface UserSettingsPersistence {
39
39
  * @returns the persistence handle.
40
40
  */
41
41
  export declare function createUserSettingsPersistence(): UserSettingsPersistence;
42
+ /**
43
+ * Read one user-level settings file as a plain object. The callers all treat a
44
+ * missing file as "unset" and a corrupt one as "warn and fall back", so this
45
+ * helper owns the one distinction they share: readable JSON that is not an
46
+ * object is corruption, not an absent preference, and must not surface as a
47
+ * cryptic property access on `null`.
48
+ * @param path - absolute path of the settings file.
49
+ * @returns the parsed object; the caller narrows each field itself.
50
+ */
51
+ export declare function readSettingsObject(path: string): Record<string, unknown>;
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * @module @deepseek-ai/dsh-tui/panel-accent
12
12
  */
13
- import { type RgbTriple } from './theme.ts';
13
+ import { type RgbTriple } from '../theme.ts';
14
14
  /** One panel's resolved accent pair (border and title share the ring color in prismatic). */
15
15
  export interface PanelAccent {
16
16
  readonly border: RgbTriple;
@@ -0,0 +1,6 @@
1
+ /** Shared optional spacer row used by bounded panel layouts. */
2
+ import { type ReactElement } from 'react';
3
+ /** Codex-style panel rhythm that still participates in the row budget. */
4
+ export declare function PanelGap({ visible }: {
5
+ visible: boolean;
6
+ }): ReactElement | undefined;
@@ -0,0 +1,10 @@
1
+ /** Shared one-line query editor for keyboard-owned filtering panels. */
2
+ /**
3
+ * Apply one keystroke to a panel search query. IME commits arrive as one
4
+ * multi-character chunk, so the whole printable run is appended; paste
5
+ * markers are stripped and control-laden chunks are ignored.
6
+ */
7
+ export declare function editQuery(query: string, input: string, key: {
8
+ backspace?: boolean;
9
+ delete?: boolean;
10
+ }): string | undefined;
@@ -0,0 +1,8 @@
1
+ /** Ink renderer for width-safe styled terminal rows. */
2
+ import { type ReactElement } from 'react';
3
+ import type { StyledLine } from '../render/lines.ts';
4
+ /** Render width-safe rows; every child is exactly one terminal row. */
5
+ export declare function StyledRows({ lines }: {
6
+ lines: readonly StyledLine[];
7
+ }): ReactElement;
8
+ /** File-oriented, color-coded unified diff viewport. */
@@ -10,7 +10,7 @@
10
10
  * an empty OSC payload and the terminal falls back to its own default; the
11
11
  * previously set title is not portable to read back and is never restored.
12
12
  *
13
- * @module @deepseek-ai/dsh-code/terminal-title
13
+ * @module @deepseek-ai/dsh-code/ui/terminal-title
14
14
  */
15
15
  /** Tab label before a session carries a name. */
16
16
  export declare const DEFAULT_TERMINAL_TITLE = "deepseek";
@@ -0,0 +1,12 @@
1
+ /** Shared terminal UI contracts used by the runner, App, and composer. */
2
+ /** Visual priority for one bounded local notice. */
3
+ export type NoticeTone = 'info' | 'warning' | 'error';
4
+ /** One mutation the terminal may request for a pending next-turn inbox item. */
5
+ export type QueueMutation = {
6
+ readonly kind: 'remove';
7
+ } | {
8
+ readonly kind: 'edit';
9
+ readonly text: string;
10
+ } | {
11
+ readonly kind: 'steer';
12
+ };
@@ -0,0 +1,6 @@
1
+ /** Wall-clock animation frame hook shared by independent terminal leaves. */
2
+ /**
3
+ * Derive ticks from elapsed wall time so a stretched interval skips ahead
4
+ * instead of slowing the animation under a busy event loop or remote shell.
5
+ */
6
+ export declare function useFrames(intervalMs: number, active?: boolean): number;
@@ -0,0 +1,7 @@
1
+ /** Stable Ink input subscription for stateful keyboard-owned surfaces. */
2
+ import { type Key } from 'ink';
3
+ /**
4
+ * Ink re-subscribes its input effect whenever the handler identity changes.
5
+ * Keep ownership stable while a surface updates cursor, scroll, or draft state.
6
+ */
7
+ export declare function useStableInput(handler: (input: string, key: Key) => void, active: boolean): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-code",
3
3
  "description": "DeepSeek Harness CLI core bundle: interactive coding terminal, durable sessions, and model management for dsh --profile cli",
4
- "version": "1.3.0",
4
+ "version": "1.5.0",
5
5
  "packageManager": "pnpm@12.4.1",
6
6
  "type": "module",
7
7
  "bin": {
@@ -65,7 +65,8 @@
65
65
  "typecheck:tests": "tsc -p tsconfig.test.json --noEmit",
66
66
  "lint": "eslint . --max-warnings 0",
67
67
  "lint:fix": "eslint . --fix --max-warnings 0",
68
- "verify": "pnpm lint && pnpm typecheck && pnpm typecheck:tests && pnpm test",
68
+ "perf:check": "tsx scripts/check-performance.ts",
69
+ "verify": "pnpm lint && pnpm typecheck && pnpm typecheck:tests && pnpm test && pnpm perf:check",
69
70
  "gen:whale": "tsx scripts/gen-whale-glyph.ts",
70
71
  "prepare": "pnpm build",
71
72
  "prepublishOnly": "pnpm audit:prod && pnpm exec tsx scripts/check-release.ts --package-version && pnpm verify && pnpm build"