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,242 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import type { Token, Tokens } from "marked";
|
|
3
|
-
import { inlineToPlainText } from "../InlineRenderer.tsx";
|
|
4
|
-
|
|
5
|
-
const MIN_COLUMN_WIDTH = 3;
|
|
6
|
-
const MAX_ROW_LINES = 4;
|
|
7
|
-
const SAFETY_MARGIN = 4;
|
|
8
|
-
|
|
9
|
-
type TableLayout = {
|
|
10
|
-
mode: "horizontal" | "vertical";
|
|
11
|
-
lines: string[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function displayWidth(value: string): number {
|
|
15
|
-
return Array.from(value).length;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function longestWordWidth(value: string): number {
|
|
19
|
-
const words = value.split(/\s+/).filter(Boolean);
|
|
20
|
-
if (words.length === 0) {
|
|
21
|
-
return MIN_COLUMN_WIDTH;
|
|
22
|
-
}
|
|
23
|
-
return Math.max(...words.map((word) => displayWidth(word)), MIN_COLUMN_WIDTH);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function wrapText(value: string, width: number): string[] {
|
|
27
|
-
if (width <= 0) {
|
|
28
|
-
return [value];
|
|
29
|
-
}
|
|
30
|
-
const normalized = value.replace(/\r\n/g, "\n").trimEnd();
|
|
31
|
-
const sourceLines = normalized.length > 0 ? normalized.split("\n") : [""];
|
|
32
|
-
const wrapped = sourceLines.flatMap((line) => {
|
|
33
|
-
const words = line.split(/\s+/).filter(Boolean);
|
|
34
|
-
if (words.length === 0) {
|
|
35
|
-
return [""];
|
|
36
|
-
}
|
|
37
|
-
const output: string[] = [];
|
|
38
|
-
let current = "";
|
|
39
|
-
for (const word of words) {
|
|
40
|
-
const candidate = current ? `${current} ${word}` : word;
|
|
41
|
-
if (displayWidth(candidate) <= width) {
|
|
42
|
-
current = candidate;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (current) {
|
|
46
|
-
output.push(current);
|
|
47
|
-
}
|
|
48
|
-
if (displayWidth(word) <= width) {
|
|
49
|
-
current = word;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
let remaining = word;
|
|
53
|
-
while (displayWidth(remaining) > width) {
|
|
54
|
-
output.push(Array.from(remaining).slice(0, width).join(""));
|
|
55
|
-
remaining = Array.from(remaining).slice(width).join("");
|
|
56
|
-
}
|
|
57
|
-
current = remaining;
|
|
58
|
-
}
|
|
59
|
-
if (current) {
|
|
60
|
-
output.push(current);
|
|
61
|
-
}
|
|
62
|
-
return output.length > 0 ? output : [""];
|
|
63
|
-
});
|
|
64
|
-
return wrapped.length > 0 ? wrapped : [""];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function padAligned(
|
|
68
|
-
value: string,
|
|
69
|
-
width: number,
|
|
70
|
-
align: "left" | "center" | "right" | null | undefined,
|
|
71
|
-
): string {
|
|
72
|
-
const padding = Math.max(0, width - displayWidth(value));
|
|
73
|
-
if (align === "center") {
|
|
74
|
-
const leftPad = Math.floor(padding / 2);
|
|
75
|
-
return `${" ".repeat(leftPad)}${value}${" ".repeat(padding - leftPad)}`;
|
|
76
|
-
}
|
|
77
|
-
if (align === "right") {
|
|
78
|
-
return `${" ".repeat(padding)}${value}`;
|
|
79
|
-
}
|
|
80
|
-
return `${value}${" ".repeat(padding)}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function rowToCells(row: Array<{ tokens?: Token[] }>): string[] {
|
|
84
|
-
return row.map((cell) => inlineToPlainText(cell.tokens).trim());
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function getVerticalLayout(
|
|
88
|
-
header: string[],
|
|
89
|
-
rows: string[][],
|
|
90
|
-
terminalWidth: number,
|
|
91
|
-
): TableLayout {
|
|
92
|
-
const lines: string[] = [];
|
|
93
|
-
const separator = "─".repeat(Math.min(Math.max(terminalWidth - 1, 10), 40));
|
|
94
|
-
rows.forEach((row, rowIndex) => {
|
|
95
|
-
if (rowIndex > 0) {
|
|
96
|
-
lines.push(separator);
|
|
97
|
-
}
|
|
98
|
-
row.forEach((cell, columnIndex) => {
|
|
99
|
-
const label = header[columnIndex] || `Column ${columnIndex + 1}`;
|
|
100
|
-
const compact = cell.replace(/\s+/g, " ").trim();
|
|
101
|
-
const wrapped = wrapText(
|
|
102
|
-
compact,
|
|
103
|
-
Math.max(10, terminalWidth - displayWidth(label) - 3),
|
|
104
|
-
);
|
|
105
|
-
lines.push(`${label}: ${wrapped[0] ?? ""}`);
|
|
106
|
-
for (let index = 1; index < wrapped.length; index += 1) {
|
|
107
|
-
lines.push(` ${wrapped[index]}`);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
return { mode: "vertical", lines };
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function useMarkdownTableLayout(
|
|
115
|
-
token: Tokens.Table,
|
|
116
|
-
terminalWidth: number,
|
|
117
|
-
): TableLayout {
|
|
118
|
-
return useMemo(() => {
|
|
119
|
-
const header = rowToCells(token.header);
|
|
120
|
-
const rows = token.rows.map((row) => rowToCells(row));
|
|
121
|
-
const columnCount = header.length;
|
|
122
|
-
if (columnCount === 0) {
|
|
123
|
-
return { mode: "horizontal", lines: [] };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const minWidths = header.map((_, columnIndex) => {
|
|
127
|
-
let max = longestWordWidth(header[columnIndex] ?? "");
|
|
128
|
-
for (const row of rows) {
|
|
129
|
-
max = Math.max(max, longestWordWidth(row[columnIndex] ?? ""));
|
|
130
|
-
}
|
|
131
|
-
return max;
|
|
132
|
-
});
|
|
133
|
-
const idealWidths = header.map((_, columnIndex) => {
|
|
134
|
-
let max = Math.max(
|
|
135
|
-
displayWidth(header[columnIndex] ?? ""),
|
|
136
|
-
MIN_COLUMN_WIDTH,
|
|
137
|
-
);
|
|
138
|
-
for (const row of rows) {
|
|
139
|
-
max = Math.max(max, displayWidth(row[columnIndex] ?? ""));
|
|
140
|
-
}
|
|
141
|
-
return max;
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const borderOverhead = 1 + columnCount * 3;
|
|
145
|
-
const availableWidth = Math.max(
|
|
146
|
-
terminalWidth - borderOverhead - SAFETY_MARGIN,
|
|
147
|
-
columnCount * MIN_COLUMN_WIDTH,
|
|
148
|
-
);
|
|
149
|
-
const totalMin = minWidths.reduce((sum, width) => sum + width, 0);
|
|
150
|
-
const totalIdeal = idealWidths.reduce((sum, width) => sum + width, 0);
|
|
151
|
-
|
|
152
|
-
let columnWidths: number[];
|
|
153
|
-
if (totalIdeal <= availableWidth) {
|
|
154
|
-
columnWidths = idealWidths;
|
|
155
|
-
} else if (totalMin <= availableWidth) {
|
|
156
|
-
const remaining = availableWidth - totalMin;
|
|
157
|
-
const overflows = idealWidths.map(
|
|
158
|
-
(ideal, index) => ideal - minWidths[index]!,
|
|
159
|
-
);
|
|
160
|
-
const totalOverflow = overflows.reduce(
|
|
161
|
-
(sum, overflow) => sum + overflow,
|
|
162
|
-
0,
|
|
163
|
-
);
|
|
164
|
-
columnWidths = minWidths.map((minWidth, index) => {
|
|
165
|
-
if (totalOverflow === 0) {
|
|
166
|
-
return minWidth;
|
|
167
|
-
}
|
|
168
|
-
const extra = Math.floor(
|
|
169
|
-
(overflows[index]! / totalOverflow) * remaining,
|
|
170
|
-
);
|
|
171
|
-
return minWidth + extra;
|
|
172
|
-
});
|
|
173
|
-
} else {
|
|
174
|
-
const ratio = availableWidth / totalMin;
|
|
175
|
-
columnWidths = minWidths.map((width) =>
|
|
176
|
-
Math.max(Math.floor(width * ratio), MIN_COLUMN_WIDTH),
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const maxRowLines = [header, ...rows]
|
|
181
|
-
.map((row) =>
|
|
182
|
-
row.reduce((max, cell, index) => {
|
|
183
|
-
const wrapped = wrapText(cell, columnWidths[index]!);
|
|
184
|
-
return Math.max(max, wrapped.length);
|
|
185
|
-
}, 1),
|
|
186
|
-
)
|
|
187
|
-
.reduce((max, count) => Math.max(max, count), 1);
|
|
188
|
-
|
|
189
|
-
if (maxRowLines > MAX_ROW_LINES) {
|
|
190
|
-
return getVerticalLayout(header, rows, terminalWidth);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function border(type: "top" | "middle" | "bottom"): string {
|
|
194
|
-
const chars = {
|
|
195
|
-
top: ["┌", "─", "┬", "┐"],
|
|
196
|
-
middle: ["├", "─", "┼", "┤"],
|
|
197
|
-
bottom: ["└", "─", "┴", "┘"],
|
|
198
|
-
}[type] as [string, string, string, string];
|
|
199
|
-
const [left, line, cross, right] = chars;
|
|
200
|
-
return `${left}${columnWidths
|
|
201
|
-
.map((width) => line.repeat(width + 2))
|
|
202
|
-
.join(cross)}${right}`;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function renderRow(
|
|
206
|
-
row: string[],
|
|
207
|
-
isHeader: boolean,
|
|
208
|
-
align: Array<"left" | "center" | "right" | null | undefined>,
|
|
209
|
-
): string[] {
|
|
210
|
-
const cells = row.map((cell, index) =>
|
|
211
|
-
wrapText(cell, columnWidths[index]!),
|
|
212
|
-
);
|
|
213
|
-
const lineCount = Math.max(...cells.map((lines) => lines.length), 1);
|
|
214
|
-
const output: string[] = [];
|
|
215
|
-
for (let lineIndex = 0; lineIndex < lineCount; lineIndex += 1) {
|
|
216
|
-
let line = "│";
|
|
217
|
-
for (let columnIndex = 0; columnIndex < row.length; columnIndex += 1) {
|
|
218
|
-
const value = cells[columnIndex]?.[lineIndex] ?? "";
|
|
219
|
-
const cellAlign = isHeader ? "center" : align[columnIndex];
|
|
220
|
-
line += ` ${padAligned(value, columnWidths[columnIndex]!, cellAlign)} │`;
|
|
221
|
-
}
|
|
222
|
-
output.push(line);
|
|
223
|
-
}
|
|
224
|
-
return output;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const alignments = token.align ?? [];
|
|
228
|
-
const lines: string[] = [
|
|
229
|
-
border("top"),
|
|
230
|
-
...renderRow(header, true, alignments),
|
|
231
|
-
border("middle"),
|
|
232
|
-
];
|
|
233
|
-
rows.forEach((row, rowIndex) => {
|
|
234
|
-
lines.push(...renderRow(row, false, alignments));
|
|
235
|
-
if (rowIndex < rows.length - 1) {
|
|
236
|
-
lines.push(border("middle"));
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
lines.push(border("bottom"));
|
|
240
|
-
return { mode: "horizontal", lines };
|
|
241
|
-
}, [terminalWidth, token]);
|
|
242
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useMemo, useRef } from "react";
|
|
2
|
-
import { type Token } from "marked";
|
|
3
|
-
import { lexMarkdown, splitStreamingMarkdown } from "../lexer.ts";
|
|
4
|
-
|
|
5
|
-
export type MarkdownTokenPlan = {
|
|
6
|
-
fullTokens: Token[];
|
|
7
|
-
stablePrefix: string;
|
|
8
|
-
unstableSuffix: string;
|
|
9
|
-
stableTokens: Token[];
|
|
10
|
-
unstableTokens: Token[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function useMarkdownTokens(
|
|
14
|
-
content: string,
|
|
15
|
-
streaming: boolean,
|
|
16
|
-
): MarkdownTokenPlan {
|
|
17
|
-
const stablePrefixRef = useRef("");
|
|
18
|
-
const fullTokens = useMemo(() => lexMarkdown(content), [content]);
|
|
19
|
-
|
|
20
|
-
const streamSegments = streaming
|
|
21
|
-
? splitStreamingMarkdown(content, stablePrefixRef.current)
|
|
22
|
-
: { stablePrefix: "", unstableSuffix: "" };
|
|
23
|
-
|
|
24
|
-
const stableTokens = useMemo(
|
|
25
|
-
() => lexMarkdown(streamSegments.stablePrefix),
|
|
26
|
-
[streamSegments.stablePrefix],
|
|
27
|
-
);
|
|
28
|
-
const unstableTokens = useMemo(
|
|
29
|
-
() => lexMarkdown(streamSegments.unstableSuffix),
|
|
30
|
-
[streamSegments.unstableSuffix],
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
if (!streaming) {
|
|
34
|
-
stablePrefixRef.current = "";
|
|
35
|
-
} else {
|
|
36
|
-
stablePrefixRef.current = streamSegments.stablePrefix;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
fullTokens,
|
|
41
|
-
stablePrefix: streamSegments.stablePrefix,
|
|
42
|
-
unstableSuffix: streamSegments.unstableSuffix,
|
|
43
|
-
stableTokens,
|
|
44
|
-
unstableTokens,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { marked, type Token } from "marked";
|
|
2
|
-
|
|
3
|
-
const TOKEN_CACHE_MAX = 500;
|
|
4
|
-
const tokenCache = new Map<string, Token[]>();
|
|
5
|
-
let markedConfigured = false;
|
|
6
|
-
|
|
7
|
-
const MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
|
|
8
|
-
|
|
9
|
-
function hashContent(input: string): string {
|
|
10
|
-
let hash = 5381;
|
|
11
|
-
for (let index = 0; index < input.length; index += 1) {
|
|
12
|
-
hash = (hash * 33) ^ input.charCodeAt(index);
|
|
13
|
-
}
|
|
14
|
-
return (hash >>> 0).toString(36);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function hasMarkdownSyntax(value: string): boolean {
|
|
18
|
-
const sample = value.length > 500 ? value.slice(0, 500) : value;
|
|
19
|
-
return MD_SYNTAX_RE.test(sample);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function paragraphToken(value: string): Token[] {
|
|
23
|
-
return [
|
|
24
|
-
{
|
|
25
|
-
type: "paragraph",
|
|
26
|
-
raw: value,
|
|
27
|
-
text: value,
|
|
28
|
-
tokens: [
|
|
29
|
-
{
|
|
30
|
-
type: "text",
|
|
31
|
-
raw: value,
|
|
32
|
-
text: value,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
} as Token,
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function lexer(content: string): Token[] {
|
|
40
|
-
configureMarked();
|
|
41
|
-
if (!hasMarkdownSyntax(content)) {
|
|
42
|
-
return paragraphToken(content);
|
|
43
|
-
}
|
|
44
|
-
return marked.lexer(content);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function configureMarked(): void {
|
|
48
|
-
if (markedConfigured) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
markedConfigured = true;
|
|
52
|
-
marked.use({ gfm: true, breaks: false });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function lexMarkdown(content: string): Token[] {
|
|
56
|
-
const key = hashContent(content);
|
|
57
|
-
const hit = tokenCache.get(key);
|
|
58
|
-
if (hit) {
|
|
59
|
-
tokenCache.delete(key);
|
|
60
|
-
tokenCache.set(key, hit);
|
|
61
|
-
return hit;
|
|
62
|
-
}
|
|
63
|
-
const tokens = lexer(content);
|
|
64
|
-
if (tokenCache.size >= TOKEN_CACHE_MAX) {
|
|
65
|
-
const oldest = tokenCache.keys().next().value;
|
|
66
|
-
if (oldest !== undefined) {
|
|
67
|
-
tokenCache.delete(oldest);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
tokenCache.set(key, tokens);
|
|
71
|
-
return tokens;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function splitStreamingMarkdown(
|
|
75
|
-
content: string,
|
|
76
|
-
stablePrefix: string,
|
|
77
|
-
): { stablePrefix: string; unstableSuffix: string } {
|
|
78
|
-
configureMarked();
|
|
79
|
-
let currentStablePrefix = stablePrefix;
|
|
80
|
-
if (!content.startsWith(currentStablePrefix)) {
|
|
81
|
-
currentStablePrefix = "";
|
|
82
|
-
}
|
|
83
|
-
const boundary = currentStablePrefix.length;
|
|
84
|
-
const tokens = lexer(content.slice(boundary));
|
|
85
|
-
let lastContentIndex = tokens.length - 1;
|
|
86
|
-
while (lastContentIndex >= 0 && tokens[lastContentIndex]?.type === "space") {
|
|
87
|
-
lastContentIndex -= 1;
|
|
88
|
-
}
|
|
89
|
-
let advance = 0;
|
|
90
|
-
for (let index = 0; index < lastContentIndex; index += 1) {
|
|
91
|
-
advance += tokens[index]?.raw.length ?? 0;
|
|
92
|
-
}
|
|
93
|
-
if (advance > 0) {
|
|
94
|
-
currentStablePrefix = content.slice(0, boundary + advance);
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
stablePrefix: currentStablePrefix,
|
|
98
|
-
unstableSuffix: content.slice(currentStablePrefix.length),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
import { attachmentsPath } from "../../../core/utils/paths.ts";
|
|
7
|
-
|
|
8
|
-
const execFileAsync = promisify(execFile);
|
|
9
|
-
|
|
10
|
-
function appleScriptString(value: string): string {
|
|
11
|
-
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async function createClipboardImagePath(): Promise<string> {
|
|
15
|
-
const root = attachmentsPath();
|
|
16
|
-
await mkdir(root, { recursive: true });
|
|
17
|
-
return join(root, `${randomUUID()}-clipboard.png`);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function fileHasContent(path: string): Promise<boolean> {
|
|
21
|
-
try {
|
|
22
|
-
const data = await readFile(path);
|
|
23
|
-
return data.length > 0;
|
|
24
|
-
} catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function saveMacClipboardImage(): Promise<string | null> {
|
|
30
|
-
const outputPath = await createClipboardImagePath();
|
|
31
|
-
const outputPathLiteral = appleScriptString(outputPath);
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
await execFileAsync("osascript", [
|
|
35
|
-
"-e",
|
|
36
|
-
"set png_data to (the clipboard as «class PNGf»)",
|
|
37
|
-
"-e",
|
|
38
|
-
`set fp to open for access POSIX file ${outputPathLiteral} with write permission`,
|
|
39
|
-
"-e",
|
|
40
|
-
"set eof fp to 0",
|
|
41
|
-
"-e",
|
|
42
|
-
"write png_data to fp",
|
|
43
|
-
"-e",
|
|
44
|
-
"close access fp",
|
|
45
|
-
]);
|
|
46
|
-
return (await fileHasContent(outputPath)) ? outputPath : null;
|
|
47
|
-
} catch {
|
|
48
|
-
await unlink(outputPath).catch(() => undefined);
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function saveLinuxClipboardImage(): Promise<string | null> {
|
|
54
|
-
const outputPath = await createClipboardImagePath();
|
|
55
|
-
const candidates: Array<[string, string[]]> = [
|
|
56
|
-
["wl-paste", ["--type", "image/png"]],
|
|
57
|
-
["xclip", ["-selection", "clipboard", "-t", "image/png", "-o"]],
|
|
58
|
-
["xclip", ["-selection", "clipboard", "-t", "image/jpeg", "-o"]],
|
|
59
|
-
["xclip", ["-selection", "clipboard", "-t", "image/webp", "-o"]],
|
|
60
|
-
["xsel", ["--clipboard", "--output"]],
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
for (const [command, args] of candidates) {
|
|
64
|
-
try {
|
|
65
|
-
const { stdout } = await execFileAsync(command, args, {
|
|
66
|
-
encoding: "buffer",
|
|
67
|
-
maxBuffer: 20 * 1024 * 1024,
|
|
68
|
-
});
|
|
69
|
-
if (!Buffer.isBuffer(stdout) || stdout.length === 0) {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
await writeFile(outputPath, stdout);
|
|
73
|
-
return outputPath;
|
|
74
|
-
} catch {
|
|
75
|
-
// Try the next clipboard utility.
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
await unlink(outputPath).catch(() => undefined);
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function saveWindowsClipboardImage(): Promise<string | null> {
|
|
84
|
-
const outputPath = await createClipboardImagePath();
|
|
85
|
-
const escapedPath = outputPath.replace(/'/g, "''");
|
|
86
|
-
const script = [
|
|
87
|
-
"Add-Type -AssemblyName System.Windows.Forms",
|
|
88
|
-
"Add-Type -AssemblyName System.Drawing",
|
|
89
|
-
"$img = [System.Windows.Forms.Clipboard]::GetImage()",
|
|
90
|
-
"if ($null -eq $img) { exit 1 }",
|
|
91
|
-
`$img.Save('${escapedPath}', [System.Drawing.Imaging.ImageFormat]::Png)`,
|
|
92
|
-
].join("; ");
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
await execFileAsync("powershell.exe", [
|
|
96
|
-
"-NoProfile",
|
|
97
|
-
"-NonInteractive",
|
|
98
|
-
"-Command",
|
|
99
|
-
script,
|
|
100
|
-
]);
|
|
101
|
-
return (await fileHasContent(outputPath)) ? outputPath : null;
|
|
102
|
-
} catch {
|
|
103
|
-
await unlink(outputPath).catch(() => undefined);
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export async function saveClipboardImageAsAttachment(): Promise<string | null> {
|
|
109
|
-
switch (process.platform) {
|
|
110
|
-
case "darwin":
|
|
111
|
-
return saveMacClipboardImage();
|
|
112
|
-
case "linux":
|
|
113
|
-
return saveLinuxClipboardImage();
|
|
114
|
-
case "win32":
|
|
115
|
-
return saveWindowsClipboardImage();
|
|
116
|
-
default:
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
}
|