@agent-native/core 0.129.1 → 0.130.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 (596) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +78 -0
  3. package/corpus/core/docs/content/cloneable-saas.mdx +114 -0
  4. package/corpus/core/docs/content/creating-templates.mdx +28 -2
  5. package/corpus/core/docs/content/syncing-template-changes.mdx +7 -0
  6. package/corpus/core/docs/content/template-clips-developers.mdx +12 -5
  7. package/corpus/core/docs/content/template-dispatch-developers.mdx +1 -1
  8. package/corpus/core/docs/content/template-dispatch.mdx +1 -1
  9. package/corpus/core/package.json +1 -1
  10. package/corpus/core/src/action-ui.ts +1 -0
  11. package/corpus/core/src/action.ts +5 -1
  12. package/corpus/core/src/agent/engine/ai-sdk-engine.ts +15 -5
  13. package/corpus/core/src/agent/harness/runner.ts +5 -0
  14. package/corpus/core/src/agent/production-agent.ts +33 -0
  15. package/corpus/core/src/agent/run-loop-with-resume.ts +5 -0
  16. package/corpus/core/src/agent/run-manager.ts +126 -1
  17. package/corpus/core/src/agent/thread-data-builder.ts +47 -2
  18. package/corpus/core/src/agent/types.ts +2 -0
  19. package/corpus/core/src/chat-threads/store.ts +4 -5
  20. package/corpus/core/src/cli/create.ts +1139 -65
  21. package/corpus/core/src/cli/design-connect.ts +3 -7
  22. package/corpus/core/src/cli/index.ts +5 -3
  23. package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +83 -47
  24. package/corpus/core/src/client/AssistantChat.tsx +27 -16
  25. package/corpus/core/src/client/agent-chat-adapter.ts +24 -0
  26. package/corpus/core/src/client/blocks/library/wireframe-kit.tsx +17 -2
  27. package/corpus/core/src/client/chat/index.ts +1 -0
  28. package/corpus/core/src/client/chat/message-components.tsx +104 -1
  29. package/corpus/core/src/client/chat/run-recovery.tsx +15 -3
  30. package/corpus/core/src/client/chat/widgets/DataTableWidget.tsx +10 -29
  31. package/corpus/core/src/client/chat/widgets/WorkspaceFileWidget.tsx +71 -0
  32. package/corpus/core/src/client/chat/widgets/builtin-tool-renderers.tsx +22 -0
  33. package/corpus/core/src/client/chat/widgets/workspace-file-result.ts +49 -0
  34. package/corpus/core/src/client/embed-auth.ts +2 -0
  35. package/corpus/core/src/client/org/InvitationBanner.tsx +14 -1
  36. package/corpus/core/src/client/org/OrgSwitcher.tsx +23 -0
  37. package/corpus/core/src/client/org/TeamPage.tsx +130 -0
  38. package/corpus/core/src/client/org/WorkspaceNotice.tsx +85 -0
  39. package/corpus/core/src/client/org/hooks.ts +14 -0
  40. package/corpus/core/src/client/org/index.ts +2 -0
  41. package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +27 -40
  42. package/corpus/core/src/client/resources/ResourcesPanel.tsx +134 -51
  43. package/corpus/core/src/client/resources/mcp-integration-catalog.ts +7 -0
  44. package/corpus/core/src/client/resources/use-resources.ts +6 -0
  45. package/corpus/core/src/client/use-action.ts +3 -1
  46. package/corpus/core/src/client/widgets/index.ts +1 -0
  47. package/corpus/core/src/coding-tools/run-code.ts +2 -1
  48. package/corpus/core/src/db/client.ts +28 -4
  49. package/corpus/core/src/deploy/build.ts +31 -3
  50. package/corpus/core/src/eject/remote-mcp-presets.ts +1 -1
  51. package/corpus/core/src/index.browser.ts +1 -0
  52. package/corpus/core/src/index.ts +1 -0
  53. package/corpus/core/src/integrations/google-docs-poller.ts +3 -0
  54. package/corpus/core/src/integrations/webhook-handler.ts +28 -11
  55. package/corpus/core/src/jobs/scheduler.ts +4 -0
  56. package/corpus/core/src/localization/default-messages.ts +3 -2
  57. package/corpus/core/src/mcp/build-server.ts +20 -2
  58. package/corpus/core/src/observability/traces.ts +48 -12
  59. package/corpus/core/src/org/handlers.ts +52 -1
  60. package/corpus/core/src/org/migrations.ts +4 -0
  61. package/corpus/core/src/org/plugin.ts +14 -0
  62. package/corpus/core/src/org/schema.ts +1 -0
  63. package/corpus/core/src/org/types.ts +8 -0
  64. package/corpus/core/src/org/workspace-url.ts +74 -0
  65. package/corpus/core/src/resources/handlers.ts +35 -5
  66. package/corpus/core/src/scripts/runner.ts +183 -5
  67. package/corpus/core/src/server/action-routes.ts +32 -2
  68. package/corpus/core/src/server/agent-chat-plugin.ts +29 -0
  69. package/corpus/core/src/server/agent-teams.ts +10 -1
  70. package/corpus/core/src/server/auth.ts +33 -7
  71. package/corpus/core/src/server/embed-route.ts +9 -0
  72. package/corpus/core/src/server/embed-session.ts +62 -3
  73. package/corpus/core/src/server/open-route.ts +20 -6
  74. package/corpus/core/src/server/prompts/framework-core-compact.ts +1 -1
  75. package/corpus/core/src/server/prompts/framework-core.ts +1 -0
  76. package/corpus/core/src/server/request-context.ts +36 -1
  77. package/corpus/core/src/shared/embed-auth.ts +1 -0
  78. package/corpus/core/src/shared/html-document.ts +115 -0
  79. package/corpus/core/src/shared/index.ts +1 -0
  80. package/corpus/core/src/sharing/access.ts +8 -1
  81. package/corpus/core/src/sharing/registry.ts +11 -2
  82. package/corpus/core/src/workspace-files/actions.ts +100 -0
  83. package/corpus/core/src/workspace-files/tool.ts +4 -0
  84. package/corpus/templates/analytics/.agents/skills/analysis-workspace/SKILL.md +4 -0
  85. package/corpus/templates/analytics/.agents/skills/hubspot/SKILL.md +9 -1
  86. package/corpus/templates/analytics/AGENTS.md +17 -24
  87. package/corpus/templates/analytics/actions/data-source-status.ts +11 -1
  88. package/corpus/templates/analytics/app/i18n-data.ts +34 -0
  89. package/corpus/templates/analytics/app/lib/data-source-status.ts +86 -0
  90. package/corpus/templates/analytics/app/lib/native-mcp-exclusions.ts +9 -0
  91. package/corpus/templates/analytics/app/pages/DataSources.tsx +184 -20
  92. package/corpus/templates/analytics/changelog/2026-07-28-native-analytics-data-sources-no-longer-show-duplicate-mc.md +6 -0
  93. package/corpus/templates/analytics/changelog/2026-07-29-exports-now-appear-in-chat-with-a-direct-download-instead-of.md +6 -0
  94. package/corpus/templates/analytics/changelog/2026-07-29-queued-chat-prompts-no-longer-resend-after-analytics-navigat.md +6 -0
  95. package/corpus/templates/analytics/changelog/2026-07-29-scheduled-dashboard-emails-load-every-panel-reliably-without.md +6 -0
  96. package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +6 -3
  97. package/corpus/templates/analytics/server/lib/credential-keys.ts +1 -1
  98. package/corpus/templates/analytics/server/lib/hubspot.ts +1 -1
  99. package/corpus/templates/analytics/server/lib/provider-credentials.ts +55 -1
  100. package/corpus/templates/analytics/server/plugins/agent-chat.ts +123 -27
  101. package/corpus/templates/analytics/server/routes/[...page].get.ts +2 -7
  102. package/corpus/templates/analytics/vite.config.ts +7 -0
  103. package/corpus/templates/brain/actions/list-connection-providers.ts +100 -2
  104. package/corpus/templates/brain/app/lib/brain.ts +10 -0
  105. package/corpus/templates/brain/app/routes/sources.tsx +15 -4
  106. package/corpus/templates/brain/changelog/2026-07-29-brain-automatically-retries-failed-source-syncs-and-guides-y.md +6 -0
  107. package/corpus/templates/brain/jobs/process-ingest-queue.ts +13 -0
  108. package/corpus/templates/brain/server/jobs/sync-sources.ts +27 -22
  109. package/corpus/templates/brain/server/plugins/agent-chat.ts +2 -1
  110. package/corpus/templates/brain/server/routes/api/brain/queue/run.post.ts +7 -1
  111. package/corpus/templates/clips/AGENTS.md +1 -1
  112. package/corpus/templates/clips/actions/create-recording-agent-link.ts +11 -1
  113. package/corpus/templates/clips/actions/update-comment.ts +68 -0
  114. package/corpus/templates/clips/app/components/editor/editor-layout.tsx +0 -1
  115. package/corpus/templates/clips/app/components/player/comments-panel.tsx +221 -65
  116. package/corpus/templates/clips/app/components/player/video-player.tsx +101 -27
  117. package/corpus/templates/clips/app/i18n/en-US.ts +2 -1
  118. package/corpus/templates/clips/app/routes/bug-report.done.tsx +48 -27
  119. package/corpus/templates/clips/app/routes/bug-report.tsx +43 -4
  120. package/corpus/templates/clips/app/routes/record.tsx +2 -0
  121. package/corpus/templates/clips/changelog/2026-07-29-clip-playback-now-recovers-instead-of-getting-stuck-when-a-b.md +6 -0
  122. package/corpus/templates/clips/changelog/2026-07-29-comments-can-now-be-edited-after-posting.md +6 -0
  123. package/corpus/templates/clips/changelog/2026-07-29-download-actions-now-use-a-shorter-clearer-label.md +6 -0
  124. package/corpus/templates/clips/changelog/2026-07-29-embedded-bug-reports-now-return-a-temporary-agent-readable.md +6 -0
  125. package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +1 -1
  126. package/corpus/templates/clips/desktop/src-tauri/src/system_audio.rs +21 -1
  127. package/corpus/templates/clips/shared/bug-report.ts +99 -0
  128. package/corpus/templates/content/actions/_content-database-personal-view.ts +7 -1
  129. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +5 -2
  130. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +20 -8
  131. package/corpus/templates/content/changelog/2026-07-29-missing-databases-no-longer-trigger-repeated-personal-view-e.md +6 -0
  132. package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +83 -47
  133. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +474 -55
  134. package/corpus/templates/design/.generated/bridge/embedded-wheel.generated.ts +3 -0
  135. package/corpus/templates/design/.generated/bridge/hit-test.generated.ts +18 -1
  136. package/corpus/templates/design/.generated/bridge/source-location.generated.ts +348 -0
  137. package/corpus/templates/design/actions/add-localhost-screens.ts +2 -7
  138. package/corpus/templates/design/actions/apply-visual-edit.ts +7 -1
  139. package/corpus/templates/design/actions/connect-localhost.ts +5 -9
  140. package/corpus/templates/design/actions/create-component.ts +16 -13
  141. package/corpus/templates/design/actions/grant-localhost-write-consent.ts +2 -7
  142. package/corpus/templates/design/actions/list-design-source-capabilities.ts +4 -7
  143. package/corpus/templates/design/actions/list-local-files.ts +26 -50
  144. package/corpus/templates/design/actions/list-localhost-connections.ts +2 -7
  145. package/corpus/templates/design/actions/migrate-board-objects-to-file.ts +2 -2
  146. package/corpus/templates/design/actions/open-visual-edit.ts +234 -135
  147. package/corpus/templates/design/actions/read-local-file.ts +26 -50
  148. package/corpus/templates/design/actions/request-localhost-write-consent.ts +2 -7
  149. package/corpus/templates/design/actions/write-local-file.ts +31 -73
  150. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +307 -133
  151. package/corpus/templates/design/app/components/design/EditPanel.tsx +94 -22
  152. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +137 -60
  153. package/corpus/templates/design/app/components/design/ResponsiveInteractBar.tsx +75 -14
  154. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +755 -97
  155. package/corpus/templates/design/app/components/design/bridge/embedded-wheel.bridge.ts +8 -0
  156. package/corpus/templates/design/app/components/design/bridge/hit-test.bridge.ts +24 -1
  157. package/corpus/templates/design/app/components/design/bridge/source-location.bridge.ts +530 -0
  158. package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbenchLoader.tsx +278 -0
  159. package/corpus/templates/design/app/components/design/code-workbench/editor/MonacoHost.tsx +32 -12
  160. package/corpus/templates/design/app/components/design/code-workbench/editor/monaco-setup.ts +14 -3
  161. package/corpus/templates/design/app/components/design/code-workbench/explorer/ExplorerView.tsx +87 -24
  162. package/corpus/templates/design/app/components/design/code-workbench/explorer/FileTree.tsx +36 -0
  163. package/corpus/templates/design/app/components/design/code-workbench/store.tsx +2 -1
  164. package/corpus/templates/design/app/components/design/code-workbench/workspace/localhost-provider.ts +48 -8
  165. package/corpus/templates/design/app/components/design/design-canvas/content-size-report.ts +3 -13
  166. package/corpus/templates/design/app/components/design/design-canvas/embedded-frame.ts +4 -2
  167. package/corpus/templates/design/app/components/design/design-canvas/hit-test.ts +3 -13
  168. package/corpus/templates/design/app/components/design/edit-panel/element-classification.ts +3 -1
  169. package/corpus/templates/design/app/components/design/edit-panel/inspect-code-source.ts +93 -0
  170. package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +4 -2
  171. package/corpus/templates/design/app/components/design/multi-screen/cross-screen-drop.ts +35 -0
  172. package/corpus/templates/design/app/components/design/multi-screen/iframe-targeting.ts +24 -0
  173. package/corpus/templates/design/app/components/design/multi-screen/types.ts +9 -0
  174. package/corpus/templates/design/app/components/design/types.ts +29 -0
  175. package/corpus/templates/design/app/components/layout/Layout.tsx +7 -4
  176. package/corpus/templates/design/app/hooks/use-navigation-state.ts +3 -0
  177. package/corpus/templates/design/app/i18n-data.ts +153 -46
  178. package/corpus/templates/design/app/i18n-responsive-interact.ts +12 -12
  179. package/corpus/templates/design/app/lib/design-editor-route.ts +23 -0
  180. package/corpus/templates/design/app/pages/VisualEdit.tsx +19 -6
  181. package/corpus/templates/design/app/pages/design-editor/action-error.ts +19 -0
  182. package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +29 -0
  183. package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +6 -0
  184. package/corpus/templates/design/app/pages/design-editor/code-layer-state.ts +277 -15
  185. package/corpus/templates/design/app/pages/design-editor/editor-state.ts +75 -9
  186. package/corpus/templates/design/app/pages/design-editor/layer-state-scope.ts +28 -0
  187. package/corpus/templates/design/app/pages/design-editor/live-screen-layer-drop.ts +41 -0
  188. package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +496 -41
  189. package/corpus/templates/design/app/pages/design-editor/pending-live-edit-unload-guard.ts +27 -0
  190. package/corpus/templates/design/app/pages/design-editor/pending-structure-verification.ts +10 -0
  191. package/corpus/templates/design/app/pages/design-editor/react-semantic-handoff.ts +168 -9
  192. package/corpus/templates/design/app/pages/design-editor/responsive-interact.ts +41 -3
  193. package/corpus/templates/design/app/pages/design-editor/screen-command-utils.ts +5 -0
  194. package/corpus/templates/design/app/pages/design-editor/selection-state.ts +42 -13
  195. package/corpus/templates/design/app/pages/design-editor/source-location.ts +180 -0
  196. package/corpus/templates/design/app/pages/design-editor/tool-state.ts +17 -0
  197. package/corpus/templates/design/app/public-routes.ts +1 -0
  198. package/corpus/templates/design/app/routes/visual-edit.$id.tsx +15 -0
  199. package/corpus/templates/design/changelog/2026-06-29-screen-overview-is-easier-to-find-and-named-screens-open-dir.md +1 -1
  200. package/corpus/templates/design/changelog/2026-07-28-deleting-a-selected-element-now-removes-it-from-the-live-pre.md +6 -0
  201. package/corpus/templates/design/changelog/2026-07-28-deleting-an-element-on-a-connected-localhost-screen-now-queu.md +6 -0
  202. package/corpus/templates/design/changelog/2026-07-28-interact-mode-now-shows-a-responsive-device-preview-with-pre.md +6 -0
  203. package/corpus/templates/design/changelog/2026-07-28-layer-hide-and-lock-now-apply-to-the-live-preview-instead-of.md +6 -0
  204. package/corpus/templates/design/changelog/2026-07-28-layers-panel-selections-on-a-connected-localhost-screen-can-.md +6 -0
  205. package/corpus/templates/design/changelog/2026-07-28-locked-layers-now-show-a-subtle-dashed-outline-in-the-live-p.md +6 -0
  206. package/corpus/templates/design/changelog/2026-07-28-the-apply-design-updates-button-now-counts-pending-live-text.md +6 -0
  207. package/corpus/templates/design/changelog/2026-07-28-the-design-canvas-no-longer-stalls-on-a-render-loop-while-a-.md +6 -0
  208. package/corpus/templates/design/changelog/2026-07-28-visual-edit-on-a-local-dev-server-no-longer-requires-signing.md +6 -0
  209. package/corpus/templates/design/changelog/2026-07-28-visual-edits-on-a-react-19-app-no-longer-report-a-source-lin.md +6 -0
  210. package/corpus/templates/design/changelog/2026-07-29-an-edit-that-cannot-be-written-to-source-now-names-the-reaso.md +6 -0
  211. package/corpus/templates/design/changelog/2026-07-29-applying-a-primitive-dropped-onto-a-connected-localhost-scre.md +6 -0
  212. package/corpus/templates/design/changelog/2026-07-29-changing-a-style-in-the-inspector-now-updates-a-connected-lo.md +6 -0
  213. package/corpus/templates/design/changelog/2026-07-29-choosing-edit-or-annotate-from-a-focused-screen-now-returns-.md +6 -0
  214. package/corpus/templates/design/changelog/2026-07-29-concurrent-source-edits-now-return-a-clear-conflict-response.md +6 -0
  215. package/corpus/templates/design/changelog/2026-07-29-creating-a-component-from-an-element-that-repeats-in-the-sou.md +6 -0
  216. package/corpus/templates/design/changelog/2026-07-29-deleting-an-element-you-just-dropped-onto-a-live-screen-no-l.md +6 -0
  217. package/corpus/templates/design/changelog/2026-07-29-dragging-a-layer-across-screens-no-longer-dies-when-the-poin.md +6 -0
  218. package/corpus/templates/design/changelog/2026-07-29-dragging-an-element-from-a-stored-screen-into-a-live-localho.md +6 -0
  219. package/corpus/templates/design/changelog/2026-07-29-drawing-a-box-on-the-canvas-and-dragging-it-into-a-connected.md +6 -0
  220. package/corpus/templates/design/changelog/2026-07-29-fixed-a-loading-screen-flicker-when-reopening-designs-with-a.md +6 -0
  221. package/corpus/templates/design/changelog/2026-07-29-interact-mode-has-edit-and-annotate-buttons-again-so-you-can.md +6 -0
  222. package/corpus/templates/design/changelog/2026-07-29-layer-groups-can-be-dropped-onto-live-localhost-screens.md +6 -0
  223. package/corpus/templates/design/changelog/2026-07-29-localhost-source-errors-now-say-what-actually-went-wrong-whi.md +6 -0
  224. package/corpus/templates/design/changelog/2026-07-29-opening-or-refreshing-a-live-localhost-screen-in-single-scre.md +6 -0
  225. package/corpus/templates/design/changelog/2026-07-29-redo-after-undoing-a-drop-onto-a-live-screen-puts-the-elemen.md +6 -0
  226. package/corpus/templates/design/changelog/2026-07-29-shapes-can-be-drawn-directly-onto-live-localhost-screens.md +6 -0
  227. package/corpus/templates/design/changelog/2026-07-29-shapes-drawn-on-the-canvas-board-now-appear-immediately-inst.md +6 -0
  228. package/corpus/templates/design/changelog/2026-07-29-style-edits-on-a-running-localhost-screen-now-preview-live-a.md +6 -0
  229. package/corpus/templates/design/changelog/2026-07-29-the-apply-design-updates-control-now-appears-as-a-clean-conn.md +6 -0
  230. package/corpus/templates/design/changelog/2026-07-29-visual-edits-on-a-mapped-component-instance-now-tell-the-age.md +6 -0
  231. package/corpus/templates/design/server/lib/design-data-access.ts +21 -7
  232. package/corpus/templates/design/server/lib/localhost-connection.ts +240 -0
  233. package/corpus/templates/design/server/routes/[...page].get.ts +2 -5
  234. package/corpus/templates/design/server/source-workspace.ts +2 -0
  235. package/corpus/templates/design/shared/code-layer.ts +43 -0
  236. package/corpus/templates/design/shared/html-content.ts +26 -0
  237. package/corpus/templates/design/shared/html-integrity.ts +21 -1
  238. package/corpus/templates/design/shared/local-jsx-visual-edit.ts +15 -0
  239. package/corpus/templates/design/shared/source-mode.ts +76 -0
  240. package/corpus/templates/dispatch/changelog/2026-07-29-workspace-members-without-admin-access-now-see-a-clear-permi.md +6 -0
  241. package/corpus/templates/dispatch/server/lib/usage-metrics.ts +2 -1
  242. package/corpus/templates/plan/app/lib/plan-annotation-runtime.ts +3 -4
  243. package/corpus/templates/plan/server/routes/[...page].get.ts +2 -5
  244. package/corpus/templates/slides/actions/patch-deck.ts +29 -17
  245. package/corpus/toolkit/CHANGELOG.md +6 -0
  246. package/corpus/toolkit/package.json +1 -1
  247. package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +3 -2
  248. package/dist/action-ui.d.ts +1 -0
  249. package/dist/action-ui.d.ts.map +1 -1
  250. package/dist/action-ui.js +1 -0
  251. package/dist/action-ui.js.map +1 -1
  252. package/dist/action.d.ts +5 -1
  253. package/dist/action.d.ts.map +1 -1
  254. package/dist/action.js.map +1 -1
  255. package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
  256. package/dist/agent/engine/ai-sdk-engine.js +13 -5
  257. package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
  258. package/dist/agent/harness/runner.d.ts.map +1 -1
  259. package/dist/agent/harness/runner.js +5 -0
  260. package/dist/agent/harness/runner.js.map +1 -1
  261. package/dist/agent/production-agent.d.ts +16 -0
  262. package/dist/agent/production-agent.d.ts.map +1 -1
  263. package/dist/agent/production-agent.js +18 -1
  264. package/dist/agent/production-agent.js.map +1 -1
  265. package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
  266. package/dist/agent/run-loop-with-resume.js +6 -0
  267. package/dist/agent/run-loop-with-resume.js.map +1 -1
  268. package/dist/agent/run-manager.d.ts +14 -0
  269. package/dist/agent/run-manager.d.ts.map +1 -1
  270. package/dist/agent/run-manager.js +91 -1
  271. package/dist/agent/run-manager.js.map +1 -1
  272. package/dist/agent/thread-data-builder.d.ts +3 -0
  273. package/dist/agent/thread-data-builder.d.ts.map +1 -1
  274. package/dist/agent/thread-data-builder.js +35 -3
  275. package/dist/agent/thread-data-builder.js.map +1 -1
  276. package/dist/agent/types.d.ts +2 -0
  277. package/dist/agent/types.d.ts.map +1 -1
  278. package/dist/agent/types.js.map +1 -1
  279. package/dist/chat-threads/store.d.ts.map +1 -1
  280. package/dist/chat-threads/store.js +4 -6
  281. package/dist/chat-threads/store.js.map +1 -1
  282. package/dist/cli/create.d.ts +66 -6
  283. package/dist/cli/create.d.ts.map +1 -1
  284. package/dist/cli/create.js +765 -66
  285. package/dist/cli/create.js.map +1 -1
  286. package/dist/cli/design-connect.d.ts.map +1 -1
  287. package/dist/cli/design-connect.js +2 -7
  288. package/dist/cli/design-connect.js.map +1 -1
  289. package/dist/cli/index.js +5 -3
  290. package/dist/cli/index.js.map +1 -1
  291. package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
  292. package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -1
  293. package/dist/cli/skills-content/design-visual-edit-skill.js +83 -47
  294. package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -1
  295. package/dist/client/AssistantChat.d.ts.map +1 -1
  296. package/dist/client/AssistantChat.js +16 -9
  297. package/dist/client/AssistantChat.js.map +1 -1
  298. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  299. package/dist/client/agent-chat-adapter.js +21 -0
  300. package/dist/client/agent-chat-adapter.js.map +1 -1
  301. package/dist/client/blocks/library/wireframe-kit.d.ts +2 -0
  302. package/dist/client/blocks/library/wireframe-kit.d.ts.map +1 -1
  303. package/dist/client/blocks/library/wireframe-kit.js +8 -2
  304. package/dist/client/blocks/library/wireframe-kit.js.map +1 -1
  305. package/dist/client/chat/index.d.ts +1 -1
  306. package/dist/client/chat/index.d.ts.map +1 -1
  307. package/dist/client/chat/index.js +1 -1
  308. package/dist/client/chat/index.js.map +1 -1
  309. package/dist/client/chat/message-components.d.ts +17 -0
  310. package/dist/client/chat/message-components.d.ts.map +1 -1
  311. package/dist/client/chat/message-components.js +24 -2
  312. package/dist/client/chat/message-components.js.map +1 -1
  313. package/dist/client/chat/run-recovery.d.ts +6 -0
  314. package/dist/client/chat/run-recovery.d.ts.map +1 -1
  315. package/dist/client/chat/run-recovery.js +13 -3
  316. package/dist/client/chat/run-recovery.js.map +1 -1
  317. package/dist/client/chat/widgets/DataTableWidget.d.ts.map +1 -1
  318. package/dist/client/chat/widgets/DataTableWidget.js +2 -3
  319. package/dist/client/chat/widgets/DataTableWidget.js.map +1 -1
  320. package/dist/client/chat/widgets/WorkspaceFileWidget.d.ts +5 -0
  321. package/dist/client/chat/widgets/WorkspaceFileWidget.d.ts.map +1 -0
  322. package/dist/client/chat/widgets/WorkspaceFileWidget.js +34 -0
  323. package/dist/client/chat/widgets/WorkspaceFileWidget.js.map +1 -0
  324. package/dist/client/chat/widgets/builtin-tool-renderers.d.ts.map +1 -1
  325. package/dist/client/chat/widgets/builtin-tool-renderers.js +13 -1
  326. package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -1
  327. package/dist/client/chat/widgets/workspace-file-result.d.ts +12 -0
  328. package/dist/client/chat/widgets/workspace-file-result.d.ts.map +1 -0
  329. package/dist/client/chat/widgets/workspace-file-result.js +34 -0
  330. package/dist/client/chat/widgets/workspace-file-result.js.map +1 -0
  331. package/dist/client/embed-auth.d.ts.map +1 -1
  332. package/dist/client/embed-auth.js +2 -1
  333. package/dist/client/embed-auth.js.map +1 -1
  334. package/dist/client/org/InvitationBanner.d.ts +5 -2
  335. package/dist/client/org/InvitationBanner.d.ts.map +1 -1
  336. package/dist/client/org/InvitationBanner.js +9 -2
  337. package/dist/client/org/InvitationBanner.js.map +1 -1
  338. package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
  339. package/dist/client/org/OrgSwitcher.js +3 -2
  340. package/dist/client/org/OrgSwitcher.js.map +1 -1
  341. package/dist/client/org/TeamPage.d.ts.map +1 -1
  342. package/dist/client/org/TeamPage.js +27 -3
  343. package/dist/client/org/TeamPage.js.map +1 -1
  344. package/dist/client/org/WorkspaceNotice.d.ts +18 -0
  345. package/dist/client/org/WorkspaceNotice.d.ts.map +1 -0
  346. package/dist/client/org/WorkspaceNotice.js +56 -0
  347. package/dist/client/org/WorkspaceNotice.js.map +1 -0
  348. package/dist/client/org/hooks.d.ts +1 -0
  349. package/dist/client/org/hooks.d.ts.map +1 -1
  350. package/dist/client/org/hooks.js +12 -0
  351. package/dist/client/org/hooks.js.map +1 -1
  352. package/dist/client/org/index.d.ts +2 -1
  353. package/dist/client/org/index.d.ts.map +1 -1
  354. package/dist/client/org/index.js +2 -1
  355. package/dist/client/org/index.js.map +1 -1
  356. package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
  357. package/dist/client/resources/McpIntegrationDialog.js +8 -12
  358. package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
  359. package/dist/client/resources/ResourcesPanel.d.ts +3 -0
  360. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  361. package/dist/client/resources/ResourcesPanel.js +49 -20
  362. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  363. package/dist/client/resources/mcp-integration-catalog.d.ts +1 -0
  364. package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
  365. package/dist/client/resources/mcp-integration-catalog.js +3 -0
  366. package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
  367. package/dist/client/resources/use-resources.d.ts +1 -0
  368. package/dist/client/resources/use-resources.d.ts.map +1 -1
  369. package/dist/client/resources/use-resources.js +3 -0
  370. package/dist/client/resources/use-resources.js.map +1 -1
  371. package/dist/client/use-action.d.ts +3 -1
  372. package/dist/client/use-action.d.ts.map +1 -1
  373. package/dist/client/use-action.js +3 -1
  374. package/dist/client/use-action.js.map +1 -1
  375. package/dist/client/widgets/index.d.ts +1 -1
  376. package/dist/client/widgets/index.d.ts.map +1 -1
  377. package/dist/client/widgets/index.js +1 -1
  378. package/dist/client/widgets/index.js.map +1 -1
  379. package/dist/coding-tools/run-code.js +2 -1
  380. package/dist/coding-tools/run-code.js.map +1 -1
  381. package/dist/collab/awareness.d.ts +2 -2
  382. package/dist/collab/awareness.d.ts.map +1 -1
  383. package/dist/collab/routes.d.ts +1 -1
  384. package/dist/db/client.d.ts +1 -0
  385. package/dist/db/client.d.ts.map +1 -1
  386. package/dist/db/client.js +24 -3
  387. package/dist/db/client.js.map +1 -1
  388. package/dist/deploy/build.d.ts.map +1 -1
  389. package/dist/deploy/build.js +25 -3
  390. package/dist/deploy/build.js.map +1 -1
  391. package/dist/eject/remote-mcp-presets.js +1 -1
  392. package/dist/eject/remote-mcp-presets.js.map +1 -1
  393. package/dist/index.browser.d.ts +1 -1
  394. package/dist/index.browser.d.ts.map +1 -1
  395. package/dist/index.browser.js +1 -1
  396. package/dist/index.browser.js.map +1 -1
  397. package/dist/index.d.ts +1 -1
  398. package/dist/index.d.ts.map +1 -1
  399. package/dist/index.js +1 -1
  400. package/dist/index.js.map +1 -1
  401. package/dist/integrations/google-docs-poller.d.ts.map +1 -1
  402. package/dist/integrations/google-docs-poller.js +4 -1
  403. package/dist/integrations/google-docs-poller.js.map +1 -1
  404. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  405. package/dist/integrations/webhook-handler.js +23 -11
  406. package/dist/integrations/webhook-handler.js.map +1 -1
  407. package/dist/jobs/scheduler.js +4 -0
  408. package/dist/jobs/scheduler.js.map +1 -1
  409. package/dist/localization/default-messages.d.ts +3 -2
  410. package/dist/localization/default-messages.d.ts.map +1 -1
  411. package/dist/localization/default-messages.js +3 -2
  412. package/dist/localization/default-messages.js.map +1 -1
  413. package/dist/mcp/build-server.d.ts.map +1 -1
  414. package/dist/mcp/build-server.js +10 -1
  415. package/dist/mcp/build-server.js.map +1 -1
  416. package/dist/notifications/routes.d.ts +1 -1
  417. package/dist/observability/traces.d.ts.map +1 -1
  418. package/dist/observability/traces.js +27 -7
  419. package/dist/observability/traces.js.map +1 -1
  420. package/dist/org/handlers.d.ts +15 -0
  421. package/dist/org/handlers.d.ts.map +1 -1
  422. package/dist/org/handlers.js +45 -1
  423. package/dist/org/handlers.js.map +1 -1
  424. package/dist/org/migrations.d.ts.map +1 -1
  425. package/dist/org/migrations.js +4 -0
  426. package/dist/org/migrations.js.map +1 -1
  427. package/dist/org/plugin.d.ts +1 -0
  428. package/dist/org/plugin.d.ts.map +1 -1
  429. package/dist/org/plugin.js +10 -1
  430. package/dist/org/plugin.js.map +1 -1
  431. package/dist/org/schema.d.ts +19 -0
  432. package/dist/org/schema.d.ts.map +1 -1
  433. package/dist/org/schema.js +1 -0
  434. package/dist/org/schema.js.map +1 -1
  435. package/dist/org/types.d.ts +8 -0
  436. package/dist/org/types.d.ts.map +1 -1
  437. package/dist/org/types.js.map +1 -1
  438. package/dist/org/workspace-url.d.ts +32 -0
  439. package/dist/org/workspace-url.d.ts.map +1 -0
  440. package/dist/org/workspace-url.js +63 -0
  441. package/dist/org/workspace-url.js.map +1 -0
  442. package/dist/progress/routes.d.ts +1 -1
  443. package/dist/provider-api/actions/custom-provider-registration.d.ts +11 -11
  444. package/dist/provider-api/actions/provider-api.d.ts +7 -7
  445. package/dist/resources/handlers.d.ts +2 -3
  446. package/dist/resources/handlers.d.ts.map +1 -1
  447. package/dist/resources/handlers.js +25 -5
  448. package/dist/resources/handlers.js.map +1 -1
  449. package/dist/scripts/runner.d.ts +17 -0
  450. package/dist/scripts/runner.d.ts.map +1 -1
  451. package/dist/scripts/runner.js +130 -5
  452. package/dist/scripts/runner.js.map +1 -1
  453. package/dist/secrets/routes.d.ts +9 -9
  454. package/dist/server/action-routes.d.ts.map +1 -1
  455. package/dist/server/action-routes.js +24 -2
  456. package/dist/server/action-routes.js.map +1 -1
  457. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  458. package/dist/server/agent-chat-plugin.js +26 -1
  459. package/dist/server/agent-chat-plugin.js.map +1 -1
  460. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  461. package/dist/server/agent-teams.d.ts.map +1 -1
  462. package/dist/server/agent-teams.js +10 -1
  463. package/dist/server/agent-teams.js.map +1 -1
  464. package/dist/server/auth.d.ts +22 -0
  465. package/dist/server/auth.d.ts.map +1 -1
  466. package/dist/server/auth.js +33 -7
  467. package/dist/server/auth.js.map +1 -1
  468. package/dist/server/embed-route.d.ts.map +1 -1
  469. package/dist/server/embed-route.js +6 -1
  470. package/dist/server/embed-route.js.map +1 -1
  471. package/dist/server/embed-session.d.ts +7 -0
  472. package/dist/server/embed-session.d.ts.map +1 -1
  473. package/dist/server/embed-session.js +46 -4
  474. package/dist/server/embed-session.js.map +1 -1
  475. package/dist/server/open-route.d.ts.map +1 -1
  476. package/dist/server/open-route.js +17 -7
  477. package/dist/server/open-route.js.map +1 -1
  478. package/dist/server/prompts/framework-core-compact.js +1 -1
  479. package/dist/server/prompts/framework-core-compact.js.map +1 -1
  480. package/dist/server/prompts/framework-core.d.ts.map +1 -1
  481. package/dist/server/prompts/framework-core.js +1 -0
  482. package/dist/server/prompts/framework-core.js.map +1 -1
  483. package/dist/server/request-context.d.ts +26 -0
  484. package/dist/server/request-context.d.ts.map +1 -1
  485. package/dist/server/request-context.js +18 -1
  486. package/dist/server/request-context.js.map +1 -1
  487. package/dist/shared/embed-auth.d.ts +1 -0
  488. package/dist/shared/embed-auth.d.ts.map +1 -1
  489. package/dist/shared/embed-auth.js +1 -0
  490. package/dist/shared/embed-auth.js.map +1 -1
  491. package/dist/shared/html-document.d.ts +12 -0
  492. package/dist/shared/html-document.d.ts.map +1 -0
  493. package/dist/shared/html-document.js +92 -0
  494. package/dist/shared/html-document.js.map +1 -0
  495. package/dist/shared/index.d.ts +1 -0
  496. package/dist/shared/index.d.ts.map +1 -1
  497. package/dist/shared/index.js +1 -0
  498. package/dist/shared/index.js.map +1 -1
  499. package/dist/sharing/access.d.ts +1 -0
  500. package/dist/sharing/access.d.ts.map +1 -1
  501. package/dist/sharing/access.js +8 -2
  502. package/dist/sharing/access.js.map +1 -1
  503. package/dist/sharing/registry.d.ts +3 -0
  504. package/dist/sharing/registry.d.ts.map +1 -1
  505. package/dist/sharing/registry.js.map +1 -1
  506. package/dist/workspace-files/actions.d.ts +28 -0
  507. package/dist/workspace-files/actions.d.ts.map +1 -0
  508. package/dist/workspace-files/actions.js +75 -0
  509. package/dist/workspace-files/actions.js.map +1 -0
  510. package/dist/workspace-files/tool.d.ts.map +1 -1
  511. package/dist/workspace-files/tool.js +4 -0
  512. package/dist/workspace-files/tool.js.map +1 -1
  513. package/docs/content/cloneable-saas.mdx +114 -0
  514. package/docs/content/creating-templates.mdx +28 -2
  515. package/docs/content/syncing-template-changes.mdx +7 -0
  516. package/docs/content/template-clips-developers.mdx +12 -5
  517. package/docs/content/template-dispatch-developers.mdx +1 -1
  518. package/docs/content/template-dispatch.mdx +1 -1
  519. package/package.json +2 -2
  520. package/src/action-ui.ts +1 -0
  521. package/src/action.ts +5 -1
  522. package/src/agent/engine/ai-sdk-engine.ts +15 -5
  523. package/src/agent/harness/runner.ts +5 -0
  524. package/src/agent/production-agent.ts +33 -0
  525. package/src/agent/run-loop-with-resume.ts +5 -0
  526. package/src/agent/run-manager.ts +126 -1
  527. package/src/agent/thread-data-builder.ts +47 -2
  528. package/src/agent/types.ts +2 -0
  529. package/src/chat-threads/store.ts +4 -5
  530. package/src/cli/create.ts +1139 -65
  531. package/src/cli/design-connect.ts +3 -7
  532. package/src/cli/index.ts +5 -3
  533. package/src/cli/skills-content/design-visual-edit-skill.ts +83 -47
  534. package/src/client/AssistantChat.tsx +27 -16
  535. package/src/client/agent-chat-adapter.ts +24 -0
  536. package/src/client/blocks/library/wireframe-kit.tsx +17 -2
  537. package/src/client/chat/index.ts +1 -0
  538. package/src/client/chat/message-components.tsx +104 -1
  539. package/src/client/chat/run-recovery.tsx +15 -3
  540. package/src/client/chat/widgets/DataTableWidget.tsx +10 -29
  541. package/src/client/chat/widgets/WorkspaceFileWidget.tsx +71 -0
  542. package/src/client/chat/widgets/builtin-tool-renderers.tsx +22 -0
  543. package/src/client/chat/widgets/workspace-file-result.ts +49 -0
  544. package/src/client/embed-auth.ts +2 -0
  545. package/src/client/org/InvitationBanner.tsx +14 -1
  546. package/src/client/org/OrgSwitcher.tsx +23 -0
  547. package/src/client/org/TeamPage.tsx +130 -0
  548. package/src/client/org/WorkspaceNotice.tsx +85 -0
  549. package/src/client/org/hooks.ts +14 -0
  550. package/src/client/org/index.ts +2 -0
  551. package/src/client/resources/McpIntegrationDialog.tsx +27 -40
  552. package/src/client/resources/ResourcesPanel.tsx +134 -51
  553. package/src/client/resources/mcp-integration-catalog.ts +7 -0
  554. package/src/client/resources/use-resources.ts +6 -0
  555. package/src/client/use-action.ts +3 -1
  556. package/src/client/widgets/index.ts +1 -0
  557. package/src/coding-tools/run-code.ts +2 -1
  558. package/src/db/client.ts +28 -4
  559. package/src/deploy/build.ts +31 -3
  560. package/src/eject/remote-mcp-presets.ts +1 -1
  561. package/src/index.browser.ts +1 -0
  562. package/src/index.ts +1 -0
  563. package/src/integrations/google-docs-poller.ts +3 -0
  564. package/src/integrations/webhook-handler.ts +28 -11
  565. package/src/jobs/scheduler.ts +4 -0
  566. package/src/localization/default-messages.ts +3 -2
  567. package/src/mcp/build-server.ts +20 -2
  568. package/src/observability/traces.ts +48 -12
  569. package/src/org/handlers.ts +52 -1
  570. package/src/org/migrations.ts +4 -0
  571. package/src/org/plugin.ts +14 -0
  572. package/src/org/schema.ts +1 -0
  573. package/src/org/types.ts +8 -0
  574. package/src/org/workspace-url.ts +74 -0
  575. package/src/resources/handlers.ts +35 -5
  576. package/src/scripts/runner.ts +183 -5
  577. package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +2 -1
  578. package/src/server/action-routes.ts +32 -2
  579. package/src/server/agent-chat-plugin.ts +29 -0
  580. package/src/server/agent-teams.ts +10 -1
  581. package/src/server/auth.ts +33 -7
  582. package/src/server/embed-route.ts +9 -0
  583. package/src/server/embed-session.ts +62 -3
  584. package/src/server/open-route.ts +20 -6
  585. package/src/server/prompts/framework-core-compact.ts +1 -1
  586. package/src/server/prompts/framework-core.ts +1 -0
  587. package/src/server/request-context.ts +36 -1
  588. package/src/shared/embed-auth.ts +1 -0
  589. package/src/shared/html-document.ts +115 -0
  590. package/src/shared/index.ts +1 -0
  591. package/src/sharing/access.ts +8 -1
  592. package/src/sharing/registry.ts +11 -2
  593. package/src/workspace-files/actions.ts +100 -0
  594. package/src/workspace-files/tool.ts +4 -0
  595. package/corpus/templates/design/changelog/2026-07-28-interact-mode-can-preview-designs-in-responsive-device-sizes.md +0 -6
  596. package/corpus/templates/design/changelog/2026-07-28-interact-mode-now-opens-a-full-screen-responsive-preview-wit.md +0 -6
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconExternalLink } from "@tabler/icons-react";
3
+ import { useState } from "react";
4
+ import { shouldOfferWorkspace } from "../../org/workspace-url.js";
5
+ import { useOrg } from "./hooks.js";
6
+ const DISMISS_KEY_PREFIX = "agent-native:workspace-notice-dismissed:";
7
+ function dismissKey(workspaceUrl) {
8
+ return `${DISMISS_KEY_PREFIX}${workspaceUrl}`;
9
+ }
10
+ function readDismissed(workspaceUrl) {
11
+ try {
12
+ return localStorage.getItem(dismissKey(workspaceUrl)) === "1";
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ }
18
+ /**
19
+ * Points a member at their org's own workspace when they've landed somewhere
20
+ * else — typically a shared hosted app opened from the template catalog.
21
+ *
22
+ * The switcher shows the same org name on both deployments, so without this
23
+ * the two are indistinguishable: the app looks like their team's, the team's
24
+ * apps aren't in it, and the natural reading is a broken session rather than
25
+ * a different host. Renders nothing unless an owner/admin has set a workspace
26
+ * URL and the member is not already on it.
27
+ *
28
+ * Deliberately a choice, not a redirect. The shared hosted app is the real
29
+ * product for most people, and some members of an org with a workspace still
30
+ * want to be here.
31
+ */
32
+ export function WorkspaceNotice({ className }) {
33
+ const { data: org } = useOrg();
34
+ // Only re-renders after a click; the persisted answer is re-read below,
35
+ // because on every load this renders before the org query resolves and a
36
+ // value captured then would always be the pre-data default.
37
+ const [dismissedNow, setDismissedNow] = useState(false);
38
+ const workspaceUrl = org?.workspaceUrl ?? null;
39
+ if (typeof window === "undefined")
40
+ return null;
41
+ if (!workspaceUrl || dismissedNow || readDismissed(workspaceUrl))
42
+ return null;
43
+ if (!shouldOfferWorkspace(window.location.href, workspaceUrl))
44
+ return null;
45
+ const workspaceHost = new URL(workspaceUrl).host;
46
+ return (_jsx("div", { className: `border-b border-border bg-blue-50 dark:bg-blue-950/30 px-3 py-2.5 sm:px-4 ${className ?? ""}`, children: _jsxs("div", { className: "flex items-center justify-between gap-4 text-sm", children: [_jsxs("span", { className: "min-w-0 flex-1 text-foreground", children: [_jsx("span", { className: "font-medium", children: org?.orgName }), " has its own workspace at ", _jsx("span", { className: "font-medium", children: workspaceHost }), ". Your team's apps live there, not here."] }), _jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [_jsxs("a", { href: workspaceUrl, className: "inline-flex items-center gap-1.5 rounded-md bg-green-600 px-3 py-1.5 text-xs font-medium text-white no-underline hover:bg-green-700", children: [_jsx(IconExternalLink, { className: "h-3 w-3" }), "Go there"] }), _jsx("button", { type: "button", onClick: () => {
47
+ try {
48
+ localStorage.setItem(dismissKey(workspaceUrl), "1");
49
+ }
50
+ catch {
51
+ // Private-mode storage failure only costs a repeat banner.
52
+ }
53
+ setDismissedNow(true);
54
+ }, className: "rounded-md border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground cursor-pointer", children: "Stay here" })] })] }) }));
55
+ }
56
+ //# sourceMappingURL=WorkspaceNotice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspaceNotice.js","sourceRoot":"","sources":["../../../src/client/org/WorkspaceNotice.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,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AAS,EAAC,gCAAgC,aAC9C,eAAM,SAAS,EAAC,aAAa,YAAE,GAAG,EAAE,OAAO,GAAQ,gCACtC,eAAM,SAAS,EAAC,aAAa,YAAE,aAAa,GAAQ,gDAE5D,EACP,eAAK,SAAS,EAAC,kCAAkC,aAC/C,aACE,IAAI,EAAE,YAAY,EAClB,SAAS,EAAC,qIAAqI,aAE/I,KAAC,gBAAgB,IAAC,SAAS,EAAC,SAAS,GAAG,gBAEtC,EACJ,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE;gCACZ,IAAI,CAAC;oCACH,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC;gCACtD,CAAC;gCAAC,MAAM,CAAC;oCACP,2DAA2D;gCAC7D,CAAC;gCACD,eAAe,CAAC,IAAI,CAAC,CAAC;4BACxB,CAAC,EACD,SAAS,EAAC,4HAA4H,0BAG/H,IACL,IACF,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { IconExternalLink } from \"@tabler/icons-react\";\nimport { useState } from \"react\";\n\nimport { shouldOfferWorkspace } from \"../../org/workspace-url.js\";\nimport { useOrg } from \"./hooks.js\";\n\nconst DISMISS_KEY_PREFIX = \"agent-native:workspace-notice-dismissed:\";\n\nfunction dismissKey(workspaceUrl: string): string {\n return `${DISMISS_KEY_PREFIX}${workspaceUrl}`;\n}\n\nfunction readDismissed(workspaceUrl: string): boolean {\n try {\n return localStorage.getItem(dismissKey(workspaceUrl)) === \"1\";\n } catch {\n return false;\n }\n}\n\n/**\n * Points a member at their org's own workspace when they've landed somewhere\n * else — typically a shared hosted app opened from the template catalog.\n *\n * The switcher shows the same org name on both deployments, so without this\n * the two are indistinguishable: the app looks like their team's, the team's\n * apps aren't in it, and the natural reading is a broken session rather than\n * a different host. Renders nothing unless an owner/admin has set a workspace\n * URL and the member is not already on it.\n *\n * Deliberately a choice, not a redirect. The shared hosted app is the real\n * product for most people, and some members of an org with a workspace still\n * want to be here.\n */\nexport function WorkspaceNotice({ className }: { className?: string }) {\n const { data: org } = useOrg();\n // Only re-renders after a click; the persisted answer is re-read below,\n // because on every load this renders before the org query resolves and a\n // value captured then would always be the pre-data default.\n const [dismissedNow, setDismissedNow] = useState(false);\n const workspaceUrl = org?.workspaceUrl ?? null;\n\n if (typeof window === \"undefined\") return null;\n if (!workspaceUrl || dismissedNow || readDismissed(workspaceUrl)) return null;\n if (!shouldOfferWorkspace(window.location.href, workspaceUrl)) return null;\n\n const workspaceHost = new URL(workspaceUrl).host;\n\n return (\n <div\n className={`border-b border-border bg-blue-50 dark:bg-blue-950/30 px-3 py-2.5 sm:px-4 ${className ?? \"\"}`}\n >\n <div className=\"flex items-center justify-between gap-4 text-sm\">\n <span className=\"min-w-0 flex-1 text-foreground\">\n <span className=\"font-medium\">{org?.orgName}</span> has its own\n workspace at <span className=\"font-medium\">{workspaceHost}</span>.\n Your team&apos;s apps live there, not here.\n </span>\n <div className=\"flex shrink-0 items-center gap-2\">\n <a\n href={workspaceUrl}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-green-600 px-3 py-1.5 text-xs font-medium text-white no-underline hover:bg-green-700\"\n >\n <IconExternalLink className=\"h-3 w-3\" />\n Go there\n </a>\n <button\n type=\"button\"\n onClick={() => {\n try {\n localStorage.setItem(dismissKey(workspaceUrl), \"1\");\n } catch {\n // Private-mode storage failure only costs a repeat banner.\n }\n setDismissedNow(true);\n }}\n className=\"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground cursor-pointer\"\n >\n Stay here\n </button>\n </div>\n </div>\n </div>\n );\n}\n"]}
@@ -54,6 +54,7 @@ export declare function useSwitchOrg(): import("@tanstack/react-query").UseMutat
54
54
  export declare function useDeleteOrg(): import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
