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,51 +0,0 @@
|
|
|
1
|
-
import { GoogleModel } from "@strands-agents/sdk/models/google";
|
|
2
|
-
import type { GoogleModelOptions } from "@strands-agents/sdk/models/google";
|
|
3
|
-
import { omit, pick } from "lodash";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Keys passed to {@link GoogleModel} alongside `modelId` / `params`.
|
|
7
|
-
* Generation options (`temperature`, `maxOutputTokens`, …) belong in `params`
|
|
8
|
-
* (see Gemini [GenerationConfig](https://ai.google.dev/api/generate-content#generationconfig)).
|
|
9
|
-
*/
|
|
10
|
-
const TOP_LEVEL_KEYS = [
|
|
11
|
-
"apiKey",
|
|
12
|
-
"client",
|
|
13
|
-
"clientConfig",
|
|
14
|
-
"builtInTools",
|
|
15
|
-
] as const;
|
|
16
|
-
|
|
17
|
-
function omitUndefined(
|
|
18
|
-
record: Record<string, unknown>,
|
|
19
|
-
): Record<string, unknown> {
|
|
20
|
-
const unset = Object.keys(record).filter((k) => record[k] === undefined);
|
|
21
|
-
return omit(record, unset);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Google Gemini via Strands {@link GoogleModel} (`@google/genai` under the hood).
|
|
26
|
-
*
|
|
27
|
-
* - **`config.llm.model`**: Gemini id (e.g. `gemini-2.5-flash`).
|
|
28
|
-
* - **`params`**: Optional `apiKey` (defaults to `GEMINI_API_KEY`), or `client` / `clientConfig`
|
|
29
|
-
* for a custom Google GenAI client. Any other keys are sent as `params` to the API
|
|
30
|
-
* (`temperature`, `maxOutputTokens`, `topP`, `topK`, …).
|
|
31
|
-
*/
|
|
32
|
-
export function create(
|
|
33
|
-
model: string,
|
|
34
|
-
params: Record<string, unknown> = {},
|
|
35
|
-
): GoogleModel {
|
|
36
|
-
const top = omitUndefined(
|
|
37
|
-
pick(params, [...TOP_LEVEL_KEYS]) as Record<string, unknown>,
|
|
38
|
-
) as Pick<
|
|
39
|
-
GoogleModelOptions,
|
|
40
|
-
"apiKey" | "client" | "clientConfig" | "builtInTools"
|
|
41
|
-
>;
|
|
42
|
-
const filtered = omitUndefined(
|
|
43
|
-
omit(params, [...TOP_LEVEL_KEYS]) as Record<string, unknown>,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return new GoogleModel({
|
|
47
|
-
modelId: model,
|
|
48
|
-
...top,
|
|
49
|
-
...(Object.keys(filtered).length > 0 ? { params: filtered } : {}),
|
|
50
|
-
} as GoogleModelOptions);
|
|
51
|
-
}
|
package/src/core/models/groq.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createGroq, groq } from "@ai-sdk/groq";
|
|
2
|
-
import { VercelModel } from "@strands-agents/sdk/models/vercel";
|
|
3
|
-
import type { GroqProviderSettings } from "@ai-sdk/groq";
|
|
4
|
-
import type { VercelModelConfig } from "@strands-agents/sdk/models/vercel";
|
|
5
|
-
import { omit, pick } from "lodash";
|
|
6
|
-
|
|
7
|
-
const PROVIDER_SETTINGS_KEYS = ["apiKey", "baseURL", "headers"] as const;
|
|
8
|
-
|
|
9
|
-
function pickProviderSettings(
|
|
10
|
-
params: Record<string, unknown>,
|
|
11
|
-
): GroqProviderSettings {
|
|
12
|
-
const picked = pick(params, [...PROVIDER_SETTINGS_KEYS]) as Record<
|
|
13
|
-
string,
|
|
14
|
-
unknown
|
|
15
|
-
>;
|
|
16
|
-
const unset = Object.keys(picked).filter((k) => picked[k] === undefined);
|
|
17
|
-
return omit(picked, unset) as GroqProviderSettings;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function pickVercelModelConfig(
|
|
21
|
-
params: Record<string, unknown>,
|
|
22
|
-
): Partial<VercelModelConfig> {
|
|
23
|
-
return omit(params, [
|
|
24
|
-
...PROVIDER_SETTINGS_KEYS,
|
|
25
|
-
]) as Partial<VercelModelConfig>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Groq via AI SDK + Strands {@link VercelModel}.
|
|
30
|
-
*
|
|
31
|
-
* - **`config.llm.model`**: model id passed to `groq(...)` (e.g. `gemma2-9b-it`).
|
|
32
|
-
* - **`params`**: {@link GroqProviderSettings} (`apiKey`, `baseURL`, `headers`).
|
|
33
|
-
* If none are set, the default provider is used (`GROQ_API_KEY` from env).
|
|
34
|
-
* - Any other `params` keys are forwarded as {@link VercelModelConfig} (e.g. `temperature`, `maxTokens`).
|
|
35
|
-
*/
|
|
36
|
-
export function create(
|
|
37
|
-
model: string,
|
|
38
|
-
params: Record<string, unknown> = {},
|
|
39
|
-
): VercelModel {
|
|
40
|
-
const settings = pickProviderSettings(params);
|
|
41
|
-
const provider =
|
|
42
|
-
Object.keys(settings).length > 0 ? createGroq(settings) : groq;
|
|
43
|
-
const config = pickVercelModelConfig(params);
|
|
44
|
-
return new VercelModel({
|
|
45
|
-
provider: provider(model),
|
|
46
|
-
...config,
|
|
47
|
-
});
|
|
48
|
-
}
|
package/src/core/models/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Model, BaseModelConfig } from "@strands-agents/sdk";
|
|
2
|
-
|
|
3
|
-
export type ModelProvider = {
|
|
4
|
-
create: (
|
|
5
|
-
model: string,
|
|
6
|
-
params: Record<string, any>,
|
|
7
|
-
) => Model<BaseModelConfig>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const modelProviders: Record<string, () => Promise<ModelProvider>> = {
|
|
11
|
-
anthropic: () => import("./anthropic.ts"),
|
|
12
|
-
bedrock: () => import("./bedrock.ts"),
|
|
13
|
-
google: () => import("./google.ts"),
|
|
14
|
-
groq: () => import("./groq.ts"),
|
|
15
|
-
moonshot: () => import("./moonshot.ts"),
|
|
16
|
-
ollama: () => import("./ollama/index.ts"),
|
|
17
|
-
openai: () => import("./openai.ts"),
|
|
18
|
-
xai: () => import("./xai.ts"),
|
|
19
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { createMoonshotAI, moonshotai } from "@ai-sdk/moonshotai";
|
|
2
|
-
import { VercelModel } from "@strands-agents/sdk/models/vercel";
|
|
3
|
-
import type { MoonshotAIProviderSettings } from "@ai-sdk/moonshotai";
|
|
4
|
-
import type { VercelModelConfig } from "@strands-agents/sdk/models/vercel";
|
|
5
|
-
import { omit, pick } from "lodash";
|
|
6
|
-
|
|
7
|
-
const PROVIDER_SETTINGS_KEYS = [
|
|
8
|
-
"apiKey",
|
|
9
|
-
"baseURL",
|
|
10
|
-
"headers",
|
|
11
|
-
"fetch",
|
|
12
|
-
] as const;
|
|
13
|
-
|
|
14
|
-
function pickProviderSettings(
|
|
15
|
-
params: Record<string, unknown>,
|
|
16
|
-
): MoonshotAIProviderSettings {
|
|
17
|
-
const picked = pick(params, [...PROVIDER_SETTINGS_KEYS]) as Record<
|
|
18
|
-
string,
|
|
19
|
-
unknown
|
|
20
|
-
>;
|
|
21
|
-
const unset = Object.keys(picked).filter((k) => picked[k] === undefined);
|
|
22
|
-
return omit(picked, unset) as MoonshotAIProviderSettings;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function pickVercelModelConfig(
|
|
26
|
-
params: Record<string, unknown>,
|
|
27
|
-
): Partial<VercelModelConfig> {
|
|
28
|
-
return omit(params, [
|
|
29
|
-
...PROVIDER_SETTINGS_KEYS,
|
|
30
|
-
]) as Partial<VercelModelConfig>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Moonshot AI via AI SDK + Strands {@link VercelModel}.
|
|
35
|
-
*
|
|
36
|
-
* - **`config.llm.model`**: model id passed to `moonshotai(...)` (e.g. `kimi-k2.5`).
|
|
37
|
-
* - **`params`**: {@link MoonshotAIProviderSettings} (`apiKey`, `baseURL`, `headers`, `fetch`).
|
|
38
|
-
* If none are set, the default provider is used (`MOONSHOT_API_KEY` from env).
|
|
39
|
-
* - Any other `params` keys are forwarded as {@link VercelModelConfig} (e.g. `temperature`,
|
|
40
|
-
* `maxTokens`, `providerOptions`).
|
|
41
|
-
*/
|
|
42
|
-
export function create(
|
|
43
|
-
model: string,
|
|
44
|
-
params: Record<string, unknown> = {},
|
|
45
|
-
): VercelModel {
|
|
46
|
-
const settings = pickProviderSettings(params);
|
|
47
|
-
const provider =
|
|
48
|
-
Object.keys(settings).length > 0 ? createMoonshotAI(settings) : moonshotai;
|
|
49
|
-
const config = pickVercelModelConfig(params);
|
|
50
|
-
return new VercelModel({
|
|
51
|
-
provider: provider(model),
|
|
52
|
-
...config,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { OllamaModelConfig } from "./strands-ollama.ts";
|
|
2
|
-
import { StrandsOllamaModel } from "./strands-ollama.ts";
|
|
3
|
-
|
|
4
|
-
/** Strands {@link Model} backed by local (or remote) Ollama via `ollama` JS. */
|
|
5
|
-
export function create(
|
|
6
|
-
model: string,
|
|
7
|
-
params: Record<string, any>,
|
|
8
|
-
): StrandsOllamaModel {
|
|
9
|
-
return new StrandsOllamaModel({
|
|
10
|
-
modelId: model,
|
|
11
|
-
...(params as Omit<OllamaModelConfig, "modelId">),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ContextWindowOverflowError,
|
|
3
|
-
Model,
|
|
4
|
-
ModelError,
|
|
5
|
-
} from "@strands-agents/sdk";
|
|
6
|
-
import type { SystemPrompt } from "@strands-agents/sdk";
|
|
7
|
-
import type { BaseModelConfig, StreamOptions } from "@strands-agents/sdk";
|
|
8
|
-
import {
|
|
9
|
-
ModelContentBlockDeltaEvent,
|
|
10
|
-
ModelContentBlockStartEvent,
|
|
11
|
-
ModelContentBlockStopEvent,
|
|
12
|
-
ModelMessageStartEvent,
|
|
13
|
-
ModelMessageStopEvent,
|
|
14
|
-
ModelMetadataEvent,
|
|
15
|
-
} from "@strands-agents/sdk";
|
|
16
|
-
import type { ModelStreamEvent } from "@strands-agents/sdk";
|
|
17
|
-
import type { ToolSpec } from "@strands-agents/sdk";
|
|
18
|
-
import { Message, ToolResultBlock, ToolUseBlock } from "@strands-agents/sdk";
|
|
19
|
-
import type {
|
|
20
|
-
ContentBlock,
|
|
21
|
-
ImageBlock,
|
|
22
|
-
JsonBlock,
|
|
23
|
-
ToolResultContent,
|
|
24
|
-
} from "@strands-agents/sdk";
|
|
25
|
-
import { Ollama } from "ollama";
|
|
26
|
-
import type {
|
|
27
|
-
ChatRequest,
|
|
28
|
-
ChatResponse,
|
|
29
|
-
Message as OllamaMessage,
|
|
30
|
-
Tool as OllamaTool,
|
|
31
|
-
} from "ollama";
|
|
32
|
-
|
|
33
|
-
export interface OllamaModelConfig extends BaseModelConfig {
|
|
34
|
-
modelId?: string;
|
|
35
|
-
/** Ollama server URL (default `http://127.0.0.1:11434` or `OLLAMA_HOST`). */
|
|
36
|
-
host?: string;
|
|
37
|
-
/** Passed through to Ollama `keep_alive`. */
|
|
38
|
-
keepAlive?: string | number;
|
|
39
|
-
/** Merged into Ollama `options` (e.g. num_ctx). */
|
|
40
|
-
options?: Record<string, unknown>;
|
|
41
|
-
/**
|
|
42
|
-
* Ollama `think` flag (controls `message.thinking` on supported models).
|
|
43
|
-
* - **Omitted (`undefined`):** do not send `think` — server default (often streams `thinking`, which we map to
|
|
44
|
-
* Strands `ReasoningBlock` via `reasoningContentDelta`).
|
|
45
|
-
* - **`false`:** disable the thinking channel; the model puts prose in `content` only (shows up as normal
|
|
46
|
-
* `TextBlock` in persisted sessions).
|
|
47
|
-
* - **`true` or `"high" | "medium" | "low"`:** force extended thinking at that level.
|
|
48
|
-
*/
|
|
49
|
-
think?: boolean | "high" | "medium" | "low";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function extractSystemText(system?: SystemPrompt): string | undefined {
|
|
53
|
-
if (system === undefined) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
if (typeof system === "string") {
|
|
57
|
-
return system;
|
|
58
|
-
}
|
|
59
|
-
const parts: string[] = [];
|
|
60
|
-
for (const block of system) {
|
|
61
|
-
if (block.type === "textBlock") {
|
|
62
|
-
parts.push(block.text);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const joined = parts.join("\n").trim();
|
|
66
|
-
return joined.length > 0 ? joined : undefined;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** One Ollama chat message carrying an image (bytes or URL string). */
|
|
70
|
-
function formatImageBlock(
|
|
71
|
-
role: "user" | "assistant" | "tool",
|
|
72
|
-
block: ImageBlock,
|
|
73
|
-
): OllamaMessage[] {
|
|
74
|
-
const src = block.source;
|
|
75
|
-
if (src.type === "imageSourceBytes") {
|
|
76
|
-
return [{ role, content: "", images: [src.bytes] }];
|
|
77
|
-
}
|
|
78
|
-
if (src.type === "imageSourceUrl") {
|
|
79
|
-
return [{ role, content: "", images: [src.url] }];
|
|
80
|
-
}
|
|
81
|
-
return [
|
|
82
|
-
{
|
|
83
|
-
role,
|
|
84
|
-
content:
|
|
85
|
-
"(Ollama: image sources other than bytes or URL are not supported for this provider)",
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Flatten a tool result into one Ollama `role: "tool"` message per content item, matching
|
|
92
|
-
* Python `OllamaModel._format_request_message_contents` for `toolResult` (text, JSON as text,
|
|
93
|
-
* nested images as `images`, etc.).
|
|
94
|
-
*/
|
|
95
|
-
function formatToolResultContentsToOllama(
|
|
96
|
-
block: ToolResultBlock,
|
|
97
|
-
): OllamaMessage[] {
|
|
98
|
-
const out: OllamaMessage[] = [];
|
|
99
|
-
for (const c of block.content) {
|
|
100
|
-
out.push(...formatToolResultContentToOllama(c));
|
|
101
|
-
}
|
|
102
|
-
if (out.length > 0) {
|
|
103
|
-
return out;
|
|
104
|
-
}
|
|
105
|
-
const fallback = block.status === "error" ? "(tool error)" : "";
|
|
106
|
-
return [{ role: "tool", content: fallback }];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function formatToolResultContentToOllama(
|
|
110
|
-
c: ToolResultContent,
|
|
111
|
-
): OllamaMessage[] {
|
|
112
|
-
if (c.type === "textBlock") {
|
|
113
|
-
return [{ role: "tool", content: c.text }];
|
|
114
|
-
}
|
|
115
|
-
if (c.type === "jsonBlock") {
|
|
116
|
-
const j = c as JsonBlock;
|
|
117
|
-
return [{ role: "tool", content: JSON.stringify(j.json) }];
|
|
118
|
-
}
|
|
119
|
-
if (c.type === "imageBlock") {
|
|
120
|
-
return formatImageBlock("tool", c as ImageBlock);
|
|
121
|
-
}
|
|
122
|
-
if (c.type === "videoBlock" || c.type === "documentBlock") {
|
|
123
|
-
return [
|
|
124
|
-
{
|
|
125
|
-
role: "tool",
|
|
126
|
-
content: `(Ollama: tool result ${c.type} is not supported)`,
|
|
127
|
-
},
|
|
128
|
-
];
|
|
129
|
-
}
|
|
130
|
-
return [];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function formatContentBlock(
|
|
134
|
-
role: "user" | "assistant",
|
|
135
|
-
block: ContentBlock,
|
|
136
|
-
): OllamaMessage[] {
|
|
137
|
-
if (block.type === "textBlock") {
|
|
138
|
-
return [{ role, content: block.text }];
|
|
139
|
-
}
|
|
140
|
-
if (block.type === "imageBlock") {
|
|
141
|
-
return formatImageBlock(role, block as ImageBlock);
|
|
142
|
-
}
|
|
143
|
-
if (block.type === "toolUseBlock") {
|
|
144
|
-
const b = block as ToolUseBlock;
|
|
145
|
-
const args =
|
|
146
|
-
typeof b.input === "object" && b.input !== null && !Array.isArray(b.input)
|
|
147
|
-
? (b.input as Record<string, unknown>)
|
|
148
|
-
: {};
|
|
149
|
-
return [
|
|
150
|
-
{
|
|
151
|
-
role: "assistant",
|
|
152
|
-
content: "",
|
|
153
|
-
tool_calls: [
|
|
154
|
-
{
|
|
155
|
-
function: {
|
|
156
|
-
name: b.name,
|
|
157
|
-
arguments: args,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
];
|
|
163
|
-
}
|
|
164
|
-
if (block.type === "toolResultBlock") {
|
|
165
|
-
return formatToolResultContentsToOllama(block as ToolResultBlock);
|
|
166
|
-
}
|
|
167
|
-
if (block.type === "reasoningBlock") {
|
|
168
|
-
// Ollama chat history has no structured reasoning part. Re-sending prior turns' chain
|
|
169
|
-
// of thought as plain text would pollute `content` and break separation in persistence — omit.
|
|
170
|
-
return [];
|
|
171
|
-
}
|
|
172
|
-
return [];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function strandsMessagesToOllama(
|
|
176
|
-
messages: Message[],
|
|
177
|
-
systemText: string | undefined,
|
|
178
|
-
): OllamaMessage[] {
|
|
179
|
-
const out: OllamaMessage[] = [];
|
|
180
|
-
if (systemText) {
|
|
181
|
-
out.push({ role: "system", content: systemText });
|
|
182
|
-
}
|
|
183
|
-
for (const msg of messages) {
|
|
184
|
-
for (const block of msg.content) {
|
|
185
|
-
out.push(...formatContentBlock(msg.role, block));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return out;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function strandsToolsToOllama(
|
|
192
|
-
toolSpecs: ToolSpec[] | undefined,
|
|
193
|
-
): OllamaTool[] | undefined {
|
|
194
|
-
if (!toolSpecs?.length) {
|
|
195
|
-
return undefined;
|
|
196
|
-
}
|
|
197
|
-
return toolSpecs.map(
|
|
198
|
-
(spec) =>
|
|
199
|
-
({
|
|
200
|
-
type: "function",
|
|
201
|
-
function: {
|
|
202
|
-
name: spec.name,
|
|
203
|
-
description: spec.description,
|
|
204
|
-
parameters: spec.inputSchema ?? { type: "object", properties: {} },
|
|
205
|
-
},
|
|
206
|
-
}) as OllamaTool,
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function mapDoneReason(reason: string | undefined): "endTurn" | "maxTokens" {
|
|
211
|
-
const r = (reason ?? "").toLowerCase();
|
|
212
|
-
if (r.includes("length") || r === "max_tokens") {
|
|
213
|
-
return "maxTokens";
|
|
214
|
-
}
|
|
215
|
-
return "endTurn";
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** Stable key so we do not re-emit identical `tool_calls` on repeated stream chunks. */
|
|
219
|
-
function toolCallsSnapshotKey(
|
|
220
|
-
calls: NonNullable<NonNullable<ChatResponse["message"]>["tool_calls"]>,
|
|
221
|
-
): string {
|
|
222
|
-
return JSON.stringify(
|
|
223
|
-
calls.map((tc) => ({
|
|
224
|
-
name: tc.function?.name,
|
|
225
|
-
args: tc.function?.arguments,
|
|
226
|
-
})),
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export class StrandsOllamaModel extends Model<OllamaModelConfig> {
|
|
231
|
-
private config: OllamaModelConfig;
|
|
232
|
-
private readonly client: Ollama;
|
|
233
|
-
|
|
234
|
-
constructor(config: OllamaModelConfig) {
|
|
235
|
-
super();
|
|
236
|
-
this.config = { ...config };
|
|
237
|
-
this.client = new Ollama({
|
|
238
|
-
host:
|
|
239
|
-
this.config.host ?? process.env.OLLAMA_HOST ?? "http://127.0.0.1:11434",
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
updateConfig(modelConfig: OllamaModelConfig): void {
|
|
244
|
-
this.config = { ...this.config, ...modelConfig };
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
getConfig(): OllamaModelConfig {
|
|
248
|
-
return { ...this.config };
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async *stream(
|
|
252
|
-
messages: Message[],
|
|
253
|
-
options?: StreamOptions,
|
|
254
|
-
): AsyncIterable<ModelStreamEvent> {
|
|
255
|
-
const modelId = this.config.modelId;
|
|
256
|
-
if (!modelId) {
|
|
257
|
-
throw new ModelError("Ollama modelId is not configured");
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const systemText = extractSystemText(options?.systemPrompt);
|
|
261
|
-
const ollamaMessages = strandsMessagesToOllama(messages, systemText);
|
|
262
|
-
const tools = strandsToolsToOllama(options?.toolSpecs);
|
|
263
|
-
|
|
264
|
-
const request: ChatRequest = {
|
|
265
|
-
model: modelId,
|
|
266
|
-
messages: ollamaMessages,
|
|
267
|
-
stream: true,
|
|
268
|
-
tools,
|
|
269
|
-
options: {
|
|
270
|
-
num_predict: this.config.maxTokens,
|
|
271
|
-
temperature: this.config.temperature,
|
|
272
|
-
top_p: this.config.topP,
|
|
273
|
-
...(this.config.options ?? {}),
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
if (this.config.think !== undefined) {
|
|
277
|
-
request.think = this.config.think;
|
|
278
|
-
}
|
|
279
|
-
if (this.config.keepAlive !== undefined) {
|
|
280
|
-
request.keep_alive = this.config.keepAlive;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
let stream: AsyncIterable<ChatResponse>;
|
|
284
|
-
try {
|
|
285
|
-
stream = await this.client.chat({ ...request, stream: true });
|
|
286
|
-
} catch (e) {
|
|
287
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
288
|
-
if (msg.toLowerCase().includes("context") || msg.includes("token")) {
|
|
289
|
-
throw new ContextWindowOverflowError(msg);
|
|
290
|
-
}
|
|
291
|
-
throw new ModelError(`Ollama chat error: ${msg}`, { cause: e });
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// `message.content` is treated as an incremental fragment per chunk (Ollama / ollama-js).
|
|
295
|
-
// **Tool calls:** many models (e.g. gemma4:e4b) send `tool_calls` only on `done: false` chunks;
|
|
296
|
-
// the final `done: true` line often omits `tool_calls`, so we must not require `part.done`.
|
|
297
|
-
// Emit tools when a new snapshot differs from the last emitted (Strands concatenates tool deltas).
|
|
298
|
-
yield new ModelMessageStartEvent({
|
|
299
|
-
type: "modelMessageStartEvent",
|
|
300
|
-
role: "assistant",
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
let last: ChatResponse | undefined;
|
|
304
|
-
let toolRequested = false;
|
|
305
|
-
let textBlockOpen = false;
|
|
306
|
-
let reasoningBlockOpen = false;
|
|
307
|
-
let lastEmittedToolCallsKey: string | undefined;
|
|
308
|
-
|
|
309
|
-
for await (const part of stream) {
|
|
310
|
-
last = part;
|
|
311
|
-
const msg = part.message;
|
|
312
|
-
if (!msg) {
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const calls = msg.tool_calls;
|
|
317
|
-
if (calls?.length) {
|
|
318
|
-
const snapKey = toolCallsSnapshotKey(calls);
|
|
319
|
-
if (snapKey !== lastEmittedToolCallsKey) {
|
|
320
|
-
lastEmittedToolCallsKey = snapKey;
|
|
321
|
-
toolRequested = true;
|
|
322
|
-
if (reasoningBlockOpen) {
|
|
323
|
-
yield new ModelContentBlockStopEvent({
|
|
324
|
-
type: "modelContentBlockStopEvent",
|
|
325
|
-
});
|
|
326
|
-
reasoningBlockOpen = false;
|
|
327
|
-
}
|
|
328
|
-
if (textBlockOpen) {
|
|
329
|
-
yield new ModelContentBlockStopEvent({
|
|
330
|
-
type: "modelContentBlockStopEvent",
|
|
331
|
-
});
|
|
332
|
-
textBlockOpen = false;
|
|
333
|
-
}
|
|
334
|
-
let toolIndex = 0;
|
|
335
|
-
for (const toolCall of calls) {
|
|
336
|
-
const name = toolCall.function?.name ?? "tool";
|
|
337
|
-
const apiId = (toolCall as { id?: string }).id;
|
|
338
|
-
const toolUseId =
|
|
339
|
-
apiId ?? (calls.length > 1 ? `${name}_${toolIndex}` : name);
|
|
340
|
-
toolIndex += 1;
|
|
341
|
-
const argsRaw = toolCall.function?.arguments;
|
|
342
|
-
const inputStr =
|
|
343
|
-
typeof argsRaw === "string"
|
|
344
|
-
? argsRaw
|
|
345
|
-
: JSON.stringify(argsRaw ?? {});
|
|
346
|
-
yield new ModelContentBlockStartEvent({
|
|
347
|
-
type: "modelContentBlockStartEvent",
|
|
348
|
-
start: { type: "toolUseStart", name, toolUseId },
|
|
349
|
-
});
|
|
350
|
-
yield new ModelContentBlockDeltaEvent({
|
|
351
|
-
type: "modelContentBlockDeltaEvent",
|
|
352
|
-
delta: {
|
|
353
|
-
type: "toolUseInputDelta",
|
|
354
|
-
input: inputStr,
|
|
355
|
-
},
|
|
356
|
-
});
|
|
357
|
-
yield new ModelContentBlockStopEvent({
|
|
358
|
-
type: "modelContentBlockStopEvent",
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
const thinking = (msg as { thinking?: string }).thinking ?? "";
|
|
365
|
-
const content = msg.content ?? "";
|
|
366
|
-
|
|
367
|
-
if (thinking.length > 0) {
|
|
368
|
-
if (textBlockOpen) {
|
|
369
|
-
yield new ModelContentBlockStopEvent({
|
|
370
|
-
type: "modelContentBlockStopEvent",
|
|
371
|
-
});
|
|
372
|
-
textBlockOpen = false;
|
|
373
|
-
}
|
|
374
|
-
if (!reasoningBlockOpen) {
|
|
375
|
-
yield new ModelContentBlockStartEvent({
|
|
376
|
-
type: "modelContentBlockStartEvent",
|
|
377
|
-
});
|
|
378
|
-
reasoningBlockOpen = true;
|
|
379
|
-
}
|
|
380
|
-
yield new ModelContentBlockDeltaEvent({
|
|
381
|
-
type: "modelContentBlockDeltaEvent",
|
|
382
|
-
delta: { type: "reasoningContentDelta", text: thinking },
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (content.length > 0) {
|
|
387
|
-
if (reasoningBlockOpen) {
|
|
388
|
-
yield new ModelContentBlockStopEvent({
|
|
389
|
-
type: "modelContentBlockStopEvent",
|
|
390
|
-
});
|
|
391
|
-
reasoningBlockOpen = false;
|
|
392
|
-
}
|
|
393
|
-
if (!textBlockOpen) {
|
|
394
|
-
yield new ModelContentBlockStartEvent({
|
|
395
|
-
type: "modelContentBlockStartEvent",
|
|
396
|
-
});
|
|
397
|
-
textBlockOpen = true;
|
|
398
|
-
}
|
|
399
|
-
yield new ModelContentBlockDeltaEvent({
|
|
400
|
-
type: "modelContentBlockDeltaEvent",
|
|
401
|
-
delta: { type: "textDelta", text: content },
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (reasoningBlockOpen) {
|
|
407
|
-
yield new ModelContentBlockStopEvent({
|
|
408
|
-
type: "modelContentBlockStopEvent",
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
if (textBlockOpen) {
|
|
412
|
-
yield new ModelContentBlockStopEvent({
|
|
413
|
-
type: "modelContentBlockStopEvent",
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const doneReason = last?.done_reason;
|
|
418
|
-
const stopReason = toolRequested
|
|
419
|
-
? ("toolUse" as const)
|
|
420
|
-
: mapDoneReason(doneReason);
|
|
421
|
-
|
|
422
|
-
yield new ModelMessageStopEvent({
|
|
423
|
-
type: "modelMessageStopEvent",
|
|
424
|
-
stopReason,
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
yield new ModelMetadataEvent({
|
|
428
|
-
type: "modelMetadataEvent",
|
|
429
|
-
usage: {
|
|
430
|
-
inputTokens: last?.prompt_eval_count ?? 0,
|
|
431
|
-
outputTokens: last?.eval_count ?? 0,
|
|
432
|
-
totalTokens: (last?.prompt_eval_count ?? 0) + (last?.eval_count ?? 0),
|
|
433
|
-
},
|
|
434
|
-
metrics: last?.total_duration
|
|
435
|
-
? { latencyMs: last.total_duration / 1_000_000 }
|
|
436
|
-
: undefined,
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
}
|
package/src/core/models/xai.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createXai, xai } from "@ai-sdk/xai";
|
|
2
|
-
import { VercelModel } from "@strands-agents/sdk/models/vercel";
|
|
3
|
-
import type { XaiProviderSettings } from "@ai-sdk/xai";
|
|
4
|
-
import type { VercelModelConfig } from "@strands-agents/sdk/models/vercel";
|
|
5
|
-
import { omit, pick } from "lodash";
|
|
6
|
-
|
|
7
|
-
const PROVIDER_SETTINGS_KEYS = ["apiKey", "baseURL", "headers"] as const;
|
|
8
|
-
|
|
9
|
-
function pickProviderSettings(
|
|
10
|
-
params: Record<string, unknown>,
|
|
11
|
-
): XaiProviderSettings {
|
|
12
|
-
const picked = pick(params, [...PROVIDER_SETTINGS_KEYS]) as Record<
|
|
13
|
-
string,
|
|
14
|
-
unknown
|
|
15
|
-
>;
|
|
16
|
-
const unset = Object.keys(picked).filter((k) => picked[k] === undefined);
|
|
17
|
-
return omit(picked, unset) as XaiProviderSettings;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function pickVercelModelConfig(
|
|
21
|
-
params: Record<string, unknown>,
|
|
22
|
-
): Partial<VercelModelConfig> {
|
|
23
|
-
return omit(params, [
|
|
24
|
-
...PROVIDER_SETTINGS_KEYS,
|
|
25
|
-
]) as Partial<VercelModelConfig>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* xAI (Grok) via AI SDK + Strands {@link VercelModel}.
|
|
30
|
-
*
|
|
31
|
-
* - **`config.llm.model`**: model id passed to `xai(...)` (e.g. `grok-4.20-non-reasoning`).
|
|
32
|
-
* - **`params`**: {@link XaiProviderSettings} (`apiKey`, `baseURL`, `headers`).
|
|
33
|
-
* If none are set, the default provider is used (`XAI_API_KEY` from env).
|
|
34
|
-
* - Any other `params` keys are forwarded as {@link VercelModelConfig} (e.g. `temperature`, `maxTokens`).
|
|
35
|
-
*/
|
|
36
|
-
export function create(
|
|
37
|
-
model: string,
|
|
38
|
-
params: Record<string, unknown> = {},
|
|
39
|
-
): VercelModel {
|
|
40
|
-
const settings = pickProviderSettings(params);
|
|
41
|
-
const provider = Object.keys(settings).length > 0 ? createXai(settings) : xai;
|
|
42
|
-
const config = pickVercelModelConfig(params);
|
|
43
|
-
return new VercelModel({
|
|
44
|
-
provider: provider(model),
|
|
45
|
-
...config,
|
|
46
|
-
});
|
|
47
|
-
}
|