@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,33 +0,0 @@
1
- import { createSystemMessage, createUserMessage } from '@robota-sdk/agent-core';
2
-
3
- import type { IAIProvider } from '@robota-sdk/agent-core';
4
-
5
- const SYSTEM_PROMPT =
6
- 'You generate short session titles. Respond with ONLY a 3-5 word lowercase-hyphenated title (e.g. refactor-auth-middleware). No explanation, no punctuation, no quotes.';
7
-
8
- const MAX_FIRST_MESSAGE_CHARS = 200;
9
-
10
- function sanitizeName(raw: string): string {
11
- return raw
12
- .toLowerCase()
13
- .replace(/[^a-z0-9\s-]/g, '')
14
- .trim()
15
- .replace(/\s+/g, '-')
16
- .replace(/-+/g, '-')
17
- .slice(0, 60);
18
- }
19
-
20
- export async function generateSessionName(
21
- provider: IAIProvider,
22
- firstMessage: string,
23
- ): Promise<string> {
24
- const truncated = firstMessage.slice(0, MAX_FIRST_MESSAGE_CHARS);
25
- const response = await provider.chat(
26
- [createSystemMessage(SYSTEM_PROMPT), createUserMessage(truncated)],
27
- { maxTokens: 20 },
28
- );
29
- const raw = typeof response.content === 'string' ? response.content : '';
30
- const name = sanitizeName(raw);
31
- if (!name || name.length < 3) return sanitizeName(firstMessage);
32
- return name;
33
- }
@@ -1,63 +0,0 @@
1
- export type TStatusActivityKind = 'tools' | 'thinking' | 'background' | 'queued' | 'idle';
2
-
3
- export interface IStatusActivityInput {
4
- isThinking: boolean;
5
- activeToolCount: number;
6
- activeBackgroundTaskCount: number;
7
- hasPendingPrompt: boolean;
8
- }
9
-
10
- export interface IStatusActivity {
11
- kind: TStatusActivityKind;
12
- label: string;
13
- color: string;
14
- segments: string[];
15
- text: string;
16
- }
17
-
18
- const NO_ACTIVE_ITEMS = 0;
19
-
20
- export function formatStatusActivity(input: IStatusActivityInput): IStatusActivity {
21
- const base = getPrimaryActivity(input);
22
- const segments = input.hasPendingPrompt && base.kind !== 'queued' ? ['queued'] : [];
23
- const text = [base.label, ...segments].join(' · ');
24
- return { ...base, segments, text };
25
- }
26
-
27
- function getPrimaryActivity(
28
- input: IStatusActivityInput,
29
- ): Omit<IStatusActivity, 'segments' | 'text'> {
30
- if (input.activeToolCount > NO_ACTIVE_ITEMS) {
31
- return {
32
- kind: 'tools',
33
- label: `Tools (${input.activeToolCount})`,
34
- color: 'cyan',
35
- };
36
- }
37
- if (input.isThinking) {
38
- return {
39
- kind: 'thinking',
40
- label: 'Thinking',
41
- color: 'yellow',
42
- };
43
- }
44
- if (input.activeBackgroundTaskCount > NO_ACTIVE_ITEMS) {
45
- return {
46
- kind: 'background',
47
- label: `Background (${input.activeBackgroundTaskCount})`,
48
- color: 'cyan',
49
- };
50
- }
51
- if (input.hasPendingPrompt) {
52
- return {
53
- kind: 'queued',
54
- label: 'Queued',
55
- color: 'yellow',
56
- };
57
- }
58
- return {
59
- kind: 'idle',
60
- label: 'Idle',
61
- color: 'gray',
62
- };
63
- }
@@ -1,13 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
-
3
- import type { ITuiCliAdapter } from './tui-cli-adapter.js';
4
-
5
- const TuiCliAdapterContext = createContext<ITuiCliAdapter | null>(null);
6
-
7
- export const TuiCliAdapterProvider = TuiCliAdapterContext.Provider;
8
-
9
- export function useTuiCliAdapter(): ITuiCliAdapter {
10
- const adapter = useContext(TuiCliAdapterContext);
11
- if (!adapter) throw new Error('TuiCliAdapterContext not provided');
12
- return adapter;
13
- }
@@ -1,25 +0,0 @@
1
- import type { TUniversalValue } from '@robota-sdk/agent-core';
2
- import type { CommandRegistry } from '@robota-sdk/agent-framework';
3
- import type {
4
- IStatusLineCommandSettings,
5
- TStatusLineCommandSettingsPatch,
6
- } from '@robota-sdk/agent-interface-transport';
7
-
8
- export interface ITuiCliAdapter {
9
- getUserSettingsPath(): string;
10
- readSettings(path: string): Record<string, TUniversalValue>;
11
- writeSettings(path: string, settings: Record<string, TUniversalValue>): void;
12
- deleteSettings(path: string): boolean;
13
- applyStatusLineSettings(
14
- path: string,
15
- patch: TStatusLineCommandSettingsPatch,
16
- ): IStatusLineCommandSettings;
17
- reloadPluginCommandSource(registry: CommandRegistry): void;
18
- applyActiveModelChange(
19
- cwd: string,
20
- modelId: string,
21
- options?: { providerOverride?: string },
22
- ): { applied: boolean };
23
- getGitBranch(cwd: string): string | undefined;
24
- getProviderDisplayName(type: string): string;
25
- }
@@ -1,226 +0,0 @@
1
- /**
2
- * TuiStateManager — pure TypeScript rendering state manager.
3
- *
4
- * Converts InteractiveSession events into rendering state.
5
- * No React dependency. Fully unit-testable.
6
- *
7
- * React hook (useTuiChannel) subscribes to onChange
8
- * and reads state for rendering.
9
- */
10
-
11
- import type { IContextWindowState, IHistoryEntry } from '@robota-sdk/agent-core';
12
- import type {
13
- IExecutionResult,
14
- IExecutionWorkspaceSnapshot,
15
- IToolState,
16
- } from '@robota-sdk/agent-interface-transport';
17
-
18
- /** Max messages kept in rendering state */
19
- const MAX_RENDERED_MESSAGES = 100;
20
-
21
- /** Debounce interval for streaming text notify (limits renderMarkdown frequency) */
22
- const STREAMING_DEBOUNCE_MS = 300;
23
- export interface IContextState {
24
- percentage: number;
25
- usedTokens: number;
26
- maxTokens: number;
27
- }
28
-
29
- /** Create a debounced notify — schedules at most one call per interval. */
30
- function createDebouncedNotify(
31
- notify: () => void,
32
- ms: number,
33
- ): { schedule: () => void; flush: () => void } {
34
- let timer: ReturnType<typeof setTimeout> | null = null;
35
- return {
36
- schedule() {
37
- if (!timer) {
38
- timer = setTimeout(() => {
39
- timer = null;
40
- notify();
41
- }, ms);
42
- }
43
- },
44
- flush() {
45
- if (timer) {
46
- clearTimeout(timer);
47
- timer = null;
48
- }
49
- },
50
- };
51
- }
52
-
53
- export class TuiStateManager {
54
- // ── Rendering state ───────────────────────────────────────────
55
- history: IHistoryEntry[] = [];
56
- streamingText = '';
57
- activeTools: IToolState[] = [];
58
- isThinking = false;
59
- isAborting = false;
60
- pendingPrompt: string | null = null;
61
- contextState: IContextState = { percentage: 0, usedTokens: 0, maxTokens: 0 };
62
- executionWorkspaceSnapshot: IExecutionWorkspaceSnapshot | null = null;
63
- selectedExecutionEntryId: string | undefined;
64
-
65
- /** Called after any state change. React hook sets this to trigger re-render. */
66
- onChange: (() => void) | null = null;
67
-
68
- // ── Internal ──────────────────────────────────────────────────
69
- private streamBuf = '';
70
- private debouncedStreamNotify = createDebouncedNotify(() => this.notify(), STREAMING_DEBOUNCE_MS);
71
-
72
- private notify(): void {
73
- this.onChange?.();
74
- }
75
-
76
- // ── Event handlers (InteractiveSession → state) ───────────────
77
-
78
- onTextDelta = (delta: string): void => {
79
- this.streamBuf += delta;
80
- this.streamingText = this.streamBuf;
81
- this.debouncedStreamNotify.schedule();
82
- };
83
-
84
- onToolStart = (state: IToolState): void => {
85
- this.activeTools = [...this.activeTools, state];
86
- this.notify();
87
- };
88
-
89
- onToolEnd = (state: IToolState): void => {
90
- // findLastIndex: when same tool runs concurrently, match the most recently started instance
91
- const idx = this.activeTools.findLastIndex((t) => t.toolName === state.toolName && t.isRunning);
92
- if (idx !== -1) {
93
- const updated = [...this.activeTools];
94
- updated[idx] = state;
95
- this.activeTools = updated;
96
- }
97
- this.notify();
98
- };
99
-
100
- onThinking = (thinking: boolean): void => {
101
- this.isThinking = thinking;
102
- if (thinking) {
103
- // Clear at START of new execution (preserves previous result until next)
104
- this.debouncedStreamNotify.flush();
105
- this.streamBuf = '';
106
- this.streamingText = '';
107
- this.activeTools = [];
108
- } else {
109
- this.isAborting = false;
110
- this.activeTools = [];
111
- }
112
- this.notify();
113
- };
114
-
115
- onComplete = (result: IExecutionResult): void => {
116
- // Tool summary is now in messages (pushed by InteractiveSession)
117
- // Clear streaming display
118
- this.debouncedStreamNotify.flush();
119
- this.streamBuf = '';
120
- this.streamingText = '';
121
- this.activeTools = [];
122
- this.contextState = {
123
- percentage: result.contextState.usedPercentage,
124
- usedTokens: result.contextState.usedTokens,
125
- maxTokens: result.contextState.maxTokens,
126
- };
127
- this.notify();
128
- };
129
-
130
- onInterrupted = (): void => {
131
- // Tool summary is now in messages
132
- this.debouncedStreamNotify.flush();
133
- this.streamBuf = '';
134
- this.streamingText = '';
135
- this.activeTools = [];
136
- this.notify();
137
- };
138
-
139
- onError = (): void => {
140
- // Tool summary is now in messages
141
- this.debouncedStreamNotify.flush();
142
- this.streamBuf = '';
143
- this.streamingText = '';
144
- this.activeTools = [];
145
- this.notify();
146
- };
147
-
148
- onContextUpdate = (state: IContextWindowState): void => {
149
- this.setContextState({
150
- percentage: state.usedPercentage,
151
- usedTokens: state.usedTokens,
152
- maxTokens: state.maxTokens,
153
- });
154
- };
155
-
156
- // ── State updates from external sources ───────────────────────
157
-
158
- /** Sync history from InteractiveSession */
159
- syncHistory(entries: IHistoryEntry[]): void {
160
- if (entries.length === 0) return;
161
- this.history =
162
- entries.length > MAX_RENDERED_MESSAGES ? entries.slice(-MAX_RENDERED_MESSAGES) : [...entries];
163
- this.notify();
164
- }
165
-
166
- /** Add a single history entry */
167
- addEntry(entry: IHistoryEntry): void {
168
- const updated = [...this.history, entry];
169
- this.history =
170
- updated.length > MAX_RENDERED_MESSAGES ? updated.slice(-MAX_RENDERED_MESSAGES) : updated;
171
- this.notify();
172
- }
173
-
174
- clearHistory(): void {
175
- this.history = [];
176
- this.debouncedStreamNotify.flush();
177
- this.streamBuf = '';
178
- this.streamingText = '';
179
- this.activeTools = [];
180
- this.notify();
181
- }
182
-
183
- /** Update pending prompt state */
184
- setPendingPrompt(prompt: string | null): void {
185
- this.pendingPrompt = prompt;
186
- this.notify();
187
- }
188
-
189
- /** Set aborting flag */
190
- setAborting(aborting: boolean): void {
191
- this.isAborting = aborting;
192
- this.notify();
193
- }
194
-
195
- /** Update context state */
196
- setContextState(state: IContextState): void {
197
- this.contextState = state;
198
- this.notify();
199
- }
200
-
201
- syncExecutionWorkspaceSnapshot(snapshot: IExecutionWorkspaceSnapshot): void {
202
- const currentSelection = this.selectedExecutionEntryId;
203
- const hasCurrentSelection =
204
- currentSelection !== undefined &&
205
- snapshot.entries.some((entry) => entry.id === currentSelection);
206
- const selectedExecutionEntryId = hasCurrentSelection
207
- ? currentSelection
208
- : (snapshot.selectedEntryId ?? snapshot.entries[0]?.id);
209
- this.executionWorkspaceSnapshot = {
210
- ...snapshot,
211
- ...(selectedExecutionEntryId ? { selectedEntryId: selectedExecutionEntryId } : {}),
212
- };
213
- this.selectedExecutionEntryId = selectedExecutionEntryId;
214
- this.notify();
215
- }
216
-
217
- selectExecutionWorkspaceEntry(entryId: string): void {
218
- if (!this.executionWorkspaceSnapshot?.entries.some((entry) => entry.id === entryId)) return;
219
- this.selectedExecutionEntryId = entryId;
220
- this.executionWorkspaceSnapshot = {
221
- ...this.executionWorkspaceSnapshot,
222
- selectedEntryId: entryId,
223
- };
224
- this.notify();
225
- }
226
- }
@@ -1,35 +0,0 @@
1
- import { renderApp, type IRenderOptions } from './render.js';
2
-
3
- import type { TUniversalValue } from '@robota-sdk/agent-core';
4
- import type {
5
- IConfigurableTransport,
6
- IInteractiveSession,
7
- } from '@robota-sdk/agent-interface-transport';
8
-
9
- export class TuiTransport implements IConfigurableTransport<IInteractiveSession> {
10
- readonly name = 'tui';
11
- readonly defaultEnabled = true;
12
- readonly optionsSchema = {};
13
-
14
- private readonly options: IRenderOptions;
15
-
16
- constructor(options: IRenderOptions) {
17
- this.options = options;
18
- }
19
-
20
- attach(_session: IInteractiveSession): void {
21
- // TuiTransport creates its own InteractiveSession internally via TuiInteractionChannel.
22
- }
23
-
24
- async start(): Promise<void> {
25
- await renderApp(this.options);
26
- }
27
-
28
- async stop(): Promise<void> {
29
- // Ink exits when the user triggers shutdown from within the TUI.
30
- }
31
-
32
- validateOptions(_options: Record<string, TUniversalValue>): boolean {
33
- return true;
34
- }
35
- }
package/src/tui/types.ts DELETED
@@ -1,15 +0,0 @@
1
- /** UI-layer permission types for the Ink TUI */
2
-
3
- import type { TToolArgs } from '@robota-sdk/agent-core';
4
-
5
- /**
6
- * Permission result: true (allow once), false (deny), 'allow-session' (remember for session),
7
- * or 'allow-project' (persist to .robota/settings.local.json).
8
- */
9
- export type TPermissionResult = boolean | 'allow-session' | 'allow-project';
10
-
11
- export interface IPermissionRequest {
12
- toolName: string;
13
- toolArgs: TToolArgs;
14
- resolve: (result: TPermissionResult) => void;
15
- }