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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +17 -14
  3. package/dist/node/headless/index.cjs +1 -1
  4. package/dist/node/headless/index.d.ts +1 -1
  5. package/dist/node/headless/index.js +1 -1
  6. package/dist/node/{headless-mRYilLfC.js → headless-DG_MEbf0.js} +7 -4
  7. package/dist/node/headless-DG_MEbf0.js.map +1 -0
  8. package/dist/node/headless-xq77JBq0.cjs +18 -0
  9. package/dist/node/{index-E8Gx4-lc.d.ts → index-CrJ2Lhn3.d.ts} +16 -3
  10. package/dist/node/index-CrJ2Lhn3.d.ts.map +1 -0
  11. package/dist/node/index-JIvzrtaA.d.ts +52 -0
  12. package/dist/node/index-JIvzrtaA.d.ts.map +1 -0
  13. package/dist/node/{index-CYl7ksS6.d.ts → index-JTD_xtEQ.d.ts} +15 -2
  14. package/dist/node/index-JTD_xtEQ.d.ts.map +1 -0
  15. package/dist/node/index-y_HBOfzO.d.ts +52 -0
  16. package/dist/node/index-y_HBOfzO.d.ts.map +1 -0
  17. package/dist/node/index.cjs +1 -1
  18. package/dist/node/index.d.ts +10 -9
  19. package/dist/node/index.d.ts.map +1 -1
  20. package/dist/node/index.js +1 -1
  21. package/dist/node/index.js.map +1 -1
  22. package/dist/node/programmatic/index.cjs +1 -0
  23. package/dist/node/programmatic/index.d.ts +2 -0
  24. package/dist/node/programmatic/index.js +1 -0
  25. package/dist/node/programmatic-6wLf68qJ.cjs +1 -0
  26. package/dist/node/programmatic-70dxIXtS.js +2 -0
  27. package/dist/node/programmatic-70dxIXtS.js.map +1 -0
  28. package/dist/node/testing/index.cjs +1 -1
  29. package/dist/node/testing/index.d.ts +2 -21
  30. package/dist/node/testing/index.js +1 -2
  31. package/package.json +15 -71
  32. package/src/__tests__/programmatic/programmatic-ask-user.test.ts +32 -0
  33. package/src/__tests__/programmatic/programmatic-driver.test.ts +107 -0
  34. package/src/__tests__/programmatic/programmatic-flows.test.ts +140 -0
  35. package/src/__tests__/transport-registry.stop-all.test.ts +53 -0
  36. package/src/headless/HeadlessInteractionChannel.ts +22 -5
  37. package/src/headless/__tests__/headless-goal-runner.test.ts +108 -0
  38. package/src/headless/__tests__/headless-runner.test.ts +2 -1
  39. package/src/headless/headless-runner.ts +67 -1
  40. package/src/headless/headless-stream-json.ts +1 -1
  41. package/src/headless/print-terminal.ts +1 -0
  42. package/src/index.ts +2 -5
  43. package/src/programmatic/ProgrammaticInteractionChannel.ts +82 -0
  44. package/src/programmatic/createProgrammaticAgent.ts +71 -0
  45. package/src/programmatic/index.ts +5 -0
  46. package/src/testing/index.ts +7 -4
  47. package/src/transport-registry.ts +15 -12
  48. package/dist/node/headless-CT2ibQnr.cjs +0 -15
  49. package/dist/node/headless-mRYilLfC.js.map +0 -1
  50. package/dist/node/http/index.cjs +0 -1
  51. package/dist/node/http/index.d.ts +0 -2
  52. package/dist/node/http/index.js +0 -1
  53. package/dist/node/http-2Jiuflc1.js +0 -2
  54. package/dist/node/http-2Jiuflc1.js.map +0 -1
  55. package/dist/node/http-CBAvefLw.cjs +0 -1
  56. package/dist/node/index-BNccqSpv.d.ts +0 -86
  57. package/dist/node/index-BNccqSpv.d.ts.map +0 -1
  58. package/dist/node/index-BUhHIf7X.d.ts +0 -86
  59. package/dist/node/index-BUhHIf7X.d.ts.map +0 -1
  60. package/dist/node/index-BnAGE-u9.d.ts +0 -33
  61. package/dist/node/index-BnAGE-u9.d.ts.map +0 -1
  62. package/dist/node/index-BrQ4gGw0.d.ts +0 -213
  63. package/dist/node/index-BrQ4gGw0.d.ts.map +0 -1
  64. package/dist/node/index-CYl7ksS6.d.ts.map +0 -1
  65. package/dist/node/index-CoeBF21y.d.ts +0 -213
  66. package/dist/node/index-CoeBF21y.d.ts.map +0 -1
  67. package/dist/node/index-DHt-2VQ-.d.ts +0 -46
  68. package/dist/node/index-DHt-2VQ-.d.ts.map +0 -1
  69. package/dist/node/index-DMwKN5Le.d.ts +0 -33
  70. package/dist/node/index-DMwKN5Le.d.ts.map +0 -1
  71. package/dist/node/index-E8Gx4-lc.d.ts.map +0 -1
  72. package/dist/node/index-c0M42fsA.d.ts +0 -46
  73. package/dist/node/index-c0M42fsA.d.ts.map +0 -1
  74. package/dist/node/mcp/index.cjs +0 -1
  75. package/dist/node/mcp/index.d.ts +0 -2
  76. package/dist/node/mcp/index.js +0 -1
  77. package/dist/node/mcp-BOglBJNy.cjs +0 -1
  78. package/dist/node/mcp-D3BBVK7C.js +0 -2
  79. package/dist/node/mcp-D3BBVK7C.js.map +0 -1
  80. package/dist/node/rolldown-runtime-CMqjfN_6.cjs +0 -1
  81. package/dist/node/testing/index.d.ts.map +0 -1
  82. package/dist/node/testing/index.js.map +0 -1
  83. package/dist/node/tui/index.cjs +0 -1
  84. package/dist/node/tui/index.d.ts +0 -2
  85. package/dist/node/tui/index.js +0 -1
  86. package/dist/node/tui-CcH5EsQh.js +0 -25
  87. package/dist/node/tui-CcH5EsQh.js.map +0 -1
  88. package/dist/node/tui-DznRbcku.cjs +0 -24
  89. package/dist/node/ws/index.cjs +0 -1
  90. package/dist/node/ws/index.d.ts +0 -2
  91. package/dist/node/ws/index.js +0 -1
  92. package/dist/node/ws-Dc2RUwVs.js +0 -2
  93. package/dist/node/ws-Dc2RUwVs.js.map +0 -1
  94. package/dist/node/ws-QNMQn5kg.cjs +0 -1
  95. package/src/http/__tests__/http-transport.test.ts +0 -55
  96. package/src/http/__tests__/routes.test.ts +0 -168
  97. package/src/http/http-transport.ts +0 -41
  98. package/src/http/index.ts +0 -4
  99. package/src/http/routes.ts +0 -152
  100. package/src/mcp/__tests__/mcp-server.test.ts +0 -66
  101. package/src/mcp/__tests__/mcp-transport.test.ts +0 -46
  102. package/src/mcp/index.ts +0 -4
  103. package/src/mcp/mcp-server.ts +0 -163
  104. package/src/mcp/mcp-transport.ts +0 -48
  105. package/src/testing/__tests__/scripted-provider.test.ts +0 -73
  106. package/src/testing/scripted-provider.ts +0 -73
  107. package/src/tui/App.tsx +0 -491
  108. package/src/tui/BackgroundTaskPanel.tsx +0 -36
  109. package/src/tui/CjkTextInput.tsx +0 -199
  110. package/src/tui/ConfirmPrompt.tsx +0 -70
  111. package/src/tui/ContextWarningBanner.tsx +0 -34
  112. package/src/tui/ExecutionWorkspaceDetailPane.tsx +0 -64
  113. package/src/tui/ExecutionWorkspaceSwitcher.tsx +0 -187
  114. package/src/tui/InputArea.tsx +0 -310
  115. package/src/tui/InteractivePrompt.tsx +0 -59
  116. package/src/tui/ListPicker.tsx +0 -95
  117. package/src/tui/MenuSelect.tsx +0 -104
  118. package/src/tui/MessageList.tsx +0 -284
  119. package/src/tui/PermissionPrompt.tsx +0 -86
  120. package/src/tui/PluginTUI.tsx +0 -258
  121. package/src/tui/SessionPicker.tsx +0 -68
  122. package/src/tui/SessionStatusBar.tsx +0 -73
  123. package/src/tui/SlashAutocomplete.tsx +0 -110
  124. package/src/tui/StatusBar.tsx +0 -236
  125. package/src/tui/StreamingIndicator.tsx +0 -93
  126. package/src/tui/TextPrompt.tsx +0 -81
  127. package/src/tui/ToolCommandOutput.tsx +0 -39
  128. package/src/tui/ToolDiffBlock.tsx +0 -32
  129. package/src/tui/TransportTUI.tsx +0 -117
  130. package/src/tui/TuiInteractionChannel.ts +0 -495
  131. package/src/tui/UpdateNotice.tsx +0 -14
  132. package/src/tui/UsageSummaryEntry.tsx +0 -39
  133. package/src/tui/WaveText.tsx +0 -44
  134. package/src/tui/__tests__/InteractivePrompt.test.tsx +0 -82
  135. package/src/tui/__tests__/ListPicker.test.tsx +0 -159
  136. package/src/tui/__tests__/MenuSelect.test.tsx +0 -103
  137. package/src/tui/__tests__/PluginTUI.test.tsx +0 -167
  138. package/src/tui/__tests__/SlashAutocomplete.test.tsx +0 -140
  139. package/src/tui/__tests__/TextPrompt.test.tsx +0 -98
  140. package/src/tui/__tests__/TuiInteractionChannel.display-contract.test.ts +0 -239
  141. package/src/tui/__tests__/TuiInteractionChannel.lifecycle.test.ts +0 -297
  142. package/src/tui/__tests__/TuiInteractionChannel.requestAction.test.ts +0 -124
  143. package/src/tui/__tests__/UpdateNotice.test.tsx +0 -15
  144. package/src/tui/__tests__/abort-after-permission.test.tsx +0 -169
  145. package/src/tui/__tests__/abort-streaming-e2e.test.tsx +0 -183
  146. package/src/tui/__tests__/background-task-panel.test.tsx +0 -53
  147. package/src/tui/__tests__/background-task-row-format.test.ts +0 -59
  148. package/src/tui/__tests__/channel-factory-integration.test.ts +0 -138
  149. package/src/tui/__tests__/cjk-text-input-flow.test.ts +0 -109
  150. package/src/tui/__tests__/cjk-text-input.test.ts +0 -191
  151. package/src/tui/__tests__/command-effect-handler.test.ts +0 -127
  152. package/src/tui/__tests__/command-output-summary.test.ts +0 -95
  153. package/src/tui/__tests__/compact-event-bridge.test.ts +0 -20
  154. package/src/tui/__tests__/confirm-permission-flow.test.ts +0 -130
  155. package/src/tui/__tests__/confirm-prompt.test.tsx +0 -87
  156. package/src/tui/__tests__/execution-workspace-switcher.test.tsx +0 -110
  157. package/src/tui/__tests__/execution-workspace-view-model.test.ts +0 -93
  158. package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +0 -125
  159. package/src/tui/__tests__/input-area-flow.test.ts +0 -164
  160. package/src/tui/__tests__/message-list-rendering.test.tsx +0 -353
  161. package/src/tui/__tests__/prompt-queue.test.tsx +0 -255
  162. package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +0 -233
  163. package/src/tui/__tests__/pty/pty-driver.ts +0 -135
  164. package/src/tui/__tests__/pty/tui-pty.ptytest.ts +0 -61
  165. package/src/tui/__tests__/render-channel-options.test.ts +0 -32
  166. package/src/tui/__tests__/render-markdown.test.ts +0 -72
  167. package/src/tui/__tests__/selection-flow.test.ts +0 -61
  168. package/src/tui/__tests__/session-init-poller.test.ts +0 -102
  169. package/src/tui/__tests__/session-naming.test.ts +0 -64
  170. package/src/tui/__tests__/session-switch-channel.test.tsx +0 -307
  171. package/src/tui/__tests__/slash-routing-effects.test.ts +0 -228
  172. package/src/tui/__tests__/status-activity.test.ts +0 -71
  173. package/src/tui/__tests__/status-bar.test.tsx +0 -177
  174. package/src/tui/__tests__/streaming-indicator.test.tsx +0 -137
  175. package/src/tui/__tests__/text-prompt-flow.test.ts +0 -77
  176. package/src/tui/__tests__/tui-channel-init-failure.test.ts +0 -57
  177. package/src/tui/__tests__/tui-state-manager.test.ts +0 -401
  178. package/src/tui/background-task-row-format.ts +0 -53
  179. package/src/tui/command-interaction.ts +0 -9
  180. package/src/tui/command-output-summary.ts +0 -122
  181. package/src/tui/create-default-tui-cli-adapter.ts +0 -41
  182. package/src/tui/execution-workspace-view-model.ts +0 -123
  183. package/src/tui/flows/cjk-text-input-flow.ts +0 -285
  184. package/src/tui/flows/confirm-prompt-flow.ts +0 -45
  185. package/src/tui/flows/input-area-flow.ts +0 -189
  186. package/src/tui/flows/permission-prompt-flow.ts +0 -85
  187. package/src/tui/flows/selection-flow.ts +0 -126
  188. package/src/tui/flows/session-init-poller.ts +0 -77
  189. package/src/tui/flows/text-prompt-flow.ts +0 -98
  190. package/src/tui/hooks/command-effect-handler.ts +0 -97
  191. package/src/tui/hooks/command-effect-queue.ts +0 -39
  192. package/src/tui/hooks/side-effects-types.ts +0 -35
  193. package/src/tui/hooks/useAutocomplete.ts +0 -87
  194. package/src/tui/hooks/usePluginCallbacks.ts +0 -31
  195. package/src/tui/hooks/usePluginScreenData.ts +0 -85
  196. package/src/tui/hooks/useSideEffects.ts +0 -175
  197. package/src/tui/hooks/useSlashRouting.ts +0 -118
  198. package/src/tui/hooks/useStatusLineSettings.ts +0 -37
  199. package/src/tui/hooks/useTuiChannel.ts +0 -95
  200. package/src/tui/index.ts +0 -14
  201. package/src/tui/interactions/CommandConfirm.tsx +0 -36
  202. package/src/tui/interactions/CommandPicker.tsx +0 -77
  203. package/src/tui/interactions/__tests__/CommandConfirm.test.tsx +0 -124
  204. package/src/tui/interactions/__tests__/CommandPicker.test.tsx +0 -138
  205. package/src/tui/plugin-tui-handlers.ts +0 -163
  206. package/src/tui/render-markdown.ts +0 -130
  207. package/src/tui/render.tsx +0 -129
  208. package/src/tui/session-naming.ts +0 -33
  209. package/src/tui/status-activity.ts +0 -63
  210. package/src/tui/tui-cli-adapter-context.tsx +0 -13
  211. package/src/tui/tui-cli-adapter.ts +0 -25
  212. package/src/tui/tui-state-manager.ts +0 -226
  213. package/src/tui/tui-transport.ts +0 -35
  214. package/src/tui/types.ts +0 -15
  215. package/src/tui/utils/__tests__/edit-diff.test.ts +0 -426
  216. package/src/tui/utils/__tests__/paste-detection.test.ts +0 -116
  217. package/src/tui/utils/__tests__/paste-labels.test.ts +0 -46
  218. package/src/tui/utils/__tests__/tool-call-extractor.test.ts +0 -227
  219. package/src/tui/utils/__tests__/tool-diff-summary.test.ts +0 -104
  220. package/src/tui/utils/edit-diff.ts +0 -153
  221. package/src/tui/utils/paste-labels.ts +0 -9
  222. package/src/tui/utils/tool-call-extractor.ts +0 -92
  223. package/src/tui/utils/tool-diff-summary.ts +0 -75
  224. package/src/ws/__tests__/ws-handler.test.ts +0 -409
  225. package/src/ws/__tests__/ws-transport.test.ts +0 -53
  226. package/src/ws/index.ts +0 -13
  227. package/src/ws/ws-background-messages.ts +0 -170
  228. package/src/ws/ws-handler.ts +0 -280
  229. package/src/ws/ws-protocol.ts +0 -78
  230. package/src/ws/ws-transport-configurable.ts +0 -128
  231. package/src/ws/ws-transport.ts +0 -42
