@agi-fans/dsh-tui 0.21.0 → 0.22.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 (243) hide show
  1. package/lib/CHANGELOG.md +158 -1
  2. package/lib/chrome/box.d.ts +47 -16
  3. package/lib/chrome/box.js +172 -130
  4. package/lib/chrome/box.js.map +1 -1
  5. package/lib/chrome/code-highlight.d.ts +15 -0
  6. package/lib/chrome/code-highlight.js +60 -4
  7. package/lib/chrome/code-highlight.js.map +1 -1
  8. package/lib/chrome/command-output.d.ts +29 -2
  9. package/lib/chrome/command-output.js +100 -4
  10. package/lib/chrome/command-output.js.map +1 -1
  11. package/lib/chrome/main-screen-renderer.d.ts +16 -0
  12. package/lib/chrome/main-screen-renderer.js +53 -5
  13. package/lib/chrome/main-screen-renderer.js.map +1 -1
  14. package/lib/chrome/markdown.js +30 -10
  15. package/lib/chrome/markdown.js.map +1 -1
  16. package/lib/chrome/relative-time.d.ts +17 -0
  17. package/lib/chrome/relative-time.js +36 -0
  18. package/lib/chrome/relative-time.js.map +1 -1
  19. package/lib/chrome/secret-mask.d.ts +35 -0
  20. package/lib/chrome/secret-mask.js +180 -0
  21. package/lib/chrome/secret-mask.js.map +1 -0
  22. package/lib/chrome/status-config.d.ts +161 -51
  23. package/lib/chrome/status-config.js +237 -126
  24. package/lib/chrome/status-config.js.map +1 -1
  25. package/lib/chrome/status-line.d.ts +3 -2
  26. package/lib/chrome/status-line.js +105 -63
  27. package/lib/chrome/status-line.js.map +1 -1
  28. package/lib/chrome/terminal-colors.d.ts +85 -0
  29. package/lib/chrome/terminal-colors.js +230 -0
  30. package/lib/chrome/terminal-colors.js.map +1 -0
  31. package/lib/chrome/terminal-images.d.ts +9 -1
  32. package/lib/chrome/terminal-images.js +27 -4
  33. package/lib/chrome/terminal-images.js.map +1 -1
  34. package/lib/chrome/theme.d.ts +32 -9
  35. package/lib/chrome/theme.js +595 -498
  36. package/lib/chrome/theme.js.map +1 -1
  37. package/lib/chrome/tool-renderers.js +69 -13
  38. package/lib/chrome/tool-renderers.js.map +1 -1
  39. package/lib/chrome/tools-list.d.ts +1 -4
  40. package/lib/chrome/tools-list.js +1 -41
  41. package/lib/chrome/tools-list.js.map +1 -1
  42. package/lib/chrome/welcome-tips.d.ts +20 -8
  43. package/lib/chrome/welcome-tips.js +22 -42
  44. package/lib/chrome/welcome-tips.js.map +1 -1
  45. package/lib/commands/auth-ids.d.ts +25 -0
  46. package/lib/commands/auth-ids.js +27 -0
  47. package/lib/commands/auth-ids.js.map +1 -0
  48. package/lib/commands/auth-input.d.ts +34 -0
  49. package/lib/commands/auth-input.js +96 -0
  50. package/lib/commands/auth-input.js.map +1 -0
  51. package/lib/commands/auth-providers.d.ts +39 -0
  52. package/lib/commands/auth-providers.js +125 -0
  53. package/lib/commands/auth-providers.js.map +1 -0
  54. package/lib/commands/auth.d.ts +12 -20
  55. package/lib/commands/auth.js +42 -229
  56. package/lib/commands/auth.js.map +1 -1
  57. package/lib/commands/btw.d.ts +13 -1
  58. package/lib/commands/btw.js +37 -104
  59. package/lib/commands/btw.js.map +1 -1
  60. package/lib/commands/diff.js +1 -96
  61. package/lib/commands/diff.js.map +1 -1
  62. package/lib/commands/export.d.ts +1 -1
  63. package/lib/commands/export.js +3 -27
  64. package/lib/commands/export.js.map +1 -1
  65. package/lib/commands/files.d.ts +17 -1
  66. package/lib/commands/files.js +67 -107
  67. package/lib/commands/files.js.map +1 -1
  68. package/lib/commands/jobs.d.ts +19 -4
  69. package/lib/commands/jobs.js +50 -7
  70. package/lib/commands/jobs.js.map +1 -1
  71. package/lib/commands/model.js +108 -76
  72. package/lib/commands/model.js.map +1 -1
  73. package/lib/commands/permission.js +15 -16
  74. package/lib/commands/permission.js.map +1 -1
  75. package/lib/commands/plugins.js +133 -16
  76. package/lib/commands/plugins.js.map +1 -1
  77. package/lib/commands/schedule.d.ts +10 -0
  78. package/lib/commands/schedule.js +45 -14
  79. package/lib/commands/schedule.js.map +1 -1
  80. package/lib/commands/session-configuration.js +2 -10
  81. package/lib/commands/session-configuration.js.map +1 -1
  82. package/lib/commands/session.js +14 -38
  83. package/lib/commands/session.js.map +1 -1
  84. package/lib/commands/terminal.d.ts +14 -8
  85. package/lib/commands/terminal.js +19 -178
  86. package/lib/commands/terminal.js.map +1 -1
  87. package/lib/commands/trajectory.js +4 -1
  88. package/lib/commands/trajectory.js.map +1 -1
  89. package/lib/definition.d.ts +122 -22
  90. package/lib/definition.js.map +1 -1
  91. package/lib/index.d.ts +1 -0
  92. package/lib/index.js +1 -0
  93. package/lib/index.js.map +1 -1
  94. package/lib/input/actions.d.ts +51 -0
  95. package/lib/input/actions.js +120 -0
  96. package/lib/input/actions.js.map +1 -0
  97. package/lib/input/editor.d.ts +0 -10
  98. package/lib/input/editor.js +11 -9
  99. package/lib/input/editor.js.map +1 -1
  100. package/lib/input/image-paste.d.ts +19 -1
  101. package/lib/input/image-paste.js +82 -1
  102. package/lib/input/image-paste.js.map +1 -1
  103. package/lib/input/keybindings-config.d.ts +12 -5
  104. package/lib/input/keybindings-config.js +30 -57
  105. package/lib/input/keybindings-config.js.map +1 -1
  106. package/lib/input/keys.d.ts +16 -0
  107. package/lib/input/keys.js +38 -3
  108. package/lib/input/keys.js.map +1 -1
  109. package/lib/input/wheel-scroll.d.ts +46 -0
  110. package/lib/input/wheel-scroll.js +69 -0
  111. package/lib/input/wheel-scroll.js.map +1 -0
  112. package/lib/prompt-intents.d.ts +182 -0
  113. package/lib/prompt-intents.js +127 -0
  114. package/lib/prompt-intents.js.map +1 -0
  115. package/lib/runtime/cancellable.d.ts +75 -0
  116. package/lib/runtime/cancellable.js +76 -0
  117. package/lib/runtime/cancellable.js.map +1 -0
  118. package/lib/runtime/composer-images.js +5 -4
  119. package/lib/runtime/composer-images.js.map +1 -1
  120. package/lib/runtime/composer-shell.d.ts +17 -2
  121. package/lib/runtime/composer-shell.js +109 -43
  122. package/lib/runtime/composer-shell.js.map +1 -1
  123. package/lib/runtime/file-recovery-review.d.ts +0 -1
  124. package/lib/runtime/file-recovery-review.js +29 -30
  125. package/lib/runtime/file-recovery-review.js.map +1 -1
  126. package/lib/runtime/file-recovery-store.js +5 -1
  127. package/lib/runtime/file-recovery-store.js.map +1 -1
  128. package/lib/runtime/file-review.js +1 -1
  129. package/lib/runtime/file-review.js.map +1 -1
  130. package/lib/runtime/hook-settings.d.ts +2 -2
  131. package/lib/runtime/plain-tui.d.ts +2 -0
  132. package/lib/runtime/plain-tui.js +7 -1
  133. package/lib/runtime/plain-tui.js.map +1 -1
  134. package/lib/runtime/plugin-settings.d.ts +1 -1
  135. package/lib/runtime/plugin-settings.js +10 -8
  136. package/lib/runtime/plugin-settings.js.map +1 -1
  137. package/lib/runtime/provider-local.d.ts +57 -15
  138. package/lib/runtime/provider-local.js +1112 -471
  139. package/lib/runtime/provider-local.js.map +1 -1
  140. package/lib/runtime/runner.js +5 -11
  141. package/lib/runtime/runner.js.map +1 -1
  142. package/lib/runtime/settings-preferences.js +1 -1
  143. package/lib/runtime/settings-preferences.js.map +1 -1
  144. package/lib/runtime/startup-notices.js +2 -0
  145. package/lib/runtime/startup-notices.js.map +1 -1
  146. package/lib/runtime/terminal-modes.d.ts +47 -0
  147. package/lib/runtime/terminal-modes.js +86 -0
  148. package/lib/runtime/terminal-modes.js.map +1 -0
  149. package/lib/runtime/terminal-notifications.d.ts +3 -5
  150. package/lib/runtime/terminal-notifications.js +4 -8
  151. package/lib/runtime/terminal-notifications.js.map +1 -1
  152. package/lib/runtime/terminal-probe.d.ts +36 -0
  153. package/lib/runtime/terminal-probe.js +37 -0
  154. package/lib/runtime/terminal-probe.js.map +1 -0
  155. package/lib/runtime/terminal-session.d.ts +57 -0
  156. package/lib/runtime/terminal-session.js +164 -0
  157. package/lib/runtime/terminal-session.js.map +1 -0
  158. package/lib/session/interaction-adapter.js +7 -8
  159. package/lib/session/interaction-adapter.js.map +1 -1
  160. package/lib/session/message-queue.js +1 -1
  161. package/lib/session/message-queue.js.map +1 -1
  162. package/lib/session/package-metadata.d.ts +8 -0
  163. package/lib/session/package-metadata.js +8 -0
  164. package/lib/session/package-metadata.js.map +1 -1
  165. package/lib/session/session-controller.d.ts +10 -11
  166. package/lib/session/session-controller.js +95 -13
  167. package/lib/session/session-controller.js.map +1 -1
  168. package/lib/session/session-tree.d.ts +2 -0
  169. package/lib/session/session-tree.js +2 -0
  170. package/lib/session/session-tree.js.map +1 -1
  171. package/lib/session/tui-settings.d.ts +40 -11
  172. package/lib/session/tui-settings.js +73 -34
  173. package/lib/session/tui-settings.js.map +1 -1
  174. package/lib/views/autocomplete.d.ts +18 -2
  175. package/lib/views/autocomplete.js +51 -38
  176. package/lib/views/autocomplete.js.map +1 -1
  177. package/lib/views/copy-targets.d.ts +12 -13
  178. package/lib/views/copy-targets.js +16 -46
  179. package/lib/views/copy-targets.js.map +1 -1
  180. package/lib/views/document-reader.js +18 -5
  181. package/lib/views/document-reader.js.map +1 -1
  182. package/lib/views/event-views.js +42 -6
  183. package/lib/views/event-views.js.map +1 -1
  184. package/lib/views/history-search.js +15 -21
  185. package/lib/views/history-search.js.map +1 -1
  186. package/lib/views/hotkeys.d.ts +7 -1
  187. package/lib/views/hotkeys.js +49 -25
  188. package/lib/views/hotkeys.js.map +1 -1
  189. package/lib/views/list-navigation.d.ts +62 -0
  190. package/lib/views/list-navigation.js +73 -0
  191. package/lib/views/list-navigation.js.map +1 -0
  192. package/lib/views/list-view.d.ts +99 -0
  193. package/lib/views/list-view.js +165 -0
  194. package/lib/views/list-view.js.map +1 -0
  195. package/lib/views/prompt-selector.d.ts +31 -3
  196. package/lib/views/prompt-selector.js +249 -125
  197. package/lib/views/prompt-selector.js.map +1 -1
  198. package/lib/views/session-files.d.ts +1 -2
  199. package/lib/views/session-files.js +1 -11
  200. package/lib/views/session-files.js.map +1 -1
  201. package/lib/views/settings-list.d.ts +10 -8
  202. package/lib/views/settings-list.js +116 -283
  203. package/lib/views/settings-list.js.map +1 -1
  204. package/lib/views/trajectory-timeline.d.ts +72 -0
  205. package/lib/views/trajectory-timeline.js +133 -0
  206. package/lib/views/trajectory-timeline.js.map +1 -0
  207. package/lib/views/trajectory.d.ts +15 -4
  208. package/lib/views/trajectory.js +557 -123
  209. package/lib/views/trajectory.js.map +1 -1
  210. package/lib/views/transcript-render.d.ts +95 -25
  211. package/lib/views/transcript-render.js +501 -167
  212. package/lib/views/transcript-render.js.map +1 -1
  213. package/lib/views/transcript-search.d.ts +39 -6
  214. package/lib/views/transcript-search.js +46 -11
  215. package/lib/views/transcript-search.js.map +1 -1
  216. package/lib/views/transcript-types.d.ts +63 -5
  217. package/lib/views/transcript-types.js +23 -11
  218. package/lib/views/transcript-types.js.map +1 -1
  219. package/package.json +67 -86
  220. package/lib/commands/advisor.d.ts +0 -15
  221. package/lib/commands/advisor.js +0 -200
  222. package/lib/commands/advisor.js.map +0 -1
  223. package/lib/commands/loop.d.ts +0 -52
  224. package/lib/commands/loop.js +0 -307
  225. package/lib/commands/loop.js.map +0 -1
  226. package/lib/commands/rate.d.ts +0 -33
  227. package/lib/commands/rate.js +0 -212
  228. package/lib/commands/rate.js.map +0 -1
  229. package/lib/commands/steer.d.ts +0 -5
  230. package/lib/commands/steer.js +0 -24
  231. package/lib/commands/steer.js.map +0 -1
  232. package/lib/commands/worktree.d.ts +0 -5
  233. package/lib/commands/worktree.js +0 -103
  234. package/lib/commands/worktree.js.map +0 -1
  235. package/lib/runtime/terminal-reader.d.ts +0 -11
  236. package/lib/runtime/terminal-reader.js +0 -87
  237. package/lib/runtime/terminal-reader.js.map +0 -1
  238. package/lib/views/agent-hub.d.ts +0 -32
  239. package/lib/views/agent-hub.js +0 -209
  240. package/lib/views/agent-hub.js.map +0 -1
  241. package/lib/views/copy-selector.d.ts +0 -54
  242. package/lib/views/copy-selector.js +0 -170
  243. package/lib/views/copy-selector.js.map +0 -1
