@datalayer/core 1.1.59 → 1.1.66

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 (366) hide show
  1. package/README.md +2 -2
  2. package/lib/api/DatalayerApi.d.ts +42 -1
  3. package/lib/api/DatalayerApi.js +90 -3
  4. package/lib/api/constants.d.ts +18 -0
  5. package/lib/api/constants.js +18 -0
  6. package/lib/api/contents/attachments.d.ts +9 -0
  7. package/lib/api/contents/attachments.js +43 -0
  8. package/lib/api/contents/bridges.d.ts +22 -0
  9. package/lib/api/contents/bridges.js +79 -0
  10. package/lib/api/contents/capabilities.d.ts +11 -0
  11. package/lib/api/contents/capabilities.js +21 -0
  12. package/lib/api/contents/cloudStorage.d.ts +31 -0
  13. package/lib/api/contents/cloudStorage.js +89 -0
  14. package/lib/api/contents/dataservers.d.ts +37 -0
  15. package/lib/api/contents/dataservers.js +121 -0
  16. package/lib/api/contents/datasets.d.ts +15 -0
  17. package/lib/api/contents/datasets.js +45 -0
  18. package/lib/api/contents/datasources.d.ts +70 -0
  19. package/lib/api/contents/datasources.js +149 -0
  20. package/lib/api/contents/generated.d.ts +1070 -0
  21. package/lib/api/contents/index.d.ts +16 -0
  22. package/lib/api/contents/index.js +20 -0
  23. package/lib/api/contents/mcp.d.ts +46 -0
  24. package/lib/api/contents/mcp.js +157 -0
  25. package/lib/api/contents/objects.d.ts +31 -0
  26. package/lib/api/contents/objects.js +88 -0
  27. package/lib/api/contents/operations.d.ts +3 -0
  28. package/lib/api/contents/operations.js +19 -0
  29. package/lib/api/contents/runtimeMounts.d.ts +40 -0
  30. package/lib/api/contents/runtimeMounts.js +59 -0
  31. package/lib/api/contents/sandboxUid.d.ts +53 -0
  32. package/lib/api/contents/sandboxUid.js +78 -0
  33. package/lib/api/contents/sources.d.ts +19 -0
  34. package/lib/api/contents/sources.js +119 -0
  35. package/lib/api/contents/sync.d.ts +18 -0
  36. package/lib/api/contents/sync.js +69 -0
  37. package/lib/api/contents/transfers.d.ts +38 -0
  38. package/lib/api/contents/transfers.js +123 -0
  39. package/lib/api/iam/connectedAgents.d.ts +39 -0
  40. package/lib/api/iam/connectedAgents.js +52 -0
  41. package/lib/api/iam/index.d.ts +2 -1
  42. package/lib/api/iam/index.js +2 -1
  43. package/lib/api/iam/mcpAlertRules.d.ts +51 -0
  44. package/lib/api/iam/mcpAlertRules.js +198 -0
  45. package/lib/api/iam/mcpAuditSettings.d.ts +46 -0
  46. package/lib/api/iam/mcpAuditSettings.js +120 -0
  47. package/lib/api/iam/mcpPolicy.d.ts +80 -0
  48. package/lib/api/iam/mcpPolicy.js +132 -0
  49. package/lib/api/iam/organizationTeams.d.ts +13 -0
  50. package/lib/api/iam/organizationTeams.js +43 -0
  51. package/lib/api/iam/serviceAgents.d.ts +68 -0
  52. package/lib/api/iam/serviceAgents.js +119 -0
  53. package/lib/api/index.d.ts +4 -1
  54. package/lib/api/index.js +3 -1
  55. package/lib/api/mcp/activity.d.ts +37 -0
  56. package/lib/api/mcp/activity.js +26 -0
  57. package/lib/api/mcp/alerts.d.ts +25 -0
  58. package/lib/api/mcp/alerts.js +51 -0
  59. package/lib/api/mcp/audit.d.ts +29 -0
  60. package/lib/api/mcp/audit.js +55 -0
  61. package/lib/api/mcp/bindings.d.ts +18 -0
  62. package/lib/api/mcp/bindings.js +42 -0
  63. package/lib/api/mcp/forwarding.d.ts +25 -0
  64. package/lib/api/mcp/forwarding.js +46 -0
  65. package/lib/api/mcp/gateway.d.ts +16 -0
  66. package/lib/api/mcp/gateway.js +70 -0
  67. package/lib/api/mcp/generated.d.ts +22 -0
  68. package/lib/api/mcp/generated.js +213 -0
  69. package/lib/api/mcp/index.d.ts +17 -0
  70. package/lib/api/mcp/index.js +25 -0
  71. package/lib/api/mcp/observability.d.ts +125 -0
  72. package/lib/api/mcp/observability.js +254 -0
  73. package/lib/api/mcp/operations.d.ts +83 -0
  74. package/lib/api/mcp/operations.js +50 -0
  75. package/lib/api/mcp/organizations.d.ts +102 -0
  76. package/lib/api/mcp/organizations.js +46 -0
  77. package/lib/api/mcp/policy.d.ts +9 -0
  78. package/lib/api/mcp/policy.js +23 -0
  79. package/lib/api/mcp/tasks.d.ts +49 -0
  80. package/lib/api/mcp/tasks.js +147 -0
  81. package/lib/api/utils/validation.d.ts +1 -1
  82. package/lib/api/utils/validation.js +1 -1
  83. package/lib/client/auth/index.js +0 -5
  84. package/lib/client/auth/storage.js +0 -5
  85. package/lib/client/auth/strategies.js +0 -5
  86. package/lib/client/base.d.ts +6 -0
  87. package/lib/client/base.js +8 -0
  88. package/lib/client/index.d.ts +0 -10
  89. package/lib/client/index.js +2 -2
  90. package/lib/client/mixins/ContentsMixin.d.ts +71 -0
  91. package/lib/client/mixins/ContentsMixin.js +157 -0
  92. package/lib/client/mixins/IAMMixin.d.ts +0 -31
  93. package/lib/client/mixins/IAMMixin.js +0 -58
  94. package/lib/components/animation/AnimatedText.d.ts +1 -0
  95. package/lib/components/animation/AnimatedText.js +0 -4
  96. package/lib/components/auth/SigInAPIKey.d.ts +1 -0
  97. package/lib/components/auth/SigInAPIKey.js +0 -6
  98. package/lib/components/auth/SignIn.d.ts +1 -0
  99. package/lib/components/auth/SignIn.js +0 -4
  100. package/lib/components/auth/SignIn.stories.d.ts +2 -2
  101. package/lib/components/avatars/BoringAvatar.d.ts +1 -1
  102. package/lib/components/avatars/BoringAvatar.stories.d.ts +1 -1
  103. package/lib/components/avatars/DLAvatar.d.ts +1 -1
  104. package/lib/components/avatars/DLAvatar.js +0 -4
  105. package/lib/components/avatars/UserAvatar.d.ts +18 -1
  106. package/lib/components/avatars/UserAvatar.js +14 -14
  107. package/lib/components/avatars/UserProfileAvatar.d.ts +1 -1
  108. package/lib/components/banners/NoAutomationBanner.d.ts +1 -1
  109. package/lib/components/billing/BillingEntitySelect.d.ts +10 -0
  110. package/lib/components/billing/BillingEntitySelect.js +0 -17
  111. package/lib/components/billing/index.js +0 -4
  112. package/lib/components/buttons/DownloadCSVButton.d.ts +1 -1
  113. package/lib/components/buttons/DownloadJsonButton.d.ts +1 -1
  114. package/lib/components/buttons/LongActionButton.d.ts +1 -0
  115. package/lib/components/buttons/LongActionButton.js +0 -4
  116. package/lib/components/buttons/UploadButton.d.ts +1 -0
  117. package/lib/components/buttons/UploadButton.js +0 -4
  118. package/lib/components/checkout/StripeCheckout.d.ts +1 -1
  119. package/lib/components/collaboration/LiveEditorCollaborators.d.ts +31 -0
  120. package/lib/components/collaboration/LiveEditorCollaborators.js +98 -53
  121. package/lib/components/collaboration/index.js +0 -4
  122. package/lib/components/confetti/ConfettiSuccess.d.ts +1 -1
  123. package/lib/components/contents/ContentSourceCard.d.ts +8 -0
  124. package/lib/components/contents/ContentSourceCard.js +23 -0
  125. package/lib/components/contents/HomeFolderObjectsBrowser.d.ts +10 -0
  126. package/lib/components/contents/HomeFolderObjectsBrowser.js +148 -0
  127. package/lib/components/contents/index.d.ts +2 -0
  128. package/lib/components/contents/index.js +6 -0
  129. package/lib/components/context/OrganizationSelect.d.ts +1 -1
  130. package/lib/components/display/AvatarSkeleton.d.ts +1 -1
  131. package/lib/components/display/BusyDots.d.ts +1 -1
  132. package/lib/components/display/CenteredSpinner.d.ts +1 -1
  133. package/lib/components/display/CodePreview.d.ts +1 -1
  134. package/lib/components/display/DatalayerBox.d.ts +7 -2
  135. package/lib/components/display/DatalayerBox.js +6 -6
  136. package/lib/components/display/HorizontalCenter.d.ts +1 -1
  137. package/lib/components/display/JupyterDialog.d.ts +1 -0
  138. package/lib/components/display/JupyterDialog.js +1 -7
  139. package/lib/components/display/Markdown.d.ts +1 -0
  140. package/lib/components/display/NotebookSkeleton.d.ts +1 -1
  141. package/lib/components/display/Placeholder.d.ts +1 -1
  142. package/lib/components/display/ToTopBranded.d.ts +1 -1
  143. package/lib/components/echarts/EChartsReact.d.ts +1 -1
  144. package/lib/components/flashes/FlashClosable.d.ts +1 -0
  145. package/lib/components/flashes/FlashClosable.js +0 -4
  146. package/lib/components/flashes/FlashGuest.d.ts +1 -1
  147. package/lib/components/flashes/FlashSurveys.d.ts +1 -1
  148. package/lib/components/flashes/FlashUnauthorized.d.ts +1 -0
  149. package/lib/components/flashes/FlashUnauthorized.js +0 -6
  150. package/lib/components/flashes/surveys/Survey2025_1.d.ts +1 -1
  151. package/lib/components/iam/ExternalTokenSilentLogin.d.ts +1 -1
  152. package/lib/components/index.d.ts +2 -0
  153. package/lib/components/index.js +2 -0
  154. package/lib/components/labels/StatusLabels.d.ts +10 -0
  155. package/lib/components/labels/StatusLabels.js +30 -1
  156. package/lib/components/labels/VisibilityLabel.d.ts +1 -1
  157. package/lib/components/landings/StepBlock.d.ts +1 -1
  158. package/lib/components/mcp/ClientBadge.d.ts +41 -0
  159. package/lib/components/mcp/ClientBadge.js +33 -0
  160. package/lib/components/mcp/McpErrorBlankslate.d.ts +21 -0
  161. package/lib/components/mcp/McpErrorBlankslate.js +17 -0
  162. package/lib/components/mcp/ScopeList.d.ts +28 -0
  163. package/lib/components/mcp/ScopeList.js +14 -0
  164. package/lib/components/mcp/index.d.ts +10 -0
  165. package/lib/components/mcp/index.js +18 -0
  166. package/lib/components/navbar/NavigationVisbilityObserver.d.ts +2 -1
  167. package/lib/components/navbar/SubdomainNavBar.d.ts +10 -5
  168. package/lib/components/navbar/SubdomainNavBar.js +2 -1
  169. package/lib/components/notebooks/JupyterNotebook.d.ts +1 -1
  170. package/lib/components/notebooks/JupyterNotebookToolbar.d.ts +1 -1
  171. package/lib/components/principal/PrincipalAppearance.d.ts +1 -0
  172. package/lib/components/principal/PrincipalAppearance.js +0 -8
  173. package/lib/components/principal/PrincipalAvatar.d.ts +9 -1
  174. package/lib/components/principal/PrincipalAvatar.js +25 -10
  175. package/lib/components/principal/PrincipalBadge.d.ts +1 -1
  176. package/lib/components/principal/PrincipalBanner.d.ts +1 -1
  177. package/lib/components/principal/PrincipalDetailsOverlay.d.ts +31 -1
  178. package/lib/components/principal/PrincipalDetailsOverlay.js +64 -33
  179. package/lib/components/principal/PrincipalHoverCard.d.ts +31 -0
  180. package/lib/components/principal/PrincipalHoverCard.js +52 -0
  181. package/lib/components/principal/PrincipalSwitcherMenu.d.ts +1 -0
  182. package/lib/components/principal/PrincipalSwitcherMenu.js +7 -15
  183. package/lib/components/principal/index.d.ts +2 -1
  184. package/lib/components/principal/index.js +2 -1
  185. package/lib/components/progress/ConsumptionBar.d.ts +1 -0
  186. package/lib/components/progress/ConsumptionBar.js +0 -4
  187. package/lib/components/progress/ProgressRing.d.ts +1 -0
  188. package/lib/components/progress/SpinnerBar.d.ts +1 -1
  189. package/lib/components/progress/Timer.d.ts +1 -0
  190. package/lib/components/progress/Timer.js +0 -4
  191. package/lib/components/screencapture/ScreencaptureButton.d.ts +1 -1
  192. package/lib/components/sharing/ShareAccessComponent.d.ts +15 -1
  193. package/lib/components/sharing/ShareAccessComponent.js +36 -23
  194. package/lib/components/sharing/SharingEditor.d.ts +17 -0
  195. package/lib/components/sharing/SharingEditor.js +0 -24
  196. package/lib/components/sparklines/Sparklines.js +3 -4
  197. package/lib/components/sparklines/index.js +0 -4
  198. package/lib/components/storage/ContentsBrowser.d.ts +25 -1
  199. package/lib/components/storage/ContentsBrowser.js +145 -52
  200. package/lib/components/storage/ContentsBrowserMock.d.ts +3 -0
  201. package/lib/components/storage/ContentsBrowserMock.js +75 -0
  202. package/lib/components/storage/ContentsItems.d.ts +2 -1
  203. package/lib/components/storage/ContentsItems.js +0 -4
  204. package/lib/components/storage/ContentsTable.d.ts +50 -0
  205. package/lib/components/storage/ContentsTable.js +134 -0
  206. package/lib/components/storage/HomeFolderDrive.d.ts +71 -0
  207. package/lib/components/storage/HomeFolderDrive.js +248 -0
  208. package/lib/components/storage/index.d.ts +2 -0
  209. package/lib/components/storage/index.js +2 -0
  210. package/lib/components/students/StudentItemStatus.d.ts +1 -1
  211. package/lib/components/students/StudentResultCircle.d.ts +1 -1
  212. package/lib/components/subnav/SubNav.d.ts +5 -5
  213. package/lib/components/subnav/SubNav.js +11 -9
  214. package/lib/components/tables/DataTable.d.ts +1 -1
  215. package/lib/components/text-reveal/TextRevealAnimation.d.ts +2 -2
  216. package/lib/components/text-reveal/useTextRevealAnimationLines.d.ts +1 -1
  217. package/lib/components/time/LiveRelativeTime.d.ts +1 -0
  218. package/lib/components/time/LiveRelativeTime.js +0 -8
  219. package/lib/components/time/index.js +0 -4
  220. package/lib/components/timeline/Timeline.d.ts +1 -1
  221. package/lib/components/timeline/index.js +0 -4
  222. package/lib/components/users/PeerIndicator.d.ts +1 -0
  223. package/lib/components/users/PeerIndicator.js +0 -4
  224. package/lib/config/Configuration.d.ts +15 -17
  225. package/lib/config/Configuration.js +7 -0
  226. package/lib/hooks/index.d.ts +2 -0
  227. package/lib/hooks/index.js +2 -0
  228. package/lib/hooks/layouts/LayoutBackdrop.d.ts +1 -1
  229. package/lib/hooks/layouts/LayoutScreencapture.d.ts +1 -1
  230. package/lib/hooks/useBackdrop.d.ts +1 -1
  231. package/lib/hooks/useBackdropJupyterLab.d.ts +3 -2
  232. package/lib/hooks/useBackdropJupyterLab.js +0 -4
  233. package/lib/hooks/useCache.d.ts +310 -105
  234. package/lib/hooks/useCache.js +142 -355
  235. package/lib/hooks/useContainsFocus.d.ts +1 -1
  236. package/lib/hooks/useContents.d.ts +313 -0
  237. package/lib/hooks/useContents.js +964 -0
  238. package/lib/hooks/useFocusTrap.d.ts +4 -4
  239. package/lib/hooks/useFocusTrap.js +1 -1
  240. package/lib/hooks/useMcp.d.ts +229 -0
  241. package/lib/hooks/useMcp.js +656 -0
  242. package/lib/hooks/useMobile.js +0 -5
  243. package/lib/hooks/useProjectStore.d.ts +3 -3
  244. package/lib/hooks/useProjectStore.js +4 -4
  245. package/lib/hooks/useRef.d.ts +1 -1
  246. package/lib/hooks/useRef.js +3 -0
  247. package/lib/hooks/useScreencapture.d.ts +2 -1
  248. package/lib/hooks/useScreencapture.js +0 -4
  249. package/lib/hooks/useToast.js +0 -4
  250. package/lib/hooks/useUser.js +42 -0
  251. package/lib/hooks/useVisibilityObserver.d.ts +1 -1
  252. package/lib/index.d.ts +4 -1
  253. package/lib/index.js +3 -1
  254. package/lib/mocks/components/FlashMock.d.ts +1 -1
  255. package/lib/mocks/views/ActionMenuMock.d.ts +1 -1
  256. package/lib/mocks/views/ChartMock.d.ts +1 -1
  257. package/lib/mocks/views/DashboardMock.d.ts +1 -1
  258. package/lib/mocks/views/FormMock.d.ts +1 -1
  259. package/lib/mocks/views/TableMock.d.ts +1 -1
  260. package/lib/mocks/views/WipMock.d.ts +1 -1
  261. package/lib/models/Credits.d.ts +16 -0
  262. package/lib/models/Credits.js +22 -0
  263. package/lib/models/McpAuditEvent.d.ts +52 -0
  264. package/lib/models/McpAuditEvent.js +5 -0
  265. package/lib/models/McpBinding.d.ts +51 -0
  266. package/lib/models/McpBinding.js +5 -0
  267. package/lib/models/McpPolicy.d.ts +77 -0
  268. package/lib/models/McpPolicy.js +5 -0
  269. package/lib/models/McpTask.d.ts +94 -0
  270. package/lib/models/McpTask.js +7 -0
  271. package/lib/models/StartedBy.d.ts +57 -0
  272. package/lib/models/StartedBy.js +81 -0
  273. package/lib/models/UserDTO.js +4 -2
  274. package/lib/models/contents/__fixtures__/solr-codec.json +57 -0
  275. package/lib/models/contents/__fixtures__/v1-contracts.json +66 -0
  276. package/lib/models/contents/fieldCase.d.ts +8 -0
  277. package/lib/models/contents/fieldCase.js +37 -0
  278. package/lib/models/contents/index.d.ts +2 -0
  279. package/lib/models/contents/index.js +6 -0
  280. package/lib/models/contents/permissions.d.ts +16 -0
  281. package/lib/models/contents/permissions.js +34 -0
  282. package/lib/models/index.d.ts +5 -1
  283. package/lib/models/index.js +5 -1
  284. package/lib/state/substates/CoreState.d.ts +15 -7
  285. package/lib/state/substates/CoreState.js +18 -14
  286. package/lib/state/substates/IAMState.d.ts +1 -1
  287. package/lib/state/substates/IAMState.js +5 -5
  288. package/lib/state/substates/ProfileState.js +0 -4
  289. package/lib/state/substates/index.d.ts +0 -1
  290. package/lib/state/substates/index.js +0 -1
  291. package/lib/utils/Jwt.d.ts +26 -0
  292. package/lib/utils/Jwt.js +37 -0
  293. package/lib/utils/WithSuspense.d.ts +1 -1
  294. package/lib/views/api-keys/APIKeyEdit.d.ts +1 -1
  295. package/lib/views/api-keys/APIKeyNew.d.ts +1 -1
  296. package/lib/views/api-keys/APIKeys.d.ts +1 -1
  297. package/lib/views/api-keys/APIKeys.js +30 -4
  298. package/lib/views/api-keys/APIKeysStandalone.d.ts +5 -1
  299. package/lib/views/api-keys/APIKeysStandalone.js +2 -2
  300. package/lib/views/datasources/DatasourceDetail.d.ts +12 -5
  301. package/lib/views/datasources/DatasourceDetail.js +80 -110
  302. package/lib/views/datasources/DatasourceNew.d.ts +14 -8
  303. package/lib/views/datasources/DatasourceNew.js +129 -118
  304. package/lib/views/datasources/Datasources.d.ts +39 -7
  305. package/lib/views/datasources/Datasources.js +95 -40
  306. package/lib/views/datasources/DatasourcesMock.d.ts +3 -0
  307. package/lib/views/datasources/DatasourcesMock.js +57 -0
  308. package/lib/views/iam/SignInSimple.d.ts +12 -0
  309. package/lib/views/iam/SignInSimple.js +4 -4
  310. package/lib/views/index.d.ts +1 -0
  311. package/lib/views/index.js +1 -0
  312. package/lib/views/mcp/AlertDestinations.d.ts +34 -0
  313. package/lib/views/mcp/AlertDestinations.js +75 -0
  314. package/lib/views/mcp/AlertRules.d.ts +32 -0
  315. package/lib/views/mcp/AlertRules.js +245 -0
  316. package/lib/views/mcp/AuditLog.d.ts +42 -0
  317. package/lib/views/mcp/AuditLog.js +144 -0
  318. package/lib/views/mcp/ConnectedAgents.d.ts +34 -0
  319. package/lib/views/mcp/ConnectedAgents.js +100 -0
  320. package/lib/views/mcp/EnterpriseConsole.d.ts +74 -0
  321. package/lib/views/mcp/EnterpriseConsole.js +173 -0
  322. package/lib/views/mcp/McpDashboard.d.ts +50 -0
  323. package/lib/views/mcp/McpDashboard.js +347 -0
  324. package/lib/views/mcp/McpHome.d.ts +92 -0
  325. package/lib/views/mcp/McpHome.js +153 -0
  326. package/lib/views/mcp/McpObservability.d.ts +50 -0
  327. package/lib/views/mcp/McpObservability.js +150 -0
  328. package/lib/views/mcp/OrganizationPolicy.d.ts +45 -0
  329. package/lib/views/mcp/OrganizationPolicy.js +107 -0
  330. package/lib/views/mcp/OrganizationUsage.d.ts +69 -0
  331. package/lib/views/mcp/OrganizationUsage.js +113 -0
  332. package/lib/views/mcp/PersonalPolicy.d.ts +54 -0
  333. package/lib/views/mcp/PersonalPolicy.js +125 -0
  334. package/lib/views/mcp/Policies.d.ts +53 -0
  335. package/lib/views/mcp/Policies.js +210 -0
  336. package/lib/views/mcp/PolicyForm.d.ts +67 -0
  337. package/lib/views/mcp/PolicyForm.js +91 -0
  338. package/lib/views/mcp/PolicyHistory.d.ts +45 -0
  339. package/lib/views/mcp/PolicyHistory.js +62 -0
  340. package/lib/views/mcp/ServiceAgents.d.ts +46 -0
  341. package/lib/views/mcp/ServiceAgents.js +194 -0
  342. package/lib/views/mcp/TeamPolicies.d.ts +33 -0
  343. package/lib/views/mcp/TeamPolicies.js +98 -0
  344. package/lib/views/mcp/format.d.ts +25 -0
  345. package/lib/views/mcp/format.js +77 -0
  346. package/lib/views/mcp/index.d.ts +29 -0
  347. package/lib/views/mcp/index.js +37 -0
  348. package/lib/views/mcp/types.d.ts +66 -0
  349. package/lib/views/mcp/types.js +5 -0
  350. package/lib/views/secrets/SecretEdit.d.ts +5 -1
  351. package/lib/views/secrets/SecretEdit.js +2 -2
  352. package/lib/views/secrets/SecretNew.d.ts +11 -1
  353. package/lib/views/secrets/SecretNew.js +2 -2
  354. package/lib/views/secrets/Secrets.d.ts +12 -1
  355. package/lib/views/secrets/Secrets.js +2 -2
  356. package/package.json +28 -24
  357. package/scripts/generate-contents-types.py +169 -0
  358. package/scripts/generate-mcp-types.py +233 -0
  359. package/lib/api/iam/datasources.d.ts +0 -86
  360. package/lib/api/iam/datasources.js +0 -185
  361. package/lib/components/toolbars/index.d.ts +0 -1
  362. package/lib/models/Datasource.d.ts +0 -181
  363. package/lib/models/Datasource.js +0 -154
  364. package/lib/state/substates/DatasourceState.d.ts +0 -11
  365. package/lib/state/substates/DatasourceState.js +0 -16
  366. /package/lib/{components/toolbars/index.js → api/contents/generated.js} +0 -0
