@robota-sdk/agent-transport 3.0.0-beta.64

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 (183) hide show
  1. package/LICENSE +21 -0
  2. package/dist/node/headless/index.cjs +1 -0
  3. package/dist/node/headless/index.d.ts +2 -0
  4. package/dist/node/headless/index.js +1 -0
  5. package/dist/node/headless-CWEpJXFK.js +7 -0
  6. package/dist/node/headless-CWEpJXFK.js.map +1 -0
  7. package/dist/node/headless-CsZFelG9.cjs +6 -0
  8. package/dist/node/http/index.cjs +1 -0
  9. package/dist/node/http/index.d.ts +2 -0
  10. package/dist/node/http/index.js +1 -0
  11. package/dist/node/http-CM3TJhrF.cjs +1 -0
  12. package/dist/node/http-DwO1AHG-.js +2 -0
  13. package/dist/node/http-DwO1AHG-.js.map +1 -0
  14. package/dist/node/index--Ti9NzQX.d.ts +64 -0
  15. package/dist/node/index--Ti9NzQX.d.ts.map +1 -0
  16. package/dist/node/index-B_rcr14p.d.ts +47 -0
  17. package/dist/node/index-B_rcr14p.d.ts.map +1 -0
  18. package/dist/node/index-C9LWCL4l.d.ts +34 -0
  19. package/dist/node/index-C9LWCL4l.d.ts.map +1 -0
  20. package/dist/node/index-CAr3ioVh.d.ts +64 -0
  21. package/dist/node/index-CAr3ioVh.d.ts.map +1 -0
  22. package/dist/node/index-CEs25wVk.d.ts +213 -0
  23. package/dist/node/index-CEs25wVk.d.ts.map +1 -0
  24. package/dist/node/index-CvXLpjJO.d.ts +213 -0
  25. package/dist/node/index-CvXLpjJO.d.ts.map +1 -0
  26. package/dist/node/index-D34WUfFH.d.ts +26 -0
  27. package/dist/node/index-D34WUfFH.d.ts.map +1 -0
  28. package/dist/node/index-Y0zHb1Bz.d.ts +47 -0
  29. package/dist/node/index-Y0zHb1Bz.d.ts.map +1 -0
  30. package/dist/node/index-k3TUjA-T.d.ts +26 -0
  31. package/dist/node/index-k3TUjA-T.d.ts.map +1 -0
  32. package/dist/node/index-nBlMTFkZ.d.ts +34 -0
  33. package/dist/node/index-nBlMTFkZ.d.ts.map +1 -0
  34. package/dist/node/index.cjs +1 -0
  35. package/dist/node/index.d.ts +6 -0
  36. package/dist/node/index.js +1 -0
  37. package/dist/node/mcp/index.cjs +1 -0
  38. package/dist/node/mcp/index.d.ts +2 -0
  39. package/dist/node/mcp/index.js +1 -0
  40. package/dist/node/mcp-BXBwF6Wu.js +2 -0
  41. package/dist/node/mcp-BXBwF6Wu.js.map +1 -0
  42. package/dist/node/mcp-DcHuGokt.cjs +1 -0
  43. package/dist/node/tui/index.cjs +1 -0
  44. package/dist/node/tui/index.d.ts +2 -0
  45. package/dist/node/tui/index.js +1 -0
  46. package/dist/node/tui-CeD_6rSo.cjs +24 -0
  47. package/dist/node/tui-zmDTPk4b.js +25 -0
  48. package/dist/node/tui-zmDTPk4b.js.map +1 -0
  49. package/dist/node/ws/index.cjs +1 -0
  50. package/dist/node/ws/index.d.ts +2 -0
  51. package/dist/node/ws/index.js +1 -0
  52. package/dist/node/ws-B-oRccFl.js +2 -0
  53. package/dist/node/ws-B-oRccFl.js.map +1 -0
  54. package/dist/node/ws-COnIgnmn.cjs +1 -0
  55. package/package.json +141 -0
  56. package/src/headless/__tests__/headless-runner-initialization.test.ts +45 -0
  57. package/src/headless/__tests__/headless-runner.test.ts +484 -0
  58. package/src/headless/__tests__/headless-skill-activation.integration.test.ts +430 -0
  59. package/src/headless/__tests__/headless-transport.test.ts +268 -0
  60. package/src/headless/headless-runner.ts +141 -0
  61. package/src/headless/headless-stream-json.ts +142 -0
  62. package/src/headless/headless-transport.ts +43 -0
  63. package/src/headless/index.ts +4 -0
  64. package/src/http/__tests__/http-transport.test.ts +55 -0
  65. package/src/http/__tests__/routes.test.ts +168 -0
  66. package/src/http/http-transport.ts +42 -0
  67. package/src/http/index.ts +4 -0
  68. package/src/http/routes.ts +151 -0
  69. package/src/index.ts +5 -0
  70. package/src/mcp/__tests__/mcp-server.test.ts +66 -0
  71. package/src/mcp/__tests__/mcp-transport.test.ts +46 -0
  72. package/src/mcp/index.ts +4 -0
  73. package/src/mcp/mcp-server.ts +162 -0
  74. package/src/mcp/mcp-transport.ts +48 -0
  75. package/src/tui/App.tsx +478 -0
  76. package/src/tui/BackgroundTaskPanel.tsx +34 -0
  77. package/src/tui/CjkTextInput.tsx +204 -0
  78. package/src/tui/ConfirmPrompt.tsx +69 -0
  79. package/src/tui/ExecutionWorkspaceDetailPane.tsx +62 -0
  80. package/src/tui/ExecutionWorkspaceSwitcher.tsx +185 -0
  81. package/src/tui/InkTerminal.ts +42 -0
  82. package/src/tui/InputArea.tsx +298 -0
  83. package/src/tui/InteractivePrompt.tsx +57 -0
  84. package/src/tui/ListPicker.tsx +94 -0
  85. package/src/tui/MenuSelect.tsx +103 -0
  86. package/src/tui/MessageList.tsx +282 -0
  87. package/src/tui/PermissionPrompt.tsx +84 -0
  88. package/src/tui/PluginTUI.tsx +256 -0
  89. package/src/tui/SessionPicker.tsx +66 -0
  90. package/src/tui/SessionStatusBar.tsx +66 -0
  91. package/src/tui/SlashAutocomplete.tsx +110 -0
  92. package/src/tui/StatusBar.tsx +213 -0
  93. package/src/tui/StreamingIndicator.tsx +91 -0
  94. package/src/tui/TextPrompt.tsx +80 -0
  95. package/src/tui/ToolCommandOutput.tsx +37 -0
  96. package/src/tui/ToolDiffBlock.tsx +30 -0
  97. package/src/tui/TransportTUI.tsx +116 -0
  98. package/src/tui/UpdateNotice.tsx +14 -0
  99. package/src/tui/UsageSummaryEntry.tsx +38 -0
  100. package/src/tui/WaveText.tsx +44 -0
  101. package/src/tui/__tests__/InteractivePrompt.test.tsx +82 -0
  102. package/src/tui/__tests__/ListPicker.test.tsx +159 -0
  103. package/src/tui/__tests__/MenuSelect.test.tsx +103 -0
  104. package/src/tui/__tests__/PluginTUI.test.tsx +167 -0
  105. package/src/tui/__tests__/SlashAutocomplete.test.tsx +140 -0
  106. package/src/tui/__tests__/TextPrompt.test.tsx +98 -0
  107. package/src/tui/__tests__/UpdateNotice.test.tsx +15 -0
  108. package/src/tui/__tests__/abort-after-permission.test.tsx +169 -0
  109. package/src/tui/__tests__/abort-streaming-e2e.test.tsx +183 -0
  110. package/src/tui/__tests__/background-task-panel.test.tsx +53 -0
  111. package/src/tui/__tests__/background-task-row-format.test.ts +59 -0
  112. package/src/tui/__tests__/cjk-text-input-flow.test.ts +109 -0
  113. package/src/tui/__tests__/cjk-text-input.test.ts +191 -0
  114. package/src/tui/__tests__/command-effect-handler.test.ts +128 -0
  115. package/src/tui/__tests__/command-output-summary.test.ts +95 -0
  116. package/src/tui/__tests__/compact-event-bridge.test.ts +20 -0
  117. package/src/tui/__tests__/confirm-permission-flow.test.ts +91 -0
  118. package/src/tui/__tests__/confirm-prompt.test.tsx +87 -0
  119. package/src/tui/__tests__/execution-workspace-switcher.test.tsx +110 -0
  120. package/src/tui/__tests__/execution-workspace-view-model.test.ts +93 -0
  121. package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +122 -0
  122. package/src/tui/__tests__/input-area-flow.test.ts +152 -0
  123. package/src/tui/__tests__/message-list-rendering.test.tsx +353 -0
  124. package/src/tui/__tests__/model-change-side-effect.test.ts +91 -0
  125. package/src/tui/__tests__/prompt-queue.test.tsx +255 -0
  126. package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +233 -0
  127. package/src/tui/__tests__/render-markdown.test.ts +72 -0
  128. package/src/tui/__tests__/selection-flow.test.ts +61 -0
  129. package/src/tui/__tests__/slash-routing-effects.test.ts +225 -0
  130. package/src/tui/__tests__/status-activity.test.ts +71 -0
  131. package/src/tui/__tests__/status-bar.test.tsx +157 -0
  132. package/src/tui/__tests__/streaming-indicator.test.tsx +137 -0
  133. package/src/tui/__tests__/text-prompt-flow.test.ts +77 -0
  134. package/src/tui/__tests__/tui-state-manager.test.ts +401 -0
  135. package/src/tui/background-task-row-format.ts +52 -0
  136. package/src/tui/command-output-summary.ts +122 -0
  137. package/src/tui/execution-workspace-view-model.ts +123 -0
  138. package/src/tui/flows/cjk-text-input-flow.ts +285 -0
  139. package/src/tui/flows/confirm-prompt-flow.ts +45 -0
  140. package/src/tui/flows/input-area-flow.ts +186 -0
  141. package/src/tui/flows/permission-prompt-flow.ts +76 -0
  142. package/src/tui/flows/selection-flow.ts +126 -0
  143. package/src/tui/flows/text-prompt-flow.ts +98 -0
  144. package/src/tui/hooks/command-effect-handler.ts +98 -0
  145. package/src/tui/hooks/command-effect-queue.ts +39 -0
  146. package/src/tui/hooks/model-change-side-effect.ts +63 -0
  147. package/src/tui/hooks/side-effects-types.ts +38 -0
  148. package/src/tui/hooks/use-interactive-session-init.ts +50 -0
  149. package/src/tui/hooks/useAutocomplete.ts +85 -0
  150. package/src/tui/hooks/useInteractiveSession.ts +273 -0
  151. package/src/tui/hooks/usePermissionQueue.ts +51 -0
  152. package/src/tui/hooks/usePluginCallbacks.ts +30 -0
  153. package/src/tui/hooks/usePluginScreenData.ts +84 -0
  154. package/src/tui/hooks/useSideEffects.ts +210 -0
  155. package/src/tui/hooks/useSlashRouting.ts +117 -0
  156. package/src/tui/hooks/useStatusLineSettings.ts +35 -0
  157. package/src/tui/index.ts +3 -0
  158. package/src/tui/plugin-tui-handlers.ts +163 -0
  159. package/src/tui/render-markdown.ts +129 -0
  160. package/src/tui/render.tsx +60 -0
  161. package/src/tui/status-activity.ts +63 -0
  162. package/src/tui/tui-cli-adapter-context.tsx +12 -0
  163. package/src/tui/tui-cli-adapter.ts +25 -0
  164. package/src/tui/tui-state-manager.ts +225 -0
  165. package/src/tui/tui-transport.ts +32 -0
  166. package/src/tui/types.ts +14 -0
  167. package/src/tui/utils/__tests__/edit-diff.test.ts +426 -0
  168. package/src/tui/utils/__tests__/paste-detection.test.ts +116 -0
  169. package/src/tui/utils/__tests__/paste-labels.test.ts +46 -0
  170. package/src/tui/utils/__tests__/tool-call-extractor.test.ts +227 -0
  171. package/src/tui/utils/__tests__/tool-diff-summary.test.ts +104 -0
  172. package/src/tui/utils/edit-diff.ts +152 -0
  173. package/src/tui/utils/paste-labels.ts +9 -0
  174. package/src/tui/utils/tool-call-extractor.ts +91 -0
  175. package/src/tui/utils/tool-diff-summary.ts +75 -0
  176. package/src/ws/__tests__/ws-handler.test.ts +407 -0
  177. package/src/ws/__tests__/ws-transport.test.ts +53 -0
  178. package/src/ws/index.ts +13 -0
  179. package/src/ws/ws-background-messages.ts +170 -0
  180. package/src/ws/ws-handler.ts +279 -0
  181. package/src/ws/ws-protocol.ts +76 -0
  182. package/src/ws/ws-transport-configurable.ts +123 -0
  183. package/src/ws/ws-transport.ts +42 -0