@@ -0,0 +1,182 @@
1
+ /**
2
+ * The four intents a caller actually has when it asks the reader something.
3
+ *
4
+ * `TuiPrompt` grew to forty-six optional fields because every new surface added
5
+ * one: `presentation`, `filterable`, `approveValue`,
6
+ * `dismissLabel`, `skippable`, `wait`, `interrupt`, `onSuperseded`,
7
+ * `refreshDocument`, `refreshOptions` … A caller passing `{ title, question,
8
+ * allowCustom: true }` had to know that omitting `options` means "free text" and
9
+ * that `allowCustom: false` is what makes a list non-editable. Nothing in the
10
+ * type said which fields belong together, so each new caller assembled its own
11
+ * combination and the interface kept widening.
12
+ *
13
+ * These four intents are measured, not invented: across 196 call sites, 109 ask
14
+ * for free text, 45 offer a list, 14 read a document, and the rest are those
15
+ * shapes with one extra field. Each function below names the intent, defaults
16
+ * what the intent always wants, and leaves the escape hatch — {@link TuiService.prompt}
17
+ * with the full type — for the handful of surfaces that genuinely need it.
18
+ *
19
+ * @module @agi-fans/dsh-tui/prompt-intents
20
+ */
21
+ import type { TuiDocumentPosition, TuiDocumentSource, TuiPrompt } from './definition.ts';
22
+ /** One choice a {@link choose} offers. */
23
+ export interface PromptChoice {
24
+ label: string;
25
+ /** Answer returned to the caller; defaults to {@link label}. */
26
+ value?: string;
27
+ description?: string;
28
+ /** Parent value when the list is a tree; a missing parent makes a root. */
29
+ parentValue?: string;
30
+ /** Secondary content shown above the metadata in a spacious list. */
31
+ preview?: string;
32
+ /** Verb shown for Enter on this row. */
33
+ submitLabel?: string;
34
+ /** Semantic badge painted after the description. */
35
+ badge?: {
36
+ label: string;
37
+ tone: 'success' | 'warning' | 'error' | 'muted';
38
+ };
39
+ }
40
+ /** One keyboard chord a {@link choose} list accepts besides Enter and the arrows. */
41
+ export interface PromptAction {
42
+ key: string;
43
+ label: string;
44
+ /** Returned before the selected value, so the caller can tell which chord fired. */
45
+ valuePrefix: string;
46
+ /** `list` returns only the prefix, even with no row selected. */
47
+ scope?: 'selection' | 'list';
48
+ }
49
+ /** A surface that needs no answer, only a decision to stop. */
50
+ export interface CancelSurface {
51
+ /** Label of the option that cancels; defaults to `Cancel`. */
52
+ cancelLabel?: string;
53
+ /** What cancelling does and does not undo. */
54
+ detail?: string;
55
+ signal?: AbortSignal;
56
+ /**
57
+ * The work behind the surface, so `Esc` and `Ctrl+C` can stop it.
58
+ *
59
+ * Returning true keeps a primary turn running: a progress surface belongs to
60
+ * one operation, not to the session.
61
+ */
62
+ interrupt?: () => boolean | void;
63
+ /** The surface was taken by something with a stronger claim on the screen. */
64
+ onSuperseded?: (input: string) => void;
65
+ /** Repaint an open document; read on every refresh. */
66
+ refreshDocument?: () => string;
67
+ }
68
+ /**
69
+ * Ask for free text.
70
+ *
71
+ * This is the shape 109 of 196 call sites wanted and had to spell as
72
+ * `{ allowCustom: true, notify: false }`. A bare input needs no `options` array
73
+ * and no `presentation`; both are supplied here so the caller states one thing.
74
+ */
75
+ export declare function askPrompt(request: {
76
+ title: string;
77
+ question: string;
78
+ detail?: string;
79
+ /** Prefilled text the reader can edit. */
80
+ initialInput?: string;
81
+ /** Keep indentation and trailing newlines, for message-shaped input. */
82
+ preserveWhitespace?: boolean;
83
+ /** Mask what is typed; the real value stays in the editor only. */
84
+ secret?: boolean;
85
+ /** Rescue partially typed text when the prompt is dismissed or aborted. */
86
+ onCancelDraft?: (draft: string) => void;
87
+ /** Verb shown for Enter, such as `validate`; the input is still free text. */
88
+ submitLabel?: string;
89
+ signal?: AbortSignal;
90
+ /** Announce this prompt; off for user-initiated surfaces the reader just opened. */
91
+ notify?: boolean;
92
+ }): TuiPrompt;
93
+ /**
94
+ * Offer a list of choices.
95
+ *
96
+ * The list is not editable: a caller that wants both a list and free text wants
97
+ * {@link askPrompt} with `detail`, or the full {@link TuiPrompt} if it really
98
+ * needs both. Keeping the two apart is what lets this function state the shape
99
+ * without an `allowCustom` flag the caller has to reason about.
100
+ */
101
+ export declare function choosePrompt<const T extends PromptChoice>(request: {
102
+ title: string;
103
+ question: string;
104
+ detail?: string;
105
+ options: readonly T[];
106
+ /** Value selected when the list opens. */
107
+ initialValue?: string;
108
+ /** Let typed text filter the rows. */
109
+ filterable?: boolean;
110
+ /** Text shown when the list has no rows; the caller owns this wording. */
111
+ emptyText?: string;
112
+ /** Keyboard chords the list accepts besides Enter and the arrows. */
113
+ actions?: readonly PromptAction[];
114
+ /** Allow more than one row to be checked. */
115
+ multiSelect?: boolean;
116
+ /** Values checked when a multi-select list opens. */
117
+ initialValues?: readonly string[];
118
+ /** Submit an empty answer when every choice is unchecked. */
119
+ allowEmptySelection?: boolean;
120
+ /** Verb shown after Enter in the navigation hint. */
121
+ submitLabel?: string;
122
+ signal?: AbortSignal;
123
+ notify?: boolean;
124
+ }): TuiPrompt;
125
+ /**
126
+ * Ask one yes/no question.
127
+ *
128
+ * Returns a boolean rather than a string or null, because "dismissed" and "no"
129
+ * are the same answer: a reader who presses Escape has not agreed to anything.
130
+ * Callers that need to tell those apart use the full prompt.
131
+ */
132
+ export declare function confirmPrompt(prompt: (request: TuiPrompt) => Promise<string | null>, request: {
133
+ title: string;
134
+ question: string;
135
+ detail?: string;
136
+ /** Verb on the accepting row; the declining row is always a cancel. */
137
+ acceptLabel?: string;
138
+ /** One line under the accepting row saying what accepting does. */
139
+ acceptDescription?: string;
140
+ /**
141
+ * Label of the declining row; defaults to `Cancel`.
142
+ *
143
+ * Pass `null` for a one-way door: the reader either proceeds or dismisses.
144
+ * That is a different intent from a yes/no question — "install and enable"
145
+ * has no meaningful opposite to put beside it — and it is what 24 call sites
146
+ * meant by a list with a single row.
147
+ */
148
+ cancelLabel?: string | null;
149
+ /** One line under the declining row; usually what staying put means. */
150
+ cancelDescription?: string;
151
+ signal?: AbortSignal;
152
+ notify?: boolean;
153
+ }): Promise<boolean>;
154
+ /**
155
+ * Show a document the reader can scroll, search, and leave.
156
+ *
157
+ * The surface is dropped automatically when the work it describes ends, so the
158
+ * caller does not have to pair an open with a close.
159
+ */
160
+ export declare function readPrompt(request: {
161
+ title: string;
162
+ question: string;
163
+ /** The text to read; wrapped by default. */
164
+ text?: string;
165
+ /** A prepared source reader with line numbers and search. */
166
+ source?: TuiDocumentSource;
167
+ /** Open at this position. */
168
+ position?: TuiDocumentPosition;
169
+ /** Open at the latest row, for output that is still arriving. */
170
+ tail?: boolean;
171
+ /** A prepared image shown in the dedicated reader. */
172
+ image?: TuiPrompt['documentImage'];
173
+ /** Repaint while open; read on every refresh. */
174
+ refresh?: () => string;
175
+ /** Told the last visible position when the reader leaves. */
176
+ onPosition?: (position: TuiDocumentPosition) => void;
177
+ cancelLabel?: string;
178
+ detail?: string;
179
+ signal?: AbortSignal;
180
+ interrupt?: () => boolean | void;
181
+ onSuperseded?: (input: string) => void;
182
+ }): TuiPrompt;
@@ -0,0 +1,127 @@
1
+ /**
2
+ * The four intents a caller actually has when it asks the reader something.
3
+ *
4
+ * `TuiPrompt` grew to forty-six optional fields because every new surface added
5
+ * one: `presentation`, `filterable`, `approveValue`,
6
+ * `dismissLabel`, `skippable`, `wait`, `interrupt`, `onSuperseded`,
7
+ * `refreshDocument`, `refreshOptions` … A caller passing `{ title, question,
8
+ * allowCustom: true }` had to know that omitting `options` means "free text" and
9
+ * that `allowCustom: false` is what makes a list non-editable. Nothing in the
10
+ * type said which fields belong together, so each new caller assembled its own
11
+ * combination and the interface kept widening.
12
+ *
13
+ * These four intents are measured, not invented: across 196 call sites, 109 ask
14
+ * for free text, 45 offer a list, 14 read a document, and the rest are those
15
+ * shapes with one extra field. Each function below names the intent, defaults
16
+ * what the intent always wants, and leaves the escape hatch — {@link TuiService.prompt}
17
+ * with the full type — for the handful of surfaces that genuinely need it.
18
+ *
19
+ * @module @agi-fans/dsh-tui/prompt-intents
20
+ */
21
+ /**
22
+ * Ask for free text.
23
+ *
24
+ * This is the shape 109 of 196 call sites wanted and had to spell as
25
+ * `{ allowCustom: true, notify: false }`. A bare input needs no `options` array
26
+ * and no `presentation`; both are supplied here so the caller states one thing.
27
+ */
28
+ export function askPrompt(request) {
29
+ return {
30
+ title: request.title,
31
+ question: request.question,
32
+ ...(request.detail === undefined ? {} : { detail: request.detail }),
33
+ ...(request.initialInput === undefined ? {} : { initialInput: request.initialInput }),
34
+ ...(request.preserveWhitespace === true ? { preserveWhitespace: true } : {}),
35
+ ...(request.secret === true ? { secret: true } : {}),
36
+ ...(request.onCancelDraft === undefined ? {} : { onCancelDraft: request.onCancelDraft }),
37
+ ...(request.submitLabel === undefined ? {} : { submitLabel: request.submitLabel }),
38
+ ...(request.signal === undefined ? {} : { signal: request.signal }),
39
+ allowCustom: true,
40
+ notify: request.notify ?? false,
41
+ };
42
+ }
43
+ /**
44
+ * Offer a list of choices.
45
+ *
46
+ * The list is not editable: a caller that wants both a list and free text wants
47
+ * {@link askPrompt} with `detail`, or the full {@link TuiPrompt} if it really
48
+ * needs both. Keeping the two apart is what lets this function state the shape
49
+ * without an `allowCustom` flag the caller has to reason about.
50
+ */
51
+ export function choosePrompt(request) {
52
+ return {
53
+ title: request.title,
54
+ question: request.question,
55
+ ...(request.detail === undefined ? {} : { detail: request.detail }),
56
+ options: request.options,
57
+ ...(request.initialValue === undefined ? {} : { initialValue: request.initialValue }),
58
+ ...(request.filterable === true ? { filterable: true } : {}),
59
+ ...(request.emptyText === undefined ? {} : { emptyText: request.emptyText }),
60
+ ...(request.actions === undefined ? {} : { actions: request.actions }),
61
+ ...(request.multiSelect === true ? { multiSelect: true } : {}),
62
+ ...(request.initialValues === undefined ? {} : { initialValues: request.initialValues }),
63
+ ...(request.allowEmptySelection === true ? { allowEmptySelection: true } : {}),
64
+ ...(request.submitLabel === undefined ? {} : { submitLabel: request.submitLabel }),
65
+ ...(request.signal === undefined ? {} : { signal: request.signal }),
66
+ allowCustom: false,
67
+ notify: request.notify ?? false,
68
+ };
69
+ }
70
+ /**
71
+ * Ask one yes/no question.
72
+ *
73
+ * Returns a boolean rather than a string or null, because "dismissed" and "no"
74
+ * are the same answer: a reader who presses Escape has not agreed to anything.
75
+ * Callers that need to tell those apart use the full prompt.
76
+ */
77
+ export async function confirmPrompt(prompt, request) {
78
+ const accept = request.acceptLabel ?? 'Continue';
79
+ const answer = await prompt({
80
+ title: request.title,
81
+ question: request.question,
82
+ ...(request.detail === undefined ? {} : { detail: request.detail }),
83
+ options: request.cancelLabel === null
84
+ ? [{ label: accept, value: 'accept', ...(request.acceptDescription === undefined ? {} : { description: request.acceptDescription }) }]
85
+ : [
86
+ { label: accept, value: 'accept', ...(request.acceptDescription === undefined ? {} : { description: request.acceptDescription }) },
87
+ { label: request.cancelLabel ?? 'Cancel', value: 'cancel', ...(request.cancelDescription === undefined ? {} : { description: request.cancelDescription }) },
88
+ ],
89
+ // A one-way door preselects its only row; dismissal is still a no.
90
+ ...(request.cancelLabel === null ? { initialValue: 'accept' } : { initialValue: 'cancel' }),
91
+ allowCustom: false,
92
+ notify: request.notify ?? false,
93
+ ...(request.signal === undefined ? {} : { signal: request.signal }),
94
+ });
95
+ return answer === 'accept';
96
+ }
97
+ /**
98
+ * Show a document the reader can scroll, search, and leave.
99
+ *
100
+ * The surface is dropped automatically when the work it describes ends, so the
101
+ * caller does not have to pair an open with a close.
102
+ */
103
+ export function readPrompt(request) {
104
+ return {
105
+ title: request.title,
106
+ question: request.question,
107
+ ...(request.detail === undefined ? {} : { detail: request.detail }),
108
+ // A plain string becomes a source so the reader gets line numbers and search
109
+ // rather than a wrapped prose page; an explicit source wins.
110
+ ...(request.source !== undefined
111
+ ? { documentSource: request.source }
112
+ : request.text === undefined ? {} : { documentSource: { text: request.text } }),
113
+ ...(request.position === undefined ? {} : { documentPosition: request.position }),
114
+ ...(request.tail === true ? { documentTail: true } : {}),
115
+ ...(request.image === undefined ? {} : { documentImage: request.image }),
116
+ ...(request.refresh === undefined ? {} : { refreshDocument: request.refresh }),
117
+ ...(request.onPosition === undefined ? {} : { onDocumentPosition: request.onPosition }),
118
+ options: [{ label: request.cancelLabel ?? 'Cancel', value: 'cancel' }],
119
+ presentation: 'document',
120
+ allowCustom: false,
121
+ notify: false,
122
+ ...(request.signal === undefined ? {} : { signal: request.signal }),
123
+ ...(request.interrupt === undefined ? {} : { interrupt: request.interrupt }),
124
+ ...(request.onSuperseded === undefined ? {} : { onSuperseded: request.onSuperseded }),
125
+ };
126
+ }
127
+ //# sourceMappingURL=prompt-intents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-intents.js","sourceRoot":"","sources":["../src/prompt-intents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAkDH;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,OAiBzB;IACC,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;QACnE,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACrF,GAAG,CAAC,OAAO,CAAC,kBAAkB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;QACxF,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;QAClF,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,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EAAE,CAAC;QACnE,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;QAC5E,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;KACtF,CAAA;AACH,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * One cancellable long operation with its own progress surface.
3
+ *
4
+ * A long command needs three things wired together, and every call site used to
5
+ * write the same wiring by hand:
6
+ *
7
+ * 1. a signal that combines the caller's own cancellation with the reader's;
8
+ * 2. a prompt that gives the reader a way to cancel — Enter, Escape, `Ctrl+C`;
9
+ * 3. a "finished" signal so that dismissing the prompt because the *work* ended
10
+ * is not mistaken for the reader cancelling the work.
11
+ *
12
+ * The third point is where hand-written copies went wrong: the prompt's promise
13
+ * settles both when the reader cancels and when the operation completes, so a
14
+ * naive `.then(() => controller.abort())` aborted the operation on its own
15
+ * success. Each site had to guard it with a second `finished` controller, and
16
+ * each site wrote that guard differently.
17
+ *
18
+ * `run()` owns the whole lifecycle: the body receives the combined signal, and
19
+ * the prompt is dismissed when the body settles either way.
20
+ *
21
+ * @module @agi-fans/dsh-tui/cancellable
22
+ */
23
+ import type { TuiService } from '../definition.ts';
24
+ /** One progress surface the reader can cancel from. */
25
+ export interface CancellableProgress {
26
+ /** Title of the surface, such as `Creating worktree`. */
27
+ title: string;
28
+ /** The subject line: what is being done, in one row. */
29
+ question: string;
30
+ /** What cancelling does and does not undo. Shown under the subject. */
31
+ detail?: string;
32
+ /** Label of the cancel option. */
33
+ cancelLabel?: string;
34
+ /**
35
+ * Progress card, or a reading surface that updates while the work streams.
36
+ *
37
+ * A streaming operation (a side question's answer) needs a document the reader
38
+ * can watch and scroll; a file restore only needs to say what is happening. The
39
+ * lifecycle is identical, so both are one option rather than two helpers.
40
+ */
41
+ presentation?: 'progress' | 'document';
42
+ /** Repaint the open document; read on each refresh. */
43
+ document?: () => string;
44
+ /**
45
+ * Whether to open the surface at all.
46
+ *
47
+ * The caller decides, because the three operations disagreed: a worktree and a
48
+ * side question are interactive-only, while a file restore reports progress even
49
+ * when the caller did not claim an interactive screen. Inferring this from
50
+ * `tui.interactive` silently dropped the restore's progress surface.
51
+ */
52
+ surface: boolean;
53
+ }
54
+ /**
55
+ * Why a cancellable operation stopped early.
56
+ *
57
+ * The two are not the same event: a reader who presses cancel is watching, and
58
+ * knows the work stopped, while a superseded surface means the screen was taken
59
+ * by something else and the reader never saw the result. Callers that report a
60
+ * partial outcome treat them differently.
61
+ */
62
+ export type CancellationReason = 'cancelled' | 'superseded';
63
+ /**
64
+ * Run one long operation behind a cancel surface.
65
+ *
66
+ * Returns `undefined` when the operation never started because the caller was
67
+ * already aborted, so callers can skip their success path without checking.
68
+ *
69
+ * A non-interactive host runs the body without a surface: there is no reader to
70
+ * cancel it, and opening a prompt would claim a screen the pipe does not have.
71
+ */
72
+ export declare function cancellable<T>(tui: Pick<TuiService, 'interactive' | 'prompt'>, progress: CancellableProgress, parent: AbortSignal, run: (signal: AbortSignal) => Promise<T>): Promise<{
73
+ value: T;
74
+ reason: CancellationReason | undefined;
75
+ } | undefined>;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * One cancellable long operation with its own progress surface.
3
+ *
4
+ * A long command needs three things wired together, and every call site used to
5
+ * write the same wiring by hand:
6
+ *
7
+ * 1. a signal that combines the caller's own cancellation with the reader's;
8
+ * 2. a prompt that gives the reader a way to cancel — Enter, Escape, `Ctrl+C`;
9
+ * 3. a "finished" signal so that dismissing the prompt because the *work* ended
10
+ * is not mistaken for the reader cancelling the work.
11
+ *
12
+ * The third point is where hand-written copies went wrong: the prompt's promise
13
+ * settles both when the reader cancels and when the operation completes, so a
14
+ * naive `.then(() => controller.abort())` aborted the operation on its own
15
+ * success. Each site had to guard it with a second `finished` controller, and
16
+ * each site wrote that guard differently.
17
+ *
18
+ * `run()` owns the whole lifecycle: the body receives the combined signal, and
19
+ * the prompt is dismissed when the body settles either way.
20
+ *
21
+ * @module @agi-fans/dsh-tui/cancellable
22
+ */
23
+ /**
24
+ * Run one long operation behind a cancel surface.
25
+ *
26
+ * Returns `undefined` when the operation never started because the caller was
27
+ * already aborted, so callers can skip their success path without checking.
28
+ *
29
+ * A non-interactive host runs the body without a surface: there is no reader to
30
+ * cancel it, and opening a prompt would claim a screen the pipe does not have.
31
+ */
32
+ export async function cancellable(tui, progress, parent, run) {
33
+ if (parent.aborted)
34
+ return undefined;
35
+ const cancel = new AbortController();
36
+ const finished = new AbortController();
37
+ const signal = AbortSignal.any([parent, cancel.signal]);
38
+ let superseded = false;
39
+ const surface = progress.surface
40
+ ? tui.prompt({
41
+ title: progress.title,
42
+ question: progress.question,
43
+ ...(progress.detail === undefined ? {} : { detail: progress.detail }),
44
+ ...(progress.document === undefined ? {} : { refreshDocument: progress.document }),
45
+ // Both surfaces report cancellation through the `interrupt` hook instead of
46
+ // the returned value, because the reader may be reading while it runs; the
47
+ // option list is only the keyboard affordance.
48
+ presentation: progress.presentation ?? 'progress',
49
+ options: [{ label: progress.cancelLabel ?? 'Cancel', value: 'cancel' }],
50
+ allowCustom: false,
51
+ notify: false,
52
+ signal: AbortSignal.any([parent, finished.signal]),
53
+ interrupt: () => { cancel.abort(); return true; },
54
+ // A superseding prompt takes the screen, which ends this operation rather
55
+ // than letting it run behind a surface nobody can see.
56
+ onSuperseded: () => { superseded = true; cancel.abort(); },
57
+ })
58
+ .then(() => { if (!finished.signal.aborted)
59
+ cancel.abort(); }, () => { cancel.abort(); })
60
+ : Promise.resolve();
61
+ try {
62
+ const value = await run(signal);
63
+ // `cancel` also fires when the parent aborted; only a stop the reader caused
64
+ // is reported as one.
65
+ const stopped = cancel.signal.aborted && !parent.aborted;
66
+ return { value, reason: stopped ? (superseded ? 'superseded' : 'cancelled') : undefined };
67
+ }
68
+ finally {
69
+ // Dismiss the surface exactly once, whether the work finished, failed, or
70
+ // was cancelled. Aborting `finished` first is what tells the prompt's own
71
+ // `.then` that this dismissal is not a cancellation.
72
+ finished.abort();
73
+ await surface;
74
+ }
75
+ }
76
+ //# sourceMappingURL=cancellable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancellable.js","sourceRoot":"","sources":["../../src/runtime/cancellable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA6CH;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAA+C,EAC/C,QAA6B,EAC7B,MAAmB,EACnB,GAAwC;IAExC,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,SAAS,CAAA;IACpC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACpC,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAA;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IACvD,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO;QAC9B,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;YACX,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;YACrE,GAAG,CAAC,QAAQ,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAClF,4EAA4E;YAC5E,2EAA2E;YAC3E,+CAA+C;YAC/C,YAAY,EAAE,QA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AC,KAAK,EAAE,CAAA;QAChB,MAAM,OAAO,CAAA;IACf,CAAC;AACH,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * decoding, and the prompt/settings/search branches that decide whether a
8
8
  * paste is an image at all stay in the provider.
