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