@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.
Files changed (344) hide show
  1. package/dist/auth/passwordPolicy.d.ts +55 -0
  2. package/dist/auth/passwordPolicy.d.ts.map +1 -0
  3. package/dist/auth/passwordPolicy.js +63 -0
  4. package/dist/auth/passwordPolicy.js.map +1 -0
  5. package/dist/auth/texts.d.ts +815 -0
  6. package/dist/auth/texts.d.ts.map +1 -0
  7. package/dist/auth/texts.js +429 -0
  8. package/dist/auth/texts.js.map +1 -0
  9. package/dist/client/AIHubClient.d.ts +1058 -0
  10. package/dist/client/AIHubClient.d.ts.map +1 -0
  11. package/dist/client/AIHubClient.js +950 -0
  12. package/dist/client/AIHubClient.js.map +1 -0
  13. package/dist/client/index.d.ts +11 -0
  14. package/dist/client/index.d.ts.map +1 -0
  15. package/dist/client/index.js +9 -0
  16. package/dist/client/index.js.map +1 -0
  17. package/dist/client/sseParser.d.ts +41 -0
  18. package/dist/client/sseParser.d.ts.map +1 -0
  19. package/dist/client/sseParser.js +153 -0
  20. package/dist/client/sseParser.js.map +1 -0
  21. package/dist/client/tokenStorage.d.ts +56 -0
  22. package/dist/client/tokenStorage.d.ts.map +1 -0
  23. package/dist/client/tokenStorage.js +116 -0
  24. package/dist/client/tokenStorage.js.map +1 -0
  25. package/dist/components/AgentsPicker/index.d.ts +70 -0
  26. package/dist/components/AgentsPicker/index.d.ts.map +1 -0
  27. package/dist/components/AgentsPicker/index.js +63 -0
  28. package/dist/components/AgentsPicker/index.js.map +1 -0
  29. package/dist/components/AuthGate/index.d.ts +79 -0
  30. package/dist/components/AuthGate/index.d.ts.map +1 -0
  31. package/dist/components/AuthGate/index.js +61 -0
  32. package/dist/components/AuthGate/index.js.map +1 -0
  33. package/dist/components/CacheBadge/index.d.ts +88 -0
  34. package/dist/components/CacheBadge/index.d.ts.map +1 -0
  35. package/dist/components/CacheBadge/index.js +127 -0
  36. package/dist/components/CacheBadge/index.js.map +1 -0
  37. package/dist/components/ChangePassword/index.d.ts +109 -0
  38. package/dist/components/ChangePassword/index.d.ts.map +1 -0
  39. package/dist/components/ChangePassword/index.js +142 -0
  40. package/dist/components/ChangePassword/index.js.map +1 -0
  41. package/dist/components/ChatShell/ShellHeader.d.ts +44 -0
  42. package/dist/components/ChatShell/ShellHeader.d.ts.map +1 -0
  43. package/dist/components/ChatShell/ShellHeader.js +14 -0
  44. package/dist/components/ChatShell/ShellHeader.js.map +1 -0
  45. package/dist/components/ChatShell/UserMenu.d.ts +48 -0
  46. package/dist/components/ChatShell/UserMenu.d.ts.map +1 -0
  47. package/dist/components/ChatShell/UserMenu.js +86 -0
  48. package/dist/components/ChatShell/UserMenu.js.map +1 -0
  49. package/dist/components/ChatShell/index.d.ts +98 -0
  50. package/dist/components/ChatShell/index.d.ts.map +1 -0
  51. package/dist/components/ChatShell/index.js +124 -0
  52. package/dist/components/ChatShell/index.js.map +1 -0
  53. package/dist/components/DataClubAIHub/index.d.ts +132 -0
  54. package/dist/components/DataClubAIHub/index.d.ts.map +1 -0
  55. package/dist/components/DataClubAIHub/index.js +124 -0
  56. package/dist/components/DataClubAIHub/index.js.map +1 -0
  57. package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts +89 -0
  58. package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts.map +1 -0
  59. package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js +199 -0
  60. package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js.map +1 -0
  61. package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts +33 -0
  62. package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts.map +1 -0
  63. package/dist/components/DataClubAIHubAdmin/AgentsPage.js +137 -0
  64. package/dist/components/DataClubAIHubAdmin/AgentsPage.js.map +1 -0
  65. package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts +50 -0
  66. package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts.map +1 -0
  67. package/dist/components/DataClubAIHubAdmin/CreateUserModal.js +93 -0
  68. package/dist/components/DataClubAIHubAdmin/CreateUserModal.js.map +1 -0
  69. package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts +49 -0
  70. package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts.map +1 -0
  71. package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js +94 -0
  72. package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js.map +1 -0
  73. package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts +37 -0
  74. package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts.map +1 -0
  75. package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js +44 -0
  76. package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js.map +1 -0
  77. package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts +56 -0
  78. package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts.map +1 -0
  79. package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js +158 -0
  80. package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js.map +1 -0
  81. package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts +29 -0
  82. package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts.map +1 -0
  83. package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js +183 -0
  84. package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js.map +1 -0
  85. package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts +38 -0
  86. package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts.map +1 -0
  87. package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js +294 -0
  88. package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js.map +1 -0
  89. package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts +36 -0
  90. package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts.map +1 -0
  91. package/dist/components/DataClubAIHubAdmin/SettingsPage.js +373 -0
  92. package/dist/components/DataClubAIHubAdmin/SettingsPage.js.map +1 -0
  93. package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts +47 -0
  94. package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts.map +1 -0
  95. package/dist/components/DataClubAIHubAdmin/UsersPage.js +233 -0
  96. package/dist/components/DataClubAIHubAdmin/UsersPage.js.map +1 -0
  97. package/dist/components/DataClubAIHubAdmin/index.d.ts +87 -0
  98. package/dist/components/DataClubAIHubAdmin/index.d.ts.map +1 -0
  99. package/dist/components/DataClubAIHubAdmin/index.js +137 -0
  100. package/dist/components/DataClubAIHubAdmin/index.js.map +1 -0
  101. package/dist/components/DataClubAIHubLogin/index.d.ts +113 -0
  102. package/dist/components/DataClubAIHubLogin/index.d.ts.map +1 -0
  103. package/dist/components/DataClubAIHubLogin/index.js +123 -0
  104. package/dist/components/DataClubAIHubLogin/index.js.map +1 -0
  105. package/dist/components/EffortControl/index.d.ts +57 -0
  106. package/dist/components/EffortControl/index.d.ts.map +1 -0
  107. package/dist/components/EffortControl/index.js +84 -0
  108. package/dist/components/EffortControl/index.js.map +1 -0
  109. package/dist/components/Layout/index.d.ts +63 -0
  110. package/dist/components/Layout/index.d.ts.map +1 -0
  111. package/dist/components/Layout/index.js +45 -0
  112. package/dist/components/Layout/index.js.map +1 -0
  113. package/dist/components/MainColumn/index.d.ts +69 -0
  114. package/dist/components/MainColumn/index.d.ts.map +1 -0
  115. package/dist/components/MainColumn/index.js +47 -0
  116. package/dist/components/MainColumn/index.js.map +1 -0
  117. package/dist/components/MarkdownRenderer/index.d.ts +66 -0
  118. package/dist/components/MarkdownRenderer/index.d.ts.map +1 -0
  119. package/dist/components/MarkdownRenderer/index.js +153 -0
  120. package/dist/components/MarkdownRenderer/index.js.map +1 -0
  121. package/dist/components/MessageInput/index.d.ts +85 -0
  122. package/dist/components/MessageInput/index.d.ts.map +1 -0
  123. package/dist/components/MessageInput/index.js +139 -0
  124. package/dist/components/MessageInput/index.js.map +1 -0
  125. package/dist/components/MessageList/index.d.ts +156 -0
  126. package/dist/components/MessageList/index.d.ts.map +1 -0
  127. package/dist/components/MessageList/index.js +352 -0
  128. package/dist/components/MessageList/index.js.map +1 -0
  129. package/dist/components/ReasoningSelector/index.d.ts +77 -0
  130. package/dist/components/ReasoningSelector/index.d.ts.map +1 -0
  131. package/dist/components/ReasoningSelector/index.js +156 -0
  132. package/dist/components/ReasoningSelector/index.js.map +1 -0
  133. package/dist/components/ReasoningView/index.d.ts +94 -0
  134. package/dist/components/ReasoningView/index.d.ts.map +1 -0
  135. package/dist/components/ReasoningView/index.js +83 -0
  136. package/dist/components/ReasoningView/index.js.map +1 -0
  137. package/dist/components/ScrollToPresentButton/index.d.ts +54 -0
  138. package/dist/components/ScrollToPresentButton/index.d.ts.map +1 -0
  139. package/dist/components/ScrollToPresentButton/index.js +44 -0
  140. package/dist/components/ScrollToPresentButton/index.js.map +1 -0
  141. package/dist/components/SessionsPanel/SessionTitleModal.d.ts +79 -0
  142. package/dist/components/SessionsPanel/SessionTitleModal.d.ts.map +1 -0
  143. package/dist/components/SessionsPanel/SessionTitleModal.js +102 -0
  144. package/dist/components/SessionsPanel/SessionTitleModal.js.map +1 -0
  145. package/dist/components/SessionsPanel/index.d.ts +100 -0
  146. package/dist/components/SessionsPanel/index.d.ts.map +1 -0
  147. package/dist/components/SessionsPanel/index.js +176 -0
  148. package/dist/components/SessionsPanel/index.js.map +1 -0
  149. package/dist/components/SystemNotice/index.d.ts +66 -0
  150. package/dist/components/SystemNotice/index.d.ts.map +1 -0
  151. package/dist/components/SystemNotice/index.js +81 -0
  152. package/dist/components/SystemNotice/index.js.map +1 -0
  153. package/dist/components/ThemeSwitcher/index.d.ts +66 -0
  154. package/dist/components/ThemeSwitcher/index.d.ts.map +1 -0
  155. package/dist/components/ThemeSwitcher/index.js +73 -0
  156. package/dist/components/ThemeSwitcher/index.js.map +1 -0
  157. package/dist/components/ToolCallView/formatContent.d.ts +36 -0
  158. package/dist/components/ToolCallView/formatContent.d.ts.map +1 -0
  159. package/dist/components/ToolCallView/formatContent.js +53 -0
  160. package/dist/components/ToolCallView/formatContent.js.map +1 -0
  161. package/dist/components/ToolCallView/index.d.ts +120 -0
  162. package/dist/components/ToolCallView/index.d.ts.map +1 -0
  163. package/dist/components/ToolCallView/index.js +104 -0
  164. package/dist/components/ToolCallView/index.js.map +1 -0
  165. package/dist/components/TpmBanner/index.d.ts +53 -0
  166. package/dist/components/TpmBanner/index.d.ts.map +1 -0
  167. package/dist/components/TpmBanner/index.js +116 -0
  168. package/dist/components/TpmBanner/index.js.map +1 -0
  169. package/dist/components/TurnStatusIndicator/index.d.ts +77 -0
  170. package/dist/components/TurnStatusIndicator/index.d.ts.map +1 -0
  171. package/dist/components/TurnStatusIndicator/index.js +122 -0
  172. package/dist/components/TurnStatusIndicator/index.js.map +1 -0
  173. package/dist/components/internal/PasswordInput.d.ts +62 -0
  174. package/dist/components/internal/PasswordInput.d.ts.map +1 -0
  175. package/dist/components/internal/PasswordInput.js +42 -0
  176. package/dist/components/internal/PasswordInput.js.map +1 -0
  177. package/dist/context/AIHubContext.d.ts +220 -0
  178. package/dist/context/AIHubContext.d.ts.map +1 -0
  179. package/dist/context/AIHubContext.js +19 -0
  180. package/dist/context/AIHubContext.js.map +1 -0
  181. package/dist/context/AIHubProvider.d.ts +75 -0
  182. package/dist/context/AIHubProvider.d.ts.map +1 -0
  183. package/dist/context/AIHubProvider.js +954 -0
  184. package/dist/context/AIHubProvider.js.map +1 -0
  185. package/dist/context/index.d.ts +9 -0
  186. package/dist/context/index.d.ts.map +1 -0
  187. package/dist/context/index.js +9 -0
  188. package/dist/context/index.js.map +1 -0
  189. package/dist/context/theme.d.ts +43 -0
  190. package/dist/context/theme.d.ts.map +1 -0
  191. package/dist/context/theme.js +70 -0
  192. package/dist/context/theme.js.map +1 -0
  193. package/dist/context/useAIHub.d.ts +104 -0
  194. package/dist/context/useAIHub.d.ts.map +1 -0
  195. package/dist/context/useAIHub.js +63 -0
  196. package/dist/context/useAIHub.js.map +1 -0
  197. package/dist/context/useAIHubAuth.d.ts +44 -0
  198. package/dist/context/useAIHubAuth.d.ts.map +1 -0
  199. package/dist/context/useAIHubAuth.js +35 -0
  200. package/dist/context/useAIHubAuth.js.map +1 -0
  201. package/dist/index.d.ts +76 -0
  202. package/dist/index.d.ts.map +1 -0
  203. package/dist/index.js +57 -0
  204. package/dist/index.js.map +1 -0
  205. package/dist/primitives/index.d.ts +99 -0
  206. package/dist/primitives/index.d.ts.map +1 -0
  207. package/dist/primitives/index.js +97 -0
  208. package/dist/primitives/index.js.map +1 -0
  209. package/dist/state/affordances.d.ts +182 -0
  210. package/dist/state/affordances.d.ts.map +1 -0
  211. package/dist/state/affordances.js +189 -0
  212. package/dist/state/affordances.js.map +1 -0
  213. package/dist/state/stateReducer.d.ts +72 -0
  214. package/dist/state/stateReducer.d.ts.map +1 -0
  215. package/dist/state/stateReducer.js +122 -0
  216. package/dist/state/stateReducer.js.map +1 -0
  217. package/dist/stories/EffortControl.stories.d.ts +14 -0
  218. package/dist/stories/EffortControl.stories.d.ts.map +1 -0
  219. package/dist/stories/EffortControl.stories.js +43 -0
  220. package/dist/stories/EffortControl.stories.js.map +1 -0
  221. package/dist/stories/MarkdownRenderer.stories.d.ts +25 -0
  222. package/dist/stories/MarkdownRenderer.stories.d.ts.map +1 -0
  223. package/dist/stories/MarkdownRenderer.stories.js +178 -0
  224. package/dist/stories/MarkdownRenderer.stories.js.map +1 -0
  225. package/dist/stories/MessageBubble.stories.d.ts +21 -0
  226. package/dist/stories/MessageBubble.stories.d.ts.map +1 -0
  227. package/dist/stories/MessageBubble.stories.js +59 -0
  228. package/dist/stories/MessageBubble.stories.js.map +1 -0
  229. package/dist/stories/ReasoningView.stories.d.ts +18 -0
  230. package/dist/stories/ReasoningView.stories.d.ts.map +1 -0
  231. package/dist/stories/ReasoningView.stories.js +62 -0
  232. package/dist/stories/ReasoningView.stories.js.map +1 -0
  233. package/dist/stories/ScrollToPresentButton.stories.d.ts +18 -0
  234. package/dist/stories/ScrollToPresentButton.stories.d.ts.map +1 -0
  235. package/dist/stories/ScrollToPresentButton.stories.js +34 -0
  236. package/dist/stories/ScrollToPresentButton.stories.js.map +1 -0
  237. package/dist/stories/SystemNotice.stories.d.ts +17 -0
  238. package/dist/stories/SystemNotice.stories.d.ts.map +1 -0
  239. package/dist/stories/SystemNotice.stories.js +42 -0
  240. package/dist/stories/SystemNotice.stories.js.map +1 -0
  241. package/dist/stories/ThemeSwitcher.stories.d.ts +15 -0
  242. package/dist/stories/ThemeSwitcher.stories.d.ts.map +1 -0
  243. package/dist/stories/ThemeSwitcher.stories.js +35 -0
  244. package/dist/stories/ThemeSwitcher.stories.js.map +1 -0
  245. package/dist/stories/ToolCallView.stories.d.ts +20 -0
  246. package/dist/stories/ToolCallView.stories.d.ts.map +1 -0
  247. package/dist/stories/ToolCallView.stories.js +65 -0
  248. package/dist/stories/ToolCallView.stories.js.map +1 -0
  249. package/dist/stories/TpmBanner.stories.d.ts +24 -0
  250. package/dist/stories/TpmBanner.stories.d.ts.map +1 -0
  251. package/dist/stories/TpmBanner.stories.js +63 -0
  252. package/dist/stories/TpmBanner.stories.js.map +1 -0
  253. package/dist/stories/TurnStatusIndicator.stories.d.ts +25 -0
  254. package/dist/stories/TurnStatusIndicator.stories.d.ts.map +1 -0
  255. package/dist/stories/TurnStatusIndicator.stories.js +56 -0
  256. package/dist/stories/TurnStatusIndicator.stories.js.map +1 -0
  257. package/dist/stories/_mockProvider.d.ts +44 -0
  258. package/dist/stories/_mockProvider.d.ts.map +1 -0
  259. package/dist/stories/_mockProvider.js +84 -0
  260. package/dist/stories/_mockProvider.js.map +1 -0
  261. package/dist/types.d.ts +787 -0
  262. package/dist/types.d.ts.map +1 -0
  263. package/dist/types.js +19 -0
  264. package/dist/types.js.map +1 -0
  265. package/dist/webcomponent/defineWebComponent.d.ts +106 -0
  266. package/dist/webcomponent/defineWebComponent.d.ts.map +1 -0
  267. package/dist/webcomponent/defineWebComponent.js +126 -0
  268. package/dist/webcomponent/defineWebComponent.js.map +1 -0
  269. package/dist/webcomponent/index.d.ts +7 -0
  270. package/dist/webcomponent/index.d.ts.map +1 -0
  271. package/dist/webcomponent/index.js +7 -0
  272. package/dist/webcomponent/index.js.map +1 -0
  273. package/package.json +63 -0
  274. package/src/__lint-canary__/step1-lint-canary.ts.disabled +28 -0
  275. package/src/auth/passwordPolicy.ts +75 -0
  276. package/src/auth/texts.ts +1294 -0
  277. package/src/client/AIHubClient.ts +1718 -0
  278. package/src/client/index.ts +30 -0
  279. package/src/client/sseParser.ts +168 -0
  280. package/src/client/tokenStorage.ts +131 -0
  281. package/src/components/AgentsPicker/index.tsx +147 -0
  282. package/src/components/AuthGate/index.tsx +132 -0
  283. package/src/components/CacheBadge/index.tsx +245 -0
  284. package/src/components/ChangePassword/index.tsx +375 -0
  285. package/src/components/ChatShell/ShellHeader.tsx +80 -0
  286. package/src/components/ChatShell/UserMenu.tsx +196 -0
  287. package/src/components/ChatShell/index.tsx +307 -0
  288. package/src/components/DataClubAIHub/index.tsx +300 -0
  289. package/src/components/DataClubAIHubAdmin/AgentEditorModal.tsx +505 -0
  290. package/src/components/DataClubAIHubAdmin/AgentsPage.tsx +342 -0
  291. package/src/components/DataClubAIHubAdmin/CreateUserModal.tsx +214 -0
  292. package/src/components/DataClubAIHubAdmin/PasswordRevealModal.tsx +204 -0
  293. package/src/components/DataClubAIHubAdmin/ResetPasswordModal.tsx +122 -0
  294. package/src/components/DataClubAIHubAdmin/RotatingMessageEditorModal.tsx +408 -0
  295. package/src/components/DataClubAIHubAdmin/RotatingMessagesPage.tsx +373 -0
  296. package/src/components/DataClubAIHubAdmin/SessionsOverviewPage.tsx +639 -0
  297. package/src/components/DataClubAIHubAdmin/SettingsPage.tsx +979 -0
  298. package/src/components/DataClubAIHubAdmin/UsersPage.tsx +495 -0
  299. package/src/components/DataClubAIHubAdmin/index.tsx +277 -0
  300. package/src/components/DataClubAIHubLogin/index.tsx +282 -0
  301. package/src/components/EffortControl/index.tsx +138 -0
  302. package/src/components/Layout/index.tsx +92 -0
  303. package/src/components/MainColumn/index.tsx +131 -0
  304. package/src/components/MarkdownRenderer/index.tsx +256 -0
  305. package/src/components/MessageInput/index.tsx +283 -0
  306. package/src/components/MessageList/index.tsx +753 -0
  307. package/src/components/ReasoningSelector/index.tsx +268 -0
  308. package/src/components/ReasoningView/index.tsx +183 -0
  309. package/src/components/ScrollToPresentButton/index.tsx +85 -0
  310. package/src/components/SessionsPanel/SessionTitleModal.tsx +256 -0
  311. package/src/components/SessionsPanel/index.tsx +406 -0
  312. package/src/components/SystemNotice/index.tsx +151 -0
  313. package/src/components/ThemeSwitcher/index.tsx +136 -0
  314. package/src/components/ToolCallView/formatContent.ts +50 -0
  315. package/src/components/ToolCallView/index.tsx +274 -0
  316. package/src/components/TpmBanner/index.tsx +172 -0
  317. package/src/components/TurnStatusIndicator/index.tsx +203 -0
  318. package/src/components/internal/PasswordInput.tsx +145 -0
  319. package/src/context/AIHubContext.ts +249 -0
  320. package/src/context/AIHubProvider.tsx +1084 -0
  321. package/src/context/index.ts +9 -0
  322. package/src/context/theme.ts +76 -0
  323. package/src/context/useAIHub.ts +151 -0
  324. package/src/context/useAIHubAuth.ts +65 -0
  325. package/src/index.ts +275 -0
  326. package/src/primitives/index.ts +101 -0
  327. package/src/state/affordances.ts +321 -0
  328. package/src/state/stateReducer.ts +131 -0
  329. package/src/stories/EffortControl.stories.tsx +63 -0
  330. package/src/stories/MarkdownRenderer.stories.tsx +201 -0
  331. package/src/stories/MessageBubble.stories.tsx +101 -0
  332. package/src/stories/ReasoningView.stories.tsx +81 -0
  333. package/src/stories/ScrollToPresentButton.stories.tsx +52 -0
  334. package/src/stories/SystemNotice.stories.tsx +59 -0
  335. package/src/stories/ThemeSwitcher.stories.tsx +55 -0
  336. package/src/stories/ToolCallView.stories.tsx +95 -0
  337. package/src/stories/TpmBanner.stories.tsx +93 -0
  338. package/src/stories/TurnStatusIndicator.stories.tsx +86 -0
  339. package/src/stories/_mockProvider.tsx +116 -0
  340. package/src/styles/CLASSES.md +356 -0
  341. package/src/styles/default.css +2937 -0
  342. package/src/types.ts +867 -0
  343. package/src/webcomponent/defineWebComponent.tsx +193 -0
  344. package/src/webcomponent/index.ts +11 -0