@@ -0,0 +1,656 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /*
6
+ * Copyright (c) 2023-2026 Datalayer, Inc.
7
+ * Distributed under the terms of the Modified BSD License.
8
+ */
9
+ /**
10
+ * Hooks over the Jupyter MCP Server, IAM's connected agents and the OTEL
11
+ * service, in the `useContents.ts` shape: `enabled` on token and URL,
12
+ * `staleTime` per resource, filters in the query key, mutations that
13
+ * `setQueryData` and invalidate.
14
+ *
15
+ * Polling by predicate: a task refetches every two seconds while it is not
16
+ * terminal and stops when it is; the activity answer every ten seconds as
17
+ * the fallback under the websocket; audit and policy on demand. An open
18
+ * Runs panel subscribes to the task's server-sent events instead.
19
+ *
20
+ * @module hooks/useMcp
21
+ */
22
+ import { useEffect } from 'react';
23
+ import { useMutation, useQueries, useQuery, useQueryClient, } from '@tanstack/react-query';
24
+ import { answerTask, cancelTask, exportAuditEvents, fetchMcpLogs, fetchMcpMetrics, fetchRunTrace, fetchTraceSpans, getEffectivePolicy, getGatewayVersion, getMcpActivity, getOrganizationMcpOverview, getOrganizationMcpUsage, getTask, getWorkflowsHealth, isMcpTaskTerminal, listAuditEvents, listBindings, listNotebookTasks, listTasks, listWorkers, subscribeTaskEvents, terminateBinding, } from '../api/mcp/index.js';
25
+ import { disconnectAgent, listConnectedAgents } from '../api/iam/connectedAgents.js';
26
+ import { listOrganizationTeams, } from '../api/iam/organizationTeams.js';
27
+ import { getAuditSettings, setAuditSettings, } from '../api/iam/mcpAuditSettings.js';
28
+ import { getMcpForwarding, } from '../api/mcp/forwarding.js';
29
+ import { testAlertRule, } from '../api/mcp/alerts.js';
30
+ import { createAlertRule, deleteAlertRule, listAlertRules, updateAlertRule, } from '../api/iam/mcpAlertRules.js';
31
+ import { deleteMcpPolicy, getMcpPolicy, setMcpPolicy, } from '../api/iam/mcpPolicy.js';
32
+ import { createServiceAgent, listServiceAgents, revokeServiceAgent, rotateServiceAgentKey, } from '../api/iam/serviceAgents.js';
33
+ import { useCoreStore, useIAMStore } from '../state/index.js';
34
+ import { queryKeys } from './useCache.js';
35
+ const useMcpServerUrl = () => useCoreStore(state => state.configuration.jupyterMcpServerUrl);
36
+ const useIamUrl = () => useCoreStore(state => state.configuration.iamUrl);
37
+ const useOtelUrl = () => useCoreStore(state => state.configuration.otelUrl);
38
+ // -- Tasks -----------------------------------------------------------------
39
+ export const useTasks = (filters = {}, options = {}) => {
40
+ const token = useIAMStore(state => state.token);
41
+ const mcpUrl = useMcpServerUrl();
42
+ return useQuery({
43
+ queryKey: queryKeys.mcp.taskList(filters),
44
+ queryFn: () => listTasks(token ?? '', filters, mcpUrl),
45
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
46
+ staleTime: 5_000,
47
+ refetchInterval: filters.status && !isMcpTaskTerminal(filters.status) ? 5_000 : false,
48
+ });
49
+ };
50
+ /** One task, polled every two seconds until it is terminal. */
51
+ export const useTask = (taskUid) => {
52
+ const token = useIAMStore(state => state.token);
53
+ const mcpUrl = useMcpServerUrl();
54
+ return useQuery({
55
+ queryKey: queryKeys.mcp.task(taskUid ?? ''),
56
+ queryFn: () => getTask(token ?? '', taskUid, mcpUrl),
57
+ enabled: Boolean(token && mcpUrl && taskUid),
58
+ refetchInterval: query => query.state.data && isMcpTaskTerminal(query.state.data.status) ? false : 2_000,
59
+ });
60
+ };
61
+ export const useNotebookTasks = (notebookUid, filters = {}) => {
62
+ const token = useIAMStore(state => state.token);
63
+ const mcpUrl = useMcpServerUrl();
64
+ return useQuery({
65
+ queryKey: queryKeys.mcp.notebookTasks(notebookUid ?? '', filters),
66
+ queryFn: () => listNotebookTasks(token ?? '', notebookUid, filters, mcpUrl),
67
+ enabled: Boolean(token && mcpUrl && notebookUid),
68
+ staleTime: 5_000,
69
+ });
70
+ };
71
+ /**
72
+ * The task's server-sent events, patched into the task's cache entry so
73
+ * every `useTask` of it updates without polling. Ends by itself when the
74
+ * task is terminal; the subscription closes with the component.
75
+ */
76
+ export const useTaskEvents = (taskUid, options = {}) => {
77
+ const queryClient = useQueryClient();
78
+ const token = useIAMStore(state => state.token);
79
+ const mcpUrl = useMcpServerUrl();
80
+ const enabled = Boolean(token && mcpUrl && taskUid) && (options.enabled ?? true);
81
+ const { onEvent } = options;
82
+ useEffect(() => {
83
+ if (!enabled) {
84
+ return undefined;
85
+ }
86
+ const close = subscribeTaskEvents(token ?? '', taskUid, {
87
+ onEvent: event => {
88
+ queryClient.setQueryData(queryKeys.mcp.task(taskUid), current => {
89
+ if (event.task) {
90
+ return event.task;
91
+ }
92
+ if (!current) {
93
+ return current;
94
+ }
95
+ return {
96
+ ...current,
97
+ status: event.status ?? current.status,
98
+ statusMessage: event.statusMessage ?? current.statusMessage,
99
+ lastUpdatedAt: event.at ?? current.lastUpdatedAt,
100
+ outputs: event.output ? [...(current.outputs ?? []), event.output] : current.outputs,
101
+ };
102
+ });
103
+ onEvent?.(event);
104
+ },
105
+ onClose: () => {
106
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.task(taskUid) });
107
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.tasks() });
108
+ },
109
+ }, mcpUrl);
110
+ return close;
111
+ }, [enabled, token, taskUid, mcpUrl, queryClient, onEvent]);
112
+ };
113
+ export const useCancelTask = () => {
114
+ const queryClient = useQueryClient();
115
+ const token = useIAMStore(state => state.token);
116
+ const mcpUrl = useMcpServerUrl();
117
+ return useMutation({
118
+ mutationFn: taskUid => cancelTask(token ?? '', taskUid, mcpUrl),
119
+ onSuccess: task => {
120
+ queryClient.setQueryData(queryKeys.mcp.task(task.uid), task);
121
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.tasks() });
122
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.activity() });
123
+ },
124
+ });
125
+ };
126
+ export const useAnswerTask = () => {
127
+ const queryClient = useQueryClient();
128
+ const token = useIAMStore(state => state.token);
129
+ const mcpUrl = useMcpServerUrl();
130
+ return useMutation({
131
+ mutationFn: ({ taskUid, input }) => answerTask(token ?? '', taskUid, { input }, crypto.randomUUID(), mcpUrl),
132
+ onSuccess: task => {
133
+ queryClient.setQueryData(queryKeys.mcp.task(task.uid), task);
134
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.tasks() });
135
+ },
136
+ });
137
+ };
138
+ // -- Bindings --------------------------------------------------------------
139
+ export const useBindings = (filters = {}, options = {}) => {
140
+ const token = useIAMStore(state => state.token);
141
+ const mcpUrl = useMcpServerUrl();
142
+ return useQuery({
143
+ queryKey: queryKeys.mcp.bindingList(filters),
144
+ queryFn: () => listBindings(token ?? '', filters, mcpUrl),
145
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
146
+ staleTime: 10_000,
147
+ });
148
+ };
149
+ export const useTerminateBinding = () => {
150
+ const queryClient = useQueryClient();
151
+ const token = useIAMStore(state => state.token);
152
+ const mcpUrl = useMcpServerUrl();
153
+ return useMutation({
154
+ mutationFn: bindingUid => terminateBinding(token ?? '', bindingUid, mcpUrl),
155
+ onSuccess: () => {
156
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.bindings() });
157
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.activity() });
158
+ },
159
+ });
160
+ };
161
+ // -- Activity --------------------------------------------------------------
162
+ /**
163
+ * What is going on for the caller, refetched every ten seconds as the
164
+ * fallback under the ai-agents websocket, which patches the same entry.
165
+ */
166
+ export const useMcpActivity = (filters = {}, options = {}) => {
167
+ const token = useIAMStore(state => state.token);
168
+ const mcpUrl = useMcpServerUrl();
169
+ return useQuery({
170
+ queryKey: queryKeys.mcp.activity(filters),
171
+ queryFn: () => getMcpActivity(token ?? '', filters, mcpUrl),
172
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
173
+ staleTime: 5_000,
174
+ /*
175
+ * A poll that cannot succeed stops polling.
176
+ *
177
+ * `refetchInterval` as a plain number re-arms after *every* settle,
178
+ * failures included — so an endpoint the browser refuses outright (no
179
+ * CORS header, a dead host, a revoked token) turned this into a tight
180
+ * loop: fetch, fail, re-arm, fetch. Each failure is a query state change,
181
+ * and every observer re-rendered on each one, which read as a page
182
+ * repainting on a timer with nothing behind it.
183
+ *
184
+ * As a function it can decline. One error is enough to stand down; a
185
+ * remount, a refocus or a token change starts it again, which is when
186
+ * the answer could genuinely have changed.
187
+ */
188
+ refetchInterval: query => query.state.status === 'error'
189
+ ? false
190
+ : (options.pollIntervalMs ?? 10_000),
191
+ refetchIntervalInBackground: false,
192
+ // One retry, not the default three. The failures worth retrying here are
193
+ // transient; a refused origin is not, and three attempts only make the
194
+ // loop above three times as loud.
195
+ retry: 1,
196
+ /*
197
+ * Re-render for the answer, not for the asking.
198
+ *
199
+ * This polls for as long as the page is open, and by default a query
200
+ * notifies on every observed field — so `isFetching` going true and back
201
+ * again re-rendered every consumer twice a poll, whether or not a single
202
+ * byte had changed. On a dashboard that reads only the data, that is a
203
+ * repaint on a timer with nothing behind it.
204
+ *
205
+ * Structural sharing already keeps `data` referentially stable when the
206
+ * payload is unchanged, so with this the quiet polls cost nothing.
207
+ */
208
+ /*
209
+ * Re-render for the answer, not for the asking.
210
+ *
211
+ * `error` is deliberately absent: this is a background poll, and a
212
+ * consumer that redraws every time it fails is redrawing for something it
213
+ * does not show. `isPending` covers the one transition that matters —
214
+ * nothing yet, then something.
215
+ */
216
+ notifyOnChangeProps: ['data', 'isPending'],
217
+ });
218
+ };
219
+ // -- Audit -----------------------------------------------------------------
220
+ /** One page of the audit log; the cursor is one of the filters, as the URL keeps it. */
221
+ export const useAuditEvents = (filters = {}, options = {}) => {
222
+ const token = useIAMStore(state => state.token);
223
+ const mcpUrl = useMcpServerUrl();
224
+ return useQuery({
225
+ queryKey: queryKeys.mcp.auditList(filters),
226
+ queryFn: () => listAuditEvents(token ?? '', filters, mcpUrl),
227
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
228
+ staleTime: 30_000,
229
+ placeholderData: previous => previous,
230
+ });
231
+ };
232
+ /** The whole selection as one JSONL or CSV document, on demand. */
233
+ export const useAuditExport = () => {
234
+ const token = useIAMStore(state => state.token);
235
+ const mcpUrl = useMcpServerUrl();
236
+ return useMutation({
237
+ mutationFn: ({ filters = {}, format = 'jsonl' }) => exportAuditEvents(token ?? '', filters, format, mcpUrl),
238
+ });
239
+ };
240
+ // -- Policy ----------------------------------------------------------------
241
+ /** The effective policy for the caller, or previewed as one agent. */
242
+ export const useEffectivePolicy = (agent, filters = {}, options = {}) => {
243
+ const token = useIAMStore(state => state.token);
244
+ const mcpUrl = useMcpServerUrl();
245
+ const policyFilters = { agent, ...filters };
246
+ return useQuery({
247
+ queryKey: queryKeys.mcp.policy(policyFilters),
248
+ queryFn: () => getEffectivePolicy(token ?? '', policyFilters, mcpUrl),
249
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
250
+ staleTime: 60_000,
251
+ });
252
+ };
253
+ // -- Organizations (the Enterprise console) --------------------------------
254
+ /**
255
+ * The organization's MCP overview, for the console's first page.
256
+ *
257
+ * Read on demand and kept for a minute: an administrator reads it, acts, and
258
+ * comes back — it is not a live pane, and a page that re-asked every ten
259
+ * seconds would cost the gateway three bounded queries for nothing.
260
+ */
261
+ export const useOrgMcpOverview = (orgUid, filters = {}, options = {}) => {
262
+ const token = useIAMStore(state => state.token);
263
+ const mcpUrl = useMcpServerUrl();
264
+ return useQuery({
265
+ queryKey: queryKeys.mcp.orgOverview(orgUid ?? '', filters),
266
+ queryFn: () => getOrganizationMcpOverview(token ?? '', orgUid, filters, mcpUrl),
267
+ enabled: Boolean(token && mcpUrl && orgUid) && (options.enabled ?? true),
268
+ staleTime: 60_000,
269
+ });
270
+ };
271
+ /**
272
+ * The organization's use against its quotas, and which agents spent it.
273
+ *
274
+ * Kept for a minute like the overview, and for the same reason: an
275
+ * administrator reads it, acts, and comes back. A budget that re-asked every
276
+ * ten seconds would cost IAM a ledger query for a number that moves in
277
+ * credits, not in milliseconds.
278
+ */
279
+ export const useOrgMcpUsage = (orgUid, filters = {}, options = {}) => {
280
+ const token = useIAMStore(state => state.token);
281
+ const mcpUrl = useMcpServerUrl();
282
+ return useQuery({
283
+ queryKey: queryKeys.mcp.orgUsage(orgUid ?? '', filters),
284
+ queryFn: () => getOrganizationMcpUsage(token ?? '', orgUid, filters, mcpUrl),
285
+ enabled: Boolean(token && mcpUrl && orgUid) && (options.enabled ?? true),
286
+ staleTime: 60_000,
287
+ });
288
+ };
289
+ // -- Connected agents (IAM) ------------------------------------------------
290
+ export const useConnectedAgents = (options = {}) => {
291
+ const token = useIAMStore(state => state.token);
292
+ const iamUrl = useIamUrl();
293
+ return useQuery({
294
+ queryKey: queryKeys.mcp.connectedAgents(),
295
+ queryFn: () => listConnectedAgents(token ?? '', iamUrl),
296
+ enabled: Boolean(token && iamUrl) && (options.enabled ?? true),
297
+ staleTime: 30_000,
298
+ });
299
+ };
300
+ /** Revoke a grant; the list and the activity are refreshed, never guessed. */
301
+ export const useDisconnectAgent = () => {
302
+ const queryClient = useQueryClient();
303
+ const token = useIAMStore(state => state.token);
304
+ const iamUrl = useIamUrl();
305
+ return useMutation({
306
+ mutationFn: grantUid => disconnectAgent(token ?? '', grantUid, iamUrl),
307
+ onSuccess: () => {
308
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.connectedAgents() });
309
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.activity() });
310
+ },
311
+ });
312
+ };
313
+ // -- Teams (IAM) ------------------------------------------------------------
314
+ /** One organization's teams, for the console's team policy page. */
315
+ export const useOrganizationTeams = (orgUid, options = {}) => {
316
+ const token = useIAMStore(state => state.token);
317
+ const iamUrl = useIamUrl();
318
+ return useQuery({
319
+ queryKey: queryKeys.mcp.organizationTeams(orgUid),
320
+ queryFn: () => listOrganizationTeams(token ?? '', orgUid, iamUrl),
321
+ enabled: Boolean(token && iamUrl && orgUid) && (options.enabled ?? true),
322
+ staleTime: 60_000,
323
+ });
324
+ };
325
+ /**
326
+ * Whether the audit is reaching the organization's own system of record.
327
+ *
328
+ * Polled rather than read once: a destination that stops answering does so
329
+ * while somebody is looking at the page, and the point of the panel is to
330
+ * say when that happens.
331
+ */
332
+ export const useMcpForwarding = (org = '', options = {}) => {
333
+ const token = useIAMStore(state => state.token);
334
+ const mcpUrl = useMcpServerUrl();
335
+ return useQuery({
336
+ queryKey: queryKeys.mcp.forwarding(org),
337
+ queryFn: () => getMcpForwarding(token ?? '', org, mcpUrl),
338
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
339
+ staleTime: 30_000,
340
+ refetchInterval: 60_000,
341
+ });
342
+ };
343
+ // -- Audit settings: retention, forwarding, alert destinations (IAM) --------
344
+ /** One organization's settings, or `null` where it has decided nothing. */
345
+ export const useAuditSettings = (orgUid, options = {}) => {
346
+ const token = useIAMStore(state => state.token);
347
+ const iamUrl = useIamUrl();
348
+ return useQuery({
349
+ queryKey: queryKeys.mcp.auditSettings(orgUid),
350
+ queryFn: () => getAuditSettings(token ?? '', orgUid, iamUrl),
351
+ enabled: Boolean(token && iamUrl && orgUid) && (options.enabled ?? true),
352
+ staleTime: 30_000,
353
+ });
354
+ };
355
+ /**
356
+ * Change some of them. Only what is passed is sent, because IAM merges: a
357
+ * page editing the alert destinations must not clear a retention it never
358
+ * showed.
359
+ */
360
+ export const useSetAuditSettings = (orgUid) => {
361
+ const queryClient = useQueryClient();
362
+ const token = useIAMStore(state => state.token);
363
+ const iamUrl = useIamUrl();
364
+ return useMutation({
365
+ mutationFn: ({ settings, expectedVersion }) => setAuditSettings(token ?? '', orgUid, settings, { expectedVersion }, iamUrl),
366
+ onSuccess: () => {
367
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.auditSettings(orgUid) });
368
+ },
369
+ });
370
+ };
371
+ /**
372
+ * Try a rule against current values.
373
+ *
374
+ * A mutation rather than a query: it is something somebody asks for, once,
375
+ * by pressing a button — and caching "what does this see now" would answer
376
+ * the second press with the first press's numbers.
377
+ */
378
+ export const useTestAlertRule = () => {
379
+ const token = useIAMStore(state => state.token);
380
+ const mcpUrl = useMcpServerUrl();
381
+ return useMutation({
382
+ mutationFn: rule => testAlertRule(token ?? '', rule, mcpUrl),
383
+ });
384
+ };
385
+ // -- Alert rules (IAM) ------------------------------------------------------
386
+ /** One organization's alert rules, disabled ones included. */
387
+ export const useAlertRules = (orgUid, options = {}) => {
388
+ const token = useIAMStore(state => state.token);
389
+ const iamUrl = useIamUrl();
390
+ return useQuery({
391
+ queryKey: queryKeys.mcp.alertRules(orgUid),
392
+ queryFn: () => listAlertRules(token ?? '', orgUid, iamUrl),
393
+ enabled: Boolean(token && iamUrl && orgUid) && (options.enabled ?? true),
394
+ staleTime: 30_000,
395
+ });
396
+ };
397
+ export const useCreateAlertRule = (orgUid) => {
398
+ const queryClient = useQueryClient();
399
+ const token = useIAMStore(state => state.token);
400
+ const iamUrl = useIamUrl();
401
+ return useMutation({
402
+ mutationFn: rule => createAlertRule(token ?? '', orgUid, rule, iamUrl),
403
+ onSuccess: () => {
404
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.alertRules(orgUid) });
405
+ },
406
+ });
407
+ };
408
+ export const useUpdateAlertRule = (orgUid) => {
409
+ const queryClient = useQueryClient();
410
+ const token = useIAMStore(state => state.token);
411
+ const iamUrl = useIamUrl();
412
+ return useMutation({
413
+ mutationFn: ({ uid, rule }) => updateAlertRule(token ?? '', orgUid, uid, rule, iamUrl),
414
+ onSuccess: () => {
415
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.alertRules(orgUid) });
416
+ },
417
+ });
418
+ };
419
+ export const useDeleteAlertRule = (orgUid) => {
420
+ const queryClient = useQueryClient();
421
+ const token = useIAMStore(state => state.token);
422
+ const iamUrl = useIamUrl();
423
+ return useMutation({
424
+ mutationFn: uid => deleteAlertRule(token ?? '', orgUid, uid, iamUrl),
425
+ onSuccess: () => {
426
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.alertRules(orgUid) });
427
+ },
428
+ });
429
+ };
430
+ // -- The policy layer IAM stores (IAM) -------------------------------------
431
+ /**
432
+ * One layer's rules, or `null` where nobody has written one.
433
+ *
434
+ * `null` is a real answer and not an error: most organizations have never
435
+ * written a policy, and a form needs to tell "narrows nothing" from "does
436
+ * not exist" — only the second has nothing to remove.
437
+ */
438
+ export const useMcpPolicyLayer = (scope, subjectUid, options = {}) => {
439
+ const token = useIAMStore(state => state.token);
440
+ const iamUrl = useIamUrl();
441
+ return useQuery({
442
+ queryKey: queryKeys.mcp.policyLayer(scope, subjectUid),
443
+ queryFn: () => getMcpPolicy(token ?? '', scope, subjectUid, iamUrl),
444
+ enabled: Boolean(token && iamUrl && subjectUid) && (options.enabled ?? true),
445
+ staleTime: 30_000,
446
+ });
447
+ };
448
+ /**
449
+ * Several layers at once, for a page that has to compare against them all.
450
+ *
451
+ * The personal policy page needs every organization a person belongs to in
452
+ * order to say which of their values will have no effect. One hook per
453
+ * organization is not something a component can do — the count changes — so
454
+ * they are fetched together and answered in the order asked.
455
+ *
456
+ * A layer that could not be read comes back `null`, the same as one nobody
457
+ * has written. That is the safe direction here: the page would rather say
458
+ * nothing about narrowing than invent a cap somebody does not have.
459
+ */
460
+ export const useMcpPolicyLayers = (scope, subjectUids) => {
461
+ const token = useIAMStore(state => state.token);
462
+ const iamUrl = useIamUrl();
463
+ return useQueries({
464
+ queries: subjectUids.map(subjectUid => ({
465
+ queryKey: queryKeys.mcp.policyLayer(scope, subjectUid),
466
+ queryFn: () => getMcpPolicy(token ?? '', scope, subjectUid, iamUrl),
467
+ enabled: Boolean(token && iamUrl && subjectUid),
468
+ staleTime: 30_000,
469
+ })),
470
+ });
471
+ };
472
+ /**
473
+ * Replace one layer's rules.
474
+ *
475
+ * The **effective** policy is invalidated alongside the layer: the two are
476
+ * the same fact read two ways, and a page still showing the old effective
477
+ * policy after a write is a page saying the change did not take.
478
+ */
479
+ export const useSetMcpPolicyLayer = (scope, subjectUid) => {
480
+ const queryClient = useQueryClient();
481
+ const token = useIAMStore(state => state.token);
482
+ const iamUrl = useIamUrl();
483
+ return useMutation({
484
+ mutationFn: ({ rules, expectedVersion }) => setMcpPolicy(token ?? '', scope, subjectUid, rules, { expectedVersion }, iamUrl),
485
+ onSuccess: () => {
486
+ queryClient.invalidateQueries({
487
+ queryKey: queryKeys.mcp.policyLayer(scope, subjectUid),
488
+ });
489
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.policy() });
490
+ },
491
+ });
492
+ };
493
+ /** Remove one layer, so it narrows nothing again. */
494
+ export const useDeleteMcpPolicyLayer = (scope, subjectUid) => {
495
+ const queryClient = useQueryClient();
496
+ const token = useIAMStore(state => state.token);
497
+ const iamUrl = useIamUrl();
498
+ return useMutation({
499
+ mutationFn: () => deleteMcpPolicy(token ?? '', scope, subjectUid, iamUrl),
500
+ onSuccess: () => {
501
+ queryClient.invalidateQueries({
502
+ queryKey: queryKeys.mcp.policyLayer(scope, subjectUid),
503
+ });
504
+ queryClient.invalidateQueries({ queryKey: queryKeys.mcp.policy() });
505
+ },
506
+ });
507
+ };
508
+ // -- Service agents (IAM) --------------------------------------------------
509
+ /**
510
+ * One organization's service agents, revoked ones included.
511
+ *
512
+ * Keyed by the organization: two organizations' lists must never share a
513
+ * cache entry, or an owner of both would see one under the other's name.
514
+ */
515
+ export const useServiceAgents = (orgUid, options = {}) => {
516
+ const token = useIAMStore(state => state.token);
517
+ const iamUrl = useIamUrl();
518
+ return useQuery({
519
+ queryKey: queryKeys.mcp.serviceAgents(orgUid),
520
+ queryFn: () => listServiceAgents(token ?? '', orgUid, iamUrl),
521
+ enabled: Boolean(token && iamUrl && orgUid) && (options.enabled ?? true),
522
+ staleTime: 30_000,
523
+ });
524
+ };
525
+ /**
526
+ * Create one. The answer carries the key, and it is the only place it
527
+ * exists — so the caller must render it before doing anything else with it.
528
+ */
529
+ export const useCreateServiceAgent = (orgUid) => {
530
+ const queryClient = useQueryClient();
531
+ const token = useIAMStore(state => state.token);
532
+ const iamUrl = useIamUrl();
533
+ return useMutation({
534
+ mutationFn: agent => createServiceAgent(token ?? '', orgUid, agent, iamUrl),
535
+ onSuccess: () => {
536
+ queryClient.invalidateQueries({
537
+ queryKey: queryKeys.mcp.serviceAgents(orgUid),
538
+ });
539
+ },
540
+ });
541
+ };
542
+ /** Replace an agent's key; the old one stops working with the call. */
543
+ export const useRotateServiceAgentKey = (orgUid) => {
544
+ const queryClient = useQueryClient();
545
+ const token = useIAMStore(state => state.token);
546
+ const iamUrl = useIamUrl();
547
+ return useMutation({
548
+ mutationFn: agentUid => rotateServiceAgentKey(token ?? '', orgUid, agentUid, iamUrl),
549
+ onSuccess: () => {
550
+ queryClient.invalidateQueries({
551
+ queryKey: queryKeys.mcp.serviceAgents(orgUid),
552
+ });
553
+ },
554
+ });
555
+ };
556
+ /** Stop an agent. The list is refetched rather than edited in place. */
557
+ export const useRevokeServiceAgent = (orgUid) => {
558
+ const queryClient = useQueryClient();
559
+ const token = useIAMStore(state => state.token);
560
+ const iamUrl = useIamUrl();
561
+ return useMutation({
562
+ mutationFn: agentUid => revokeServiceAgent(token ?? '', orgUid, agentUid, iamUrl),
563
+ onSuccess: () => {
564
+ queryClient.invalidateQueries({
565
+ queryKey: queryKeys.mcp.serviceAgents(orgUid),
566
+ });
567
+ },
568
+ });
569
+ };
570
+ // -- Observability (OTEL) --------------------------------------------------
571
+ /** The spans of a run, from the task's trace id; asked again while the task runs. */
572
+ export const useRunTrace = (taskUid, options = {}) => {
573
+ const token = useIAMStore(state => state.token);
574
+ const otelUrl = useOtelUrl();
575
+ const task = useTask(taskUid);
576
+ return useQuery({
577
+ queryKey: queryKeys.mcp.trace(taskUid ?? ''),
578
+ queryFn: () => fetchRunTrace(token ?? '', task.data, otelUrl),
579
+ enabled: Boolean(token && otelUrl && task.data) && (options.enabled ?? true),
580
+ staleTime: 15_000,
581
+ refetchInterval: task.data && !isMcpTaskTerminal(task.data.status) ? 5_000 : false,
582
+ });
583
+ };
584
+ /**
585
+ * The spans of one trace, for a call that finished inside its own request.
586
+ *
587
+ * Read once and kept: a finished trace does not change, and the pane that
588
+ * shows it is opened from an audit row rather than watched.
589
+ */
590
+ export const useMcpTrace = (traceId, options = {}) => {
591
+ const token = useIAMStore(state => state.token);
592
+ const otelUrl = useOtelUrl();
593
+ return useQuery({
594
+ queryKey: queryKeys.mcp.traceById(traceId ?? ''),
595
+ queryFn: () => fetchTraceSpans(token ?? '', traceId, otelUrl),
596
+ enabled: Boolean(token && otelUrl && traceId) && (options.enabled ?? true),
597
+ staleTime: 60_000,
598
+ });
599
+ };
600
+ /** The four SLIs and the catalog, platform-wide or for one agent or organization. */
601
+ export const useMcpMetrics = (filters = {}, options = {}) => {
602
+ const token = useIAMStore(state => state.token);
603
+ const otelUrl = useOtelUrl();
604
+ return useQuery({
605
+ queryKey: queryKeys.mcp.metrics(filters),
606
+ queryFn: () => fetchMcpMetrics(token ?? '', filters, otelUrl),
607
+ enabled: Boolean(token && otelUrl) && (options.enabled ?? true),
608
+ staleTime: 30_000,
609
+ });
610
+ };
611
+ /** The log lines of a run, gateway and worker alike, by its trace. */
612
+ export const useMcpLogs = (taskUid, options = {}) => {
613
+ const token = useIAMStore(state => state.token);
614
+ const otelUrl = useOtelUrl();
615
+ const task = useTask(taskUid);
616
+ return useQuery({
617
+ queryKey: queryKeys.mcp.logs(taskUid ?? ''),
618
+ queryFn: () => fetchMcpLogs(token ?? '', task.data, { limit: options.limit, severity: options.severity }, otelUrl),
619
+ enabled: Boolean(token && otelUrl && task.data) && (options.enabled ?? true),
620
+ staleTime: 15_000,
621
+ refetchInterval: task.data && !isMcpTaskTerminal(task.data.status) ? 5_000 : false,
622
+ });
623
+ };
624
+ // -- Operations (platform administrators) ----------------------------------
625
+ export const useMcpWorkers = (options = {}) => {
626
+ const token = useIAMStore(state => state.token);
627
+ const mcpUrl = useMcpServerUrl();
628
+ return useQuery({
629
+ queryKey: queryKeys.mcp.workers(),
630
+ queryFn: () => listWorkers(token ?? '', mcpUrl),
631
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
632
+ staleTime: 5_000,
633
+ refetchInterval: 10_000,
634
+ });
635
+ };
636
+ export const useMcpWorkflowsHealth = (options = {}) => {
637
+ const token = useIAMStore(state => state.token);
638
+ const mcpUrl = useMcpServerUrl();
639
+ return useQuery({
640
+ queryKey: queryKeys.mcp.workflows(),
641
+ queryFn: () => getWorkflowsHealth(token ?? '', mcpUrl),
642
+ enabled: Boolean(token && mcpUrl) && (options.enabled ?? true),
643
+ staleTime: 10_000,
644
+ refetchInterval: 30_000,
645
+ });
646
+ };
647
+ /** The gateway's version and resource; no token needed. */
648
+ export const useMcpGatewayVersion = () => {
649
+ const mcpUrl = useMcpServerUrl();
650
+ return useQuery({
651
+ queryKey: queryKeys.mcp.gatewayVersion(),
652
+ queryFn: () => getGatewayVersion(mcpUrl),
653
+ enabled: Boolean(mcpUrl),
654
+ staleTime: 300_000,
655
+ });
656
+ };
@@ -2,11 +2,6 @@
2
2
  * Copyright (c) 2023-2025 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
