@xp266/dshtui 0.1.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 (159) hide show
  1. package/bin/dshtui.js +65 -0
  2. package/cordis.patch.yml +81 -0
  3. package/lib/contract/index.d.mts +2 -0
  4. package/lib/contract/index.mjs +5 -0
  5. package/lib/dialog.d.mts +156 -0
  6. package/lib/dialog.mjs +3 -0
  7. package/lib/index-DqnaSXqP.d.mts +823 -0
  8. package/lib/index.d.mts +17 -0
  9. package/lib/index.mjs +11404 -0
  10. package/lib/prod-react-Dzof4qJx.mjs +4 -0
  11. package/lib/surface-DdxzIgIY.mjs +3126 -0
  12. package/lib/vendor.d.mts +3 -0
  13. package/lib/vendor.mjs +4 -0
  14. package/package.json +128 -0
  15. package/src/apply-theme.ts +8 -0
  16. package/src/boot-log.ts +35 -0
  17. package/src/chat/blocks.ts +41 -0
  18. package/src/chat/bridge.ts +1076 -0
  19. package/src/chat/builtin-tool-views.ts +53 -0
  20. package/src/chat/chat-face.ts +16 -0
  21. package/src/chat/chat-nodes.ts +53 -0
  22. package/src/chat/efforts.ts +4 -0
  23. package/src/chat/interactions.ts +329 -0
  24. package/src/chat/models.ts +263 -0
  25. package/src/chat/partial-json.ts +125 -0
  26. package/src/chat/presets.ts +26 -0
  27. package/src/chat/question-view.ts +106 -0
  28. package/src/chat/retry-status.ts +33 -0
  29. package/src/chat/session-groups.ts +34 -0
  30. package/src/chat/session-list.ts +311 -0
  31. package/src/chat/store.ts +636 -0
  32. package/src/chat/todo-view.ts +66 -0
  33. package/src/chat/tool-view.ts +311 -0
  34. package/src/chat/tool-views.ts +114 -0
  35. package/src/contract/index.ts +704 -0
  36. package/src/contract/upstream.ts +165 -0
  37. package/src/core/caret-nonce.ts +19 -0
  38. package/src/core/composer-layout.ts +65 -0
  39. package/src/core/edit.ts +152 -0
  40. package/src/core/field-view.ts +52 -0
  41. package/src/core/fields.ts +185 -0
  42. package/src/core/metrics.ts +26 -0
  43. package/src/core/paste.ts +149 -0
  44. package/src/core/segments.ts +112 -0
  45. package/src/core/text.ts +290 -0
  46. package/src/dialog.ts +11 -0
  47. package/src/env.ts +38 -0
  48. package/src/harness-home.ts +22 -0
  49. package/src/hot-theme.ts +56 -0
  50. package/src/index.tsx +185 -0
  51. package/src/kernel/registry.ts +102 -0
  52. package/src/kernel/surface.ts +33 -0
  53. package/src/log.ts +249 -0
  54. package/src/model/message.ts +89 -0
  55. package/src/model/selection.ts +63 -0
  56. package/src/performance-guard.ts +28 -0
  57. package/src/runtime/prod-react.ts +10 -0
  58. package/src/terminal/background.ts +66 -0
  59. package/src/terminal/capabilities.ts +54 -0
  60. package/src/terminal/clipboard-backends.ts +69 -0
  61. package/src/terminal/clipboard.ts +161 -0
  62. package/src/terminal/cursor-shape.ts +13 -0
  63. package/src/terminal/glyphs.ts +44 -0
  64. package/src/terminal/mouse.ts +154 -0
  65. package/src/terminal/probe.ts +61 -0
  66. package/src/terminal/screen.ts +349 -0
  67. package/src/theme-settings.ts +31 -0
  68. package/src/theme.ts +319 -0
  69. package/src/ui/app.tsx +454 -0
  70. package/src/ui/chrome/caps.tsx +9 -0
  71. package/src/ui/chrome/hint-service.ts +87 -0
  72. package/src/ui/chrome/input-status.ts +27 -0
  73. package/src/ui/chrome/key-gate.tsx +29 -0
  74. package/src/ui/chrome/status-bar.tsx +147 -0
  75. package/src/ui/contributions.ts +47 -0
  76. package/src/ui/dialog/defaults-dialog.tsx +152 -0
  77. package/src/ui/dialog/dialog-item.tsx +38 -0
  78. package/src/ui/dialog/dialog.tsx +386 -0
  79. package/src/ui/dialog/effort-dialog.tsx +45 -0
  80. package/src/ui/dialog/geometry.ts +131 -0
  81. package/src/ui/dialog/items.ts +124 -0
  82. package/src/ui/dialog/list-dialog.tsx +63 -0
  83. package/src/ui/dialog/models-dialog.tsx +203 -0
  84. package/src/ui/dialog/presets-dialog.tsx +46 -0
  85. package/src/ui/dialog/providers-dialog.tsx +313 -0
  86. package/src/ui/dialog/sessions-dialog.tsx +163 -0
  87. package/src/ui/dialog/sizes.ts +7 -0
  88. package/src/ui/dialog/status-lines.ts +11 -0
  89. package/src/ui/dialog/todo-dialog.tsx +29 -0
  90. package/src/ui/dialog/use-dialog-input.ts +186 -0
  91. package/src/ui/extension-point.ts +188 -0
  92. package/src/ui/home-logo.ts +132 -0
  93. package/src/ui/hooks/use-async-action.ts +25 -0
  94. package/src/ui/hooks/use-async-list.ts +71 -0
  95. package/src/ui/hooks/use-caret.ts +24 -0
  96. package/src/ui/hooks/use-chat-events.ts +153 -0
  97. package/src/ui/hooks/use-mouse-selection.ts +352 -0
  98. package/src/ui/hooks/use-scroll.ts +49 -0
  99. package/src/ui/hooks/use-terminal-size.ts +20 -0
  100. package/src/ui/input/commands.ts +118 -0
  101. package/src/ui/input/composer-bus.ts +14 -0
  102. package/src/ui/input/composer-fields.ts +111 -0
  103. package/src/ui/input/composer-keys.ts +21 -0
  104. package/src/ui/input/composer-paste.ts +20 -0
  105. package/src/ui/input/input-bar.tsx +279 -0
  106. package/src/ui/input/use-composer.ts +495 -0
  107. package/src/ui/key-arbiter.ts +37 -0
  108. package/src/ui/keymap.ts +15 -0
  109. package/src/ui/layout-service.ts +77 -0
  110. package/src/ui/message/layout.ts +763 -0
  111. package/src/ui/message/md/block.ts +247 -0
  112. package/src/ui/message/md/engine.ts +430 -0
  113. package/src/ui/message/md/extensions.ts +58 -0
  114. package/src/ui/message/md/highlight.ts +626 -0
  115. package/src/ui/message/md/index.ts +14 -0
  116. package/src/ui/message/md/inline.ts +97 -0
  117. package/src/ui/message/md/palette.ts +87 -0
  118. package/src/ui/message/message-list.tsx +69 -0
  119. package/src/ui/message/message-row.tsx +137 -0
  120. package/src/ui/message/message-views.ts +16 -0
  121. package/src/ui/message/renderers.ts +39 -0
  122. package/src/ui/message/tool-diff.ts +188 -0
  123. package/src/ui/message/warmup.ts +41 -0
  124. package/src/ui/message/wave.ts +98 -0
  125. package/src/ui/overlay.ts +22 -0
  126. package/src/ui/panels/approval-panel.tsx +193 -0
  127. package/src/ui/panels/exports.ts +3 -0
  128. package/src/ui/panels/question-model.ts +424 -0
  129. package/src/ui/panels/question-panel.tsx +154 -0
  130. package/src/ui/panels/surface.tsx +106 -0
  131. package/src/ui/panels-builtin.tsx +86 -0
  132. package/src/ui/pointer/builtins.ts +281 -0
  133. package/src/ui/pointer/registry.ts +25 -0
  134. package/src/ui/region.tsx +31 -0
  135. package/src/ui/selection/service.ts +92 -0
  136. package/src/ui/selection-registry.ts +88 -0
  137. package/src/ui/selection.tsx +148 -0
  138. package/src/ui/spinner-tick.tsx +24 -0
  139. package/src/ui/use-available-windows.ts +31 -0
  140. package/src/ui/widgets/actions.tsx +84 -0
  141. package/src/ui/widgets/button.tsx +57 -0
  142. package/src/ui/widgets/checkbox.tsx +58 -0
  143. package/src/ui/widgets/header.tsx +36 -0
  144. package/src/ui/widgets/index.ts +8 -0
  145. package/src/ui/widgets/input.tsx +76 -0
  146. package/src/ui/widgets/registry.ts +32 -0
  147. package/src/ui/widgets/search.tsx +59 -0
  148. package/src/ui/widgets/select.tsx +97 -0
  149. package/src/ui/widgets/static.tsx +37 -0
  150. package/src/ui/widgets/types.ts +1 -0
  151. package/src/ui/window-services-bridge.ts +71 -0
  152. package/src/ui/window-services.ts +20 -0
  153. package/src/ui/windows/models-window.tsx +15 -0
  154. package/src/ui/windows/providers-window.tsx +14 -0
  155. package/src/ui/windows/service-window.tsx +18 -0
  156. package/src/ui/windows/sessions-window.tsx +25 -0
  157. package/src/ui/windows-builtin.tsx +94 -0
  158. package/src/ui/windows.ts +18 -0
  159. package/src/vendor.ts +12 -0