55
55
  export declare function useJoinByDomain(): import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
56
56
  export declare function useSetOrgDomain(): import("@tanstack/react-query").UseMutationResult<any, Error, string | null, unknown>;
57
+ export declare function useSetOrgWorkspaceUrl(): import("@tanstack/react-query").UseMutationResult<any, Error, string | null, unknown>;
57
58
  export interface AppRoleAssignment {
58
59
  email: string;
59
60
  role: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/client/org/hooks.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,oBAAoB,EACpB,OAAO,EACR,MAAM,oBAAoB,CAAC;AAoC5B,wBAAgB,MAAM,4EAMrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,wBAAgB,UAAU,IAAI,gBAAgB,CAa7C;AAED,wBAAgB,aAAa;aAIA,SAAS,EAAE;WAKvC;AAED,wBAAgB,iBAAiB;iBAEA,oBAAoB,EAAE;WAKtD;AAmBD,wBAAgB,YAAY,mFAe3B;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,wBAAgB,eAAe,gGAoB9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,KAAK,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,UAAU,CAAC;QACjB,MAAM,EAAE,SAAS,CAAC;QAClB,SAAS,EAAE,OAAO,CAAC;QACn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gDomain() {
240
240
  },
241
241
  });
242
242
  }
243
+ export function useSetOrgWorkspaceUrl() {
244
+ const qc = useQueryClient();
245
+ return useMutation({
246
+ mutationFn: (url) => apiFetch(`${ORG_BASE}/workspace-url`, {
247
+ method: "PUT",
248
+ body: JSON.stringify({ url }),
249
+ }),
250
+ onSuccess: async () => {
251
+ await qc.invalidateQueries({ queryKey: ["org-me"] });
252
+ },
253
+ });
254
+ }
243
255
  /**
244
256
  * App-role vocabulary and assignments for the active org.
245
257
  *
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/client/org/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,QAAQ,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAEvD,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,IAAkB;IACtD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE;QAC5B,GAAG,IAAI;QACP,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,GAAG,IAAI,EAAE,OAAO;SACjB;KACF,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,uEAAuE;QACvE,qEAAqE;QACrE,2DAA2D;QAC3D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,OAAO,GAAW,GAAG,CAAC,UAAU,CAAC;QACrC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,IA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AAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,WAAW,CAA4C;QAC5D,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,QAAQ,aAAa,CAAC;KACrD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IAC5B,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,CAAC,MAAe,EAAE,EAAE,CAC9B,QAAQ,CAAC,GAAG,QAAQ,aAAa,EAAE;YACjC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACjC,CAAC;QACJ,SAAS,EAAE,KAAK,IAAI,EAAE;YACpB,MAAM,EAAE,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvD,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAgBD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CACnB,QAAQ,CAAC,GAAG,QAAQ,kBAAkB,EAAE;YACtC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,UAAU,EACR,IAAI,IAAI,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;aAC7D,CAAC;SACH,CAAC;KACL,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nimport {\n canInviteOrgMembers,\n canManageOrg,\n canManageOrgDomain,\n} from \"../../org/permissions.js\";\nimport type {\n OrgInfo,\n OrgMember,\n OrgPendingInvitation,\n OrgRole,\n} from \"../../org/types.js\";\nimport { agentNativePath } from \"../api-path.js\";\n\nconst ORG_BASE = agentNativePath(\"/_agent-native/org\");\n\nasync function apiFetch(path: string, init?: RequestInit) {\n const res = await fetch(path, {\n ...init,\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...init?.headers,\n },\n });\n if (!res.ok) {\n // Prefer a JSON `error` / `message` field when the server returns one,\n // and only fall back to the raw body for plaintext responses. Avoids\n // surfacing `{\"error\":\"...\"}` as the user-visible message.\n const text = await res.text().catch(() => \"\");\n let message: string = res.statusText;\n if (text) {\n try {\n const parsed = JSON.parse(text) as {\n error?: string;\n message?: string;\n };\n message = parsed.error ?? parsed.message ?? text;\n } catch {\n message = text;\n }\n }\n throw new Error(message);\n }\n return res.json();\n}\n\nexport function useOrg() {\n return useQuery<OrgInfo>({\n queryKey: [\"org-me\"],\n queryFn: () => apiFetch(`${ORG_BASE}/me`),\n staleTime: 30_000,\n });\n}\n\nexport interface UseOrgRoleResult {\n org: OrgInfo | undefined;\n role: OrgRole | null;\n isOwner: boolean;\n canManageOrg: boolean;\n canInviteMembers: boolean;\n canManageDomain: boolean;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport function useOrgRole(): UseOrgRoleResult {\n const query = useOrg();\n const role = query.data?.role ?? null;\n return {\n org: query.data,\n role,\n isOwner: role === \"owner\",\n canManageOrg: canManageOrg(role),\n canInviteMembers: canInviteOrgMembers(role),\n canManageDomain: canManageOrgDomain(role),\n isLoading: query.isLoading,\n error: query.error,\n };\n}\n\nexport function useOrgMembers() {\n // Scope the cache by active orgId so switching or creating an org forces a\n // fresh fetch rather than briefly showing the previous org's members.\n const { data: org } = useOrg();\n return useQuery<{ members: OrgMember[] }>({\n queryKey: [\"org-members\", org?.orgId ?? null],\n queryFn: () => apiFetch(`${ORG_BASE}/members`),\n staleTime: 30_000,\n });\n}\n\nexport function useOrgInvitations() {\n const { data: org } = useOrg();\n return useQuery<{ invitations: OrgPendingInvitation[] }>({\n queryKey: [\"org-invitations\", org?.orgId ?? null],\n queryFn: () => apiFetch(`${ORG_BASE}/invitations`),\n staleTime: 30_000,\n });\n}\n\n// NOTE: the onSuccess handlers below `await invalidateQueries`. In\n// TanStack Query v5, invalidateQueries:\n// 1. Marks every matching query as stale, so the next mount of an\n// INACTIVE query (e.g. the org-members table on a settings page\n// the user hasn't visited yet) refetches immediately instead of\n// serving 30-second-stale cached data.\n// 2. Triggers a refetch of every ACTIVE query that matches.\n// 3. Returns a promise that resolves once those refetches settle.\n//\n// `await`ing therefore keeps `mutation.isPending` true through the\n// full read-after-write window — closing the create-org / accept-\n// invite race where a button could re-enable mid-refetch. We\n// previously tried refetchQueries here for \"unambiguous semantics\",\n// but that variant doesn't mark inactive queries stale, leaving them\n// to serve stale data on next mount. invalidateQueries is the right\n// primitive — it just needed an `await`.\n\nexport function useCreateOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (name: string) =>\n apiFetch(ORG_BASE, {\n method: \"POST\",\n body: JSON.stringify({ name }),\n }),\n onSuccess: async () => {\n // Creating an org also switches the user into it server-side, so every\n // org-scoped query (members, invitations, and template-level data) is\n // now stale. Match the broad invalidation that useSwitchOrg already does.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport type InviteRole = \"admin\" | \"member\";\n\nexport interface InviteVars {\n email: string;\n role?: InviteRole;\n}\n\nexport function useInviteMember() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: string | InviteVars) => {\n const body: { email: string; role: InviteRole } =\n typeof vars === \"string\"\n ? { email: vars, role: \"member\" }\n : { email: vars.email, role: vars.role ?? \"member\" };\n return apiFetch(`${ORG_BASE}/invitations`, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n },\n onSuccess: async () => {\n await Promise.all([\n qc.invalidateQueries({ queryKey: [\"org-members\"] }),\n qc.invalidateQueries({ queryKey: [\"org-invitations\"] }),\n ]);\n },\n });\n}\n\nexport interface BulkInviteResult {\n succeeded: Array<{\n id: string;\n email: string;\n role: InviteRole;\n status: \"pending\";\n emailSent: boolean;\n emailError?: string;\n }>;\n failed: Array<{ email: string; error: string }>;\n total: number;\n}\n\nexport function useBulkInviteMembers() {\n const qc = useQueryClient();\n return useMutation<BulkInviteResult, Error, InviteVars[]>({\n mutationFn: (invites) =>\n apiFetch(`${ORG_BASE}/invitations`, {\n method: \"POST\",\n body: JSON.stringify({\n invites: invites.map((i) => ({\n email: i.email,\n role: i.role ?? \"member\",\n })),\n }),\n }),\n onSuccess: async () => {\n await Promise.all([\n qc.invalidateQueries({ queryKey: [\"org-members\"] }),\n qc.invalidateQueries({ queryKey: [\"org-invitations\"] }),\n ]);\n },\n });\n}\n\nexport function useChangeMemberRole() {\n const qc = useQueryClient();\n return useMutation<\n { email: string; role: InviteRole },\n Error,\n { email: string; role: InviteRole }\n >({\n mutationFn: ({ email, role }) =>\n apiFetch(`${ORG_BASE}/members/${encodeURIComponent(email)}/role`, {\n method: \"PUT\",\n body: JSON.stringify({ role }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-members\"] });\n },\n });\n}\n\nexport function useAcceptInvitation() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (invitationId: string) =>\n apiFetch(`${ORG_BASE}/invitations/${invitationId}/accept`, {\n method: \"POST\",\n }),\n onSuccess: async () => {\n // Joining/switching orgs changes all org-scoped data — invalidate\n // every cached query (no key filter) so each one refetches or is\n // marked stale for the next mount.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useRemoveMember() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (email: string) =>\n apiFetch(`${ORG_BASE}/members/${encodeURIComponent(email)}`, {\n method: \"DELETE\",\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-members\"] });\n },\n });\n}\n\nexport function useUpdateOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (name: string) =>\n apiFetch(ORG_BASE, {\n method: \"PATCH\",\n body: JSON.stringify({ name }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-me\"] });\n },\n });\n}\n\nexport function useSwitchOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (orgId: string | null) =>\n apiFetch(`${ORG_BASE}/switch`, {\n method: \"PUT\",\n body: JSON.stringify({ orgId }),\n }),\n onSuccess: async () => {\n // Switching org changes everything scoped to AGENT_ORG_ID.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useDeleteOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (name: string) =>\n apiFetch(ORG_BASE, {\n method: \"DELETE\",\n body: JSON.stringify({ name }),\n }),\n onSuccess: async () => {\n // Deleting an org drops the user into a different active org (or none),\n // so every org-scoped query is stale — same reasoning as create/switch.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useJoinByDomain() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (orgId: string) =>\n apiFetch(`${ORG_BASE}/join-by-domain`, {\n method: \"POST\",\n body: JSON.stringify({ orgId }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useSetOrgDomain() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (domain: string | null) =>\n apiFetch(`${ORG_BASE}/domain`, {\n method: \"PUT\",\n body: JSON.stringify({ domain }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-me\"] });\n },\n });\n}\n\nexport interface AppRoleAssignment {\n email: string;\n role: string;\n}\n\nexport interface AppRolesInfo {\n appId: string;\n roles: string[];\n /** Shown for members with no assignment. Never satisfies a server guard. */\n defaultRole: string | null;\n roleLabels: Record<string, string>;\n /** Whether the current user may change assignments (org owner/admin). */\n canManage: boolean;\n assignments: AppRoleAssignment[];\n myRole: string | null;\n}\n\n/**\n * App-role vocabulary and assignments for the active org.\n *\n * `myRole` and `canManage` are progressive disclosure only — every guarded\n * operation re-resolves both server-side, so a client that shows the wrong\n * affordance still cannot perform the operation.\n */\nexport function useAppRoles(appId: string | undefined) {\n const { data: org } = useOrg();\n return useQuery<AppRolesInfo>({\n queryKey: [\"org-app-roles\", appId ?? null, org?.orgId ?? null],\n queryFn: () =>\n apiFetch(`${ORG_BASE}/app-roles?appId=${encodeURIComponent(appId!)}`),\n enabled: Boolean(appId),\n staleTime: 30_000,\n });\n}\n\n/** The current user's role in one app, or `null` when unassigned. */\nexport function useAppRole(appId: string | undefined): {\n role: string | null;\n isLoading: boolean;\n error: Error | null;\n} {\n const query = useAppRoles(appId);\n return {\n role: query.data?.myRole ?? null,\n isLoading: query.isLoading,\n error: query.error,\n };\n}\n\nexport function useSetAppMemberRole(appId: string) {\n const qc = useQueryClient();\n return useMutation<\n { appId: string; email: string; role: string | null },\n Error,\n { email: string; role: string | null }\n >({\n mutationFn: ({ email, role }) =>\n apiFetch(`${ORG_BASE}/app-roles/${encodeURIComponent(email)}`, {\n method: \"PUT\",\n body: JSON.stringify({ appId, role }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-app-roles\"] });\n },\n });\n}\n\n/**\n * Fetch the org's A2A secret on demand (owner/admin). Deliberately a separate\n * request from `useOrg()` so the secret only reaches the browser when the\n * operator asks to reveal or copy it.\n */\nexport function useRevealA2ASecret() {\n return useMutation<{ a2aSecret: string | null }, Error, void>({\n mutationFn: () => apiFetch(`${ORG_BASE}/a2a-secret`),\n });\n}\n\nexport function useSetA2ASecret() {\n const qc = useQueryClient();\n return useMutation<\n { a2aSecret: string; previousSecret: string | null },\n Error,\n string | undefined\n >({\n mutationFn: (secret?: string) =>\n apiFetch(`${ORG_BASE}/a2a-secret`, {\n method: \"PUT\",\n body: JSON.stringify({ secret }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-me\"] });\n },\n });\n}\n\nexport interface SyncA2ASecretResult {\n total: number;\n succeeded: number;\n failed: number;\n results: Array<{\n id: string;\n name: string;\n url: string;\n ok: boolean;\n status?: number;\n error?: string;\n }>;\n}\n\n/**\n * Push the org's A2A secret to every connected app so cross-app delegation\n * works without manual copy/paste. Optionally pass a `signSecret` to sign\n * the outbound JWTs with a different secret (used by the regenerate-then-\n * sync flow where the new secret is in DB but peers still hold the old\n * one).\n */\nexport function useSyncA2ASecret() {\n return useMutation<\n SyncA2ASecretResult,\n Error,\n { signSecret?: string } | void\n >({\n mutationFn: (vars) =>\n apiFetch(`${ORG_BASE}/a2a-secret/sync`, {\n method: \"POST\",\n body: JSON.stringify({\n signSecret:\n vars && \"signSecret\" in vars ? vars.signSecret : undefined,\n }),\n }),\n });\n}\n"]}
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/client/org/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,QAAQ,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAEvD,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,IAAkB;IACtD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE;QAC5B,GAAG,IAAI;QACP,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,GAAG,IAAI,EAAE,OAAO;SACjB;KACF,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,uEAAuE;QACvE,qEAAqE;QACrE,2DAA2D;QAC3D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,OAAO,GAAW,GAAG,CAAC,UAAU,CAAC;QACrC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,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AE;YACtC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,UAAU,EACR,IAAI,IAAI,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;aAC7D,CAAC;SACH,CAAC;KACL,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nimport {\n canInviteOrgMembers,\n canManageOrg,\n canManageOrgDomain,\n} from \"../../org/permissions.js\";\nimport type {\n OrgInfo,\n OrgMember,\n OrgPendingInvitation,\n OrgRole,\n} from \"../../org/types.js\";\nimport { agentNativePath } from \"../api-path.js\";\n\nconst ORG_BASE = agentNativePath(\"/_agent-native/org\");\n\nasync function apiFetch(path: string, init?: RequestInit) {\n const res = await fetch(path, {\n ...init,\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...init?.headers,\n },\n });\n if (!res.ok) {\n // Prefer a JSON `error` / `message` field when the server returns one,\n // and only fall back to the raw body for plaintext responses. Avoids\n // surfacing `{\"error\":\"...\"}` as the user-visible message.\n const text = await res.text().catch(() => \"\");\n let message: string = res.statusText;\n if (text) {\n try {\n const parsed = JSON.parse(text) as {\n error?: string;\n message?: string;\n };\n message = parsed.error ?? parsed.message ?? text;\n } catch {\n message = text;\n }\n }\n throw new Error(message);\n }\n return res.json();\n}\n\nexport function useOrg() {\n return useQuery<OrgInfo>({\n queryKey: [\"org-me\"],\n queryFn: () => apiFetch(`${ORG_BASE}/me`),\n staleTime: 30_000,\n });\n}\n\nexport interface UseOrgRoleResult {\n org: OrgInfo | undefined;\n role: OrgRole | null;\n isOwner: boolean;\n canManageOrg: boolean;\n canInviteMembers: boolean;\n canManageDomain: boolean;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport function useOrgRole(): UseOrgRoleResult {\n const query = useOrg();\n const role = query.data?.role ?? null;\n return {\n org: query.data,\n role,\n isOwner: role === \"owner\",\n canManageOrg: canManageOrg(role),\n canInviteMembers: canInviteOrgMembers(role),\n canManageDomain: canManageOrgDomain(role),\n isLoading: query.isLoading,\n error: query.error,\n };\n}\n\nexport function useOrgMembers() {\n // Scope the cache by active orgId so switching or creating an org forces a\n // fresh fetch rather than briefly showing the previous org's members.\n const { data: org } = useOrg();\n return useQuery<{ members: OrgMember[] }>({\n queryKey: [\"org-members\", org?.orgId ?? null],\n queryFn: () => apiFetch(`${ORG_BASE}/members`),\n staleTime: 30_000,\n });\n}\n\nexport function useOrgInvitations() {\n const { data: org } = useOrg();\n return useQuery<{ invitations: OrgPendingInvitation[] }>({\n queryKey: [\"org-invitations\", org?.orgId ?? null],\n queryFn: () => apiFetch(`${ORG_BASE}/invitations`),\n staleTime: 30_000,\n });\n}\n\n// NOTE: the onSuccess handlers below `await invalidateQueries`. In\n// TanStack Query v5, invalidateQueries:\n// 1. Marks every matching query as stale, so the next mount of an\n// INACTIVE query (e.g. the org-members table on a settings page\n// the user hasn't visited yet) refetches immediately instead of\n// serving 30-second-stale cached data.\n// 2. Triggers a refetch of every ACTIVE query that matches.\n// 3. Returns a promise that resolves once those refetches settle.\n//\n// `await`ing therefore keeps `mutation.isPending` true through the\n// full read-after-write window — closing the create-org / accept-\n// invite race where a button could re-enable mid-refetch. We\n// previously tried refetchQueries here for \"unambiguous semantics\",\n// but that variant doesn't mark inactive queries stale, leaving them\n// to serve stale data on next mount. invalidateQueries is the right\n// primitive — it just needed an `await`.\n\nexport function useCreateOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (name: string) =>\n apiFetch(ORG_BASE, {\n method: \"POST\",\n body: JSON.stringify({ name }),\n }),\n onSuccess: async () => {\n // Creating an org also switches the user into it server-side, so every\n // org-scoped query (members, invitations, and template-level data) is\n // now stale. Match the broad invalidation that useSwitchOrg already does.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport type InviteRole = \"admin\" | \"member\";\n\nexport interface InviteVars {\n email: string;\n role?: InviteRole;\n}\n\nexport function useInviteMember() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: string | InviteVars) => {\n const body: { email: string; role: InviteRole } =\n typeof vars === \"string\"\n ? { email: vars, role: \"member\" }\n : { email: vars.email, role: vars.role ?? \"member\" };\n return apiFetch(`${ORG_BASE}/invitations`, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n },\n onSuccess: async () => {\n await Promise.all([\n qc.invalidateQueries({ queryKey: [\"org-members\"] }),\n qc.invalidateQueries({ queryKey: [\"org-invitations\"] }),\n ]);\n },\n });\n}\n\nexport interface BulkInviteResult {\n succeeded: Array<{\n id: string;\n email: string;\n role: InviteRole;\n status: \"pending\";\n emailSent: boolean;\n emailError?: string;\n }>;\n failed: Array<{ email: string; error: string }>;\n total: number;\n}\n\nexport function useBulkInviteMembers() {\n const qc = useQueryClient();\n return useMutation<BulkInviteResult, Error, InviteVars[]>({\n mutationFn: (invites) =>\n apiFetch(`${ORG_BASE}/invitations`, {\n method: \"POST\",\n body: JSON.stringify({\n invites: invites.map((i) => ({\n email: i.email,\n role: i.role ?? \"member\",\n })),\n }),\n }),\n onSuccess: async () => {\n await Promise.all([\n qc.invalidateQueries({ queryKey: [\"org-members\"] }),\n qc.invalidateQueries({ queryKey: [\"org-invitations\"] }),\n ]);\n },\n });\n}\n\nexport function useChangeMemberRole() {\n const qc = useQueryClient();\n return useMutation<\n { email: string; role: InviteRole },\n Error,\n { email: string; role: InviteRole }\n >({\n mutationFn: ({ email, role }) =>\n apiFetch(`${ORG_BASE}/members/${encodeURIComponent(email)}/role`, {\n method: \"PUT\",\n body: JSON.stringify({ role }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-members\"] });\n },\n });\n}\n\nexport function useAcceptInvitation() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (invitationId: string) =>\n apiFetch(`${ORG_BASE}/invitations/${invitationId}/accept`, {\n method: \"POST\",\n }),\n onSuccess: async () => {\n // Joining/switching orgs changes all org-scoped data — invalidate\n // every cached query (no key filter) so each one refetches or is\n // marked stale for the next mount.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useRemoveMember() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (email: string) =>\n apiFetch(`${ORG_BASE}/members/${encodeURIComponent(email)}`, {\n method: \"DELETE\",\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-members\"] });\n },\n });\n}\n\nexport function useUpdateOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (name: string) =>\n apiFetch(ORG_BASE, {\n method: \"PATCH\",\n body: JSON.stringify({ name }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-me\"] });\n },\n });\n}\n\nexport function useSwitchOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (orgId: string | null) =>\n apiFetch(`${ORG_BASE}/switch`, {\n method: \"PUT\",\n body: JSON.stringify({ orgId }),\n }),\n onSuccess: async () => {\n // Switching org changes everything scoped to AGENT_ORG_ID.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useDeleteOrg() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (name: string) =>\n apiFetch(ORG_BASE, {\n method: \"DELETE\",\n body: JSON.stringify({ name }),\n }),\n onSuccess: async () => {\n // Deleting an org drops the user into a different active org (or none),\n // so every org-scoped query is stale — same reasoning as create/switch.\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useJoinByDomain() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (orgId: string) =>\n apiFetch(`${ORG_BASE}/join-by-domain`, {\n method: \"POST\",\n body: JSON.stringify({ orgId }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries();\n },\n });\n}\n\nexport function useSetOrgDomain() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (domain: string | null) =>\n apiFetch(`${ORG_BASE}/domain`, {\n method: \"PUT\",\n body: JSON.stringify({ domain }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-me\"] });\n },\n });\n}\n\nexport function useSetOrgWorkspaceUrl() {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (url: string | null) =>\n apiFetch(`${ORG_BASE}/workspace-url`, {\n method: \"PUT\",\n body: JSON.stringify({ url }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-me\"] });\n },\n });\n}\n\nexport interface AppRoleAssignment {\n email: string;\n role: string;\n}\n\nexport interface AppRolesInfo {\n appId: string;\n roles: string[];\n /** Shown for members with no assignment. Never satisfies a server guard. */\n defaultRole: string | null;\n roleLabels: Record<string, string>;\n /** Whether the current user may change assignments (org owner/admin). */\n canManage: boolean;\n assignments: AppRoleAssignment[];\n myRole: string | null;\n}\n\n/**\n * App-role vocabulary and assignments for the active org.\n *\n * `myRole` and `canManage` are progressive disclosure only — every guarded\n * operation re-resolves both server-side, so a client that shows the wrong\n * affordance still cannot perform the operation.\n */\nexport function useAppRoles(appId: string | undefined) {\n const { data: org } = useOrg();\n return useQuery<AppRolesInfo>({\n queryKey: [\"org-app-roles\", appId ?? null, org?.orgId ?? null],\n queryFn: () =>\n apiFetch(`${ORG_BASE}/app-roles?appId=${encodeURIComponent(appId!)}`),\n enabled: Boolean(appId),\n staleTime: 30_000,\n });\n}\n\n/** The current user's role in one app, or `null` when unassigned. */\nexport function useAppRole(appId: string | undefined): {\n role: string | null;\n isLoading: boolean;\n error: Error | null;\n} {\n const query = useAppRoles(appId);\n return {\n role: query.data?.myRole ?? null,\n isLoading: query.isLoading,\n error: query.error,\n };\n}\n\nexport function useSetAppMemberRole(appId: string) {\n const qc = useQueryClient();\n return useMutation<\n { appId: string; email: string; role: string | null },\n Error,\n { email: string; role: string | null }\n >({\n mutationFn: ({ email, role }) =>\n apiFetch(`${ORG_BASE}/app-roles/${encodeURIComponent(email)}`, {\n method: \"PUT\",\n body: JSON.stringify({ appId, role }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-app-roles\"] });\n },\n });\n}\n\n/**\n * Fetch the org's A2A secret on demand (owner/admin). Deliberately a separate\n * request from `useOrg()` so the secret only reaches the browser when the\n * operator asks to reveal or copy it.\n */\nexport function useRevealA2ASecret() {\n return useMutation<{ a2aSecret: string | null }, Error, void>({\n mutationFn: () => apiFetch(`${ORG_BASE}/a2a-secret`),\n });\n}\n\nexport function useSetA2ASecret() {\n const qc = useQueryClient();\n return useMutation<\n { a2aSecret: string; previousSecret: string | null },\n Error,\n string | undefined\n >({\n mutationFn: (secret?: string) =>\n apiFetch(`${ORG_BASE}/a2a-secret`, {\n method: \"PUT\",\n body: JSON.stringify({ secret }),\n }),\n onSuccess: async () => {\n await qc.invalidateQueries({ queryKey: [\"org-me\"] });\n },\n });\n}\n\nexport interface SyncA2ASecretResult {\n total: number;\n succeeded: number;\n failed: number;\n results: Array<{\n id: string;\n name: string;\n url: string;\n ok: boolean;\n status?: number;\n error?: string;\n }>;\n}\n\n/**\n * Push the org's A2A secret to every connected app so cross-app delegation\n * works without manual copy/paste. Optionally pass a `signSecret` to sign\n * the outbound JWTs with a different secret (used by the regenerate-then-\n * sync flow where the new secret is in DB but peers still hold the old\n * one).\n */\nexport function useSyncA2ASecret() {\n return useMutation<\n SyncA2ASecretResult,\n Error,\n { signSecret?: string } | void\n >({\n mutationFn: (vars) =>\n apiFetch(`${ORG_BASE}/a2a-secret/sync`, {\n method: \"POST\",\n body: JSON.stringify({\n signSecret:\n vars && \"signSecret\" in vars ? vars.signSecret : undefined,\n }),\n }),\n });\n}\n"]}
@@ -1,8 +1,9 @@
1
- export { useOrg, useOrgMembers, useOrgInvitations, useCreateOrg, useUpdateOrg, useInviteMember, useBulkInviteMembers, useChangeMemberRole, useAcceptInvitation, useRemoveMember, useDeleteOrg, useSwitchOrg, useJoinByDomain, useSetOrgDomain, useRevealA2ASecret, useSetA2ASecret, useSyncA2ASecret, useOrgRole, useAppRoles, useAppRole, useSetAppMemberRole, } from "./hooks.js";
1
+ export { useOrg, useOrgMembers, useOrgInvitations, useCreateOrg, useUpdateOrg, useInviteMember, useBulkInviteMembers, useChangeMemberRole, useAcceptInvitation, useRemoveMember, useDeleteOrg, useSwitchOrg, useJoinByDomain, useSetOrgDomain, useSetOrgWorkspaceUrl, useRevealA2ASecret, useSetA2ASecret, useSyncA2ASecret, useOrgRole, useAppRoles, useAppRole, useSetAppMemberRole, } from "./hooks.js";
2
2
  export type { InviteRole, InviteVars, BulkInviteResult, SyncA2ASecretResult, UseOrgRoleResult, AppRoleAssignment, AppRolesInfo, } from "./hooks.js";
