@robota-sdk/agent-transport 3.0.0-beta.75 → 3.0.0-beta.77

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 (231) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +17 -14
  3. package/dist/node/headless/index.cjs +1 -1
  4. package/dist/node/headless/index.d.ts +1 -1
  5. package/dist/node/headless/index.js +1 -1
  6. package/dist/node/{headless-mRYilLfC.js → headless-DG_MEbf0.js} +7 -4
  7. package/dist/node/headless-DG_MEbf0.js.map +1 -0
  8. package/dist/node/headless-xq77JBq0.cjs +18 -0
  9. package/dist/node/{index-E8Gx4-lc.d.ts → index-CrJ2Lhn3.d.ts} +16 -3
  10. package/dist/node/index-CrJ2Lhn3.d.ts.map +1 -0
  11. package/dist/node/index-JIvzrtaA.d.ts +52 -0
  12. package/dist/node/index-JIvzrtaA.d.ts.map +1 -0
  13. package/dist/node/{index-CYl7ksS6.d.ts → index-JTD_xtEQ.d.ts} +15 -2
  14. package/dist/node/index-JTD_xtEQ.d.ts.map +1 -0
  15. package/dist/node/index-y_HBOfzO.d.ts +52 -0
  16. package/dist/node/index-y_HBOfzO.d.ts.map +1 -0
  17. package/dist/node/index.cjs +1 -1
  18. package/dist/node/index.d.ts +10 -9
  19. package/dist/node/index.d.ts.map +1 -1
  20. package/dist/node/index.js +1 -1
  21. package/dist/node/index.js.map +1 -1
  22. package/dist/node/programmatic/index.cjs +1 -0
  23. package/dist/node/programmatic/index.d.ts +2 -0
  24. package/dist/node/programmatic/index.js +1 -0
  25. package/dist/node/programmatic-6wLf68qJ.cjs +1 -0
  26. package/dist/node/programmatic-70dxIXtS.js +2 -0
  27. package/dist/node/programmatic-70dxIXtS.js.map +1 -0
  28. package/dist/node/testing/index.cjs +1 -1
  29. package/dist/node/testing/index.d.ts +2 -21
  30. package/dist/node/testing/index.js +1 -2
  31. package/package.json +15 -71
  32. package/src/__tests__/programmatic/programmatic-ask-user.test.ts +32 -0
  33. package/src/__tests__/programmatic/programmatic-driver.test.ts +107 -0
  34. package/src/__tests__/programmatic/programmatic-flows.test.ts +140 -0
  35. package/src/__tests__/transport-registry.stop-all.test.ts +53 -0
  36. package/src/headless/HeadlessInteractionChannel.ts +22 -5
  37. package/src/headless/__tests__/headless-goal-runner.test.ts +108 -0
  38. package/src/headless/__tests__/headless-runner.test.ts +2 -1
  39. package/src/headless/headless-runner.ts +67 -1
  40. package/src/headless/headless-stream-json.ts +1 -1
  41. package/src/headless/print-terminal.ts +1 -0
  42. package/src/index.ts +2 -5
  43. package/src/programmatic/ProgrammaticInteractionChannel.ts +82 -0
  44. package/src/programmatic/createProgrammaticAgent.ts +71 -0
  45. package/src/programmatic/index.ts +5 -0
  46. package/src/testing/index.ts +7 -4
  47. package/src/transport-registry.ts +15 -12
  48. package/dist/node/headless-CT2ibQnr.cjs +0 -15
  49. package/dist/node/headless-mRYilLfC.js.map +0 -1
  50. package/dist/node/http/index.cjs +0 -1
  51. package/dist/node/http/index.d.ts +0 -2
  52. package/dist/node/http/index.js +0 -1
  53. package/dist/node/http-2Jiuflc1.js +0 -2
  54. package/dist/node/http-2Jiuflc1.js.map +0 -1
  55. package/dist/node/http-CBAvefLw.cjs +0 -1
  56. package/dist/node/index-BNccqSpv.d.ts +0 -86
  57. package/dist/node/index-BNccqSpv.d.ts.map +0 -1
  58. package/dist/node/index-BUhHIf7X.d.ts +0 -86
  59. package/dist/node/index-BUhHIf7X.d.ts.map +0 -1
  60. package/dist/node/index-BnAGE-u9.d.ts +0 -33
  61. package/dist/node/index-BnAGE-u9.d.ts.map +0 -1
  62. package/dist/node/index-BrQ4gGw0.d.ts +0 -213
  63. package/dist/node/index-BrQ4gGw0.d.ts.map +0 -1
  64. package/dist/node/index-CYl7ksS6.d.ts.map +0 -1
  65. package/dist/node/index-CoeBF21y.d.ts +0 -213
  66. package/dist/node/index-CoeBF21y.d.ts.map +0 -1
  67. package/dist/node/index-DHt-2VQ-.d.ts +0 -46
  68. package/dist/node/index-DHt-2VQ-.d.ts.map +0 -1
  69. package/dist/node/index-DMwKN5Le.d.ts +0 -33
  70. package/dist/node/index-DMwKN5Le.d.ts.map +0 -1
  71. package/dist/node/index-E8Gx4-lc.d.ts.map +0 -1
  72. package/dist/node/index-c0M42fsA.d.ts +0 -46
  73. package/dist/node/index-c0M42fsA.d.ts.map +0 -1
  74. package/dist/node/mcp/index.cjs +0 -1
  75. package/dist/node/mcp/index.d.ts +0 -2
  76. package/dist/node/mcp/index.js +0 -1
  77. package/dist/node/mcp-BOglBJNy.cjs +0 -1
  78. package/dist/node/mcp-D3BBVK7C.js +0 -2
  79. package/dist/node/mcp-D3BBVK7C.js.map +0 -1
  80. package/dist/node/rolldown-runtime-CMqjfN_6.cjs +0 -1
  81. package/dist/node/testing/index.d.ts.map +0 -1
  82. package/dist/node/testing/index.js.map +0 -1
  83. package/dist/node/tui/index.cjs +0 -1
  84. package/dist/node/tui/index.d.ts +0 -2
  85. package/dist/node/tui/index.js +0 -1
  86. package/dist/node/tui-CcH5EsQh.js +0 -25
  87. package/dist/node/tui-CcH5EsQh.js.map +0 -1
  88. package/dist/node/tui-DznRbcku.cjs +0 -24
  89. package/dist/node/ws/index.cjs +0 -1
  90. package/dist/node/ws/index.d.ts +0 -2
  91. package/dist/node/ws/index.js +0 -1
  92. package/dist/node/ws-Dc2RUwVs.js +0 -2
  93. package/dist/node/ws-Dc2RUwVs.js.map +0 -1
  94. package/dist/node/ws-QNMQn5kg.cjs +0 -1
  95. package/src/http/__tests__/http-transport.test.ts +0 -55
  96. package/src/http/__tests__/routes.test.ts +0 -168
  97. package/src/http/http-transport.ts +0 -41
  98. package/src/http/index.ts +0 -4
  99. package/src/http/routes.ts +0 -152
  100. package/src/mcp/__tests__/mcp-server.test.ts +0 -66
  101. package/src/mcp/__tests__/mcp-transport.test.ts +0 -46
  102. package/src/mcp/index.ts +0 -4
  103. package/src/mcp/mcp-server.ts +0 -163
  104. package/src/mcp/mcp-transport.ts +0 -48
  105. package/src/testing/__tests__/scripted-provider.test.ts +0 -73
  106. package/src/testing/scripted-provider.ts +0 -73
  107. package/src/tui/App.tsx +0 -491
  108. package/src/tui/BackgroundTaskPanel.tsx +0 -36
  109. package/src/tui/CjkTextInput.tsx +0 -199
  110. package/src/tui/ConfirmPrompt.tsx +0 -70
  111. package/src/tui/ContextWarningBanner.tsx +0 -34
  112. package/src/tui/ExecutionWorkspaceDetailPane.tsx +0 -64
  113. package/src/tui/ExecutionWorkspaceSwitcher.tsx +0 -187
  114. package/src/tui/InputArea.tsx +0 -310
  115. package/src/tui/InteractivePrompt.tsx +0 -59
  116. package/src/tui/ListPicker.tsx +0 -95
  117. package/src/tui/MenuSelect.tsx +0 -104
  118. package/src/tui/MessageList.tsx +0 -284
  119. package/src/tui/PermissionPrompt.tsx +0 -86
  120. package/src/tui/PluginTUI.tsx +0 -258
  121. package/src/tui/SessionPicker.tsx +0 -68
  122. package/src/tui/SessionStatusBar.tsx +0 -73
  123. package/src/tui/SlashAutocomplete.tsx +0 -110
  124. package/src/tui/StatusBar.tsx +0 -236
  125. package/src/tui/StreamingIndicator.tsx +0 -93
  126. package/src/tui/TextPrompt.tsx +0 -81
  127. package/src/tui/ToolCommandOutput.tsx +0 -39
  128. package/src/tui/ToolDiffBlock.tsx +0 -32
  129. package/src/tui/TransportTUI.tsx +0 -117
  130. package/src/tui/TuiInteractionChannel.ts +0 -495
  131. package/src/tui/UpdateNotice.tsx +0 -14
  132. package/src/tui/UsageSummaryEntry.tsx +0 -39
  133. package/src/tui/WaveText.tsx +0 -44
  134. package/src/tui/__tests__/InteractivePrompt.test.tsx +0 -82
  135. package/src/tui/__tests__/ListPicker.test.tsx +0 -159
  136. package/src/tui/__tests__/MenuSelect.test.tsx +0 -103
  137. package/src/tui/__tests__/PluginTUI.test.tsx +0 -167
  138. package/src/tui/__tests__/SlashAutocomplete.test.tsx +0 -140
  139. package/src/tui/__tests__/TextPrompt.test.tsx +0 -98
  140. package/src/tui/__tests__/TuiInteractionChannel.display-contract.test.ts +0 -239
  141. package/src/tui/__tests__/TuiInteractionChannel.lifecycle.test.ts +0 -297
  142. package/src/tui/__tests__/TuiInteractionChannel.requestAction.test.ts +0 -124
  143. package/src/tui/__tests__/UpdateNotice.test.tsx +0 -15
  144. package/src/tui/__tests__/abort-after-permission.test.tsx +0 -169
  145. package/src/tui/__tests__/abort-streaming-e2e.test.tsx +0 -183
  146. package/src/tui/__tests__/background-task-panel.test.tsx +0 -53
  147. package/src/tui/__tests__/background-task-row-format.test.ts +0 -59
  148. package/src/tui/__tests__/channel-factory-integration.test.ts +0 -138
  149. package/src/tui/__tests__/cjk-text-input-flow.test.ts +0 -109
  150. package/src/tui/__tests__/cjk-text-input.test.ts +0 -191
  151. package/src/tui/__tests__/command-effect-handler.test.ts +0 -127
  152. package/src/tui/__tests__/command-output-summary.test.ts +0 -95
  153. package/src/tui/__tests__/compact-event-bridge.test.ts +0 -20
  154. package/src/tui/__tests__/confirm-permission-flow.test.ts +0 -130
  155. package/src/tui/__tests__/confirm-prompt.test.tsx +0 -87
  156. package/src/tui/__tests__/execution-workspace-switcher.test.tsx +0 -110
  157. package/src/tui/__tests__/execution-workspace-view-model.test.ts +0 -93
  158. package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +0 -125
  159. package/src/tui/__tests__/input-area-flow.test.ts +0 -164
  160. package/src/tui/__tests__/message-list-rendering.test.tsx +0 -353
  161. package/src/tui/__tests__/prompt-queue.test.tsx +0 -255
  162. package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +0 -233
  163. package/src/tui/__tests__/pty/pty-driver.ts +0 -135
  164. package/src/tui/__tests__/pty/tui-pty.ptytest.ts +0 -61
  165. package/src/tui/__tests__/render-channel-options.test.ts +0 -32
  166. package/src/tui/__tests__/render-markdown.test.ts +0 -72
  167. package/src/tui/__tests__/selection-flow.test.ts +0 -61
  168. package/src/tui/__tests__/session-init-poller.test.ts +0 -102
  169. package/src/tui/__tests__/session-naming.test.ts +0 -64
  170. package/src/tui/__tests__/session-switch-channel.test.tsx +0 -307
  171. package/src/tui/__tests__/slash-routing-effects.test.ts +0 -228
  172. package/src/tui/__tests__/status-activity.test.ts +0 -71
  173. package/src/tui/__tests__/status-bar.test.tsx +0 -177
  174. package/src/tui/__tests__/streaming-indicator.test.tsx +0 -137
  175. package/src/tui/__tests__/text-prompt-flow.test.ts +0 -77
  176. package/src/tui/__tests__/tui-channel-init-failure.test.ts +0 -57
  177. package/src/tui/__tests__/tui-state-manager.test.ts +0 -401
  178. package/src/tui/background-task-row-format.ts +0 -53
  179. package/src/tui/command-interaction.ts +0 -9
  180. package/src/tui/command-output-summary.ts +0 -122
  181. package/src/tui/create-default-tui-cli-adapter.ts +0 -41
  182. package/src/tui/execution-workspace-view-model.ts +0 -123
  183. package/src/tui/flows/cjk-text-input-flow.ts +0 -285
  184. package/src/tui/flows/confirm-prompt-flow.ts +0 -45
  185. package/src/tui/flows/input-area-flow.ts +0 -189
  186. package/src/tui/flows/permission-prompt-flow.ts +0 -85
  187. package/src/tui/flows/selection-flow.ts +0 -126
  188. package/src/tui/flows/session-init-poller.ts +0 -77
  189. package/src/tui/flows/text-prompt-flow.ts +0 -98
  190. package/src/tui/hooks/command-effect-handler.ts +0 -97
  191. package/src/tui/hooks/command-effect-queue.ts +0 -39
  192. package/src/tui/hooks/side-effects-types.ts +0 -35
  193. package/src/tui/hooks/useAutocomplete.ts +0 -87
  194. package/src/tui/hooks/usePluginCallbacks.ts +0 -31
  195. package/src/tui/hooks/usePluginScreenData.ts +0 -85
  196. package/src/tui/hooks/useSideEffects.ts +0 -175
  197. package/src/tui/hooks/useSlashRouting.ts +0 -118
  198. package/src/tui/hooks/useStatusLineSettings.ts +0 -37
  199. package/src/tui/hooks/useTuiChannel.ts +0 -95
  200. package/src/tui/index.ts +0 -14
  201. package/src/tui/interactions/CommandConfirm.tsx +0 -36
  202. package/src/tui/interactions/CommandPicker.tsx +0 -77
  203. package/src/tui/interactions/__tests__/CommandConfirm.test.tsx +0 -124
  204. package/src/tui/interactions/__tests__/CommandPicker.test.tsx +0 -138
  205. package/src/tui/plugin-tui-handlers.ts +0 -163
  206. package/src/tui/render-markdown.ts +0 -130
  207. package/src/tui/render.tsx +0 -129
  208. package/src/tui/session-naming.ts +0 -33
  209. package/src/tui/status-activity.ts +0 -63
  210. package/src/tui/tui-cli-adapter-context.tsx +0 -13
  211. package/src/tui/tui-cli-adapter.ts +0 -25
  212. package/src/tui/tui-state-manager.ts +0 -226
  213. package/src/tui/tui-transport.ts +0 -35
  214. package/src/tui/types.ts +0 -15
  215. package/src/tui/utils/__tests__/edit-diff.test.ts +0 -426
  216. package/src/tui/utils/__tests__/paste-detection.test.ts +0 -116
  217. package/src/tui/utils/__tests__/paste-labels.test.ts +0 -46
  218. package/src/tui/utils/__tests__/tool-call-extractor.test.ts +0 -227
  219. package/src/tui/utils/__tests__/tool-diff-summary.test.ts +0 -104
  220. package/src/tui/utils/edit-diff.ts +0 -153
  221. package/src/tui/utils/paste-labels.ts +0 -9
  222. package/src/tui/utils/tool-call-extractor.ts +0 -92
  223. package/src/tui/utils/tool-diff-summary.ts +0 -75
  224. package/src/ws/__tests__/ws-handler.test.ts +0 -409
  225. package/src/ws/__tests__/ws-transport.test.ts +0 -53
  226. package/src/ws/index.ts +0 -13
  227. package/src/ws/ws-background-messages.ts +0 -170
  228. package/src/ws/ws-handler.ts +0 -280
  229. package/src/ws/ws-protocol.ts +0 -78
  230. package/src/ws/ws-transport-configurable.ts +0 -128
  231. package/src/ws/ws-transport.ts +0 -42
