@adecore/agents-react 0.0.1 → 0.17.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +110 -0
- package/README.md +61 -0
- package/dist/agents/AccountDot.d.ts +4 -0
- package/dist/agents/AccountDot.js +8 -0
- package/dist/agents/AgentIcon.d.ts +6 -0
- package/dist/agents/AgentIcon.js +20 -0
- package/dist/agents/ModelOptionControl.d.ts +15 -0
- package/dist/agents/ModelOptionControl.js +33 -0
- package/dist/agents/ProviderLogo.d.ts +8 -0
- package/dist/agents/ProviderLogo.js +8 -0
- package/dist/agents/account-limits.d.ts +7 -0
- package/dist/agents/account-limits.js +40 -0
- package/dist/agents/accounts.d.ts +22 -0
- package/dist/agents/accounts.js +113 -0
- package/dist/agents/model-name.d.ts +12 -0
- package/dist/agents/model-name.js +56 -0
- package/dist/agents/model-options.d.ts +5 -0
- package/dist/agents/model-options.js +15 -0
- package/dist/agents/provider-paths.d.ts +2 -0
- package/dist/agents/provider-paths.js +8 -0
- package/dist/agents/status-look.d.ts +13 -0
- package/dist/agents/status-look.js +24 -0
- package/dist/chat/account-choice.d.ts +11 -0
- package/dist/chat/account-choice.js +30 -0
- package/dist/chat/actions.d.ts +6 -0
- package/dist/chat/actions.js +68 -0
- package/dist/chat/activity.d.ts +5 -0
- package/dist/chat/activity.js +6 -0
- package/dist/chat/attachments.d.ts +23 -0
- package/dist/chat/attachments.js +86 -0
- package/dist/chat/bookmarks.d.ts +14 -0
- package/dist/chat/bookmarks.js +73 -0
- package/dist/chat/chat-client.d.ts +55 -0
- package/dist/chat/chat-client.js +279 -0
- package/dist/chat/chat-references.d.ts +5 -0
- package/dist/chat/chat-references.js +5 -0
- package/dist/chat/drafts.d.ts +29 -0
- package/dist/chat/drafts.js +116 -0
- package/dist/chat/forks.d.ts +2 -0
- package/dist/chat/forks.js +28 -0
- package/dist/chat/guards.d.ts +12 -0
- package/dist/chat/guards.js +69 -0
- package/dist/chat/logic/ansi.d.ts +13 -0
- package/dist/chat/logic/ansi.js +185 -0
- package/dist/chat/logic/answers.d.ts +1 -0
- package/dist/chat/logic/answers.js +8 -0
- package/dist/chat/logic/bookmarks.d.ts +5 -0
- package/dist/chat/logic/bookmarks.js +33 -0
- package/dist/chat/logic/context-usage.d.ts +12 -0
- package/dist/chat/logic/context-usage.js +21 -0
- package/dist/chat/logic/fork.d.ts +45 -0
- package/dist/chat/logic/fork.js +148 -0
- package/dist/chat/logic/handback.d.ts +2 -0
- package/dist/chat/logic/handback.js +8 -0
- package/dist/chat/logic/json.d.ts +1 -0
- package/dist/chat/logic/json.js +4 -0
- package/dist/chat/logic/limit.d.ts +7 -0
- package/dist/chat/logic/limit.js +34 -0
- package/dist/chat/logic/resume-compaction.d.ts +14 -0
- package/dist/chat/logic/resume-compaction.js +47 -0
- package/dist/chat/logic/scrubber.d.ts +50 -0
- package/dist/chat/logic/scrubber.js +220 -0
- package/dist/chat/logic/thread-cards.d.ts +3 -0
- package/dist/chat/logic/thread-cards.js +59 -0
- package/dist/chat/logic/timeline-copy.d.ts +4 -0
- package/dist/chat/logic/timeline-copy.js +59 -0
- package/dist/chat/logic/timeline-target.d.ts +12 -0
- package/dist/chat/logic/timeline-target.js +34 -0
- package/dist/chat/logic/timeline.d.ts +115 -0
- package/dist/chat/logic/timeline.js +343 -0
- package/dist/chat/logic/tool-catalog.d.ts +10 -0
- package/dist/chat/logic/tool-catalog.js +44 -0
- package/dist/chat/logic/tools.d.ts +15 -0
- package/dist/chat/logic/tools.js +82 -0
- package/dist/chat/logic/welcome.d.ts +2 -0
- package/dist/chat/logic/welcome.js +10 -0
- package/dist/chat/logic/workflow.d.ts +14 -0
- package/dist/chat/logic/workflow.js +47 -0
- package/dist/chat/mentions.d.ts +65 -0
- package/dist/chat/mentions.js +184 -0
- package/dist/chat/persisted-json.d.ts +5 -0
- package/dist/chat/persisted-json.js +58 -0
- package/dist/chat/preferences.d.ts +27 -0
- package/dist/chat/preferences.js +139 -0
- package/dist/chat/quote.d.ts +2 -0
- package/dist/chat/quote.js +25 -0
- package/dist/chat/recent-messages.d.ts +17 -0
- package/dist/chat/recent-messages.js +36 -0
- package/dist/chat/resume-compaction-dismissals.d.ts +3 -0
- package/dist/chat/resume-compaction-dismissals.js +14 -0
- package/dist/chat/runtime-modes.d.ts +4 -0
- package/dist/chat/runtime-modes.js +15 -0
- package/dist/chat/stash.d.ts +24 -0
- package/dist/chat/stash.js +91 -0
- package/dist/chat/subagent-conversation.d.ts +41 -0
- package/dist/chat/subagent-conversation.js +167 -0
- package/dist/chat/subagent-list.d.ts +19 -0
- package/dist/chat/subagent-list.js +106 -0
- package/dist/chat/subagent-support.d.ts +6 -0
- package/dist/chat/subagent-support.js +14 -0
- package/dist/chat/subagent-view.d.ts +35 -0
- package/dist/chat/subagent-view.js +96 -0
- package/dist/chat/thumbnails.d.ts +10 -0
- package/dist/chat/thumbnails.js +89 -0
- package/dist/chat/timeline-flash.d.ts +12 -0
- package/dist/chat/timeline-flash.js +16 -0
- package/dist/chat/timeline-scroll.d.ts +27 -0
- package/dist/chat/timeline-scroll.js +152 -0
- package/dist/chat/ui/AccountPill.d.ts +3 -0
- package/dist/chat/ui/AccountPill.js +23 -0
- package/dist/chat/ui/AnsiOutput.d.ts +5 -0
- package/dist/chat/ui/AnsiOutput.js +9 -0
- package/dist/chat/ui/BookmarkMarker.d.ts +8 -0
- package/dist/chat/ui/BookmarkMarker.js +57 -0
- package/dist/chat/ui/BookmarkSubmenu.d.ts +3 -0
- package/dist/chat/ui/BookmarkSubmenu.js +33 -0
- package/dist/chat/ui/ChatActivity.d.ts +7 -0
- package/dist/chat/ui/ChatActivity.js +84 -0
- package/dist/chat/ui/ChatReferenceChip.d.ts +4 -0
- package/dist/chat/ui/ChatReferenceChip.js +16 -0
- package/dist/chat/ui/CodeBlock.d.ts +4 -0
- package/dist/chat/ui/CodeBlock.js +132 -0
- package/dist/chat/ui/Composer.d.ts +15 -0
- package/dist/chat/ui/Composer.js +856 -0
- package/dist/chat/ui/ComposerInput.d.ts +29 -0
- package/dist/chat/ui/ComposerInput.js +127 -0
- package/dist/chat/ui/DiffPool.d.ts +5 -0
- package/dist/chat/ui/DiffPool.js +26 -0
- package/dist/chat/ui/EditDiff.d.ts +4 -0
- package/dist/chat/ui/EditDiff.js +21 -0
- package/dist/chat/ui/FadingWords.d.ts +3 -0
- package/dist/chat/ui/FadingWords.js +5 -0
- package/dist/chat/ui/ImageView.d.ts +6 -0
- package/dist/chat/ui/ImageView.js +81 -0
- package/dist/chat/ui/LimitState.d.ts +8 -0
- package/dist/chat/ui/LimitState.js +112 -0
- package/dist/chat/ui/Markdown.d.ts +18 -0
- package/dist/chat/ui/Markdown.js +159 -0
- package/dist/chat/ui/MessageActions.d.ts +9 -0
- package/dist/chat/ui/MessageActions.js +53 -0
- package/dist/chat/ui/Pickers.d.ts +21 -0
- package/dist/chat/ui/Pickers.js +111 -0
- package/dist/chat/ui/PromptComposer.d.ts +13 -0
- package/dist/chat/ui/PromptComposer.js +56 -0
- package/dist/chat/ui/QuoteButton.d.ts +7 -0
- package/dist/chat/ui/QuoteButton.js +74 -0
- package/dist/chat/ui/ResumeCompactionDock.d.ts +5 -0
- package/dist/chat/ui/ResumeCompactionDock.js +14 -0
- package/dist/chat/ui/RunSettings.d.ts +28 -0
- package/dist/chat/ui/RunSettings.js +153 -0
- package/dist/chat/ui/Scrubber.d.ts +17 -0
- package/dist/chat/ui/Scrubber.js +118 -0
- package/dist/chat/ui/SubagentControls.d.ts +11 -0
- package/dist/chat/ui/SubagentControls.js +36 -0
- package/dist/chat/ui/SubagentInfo.d.ts +4 -0
- package/dist/chat/ui/SubagentInfo.js +34 -0
- package/dist/chat/ui/SubagentStopButton.d.ts +7 -0
- package/dist/chat/ui/SubagentStopButton.js +34 -0
- package/dist/chat/ui/SubagentTimeline.d.ts +4 -0
- package/dist/chat/ui/SubagentTimeline.js +107 -0
- package/dist/chat/ui/Timeline.d.ts +6 -0
- package/dist/chat/ui/Timeline.js +424 -0
- package/dist/chat/ui/TimelineMenu.d.ts +12 -0
- package/dist/chat/ui/TimelineMenu.js +54 -0
- package/dist/chat/ui/UnifiedDiff.d.ts +11 -0
- package/dist/chat/ui/UnifiedDiff.js +66 -0
- package/dist/chat/ui/UploadThumb.d.ts +4 -0
- package/dist/chat/ui/UploadThumb.js +11 -0
- package/dist/chat/ui/Welcome.d.ts +4 -0
- package/dist/chat/ui/Welcome.js +16 -0
- package/dist/chat/ui/chips.d.ts +4 -0
- package/dist/chat/ui/chips.js +11 -0
- package/dist/chat/ui/code-lines.d.ts +18 -0
- package/dist/chat/ui/code-lines.js +46 -0
- package/dist/chat/ui/code-streaming.d.ts +1 -0
- package/dist/chat/ui/code-streaming.js +3 -0
- package/dist/chat/ui/code-theme.d.ts +3 -0
- package/dist/chat/ui/code-theme.js +12 -0
- package/dist/chat/ui/composer/chips.d.ts +6 -0
- package/dist/chat/ui/composer/chips.js +31 -0
- package/dist/chat/ui/composer/editor.d.ts +11 -0
- package/dist/chat/ui/composer/editor.js +98 -0
- package/dist/chat/ui/composer/insert.d.ts +2 -0
- package/dist/chat/ui/composer/insert.js +19 -0
- package/dist/chat/ui/composer/keys.d.ts +30 -0
- package/dist/chat/ui/composer/keys.js +100 -0
- package/dist/chat/ui/diff-theme.d.ts +2 -0
- package/dist/chat/ui/diff-theme.js +20 -0
- package/dist/chat/ui/file-links.d.ts +5 -0
- package/dist/chat/ui/file-links.js +20 -0
- package/dist/chat/ui/find-reveal.d.ts +7 -0
- package/dist/chat/ui/find-reveal.js +13 -0
- package/dist/chat/ui/full-diff.d.ts +6 -0
- package/dist/chat/ui/full-diff.js +19 -0
- package/dist/chat/ui/icons.d.ts +4 -0
- package/dist/chat/ui/icons.js +20 -0
- package/dist/chat/ui/markdown-blocks.d.ts +6 -0
- package/dist/chat/ui/markdown-blocks.js +103 -0
- package/dist/chat/ui/quote-selection.d.ts +3 -0
- package/dist/chat/ui/quote-selection.js +46 -0
- package/dist/chat/ui/rehype-chips.d.ts +23 -0
- package/dist/chat/ui/rehype-chips.js +32 -0
- package/dist/chat/ui/rehype-fade.d.ts +23 -0
- package/dist/chat/ui/rehype-fade.js +36 -0
- package/dist/chat/ui/remark-html-as-text.d.ts +8 -0
- package/dist/chat/ui/remark-html-as-text.js +26 -0
- package/dist/chat/ui/reply-context.d.ts +5 -0
- package/dist/chat/ui/reply-context.js +2 -0
- package/dist/chat/ui/reveal.d.ts +13 -0
- package/dist/chat/ui/reveal.js +114 -0
- package/dist/chat/ui/rows/ForksRow.d.ts +4 -0
- package/dist/chat/ui/rows/ForksRow.js +38 -0
- package/dist/chat/ui/rows/MessageRows.d.ts +40 -0
- package/dist/chat/ui/rows/MessageRows.js +204 -0
- package/dist/chat/ui/rows/Rows.d.ts +12 -0
- package/dist/chat/ui/rows/Rows.js +61 -0
- package/dist/chat/ui/rows/SubagentRow.d.ts +17 -0
- package/dist/chat/ui/rows/SubagentRow.js +101 -0
- package/dist/chat/ui/rows/TaskRow.d.ts +8 -0
- package/dist/chat/ui/rows/TaskRow.js +63 -0
- package/dist/chat/ui/rows/WorkRows.d.ts +47 -0
- package/dist/chat/ui/rows/WorkRows.js +168 -0
- package/dist/chat/ui/rows/WorkflowRow.d.ts +8 -0
- package/dist/chat/ui/rows/WorkflowRow.js +48 -0
- package/dist/chat/ui/rows/row-rhythm.d.ts +6 -0
- package/dist/chat/ui/rows/row-rhythm.js +34 -0
- package/dist/chat/ui/useToggleSet.d.ts +6 -0
- package/dist/chat/ui/useToggleSet.js +25 -0
- package/dist/host.d.ts +195 -0
- package/dist/host.js +55 -0
- package/dist/lazy.d.ts +6 -0
- package/dist/lazy.js +57 -0
- package/dist/locales/en/agent-chat.json +446 -0
- package/dist/locales/en/agent-prompts.json +42 -0
- package/dist/locales/en/agent-providers.json +131 -0
- package/dist/locales/en/agent-usage.json +131 -0
- package/dist/locales/nl/agent-chat.json +446 -0
- package/dist/locales/nl/agent-prompts.json +42 -0
- package/dist/locales/nl/agent-providers.json +131 -0
- package/dist/locales/nl/agent-usage.json +131 -0
- package/dist/locales.d.ts +5 -0
- package/dist/locales.js +20 -0
- package/dist/mounted-registry.d.ts +7 -0
- package/dist/mounted-registry.js +39 -0
- package/dist/port-transport.d.ts +6 -0
- package/dist/port-transport.js +129 -0
- package/dist/prompts/logic/focus.d.ts +2 -0
- package/dist/prompts/logic/focus.js +23 -0
- package/dist/prompts/logic/keys.d.ts +42 -0
- package/dist/prompts/logic/keys.js +94 -0
- package/dist/prompts/logic/prompts.d.ts +34 -0
- package/dist/prompts/logic/prompts.fixtures.d.ts +5 -0
- package/dist/prompts/logic/prompts.fixtures.js +79 -0
- package/dist/prompts/logic/prompts.js +32 -0
- package/dist/prompts/logic/subjects.d.ts +50 -0
- package/dist/prompts/logic/subjects.js +63 -0
- package/dist/prompts/logic/useFocusAfterAnswer.d.ts +6 -0
- package/dist/prompts/logic/useFocusAfterAnswer.js +28 -0
- package/dist/prompts/logic/usePromptSession.d.ts +24 -0
- package/dist/prompts/logic/usePromptSession.js +87 -0
- package/dist/prompts/ui/ApprovalBody.d.ts +13 -0
- package/dist/prompts/ui/ApprovalBody.js +34 -0
- package/dist/prompts/ui/PromptActions.d.ts +27 -0
- package/dist/prompts/ui/PromptActions.js +18 -0
- package/dist/prompts/ui/PromptCard.d.ts +16 -0
- package/dist/prompts/ui/PromptCard.js +50 -0
- package/dist/prompts/ui/PromptView.d.ts +2 -0
- package/dist/prompts/ui/PromptView.js +47 -0
- package/dist/prompts/ui/QuestionBody.d.ts +9 -0
- package/dist/prompts/ui/QuestionBody.js +87 -0
- package/dist/providers/AccountColors.d.ts +5 -0
- package/dist/providers/AccountColors.js +8 -0
- package/dist/providers/AccountDetail.d.ts +12 -0
- package/dist/providers/AccountDetail.js +69 -0
- package/dist/providers/AccountVariables.d.ts +8 -0
- package/dist/providers/AccountVariables.js +43 -0
- package/dist/providers/AddAccountForm.d.ts +10 -0
- package/dist/providers/AddAccountForm.js +54 -0
- package/dist/providers/CliDetail.d.ts +12 -0
- package/dist/providers/CliDetail.js +54 -0
- package/dist/providers/ProvidersPane.d.ts +9 -0
- package/dist/providers/ProvidersPane.js +86 -0
- package/dist/providers/account-actions.d.ts +7 -0
- package/dist/providers/account-actions.js +57 -0
- package/dist/providers/parts.d.ts +9 -0
- package/dist/providers/parts.js +18 -0
- package/dist/providers/provider-abilities.d.ts +2 -0
- package/dist/providers/provider-abilities.js +7 -0
- package/dist/providers/variables.d.ts +13 -0
- package/dist/providers/variables.js +63 -0
- package/dist/scope.d.ts +11 -0
- package/dist/scope.js +10 -0
- package/dist/settings/sections.d.ts +13 -0
- package/dist/settings/sections.js +32 -0
- package/dist/state/chats.d.ts +44 -0
- package/dist/state/chats.js +199 -0
- package/dist/state/provider-accounts.d.ts +17 -0
- package/dist/state/provider-accounts.js +67 -0
- package/dist/state/providers.d.ts +17 -0
- package/dist/state/providers.js +33 -0
- package/dist/state/usage.d.ts +44 -0
- package/dist/state/usage.js +121 -0
- package/dist/storage.d.ts +20 -0
- package/dist/storage.js +89 -0
- package/dist/theme.css +212 -0
- package/dist/transport.d.ts +24 -0
- package/dist/transport.js +18 -0
- package/dist/ui/PlainTextarea.d.ts +2 -0
- package/dist/ui/PlainTextarea.js +5 -0
- package/dist/usage/LimitsList.d.ts +18 -0
- package/dist/usage/LimitsList.js +73 -0
- package/dist/usage/UsageBreakdown.d.ts +9 -0
- package/dist/usage/UsageBreakdown.js +67 -0
- package/dist/usage/UsageChart.d.ts +10 -0
- package/dist/usage/UsageChart.js +47 -0
- package/dist/usage/UsageDialog.d.ts +6 -0
- package/dist/usage/UsageDialog.js +12 -0
- package/dist/usage/UsageLimits.d.ts +1 -0
- package/dist/usage/UsageLimits.js +57 -0
- package/dist/usage/UsageLimitsCard.d.ts +4 -0
- package/dist/usage/UsageLimitsCard.js +26 -0
- package/dist/usage/UsagePage.d.ts +7 -0
- package/dist/usage/UsagePage.js +154 -0
- package/dist/usage/UsagePane.d.ts +3 -0
- package/dist/usage/UsagePane.js +21 -0
- package/dist/usage/UsageSummary.d.ts +12 -0
- package/dist/usage/UsageSummary.js +15 -0
- package/dist/usage/UsageTiles.d.ts +7 -0
- package/dist/usage/UsageTiles.js +19 -0
- package/dist/usage/format.d.ts +13 -0
- package/dist/usage/format.js +55 -0
- package/dist/usage/limit-groups.d.ts +22 -0
- package/dist/usage/limit-groups.js +86 -0
- package/dist/usage/limits.d.ts +4 -0
- package/dist/usage/limits.js +58 -0
- package/dist/usage/money.d.ts +1 -0
- package/dist/usage/money.js +13 -0
- package/dist/usage/summary.d.ts +34 -0
- package/dist/usage/summary.js +94 -0
- package/package.json +895 -3
- package/src/agents/AccountDot.tsx +14 -0
- package/src/agents/AgentIcon.tsx +26 -0
- package/src/agents/ModelOptionControl.tsx +68 -0
- package/src/agents/ProviderLogo.tsx +20 -0
- package/src/agents/account-limits.ts +61 -0
- package/src/agents/accounts.ts +137 -0
- package/src/agents/model-name.ts +70 -0
- package/src/agents/model-options.ts +21 -0
- package/src/agents/provider-paths.ts +10 -0
- package/src/agents/status-look.ts +43 -0
- package/src/chat/account-choice.ts +44 -0
- package/src/chat/actions.ts +72 -0
- package/src/chat/activity.ts +8 -0
- package/src/chat/attachments.ts +118 -0
- package/src/chat/bookmarks.ts +87 -0
- package/src/chat/chat-client.ts +345 -0
- package/src/chat/chat-references.ts +11 -0
- package/src/chat/drafts.ts +165 -0
- package/src/chat/forks.ts +33 -0
- package/src/chat/guards.ts +84 -0
- package/src/chat/logic/ansi.ts +206 -0
- package/src/chat/logic/answers.ts +8 -0
- package/src/chat/logic/bookmarks.ts +42 -0
- package/src/chat/logic/context-usage.ts +36 -0
- package/src/chat/logic/fork.ts +200 -0
- package/src/chat/logic/handback.ts +10 -0
- package/src/chat/logic/json.ts +4 -0
- package/src/chat/logic/limit.ts +46 -0
- package/src/chat/logic/resume-compaction.ts +71 -0
- package/src/chat/logic/scrubber.ts +289 -0
- package/src/chat/logic/thread-cards.ts +64 -0
- package/src/chat/logic/timeline-copy.ts +65 -0
- package/src/chat/logic/timeline-target.ts +52 -0
- package/src/chat/logic/timeline.ts +419 -0
- package/src/chat/logic/tool-catalog.ts +62 -0
- package/src/chat/logic/tools.ts +102 -0
- package/src/chat/logic/welcome.ts +13 -0
- package/src/chat/logic/workflow.ts +66 -0
- package/src/chat/mentions.ts +232 -0
- package/src/chat/persisted-json.ts +67 -0
- package/src/chat/preferences.ts +179 -0
- package/src/chat/quote.ts +26 -0
- package/src/chat/recent-messages.ts +59 -0
- package/src/chat/resume-compaction-dismissals.ts +17 -0
- package/src/chat/runtime-modes.ts +18 -0
- package/src/chat/stash.ts +122 -0
- package/src/chat/subagent-conversation.ts +203 -0
- package/src/chat/subagent-list.ts +141 -0
- package/src/chat/subagent-support.ts +21 -0
- package/src/chat/subagent-view.ts +137 -0
- package/src/chat/thumbnails.ts +108 -0
- package/src/chat/timeline-flash.ts +33 -0
- package/src/chat/timeline-scroll.ts +199 -0
- package/src/chat/ui/AccountPill.tsx +31 -0
- package/src/chat/ui/AnsiOutput.tsx +18 -0
- package/src/chat/ui/BookmarkMarker.tsx +108 -0
- package/src/chat/ui/BookmarkSubmenu.tsx +53 -0
- package/src/chat/ui/ChatActivity.tsx +198 -0
- package/src/chat/ui/ChatReferenceChip.tsx +28 -0
- package/src/chat/ui/CodeBlock.tsx +175 -0
- package/src/chat/ui/Composer.tsx +1326 -0
- package/src/chat/ui/ComposerInput.tsx +187 -0
- package/src/chat/ui/DiffPool.tsx +36 -0
- package/src/chat/ui/EditDiff.tsx +30 -0
- package/src/chat/ui/FadingWords.tsx +18 -0
- package/src/chat/ui/ImageView.tsx +159 -0
- package/src/chat/ui/LimitState.tsx +165 -0
- package/src/chat/ui/Markdown.tsx +258 -0
- package/src/chat/ui/MessageActions.tsx +88 -0
- package/src/chat/ui/Pickers.tsx +272 -0
- package/src/chat/ui/PromptComposer.tsx +119 -0
- package/src/chat/ui/QuoteButton.tsx +103 -0
- package/src/chat/ui/ResumeCompactionDock.tsx +28 -0
- package/src/chat/ui/RunSettings.tsx +546 -0
- package/src/chat/ui/Scrubber.tsx +262 -0
- package/src/chat/ui/SubagentControls.tsx +66 -0
- package/src/chat/ui/SubagentInfo.tsx +67 -0
- package/src/chat/ui/SubagentStopButton.tsx +45 -0
- package/src/chat/ui/SubagentTimeline.tsx +170 -0
- package/src/chat/ui/Timeline.tsx +628 -0
- package/src/chat/ui/TimelineMenu.tsx +124 -0
- package/src/chat/ui/UnifiedDiff.tsx +99 -0
- package/src/chat/ui/UploadThumb.tsx +13 -0
- package/src/chat/ui/Welcome.tsx +22 -0
- package/src/chat/ui/chips.ts +15 -0
- package/src/chat/ui/code-lines.ts +60 -0
- package/src/chat/ui/code-streaming.ts +4 -0
- package/src/chat/ui/code-theme.ts +15 -0
- package/src/chat/ui/composer/chips.ts +43 -0
- package/src/chat/ui/composer/editor.ts +118 -0
- package/src/chat/ui/composer/insert.ts +22 -0
- package/src/chat/ui/composer/keys.ts +144 -0
- package/src/chat/ui/diff-theme.ts +23 -0
- package/src/chat/ui/file-links.ts +24 -0
- package/src/chat/ui/find-reveal.ts +23 -0
- package/src/chat/ui/full-diff.ts +25 -0
- package/src/chat/ui/icons.tsx +24 -0
- package/src/chat/ui/markdown-blocks.ts +123 -0
- package/src/chat/ui/quote-selection.ts +53 -0
- package/src/chat/ui/rehype-chips.ts +62 -0
- package/src/chat/ui/rehype-fade.ts +64 -0
- package/src/chat/ui/remark-html-as-text.ts +36 -0
- package/src/chat/ui/reply-context.ts +4 -0
- package/src/chat/ui/reveal.ts +135 -0
- package/src/chat/ui/rows/ForksRow.tsx +79 -0
- package/src/chat/ui/rows/MessageRows.tsx +415 -0
- package/src/chat/ui/rows/Rows.tsx +81 -0
- package/src/chat/ui/rows/SubagentRow.tsx +209 -0
- package/src/chat/ui/rows/TaskRow.tsx +91 -0
- package/src/chat/ui/rows/WorkRows.tsx +445 -0
- package/src/chat/ui/rows/WorkflowRow.tsx +120 -0
- package/src/chat/ui/rows/row-rhythm.ts +37 -0
- package/src/chat/ui/useToggleSet.ts +39 -0
- package/src/host.ts +324 -0
- package/src/lazy.tsx +64 -0
- package/src/locales/en/agent-chat.json +446 -0
- package/src/locales/en/agent-prompts.json +42 -0
- package/src/locales/en/agent-providers.json +131 -0
- package/src/locales/en/agent-usage.json +131 -0
- package/src/locales/nl/agent-chat.json +446 -0
- package/src/locales/nl/agent-prompts.json +42 -0
- package/src/locales/nl/agent-providers.json +131 -0
- package/src/locales/nl/agent-usage.json +131 -0
- package/src/locales.ts +33 -0
- package/src/mounted-registry.ts +45 -0
- package/src/port-transport.ts +146 -0
- package/src/prompts/logic/focus.ts +25 -0
- package/src/prompts/logic/keys.ts +116 -0
- package/src/prompts/logic/prompts.fixtures.ts +84 -0
- package/src/prompts/logic/prompts.ts +58 -0
- package/src/prompts/logic/subjects.ts +122 -0
- package/src/prompts/logic/useFocusAfterAnswer.ts +38 -0
- package/src/prompts/logic/usePromptSession.ts +114 -0
- package/src/prompts/ui/ApprovalBody.tsx +109 -0
- package/src/prompts/ui/PromptActions.tsx +109 -0
- package/src/prompts/ui/PromptCard.tsx +101 -0
- package/src/prompts/ui/PromptView.tsx +111 -0
- package/src/prompts/ui/QuestionBody.tsx +174 -0
- package/src/providers/AccountColors.tsx +8 -0
- package/src/providers/AccountDetail.tsx +209 -0
- package/src/providers/AccountVariables.tsx +126 -0
- package/src/providers/AddAccountForm.tsx +121 -0
- package/src/providers/CliDetail.tsx +157 -0
- package/src/providers/ProvidersPane.tsx +236 -0
- package/src/providers/account-actions.ts +67 -0
- package/src/providers/parts.tsx +25 -0
- package/src/providers/provider-abilities.ts +9 -0
- package/src/providers/variables.ts +87 -0
- package/src/scope.ts +30 -0
- package/src/settings/sections.ts +47 -0
- package/src/state/chats.ts +279 -0
- package/src/state/provider-accounts.ts +87 -0
- package/src/state/providers.ts +50 -0
- package/src/state/usage.ts +196 -0
- package/src/storage.ts +113 -0
- package/src/theme.css +212 -0
- package/src/transport.ts +50 -0
- package/src/ui/PlainTextarea.tsx +6 -0
- package/src/usage/LimitsList.tsx +232 -0
- package/src/usage/UsageBreakdown.tsx +210 -0
- package/src/usage/UsageChart.tsx +113 -0
- package/src/usage/UsageDialog.tsx +20 -0
- package/src/usage/UsageLimits.tsx +145 -0
- package/src/usage/UsageLimitsCard.tsx +36 -0
- package/src/usage/UsagePage.tsx +276 -0
- package/src/usage/UsagePane.tsx +52 -0
- package/src/usage/UsageSummary.tsx +50 -0
- package/src/usage/UsageTiles.tsx +34 -0
- package/src/usage/format.ts +71 -0
- package/src/usage/limit-groups.ts +119 -0
- package/src/usage/limits.ts +71 -0
- package/src/usage/money.ts +14 -0
- package/src/usage/summary.ts +137 -0
package/src/host.ts
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import type { ComponentProps, ComponentType, ReactNode, RefObject } from 'react';
|
|
2
|
+
import type { Extension } from '@codemirror/state';
|
|
3
|
+
import type { EditorView } from '@codemirror/view';
|
|
4
|
+
import type { ThemeRegistration } from 'shiki';
|
|
5
|
+
import type { AgentKind, ChatCheckpointDiff, ChatConfigurePayload, ChatItem, ChatSubagentItem } from '@adecore/agent-contracts';
|
|
6
|
+
import { isApplePlatform } from '@adecore/ui';
|
|
7
|
+
import type { TimelineRow } from './chat/logic/timeline';
|
|
8
|
+
import type { FindReveal } from './chat/ui/find-reveal';
|
|
9
|
+
import type { PromptAction } from './prompts/logic/prompts';
|
|
10
|
+
import type { HostPrompt, PromptViewProps } from './prompts/logic/subjects';
|
|
11
|
+
import { PlainTextarea } from './ui/PlainTextarea';
|
|
12
|
+
import { configureChatStorage, type ChatStorageOptions } from './storage';
|
|
13
|
+
|
|
14
|
+
/* A color an account may wear, by the name the host stores it under. */
|
|
15
|
+
export interface AccentChoice {
|
|
16
|
+
id: string;
|
|
17
|
+
color: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ChatToast {
|
|
21
|
+
/* A toast with the same id replaces the one that is up. */
|
|
22
|
+
id?: string;
|
|
23
|
+
title: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
/* `deleted` says something went that the action can bring back. */
|
|
26
|
+
kind: 'success' | 'error' | 'deleted';
|
|
27
|
+
action?: { label: string; run(): void };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* What a person does to a chat from its own surfaces. Without an app's own set, each one is the request
|
|
32
|
+
* a chat host answers; an app that runs every action through one door (confirmations, voice, an
|
|
33
|
+
* activity log) hands its own. A refusal throws something with a `code`.
|
|
34
|
+
*/
|
|
35
|
+
export interface ChatActions {
|
|
36
|
+
clear(chatId: string, force: boolean): Promise<void>;
|
|
37
|
+
/* With `subagents`, also ends the agents this chat opened. */
|
|
38
|
+
stopTurn(chatId: string, subagents: boolean): Promise<void>;
|
|
39
|
+
/* Refused with `request-not-found` when the message already went out. */
|
|
40
|
+
unqueue(chatId: string, messageId: string): Promise<void>;
|
|
41
|
+
sendNow(chatId: string, messageId: string): Promise<void>;
|
|
42
|
+
compact(chatId: string): Promise<void>;
|
|
43
|
+
configure(chatId: string, patch: Omit<ChatConfigurePayload, 'chatId'>): Promise<void>;
|
|
44
|
+
continueOn(chatId: string, account: string): Promise<void>;
|
|
45
|
+
/* Null when the turn has no checkpoint to compare against. */
|
|
46
|
+
turnDiff(chatId: string, turnId: string): Promise<ChatCheckpointDiff | null>;
|
|
47
|
+
stopSubagent(chatId: string, toolUseId: string): Promise<void>;
|
|
48
|
+
stopTask(chatId: string, taskId: string): Promise<void>;
|
|
49
|
+
approve(chatId: string, requestId: string, decision: 'allow' | 'allow-always' | 'deny', message?: string): Promise<void>;
|
|
50
|
+
answer(chatId: string, requestId: string, answers: Record<string, string>): Promise<void>;
|
|
51
|
+
dismiss(chatId: string, itemId: string): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* A path an answer names, as it was written: absolute, or relative to the folder the chat works in. */
|
|
55
|
+
export interface FileRef {
|
|
56
|
+
path: string;
|
|
57
|
+
/* One-based, when the reference named a line. */
|
|
58
|
+
line?: number;
|
|
59
|
+
/* A trailing separator is the only thing that says a reference means a directory. */
|
|
60
|
+
directory: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Where another chat stands and how to get there; a null title is a chat that is gone. */
|
|
64
|
+
export interface ChatPlace {
|
|
65
|
+
title: string | null;
|
|
66
|
+
go(): void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* The task behind a sub-agent row an app opened with a task of its own (`origin` that is not the CLI's). */
|
|
70
|
+
export interface SubagentTask {
|
|
71
|
+
status: 'open' | 'done' | 'failed' | 'cancelled';
|
|
72
|
+
createdAt: number;
|
|
73
|
+
settledAt: number | null;
|
|
74
|
+
/* Set while the child waits out a limit, with when it lifts. */
|
|
75
|
+
paused?: { until?: number };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* What a find in a thread needs of it, and what it hands back to draw. */
|
|
79
|
+
export interface TimelineFindOptions {
|
|
80
|
+
chatId: string;
|
|
81
|
+
/* What the find key looks for, and what the bar stands in. */
|
|
82
|
+
frame: RefObject<HTMLDivElement | null>;
|
|
83
|
+
/* Where the rows are drawn, which is what gets marked. */
|
|
84
|
+
thread: RefObject<HTMLDivElement | null>;
|
|
85
|
+
scroller: RefObject<HTMLDivElement | null>;
|
|
86
|
+
enabled: boolean;
|
|
87
|
+
rows: readonly TimelineRow[];
|
|
88
|
+
structure: Readonly<Record<string, ChatItem>> | undefined;
|
|
89
|
+
order: readonly string[] | undefined;
|
|
90
|
+
/* The first row on screen, where a new search starts looking. */
|
|
91
|
+
firstRowInView(): number;
|
|
92
|
+
openTurn(turnId: string): void;
|
|
93
|
+
openGroup(id: string): void;
|
|
94
|
+
openSubagent(id: string): void;
|
|
95
|
+
scrollToRow(index: number): void;
|
|
96
|
+
/* The height of the composer standing over the end of the scroller. */
|
|
97
|
+
coveredHeight(): number;
|
|
98
|
+
stopFollowing(): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface TimelineFind {
|
|
102
|
+
open: boolean;
|
|
103
|
+
/* Drawn over the thread while the find is open. */
|
|
104
|
+
bar: ReactNode;
|
|
105
|
+
reveal: FindReveal | null;
|
|
106
|
+
/* The row each hit is shown at, in the order of the hits. */
|
|
107
|
+
hitRows: readonly number[];
|
|
108
|
+
currentRow: number | null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* The dictation control beside the composer's editor; it takes its text from the editor itself. */
|
|
112
|
+
export interface ComposerDictationProps {
|
|
113
|
+
targetRef: RefObject<HTMLElement | null>;
|
|
114
|
+
/* Where the button goes, in the composer's row of round controls. */
|
|
115
|
+
buttonContainer: HTMLElement | null | undefined;
|
|
116
|
+
disabled: boolean;
|
|
117
|
+
editor(): EditorView | null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type TextareaProps = ComponentProps<'textarea'> & {
|
|
121
|
+
/* Where a button beside the field sits, such as a negative margin so it does not make a one-line row taller. */
|
|
122
|
+
buttonClassName?: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/* An attached file's bytes, as a URL an image or a link can use; `failure` says why there is none. */
|
|
126
|
+
export interface ResourceUrl {
|
|
127
|
+
url: string | null;
|
|
128
|
+
failure: string | null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* What an app's own control in the composer's row gets. */
|
|
132
|
+
export interface ComposerSlotProps {
|
|
133
|
+
scopeId: string;
|
|
134
|
+
chatId: string;
|
|
135
|
+
disabled: boolean;
|
|
136
|
+
/* Puts text in the draft at the caret, a space apart from the words beside it, and gives the editor the focus. */
|
|
137
|
+
insert(text: string): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* What an app's own chips for a chat's sub-agents get, in place of the one flyout over the composer. */
|
|
141
|
+
export interface SubagentSlotProps {
|
|
142
|
+
chatId: string;
|
|
143
|
+
/* Never empty: without rows the slot is not drawn. */
|
|
144
|
+
items: readonly ChatSubagentItem[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* A card of the app's own between the messages of a thread. */
|
|
148
|
+
export interface ThreadCard {
|
|
149
|
+
/* Unique within the chat; the thread keys its row by it, so the same card keeps its place and its measure. */
|
|
150
|
+
id: string;
|
|
151
|
+
/* When it happened, in milliseconds on the clock of a chat item's `createdAt`: it follows every row from before then. */
|
|
152
|
+
at: number;
|
|
153
|
+
/* Called only while the card is on screen, since the thread draws only the rows in view. */
|
|
154
|
+
render(): ReactNode;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Who writes a chat's replies, as the header over each one names them. */
|
|
158
|
+
export interface ReplyAuthor {
|
|
159
|
+
name: string;
|
|
160
|
+
/* Drawn before the name, such as an avatar. */
|
|
161
|
+
mark?: ReactNode;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/*
|
|
165
|
+
* What the app around the chat decides and the chat cannot. Set once, before the first render, with
|
|
166
|
+
* `setChatHost`; whatever an app leaves out keeps the default here, which is the chat without that
|
|
167
|
+
* part. The same in every scope, so a function that is about one host of chats is told its scope id.
|
|
168
|
+
* The hooks are called as hooks: an app hands the same function for the life of the page.
|
|
169
|
+
*/
|
|
170
|
+
export interface ChatHost {
|
|
171
|
+
storage?: ChatStorageOptions;
|
|
172
|
+
/* The colors an account may wear in the order a picker offers them, the few it shows first, and their names. */
|
|
173
|
+
accents: {
|
|
174
|
+
all: readonly AccentChoice[];
|
|
175
|
+
featured: readonly string[];
|
|
176
|
+
label(id: string): string;
|
|
177
|
+
/* The accent the app is painted in, which an account without a color of its own wears. */
|
|
178
|
+
current(): string;
|
|
179
|
+
};
|
|
180
|
+
isApplePlatform(): boolean;
|
|
181
|
+
/* A key the app keeps for itself even while the composer has the keyboard, such as the ones that move between views. */
|
|
182
|
+
isAppShortcut(event: KeyboardEvent): boolean;
|
|
183
|
+
notify(toast: ChatToast): void;
|
|
184
|
+
/* The app's own actions; null runs every one as a request on the scope's transport. */
|
|
185
|
+
actions: ChatActions | null;
|
|
186
|
+
/* Files under `cwd` for the composer's `@` picker; null offers none. */
|
|
187
|
+
searchFiles: ((scopeId: string, cwd: string, query: string, limit: number) => Promise<string[]>) | null;
|
|
188
|
+
/* The bytes of a file attached to a message, where the host keeps them. */
|
|
189
|
+
attachments: {
|
|
190
|
+
useUrl(scopeId: string, chatId: string, attachmentId: string): ResourceUrl;
|
|
191
|
+
read(scopeId: string, chatId: string, attachmentId: string): Promise<Blob>;
|
|
192
|
+
};
|
|
193
|
+
/* The image a tool read, drawn under its row; null draws none. */
|
|
194
|
+
ReadImage: ComponentType<{ path: string }> | null;
|
|
195
|
+
code: {
|
|
196
|
+
/* Whether the app is light or dark right now. */
|
|
197
|
+
useMode(): 'light' | 'dark';
|
|
198
|
+
/* The Shiki theme ids code is drawn in, one per mode. */
|
|
199
|
+
useThemes(): { light: string; dark: string };
|
|
200
|
+
/* Themes the app ships itself, found by name; the rest Shiki looks up by id. */
|
|
201
|
+
custom: ReadonlyArray<ThemeRegistration & { name: string }>;
|
|
202
|
+
};
|
|
203
|
+
/* How a reply appears while it streams: a word, a block or the whole of it at a time. */
|
|
204
|
+
useStreaming(): 'words' | 'blocks' | 'whole';
|
|
205
|
+
/* Paths in an answer as links; null leaves them text. */
|
|
206
|
+
fileLinks: {
|
|
207
|
+
/* The reference a piece of text names, where the folder it counts from lets it be opened. */
|
|
208
|
+
target(text: string, cwd: string | null): FileRef | null;
|
|
209
|
+
open(cwd: string | null, ref: FileRef): void;
|
|
210
|
+
} | null;
|
|
211
|
+
/* Find in a thread; without one the thread has no find. */
|
|
212
|
+
useTimelineFind(options: TimelineFindOptions): TimelineFind;
|
|
213
|
+
dictation: {
|
|
214
|
+
/* The field a written answer goes in. */
|
|
215
|
+
Textarea: ComponentType<TextareaProps>;
|
|
216
|
+
/* What the composer's editor carries for dictated text, and the control beside it. */
|
|
217
|
+
composer: { extensions: Extension; Control: ComponentType<ComposerDictationProps> } | null;
|
|
218
|
+
};
|
|
219
|
+
prompts: {
|
|
220
|
+
/* Prompts the app raises beside a chat's own requests, answered in the same place. */
|
|
221
|
+
useExtra(scopeId: string, chatId: string): readonly HostPrompt[];
|
|
222
|
+
render(prompt: HostPrompt, props: PromptViewProps): ReactNode;
|
|
223
|
+
answer(prompt: HostPrompt, action: PromptAction): Promise<void>;
|
|
224
|
+
};
|
|
225
|
+
/* Other chats a message may point at with `@`, beside the files. */
|
|
226
|
+
useReferableChats(): ReadonlyArray<{ id: string; title: string }>;
|
|
227
|
+
/* Opens the CLI's own login for an account, somewhere the app can run a command; null offers none. */
|
|
228
|
+
openLogin: ((scopeId: string, kind: AgentKind, accountId: string, name: string) => Promise<void>) | null;
|
|
229
|
+
/* Why a login cannot start from here right now, or null when it can. */
|
|
230
|
+
useLoginBlocked(scopeId: string): string | null;
|
|
231
|
+
/* The name and the mark of a project of the host, for the usage per project; null draws the folder's own. */
|
|
232
|
+
useProjectLook(scopeId: string, projectId: string | null): { name: string; mark: ReactNode } | null;
|
|
233
|
+
/* Where another chat of the app stands, for a fork's way back and a note from a fork. */
|
|
234
|
+
useChatPlace(chatId: string): ChatPlace;
|
|
235
|
+
/* What a chat may read besides its folder, named under an empty thread. */
|
|
236
|
+
useContextSources(chatId: string): ReadonlyArray<{ title: string }>;
|
|
237
|
+
/* Whether the folder a chat works in is the app's business only, so an empty thread does not name it. */
|
|
238
|
+
useHidesFolder(chatId: string): boolean;
|
|
239
|
+
/* Whether a chat before its first message opens on a greeting with the composer under it, rather than an empty thread over a docked composer. */
|
|
240
|
+
useWelcome(chatId: string): boolean;
|
|
241
|
+
tasks: {
|
|
242
|
+
useTasks(scopeId: string): Readonly<Record<string, SubagentTask>> | undefined;
|
|
243
|
+
/* Null for a row with no task behind it. */
|
|
244
|
+
useTask(scopeId: string, taskId: string | null): SubagentTask | null;
|
|
245
|
+
};
|
|
246
|
+
/* Asked before a stop that ends agents the chat opened; `run` stops. */
|
|
247
|
+
confirm: {
|
|
248
|
+
stopSubagents(scopeId: string, chatId: string, run: () => void): void;
|
|
249
|
+
stopTask(scopeId: string, childId: string, title: string, run: () => void): void;
|
|
250
|
+
};
|
|
251
|
+
/* Offers a fork of the chat after one of its turns; null offers none. */
|
|
252
|
+
fork: ((chatId: string, turnId: string) => void) | null;
|
|
253
|
+
/* Opens the app's settings on a section: `providers`, or `agents`. */
|
|
254
|
+
openSettings(section: 'providers' | 'agents'): void;
|
|
255
|
+
/* Whether the host lets a chat go on by itself once a limit it stopped on lifts. */
|
|
256
|
+
useResumeAtReset(scopeId: string): boolean;
|
|
257
|
+
/* The words an empty composer opens with, before the keys it hints at; null keeps the chat's own. */
|
|
258
|
+
useComposerPlaceholder(scopeId: string, chatId: string): string | null;
|
|
259
|
+
/* The app's own control in the composer's row, after the pickers; null draws none. */
|
|
260
|
+
ComposerSlot: ComponentType<ComposerSlotProps> | null;
|
|
261
|
+
/* The app's own chips for a chat's sub-agents over the composer; null draws the one flyout. */
|
|
262
|
+
SubagentSlot: ComponentType<SubagentSlotProps> | null;
|
|
263
|
+
/* Cards of the app's own in a thread, in any order. Hand back the same array while none changed, or the thread lays out its rows again on every render. */
|
|
264
|
+
useThreadCards(scopeId: string, chatId: string): readonly ThreadCard[];
|
|
265
|
+
/* A header over every reply with its author and how long ago it began; null names the agent for a screen reader only. */
|
|
266
|
+
useReplyAuthor(scopeId: string, chatId: string): ReplyAuthor | null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const NO_PROMPTS: readonly HostPrompt[] = [];
|
|
270
|
+
const NO_CHATS: ReadonlyArray<{ id: string; title: string }> = [];
|
|
271
|
+
const NO_ROWS: readonly number[] = [];
|
|
272
|
+
const NO_FIND: TimelineFind = { open: false, bar: null, reveal: null, hitRows: NO_ROWS, currentRow: null };
|
|
273
|
+
const NO_SOURCES: ReadonlyArray<{ title: string }> = [];
|
|
274
|
+
const NO_URL: ResourceUrl = { url: null, failure: null };
|
|
275
|
+
const NOWHERE: ChatPlace = { title: null, go: () => undefined };
|
|
276
|
+
const NO_CARDS: readonly ThreadCard[] = [];
|
|
277
|
+
|
|
278
|
+
const DEFAULT_HOST: ChatHost = {
|
|
279
|
+
accents: { all: [], featured: [], label: (id) => id, current: () => '' },
|
|
280
|
+
isApplePlatform,
|
|
281
|
+
isAppShortcut: () => false,
|
|
282
|
+
notify: () => undefined,
|
|
283
|
+
actions: null,
|
|
284
|
+
searchFiles: null,
|
|
285
|
+
attachments: { useUrl: () => NO_URL, read: () => Promise.reject(new Error('This app keeps no attached files')) },
|
|
286
|
+
ReadImage: null,
|
|
287
|
+
code: { useMode: () => 'light', useThemes: () => ({ light: 'github-light', dark: 'github-dark' }), custom: [] },
|
|
288
|
+
useStreaming: () => 'words',
|
|
289
|
+
fileLinks: null,
|
|
290
|
+
useTimelineFind: () => NO_FIND,
|
|
291
|
+
dictation: { Textarea: PlainTextarea, composer: null },
|
|
292
|
+
prompts: { useExtra: () => NO_PROMPTS, render: () => null, answer: () => Promise.reject(new Error('This app raises no prompts of its own')) },
|
|
293
|
+
useReferableChats: () => NO_CHATS,
|
|
294
|
+
openLogin: null,
|
|
295
|
+
useLoginBlocked: () => null,
|
|
296
|
+
useProjectLook: () => null,
|
|
297
|
+
useChatPlace: () => NOWHERE,
|
|
298
|
+
useContextSources: () => NO_SOURCES,
|
|
299
|
+
useHidesFolder: () => false,
|
|
300
|
+
useWelcome: () => false,
|
|
301
|
+
tasks: { useTasks: () => undefined, useTask: () => null },
|
|
302
|
+
confirm: { stopSubagents: (_scopeId, _chatId, run) => run(), stopTask: (_scopeId, _childId, _title, run) => run() },
|
|
303
|
+
fork: null,
|
|
304
|
+
openSettings: () => undefined,
|
|
305
|
+
useResumeAtReset: () => true,
|
|
306
|
+
useComposerPlaceholder: () => null,
|
|
307
|
+
ComposerSlot: null,
|
|
308
|
+
SubagentSlot: null,
|
|
309
|
+
useThreadCards: () => NO_CARDS,
|
|
310
|
+
useReplyAuthor: () => null
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
let host: ChatHost = DEFAULT_HOST;
|
|
314
|
+
|
|
315
|
+
export function setChatHost(patch: Partial<ChatHost>): void {
|
|
316
|
+
if (patch.storage !== undefined) {
|
|
317
|
+
configureChatStorage(patch.storage);
|
|
318
|
+
}
|
|
319
|
+
host = { ...host, ...patch };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function chatHost(): ChatHost {
|
|
323
|
+
return host;
|
|
324
|
+
}
|
package/src/lazy.tsx
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { lazy, type ComponentProps, type ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
type Loader = () => Promise<unknown>;
|
|
4
|
+
|
|
5
|
+
const loaders: Loader[] = [];
|
|
6
|
+
let register: ((load: Loader) => void) | null = null;
|
|
7
|
+
const openErrorListeners = new Set<(error: unknown) => void>();
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Hands every module the chat loads lazily to the app's prefetcher: the ones made so far, and each
|
|
11
|
+
* one made from now on. Without it they load on their first render, as `React.lazy` does.
|
|
12
|
+
*/
|
|
13
|
+
export function setLazyPrefetch(next: (load: Loader) => void): void {
|
|
14
|
+
register = next;
|
|
15
|
+
for (const load of loaders) {
|
|
16
|
+
next(load);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Tells `listener` when a module the chat loads for a render fails to load, the way `onLazyOpenError`
|
|
22
|
+
* of `@adecore/ui` does for the app's own. A failed prefetch never reaches it.
|
|
23
|
+
*/
|
|
24
|
+
export function onLazyOpenError(listener: (error: unknown) => void): () => void {
|
|
25
|
+
openErrorListeners.add(listener);
|
|
26
|
+
return () => {
|
|
27
|
+
openErrorListeners.delete(listener);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* `React.lazy` for a module that exports its component by name, `default` included. Once the module
|
|
33
|
+
* is here the component is drawn straight away, since `React.lazy` suspends for a tick even on a
|
|
34
|
+
* module the prefetcher already fetched.
|
|
35
|
+
*/
|
|
36
|
+
export function lazyNamed<Module extends Record<Name, ComponentType<any>>, Name extends keyof Module>(
|
|
37
|
+
load: () => Promise<Module>,
|
|
38
|
+
name: Name
|
|
39
|
+
): ComponentType<ComponentProps<Module[Name]>> {
|
|
40
|
+
let loaded: ComponentType<any> | null = null;
|
|
41
|
+
const open = async (): Promise<ComponentType<any>> => {
|
|
42
|
+
const component = (await load())[name];
|
|
43
|
+
loaded ??= component;
|
|
44
|
+
return component;
|
|
45
|
+
};
|
|
46
|
+
loaders.push(open);
|
|
47
|
+
register?.(open);
|
|
48
|
+
// Only a render loads through here; a prefetch calls `open` itself, so its failures report nothing.
|
|
49
|
+
const Lazy = lazy(async () => {
|
|
50
|
+
try {
|
|
51
|
+
return { default: await open() };
|
|
52
|
+
} catch (error) {
|
|
53
|
+
for (const listener of openErrorListeners) {
|
|
54
|
+
listener(error);
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const LazyNamed = (props: ComponentProps<Module[Name]>) => {
|
|
60
|
+
const Component: ComponentType<any> = loaded ?? Lazy;
|
|
61
|
+
return <Component {...props} />;
|
|
62
|
+
};
|
|
63
|
+
return LazyNamed;
|
|
64
|
+
}
|