@@ -0,0 +1,823 @@
1
+ import { ComponentType, ReactNode, Ref } from "react";
2
+ import { Token } from "marked";
3
+ import { ContentBlock } from "@deepseek-ai/dsh-llm";
4
+ import { SessionEvent } from "@deepseek-ai/dsh-session";
5
+ //#region src/core/segments.d.ts
6
+ interface MarkStyle {
7
+ color?: string;
8
+ background?: string;
9
+ bold?: boolean;
10
+ italic?: boolean;
11
+ strike?: boolean;
12
+ underline?: boolean;
13
+ }
14
+ interface Segment {
15
+ text: string;
16
+ style: MarkStyle;
17
+ }
18
+ //#endregion
19
+ //#region src/ui/message/md/palette.d.ts
20
+ interface MdPalette {
21
+ plain: MarkStyle;
22
+ bold: MarkStyle;
23
+ italic: MarkStyle;
24
+ strike: MarkStyle;
25
+ link: MarkStyle;
26
+ inlineCode: MarkStyle;
27
+ quoteBar: MarkStyle;
28
+ hr: MarkStyle;
29
+ listMarker: MarkStyle;
30
+ taskDone: MarkStyle;
31
+ taskTodo: MarkStyle;
32
+ heading(level: number): MarkStyle;
33
+ codePlain: MarkStyle;
34
+ codeFallback: MarkStyle;
35
+ }
36
+ //#endregion
37
+ //#region src/core/paste.d.ts
38
+ type PendingImage = {
39
+ kind: 'path';
40
+ path: string;
41
+ } | {
42
+ kind: 'data';
43
+ data: Uint8Array;
44
+ mediaType: string;
45
+ name?: string;
46
+ };
47
+ //#endregion
48
+ //#region src/model/selection.d.ts
49
+ interface LineSelection {
50
+ anchorRow: number;
51
+ anchorCol: number;
52
+ focusRow: number;
53
+ focusCol: number;
54
+ inMessage: boolean;
55
+ }
56
+ //#endregion
57
+ //#region src/model/message.d.ts
58
+ interface BubbleMessage {
59
+ kind: 'bubble';
60
+ id: string;
61
+ role: 'user' | 'assistant' | 'error';
62
+ content: string;
63
+ streaming?: boolean;
64
+ origin?: 'command';
65
+ }
66
+ interface CollapsibleMessage {
67
+ kind: 'collapsible';
68
+ id: string;
69
+ label: string;
70
+ body: string;
71
+ running: boolean;
72
+ collapsed: boolean;
73
+ bodyCol?: number;
74
+ thinking?: boolean;
75
+ streaming?: boolean;
76
+ startedAt?: number;
77
+ }
78
+ type DiffLineKind$1 = 'ctx' | 'del' | 'add';
79
+ interface DiffLine$1 {
80
+ kind: DiffLineKind$1;
81
+ text: string;
82
+ }
83
+ /**
84
+ * Generic tool card: every tool shares one bubble shape. The header carries
85
+ * the tool name plus a parameter summary; the body shows the full arguments
86
+ * and result (or a diff / read window when the tool protocol produced one).
87
+ * No per-tool customization exists at this layer.
88
+ */
89
+ interface ToolCardMessage {
90
+ kind: 'tool-card';
91
+ id: string;
92
+ tool: string;
93
+ /** Header text: tool name plus optional parameter summary. */
94
+ label: string;
95
+ /** Full call-side arguments, rendered verbatim while running (and after, for full disclosure). */
96
+ argsBody: string;
97
+ /** Full settled result text from the tool protocol. */
98
+ resultBody?: string;
99
+ bodyCol?: number;
100
+ diff?: {
101
+ path: string;
102
+ hunks: readonly (readonly DiffLine$1[])[];
103
+ backgrounds?: boolean;
104
+ };
105
+ /** Structured read window replacing the text result body. */
106
+ read?: ToolReadView;
107
+ /** True when the settled result reported isError without a structured error; the result text renders as the error. */
108
+ failed?: boolean;
109
+ /** Sub-calls dispatched under this call (code mode); rendered as a child list. */
110
+ nested?: readonly ToolCardMessage[];
111
+ error?: string;
112
+ exitCode?: number;
113
+ signal?: string;
114
+ running: boolean;
115
+ streaming?: boolean;
116
+ startedAt?: number;
117
+ }
118
+ interface CompactionMessage {
119
+ kind: 'compaction';
120
+ id: string;
121
+ compactionId: string;
122
+ running: boolean;
123
+ summary: string;
124
+ error?: string;
125
+ streaming?: boolean;
126
+ }
127
+ interface HomeLogoMessage {
128
+ kind: 'home-logo';
129
+ id: string;
130
+ /** Artwork lines after culling; empty when the terminal cannot fit the logo. */
131
+ lines: readonly string[];
132
+ /** One gradient color per artwork line, aligned with `lines`. */
133
+ colors: readonly string[];
134
+ /** Version banner lines rendered under the artwork inside the same bubble. */
135
+ info: readonly string[];
136
+ }
137
+ type MessageKind = 'bubble' | 'collapsible' | 'tool-card' | 'compaction' | 'custom' | 'home-logo';
138
+ type Message = BubbleMessage | CollapsibleMessage | ToolCardMessage | CompactionMessage | CustomMessage | HomeLogoMessage;
139
+ //#endregion
140
+ //#region src/terminal/mouse.d.ts
141
+ type MouseEventType = 'down' | 'up' | 'drag' | 'move' | 'scroll';
142
+ interface MouseEventData {
143
+ type: MouseEventType;
144
+ button: number;
145
+ x: number;
146
+ y: number;
147
+ modifiers: {
148
+ shift: boolean;
149
+ alt: boolean;
150
+ ctrl: boolean;
151
+ };
152
+ scrollDirection?: 'up' | 'down';
153
+ }
154
+ //#endregion
155
+ //#region src/ui/hooks/use-scroll.d.ts
156
+ interface ScrollSnapshot {
157
+ top: number;
158
+ maxScroll: number;
159
+ }
160
+ //#endregion
161
+ //#region src/contract/index.d.ts
162
+ interface WindowHandle {
163
+ clickAt(y: number, x: number): void;
164
+ wheelAt(y: number, dir: -1 | 1): boolean;
165
+ }
166
+ interface WindowProps {
167
+ open: boolean;
168
+ onClose(): void;
169
+ handleRef?: Ref<WindowHandle>;
170
+ }
171
+ interface WindowCommandSpec {
172
+ name: string;
173
+ description: string;
174
+ }
175
+ interface WindowContribution {
176
+ id: string;
177
+ title: string;
178
+ component: ComponentType<WindowProps>;
179
+ order?: number;
180
+ command?: WindowCommandSpec;
181
+ required?: readonly string[];
182
+ }
183
+ interface TuiWindowsFace {
184
+ register(contribution: WindowContribution): () => void;
185
+ }
186
+ interface StatusLineContribution {
187
+ id: string;
188
+ order?: number;
189
+ render(props: {
190
+ columns: number;
191
+ }): string;
192
+ }
193
+ interface OverlayContribution {
194
+ id: string;
195
+ render(props: {
196
+ onClose(): void;
197
+ }): ReactNode;
198
+ }
199
+ interface TuiServicesFace {
200
+ register(name: string, service: unknown): () => void;
201
+ }
202
+ interface PaintArgs<I> {
203
+ item: I;
204
+ focused: boolean;
205
+ subCol: number;
206
+ cursor?: number;
207
+ width: number;
208
+ y: number;
209
+ x: number;
210
+ pressed: 'left' | 'right' | null;
211
+ clip: number;
212
+ }
213
+ interface ClickHit {
214
+ localX: number;
215
+ localY: number;
216
+ width: number;
217
+ }
218
+ interface ClickActions {
219
+ focus(subCol: number): void;
220
+ flash(side: 'left' | 'right'): void;
221
+ }
222
+ interface WidgetKeyApi {
223
+ cursor: number;
224
+ subCol: number;
225
+ setCursor(next: number): void;
226
+ navigate(direction: 'up' | 'down' | 'left' | 'right'): void;
227
+ }
228
+ interface WidgetDef<I extends {
229
+ type: string;
230
+ }> {
231
+ height(item: I, width: number): number;
232
+ paintWidth(item: I): number;
233
+ render(paint: PaintArgs<I>): ReactNode;
234
+ searchTexts?(item: I, searchRight: boolean): string[];
235
+ stops?(item: I): number;
236
+ fullRowFocus?: boolean;
237
+ selectable?: boolean;
238
+ editable?: boolean;
239
+ caret?(item: I, cursor: number, width: number): {
240
+ dy: number;
241
+ dx: number;
242
+ };
243
+ onLeftRight?(item: I, direction: -1 | 1, api: WidgetKeyApi): boolean;
244
+ onEnter?(item: I, api: WidgetKeyApi): boolean;
245
+ onSpace?(item: I): void;
246
+ onClick?(item: I, hit: ClickHit, actions: ClickActions): boolean;
247
+ activate?(item: I): void;
248
+ }
249
+ interface TuiWidgetsFace {
250
+ register<I extends {
251
+ type: string;
252
+ }>(type: I['type'], def: WidgetDef<I>): () => void;
253
+ }
254
+ /**
255
+ * Open registry for plugin dialog item kinds. Declaration-merge a property
256
+ * named after your item kind (any key) whose value is the item object type
257
+ * carrying a `type` discriminant; the merged types join the `DialogItem`
258
+ * union so your widget def stays fully typed.
259
+ */
260
+ interface DialogItemKinds {}
261
+ interface ThemePaletteContribution {
262
+ id: string;
263
+ order?: number;
264
+ /** Which theme mode(s) this palette patch applies to; defaults to 'both'. */
265
+ mode?: 'dark' | 'light' | 'both';
266
+ /** Color name (a `Theme` palette key) to replacement hex/text value. */
267
+ colors: Readonly<Record<string, string>>;
268
+ }
269
+ interface TuiPaletteFace {
270
+ register(contribution: ThemePaletteContribution): () => void;
271
+ /** Read a palette color by key, including plugin-contributed keys. */
272
+ color(key: string): string | undefined;
273
+ }
274
+ interface ClipboardBackendContribution {
275
+ id: string;
276
+ order?: number;
277
+ readText?(): string | undefined | Promise<string | undefined>;
278
+ readImage?(): {
279
+ data: Uint8Array;
280
+ mediaType: string;
281
+ } | undefined | Promise<{
282
+ data: Uint8Array;
283
+ mediaType: string;
284
+ } | undefined>;
285
+ writeText?(text: string): boolean;
286
+ }
287
+ interface TuiClipboardFace {
288
+ register(contribution: ClipboardBackendContribution): () => void;
289
+ }
290
+ interface TuiKey {
291
+ upArrow: boolean;
292
+ downArrow: boolean;
293
+ leftArrow: boolean;
294
+ rightArrow: boolean;
295
+ pageDown: boolean;
296
+ pageUp: boolean;
297
+ home?: boolean;
298
+ end?: boolean;
299
+ return: boolean;
300
+ escape: boolean;
301
+ ctrl: boolean;
302
+ shift: boolean;
303
+ tab: boolean;
304
+ backspace: boolean;
305
+ delete: boolean;
306
+ meta: boolean;
307
+ }
308
+ interface KeyBindingContribution {
309
+ id: string;
310
+ order?: number;
311
+ /**
312
+ * Invoked for every terminal key event before builtin shell handling.
313
+ * Return true to consume the key; later bindings and builtin handling
314
+ * are skipped for that event.
315
+ */
316
+ handle(input: string, key: TuiKey): boolean;
317
+ }
318
+ interface TuiKeymapFace {
319
+ register(contribution: KeyBindingContribution): () => void;
320
+ }
321
+ interface PointerUiContext {
322
+ dialogOpen: boolean;
323
+ panelActive: boolean;
324
+ hintRegion: {
325
+ top: number;
326
+ bottom: number;
327
+ } | null;
328
+ rows: number;
329
+ columns: number;
330
+ messageHeight: number;
331
+ inputHeight: number;
332
+ scrollTop: number;
333
+ getScroll(): ScrollSnapshot;
334
+ }
335
+ interface PointerSession {
336
+ getSelection(): LineSelection | null;
337
+ setSelection(next: LineSelection | null): void;
338
+ scroll(next: number): void;
339
+ /** Start (-1/1) or stop (0) drag-follow auto scrolling of the message area. */
340
+ autoScroll(direction: -1 | 1 | 0): void;
341
+ }
342
+ interface PointerEventFrame {
343
+ event: MouseEventData;
344
+ session: PointerSession;
345
+ ui: PointerUiContext;
346
+ }
347
+ interface PointerHandlerContribution {
348
+ id: string;
349
+ order?: number;
350
+ /** Return true to claim the gesture; drag and up are then routed here exclusively. */
351
+ onDown(frame: PointerEventFrame): boolean;
352
+ onDrag?(frame: PointerEventFrame): void;
353
+ onUp?(frame: PointerEventFrame): void;
354
+ onWheel?(frame: PointerEventFrame): boolean;
355
+ }
356
+ /** Builtin gesture handlers live at order 100..190; see registerPointerHandler. */
357
+ declare const POINTER_PLUGIN_ORDER = 300;
358
+ interface HintMatcherContribution {
359
+ id: string;
360
+ order?: number;
361
+ match(entries: readonly HintEntry[], context: {
362
+ value: string;
363
+ query: string;
364
+ }): HintEntry[] | null;
365
+ }
366
+ interface HintEntry {
367
+ command: string;
368
+ description: string;
369
+ hint?: string;
370
+ }
371
+ interface HintArgsContribution {
372
+ id: string;
373
+ order?: number;
374
+ args(name: string): string[] | null | Promise<string[] | null>;
375
+ }
376
+ interface TuiHintFace {
377
+ matchers: {
378
+ register(contribution: HintMatcherContribution): () => void;
379
+ };
380
+ args: {
381
+ register(contribution: HintArgsContribution): () => void;
382
+ };
383
+ }
384
+ interface TuiPointerFace {
385
+ register(contribution: PointerHandlerContribution): () => void;
386
+ }
387
+ interface SelectionExtractContext {
388
+ messageText(sel: LineSelection): string;
389
+ chromeText(sel: LineSelection): string;
390
+ }
391
+ interface SelectionDomainContribution {
392
+ id: string;
393
+ order?: number;
394
+ hit(sel: LineSelection): boolean;
395
+ extract(sel: LineSelection, context: SelectionExtractContext): string | null;
396
+ }
397
+ interface SelectionTransformerContribution {
398
+ id: string;
399
+ order?: number;
400
+ transform(text: string): string;
401
+ }
402
+ interface SelectionClipboardContribution {
403
+ id: string;
404
+ order?: number;
405
+ copy(text: string): boolean;
406
+ }
407
+ interface TuiSelectionFace {
408
+ domains: {
409
+ register(contribution: SelectionDomainContribution): () => void;
410
+ };
411
+ transformers: {
412
+ register(contribution: SelectionTransformerContribution): () => void;
413
+ };
414
+ clipboard: {
415
+ register(contribution: SelectionClipboardContribution): () => void;
416
+ };
417
+ }
418
+ interface InputStatusContext {
419
+ columns: number;
420
+ rows: number;
421
+ busy: boolean;
422
+ running: boolean;
423
+ modelName: string;
424
+ permissionMode: string;
425
+ effortName: string | undefined;
426
+ presetName: string | undefined;
427
+ }
428
+ interface InputStatusPart {
429
+ text: string;
430
+ color?: string;
431
+ bold?: boolean;
432
+ }
433
+ interface InputStatusContribution {
434
+ id: string;
435
+ order?: number;
436
+ /** Return one part, an array of parts, or null to contribute nothing this render. */
437
+ render(context: InputStatusContext): InputStatusPart | InputStatusPart[] | null;
438
+ }
439
+ interface HomeLogoContribution {
440
+ id: string;
441
+ order?: number;
442
+ /** Logo artwork rendered as the first chat-styled bubble on the home page, one string per terminal row. */
443
+ lines: readonly string[];
444
+ }
445
+ interface TuiHomeLogoFace {
446
+ register(contribution: HomeLogoContribution): () => void;
447
+ }
448
+ interface TuiChromeFace {
449
+ statusLine: {
450
+ register(contribution: StatusLineContribution): () => void;
451
+ };
452
+ overlays: {
453
+ register(contribution: OverlayContribution): () => void;
454
+ };
455
+ widgets: TuiWidgetsFace;
456
+ palette: TuiPaletteFace;
457
+ keys: TuiKeymapFace;
458
+ inputStatus: {
459
+ register(contribution: InputStatusContribution): () => void;
460
+ };
461
+ logo: TuiHomeLogoFace;
462
+ }
463
+ interface CommandDef {
464
+ id: string;
465
+ command: string;
466
+ description: string;
467
+ hint?: string;
468
+ args?: readonly string[];
469
+ run?: () => void;
470
+ order?: number;
471
+ }
472
+ interface TuiCommandsFace {
473
+ register(def: CommandDef): () => void;
474
+ }
475
+ type DiffLineKind = 'ctx' | 'del' | 'add';
476
+ interface DiffLine {
477
+ kind: DiffLineKind;
478
+ text: string;
479
+ }
480
+ type DiffHunk = readonly DiffLine[];
481
+ interface ToolViewDiff {
482
+ path: string;
483
+ hunks: readonly DiffHunk[];
484
+ /**
485
+ * Paint whole-line red/green backgrounds behind removed and added lines.
486
+ * Defaults to true when any line is a removal, false for pure additions.
487
+ * Set it explicitly to override that heuristic.
488
+ */
489
+ backgrounds?: boolean;
490
+ }
491
+ interface ToolResultView {
492
+ content: readonly ContentBlock[];
493
+ isError: boolean;
494
+ meta?: unknown;
495
+ }
496
+ interface ToolViewCallContext {
497
+ tool: string;
498
+ callId: string;
499
+ args: unknown;
500
+ argumentsRaw: string;
501
+ cwd: string;
502
+ }
503
+ interface ToolViewResultContext {
504
+ tool: string;
505
+ callId: string;
506
+ args: unknown;
507
+ result: ToolResultView;
508
+ cwd: string;
509
+ }
510
+ interface ToolCallPresentation {
511
+ label?: string;
512
+ body?: string;
513
+ bodyCol?: number;
514
+ diff?: ToolViewDiff;
515
+ }
516
+ interface ToolResultPresentation {
517
+ kind: 'replace' | 'append';
518
+ text: string;
519
+ /** Header replacement applied when kind is 'replace' ('' clears the suffix). */
520
+ label?: string;
521
+ /** Call-side body replacement ('' clears it), for settled views that supersede the args. */
522
+ argsBody?: string;
523
+ exitCode?: number;
524
+ signal?: string;
525
+ bodyCol?: number;
526
+ diff?: ToolViewDiff;
527
+ /** Structured read window; rendered as a numbered code card. */
528
+ read?: ToolReadView;
529
+ }
530
+ /** One numbered line of a structured read result. */
531
+ interface ToolReadLine {
532
+ number: number;
533
+ text: string;
534
+ }
535
+ /** The `card: 'read'` projection: a numbered file window plus its totals. */
536
+ interface ToolReadView {
537
+ path?: string;
538
+ lines: readonly ToolReadLine[];
539
+ /** 1-based first line of the window when it carries no lines. */
540
+ offset?: number;
541
+ /** Total lines in the file, for a "lines N of M" footer. */
542
+ totalLines?: number;
543
+ /** Syntax highlighting hint (e.g. `ts`). */
544
+ lang?: string;
545
+ }
546
+ interface ToolViewContribution {
547
+ tool: string;
548
+ order?: number;
549
+ /**
550
+ * When true, the builtin presenter never runs for this tool: a call or
551
+ * result handler returning undefined renders as a bare card instead of
552
+ * falling through to the builtin presentation.
553
+ */
554
+ takeover?: boolean;
555
+ call?(context: ToolViewCallContext): ToolCallPresentation | undefined;
556
+ result?(context: ToolViewResultContext): ToolResultPresentation | undefined;
557
+ }
558
+ interface TuiToolsFace {
559
+ register(contribution: ToolViewContribution): () => void;
560
+ }
561
+ interface CustomMessage {
562
+ kind: 'custom';
563
+ id: string;
564
+ view: string;
565
+ data: unknown;
566
+ running?: boolean;
567
+ streaming?: boolean;
568
+ }
569
+ type CustomMessageSeed = Omit<CustomMessage, 'kind' | 'id'>;
570
+ interface ChatNodeDefinition {
571
+ id: string;
572
+ order?: number;
573
+ match(event: SessionEvent): boolean;
574
+ start(event: SessionEvent): CustomMessageSeed;
575
+ update?(event: SessionEvent, message: CustomMessage): CustomMessageSeed | null;
576
+ }
577
+ interface MessageViewContext {
578
+ message: CustomMessage;
579
+ width: number;
580
+ }
581
+ interface MessageViewRender {
582
+ label?: string;
583
+ lines: readonly string[];
584
+ wrap?: boolean;
585
+ muted?: boolean;
586
+ }
587
+ interface MessageViewContribution {
588
+ view: string;
589
+ order?: number;
590
+ render(context: MessageViewContext): MessageViewRender;
591
+ }
592
+ interface MessageRendererResult {
593
+ lines: string[];
594
+ rows?: Segment[][] | null;
595
+ bgs?: (string | undefined)[] | null;
596
+ customLabel?: string;
597
+ customMuted?: boolean;
598
+ }
599
+ interface MessageRendererContribution {
600
+ /** Message kind to take over: 'bubble' | 'collapsible' | 'tool-card' | 'compaction' | 'custom'. */
601
+ kind: string;
602
+ order?: number;
603
+ /** Return undefined to fall through to the builtin rendering. */
604
+ render(message: Message, width: number): MessageRendererResult | undefined;
605
+ }
606
+ interface TuiContentFace {
607
+ nodes: {
608
+ register(definition: ChatNodeDefinition): () => void;
609
+ };
610
+ views: {
611
+ register(contribution: MessageViewContribution): () => void;
612
+ };
613
+ renderers: {
614
+ register(contribution: MessageRendererContribution): () => void;
615
+ };
616
+ }
617
+ interface TuiStartupSink {
618
+ id: string;
619
+ /** Invoked for each boot progress line while the shell is starting. */
620
+ write(line: string): void;
621
+ }
622
+ interface TuiStartupFace {
623
+ registerSink(sink: TuiStartupSink): () => void;
624
+ }
625
+ interface SpecialFieldStyle {
626
+ color: string;
627
+ background: string;
628
+ bold?: boolean;
629
+ }
630
+ interface SpecialFieldContribution {
631
+ kind: string;
632
+ style(): SpecialFieldStyle;
633
+ /** Text injected into the sent message for a field of this kind; defaults to the label. */
634
+ expand?(data: unknown): string;
635
+ }
636
+ interface TuiFieldsFace {
637
+ register(contribution: SpecialFieldContribution): () => void;
638
+ }
639
+ /**
640
+ * Create a special field instance rendered as an inline chip with its own
641
+ * background. The returned sentinel char behaves like a single grapheme:
642
+ * cursor movement and deletion treat it atomically and line wrapping never
643
+ * splits it. `kind` resolves the style from registered field kinds.
644
+ */
645
+ interface SpecialFieldCreateInput {
646
+ kind: string;
647
+ label: string;
648
+ /** Which reclaim scan owns the slot: 'composer' chips die with composer text, 'message' chips with the message list. */
649
+ owner?: 'composer' | 'message';
650
+ }
651
+ interface SpecialFieldFactory {
652
+ create(input: SpecialFieldCreateInput): string | null;
653
+ release(char: string): void;
654
+ /** Protect a chip from the automatic reclaim scans until the disposer runs. */
655
+ pin(char: string): (() => void) | undefined;
656
+ isFieldChar(char: string): boolean;
657
+ labelOf(char: string): string | undefined;
658
+ }
659
+ interface PasteContext {
660
+ /** Raw pasted text with normalized newlines. */
661
+ text: string;
662
+ /** Insert at this char index in the composer value. */
663
+ cursor: number;
664
+ }
665
+ interface PasteResult {
666
+ /** Text to insert (may contain field sentinel chars created via the field factory). */
667
+ insert: string;
668
+ }
669
+ interface PasteHandlerContribution {
670
+ id: string;
671
+ order?: number;
672
+ /** Return a result to claim the paste; return undefined to fall through. */
673
+ handle(context: PasteContext): PasteResult | undefined;
674
+ }
675
+ interface ComposerInsertSpec {
676
+ /** Plain text to insert at the cursor. */
677
+ text?: string;
678
+ /** A special field chip to insert at the cursor; `data` is passed to the kind's expand on send. */
679
+ field?: {
680
+ kind: string;
681
+ label: string;
682
+ data?: unknown;
683
+ };
684
+ }
685
+ interface TuiComposerFace {
686
+ paste: {
687
+ register(handler: PasteHandlerContribution): () => void;
688
+ };
689
+ /**
690
+ * Intercept a key before the builtin composer handling consumes it.
691
+ * Runs for every key routed to the composer (only while it is interactive);
692
+ * return true to consume the event.
693
+ */
694
+ keys: {
695
+ register(binding: {
696
+ id: string;
697
+ order?: number;
698
+ handle(input: string, key: TuiKey): boolean;
699
+ }): () => void;
700
+ };
701
+ /** Insert text or a special field into the live composer at the cursor. False when the composer is not mounted. */
702
+ insert(spec: ComposerInsertSpec): boolean;
703
+ }
704
+ interface MarkdownInlineContext {
705
+ palette: MdPalette;
706
+ base?: MarkStyle;
707
+ }
708
+ interface MarkdownBlockContext {
709
+ palette: MdPalette;
710
+ thinking: boolean;
711
+ width: number;
712
+ streamId: string;
713
+ }
714
+ /**
715
+ * A custom markdown block renderer. Keyed by the marked token `type` it
716
+ * claims (`code`, `heading`, `table`, ...). Registering over an existing
717
+ * type replaces that layer; disposing restores it (layered registry
718
+ * semantics).
719
+ */
720
+ interface MarkdownBlockContribution {
721
+ /** marked token type this renderer claims. */
722
+ type: string;
723
+ order?: number;
724
+ render(token: Token, context: MarkdownBlockContext): Segment[][];
725
+ }
726
+ /** A custom inline (span-level) markdown token renderer, keyed by token `type`. */
727
+ interface MarkdownInlineContribution {
728
+ type: string;
729
+ order?: number;
730
+ render(token: Token, context: MarkdownInlineContext): Segment;
731
+ }
732
+ interface PrismGrammarContribution {
733
+ /** Code fence language id (lowercase). */
734
+ id: string;
735
+ /** Prism grammar object (from a loaded prism component or hand-built). */
736
+ grammar: unknown;
737
+ /** Extra aliases accepted for the same grammar. */
738
+ aliases?: readonly string[];
739
+ }
740
+ interface TuiMarkdownFace {
741
+ blocks: {
742
+ register(contribution: MarkdownBlockContribution): () => void;
743
+ };
744
+ inline: {
745
+ register(contribution: MarkdownInlineContribution): () => void;
746
+ };
747
+ languages: {
748
+ register(contribution: PrismGrammarContribution): () => void;
749
+ };
750
+ }
751
+ interface InteractionPanelComponentProps {
752
+ request: unknown;
753
+ resolve(value: unknown): void;
754
+ reject(cause: unknown): void;
755
+ active: boolean;
756
+ columns: number;
757
+ rows: number;
758
+ innerWidth: number;
759
+ blockWidth: number;
760
+ background: string;
761
+ handleRef?: {
762
+ current: unknown;
763
+ };
764
+ onResize(height: number): void;
765
+ }
766
+ interface InteractionPanelContribution {
767
+ kind: string;
768
+ order?: number;
769
+ component: ComponentType<InteractionPanelComponentProps>;
770
+ }
771
+ interface TuiInteractionPanelsFace {
772
+ register(contribution: InteractionPanelContribution): () => void;
773
+ }
774
+ interface TuiInteractionsFace {
775
+ panels: TuiInteractionPanelsFace;
776
+ /** Queue a plugin interaction; resolves when the panel for `kind` settles it. */
777
+ push(kind: string, request: unknown, signal?: AbortSignal): Promise<unknown>;
778
+ }
779
+ interface TuiSessionSummary {
780
+ id: string;
781
+ name: string;
782
+ directory: string;
783
+ ungrouped: boolean;
784
+ updatedAt: number;
785
+ modifiedAt?: number;
786
+ }
787
+ interface TuiChatFace {
788
+ cwd(): string;
789
+ activeSessionId(): string;
790
+ onEvent(listener: (event: SessionEvent) => void): () => void;
791
+ send(text: string, images?: ReadonlyArray<readonly PendingImage[]>): void;
792
+ interrupt(): void;
793
+ newSession(): Promise<void>;
794
+ openSession(id: string): Promise<void>;
795
+ listSessions(): Promise<TuiSessionSummary[]>;
796
+ }
797
+ interface TuiExtensionPoint {
798
+ windows: TuiWindowsFace;
799
+ services: TuiServicesFace;
800
+ chrome: TuiChromeFace;
801
+ commands: TuiCommandsFace;
802
+ tools: TuiToolsFace;
803
+ content: TuiContentFace;
804
+ startup: TuiStartupFace;
805
+ fields: TuiFieldsFace & {
806
+ factory: SpecialFieldFactory;
807
+ };
808
+ composer: TuiComposerFace;
809
+ markdown: TuiMarkdownFace;
810
+ hint: TuiHintFace;
811
+ pointer: TuiPointerFace;
812
+ selection: TuiSelectionFace;
813
+ clipboard: TuiClipboardFace;
814
+ interactions?: TuiInteractionsFace;
815
+ chat?: TuiChatFace;
816
+ }
817
+ declare module '@deepseek-ai/cordis' {
818
+ interface Context {
819
+ tui: TuiExtensionPoint;
820
+ }
821
+ }
822
+ //#endregion
823
+ export { ToolCallPresentation as $, MessageViewContribution as A, TuiToolsFace as At, PointerSession as B, MouseEventData as Bt, MarkdownBlockContext as C, TuiPaletteFace as Ct, MessageRendererContribution as D, TuiSessionSummary as Dt, MarkdownInlineContribution as E, TuiServicesFace as Et, PasteContext as F, WindowCommandSpec as Ft, SelectionExtractContext as G, Segment as Gt, PrismGrammarContribution as H, MessageKind as Ht, PasteHandlerContribution as I, WindowContribution as It, SpecialFieldCreateInput as J, SelectionTransformerContribution as K, PasteResult as L, WindowHandle as Lt, OverlayContribution as M, TuiWindowsFace as Mt, POINTER_PLUGIN_ORDER as N, WidgetDef as Nt, MessageRendererResult as O, TuiStartupFace as Ot, PaintArgs as P, WidgetKeyApi as Pt, ThemePaletteContribution as Q, PointerEventFrame as R, WindowProps as Rt, KeyBindingContribution as S, TuiMarkdownFace as St, MarkdownInlineContext as T, TuiSelectionFace as Tt, SelectionClipboardContribution as U, LineSelection as Ut, PointerUiContext as V, MouseEventType as Vt, SelectionDomainContribution as W, PendingImage as Wt, SpecialFieldStyle as X, SpecialFieldFactory as Y, StatusLineContribution as Z, InputStatusContext as _, TuiHomeLogoFace as _t, CommandDef as a, ToolViewContribution as at, InteractionPanelComponentProps as b, TuiKey as bt, CustomMessageSeed as c, TuiChatFace as ct, DiffLine as d, TuiCommandsFace as dt, ToolReadLine as et, DiffLineKind as f, TuiComposerFace as ft, HomeLogoContribution as g, TuiHintFace as gt, HintMatcherContribution as h, TuiFieldsFace as ht, ClipboardBackendContribution as i, ToolViewCallContext as it, MessageViewRender as j, TuiWidgetsFace as jt, MessageViewContext as k, TuiStartupSink as kt, DialogItemKinds as l, TuiChromeFace as lt, HintEntry as m, TuiExtensionPoint as mt, ClickActions as n, ToolResultPresentation as nt, ComposerInsertSpec as o, ToolViewDiff as ot, HintArgsContribution as p, TuiContentFace as pt, SpecialFieldContribution as q, ClickHit as r, ToolResultView as rt, CustomMessage as s, ToolViewResultContext as st, ChatNodeDefinition as t, ToolReadView as tt, DiffHunk as u, TuiClipboardFace as ut, InputStatusContribution as v, TuiInteractionPanelsFace as vt, MarkdownBlockContribution as w, TuiPointerFace as wt, InteractionPanelContribution as x, TuiKeymapFace as xt, InputStatusPart as y, TuiInteractionsFace as yt, PointerHandlerContribution as z, ScrollSnapshot as zt };