@@ -1,199 +0,0 @@
1
- /**
2
- * CJK-aware TextInput component for Ink.
3
- *
4
- * Replaces ink-text-input with proper wide character support:
5
- * - Uses string-width for display width calculation
6
- * - Cursor position based on character index (not display columns)
7
- * - Renders CJK characters correctly (2 columns each)
8
- * - Uses refs for value/cursor to avoid React state batching issues
9
- * (IME sends multiple keystrokes synchronously, state updates are async)
10
- *
11
- * Drop-in replacement: same props as ink-text-input.
12
- */
13
-
14
- import chalk from 'chalk';
15
- import { Text, useInput, usePaste } from 'ink';
16
- import React, { useRef, useState } from 'react';
17
-
18
- import {
19
- applyCjkTextInput,
20
- applyCjkTextPaste,
21
- createCjkTextInputFlowState,
22
- syncCjkTextInputFlowState,
23
- type ICjkTextInputFlowState,
24
- } from './flows/cjk-text-input-flow.js';
25
-
26
- interface IProps {
27
- value: string;
28
- onChange: (value: string) => void;
29
- onSubmit?: (value: string) => void;
30
- onPaste?: (text: string, cursorPosition: number) => void;
31
- placeholder?: string;
32
- focus?: boolean;
33
- showCursor?: boolean;
34
- /** Available width in columns for visual line wrapping navigation */
35
- availableWidth?: number;
36
- /** Cursor position hint for external value changes. null = end (default). */
37
- cursorHint?: number | null;
38
- /** When false, parent flows own up/down arrow behavior. */
39
- enableVerticalNavigation?: boolean;
40
- }
41
-
42
- interface IInputHandlerOptions {
43
- stateRef: React.MutableRefObject<ICjkTextInputFlowState>;
44
- onChange: (value: string) => void;
45
- onSubmit?: (value: string) => void;
46
- onPaste?: (text: string, cursorPosition: number) => void;
47
- availableWidth?: number;
48
- focus: boolean;
49
- enableVerticalNavigation: boolean;
50
- forceRender: React.Dispatch<React.SetStateAction<number>>;
51
- }
52
-
53
- export default function CjkTextInput({
54
- value,
55
- onChange,
56
- onSubmit,
57
- onPaste,
58
- placeholder = '',
59
- focus = true,
60
- showCursor = true,
61
- availableWidth,
62
- cursorHint = null,
63
- enableVerticalNavigation = true,
64
- }: IProps): React.ReactElement {
65
- const stateRef = useRef<ICjkTextInputFlowState>(createCjkTextInputFlowState(value));
66
- const [, forceRender] = useState(0);
67
-
68
- // Sync ref when value changes from parent (e.g., setValue(''), tab completion, paste)
69
- stateRef.current = syncCjkTextInputFlowState(stateRef.current, value, cursorHint);
70
-
71
- useCjkTextInputHandlers({
72
- stateRef,
73
- onChange,
74
- onSubmit,
75
- onPaste,
76
- availableWidth,
77
- focus,
78
- enableVerticalNavigation,
79
- forceRender,
80
- });
81
-
82
- // Real terminal cursor positioning is intentionally omitted.
83
- // setCursorPosition(x, 0) crashes Terminal.app via Korean IME SIGSEGV.
84
- // Correct fix requires the input row's y offset from the bottom of the render,
85
- // which Ink does not expose. Tracked as a known limitation.
86
-
87
- return (
88
- <Text>
89
- {renderWithCursor(
90
- stateRef.current.value,
91
- stateRef.current.cursor,
92
- placeholder,
93
- showCursor && focus,
94
- )}
95
- </Text>
96
- );
97
- }
98
-
99
- function useCjkTextInputHandlers(options: IInputHandlerOptions): void {
100
- usePaste(
101
- (text) => {
102
- applyCjkFlowSafely(options, () =>
103
- applyCjkTextPaste(options.stateRef.current, text, createFlowOptions(options)),
104
- );
105
- },
106
- { isActive: options.focus },
107
- );
108
-
109
- useInput(
110
- (input, key) => {
111
- applyCjkFlowSafely(options, () =>
112
- applyCjkTextInput(options.stateRef.current, input, key, createFlowOptions(options)),
113
- );
114
- },
115
- { isActive: options.focus },
116
- );
117
- }
118
-
119
- function createFlowOptions(options: IInputHandlerOptions): {
120
- availableWidth?: number;
121
- canPaste: boolean;
122
- enableVerticalNavigation: boolean;
123
- } {
124
- return {
125
- availableWidth: options.availableWidth,
126
- canPaste: options.onPaste !== undefined,
127
- enableVerticalNavigation: options.enableVerticalNavigation,
128
- };
129
- }
130
-
131
- function applyCjkFlowSafely(
132
- options: IInputHandlerOptions,
133
- run: () => ReturnType<typeof applyCjkTextInput>,
134
- ): void {
135
- try {
136
- const result = run();
137
- options.stateRef.current = result.state;
138
- applyCjkTextInputEffect(
139
- result.effect,
140
- options.onChange,
141
- options.onSubmit,
142
- options.onPaste,
143
- options.forceRender,
144
- );
145
- } catch {
146
- // allow-fallback: Korean IME in raw mode can produce unexpected byte sequences
147
- }
148
- }
149
-
150
- function applyCjkTextInputEffect(
151
- effect: ReturnType<typeof applyCjkTextInput>['effect'],
152
- onChange: (value: string) => void,
153
- onSubmit: ((value: string) => void) | undefined,
154
- onPaste: ((text: string, cursorPosition: number) => void) | undefined,
155
- forceRender: React.Dispatch<React.SetStateAction<number>>,
156
- ): void {
157
- if (effect.type === 'change') {
158
- onChange(effect.value);
159
- } else if (effect.type === 'submit') {
160
- onSubmit?.(effect.value);
161
- } else if (effect.type === 'paste') {
162
- onPaste?.(effect.text, effect.cursor);
163
- } else if (effect.type === 'render') {
164
- forceRender((n) => n + 1);
165
- }
166
- }
167
-
168
- /** Render text with an inverse-style cursor at the correct position */
169
- function renderWithCursor(
170
- value: string,
171
- cursorOffset: number,
172
- placeholder: string,
173
- showCursor: boolean,
174
- ): string {
175
- if (!showCursor) {
176
- return value.length > 0 ? value : placeholder ? chalk.gray(placeholder) : '';
177
- }
178
-
179
- if (value.length === 0) {
180
- if (placeholder.length > 0) {
181
- return chalk.inverse(placeholder[0]) + chalk.gray(placeholder.slice(1));
182
- }
183
- return chalk.inverse(' ');
184
- }
185
-
186
- const chars = [...value];
187
- let rendered = '';
188
-
189
- for (let i = 0; i < chars.length; i++) {
190
- const char = chars[i] ?? '';
191
- rendered += i === cursorOffset ? chalk.inverse(char) : char;
192
- }
193
-
194
- if (cursorOffset >= chars.length) {
195
- rendered += chalk.inverse(' ');
196
- }
197
-
198
- return rendered;
199
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * Reusable confirmation prompt with arrow-key selection.
3
- * Used by model change, permission prompts, and other yes/no confirmations.
4
- */
5
-
6
- import { Box, Text, useInput } from 'ink';
7
- import React, { useState, useRef, useCallback } from 'react';
8
-
9
- import {
10
- applyConfirmPromptInput,
11
- getConfirmPromptInputAction,
12
- type TConfirmPromptInputAction,
13
- } from './flows/confirm-prompt-flow.js';
14
- import { createSelectionFlowState, type ISelectionFlowState } from './flows/selection-flow.js';
15
-
16
- interface IProps {
17
- /** Message to display above the options */
18
- message: string;
19
- /** Options to select from (default: ['Yes', 'No']) */
20
- options?: string[];
21
- /** Callback with the selected index */
22
- onSelect: (index: number) => void;
23
- }
24
-
25
- export default function ConfirmPrompt({
26
- message,
27
- options = ['Yes', 'No'],
28
- onSelect,
29
- }: IProps): React.ReactElement {
30
- const [state, setState] = useState<ISelectionFlowState>(() => createSelectionFlowState());
31
- const stateRef = useRef(state);
32
- const applyAction = useCallback(
33
- (action: TConfirmPromptInputAction): void => {
34
- const result = applyConfirmPromptInput(stateRef.current, action, options.length);
35
- stateRef.current = result.state;
36
- setState(result.state);
37
- if (result.effect.type === 'select') {
38
- onSelect(result.effect.index);
39
- }
40
- },
41
- [onSelect, options.length],
42
- );
43
-
44
- useInput((input, key) => {
45
- const action = getConfirmPromptInputAction(input, key, options.length);
46
- if (action !== undefined) {
47
- applyAction(action);
48
- }
49
- });
50
-
51
- return (
52
- <Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
53
- <Text color="yellow">{message}</Text>
54
- <Box marginTop={1}>
55
- {options.map((opt, i) => (
56
- <Box key={opt} marginRight={2}>
57
- <Text
58
- color={i === state.selectedIndex ? 'cyan' : undefined}
59
- bold={i === state.selectedIndex}
60
- >
61
- {i === state.selectedIndex ? '> ' : ' '}
62
- {opt}
63
- </Text>
64
- </Box>
65
- ))}
66
- </Box>
67
- <Text dimColor> arrow keys to select, Enter to confirm</Text>
68
- </Box>
69
- );
70
- }
@@ -1,34 +0,0 @@
1
- import { Box, Text } from 'ink';
2
- import React from 'react';
3
-
4
- interface IProps {
5
- percentage: number;
6
- }
7
-
8
- const COMPACT_SUGGESTION_THRESHOLD = 70;
9
- const CRITICAL_THRESHOLD = 90;
10
-
11
- export function ContextWarningBanner({ percentage }: IProps): React.ReactElement | null {
12
- if (percentage >= CRITICAL_THRESHOLD) {
13
- return (
14
- <Box borderStyle="single" borderColor="red" paddingX={1}>
15
- <Text color="red" bold>
16
- ⚠ Context at {Math.round(percentage)}% — window nearly full. Run /compact to summarize
17
- the conversation.
18
- </Text>
19
- </Box>
20
- );
21
- }
22
-
23
- if (percentage >= COMPACT_SUGGESTION_THRESHOLD) {
24
- return (
25
- <Box paddingX={1}>
26
- <Text color="yellow">
27
- Context at {Math.round(percentage)}% — consider running /compact to free up space.
28
- </Text>
29
- </Box>
30
- );
31
- }
32
-
33
- return null;
34
- }
@@ -1,64 +0,0 @@
1
- import { Box, Text } from 'ink';
2
- import React from 'react';
3
-
4
- import {
5
- formatExecutionDetailRecord,
6
- formatExecutionWorkspaceEntryRow,
7
- } from './execution-workspace-view-model.js';
8
-
9
- import type {
10
- IExecutionDetailPage,
11
- IExecutionWorkspaceEntry,
12
- TExecutionDetailRecordKind,
13
- } from '@robota-sdk/agent-interface-transport';
14
-
15
- const MAX_VISIBLE_DETAIL_RECORDS = 12;
16
-
17
- interface IProps {
18
- entry: IExecutionWorkspaceEntry;
19
- page: IExecutionDetailPage | null;
20
- loading?: boolean;
21
- error?: string;
22
- }
23
-
24
- export default function ExecutionWorkspaceDetailPane({
25
- entry,
26
- page,
27
- loading,
28
- error,
29
- }: IProps): React.ReactElement {
30
- const row = formatExecutionWorkspaceEntryRow(entry, { selectedEntryId: entry.id });
31
- const records = page?.records.slice(-MAX_VISIBLE_DETAIL_RECORDS) ?? [];
32
-
33
- return (
34
- <Box flexDirection="column" marginBottom={1}>
35
- <Text color="cyan" bold>
36
- {`Viewing ${row.title}`}
37
- </Text>
38
- <Text dimColor>
39
- {row.statusLabel}
40
- {row.subtitle ? ` · ${row.subtitle}` : ''}
41
- {row.preview ? ` · ${row.preview}` : ''}
42
- </Text>
43
- {loading ? <Text dimColor>Loading workspace detail...</Text> : null}
44
- {error ? <Text color="red">{error}</Text> : null}
45
- {!loading && !error && records.length === 0 ? <Text dimColor>No detail yet</Text> : null}
46
- {!loading &&
47
- !error &&
48
- records.map((record) => (
49
- <Text key={record.id} color={getDetailRecordColor(record.kind)}>
50
- {formatExecutionDetailRecord(record)}
51
- </Text>
52
- ))}
53
- {page?.nextCursor ? <Text dimColor>... more detail available</Text> : null}
54
- </Box>
55
- );
56
- }
57
-
58
- function getDetailRecordColor(kind: TExecutionDetailRecordKind): string | undefined {
59
- if (kind === 'error') return 'red';
60
- if (kind === 'result') return 'green';
61
- if (kind === 'process_output') return 'white';
62
- if (kind === 'group_summary') return 'cyan';
63
- return undefined;
64
- }
@@ -1,187 +0,0 @@
1
- import { Box, Text, useInput } from 'ink';
2
- import React, { useEffect, useRef, useState } from 'react';
3
-
4
- import { formatExecutionWorkspaceEntryRow } from './execution-workspace-view-model.js';
5
- import {
6
- applySelectionInput,
7
- createSelectionFlowState,
8
- getVerticalSelectionInputAction,
9
- normalizeSelectionState,
10
- type ISelectionFlowState,
11
- type TSelectionInputAction,
12
- } from './flows/selection-flow.js';
13
-
14
- import type {
15
- IExecutionWorkspaceEntry,
16
- IExecutionWorkspaceSnapshot,
17
- } from '@robota-sdk/agent-interface-transport';
18
-
19
- const MAX_VISIBLE_WORKSPACE_ENTRIES = 8;
20
-
21
- interface IProps {
22
- snapshot: IExecutionWorkspaceSnapshot | null;
23
- selectedEntryId?: string;
24
- onSelect: (entryId: string) => void;
25
- onClose: () => void;
26
- }
27
-
28
- export default function ExecutionWorkspaceSwitcher({
29
- snapshot,
30
- selectedEntryId,
31
- onSelect,
32
- onClose,
33
- }: IProps): React.ReactElement {
34
- const entries = [...(snapshot?.entries ?? [])];
35
- const { normalized, visibleEntries, applyAction } = useWorkspaceSwitcherSelection({
36
- entries,
37
- selectedEntryId,
38
- onSelect,
39
- onClose,
40
- });
41
-
42
- useInput((_input, key) => {
43
- const action = getVerticalSelectionInputAction(key);
44
- if (action !== undefined) applyAction(action);
45
- });
46
-
47
- return (
48
- <Box flexDirection="column" borderStyle="round" borderColor="cyan" paddingX={1}>
49
- <Text color="cyan" bold>
50
- Execution workspace
51
- </Text>
52
- <Box flexDirection="column" marginTop={1}>
53
- {visibleEntries.length === 0 ? (
54
- <Text dimColor>No workspace entries</Text>
55
- ) : (
56
- visibleEntries.map((entry, index) => (
57
- <ExecutionWorkspaceSwitcherRow
58
- key={entry.id}
59
- entry={entry}
60
- isFocused={normalized.scrollOffset + index === normalized.selectedIndex}
61
- selectedEntryId={selectedEntryId}
62
- />
63
- ))
64
- )}
65
- </Box>
66
- <Text dimColor>Ctrl+B Close ↑↓ Navigate Enter Switch Esc Close</Text>
67
- </Box>
68
- );
69
- }
70
-
71
- interface IUseWorkspaceSwitcherSelectionInput {
72
- entries: IExecutionWorkspaceEntry[];
73
- selectedEntryId?: string;
74
- onSelect: (entryId: string) => void;
75
- onClose: () => void;
76
- }
77
-
78
- function useWorkspaceSwitcherSelection({
79
- entries,
80
- selectedEntryId,
81
- onSelect,
82
- onClose,
83
- }: IUseWorkspaceSwitcherSelectionInput): {
84
- normalized: ISelectionFlowState;
85
- visibleEntries: IExecutionWorkspaceEntry[];
86
- applyAction: (action: TSelectionInputAction) => void;
87
- } {
88
- const [state, setState] = useState<ISelectionFlowState>(() => createSelectionFlowState());
89
- const stateRef = useRef(state);
90
-
91
- useEffect(() => {
92
- const selectedIndex = Math.max(
93
- 0,
94
- entries.findIndex((entry) => entry.id === selectedEntryId),
95
- );
96
- const nextState = createNormalizedSelection({ selectedIndex, itemCount: entries.length });
97
- stateRef.current = nextState;
98
- setState(nextState);
99
- }, [entries.length, selectedEntryId]);
100
-
101
- const normalized = createNormalizedSelection({
102
- selectedIndex: state.selectedIndex,
103
- scrollOffset: state.scrollOffset,
104
- itemCount: entries.length,
105
- });
106
- if (normalized !== state) stateRef.current = normalized;
107
- return {
108
- normalized,
109
- visibleEntries: entries.slice(
110
- normalized.scrollOffset,
111
- normalized.scrollOffset + MAX_VISIBLE_WORKSPACE_ENTRIES,
112
- ),
113
- applyAction: createApplyAction({ entries, stateRef, setState, onSelect, onClose }),
114
- };
115
- }
116
-
117
- function createApplyAction({
118
- entries,
119
- stateRef,
120
- setState,
121
- onSelect,
122
- onClose,
123
- }: {
124
- entries: IExecutionWorkspaceEntry[];
125
- stateRef: React.MutableRefObject<ISelectionFlowState>;
126
- setState: React.Dispatch<React.SetStateAction<ISelectionFlowState>>;
127
- onSelect: (entryId: string) => void;
128
- onClose: () => void;
129
- }): (action: TSelectionInputAction) => void {
130
- return (action): void => {
131
- const result = applySelectionInput(stateRef.current, action, {
132
- itemCount: entries.length,
133
- maxVisible: MAX_VISIBLE_WORKSPACE_ENTRIES,
134
- });
135
- const nextState =
136
- result.effect.type === 'select' || result.effect.type === 'cancel'
137
- ? { ...result.state, resolved: false }
138
- : result.state;
139
- stateRef.current = nextState;
140
- setState(nextState);
141
- if (result.effect.type === 'cancel') {
142
- onClose();
143
- } else if (result.effect.type === 'select') {
144
- const entry = entries[result.effect.index];
145
- if (entry) onSelect(entry.id);
146
- }
147
- };
148
- }
149
-
150
- function createNormalizedSelection(input: {
151
- selectedIndex: number;
152
- scrollOffset?: number;
153
- itemCount: number;
154
- }): ISelectionFlowState {
155
- return normalizeSelectionState(
156
- {
157
- selectedIndex: input.selectedIndex,
158
- scrollOffset: input.scrollOffset ?? 0,
159
- resolved: false,
160
- },
161
- { itemCount: input.itemCount, maxVisible: MAX_VISIBLE_WORKSPACE_ENTRIES },
162
- );
163
- }
164
-
165
- function ExecutionWorkspaceSwitcherRow({
166
- entry,
167
- isFocused,
168
- selectedEntryId,
169
- }: {
170
- entry: IExecutionWorkspaceEntry;
171
- isFocused: boolean;
172
- selectedEntryId?: string;
173
- }): React.ReactElement {
174
- const row = formatExecutionWorkspaceEntryRow(entry, { selectedEntryId });
175
- return (
176
- <Text>
177
- <Text color={isFocused ? 'cyan' : undefined} bold={isFocused}>
178
- {isFocused ? '> ' : ' '}
179
- </Text>
180
- <Text color={row.color}>{row.radio}</Text>
181
- <Text color={isFocused ? 'cyan' : undefined} bold={isFocused}>{` ${row.title}`}</Text>
182
- <Text dimColor>{` · ${row.statusLabel}`}</Text>
183
- {row.subtitle ? <Text dimColor>{` · ${row.subtitle}`}</Text> : null}
184
- {row.preview ? <Text dimColor>{` · ${row.preview}`}</Text> : null}
185
- </Text>
186
- );
187
- }