@agi-fans/dsh-tui 0.18.0 → 0.20.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 (227) hide show
  1. package/lib/CHANGELOG.md +115 -1
  2. package/lib/chrome/box.d.ts +2 -0
  3. package/lib/chrome/box.js +6 -12
  4. package/lib/chrome/box.js.map +1 -1
  5. package/lib/chrome/code-highlight.d.ts +26 -18
  6. package/lib/chrome/code-highlight.js +114 -39
  7. package/lib/chrome/code-highlight.js.map +1 -1
  8. package/lib/chrome/diff-render.d.ts +1 -2
  9. package/lib/chrome/diff-render.js +41 -90
  10. package/lib/chrome/diff-render.js.map +1 -1
  11. package/lib/chrome/main-screen-renderer.d.ts +52 -30
  12. package/lib/chrome/main-screen-renderer.js +1730 -79
  13. package/lib/chrome/main-screen-renderer.js.map +1 -1
  14. package/lib/chrome/markdown.js +144 -101
  15. package/lib/chrome/markdown.js.map +1 -1
  16. package/lib/chrome/math.d.ts +4 -0
  17. package/lib/chrome/math.js +340 -0
  18. package/lib/chrome/math.js.map +1 -0
  19. package/lib/chrome/md-style.d.ts +3 -0
  20. package/lib/chrome/md-style.js.map +1 -1
  21. package/lib/chrome/mermaid.d.ts +6 -0
  22. package/lib/chrome/mermaid.js +56 -0
  23. package/lib/chrome/mermaid.js.map +1 -0
  24. package/lib/chrome/renderer.d.ts +78 -0
  25. package/lib/chrome/renderer.js.map +1 -1
  26. package/lib/chrome/status-config.d.ts +5 -0
  27. package/lib/chrome/status-config.js +3 -0
  28. package/lib/chrome/status-config.js.map +1 -1
  29. package/lib/chrome/status-line.d.ts +0 -21
  30. package/lib/chrome/status-line.js +8 -65
  31. package/lib/chrome/status-line.js.map +1 -1
  32. package/lib/chrome/terminal-images.d.ts +31 -0
  33. package/lib/chrome/terminal-images.js +34 -0
  34. package/lib/chrome/terminal-images.js.map +1 -0
  35. package/lib/chrome/theme.d.ts +23 -6
  36. package/lib/chrome/theme.js +217 -109
  37. package/lib/chrome/theme.js.map +1 -1
  38. package/lib/chrome/tool-args.d.ts +24 -1
  39. package/lib/chrome/tool-args.js +40 -1
  40. package/lib/chrome/tool-args.js.map +1 -1
  41. package/lib/chrome/tool-renderers.d.ts +11 -0
  42. package/lib/chrome/tool-renderers.js +55 -5
  43. package/lib/chrome/tool-renderers.js.map +1 -1
  44. package/lib/chrome/welcome-tips.js +2 -2
  45. package/lib/chrome/welcome-tips.js.map +1 -1
  46. package/lib/chrome/width.d.ts +7 -3
  47. package/lib/chrome/width.js +78 -14
  48. package/lib/chrome/width.js.map +1 -1
  49. package/lib/commands/diff.js +49 -3
  50. package/lib/commands/diff.js.map +1 -1
  51. package/lib/commands/export.js +28 -5
  52. package/lib/commands/export.js.map +1 -1
  53. package/lib/commands/files.d.ts +8 -0
  54. package/lib/commands/files.js +137 -0
  55. package/lib/commands/files.js.map +1 -0
  56. package/lib/commands/plugins.d.ts +8 -0
  57. package/lib/commands/plugins.js +158 -0
  58. package/lib/commands/plugins.js.map +1 -0
  59. package/lib/commands/session-configuration.d.ts +4 -0
  60. package/lib/commands/session-configuration.js +39 -8
  61. package/lib/commands/session-configuration.js.map +1 -1
  62. package/lib/commands/session.js +47 -15
  63. package/lib/commands/session.js.map +1 -1
  64. package/lib/commands/steer.js +2 -2
  65. package/lib/commands/steer.js.map +1 -1
  66. package/lib/commands/terminal.d.ts +7 -0
  67. package/lib/commands/terminal.js +99 -0
  68. package/lib/commands/terminal.js.map +1 -0
  69. package/lib/definition.d.ts +180 -14
  70. package/lib/definition.js.map +1 -1
  71. package/lib/input/clipboard.d.ts +12 -7
  72. package/lib/input/clipboard.js +79 -20
  73. package/lib/input/clipboard.js.map +1 -1
  74. package/lib/input/composer-files.d.ts +26 -0
  75. package/lib/input/composer-files.js +50 -0
  76. package/lib/input/composer-files.js.map +1 -0
  77. package/lib/input/editor-discovery.d.ts +21 -0
  78. package/lib/input/editor-discovery.js +99 -0
  79. package/lib/input/editor-discovery.js.map +1 -0
  80. package/lib/input/editor.d.ts +26 -1
  81. package/lib/input/editor.js +126 -12
  82. package/lib/input/editor.js.map +1 -1
  83. package/lib/input/external-editor.d.ts +5 -2
  84. package/lib/input/external-editor.js +14 -12
  85. package/lib/input/external-editor.js.map +1 -1
  86. package/lib/input/fuzzy-search.d.ts +9 -0
  87. package/lib/input/fuzzy-search.js +113 -0
  88. package/lib/input/fuzzy-search.js.map +1 -0
  89. package/lib/input/keybindings-config.d.ts +1 -1
  90. package/lib/input/keybindings-config.js +7 -1
  91. package/lib/input/keybindings-config.js.map +1 -1
  92. package/lib/input/keys.d.ts +17 -0
  93. package/lib/input/keys.js +21 -5
  94. package/lib/input/keys.js.map +1 -1
  95. package/lib/input/mouse-policy.d.ts +3 -0
  96. package/lib/input/mouse-policy.js +14 -0
  97. package/lib/input/mouse-policy.js.map +1 -0
  98. package/lib/input/paste-burst.d.ts +16 -0
  99. package/lib/input/paste-burst.js +61 -0
  100. package/lib/input/paste-burst.js.map +1 -0
  101. package/lib/input/text-selection.d.ts +20 -0
  102. package/lib/input/text-selection.js +195 -0
  103. package/lib/input/text-selection.js.map +1 -0
  104. package/lib/runtime/composer-images.d.ts +1 -0
  105. package/lib/runtime/composer-images.js +11 -3
  106. package/lib/runtime/composer-images.js.map +1 -1
  107. package/lib/runtime/file-open.d.ts +2 -0
  108. package/lib/runtime/file-open.js +12 -0
  109. package/lib/runtime/file-open.js.map +1 -0
  110. package/lib/runtime/file-review.d.ts +24 -0
  111. package/lib/runtime/file-review.js +188 -0
  112. package/lib/runtime/file-review.js.map +1 -0
  113. package/lib/runtime/herdr-agent.d.ts +7 -15
  114. package/lib/runtime/herdr-agent.js +151 -79
  115. package/lib/runtime/herdr-agent.js.map +1 -1
  116. package/lib/runtime/hook-settings.d.ts +17 -0
  117. package/lib/runtime/hook-settings.js +57 -0
  118. package/lib/runtime/hook-settings.js.map +1 -0
  119. package/lib/runtime/human-interaction.js +1 -1
  120. package/lib/runtime/human-interaction.js.map +1 -1
  121. package/lib/runtime/image-preview.d.ts +8 -0
  122. package/lib/runtime/image-preview.js +119 -0
  123. package/lib/runtime/image-preview.js.map +1 -0
  124. package/lib/runtime/plain-tui.d.ts +2 -0
  125. package/lib/runtime/plain-tui.js +2 -2
  126. package/lib/runtime/plain-tui.js.map +1 -1
  127. package/lib/runtime/plugin-settings.d.ts +17 -0
  128. package/lib/runtime/plugin-settings.js +154 -0
  129. package/lib/runtime/plugin-settings.js.map +1 -0
  130. package/lib/runtime/provider-local.d.ts +58 -7
  131. package/lib/runtime/provider-local.js +1394 -137
  132. package/lib/runtime/provider-local.js.map +1 -1
  133. package/lib/runtime/runner.js +3 -3
  134. package/lib/runtime/runner.js.map +1 -1
  135. package/lib/runtime/session-archive.d.ts +5 -0
  136. package/lib/runtime/session-archive.js +114 -0
  137. package/lib/runtime/session-archive.js.map +1 -0
  138. package/lib/runtime/subagent-model-selection.d.ts +5 -0
  139. package/lib/runtime/subagent-model-selection.js +15 -0
  140. package/lib/runtime/subagent-model-selection.js.map +1 -0
  141. package/lib/runtime/terminal-notifications.d.ts +8 -0
  142. package/lib/runtime/terminal-notifications.js +16 -0
  143. package/lib/runtime/terminal-notifications.js.map +1 -1
  144. package/lib/runtime/terminal-reader.d.ts +11 -0
  145. package/lib/runtime/terminal-reader.js +87 -0
  146. package/lib/runtime/terminal-reader.js.map +1 -0
  147. package/lib/runtime/tool-presentation.js +43 -30
  148. package/lib/runtime/tool-presentation.js.map +1 -1
  149. package/lib/session/composer-drafts.d.ts +20 -0
  150. package/lib/session/composer-drafts.js +103 -0
  151. package/lib/session/composer-drafts.js.map +1 -0
  152. package/lib/session/conversation-turns.d.ts +16 -0
  153. package/lib/session/conversation-turns.js +33 -0
  154. package/lib/session/conversation-turns.js.map +1 -0
  155. package/lib/session/feature-toggles.d.ts +79 -0
  156. package/lib/session/feature-toggles.js +139 -0
  157. package/lib/session/feature-toggles.js.map +1 -0
  158. package/lib/session/fold-policy.d.ts +4 -0
  159. package/lib/session/fold-policy.js +4 -0
  160. package/lib/session/fold-policy.js.map +1 -0
  161. package/lib/session/interaction-adapter.d.ts +2 -2
  162. package/lib/session/interaction-adapter.js +156 -25
  163. package/lib/session/interaction-adapter.js.map +1 -1
  164. package/lib/session/job-notice.d.ts +4 -0
  165. package/lib/session/job-notice.js +44 -3
  166. package/lib/session/job-notice.js.map +1 -1
  167. package/lib/session/message-queue.d.ts +22 -0
  168. package/lib/session/message-queue.js +157 -0
  169. package/lib/session/message-queue.js.map +1 -0
  170. package/lib/session/project-file-search.js +3 -21
  171. package/lib/session/project-file-search.js.map +1 -1
  172. package/lib/session/session-controller.d.ts +11 -18
  173. package/lib/session/session-controller.js +246 -100
  174. package/lib/session/session-controller.js.map +1 -1
  175. package/lib/session/session-library.d.ts +11 -3
  176. package/lib/session/session-library.js +48 -8
  177. package/lib/session/session-library.js.map +1 -1
  178. package/lib/session/session-tree.d.ts +26 -0
  179. package/lib/session/session-tree.js +112 -0
  180. package/lib/session/session-tree.js.map +1 -0
  181. package/lib/session/steering.d.ts +3 -0
  182. package/lib/session/steering.js +9 -0
  183. package/lib/session/steering.js.map +1 -0
  184. package/lib/session/tui-settings.d.ts +23 -1
  185. package/lib/session/tui-settings.js +15 -2
  186. package/lib/session/tui-settings.js.map +1 -1
  187. package/lib/session/workflow-projection.d.ts +9 -0
  188. package/lib/session/workflow-projection.js +44 -0
  189. package/lib/session/workflow-projection.js.map +1 -0
  190. package/lib/views/agent-hub.js +9 -4
  191. package/lib/views/agent-hub.js.map +1 -1
  192. package/lib/views/autocomplete.js +5 -25
  193. package/lib/views/autocomplete.js.map +1 -1
  194. package/lib/views/document-reader.d.ts +34 -0
  195. package/lib/views/document-reader.js +145 -0
  196. package/lib/views/document-reader.js.map +1 -0
  197. package/lib/views/event-views.d.ts +26 -2
  198. package/lib/views/event-views.js +196 -42
  199. package/lib/views/event-views.js.map +1 -1
  200. package/lib/views/hotkeys.d.ts +2 -0
  201. package/lib/views/hotkeys.js +20 -8
  202. package/lib/views/hotkeys.js.map +1 -1
  203. package/lib/views/prompt-selector.d.ts +33 -3
  204. package/lib/views/prompt-selector.js +287 -43
  205. package/lib/views/prompt-selector.js.map +1 -1
  206. package/lib/views/prompt-tree.d.ts +11 -0
  207. package/lib/views/prompt-tree.js +74 -0
  208. package/lib/views/prompt-tree.js.map +1 -0
  209. package/lib/views/session-files.d.ts +7 -0
  210. package/lib/views/session-files.js +62 -0
  211. package/lib/views/session-files.js.map +1 -0
  212. package/lib/views/settings-list.d.ts +32 -4
  213. package/lib/views/settings-list.js +148 -37
  214. package/lib/views/settings-list.js.map +1 -1
  215. package/lib/views/transcript-render.d.ts +117 -18
  216. package/lib/views/transcript-render.js +1084 -126
  217. package/lib/views/transcript-render.js.map +1 -1
  218. package/lib/views/transcript-types.d.ts +80 -2
  219. package/lib/views/transcript-types.js +11 -0
  220. package/lib/views/transcript-types.js.map +1 -1
  221. package/lib/views/workspace-changes.d.ts +27 -0
  222. package/lib/views/workspace-changes.js +128 -0
  223. package/lib/views/workspace-changes.js.map +1 -0
  224. package/package.json +77 -41
  225. package/lib/chrome/style.d.ts +0 -22
  226. package/lib/chrome/style.js +0 -23
  227. package/lib/chrome/style.js.map +0 -1
