@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,9 @@
|
|
|
1
|
+
import type { ChatQuestion } from '@adecore/agent-contracts';
|
|
2
|
+
import { type PromptAnswer } from '../logic/prompts.js';
|
|
3
|
+
export declare function QuestionBody({ question, answer, onAnswer, onCommit, locked }: {
|
|
4
|
+
question: ChatQuestion;
|
|
5
|
+
answer: PromptAnswer;
|
|
6
|
+
onAnswer(answer: PromptAnswer): void;
|
|
7
|
+
onCommit(answer: PromptAnswer): void;
|
|
8
|
+
locked: boolean;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Circle, CircleCheck, Square } from 'lucide-react';
|
|
6
|
+
import { answerFieldKey, choiceKey, stepIndex } from '../logic/keys.js';
|
|
7
|
+
import { pickPromptChoice } from '../logic/prompts.js';
|
|
8
|
+
import { Icon } from '@adecore/ui';
|
|
9
|
+
import { chatHost } from '../../host.js';
|
|
10
|
+
/* One question of a request: its choices, "Something else…", or a written answer when it offers no choices. */
|
|
11
|
+
export function QuestionBody({ question, answer, onAnswer, onCommit, locked }) {
|
|
12
|
+
const { t } = useTranslation('agent-prompts');
|
|
13
|
+
const AnswerField = chatHost().dictation.Textarea;
|
|
14
|
+
// The choices, then the "Something else…" field form one list with a single tab stop.
|
|
15
|
+
const items = useRef([]);
|
|
16
|
+
const shownQuestion = useRef(question.id);
|
|
17
|
+
const count = question.choices.length + 1;
|
|
18
|
+
const chosen = question.choices.findIndex((choice) => !answer.custom && answer.choices.includes(choice.label));
|
|
19
|
+
const tabStop = chosen !== -1 ? chosen : answer.custom ? question.choices.length : 0;
|
|
20
|
+
// The focused choice of the question before is gone once the next one shows; the keyboard goes on in this one.
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (shownQuestion.current === question.id) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
shownQuestion.current = question.id;
|
|
26
|
+
if (document.activeElement === null || document.activeElement === document.body) {
|
|
27
|
+
(items.current[tabStop] ?? items.current[0])?.focus({ preventScroll: true });
|
|
28
|
+
}
|
|
29
|
+
}, [question.id, tabStop]);
|
|
30
|
+
const onChoiceKeyDown = (event, index, label) => {
|
|
31
|
+
const action = choiceKey(event.nativeEvent, {
|
|
32
|
+
multiSelect: question.multiSelect,
|
|
33
|
+
anyChosen: !answer.custom && answer.choices.length > 0
|
|
34
|
+
});
|
|
35
|
+
if (action === null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
if (action.kind === 'move') {
|
|
40
|
+
items.current[stepIndex(index, count, action.to)]?.focus();
|
|
41
|
+
}
|
|
42
|
+
else if (action.kind === 'commit') {
|
|
43
|
+
onCommit(answer);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const next = pickPromptChoice(answer, question, label);
|
|
47
|
+
onAnswer(next);
|
|
48
|
+
if (action.kind === 'pick-and-commit') {
|
|
49
|
+
onCommit(next);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const onFieldKeyDown = (event) => {
|
|
54
|
+
const field = event.currentTarget;
|
|
55
|
+
const action = answerFieldKey(event.nativeEvent, {
|
|
56
|
+
belowChoices: question.choices.length > 0,
|
|
57
|
+
caretAtStart: field.selectionStart === 0 && field.selectionEnd === 0,
|
|
58
|
+
hasText: field.value.trim() !== ''
|
|
59
|
+
});
|
|
60
|
+
if (action === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
if (action.kind === 'to-last-choice') {
|
|
65
|
+
items.current[question.choices.length - 1]?.focus();
|
|
66
|
+
}
|
|
67
|
+
else if (action.kind === 'commit') {
|
|
68
|
+
onCommit({ ...answer, custom: true });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [question.multiSelect && _jsx("p", { className: "text-xs text-text-muted", children: t('question.multiSelect') }), question.choices.length > 0 && (_jsxs("div", { role: question.multiSelect ? 'group' : 'radiogroup', "aria-label": question.question, className: "flex flex-col gap-2", children: [question.choices.map((choice, index) => {
|
|
72
|
+
const selected = !answer.custom && answer.choices.includes(choice.label);
|
|
73
|
+
return (_jsxs("button", { ref: (element) => {
|
|
74
|
+
items.current[index] = element;
|
|
75
|
+
}, type: "button", role: question.multiSelect ? 'checkbox' : 'radio', "aria-checked": selected, tabIndex: index === tabStop ? 0 : -1, "data-prompt-entry": index === tabStop ? '' : undefined, disabled: locked, className: clsx('flex min-h-9 items-start gap-2 rounded-lg border px-3 py-2 text-left disabled:opacity-50', selected ? 'border-accent bg-accent-soft' : 'border-border bg-surface-hover hover:bg-surface-active'), onClick: () => onAnswer(pickPromptChoice(answer, question, choice.label)), onKeyDown: (event) => onChoiceKeyDown(event, index, choice.label), children: [_jsx(Icon, { icon: selected ? CircleCheck : question.multiSelect ? Square : Circle, size: 16, className: "mt-0.5 shrink-0 text-text-muted" }), _jsxs("span", { className: "flex min-w-0 flex-wrap items-baseline gap-x-2", children: [_jsx("span", { className: "text-xs text-text", children: choice.label }), choice.description && _jsx("span", { className: "text-xs text-text-muted", children: choice.description })] })] }, choice.label));
|
|
76
|
+
}), _jsxs("label", { className: clsx('flex min-h-9 items-start gap-2 rounded-lg border px-3 py-2 text-left text-xs text-text focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-accent', answer.custom ? 'border-accent bg-accent-soft' : 'border-border bg-surface-hover', locked && 'opacity-50'),
|
|
77
|
+
// A press picks the row; the keyboard only passing through on its way up or down does not.
|
|
78
|
+
onPointerDown: () => {
|
|
79
|
+
if (!locked && !answer.custom) {
|
|
80
|
+
onAnswer({ ...answer, custom: true });
|
|
81
|
+
}
|
|
82
|
+
}, children: [_jsx(Icon, { icon: answer.custom ? CircleCheck : Circle, size: 16, className: "mt-0.5 shrink-0" }), _jsx(AnswerField, { ref: (element) => {
|
|
83
|
+
items.current[question.choices.length] = element;
|
|
84
|
+
}, rows: 1, tabIndex: tabStop === question.choices.length ? 0 : -1, "data-prompt-entry": tabStop === question.choices.length ? '' : undefined, className: "max-h-40 min-w-0 flex-1 resize-none field-sizing-content bg-transparent outline-none placeholder:text-text-muted", buttonClassName: "-my-1 -mr-1.5", "aria-label": t('question.answerLabel'), placeholder: t('question.somethingElse'), value: answer.text, disabled: locked, onChange: (e) => onAnswer({ ...answer, custom: true, text: e.target.value }), onKeyDown: onFieldKeyDown })] })] })), question.choices.length === 0 && (_jsx(AnswerField, { ref: (element) => {
|
|
85
|
+
items.current[0] = element;
|
|
86
|
+
}, className: "field min-h-20 text-sm", "aria-label": t('question.answerLabel'), placeholder: t('question.answerPlaceholder'), "data-prompt-entry": "", value: answer.text, disabled: locked, onChange: (e) => onAnswer({ ...answer, text: e.target.value }), onKeyDown: onFieldKeyDown }))] }));
|
|
87
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AccentSwatches } from '@adecore/ui';
|
|
3
|
+
import { chatHost } from '../host.js';
|
|
4
|
+
/* The colors an account may wear, the host's palette. */
|
|
5
|
+
export function AccountColors({ value, label, onChange }) {
|
|
6
|
+
const { all, featured, label: labelOf } = chatHost().accents;
|
|
7
|
+
return _jsx(AccentSwatches, { value: value, label: label, accents: all, featured: featured, labelOf: labelOf, onValueChange: onChange });
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProviderInfo } from '@adecore/agent-contracts';
|
|
2
|
+
import { type AccountEntry } from '../agents/accounts.js';
|
|
3
|
+
interface AccountDetailProps {
|
|
4
|
+
provider: ProviderInfo;
|
|
5
|
+
entry: AccountEntry;
|
|
6
|
+
canLogIn: boolean;
|
|
7
|
+
loginBlocked: string | null;
|
|
8
|
+
secretsAvailable: boolean;
|
|
9
|
+
onRemoved(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function AccountDetail({ provider, entry, canLogIn, loginBlocked, secretsAvailable, onRemoved }: AccountDetailProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
4
|
+
import { LogIn } from 'lucide-react';
|
|
5
|
+
import { AccountDot } from '../agents/AccountDot.js';
|
|
6
|
+
import { accountName, FOLDER_VARIABLES } from '../agents/accounts.js';
|
|
7
|
+
import { ConfirmDialog, DetailHeader, SettingsRow, SettingsSection } from '@adecore/ui/settings';
|
|
8
|
+
import { Button, copyText, Icon, Input, Switch, Tooltip } from '@adecore/ui';
|
|
9
|
+
import { chatHost } from '../host.js';
|
|
10
|
+
import { useChatScope } from '../scope.js';
|
|
11
|
+
import { removeAccount, saveAccount } from './account-actions.js';
|
|
12
|
+
import { AccountVariables } from './AccountVariables.js';
|
|
13
|
+
import { AccountColors } from './AccountColors.js';
|
|
14
|
+
import { CliMark } from './parts.js';
|
|
15
|
+
// The states in which the machine's own sentence says more than the usual line under the login.
|
|
16
|
+
const TROUBLE = new Set(['folder-missing', 'unavailable', 'failed']);
|
|
17
|
+
/* The name a person types, saved when they leave the field; an empty one goes back to what was there. */
|
|
18
|
+
function NameField({ value, label, onSave }) {
|
|
19
|
+
const [draft, setDraft] = useState(value);
|
|
20
|
+
const commit = () => {
|
|
21
|
+
const name = draft.trim();
|
|
22
|
+
if (name === '' || name === value) {
|
|
23
|
+
setDraft(value);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
onSave(name);
|
|
27
|
+
};
|
|
28
|
+
return (_jsx(Input, { className: "w-55 max-w-full", value: draft, maxLength: 80, "aria-label": label, onChange: (event) => setDraft(event.target.value), onBlur: commit, onKeyDown: (event) => {
|
|
29
|
+
if (event.key === 'Enter') {
|
|
30
|
+
event.currentTarget.blur();
|
|
31
|
+
}
|
|
32
|
+
} }));
|
|
33
|
+
}
|
|
34
|
+
/* One account: how it looks in a picker, who is signed in, where its folder is, its variables. */
|
|
35
|
+
export function AccountDetail({ provider, entry, canLogIn, loginBlocked, secretsAvailable, onRemoved }) {
|
|
36
|
+
const { t } = useTranslation('agent-providers');
|
|
37
|
+
const scope = useChatScope();
|
|
38
|
+
const [confirming, setConfirming] = useState(false);
|
|
39
|
+
const { id, account, status, isDefault } = entry;
|
|
40
|
+
const name = accountName(entry, provider.name);
|
|
41
|
+
const folder = status?.home ?? '';
|
|
42
|
+
const variable = FOLDER_VARIABLES[provider.kind];
|
|
43
|
+
const signedIn = status?.state === 'ready';
|
|
44
|
+
const showFolder = () => {
|
|
45
|
+
copyText(folder);
|
|
46
|
+
chatHost().notify({ kind: 'success', title: t('account.folderCopied'), description: folder });
|
|
47
|
+
};
|
|
48
|
+
const loginDetail = () => {
|
|
49
|
+
if (status !== null && TROUBLE.has(status.state) && status.message) {
|
|
50
|
+
return status.message;
|
|
51
|
+
}
|
|
52
|
+
if (!signedIn) {
|
|
53
|
+
return t('account.login.signedOutDetail');
|
|
54
|
+
}
|
|
55
|
+
return status?.plan ? t('account.login.planDetail', { plan: status.plan }) : t('account.login.detail');
|
|
56
|
+
};
|
|
57
|
+
const loginButton = (_jsxs(Button, { variant: "secondary", disabled: loginBlocked !== null, onClick: () => void chatHost().openLogin?.(scope.id, provider.kind, id, name), children: [_jsx(Icon, { icon: LogIn, size: 14 }), signedIn ? t('account.login.logInAgain') : t('account.login.logIn')] }));
|
|
58
|
+
return (_jsxs(_Fragment, { children: [_jsx(DetailHeader, { mark: _jsx("span", { className: "grid h-6 shrink-0 place-items-center", children: _jsx(AccountDot, { color: account.color, className: "size-3" }) }), title: name, subtitle: _jsxs(_Fragment, { children: [_jsx(CliMark, { kind: provider.kind, size: 12, className: "text-text-muted" }), t('account.kind', { provider: provider.name })] }), actions: folder !== '' && (_jsx(Button, { variant: "secondary", onClick: showFolder, children: t('account.showFolder') })) }), _jsxs(SettingsSection, { children: [_jsx(SettingsRow, { label: t('account.enabled.label'), description: t('account.enabled.description'), control: _jsx(Switch, { checked: account.enabled !== false, label: t('account.enabled.label'), onCheckedChange: (checked) => {
|
|
59
|
+
const { enabled: _enabled, ...rest } = account;
|
|
60
|
+
void saveAccount(scope, id, checked ? rest : { ...rest, enabled: false });
|
|
61
|
+
} }) }), _jsx(SettingsRow, { label: t('account.name'), control: _jsx(NameField, { value: name, label: t('account.name'), onSave: (label) => void saveAccount(scope, id, { ...account, label }) }, name) }), _jsx(SettingsRow, { label: t('account.color'), control: _jsx(AccountColors, { value: account.color, label: t('account.color'), onChange: (color) => void saveAccount(scope, id, { ...account, color }) }) })] }), canLogIn && (_jsxs(SettingsSection, { title: t('account.login.title'), children: [_jsx(SettingsRow, { label: signedIn
|
|
62
|
+
? status?.email
|
|
63
|
+
? t('account.login.signedInAs', { email: status.email })
|
|
64
|
+
: t('account.login.signedIn')
|
|
65
|
+
: t('account.login.signedOut'), description: loginBlocked === null ? loginDetail() : `${loginDetail()} ${loginBlocked}`, control: loginBlocked === null ? (loginButton) : (_jsx(Tooltip, { label: loginBlocked, children: _jsx("span", { className: "inline-flex", children: loginButton }) })) }), _jsxs(SettingsRow, { label: t('account.folder.label'), children: [_jsx(Input, { mono: true, className: "h-8.5", value: folder, readOnly: true, "aria-label": t('account.folder.label') }), _jsx("p", { className: "-mt-1 text-xs text-text-muted", children: variable ? (_jsx(Trans, { t: t, i18nKey: "account.folder.detail", values: { variable }, components: { code: _jsx("code", { className: "font-mono text-code" }) } })) : (t('account.folder.detailPlain')) })] })] })), _jsx(AccountVariables, { id: id, account: account, secretsAvailable: secretsAvailable }, `${id}:${JSON.stringify(account.env ?? [])}`), _jsx(SettingsSection, { children: _jsx(SettingsRow, { label: t('account.remove.label'), description: isDefault ? t('account.remove.defaultNote') : t('account.remove.description'), control: _jsx(Button, { variant: "danger-outline", disabled: isDefault, onClick: () => setConfirming(true), children: t('account.remove.button') }) }) }), _jsx(ConfirmDialog, { open: confirming, onOpenChange: setConfirming, title: t('account.remove.confirmTitle', { account: name }), description: t('account.remove.confirmDescription', { folder }), confirmLabel: t('account.remove.confirm'), onConfirm: async () => {
|
|
66
|
+
await removeAccount(scope, id, provider.kind);
|
|
67
|
+
onRemoved();
|
|
68
|
+
} })] }));
|
|
69
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProviderAccount } from '@adecore/agent-contracts';
|
|
2
|
+
interface AccountVariablesProps {
|
|
3
|
+
id: string;
|
|
4
|
+
account: ProviderAccount;
|
|
5
|
+
secretsAvailable: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function AccountVariables({ id, account, secretsAvailable }: AccountVariablesProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { Lock, LockOpen, Plus, X } from 'lucide-react';
|
|
5
|
+
import { useChatScope } from '../scope.js';
|
|
6
|
+
import { saveAccount } from './account-actions.js';
|
|
7
|
+
import { draftsOf, emptyDraft, variablesChanged, variablesOf, variablesProblem } from './variables.js';
|
|
8
|
+
import { SettingsRow, SettingsSection } from '@adecore/ui/settings';
|
|
9
|
+
import { Button, FormError, Icon, IconButton, Input, Tooltip } from '@adecore/ui';
|
|
10
|
+
/*
|
|
11
|
+
* The environment of one account, edited as a whole and saved with one button: a half-typed name or a
|
|
12
|
+
* secret that still has to be retyped would otherwise reach the machine one keystroke at a time.
|
|
13
|
+
*/
|
|
14
|
+
export function AccountVariables({ id, account, secretsAvailable }) {
|
|
15
|
+
const { t } = useTranslation('agent-providers');
|
|
16
|
+
const scope = useChatScope();
|
|
17
|
+
const [drafts, setDrafts] = useState(() => draftsOf(account.env));
|
|
18
|
+
const [saving, setSaving] = useState(false);
|
|
19
|
+
const changed = variablesChanged(drafts, account.env);
|
|
20
|
+
const problem = changed ? variablesProblem(drafts) : null;
|
|
21
|
+
const update = (key, patch) => {
|
|
22
|
+
setDrafts((current) => current.map((draft) => (draft.key === key ? { ...draft, ...patch } : draft)));
|
|
23
|
+
};
|
|
24
|
+
const save = async () => {
|
|
25
|
+
const env = variablesOf(drafts);
|
|
26
|
+
const { env: _env, ...rest } = account;
|
|
27
|
+
setSaving(true);
|
|
28
|
+
try {
|
|
29
|
+
await saveAccount(scope, id, env.length === 0 ? rest : { ...rest, env });
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
setSaving(false);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return (_jsxs(SettingsSection, { title: t('account.variables.title'), description: t('account.variables.description'), action: _jsxs(Button, { variant: "secondary", size: "sm", onClick: () => setDrafts((current) => [...current, emptyDraft(false)]), children: [_jsx(Icon, { icon: Plus, size: 14 }), t('account.variables.add')] }), footer: secretsAvailable ? undefined : t('account.variables.noKeychain'), children: [drafts.length === 0 && _jsx(SettingsRow, { muted: true, label: t('account.variables.none') }), drafts.map((draft, index) => {
|
|
36
|
+
const name = draft.name.trim() || String(index + 1);
|
|
37
|
+
const kept = draft.value === '' && draft.sensitive && draft.kept === draft.name.trim();
|
|
38
|
+
const lockLabel = draft.sensitive ? t('account.variables.unlock', { name }) : t('account.variables.lock', { name });
|
|
39
|
+
// Off a keychain a value can only be made plain, never secret.
|
|
40
|
+
const lockDisabled = !secretsAvailable && !draft.sensitive;
|
|
41
|
+
return (_jsxs("div", { className: "flex min-w-0 items-center gap-2 px-3.5 py-3 font-mono text-code", children: [_jsx(Input, { mono: true, className: "h-7.5 w-47.5 shrink-0 max-[640px]:w-32", value: draft.name, spellCheck: false, autoComplete: "off", "aria-label": t('account.variables.name', { index: index + 1 }), placeholder: "NAME", onChange: (event) => update(draft.key, { name: event.target.value }) }), _jsx("span", { className: "text-text-faint", children: "=" }), _jsx(Input, { mono: true, className: "h-7.5 min-w-0 grow", type: draft.sensitive ? 'password' : 'text', value: draft.value, spellCheck: false, autoComplete: "off", "aria-label": t('account.variables.value', { name }), placeholder: kept ? t('account.variables.kept') : undefined, onChange: (event) => update(draft.key, { value: event.target.value }) }), _jsx(Tooltip, { label: lockDisabled ? t('account.variables.noKeychain') : lockLabel, children: _jsx("span", { className: "inline-flex", children: _jsx(IconButton, { icon: draft.sensitive ? Lock : LockOpen, size: "sm", label: lockLabel, tooltip: false, className: draft.sensitive ? 'text-text' : undefined, "aria-pressed": draft.sensitive, disabled: lockDisabled, onClick: () => update(draft.key, { sensitive: !draft.sensitive }) }) }) }), _jsx(IconButton, { icon: X, size: "sm", label: t('account.variables.remove', { name }), onClick: () => setDrafts((current) => current.filter((other) => other.key !== draft.key)) })] }, draft.key));
|
|
42
|
+
}), changed && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center justify-end gap-2 px-4.5 py-3", children: [problem !== null && (_jsx(FormError, { render: _jsx("span", {}), className: "mr-auto", children: problem })), _jsx(Button, { onClick: () => setDrafts(draftsOf(account.env)), children: t('account.variables.discard') }), _jsx(Button, { variant: "primary", disabled: problem !== null || saving, onClick: () => void save(), children: t('common.save') })] }))] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProviderInfo } from '@adecore/agent-contracts';
|
|
2
|
+
import { type AccountEntry } from '../agents/accounts.js';
|
|
3
|
+
interface AddAccountFormProps {
|
|
4
|
+
provider: ProviderInfo;
|
|
5
|
+
entries: AccountEntry[];
|
|
6
|
+
onCancel(): void;
|
|
7
|
+
onAdded(id: string, name: string, made: boolean): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function AddAccountForm({ provider, entries, onCancel, onAdded }: AddAccountFormProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { ChevronRight } from 'lucide-react';
|
|
6
|
+
import { freeAccountColor, mintAccountId } from '../agents/accounts.js';
|
|
7
|
+
import { chatHost } from '../host.js';
|
|
8
|
+
import { useChatScope } from '../scope.js';
|
|
9
|
+
import { createAccount, linkAccount } from './account-actions.js';
|
|
10
|
+
import { AccountColors } from './AccountColors.js';
|
|
11
|
+
import { DetailHeader, SettingsRow, SettingsSection } from '@adecore/ui/settings';
|
|
12
|
+
import { Button, FormError, Icon, Input } from '@adecore/ui';
|
|
13
|
+
import { CliTile } from './parts.js';
|
|
14
|
+
import { providerAccountsOf } from '../state/provider-accounts.js';
|
|
15
|
+
/*
|
|
16
|
+
* A name and a color, asked before anything exists, so the account is made once with both. By default
|
|
17
|
+
* the machine makes the folder; under Advanced a person points at a folder of their own instead.
|
|
18
|
+
*/
|
|
19
|
+
export function AddAccountForm({ provider, entries, onCancel, onAdded }) {
|
|
20
|
+
const { t } = useTranslation('agent-providers');
|
|
21
|
+
const scope = useChatScope();
|
|
22
|
+
const [name, setName] = useState('');
|
|
23
|
+
const [color, setColor] = useState(() => freeAccountColor(entries, chatHost().accents.current()));
|
|
24
|
+
const [advanced, setAdvanced] = useState(false);
|
|
25
|
+
const [folder, setFolder] = useState('');
|
|
26
|
+
const [busy, setBusy] = useState(false);
|
|
27
|
+
const [error, setError] = useState(null);
|
|
28
|
+
const label = name.trim();
|
|
29
|
+
const linking = advanced && folder.trim() !== '';
|
|
30
|
+
const submit = async (event) => {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
if (label === '' || busy) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setBusy(true);
|
|
36
|
+
setError(null);
|
|
37
|
+
try {
|
|
38
|
+
if (linking) {
|
|
39
|
+
const taken = new Set(Object.keys(providerAccountsOf(scope.id).accounts?.accounts ?? {}));
|
|
40
|
+
const id = mintAccountId(provider.kind, label, taken);
|
|
41
|
+
await linkAccount(scope, id, { kind: provider.kind, label, color, home: folder.trim() });
|
|
42
|
+
onAdded(id, label, false);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
onAdded(await createAccount(scope, provider.kind, label, color), label, true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
50
|
+
setBusy(false);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return (_jsxs("form", { className: "contents", onSubmit: (event) => void submit(event), children: [_jsx(DetailHeader, { mark: _jsx(CliTile, { kind: provider.kind }), title: t('add.title', { provider: provider.name }), subtitle: t('add.description') }), _jsxs(SettingsSection, { children: [_jsx(SettingsRow, { label: t('add.name'), control: _jsx(Input, { className: "w-55 max-w-full", value: name, maxLength: 80, autoFocus: true, placeholder: t('add.namePlaceholder'), "aria-label": t('add.name'), onChange: (event) => setName(event.target.value) }) }), _jsx(SettingsRow, { label: t('add.color'), control: _jsx(AccountColors, { value: color, label: t('add.color'), onChange: setColor }) })] }), _jsxs("div", { className: "flex min-w-0 flex-col gap-2.5", children: [_jsxs("button", { type: "button", "aria-expanded": advanced, className: "flex items-center gap-1.5 self-start text-sm font-medium text-text-muted hover:text-text", onClick: () => setAdvanced((open) => !open), children: [_jsx(Icon, { icon: ChevronRight, size: 14, className: clsx('transition-transform', advanced && 'rotate-90') }), t('add.advanced')] }), advanced && (_jsx(SettingsSection, { children: _jsx(SettingsRow, { label: t('add.link.label'), description: t('add.link.description'), children: _jsx(Input, { mono: true, value: folder, spellCheck: false, autoComplete: "off", placeholder: t('add.link.placeholder'), "aria-label": t('add.link.label'), onChange: (event) => setFolder(event.target.value) }) }) }))] }), _jsxs("div", { className: "flex min-w-0 flex-wrap items-center justify-end gap-2", children: [error !== null && (_jsx(FormError, { render: _jsx("span", {}), className: "mr-auto break-words", children: error || t('add.failed') })), _jsx(Button, { onClick: onCancel, children: t('common.cancel') }), _jsx(Button, { type: "submit", variant: "primary", disabled: label === '' || busy, children: linking ? t('add.linkButton') : t('add.create') })] })] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProviderInfo } from '@adecore/agent-contracts';
|
|
2
|
+
import { type AccountEntry } from '../agents/accounts.js';
|
|
3
|
+
interface CliDetailProps {
|
|
4
|
+
provider: ProviderInfo;
|
|
5
|
+
entries: AccountEntry[] | null;
|
|
6
|
+
defaults: boolean;
|
|
7
|
+
canAddAccount: boolean;
|
|
8
|
+
onAddAccount(): void;
|
|
9
|
+
onPickAccount(id: string): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function CliDetail({ provider, entries, defaults, canAddAccount, onAddAccount, onPickAccount }: CliDetailProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { ChevronRight, Plus } from 'lucide-react';
|
|
4
|
+
import { AccountDot } from '../agents/AccountDot.js';
|
|
5
|
+
import { ModelOptionControl } from '../agents/ModelOptionControl.js';
|
|
6
|
+
import { carryOptions } from '../agents/model-options.js';
|
|
7
|
+
import { ACCOUNT_TONE_CLASSES, accountName, accountStatusLine } from '../agents/accounts.js';
|
|
8
|
+
import { accountFor, forgetChatSelection, rememberChatAccount, rememberChatSelection, selectionFor, useChatPreferences } from '../chat/preferences.js';
|
|
9
|
+
import { useChatScope } from '../scope.js';
|
|
10
|
+
import { providerAbilities } from './provider-abilities.js';
|
|
11
|
+
import { DetailHeader, SettingsRow, SettingsSection } from '@adecore/ui/settings';
|
|
12
|
+
import { Button, Icon, Select } from '@adecore/ui';
|
|
13
|
+
import { CliTile } from './parts.js';
|
|
14
|
+
import { useProviderAccountsStore } from '../state/provider-accounts.js';
|
|
15
|
+
const PROVIDER_DEFAULT = '';
|
|
16
|
+
/* One row per knob the chosen model exposes; the composer's option picker shows the same descriptors. */
|
|
17
|
+
function ModelOptionRows({ provider, model, options }) {
|
|
18
|
+
const setOption = (id, value) => {
|
|
19
|
+
rememberChatSelection(provider, { model: model.slug, options: { ...options, [id]: value } });
|
|
20
|
+
};
|
|
21
|
+
return (_jsx(_Fragment, { children: model.options.map((option) => (_jsx(SettingsRow, { indent: true, muted: true, label: option.label, control: _jsx(ModelOptionControl, { option: option, options: options, layout: "row", onChange: (value) => setOption(option.id, value) }) }, option.id))) }));
|
|
22
|
+
}
|
|
23
|
+
/* One CLI: what it is, what a new chat of it starts with unless `defaults` is off, and its accounts. */
|
|
24
|
+
export function CliDetail({ provider, entries, defaults, canAddAccount, onAddAccount, onPickAccount }) {
|
|
25
|
+
const { t } = useTranslation('agent-providers');
|
|
26
|
+
const { id: scopeId } = useChatScope();
|
|
27
|
+
const preferences = useChatPreferences();
|
|
28
|
+
const selection = selectionFor(preferences, provider.kind);
|
|
29
|
+
const model = provider.models.find((entry) => entry.slug === selection?.model);
|
|
30
|
+
const machineAccounts = useProviderAccountsStore((s) => (s.byScope[scopeId]?.loaded ? s.byScope[scopeId].accounts : undefined));
|
|
31
|
+
const picked = accountFor(preferences, scopeId, provider.kind, machineAccounts) ?? provider.kind;
|
|
32
|
+
// An account that is off is out of every picker, unless it is the one picked already.
|
|
33
|
+
const choosable = (entries ?? []).filter((entry) => entry.account.enabled !== false || entry.id === picked);
|
|
34
|
+
const canLogIn = canAddAccount;
|
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsx(DetailHeader, { mark: _jsx(CliTile, { kind: provider.kind }), title: provider.name, subtitle: `${provider.version ? `${t('abilities.version', { version: provider.version })} ` : ''}${providerAbilities(provider)}`, actions: canAddAccount && (_jsxs(Button, { variant: "secondary", className: "whitespace-nowrap", onClick: onAddAccount, children: [_jsx(Icon, { icon: Plus, size: 14 }), t('cli.addAccount')] })) }), defaults && (_jsxs(SettingsSection, { title: t('cli.defaults.title'), description: t('cli.defaults.description'), children: [choosable.length > 0 && (_jsx(SettingsRow, { searchId: "providers.defaults.account", label: t('cli.defaults.account'), control: _jsx(Select, { value: picked, label: t('cli.defaults.accountFor', { provider: provider.name }), align: "end", items: choosable.map((entry) => ({
|
|
36
|
+
value: entry.id,
|
|
37
|
+
label: accountName(entry, provider.name),
|
|
38
|
+
icon: _jsx(AccountDot, { color: entry.account.color, className: "size-2" })
|
|
39
|
+
})), onValueChange: (id) => rememberChatAccount(scopeId, provider.kind, id) }) })), provider.models.length > 0 && (_jsx(SettingsRow, { searchId: "providers.defaults.model", label: t('cli.defaults.model'), description: model ? t('cli.defaults.shared', { provider: provider.name }) : t('cli.defaults.usesCliDefault'), control: _jsx(Select, { value: model?.slug ?? PROVIDER_DEFAULT, label: t('cli.defaults.modelFor', { provider: provider.name }), align: "end", items: [
|
|
40
|
+
{ value: PROVIDER_DEFAULT, label: t('cli.defaults.providerDefault') },
|
|
41
|
+
...provider.models.map((entry) => ({
|
|
42
|
+
value: entry.slug,
|
|
43
|
+
label: entry.legacy ? t('cli.defaults.legacyModel', { name: entry.name }) : entry.name
|
|
44
|
+
}))
|
|
45
|
+
], onValueChange: (value) => value === PROVIDER_DEFAULT
|
|
46
|
+
? forgetChatSelection(provider.kind)
|
|
47
|
+
: rememberChatSelection(provider.kind, {
|
|
48
|
+
model: value,
|
|
49
|
+
options: carryOptions(selection?.options ?? {}, provider.models.find((entry) => entry.slug === value))
|
|
50
|
+
}) }) })), model && _jsx(ModelOptionRows, { provider: provider.kind, model: model, options: selection?.options ?? {} }), choosable.length === 0 && provider.models.length === 0 && _jsx(SettingsRow, { muted: true, label: t('cli.defaults.usesCliDefault') })] })), entries === null ? (_jsx("p", { className: "text-xs text-text-faint", children: t('list.noAccounts') })) : (_jsx(SettingsSection, { title: t('cli.accounts'), footer: canAddAccount ? undefined : t('cli.onlyDefault', { provider: provider.name }), children: entries.map((entry) => {
|
|
51
|
+
const status = accountStatusLine(entry.status, canLogIn);
|
|
52
|
+
return (_jsxs("button", { type: "button", className: "flex w-full min-w-0 items-center gap-3 px-4.5 py-3 text-left first:rounded-t-xl last:rounded-b-xl hover:bg-surface-hover", onClick: () => onPickAccount(entry.id), children: [_jsx(AccountDot, { color: entry.account.color }), _jsx("span", { className: "min-w-0 grow truncate text-sm text-text", children: accountName(entry, provider.name) }), _jsx("span", { className: `shrink-0 text-xs ${ACCOUNT_TONE_CLASSES[status.tone]}`, children: status.text }), _jsx(Icon, { icon: ChevronRight, size: 14, className: "shrink-0 text-text-faint" })] }, entry.id));
|
|
53
|
+
}) }))] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { ProviderInfo } from '@adecore/agent-contracts';
|
|
3
|
+
interface ProvidersPaneProps {
|
|
4
|
+
target?: string | null;
|
|
5
|
+
detailOf?(provider: ProviderInfo): ReactNode | null;
|
|
6
|
+
defaults?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ProvidersPane({ target, detailOf, defaults }: ProvidersPaneProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Plus, Terminal } from 'lucide-react';
|
|
6
|
+
import { AccountDot } from '../agents/AccountDot.js';
|
|
7
|
+
import { ACCOUNT_TONE_CLASSES, accountName, accountsOfKind, accountStatusLine } from '../agents/accounts.js';
|
|
8
|
+
import { ErrorBoundary, Icon, IconButton, SectionLabel, Skeleton } from '@adecore/ui';
|
|
9
|
+
import { MasterDetail } from '@adecore/ui/settings';
|
|
10
|
+
import { chatHost } from '../host.js';
|
|
11
|
+
import { useChatScope } from '../scope.js';
|
|
12
|
+
import { AccountDetail } from './AccountDetail.js';
|
|
13
|
+
import { AddAccountForm } from './AddAccountForm.js';
|
|
14
|
+
import { CliDetail } from './CliDetail.js';
|
|
15
|
+
import { CliMark } from './parts.js';
|
|
16
|
+
import { useProviderAccounts } from '../state/provider-accounts.js';
|
|
17
|
+
import { useProviders } from '../state/providers.js';
|
|
18
|
+
/* A row of the list with a control of its own beside the part that picks it, so the two never nest. */
|
|
19
|
+
function ListRow({ selected, onSelect, children, trailing, className }) {
|
|
20
|
+
return (_jsxs("div", { className: clsx('flex min-w-0 shrink-0 items-center gap-2 rounded-lg pr-2', selected ? 'bg-text/5' : 'hover:bg-surface-hover', className), children: [_jsx("button", { type: "button", "aria-current": selected ? 'true' : undefined, className: "flex min-w-0 grow items-center gap-3 self-stretch rounded-lg py-2 pl-3 text-left focus-visible:-outline-offset-2", onClick: onSelect, children: children }), trailing] }));
|
|
21
|
+
}
|
|
22
|
+
/* The agent CLIs of the host in scope, each with its accounts, beside the detail of what is picked. */
|
|
23
|
+
export function ProvidersPane({ target = null, detailOf, defaults = true }) {
|
|
24
|
+
const { t } = useTranslation('agent-providers');
|
|
25
|
+
const { id: scopeId } = useChatScope();
|
|
26
|
+
const providers = useProviders((s) => s.providers);
|
|
27
|
+
const loaded = useProviders((s) => s.loaded);
|
|
28
|
+
const accounts = useProviderAccounts((s) => s.accounts);
|
|
29
|
+
const { openLogin } = chatHost();
|
|
30
|
+
const loginBlocked = chatHost().useLoginBlocked(scopeId);
|
|
31
|
+
const [picked, setPicked] = useState(() => (target === 'providers.apple' ? { kind: 'cli', cli: 'apple' } : null));
|
|
32
|
+
const installed = useMemo(() => providers.filter((provider) => provider.installed || provider.kind === 'apple'), [providers]);
|
|
33
|
+
const missing = useMemo(() => providers.filter((provider) => !provider.installed && provider.kind !== 'apple'), [providers]);
|
|
34
|
+
const entriesOf = (kind) => accountsOfKind(accounts, kind);
|
|
35
|
+
const canAddAccount = (kind) => accounts?.loginCommands?.[kind] !== undefined;
|
|
36
|
+
// What was picked may be gone since (an account removed elsewhere); the first CLI stands in for it.
|
|
37
|
+
const pickedEntry = picked?.kind === 'account' ? (Object.hasOwn(accounts?.accounts ?? {}, picked.id) ? picked.id : null) : null;
|
|
38
|
+
const current = picked !== null && (picked.kind !== 'account' || pickedEntry !== null) ? picked : installed[0] ? { kind: 'cli', cli: installed[0].kind } : null;
|
|
39
|
+
const currentAccount = current?.kind === 'account' ? accounts?.accounts[current.id] : undefined;
|
|
40
|
+
const currentCli = current === null ? null : current.kind === 'account' ? currentAccount?.kind : current.cli;
|
|
41
|
+
const provider = installed.find((entry) => entry.kind === currentCli) ?? null;
|
|
42
|
+
// A search result lands on a row of a CLI's detail, so a picked account makes way for its CLI.
|
|
43
|
+
const [seenTarget, setSeenTarget] = useState(target);
|
|
44
|
+
if (target !== seenTarget) {
|
|
45
|
+
setSeenTarget(target);
|
|
46
|
+
if (target === 'providers.apple') {
|
|
47
|
+
setPicked({ kind: 'cli', cli: 'apple' });
|
|
48
|
+
}
|
|
49
|
+
else if (target?.startsWith('providers.') && current?.kind !== 'cli' && provider !== null) {
|
|
50
|
+
setPicked({ kind: 'cli', cli: provider.kind });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const added = (id, name, made) => {
|
|
54
|
+
setPicked({ kind: 'account', id });
|
|
55
|
+
if (made && provider !== null && openLogin !== null && loginBlocked === null) {
|
|
56
|
+
void openLogin(scopeId, provider.kind, id, name);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const group = (cli) => {
|
|
60
|
+
const entries = cli.installed ? entriesOf(cli.kind) : [];
|
|
61
|
+
return (_jsxs("div", { className: "flex min-w-0 shrink-0 flex-col gap-0.5 pt-1", children: [_jsxs(ListRow, { selected: current?.kind === 'cli' && current.cli === cli.kind, onSelect: () => setPicked({ kind: 'cli', cli: cli.kind }), className: "pr-1", trailing: canAddAccount(cli.kind) && (_jsx(IconButton, { icon: Plus, size: "sm", label: t('list.addAccount', { provider: cli.name }), onClick: () => setPicked({ kind: 'add', cli: cli.kind }) })), children: [_jsx(CliMark, { kind: cli.kind }), _jsx("span", { className: "min-w-0 grow truncate text-xs font-medium text-text", children: cli.name }), cli.kind !== 'apple' && cli.version && _jsx("span", { className: "shrink-0 font-mono text-code text-text-faint", children: cli.version })] }), entries.map((entry) => {
|
|
62
|
+
const name = accountName(entry, cli.name);
|
|
63
|
+
const status = accountStatusLine(entry.status, canAddAccount(cli.kind));
|
|
64
|
+
return (_jsxs(ListRow, { selected: current?.kind === 'account' && current.id === entry.id, onSelect: () => setPicked({ kind: 'account', id: entry.id }), children: [_jsx("span", { className: "grid w-3.5 shrink-0 place-items-center", children: _jsx(AccountDot, { color: entry.account.color, className: "size-2.25" }) }), _jsxs("span", { className: "flex min-w-0 grow flex-col", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2 text-sm text-text", children: [_jsx("span", { className: "truncate", children: name }), entry.isDefault && (_jsx("span", { className: "shrink-0 rounded-md bg-surface-active px-1.5 text-xs text-text-muted", children: t('list.default') }))] }), _jsx("span", { className: clsx('truncate text-xs', ACCOUNT_TONE_CLASSES[status.tone]), children: status.text })] })] }, entry.id));
|
|
65
|
+
})] }, cli.kind));
|
|
66
|
+
};
|
|
67
|
+
const list = !loaded ? (_jsxs("div", { className: "flex flex-col gap-3 p-3", children: [_jsx(Skeleton, { className: "w-32" }), _jsx(Skeleton, { className: "w-40" })] })) : (_jsxs(_Fragment, { children: [installed.map(group), installed.length === 0 && _jsx("p", { className: "px-3 py-2 text-xs text-text-muted", children: t('list.none') }), missing.length > 0 && (_jsxs("div", { className: "mt-1.5 flex min-w-0 shrink-0 flex-col border-t border-border pt-2.5 pb-2", children: [_jsx(SectionLabel, { className: "px-3 pt-1 pb-1.5", children: t('list.notInstalled') }), missing.map((cli) => (_jsxs("div", { className: "flex h-10 min-w-0 items-center gap-3 px-3 text-sm text-text-muted", children: [_jsx(Icon, { icon: Terminal, size: 14, className: "shrink-0" }), _jsx("span", { className: "min-w-0 grow truncate", children: cli.name }), _jsx("span", { className: "shrink-0 text-xs text-text-faint", children: t('list.missing') })] }, cli.kind))), _jsx("p", { className: "mt-1 px-3 text-xs text-text-faint", children: t('list.notInstalledNote') })] }))] }));
|
|
68
|
+
const detail = () => {
|
|
69
|
+
if (current === null || provider === null) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const own = current.kind === 'cli' ? (detailOf?.(provider) ?? null) : null;
|
|
73
|
+
if (own !== null) {
|
|
74
|
+
return own;
|
|
75
|
+
}
|
|
76
|
+
if (current.kind === 'add') {
|
|
77
|
+
return (_jsx(AddAccountForm, { provider: provider, entries: entriesOf(provider.kind), onCancel: () => setPicked({ kind: 'cli', cli: provider.kind }), onAdded: added }, provider.kind));
|
|
78
|
+
}
|
|
79
|
+
if (current.kind === 'account') {
|
|
80
|
+
const entry = entriesOf(provider.kind).find((candidate) => candidate.id === current.id);
|
|
81
|
+
return (entry && (_jsx(AccountDetail, { provider: provider, entry: entry, canLogIn: openLogin !== null && canAddAccount(provider.kind), loginBlocked: loginBlocked, secretsAvailable: accounts?.secretsAvailable === true, onRemoved: () => setPicked({ kind: 'cli', cli: provider.kind }) }, entry.id)));
|
|
82
|
+
}
|
|
83
|
+
return (_jsx(CliDetail, { provider: provider, entries: accounts === null ? null : entriesOf(provider.kind), defaults: defaults, canAddAccount: canAddAccount(provider.kind), onAddAccount: () => setPicked({ kind: 'add', cli: provider.kind }), onPickAccount: (id) => setPicked({ kind: 'account', id }) }));
|
|
84
|
+
};
|
|
85
|
+
return (_jsx(MasterDetail, { listWidth: 340, listLabel: t('list.label'), list: list, detail: _jsx(ErrorBoundary, { label: t('failed'), resetKeys: [scopeId, current?.kind, currentCli], children: _jsx("div", { className: "flex min-w-0 flex-col gap-7", children: detail() }) }) }));
|
|
86
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AgentKind, ProviderAccount, ProviderAccountMap } from '@adecore/agent-contracts';
|
|
2
|
+
import type { ChatScope } from '../scope.js';
|
|
3
|
+
export declare function saveAccounts(scope: ChatScope, accounts: ProviderAccountMap): Promise<boolean>;
|
|
4
|
+
export declare function saveAccount(scope: ChatScope, id: string, account: ProviderAccount): Promise<boolean>;
|
|
5
|
+
export declare function removeAccount(scope: ChatScope, id: string, kind: AgentKind): Promise<void>;
|
|
6
|
+
export declare function createAccount(scope: ChatScope, kind: AgentKind, label: string, color: string): Promise<string>;
|
|
7
|
+
export declare function linkAccount(scope: ChatScope, id: string, account: ProviderAccount): Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import { accountFor, readChatPreferences, rememberChatAccount } from '../chat/preferences.js';
|
|
3
|
+
import { chatHost } from '../host.js';
|
|
4
|
+
import { providerAccountsOf, useProviderAccountsStore } from '../state/provider-accounts.js';
|
|
5
|
+
function words(key, values) {
|
|
6
|
+
return i18next.t(`agent-providers:${key}`, values);
|
|
7
|
+
}
|
|
8
|
+
function reason(e) {
|
|
9
|
+
return e instanceof Error ? e.message : String(e);
|
|
10
|
+
}
|
|
11
|
+
function linkTo(scope) {
|
|
12
|
+
if (scope.transport.status !== 'open') {
|
|
13
|
+
throw new Error(words('notAnswering'));
|
|
14
|
+
}
|
|
15
|
+
return scope.transport;
|
|
16
|
+
}
|
|
17
|
+
/* The whole map, as `accounts.save` takes it. Answers false when the host refused, which a toast then says. */
|
|
18
|
+
export async function saveAccounts(scope, accounts) {
|
|
19
|
+
try {
|
|
20
|
+
useProviderAccountsStore.getState().set(scope.id, await linkTo(scope).request('accounts.save', { accounts }));
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
chatHost().notify({ id: `providers-save-${scope.id}`, kind: 'error', title: words('account.saveFailed'), description: reason(e) });
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/* One account changed and every other one as the host last said. */
|
|
29
|
+
export function saveAccount(scope, id, account) {
|
|
30
|
+
const current = providerAccountsOf(scope.id).accounts?.accounts ?? {};
|
|
31
|
+
return saveAccounts(scope, { ...current, [id]: account });
|
|
32
|
+
}
|
|
33
|
+
/*
|
|
34
|
+
* Forgets an account; its folder stays where it is. A pick for new agents that named it goes back to
|
|
35
|
+
* the CLI's default account, since no chat started from it yet.
|
|
36
|
+
*/
|
|
37
|
+
export async function removeAccount(scope, id, kind) {
|
|
38
|
+
const { [id]: _gone, ...rest } = providerAccountsOf(scope.id).accounts?.accounts ?? {};
|
|
39
|
+
if (!(await saveAccounts(scope, rest))) {
|
|
40
|
+
throw new Error(words('account.saveFailed'));
|
|
41
|
+
}
|
|
42
|
+
if (accountFor(readChatPreferences(), scope.id, kind) === id) {
|
|
43
|
+
rememberChatAccount(scope.id, kind, null);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/* An account in a folder the host makes for it; answers its id. Throws what the host said, for the form to show. */
|
|
47
|
+
export async function createAccount(scope, kind, label, color) {
|
|
48
|
+
const created = await linkTo(scope).request('accounts.create', { kind, label, color });
|
|
49
|
+
const { id, ...accounts } = created;
|
|
50
|
+
useProviderAccountsStore.getState().set(scope.id, accounts);
|
|
51
|
+
return id;
|
|
52
|
+
}
|
|
53
|
+
/* An account in a folder that is already on the host. Throws what the host said, for the form to show. */
|
|
54
|
+
export async function linkAccount(scope, id, account) {
|
|
55
|
+
const current = providerAccountsOf(scope.id).accounts?.accounts ?? {};
|
|
56
|
+
useProviderAccountsStore.getState().set(scope.id, await linkTo(scope).request('accounts.save', { accounts: { ...current, [id]: account } }));
|
|
57
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentKind } from '@adecore/agent-contracts';
|
|
2
|
+
export declare function CliMark({ kind, size, className }: {
|
|
3
|
+
kind: AgentKind;
|
|
4
|
+
size?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export declare function CliTile({ kind }: {
|
|
8
|
+
kind: AgentKind;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { AgentIcon } from '../agents/AgentIcon.js';
|
|
4
|
+
// Each CLI in its color of the usage charts, so a mark here reads as the same CLI there.
|
|
5
|
+
const CLI_COLORS = {
|
|
6
|
+
apple: 'text-text-muted',
|
|
7
|
+
claude: 'text-chart-claude',
|
|
8
|
+
codex: 'text-chart-codex',
|
|
9
|
+
gemini: 'text-chart-gemini',
|
|
10
|
+
copilot: 'text-chart-copilot'
|
|
11
|
+
};
|
|
12
|
+
export function CliMark({ kind, size = 14, className }) {
|
|
13
|
+
return _jsx(AgentIcon, { kind: kind, size: size, className: clsx('shrink-0', CLI_COLORS[kind], className) });
|
|
14
|
+
}
|
|
15
|
+
/* As tall as the title's first line, so the mark sits beside the name rather than between the two lines. */
|
|
16
|
+
export function CliTile({ kind }) {
|
|
17
|
+
return (_jsx("span", { className: "grid h-6 shrink-0 place-items-center", children: _jsx(CliMark, { kind: kind, size: 24 }) }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
/* What a provider offers, in one sentence, where it can be opened and whether its hooks report status. */
|
|
3
|
+
export function providerAbilities(provider) {
|
|
4
|
+
const where = provider.capabilities.chat ? i18next.t('agent-providers:abilities.chatAndTerminal') : i18next.t('agent-providers:abilities.terminalOnly');
|
|
5
|
+
const status = provider.capabilities.hooks ? i18next.t('agent-providers:abilities.reportsStatus') : i18next.t('agent-providers:abilities.noStatus');
|
|
6
|
+
return `${where} ${status}`;
|
|
7
|
+
}
|