@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,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<RotatingMessageEditorModal />` — shared create + edit modal for the
|
|
3
|
+
* Rotating messages sub-page.
|
|
4
|
+
*
|
|
5
|
+
* Fields: display name, prompt (textarea), raw Letta agent id, and a schedule
|
|
6
|
+
* picker offering the two presets (`every N hours/days`, `daily at HH:MM`) plus
|
|
7
|
+
* an advanced cron escape hatch. The modal owns local required-field validation
|
|
8
|
+
* and the schedule-shape assembly; the parent page owns the network call.
|
|
9
|
+
*
|
|
10
|
+
* Errors surface inline for field-targeted server codes
|
|
11
|
+
* (`letta_agent_not_found` → agent field, `invalid_schedule` → schedule) and as
|
|
12
|
+
* a banner otherwise.
|
|
13
|
+
*
|
|
14
|
+
* @see docs/server/rotating-messages.md
|
|
15
|
+
*/
|
|
16
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
17
|
+
|
|
18
|
+
import type { AIHubAdminTexts } from "../../auth/texts.js";
|
|
19
|
+
import {
|
|
20
|
+
AIHubRequestError,
|
|
21
|
+
type RotatingMessageScheduleKind,
|
|
22
|
+
} from "../../client/AIHubClient.js";
|
|
23
|
+
|
|
24
|
+
/** Create vs edit. */
|
|
25
|
+
export type RotatingEditorMode = "create" | "edit";
|
|
26
|
+
|
|
27
|
+
/** Initial values for the edit variant. */
|
|
28
|
+
export interface RotatingEditorInitial {
|
|
29
|
+
displayName: string;
|
|
30
|
+
prompt: string;
|
|
31
|
+
lettaAgentId: string;
|
|
32
|
+
scheduleKind: RotatingMessageScheduleKind;
|
|
33
|
+
intervalSeconds: number | null;
|
|
34
|
+
dailyTime: string | null;
|
|
35
|
+
cronExpression: string | null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Submit body passed up to the parent page. */
|
|
39
|
+
export interface RotatingEditorSubmitBody {
|
|
40
|
+
displayName: string;
|
|
41
|
+
prompt: string;
|
|
42
|
+
lettaAgentId: string;
|
|
43
|
+
scheduleKind: RotatingMessageScheduleKind;
|
|
44
|
+
intervalSeconds: number | null;
|
|
45
|
+
dailyTime: string | null;
|
|
46
|
+
cronExpression: string | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Props for `<RotatingMessageEditorModal />`. */
|
|
50
|
+
export interface RotatingMessageEditorModalProps {
|
|
51
|
+
mode: RotatingEditorMode;
|
|
52
|
+
initial?: RotatingEditorInitial;
|
|
53
|
+
texts: AIHubAdminTexts;
|
|
54
|
+
onSubmit: (body: RotatingEditorSubmitBody) => Promise<void>;
|
|
55
|
+
onCancel: () => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const HHMM_RE = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
|
59
|
+
|
|
60
|
+
/** Decomposes an interval in seconds into a {value, unit} pair for the form. */
|
|
61
|
+
function decomposeInterval(seconds: number | null): { value: string; unit: "hours" | "days" } {
|
|
62
|
+
if (seconds && seconds % 86_400 === 0) {
|
|
63
|
+
return { value: String(seconds / 86_400), unit: "days" };
|
|
64
|
+
}
|
|
65
|
+
if (seconds && seconds % 3_600 === 0) {
|
|
66
|
+
return { value: String(seconds / 3_600), unit: "hours" };
|
|
67
|
+
}
|
|
68
|
+
return { value: "6", unit: "hours" };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Renders the create / edit form.
|
|
73
|
+
*
|
|
74
|
+
* @param props - see {@link RotatingMessageEditorModalProps}.
|
|
75
|
+
* @returns the modal markup.
|
|
76
|
+
*/
|
|
77
|
+
export function RotatingMessageEditorModal(
|
|
78
|
+
props: RotatingMessageEditorModalProps,
|
|
79
|
+
): ReactNode {
|
|
80
|
+
const isEdit = props.mode === "edit";
|
|
81
|
+
const initialInterval = decomposeInterval(props.initial?.intervalSeconds ?? null);
|
|
82
|
+
|
|
83
|
+
const [displayName, setDisplayName] = useState(props.initial?.displayName ?? "");
|
|
84
|
+
const [prompt, setPrompt] = useState(props.initial?.prompt ?? "");
|
|
85
|
+
const [lettaAgentId, setLettaAgentId] = useState(props.initial?.lettaAgentId ?? "");
|
|
86
|
+
const [scheduleKind, setScheduleKind] = useState<RotatingMessageScheduleKind>(
|
|
87
|
+
props.initial?.scheduleKind ?? "every",
|
|
88
|
+
);
|
|
89
|
+
const [intervalValue, setIntervalValue] = useState(initialInterval.value);
|
|
90
|
+
const [intervalUnit, setIntervalUnit] = useState<"hours" | "days">(initialInterval.unit);
|
|
91
|
+
const [dailyTime, setDailyTime] = useState(props.initial?.dailyTime ?? "06:00");
|
|
92
|
+
const [cronExpression, setCronExpression] = useState(props.initial?.cronExpression ?? "0 6 * * *");
|
|
93
|
+
|
|
94
|
+
const [nameError, setNameError] = useState<string | null>(null);
|
|
95
|
+
const [promptError, setPromptError] = useState<string | null>(null);
|
|
96
|
+
const [agentError, setAgentError] = useState<string | null>(null);
|
|
97
|
+
const [scheduleError, setScheduleError] = useState<string | null>(null);
|
|
98
|
+
const [banner, setBanner] = useState<string | null>(null);
|
|
99
|
+
const [submitting, setSubmitting] = useState(false);
|
|
100
|
+
const firstFieldRef = useRef<HTMLInputElement | null>(null);
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
firstFieldRef.current?.focus();
|
|
104
|
+
}, []);
|
|
105
|
+
|
|
106
|
+
function assembleSchedule():
|
|
107
|
+
| { ok: true; body: Pick<RotatingEditorSubmitBody, "scheduleKind" | "intervalSeconds" | "dailyTime" | "cronExpression"> }
|
|
108
|
+
| { ok: false } {
|
|
109
|
+
if (scheduleKind === "every") {
|
|
110
|
+
const n = Number(intervalValue);
|
|
111
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
112
|
+
setScheduleError(props.texts.rotatingScheduleInvalidError);
|
|
113
|
+
return { ok: false };
|
|
114
|
+
}
|
|
115
|
+
const seconds = Math.round(n * (intervalUnit === "days" ? 86_400 : 3_600));
|
|
116
|
+
return {
|
|
117
|
+
ok: true,
|
|
118
|
+
body: { scheduleKind, intervalSeconds: seconds, dailyTime: null, cronExpression: null },
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (scheduleKind === "daily") {
|
|
122
|
+
if (!HHMM_RE.test(dailyTime)) {
|
|
123
|
+
setScheduleError(props.texts.rotatingScheduleInvalidError);
|
|
124
|
+
return { ok: false };
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
body: { scheduleKind, intervalSeconds: null, dailyTime, cronExpression: null },
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const expr = cronExpression.trim();
|
|
132
|
+
if (expr.length === 0) {
|
|
133
|
+
setScheduleError(props.texts.rotatingScheduleInvalidError);
|
|
134
|
+
return { ok: false };
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
ok: true,
|
|
138
|
+
body: { scheduleKind, intervalSeconds: null, dailyTime: null, cronExpression: expr },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function handleSubmit(event: React.FormEvent): Promise<void> {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
setBanner(null);
|
|
145
|
+
setNameError(null);
|
|
146
|
+
setPromptError(null);
|
|
147
|
+
setAgentError(null);
|
|
148
|
+
setScheduleError(null);
|
|
149
|
+
|
|
150
|
+
const trimmedName = displayName.trim();
|
|
151
|
+
const trimmedPrompt = prompt.trim();
|
|
152
|
+
const trimmedAgent = lettaAgentId.trim();
|
|
153
|
+
if (trimmedName.length === 0) {
|
|
154
|
+
setNameError(props.texts.rotatingNameRequiredError);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (trimmedPrompt.length === 0) {
|
|
158
|
+
setPromptError(props.texts.rotatingPromptRequiredError);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (trimmedAgent.length === 0) {
|
|
162
|
+
setAgentError(props.texts.rotatingAgentRequiredError);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const schedule = assembleSchedule();
|
|
166
|
+
if (!schedule.ok) return;
|
|
167
|
+
|
|
168
|
+
setSubmitting(true);
|
|
169
|
+
try {
|
|
170
|
+
await props.onSubmit({
|
|
171
|
+
displayName: trimmedName,
|
|
172
|
+
prompt: trimmedPrompt,
|
|
173
|
+
lettaAgentId: trimmedAgent,
|
|
174
|
+
...schedule.body,
|
|
175
|
+
});
|
|
176
|
+
} catch (err) {
|
|
177
|
+
if (err instanceof AIHubRequestError) {
|
|
178
|
+
switch (err.code) {
|
|
179
|
+
case "letta_agent_not_found":
|
|
180
|
+
setAgentError(props.texts.rotatingAgentNotFoundError);
|
|
181
|
+
break;
|
|
182
|
+
case "invalid_schedule":
|
|
183
|
+
setScheduleError(props.texts.rotatingScheduleInvalidError);
|
|
184
|
+
break;
|
|
185
|
+
default:
|
|
186
|
+
setBanner(
|
|
187
|
+
err.message.length > 0 ? err.message : props.texts.rotatingSubmitGenericError,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
setBanner(
|
|
192
|
+
err instanceof Error && err.message.length > 0
|
|
193
|
+
? err.message
|
|
194
|
+
: props.texts.rotatingSubmitGenericError,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
setSubmitting(false);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const titleText = isEdit
|
|
202
|
+
? props.texts.editRotatingModalTitle.replace("{name}", props.initial?.displayName ?? "")
|
|
203
|
+
: props.texts.createRotatingModalTitle;
|
|
204
|
+
const submitText = submitting
|
|
205
|
+
? props.texts.rotatingModalSubmittingButton
|
|
206
|
+
: isEdit
|
|
207
|
+
? props.texts.rotatingModalSaveButton
|
|
208
|
+
: props.texts.rotatingModalCreateButton;
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<div
|
|
212
|
+
className="data-club-ai-hub-admin__modal-backdrop"
|
|
213
|
+
role="presentation"
|
|
214
|
+
onMouseDown={(event) => {
|
|
215
|
+
if (event.target === event.currentTarget) props.onCancel();
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
<div
|
|
219
|
+
className="data-club-ai-hub-admin__modal"
|
|
220
|
+
role="dialog"
|
|
221
|
+
aria-modal="true"
|
|
222
|
+
aria-labelledby="rotating-editor-title"
|
|
223
|
+
data-testid={`admin-rotating-${props.mode}-modal`}
|
|
224
|
+
>
|
|
225
|
+
<h2 id="rotating-editor-title" className="data-club-ai-hub-admin__modal-title">
|
|
226
|
+
{titleText}
|
|
227
|
+
</h2>
|
|
228
|
+
<form onSubmit={(event) => void handleSubmit(event)} noValidate>
|
|
229
|
+
<label className="data-club-ai-hub-admin__form-field">
|
|
230
|
+
<span className="data-club-ai-hub-admin__form-label">{props.texts.rotatingNameLabel}</span>
|
|
231
|
+
<input
|
|
232
|
+
ref={firstFieldRef}
|
|
233
|
+
type="text"
|
|
234
|
+
className="data-club-ai-hub-admin__form-input"
|
|
235
|
+
data-testid="admin-rotating-name-input"
|
|
236
|
+
value={displayName}
|
|
237
|
+
onChange={(event) => setDisplayName(event.target.value)}
|
|
238
|
+
maxLength={255}
|
|
239
|
+
disabled={submitting}
|
|
240
|
+
/>
|
|
241
|
+
<span className="data-club-ai-hub-admin__form-helper">{props.texts.rotatingNameHelper}</span>
|
|
242
|
+
{nameError !== null ? (
|
|
243
|
+
<span className="data-club-ai-hub-admin__form-error" role="alert">
|
|
244
|
+
{nameError}
|
|
245
|
+
</span>
|
|
246
|
+
) : null}
|
|
247
|
+
</label>
|
|
248
|
+
|
|
249
|
+
<label className="data-club-ai-hub-admin__form-field">
|
|
250
|
+
<span className="data-club-ai-hub-admin__form-label">{props.texts.rotatingPromptLabel}</span>
|
|
251
|
+
<textarea
|
|
252
|
+
className="data-club-ai-hub-admin__form-input"
|
|
253
|
+
data-testid="admin-rotating-prompt-input"
|
|
254
|
+
value={prompt}
|
|
255
|
+
onChange={(event) => setPrompt(event.target.value)}
|
|
256
|
+
maxLength={10_000}
|
|
257
|
+
rows={3}
|
|
258
|
+
disabled={submitting}
|
|
259
|
+
/>
|
|
260
|
+
<span className="data-club-ai-hub-admin__form-helper">{props.texts.rotatingPromptHelper}</span>
|
|
261
|
+
{promptError !== null ? (
|
|
262
|
+
<span className="data-club-ai-hub-admin__form-error" role="alert">
|
|
263
|
+
{promptError}
|
|
264
|
+
</span>
|
|
265
|
+
) : null}
|
|
266
|
+
</label>
|
|
267
|
+
|
|
268
|
+
<label className="data-club-ai-hub-admin__form-field">
|
|
269
|
+
<span className="data-club-ai-hub-admin__form-label">{props.texts.rotatingAgentLabel}</span>
|
|
270
|
+
<input
|
|
271
|
+
type="text"
|
|
272
|
+
className="data-club-ai-hub-admin__form-input"
|
|
273
|
+
data-testid="admin-rotating-agent-input"
|
|
274
|
+
value={lettaAgentId}
|
|
275
|
+
onChange={(event) => setLettaAgentId(event.target.value)}
|
|
276
|
+
maxLength={255}
|
|
277
|
+
disabled={submitting}
|
|
278
|
+
/>
|
|
279
|
+
<span className="data-club-ai-hub-admin__form-helper">{props.texts.rotatingAgentHelper}</span>
|
|
280
|
+
{agentError !== null ? (
|
|
281
|
+
<span className="data-club-ai-hub-admin__form-error" role="alert">
|
|
282
|
+
{agentError}
|
|
283
|
+
</span>
|
|
284
|
+
) : null}
|
|
285
|
+
</label>
|
|
286
|
+
|
|
287
|
+
<fieldset className="data-club-ai-hub-admin__form-field" data-testid="admin-rotating-schedule">
|
|
288
|
+
<legend className="data-club-ai-hub-admin__form-label">{props.texts.rotatingScheduleLabel}</legend>
|
|
289
|
+
<label className="data-club-ai-hub-admin__radio-row">
|
|
290
|
+
<input
|
|
291
|
+
type="radio"
|
|
292
|
+
name="schedule-kind"
|
|
293
|
+
checked={scheduleKind === "every"}
|
|
294
|
+
onChange={() => setScheduleKind("every")}
|
|
295
|
+
disabled={submitting}
|
|
296
|
+
/>
|
|
297
|
+
<span>{props.texts.rotatingScheduleEveryOption}</span>
|
|
298
|
+
</label>
|
|
299
|
+
{scheduleKind === "every" ? (
|
|
300
|
+
<div className="data-club-ai-hub-admin__inline-row">
|
|
301
|
+
<span className="data-club-ai-hub-admin__form-label">{props.texts.rotatingIntervalValueLabel}</span>
|
|
302
|
+
<input
|
|
303
|
+
type="number"
|
|
304
|
+
min={1}
|
|
305
|
+
className="data-club-ai-hub-admin__form-input data-club-ai-hub-admin__form-input--narrow"
|
|
306
|
+
data-testid="admin-rotating-interval-value"
|
|
307
|
+
value={intervalValue}
|
|
308
|
+
onChange={(event) => setIntervalValue(event.target.value)}
|
|
309
|
+
disabled={submitting}
|
|
310
|
+
/>
|
|
311
|
+
<select
|
|
312
|
+
className="data-club-ai-hub-admin__form-input data-club-ai-hub-admin__form-input--narrow"
|
|
313
|
+
data-testid="admin-rotating-interval-unit"
|
|
314
|
+
value={intervalUnit}
|
|
315
|
+
onChange={(event) => setIntervalUnit(event.target.value as "hours" | "days")}
|
|
316
|
+
disabled={submitting}
|
|
317
|
+
>
|
|
318
|
+
<option value="hours">{props.texts.rotatingIntervalUnitHours}</option>
|
|
319
|
+
<option value="days">{props.texts.rotatingIntervalUnitDays}</option>
|
|
320
|
+
</select>
|
|
321
|
+
</div>
|
|
322
|
+
) : null}
|
|
323
|
+
|
|
324
|
+
<label className="data-club-ai-hub-admin__radio-row">
|
|
325
|
+
<input
|
|
326
|
+
type="radio"
|
|
327
|
+
name="schedule-kind"
|
|
328
|
+
checked={scheduleKind === "daily"}
|
|
329
|
+
onChange={() => setScheduleKind("daily")}
|
|
330
|
+
disabled={submitting}
|
|
331
|
+
/>
|
|
332
|
+
<span>{props.texts.rotatingScheduleDailyOption}</span>
|
|
333
|
+
</label>
|
|
334
|
+
{scheduleKind === "daily" ? (
|
|
335
|
+
<div className="data-club-ai-hub-admin__inline-row">
|
|
336
|
+
<span className="data-club-ai-hub-admin__form-label">{props.texts.rotatingDailyTimeLabel}</span>
|
|
337
|
+
<input
|
|
338
|
+
type="time"
|
|
339
|
+
className="data-club-ai-hub-admin__form-input data-club-ai-hub-admin__form-input--narrow"
|
|
340
|
+
data-testid="admin-rotating-daily-time"
|
|
341
|
+
value={dailyTime}
|
|
342
|
+
onChange={(event) => setDailyTime(event.target.value)}
|
|
343
|
+
disabled={submitting}
|
|
344
|
+
/>
|
|
345
|
+
<span className="data-club-ai-hub-admin__form-helper">{props.texts.rotatingDailyTimeHelper}</span>
|
|
346
|
+
</div>
|
|
347
|
+
) : null}
|
|
348
|
+
|
|
349
|
+
<label className="data-club-ai-hub-admin__radio-row">
|
|
350
|
+
<input
|
|
351
|
+
type="radio"
|
|
352
|
+
name="schedule-kind"
|
|
353
|
+
checked={scheduleKind === "cron"}
|
|
354
|
+
onChange={() => setScheduleKind("cron")}
|
|
355
|
+
disabled={submitting}
|
|
356
|
+
/>
|
|
357
|
+
<span>{props.texts.rotatingScheduleCronOption}</span>
|
|
358
|
+
</label>
|
|
359
|
+
{scheduleKind === "cron" ? (
|
|
360
|
+
<div className="data-club-ai-hub-admin__inline-row">
|
|
361
|
+
<input
|
|
362
|
+
type="text"
|
|
363
|
+
className="data-club-ai-hub-admin__form-input"
|
|
364
|
+
data-testid="admin-rotating-cron-input"
|
|
365
|
+
value={cronExpression}
|
|
366
|
+
onChange={(event) => setCronExpression(event.target.value)}
|
|
367
|
+
maxLength={255}
|
|
368
|
+
disabled={submitting}
|
|
369
|
+
/>
|
|
370
|
+
<span className="data-club-ai-hub-admin__form-helper">{props.texts.rotatingCronHelper}</span>
|
|
371
|
+
</div>
|
|
372
|
+
) : null}
|
|
373
|
+
{scheduleError !== null ? (
|
|
374
|
+
<span className="data-club-ai-hub-admin__form-error" role="alert" data-testid="admin-rotating-schedule-error">
|
|
375
|
+
{scheduleError}
|
|
376
|
+
</span>
|
|
377
|
+
) : null}
|
|
378
|
+
</fieldset>
|
|
379
|
+
|
|
380
|
+
{banner !== null ? (
|
|
381
|
+
<div className="data-club-ai-hub-admin__error" role="alert" data-testid="admin-rotating-modal-banner">
|
|
382
|
+
{banner}
|
|
383
|
+
</div>
|
|
384
|
+
) : null}
|
|
385
|
+
<div className="data-club-ai-hub-admin__modal-actions">
|
|
386
|
+
<button
|
|
387
|
+
type="button"
|
|
388
|
+
className="data-club-ai-hub-admin__button"
|
|
389
|
+
data-testid="admin-rotating-modal-cancel"
|
|
390
|
+
onClick={props.onCancel}
|
|
391
|
+
disabled={submitting}
|
|
392
|
+
>
|
|
393
|
+
{props.texts.rotatingModalCancelButton}
|
|
394
|
+
</button>
|
|
395
|
+
<button
|
|
396
|
+
type="submit"
|
|
397
|
+
className="data-club-ai-hub-admin__button data-club-ai-hub-admin__button--primary"
|
|
398
|
+
data-testid="admin-rotating-modal-submit"
|
|
399
|
+
disabled={submitting}
|
|
400
|
+
>
|
|
401
|
+
{submitText}
|
|
402
|
+
</button>
|
|
403
|
+
</div>
|
|
404
|
+
</form>
|
|
405
|
+
</div>
|
|
406
|
+
</div>
|
|
407
|
+
);
|
|
408
|
+
}
|