3
3
  export type { AppRolesDescriptor } from "../../org/app-roles.js";
4
4
  export { OrgSwitcher, type OrgSwitcherProps } from "./OrgSwitcher.js";
5
5
  export { InvitationBanner, type InvitationBannerProps, } from "./InvitationBanner.js";
6
+ export { WorkspaceNotice } from "./WorkspaceNotice.js";
6
7
  export { TeamPage, type TeamPageProps } from "./TeamPage.js";
7
8
  export { RequireActiveOrg, type RequireActiveOrgProps, } from "./RequireActiveOrg.js";
8
9
  export { defaultOrgAppLinks, dispatchAppsHref, dispatchOverviewHref, isWorkspaceAppEnvironment, parseWorkspaceAppLinks, parseWorkspaceAppLinksJson, visibleOrgAppLinks, ORG_SWITCHER_MAX_APP_LINKS, type OrgSwitcherAppLink, type UseOrgSwitcherAppLinksResult, type VisibleOrgAppLinks, } from "./workspace-app-links.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/org/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC;AAIpB,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,OAAO,EACP,OAAO,EACP,SAAS,EACT,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,cAAc,GACf,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/org/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC;AAIpB,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,OAAO,EACP,OAAO,EACP,SAAS,EACT,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,cAAc,GACf,MAAM,oBAAoB,CAAC"}
