@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
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
- }