hoomanjs 1.18.0 → 1.18.1
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 +22 -26
- package/dist/acp/acp-agent.d.ts +69 -0
- package/dist/acp/acp-agent.js +628 -0
- package/dist/acp/acp-agent.js.map +1 -0
- package/dist/acp/approvals.d.ts +5 -0
- package/dist/acp/approvals.js +130 -0
- package/dist/acp/approvals.js.map +1 -0
- package/dist/acp/index.d.ts +1 -0
- package/dist/acp/index.js +2 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/mcp-servers.d.ts +7 -0
- package/dist/acp/mcp-servers.js +57 -0
- package/dist/acp/mcp-servers.js.map +1 -0
- package/dist/acp/meta/system-prompt.d.ts +12 -0
- package/dist/acp/meta/system-prompt.js +41 -0
- package/dist/acp/meta/system-prompt.js.map +1 -0
- package/dist/acp/meta/user-id.d.ts +12 -0
- package/dist/acp/meta/user-id.js +43 -0
- package/dist/acp/meta/user-id.js.map +1 -0
- package/dist/acp/prompt-invoke.d.ts +10 -0
- package/dist/acp/prompt-invoke.js +131 -0
- package/dist/acp/prompt-invoke.js.map +1 -0
- package/dist/acp/sessions/config-options.d.ts +7 -0
- package/dist/acp/sessions/config-options.js +101 -0
- package/dist/acp/sessions/config-options.js.map +1 -0
- package/dist/acp/sessions/replay.d.ts +7 -0
- package/dist/acp/sessions/replay.js +117 -0
- package/dist/acp/sessions/replay.js.map +1 -0
- package/dist/acp/sessions/store.d.ts +24 -0
- package/dist/acp/sessions/store.js +96 -0
- package/dist/acp/sessions/store.js.map +1 -0
- package/dist/acp/sessions/title.d.ts +5 -0
- package/dist/acp/sessions/title.js +22 -0
- package/dist/acp/sessions/title.js.map +1 -0
- package/dist/acp/utils/paths.d.ts +2 -0
- package/{src/acp/utils/paths.ts → dist/acp/utils/paths.js} +2 -2
- package/dist/acp/utils/paths.js.map +1 -0
- package/dist/acp/utils/tool-kind.d.ts +6 -0
- package/dist/acp/utils/tool-kind.js +53 -0
- package/dist/acp/utils/tool-kind.js.map +1 -0
- package/dist/acp/utils/tool-locations.d.ts +3 -0
- package/dist/acp/utils/tool-locations.js +44 -0
- package/dist/acp/utils/tool-locations.js.map +1 -0
- package/dist/acp/utils/tool-result-content.d.ts +8 -0
- package/dist/acp/utils/tool-result-content.js +14 -0
- package/dist/acp/utils/tool-result-content.js.map +1 -0
- package/dist/chat/app.d.ts +15 -0
- package/dist/chat/app.js +458 -0
- package/dist/chat/app.js.map +1 -0
- package/dist/chat/approvals.d.ts +15 -0
- package/dist/chat/approvals.js +74 -0
- package/dist/chat/approvals.js.map +1 -0
- package/dist/chat/components/ApprovalPrompt.d.ts +6 -0
- package/dist/chat/components/ApprovalPrompt.js +11 -0
- package/dist/chat/components/ApprovalPrompt.js.map +1 -0
- package/dist/chat/components/ChatMessage.d.ts +7 -0
- package/dist/chat/components/ChatMessage.js +19 -0
- package/dist/chat/components/ChatMessage.js.map +1 -0
- package/dist/chat/components/Composer.d.ts +11 -0
- package/dist/chat/components/Composer.js +9 -0
- package/dist/chat/components/Composer.js.map +1 -0
- package/dist/chat/components/EmptyChatBanner.d.ts +2 -0
- package/dist/chat/components/EmptyChatBanner.js +8 -0
- package/dist/chat/components/EmptyChatBanner.js.map +1 -0
- package/dist/chat/components/PromptInput.d.ts +11 -0
- package/dist/chat/components/PromptInput.js +26 -0
- package/dist/chat/components/PromptInput.js.map +1 -0
- package/dist/chat/components/QueuedPrompts.d.ts +10 -0
- package/dist/chat/components/QueuedPrompts.js +38 -0
- package/dist/chat/components/QueuedPrompts.js.map +1 -0
- package/dist/chat/components/ReasoningStrip.d.ts +6 -0
- package/dist/chat/components/ReasoningStrip.js +13 -0
- package/dist/chat/components/ReasoningStrip.js.map +1 -0
- package/dist/chat/components/ScrollView.d.ts +101 -0
- package/dist/chat/components/ScrollView.js +74 -0
- package/dist/chat/components/ScrollView.js.map +1 -0
- package/dist/chat/components/Spinner.d.ts +8 -0
- package/dist/chat/components/Spinner.js +19 -0
- package/dist/chat/components/Spinner.js.map +1 -0
- package/dist/chat/components/StatusBar.d.ts +20 -0
- package/dist/chat/components/StatusBar.js +20 -0
- package/dist/chat/components/StatusBar.js.map +1 -0
- package/dist/chat/components/ThinkingStatus.d.ts +1 -0
- package/dist/chat/components/ThinkingStatus.js +119 -0
- package/dist/chat/components/ThinkingStatus.js.map +1 -0
- package/dist/chat/components/TodoPanel.d.ts +6 -0
- package/dist/chat/components/TodoPanel.js +27 -0
- package/dist/chat/components/TodoPanel.js.map +1 -0
- package/dist/chat/components/ToolEvent.d.ts +6 -0
- package/dist/chat/components/ToolEvent.js +18 -0
- package/dist/chat/components/ToolEvent.js.map +1 -0
- package/dist/chat/components/ToolEventFileResult.d.ts +9 -0
- package/dist/chat/components/ToolEventFileResult.js +50 -0
- package/dist/chat/components/ToolEventFileResult.js.map +1 -0
- package/dist/chat/components/Transcript.d.ts +7 -0
- package/dist/chat/components/Transcript.js +9 -0
- package/dist/chat/components/Transcript.js.map +1 -0
- package/dist/chat/components/TranscriptViewport.d.ts +9 -0
- package/dist/chat/components/TranscriptViewport.js +124 -0
- package/dist/chat/components/TranscriptViewport.js.map +1 -0
- package/dist/chat/components/ascii-logo.d.ts +1 -0
- package/{src/chat/components/ascii-logo.ts → dist/chat/components/ascii-logo.js} +3 -2
- package/dist/chat/components/ascii-logo.js.map +1 -0
- package/dist/chat/components/file-tool-diff/file-tool-result.d.ts +26 -0
- package/dist/chat/components/file-tool-diff/file-tool-result.js +73 -0
- package/dist/chat/components/file-tool-diff/file-tool-result.js.map +1 -0
- package/dist/chat/components/markdown/BlockRenderer.d.ts +8 -0
- package/dist/chat/components/markdown/BlockRenderer.js +87 -0
- package/dist/chat/components/markdown/BlockRenderer.js.map +1 -0
- package/dist/chat/components/markdown/CodeBlock.d.ts +7 -0
- package/dist/chat/components/markdown/CodeBlock.js +55 -0
- package/dist/chat/components/markdown/CodeBlock.js.map +1 -0
- package/dist/chat/components/markdown/InlineRenderer.d.ts +8 -0
- package/dist/chat/components/markdown/InlineRenderer.js +96 -0
- package/dist/chat/components/markdown/InlineRenderer.js.map +1 -0
- package/dist/chat/components/markdown/MarkdownMessage.d.ts +6 -0
- package/dist/chat/components/markdown/MarkdownMessage.js +13 -0
- package/dist/chat/components/markdown/MarkdownMessage.js.map +1 -0
- package/dist/chat/components/markdown/MarkdownTable.d.ts +6 -0
- package/dist/chat/components/markdown/MarkdownTable.js +12 -0
- package/dist/chat/components/markdown/MarkdownTable.js.map +1 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTableLayout.d.ts +7 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTableLayout.js +186 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTableLayout.js.map +1 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTokens.d.ts +9 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTokens.js +25 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTokens.js.map +1 -0
- package/dist/chat/components/markdown/lexer.d.ts +7 -0
- package/dist/chat/components/markdown/lexer.js +89 -0
- package/dist/chat/components/markdown/lexer.js.map +1 -0
- package/dist/chat/components/prompt-input/clipboard-image.d.ts +1 -0
- package/dist/chat/components/prompt-input/clipboard-image.js +112 -0
- package/dist/chat/components/prompt-input/clipboard-image.js.map +1 -0
- package/dist/chat/components/prompt-input/hooks/usePromptInputController.d.ts +1 -0
- package/dist/chat/components/prompt-input/hooks/usePromptInputController.js +2 -0
- package/dist/chat/components/prompt-input/hooks/usePromptInputController.js.map +1 -0
- package/dist/chat/components/prompt-input/input-model.d.ts +28 -0
- package/dist/chat/components/prompt-input/input-model.js +231 -0
- package/dist/chat/components/prompt-input/input-model.js.map +1 -0
- package/dist/chat/components/prompt-input/paste.d.ts +11 -0
- package/dist/chat/components/prompt-input/paste.js +85 -0
- package/dist/chat/components/prompt-input/paste.js.map +1 -0
- package/dist/chat/components/prompt-input/render.d.ts +13 -0
- package/dist/chat/components/prompt-input/render.js +54 -0
- package/dist/chat/components/prompt-input/render.js.map +1 -0
- package/dist/chat/components/prompt-input/usePromptInputController.d.ts +17 -0
- package/dist/chat/components/prompt-input/usePromptInputController.js +366 -0
- package/dist/chat/components/prompt-input/usePromptInputController.js.map +1 -0
- package/dist/chat/components/shared.d.ts +6 -0
- package/dist/chat/components/shared.js +66 -0
- package/dist/chat/components/shared.js.map +1 -0
- package/dist/chat/index.d.ts +13 -0
- package/dist/chat/index.js +18 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/mouse.d.ts +5 -0
- package/dist/chat/mouse.js +9 -0
- package/dist/chat/mouse.js.map +1 -0
- package/dist/chat/types.d.ts +20 -0
- package/dist/chat/types.js +2 -0
- package/dist/chat/types.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +126 -0
- package/dist/cli.js.map +1 -0
- package/dist/configure/app.d.ts +3 -0
- package/dist/configure/app.js +1036 -0
- package/dist/configure/app.js.map +1 -0
- package/dist/configure/components/BusyScreen.d.ts +6 -0
- package/dist/configure/components/BusyScreen.js +7 -0
- package/dist/configure/components/BusyScreen.js.map +1 -0
- package/dist/configure/components/HomeScreen.d.ts +12 -0
- package/dist/configure/components/HomeScreen.js +7 -0
- package/dist/configure/components/HomeScreen.js.map +1 -0
- package/dist/configure/components/MenuScreen.d.ts +10 -0
- package/dist/configure/components/MenuScreen.js +15 -0
- package/dist/configure/components/MenuScreen.js.map +1 -0
- package/dist/configure/components/PromptForm.d.ts +8 -0
- package/dist/configure/components/PromptForm.js +12 -0
- package/dist/configure/components/PromptForm.js.map +1 -0
- package/dist/configure/components/SelectMenuItem.d.ts +7 -0
- package/dist/configure/components/SelectMenuItem.js +18 -0
- package/dist/configure/components/SelectMenuItem.js.map +1 -0
- package/dist/configure/index.d.ts +1 -0
- package/dist/configure/index.js +28 -0
- package/dist/configure/index.js.map +1 -0
- package/dist/configure/open-in-editor.d.ts +8 -0
- package/dist/configure/open-in-editor.js +120 -0
- package/dist/configure/open-in-editor.js.map +1 -0
- package/dist/configure/types.d.ts +63 -0
- package/dist/configure/types.js +2 -0
- package/dist/configure/types.js.map +1 -0
- package/dist/configure/utils.d.ts +19 -0
- package/dist/configure/utils.js +108 -0
- package/dist/configure/utils.js.map +1 -0
- package/dist/core/agent/index.d.ts +13 -0
- package/dist/core/agent/index.js +70 -0
- package/dist/core/agent/index.js.map +1 -0
- package/dist/core/agents/definitions.d.ts +12 -0
- package/dist/core/agents/definitions.js +35 -0
- package/dist/core/agents/definitions.js.map +1 -0
- package/dist/core/agents/index.d.ts +4 -0
- package/dist/core/agents/index.js +5 -0
- package/dist/core/agents/index.js.map +1 -0
- package/dist/core/agents/registry.d.ts +5 -0
- package/dist/core/agents/registry.js +84 -0
- package/dist/core/agents/registry.js.map +1 -0
- package/dist/core/agents/runner.d.ts +36 -0
- package/dist/core/agents/runner.js +275 -0
- package/dist/core/agents/runner.js.map +1 -0
- package/dist/core/agents/tools.d.ts +20 -0
- package/dist/core/agents/tools.js +66 -0
- package/dist/core/agents/tools.js.map +1 -0
- package/dist/core/config.d.ts +272 -0
- package/dist/core/config.js +334 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.js +21 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/mcp/config.d.ts +44 -0
- package/dist/core/mcp/config.js +65 -0
- package/dist/core/mcp/config.js.map +1 -0
- package/dist/core/mcp/index.d.ts +8 -0
- package/dist/core/mcp/index.js +12 -0
- package/dist/core/mcp/index.js.map +1 -0
- package/dist/core/mcp/manager.d.ts +69 -0
- package/dist/core/mcp/manager.js +376 -0
- package/dist/core/mcp/manager.js.map +1 -0
- package/dist/core/mcp/prefixed-mcp-tool.d.ts +14 -0
- package/dist/core/mcp/prefixed-mcp-tool.js +38 -0
- package/dist/core/mcp/prefixed-mcp-tool.js.map +1 -0
- package/dist/core/mcp/tools.d.ts +5 -0
- package/dist/core/mcp/tools.js +82 -0
- package/dist/core/mcp/tools.js.map +1 -0
- package/dist/core/mcp/types.d.ts +40 -0
- package/dist/core/mcp/types.js +28 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/memory/index.d.ts +3 -0
- package/dist/core/memory/index.js +3 -0
- package/dist/core/memory/index.js.map +1 -0
- package/dist/core/memory/ltm/embed.d.ts +16 -0
- package/dist/core/memory/ltm/embed.js +49 -0
- package/dist/core/memory/ltm/embed.js.map +1 -0
- package/dist/core/memory/ltm/index.d.ts +3 -0
- package/dist/core/memory/ltm/index.js +3 -0
- package/dist/core/memory/ltm/index.js.map +1 -0
- package/dist/core/memory/ltm/store.d.ts +20 -0
- package/dist/core/memory/ltm/store.js +271 -0
- package/dist/core/memory/ltm/store.js.map +1 -0
- package/dist/core/memory/ltm/tools.d.ts +21 -0
- package/dist/core/memory/ltm/tools.js +127 -0
- package/dist/core/memory/ltm/tools.js.map +1 -0
- package/dist/core/memory/ltm/types.d.ts +79 -0
- package/dist/core/memory/ltm/types.js +2 -0
- package/dist/core/memory/ltm/types.js.map +1 -0
- package/dist/core/memory/ltm/utils.d.ts +40 -0
- package/dist/core/memory/ltm/utils.js +145 -0
- package/dist/core/memory/ltm/utils.js.map +1 -0
- package/dist/core/memory/stm/flat-file-storage.d.ts +27 -0
- package/dist/core/memory/stm/flat-file-storage.js +63 -0
- package/dist/core/memory/stm/flat-file-storage.js.map +1 -0
- package/dist/core/memory/stm/index.d.ts +13 -0
- package/dist/core/memory/stm/index.js +24 -0
- package/dist/core/memory/stm/index.js.map +1 -0
- package/dist/core/memory/stm/lazy-session-manager.d.ts +37 -0
- package/dist/core/memory/stm/lazy-session-manager.js +163 -0
- package/dist/core/memory/stm/lazy-session-manager.js.map +1 -0
- package/dist/core/models/anthropic.d.ts +10 -0
- package/dist/core/models/anthropic.js +38 -0
- package/dist/core/models/anthropic.js.map +1 -0
- package/dist/core/models/bedrock.d.ts +21 -0
- package/dist/core/models/bedrock.js +24 -0
- package/dist/core/models/bedrock.js.map +1 -0
- package/dist/core/models/google.d.ts +10 -0
- package/dist/core/models/google.js +36 -0
- package/dist/core/models/google.js.map +1 -0
- package/dist/core/models/groq.d.ts +10 -0
- package/dist/core/models/groq.js +33 -0
- package/dist/core/models/groq.js.map +1 -0
- package/dist/core/models/index.d.ts +5 -0
- package/dist/core/models/index.js +11 -0
- package/dist/core/models/index.js.map +1 -0
- package/dist/core/models/moonshot.d.ts +11 -0
- package/dist/core/models/moonshot.js +39 -0
- package/dist/core/models/moonshot.js.map +1 -0
- package/dist/core/models/ollama/index.d.ts +3 -0
- package/dist/core/models/ollama/index.js +9 -0
- package/dist/core/models/ollama/index.js.map +1 -0
- package/dist/core/models/ollama/strands-ollama.d.ts +30 -0
- package/dist/core/models/ollama/strands-ollama.js +336 -0
- package/dist/core/models/ollama/strands-ollama.js.map +1 -0
- package/dist/core/models/openai.d.ts +4 -0
- package/dist/core/models/openai.js +9 -0
- package/dist/core/models/openai.js.map +1 -0
- package/dist/core/models/xai.d.ts +10 -0
- package/dist/core/models/xai.js +33 -0
- package/dist/core/models/xai.js.map +1 -0
- package/dist/core/prompts/environment.d.ts +11 -0
- package/dist/core/prompts/environment.js +51 -0
- package/dist/core/prompts/environment.js.map +1 -0
- package/dist/core/prompts/index.d.ts +7 -0
- package/dist/core/prompts/index.js +14 -0
- package/dist/core/prompts/index.js.map +1 -0
- package/dist/core/prompts/skills.d.ts +15 -0
- package/dist/core/prompts/skills.js +86 -0
- package/dist/core/prompts/skills.js.map +1 -0
- package/dist/core/prompts/system.d.ts +22 -0
- package/dist/core/prompts/system.js +164 -0
- package/dist/core/prompts/system.js.map +1 -0
- package/dist/core/skills/built-in/hooman-config/SKILL.md +9 -0
- package/dist/core/skills/index.d.ts +2 -0
- package/dist/core/skills/index.js +3 -0
- package/dist/core/skills/index.js.map +1 -0
- package/dist/core/skills/metadata.d.ts +8 -0
- package/dist/core/skills/metadata.js +20 -0
- package/dist/core/skills/metadata.js.map +1 -0
- package/dist/core/skills/registry.d.ts +38 -0
- package/dist/core/skills/registry.js +165 -0
- package/dist/core/skills/registry.js.map +1 -0
- package/dist/core/skills/tools.d.ts +9 -0
- package/dist/core/skills/tools.js +73 -0
- package/dist/core/skills/tools.js.map +1 -0
- package/dist/core/state/file-tool-display.d.ts +20 -0
- package/dist/core/state/file-tool-display.js +35 -0
- package/dist/core/state/file-tool-display.js.map +1 -0
- package/dist/core/state/thought-process.d.ts +18 -0
- package/dist/core/state/thought-process.js +21 -0
- package/dist/core/state/thought-process.js.map +1 -0
- package/dist/core/state/todos.d.ts +39 -0
- package/dist/core/state/todos.js +53 -0
- package/dist/core/state/todos.js.map +1 -0
- package/dist/core/state/tool-approvals.d.ts +12 -0
- package/dist/core/state/tool-approvals.js +81 -0
- package/dist/core/state/tool-approvals.js.map +1 -0
- package/dist/core/tools/fetch.d.ts +9 -0
- package/dist/core/tools/fetch.js +228 -0
- package/dist/core/tools/fetch.js.map +1 -0
- package/dist/core/tools/filesystem.d.ts +35 -0
- package/dist/core/tools/filesystem.js +791 -0
- package/dist/core/tools/filesystem.js.map +1 -0
- package/dist/core/tools/index.d.ts +9 -0
- package/dist/core/tools/index.js +10 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/shell.d.ts +18 -0
- package/dist/core/tools/shell.js +308 -0
- package/dist/core/tools/shell.js.map +1 -0
- package/dist/core/tools/sleep.d.ts +4 -0
- package/dist/core/tools/sleep.js +46 -0
- package/dist/core/tools/sleep.js.map +1 -0
- package/dist/core/tools/thinking.d.ts +12 -0
- package/dist/core/tools/thinking.js +119 -0
- package/dist/core/tools/thinking.js.map +1 -0
- package/dist/core/tools/time.d.ts +8 -0
- package/dist/core/tools/time.js +94 -0
- package/dist/core/tools/time.js.map +1 -0
- package/dist/core/tools/todo.d.ts +9 -0
- package/dist/core/tools/todo.js +33 -0
- package/dist/core/tools/todo.js.map +1 -0
- package/dist/core/tools/web-search.d.ts +11 -0
- package/dist/core/tools/web-search.js +211 -0
- package/dist/core/tools/web-search.js.map +1 -0
- package/dist/core/tools/wiki.d.ts +11 -0
- package/dist/core/tools/wiki.js +566 -0
- package/dist/core/tools/wiki.js.map +1 -0
- package/dist/core/utils/attachments.d.ts +23 -0
- package/dist/core/utils/attachments.js +125 -0
- package/dist/core/utils/attachments.js.map +1 -0
- package/dist/core/utils/cwd-context.d.ts +2 -0
- package/dist/core/utils/cwd-context.js +9 -0
- package/dist/core/utils/cwd-context.js.map +1 -0
- package/dist/core/utils/file-formats.d.ts +4 -0
- package/dist/core/utils/file-formats.js +48 -0
- package/dist/core/utils/file-formats.js.map +1 -0
- package/dist/core/utils/paths.d.ts +7 -0
- package/dist/core/utils/paths.js +25 -0
- package/dist/core/utils/paths.js.map +1 -0
- package/dist/daemon/approvals.d.ts +5 -0
- package/dist/daemon/approvals.js +95 -0
- package/dist/daemon/approvals.js.map +1 -0
- package/dist/daemon/index.d.ts +11 -0
- package/dist/daemon/index.js +106 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/queue.d.ts +5 -0
- package/dist/daemon/queue.js +38 -0
- package/dist/daemon/queue.js.map +1 -0
- package/dist/exec/approvals.d.ts +6 -0
- package/dist/exec/approvals.js +74 -0
- package/dist/exec/approvals.js.map +1 -0
- package/package.json +20 -9
- package/.github/screenshot.png +0 -0
- package/.github/workflows/build-publish.yml +0 -49
- package/docker-compose.yml +0 -13
- package/src/acp/acp-agent.ts +0 -814
- package/src/acp/approvals.ts +0 -146
- package/src/acp/index.ts +0 -1
- package/src/acp/mcp-servers.ts +0 -64
- package/src/acp/meta/system-prompt.ts +0 -44
- package/src/acp/meta/user-id.ts +0 -44
- package/src/acp/prompt-invoke.ts +0 -149
- package/src/acp/sessions/config-options.ts +0 -120
- package/src/acp/sessions/replay.ts +0 -131
- package/src/acp/sessions/store.ts +0 -161
- package/src/acp/sessions/title.ts +0 -22
- package/src/acp/utils/tool-kind.ts +0 -61
- package/src/acp/utils/tool-locations.ts +0 -48
- package/src/acp/utils/tool-result-content.ts +0 -27
- package/src/chat/app.tsx +0 -636
- package/src/chat/approvals.ts +0 -97
- package/src/chat/components/ApprovalPrompt.tsx +0 -25
- package/src/chat/components/ChatMessage.tsx +0 -50
- package/src/chat/components/Composer.tsx +0 -45
- package/src/chat/components/EmptyChatBanner.tsx +0 -26
- package/src/chat/components/PromptInput.tsx +0 -62
- package/src/chat/components/QueuedPrompts.tsx +0 -76
- package/src/chat/components/ReasoningStrip.tsx +0 -30
- package/src/chat/components/Spinner.tsx +0 -34
- package/src/chat/components/StatusBar.tsx +0 -67
- package/src/chat/components/ThinkingStatus.tsx +0 -128
- package/src/chat/components/TodoPanel.tsx +0 -49
- package/src/chat/components/ToolEvent.tsx +0 -41
- package/src/chat/components/ToolEventFileResult.tsx +0 -116
- package/src/chat/components/Transcript.tsx +0 -34
- package/src/chat/components/TranscriptViewport.tsx +0 -170
- package/src/chat/components/file-tool-diff/file-tool-result.ts +0 -155
- package/src/chat/components/markdown/BlockRenderer.tsx +0 -207
- package/src/chat/components/markdown/CodeBlock.tsx +0 -100
- package/src/chat/components/markdown/InlineRenderer.tsx +0 -122
- package/src/chat/components/markdown/MarkdownMessage.tsx +0 -35
- package/src/chat/components/markdown/MarkdownTable.tsx +0 -23
- package/src/chat/components/markdown/hooks/useMarkdownTableLayout.ts +0 -242
- package/src/chat/components/markdown/hooks/useMarkdownTokens.ts +0 -46
- package/src/chat/components/markdown/lexer.ts +0 -100
- package/src/chat/components/prompt-input/clipboard-image.ts +0 -119
- package/src/chat/components/prompt-input/hooks/usePromptInputController.ts +0 -4
- package/src/chat/components/prompt-input/input-model.ts +0 -294
- package/src/chat/components/prompt-input/paste.ts +0 -105
- package/src/chat/components/prompt-input/render.ts +0 -83
- package/src/chat/components/prompt-input/usePromptInputController.ts +0 -498
- package/src/chat/components/shared.ts +0 -70
- package/src/chat/index.tsx +0 -41
- package/src/chat/mouse.ts +0 -17
- package/src/chat/types.ts +0 -24
- package/src/cli.ts +0 -181
- package/src/configure/app.tsx +0 -1349
- package/src/configure/components/BusyScreen.tsx +0 -22
- package/src/configure/components/HomeScreen.tsx +0 -43
- package/src/configure/components/MenuScreen.tsx +0 -44
- package/src/configure/components/PromptForm.tsx +0 -40
- package/src/configure/components/SelectMenuItem.tsx +0 -30
- package/src/configure/index.tsx +0 -43
- package/src/configure/open-in-editor.ts +0 -133
- package/src/configure/types.ts +0 -51
- package/src/configure/utils.ts +0 -134
- package/src/core/agent/index.ts +0 -108
- package/src/core/agents/definitions.ts +0 -48
- package/src/core/agents/index.ts +0 -15
- package/src/core/agents/registry.ts +0 -106
- package/src/core/agents/runner.ts +0 -375
- package/src/core/agents/tools.ts +0 -100
- package/src/core/config.ts +0 -377
- package/src/core/index.ts +0 -60
- package/src/core/mcp/config.ts +0 -80
- package/src/core/mcp/index.ts +0 -33
- package/src/core/mcp/manager.ts +0 -491
- package/src/core/mcp/prefixed-mcp-tool.ts +0 -45
- package/src/core/mcp/tools.ts +0 -92
- package/src/core/mcp/types.ts +0 -37
- package/src/core/memory/index.ts +0 -17
- package/src/core/memory/ltm/embed.ts +0 -67
- package/src/core/memory/ltm/index.ts +0 -18
- package/src/core/memory/ltm/store.ts +0 -376
- package/src/core/memory/ltm/tools.ts +0 -146
- package/src/core/memory/ltm/types.ts +0 -111
- package/src/core/memory/ltm/utils.ts +0 -218
- package/src/core/memory/stm/flat-file-storage.ts +0 -89
- package/src/core/memory/stm/index.ts +0 -32
- package/src/core/memory/stm/lazy-session-manager.ts +0 -220
- package/src/core/models/anthropic.ts +0 -53
- package/src/core/models/bedrock.ts +0 -54
- package/src/core/models/google.ts +0 -51
- package/src/core/models/groq.ts +0 -48
- package/src/core/models/index.ts +0 -19
- package/src/core/models/moonshot.ts +0 -54
- package/src/core/models/ollama/index.ts +0 -13
- package/src/core/models/ollama/strands-ollama.ts +0 -439
- package/src/core/models/openai.ts +0 -12
- package/src/core/models/xai.ts +0 -47
- package/src/core/prompts/environment.ts +0 -71
- package/src/core/prompts/index.ts +0 -22
- package/src/core/prompts/skills.ts +0 -66
- package/src/core/prompts/system.ts +0 -183
- package/src/core/skills/index.ts +0 -2
- package/src/core/skills/registry.ts +0 -239
- package/src/core/skills/tools.ts +0 -80
- package/src/core/state/file-tool-display.ts +0 -70
- package/src/core/state/thought-process.ts +0 -49
- package/src/core/state/todos.ts +0 -84
- package/src/core/state/tool-approvals.ts +0 -100
- package/src/core/tools/fetch.ts +0 -288
- package/src/core/tools/filesystem.ts +0 -1105
- package/src/core/tools/index.ts +0 -9
- package/src/core/tools/shell.ts +0 -426
- package/src/core/tools/sleep.ts +0 -51
- package/src/core/tools/thinking.ts +0 -149
- package/src/core/tools/time.ts +0 -121
- package/src/core/tools/todo.ts +0 -44
- package/src/core/tools/web-search.ts +0 -278
- package/src/core/tools/wiki.ts +0 -703
- package/src/core/utils/attachments.ts +0 -201
- package/src/core/utils/cwd-context.ts +0 -11
- package/src/core/utils/file-formats.ts +0 -60
- package/src/core/utils/paths.ts +0 -37
- package/src/daemon/approvals.ts +0 -127
- package/src/daemon/index.ts +0 -153
- package/src/daemon/queue.ts +0 -48
- package/src/exec/approvals.ts +0 -90
- package/tsconfig.json +0 -30
- /package/{src → dist}/core/prompts/agents/plan.md +0 -0
- /package/{src → dist}/core/prompts/agents/research.md +0 -0
- /package/{src → dist}/core/prompts/harness/behaviour.md +0 -0
- /package/{src → dist}/core/prompts/harness/communication.md +0 -0
- /package/{src → dist}/core/prompts/harness/engineering.md +0 -0
- /package/{src → dist}/core/prompts/harness/execution.md +0 -0
- /package/{src → dist}/core/prompts/harness/guardrails.md +0 -0
- /package/{src → dist}/core/prompts/static/daemon.md +0 -0
- /package/{src → dist}/core/prompts/static/environment.md +0 -0
- /package/{src → dist}/core/prompts/static/fetch.md +0 -0
- /package/{src → dist}/core/prompts/static/filesystem.md +0 -0
- /package/{src → dist}/core/prompts/static/identity.md +0 -0
- /package/{src → dist}/core/prompts/static/ltm.md +0 -0
- /package/{src → dist}/core/prompts/static/shell.md +0 -0
- /package/{src → dist}/core/prompts/static/skills.md +0 -0
- /package/{src → dist}/core/prompts/static/sleep.md +0 -0
- /package/{src → dist}/core/prompts/static/subagents.md +0 -0
- /package/{src → dist}/core/prompts/static/thinking.md +0 -0
- /package/{src → dist}/core/prompts/static/todo.md +0 -0
- /package/{src → dist}/core/prompts/static/web-search.md +0 -0
- /package/{src → dist}/core/prompts/static/wiki.md +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { JSONValue } from "@strands-agents/sdk";
|
|
2
|
-
|
|
3
|
-
const FILE_TOOL_DISPLAY_STATE_KEY = "fileToolDisplay";
|
|
4
|
-
|
|
5
|
-
export type StructuredPatchHunk = {
|
|
6
|
-
oldStart: number;
|
|
7
|
-
oldLines: number;
|
|
8
|
-
newStart: number;
|
|
9
|
-
newLines: number;
|
|
10
|
-
lines: string[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type FileToolDisplay = {
|
|
14
|
-
previews?: string[];
|
|
15
|
-
structuredPatch?: StructuredPatchHunk[];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type DisplayStateStore = {
|
|
19
|
-
get(key: string): JSONValue | undefined;
|
|
20
|
-
set(key: string, value: unknown): void;
|
|
21
|
-
delete(key: string): void;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function readDisplayState(
|
|
25
|
-
appState: DisplayStateStore,
|
|
26
|
-
): Record<string, FileToolDisplay> {
|
|
27
|
-
const value = appState.get(FILE_TOOL_DISPLAY_STATE_KEY);
|
|
28
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
29
|
-
? (value as Record<string, FileToolDisplay>)
|
|
30
|
-
: {};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function setFileToolDisplay(
|
|
34
|
-
appState: DisplayStateStore,
|
|
35
|
-
toolUseId: string | undefined,
|
|
36
|
-
display: FileToolDisplay,
|
|
37
|
-
): void {
|
|
38
|
-
if (!toolUseId) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
appState.set(FILE_TOOL_DISPLAY_STATE_KEY, {
|
|
43
|
-
...readDisplayState(appState),
|
|
44
|
-
[toolUseId]: display,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function takeFileToolDisplay(
|
|
49
|
-
appState: DisplayStateStore,
|
|
50
|
-
toolUseId: string | null,
|
|
51
|
-
): FileToolDisplay | undefined {
|
|
52
|
-
if (!toolUseId) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const state = readDisplayState(appState);
|
|
57
|
-
const display = state[toolUseId];
|
|
58
|
-
if (!display) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const { [toolUseId]: _removed, ...nextState } = state;
|
|
63
|
-
if (Object.keys(nextState).length === 0) {
|
|
64
|
-
appState.delete(FILE_TOOL_DISPLAY_STATE_KEY);
|
|
65
|
-
} else {
|
|
66
|
-
appState.set(FILE_TOOL_DISPLAY_STATE_KEY, nextState);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return display;
|
|
70
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ToolContext } from "@strands-agents/sdk";
|
|
2
|
-
|
|
3
|
-
const THINKING_STATE_KEY = "thinking.sequential";
|
|
4
|
-
|
|
5
|
-
export type ThoughtEntry = {
|
|
6
|
-
thought: string;
|
|
7
|
-
thoughtNumber: number;
|
|
8
|
-
totalThoughts: number;
|
|
9
|
-
nextThoughtNeeded: boolean;
|
|
10
|
-
isRevision: boolean;
|
|
11
|
-
revisesThought: number | null;
|
|
12
|
-
branchFromThought: number | null;
|
|
13
|
-
branchId: string | null;
|
|
14
|
-
needsMoreThoughts: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type ThinkingState = {
|
|
18
|
-
history: ThoughtEntry[];
|
|
19
|
-
branches: string[];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function isThinkingState(value: unknown): value is ThinkingState {
|
|
23
|
-
return (
|
|
24
|
-
value !== null &&
|
|
25
|
-
typeof value === "object" &&
|
|
26
|
-
!Array.isArray(value) &&
|
|
27
|
-
"history" in value &&
|
|
28
|
-
"branches" in value &&
|
|
29
|
-
Array.isArray(value.history) &&
|
|
30
|
-
Array.isArray(value.branches)
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function readThinkingState(context: ToolContext): ThinkingState {
|
|
35
|
-
const current = context.agent.appState.get(THINKING_STATE_KEY);
|
|
36
|
-
|
|
37
|
-
if (isThinkingState(current)) {
|
|
38
|
-
return current;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return { history: [], branches: [] };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function writeThinkingState(
|
|
45
|
-
context: ToolContext,
|
|
46
|
-
state: ThinkingState,
|
|
47
|
-
): void {
|
|
48
|
-
context.agent.appState.set(THINKING_STATE_KEY, state);
|
|
49
|
-
}
|
package/src/core/state/todos.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const TODO_ITEMS_STATE_KEY = "todo.items";
|
|
4
|
-
export const TODO_VISIBLE_STATE_KEY = "todo.visible";
|
|
5
|
-
|
|
6
|
-
export const TodoStatusSchema = z.enum(["pending", "in_progress", "completed"]);
|
|
7
|
-
|
|
8
|
-
export const TodoItemSchema = z.object({
|
|
9
|
-
content: z.string().trim().min(1),
|
|
10
|
-
status: TodoStatusSchema,
|
|
11
|
-
activeForm: z.string().trim().min(1),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export type TodoStatus = z.infer<typeof TodoStatusSchema>;
|
|
15
|
-
export type TodoItem = z.infer<typeof TodoItemSchema>;
|
|
16
|
-
|
|
17
|
-
type AppStateLike = {
|
|
18
|
-
get<T = unknown>(key: string): T;
|
|
19
|
-
set(key: string, value: unknown): void;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type AgentLike = {
|
|
23
|
-
appState: AppStateLike;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type TodoViewState = {
|
|
27
|
-
visible: boolean;
|
|
28
|
-
todos: TodoItem[];
|
|
29
|
-
total: number;
|
|
30
|
-
pending: number;
|
|
31
|
-
ongoing: number;
|
|
32
|
-
completed: number;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
function normalizeTodoItems(value: unknown): TodoItem[] {
|
|
36
|
-
if (!Array.isArray(value)) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
const normalized: TodoItem[] = [];
|
|
40
|
-
for (const item of value) {
|
|
41
|
-
const parsed = TodoItemSchema.safeParse(item);
|
|
42
|
-
if (parsed.success) {
|
|
43
|
-
normalized.push(parsed.data);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return normalized;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function summarizeTodos(
|
|
50
|
-
todos: TodoItem[],
|
|
51
|
-
): Omit<TodoViewState, "visible" | "todos"> {
|
|
52
|
-
const pending = todos.filter((todo) => todo.status === "pending").length;
|
|
53
|
-
const ongoing = todos.filter((todo) => todo.status === "in_progress").length;
|
|
54
|
-
const completed = todos.filter((todo) => todo.status === "completed").length;
|
|
55
|
-
return {
|
|
56
|
-
total: todos.length,
|
|
57
|
-
pending,
|
|
58
|
-
ongoing,
|
|
59
|
-
completed,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function getTodoViewState(agent: AgentLike): TodoViewState {
|
|
64
|
-
const todos = normalizeTodoItems(agent.appState.get(TODO_ITEMS_STATE_KEY));
|
|
65
|
-
const rawVisible = agent.appState.get(TODO_VISIBLE_STATE_KEY);
|
|
66
|
-
const visible =
|
|
67
|
-
typeof rawVisible === "boolean" ? rawVisible : todos.length > 0;
|
|
68
|
-
const summary = summarizeTodos(todos);
|
|
69
|
-
return {
|
|
70
|
-
visible,
|
|
71
|
-
todos,
|
|
72
|
-
...summary,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function setTodoState(agent: AgentLike, todos: TodoItem[]): void {
|
|
77
|
-
agent.appState.set(TODO_ITEMS_STATE_KEY, todos);
|
|
78
|
-
agent.appState.set(TODO_VISIBLE_STATE_KEY, todos.length > 0);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function clearTodoState(agent: AgentLike): void {
|
|
82
|
-
agent.appState.set(TODO_ITEMS_STATE_KEY, []);
|
|
83
|
-
agent.appState.set(TODO_VISIBLE_STATE_KEY, false);
|
|
84
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
type AppStateLike = {
|
|
2
|
-
get<T = unknown>(key: string): T;
|
|
3
|
-
set(key: string, value: unknown): void;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
type AgentLike = {
|
|
7
|
-
appState: AppStateLike;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const SESSION_ALLOWED_TOOLS_KEY = "allowedTools";
|
|
11
|
-
|
|
12
|
-
export const INTERNAL_ALWAYS_ALLOWED = new Set([
|
|
13
|
-
// Strands / runtime
|
|
14
|
-
"strands_structured_output",
|
|
15
|
-
// Todos
|
|
16
|
-
"update_todos",
|
|
17
|
-
// Thinking
|
|
18
|
-
"think",
|
|
19
|
-
// Agent orchestration
|
|
20
|
-
"run_agents",
|
|
21
|
-
// Sleep
|
|
22
|
-
"sleep",
|
|
23
|
-
// Time
|
|
24
|
-
"convert_time",
|
|
25
|
-
"get_current_time",
|
|
26
|
-
// Wiki
|
|
27
|
-
"wiki_knowledge_graph",
|
|
28
|
-
"wiki_list_files",
|
|
29
|
-
"wiki_read_file",
|
|
30
|
-
"wiki_search",
|
|
31
|
-
"wiki_stats",
|
|
32
|
-
"wiki_write_file",
|
|
33
|
-
// Web search
|
|
34
|
-
"web_search",
|
|
35
|
-
// Long-term memory
|
|
36
|
-
"archive_memory",
|
|
37
|
-
"search_memory",
|
|
38
|
-
"store_memory",
|
|
39
|
-
"update_memory",
|
|
40
|
-
// Skills
|
|
41
|
-
"list_skills",
|
|
42
|
-
"search_skills",
|
|
43
|
-
// MCP config
|
|
44
|
-
"get_mcp_server",
|
|
45
|
-
"list_mcp_servers",
|
|
46
|
-
// Filesystem (list / search / metadata)
|
|
47
|
-
"directory_tree",
|
|
48
|
-
"get_file_info",
|
|
49
|
-
"list_directory",
|
|
50
|
-
"search_files",
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
function normalizeAllowedTools(value: unknown): string[] {
|
|
54
|
-
if (!Array.isArray(value)) {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const unique = new Set<string>();
|
|
59
|
-
for (const entry of value) {
|
|
60
|
-
if (typeof entry !== "string") {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const normalized = entry.trim();
|
|
64
|
-
if (!normalized) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
unique.add(normalized);
|
|
68
|
-
}
|
|
69
|
-
return [...unique];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function getSessionAllowedTools(agent: AgentLike): string[] {
|
|
73
|
-
const current = normalizeAllowedTools(
|
|
74
|
-
agent.appState.get(SESSION_ALLOWED_TOOLS_KEY),
|
|
75
|
-
);
|
|
76
|
-
const raw = agent.appState.get(SESSION_ALLOWED_TOOLS_KEY);
|
|
77
|
-
if (!Array.isArray(raw) || current.length !== raw.length) {
|
|
78
|
-
agent.appState.set(SESSION_ALLOWED_TOOLS_KEY, current);
|
|
79
|
-
}
|
|
80
|
-
return current;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function isToolSessionAllowed(
|
|
84
|
-
agent: AgentLike,
|
|
85
|
-
toolName: string,
|
|
86
|
-
): boolean {
|
|
87
|
-
return getSessionAllowedTools(agent).includes(toolName);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function allowToolForSession(agent: AgentLike, toolName: string): void {
|
|
91
|
-
const normalized = toolName.trim();
|
|
92
|
-
if (!normalized) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const allowed = getSessionAllowedTools(agent);
|
|
96
|
-
if (allowed.includes(normalized)) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
agent.appState.set(SESSION_ALLOWED_TOOLS_KEY, [...allowed, normalized]);
|
|
100
|
-
}
|
package/src/core/tools/fetch.ts
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import dns from "node:dns/promises";
|
|
2
|
-
import net from "node:net";
|
|
3
|
-
import { Readability } from "@mozilla/readability";
|
|
4
|
-
import { JSDOM } from "jsdom";
|
|
5
|
-
import { tool } from "@strands-agents/sdk";
|
|
6
|
-
import type { JSONValue, ToolContext } from "@strands-agents/sdk";
|
|
7
|
-
import TurndownService from "turndown";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
|
|
10
|
-
async function createUserAgent(): Promise<string> {
|
|
11
|
-
const path = new URL("../../../package.json", import.meta.url);
|
|
12
|
-
const pkg = (await Bun.file(path).json()) as {
|
|
13
|
-
name?: string;
|
|
14
|
-
version?: string;
|
|
15
|
-
};
|
|
16
|
-
return `${pkg.name ?? "hoomanjs"}/${pkg.version ?? "0.0.0"}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
20
|
-
const DEFAULT_MAX_LENGTH = 5000;
|
|
21
|
-
const MAX_FETCH_LENGTH = 1_000_000;
|
|
22
|
-
|
|
23
|
-
const turndown = new TurndownService({
|
|
24
|
-
headingStyle: "atx",
|
|
25
|
-
bulletListMarker: "-",
|
|
26
|
-
codeBlockStyle: "fenced",
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
function toJsonValue(value: unknown): JSONValue {
|
|
30
|
-
return JSON.parse(JSON.stringify(value)) as JSONValue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isHttpUrl(value: string): URL {
|
|
34
|
-
const url = new URL(value);
|
|
35
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
36
|
-
throw new Error("Only http:// and https:// URLs are supported.");
|
|
37
|
-
}
|
|
38
|
-
return url;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function isPrivateHostname(hostname: string): boolean {
|
|
42
|
-
const normalized = hostname.toLowerCase();
|
|
43
|
-
return (
|
|
44
|
-
normalized === "localhost" ||
|
|
45
|
-
normalized === "127.0.0.1" ||
|
|
46
|
-
normalized === "::1" ||
|
|
47
|
-
normalized.endsWith(".localhost")
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function isPrivateIp(address: string): boolean {
|
|
52
|
-
const version = net.isIP(address);
|
|
53
|
-
if (version === 4) {
|
|
54
|
-
const parts = address.split(".").map((part) => Number(part));
|
|
55
|
-
const a = parts[0] ?? -1;
|
|
56
|
-
const b = parts[1] ?? -1;
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
a === 10 ||
|
|
60
|
-
a === 127 ||
|
|
61
|
-
(a === 172 && b >= 16 && b <= 31) ||
|
|
62
|
-
(a === 192 && b === 168) ||
|
|
63
|
-
(a === 169 && b === 254)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (version === 6) {
|
|
68
|
-
const normalized = address.toLowerCase();
|
|
69
|
-
return (
|
|
70
|
-
normalized === "::1" ||
|
|
71
|
-
normalized.startsWith("fc") ||
|
|
72
|
-
normalized.startsWith("fd") ||
|
|
73
|
-
normalized.startsWith("fe80:")
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async function assertRemoteUrl(url: URL): Promise<void> {
|
|
81
|
-
if (isPrivateHostname(url.hostname)) {
|
|
82
|
-
throw new Error("Fetching localhost or loopback URLs is not allowed.");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const resolved = await dns.lookup(url.hostname, { all: true });
|
|
86
|
-
if (resolved.some((entry) => isPrivateIp(entry.address))) {
|
|
87
|
-
throw new Error("Fetching private-network URLs is not allowed.");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function responseHeaders(headers: Headers): Record<string, string> {
|
|
92
|
-
const out: Record<string, string> = {};
|
|
93
|
-
headers.forEach((value, key) => {
|
|
94
|
-
out[key] = value;
|
|
95
|
-
});
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function isHtml(contentType: string, body: string): boolean {
|
|
100
|
-
const normalized = contentType.toLowerCase();
|
|
101
|
-
return (
|
|
102
|
-
normalized.includes("text/html") ||
|
|
103
|
-
normalized.includes("application/xhtml+xml") ||
|
|
104
|
-
/^\s*<!doctype html/i.test(body) ||
|
|
105
|
-
/^\s*<html[\s>]/i.test(body)
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function tryFormatJson(body: string): string {
|
|
110
|
-
try {
|
|
111
|
-
return JSON.stringify(JSON.parse(body), null, 2);
|
|
112
|
-
} catch {
|
|
113
|
-
return body;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function htmlToMarkdown(
|
|
118
|
-
html: string,
|
|
119
|
-
baseUrl: string,
|
|
120
|
-
): { markdown: string; title?: string | null } {
|
|
121
|
-
const dom = new JSDOM(html, { url: baseUrl });
|
|
122
|
-
const reader = new Readability(dom.window.document);
|
|
123
|
-
const article = reader.parse();
|
|
124
|
-
|
|
125
|
-
const source = article?.content ?? dom.window.document.body?.innerHTML ?? "";
|
|
126
|
-
const markdown = turndown.turndown(source).trim();
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
markdown: markdown || "Page could not be simplified to markdown.",
|
|
130
|
-
title: article?.title ?? dom.window.document.title ?? null,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function sliceContent(
|
|
135
|
-
content: string,
|
|
136
|
-
startIndex: number,
|
|
137
|
-
maxLength: number,
|
|
138
|
-
): { content: string; truncated: boolean; nextStartIndex: number | null } {
|
|
139
|
-
if (startIndex >= content.length) {
|
|
140
|
-
return {
|
|
141
|
-
content: "No more content available.",
|
|
142
|
-
truncated: false,
|
|
143
|
-
nextStartIndex: null,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const slice = content.slice(startIndex, startIndex + maxLength);
|
|
148
|
-
const nextStartIndex =
|
|
149
|
-
startIndex + slice.length < content.length
|
|
150
|
-
? startIndex + slice.length
|
|
151
|
-
: null;
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
content: slice,
|
|
155
|
-
truncated: nextStartIndex !== null,
|
|
156
|
-
nextStartIndex,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function createFetchInputSchema() {
|
|
161
|
-
return z.object({
|
|
162
|
-
url: z.string().url().describe("Remote HTTP(S) URL to fetch."),
|
|
163
|
-
max_length: z.coerce
|
|
164
|
-
.number()
|
|
165
|
-
.int()
|
|
166
|
-
.min(1)
|
|
167
|
-
.max(MAX_FETCH_LENGTH)
|
|
168
|
-
.optional()
|
|
169
|
-
.describe("Maximum number of characters to return."),
|
|
170
|
-
start_index: z.coerce
|
|
171
|
-
.number()
|
|
172
|
-
.int()
|
|
173
|
-
.min(0)
|
|
174
|
-
.optional()
|
|
175
|
-
.describe("Start returning content from this character index."),
|
|
176
|
-
raw: z
|
|
177
|
-
.boolean()
|
|
178
|
-
.optional()
|
|
179
|
-
.describe(
|
|
180
|
-
"Return raw response text instead of simplifying HTML to markdown.",
|
|
181
|
-
),
|
|
182
|
-
timeout: z.coerce
|
|
183
|
-
.number()
|
|
184
|
-
.positive()
|
|
185
|
-
.optional()
|
|
186
|
-
.describe("Request timeout in seconds."),
|
|
187
|
-
headers: z
|
|
188
|
-
.record(z.string(), z.string())
|
|
189
|
-
.optional()
|
|
190
|
-
.describe("Optional extra HTTP headers."),
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export function createFetchTools() {
|
|
195
|
-
const inputSchema = createFetchInputSchema();
|
|
196
|
-
|
|
197
|
-
return [
|
|
198
|
-
tool({
|
|
199
|
-
name: "fetch",
|
|
200
|
-
description:
|
|
201
|
-
"Fetch a remote URL and return response content. HTML pages are simplified to markdown by default to save context window and tokens.",
|
|
202
|
-
inputSchema,
|
|
203
|
-
callback: async (input, context?: ToolContext) => {
|
|
204
|
-
const timeoutSeconds = input.timeout ?? DEFAULT_TIMEOUT_SECONDS;
|
|
205
|
-
const timeoutSignal = AbortSignal.timeout(timeoutSeconds * 1000);
|
|
206
|
-
const signal = context
|
|
207
|
-
? AbortSignal.any([timeoutSignal, context.agent.cancelSignal])
|
|
208
|
-
: timeoutSignal;
|
|
209
|
-
|
|
210
|
-
const url = isHttpUrl(input.url);
|
|
211
|
-
await assertRemoteUrl(url);
|
|
212
|
-
|
|
213
|
-
const headers = new Headers(input.headers);
|
|
214
|
-
if (!headers.has("user-agent")) {
|
|
215
|
-
headers.set("user-agent", await createUserAgent());
|
|
216
|
-
}
|
|
217
|
-
if (!headers.has("accept")) {
|
|
218
|
-
headers.set(
|
|
219
|
-
"accept",
|
|
220
|
-
"text/html,application/xhtml+xml,application/json,text/plain;q=0.9,*/*;q=0.5",
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
try {
|
|
225
|
-
const response = await fetch(url, {
|
|
226
|
-
method: "GET",
|
|
227
|
-
headers,
|
|
228
|
-
redirect: "follow",
|
|
229
|
-
signal,
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
const text = await response.text();
|
|
233
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
234
|
-
|
|
235
|
-
if (!response.ok) {
|
|
236
|
-
throw new Error(
|
|
237
|
-
`HTTP ${response.status} ${response.statusText}: GET ${url.toString()}`,
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
let transformed = text;
|
|
242
|
-
let transformedFormat: "raw" | "markdown" | "json-pretty" = "raw";
|
|
243
|
-
let title: string | null | undefined;
|
|
244
|
-
|
|
245
|
-
if (!input.raw && isHtml(contentType, text)) {
|
|
246
|
-
const result = htmlToMarkdown(text, url.toString());
|
|
247
|
-
transformed = result.markdown;
|
|
248
|
-
transformedFormat = "markdown";
|
|
249
|
-
title = result.title;
|
|
250
|
-
} else if (contentType.toLowerCase().includes("json")) {
|
|
251
|
-
transformed = tryFormatJson(text);
|
|
252
|
-
transformedFormat = "json-pretty";
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const paged = sliceContent(
|
|
256
|
-
transformed,
|
|
257
|
-
input.start_index ?? 0,
|
|
258
|
-
input.max_length ?? DEFAULT_MAX_LENGTH,
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
return toJsonValue({
|
|
262
|
-
url: url.toString(),
|
|
263
|
-
status: response.status,
|
|
264
|
-
statusText: response.statusText,
|
|
265
|
-
headers: responseHeaders(response.headers),
|
|
266
|
-
content_type: contentType || null,
|
|
267
|
-
format: transformedFormat,
|
|
268
|
-
title: title ?? null,
|
|
269
|
-
start_index: input.start_index ?? 0,
|
|
270
|
-
max_length: input.max_length ?? DEFAULT_MAX_LENGTH,
|
|
271
|
-
total_length: transformed.length,
|
|
272
|
-
truncated: paged.truncated,
|
|
273
|
-
next_start_index: paged.nextStartIndex,
|
|
274
|
-
content: paged.content,
|
|
275
|
-
});
|
|
276
|
-
} catch (error) {
|
|
277
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
278
|
-
const reason = timeoutSignal.aborted
|
|
279
|
-
? `Request timed out after ${timeoutSeconds} seconds`
|
|
280
|
-
: "Request was cancelled";
|
|
281
|
-
throw new Error(`${reason}: ${url.toString()}`);
|
|
282
|
-
}
|
|
283
|
-
throw error;
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
}),
|
|
287
|
-
];
|
|
288
|
-
}
|