@@ -1,130 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- applyConfirmPromptInput,
4
- getConfirmPromptInputAction,
5
- } from '../flows/confirm-prompt-flow.js';
6
- import {
7
- applyPermissionPromptInput,
8
- getPermissionPromptInputAction,
9
- PERMISSION_PROMPT_OPTIONS,
10
- } from '../flows/permission-prompt-flow.js';
11
- import { createSelectionFlowState } from '../flows/selection-flow.js';
12
-
13
- describe('confirm prompt flow', () => {
14
- it('Given two options When y shortcut is mapped and applied Then first option is selected', () => {
15
- const action = getConfirmPromptInputAction('y', {}, 2);
16
- expect(action).toEqual({ type: 'shortcut', index: 0 });
17
-
18
- const result = applyConfirmPromptInput(createSelectionFlowState(), action!, 2);
19
-
20
- expect(result.effect).toEqual({ type: 'select', index: 0 });
21
- });
22
-
23
- it('Given more than two options When y or n is typed Then shortcuts are ignored', () => {
24
- expect(getConfirmPromptInputAction('y', {}, 3)).toBeUndefined();
25
- expect(getConfirmPromptInputAction('n', {}, 3)).toBeUndefined();
26
- });
27
-
28
- it('Given selection moved right When enter is applied Then current option is selected', () => {
29
- const moved = applyConfirmPromptInput(createSelectionFlowState(), 'next', 2).state;
30
-
31
- const result = applyConfirmPromptInput(moved, 'select', 2);
32
-
33
- expect(result.effect).toEqual({ type: 'select', index: 1 });
34
- });
35
-
36
- it('Given prompt is resolved When shortcut is applied Then no second selection is emitted', () => {
37
- const selected = applyConfirmPromptInput(createSelectionFlowState(), 'select', 2).state;
38
-
39
- const result = applyConfirmPromptInput(selected, { type: 'shortcut', index: 1 }, 2);
40
-
41
- expect(result.effect).toEqual({ type: 'none' });
42
- });
43
- });
44
-
45
- describe('permission prompt flow', () => {
46
- it('Given y shortcut When applied Then allow decision is emitted', () => {
47
- const action = getPermissionPromptInputAction('y', {});
48
-
49
- const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
50
-
51
- expect(result.effect).toEqual({ type: 'resolve', decision: true });
52
- });
53
-
54
- it('Given a shortcut When applied Then allow-session decision is emitted', () => {
55
- const action = getPermissionPromptInputAction('a', {});
56
-
57
- const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
58
-
59
- expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
60
- });
61
-
62
- it('Given p or 3 shortcut When applied Then allow-project decision is emitted', () => {
63
- expect(
64
- applyPermissionPromptInput(
65
- createSelectionFlowState(),
66
- getPermissionPromptInputAction('p', {})!,
67
- ).effect,
68
- ).toEqual({ type: 'resolve', decision: 'allow-project' });
69
- expect(
70
- applyPermissionPromptInput(
71
- createSelectionFlowState(),
72
- getPermissionPromptInputAction('3', {})!,
73
- ).effect,
74
- ).toEqual({ type: 'resolve', decision: 'allow-project' });
75
- });
76
-
77
- it('Given deny shortcuts When applied Then false decision is emitted', () => {
78
- expect(
79
- applyPermissionPromptInput(
80
- createSelectionFlowState(),
81
- getPermissionPromptInputAction('n', {})!,
82
- ).effect,
83
- ).toEqual({ type: 'resolve', decision: false });
84
- expect(
85
- applyPermissionPromptInput(
86
- createSelectionFlowState(),
87
- getPermissionPromptInputAction('4', {})!,
88
- ).effect,
89
- ).toEqual({ type: 'resolve', decision: false });
90
- });
91
-
92
- it('Given arrow navigation When enter is applied Then selected permission is resolved', () => {
93
- const moved = applyPermissionPromptInput(createSelectionFlowState(), 'next').state;
94
-
95
- const result = applyPermissionPromptInput(moved, 'select');
96
-
97
- expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
98
- });
99
-
100
- it('Given permission is resolved When shortcut is applied Then no second decision is emitted', () => {
101
- const resolved = applyPermissionPromptInput(createSelectionFlowState(), 'select').state;
102
-
103
- const result = applyPermissionPromptInput(resolved, { type: 'shortcut', index: 2 });
104
-
105
- expect(result.effect).toEqual({ type: 'none' });
106
- });
107
-
108
- // CLI-030 TC-03: [s] option is shown
109
- it('Given PERMISSION_PROMPT_OPTIONS When inspected Then session option contains [s] hint', () => {
110
- expect(PERMISSION_PROMPT_OPTIONS[1]).toContain('[s]');
111
- });
112
-
113
- // CLI-030 TC-03: s key maps to allow-session
114
- it('Given s shortcut When applied Then allow-session decision is emitted', () => {
115
- const action = getPermissionPromptInputAction('s', {});
116
-
117
- const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
118
-
119
- expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
120
- });
121
-
122
- // CLI-030 TC-04: allow-once (y) does not add to session list
123
- it('Given y (allow-once) shortcut When applied Then true decision is emitted (not allow-session)', () => {
124
- const action = getPermissionPromptInputAction('y', {});
125
-
126
- const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
127
-
128
- expect(result.effect).toEqual({ type: 'resolve', decision: true });
129
- });
130
- });
@@ -1,87 +0,0 @@
1
- import React from 'react';
2
- import { describe, it, expect, vi } from 'vitest';
3
- import { render } from 'ink-testing-library';
4
- import ConfirmPrompt from '../ConfirmPrompt.js';
5
-
6
- const delay = (ms: number) => new Promise((r) => setTimeout(r, ms));
7
-
8
- describe('ConfirmPrompt', () => {
9
- it('renders message text', () => {
10
- const { lastFrame } = render(<ConfirmPrompt message="Are you sure?" onSelect={() => {}} />);
11
- expect(lastFrame()).toContain('Are you sure?');
12
- });
13
-
14
- it('renders default Yes/No options', () => {
15
- const { lastFrame } = render(<ConfirmPrompt message="Confirm?" onSelect={() => {}} />);
16
- const frame = lastFrame()!;
17
- expect(frame).toContain('Yes');
18
- expect(frame).toContain('No');
19
- });
20
-
21
- it('renders custom options', () => {
22
- const { lastFrame } = render(
23
- <ConfirmPrompt message="Pick" options={['A', 'B', 'C']} onSelect={() => {}} />,
24
- );
25
- const frame = lastFrame()!;
26
- expect(frame).toContain('A');
27
- expect(frame).toContain('B');
28
- expect(frame).toContain('C');
29
- });
30
-
31
- it('first option is highlighted by default', () => {
32
- const { lastFrame } = render(<ConfirmPrompt message="Confirm?" onSelect={() => {}} />);
33
- const frame = lastFrame()!;
34
- // The selected item has '> ' prefix
35
- expect(frame).toContain('> Yes');
36
- });
37
-
38
- it('selects first option on Enter', () => {
39
- const onSelect = vi.fn();
40
- const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
41
- stdin.write('\r');
42
- expect(onSelect).toHaveBeenCalledWith(0);
43
- });
44
-
45
- it('navigates to second option with arrow down and selects', async () => {
46
- const onSelect = vi.fn();
47
- const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
48
- // Arrow down (move to No)
49
- stdin.write('\x1b[B');
50
- await delay(50);
51
- stdin.write('\r');
52
- expect(onSelect).toHaveBeenCalledWith(1);
53
- });
54
-
55
- it('y shortcut selects first option (Yes)', () => {
56
- const onSelect = vi.fn();
57
- const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
58
- stdin.write('y');
59
- expect(onSelect).toHaveBeenCalledWith(0);
60
- });
61
-
62
- it('n shortcut selects second option (No)', () => {
63
- const onSelect = vi.fn();
64
- const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
65
- stdin.write('n');
66
- expect(onSelect).toHaveBeenCalledWith(1);
67
- });
68
-
69
- it('y/n shortcuts do not work with more than 2 options', () => {
70
- const onSelect = vi.fn();
71
- const { stdin } = render(
72
- <ConfirmPrompt message="Pick" options={['A', 'B', 'C']} onSelect={onSelect} />,
73
- );
74
- stdin.write('y');
75
- stdin.write('n');
76
- expect(onSelect).not.toHaveBeenCalled();
77
- });
78
-
79
- it('ignores input after selection (no double-fire)', () => {
80
- const onSelect = vi.fn();
81
- const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
82
- stdin.write('\r');
83
- stdin.write('\r');
84
- stdin.write('y');
85
- expect(onSelect).toHaveBeenCalledTimes(1);
86
- });
87
- });
@@ -1,110 +0,0 @@
1
- import React from 'react';
2
- import { describe, expect, it, vi } from 'vitest';
3
- import { render } from 'ink-testing-library';
4
- import type {
5
- IExecutionWorkspaceEntry,
6
- IExecutionWorkspaceSnapshot,
7
- } from '@robota-sdk/agent-interface-transport';
8
- import ExecutionWorkspaceSwitcher from '../ExecutionWorkspaceSwitcher.js';
9
- import ExecutionWorkspaceDetailPane from '../ExecutionWorkspaceDetailPane.js';
10
-
11
- function makeEntry(overrides: Partial<IExecutionWorkspaceEntry>): IExecutionWorkspaceEntry {
12
- return {
13
- id: 'main:session_1',
14
- sourceId: 'session_1',
15
- kind: 'main_thread',
16
- origin: { kind: 'user_prompt', sessionId: 'session_1' },
17
- status: 'idle',
18
- title: 'Main thread',
19
- subtitle: '2 history entries',
20
- unread: false,
21
- attention: 'none',
22
- visibility: 'default',
23
- updatedAt: '2026-05-09T00:00:00.000Z',
24
- controls: ['select'],
25
- ...overrides,
26
- };
27
- }
28
-
29
- function makeSnapshot(): IExecutionWorkspaceSnapshot {
30
- return {
31
- sessionId: 'session_1',
32
- selectedEntryId: 'main:session_1',
33
- updatedAt: '2026-05-09T00:00:00.000Z',
34
- entries: [
35
- makeEntry({ id: 'main:session_1', kind: 'main_thread', title: 'Main thread' }),
36
- makeEntry({
37
- id: 'task:agent_1',
38
- sourceId: 'agent_1',
39
- kind: 'background_task',
40
- taskKind: 'agent',
41
- status: 'running',
42
- title: 'Explore',
43
- subtitle: 'general-purpose',
44
- preview: 'Inspect task layer',
45
- controls: ['select', 'cancel'],
46
- }),
47
- ],
48
- };
49
- }
50
-
51
- describe('ExecutionWorkspaceSwitcher', () => {
52
- it('renders main and background entries with selected radio markers', () => {
53
- const { lastFrame } = render(
54
- <ExecutionWorkspaceSwitcher
55
- snapshot={makeSnapshot()}
56
- selectedEntryId="task:agent_1"
57
- onSelect={vi.fn()}
58
- onClose={vi.fn()}
59
- />,
60
- );
61
-
62
- const frame = lastFrame()!;
63
- expect(frame).toContain('Execution workspace');
64
- expect(frame).toContain('○ Main thread');
65
- expect(frame).toContain('● Explore agent');
66
- expect(frame).toContain('Inspect task layer');
67
- });
68
-
69
- it('commits the highlighted entry on enter without invoking task controls', () => {
70
- const onSelect = vi.fn();
71
- const { stdin } = render(
72
- <ExecutionWorkspaceSwitcher
73
- snapshot={makeSnapshot()}
74
- selectedEntryId="main:session_1"
75
- onSelect={onSelect}
76
- onClose={vi.fn()}
77
- />,
78
- );
79
-
80
- stdin.write('\u001B[B');
81
- stdin.write('\r');
82
-
83
- expect(onSelect).toHaveBeenCalledWith('task:agent_1');
84
- });
85
-
86
- it('renders selected entry detail records from the SDK detail page', () => {
87
- const entry = makeEntry({
88
- id: 'task:agent_1',
89
- sourceId: 'agent_1',
90
- kind: 'background_task',
91
- taskKind: 'agent',
92
- status: 'completed',
93
- title: 'Explore',
94
- preview: 'Done',
95
- });
96
- const { lastFrame } = render(
97
- <ExecutionWorkspaceDetailPane
98
- entry={entry}
99
- page={{
100
- entryId: 'task:agent_1',
101
- records: [{ id: 'r1', kind: 'result', text: 'Final background result' }],
102
- }}
103
- />,
104
- );
105
-
106
- const frame = lastFrame()!;
107
- expect(frame).toContain('Viewing Explore agent');
108
- expect(frame).toContain('Final background result');
109
- });
110
- });
@@ -1,93 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type {
3
- IExecutionWorkspaceEntry,
4
- IExecutionWorkspaceSnapshot,
5
- } from '@robota-sdk/agent-interface-transport';
6
- import {
7
- countActiveBackgroundWorkspaceEntries,
8
- formatExecutionDetailRecord,
9
- formatExecutionWorkspaceEntryRow,
10
- getDefaultBackgroundWorkspaceEntries,
11
- } from '../execution-workspace-view-model.js';
12
-
13
- function makeEntry(overrides: Partial<IExecutionWorkspaceEntry>): IExecutionWorkspaceEntry {
14
- return {
15
- id: 'task:agent_1',
16
- sourceId: 'agent_1',
17
- kind: 'background_task',
18
- origin: { kind: 'slash_command', sessionId: 'session_1', commandName: 'agent' },
19
- taskKind: 'agent',
20
- status: 'running',
21
- title: 'Explore',
22
- subtitle: 'general-purpose',
23
- preview: 'Map the CLI state manager',
24
- unread: false,
25
- attention: 'none',
26
- visibility: 'default',
27
- updatedAt: '2026-05-09T00:00:00.000Z',
28
- controls: ['select', 'cancel'],
29
- ...overrides,
30
- };
31
- }
32
-
33
- function makeSnapshot(entries: readonly IExecutionWorkspaceEntry[]): IExecutionWorkspaceSnapshot {
34
- return {
35
- sessionId: 'session_1',
36
- selectedEntryId: 'main:session_1',
37
- updatedAt: '2026-05-09T00:00:00.000Z',
38
- entries,
39
- };
40
- }
41
-
42
- describe('execution workspace view model', () => {
43
- it('renders selected and inactive entries with radio markers', () => {
44
- const row = formatExecutionWorkspaceEntryRow(makeEntry({ id: 'task:agent_1' }), {
45
- selectedEntryId: 'task:agent_1',
46
- });
47
- const inactive = formatExecutionWorkspaceEntryRow(makeEntry({ id: 'task:process_1' }), {
48
- selectedEntryId: 'task:agent_1',
49
- });
50
-
51
- expect(row.radio).toBe('●');
52
- expect(row.title).toBe('Explore agent');
53
- expect(row.subtitle).toBe('agent · general-purpose');
54
- expect(row.statusLabel).toBe('running');
55
- expect(inactive.radio).toBe('○');
56
- });
57
-
58
- it('filters default-visible background task entries for the compact panel', () => {
59
- const snapshot = makeSnapshot([
60
- makeEntry({ id: 'main:session_1', kind: 'main_thread', title: 'Main thread' }),
61
- makeEntry({ id: 'task:agent_1', visibility: 'default' }),
62
- makeEntry({ id: 'task:agent_2', visibility: 'collapsed' }),
63
- makeEntry({ id: 'group:group_1', kind: 'background_group', visibility: 'default' }),
64
- ]);
65
-
66
- expect(getDefaultBackgroundWorkspaceEntries(snapshot).map((entry) => entry.id)).toEqual([
67
- 'task:agent_1',
68
- ]);
69
- });
70
-
71
- it('counts active default-visible background tasks without treating collapsed tasks as active', () => {
72
- const snapshot = makeSnapshot([
73
- makeEntry({ id: 'task:queued', status: 'queued' }),
74
- makeEntry({ id: 'task:running', status: 'running' }),
75
- makeEntry({ id: 'task:permission', status: 'waiting_permission' }),
76
- makeEntry({ id: 'task:done', status: 'completed' }),
77
- makeEntry({ id: 'task:hidden', status: 'running', visibility: 'collapsed' }),
78
- ]);
79
-
80
- expect(countActiveBackgroundWorkspaceEntries(snapshot)).toBe(3);
81
- });
82
-
83
- it('bounds detail record text without parsing runner-specific output', () => {
84
- const text = formatExecutionDetailRecord({
85
- id: 'record_1',
86
- kind: 'process_output',
87
- text: ` ${'a'.repeat(180)} `,
88
- });
89
-
90
- expect(text).toHaveLength(163);
91
- expect(text.endsWith('...')).toBe(true);
92
- });
93
- });
@@ -1,125 +0,0 @@
1
- import { writeFileSync } from 'node:fs';
2
-
3
- import {
4
- createProviderSetupFlow,
5
- formatProviderSetupHelpLinks,
6
- getProviderSetupStep,
7
- submitProviderSetupValue,
8
- validateProviderSetupValue,
9
- type IProviderSetupFlowState,
10
- type TProviderSetupType,
11
- } from '@robota-sdk/agent-command';
12
- import { render, useApp } from 'ink';
13
- import React from 'react';
14
-
15
- import InteractivePrompt from '../../InteractivePrompt.js';
16
-
17
- import type { IAIProvider, IProviderDefinition } from '@robota-sdk/agent-core';
18
- import type { TCommandInteractionPrompt as TInteractivePrompt } from '@robota-sdk/agent-interface-transport';
19
-
20
- const openaiDefaults = {
21
- apiKey: '$ENV:OPENAI_API_KEY',
22
- };
23
-
24
- const providerDefinitions: readonly IProviderDefinition[] = [
25
- {
26
- type: 'openai',
27
- defaults: openaiDefaults,
28
- setupHelpLinks: [
29
- {
30
- kind: 'api-key',
31
- label: 'OpenAI API keys',
32
- url: 'https://platform.openai.com/api-keys',
33
- },
34
- ],
35
- setupSteps: [
36
- {
37
- key: 'model',
38
- title: 'OpenAI model',
39
- required: true,
40
- },
41
- {
42
- key: 'apiKey',
43
- title: 'OpenAI API key',
44
- defaultValue: openaiDefaults.apiKey,
45
- masked: true,
46
- },
47
- ],
48
- requiresApiKey: true,
49
- createProvider: () => {
50
- throw new Error('not used');
51
- },
52
- } as IProviderDefinition & { createProvider: () => IAIProvider },
53
- {
54
- type: 'anthropic',
55
- defaults: { model: 'claude-sonnet-4-6' },
56
- setupSteps: [
57
- { key: 'apiKey', title: 'Anthropic API key', required: true, masked: true },
58
- { key: 'model', title: 'Anthropic model', defaultValue: 'claude-sonnet-4-6' },
59
- ],
60
- requiresApiKey: true,
61
- createProvider: () => {
62
- throw new Error('not used');
63
- },
64
- } as IProviderDefinition & { createProvider: () => IAIProvider },
65
- ];
66
-
67
- const [, , outputPath, rawType] = process.argv;
68
-
69
- if (!outputPath || (rawType !== 'openai' && rawType !== 'anthropic')) {
70
- process.stderr.write('Usage: provider-setup-prompt-driver <output-path> <openai|anthropic>\n');
71
- process.exit(1);
72
- }
73
-
74
- function Driver({ type }: { type: TProviderSetupType }): React.ReactElement {
75
- const { exit } = useApp();
76
- const initial = createProviderSetupFlow(type, providerDefinitions);
77
- const [state, setState] = React.useState<IProviderSetupFlowState>(initial);
78
- const [prompt, setPrompt] = React.useState<TInteractivePrompt>(() => toPrompt(initial));
79
-
80
- return (
81
- <InteractivePrompt
82
- prompt={prompt}
83
- onSubmit={(value) => {
84
- const result = submitProviderSetupValue(state, value);
85
- if (result.status === 'complete') {
86
- writeFileSync(outputPath, JSON.stringify(result.input), 'utf8');
87
- exit();
88
- setTimeout(() => process.exit(0), 0);
89
- return;
90
- }
91
- if (result.status === 'error') {
92
- throw new Error(result.message);
93
- }
94
- setState(result.state);
95
- setPrompt(toPrompt(result.state));
96
- }}
97
- onCancel={() => {
98
- exit();
99
- setTimeout(() => process.exit(2), 0);
100
- }}
101
- />
102
- );
103
- }
104
-
105
- function toPrompt(flow: IProviderSetupFlowState): TInteractivePrompt {
106
- const step = getProviderSetupStep(flow);
107
- return {
108
- kind: 'text',
109
- title: step.title,
110
- ...toPromptDescription(flow),
111
- ...(step.defaultValue !== undefined ? { placeholder: step.defaultValue } : {}),
112
- ...(step.defaultValue !== undefined ? { allowEmpty: true } : {}),
113
- ...(step.masked !== undefined ? { masked: step.masked } : {}),
114
- validate: (value) => validateProviderSetupValue(step, value),
115
- };
116
- }
117
-
118
- function toPromptDescription(
119
- flow: IProviderSetupFlowState,
120
- ): { description: string } | Record<string, never> {
121
- const description = formatProviderSetupHelpLinks(flow.setupHelpLinks);
122
- return description.length > 0 ? { description } : {};
123
- }
124
-
125
- render(<Driver type={rawType} />);