@@ -1,7 +1,8 @@
1
1
  // Public client API for the org module.
2
- export { useOrg, useOrgMembers, useOrgInvitations, useCreateOrg, useUpdateOrg, useInviteMember, useBulkInviteMembers, useChangeMemberRole, useAcceptInvitation, useRemoveMember, useDeleteOrg, useSwitchOrg, useJoinByDomain, useSetOrgDomain, useRevealA2ASecret, useSetA2ASecret, useSyncA2ASecret, useOrgRole, useAppRoles, useAppRole, useSetAppMemberRole, } from "./hooks.js";
2
+ export { useOrg, useOrgMembers, useOrgInvitations, useCreateOrg, useUpdateOrg, useInviteMember, useBulkInviteMembers, useChangeMemberRole, useAcceptInvitation, useRemoveMember, useDeleteOrg, useSwitchOrg, useJoinByDomain, useSetOrgDomain, useSetOrgWorkspaceUrl, useRevealA2ASecret, useSetA2ASecret, useSyncA2ASecret, useOrgRole, useAppRoles, useAppRole, useSetAppMemberRole, } from "./hooks.js";
3
3
  export { OrgSwitcher } from "./OrgSwitcher.js";
4
4
  export { InvitationBanner, } from "./InvitationBanner.js";