@@ -0,0 +1,66 @@
1
+ import React, { useMemo } from 'react';
2
+ import type { TPermissionMode } from '@robota-sdk/agent-core';
3
+ import type { IStatusLineCommandSettings } from '@robota-sdk/agent-framework';
4
+ import { useTuiCliAdapter } from './tui-cli-adapter-context.js';
5
+ import StatusBar from './StatusBar.js';
6
+
7
+ interface IProps {
8
+ cwd: string;
9
+ permissionMode: TPermissionMode;
10
+ modelId?: string;
11
+ providerType?: string | undefined;
12
+ sessionId: string;
13
+ isThinking: boolean;
14
+ activeToolCount: number;
15
+ activeBackgroundTaskCount: number;
16
+ hasPendingPrompt: boolean;
17
+ contextState: { percentage: number; usedTokens: number; maxTokens: number };
18
+ sessionName?: string;
19
+ settings: IStatusLineCommandSettings;
20
+ activeAgentLabel?: string;
21
+ }
22
+
23
+ export default function SessionStatusBar({
24
+ cwd,
25
+ permissionMode,
26
+ modelId,
27
+ providerType,
28
+ sessionId,
29
+ isThinking,
30
+ activeToolCount,
31
+ activeBackgroundTaskCount,
32
+ hasPendingPrompt,
33
+ contextState,
34
+ sessionName,
35
+ settings,
36
+ activeAgentLabel,
37
+ }: IProps): React.ReactElement | null {
38
+ const cliAdapter = useTuiCliAdapter();
39
+ const gitBranch = useMemo(() => cliAdapter.getGitBranch(cwd), [cliAdapter, cwd]);
40
+ const providerDisplayName = useMemo(
41
+ () =>
42
+ providerType !== undefined ? cliAdapter.getProviderDisplayName(providerType) : undefined,
43
+ [cliAdapter, providerType],
44
+ );
45
+ if (!settings.enabled) return null;
46
+
47
+ return (
48
+ <StatusBar
49
+ permissionMode={permissionMode}
50
+ modelName={modelId ?? ''}
51
+ providerDisplayName={providerDisplayName}
52
+ sessionId={sessionId}
53
+ isThinking={isThinking}
54
+ activeToolCount={activeToolCount}
55
+ activeBackgroundTaskCount={activeBackgroundTaskCount}
56
+ hasPendingPrompt={hasPendingPrompt}
57
+ contextPercentage={contextState.percentage}
58
+ contextUsedTokens={contextState.usedTokens}
59
+ contextMaxTokens={contextState.maxTokens}
60
+ sessionName={sessionName}
61
+ gitBranch={gitBranch}
62
+ showGitBranch={settings.gitBranch}
63
+ activeAgentLabel={activeAgentLabel}
64
+ />
65
+ );
66
+ }
@@ -0,0 +1,110 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Box, Text, useStdout } from 'ink';
3
+ import type { ICommand } from '@robota-sdk/agent-framework';
4
+
5
+ interface IProps {
6
+ /** Filtered list of commands to display */
7
+ commands: ICommand[];
8
+ /** Currently highlighted item index */
9
+ selectedIndex: number;
10
+ /** Whether to show the popup */
11
+ visible: boolean;
12
+ /** Whether showing subcommands (no slash prefix) */
13
+ isSubcommandMode?: boolean;
14
+ }
15
+
16
+ const MAX_VISIBLE = 8;
17
+ // border(1×2) + paddingX(1×2) consumed by outer box
18
+ const OUTER_CHROME = 4;
19
+ const MIN_ROW_WIDTH = 40;
20
+ const NAME_COL_MAX = 20;
21
+
22
+ function useRowWidth(): number {
23
+ const { stdout } = useStdout();
24
+ const measure = () => Math.max(MIN_ROW_WIDTH, (stdout.columns ?? 80) - OUTER_CHROME);
25
+ const [width, setWidth] = useState(measure);
26
+
27
+ useEffect(() => {
28
+ const onResize = () => setWidth(measure());
29
+ stdout.on('resize', onResize);
30
+ return () => {
31
+ stdout.off('resize', onResize);
32
+ };
33
+ }, [stdout]);
34
+
35
+ return width;
36
+ }
37
+
38
+ function capName(name: string, colWidth: number): string {
39
+ return name.length > colWidth ? `${name.slice(0, colWidth - 1)}…` : name.padEnd(colWidth);
40
+ }
41
+
42
+ /** Render a single command row */
43
+ function CommandRow(props: {
44
+ cmd: ICommand;
45
+ isSelected: boolean;
46
+ showSlash: boolean;
47
+ rowWidth: number;
48
+ nameColWidth: number;
49
+ }): React.ReactElement {
50
+ const { cmd, isSelected, showSlash, rowWidth, nameColWidth } = props;
51
+ const indicator = isSelected ? '▸ ' : ' ';
52
+ const nameColor = isSelected ? 'cyan' : undefined;
53
+ const dimmed = !isSelected;
54
+ const displayLabel = cmd.displayName ?? cmd.name;
55
+ const namePart = capName(displayLabel, nameColWidth);
56
+ const text = showSlash
57
+ ? `${indicator}/${namePart} ${cmd.description ?? ''}`
58
+ : `${indicator}${namePart} ${cmd.description ?? ''}`;
59
+
60
+ return (
61
+ <Box width={rowWidth}>
62
+ <Text color={nameColor} dimColor={dimmed} wrap="truncate-end">
63
+ {text}
64
+ </Text>
65
+ </Box>
66
+ );
67
+ }
68
+
69
+ /** Autocomplete popup showing matching slash commands */
70
+ export default function SlashAutocomplete({
71
+ commands,
72
+ selectedIndex,
73
+ visible,
74
+ isSubcommandMode,
75
+ }: IProps): React.ReactElement | null {
76
+ const rowWidth = useRowWidth();
77
+
78
+ if (!visible || commands.length === 0) return null;
79
+
80
+ const scrollOffset = computeScrollOffset(selectedIndex, commands.length);
81
+ const visibleCommands = commands.slice(scrollOffset, scrollOffset + MAX_VISIBLE);
82
+
83
+ const nameColWidth = Math.min(
84
+ NAME_COL_MAX,
85
+ Math.max(...visibleCommands.map((c) => (c.displayName ?? c.name).length)),
86
+ );
87
+
88
+ return (
89
+ <Box flexDirection="column" borderStyle="round" borderColor="gray" paddingX={1}>
90
+ {visibleCommands.map((cmd, i) => (
91
+ <CommandRow
92
+ key={cmd.name}
93
+ cmd={cmd}
94
+ isSelected={scrollOffset + i === selectedIndex}
95
+ showSlash={!isSubcommandMode}
96
+ rowWidth={rowWidth}
97
+ nameColWidth={nameColWidth}
98
+ />
99
+ ))}
100
+ </Box>
101
+ );
102
+ }
103
+
104
+ /** Compute scroll offset to keep selectedIndex visible */
105
+ function computeScrollOffset(selectedIndex: number, total: number): number {
106
+ if (total <= MAX_VISIBLE) return 0;
107
+ if (selectedIndex < MAX_VISIBLE) return 0;
108
+ const maxOffset = total - MAX_VISIBLE;
109
+ return Math.min(selectedIndex - MAX_VISIBLE + 1, maxOffset);
110
+ }
@@ -0,0 +1,213 @@
1
+ import React from 'react';
2
+ import { Box, Text } from 'ink';
3
+ import type { TPermissionMode } from '@robota-sdk/agent-core';
4
+ import { formatTokenCount } from '@robota-sdk/agent-core';
5
+ import { formatStatusActivity } from './status-activity.js';
6
+
7
+ /** Threshold boundaries for context percentage color coding */
8
+ const CONTEXT_YELLOW_THRESHOLD = 70;
9
+ const CONTEXT_RED_THRESHOLD = 90;
10
+
11
+ interface IProps {
12
+ permissionMode: TPermissionMode;
13
+ modelName: string;
14
+ providerDisplayName?: string | undefined;
15
+ sessionId: string;
16
+ isThinking: boolean;
17
+ activeToolCount?: number;
18
+ activeBackgroundTaskCount?: number;
19
+ hasPendingPrompt?: boolean;
20
+ contextPercentage: number;
21
+ contextUsedTokens: number;
22
+ contextMaxTokens: number;
23
+ sessionName?: string;
24
+ gitBranch?: string;
25
+ showGitBranch?: boolean;
26
+ activeAgentLabel?: string;
27
+ }
28
+
29
+ interface IStatusLeftProps {
30
+ permissionMode: TPermissionMode;
31
+ modelName: string;
32
+ providerDisplayName?: string | undefined;
33
+ isThinking: boolean;
34
+ activeToolCount: number;
35
+ activeBackgroundTaskCount: number;
36
+ hasPendingPrompt: boolean;
37
+ contextPercentage: number;
38
+ contextUsedTokens: number;
39
+ contextMaxTokens: number;
40
+ sessionName?: string;
41
+ gitBranch?: string;
42
+ showGitBranch: boolean;
43
+ }
44
+
45
+ /** Return the color for the context percentage indicator */
46
+ function getContextColor(percentage: number): string {
47
+ if (percentage >= CONTEXT_RED_THRESHOLD) return 'red';
48
+ if (percentage >= CONTEXT_YELLOW_THRESHOLD) return 'yellow';
49
+ return 'green';
50
+ }
51
+
52
+ function StatusActivityText({
53
+ isThinking,
54
+ activeToolCount,
55
+ activeBackgroundTaskCount,
56
+ hasPendingPrompt,
57
+ }: Pick<
58
+ IStatusLeftProps,
59
+ 'isThinking' | 'activeToolCount' | 'activeBackgroundTaskCount' | 'hasPendingPrompt'
60
+ >): React.ReactElement {
61
+ const activity = formatStatusActivity({
62
+ isThinking,
63
+ activeToolCount,
64
+ activeBackgroundTaskCount,
65
+ hasPendingPrompt,
66
+ });
67
+
68
+ return (
69
+ <Text color={activity.color} bold={activity.kind !== 'idle'}>
70
+ {activity.text}
71
+ </Text>
72
+ );
73
+ }
74
+
75
+ function ContextText({
76
+ percentage,
77
+ usedTokens,
78
+ maxTokens,
79
+ }: {
80
+ percentage: number;
81
+ usedTokens: number;
82
+ maxTokens: number;
83
+ }): React.ReactElement {
84
+ return (
85
+ <Text color={getContextColor(percentage)}>
86
+ Context: {Math.round(percentage)}% ({formatTokenCount(usedTokens)}/
87
+ {formatTokenCount(maxTokens)})
88
+ </Text>
89
+ );
90
+ }
91
+
92
+ function ModeText({ permissionMode }: { permissionMode: TPermissionMode }): React.ReactElement {
93
+ return (
94
+ <>
95
+ <Text color="cyan" bold>
96
+ Mode:
97
+ </Text>{' '}
98
+ <Text>{permissionMode}</Text>
99
+ </>
100
+ );
101
+ }
102
+
103
+ function shouldShowPermissionMode(permissionMode: TPermissionMode): boolean {
104
+ return permissionMode !== 'default';
105
+ }
106
+
107
+ function ProviderText({
108
+ modelName,
109
+ providerDisplayName,
110
+ }: {
111
+ modelName: string;
112
+ providerDisplayName?: string | undefined;
113
+ }): React.ReactElement {
114
+ if (providerDisplayName !== undefined) {
115
+ return (
116
+ <Text dimColor>
117
+ {providerDisplayName} {modelName}
118
+ </Text>
119
+ );
120
+ }
121
+ return <Text dimColor>{modelName}</Text>;
122
+ }
123
+
124
+ function StatusLeft(props: IStatusLeftProps): React.ReactElement {
125
+ const shouldShowGitBranch =
126
+ props.showGitBranch && props.gitBranch !== undefined && props.gitBranch.length > 0;
127
+ const showPermissionMode = shouldShowPermissionMode(props.permissionMode);
128
+ return (
129
+ <Text>
130
+ <StatusActivityText
131
+ isThinking={props.isThinking}
132
+ activeToolCount={props.activeToolCount}
133
+ activeBackgroundTaskCount={props.activeBackgroundTaskCount}
134
+ hasPendingPrompt={props.hasPendingPrompt}
135
+ />
136
+ {showPermissionMode && (
137
+ <>
138
+ {' | '}
139
+ <ModeText permissionMode={props.permissionMode} />
140
+ </>
141
+ )}
142
+ {props.sessionName && (
143
+ <>
144
+ {' | '}
145
+ <Text color="magenta">{props.sessionName}</Text>
146
+ </>
147
+ )}
148
+ {shouldShowGitBranch && (
149
+ <>
150
+ {' | '}
151
+ <Text dimColor>git: {props.gitBranch}</Text>
152
+ </>
153
+ )}
154
+ {' | '}
155
+ <ProviderText modelName={props.modelName} providerDisplayName={props.providerDisplayName} />
156
+ {' | '}
157
+ <ContextText
158
+ percentage={props.contextPercentage}
159
+ usedTokens={props.contextUsedTokens}
160
+ maxTokens={props.contextMaxTokens}
161
+ />
162
+ </Text>
163
+ );
164
+ }
165
+
166
+ export default function StatusBar({
167
+ permissionMode,
168
+ modelName,
169
+ providerDisplayName,
170
+ sessionId: _sessionId,
171
+ isThinking,
172
+ activeToolCount = 0,
173
+ activeBackgroundTaskCount = 0,
174
+ hasPendingPrompt = false,
175
+ contextPercentage,
176
+ contextUsedTokens,
177
+ contextMaxTokens,
178
+ sessionName,
179
+ gitBranch,
180
+ showGitBranch = true,
181
+ activeAgentLabel,
182
+ }: IProps): React.ReactElement {
183
+ return (
184
+ <Box
185
+ borderStyle="single"
186
+ borderColor="gray"
187
+ paddingLeft={1}
188
+ paddingRight={1}
189
+ justifyContent="space-between"
190
+ >
191
+ <StatusLeft
192
+ permissionMode={permissionMode}
193
+ modelName={modelName}
194
+ providerDisplayName={providerDisplayName}
195
+ isThinking={isThinking}
196
+ activeToolCount={activeToolCount}
197
+ activeBackgroundTaskCount={activeBackgroundTaskCount}
198
+ hasPendingPrompt={hasPendingPrompt}
199
+ contextPercentage={contextPercentage}
200
+ contextUsedTokens={contextUsedTokens}
201
+ contextMaxTokens={contextMaxTokens}
202
+ sessionName={sessionName}
203
+ gitBranch={gitBranch}
204
+ showGitBranch={showGitBranch}
205
+ />
206
+ {activeAgentLabel !== undefined && (
207
+ <Text color="yellow" bold>
208
+ [{activeAgentLabel}]
209
+ </Text>
210
+ )}
211
+ </Box>
212
+ );
213
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Streaming indicator — shows real-time tool execution and AI response text.
3
+ * Displayed during session.run() execution.
4
+ */
5
+
6
+ import React from 'react';
7
+ import { Box, Text } from 'ink';
8
+ import type { IToolState } from '@robota-sdk/agent-framework';
9
+ import { renderMarkdown } from './render-markdown.js';
10
+ import ToolDiffBlock from './ToolDiffBlock.js';
11
+
12
+ function getToolStyle(t: IToolState): {
13
+ color: string;
14
+ icon: string;
15
+ strikethrough: boolean;
16
+ } {
17
+ if (t.isRunning) return { color: 'yellow', icon: '⟳', strikethrough: false };
18
+ if (t.result === 'error') return { color: 'red', icon: '✗', strikethrough: true };
19
+ if (t.result === 'denied') return { color: 'yellowBright', icon: '⊘', strikethrough: true };
20
+ return { color: 'green', icon: '✓', strikethrough: false };
21
+ }
22
+
23
+ interface IProps {
24
+ text: string;
25
+ activeTools: IToolState[];
26
+ isThinking?: boolean;
27
+ }
28
+
29
+ function renderThinkingFallback(isThinking: boolean): React.ReactElement {
30
+ if (!isThinking) return <></>;
31
+ return (
32
+ <Box marginBottom={1}>
33
+ <Text color="yellow">Thinking...</Text>
34
+ </Box>
35
+ );
36
+ }
37
+
38
+ function renderTools(activeTools: IToolState[]): React.ReactElement {
39
+ return (
40
+ <Box flexDirection="column" marginBottom={1}>
41
+ <Text color="white" bold>
42
+ Tools:
43
+ </Text>
44
+ <Text> </Text>
45
+ {activeTools.map((t, i) => {
46
+ const { color, icon, strikethrough } = getToolStyle(t);
47
+ return (
48
+ <Box key={`${t.toolName}-${i}`} flexDirection="column">
49
+ <Text color={color} strikethrough={strikethrough}>
50
+ {' '}
51
+ {icon} {t.toolName}({t.firstArg})
52
+ </Text>
53
+ {t.diffLines && t.diffLines.length > 0 && (
54
+ <ToolDiffBlock file={t.diffFile} lines={t.diffLines} />
55
+ )}
56
+ </Box>
57
+ );
58
+ })}
59
+ </Box>
60
+ );
61
+ }
62
+
63
+ export default function StreamingIndicator({
64
+ text,
65
+ activeTools,
66
+ isThinking = false,
67
+ }: IProps): React.ReactElement {
68
+ const hasTools = activeTools.length > 0;
69
+ const hasText = text.length > 0;
70
+
71
+ if (!hasTools && !hasText) {
72
+ return renderThinkingFallback(isThinking);
73
+ }
74
+
75
+ return (
76
+ <Box flexDirection="column">
77
+ {hasTools && renderTools(activeTools)}
78
+ {hasText && (
79
+ <Box flexDirection="column" marginBottom={1}>
80
+ <Text color="cyan" bold>
81
+ Robota:
82
+ </Text>
83
+ <Text> </Text>
84
+ <Box marginLeft={2}>
85
+ <Text wrap="wrap">{renderMarkdown(text)}</Text>
86
+ </Box>
87
+ </Box>
88
+ )}
89
+ </Box>
90
+ );
91
+ }
@@ -0,0 +1,80 @@
1
+ import React, { useState, useRef, useCallback } from 'react';
2
+ import { Box, Text, useInput } from 'ink';
3
+ import {
4
+ applyTextPromptInput,
5
+ createTextPromptFlowState,
6
+ getTextPromptInputAction,
7
+ type ITextPromptFlowState,
8
+ type TTextPromptInputAction,
9
+ } from './flows/text-prompt-flow.js';
10
+
11
+ interface IProps {
12
+ title: string;
13
+ description?: string;
14
+ placeholder?: string;
15
+ onSubmit: (value: string) => void;
16
+ onCancel: () => void;
17
+ validate?: (value: string) => string | undefined;
18
+ allowEmpty?: boolean;
19
+ masked?: boolean;
20
+ }
21
+
22
+ export default function TextPrompt({
23
+ title,
24
+ description,
25
+ placeholder,
26
+ onSubmit,
27
+ onCancel,
28
+ validate,
29
+ allowEmpty = false,
30
+ masked = false,
31
+ }: IProps): React.ReactElement {
32
+ const [state, setState] = useState<ITextPromptFlowState>(() => createTextPromptFlowState());
33
+ const stateRef = useRef(state);
34
+ const applyAction = useCallback(
35
+ (action: TTextPromptInputAction): void => {
36
+ const result = applyTextPromptInput(stateRef.current, action, { allowEmpty, validate });
37
+ stateRef.current = result.state;
38
+ setState(result.state);
39
+ if (result.effect.type === 'cancel') {
40
+ onCancel();
41
+ } else if (result.effect.type === 'submit') {
42
+ onSubmit(result.effect.value);
43
+ }
44
+ },
45
+ [allowEmpty, validate, onCancel, onSubmit],
46
+ );
47
+
48
+ useInput((input, key) => {
49
+ const action = getTextPromptInputAction(input, key);
50
+ if (action !== undefined) applyAction(action);
51
+ });
52
+
53
+ return (
54
+ <Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
55
+ <Text color="yellow" bold>
56
+ {title}
57
+ </Text>
58
+ <PromptDescription description={description} />
59
+ <Box marginTop={1}>
60
+ <Text color="cyan">&gt; </Text>
61
+ {state.value ? (
62
+ <Text>{masked ? '*'.repeat(state.value.length) : state.value}</Text>
63
+ ) : placeholder ? (
64
+ <Text dimColor>{placeholder}</Text>
65
+ ) : null}
66
+ <Text color="cyan">█</Text>
67
+ </Box>
68
+ {state.error && <Text color="red">{state.error}</Text>}
69
+ <Text dimColor> Enter Submit Esc Cancel</Text>
70
+ </Box>
71
+ );
72
+ }
73
+
74
+ function PromptDescription({ description }: { description?: string }): React.ReactElement | null {
75
+ if (description === undefined || description.length === 0) {
76
+ return null;
77
+ }
78
+
79
+ return <Text dimColor>{description}</Text>;
80
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { Box, Text } from 'ink';
3
+ import type { ICommandOutputInput } from './command-output-summary.js';
4
+ import { formatCommandOutputSummary } from './command-output-summary.js';
5
+
6
+ interface IProps {
7
+ tool: ICommandOutputInput;
8
+ }
9
+
10
+ export default function ToolCommandOutput({ tool }: IProps): React.ReactElement | null {
11
+ const summary = formatCommandOutputSummary(tool);
12
+ if (!summary) return null;
13
+ if (
14
+ summary.statusLabel === 'ok' &&
15
+ summary.previewLines.length === 0 &&
16
+ !summary.transcriptHint
17
+ ) {
18
+ return null;
19
+ }
20
+ const color = summary.status === 'error' ? 'red' : 'white';
21
+
22
+ return (
23
+ <Box flexDirection="column" marginLeft={4}>
24
+ {summary.statusLabel !== 'ok' && (
25
+ <Text color={color} dimColor>
26
+ {summary.statusLabel}
27
+ </Text>
28
+ )}
29
+ {summary.previewLines.map((line, index) => (
30
+ <Text key={`${line}-${index}`} color={color} dimColor>
31
+ {line}
32
+ </Text>
33
+ ))}
34
+ {summary.transcriptHint && <Text dimColor>{summary.transcriptHint}</Text>}
35
+ </Box>
36
+ );
37
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { Box, Text } from 'ink';
3
+ import { buildToolDiffSummary } from './utils/tool-diff-summary.js';
4
+ import { renderMarkdown } from './render-markdown.js';
5
+ import type { IDiffLine } from './utils/edit-diff.js';
6
+
7
+ interface IProps {
8
+ file?: string;
9
+ lines: readonly IDiffLine[];
10
+ }
11
+
12
+ export default function ToolDiffBlock({ file, lines }: IProps): React.ReactElement {
13
+ const summary = buildToolDiffSummary({ file, lines });
14
+
15
+ return (
16
+ <Box flexDirection="column" marginLeft={4}>
17
+ {summary.file && (
18
+ <Text color="white" dimColor>
19
+ │ {summary.file}
20
+ </Text>
21
+ )}
22
+ <Text>{renderMarkdown(summary.markdown)}</Text>
23
+ {summary.truncated && (
24
+ <Text color="white" dimColor>
25
+ │ ... and {summary.remainingLineCount} more lines
26
+ </Text>
27
+ )}
28
+ </Box>
29
+ );
30
+ }