@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.
Files changed (200) hide show
  1. package/.oxlintrc.json +8 -0
  2. package/dist/index.mjs +12603 -0
  3. package/package.json +7 -39
  4. package/resources/abacus.ico +0 -0
  5. package/resources/entitlements.plist +9 -0
  6. package/src/__e2e__/README.md +196 -0
  7. package/src/__e2e__/agent-interactions.e2e.test.tsx +61 -0
  8. package/src/__e2e__/cli-commands.e2e.test.tsx +77 -0
  9. package/src/__e2e__/conversation-throttle.e2e.test.ts +453 -0
  10. package/src/__e2e__/conversation.e2e.test.tsx +56 -0
  11. package/src/__e2e__/diff-preview.e2e.test.tsx +3399 -0
  12. package/src/__e2e__/file-creation.e2e.test.tsx +149 -0
  13. package/src/__e2e__/helpers/test-helpers.ts +450 -0
  14. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +34 -0
  15. package/src/__e2e__/llm-models.e2e.test.ts +402 -0
  16. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +71 -0
  17. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +167 -0
  18. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +185 -0
  19. package/src/__e2e__/repl.e2e.test.tsx +78 -0
  20. package/src/__e2e__/shell-compatibility.e2e.test.tsx +76 -0
  21. package/src/__e2e__/theme-mcp.e2e.test.tsx +98 -0
  22. package/src/__e2e__/tool-permissions.e2e.test.tsx +66 -0
  23. package/src/args.ts +22 -0
  24. package/src/components/__tests__/react-compiler.test.tsx +78 -0
  25. package/src/components/__tests__/status-indicator.test.tsx +403 -0
  26. package/src/components/composer/__tests__/bash-runner.test.tsx +263 -0
  27. package/src/components/composer/agent-mode-indicator.tsx +63 -0
  28. package/src/components/composer/bash-runner.tsx +54 -0
  29. package/src/components/composer/commands/default-commands.tsx +615 -0
  30. package/src/components/composer/commands/handler.tsx +59 -0
  31. package/src/components/composer/commands/picker.tsx +273 -0
  32. package/src/components/composer/commands/registry.ts +233 -0
  33. package/src/components/composer/commands/types.ts +33 -0
  34. package/src/components/composer/context.tsx +88 -0
  35. package/src/components/composer/file-mention-picker.tsx +83 -0
  36. package/src/components/composer/help.tsx +44 -0
  37. package/src/components/composer/index.tsx +1006 -0
  38. package/src/components/composer/mentions.ts +57 -0
  39. package/src/components/composer/message-queue.tsx +70 -0
  40. package/src/components/composer/mode-panel.tsx +35 -0
  41. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +755 -0
  42. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +1108 -0
  43. package/src/components/composer/modes/bash-handler.tsx +132 -0
  44. package/src/components/composer/modes/bash-renderer.tsx +175 -0
  45. package/src/components/composer/modes/default-handlers.tsx +33 -0
  46. package/src/components/composer/modes/index.ts +41 -0
  47. package/src/components/composer/modes/types.ts +21 -0
  48. package/src/components/composer/persistent-shell.ts +283 -0
  49. package/src/components/composer/process.ts +65 -0
  50. package/src/components/composer/types.ts +9 -0
  51. package/src/components/composer/use-mention-search.ts +68 -0
  52. package/src/components/error-boundry.tsx +60 -0
  53. package/src/components/exit-message.tsx +29 -0
  54. package/src/components/expanded-view.tsx +74 -0
  55. package/src/components/file-completion.tsx +127 -0
  56. package/src/components/header.tsx +47 -0
  57. package/src/components/logo.tsx +37 -0
  58. package/src/components/segments.tsx +356 -0
  59. package/src/components/status-indicator.tsx +306 -0
  60. package/src/components/tool-group-summary.tsx +263 -0
  61. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +312 -0
  62. package/src/components/tool-permissions/diff-preview.tsx +355 -0
  63. package/src/components/tool-permissions/index.ts +5 -0
  64. package/src/components/tool-permissions/permission-options.tsx +375 -0
  65. package/src/components/tool-permissions/permission-preview-header.tsx +57 -0
  66. package/src/components/tool-permissions/tool-permission-ui.tsx +398 -0
  67. package/src/components/tools/agent/ask-user-question.tsx +101 -0
  68. package/src/components/tools/agent/enter-plan-mode.tsx +49 -0
  69. package/src/components/tools/agent/exit-plan-mode.tsx +75 -0
  70. package/src/components/tools/agent/handoff-to-main.tsx +27 -0
  71. package/src/components/tools/agent/subagent.tsx +37 -0
  72. package/src/components/tools/agent/todo-write.tsx +104 -0
  73. package/src/components/tools/browser/close-tab.tsx +58 -0
  74. package/src/components/tools/browser/computer.tsx +70 -0
  75. package/src/components/tools/browser/get-interactive-elements.tsx +54 -0
  76. package/src/components/tools/browser/get-tab-content.tsx +51 -0
  77. package/src/components/tools/browser/navigate-to.tsx +59 -0
  78. package/src/components/tools/browser/new-tab.tsx +60 -0
  79. package/src/components/tools/browser/perform-action.tsx +63 -0
  80. package/src/components/tools/browser/refresh-tab.tsx +43 -0
  81. package/src/components/tools/browser/switch-tab.tsx +58 -0
  82. package/src/components/tools/filesystem/delete-file.tsx +104 -0
  83. package/src/components/tools/filesystem/edit.tsx +220 -0
  84. package/src/components/tools/filesystem/list-dir.tsx +78 -0
  85. package/src/components/tools/filesystem/read-file.tsx +180 -0
  86. package/src/components/tools/filesystem/upload-image.tsx +76 -0
  87. package/src/components/tools/ide/ide-diagnostics.tsx +62 -0
  88. package/src/components/tools/index.ts +91 -0
  89. package/src/components/tools/mcp/mcp-tool.tsx +158 -0
  90. package/src/components/tools/search/fetch-url.tsx +73 -0
  91. package/src/components/tools/search/file-search.tsx +78 -0
  92. package/src/components/tools/search/grep.tsx +90 -0
  93. package/src/components/tools/search/semantic-search.tsx +66 -0
  94. package/src/components/tools/search/web-search.tsx +71 -0
  95. package/src/components/tools/shared/index.tsx +48 -0
  96. package/src/components/tools/shared/zod-coercion.ts +35 -0
  97. package/src/components/tools/terminal/bash-tool-output.tsx +174 -0
  98. package/src/components/tools/terminal/get-terminal-output.tsx +85 -0
  99. package/src/components/tools/terminal/run-in-terminal.tsx +106 -0
  100. package/src/components/tools/types.ts +16 -0
  101. package/src/components/tools.tsx +66 -0
  102. package/src/components/ui/__tests__/divider.test.tsx +61 -0
  103. package/src/components/ui/__tests__/gradient.test.tsx +125 -0
  104. package/src/components/ui/__tests__/input.test.tsx +166 -0
  105. package/src/components/ui/__tests__/select.test.tsx +273 -0
  106. package/src/components/ui/__tests__/shimmer.test.tsx +99 -0
  107. package/src/components/ui/blinking-indicator.tsx +25 -0
  108. package/src/components/ui/divider.tsx +162 -0
  109. package/src/components/ui/gradient.tsx +56 -0
  110. package/src/components/ui/input.tsx +228 -0
  111. package/src/components/ui/select.tsx +151 -0
  112. package/src/components/ui/shimmer.tsx +84 -0
  113. package/src/context/agent-mode.tsx +95 -0
  114. package/src/context/extension-file.tsx +136 -0
  115. package/src/context/network-activity.tsx +45 -0
  116. package/src/context/notification.tsx +62 -0
  117. package/src/context/shell-size.tsx +49 -0
  118. package/src/context/shell-title.tsx +38 -0
  119. package/src/entrypoints/print-mode.ts +312 -0
  120. package/src/entrypoints/repl.tsx +401 -0
  121. package/src/hooks/use-agent.ts +15 -0
  122. package/src/hooks/use-api-client.ts +1 -0
  123. package/src/hooks/use-available-height.ts +8 -0
  124. package/src/hooks/use-cleanup.ts +29 -0
  125. package/src/hooks/use-interrupt-manager.ts +242 -0
  126. package/src/hooks/use-models.ts +22 -0
  127. package/src/index.ts +217 -0
  128. package/src/lib/__tests__/ansi.test.ts +255 -0
  129. package/src/lib/__tests__/cli.test.ts +122 -0
  130. package/src/lib/__tests__/commands.test.ts +325 -0
  131. package/src/lib/__tests__/constants.test.ts +15 -0
  132. package/src/lib/__tests__/focusables.test.ts +25 -0
  133. package/src/lib/__tests__/fs.test.ts +231 -0
  134. package/src/lib/__tests__/markdown.test.tsx +348 -0
  135. package/src/lib/__tests__/mcpCommandHandler.test.ts +173 -0
  136. package/src/lib/__tests__/mcpManagement.test.ts +38 -0
  137. package/src/lib/__tests__/path-paste.test.ts +144 -0
  138. package/src/lib/__tests__/path.test.ts +300 -0
  139. package/src/lib/__tests__/queries.test.ts +39 -0
  140. package/src/lib/__tests__/standaloneMcpService.test.ts +71 -0
  141. package/src/lib/__tests__/text-buffer.test.ts +328 -0
  142. package/src/lib/__tests__/text-utils.test.ts +32 -0
  143. package/src/lib/__tests__/timing.test.ts +78 -0
  144. package/src/lib/__tests__/utils.test.ts +238 -0
  145. package/src/lib/__tests__/vim-buffer-actions.test.ts +154 -0
  146. package/src/lib/ansi.ts +150 -0
  147. package/src/lib/cli-push-server.ts +112 -0
  148. package/src/lib/cli.ts +44 -0
  149. package/src/lib/clipboard.ts +226 -0
  150. package/src/lib/command-utils.ts +93 -0
  151. package/src/lib/commands.ts +270 -0
  152. package/src/lib/constants.ts +3 -0
  153. package/src/lib/extension-connection.ts +181 -0
  154. package/src/lib/focusables.ts +7 -0
  155. package/src/lib/fs.ts +533 -0
  156. package/src/lib/markdown/code-block.tsx +63 -0
  157. package/src/lib/markdown/index.ts +4 -0
  158. package/src/lib/markdown/link.tsx +19 -0
  159. package/src/lib/markdown/markdown.tsx +372 -0
  160. package/src/lib/markdown/types.ts +15 -0
  161. package/src/lib/mcpCommandHandler.ts +121 -0
  162. package/src/lib/mcpManagement.ts +44 -0
  163. package/src/lib/path-paste.ts +185 -0
  164. package/src/lib/path.ts +179 -0
  165. package/src/lib/queries.ts +15 -0
  166. package/src/lib/standaloneMcpService.ts +688 -0
  167. package/src/lib/status-utils.ts +237 -0
  168. package/src/lib/test-utils.tsx +72 -0
  169. package/src/lib/text-buffer.ts +2415 -0
  170. package/src/lib/text-utils.ts +272 -0
  171. package/src/lib/timing.ts +63 -0
  172. package/src/lib/types.ts +295 -0
  173. package/src/lib/utils.ts +182 -0
  174. package/src/lib/vim-buffer-actions.ts +732 -0
  175. package/src/providers/agent.tsx +1075 -0
  176. package/src/providers/api-client.tsx +43 -0
  177. package/src/services/logger.ts +85 -0
  178. package/src/terminal/detection.ts +187 -0
  179. package/src/terminal/exit.ts +279 -0
  180. package/src/terminal/notification.ts +83 -0
  181. package/src/terminal/progress.ts +201 -0
  182. package/src/terminal/setup.ts +797 -0
  183. package/src/terminal/suspend.ts +58 -0
  184. package/src/terminal/types.ts +51 -0
  185. package/src/theme/context.tsx +57 -0
  186. package/src/theme/index.ts +4 -0
  187. package/src/theme/themed.tsx +35 -0
  188. package/src/theme/themes.json +546 -0
  189. package/src/theme/types.ts +110 -0
  190. package/src/tools/types.ts +59 -0
  191. package/src/tools/utils/__tests__/zod-coercion.test.ts +33 -0
  192. package/src/tools/utils/tool-ui-components.tsx +631 -0
  193. package/src/tools/utils/zod-coercion.ts +35 -0
  194. package/tsconfig.json +11 -0
  195. package/tsconfig.node.json +29 -0
  196. package/tsconfig.test.json +27 -0
  197. package/tsdown.config.ts +17 -0
  198. package/vitest.config.ts +76 -0
  199. package/README.md +0 -28
  200. package/dist/index.js +0 -26