5
+ export { WorkspaceNotice } from "./WorkspaceNotice.js";
5
6
  export { TeamPage } from "./TeamPage.js";
6
7
  export { RequireActiveOrg, } from "./RequireActiveOrg.js";
7
8
  export { defaultOrgAppLinks, dispatchAppsHref, dispatchOverviewHref, isWorkspaceAppEnvironment, parseWorkspaceAppLinks, parseWorkspaceAppLinksJson, visibleOrgAppLinks, ORG_SWITCHER_MAX_APP_LINKS, } from "./workspace-app-links.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/org/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAgBpB,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,GAI3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,0BAA0B,CAAC","sourcesContent":["// Public client API for the org module.\n\nexport {\n useOrg,\n useOrgMembers,\n useOrgInvitations,\n useCreateOrg,\n useUpdateOrg,\n useInviteMember,\n useBulkInviteMembers,\n useChangeMemberRole,\n useAcceptInvitation,\n useRemoveMember,\n useDeleteOrg,\n useSwitchOrg,\n useJoinByDomain,\n useSetOrgDomain,\n useRevealA2ASecret,\n useSetA2ASecret,\n useSyncA2ASecret,\n useOrgRole,\n useAppRoles,\n useAppRole,\n useSetAppMemberRole,\n} from \"./hooks.js\";\n\nexport type {\n InviteRole,\n InviteVars,\n BulkInviteResult,\n SyncA2ASecretResult,\n UseOrgRoleResult,\n AppRoleAssignment,\n AppRolesInfo,\n} from \"./hooks.js\";\n\n// Type-only re-export so templates can annotate the `appRoles` prop without\n// importing the server module.\nexport type { AppRolesDescriptor } from \"../../org/app-roles.js\";\n\nexport { OrgSwitcher, type OrgSwitcherProps } from \"./OrgSwitcher.js\";\nexport {\n InvitationBanner,\n type InvitationBannerProps,\n} from \"./InvitationBanner.js\";\nexport { TeamPage, type TeamPageProps } from \"./TeamPage.js\";\nexport {\n RequireActiveOrg,\n type RequireActiveOrgProps,\n} from \"./RequireActiveOrg.js\";\nexport {\n defaultOrgAppLinks,\n dispatchAppsHref,\n dispatchOverviewHref,\n isWorkspaceAppEnvironment,\n parseWorkspaceAppLinks,\n parseWorkspaceAppLinksJson,\n visibleOrgAppLinks,\n ORG_SWITCHER_MAX_APP_LINKS,\n type OrgSwitcherAppLink,\n type UseOrgSwitcherAppLinksResult,\n type VisibleOrgAppLinks,\n} from \"./workspace-app-links.js\";\nexport {\n canInviteOrgMembers,\n canManageOrg,\n canManageOrgDomain,\n orgRoleAtLeast,\n orgRoleRank,\n} from \"../../org/permissions.js\";\n\n// Re-export the shared types so consumers can import them from one place.\nexport type {\n OrgRole,\n OrgInfo,\n OrgMember,\n OrgPendingInvitation,\n OrgSummary,\n OrgInvitationSummary,\n DomainMatchOrg,\n} from \"../../org/types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/org/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAgBpB,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,GAI3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,0BAA0B,CAAC","sourcesContent":["// Public client API for the org module.\n\nexport {\n useOrg,\n useOrgMembers,\n useOrgInvitations,\n useCreateOrg,\n useUpdateOrg,\n useInviteMember,\n useBulkInviteMembers,\n useChangeMemberRole,\n useAcceptInvitation,\n useRemoveMember,\n useDeleteOrg,\n useSwitchOrg,\n useJoinByDomain,\n useSetOrgDomain,\n useSetOrgWorkspaceUrl,\n useRevealA2ASecret,\n useSetA2ASecret,\n useSyncA2ASecret,\n useOrgRole,\n useAppRoles,\n useAppRole,\n useSetAppMemberRole,\n} from \"./hooks.js\";\n\nexport type {\n InviteRole,\n InviteVars,\n BulkInviteResult,\n SyncA2ASecretResult,\n UseOrgRoleResult,\n AppRoleAssignment,\n AppRolesInfo,\n} from \"./hooks.js\";\n\n// Type-only re-export so templates can annotate the `appRoles` prop without\n// importing the server module.\nexport type { AppRolesDescriptor } from \"../../org/app-roles.js\";\n\nexport { OrgSwitcher, type OrgSwitcherProps } from \"./OrgSwitcher.js\";\nexport {\n InvitationBanner,\n type InvitationBannerProps,\n} from \"./InvitationBanner.js\";\nexport { WorkspaceNotice } from \"./WorkspaceNotice.js\";\nexport { TeamPage, type TeamPageProps } from \"./TeamPage.js\";\nexport {\n RequireActiveOrg,\n type RequireActiveOrgProps,\n} from \"./RequireActiveOrg.js\";\nexport {\n defaultOrgAppLinks,\n dispatchAppsHref,\n dispatchOverviewHref,\n isWorkspaceAppEnvironment,\n parseWorkspaceAppLinks,\n parseWorkspaceAppLinksJson,\n visibleOrgAppLinks,\n ORG_SWITCHER_MAX_APP_LINKS,\n type OrgSwitcherAppLink,\n type UseOrgSwitcherAppLinksResult,\n type VisibleOrgAppLinks,\n} from \"./workspace-app-links.js\";\nexport {\n canInviteOrgMembers,\n canManageOrg,\n canManageOrgDomain,\n orgRoleAtLeast,\n orgRoleRank,\n} from \"../../org/permissions.js\";\n\n// Re-export the shared types so consumers can import them from one place.\nexport type {\n OrgRole,\n OrgInfo,\n OrgMember,\n OrgPendingInvitation,\n OrgSummary,\n OrgInvitationSummary,\n DomainMatchOrg,\n} from \"../../org/types.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"McpIntegrationDialog.d.ts","sourceRoot":"","sources":["../../../src/client/resources/McpIntegrationDialog.tsx"],"names":[],"mappings":"AAyBA,OAAO,EASL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,cAAc,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACxC;AAkED,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,oBAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,YAAY,GACb,EAAE,yBAAyB,sCAksB3B"}
1
+ {"version":3,"file":"McpIntegrationDialog.d.ts","sourceRoot":"","sources":["../../../src/client/resources/McpIntegrationDialog.tsx"],"names":[],"mappings":"AAyBA,OAAO,EAUL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,cAAc,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACxC;AAkED,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,oBAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,YAAY,GACb,EAAE,yBAAyB,sCAorB3B"}
@@ -7,7 +7,7 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, }
7
7
  import { Tooltip, TooltipContent, TooltipTrigger, } from "../components/ui/tooltip.js";
8
8
  import { useT } from "../i18n.js";
9
9
  import { cn } from "../utils.js";
10
- import { buildMcpOAuthStartUrl, createMcpIntegrationFormDefaults, filterMcpIntegrations, getMcpIntegrationApiFallback, getDefaultMcpIntegrations, isCustomMcpIntegrationEnabled, navigateToMcpOAuthStart, resolveMcpIntegrationScope, } from "./mcp-integration-catalog.js";
10
+ import { buildMcpOAuthStartUrl, createMcpIntegrationFormDefaults, filterMcpIntegrations, getMcpIntegrationApiFallback, getDefaultMcpIntegrations, isCustomMcpIntegrationEnabled, navigateToMcpOAuthStart, resolveMcpIntegrationScope, shouldOfferMcpOrganizationScope, } from "./mcp-integration-catalog.js";
11
11
  import { formatMcpServerError, getMcpUrlValidationError, testMcpServerUrl, useMcpServers, } from "./use-mcp-servers.js";
12
12
  function IntegrationLogo({ name, logoUrl }) {
13
13
  const [loaded, setLoaded] = useState(false);
@@ -154,7 +154,7 @@ export function McpIntegrationDialog({ open, onOpenChange, initialIntegrationId
154
154
  name: args.name,
155
155
  url: args.url,
156
156
  description: args.description,
157
- scope: safeDefaultScope,
157
+ scope,
158
158
  returnUrl,
159
159
  })));
