@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,120 @@
1
+ /**
2
+ * `<ToolCallView />` — collapsible tool-call card inside an assistant
3
+ * bubble.
4
+ *
5
+ * Header carries the tool name + status (`running`/`done`/`error`) +
6
+ * duration. Body shows input + output (or input + error). Default
7
+ * collapsed; click `[▶]` to expand. Tool errors do NOT fail the turn
8
+ * — the card stays as evidence of what happened (§10.3).
9
+ *
10
+ * Step 10 only renders tool calls when `toolCallsVisible` (resolved) is
11
+ * true. The decision lives in `MessageList`.
12
+ *
13
+ * Exported under `AIHub.ToolCallView`.
14
+ *
15
+ * @see SPECIFICATIONS.md §9.3 — tool events
16
+ * @see SPECIFICATIONS.md §10.3 — tool error vs. agent error
17
+ * @see ui-sketches/03-chat.md — tool_call_card
18
+ */
19
+ import { type ReactNode } from "react";
20
+ import { type AIHubTexts, type DeepPartial } from "../../auth/texts.js";
21
+ /** Status of a tool call. */
22
+ export type ToolCallStatus = "running" | "done" | "error";
23
+ /** BEM class names emitted by `<ToolCallView />`. */
24
+ export interface ToolCallViewClassNames {
25
+ /** Outer card. */
26
+ root: string;
27
+ /** Modifier — `--collapsed`. */
28
+ rootCollapsed: string;
29
+ /** Modifier — `--expanded`. */
30
+ rootExpanded: string;
31
+ /** Status modifier — `--running`. */
32
+ rootRunning: string;
33
+ /** Status modifier — `--done`. */
34
+ rootDone: string;
35
+ /** Status modifier — `--error`. */
36
+ rootError: string;
37
+ /** Header element. */
38
+ header: string;
39
+ /** Tool name inside header. */
40
+ toolName: string;
41
+ /** Status icon + text inside header. */
42
+ status: string;
43
+ /** Duration text inside header. */
44
+ duration: string;
45
+ /** Expand/collapse toggle. */
46
+ toggle: string;
47
+ /** Body element (mounted only when expanded). */
48
+ body: string;
49
+ /** Modifier on the body — `--error`. */
50
+ bodyError: string;
51
+ /** Input section. */
52
+ inputSection: string;
53
+ /** Output section. */
54
+ outputSection: string;
55
+ /** Section label (Input: / Output: / Error:). */
56
+ sectionLabel: string;
57
+ /** Section pre/code content. */
58
+ sectionContent: string;
59
+ }
60
+ /** Props for `<ToolCallView />`. */
61
+ export interface ToolCallViewProps {
62
+ /** Tool name (e.g. "search_web"). */
63
+ toolName: string;
64
+ /** Current status. Drives the icon + the body's error modifier. */
65
+ status: ToolCallStatus;
66
+ /** Tool input — pretty-printed JSON usually. */
67
+ input: string;
68
+ /** Tool output (only meaningful when `status === "done"`). */
69
+ output?: string;
70
+ /** Error message (only meaningful when `status === "error"`). */
71
+ error?: string;
72
+ /** Duration in seconds, when known. */
73
+ durationSeconds?: number;
74
+ /**
75
+ * Override initial expanded state. Default false (collapsed); the
76
+ * spec's `tool_call_card --collapsed` is the default visual.
77
+ *
78
+ * Ignored when `expanded` is passed (controlled mode).
79
+ */
80
+ defaultExpanded?: boolean;
81
+ /**
82
+ * Controlled expanded state. When set, `<ToolCallView />` defers all
83
+ * expand/collapse decisions to the parent — `onToggle` fires on the
84
+ * user's toggle click and the parent computes the next `expanded`.
85
+ * Used by `<MessageList />` to enforce the accordion +
86
+ * auto-expand-while-streaming rules across blocks. When omitted, the
87
+ * component falls back to internal `useState` (default-collapsed,
88
+ * per-instance toggle) for backward compatibility.
89
+ */
90
+ expanded?: boolean;
91
+ /**
92
+ * Toggle handler for the controlled mode. Fires on the user's click;
93
+ * the parent decides what to do with it. Ignored in uncontrolled mode.
94
+ */
95
+ onToggle?: () => void;
96
+ /** Wrapper-supplied i18n. */
97
+ texts?: DeepPartial<AIHubTexts>;
98
+ /** Extra class merged onto the root. */
99
+ className?: string;
100
+ /** Per-element class overrides. */
101
+ classNames?: Partial<ToolCallViewClassNames>;
102
+ /**
103
+ * Transform applied to the displayed `input` / `output` / `error`
104
+ * strings. Defaults to [[formatToolContentForDisplay]], which
105
+ * JSON-pretty-prints the value (when parseable) and unescapes the
106
+ * whitespace JSON-escape sequences (`\n`, `\t`, `\r`) so they render
107
+ * as actual layout. Pass `(s) => s` to opt out (e.g. for a raw
108
+ * debugging view), or supply a custom formatter to reshape the
109
+ * content (e.g. redact secrets).
110
+ */
111
+ formatContent?: (raw: string) => string;
112
+ }
113
+ /**
114
+ * Renders the card.
115
+ *
116
+ * @param props - see `ToolCallViewProps`.
117
+ * @returns the rendered card.
118
+ */
119
+ export declare function ToolCallView(props: ToolCallViewProps): ReactNode;
120
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ToolCallView/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAG7B,6BAA6B;AAC7B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1D,qDAAqD;AACrD,MAAM,WAAW,sBAAsB;IACrC,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,QAAQ,EAAE,MAAM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_jsx } from "react/jsx-runtime";
2
+ /**
3
+ * `<ToolCallView />` — collapsible tool-call card inside an assistant
4
+ * bubble.
5
+ *
6
+ * Header carries the tool name + status (`running`/`done`/`error`) +
7
+ * duration. Body shows input + output (or input + error). Default
8
+ * collapsed; click `[▶]` to expand. Tool errors do NOT fail the turn
9
+ * — the card stays as evidence of what happened (§10.3).
10
+ *
11
+ * Step 10 only renders tool calls when `toolCallsVisible` (resolved) is
12
+ * true. The decision lives in `MessageList`.
13
+ *
14
+ * Exported under `AIHub.ToolCallView`.
15
+ *
16
+ * @see SPECIFICATIONS.md §9.3 — tool events
17
+ * @see SPECIFICATIONS.md §10.3 — tool error vs. agent error
18
+ * @see ui-sketches/03-chat.md — tool_call_card
19
+ */
20
+ import { useState } from "react";
21
+ import { resolveAIHubTexts, } from "../../auth/texts.js";
22
+ import { formatToolContentForDisplay } from "./formatContent.js";
23
+ const DEFAULT_CLASS_NAMES = Object.freeze({
24
+ root: "data-club-ai-hub__tool-call-card",
25
+ rootCollapsed: "data-club-ai-hub__tool-call-card--collapsed",
26
+ rootExpanded: "data-club-ai-hub__tool-call-card--expanded",
27
+ rootRunning: "data-club-ai-hub__tool-call-card--running",
28
+ rootDone: "data-club-ai-hub__tool-call-card--done",
29
+ rootError: "data-club-ai-hub__tool-call-card--error",
30
+ header: "data-club-ai-hub__tool-call-card__header",
31
+ toolName: "data-club-ai-hub__tool-call-card__tool-name",
32
+ status: "data-club-ai-hub__tool-call-card__status",
33
+ duration: "data-club-ai-hub__tool-call-card__duration",
34
+ toggle: "data-club-ai-hub__tool-call-card__toggle",
35
+ body: "data-club-ai-hub__tool-call-card__body",
36
+ bodyError: "data-club-ai-hub__tool-call-card__body--error",
37
+ inputSection: "data-club-ai-hub__tool-call-card__input-section",
38
+ outputSection: "data-club-ai-hub__tool-call-card__output-section",
39
+ sectionLabel: "data-club-ai-hub__tool-call-card__section-label",
40
+ sectionContent: "data-club-ai-hub__tool-call-card__section-content",
41
+ });
42
+ /**
43
+ * Returns the BEM modifier for the status.
44
+ */
45
+ function statusModifier(status, cls) {
46
+ switch (status) {
47
+ case "running":
48
+ return cls.rootRunning;
49
+ case "done":
50
+ return cls.rootDone;
51
+ case "error":
52
+ return cls.rootError;
53
+ }
54
+ }
55
+ /**
56
+ * Returns the i18n status text for the header.
57
+ */
58
+ function statusText(status, chat) {
59
+ switch (status) {
60
+ case "running":
61
+ return chat.toolCallRunningStatus;
62
+ case "done":
63
+ return chat.toolCallDoneStatus;
64
+ case "error":
65
+ return chat.toolCallErrorStatus;
66
+ }
67
+ }
68
+ /**
69
+ * Renders the card.
70
+ *
71
+ * @param props - see `ToolCallViewProps`.
72
+ * @returns the rendered card.
73
+ */
74
+ export function ToolCallView(props) {
75
+ const texts = resolveAIHubTexts(props.texts);
76
+ const cls = { ...DEFAULT_CLASS_NAMES, ...(props.classNames ?? {}) };
77
+ const [uncontrolledExpanded, setUncontrolledExpanded] = useState(props.defaultExpanded ?? false);
78
+ const isControlled = props.expanded !== undefined;
79
+ const expanded = isControlled ? props.expanded : uncontrolledExpanded;
80
+ const handleToggle = isControlled
81
+ ? props.onToggle ?? (() => { })
82
+ : () => setUncontrolledExpanded((e) => !e);
83
+ const seconds = props.durationSeconds ?? 0;
84
+ const durationText = seconds > 0 ? `(${seconds.toFixed(1)}s)` : "";
85
+ const formatContent = props.formatContent ?? formatToolContentForDisplay;
86
+ const rootClass = [
87
+ cls.root,
88
+ expanded ? cls.rootExpanded : cls.rootCollapsed,
89
+ statusModifier(props.status, cls),
90
+ props.className,
91
+ ]
92
+ .filter(Boolean)
93
+ .join(" ");
94
+ const bodyClass = [
95
+ cls.body,
96
+ props.status === "error" ? cls.bodyError : null,
97
+ ]
98
+ .filter(Boolean)
99
+ .join(" ");
100
+ return (_jsxs("div", { className: rootClass, "data-testid": "tool-call-view", "data-status": props.status, "data-expanded": expanded ? "true" : "false", children: [_jsxs("div", { className: cls.header, children: [_jsxs("span", { className: cls.toolName, "data-testid": "tool-call-view-name", children: ["\uD83D\uDD27 ", props.toolName] }), _jsx("span", { className: cls.status, "data-testid": "tool-call-view-status", children: statusText(props.status, texts.chat) }), durationText ? (_jsx("span", { className: cls.duration, children: durationText })) : null, _jsx("button", { type: "button", className: cls.toggle, onClick: handleToggle, "aria-expanded": expanded, "aria-label": expanded
101
+ ? texts.chat.toolCallCollapseAriaLabel
102
+ : texts.chat.toolCallExpandAriaLabel, "data-testid": "tool-call-view-toggle", children: expanded ? "▼" : "▶" })] }), expanded ? (_jsxs("div", { className: bodyClass, "data-testid": "tool-call-view-body", children: [_jsxs("div", { className: cls.inputSection, children: [_jsx("div", { className: cls.sectionLabel, children: texts.chat.toolCallInputLabel }), _jsx("pre", { className: cls.sectionContent, children: formatContent(props.input) })] }), props.status === "error" ? (_jsxs("div", { className: cls.outputSection, children: [_jsx("div", { className: cls.sectionLabel, children: texts.chat.toolCallErrorLabel }), _jsx("pre", { className: cls.sectionContent, children: formatContent(props.error ?? "") })] })) : props.output !== undefined ? (_jsxs("div", { className: cls.outputSection, children: [_jsx("div", { className: cls.sectionLabel, children: texts.chat.toolCallOutputLabel }), _jsx("pre", { className: cls.sectionContent, children: formatContent(props.output) })] })) : null] })) : null] }));
103
+ }
104
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ToolCallView/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEjD,OAAO,EACL,iBAAiB,GAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AA2CjE,MAAM,mBAAmB,GAA2B,MAAM,CAAC,MAAM,CAAC;IAChE,IAAI,EAAE,kCAAkC;IACxC,aAAa,EAAE,6CAA6C;IAC5D,YAAY,EAAE,4CAA4C;IAC1D,WAAW,EAAE,2CAA2C;IACxD,QAAQ,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AAkB,GAC1B,EACN,cAAK,SAAS,EAAE,GAAG,CAAC,cAAc,YAAG,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,GAAO,IACxE,CACP,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAC/B,eAAK,SAAS,EAAE,GAAG,CAAC,aAAa,aAC/B,cAAK,SAAS,EAAE,GAAG,CAAC,YAAY,YAC7B,KAAK,CAAC,IAAI,CAAC,mBAAmB,GAC3B,EACN,cAAK,SAAS,EAAE,GAAG,CAAC,cAAc,YAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,GAAO,IACnE,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * `<TpmBanner />` — TPM-recovery banner with countdown.
3
+ *
4
+ * Specialization of `<SystemNotice />` that:
5
+ *
6
+ * 1. Reads the active turn's `tpm_retry_at` from `useAIHub().state` and
7
+ * computes the remaining seconds at ~1Hz.
8
+ * 2. Switches variant based on §10.4: `tpm-wait` while `phase ===
9
+ * waiting_provider`, transient `resumed` flash on the `running →
10
+ * running(model_*)` recovery transition, and `error` when the
11
+ * `lastTurnError` is `tpm_exhausted`.
12
+ * 3. Renders nothing when none of the conditions apply — components can
13
+ * mount it unconditionally without flicker.
14
+ *
15
+ * The provider's reducer already clears `tpm_retry_at` on the `resumed`
16
+ * notice; the banner observes that change and shows the brief "Resumed."
17
+ * flash for 2s. The exhausted-error path renders a Retry button that
18
+ * re-issues the last user message (delegated to the parent via
19
+ * `onRetry`).
20
+ *
21
+ * @see SPECIFICATIONS.md §6.5 — TPM recovery
22
+ * @see SPECIFICATIONS.md §10.4 — predicates bound to (status, phase)
23
+ * @see ui-sketches/03-chat.md — system_notice variants
24
+ */
25
+ import { type ReactNode } from "react";
26
+ import { type AIHubTexts, type DeepPartial } from "../../auth/texts.js";
27
+ /** Props for `<TpmBanner />`. */
28
+ export interface TpmBannerProps {
29
+ /**
30
+ * Called when the user clicks the Retry button on the `--error`
31
+ * variant. Wraps `sendMessage` of the last user message; the parent
32
+ * decides what "last user message" means (the monolith threads its
33
+ * own ref through).
34
+ */
35
+ onRetry?: () => void;
36
+ /** Wrapper-supplied i18n. */
37
+ texts?: DeepPartial<AIHubTexts>;
38
+ /** Extra class merged onto the root. */
39
+ className?: string;
40
+ /**
41
+ * Override the resolved "now" — test injection point. Production code
42
+ * leaves this unset (defaults to `Date.now()` at each tick).
43
+ */
44
+ nowProvider?: () => number;
45
+ }
46
+ /**
47
+ * Renders the banner.
48
+ *
49
+ * @param props - see `TpmBannerProps`.
50
+ * @returns the rendered banner, or `null` when nothing should render.
51
+ */
52
+ export declare function TpmBanner(props: TpmBannerProps): ReactNode;
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TpmBanner/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAiC7B,iCAAiC;AACjC,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAChC,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAiF1D"}
@@ -0,0 +1,116 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * `<TpmBanner />` — TPM-recovery banner with countdown.
4
+ *
5
+ * Specialization of `<SystemNotice />` that:
6
+ *
7
+ * 1. Reads the active turn's `tpm_retry_at` from `useAIHub().state` and
8
+ * computes the remaining seconds at ~1Hz.
9
+ * 2. Switches variant based on §10.4: `tpm-wait` while `phase ===
10
+ * waiting_provider`, transient `resumed` flash on the `running →
11
+ * running(model_*)` recovery transition, and `error` when the
12
+ * `lastTurnError` is `tpm_exhausted`.
13
+ * 3. Renders nothing when none of the conditions apply — components can
14
+ * mount it unconditionally without flicker.
15
+ *
16
+ * The provider's reducer already clears `tpm_retry_at` on the `resumed`
17
+ * notice; the banner observes that change and shows the brief "Resumed."
18
+ * flash for 2s. The exhausted-error path renders a Retry button that
19
+ * re-issues the last user message (delegated to the parent via
20
+ * `onRetry`).
21
+ *
22
+ * @see SPECIFICATIONS.md §6.5 — TPM recovery
23
+ * @see SPECIFICATIONS.md §10.4 — predicates bound to (status, phase)
24
+ * @see ui-sketches/03-chat.md — system_notice variants
25
+ */
26
+ import { useEffect, useState } from "react";
27
+ import { resolveAIHubTexts, } from "../../auth/texts.js";
28
+ import { useAIHub } from "../../context/useAIHub.js";
29
+ import { SystemNotice } from "../SystemNotice/index.js";
30
+ /** Duration of the post-recovery "Resumed." flash, in milliseconds. */
31
+ const RESUMED_FLASH_MS = 2000;
32
+ /**
33
+ * Renders the countdown text by replacing `{seconds}` in the template.
34
+ *
35
+ * @param template - i18n template with `{seconds}` placeholder.
36
+ * @param seconds - integer seconds remaining; floors at 0.
37
+ * @returns the resolved text.
38
+ */
39
+ function renderCountdown(template, seconds) {
40
+ const safe = Math.max(0, Math.floor(seconds));
41
+ return template.replace("{seconds}", String(safe));
42
+ }
43
+ /**
44
+ * Computes seconds-until against an ISO timestamp.
45
+ *
46
+ * @param retryAt - ISO timestamp from `tpm_retry_at`.
47
+ * @param now - epoch ms (test injection point).
48
+ * @returns seconds remaining (>= 0). Returns 0 when `retryAt` is invalid.
49
+ */
50
+ function secondsUntil(retryAt, now) {
51
+ const target = Date.parse(retryAt);
52
+ if (!Number.isFinite(target))
53
+ return 0;
54
+ return Math.max(0, (target - now) / 1000);
55
+ }
56
+ /**
57
+ * Renders the banner.
58
+ *
59
+ * @param props - see `TpmBannerProps`.
60
+ * @returns the rendered banner, or `null` when nothing should render.
61
+ */
62
+ export function TpmBanner(props) {
63
+ const { state, lastTurnError } = useAIHub();
64
+ const texts = resolveAIHubTexts(props.texts);
65
+ // Tick at 1Hz while we're in the wait phase. The interval is
66
+ // re-installed when the deadline changes (new wait) or removed when
67
+ // we leave the wait phase.
68
+ const [, forceTick] = useState(0);
69
+ useEffect(() => {
70
+ if (state.phase !== "waiting_provider")
71
+ return;
72
+ const tick = setInterval(() => {
73
+ forceTick((n) => n + 1);
74
+ }, 1000);
75
+ return () => clearInterval(tick);
76
+ }, [state.phase, state.tpm_retry_at]);
77
+ // Track the *previous* phase so the `running(waiting_provider) →
78
+ // running(model_*)` transition triggers the "Resumed." flash. We hold
79
+ // the flash on the screen for RESUMED_FLASH_MS, then clear.
80
+ const [showResumed, setShowResumed] = useState(false);
81
+ const [prevPhase, setPrevPhase] = useState(state.phase);
82
+ useEffect(() => {
83
+ if (prevPhase === "waiting_provider" &&
84
+ state.phase !== "waiting_provider" &&
85
+ state.status === "running") {
86
+ setShowResumed(true);
87
+ const t = setTimeout(() => setShowResumed(false), RESUMED_FLASH_MS);
88
+ setPrevPhase(state.phase);
89
+ return () => clearTimeout(t);
90
+ }
91
+ setPrevPhase(state.phase);
92
+ return undefined;
93
+ }, [state.phase, state.status]);
94
+ // Wait phase: render `--tpm-wait` with countdown.
95
+ if (state.phase === "waiting_provider" && state.tpm_retry_at) {
96
+ const now = (props.nowProvider ?? Date.now)();
97
+ const remaining = secondsUntil(state.tpm_retry_at, now);
98
+ return (_jsx(SystemNotice, { variant: "tpm-wait", message: renderCountdown(texts.chat.tpmWaitText, remaining), ...(props.className !== undefined ? { className: props.className } : {}) }));
99
+ }
100
+ // Brief "Resumed." flash right after a successful recovery.
101
+ if (showResumed) {
102
+ return (_jsx(SystemNotice, { variant: "resumed", message: texts.chat.systemResumedText, ...(props.className !== undefined ? { className: props.className } : {}) }));
103
+ }
104
+ // Exhausted-error path — the provider sets `lastTurnError` on
105
+ // `error{tpm_exhausted}` + `stream_end{error}`. The retry button only
106
+ // surfaces here (the generic `--failed` Retry button on the message
107
+ // bubble is the equivalent for non-TPM failures).
108
+ if (lastTurnError &&
109
+ lastTurnError.toLowerCase().includes("rate")) {
110
+ return (_jsx(SystemNotice, { variant: "error", message: texts.chat.tpmExhaustedText, ...(props.onRetry !== undefined
111
+ ? { action: { label: texts.chat.tpmRetryButton, onClick: props.onRetry } }
112
+ : {}), ...(props.className !== undefined ? { className: props.className } : {}) }));
113
+ }
114
+ return null;
115
+ }
116
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TpmBanner/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAE5D,OAAO,EACL,iBAAiB,GAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,uEAAuE;AACvE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,OAAe;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;GA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AAE,KAAK,CAAC,IAAI,CAAC,iBAAiB,KACjC,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACzE,CACH,CAAC;IACJ,CAAC;IAED,8DAA8D;IAC9D,sEAAsE;IACtE,oEAAoE;IACpE,kDAAkD;IAClD,IACE,aAAa;QACb,aAAa,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,CAAC;QACD,OAAO,CACL,KAAC,YAAY,IACX,OAAO,EAAC,OAAO,EACf,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,KAChC,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS;gBAC9B,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE;gBAC1E,CAAC,CAAC,EAAE,CAAC,KACH,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACzE,CACH,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * `<TurnStatusIndicator />` — a small `●` dot + short label reflecting the
3
+ * active turn's `(status, phase)`.
4
+ *
5
+ * Pure function of state (via `turnStatusVisual` in `state/affordances.ts`).
6
+ * Two soft-state behaviors are local to the component:
7
+ *
8
+ * 1. **`done` flash.** On the transition `running → done`, the indicator
9
+ * briefly shows "Done" (~2s) and then settles to "Ready" — this is the
10
+ * visual "the turn finished" affordance the predicate table calls for.
11
+ * 2. **`cancelled` auto-clear.** After ~3s the indicator clears back to
12
+ * "Ready" so the cancelled stamp doesn't sit forever in the header.
13
+ *
14
+ * Both timers respect `prefers-reduced-motion` by skipping the pulse
15
+ * animation; the timer logic still runs, but the dot stays static.
16
+ *
17
+ * Rendering is gated by:
18
+ *
19
+ * - the `showTurnStatus` React prop (default true) AND
20
+ * - the `turn_status_visible` server toggle (§8.4) — precedence: server > prop.
21
+ *
22
+ * Both gates are AND-combined in `useAffordanceFlags` upstream so the
23
+ * primitive itself only checks `if (!visible) return null`.
24
+ *
25
+ * Exported under `AIHub.TurnStatusIndicator`.
26
+ *
27
+ * @see SPECIFICATIONS.md §10.4 — predicate table + label map
28
+ * @see ui-sketches/03-chat.md — turn_status_indicator
29
+ */
30
+ import { type ReactNode } from "react";
31
+ import type { AIHubState } from "../../types.js";
32
+ /**
33
+ * BEM class names emitted by `<TurnStatusIndicator />`.
34
+ */
35
+ export interface TurnStatusIndicatorClassNames {
36
+ /** Outer wrapper. */
37
+ root: string;
38
+ /** Dot element — pulse animation hooks here. */
39
+ dot: string;
40
+ /** Modifier on the dot — `--idle` (gray static). */
41
+ dotIdle: string;
42
+ /** Modifier on the dot — `--running` (accent pulsing). */
43
+ dotRunning: string;
44
+ /** Modifier on the dot — `--warning` (yellow pulsing). */
45
+ dotWarning: string;
46
+ /** Modifier on the dot — `--error` (red static). */
47
+ dotError: string;
48
+ /** Modifier added when pulsing is allowed (drops under reduced-motion). */
49
+ dotPulse: string;
50
+ /** Label text. */
51
+ label: string;
52
+ }
53
+ /**
54
+ * Props for `<TurnStatusIndicator />`.
55
+ *
56
+ * `state` is optional — when omitted the component reads it from the
57
+ * provider via `useAIHub()`. Passing it explicitly is useful for the
58
+ * Storybook stories (Step 10 ships them for every cell of the §10.4
59
+ * table) and for the test harness, both of which render the indicator
60
+ * in isolation without a real reducer in scope.
61
+ */
62
+ export interface TurnStatusIndicatorProps {
63
+ /** Override the state read from context (used by stories + tests). */
64
+ state?: AIHubState;
65
+ /** Extra class merged onto the root. */
66
+ className?: string;
67
+ /** Per-element class overrides. */
68
+ classNames?: Partial<TurnStatusIndicatorClassNames>;
69
+ }
70
+ /**
71
+ * Renders the indicator.
72
+ *
73
+ * @param props - see `TurnStatusIndicatorProps`.
74
+ * @returns the rendered indicator.
75
+ */
76
+ export declare function TurnStatusIndicator(props: TurnStatusIndicatorProps): ReactNode;
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TurnStatusIndicator/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAgCD;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACvC,sEAAsE;IACtE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;CACrD;AAaD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,wBAAwB,GAC9B,SAAS,CAyEX"}
@@ -0,0 +1,122 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * `<TurnStatusIndicator />` — a small `●` dot + short label reflecting the
4
+ * active turn's `(status, phase)`.
5
+ *
6
+ * Pure function of state (via `turnStatusVisual` in `state/affordances.ts`).
7
+ * Two soft-state behaviors are local to the component:
8
+ *
9
+ * 1. **`done` flash.** On the transition `running → done`, the indicator
10
+ * briefly shows "Done" (~2s) and then settles to "Ready" — this is the
11
+ * visual "the turn finished" affordance the predicate table calls for.
12
+ * 2. **`cancelled` auto-clear.** After ~3s the indicator clears back to
13
+ * "Ready" so the cancelled stamp doesn't sit forever in the header.
14
+ *
15
+ * Both timers respect `prefers-reduced-motion` by skipping the pulse
16
+ * animation; the timer logic still runs, but the dot stays static.
17
+ *
18
+ * Rendering is gated by:
19
+ *
20
+ * - the `showTurnStatus` React prop (default true) AND
21
+ * - the `turn_status_visible` server toggle (§8.4) — precedence: server > prop.
22
+ *
23
+ * Both gates are AND-combined in `useAffordanceFlags` upstream so the
24
+ * primitive itself only checks `if (!visible) return null`.
25
+ *
26
+ * Exported under `AIHub.TurnStatusIndicator`.
27
+ *
28
+ * @see SPECIFICATIONS.md §10.4 — predicate table + label map
29
+ * @see ui-sketches/03-chat.md — turn_status_indicator
30
+ */
31
+ import { useEffect, useRef, useState } from "react";
32
+ import { useAIHub } from "../../context/useAIHub.js";
33
+ import { turnStatusVisual } from "../../state/affordances.js";
34
+ const DEFAULT_CLASS_NAMES = Object.freeze({
35
+ root: "data-club-ai-hub__turn-status",
36
+ dot: "data-club-ai-hub__turn-status__dot",
37
+ dotIdle: "data-club-ai-hub__turn-status__dot--idle",
38
+ dotRunning: "data-club-ai-hub__turn-status__dot--running",
39
+ dotWarning: "data-club-ai-hub__turn-status__dot--warning",
40
+ dotError: "data-club-ai-hub__turn-status__dot--error",
41
+ dotPulse: "data-club-ai-hub__turn-status__dot--pulse",
42
+ label: "data-club-ai-hub__turn-status__label",
43
+ });
44
+ /**
45
+ * Maps the visual variant to its modifier class.
46
+ */
47
+ function dotModifier(variant, cls) {
48
+ switch (variant) {
49
+ case "running":
50
+ return cls.dotRunning;
51
+ case "warning":
52
+ return cls.dotWarning;
53
+ case "error":
54
+ return cls.dotError;
55
+ case "idle":
56
+ return cls.dotIdle;
57
+ }
58
+ }
59
+ /**
60
+ * Duration of the post-done "Done" flash, in milliseconds. After this
61
+ * expires the indicator settles back to "Ready" (`idle` dot).
62
+ */
63
+ const DONE_FLASH_MS = 2000;
64
+ /**
65
+ * Duration of the post-cancel "Cancelled" stamp, in milliseconds.
66
+ */
67
+ const CANCELLED_CLEAR_MS = 3000;
68
+ /**
69
+ * Renders the indicator.
70
+ *
71
+ * @param props - see `TurnStatusIndicatorProps`.
72
+ * @returns the rendered indicator.
73
+ */
74
+ export function TurnStatusIndicator(props) {
75
+ const ctx = useAIHub();
76
+ const state = props.state ?? ctx.state;
77
+ const cls = { ...DEFAULT_CLASS_NAMES, ...(props.classNames ?? {}) };
78
+ // Capture the *effective* status / phase for rendering. After done /
79
+ // cancelled clear timers expire we treat the state as `idle` so the
80
+ // dot doesn't sit on "Done" forever.
81
+ const [effective, setEffective] = useState({ status: state.status, phase: state.phase });
82
+ // Track the previous status so we know when to start the
83
+ // done/cancelled clear timer (state only updates on transitions).
84
+ const prevStatusRef = useRef(state.status);
85
+ useEffect(() => {
86
+ const prev = prevStatusRef.current;
87
+ prevStatusRef.current = state.status;
88
+ // No timer needed when the status is steady at running or idle.
89
+ if (state.status === prev) {
90
+ setEffective({ status: state.status, phase: state.phase });
91
+ return;
92
+ }
93
+ // Fresh state — lift it.
94
+ setEffective({ status: state.status, phase: state.phase });
95
+ if (state.status === "done") {
96
+ const t = setTimeout(() => {
97
+ setEffective({ status: "idle", phase: null });
98
+ }, DONE_FLASH_MS);
99
+ return () => clearTimeout(t);
100
+ }
101
+ if (state.status === "cancelled") {
102
+ const t = setTimeout(() => {
103
+ setEffective({ status: "idle", phase: null });
104
+ }, CANCELLED_CLEAR_MS);
105
+ return () => clearTimeout(t);
106
+ }
107
+ return undefined;
108
+ }, [state.status, state.phase]);
109
+ const visual = turnStatusVisual(effective.status, effective.phase);
110
+ const rootClass = props.className
111
+ ? `${cls.root} ${props.className}`
112
+ : cls.root;
113
+ const dotClass = [
114
+ cls.dot,
115
+ dotModifier(visual.dot, cls),
116
+ visual.pulse ? cls.dotPulse : null,
117
+ ]
118
+ .filter(Boolean)
119
+ .join(" ");
120
+ return (_jsxs("div", { className: rootClass, "data-testid": "turn-status-indicator", "data-status": effective.status, "data-phase": effective.phase ?? "none", "data-variant": visual.dot, role: "status", "aria-live": "polite", children: [_jsx("span", { className: dotClass, "aria-hidden": "true" }), _jsx("span", { className: cls.label, "data-testid": "turn-status-label", children: visual.label })] }));
121
+ }
122
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TurnStatusIndicator/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AA6B9D,MAAM,mBAAmB,GAAkC,MAAM,CAAC,MAAM,CAAC;IACvE,IAAI,EAAE,+BAA+B;IACrC,GAAG,EAAE,oCAAoC;IACzC,OAAO,EAAE,0CAA0C;IACnD,UAAU,EAAE,6CAA6C;IACzD,UAAU,EAAE,6CAA6C;IACzD,QAAQ,EAAE,2CAA2C;IACrD,QAAQ,EAAE,2CAA2C;IACrD,KAAK,EAAE,sCAAsC;CAC9C,CAAkC,CAAC;AAEpC;;GAEG;AACH,SAAS,WAAW,CAClB,OAAiD,EACjD,GAAkC;IAElC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,SAAS;YACZ,OAAO,GAAG,CAAC,UAAU,CAAC;QACxB,KAAK,SAAS;YACZ,OAAO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