@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,130 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
applyConfirmPromptInput,
|
|
4
|
-
getConfirmPromptInputAction,
|
|
5
|
-
} from '../flows/confirm-prompt-flow.js';
|
|
6
|
-
import {
|
|
7
|
-
applyPermissionPromptInput,
|
|
8
|
-
getPermissionPromptInputAction,
|
|
9
|
-
PERMISSION_PROMPT_OPTIONS,
|
|
10
|
-
} from '../flows/permission-prompt-flow.js';
|
|
11
|
-
import { createSelectionFlowState } from '../flows/selection-flow.js';
|
|
12
|
-
|
|
13
|
-
describe('confirm prompt flow', () => {
|
|
14
|
-
it('Given two options When y shortcut is mapped and applied Then first option is selected', () => {
|
|
15
|
-
const action = getConfirmPromptInputAction('y', {}, 2);
|
|
16
|
-
expect(action).toEqual({ type: 'shortcut', index: 0 });
|
|
17
|
-
|
|
18
|
-
const result = applyConfirmPromptInput(createSelectionFlowState(), action!, 2);
|
|
19
|
-
|
|
20
|
-
expect(result.effect).toEqual({ type: 'select', index: 0 });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('Given more than two options When y or n is typed Then shortcuts are ignored', () => {
|
|
24
|
-
expect(getConfirmPromptInputAction('y', {}, 3)).toBeUndefined();
|
|
25
|
-
expect(getConfirmPromptInputAction('n', {}, 3)).toBeUndefined();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('Given selection moved right When enter is applied Then current option is selected', () => {
|
|
29
|
-
const moved = applyConfirmPromptInput(createSelectionFlowState(), 'next', 2).state;
|
|
30
|
-
|
|
31
|
-
const result = applyConfirmPromptInput(moved, 'select', 2);
|
|
32
|
-
|
|
33
|
-
expect(result.effect).toEqual({ type: 'select', index: 1 });
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('Given prompt is resolved When shortcut is applied Then no second selection is emitted', () => {
|
|
37
|
-
const selected = applyConfirmPromptInput(createSelectionFlowState(), 'select', 2).state;
|
|
38
|
-
|
|
39
|
-
const result = applyConfirmPromptInput(selected, { type: 'shortcut', index: 1 }, 2);
|
|
40
|
-
|
|
41
|
-
expect(result.effect).toEqual({ type: 'none' });
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe('permission prompt flow', () => {
|
|
46
|
-
it('Given y shortcut When applied Then allow decision is emitted', () => {
|
|
47
|
-
const action = getPermissionPromptInputAction('y', {});
|
|
48
|
-
|
|
49
|
-
const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
|
|
50
|
-
|
|
51
|
-
expect(result.effect).toEqual({ type: 'resolve', decision: true });
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('Given a shortcut When applied Then allow-session decision is emitted', () => {
|
|
55
|
-
const action = getPermissionPromptInputAction('a', {});
|
|
56
|
-
|
|
57
|
-
const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
|
|
58
|
-
|
|
59
|
-
expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('Given p or 3 shortcut When applied Then allow-project decision is emitted', () => {
|
|
63
|
-
expect(
|
|
64
|
-
applyPermissionPromptInput(
|
|
65
|
-
createSelectionFlowState(),
|
|
66
|
-
getPermissionPromptInputAction('p', {})!,
|
|
67
|
-
).effect,
|
|
68
|
-
).toEqual({ type: 'resolve', decision: 'allow-project' });
|
|
69
|
-
expect(
|
|
70
|
-
applyPermissionPromptInput(
|
|
71
|
-
createSelectionFlowState(),
|
|
72
|
-
getPermissionPromptInputAction('3', {})!,
|
|
73
|
-
).effect,
|
|
74
|
-
).toEqual({ type: 'resolve', decision: 'allow-project' });
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('Given deny shortcuts When applied Then false decision is emitted', () => {
|
|
78
|
-
expect(
|
|
79
|
-
applyPermissionPromptInput(
|
|
80
|
-
createSelectionFlowState(),
|
|
81
|
-
getPermissionPromptInputAction('n', {})!,
|
|
82
|
-
).effect,
|
|
83
|
-
).toEqual({ type: 'resolve', decision: false });
|
|
84
|
-
expect(
|
|
85
|
-
applyPermissionPromptInput(
|
|
86
|
-
createSelectionFlowState(),
|
|
87
|
-
getPermissionPromptInputAction('4', {})!,
|
|
88
|
-
).effect,
|
|
89
|
-
).toEqual({ type: 'resolve', decision: false });
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('Given arrow navigation When enter is applied Then selected permission is resolved', () => {
|
|
93
|
-
const moved = applyPermissionPromptInput(createSelectionFlowState(), 'next').state;
|
|
94
|
-
|
|
95
|
-
const result = applyPermissionPromptInput(moved, 'select');
|
|
96
|
-
|
|
97
|
-
expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('Given permission is resolved When shortcut is applied Then no second decision is emitted', () => {
|
|
101
|
-
const resolved = applyPermissionPromptInput(createSelectionFlowState(), 'select').state;
|
|
102
|
-
|
|
103
|
-
const result = applyPermissionPromptInput(resolved, { type: 'shortcut', index: 2 });
|
|
104
|
-
|
|
105
|
-
expect(result.effect).toEqual({ type: 'none' });
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// CLI-030 TC-03: [s] option is shown
|
|
109
|
-
it('Given PERMISSION_PROMPT_OPTIONS When inspected Then session option contains [s] hint', () => {
|
|
110
|
-
expect(PERMISSION_PROMPT_OPTIONS[1]).toContain('[s]');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// CLI-030 TC-03: s key maps to allow-session
|
|
114
|
-
it('Given s shortcut When applied Then allow-session decision is emitted', () => {
|
|
115
|
-
const action = getPermissionPromptInputAction('s', {});
|
|
116
|
-
|
|
117
|
-
const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
|
|
118
|
-
|
|
119
|
-
expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// CLI-030 TC-04: allow-once (y) does not add to session list
|
|
123
|
-
it('Given y (allow-once) shortcut When applied Then true decision is emitted (not allow-session)', () => {
|
|
124
|
-
const action = getPermissionPromptInputAction('y', {});
|
|
125
|
-
|
|
126
|
-
const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
|
|
127
|
-
|
|
128
|
-
expect(result.effect).toEqual({ type: 'resolve', decision: true });
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
3
|
-
import { render } from 'ink-testing-library';
|
|
4
|
-
import ConfirmPrompt from '../ConfirmPrompt.js';
|
|
5
|
-
|
|
6
|
-
const delay = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
7
|
-
|
|
8
|
-
describe('ConfirmPrompt', () => {
|
|
9
|
-
it('renders message text', () => {
|
|
10
|
-
const { lastFrame } = render(<ConfirmPrompt message="Are you sure?" onSelect={() => {}} />);
|
|
11
|
-
expect(lastFrame()).toContain('Are you sure?');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('renders default Yes/No options', () => {
|
|
15
|
-
const { lastFrame } = render(<ConfirmPrompt message="Confirm?" onSelect={() => {}} />);
|
|
16
|
-
const frame = lastFrame()!;
|
|
17
|
-
expect(frame).toContain('Yes');
|
|
18
|
-
expect(frame).toContain('No');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('renders custom options', () => {
|
|
22
|
-
const { lastFrame } = render(
|
|
23
|
-
<ConfirmPrompt message="Pick" options={['A', 'B', 'C']} onSelect={() => {}} />,
|
|
24
|
-
);
|
|
25
|
-
const frame = lastFrame()!;
|
|
26
|
-
expect(frame).toContain('A');
|
|
27
|
-
expect(frame).toContain('B');
|
|
28
|
-
expect(frame).toContain('C');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('first option is highlighted by default', () => {
|
|
32
|
-
const { lastFrame } = render(<ConfirmPrompt message="Confirm?" onSelect={() => {}} />);
|
|
33
|
-
const frame = lastFrame()!;
|
|
34
|
-
// The selected item has '> ' prefix
|
|
35
|
-
expect(frame).toContain('> Yes');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('selects first option on Enter', () => {
|
|
39
|
-
const onSelect = vi.fn();
|
|
40
|
-
const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
|
|
41
|
-
stdin.write('\r');
|
|
42
|
-
expect(onSelect).toHaveBeenCalledWith(0);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('navigates to second option with arrow down and selects', async () => {
|
|
46
|
-
const onSelect = vi.fn();
|
|
47
|
-
const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
|
|
48
|
-
// Arrow down (move to No)
|
|
49
|
-
stdin.write('\x1b[B');
|
|
50
|
-
await delay(50);
|
|
51
|
-
stdin.write('\r');
|
|
52
|
-
expect(onSelect).toHaveBeenCalledWith(1);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('y shortcut selects first option (Yes)', () => {
|
|
56
|
-
const onSelect = vi.fn();
|
|
57
|
-
const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
|
|
58
|
-
stdin.write('y');
|
|
59
|
-
expect(onSelect).toHaveBeenCalledWith(0);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('n shortcut selects second option (No)', () => {
|
|
63
|
-
const onSelect = vi.fn();
|
|
64
|
-
const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
|
|
65
|
-
stdin.write('n');
|
|
66
|
-
expect(onSelect).toHaveBeenCalledWith(1);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('y/n shortcuts do not work with more than 2 options', () => {
|
|
70
|
-
const onSelect = vi.fn();
|
|
71
|
-
const { stdin } = render(
|
|
72
|
-
<ConfirmPrompt message="Pick" options={['A', 'B', 'C']} onSelect={onSelect} />,
|
|
73
|
-
);
|
|
74
|
-
stdin.write('y');
|
|
75
|
-
stdin.write('n');
|
|
76
|
-
expect(onSelect).not.toHaveBeenCalled();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('ignores input after selection (no double-fire)', () => {
|
|
80
|
-
const onSelect = vi.fn();
|
|
81
|
-
const { stdin } = render(<ConfirmPrompt message="Confirm?" onSelect={onSelect} />);
|
|
82
|
-
stdin.write('\r');
|
|
83
|
-
stdin.write('\r');
|
|
84
|
-
stdin.write('y');
|
|
85
|
-
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import { render } from 'ink-testing-library';
|
|
4
|
-
import type {
|
|
5
|
-
IExecutionWorkspaceEntry,
|
|
6
|
-
IExecutionWorkspaceSnapshot,
|
|
7
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
8
|
-
import ExecutionWorkspaceSwitcher from '../ExecutionWorkspaceSwitcher.js';
|
|
9
|
-
import ExecutionWorkspaceDetailPane from '../ExecutionWorkspaceDetailPane.js';
|
|
10
|
-
|
|
11
|
-
function makeEntry(overrides: Partial<IExecutionWorkspaceEntry>): IExecutionWorkspaceEntry {
|
|
12
|
-
return {
|
|
13
|
-
id: 'main:session_1',
|
|
14
|
-
sourceId: 'session_1',
|
|
15
|
-
kind: 'main_thread',
|
|
16
|
-
origin: { kind: 'user_prompt', sessionId: 'session_1' },
|
|
17
|
-
status: 'idle',
|
|
18
|
-
title: 'Main thread',
|
|
19
|
-
subtitle: '2 history entries',
|
|
20
|
-
unread: false,
|
|
21
|
-
attention: 'none',
|
|
22
|
-
visibility: 'default',
|
|
23
|
-
updatedAt: '2026-05-09T00:00:00.000Z',
|
|
24
|
-
controls: ['select'],
|
|
25
|
-
...overrides,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function makeSnapshot(): IExecutionWorkspaceSnapshot {
|
|
30
|
-
return {
|
|
31
|
-
sessionId: 'session_1',
|
|
32
|
-
selectedEntryId: 'main:session_1',
|
|
33
|
-
updatedAt: '2026-05-09T00:00:00.000Z',
|
|
34
|
-
entries: [
|
|
35
|
-
makeEntry({ id: 'main:session_1', kind: 'main_thread', title: 'Main thread' }),
|
|
36
|
-
makeEntry({
|
|
37
|
-
id: 'task:agent_1',
|
|
38
|
-
sourceId: 'agent_1',
|
|
39
|
-
kind: 'background_task',
|
|
40
|
-
taskKind: 'agent',
|
|
41
|
-
status: 'running',
|
|
42
|
-
title: 'Explore',
|
|
43
|
-
subtitle: 'general-purpose',
|
|
44
|
-
preview: 'Inspect task layer',
|
|
45
|
-
controls: ['select', 'cancel'],
|
|
46
|
-
}),
|
|
47
|
-
],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
describe('ExecutionWorkspaceSwitcher', () => {
|
|
52
|
-
it('renders main and background entries with selected radio markers', () => {
|
|
53
|
-
const { lastFrame } = render(
|
|
54
|
-
<ExecutionWorkspaceSwitcher
|
|
55
|
-
snapshot={makeSnapshot()}
|
|
56
|
-
selectedEntryId="task:agent_1"
|
|
57
|
-
onSelect={vi.fn()}
|
|
58
|
-
onClose={vi.fn()}
|
|
59
|
-
/>,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const frame = lastFrame()!;
|
|
63
|
-
expect(frame).toContain('Execution workspace');
|
|
64
|
-
expect(frame).toContain('○ Main thread');
|
|
65
|
-
expect(frame).toContain('● Explore agent');
|
|
66
|
-
expect(frame).toContain('Inspect task layer');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('commits the highlighted entry on enter without invoking task controls', () => {
|
|
70
|
-
const onSelect = vi.fn();
|
|
71
|
-
const { stdin } = render(
|
|
72
|
-
<ExecutionWorkspaceSwitcher
|
|
73
|
-
snapshot={makeSnapshot()}
|
|
74
|
-
selectedEntryId="main:session_1"
|
|
75
|
-
onSelect={onSelect}
|
|
76
|
-
onClose={vi.fn()}
|
|
77
|
-
/>,
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
stdin.write('\u001B[B');
|
|
81
|
-
stdin.write('\r');
|
|
82
|
-
|
|
83
|
-
expect(onSelect).toHaveBeenCalledWith('task:agent_1');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('renders selected entry detail records from the SDK detail page', () => {
|
|
87
|
-
const entry = makeEntry({
|
|
88
|
-
id: 'task:agent_1',
|
|
89
|
-
sourceId: 'agent_1',
|
|
90
|
-
kind: 'background_task',
|
|
91
|
-
taskKind: 'agent',
|
|
92
|
-
status: 'completed',
|
|
93
|
-
title: 'Explore',
|
|
94
|
-
preview: 'Done',
|
|
95
|
-
});
|
|
96
|
-
const { lastFrame } = render(
|
|
97
|
-
<ExecutionWorkspaceDetailPane
|
|
98
|
-
entry={entry}
|
|
99
|
-
page={{
|
|
100
|
-
entryId: 'task:agent_1',
|
|
101
|
-
records: [{ id: 'r1', kind: 'result', text: 'Final background result' }],
|
|
102
|
-
}}
|
|
103
|
-
/>,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const frame = lastFrame()!;
|
|
107
|
-
expect(frame).toContain('Viewing Explore agent');
|
|
108
|
-
expect(frame).toContain('Final background result');
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type {
|
|
3
|
-
IExecutionWorkspaceEntry,
|
|
4
|
-
IExecutionWorkspaceSnapshot,
|
|
5
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
6
|
-
import {
|
|
7
|
-
countActiveBackgroundWorkspaceEntries,
|
|
8
|
-
formatExecutionDetailRecord,
|
|
9
|
-
formatExecutionWorkspaceEntryRow,
|
|
10
|
-
getDefaultBackgroundWorkspaceEntries,
|
|
11
|
-
} from '../execution-workspace-view-model.js';
|
|
12
|
-
|
|
13
|
-
function makeEntry(overrides: Partial<IExecutionWorkspaceEntry>): IExecutionWorkspaceEntry {
|
|
14
|
-
return {
|
|
15
|
-
id: 'task:agent_1',
|
|
16
|
-
sourceId: 'agent_1',
|
|
17
|
-
kind: 'background_task',
|
|
18
|
-
origin: { kind: 'slash_command', sessionId: 'session_1', commandName: 'agent' },
|
|
19
|
-
taskKind: 'agent',
|
|
20
|
-
status: 'running',
|
|
21
|
-
title: 'Explore',
|
|
22
|
-
subtitle: 'general-purpose',
|
|
23
|
-
preview: 'Map the CLI state manager',
|
|
24
|
-
unread: false,
|
|
25
|
-
attention: 'none',
|
|
26
|
-
visibility: 'default',
|
|
27
|
-
updatedAt: '2026-05-09T00:00:00.000Z',
|
|
28
|
-
controls: ['select', 'cancel'],
|
|
29
|
-
...overrides,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function makeSnapshot(entries: readonly IExecutionWorkspaceEntry[]): IExecutionWorkspaceSnapshot {
|
|
34
|
-
return {
|
|
35
|
-
sessionId: 'session_1',
|
|
36
|
-
selectedEntryId: 'main:session_1',
|
|
37
|
-
updatedAt: '2026-05-09T00:00:00.000Z',
|
|
38
|
-
entries,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
describe('execution workspace view model', () => {
|
|
43
|
-
it('renders selected and inactive entries with radio markers', () => {
|
|
44
|
-
const row = formatExecutionWorkspaceEntryRow(makeEntry({ id: 'task:agent_1' }), {
|
|
45
|
-
selectedEntryId: 'task:agent_1',
|
|
46
|
-
});
|
|
47
|
-
const inactive = formatExecutionWorkspaceEntryRow(makeEntry({ id: 'task:process_1' }), {
|
|
48
|
-
selectedEntryId: 'task:agent_1',
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
expect(row.radio).toBe('●');
|
|
52
|
-
expect(row.title).toBe('Explore agent');
|
|
53
|
-
expect(row.subtitle).toBe('agent · general-purpose');
|
|
54
|
-
expect(row.statusLabel).toBe('running');
|
|
55
|
-
expect(inactive.radio).toBe('○');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('filters default-visible background task entries for the compact panel', () => {
|
|
59
|
-
const snapshot = makeSnapshot([
|
|
60
|
-
makeEntry({ id: 'main:session_1', kind: 'main_thread', title: 'Main thread' }),
|
|
61
|
-
makeEntry({ id: 'task:agent_1', visibility: 'default' }),
|
|
62
|
-
makeEntry({ id: 'task:agent_2', visibility: 'collapsed' }),
|
|
63
|
-
makeEntry({ id: 'group:group_1', kind: 'background_group', visibility: 'default' }),
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
expect(getDefaultBackgroundWorkspaceEntries(snapshot).map((entry) => entry.id)).toEqual([
|
|
67
|
-
'task:agent_1',
|
|
68
|
-
]);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('counts active default-visible background tasks without treating collapsed tasks as active', () => {
|
|
72
|
-
const snapshot = makeSnapshot([
|
|
73
|
-
makeEntry({ id: 'task:queued', status: 'queued' }),
|
|
74
|
-
makeEntry({ id: 'task:running', status: 'running' }),
|
|
75
|
-
makeEntry({ id: 'task:permission', status: 'waiting_permission' }),
|
|
76
|
-
makeEntry({ id: 'task:done', status: 'completed' }),
|
|
77
|
-
makeEntry({ id: 'task:hidden', status: 'running', visibility: 'collapsed' }),
|
|
78
|
-
]);
|
|
79
|
-
|
|
80
|
-
expect(countActiveBackgroundWorkspaceEntries(snapshot)).toBe(3);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('bounds detail record text without parsing runner-specific output', () => {
|
|
84
|
-
const text = formatExecutionDetailRecord({
|
|
85
|
-
id: 'record_1',
|
|
86
|
-
kind: 'process_output',
|
|
87
|
-
text: ` ${'a'.repeat(180)} `,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(text).toHaveLength(163);
|
|
91
|
-
expect(text.endsWith('...')).toBe(true);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from 'node:fs';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
createProviderSetupFlow,
|
|
5
|
-
formatProviderSetupHelpLinks,
|
|
6
|
-
getProviderSetupStep,
|
|
7
|
-
submitProviderSetupValue,
|
|
8
|
-
validateProviderSetupValue,
|
|
9
|
-
type IProviderSetupFlowState,
|
|
10
|
-
type TProviderSetupType,
|
|
11
|
-
} from '@robota-sdk/agent-command';
|
|
12
|
-
import { render, useApp } from 'ink';
|
|
13
|
-
import React from 'react';
|
|
14
|
-
|
|
15
|
-
import InteractivePrompt from '../../InteractivePrompt.js';
|
|
16
|
-
|
|
17
|
-
import type { IAIProvider, IProviderDefinition } from '@robota-sdk/agent-core';
|
|
18
|
-
import type { TCommandInteractionPrompt as TInteractivePrompt } from '@robota-sdk/agent-interface-transport';
|
|
19
|
-
|
|
20
|
-
const openaiDefaults = {
|
|
21
|
-
apiKey: '$ENV:OPENAI_API_KEY',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const providerDefinitions: readonly IProviderDefinition[] = [
|
|
25
|
-
{
|
|
26
|
-
type: 'openai',
|
|
27
|
-
defaults: openaiDefaults,
|
|
28
|
-
setupHelpLinks: [
|
|
29
|
-
{
|
|
30
|
-
kind: 'api-key',
|
|
31
|
-
label: 'OpenAI API keys',
|
|
32
|
-
url: 'https://platform.openai.com/api-keys',
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
setupSteps: [
|
|
36
|
-
{
|
|
37
|
-
key: 'model',
|
|
38
|
-
title: 'OpenAI model',
|
|
39
|
-
required: true,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
key: 'apiKey',
|
|
43
|
-
title: 'OpenAI API key',
|
|
44
|
-
defaultValue: openaiDefaults.apiKey,
|
|
45
|
-
masked: true,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
requiresApiKey: true,
|
|
49
|
-
createProvider: () => {
|
|
50
|
-
throw new Error('not used');
|
|
51
|
-
},
|
|
52
|
-
} as IProviderDefinition & { createProvider: () => IAIProvider },
|
|
53
|
-
{
|
|
54
|
-
type: 'anthropic',
|
|
55
|
-
defaults: { model: 'claude-sonnet-4-6' },
|
|
56
|
-
setupSteps: [
|
|
57
|
-
{ key: 'apiKey', title: 'Anthropic API key', required: true, masked: true },
|
|
58
|
-
{ key: 'model', title: 'Anthropic model', defaultValue: 'claude-sonnet-4-6' },
|
|
59
|
-
],
|
|
60
|
-
requiresApiKey: true,
|
|
61
|
-
createProvider: () => {
|
|
62
|
-
throw new Error('not used');
|
|
63
|
-
},
|
|
64
|
-
} as IProviderDefinition & { createProvider: () => IAIProvider },
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
const [, , outputPath, rawType] = process.argv;
|
|
68
|
-
|
|
69
|
-
if (!outputPath || (rawType !== 'openai' && rawType !== 'anthropic')) {
|
|
70
|
-
process.stderr.write('Usage: provider-setup-prompt-driver <output-path> <openai|anthropic>\n');
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function Driver({ type }: { type: TProviderSetupType }): React.ReactElement {
|
|
75
|
-
const { exit } = useApp();
|
|
76
|
-
const initial = createProviderSetupFlow(type, providerDefinitions);
|
|
77
|
-
const [state, setState] = React.useState<IProviderSetupFlowState>(initial);
|
|
78
|
-
const [prompt, setPrompt] = React.useState<TInteractivePrompt>(() => toPrompt(initial));
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<InteractivePrompt
|
|
82
|
-
prompt={prompt}
|
|
83
|
-
onSubmit={(value) => {
|
|
84
|
-
const result = submitProviderSetupValue(state, value);
|
|
85
|
-
if (result.status === 'complete') {
|
|
86
|
-
writeFileSync(outputPath, JSON.stringify(result.input), 'utf8');
|
|
87
|
-
exit();
|
|
88
|
-
setTimeout(() => process.exit(0), 0);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (result.status === 'error') {
|
|
92
|
-
throw new Error(result.message);
|
|
93
|
-
}
|
|
94
|
-
setState(result.state);
|
|
95
|
-
setPrompt(toPrompt(result.state));
|
|
96
|
-
}}
|
|
97
|
-
onCancel={() => {
|
|
98
|
-
exit();
|
|
99
|
-
setTimeout(() => process.exit(2), 0);
|
|
100
|
-
}}
|
|
101
|
-
/>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function toPrompt(flow: IProviderSetupFlowState): TInteractivePrompt {
|
|
106
|
-
const step = getProviderSetupStep(flow);
|
|
107
|
-
return {
|
|
108
|
-
kind: 'text',
|
|
109
|
-
title: step.title,
|
|
110
|
-
...toPromptDescription(flow),
|
|
111
|
-
...(step.defaultValue !== undefined ? { placeholder: step.defaultValue } : {}),
|
|
112
|
-
...(step.defaultValue !== undefined ? { allowEmpty: true } : {}),
|
|
113
|
-
...(step.masked !== undefined ? { masked: step.masked } : {}),
|
|
114
|
-
validate: (value) => validateProviderSetupValue(step, value),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function toPromptDescription(
|
|
119
|
-
flow: IProviderSetupFlowState,
|
|
120
|
-
): { description: string } | Record<string, never> {
|
|
121
|
-
const description = formatProviderSetupHelpLinks(flow.setupHelpLinks);
|
|
122
|
-
return description.length > 0 ? { description } : {};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
render(<Driver type={rawType} />);
|