@@ -0,0 +1,787 @@
1
+ /**
2
+ * Shared type definitions for the ai-hub library.
3
+ *
4
+ * Owned by `@data-club/ai-hub` per SPECIFICATIONS.md §7.1; the server package
5
+ * imports from here via the workspace symlink so the wire protocol (§9), the
6
+ * state machine (§10), and the role / user / session shapes (§11, §8) stay in
7
+ * exactly one place.
8
+ *
9
+ * Step 1 only defines the types — there is intentionally no runtime code in
10
+ * this file. Subsequent steps add reducers (Step 7), server handlers (Steps 2+),
11
+ * and React components (Steps 8+) that consume these.
12
+ *
13
+ * @see SPECIFICATIONS.md §7.1 — exports
14
+ * @see SPECIFICATIONS.md §9 — wire protocol
15
+ * @see SPECIFICATIONS.md §10 — state machine
16
+ * @see SPECIFICATIONS.md §11 — data model
17
+ */
18
+ /**
19
+ * The four-role RBAC model. Every JWT carries one of these in its `role` claim;
20
+ * every protected endpoint enforces a minimum-role gate per the §8.2 matrix.
21
+ *
22
+ * Hierarchy (top → bottom = more capabilities):
23
+ *
24
+ * - `super_admin` — DataClub staff. Holds Letta connection settings, signing-key
25
+ * rotation, metrics-token rotation, and the deployment-wide feature toggles.
26
+ * - `admin` — customer leadership. Manages users (incl. password resets) but
27
+ * cannot touch other admins (admin shield rule, §8.1).
28
+ * - `power_user` — elevated employee. CRUD on the ai-hub agents catalog + TPM
29
+ * recovery settings.
30
+ * - `user` — regular end-user. Chat only.
31
+ *
32
+ * @see SPECIFICATIONS.md §8.1 — role model
33
+ * @see SPECIFICATIONS.md §8.2 — permission matrix
34
+ */
35
+ export type AIHubRole = "user" | "power_user" | "admin" | "super_admin";
36
+ /**
37
+ * Per-user identity payload returned by `/auth/me` and `/auth/login`. Pure
38
+ * per-user state — no deployment-wide context lives on this shape (those
39
+ * fields are on `AIHubDeployment`).
40
+ *
41
+ * Does NOT include `password_hash`, `is_initial_password`, or any other
42
+ * internal column from the §11 `user` schema — those stay server-side.
43
+ *
44
+ * @see SPECIFICATIONS.md §6.3.4 — `GET /auth/me`
45
+ * @see SPECIFICATIONS.md §11 — `user` table
46
+ */
47
+ export interface AIHubUser {
48
+ /** Stable UUID assigned at row creation. */
49
+ id: string;
50
+ /** Login identifier (unique per deployment). */
51
+ username: string;
52
+ /** Optional human-readable name shown in admin lists. NULL when unset. */
53
+ display_name: string | null;
54
+ /** Effective role used for access control; drives the §8.2 matrix. */
55
+ role: AIHubRole;
56
+ /**
57
+ * The user's stored theme preference (`"light"` or `"dark"`). NULL when the
58
+ * user has not picked one explicitly — the client falls through to
59
+ * `deployment.theme_default` (subject to `deployment.theme_switcher_enabled`).
60
+ *
61
+ * @see SPECIFICATIONS.md §7.6 — theme resolution
62
+ */
63
+ theme_preference: "light" | "dark" | null;
64
+ }
65
+ /**
66
+ * Per-deployment context returned alongside `AIHubUser` from `/auth/me` and
67
+ * `/auth/login`. These fields are properties of the deployment as a whole
68
+ * (sourced from `admin_setting`), not of the individual user — they're
69
+ * bundled into the auth response for a single round-trip on shell render.
70
+ *
71
+ * The resolved theme is **not** included here — the client computes it from
72
+ * `user.theme_preference + deployment.{theme_default, theme_switcher_enabled}`
73
+ * per §7.6 (two lines in the React provider).
74
+ *
75
+ * `letta_ade_url` is included only when the caller's role is `power_user`
76
+ * or higher; for `user`-role callers the field is absent — by design
77
+ * (§6.3.4: the URL is an admin-surface concern).
78
+ *
79
+ * @see SPECIFICATIONS.md §6.3.4 — `GET /auth/me`
80
+ * @see SPECIFICATIONS.md §7.6 — theme resolution
81
+ */
82
+ export interface AIHubDeployment {
83
+ /**
84
+ * Initial theme for new users; the only theme used when the switcher is
85
+ * disabled.
86
+ */
87
+ theme_default: "light" | "dark";
88
+ /**
89
+ * When `false`, the deployment is single-theme — `AIHub.ThemeSwitcher` is
90
+ * hidden and every user sees `theme_default` regardless of any stored
91
+ * `user.theme_preference`.
92
+ */
93
+ theme_switcher_enabled: boolean;
94
+ /**
95
+ * Browser-facing URL of the self-hosted Letta ADE — only present when the
96
+ * caller's role is `power_user` or higher. Absent for `user`-role callers.
97
+ */
98
+ letta_ade_url?: string;
99
+ }
100
+ /**
101
+ * Combined `{ user, deployment }` envelope returned by `/auth/me`,
102
+ * `/auth/me/preferences`, and embedded in `/auth/login`'s response.
103
+ *
104
+ * The split (per Step-3 spec revision) makes the per-user vs. per-deployment
105
+ * boundary explicit on the wire — clients never have to guess whether a
106
+ * field is "about me" or "about my deployment."
107
+ *
108
+ * @see SPECIFICATIONS.md §6.3.4
109
+ */
110
+ export interface AIHubAuthContext {
111
+ /** The authenticated user's identity + stored preferences. */
112
+ user: AIHubUser;
113
+ /** The deployment-wide context the client needs to render the shell. */
114
+ deployment: AIHubDeployment;
115
+ }
116
+ /**
117
+ * Public session shape returned by `/sessions` and `/sessions/{id}`.
118
+ *
119
+ * Does not expose Letta's `conversation_id` to the React client — that's
120
+ * server-internal (§11). The client identifies a session purely by `id`.
121
+ *
122
+ * @see SPECIFICATIONS.md §6.3.1 — sessions
123
+ * @see SPECIFICATIONS.md §11 — `session` table
124
+ */
125
+ export interface Session {
126
+ /** Stable UUID. */
127
+ id: string;
128
+ /** Owner user-id. The server enforces (caller_id === user_id) on read/write. */
129
+ user_id: string;
130
+ /** The ai-hub agent (use-case) this session is scoped to. */
131
+ agent_id: string;
132
+ /** User-supplied title (1..80 chars, required at create-time per §6.3.1). */
133
+ title: string;
134
+ /**
135
+ * Soft-hide flag. Archived sessions are excluded from `GET /sessions` by
136
+ * default; pass `?include_archived=true` to surface them. There is no
137
+ * hard-delete in v1 (§6.3.1).
138
+ */
139
+ is_archived: boolean;
140
+ /** ISO-8601 timestamp. */
141
+ created_at: string;
142
+ /** ISO-8601 timestamp; bumped on rename / archive flip. */
143
+ updated_at: string;
144
+ /**
145
+ * Per-session reasoning state — applied to the agent's `model_settings`
146
+ * before each turn. `null` for a field means "use agent default".
147
+ *
148
+ * The accepted enum values depend on the agent's model: Anthropic uses
149
+ * `low|medium|high|xhigh|max`; OpenAI uses `none|minimal|low|medium|high|xhigh`.
150
+ * The `capabilities` field (present on `GET /sessions/:id` responses)
151
+ * drives which controls the UI should render.
152
+ */
153
+ reasoning?: {
154
+ effort: string | null;
155
+ verbosity: string | null;
156
+ thinking_budget: number | null;
157
+ };
158
+ /**
159
+ * Per-model reasoning capabilities. Present on `GET /sessions/:id`
160
+ * (single-session fetch); omitted on the list endpoint to save a Letta
161
+ * call per row.
162
+ *
163
+ * Mirrors the SDK schema shape — when Letta adds new providers or knobs,
164
+ * we copy the diff and the UI picks it up automatically.
165
+ */
166
+ capabilities?: {
167
+ /** Anthropic-shape effort dropdown. Present for `anthropic/*`, `bedrock/*`. */
168
+ effort?: {
169
+ enum: ReadonlyArray<string>;
170
+ };
171
+ /** OpenAI-shape `reasoning_effort` dropdown. */
172
+ reasoning_effort?: {
173
+ enum: ReadonlyArray<string>;
174
+ };
175
+ /** OpenAI verbosity dropdown — independent of effort. */
176
+ verbosity?: {
177
+ enum: ReadonlyArray<string>;
178
+ };
179
+ /** Google-style numeric thinking budget. */
180
+ thinking_budget?: {
181
+ min: number;
182
+ max: number;
183
+ };
184
+ };
185
+ }
186
+ /**
187
+ * One assembled message as the React client renders it. Distinct from the
188
+ * streaming-event shape (`AIHubEvent`) — events build up to one of these and
189
+ * then `assistant_message_complete` carries the final assembled value.
190
+ *
191
+ * The exact rich-content variants (markdown, tool-call records inline, reasoning
192
+ * blocks) are filled in in Step 5 (server-side translator) and Step 7 (client
193
+ * reducer); Step 1 ships the structural skeleton.
194
+ *
195
+ * @see SPECIFICATIONS.md §9.2 — `assistant_message_complete`
196
+ */
197
+ export interface AIHubMessage {
198
+ /** Stable id assigned by Letta (per-message in a conversation). */
199
+ id: string;
200
+ /** Originator role — drives the bubble variant (§7.3). */
201
+ role: "user" | "assistant" | "system" | "tool";
202
+ /** Plain-text content; rich-content rendering is handled in Step 7. */
203
+ content: string;
204
+ /** ISO-8601 timestamp. */
205
+ created_at: string;
206
+ /**
207
+ * Reasoning block produced by the assistant turn, when present.
208
+ *
209
+ * Set only on `assistant`-role messages whose turn was sent with a
210
+ * non-`none` `effort` and produced a `reasoning_message` row in Letta.
211
+ * The React `<ReasoningView />` primitive renders this inside the
212
+ * assistant bubble (collapsed by default).
213
+ *
214
+ * Concatenation of every `reasoning_message` row that shared the turn's
215
+ * id — Letta sometimes emits multiple reasoning rows per turn.
216
+ *
217
+ * @see SPECIFICATIONS.md §7.4 — reasoning effort
218
+ * @see ui-sketches/03-chat.md — reasoning_block
219
+ */
220
+ reasoning?: string | null;
221
+ /**
222
+ * Tool calls the assistant turn invoked, when any.
223
+ *
224
+ * Set only on `assistant`-role messages whose turn produced at least one
225
+ * `tool_call_message` + matching `tool_return_message` row in Letta. The
226
+ * React `<ToolCallView />` primitive renders one card per entry inside
227
+ * the assistant bubble.
228
+ *
229
+ * @see SPECIFICATIONS.md §9.3 — tool events
230
+ * @see SPECIFICATIONS.md §10.3 — tool error vs. agent error
231
+ * @see ui-sketches/03-chat.md — tool_call_card
232
+ */
233
+ tool_calls?: AIHubToolCallRecord[] | null;
234
+ /**
235
+ * Provider-reported token usage for the turn that produced this
236
+ * message. Set on the LAST assistant message of each turn (the
237
+ * `usage_statistics` event is per-run, not per-message; we stamp it
238
+ * on the visible final bubble). Renders as a small cache-status
239
+ * badge in the chat UI; hover for the full breakdown.
240
+ *
241
+ * @see AIHubMessageUsage
242
+ */
243
+ usage?: AIHubMessageUsage | null;
244
+ }
245
+ /**
246
+ * One tool call invoked during an assistant turn, as carried on
247
+ * `AIHubMessage.tool_calls`. Distinct from the streaming
248
+ * `tool_call_*` events: this is the finalized record persisted with
249
+ * the assistant message.
250
+ */
251
+ export interface AIHubToolCallRecord {
252
+ /** Letta-assigned id; correlates the call to its result. */
253
+ tool_call_id: string;
254
+ /** The tool name (e.g. `"search_web"`). */
255
+ tool_name: string;
256
+ /** Tool input — pretty-printed JSON when parseable. */
257
+ input: string;
258
+ /**
259
+ * Tool output (success path), or `null` if the call errored / hasn't
260
+ * returned. For `error` status, `error` is populated instead.
261
+ */
262
+ output?: string | null;
263
+ /** Error text (error path), or `null` on success. */
264
+ error?: string | null;
265
+ /** Terminal status; mirrors Letta's `tool_return_message.status`. */
266
+ status: "success" | "error";
267
+ }
268
+ /**
269
+ * One row in a session's message-override table. Customizations write
270
+ * these to substitute message content at the wire boundary; each row
271
+ * carries up to two layers (`system_override`, `user_override`) keyed by
272
+ * `ordinal_position` (Letta's rotating message ids are NOT used — they
273
+ * change on every system-prompt recompile).
274
+ *
275
+ * **Layers**:
276
+ *
277
+ * - `system_override` — what the LLM saw / should see at this position.
278
+ * Stored but not consulted at display time today; reserved for future
279
+ * context-replay features and audit/debug tooling.
280
+ * - `user_override` — what the human sees in the chat transcript at
281
+ * this position. Substituted into the wire `content` field on
282
+ * `getSessionMessages`.
283
+ *
284
+ * At least one layer is always non-null. The two writers (the
285
+ * `/chat` post-turn writer and the `setMessageOverride` SDK method)
286
+ * merge into the same row: each only touches the column(s) it cares
287
+ * about, the other layer is preserved.
288
+ *
289
+ * @see `AIHubClient.listMessageOverrides`
290
+ * @see `AIHubClient.setMessageOverride`
291
+ */
292
+ export interface AIHubMessageOverride {
293
+ /**
294
+ * 0-based index into Letta's chronologically-sorted message list for
295
+ * this conversation. Position 0 is typically Letta's compiled
296
+ * `system_message`; subsequent positions interleave user / assistant /
297
+ * tool rows in the order Letta surfaces them.
298
+ */
299
+ ordinal_position: number;
300
+ /**
301
+ * System-view replacement. `null` when no system-layer override was
302
+ * written. Stored but inert at display time.
303
+ */
304
+ system_override: string | null;
305
+ /**
306
+ * User-view replacement. `null` when no user-layer override was
307
+ * written. Substituted into the wire `content` field on
308
+ * `getSessionMessages` when non-null.
309
+ */
310
+ user_override: string | null;
311
+ /** ISO-8601 timestamp the override was first written. */
312
+ created_at: string;
313
+ /** ISO-8601 timestamp of the last update. */
314
+ updated_at: string;
315
+ }
316
+ /**
317
+ * Top-level turn status. Orthogonal to `RunningPhase` — `phase` is only
318
+ * meaningful when `status === "running"`. Terminal states (`done`, `cancelled`,
319
+ * `failed`) end the turn but never the session — every session can always
320
+ * accept a new turn.
321
+ *
322
+ * @see SPECIFICATIONS.md §10.1 — status × phase
323
+ */
324
+ export type TurnStatus = "idle" | "running" | "done" | "cancelled" | "failed";
325
+ /**
326
+ * The sub-state of a running turn. Drives the §10.4 affordance predicate table
327
+ * (which buttons / banners / spinners / cards render) and the
328
+ * `TurnStatusIndicator` label table.
329
+ *
330
+ * @see SPECIFICATIONS.md §10.1 — phase enumeration
331
+ * @see SPECIFICATIONS.md §10.4 — affordances bound to (status, phase)
332
+ */
333
+ export type RunningPhase = "model_text" | "model_reasoning" | "model_tool_input" | "tool_executing" | "waiting_provider" | "awaiting_user";
334
+ /**
335
+ * The reducer-level state derived from the SSE event stream.
336
+ *
337
+ * The ai-hub server is authoritative; `AIHubState` is the React client's
338
+ * derivation, rebuilt on reconnect by replaying the persisted event log. The
339
+ * reducer (~100 LOC, lands in Step 7) takes `AIHubState` + `AIHubEvent` and
340
+ * returns the next `AIHubState`.
341
+ *
342
+ * @see SPECIFICATIONS.md §7.5 — state on the client
343
+ * @see SPECIFICATIONS.md §10 — state machine
344
+ */
345
+ export interface AIHubState {
346
+ /** Top-level turn status. */
347
+ status: TurnStatus;
348
+ /** Sub-phase; only meaningful when `status === "running"`. */
349
+ phase: RunningPhase | null;
350
+ /**
351
+ * Highest event `seq` consumed so far for the active turn — used as the
352
+ * `from_seq` cursor on resumption (§9, §6.3.2).
353
+ */
354
+ last_seq: number;
355
+ /** The active turn's id, or null when idle / between turns. */
356
+ turn_id: string | null;
357
+ /** The currently-open session's id, or null when no session is selected. */
358
+ session_id: string | null;
359
+ /**
360
+ * The countdown deadline (ISO-8601) attached to the latest
361
+ * `system_notice {code: "tpm_wait"}`. The TPM banner reads this for its
362
+ * countdown timer. Null when not in TPM recovery.
363
+ *
364
+ * @see SPECIFICATIONS.md §6.5 — TPM recovery
365
+ */
366
+ tpm_retry_at: string | null;
367
+ }
368
+ /**
369
+ * Snapshot of `(status, phase)` carried by every SSE event so the client can
370
+ * branch on a single field without having to track the reducer's intermediate
371
+ * state. The server emits this snapshot at the moment of emission (§9).
372
+ */
373
+ export interface AIHubEventState {
374
+ /** Status at the moment the event was emitted. */
375
+ status: TurnStatus;
376
+ /** Phase at the moment of emission. Null when status is not `running`. */
377
+ phase: RunningPhase | null;
378
+ }
379
+ /**
380
+ * Common envelope shared by every SSE event the server emits. Concrete events
381
+ * extend this with `event` (the discriminator) + `data` (the payload).
382
+ *
383
+ * @see SPECIFICATIONS.md §9 — wire protocol
384
+ */
385
+ interface AIHubEventBase {
386
+ /** Monotonic per-turn sequence, starting at 0 — used for resumption. */
387
+ seq: number;
388
+ /** `(status, phase)` snapshot at emission time. */
389
+ state: AIHubEventState;
390
+ }
391
+ /**
392
+ * Lifecycle: emitted once at the start of every turn. Carries the
393
+ * `protocol_version` so future wire-protocol bumps surface as a discriminator
394
+ * rather than silent shape drift.
395
+ *
396
+ * @see SPECIFICATIONS.md §9.1
397
+ */
398
+ export interface AIHubLifecycleStreamStartEvent extends AIHubEventBase {
399
+ event: "stream_start";
400
+ data: {
401
+ /** Wire-protocol version, bumped independently of package versions. */
402
+ protocol_version: string;
403
+ /** The session this turn belongs to. */
404
+ session_id: string;
405
+ /** This turn's id — used as the cursor on `/chat/{turn_id}/events`. */
406
+ turn_id: string;
407
+ };
408
+ }
409
+ /**
410
+ * Lifecycle: emitted once at the end of every turn. The `reason` discriminates
411
+ * between a healthy completion, a user-driven cancel, and an unrecoverable
412
+ * error.
413
+ *
414
+ * @see SPECIFICATIONS.md §9.1
415
+ */
416
+ export interface AIHubLifecycleStreamEndEvent extends AIHubEventBase {
417
+ event: "stream_end";
418
+ data: {
419
+ /** Why the stream ended. Drives the terminal `TurnStatus`. */
420
+ reason: "done" | "cancelled" | "error";
421
+ };
422
+ }
423
+ /**
424
+ * Lifecycle: keep-alive while the turn is idle. No payload — exists purely so
425
+ * intermediary proxies don't time the connection out (§9.5).
426
+ *
427
+ * @see SPECIFICATIONS.md §9.1
428
+ */
429
+ export interface AIHubLifecycleHeartbeatEvent extends AIHubEventBase {
430
+ event: "heartbeat";
431
+ }
432
+ /**
433
+ * Content: streaming assistant text. The reducer concatenates `delta`s into
434
+ * the active assistant bubble.
435
+ *
436
+ * @see SPECIFICATIONS.md §9.2
437
+ */
438
+ export interface AIHubContentAssistantDeltaEvent extends AIHubEventBase {
439
+ event: "assistant_delta";
440
+ data: {
441
+ /** Next chunk of assistant text. */
442
+ delta: string;
443
+ };
444
+ }
445
+ /**
446
+ * Content: streaming reasoning text. Only emitted on turns the user sent with
447
+ * a non-`none` effort — `none` means no reasoning at all (§7.4).
448
+ *
449
+ * @see SPECIFICATIONS.md §9.2
450
+ */
451
+ export interface AIHubContentReasoningDeltaEvent extends AIHubEventBase {
452
+ event: "reasoning_delta";
453
+ data: {
454
+ /** Next chunk of reasoning text. */
455
+ delta: string;
456
+ };
457
+ }
458
+ /**
459
+ * Content: the fully assembled assistant turn, emitted once near `stream_end`.
460
+ * The React reducer uses this to replace the running bubble with the canonical
461
+ * message shape returned by the API.
462
+ *
463
+ * @see SPECIFICATIONS.md §9.2
464
+ */
465
+ export interface AIHubContentAssistantMessageCompleteEvent extends AIHubEventBase {
466
+ event: "assistant_message_complete";
467
+ data: {
468
+ /** The fully assembled message as it should be persisted in history. */
469
+ message: AIHubMessage;
470
+ };
471
+ }
472
+ /**
473
+ * Tool: the model started emitting a tool call's input. Phase →
474
+ * `model_tool_input`; the UI's tool-call card opens with the input streaming
475
+ * in.
476
+ *
477
+ * @see SPECIFICATIONS.md §9.3
478
+ */
479
+ export interface AIHubToolCallStartedEvent extends AIHubEventBase {
480
+ event: "tool_call_started";
481
+ data: {
482
+ /** Stable id used to correlate every event for this call. */
483
+ tool_call_id: string;
484
+ /** Letta-side tool name. */
485
+ tool_name: string;
486
+ };
487
+ }
488
+ /**
489
+ * Tool: the model is streaming the call's input character-by-character.
490
+ *
491
+ * @see SPECIFICATIONS.md §9.3
492
+ */
493
+ export interface AIHubToolCallInputDeltaEvent extends AIHubEventBase {
494
+ event: "tool_call_input_delta";
495
+ data: {
496
+ /** Correlates back to the originating `tool_call_started`. */
497
+ tool_call_id: string;
498
+ /** Next chunk of the call's JSON input. */
499
+ partial_json: string;
500
+ };
501
+ }
502
+ /**
503
+ * Tool: the model finished emitting input; Letta is dispatching the tool now.
504
+ * Phase → `tool_executing`.
505
+ *
506
+ * @see SPECIFICATIONS.md §9.3
507
+ */
508
+ export interface AIHubToolCallDispatchedEvent extends AIHubEventBase {
509
+ event: "tool_call_dispatched";
510
+ data: {
511
+ /** Correlates back to the originating `tool_call_started`. */
512
+ tool_call_id: string;
513
+ /** The fully assembled JSON input the tool was called with. */
514
+ input: unknown;
515
+ };
516
+ }
517
+ /**
518
+ * Tool: optional progress event for long-running tools.
519
+ *
520
+ * @see SPECIFICATIONS.md §9.3
521
+ */
522
+ export interface AIHubToolCallProgressEvent extends AIHubEventBase {
523
+ event: "tool_call_progress";
524
+ data: {
525
+ /** Correlates back to the originating `tool_call_started`. */
526
+ tool_call_id: string;
527
+ /** Implementation-defined progress chunk (string or structured payload). */
528
+ chunk: unknown;
529
+ };
530
+ }
531
+ /**
532
+ * Tool: the call resolved.
533
+ *
534
+ * Tool errors are NOT turn errors — phase reverts to `model_text` and the
535
+ * model decides what to do next (retry, apologize, change approach). Only an
536
+ * `error` event flips the turn to `failed` (§10.3).
537
+ *
538
+ * @see SPECIFICATIONS.md §9.3
539
+ * @see SPECIFICATIONS.md §10.3 — tool error vs. agent error
540
+ */
541
+ export interface AIHubToolCallResultEvent extends AIHubEventBase {
542
+ event: "tool_call_result";
543
+ data: {
544
+ /** Correlates back to the originating `tool_call_started`. */
545
+ tool_call_id: string;
546
+ /** Either an output (success) or an error (tool-side failure). */
547
+ output?: unknown;
548
+ error?: {
549
+ /** Short machine-readable code for the tool's error. */
550
+ code: string;
551
+ /** Human-readable description. */
552
+ message: string;
553
+ };
554
+ };
555
+ }
556
+ /**
557
+ * System: TPM-recovery status notice. Codes:
558
+ *
559
+ * - `tpm_wait` — provider rate-limited; the server is waiting for `retry_at`.
560
+ * - `resumed` — recovery succeeded; streaming continues.
561
+ * - (extensible — additional codes may be added in future minor versions)
562
+ *
563
+ * @see SPECIFICATIONS.md §6.5 — TPM recovery
564
+ * @see SPECIFICATIONS.md §9.4
565
+ */
566
+ export interface AIHubSystemNoticeEvent extends AIHubEventBase {
567
+ event: "system_notice";
568
+ data: {
569
+ /** Discriminator for the notice variant. */
570
+ code: "tpm_wait" | "resumed" | (string & {});
571
+ /** Human-readable message; safe to surface to end-users. */
572
+ message: string;
573
+ /** Only set on `tpm_wait` — ISO-8601 deadline for the countdown. */
574
+ retry_at?: string;
575
+ };
576
+ }
577
+ /**
578
+ * System: per-turn token-usage counters propagated from Letta. Stamped
579
+ * on the LAST assistant message of the turn — the React reducer uses
580
+ * `letta_message_id` to attach the badge to the right bubble. Also
581
+ * persisted server-side so a refresh keeps the badge.
582
+ *
583
+ * @see SPECIFICATIONS.md §9.4
584
+ * @see docs/server/chat-sse.md
585
+ */
586
+ export interface AIHubSystemUsageEvent extends AIHubEventBase {
587
+ event: "usage";
588
+ data: {
589
+ /**
590
+ * Letta message id this usage attaches to (the turn's last assistant
591
+ * message). The reducer joins this against the chat history to put
592
+ * the cache badge on the right bubble. Optional for forward
593
+ * compatibility with future per-message usage events.
594
+ */
595
+ letta_message_id?: string;
596
+ /** Non-cached input-token count (prompt_tokens). */
597
+ input?: number;
598
+ /** Output-token count (completion_tokens). */
599
+ output?: number;
600
+ /** Cache-read-token count — Anthropic / OpenAI / Gemini all report. */
601
+ cache_read?: number;
602
+ /** Cache-write-token count — Anthropic only; null elsewhere. */
603
+ cache_write?: number;
604
+ /** Reasoning / thinking tokens for models that produce them. */
605
+ reasoning?: number;
606
+ /** Letta's rolling context-window-size estimate post-turn. */
607
+ context?: number;
608
+ /** Sum reported by provider (may differ from input+output when reasoning is counted separately). */
609
+ total?: number;
610
+ };
611
+ }
612
+ /**
613
+ * Per-assistant-message cache + token usage, attached to the
614
+ * historical chat record. Returned from `GET /sessions/{id}/messages`
615
+ * via `AIHubMessage.usage`. Same shape as the live wire event's
616
+ * `data` minus the `letta_message_id` (which is already the message
617
+ * itself).
618
+ *
619
+ * @see AIHubSystemUsageEvent
620
+ */
621
+ export interface AIHubMessageUsage {
622
+ input?: number | null;
623
+ output?: number | null;
624
+ cache_read?: number | null;
625
+ cache_write?: number | null;
626
+ reasoning?: number | null;
627
+ context?: number | null;
628
+ total?: number | null;
629
+ }
630
+ /**
631
+ * System: non-recoverable error. Followed by `stream_end {reason: "error"}`.
632
+ * The turn transitions to `failed`; the session remains usable.
633
+ *
634
+ * @see SPECIFICATIONS.md §9.4
635
+ * @see SPECIFICATIONS.md §10.3
636
+ */
637
+ export interface AIHubSystemErrorEvent extends AIHubEventBase {
638
+ event: "error";
639
+ data: {
640
+ /** Machine-readable error code for client branching. */
641
+ code: "tpm_exhausted" | "provider_error" | "internal" | "stream_idle" | (string & {});
642
+ /** Human-readable description. */
643
+ message: string;
644
+ /** Pino `request_id` for log correlation. */
645
+ request_id: string;
646
+ };
647
+ }
648
+ /**
649
+ * Discriminated union of every SSE event the ai-hub server emits.
650
+ *
651
+ * Branch on `event` to narrow to a concrete payload. The reducer (Step 7) is
652
+ * the canonical consumer; the server's `eventTranslator.ts` (Step 5) is the
653
+ * canonical producer.
654
+ *
655
+ * @see SPECIFICATIONS.md §9 — full wire protocol
656
+ */
657
+ export type AIHubEvent = AIHubLifecycleStreamStartEvent | AIHubLifecycleStreamEndEvent | AIHubLifecycleHeartbeatEvent | AIHubContentAssistantDeltaEvent | AIHubContentReasoningDeltaEvent | AIHubContentAssistantMessageCompleteEvent | AIHubToolCallStartedEvent | AIHubToolCallInputDeltaEvent | AIHubToolCallDispatchedEvent | AIHubToolCallProgressEvent | AIHubToolCallResultEvent | AIHubSystemNoticeEvent | AIHubSystemUsageEvent | AIHubSystemErrorEvent;
658
+ /**
659
+ * The deployment-wide UI feature toggles set by `super_admin` (§8.4), served
660
+ * by the public `GET /feature-toggles` endpoint and consumed by the React
661
+ * provider on mount.
662
+ *
663
+ * Every key is **optional** — a missing key means "fall back to the React
664
+ * prop's value (which itself falls back to the built-in default)". The
665
+ * server stores a flat JSON blob keyed by these names; only the keys the
666
+ * super_admin explicitly set are present on the wire.
667
+ *
668
+ * Precedence at render time (highest → lowest): server toggle > React prop >
669
+ * built-in default. The provider applies precedence client-side via
670
+ * `useAffordanceFlags()` (Step 10).
671
+ *
672
+ * Adding a new toggle requires updating:
673
+ *
674
+ * 1. This interface (the wire type).
675
+ * 2. `packages/ai-hub-server/src/routes/admin/settings.ts` (`featureTogglesSchema`).
676
+ * 3. `packages/ai-hub/src/state/affordances.ts` (`useAffordanceFlags`).
677
+ *
678
+ * @see SPECIFICATIONS.md §8.4 — feature toggles
679
+ * @see ui-sketches/08-admin-settings.md — feature_toggles_section
680
+ */
681
+ export interface AIHubFeatureToggles {
682
+ /** Overrides `sessions` prop on `<DataClubAIHub />`. */
683
+ sessions_panel_enabled?: boolean;
684
+ /** Overrides `sessionsPanelResizable` prop. */
685
+ sessions_panel_resizable?: boolean;
686
+ /** Overrides `sessionsPanelCollapsible` prop. */
687
+ sessions_panel_collapsible?: boolean;
688
+ /** Overrides `showCreateSessionButton` prop. */
689
+ create_session_button_enabled?: boolean;
690
+ /** Overrides `userInput` prop. */
691
+ user_input_enabled?: boolean;
692
+ /** Overrides `showStopButton` prop. */
693
+ stop_button_enabled?: boolean;
694
+ /** Overrides `showToolCalls` prop. */
695
+ tool_calls_visible?: boolean;
696
+ /** Overrides `showReasoning` prop. */
697
+ reasoning_visible?: boolean;
698
+ /** Overrides `showSystemMessages` prop. */
699
+ system_messages_visible?: boolean;
700
+ /** Overrides `showTpmNotice` prop. */
701
+ tpm_notice_visible?: boolean;
702
+ /** Overrides `showEffortControl` prop. */
703
+ effort_control_visible?: boolean;
704
+ /** Overrides `showScrollToPresentButton` prop. */
705
+ scroll_to_present_visible?: boolean;
706
+ /** Overrides `showTurnStatus` prop. */
707
+ turn_status_visible?: boolean;
708
+ }
709
+ /**
710
+ * Top-level error shape the React client hands to user-supplied `onError`
711
+ * callbacks. Distinct from the in-stream `AIHubSystemErrorEvent`: this is the
712
+ * library's outward error surface, used for both transport-level failures
713
+ * (network, 401, 5xx) and surfaced stream errors.
714
+ *
715
+ * @see SPECIFICATIONS.md §7.2 — provider props
716
+ */
717
+ export interface AIHubError {
718
+ /** Machine-readable code; clients use this for branching, not `message`. */
719
+ code: "unauthorized" | "forbidden" | "not_found" | "validation" | "network" | "tpm_exhausted" | "provider_error" | "internal" | (string & {});
720
+ /** Human-readable message; safe to render to end-users. */
721
+ message: string;
722
+ /** HTTP status, when the error originated from a server response. */
723
+ status?: number;
724
+ /** Pino `request_id` for log correlation when available. */
725
+ request_id?: string;
726
+ }
727
+ /**
728
+ * Renderer for the action bar of every message bubble. Tier 2 wrappers pass
729
+ * one of these via `customMessageActions` on `<DataClubAIHub />`; Tier 3
730
+ * wrappers pass the same shape via `renderMessageActions` on
731
+ * `<AIHub.MessageList />`.
732
+ *
733
+ * Returning `null` (or an empty fragment) disables the action bar for that
734
+ * message.
735
+ *
736
+ * @see SPECIFICATIONS.md §7.3 — `<DataClubAIHub />` props
737
+ * @see SPECIFICATIONS.md §7.9 — primitive composition
738
+ */
739
+ export type AIHubMessageActionRenderer = (msg: AIHubMessage) => unknown;
740
+ /**
741
+ * Renderer that replaces the entire message bubble. Advanced — most wrappers
742
+ * should use `AIHubMessageActionRenderer` instead. Tier 2: `customMessageBubble`;
743
+ * Tier 3: `renderMessageBubble` on `<AIHub.MessageList />`.
744
+ *
745
+ * @see SPECIFICATIONS.md §7.3
746
+ * @see SPECIFICATIONS.md §7.9
747
+ */
748
+ export type AIHubMessageBubbleRenderer = (msg: AIHubMessage) => unknown;
749
+ /**
750
+ * Aggregated slot-prop bag — convenience type for wrappers that pass a single
751
+ * options object instead of individual props. The fields mirror the slot props
752
+ * on `<DataClubAIHub />` (§7.3).
753
+ *
754
+ * `unknown` (rather than React.ReactNode) is used here so this types module
755
+ * stays React-version-agnostic; the React package re-exports a stricter
756
+ * variant from `index.ts` once React is in scope.
757
+ *
758
+ * @see SPECIFICATIONS.md §7.3 — slot props
759
+ */
760
+ export interface AIHubSlotProps {
761
+ /**
762
+ * Replaces the default gradient text logo in the shell header. Per-customer
763
+ * wrappers populate this with their logo + brand name + nav links.
764
+ */
765
+ customShellHeaderLeft?: unknown;
766
+ /**
767
+ * Renders a footer strip below `main_area`. Unset (default) → no footer.
768
+ */
769
+ customShellFooter?: unknown;
770
+ /**
771
+ * Rendered next to the agent name + turn-status indicator inside the chat
772
+ * column header (distinct from the shell header above).
773
+ */
774
+ customHeaderContent?: unknown;
775
+ /** Per-message action bar slot (e.g. thumbs-up / thumbs-down). */
776
+ customMessageActions?: AIHubMessageActionRenderer;
777
+ /** Override the entire message bubble — advanced. */
778
+ customMessageBubble?: AIHubMessageBubbleRenderer;
779
+ /** Extra items in the input toolbar (next to the effort dropdown). */
780
+ customInputToolbarItems?: unknown;
781
+ /** Top-of-sessions-panel slot. */
782
+ customSidebarHeader?: unknown;
783
+ /** Bottom-of-sessions-panel slot. */
784
+ customSidebarFooter?: unknown;
785
+ }
786
+ export {};
787
+ //# sourceMappingURL=types.d.ts.map