@@ -10,25 +10,73 @@
10
10
  * @module @agi-fans/dsh-tui
11
11
  */
12
12
  import type { SessionEvent } from '@deepseek-ai/dsh-session';
13
+ import type { WorkspaceChangesSummary } from '@deepseek-ai/dsh-workspace-changes';
13
14
  import type { StreamDelta } from './views/event-views.ts';
14
15
  import type { TuiPrefs } from './views/settings-list.ts';
15
- import type { ImageMediaType } from '@deepseek-ai/dsh-attachment';
16
+ import type { FileAttachmentRef, ImageMediaType } from '@deepseek-ai/dsh-attachment';
16
17
  import type { TuiToolPresentation } from './chrome/tool-renderers.ts';
17
18
  /** Context service name providers publish under. */
18
19
  export declare const TUI_SERVICE = "tui";
19
20
  /** Whole-agent liveness, mirroring the SDK session.status vocabulary. */
20
21
  export type TuiStatus = 'idle' | 'running';
22
+ /** Why the controller is replacing the visible transcript. */
23
+ export type TuiTranscriptReplacement = 'initial' | 'new' | 'open' | 'refresh';
21
24
  /** Command metadata contributed by the active agent's plugin scope. */
22
25
  export interface TuiCommand {
23
26
  name: string;
24
27
  description: string;
25
28
  inputHint?: string;
26
29
  }
