@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
package/src/tui/CjkTextInput.tsx
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CJK-aware TextInput component for Ink.
|
|
3
|
-
*
|
|
4
|
-
* Replaces ink-text-input with proper wide character support:
|
|
5
|
-
* - Uses string-width for display width calculation
|
|
6
|
-
* - Cursor position based on character index (not display columns)
|
|
7
|
-
* - Renders CJK characters correctly (2 columns each)
|
|
8
|
-
* - Uses refs for value/cursor to avoid React state batching issues
|
|
9
|
-
* (IME sends multiple keystrokes synchronously, state updates are async)
|
|
10
|
-
*
|
|
11
|
-
* Drop-in replacement: same props as ink-text-input.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import chalk from 'chalk';
|
|
15
|
-
import { Text, useInput, usePaste } from 'ink';
|
|
16
|
-
import React, { useRef, useState } from 'react';
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
applyCjkTextInput,
|
|
20
|
-
applyCjkTextPaste,
|
|
21
|
-
createCjkTextInputFlowState,
|
|
22
|
-
syncCjkTextInputFlowState,
|
|
23
|
-
type ICjkTextInputFlowState,
|
|
24
|
-
} from './flows/cjk-text-input-flow.js';
|
|
25
|
-
|
|
26
|
-
interface IProps {
|
|
27
|
-
value: string;
|
|
28
|
-
onChange: (value: string) => void;
|
|
29
|
-
onSubmit?: (value: string) => void;
|
|
30
|
-
onPaste?: (text: string, cursorPosition: number) => void;
|
|
31
|
-
placeholder?: string;
|
|
32
|
-
focus?: boolean;
|
|
33
|
-
showCursor?: boolean;
|
|
34
|
-
/** Available width in columns for visual line wrapping navigation */
|
|
35
|
-
availableWidth?: number;
|
|
36
|
-
/** Cursor position hint for external value changes. null = end (default). */
|
|
37
|
-
cursorHint?: number | null;
|
|
38
|
-
/** When false, parent flows own up/down arrow behavior. */
|
|
39
|
-
enableVerticalNavigation?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface IInputHandlerOptions {
|
|
43
|
-
stateRef: React.MutableRefObject<ICjkTextInputFlowState>;
|
|
44
|
-
onChange: (value: string) => void;
|
|
45
|
-
onSubmit?: (value: string) => void;
|
|
46
|
-
onPaste?: (text: string, cursorPosition: number) => void;
|
|
47
|
-
availableWidth?: number;
|
|
48
|
-
focus: boolean;
|
|
49
|
-
enableVerticalNavigation: boolean;
|
|
50
|
-
forceRender: React.Dispatch<React.SetStateAction<number>>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default function CjkTextInput({
|
|
54
|
-
value,
|
|
55
|
-
onChange,
|
|
56
|
-
onSubmit,
|
|
57
|
-
onPaste,
|
|
58
|
-
placeholder = '',
|
|
59
|
-
focus = true,
|
|
60
|
-
showCursor = true,
|
|
61
|
-
availableWidth,
|
|
62
|
-
cursorHint = null,
|
|
63
|
-
enableVerticalNavigation = true,
|
|
64
|
-
}: IProps): React.ReactElement {
|
|
65
|
-
const stateRef = useRef<ICjkTextInputFlowState>(createCjkTextInputFlowState(value));
|
|
66
|
-
const [, forceRender] = useState(0);
|
|
67
|
-
|
|
68
|
-
// Sync ref when value changes from parent (e.g., setValue(''), tab completion, paste)
|
|
69
|
-
stateRef.current = syncCjkTextInputFlowState(stateRef.current, value, cursorHint);
|
|
70
|
-
|
|
71
|
-
useCjkTextInputHandlers({
|
|
72
|
-
stateRef,
|
|
73
|
-
onChange,
|
|
74
|
-
onSubmit,
|
|
75
|
-
onPaste,
|
|
76
|
-
availableWidth,
|
|
77
|
-
focus,
|
|
78
|
-
enableVerticalNavigation,
|
|
79
|
-
forceRender,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// Real terminal cursor positioning is intentionally omitted.
|
|
83
|
-
// setCursorPosition(x, 0) crashes Terminal.app via Korean IME SIGSEGV.
|
|
84
|
-
// Correct fix requires the input row's y offset from the bottom of the render,
|
|
85
|
-
// which Ink does not expose. Tracked as a known limitation.
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<Text>
|
|
89
|
-
{renderWithCursor(
|
|
90
|
-
stateRef.current.value,
|
|
91
|
-
stateRef.current.cursor,
|
|
92
|
-
placeholder,
|
|
93
|
-
showCursor && focus,
|
|
94
|
-
)}
|
|
95
|
-
</Text>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function useCjkTextInputHandlers(options: IInputHandlerOptions): void {
|
|
100
|
-
usePaste(
|
|
101
|
-
(text) => {
|
|
102
|
-
applyCjkFlowSafely(options, () =>
|
|
103
|
-
applyCjkTextPaste(options.stateRef.current, text, createFlowOptions(options)),
|
|
104
|
-
);
|
|
105
|
-
},
|
|
106
|
-
{ isActive: options.focus },
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
useInput(
|
|
110
|
-
(input, key) => {
|
|
111
|
-
applyCjkFlowSafely(options, () =>
|
|
112
|
-
applyCjkTextInput(options.stateRef.current, input, key, createFlowOptions(options)),
|
|
113
|
-
);
|
|
114
|
-
},
|
|
115
|
-
{ isActive: options.focus },
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function createFlowOptions(options: IInputHandlerOptions): {
|
|
120
|
-
availableWidth?: number;
|
|
121
|
-
canPaste: boolean;
|
|
122
|
-
enableVerticalNavigation: boolean;
|
|
123
|
-
} {
|
|
124
|
-
return {
|
|
125
|
-
availableWidth: options.availableWidth,
|
|
126
|
-
canPaste: options.onPaste !== undefined,
|
|
127
|
-
enableVerticalNavigation: options.enableVerticalNavigation,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function applyCjkFlowSafely(
|
|
132
|
-
options: IInputHandlerOptions,
|
|
133
|
-
run: () => ReturnType<typeof applyCjkTextInput>,
|
|
134
|
-
): void {
|
|
135
|
-
try {
|
|
136
|
-
const result = run();
|
|
137
|
-
options.stateRef.current = result.state;
|
|
138
|
-
applyCjkTextInputEffect(
|
|
139
|
-
result.effect,
|
|
140
|
-
options.onChange,
|
|
141
|
-
options.onSubmit,
|
|
142
|
-
options.onPaste,
|
|
143
|
-
options.forceRender,
|
|
144
|
-
);
|
|
145
|
-
} catch {
|
|
146
|
-
// allow-fallback: Korean IME in raw mode can produce unexpected byte sequences
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function applyCjkTextInputEffect(
|
|
151
|
-
effect: ReturnType<typeof applyCjkTextInput>['effect'],
|
|
152
|
-
onChange: (value: string) => void,
|
|
153
|
-
onSubmit: ((value: string) => void) | undefined,
|
|
154
|
-
onPaste: ((text: string, cursorPosition: number) => void) | undefined,
|
|
155
|
-
forceRender: React.Dispatch<React.SetStateAction<number>>,
|
|
156
|
-
): void {
|
|
157
|
-
if (effect.type === 'change') {
|
|
158
|
-
onChange(effect.value);
|
|
159
|
-
} else if (effect.type === 'submit') {
|
|
160
|
-
onSubmit?.(effect.value);
|
|
161
|
-
} else if (effect.type === 'paste') {
|
|
162
|
-
onPaste?.(effect.text, effect.cursor);
|
|
163
|
-
} else if (effect.type === 'render') {
|
|
164
|
-
forceRender((n) => n + 1);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** Render text with an inverse-style cursor at the correct position */
|
|
169
|
-
function renderWithCursor(
|
|
170
|
-
value: string,
|
|
171
|
-
cursorOffset: number,
|
|
172
|
-
placeholder: string,
|
|
173
|
-
showCursor: boolean,
|
|
174
|
-
): string {
|
|
175
|
-
if (!showCursor) {
|
|
176
|
-
return value.length > 0 ? value : placeholder ? chalk.gray(placeholder) : '';
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (value.length === 0) {
|
|
180
|
-
if (placeholder.length > 0) {
|
|
181
|
-
return chalk.inverse(placeholder[0]) + chalk.gray(placeholder.slice(1));
|
|
182
|
-
}
|
|
183
|
-
return chalk.inverse(' ');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const chars = [...value];
|
|
187
|
-
let rendered = '';
|
|
188
|
-
|
|
189
|
-
for (let i = 0; i < chars.length; i++) {
|
|
190
|
-
const char = chars[i] ?? '';
|
|
191
|
-
rendered += i === cursorOffset ? chalk.inverse(char) : char;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (cursorOffset >= chars.length) {
|
|
195
|
-
rendered += chalk.inverse(' ');
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return rendered;
|
|
199
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reusable confirmation prompt with arrow-key selection.
|
|
3
|
-
* Used by model change, permission prompts, and other yes/no confirmations.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Box, Text, useInput } from 'ink';
|
|
7
|
-
import React, { useState, useRef, useCallback } from 'react';
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
applyConfirmPromptInput,
|
|
11
|
-
getConfirmPromptInputAction,
|
|
12
|
-
type TConfirmPromptInputAction,
|
|
13
|
-
} from './flows/confirm-prompt-flow.js';
|
|
14
|
-
import { createSelectionFlowState, type ISelectionFlowState } from './flows/selection-flow.js';
|
|
15
|
-
|
|
16
|
-
interface IProps {
|
|
17
|
-
/** Message to display above the options */
|
|
18
|
-
message: string;
|
|
19
|
-
/** Options to select from (default: ['Yes', 'No']) */
|
|
20
|
-
options?: string[];
|
|
21
|
-
/** Callback with the selected index */
|
|
22
|
-
onSelect: (index: number) => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default function ConfirmPrompt({
|
|
26
|
-
message,
|
|
27
|
-
options = ['Yes', 'No'],
|
|
28
|
-
onSelect,
|
|
29
|
-
}: IProps): React.ReactElement {
|
|
30
|
-
const [state, setState] = useState<ISelectionFlowState>(() => createSelectionFlowState());
|
|
31
|
-
const stateRef = useRef(state);
|
|
32
|
-
const applyAction = useCallback(
|
|
33
|
-
(action: TConfirmPromptInputAction): void => {
|
|
34
|
-
const result = applyConfirmPromptInput(stateRef.current, action, options.length);
|
|
35
|
-
stateRef.current = result.state;
|
|
36
|
-
setState(result.state);
|
|
37
|
-
if (result.effect.type === 'select') {
|
|
38
|
-
onSelect(result.effect.index);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
[onSelect, options.length],
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
useInput((input, key) => {
|
|
45
|
-
const action = getConfirmPromptInputAction(input, key, options.length);
|
|
46
|
-
if (action !== undefined) {
|
|
47
|
-
applyAction(action);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
|
|
53
|
-
<Text color="yellow">{message}</Text>
|
|
54
|
-
<Box marginTop={1}>
|
|
55
|
-
{options.map((opt, i) => (
|
|
56
|
-
<Box key={opt} marginRight={2}>
|
|
57
|
-
<Text
|
|
58
|
-
color={i === state.selectedIndex ? 'cyan' : undefined}
|
|
59
|
-
bold={i === state.selectedIndex}
|
|
60
|
-
>
|
|
61
|
-
{i === state.selectedIndex ? '> ' : ' '}
|
|
62
|
-
{opt}
|
|
63
|
-
</Text>
|
|
64
|
-
</Box>
|
|
65
|
-
))}
|
|
66
|
-
</Box>
|
|
67
|
-
<Text dimColor> arrow keys to select, Enter to confirm</Text>
|
|
68
|
-
</Box>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Box, Text } from 'ink';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
interface IProps {
|
|
5
|
-
percentage: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const COMPACT_SUGGESTION_THRESHOLD = 70;
|
|
9
|
-
const CRITICAL_THRESHOLD = 90;
|
|
10
|
-
|
|
11
|
-
export function ContextWarningBanner({ percentage }: IProps): React.ReactElement | null {
|
|
12
|
-
if (percentage >= CRITICAL_THRESHOLD) {
|
|
13
|
-
return (
|
|
14
|
-
<Box borderStyle="single" borderColor="red" paddingX={1}>
|
|
15
|
-
<Text color="red" bold>
|
|
16
|
-
⚠ Context at {Math.round(percentage)}% — window nearly full. Run /compact to summarize
|
|
17
|
-
the conversation.
|
|
18
|
-
</Text>
|
|
19
|
-
</Box>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (percentage >= COMPACT_SUGGESTION_THRESHOLD) {
|
|
24
|
-
return (
|
|
25
|
-
<Box paddingX={1}>
|
|
26
|
-
<Text color="yellow">
|
|
27
|
-
Context at {Math.round(percentage)}% — consider running /compact to free up space.
|
|
28
|
-
</Text>
|
|
29
|
-
</Box>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Box, Text } from 'ink';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
formatExecutionDetailRecord,
|
|
6
|
-
formatExecutionWorkspaceEntryRow,
|
|
7
|
-
} from './execution-workspace-view-model.js';
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
IExecutionDetailPage,
|
|
11
|
-
IExecutionWorkspaceEntry,
|
|
12
|
-
TExecutionDetailRecordKind,
|
|
13
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
14
|
-
|
|
15
|
-
const MAX_VISIBLE_DETAIL_RECORDS = 12;
|
|
16
|
-
|
|
17
|
-
interface IProps {
|
|
18
|
-
entry: IExecutionWorkspaceEntry;
|
|
19
|
-
page: IExecutionDetailPage | null;
|
|
20
|
-
loading?: boolean;
|
|
21
|
-
error?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default function ExecutionWorkspaceDetailPane({
|
|
25
|
-
entry,
|
|
26
|
-
page,
|
|
27
|
-
loading,
|
|
28
|
-
error,
|
|
29
|
-
}: IProps): React.ReactElement {
|
|
30
|
-
const row = formatExecutionWorkspaceEntryRow(entry, { selectedEntryId: entry.id });
|
|
31
|
-
const records = page?.records.slice(-MAX_VISIBLE_DETAIL_RECORDS) ?? [];
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
35
|
-
<Text color="cyan" bold>
|
|
36
|
-
{`Viewing ${row.title}`}
|
|
37
|
-
</Text>
|
|
38
|
-
<Text dimColor>
|
|
39
|
-
{row.statusLabel}
|
|
40
|
-
{row.subtitle ? ` · ${row.subtitle}` : ''}
|
|
41
|
-
{row.preview ? ` · ${row.preview}` : ''}
|
|
42
|
-
</Text>
|
|
43
|
-
{loading ? <Text dimColor>Loading workspace detail...</Text> : null}
|
|
44
|
-
{error ? <Text color="red">{error}</Text> : null}
|
|
45
|
-
{!loading && !error && records.length === 0 ? <Text dimColor>No detail yet</Text> : null}
|
|
46
|
-
{!loading &&
|
|
47
|
-
!error &&
|
|
48
|
-
records.map((record) => (
|
|
49
|
-
<Text key={record.id} color={getDetailRecordColor(record.kind)}>
|
|
50
|
-
{formatExecutionDetailRecord(record)}
|
|
51
|
-
</Text>
|
|
52
|
-
))}
|
|
53
|
-
{page?.nextCursor ? <Text dimColor>... more detail available</Text> : null}
|
|
54
|
-
</Box>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function getDetailRecordColor(kind: TExecutionDetailRecordKind): string | undefined {
|
|
59
|
-
if (kind === 'error') return 'red';
|
|
60
|
-
if (kind === 'result') return 'green';
|
|
61
|
-
if (kind === 'process_output') return 'white';
|
|
62
|
-
if (kind === 'group_summary') return 'cyan';
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { Box, Text, useInput } from 'ink';
|
|
2
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
import { formatExecutionWorkspaceEntryRow } from './execution-workspace-view-model.js';
|
|
5
|
-
import {
|
|
6
|
-
applySelectionInput,
|
|
7
|
-
createSelectionFlowState,
|
|
8
|
-
getVerticalSelectionInputAction,
|
|
9
|
-
normalizeSelectionState,
|
|
10
|
-
type ISelectionFlowState,
|
|
11
|
-
type TSelectionInputAction,
|
|
12
|
-
} from './flows/selection-flow.js';
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
IExecutionWorkspaceEntry,
|
|
16
|
-
IExecutionWorkspaceSnapshot,
|
|
17
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
18
|
-
|
|
19
|
-
const MAX_VISIBLE_WORKSPACE_ENTRIES = 8;
|
|
20
|
-
|
|
21
|
-
interface IProps {
|
|
22
|
-
snapshot: IExecutionWorkspaceSnapshot | null;
|
|
23
|
-
selectedEntryId?: string;
|
|
24
|
-
onSelect: (entryId: string) => void;
|
|
25
|
-
onClose: () => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default function ExecutionWorkspaceSwitcher({
|
|
29
|
-
snapshot,
|
|
30
|
-
selectedEntryId,
|
|
31
|
-
onSelect,
|
|
32
|
-
onClose,
|
|
33
|
-
}: IProps): React.ReactElement {
|
|
34
|
-
const entries = [...(snapshot?.entries ?? [])];
|
|
35
|
-
const { normalized, visibleEntries, applyAction } = useWorkspaceSwitcherSelection({
|
|
36
|
-
entries,
|
|
37
|
-
selectedEntryId,
|
|
38
|
-
onSelect,
|
|
39
|
-
onClose,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
useInput((_input, key) => {
|
|
43
|
-
const action = getVerticalSelectionInputAction(key);
|
|
44
|
-
if (action !== undefined) applyAction(action);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Box flexDirection="column" borderStyle="round" borderColor="cyan" paddingX={1}>
|
|
49
|
-
<Text color="cyan" bold>
|
|
50
|
-
Execution workspace
|
|
51
|
-
</Text>
|
|
52
|
-
<Box flexDirection="column" marginTop={1}>
|
|
53
|
-
{visibleEntries.length === 0 ? (
|
|
54
|
-
<Text dimColor>No workspace entries</Text>
|
|
55
|
-
) : (
|
|
56
|
-
visibleEntries.map((entry, index) => (
|
|
57
|
-
<ExecutionWorkspaceSwitcherRow
|
|
58
|
-
key={entry.id}
|
|
59
|
-
entry={entry}
|
|
60
|
-
isFocused={normalized.scrollOffset + index === normalized.selectedIndex}
|
|
61
|
-
selectedEntryId={selectedEntryId}
|
|
62
|
-
/>
|
|
63
|
-
))
|
|
64
|
-
)}
|
|
65
|
-
</Box>
|
|
66
|
-
<Text dimColor>Ctrl+B Close ↑↓ Navigate Enter Switch Esc Close</Text>
|
|
67
|
-
</Box>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface IUseWorkspaceSwitcherSelectionInput {
|
|
72
|
-
entries: IExecutionWorkspaceEntry[];
|
|
73
|
-
selectedEntryId?: string;
|
|
74
|
-
onSelect: (entryId: string) => void;
|
|
75
|
-
onClose: () => void;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function useWorkspaceSwitcherSelection({
|
|
79
|
-
entries,
|
|
80
|
-
selectedEntryId,
|
|
81
|
-
onSelect,
|
|
82
|
-
onClose,
|
|
83
|
-
}: IUseWorkspaceSwitcherSelectionInput): {
|
|
84
|
-
normalized: ISelectionFlowState;
|
|
85
|
-
visibleEntries: IExecutionWorkspaceEntry[];
|
|
86
|
-
applyAction: (action: TSelectionInputAction) => void;
|
|
87
|
-
} {
|
|
88
|
-
const [state, setState] = useState<ISelectionFlowState>(() => createSelectionFlowState());
|
|
89
|
-
const stateRef = useRef(state);
|
|
90
|
-
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
const selectedIndex = Math.max(
|
|
93
|
-
0,
|
|
94
|
-
entries.findIndex((entry) => entry.id === selectedEntryId),
|
|
95
|
-
);
|
|
96
|
-
const nextState = createNormalizedSelection({ selectedIndex, itemCount: entries.length });
|
|
97
|
-
stateRef.current = nextState;
|
|
98
|
-
setState(nextState);
|
|
99
|
-
}, [entries.length, selectedEntryId]);
|
|
100
|
-
|
|
101
|
-
const normalized = createNormalizedSelection({
|
|
102
|
-
selectedIndex: state.selectedIndex,
|
|
103
|
-
scrollOffset: state.scrollOffset,
|
|
104
|
-
itemCount: entries.length,
|
|
105
|
-
});
|
|
106
|
-
if (normalized !== state) stateRef.current = normalized;
|
|
107
|
-
return {
|
|
108
|
-
normalized,
|
|
109
|
-
visibleEntries: entries.slice(
|
|
110
|
-
normalized.scrollOffset,
|
|
111
|
-
normalized.scrollOffset + MAX_VISIBLE_WORKSPACE_ENTRIES,
|
|
112
|
-
),
|
|
113
|
-
applyAction: createApplyAction({ entries, stateRef, setState, onSelect, onClose }),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function createApplyAction({
|
|
118
|
-
entries,
|
|
119
|
-
stateRef,
|
|
120
|
-
setState,
|
|
121
|
-
onSelect,
|
|
122
|
-
onClose,
|
|
123
|
-
}: {
|
|
124
|
-
entries: IExecutionWorkspaceEntry[];
|
|
125
|
-
stateRef: React.MutableRefObject<ISelectionFlowState>;
|
|
126
|
-
setState: React.Dispatch<React.SetStateAction<ISelectionFlowState>>;
|
|
127
|
-
onSelect: (entryId: string) => void;
|
|
128
|
-
onClose: () => void;
|
|
129
|
-
}): (action: TSelectionInputAction) => void {
|
|
130
|
-
return (action): void => {
|
|
131
|
-
const result = applySelectionInput(stateRef.current, action, {
|
|
132
|
-
itemCount: entries.length,
|
|
133
|
-
maxVisible: MAX_VISIBLE_WORKSPACE_ENTRIES,
|
|
134
|
-
});
|
|
135
|
-
const nextState =
|
|
136
|
-
result.effect.type === 'select' || result.effect.type === 'cancel'
|
|
137
|
-
? { ...result.state, resolved: false }
|
|
138
|
-
: result.state;
|
|
139
|
-
stateRef.current = nextState;
|
|
140
|
-
setState(nextState);
|
|
141
|
-
if (result.effect.type === 'cancel') {
|
|
142
|
-
onClose();
|
|
143
|
-
} else if (result.effect.type === 'select') {
|
|
144
|
-
const entry = entries[result.effect.index];
|
|
145
|
-
if (entry) onSelect(entry.id);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function createNormalizedSelection(input: {
|
|
151
|
-
selectedIndex: number;
|
|
152
|
-
scrollOffset?: number;
|
|
153
|
-
itemCount: number;
|
|
154
|
-
}): ISelectionFlowState {
|
|
155
|
-
return normalizeSelectionState(
|
|
156
|
-
{
|
|
157
|
-
selectedIndex: input.selectedIndex,
|
|
158
|
-
scrollOffset: input.scrollOffset ?? 0,
|
|
159
|
-
resolved: false,
|
|
160
|
-
},
|
|
161
|
-
{ itemCount: input.itemCount, maxVisible: MAX_VISIBLE_WORKSPACE_ENTRIES },
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function ExecutionWorkspaceSwitcherRow({
|
|
166
|
-
entry,
|
|
167
|
-
isFocused,
|
|
168
|
-
selectedEntryId,
|
|
169
|
-
}: {
|
|
170
|
-
entry: IExecutionWorkspaceEntry;
|
|
171
|
-
isFocused: boolean;
|
|
172
|
-
selectedEntryId?: string;
|
|
173
|
-
}): React.ReactElement {
|
|
174
|
-
const row = formatExecutionWorkspaceEntryRow(entry, { selectedEntryId });
|
|
175
|
-
return (
|
|
176
|
-
<Text>
|
|
177
|
-
<Text color={isFocused ? 'cyan' : undefined} bold={isFocused}>
|
|
178
|
-
{isFocused ? '> ' : ' '}
|
|
179
|
-
</Text>
|
|
180
|
-
<Text color={row.color}>{row.radio}</Text>
|
|
181
|
-
<Text color={isFocused ? 'cyan' : undefined} bold={isFocused}>{` ${row.title}`}</Text>
|
|
182
|
-
<Text dimColor>{` · ${row.statusLabel}`}</Text>
|
|
183
|
-
{row.subtitle ? <Text dimColor>{` · ${row.subtitle}`}</Text> : null}
|
|
184
|
-
{row.preview ? <Text dimColor>{` · ${row.preview}`}</Text> : null}
|
|
185
|
-
</Text>
|
|
186
|
-
);
|
|
187
|
-
}
|