@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,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<AdminRotatingMessagesPage />` — the Rotating messages sub-page mounted
|
|
3
|
+
* inside `<DataClubAIHubAdmin />`.
|
|
4
|
+
*
|
|
5
|
+
* Lists rotating starting messages with per-row `[Edit]`, `[Rotate now]`, and
|
|
6
|
+
* `[Archive]` / `[Unarchive]` actions, a top-right `[+ Create]`, and a
|
|
7
|
+
* `[☐ Show archived]` toggle. Each row exposes its `rmsg-…` reference id
|
|
8
|
+
* (copyable) — that's what an admin pastes / picks in an agent's Base
|
|
9
|
+
* conversation field. Archive-only, like Agents (no hard delete).
|
|
10
|
+
*
|
|
11
|
+
* Visible to `power_user`+ per §8.2; the shell does the gating.
|
|
12
|
+
*
|
|
13
|
+
* @see docs/server/rotating-messages.md
|
|
14
|
+
*/
|
|
15
|
+
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
|
16
|
+
|
|
17
|
+
import type { AIHubAdminTexts } from "../../auth/texts.js";
|
|
18
|
+
import type { AdminRotatingMessageView } from "../../client/AIHubClient.js";
|
|
19
|
+
import { useAIHub } from "../../context/useAIHub.js";
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
RotatingMessageEditorModal,
|
|
23
|
+
type RotatingEditorMode,
|
|
24
|
+
type RotatingEditorSubmitBody,
|
|
25
|
+
} from "./RotatingMessageEditorModal.js";
|
|
26
|
+
|
|
27
|
+
/** Editor modal state. */
|
|
28
|
+
type EditorState =
|
|
29
|
+
| { kind: "closed" }
|
|
30
|
+
| { kind: "create" }
|
|
31
|
+
| { kind: "edit"; row: AdminRotatingMessageView };
|
|
32
|
+
|
|
33
|
+
/** Alphabetical by display_name. */
|
|
34
|
+
function byDisplayName(a: AdminRotatingMessageView, b: AdminRotatingMessageView): number {
|
|
35
|
+
return a.display_name.localeCompare(b.display_name);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Human-readable one-line schedule summary. */
|
|
39
|
+
function scheduleSummary(row: AdminRotatingMessageView, texts: AIHubAdminTexts): string {
|
|
40
|
+
if (row.schedule_kind === "every" && row.interval_seconds) {
|
|
41
|
+
const s = row.interval_seconds;
|
|
42
|
+
if (s % 86_400 === 0) return `${texts.rotatingScheduleEveryOption} ${s / 86_400} ${texts.rotatingIntervalUnitDays}`;
|
|
43
|
+
if (s % 3_600 === 0) return `${texts.rotatingScheduleEveryOption} ${s / 3_600} ${texts.rotatingIntervalUnitHours}`;
|
|
44
|
+
return `${texts.rotatingScheduleEveryOption} ${Math.round(s / 60)} min`;
|
|
45
|
+
}
|
|
46
|
+
if (row.schedule_kind === "daily" && row.daily_time) {
|
|
47
|
+
return `${texts.rotatingScheduleDailyOption} ${row.daily_time} UTC`;
|
|
48
|
+
}
|
|
49
|
+
if (row.schedule_kind === "cron" && row.cron_expression) {
|
|
50
|
+
return `cron: ${row.cron_expression}`;
|
|
51
|
+
}
|
|
52
|
+
return "—";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Status pill label. */
|
|
56
|
+
function statusLabel(row: AdminRotatingMessageView, texts: AIHubAdminTexts): string {
|
|
57
|
+
if (row.is_archived) return texts.rotatingStatusArchived;
|
|
58
|
+
switch (row.last_status) {
|
|
59
|
+
case "ok":
|
|
60
|
+
return texts.rotatingStatusOk;
|
|
61
|
+
case "error":
|
|
62
|
+
return texts.rotatingStatusError;
|
|
63
|
+
default:
|
|
64
|
+
return texts.rotatingStatusPending;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Props for `<AdminRotatingMessagesPage />`. */
|
|
69
|
+
export interface AdminRotatingMessagesPageProps {
|
|
70
|
+
/** Resolved admin texts. */
|
|
71
|
+
texts: AIHubAdminTexts;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Renders the Rotating messages sub-page.
|
|
76
|
+
*
|
|
77
|
+
* @param props - see {@link AdminRotatingMessagesPageProps}.
|
|
78
|
+
* @returns the rendered page.
|
|
79
|
+
*/
|
|
80
|
+
export function AdminRotatingMessagesPage(
|
|
81
|
+
props: AdminRotatingMessagesPageProps,
|
|
82
|
+
): ReactNode {
|
|
83
|
+
const { client } = useAIHub();
|
|
84
|
+
|
|
85
|
+
const [rows, setRows] = useState<AdminRotatingMessageView[] | null>(null);
|
|
86
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
87
|
+
const [showArchived, setShowArchived] = useState(false);
|
|
88
|
+
const [editor, setEditor] = useState<EditorState>({ kind: "closed" });
|
|
89
|
+
const [rotatingNow, setRotatingNow] = useState<ReadonlySet<string>>(new Set());
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
let cancelled = false;
|
|
93
|
+
void (async () => {
|
|
94
|
+
try {
|
|
95
|
+
const fetched = await client.listAdminRotatingMessages();
|
|
96
|
+
if (!cancelled) {
|
|
97
|
+
setRows([...fetched].sort(byDisplayName));
|
|
98
|
+
setLoadError(null);
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (!cancelled) {
|
|
102
|
+
setLoadError(
|
|
103
|
+
err instanceof Error && err.message.length > 0
|
|
104
|
+
? err.message
|
|
105
|
+
: props.texts.rotatingGenericError,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
})();
|
|
110
|
+
return () => {
|
|
111
|
+
cancelled = true;
|
|
112
|
+
};
|
|
113
|
+
}, [client, props.texts.rotatingGenericError]);
|
|
114
|
+
|
|
115
|
+
const visibleRows = useMemo(() => {
|
|
116
|
+
if (rows === null) return null;
|
|
117
|
+
return showArchived ? rows : rows.filter((r) => !r.is_archived);
|
|
118
|
+
}, [rows, showArchived]);
|
|
119
|
+
|
|
120
|
+
function upsert(row: AdminRotatingMessageView): void {
|
|
121
|
+
setRows((prev) => {
|
|
122
|
+
if (prev === null) return [row];
|
|
123
|
+
const exists = prev.some((r) => r.id === row.id);
|
|
124
|
+
const next = exists ? prev.map((r) => (r.id === row.id ? row : r)) : [...prev, row];
|
|
125
|
+
return next.sort(byDisplayName);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function handleCreateSubmit(body: RotatingEditorSubmitBody): Promise<void> {
|
|
130
|
+
const created = await client.createAdminRotatingMessage({
|
|
131
|
+
displayName: body.displayName,
|
|
132
|
+
prompt: body.prompt,
|
|
133
|
+
lettaAgentId: body.lettaAgentId,
|
|
134
|
+
scheduleKind: body.scheduleKind,
|
|
135
|
+
intervalSeconds: body.intervalSeconds,
|
|
136
|
+
dailyTime: body.dailyTime,
|
|
137
|
+
cronExpression: body.cronExpression,
|
|
138
|
+
});
|
|
139
|
+
upsert(created);
|
|
140
|
+
setEditor({ kind: "closed" });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function handleEditSubmit(
|
|
144
|
+
target: AdminRotatingMessageView,
|
|
145
|
+
body: RotatingEditorSubmitBody,
|
|
146
|
+
): Promise<void> {
|
|
147
|
+
const updated = await client.patchAdminRotatingMessage(target.id, {
|
|
148
|
+
displayName: body.displayName,
|
|
149
|
+
prompt: body.prompt,
|
|
150
|
+
lettaAgentId: body.lettaAgentId,
|
|
151
|
+
scheduleKind: body.scheduleKind,
|
|
152
|
+
intervalSeconds: body.intervalSeconds,
|
|
153
|
+
dailyTime: body.dailyTime,
|
|
154
|
+
cronExpression: body.cronExpression,
|
|
155
|
+
});
|
|
156
|
+
upsert(updated);
|
|
157
|
+
setEditor({ kind: "closed" });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function handleRotateNow(target: AdminRotatingMessageView): Promise<void> {
|
|
161
|
+
setRotatingNow((prev) => new Set(prev).add(target.id));
|
|
162
|
+
try {
|
|
163
|
+
const res = await client.rotateAdminRotatingMessageNow(target.id);
|
|
164
|
+
upsert(res.rotating_message);
|
|
165
|
+
} catch (err) {
|
|
166
|
+
setLoadError(
|
|
167
|
+
err instanceof Error && err.message.length > 0
|
|
168
|
+
? err.message
|
|
169
|
+
: props.texts.rotatingGenericError,
|
|
170
|
+
);
|
|
171
|
+
} finally {
|
|
172
|
+
setRotatingNow((prev) => {
|
|
173
|
+
const next = new Set(prev);
|
|
174
|
+
next.delete(target.id);
|
|
175
|
+
return next;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function handleArchiveToggle(
|
|
181
|
+
target: AdminRotatingMessageView,
|
|
182
|
+
archive: boolean,
|
|
183
|
+
): Promise<void> {
|
|
184
|
+
if (archive) {
|
|
185
|
+
const prompt = props.texts.rotatingArchiveConfirmPrompt.replace("{name}", target.display_name);
|
|
186
|
+
// eslint-disable-next-line no-alert
|
|
187
|
+
const ok =
|
|
188
|
+
typeof window !== "undefined" && typeof window.confirm === "function"
|
|
189
|
+
? window.confirm(prompt)
|
|
190
|
+
: true;
|
|
191
|
+
if (!ok) return;
|
|
192
|
+
}
|
|
193
|
+
const updated = await client.patchAdminRotatingMessage(target.id, { isArchived: archive });
|
|
194
|
+
upsert(updated);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function copyId(id: string): void {
|
|
198
|
+
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
199
|
+
void navigator.clipboard.writeText(id);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div className="data-club-ai-hub-admin__rotating-page" data-testid="admin-rotating-page">
|
|
205
|
+
<header className="data-club-ai-hub-admin__page-header">
|
|
206
|
+
<h1 className="data-club-ai-hub-admin__page-heading" data-testid="admin-rotating-heading">
|
|
207
|
+
{props.texts.rotatingHeading}
|
|
208
|
+
</h1>
|
|
209
|
+
<div className="data-club-ai-hub-admin__page-header-actions">
|
|
210
|
+
<button
|
|
211
|
+
type="button"
|
|
212
|
+
className="data-club-ai-hub-admin__button data-club-ai-hub-admin__button--primary"
|
|
213
|
+
data-testid="admin-rotating-create"
|
|
214
|
+
onClick={() => setEditor({ kind: "create" })}
|
|
215
|
+
>
|
|
216
|
+
{props.texts.rotatingCreateButton}
|
|
217
|
+
</button>
|
|
218
|
+
</div>
|
|
219
|
+
</header>
|
|
220
|
+
|
|
221
|
+
{loadError !== null ? (
|
|
222
|
+
<div className="data-club-ai-hub-admin__error" data-testid="admin-rotating-error" role="alert">
|
|
223
|
+
{loadError}
|
|
224
|
+
</div>
|
|
225
|
+
) : null}
|
|
226
|
+
{rows === null && loadError === null ? (
|
|
227
|
+
<p className="data-club-ai-hub-admin__loading" data-testid="admin-rotating-loading">
|
|
228
|
+
{props.texts.rotatingLoading}
|
|
229
|
+
</p>
|
|
230
|
+
) : null}
|
|
231
|
+
{visibleRows !== null && visibleRows.length === 0 ? (
|
|
232
|
+
<p className="data-club-ai-hub-admin__empty" data-testid="admin-rotating-empty">
|
|
233
|
+
{props.texts.rotatingEmpty}
|
|
234
|
+
</p>
|
|
235
|
+
) : null}
|
|
236
|
+
|
|
237
|
+
{visibleRows !== null && visibleRows.length > 0 ? (
|
|
238
|
+
<table className="data-club-ai-hub-admin__rotating-table" data-testid="admin-rotating-table">
|
|
239
|
+
<thead>
|
|
240
|
+
<tr>
|
|
241
|
+
<th>{props.texts.rotatingColumnName}</th>
|
|
242
|
+
<th>{props.texts.rotatingColumnAgent}</th>
|
|
243
|
+
<th>{props.texts.rotatingColumnSchedule}</th>
|
|
244
|
+
<th>{props.texts.rotatingColumnStatus}</th>
|
|
245
|
+
<th>{props.texts.rotatingColumnId}</th>
|
|
246
|
+
<th>{props.texts.rotatingColumnActions}</th>
|
|
247
|
+
</tr>
|
|
248
|
+
</thead>
|
|
249
|
+
<tbody>
|
|
250
|
+
{visibleRows.map((r) => {
|
|
251
|
+
const isRotating = rotatingNow.has(r.id);
|
|
252
|
+
return (
|
|
253
|
+
<tr
|
|
254
|
+
key={r.id}
|
|
255
|
+
data-testid={`admin-rotating-row-${r.id}`}
|
|
256
|
+
data-archived={r.is_archived ? "true" : "false"}
|
|
257
|
+
className={
|
|
258
|
+
r.is_archived
|
|
259
|
+
? "data-club-ai-hub-admin__rotating-row data-club-ai-hub-admin__rotating-row--archived"
|
|
260
|
+
: "data-club-ai-hub-admin__rotating-row"
|
|
261
|
+
}
|
|
262
|
+
>
|
|
263
|
+
<td>{r.display_name}</td>
|
|
264
|
+
<td>
|
|
265
|
+
<code className="data-club-ai-hub-admin__mono">{r.letta_agent_id}</code>
|
|
266
|
+
</td>
|
|
267
|
+
<td>{scheduleSummary(r, props.texts)}</td>
|
|
268
|
+
<td>
|
|
269
|
+
<span
|
|
270
|
+
className={
|
|
271
|
+
r.last_status === "error" && !r.is_archived
|
|
272
|
+
? "data-club-ai-hub-admin__status-pill data-club-ai-hub-admin__status-pill--archived"
|
|
273
|
+
: "data-club-ai-hub-admin__status-pill data-club-ai-hub-admin__status-pill--active"
|
|
274
|
+
}
|
|
275
|
+
title={r.last_error ?? undefined}
|
|
276
|
+
>
|
|
277
|
+
{statusLabel(r, props.texts)}
|
|
278
|
+
</span>
|
|
279
|
+
</td>
|
|
280
|
+
<td>
|
|
281
|
+
<button
|
|
282
|
+
type="button"
|
|
283
|
+
className="data-club-ai-hub-admin__mono data-club-ai-hub-admin__row-action"
|
|
284
|
+
data-testid={`admin-rotating-row-${r.id}-copy-id`}
|
|
285
|
+
onClick={() => copyId(r.id)}
|
|
286
|
+
title={r.id}
|
|
287
|
+
>
|
|
288
|
+
{r.id}
|
|
289
|
+
</button>
|
|
290
|
+
</td>
|
|
291
|
+
<td>
|
|
292
|
+
<button
|
|
293
|
+
type="button"
|
|
294
|
+
className="data-club-ai-hub-admin__row-action"
|
|
295
|
+
data-testid={`admin-rotating-row-${r.id}-edit`}
|
|
296
|
+
onClick={() => setEditor({ kind: "edit", row: r })}
|
|
297
|
+
>
|
|
298
|
+
{props.texts.rotatingEditButton}
|
|
299
|
+
</button>
|
|
300
|
+
<button
|
|
301
|
+
type="button"
|
|
302
|
+
className="data-club-ai-hub-admin__row-action"
|
|
303
|
+
data-testid={`admin-rotating-row-${r.id}-rotate-now`}
|
|
304
|
+
onClick={() => void handleRotateNow(r)}
|
|
305
|
+
disabled={isRotating}
|
|
306
|
+
>
|
|
307
|
+
{isRotating ? props.texts.rotatingRotateNowRunning : props.texts.rotatingRotateNowButton}
|
|
308
|
+
</button>
|
|
309
|
+
{r.is_archived ? (
|
|
310
|
+
<button
|
|
311
|
+
type="button"
|
|
312
|
+
className="data-club-ai-hub-admin__row-action"
|
|
313
|
+
data-testid={`admin-rotating-row-${r.id}-unarchive`}
|
|
314
|
+
onClick={() => void handleArchiveToggle(r, false)}
|
|
315
|
+
>
|
|
316
|
+
{props.texts.rotatingUnarchiveButton}
|
|
317
|
+
</button>
|
|
318
|
+
) : (
|
|
319
|
+
<button
|
|
320
|
+
type="button"
|
|
321
|
+
className="data-club-ai-hub-admin__row-action"
|
|
322
|
+
data-testid={`admin-rotating-row-${r.id}-archive`}
|
|
323
|
+
onClick={() => void handleArchiveToggle(r, true)}
|
|
324
|
+
>
|
|
325
|
+
{props.texts.rotatingArchiveButton}
|
|
326
|
+
</button>
|
|
327
|
+
)}
|
|
328
|
+
</td>
|
|
329
|
+
</tr>
|
|
330
|
+
);
|
|
331
|
+
})}
|
|
332
|
+
</tbody>
|
|
333
|
+
</table>
|
|
334
|
+
) : null}
|
|
335
|
+
|
|
336
|
+
<label className="data-club-ai-hub-admin__filter-toggle">
|
|
337
|
+
<input
|
|
338
|
+
type="checkbox"
|
|
339
|
+
data-testid="admin-rotating-show-archived"
|
|
340
|
+
checked={showArchived}
|
|
341
|
+
onChange={(event) => setShowArchived(event.target.checked)}
|
|
342
|
+
/>
|
|
343
|
+
<span>{props.texts.rotatingShowArchivedToggle}</span>
|
|
344
|
+
</label>
|
|
345
|
+
|
|
346
|
+
{editor.kind === "create" ? (
|
|
347
|
+
<RotatingMessageEditorModal
|
|
348
|
+
mode={"create" satisfies RotatingEditorMode}
|
|
349
|
+
texts={props.texts}
|
|
350
|
+
onSubmit={handleCreateSubmit}
|
|
351
|
+
onCancel={() => setEditor({ kind: "closed" })}
|
|
352
|
+
/>
|
|
353
|
+
) : null}
|
|
354
|
+
{editor.kind === "edit" ? (
|
|
355
|
+
<RotatingMessageEditorModal
|
|
356
|
+
mode={"edit" satisfies RotatingEditorMode}
|
|
357
|
+
initial={{
|
|
358
|
+
displayName: editor.row.display_name,
|
|
359
|
+
prompt: editor.row.prompt,
|
|
360
|
+
lettaAgentId: editor.row.letta_agent_id,
|
|
361
|
+
scheduleKind: editor.row.schedule_kind,
|
|
362
|
+
intervalSeconds: editor.row.interval_seconds,
|
|
363
|
+
dailyTime: editor.row.daily_time,
|
|
364
|
+
cronExpression: editor.row.cron_expression,
|
|
365
|
+
}}
|
|
366
|
+
texts={props.texts}
|
|
367
|
+
onSubmit={(body) => handleEditSubmit(editor.row, body)}
|
|
368
|
+
onCancel={() => setEditor({ kind: "closed" })}
|
|
369
|
+
/>
|
|
370
|
+
) : null}
|
|
371
|
+
</div>
|
|
372
|
+
);
|
|
373
|
+
}
|