9
9
  */
10
- import { imageMarker, probeImageDimensions } from "../input/image-paste.js";
10
+ import { imageMarker, probeImageDimensions, submissionDraftText } from "../input/image-paste.js";
11
11
  export class ComposerImages {
12
12
  #deps;
13
13
  #images = [];
@@ -139,15 +139,16 @@ export class ComposerImages {
139
139
  const image = currentImages[index];
140
140
  rebasedCurrent = rebasedCurrent.replaceAll(imageMarker(index, image), imageMarker(index + submission.images.length, image));
141
141
  }
142
- const separator = submission.text !== '' && rebasedCurrent !== '' ? '\n' : '';
142
+ const restored = submissionDraftText(submission);
143
+ const separator = restored !== '' && rebasedCurrent !== '' ? '\n' : '';
143
144
  this.#images = [...submission.images.map(image => ({ ...image })), ...currentImages];
144
- editor.replaceText(submission.text + separator + rebasedCurrent);
145
+ editor.replaceText(restored + separator + rebasedCurrent);
145
146
  }
146
147
  /** Replace drafts and text with a queued/edited submission. */
147
148
  replace(submission) {
148
149
  this.#revision++;
149
150
  this.#images = submission.images.map(image => ({ ...image }));
150
- this.#deps.editor.setText(submission.text);
151
+ this.#deps.editor.setText(submissionDraftText(submission));
151
152
  }
