@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,33 +0,0 @@
|
|
|
1
|
-
import { createSystemMessage, createUserMessage } from '@robota-sdk/agent-core';
|
|
2
|
-
|
|
3
|
-
import type { IAIProvider } from '@robota-sdk/agent-core';
|
|
4
|
-
|
|
5
|
-
const SYSTEM_PROMPT =
|
|
6
|
-
'You generate short session titles. Respond with ONLY a 3-5 word lowercase-hyphenated title (e.g. refactor-auth-middleware). No explanation, no punctuation, no quotes.';
|
|
7
|
-
|
|
8
|
-
const MAX_FIRST_MESSAGE_CHARS = 200;
|
|
9
|
-
|
|
10
|
-
function sanitizeName(raw: string): string {
|
|
11
|
-
return raw
|
|
12
|
-
.toLowerCase()
|
|
13
|
-
.replace(/[^a-z0-9\s-]/g, '')
|
|
14
|
-
.trim()
|
|
15
|
-
.replace(/\s+/g, '-')
|
|
16
|
-
.replace(/-+/g, '-')
|
|
17
|
-
.slice(0, 60);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function generateSessionName(
|
|
21
|
-
provider: IAIProvider,
|
|
22
|
-
firstMessage: string,
|
|
23
|
-
): Promise<string> {
|
|
24
|
-
const truncated = firstMessage.slice(0, MAX_FIRST_MESSAGE_CHARS);
|
|
25
|
-
const response = await provider.chat(
|
|
26
|
-
[createSystemMessage(SYSTEM_PROMPT), createUserMessage(truncated)],
|
|
27
|
-
{ maxTokens: 20 },
|
|
28
|
-
);
|
|
29
|
-
const raw = typeof response.content === 'string' ? response.content : '';
|
|
30
|
-
const name = sanitizeName(raw);
|
|
31
|
-
if (!name || name.length < 3) return sanitizeName(firstMessage);
|
|
32
|
-
return name;
|
|
33
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export type TStatusActivityKind = 'tools' | 'thinking' | 'background' | 'queued' | 'idle';
|
|
2
|
-
|
|
3
|
-
export interface IStatusActivityInput {
|
|
4
|
-
isThinking: boolean;
|
|
5
|
-
activeToolCount: number;
|
|
6
|
-
activeBackgroundTaskCount: number;
|
|
7
|
-
hasPendingPrompt: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface IStatusActivity {
|
|
11
|
-
kind: TStatusActivityKind;
|
|
12
|
-
label: string;
|
|
13
|
-
color: string;
|
|
14
|
-
segments: string[];
|
|
15
|
-
text: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const NO_ACTIVE_ITEMS = 0;
|
|
19
|
-
|
|
20
|
-
export function formatStatusActivity(input: IStatusActivityInput): IStatusActivity {
|
|
21
|
-
const base = getPrimaryActivity(input);
|
|
22
|
-
const segments = input.hasPendingPrompt && base.kind !== 'queued' ? ['queued'] : [];
|
|
23
|
-
const text = [base.label, ...segments].join(' · ');
|
|
24
|
-
return { ...base, segments, text };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function getPrimaryActivity(
|
|
28
|
-
input: IStatusActivityInput,
|
|
29
|
-
): Omit<IStatusActivity, 'segments' | 'text'> {
|
|
30
|
-
if (input.activeToolCount > NO_ACTIVE_ITEMS) {
|
|
31
|
-
return {
|
|
32
|
-
kind: 'tools',
|
|
33
|
-
label: `Tools (${input.activeToolCount})`,
|
|
34
|
-
color: 'cyan',
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (input.isThinking) {
|
|
38
|
-
return {
|
|
39
|
-
kind: 'thinking',
|
|
40
|
-
label: 'Thinking',
|
|
41
|
-
color: 'yellow',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
if (input.activeBackgroundTaskCount > NO_ACTIVE_ITEMS) {
|
|
45
|
-
return {
|
|
46
|
-
kind: 'background',
|
|
47
|
-
label: `Background (${input.activeBackgroundTaskCount})`,
|
|
48
|
-
color: 'cyan',
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (input.hasPendingPrompt) {
|
|
52
|
-
return {
|
|
53
|
-
kind: 'queued',
|
|
54
|
-
label: 'Queued',
|
|
55
|
-
color: 'yellow',
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
kind: 'idle',
|
|
60
|
-
label: 'Idle',
|
|
61
|
-
color: 'gray',
|
|
62
|
-
};
|
|
63
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { ITuiCliAdapter } from './tui-cli-adapter.js';
|
|
4
|
-
|
|
5
|
-
const TuiCliAdapterContext = createContext<ITuiCliAdapter | null>(null);
|
|
6
|
-
|
|
7
|
-
export const TuiCliAdapterProvider = TuiCliAdapterContext.Provider;
|
|
8
|
-
|
|
9
|
-
export function useTuiCliAdapter(): ITuiCliAdapter {
|
|
10
|
-
const adapter = useContext(TuiCliAdapterContext);
|
|
11
|
-
if (!adapter) throw new Error('TuiCliAdapterContext not provided');
|
|
12
|
-
return adapter;
|
|
13
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { TUniversalValue } from '@robota-sdk/agent-core';
|
|
2
|
-
import type { CommandRegistry } from '@robota-sdk/agent-framework';
|
|
3
|
-
import type {
|
|
4
|
-
IStatusLineCommandSettings,
|
|
5
|
-
TStatusLineCommandSettingsPatch,
|
|
6
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
7
|
-
|
|
8
|
-
export interface ITuiCliAdapter {
|
|
9
|
-
getUserSettingsPath(): string;
|
|
10
|
-
readSettings(path: string): Record<string, TUniversalValue>;
|
|
11
|
-
writeSettings(path: string, settings: Record<string, TUniversalValue>): void;
|
|
12
|
-
deleteSettings(path: string): boolean;
|
|
13
|
-
applyStatusLineSettings(
|
|
14
|
-
path: string,
|
|
15
|
-
patch: TStatusLineCommandSettingsPatch,
|
|
16
|
-
): IStatusLineCommandSettings;
|
|
17
|
-
reloadPluginCommandSource(registry: CommandRegistry): void;
|
|
18
|
-
applyActiveModelChange(
|
|
19
|
-
cwd: string,
|
|
20
|
-
modelId: string,
|
|
21
|
-
options?: { providerOverride?: string },
|
|
22
|
-
): { applied: boolean };
|
|
23
|
-
getGitBranch(cwd: string): string | undefined;
|
|
24
|
-
getProviderDisplayName(type: string): string;
|
|
25
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TuiStateManager — pure TypeScript rendering state manager.
|
|
3
|
-
*
|
|
4
|
-
* Converts InteractiveSession events into rendering state.
|
|
5
|
-
* No React dependency. Fully unit-testable.
|
|
6
|
-
*
|
|
7
|
-
* React hook (useTuiChannel) subscribes to onChange
|
|
8
|
-
* and reads state for rendering.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { IContextWindowState, IHistoryEntry } from '@robota-sdk/agent-core';
|
|
12
|
-
import type {
|
|
13
|
-
IExecutionResult,
|
|
14
|
-
IExecutionWorkspaceSnapshot,
|
|
15
|
-
IToolState,
|
|
16
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
17
|
-
|
|
18
|
-
/** Max messages kept in rendering state */
|
|
19
|
-
const MAX_RENDERED_MESSAGES = 100;
|
|
20
|
-
|
|
21
|
-
/** Debounce interval for streaming text notify (limits renderMarkdown frequency) */
|
|
22
|
-
const STREAMING_DEBOUNCE_MS = 300;
|
|
23
|
-
export interface IContextState {
|
|
24
|
-
percentage: number;
|
|
25
|
-
usedTokens: number;
|
|
26
|
-
maxTokens: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Create a debounced notify — schedules at most one call per interval. */
|
|
30
|
-
function createDebouncedNotify(
|
|
31
|
-
notify: () => void,
|
|
32
|
-
ms: number,
|
|
33
|
-
): { schedule: () => void; flush: () => void } {
|
|
34
|
-
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
35
|
-
return {
|
|
36
|
-
schedule() {
|
|
37
|
-
if (!timer) {
|
|
38
|
-
timer = setTimeout(() => {
|
|
39
|
-
timer = null;
|
|
40
|
-
notify();
|
|
41
|
-
}, ms);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
flush() {
|
|
45
|
-
if (timer) {
|
|
46
|
-
clearTimeout(timer);
|
|
47
|
-
timer = null;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class TuiStateManager {
|
|
54
|
-
// ── Rendering state ───────────────────────────────────────────
|
|
55
|
-
history: IHistoryEntry[] = [];
|
|
56
|
-
streamingText = '';
|
|
57
|
-
activeTools: IToolState[] = [];
|
|
58
|
-
isThinking = false;
|
|
59
|
-
isAborting = false;
|
|
60
|
-
pendingPrompt: string | null = null;
|
|
61
|
-
contextState: IContextState = { percentage: 0, usedTokens: 0, maxTokens: 0 };
|
|
62
|
-
executionWorkspaceSnapshot: IExecutionWorkspaceSnapshot | null = null;
|
|
63
|
-
selectedExecutionEntryId: string | undefined;
|
|
64
|
-
|
|
65
|
-
/** Called after any state change. React hook sets this to trigger re-render. */
|
|
66
|
-
onChange: (() => void) | null = null;
|
|
67
|
-
|
|
68
|
-
// ── Internal ──────────────────────────────────────────────────
|
|
69
|
-
private streamBuf = '';
|
|
70
|
-
private debouncedStreamNotify = createDebouncedNotify(() => this.notify(), STREAMING_DEBOUNCE_MS);
|
|
71
|
-
|
|
72
|
-
private notify(): void {
|
|
73
|
-
this.onChange?.();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ── Event handlers (InteractiveSession → state) ───────────────
|
|
77
|
-
|
|
78
|
-
onTextDelta = (delta: string): void => {
|
|
79
|
-
this.streamBuf += delta;
|
|
80
|
-
this.streamingText = this.streamBuf;
|
|
81
|
-
this.debouncedStreamNotify.schedule();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
onToolStart = (state: IToolState): void => {
|
|
85
|
-
this.activeTools = [...this.activeTools, state];
|
|
86
|
-
this.notify();
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
onToolEnd = (state: IToolState): void => {
|
|
90
|
-
// findLastIndex: when same tool runs concurrently, match the most recently started instance
|
|
91
|
-
const idx = this.activeTools.findLastIndex((t) => t.toolName === state.toolName && t.isRunning);
|
|
92
|
-
if (idx !== -1) {
|
|
93
|
-
const updated = [...this.activeTools];
|
|
94
|
-
updated[idx] = state;
|
|
95
|
-
this.activeTools = updated;
|
|
96
|
-
}
|
|
97
|
-
this.notify();
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
onThinking = (thinking: boolean): void => {
|
|
101
|
-
this.isThinking = thinking;
|
|
102
|
-
if (thinking) {
|
|
103
|
-
// Clear at START of new execution (preserves previous result until next)
|
|
104
|
-
this.debouncedStreamNotify.flush();
|
|
105
|
-
this.streamBuf = '';
|
|
106
|
-
this.streamingText = '';
|
|
107
|
-
this.activeTools = [];
|
|
108
|
-
} else {
|
|
109
|
-
this.isAborting = false;
|
|
110
|
-
this.activeTools = [];
|
|
111
|
-
}
|
|
112
|
-
this.notify();
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
onComplete = (result: IExecutionResult): void => {
|
|
116
|
-
// Tool summary is now in messages (pushed by InteractiveSession)
|
|
117
|
-
// Clear streaming display
|
|
118
|
-
this.debouncedStreamNotify.flush();
|
|
119
|
-
this.streamBuf = '';
|
|
120
|
-
this.streamingText = '';
|
|
121
|
-
this.activeTools = [];
|
|
122
|
-
this.contextState = {
|
|
123
|
-
percentage: result.contextState.usedPercentage,
|
|
124
|
-
usedTokens: result.contextState.usedTokens,
|
|
125
|
-
maxTokens: result.contextState.maxTokens,
|
|
126
|
-
};
|
|
127
|
-
this.notify();
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
onInterrupted = (): void => {
|
|
131
|
-
// Tool summary is now in messages
|
|
132
|
-
this.debouncedStreamNotify.flush();
|
|
133
|
-
this.streamBuf = '';
|
|
134
|
-
this.streamingText = '';
|
|
135
|
-
this.activeTools = [];
|
|
136
|
-
this.notify();
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
onError = (): void => {
|
|
140
|
-
// Tool summary is now in messages
|
|
141
|
-
this.debouncedStreamNotify.flush();
|
|
142
|
-
this.streamBuf = '';
|
|
143
|
-
this.streamingText = '';
|
|
144
|
-
this.activeTools = [];
|
|
145
|
-
this.notify();
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
onContextUpdate = (state: IContextWindowState): void => {
|
|
149
|
-
this.setContextState({
|
|
150
|
-
percentage: state.usedPercentage,
|
|
151
|
-
usedTokens: state.usedTokens,
|
|
152
|
-
maxTokens: state.maxTokens,
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// ── State updates from external sources ───────────────────────
|
|
157
|
-
|
|
158
|
-
/** Sync history from InteractiveSession */
|
|
159
|
-
syncHistory(entries: IHistoryEntry[]): void {
|
|
160
|
-
if (entries.length === 0) return;
|
|
161
|
-
this.history =
|
|
162
|
-
entries.length > MAX_RENDERED_MESSAGES ? entries.slice(-MAX_RENDERED_MESSAGES) : [...entries];
|
|
163
|
-
this.notify();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/** Add a single history entry */
|
|
167
|
-
addEntry(entry: IHistoryEntry): void {
|
|
168
|
-
const updated = [...this.history, entry];
|
|
169
|
-
this.history =
|
|
170
|
-
updated.length > MAX_RENDERED_MESSAGES ? updated.slice(-MAX_RENDERED_MESSAGES) : updated;
|
|
171
|
-
this.notify();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
clearHistory(): void {
|
|
175
|
-
this.history = [];
|
|
176
|
-
this.debouncedStreamNotify.flush();
|
|
177
|
-
this.streamBuf = '';
|
|
178
|
-
this.streamingText = '';
|
|
179
|
-
this.activeTools = [];
|
|
180
|
-
this.notify();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/** Update pending prompt state */
|
|
184
|
-
setPendingPrompt(prompt: string | null): void {
|
|
185
|
-
this.pendingPrompt = prompt;
|
|
186
|
-
this.notify();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/** Set aborting flag */
|
|
190
|
-
setAborting(aborting: boolean): void {
|
|
191
|
-
this.isAborting = aborting;
|
|
192
|
-
this.notify();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/** Update context state */
|
|
196
|
-
setContextState(state: IContextState): void {
|
|
197
|
-
this.contextState = state;
|
|
198
|
-
this.notify();
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
syncExecutionWorkspaceSnapshot(snapshot: IExecutionWorkspaceSnapshot): void {
|
|
202
|
-
const currentSelection = this.selectedExecutionEntryId;
|
|
203
|
-
const hasCurrentSelection =
|
|
204
|
-
currentSelection !== undefined &&
|
|
205
|
-
snapshot.entries.some((entry) => entry.id === currentSelection);
|
|
206
|
-
const selectedExecutionEntryId = hasCurrentSelection
|
|
207
|
-
? currentSelection
|
|
208
|
-
: (snapshot.selectedEntryId ?? snapshot.entries[0]?.id);
|
|
209
|
-
this.executionWorkspaceSnapshot = {
|
|
210
|
-
...snapshot,
|
|
211
|
-
...(selectedExecutionEntryId ? { selectedEntryId: selectedExecutionEntryId } : {}),
|
|
212
|
-
};
|
|
213
|
-
this.selectedExecutionEntryId = selectedExecutionEntryId;
|
|
214
|
-
this.notify();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
selectExecutionWorkspaceEntry(entryId: string): void {
|
|
218
|
-
if (!this.executionWorkspaceSnapshot?.entries.some((entry) => entry.id === entryId)) return;
|
|
219
|
-
this.selectedExecutionEntryId = entryId;
|
|
220
|
-
this.executionWorkspaceSnapshot = {
|
|
221
|
-
...this.executionWorkspaceSnapshot,
|
|
222
|
-
selectedEntryId: entryId,
|
|
223
|
-
};
|
|
224
|
-
this.notify();
|
|
225
|
-
}
|
|
226
|
-
}
|
package/src/tui/tui-transport.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { renderApp, type IRenderOptions } from './render.js';
|
|
2
|
-
|
|
3
|
-
import type { TUniversalValue } from '@robota-sdk/agent-core';
|
|
4
|
-
import type {
|
|
5
|
-
IConfigurableTransport,
|
|
6
|
-
IInteractiveSession,
|
|
7
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
8
|
-
|
|
9
|
-
export class TuiTransport implements IConfigurableTransport<IInteractiveSession> {
|
|
10
|
-
readonly name = 'tui';
|
|
11
|
-
readonly defaultEnabled = true;
|
|
12
|
-
readonly optionsSchema = {};
|
|
13
|
-
|
|
14
|
-
private readonly options: IRenderOptions;
|
|
15
|
-
|
|
16
|
-
constructor(options: IRenderOptions) {
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
attach(_session: IInteractiveSession): void {
|
|
21
|
-
// TuiTransport creates its own InteractiveSession internally via TuiInteractionChannel.
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async start(): Promise<void> {
|
|
25
|
-
await renderApp(this.options);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async stop(): Promise<void> {
|
|
29
|
-
// Ink exits when the user triggers shutdown from within the TUI.
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
validateOptions(_options: Record<string, TUniversalValue>): boolean {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/tui/types.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** UI-layer permission types for the Ink TUI */
|
|
2
|
-
|
|
3
|
-
import type { TToolArgs } from '@robota-sdk/agent-core';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Permission result: true (allow once), false (deny), 'allow-session' (remember for session),
|
|
7
|
-
* or 'allow-project' (persist to .robota/settings.local.json).
|
|
8
|
-
*/
|
|
9
|
-
export type TPermissionResult = boolean | 'allow-session' | 'allow-project';
|
|
10
|
-
|
|
11
|
-
export interface IPermissionRequest {
|
|
12
|
-
toolName: string;
|
|
13
|
-
toolArgs: TToolArgs;
|
|
14
|
-
resolve: (result: TPermissionResult) => void;
|
|
15
|
-
}
|