@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,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal React context shared by `<AIHubProvider>` + the `useAIHub` /
|
|
3
|
+
* `useAIHubAuth` hooks.
|
|
4
|
+
*
|
|
5
|
+
* Kept separate from `AIHubProvider.tsx` so the hooks can import the
|
|
6
|
+
* context object without pulling in the provider's component tree (and
|
|
7
|
+
* the JSX dependencies that come with it).
|
|
8
|
+
*
|
|
9
|
+
* @see SPECIFICATIONS.md §7.2 — provider + hooks
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { createContext } from "react";
|
|
13
|
+
|
|
14
|
+
import type {
|
|
15
|
+
AgentSummary,
|
|
16
|
+
AIHubClient,
|
|
17
|
+
LoginResponse,
|
|
18
|
+
PatchSessionOptions,
|
|
19
|
+
} from "../client/AIHubClient.js";
|
|
20
|
+
import type { AIHubEffort } from "../client/AIHubClient.js";
|
|
21
|
+
import type {
|
|
22
|
+
AIHubAuthContext,
|
|
23
|
+
AIHubFeatureToggles,
|
|
24
|
+
AIHubMessage,
|
|
25
|
+
AIHubRole,
|
|
26
|
+
AIHubState,
|
|
27
|
+
AIHubToolCallRecord,
|
|
28
|
+
AIHubUser,
|
|
29
|
+
Session,
|
|
30
|
+
} from "../types.js";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The shape provided by `<AIHubProvider>` to its descendants. Hook
|
|
34
|
+
* implementations destructure this; consumers don't see it directly.
|
|
35
|
+
*/
|
|
36
|
+
export interface AIHubContextValue {
|
|
37
|
+
/** The underlying SDK — consumers can call any method directly. */
|
|
38
|
+
client: AIHubClient;
|
|
39
|
+
|
|
40
|
+
/* ── auth state ─────────────────────────────────────────────────── */
|
|
41
|
+
/** Currently authenticated user, or null when no valid token is present. */
|
|
42
|
+
user: AIHubUser | null;
|
|
43
|
+
/** Echoes `user.role` for convenience; null when unauthenticated. */
|
|
44
|
+
role: AIHubRole | null;
|
|
45
|
+
/** Deployment-wide context from `/auth/me`; null when unauthenticated. */
|
|
46
|
+
deployment: AIHubAuthContext["deployment"] | null;
|
|
47
|
+
/**
|
|
48
|
+
* True when the user must call `changePassword` before any other endpoint
|
|
49
|
+
* accepts the token. Forces the change-password screen to render under
|
|
50
|
+
* `AuthGate` (Step 8).
|
|
51
|
+
*/
|
|
52
|
+
mustChangePassword: boolean;
|
|
53
|
+
/** Initialization state — `true` until the first `/auth/me` resolves. */
|
|
54
|
+
hydrating: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Logs in via `client.login`. Stores the token + refreshes auth state.
|
|
57
|
+
* Returns the underlying `LoginResponse` so callers (e.g. the auto-
|
|
58
|
+
* rendered `<DataClubAIHubLogin />`) can branch on `mustChangePassword`
|
|
59
|
+
* + read the just-authenticated `user` without waiting for the next
|
|
60
|
+
* render. Throws `AIHubRequestError` on failure (the caller decides UX).
|
|
61
|
+
*/
|
|
62
|
+
login: (username: string, password: string) => Promise<LoginResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Clears the local token; calls `client.logout()` best-effort for the
|
|
65
|
+
* audit log. The state transitions to `user=null, role=null` so consumers
|
|
66
|
+
* route back to login.
|
|
67
|
+
*/
|
|
68
|
+
logout: () => Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Calls `client.changePassword`; after success, refreshes `/auth/me` so
|
|
71
|
+
* `user` + `deployment` reflect the now-clearable `is_initial_password`
|
|
72
|
+
* flag.
|
|
73
|
+
*/
|
|
74
|
+
changePassword: (
|
|
75
|
+
currentPassword: string | null,
|
|
76
|
+
newPassword: string,
|
|
77
|
+
) => Promise<void>;
|
|
78
|
+
|
|
79
|
+
/* ── chat state (wired in Step 9) ───────────────────────────────── */
|
|
80
|
+
/**
|
|
81
|
+
* Active turn's reducer state, driven by SSE events flowing from
|
|
82
|
+
* `client.streamChat()`. Re-derived from the persisted event log on
|
|
83
|
+
* reconnect (§7.5).
|
|
84
|
+
*/
|
|
85
|
+
state: AIHubState;
|
|
86
|
+
/** Per-message reasoning effort (§7.4). Defaults to `"medium"`. */
|
|
87
|
+
effort: AIHubEffort;
|
|
88
|
+
/** Sets the per-message effort. Survives until changed. */
|
|
89
|
+
setEffort: (next: AIHubEffort) => void;
|
|
90
|
+
/**
|
|
91
|
+
* The ai-hub agents catalog visible to the caller (non-archived only,
|
|
92
|
+
* with caller-scoped `session_count`). Loaded once after authentication;
|
|
93
|
+
* refreshed via `refreshAgents()`.
|
|
94
|
+
*/
|
|
95
|
+
agents: AgentSummary[];
|
|
96
|
+
/** True while the initial `/agents` request is in flight. */
|
|
97
|
+
agentsLoading: boolean;
|
|
98
|
+
/** Refetches `/agents` — e.g. after a new session was created. */
|
|
99
|
+
refreshAgents: () => Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* The ai-hub agent the user has opened. `null` when on the agents
|
|
102
|
+
* picker. The sessions list + chat column read from this.
|
|
103
|
+
*/
|
|
104
|
+
activeAgentId: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Opens an agent (transitions out of the agents picker) or clears the
|
|
107
|
+
* selection back to it (`null`).
|
|
108
|
+
*/
|
|
109
|
+
setActiveAgent: (id: string | null) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Sessions for the active agent + current user, ordered by
|
|
112
|
+
* `updated_at DESC`. Empty when no agent is open.
|
|
113
|
+
*/
|
|
114
|
+
sessions: Session[];
|
|
115
|
+
/** True while the active agent's `/sessions` request is in flight. */
|
|
116
|
+
sessionsLoading: boolean;
|
|
117
|
+
/** Refetches `/sessions` for the active agent. */
|
|
118
|
+
refreshSessions: () => Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the sessions list includes archived rows. Toggled by the
|
|
121
|
+
* `archived_filter_toggle` at the bottom of the panel.
|
|
122
|
+
*/
|
|
123
|
+
includeArchivedSessions: boolean;
|
|
124
|
+
/** Sets the archived filter. */
|
|
125
|
+
setIncludeArchivedSessions: (next: boolean) => void;
|
|
126
|
+
/** The opened session id, or `null` if none. */
|
|
127
|
+
activeSessionId: string | null;
|
|
128
|
+
/** Opens a session (loads its message history). */
|
|
129
|
+
setActiveSession: (id: string | null) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a session via `POST /sessions` and selects it. `title` is
|
|
132
|
+
* required (1..80 chars). Rejected client-side on empty / oversize.
|
|
133
|
+
*/
|
|
134
|
+
createSession: (title: string) => Promise<Session>;
|
|
135
|
+
/** Rename / archive a session via `PATCH /sessions/{id}`. */
|
|
136
|
+
patchSession: (id: string, patch: PatchSessionOptions) => Promise<Session>;
|
|
137
|
+
/**
|
|
138
|
+
* Messages for the active session. Loaded from
|
|
139
|
+
* `GET /sessions/{id}/messages` when `activeSessionId` changes; appended
|
|
140
|
+
* to during streaming. Empty when no session is active.
|
|
141
|
+
*/
|
|
142
|
+
messages: AIHubMessage[];
|
|
143
|
+
/** True while the active session's message history is loading. */
|
|
144
|
+
messagesLoading: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* In-progress assistant text — accumulating `assistant_delta`s for the
|
|
147
|
+
* currently-streaming turn. `null` when no turn is in flight.
|
|
148
|
+
*/
|
|
149
|
+
streamingAssistantText: string | null;
|
|
150
|
+
/**
|
|
151
|
+
* In-progress reasoning text — accumulating `reasoning_delta`s for
|
|
152
|
+
* the currently-streaming turn. `null` when no reasoning is in
|
|
153
|
+
* flight. The live assistant bubble renders this via
|
|
154
|
+
* `<ReasoningView />`.
|
|
155
|
+
*/
|
|
156
|
+
streamingReasoning: string | null;
|
|
157
|
+
/**
|
|
158
|
+
* In-progress tool calls — built up from `tool_call_started` /
|
|
159
|
+
* `tool_call_input_delta` / `tool_call_result` events. Empty when no
|
|
160
|
+
* tool is being invoked.
|
|
161
|
+
*/
|
|
162
|
+
streamingToolCalls: ReadonlyArray<AIHubToolCallRecord>;
|
|
163
|
+
/**
|
|
164
|
+
* Sends `text` against the active session, opening an SSE stream. Throws
|
|
165
|
+
* if no session is active or the request fails before the stream opens.
|
|
166
|
+
*/
|
|
167
|
+
sendMessage: (text: string) => Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Cancels the in-flight turn via `POST /chat/{turn_id}/cancel`.
|
|
170
|
+
* The server-side handler calls Letta's authoritative
|
|
171
|
+
* `agents.messages.cancel` API (which rolls back the in-progress
|
|
172
|
+
* step from the conversation history while preserving completed
|
|
173
|
+
* steps) and signals our runner to emit `stream_end{cancelled}`.
|
|
174
|
+
* The client deliberately DOES NOT abort the SSE iterator — it
|
|
175
|
+
* waits for the genuine terminal event so the post-stream
|
|
176
|
+
* canonicalize sees Letta's true final state.
|
|
177
|
+
*/
|
|
178
|
+
stop: () => Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* True from the moment the user clicks Stop until the in-flight
|
|
181
|
+
* turn's `stream_end` lands. UI-only flag; the state machine's
|
|
182
|
+
* `state.status` stays `running` for the brief "Stopping…" window
|
|
183
|
+
* because the server is server-authoritative for that. Drives the
|
|
184
|
+
* button label / disabled state in `<MessageInput>`.
|
|
185
|
+
*/
|
|
186
|
+
isStoppingTurn: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Text to push into the input on the next render. Set by the post-
|
|
189
|
+
* stream-end branch when a cancel rolled back the user's message
|
|
190
|
+
* (single-step cancel: Letta deletes the entire turn including the
|
|
191
|
+
* user message). `<MessageInput>` reads it, populates the textarea,
|
|
192
|
+
* and clears via `consumePendingDraft()`.
|
|
193
|
+
*/
|
|
194
|
+
pendingDraft: string | null;
|
|
195
|
+
/**
|
|
196
|
+
* Atomically reads + clears `pendingDraft` — used by `<MessageInput>`
|
|
197
|
+
* after it copies the value into its local textarea state. Returns
|
|
198
|
+
* the consumed value (or null if none was pending).
|
|
199
|
+
*/
|
|
200
|
+
consumePendingDraft: () => string | null;
|
|
201
|
+
/**
|
|
202
|
+
* Returned by `sendMessage` when the stream fails before any `stream_end`
|
|
203
|
+
* fires (network drop, unrecoverable error). Plain message for the
|
|
204
|
+
* `--failed` modifier — Step 10 enriches with a Retry button.
|
|
205
|
+
*/
|
|
206
|
+
lastTurnError: string | null;
|
|
207
|
+
|
|
208
|
+
/* ── theme state (§7.6) ─────────────────────────────────────────── */
|
|
209
|
+
/** Resolved theme (`light` | `dark`) — computed per §7.6 precedence. */
|
|
210
|
+
theme: "light" | "dark";
|
|
211
|
+
/**
|
|
212
|
+
* Flips the theme. Optimistic; reverts on server error
|
|
213
|
+
* (`theme_switcher_disabled` → server returned 409).
|
|
214
|
+
*/
|
|
215
|
+
setTheme: (next: "light" | "dark") => Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Mirror of `deployment.theme_switcher_enabled`. When false, the
|
|
218
|
+
* `AIHub.ThemeSwitcher` primitive renders nothing.
|
|
219
|
+
*/
|
|
220
|
+
themeSwitcherEnabled: boolean;
|
|
221
|
+
|
|
222
|
+
/* ── feature toggles (§8.4, wired in Step 10) ──────────────────── */
|
|
223
|
+
/**
|
|
224
|
+
* The deployment-wide UI feature toggles fetched from public
|
|
225
|
+
* `GET /feature-toggles` on mount. `null` while the request is in
|
|
226
|
+
* flight; thereafter the wire blob (possibly empty `{}`).
|
|
227
|
+
*
|
|
228
|
+
* Consumers should not branch on individual keys directly — use
|
|
229
|
+
* `useAffordanceFlags()` to compute the resolved flag stack with
|
|
230
|
+
* precedence ("server toggle > React prop > built-in default").
|
|
231
|
+
*
|
|
232
|
+
* @see SPECIFICATIONS.md §8.4
|
|
233
|
+
*/
|
|
234
|
+
featureToggles: AIHubFeatureToggles | null;
|
|
235
|
+
/**
|
|
236
|
+
* Re-fetches the toggles blob. Called by the super-admin Settings
|
|
237
|
+
* page (Step 12) after a save so the saving super-admin sees the
|
|
238
|
+
* effect without a page reload.
|
|
239
|
+
*/
|
|
240
|
+
refreshFeatureToggles: () => Promise<void>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The React context object. Default value is `null` — every hook checks
|
|
245
|
+
* for null and throws a "Wrapped in `<AIHubProvider>`?" error in dev so
|
|
246
|
+
* misconfiguration surfaces immediately instead of cascading null-deref
|
|
247
|
+
* failures in components.
|
|
248
|
+
*/
|
|
249
|
+
export const aiHubContext = createContext<AIHubContextValue | null>(null);
|