160
160
  };
@@ -263,17 +263,13 @@ export function McpIntegrationDialog({ open, onOpenChange, initialIntegrationId
263
263
  }
264
264
  };
265
265
  const renderScopeSelector = () => {
266
- const orgTooltip = !hasOrg
267
- ? t("mcpIntegrations.orgNoOrg")
268
- : !canCreateOrgMcp
269
- ? t("mcpIntegrations.orgAdminOnly")
270
- : null;
266
+ if (!shouldOfferMcpOrganizationScope(hasOrg, canCreateOrgMcp))
267
+ return null;
271
268
  return (_jsxs("div", { className: "flex gap-1 rounded-md border border-border bg-background p-0.5", children: [_jsx("button", { type: "button", onClick: () => setScope("user"), className: cn("flex-1 rounded px-2 py-1.5 text-[11px] font-medium", scope === "user"
272
269
  ? "bg-accent text-foreground"
273
- : "text-muted-foreground hover:text-foreground"), children: t("mcpIntegrations.personal") }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: () => hasOrg && canCreateOrgMcp && setScope("org"), disabled: !hasOrg || !canCreateOrgMcp, className: cn("flex-1 rounded px-2 py-1.5 text-[11px] font-medium", scope === "org"
274
- ? "bg-accent text-foreground"
275
- : "text-muted-foreground hover:text-foreground", (!hasOrg || !canCreateOrgMcp) &&
276
- "cursor-not-allowed opacity-50 hover:text-muted-foreground"), children: t("mcpIntegrations.organization") }) }), orgTooltip && _jsx(TooltipContent, { children: orgTooltip })] })] }));
270
+ : "text-muted-foreground hover:text-foreground"), children: t("mcpIntegrations.personal") }), _jsx("button", { type: "button", onClick: () => setScope("org"), className: cn("flex-1 rounded px-2 py-1.5 text-[11px] font-medium", scope === "org"
271
+ ? "bg-accent text-foreground"
272
+ : "text-muted-foreground hover:text-foreground"), children: t("mcpIntegrations.organization") })] }));
277
273
  };
