@abacus-ai/cli 1.106.25007 → 2.0.0-canary.0
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/.oxlintrc.json +8 -0
- package/dist/index.mjs +12603 -0
- package/package.json +7 -39
- package/resources/abacus.ico +0 -0
- package/resources/entitlements.plist +9 -0
- package/src/__e2e__/README.md +196 -0
- package/src/__e2e__/agent-interactions.e2e.test.tsx +61 -0
- package/src/__e2e__/cli-commands.e2e.test.tsx +77 -0
- package/src/__e2e__/conversation-throttle.e2e.test.ts +453 -0
- package/src/__e2e__/conversation.e2e.test.tsx +56 -0
- package/src/__e2e__/diff-preview.e2e.test.tsx +3399 -0
- package/src/__e2e__/file-creation.e2e.test.tsx +149 -0
- package/src/__e2e__/helpers/test-helpers.ts +450 -0
- package/src/__e2e__/keyboard-navigation.e2e.test.tsx +34 -0
- package/src/__e2e__/llm-models.e2e.test.ts +402 -0
- package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +71 -0
- package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +167 -0
- package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +185 -0
- package/src/__e2e__/repl.e2e.test.tsx +78 -0
- package/src/__e2e__/shell-compatibility.e2e.test.tsx +76 -0
- package/src/__e2e__/theme-mcp.e2e.test.tsx +98 -0
- package/src/__e2e__/tool-permissions.e2e.test.tsx +66 -0
- package/src/args.ts +22 -0
- package/src/components/__tests__/react-compiler.test.tsx +78 -0
- package/src/components/__tests__/status-indicator.test.tsx +403 -0
- package/src/components/composer/__tests__/bash-runner.test.tsx +263 -0
- package/src/components/composer/agent-mode-indicator.tsx +63 -0
- package/src/components/composer/bash-runner.tsx +54 -0
- package/src/components/composer/commands/default-commands.tsx +615 -0
- package/src/components/composer/commands/handler.tsx +59 -0
- package/src/components/composer/commands/picker.tsx +273 -0
- package/src/components/composer/commands/registry.ts +233 -0
- package/src/components/composer/commands/types.ts +33 -0
- package/src/components/composer/context.tsx +88 -0
- package/src/components/composer/file-mention-picker.tsx +83 -0
- package/src/components/composer/help.tsx +44 -0
- package/src/components/composer/index.tsx +1006 -0
- package/src/components/composer/mentions.ts +57 -0
- package/src/components/composer/message-queue.tsx +70 -0
- package/src/components/composer/mode-panel.tsx +35 -0
- package/src/components/composer/modes/__tests__/bash-handler.test.tsx +755 -0
- package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +1108 -0
- package/src/components/composer/modes/bash-handler.tsx +132 -0
- package/src/components/composer/modes/bash-renderer.tsx +175 -0
- package/src/components/composer/modes/default-handlers.tsx +33 -0
- package/src/components/composer/modes/index.ts +41 -0
- package/src/components/composer/modes/types.ts +21 -0
- package/src/components/composer/persistent-shell.ts +283 -0
- package/src/components/composer/process.ts +65 -0
- package/src/components/composer/types.ts +9 -0
- package/src/components/composer/use-mention-search.ts +68 -0
- package/src/components/error-boundry.tsx +60 -0
- package/src/components/exit-message.tsx +29 -0
- package/src/components/expanded-view.tsx +74 -0
- package/src/components/file-completion.tsx +127 -0
- package/src/components/header.tsx +47 -0
- package/src/components/logo.tsx +37 -0
- package/src/components/segments.tsx +356 -0
- package/src/components/status-indicator.tsx +306 -0
- package/src/components/tool-group-summary.tsx +263 -0
- package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +312 -0
- package/src/components/tool-permissions/diff-preview.tsx +355 -0
- package/src/components/tool-permissions/index.ts +5 -0
- package/src/components/tool-permissions/permission-options.tsx +375 -0
- package/src/components/tool-permissions/permission-preview-header.tsx +57 -0
- package/src/components/tool-permissions/tool-permission-ui.tsx +398 -0
- package/src/components/tools/agent/ask-user-question.tsx +101 -0
- package/src/components/tools/agent/enter-plan-mode.tsx +49 -0
- package/src/components/tools/agent/exit-plan-mode.tsx +75 -0
- package/src/components/tools/agent/handoff-to-main.tsx +27 -0
- package/src/components/tools/agent/subagent.tsx +37 -0
- package/src/components/tools/agent/todo-write.tsx +104 -0
- package/src/components/tools/browser/close-tab.tsx +58 -0
- package/src/components/tools/browser/computer.tsx +70 -0
- package/src/components/tools/browser/get-interactive-elements.tsx +54 -0
- package/src/components/tools/browser/get-tab-content.tsx +51 -0
- package/src/components/tools/browser/navigate-to.tsx +59 -0
- package/src/components/tools/browser/new-tab.tsx +60 -0
- package/src/components/tools/browser/perform-action.tsx +63 -0
- package/src/components/tools/browser/refresh-tab.tsx +43 -0
- package/src/components/tools/browser/switch-tab.tsx +58 -0
- package/src/components/tools/filesystem/delete-file.tsx +104 -0
- package/src/components/tools/filesystem/edit.tsx +220 -0
- package/src/components/tools/filesystem/list-dir.tsx +78 -0
- package/src/components/tools/filesystem/read-file.tsx +180 -0
- package/src/components/tools/filesystem/upload-image.tsx +76 -0
- package/src/components/tools/ide/ide-diagnostics.tsx +62 -0
- package/src/components/tools/index.ts +91 -0
- package/src/components/tools/mcp/mcp-tool.tsx +158 -0
- package/src/components/tools/search/fetch-url.tsx +73 -0
- package/src/components/tools/search/file-search.tsx +78 -0
- package/src/components/tools/search/grep.tsx +90 -0
- package/src/components/tools/search/semantic-search.tsx +66 -0
- package/src/components/tools/search/web-search.tsx +71 -0
- package/src/components/tools/shared/index.tsx +48 -0
- package/src/components/tools/shared/zod-coercion.ts +35 -0
- package/src/components/tools/terminal/bash-tool-output.tsx +174 -0
- package/src/components/tools/terminal/get-terminal-output.tsx +85 -0
- package/src/components/tools/terminal/run-in-terminal.tsx +106 -0
- package/src/components/tools/types.ts +16 -0
- package/src/components/tools.tsx +66 -0
- package/src/components/ui/__tests__/divider.test.tsx +61 -0
- package/src/components/ui/__tests__/gradient.test.tsx +125 -0
- package/src/components/ui/__tests__/input.test.tsx +166 -0
- package/src/components/ui/__tests__/select.test.tsx +273 -0
- package/src/components/ui/__tests__/shimmer.test.tsx +99 -0
- package/src/components/ui/blinking-indicator.tsx +25 -0
- package/src/components/ui/divider.tsx +162 -0
- package/src/components/ui/gradient.tsx +56 -0
- package/src/components/ui/input.tsx +228 -0
- package/src/components/ui/select.tsx +151 -0
- package/src/components/ui/shimmer.tsx +84 -0
- package/src/context/agent-mode.tsx +95 -0
- package/src/context/extension-file.tsx +136 -0
- package/src/context/network-activity.tsx +45 -0
- package/src/context/notification.tsx +62 -0
- package/src/context/shell-size.tsx +49 -0
- package/src/context/shell-title.tsx +38 -0
- package/src/entrypoints/print-mode.ts +312 -0
- package/src/entrypoints/repl.tsx +401 -0
- package/src/hooks/use-agent.ts +15 -0
- package/src/hooks/use-api-client.ts +1 -0
- package/src/hooks/use-available-height.ts +8 -0
- package/src/hooks/use-cleanup.ts +29 -0
- package/src/hooks/use-interrupt-manager.ts +242 -0
- package/src/hooks/use-models.ts +22 -0
- package/src/index.ts +217 -0
- package/src/lib/__tests__/ansi.test.ts +255 -0
- package/src/lib/__tests__/cli.test.ts +122 -0
- package/src/lib/__tests__/commands.test.ts +325 -0
- package/src/lib/__tests__/constants.test.ts +15 -0
- package/src/lib/__tests__/focusables.test.ts +25 -0
- package/src/lib/__tests__/fs.test.ts +231 -0
- package/src/lib/__tests__/markdown.test.tsx +348 -0
- package/src/lib/__tests__/mcpCommandHandler.test.ts +173 -0
- package/src/lib/__tests__/mcpManagement.test.ts +38 -0
- package/src/lib/__tests__/path-paste.test.ts +144 -0
- package/src/lib/__tests__/path.test.ts +300 -0
- package/src/lib/__tests__/queries.test.ts +39 -0
- package/src/lib/__tests__/standaloneMcpService.test.ts +71 -0
- package/src/lib/__tests__/text-buffer.test.ts +328 -0
- package/src/lib/__tests__/text-utils.test.ts +32 -0
- package/src/lib/__tests__/timing.test.ts +78 -0
- package/src/lib/__tests__/utils.test.ts +238 -0
- package/src/lib/__tests__/vim-buffer-actions.test.ts +154 -0
- package/src/lib/ansi.ts +150 -0
- package/src/lib/cli-push-server.ts +112 -0
- package/src/lib/cli.ts +44 -0
- package/src/lib/clipboard.ts +226 -0
- package/src/lib/command-utils.ts +93 -0
- package/src/lib/commands.ts +270 -0
- package/src/lib/constants.ts +3 -0
- package/src/lib/extension-connection.ts +181 -0
- package/src/lib/focusables.ts +7 -0
- package/src/lib/fs.ts +533 -0
- package/src/lib/markdown/code-block.tsx +63 -0
- package/src/lib/markdown/index.ts +4 -0
- package/src/lib/markdown/link.tsx +19 -0
- package/src/lib/markdown/markdown.tsx +372 -0
- package/src/lib/markdown/types.ts +15 -0
- package/src/lib/mcpCommandHandler.ts +121 -0
- package/src/lib/mcpManagement.ts +44 -0
- package/src/lib/path-paste.ts +185 -0
- package/src/lib/path.ts +179 -0
- package/src/lib/queries.ts +15 -0
- package/src/lib/standaloneMcpService.ts +688 -0
- package/src/lib/status-utils.ts +237 -0
- package/src/lib/test-utils.tsx +72 -0
- package/src/lib/text-buffer.ts +2415 -0
- package/src/lib/text-utils.ts +272 -0
- package/src/lib/timing.ts +63 -0
- package/src/lib/types.ts +295 -0
- package/src/lib/utils.ts +182 -0
- package/src/lib/vim-buffer-actions.ts +732 -0
- package/src/providers/agent.tsx +1075 -0
- package/src/providers/api-client.tsx +43 -0
- package/src/services/logger.ts +85 -0
- package/src/terminal/detection.ts +187 -0
- package/src/terminal/exit.ts +279 -0
- package/src/terminal/notification.ts +83 -0
- package/src/terminal/progress.ts +201 -0
- package/src/terminal/setup.ts +797 -0
- package/src/terminal/suspend.ts +58 -0
- package/src/terminal/types.ts +51 -0
- package/src/theme/context.tsx +57 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/themed.tsx +35 -0
- package/src/theme/themes.json +546 -0
- package/src/theme/types.ts +110 -0
- package/src/tools/types.ts +59 -0
- package/src/tools/utils/__tests__/zod-coercion.test.ts +33 -0
- package/src/tools/utils/tool-ui-components.tsx +631 -0
- package/src/tools/utils/zod-coercion.ts +35 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +29 -0
- package/tsconfig.test.json +27 -0
- package/tsdown.config.ts +17 -0
- package/vitest.config.ts +76 -0
- package/README.md +0 -28
- package/dist/index.js +0 -26
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import type { PermissionDecision } from "@codellm/agent";
|
|
2
|
+
|
|
3
|
+
import { View, Text } from "@codellm/jar";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
|
|
6
|
+
import type { PendingToolPermission, ToolPermissionResult } from "../../providers/agent.js";
|
|
7
|
+
|
|
8
|
+
import { AgentMode } from "../../components/composer/types.js";
|
|
9
|
+
import { useAgentMode } from "../../context/agent-mode.js";
|
|
10
|
+
import { Markdown } from "../../lib/markdown/markdown.js";
|
|
11
|
+
import { CodePreview } from "../tools/shared/index.js";
|
|
12
|
+
import { AskUserQuestionPermissionUI } from "./ask-user-question-permission-ui.js";
|
|
13
|
+
import { DiffPreview } from "./diff-preview.js";
|
|
14
|
+
import { PermissionOptions, type PermissionOption } from "./permission-options.js";
|
|
15
|
+
import { PermissionPreviewHeader, dashedBorderStyle } from "./permission-preview-header.js";
|
|
16
|
+
|
|
17
|
+
interface ToolPermissionUIProps {
|
|
18
|
+
pendingTool: PendingToolPermission;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function mapResultToDecision(result: ToolPermissionResult): PermissionDecision {
|
|
22
|
+
if (result.decision === "accept" && result.userMessage) {
|
|
23
|
+
return { type: "accept_with_message", message: result.userMessage };
|
|
24
|
+
}
|
|
25
|
+
if (result.decision === "reject" && result.userMessage) {
|
|
26
|
+
return { type: "reject_with_message", message: result.userMessage };
|
|
27
|
+
}
|
|
28
|
+
return result.decision;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const EditFilePermissionUI = memo(
|
|
32
|
+
({
|
|
33
|
+
filePath,
|
|
34
|
+
originalContent,
|
|
35
|
+
newContent,
|
|
36
|
+
diffShownInEditor,
|
|
37
|
+
onResolve,
|
|
38
|
+
}: {
|
|
39
|
+
filePath: string;
|
|
40
|
+
originalContent: string;
|
|
41
|
+
newContent: string;
|
|
42
|
+
diffShownInEditor?: boolean;
|
|
43
|
+
onResolve: (decision: PermissionDecision) => void;
|
|
44
|
+
}) => {
|
|
45
|
+
const isNewFile = !originalContent;
|
|
46
|
+
const { agentMode } = useAgentMode();
|
|
47
|
+
const inPlanMode = agentMode === AgentMode.PlanMode;
|
|
48
|
+
|
|
49
|
+
const options: PermissionOption[] = [
|
|
50
|
+
{ label: "Accept", value: "accept" },
|
|
51
|
+
...(!inPlanMode
|
|
52
|
+
? [
|
|
53
|
+
{
|
|
54
|
+
label: "Always accept all edits",
|
|
55
|
+
value: "allowAlways" as const,
|
|
56
|
+
hint: "shift+tab",
|
|
57
|
+
},
|
|
58
|
+
]
|
|
59
|
+
: []),
|
|
60
|
+
{ label: "Reject", value: "reject" },
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const handleSelect = (result: ToolPermissionResult) => {
|
|
64
|
+
onResolve(mapResultToDecision(result));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if (diffShownInEditor) {
|
|
68
|
+
return (
|
|
69
|
+
<View flexDirection="column">
|
|
70
|
+
<PermissionPreviewHeader
|
|
71
|
+
title={`${isNewFile ? "Create" : "Update"} file ${filePath}`}
|
|
72
|
+
subtitle="Opened changes in the editor"
|
|
73
|
+
/>
|
|
74
|
+
<View flexDirection="column" paddingLeft={1}>
|
|
75
|
+
<PermissionOptions options={options} onSelect={handleSelect} />
|
|
76
|
+
</View>
|
|
77
|
+
</View>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<View flexDirection="column">
|
|
83
|
+
<PermissionPreviewHeader title={`${isNewFile ? "Create" : "Update"} file ${filePath}`} />
|
|
84
|
+
{isNewFile ? (
|
|
85
|
+
<CodePreview filePath={filePath} content={newContent} maxLines={100} />
|
|
86
|
+
) : (
|
|
87
|
+
<DiffPreview
|
|
88
|
+
filePath={filePath}
|
|
89
|
+
originalContent={originalContent}
|
|
90
|
+
newContent={newContent}
|
|
91
|
+
paddingLeft={1}
|
|
92
|
+
/>
|
|
93
|
+
)}
|
|
94
|
+
<View
|
|
95
|
+
borderStyle={dashedBorderStyle}
|
|
96
|
+
borderBottom
|
|
97
|
+
borderTop={false}
|
|
98
|
+
borderLeft={false}
|
|
99
|
+
borderRight={false}
|
|
100
|
+
/>
|
|
101
|
+
<View flexDirection="column" paddingLeft={1}>
|
|
102
|
+
<PermissionOptions options={options} onSelect={handleSelect} />
|
|
103
|
+
</View>
|
|
104
|
+
</View>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
EditFilePermissionUI.displayName = "EditFilePermissionUI";
|
|
109
|
+
|
|
110
|
+
const DeleteFilePermissionUI = memo(
|
|
111
|
+
({
|
|
112
|
+
filePath,
|
|
113
|
+
onResolve,
|
|
114
|
+
}: {
|
|
115
|
+
filePath: string;
|
|
116
|
+
onResolve: (decision: PermissionDecision) => void;
|
|
117
|
+
}) => {
|
|
118
|
+
const options: PermissionOption[] = [
|
|
119
|
+
{ label: "Yes", value: "accept" },
|
|
120
|
+
{ label: "No", value: "reject" },
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
const handleSelect = (result: ToolPermissionResult) => {
|
|
124
|
+
onResolve(mapResultToDecision(result));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<View flexDirection="column">
|
|
129
|
+
<PermissionPreviewHeader title={`Delete file ${filePath}`} />
|
|
130
|
+
<View flexDirection="column" paddingLeft={1} paddingY={1}>
|
|
131
|
+
<Text color="red">{filePath}</Text>
|
|
132
|
+
</View>
|
|
133
|
+
<View
|
|
134
|
+
borderStyle={dashedBorderStyle}
|
|
135
|
+
borderBottom
|
|
136
|
+
borderTop={false}
|
|
137
|
+
borderLeft={false}
|
|
138
|
+
borderRight={false}
|
|
139
|
+
/>
|
|
140
|
+
<View flexDirection="column" paddingLeft={1}>
|
|
141
|
+
<PermissionOptions options={options} onSelect={handleSelect} />
|
|
142
|
+
</View>
|
|
143
|
+
</View>
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
DeleteFilePermissionUI.displayName = "DeleteFilePermissionUI";
|
|
148
|
+
|
|
149
|
+
const BrowserActionPermissionUI = memo(
|
|
150
|
+
({
|
|
151
|
+
description,
|
|
152
|
+
url,
|
|
153
|
+
onResolve,
|
|
154
|
+
}: {
|
|
155
|
+
description: string;
|
|
156
|
+
url?: string;
|
|
157
|
+
onResolve: (decision: PermissionDecision) => void;
|
|
158
|
+
}) => {
|
|
159
|
+
const options: PermissionOption[] = [
|
|
160
|
+
{ label: "Yes", value: "accept" },
|
|
161
|
+
{ label: "No", value: "reject" },
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
const handleSelect = (result: ToolPermissionResult) => {
|
|
165
|
+
onResolve(mapResultToDecision(result));
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<View flexDirection="column">
|
|
170
|
+
<PermissionPreviewHeader title={`Browser action: ${description}`} />
|
|
171
|
+
<View flexDirection="column" paddingLeft={1} paddingY={1}>
|
|
172
|
+
<Text>{description}</Text>
|
|
173
|
+
{url && <Text dimColor>URL: {url}</Text>}
|
|
174
|
+
</View>
|
|
175
|
+
<View
|
|
176
|
+
borderStyle={dashedBorderStyle}
|
|
177
|
+
borderBottom
|
|
178
|
+
borderTop={false}
|
|
179
|
+
borderLeft={false}
|
|
180
|
+
borderRight={false}
|
|
181
|
+
/>
|
|
182
|
+
<View flexDirection="column" paddingLeft={1}>
|
|
183
|
+
<PermissionOptions options={options} onSelect={handleSelect} />
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
);
|
|
187
|
+
},
|
|
188
|
+
);
|
|
189
|
+
BrowserActionPermissionUI.displayName = "BrowserActionPermissionUI";
|
|
190
|
+
|
|
191
|
+
const RunTerminalPermissionUI = memo(
|
|
192
|
+
({
|
|
193
|
+
command,
|
|
194
|
+
background,
|
|
195
|
+
onResolve,
|
|
196
|
+
}: {
|
|
197
|
+
command: string;
|
|
198
|
+
background: boolean;
|
|
199
|
+
onResolve: (decision: PermissionDecision) => void;
|
|
200
|
+
}) => {
|
|
201
|
+
const options: PermissionOption[] = [
|
|
202
|
+
{ label: "Yes", value: "accept" },
|
|
203
|
+
{ label: "No", value: "reject" },
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
const handleSelect = (result: ToolPermissionResult) => {
|
|
207
|
+
onResolve(mapResultToDecision(result));
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<View flexDirection="column">
|
|
212
|
+
<PermissionPreviewHeader title="Bash command" />
|
|
213
|
+
<View flexDirection="column" paddingLeft={1} paddingY={1}>
|
|
214
|
+
<Text color="cyan">{command}</Text>
|
|
215
|
+
{background && (
|
|
216
|
+
<View paddingTop={1}>
|
|
217
|
+
<Text dimColor>(Running in background)</Text>
|
|
218
|
+
</View>
|
|
219
|
+
)}
|
|
220
|
+
</View>
|
|
221
|
+
<View
|
|
222
|
+
borderStyle={dashedBorderStyle}
|
|
223
|
+
borderBottom
|
|
224
|
+
borderTop={false}
|
|
225
|
+
borderLeft={false}
|
|
226
|
+
borderRight={false}
|
|
227
|
+
/>
|
|
228
|
+
<View flexDirection="column" paddingLeft={1}>
|
|
229
|
+
<PermissionOptions
|
|
230
|
+
options={options}
|
|
231
|
+
onSelect={handleSelect}
|
|
232
|
+
inputPlaceholder="Type here to tell AbacusAI what to do differently"
|
|
233
|
+
/>
|
|
234
|
+
</View>
|
|
235
|
+
</View>
|
|
236
|
+
);
|
|
237
|
+
},
|
|
238
|
+
);
|
|
239
|
+
RunTerminalPermissionUI.displayName = "RunTerminalPermissionUI";
|
|
240
|
+
|
|
241
|
+
const GenericPermissionUI = memo(
|
|
242
|
+
({
|
|
243
|
+
title,
|
|
244
|
+
description,
|
|
245
|
+
onResolve,
|
|
246
|
+
}: {
|
|
247
|
+
title: string;
|
|
248
|
+
description: string;
|
|
249
|
+
onResolve: (decision: PermissionDecision) => void;
|
|
250
|
+
}) => {
|
|
251
|
+
const options: PermissionOption[] = [
|
|
252
|
+
{ label: "Yes", value: "accept" },
|
|
253
|
+
{ label: "No", value: "reject" },
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
const handleSelect = (result: ToolPermissionResult) => {
|
|
257
|
+
onResolve(mapResultToDecision(result));
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<View flexDirection="column">
|
|
262
|
+
<PermissionPreviewHeader title={title} />
|
|
263
|
+
<View flexDirection="column" paddingLeft={1} paddingY={1}>
|
|
264
|
+
<Text>{description}</Text>
|
|
265
|
+
</View>
|
|
266
|
+
<View
|
|
267
|
+
borderStyle={dashedBorderStyle}
|
|
268
|
+
borderBottom
|
|
269
|
+
borderTop={false}
|
|
270
|
+
borderLeft={false}
|
|
271
|
+
borderRight={false}
|
|
272
|
+
/>
|
|
273
|
+
<View flexDirection="column" paddingLeft={1}>
|
|
274
|
+
<PermissionOptions options={options} onSelect={handleSelect} />
|
|
275
|
+
</View>
|
|
276
|
+
</View>
|
|
277
|
+
);
|
|
278
|
+
},
|
|
279
|
+
);
|
|
280
|
+
GenericPermissionUI.displayName = "GenericPermissionUI";
|
|
281
|
+
|
|
282
|
+
const ExitPlanModePermissionUI = memo(
|
|
283
|
+
({
|
|
284
|
+
planFilePath,
|
|
285
|
+
planContent,
|
|
286
|
+
onResolve,
|
|
287
|
+
}: {
|
|
288
|
+
planFilePath: string;
|
|
289
|
+
planContent: string;
|
|
290
|
+
onResolve: (decision: PermissionDecision) => void;
|
|
291
|
+
}) => {
|
|
292
|
+
const options: PermissionOption[] = [
|
|
293
|
+
{
|
|
294
|
+
label: "Yes, implement the plan (auto-accept all edits)",
|
|
295
|
+
value: "allowAlways",
|
|
296
|
+
hint: "shift+tab",
|
|
297
|
+
},
|
|
298
|
+
{ label: "Yes, implement the plan (approve each edit)", value: "accept" },
|
|
299
|
+
{ label: "No, keep planning", value: "reject" },
|
|
300
|
+
];
|
|
301
|
+
|
|
302
|
+
const handleSelect = (result: ToolPermissionResult) => {
|
|
303
|
+
onResolve(mapResultToDecision(result));
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const truncatedPath = planFilePath.length > 60 ? `…${planFilePath.slice(-60)}` : planFilePath;
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<View flexDirection="column">
|
|
310
|
+
<PermissionPreviewHeader title={`Ready to code? Implement plan: ${truncatedPath}`} />
|
|
311
|
+
{planContent && (
|
|
312
|
+
<View flexDirection="column" paddingLeft={1} paddingY={1}>
|
|
313
|
+
<Text dimColor>Here is Abacus's plan:</Text>
|
|
314
|
+
<Markdown>{planContent}</Markdown>
|
|
315
|
+
</View>
|
|
316
|
+
)}
|
|
317
|
+
<View
|
|
318
|
+
borderStyle={dashedBorderStyle}
|
|
319
|
+
borderBottom
|
|
320
|
+
borderTop={false}
|
|
321
|
+
borderLeft={false}
|
|
322
|
+
borderRight={false}
|
|
323
|
+
/>
|
|
324
|
+
<View flexDirection="column" paddingLeft={1}>
|
|
325
|
+
<PermissionOptions
|
|
326
|
+
options={options}
|
|
327
|
+
onSelect={handleSelect}
|
|
328
|
+
inputPlaceholder="Add instructions for the implementation"
|
|
329
|
+
/>
|
|
330
|
+
</View>
|
|
331
|
+
</View>
|
|
332
|
+
);
|
|
333
|
+
},
|
|
334
|
+
);
|
|
335
|
+
ExitPlanModePermissionUI.displayName = "ExitPlanModePermissionUI";
|
|
336
|
+
|
|
337
|
+
export const ToolPermissionUI = memo(({ pendingTool }: ToolPermissionUIProps) => {
|
|
338
|
+
const { request, resolve } = pendingTool;
|
|
339
|
+
|
|
340
|
+
switch (request.type) {
|
|
341
|
+
case "edit_file":
|
|
342
|
+
return (
|
|
343
|
+
<EditFilePermissionUI
|
|
344
|
+
filePath={request.filePath}
|
|
345
|
+
originalContent={request.originalContent}
|
|
346
|
+
newContent={request.newContent}
|
|
347
|
+
diffShownInEditor={request.diffShownInEditor}
|
|
348
|
+
onResolve={resolve}
|
|
349
|
+
/>
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
case "delete_file":
|
|
353
|
+
return <DeleteFilePermissionUI filePath={request.filePath} onResolve={resolve} />;
|
|
354
|
+
|
|
355
|
+
case "run_terminal":
|
|
356
|
+
return (
|
|
357
|
+
<RunTerminalPermissionUI
|
|
358
|
+
command={request.command}
|
|
359
|
+
background={request.background}
|
|
360
|
+
onResolve={resolve}
|
|
361
|
+
/>
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
case "browser_action":
|
|
365
|
+
return (
|
|
366
|
+
<BrowserActionPermissionUI
|
|
367
|
+
description={request.description}
|
|
368
|
+
url={request.url}
|
|
369
|
+
onResolve={resolve}
|
|
370
|
+
/>
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
case "generic":
|
|
374
|
+
return (
|
|
375
|
+
<GenericPermissionUI
|
|
376
|
+
title={`Tool: ${request.toolName}`}
|
|
377
|
+
description={request.inputSummary}
|
|
378
|
+
onResolve={resolve}
|
|
379
|
+
/>
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
case "exit_plan_mode":
|
|
383
|
+
return (
|
|
384
|
+
<ExitPlanModePermissionUI
|
|
385
|
+
planFilePath={request.planFilePath}
|
|
386
|
+
planContent={request.planContent}
|
|
387
|
+
onResolve={resolve}
|
|
388
|
+
/>
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
case "ask_user_question":
|
|
392
|
+
return <AskUserQuestionPermissionUI questions={request.questions} onResolve={resolve} />;
|
|
393
|
+
|
|
394
|
+
default:
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
ToolPermissionUI.displayName = "ToolPermissionUI";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { AskUserQuestionParsedData } from "@codellm/agent";
|
|
2
|
+
|
|
3
|
+
import { View, Text } from "@codellm/jar";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
import type { ToolDef, ToolStatus } from "../types.js";
|
|
8
|
+
|
|
9
|
+
import { ToolHeader, ToolResult, PreviewContent } from "../shared/index.js";
|
|
10
|
+
import { snakeToCamel } from "../shared/index.js";
|
|
11
|
+
import { coerceBoolean } from "../shared/zod-coercion.js";
|
|
12
|
+
|
|
13
|
+
const AskUserQuestionParams = z.object({
|
|
14
|
+
questions: z.array(
|
|
15
|
+
z.object({
|
|
16
|
+
question: z.string(),
|
|
17
|
+
header: z.string(),
|
|
18
|
+
options: z.array(z.object({ label: z.string(), description: z.string() })),
|
|
19
|
+
multiSelect: coerceBoolean,
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
answers: z.record(z.string(), z.string()).optional(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const askUserQuestionTool: ToolDef<AskUserQuestionParsedData> = {
|
|
26
|
+
displayName: "AskUserQuestion",
|
|
27
|
+
getHeaderParams(_input: Record<string, unknown>): string {
|
|
28
|
+
return "";
|
|
29
|
+
},
|
|
30
|
+
renderUI(
|
|
31
|
+
rawInput: Record<string, unknown>,
|
|
32
|
+
status: ToolStatus,
|
|
33
|
+
parsedResult,
|
|
34
|
+
): React.ReactElement {
|
|
35
|
+
const pr = AskUserQuestionParams.safeParse(snakeToCamel(rawInput));
|
|
36
|
+
if (!pr.success) {
|
|
37
|
+
return (
|
|
38
|
+
<View flexDirection="column">
|
|
39
|
+
<ToolHeader name="AskUserQuestion" status="error" />
|
|
40
|
+
<ToolResult color="red">Invalid params</ToolResult>
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const params = pr.data;
|
|
45
|
+
const questions = params.questions || [];
|
|
46
|
+
const answers = parsedResult?.data.answers ?? params.answers ?? {};
|
|
47
|
+
|
|
48
|
+
if (status === "interrupted") {
|
|
49
|
+
return (
|
|
50
|
+
<View flexDirection="column">
|
|
51
|
+
<ToolHeader name="AskUserQuestion" status="interrupted" />
|
|
52
|
+
<ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (status === "rejected") {
|
|
58
|
+
const hasAnswers = Object.keys(answers).length > 0;
|
|
59
|
+
return (
|
|
60
|
+
<View flexDirection="column">
|
|
61
|
+
<ToolHeader name="AskUserQuestion" status={hasAnswers ? "success" : "rejected"} />
|
|
62
|
+
<ToolResult color={hasAnswers ? "green" : "yellow"}>
|
|
63
|
+
{hasAnswers
|
|
64
|
+
? `User answered ${Object.keys(answers).length} question${Object.keys(answers).length !== 1 ? "s" : ""}`
|
|
65
|
+
: "User cancelled the questions"}
|
|
66
|
+
</ToolResult>
|
|
67
|
+
</View>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status === "pending" || status === "executing") {
|
|
72
|
+
return <ToolHeader name="AskUserQuestion" status="pending" showSpinner />;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const questionCount = questions.length;
|
|
76
|
+
const answerCount = Object.keys(answers).length;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<View flexDirection="column" gap={0}>
|
|
80
|
+
<ToolHeader name="AskUserQuestion" status="success" />
|
|
81
|
+
<ToolResult>
|
|
82
|
+
Answered {questionCount} question{questionCount !== 1 ? "s" : ""}
|
|
83
|
+
</ToolResult>
|
|
84
|
+
{answerCount > 0 && (
|
|
85
|
+
<PreviewContent>
|
|
86
|
+
{Object.entries(answers).map(([key, value], index) => {
|
|
87
|
+
const questionIndex = parseInt(key.replace("question_", ""), 10);
|
|
88
|
+
const question = questions[questionIndex];
|
|
89
|
+
return (
|
|
90
|
+
<View key={index} flexDirection="column" marginBottom={1}>
|
|
91
|
+
<Text dimColor>{question?.header || `Question ${questionIndex + 1}`}</Text>
|
|
92
|
+
<Text color="cyan">→ {String(value)}</Text>
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
</PreviewContent>
|
|
97
|
+
)}
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ParsedToolResult } from "@codellm/agent";
|
|
2
|
+
|
|
3
|
+
import { View } from "@codellm/jar";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
import type { ToolDef, ToolStatus } from "../types.js";
|
|
7
|
+
|
|
8
|
+
import { ToolHeader, ToolResult } from "../shared/index.js";
|
|
9
|
+
|
|
10
|
+
export const enterPlanModeTool: ToolDef = {
|
|
11
|
+
displayName: "EnterPlanMode",
|
|
12
|
+
getHeaderParams(_input: Record<string, unknown>): string {
|
|
13
|
+
return "";
|
|
14
|
+
},
|
|
15
|
+
renderUI(
|
|
16
|
+
_rawInput: Record<string, unknown>,
|
|
17
|
+
status: ToolStatus,
|
|
18
|
+
_parsedResult?: ParsedToolResult,
|
|
19
|
+
): React.ReactElement {
|
|
20
|
+
if (status === "interrupted") {
|
|
21
|
+
return (
|
|
22
|
+
<View flexDirection="column">
|
|
23
|
+
<ToolHeader name="EnterPlanMode" status="interrupted" />
|
|
24
|
+
<ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (status === "rejected") {
|
|
30
|
+
return (
|
|
31
|
+
<View flexDirection="column">
|
|
32
|
+
<ToolHeader name="EnterPlanMode" status="rejected" />
|
|
33
|
+
<ToolResult color="yellow">Plan mode entry rejected</ToolResult>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (status === "pending" || status === "executing") {
|
|
39
|
+
return <ToolHeader name="EnterPlanMode" status="pending" showSpinner />;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<View flexDirection="column" gap={0}>
|
|
44
|
+
<ToolHeader name="EnterPlanMode" status="success" />
|
|
45
|
+
<ToolResult>Entered plan mode</ToolResult>
|
|
46
|
+
</View>
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ParsedToolResult } from "@codellm/agent";
|
|
2
|
+
|
|
3
|
+
import { AgentMode } from "@codellm/agent";
|
|
4
|
+
import { View } from "@codellm/jar";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
|
|
8
|
+
import type { ToolDef, ToolStatus } from "../types.js";
|
|
9
|
+
|
|
10
|
+
import { useAgentMode } from "../../../context/agent-mode.js";
|
|
11
|
+
import { ToolHeader, ToolResult, truncatePath } from "../shared/index.js";
|
|
12
|
+
import { snakeToCamel } from "../shared/index.js";
|
|
13
|
+
|
|
14
|
+
const ExitPlanModeParams = z.object({ planFilePath: z.string() });
|
|
15
|
+
|
|
16
|
+
function ExitPlanModeUI({
|
|
17
|
+
rawInput,
|
|
18
|
+
status,
|
|
19
|
+
}: {
|
|
20
|
+
rawInput: Record<string, unknown>;
|
|
21
|
+
status: ToolStatus;
|
|
22
|
+
}) {
|
|
23
|
+
const { agentMode } = useAgentMode();
|
|
24
|
+
const pr = ExitPlanModeParams.safeParse(snakeToCamel(rawInput));
|
|
25
|
+
const planFilePath =
|
|
26
|
+
(pr.success ? pr.data.planFilePath : (rawInput?.planFilePath as string)) || "";
|
|
27
|
+
|
|
28
|
+
if (status === "interrupted") {
|
|
29
|
+
return (
|
|
30
|
+
<View flexDirection="column">
|
|
31
|
+
<ToolHeader name="ExitPlanMode" status="interrupted" />
|
|
32
|
+
<ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (status === "rejected") {
|
|
38
|
+
return (
|
|
39
|
+
<View flexDirection="column">
|
|
40
|
+
<ToolHeader name="ExitPlanMode" status="rejected" />
|
|
41
|
+
<ToolResult color="yellow">Plan rejected</ToolResult>
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (status === "pending" || status === "executing") {
|
|
47
|
+
return <ToolHeader name="ExitPlanMode" status="pending" showSpinner />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const modeMessage =
|
|
51
|
+
agentMode === AgentMode.AcceptEdits ? "Plan approved (auto-accept mode)" : "Plan approved";
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View flexDirection="column" gap={0}>
|
|
55
|
+
<ToolHeader name="ExitPlanMode" status="success" />
|
|
56
|
+
<ToolResult>
|
|
57
|
+
{modeMessage}: {truncatePath(planFilePath)}
|
|
58
|
+
</ToolResult>
|
|
59
|
+
</View>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const exitPlanModeTool: ToolDef = {
|
|
64
|
+
displayName: "ExitPlanMode",
|
|
65
|
+
getHeaderParams(input: Record<string, unknown>): string {
|
|
66
|
+
return (input?.planFilePath as string) || "";
|
|
67
|
+
},
|
|
68
|
+
renderUI(
|
|
69
|
+
rawInput: Record<string, unknown>,
|
|
70
|
+
status: ToolStatus,
|
|
71
|
+
_parsedResult?: ParsedToolResult,
|
|
72
|
+
): React.ReactElement {
|
|
73
|
+
return <ExitPlanModeUI rawInput={rawInput} status={status} />;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ParsedToolResult } from "@codellm/agent";
|
|
2
|
+
|
|
3
|
+
import { View } from "@codellm/jar";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
import type { ToolDef, ToolStatus } from "../types.js";
|
|
7
|
+
|
|
8
|
+
import { ToolHeader, ToolResult } from "../shared/index.js";
|
|
9
|
+
|
|
10
|
+
export const handOffToMainTool: ToolDef = {
|
|
11
|
+
displayName: "HandOff",
|
|
12
|
+
getHeaderParams(_input: Record<string, unknown>): string {
|
|
13
|
+
return "";
|
|
14
|
+
},
|
|
15
|
+
renderUI(
|
|
16
|
+
_rawInput: Record<string, unknown>,
|
|
17
|
+
_status: ToolStatus,
|
|
18
|
+
_parsedResult?: ParsedToolResult,
|
|
19
|
+
): React.ReactElement {
|
|
20
|
+
return (
|
|
21
|
+
<View flexDirection="column">
|
|
22
|
+
<ToolHeader name="HandOff" status="success" />
|
|
23
|
+
<ToolResult>Handed off to main agent</ToolResult>
|
|
24
|
+
</View>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ParsedToolResult } from "@codellm/agent";
|
|
2
|
+
|
|
3
|
+
import { View } from "@codellm/jar";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
import type { ToolDef, ToolStatus } from "../types.js";
|
|
8
|
+
|
|
9
|
+
import { ToolHeader, ToolResult } from "../shared/index.js";
|
|
10
|
+
import { snakeToCamel } from "../shared/index.js";
|
|
11
|
+
|
|
12
|
+
const SubagentParams = z.object({
|
|
13
|
+
agent: z.string(),
|
|
14
|
+
task: z.string(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const subagentTool: ToolDef = {
|
|
18
|
+
displayName: "Subagent",
|
|
19
|
+
getHeaderParams(input: Record<string, unknown>): string {
|
|
20
|
+
return (input?.agent || "") as string;
|
|
21
|
+
},
|
|
22
|
+
renderUI(
|
|
23
|
+
rawInput: Record<string, unknown>,
|
|
24
|
+
_status: ToolStatus,
|
|
25
|
+
_parsedResult?: ParsedToolResult,
|
|
26
|
+
): React.ReactElement {
|
|
27
|
+
const pr = SubagentParams.safeParse(snakeToCamel(rawInput));
|
|
28
|
+
const agent = (pr.success ? pr.data.agent : rawInput?.agent || "") as string;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View flexDirection="column">
|
|
32
|
+
<ToolHeader name="Subagent" params={agent} status="success" />
|
|
33
|
+
<ToolResult>Switched to {agent} agent</ToolResult>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
};
|