@tai42/studio-sdk 0.2.0

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 (422) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +15 -0
  3. package/README.md +318 -0
  4. package/SECURITY.md +51 -0
  5. package/dist/components/badge.d.ts +13 -0
  6. package/dist/components/badge.d.ts.map +1 -0
  7. package/dist/components/badge.js +14 -0
  8. package/dist/components/badge.js.map +1 -0
  9. package/dist/components/checkbox.d.ts +24 -0
  10. package/dist/components/checkbox.d.ts.map +1 -0
  11. package/dist/components/checkbox.js +31 -0
  12. package/dist/components/checkbox.js.map +1 -0
  13. package/dist/components/code-block.d.ts +7 -0
  14. package/dist/components/code-block.d.ts.map +1 -0
  15. package/dist/components/code-block.js +23 -0
  16. package/dist/components/code-block.js.map +1 -0
  17. package/dist/components/completion-input.d.ts +31 -0
  18. package/dist/components/completion-input.d.ts.map +1 -0
  19. package/dist/components/completion-input.js +61 -0
  20. package/dist/components/completion-input.js.map +1 -0
  21. package/dist/components/components.css +2212 -0
  22. package/dist/components/confirm-dialog.d.ts +40 -0
  23. package/dist/components/confirm-dialog.d.ts.map +1 -0
  24. package/dist/components/confirm-dialog.js +11 -0
  25. package/dist/components/confirm-dialog.js.map +1 -0
  26. package/dist/components/control-styles.d.ts +12 -0
  27. package/dist/components/control-styles.d.ts.map +1 -0
  28. package/dist/components/control-styles.js +14 -0
  29. package/dist/components/control-styles.js.map +1 -0
  30. package/dist/components/copy-field.d.ts +8 -0
  31. package/dist/components/copy-field.d.ts.map +1 -0
  32. package/dist/components/copy-field.js +106 -0
  33. package/dist/components/copy-field.js.map +1 -0
  34. package/dist/components/dialog.d.ts +21 -0
  35. package/dist/components/dialog.d.ts.map +1 -0
  36. package/dist/components/dialog.js +25 -0
  37. package/dist/components/dialog.js.map +1 -0
  38. package/dist/components/drawer.d.ts +22 -0
  39. package/dist/components/drawer.d.ts.map +1 -0
  40. package/dist/components/drawer.js +32 -0
  41. package/dist/components/drawer.js.map +1 -0
  42. package/dist/components/error-boundary.d.ts +33 -0
  43. package/dist/components/error-boundary.d.ts.map +1 -0
  44. package/dist/components/error-boundary.js +36 -0
  45. package/dist/components/error-boundary.js.map +1 -0
  46. package/dist/components/extension-combo-builder.d.ts +70 -0
  47. package/dist/components/extension-combo-builder.d.ts.map +1 -0
  48. package/dist/components/extension-combo-builder.js +154 -0
  49. package/dist/components/extension-combo-builder.js.map +1 -0
  50. package/dist/components/extension-grouping.d.ts +65 -0
  51. package/dist/components/extension-grouping.d.ts.map +1 -0
  52. package/dist/components/extension-grouping.js +78 -0
  53. package/dist/components/extension-grouping.js.map +1 -0
  54. package/dist/components/extension-picker.d.ts +35 -0
  55. package/dist/components/extension-picker.d.ts.map +1 -0
  56. package/dist/components/extension-picker.js +31 -0
  57. package/dist/components/extension-picker.js.map +1 -0
  58. package/dist/components/external-link.d.ts +19 -0
  59. package/dist/components/external-link.d.ts.map +1 -0
  60. package/dist/components/external-link.js +12 -0
  61. package/dist/components/external-link.js.map +1 -0
  62. package/dist/components/field.d.ts +64 -0
  63. package/dist/components/field.d.ts.map +1 -0
  64. package/dist/components/field.js +56 -0
  65. package/dist/components/field.js.map +1 -0
  66. package/dist/components/fleet-report.d.ts +39 -0
  67. package/dist/components/fleet-report.d.ts.map +1 -0
  68. package/dist/components/fleet-report.js +50 -0
  69. package/dist/components/fleet-report.js.map +1 -0
  70. package/dist/components/fonts.css +22 -0
  71. package/dist/components/icons.d.ts +142 -0
  72. package/dist/components/icons.d.ts.map +1 -0
  73. package/dist/components/icons.js +139 -0
  74. package/dist/components/icons.js.map +1 -0
  75. package/dist/components/inputs.d.ts +52 -0
  76. package/dist/components/inputs.d.ts.map +1 -0
  77. package/dist/components/inputs.js +35 -0
  78. package/dist/components/inputs.js.map +1 -0
  79. package/dist/components/json-diff.d.ts +40 -0
  80. package/dist/components/json-diff.d.ts.map +1 -0
  81. package/dist/components/json-diff.js +119 -0
  82. package/dist/components/json-diff.js.map +1 -0
  83. package/dist/components/json-tree.d.ts +8 -0
  84. package/dist/components/json-tree.d.ts.map +1 -0
  85. package/dist/components/json-tree.js +70 -0
  86. package/dist/components/json-tree.js.map +1 -0
  87. package/dist/components/modal-focus.d.ts +15 -0
  88. package/dist/components/modal-focus.d.ts.map +1 -0
  89. package/dist/components/modal-focus.js +136 -0
  90. package/dist/components/modal-focus.js.map +1 -0
  91. package/dist/components/page-header.d.ts +56 -0
  92. package/dist/components/page-header.d.ts.map +1 -0
  93. package/dist/components/page-header.js +24 -0
  94. package/dist/components/page-header.js.map +1 -0
  95. package/dist/components/primitives.d.ts +186 -0
  96. package/dist/components/primitives.d.ts.map +1 -0
  97. package/dist/components/primitives.js +204 -0
  98. package/dist/components/primitives.js.map +1 -0
  99. package/dist/components/progress-bar.d.ts +29 -0
  100. package/dist/components/progress-bar.d.ts.map +1 -0
  101. package/dist/components/progress-bar.js +48 -0
  102. package/dist/components/progress-bar.js.map +1 -0
  103. package/dist/components/radio-group.d.ts +37 -0
  104. package/dist/components/radio-group.d.ts.map +1 -0
  105. package/dist/components/radio-group.js +56 -0
  106. package/dist/components/radio-group.js.map +1 -0
  107. package/dist/components/reveal-input.d.ts +13 -0
  108. package/dist/components/reveal-input.d.ts.map +1 -0
  109. package/dist/components/reveal-input.js +31 -0
  110. package/dist/components/reveal-input.js.map +1 -0
  111. package/dist/components/scroll-region.d.ts +85 -0
  112. package/dist/components/scroll-region.d.ts.map +1 -0
  113. package/dist/components/scroll-region.js +574 -0
  114. package/dist/components/scroll-region.js.map +1 -0
  115. package/dist/components/select.d.ts +53 -0
  116. package/dist/components/select.d.ts.map +1 -0
  117. package/dist/components/select.js +33 -0
  118. package/dist/components/select.js.map +1 -0
  119. package/dist/components/table.d.ts +59 -0
  120. package/dist/components/table.d.ts.map +1 -0
  121. package/dist/components/table.js +20 -0
  122. package/dist/components/table.js.map +1 -0
  123. package/dist/components/tabs.d.ts +15 -0
  124. package/dist/components/tabs.d.ts.map +1 -0
  125. package/dist/components/tabs.js +13 -0
  126. package/dist/components/tabs.js.map +1 -0
  127. package/dist/components/tags.d.ts +46 -0
  128. package/dist/components/tags.d.ts.map +1 -0
  129. package/dist/components/tags.js +68 -0
  130. package/dist/components/tags.js.map +1 -0
  131. package/dist/components/tokens.css +392 -0
  132. package/dist/components/tokens.d.ts +15 -0
  133. package/dist/components/tokens.d.ts.map +1 -0
  134. package/dist/components/tokens.js +101 -0
  135. package/dist/components/tokens.js.map +1 -0
  136. package/dist/components/tool-picker.d.ts +24 -0
  137. package/dist/components/tool-picker.d.ts.map +1 -0
  138. package/dist/components/tool-picker.js +97 -0
  139. package/dist/components/tool-picker.js.map +1 -0
  140. package/dist/components/tooltip.d.ts +17 -0
  141. package/dist/components/tooltip.d.ts.map +1 -0
  142. package/dist/components/tooltip.js +18 -0
  143. package/dist/components/tooltip.js.map +1 -0
  144. package/dist/components/version-history-panel.d.ts +71 -0
  145. package/dist/components/version-history-panel.d.ts.map +1 -0
  146. package/dist/components/version-history-panel.js +148 -0
  147. package/dist/components/version-history-panel.js.map +1 -0
  148. package/dist/download.d.ts +7 -0
  149. package/dist/download.d.ts.map +1 -0
  150. package/dist/download.js +18 -0
  151. package/dist/download.js.map +1 -0
  152. package/dist/element-slot.d.ts +4 -0
  153. package/dist/element-slot.d.ts.map +1 -0
  154. package/dist/element-slot.js +20 -0
  155. package/dist/element-slot.js.map +1 -0
  156. package/dist/elicitation/ElicitationForm.d.ts +34 -0
  157. package/dist/elicitation/ElicitationForm.d.ts.map +1 -0
  158. package/dist/elicitation/ElicitationForm.js +24 -0
  159. package/dist/elicitation/ElicitationForm.js.map +1 -0
  160. package/dist/errors.d.ts +9 -0
  161. package/dist/errors.d.ts.map +1 -0
  162. package/dist/errors.js +15 -0
  163. package/dist/errors.js.map +1 -0
  164. package/dist/extension-combos.d.ts +13 -0
  165. package/dist/extension-combos.d.ts.map +1 -0
  166. package/dist/extension-combos.js +9 -0
  167. package/dist/extension-combos.js.map +1 -0
  168. package/dist/hooks/useApi.d.ts +1222 -0
  169. package/dist/hooks/useApi.d.ts.map +1 -0
  170. package/dist/hooks/useApi.js +22 -0
  171. package/dist/hooks/useApi.js.map +1 -0
  172. package/dist/hooks/useAuth.d.ts +13 -0
  173. package/dist/hooks/useAuth.d.ts.map +1 -0
  174. package/dist/hooks/useAuth.js +53 -0
  175. package/dist/hooks/useAuth.js.map +1 -0
  176. package/dist/hooks/useBreakpoint.d.ts +10 -0
  177. package/dist/hooks/useBreakpoint.d.ts.map +1 -0
  178. package/dist/hooks/useBreakpoint.js +66 -0
  179. package/dist/hooks/useBreakpoint.js.map +1 -0
  180. package/dist/hooks/useCapabilities.d.ts +88 -0
  181. package/dist/hooks/useCapabilities.d.ts.map +1 -0
  182. package/dist/hooks/useCapabilities.js +203 -0
  183. package/dist/hooks/useCapabilities.js.map +1 -0
  184. package/dist/hooks/useSse.d.ts +13 -0
  185. package/dist/hooks/useSse.d.ts.map +1 -0
  186. package/dist/hooks/useSse.js +298 -0
  187. package/dist/hooks/useSse.js.map +1 -0
  188. package/dist/hooks/useTheme.d.ts +20 -0
  189. package/dist/hooks/useTheme.d.ts.map +1 -0
  190. package/dist/hooks/useTheme.js +97 -0
  191. package/dist/hooks/useTheme.js.map +1 -0
  192. package/dist/hooks/useUnauthorized.d.ts +3 -0
  193. package/dist/hooks/useUnauthorized.d.ts.map +1 -0
  194. package/dist/hooks/useUnauthorized.js +18 -0
  195. package/dist/hooks/useUnauthorized.js.map +1 -0
  196. package/dist/host.d.ts +11 -0
  197. package/dist/host.d.ts.map +1 -0
  198. package/dist/host.js +10 -0
  199. package/dist/host.js.map +1 -0
  200. package/dist/index.d.ts +118 -0
  201. package/dist/index.d.ts.map +1 -0
  202. package/dist/index.js +91 -0
  203. package/dist/index.js.map +1 -0
  204. package/dist/navigation/context.d.ts +25 -0
  205. package/dist/navigation/context.d.ts.map +1 -0
  206. package/dist/navigation/context.js +45 -0
  207. package/dist/navigation/context.js.map +1 -0
  208. package/dist/navigation/index.d.ts +4 -0
  209. package/dist/navigation/index.d.ts.map +1 -0
  210. package/dist/navigation/index.js +2 -0
  211. package/dist/navigation/index.js.map +1 -0
  212. package/dist/navigation/types.d.ts +97 -0
  213. package/dist/navigation/types.d.ts.map +1 -0
  214. package/dist/navigation/types.js +16 -0
  215. package/dist/navigation/types.js.map +1 -0
  216. package/dist/plugin/host-state.d.ts +45 -0
  217. package/dist/plugin/host-state.d.ts.map +1 -0
  218. package/dist/plugin/host-state.js +62 -0
  219. package/dist/plugin/host-state.js.map +1 -0
  220. package/dist/plugin/registry.d.ts +35 -0
  221. package/dist/plugin/registry.d.ts.map +1 -0
  222. package/dist/plugin/registry.js +129 -0
  223. package/dist/plugin/registry.js.map +1 -0
  224. package/dist/plugin/types.d.ts +165 -0
  225. package/dist/plugin/types.d.ts.map +1 -0
  226. package/dist/plugin/types.js +2 -0
  227. package/dist/plugin/types.js.map +1 -0
  228. package/dist/plugin/version.d.ts +34 -0
  229. package/dist/plugin/version.d.ts.map +1 -0
  230. package/dist/plugin/version.js +37 -0
  231. package/dist/plugin/version.js.map +1 -0
  232. package/dist/query-keys.d.ts +31 -0
  233. package/dist/query-keys.d.ts.map +1 -0
  234. package/dist/query-keys.js +31 -0
  235. package/dist/query-keys.js.map +1 -0
  236. package/dist/schema-editor/SchemaEditor.d.ts +43 -0
  237. package/dist/schema-editor/SchemaEditor.d.ts.map +1 -0
  238. package/dist/schema-editor/SchemaEditor.js +106 -0
  239. package/dist/schema-editor/SchemaEditor.js.map +1 -0
  240. package/dist/schema-editor/index.d.ts +10 -0
  241. package/dist/schema-editor/index.d.ts.map +1 -0
  242. package/dist/schema-editor/index.js +8 -0
  243. package/dist/schema-editor/index.js.map +1 -0
  244. package/dist/schema-editor/lint.d.ts +37 -0
  245. package/dist/schema-editor/lint.d.ts.map +1 -0
  246. package/dist/schema-editor/lint.js +49 -0
  247. package/dist/schema-editor/lint.js.map +1 -0
  248. package/dist/schema-form/SchemaForm.d.ts +70 -0
  249. package/dist/schema-form/SchemaForm.d.ts.map +1 -0
  250. package/dist/schema-form/SchemaForm.js +13 -0
  251. package/dist/schema-form/SchemaForm.js.map +1 -0
  252. package/dist/schema-form/array-field.d.ts +20 -0
  253. package/dist/schema-form/array-field.d.ts.map +1 -0
  254. package/dist/schema-form/array-field.js +39 -0
  255. package/dist/schema-form/array-field.js.map +1 -0
  256. package/dist/schema-form/classify.d.ts +87 -0
  257. package/dist/schema-form/classify.d.ts.map +1 -0
  258. package/dist/schema-form/classify.js +199 -0
  259. package/dist/schema-form/classify.js.map +1 -0
  260. package/dist/schema-form/context.d.ts +4 -0
  261. package/dist/schema-form/context.d.ts.map +1 -0
  262. package/dist/schema-form/context.js +14 -0
  263. package/dist/schema-form/context.js.map +1 -0
  264. package/dist/schema-form/default-value.d.ts +8 -0
  265. package/dist/schema-form/default-value.d.ts.map +1 -0
  266. package/dist/schema-form/default-value.js +64 -0
  267. package/dist/schema-form/default-value.js.map +1 -0
  268. package/dist/schema-form/enum-field.d.ts +19 -0
  269. package/dist/schema-form/enum-field.d.ts.map +1 -0
  270. package/dist/schema-form/enum-field.js +26 -0
  271. package/dist/schema-form/enum-field.js.map +1 -0
  272. package/dist/schema-form/field-group.d.ts +9 -0
  273. package/dist/schema-form/field-group.d.ts.map +1 -0
  274. package/dist/schema-form/field-group.js +32 -0
  275. package/dist/schema-form/field-group.js.map +1 -0
  276. package/dist/schema-form/field-node.d.ts +24 -0
  277. package/dist/schema-form/field-node.d.ts.map +1 -0
  278. package/dist/schema-form/field-node.js +51 -0
  279. package/dist/schema-form/field-node.js.map +1 -0
  280. package/dist/schema-form/index.d.ts +13 -0
  281. package/dist/schema-form/index.d.ts.map +1 -0
  282. package/dist/schema-form/index.js +11 -0
  283. package/dist/schema-form/index.js.map +1 -0
  284. package/dist/schema-form/media-field.d.ts +24 -0
  285. package/dist/schema-form/media-field.d.ts.map +1 -0
  286. package/dist/schema-form/media-field.js +169 -0
  287. package/dist/schema-form/media-field.js.map +1 -0
  288. package/dist/schema-form/media.d.ts +40 -0
  289. package/dist/schema-form/media.d.ts.map +1 -0
  290. package/dist/schema-form/media.js +65 -0
  291. package/dist/schema-form/media.js.map +1 -0
  292. package/dist/schema-form/object-fields.d.ts +20 -0
  293. package/dist/schema-form/object-fields.d.ts.map +1 -0
  294. package/dist/schema-form/object-fields.js +24 -0
  295. package/dist/schema-form/object-fields.js.map +1 -0
  296. package/dist/schema-form/resolve.d.ts +41 -0
  297. package/dist/schema-form/resolve.d.ts.map +1 -0
  298. package/dist/schema-form/resolve.js +102 -0
  299. package/dist/schema-form/resolve.js.map +1 -0
  300. package/dist/schema-form/string-field.d.ts +20 -0
  301. package/dist/schema-form/string-field.d.ts.map +1 -0
  302. package/dist/schema-form/string-field.js +68 -0
  303. package/dist/schema-form/string-field.js.map +1 -0
  304. package/dist/schema-form/styles.d.ts +18 -0
  305. package/dist/schema-form/styles.d.ts.map +1 -0
  306. package/dist/schema-form/styles.js +18 -0
  307. package/dist/schema-form/styles.js.map +1 -0
  308. package/dist/schema-form/types.d.ts +67 -0
  309. package/dist/schema-form/types.d.ts.map +1 -0
  310. package/dist/schema-form/types.js +10 -0
  311. package/dist/schema-form/types.js.map +1 -0
  312. package/dist/schema-form/union-field.d.ts +24 -0
  313. package/dist/schema-form/union-field.d.ts.map +1 -0
  314. package/dist/schema-form/union-field.js +55 -0
  315. package/dist/schema-form/union-field.js.map +1 -0
  316. package/dist/schema-form/union.d.ts +4 -0
  317. package/dist/schema-form/union.d.ts.map +1 -0
  318. package/dist/schema-form/union.js +68 -0
  319. package/dist/schema-form/union.js.map +1 -0
  320. package/dist/schema-form/unsupported-notice.d.ts +18 -0
  321. package/dist/schema-form/unsupported-notice.d.ts.map +1 -0
  322. package/dist/schema-form/unsupported-notice.js +8 -0
  323. package/dist/schema-form/unsupported-notice.js.map +1 -0
  324. package/dist/schema-form/validate.d.ts +18 -0
  325. package/dist/schema-form/validate.d.ts.map +1 -0
  326. package/dist/schema-form/validate.js +162 -0
  327. package/dist/schema-form/validate.js.map +1 -0
  328. package/dist/structured-output/StructuredOutput.d.ts +27 -0
  329. package/dist/structured-output/StructuredOutput.d.ts.map +1 -0
  330. package/dist/structured-output/StructuredOutput.js +41 -0
  331. package/dist/structured-output/StructuredOutput.js.map +1 -0
  332. package/dist/testing.d.ts +80 -0
  333. package/dist/testing.d.ts.map +1 -0
  334. package/dist/testing.js +207 -0
  335. package/dist/testing.js.map +1 -0
  336. package/package.json +101 -0
  337. package/src/components/badge.tsx +31 -0
  338. package/src/components/checkbox.tsx +93 -0
  339. package/src/components/code-block.tsx +37 -0
  340. package/src/components/completion-input.tsx +137 -0
  341. package/src/components/components.css +2212 -0
  342. package/src/components/confirm-dialog.tsx +77 -0
  343. package/src/components/control-styles.ts +14 -0
  344. package/src/components/copy-field.tsx +178 -0
  345. package/src/components/dialog.tsx +76 -0
  346. package/src/components/drawer.tsx +83 -0
  347. package/src/components/error-boundary.tsx +56 -0
  348. package/src/components/extension-combo-builder.tsx +305 -0
  349. package/src/components/extension-grouping.ts +116 -0
  350. package/src/components/extension-picker.tsx +97 -0
  351. package/src/components/external-link.tsx +40 -0
  352. package/src/components/field.tsx +169 -0
  353. package/src/components/fleet-report.tsx +136 -0
  354. package/src/components/fonts.css +22 -0
  355. package/src/components/icons.tsx +504 -0
  356. package/src/components/inputs.tsx +125 -0
  357. package/src/components/json-diff.tsx +192 -0
  358. package/src/components/json-tree.tsx +129 -0
  359. package/src/components/modal-focus.ts +150 -0
  360. package/src/components/page-header.tsx +107 -0
  361. package/src/components/primitives.tsx +489 -0
  362. package/src/components/progress-bar.tsx +100 -0
  363. package/src/components/radio-group.tsx +160 -0
  364. package/src/components/reveal-input.tsx +87 -0
  365. package/src/components/scroll-region.tsx +703 -0
  366. package/src/components/select.tsx +149 -0
  367. package/src/components/table.tsx +94 -0
  368. package/src/components/tabs.tsx +51 -0
  369. package/src/components/tags.tsx +137 -0
  370. package/src/components/tokens.css +392 -0
  371. package/src/components/tokens.ts +102 -0
  372. package/src/components/tool-picker.tsx +175 -0
  373. package/src/components/tooltip.tsx +46 -0
  374. package/src/components/version-history-panel.tsx +407 -0
  375. package/src/css.d.ts +2 -0
  376. package/src/download.ts +17 -0
  377. package/src/element-slot.ts +22 -0
  378. package/src/elicitation/ElicitationForm.tsx +87 -0
  379. package/src/errors.ts +12 -0
  380. package/src/extension-combos.ts +18 -0
  381. package/src/hooks/useApi.ts +27 -0
  382. package/src/hooks/useAuth.ts +67 -0
  383. package/src/hooks/useBreakpoint.ts +78 -0
  384. package/src/hooks/useCapabilities.ts +242 -0
  385. package/src/hooks/useSse.ts +314 -0
  386. package/src/hooks/useTheme.ts +133 -0
  387. package/src/hooks/useUnauthorized.ts +20 -0
  388. package/src/host.ts +15 -0
  389. package/src/index.ts +267 -0
  390. package/src/navigation/context.tsx +90 -0
  391. package/src/navigation/index.ts +9 -0
  392. package/src/navigation/types.ts +90 -0
  393. package/src/plugin/host-state.ts +93 -0
  394. package/src/plugin/registry.ts +174 -0
  395. package/src/plugin/types.ts +178 -0
  396. package/src/plugin/version.ts +44 -0
  397. package/src/query-keys.ts +34 -0
  398. package/src/schema-editor/SchemaEditor.tsx +186 -0
  399. package/src/schema-editor/index.ts +9 -0
  400. package/src/schema-editor/lint.ts +70 -0
  401. package/src/schema-form/SchemaForm.tsx +107 -0
  402. package/src/schema-form/array-field.tsx +110 -0
  403. package/src/schema-form/classify.ts +302 -0
  404. package/src/schema-form/context.ts +17 -0
  405. package/src/schema-form/default-value.ts +65 -0
  406. package/src/schema-form/enum-field.tsx +65 -0
  407. package/src/schema-form/field-group.tsx +71 -0
  408. package/src/schema-form/field-node.tsx +161 -0
  409. package/src/schema-form/index.ts +12 -0
  410. package/src/schema-form/media-field.tsx +281 -0
  411. package/src/schema-form/media.ts +69 -0
  412. package/src/schema-form/object-fields.tsx +74 -0
  413. package/src/schema-form/resolve.ts +114 -0
  414. package/src/schema-form/string-field.tsx +161 -0
  415. package/src/schema-form/styles.ts +20 -0
  416. package/src/schema-form/types.ts +71 -0
  417. package/src/schema-form/union-field.tsx +122 -0
  418. package/src/schema-form/union.ts +78 -0
  419. package/src/schema-form/unsupported-notice.tsx +39 -0
  420. package/src/schema-form/validate.ts +183 -0
  421. package/src/structured-output/StructuredOutput.tsx +81 -0
  422. package/src/testing.ts +235 -0
