@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,1058 @@
1
+ /**
2
+ * `AIHubClient` — the typed TypeScript SDK for `@data-club/ai-hub-server`.
3
+ *
4
+ * Used internally by `<AIHubProvider>` to power every component in the
5
+ * library; also exported for apps that build entirely custom UIs without
6
+ * the React layer (§7.8).
7
+ *
8
+ * Design notes:
9
+ *
10
+ * - **Wire is snake_case; SDK arguments are camelCase.** The translation is
11
+ * per-method and explicit so the reader can see exactly which fields cross
12
+ * the boundary. The only header-level camelCase translation is on
13
+ * `login()`'s response: `must_change_password` → `mustChangePassword`
14
+ * (per §6.3.4). `user.*` and `deployment.*` keep their snake_case keys —
15
+ * they're echoed through to React state and the BEM CSS contract is
16
+ * already snake_case-aware.
17
+ * - **SSE uses `fetch` + `ReadableStream`, not `EventSource`** (§9.5 — the
18
+ * browser API can't carry custom auth headers).
19
+ * - **No silent refresh** (§6.7). A 401 on any protected request fires the
20
+ * `onUnauthorized` callback exactly once; the provider then routes the
21
+ * user back to `<DataClubAIHubLogin />`.
22
+ * - **Empty-title rejection on `createSession`** is enforced client-side
23
+ * before the request goes out so we don't burn an HTTP round-trip on a
24
+ * case the server will 400 anyway.
25
+ *
26
+ * @see SPECIFICATIONS.md §7.8 — client SDK
27
+ * @see SPECIFICATIONS.md §6.3 — API surface
28
+ * @see SPECIFICATIONS.md §6.7 — auth model
29
+ */
30
+ import type { AIHubAuthContext, AIHubDeployment, AIHubError, AIHubEvent, AIHubFeatureToggles, AIHubMessage, AIHubMessageOverride, AIHubRole, AIHubUser, Session } from "../types.js";
31
+ import { type TokenStorage, type TokenStorageMode } from "./tokenStorage.js";
32
+ /**
33
+ * Constructor options for `AIHubClient`.
34
+ */
35
+ export interface AIHubClientOptions {
36
+ /**
37
+ * Base URL the server is mounted at — typically `/api/ai-hub` in a
38
+ * per-customer wrapper (§5). No trailing slash; the client appends paths.
39
+ */
40
+ baseUrl: string;
41
+ /**
42
+ * Custom `fetch`. Defaults to `globalThis.fetch`. Override for tests or
43
+ * for non-DOM environments (Workers, Bun, etc.).
44
+ */
45
+ fetch?: typeof fetch;
46
+ /**
47
+ * How to persist the JWT. Either one of the three built-in modes or a
48
+ * custom adapter. Defaults to `"localStorage"`.
49
+ */
50
+ tokenStorage?: TokenStorageMode | TokenStorage;
51
+ /**
52
+ * Fired when the server returns 401 on a protected request — the provider
53
+ * uses this to route back to login (§6.7 — no silent refresh in v1).
54
+ * The token is cleared before the callback fires.
55
+ */
56
+ onUnauthorized?: () => void;
57
+ }
58
+ /**
59
+ * Response shape returned by `login()`. The `deployment` block is omitted
60
+ * when `mustChangePassword === true` (the change-only token grants no
61
+ * deployment access — §6.3.4).
62
+ */
63
+ export interface LoginResponse {
64
+ /** The bearer token. Either a 24 h session JWT or a 5 min change-only JWT. */
65
+ token: string;
66
+ /**
67
+ * True when the user must call `changePassword` before any other endpoint
68
+ * will accept the token. Camelcased from the wire's `must_change_password`.
69
+ */
70
+ mustChangePassword: boolean;
71
+ /** The authenticated user (per-user identity). */
72
+ user: AIHubUser;
73
+ /** Per-deployment context. Absent when `mustChangePassword === true`. */
74
+ deployment?: AIHubDeployment;
75
+ }
76
+ /** Filter args for `listSessions`. */
77
+ export interface ListSessionsOptions {
78
+ /** The ai-hub agent the sessions belong to. Required (§6.3.1). */
79
+ agentId: string;
80
+ /** Surface archived rows as well. Defaults to false. */
81
+ includeArchived?: boolean;
82
+ }
83
+ /** Body for `createSession`. */
84
+ export interface CreateSessionOptions {
85
+ /** The ai-hub agent the new session is scoped to. */
86
+ agentId: string;
87
+ /** The user-entered chat title. 1..80 chars; empty is rejected client-side. */
88
+ title: string;
89
+ }
90
+ /** Body for `patchSession`. Either or both fields may be supplied. */
91
+ export interface PatchSessionOptions {
92
+ /** New title (1..80 chars). */
93
+ title?: string;
94
+ /** New archive state. */
95
+ isArchived?: boolean;
96
+ }
97
+ /**
98
+ * Body for `patchSessionReasoning`. Fields are independent — the UI may
99
+ * send just the one the user changed. `null` explicitly clears a field
100
+ * (back to agent default); omitting it keeps the existing value.
101
+ *
102
+ * Enum values depend on the agent's model — server-side validation is
103
+ * intentionally loose so this layer stays schema-driven. The actual
104
+ * rejection (if any) happens when Letta receives the patched `model_settings`
105
+ * before the next turn.
106
+ */
107
+ export interface PatchSessionReasoningOptions {
108
+ /** Anthropic/Bedrock-shape effort OR OpenAI-shape reasoning_effort — handled the same here. */
109
+ effort?: string | null;
110
+ /** OpenAI verbosity. */
111
+ verbosity?: string | null;
112
+ /** Google numeric thinking budget. */
113
+ thinkingBudget?: number | null;
114
+ }
115
+ /** Reasoning-effort enum (§7.4). `none` means no reasoning at all. */
116
+ export type AIHubEffort = "none" | "minimal" | "low" | "medium" | "high" | "extra_high";
117
+ /** Body for `streamChat`. */
118
+ export interface StreamChatBody {
119
+ /** The ai-hub session id the message is being posted to. */
120
+ sessionId: string;
121
+ /** The user's message text. Non-empty per the server's Zod schema. */
122
+ userMessage: string;
123
+ /** Per-message reasoning effort (§7.4). */
124
+ effort?: AIHubEffort;
125
+ /**
126
+ * Allows reconnecting to the same turn from a different connection;
127
+ * see §6.3.2.
128
+ */
129
+ idempotencyKey?: string;
130
+ /**
131
+ * Optional tier-3 customization: the human-facing replacement to show
132
+ * in the chat transcript at the position the new user message lands
133
+ * at. When set, the server sends `userMessage` to Letta verbatim
134
+ * (system view), then — only after the turn terminates `done` —
135
+ * writes an override row whose `user_override` field is this string.
136
+ * Subsequent `getSessionMessages` calls will substitute it in place
137
+ * of the wrapped Letta content.
138
+ *
139
+ * Persisted only on `done`. On `cancelled` / `failed`, Letta drops
140
+ * the user message and we drop the override too (no orphan row).
141
+ */
142
+ userOverride?: string;
143
+ }
144
+ /** Per-call options shared by `streamChat` + `getTurnEvents`. */
145
+ export interface StreamChatOptions {
146
+ /** Aborts the in-flight stream. */
147
+ signal?: AbortSignal;
148
+ /**
149
+ * Resumption cursor for `getTurnEvents`; ignored on `streamChat` in v1
150
+ * but accepted for forward-compat with the §6.3.2 idempotency surface.
151
+ */
152
+ fromSeq?: number;
153
+ }
154
+ /** Per-agent entry returned by `listAgents`. */
155
+ export interface AgentSummary {
156
+ /** Stable id of the ai-hub agent. */
157
+ id: string;
158
+ /** User-visible name shown in the agents picker. */
159
+ display_name: string;
160
+ /**
161
+ * Caller-scoped count of the caller's own non-archived sessions against
162
+ * this agent — populated server-side in one round-trip (§6.3.3).
163
+ */
164
+ session_count: number;
165
+ }
166
+ /** Response shape from `cancelTurn`. */
167
+ export interface CancelTurnResponse {
168
+ /** The cancelled turn's id (echoed). */
169
+ turn_id: string;
170
+ /** Terminal status after cancellation. Usually `"cancelled"`. */
171
+ status: "running" | "done" | "cancelled" | "failed";
172
+ /** True when the turn had already settled before the call landed. */
173
+ was_already_terminal: boolean;
174
+ }
175
+ /**
176
+ * Admin-view shape of a single user row, as returned by `GET /admin/users`,
177
+ * `POST /admin/users`, and `PATCH /admin/users/:id/role`.
178
+ *
179
+ * Excludes `password_hash` and `identity_source` (server-internal — §6.3.4).
180
+ * Note the surface is wider than the user-facing `AIHubUser` — admins need
181
+ * to see `is_initial_password` (to flag rows with the ⚠ indicator) plus the
182
+ * created / updated timestamps.
183
+ *
184
+ * @see SPECIFICATIONS.md §6.3.4 — admin users endpoints
185
+ * @see ui-sketches/05-admin-users.md
186
+ */
187
+ export interface AdminUserView {
188
+ /** Stable UUID. */
189
+ id: string;
190
+ /** Login identifier (unique per deployment). */
191
+ username: string;
192
+ /** Optional human-readable name. `null` when unset. */
193
+ display_name: string | null;
194
+ /** Effective role used for access control. */
195
+ role: AIHubRole;
196
+ /**
197
+ * True until the user completes the change-password flow on first login
198
+ * (or after an admin-initiated password reset). Drives the ⚠ marker in
199
+ * the admin Users table.
200
+ */
201
+ is_initial_password: boolean;
202
+ /** The user's stored theme preference, or `null` when not set. */
203
+ theme_preference: "light" | "dark" | null;
204
+ /** ISO-8601 timestamp. */
205
+ created_at: string;
206
+ /** ISO-8601 timestamp; bumped on role change / password reset. */
207
+ updated_at: string;
208
+ }
209
+ /** Body for `createUser`. */
210
+ export interface CreateUserBody {
211
+ /** Login identifier. Must be unique (server returns 409 on collision). */
212
+ username: string;
213
+ /** Optional human-readable name. */
214
+ displayName?: string | null;
215
+ /**
216
+ * Initial role. Defaults to `"user"` server-side. Admins cannot create
217
+ * `super_admin`s (server enforces).
218
+ */
219
+ role?: AIHubRole;
220
+ }
221
+ /** Response from `createUser` / `resetUserPassword` — plaintext returned once. */
222
+ export interface AdminUserPasswordReveal {
223
+ /**
224
+ * 16-char alphanumeric plaintext password the server just generated.
225
+ * Returned **exactly once** — there is no path to retrieve this value
226
+ * again. The admin UI must surface it in a one-time-reveal modal before
227
+ * the user dismisses it; calling `resetUserPassword` again issues a
228
+ * different value (and invalidates the old).
229
+ */
230
+ generatedPassword: string;
231
+ }
232
+ /** Response from `createUser` — the new user plus its one-time password. */
233
+ export interface CreateUserResponse extends AdminUserPasswordReveal {
234
+ /** The newly-created user row. */
235
+ user: AdminUserView;
236
+ }
237
+ /**
238
+ * Admin-view shape of an ai-hub agent row. Differs from the user-facing
239
+ * `AgentSummary` (returned by `GET /agents`) by carrying the Letta `agent_id`
240
+ * the admin needs to see / edit, the (deprecated-but-still-stored) TPM
241
+ * settings, and the archive flag.
242
+ *
243
+ * @see SPECIFICATIONS.md §6.3.4 — admin agents endpoints
244
+ * @see ui-sketches/06-admin-agents.md
245
+ */
246
+ export interface AdminAgentView {
247
+ /** Stable UUID. */
248
+ id: string;
249
+ /** Display name surfaced to end users in the agents picker. */
250
+ display_name: string;
251
+ /** The assigned Letta agent id. */
252
+ letta_agent_id: string;
253
+ /**
254
+ * TPM-recovery state — kept on the row post-Step-11.5 for forward
255
+ * compatibility but **no longer read by runtime code** (§6.5). The admin
256
+ * Agents page deliberately does not surface a TPM settings modal anymore.
257
+ */
258
+ tpm_recovery_enabled: boolean;
259
+ /** Same — retained for forward compatibility. */
260
+ max_recovery_attempts: number;
261
+ /** Same — retained for forward compatibility. */
262
+ default_retry_after_seconds: number;
263
+ /** Same — retained for forward compatibility. */
264
+ stream_idle_timeout_seconds: number;
265
+ /**
266
+ * Soft-hide flag. Archived agents disappear from `GET /agents` so no new
267
+ * sessions can start against them; existing sessions remain readable +
268
+ * writable (§6.3.4).
269
+ */
270
+ is_archived: boolean;
271
+ /**
272
+ * Step-12.5 — name of the seed folder under `AI_HUB_FILES_DIR/seeds/`.
273
+ * `null` when no sandbox is configured for this agent. See
274
+ * docs/server/session-sandboxes.md.
275
+ */
276
+ sandbox_seed_name: string | null;
277
+ /**
278
+ * Step-12.5 — Letta conversation id (`conv-…`) to fork from at session
279
+ * create. `null` when this agent starts every session brand-new.
280
+ */
281
+ fork_source_conversation_id: string | null;
282
+ /** ISO-8601 timestamp. */
283
+ created_at: string;
284
+ /** ISO-8601 timestamp. */
285
+ updated_at: string;
286
+ }
287
+ /** Body for `createAdminAgent`. */
288
+ export interface CreateAdminAgentBody {
289
+ /** Display name; must be 1..255 chars. */
290
+ displayName: string;
291
+ /**
292
+ * The Letta-side agent id this ai-hub agent will point at. Validated by
293
+ * the server against `client.agents.retrieve(...)`; if Letta doesn't
294
+ * recognize the id, the server returns 400 `letta_agent_not_found`.
295
+ */
296
+ lettaAgentId: string;
297
+ /**
298
+ * Step-12.5 — optional seed folder name. When non-null, each new
299
+ * session for this agent gets a fresh copy of `seeds/<name>/` as its
300
+ * working directory. Validated against `^[a-zA-Z0-9_-]+$` + filesystem
301
+ * existence; misses return 400 `seed_name_invalid` / `seed_dir_not_found`.
302
+ */
303
+ sandboxSeedName?: string | null;
304
+ /**
305
+ * Step-12.5 — optional Letta conversation id to fork from at session
306
+ * create. Validated against Letta + agent-id match; misses return
307
+ * 400 `fork_source_not_found` / `fork_source_agent_mismatch`.
308
+ */
309
+ forkSourceConversationId?: string | null;
310
+ }
311
+ /** Body for `patchAdminAgent`. Each field independently optional. */
312
+ export interface PatchAdminAgentBody {
313
+ /** New display name. */
314
+ displayName?: string;
315
+ /**
316
+ * New assigned Letta agent id. The server validates it before accepting;
317
+ * see {@link CreateAdminAgentBody.lettaAgentId} for the failure mode.
318
+ */
319
+ lettaAgentId?: string;
320
+ /** Archive / unarchive flag. */
321
+ isArchived?: boolean;
322
+ /**
323
+ * Step-12.5 — set / change / clear (with `null`) the sandbox seed name.
324
+ * Same validation as on create.
325
+ */
326
+ sandboxSeedName?: string | null;
327
+ /**
328
+ * Step-12.5 — set / change / clear (with `null`) the fork source. Same
329
+ * validation as on create. May be a raw `conv-…` id or an `rmsg-…`
330
+ * rotating-message reference.
331
+ */
332
+ forkSourceConversationId?: string | null;
333
+ }
334
+ /** Which scheduling shape a rotating message uses. */
335
+ export type RotatingMessageScheduleKind = "every" | "daily" | "cron";
336
+ /**
337
+ * One row from `GET /admin/rotating-messages`. A rotating starting message
338
+ * runs `prompt` against `letta_agent_id` on the configured schedule and stores
339
+ * the agent's reply as `current_conversation_id` — a forkable base conversation
340
+ * referenced elsewhere by its `rmsg-…` `id`.
341
+ *
342
+ * @see docs/server/rotating-messages.md
343
+ */
344
+ export interface AdminRotatingMessageView {
345
+ /** The `rmsg-…` identifier — also the value pasted into an agent's Base conversation field. */
346
+ id: string;
347
+ /** Operator-facing display name. */
348
+ display_name: string;
349
+ /** The prompt sent to the agent each rotation. */
350
+ prompt: string;
351
+ /** Raw Letta agent id the prompt runs against. */
352
+ letta_agent_id: string;
353
+ /** Schedule discriminator. */
354
+ schedule_kind: RotatingMessageScheduleKind;
355
+ /** Interval (seconds) when `schedule_kind === "every"`; else null. */
356
+ interval_seconds: number | null;
357
+ /** `"HH:MM"` (UTC) when `schedule_kind === "daily"`; else null. */
358
+ daily_time: string | null;
359
+ /** 5-field cron expression when `schedule_kind === "cron"`; else null. */
360
+ cron_expression: string | null;
361
+ /** Current prepared conversation id; null until the first successful rotation. */
362
+ current_conversation_id: string | null;
363
+ /** Outcome of the most recent rotation. */
364
+ last_status: "pending" | "ok" | "error";
365
+ /** Error from the last failed rotation; null otherwise. */
366
+ last_error: string | null;
367
+ /** ISO-8601 timestamp of the last successful rotation; null until first success. */
368
+ last_rotated_at: string | null;
369
+ /** ISO-8601 timestamp the scheduler uses to decide when to rotate next. */
370
+ next_rotation_at: string;
371
+ /** Soft-hide flag. */
372
+ is_archived: boolean;
373
+ /** ISO-8601 timestamp. */
374
+ created_at: string;
375
+ /** ISO-8601 timestamp. */
376
+ updated_at: string;
377
+ }
378
+ /** Body for `createAdminRotatingMessage`. */
379
+ export interface CreateAdminRotatingMessageBody {
380
+ displayName: string;
381
+ prompt: string;
382
+ lettaAgentId: string;
383
+ scheduleKind: RotatingMessageScheduleKind;
384
+ /** Required when `scheduleKind === "every"`. */
385
+ intervalSeconds?: number | null;
386
+ /** Required when `scheduleKind === "daily"` (`"HH:MM"`, UTC). */
387
+ dailyTime?: string | null;
388
+ /** Required when `scheduleKind === "cron"` (5-field cron). */
389
+ cronExpression?: string | null;
390
+ }
391
+ /** Body for `patchAdminRotatingMessage`. Each field independently optional. */
392
+ export interface PatchAdminRotatingMessageBody {
393
+ displayName?: string;
394
+ prompt?: string;
395
+ lettaAgentId?: string;
396
+ scheduleKind?: RotatingMessageScheduleKind;
397
+ intervalSeconds?: number | null;
398
+ dailyTime?: string | null;
399
+ cronExpression?: string | null;
400
+ isArchived?: boolean;
401
+ }
402
+ /** Response from `rotateAdminRotatingMessageNow`. */
403
+ export interface RotateNowResponse {
404
+ /** The refreshed row after the inline rotation attempt. */
405
+ rotating_message: AdminRotatingMessageView;
406
+ /** The attempt's outcome. */
407
+ outcome: {
408
+ status: "ok" | "error";
409
+ conversationId?: string;
410
+ error?: string;
411
+ };
412
+ }
413
+ /**
414
+ * One row in `GET /admin/sessions` — the session row joined to its owner
415
+ * username + agent display name so the admin table can render labels without
416
+ * a follow-up round-trip.
417
+ *
418
+ * @see SPECIFICATIONS.md §6.3.4 — admin sessions endpoint
419
+ * @see ui-sketches/07-admin-sessions-overview.md
420
+ */
421
+ export interface AdminSessionView {
422
+ /** Stable session id. */
423
+ id: string;
424
+ /** Owner's user id. */
425
+ user_id: string;
426
+ /** Agent (ai-hub catalog) id. */
427
+ agent_id: string;
428
+ /** Session title. */
429
+ title: string;
430
+ /** Soft-hide flag. */
431
+ is_archived: boolean;
432
+ /**
433
+ * Step-12.5 — `true` when the session has a per-session sandbox folder
434
+ * on disk; the super_admin's `[Purge sandbox]` button is shown only
435
+ * when this is true. The absolute path is deliberately NOT exposed
436
+ * over the wire (server filesystem-layout leak).
437
+ */
438
+ has_sandbox: boolean;
439
+ /** ISO-8601 timestamp. */
440
+ created_at: string;
441
+ /** ISO-8601 timestamp; bumped on rename / archive flip / new turn. */
442
+ updated_at: string;
443
+ /** Owner's username — server-joined. */
444
+ owner_username: string;
445
+ /** Agent's display name — server-joined. */
446
+ agent_display_name: string;
447
+ }
448
+ /** Filter args for `listAdminSessions`. */
449
+ export interface ListAdminSessionsOptions {
450
+ /** Filter by owner. */
451
+ ownerId?: string;
452
+ /** Filter by ai-hub agent. */
453
+ agentId?: string;
454
+ /** Filter by archive state. Defaults to `"active"` per the server. */
455
+ status?: "active" | "archived" | "all";
456
+ /** Case-insensitive substring match against the session title. */
457
+ search?: string;
458
+ /** Opaque pagination cursor returned in the previous page's `nextCursor`. */
459
+ cursor?: string;
460
+ /** Page size; 1..200. Defaults to 50 server-side. */
461
+ limit?: number;
462
+ }
463
+ /**
464
+ * Response shape from `listAdminSessions` — a page of rows plus a cursor for
465
+ * the next page.
466
+ */
467
+ export interface ListAdminSessionsResponse {
468
+ /** The page of sessions. */
469
+ sessions: AdminSessionView[];
470
+ /** Cursor to pass back as `cursor` for the next page; `null` on last page. */
471
+ nextCursor: string | null;
472
+ }
473
+ /**
474
+ * Response shape from `GET /admin/settings` — deployment-wide configuration
475
+ * the super-admin sees on the settings page.
476
+ *
477
+ * Encrypted Letta API key is **never** returned in plaintext through this
478
+ * endpoint. `letta_api_key_set` + `letta_api_key_masked` let the UI display
479
+ * "configured / not configured" without exposing the value.
480
+ *
481
+ * @see SPECIFICATIONS.md §6.3.4 — settings endpoints
482
+ * @see ui-sketches/08-admin-settings.md
483
+ */
484
+ export interface AdminSettingsView {
485
+ /** Letta API base URL (e.g. `http://letta:8283`). `null` until set. */
486
+ letta_base_url: string | null;
487
+ /** Optional override for the "Open Letta ADE" link target. `null` when unset. */
488
+ letta_ade_url: string | null;
489
+ /** Masked placeholder (`••••••••`) when a key is stored in the DB; `null` otherwise. */
490
+ letta_api_key_masked: string | null;
491
+ /**
492
+ * True when the runtime has a usable API key from EITHER source — DB or
493
+ * env. The admin UI uses this to decide whether to render "configured"
494
+ * vs. "missing." Pair with `letta_api_key_source` for source-aware copy.
495
+ */
496
+ letta_api_key_set: boolean;
497
+ /**
498
+ * Which source the runtime is *currently* using for the Letta API key —
499
+ * `"db"` when a super-admin set it via the admin panel (DB wins over
500
+ * env per spec), `"env"` when the DB column is empty and the server's
501
+ * `LETTA_API_KEY` env var is set, `"none"` when no usable value exists
502
+ * anywhere (chat path will throw). Lets the UI label the field
503
+ * "(from env)" / "(from admin panel)" so operators aren't confused
504
+ * about why their `.env` change didn't appear to take effect (or did).
505
+ */
506
+ letta_api_key_source: "db" | "env" | "none";
507
+ /** Theme settings, stored as separate columns server-side. */
508
+ theme: {
509
+ default: "light" | "dark";
510
+ switcher_enabled: boolean;
511
+ };
512
+ /** The flat §8.4 feature-toggles blob. */
513
+ feature_toggles: AIHubFeatureToggles;
514
+ /** ISO-8601 of the last signing-key rotation. `null` until first rotation. */
515
+ signing_key_rotated_at: string | null;
516
+ /** ISO-8601 of the last metrics-token rotation. `null` until first rotation. */
517
+ metrics_scrape_token_rotated_at: string | null;
518
+ /** ISO-8601 of the last settings update. */
519
+ updated_at: string;
520
+ }
521
+ /** Body for `patchAdminSettings`. Each field independently optional. */
522
+ export interface PatchAdminSettingsBody {
523
+ /** Letta base URL. Pass `null` to clear (the schema accepts null + URL). */
524
+ lettaBaseUrl?: string | null;
525
+ /** Letta ADE URL. Pass `null` to clear. */
526
+ lettaAdeUrl?: string | null;
527
+ /** New Letta API key (plaintext over HTTPS; encrypted server-side at rest). */
528
+ lettaApiKey?: string;
529
+ /** Theme partial — either or both fields. */
530
+ theme?: {
531
+ default?: "light" | "dark";
532
+ switcherEnabled?: boolean;
533
+ };
534
+ }
535
+ /** Response from `rotateAdminMetricsToken` — the new token returned **once**. */
536
+ export interface AdminMetricsTokenRotateResponse {
537
+ /** The freshly-generated 32-byte hex token. Shown to the admin exactly once. */
538
+ token: string;
539
+ }
540
+ /**
541
+ * Thrown for any HTTP-level failure (non-2xx, network drop, etc.). The
542
+ * `code` discriminates by §7.2's `AIHubError` codes; the message is safe
543
+ * to render to end-users (it's either the server's `error.message` or a
544
+ * fixed transport-level string).
545
+ */
546
+ export declare class AIHubRequestError extends Error implements AIHubError {
547
+ /** Machine-readable code; clients branch on this rather than the message. */
548
+ readonly name = "AIHubRequestError";
549
+ /** Discriminator matching `AIHubError.code`. */
550
+ readonly code: AIHubError["code"];
551
+ /** HTTP status when one was available. */
552
+ readonly status?: number;
553
+ /** Pino `request_id` from the server for log correlation. */
554
+ readonly request_id?: string;
555
+ /**
556
+ * @param code - the error discriminator.
557
+ * @param message - the human-readable message.
558
+ * @param status - HTTP status, when available.
559
+ * @param requestId - request id, when available.
560
+ */
561
+ constructor(code: AIHubError["code"], message: string, status?: number, requestId?: string);
562
+ }
563
+ /**
564
+ * The typed SDK every React surface in the library is built on.
565
+ *
566
+ * The client owns the JWT lifecycle (storage + clearing on 401) and the
567
+ * SSE plumbing; everything else is a thin HTTP wrapper that translates
568
+ * camelCase arguments into the server's snake_case wire format.
569
+ *
570
+ * @example
571
+ * ```ts
572
+ * const client = new AIHubClient({ baseUrl: "/api/ai-hub" });
573
+ * const { token, mustChangePassword, user } = await client.login("alice", "secret");
574
+ * if (!mustChangePassword) {
575
+ * for await (const event of client.streamChat({
576
+ * sessionId: session.id,
577
+ * userMessage: "Hello.",
578
+ * })) {
579
+ * console.log(event);
580
+ * }
581
+ * }
582
+ * ```
583
+ */
584
+ export declare class AIHubClient {
585
+ private readonly baseUrl;
586
+ private readonly fetchImpl;
587
+ private readonly tokenStore;
588
+ private readonly onUnauthorized?;
589
+ /** Guards against firing `onUnauthorized` more than once per 401 storm. */
590
+ private unauthorizedFired;
591
+ /**
592
+ * @param options - constructor options. `baseUrl` is required; everything
593
+ * else has a sensible default.
594
+ */
595
+ constructor(options: AIHubClientOptions);
596
+ /** Returns the currently-stored token, or null. */
597
+ getToken(): string | null;
598
+ /**
599
+ * Replaces the stored token. Used by the provider after `login` /
600
+ * `changePassword` to persist the JWT before the next request fires.
601
+ *
602
+ * @param token - the bearer JWT to store.
603
+ */
604
+ setToken(token: string): void;
605
+ /** Clears the stored token. Idempotent. */
606
+ clearToken(): void;
607
+ /**
608
+ * `POST /auth/login`. On success, persists the returned token automatically
609
+ * so subsequent calls authenticate without the caller threading the JWT
610
+ * through.
611
+ *
612
+ * @param username - the user's login id.
613
+ * @param password - plaintext password (sent over HTTPS to the server).
614
+ * @returns the login response, with `mustChangePassword` camelcased.
615
+ */
616
+ login(username: string, password: string): Promise<LoginResponse>;
617
+ /**
618
+ * `POST /auth/change-password`. Returns the fresh session token (the
619
+ * change-only token is consumed by this call).
620
+ *
621
+ * @param currentPassword - the user's existing password, or null when
622
+ * the caller is authenticating with a password-change-only token
623
+ * (forced-change flow — §8.5).
624
+ * @param newPassword - the new password. Must satisfy the §8.5 policy
625
+ * (≥8 chars, ≥2 of {letters, digits, special}).
626
+ * @returns the new session token, persisted automatically.
627
+ */
628
+ changePassword(currentPassword: string | null, newPassword: string): Promise<{
629
+ token: string;
630
+ }>;
631
+ /**
632
+ * `POST /auth/logout`. Server-side this is a no-op in v1 (no token
633
+ * blacklist — §6.3.4); we issue it for symmetry and to give the server
634
+ * an audit-log entry. Always clears the local token afterward, even
635
+ * when the request fails.
636
+ */
637
+ logout(): Promise<void>;
638
+ /**
639
+ * `GET /auth/me` — fetches the `{ user, deployment }` envelope.
640
+ */
641
+ me(): Promise<AIHubAuthContext>;
642
+ /**
643
+ * `GET /feature-toggles` — fetches the deployment-wide UI feature
644
+ * toggles set by `super_admin` (§8.4). **Unauthenticated** — no token
645
+ * required, every role gets the same response. The provider calls this
646
+ * on mount so the §8.4 precedence ("server toggle > React prop >
647
+ * built-in default") applies before the chat shell first renders.
648
+ *
649
+ * Missing keys are returned absent in the response (not coerced to
650
+ * `false`) so the client can distinguish "explicitly off" from "fall
651
+ * through to the React prop default."
652
+ *
653
+ * @returns the wire-format toggles blob; may be empty (`{}`) when the
654
+ * super_admin hasn't set anything.
655
+ */
656
+ getFeatureToggles(): Promise<AIHubFeatureToggles>;
657
+ /**
658
+ * `PATCH /auth/me/preferences` — updates the caller's stored
659
+ * `theme_preference`. Returns the refreshed envelope.
660
+ *
661
+ * Rejected with `AIHubRequestError(code: "theme_switcher_disabled")` (HTTP
662
+ * 409) when the deployment has the switcher turned off (§7.6).
663
+ *
664
+ * @param prefs - the preferences patch (currently only `theme`).
665
+ * @param prefs.theme - new theme preference (`"light"` or `"dark"`).
666
+ */
667
+ updatePreferences(prefs: {
668
+ theme?: "light" | "dark";
669
+ }): Promise<AIHubAuthContext>;
670
+ /**
671
+ * `GET /sessions?agent_id=...&include_archived=...`.
672
+ *
673
+ * @param options - filter arguments; `agentId` is required.
674
+ */
675
+ listSessions(options: ListSessionsOptions): Promise<Session[]>;
676
+ /**
677
+ * `POST /sessions`.
678
+ *
679
+ * Client-side validation: title must be 1..80 chars. Empty / oversize
680
+ * titles throw `AIHubRequestError(code: "validation")` synchronously
681
+ * without an HTTP round-trip.
682
+ *
683
+ * @param options - the agent id + non-empty title.
684
+ * @returns the created session row.
685
+ */
686
+ createSession(options: CreateSessionOptions): Promise<Session>;
687
+ /** `GET /sessions/:id`. */
688
+ getSession(id: string): Promise<Session>;
689
+ /**
690
+ * `PATCH /sessions/:id` — rename and/or archive in one call. An empty
691
+ * patch (`{}`) returns the row unchanged.
692
+ *
693
+ * @param id - the session id.
694
+ * @param patch - the fields to update.
695
+ */
696
+ patchSession(id: string, patch: PatchSessionOptions): Promise<Session>;
697
+ /**
698
+ * `PATCH /sessions/:id/reasoning` — update the user's per-session reasoning
699
+ * settings. The server applies them to the agent's `model_settings`
700
+ * automatically before the next chat turn.
701
+ *
702
+ * Returns the refreshed session including `capabilities`, so the caller
703
+ * can re-render UI controls without a separate GET.
704
+ */
705
+ patchSessionReasoning(id: string, patch: PatchSessionReasoningOptions): Promise<Session>;
706
+ /** `GET /sessions/:id/messages`. */
707
+ getSessionMessages(id: string): Promise<AIHubMessage[]>;
708
+ /**
709
+ * `GET /sessions/:id/message-overrides` — returns the caller's per-message
710
+ * content substitutions for this session's underlying Letta conversation.
711
+ *
712
+ * Overrides are keyed by `ordinal_position` (0-based index into Letta's
713
+ * chronologically-sorted message list). They're applied automatically by
714
+ * `getSessionMessages` — callers don't need to merge manually; this
715
+ * endpoint exists so custom Tier-3 UIs can render an edit affordance
716
+ * next to each message that has an override.
717
+ *
718
+ * @param sessionId - the ai-hub session id.
719
+ * @returns the overrides sorted by `ordinal_position` ascending.
720
+ */
721
+ listMessageOverrides(sessionId: string): Promise<AIHubMessageOverride[]>;
722
+ /**
723
+ * `PUT /sessions/:id/message-overrides/:position` — upsert one or both
724
+ * override layers for the message at `ordinalPosition`.
725
+ *
726
+ * Pass `systemOverride` to set the LLM-facing view, `userOverride` to
727
+ * set the UI-facing view, or both. At least one must be provided.
728
+ * **Merge semantics**: only the layer(s) you pass are written; an
729
+ * existing value on the other layer is preserved.
730
+ *
731
+ * **Validation gates** (server-enforced):
732
+ *
733
+ * - `409 turn_in_progress` — a turn is currently live for this session.
734
+ * - `409 message_not_found` — no Letta message exists at this position
735
+ * yet (typical when a tier-3 caller tries to override a message
736
+ * before it has landed; wait for the turn to finish first).
737
+ *
738
+ * Pass empty string for `userOverride` to visually hide the message
739
+ * (the bubble slot stays — use `deleteMessageOverride` to remove the
740
+ * slot entirely).
741
+ *
742
+ * @param sessionId - the ai-hub session id.
743
+ * @param ordinalPosition - the 0-based index in Letta's message list.
744
+ * @param override - one or both layers to write.
745
+ * @returns the resulting override row.
746
+ */
747
+ setMessageOverride(sessionId: string, ordinalPosition: number, override: {
748
+ systemOverride?: string;
749
+ userOverride?: string;
750
+ }): Promise<AIHubMessageOverride>;
751
+ /**
752
+ * `DELETE /sessions/:id/message-overrides/:position` — remove an override.
753
+ *
754
+ * Idempotent: returns successfully whether or not the row existed.
755
+ *
756
+ * @param sessionId - the ai-hub session id.
757
+ * @param ordinalPosition - the 0-based index in Letta's message list.
758
+ */
759
+ deleteMessageOverride(sessionId: string, ordinalPosition: number): Promise<void>;
760
+ /**
761
+ * `GET /agents` — returns the user-facing agent catalog (non-archived
762
+ * only) with each entry's `session_count` scoped to the caller.
763
+ */
764
+ listAgents(): Promise<AgentSummary[]>;
765
+ /**
766
+ * `POST /chat` — opens an SSE stream. Returns an async iterable of
767
+ * `AIHubEvent`s; consume with `for await (const event of …)`.
768
+ *
769
+ * The iterable terminates when the server emits `stream_end` (the bytes
770
+ * stop after that). To abort early, pass `opts.signal`.
771
+ *
772
+ * @param body - the request body (sessionId, userMessage, optional effort,
773
+ * optional idempotencyKey).
774
+ * @param opts - optional abort signal and resumption hint.
775
+ */
776
+ streamChat(body: StreamChatBody, opts?: StreamChatOptions): AsyncIterable<AIHubEvent>;
777
+ /**
778
+ * `GET /chat/:turn_id/events?from_seq=N` — resumption replay then
779
+ * live-attach.
780
+ *
781
+ * @param turnId - the turn to resume.
782
+ * @param opts - optional abort signal and `fromSeq` cursor (defaults to
783
+ * `-1` so every persisted event is replayed).
784
+ */
785
+ getTurnEvents(turnId: string, opts?: StreamChatOptions): AsyncIterable<AIHubEvent>;
786
+ /** `POST /chat/:turn_id/cancel`. */
787
+ cancelTurn(turnId: string): Promise<CancelTurnResponse>;
788
+ /**
789
+ * `GET /admin/users` — fetches every user row in the deployment.
790
+ *
791
+ * Caller must be `admin` or `super_admin`; the server returns 403
792
+ * otherwise (the SDK surfaces it as `AIHubRequestError(code: "forbidden")`).
793
+ *
794
+ * @returns the user rows, sorted alphabetically by username.
795
+ * @throws {AIHubRequestError} `forbidden` for `user` / `power_user` callers.
796
+ */
797
+ listAdminUsers(): Promise<AdminUserView[]>;
798
+ /**
799
+ * `POST /admin/users` — creates a user; the server generates the password.
800
+ *
801
+ * Returns the new row plus the **one-time** plaintext password
802
+ * (`generatedPassword`). The caller is responsible for surfacing it
803
+ * exactly once in the UI — there is no way to retrieve it later.
804
+ *
805
+ * Admins cannot create `super_admin`s (server returns 403 if the body
806
+ * requests it). On username collision returns 409 `username_taken`.
807
+ *
808
+ * @param body - the new user's identity + initial role.
809
+ * @returns the created row and the one-time password.
810
+ * @throws {AIHubRequestError} `forbidden` (caller role insufficient or
811
+ * admin tried to grant super_admin), `validation` (malformed body),
812
+ * or `username_taken` (409).
813
+ */
814
+ createAdminUser(body: CreateUserBody): Promise<CreateUserResponse>;
815
+ /**
816
+ * `PATCH /admin/users/:id/role` — changes a user's role.
817
+ *
818
+ * The server enforces the admin-shield + super-admin-min-count rules
819
+ * transactionally (§8.1). Violations come back as 403 with codes like
820
+ * `admin_shield`, `super_admin_min_count`, or `forbidden`.
821
+ *
822
+ * @param id - the target user's id.
823
+ * @param role - the new role.
824
+ * @returns the updated row.
825
+ * @throws {AIHubRequestError} `forbidden` (shield / min-count / caller
826
+ * cannot grant this role).
827
+ */
828
+ patchAdminUserRole(id: string, role: AIHubRole): Promise<AdminUserView>;
829
+ /**
830
+ * `POST /admin/users/:id/reset-password` — issues a fresh password.
831
+ *
832
+ * Sets `is_initial_password = true` on the target. The new plaintext is
833
+ * returned **exactly once** in `generatedPassword`; the admin UI must
834
+ * surface it via the one-time-reveal modal.
835
+ *
836
+ * @param id - the target user's id.
837
+ * @returns the one-time plaintext.
838
+ * @throws {AIHubRequestError} `forbidden` (shield / min-count).
839
+ */
840
+ resetAdminUserPassword(id: string): Promise<AdminUserPasswordReveal>;
841
+ /**
842
+ * `DELETE /admin/users/:id` — hard-deletes a user.
843
+ *
844
+ * Cascades to that user's sessions via the FK. The server blocks
845
+ * self-delete (returns 403) so a careless click can't brick the caller's
846
+ * own account; shield + min-count apply as for role change.
847
+ *
848
+ * @param id - the target user's id.
849
+ * @throws {AIHubRequestError} `forbidden` (shield, min-count, or
850
+ * attempting to delete oneself).
851
+ */
852
+ deleteAdminUser(id: string): Promise<void>;
853
+ /**
854
+ * `GET /admin/agents` — every ai-hub agent in the deployment, including
855
+ * archived ones. Caller must be `power_user`+ per §8.2.
856
+ *
857
+ * Sort order: ascending by `display_name` (the server's `ORDER BY`).
858
+ *
859
+ * @returns the agent rows.
860
+ * @throws {AIHubRequestError} `forbidden` for `user` callers.
861
+ */
862
+ listAdminAgents(): Promise<AdminAgentView[]>;
863
+ /**
864
+ * `POST /admin/agents` — register a new ai-hub agent in the catalog.
865
+ *
866
+ * The server validates `lettaAgentId` against Letta; if the id isn't
867
+ * resolvable the response is 400 `letta_agent_not_found` (surface inline
868
+ * on the form field).
869
+ *
870
+ * @param body - the display name + assigned Letta agent id.
871
+ * @returns the newly-created row.
872
+ * @throws {AIHubRequestError} `letta_agent_not_found`, `validation`, `forbidden`.
873
+ */
874
+ createAdminAgent(body: CreateAdminAgentBody): Promise<AdminAgentView>;
875
+ /**
876
+ * `PATCH /admin/agents/:id` — update one or more fields. Every field is
877
+ * optional; an empty patch is a 200 no-op.
878
+ *
879
+ * Archive / unarchive flows through this same endpoint via `isArchived`.
880
+ *
881
+ * @param id - the ai-hub agent id.
882
+ * @param body - the fields to update.
883
+ * @returns the refreshed row.
884
+ * @throws {AIHubRequestError} `letta_agent_not_found` if `lettaAgentId`
885
+ * was supplied and doesn't resolve in Letta.
886
+ */
887
+ patchAdminAgent(id: string, body: PatchAdminAgentBody): Promise<AdminAgentView>;
888
+ /**
889
+ * `GET /admin/rotating-messages` — every rotating starting message in the
890
+ * deployment (archived included), sorted by display name. `power_user`+.
891
+ *
892
+ * @returns the rows.
893
+ * @throws {AIHubRequestError} `forbidden` for `user` callers.
894
+ */
895
+ listAdminRotatingMessages(): Promise<AdminRotatingMessageView[]>;
896
+ /**
897
+ * `POST /admin/rotating-messages` — create a rotating starting message. The
898
+ * server validates `lettaAgentId` against Letta (`letta_agent_not_found`)
899
+ * and the schedule shape (`invalid_schedule`).
900
+ *
901
+ * @param body - the prompt, agent, and schedule config.
902
+ * @returns the newly-created row (including its `rmsg-…` id).
903
+ * @throws {AIHubRequestError} `letta_agent_not_found`, `invalid_schedule`, `validation`, `forbidden`.
904
+ */
905
+ createAdminRotatingMessage(body: CreateAdminRotatingMessageBody): Promise<AdminRotatingMessageView>;
906
+ /**
907
+ * `PATCH /admin/rotating-messages/:id` — update one or more fields. Every
908
+ * field is optional; an empty patch is a 200 no-op. Changing the schedule
909
+ * recomputes the next rotation time.
910
+ *
911
+ * @param id - the rotating message id.
912
+ * @param body - the fields to update.
913
+ * @returns the refreshed row.
914
+ * @throws {AIHubRequestError} `letta_agent_not_found`, `invalid_schedule`, `not_found`, `forbidden`.
915
+ */
916
+ patchAdminRotatingMessage(id: string, body: PatchAdminRotatingMessageBody): Promise<AdminRotatingMessageView>;
917
+ /**
918
+ * `POST /admin/rotating-messages/:id/rotate-now` — run a rotation inline
919
+ * (preview / force-refresh). May take a while — it spawns the Letta Code
920
+ * subprocess like a real chat turn.
921
+ *
922
+ * @param id - the rotating message id.
923
+ * @returns the refreshed row plus the attempt's outcome.
924
+ * @throws {AIHubRequestError} `not_found`, `forbidden`.
925
+ */
926
+ rotateAdminRotatingMessageNow(id: string): Promise<RotateNowResponse>;
927
+ /**
928
+ * `GET /admin/sessions` — paginated read-only browser over every session
929
+ * in the deployment. `power_user`+ per §8.2.
930
+ *
931
+ * Each row carries `owner_username` + `agent_display_name` joined
932
+ * server-side. Use `nextCursor` (when non-null) as the `cursor` for the
933
+ * next page.
934
+ *
935
+ * @param options - filter + pagination args. All optional.
936
+ * @returns the page plus the next-cursor.
937
+ */
938
+ listAdminSessions(options?: ListAdminSessionsOptions): Promise<ListAdminSessionsResponse>;
939
+ /**
940
+ * `GET /admin/sessions/:id/messages` — read-only history for any session
941
+ * (cross-user). Returns the same `AIHubMessage[]` shape as the user-facing
942
+ * `getSessionMessages` so the same `<MessageBubble />` rendering can be
943
+ * reused.
944
+ *
945
+ * @param id - any session id in the deployment.
946
+ * @returns the projected message list.
947
+ * @throws {AIHubRequestError} `forbidden` for `user` callers, `not_found`
948
+ * if the session id doesn't exist.
949
+ */
950
+ getAdminSessionMessages(id: string): Promise<AIHubMessage[]>;
951
+ /**
952
+ * Step-12.5 — `POST /admin/sessions/:id/purge-sandbox`.
953
+ *
954
+ * Removes the per-session sandbox folder from disk + clears
955
+ * `session.sandbox_dir`. Idempotent: 204 on success regardless of
956
+ * whether the session ever had a sandbox. Rejects with
957
+ * `409 turn_running` if a chat turn is live for the session.
958
+ *
959
+ * `super_admin` only — `admin` / `power_user` callers get 403.
960
+ *
961
+ * @param id - the ai-hub session id.
962
+ * @throws {AIHubRequestError} `turn_running`, `forbidden`, `not_found`.
963
+ */
964
+ purgeAdminSessionSandbox(id: string): Promise<void>;
965
+ /**
966
+ * `GET /admin/settings` — deployment-wide configuration (super_admin only).
967
+ *
968
+ * The Letta API key is never returned in plaintext; the response carries
969
+ * `letta_api_key_set` + `letta_api_key_masked` so the UI can render
970
+ * "configured / not configured" affordances.
971
+ */
972
+ getAdminSettings(): Promise<AdminSettingsView>;
973
+ /**
974
+ * `PATCH /admin/settings` — update one or more deployment settings.
975
+ *
976
+ * The API key, when supplied, is encrypted under `AI_HUB_ENCRYPTION_KEY`
977
+ * server-side. Theme fields live as separate columns and follow the same
978
+ * precedence as the React props (server > prop > built-in default).
979
+ *
980
+ * @param body - the patch. Each field independent.
981
+ * @returns the refreshed settings view.
982
+ */
983
+ patchAdminSettings(body: PatchAdminSettingsBody): Promise<AdminSettingsView>;
984
+ /**
985
+ * `GET /admin/settings/feature-toggles` — the §8.4 toggle blob the
986
+ * super-admin sees. Same payload the `getFeatureToggles` (unauthenticated)
987
+ * endpoint returns, but gated and intended for the settings editor.
988
+ */
989
+ getAdminFeatureToggles(): Promise<AIHubFeatureToggles>;
990
+ /**
991
+ * `PATCH /admin/settings/feature-toggles` — merge-patch the §8.4 toggle
992
+ * blob. Unknown keys are rejected with 400; the server's strict schema is
993
+ * the source of truth for which toggles are accepted.
994
+ *
995
+ * @param toggles - the partial — only the keys you want to write.
996
+ */
997
+ patchAdminFeatureToggles(toggles: AIHubFeatureToggles): Promise<AIHubFeatureToggles>;
998
+ /**
999
+ * `POST /admin/settings/rotate-signing-key` — replace the JWT signing key
1000
+ * in place. **Every outstanding JWT is invalidated immediately**, including
1001
+ * the caller's own. The next protected request from the UI will 401 and
1002
+ * the provider routes back to login (§6.7).
1003
+ *
1004
+ * Returns nothing — the new key never leaves the server.
1005
+ */
1006
+ rotateAdminSigningKey(): Promise<void>;
1007
+ /**
1008
+ * `POST /admin/settings/rotate-metrics-token` — rotate the `/metrics`
1009
+ * bearer token. The new token is returned **exactly once** in
1010
+ * `{ token }`; subsequent `getAdminSettings` calls do NOT echo it back.
1011
+ * The admin must copy it into their Prometheus / Alloy config before
1012
+ * dismissing the reveal modal (§6.10).
1013
+ *
1014
+ * Does NOT invalidate the caller's JWT — only the metrics-scraper bearer
1015
+ * changes.
1016
+ */
1017
+ rotateAdminMetricsToken(): Promise<AdminMetricsTokenRotateResponse>;
1018
+ /**
1019
+ * Sends a JSON request and parses the JSON response. Centralizes auth
1020
+ * header injection, 401 handling, and error normalization.
1021
+ *
1022
+ * @param method - HTTP method.
1023
+ * @param path - path under `baseUrl`.
1024
+ * @param opts - optional body and unauthenticated-mode flag.
1025
+ * @param opts.body - JSON body to send (omit for GET / DELETE).
1026
+ * @param opts.authenticated - set to `false` to skip the bearer header
1027
+ * (login is the only such caller). Defaults to true.
1028
+ * @returns the parsed response.
1029
+ */
1030
+ private requestJson;
1031
+ /**
1032
+ * Shared backbone for `streamChat` and `getTurnEvents`. Yields events
1033
+ * from an SSE response; throws `AIHubRequestError` on 4xx/5xx before the
1034
+ * stream opens.
1035
+ *
1036
+ * @param method - HTTP method.
1037
+ * @param path - path under `baseUrl`.
1038
+ * @param body - optional JSON body (POST /chat only).
1039
+ * @param opts - abort signal.
1040
+ * @yields each ai-hub event from the SSE stream until `stream_end`.
1041
+ */
1042
+ private streamRequest;
1043
+ /**
1044
+ * Clears the token and fires the unauthorized callback (at most once per
1045
+ * 401 storm — the flag resets on next `setToken`).
1046
+ */
1047
+ private handleUnauthorized;
1048
+ /**
1049
+ * Builds an `AIHubRequestError` from a non-ok server response. Reads the
1050
+ * server's `{ error: { code, message, request_id } }` envelope when
1051
+ * present; falls back to status-code-derived defaults otherwise.
1052
+ *
1053
+ * @param response - the fetch response (status >= 400).
1054
+ * @returns the normalized error.
1055
+ */
1056
+ private errorFromResponse;
1057
+ }
1058
+ //# sourceMappingURL=AIHubClient.d.ts.map