@mragentix/cli 4.2.37
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/LICENSE +21 -0
- package/README.md +149 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +772 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +29 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +87 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +498 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/agents.d.ts +30 -0
- package/dist/core/agents.d.ts.map +1 -0
- package/dist/core/agents.js +91 -0
- package/dist/core/agents.js.map +1 -0
- package/dist/core/auth-storage.d.ts +35 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +144 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/auto-update.d.ts +8 -0
- package/dist/core/auto-update.d.ts.map +1 -0
- package/dist/core/auto-update.js +152 -0
- package/dist/core/auto-update.js.map +1 -0
- package/dist/core/compaction/compactor.d.ts +69 -0
- package/dist/core/compaction/compactor.d.ts.map +1 -0
- package/dist/core/compaction/compactor.js +405 -0
- package/dist/core/compaction/compactor.js.map +1 -0
- package/dist/core/compaction/compactor.test.d.ts +2 -0
- package/dist/core/compaction/compactor.test.d.ts.map +1 -0
- package/dist/core/compaction/compactor.test.js +461 -0
- package/dist/core/compaction/compactor.test.js.map +1 -0
- package/dist/core/compaction/token-estimator.d.ts +10 -0
- package/dist/core/compaction/token-estimator.d.ts.map +1 -0
- package/dist/core/compaction/token-estimator.js +75 -0
- package/dist/core/compaction/token-estimator.js.map +1 -0
- package/dist/core/compaction/token-estimator.test.d.ts +2 -0
- package/dist/core/compaction/token-estimator.test.d.ts.map +1 -0
- package/dist/core/compaction/token-estimator.test.js +137 -0
- package/dist/core/compaction/token-estimator.test.js.map +1 -0
- package/dist/core/custom-commands.d.ts +13 -0
- package/dist/core/custom-commands.d.ts.map +1 -0
- package/dist/core/custom-commands.js +40 -0
- package/dist/core/custom-commands.js.map +1 -0
- package/dist/core/event-bus.d.ts +95 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +99 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +8 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +48 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/types.d.ts +19 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +2 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/file-lock.d.ts +6 -0
- package/dist/core/file-lock.d.ts.map +1 -0
- package/dist/core/file-lock.js +76 -0
- package/dist/core/file-lock.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +26 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +132 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/mcp/client.d.ts +9 -0
- package/dist/core/mcp/client.d.ts.map +1 -0
- package/dist/core/mcp/client.js +126 -0
- package/dist/core/mcp/client.js.map +1 -0
- package/dist/core/mcp/defaults.d.ts +9 -0
- package/dist/core/mcp/defaults.d.ts.map +1 -0
- package/dist/core/mcp/defaults.js +47 -0
- package/dist/core/mcp/defaults.js.map +1 -0
- package/dist/core/mcp/index.d.ts +4 -0
- package/dist/core/mcp/index.d.ts.map +1 -0
- package/dist/core/mcp/index.js +3 -0
- package/dist/core/mcp/index.js.map +1 -0
- package/dist/core/mcp/types.d.ts +15 -0
- package/dist/core/mcp/types.d.ts.map +1 -0
- package/dist/core/mcp/types.js +2 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/model-registry.d.ts +25 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +135 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/oauth/anthropic.d.ts +4 -0
- package/dist/core/oauth/anthropic.d.ts.map +1 -0
- package/dist/core/oauth/anthropic.js +75 -0
- package/dist/core/oauth/anthropic.js.map +1 -0
- package/dist/core/oauth/openai.d.ts +4 -0
- package/dist/core/oauth/openai.d.ts.map +1 -0
- package/dist/core/oauth/openai.js +186 -0
- package/dist/core/oauth/openai.js.map +1 -0
- package/dist/core/oauth/pkce.d.ts +5 -0
- package/dist/core/oauth/pkce.d.ts.map +1 -0
- package/dist/core/oauth/pkce.js +17 -0
- package/dist/core/oauth/pkce.js.map +1 -0
- package/dist/core/oauth/types.d.ts +12 -0
- package/dist/core/oauth/types.d.ts.map +1 -0
- package/dist/core/oauth/types.js +2 -0
- package/dist/core/oauth/types.js.map +1 -0
- package/dist/core/process-manager.d.ts +30 -0
- package/dist/core/process-manager.d.ts.map +1 -0
- package/dist/core/process-manager.js +130 -0
- package/dist/core/process-manager.js.map +1 -0
- package/dist/core/prompt-commands.d.ts +14 -0
- package/dist/core/prompt-commands.d.ts.map +1 -0
- package/dist/core/prompt-commands.js +496 -0
- package/dist/core/prompt-commands.js.map +1 -0
- package/dist/core/session-manager.d.ts +112 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +326 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +43 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +64 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +23 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +89 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +35 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +183 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/telegram.d.ts +94 -0
- package/dist/core/telegram.d.ts.map +1 -0
- package/dist/core/telegram.js +227 -0
- package/dist/core/telegram.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive.d.ts +3 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +173 -0
- package/dist/interactive.js.map +1 -0
- package/dist/modes/index.d.ts +3 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +3 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/json-mode.d.ts +13 -0
- package/dist/modes/json-mode.d.ts.map +1 -0
- package/dist/modes/json-mode.js +74 -0
- package/dist/modes/json-mode.js.map +1 -0
- package/dist/modes/print-mode.d.ts +12 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +49 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc-mode.d.ts +28 -0
- package/dist/modes/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc-mode.js +145 -0
- package/dist/modes/rpc-mode.js.map +1 -0
- package/dist/modes/serve-mode.d.ts +21 -0
- package/dist/modes/serve-mode.d.ts.map +1 -0
- package/dist/modes/serve-mode.js +649 -0
- package/dist/modes/serve-mode.js.map +1 -0
- package/dist/session.d.ts +16 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +129 -0
- package/dist/session.js.map +1 -0
- package/dist/system-prompt.d.ts +6 -0
- package/dist/system-prompt.d.ts.map +1 -0
- package/dist/system-prompt.js +115 -0
- package/dist/system-prompt.js.map +1 -0
- package/dist/tools/bash.d.ts +13 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +165 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit-diff.d.ts +18 -0
- package/dist/tools/edit-diff.d.ts.map +1 -0
- package/dist/tools/edit-diff.js +92 -0
- package/dist/tools/edit-diff.js.map +1 -0
- package/dist/tools/edit.d.ts +11 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +57 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/find.d.ts +9 -0
- package/dist/tools/find.d.ts.map +1 -0
- package/dist/tools/find.js +59 -0
- package/dist/tools/find.js.map +1 -0
- package/dist/tools/grep.d.ts +13 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +121 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/index.d.ts +30 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +50 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/ls.d.ts +10 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +56 -0
- package/dist/tools/ls.js.map +1 -0
- package/dist/tools/operations.d.ts +39 -0
- package/dist/tools/operations.d.ts.map +1 -0
- package/dist/tools/operations.js +27 -0
- package/dist/tools/operations.js.map +1 -0
- package/dist/tools/path-utils.d.ts +7 -0
- package/dist/tools/path-utils.d.ts.map +1 -0
- package/dist/tools/path-utils.js +27 -0
- package/dist/tools/path-utils.js.map +1 -0
- package/dist/tools/read.d.ts +12 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +113 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/subagent.d.ts +26 -0
- package/dist/tools/subagent.d.ts.map +1 -0
- package/dist/tools/subagent.js +210 -0
- package/dist/tools/subagent.js.map +1 -0
- package/dist/tools/task-output.d.ts +10 -0
- package/dist/tools/task-output.d.ts.map +1 -0
- package/dist/tools/task-output.js +33 -0
- package/dist/tools/task-output.js.map +1 -0
- package/dist/tools/task-stop.d.ts +9 -0
- package/dist/tools/task-stop.d.ts.map +1 -0
- package/dist/tools/task-stop.js +15 -0
- package/dist/tools/task-stop.js.map +1 -0
- package/dist/tools/tasks.d.ts +16 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +132 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/truncate.d.ts +19 -0
- package/dist/tools/truncate.d.ts.map +1 -0
- package/dist/tools/truncate.js +59 -0
- package/dist/tools/truncate.js.map +1 -0
- package/dist/tools/truncate.test.d.ts +2 -0
- package/dist/tools/truncate.test.d.ts.map +1 -0
- package/dist/tools/truncate.test.js +100 -0
- package/dist/tools/truncate.test.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +9 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +97 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/write.d.ts +10 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +30 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/tools/write.test.d.ts +2 -0
- package/dist/tools/write.test.d.ts.map +1 -0
- package/dist/tools/write.test.js +84 -0
- package/dist/tools/write.test.js.map +1 -0
- package/dist/types.d.ts +36 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/App.d.ts +148 -0
- package/dist/ui/App.d.ts.map +1 -0
- package/dist/ui/App.js +1191 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/components/ActivityIndicator.d.ts +13 -0
- package/dist/ui/components/ActivityIndicator.d.ts.map +1 -0
- package/dist/ui/components/ActivityIndicator.js +313 -0
- package/dist/ui/components/ActivityIndicator.js.map +1 -0
- package/dist/ui/components/AnimationContext.d.ts +22 -0
- package/dist/ui/components/AnimationContext.d.ts.map +1 -0
- package/dist/ui/components/AnimationContext.js +35 -0
- package/dist/ui/components/AnimationContext.js.map +1 -0
- package/dist/ui/components/AssistantMessage.d.ts +9 -0
- package/dist/ui/components/AssistantMessage.d.ts.map +1 -0
- package/dist/ui/components/AssistantMessage.js +11 -0
- package/dist/ui/components/AssistantMessage.js.map +1 -0
- package/dist/ui/components/BackgroundTasksBar.d.ts +15 -0
- package/dist/ui/components/BackgroundTasksBar.d.ts.map +1 -0
- package/dist/ui/components/BackgroundTasksBar.js +74 -0
- package/dist/ui/components/BackgroundTasksBar.js.map +1 -0
- package/dist/ui/components/Banner.d.ts +11 -0
- package/dist/ui/components/Banner.d.ts.map +1 -0
- package/dist/ui/components/Banner.js +55 -0
- package/dist/ui/components/Banner.js.map +1 -0
- package/dist/ui/components/CompactionNotice.d.ts +10 -0
- package/dist/ui/components/CompactionNotice.d.ts.map +1 -0
- package/dist/ui/components/CompactionNotice.js +27 -0
- package/dist/ui/components/CompactionNotice.js.map +1 -0
- package/dist/ui/components/DiffView.d.ts +4 -0
- package/dist/ui/components/DiffView.d.ts.map +1 -0
- package/dist/ui/components/DiffView.js +20 -0
- package/dist/ui/components/DiffView.js.map +1 -0
- package/dist/ui/components/Footer.d.ts +10 -0
- package/dist/ui/components/Footer.d.ts.map +1 -0
- package/dist/ui/components/Footer.js +105 -0
- package/dist/ui/components/Footer.js.map +1 -0
- package/dist/ui/components/InputArea.d.ts +21 -0
- package/dist/ui/components/InputArea.d.ts.map +1 -0
- package/dist/ui/components/InputArea.js +465 -0
- package/dist/ui/components/InputArea.js.map +1 -0
- package/dist/ui/components/Markdown.d.ts +9 -0
- package/dist/ui/components/Markdown.d.ts.map +1 -0
- package/dist/ui/components/Markdown.js +246 -0
- package/dist/ui/components/Markdown.js.map +1 -0
- package/dist/ui/components/ModelSelector.d.ts +11 -0
- package/dist/ui/components/ModelSelector.d.ts.map +1 -0
- package/dist/ui/components/ModelSelector.js +20 -0
- package/dist/ui/components/ModelSelector.js.map +1 -0
- package/dist/ui/components/Overlay.d.ts +8 -0
- package/dist/ui/components/Overlay.d.ts.map +1 -0
- package/dist/ui/components/Overlay.js +9 -0
- package/dist/ui/components/Overlay.js.map +1 -0
- package/dist/ui/components/SelectList.d.ts +14 -0
- package/dist/ui/components/SelectList.d.ts.map +1 -0
- package/dist/ui/components/SelectList.js +46 -0
- package/dist/ui/components/SelectList.js.map +1 -0
- package/dist/ui/components/ServerToolExecution.d.ts +17 -0
- package/dist/ui/components/ServerToolExecution.d.ts.map +1 -0
- package/dist/ui/components/ServerToolExecution.js +26 -0
- package/dist/ui/components/ServerToolExecution.js.map +1 -0
- package/dist/ui/components/SessionSelector.d.ts +9 -0
- package/dist/ui/components/SessionSelector.d.ts.map +1 -0
- package/dist/ui/components/SessionSelector.js +13 -0
- package/dist/ui/components/SessionSelector.js.map +1 -0
- package/dist/ui/components/SettingsSelector.d.ts +9 -0
- package/dist/ui/components/SettingsSelector.d.ts.map +1 -0
- package/dist/ui/components/SettingsSelector.js +13 -0
- package/dist/ui/components/SettingsSelector.js.map +1 -0
- package/dist/ui/components/SlashCommandMenu.d.ts +15 -0
- package/dist/ui/components/SlashCommandMenu.d.ts.map +1 -0
- package/dist/ui/components/SlashCommandMenu.js +32 -0
- package/dist/ui/components/SlashCommandMenu.js.map +1 -0
- package/dist/ui/components/Spinner.d.ts +4 -0
- package/dist/ui/components/Spinner.d.ts.map +1 -0
- package/dist/ui/components/Spinner.js +13 -0
- package/dist/ui/components/Spinner.js.map +1 -0
- package/dist/ui/components/StreamingArea.d.ts +10 -0
- package/dist/ui/components/StreamingArea.d.ts.map +1 -0
- package/dist/ui/components/StreamingArea.js +58 -0
- package/dist/ui/components/StreamingArea.js.map +1 -0
- package/dist/ui/components/SubAgentPanel.d.ts +21 -0
- package/dist/ui/components/SubAgentPanel.d.ts.map +1 -0
- package/dist/ui/components/SubAgentPanel.js +71 -0
- package/dist/ui/components/SubAgentPanel.js.map +1 -0
- package/dist/ui/components/TaskOverlay.d.ts +10 -0
- package/dist/ui/components/TaskOverlay.d.ts.map +1 -0
- package/dist/ui/components/TaskOverlay.js +263 -0
- package/dist/ui/components/TaskOverlay.js.map +1 -0
- package/dist/ui/components/ThinkingBlock.d.ts +11 -0
- package/dist/ui/components/ThinkingBlock.d.ts.map +1 -0
- package/dist/ui/components/ThinkingBlock.js +43 -0
- package/dist/ui/components/ThinkingBlock.js.map +1 -0
- package/dist/ui/components/ThinkingIndicator.d.ts +6 -0
- package/dist/ui/components/ThinkingIndicator.d.ts.map +1 -0
- package/dist/ui/components/ThinkingIndicator.js +144 -0
- package/dist/ui/components/ThinkingIndicator.js.map +1 -0
- package/dist/ui/components/ToolExecution.d.ts +16 -0
- package/dist/ui/components/ToolExecution.d.ts.map +1 -0
- package/dist/ui/components/ToolExecution.js +490 -0
- package/dist/ui/components/ToolExecution.js.map +1 -0
- package/dist/ui/components/ToolGroupExecution.d.ts +7 -0
- package/dist/ui/components/ToolGroupExecution.d.ts.map +1 -0
- package/dist/ui/components/ToolGroupExecution.js +115 -0
- package/dist/ui/components/ToolGroupExecution.js.map +1 -0
- package/dist/ui/components/UserMessage.d.ts +7 -0
- package/dist/ui/components/UserMessage.d.ts.map +1 -0
- package/dist/ui/components/UserMessage.js +16 -0
- package/dist/ui/components/UserMessage.js.map +1 -0
- package/dist/ui/components/index.d.ts +15 -0
- package/dist/ui/components/index.d.ts.map +1 -0
- package/dist/ui/components/index.js +15 -0
- package/dist/ui/components/index.js.map +1 -0
- package/dist/ui/hooks/useAgentLoop.d.ts +69 -0
- package/dist/ui/hooks/useAgentLoop.d.ts.map +1 -0
- package/dist/ui/hooks/useAgentLoop.js +483 -0
- package/dist/ui/hooks/useAgentLoop.js.map +1 -0
- package/dist/ui/hooks/useSessionManager.d.ts +13 -0
- package/dist/ui/hooks/useSessionManager.d.ts.map +1 -0
- package/dist/ui/hooks/useSessionManager.js +43 -0
- package/dist/ui/hooks/useSessionManager.js.map +1 -0
- package/dist/ui/hooks/useSlashCommands.d.ts +7 -0
- package/dist/ui/hooks/useSlashCommands.d.ts.map +1 -0
- package/dist/ui/hooks/useSlashCommands.js +11 -0
- package/dist/ui/hooks/useSlashCommands.js.map +1 -0
- package/dist/ui/hooks/useTerminalSize.d.ts +20 -0
- package/dist/ui/hooks/useTerminalSize.d.ts.map +1 -0
- package/dist/ui/hooks/useTerminalSize.js +55 -0
- package/dist/ui/hooks/useTerminalSize.js.map +1 -0
- package/dist/ui/hooks/useTerminalTitle.d.ts +3 -0
- package/dist/ui/hooks/useTerminalTitle.d.ts.map +1 -0
- package/dist/ui/hooks/useTerminalTitle.js +41 -0
- package/dist/ui/hooks/useTerminalTitle.js.map +1 -0
- package/dist/ui/live-item-flush.d.ts +59 -0
- package/dist/ui/live-item-flush.d.ts.map +1 -0
- package/dist/ui/live-item-flush.js +135 -0
- package/dist/ui/live-item-flush.js.map +1 -0
- package/dist/ui/live-item-flush.test.d.ts +2 -0
- package/dist/ui/live-item-flush.test.d.ts.map +1 -0
- package/dist/ui/live-item-flush.test.js +307 -0
- package/dist/ui/live-item-flush.test.js.map +1 -0
- package/dist/ui/login.d.ts +3 -0
- package/dist/ui/login.d.ts.map +1 -0
- package/dist/ui/login.js +117 -0
- package/dist/ui/login.js.map +1 -0
- package/dist/ui/render.d.ts +38 -0
- package/dist/ui/render.d.ts.map +1 -0
- package/dist/ui/render.js +72 -0
- package/dist/ui/render.js.map +1 -0
- package/dist/ui/sessions.d.ts +2 -0
- package/dist/ui/sessions.d.ts.map +1 -0
- package/dist/ui/sessions.js +208 -0
- package/dist/ui/sessions.js.map +1 -0
- package/dist/ui/spinner-frames.d.ts +3 -0
- package/dist/ui/spinner-frames.d.ts.map +1 -0
- package/dist/ui/spinner-frames.js +7 -0
- package/dist/ui/spinner-frames.js.map +1 -0
- package/dist/ui/theme/dark.json +24 -0
- package/dist/ui/theme/detect-theme.d.ts +12 -0
- package/dist/ui/theme/detect-theme.d.ts.map +1 -0
- package/dist/ui/theme/detect-theme.js +152 -0
- package/dist/ui/theme/detect-theme.js.map +1 -0
- package/dist/ui/theme/light.json +24 -0
- package/dist/ui/theme/theme.d.ts +29 -0
- package/dist/ui/theme/theme.d.ts.map +1 -0
- package/dist/ui/theme/theme.js +11 -0
- package/dist/ui/theme/theme.js.map +1 -0
- package/dist/ui/utils/highlight.d.ts +8 -0
- package/dist/ui/utils/highlight.d.ts.map +1 -0
- package/dist/ui/utils/highlight.js +49 -0
- package/dist/ui/utils/highlight.js.map +1 -0
- package/dist/ui/utils/table-text.d.ts +25 -0
- package/dist/ui/utils/table-text.d.ts.map +1 -0
- package/dist/ui/utils/table-text.js +78 -0
- package/dist/ui/utils/table-text.js.map +1 -0
- package/dist/ui/utils/table-text.test.d.ts +2 -0
- package/dist/ui/utils/table-text.test.d.ts.map +1 -0
- package/dist/ui/utils/table-text.test.js +202 -0
- package/dist/ui/utils/table-text.test.js.map +1 -0
- package/dist/utils/error-handler.d.ts +5 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +120 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/format.d.ts +21 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +120 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/git.d.ts +2 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +13 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image.d.ts +30 -0
- package/dist/utils/image.d.ts.map +1 -0
- package/dist/utils/image.js +231 -0
- package/dist/utils/image.js.map +1 -0
- package/dist/utils/markdown.d.ts +6 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +25 -0
- package/dist/utils/markdown.js.map +1 -0
- package/dist/utils/process.d.ts +6 -0
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +19 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +8 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sound.d.ts +2 -0
- package/dist/utils/sound.d.ts.map +1 -0
- package/dist/utils/sound.js +11 -0
- package/dist/utils/sound.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { diffLines } from "diff";
|
|
2
|
+
/**
|
|
3
|
+
* Normalize text for fuzzy matching:
|
|
4
|
+
* - Strip trailing whitespace per line
|
|
5
|
+
* - Replace smart quotes with straight quotes
|
|
6
|
+
* - Replace unicode dashes with hyphens
|
|
7
|
+
*/
|
|
8
|
+
function normalizeForFuzzyMatch(text) {
|
|
9
|
+
return text
|
|
10
|
+
.replace(/[^\S\n]+$/gm, "") // trailing whitespace per line
|
|
11
|
+
.replace(/[\u2018\u2019]/g, "'") // smart single quotes
|
|
12
|
+
.replace(/[\u201C\u201D]/g, '"') // smart double quotes
|
|
13
|
+
.replace(/[\u2013\u2014]/g, "-"); // en/em dashes
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Find text in content, trying exact match first then fuzzy.
|
|
17
|
+
*/
|
|
18
|
+
export function fuzzyFindText(content, oldText) {
|
|
19
|
+
// Exact match first
|
|
20
|
+
const exactIndex = content.indexOf(oldText);
|
|
21
|
+
if (exactIndex !== -1) {
|
|
22
|
+
return { found: true, index: exactIndex, matchLength: oldText.length, usedFuzzy: false };
|
|
23
|
+
}
|
|
24
|
+
// Fuzzy match: normalize both sides
|
|
25
|
+
const normalizedContent = normalizeForFuzzyMatch(content);
|
|
26
|
+
const normalizedOld = normalizeForFuzzyMatch(oldText);
|
|
27
|
+
const fuzzyIndex = normalizedContent.indexOf(normalizedOld);
|
|
28
|
+
if (fuzzyIndex !== -1) {
|
|
29
|
+
// Map back to original content: find the actual length in original
|
|
30
|
+
// Since normalization only changes per-character substitutions and trailing whitespace,
|
|
31
|
+
// we need to find the original range.
|
|
32
|
+
// Strategy: match line by line to find the original span.
|
|
33
|
+
const normalizedBefore = normalizedContent.slice(0, fuzzyIndex);
|
|
34
|
+
const linesBefore = normalizedBefore.split("\n").length - 1;
|
|
35
|
+
const normalizedMatch = normalizedContent.slice(fuzzyIndex, fuzzyIndex + normalizedOld.length);
|
|
36
|
+
const matchLineCount = normalizedMatch.split("\n").length;
|
|
37
|
+
const contentLines = content.split("\n");
|
|
38
|
+
const matchLines = contentLines.slice(linesBefore, linesBefore + matchLineCount);
|
|
39
|
+
const originalMatch = matchLines.join("\n");
|
|
40
|
+
// Find actual index of the first match line start
|
|
41
|
+
let actualIndex = 0;
|
|
42
|
+
for (let i = 0; i < linesBefore; i++) {
|
|
43
|
+
actualIndex += contentLines[i].length + 1; // +1 for \n
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
found: true,
|
|
47
|
+
index: actualIndex,
|
|
48
|
+
matchLength: originalMatch.length,
|
|
49
|
+
usedFuzzy: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return { found: false, index: -1, matchLength: 0, usedFuzzy: false };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Count occurrences of oldText in content (exact first, then fuzzy).
|
|
56
|
+
*/
|
|
57
|
+
export function countOccurrences(content, oldText) {
|
|
58
|
+
// Try exact first
|
|
59
|
+
let count = 0;
|
|
60
|
+
let pos = 0;
|
|
61
|
+
while ((pos = content.indexOf(oldText, pos)) !== -1) {
|
|
62
|
+
count++;
|
|
63
|
+
pos += oldText.length;
|
|
64
|
+
}
|
|
65
|
+
if (count > 0)
|
|
66
|
+
return count;
|
|
67
|
+
// Fuzzy count
|
|
68
|
+
const normalizedContent = normalizeForFuzzyMatch(content);
|
|
69
|
+
const normalizedOld = normalizeForFuzzyMatch(oldText);
|
|
70
|
+
pos = 0;
|
|
71
|
+
while ((pos = normalizedContent.indexOf(normalizedOld, pos)) !== -1) {
|
|
72
|
+
count++;
|
|
73
|
+
pos += normalizedOld.length;
|
|
74
|
+
}
|
|
75
|
+
return count;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Generate a unified diff string.
|
|
79
|
+
*/
|
|
80
|
+
export function generateDiff(oldContent, newContent, filePath) {
|
|
81
|
+
const changes = diffLines(oldContent, newContent);
|
|
82
|
+
const lines = [`--- a/${filePath}`, `+++ b/${filePath}`];
|
|
83
|
+
for (const change of changes) {
|
|
84
|
+
const prefix = change.added ? "+" : change.removed ? "-" : " ";
|
|
85
|
+
const changeLines = change.value.replace(/\n$/, "").split("\n");
|
|
86
|
+
for (const line of changeLines) {
|
|
87
|
+
lines.push(`${prefix}${line}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return lines.join("\n");
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=edit-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-diff.js","sourceRoot":"","sources":["../../src/tools/edit-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,IAAY;IAC1C,OAAO,IAAI;SACR,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,+BAA+B;SAC1D,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,sBAAsB;SACtD,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,sBAAsB;SACtD,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,CAAC,eAAe;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,OAAe;IAEf,oBAAoB;IACpB,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC3F,CAAC;IAED,oCAAoC;IACpC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,aAAa,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAEtD,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,aA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AAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChE,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentTool } from "@mragentix/agent";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
4
|
+
declare const EditParams: z.ZodObject<{
|
|
5
|
+
file_path: z.ZodString;
|
|
6
|
+
old_text: z.ZodString;
|
|
7
|
+
new_text: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare function createEditTool(cwd: string, readFiles?: Set<string>, ops?: ToolOperations): AgentTool<typeof EditParams>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEvE,QAAA,MAAM,UAAU;;;;iBAId,CAAC;AAEH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,GAAG,GAAE,cAAgC,GACpC,SAAS,CAAC,OAAO,UAAU,CAAC,CA6D9B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { resolvePath, rejectSymlink } from "./path-utils.js";
|
|
4
|
+
import { fuzzyFindText, countOccurrences, generateDiff } from "./edit-diff.js";
|
|
5
|
+
import { localOperations } from "./operations.js";
|
|
6
|
+
const EditParams = z.object({
|
|
7
|
+
file_path: z.string().describe("The file path to edit"),
|
|
8
|
+
old_text: z.string().describe("The exact text to find and replace"),
|
|
9
|
+
new_text: z.string().describe("The replacement text"),
|
|
10
|
+
});
|
|
11
|
+
export function createEditTool(cwd, readFiles, ops = localOperations) {
|
|
12
|
+
return {
|
|
13
|
+
name: "edit",
|
|
14
|
+
description: "Replace a specific text string in a file. The file must be read first before editing. " +
|
|
15
|
+
"The old_text must uniquely match exactly one location in the file. Returns a unified diff of the change.",
|
|
16
|
+
parameters: EditParams,
|
|
17
|
+
async execute({ file_path, old_text, new_text }) {
|
|
18
|
+
const resolved = resolvePath(cwd, file_path);
|
|
19
|
+
await rejectSymlink(resolved);
|
|
20
|
+
if (readFiles && !readFiles.has(resolved)) {
|
|
21
|
+
throw new Error("File must be read first before editing. Use the read tool first.");
|
|
22
|
+
}
|
|
23
|
+
const content = await ops.readFile(resolved);
|
|
24
|
+
// Detect line endings
|
|
25
|
+
const hasCRLF = content.includes("\r\n");
|
|
26
|
+
// Normalize for matching
|
|
27
|
+
const normalized = hasCRLF ? content.replace(/\r\n/g, "\n") : content;
|
|
28
|
+
const normalizedOld = hasCRLF ? old_text.replace(/\r\n/g, "\n") : old_text;
|
|
29
|
+
const normalizedNew = hasCRLF ? new_text.replace(/\r\n/g, "\n") : new_text;
|
|
30
|
+
// Check uniqueness
|
|
31
|
+
const occurrences = countOccurrences(normalized, normalizedOld);
|
|
32
|
+
if (occurrences === 0) {
|
|
33
|
+
throw new Error(`old_text not found in ${path.basename(resolved)}. ` +
|
|
34
|
+
"Make sure the text matches exactly, including whitespace and indentation.");
|
|
35
|
+
}
|
|
36
|
+
if (occurrences > 1) {
|
|
37
|
+
throw new Error(`old_text found ${occurrences} times in ${path.basename(resolved)}. ` +
|
|
38
|
+
"Include more surrounding context to make the match unique.");
|
|
39
|
+
}
|
|
40
|
+
// Find and replace
|
|
41
|
+
const match = fuzzyFindText(normalized, normalizedOld);
|
|
42
|
+
if (!match.found) {
|
|
43
|
+
throw new Error(`old_text not found in ${path.basename(resolved)}.`);
|
|
44
|
+
}
|
|
45
|
+
const newContent = normalized.slice(0, match.index) +
|
|
46
|
+
normalizedNew +
|
|
47
|
+
normalized.slice(match.index + match.matchLength);
|
|
48
|
+
// Restore line endings if needed
|
|
49
|
+
const finalContent = hasCRLF ? newContent.replace(/\n/g, "\r\n") : newContent;
|
|
50
|
+
await ops.writeFile(resolved, finalContent);
|
|
51
|
+
const relPath = path.relative(cwd, resolved);
|
|
52
|
+
const diff = generateDiff(normalized, newContent, relPath);
|
|
53
|
+
return diff;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AAEvE,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACvD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IACnE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,C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entix/agent";
|
|
3
|
+
declare const FindParams: z.ZodObject<{
|
|
4
|
+
pattern: z.ZodString;
|
|
5
|
+
path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare function createFindTool(cwd: string): AgentTool<typeof FindParams>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/tools/find.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,QAAA,MAAM,UAAU;;;iBAGd,CAAC;AAIH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CA2CxE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { resolvePath } from "./path-utils.js";
|
|
5
|
+
const FindParams = z.object({
|
|
6
|
+
pattern: z.string().describe("Glob pattern to match files (e.g. '**/*.ts', 'src/**/*.tsx')"),
|
|
7
|
+
path: z.string().optional().describe("Directory to search in (defaults to cwd)"),
|
|
8
|
+
});
|
|
9
|
+
const MAX_RESULTS = 100;
|
|
10
|
+
export function createFindTool(cwd) {
|
|
11
|
+
return {
|
|
12
|
+
name: "find",
|
|
13
|
+
description: "Find files matching a glob pattern. Respects .gitignore. " +
|
|
14
|
+
"Returns sorted file paths, truncated if more than 100 matches.",
|
|
15
|
+
parameters: FindParams,
|
|
16
|
+
async execute({ pattern, path: searchPath }) {
|
|
17
|
+
const dir = searchPath ? resolvePath(cwd, searchPath) : cwd;
|
|
18
|
+
// Dynamic import for ESM-only fast-glob
|
|
19
|
+
const fg = await import("fast-glob");
|
|
20
|
+
const ignore = await import("ignore");
|
|
21
|
+
// Load .gitignore patterns
|
|
22
|
+
const ignorePatterns = await loadGitignore(dir);
|
|
23
|
+
const ig = ignore.default();
|
|
24
|
+
ig.add(ignorePatterns);
|
|
25
|
+
const entries = await fg.default(pattern, {
|
|
26
|
+
cwd: dir,
|
|
27
|
+
dot: false,
|
|
28
|
+
onlyFiles: true,
|
|
29
|
+
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
30
|
+
});
|
|
31
|
+
// Filter by .gitignore
|
|
32
|
+
const filtered = entries.filter((entry) => !ig.ignores(entry));
|
|
33
|
+
filtered.sort();
|
|
34
|
+
const truncated = filtered.length > MAX_RESULTS;
|
|
35
|
+
const shown = truncated ? filtered.slice(0, MAX_RESULTS) : filtered;
|
|
36
|
+
let output = shown.join("\n");
|
|
37
|
+
if (truncated) {
|
|
38
|
+
output += `\n\n[Truncated: showing ${MAX_RESULTS} of ${filtered.length} matches]`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
output += `\n\n${filtered.length} file(s) found`;
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function loadGitignore(dir) {
|
|
48
|
+
try {
|
|
49
|
+
const content = await fs.readFile(path.join(dir, ".gitignore"), "utf-8");
|
|
50
|
+
return content
|
|
51
|
+
.split("\n")
|
|
52
|
+
.map((l) => l.trim())
|
|
53
|
+
.filter((l) => l && !l.startsWith("#"));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,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} from "@mragentix/agent";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
4
|
+
declare const GrepParams: z.ZodObject<{
|
|
5
|
+
pattern: z.ZodString;
|
|
6
|
+
path: z.ZodOptional<z.ZodString>;
|
|
7
|
+
include: z.ZodOptional<z.ZodString>;
|
|
8
|
+
max_results: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
case_insensitive: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare function createGrepTool(cwd: string, ops?: ToolOperations): AgentTool<typeof GrepParams>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=grep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEvE,QAAA,MAAM,UAAU;;;;;;iBAWd,CAAC;AAKH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,cAAgC,GACpC,SAAS,CAAC,OAAO,UAAU,CAAC,CAyD9B"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import readline from "node:readline";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { resolvePath } from "./path-utils.js";
|
|
5
|
+
import { BINARY_EXTENSIONS } from "./read.js";
|
|
6
|
+
import { localOperations } from "./operations.js";
|
|
7
|
+
const GrepParams = z.object({
|
|
8
|
+
pattern: z.string().describe("Search pattern (regex supported)"),
|
|
9
|
+
path: z.string().optional().describe("File or directory to search (defaults to cwd)"),
|
|
10
|
+
include: z.string().optional().describe("Glob pattern to filter files (e.g. '*.ts')"),
|
|
11
|
+
max_results: z
|
|
12
|
+
.number()
|
|
13
|
+
.int()
|
|
14
|
+
.min(1)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Maximum matches to return (default: 50)"),
|
|
17
|
+
case_insensitive: z.boolean().optional().describe("Case-insensitive search"),
|
|
18
|
+
});
|
|
19
|
+
const DEFAULT_MAX_RESULTS = 50;
|
|
20
|
+
const MAX_LINE_LENGTH = 500;
|
|
21
|
+
export function createGrepTool(cwd, ops = localOperations) {
|
|
22
|
+
return {
|
|
23
|
+
name: "grep",
|
|
24
|
+
description: "Search file contents using regex. Returns filepath:line_number:content for matches. " +
|
|
25
|
+
"Respects .gitignore. Skips binary files.",
|
|
26
|
+
parameters: GrepParams,
|
|
27
|
+
async execute({ pattern, path: searchPath, include, max_results, case_insensitive }) {
|
|
28
|
+
const dir = searchPath ? resolvePath(cwd, searchPath) : cwd;
|
|
29
|
+
const maxResults = max_results ?? DEFAULT_MAX_RESULTS;
|
|
30
|
+
const flags = case_insensitive ? "gi" : "g";
|
|
31
|
+
let regex;
|
|
32
|
+
try {
|
|
33
|
+
regex = new RegExp(pattern, flags);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw new Error(`Invalid regex pattern: ${err.message}`, { cause: err });
|
|
37
|
+
}
|
|
38
|
+
// Check if dir is a file
|
|
39
|
+
const stat = await ops.stat(dir);
|
|
40
|
+
if (stat.isFile()) {
|
|
41
|
+
const results = await searchFile(dir, regex, cwd, maxResults, ops);
|
|
42
|
+
return formatResults(results, maxResults);
|
|
43
|
+
}
|
|
44
|
+
// Enumerate files
|
|
45
|
+
const fg = await import("fast-glob");
|
|
46
|
+
const globPattern = include ?? "**/*";
|
|
47
|
+
const entries = await fg.default(globPattern, {
|
|
48
|
+
cwd: dir,
|
|
49
|
+
dot: false,
|
|
50
|
+
onlyFiles: true,
|
|
51
|
+
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
52
|
+
});
|
|
53
|
+
const results = [];
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
if (results.length >= maxResults)
|
|
56
|
+
break;
|
|
57
|
+
const ext = path.extname(entry).toLowerCase();
|
|
58
|
+
if (BINARY_EXTENSIONS.has(ext))
|
|
59
|
+
continue;
|
|
60
|
+
const filePath = path.join(dir, entry);
|
|
61
|
+
const fileResults = await searchFile(filePath, regex, cwd, maxResults - results.length, ops);
|
|
62
|
+
results.push(...fileResults);
|
|
63
|
+
}
|
|
64
|
+
return formatResults(results, maxResults);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function searchFile(filePath, regex, cwd, maxResults, ops) {
|
|
69
|
+
const results = [];
|
|
70
|
+
const relPath = path.relative(cwd, filePath);
|
|
71
|
+
const stream = ops.createReadStream(filePath, "utf-8");
|
|
72
|
+
try {
|
|
73
|
+
const rl = readline.createInterface({
|
|
74
|
+
input: stream,
|
|
75
|
+
crlfDelay: Infinity,
|
|
76
|
+
});
|
|
77
|
+
let lineNum = 0;
|
|
78
|
+
try {
|
|
79
|
+
for await (const line of rl) {
|
|
80
|
+
lineNum++;
|
|
81
|
+
// Bail out if line contains null bytes (binary file not caught by extension check)
|
|
82
|
+
if (lineNum <= 5 && line.includes("\0")) {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
// Reset lastIndex for global regex
|
|
86
|
+
regex.lastIndex = 0;
|
|
87
|
+
if (regex.test(line)) {
|
|
88
|
+
// Truncate long lines to prevent massive output from binary/minified files
|
|
89
|
+
const truncatedLine = line.length > MAX_LINE_LENGTH ? line.slice(0, MAX_LINE_LENGTH) + "…" : line;
|
|
90
|
+
results.push(`${relPath}:${lineNum}:${truncatedLine}`);
|
|
91
|
+
if (results.length >= maxResults) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
rl.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Skip unreadable files
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
stream.destroy();
|
|
106
|
+
}
|
|
107
|
+
return results;
|
|
108
|
+
}
|
|
109
|
+
function formatResults(results, maxResults) {
|
|
110
|
+
if (results.length === 0)
|
|
111
|
+
return "No matches found.";
|
|
112
|
+
let output = results.join("\n");
|
|
113
|
+
if (results.length >= maxResults) {
|
|
114
|
+
output += `\n\n[Truncated at ${maxResults} matches]`;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
output += `\n\n${results.length} match(es) found`;
|
|
118
|
+
}
|
|
119
|
+
return output;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=grep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AAEvE,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAChE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IACrF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;IACrF,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,EAAE;SAC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OAAO,CAAC;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,OAAiB,EAAE,UAAkB;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,mBAAmB,CAAC;IAErD,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,OAAO,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACjC,MAAM,IAAI,qBAAqB,UAAU,WAAW,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,kBAAkB,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AgentTool } from "@mragentix/agent";
|
|
2
|
+
import { ProcessManager } from "../core/process-manager.js";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
4
|
+
import type { AgentDefinition } from "../core/agents.js";
|
|
5
|
+
export interface CreateToolsOptions {
|
|
6
|
+
agents?: AgentDefinition[];
|
|
7
|
+
provider?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
/** Custom I/O operations for remote execution (SSH, Docker, etc.). Defaults to local filesystem. */
|
|
10
|
+
operations?: ToolOperations;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateToolsResult {
|
|
13
|
+
tools: AgentTool[];
|
|
14
|
+
processManager: ProcessManager;
|
|
15
|
+
}
|
|
16
|
+
export declare function createTools(cwd: string, opts?: CreateToolsOptions): CreateToolsResult;
|
|
17
|
+
export { createReadTool } from "./read.js";
|
|
18
|
+
export { createWriteTool } from "./write.js";
|
|
19
|
+
export { createEditTool } from "./edit.js";
|
|
20
|
+
export { createBashTool } from "./bash.js";
|
|
21
|
+
export { createFindTool } from "./find.js";
|
|
22
|
+
export { createGrepTool } from "./grep.js";
|
|
23
|
+
export { createLsTool } from "./ls.js";
|
|
24
|
+
export { createWebFetchTool } from "./web-fetch.js";
|
|
25
|
+
export { createTaskOutputTool } from "./task-output.js";
|
|
26
|
+
export { createTaskStopTool } from "./task-stop.js";
|
|
27
|
+
export { createTasksTool } from "./tasks.js";
|
|
28
|
+
export { ProcessManager } from "../core/process-manager.js";
|
|
29
|
+
export { localOperations, type ToolOperations } from "./operations.js";
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAa5D,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CAwBrF;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ProcessManager } from "../core/process-manager.js";
|
|
2
|
+
import { createReadTool } from "./read.js";
|
|
3
|
+
import { createWriteTool } from "./write.js";
|
|
4
|
+
import { createEditTool } from "./edit.js";
|
|
5
|
+
import { createBashTool } from "./bash.js";
|
|
6
|
+
import { createFindTool } from "./find.js";
|
|
7
|
+
import { createGrepTool } from "./grep.js";
|
|
8
|
+
import { createLsTool } from "./ls.js";
|
|
9
|
+
import { createSubAgentTool } from "./subagent.js";
|
|
10
|
+
import { createWebFetchTool } from "./web-fetch.js";
|
|
11
|
+
import { createTaskOutputTool } from "./task-output.js";
|
|
12
|
+
import { createTaskStopTool } from "./task-stop.js";
|
|
13
|
+
import { createTasksTool } from "./tasks.js";
|
|
14
|
+
import { localOperations } from "./operations.js";
|
|
15
|
+
export function createTools(cwd, opts) {
|
|
16
|
+
const readFiles = new Set();
|
|
17
|
+
const processManager = new ProcessManager();
|
|
18
|
+
const ops = opts?.operations ?? localOperations;
|
|
19
|
+
const tools = [
|
|
20
|
+
createReadTool(cwd, readFiles, ops),
|
|
21
|
+
createWriteTool(cwd, readFiles, ops),
|
|
22
|
+
createEditTool(cwd, readFiles, ops),
|
|
23
|
+
createBashTool(cwd, processManager, ops),
|
|
24
|
+
createFindTool(cwd),
|
|
25
|
+
createGrepTool(cwd, ops),
|
|
26
|
+
createLsTool(cwd, ops),
|
|
27
|
+
createWebFetchTool(),
|
|
28
|
+
createTaskOutputTool(processManager),
|
|
29
|
+
createTaskStopTool(processManager),
|
|
30
|
+
createTasksTool(cwd),
|
|
31
|
+
];
|
|
32
|
+
if (opts?.agents && opts.agents.length > 0 && opts.provider && opts.model) {
|
|
33
|
+
tools.push(createSubAgentTool(cwd, opts.agents, opts.provider, opts.model));
|
|
34
|
+
}
|
|
35
|
+
return { tools, processManager };
|
|
36
|
+
}
|
|
37
|
+
export { createReadTool } from "./read.js";
|
|
38
|
+
export { createWriteTool } from "./write.js";
|
|
39
|
+
export { createEditTool } from "./edit.js";
|
|
40
|
+
export { createBashTool } from "./bash.js";
|
|
41
|
+
export { createFindTool } from "./find.js";
|
|
42
|
+
export { createGrepTool } from "./grep.js";
|
|
43
|
+
export { createLsTool } from "./ls.js";
|
|
44
|
+
export { createWebFetchTool } from "./web-fetch.js";
|
|
45
|
+
export { createTaskOutputTool } from "./task-output.js";
|
|
46
|
+
export { createTaskStopTool } from "./task-stop.js";
|
|
47
|
+
export { createTasksTool } from "./tasks.js";
|
|
48
|
+
export { ProcessManager } from "../core/process-manager.js";
|
|
49
|
+
export { localOperations } from "./operations.js";
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;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,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AACnC,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentTool } from "@mragentix/agent";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
4
|
+
declare const LsParams: z.ZodObject<{
|
|
5
|
+
path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
all: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare function createLsTool(cwd: string, ops?: ToolOperations): AgentTool<typeof LsParams>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEvE,QAAA,MAAM,QAAQ;;;iBAGZ,CAAC;AAEH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,cAAgC,GACpC,SAAS,CAAC,OAAO,QAAQ,CAAC,CAyC5B"}
|
package/dist/tools/ls.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { resolvePath } from "./path-utils.js";
|
|
4
|
+
import { localOperations } from "./operations.js";
|
|
5
|
+
const LsParams = z.object({
|
|
6
|
+
path: z.string().optional().describe("Directory path (defaults to cwd)"),
|
|
7
|
+
all: z.boolean().optional().describe("Show hidden files (default: false)"),
|
|
8
|
+
});
|
|
9
|
+
export function createLsTool(cwd, ops = localOperations) {
|
|
10
|
+
return {
|
|
11
|
+
name: "ls",
|
|
12
|
+
description: "List directory contents with file types and sizes. Directories listed first.",
|
|
13
|
+
parameters: LsParams,
|
|
14
|
+
async execute({ path: dirPath, all }) {
|
|
15
|
+
const resolved = dirPath ? resolvePath(cwd, dirPath) : cwd;
|
|
16
|
+
const entries = await ops.readdir(resolved, { withFileTypes: true });
|
|
17
|
+
// Filter hidden files unless --all
|
|
18
|
+
const filtered = all ? entries : entries.filter((e) => !e.name.startsWith("."));
|
|
19
|
+
// Separate dirs and files, then sort each alphabetically
|
|
20
|
+
const dirs = filtered
|
|
21
|
+
.filter((e) => e.isDirectory())
|
|
22
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
23
|
+
const files = filtered
|
|
24
|
+
.filter((e) => !e.isDirectory())
|
|
25
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
26
|
+
const lines = [];
|
|
27
|
+
for (const dir of dirs) {
|
|
28
|
+
lines.push(`d - ${dir.name}/`);
|
|
29
|
+
}
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
try {
|
|
32
|
+
const stat = await ops.stat(path.join(resolved, file.name));
|
|
33
|
+
const size = formatSize(stat.size);
|
|
34
|
+
const type = file.isSymbolicLink() ? "l" : "f";
|
|
35
|
+
lines.push(`${type} ${size.padStart(8)} ${file.name}`);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
lines.push(`? - ${file.name}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (lines.length === 0)
|
|
42
|
+
return "Empty directory.";
|
|
43
|
+
return lines.join("\n");
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function formatSize(bytes) {
|
|
48
|
+
if (bytes < 1024)
|
|
49
|
+
return `${bytes}B`;
|
|
50
|
+
if (bytes < 1024 * 1024)
|
|
51
|
+
return `${(bytes / 1024).toFixed(1)}K`;
|
|
52
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
53
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}M`;
|
|
54
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)}G`;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AAEvE,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACxB,IAAI,EAAE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G,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAChE,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAChF,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { type ReadStream } from "node:fs";
|
|
3
|
+
import type { Dirent, Stats } from "node:fs";
|
|
4
|
+
/**
|
|
5
|
+
* Abstraction over filesystem and process operations.
|
|
6
|
+
* Default implementation uses local Node.js APIs.
|
|
7
|
+
* Replace with SSH/Docker/cloud implementations for remote execution.
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolOperations {
|
|
10
|
+
/** Read a file's contents as UTF-8 string. */
|
|
11
|
+
readFile(path: string): Promise<string>;
|
|
12
|
+
/** Write content to a file. Creates parent directories if needed. */
|
|
13
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
14
|
+
/** Get file/directory stats. */
|
|
15
|
+
stat(path: string): Promise<Stats>;
|
|
16
|
+
/** Check if a path is a symbolic link. */
|
|
17
|
+
lstat(path: string): Promise<Stats>;
|
|
18
|
+
/** Read directory contents with file type info. */
|
|
19
|
+
readdir(path: string, options: {
|
|
20
|
+
withFileTypes: true;
|
|
21
|
+
}): Promise<Dirent[]>;
|
|
22
|
+
/** Create a directory (recursive). */
|
|
23
|
+
mkdir(path: string): Promise<void>;
|
|
24
|
+
/** Create a readable stream for a file. */
|
|
25
|
+
createReadStream(path: string, encoding: BufferEncoding): ReadStream;
|
|
26
|
+
/** Spawn a child process. Returns the ChildProcess handle. */
|
|
27
|
+
spawn(command: string, args: string[], options: {
|
|
28
|
+
cwd: string;
|
|
29
|
+
env?: Record<string, string>;
|
|
30
|
+
detached?: boolean;
|
|
31
|
+
stdio?: Array<"pipe" | "ignore">;
|
|
32
|
+
}): ChildProcess;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Default local filesystem + process operations.
|
|
36
|
+
* This is what tools use when running on the local machine.
|
|
37
|
+
*/
|
|
38
|
+
export declare const localOperations: ToolOperations;
|
|
39
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/tools/operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExC,qEAAqE;IACrE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD,gCAAgC;IAChC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAEnC,0CAA0C;IAC1C,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAEpC,mDAAmD;IACnD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,aAAa,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAE3E,sCAAsC;IACtC,KAAK,CAAC,IAA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