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

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 (187) hide show
  1. package/README.md +10 -10
  2. package/dist/node/headless/index.cjs +1 -1
  3. package/dist/node/{headless-CT2ibQnr.cjs → headless-OnpVk4-k.cjs} +7 -7
  4. package/dist/node/index.cjs +1 -1
  5. package/dist/node/index.d.ts +1 -6
  6. package/dist/node/index.d.ts.map +1 -1
  7. package/dist/node/index.js +1 -1
  8. package/dist/node/index.js.map +1 -1
  9. package/package.json +7 -75
  10. package/src/index.ts +1 -5
  11. package/src/transport-registry.ts +0 -9
  12. package/dist/node/http/index.cjs +0 -1
  13. package/dist/node/http/index.d.ts +0 -2
  14. package/dist/node/http/index.js +0 -1
  15. package/dist/node/http-2Jiuflc1.js +0 -2
  16. package/dist/node/http-2Jiuflc1.js.map +0 -1
  17. package/dist/node/http-CBAvefLw.cjs +0 -1
  18. package/dist/node/index-BNccqSpv.d.ts +0 -86
  19. package/dist/node/index-BNccqSpv.d.ts.map +0 -1
  20. package/dist/node/index-BUhHIf7X.d.ts +0 -86
  21. package/dist/node/index-BUhHIf7X.d.ts.map +0 -1
  22. package/dist/node/index-BnAGE-u9.d.ts +0 -33
  23. package/dist/node/index-BnAGE-u9.d.ts.map +0 -1
  24. package/dist/node/index-BrQ4gGw0.d.ts +0 -213
  25. package/dist/node/index-BrQ4gGw0.d.ts.map +0 -1
  26. package/dist/node/index-CoeBF21y.d.ts +0 -213
  27. package/dist/node/index-CoeBF21y.d.ts.map +0 -1
  28. package/dist/node/index-DHt-2VQ-.d.ts +0 -46
  29. package/dist/node/index-DHt-2VQ-.d.ts.map +0 -1
  30. package/dist/node/index-DMwKN5Le.d.ts +0 -33
  31. package/dist/node/index-DMwKN5Le.d.ts.map +0 -1
  32. package/dist/node/index-c0M42fsA.d.ts +0 -46
  33. package/dist/node/index-c0M42fsA.d.ts.map +0 -1
  34. package/dist/node/mcp/index.cjs +0 -1
  35. package/dist/node/mcp/index.d.ts +0 -2
  36. package/dist/node/mcp/index.js +0 -1
  37. package/dist/node/mcp-BOglBJNy.cjs +0 -1
  38. package/dist/node/mcp-D3BBVK7C.js +0 -2
  39. package/dist/node/mcp-D3BBVK7C.js.map +0 -1
  40. package/dist/node/rolldown-runtime-CMqjfN_6.cjs +0 -1
  41. package/dist/node/tui/index.cjs +0 -1
  42. package/dist/node/tui/index.d.ts +0 -2
  43. package/dist/node/tui/index.js +0 -1
  44. package/dist/node/tui-CcH5EsQh.js +0 -25
  45. package/dist/node/tui-CcH5EsQh.js.map +0 -1
  46. package/dist/node/tui-DznRbcku.cjs +0 -24
  47. package/dist/node/ws/index.cjs +0 -1
  48. package/dist/node/ws/index.d.ts +0 -2
  49. package/dist/node/ws/index.js +0 -1
  50. package/dist/node/ws-Dc2RUwVs.js +0 -2
  51. package/dist/node/ws-Dc2RUwVs.js.map +0 -1
  52. package/dist/node/ws-QNMQn5kg.cjs +0 -1
  53. package/src/http/__tests__/http-transport.test.ts +0 -55
  54. package/src/http/__tests__/routes.test.ts +0 -168
  55. package/src/http/http-transport.ts +0 -41
  56. package/src/http/index.ts +0 -4
  57. package/src/http/routes.ts +0 -152
  58. package/src/mcp/__tests__/mcp-server.test.ts +0 -66
  59. package/src/mcp/__tests__/mcp-transport.test.ts +0 -46
  60. package/src/mcp/index.ts +0 -4
  61. package/src/mcp/mcp-server.ts +0 -163
  62. package/src/mcp/mcp-transport.ts +0 -48
  63. package/src/tui/App.tsx +0 -491
  64. package/src/tui/BackgroundTaskPanel.tsx +0 -36
  65. package/src/tui/CjkTextInput.tsx +0 -199
  66. package/src/tui/ConfirmPrompt.tsx +0 -70
  67. package/src/tui/ContextWarningBanner.tsx +0 -34
  68. package/src/tui/ExecutionWorkspaceDetailPane.tsx +0 -64
  69. package/src/tui/ExecutionWorkspaceSwitcher.tsx +0 -187
  70. package/src/tui/InputArea.tsx +0 -310
  71. package/src/tui/InteractivePrompt.tsx +0 -59
  72. package/src/tui/ListPicker.tsx +0 -95
  73. package/src/tui/MenuSelect.tsx +0 -104
  74. package/src/tui/MessageList.tsx +0 -284
  75. package/src/tui/PermissionPrompt.tsx +0 -86
  76. package/src/tui/PluginTUI.tsx +0 -258
  77. package/src/tui/SessionPicker.tsx +0 -68
  78. package/src/tui/SessionStatusBar.tsx +0 -73
  79. package/src/tui/SlashAutocomplete.tsx +0 -110
  80. package/src/tui/StatusBar.tsx +0 -236
  81. package/src/tui/StreamingIndicator.tsx +0 -93
  82. package/src/tui/TextPrompt.tsx +0 -81
  83. package/src/tui/ToolCommandOutput.tsx +0 -39
  84. package/src/tui/ToolDiffBlock.tsx +0 -32
  85. package/src/tui/TransportTUI.tsx +0 -117
  86. package/src/tui/TuiInteractionChannel.ts +0 -495
  87. package/src/tui/UpdateNotice.tsx +0 -14
  88. package/src/tui/UsageSummaryEntry.tsx +0 -39
  89. package/src/tui/WaveText.tsx +0 -44
  90. package/src/tui/__tests__/InteractivePrompt.test.tsx +0 -82
  91. package/src/tui/__tests__/ListPicker.test.tsx +0 -159
  92. package/src/tui/__tests__/MenuSelect.test.tsx +0 -103
  93. package/src/tui/__tests__/PluginTUI.test.tsx +0 -167
  94. package/src/tui/__tests__/SlashAutocomplete.test.tsx +0 -140
  95. package/src/tui/__tests__/TextPrompt.test.tsx +0 -98
  96. package/src/tui/__tests__/TuiInteractionChannel.display-contract.test.ts +0 -239
  97. package/src/tui/__tests__/TuiInteractionChannel.lifecycle.test.ts +0 -297
  98. package/src/tui/__tests__/TuiInteractionChannel.requestAction.test.ts +0 -124
  99. package/src/tui/__tests__/UpdateNotice.test.tsx +0 -15
  100. package/src/tui/__tests__/abort-after-permission.test.tsx +0 -169
  101. package/src/tui/__tests__/abort-streaming-e2e.test.tsx +0 -183
  102. package/src/tui/__tests__/background-task-panel.test.tsx +0 -53
  103. package/src/tui/__tests__/background-task-row-format.test.ts +0 -59
  104. package/src/tui/__tests__/channel-factory-integration.test.ts +0 -138
  105. package/src/tui/__tests__/cjk-text-input-flow.test.ts +0 -109
  106. package/src/tui/__tests__/cjk-text-input.test.ts +0 -191
  107. package/src/tui/__tests__/command-effect-handler.test.ts +0 -127
  108. package/src/tui/__tests__/command-output-summary.test.ts +0 -95
  109. package/src/tui/__tests__/compact-event-bridge.test.ts +0 -20
  110. package/src/tui/__tests__/confirm-permission-flow.test.ts +0 -130
  111. package/src/tui/__tests__/confirm-prompt.test.tsx +0 -87
  112. package/src/tui/__tests__/execution-workspace-switcher.test.tsx +0 -110
  113. package/src/tui/__tests__/execution-workspace-view-model.test.ts +0 -93
  114. package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +0 -125
  115. package/src/tui/__tests__/input-area-flow.test.ts +0 -164
  116. package/src/tui/__tests__/message-list-rendering.test.tsx +0 -353
  117. package/src/tui/__tests__/prompt-queue.test.tsx +0 -255
  118. package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +0 -233
  119. package/src/tui/__tests__/pty/pty-driver.ts +0 -135
  120. package/src/tui/__tests__/pty/tui-pty.ptytest.ts +0 -61
  121. package/src/tui/__tests__/render-channel-options.test.ts +0 -32
  122. package/src/tui/__tests__/render-markdown.test.ts +0 -72
  123. package/src/tui/__tests__/selection-flow.test.ts +0 -61
  124. package/src/tui/__tests__/session-init-poller.test.ts +0 -102
  125. package/src/tui/__tests__/session-naming.test.ts +0 -64
  126. package/src/tui/__tests__/session-switch-channel.test.tsx +0 -307
  127. package/src/tui/__tests__/slash-routing-effects.test.ts +0 -228
  128. package/src/tui/__tests__/status-activity.test.ts +0 -71
  129. package/src/tui/__tests__/status-bar.test.tsx +0 -177
  130. package/src/tui/__tests__/streaming-indicator.test.tsx +0 -137
  131. package/src/tui/__tests__/text-prompt-flow.test.ts +0 -77
  132. package/src/tui/__tests__/tui-channel-init-failure.test.ts +0 -57
  133. package/src/tui/__tests__/tui-state-manager.test.ts +0 -401
  134. package/src/tui/background-task-row-format.ts +0 -53
  135. package/src/tui/command-interaction.ts +0 -9
  136. package/src/tui/command-output-summary.ts +0 -122
  137. package/src/tui/create-default-tui-cli-adapter.ts +0 -41
  138. package/src/tui/execution-workspace-view-model.ts +0 -123
  139. package/src/tui/flows/cjk-text-input-flow.ts +0 -285
  140. package/src/tui/flows/confirm-prompt-flow.ts +0 -45
  141. package/src/tui/flows/input-area-flow.ts +0 -189
  142. package/src/tui/flows/permission-prompt-flow.ts +0 -85
  143. package/src/tui/flows/selection-flow.ts +0 -126
  144. package/src/tui/flows/session-init-poller.ts +0 -77
  145. package/src/tui/flows/text-prompt-flow.ts +0 -98
  146. package/src/tui/hooks/command-effect-handler.ts +0 -97
  147. package/src/tui/hooks/command-effect-queue.ts +0 -39
  148. package/src/tui/hooks/side-effects-types.ts +0 -35
  149. package/src/tui/hooks/useAutocomplete.ts +0 -87
  150. package/src/tui/hooks/usePluginCallbacks.ts +0 -31
  151. package/src/tui/hooks/usePluginScreenData.ts +0 -85
  152. package/src/tui/hooks/useSideEffects.ts +0 -175
  153. package/src/tui/hooks/useSlashRouting.ts +0 -118
  154. package/src/tui/hooks/useStatusLineSettings.ts +0 -37
  155. package/src/tui/hooks/useTuiChannel.ts +0 -95
  156. package/src/tui/index.ts +0 -14
  157. package/src/tui/interactions/CommandConfirm.tsx +0 -36
  158. package/src/tui/interactions/CommandPicker.tsx +0 -77
  159. package/src/tui/interactions/__tests__/CommandConfirm.test.tsx +0 -124
  160. package/src/tui/interactions/__tests__/CommandPicker.test.tsx +0 -138
  161. package/src/tui/plugin-tui-handlers.ts +0 -163
  162. package/src/tui/render-markdown.ts +0 -130
  163. package/src/tui/render.tsx +0 -129
  164. package/src/tui/session-naming.ts +0 -33
  165. package/src/tui/status-activity.ts +0 -63
  166. package/src/tui/tui-cli-adapter-context.tsx +0 -13
  167. package/src/tui/tui-cli-adapter.ts +0 -25
  168. package/src/tui/tui-state-manager.ts +0 -226
  169. package/src/tui/tui-transport.ts +0 -35
  170. package/src/tui/types.ts +0 -15
  171. package/src/tui/utils/__tests__/edit-diff.test.ts +0 -426
  172. package/src/tui/utils/__tests__/paste-detection.test.ts +0 -116
  173. package/src/tui/utils/__tests__/paste-labels.test.ts +0 -46
  174. package/src/tui/utils/__tests__/tool-call-extractor.test.ts +0 -227
  175. package/src/tui/utils/__tests__/tool-diff-summary.test.ts +0 -104
  176. package/src/tui/utils/edit-diff.ts +0 -153
  177. package/src/tui/utils/paste-labels.ts +0 -9
  178. package/src/tui/utils/tool-call-extractor.ts +0 -92
  179. package/src/tui/utils/tool-diff-summary.ts +0 -75
  180. package/src/ws/__tests__/ws-handler.test.ts +0 -409
  181. package/src/ws/__tests__/ws-transport.test.ts +0 -53
  182. package/src/ws/index.ts +0 -13
  183. package/src/ws/ws-background-messages.ts +0 -170
  184. package/src/ws/ws-handler.ts +0 -280
  185. package/src/ws/ws-protocol.ts +0 -78
  186. package/src/ws/ws-transport-configurable.ts +0 -128
  187. package/src/ws/ws-transport.ts +0 -42
