@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/App.tsx
DELETED
|
@@ -1,488 +0,0 @@
|
|
|
1
|
-
import { createSystemMessage, messageToHistoryEntry } from '@robota-sdk/agent-core';
|
|
2
|
-
import { listResumableSessionSummaries } from '@robota-sdk/agent-framework';
|
|
3
|
-
import { Box, Static, Text, useApp, useInput } from 'ink';
|
|
4
|
-
import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react';
|
|
5
|
-
|
|
6
|
-
import BackgroundTaskPanel from './BackgroundTaskPanel.js';
|
|
7
|
-
import { ContextWarningBanner } from './ContextWarningBanner.js';
|
|
8
|
-
import {
|
|
9
|
-
countActiveBackgroundWorkspaceEntries,
|
|
10
|
-
getDefaultBackgroundWorkspaceEntries,
|
|
11
|
-
} from './execution-workspace-view-model.js';
|
|
12
|
-
import ExecutionWorkspaceDetailPane from './ExecutionWorkspaceDetailPane.js';
|
|
13
|
-
import ExecutionWorkspaceSwitcher from './ExecutionWorkspaceSwitcher.js';
|
|
14
|
-
import { usePluginCallbacks } from './hooks/usePluginCallbacks.js';
|
|
15
|
-
import { useSideEffects } from './hooks/useSideEffects.js';
|
|
16
|
-
import { useStatusLineSettings } from './hooks/useStatusLineSettings.js';
|
|
17
|
-
import { useTuiChannel } from './hooks/useTuiChannel.js';
|
|
18
|
-
import InputArea from './InputArea.js';
|
|
19
|
-
import InteractivePrompt from './InteractivePrompt.js';
|
|
20
|
-
import MessageList from './MessageList.js';
|
|
21
|
-
import PermissionPrompt from './PermissionPrompt.js';
|
|
22
|
-
import PluginTUI from './PluginTUI.js';
|
|
23
|
-
import SessionPicker from './SessionPicker.js';
|
|
24
|
-
import SessionStatusBar from './SessionStatusBar.js';
|
|
25
|
-
import StreamingIndicator from './StreamingIndicator.js';
|
|
26
|
-
import TransportTUI from './TransportTUI.js';
|
|
27
|
-
import { TuiCliAdapterProvider } from './tui-cli-adapter-context.js';
|
|
28
|
-
import UpdateNotice from './UpdateNotice.js';
|
|
29
|
-
|
|
30
|
-
import type { ITuiCliAdapter } from './tui-cli-adapter.js';
|
|
31
|
-
import type { TuiInteractionChannel } from './TuiInteractionChannel.js';
|
|
32
|
-
import type { TPermissionMode } from '@robota-sdk/agent-core';
|
|
33
|
-
import type {
|
|
34
|
-
IExecutionDetailPage,
|
|
35
|
-
IInteractiveSession,
|
|
36
|
-
IInteractiveSessionStore,
|
|
37
|
-
ITransportRegistryView,
|
|
38
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
39
|
-
|
|
40
|
-
interface IProps {
|
|
41
|
-
cwd: string;
|
|
42
|
-
/**
|
|
43
|
-
* Sole channel source (CLI-B12): App owns the channel lifecycle in React state.
|
|
44
|
-
* The initial channel and every session-switch replacement come from this factory.
|
|
45
|
-
*/
|
|
46
|
-
createChannel: (resumeSessionId?: string) => TuiInteractionChannel;
|
|
47
|
-
providerOverride?: string | undefined;
|
|
48
|
-
providerType?: string | undefined;
|
|
49
|
-
modelId?: string;
|
|
50
|
-
permissionMode?: TPermissionMode;
|
|
51
|
-
version?: string;
|
|
52
|
-
sessionStore?: IInteractiveSessionStore;
|
|
53
|
-
resumeSessionId?: string;
|
|
54
|
-
showSessionPickerOnStart?: boolean;
|
|
55
|
-
startupUpdateNotice?: Promise<string | undefined>;
|
|
56
|
-
transportRegistry?: ITransportRegistryView<IInteractiveSession>;
|
|
57
|
-
cliAdapter: ITuiCliAdapter;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default function App(props: IProps): React.ReactElement {
|
|
61
|
-
// Lazy initializer: channel construction is side-effect-free (object wiring only);
|
|
62
|
-
// I/O starts in AppInner's effect via channel.start(). Runs once per mount.
|
|
63
|
-
const [sessionState, setSessionState] = useState<{
|
|
64
|
-
channel: TuiInteractionChannel;
|
|
65
|
-
sessionId: string | undefined;
|
|
66
|
-
}>(() => ({
|
|
67
|
-
channel: props.createChannel(props.resumeSessionId),
|
|
68
|
-
sessionId: props.resumeSessionId,
|
|
69
|
-
}));
|
|
70
|
-
const [showInitialSessionPicker, setShowInitialSessionPicker] = useState(
|
|
71
|
-
props.showSessionPickerOnStart ?? false,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<TuiCliAdapterProvider value={props.cliAdapter}>
|
|
76
|
-
<AppInner
|
|
77
|
-
key={sessionState.sessionId ?? '__new__'}
|
|
78
|
-
{...props}
|
|
79
|
-
channel={sessionState.channel}
|
|
80
|
-
showSessionPickerOnStart={showInitialSessionPicker}
|
|
81
|
-
resumeSessionId={sessionState.sessionId}
|
|
82
|
-
onSessionSwitch={(sessionId) => {
|
|
83
|
-
setShowInitialSessionPicker(false);
|
|
84
|
-
// Stop the old channel BEFORE the new one becomes active so it can
|
|
85
|
-
// never receive events addressed to the new session (CLI-B12).
|
|
86
|
-
void sessionState.channel.stop();
|
|
87
|
-
setSessionState({ channel: props.createChannel(sessionId), sessionId });
|
|
88
|
-
}}
|
|
89
|
-
/>
|
|
90
|
-
</TuiCliAdapterProvider>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function AppInner(
|
|
95
|
-
props: IProps & {
|
|
96
|
-
channel: TuiInteractionChannel;
|
|
97
|
-
onSessionSwitch: (sessionId: string) => void;
|
|
98
|
-
},
|
|
99
|
-
): React.ReactElement {
|
|
100
|
-
const cwd = props.cwd;
|
|
101
|
-
const { channel } = props;
|
|
102
|
-
|
|
103
|
-
const {
|
|
104
|
-
interactiveSession,
|
|
105
|
-
registry,
|
|
106
|
-
commandEffectQueue,
|
|
107
|
-
history,
|
|
108
|
-
addEntry,
|
|
109
|
-
streamingText,
|
|
110
|
-
activeTools,
|
|
111
|
-
isThinking,
|
|
112
|
-
isAborting,
|
|
113
|
-
isShuttingDown,
|
|
114
|
-
pendingPrompt,
|
|
115
|
-
executionWorkspaceSnapshot,
|
|
116
|
-
selectedExecutionEntryId,
|
|
117
|
-
selectExecutionWorkspaceEntry,
|
|
118
|
-
readExecutionWorkspaceDetail,
|
|
119
|
-
permissionRequest,
|
|
120
|
-
contextState,
|
|
121
|
-
handleSubmit: baseHandleSubmit,
|
|
122
|
-
handleAbort,
|
|
123
|
-
handleCancelQueue,
|
|
124
|
-
handleShutdown,
|
|
125
|
-
} = useTuiChannel(channel);
|
|
126
|
-
|
|
127
|
-
const [sessionName, setSessionName] = useState<string | undefined>(channel.sessionName);
|
|
128
|
-
|
|
129
|
-
const fallbackPluginCallbacks = usePluginCallbacks(cwd);
|
|
130
|
-
const pluginCallbacks = interactiveSession
|
|
131
|
-
? (undefined as unknown as ReturnType<typeof usePluginCallbacks>)
|
|
132
|
-
: fallbackPluginCallbacks;
|
|
133
|
-
const { exit } = useApp();
|
|
134
|
-
const [updateNotice, setUpdateNotice] = useState<string | undefined>();
|
|
135
|
-
const [showExecutionWorkspaceSwitcher, setShowExecutionWorkspaceSwitcher] = useState(false);
|
|
136
|
-
const [executionDetailPage, setExecutionDetailPage] = useState<IExecutionDetailPage | null>(null);
|
|
137
|
-
const [executionDetailError, setExecutionDetailError] = useState<string | undefined>();
|
|
138
|
-
const [isExecutionDetailLoading, setIsExecutionDetailLoading] = useState(false);
|
|
139
|
-
const [statusLineSettings, setStatusLineSettings] = useStatusLineSettings();
|
|
140
|
-
const [gitRefreshToken, setGitRefreshToken] = useState(0);
|
|
141
|
-
const backgroundWorkspaceEntries = useMemo(
|
|
142
|
-
() => getDefaultBackgroundWorkspaceEntries(executionWorkspaceSnapshot),
|
|
143
|
-
[executionWorkspaceSnapshot],
|
|
144
|
-
);
|
|
145
|
-
const activeBackgroundTaskCount = countActiveBackgroundWorkspaceEntries(
|
|
146
|
-
executionWorkspaceSnapshot,
|
|
147
|
-
);
|
|
148
|
-
const selectedExecutionEntry = useMemo(
|
|
149
|
-
() =>
|
|
150
|
-
executionWorkspaceSnapshot?.entries.find((entry) => entry.id === selectedExecutionEntryId),
|
|
151
|
-
[executionWorkspaceSnapshot, selectedExecutionEntryId],
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
const {
|
|
155
|
-
handleSubmit,
|
|
156
|
-
pendingInteractionPrompt,
|
|
157
|
-
showPluginTUI,
|
|
158
|
-
showSessionPicker,
|
|
159
|
-
showTransportTUI,
|
|
160
|
-
setShowPluginTUI,
|
|
161
|
-
setShowSessionPicker,
|
|
162
|
-
setShowTransportTUI,
|
|
163
|
-
handleInteractionSubmit,
|
|
164
|
-
handleInteractionCancel,
|
|
165
|
-
} = useSideEffects({
|
|
166
|
-
cwd,
|
|
167
|
-
providerOverride: props.providerOverride,
|
|
168
|
-
interactiveSession,
|
|
169
|
-
commandEffectQueue,
|
|
170
|
-
addEntry,
|
|
171
|
-
baseHandleSubmit,
|
|
172
|
-
setSessionName,
|
|
173
|
-
setStatusLineSettings,
|
|
174
|
-
showSessionPickerOnStart: props.showSessionPickerOnStart,
|
|
175
|
-
openAgentSwitcher: () => setShowExecutionWorkspaceSwitcher(true),
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
void channel.start();
|
|
180
|
-
return () => {
|
|
181
|
-
void channel.stop();
|
|
182
|
-
};
|
|
183
|
-
}, [channel]);
|
|
184
|
-
|
|
185
|
-
const isSelectedEntryInteractive =
|
|
186
|
-
!selectedExecutionEntry ||
|
|
187
|
-
selectedExecutionEntry.kind === 'main_thread' ||
|
|
188
|
-
selectedExecutionEntry.controls.includes('send');
|
|
189
|
-
|
|
190
|
-
const activeAgentLabel =
|
|
191
|
-
selectedExecutionEntry && selectedExecutionEntry.kind !== 'main_thread'
|
|
192
|
-
? selectedExecutionEntry.title
|
|
193
|
-
: undefined;
|
|
194
|
-
|
|
195
|
-
const mainThreadEntryId = useMemo(
|
|
196
|
-
() => executionWorkspaceSnapshot?.entries.find((e) => e.kind === 'main_thread')?.id,
|
|
197
|
-
[executionWorkspaceSnapshot],
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const handleSubmitWithRouting = useCallback(
|
|
201
|
-
async (input: string): Promise<void> => {
|
|
202
|
-
if (
|
|
203
|
-
selectedExecutionEntry &&
|
|
204
|
-
selectedExecutionEntry.kind !== 'main_thread' &&
|
|
205
|
-
selectedExecutionEntry.controls.includes('send')
|
|
206
|
-
) {
|
|
207
|
-
await interactiveSession.sendAgentJob(selectedExecutionEntry.sourceId, input);
|
|
208
|
-
} else {
|
|
209
|
-
await handleSubmit(input);
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
[selectedExecutionEntry, handleSubmit, interactiveSession],
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
const handleSubmitWithGitRefresh = useCallback(
|
|
216
|
-
async (input: string): Promise<void> => {
|
|
217
|
-
setGitRefreshToken((t) => t + 1);
|
|
218
|
-
await handleSubmitWithRouting(input);
|
|
219
|
-
},
|
|
220
|
-
[handleSubmitWithRouting],
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
// Refresh git branch when AI response completes.
|
|
224
|
-
const wasThinkingRef = useRef(false);
|
|
225
|
-
useEffect(() => {
|
|
226
|
-
if (wasThinkingRef.current && !isThinking) {
|
|
227
|
-
setGitRefreshToken((t) => t + 1);
|
|
228
|
-
}
|
|
229
|
-
wasThinkingRef.current = isThinking;
|
|
230
|
-
}, [isThinking]);
|
|
231
|
-
|
|
232
|
-
// Sync session name from InteractiveSession when resuming
|
|
233
|
-
useEffect(() => {
|
|
234
|
-
const name = interactiveSession?.getName?.();
|
|
235
|
-
if (name && !sessionName) setSessionName(name);
|
|
236
|
-
}, [interactiveSession, sessionName]);
|
|
237
|
-
|
|
238
|
-
useEffect(() => {
|
|
239
|
-
let isMounted = true;
|
|
240
|
-
props.startupUpdateNotice
|
|
241
|
-
?.then((notice) => {
|
|
242
|
-
if (isMounted && notice !== undefined) {
|
|
243
|
-
setUpdateNotice(notice);
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
.catch(() => {
|
|
247
|
-
// Startup update checks are best-effort and must not disrupt the TUI.
|
|
248
|
-
});
|
|
249
|
-
return () => {
|
|
250
|
-
isMounted = false;
|
|
251
|
-
};
|
|
252
|
-
}, [props.startupUpdateNotice]);
|
|
253
|
-
|
|
254
|
-
// Update terminal title
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
const title = sessionName ? `Robota — ${sessionName}` : 'Robota';
|
|
257
|
-
process.stdout.write(`\x1b]0;${title}\x07`);
|
|
258
|
-
}, [sessionName]);
|
|
259
|
-
|
|
260
|
-
// ESC abort
|
|
261
|
-
useInput((_input: string, key: { escape: boolean }) => {
|
|
262
|
-
if (!key.escape || !isThinking) return;
|
|
263
|
-
if (
|
|
264
|
-
permissionRequest ||
|
|
265
|
-
showPluginTUI ||
|
|
266
|
-
showTransportTUI ||
|
|
267
|
-
showSessionPicker ||
|
|
268
|
-
showExecutionWorkspaceSwitcher
|
|
269
|
-
) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
handleAbort();
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
// Ctrl+B toggles the execution workspace switcher.
|
|
276
|
-
useInput((input: string, key: { ctrl?: boolean }) => {
|
|
277
|
-
if (!key.ctrl || input !== 'b') return;
|
|
278
|
-
if (permissionRequest || showPluginTUI || showSessionPicker || isShuttingDown) return;
|
|
279
|
-
setShowExecutionWorkspaceSwitcher((shown) => !shown);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// ESC returns to main thread when a background entry is selected (and not thinking).
|
|
283
|
-
useInput((_input: string, key: { escape: boolean }) => {
|
|
284
|
-
if (!key.escape || isThinking) return;
|
|
285
|
-
if (
|
|
286
|
-
permissionRequest ||
|
|
287
|
-
showPluginTUI ||
|
|
288
|
-
showTransportTUI ||
|
|
289
|
-
showSessionPicker ||
|
|
290
|
-
showExecutionWorkspaceSwitcher
|
|
291
|
-
) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if (
|
|
295
|
-
selectedExecutionEntry &&
|
|
296
|
-
selectedExecutionEntry.kind !== 'main_thread' &&
|
|
297
|
-
mainThreadEntryId !== undefined
|
|
298
|
-
) {
|
|
299
|
-
selectExecutionWorkspaceEntry(mainThreadEntryId);
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
// Ctrl+C graceful shutdown
|
|
304
|
-
useInput((input: string, key: { ctrl?: boolean }) => {
|
|
305
|
-
if (!key.ctrl || input !== 'c' || isShuttingDown) return;
|
|
306
|
-
void handleShutdown('prompt_input_exit').finally(() => exit());
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
useEffect(() => {
|
|
310
|
-
const onSigterm = (): void => {
|
|
311
|
-
if (isShuttingDown) return;
|
|
312
|
-
void handleShutdown('other').finally(() => exit());
|
|
313
|
-
};
|
|
314
|
-
process.once('SIGINT', onSigterm);
|
|
315
|
-
process.once('SIGTERM', onSigterm);
|
|
316
|
-
return () => {
|
|
317
|
-
process.off('SIGINT', onSigterm);
|
|
318
|
-
process.off('SIGTERM', onSigterm);
|
|
319
|
-
};
|
|
320
|
-
}, [handleShutdown, exit, isShuttingDown]);
|
|
321
|
-
|
|
322
|
-
useEffect(() => {
|
|
323
|
-
if (!selectedExecutionEntry || selectedExecutionEntry.kind === 'main_thread') {
|
|
324
|
-
setExecutionDetailPage(null);
|
|
325
|
-
setExecutionDetailError(undefined);
|
|
326
|
-
setIsExecutionDetailLoading(false);
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
let isCurrent = true;
|
|
331
|
-
setIsExecutionDetailLoading(true);
|
|
332
|
-
setExecutionDetailError(undefined);
|
|
333
|
-
readExecutionWorkspaceDetail(selectedExecutionEntry.id)
|
|
334
|
-
.then((page) => {
|
|
335
|
-
if (!isCurrent) return;
|
|
336
|
-
setExecutionDetailPage(page);
|
|
337
|
-
setIsExecutionDetailLoading(false);
|
|
338
|
-
})
|
|
339
|
-
.catch((error: Error) => {
|
|
340
|
-
if (!isCurrent) return;
|
|
341
|
-
setExecutionDetailError(error.message);
|
|
342
|
-
setIsExecutionDetailLoading(false);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
return () => {
|
|
346
|
-
isCurrent = false;
|
|
347
|
-
};
|
|
348
|
-
}, [executionWorkspaceSnapshot, readExecutionWorkspaceDetail, selectedExecutionEntry]);
|
|
349
|
-
|
|
350
|
-
// Session may not be initialized yet
|
|
351
|
-
let permissionMode: TPermissionMode = props.permissionMode ?? 'default';
|
|
352
|
-
let sessionId = '';
|
|
353
|
-
try {
|
|
354
|
-
// allow-fallback: session initializes asynchronously; use defaults until ready
|
|
355
|
-
const session = interactiveSession.getSession();
|
|
356
|
-
permissionMode = session.getPermissionMode();
|
|
357
|
-
sessionId = session.getSessionId();
|
|
358
|
-
} catch {
|
|
359
|
-
// allow-fallback: session initializes asynchronously; use defaults until ready
|
|
360
|
-
// Not yet initialized
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return (
|
|
364
|
-
<Box flexDirection="column">
|
|
365
|
-
<Static items={[{ version: props.version ?? '0.0.0' }]}>
|
|
366
|
-
{(item) => (
|
|
367
|
-
<Box key="logo" flexDirection="column" paddingX={1} marginBottom={1}>
|
|
368
|
-
<Text color="cyan" bold>{`
|
|
369
|
-
____ ___ ____ ___ _____ _
|
|
370
|
-
| _ \\ / _ \\| __ ) / _ \\_ _|/ \\
|
|
371
|
-
| |_) | | | | _ \\| | | || | / _ \\
|
|
372
|
-
| _ <| |_| | |_) | |_| || |/ ___ \\
|
|
373
|
-
|_| \\_\\\\___/|____/ \\___/ |_/_/ \\_\\
|
|
374
|
-
`}</Text>
|
|
375
|
-
<Text dimColor> v{item.version}</Text>
|
|
376
|
-
</Box>
|
|
377
|
-
)}
|
|
378
|
-
</Static>
|
|
379
|
-
{updateNotice && <UpdateNotice message={updateNotice} />}
|
|
380
|
-
<Box flexDirection="column" paddingX={1} flexGrow={1}>
|
|
381
|
-
{selectedExecutionEntry && selectedExecutionEntry.kind !== 'main_thread' ? (
|
|
382
|
-
<ExecutionWorkspaceDetailPane
|
|
383
|
-
entry={selectedExecutionEntry}
|
|
384
|
-
page={executionDetailPage}
|
|
385
|
-
loading={isExecutionDetailLoading}
|
|
386
|
-
error={executionDetailError}
|
|
387
|
-
/>
|
|
388
|
-
) : (
|
|
389
|
-
<MessageList history={history} />
|
|
390
|
-
)}
|
|
391
|
-
{isShuttingDown && (
|
|
392
|
-
<Box marginBottom={1}>
|
|
393
|
-
<Text color="yellow">Shutting down...</Text>
|
|
394
|
-
</Box>
|
|
395
|
-
)}
|
|
396
|
-
{(isThinking || activeTools.length > 0) && (
|
|
397
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
398
|
-
<StreamingIndicator
|
|
399
|
-
text={streamingText}
|
|
400
|
-
activeTools={activeTools}
|
|
401
|
-
isThinking={isThinking}
|
|
402
|
-
/>
|
|
403
|
-
</Box>
|
|
404
|
-
)}
|
|
405
|
-
<BackgroundTaskPanel entries={backgroundWorkspaceEntries} />
|
|
406
|
-
</Box>
|
|
407
|
-
{showExecutionWorkspaceSwitcher && (
|
|
408
|
-
<ExecutionWorkspaceSwitcher
|
|
409
|
-
snapshot={executionWorkspaceSnapshot}
|
|
410
|
-
selectedEntryId={selectedExecutionEntryId}
|
|
411
|
-
onSelect={selectExecutionWorkspaceEntry}
|
|
412
|
-
onClose={() => setShowExecutionWorkspaceSwitcher(false)}
|
|
413
|
-
/>
|
|
414
|
-
)}
|
|
415
|
-
{permissionRequest && <PermissionPrompt request={permissionRequest} />}
|
|
416
|
-
{pendingInteractionPrompt && (
|
|
417
|
-
<InteractivePrompt
|
|
418
|
-
prompt={pendingInteractionPrompt}
|
|
419
|
-
onSubmit={handleInteractionSubmit}
|
|
420
|
-
onCancel={handleInteractionCancel}
|
|
421
|
-
/>
|
|
422
|
-
)}
|
|
423
|
-
{showPluginTUI && (
|
|
424
|
-
<PluginTUI
|
|
425
|
-
callbacks={pluginCallbacks}
|
|
426
|
-
onClose={() => setShowPluginTUI(false)}
|
|
427
|
-
addMessage={(msg) => addEntry(messageToHistoryEntry(createSystemMessage(msg.content)))}
|
|
428
|
-
/>
|
|
429
|
-
)}
|
|
430
|
-
{showTransportTUI && props.transportRegistry && (
|
|
431
|
-
<TransportTUI
|
|
432
|
-
registry={props.transportRegistry}
|
|
433
|
-
onClose={() => setShowTransportTUI(false)}
|
|
434
|
-
/>
|
|
435
|
-
)}
|
|
436
|
-
{showSessionPicker && (
|
|
437
|
-
<SessionPicker
|
|
438
|
-
sessions={listResumableSessionSummaries(props.sessionStore, props.cwd)}
|
|
439
|
-
onSelect={(id) => {
|
|
440
|
-
setShowSessionPicker(false);
|
|
441
|
-
props.onSessionSwitch(id);
|
|
442
|
-
}}
|
|
443
|
-
onCancel={() => {
|
|
444
|
-
setShowSessionPicker(false);
|
|
445
|
-
addEntry(messageToHistoryEntry(createSystemMessage('Session resume cancelled.')));
|
|
446
|
-
}}
|
|
447
|
-
/>
|
|
448
|
-
)}
|
|
449
|
-
<ContextWarningBanner percentage={contextState.percentage} />
|
|
450
|
-
<InputArea
|
|
451
|
-
onSubmit={handleSubmitWithGitRefresh}
|
|
452
|
-
onCancelQueue={handleCancelQueue}
|
|
453
|
-
isDisabled={
|
|
454
|
-
!!permissionRequest ||
|
|
455
|
-
showPluginTUI ||
|
|
456
|
-
showTransportTUI ||
|
|
457
|
-
showSessionPicker ||
|
|
458
|
-
showExecutionWorkspaceSwitcher ||
|
|
459
|
-
isShuttingDown ||
|
|
460
|
-
pendingInteractionPrompt !== null ||
|
|
461
|
-
(isThinking && !!pendingPrompt) ||
|
|
462
|
-
!isSelectedEntryInteractive
|
|
463
|
-
}
|
|
464
|
-
isAborting={isAborting}
|
|
465
|
-
pendingPrompt={pendingPrompt}
|
|
466
|
-
registry={registry}
|
|
467
|
-
sessionName={sessionName}
|
|
468
|
-
history={history}
|
|
469
|
-
/>
|
|
470
|
-
<SessionStatusBar
|
|
471
|
-
cwd={cwd}
|
|
472
|
-
permissionMode={permissionMode}
|
|
473
|
-
modelId={props.modelId}
|
|
474
|
-
providerType={props.providerType}
|
|
475
|
-
sessionId={sessionId}
|
|
476
|
-
isThinking={isThinking}
|
|
477
|
-
activeToolCount={activeTools.length}
|
|
478
|
-
activeBackgroundTaskCount={activeBackgroundTaskCount}
|
|
479
|
-
hasPendingPrompt={pendingPrompt !== null}
|
|
480
|
-
contextState={contextState}
|
|
481
|
-
sessionName={sessionName}
|
|
482
|
-
settings={statusLineSettings}
|
|
483
|
-
activeAgentLabel={activeAgentLabel}
|
|
484
|
-
gitRefreshToken={gitRefreshToken}
|
|
485
|
-
/>
|
|
486
|
-
</Box>
|
|
487
|
-
);
|
|
488
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Box, Text } from 'ink';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { formatBackgroundTaskRow } from './background-task-row-format.js';
|
|
5
|
-
|
|
6
|
-
import type { IExecutionWorkspaceEntry } from '@robota-sdk/agent-interface-transport';
|
|
7
|
-
|
|
8
|
-
interface IProps {
|
|
9
|
-
entries: IExecutionWorkspaceEntry[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function BackgroundTaskPanel({ entries }: IProps): React.ReactElement | null {
|
|
13
|
-
if (entries.length === 0) return null;
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
17
|
-
<Text color="cyan" bold>
|
|
18
|
-
Background work
|
|
19
|
-
</Text>
|
|
20
|
-
{entries.map((entry, index) => {
|
|
21
|
-
const row = formatBackgroundTaskRow(entry, { isLast: index === entries.length - 1 });
|
|
22
|
-
return (
|
|
23
|
-
<Text key={entry.id}>
|
|
24
|
-
{`${row.connector} `}
|
|
25
|
-
<Text color={row.color}>{row.marker}</Text>
|
|
26
|
-
{` ${row.label}`}
|
|
27
|
-
{row.segments.map((segment, segmentIndex) => (
|
|
28
|
-
<Text key={`${segment}-${segmentIndex}`} dimColor>{` · ${segment}`}</Text>
|
|
29
|
-
))}
|
|
30
|
-
{row.preview ? <Text dimColor>{` · ${row.preview}`}</Text> : null}
|
|
31
|
-
</Text>
|
|
32
|
-
);
|
|
33
|
-
})}
|
|
34
|
-
</Box>
|
|
35
|
-
);
|
|
36
|
-
}
|