278
274
  if (!showCatalog && !customIntegrationEnabled)
279
275
  return null;
@@ -332,6 +328,6 @@ export function McpIntegrationDialog({ open, onOpenChange, initialIntegrationId
332
328
  }, placeholder: selected?.headerPlaceholder ??
333
329
  t("mcpIntegrations.headersPlaceholder") })] })), selected?.docsUrl && (_jsxs("a", { href: selected.docsUrl, target: "_blank", rel: "noopener noreferrer", className: "inline-flex items-center gap-1 text-[11px] text-muted-foreground underline hover:text-foreground", children: [t("mcpIntegrations.openSetupDocs"), _jsx(IconExternalLink, { className: "h-3 w-3" })] })), testResult && (_jsxs("div", { className: cn("flex items-start gap-1 rounded-md px-3 py-2 text-[11px] leading-snug", testResult.ok
334
330
  ? "bg-green-500/5 text-green-600 dark:text-green-400"
335
- : "bg-red-500/5 text-red-600 dark:text-red-400"), children: [testResult.ok && (_jsx(IconCheck, { className: "mt-0.5 h-3 w-3 shrink-0" })), _jsx("span", { className: "min-w-0 break-words", children: testResult.message })] })), error && (_jsx("div", { className: "break-words rounded-md bg-red-500/5 px-3 py-2 text-[11px] leading-snug text-red-600 dark:text-red-400", children: error }))] }) }), _jsxs("div", { className: "flex shrink-0 items-center justify-between gap-2 border-t border-border px-7 py-4", children: [_jsx("button", { type: "button", onClick: runTest, disabled: !url.trim() || busy, className: "rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40", children: t("mcpIntegrations.test") }), selected?.authMode === "oauth" && !selectedRequiresSetup ? (_jsxs("button", { type: "button", onClick: () => connectWithOAuth(selected), disabled: !name.trim() || !url.trim() || busy, "aria-busy": busy, className: "rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40", children: [busy && (_jsx(IconLoader2, { className: "me-1.5 inline h-3.5 w-3.5 animate-spin" })), t("mcpIntegrations.connectWithOAuth")] })) : !selected ? (_jsxs("button", { type: "button", onClick: connectCustomWithOAuth, disabled: !name.trim() || !url.trim() || busy, "aria-busy": busy, className: "rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40", children: [busy && (_jsx(IconLoader2, { className: "me-1.5 inline h-3.5 w-3.5 animate-spin" })), t("mcpIntegrations.connectWithOAuth")] })) : null, selectedRequiresSetup ? (selected?.docsUrl ? (_jsxs("a", { href: selected.docsUrl, target: "_blank", rel: "noopener noreferrer", className: "inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90", children: [t("mcpIntegrations.viewSetup"), _jsx(IconExternalLink, { className: "h-3 w-3" })] })) : null) : (_jsxs("button", { type: "button", onClick: submitForm, disabled: !name.trim() || !url.trim() || busy, className: "inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-40", children: [busy && _jsx(IconLoader2, { className: "h-3.5 w-3.5 animate-spin" }), t("mcpIntegrations.connect")] }))] })] })) }) }));
331
+ : "bg-red-500/5 text-red-600 dark:text-red-400"), children: [testResult.ok && (_jsx(IconCheck, { className: "mt-0.5 h-3 w-3 shrink-0" })), _jsx("span", { className: "min-w-0 break-words", children: testResult.message })] })), error && (_jsx("div", { className: "break-words rounded-md bg-red-500/5 px-3 py-2 text-[11px] leading-snug text-red-600 dark:text-red-400", children: error }))] }) }), _jsxs("div", { className: "flex shrink-0 items-center justify-between gap-2 border-t border-border px-7 py-4", children: [_jsx("button", { type: "button", onClick: runTest, disabled: !url.trim() || busy, className: "rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40", children: t("mcpIntegrations.test") }), !selected ? (_jsxs("button", { type: "button", onClick: connectCustomWithOAuth, disabled: !name.trim() || !url.trim() || busy, "aria-busy": busy, className: "rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40", children: [busy && (_jsx(IconLoader2, { className: "me-1.5 inline h-3.5 w-3.5 animate-spin" })), t("mcpIntegrations.connectWithOAuth")] })) : null, selectedRequiresSetup ? (selected?.docsUrl ? (_jsxs("a", { href: selected.docsUrl, target: "_blank", rel: "noopener noreferrer", className: "inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90", children: [t("mcpIntegrations.viewSetup"), _jsx(IconExternalLink, { className: "h-3 w-3" })] })) : null) : selected?.authMode === "oauth" ? (_jsxs("button", { type: "button", onClick: () => connectWithOAuth(selected), disabled: !name.trim() || !url.trim() || busy, "aria-busy": busy, className: "inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-40", children: [busy && _jsx(IconLoader2, { className: "h-3.5 w-3.5 animate-spin" }), t("mcpIntegrations.connectWithOAuth")] })) : (_jsxs("button", { type: "button", onClick: submitForm, disabled: !name.trim() || !url.trim() || busy, className: "inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-40", children: [busy && _jsx(IconLoader2, { className: "h-3.5 w-3.5 animate-spin" }), t("mcpIntegrations.connect")] }))] })] })) }) }));
336
332
  }
337
333
  //# sourceMappingURL=McpIntegrationDialog.js.map