@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
@@ -1,85 +0,0 @@
1
- import {
2
- applySelectionInput,
3
- getDirectionalSelectionInputAction,
4
- type ISelectionFlowState,
5
- type ISelectionInputKey,
6
- type TSelectionInputAction,
7
- } from './selection-flow.js';
8
-
9
- export const PERMISSION_PROMPT_OPTIONS = [
10
- 'Allow [y]',
11
- 'Allow always (this session) [s]',
12
- 'Allow always (this project) [p]',
13
- 'Deny [n]',
14
- ] as const;
15
-
16
- export type TPermissionPromptDecision = true | 'allow-session' | 'allow-project' | false;
17
- export type TPermissionPromptInputAction =
18
- | TSelectionInputAction
19
- | { type: 'shortcut'; index: number };
20
-
21
- export type TPermissionPromptEffect =
22
- | { type: 'none' }
23
- | { type: 'resolve'; decision: TPermissionPromptDecision };
24
-
25
- export function getPermissionPromptInputAction(
26
- input: string,
27
- key: ISelectionInputKey,
28
- ): TPermissionPromptInputAction | undefined {
29
- const action = getDirectionalSelectionInputAction({ ...key, escape: false });
30
- if (action !== undefined) {
31
- return action;
32
- }
33
- if (input === 'y' || input === '1') {
34
- return { type: 'shortcut', index: 0 };
35
- }
36
- if (input === 's' || input === 'a' || input === '2') {
37
- return { type: 'shortcut', index: 1 };
38
- }
39
- if (input === 'p' || input === '3') {
40
- return { type: 'shortcut', index: 2 };
41
- }
42
- if (input === 'n' || input === 'd' || input === '4') {
43
- return { type: 'shortcut', index: 3 };
44
- }
45
- return undefined;
46
- }
47
-
48
- export function applyPermissionPromptInput(
49
- state: ISelectionFlowState,
50
- action: TPermissionPromptInputAction,
51
- ): { state: ISelectionFlowState; effect: TPermissionPromptEffect } {
52
- if (state.resolved) {
53
- return { state, effect: { type: 'none' } };
54
- }
55
- if (typeof action !== 'string') {
56
- return resolvePermissionIndex(state, action.index);
57
- }
58
- const result = applySelectionInput(state, action, {
59
- itemCount: PERMISSION_PROMPT_OPTIONS.length,
60
- });
61
- if (result.effect.type !== 'select') {
62
- return { state: result.state, effect: { type: 'none' } };
63
- }
64
- return {
65
- state: result.state,
66
- effect: { type: 'resolve', decision: getPermissionDecision(result.effect.index) },
67
- };
68
- }
69
-
70
- function getPermissionDecision(index: number): TPermissionPromptDecision {
71
- if (index === 0) return true;
72
- if (index === 1) return 'allow-session';
73
- if (index === 2) return 'allow-project';
74
- return false;
75
- }
76
-
77
- function resolvePermissionIndex(
78
- state: ISelectionFlowState,
79
- index: number,
80
- ): { state: ISelectionFlowState; effect: TPermissionPromptEffect } {
81
- return {
82
- state: { ...state, selectedIndex: index, resolved: true },
83
- effect: { type: 'resolve', decision: getPermissionDecision(index) },
84
- };
85
- }
@@ -1,126 +0,0 @@
1
- export interface ISelectionFlowState {
2
- selectedIndex: number;
3
- scrollOffset: number;
4
- resolved: boolean;
5
- }
6
-
7
- export interface ISelectionInputKey {
8
- escape?: boolean;
9
- return?: boolean;
10
- upArrow?: boolean;
11
- downArrow?: boolean;
12
- leftArrow?: boolean;
13
- rightArrow?: boolean;
14
- }
15
-
16
- export type TSelectionInputAction = 'cancel' | 'select' | 'previous' | 'next';
17
-
18
- export type TSelectionEffect =
19
- | { type: 'none' }
20
- | { type: 'cancel' }
21
- | { type: 'select'; index: number };
22
-
23
- export interface ISelectionFlowOptions {
24
- itemCount: number;
25
- maxVisible?: number;
26
- wrap?: boolean;
27
- enabled?: boolean;
28
- }
29
-
30
- export function createSelectionFlowState(): ISelectionFlowState {
31
- return { selectedIndex: 0, scrollOffset: 0, resolved: false };
32
- }
33
-
34
- export function getVerticalSelectionInputAction(
35
- key: ISelectionInputKey,
36
- ): TSelectionInputAction | undefined {
37
- if (key.escape === true) return 'cancel';
38
- if (key.upArrow === true) return 'previous';
39
- if (key.downArrow === true) return 'next';
40
- if (key.return === true) return 'select';
41
- return undefined;
42
- }
43
-
44
- export function getDirectionalSelectionInputAction(
45
- key: ISelectionInputKey,
46
- ): TSelectionInputAction | undefined {
47
- if (key.escape === true) return 'cancel';
48
- if (key.leftArrow === true || key.upArrow === true) return 'previous';
49
- if (key.rightArrow === true || key.downArrow === true) return 'next';
50
- if (key.return === true) return 'select';
51
- return undefined;
52
- }
53
-
54
- export function applySelectionInput(
55
- state: ISelectionFlowState,
56
- action: TSelectionInputAction,
57
- options: ISelectionFlowOptions,
58
- ): { state: ISelectionFlowState; effect: TSelectionEffect } {
59
- if (state.resolved) {
60
- return { state, effect: { type: 'none' } };
61
- }
62
- if (action === 'cancel') {
63
- return { state: { ...state, resolved: true }, effect: { type: 'cancel' } };
64
- }
65
- if (options.enabled === false || options.itemCount === 0) {
66
- return { state, effect: { type: 'none' } };
67
- }
68
- if (action === 'select') {
69
- const index = clampIndex(state.selectedIndex, options.itemCount);
70
- return {
71
- state: { ...state, selectedIndex: index, resolved: true },
72
- effect: { type: 'select', index },
73
- };
74
- }
75
- const selectedIndex = moveSelection(state.selectedIndex, action, options);
76
- const scrollOffset = resolveScrollOffset(selectedIndex, state.scrollOffset, options);
77
- return { state: { ...state, selectedIndex, scrollOffset }, effect: { type: 'none' } };
78
- }
79
-
80
- export function normalizeSelectionState(
81
- state: ISelectionFlowState,
82
- options: ISelectionFlowOptions,
83
- ): ISelectionFlowState {
84
- if (options.itemCount === 0) {
85
- return { ...state, selectedIndex: 0, scrollOffset: 0 };
86
- }
87
- const selectedIndex = clampIndex(state.selectedIndex, options.itemCount);
88
- const scrollOffset = resolveScrollOffset(selectedIndex, state.scrollOffset, options);
89
- if (selectedIndex === state.selectedIndex && scrollOffset === state.scrollOffset) {
90
- return state;
91
- }
92
- return {
93
- ...state,
94
- selectedIndex,
95
- scrollOffset,
96
- };
97
- }
98
-
99
- function moveSelection(
100
- selectedIndex: number,
101
- action: TSelectionInputAction,
102
- options: ISelectionFlowOptions,
103
- ): number {
104
- if (action === 'previous') {
105
- if (options.wrap === true && selectedIndex === 0) return options.itemCount - 1;
106
- return Math.max(0, selectedIndex - 1);
107
- }
108
- if (options.wrap === true && selectedIndex === options.itemCount - 1) return 0;
109
- return Math.min(options.itemCount - 1, selectedIndex + 1);
110
- }
111
-
112
- function resolveScrollOffset(
113
- selectedIndex: number,
114
- scrollOffset: number,
115
- options: ISelectionFlowOptions,
116
- ): number {
117
- const maxVisible = options.maxVisible ?? options.itemCount;
118
- if (maxVisible <= 0) return 0;
119
- if (selectedIndex < scrollOffset) return selectedIndex;
120
- if (selectedIndex >= scrollOffset + maxVisible) return selectedIndex - maxVisible + 1;
121
- return Math.max(0, scrollOffset);
122
- }
123
-
124
- function clampIndex(index: number, itemCount: number): number {
125
- return Math.min(Math.max(index, 0), itemCount - 1);
126
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * Bounded polling helper for asynchronous session initialization.
3
- *
4
- * Distinguishes benign "not yet initialized" errors (retried until a timeout)
5
- * from real failures (surfaced immediately), so the TUI can show an error
6
- * instead of spinning forever.
7
- */
8
-
9
- export type TSessionInitFailure =
10
- | { kind: 'timeout'; lastError: Error | undefined }
11
- | { kind: 'error'; error: Error };
12
-
13
- export interface ISessionInitPollerOptions {
14
- /** Throws while the session is not ready; returns normally when ready. */
15
- check: () => void;
16
- intervalMs: number;
17
- timeoutMs: number;
18
- /** Returns true when an error means "keep polling". Defaults to /not initialized/i. */
19
- isBenignError?: (error: Error) => boolean;
20
- onReady: () => void;
21
- onFailure: (failure: TSessionInitFailure) => void;
22
- }
23
-
24
- export interface ISessionInitPoller {
25
- start(): void;
26
- stop(): void;
27
- }
28
-
29
- function defaultIsBenignError(error: Error): boolean {
30
- return /not initialized/i.test(error.message);
31
- }
32
-
33
- export function createSessionInitPoller(options: ISessionInitPollerOptions): ISessionInitPoller {
34
- const isBenign = options.isBenignError ?? defaultIsBenignError;
35
- let timer: ReturnType<typeof setInterval> | null = null;
36
- let elapsedMs = 0;
37
- let lastBenignError: Error | undefined;
38
-
39
- function stop(): void {
40
- if (timer !== null) {
41
- clearInterval(timer);
42
- timer = null;
43
- }
44
- }
45
-
46
- function tick(): void {
47
- elapsedMs += options.intervalMs;
48
- try {
49
- options.check();
50
- } catch (raw) {
51
- // allow-fallback: poller's purpose is to classify and route this error, never to swallow it
52
- const error = raw instanceof Error ? raw : new Error(String(raw));
53
- if (!isBenign(error)) {
54
- stop();
55
- options.onFailure({ kind: 'error', error });
56
- return;
57
- }
58
- lastBenignError = error;
59
- if (elapsedMs >= options.timeoutMs) {
60
- stop();
61
- options.onFailure({ kind: 'timeout', lastError: lastBenignError });
62
- }
63
- return;
64
- }
65
- stop();
66
- options.onReady();
67
- }
68
-
69
- return {
70
- start(): void {
71
- if (timer !== null) return;
72
- elapsedMs = 0;
73
- timer = setInterval(tick, options.intervalMs);
74
- },
75
- stop,
76
- };
77
- }
@@ -1,98 +0,0 @@
1
- export interface ITextPromptFlowState {
2
- value: string;
3
- error?: string;
4
- resolved: boolean;
5
- }
6
-
7
- export interface ITextPromptInputKey {
8
- escape?: boolean;
9
- return?: boolean;
10
- backspace?: boolean;
11
- delete?: boolean;
12
- ctrl?: boolean;
13
- meta?: boolean;
14
- }
15
-
16
- export type TTextPromptInputAction =
17
- | { type: 'cancel' }
18
- | { type: 'submit' }
19
- | { type: 'delete' }
20
- | { type: 'insert'; value: string };
21
-
22
- export type TTextPromptEffect =
23
- | { type: 'none' }
24
- | { type: 'cancel' }
25
- | { type: 'submit'; value: string };
26
-
27
- export interface ITextPromptFlowOptions {
28
- allowEmpty: boolean;
29
- validate?: (value: string) => string | undefined;
30
- }
31
-
32
- export function createTextPromptFlowState(): ITextPromptFlowState {
33
- return { value: '', resolved: false };
34
- }
35
-
36
- export function getTextPromptInputAction(
37
- input: string,
38
- key: ITextPromptInputKey,
39
- ): TTextPromptInputAction | undefined {
40
- if (key.escape === true) {
41
- return { type: 'cancel' };
42
- }
43
- if (key.return === true) {
44
- return { type: 'submit' };
45
- }
46
- if (key.backspace === true || key.delete === true) {
47
- return { type: 'delete' };
48
- }
49
- if (input && key.ctrl !== true && key.meta !== true) {
50
- return { type: 'insert', value: input };
51
- }
52
- return undefined;
53
- }
54
-
55
- export function applyTextPromptInput(
56
- state: ITextPromptFlowState,
57
- action: TTextPromptInputAction,
58
- options: ITextPromptFlowOptions,
59
- ): { state: ITextPromptFlowState; effect: TTextPromptEffect } {
60
- if (state.resolved) {
61
- return { state, effect: { type: 'none' } };
62
- }
63
- if (action.type === 'cancel') {
64
- return { state: { ...state, resolved: true }, effect: { type: 'cancel' } };
65
- }
66
- if (action.type === 'delete') {
67
- return {
68
- state: { ...state, value: state.value.slice(0, -1), error: undefined },
69
- effect: { type: 'none' },
70
- };
71
- }
72
- if (action.type === 'insert') {
73
- return {
74
- state: { ...state, value: state.value + action.value, error: undefined },
75
- effect: { type: 'none' },
76
- };
77
- }
78
- return submitTextPromptValue(state, options);
79
- }
80
-
81
- function submitTextPromptValue(
82
- state: ITextPromptFlowState,
83
- options: ITextPromptFlowOptions,
84
- ): { state: ITextPromptFlowState; effect: TTextPromptEffect } {
85
- const trimmed = state.value.trim();
86
- if (!trimmed && !options.allowEmpty) {
87
- const emptyError = options.validate?.(trimmed);
88
- return {
89
- state: emptyError ? { ...state, error: emptyError } : state,
90
- effect: { type: 'none' },
91
- };
92
- }
93
- const error = options.validate?.(trimmed);
94
- if (error !== undefined) {
95
- return { state: { ...state, error }, effect: { type: 'none' } };
96
- }
97
- return { state: { ...state, resolved: true }, effect: { type: 'submit', value: trimmed } };
98
- }
@@ -1,97 +0,0 @@
1
- import { createSystemMessage, messageToHistoryEntry } from '@robota-sdk/agent-core';
2
- import { isStatusLineCommandSettingsPatch } from '@robota-sdk/agent-framework';
3
-
4
- import type { ITuiCliAdapter } from '../tui-cli-adapter.js';
5
- import type { IHistoryEntry, TSessionEndReason } from '@robota-sdk/agent-core';
6
- import type {
7
- TCommandEffect,
8
- TStatusLineCommandSettingsPatch,
9
- } from '@robota-sdk/agent-interface-transport';
10
-
11
- export interface ICommandEffectHandlerDeps {
12
- addEntry: (entry: IHistoryEntry) => void;
13
- requestShutdown: (reason: TSessionEndReason, message: string) => void;
14
- openPluginTUI: () => void;
15
- openSessionPicker: () => void;
16
- openTransportTUI: () => void;
17
- openAgentSwitcher: () => void;
18
- renameSession: (name: string) => void;
19
- applyStatusLinePatch: (patch: TStatusLineCommandSettingsPatch) => boolean;
20
- cliAdapter: ITuiCliAdapter;
21
- }
22
-
23
- export function applyCommandEffects(
24
- effects: readonly TCommandEffect[],
25
- deps: ICommandEffectHandlerDeps,
26
- ): boolean {
27
- for (const effect of effects) {
28
- if (effect.type === 'language-change-requested') {
29
- applyLanguageEffect(effect.language, deps);
30
- return true;
31
- }
32
- if (effect.type === 'settings-reset-requested') {
33
- applySettingsResetEffect(deps);
34
- return true;
35
- }
36
- if (effect.type === 'session-exit-requested') {
37
- deps.requestShutdown(
38
- effect.reason ?? 'prompt_input_exit',
39
- effect.message ?? 'User requested exit',
40
- );
41
- return true;
42
- }
43
- if (effect.type === 'session-restart-requested') {
44
- deps.requestShutdown(effect.reason, effect.message);
45
- return true;
46
- }
47
- if (effect.type === 'plugin-tui-requested') {
48
- deps.openPluginTUI();
49
- return true;
50
- }
51
- if (effect.type === 'settings-tui-requested') {
52
- deps.openTransportTUI();
53
- return true;
54
- }
55
- if (effect.type === 'agent-switcher-requested') {
56
- deps.openAgentSwitcher();
57
- return true;
58
- }
59
- if (effect.type === 'session-picker-requested') {
60
- deps.openSessionPicker();
61
- return true;
62
- }
63
- if (effect.type === 'session-renamed') {
64
- deps.renameSession(effect.name);
65
- return true;
66
- }
67
- if (effect.type === 'statusline-settings-patch') {
68
- if (isStatusLineCommandSettingsPatch(effect.patch)) {
69
- return deps.applyStatusLinePatch(effect.patch);
70
- }
71
- }
72
- }
73
- return false;
74
- }
75
-
76
- function applyLanguageEffect(language: string, deps: ICommandEffectHandlerDeps): void {
77
- const settingsPath = deps.cliAdapter.getUserSettingsPath();
78
- const settings = deps.cliAdapter.readSettings(settingsPath);
79
- settings.language = language;
80
- deps.cliAdapter.writeSettings(settingsPath, settings);
81
- deps.addEntry(
82
- messageToHistoryEntry(createSystemMessage(`Language set to "${language}". Restarting...`)),
83
- );
84
- deps.requestShutdown('other', 'Language change restart');
85
- }
86
-
87
- function applySettingsResetEffect(deps: ICommandEffectHandlerDeps): void {
88
- const settingsPath = deps.cliAdapter.getUserSettingsPath();
89
- if (deps.cliAdapter.deleteSettings(settingsPath)) {
90
- deps.addEntry(
91
- messageToHistoryEntry(createSystemMessage(`Deleted ${settingsPath}. Exiting...`)),
92
- );
93
- } else {
94
- deps.addEntry(messageToHistoryEntry(createSystemMessage('No user settings found.')));
95
- }
96
- deps.requestShutdown('other', 'Reset settings restart');
97
- }
@@ -1,39 +0,0 @@
1
- import type { ICommandInteraction, TCommandEffect } from '@robota-sdk/agent-interface-transport';
2
-
3
- export type TQueuedCommandState =
4
- | {
5
- type: 'interaction';
6
- interaction: ICommandInteraction;
7
- }
8
- | {
9
- type: 'effects';
10
- effects: readonly TCommandEffect[];
11
- };
12
-
13
- export interface ICommandEffectQueue {
14
- enqueueInteraction(interaction: ICommandInteraction): void;
15
- enqueueEffects(effects: readonly TCommandEffect[]): void;
16
- drain(): TQueuedCommandState | undefined;
17
- clear(): void;
18
- }
19
-
20
- export class CommandEffectQueue implements ICommandEffectQueue {
21
- private readonly queue: TQueuedCommandState[] = [];
22
-
23
- enqueueInteraction(interaction: ICommandInteraction): void {
24
- this.queue.push({ type: 'interaction', interaction });
25
- }
26
-
27
- enqueueEffects(effects: readonly TCommandEffect[]): void {
28
- if (effects.length === 0) return;
29
- this.queue.push({ type: 'effects', effects: [...effects] });
30
- }
31
-
32
- drain(): TQueuedCommandState | undefined {
33
- return this.queue.shift();
34
- }
35
-
36
- clear(): void {
37
- this.queue.length = 0;
38
- }
39
- }
@@ -1,35 +0,0 @@
1
- import type { ICommandEffectQueue } from './command-effect-queue.js';
2
- import type { IHistoryEntry } from '@robota-sdk/agent-core';
3
- import type { InteractiveSession } from '@robota-sdk/agent-framework';
4
- import type {
5
- IStatusLineCommandSettings as TStatusLineSettings,
6
- TCommandInteractionPrompt as TInteractivePrompt,
7
- } from '@robota-sdk/agent-interface-transport';
8
-
9
- export type { TInteractivePrompt, TStatusLineSettings };
10
-
11
- export interface IUseSideEffectsOptions {
12
- cwd: string;
13
- providerOverride?: string | undefined;
14
- interactiveSession: InteractiveSession;
15
- commandEffectQueue: ICommandEffectQueue;
16
- addEntry: (entry: IHistoryEntry) => void;
17
- baseHandleSubmit: (input: string) => Promise<void>;
18
- setSessionName: (name: string) => void;
19
- setStatusLineSettings: (settings: TStatusLineSettings) => void;
20
- showSessionPickerOnStart?: boolean;
21
- openAgentSwitcher?: () => void;
22
- }
23
-
24
- export interface IUseSideEffectsResult {
25
- handleSubmit: (input: string) => Promise<void>;
26
- pendingInteractionPrompt: TInteractivePrompt | null;
27
- showPluginTUI: boolean;
28
- showSessionPicker: boolean;
29
- showTransportTUI: boolean;
30
- setShowPluginTUI: (show: boolean) => void;
31
- setShowSessionPicker: (show: boolean) => void;
32
- setShowTransportTUI: (show: boolean) => void;
33
- handleInteractionSubmit: (value: string) => Promise<void>;
34
- handleInteractionCancel: () => void;
35
- }
@@ -1,87 +0,0 @@
1
- /**
2
- * Slash command autocomplete hook.
3
- * Extracted from InputArea.tsx for single-responsibility.
4
- */
5
-
6
- import React, { useState, useMemo } from 'react';
7
-
8
- import type { CommandRegistry } from '@robota-sdk/agent-framework';
9
- import type { ICommand } from '@robota-sdk/agent-interface-transport';
10
-
11
- /** Parse input to determine autocomplete state */
12
- function parseSlashInput(value: string): {
13
- isSlash: boolean;
14
- parentCommand: string;
15
- filter: string;
16
- } {
17
- if (!value.startsWith('/')) return { isSlash: false, parentCommand: '', filter: '' };
18
- const afterSlash = value.slice(1);
19
- const spaceIndex = afterSlash.indexOf(' ');
20
- if (spaceIndex === -1) return { isSlash: true, parentCommand: '', filter: afterSlash };
21
- const parent = afterSlash.slice(0, spaceIndex);
22
- const rest = afterSlash.slice(spaceIndex + 1);
23
- return { isSlash: true, parentCommand: parent, filter: rest };
24
- }
25
-
26
- /** Hook: manage autocomplete state */
27
- export function useAutocomplete(
28
- value: string,
29
- registry: CommandRegistry | undefined,
30
- ): {
31
- showPopup: boolean;
32
- filteredCommands: ICommand[];
33
- selectedIndex: number;
34
- setSelectedIndex: React.Dispatch<React.SetStateAction<number>>;
35
- isSubcommandMode: boolean;
36
- setShowPopup: React.Dispatch<React.SetStateAction<boolean>>;
37
- } {
38
- const [selectedIndex, setSelectedIndex] = useState(0);
39
- const [dismissed, setDismissed] = useState(false);
40
-
41
- // Reset dismissed when input changes
42
- const prevValueRef = React.useRef(value);
43
- if (prevValueRef.current !== value) {
44
- prevValueRef.current = value;
45
- if (dismissed) setDismissed(false);
46
- }
47
-
48
- const parsed = parseSlashInput(value);
49
- const isSubcommandMode = parsed.isSlash && parsed.parentCommand.length > 0;
50
-
51
- const filteredCommands = useMemo(() => {
52
- if (!registry || !parsed.isSlash || dismissed) return [];
53
- if (isSubcommandMode) {
54
- const subs = registry.getSubcommands(parsed.parentCommand);
55
- if (subs.length === 0) return [];
56
- if (!parsed.filter) return subs;
57
- const lower = parsed.filter.toLowerCase();
58
- return subs.filter((c) => c.name.toLowerCase().startsWith(lower));
59
- }
60
- return registry.getCommands(parsed.filter);
61
- }, [registry, parsed.isSlash, parsed.parentCommand, parsed.filter, dismissed, isSubcommandMode]);
62
-
63
- const showPopup = parsed.isSlash && filteredCommands.length > 0 && !dismissed;
64
-
65
- // Clamp selectedIndex
66
- if (selectedIndex >= filteredCommands.length && filteredCommands.length > 0) {
67
- setSelectedIndex(filteredCommands.length - 1);
68
- }
69
-
70
- return {
71
- showPopup,
72
- filteredCommands,
73
- selectedIndex,
74
- setSelectedIndex,
75
- isSubcommandMode,
76
- setShowPopup: (val) => {
77
- if (typeof val === 'function') {
78
- setDismissed((prev) => {
79
- const nextVal = (val as (prev: boolean) => boolean)(!prev);
80
- return !nextVal;
81
- });
82
- } else {
83
- setDismissed(!val);
84
- }
85
- },
86
- };
87
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Hook: returns a no-op ICommandPluginAdapter for when no plugin adapter is provided.
3
- *
4
- * In normal usage, App receives commandHostAdapters.plugin from the CLI (agent-cli), which
5
- * constructs the real adapter. This fallback exists only for test environments where no adapter
6
- * is injected.
7
- */
8
-
9
- import { useMemo } from 'react';
10
-
11
- import type { ICommandPluginAdapter } from '@robota-sdk/agent-interface-transport';
12
-
13
- function createNoOpPluginAdapter(): ICommandPluginAdapter {
14
- return {
15
- listInstalled: async () => [],
16
- listAvailablePlugins: async () => [],
17
- install: async () => undefined,
18
- uninstall: async () => undefined,
19
- enable: async () => undefined,
20
- disable: async () => undefined,
21
- marketplaceAdd: async () => '',
22
- marketplaceRemove: async () => undefined,
23
- marketplaceUpdate: async () => undefined,
24
- marketplaceList: async () => [],
25
- reloadPlugins: async () => ({ loadedPluginCount: 0 }),
26
- };
27
- }
28
-
29
- export function usePluginCallbacks(_cwd: string): ICommandPluginAdapter {
30
- return useMemo(() => createNoOpPluginAdapter(), []);
31
- }