152
153
  clear() {
153
154
  this.#revision++;
@@ -1 +1 @@
1
- {"version":3,"file":"composer-images.js","sourceRoot":"","sources":["../../src/runtime/composer-images.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAQ3E,MAAM,OAAO,cAAc;IAChB,KAAK,CAAoB;IAClC,OAAO,GAAoB,EAAE,CAAA;IAC7B,SAAS,GAAG,CAAC,CAAA;IACb,SAAS,CAAuD;IAEhE,YAAY,IAAwB;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED,IAAI,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G,QAAQ,KAAK,EAAE,IAAI,cAAc,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;QACtE,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,CAAA;QACpF,MAAM,CAAC,WAAW,CAAC,QAAQ,GAAG,SAAS,GAAG,cAAc,CAAC,CAAA;IAC3D,CAAC;IAED,+DAA+D;IAC/D,OAAO,CAAC,UAAyB;QAC/B,IAAI,CAAC,SAAS,EAAE,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAA;QAC7D,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC5D,CAAC;IAED,KAAK;QACH,IAAI,CAAC,SAAS,EAAE,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;IACnB,CAAC;CACF"}
@@ -7,9 +7,24 @@ export declare function composerShellCommand(submission: TuiSubmission): string
7
7
  /** `!!<command>` runs in the session Shell and shares its output to the conversation. */
8
8
  export declare function composerShellShare(submission: TuiSubmission): boolean;
9
9
  /**
10
- * Send a line, then show its live terminal. Esc detaches without terminating it.
11
- * Ordinary `!` output remains outside the model context unless shared (`s` or `!!`).
10
+ * Run one Shell line in the session Shell, streaming its output to a live card.
11
+ *
12
+ * The card is the surface. There is no reader to enter and leave: the command
13
+ * streams into the transcript where the reader asked for it, and finishes when
14
+ * the command finishes. `!` keeps the output outside the model's context; `!!`
15
+ * shares it once the command settles.
12
16
  */
13
17
  export declare function runComposerShell(ctx: Context, owner: Agent, command: string, upstream: AbortSignal, options?: {
14
18
  share?: boolean;
15
19
  }): Promise<void>;
20
+ /**
21
+ * Close the composer Shell when it is not running anything.
22
+ *
23
+ * The Shell is reused across `!` lines so a directory change or an environment
24
+ * variable survives, which is the whole point of it. That reuse also pins the
25
+ * session to the Access level it was created in: the Harness refuses to change
26
+ * sandbox mode while a persistent terminal is open, and a reader driving `!`
27
+ * cards would otherwise be stuck on one level forever with no way out. A Shell
28
+ * with a command still running is left alone — closing it would kill work.
29
+ */
30
+ export declare function closeIdleComposerShell(ctx: Context, owner: Agent): Promise<boolean>;