package/src/tui/App.tsx DELETED
@@ -1,491 +0,0 @@
1
- import { createSystemMessage, messageToHistoryEntry } from '@robota-sdk/agent-core';
2
- import { listResumableSessionSummaries } from '@robota-sdk/agent-framework';
3
- import { Box, Static, Text, useApp, useInput } from 'ink';
4
- import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react';
5
-
6
- import BackgroundTaskPanel from './BackgroundTaskPanel.js';
7
- import { ContextWarningBanner } from './ContextWarningBanner.js';
8
- import {
9
- countActiveBackgroundWorkspaceEntries,
10
- getDefaultBackgroundWorkspaceEntries,
11
- } from './execution-workspace-view-model.js';
12
- import ExecutionWorkspaceDetailPane from './ExecutionWorkspaceDetailPane.js';
13
- import ExecutionWorkspaceSwitcher from './ExecutionWorkspaceSwitcher.js';
14
- import { usePluginCallbacks } from './hooks/usePluginCallbacks.js';
15
- import { useSideEffects } from './hooks/useSideEffects.js';
16
- import { useStatusLineSettings } from './hooks/useStatusLineSettings.js';
17
- import { useTuiChannel } from './hooks/useTuiChannel.js';
18
- import InputArea from './InputArea.js';
19
- import InteractivePrompt from './InteractivePrompt.js';
20
- import MessageList from './MessageList.js';
21
- import PermissionPrompt from './PermissionPrompt.js';
22
- import PluginTUI from './PluginTUI.js';
23
- import SessionPicker from './SessionPicker.js';
24
- import SessionStatusBar from './SessionStatusBar.js';
25
- import StreamingIndicator from './StreamingIndicator.js';
26
- import TransportTUI from './TransportTUI.js';
27
- import { TuiCliAdapterProvider } from './tui-cli-adapter-context.js';
28
- import UpdateNotice from './UpdateNotice.js';
29
-
30
- import type { ITuiCliAdapter } from './tui-cli-adapter.js';
31
- import type { TuiInteractionChannel } from './TuiInteractionChannel.js';
32
- import type { TPermissionMode } from '@robota-sdk/agent-core';
33
- import type {
34
- IExecutionDetailPage,
35
- IInteractiveSession,
36
- IInteractiveSessionStore,
37
- ITransportRegistryView,
38
- } from '@robota-sdk/agent-interface-transport';
39
-
40
- interface IProps {
41
- cwd: string;
42
- /**
43
- * Sole channel source (CLI-B12): App owns the channel lifecycle in React state.
44
- * The initial channel and every session-switch replacement come from this factory.
45
- */
46
- createChannel: (resumeSessionId?: string) => TuiInteractionChannel;
47
- providerOverride?: string | undefined;
48
- providerType?: string | undefined;
49
- modelId?: string;
50
- permissionMode?: TPermissionMode;
51
- version?: string;
52
- sessionStore?: IInteractiveSessionStore;
53
- resumeSessionId?: string;
54
- showSessionPickerOnStart?: boolean;
55
- startupUpdateNotice?: Promise<string | undefined>;
56
- transportRegistry?: ITransportRegistryView<IInteractiveSession>;
57
- cliAdapter: ITuiCliAdapter;
58
- }
59
-
60
- export default function App(props: IProps): React.ReactElement {
61
- // Lazy initializer: channel construction is side-effect-free (object wiring only);
62
- // I/O starts in AppInner's effect via channel.start(). Runs once per mount.
63
- const [sessionState, setSessionState] = useState<{
64
- channel: TuiInteractionChannel;
65
- sessionId: string | undefined;
66
- }>(() => ({
67
- channel: props.createChannel(props.resumeSessionId),
68
- sessionId: props.resumeSessionId,
69
- }));
70
- const [showInitialSessionPicker, setShowInitialSessionPicker] = useState(
71
- props.showSessionPickerOnStart ?? false,
72
- );
73
-
74
- return (
75
- <TuiCliAdapterProvider value={props.cliAdapter}>
76
- <AppInner
77
- key={sessionState.sessionId ?? '__new__'}
78
- {...props}
79
- channel={sessionState.channel}
80
- showSessionPickerOnStart={showInitialSessionPicker}
81
- resumeSessionId={sessionState.sessionId}
82
- onSessionSwitch={(sessionId) => {
83
- setShowInitialSessionPicker(false);
84
- // Stop the old channel BEFORE the new one becomes active so it can
85
- // never receive events addressed to the new session (CLI-B12).
86
- void sessionState.channel.stop();
87
- setSessionState({ channel: props.createChannel(sessionId), sessionId });
88
- }}
89
- />
90
- </TuiCliAdapterProvider>
91
- );
92
- }
93
-
94
- function AppInner(
95
- props: IProps & {
96
- channel: TuiInteractionChannel;
97
- onSessionSwitch: (sessionId: string) => void;
98
- },
99
- ): React.ReactElement {
100
- const cwd = props.cwd;
101
- const { channel } = props;
102
-
103
- const {
104
- interactiveSession,
105
- registry,
106
- commandEffectQueue,
107
- history,
108
- addEntry,
109
- streamingText,
110
- activeTools,
111
- isThinking,
112
- isAborting,
113
- isShuttingDown,
114
- pendingPrompt,
115
- executionWorkspaceSnapshot,
116
- selectedExecutionEntryId,
117
- selectExecutionWorkspaceEntry,
118
- readExecutionWorkspaceDetail,
119
- permissionRequest,
120
- contextState,
121
- handleSubmit: baseHandleSubmit,
122
- handleAbort,
123
- handleCancelQueue,
124
- handleShutdown,
125
- } = useTuiChannel(channel);
126
-
127
- const [sessionName, setSessionName] = useState<string | undefined>(channel.sessionName);
128
-
129
- const fallbackPluginCallbacks = usePluginCallbacks(cwd);
130
- const pluginCallbacks = interactiveSession
131
- ? (undefined as unknown as ReturnType<typeof usePluginCallbacks>)
132
- : fallbackPluginCallbacks;
133
- const { exit } = useApp();
134
- const [updateNotice, setUpdateNotice] = useState<string | undefined>();
135
- const [showExecutionWorkspaceSwitcher, setShowExecutionWorkspaceSwitcher] = useState(false);
136
- const [executionDetailPage, setExecutionDetailPage] = useState<IExecutionDetailPage | null>(null);
137
- const [executionDetailError, setExecutionDetailError] = useState<string | undefined>();
138
- const [isExecutionDetailLoading, setIsExecutionDetailLoading] = useState(false);
139
- const [statusLineSettings, setStatusLineSettings] = useStatusLineSettings();
140
- const [gitRefreshToken, setGitRefreshToken] = useState(0);
141
- const backgroundWorkspaceEntries = useMemo(
142
- () => getDefaultBackgroundWorkspaceEntries(executionWorkspaceSnapshot),
143
- [executionWorkspaceSnapshot],
144
- );
145
- const activeBackgroundTaskCount = countActiveBackgroundWorkspaceEntries(
146
- executionWorkspaceSnapshot,
147
- );
148
- const selectedExecutionEntry = useMemo(
149
- () =>
150
- executionWorkspaceSnapshot?.entries.find((entry) => entry.id === selectedExecutionEntryId),
151
- [executionWorkspaceSnapshot, selectedExecutionEntryId],
152
- );
153
-
154
- const {
155
- handleSubmit,
156
- pendingInteractionPrompt,
157
- showPluginTUI,
158
- showSessionPicker,
159
- showTransportTUI,
160
- setShowPluginTUI,
161
- setShowSessionPicker,
162
- setShowTransportTUI,
163
- handleInteractionSubmit,
164
- handleInteractionCancel,
165
- } = useSideEffects({
166
- cwd,
167
- providerOverride: props.providerOverride,
168
- interactiveSession,
169
- commandEffectQueue,
170
- addEntry,
171
- baseHandleSubmit,
172
- setSessionName,
173
- setStatusLineSettings,
174
- showSessionPickerOnStart: props.showSessionPickerOnStart,
175
- openAgentSwitcher: () => setShowExecutionWorkspaceSwitcher(true),
176
- });
177
-
178
- useEffect(() => {
179
- void channel.start();
180
- return () => {
181
- void channel.stop();
182
- };
183
- }, [channel]);
184
-
185
- const isSelectedEntryInteractive =
186
- !selectedExecutionEntry ||
187
- selectedExecutionEntry.kind === 'main_thread' ||
188
- selectedExecutionEntry.controls.includes('send');
189
-
190
- const activeAgentLabel =
191
- selectedExecutionEntry && selectedExecutionEntry.kind !== 'main_thread'
192
- ? selectedExecutionEntry.title
193
- : undefined;
194
-
195
- const mainThreadEntryId = useMemo(
196
- () => executionWorkspaceSnapshot?.entries.find((e) => e.kind === 'main_thread')?.id,
197
- [executionWorkspaceSnapshot],
198
- );
199
-
200
- const handleSubmitWithRouting = useCallback(
201
- async (input: string): Promise<void> => {
202
- if (
203
- selectedExecutionEntry &&
204
- selectedExecutionEntry.kind !== 'main_thread' &&
205
- selectedExecutionEntry.controls.includes('send')
206
- ) {
207
- await interactiveSession.sendAgentJob(selectedExecutionEntry.sourceId, input);
208
- } else {
209
- await handleSubmit(input);
210
- }
211
- },
212
- [selectedExecutionEntry, handleSubmit, interactiveSession],
213
- );
214
-
215
- const handleSubmitWithGitRefresh = useCallback(
216
- async (input: string): Promise<void> => {
217
- setGitRefreshToken((t) => t + 1);
218
- await handleSubmitWithRouting(input);
219
- },
220
- [handleSubmitWithRouting],
221
- );
222
-
223
- // Refresh git branch when AI response completes.
224
- const wasThinkingRef = useRef(false);
225
- useEffect(() => {
226
- if (wasThinkingRef.current && !isThinking) {
227
- setGitRefreshToken((t) => t + 1);
228
- }
229
- wasThinkingRef.current = isThinking;
230
- }, [isThinking]);
231
-
232
- // Sync session name from InteractiveSession when resuming
233
- useEffect(() => {
234
- const name = interactiveSession?.getName?.();
235
- if (name && !sessionName) setSessionName(name);
236
- }, [interactiveSession, sessionName]);
237
-
238
- useEffect(() => {
239
- let isMounted = true;
240
- props.startupUpdateNotice
241
- ?.then((notice) => {
242
- if (isMounted && notice !== undefined) {
243
- setUpdateNotice(notice);
244
- }
245
- })
246
- .catch(() => {
247
- // Startup update checks are best-effort and must not disrupt the TUI.
248
- });
249
- return () => {
250
- isMounted = false;
251
- };
252
- }, [props.startupUpdateNotice]);
253
-
254
- // Update terminal title
255
- useEffect(() => {
256
- const title = sessionName ? `Robota — ${sessionName}` : 'Robota';
257
- process.stdout.write(`\x1b]0;${title}\x07`);
258
- }, [sessionName]);
259
-
260
- // ESC abort
261
- useInput((_input: string, key: { escape: boolean }) => {
262
- if (!key.escape || !isThinking) return;
263
- if (
264
- permissionRequest ||
265
- showPluginTUI ||
266
- showTransportTUI ||
267
- showSessionPicker ||
268
- showExecutionWorkspaceSwitcher
269
- ) {
270
- return;
271
- }
272
- handleAbort();
273
- });
274
-
275
- // Ctrl+B toggles the execution workspace switcher.
276
- useInput((input: string, key: { ctrl?: boolean }) => {
277
- if (!key.ctrl || input !== 'b') return;
278
- if (permissionRequest || showPluginTUI || showSessionPicker || isShuttingDown) return;
279
- setShowExecutionWorkspaceSwitcher((shown) => !shown);
280
- });
281
-
282
- // ESC returns to main thread when a background entry is selected (and not thinking).
283
- useInput((_input: string, key: { escape: boolean }) => {
284
- if (!key.escape || isThinking) return;
285
- if (
286
- permissionRequest ||
287
- showPluginTUI ||
288
- showTransportTUI ||
289
- showSessionPicker ||
290
- showExecutionWorkspaceSwitcher
291
- ) {
292
- return;
293
- }
294
- if (
295
- selectedExecutionEntry &&
296
- selectedExecutionEntry.kind !== 'main_thread' &&
297
- mainThreadEntryId !== undefined
298
- ) {
299
- selectExecutionWorkspaceEntry(mainThreadEntryId);
300
- }
301
- });
302
-
303
- // Ctrl+C graceful shutdown
304
- useInput((input: string, key: { ctrl?: boolean }) => {
305
- if (!key.ctrl || input !== 'c' || isShuttingDown) return;
306
- void handleShutdown('prompt_input_exit').finally(() => exit());
307
- });
308
-
309
- useEffect(() => {
310
- const onSigterm = (): void => {
311
- if (isShuttingDown) return;
312
- void handleShutdown('other').finally(() => exit());
313
- };
314
- process.once('SIGINT', onSigterm);
315
- process.once('SIGTERM', onSigterm);
316
- return () => {
317
- process.off('SIGINT', onSigterm);
318
- process.off('SIGTERM', onSigterm);
319
- };
320
- }, [handleShutdown, exit, isShuttingDown]);
321
-
322
- useEffect(() => {
323
- if (!selectedExecutionEntry || selectedExecutionEntry.kind === 'main_thread') {
324
- setExecutionDetailPage(null);
325
- setExecutionDetailError(undefined);
326
- setIsExecutionDetailLoading(false);
327
- return;
328
- }
329
-
330
- let isCurrent = true;
331
- setIsExecutionDetailLoading(true);
332
- setExecutionDetailError(undefined);
333
- readExecutionWorkspaceDetail(selectedExecutionEntry.id)
334
- .then((page) => {
335
- if (!isCurrent) return;
336
- setExecutionDetailPage(page);
337
- setIsExecutionDetailLoading(false);
338
- })
339
- .catch((error: Error) => {
340
- if (!isCurrent) return;
341
- setExecutionDetailError(error.message);
342
- setIsExecutionDetailLoading(false);
343
- });
344
-
345
- return () => {
346
- isCurrent = false;
347
- };
348
- }, [executionWorkspaceSnapshot, readExecutionWorkspaceDetail, selectedExecutionEntry]);
349
-
350
- // Session may not be initialized yet
351
- let permissionMode: TPermissionMode = props.permissionMode ?? 'default';
352
- let sessionId = '';
353
- let activePresetId: string | undefined;
354
- try {
355
- // allow-fallback: session initializes asynchronously; use defaults until ready
356
- const session = interactiveSession.getSession();
357
- permissionMode = session.getPermissionMode();
358
- activePresetId = session.getActivePresetId?.();
359
- sessionId = session.getSessionId();
360
- } catch {
361
- // allow-fallback: session initializes asynchronously; use defaults until ready
362
- // Not yet initialized
363
- }
364
-
365
- return (
366
- <Box flexDirection="column">
367
- <Static items={[{ version: props.version ?? '0.0.0' }]}>
368
- {(item) => (
369
- <Box key="logo" flexDirection="column" paddingX={1} marginBottom={1}>
370
- <Text color="cyan" bold>{`
371
- ____ ___ ____ ___ _____ _
372
- | _ \\ / _ \\| __ ) / _ \\_ _|/ \\
373
- | |_) | | | | _ \\| | | || | / _ \\
374
- | _ <| |_| | |_) | |_| || |/ ___ \\
375
- |_| \\_\\\\___/|____/ \\___/ |_/_/ \\_\\
376
- `}</Text>
377
- <Text dimColor> v{item.version}</Text>
378
- </Box>
379
- )}
380
- </Static>
381
- {updateNotice && <UpdateNotice message={updateNotice} />}
382
- <Box flexDirection="column" paddingX={1} flexGrow={1}>
383
- {selectedExecutionEntry && selectedExecutionEntry.kind !== 'main_thread' ? (
384
- <ExecutionWorkspaceDetailPane
385
- entry={selectedExecutionEntry}
386
- page={executionDetailPage}
387
- loading={isExecutionDetailLoading}
388
- error={executionDetailError}
389
- />
390
- ) : (
391
- <MessageList history={history} />
392
- )}
393
- {isShuttingDown && (
394
- <Box marginBottom={1}>
395
- <Text color="yellow">Shutting down...</Text>
396
- </Box>
397
- )}
398
- {(isThinking || activeTools.length > 0) && (
399
- <Box flexDirection="column" marginBottom={1}>
400
- <StreamingIndicator
401
- text={streamingText}
402
- activeTools={activeTools}
403
- isThinking={isThinking}
404
- />
405
- </Box>
406
- )}
407
- <BackgroundTaskPanel entries={backgroundWorkspaceEntries} />
408
- </Box>
409
- {showExecutionWorkspaceSwitcher && (
410
- <ExecutionWorkspaceSwitcher
411
- snapshot={executionWorkspaceSnapshot}
412
- selectedEntryId={selectedExecutionEntryId}
413
- onSelect={selectExecutionWorkspaceEntry}
414
- onClose={() => setShowExecutionWorkspaceSwitcher(false)}
415
- />
416
- )}
417
- {permissionRequest && <PermissionPrompt request={permissionRequest} />}
418
- {pendingInteractionPrompt && (
419
- <InteractivePrompt
420
- prompt={pendingInteractionPrompt}
421
- onSubmit={handleInteractionSubmit}
422
- onCancel={handleInteractionCancel}
423
- />
424
- )}
425
- {showPluginTUI && (
426
- <PluginTUI
427
- callbacks={pluginCallbacks}
428
- onClose={() => setShowPluginTUI(false)}
429
- addMessage={(msg) => addEntry(messageToHistoryEntry(createSystemMessage(msg.content)))}
430
- />
431
- )}
432
- {showTransportTUI && props.transportRegistry && (
433
- <TransportTUI
434
- registry={props.transportRegistry}
435
- onClose={() => setShowTransportTUI(false)}
436
- />
437
- )}
438
- {showSessionPicker && (
439
- <SessionPicker
440
- sessions={listResumableSessionSummaries(props.sessionStore, props.cwd)}
441
- onSelect={(id) => {
442
- setShowSessionPicker(false);
443
- props.onSessionSwitch(id);
444
- }}
445
- onCancel={() => {
446
- setShowSessionPicker(false);
447
- addEntry(messageToHistoryEntry(createSystemMessage('Session resume cancelled.')));
448
- }}
449
- />
450
- )}
451
- <ContextWarningBanner percentage={contextState.percentage} />
452
- <InputArea
453
- onSubmit={handleSubmitWithGitRefresh}
454
- onCancelQueue={handleCancelQueue}
455
- isDisabled={
456
- !!permissionRequest ||
457
- showPluginTUI ||
458
- showTransportTUI ||
459
- showSessionPicker ||
460
- showExecutionWorkspaceSwitcher ||
461
- isShuttingDown ||
462
- pendingInteractionPrompt !== null ||
463
- (isThinking && !!pendingPrompt) ||
464
- !isSelectedEntryInteractive
465
- }
466
- isAborting={isAborting}
467
- pendingPrompt={pendingPrompt}
468
- registry={registry}
469
- sessionName={sessionName}
470
- history={history}
471
- />
472
- <SessionStatusBar
473
- cwd={cwd}
474
- permissionMode={permissionMode}
475
- modelId={props.modelId}
476
- providerType={props.providerType}
477
- sessionId={sessionId}
478
- isThinking={isThinking}
479
- activeToolCount={activeTools.length}
480
- activeBackgroundTaskCount={activeBackgroundTaskCount}
481
- hasPendingPrompt={pendingPrompt !== null}
482
- contextState={contextState}
483
- sessionName={sessionName}
484
- settings={statusLineSettings}
485
- activeAgentLabel={activeAgentLabel}
486
- activePresetId={activePresetId}
487
- gitRefreshToken={gitRefreshToken}
488
- />
489
- </Box>
490
- );
491
- }
@@ -1,36 +0,0 @@
1
- import { Box, Text } from 'ink';
2
- import React from 'react';
3
-
4
- import { formatBackgroundTaskRow } from './background-task-row-format.js';
5
-
6
- import type { IExecutionWorkspaceEntry } from '@robota-sdk/agent-interface-transport';
7
-
8
- interface IProps {
9
- entries: IExecutionWorkspaceEntry[];
10
- }
11
-
12
- export default function BackgroundTaskPanel({ entries }: IProps): React.ReactElement | null {
13
- if (entries.length === 0) return null;
14
-
15
- return (
16
- <Box flexDirection="column" marginBottom={1}>
17
- <Text color="cyan" bold>
18
- Background work
19
- </Text>
20
- {entries.map((entry, index) => {
21
- const row = formatBackgroundTaskRow(entry, { isLast: index === entries.length - 1 });
22
- return (
23
- <Text key={entry.id}>
24
- {`${row.connector} `}
25
- <Text color={row.color}>{row.marker}</Text>
26
- {` ${row.label}`}
27
- {row.segments.map((segment, segmentIndex) => (
28
- <Text key={`${segment}-${segmentIndex}`} dimColor>{` · ${segment}`}</Text>
29
- ))}
30
- {row.preview ? <Text dimColor>{` · ${row.preview}`}</Text> : null}
31
- </Text>
32
- );
33
- })}
34
- </Box>
35
- );
36
- }