@@ -0,0 +1,104 @@
1
+ import type { ParsedToolResult } from "@codellm/agent";
2
+
3
+ import { View, Text } from "@codellm/jar";
4
+ import React, { useCallback } 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
+
12
+ const TodoWriteParams = z.object({
13
+ todos: z.preprocess(
14
+ (val) => {
15
+ if (val === undefined || val === null) return [];
16
+ if (typeof val === "string") {
17
+ try {
18
+ const parsed = JSON.parse(val);
19
+ return Array.isArray(parsed) ? parsed : [];
20
+ } catch {
21
+ return [];
22
+ }
23
+ }
24
+ if (Array.isArray(val)) return val;
25
+ return [];
26
+ },
27
+ z.array(
28
+ z.object({
29
+ content: z.string(),
30
+ status: z.enum(["pending", "in_progress", "completed", "cancelled"]),
31
+ id: z.string().optional(),
32
+ }),
33
+ ),
34
+ ),
35
+ });
36
+
37
+ function TodoWriteUI({
38
+ rawInput,
39
+ parsedResult,
40
+ }: {
41
+ rawInput: Record<string, unknown>;
42
+ parsedResult?: ParsedToolResult;
43
+ }) {
44
+ const pr = TodoWriteParams.safeParse(snakeToCamel(rawInput));
45
+ const todos = pr.success ? pr.data.todos : [];
46
+
47
+ const getStatusIcon = useCallback((status: string) => {
48
+ switch (status) {
49
+ case "completed":
50
+ return "[x]";
51
+ case "in_progress":
52
+ return "[>]";
53
+ default:
54
+ return "[ ]";
55
+ }
56
+ }, []);
57
+
58
+ const getStatusColor = useCallback((status: string) => {
59
+ switch (status) {
60
+ case "completed":
61
+ return "green";
62
+ case "in_progress":
63
+ return "blue";
64
+ default:
65
+ return "gray";
66
+ }
67
+ }, []);
68
+
69
+ return (
70
+ <View flexDirection="column" gap={0}>
71
+ <ToolHeader name="TodoWrite" status="success" />
72
+ {parsedResult?.summary && <ToolResult>{parsedResult.summary}</ToolResult>}
73
+ {todos.length > 0 && (
74
+ <PreviewContent>
75
+ {todos.map((todo, index) => (
76
+ <View key={index} flexDirection="row" alignItems="center" gap={1}>
77
+ <Text color={getStatusColor(todo.status)}>{getStatusIcon(todo.status)}</Text>
78
+ <Text
79
+ color={todo.status === "completed" ? "gray" : undefined}
80
+ dimColor={todo.status === "completed"}
81
+ >
82
+ {todo.content}
83
+ </Text>
84
+ </View>
85
+ ))}
86
+ </PreviewContent>
87
+ )}
88
+ </View>
89
+ );
90
+ }
91
+
92
+ export const todoWriteTool: ToolDef = {
93
+ displayName: "TodoWrite",
94
+ getHeaderParams(_input: Record<string, unknown>): string {
95
+ return "";
96
+ },
97
+ renderUI(
98
+ rawInput: Record<string, unknown>,
99
+ _status: ToolStatus,
100
+ parsedResult?: ParsedToolResult,
101
+ ): React.ReactElement {
102
+ return <TodoWriteUI rawInput={rawInput} parsedResult={parsedResult} />;
103
+ },
104
+ };
@@ -0,0 +1,58 @@
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
+ import { coerceNumber } from "../shared/zod-coercion.js";
12
+
13
+ const CloseTabParams = z.object({ id: coerceNumber });
14
+
15
+ export const closeTabTool: ToolDef = {
16
+ displayName: "CloseTab",
17
+ getHeaderParams(input: Record<string, unknown>): string {
18
+ return `id: ${input?.id ?? ""}`;
19
+ },
20
+ renderUI(
21
+ rawInput: Record<string, unknown>,
22
+ status: ToolStatus,
23
+ parsedResult?: ParsedToolResult,
24
+ ): React.ReactElement {
25
+ const pr = CloseTabParams.safeParse(snakeToCamel(rawInput));
26
+ if (!pr.success)
27
+ return (
28
+ <View flexDirection="column">
29
+ <ToolHeader name="CloseTab" status="error" />
30
+ <ToolResult color="red">Invalid params</ToolResult>
31
+ </View>
32
+ );
33
+ const tabId = pr.data.id;
34
+ const isExecuting = !parsedResult && status === "executing";
35
+
36
+ if (isExecuting)
37
+ return <ToolHeader name="CloseTab" params={`id: ${tabId}`} status="pending" showSpinner />;
38
+ if (!parsedResult)
39
+ return (
40
+ <View flexDirection="column">
41
+ <ToolHeader name="CloseTab" params={`id: ${tabId}`} status="pending" />
42
+ </View>
43
+ );
44
+ if (status === "error")
45
+ return (
46
+ <View flexDirection="column">
47
+ <ToolHeader name="CloseTab" params={`id: ${tabId}`} status="error" />
48
+ <ToolResult color="red">Error closing tab</ToolResult>
49
+ </View>
50
+ );
51
+ return (
52
+ <View flexDirection="column">
53
+ <ToolHeader name="CloseTab" params={`id: ${tabId}`} status="success" />
54
+ <ToolResult>Closed</ToolResult>
55
+ </View>
56
+ );
57
+ },
58
+ };
@@ -0,0 +1,70 @@
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
+ import { coerceNumber, coerceOptionalNumber } from "../shared/zod-coercion.js";
12
+
13
+ const ComputerParams = z.object({
14
+ action: z.enum([
15
+ "key",
16
+ "type",
17
+ "mouse_move",
18
+ "left_click",
19
+ "left_click_drag",
20
+ "right_click",
21
+ "middle_click",
22
+ "double_click",
23
+ "screenshot",
24
+ "cursor_position",
25
+ ]),
26
+ coordinate: z.tuple([coerceNumber, coerceNumber]).optional(),
27
+ startCoordinate: z.tuple([coerceNumber, coerceNumber]).optional(),
28
+ duration: coerceOptionalNumber,
29
+ text: z.string().optional(),
30
+ scrollAmount: coerceOptionalNumber,
31
+ scrollDirection: z.enum(["up", "down", "left", "right"]).optional(),
32
+ });
33
+
34
+ export const computerTool: ToolDef = {
35
+ displayName: "Computer",
36
+ getHeaderParams(input: Record<string, unknown>): string {
37
+ return (input?.action || "action") as string;
38
+ },
39
+ renderUI(
40
+ rawInput: Record<string, unknown>,
41
+ status: ToolStatus,
42
+ parsedResult?: ParsedToolResult,
43
+ ): React.ReactElement {
44
+ const pr = ComputerParams.safeParse(snakeToCamel(rawInput));
45
+ const action = (pr.success ? pr.data.action : rawInput?.action || "action") as string;
46
+ const isExecuting = !parsedResult && status === "executing";
47
+
48
+ if (isExecuting)
49
+ return <ToolHeader name="Computer" params={action} status="executing" showSpinner />;
50
+ if (status === "error")
51
+ return (
52
+ <View flexDirection="column">
53
+ <ToolHeader name="Computer" params={action} status="error" />
54
+ <ToolResult color="red">Error performing computer action</ToolResult>
55
+ </View>
56
+ );
57
+ if (!parsedResult)
58
+ return (
59
+ <View flexDirection="column">
60
+ <ToolHeader name="Computer" params={action} status="pending" />
61
+ </View>
62
+ );
63
+ return (
64
+ <View flexDirection="column">
65
+ <ToolHeader name="Computer" params={action} status="success" />
66
+ <ToolResult>Performed {action}</ToolResult>
67
+ </View>
68
+ );
69
+ },
70
+ };
@@ -0,0 +1,54 @@
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
+ import { coerceOptionalNumber } from "../shared/zod-coercion.js";
12
+
13
+ const GetInteractiveElementsParams = z.object({ id: coerceOptionalNumber });
14
+
15
+ export const getInteractiveElementsTool: ToolDef = {
16
+ displayName: "GetElements",
17
+ getHeaderParams(input: Record<string, unknown>): string {
18
+ return input?.id !== undefined ? `id: ${input.id}` : "";
19
+ },
20
+ renderUI(
21
+ rawInput: Record<string, unknown>,
22
+ status: ToolStatus,
23
+ parsedResult?: ParsedToolResult,
24
+ ): React.ReactElement {
25
+ const pr = GetInteractiveElementsParams.safeParse(snakeToCamel(rawInput));
26
+ const displayParams = pr.success && pr.data.id !== undefined ? `id: ${pr.data.id}` : undefined;
27
+ const isExecuting = !parsedResult && status === "executing";
28
+
29
+ if (isExecuting)
30
+ return (
31
+ <ToolHeader name="GetElements" params={displayParams} status="executing" showSpinner />
32
+ );
33
+ if (status === "error")
34
+ return (
35
+ <View flexDirection="column">
36
+ <ToolHeader name="GetElements" params={displayParams} status="error" />
37
+ <ToolResult color="red">Error: Failed to get interactive elements</ToolResult>
38
+ </View>
39
+ );
40
+ if (!parsedResult)
41
+ return (
42
+ <View flexDirection="column">
43
+ <ToolHeader name="GetElements" params={displayParams} status="pending" />
44
+ </View>
45
+ );
46
+
47
+ return (
48
+ <View flexDirection="column">
49
+ <ToolHeader name="GetElements" params={displayParams} status="success" />
50
+ <ToolResult>{parsedResult.summary ?? "Found elements"}</ToolResult>
51
+ </View>
52
+ );
53
+ },
54
+ };
@@ -0,0 +1,51 @@
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
+ import { coerceOptionalNumber } from "../shared/zod-coercion.js";
12
+
13
+ const GetTabContentParams = z.object({ id: coerceOptionalNumber });
14
+
15
+ export const getTabContentTool: ToolDef = {
16
+ displayName: "GetContent",
17
+ getHeaderParams(input: Record<string, unknown>): string {
18
+ return input?.id !== undefined ? `id: ${input.id}` : "";
19
+ },
20
+ renderUI(
21
+ rawInput: Record<string, unknown>,
22
+ status: ToolStatus,
23
+ parsedResult?: ParsedToolResult,
24
+ ): React.ReactElement {
25
+ const pr = GetTabContentParams.safeParse(snakeToCamel(rawInput));
26
+ const displayParams = pr.success && pr.data.id !== undefined ? `id: ${pr.data.id}` : undefined;
27
+ const isExecuting = !parsedResult && status === "executing";
28
+
29
+ if (isExecuting)
30
+ return <ToolHeader name="GetContent" params={displayParams} status="executing" showSpinner />;
31
+ if (status === "error")
32
+ return (
33
+ <View flexDirection="column">
34
+ <ToolHeader name="GetContent" params={displayParams} status="error" />
35
+ <ToolResult color="red">Error: Failed to get tab content</ToolResult>
36
+ </View>
37
+ );
38
+ if (!parsedResult)
39
+ return (
40
+ <View flexDirection="column">
41
+ <ToolHeader name="GetContent" params={displayParams} status="pending" />
42
+ </View>
43
+ );
44
+ return (
45
+ <View flexDirection="column">
46
+ <ToolHeader name="GetContent" params={displayParams} status="success" />
47
+ <ToolResult>{parsedResult.summary ?? "Got content"}</ToolResult>
48
+ </View>
49
+ );
50
+ },
51
+ };
@@ -0,0 +1,59 @@
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 NavigateToParams = z.object({ url: z.string() });
13
+
14
+ export const navigateToTool: ToolDef = {
15
+ displayName: "Navigate",
16
+ getHeaderParams(input: Record<string, unknown>): string {
17
+ const url = (input?.url || "") as string;
18
+ return url.length > 50 ? url.substring(0, 47) + "..." : url;
19
+ },
20
+ renderUI(
21
+ rawInput: Record<string, unknown>,
22
+ status: ToolStatus,
23
+ parsedResult?: ParsedToolResult,
24
+ ): React.ReactElement {
25
+ const pr = NavigateToParams.safeParse(snakeToCamel(rawInput));
26
+ if (!pr.success)
27
+ return (
28
+ <View flexDirection="column">
29
+ <ToolHeader name="Navigate" params="" status="error" />
30
+ <ToolResult color="red">Invalid params</ToolResult>
31
+ </View>
32
+ );
33
+ const url = pr.data.url || "";
34
+ const truncatedUrl = url.length > 50 ? url.substring(0, 47) + "..." : url;
35
+ const isExecuting = !parsedResult && status === "executing";
36
+
37
+ if (isExecuting)
38
+ return <ToolHeader name="Navigate" params={truncatedUrl} status="executing" showSpinner />;
39
+ if (status === "error")
40
+ return (
41
+ <View flexDirection="column">
42
+ <ToolHeader name="Navigate" params={truncatedUrl} status="error" />
43
+ <ToolResult color="red">Error navigating to URL</ToolResult>
44
+ </View>
45
+ );
46
+ if (!parsedResult)
47
+ return (
48
+ <View flexDirection="column">
49
+ <ToolHeader name="Navigate" params={truncatedUrl} status="pending" />
50
+ </View>
51
+ );
52
+ return (
53
+ <View flexDirection="column">
54
+ <ToolHeader name="Navigate" params={truncatedUrl} status="success" />
55
+ <ToolResult>Navigated</ToolResult>
56
+ </View>
57
+ );
58
+ },
59
+ };
@@ -0,0 +1,60 @@
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 NewTabParams = z.object({ url: z.string().optional() });
13
+
14
+ export const newTabTool: ToolDef = {
15
+ displayName: "NewTab",
16
+ getHeaderParams(input: Record<string, unknown>): string {
17
+ const url = (input?.url || "") as string;
18
+ return url.length > 40 ? url.substring(0, 37) + "..." : url;
19
+ },
20
+ renderUI(
21
+ rawInput: Record<string, unknown>,
22
+ status: ToolStatus,
23
+ parsedResult?: ParsedToolResult,
24
+ ): React.ReactElement {
25
+ const pr = NewTabParams.safeParse(snakeToCamel(rawInput));
26
+ if (!pr.success)
27
+ return (
28
+ <View flexDirection="column">
29
+ <ToolHeader name="NewTab" status="error" />
30
+ <ToolResult color="red">Invalid params</ToolResult>
31
+ </View>
32
+ );
33
+ const url = pr.data.url || "";
34
+ const truncatedUrl = url.length > 40 ? url.substring(0, 37) + "..." : url;
35
+ const displayParam = truncatedUrl || undefined;
36
+ const isExecuting = !parsedResult && status === "executing";
37
+
38
+ if (isExecuting)
39
+ return <ToolHeader name="NewTab" params={displayParam} status="executing" showSpinner />;
40
+ if (status === "error")
41
+ return (
42
+ <View flexDirection="column">
43
+ <ToolHeader name="NewTab" params={displayParam} status="error" />
44
+ <ToolResult color="red">Error opening new tab</ToolResult>
45
+ </View>
46
+ );
47
+ if (!parsedResult)
48
+ return (
49
+ <View flexDirection="column">
50
+ <ToolHeader name="NewTab" params={displayParam} status="pending" />
51
+ </View>
52
+ );
53
+ return (
54
+ <View flexDirection="column">
55
+ <ToolHeader name="NewTab" params={displayParam} status="success" />
56
+ <ToolResult>{parsedResult.summary ?? "Opened tab"}</ToolResult>
57
+ </View>
58
+ );
59
+ },
60
+ };
@@ -0,0 +1,63 @@
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
+ import { coerceOptionalNumber } from "../shared/zod-coercion.js";
12
+
13
+ const PerformActionParams = z.object({
14
+ id: z.string(),
15
+ action: z.enum(["click", "type", "hover", "scroll", "focus", "select"]),
16
+ text: z.string().optional(),
17
+ scroll_direction: z.enum(["up", "down", "left", "right"]).optional(),
18
+ scroll_amount: coerceOptionalNumber,
19
+ held_keys: z.string().optional(),
20
+ tab_id: coerceOptionalNumber,
21
+ });
22
+
23
+ export const performActionTool: ToolDef = {
24
+ displayName: "PerformAction",
25
+ getHeaderParams(input: Record<string, unknown>): string {
26
+ const elementId = String(input?.id || "").substring(0, 20);
27
+ return `id: ${elementId}`;
28
+ },
29
+ renderUI(
30
+ rawInput: Record<string, unknown>,
31
+ status: ToolStatus,
32
+ parsedResult?: ParsedToolResult,
33
+ ): React.ReactElement {
34
+ const pr = PerformActionParams.safeParse(snakeToCamel(rawInput));
35
+ const action = (pr.success ? pr.data.action : rawInput?.action || "action") as string;
36
+ const elementId = String(rawInput?.id || "").substring(0, 20);
37
+ const displayParams = `id: ${elementId}`;
38
+ const actionName = action.charAt(0).toUpperCase() + action.slice(1);
39
+ const isExecuting = !parsedResult && status === "executing";
40
+
41
+ if (isExecuting)
42
+ return <ToolHeader name={actionName} params={displayParams} status="executing" showSpinner />;
43
+ if (status === "error")
44
+ return (
45
+ <View flexDirection="column">
46
+ <ToolHeader name={actionName} params={displayParams} status="error" />
47
+ <ToolResult color="red">Error performing action</ToolResult>
48
+ </View>
49
+ );
50
+ if (!parsedResult)
51
+ return (
52
+ <View flexDirection="column">
53
+ <ToolHeader name={actionName} params={displayParams} status="pending" />
54
+ </View>
55
+ );
56
+ return (
57
+ <View flexDirection="column">
58
+ <ToolHeader name={actionName} params={displayParams} status="success" />
59
+ <ToolResult>Performed {action}</ToolResult>
60
+ </View>
61
+ );
62
+ },
63
+ };
@@ -0,0 +1,43 @@
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 refreshTabTool: ToolDef = {
11
+ displayName: "Refresh",
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
+ const isExecuting = !parsedResult && status === "executing";
21
+
22
+ if (isExecuting) return <ToolHeader name="Refresh" status="pending" showSpinner />;
23
+ if (!parsedResult)
24
+ return (
25
+ <View flexDirection="column">
26
+ <ToolHeader name="Refresh" status="pending" />
27
+ </View>
28
+ );
29
+ if (status === "error")
30
+ return (
31
+ <View flexDirection="column">
32
+ <ToolHeader name="Refresh" status="error" />
33
+ <ToolResult color="red">Error refreshing tab</ToolResult>
34
+ </View>
35
+ );
36
+ return (
37
+ <View flexDirection="column">
38
+ <ToolHeader name="Refresh" status="success" />
39
+ <ToolResult>Refreshed</ToolResult>
40
+ </View>
41
+ );
42
+ },
43
+ };
@@ -0,0 +1,58 @@
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
+ import { coerceNumber } from "../shared/zod-coercion.js";
12
+
13
+ const SwitchTabParams = z.object({ id: coerceNumber });
14
+
15
+ export const switchTabTool: ToolDef = {
16
+ displayName: "SwitchTab",
17
+ getHeaderParams(input: Record<string, unknown>): string {
18
+ return `id: ${input?.id ?? ""}`;
19
+ },
20
+ renderUI(
21
+ rawInput: Record<string, unknown>,
22
+ status: ToolStatus,
23
+ parsedResult?: ParsedToolResult,
24
+ ): React.ReactElement {
25
+ const pr = SwitchTabParams.safeParse(snakeToCamel(rawInput));
26
+ if (!pr.success)
27
+ return (
28
+ <View flexDirection="column">
29
+ <ToolHeader name="SwitchTab" status="error" />
30
+ <ToolResult color="red">Invalid params</ToolResult>
31
+ </View>
32
+ );
33
+ const tabId = pr.data.id;
34
+ const isExecuting = !parsedResult && status === "executing";
35
+
36
+ if (isExecuting)
37
+ return <ToolHeader name="SwitchTab" params={`id: ${tabId}`} status="executing" showSpinner />;
38
+ if (status === "error")
39
+ return (
40
+ <View flexDirection="column">
41
+ <ToolHeader name="SwitchTab" params={`id: ${tabId}`} status="error" />
42
+ <ToolResult color="red">Error switching tab</ToolResult>
43
+ </View>
44
+ );
45
+ if (!parsedResult)
46
+ return (
47
+ <View flexDirection="column">
48
+ <ToolHeader name="SwitchTab" params={`id: ${tabId}`} status="pending" />
49
+ </View>
50
+ );
51
+ return (
52
+ <View flexDirection="column">
53
+ <ToolHeader name="SwitchTab" params={`id: ${tabId}`} status="success" />
54
+ <ToolResult>Switched to tab {tabId}</ToolResult>
55
+ </View>
56
+ );
57
+ },
58
+ };