@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,101 @@
|
|
|
1
|
+
import type { KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Hand, MessageCircleQuestionMark, type LucideIcon } from 'lucide-react';
|
|
4
|
+
import { chatHost } from '../../host';
|
|
5
|
+
import { headingKey, isPrimaryKey, staysInCard, stepIndex, toolbarKey } from '../logic/keys';
|
|
6
|
+
import { Icon } from '@adecore/ui';
|
|
7
|
+
|
|
8
|
+
/* The raised glass a chat's composer is made of, for a card that stands on its own over a canvas. */
|
|
9
|
+
export const PROMPT_SURFACE =
|
|
10
|
+
'flex flex-col overflow-hidden rounded-2xl border border-border bg-[color-mix(in_srgb,var(--surface-raised)_92%,transparent)] shadow-float backdrop-blur-[14px]';
|
|
11
|
+
|
|
12
|
+
export type PromptCardKind = 'approval' | 'question' | 'waiting';
|
|
13
|
+
|
|
14
|
+
const ICONS: Record<PromptCardKind, LucideIcon> = { approval: Hand, question: MessageCircleQuestionMark, waiting: MessageCircleQuestionMark };
|
|
15
|
+
|
|
16
|
+
interface PromptCardProps {
|
|
17
|
+
kind: PromptCardKind;
|
|
18
|
+
heading: ReactNode;
|
|
19
|
+
/* The muted line under the heading; left out when there is nothing to say. */
|
|
20
|
+
meta?: ReactNode;
|
|
21
|
+
/* The stack's source row, drawn above the card and outside `.prompt-card`, so paging is never mistaken for an answer. */
|
|
22
|
+
top?: ReactNode;
|
|
23
|
+
actions: ReactNode;
|
|
24
|
+
busy: boolean;
|
|
25
|
+
/* Why the card cannot be answered from here, in a quiet line; null while it can. */
|
|
26
|
+
notice: string | null;
|
|
27
|
+
error: string | null;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* The keys every card shares: Mod+Enter, entering from the heading and the action row. The body handles
|
|
33
|
+
* its own keys first and says so with `preventDefault`.
|
|
34
|
+
*/
|
|
35
|
+
function onCardKeyDown(event: KeyboardEvent<HTMLDivElement>) {
|
|
36
|
+
const card = event.currentTarget;
|
|
37
|
+
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
38
|
+
if (!event.defaultPrevented) {
|
|
39
|
+
if (isPrimaryKey(event.nativeEvent, chatHost().isApplePlatform())) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
// A click on the button itself, so a disabled Next or Answer stays as disabled as it looks.
|
|
42
|
+
card.querySelector<HTMLButtonElement>('[data-prompt-primary]:not(:disabled)')?.click();
|
|
43
|
+
} else if (target?.classList.contains('prompt-heading') && headingKey(event.nativeEvent)) {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
card.querySelector<HTMLElement>('[data-prompt-entry]:not(:disabled), [data-prompt-primary]:not(:disabled)')?.focus();
|
|
46
|
+
} else {
|
|
47
|
+
const toolbar = target?.closest('[role="toolbar"]');
|
|
48
|
+
const step = toolbar ? toolbarKey(event.nativeEvent) : null;
|
|
49
|
+
if (toolbar && step !== null) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
const buttons = [...toolbar.querySelectorAll<HTMLButtonElement>('button:not(:disabled)')];
|
|
52
|
+
const current = buttons.findIndex((button) => button.contains(target));
|
|
53
|
+
buttons[stepIndex(current, buttons.length, step)]?.focus();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (event.defaultPrevented || staysInCard(event.nativeEvent)) {
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* What every prompt looks like, whatever asked it: in a chat's composer and in a canvas's stack. */
|
|
63
|
+
export function PromptCard({ kind, heading, meta, top, actions, busy, notice, error, children }: PromptCardProps) {
|
|
64
|
+
const { t } = useTranslation('agent-prompts');
|
|
65
|
+
const card = (
|
|
66
|
+
<div className="prompt-card flex min-h-0 flex-col gap-2 p-3" role="group" aria-label={t(`card.${kind}`)} aria-busy={busy} onKeyDown={onCardKeyDown}>
|
|
67
|
+
{/* The scroll box would clip the focus ring of whatever sits against its edge, so it carries the
|
|
68
|
+
room that ring needs and gives the same amount back to the card's own padding. */}
|
|
69
|
+
<div className="-m-1.5 max-h-[min(50dvh,480px)] overflow-auto overscroll-contain p-1.5">
|
|
70
|
+
<div className="flex flex-col gap-2">
|
|
71
|
+
<div className="flex items-start gap-2">
|
|
72
|
+
<Icon icon={ICONS[kind]} size={16} className="mt-[3px] shrink-0 text-status-needs-you" />
|
|
73
|
+
<h3 tabIndex={-1} className="prompt-heading min-w-0 break-words text-sm font-semibold text-text outline-offset-4">
|
|
74
|
+
{heading}
|
|
75
|
+
</h3>
|
|
76
|
+
</div>
|
|
77
|
+
{meta && <div className="flex flex-wrap gap-x-3 gap-y-1 text-xs text-text-muted">{meta}</div>}
|
|
78
|
+
{children}
|
|
79
|
+
{notice && <p className="text-xs text-text-muted">{notice}</p>}
|
|
80
|
+
{error && (
|
|
81
|
+
<p role="alert" className="text-xs text-status-error">
|
|
82
|
+
{error}
|
|
83
|
+
</p>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
<div role="toolbar" aria-label={t('toolbar')} className="flex flex-wrap items-center gap-1.5">
|
|
88
|
+
{actions}
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
if (top === undefined) {
|
|
93
|
+
return card;
|
|
94
|
+
}
|
|
95
|
+
return (
|
|
96
|
+
<div className="flex min-h-0 flex-col">
|
|
97
|
+
{top}
|
|
98
|
+
{card}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next';
|
|
2
|
+
import { toolSummary } from '../../chat/logic/tools';
|
|
3
|
+
import { chatHost } from '../../host';
|
|
4
|
+
import { answerValue, promptAnswers, questionAnswer, type PromptDraft } from '../logic/prompts';
|
|
5
|
+
import { approvalButtons, type PromptViewProps } from '../logic/subjects';
|
|
6
|
+
import { ApprovalBody } from './ApprovalBody';
|
|
7
|
+
import { ApprovalActions, QuestionActions } from './PromptActions';
|
|
8
|
+
import { PromptCard } from './PromptCard';
|
|
9
|
+
import { QuestionBody } from './QuestionBody';
|
|
10
|
+
|
|
11
|
+
/* A permission request or question, answered in place: a chat's, or one of the app's own that it draws itself. */
|
|
12
|
+
export function PromptView(props: PromptViewProps) {
|
|
13
|
+
const { subject, draft, onDraft, onAction, more, hasDraft, denyReason, disabled, sending, error, top } = props;
|
|
14
|
+
const { t } = useTranslation('agent-prompts');
|
|
15
|
+
const locked = sending || disabled;
|
|
16
|
+
const notice = disabled ? t('error.notConnected') : null;
|
|
17
|
+
const buttons = approvalButtons(subject, draft.reason).map(({ action, ...button }) => ({ ...button, onPress: () => onAction(action) }));
|
|
18
|
+
|
|
19
|
+
if (subject.kind === 'host') {
|
|
20
|
+
return chatHost().prompts.render(subject.prompt, props);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { item } = subject;
|
|
24
|
+
const question = item.kind === 'question' ? item.questions[Math.min(draft.index, item.questions.length - 1)]! : null;
|
|
25
|
+
const answer = question ? questionAnswer(draft, question) : null;
|
|
26
|
+
const last = item.kind === 'question' && draft.index === item.questions.length - 1;
|
|
27
|
+
// Whether Next or Answer may go with this draft. The keys ask it as well as the button.
|
|
28
|
+
const readyWith = (next: PromptDraft): boolean =>
|
|
29
|
+
item.kind === 'question' && !!question && !!answerValue(questionAnswer(next, question)) && !(last && !promptAnswers(item, next));
|
|
30
|
+
const commit = (next: PromptDraft) => {
|
|
31
|
+
if (item.kind !== 'question' || locked || !readyWith(next)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!last) {
|
|
35
|
+
onDraft({ ...next, index: next.index + 1 });
|
|
36
|
+
} else {
|
|
37
|
+
const answers = promptAnswers(item, next);
|
|
38
|
+
if (answers) {
|
|
39
|
+
onAction({ kind: 'answer', answers });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const multiple = item.kind === 'question' && item.questions.length > 1;
|
|
44
|
+
const meta =
|
|
45
|
+
more > 0 || hasDraft || multiple ? (
|
|
46
|
+
<>
|
|
47
|
+
{more > 0 && <span className="tabular-nums">{t('meta.waiting', { count: more + 1 })}</span>}
|
|
48
|
+
{multiple && <span className="tabular-nums">{t('meta.question', { index: draft.index + 1, total: item.questions.length })}</span>}
|
|
49
|
+
{hasDraft && <span>{t('meta.draftSaved')}</span>}
|
|
50
|
+
</>
|
|
51
|
+
) : null;
|
|
52
|
+
|
|
53
|
+
if (item.kind === 'approval') {
|
|
54
|
+
return (
|
|
55
|
+
<PromptCard
|
|
56
|
+
kind="approval"
|
|
57
|
+
heading={`${item.toolName === 'Bash' ? t('approval.runCommand') : item.toolName} ${item.toolName === 'Bash' ? '' : toolSummary(item.toolName, item.input)}`}
|
|
58
|
+
meta={meta}
|
|
59
|
+
top={top}
|
|
60
|
+
busy={sending}
|
|
61
|
+
notice={notice}
|
|
62
|
+
error={error}
|
|
63
|
+
actions={
|
|
64
|
+
<ApprovalActions
|
|
65
|
+
buttons={buttons}
|
|
66
|
+
onAddReason={denyReason && !draft.showReason ? () => onDraft({ ...draft, showReason: true }) : undefined}
|
|
67
|
+
locked={locked}
|
|
68
|
+
sending={sending}
|
|
69
|
+
/>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
<ApprovalBody item={item} draft={draft} onDraft={onDraft} denyReason={denyReason} locked={locked} />
|
|
73
|
+
</PromptCard>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<PromptCard
|
|
79
|
+
kind="question"
|
|
80
|
+
heading={question?.question}
|
|
81
|
+
meta={meta}
|
|
82
|
+
top={top}
|
|
83
|
+
busy={sending}
|
|
84
|
+
notice={notice}
|
|
85
|
+
error={error}
|
|
86
|
+
actions={
|
|
87
|
+
<QuestionActions
|
|
88
|
+
index={draft.index}
|
|
89
|
+
dismissable={item.async === true}
|
|
90
|
+
last={last}
|
|
91
|
+
ready={readyWith(draft)}
|
|
92
|
+
locked={locked}
|
|
93
|
+
sending={sending}
|
|
94
|
+
onPrevious={() => onDraft({ ...draft, index: draft.index - 1 })}
|
|
95
|
+
onDismiss={() => onAction({ kind: 'dismiss' })}
|
|
96
|
+
onCommit={() => commit(draft)}
|
|
97
|
+
/>
|
|
98
|
+
}
|
|
99
|
+
>
|
|
100
|
+
{question && answer && (
|
|
101
|
+
<QuestionBody
|
|
102
|
+
question={question}
|
|
103
|
+
answer={answer}
|
|
104
|
+
onAnswer={(next) => onDraft({ ...draft, answers: { ...draft.answers, [question.id]: next } })}
|
|
105
|
+
onCommit={(next) => commit({ ...draft, answers: { ...draft.answers, [question.id]: next } })}
|
|
106
|
+
locked={locked}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
</PromptCard>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { useEffect, useRef, type KeyboardEvent } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { Circle, CircleCheck, Square } from 'lucide-react';
|
|
5
|
+
import type { ChatQuestion } from '@adecore/agent-contracts';
|
|
6
|
+
import { answerFieldKey, choiceKey, stepIndex } from '../logic/keys';
|
|
7
|
+
import { pickPromptChoice, type PromptAnswer } from '../logic/prompts';
|
|
8
|
+
import { Icon } from '@adecore/ui';
|
|
9
|
+
import { chatHost } from '../../host';
|
|
10
|
+
|
|
11
|
+
/* One question of a request: its choices, "Something else…", or a written answer when it offers no choices. */
|
|
12
|
+
export function QuestionBody({
|
|
13
|
+
question,
|
|
14
|
+
answer,
|
|
15
|
+
onAnswer,
|
|
16
|
+
onCommit,
|
|
17
|
+
locked
|
|
18
|
+
}: {
|
|
19
|
+
question: ChatQuestion;
|
|
20
|
+
answer: PromptAnswer;
|
|
21
|
+
onAnswer(answer: PromptAnswer): void;
|
|
22
|
+
/* Next or Answer with this answer in place, when the question allows it. */
|
|
23
|
+
onCommit(answer: PromptAnswer): void;
|
|
24
|
+
locked: boolean;
|
|
25
|
+
}) {
|
|
26
|
+
const { t } = useTranslation('agent-prompts');
|
|
27
|
+
const AnswerField = chatHost().dictation.Textarea;
|
|
28
|
+
// The choices, then the "Something else…" field form one list with a single tab stop.
|
|
29
|
+
const items = useRef<(HTMLElement | null)[]>([]);
|
|
30
|
+
const shownQuestion = useRef(question.id);
|
|
31
|
+
const count = question.choices.length + 1;
|
|
32
|
+
const chosen = question.choices.findIndex((choice) => !answer.custom && answer.choices.includes(choice.label));
|
|
33
|
+
const tabStop = chosen !== -1 ? chosen : answer.custom ? question.choices.length : 0;
|
|
34
|
+
|
|
35
|
+
// The focused choice of the question before is gone once the next one shows; the keyboard goes on in this one.
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (shownQuestion.current === question.id) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
shownQuestion.current = question.id;
|
|
41
|
+
if (document.activeElement === null || document.activeElement === document.body) {
|
|
42
|
+
(items.current[tabStop] ?? items.current[0])?.focus({ preventScroll: true });
|
|
43
|
+
}
|
|
44
|
+
}, [question.id, tabStop]);
|
|
45
|
+
|
|
46
|
+
const onChoiceKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number, label: string) => {
|
|
47
|
+
const action = choiceKey(event.nativeEvent, {
|
|
48
|
+
multiSelect: question.multiSelect,
|
|
49
|
+
anyChosen: !answer.custom && answer.choices.length > 0
|
|
50
|
+
});
|
|
51
|
+
if (action === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
if (action.kind === 'move') {
|
|
56
|
+
items.current[stepIndex(index, count, action.to)]?.focus();
|
|
57
|
+
} else if (action.kind === 'commit') {
|
|
58
|
+
onCommit(answer);
|
|
59
|
+
} else {
|
|
60
|
+
const next = pickPromptChoice(answer, question, label);
|
|
61
|
+
onAnswer(next);
|
|
62
|
+
if (action.kind === 'pick-and-commit') {
|
|
63
|
+
onCommit(next);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const onFieldKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
69
|
+
const field = event.currentTarget;
|
|
70
|
+
const action = answerFieldKey(event.nativeEvent, {
|
|
71
|
+
belowChoices: question.choices.length > 0,
|
|
72
|
+
caretAtStart: field.selectionStart === 0 && field.selectionEnd === 0,
|
|
73
|
+
hasText: field.value.trim() !== ''
|
|
74
|
+
});
|
|
75
|
+
if (action === null) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
if (action.kind === 'to-last-choice') {
|
|
80
|
+
items.current[question.choices.length - 1]?.focus();
|
|
81
|
+
} else if (action.kind === 'commit') {
|
|
82
|
+
onCommit({ ...answer, custom: true });
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className="flex flex-col gap-2">
|
|
88
|
+
{question.multiSelect && <p className="text-xs text-text-muted">{t('question.multiSelect')}</p>}
|
|
89
|
+
{question.choices.length > 0 && (
|
|
90
|
+
<div role={question.multiSelect ? 'group' : 'radiogroup'} aria-label={question.question} className="flex flex-col gap-2">
|
|
91
|
+
{question.choices.map((choice, index) => {
|
|
92
|
+
const selected = !answer.custom && answer.choices.includes(choice.label);
|
|
93
|
+
return (
|
|
94
|
+
<button
|
|
95
|
+
key={choice.label}
|
|
96
|
+
ref={(element) => {
|
|
97
|
+
items.current[index] = element;
|
|
98
|
+
}}
|
|
99
|
+
type="button"
|
|
100
|
+
role={question.multiSelect ? 'checkbox' : 'radio'}
|
|
101
|
+
aria-checked={selected}
|
|
102
|
+
tabIndex={index === tabStop ? 0 : -1}
|
|
103
|
+
data-prompt-entry={index === tabStop ? '' : undefined}
|
|
104
|
+
disabled={locked}
|
|
105
|
+
className={clsx(
|
|
106
|
+
'flex min-h-9 items-start gap-2 rounded-lg border px-3 py-2 text-left disabled:opacity-50',
|
|
107
|
+
selected ? 'border-accent bg-accent-soft' : 'border-border bg-surface-hover hover:bg-surface-active'
|
|
108
|
+
)}
|
|
109
|
+
onClick={() => onAnswer(pickPromptChoice(answer, question, choice.label))}
|
|
110
|
+
onKeyDown={(event) => onChoiceKeyDown(event, index, choice.label)}
|
|
111
|
+
>
|
|
112
|
+
<Icon
|
|
113
|
+
icon={selected ? CircleCheck : question.multiSelect ? Square : Circle}
|
|
114
|
+
size={16}
|
|
115
|
+
className="mt-0.5 shrink-0 text-text-muted"
|
|
116
|
+
/>
|
|
117
|
+
<span className="flex min-w-0 flex-wrap items-baseline gap-x-2">
|
|
118
|
+
<span className="text-xs text-text">{choice.label}</span>
|
|
119
|
+
{choice.description && <span className="text-xs text-text-muted">{choice.description}</span>}
|
|
120
|
+
</span>
|
|
121
|
+
</button>
|
|
122
|
+
);
|
|
123
|
+
})}
|
|
124
|
+
<label
|
|
125
|
+
className={clsx(
|
|
126
|
+
'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',
|
|
127
|
+
answer.custom ? 'border-accent bg-accent-soft' : 'border-border bg-surface-hover',
|
|
128
|
+
locked && 'opacity-50'
|
|
129
|
+
)}
|
|
130
|
+
// A press picks the row; the keyboard only passing through on its way up or down does not.
|
|
131
|
+
onPointerDown={() => {
|
|
132
|
+
if (!locked && !answer.custom) {
|
|
133
|
+
onAnswer({ ...answer, custom: true });
|
|
134
|
+
}
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
<Icon icon={answer.custom ? CircleCheck : Circle} size={16} className="mt-0.5 shrink-0" />
|
|
138
|
+
<AnswerField
|
|
139
|
+
ref={(element) => {
|
|
140
|
+
items.current[question.choices.length] = element;
|
|
141
|
+
}}
|
|
142
|
+
rows={1}
|
|
143
|
+
tabIndex={tabStop === question.choices.length ? 0 : -1}
|
|
144
|
+
data-prompt-entry={tabStop === question.choices.length ? '' : undefined}
|
|
145
|
+
className="max-h-40 min-w-0 flex-1 resize-none field-sizing-content bg-transparent outline-none placeholder:text-text-muted"
|
|
146
|
+
buttonClassName="-my-1 -mr-1.5"
|
|
147
|
+
aria-label={t('question.answerLabel')}
|
|
148
|
+
placeholder={t('question.somethingElse')}
|
|
149
|
+
value={answer.text}
|
|
150
|
+
disabled={locked}
|
|
151
|
+
onChange={(e) => onAnswer({ ...answer, custom: true, text: e.target.value })}
|
|
152
|
+
onKeyDown={onFieldKeyDown}
|
|
153
|
+
/>
|
|
154
|
+
</label>
|
|
155
|
+
</div>
|
|
156
|
+
)}
|
|
157
|
+
{question.choices.length === 0 && (
|
|
158
|
+
<AnswerField
|
|
159
|
+
ref={(element) => {
|
|
160
|
+
items.current[0] = element;
|
|
161
|
+
}}
|
|
162
|
+
className="field min-h-20 text-sm"
|
|
163
|
+
aria-label={t('question.answerLabel')}
|
|
164
|
+
placeholder={t('question.answerPlaceholder')}
|
|
165
|
+
data-prompt-entry=""
|
|
166
|
+
value={answer.text}
|
|
167
|
+
disabled={locked}
|
|
168
|
+
onChange={(e) => onAnswer({ ...answer, text: e.target.value })}
|
|
169
|
+
onKeyDown={onFieldKeyDown}
|
|
170
|
+
/>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccentSwatches } from '@adecore/ui';
|
|
2
|
+
import { chatHost } from '../host';
|
|
3
|
+
|
|
4
|
+
/* The colors an account may wear, the host's palette. */
|
|
5
|
+
export function AccountColors({ value, label, onChange }: { value: string | undefined; label: string; onChange(id: string): void }) {
|
|
6
|
+
const { all, featured, label: labelOf } = chatHost().accents;
|
|
7
|
+
return <AccentSwatches value={value} label={label} accents={all} featured={featured} labelOf={labelOf} onValueChange={onChange} />;
|
|
8
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
3
|
+
import { LogIn } from 'lucide-react';
|
|
4
|
+
import type { ProviderInfo } from '@adecore/agent-contracts';
|
|
5
|
+
import { AccountDot } from '../agents/AccountDot';
|
|
6
|
+
import { accountName, FOLDER_VARIABLES, type AccountEntry } from '../agents/accounts';
|
|
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';
|
|
10
|
+
import { useChatScope } from '../scope';
|
|
11
|
+
import { removeAccount, saveAccount } from './account-actions';
|
|
12
|
+
import { AccountVariables } from './AccountVariables';
|
|
13
|
+
import { AccountColors } from './AccountColors';
|
|
14
|
+
import { CliMark } from './parts';
|
|
15
|
+
|
|
16
|
+
// The states in which the machine's own sentence says more than the usual line under the login.
|
|
17
|
+
const TROUBLE = new Set(['folder-missing', 'unavailable', 'failed']);
|
|
18
|
+
|
|
19
|
+
interface AccountDetailProps {
|
|
20
|
+
provider: ProviderInfo;
|
|
21
|
+
entry: AccountEntry;
|
|
22
|
+
/* False for a CLI without a config folder: it has only its own login, and nothing to sign in here. */
|
|
23
|
+
canLogIn: boolean;
|
|
24
|
+
/* Why a login cannot open a terminal right now, or null when it can. */
|
|
25
|
+
loginBlocked: string | null;
|
|
26
|
+
secretsAvailable: boolean;
|
|
27
|
+
onRemoved(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* The name a person types, saved when they leave the field; an empty one goes back to what was there. */
|
|
31
|
+
function NameField({ value, label, onSave }: { value: string; label: string; onSave(name: string): void }) {
|
|
32
|
+
const [draft, setDraft] = useState(value);
|
|
33
|
+
const commit = (): void => {
|
|
34
|
+
const name = draft.trim();
|
|
35
|
+
if (name === '' || name === value) {
|
|
36
|
+
setDraft(value);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
onSave(name);
|
|
40
|
+
};
|
|
41
|
+
return (
|
|
42
|
+
<Input
|
|
43
|
+
className="w-55 max-w-full"
|
|
44
|
+
value={draft}
|
|
45
|
+
maxLength={80}
|
|
46
|
+
aria-label={label}
|
|
47
|
+
onChange={(event) => setDraft(event.target.value)}
|
|
48
|
+
onBlur={commit}
|
|
49
|
+
onKeyDown={(event) => {
|
|
50
|
+
if (event.key === 'Enter') {
|
|
51
|
+
event.currentTarget.blur();
|
|
52
|
+
}
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* One account: how it looks in a picker, who is signed in, where its folder is, its variables. */
|
|
59
|
+
export function AccountDetail({ provider, entry, canLogIn, loginBlocked, secretsAvailable, onRemoved }: AccountDetailProps) {
|
|
60
|
+
const { t } = useTranslation('agent-providers');
|
|
61
|
+
const scope = useChatScope();
|
|
62
|
+
const [confirming, setConfirming] = useState(false);
|
|
63
|
+
const { id, account, status, isDefault } = entry;
|
|
64
|
+
const name = accountName(entry, provider.name);
|
|
65
|
+
const folder = status?.home ?? '';
|
|
66
|
+
const variable = FOLDER_VARIABLES[provider.kind];
|
|
67
|
+
const signedIn = status?.state === 'ready';
|
|
68
|
+
|
|
69
|
+
const showFolder = (): void => {
|
|
70
|
+
copyText(folder);
|
|
71
|
+
chatHost().notify({ kind: 'success', title: t('account.folderCopied'), description: folder });
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const loginDetail = (): string => {
|
|
75
|
+
if (status !== null && TROUBLE.has(status.state) && status.message) {
|
|
76
|
+
return status.message;
|
|
77
|
+
}
|
|
78
|
+
if (!signedIn) {
|
|
79
|
+
return t('account.login.signedOutDetail');
|
|
80
|
+
}
|
|
81
|
+
return status?.plan ? t('account.login.planDetail', { plan: status.plan }) : t('account.login.detail');
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const loginButton = (
|
|
85
|
+
<Button variant="secondary" disabled={loginBlocked !== null} onClick={() => void chatHost().openLogin?.(scope.id, provider.kind, id, name)}>
|
|
86
|
+
<Icon icon={LogIn} size={14} />
|
|
87
|
+
{signedIn ? t('account.login.logInAgain') : t('account.login.logIn')}
|
|
88
|
+
</Button>
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<>
|
|
93
|
+
<DetailHeader
|
|
94
|
+
mark={
|
|
95
|
+
<span className="grid h-6 shrink-0 place-items-center">
|
|
96
|
+
<AccountDot color={account.color} className="size-3" />
|
|
97
|
+
</span>
|
|
98
|
+
}
|
|
99
|
+
title={name}
|
|
100
|
+
subtitle={
|
|
101
|
+
<>
|
|
102
|
+
<CliMark kind={provider.kind} size={12} className="text-text-muted" />
|
|
103
|
+
{t('account.kind', { provider: provider.name })}
|
|
104
|
+
</>
|
|
105
|
+
}
|
|
106
|
+
actions={
|
|
107
|
+
folder !== '' && (
|
|
108
|
+
<Button variant="secondary" onClick={showFolder}>
|
|
109
|
+
{t('account.showFolder')}
|
|
110
|
+
</Button>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
/>
|
|
114
|
+
<SettingsSection>
|
|
115
|
+
<SettingsRow
|
|
116
|
+
label={t('account.enabled.label')}
|
|
117
|
+
description={t('account.enabled.description')}
|
|
118
|
+
control={
|
|
119
|
+
<Switch
|
|
120
|
+
checked={account.enabled !== false}
|
|
121
|
+
label={t('account.enabled.label')}
|
|
122
|
+
onCheckedChange={(checked) => {
|
|
123
|
+
const { enabled: _enabled, ...rest } = account;
|
|
124
|
+
void saveAccount(scope, id, checked ? rest : { ...rest, enabled: false });
|
|
125
|
+
}}
|
|
126
|
+
/>
|
|
127
|
+
}
|
|
128
|
+
/>
|
|
129
|
+
<SettingsRow
|
|
130
|
+
label={t('account.name')}
|
|
131
|
+
control={
|
|
132
|
+
<NameField key={name} value={name} label={t('account.name')} onSave={(label) => void saveAccount(scope, id, { ...account, label })} />
|
|
133
|
+
}
|
|
134
|
+
/>
|
|
135
|
+
<SettingsRow
|
|
136
|
+
label={t('account.color')}
|
|
137
|
+
control={
|
|
138
|
+
<AccountColors
|
|
139
|
+
value={account.color}
|
|
140
|
+
label={t('account.color')}
|
|
141
|
+
onChange={(color) => void saveAccount(scope, id, { ...account, color })}
|
|
142
|
+
/>
|
|
143
|
+
}
|
|
144
|
+
/>
|
|
145
|
+
</SettingsSection>
|
|
146
|
+
{canLogIn && (
|
|
147
|
+
<SettingsSection title={t('account.login.title')}>
|
|
148
|
+
<SettingsRow
|
|
149
|
+
label={
|
|
150
|
+
signedIn
|
|
151
|
+
? status?.email
|
|
152
|
+
? t('account.login.signedInAs', { email: status.email })
|
|
153
|
+
: t('account.login.signedIn')
|
|
154
|
+
: t('account.login.signedOut')
|
|
155
|
+
}
|
|
156
|
+
description={loginBlocked === null ? loginDetail() : `${loginDetail()} ${loginBlocked}`}
|
|
157
|
+
control={
|
|
158
|
+
loginBlocked === null ? (
|
|
159
|
+
loginButton
|
|
160
|
+
) : (
|
|
161
|
+
<Tooltip label={loginBlocked}>
|
|
162
|
+
<span className="inline-flex">{loginButton}</span>
|
|
163
|
+
</Tooltip>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
/>
|
|
167
|
+
<SettingsRow label={t('account.folder.label')}>
|
|
168
|
+
<Input mono className="h-8.5" value={folder} readOnly aria-label={t('account.folder.label')} />
|
|
169
|
+
<p className="-mt-1 text-xs text-text-muted">
|
|
170
|
+
{variable ? (
|
|
171
|
+
<Trans
|
|
172
|
+
t={t}
|
|
173
|
+
i18nKey="account.folder.detail"
|
|
174
|
+
values={{ variable }}
|
|
175
|
+
components={{ code: <code className="font-mono text-code" /> }}
|
|
176
|
+
/>
|
|
177
|
+
) : (
|
|
178
|
+
t('account.folder.detailPlain')
|
|
179
|
+
)}
|
|
180
|
+
</p>
|
|
181
|
+
</SettingsRow>
|
|
182
|
+
</SettingsSection>
|
|
183
|
+
)}
|
|
184
|
+
<AccountVariables key={`${id}:${JSON.stringify(account.env ?? [])}`} id={id} account={account} secretsAvailable={secretsAvailable} />
|
|
185
|
+
<SettingsSection>
|
|
186
|
+
<SettingsRow
|
|
187
|
+
label={t('account.remove.label')}
|
|
188
|
+
description={isDefault ? t('account.remove.defaultNote') : t('account.remove.description')}
|
|
189
|
+
control={
|
|
190
|
+
<Button variant="danger-outline" disabled={isDefault} onClick={() => setConfirming(true)}>
|
|
191
|
+
{t('account.remove.button')}
|
|
192
|
+
</Button>
|
|
193
|
+
}
|
|
194
|
+
/>
|
|
195
|
+
</SettingsSection>
|
|
196
|
+
<ConfirmDialog
|
|
197
|
+
open={confirming}
|
|
198
|
+
onOpenChange={setConfirming}
|
|
199
|
+
title={t('account.remove.confirmTitle', { account: name })}
|
|
200
|
+
description={t('account.remove.confirmDescription', { folder })}
|
|
201
|
+
confirmLabel={t('account.remove.confirm')}
|
|
202
|
+
onConfirm={async () => {
|
|
203
|
+
await removeAccount(scope, id, provider.kind);
|
|
204
|
+
onRemoved();
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
</>
|
|
208
|
+
);
|
|
209
|
+
}
|