@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,164 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- appendPromptHistory,
4
- createPasteLabelChange,
5
- createPromptHistoryNavigationState,
6
- extractPromptHistory,
7
- getAutocompletePopupAction,
8
- getPromptHistoryInputAction,
9
- getPendingPromptInputAction,
10
- moveAutocompleteSelection,
11
- navigatePromptHistory,
12
- resolveEnterCommandSelection,
13
- resolveTabCompletion,
14
- shouldSubmitInput,
15
- } from '../flows/input-area-flow.js';
16
- import type { ICommand } from '@robota-sdk/agent-interface-transport';
17
- import {
18
- createAssistantMessage,
19
- createSystemMessage,
20
- createUserMessage,
21
- messageToHistoryEntry,
22
- } from '@robota-sdk/agent-core';
23
-
24
- const command = (name: string, subcommands?: ICommand[]): ICommand => ({
25
- name,
26
- description: `${name} command`,
27
- source: 'test',
28
- subcommands,
29
- execute: async () => {},
30
- });
31
-
32
- describe('input area flow', () => {
33
- it('Given autocomplete key info When mapped Then popup actions are produced', () => {
34
- expect(getAutocompletePopupAction({ upArrow: true })).toBe('previous');
35
- expect(getAutocompletePopupAction({ downArrow: true })).toBe('next');
36
- expect(getAutocompletePopupAction({ escape: true })).toBe('close');
37
- expect(getAutocompletePopupAction({ tab: true })).toBe('complete');
38
- });
39
-
40
- it('Given pending prompt key info When mapped Then cancel queue action is produced', () => {
41
- expect(getPendingPromptInputAction({ backspace: true })).toBe('cancelQueue');
42
- expect(getPendingPromptInputAction({ delete: true })).toBe('cancelQueue');
43
- expect(getPendingPromptInputAction({ downArrow: true })).toBeUndefined();
44
- });
45
-
46
- it('Given wrapping autocomplete When moving beyond bounds Then index wraps', () => {
47
- expect(moveAutocompleteSelection(0, 3, 'previous')).toBe(2);
48
- expect(moveAutocompleteSelection(2, 3, 'next')).toBe(0);
49
- });
50
-
51
- it('Given parent command input When tab completes subcommand Then child name is inserted', () => {
52
- const result = resolveTabCompletion('/plugin i', command('install'));
53
-
54
- expect(result).toEqual({ type: 'insert', value: '/plugin install ' });
55
- });
56
-
57
- it('Given command with subcommands When enter selects it Then command name is inserted', () => {
58
- const result = resolveEnterCommandSelection('/pl', command('plugin', [command('list')]));
59
-
60
- expect(result).toEqual({ type: 'insert', value: '/plugin ', selectedIndex: 0 });
61
- });
62
-
63
- it('Given leaf command When enter selects it Then submit value is emitted', () => {
64
- const result = resolveEnterCommandSelection('/he', command('help'));
65
-
66
- expect(result).toEqual({ type: 'submit', value: '/help' });
67
- });
68
-
69
- it('Given command with no args and no subcommands When enter selects Then submits', () => {
70
- const result = resolveEnterCommandSelection('/ex', command('exit'));
71
-
72
- expect(result).toEqual({ type: 'submit', value: '/exit' });
73
- });
74
-
75
- it('Given subcommand selected (args present) When enter selects Then submits', () => {
76
- const result = resolveEnterCommandSelection('/mode plan', command('plan'));
77
-
78
- expect(result).toEqual({ type: 'submit', value: '/mode plan' });
79
- });
80
-
81
- it('Given multiline paste When label change is created Then label is inserted at cursor', () => {
82
- const result = createPasteLabelChange('abef', 2, 7, 'c\nd\ne');
83
-
84
- expect(result).toEqual({
85
- value: 'ab[Pasted text #7 +3 lines]ef',
86
- cursorHint: 27,
87
- label: '[Pasted text #7 +3 lines]',
88
- lineCount: 3,
89
- });
90
- });
91
-
92
- it('Given blank prompt When checked Then submit is rejected', () => {
93
- expect(shouldSubmitInput(' ')).toBe(false);
94
- expect(shouldSubmitInput(' hello ')).toBe(true);
95
- });
96
-
97
- it('Given prompt history key info When mapped Then history actions are produced', () => {
98
- expect(getPromptHistoryInputAction({ upArrow: true })).toBe('previous');
99
- expect(getPromptHistoryInputAction({ downArrow: true })).toBe('next');
100
- expect(getPromptHistoryInputAction({ escape: true })).toBeUndefined();
101
- });
102
-
103
- it('Given empty prompt history When navigating Then input is unchanged', () => {
104
- const result = navigatePromptHistory(
105
- 'draft',
106
- [],
107
- createPromptHistoryNavigationState(),
108
- 'previous',
109
- );
110
-
111
- expect(result).toEqual({
112
- value: 'draft',
113
- cursorHint: 5,
114
- state: createPromptHistoryNavigationState(),
115
- });
116
- });
117
-
118
- it('Given draft and history When pressing up Then latest prompt is recalled and draft is saved', () => {
119
- const result = navigatePromptHistory(
120
- 'draft text',
121
- ['first', 'second'],
122
- createPromptHistoryNavigationState(),
123
- 'previous',
124
- );
125
-
126
- expect(result).toEqual({
127
- value: 'second',
128
- cursorHint: 6,
129
- state: { selectedIndex: 1, draft: 'draft text' },
130
- });
131
- });
132
-
133
- it('Given history navigation When pressing down past latest Then draft is restored', () => {
134
- const result = navigatePromptHistory(
135
- 'second',
136
- ['first', 'second'],
137
- { selectedIndex: 1, draft: 'draft text' },
138
- 'next',
139
- );
140
-
141
- expect(result).toEqual({
142
- value: 'draft text',
143
- cursorHint: 10,
144
- state: createPromptHistoryNavigationState(),
145
- });
146
- });
147
-
148
- it('Given prompt submit When appended Then blank and consecutive duplicates are ignored', () => {
149
- expect(appendPromptHistory(['first'], 'second')).toEqual(['first', 'second']);
150
- expect(appendPromptHistory(['first'], 'first')).toEqual(['first']);
151
- expect(appendPromptHistory(['first'], ' ')).toEqual(['first']);
152
- });
153
-
154
- it('Given history entries When extracted Then only user chat content is included', () => {
155
- const entries = [
156
- messageToHistoryEntry(createUserMessage('first')),
157
- messageToHistoryEntry(createAssistantMessage('answer')),
158
- messageToHistoryEntry(createSystemMessage('system')),
159
- messageToHistoryEntry(createUserMessage('second')),
160
- ];
161
-
162
- expect(extractPromptHistory(entries)).toEqual(['first', 'second']);
163
- });
164
- });
@@ -1,353 +0,0 @@
1
- /**
2
- * Rendering tests for MessageList — verifies that IHistoryEntry[]
3
- * entries render with correct labels and content.
4
- *
5
- * These tests catch rendering bugs that data-flow tests miss:
6
- * - tool execution list must show "Tool:" label with tool names
7
- * - chat messages must show correct role labels
8
- * - event entries must show formatted content
9
- */
10
-
11
- import React from 'react';
12
- import { render } from 'ink-testing-library';
13
- import { describe, it, expect } from 'vitest';
14
- import MessageList from '../MessageList.js';
15
- import type { IHistoryEntry } from '@robota-sdk/agent-core';
16
- import {
17
- createUserMessage,
18
- createAssistantMessage,
19
- createSystemMessage,
20
- createToolMessage,
21
- messageToHistoryEntry,
22
- } from '@robota-sdk/agent-core';
23
-
24
- function makeToolSummaryEntry(): IHistoryEntry {
25
- return {
26
- id: 'tool-1',
27
- timestamp: new Date(),
28
- category: 'event',
29
- type: 'tool-summary',
30
- data: {
31
- tools: [
32
- { toolName: 'Read', firstArg: 'file.ts', isRunning: false, result: 'success' },
33
- { toolName: 'Edit', firstArg: 'file.ts', isRunning: false, result: 'success' },
34
- ],
35
- summary: '✓ Read(file.ts)\n✓ Edit(file.ts)',
36
- },
37
- };
38
- }
39
-
40
- function makeSkillInvocationEntry(): IHistoryEntry {
41
- return {
42
- id: 'evt-1',
43
- timestamp: new Date(),
44
- category: 'event',
45
- type: 'skill-activation',
46
- data: {
47
- type: 'skill-activation',
48
- skillName: 'audit',
49
- source: 'plugin',
50
- invocation: 'user-slash',
51
- mode: 'inject',
52
- status: 'started',
53
- timestamp: '2026-05-06T00:00:00.000Z',
54
- message: 'Invoking plugin skill: audit',
55
- },
56
- };
57
- }
58
-
59
- describe('MessageList rendering', () => {
60
- // ── Tool summary rendering ────────────────────────────────────
61
-
62
- it('tool execution list renders with "Tool:" label and tool names', () => {
63
- const history: IHistoryEntry[] = [makeToolSummaryEntry()];
64
- const { lastFrame } = render(<MessageList history={history} />);
65
- const output = lastFrame() ?? '';
66
-
67
- expect(output).toContain('Tool:');
68
- expect(output).toContain('Read(file.ts)');
69
- expect(output).toContain('Edit(file.ts)');
70
- });
71
-
72
- // ── Skill invocation rendering ────────────────────────────────
73
-
74
- it('skill-activation event renders with "System:" label and message', () => {
75
- const history: IHistoryEntry[] = [makeSkillInvocationEntry()];
76
- const { lastFrame } = render(<MessageList history={history} />);
77
- const output = lastFrame() ?? '';
78
-
79
- expect(output).toContain('System:');
80
- expect(output).toContain('Invoking plugin skill: audit');
81
- });
82
-
83
- // ── Chat message rendering ────────────────────────────────────
84
-
85
- it('user message renders with "You:" label', () => {
86
- const history: IHistoryEntry[] = [messageToHistoryEntry(createUserMessage('hello'))];
87
- const { lastFrame } = render(<MessageList history={history} />);
88
- const output = lastFrame() ?? '';
89
-
90
- expect(output).toContain('You:');
91
- expect(output).toContain('hello');
92
- });
93
-
94
- it('assistant message renders with "Robota:" label', () => {
95
- const history: IHistoryEntry[] = [
96
- messageToHistoryEntry(createAssistantMessage('response text')),
97
- ];
98
- const { lastFrame } = render(<MessageList history={history} />);
99
- const output = lastFrame() ?? '';
100
-
101
- expect(output).toContain('Robota:');
102
- expect(output).toContain('response text');
103
- });
104
-
105
- it('assistant message preserves CJK and emoji content', () => {
106
- const content = '긴 한국어 응답과 emoji 🎉 를 표시합니다';
107
- const history: IHistoryEntry[] = [messageToHistoryEntry(createAssistantMessage(content))];
108
- const { lastFrame } = render(<MessageList history={history} />);
109
-
110
- expect(lastFrame()).toContain(content);
111
- });
112
-
113
- it('assistant message renders markdown diff fenced code block content', () => {
114
- const response = [
115
- 'Patch preview:',
116
- '',
117
- '```diff',
118
- '- const oldValue = true;',
119
- '+ const newValue = true;',
120
- '```',
121
- ].join('\n');
122
- const history: IHistoryEntry[] = [messageToHistoryEntry(createAssistantMessage(response))];
123
- const { lastFrame } = render(<MessageList history={history} />);
124
- const output = lastFrame() ?? '';
125
-
126
- expect(output).toContain('Robota:');
127
- expect(output).toContain('Patch preview:');
128
- expect(output).toContain('- const oldValue = true;');
129
- expect(output).toContain('+ const newValue = true;');
130
- });
131
-
132
- it('tool message diff summary renders through markdown diff body format', () => {
133
- const toolSummary = [
134
- {
135
- line: 'Edit(/src/index.ts)',
136
- diffFile: '/src/index.ts',
137
- diffLines: [
138
- { type: 'remove', lineNumber: 1, text: 'const oldValue = true;' },
139
- { type: 'add', lineNumber: 1, text: 'const newValue = true;' },
140
- ],
141
- },
142
- ];
143
- const history: IHistoryEntry[] = [
144
- messageToHistoryEntry(
145
- createToolMessage(JSON.stringify(toolSummary), {
146
- toolCallId: 'call_1',
147
- name: 'tools',
148
- }),
149
- ),
150
- ];
151
-
152
- const { lastFrame } = render(<MessageList history={history} />);
153
- const output = lastFrame() ?? '';
154
-
155
- expect(output).toContain('/src/index.ts');
156
- expect(output).toContain('- 1 | const oldValue = true;');
157
- expect(output).toContain('+ 1 | const newValue = true;');
158
- expect(output).not.toContain('│ 1 - const oldValue = true;');
159
- });
160
-
161
- it('tool-summary event renders persisted edit diff metadata', () => {
162
- const history: IHistoryEntry[] = [
163
- {
164
- id: 'summary_1',
165
- timestamp: new Date(),
166
- category: 'event',
167
- type: 'tool-summary',
168
- data: {
169
- tools: [
170
- {
171
- toolName: 'Edit',
172
- firstArg: '/src/index.ts',
173
- isRunning: false,
174
- result: 'success',
175
- diffFile: '/src/index.ts',
176
- diffLines: [
177
- { type: 'remove', lineNumber: 1, text: 'const temporary = true;' },
178
- { type: 'add', lineNumber: 1, text: 'const original = true;' },
179
- ],
180
- },
181
- ],
182
- summary: '✓ Edit(/src/index.ts)',
183
- },
184
- },
185
- ];
186
-
187
- const { lastFrame } = render(<MessageList history={history} />);
188
- const output = lastFrame() ?? '';
189
-
190
- expect(output).toContain('/src/index.ts');
191
- expect(output).toContain('- 1 | const temporary = true;');
192
- expect(output).toContain('+ 1 | const original = true;');
193
- });
194
-
195
- it('tool-summary event collapses long command output with transcript hint', () => {
196
- const commandOutput = Array.from({ length: 7 }, (_, index) => `line-${index + 1}`).join('\n');
197
- const history: IHistoryEntry[] = [
198
- {
199
- id: 'summary_command_long',
200
- timestamp: new Date(),
201
- category: 'event',
202
- type: 'tool-summary',
203
- data: {
204
- tools: [
205
- {
206
- toolName: 'Bash',
207
- firstArg: 'pnpm test',
208
- isRunning: false,
209
- result: 'success',
210
- toolResultData: JSON.stringify({
211
- success: true,
212
- output: commandOutput,
213
- exitCode: 0,
214
- }),
215
- },
216
- ],
217
- summary: '✓ Bash(pnpm test)',
218
- },
219
- },
220
- ];
221
-
222
- const { lastFrame } = render(<MessageList history={history} />);
223
- const output = lastFrame() ?? '';
224
-
225
- expect(output).toContain('✓ Bash(pnpm test)');
226
- expect(output).toContain('line-1');
227
- expect(output).toContain('line-4');
228
- expect(output).not.toContain('line-5');
229
- expect(output).toContain('... +3 lines (full output in session transcript)');
230
- });
231
-
232
- it('tool-summary event marks non-zero command exits as failed', () => {
233
- const history: IHistoryEntry[] = [
234
- {
235
- id: 'summary_command_failed',
236
- timestamp: new Date(),
237
- category: 'event',
238
- type: 'tool-summary',
239
- data: {
240
- tools: [
241
- {
242
- toolName: 'Bash',
243
- firstArg: 'exit 42',
244
- isRunning: false,
245
- result: 'success',
246
- toolResultData: JSON.stringify({ success: true, output: '', exitCode: 42 }),
247
- },
248
- ],
249
- summary: '✓ Bash(exit 42)',
250
- },
251
- },
252
- ];
253
-
254
- const { lastFrame } = render(<MessageList history={history} />);
255
- const output = lastFrame() ?? '';
256
-
257
- expect(output).toContain('✗ Bash(exit 42)');
258
- expect(output).toContain('exit 42');
259
- });
260
-
261
- it('usage-summary event renders compact token and cost visibility', () => {
262
- const history: IHistoryEntry[] = [
263
- {
264
- id: 'usage_1',
265
- timestamp: new Date(),
266
- category: 'event',
267
- type: 'usage-summary',
268
- data: {
269
- kind: 'exact',
270
- scope: 'turn',
271
- promptTokens: 100,
272
- completionTokens: 50,
273
- totalTokens: 150,
274
- contextUsedTokens: 150,
275
- contextMaxTokens: 1000,
276
- contextUsedPercentage: 15,
277
- costStatus: 'unknown',
278
- },
279
- },
280
- ];
281
-
282
- const { lastFrame } = render(<MessageList history={history} />);
283
- const output = lastFrame() ?? '';
284
-
285
- expect(output).toContain('Usage:');
286
- expect(output).toContain('exact');
287
- expect(output).toContain('150 tokens');
288
- expect(output).toContain('in 100');
289
- expect(output).toContain('out 50');
290
- expect(output).toContain('cost unknown');
291
- });
292
-
293
- it('system message renders with "System:" label', () => {
294
- const history: IHistoryEntry[] = [
295
- messageToHistoryEntry(createSystemMessage('Interrupted by user.')),
296
- ];
297
- const { lastFrame } = render(<MessageList history={history} />);
298
- const output = lastFrame() ?? '';
299
-
300
- expect(output).toContain('System:');
301
- expect(output).toContain('Interrupted by user.');
302
- });
303
-
304
- // ── Display order after abort ─────────────────────────────────
305
-
306
- it('abort display order: You → Tool → Robota → System', () => {
307
- const history: IHistoryEntry[] = [
308
- messageToHistoryEntry(createUserMessage('/audit')),
309
- makeToolSummaryEntry(),
310
- messageToHistoryEntry(createAssistantMessage('partial response')),
311
- messageToHistoryEntry(createSystemMessage('Interrupted by user.')),
312
- ];
313
-
314
- const { lastFrame } = render(<MessageList history={history} />);
315
- const output = lastFrame() ?? '';
316
-
317
- const youIdx = output.indexOf('You:');
318
- const toolIdx = output.indexOf('Tool:');
319
- const robotaIdx = output.indexOf('Robota:');
320
- const systemIdx = output.indexOf('Interrupted by user.');
321
-
322
- // All must be present
323
- expect(youIdx).toBeGreaterThanOrEqual(0);
324
- expect(toolIdx).toBeGreaterThanOrEqual(0);
325
- expect(robotaIdx).toBeGreaterThanOrEqual(0);
326
- expect(systemIdx).toBeGreaterThanOrEqual(0);
327
-
328
- // Order: You → Tool → Robota → System
329
- expect(youIdx).toBeLessThan(toolIdx);
330
- expect(toolIdx).toBeLessThan(robotaIdx);
331
- expect(robotaIdx).toBeLessThan(systemIdx);
332
- });
333
-
334
- // ── Mixed history ─────────────────────────────────────────────
335
-
336
- it('renders mixed chat and event entries in order', () => {
337
- const history: IHistoryEntry[] = [
338
- messageToHistoryEntry(createUserMessage('hello')),
339
- makeSkillInvocationEntry(),
340
- makeToolSummaryEntry(),
341
- messageToHistoryEntry(createAssistantMessage('done')),
342
- ];
343
-
344
- const { lastFrame } = render(<MessageList history={history} />);
345
- const output = lastFrame() ?? '';
346
-
347
- // All four entries rendered
348
- expect(output).toContain('You:');
349
- expect(output).toContain('Invoking plugin skill: audit');
350
- expect(output).toContain('Tool:');
351
- expect(output).toContain('Robota:');
352
- });
353
- });