@robota-sdk/agent-transport 3.0.0-beta.74 → 3.0.0-beta.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/node/headless/index.cjs +1 -1
- package/dist/node/headless/index.d.ts +1 -1
- package/dist/node/headless/index.js +1 -1
- package/dist/node/headless-OnpVk4-k.cjs +15 -0
- package/dist/node/{headless-D02zUEGh.js → headless-mRYilLfC.js} +2 -2
- package/dist/node/{headless-D02zUEGh.js.map → headless-mRYilLfC.js.map} +1 -1
- package/dist/node/{index-DE3-dHqw.d.ts → index-CYl7ksS6.d.ts} +12 -2
- package/dist/node/{index-DE3-dHqw.d.ts.map → index-CYl7ksS6.d.ts.map} +1 -1
- package/dist/node/{index-WKTgvhlg.d.ts → index-E8Gx4-lc.d.ts} +12 -2
- package/dist/node/{index-WKTgvhlg.d.ts.map → index-E8Gx4-lc.d.ts.map} +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.ts +2 -7
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +7 -75
- package/src/headless/HeadlessInteractionChannel.ts +21 -1
- package/src/index.ts +1 -5
- package/src/transport-registry.ts +0 -9
- package/dist/node/headless-BeHAOlIM.cjs +0 -15
- package/dist/node/http/index.cjs +0 -1
- package/dist/node/http/index.d.ts +0 -2
- package/dist/node/http/index.js +0 -1
- package/dist/node/http-2Jiuflc1.js +0 -2
- package/dist/node/http-2Jiuflc1.js.map +0 -1
- package/dist/node/http-CBAvefLw.cjs +0 -1
- package/dist/node/index-BQLN_Lc9.d.ts +0 -78
- package/dist/node/index-BQLN_Lc9.d.ts.map +0 -1
- package/dist/node/index-BnAGE-u9.d.ts +0 -33
- package/dist/node/index-BnAGE-u9.d.ts.map +0 -1
- package/dist/node/index-BrQ4gGw0.d.ts +0 -213
- package/dist/node/index-BrQ4gGw0.d.ts.map +0 -1
- package/dist/node/index-CoeBF21y.d.ts +0 -213
- package/dist/node/index-CoeBF21y.d.ts.map +0 -1
- package/dist/node/index-DHt-2VQ-.d.ts +0 -46
- package/dist/node/index-DHt-2VQ-.d.ts.map +0 -1
- package/dist/node/index-DMwKN5Le.d.ts +0 -33
- package/dist/node/index-DMwKN5Le.d.ts.map +0 -1
- package/dist/node/index-IvYaYY6v.d.ts +0 -78
- package/dist/node/index-IvYaYY6v.d.ts.map +0 -1
- package/dist/node/index-c0M42fsA.d.ts +0 -46
- package/dist/node/index-c0M42fsA.d.ts.map +0 -1
- package/dist/node/mcp/index.cjs +0 -1
- package/dist/node/mcp/index.d.ts +0 -2
- package/dist/node/mcp/index.js +0 -1
- package/dist/node/mcp-BOglBJNy.cjs +0 -1
- package/dist/node/mcp-D3BBVK7C.js +0 -2
- package/dist/node/mcp-D3BBVK7C.js.map +0 -1
- package/dist/node/rolldown-runtime-CMqjfN_6.cjs +0 -1
- package/dist/node/tui/index.cjs +0 -1
- package/dist/node/tui/index.d.ts +0 -2
- package/dist/node/tui/index.js +0 -1
- package/dist/node/tui-Btb1q88j.js +0 -25
- package/dist/node/tui-Btb1q88j.js.map +0 -1
- package/dist/node/tui-SbUT7Zlt.cjs +0 -24
- package/dist/node/ws/index.cjs +0 -1
- package/dist/node/ws/index.d.ts +0 -2
- package/dist/node/ws/index.js +0 -1
- package/dist/node/ws-Dc2RUwVs.js +0 -2
- package/dist/node/ws-Dc2RUwVs.js.map +0 -1
- package/dist/node/ws-QNMQn5kg.cjs +0 -1
- package/src/http/__tests__/http-transport.test.ts +0 -55
- package/src/http/__tests__/routes.test.ts +0 -168
- package/src/http/http-transport.ts +0 -41
- package/src/http/index.ts +0 -4
- package/src/http/routes.ts +0 -152
- package/src/mcp/__tests__/mcp-server.test.ts +0 -66
- package/src/mcp/__tests__/mcp-transport.test.ts +0 -46
- package/src/mcp/index.ts +0 -4
- package/src/mcp/mcp-server.ts +0 -163
- package/src/mcp/mcp-transport.ts +0 -48
- package/src/tui/App.tsx +0 -488
- package/src/tui/BackgroundTaskPanel.tsx +0 -36
- package/src/tui/CjkTextInput.tsx +0 -199
- package/src/tui/ConfirmPrompt.tsx +0 -70
- package/src/tui/ContextWarningBanner.tsx +0 -34
- package/src/tui/ExecutionWorkspaceDetailPane.tsx +0 -64
- package/src/tui/ExecutionWorkspaceSwitcher.tsx +0 -187
- package/src/tui/InputArea.tsx +0 -310
- package/src/tui/InteractivePrompt.tsx +0 -59
- package/src/tui/ListPicker.tsx +0 -95
- package/src/tui/MenuSelect.tsx +0 -104
- package/src/tui/MessageList.tsx +0 -284
- package/src/tui/PermissionPrompt.tsx +0 -86
- package/src/tui/PluginTUI.tsx +0 -258
- package/src/tui/SessionPicker.tsx +0 -68
- package/src/tui/SessionStatusBar.tsx +0 -70
- package/src/tui/SlashAutocomplete.tsx +0 -110
- package/src/tui/StatusBar.tsx +0 -209
- package/src/tui/StreamingIndicator.tsx +0 -93
- package/src/tui/TextPrompt.tsx +0 -81
- package/src/tui/ToolCommandOutput.tsx +0 -39
- package/src/tui/ToolDiffBlock.tsx +0 -32
- package/src/tui/TransportTUI.tsx +0 -117
- package/src/tui/TuiInteractionChannel.ts +0 -483
- package/src/tui/UpdateNotice.tsx +0 -14
- package/src/tui/UsageSummaryEntry.tsx +0 -39
- package/src/tui/WaveText.tsx +0 -44
- package/src/tui/__tests__/InteractivePrompt.test.tsx +0 -82
- package/src/tui/__tests__/ListPicker.test.tsx +0 -159
- package/src/tui/__tests__/MenuSelect.test.tsx +0 -103
- package/src/tui/__tests__/PluginTUI.test.tsx +0 -167
- package/src/tui/__tests__/SlashAutocomplete.test.tsx +0 -140
- package/src/tui/__tests__/TextPrompt.test.tsx +0 -98
- package/src/tui/__tests__/TuiInteractionChannel.display-contract.test.ts +0 -239
- package/src/tui/__tests__/TuiInteractionChannel.lifecycle.test.ts +0 -297
- package/src/tui/__tests__/TuiInteractionChannel.requestAction.test.ts +0 -124
- package/src/tui/__tests__/UpdateNotice.test.tsx +0 -15
- package/src/tui/__tests__/abort-after-permission.test.tsx +0 -169
- package/src/tui/__tests__/abort-streaming-e2e.test.tsx +0 -183
- package/src/tui/__tests__/background-task-panel.test.tsx +0 -53
- package/src/tui/__tests__/background-task-row-format.test.ts +0 -59
- package/src/tui/__tests__/channel-factory-integration.test.ts +0 -138
- package/src/tui/__tests__/cjk-text-input-flow.test.ts +0 -109
- package/src/tui/__tests__/cjk-text-input.test.ts +0 -191
- package/src/tui/__tests__/command-effect-handler.test.ts +0 -127
- package/src/tui/__tests__/command-output-summary.test.ts +0 -95
- package/src/tui/__tests__/compact-event-bridge.test.ts +0 -20
- package/src/tui/__tests__/confirm-permission-flow.test.ts +0 -130
- package/src/tui/__tests__/confirm-prompt.test.tsx +0 -87
- package/src/tui/__tests__/execution-workspace-switcher.test.tsx +0 -110
- package/src/tui/__tests__/execution-workspace-view-model.test.ts +0 -93
- package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +0 -125
- package/src/tui/__tests__/input-area-flow.test.ts +0 -164
- package/src/tui/__tests__/message-list-rendering.test.tsx +0 -353
- package/src/tui/__tests__/prompt-queue.test.tsx +0 -255
- package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +0 -233
- package/src/tui/__tests__/pty/pty-driver.ts +0 -135
- package/src/tui/__tests__/pty/tui-pty.ptytest.ts +0 -61
- package/src/tui/__tests__/render-channel-options.test.ts +0 -32
- package/src/tui/__tests__/render-markdown.test.ts +0 -72
- package/src/tui/__tests__/selection-flow.test.ts +0 -61
- package/src/tui/__tests__/session-init-poller.test.ts +0 -102
- package/src/tui/__tests__/session-naming.test.ts +0 -64
- package/src/tui/__tests__/session-switch-channel.test.tsx +0 -307
- package/src/tui/__tests__/slash-routing-effects.test.ts +0 -228
- package/src/tui/__tests__/status-activity.test.ts +0 -71
- package/src/tui/__tests__/status-bar.test.tsx +0 -158
- package/src/tui/__tests__/streaming-indicator.test.tsx +0 -137
- package/src/tui/__tests__/text-prompt-flow.test.ts +0 -77
- package/src/tui/__tests__/tui-channel-init-failure.test.ts +0 -57
- package/src/tui/__tests__/tui-state-manager.test.ts +0 -401
- package/src/tui/background-task-row-format.ts +0 -53
- package/src/tui/command-interaction.ts +0 -9
- package/src/tui/command-output-summary.ts +0 -122
- package/src/tui/create-default-tui-cli-adapter.ts +0 -41
- package/src/tui/execution-workspace-view-model.ts +0 -123
- package/src/tui/flows/cjk-text-input-flow.ts +0 -285
- package/src/tui/flows/confirm-prompt-flow.ts +0 -45
- package/src/tui/flows/input-area-flow.ts +0 -189
- package/src/tui/flows/permission-prompt-flow.ts +0 -85
- package/src/tui/flows/selection-flow.ts +0 -126
- package/src/tui/flows/session-init-poller.ts +0 -77
- package/src/tui/flows/text-prompt-flow.ts +0 -98
- package/src/tui/hooks/command-effect-handler.ts +0 -97
- package/src/tui/hooks/command-effect-queue.ts +0 -39
- package/src/tui/hooks/side-effects-types.ts +0 -35
- package/src/tui/hooks/useAutocomplete.ts +0 -87
- package/src/tui/hooks/usePluginCallbacks.ts +0 -31
- package/src/tui/hooks/usePluginScreenData.ts +0 -85
- package/src/tui/hooks/useSideEffects.ts +0 -175
- package/src/tui/hooks/useSlashRouting.ts +0 -118
- package/src/tui/hooks/useStatusLineSettings.ts +0 -37
- package/src/tui/hooks/useTuiChannel.ts +0 -95
- package/src/tui/index.ts +0 -14
- package/src/tui/interactions/CommandConfirm.tsx +0 -36
- package/src/tui/interactions/CommandPicker.tsx +0 -77
- package/src/tui/interactions/__tests__/CommandConfirm.test.tsx +0 -124
- package/src/tui/interactions/__tests__/CommandPicker.test.tsx +0 -138
- package/src/tui/plugin-tui-handlers.ts +0 -163
- package/src/tui/render-markdown.ts +0 -130
- package/src/tui/render.tsx +0 -117
- package/src/tui/session-naming.ts +0 -33
- package/src/tui/status-activity.ts +0 -63
- package/src/tui/tui-cli-adapter-context.tsx +0 -13
- package/src/tui/tui-cli-adapter.ts +0 -25
- package/src/tui/tui-state-manager.ts +0 -226
- package/src/tui/tui-transport.ts +0 -35
- package/src/tui/types.ts +0 -15
- package/src/tui/utils/__tests__/edit-diff.test.ts +0 -426
- package/src/tui/utils/__tests__/paste-detection.test.ts +0 -116
- package/src/tui/utils/__tests__/paste-labels.test.ts +0 -46
- package/src/tui/utils/__tests__/tool-call-extractor.test.ts +0 -227
- package/src/tui/utils/__tests__/tool-diff-summary.test.ts +0 -104
- package/src/tui/utils/edit-diff.ts +0 -153
- package/src/tui/utils/paste-labels.ts +0 -9
- package/src/tui/utils/tool-call-extractor.ts +0 -92
- package/src/tui/utils/tool-diff-summary.ts +0 -75
- package/src/ws/__tests__/ws-handler.test.ts +0 -409
- package/src/ws/__tests__/ws-transport.test.ts +0 -53
- package/src/ws/index.ts +0 -13
- package/src/ws/ws-background-messages.ts +0 -170
- package/src/ws/ws-handler.ts +0 -280
- package/src/ws/ws-protocol.ts +0 -78
- package/src/ws/ws-transport-configurable.ts +0 -128
- package/src/ws/ws-transport.ts +0 -42
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import StatusBar from './StatusBar.js';
|
|
4
|
-
import { useTuiCliAdapter } from './tui-cli-adapter-context.js';
|
|
5
|
-
|
|
6
|
-
import type { TPermissionMode } from '@robota-sdk/agent-core';
|
|
7
|
-
import type { IStatusLineCommandSettings } from '@robota-sdk/agent-interface-transport';
|
|
8
|
-
|
|
9
|
-
interface IProps {
|
|
10
|
-
cwd: string;
|
|
11
|
-
permissionMode: TPermissionMode;
|
|
12
|
-
modelId?: string;
|
|
13
|
-
providerType?: string | undefined;
|
|
14
|
-
sessionId: string;
|
|
15
|
-
isThinking: boolean;
|
|
16
|
-
activeToolCount: number;
|
|
17
|
-
activeBackgroundTaskCount: number;
|
|
18
|
-
hasPendingPrompt: boolean;
|
|
19
|
-
contextState: { percentage: number; usedTokens: number; maxTokens: number };
|
|
20
|
-
sessionName?: string;
|
|
21
|
-
settings: IStatusLineCommandSettings;
|
|
22
|
-
activeAgentLabel?: string;
|
|
23
|
-
gitRefreshToken?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default function SessionStatusBar({
|
|
27
|
-
cwd,
|
|
28
|
-
permissionMode,
|
|
29
|
-
modelId,
|
|
30
|
-
providerType,
|
|
31
|
-
sessionId,
|
|
32
|
-
isThinking,
|
|
33
|
-
activeToolCount,
|
|
34
|
-
activeBackgroundTaskCount,
|
|
35
|
-
hasPendingPrompt,
|
|
36
|
-
contextState,
|
|
37
|
-
sessionName,
|
|
38
|
-
settings,
|
|
39
|
-
activeAgentLabel,
|
|
40
|
-
gitRefreshToken,
|
|
41
|
-
}: IProps): React.ReactElement | null {
|
|
42
|
-
const cliAdapter = useTuiCliAdapter();
|
|
43
|
-
const gitBranch = useMemo(() => cliAdapter.getGitBranch(cwd), [cliAdapter, cwd, gitRefreshToken]);
|
|
44
|
-
const providerDisplayName = useMemo(
|
|
45
|
-
() =>
|
|
46
|
-
providerType !== undefined ? cliAdapter.getProviderDisplayName(providerType) : undefined,
|
|
47
|
-
[cliAdapter, providerType],
|
|
48
|
-
);
|
|
49
|
-
if (!settings.enabled) return null;
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<StatusBar
|
|
53
|
-
permissionMode={permissionMode}
|
|
54
|
-
modelName={modelId ?? ''}
|
|
55
|
-
providerDisplayName={providerDisplayName}
|
|
56
|
-
sessionId={sessionId}
|
|
57
|
-
isThinking={isThinking}
|
|
58
|
-
activeToolCount={activeToolCount}
|
|
59
|
-
activeBackgroundTaskCount={activeBackgroundTaskCount}
|
|
60
|
-
hasPendingPrompt={hasPendingPrompt}
|
|
61
|
-
contextPercentage={contextState.percentage}
|
|
62
|
-
contextUsedTokens={contextState.usedTokens}
|
|
63
|
-
contextMaxTokens={contextState.maxTokens}
|
|
64
|
-
sessionName={sessionName}
|
|
65
|
-
gitBranch={gitBranch}
|
|
66
|
-
showGitBranch={settings.gitBranch}
|
|
67
|
-
activeAgentLabel={activeAgentLabel}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Box, Text, useStdout } from 'ink';
|
|
2
|
-
import React, { useState, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
import type { ICommand } from '@robota-sdk/agent-interface-transport';
|
|
5
|
-
|
|
6
|
-
interface IProps {
|
|
7
|
-
/** Filtered list of commands to display */
|
|
8
|
-
commands: ICommand[];
|
|
9
|
-
/** Currently highlighted item index */
|
|
10
|
-
selectedIndex: number;
|
|
11
|
-
/** Whether to show the popup */
|
|
12
|
-
visible: boolean;
|
|
13
|
-
/** Whether showing subcommands (no slash prefix) */
|
|
14
|
-
isSubcommandMode?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const MAX_VISIBLE = 8;
|
|
18
|
-
// border(1×2) + paddingX(1×2) consumed by outer box
|
|
19
|
-
const OUTER_CHROME = 4;
|
|
20
|
-
const MIN_ROW_WIDTH = 40;
|
|
21
|
-
const NAME_COL_MAX = 20;
|
|
22
|
-
|
|
23
|
-
function useRowWidth(): number {
|
|
24
|
-
const { stdout } = useStdout();
|
|
25
|
-
const measure = (): number => Math.max(MIN_ROW_WIDTH, (stdout.columns ?? 80) - OUTER_CHROME);
|
|
26
|
-
const [width, setWidth] = useState(measure);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const onResize = (): void => setWidth(measure());
|
|
30
|
-
stdout.on('resize', onResize);
|
|
31
|
-
return () => {
|
|
32
|
-
stdout.off('resize', onResize);
|
|
33
|
-
};
|
|
34
|
-
}, [stdout]);
|
|
35
|
-
|
|
36
|
-
return width;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function capName(name: string, colWidth: number): string {
|
|
40
|
-
return name.length > colWidth ? `${name.slice(0, colWidth - 1)}…` : name.padEnd(colWidth);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Render a single command row */
|
|
44
|
-
function CommandRow(props: {
|
|
45
|
-
cmd: ICommand;
|
|
46
|
-
isSelected: boolean;
|
|
47
|
-
showSlash: boolean;
|
|
48
|
-
rowWidth: number;
|
|
49
|
-
nameColWidth: number;
|
|
50
|
-
}): React.ReactElement {
|
|
51
|
-
const { cmd, isSelected, showSlash, rowWidth, nameColWidth } = props;
|
|
52
|
-
const indicator = isSelected ? '▸ ' : ' ';
|
|
53
|
-
const nameColor = isSelected ? 'cyan' : undefined;
|
|
54
|
-
const dimmed = !isSelected;
|
|
55
|
-
const namePart = capName(cmd.name, 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.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
|
-
}
|
package/src/tui/StatusBar.tsx
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { formatTokenCount } from '@robota-sdk/agent-core';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
import { formatStatusActivity } from './status-activity.js';
|
|
6
|
-
|
|
7
|
-
import type { TPermissionMode } from '@robota-sdk/agent-core';
|
|
8
|
-
|
|
9
|
-
/** Threshold boundaries for context percentage color coding */
|
|
10
|
-
const CONTEXT_YELLOW_THRESHOLD = 70;
|
|
11
|
-
const CONTEXT_RED_THRESHOLD = 90;
|
|
12
|
-
|
|
13
|
-
interface IProps {
|
|
14
|
-
permissionMode: TPermissionMode;
|
|
15
|
-
modelName: string;
|
|
16
|
-
providerDisplayName?: string | undefined;
|
|
17
|
-
sessionId: string;
|
|
18
|
-
isThinking: boolean;
|
|
19
|
-
activeToolCount?: number;
|
|
20
|
-
activeBackgroundTaskCount?: number;
|
|
21
|
-
hasPendingPrompt?: boolean;
|
|
22
|
-
contextPercentage: number;
|
|
23
|
-
contextUsedTokens: number;
|
|
24
|
-
contextMaxTokens: number;
|
|
25
|
-
sessionName?: string;
|
|
26
|
-
gitBranch?: string;
|
|
27
|
-
showGitBranch?: boolean;
|
|
28
|
-
activeAgentLabel?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface IStatusLeftProps {
|
|
32
|
-
permissionMode: TPermissionMode;
|
|
33
|
-
modelName: string;
|
|
34
|
-
providerDisplayName?: string | undefined;
|
|
35
|
-
isThinking: boolean;
|
|
36
|
-
activeToolCount: number;
|
|
37
|
-
activeBackgroundTaskCount: number;
|
|
38
|
-
hasPendingPrompt: boolean;
|
|
39
|
-
contextPercentage: number;
|
|
40
|
-
contextUsedTokens: number;
|
|
41
|
-
contextMaxTokens: number;
|
|
42
|
-
sessionName?: string;
|
|
43
|
-
gitBranch?: string;
|
|
44
|
-
showGitBranch: boolean;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Return the color for the context percentage indicator */
|
|
48
|
-
function getContextColor(percentage: number): string {
|
|
49
|
-
if (percentage >= CONTEXT_RED_THRESHOLD) return 'red';
|
|
50
|
-
if (percentage >= CONTEXT_YELLOW_THRESHOLD) return 'yellow';
|
|
51
|
-
return 'green';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function StatusActivityText({
|
|
55
|
-
isThinking,
|
|
56
|
-
activeToolCount,
|
|
57
|
-
activeBackgroundTaskCount,
|
|
58
|
-
hasPendingPrompt,
|
|
59
|
-
}: Pick<
|
|
60
|
-
IStatusLeftProps,
|
|
61
|
-
'isThinking' | 'activeToolCount' | 'activeBackgroundTaskCount' | 'hasPendingPrompt'
|
|
62
|
-
>): React.ReactElement {
|
|
63
|
-
const activity = formatStatusActivity({
|
|
64
|
-
isThinking,
|
|
65
|
-
activeToolCount,
|
|
66
|
-
activeBackgroundTaskCount,
|
|
67
|
-
hasPendingPrompt,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<Text color={activity.color} bold={activity.kind !== 'idle'}>
|
|
72
|
-
{activity.text}
|
|
73
|
-
</Text>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function ContextText({
|
|
78
|
-
percentage,
|
|
79
|
-
usedTokens,
|
|
80
|
-
maxTokens,
|
|
81
|
-
}: {
|
|
82
|
-
percentage: number;
|
|
83
|
-
usedTokens: number;
|
|
84
|
-
maxTokens: number;
|
|
85
|
-
}): React.ReactElement {
|
|
86
|
-
return (
|
|
87
|
-
<Text color={getContextColor(percentage)}>
|
|
88
|
-
Context: {Math.round(percentage)}% ({formatTokenCount(usedTokens)}/
|
|
89
|
-
{formatTokenCount(maxTokens)} tokens)
|
|
90
|
-
</Text>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function ModeText({ permissionMode }: { permissionMode: TPermissionMode }): React.ReactElement {
|
|
95
|
-
return (
|
|
96
|
-
<>
|
|
97
|
-
<Text color="cyan" bold>
|
|
98
|
-
Mode:
|
|
99
|
-
</Text>{' '}
|
|
100
|
-
<Text>{permissionMode}</Text>
|
|
101
|
-
</>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function shouldShowPermissionMode(permissionMode: TPermissionMode): boolean {
|
|
106
|
-
return permissionMode !== 'default';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function ProviderText({
|
|
110
|
-
modelName,
|
|
111
|
-
providerDisplayName,
|
|
112
|
-
}: {
|
|
113
|
-
modelName: string;
|
|
114
|
-
providerDisplayName?: string | undefined;
|
|
115
|
-
}): React.ReactElement {
|
|
116
|
-
if (providerDisplayName !== undefined) {
|
|
117
|
-
return (
|
|
118
|
-
<Text dimColor>
|
|
119
|
-
{providerDisplayName} {modelName}
|
|
120
|
-
</Text>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
return <Text dimColor>{modelName}</Text>;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function StatusLeft(props: IStatusLeftProps): React.ReactElement {
|
|
127
|
-
const shouldShowGitBranch =
|
|
128
|
-
props.showGitBranch && props.gitBranch !== undefined && props.gitBranch.length > 0;
|
|
129
|
-
const showPermissionMode = shouldShowPermissionMode(props.permissionMode);
|
|
130
|
-
return (
|
|
131
|
-
<Text>
|
|
132
|
-
<StatusActivityText
|
|
133
|
-
isThinking={props.isThinking}
|
|
134
|
-
activeToolCount={props.activeToolCount}
|
|
135
|
-
activeBackgroundTaskCount={props.activeBackgroundTaskCount}
|
|
136
|
-
hasPendingPrompt={props.hasPendingPrompt}
|
|
137
|
-
/>
|
|
138
|
-
{showPermissionMode && (
|
|
139
|
-
<>
|
|
140
|
-
{' | '}
|
|
141
|
-
<ModeText permissionMode={props.permissionMode} />
|
|
142
|
-
</>
|
|
143
|
-
)}
|
|
144
|
-
{props.sessionName && (
|
|
145
|
-
<>
|
|
146
|
-
{' | '}
|
|
147
|
-
<Text color="magenta">{props.sessionName}</Text>
|
|
148
|
-
</>
|
|
149
|
-
)}
|
|
150
|
-
{shouldShowGitBranch && (
|
|
151
|
-
<>
|
|
152
|
-
{' | '}
|
|
153
|
-
<Text dimColor>git: {props.gitBranch}</Text>
|
|
154
|
-
</>
|
|
155
|
-
)}
|
|
156
|
-
{' | '}
|
|
157
|
-
<ProviderText modelName={props.modelName} providerDisplayName={props.providerDisplayName} />
|
|
158
|
-
{' | '}
|
|
159
|
-
<ContextText
|
|
160
|
-
percentage={props.contextPercentage}
|
|
161
|
-
usedTokens={props.contextUsedTokens}
|
|
162
|
-
maxTokens={props.contextMaxTokens}
|
|
163
|
-
/>
|
|
164
|
-
</Text>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export default function StatusBar({
|
|
169
|
-
permissionMode,
|
|
170
|
-
modelName,
|
|
171
|
-
providerDisplayName,
|
|
172
|
-
sessionId: _sessionId,
|
|
173
|
-
isThinking,
|
|
174
|
-
activeToolCount = 0,
|
|
175
|
-
activeBackgroundTaskCount = 0,
|
|
176
|
-
hasPendingPrompt = false,
|
|
177
|
-
contextPercentage,
|
|
178
|
-
contextUsedTokens,
|
|
179
|
-
contextMaxTokens,
|
|
180
|
-
sessionName,
|
|
181
|
-
gitBranch,
|
|
182
|
-
showGitBranch = true,
|
|
183
|
-
activeAgentLabel,
|
|
184
|
-
}: IProps): React.ReactElement {
|
|
185
|
-
return (
|
|
186
|
-
<Box paddingLeft={1} paddingRight={1} justifyContent="space-between">
|
|
187
|
-
<StatusLeft
|
|
188
|
-
permissionMode={permissionMode}
|
|
189
|
-
modelName={modelName}
|
|
190
|
-
providerDisplayName={providerDisplayName}
|
|
191
|
-
isThinking={isThinking}
|
|
192
|
-
activeToolCount={activeToolCount}
|
|
193
|
-
activeBackgroundTaskCount={activeBackgroundTaskCount}
|
|
194
|
-
hasPendingPrompt={hasPendingPrompt}
|
|
195
|
-
contextPercentage={contextPercentage}
|
|
196
|
-
contextUsedTokens={contextUsedTokens}
|
|
197
|
-
contextMaxTokens={contextMaxTokens}
|
|
198
|
-
sessionName={sessionName}
|
|
199
|
-
gitBranch={gitBranch}
|
|
200
|
-
showGitBranch={showGitBranch}
|
|
201
|
-
/>
|
|
202
|
-
{activeAgentLabel !== undefined && (
|
|
203
|
-
<Text color="yellow" bold>
|
|
204
|
-
[{activeAgentLabel}]
|
|
205
|
-
</Text>
|
|
206
|
-
)}
|
|
207
|
-
</Box>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Streaming indicator — shows real-time tool execution and AI response text.
|
|
3
|
-
* Displayed during session.run() execution.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Box, Text } from 'ink';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
import { renderMarkdown } from './render-markdown.js';
|
|
10
|
-
import ToolDiffBlock from './ToolDiffBlock.js';
|
|
11
|
-
|
|
12
|
-
import type { IToolState } from '@robota-sdk/agent-interface-transport';
|
|
13
|
-
|
|
14
|
-
function getToolStyle(t: IToolState): {
|
|
15
|
-
color: string;
|
|
16
|
-
icon: string;
|
|
17
|
-
strikethrough: boolean;
|
|
18
|
-
} {
|
|
19
|
-
if (t.isRunning) return { color: 'yellow', icon: '⟳', strikethrough: false };
|
|
20
|
-
if (t.result === 'error') return { color: 'red', icon: '✗', strikethrough: true };
|
|
21
|
-
if (t.result === 'denied') return { color: 'yellowBright', icon: '⊘', strikethrough: true };
|
|
22
|
-
return { color: 'green', icon: '✓', strikethrough: false };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface IProps {
|
|
26
|
-
text: string;
|
|
27
|
-
activeTools: IToolState[];
|
|
28
|
-
isThinking?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function renderThinkingFallback(isThinking: boolean): React.ReactElement {
|
|
32
|
-
if (!isThinking) return <></>;
|
|
33
|
-
return (
|
|
34
|
-
<Box marginBottom={1}>
|
|
35
|
-
<Text color="yellow">Thinking...</Text>
|
|
36
|
-
</Box>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function renderTools(activeTools: IToolState[]): React.ReactElement {
|
|
41
|
-
return (
|
|
42
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
43
|
-
<Text color="white" bold>
|
|
44
|
-
Tools:
|
|
45
|
-
</Text>
|
|
46
|
-
<Text> </Text>
|
|
47
|
-
{activeTools.map((t, i) => {
|
|
48
|
-
const { color, icon, strikethrough } = getToolStyle(t);
|
|
49
|
-
return (
|
|
50
|
-
<Box key={`${t.toolName}-${i}`} flexDirection="column">
|
|
51
|
-
<Text color={color} strikethrough={strikethrough}>
|
|
52
|
-
{' '}
|
|
53
|
-
{icon} {t.toolName}({t.firstArg})
|
|
54
|
-
</Text>
|
|
55
|
-
{t.diffLines && t.diffLines.length > 0 && (
|
|
56
|
-
<ToolDiffBlock file={t.diffFile} lines={t.diffLines} />
|
|
57
|
-
)}
|
|
58
|
-
</Box>
|
|
59
|
-
);
|
|
60
|
-
})}
|
|
61
|
-
</Box>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default function StreamingIndicator({
|
|
66
|
-
text,
|
|
67
|
-
activeTools,
|
|
68
|
-
isThinking = false,
|
|
69
|
-
}: IProps): React.ReactElement {
|
|
70
|
-
const hasTools = activeTools.length > 0;
|
|
71
|
-
const hasText = text.length > 0;
|
|
72
|
-
|
|
73
|
-
if (!hasTools && !hasText) {
|
|
74
|
-
return renderThinkingFallback(isThinking);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Box flexDirection="column">
|
|
79
|
-
{hasTools && renderTools(activeTools)}
|
|
80
|
-
{hasText && (
|
|
81
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
82
|
-
<Text color="cyan" bold>
|
|
83
|
-
Robota:
|
|
84
|
-
</Text>
|
|
85
|
-
<Text> </Text>
|
|
86
|
-
<Box marginLeft={2}>
|
|
87
|
-
<Text wrap="wrap">{renderMarkdown(text)}</Text>
|
|
88
|
-
</Box>
|
|
89
|
-
</Box>
|
|
90
|
-
)}
|
|
91
|
-
</Box>
|
|
92
|
-
);
|
|
93
|
-
}
|
package/src/tui/TextPrompt.tsx
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Box, Text, useInput } from 'ink';
|
|
2
|
-
import React, { useState, useRef, useCallback } from 'react';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
applyTextPromptInput,
|
|
6
|
-
createTextPromptFlowState,
|
|
7
|
-
getTextPromptInputAction,
|
|
8
|
-
type ITextPromptFlowState,
|
|
9
|
-
type TTextPromptInputAction,
|
|
10
|
-
} from './flows/text-prompt-flow.js';
|
|
11
|
-
|
|
12
|
-
interface IProps {
|
|
13
|
-
title: string;
|
|
14
|
-
description?: string;
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
onSubmit: (value: string) => void;
|
|
17
|
-
onCancel: () => void;
|
|
18
|
-
validate?: (value: string) => string | undefined;
|
|
19
|
-
allowEmpty?: boolean;
|
|
20
|
-
masked?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default function TextPrompt({
|
|
24
|
-
title,
|
|
25
|
-
description,
|
|
26
|
-
placeholder,
|
|
27
|
-
onSubmit,
|
|
28
|
-
onCancel,
|
|
29
|
-
validate,
|
|
30
|
-
allowEmpty = false,
|
|
31
|
-
masked = false,
|
|
32
|
-
}: IProps): React.ReactElement {
|
|
33
|
-
const [state, setState] = useState<ITextPromptFlowState>(() => createTextPromptFlowState());
|
|
34
|
-
const stateRef = useRef(state);
|
|
35
|
-
const applyAction = useCallback(
|
|
36
|
-
(action: TTextPromptInputAction): void => {
|
|
37
|
-
const result = applyTextPromptInput(stateRef.current, action, { allowEmpty, validate });
|
|
38
|
-
stateRef.current = result.state;
|
|
39
|
-
setState(result.state);
|
|
40
|
-
if (result.effect.type === 'cancel') {
|
|
41
|
-
onCancel();
|
|
42
|
-
} else if (result.effect.type === 'submit') {
|
|
43
|
-
onSubmit(result.effect.value);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
[allowEmpty, validate, onCancel, onSubmit],
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
useInput((input, key) => {
|
|
50
|
-
const action = getTextPromptInputAction(input, key);
|
|
51
|
-
if (action !== undefined) applyAction(action);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
|
|
56
|
-
<Text color="yellow" bold>
|
|
57
|
-
{title}
|
|
58
|
-
</Text>
|
|
59
|
-
<PromptDescription description={description} />
|
|
60
|
-
<Box marginTop={1}>
|
|
61
|
-
<Text color="cyan">> </Text>
|
|
62
|
-
{state.value ? (
|
|
63
|
-
<Text>{masked ? '*'.repeat(state.value.length) : state.value}</Text>
|
|
64
|
-
) : placeholder ? (
|
|
65
|
-
<Text dimColor>{placeholder}</Text>
|
|
66
|
-
) : null}
|
|
67
|
-
<Text color="cyan">█</Text>
|
|
68
|
-
</Box>
|
|
69
|
-
{state.error && <Text color="red">{state.error}</Text>}
|
|
70
|
-
<Text dimColor> Enter Submit Esc Cancel</Text>
|
|
71
|
-
</Box>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function PromptDescription({ description }: { description?: string }): React.ReactElement | null {
|
|
76
|
-
if (description === undefined || description.length === 0) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return <Text dimColor>{description}</Text>;
|
|
81
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Box, Text } from 'ink';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { formatCommandOutputSummary } from './command-output-summary.js';
|
|
5
|
-
|
|
6
|
-
import type { ICommandOutputInput } from './command-output-summary.js';
|
|
7
|
-
|
|
8
|
-
interface IProps {
|
|
9
|
-
tool: ICommandOutputInput;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function ToolCommandOutput({ tool }: IProps): React.ReactElement | null {
|
|
13
|
-
const summary = formatCommandOutputSummary(tool);
|
|
14
|
-
if (!summary) return null;
|
|
15
|
-
if (
|
|
16
|
-
summary.statusLabel === 'ok' &&
|
|
17
|
-
summary.previewLines.length === 0 &&
|
|
18
|
-
!summary.transcriptHint
|
|
19
|
-
) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
const color = summary.status === 'error' ? 'red' : 'white';
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Box flexDirection="column" marginLeft={4}>
|
|
26
|
-
{summary.statusLabel !== 'ok' && (
|
|
27
|
-
<Text color={color} dimColor>
|
|
28
|
-
{summary.statusLabel}
|
|
29
|
-
</Text>
|
|
30
|
-
)}
|
|
31
|
-
{summary.previewLines.map((line, index) => (
|
|
32
|
-
<Text key={`${line}-${index}`} color={color} dimColor>
|
|
33
|
-
{line}
|
|
34
|
-
</Text>
|
|
35
|
-
))}
|
|
36
|
-
{summary.transcriptHint && <Text dimColor>{summary.transcriptHint}</Text>}
|
|
37
|
-
</Box>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Box, Text } from 'ink';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { renderMarkdown } from './render-markdown.js';
|
|
5
|
-
import { buildToolDiffSummary } from './utils/tool-diff-summary.js';
|
|
6
|
-
|
|
7
|
-
import type { IDiffLine } from './utils/edit-diff.js';
|
|
8
|
-
|
|
9
|
-
interface IProps {
|
|
10
|
-
file?: string;
|
|
11
|
-
lines: readonly IDiffLine[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default function ToolDiffBlock({ file, lines }: IProps): React.ReactElement {
|
|
15
|
-
const summary = buildToolDiffSummary({ file, lines });
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Box flexDirection="column" marginLeft={4}>
|
|
19
|
-
{summary.file && (
|
|
20
|
-
<Text color="white" dimColor>
|
|
21
|
-
│ {summary.file}
|
|
22
|
-
</Text>
|
|
23
|
-
)}
|
|
24
|
-
<Text>{renderMarkdown(summary.markdown)}</Text>
|
|
25
|
-
{summary.truncated && (
|
|
26
|
-
<Text color="white" dimColor>
|
|
27
|
-
│ ... and {summary.remainingLineCount} more lines
|
|
28
|
-
</Text>
|
|
29
|
-
)}
|
|
30
|
-
</Box>
|
|
31
|
-
);
|
|
32
|
-
}
|