@@ -0,0 +1,298 @@
1
+ /**
2
+ * `useSse` — the live interactions stream, implemented over the api-client's
3
+ * `streamInteractions` (fetch + ReadableStream, never EventSource).
4
+ *
5
+ * SSE event contract: events `interaction.add` /
6
+ * `interaction.answered` / `interaction.removed` / `interaction.backlog_done`.
7
+ * The `add` frame (backlog on connect + live tail) carries the full question;
8
+ * `answered` / `removed` frames carry only ids. On (re)connect the server
9
+ * replays the current pending set as the backlog; this hook treats that backlog
10
+ * as authoritative — an entry not re-seen by `interaction.backlog_done` is
11
+ * dropped, so an interaction removed while the client was disconnected does not
12
+ * linger. `add` frames are at-least-once, so entries are de-duplicated by
13
+ * `interaction_id`, and a redelivered `add` preserves the client `answered` flag.
14
+ *
15
+ * The `Interaction` type is imported type-only (no runtime dep on api-client);
16
+ * frames are validated defensively and a malformed frame is surfaced as an error,
17
+ * never rendered as a silent blank. `answered` is not a wire field — it is a
18
+ * client flag this hook flips on an `interaction.answered` event.
19
+ */
20
+ import { useEffect, useRef, useState } from 'react';
21
+ import { useApi } from './useApi';
22
+ import { useOnUnauthorized } from './useUnauthorized';
23
+ // Reconnect backoff: capped exponential with full jitter. The delay for attempt
24
+ // n is a random value in [0, min(CAP, BASE * 2**n)); the attempt counter resets
25
+ // only when a connection is proven healthy (`interaction.backlog_done`), not when
26
+ // it merely opens — so a flapping server that accepts the request then drops the
27
+ // body still backs off instead of tight-looping. A healthy tail-reconnect is
28
+ // near-instant while a sustained outage backs off, and the jitter spreads many
29
+ // clients apart rather than retrying in lockstep.
30
+ const RECONNECT_BASE_MS = 1500;
31
+ const RECONNECT_CAP_MS = 30000;
32
+ // The wire `answer_format` values. Duplicated from the api-client enum by design:
33
+ // the SDK is the leaf and must not import api-client at runtime. The `satisfies`
34
+ // pin against `Interaction['answer_format']` fails to compile if a listed value
35
+ // leaves the union, so this runtime guard cannot silently drift from the type.
36
+ const ANSWER_FORMATS = new Set([
37
+ 'text',
38
+ 'confirm',
39
+ 'select',
40
+ 'form',
41
+ 'external',
42
+ ]);
43
+ function isRecord(value) {
44
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
45
+ }
46
+ /** Parse a frame's JSON to a plain object, or null when it is not one. */
47
+ function parseJson(data) {
48
+ if (!data)
49
+ return null;
50
+ try {
51
+ const obj = JSON.parse(data);
52
+ return isRecord(obj) ? obj : null;
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ }
58
+ /**
59
+ * Validate an `interaction.add` frame into an `Interaction`, or null when it is
60
+ * malformed. This mirrors the api-client `interaction` zod schema exactly — it
61
+ * accepts what that schema accepts, no more, no less. The strict-required fields
62
+ * — `interaction_id`, `group_id`, `created_at`, `timeout_at` — must be a string
63
+ * and `answer_format` a known enum value; any missing or non-string one returns
64
+ * null so the caller surfaces it as an error rather than rendering a blank card.
65
+ * Two fields are laxer, matching the schema: `question` is
66
+ * `z.string().default('')`, whose default substitutes ONLY an absent/undefined
67
+ * value, so a missing question normalizes to `''` while a present `null` (or any
68
+ * present non-string) is rejected; `format_payload` is nullish, so an absent/null
69
+ * value (text/confirm carry none) normalizes to `{}` while a present non-object is
70
+ * rejected — never silently coerced to a blank card.
71
+ */
72
+ function parseAddFrame(data) {
73
+ const obj = parseJson(data);
74
+ if (obj === null)
75
+ return null;
76
+ const { interaction_id, group_id, question, answer_format, format_payload, created_at, timeout_at, sensitive, server_verified, channel, media, } = obj;
77
+ if (typeof interaction_id !== 'string')
78
+ return null;
79
+ if (typeof group_id !== 'string')
80
+ return null;
81
+ // `question` is z.string().default('') in the schema: the default substitutes
82
+ // ONLY an absent/undefined value, so a missing question is valid while a
83
+ // present null (or any other present non-string) is malformed.
84
+ if (question !== undefined && typeof question !== 'string')
85
+ return null;
86
+ if (typeof created_at !== 'string')
87
+ return null;
88
+ if (typeof timeout_at !== 'string')
89
+ return null;
90
+ if (typeof answer_format !== 'string' || !ANSWER_FORMATS.has(answer_format))
91
+ return null;
92
+ // `format_payload` is nullish in the schema: absent/null normalizes to {}, but
93
+ // a present non-object is malformed and must not be coerced to a blank card.
94
+ if (format_payload != null && !isRecord(format_payload))
95
+ return null;
96
+ // `sensitive` is z.boolean().default(false): an absent value normalizes to
97
+ // false, while a present non-boolean is malformed.
98
+ if (sensitive !== undefined && typeof sensitive !== 'boolean')
99
+ return null;
100
+ // `server_verified` is z.boolean().optional(): an absent value stays undefined,
101
+ // while a present non-boolean is malformed.
102
+ if (server_verified !== undefined && typeof server_verified !== 'boolean')
103
+ return null;
104
+ // `channel` is z.string().optional(): the delivery-channel name rides the frame
105
+ // only for a channel-delivered question; absent stays undefined, a present
106
+ // non-string is malformed.
107
+ if (channel !== undefined && typeof channel !== 'string')
108
+ return null;
109
+ // `media` is z.array(z.unknown()).optional(): the display-only media rides the
110
+ // frame only when the question carries some; absent stays undefined, a present
111
+ // non-array is malformed. The ITEMS stay unknown here (loose by design) — each is
112
+ // validated per item by the renderer, so one bad item never fails this frame.
113
+ if (media !== undefined && !Array.isArray(media))
114
+ return null;
115
+ return {
116
+ interaction_id,
117
+ group_id,
118
+ question: typeof question === 'string' ? question : '',
119
+ answer_format: answer_format,
120
+ format_payload: isRecord(format_payload) ? format_payload : {},
121
+ created_at,
122
+ timeout_at,
123
+ sensitive: sensitive ?? false,
124
+ ...(typeof server_verified === 'boolean' ? { server_verified } : {}),
125
+ ...(typeof channel === 'string' ? { channel } : {}),
126
+ ...(Array.isArray(media) ? { media } : {}),
127
+ };
128
+ }
129
+ /** The interaction id from an `answered` / `removed` frame, or null. */
130
+ function parseId(data) {
131
+ const id = parseJson(data)?.interaction_id;
132
+ return typeof id === 'string' ? id : null;
133
+ }
134
+ export function useInteractionsStream() {
135
+ const api = useApi();
136
+ const onUnauthorized = useOnUnauthorized();
137
+ const [state, setState] = useState({
138
+ interactions: [],
139
+ connected: false,
140
+ backlogLoaded: false,
141
+ error: null,
142
+ });
143
+ // Source of truth: a dedupe map keyed by interaction_id, rebuilt into the
144
+ // ordered array on every change.
145
+ const mapRef = useRef(new Map());
146
+ useEffect(() => {
147
+ const controller = new AbortController();
148
+ const aborted = () => controller.signal.aborted;
149
+ // A successful data frame rebuilds the list and clears any transient
150
+ // frame-parse error — one bad frame on a healthy stream must not stick.
151
+ const publish = () => {
152
+ setState((prev) => ({
153
+ ...prev,
154
+ interactions: Array.from(mapRef.current.values()),
155
+ error: null,
156
+ }));
157
+ };
158
+ const surfaceMalformed = (event) => {
159
+ setState((prev) => ({ ...prev, error: new Error(`malformed interaction frame: ${event}`) }));
160
+ };
161
+ // Per-connection reconcile state: the replayed backlog is authoritative, so
162
+ // ids not re-seen by `interaction.backlog_done` are dropped as
163
+ // removed-while-disconnected.
164
+ let reconciling = false;
165
+ let seenInBacklog = new Set();
166
+ // Consecutive failed reconnect attempts. Reset only when a connection proves
167
+ // healthy (`interaction.backlog_done`), NOT merely when it opens — a server
168
+ // that accepts the request then drops the body would otherwise reset every
169
+ // time and never back off.
170
+ let reconnectAttempt = 0;
171
+ const beginConnection = () => {
172
+ reconciling = true;
173
+ seenInBacklog = new Set();
174
+ };
175
+ const applyFrame = (event, data) => {
176
+ if (event === 'interaction.backlog_done') {
177
+ if (reconciling) {
178
+ for (const id of mapRef.current.keys()) {
179
+ if (!seenInBacklog.has(id))
180
+ mapRef.current.delete(id);
181
+ }
182
+ reconciling = false;
183
+ }
184
+ // A completed backlog is proof the connection is healthy — clear the
185
+ // reconnect backoff so the next drop reconnects promptly.
186
+ reconnectAttempt = 0;
187
+ setState((prev) => ({
188
+ ...prev,
189
+ interactions: Array.from(mapRef.current.values()),
190
+ backlogLoaded: true,
191
+ }));
192
+ return;
193
+ }
194
+ if (event === 'interaction.removed') {
195
+ const id = parseId(data);
196
+ if (id === null) {
197
+ surfaceMalformed(event);
198
+ return;
199
+ }
200
+ mapRef.current.delete(id);
201
+ publish();
202
+ return;
203
+ }
204
+ if (event === 'interaction.answered') {
205
+ const id = parseId(data);
206
+ if (id === null) {
207
+ surfaceMalformed(event);
208
+ return;
209
+ }
210
+ // The answered frame carries only ids — flip the existing item's flag,
211
+ // keeping its question/format. An answered event for an item we never saw
212
+ // has nothing to show.
213
+ const existing = mapRef.current.get(id);
214
+ if (existing)
215
+ mapRef.current.set(id, { ...existing, answered: true });
216
+ publish();
217
+ return;
218
+ }
219
+ // interaction.add — the full question.
220
+ const interaction = parseAddFrame(data);
221
+ if (interaction === null) {
222
+ surfaceMalformed(event);
223
+ return;
224
+ }
225
+ if (reconciling)
226
+ seenInBacklog.add(interaction.interaction_id);
227
+ // Dedupe by id; a redelivered add preserves the client answered flag so a
228
+ // prior `answered` is not undone by an at-least-once replay.
229
+ const existing = mapRef.current.get(interaction.interaction_id);
230
+ mapRef.current.set(interaction.interaction_id, {
231
+ ...interaction,
232
+ answered: existing?.answered ?? false,
233
+ });
234
+ publish();
235
+ };
236
+ // The abort signal is the single cancellation source of truth: the cleanup
237
+ // aborts it, and every loop guard reads it fresh.
238
+ const run = async () => {
239
+ while (!aborted()) {
240
+ try {
241
+ const frames = await api.streamInteractions(controller.signal);
242
+ if (aborted())
243
+ return;
244
+ beginConnection();
245
+ setState((prev) => ({ ...prev, connected: true, error: null }));
246
+ for await (const frame of frames) {
247
+ if (aborted())
248
+ return;
249
+ applyFrame(frame.event, frame.data);
250
+ }
251
+ }
252
+ catch (err) {
253
+ if (aborted())
254
+ return;
255
+ const error = err instanceof Error ? err : new Error(String(err));
256
+ setState((prev) => ({ ...prev, connected: false, error }));
257
+ if (error.name === 'ApiUnauthorizedError') {
258
+ // A 401 means the stored credential is dead — reconnecting would just
259
+ // replay the same bad key every delay forever. Treat it as terminal
260
+ // and hand off to the app's 401→login handler, the same path every
261
+ // other data call takes; do not loop.
262
+ onUnauthorized();
263
+ return;
264
+ }
265
+ }
266
+ // Stream ended or errored → wait, then reconnect (server replays backlog).
267
+ // Guard before the setState, like every other setState in run(): a
268
+ // microtask scheduled after the `for await` must not write state after
269
+ // the effect cleanup has aborted (and unmounted) the hook.
270
+ if (aborted())
271
+ return;
272
+ setState((prev) => ({ ...prev, connected: false }));
273
+ const ceiling = Math.min(RECONNECT_CAP_MS, RECONNECT_BASE_MS * 2 ** reconnectAttempt);
274
+ const delay = Math.random() * ceiling;
275
+ reconnectAttempt += 1;
276
+ await new Promise((resolve) => {
277
+ const onAbort = () => {
278
+ clearTimeout(timer);
279
+ resolve();
280
+ };
281
+ const timer = setTimeout(() => {
282
+ // Normal wake: drop the abort listener so it does not accumulate
283
+ // across reconnects ({ once: true } only self-removes on firing).
284
+ controller.signal.removeEventListener('abort', onAbort);
285
+ resolve();
286
+ }, delay);
287
+ controller.signal.addEventListener('abort', onAbort, { once: true });
288
+ });
289
+ }
290
+ };
291
+ void run();
292
+ return () => {
293
+ controller.abort();
294
+ };
295
+ }, [api, onUnauthorized]);
296
+ return state;
297
+ }
298
+ //# sourceMappingURL=useSse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSse.js","sourceRoot":"","sources":["../../src/hooks/useSse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAYtD,gFAAgF;AAChF,gFAAgF;AAChF,kFAAkF;AAClF,iFAAiF;AACjF,6EAA6E;AAC7E,+EAA+E;AAC/E,kDAAkD;AAClD,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,kFAAkF;AAClF,iFAAiF;AACjF,gFAAgF;AAChF,+EAA+E;AAC/E,MAAM,cAAc,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AAC;QAEF,KAAK,GAAG,EAAE,CAAC;QACX,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC;IAE1B,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from 'react';
2
+ export type Theme = 'light' | 'dark';
3
+ export type ThemePreference = 'light' | 'dark' | 'system';
4
+ export interface ThemeState {
5
+ /** The resolved theme the tokens key off — always concrete, never `'system'`. */
6
+ readonly theme: Theme;
7
+ /** The operator's choice: a pinned theme, or `'system'` to follow the OS. */
8
+ readonly preference: ThemePreference;
9
+ /** Set the preference and persist it. The only path that writes storage. */
10
+ readonly setPreference: (preference: ThemePreference) => void;
11
+ /** Pin an explicit theme (persists) — a preference shortcut kept for callers. */
12
+ readonly setTheme: (theme: Theme) => void;
13
+ /** Flip between the two pinned themes off the current resolved theme (persists). */
14
+ readonly toggle: () => void;
15
+ }
16
+ export declare function ThemeProvider({ children }: {
17
+ children: ReactNode;
18
+ }): import("react").FunctionComponentElement<import("react").ProviderProps<ThemeState | null>>;
19
+ export declare function useTheme(): ThemeState;
20
+ //# sourceMappingURL=useTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE1D,MAAM,WAAW,UAAU;IACzB,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,4EAA4E;IAC5E,QAAQ,CAAC,aAAa,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,IAAI,CAAC;IAC9D,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC1C,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AA4BD,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,8FA0DlE;AAED,wBAAgB,QAAQ,IAAI,UAAU,CAIrC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * `useTheme` — light/dark theme, token-driven. The active theme stamps
3
+ * `data-theme` on the document root, which the DS token layers key off.
4
+ *
5
+ * A three-state PREFERENCE sits behind the resolved theme: `'light'` and
6
+ * `'dark'` pin it, `'system'` follows `prefers-color-scheme` and tracks OS
7
+ * changes live. The resolved `theme` a consumer reads is always the concrete
8
+ * `'light' | 'dark'` the tokens need — never `'system'`.
9
+ *
10
+ * The preference persists to `localStorage`, but ONLY when the operator sets it
11
+ * explicitly (`setPreference` / `setTheme` / `toggle`). Boot READS the stored
12
+ * value; it never WRITES one, so a session that only ever renders the app leaves
13
+ * storage untouched. A `'system'` preference clears any pinned choice and hands
14
+ * the theme back to the OS.
15
+ */
16
+ import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useState, } from 'react';
17
+ const ThemeContext = createContext(null);
18
+ /** Where the explicit preference is stored between sessions. */
19
+ const STORAGE_KEY = 'tai-studio.theme-preference';
20
+ function systemTheme() {
21
+ try {
22
+ return globalThis.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
23
+ }
24
+ catch {
25
+ return 'light';
26
+ }
27
+ }
28
+ /** The persisted preference, or `'system'` when none is stored or storage is
29
+ * unavailable. A READ only — boot never writes, so an untouched session leaves
30
+ * storage alone (the login flows depend on this). */
31
+ function readStoredPreference() {
32
+ try {
33
+ const raw = globalThis.localStorage.getItem(STORAGE_KEY);
34
+ if (raw === 'light' || raw === 'dark' || raw === 'system')
35
+ return raw;
36
+ }
37
+ catch {
38
+ // No storage (private mode / non-browser) — the OS preference is the default.
39
+ }
40
+ return 'system';
41
+ }
42
+ export function ThemeProvider({ children }) {
43
+ const [preference, setPreferenceState] = useState(readStoredPreference);
44
+ // The live OS resolution, kept current by the listener below; it only feeds the
45
+ // resolved theme while the preference is `'system'`.
46
+ const [systemResolved, setSystemResolved] = useState(systemTheme);
47
+ const theme = preference === 'system' ? systemResolved : preference;
48
+ useEffect(() => {
49
+ globalThis.document.documentElement.setAttribute('data-theme', theme);
50
+ }, [theme]);
51
+ // Track the OS preference live, but ONLY while following it. The same defensive
52
+ // guard as `systemTheme()` — jsdom has no `matchMedia`, so subscribing is
53
+ // best-effort and its absence simply leaves the last resolved value in place.
54
+ useEffect(() => {
55
+ if (preference !== 'system')
56
+ return;
57
+ let query;
58
+ try {
59
+ query = globalThis.matchMedia('(prefers-color-scheme: dark)');
60
+ }
61
+ catch {
62
+ return;
63
+ }
64
+ setSystemResolved(query.matches ? 'dark' : 'light');
65
+ const onChange = (event) => {
66
+ setSystemResolved(event.matches ? 'dark' : 'light');
67
+ };
68
+ query.addEventListener('change', onChange);
69
+ return () => {
70
+ query.removeEventListener('change', onChange);
71
+ };
72
+ }, [preference]);
73
+ const setPreference = useCallback((next) => {
74
+ setPreferenceState(next);
75
+ try {
76
+ globalThis.localStorage.setItem(STORAGE_KEY, next);
77
+ }
78
+ catch {
79
+ // Storage unavailable — the choice still applies for this session in memory.
80
+ }
81
+ }, []);
82
+ const setTheme = useCallback((next) => {
83
+ setPreference(next);
84
+ }, [setPreference]);
85
+ const toggle = useCallback(() => {
86
+ setPreference(theme === 'dark' ? 'light' : 'dark');
87
+ }, [setPreference, theme]);
88
+ const value = useMemo(() => ({ theme, preference, setPreference, setTheme, toggle }), [theme, preference, setPreference, setTheme, toggle]);
89
+ return createElement(ThemeContext.Provider, { value }, children);
90
+ }
91
+ export function useTheme() {
92
+ const state = useContext(ThemeContext);
93
+ if (state === null)
94
+ throw new Error('useTheme must be used within a <ThemeProvider>');
95
+ return state;
96
+ }
97
+ //# sourceMappingURL=useTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AAmBf,MAAM,YAAY,GAAG,aAAa,CAAoB,IAAI,CAAC,CAAC;AAE5D,gEAAgE;AAChE,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAElD,SAAS,WAAW;IAClB,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC1F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;qDAEqD;AACrD,SAAS,oBAAoB;IAC3B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACzD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,8EAA8E;IAChF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAA2B;IACjE,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAkB,oBAAoB,CAAC,CAAC;IACzF,gFAAgF;IAChF,qDAAqD;IACrD,MAAM,CAAC,cAAc,EAAE,iBAAi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AAW,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,6EAA6E;QAC/E,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,IAAW,EAAE,EAAE;QACd,aAAa,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,aAAa,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;IAE3B,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EAC9D,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,CACrD,CAAC;IAEF,OAAO,aAAa,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACvC,IAAI,KAAK,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACtF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const UnauthorizedProvider: import("react").Provider<() => void>;
2
+ export declare function useOnUnauthorized(): () => void;
3
+ //# sourceMappingURL=useUnauthorized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUnauthorized.d.ts","sourceRoot":"","sources":["../../src/hooks/useUnauthorized.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,oBAAoB,iCAFe,IAAI,CAEY,CAAC;AAEjE,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CAE9C"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `useOnUnauthorized` — the app's "the credential is dead, route to login" handler,
3
+ * provided through an SDK-owned context so shared hooks can reach it without a
4
+ * runtime dependency on the shell or the router.
5
+ *
6
+ * The default is a no-op, so a consumer rendered without a provider (a test, or a
7
+ * plugin in isolation) still works — it just does not route. The shell wires the
8
+ * real handler (the same one the api-client's 401 path drives) so a 401 raised
9
+ * OUTSIDE TanStack Query — notably the raw interactions SSE fetch — lands on the
10
+ * one login-routing path instead of being retried against a known-bad key.
11
+ */
12
+ import { createContext, useContext } from 'react';
13
+ const UnauthorizedContext = createContext(() => undefined);
14
+ export const UnauthorizedProvider = UnauthorizedContext.Provider;
15
+ export function useOnUnauthorized() {
16
+ return useContext(UnauthorizedContext);
17
+ }
18
+ //# sourceMappingURL=useUnauthorized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUnauthorized.js","sourceRoot":"","sources":["../../src/hooks/useUnauthorized.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,mBAAmB,GAAG,aAAa,CAAa,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAEvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,QAAQ,CAAC;AAEjE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC"}
package/dist/host.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @tai42/studio-sdk/host — the HOST-ONLY registry API. `loadPlugin` (the one entry
3
+ * through which a plugin's `register` contributes) and `getContributions` (what the
4
+ * shell reads) live here, apart from the plugin surface, so the served plugin asset
5
+ * carries no way to forge, wipe, or enumerate the registry. Only the host bundle
6
+ * imports this. See SECURITY.md for the trust boundary.
7
+ */
8
+ export { loadPlugin, getContributions } from './plugin/registry';
9
+ export { setPluginHostState, getPluginHostState, subscribePluginHost, usePluginContributions, } from './plugin/host-state';
10
+ export type { PluginLoaderState, PluginContributionsSnapshot } from './plugin/host-state';
11
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/host.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @tai42/studio-sdk/host — the HOST-ONLY registry API. `loadPlugin` (the one entry
3
+ * through which a plugin's `register` contributes) and `getContributions` (what the
4
+ * shell reads) live here, apart from the plugin surface, so the served plugin asset
5
+ * carries no way to forge, wipe, or enumerate the registry. Only the host bundle
6
+ * imports this. See SECURITY.md for the trust boundary.
7
+ */
8
+ export { loadPlugin, getContributions } from './plugin/registry';
9
+ export { setPluginHostState, getPluginHostState, subscribePluginHost, usePluginContributions, } from './plugin/host-state';
10
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @tai42/studio-sdk — the PLUGIN SURFACE: everything a Studio plugin (and every
3
+ * feature) is allowed to touch.
4
+ *
5
+ * 1. The STUDIO-PLUGIN API a plugin implements: the `PluginContext` its `register`
6
+ * entry receives, the contribution types, and the compatibility gate.
7
+ * 2. The design system + hooks every feature (and every plugin) builds on.
8
+ *
9
+ * The host registry (`loadPlugin`/`getContributions`) is DELIBERATELY absent here
10
+ * so the served plugin asset cannot forge, wipe, or enumerate the registry; it is
11
+ * exported only from `@tai42/studio-sdk/host`, which the host bundle imports. See
12
+ * SECURITY.md for the trust boundary.
13
+ *
14
+ * The three shared modules (react, react-dom, @tai42/studio-sdk) are singletons
15
+ * across the plugin boundary; this package imports nothing internal at runtime
16
+ * (the `ApiClient`/`Interaction` types are type-only imports).
17
+ */
18
+ import './components/tokens.css';
19
+ import './components/fonts.css';
20
+ import './components/components.css';
21
+ export type { PluginContext, PluginEntry, ToolPanelProps, PluginPageProps, SettingsTabProps, ToolPanelContribution, PageContribution, RegisteredPage, SettingsTabContribution, RegisteredSettingsTab, NavEntryContribution, RegisteredNavEntry, PluginContributions, RequiredCapabilities, } from './plugin/types';
22
+ export { STUDIO_PLUGIN_API_VERSION, checkPluginApiVersion } from './plugin/version';
23
+ export type { VersionGateResult } from './plugin/version';
24
+ export { ApiProvider, useApi } from './hooks/useApi';
25
+ export type { ApiClient } from './hooks/useApi';
26
+ export { UnauthorizedProvider, useOnUnauthorized } from './hooks/useUnauthorized';
27
+ export { AuthProvider, useAuth } from './hooks/useAuth';
28
+ export type { AuthState } from './hooks/useAuth';
29
+ export { CapabilityProvider, useCapabilities, useCanWrite, isFullProjection, coversAnyRoute, coversRoute, coversWrite, } from './hooks/useCapabilities';
30
+ export type { CapabilityState, CapabilityContextValue } from './hooks/useCapabilities';
31
+ export { ThemeProvider, useTheme } from './hooks/useTheme';
32
+ export type { Theme, ThemePreference, ThemeState } from './hooks/useTheme';
33
+ export { useBreakpoint } from './hooks/useBreakpoint';
34
+ export type { Breakpoint, BreakpointState } from './hooks/useBreakpoint';
35
+ export { useInteractionsStream } from './hooks/useSse';
36
+ export type { InteractionsStreamState, StreamInteraction } from './hooks/useSse';
37
+ export { NavigationProvider, AppLink, useAppNavigate, useResolvePath } from './navigation';
38
+ export type { AppLinkProps, RouteToken, RouteSearch, RouteSearchByToken, PageProps, NavigationContextValue, } from './navigation';
39
+ export { errorMessage } from './errors';
40
+ export { downloadBlob } from './download';
41
+ export { toolsListKey, extensionsQueryKey, subMcpKey, tokensPayloadKey } from './query-keys';
42
+ export { comboElementNames, extensionElementName } from './extension-combos';
43
+ export { Button, Card, Skeleton, EmptyState, ErrorState, Spinner } from './components/primitives';
44
+ export type { ButtonProps, LinkButtonProps, ButtonVariant, CardProps, SkeletonProps, EmptyStateProps, ErrorStateProps, SpinnerProps, } from './components/primitives';
45
+ export { PageHeader, Page, Stack } from './components/page-header';
46
+ export type { PageHeaderProps, PageLayoutProps, StackProps } from './components/page-header';
47
+ export { ErrorBoundary } from './components/error-boundary';
48
+ export type { ErrorBoundaryProps } from './components/error-boundary';
49
+ export { Field, useFieldControl } from './components/field';
50
+ export type { FieldProps, FieldControlProps } from './components/field';
51
+ export { TextInput, Textarea, NumberInput } from './components/inputs';
52
+ export type { TextInputProps, TextareaProps, NumberInputProps } from './components/inputs';
53
+ export { Select } from './components/select';
54
+ export type { SelectProps, SelectGroupsProps, SelectOption, SelectGroup, } from './components/select';
55
+ export { Checkbox } from './components/checkbox';
56
+ export type { CheckboxProps } from './components/checkbox';
57
+ export { RadioGroup } from './components/radio-group';
58
+ export type { RadioGroupProps, RadioOption } from './components/radio-group';
59
+ export { Badge } from './components/badge';
60
+ export type { BadgeProps } from './components/badge';
61
+ export { Tabs } from './components/tabs';
62
+ export type { TabsProps, TabItem } from './components/tabs';
63
+ export { Dialog } from './components/dialog';
64
+ export type { DialogProps } from './components/dialog';
65
+ export { ConfirmDialog } from './components/confirm-dialog';
66
+ export type { ConfirmDialogProps } from './components/confirm-dialog';
67
+ export { Drawer } from './components/drawer';
68
+ export type { DrawerProps } from './components/drawer';
69
+ export { Tooltip } from './components/tooltip';
70
+ export type { TooltipProps } from './components/tooltip';
71
+ export { Table, THead, TBody, TR, TH, TD } from './components/table';
72
+ export type { TableProps, TableSectionProps, TableRowProps, THProps, TDProps, NumericColumnProps, } from './components/table';
73
+ export { ScrollRegion, useOverflowRegion, useProseScrollRegions } from './components/scroll-region';
74
+ export type { ScrollRegionProps, OverflowRegionAttributes, ProseScrollLabels, } from './components/scroll-region';
75
+ export { JsonTree } from './components/json-tree';
76
+ export type { JsonTreeProps } from './components/json-tree';
77
+ export { JsonDiff, diffJson } from './components/json-diff';
78
+ export type { JsonDiffProps, JsonDiffRow } from './components/json-diff';
79
+ export { TagChips, TagsInput } from './components/tags';
80
+ export type { TagChipsProps, TagsInputProps } from './components/tags';
81
+ export { CodeBlock } from './components/code-block';
82
+ export type { CodeBlockProps } from './components/code-block';
83
+ export { FleetReport } from './components/fleet-report';
84
+ export type { FleetReportProps } from './components/fleet-report';
85
+ export { ExternalLinkButton, isSafeHttpUrl } from './components/external-link';
86
+ export { safeHttpUrl } from './components/primitives';
87
+ export type { ExternalLinkButtonProps } from './components/external-link';
88
+ export { ToolPicker } from './components/tool-picker';
89
+ export type { ToolPickerProps } from './components/tool-picker';
90
+ export { ExtensionPicker } from './components/extension-picker';
91
+ export type { ExtensionPickerProps } from './components/extension-picker';
92
+ export { ExtensionComboBuilder } from './components/extension-combo-builder';
93
+ export type { ExtensionComboBuilderProps } from './components/extension-combo-builder';
94
+ export { baseNameOf, groupIntoFamilies, groupByKind, kindVariant, NON_STACKABLE_KIND, } from './components/extension-grouping';
95
+ export type { ExtensionFamily, ExtensionKindGroup } from './components/extension-grouping';
96
+ export { VersionHistoryPanel } from './components/version-history-panel';
97
+ export type { VersionHistoryPanelProps, VersionHistoryEntry, } from './components/version-history-panel';
98
+ export { RevealInput } from './components/reveal-input';
99
+ export type { RevealInputProps } from './components/reveal-input';
100
+ export { CopyField } from './components/copy-field';
101
+ export type { CopyFieldProps } from './components/copy-field';
102
+ export { TOKEN_NAMES } from './components/tokens';
103
+ export type { TokenName } from './components/tokens';
104
+ export { NAV_ICONS, DashboardIcon, ToolsIcon, AgentsIcon, PresetsIcon, ExtensionsIcon, TemplatesIcon, ConnectorsIcon, HooksIcon, StorageIcon, SchedulingIcon, InteractionsIcon, NotificationsIcon, MarketplaceIcon, ManifestIcon, SettingsIcon, SystemIcon, SearchIcon, SignOutIcon, MenuIcon, CloseIcon, FilterIcon, ArrowLeftIcon, ArrowUpIcon, ArrowDownIcon, ChevronDownIcon, ChevronRightIcon, CheckIcon, MinusIcon, CopyIcon, ExternalLinkIcon, EyeIcon, EyeOffIcon, SortAscIcon, SortDescIcon, SunIcon, MoonIcon, MonitorIcon, CheckCircleIcon, AlertTriangleIcon, XCircleIcon, PendingIcon, } from './components/icons';
105
+ export type { IconProps, IconComponent } from './components/icons';
106
+ export { SchemaForm, defaultValueForSchema, validateAgainstSchema, resolveRef, } from './schema-form';
107
+ export type { SchemaFormProps, CompletionProvider, JsonSchema, JsonSchemaType, Discriminator, SchemaFormErrors, } from './schema-form';
108
+ export { SchemaEditor, lintSchemaText } from './schema-editor';
109
+ export type { SchemaEditorProps, SchemaEditorChange, SchemaLintResult } from './schema-editor';
110
+ export { ProgressBar } from './components/progress-bar';
111
+ export type { ProgressBarProps } from './components/progress-bar';
112
+ export { CompletionInput } from './components/completion-input';
113
+ export type { CompletionInputProps } from './components/completion-input';
114
+ export { ElicitationForm } from './elicitation/ElicitationForm';
115
+ export type { ElicitationFormProps } from './elicitation/ElicitationForm';
116
+ export { StructuredOutput } from './structured-output/StructuredOutput';
117
+ export type { StructuredOutputProps } from './structured-output/StructuredOutput';
118
+ //# sourceMappingURL=index.d.ts.map