@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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProviderAccountVariable } from '@adecore/agent-contracts';
|
|
2
|
+
export interface VariableDraft {
|
|
3
|
+
key: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
sensitive: boolean;
|
|
7
|
+
kept: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function draftsOf(env: readonly ProviderAccountVariable[] | undefined): VariableDraft[];
|
|
10
|
+
export declare function emptyDraft(sensitive: boolean): VariableDraft;
|
|
11
|
+
export declare function variablesProblem(drafts: readonly VariableDraft[]): string | null;
|
|
12
|
+
export declare function variablesOf(drafts: readonly VariableDraft[]): ProviderAccountVariable[];
|
|
13
|
+
export declare function variablesChanged(drafts: readonly VariableDraft[], env: readonly ProviderAccountVariable[] | undefined): boolean;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
const NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
3
|
+
let drafted = 0;
|
|
4
|
+
function nextKey() {
|
|
5
|
+
drafted += 1;
|
|
6
|
+
return `variable-${drafted}`;
|
|
7
|
+
}
|
|
8
|
+
export function draftsOf(env) {
|
|
9
|
+
return (env ?? []).map((variable) => ({
|
|
10
|
+
key: nextKey(),
|
|
11
|
+
name: variable.name,
|
|
12
|
+
value: variable.value,
|
|
13
|
+
sensitive: variable.sensitive,
|
|
14
|
+
kept: variable.sensitive && variable.valueRedacted === true ? variable.name : null
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
export function emptyDraft(sensitive) {
|
|
18
|
+
return { key: nextKey(), name: '', value: '', sensitive, kept: null };
|
|
19
|
+
}
|
|
20
|
+
/*
|
|
21
|
+
* A value the keychain holds only counts under the name it was kept under, and only while it stays
|
|
22
|
+
* sensitive: the machine finds it by that name, and never hands it out to be stored in plain text.
|
|
23
|
+
*/
|
|
24
|
+
function keepsValue(draft) {
|
|
25
|
+
return draft.value === '' && draft.sensitive && draft.kept === draft.name;
|
|
26
|
+
}
|
|
27
|
+
/* The first thing that keeps these from being saved, in a sentence; null when they can be. */
|
|
28
|
+
export function variablesProblem(drafts) {
|
|
29
|
+
const words = (key, name) => i18next.t(`agent-providers:account.variables.problem.${key}`, { name });
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
for (const draft of drafts) {
|
|
32
|
+
const name = draft.name.trim();
|
|
33
|
+
if (name === '') {
|
|
34
|
+
return words('noName', '');
|
|
35
|
+
}
|
|
36
|
+
if (!NAME.test(name)) {
|
|
37
|
+
return words('invalidName', name);
|
|
38
|
+
}
|
|
39
|
+
if (seen.has(name)) {
|
|
40
|
+
return words('duplicate', name);
|
|
41
|
+
}
|
|
42
|
+
seen.add(name);
|
|
43
|
+
if (draft.value === '' && !keepsValue({ ...draft, name })) {
|
|
44
|
+
return words('noValue', name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/* The variables as `accounts.save` takes them; a kept value goes back empty and redacted, so the machine keeps what it has. */
|
|
50
|
+
export function variablesOf(drafts) {
|
|
51
|
+
return drafts.map((draft) => {
|
|
52
|
+
const name = draft.name.trim();
|
|
53
|
+
if (keepsValue({ ...draft, name })) {
|
|
54
|
+
return { name, value: '', sensitive: true, valueRedacted: true };
|
|
55
|
+
}
|
|
56
|
+
return { name, value: draft.value, sensitive: draft.sensitive };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/* Whether the drafts say something other than what the machine holds. */
|
|
60
|
+
export function variablesChanged(drafts, env) {
|
|
61
|
+
return (JSON.stringify(variablesOf(drafts)) !==
|
|
62
|
+
JSON.stringify((env ?? []).map(({ name, value, sensitive, valueRedacted }) => ({ name, value, sensitive, ...(valueRedacted ? { valueRedacted } : {}) }))));
|
|
63
|
+
}
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChatClient } from './chat/chat-client.js';
|
|
2
|
+
import type { ChatTransport } from './transport.js';
|
|
3
|
+
export interface ChatScope {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
keyOf(chatId: string): string;
|
|
6
|
+
owns(key: string): boolean;
|
|
7
|
+
readonly transport: ChatTransport;
|
|
8
|
+
readonly chats: ChatClient;
|
|
9
|
+
}
|
|
10
|
+
export declare const ChatScopeContext: import("react").Context<ChatScope | null>;
|
|
11
|
+
export declare function useChatScope(): ChatScope;
|
package/dist/scope.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
export const ChatScopeContext = createContext(null);
|
|
3
|
+
/* Throws outside a scope on purpose: a component that reads a chat has to know which host it runs on. */
|
|
4
|
+
export function useChatScope() {
|
|
5
|
+
const scope = useContext(ChatScopeContext);
|
|
6
|
+
if (scope === null) {
|
|
7
|
+
throw new Error('This component reads a chat, so it has to be rendered inside a ChatScopeContext');
|
|
8
|
+
}
|
|
9
|
+
return scope;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { type LucideIcon } from 'lucide-react';
|
|
3
|
+
import type { SettingsSectionEntry } from '@adecore/ui/settings';
|
|
4
|
+
export interface AgentsSettingsSection {
|
|
5
|
+
id: string;
|
|
6
|
+
icon: LucideIcon;
|
|
7
|
+
split?: boolean;
|
|
8
|
+
label(): string;
|
|
9
|
+
description(): string;
|
|
10
|
+
}
|
|
11
|
+
export declare const PROVIDERS_SECTION: AgentsSettingsSection;
|
|
12
|
+
export declare const USAGE_SECTION: AgentsSettingsSection;
|
|
13
|
+
export declare function settingsSection(section: AgentsSettingsSection, pane: ComponentType): SettingsSectionEntry;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import { Brain, ChartNoAxesColumn } from 'lucide-react';
|
|
3
|
+
/* The agent CLIs of the host and the accounts they sign in with: `ProvidersPane`. */
|
|
4
|
+
export const PROVIDERS_SECTION = {
|
|
5
|
+
id: 'providers',
|
|
6
|
+
icon: Brain,
|
|
7
|
+
split: true,
|
|
8
|
+
label: () => i18next.t('agent-providers:section.label'),
|
|
9
|
+
description: () => i18next.t('agent-providers:section.description')
|
|
10
|
+
};
|
|
11
|
+
/* The currency of the usage page and the way to it: `UsagePane`. */
|
|
12
|
+
export const USAGE_SECTION = {
|
|
13
|
+
id: 'usage',
|
|
14
|
+
icon: ChartNoAxesColumn,
|
|
15
|
+
label: () => i18next.t('agent-usage:section.label'),
|
|
16
|
+
description: () => i18next.t('agent-usage:section.description')
|
|
17
|
+
};
|
|
18
|
+
/*
|
|
19
|
+
* The entry the dialog takes for a section, with the pane the app hands it: the pane of this package
|
|
20
|
+
* itself, a lazy one, or a wrapper that gives the pane what only the app knows. Built when the dialog
|
|
21
|
+
* draws, since the words follow the language.
|
|
22
|
+
*/
|
|
23
|
+
export function settingsSection(section, pane) {
|
|
24
|
+
return {
|
|
25
|
+
id: section.id,
|
|
26
|
+
icon: section.icon,
|
|
27
|
+
label: section.label(),
|
|
28
|
+
description: section.description(),
|
|
29
|
+
pane,
|
|
30
|
+
split: section.split
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ChatApprovalItem, ChatBookmark, ChatEvent, ChatHistoryResult, ChatInfo, ChatItem, ChatQuestionItem } from '@adecore/agent-contracts';
|
|
2
|
+
export interface ChatState {
|
|
3
|
+
info: ChatInfo;
|
|
4
|
+
items: Record<string, ChatItem>;
|
|
5
|
+
structure: Record<string, ChatItem>;
|
|
6
|
+
order: string[];
|
|
7
|
+
history?: ChatHistoryPage;
|
|
8
|
+
waitingBefore?: string[];
|
|
9
|
+
bookmarks?: ChatBookmark[];
|
|
10
|
+
}
|
|
11
|
+
export type ChatHistoryPage = ChatHistoryResult['history'];
|
|
12
|
+
export interface ChatPage {
|
|
13
|
+
history: ChatHistoryPage;
|
|
14
|
+
pending: ChatItem[];
|
|
15
|
+
}
|
|
16
|
+
export type ChatsById = Record<string, ChatState>;
|
|
17
|
+
export type ChatStatuses = Record<string, Pick<ChatState, 'info'>>;
|
|
18
|
+
export interface ChatSink {
|
|
19
|
+
reset(chatId: string, info: ChatInfo, items: ChatItem[], page?: ChatPage): void;
|
|
20
|
+
prepend(chatId: string, cursor: string, page: ChatHistoryResult): void;
|
|
21
|
+
apply(chatId: string, event: ChatEvent): void;
|
|
22
|
+
status(chatId: string, info: ChatInfo): void;
|
|
23
|
+
bookmarks(chatId: string, bookmarks: ChatBookmark[]): void;
|
|
24
|
+
forget(chatId: string): void;
|
|
25
|
+
}
|
|
26
|
+
interface ChatsStore {
|
|
27
|
+
byKey: ChatsById;
|
|
28
|
+
statusByKey: ChatStatuses;
|
|
29
|
+
reset(key: string, info: ChatInfo, items: ChatItem[], page?: ChatPage): void;
|
|
30
|
+
prepend(key: string, cursor: string, page: ChatHistoryResult): void;
|
|
31
|
+
apply(key: string, event: ChatEvent): void;
|
|
32
|
+
status(key: string, info: ChatInfo): void;
|
|
33
|
+
bookmarks(key: string, bookmarks: ChatBookmark[]): void;
|
|
34
|
+
forget(key: string): void;
|
|
35
|
+
forgetWhere(matches: (key: string) => boolean): void;
|
|
36
|
+
}
|
|
37
|
+
export declare function prependPage(state: ChatState, cursor: string, page: ChatHistoryResult): ChatState;
|
|
38
|
+
export declare function waitingRequestsOf(chat: Pick<ChatState, 'structure' | 'order' | 'waitingBefore'> | undefined): Array<ChatApprovalItem | ChatQuestionItem>;
|
|
39
|
+
export declare function applyEvent(state: ChatState, event: ChatEvent): ChatState;
|
|
40
|
+
export declare const useChats: import("zustand").UseBoundStore<import("zustand").StoreApi<ChatsStore>>;
|
|
41
|
+
export declare function chatSink(keyOf: (chatId: string) => string): ChatSink;
|
|
42
|
+
export declare function useChatRow<T>(chatId: string, select: (row: ChatState | undefined) => T): T;
|
|
43
|
+
export declare function useCurrentItem<T extends ChatItem>(chatId: string, derived: T): T;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { useChatScope } from '../scope.js';
|
|
3
|
+
function isWaiting(item) {
|
|
4
|
+
return (item?.kind === 'approval' && item.decision === 'pending') || (item?.kind === 'question' && item.state === 'pending');
|
|
5
|
+
}
|
|
6
|
+
function stateOf(info, items, page) {
|
|
7
|
+
const byId = Object.fromEntries(items.map((item) => [item.id, item]));
|
|
8
|
+
const order = items.map((item) => item.id);
|
|
9
|
+
if (page === undefined || page.history.cursor === null) {
|
|
10
|
+
return { info, items: byId, structure: byId, order };
|
|
11
|
+
}
|
|
12
|
+
const before = page.pending.filter((item) => !(item.id in byId));
|
|
13
|
+
for (const item of before) {
|
|
14
|
+
byId[item.id] = item;
|
|
15
|
+
}
|
|
16
|
+
return { info, items: byId, structure: byId, order, history: page.history, waitingBefore: before.map((item) => item.id) };
|
|
17
|
+
}
|
|
18
|
+
/* An older host names no place in the thread, and it always hands over the whole of it. */
|
|
19
|
+
function isBeforePage(state, historyIndex) {
|
|
20
|
+
return state.history !== undefined && historyIndex !== undefined && historyIndex < state.history.start;
|
|
21
|
+
}
|
|
22
|
+
/* An item from before the page this client holds matters only as a request that waits, or one that stopped waiting. */
|
|
23
|
+
function withEarlierItem(state, item) {
|
|
24
|
+
const waiting = state.waitingBefore ?? [];
|
|
25
|
+
const held = waiting.includes(item.id);
|
|
26
|
+
if (isWaiting(item)) {
|
|
27
|
+
return { ...withItem(state, item), waitingBefore: held ? waiting : [...waiting, item.id] };
|
|
28
|
+
}
|
|
29
|
+
return held ? { ...withItem(state, item), waitingBefore: waiting.filter((id) => id !== item.id) } : state;
|
|
30
|
+
}
|
|
31
|
+
/* The page before the one a chat holds, unless the thread was read again since that page was asked for. */
|
|
32
|
+
export function prependPage(state, cursor, page) {
|
|
33
|
+
if (state.history?.cursor !== cursor) {
|
|
34
|
+
return state;
|
|
35
|
+
}
|
|
36
|
+
const held = new Set(state.order);
|
|
37
|
+
const older = page.items.filter((item) => !held.has(item.id));
|
|
38
|
+
const olderIds = new Set(older.map((item) => item.id));
|
|
39
|
+
const items = { ...state.items };
|
|
40
|
+
for (const item of older) {
|
|
41
|
+
items[item.id] = item;
|
|
42
|
+
}
|
|
43
|
+
const order = [...olderIds, ...state.order];
|
|
44
|
+
if (page.history.cursor === null) {
|
|
45
|
+
const { history: _history, waitingBefore: _waitingBefore, ...rest } = state;
|
|
46
|
+
return { ...rest, items, structure: items, order };
|
|
47
|
+
}
|
|
48
|
+
const waitingBefore = (state.waitingBefore ?? []).filter((id) => !olderIds.has(id));
|
|
49
|
+
return { ...state, items, structure: items, order, history: page.history, waitingBefore };
|
|
50
|
+
}
|
|
51
|
+
/* The requests that still wait, oldest first: those from before the page this client holds, then the thread's own. */
|
|
52
|
+
export function waitingRequestsOf(chat) {
|
|
53
|
+
return [...(chat?.waitingBefore ?? []), ...(chat?.order ?? [])].map((id) => chat?.structure[id]).filter(isWaiting);
|
|
54
|
+
}
|
|
55
|
+
/* The state with one item replaced, in the thread and in the structure the rows come from. */
|
|
56
|
+
function withItem(state, item) {
|
|
57
|
+
const items = { ...state.items, [item.id]: item };
|
|
58
|
+
return { ...state, items, structure: items };
|
|
59
|
+
}
|
|
60
|
+
/* Cheap enough, since a status only arrives when the host saw one change, never on a streamed word. */
|
|
61
|
+
function sameInfo(left, right) {
|
|
62
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
63
|
+
}
|
|
64
|
+
/* The statuses with this chat's info in them, the same object when that info is already there. */
|
|
65
|
+
function withStatus(statuses, key, info) {
|
|
66
|
+
return statuses[key]?.info === info ? statuses : { ...statuses, [key]: { info } };
|
|
67
|
+
}
|
|
68
|
+
function without(rows, matches) {
|
|
69
|
+
return Object.fromEntries(Object.entries(rows).filter(([key]) => !matches(key)));
|
|
70
|
+
}
|
|
71
|
+
export function applyEvent(state, event) {
|
|
72
|
+
switch (event.type) {
|
|
73
|
+
case 'item': {
|
|
74
|
+
if (isBeforePage(state, event.historyIndex)) {
|
|
75
|
+
return withEarlierItem(state, event.item);
|
|
76
|
+
}
|
|
77
|
+
const known = event.item.id in state.items;
|
|
78
|
+
return { ...withItem(state, event.item), order: known ? state.order : [...state.order, event.item.id] };
|
|
79
|
+
}
|
|
80
|
+
case 'delta': {
|
|
81
|
+
const item = state.items[event.itemId];
|
|
82
|
+
if (item?.kind === 'assistant' || item?.kind === 'thinking') {
|
|
83
|
+
const grown = { ...item, text: item.text + event.text };
|
|
84
|
+
// The first text is structure after all, since an empty reply that is not streaming has no row.
|
|
85
|
+
if (item.text === '') {
|
|
86
|
+
return withItem(state, grown);
|
|
87
|
+
}
|
|
88
|
+
return { ...state, items: { ...state.items, [event.itemId]: grown } };
|
|
89
|
+
}
|
|
90
|
+
if (item?.kind === 'tool' && item.state === 'running') {
|
|
91
|
+
const progress = item.progress ?? { startedAt: null, description: null, output: null };
|
|
92
|
+
const grown = { ...item, progress: { ...progress, output: (progress.output ?? '') + event.text } };
|
|
93
|
+
return { ...state, items: { ...state.items, [event.itemId]: grown } };
|
|
94
|
+
}
|
|
95
|
+
return state;
|
|
96
|
+
}
|
|
97
|
+
case 'info':
|
|
98
|
+
return { ...state, info: event.info };
|
|
99
|
+
case 'reset':
|
|
100
|
+
return stateOf(event.info, event.items);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export const useChats = create((set) => ({
|
|
104
|
+
byKey: {},
|
|
105
|
+
statusByKey: {},
|
|
106
|
+
reset(key, info, items, page) {
|
|
107
|
+
set((s) => {
|
|
108
|
+
// The bookmarks are not part of the thread; they come in on their own and outlive a reset of it.
|
|
109
|
+
const bookmarks = s.byKey[key]?.bookmarks;
|
|
110
|
+
const next = stateOf(info, items, page);
|
|
111
|
+
return {
|
|
112
|
+
byKey: { ...s.byKey, [key]: bookmarks === undefined ? next : { ...next, bookmarks } },
|
|
113
|
+
statusByKey: withStatus(s.statusByKey, key, info)
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
prepend(key, cursor, page) {
|
|
118
|
+
set((s) => {
|
|
119
|
+
const current = s.byKey[key];
|
|
120
|
+
if (!current) {
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
const next = prependPage(current, cursor, page);
|
|
124
|
+
return next === current ? {} : { byKey: { ...s.byKey, [key]: next } };
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
apply(key, event) {
|
|
128
|
+
set((s) => {
|
|
129
|
+
const current = s.byKey[key];
|
|
130
|
+
if (!current) {
|
|
131
|
+
return {};
|
|
132
|
+
}
|
|
133
|
+
const next = applyEvent(current, event);
|
|
134
|
+
return { byKey: { ...s.byKey, [key]: next }, statusByKey: withStatus(s.statusByKey, key, next.info) };
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
/*
|
|
138
|
+
* The status of a chat this window is not reading, which the host sends for every chat it has
|
|
139
|
+
* loaded. The thread stays empty until somebody attaches, since this is what a header, a list and
|
|
140
|
+
* the counters need, and they ask the info and never the items.
|
|
141
|
+
*/
|
|
142
|
+
status(key, info) {
|
|
143
|
+
set((s) => {
|
|
144
|
+
const current = s.byKey[key];
|
|
145
|
+
if (!current) {
|
|
146
|
+
return { byKey: { ...s.byKey, [key]: stateOf(info, []) }, statusByKey: withStatus(s.statusByKey, key, info) };
|
|
147
|
+
}
|
|
148
|
+
// An attached client already had this on `chat.event`; writing it again would redraw the thread.
|
|
149
|
+
if (sameInfo(current.info, info)) {
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
return { byKey: { ...s.byKey, [key]: { ...current, info } }, statusByKey: withStatus(s.statusByKey, key, info) };
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
bookmarks(key, bookmarks) {
|
|
156
|
+
set((s) => {
|
|
157
|
+
const current = s.byKey[key];
|
|
158
|
+
if (!current) {
|
|
159
|
+
return {};
|
|
160
|
+
}
|
|
161
|
+
return { byKey: { ...s.byKey, [key]: { ...current, bookmarks } } };
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
forget(key) {
|
|
165
|
+
set((s) => {
|
|
166
|
+
const next = { ...s.byKey };
|
|
167
|
+
delete next[key];
|
|
168
|
+
const statuses = { ...s.statusByKey };
|
|
169
|
+
delete statuses[key];
|
|
170
|
+
return { byKey: next, statusByKey: statuses };
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
forgetWhere(matches) {
|
|
174
|
+
set((s) => ({ byKey: without(s.byKey, matches), statusByKey: without(s.statusByKey, matches) }));
|
|
175
|
+
}
|
|
176
|
+
}));
|
|
177
|
+
/* The sink of one host's chat client: it hands over chat ids, this puts them under the keys of its scope. */
|
|
178
|
+
export function chatSink(keyOf) {
|
|
179
|
+
return {
|
|
180
|
+
reset: (chatId, info, items, page) => useChats.getState().reset(keyOf(chatId), info, items, page),
|
|
181
|
+
prepend: (chatId, cursor, page) => useChats.getState().prepend(keyOf(chatId), cursor, page),
|
|
182
|
+
apply: (chatId, event) => useChats.getState().apply(keyOf(chatId), event),
|
|
183
|
+
status: (chatId, info) => useChats.getState().status(keyOf(chatId), info),
|
|
184
|
+
bookmarks: (chatId, bookmarks) => useChats.getState().bookmarks(keyOf(chatId), bookmarks),
|
|
185
|
+
forget: (chatId) => useChats.getState().forget(keyOf(chatId))
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/* One chat's thread in the scope this is rendered in. The selector keeps a render tied to the field it reads. */
|
|
189
|
+
export function useChatRow(chatId, select) {
|
|
190
|
+
const { keyOf } = useChatScope();
|
|
191
|
+
return useChats((s) => select(s.byKey[keyOf(chatId)]));
|
|
192
|
+
}
|
|
193
|
+
/* The item as the thread holds it now, for a row derived from the structure, which a delta leaves alone. */
|
|
194
|
+
export function useCurrentItem(chatId, derived) {
|
|
195
|
+
return useChatRow(chatId, (row) => {
|
|
196
|
+
const item = row?.items[derived.id];
|
|
197
|
+
return item?.kind === derived.kind ? item : derived;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ProviderAccounts } from '@adecore/agent-contracts';
|
|
2
|
+
import type { ChatTransport } from '../transport.js';
|
|
3
|
+
export interface ProviderAccountsRow {
|
|
4
|
+
accounts: ProviderAccounts | null;
|
|
5
|
+
loaded: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ProviderAccountsStore {
|
|
8
|
+
byScope: Record<string, ProviderAccountsRow>;
|
|
9
|
+
set(scopeId: string, accounts: ProviderAccounts | null): void;
|
|
10
|
+
forget(scopeId: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const useProviderAccountsStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ProviderAccountsStore>>;
|
|
13
|
+
export declare function useProviderAccounts<T>(select: (row: ProviderAccountsRow) => T): T;
|
|
14
|
+
export declare function providerAccountsOf(scopeId: string): ProviderAccountsRow;
|
|
15
|
+
export declare function knownAccounts(row: ProviderAccountsRow): ProviderAccounts | null | undefined;
|
|
16
|
+
export declare function watchProviderAccounts(scopeId: string, transport: ChatTransport): () => void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { useChatScope } from '../scope.js';
|
|
3
|
+
/* One object for a host that has not answered yet, so a selector gets a stable snapshot. */
|
|
4
|
+
const NONE = { accounts: null, loaded: false };
|
|
5
|
+
/* The accounts of every agent CLI on each host, and what each CLI last said about who is signed in there. */
|
|
6
|
+
export const useProviderAccountsStore = create((set, get) => ({
|
|
7
|
+
byScope: {},
|
|
8
|
+
set(scopeId, accounts) {
|
|
9
|
+
set({ byScope: { ...get().byScope, [scopeId]: { accounts, loaded: true } } });
|
|
10
|
+
},
|
|
11
|
+
forget(scopeId) {
|
|
12
|
+
const { [scopeId]: _gone, ...rest } = get().byScope;
|
|
13
|
+
set({ byScope: rest });
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
/* The accounts of the host in scope, like `useProviders`. */
|
|
17
|
+
export function useProviderAccounts(select) {
|
|
18
|
+
const { id } = useChatScope();
|
|
19
|
+
return useProviderAccountsStore((s) => select(s.byScope[id] ?? NONE));
|
|
20
|
+
}
|
|
21
|
+
export function providerAccountsOf(scopeId) {
|
|
22
|
+
return useProviderAccountsStore.getState().byScope[scopeId] ?? NONE;
|
|
23
|
+
}
|
|
24
|
+
/* The accounts as `accountFor` takes them: undefined until the host answered, null for one that keeps none. */
|
|
25
|
+
export function knownAccounts(row) {
|
|
26
|
+
return row.loaded ? row.accounts : undefined;
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
* Keeps one host's accounts in the store: the whole list on every fresh link, then every change the
|
|
30
|
+
* host announces. Answers the function that stops it.
|
|
31
|
+
*/
|
|
32
|
+
export function watchProviderAccounts(scopeId, transport) {
|
|
33
|
+
const store = useProviderAccountsStore.getState();
|
|
34
|
+
// A list asked for before a change arrived is older than that change, so it is dropped.
|
|
35
|
+
let changes = 0;
|
|
36
|
+
const load = () => {
|
|
37
|
+
const asked = changes;
|
|
38
|
+
transport
|
|
39
|
+
.request('accounts.list', {})
|
|
40
|
+
.then((accounts) => {
|
|
41
|
+
if (changes === asked) {
|
|
42
|
+
store.set(scopeId, accounts);
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
.catch(() => {
|
|
46
|
+
// A host from before accounts never answers; it has only each CLI's own login.
|
|
47
|
+
if (changes === asked && !providerAccountsOf(scopeId).loaded) {
|
|
48
|
+
store.set(scopeId, null);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const off = [
|
|
53
|
+
transport.on('accounts.changed', (accounts) => {
|
|
54
|
+
changes += 1;
|
|
55
|
+
store.set(scopeId, accounts);
|
|
56
|
+
}),
|
|
57
|
+
transport.subscribeStatus((status) => {
|
|
58
|
+
if (status === 'open') {
|
|
59
|
+
load();
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
];
|
|
63
|
+
if (transport.status === 'open') {
|
|
64
|
+
load();
|
|
65
|
+
}
|
|
66
|
+
return () => off.forEach((stop) => stop());
|
|
67
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ProviderInfo } from '@adecore/agent-contracts';
|
|
2
|
+
export interface ProvidersRow {
|
|
3
|
+
providers: ProviderInfo[];
|
|
4
|
+
loaded: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface ProvidersStore {
|
|
7
|
+
byScope: Record<string, ProvidersRow>;
|
|
8
|
+
setProviders(scopeId: string, providers: ProviderInfo[]): void;
|
|
9
|
+
forget(scopeId: string): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const useProvidersStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ProvidersStore>>;
|
|
12
|
+
export declare function useProviders<T>(select: (row: ProvidersRow) => T): T;
|
|
13
|
+
export declare function providersOf(scopeId: string): ProvidersRow;
|
|
14
|
+
export declare function providerSinkFor(scopeId: string): {
|
|
15
|
+
setProviders(providers: ProviderInfo[]): void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { useChatScope } from '../scope.js';
|
|
3
|
+
/* One object for a host that has not answered yet, so a selector gets a stable snapshot. */
|
|
4
|
+
const NONE = { providers: [], loaded: false };
|
|
5
|
+
/* Which agent CLIs each host reports, and their models; filled once per connection. */
|
|
6
|
+
export const useProvidersStore = create((set, get) => ({
|
|
7
|
+
byScope: {},
|
|
8
|
+
setProviders(scopeId, providers) {
|
|
9
|
+
set({ byScope: { ...get().byScope, [scopeId]: { providers, loaded: true } } });
|
|
10
|
+
},
|
|
11
|
+
forget(scopeId) {
|
|
12
|
+
const { [scopeId]: _gone, ...rest } = get().byScope;
|
|
13
|
+
set({ byScope: rest });
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
/*
|
|
17
|
+
* The CLIs of the host in scope. An agent menu has to offer what the host the chat will run on has
|
|
18
|
+
* installed, never what another host answered.
|
|
19
|
+
*/
|
|
20
|
+
export function useProviders(select) {
|
|
21
|
+
const { id } = useChatScope();
|
|
22
|
+
return useProvidersStore((s) => select(s.byScope[id] ?? NONE));
|
|
23
|
+
}
|
|
24
|
+
/* The same answer outside a render. */
|
|
25
|
+
export function providersOf(scopeId) {
|
|
26
|
+
return useProvidersStore.getState().byScope[scopeId] ?? NONE;
|
|
27
|
+
}
|
|
28
|
+
/* What one host's chat client fills in; it knows its own host and nothing of the others. */
|
|
29
|
+
export function providerSinkFor(scopeId) {
|
|
30
|
+
return {
|
|
31
|
+
setProviders: (providers) => useProvidersStore.getState().setProviders(scopeId, providers)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { UsageLimitsSnapshot, UsageSummaryPayload, UsageSummaryResult } from '@adecore/agent-contracts';
|
|
2
|
+
import type { UsageCurrency } from '../usage/format.js';
|
|
3
|
+
export type UsagePeriod = 'today' | '7d' | '30d' | '90d';
|
|
4
|
+
export type UsageMetric = 'cost' | 'tokens';
|
|
5
|
+
export declare const USAGE_PERIODS: readonly {
|
|
6
|
+
id: UsagePeriod;
|
|
7
|
+
days: number;
|
|
8
|
+
}[];
|
|
9
|
+
export declare let USAGE_PREFERENCES_KEY: string;
|
|
10
|
+
export declare function usagePreferencesKey(): string;
|
|
11
|
+
interface Preferences {
|
|
12
|
+
period: UsagePeriod;
|
|
13
|
+
metric: UsageMetric;
|
|
14
|
+
currency: UsageCurrency;
|
|
15
|
+
}
|
|
16
|
+
export declare function dayOf(date: Date): string;
|
|
17
|
+
export declare function windowFor(period: UsagePeriod, now?: Date): UsageSummaryPayload;
|
|
18
|
+
export declare function summaryPayload(period: UsagePeriod, account: string | null, now?: Date): UsageSummaryPayload;
|
|
19
|
+
export declare function askedKey(payload: UsageSummaryPayload): string;
|
|
20
|
+
interface UsageRow {
|
|
21
|
+
asked: string | null;
|
|
22
|
+
summary: UsageSummaryResult | null;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
failed: boolean;
|
|
25
|
+
limits: UsageLimitsSnapshot | null;
|
|
26
|
+
}
|
|
27
|
+
interface UsageStore extends Preferences {
|
|
28
|
+
byScope: Record<string, UsageRow>;
|
|
29
|
+
chosen: string | null;
|
|
30
|
+
choose(scopeId: string | null): void;
|
|
31
|
+
setPeriod(period: UsagePeriod): void;
|
|
32
|
+
setMetric(metric: UsageMetric): void;
|
|
33
|
+
setCurrency(currency: UsageCurrency): void;
|
|
34
|
+
setLoading(scopeId: string, loading: boolean): void;
|
|
35
|
+
receive(scopeId: string, asked: string, summary: UsageSummaryResult): void;
|
|
36
|
+
fail(scopeId: string): void;
|
|
37
|
+
setLimits(scopeId: string, limits: UsageLimitsSnapshot): void;
|
|
38
|
+
forget(scopeId: string): void;
|
|
39
|
+
}
|
|
40
|
+
export declare function reloadUsagePreferences(): void;
|
|
41
|
+
export declare const useUsageStore: import("zustand").UseBoundStore<import("zustand").StoreApi<UsageStore>>;
|
|
42
|
+
export type UsageView = Preferences & UsageRow;
|
|
43
|
+
export declare function useUsage<T>(select: (view: UsageView) => T): T;
|
|
44
|
+
export {};
|