- /*
6
- * Copyright (c) 2024-2025 Datalayer, Inc.
7
- *
8
- * BSD 3-Clause License
9
- */
10
5
  import * as React from 'react';
11
6
  const MOBILE_BREAKPOINT = 768;
12
7
  export function useIsMobile() {
@@ -10,8 +10,8 @@ import type { IKernelConnection } from '@jupyterlab/services/lib/kernel/kernel';
10
10
  export type ProjectRuntimeEntry = {
11
11
  /** The Jupyter session connection (notebook ↔ kernel bridge). */
12
12
  sessionConnection?: Session.ISessionConnection;
13
- /** The assigned agent pod name (mirrors project.attachedAgentPodName). */
14
- agentPodName?: string;
13
+ /** The assigned agent pod name (mirrors project.attachedAgentRuntimeName). */
14
+ agentRuntimeName?: string;
15
15
  /** Display name of the assigned agent. */
16
16
  agentName?: string;
17
17
  /** Agent runtime status (running, starting, terminated, etc.). */
@@ -29,7 +29,7 @@ export type ProjectStoreState = {
29
29
  /** Set or update the session connection for a project. */
30
30
  setSessionConnection: (projectId: string, sessionConnection: Session.ISessionConnection | undefined) => void;
31
31
  /** Set the assigned agent info for a project. */
32
- setAgent: (projectId: string, agentPodName: string | undefined, agentName?: string, agentStatus?: string, agentSpecId?: string) => void;
32
+ setAgent: (projectId: string, agentRuntimeName: string | undefined, agentName?: string, agentStatus?: string, agentSpecId?: string) => void;
33
33
  /** Remove all runtime state for a project (e.g. on unmount). */
34
34
  clearProject: (projectId: string) => void;
35
35
  /** Get the kernel connection for a project, or undefined. */