30
+ /** Whether direct output should interrupt transcript browsing. */
31
+ export interface TuiOutputOptions {
32
+ /** Reveal a requested result at the live tail, ending any inspection. */
33
+ focus?: boolean;
34
+ }
27
35
  /** Presentation intent for a direct, non-session notice. */
28
- export interface TuiNoticeOptions {
36
+ export interface TuiNoticeOptions extends TuiOutputOptions {
29
37
  level?: 'info' | 'error';
30
38
  /** Reserve a component frame for callers that explicitly own a panel. */
31
39
  framed?: boolean;
40
+ /**
41
+ * The notice reports work inside the running turn — a background job
42
+ * settling — so it folds into the turn's run instead of splitting it. It is
43
+ * ignored when no turn is running: then it speaks to the reader directly.
44
+ */
45
+ process?: boolean;
46
+ /**
47
+ * Durable id of what a process notice reports on — a job id, a retry id.
48
+ * A run is keyed by its first block, so notices sharing a run need to be
49
+ * told apart or two runs in one document collide on one key.
50
+ */
51
+ processSource?: string;
52
+ /** Job settlement to merge into its visible originating tool call when identifiable. */
53
+ job?: {
54
+ id: string;
55
+ label: string;
56
+ startedAt: number;
57
+ status: 'completed' | 'failed' | 'killed';
58
+ detail?: string;
59
+ };
60
+ }
61
+ /** Source text inspected without Markdown interpreting its syntax. */
62
+ export interface TuiDocumentSource {
63
+ readonly text: string;
64
+ /** One-based line number of the first retained source row. */
65
+ readonly firstLine?: number;
66
+ readonly language?: string;
67
+ readonly diff?: boolean;
68
+ readonly status?: string;
69
+ }
70
+ /** Source row and wrapped continuation retained across reader actions and resizing. */
71
+ export interface TuiDocumentPosition {
72
+ row: number;
73
+ wrap: number;
74
+ query: string;
75
+ /** Live readers retain whether End is following new output across actions. */
76
+ following?: boolean;
77
+ /** Source readers default to wrapping; column is a display-cell offset when unwrapped. */
78
+ wordWrap?: boolean;
79
+ column?: number;
32
80
  }
33
81
  /** One terminal-owned human prompt used by approval and question adapters. */
34
82
  export interface TuiPrompt {
@@ -46,6 +94,10 @@ export interface TuiPrompt {
46
94
  label: string;
47
95
  /** Answer returned to the caller; defaults to {@link label}. */
48
96
  value?: string;
97
+ /** Parent option value in a full-screen tree. Missing parents become roots. */
98
+ parentValue?: string;
99
+ /** Action shown for Enter on this option. */
100
+ submitLabel?: string;
49
101
  /** Secondary content preview shown above metadata in spacious lists. */
50
102
  preview?: string;
51
103
  description?: string;
@@ -55,13 +107,19 @@ export interface TuiPrompt {
55
107
  tone: 'success' | 'warning' | 'error' | 'muted';
56
108
  };
57
109
  }[];
58
- /** Optional single-key actions applied to the active option while the filter is empty. */
110
+ /** Text actions require an empty filter; full-screen lists and trees also accept key chords. */
59
111
  actions?: readonly {
60
112
  key: string;
61
113
  label: string;
62
114
  /** Prefix returned before the selected option value. */
63
115
  valuePrefix: string;
116
+ /** List actions return only their prefix, including when no option is selected. */
117
+ scope?: 'selection' | 'list';
64
118
  }[];
119
+ /** Initial editable text for a text-only prompt. */
120
+ initialInput?: string;
121
+ /** Keep indentation and trailing newlines when editing message text. */
122
+ preserveWhitespace?: boolean;
65
123
  multiSelect?: boolean;
66
124
  allowCustom?: boolean;
67
125
  /** Mask custom input while retaining the real value only in the prompt editor. */
@@ -69,7 +127,26 @@ export interface TuiPrompt {
69
127
  /** Option value selected when a fixed-choice prompt opens. */
70
128
  initialValue?: string;
71
129
  /** Full-height searchable list instead of the default prompt card. */
72
- presentation?: 'fullscreen-list' | 'plan-review';
130
+ presentation?: 'fullscreen-list' | 'fullscreen-tree' | 'plan-review' | 'document';
131
+ /** Suppress attention notifications for user-initiated browsing surfaces. */
132
+ notify?: boolean;
133
+ /** Refresh a human-owned document while it is open; stopped on dismissal or abort. */
134
+ refreshDocument?: () => string;
135
+ /** Refresh a source reader; false requests a stable paused snapshot. */
136
+ refreshDocumentSource?: (following: boolean) => TuiDocumentSource;
137
+ /** Refresh live choices; option values identify retained selection. */
138
+ refreshOptions?: () => NonNullable<TuiPrompt['options']>;
139
+ /** Yield this reading surface to an attention-requesting prompt and recover any entered text. */
140
+ onSuperseded?: (input: string) => void;
141
+ /** Open a live document at its latest rows. */
142
+ documentTail?: boolean;
143
+ /** Prepared PNG shown in a dedicated image reader; original bytes remain untouched. */
144
+ documentImage?: import('./chrome/terminal-images.ts').PreviewImage;
145
+ /** Source reader with line numbers, search, and diff navigation. */
146
+ documentSource?: TuiDocumentSource;
147
+ documentPosition?: TuiDocumentPosition;
148
+ /** Called on dismissal or action activation with the last visible source position. */
149
+ onDocumentPosition?: (position: TuiDocumentPosition) => void;
73
150
  /** Row density for full-screen lists; compact rows keep short choices together. */
74
151
  optionLayout?: 'compact' | 'spacious';
75
152
  /** Choice that approves a dedicated review; other choices may collect feedback. */
@@ -78,6 +155,17 @@ export interface TuiPrompt {
78
155
  filterable?: boolean;
79
156
  /** Verb shown after Enter in selector navigation, such as "run". */
80
157
  submitLabel?: string;
158
+ /** Dismissing an answerable question leaves it pending rather than cancelling it. */
159
+ dismissLabel?: string;
160
+ /** Ctrl+S submits an explicit empty answer for this question. */
161
+ skippable?: boolean;
162
+ /** Local countdown for a claimed Harness wait; editing or Ctrl+T holds the wait. */
163
+ wait?: {
164
+ deadline: number;
165
+ hold(): void;
166
+ };
167
+ /** Distinguish Ctrl+C interruption from dismissing an answerable question. */
168
+ interrupt?(): void;
81
169
  signal?: AbortSignal;
82
170
  }
83
171
  /** Durable, Harness-owned session controls projected into terminal chrome. */
@@ -93,6 +181,8 @@ export interface TuiSessionControls {
93
181
  permission?: string;
94
182
  /** Current durable goal; absent before the first goal and after a clear or completion. */
95
183
  goal?: TuiGoalStatus;
184
+ /** Unanswered continued questions from the Harness projection. */
185
+ pendingQuestions?: number;
96
186
  }
97
187
  /**
98
188
  * One durable goal projected into the bar above the composer. A completed goal
@@ -141,10 +231,30 @@ export interface TuiSubagentView {
141
231
  /** First durable event and latest hydrated or changed activity/state timestamps. */
142
232
  readonly startedAt?: number;
143
233
  readonly updatedAt?: number;
234
+ readonly workflow?: {
235
+ name: string;
236
+ phase?: string;
237
+ outcome?: 'completed' | 'failed' | 'cancelled';
238
+ };
239
+ }
240
+ export interface TuiWorkflowRun {
241
+ readonly id: string;
242
+ readonly name: string;
243
+ /** Open is a durable record without an end, not proof a restored worker is running. */
244
+ readonly status: string;
245
+ readonly phase?: string;
246
+ readonly members: readonly {
247
+ seq: number;
248
+ childId: string;
249
+ label: string;
250
+ phase?: string;
251
+ outcome?: 'completed' | 'failed' | 'cancelled';
252
+ }[];
144
253
  }
145
254
  /** Live descendant roster for the active root session. */
146
255
  export interface TuiSubagentRoster {
147
256
  readonly agents: readonly TuiSubagentView[];
257
+ readonly workflows?: readonly TuiWorkflowRun[];
148
258
  }
149
259
  /** The descendant whose own transcript currently replaces the parent view. */
150
260
  export interface TuiInspectedSubagent {
@@ -202,6 +312,9 @@ export interface TuiInputImage {
202
312
  export interface TuiSubmission {
203
313
  text: string;
204
314
  images: readonly TuiInputImage[];
315
+ files?: readonly FileAttachmentRef[];
316
+ /** Send pasted source as message text even when its first character is a slash. */
317
+ literal?: boolean;
205
318
  }
206
319
  /** Product-owned language preference projected into the settings overlay. */
207
320
  export interface TuiAgentBehaviorSettings {
@@ -213,17 +326,61 @@ export interface TuiAgentBehaviorSettingsBinding {
213
326
  update(next: TuiAgentBehaviorSettings): Promise<void>;
214
327
  watch(listener: (next: TuiAgentBehaviorSettings) => void): () => void;
215
328
  }
329
+ /** Terminal submissions waiting for dispatch, separate from durable Agent inbox input. */
330
+ export interface TuiPendingInputs {
331
+ list(): readonly {
332
+ id: string;
333
+ submission: TuiSubmission;
334
+ }[];
335
+ update(id: string, change: {
336
+ kind: 'replace';
337
+ submission: TuiSubmission;
338
+ } | {
339
+ kind: 'remove';
340
+ } | {
341
+ kind: 'move';
342
+ direction: -1 | 1;
343
+ }): boolean;
344
+ }
216
345
  /**
217
346
  * Terminal presentation service.
218
347
  * Implementations must be single-consumer: one runner owns readInput().
219
348
  */
220
349
  export interface TuiService {
221
- /** Render one session-log event (streamed as recorded). */
222
- event(event: SessionEvent, presentation?: TuiToolPresentation): void;
350
+ /** True when the provider owns a keyboard-driven terminal viewport. */
351
+ readonly interactive?: boolean;
352
+ /** Hand the terminal to the configured editor, then restore the live viewport. */
353
+ openFileInEditor?(path: string): void;
354
+ /** Add a durably stored file to the editable composer; sending remains explicit. */
355
+ stageFileAttachment?(file: FileAttachmentRef): void;
356
+ /**
357
+ * Render one session-log event (streamed as recorded).
358
+ *
359
+ * @param event - the appended event.
360
+ * @param presentation - tool presentation resolved for this event, when any.
361
+ * @param workspace - changed-file summary the host serves for a
362
+ * `workspace/changes` event; omitted when the plugin is unmounted or its
363
+ * recorder for the Session is gone, which renders the turn-only form.
364
+ */
365
+ event(event: SessionEvent, presentation?: TuiToolPresentation, workspace?: WorkspaceChangesSummary): void;
366
+ /**
367
+ * Attach a changed-file summary to a turn block that was already rendered
368
+ * without one.
369
+ *
370
+ * The Harness files the summary only after appending its event, so the
371
+ * controller resolves it on the next microtask and enriches the block here
372
+ * instead of replaying the event.
373
+ *
374
+ * @param turn - the turn whose block receives the summary.
375
+ * @param summary - the summary the host serves for that turn.
376
+ */
377
+ setWorkspaceSummary(turn: number, summary: WorkspaceChangesSummary): void;
223
378
  /** Fold one live `agent/assistant-stream` chunk into the transcript. */
224
379
  streamDelta(delta: StreamDelta): void;
225
- /** Update the status line liveness. */
226
- setStatus(status: TuiStatus): void;
380
+ /** Update status liveness; root signals also update pane lifecycle while inspecting a child. */
381
+ setStatus(status: TuiStatus, options?: {
382
+ root?: boolean;
383
+ }): void;
227
384
  /** Update the model and effective reasoning effort shown in the composer. */
228
385
  setModel(model: string, reasoningEffort?: string): void;
229
386
  /** Update the optional process-local Loop indicator in the fixed footer. */
@@ -249,16 +406,20 @@ export interface TuiService {
249
406
  toolCallContext(callId: string): string | undefined;
250
407
  /** Append a direct UI/command result without fabricating a session event. */
251
408
  notice(text: string, options?: TuiNoticeOptions): void;
252
- /** Append one successful plugin command result using the command-output surface. */
253
- commandOutput(command: string, text: string): void;
409
+ /** Append command output; preserve the viewport unless focus is requested. */
410
+ commandOutput(command: string, text: string, options?: TuiOutputOptions): void;
254
411
  /** Bind the product-owned Agent settings section; only one binding may be active. */
255
412
  bindAgentBehaviorSettings?(binding: TuiAgentBehaviorSettingsBinding): () => void;
256
413
  /** Currently applied preferences, for sibling rows that must honor them. */
257
414
  prefs(): TuiPrefs;
258
415
  /** Temporarily own the composer and collect one human answer. */
259
416
  prompt(request: TuiPrompt): Promise<string | null>;
260
- /** Replace the transcript when a new or resumed session becomes active. */
261
- replaceSession(events: readonly SessionEvent[], presentations?: ReadonlyMap<number, TuiToolPresentation>, status?: TuiStatus): void;
417
+ /**
418
+ * Replace the transcript while retaining earlier terminal output. Opening a
419
+ * session adds a boundary; /new adds one only after transcript content.
420
+ * Initial presentation and refreshes omit it. Defaults to opening a session.
421
+ */
422
+ replaceSession(events: readonly SessionEvent[], presentations?: ReadonlyMap<number, TuiToolPresentation>, status?: TuiStatus, reason?: TuiTranscriptReplacement): void;
262
423
  /** Update session identity, recent rows, projected controls, and aggregate figures. */
263
424
  setSession(info: {
264
425
  id: string;
@@ -292,6 +453,11 @@ export interface TuiService {
292
453
  * @returns disposer removing the listener.
293
454
  */
294
455
  onQueueEdit(listener: () => void): () => void;
456
+ /** Bind synchronous guidance admission; a rejected draft stays in the composer. */
457
+ setSteerHandler(handler: (text: string) => void): () => void;
458
+ readonly pendingInputs: TuiPendingInputs;
459
+ /** Open message management through the session owner without submitting the composer. */
460
+ setQueueHandler(handler: (signal: AbortSignal) => Promise<void>): () => void;
295
461
  /**
296
462
  * Subscribe to the idle double-Escape gesture that opens conversation rewind.
297
463
  * @returns disposer removing the listener.
@@ -326,8 +492,8 @@ export interface TuiService {
326
492
  }[]>): void;
327
493
  /** Replace the optional Harness image-admission check applied when a paste drafts an image. */
328
494
  setImageValidator(validate?: (image: TuiInputImage) => Promise<void>): void;
329
- /** Restore terminal state and settle a pending input read with null. */
330
- dispose(): void;
495
+ /** Restore the terminal and settle input immediately, then await bounded integration teardown. */
496
+ dispose(): void | Promise<void>;
331
497
  }
332
498
  declare module '@deepseek-ai/cordis' {
333
499
  interface Context {
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAA"}
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAA"}
@@ -4,16 +4,21 @@
4
4
  */
5
5
  import { spawn } from 'node:child_process';
6
6
  /** Writer used by `/copy`; injectable in tests. */
7
- export type ClipboardWriter = (text: string) => Promise<void>;
7
+ export type ClipboardWriter = (text: string) => Promise<ClipboardDelivery | void>;
8
+ /** A terminal request has no acknowledgement; distinguish it from a successful local write. */
9
+ export type ClipboardDelivery = 'confirmed' | 'requested';
8
10
  /** Reader used by raw-paste bindings; injectable in tests. */
9
11
  export type ClipboardReader = () => Promise<string>;
10
12
  /** Platform clipboard argv, or undefined when no tool is available. */
11
13
  export declare function clipboardCommand(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): readonly string[] | undefined;
12
- /**
13
- * Pipe `text` to the platform clipboard tool.
14
- * @param text - payload to copy.
15
- * @param spawnCmd - override for tests.
16
- */
17
- export declare function copyToClipboard(text: string, spawnCmd?: typeof spawn): Promise<void>;
14
+ /** Copy locally, and forward to the user's terminal in remote or tmux sessions. */
15
+ export declare function copyToClipboard(text: string, spawnCmd?: typeof spawn, options?: {
16
+ platform?: NodeJS.Platform;
17
+ env?: NodeJS.ProcessEnv;
18
+ output?: {
19
+ isTTY?: boolean;
20
+ write(chunk: string): unknown;
21
+ };
22
+ }): Promise<ClipboardDelivery>;
18
23
  /** Read raw UTF-8 text from the platform clipboard. */
19
24
  export declare function readFromClipboard(spawnCmd?: typeof spawn): Promise<string>;
@@ -15,35 +15,94 @@ export function clipboardCommand(platform = process.platform, env = process.env)
15
15
  return ['xclip', '-selection', 'clipboard'];
16
16
  return undefined;
17
17
  }
18
- /**
19
- * Pipe `text` to the platform clipboard tool.
20
- * @param text - payload to copy.
21
- * @param spawnCmd - override for tests.
22
- */
23
- export function copyToClipboard(text, spawnCmd = spawn) {
24
- const cmd = clipboardCommand();
25
- if (cmd === undefined)
26
- return Promise.reject(new Error('no clipboard tool'));
18
+ /** Bounded clipboard helper; payloads go through stdin rather than shell arguments. */
19
+ async function runCommand(command, text, spawnCmd) {
27
20
  return new Promise((resolve, reject) => {
28
- const child = spawnCmd(cmd[0] ?? '', cmd.slice(1), { stdio: ['pipe', 'ignore', 'ignore'] });
29
- const timer = setTimeout(() => {
30
- child.kill();
31
- reject(new Error('clipboard timed out'));
32
- }, 2000);
33
- child.on('error', (error) => {
34
- clearTimeout(timer);
35
- reject(error);
21
+ const child = spawnCmd(command[0] ?? '', command.slice(1), { stdio: ['pipe', 'pipe', 'ignore'], windowsHide: true });
22
+ let output = '';
23
+ const timer = setTimeout(() => { child.kill(); reject(new Error('clipboard timed out')); }, 2000);
24
+ child.on('error', error => { clearTimeout(timer); reject(error); });
25
+ child.stdout?.setEncoding('utf8');
26
+ child.stdout?.on('data', (chunk) => {
27
+ output += chunk;
28
+ if (output.length > 64 * 1024) {
29
+ child.kill();
30
+ reject(new Error('clipboard helper output too large'));
31
+ }
36
32
  });
37
- child.on('close', (code) => {
33
+ child.stdin?.on('error', error => { clearTimeout(timer); reject(error); });
34
+ child.on('close', code => {
38
35
  clearTimeout(timer);
39
36
  if (code === 0)
40
- resolve();
37
+ resolve(output);
41
38
  else
42
- reject(new Error('clipboard exited ' + String(code)));
39
+ reject(new Error('clipboard helper failed'));
43
40
  });
44
41
  child.stdin?.end(text);
45
42
  });
46
43
  }
44
+ /** Forward to an attached client in this pane's session, never an unrelated tmux client. */
45
+ async function copyThroughTmux(text, pane, spawnCmd) {
46
+ const setting = await runCommand(['tmux', 'show-options', '-gv', 'set-clipboard'], undefined, spawnCmd);
47
+ if (setting.trim() === 'off')
48
+ throw new Error('tmux clipboard is off');
49
+ const session = (await runCommand(['tmux', 'display-message', '-p', '-t', pane, '#{session_id}'], undefined, spawnCmd)).trim();
50
+ if (!session)
51
+ throw new Error('no tmux session');
52
+ const clients = await runCommand(['tmux', 'list-clients', '-t', session, '-F', '#{client_activity}\t#{client_name}'], undefined, spawnCmd);
53
+ const client = clients.trim().split('\n').map(line => {
54
+ const [time, ...name] = line.split('\t');
55
+ return { activity: Number(time), name: name.join('\t') };
56
+ }).filter(client => client.name !== '' && Number.isFinite(client.activity))
57
+ .sort((a, b) => b.activity - a.activity)[0]?.name;
58
+ if (!client)
59
+ throw new Error('no attached tmux client');
60
+ const capabilities = await runCommand(['tmux', 'show-messages', '-T', '-t', client], undefined, spawnCmd);
61
+ if (!capabilities.split('\n').some(line => /Ms: \(string\) \S/.test(line)))
62
+ throw new Error('tmux client cannot forward clipboard requests');
63
+ await runCommand(['tmux', 'load-buffer', '-w', '-t', client, '-'], text, spawnCmd);
64
+ }
65
+ /** Copy locally, and forward to the user's terminal in remote or tmux sessions. */
66
+ export async function copyToClipboard(text, spawnCmd = spawn, options = {}) {
67
+ const platform = options.platform ?? process.platform;
68
+ const env = options.env ?? process.env;
69
+ const output = options.output ?? process.stdout;
70
+ const remote = Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.SSH_TTY);
71
+ const cmd = clipboardCommand(platform, env);
72
+ let confirmed = false;
73
+ if (cmd !== undefined) {
74
+ try {
75
+ await runCommand(cmd, text, spawnCmd);
76
+ confirmed = true;
77
+ }
78
+ catch { /* Try terminal forwarding. */ }
79
+ }
80
+ const forwardingNeeded = remote || Boolean(env.TMUX || env.TMUX_PANE) || !confirmed;
81
+ if (!forwardingNeeded)
82
+ return 'confirmed';
83
+ const bytes = Buffer.byteLength(text, 'utf8');
84
+ if (bytes > 100_000) {
85
+ if (confirmed && !remote)
86
+ return 'confirmed';
87
+ throw new Error('text exceeds terminal clipboard limit');
88
+ }
89
+ if (env.TMUX_PANE) {
90
+ try {
91
+ await copyThroughTmux(text, env.TMUX_PANE, spawnCmd);
92
+ return confirmed && !remote ? 'confirmed' : 'requested';
93
+ }
94
+ catch { /* The outer terminal may allow direct OSC 52 passthrough. */ }
95
+ }
96
+ if (output.isTTY !== true) {
97
+ if (confirmed && !remote)
98
+ return 'confirmed';
99
+ throw new Error('no clipboard available');
100
+ }
101
+ const sequence = `\x1b]52;c;${Buffer.from(text, 'utf8').toString('base64')}\x07`;
102
+ output.write(env.TMUX || env.TMUX_PANE
103
+ ? `\x1bPtmux;${sequence.replaceAll('\x1b', '\x1b\x1b')}\x1b\\` : sequence);
104
+ return confirmed && !remote ? 'confirmed' : 'requested';
105
+ }
47
106
  /** Read raw UTF-8 text from the platform clipboard. */
48
107
  export function readFromClipboard(spawnCmd = spawn) {
49
108
  const cmd = process.platform === 'darwin'
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../src/input/clipboard.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAQ1C,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAC9B,WAA4B,OAAO,CAAC,QAAQ,EAC5C,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC5C,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACzC,IAAI,GAAG,CAAC,eAAe;QAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC3C,IAAI,GAAG,CAAC,OAAO;QAAE,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAA;IAC5D,OAAO,SAAS,CAAA;AAClB,CAA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@@
1
+ /** File draft markers retain durable references without retaining file bytes. */
2
+ import type { FileAttachmentRef } from '@deepseek-ai/dsh-attachment';
3
+ export declare function fileMarker(file: FileAttachmentRef, ordinal: number): string;
4
+ export declare class ComposerFiles {
5
+ #private;
6
+ private readonly input;
7
+ get revision(): number;
8
+ constructor(input: {
9
+ text(): string;
10
+ append(text: string): void;
11
+ });
12
+ add(file: FileAttachmentRef): void;
13
+ reconcile(): void;
14
+ copies(): FileAttachmentRef[];
15
+ clear(): void;
16
+ snapshot(text: string): {
17
+ entries: {
18
+ file: FileAttachmentRef;
19
+ marker: string;
20
+ }[];
21
+ next: number;
22
+ };
23
+ restoreSnapshot(snapshot: ReturnType<ComposerFiles['snapshot']>): void;
24
+ text(text: string): string;
25
+ restore(files?: readonly FileAttachmentRef[]): void;
26
+ }
@@ -0,0 +1,50 @@
1
+ /** File draft markers retain durable references without retaining file bytes. */
2
+ export function fileMarker(file, ordinal) {
3
+ return `[File:${ordinal} ${JSON.stringify(file.name)}]`;
4
+ }
5
+ export class ComposerFiles {
6
+ input;
7
+ #files = [];
8
+ #next = 0;
9
+ #revision = 0;
10
+ get revision() { return this.#revision; }
11
+ constructor(input) {
12
+ this.input = input;
13
+ }
14
+ add(file) {
15
+ this.reconcile();
16
+ if (this.#files.some(item => item.file.attachmentId === file.attachmentId && item.file.name === file.name))
17
+ return;
18
+ const marker = fileMarker(file, ++this.#next);
19
+ this.#files.push({ file, marker });
20
+ this.#revision++;
21
+ this.input.append(marker);
22
+ }
23
+ reconcile() {
24
+ const files = this.#files.filter(item => this.input.text().includes(item.marker));
25
+ if (files.length !== this.#files.length)
26
+ this.#revision++;
27
+ this.#files = files;
28
+ }
29
+ copies() { this.reconcile(); return this.#files.map(item => item.file); }
30
+ clear() { this.#files = []; this.#next = 0; this.#revision++; }
31
+ snapshot(text) {
32
+ return { entries: this.#files.filter(item => text.includes(item.marker)).map(item => ({ file: { ...item.file }, marker: item.marker })), next: this.#next };
33
+ }
34
+ restoreSnapshot(snapshot) {
35
+ this.#files = snapshot.entries.map(item => ({ file: { ...item.file }, marker: item.marker }));
36
+ this.#next = snapshot.next;
37
+ this.#revision++;
38
+ }
39
+ text(text) {
40
+ this.reconcile();
41
+ if (this.#files.length === 0)
42
+ return text;
43
+ for (const item of this.#files)
44
+ text = text.replaceAll(item.marker, '');
45
+ return text.trim();
46
+ }
47
+ restore(files = []) { this.clear(); for (const file of files)
48
+ this.add(file); }
49
+ }
50
+ //# sourceMappingURL=composer-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composer-files.js","sourceRoot":"","sources":["../../src/input/composer-files.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAIjF,MAAM,UAAU,UAAU,CAAC,IAAuB,EAAE,OAAe;IACjE,OAAO,SAAS,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;AACzD,CAAC;AAED,MAAM,OAAO,aAAa;IAKK;IAJ7B,MAAM,GAAkD,EAAE,CAAA;IAC1D,KAAK,GAAG,CAAC,CAAA;IACT,SAAS,GAAG,CAAC,CAAA;IACb,IAAI,QAAQ,KAAa,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IAChD,YAA6B,KAAqD;QAArD,UAAK,GAAL,KAAK,CAAgD;IAAG,CAAC;IACtF,GAAG,CAAC,IAAuB;QACzB,IAAI,CAAC,SAAS,EAAE,CAAA;QAChB,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;YAAE,OAAM;QAClH,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAA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AAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QAC7F,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAA;QAC1B,IAAI,CAAC,SAAS,EAAE,CAAA;IAClB,CAAC;IACD,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,SAAS,EAAE,CAAA;QAChB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACzC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACvE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAA;IACpB,CAAC;IACD,OAAO,CAAC,QAAsC,EAAE,IAAU,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;CACnH"}
@@ -0,0 +1,21 @@
1
+ export declare const EDITOR_IDS: readonly ["auto", "code", "cursor", "codium", "nvim", "vim", "nano", "vi"];
2
+ export type EditorId = typeof EDITOR_IDS[number];
3
+ export interface EditorChoice {
4
+ id: EditorId;
5
+ label: string;
6
+ }
7
+ export interface EditorCommand {
8
+ command: string;
9
+ args: string[];
10
+ env?: NodeJS.ProcessEnv;
11
+ }
12
+ export interface EditorDiscovery {
13
+ platform: NodeJS.Platform;
14
+ env: NodeJS.ProcessEnv;
15
+ home: string;
16
+ executable(path: string): boolean;
17
+ }
18
+ /** Auto honors existing environment preferences before choosing an installed editor. */
19
+ export declare function resolveEditor(id?: EditorId, discovery?: EditorDiscovery): EditorCommand;
20
+ /** Choices contain installed applications and preserve a missing saved selection. */
21
+ export declare function discoverEditors(selected?: EditorId, discovery?: EditorDiscovery): EditorChoice[];