@robota-sdk/agent-transport 3.0.0-beta.75 → 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-CT2ibQnr.cjs → headless-OnpVk4-k.cjs} +7 -7
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.ts +1 -6
- 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/index.ts +1 -5
- package/src/transport-registry.ts +0 -9
- 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-BNccqSpv.d.ts +0 -86
- package/dist/node/index-BNccqSpv.d.ts.map +0 -1
- package/dist/node/index-BUhHIf7X.d.ts +0 -86
- package/dist/node/index-BUhHIf7X.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-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-CcH5EsQh.js +0 -25
- package/dist/node/tui-CcH5EsQh.js.map +0 -1
- package/dist/node/tui-DznRbcku.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 -491
- 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 -73
- package/src/tui/SlashAutocomplete.tsx +0 -110
- package/src/tui/StatusBar.tsx +0 -236
- 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 -495
- 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 -177
- 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 -129
- 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,73 +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
|
-
activePresetId?: string;
|
|
24
|
-
gitRefreshToken?: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default function SessionStatusBar({
|
|
28
|
-
cwd,
|
|
29
|
-
permissionMode,
|
|
30
|
-
modelId,
|
|
31
|
-
providerType,
|
|
32
|
-
sessionId,
|
|
33
|
-
isThinking,
|
|
34
|
-
activeToolCount,
|
|
35
|
-
activeBackgroundTaskCount,
|
|
36
|
-
hasPendingPrompt,
|
|
37
|
-
contextState,
|
|
38
|
-
sessionName,
|
|
39
|
-
settings,
|
|
40
|
-
activeAgentLabel,
|
|
41
|
-
activePresetId,
|
|
42
|
-
gitRefreshToken,
|
|
43
|
-
}: IProps): React.ReactElement | null {
|
|
44
|
-
const cliAdapter = useTuiCliAdapter();
|
|
45
|
-
const gitBranch = useMemo(() => cliAdapter.getGitBranch(cwd), [cliAdapter, cwd, gitRefreshToken]);
|
|
46
|
-
const providerDisplayName = useMemo(
|
|
47
|
-
() =>
|
|
48
|
-
providerType !== undefined ? cliAdapter.getProviderDisplayName(providerType) : undefined,
|
|
49
|
-
[cliAdapter, providerType],
|
|
50
|
-
);
|
|
51
|
-
if (!settings.enabled) return null;
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<StatusBar
|
|
55
|
-
permissionMode={permissionMode}
|
|
56
|
-
modelName={modelId ?? ''}
|
|
57
|
-
providerDisplayName={providerDisplayName}
|
|
58
|
-
sessionId={sessionId}
|
|
59
|
-
isThinking={isThinking}
|
|
60
|
-
activeToolCount={activeToolCount}
|
|
61
|
-
activeBackgroundTaskCount={activeBackgroundTaskCount}
|
|
62
|
-
hasPendingPrompt={hasPendingPrompt}
|
|
63
|
-
contextPercentage={contextState.percentage}
|
|
64
|
-
contextUsedTokens={contextState.usedTokens}
|
|
65
|
-
contextMaxTokens={contextState.maxTokens}
|
|
66
|
-
sessionName={sessionName}
|
|
67
|
-
gitBranch={gitBranch}
|
|
68
|
-
showGitBranch={settings.gitBranch}
|
|
69
|
-
activeAgentLabel={activeAgentLabel}
|
|
70
|
-
activePresetId={activePresetId}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
@@ -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,236 +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
|
-
activePresetId?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface IStatusLeftProps {
|
|
33
|
-
permissionMode: TPermissionMode;
|
|
34
|
-
modelName: string;
|
|
35
|
-
providerDisplayName?: string | undefined;
|
|
36
|
-
isThinking: boolean;
|
|
37
|
-
activeToolCount: number;
|
|
38
|
-
activeBackgroundTaskCount: number;
|
|
39
|
-
hasPendingPrompt: boolean;
|
|
40
|
-
contextPercentage: number;
|
|
41
|
-
contextUsedTokens: number;
|
|
42
|
-
contextMaxTokens: number;
|
|
43
|
-
sessionName?: string;
|
|
44
|
-
gitBranch?: string;
|
|
45
|
-
showGitBranch: boolean;
|
|
46
|
-
activePresetId?: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Return the color for the context percentage indicator */
|
|
50
|
-
function getContextColor(percentage: number): string {
|
|
51
|
-
if (percentage >= CONTEXT_RED_THRESHOLD) return 'red';
|
|
52
|
-
if (percentage >= CONTEXT_YELLOW_THRESHOLD) return 'yellow';
|
|
53
|
-
return 'green';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function StatusActivityText({
|
|
57
|
-
isThinking,
|
|
58
|
-
activeToolCount,
|
|
59
|
-
activeBackgroundTaskCount,
|
|
60
|
-
hasPendingPrompt,
|
|
61
|
-
}: Pick<
|
|
62
|
-
IStatusLeftProps,
|
|
63
|
-
'isThinking' | 'activeToolCount' | 'activeBackgroundTaskCount' | 'hasPendingPrompt'
|
|
64
|
-
>): React.ReactElement {
|
|
65
|
-
const activity = formatStatusActivity({
|
|
66
|
-
isThinking,
|
|
67
|
-
activeToolCount,
|
|
68
|
-
activeBackgroundTaskCount,
|
|
69
|
-
hasPendingPrompt,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<Text color={activity.color} bold={activity.kind !== 'idle'}>
|
|
74
|
-
{activity.text}
|
|
75
|
-
</Text>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function ContextText({
|
|
80
|
-
percentage,
|
|
81
|
-
usedTokens,
|
|
82
|
-
maxTokens,
|
|
83
|
-
}: {
|
|
84
|
-
percentage: number;
|
|
85
|
-
usedTokens: number;
|
|
86
|
-
maxTokens: number;
|
|
87
|
-
}): React.ReactElement {
|
|
88
|
-
return (
|
|
89
|
-
<Text color={getContextColor(percentage)}>
|
|
90
|
-
Context: {Math.round(percentage)}% ({formatTokenCount(usedTokens)}/
|
|
91
|
-
{formatTokenCount(maxTokens)} tokens)
|
|
92
|
-
</Text>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function ModeText({ permissionMode }: { permissionMode: TPermissionMode }): React.ReactElement {
|
|
97
|
-
return (
|
|
98
|
-
<>
|
|
99
|
-
<Text color="cyan" bold>
|
|
100
|
-
Mode:
|
|
101
|
-
</Text>{' '}
|
|
102
|
-
<Text>{permissionMode}</Text>
|
|
103
|
-
</>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function shouldShowPermissionMode(permissionMode: TPermissionMode): boolean {
|
|
108
|
-
return permissionMode !== 'default';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function PresetText({ activePresetId }: { activePresetId: string }): React.ReactElement {
|
|
112
|
-
return (
|
|
113
|
-
<>
|
|
114
|
-
<Text color="cyan" bold>
|
|
115
|
-
Preset:
|
|
116
|
-
</Text>{' '}
|
|
117
|
-
<Text>{activePresetId}</Text>
|
|
118
|
-
</>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function shouldShowActivePreset(activePresetId: string | undefined): activePresetId is string {
|
|
123
|
-
return activePresetId !== undefined && activePresetId !== 'default';
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function ProviderText({
|
|
127
|
-
modelName,
|
|
128
|
-
providerDisplayName,
|
|
129
|
-
}: {
|
|
130
|
-
modelName: string;
|
|
131
|
-
providerDisplayName?: string | undefined;
|
|
132
|
-
}): React.ReactElement {
|
|
133
|
-
if (providerDisplayName !== undefined) {
|
|
134
|
-
return (
|
|
135
|
-
<Text dimColor>
|
|
136
|
-
{providerDisplayName} {modelName}
|
|
137
|
-
</Text>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
return <Text dimColor>{modelName}</Text>;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function StatusLeft(props: IStatusLeftProps): React.ReactElement {
|
|
144
|
-
const shouldShowGitBranch =
|
|
145
|
-
props.showGitBranch && props.gitBranch !== undefined && props.gitBranch.length > 0;
|
|
146
|
-
const showPermissionMode = shouldShowPermissionMode(props.permissionMode);
|
|
147
|
-
const activePresetId = props.activePresetId;
|
|
148
|
-
const showActivePreset = shouldShowActivePreset(activePresetId);
|
|
149
|
-
return (
|
|
150
|
-
<Text>
|
|
151
|
-
<StatusActivityText
|
|
152
|
-
isThinking={props.isThinking}
|
|
153
|
-
activeToolCount={props.activeToolCount}
|
|
154
|
-
activeBackgroundTaskCount={props.activeBackgroundTaskCount}
|
|
155
|
-
hasPendingPrompt={props.hasPendingPrompt}
|
|
156
|
-
/>
|
|
157
|
-
{showPermissionMode && (
|
|
158
|
-
<>
|
|
159
|
-
{' | '}
|
|
160
|
-
<ModeText permissionMode={props.permissionMode} />
|
|
161
|
-
</>
|
|
162
|
-
)}
|
|
163
|
-
{showActivePreset && (
|
|
164
|
-
<>
|
|
165
|
-
{' | '}
|
|
166
|
-
<PresetText activePresetId={activePresetId} />
|
|
167
|
-
</>
|
|
168
|
-
)}
|
|
169
|
-
{props.sessionName && (
|
|
170
|
-
<>
|
|
171
|
-
{' | '}
|
|
172
|
-
<Text color="magenta">{props.sessionName}</Text>
|
|
173
|
-
</>
|
|
174
|
-
)}
|
|
175
|
-
{shouldShowGitBranch && (
|
|
176
|
-
<>
|
|
177
|
-
{' | '}
|
|
178
|
-
<Text dimColor>git: {props.gitBranch}</Text>
|
|
179
|
-
</>
|
|
180
|
-
)}
|
|
181
|
-
{' | '}
|
|
182
|
-
<ProviderText modelName={props.modelName} providerDisplayName={props.providerDisplayName} />
|
|
183
|
-
{' | '}
|
|
184
|
-
<ContextText
|
|
185
|
-
percentage={props.contextPercentage}
|
|
186
|
-
usedTokens={props.contextUsedTokens}
|
|
187
|
-
maxTokens={props.contextMaxTokens}
|
|
188
|
-
/>
|
|
189
|
-
</Text>
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export default function StatusBar({
|
|
194
|
-
permissionMode,
|
|
195
|
-
modelName,
|
|
196
|
-
providerDisplayName,
|
|
197
|
-
sessionId: _sessionId,
|
|
198
|
-
isThinking,
|
|
199
|
-
activeToolCount = 0,
|
|
200
|
-
activeBackgroundTaskCount = 0,
|
|
201
|
-
hasPendingPrompt = false,
|
|
202
|
-
contextPercentage,
|
|
203
|
-
contextUsedTokens,
|
|
204
|
-
contextMaxTokens,
|
|
205
|
-
sessionName,
|
|
206
|
-
gitBranch,
|
|
207
|
-
showGitBranch = true,
|
|
208
|
-
activeAgentLabel,
|
|
209
|
-
activePresetId,
|
|
210
|
-
}: IProps): React.ReactElement {
|
|
211
|
-
return (
|
|
212
|
-
<Box paddingLeft={1} paddingRight={1} justifyContent="space-between">
|
|
213
|
-
<StatusLeft
|
|
214
|
-
permissionMode={permissionMode}
|
|
215
|
-
modelName={modelName}
|
|
216
|
-
providerDisplayName={providerDisplayName}
|
|
217
|
-
isThinking={isThinking}
|
|
218
|
-
activeToolCount={activeToolCount}
|
|
219
|
-
activeBackgroundTaskCount={activeBackgroundTaskCount}
|
|
220
|
-
hasPendingPrompt={hasPendingPrompt}
|
|
221
|
-
contextPercentage={contextPercentage}
|
|
222
|
-
contextUsedTokens={contextUsedTokens}
|
|
223
|
-
contextMaxTokens={contextMaxTokens}
|
|
224
|
-
sessionName={sessionName}
|
|
225
|
-
gitBranch={gitBranch}
|
|
226
|
-
showGitBranch={showGitBranch}
|
|
227
|
-
activePresetId={activePresetId}
|
|
228
|
-
/>
|
|
229
|
-
{activeAgentLabel !== undefined && (
|
|
230
|
-
<Text color="yellow" bold>
|
|
231
|
-
[{activeAgentLabel}]
|
|
232
|
-
</Text>
|
|
233
|
-
)}
|
|
234
|
-
</Box>
|
|
235
|
-
);
|
|
236
|
-
}
|
|
@@ -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
|
-
}
|