@adecore/agents-react 0.31.12 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/AccountDot.js +57 -6
- package/dist/agents/AgentIcon.js +88 -12
- package/dist/agents/ModelOptionControl.js +153 -18
- package/dist/agents/ProviderLogo.js +49 -4
- package/dist/agents/account-limits.js +17 -14
- package/dist/agents/accounts.js +99 -67
- package/dist/agents/agent-marks.js +5 -3
- package/dist/agents/model-name.js +42 -31
- package/dist/agents/model-options.js +8 -8
- package/dist/agents/model-requirement.js +17 -14
- package/dist/agents/option-words.d.ts +7 -0
- package/dist/agents/option-words.js +35 -0
- package/dist/agents/provider-paths.js +6 -6
- package/dist/agents/status-look.js +32 -12
- package/dist/chat/account-choice.d.ts +13 -0
- package/dist/chat/account-choice.js +90 -20
- package/dist/chat/actions.js +126 -59
- package/dist/chat/activity.js +5 -5
- package/dist/chat/attachments.js +74 -53
- package/dist/chat/bookmarks.js +58 -48
- package/dist/chat/chat-client.js +344 -263
- package/dist/chat/chat-references.js +3 -3
- package/dist/chat/composer-effort.d.ts +5 -0
- package/dist/chat/composer-effort.js +26 -0
- package/dist/chat/composer-send.js +13 -13
- package/dist/chat/drafts.js +115 -79
- package/dist/chat/forks.js +81 -24
- package/dist/chat/guards.js +15 -43
- package/dist/chat/index.d.ts +3 -1
- package/dist/chat/index.js +3 -2
- package/dist/chat/logic/ansi.js +170 -167
- package/dist/chat/logic/answers.js +2 -2
- package/dist/chat/logic/bookmarks.js +19 -19
- package/dist/chat/logic/command-looks.js +138 -96
- package/dist/chat/logic/context-usage.js +13 -9
- package/dist/chat/logic/continue-after-stop.js +15 -19
- package/dist/chat/logic/effort.d.ts +14 -0
- package/dist/chat/logic/effort.js +34 -0
- package/dist/chat/logic/embedded-code.js +387 -326
- package/dist/chat/logic/fork.js +134 -110
- package/dist/chat/logic/generated-image.js +54 -23
- package/dist/chat/logic/goal.js +28 -20
- package/dist/chat/logic/handback.js +6 -6
- package/dist/chat/logic/json.js +2 -2
- package/dist/chat/logic/limit.js +46 -30
- package/dist/chat/logic/picker-entries.d.ts +5 -3
- package/dist/chat/logic/picker-entries.js +83 -43
- package/dist/chat/logic/resume-compaction.d.ts +14 -1
- package/dist/chat/logic/resume-compaction.js +93 -24
- package/dist/chat/logic/scrubber.js +188 -136
- package/dist/chat/logic/thought.js +13 -16
- package/dist/chat/logic/thread-cards.js +60 -48
- package/dist/chat/logic/timeline-copy.js +30 -38
- package/dist/chat/logic/timeline-target.js +92 -63
- package/dist/chat/logic/timeline.js +499 -355
- package/dist/chat/logic/tool-catalog.js +54 -34
- package/dist/chat/logic/tools.js +106 -82
- package/dist/chat/logic/visual-height.js +18 -18
- package/dist/chat/logic/visual-viewport.js +6 -3
- package/dist/chat/logic/welcome.js +9 -9
- package/dist/chat/logic/workflow.d.ts +10 -0
- package/dist/chat/logic/workflow.js +130 -32
- package/dist/chat/mentions.js +149 -109
- package/dist/chat/persisted-json.js +51 -54
- package/dist/chat/preferences.d.ts +4 -0
- package/dist/chat/preferences.js +162 -84
- package/dist/chat/prompt-hold.js +9 -9
- package/dist/chat/quote.js +21 -30
- package/dist/chat/reading-width.js +12 -10
- package/dist/chat/recent-messages.js +34 -21
- package/dist/chat/resume-compaction-dismissals.js +25 -5
- package/dist/chat/runtime-modes.js +3 -3
- package/dist/chat/send-key.js +11 -7
- package/dist/chat/stash.js +89 -69
- package/dist/chat/subagent-conversation.js +181 -139
- package/dist/chat/subagent-list.js +65 -67
- package/dist/chat/subagent-support.js +12 -7
- package/dist/chat/subagent-view.js +132 -44
- package/dist/chat/thumbnails.js +88 -60
- package/dist/chat/timeline-flash.js +24 -12
- package/dist/chat/timeline-scroll.js +116 -86
- package/dist/chat/ui/AccountPill.js +126 -15
- package/dist/chat/ui/AnsiOutput.js +62 -6
- package/dist/chat/ui/BookmarkMarker.js +231 -41
- package/dist/chat/ui/BookmarkSubmenu.js +165 -18
- package/dist/chat/ui/ChatActivity.js +649 -70
- package/dist/chat/ui/ChatReferenceChip.js +104 -9
- package/dist/chat/ui/CodeBlock.js +132 -58
- package/dist/chat/ui/Composer.js +866 -132
- package/dist/chat/ui/ComposerInput.js +309 -120
- package/dist/chat/ui/DiffPool.js +75 -14
- package/dist/chat/ui/EditDiff.js +160 -21
- package/dist/chat/ui/FadingWords.js +32 -3
- package/dist/chat/ui/GoalDock.js +235 -42
- package/dist/chat/ui/ImageView.js +617 -61
- package/dist/chat/ui/LimitState.js +446 -72
- package/dist/chat/ui/Markdown.js +991 -173
- package/dist/chat/ui/MermaidBlock.js +285 -79
- package/dist/chat/ui/MessageActions.js +251 -39
- package/dist/chat/ui/ModelMarks.js +55 -5
- package/dist/chat/ui/Pickers.js +664 -113
- package/dist/chat/ui/PromptComposer.js +281 -51
- package/dist/chat/ui/QuoteButton.js +151 -57
- package/dist/chat/ui/ResumeCompactionDock.d.ts +6 -2
- package/dist/chat/ui/ResumeCompactionDock.js +141 -6
- package/dist/chat/ui/RowTime.js +59 -5
- package/dist/chat/ui/RunSettings.js +1744 -154
- package/dist/chat/ui/Scrubber.js +517 -88
- package/dist/chat/ui/ShellCommand.js +183 -107
- package/dist/chat/ui/SubagentControls.js +212 -24
- package/dist/chat/ui/SubagentInfo.js +170 -13
- package/dist/chat/ui/SubagentStopButton.js +115 -24
- package/dist/chat/ui/SubagentTimeline.js +357 -91
- package/dist/chat/ui/Timeline.js +988 -476
- package/dist/chat/ui/TimelineMenu.js +552 -37
- package/dist/chat/ui/UnifiedDiff.js +234 -27
- package/dist/chat/ui/UploadThumb.js +37 -7
- package/dist/chat/ui/VisualDialogs.js +251 -20
- package/dist/chat/ui/VisualFrame.js +321 -95
- package/dist/chat/ui/Welcome.js +72 -7
- package/dist/chat/ui/chips.js +1 -1
- package/dist/chat/ui/code-lines.js +36 -36
- package/dist/chat/ui/code-streaming.js +1 -1
- package/dist/chat/ui/code-theme.js +7 -7
- package/dist/chat/ui/composer/ComposerControls.js +329 -21
- package/dist/chat/ui/composer/ComposerMenu.js +358 -30
- package/dist/chat/ui/composer/DraftParts.js +185 -11
- package/dist/chat/ui/composer/QueuedMessages.js +138 -13
- package/dist/chat/ui/composer/chips.js +29 -19
- package/dist/chat/ui/composer/editor.js +79 -63
- package/dist/chat/ui/composer/insert.js +26 -12
- package/dist/chat/ui/composer/key-handler.js +180 -127
- package/dist/chat/ui/composer/keys.js +90 -73
- package/dist/chat/ui/composer/menu-aria.js +18 -9
- package/dist/chat/ui/composer/placeholder.js +78 -31
- package/dist/chat/ui/composer/surface.js +13 -37
- package/dist/chat/ui/composer/use-chat-controls.js +230 -90
- package/dist/chat/ui/composer/use-compaction-offer.js +50 -18
- package/dist/chat/ui/composer/use-composer-draft.js +65 -34
- package/dist/chat/ui/composer/use-composer-menus.js +478 -193
- package/dist/chat/ui/composer/use-composer-submit.js +251 -109
- package/dist/chat/ui/composer/use-continuable-turn.js +33 -6
- package/dist/chat/ui/composer/use-draft-files.js +245 -93
- package/dist/chat/ui/composer/use-effort-stepper.d.ts +13 -0
- package/dist/chat/ui/composer/use-effort-stepper.js +88 -0
- package/dist/chat/ui/composer/use-notice.js +61 -16
- package/dist/chat/ui/composer/use-pending-requests.js +38 -17
- package/dist/chat/ui/composer/use-prompt-history.js +117 -45
- package/dist/chat/ui/composer/use-prompt-hold.js +119 -35
- package/dist/chat/ui/composer/use-take-back.js +94 -72
- package/dist/chat/ui/diff/ApprovalReview.js +101 -23
- package/dist/chat/ui/diff/DiffFallbackBoundary.js +21 -13
- package/dist/chat/ui/diff/DiffOmitted.js +56 -6
- package/dist/chat/ui/diff/DiffStack.js +92 -8
- package/dist/chat/ui/diff/DiffUnavailable.js +56 -6
- package/dist/chat/ui/diff/EditorEditDiff.js +263 -51
- package/dist/chat/ui/diff/EditorPatchDiff.js +39 -14
- package/dist/chat/ui/diff/LegacyDiffPool.js +27 -10
- package/dist/chat/ui/diff/LegacyEditDiff.js +97 -20
- package/dist/chat/ui/diff/LegacyUnifiedDiff.js +172 -42
- package/dist/chat/ui/diff/RawDiff.js +65 -5
- package/dist/chat/ui/diff/ReviewDiff.js +77 -5
- package/dist/chat/ui/diff/diff-props.js +1 -1
- package/dist/chat/ui/diff/diff-source-budget.js +46 -35
- package/dist/chat/ui/diff/editor-edit-model.js +18 -14
- package/dist/chat/ui/diff/review-plan.js +63 -40
- package/dist/chat/ui/diff/review-settle.js +24 -9
- package/dist/chat/ui/diff/syntax-runtime.js +236 -201
- package/dist/chat/ui/diff/use-review-stack.js +146 -25
- package/dist/chat/ui/diff-syntax.js +70 -58
- package/dist/chat/ui/diff-theme.js +31 -12
- package/dist/chat/ui/file-links.js +39 -10
- package/dist/chat/ui/find-reveal.js +29 -8
- package/dist/chat/ui/full-diff.js +17 -12
- package/dist/chat/ui/highlighter.js +143 -113
- package/dist/chat/ui/icons.js +16 -7
- package/dist/chat/ui/index.js +1 -1
- package/dist/chat/ui/intelligent-ui/UiBlockFrame.js +556 -82
- package/dist/chat/ui/intelligent-ui/UiFallbackPart.js +73 -5
- package/dist/chat/ui/intelligent-ui/UiReply.js +666 -262
- package/dist/chat/ui/intelligent-ui/block-local.js +59 -31
- package/dist/chat/ui/intelligent-ui/chart-data.js +77 -67
- package/dist/chat/ui/intelligent-ui/node-text.js +77 -91
- package/dist/chat/ui/intelligent-ui/registry.js +46 -46
- package/dist/chat/ui/intelligent-ui/render-context.js +1 -1
- package/dist/chat/ui/intelligent-ui/renderers/base-land.js +1 -1
- package/dist/chat/ui/intelligent-ui/renderers/binding.js +3 -3
- package/dist/chat/ui/intelligent-ui/renderers/chart.js +1223 -123
- package/dist/chat/ui/intelligent-ui/renderers/choices.js +312 -34
- package/dist/chat/ui/intelligent-ui/renderers/content.js +1241 -86
- package/dist/chat/ui/intelligent-ui/renderers/data.js +619 -54
- package/dist/chat/ui/intelligent-ui/renderers/inputs.js +868 -67
- package/dist/chat/ui/intelligent-ui/renderers/links.js +366 -62
- package/dist/chat/ui/intelligent-ui/renderers/map-slots.js +118 -60
- package/dist/chat/ui/intelligent-ui/renderers/map-style.js +85 -78
- package/dist/chat/ui/intelligent-ui/renderers/map-view.js +282 -217
- package/dist/chat/ui/intelligent-ui/renderers/map.js +621 -69
- package/dist/chat/ui/intelligent-ui/renderers/place-point.js +15 -8
- package/dist/chat/ui/intelligent-ui/renderers/structure.js +262 -20
- package/dist/chat/ui/intelligent-ui/renderers/text.js +674 -49
- package/dist/chat/ui/intelligent-ui/reply-parts.js +24 -15
- package/dist/chat/ui/intelligent-ui/table-data.js +97 -57
- package/dist/chat/ui/intelligent-ui/tones.js +31 -31
- package/dist/chat/ui/intelligent-ui/use-in-view.js +30 -12
- package/dist/chat/ui/intelligent-ui/use-later.js +28 -13
- package/dist/chat/ui/intelligent-ui/use-truncated.js +45 -21
- package/dist/chat/ui/intelligent-ui/use-ui-links.js +296 -109
- package/dist/chat/ui/intelligent-ui/use-ui-queries.js +256 -246
- package/dist/chat/ui/markdown-blocks.js +296 -262
- package/dist/chat/ui/mermaid.d.ts +8 -20
- package/dist/chat/ui/mermaid.js +47 -84
- package/dist/chat/ui/quote-selection.js +32 -29
- package/dist/chat/ui/rehype-chips.js +35 -23
- package/dist/chat/ui/rehype-fade.js +28 -17
- package/dist/chat/ui/remark-html-as-text.js +22 -15
- package/dist/chat/ui/reply-context.js +1 -1
- package/dist/chat/ui/reveal.js +161 -72
- package/dist/chat/ui/rows/ForksRow.js +226 -24
- package/dist/chat/ui/rows/GeneratedImageRow.js +541 -87
- package/dist/chat/ui/rows/MessageRows.js +1706 -159
- package/dist/chat/ui/rows/RowContainer.js +57 -7
- package/dist/chat/ui/rows/Rows.js +463 -54
- package/dist/chat/ui/rows/SubagentRow.js +577 -60
- package/dist/chat/ui/rows/TaskRow.js +359 -40
- package/dist/chat/ui/rows/VisualRow.js +233 -11
- package/dist/chat/ui/rows/WorkRows.d.ts +3 -0
- package/dist/chat/ui/rows/WorkRows.js +1945 -164
- package/dist/chat/ui/rows/WorkflowRow.js +756 -37
- package/dist/chat/ui/rows/row-rhythm.js +27 -17
- package/dist/chat/ui/theme-watch.js +26 -23
- package/dist/chat/ui/timestamp-format.js +4 -1
- package/dist/chat/ui/use-diff-source-tokens.js +70 -34
- package/dist/chat/ui/useToggleSet.js +51 -19
- package/dist/chat/ui/visual-theme.js +153 -128
- package/dist/chat/visual-bridge.js +123 -123
- package/dist/chat/visual-viewport.js +94 -83
- package/dist/chat/visuals.js +13 -5
- package/dist/host-hooks.d.ts +29 -0
- package/dist/host-hooks.js +78 -0
- package/dist/host.js +120 -48
- package/dist/index.js +1 -1
- package/dist/lazy.js +38 -32
- package/dist/locales/en/agent-chat.d.ts +42 -0
- package/dist/locales/en/agent-chat.js +755 -713
- package/dist/locales/en/agent-prompts.js +42 -42
- package/dist/locales/en/agent-providers.d.ts +1 -0
- package/dist/locales/en/agent-providers.js +166 -165
- package/dist/locales/en/agent-usage.d.ts +6 -0
- package/dist/locales/en/agent-usage.js +129 -123
- package/dist/locales/nl/agent-chat.d.ts +42 -0
- package/dist/locales/nl/agent-chat.js +755 -713
- package/dist/locales/nl/agent-prompts.js +42 -42
- package/dist/locales/nl/agent-providers.d.ts +1 -0
- package/dist/locales/nl/agent-providers.js +166 -165
- package/dist/locales/nl/agent-usage.d.ts +6 -0
- package/dist/locales/nl/agent-usage.js +129 -123
- package/dist/locales.js +14 -14
- package/dist/mounted-registry.js +31 -30
- package/dist/port-transport.js +122 -111
- package/dist/prompts/index.js +1 -1
- package/dist/prompts/logic/focus.js +15 -14
- package/dist/prompts/logic/keys.js +93 -59
- package/dist/prompts/logic/prompts.js +27 -14
- package/dist/prompts/logic/subjects.js +60 -46
- package/dist/prompts/logic/useFocusAfterAnswer.js +60 -20
- package/dist/prompts/logic/usePromptSession.js +88 -77
- package/dist/prompts/ui/ApprovalBody.js +246 -27
- package/dist/prompts/ui/PromptActions.js +215 -9
- package/dist/prompts/ui/PromptCard.js +215 -36
- package/dist/prompts/ui/PromptView.js +372 -34
- package/dist/prompts/ui/QuestionBody.js +269 -73
- package/dist/providers/AccountColors.js +36 -5
- package/dist/providers/AccountDetail.js +683 -50
- package/dist/providers/AccountVariables.js +139 -32
- package/dist/providers/AddAccountForm.js +125 -38
- package/dist/providers/CliDetail.js +343 -36
- package/dist/providers/InstallPage.js +644 -59
- package/dist/providers/ProviderList.d.ts +2 -1
- package/dist/providers/ProviderList.js +215 -23
- package/dist/providers/ProvidersPane.d.ts +4 -2
- package/dist/providers/ProvidersPane.js +244 -64
- package/dist/providers/account-actions.js +54 -30
- package/dist/providers/index.js +1 -1
- package/dist/providers/install-steps.js +12 -9
- package/dist/providers/pane-target.d.ts +3 -0
- package/dist/providers/pane-target.js +34 -13
- package/dist/providers/parts.js +62 -12
- package/dist/providers/provider-abilities.js +5 -5
- package/dist/providers/provider-groups.js +75 -40
- package/dist/providers/variables.js +73 -39
- package/dist/scope.js +6 -6
- package/dist/settings/sections.js +18 -18
- package/dist/state/chats.js +404 -192
- package/dist/state/index.js +1 -1
- package/dist/state/provider-accounts.js +70 -47
- package/dist/state/providers.js +45 -16
- package/dist/state/usage.js +154 -77
- package/dist/storage.js +69 -68
- package/dist/testing/index.js +1 -1
- package/dist/testing/prompts.js +105 -67
- package/dist/transport.js +10 -10
- package/dist/ui/PlainTextarea.js +27 -3
- package/dist/usage/LimitsList.js +646 -40
- package/dist/usage/UsageBreakdown.js +879 -38
- package/dist/usage/UsageChart.js +311 -32
- package/dist/usage/UsageDialog.js +46 -4
- package/dist/usage/UsageLimits.js +467 -34
- package/dist/usage/UsageLimitsCard.js +95 -11
- package/dist/usage/UsagePage.js +817 -96
- package/dist/usage/UsagePane.js +164 -10
- package/dist/usage/UsageSummary.js +151 -6
- package/dist/usage/UsageTiles.js +164 -14
- package/dist/usage/format.js +32 -32
- package/dist/usage/index.d.ts +1 -1
- package/dist/usage/index.js +2 -1
- package/dist/usage/limit-groups.d.ts +2 -0
- package/dist/usage/limit-groups.js +77 -59
- package/dist/usage/limits.js +78 -43
- package/dist/usage/money.js +20 -4
- package/dist/usage/summary.js +85 -64
- package/package.json +9 -9
- package/src/agents/ModelOptionControl.tsx +3 -1
- package/src/agents/option-words.ts +27 -0
- package/src/chat/account-choice.ts +41 -1
- package/src/chat/composer-effort.ts +32 -0
- package/src/chat/forks.ts +4 -5
- package/src/chat/index.ts +3 -1
- package/src/chat/logic/effort.ts +32 -0
- package/src/chat/logic/picker-entries.ts +45 -10
- package/src/chat/logic/resume-compaction.ts +95 -17
- package/src/chat/logic/timeline.ts +11 -3
- package/src/chat/logic/workflow.ts +86 -4
- package/src/chat/preferences.ts +35 -0
- package/src/chat/subagent-view.ts +2 -3
- package/src/chat/ui/AnsiOutput.tsx +1 -2
- package/src/chat/ui/BookmarkSubmenu.tsx +3 -3
- package/src/chat/ui/ChatActivity.tsx +14 -22
- package/src/chat/ui/ChatReferenceChip.tsx +2 -3
- package/src/chat/ui/Composer.tsx +15 -7
- package/src/chat/ui/EditDiff.tsx +2 -3
- package/src/chat/ui/LimitState.tsx +2 -2
- package/src/chat/ui/Markdown.tsx +10 -8
- package/src/chat/ui/MermaidBlock.tsx +57 -49
- package/src/chat/ui/Pickers.tsx +49 -29
- package/src/chat/ui/PromptComposer.tsx +7 -9
- package/src/chat/ui/ResumeCompactionDock.tsx +16 -4
- package/src/chat/ui/RunSettings.tsx +67 -28
- package/src/chat/ui/Scrubber.tsx +3 -3
- package/src/chat/ui/ShellCommand.tsx +2 -0
- package/src/chat/ui/SubagentInfo.tsx +2 -3
- package/src/chat/ui/SubagentTimeline.tsx +12 -16
- package/src/chat/ui/Timeline.tsx +6 -6
- package/src/chat/ui/UnifiedDiff.tsx +3 -4
- package/src/chat/ui/VisualFrame.tsx +5 -8
- package/src/chat/ui/code-theme.ts +4 -4
- package/src/chat/ui/composer/placeholder.ts +2 -2
- package/src/chat/ui/composer/use-compaction-offer.ts +36 -16
- package/src/chat/ui/composer/use-composer-menus.ts +4 -9
- package/src/chat/ui/composer/use-composer-submit.ts +2 -1
- package/src/chat/ui/composer/use-effort-stepper.ts +56 -0
- package/src/chat/ui/composer/use-notice.ts +2 -2
- package/src/chat/ui/diff/EditorEditDiff.tsx +9 -13
- package/src/chat/ui/diff/LegacyEditDiff.tsx +12 -17
- package/src/chat/ui/diff/LegacyUnifiedDiff.tsx +13 -21
- package/src/chat/ui/diff/use-review-stack.ts +4 -4
- package/src/chat/ui/diff-theme.ts +3 -3
- package/src/chat/ui/file-links.ts +2 -2
- package/src/chat/ui/intelligent-ui/UiReply.tsx +2 -0
- package/src/chat/ui/intelligent-ui/renderers/chart.tsx +3 -3
- package/src/chat/ui/intelligent-ui/renderers/content.tsx +5 -6
- package/src/chat/ui/intelligent-ui/renderers/map-view.tsx +2 -1
- package/src/chat/ui/intelligent-ui/renderers/map.tsx +2 -1
- package/src/chat/ui/intelligent-ui/use-truncated.ts +16 -19
- package/src/chat/ui/intelligent-ui/use-ui-links.ts +3 -3
- package/src/chat/ui/mermaid.ts +52 -96
- package/src/chat/ui/rows/ForksRow.tsx +3 -5
- package/src/chat/ui/rows/GeneratedImageRow.tsx +2 -1
- package/src/chat/ui/rows/MessageRows.tsx +12 -21
- package/src/chat/ui/rows/SubagentRow.tsx +3 -3
- package/src/chat/ui/rows/TaskRow.tsx +1 -1
- package/src/chat/ui/rows/WorkRows.tsx +11 -6
- package/src/chat/ui/rows/WorkflowRow.tsx +144 -54
- package/src/chat/ui/useToggleSet.ts +15 -18
- package/src/chat/ui/visual-theme.ts +2 -3
- package/src/host-hooks.ts +113 -0
- package/src/lazy.tsx +2 -0
- package/src/locales/en/agent-chat.ts +142 -108
- package/src/locales/en/agent-prompts.ts +7 -7
- package/src/locales/en/agent-providers.ts +35 -34
- package/src/locales/en/agent-usage.ts +26 -20
- package/src/locales/nl/agent-chat.ts +134 -100
- package/src/locales/nl/agent-prompts.ts +5 -5
- package/src/locales/nl/agent-providers.ts +33 -32
- package/src/locales/nl/agent-usage.ts +25 -20
- package/src/providers/CliDetail.tsx +2 -1
- package/src/providers/InstallPage.tsx +2 -4
- package/src/providers/ProviderList.tsx +12 -2
- package/src/providers/ProvidersPane.tsx +45 -15
- package/src/providers/pane-target.ts +20 -4
- package/src/state/chats.ts +2 -2
- package/src/usage/LimitsList.tsx +12 -13
- package/src/usage/UsageBreakdown.tsx +17 -6
- package/src/usage/UsageLimits.tsx +2 -1
- package/src/usage/UsagePage.tsx +3 -3
- package/src/usage/index.ts +1 -1
- package/src/usage/limit-groups.ts +12 -0
- package/src/usage/limits.ts +2 -2
- package/src/usage/money.ts +1 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { Component, createContext, Fragment, memo, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
3
|
-
import ReactMarkdown
|
|
3
|
+
import ReactMarkdown from 'react-markdown';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { evaluateUiBlock, uiInputValues, isUiComponent, UI_CATALOG_VERSION, UiState } from '@adecore/intelligent-ui';
|
|
6
6
|
import { ErrorBoundary, Tooltip } from '@adecore/ui';
|
|
@@ -17,19 +17,20 @@ import { useUiQueries, useUiLiveValues } from './use-ui-queries.js';
|
|
|
17
17
|
import { UiSourceCitation } from './renderers/content.js';
|
|
18
18
|
import { uiChildrenOf, revealUiSource, uiLiveChoiceReason, uiUrlDomain } from './node-text.js';
|
|
19
19
|
import { uiReplyParts } from './reply-parts.js';
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
21
|
const localStates = new UiPageMemory(64);
|
|
21
22
|
function localState(key, block, answered) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
localStates.set(key, state);
|
|
23
|
+
let state = localStates.get(key);
|
|
24
|
+
if (!state) {
|
|
25
|
+
state = new UiState(block);
|
|
26
|
+
if (answered && answered.revision === block.revision) {
|
|
27
|
+
for (const [name, value] of Object.entries(answered.values ?? {})) {
|
|
28
|
+
state.set(name, value);
|
|
29
|
+
}
|
|
31
30
|
}
|
|
32
|
-
|
|
31
|
+
localStates.set(key, state);
|
|
32
|
+
}
|
|
33
|
+
return state;
|
|
33
34
|
}
|
|
34
35
|
/* The block itself, as the parent of its top-level nodes. */
|
|
35
36
|
const BLOCK = '$block';
|
|
@@ -40,88 +41,134 @@ const BLOCK = '$block';
|
|
|
40
41
|
const LITERAL_PARENTS = new Set(['CodeBlock', 'Tag', 'Choice', 'Item', 'Switch', 'Slider', 'Segmented', 'Option', 'Button', 'Column']);
|
|
41
42
|
/* Parents that stack their children, where a run of text and inline nodes is one paragraph. */
|
|
42
43
|
const PARAGRAPHS = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
[BLOCK]: 'text-xs text-text',
|
|
45
|
+
Tab: 'text-xs text-text',
|
|
46
|
+
Section: 'text-xs text-text-muted'
|
|
46
47
|
};
|
|
47
48
|
const LINKS = new Set(['File', 'Diff', 'Commit', 'Node']);
|
|
48
49
|
/* Constructs that would start a block or load an image stay text; without GFM a table never forms. */
|
|
49
|
-
const BLOCK_CONSTRUCTS = [
|
|
50
|
-
'blockQuote',
|
|
51
|
-
'codeFenced',
|
|
52
|
-
'codeIndented',
|
|
53
|
-
'definition',
|
|
54
|
-
'headingAtx',
|
|
55
|
-
'htmlFlow',
|
|
56
|
-
'htmlText',
|
|
57
|
-
'labelStartImage',
|
|
58
|
-
'list',
|
|
59
|
-
'setextUnderline',
|
|
60
|
-
'thematicBreak'
|
|
61
|
-
];
|
|
50
|
+
const BLOCK_CONSTRUCTS = ['blockQuote', 'codeFenced', 'codeIndented', 'definition', 'headingAtx', 'htmlFlow', 'htmlText', 'labelStartImage', 'list', 'setextUnderline', 'thematicBreak'];
|
|
62
51
|
/* Prose between the tags of a block is inline: only emphasis, code and links are Markdown, and a blank line is a line break. */
|
|
63
52
|
function remarkInlineProse() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
53
|
+
// The field remark-parse reads its syntax extensions from, as remark-gfm adds its own.
|
|
54
|
+
const data = this.data();
|
|
55
|
+
data.micromarkExtensions = [...(data.micromarkExtensions ?? []), {
|
|
56
|
+
disable: {
|
|
57
|
+
null: BLOCK_CONSTRUCTS
|
|
58
|
+
}
|
|
59
|
+
}];
|
|
60
|
+
return tree => {
|
|
61
|
+
tree.children = [{
|
|
62
|
+
type: 'paragraph',
|
|
63
|
+
children: (tree.children ?? []).flatMap((paragraph, index) => [...(index > 0 ? [{
|
|
64
|
+
type: 'break'
|
|
65
|
+
}] : []), ...(paragraph.children ?? [])])
|
|
66
|
+
}];
|
|
67
|
+
};
|
|
75
68
|
}
|
|
76
69
|
function remarkCitations() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
70
|
+
return tree => {
|
|
71
|
+
const visit = parent => {
|
|
72
|
+
if (['link', 'inlineCode', 'code'].includes(parent.type)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
parent.children = parent.children?.flatMap(child => {
|
|
76
|
+
if (child.type !== 'text' || !child.value) {
|
|
77
|
+
visit(child);
|
|
78
|
+
return [child];
|
|
79
|
+
}
|
|
80
|
+
const parts = [];
|
|
81
|
+
let start = 0;
|
|
82
|
+
for (const match of child.value.matchAll(/\[(\d{1,3})\]/g)) {
|
|
83
|
+
parts.push({
|
|
84
|
+
type: 'text',
|
|
85
|
+
value: child.value.slice(start, match.index)
|
|
86
|
+
});
|
|
87
|
+
parts.push({
|
|
88
|
+
type: 'citation',
|
|
89
|
+
data: {
|
|
90
|
+
hName: 'span',
|
|
91
|
+
hProperties: {
|
|
92
|
+
'data-ui-citation': match[1]
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
children: [{
|
|
96
|
+
type: 'text',
|
|
97
|
+
value: match[0]
|
|
98
|
+
}]
|
|
99
|
+
});
|
|
100
|
+
start = match.index + match[0].length;
|
|
101
|
+
}
|
|
102
|
+
parts.push({
|
|
103
|
+
type: 'text',
|
|
104
|
+
value: child.value.slice(start)
|
|
105
|
+
});
|
|
106
|
+
return parts;
|
|
107
|
+
});
|
|
103
108
|
};
|
|
109
|
+
visit(tree);
|
|
110
|
+
};
|
|
104
111
|
}
|
|
105
|
-
const CitationContext = createContext({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const CitationContext = createContext({
|
|
113
|
+
sources: new Map()
|
|
114
|
+
});
|
|
115
|
+
function ProseCitation(t0) {
|
|
116
|
+
const $ = _c(8);
|
|
117
|
+
const {
|
|
118
|
+
number,
|
|
119
|
+
children
|
|
120
|
+
} = t0;
|
|
121
|
+
const {
|
|
122
|
+
sources,
|
|
123
|
+
reveal
|
|
124
|
+
} = useContext(CitationContext);
|
|
125
|
+
let t1;
|
|
126
|
+
if ($[0] !== number || $[1] !== sources) {
|
|
127
|
+
t1 = sources.get(number);
|
|
128
|
+
$[0] = number;
|
|
129
|
+
$[1] = sources;
|
|
130
|
+
$[2] = t1;
|
|
131
|
+
} else {
|
|
132
|
+
t1 = $[2];
|
|
133
|
+
}
|
|
134
|
+
const source = t1;
|
|
135
|
+
let t2;
|
|
136
|
+
if ($[3] !== children || $[4] !== number || $[5] !== reveal || $[6] !== source) {
|
|
137
|
+
t2 = source ? /*#__PURE__*/_jsx(UiSourceCitation, {
|
|
138
|
+
number: number,
|
|
139
|
+
title: source.title,
|
|
140
|
+
url: source.url,
|
|
141
|
+
onReveal: reveal ? () => reveal(source) : undefined
|
|
142
|
+
}) : children;
|
|
143
|
+
$[3] = children;
|
|
144
|
+
$[4] = number;
|
|
145
|
+
$[5] = reveal;
|
|
146
|
+
$[6] = source;
|
|
147
|
+
$[7] = t2;
|
|
148
|
+
} else {
|
|
149
|
+
t2 = $[7];
|
|
150
|
+
}
|
|
151
|
+
return t2;
|
|
110
152
|
}
|
|
111
153
|
function sourceTargets(nodes) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
154
|
+
const lists = [];
|
|
155
|
+
const visit = (nodes, ancestors = []) => {
|
|
156
|
+
for (const node of nodes) {
|
|
157
|
+
const path = ['Tab', 'Section'].includes(node.type) ? [...ancestors, node.id] : ancestors;
|
|
158
|
+
if (node.type === 'Sources') {
|
|
159
|
+
lists.push(uiChildrenOf(node, 'Source').map(source => ({
|
|
160
|
+
id: source.id,
|
|
161
|
+
title: source.props.title,
|
|
162
|
+
url: source.props.url,
|
|
163
|
+
ancestors: path
|
|
164
|
+
})));
|
|
165
|
+
}
|
|
166
|
+
visit(node.children, path);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
visit(nodes);
|
|
170
|
+
// Numbers restart in each Sources list, so multiple lists have no unambiguous prose target.
|
|
171
|
+
return new Map(lists.length === 1 ? lists[0].map((source, index) => [index + 1, source]) : []);
|
|
125
172
|
}
|
|
126
173
|
const PROSE_PLUGINS = [remarkInlineProse, remarkCitations];
|
|
127
174
|
const PROSE_ELEMENTS = ['p', 'br', 'strong', 'em', 'code', 'a', 'span'];
|
|
@@ -129,108 +176,354 @@ const FADE_PLUGINS = [rehypeFadeWords];
|
|
|
129
176
|
const NO_PLUGINS = [];
|
|
130
177
|
const ProseUrlContext = createContext(undefined);
|
|
131
178
|
/* Through the host only, like a Source: the address is the model's, so nothing here navigates by itself. */
|
|
132
|
-
function ProseLink(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
179
|
+
function ProseLink(t0) {
|
|
180
|
+
const $ = _c(11);
|
|
181
|
+
const {
|
|
182
|
+
href,
|
|
183
|
+
children
|
|
184
|
+
} = t0;
|
|
185
|
+
const openUrl = useContext(ProseUrlContext);
|
|
186
|
+
if (openUrl === undefined || href === undefined || !/^https?:\/\//i.test(href)) {
|
|
187
|
+
return children;
|
|
188
|
+
}
|
|
189
|
+
let t1;
|
|
190
|
+
if ($[0] !== href) {
|
|
191
|
+
t1 = uiUrlDomain(href);
|
|
192
|
+
$[0] = href;
|
|
193
|
+
$[1] = t1;
|
|
194
|
+
} else {
|
|
195
|
+
t1 = $[1];
|
|
196
|
+
}
|
|
197
|
+
let t2;
|
|
198
|
+
if ($[2] !== href || $[3] !== openUrl) {
|
|
199
|
+
t2 = () => openUrl(href);
|
|
200
|
+
$[2] = href;
|
|
201
|
+
$[3] = openUrl;
|
|
202
|
+
$[4] = t2;
|
|
203
|
+
} else {
|
|
204
|
+
t2 = $[4];
|
|
205
|
+
}
|
|
206
|
+
let t3;
|
|
207
|
+
if ($[5] !== children || $[6] !== t2) {
|
|
208
|
+
t3 = /*#__PURE__*/_jsx("button", {
|
|
209
|
+
type: "button",
|
|
210
|
+
className: "cursor-pointer text-accent underline underline-offset-2 select-text",
|
|
211
|
+
onClick: t2,
|
|
212
|
+
children: children
|
|
213
|
+
});
|
|
214
|
+
$[5] = children;
|
|
215
|
+
$[6] = t2;
|
|
216
|
+
$[7] = t3;
|
|
217
|
+
} else {
|
|
218
|
+
t3 = $[7];
|
|
219
|
+
}
|
|
220
|
+
let t4;
|
|
221
|
+
if ($[8] !== t1 || $[9] !== t3) {
|
|
222
|
+
t4 = /*#__PURE__*/_jsx(Tooltip, {
|
|
223
|
+
label: t1,
|
|
224
|
+
children: t3
|
|
225
|
+
});
|
|
226
|
+
$[8] = t1;
|
|
227
|
+
$[9] = t3;
|
|
228
|
+
$[10] = t4;
|
|
229
|
+
} else {
|
|
230
|
+
t4 = $[10];
|
|
231
|
+
}
|
|
232
|
+
return t4;
|
|
138
233
|
}
|
|
139
234
|
const PROSE_COMPONENTS = {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
235
|
+
p: ({
|
|
236
|
+
children
|
|
237
|
+
}) => children,
|
|
238
|
+
code: ({
|
|
239
|
+
children
|
|
240
|
+
}) => /*#__PURE__*/_jsx("code", {
|
|
241
|
+
className: "rounded-sm bg-ui-tile px-1 py-px font-mono text-code",
|
|
242
|
+
children: children
|
|
243
|
+
}),
|
|
244
|
+
a: ({
|
|
245
|
+
href,
|
|
246
|
+
children
|
|
247
|
+
}) => /*#__PURE__*/_jsx(ProseLink, {
|
|
248
|
+
href: href,
|
|
249
|
+
children: children
|
|
250
|
+
}),
|
|
251
|
+
span: ({
|
|
252
|
+
node,
|
|
253
|
+
children,
|
|
254
|
+
className
|
|
255
|
+
}) => node?.properties['data-ui-citation'] !== undefined ? /*#__PURE__*/_jsx(ProseCitation, {
|
|
256
|
+
number: Number(node.properties['data-ui-citation']),
|
|
257
|
+
children: children
|
|
258
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
259
|
+
className: className,
|
|
260
|
+
children: children
|
|
261
|
+
})
|
|
144
262
|
};
|
|
145
263
|
/*
|
|
146
264
|
* Text an agent wrote in a block, as inline Markdown without raw HTML. Markdown trims a paragraph,
|
|
147
265
|
* so the whitespace at either end stays text: it is the space between a word and the tag beside it.
|
|
148
266
|
* While the block streams every new word fades in, as in the prose of the reply around it.
|
|
149
267
|
*/
|
|
150
|
-
const UiProse = memo(function UiProse(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
268
|
+
const UiProse = memo(function UiProse(t0) {
|
|
269
|
+
const $ = _c(10);
|
|
270
|
+
const {
|
|
271
|
+
text,
|
|
272
|
+
fade,
|
|
273
|
+
openUrl
|
|
274
|
+
} = t0;
|
|
275
|
+
let t1;
|
|
276
|
+
if ($[0] !== text) {
|
|
277
|
+
t1 = /^(\s*)([\s\S]*?)(\s*)$/.exec(text) ?? [];
|
|
278
|
+
$[0] = text;
|
|
279
|
+
$[1] = t1;
|
|
280
|
+
} else {
|
|
281
|
+
t1 = $[1];
|
|
282
|
+
}
|
|
283
|
+
const [, t2, t3, t4] = t1;
|
|
284
|
+
const lead = t2 === undefined ? "" : t2;
|
|
285
|
+
const body = t3 === undefined ? "" : t3;
|
|
286
|
+
const trail = t4 === undefined ? "" : t4;
|
|
287
|
+
if (body === "") {
|
|
288
|
+
return text;
|
|
289
|
+
}
|
|
290
|
+
const t5 = fade ? FADE_PLUGINS : NO_PLUGINS;
|
|
291
|
+
let t6;
|
|
292
|
+
if ($[2] !== body || $[3] !== t5) {
|
|
293
|
+
t6 = /*#__PURE__*/_jsx(ReactMarkdown, {
|
|
294
|
+
remarkPlugins: PROSE_PLUGINS,
|
|
295
|
+
rehypePlugins: t5,
|
|
296
|
+
allowedElements: PROSE_ELEMENTS,
|
|
297
|
+
unwrapDisallowed: true,
|
|
298
|
+
components: PROSE_COMPONENTS,
|
|
299
|
+
children: body
|
|
300
|
+
});
|
|
301
|
+
$[2] = body;
|
|
302
|
+
$[3] = t5;
|
|
303
|
+
$[4] = t6;
|
|
304
|
+
} else {
|
|
305
|
+
t6 = $[4];
|
|
306
|
+
}
|
|
307
|
+
let t7;
|
|
308
|
+
if ($[5] !== lead || $[6] !== openUrl || $[7] !== t6 || $[8] !== trail) {
|
|
309
|
+
t7 = /*#__PURE__*/_jsxs(ProseUrlContext, {
|
|
310
|
+
value: openUrl,
|
|
311
|
+
children: [lead, t6, trail]
|
|
312
|
+
});
|
|
313
|
+
$[5] = lead;
|
|
314
|
+
$[6] = openUrl;
|
|
315
|
+
$[7] = t6;
|
|
316
|
+
$[8] = trail;
|
|
317
|
+
$[9] = t7;
|
|
318
|
+
} else {
|
|
319
|
+
t7 = $[9];
|
|
320
|
+
}
|
|
321
|
+
return t7;
|
|
156
322
|
});
|
|
157
323
|
/* Which text nodes of a block the agent wrote out, by id; the value of an expression is data and stays as it is. */
|
|
158
324
|
function writtenTexts(nodes, into = new Map()) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
writtenTexts(node.children, into);
|
|
325
|
+
for (const node of nodes) {
|
|
326
|
+
if (node.type === '$text') {
|
|
327
|
+
into.set(node.id, node.expressions.text === undefined);
|
|
164
328
|
}
|
|
165
|
-
|
|
329
|
+
writtenTexts(node.children, into);
|
|
330
|
+
}
|
|
331
|
+
return into;
|
|
166
332
|
}
|
|
167
333
|
function isInline(node) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
334
|
+
if (node.type === '$text') {
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
return node.error === undefined && (node.type === 'Tag' || LINKS.has(node.type) && node.children.length === 0);
|
|
172
338
|
}
|
|
173
339
|
function isBlank(node) {
|
|
174
|
-
|
|
340
|
+
return node.type === '$text' && String(node.props.text ?? '').trim() === '';
|
|
175
341
|
}
|
|
176
342
|
/* The children of one parent, each in its own boundary. Where the parent stacks them, a run of text and inline nodes becomes a paragraph. */
|
|
177
|
-
function UiNodes({
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
343
|
+
function UiNodes({
|
|
344
|
+
nodes,
|
|
345
|
+
parent,
|
|
346
|
+
texts,
|
|
347
|
+
context
|
|
348
|
+
}) {
|
|
349
|
+
const drawn = node => /*#__PURE__*/_jsx(UiNodeBoundary, {
|
|
350
|
+
node: node,
|
|
351
|
+
children: /*#__PURE__*/_jsx(UiNodeBody, {
|
|
352
|
+
node: node,
|
|
353
|
+
parent: parent,
|
|
354
|
+
texts: texts,
|
|
355
|
+
context: context
|
|
356
|
+
})
|
|
357
|
+
}, node.id);
|
|
358
|
+
const paragraph = PARAGRAPHS[parent];
|
|
359
|
+
if (parent === 'Choices') {
|
|
360
|
+
// A primary choice stands first in the order a keyboard and a screen reader meet it too, not only on screen.
|
|
361
|
+
return [...nodes].sort((a, b) => Number(b.props.primary === true) - Number(a.props.primary === true)).map(drawn);
|
|
362
|
+
}
|
|
363
|
+
if (paragraph === undefined) {
|
|
364
|
+
return nodes.map(drawn);
|
|
365
|
+
}
|
|
366
|
+
const output = [];
|
|
367
|
+
let run = [];
|
|
368
|
+
const close = () => {
|
|
369
|
+
if (run.some(node => !isBlank(node))) {
|
|
370
|
+
output.push(/*#__PURE__*/_jsx("div", {
|
|
371
|
+
className: paragraph,
|
|
372
|
+
children: run.map(drawn)
|
|
373
|
+
}, `run:${run[0].id}`));
|
|
183
374
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (run.some((node) => !isBlank(node))) {
|
|
191
|
-
output.push(_jsx("div", { className: paragraph, children: run.map(drawn) }, `run:${run[0].id}`));
|
|
192
|
-
}
|
|
193
|
-
run = [];
|
|
194
|
-
};
|
|
195
|
-
for (const node of nodes) {
|
|
196
|
-
if (isInline(node)) {
|
|
197
|
-
run.push(node);
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
close();
|
|
201
|
-
output.push(drawn(node));
|
|
375
|
+
run = [];
|
|
376
|
+
};
|
|
377
|
+
for (const node of nodes) {
|
|
378
|
+
if (isInline(node)) {
|
|
379
|
+
run.push(node);
|
|
380
|
+
continue;
|
|
202
381
|
}
|
|
203
382
|
close();
|
|
204
|
-
|
|
383
|
+
output.push(drawn(node));
|
|
384
|
+
}
|
|
385
|
+
close();
|
|
386
|
+
return output;
|
|
205
387
|
}
|
|
206
388
|
class UiNodeBoundary extends Component {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
389
|
+
state = {
|
|
390
|
+
failed: false,
|
|
391
|
+
node: this.props.node
|
|
392
|
+
};
|
|
393
|
+
static getDerivedStateFromError() {
|
|
394
|
+
return {
|
|
395
|
+
failed: true
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
static getDerivedStateFromProps(props, state) {
|
|
399
|
+
return props.node === state.node ? null : {
|
|
400
|
+
failed: false,
|
|
401
|
+
node: props.node
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
render() {
|
|
405
|
+
return this.state.failed ? /*#__PURE__*/_jsx(UiFallbackPart, {
|
|
406
|
+
fallback: this.props.node.fallback,
|
|
407
|
+
problem: {
|
|
408
|
+
kind: 'failed'
|
|
409
|
+
}
|
|
410
|
+
}) : this.props.children;
|
|
411
|
+
}
|
|
217
412
|
}
|
|
218
|
-
function UiNodeBody(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
413
|
+
function UiNodeBody(t0) {
|
|
414
|
+
const $ = _c(25);
|
|
415
|
+
const {
|
|
416
|
+
node,
|
|
417
|
+
parent,
|
|
418
|
+
texts,
|
|
419
|
+
context
|
|
420
|
+
} = t0;
|
|
421
|
+
if (node.type === "$text") {
|
|
422
|
+
const text = String(node.props.text ?? "");
|
|
423
|
+
let t1;
|
|
424
|
+
if ($[0] !== context || $[1] !== node.id || $[2] !== node.sourceId || $[3] !== parent || $[4] !== text || $[5] !== texts) {
|
|
425
|
+
t1 = LITERAL_PARENTS.has(parent) || texts.get(node.sourceId ?? node.id) !== true ? text : /*#__PURE__*/_jsx(UiProse, {
|
|
426
|
+
text: text,
|
|
427
|
+
fade: context.phase === "streaming",
|
|
428
|
+
openUrl: context.openUrl
|
|
429
|
+
});
|
|
430
|
+
$[0] = context;
|
|
431
|
+
$[1] = node.id;
|
|
432
|
+
$[2] = node.sourceId;
|
|
433
|
+
$[3] = parent;
|
|
434
|
+
$[4] = text;
|
|
435
|
+
$[5] = texts;
|
|
436
|
+
$[6] = t1;
|
|
437
|
+
} else {
|
|
438
|
+
t1 = $[6];
|
|
439
|
+
}
|
|
440
|
+
return t1;
|
|
441
|
+
}
|
|
442
|
+
if (node.error !== undefined) {
|
|
443
|
+
let t1;
|
|
444
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
445
|
+
t1 = {
|
|
446
|
+
kind: "failed"
|
|
447
|
+
};
|
|
448
|
+
$[7] = t1;
|
|
449
|
+
} else {
|
|
450
|
+
t1 = $[7];
|
|
222
451
|
}
|
|
223
|
-
|
|
224
|
-
|
|
452
|
+
let t2;
|
|
453
|
+
if ($[8] !== node.fallback) {
|
|
454
|
+
t2 = /*#__PURE__*/_jsx(UiFallbackPart, {
|
|
455
|
+
fallback: node.fallback,
|
|
456
|
+
problem: t1
|
|
457
|
+
});
|
|
458
|
+
$[8] = node.fallback;
|
|
459
|
+
$[9] = t2;
|
|
460
|
+
} else {
|
|
461
|
+
t2 = $[9];
|
|
225
462
|
}
|
|
226
|
-
|
|
227
|
-
|
|
463
|
+
return t2;
|
|
464
|
+
}
|
|
465
|
+
if (!isUiComponent(node.type)) {
|
|
466
|
+
let t1;
|
|
467
|
+
if ($[10] !== node.type) {
|
|
468
|
+
t1 = {
|
|
469
|
+
kind: "unknown",
|
|
470
|
+
component: node.type
|
|
471
|
+
};
|
|
472
|
+
$[10] = node.type;
|
|
473
|
+
$[11] = t1;
|
|
474
|
+
} else {
|
|
475
|
+
t1 = $[11];
|
|
228
476
|
}
|
|
229
|
-
|
|
230
|
-
if (
|
|
231
|
-
|
|
477
|
+
let t2;
|
|
478
|
+
if ($[12] !== node.fallback || $[13] !== t1) {
|
|
479
|
+
t2 = /*#__PURE__*/_jsx(UiFallbackPart, {
|
|
480
|
+
fallback: node.fallback,
|
|
481
|
+
problem: t1
|
|
482
|
+
});
|
|
483
|
+
$[12] = node.fallback;
|
|
484
|
+
$[13] = t1;
|
|
485
|
+
$[14] = t2;
|
|
486
|
+
} else {
|
|
487
|
+
t2 = $[14];
|
|
232
488
|
}
|
|
233
|
-
return
|
|
489
|
+
return t2;
|
|
490
|
+
}
|
|
491
|
+
const Renderer = UI_RENDERERS[node.type];
|
|
492
|
+
if (Renderer === null) {
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
let t1;
|
|
496
|
+
if ($[15] !== context || $[16] !== node.children || $[17] !== node.type || $[18] !== texts) {
|
|
497
|
+
t1 = /*#__PURE__*/_jsx(UiNodes, {
|
|
498
|
+
nodes: node.children,
|
|
499
|
+
parent: node.type,
|
|
500
|
+
texts: texts,
|
|
501
|
+
context: context
|
|
502
|
+
});
|
|
503
|
+
$[15] = context;
|
|
504
|
+
$[16] = node.children;
|
|
505
|
+
$[17] = node.type;
|
|
506
|
+
$[18] = texts;
|
|
507
|
+
$[19] = t1;
|
|
508
|
+
} else {
|
|
509
|
+
t1 = $[19];
|
|
510
|
+
}
|
|
511
|
+
let t2;
|
|
512
|
+
if ($[20] !== Renderer || $[21] !== context || $[22] !== node || $[23] !== t1) {
|
|
513
|
+
t2 = /*#__PURE__*/_jsx(Renderer, {
|
|
514
|
+
node: node,
|
|
515
|
+
context: context,
|
|
516
|
+
children: t1
|
|
517
|
+
});
|
|
518
|
+
$[20] = Renderer;
|
|
519
|
+
$[21] = context;
|
|
520
|
+
$[22] = node;
|
|
521
|
+
$[23] = t1;
|
|
522
|
+
$[24] = t2;
|
|
523
|
+
} else {
|
|
524
|
+
t2 = $[24];
|
|
525
|
+
}
|
|
526
|
+
return t2;
|
|
234
527
|
}
|
|
235
528
|
/*
|
|
236
529
|
* The points the machine froze beside a block, as a renderer asks for them. Until the block is frozen
|
|
@@ -238,111 +531,222 @@ function UiNodeBody({ node, parent, texts, context }) {
|
|
|
238
531
|
* with no reading for its current address is one the machine did not look up.
|
|
239
532
|
*/
|
|
240
533
|
function placeReader(frozen, revision, unrecorded) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
534
|
+
if (frozen === undefined || frozen.revision !== revision) {
|
|
535
|
+
return () => unrecorded ? null : undefined;
|
|
536
|
+
}
|
|
537
|
+
return (nodeId, address) => {
|
|
538
|
+
const reading = Object.hasOwn(frozen.places ?? {}, nodeId) ? frozen.places[nodeId] : undefined;
|
|
539
|
+
return reading?.address === address.trim() && reading.state === 'found' && reading.lat !== undefined && reading.lon !== undefined ? {
|
|
540
|
+
lat: reading.lat,
|
|
541
|
+
lon: reading.lon,
|
|
542
|
+
label: reading.label
|
|
543
|
+
} : null;
|
|
544
|
+
};
|
|
250
545
|
}
|
|
251
|
-
function UiBlockBody({
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
546
|
+
function UiBlockBody({
|
|
547
|
+
block,
|
|
548
|
+
context,
|
|
549
|
+
answered,
|
|
550
|
+
frozen,
|
|
551
|
+
unrecorded
|
|
552
|
+
}) {
|
|
553
|
+
// The block's state changes in place and only its revision says so; compiled, the evaluation of the first revision would stay.
|
|
554
|
+
'use no memo';
|
|
555
|
+
|
|
556
|
+
const host = useChatHost();
|
|
557
|
+
const {
|
|
558
|
+
t
|
|
559
|
+
} = useTranslation('agent-chat');
|
|
560
|
+
const key = JSON.stringify([context.scopeId, context.chatId, context.itemId, block.id]);
|
|
561
|
+
const [state] = useState(() => localState(key, block, answered));
|
|
562
|
+
state.sync(block);
|
|
563
|
+
const stateRevision = useSyncExternalStore(listener => state.subscribe(listener), () => state.snapshot(), () => state.snapshot());
|
|
564
|
+
const [optimistic, setOptimistic] = useState(null);
|
|
565
|
+
const [failedChoiceId, setFailedChoiceId] = useState(null);
|
|
566
|
+
const pending = useRef(false);
|
|
567
|
+
useEffect(() => {
|
|
568
|
+
if (answered && answered.revision === block.revision && answered.values) {
|
|
569
|
+
for (const [name, value] of Object.entries(answered.values)) {
|
|
570
|
+
state.set(name, value);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}, [state, answered, block.revision]);
|
|
574
|
+
const answer = answered && answered.revision === block.revision ? {
|
|
575
|
+
choiceId: answered.choiceId,
|
|
576
|
+
state: answered.queued ? 'queued' : 'sent'
|
|
577
|
+
} : optimistic?.revision === block.revision ? optimistic : null;
|
|
578
|
+
const [element, setElement] = useState(null);
|
|
579
|
+
const navigation = useContext(UiReplyNavigationContext);
|
|
580
|
+
const flash = navigation?.flash;
|
|
581
|
+
const flashing = navigation?.chatId === context.chatId && flash?.itemId === context.itemId && flash.blockId === block.id && flash.revision === block.revision;
|
|
582
|
+
const queries = useUiQueries(block, state, context, element, frozen);
|
|
583
|
+
const links = useUiLinks(block, state, context, queries.reads, frozen);
|
|
584
|
+
// The state changes in place, so its revision is what tells this evaluation it went stale.
|
|
585
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
586
|
+
const evaluation = useMemo(() => evaluateUiBlock(block, state), [block, state, stateRevision]);
|
|
587
|
+
const texts = useMemo(() => writtenTexts(block.nodes), [block]);
|
|
588
|
+
const sources = useMemo(() => sourceTargets(evaluation.nodes), [evaluation]);
|
|
589
|
+
const citations = useMemo(() => ({
|
|
590
|
+
sources,
|
|
591
|
+
reveal: element ? source => {
|
|
592
|
+
void revealUiSource(element, source.id, source.ancestors);
|
|
593
|
+
} : undefined
|
|
594
|
+
}), [sources, element]);
|
|
595
|
+
const liveValue = useUiLiveValues(block, evaluation.nodes, queries.currentReadings);
|
|
596
|
+
const sendChoice = host.intelligentUi?.sendChoice;
|
|
597
|
+
const place = useMemo(() => placeReader(frozen, block.revision, unrecorded), [frozen, block.revision, unrecorded]);
|
|
598
|
+
const rendering = {
|
|
599
|
+
...context,
|
|
600
|
+
...links,
|
|
601
|
+
place,
|
|
602
|
+
answer,
|
|
603
|
+
failedChoiceId,
|
|
604
|
+
live: queries.live,
|
|
605
|
+
liveValue,
|
|
606
|
+
choiceReason: uiLiveChoiceReason(t, queries.live),
|
|
607
|
+
onChoose: !queries.ready || queries.reading ? undefined : sendChoice && block.revision && block.complete && context.phase === 'final' ? choiceId => {
|
|
608
|
+
if (pending.current || answer || queries.reading) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const values = uiInputValues(block, state);
|
|
612
|
+
const reads = queries.readsFor(values);
|
|
613
|
+
if (reads === null) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
pending.current = true;
|
|
617
|
+
setFailedChoiceId(null);
|
|
618
|
+
const revision = block.revision;
|
|
619
|
+
setOptimistic({
|
|
620
|
+
revision,
|
|
621
|
+
choiceId,
|
|
622
|
+
state: 'sending'
|
|
623
|
+
});
|
|
624
|
+
void sendChoice(context.scopeId, {
|
|
625
|
+
chatId: context.chatId,
|
|
626
|
+
itemId: context.itemId,
|
|
627
|
+
blockId: block.id,
|
|
628
|
+
revision,
|
|
629
|
+
choiceId,
|
|
630
|
+
reads,
|
|
631
|
+
values
|
|
632
|
+
}).then(state_0 => setOptimistic({
|
|
633
|
+
revision,
|
|
634
|
+
choiceId,
|
|
635
|
+
state: state_0
|
|
636
|
+
})).catch(() => {
|
|
637
|
+
setOptimistic(null);
|
|
638
|
+
setFailedChoiceId(choiceId);
|
|
639
|
+
}).finally(() => {
|
|
640
|
+
pending.current = false;
|
|
641
|
+
});
|
|
642
|
+
} : undefined
|
|
643
|
+
};
|
|
644
|
+
const unknown = block.catalogVersion !== UI_CATALOG_VERSION;
|
|
645
|
+
const failed = !unknown && !block.nodes.length && block.diagnostics.length > 0;
|
|
646
|
+
const shownAsText = unknown ? t('blocks.unreadable') : failed ? block.diagnostics[0].message : undefined;
|
|
647
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
648
|
+
ref: setElement,
|
|
649
|
+
className: "relative",
|
|
650
|
+
"data-ui-block": block.id,
|
|
651
|
+
"data-ui-revision": block.revision,
|
|
652
|
+
tabIndex: -1,
|
|
653
|
+
children: [flashing && /*#__PURE__*/_jsx("span", {
|
|
654
|
+
className: "chat-flash pointer-events-none absolute inset-0 rounded-lg",
|
|
655
|
+
"aria-hidden": true
|
|
656
|
+
}, flash.nonce), /*#__PURE__*/_jsx(UiBlockFrame, {
|
|
657
|
+
live: queries.live,
|
|
658
|
+
nodes: evaluation.nodes,
|
|
659
|
+
phase: context.phase,
|
|
660
|
+
fixes: [...block.diagnostics, ...evaluation.diagnostics].filter(diagnostic => diagnostic.severity !== 'warning'),
|
|
661
|
+
shownAsText: shownAsText,
|
|
662
|
+
answered: answered,
|
|
663
|
+
children: unknown || failed ? /*#__PURE__*/_jsx(ReplyMarkdown, {
|
|
664
|
+
text: block.fallback,
|
|
665
|
+
streaming: false
|
|
666
|
+
}) : /*#__PURE__*/_jsx(CitationContext, {
|
|
667
|
+
value: citations,
|
|
668
|
+
children: /*#__PURE__*/_jsx(UiNodes, {
|
|
669
|
+
nodes: evaluation.nodes,
|
|
670
|
+
parent: BLOCK,
|
|
671
|
+
texts: texts,
|
|
672
|
+
context: rendering
|
|
673
|
+
})
|
|
674
|
+
})
|
|
675
|
+
})]
|
|
676
|
+
});
|
|
344
677
|
}
|
|
345
678
|
/* Prose and cards a block gap apart, as the rows of a turn are; text that is only the newline between two fences draws nothing. */
|
|
346
|
-
export function UiReply(
|
|
347
|
-
|
|
348
|
-
|
|
679
|
+
export function UiReply(t0) {
|
|
680
|
+
const $ = _c(20);
|
|
681
|
+
const {
|
|
682
|
+
text,
|
|
683
|
+
blocks,
|
|
684
|
+
context,
|
|
685
|
+
answers,
|
|
686
|
+
queries,
|
|
687
|
+
reply
|
|
688
|
+
} = t0;
|
|
689
|
+
let t1;
|
|
690
|
+
if ($[0] !== answers || $[1] !== blocks || $[2] !== context.chatId || $[3] !== context.itemId || $[4] !== context.phase || $[5] !== context.scopeId || $[6] !== queries || $[7] !== reply || $[8] !== text) {
|
|
691
|
+
let t2;
|
|
692
|
+
if ($[10] !== answers || $[11] !== context.chatId || $[12] !== context.itemId || $[13] !== context.phase || $[14] !== context.scopeId || $[15] !== queries || $[16] !== reply) {
|
|
693
|
+
t2 = (part, index) => part.kind === "text" ? part.text.trim() !== "" && /*#__PURE__*/_jsx(Fragment, {
|
|
694
|
+
children: /*#__PURE__*/_jsx(ReplyMarkdown, {
|
|
695
|
+
text: part.text,
|
|
696
|
+
streaming: context.phase === "streaming",
|
|
697
|
+
reply: reply
|
|
698
|
+
})
|
|
699
|
+
}, `text:${index}`) : /*#__PURE__*/_jsx(ErrorBoundary, {
|
|
700
|
+
label: "UI block",
|
|
701
|
+
children: /*#__PURE__*/_jsx(UiBlockBody, {
|
|
702
|
+
block: part.block,
|
|
703
|
+
frozen: queries?.blocks[part.block.id],
|
|
704
|
+
unrecorded: context.phase === "final" && queries === undefined,
|
|
705
|
+
answered: answers?.[part.block.id],
|
|
706
|
+
context: {
|
|
707
|
+
scopeId: context.scopeId,
|
|
708
|
+
chatId: context.chatId,
|
|
709
|
+
itemId: context.itemId,
|
|
710
|
+
phase: context.phase,
|
|
711
|
+
blockId: part.block.id
|
|
712
|
+
}
|
|
713
|
+
})
|
|
714
|
+
}, JSON.stringify([context.scopeId, context.chatId, context.itemId, part.block.id]));
|
|
715
|
+
$[10] = answers;
|
|
716
|
+
$[11] = context.chatId;
|
|
717
|
+
$[12] = context.itemId;
|
|
718
|
+
$[13] = context.phase;
|
|
719
|
+
$[14] = context.scopeId;
|
|
720
|
+
$[15] = queries;
|
|
721
|
+
$[16] = reply;
|
|
722
|
+
$[17] = t2;
|
|
723
|
+
} else {
|
|
724
|
+
t2 = $[17];
|
|
725
|
+
}
|
|
726
|
+
t1 = uiReplyParts(text, blocks, context.phase === "streaming").map(t2);
|
|
727
|
+
$[0] = answers;
|
|
728
|
+
$[1] = blocks;
|
|
729
|
+
$[2] = context.chatId;
|
|
730
|
+
$[3] = context.itemId;
|
|
731
|
+
$[4] = context.phase;
|
|
732
|
+
$[5] = context.scopeId;
|
|
733
|
+
$[6] = queries;
|
|
734
|
+
$[7] = reply;
|
|
735
|
+
$[8] = text;
|
|
736
|
+
$[9] = t1;
|
|
737
|
+
} else {
|
|
738
|
+
t1 = $[9];
|
|
739
|
+
}
|
|
740
|
+
let t2;
|
|
741
|
+
if ($[18] !== t1) {
|
|
742
|
+
t2 = /*#__PURE__*/_jsx("div", {
|
|
743
|
+
className: "flex flex-col gap-(--chat-block-gap)",
|
|
744
|
+
children: t1
|
|
745
|
+
});
|
|
746
|
+
$[18] = t1;
|
|
747
|
+
$[19] = t2;
|
|
748
|
+
} else {
|
|
749
|
+
t2 = $[19];
|
|
750
|
+
}
|
|
751
|
+
return t2;
|
|
752
|
+
}
|