whale-code 6.4.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/README.md +95 -0
- package/bin/swag-agent.js +9 -0
- package/bin/swagmanager-mcp.js +321 -0
- package/dist/cli/app.d.ts +26 -0
- package/dist/cli/app.js +64 -0
- package/dist/cli/chat/AgentSelector.d.ts +14 -0
- package/dist/cli/chat/AgentSelector.js +14 -0
- package/dist/cli/chat/ChatApp.d.ts +9 -0
- package/dist/cli/chat/ChatApp.js +267 -0
- package/dist/cli/chat/ChatInput.d.ts +39 -0
- package/dist/cli/chat/ChatInput.js +509 -0
- package/dist/cli/chat/MarkdownText.d.ts +10 -0
- package/dist/cli/chat/MarkdownText.js +20 -0
- package/dist/cli/chat/MessageList.d.ts +37 -0
- package/dist/cli/chat/MessageList.js +80 -0
- package/dist/cli/chat/ModelSelector.d.ts +20 -0
- package/dist/cli/chat/ModelSelector.js +73 -0
- package/dist/cli/chat/RewindViewer.d.ts +26 -0
- package/dist/cli/chat/RewindViewer.js +185 -0
- package/dist/cli/chat/StoreSelector.d.ts +14 -0
- package/dist/cli/chat/StoreSelector.js +24 -0
- package/dist/cli/chat/StreamingText.d.ts +12 -0
- package/dist/cli/chat/StreamingText.js +12 -0
- package/dist/cli/chat/SubagentPanel.d.ts +45 -0
- package/dist/cli/chat/SubagentPanel.js +110 -0
- package/dist/cli/chat/TeamPanel.d.ts +21 -0
- package/dist/cli/chat/TeamPanel.js +42 -0
- package/dist/cli/chat/ToolIndicator.d.ts +25 -0
- package/dist/cli/chat/ToolIndicator.js +436 -0
- package/dist/cli/chat/hooks/useAgentLoop.d.ts +39 -0
- package/dist/cli/chat/hooks/useAgentLoop.js +382 -0
- package/dist/cli/chat/hooks/useSlashCommands.d.ts +37 -0
- package/dist/cli/chat/hooks/useSlashCommands.js +387 -0
- package/dist/cli/commands/config-cmd.d.ts +10 -0
- package/dist/cli/commands/config-cmd.js +99 -0
- package/dist/cli/commands/doctor.d.ts +14 -0
- package/dist/cli/commands/doctor.js +172 -0
- package/dist/cli/commands/init.d.ts +16 -0
- package/dist/cli/commands/init.js +278 -0
- package/dist/cli/commands/mcp.d.ts +12 -0
- package/dist/cli/commands/mcp.js +162 -0
- package/dist/cli/login/LoginApp.d.ts +7 -0
- package/dist/cli/login/LoginApp.js +157 -0
- package/dist/cli/print-mode.d.ts +31 -0
- package/dist/cli/print-mode.js +202 -0
- package/dist/cli/serve-mode.d.ts +37 -0
- package/dist/cli/serve-mode.js +636 -0
- package/dist/cli/services/agent-definitions.d.ts +25 -0
- package/dist/cli/services/agent-definitions.js +91 -0
- package/dist/cli/services/agent-events.d.ts +178 -0
- package/dist/cli/services/agent-events.js +175 -0
- package/dist/cli/services/agent-loop.d.ts +90 -0
- package/dist/cli/services/agent-loop.js +762 -0
- package/dist/cli/services/agent-worker-base.d.ts +97 -0
- package/dist/cli/services/agent-worker-base.js +220 -0
- package/dist/cli/services/auth-service.d.ts +30 -0
- package/dist/cli/services/auth-service.js +160 -0
- package/dist/cli/services/background-processes.d.ts +126 -0
- package/dist/cli/services/background-processes.js +318 -0
- package/dist/cli/services/browser-auth.d.ts +24 -0
- package/dist/cli/services/browser-auth.js +180 -0
- package/dist/cli/services/claude-md-loader.d.ts +16 -0
- package/dist/cli/services/claude-md-loader.js +58 -0
- package/dist/cli/services/config-store.d.ts +47 -0
- package/dist/cli/services/config-store.js +79 -0
- package/dist/cli/services/debug-log.d.ts +10 -0
- package/dist/cli/services/debug-log.js +52 -0
- package/dist/cli/services/error-logger.d.ts +58 -0
- package/dist/cli/services/error-logger.js +269 -0
- package/dist/cli/services/file-history.d.ts +21 -0
- package/dist/cli/services/file-history.js +83 -0
- package/dist/cli/services/format-server-response.d.ts +16 -0
- package/dist/cli/services/format-server-response.js +440 -0
- package/dist/cli/services/git-context.d.ts +11 -0
- package/dist/cli/services/git-context.js +66 -0
- package/dist/cli/services/hooks.d.ts +85 -0
- package/dist/cli/services/hooks.js +258 -0
- package/dist/cli/services/interactive-tools.d.ts +125 -0
- package/dist/cli/services/interactive-tools.js +260 -0
- package/dist/cli/services/keybinding-manager.d.ts +52 -0
- package/dist/cli/services/keybinding-manager.js +115 -0
- package/dist/cli/services/local-tools.d.ts +22 -0
- package/dist/cli/services/local-tools.js +697 -0
- package/dist/cli/services/lsp-manager.d.ts +18 -0
- package/dist/cli/services/lsp-manager.js +717 -0
- package/dist/cli/services/mcp-client.d.ts +48 -0
- package/dist/cli/services/mcp-client.js +157 -0
- package/dist/cli/services/memory-manager.d.ts +16 -0
- package/dist/cli/services/memory-manager.js +57 -0
- package/dist/cli/services/model-manager.d.ts +18 -0
- package/dist/cli/services/model-manager.js +71 -0
- package/dist/cli/services/model-router.d.ts +26 -0
- package/dist/cli/services/model-router.js +149 -0
- package/dist/cli/services/permission-modes.d.ts +13 -0
- package/dist/cli/services/permission-modes.js +43 -0
- package/dist/cli/services/rewind.d.ts +84 -0
- package/dist/cli/services/rewind.js +194 -0
- package/dist/cli/services/ripgrep.d.ts +28 -0
- package/dist/cli/services/ripgrep.js +138 -0
- package/dist/cli/services/sandbox.d.ts +29 -0
- package/dist/cli/services/sandbox.js +97 -0
- package/dist/cli/services/server-tools.d.ts +61 -0
- package/dist/cli/services/server-tools.js +543 -0
- package/dist/cli/services/session-persistence.d.ts +23 -0
- package/dist/cli/services/session-persistence.js +99 -0
- package/dist/cli/services/subagent-worker.d.ts +19 -0
- package/dist/cli/services/subagent-worker.js +41 -0
- package/dist/cli/services/subagent.d.ts +47 -0
- package/dist/cli/services/subagent.js +647 -0
- package/dist/cli/services/system-prompt.d.ts +7 -0
- package/dist/cli/services/system-prompt.js +198 -0
- package/dist/cli/services/team-lead.d.ts +73 -0
- package/dist/cli/services/team-lead.js +512 -0
- package/dist/cli/services/team-state.d.ts +77 -0
- package/dist/cli/services/team-state.js +398 -0
- package/dist/cli/services/teammate.d.ts +31 -0
- package/dist/cli/services/teammate.js +689 -0
- package/dist/cli/services/telemetry.d.ts +61 -0
- package/dist/cli/services/telemetry.js +209 -0
- package/dist/cli/services/tools/agent-tools.d.ts +14 -0
- package/dist/cli/services/tools/agent-tools.js +347 -0
- package/dist/cli/services/tools/file-ops.d.ts +15 -0
- package/dist/cli/services/tools/file-ops.js +487 -0
- package/dist/cli/services/tools/search-tools.d.ts +8 -0
- package/dist/cli/services/tools/search-tools.js +186 -0
- package/dist/cli/services/tools/shell-exec.d.ts +10 -0
- package/dist/cli/services/tools/shell-exec.js +168 -0
- package/dist/cli/services/tools/task-manager.d.ts +28 -0
- package/dist/cli/services/tools/task-manager.js +209 -0
- package/dist/cli/services/tools/web-tools.d.ts +11 -0
- package/dist/cli/services/tools/web-tools.js +395 -0
- package/dist/cli/setup/SetupApp.d.ts +9 -0
- package/dist/cli/setup/SetupApp.js +191 -0
- package/dist/cli/shared/MatrixIntro.d.ts +4 -0
- package/dist/cli/shared/MatrixIntro.js +83 -0
- package/dist/cli/shared/Theme.d.ts +74 -0
- package/dist/cli/shared/Theme.js +127 -0
- package/dist/cli/shared/WhaleBanner.d.ts +10 -0
- package/dist/cli/shared/WhaleBanner.js +12 -0
- package/dist/cli/shared/markdown.d.ts +21 -0
- package/dist/cli/shared/markdown.js +756 -0
- package/dist/cli/status/StatusApp.d.ts +4 -0
- package/dist/cli/status/StatusApp.js +105 -0
- package/dist/cli/stores/StoreApp.d.ts +7 -0
- package/dist/cli/stores/StoreApp.js +81 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +538 -0
- package/dist/local-agent/connection.d.ts +48 -0
- package/dist/local-agent/connection.js +332 -0
- package/dist/local-agent/discovery.d.ts +18 -0
- package/dist/local-agent/discovery.js +146 -0
- package/dist/local-agent/executor.d.ts +34 -0
- package/dist/local-agent/executor.js +241 -0
- package/dist/local-agent/index.d.ts +14 -0
- package/dist/local-agent/index.js +198 -0
- package/dist/node/adapters/base.d.ts +35 -0
- package/dist/node/adapters/base.js +10 -0
- package/dist/node/adapters/discord.d.ts +29 -0
- package/dist/node/adapters/discord.js +299 -0
- package/dist/node/adapters/email.d.ts +23 -0
- package/dist/node/adapters/email.js +218 -0
- package/dist/node/adapters/imessage.d.ts +17 -0
- package/dist/node/adapters/imessage.js +118 -0
- package/dist/node/adapters/slack.d.ts +26 -0
- package/dist/node/adapters/slack.js +259 -0
- package/dist/node/adapters/sms.d.ts +23 -0
- package/dist/node/adapters/sms.js +161 -0
- package/dist/node/adapters/telegram.d.ts +17 -0
- package/dist/node/adapters/telegram.js +101 -0
- package/dist/node/adapters/webchat.d.ts +27 -0
- package/dist/node/adapters/webchat.js +160 -0
- package/dist/node/adapters/whatsapp.d.ts +28 -0
- package/dist/node/adapters/whatsapp.js +230 -0
- package/dist/node/cli.d.ts +2 -0
- package/dist/node/cli.js +325 -0
- package/dist/node/config.d.ts +17 -0
- package/dist/node/config.js +31 -0
- package/dist/node/runtime.d.ts +50 -0
- package/dist/node/runtime.js +351 -0
- package/dist/server/handlers/__test-utils__/mock-supabase.d.ts +11 -0
- package/dist/server/handlers/__test-utils__/mock-supabase.js +393 -0
- package/dist/server/handlers/analytics.d.ts +17 -0
- package/dist/server/handlers/analytics.js +266 -0
- package/dist/server/handlers/api-keys.d.ts +6 -0
- package/dist/server/handlers/api-keys.js +221 -0
- package/dist/server/handlers/billing.d.ts +33 -0
- package/dist/server/handlers/billing.js +272 -0
- package/dist/server/handlers/browser.d.ts +10 -0
- package/dist/server/handlers/browser.js +517 -0
- package/dist/server/handlers/catalog.d.ts +99 -0
- package/dist/server/handlers/catalog.js +976 -0
- package/dist/server/handlers/comms.d.ts +254 -0
- package/dist/server/handlers/comms.js +588 -0
- package/dist/server/handlers/creations.d.ts +6 -0
- package/dist/server/handlers/creations.js +479 -0
- package/dist/server/handlers/crm.d.ts +89 -0
- package/dist/server/handlers/crm.js +538 -0
- package/dist/server/handlers/discovery.d.ts +6 -0
- package/dist/server/handlers/discovery.js +288 -0
- package/dist/server/handlers/embeddings.d.ts +92 -0
- package/dist/server/handlers/embeddings.js +197 -0
- package/dist/server/handlers/enrichment.d.ts +8 -0
- package/dist/server/handlers/enrichment.js +768 -0
- package/dist/server/handlers/image-gen.d.ts +6 -0
- package/dist/server/handlers/image-gen.js +409 -0
- package/dist/server/handlers/inventory.d.ts +319 -0
- package/dist/server/handlers/inventory.js +447 -0
- package/dist/server/handlers/kali.d.ts +10 -0
- package/dist/server/handlers/kali.js +210 -0
- package/dist/server/handlers/llm-providers.d.ts +6 -0
- package/dist/server/handlers/llm-providers.js +673 -0
- package/dist/server/handlers/local-agent.d.ts +6 -0
- package/dist/server/handlers/local-agent.js +118 -0
- package/dist/server/handlers/meta-ads.d.ts +111 -0
- package/dist/server/handlers/meta-ads.js +2279 -0
- package/dist/server/handlers/nodes.d.ts +33 -0
- package/dist/server/handlers/nodes.js +699 -0
- package/dist/server/handlers/operations.d.ts +138 -0
- package/dist/server/handlers/operations.js +131 -0
- package/dist/server/handlers/platform.d.ts +23 -0
- package/dist/server/handlers/platform.js +227 -0
- package/dist/server/handlers/supply-chain.d.ts +19 -0
- package/dist/server/handlers/supply-chain.js +327 -0
- package/dist/server/handlers/transcription.d.ts +17 -0
- package/dist/server/handlers/transcription.js +121 -0
- package/dist/server/handlers/video-gen.d.ts +6 -0
- package/dist/server/handlers/video-gen.js +466 -0
- package/dist/server/handlers/voice.d.ts +8 -0
- package/dist/server/handlers/voice.js +1146 -0
- package/dist/server/handlers/workflow-steps.d.ts +86 -0
- package/dist/server/handlers/workflow-steps.js +2349 -0
- package/dist/server/handlers/workflows.d.ts +7 -0
- package/dist/server/handlers/workflows.js +989 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +2427 -0
- package/dist/server/lib/batch-client.d.ts +80 -0
- package/dist/server/lib/batch-client.js +467 -0
- package/dist/server/lib/code-worker-pool.d.ts +31 -0
- package/dist/server/lib/code-worker-pool.js +224 -0
- package/dist/server/lib/code-worker.d.ts +1 -0
- package/dist/server/lib/code-worker.js +188 -0
- package/dist/server/lib/compaction-service.d.ts +32 -0
- package/dist/server/lib/compaction-service.js +162 -0
- package/dist/server/lib/logger.d.ts +19 -0
- package/dist/server/lib/logger.js +46 -0
- package/dist/server/lib/otel.d.ts +38 -0
- package/dist/server/lib/otel.js +126 -0
- package/dist/server/lib/pg-rate-limiter.d.ts +21 -0
- package/dist/server/lib/pg-rate-limiter.js +86 -0
- package/dist/server/lib/prompt-sanitizer.d.ts +37 -0
- package/dist/server/lib/prompt-sanitizer.js +177 -0
- package/dist/server/lib/provider-capabilities.d.ts +85 -0
- package/dist/server/lib/provider-capabilities.js +190 -0
- package/dist/server/lib/provider-failover.d.ts +74 -0
- package/dist/server/lib/provider-failover.js +210 -0
- package/dist/server/lib/rate-limiter.d.ts +39 -0
- package/dist/server/lib/rate-limiter.js +147 -0
- package/dist/server/lib/server-agent-loop.d.ts +107 -0
- package/dist/server/lib/server-agent-loop.js +667 -0
- package/dist/server/lib/server-subagent.d.ts +78 -0
- package/dist/server/lib/server-subagent.js +203 -0
- package/dist/server/lib/session-checkpoint.d.ts +51 -0
- package/dist/server/lib/session-checkpoint.js +145 -0
- package/dist/server/lib/ssrf-guard.d.ts +13 -0
- package/dist/server/lib/ssrf-guard.js +240 -0
- package/dist/server/lib/supabase-client.d.ts +7 -0
- package/dist/server/lib/supabase-client.js +78 -0
- package/dist/server/lib/template-resolver.d.ts +31 -0
- package/dist/server/lib/template-resolver.js +215 -0
- package/dist/server/lib/utils.d.ts +16 -0
- package/dist/server/lib/utils.js +147 -0
- package/dist/server/local-agent-gateway.d.ts +82 -0
- package/dist/server/local-agent-gateway.js +426 -0
- package/dist/server/providers/anthropic.d.ts +20 -0
- package/dist/server/providers/anthropic.js +199 -0
- package/dist/server/providers/bedrock.d.ts +20 -0
- package/dist/server/providers/bedrock.js +194 -0
- package/dist/server/providers/gemini.d.ts +24 -0
- package/dist/server/providers/gemini.js +486 -0
- package/dist/server/providers/openai.d.ts +24 -0
- package/dist/server/providers/openai.js +522 -0
- package/dist/server/providers/registry.d.ts +32 -0
- package/dist/server/providers/registry.js +58 -0
- package/dist/server/providers/shared.d.ts +32 -0
- package/dist/server/providers/shared.js +124 -0
- package/dist/server/providers/types.d.ts +92 -0
- package/dist/server/providers/types.js +12 -0
- package/dist/server/proxy-handlers.d.ts +6 -0
- package/dist/server/proxy-handlers.js +89 -0
- package/dist/server/tool-router.d.ts +149 -0
- package/dist/server/tool-router.js +803 -0
- package/dist/server/validation.d.ts +24 -0
- package/dist/server/validation.js +301 -0
- package/dist/server/worker.d.ts +19 -0
- package/dist/server/worker.js +201 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +181 -0
- package/dist/shared/agent-core.d.ts +157 -0
- package/dist/shared/agent-core.js +534 -0
- package/dist/shared/anthropic-types.d.ts +105 -0
- package/dist/shared/anthropic-types.js +7 -0
- package/dist/shared/api-client.d.ts +90 -0
- package/dist/shared/api-client.js +379 -0
- package/dist/shared/constants.d.ts +33 -0
- package/dist/shared/constants.js +80 -0
- package/dist/shared/sse-parser.d.ts +26 -0
- package/dist/shared/sse-parser.js +259 -0
- package/dist/shared/tool-dispatch.d.ts +52 -0
- package/dist/shared/tool-dispatch.js +191 -0
- package/dist/shared/types.d.ts +72 -0
- package/dist/shared/types.js +7 -0
- package/dist/updater.d.ts +25 -0
- package/dist/updater.js +140 -0
- package/dist/webchat/widget.d.ts +0 -0
- package/dist/webchat/widget.js +397 -0
- package/package.json +95 -0
- package/src/cli/services/builtin-skills/commit.md +19 -0
- package/src/cli/services/builtin-skills/review-pr.md +21 -0
- package/src/cli/services/builtin-skills/review.md +18 -0
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Tools — tool registry, definitions, and dispatcher
|
|
3
|
+
*
|
|
4
|
+
* This is a thin facade: tool implementations live in `./tools/`.
|
|
5
|
+
* All consumers import from this file for backward compatibility.
|
|
6
|
+
*/
|
|
7
|
+
// Re-export task persistence API (used by ChatApp, agent-loop)
|
|
8
|
+
export { loadTodos, setTodoSessionId, getTodoState } from "./tools/task-manager.js";
|
|
9
|
+
// Import tool implementations from extracted modules
|
|
10
|
+
import { readFile, writeFile, editFile, multiEdit, notebookEdit, listDirectory, searchFiles, searchContent, resolvePath } from "./tools/file-ops.js";
|
|
11
|
+
import { readFileSync, existsSync, statSync } from "fs";
|
|
12
|
+
import { resolve } from "path";
|
|
13
|
+
import { globSearch, grepSearch } from "./tools/search-tools.js";
|
|
14
|
+
import { runCommand, bashOutput, killShell, listShellsFn } from "./tools/shell-exec.js";
|
|
15
|
+
import { webFetch, webSearch } from "./tools/web-tools.js";
|
|
16
|
+
import { tasksTool } from "./tools/task-manager.js";
|
|
17
|
+
import { taskTool, teamCreateTool, taskOutput, taskStop, configTool, askUser, lspTool, skillTool } from "./tools/agent-tools.js";
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// TOOL NAMES
|
|
20
|
+
// ============================================================================
|
|
21
|
+
export const LOCAL_TOOL_NAMES = new Set([
|
|
22
|
+
// Original
|
|
23
|
+
"read_file",
|
|
24
|
+
"read_many_files",
|
|
25
|
+
"write_file",
|
|
26
|
+
"edit_file",
|
|
27
|
+
"list_directory",
|
|
28
|
+
"search_files",
|
|
29
|
+
"search_content",
|
|
30
|
+
"run_command",
|
|
31
|
+
// New (Claude Code parity)
|
|
32
|
+
"glob",
|
|
33
|
+
"grep",
|
|
34
|
+
"notebook_edit",
|
|
35
|
+
"web_fetch",
|
|
36
|
+
"tasks", // Replaces todo_write — action-based CRUD with IDs, deps
|
|
37
|
+
"multi_edit", // Multi-edit tool
|
|
38
|
+
"task", // Subagent tool
|
|
39
|
+
"team_create", // Agent team tool
|
|
40
|
+
// Background process tools
|
|
41
|
+
"bash_output",
|
|
42
|
+
"kill_shell",
|
|
43
|
+
"list_shells",
|
|
44
|
+
// Background task tools (shells + agents)
|
|
45
|
+
"task_output",
|
|
46
|
+
"task_stop",
|
|
47
|
+
// Web search
|
|
48
|
+
"web_search",
|
|
49
|
+
// Claude Code parity — consolidated tools
|
|
50
|
+
"config", // Settings + plan mode
|
|
51
|
+
"ask_user", // Structured questions
|
|
52
|
+
// Code intelligence
|
|
53
|
+
"lsp",
|
|
54
|
+
// Skills
|
|
55
|
+
"skill",
|
|
56
|
+
]);
|
|
57
|
+
export function isLocalTool(name) {
|
|
58
|
+
return LOCAL_TOOL_NAMES.has(name);
|
|
59
|
+
}
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// TOOL DEFINITIONS (for Anthropic API)
|
|
62
|
+
// ============================================================================
|
|
63
|
+
export const LOCAL_TOOL_DEFINITIONS = [
|
|
64
|
+
// ------------------------------------------------------------------
|
|
65
|
+
// ENHANCED ORIGINALS
|
|
66
|
+
// ------------------------------------------------------------------
|
|
67
|
+
{
|
|
68
|
+
name: "read_file",
|
|
69
|
+
description: "Read file contents. Supports line-based pagination for large files. Reads images (png/jpg/gif/webp) as visual content. Reads audio files (mp3/wav/aiff/aac/ogg/flac/m4a) as audio content. Extracts text from PDFs. For multiple files, emit all read_file calls in one response — they execute in parallel.",
|
|
70
|
+
input_schema: {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
path: { type: "string", description: "Absolute or relative path to the file" },
|
|
74
|
+
offset: { type: "number", description: "Line number to start reading from (1-based). Omit to read from start." },
|
|
75
|
+
limit: { type: "number", description: "Max number of lines to read. Omit to read all." },
|
|
76
|
+
pages: { type: "string", description: "Page range for PDFs (e.g. '1-5', '3', '10-20'). Only for .pdf files." },
|
|
77
|
+
},
|
|
78
|
+
required: ["path"],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "read_many_files",
|
|
83
|
+
description: "Read multiple files matching glob patterns in a single call. More efficient than multiple read_file calls. Returns concatenated content with file headers. Files >500 lines are truncated to first 100 lines.",
|
|
84
|
+
input_schema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
pattern: { type: "string", description: "Glob pattern like 'src/**/*.ts' or '*.json'" },
|
|
88
|
+
path: { type: "string", description: "Base directory to search in (defaults to cwd)" },
|
|
89
|
+
limit: { type: "number", description: "Max files to read (default 20, max 50)" },
|
|
90
|
+
},
|
|
91
|
+
required: ["pattern"],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "write_file",
|
|
96
|
+
description: "Write content to a file, creating it and parent directories if needed. For multiple independent files, emit all write_file calls in one response.",
|
|
97
|
+
input_schema: {
|
|
98
|
+
type: "object",
|
|
99
|
+
properties: {
|
|
100
|
+
path: { type: "string", description: "Absolute or relative path to the file" },
|
|
101
|
+
content: { type: "string", description: "Content to write to the file" },
|
|
102
|
+
},
|
|
103
|
+
required: ["path", "content"],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "edit_file",
|
|
108
|
+
description: "Edit a file by replacing an exact string match. Supports replacing all occurrences.",
|
|
109
|
+
input_schema: {
|
|
110
|
+
type: "object",
|
|
111
|
+
properties: {
|
|
112
|
+
path: { type: "string", description: "Absolute or relative path to the file" },
|
|
113
|
+
old_string: { type: "string", description: "Exact text to find in the file" },
|
|
114
|
+
new_string: { type: "string", description: "Text to replace old_string with" },
|
|
115
|
+
replace_all: { type: "boolean", description: "Replace ALL occurrences (default false — replaces first only)" },
|
|
116
|
+
},
|
|
117
|
+
required: ["path", "old_string", "new_string"],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "list_directory",
|
|
122
|
+
description: "List files and directories at the specified path",
|
|
123
|
+
input_schema: {
|
|
124
|
+
type: "object",
|
|
125
|
+
properties: {
|
|
126
|
+
path: { type: "string", description: "Absolute or relative path to the directory" },
|
|
127
|
+
recursive: { type: "boolean", description: "List recursively (default false, max 200 entries)" },
|
|
128
|
+
},
|
|
129
|
+
required: ["path"],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "search_files",
|
|
134
|
+
description: "Search for files matching a name pattern using find",
|
|
135
|
+
input_schema: {
|
|
136
|
+
type: "object",
|
|
137
|
+
properties: {
|
|
138
|
+
pattern: { type: "string", description: "File name pattern (e.g. *.ts, *.swift)" },
|
|
139
|
+
path: { type: "string", description: "Directory to search in" },
|
|
140
|
+
},
|
|
141
|
+
required: ["pattern", "path"],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "search_content",
|
|
146
|
+
description: "Search for text content in files (grep-like). For advanced search, use the 'grep' tool.",
|
|
147
|
+
input_schema: {
|
|
148
|
+
type: "object",
|
|
149
|
+
properties: {
|
|
150
|
+
query: { type: "string", description: "Text or regex pattern to search for" },
|
|
151
|
+
path: { type: "string", description: "Directory to search in" },
|
|
152
|
+
file_pattern: { type: "string", description: "Optional file glob filter (e.g. *.ts)" },
|
|
153
|
+
},
|
|
154
|
+
required: ["query", "path"],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "run_command",
|
|
159
|
+
description: "Execute a shell command. Output streams live. Use run_in_background:true for dev servers/watchers — after starting, use bash_output to verify. On macOS use python3 not python.",
|
|
160
|
+
input_schema: {
|
|
161
|
+
type: "object",
|
|
162
|
+
properties: {
|
|
163
|
+
command: { type: "string", description: "Shell command to execute" },
|
|
164
|
+
working_directory: { type: "string", description: "Working directory for the command" },
|
|
165
|
+
timeout: { type: "number", description: "Timeout in milliseconds (default 30000, max 300000)" },
|
|
166
|
+
description: { type: "string", description: "Short description of what this command does" },
|
|
167
|
+
run_in_background: { type: "boolean", description: "Run in background (for dev servers, watchers). Returns process ID immediately." },
|
|
168
|
+
},
|
|
169
|
+
required: ["command"],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
// ------------------------------------------------------------------
|
|
173
|
+
// NEW: GLOB — pattern-based file finder
|
|
174
|
+
// ------------------------------------------------------------------
|
|
175
|
+
{
|
|
176
|
+
name: "glob",
|
|
177
|
+
description: "Fast file pattern matching. Use glob patterns like '**/*.ts' or 'src/**/*.tsx'. Returns matching file paths. For multiple patterns, emit all glob calls in one response — they execute in parallel.",
|
|
178
|
+
input_schema: {
|
|
179
|
+
type: "object",
|
|
180
|
+
properties: {
|
|
181
|
+
pattern: { type: "string", description: "Glob pattern (e.g. '**/*.ts', 'src/**/*.tsx', '*.json')" },
|
|
182
|
+
path: { type: "string", description: "Base directory to search in (defaults to cwd)" },
|
|
183
|
+
},
|
|
184
|
+
required: ["pattern"],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
// ------------------------------------------------------------------
|
|
188
|
+
// NEW: GREP — advanced content search
|
|
189
|
+
// ------------------------------------------------------------------
|
|
190
|
+
{
|
|
191
|
+
name: "grep",
|
|
192
|
+
description: "Search file contents with regex, context lines, and multiple output modes. More powerful than search_content. For multiple patterns, emit all grep calls in one response — they execute in parallel.",
|
|
193
|
+
input_schema: {
|
|
194
|
+
type: "object",
|
|
195
|
+
properties: {
|
|
196
|
+
pattern: { type: "string", description: "Regex pattern to search for" },
|
|
197
|
+
path: { type: "string", description: "File or directory to search in (defaults to cwd)" },
|
|
198
|
+
glob: { type: "string", description: "Glob pattern to filter files (e.g. '*.ts', '*.{ts,tsx}')" },
|
|
199
|
+
output_mode: {
|
|
200
|
+
type: "string",
|
|
201
|
+
enum: ["content", "files_with_matches", "count"],
|
|
202
|
+
description: "Output mode: 'content' shows matching lines, 'files_with_matches' shows file paths (default), 'count' shows match counts",
|
|
203
|
+
},
|
|
204
|
+
context: { type: "number", description: "Lines of context before and after each match" },
|
|
205
|
+
before: { type: "number", description: "Lines to show before each match (-B)" },
|
|
206
|
+
after: { type: "number", description: "Lines to show after each match (-A)" },
|
|
207
|
+
case_insensitive: { type: "boolean", description: "Case insensitive search (default false)" },
|
|
208
|
+
type: { type: "string", description: "File type shorthand: js, ts, py, go, rust, java, etc." },
|
|
209
|
+
head_limit: { type: "number", description: "Max results to return (default 200)" },
|
|
210
|
+
offset: { type: "number", description: "Skip first N entries before applying head_limit (default 0)" },
|
|
211
|
+
multiline: { type: "boolean", description: "Enable multiline mode where . matches newlines (requires rg)" },
|
|
212
|
+
},
|
|
213
|
+
required: ["pattern"],
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
// ------------------------------------------------------------------
|
|
217
|
+
// NEW: NOTEBOOK_EDIT — Jupyter notebook cell editing
|
|
218
|
+
// ------------------------------------------------------------------
|
|
219
|
+
{
|
|
220
|
+
name: "notebook_edit",
|
|
221
|
+
description: "Edit Jupyter notebook (.ipynb) cells: replace, insert, or delete cells.",
|
|
222
|
+
input_schema: {
|
|
223
|
+
type: "object",
|
|
224
|
+
properties: {
|
|
225
|
+
notebook_path: { type: "string", description: "Path to the .ipynb file" },
|
|
226
|
+
cell_id: { type: "string", description: "Cell ID or 0-based index. For insert, new cell goes after this." },
|
|
227
|
+
new_source: { type: "string", description: "New source code/markdown for the cell" },
|
|
228
|
+
cell_type: { type: "string", enum: ["code", "markdown"], description: "Cell type (required for insert)" },
|
|
229
|
+
edit_mode: { type: "string", enum: ["replace", "insert", "delete"], description: "Edit mode (default: replace)" },
|
|
230
|
+
},
|
|
231
|
+
required: ["notebook_path", "new_source"],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
// ------------------------------------------------------------------
|
|
235
|
+
// NEW: WEB_FETCH — fetch URL content
|
|
236
|
+
// ------------------------------------------------------------------
|
|
237
|
+
{
|
|
238
|
+
name: "web_fetch",
|
|
239
|
+
description: "Fetch content from a URL and return as cleaned text/markdown. Strips HTML, scripts, styles.",
|
|
240
|
+
input_schema: {
|
|
241
|
+
type: "object",
|
|
242
|
+
properties: {
|
|
243
|
+
url: { type: "string", description: "URL to fetch" },
|
|
244
|
+
prompt: { type: "string", description: "What to extract from the page (used for context)" },
|
|
245
|
+
},
|
|
246
|
+
required: ["url"],
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
// ------------------------------------------------------------------
|
|
250
|
+
// NEW: WEB_SEARCH — search the web via Exa API
|
|
251
|
+
// ------------------------------------------------------------------
|
|
252
|
+
{
|
|
253
|
+
name: "web_search",
|
|
254
|
+
description: "Search the web for current information. Returns titles, URLs, and snippets.",
|
|
255
|
+
input_schema: {
|
|
256
|
+
type: "object",
|
|
257
|
+
properties: {
|
|
258
|
+
query: { type: "string", description: "Search query" },
|
|
259
|
+
allowed_domains: { type: "array", items: { type: "string" }, description: "Only include results from these domains" },
|
|
260
|
+
blocked_domains: { type: "array", items: { type: "string" }, description: "Exclude results from these domains" },
|
|
261
|
+
},
|
|
262
|
+
required: ["query"],
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
// ------------------------------------------------------------------
|
|
266
|
+
// TASKS — action-based CRUD for structured task tracking
|
|
267
|
+
// ------------------------------------------------------------------
|
|
268
|
+
{
|
|
269
|
+
name: "tasks",
|
|
270
|
+
description: "Track tasks for the current session. Actions: create (returns ID), update (status/deps), list (summary), get (full details). Supports dependencies via blocks/blockedBy.",
|
|
271
|
+
input_schema: {
|
|
272
|
+
type: "object",
|
|
273
|
+
properties: {
|
|
274
|
+
action: {
|
|
275
|
+
type: "string",
|
|
276
|
+
enum: ["create", "update", "list", "get"],
|
|
277
|
+
description: "Action to perform",
|
|
278
|
+
},
|
|
279
|
+
// For create:
|
|
280
|
+
subject: { type: "string", description: "Brief title in imperative form (create)" },
|
|
281
|
+
description: { type: "string", description: "Detailed description (create/update)" },
|
|
282
|
+
activeForm: { type: "string", description: "Present continuous spinner text (create/update)" },
|
|
283
|
+
metadata: { type: "object", description: "Arbitrary metadata (create/update)" },
|
|
284
|
+
// For update/get:
|
|
285
|
+
taskId: { type: "string", description: "Task ID (update/get)" },
|
|
286
|
+
status: { type: "string", enum: ["pending", "in_progress", "completed", "deleted"], description: "New status (update)" },
|
|
287
|
+
subject_update: { type: "string", description: "New subject (update)" },
|
|
288
|
+
addBlocks: { type: "array", items: { type: "string" }, description: "Task IDs this task blocks (update)" },
|
|
289
|
+
addBlockedBy: { type: "array", items: { type: "string" }, description: "Task IDs that block this task (update)" },
|
|
290
|
+
owner: { type: "string", description: "Task owner (update)" },
|
|
291
|
+
},
|
|
292
|
+
required: ["action"],
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
// ------------------------------------------------------------------
|
|
296
|
+
// NEW: MULTI_EDIT — multiple edits to one file in a single call
|
|
297
|
+
// ------------------------------------------------------------------
|
|
298
|
+
{
|
|
299
|
+
name: "multi_edit",
|
|
300
|
+
description: "Apply multiple edits to one file in a single call. Edits applied sequentially. Fails if any old_string not found.",
|
|
301
|
+
input_schema: {
|
|
302
|
+
type: "object",
|
|
303
|
+
properties: {
|
|
304
|
+
file_path: { type: "string", description: "Absolute or relative path to the file" },
|
|
305
|
+
edits: {
|
|
306
|
+
type: "array",
|
|
307
|
+
description: "Array of edits to apply sequentially",
|
|
308
|
+
items: {
|
|
309
|
+
type: "object",
|
|
310
|
+
properties: {
|
|
311
|
+
old_string: { type: "string", description: "Exact text to find" },
|
|
312
|
+
new_string: { type: "string", description: "Text to replace with" },
|
|
313
|
+
},
|
|
314
|
+
required: ["old_string", "new_string"],
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
required: ["file_path", "edits"],
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
// ------------------------------------------------------------------
|
|
322
|
+
// TASK — subagent for discrete tasks
|
|
323
|
+
// ------------------------------------------------------------------
|
|
324
|
+
{
|
|
325
|
+
name: "task",
|
|
326
|
+
description: "Launch a subagent in isolated context. Subagents have full tool access and batch multiple tool calls per turn (glob + grep + read_file in parallel). Launch multiple task calls in one response for parallel execution. Use for any work requiring 3+ tool calls. Subagents complete in 2-8 turns autonomously.",
|
|
327
|
+
input_schema: {
|
|
328
|
+
type: "object",
|
|
329
|
+
properties: {
|
|
330
|
+
prompt: { type: "string", description: "Specific task with clear completion criteria" },
|
|
331
|
+
subagent_type: {
|
|
332
|
+
type: "string",
|
|
333
|
+
enum: ["explore", "plan", "general-purpose", "research"],
|
|
334
|
+
description: "Agent type: explore=find, plan=design, general-purpose=do, research=lookup",
|
|
335
|
+
},
|
|
336
|
+
model: {
|
|
337
|
+
type: "string",
|
|
338
|
+
enum: ["sonnet", "opus", "haiku"],
|
|
339
|
+
description: "Haiku for quick tasks, Sonnet (default) for most, Opus for complex",
|
|
340
|
+
},
|
|
341
|
+
run_in_background: {
|
|
342
|
+
type: "boolean",
|
|
343
|
+
description: "Run agent in background. Returns output_file path to check progress via task_output.",
|
|
344
|
+
},
|
|
345
|
+
max_turns: {
|
|
346
|
+
type: "number",
|
|
347
|
+
description: "Max agentic turns (1-50). Default 8.",
|
|
348
|
+
},
|
|
349
|
+
name: {
|
|
350
|
+
type: "string",
|
|
351
|
+
description: "Display name for the agent.",
|
|
352
|
+
},
|
|
353
|
+
description: {
|
|
354
|
+
type: "string",
|
|
355
|
+
description: "Short 3-5 word description of the task.",
|
|
356
|
+
},
|
|
357
|
+
team_name: {
|
|
358
|
+
type: "string",
|
|
359
|
+
description: "Team name for spawning. Uses current team context if omitted.",
|
|
360
|
+
},
|
|
361
|
+
mode: {
|
|
362
|
+
type: "string",
|
|
363
|
+
enum: ["default", "plan", "yolo"],
|
|
364
|
+
description: "Permission mode for spawned agent (default inherits parent).",
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
required: ["prompt", "subagent_type"],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
// ------------------------------------------------------------------
|
|
371
|
+
// TEAM — parallel agent team for large tasks
|
|
372
|
+
// ------------------------------------------------------------------
|
|
373
|
+
{
|
|
374
|
+
name: "team_create",
|
|
375
|
+
description: "Create an Agent Team — multiple full Claude instances in parallel. Each teammate has full tool access, can spawn subagents via 'task' tool, and batches tool calls. Teammates → subagents → batch tools. Size tasks for 5-6 items per teammate. Include file lists to prevent conflicts.",
|
|
376
|
+
input_schema: {
|
|
377
|
+
type: "object",
|
|
378
|
+
properties: {
|
|
379
|
+
name: {
|
|
380
|
+
type: "string",
|
|
381
|
+
description: "Team name (e.g., 'Feature Implementation Team')",
|
|
382
|
+
},
|
|
383
|
+
teammate_count: {
|
|
384
|
+
type: "number",
|
|
385
|
+
description: "Number of teammates to spawn (2-5 recommended)",
|
|
386
|
+
},
|
|
387
|
+
model: {
|
|
388
|
+
type: "string",
|
|
389
|
+
enum: ["sonnet", "opus", "haiku"],
|
|
390
|
+
description: "Model for all teammates (default: sonnet)",
|
|
391
|
+
},
|
|
392
|
+
tasks: {
|
|
393
|
+
type: "array",
|
|
394
|
+
description: "Tasks for the team to complete",
|
|
395
|
+
items: {
|
|
396
|
+
type: "object",
|
|
397
|
+
properties: {
|
|
398
|
+
description: {
|
|
399
|
+
type: "string",
|
|
400
|
+
description: "Clear task description with completion criteria",
|
|
401
|
+
},
|
|
402
|
+
model: {
|
|
403
|
+
type: "string",
|
|
404
|
+
description: "Model for this task: haiku (lookups), sonnet (analysis), opus (complex reasoning). Overrides team default.",
|
|
405
|
+
},
|
|
406
|
+
files: {
|
|
407
|
+
type: "array",
|
|
408
|
+
items: { type: "string" },
|
|
409
|
+
description: "Files this task will modify (for conflict prevention)",
|
|
410
|
+
},
|
|
411
|
+
dependencies: {
|
|
412
|
+
type: "array",
|
|
413
|
+
items: { type: "string" },
|
|
414
|
+
description: "Task descriptions that must complete first",
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
required: ["description"],
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
required: ["name", "teammate_count", "tasks"],
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
// ------------------------------------------------------------------
|
|
425
|
+
// BACKGROUND PROCESS TOOLS
|
|
426
|
+
// ------------------------------------------------------------------
|
|
427
|
+
{
|
|
428
|
+
name: "bash_output",
|
|
429
|
+
description: "Read output from a running or completed background shell process. Returns only NEW output since the last read.",
|
|
430
|
+
input_schema: {
|
|
431
|
+
type: "object",
|
|
432
|
+
properties: {
|
|
433
|
+
bash_id: { type: "string", description: "The process ID returned when starting the background process" },
|
|
434
|
+
filter: { type: "string", description: "Optional regex to filter output lines" },
|
|
435
|
+
},
|
|
436
|
+
required: ["bash_id"],
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: "kill_shell",
|
|
441
|
+
description: "Terminate a running background shell process",
|
|
442
|
+
input_schema: {
|
|
443
|
+
type: "object",
|
|
444
|
+
properties: {
|
|
445
|
+
shell_id: { type: "string", description: "The process ID to kill" },
|
|
446
|
+
},
|
|
447
|
+
required: ["shell_id"],
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
name: "list_shells",
|
|
452
|
+
description: "List all background shell processes (running and recent completed)",
|
|
453
|
+
input_schema: {
|
|
454
|
+
type: "object",
|
|
455
|
+
properties: {},
|
|
456
|
+
required: [],
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
// ------------------------------------------------------------------
|
|
460
|
+
// TASK OUTPUT / TASK STOP — unified background task management
|
|
461
|
+
// ------------------------------------------------------------------
|
|
462
|
+
{
|
|
463
|
+
name: "task_output",
|
|
464
|
+
description: "Get output from a background task (shell or agent). Returns status and output content.",
|
|
465
|
+
input_schema: {
|
|
466
|
+
type: "object",
|
|
467
|
+
properties: {
|
|
468
|
+
task_id: { type: "string", description: "The task/agent ID (e.g. shell-xxx or agent-xxx)" },
|
|
469
|
+
block: { type: "boolean", description: "Wait for completion (default: true)" },
|
|
470
|
+
timeout: { type: "number", description: "Max wait time in ms (default: 30000)" },
|
|
471
|
+
},
|
|
472
|
+
required: ["task_id"],
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: "task_stop",
|
|
477
|
+
description: "Stop a running background task (shell or agent) by ID.",
|
|
478
|
+
input_schema: {
|
|
479
|
+
type: "object",
|
|
480
|
+
properties: {
|
|
481
|
+
task_id: { type: "string", description: "The task ID to stop" },
|
|
482
|
+
},
|
|
483
|
+
required: ["task_id"],
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
// ------------------------------------------------------------------
|
|
487
|
+
// CONFIG — runtime settings + mode control (consolidated)
|
|
488
|
+
// ------------------------------------------------------------------
|
|
489
|
+
{
|
|
490
|
+
name: "config",
|
|
491
|
+
description: "Read or write CLI settings. Omit value to read. Keys: model (sonnet/opus/haiku), mode (default/plan/yolo — plan restricts to read-only tools), memory. Use mode=plan before non-trivial tasks to explore first, mode=default to resume full access.",
|
|
492
|
+
input_schema: {
|
|
493
|
+
type: "object",
|
|
494
|
+
properties: {
|
|
495
|
+
setting: { type: "string", description: "Setting key: 'model', 'mode', 'memory'" },
|
|
496
|
+
value: { type: "string", description: "New value. Omit to read current value." },
|
|
497
|
+
},
|
|
498
|
+
required: ["setting"],
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
// ------------------------------------------------------------------
|
|
502
|
+
// LSP — Language Server Protocol code intelligence
|
|
503
|
+
// ------------------------------------------------------------------
|
|
504
|
+
{
|
|
505
|
+
name: "lsp",
|
|
506
|
+
description: "Code intelligence via Language Server Protocol. Supports: goToDefinition, findReferences, hover, documentSymbol, workspaceSymbol, goToImplementation, prepareCallHierarchy, incomingCalls, outgoingCalls. Requires a language server installed for the file type.",
|
|
507
|
+
input_schema: {
|
|
508
|
+
type: "object",
|
|
509
|
+
properties: {
|
|
510
|
+
operation: {
|
|
511
|
+
type: "string",
|
|
512
|
+
enum: [
|
|
513
|
+
"goToDefinition",
|
|
514
|
+
"findReferences",
|
|
515
|
+
"hover",
|
|
516
|
+
"documentSymbol",
|
|
517
|
+
"workspaceSymbol",
|
|
518
|
+
"goToImplementation",
|
|
519
|
+
"prepareCallHierarchy",
|
|
520
|
+
"incomingCalls",
|
|
521
|
+
"outgoingCalls",
|
|
522
|
+
],
|
|
523
|
+
description: "LSP operation to perform",
|
|
524
|
+
},
|
|
525
|
+
filePath: { type: "string", description: "Absolute or relative path to the file" },
|
|
526
|
+
line: { type: "number", description: "Line number (1-based, as shown in editors)" },
|
|
527
|
+
character: { type: "number", description: "Character offset (1-based, as shown in editors)" },
|
|
528
|
+
query: { type: "string", description: "Search query for workspaceSymbol operation (optional, defaults to all symbols)" },
|
|
529
|
+
},
|
|
530
|
+
required: ["operation", "filePath", "line", "character"],
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
// ------------------------------------------------------------------
|
|
534
|
+
// ASK_USER — structured multi-choice question
|
|
535
|
+
// ------------------------------------------------------------------
|
|
536
|
+
{
|
|
537
|
+
name: "ask_user",
|
|
538
|
+
description: "Ask the user a structured question with predefined options. Use to gather preferences, clarify requirements, or get decisions during execution. The user can always type a custom answer.",
|
|
539
|
+
input_schema: {
|
|
540
|
+
type: "object",
|
|
541
|
+
properties: {
|
|
542
|
+
question: { type: "string", description: "The question to ask" },
|
|
543
|
+
options: {
|
|
544
|
+
type: "array",
|
|
545
|
+
description: "2-4 options for the user to choose from",
|
|
546
|
+
items: {
|
|
547
|
+
type: "object",
|
|
548
|
+
properties: {
|
|
549
|
+
label: { type: "string", description: "Short option label (1-5 words)" },
|
|
550
|
+
description: { type: "string", description: "Explanation of what this option means" },
|
|
551
|
+
},
|
|
552
|
+
required: ["label", "description"],
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
required: ["question", "options"],
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
// ------------------------------------------------------------------
|
|
560
|
+
// SKILL — invoke named skills (model-callable)
|
|
561
|
+
// ------------------------------------------------------------------
|
|
562
|
+
{
|
|
563
|
+
name: "skill",
|
|
564
|
+
description: "Invoke a named skill. Skills provide specialized workflows like committing code, reviewing PRs, etc. Built-in skills: commit, review, review-pr. Custom skills from .whale/commands/ and ~/.swagmanager/commands/.",
|
|
565
|
+
input_schema: {
|
|
566
|
+
type: "object",
|
|
567
|
+
properties: {
|
|
568
|
+
skill: { type: "string", description: "Skill name (e.g., 'commit', 'review-pr')" },
|
|
569
|
+
args: { type: "string", description: "Optional arguments for the skill" },
|
|
570
|
+
},
|
|
571
|
+
required: ["skill"],
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
];
|
|
575
|
+
// ============================================================================
|
|
576
|
+
// READ MANY FILES — reads multiple files matching glob patterns
|
|
577
|
+
// ============================================================================
|
|
578
|
+
const BINARY_EXTENSIONS = new Set([
|
|
579
|
+
"png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg",
|
|
580
|
+
"mp3", "wav", "aiff", "aac", "ogg", "flac", "m4a",
|
|
581
|
+
"mp4", "mov", "avi", "mkv", "webm",
|
|
582
|
+
"zip", "tar", "gz", "bz2", "7z", "rar",
|
|
583
|
+
"exe", "dll", "so", "dylib", "o", "a",
|
|
584
|
+
"woff", "woff2", "ttf", "otf", "eot",
|
|
585
|
+
"pdf",
|
|
586
|
+
]);
|
|
587
|
+
const READ_MANY_TRUNCATE_LINES = 2000;
|
|
588
|
+
const READ_MANY_SHOW_LINES = 500;
|
|
589
|
+
async function readManyFiles(input) {
|
|
590
|
+
const pattern = input.pattern;
|
|
591
|
+
const basePath = input.path || process.cwd();
|
|
592
|
+
const limit = Math.min(Math.max(input.limit || 20, 1), 50);
|
|
593
|
+
// Use globSearch to find matching files
|
|
594
|
+
const globResult = globSearch({ pattern, path: basePath });
|
|
595
|
+
if (!globResult.success) {
|
|
596
|
+
return { success: false, output: globResult.output };
|
|
597
|
+
}
|
|
598
|
+
// Parse file paths from globSearch output (format: "N files:\npath1\npath2\n...")
|
|
599
|
+
const outputLines = globResult.output.split("\n");
|
|
600
|
+
if (outputLines[0] === "No files found") {
|
|
601
|
+
return { success: true, output: "No files matched the pattern." };
|
|
602
|
+
}
|
|
603
|
+
// First line is "N files:", rest are paths
|
|
604
|
+
const allFiles = outputLines.slice(1).filter(Boolean);
|
|
605
|
+
const totalFound = allFiles.length;
|
|
606
|
+
const filesToRead = allFiles.slice(0, limit);
|
|
607
|
+
const parts = [];
|
|
608
|
+
let filesRead = 0;
|
|
609
|
+
let skipped = 0;
|
|
610
|
+
for (const filePath of filesToRead) {
|
|
611
|
+
const ext = filePath.split(".").pop()?.toLowerCase() || "";
|
|
612
|
+
// Skip binary files (images, audio, video, archives, etc.)
|
|
613
|
+
if (BINARY_EXTENSIONS.has(ext)) {
|
|
614
|
+
parts.push(`=== ${filePath} ===\n[Binary file — ${ext}]\n`);
|
|
615
|
+
skipped++;
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
const absPath = resolve(resolvePath(basePath), resolvePath(filePath));
|
|
619
|
+
const targetPath = existsSync(absPath) ? absPath : filePath;
|
|
620
|
+
if (!existsSync(targetPath)) {
|
|
621
|
+
parts.push(`=== ${filePath} ===\n[File not found]\n`);
|
|
622
|
+
skipped++;
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
try {
|
|
626
|
+
const stat = statSync(targetPath);
|
|
627
|
+
// Skip files > 1MB
|
|
628
|
+
if (stat.size > 1_000_000) {
|
|
629
|
+
parts.push(`=== ${filePath} ===\n[File too large: ${(stat.size / 1024).toFixed(0)}KB]\n`);
|
|
630
|
+
skipped++;
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
const content = readFileSync(targetPath, "utf-8");
|
|
634
|
+
const lines = content.split("\n");
|
|
635
|
+
if (lines.length > READ_MANY_TRUNCATE_LINES) {
|
|
636
|
+
const truncated = lines.slice(0, READ_MANY_SHOW_LINES).join("\n");
|
|
637
|
+
parts.push(`=== ${filePath} ===\n${truncated}\n[... truncated — ${lines.length} total lines, showing first ${READ_MANY_SHOW_LINES}]\n`);
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
parts.push(`=== ${filePath} ===\n${content}\n`);
|
|
641
|
+
}
|
|
642
|
+
filesRead++;
|
|
643
|
+
}
|
|
644
|
+
catch (err) {
|
|
645
|
+
parts.push(`=== ${filePath} ===\n[Error reading file: ${err}]\n`);
|
|
646
|
+
skipped++;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const summary = `Read ${filesRead} files, skipped ${skipped}${totalFound > limit ? `, ${totalFound - limit} more matched but not read (limit: ${limit})` : ""} — ${totalFound} total matches`;
|
|
650
|
+
parts.push(summary);
|
|
651
|
+
return { success: true, output: parts.join("\n") };
|
|
652
|
+
}
|
|
653
|
+
// ============================================================================
|
|
654
|
+
// EXECUTOR — dispatches to tool implementations in ./tools/
|
|
655
|
+
// ============================================================================
|
|
656
|
+
export async function executeLocalTool(name, input) {
|
|
657
|
+
try {
|
|
658
|
+
switch (name) {
|
|
659
|
+
// File operations (tools/file-ops.ts)
|
|
660
|
+
case "read_file": return await readFile(input);
|
|
661
|
+
case "read_many_files": return await readManyFiles(input);
|
|
662
|
+
case "write_file": return writeFile(input);
|
|
663
|
+
case "edit_file": return editFile(input);
|
|
664
|
+
case "list_directory": return listDirectory(input);
|
|
665
|
+
case "search_files": return searchFiles(input);
|
|
666
|
+
case "search_content": return searchContent(input);
|
|
667
|
+
case "multi_edit": return multiEdit(input);
|
|
668
|
+
case "notebook_edit": return notebookEdit(input);
|
|
669
|
+
// Search (tools/search-tools.ts)
|
|
670
|
+
case "glob": return globSearch(input);
|
|
671
|
+
case "grep": return grepSearch(input);
|
|
672
|
+
// Shell execution (tools/shell-exec.ts)
|
|
673
|
+
case "run_command": return await runCommand(input);
|
|
674
|
+
case "bash_output": return bashOutput(input);
|
|
675
|
+
case "kill_shell": return killShell(input);
|
|
676
|
+
case "list_shells": return listShellsFn();
|
|
677
|
+
// Web (tools/web-tools.ts)
|
|
678
|
+
case "web_fetch": return await webFetch(input);
|
|
679
|
+
case "web_search": return await webSearch(input);
|
|
680
|
+
// Tasks (tools/task-manager.ts)
|
|
681
|
+
case "tasks": return tasksTool(input);
|
|
682
|
+
// Agent tools (tools/agent-tools.ts)
|
|
683
|
+
case "task": return await taskTool(input);
|
|
684
|
+
case "team_create": return await teamCreateTool(input);
|
|
685
|
+
case "task_output": return await taskOutput(input);
|
|
686
|
+
case "task_stop": return taskStop(input);
|
|
687
|
+
case "config": return configTool(input);
|
|
688
|
+
case "ask_user": return askUser(input);
|
|
689
|
+
case "lsp": return await lspTool(input);
|
|
690
|
+
case "skill": return skillTool(input);
|
|
691
|
+
default: return { success: false, output: `Unknown local tool: ${name}` };
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
catch (err) {
|
|
695
|
+
return { success: false, output: `Error: ${err}` };
|
|
696
|
+
}
|
|
697
|
+
}
|