@data-club/ai-hub 0.0.1
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/dist/auth/passwordPolicy.d.ts +55 -0
- package/dist/auth/passwordPolicy.d.ts.map +1 -0
- package/dist/auth/passwordPolicy.js +63 -0
- package/dist/auth/passwordPolicy.js.map +1 -0
- package/dist/auth/texts.d.ts +815 -0
- package/dist/auth/texts.d.ts.map +1 -0
- package/dist/auth/texts.js +429 -0
- package/dist/auth/texts.js.map +1 -0
- package/dist/client/AIHubClient.d.ts +1058 -0
- package/dist/client/AIHubClient.d.ts.map +1 -0
- package/dist/client/AIHubClient.js +950 -0
- package/dist/client/AIHubClient.js.map +1 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +9 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/sseParser.d.ts +41 -0
- package/dist/client/sseParser.d.ts.map +1 -0
- package/dist/client/sseParser.js +153 -0
- package/dist/client/sseParser.js.map +1 -0
- package/dist/client/tokenStorage.d.ts +56 -0
- package/dist/client/tokenStorage.d.ts.map +1 -0
- package/dist/client/tokenStorage.js +116 -0
- package/dist/client/tokenStorage.js.map +1 -0
- package/dist/components/AgentsPicker/index.d.ts +70 -0
- package/dist/components/AgentsPicker/index.d.ts.map +1 -0
- package/dist/components/AgentsPicker/index.js +63 -0
- package/dist/components/AgentsPicker/index.js.map +1 -0
- package/dist/components/AuthGate/index.d.ts +79 -0
- package/dist/components/AuthGate/index.d.ts.map +1 -0
- package/dist/components/AuthGate/index.js +61 -0
- package/dist/components/AuthGate/index.js.map +1 -0
- package/dist/components/CacheBadge/index.d.ts +88 -0
- package/dist/components/CacheBadge/index.d.ts.map +1 -0
- package/dist/components/CacheBadge/index.js +127 -0
- package/dist/components/CacheBadge/index.js.map +1 -0
- package/dist/components/ChangePassword/index.d.ts +109 -0
- package/dist/components/ChangePassword/index.d.ts.map +1 -0
- package/dist/components/ChangePassword/index.js +142 -0
- package/dist/components/ChangePassword/index.js.map +1 -0
- package/dist/components/ChatShell/ShellHeader.d.ts +44 -0
- package/dist/components/ChatShell/ShellHeader.d.ts.map +1 -0
- package/dist/components/ChatShell/ShellHeader.js +14 -0
- package/dist/components/ChatShell/ShellHeader.js.map +1 -0
- package/dist/components/ChatShell/UserMenu.d.ts +48 -0
- package/dist/components/ChatShell/UserMenu.d.ts.map +1 -0
- package/dist/components/ChatShell/UserMenu.js +86 -0
- package/dist/components/ChatShell/UserMenu.js.map +1 -0
- package/dist/components/ChatShell/index.d.ts +98 -0
- package/dist/components/ChatShell/index.d.ts.map +1 -0
- package/dist/components/ChatShell/index.js +124 -0
- package/dist/components/ChatShell/index.js.map +1 -0
- package/dist/components/DataClubAIHub/index.d.ts +132 -0
- package/dist/components/DataClubAIHub/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHub/index.js +124 -0
- package/dist/components/DataClubAIHub/index.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts +89 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js +199 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts +33 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.js +137 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts +50 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.js +93 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts +49 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js +94 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts +37 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js +44 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts +56 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js +158 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts +29 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js +183 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts +38 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js +294 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts +36 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.js +373 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts +47 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.js +233 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/index.d.ts +87 -0
- package/dist/components/DataClubAIHubAdmin/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/index.js +137 -0
- package/dist/components/DataClubAIHubAdmin/index.js.map +1 -0
- package/dist/components/DataClubAIHubLogin/index.d.ts +113 -0
- package/dist/components/DataClubAIHubLogin/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHubLogin/index.js +123 -0
- package/dist/components/DataClubAIHubLogin/index.js.map +1 -0
- package/dist/components/EffortControl/index.d.ts +57 -0
- package/dist/components/EffortControl/index.d.ts.map +1 -0
- package/dist/components/EffortControl/index.js +84 -0
- package/dist/components/EffortControl/index.js.map +1 -0
- package/dist/components/Layout/index.d.ts +63 -0
- package/dist/components/Layout/index.d.ts.map +1 -0
- package/dist/components/Layout/index.js +45 -0
- package/dist/components/Layout/index.js.map +1 -0
- package/dist/components/MainColumn/index.d.ts +69 -0
- package/dist/components/MainColumn/index.d.ts.map +1 -0
- package/dist/components/MainColumn/index.js +47 -0
- package/dist/components/MainColumn/index.js.map +1 -0
- package/dist/components/MarkdownRenderer/index.d.ts +66 -0
- package/dist/components/MarkdownRenderer/index.d.ts.map +1 -0
- package/dist/components/MarkdownRenderer/index.js +153 -0
- package/dist/components/MarkdownRenderer/index.js.map +1 -0
- package/dist/components/MessageInput/index.d.ts +85 -0
- package/dist/components/MessageInput/index.d.ts.map +1 -0
- package/dist/components/MessageInput/index.js +139 -0
- package/dist/components/MessageInput/index.js.map +1 -0
- package/dist/components/MessageList/index.d.ts +156 -0
- package/dist/components/MessageList/index.d.ts.map +1 -0
- package/dist/components/MessageList/index.js +352 -0
- package/dist/components/MessageList/index.js.map +1 -0
- package/dist/components/ReasoningSelector/index.d.ts +77 -0
- package/dist/components/ReasoningSelector/index.d.ts.map +1 -0
- package/dist/components/ReasoningSelector/index.js +156 -0
- package/dist/components/ReasoningSelector/index.js.map +1 -0
- package/dist/components/ReasoningView/index.d.ts +94 -0
- package/dist/components/ReasoningView/index.d.ts.map +1 -0
- package/dist/components/ReasoningView/index.js +83 -0
- package/dist/components/ReasoningView/index.js.map +1 -0
- package/dist/components/ScrollToPresentButton/index.d.ts +54 -0
- package/dist/components/ScrollToPresentButton/index.d.ts.map +1 -0
- package/dist/components/ScrollToPresentButton/index.js +44 -0
- package/dist/components/ScrollToPresentButton/index.js.map +1 -0
- package/dist/components/SessionsPanel/SessionTitleModal.d.ts +79 -0
- package/dist/components/SessionsPanel/SessionTitleModal.d.ts.map +1 -0
- package/dist/components/SessionsPanel/SessionTitleModal.js +102 -0
- package/dist/components/SessionsPanel/SessionTitleModal.js.map +1 -0
- package/dist/components/SessionsPanel/index.d.ts +100 -0
- package/dist/components/SessionsPanel/index.d.ts.map +1 -0
- package/dist/components/SessionsPanel/index.js +176 -0
- package/dist/components/SessionsPanel/index.js.map +1 -0
- package/dist/components/SystemNotice/index.d.ts +66 -0
- package/dist/components/SystemNotice/index.d.ts.map +1 -0
- package/dist/components/SystemNotice/index.js +81 -0
- package/dist/components/SystemNotice/index.js.map +1 -0
- package/dist/components/ThemeSwitcher/index.d.ts +66 -0
- package/dist/components/ThemeSwitcher/index.d.ts.map +1 -0
- package/dist/components/ThemeSwitcher/index.js +73 -0
- package/dist/components/ThemeSwitcher/index.js.map +1 -0
- package/dist/components/ToolCallView/formatContent.d.ts +36 -0
- package/dist/components/ToolCallView/formatContent.d.ts.map +1 -0
- package/dist/components/ToolCallView/formatContent.js +53 -0
- package/dist/components/ToolCallView/formatContent.js.map +1 -0
- package/dist/components/ToolCallView/index.d.ts +120 -0
- package/dist/components/ToolCallView/index.d.ts.map +1 -0
- package/dist/components/ToolCallView/index.js +104 -0
- package/dist/components/ToolCallView/index.js.map +1 -0
- package/dist/components/TpmBanner/index.d.ts +53 -0
- package/dist/components/TpmBanner/index.d.ts.map +1 -0
- package/dist/components/TpmBanner/index.js +116 -0
- package/dist/components/TpmBanner/index.js.map +1 -0
- package/dist/components/TurnStatusIndicator/index.d.ts +77 -0
- package/dist/components/TurnStatusIndicator/index.d.ts.map +1 -0
- package/dist/components/TurnStatusIndicator/index.js +122 -0
- package/dist/components/TurnStatusIndicator/index.js.map +1 -0
- package/dist/components/internal/PasswordInput.d.ts +62 -0
- package/dist/components/internal/PasswordInput.d.ts.map +1 -0
- package/dist/components/internal/PasswordInput.js +42 -0
- package/dist/components/internal/PasswordInput.js.map +1 -0
- package/dist/context/AIHubContext.d.ts +220 -0
- package/dist/context/AIHubContext.d.ts.map +1 -0
- package/dist/context/AIHubContext.js +19 -0
- package/dist/context/AIHubContext.js.map +1 -0
- package/dist/context/AIHubProvider.d.ts +75 -0
- package/dist/context/AIHubProvider.d.ts.map +1 -0
- package/dist/context/AIHubProvider.js +954 -0
- package/dist/context/AIHubProvider.js.map +1 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +9 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/theme.d.ts +43 -0
- package/dist/context/theme.d.ts.map +1 -0
- package/dist/context/theme.js +70 -0
- package/dist/context/theme.js.map +1 -0
- package/dist/context/useAIHub.d.ts +104 -0
- package/dist/context/useAIHub.d.ts.map +1 -0
- package/dist/context/useAIHub.js +63 -0
- package/dist/context/useAIHub.js.map +1 -0
- package/dist/context/useAIHubAuth.d.ts +44 -0
- package/dist/context/useAIHubAuth.d.ts.map +1 -0
- package/dist/context/useAIHubAuth.js +35 -0
- package/dist/context/useAIHubAuth.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/index.d.ts +99 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +97 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/state/affordances.d.ts +182 -0
- package/dist/state/affordances.d.ts.map +1 -0
- package/dist/state/affordances.js +189 -0
- package/dist/state/affordances.js.map +1 -0
- package/dist/state/stateReducer.d.ts +72 -0
- package/dist/state/stateReducer.d.ts.map +1 -0
- package/dist/state/stateReducer.js +122 -0
- package/dist/state/stateReducer.js.map +1 -0
- package/dist/stories/EffortControl.stories.d.ts +14 -0
- package/dist/stories/EffortControl.stories.d.ts.map +1 -0
- package/dist/stories/EffortControl.stories.js +43 -0
- package/dist/stories/EffortControl.stories.js.map +1 -0
- package/dist/stories/MarkdownRenderer.stories.d.ts +25 -0
- package/dist/stories/MarkdownRenderer.stories.d.ts.map +1 -0
- package/dist/stories/MarkdownRenderer.stories.js +178 -0
- package/dist/stories/MarkdownRenderer.stories.js.map +1 -0
- package/dist/stories/MessageBubble.stories.d.ts +21 -0
- package/dist/stories/MessageBubble.stories.d.ts.map +1 -0
- package/dist/stories/MessageBubble.stories.js +59 -0
- package/dist/stories/MessageBubble.stories.js.map +1 -0
- package/dist/stories/ReasoningView.stories.d.ts +18 -0
- package/dist/stories/ReasoningView.stories.d.ts.map +1 -0
- package/dist/stories/ReasoningView.stories.js +62 -0
- package/dist/stories/ReasoningView.stories.js.map +1 -0
- package/dist/stories/ScrollToPresentButton.stories.d.ts +18 -0
- package/dist/stories/ScrollToPresentButton.stories.d.ts.map +1 -0
- package/dist/stories/ScrollToPresentButton.stories.js +34 -0
- package/dist/stories/ScrollToPresentButton.stories.js.map +1 -0
- package/dist/stories/SystemNotice.stories.d.ts +17 -0
- package/dist/stories/SystemNotice.stories.d.ts.map +1 -0
- package/dist/stories/SystemNotice.stories.js +42 -0
- package/dist/stories/SystemNotice.stories.js.map +1 -0
- package/dist/stories/ThemeSwitcher.stories.d.ts +15 -0
- package/dist/stories/ThemeSwitcher.stories.d.ts.map +1 -0
- package/dist/stories/ThemeSwitcher.stories.js +35 -0
- package/dist/stories/ThemeSwitcher.stories.js.map +1 -0
- package/dist/stories/ToolCallView.stories.d.ts +20 -0
- package/dist/stories/ToolCallView.stories.d.ts.map +1 -0
- package/dist/stories/ToolCallView.stories.js +65 -0
- package/dist/stories/ToolCallView.stories.js.map +1 -0
- package/dist/stories/TpmBanner.stories.d.ts +24 -0
- package/dist/stories/TpmBanner.stories.d.ts.map +1 -0
- package/dist/stories/TpmBanner.stories.js +63 -0
- package/dist/stories/TpmBanner.stories.js.map +1 -0
- package/dist/stories/TurnStatusIndicator.stories.d.ts +25 -0
- package/dist/stories/TurnStatusIndicator.stories.d.ts.map +1 -0
- package/dist/stories/TurnStatusIndicator.stories.js +56 -0
- package/dist/stories/TurnStatusIndicator.stories.js.map +1 -0
- package/dist/stories/_mockProvider.d.ts +44 -0
- package/dist/stories/_mockProvider.d.ts.map +1 -0
- package/dist/stories/_mockProvider.js +84 -0
- package/dist/stories/_mockProvider.js.map +1 -0
- package/dist/types.d.ts +787 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/webcomponent/defineWebComponent.d.ts +106 -0
- package/dist/webcomponent/defineWebComponent.d.ts.map +1 -0
- package/dist/webcomponent/defineWebComponent.js +126 -0
- package/dist/webcomponent/defineWebComponent.js.map +1 -0
- package/dist/webcomponent/index.d.ts +7 -0
- package/dist/webcomponent/index.d.ts.map +1 -0
- package/dist/webcomponent/index.js +7 -0
- package/dist/webcomponent/index.js.map +1 -0
- package/package.json +63 -0
- package/src/__lint-canary__/step1-lint-canary.ts.disabled +28 -0
- package/src/auth/passwordPolicy.ts +75 -0
- package/src/auth/texts.ts +1294 -0
- package/src/client/AIHubClient.ts +1718 -0
- package/src/client/index.ts +30 -0
- package/src/client/sseParser.ts +168 -0
- package/src/client/tokenStorage.ts +131 -0
- package/src/components/AgentsPicker/index.tsx +147 -0
- package/src/components/AuthGate/index.tsx +132 -0
- package/src/components/CacheBadge/index.tsx +245 -0
- package/src/components/ChangePassword/index.tsx +375 -0
- package/src/components/ChatShell/ShellHeader.tsx +80 -0
- package/src/components/ChatShell/UserMenu.tsx +196 -0
- package/src/components/ChatShell/index.tsx +307 -0
- package/src/components/DataClubAIHub/index.tsx +300 -0
- package/src/components/DataClubAIHubAdmin/AgentEditorModal.tsx +505 -0
- package/src/components/DataClubAIHubAdmin/AgentsPage.tsx +342 -0
- package/src/components/DataClubAIHubAdmin/CreateUserModal.tsx +214 -0
- package/src/components/DataClubAIHubAdmin/PasswordRevealModal.tsx +204 -0
- package/src/components/DataClubAIHubAdmin/ResetPasswordModal.tsx +122 -0
- package/src/components/DataClubAIHubAdmin/RotatingMessageEditorModal.tsx +408 -0
- package/src/components/DataClubAIHubAdmin/RotatingMessagesPage.tsx +373 -0
- package/src/components/DataClubAIHubAdmin/SessionsOverviewPage.tsx +639 -0
- package/src/components/DataClubAIHubAdmin/SettingsPage.tsx +979 -0
- package/src/components/DataClubAIHubAdmin/UsersPage.tsx +495 -0
- package/src/components/DataClubAIHubAdmin/index.tsx +277 -0
- package/src/components/DataClubAIHubLogin/index.tsx +282 -0
- package/src/components/EffortControl/index.tsx +138 -0
- package/src/components/Layout/index.tsx +92 -0
- package/src/components/MainColumn/index.tsx +131 -0
- package/src/components/MarkdownRenderer/index.tsx +256 -0
- package/src/components/MessageInput/index.tsx +283 -0
- package/src/components/MessageList/index.tsx +753 -0
- package/src/components/ReasoningSelector/index.tsx +268 -0
- package/src/components/ReasoningView/index.tsx +183 -0
- package/src/components/ScrollToPresentButton/index.tsx +85 -0
- package/src/components/SessionsPanel/SessionTitleModal.tsx +256 -0
- package/src/components/SessionsPanel/index.tsx +406 -0
- package/src/components/SystemNotice/index.tsx +151 -0
- package/src/components/ThemeSwitcher/index.tsx +136 -0
- package/src/components/ToolCallView/formatContent.ts +50 -0
- package/src/components/ToolCallView/index.tsx +274 -0
- package/src/components/TpmBanner/index.tsx +172 -0
- package/src/components/TurnStatusIndicator/index.tsx +203 -0
- package/src/components/internal/PasswordInput.tsx +145 -0
- package/src/context/AIHubContext.ts +249 -0
- package/src/context/AIHubProvider.tsx +1084 -0
- package/src/context/index.ts +9 -0
- package/src/context/theme.ts +76 -0
- package/src/context/useAIHub.ts +151 -0
- package/src/context/useAIHubAuth.ts +65 -0
- package/src/index.ts +275 -0
- package/src/primitives/index.ts +101 -0
- package/src/state/affordances.ts +321 -0
- package/src/state/stateReducer.ts +131 -0
- package/src/stories/EffortControl.stories.tsx +63 -0
- package/src/stories/MarkdownRenderer.stories.tsx +201 -0
- package/src/stories/MessageBubble.stories.tsx +101 -0
- package/src/stories/ReasoningView.stories.tsx +81 -0
- package/src/stories/ScrollToPresentButton.stories.tsx +52 -0
- package/src/stories/SystemNotice.stories.tsx +59 -0
- package/src/stories/ThemeSwitcher.stories.tsx +55 -0
- package/src/stories/ToolCallView.stories.tsx +95 -0
- package/src/stories/TpmBanner.stories.tsx +93 -0
- package/src/stories/TurnStatusIndicator.stories.tsx +86 -0
- package/src/stories/_mockProvider.tsx +116 -0
- package/src/styles/CLASSES.md +356 -0
- package/src/styles/default.css +2937 -0
- package/src/types.ts +867 -0
- package/src/webcomponent/defineWebComponent.tsx +193 -0
- package/src/webcomponent/index.ts +11 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* `<MessageList />` — the scrollable list of message bubbles in the
|
|
4
|
+
* active session.
|
|
5
|
+
*
|
|
6
|
+
* Step 10 layers in:
|
|
7
|
+
*
|
|
8
|
+
* - `--system` / `--tool` / `--failed` bubble modifiers (Step 9 shipped
|
|
9
|
+
* `--user` / `--assistant`).
|
|
10
|
+
* - The `customMessageActions` slot — Tier-2 / Tier-3 wrappers render
|
|
11
|
+
* their own action bar inside every assistant bubble (e.g. 👍 / 👎).
|
|
12
|
+
* - The `customMessageBubble` slot — Tier-3 escape hatch that replaces
|
|
13
|
+
* the entire bubble for a message.
|
|
14
|
+
* - The `<TpmBanner />` — sits above the streaming bubble during a
|
|
15
|
+
* `waiting_provider` phase + the brief resumed-flash.
|
|
16
|
+
* - The `<ScrollToPresentButton />` — appears when the user has scrolled
|
|
17
|
+
* away from the bottom during a running turn (auto-scroll is
|
|
18
|
+
* inhibited while they're scrolled up).
|
|
19
|
+
* - Per-row Retry button on the failed-turn `--failed` assistant bubble.
|
|
20
|
+
*
|
|
21
|
+
* Server toggles (§8.4) gate via the resolved prop stack the monolith
|
|
22
|
+
* passes in:
|
|
23
|
+
*
|
|
24
|
+
* - `systemMessagesVisible` — when false, `system` and `tool`-role
|
|
25
|
+
* messages are filtered out of the list.
|
|
26
|
+
* - `tpmNoticeVisible` — when false, `<TpmBanner />` is suppressed.
|
|
27
|
+
* - `scrollToPresentVisible` — when false, the scroll-to-present
|
|
28
|
+
* button is suppressed.
|
|
29
|
+
*
|
|
30
|
+
* Exported under `AIHub.MessageList`.
|
|
31
|
+
*
|
|
32
|
+
* @see SPECIFICATIONS.md §7.1, §8.4, §10.4
|
|
33
|
+
* @see ui-sketches/03-chat.md — message_bubble + system_notice
|
|
34
|
+
*/
|
|
35
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
36
|
+
import { resolveAIHubTexts, } from "../../auth/texts.js";
|
|
37
|
+
import { useAIHub } from "../../context/useAIHub.js";
|
|
38
|
+
import { chatAffordances } from "../../state/affordances.js";
|
|
39
|
+
import { CacheBadge } from "../CacheBadge/index.js";
|
|
40
|
+
import { MarkdownRenderer } from "../MarkdownRenderer/index.js";
|
|
41
|
+
import { ReasoningView } from "../ReasoningView/index.js";
|
|
42
|
+
import { ScrollToPresentButton } from "../ScrollToPresentButton/index.js";
|
|
43
|
+
import { ToolCallView } from "../ToolCallView/index.js";
|
|
44
|
+
import { TpmBanner } from "../TpmBanner/index.js";
|
|
45
|
+
/** Distance from bottom (in pixels) that still counts as "at the latest". */
|
|
46
|
+
const BOTTOM_EPSILON_PX = 32;
|
|
47
|
+
/* ────────────────────────────────────────────────────────────────────────── */
|
|
48
|
+
/* Block-expansion stable IDs */
|
|
49
|
+
/* ────────────────────────────────────────────────────────────────────────── */
|
|
50
|
+
/**
|
|
51
|
+
* Stable id for the reasoning sub-block of a *historical* assistant
|
|
52
|
+
* message. Used as the controlled-mode key into the user-expanded
|
|
53
|
+
* accordion state owned by `<MessageList />`.
|
|
54
|
+
*/
|
|
55
|
+
function reasoningBlockId(messageId) {
|
|
56
|
+
return `reasoning:${messageId}`;
|
|
57
|
+
}
|
|
58
|
+
/** Stable id for the reasoning sub-block of the *currently-streaming* bubble. */
|
|
59
|
+
const STREAMING_REASONING_BLOCK_ID = "reasoning:streaming";
|
|
60
|
+
/**
|
|
61
|
+
* Stable id for a tool-call card. The accordion key is namespaced by the
|
|
62
|
+
* **owning bubble** (`tool:<parent>:<tool_call_id>`) — empirically Letta
|
|
63
|
+
* has been observed to reuse `tool_call_id` values across logical
|
|
64
|
+
* messages within a single multi-step run, and even when it doesn't, the
|
|
65
|
+
* historical projector's per-step attribution could surface a record in
|
|
66
|
+
* two bubbles if it misfires. Without the namespace, two cards sharing
|
|
67
|
+
* an id would expand together because the accordion state lives in
|
|
68
|
+
* `<MessageList />` (cross-bubble). The namespace makes each bubble's
|
|
69
|
+
* card an independent accordion slot regardless of upstream id quirks.
|
|
70
|
+
*
|
|
71
|
+
* Pass `"streaming"` as `parentId` for the currently-streaming bubble's
|
|
72
|
+
* tool cards; pass the historical assistant message's id otherwise.
|
|
73
|
+
*/
|
|
74
|
+
function toolCallBlockId(parentId, toolCallId) {
|
|
75
|
+
return `tool:${parentId}:${toolCallId}`;
|
|
76
|
+
}
|
|
77
|
+
const DEFAULT_CLASS_NAMES = Object.freeze({
|
|
78
|
+
wrapper: "data-club-ai-hub__messages-wrapper",
|
|
79
|
+
root: "data-club-ai-hub__messages",
|
|
80
|
+
inner: "data-club-ai-hub__messages__inner",
|
|
81
|
+
empty: "data-club-ai-hub__messages__empty",
|
|
82
|
+
loading: "data-club-ai-hub__messages__loading",
|
|
83
|
+
noSession: "data-club-ai-hub__messages__no-session",
|
|
84
|
+
errorBanner: "data-club-ai-hub__messages__error",
|
|
85
|
+
bubble: "data-club-ai-hub__message-bubble",
|
|
86
|
+
bubbleUser: "data-club-ai-hub__message-bubble--user",
|
|
87
|
+
bubbleAssistant: "data-club-ai-hub__message-bubble--assistant",
|
|
88
|
+
bubbleSystem: "data-club-ai-hub__message-bubble--system",
|
|
89
|
+
bubbleTool: "data-club-ai-hub__message-bubble--tool",
|
|
90
|
+
bubbleFailed: "data-club-ai-hub__message-bubble--failed",
|
|
91
|
+
bubbleCancelled: "data-club-ai-hub__message-bubble--cancelled",
|
|
92
|
+
bubbleRole: "data-club-ai-hub__message-bubble__role",
|
|
93
|
+
bubbleBody: "data-club-ai-hub__message-bubble__body",
|
|
94
|
+
bubbleActions: "data-club-ai-hub__message-bubble__actions",
|
|
95
|
+
bubbleRetryButton: "data-club-ai-hub__message-bubble__retry",
|
|
96
|
+
bubbleCancelledStamp: "data-club-ai-hub__message-bubble__cancelled-stamp",
|
|
97
|
+
bubbleCaret: "data-club-ai-hub__message-bubble__caret",
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Renders the message list.
|
|
101
|
+
*
|
|
102
|
+
* @param props - see `MessageListProps`.
|
|
103
|
+
* @returns the rendered list.
|
|
104
|
+
*/
|
|
105
|
+
export function MessageList(props) {
|
|
106
|
+
const { messages, messagesLoading, activeSessionId, streamingAssistantText, streamingReasoning, streamingToolCalls, lastTurnError, state, sendMessage, } = useAIHub();
|
|
107
|
+
const texts = resolveAIHubTexts(props.texts);
|
|
108
|
+
const cls = { ...DEFAULT_CLASS_NAMES, ...(props.classNames ?? {}) };
|
|
109
|
+
const showSystemMessages = props.showSystemMessages ?? true;
|
|
110
|
+
const showTpmNotice = props.showTpmNotice ?? true;
|
|
111
|
+
const showScrollToPresent = props.showScrollToPresentButton ?? true;
|
|
112
|
+
const showRetryButton = props.showRetryButton ?? true;
|
|
113
|
+
const showReasoning = props.showReasoning ?? true;
|
|
114
|
+
const showToolCalls = props.showToolCalls ?? true;
|
|
115
|
+
const rootClass = props.className
|
|
116
|
+
? `${cls.root} ${props.className}`
|
|
117
|
+
: cls.root;
|
|
118
|
+
const affordances = chatAffordances(state);
|
|
119
|
+
// Block-expansion accordion (reasoning + tool-call blocks). At rest,
|
|
120
|
+
// at most one block in the entire conversation is user-expanded —
|
|
121
|
+
// clicking a second block collapses the first. During generation,
|
|
122
|
+
// the currently-streaming block is additionally auto-expanded, and
|
|
123
|
+
// the user-accordion ignores it (so up to TWO blocks can be visible:
|
|
124
|
+
// the auto-expanded streaming one + one user-expanded). When
|
|
125
|
+
// generation finishes, the streaming auto-expand falls away and the
|
|
126
|
+
// user's manual accordion remains.
|
|
127
|
+
const [userExpandedBlockId, setUserExpandedBlockId] = useState(null);
|
|
128
|
+
// The currently-streaming block (reasoning while phase ==
|
|
129
|
+
// model_reasoning; the most recent still-running tool call while
|
|
130
|
+
// phase == model_tool_input or tool_executing). Null otherwise.
|
|
131
|
+
const currentlyStreamingBlockId = useMemo(() => {
|
|
132
|
+
if (state.status !== "running")
|
|
133
|
+
return null;
|
|
134
|
+
if (state.phase === "model_reasoning")
|
|
135
|
+
return STREAMING_REASONING_BLOCK_ID;
|
|
136
|
+
if (state.phase === "model_tool_input" || state.phase === "tool_executing") {
|
|
137
|
+
// Walk newest-first; "running" = not yet finished. The translator
|
|
138
|
+
// computes `status === "running"` when neither output nor error is
|
|
139
|
+
// set yet, but that derivation happens in the streaming-bubble
|
|
140
|
+
// render below — here we mirror it.
|
|
141
|
+
for (let i = streamingToolCalls.length - 1; i >= 0; i--) {
|
|
142
|
+
const c = streamingToolCalls[i];
|
|
143
|
+
if (!c)
|
|
144
|
+
continue;
|
|
145
|
+
const isRunning = c.status !== "error" && c.output == null;
|
|
146
|
+
if (isRunning)
|
|
147
|
+
return toolCallBlockId("streaming", c.tool_call_id);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}, [state.status, state.phase, streamingToolCalls]);
|
|
152
|
+
// `expanded` resolver: auto-expand wins (it's the visible-during-stream
|
|
153
|
+
// contract); user-accordion is the fallback.
|
|
154
|
+
const isBlockExpanded = useCallback((blockId) => blockId === currentlyStreamingBlockId || blockId === userExpandedBlockId, [currentlyStreamingBlockId, userExpandedBlockId]);
|
|
155
|
+
// Toggle: clicking the streaming-locked block is a no-op (the rule is
|
|
156
|
+
// "the latest in-progress block is always visible"). For every other
|
|
157
|
+
// block, the accordion replaces: clicking an already-user-expanded
|
|
158
|
+
// block collapses it to null; clicking any other expands it.
|
|
159
|
+
const handleToggleBlock = useCallback((blockId) => {
|
|
160
|
+
if (blockId === currentlyStreamingBlockId)
|
|
161
|
+
return;
|
|
162
|
+
setUserExpandedBlockId((current) => (current === blockId ? null : blockId));
|
|
163
|
+
}, [currentlyStreamingBlockId]);
|
|
164
|
+
// Filter messages: assistant + user always, system + tool gated by
|
|
165
|
+
// showSystemMessages. Dedupe by id defensively even though the
|
|
166
|
+
// provider already does it on its own. Empty/whitespace-only messages
|
|
167
|
+
// are skipped — they appear when the messages-list route applies an
|
|
168
|
+
// empty `user_override` row (the rendered chip would otherwise be a
|
|
169
|
+
// tiny empty bubble), or when Letta's `<memory_metadata>`-stripped
|
|
170
|
+
// system message leaves nothing behind. Assistant bubbles keep
|
|
171
|
+
// rendering when they carry `reasoning` or `tool_calls` even with
|
|
172
|
+
// empty text, since those affordances are the message body.
|
|
173
|
+
const visibleMessages = useMemo(() => {
|
|
174
|
+
const seen = new Set();
|
|
175
|
+
const out = [];
|
|
176
|
+
for (const msg of messages) {
|
|
177
|
+
if (seen.has(msg.id))
|
|
178
|
+
continue;
|
|
179
|
+
if ((msg.role === "system" || msg.role === "tool") && !showSystemMessages) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (isMessageRenderEmpty(msg))
|
|
183
|
+
continue;
|
|
184
|
+
seen.add(msg.id);
|
|
185
|
+
out.push(msg);
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
}, [messages, showSystemMessages]);
|
|
189
|
+
// Track whether the user is currently at-the-bottom (within
|
|
190
|
+
// BOTTOM_EPSILON_PX). When at-bottom, new content auto-scrolls. When
|
|
191
|
+
// scrolled up, auto-scroll is suppressed and the
|
|
192
|
+
// ScrollToPresentButton renders. Recomputed on every scroll event
|
|
193
|
+
// through the scroll container.
|
|
194
|
+
const scrollRef = useRef(null);
|
|
195
|
+
const [atBottom, setAtBottom] = useState(true);
|
|
196
|
+
const checkAtBottom = useCallback(() => {
|
|
197
|
+
const el = scrollRef.current;
|
|
198
|
+
if (!el)
|
|
199
|
+
return true;
|
|
200
|
+
return el.scrollHeight - el.scrollTop - el.clientHeight < BOTTOM_EPSILON_PX;
|
|
201
|
+
}, []);
|
|
202
|
+
function handleScroll() {
|
|
203
|
+
setAtBottom(checkAtBottom());
|
|
204
|
+
}
|
|
205
|
+
// Auto-scroll only when the user is at-the-bottom. On session change
|
|
206
|
+
// we always scroll to the bottom (loading a new session shouldn't
|
|
207
|
+
// strand the user mid-history).
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
const el = scrollRef.current;
|
|
210
|
+
if (!el)
|
|
211
|
+
return;
|
|
212
|
+
if (atBottom) {
|
|
213
|
+
el.scrollTop = el.scrollHeight;
|
|
214
|
+
}
|
|
215
|
+
}, [messages, streamingAssistantText, atBottom]);
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
const el = scrollRef.current;
|
|
218
|
+
if (!el)
|
|
219
|
+
return;
|
|
220
|
+
el.scrollTop = el.scrollHeight;
|
|
221
|
+
setAtBottom(true);
|
|
222
|
+
}, [activeSessionId]);
|
|
223
|
+
const handleScrollToPresent = useCallback(() => {
|
|
224
|
+
const el = scrollRef.current;
|
|
225
|
+
if (!el)
|
|
226
|
+
return;
|
|
227
|
+
el.scrollTop = el.scrollHeight;
|
|
228
|
+
setAtBottom(true);
|
|
229
|
+
}, []);
|
|
230
|
+
const handleRetry = useCallback(() => {
|
|
231
|
+
// Find the last user message in the visible list (the failed
|
|
232
|
+
// turn's input). Sending it re-issues the turn.
|
|
233
|
+
for (let i = visibleMessages.length - 1; i >= 0; i--) {
|
|
234
|
+
const msg = visibleMessages[i];
|
|
235
|
+
if (msg && msg.role === "user") {
|
|
236
|
+
void sendMessage(msg.content);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, [visibleMessages, sendMessage]);
|
|
241
|
+
if (!activeSessionId) {
|
|
242
|
+
return (_jsx("div", { className: cls.wrapper, "data-testid": "message-list-wrapper", children: _jsx("div", { className: rootClass, "data-testid": "message-list", children: _jsx("div", { className: cls.noSession, "data-testid": "message-list-no-session", children: texts.chat.noActiveSessionHint }) }) }));
|
|
243
|
+
}
|
|
244
|
+
return (_jsxs("div", { className: cls.wrapper, "data-testid": "message-list-wrapper", children: [_jsx("div", { className: rootClass, ref: scrollRef, onScroll: handleScroll, "data-testid": "message-list", children: _jsxs("div", { className: cls.inner, "aria-live": "polite", children: [showTpmNotice ? (_jsx(TpmBanner, { onRetry: handleRetry, ...(props.texts !== undefined ? { texts: props.texts } : {}) })) : null, messagesLoading ? (_jsx("p", { className: cls.loading, "data-testid": "message-list-loading", children: texts.chat.sessionsLoading })) : null, !messagesLoading &&
|
|
245
|
+
visibleMessages.length === 0 &&
|
|
246
|
+
streamingAssistantText === null &&
|
|
247
|
+
lastTurnError === null ? (_jsx("p", { className: cls.empty, "data-testid": "message-list-empty", children: texts.chat.emptyConversationHint })) : null, visibleMessages.map((msg) => props.renderMessageBubble ? (
|
|
248
|
+
// The Tier-3 escape hatch returns arbitrary content; we
|
|
249
|
+
// wrap with a stable React key.
|
|
250
|
+
_jsx("div", { "data-testid": "message-bubble-custom", children: props.renderMessageBubble(msg) }, msg.id)) : (_jsx(MessageBubble, { message: msg, classNames: cls, isFailedAssistant: state.status === "failed" &&
|
|
251
|
+
msg.role === "assistant" &&
|
|
252
|
+
isLastAssistant(visibleMessages, msg), isCancelledAssistant: state.status === "cancelled" &&
|
|
253
|
+
msg.role === "assistant" &&
|
|
254
|
+
isLastAssistant(visibleMessages, msg), showRetryButton: showRetryButton, showReasoning: showReasoning, showToolCalls: showToolCalls, retryLabel: texts.chat.retryFailedButton, failedLabel: texts.chat.streamFailedText, cancelledStampLabel: texts.chat.cancelledStampText, onRetry: handleRetry, isBlockExpanded: isBlockExpanded, onToggleBlock: handleToggleBlock, ...(props.texts !== undefined ? { texts: props.texts } : {}), ...(props.renderMessageActions !== undefined
|
|
255
|
+
? { renderMessageActions: props.renderMessageActions }
|
|
256
|
+
: {}) }, msg.id))), lastTurnError !== null && state.status === "failed" ? (_jsxs("div", { className: `${cls.bubble} ${cls.bubbleAssistant} ${cls.bubbleFailed}`, "data-testid": "message-bubble-failed-error", "data-role": "assistant", children: [_jsx("span", { className: cls.bubbleBody, children: texts.chat.streamFailedText }), showRetryButton ? (_jsx("button", { type: "button", className: cls.bubbleRetryButton, onClick: handleRetry, "data-testid": "message-list-retry", children: texts.chat.retryFailedButton })) : null] })) : lastTurnError !== null ? (_jsx("div", { className: cls.errorBanner, "data-testid": "message-list-error", role: "alert", children: lastTurnError })) : null, streamingAssistantText !== null ||
|
|
257
|
+
(streamingReasoning !== null && showReasoning) ||
|
|
258
|
+
(streamingToolCalls.length > 0 && showToolCalls) ? (_jsxs("div", { className: `${cls.bubble} ${cls.bubbleAssistant}`, "data-testid": "message-bubble", "data-role": "assistant", "data-streaming": "true", children: [streamingReasoning !== null && showReasoning ? (_jsx(ReasoningView, { content: streamingReasoning, streaming: state.phase === "model_reasoning", expanded: isBlockExpanded(STREAMING_REASONING_BLOCK_ID), onToggle: () => handleToggleBlock(STREAMING_REASONING_BLOCK_ID), ...(props.texts !== undefined ? { texts: props.texts } : {}) })) : null, showToolCalls
|
|
259
|
+
? streamingToolCalls.map((call) => {
|
|
260
|
+
const blockId = toolCallBlockId("streaming", call.tool_call_id);
|
|
261
|
+
return (_jsx(ToolCallView, { toolName: call.tool_name, status: call.status === "error"
|
|
262
|
+
? "error"
|
|
263
|
+
: call.output != null
|
|
264
|
+
? "done"
|
|
265
|
+
: "running", input: call.input, expanded: isBlockExpanded(blockId), onToggle: () => handleToggleBlock(blockId), ...(call.output != null ? { output: call.output } : {}), ...(call.error != null ? { error: call.error } : {}), ...(props.texts !== undefined ? { texts: props.texts } : {}) }, call.tool_call_id));
|
|
266
|
+
})
|
|
267
|
+
: null, streamingAssistantText !== null ? (_jsxs("span", { className: cls.bubbleBody, children: [_jsx(MarkdownRenderer, { content: streamingAssistantText.replace(/^\s+|\s+$/g, "") }), affordances.streamingDots ? (_jsx("span", { className: cls.bubbleCaret, "aria-hidden": "true" })) : null] })) : null] })) : null] }) }), showScrollToPresent ? (_jsx(ScrollToPresentButton, { visible: affordances.scrollToPresentVisible && !atBottom, onClick: handleScrollToPresent, ...(props.texts !== undefined ? { texts: props.texts } : {}) })) : null] }));
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Returns true when `msg` is the last assistant-role entry in `list`.
|
|
271
|
+
* Used to scope the failed/cancelled modifiers to the latest assistant
|
|
272
|
+
* turn only (mid-history assistant messages are not retroactively
|
|
273
|
+
* failed when a *new* turn fails).
|
|
274
|
+
*/
|
|
275
|
+
function isLastAssistant(list, msg) {
|
|
276
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
277
|
+
const item = list[i];
|
|
278
|
+
if (!item)
|
|
279
|
+
continue;
|
|
280
|
+
if (item.role !== "assistant")
|
|
281
|
+
continue;
|
|
282
|
+
return item.id === msg.id;
|
|
283
|
+
}
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* True when `msg` has nothing meaningful to render — its `content` is
|
|
288
|
+
* empty or whitespace-only AND it carries no `reasoning` text or
|
|
289
|
+
* `tool_calls`. Used by the visibility filter so messages overridden to
|
|
290
|
+
* empty (e.g. an empty `user_override` row applied to the persisted
|
|
291
|
+
* `system_message`, or Letta's `<memory_metadata>`-stripped system row
|
|
292
|
+
* after the strip leaves the slot empty) don't render as tiny empty
|
|
293
|
+
* bubbles.
|
|
294
|
+
*
|
|
295
|
+
* Assistant bubbles with `reasoning` or `tool_calls` are NEVER empty for
|
|
296
|
+
* this purpose — those affordances are the body. A regular text-only
|
|
297
|
+
* assistant message with whitespace content is still hidden.
|
|
298
|
+
*/
|
|
299
|
+
function isMessageRenderEmpty(msg) {
|
|
300
|
+
const text = (msg.content ?? "").trim();
|
|
301
|
+
if (text !== "")
|
|
302
|
+
return false;
|
|
303
|
+
if (msg.role === "assistant") {
|
|
304
|
+
if (msg.reasoning && msg.reasoning.trim() !== "")
|
|
305
|
+
return false;
|
|
306
|
+
if (msg.tool_calls && msg.tool_calls.length > 0)
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Single message bubble. Variant modifier is driven by `message.role`,
|
|
313
|
+
* with `--failed` / `--cancelled` overrides for the most-recent
|
|
314
|
+
* assistant bubble of the corresponding terminal status.
|
|
315
|
+
*
|
|
316
|
+
* For assistant bubbles, renders nested `<ReasoningView />` (when the
|
|
317
|
+
* message carries `reasoning`) and `<ToolCallView />` cards (one per
|
|
318
|
+
* `tool_calls` entry) before the visible text — matching the
|
|
319
|
+
* ui-sketches/03-chat.md layout.
|
|
320
|
+
*/
|
|
321
|
+
function MessageBubble(props) {
|
|
322
|
+
const { message, classNames: cls } = props;
|
|
323
|
+
const baseModifier = message.role === "user"
|
|
324
|
+
? cls.bubbleUser
|
|
325
|
+
: message.role === "assistant"
|
|
326
|
+
? cls.bubbleAssistant
|
|
327
|
+
: message.role === "system"
|
|
328
|
+
? cls.bubbleSystem
|
|
329
|
+
: cls.bubbleTool;
|
|
330
|
+
const stateModifier = props.isFailedAssistant
|
|
331
|
+
? cls.bubbleFailed
|
|
332
|
+
: props.isCancelledAssistant
|
|
333
|
+
? cls.bubbleCancelled
|
|
334
|
+
: null;
|
|
335
|
+
const klass = [cls.bubble, baseModifier, stateModifier]
|
|
336
|
+
.filter(Boolean)
|
|
337
|
+
.join(" ");
|
|
338
|
+
const actions = props.renderMessageActions && message.role === "assistant"
|
|
339
|
+
? props.renderMessageActions(message)
|
|
340
|
+
: null;
|
|
341
|
+
const isAssistant = message.role === "assistant";
|
|
342
|
+
const reasoning = isAssistant && props.showReasoning ? message.reasoning : null;
|
|
343
|
+
const toolCalls = isAssistant && props.showToolCalls ? message.tool_calls : null;
|
|
344
|
+
return (_jsxs("div", { className: klass, "data-testid": "message-bubble", "data-role": message.role, "data-message-id": message.id, "data-failed": props.isFailedAssistant ? "true" : "false", "data-cancelled": props.isCancelledAssistant ? "true" : "false", children: [reasoning ? ((() => {
|
|
345
|
+
const blockId = reasoningBlockId(message.id);
|
|
346
|
+
return (_jsx(ReasoningView, { content: reasoning, expanded: props.isBlockExpanded(blockId), onToggle: () => props.onToggleBlock(blockId), ...(props.texts !== undefined ? { texts: props.texts } : {}) }));
|
|
347
|
+
})()) : null, toolCalls?.map((call) => {
|
|
348
|
+
const blockId = toolCallBlockId(message.id, call.tool_call_id);
|
|
349
|
+
return (_jsx(ToolCallView, { toolName: call.tool_name, status: call.status === "error" ? "error" : "done", input: call.input, expanded: props.isBlockExpanded(blockId), onToggle: () => props.onToggleBlock(blockId), ...(call.output != null ? { output: call.output } : {}), ...(call.error != null ? { error: call.error } : {}), ...(props.texts !== undefined ? { texts: props.texts } : {}) }, call.tool_call_id));
|
|
350
|
+
}), _jsx("span", { className: cls.bubbleBody, children: isAssistant ? (_jsx(MarkdownRenderer, { content: message.content })) : (message.content.trim()) }), isAssistant && message.usage ? (_jsx(CacheBadge, { usage: message.usage })) : null, props.isFailedAssistant ? (_jsxs("div", { className: cls.bubbleActions, children: [_jsx("span", { children: props.failedLabel }), props.showRetryButton ? (_jsx("button", { type: "button", className: cls.bubbleRetryButton, onClick: props.onRetry, "data-testid": "message-bubble-retry", children: props.retryLabel })) : null] })) : props.isCancelledAssistant ? (_jsx("div", { className: cls.bubbleActions, children: _jsx("span", { className: cls.bubbleCancelledStamp, "data-testid": "message-bubble-cancelled-stamp", children: props.cancelledStampLabel }) })) : null, actions ? (_jsx("div", { className: cls.bubbleActions, "data-testid": "message-bubble-actions", children: actions })) : null] }));
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MessageList/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,iBAAiB,GAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAO7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,6EAA6E;AAC7E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,SAAiB;IACzC,OAAO,aAAa,SAAS,EAAE,CAAC;AAClC,CAAC;AAED,iFAAiF;AACjF,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,UAAkB;IAC3D,OAAO,QAAQ,QAAQ,IAAI,UAAU,EAAE,CAAC;AAC1C,CAAC;AAwDD,MAAM,mBAAmB,GAA0B,M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CAAC,CAAC,IAAI,IACJ,CACP,CAAC,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAC/B,cAAK,SAAS,EAAE,GAAG,CAAC,aAAa,YAC/B,eACE,SAAS,EAAE,GAAG,CAAC,oBAAoB,iBACvB,gCAAgC,YAE3C,KAAK,CAAC,mBAAmB,GACrB,GACH,CACP,CAAC,CAAC,CAAC,IAAI,EACP,OAAO,CAAC,CAAC,CAAC,CACT,cACE,SAAS,EAAE,GAAG,CAAC,aAAa,iBAChB,wBAAwB,YAEnC,OAAO,GACJ,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<ReasoningSelector />` — capability-driven per-session reasoning UI.
|
|
3
|
+
*
|
|
4
|
+
* Renders a dynamic set of dropdowns based on the active session's
|
|
5
|
+
* `capabilities` (computed server-side from the agent's model handle):
|
|
6
|
+
*
|
|
7
|
+
* - **Anthropic / Bedrock** models → one "Effort" dropdown
|
|
8
|
+
* (`low | medium | high | xhigh | max`).
|
|
9
|
+
* - **OpenAI / OpenRouter** models → two independent dropdowns:
|
|
10
|
+
* "Reasoning" (`none | minimal | low | medium | high | xhigh`)
|
|
11
|
+
* and "Verbosity" (`low | medium | high`).
|
|
12
|
+
* - **Google AI / Vertex** models → numeric "Thinking budget" input.
|
|
13
|
+
* - **Models with no reasoning surface** (Z.AI, etc.) → renders nothing.
|
|
14
|
+
*
|
|
15
|
+
* Schema-driven: the dropdown enums come from the server's capability map,
|
|
16
|
+
* which in turn mirrors Letta's per-provider `*ModelSettings` shape. When
|
|
17
|
+
* Letta adds new values (e.g. a sixth effort tier), the server publishes
|
|
18
|
+
* them and the dropdown picks them up automatically — no UI changes needed.
|
|
19
|
+
*
|
|
20
|
+
* Wire flow: on change, calls `client.patchSessionReasoning(...)` which
|
|
21
|
+
* PATCHes the session row. The next `POST /chat` reads the new value and
|
|
22
|
+
* applies it to the agent's `model_settings` before opening the stream
|
|
23
|
+
* (see `chat.ts` pre-turn sync).
|
|
24
|
+
*
|
|
25
|
+
* Exported under `AIHub.ReasoningSelector`.
|
|
26
|
+
*
|
|
27
|
+
* @see SPECIFICATIONS.md §7.4 — reasoning effort surface
|
|
28
|
+
* @see packages/ai-hub-server/src/letta/modelSettings.ts — capability map
|
|
29
|
+
* + `buildModelSettings()` (the wire-shape construction)
|
|
30
|
+
*/
|
|
31
|
+
import { type ReactNode } from "react";
|
|
32
|
+
/** BEM class names emitted by `<ReasoningSelector />`. */
|
|
33
|
+
export interface ReasoningSelectorClassNames {
|
|
34
|
+
/** The wrapper around the entire selector (may render 0..N child dropdowns). */
|
|
35
|
+
root: string;
|
|
36
|
+
/** Each individual `<label>` row. */
|
|
37
|
+
field: string;
|
|
38
|
+
/** Each label's text. */
|
|
39
|
+
label: string;
|
|
40
|
+
/** Each `<select>` element. */
|
|
41
|
+
select: string;
|
|
42
|
+
/** The numeric `<input>` (thinking budget). */
|
|
43
|
+
input: string;
|
|
44
|
+
}
|
|
45
|
+
/** Props for `<ReasoningSelector />`. */
|
|
46
|
+
export interface ReasoningSelectorProps {
|
|
47
|
+
/** Disable all inputs (e.g. while a turn is streaming). Default false. */
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Optional label overrides. When omitted, sensible English defaults
|
|
51
|
+
* apply (`"Reasoning"`, `"Verbosity"`, `"Thinking budget"`).
|
|
52
|
+
*
|
|
53
|
+
* The reasoning dropdown uses one label (`reasoning`) regardless of
|
|
54
|
+
* whether the agent's model uses Anthropic-style `effort` or
|
|
55
|
+
* OpenAI-style `reasoning_effort` on the wire — from the user's
|
|
56
|
+
* perspective it's the same "how hard should the model think" knob.
|
|
57
|
+
*/
|
|
58
|
+
labels?: {
|
|
59
|
+
reasoning?: string;
|
|
60
|
+
verbosity?: string;
|
|
61
|
+
thinkingBudget?: string;
|
|
62
|
+
/** Empty-state placeholder option (e.g. "Default"). */
|
|
63
|
+
defaultPlaceholder?: string;
|
|
64
|
+
};
|
|
65
|
+
/** Extra class merged onto the root. */
|
|
66
|
+
className?: string;
|
|
67
|
+
/** Per-element class overrides. */
|
|
68
|
+
classNames?: Partial<ReasoningSelectorClassNames>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Renders the capability-driven reasoning selector. Returns `null` when
|
|
72
|
+
* the active session's model has no reasoning surface.
|
|
73
|
+
*
|
|
74
|
+
* @param props - see `ReasoningSelectorProps`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function ReasoningSelector(props: ReasoningSelectorProps): ReactNode;
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ReasoningSelector/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAK9E,0DAA0D;AAC1D,MAAM,WAAW,2BAA2B;IAC1C,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;CACf;AAUD,yCAAyC;AACzC,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,uDAAuD;QACvD,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;CACnD;AAYD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,sBAAsB,GAC5B,SAAS,CAqKX"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* `<ReasoningSelector />` — capability-driven per-session reasoning UI.
|
|
4
|
+
*
|
|
5
|
+
* Renders a dynamic set of dropdowns based on the active session's
|
|
6
|
+
* `capabilities` (computed server-side from the agent's model handle):
|
|
7
|
+
*
|
|
8
|
+
* - **Anthropic / Bedrock** models → one "Effort" dropdown
|
|
9
|
+
* (`low | medium | high | xhigh | max`).
|
|
10
|
+
* - **OpenAI / OpenRouter** models → two independent dropdowns:
|
|
11
|
+
* "Reasoning" (`none | minimal | low | medium | high | xhigh`)
|
|
12
|
+
* and "Verbosity" (`low | medium | high`).
|
|
13
|
+
* - **Google AI / Vertex** models → numeric "Thinking budget" input.
|
|
14
|
+
* - **Models with no reasoning surface** (Z.AI, etc.) → renders nothing.
|
|
15
|
+
*
|
|
16
|
+
* Schema-driven: the dropdown enums come from the server's capability map,
|
|
17
|
+
* which in turn mirrors Letta's per-provider `*ModelSettings` shape. When
|
|
18
|
+
* Letta adds new values (e.g. a sixth effort tier), the server publishes
|
|
19
|
+
* them and the dropdown picks them up automatically — no UI changes needed.
|
|
20
|
+
*
|
|
21
|
+
* Wire flow: on change, calls `client.patchSessionReasoning(...)` which
|
|
22
|
+
* PATCHes the session row. The next `POST /chat` reads the new value and
|
|
23
|
+
* applies it to the agent's `model_settings` before opening the stream
|
|
24
|
+
* (see `chat.ts` pre-turn sync).
|
|
25
|
+
*
|
|
26
|
+
* Exported under `AIHub.ReasoningSelector`.
|
|
27
|
+
*
|
|
28
|
+
* @see SPECIFICATIONS.md §7.4 — reasoning effort surface
|
|
29
|
+
* @see packages/ai-hub-server/src/letta/modelSettings.ts — capability map
|
|
30
|
+
* + `buildModelSettings()` (the wire-shape construction)
|
|
31
|
+
*/
|
|
32
|
+
import { useEffect, useState } from "react";
|
|
33
|
+
import { useAIHub } from "../../context/useAIHub.js";
|
|
34
|
+
const DEFAULT_CLASS_NAMES = Object.freeze({
|
|
35
|
+
root: "data-club-ai-hub__reasoning-selector",
|
|
36
|
+
field: "data-club-ai-hub__reasoning-selector__field",
|
|
37
|
+
label: "data-club-ai-hub__reasoning-selector__label",
|
|
38
|
+
select: "data-club-ai-hub__reasoning-selector__select",
|
|
39
|
+
input: "data-club-ai-hub__reasoning-selector__input",
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Capitalizes an enum value for the dropdown label — `"xhigh" → "X-High"`,
|
|
43
|
+
* `"max" → "Max"`. Keeps the wire enum honest and labels readable.
|
|
44
|
+
*/
|
|
45
|
+
function labelize(value) {
|
|
46
|
+
if (value === "xhigh")
|
|
47
|
+
return "Extra High";
|
|
48
|
+
if (value === "none")
|
|
49
|
+
return "Off";
|
|
50
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Renders the capability-driven reasoning selector. Returns `null` when
|
|
54
|
+
* the active session's model has no reasoning surface.
|
|
55
|
+
*
|
|
56
|
+
* @param props - see `ReasoningSelectorProps`.
|
|
57
|
+
*/
|
|
58
|
+
export function ReasoningSelector(props) {
|
|
59
|
+
const { client, activeSessionId, state } = useAIHub();
|
|
60
|
+
const cls = { ...DEFAULT_CLASS_NAMES, ...(props.classNames ?? {}) };
|
|
61
|
+
const rootClass = props.className ? `${cls.root} ${props.className}` : cls.root;
|
|
62
|
+
// Per-component fetch: capabilities come from `GET /sessions/:id` (not
|
|
63
|
+
// the list endpoint). Re-fetched whenever the active session changes.
|
|
64
|
+
const [session, setSession] = useState(null);
|
|
65
|
+
const [saving, setSaving] = useState(false);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
let cancelled = false;
|
|
68
|
+
if (!activeSessionId) {
|
|
69
|
+
setSession(null);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
void (async () => {
|
|
73
|
+
try {
|
|
74
|
+
const s = await client.getSession(activeSessionId);
|
|
75
|
+
if (!cancelled)
|
|
76
|
+
setSession(s);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
if (!cancelled)
|
|
80
|
+
setSession(null);
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
return () => {
|
|
84
|
+
cancelled = true;
|
|
85
|
+
};
|
|
86
|
+
}, [activeSessionId, client]);
|
|
87
|
+
if (!session)
|
|
88
|
+
return null;
|
|
89
|
+
const caps = session.capabilities;
|
|
90
|
+
if (!caps)
|
|
91
|
+
return null;
|
|
92
|
+
const hasAnyControl = caps.effort !== undefined ||
|
|
93
|
+
caps.reasoning_effort !== undefined ||
|
|
94
|
+
caps.verbosity !== undefined ||
|
|
95
|
+
caps.thinking_budget !== undefined;
|
|
96
|
+
if (!hasAnyControl)
|
|
97
|
+
return null;
|
|
98
|
+
const labels = {
|
|
99
|
+
reasoning: props.labels?.reasoning ?? "Reasoning",
|
|
100
|
+
verbosity: props.labels?.verbosity ?? "Verbosity",
|
|
101
|
+
thinkingBudget: props.labels?.thinkingBudget ?? "Thinking budget",
|
|
102
|
+
defaultPlaceholder: props.labels?.defaultPlaceholder ?? "Default",
|
|
103
|
+
};
|
|
104
|
+
// Disabled when caller says so OR when a turn is streaming — keeps the
|
|
105
|
+
// user from changing settings mid-turn (the PATCH would race the
|
|
106
|
+
// pre-turn sync).
|
|
107
|
+
const disabled = (props.disabled ?? false) || state.status === "running";
|
|
108
|
+
async function persistPatch(field, value) {
|
|
109
|
+
if (!activeSessionId)
|
|
110
|
+
return;
|
|
111
|
+
setSaving(true);
|
|
112
|
+
try {
|
|
113
|
+
const patch = {};
|
|
114
|
+
if (field === "effort")
|
|
115
|
+
patch.effort = value;
|
|
116
|
+
else if (field === "verbosity")
|
|
117
|
+
patch.verbosity = value;
|
|
118
|
+
else
|
|
119
|
+
patch.thinkingBudget = value;
|
|
120
|
+
const updated = await client.patchSessionReasoning(activeSessionId, patch);
|
|
121
|
+
setSession(updated);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Soft-fail: leave the existing state. A toast / banner could be
|
|
125
|
+
// added later; matching pattern with patchSession (which also
|
|
126
|
+
// doesn't surface errors to users).
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
setSaving(false);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function handleEffortChange(e) {
|
|
133
|
+
const v = e.target.value;
|
|
134
|
+
void persistPatch("effort", v === "" ? null : v);
|
|
135
|
+
}
|
|
136
|
+
function handleVerbosityChange(e) {
|
|
137
|
+
const v = e.target.value;
|
|
138
|
+
void persistPatch("verbosity", v === "" ? null : v);
|
|
139
|
+
}
|
|
140
|
+
function handleBudgetChange(e) {
|
|
141
|
+
const v = e.target.value;
|
|
142
|
+
void persistPatch("thinkingBudget", v === "" ? null : Number(v));
|
|
143
|
+
}
|
|
144
|
+
const currentEffort = session.reasoning?.effort ?? "";
|
|
145
|
+
const currentVerbosity = session.reasoning?.verbosity ?? "";
|
|
146
|
+
const currentBudget = session.reasoning?.thinking_budget ?? "";
|
|
147
|
+
// Anthropic uses `effort`, OpenAI uses `reasoning_effort` — same control
|
|
148
|
+
// shape (dropdown), different field on the wire. Server stores either
|
|
149
|
+
// in `session.reasoning.effort` (we don't split into two columns —
|
|
150
|
+
// it's contextual to the agent's model). The UI label is unified —
|
|
151
|
+
// both render as "Reasoning" so the user sees one consistent control.
|
|
152
|
+
const effortCap = caps.effort ?? caps.reasoning_effort;
|
|
153
|
+
const effortLabel = labels.reasoning;
|
|
154
|
+
return (_jsxs("div", { className: rootClass, "data-testid": "reasoning-selector", "data-saving": saving ? "true" : undefined, children: [effortCap !== undefined && (_jsxs("label", { className: cls.field, children: [_jsx("span", { className: cls.label, children: effortLabel }), _jsxs("select", { className: cls.select, value: currentEffort, onChange: handleEffortChange, disabled: disabled || saving, "data-testid": "reasoning-selector-effort", "aria-label": effortLabel, children: [_jsx("option", { value: "", children: labels.defaultPlaceholder }), effortCap.enum.map((v) => (_jsx("option", { value: v, children: labelize(v) }, v)))] })] })), caps.verbosity !== undefined && (_jsxs("label", { className: cls.field, children: [_jsx("span", { className: cls.label, children: labels.verbosity }), _jsxs("select", { className: cls.select, value: currentVerbosity, onChange: handleVerbosityChange, disabled: disabled || saving, "data-testid": "reasoning-selector-verbosity", "aria-label": labels.verbosity, children: [_jsx("option", { value: "", children: labels.defaultPlaceholder }), caps.verbosity.enum.map((v) => (_jsx("option", { value: v, children: labelize(v) }, v)))] })] })), caps.thinking_budget !== undefined && (_jsxs("label", { className: cls.field, children: [_jsx("span", { className: cls.label, children: labels.thinkingBudget }), _jsx("input", { type: "number", className: cls.input, value: currentBudget, min: caps.thinking_budget.min, max: caps.thinking_budget.max, step: 256, onChange: handleBudgetChange, disabled: disabled || saving, "data-testid": "reasoning-selector-budget", "aria-label": labels.thinkingBudget, placeholder: labels.defaultPlaceholder })] }))] }));
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ReasoningSelector/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAoC,MAAM,OAAO,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAiBrD,MAAM,mBAAmB,GAAgC,MAAM,CAAC,MAAM,CAAC;IACrE,IAAI,EAAE,sCAAsC;IAC5C,KAAK,EAAE,6CAA6C;IACpD,KAAK,EAAE,6CAA6C;IACpD,MAAM,EAAE,8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