@lobu/runtime-server 21.2.1 → 23.0.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 (420) hide show
  1. package/dist/catalogs/automations.json +40 -13
  2. package/dist/catalogs/connectors.json +18435 -1259
  3. package/dist/catalogs/skills.json +1 -1
  4. package/dist/component.json +1 -1
  5. package/dist/connectors/README.md +21 -6
  6. package/dist/connectors/_google/actions.ts +270 -0
  7. package/dist/connectors/_google/discovery/calendar_v3.json +1 -0
  8. package/dist/connectors/_google/discovery/chat_v1.json +1 -0
  9. package/dist/connectors/_google/discovery/docs_v1.json +1 -0
  10. package/dist/connectors/_google/discovery/drive_v3.json +1 -0
  11. package/dist/connectors/_google/discovery/gmail_v1.json +1 -0
  12. package/dist/connectors/_google/discovery/people_v1.json +1 -0
  13. package/dist/connectors/_google/discovery/sheets_v4.json +1 -0
  14. package/dist/connectors/_google/discovery/tasks_v1.json +1 -0
  15. package/dist/connectors/_google/discovery/youtube_v3.json +1 -0
  16. package/dist/connectors/_google/discovery.ts +442 -0
  17. package/dist/connectors/_google/errors.ts +91 -0
  18. package/dist/connectors/_google/list-feed.ts +223 -0
  19. package/dist/connectors/_google/policies.ts +127 -0
  20. package/dist/connectors/agentid.ts +43 -0
  21. package/dist/connectors/chat-user-identity.ts +2 -1
  22. package/dist/connectors/github-automation-events.ts +9 -0
  23. package/dist/connectors/github-identity.ts +28 -3
  24. package/dist/connectors/github.ts +101 -59
  25. package/dist/connectors/google_calendar.ts +207 -719
  26. package/dist/connectors/google_drive.ts +16 -2
  27. package/dist/connectors/google_gmail.ts +52 -33
  28. package/dist/connectors/herdr.ts +406 -0
  29. package/dist/connectors/jira-helpers.ts +313 -0
  30. package/dist/connectors/jira.ts +35 -227
  31. package/dist/connectors/linear.ts +7 -4
  32. package/dist/connectors/linkedin-browser-script.ts +13 -0
  33. package/dist/connectors/linkedin-draft-page.js +104 -0
  34. package/dist/connectors/linkedin-drafts.ts +73 -0
  35. package/dist/connectors/linkedin-identity.ts +32 -0
  36. package/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  37. package/dist/connectors/linkedin-inbox.ts +156 -0
  38. package/dist/connectors/linkedin-like.ts +114 -0
  39. package/dist/connectors/linkedin-takeout.ts +577 -0
  40. package/dist/connectors/linkedin.ts +3998 -0
  41. package/dist/connectors/postgres.ts +27 -2
  42. package/dist/connectors/takeout-utils.ts +240 -0
  43. package/dist/connectors/tiktok-inbox-page.js +230 -0
  44. package/dist/connectors/tiktok-web-page.js +217 -0
  45. package/dist/connectors/tiktok_web.ts +319 -0
  46. package/dist/connectors/whatsapp-web-adapter.js +285 -567
  47. package/dist/connectors/whatsapp-web-helpers.ts +74 -455
  48. package/dist/connectors/whatsapp-web-identity.ts +135 -0
  49. package/dist/connectors/whatsapp_web.ts +159 -618
  50. package/dist/connectors/x-dm-adapter.js +556 -0
  51. package/dist/connectors/x-identity.ts +31 -2
  52. package/dist/connectors/x.ts +539 -253
  53. package/dist/db/migrations/20261005150000_retire_agent_tool_config.sql +31 -0
  54. package/dist/db/migrations/20261005173700_drop_retired_agent_tool_config.sql +29 -0
  55. package/dist/db/migrations/20261007010000_identity_association_guards.sql +242 -0
  56. package/dist/db/migrations/20261007010001_identity_association_indexes.sql +35 -0
  57. package/dist/db/migrations/20261007012000_connector_browser_requirement.sql +7 -0
  58. package/dist/db/migrations/20261009010000_identity_member_decision_indexes.sql +22 -0
  59. package/dist/db/migrations/20261009015900_retire_remaining_physical_merges.sql +196 -0
  60. package/dist/db/migrations/20261009020000_retire_physical_entity_merge.sql +82 -0
  61. package/dist/db/migrations/20261009030000_retire_physical_merge_indexes.sql +39 -0
  62. package/dist/db/migrations/20261009030001_drop_physical_entity_redirect.sql +62 -0
  63. package/dist/db/migrations/20261009040000_normalize_identity_decisions.sql +60 -0
  64. package/dist/db/migrations/20261010220000_notification_targets_user_event_order.sql +53 -0
  65. package/dist/db/migrations/20261010223000_device_workers_user_fresh_cover.sql +39 -0
  66. package/dist/db/migrations/20261010223001_runs_org_default_view.sql +41 -0
  67. package/dist/db/migrations/20261010223002_events_org_guidance.sql +42 -0
  68. package/dist/db/migrations/20261011002000_finish_product_eval_retirement.sql +37 -0
  69. package/dist/db/migrations/20261011160000_mcp_conversation_workspaces.sql +97 -0
  70. package/dist/db/migrations/20261013120000_events_live_org_effective_date.sql +42 -0
  71. package/dist/db/migrations/20261013150000_events_live_linked_org_ids_gin.sql +41 -0
  72. package/dist/db/migrations/20261014120000_clear_team_device_auto_pause.sql +34 -0
  73. package/dist/db/migrations/20261014150000_connector_webhook_event_type_backfill.sql +30 -0
  74. package/dist/db/migrations/20261014170000_retire_atlassian_mcp_webhook_refresh.sql +51 -0
  75. package/dist/db/migrations/20261015010000_connection_auth_profile_fk_set_null_column.sql +53 -0
  76. package/dist/db/migrations/20261015120000_personal_org_connector_auto_policy.sql +38 -0
  77. package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
  78. package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
  79. package/dist/db/migrations/preconditions/20261005150000_retire_agent_tool_config.sql +22 -0
  80. package/dist/db/migrations/preconditions/20261005173700_drop_retired_agent_tool_config.sql +13 -0
  81. package/dist/db/migrations/preconditions/20261009020000_retire_physical_entity_merge.sql +26 -0
  82. package/dist/db/migrations/preconditions/20261011002000_finish_product_eval_retirement.sql +14 -0
  83. package/dist/dependencies.bun.lock +144 -137
  84. package/dist/guest.bundle.js +416 -330
  85. package/dist/owletto/dist/assets/_-3J-IrxWk.js +2 -0
  86. package/dist/owletto/dist/assets/_-DYUE3ix4.js +3 -0
  87. package/dist/owletto/dist/assets/_-DtqBFgK5.js +1 -0
  88. package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +2 -0
  89. package/dist/owletto/dist/assets/_agentId-Cam7Z0N7.js +2 -0
  90. package/dist/owletto/dist/assets/_automationId-CXEiKVZJ.js +2 -0
  91. package/dist/owletto/dist/assets/_connectorKey._connectionId-CS85l61t.js +2 -0
  92. package/dist/owletto/dist/assets/_connectorKey.index-clVDIyW0.js +2 -0
  93. package/dist/owletto/dist/assets/_conversationId-Ci2k-BuN.js +2 -0
  94. package/dist/owletto/dist/assets/_deploymentId-BuUzGtVL.js +2 -0
  95. package/dist/owletto/dist/assets/_eventId-B0662F8h.js +2 -0
  96. package/dist/owletto/dist/assets/_name-CwWePlOl.js +2 -0
  97. package/dist/owletto/dist/assets/_owner-dTWkrKsK.js +3 -0
  98. package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +2 -0
  99. package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +2 -0
  100. package/dist/owletto/dist/assets/_slug-DQHutM41.js +2 -0
  101. package/dist/owletto/dist/assets/_threadId-DtqBFgK5.js +1 -0
  102. package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +2 -0
  103. package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +2 -0
  104. package/dist/owletto/dist/assets/accept-invitation-w17IFTtf.js +2 -0
  105. package/dist/owletto/dist/assets/activity-route-view-CMqYiiKM.js +2 -0
  106. package/dist/owletto/dist/assets/agent-card-controls-mnTN2AZt.js +2 -0
  107. package/dist/owletto/dist/assets/{agent-client-setup-list-BFtgRwe8.js → agent-client-setup-list-Bg3hBfUV.js} +4 -3
  108. package/dist/owletto/dist/assets/agent-connect-pages-B_vrqLVc.js +2 -0
  109. package/dist/owletto/dist/assets/agent-editor-form-hTs7eO_U.js +2 -0
  110. package/dist/owletto/dist/assets/agent-guardrails-route-BOrCXcAl.js +2 -0
  111. package/dist/owletto/dist/assets/agent-loading-shells-Dqcvky-k.js +2 -0
  112. package/dist/owletto/dist/assets/agent-permissions-matrix-BOo_4r_4.js +2 -0
  113. package/dist/owletto/dist/assets/{agent-skill-context-BAr2Dw3F.js → agent-skill-context-CCdvtlmH.js} +2 -1
  114. package/dist/owletto/dist/assets/agent-skills-route-BUxIswuq.js +2 -0
  115. package/dist/owletto/dist/assets/agent-subpage-shell-D92imvSt.js +2 -0
  116. package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +6 -0
  117. package/dist/owletto/dist/assets/agents-9XjpDj_S.js +2 -0
  118. package/dist/owletto/dist/assets/agents-workbench-Bt5QCYQ7.js +2 -0
  119. package/dist/owletto/dist/assets/app-bridge-BCm4muqj.js +128 -0
  120. package/dist/owletto/dist/assets/app._appId-CKv7_squ.js +2 -0
  121. package/dist/owletto/dist/assets/automation-detail-content-vUwVumXf.js +2 -0
  122. package/dist/owletto/dist/assets/automations-9XjpDj_S.js +2 -0
  123. package/dist/owletto/dist/assets/{callback-CaRe2TOT.js → callback-BRgcL8gz.js} +2 -1
  124. package/dist/owletto/dist/assets/{card-CMmh2mzo.js → card-Djgp00r_.js} +2 -1
  125. package/dist/owletto/dist/assets/claim-BYUZnyMp.js +2 -0
  126. package/dist/owletto/dist/assets/client-rows-EJSKR6z1.js +1 -0
  127. package/dist/owletto/dist/assets/clients-D3Zbjxin.js +2 -0
  128. package/dist/owletto/dist/assets/code-editor-DHeyRGZI.js +16 -0
  129. package/dist/owletto/dist/assets/connect-CfsFsy9P.js +2 -0
  130. package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +2 -0
  131. package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +2 -0
  132. package/dist/owletto/dist/assets/connected._clientId.activity-Ckdz6I0y.js +2 -0
  133. package/dist/owletto/dist/assets/connected._clientId.index-CNxafNeo.js +2 -0
  134. package/dist/owletto/dist/assets/connection-C3XXFEqh.js +2 -0
  135. package/dist/owletto/dist/assets/connection-feed-detail-CIJJLDP8.js +2 -0
  136. package/dist/owletto/dist/assets/connection-label-BobuYiAG.js +1 -0
  137. package/dist/owletto/dist/assets/connections-browser-CKZjzRz6.js +2 -0
  138. package/dist/owletto/dist/assets/{connector-provenance-BjKiUhYE.js → connector-provenance-8-d8hl10.js} +2 -1
  139. package/dist/owletto/dist/assets/connector-scope-lists-CadPVsI3.js +2 -0
  140. package/dist/owletto/dist/assets/{connectors-Baejya0T.js → connectors-lvLJ30lo.js} +2 -1
  141. package/dist/owletto/dist/assets/consent-CdSvVCgx.js +2 -0
  142. package/dist/owletto/dist/assets/conversations-table-BdXoZAfc.js +2 -0
  143. package/dist/owletto/dist/assets/{core.esm-QA7BQgiK.js → core.esm-CYvgWCuv.js} +2 -1
  144. package/dist/owletto/dist/assets/create-0xW9eXxG.js +2 -0
  145. package/dist/owletto/dist/assets/create-B0qhrrX4.js +2 -0
  146. package/dist/owletto/dist/assets/create-CAfF-yI1.js +2 -0
  147. package/dist/owletto/dist/assets/create-automation-form-CtSSeYj3.js +3 -0
  148. package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +2 -0
  149. package/dist/owletto/dist/assets/{cronstrue-2GHCtD7h.js → cronstrue-n4qGUraE.js} +2 -1
  150. package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +2 -0
  151. package/dist/owletto/dist/assets/deployments-RvUdVkj3.js +2 -0
  152. package/dist/owletto/dist/assets/{deployments-body-Bm2upStd.js → deployments-body-BMp7UsMo.js} +2 -1
  153. package/dist/owletto/dist/assets/device-CPU6CjkJ.js +2 -0
  154. package/dist/owletto/dist/assets/device-pin-tombstone-CrjG7gPo.js +2 -0
  155. package/dist/owletto/dist/assets/device._deviceId-Cs3ZmXWo.js +2 -0
  156. package/dist/owletto/dist/assets/{entity-options-CrbS6K-i.js → entity-options-uXjgT7y9.js} +2 -1
  157. package/dist/owletto/dist/assets/entity-page-Dc0LGr5U.js +2 -0
  158. package/dist/owletto/dist/assets/entity-type-page-CwZxa0BR.js +2 -0
  159. package/dist/owletto/dist/assets/event-detail-ve2d6Gbb.js +2 -0
  160. package/dist/owletto/dist/assets/events-feed-BtvhZF1f.js +2 -0
  161. package/dist/owletto/dist/assets/filter-editors-Cj-v6NtH.js +2 -0
  162. package/dist/owletto/dist/assets/full-page-spinner-DqpH99np.js +2 -0
  163. package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +2 -0
  164. package/dist/owletto/dist/assets/identity-BigVSBCl.js +2 -0
  165. package/dist/owletto/dist/assets/index-B9uPN6FC.js +2 -0
  166. package/dist/owletto/dist/assets/index-BLEcy9-T.css +1 -0
  167. package/dist/owletto/dist/assets/index-BQVliQW1.js +2 -0
  168. package/dist/owletto/dist/assets/index-BfedB4Rc.js +2 -0
  169. package/dist/owletto/dist/assets/index-CDz3-ieP.js +1 -0
  170. package/dist/owletto/dist/assets/index-CUw3aKBI.js +2 -0
  171. package/dist/owletto/dist/assets/index-CXhxUkv3.js +2 -0
  172. package/dist/owletto/dist/assets/index-Cr5hwh-C.js +7950 -0
  173. package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +2 -0
  174. package/dist/owletto/dist/assets/index-DKSx8JN_.js +2 -0
  175. package/dist/owletto/dist/assets/index-DVk7Ug0d.js +2 -0
  176. package/dist/owletto/dist/assets/index-DmZuKGf8.js +2 -0
  177. package/dist/owletto/dist/assets/index-DtqBFgK5.js +1 -0
  178. package/dist/owletto/dist/assets/index-Hio-HRfo.js +2 -0
  179. package/dist/owletto/dist/assets/{index-Cf0GJoiG.js → index-ICgKp3YK.js} +2 -1
  180. package/dist/owletto/dist/assets/index-Vcq4gwWv.js +1 -0
  181. package/dist/owletto/dist/assets/index-cPcroOH0.js +2 -0
  182. package/dist/owletto/dist/assets/{index-DlepU3cY.js → index-n7sTbNv4.js} +2 -1
  183. package/dist/owletto/dist/assets/index-rrnUF981.js +1 -0
  184. package/dist/owletto/dist/assets/index-xiFpcWKv.js +2 -0
  185. package/dist/owletto/dist/assets/json-diff-DBoag_OS.js +4 -0
  186. package/dist/owletto/dist/assets/{list-skeleton-BtWn2eo2.js → list-skeleton-C_GuoxAH.js} +2 -1
  187. package/dist/owletto/dist/assets/login-Ci6ixHuL.js +2 -0
  188. package/dist/owletto/dist/assets/logout-CLGgeZB7.js +2 -0
  189. package/dist/owletto/dist/assets/member-scope-gate-B44INDPY.js +2 -0
  190. package/dist/owletto/dist/assets/memory-browse-page-DyQiRvzl.js +103 -0
  191. package/dist/owletto/dist/assets/model-selector-dAbDgJvx.js +2 -0
  192. package/dist/owletto/dist/assets/models-DpVP7ZwX.js +2 -0
  193. package/dist/owletto/dist/assets/new-BUb7AnEW.js +2 -0
  194. package/dist/owletto/dist/assets/new-BkdULx2r.js +2 -0
  195. package/dist/owletto/dist/assets/new-CHOr-EcI.js +2 -0
  196. package/dist/owletto/dist/assets/oauth-workspace-access-BxsjwgdH.js +2 -0
  197. package/dist/owletto/dist/assets/organization-gxGeDjIV.js +2 -0
  198. package/dist/owletto/dist/assets/peek-pane-content-CHoQHe2H.js +2 -0
  199. package/dist/owletto/dist/assets/{permissions-h_qSft1A.js → permissions-aPHaKLec.js} +2 -1
  200. package/dist/owletto/dist/assets/proposal-review-shell-UcZr87_Q.js +2 -0
  201. package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +2 -0
  202. package/dist/owletto/dist/assets/{recent-JiBNvZzD.js → recent-D-65Pgu-.js} +2 -1
  203. package/dist/owletto/dist/assets/record-activity-CBXH6v1d.js +2 -0
  204. package/dist/owletto/dist/assets/{renderer-DgPLyEbx.js → renderer-mEDnVW0O.js} +28 -27
  205. package/dist/owletto/dist/assets/reset-password-uX_V6bip.js +2 -0
  206. package/dist/owletto/dist/assets/runs-C0rCgGwX.js +2 -0
  207. package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +2 -0
  208. package/dist/owletto/dist/assets/runs-table-syPJ6r6T.js +2 -0
  209. package/dist/owletto/dist/assets/settings-9NkNA1G1.js +2 -0
  210. package/dist/owletto/dist/assets/settings-E-10sLQX.js +2 -0
  211. package/dist/owletto/dist/assets/skill-editor-D_W3QlRz.js +1 -0
  212. package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +2 -0
  213. package/dist/owletto/dist/assets/source-record-panels-CPyzlfD1.js +2 -0
  214. package/dist/owletto/dist/assets/status-dot-B-EWMgq6.js +2 -0
  215. package/dist/owletto/dist/assets/tabs-DqIIkCX-.js +2 -0
  216. package/dist/owletto/dist/assets/{use-mention-search-B4DfZFm5.js → use-mention-search-By8RZyKW.js} +3 -2
  217. package/dist/owletto/dist/assets/view-param-filters-CqLZQrnO.js +2 -0
  218. package/dist/owletto/dist/assets/workspace-label-o_QfBuCM.js +2 -0
  219. package/dist/owletto/dist/index.html +46 -4
  220. package/dist/providers.json +1 -1
  221. package/dist/server-main.bundle.mjs +137029 -133673
  222. package/npm-shrinkwrap.json +612 -645
  223. package/package.json +4 -3
  224. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  225. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  226. package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
  227. package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
  228. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  229. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  230. package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
  231. package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
  232. package/vendor/connector-sdk/dist/connector-types.d.ts +169 -45
  233. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
  234. package/vendor/connector-sdk/dist/define-connector.js +3 -0
  235. package/vendor/connector-sdk/dist/index.d.ts +8 -2
  236. package/vendor/connector-sdk/dist/index.js +3 -0
  237. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
  238. package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
  239. package/vendor/connector-sdk/package.json +13 -1
  240. package/vendor/core/dist/agent-policy.js +1 -1
  241. package/vendor/core/dist/agent-store.d.ts +2 -0
  242. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  243. package/vendor/core/dist/agent-tooling.js +1 -1
  244. package/vendor/core/dist/capabilities.d.ts +1 -1
  245. package/vendor/core/dist/capabilities.js +2 -1
  246. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  247. package/vendor/core/dist/connector-query-errors.js +41 -1
  248. package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
  249. package/vendor/core/dist/contracts/agent-settings.js +1 -7
  250. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
  251. package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
  252. package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
  253. package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
  254. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
  255. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
  256. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
  257. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
  258. package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
  259. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
  260. package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
  261. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  262. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
  263. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
  264. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
  265. package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
  266. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  267. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  268. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
  269. package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
  270. package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
  271. package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
  272. package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
  273. package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
  274. package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
  275. package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
  276. package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
  277. package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
  278. package/vendor/core/dist/contracts/worker/protocol.d.ts +130 -159
  279. package/vendor/core/dist/contracts/worker/protocol.js +88 -76
  280. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  281. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  282. package/vendor/core/dist/index.d.ts +5 -5
  283. package/vendor/core/dist/index.js +4 -6
  284. package/vendor/core/dist/json-template.d.ts +6 -10
  285. package/vendor/core/dist/json-template.js +5 -9
  286. package/vendor/core/dist/logger.js +17 -26
  287. package/vendor/core/dist/shell-safety.d.ts +9 -0
  288. package/vendor/core/dist/shell-safety.js +154 -0
  289. package/vendor/core/dist/suggestions.d.ts +1 -1
  290. package/vendor/core/dist/suggestions.js +1 -1
  291. package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
  292. package/vendor/core/dist/tool-trace-summary.js +1 -1
  293. package/vendor/core/dist/types.d.ts +1 -3
  294. package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
  295. package/vendor/core/dist/utils/diagnostic-scrubber.js +437 -0
  296. package/vendor/core/dist/worker/auth.d.ts +44 -6
  297. package/vendor/core/dist/worker/auth.js +44 -11
  298. package/vendor/core/dist/worker/wire.d.ts +0 -10
  299. package/vendor/core/package.json +20 -11
  300. package/vendor/views/dist/api.d.ts +39 -29
  301. package/vendor/views/dist/api.js +110 -83
  302. package/vendor/views/dist/bridge.d.ts +4 -0
  303. package/vendor/views/dist/bridge.js +15 -0
  304. package/vendor/views/dist/index.d.ts +1 -0
  305. package/vendor/views/dist/index.js +0 -7
  306. package/vendor/views/package.json +4 -1
  307. package/dist/owletto/dist/assets/_-CLhipgJI.js +0 -1
  308. package/dist/owletto/dist/assets/_-D0ZVGAIA.js +0 -2
  309. package/dist/owletto/dist/assets/_agentId-BLXUf3ot.js +0 -1
  310. package/dist/owletto/dist/assets/_agentId-DnI66MF3.js +0 -1
  311. package/dist/owletto/dist/assets/_automationId-ziwseLb7.js +0 -1
  312. package/dist/owletto/dist/assets/_connectorKey._connectionId-B6V3ySFK.js +0 -1
  313. package/dist/owletto/dist/assets/_connectorKey.index-CR5u_dtt.js +0 -1
  314. package/dist/owletto/dist/assets/_conversationId-FBMYmOl8.js +0 -1
  315. package/dist/owletto/dist/assets/_deploymentId-DNTXbT_m.js +0 -1
  316. package/dist/owletto/dist/assets/_name-B37LKIxH.js +0 -1
  317. package/dist/owletto/dist/assets/_owner-BxYumqC2.js +0 -1
  318. package/dist/owletto/dist/assets/_shape-Bxz-04jR.js +0 -1
  319. package/dist/owletto/dist/assets/_skillKey-D5MFbiw2.js +0 -1
  320. package/dist/owletto/dist/assets/_slug-Dlhit09k.js +0 -1
  321. package/dist/owletto/dist/assets/_viewKey-C6535i-t.js +0 -1
  322. package/dist/owletto/dist/assets/_viewKey-CQCtY3Y8.js +0 -1
  323. package/dist/owletto/dist/assets/_viewKey-CxKfKbRa.js +0 -1
  324. package/dist/owletto/dist/assets/accept-invitation-BQQwec3R.js +0 -1
  325. package/dist/owletto/dist/assets/activity-route-view-BwThvdGs.js +0 -1
  326. package/dist/owletto/dist/assets/agent-card-controls-B3RhzsPz.js +0 -1
  327. package/dist/owletto/dist/assets/agent-connect-pages-BO4wQn4L.js +0 -1
  328. package/dist/owletto/dist/assets/agent-editor-form-BYC4uSNz.js +0 -1
  329. package/dist/owletto/dist/assets/agent-guardrails-route-Dp02G1AQ.js +0 -1
  330. package/dist/owletto/dist/assets/agent-loading-shells-OagauQzV.js +0 -1
  331. package/dist/owletto/dist/assets/agent-permissions-matrix-B9Ho3P1t.js +0 -1
  332. package/dist/owletto/dist/assets/agent-skills-route-B4VUnVi0.js +0 -1
  333. package/dist/owletto/dist/assets/agent-subpage-shell-Dz8I-GUt.js +0 -1
  334. package/dist/owletto/dist/assets/agent-thread-B9-cdkaV.js +0 -8
  335. package/dist/owletto/dist/assets/agent-thread-storage-U6htL3ad.js +0 -1
  336. package/dist/owletto/dist/assets/agents-D0CIg4b9.js +0 -1
  337. package/dist/owletto/dist/assets/agents-workbench-C2sr5h82.js +0 -1
  338. package/dist/owletto/dist/assets/app-bridge-BH3g2mKG.js +0 -127
  339. package/dist/owletto/dist/assets/app._appId-DLsJ_QWS.js +0 -1
  340. package/dist/owletto/dist/assets/automation-detail-content-9Rjb_I9j.js +0 -1
  341. package/dist/owletto/dist/assets/automations-D0CIg4b9.js +0 -1
  342. package/dist/owletto/dist/assets/calendar-DAiyi1ZL.js +0 -1
  343. package/dist/owletto/dist/assets/claim-CYHnUF7G.js +0 -1
  344. package/dist/owletto/dist/assets/clients-Cp1BJ28u.js +0 -1
  345. package/dist/owletto/dist/assets/code-editor-CYsR2VBP.js +0 -15
  346. package/dist/owletto/dist/assets/connect-CZip2g_B.js +0 -1
  347. package/dist/owletto/dist/assets/connect._clientId-CEKY8Dnv.js +0 -1
  348. package/dist/owletto/dist/assets/connected._clientId-C5xRjxNO.js +0 -1
  349. package/dist/owletto/dist/assets/connection-C06HZ241.js +0 -1
  350. package/dist/owletto/dist/assets/connection-feed-detail-D1whY5hL.js +0 -1
  351. package/dist/owletto/dist/assets/consent-CfYDldcF.js +0 -1
  352. package/dist/owletto/dist/assets/create-C3P-3_8O.js +0 -1
  353. package/dist/owletto/dist/assets/create-CwnrPUEw.js +0 -1
  354. package/dist/owletto/dist/assets/create-DOScS9Gl.js +0 -1
  355. package/dist/owletto/dist/assets/create-automation-form-CuxiIRCF.js +0 -2
  356. package/dist/owletto/dist/assets/create._connectorKey-Bjv3lCf8.js +0 -1
  357. package/dist/owletto/dist/assets/deployments-ByBv1DW-.js +0 -1
  358. package/dist/owletto/dist/assets/deployments-C-_ECORv.js +0 -1
  359. package/dist/owletto/dist/assets/device-B0i7Xp8y.js +0 -1
  360. package/dist/owletto/dist/assets/device-automation-BIjs7DZJ.js +0 -1
  361. package/dist/owletto/dist/assets/device-pin-tombstone-Bd6vS2zu.js +0 -1
  362. package/dist/owletto/dist/assets/device-rows-Bwf8qDte.js +0 -1
  363. package/dist/owletto/dist/assets/device._deviceId-DJLAesm3.js +0 -1
  364. package/dist/owletto/dist/assets/entity-page-ijZe_1-6.js +0 -1
  365. package/dist/owletto/dist/assets/entity-type-page-onp2Tk_E.js +0 -1
  366. package/dist/owletto/dist/assets/event-page-C0B2UDY-.js +0 -1
  367. package/dist/owletto/dist/assets/events-feed-DK35T4g7.js +0 -1
  368. package/dist/owletto/dist/assets/full-page-spinner-Dd8eEaxq.js +0 -1
  369. package/dist/owletto/dist/assets/guardrails-DKO8_J-G.js +0 -1
  370. package/dist/owletto/dist/assets/identity-CKM54vrM.js +0 -1
  371. package/dist/owletto/dist/assets/index--VmN5WxW.js +0 -1
  372. package/dist/owletto/dist/assets/index-B2AmRqYh.js +0 -7898
  373. package/dist/owletto/dist/assets/index-B_rcEgFX.js +0 -1
  374. package/dist/owletto/dist/assets/index-BmAuAhub.css +0 -1
  375. package/dist/owletto/dist/assets/index-BmhGe6-Z.js +0 -1
  376. package/dist/owletto/dist/assets/index-C1dJSGrL.js +0 -1
  377. package/dist/owletto/dist/assets/index-CAFw4qCb.js +0 -1
  378. package/dist/owletto/dist/assets/index-CCcc_xBw.js +0 -52
  379. package/dist/owletto/dist/assets/index-CLU3gXVm.js +0 -1
  380. package/dist/owletto/dist/assets/index-CqQVnAY-.js +0 -1
  381. package/dist/owletto/dist/assets/index-CxT0uyIe.js +0 -1
  382. package/dist/owletto/dist/assets/index-DR08e6Ec.js +0 -1
  383. package/dist/owletto/dist/assets/index-DYb9L5FC.js +0 -1
  384. package/dist/owletto/dist/assets/index-SUUcQGT-.js +0 -1
  385. package/dist/owletto/dist/assets/index-SdiFOfR1.js +0 -1
  386. package/dist/owletto/dist/assets/index-zcfi5r1l.js +0 -1
  387. package/dist/owletto/dist/assets/json-diff-ClBBYBQD.js +0 -3
  388. package/dist/owletto/dist/assets/login-d3PdO-qV.js +0 -1
  389. package/dist/owletto/dist/assets/logout-DgckxwLn.js +0 -1
  390. package/dist/owletto/dist/assets/member-scope-gate-DXOCfx-v.js +0 -1
  391. package/dist/owletto/dist/assets/memory-browse-page-CeAnKoTR.js +0 -101
  392. package/dist/owletto/dist/assets/missing-view-DrZ8m8yo.js +0 -1
  393. package/dist/owletto/dist/assets/model-selector-CapL1ARf.js +0 -1
  394. package/dist/owletto/dist/assets/models-CB8mhq7j.js +0 -1
  395. package/dist/owletto/dist/assets/new-BBUb-VR4.js +0 -1
  396. package/dist/owletto/dist/assets/new-CBLJ25_w.js +0 -1
  397. package/dist/owletto/dist/assets/new-tTXB4qBW.js +0 -1
  398. package/dist/owletto/dist/assets/oauth-workspace-access-DearynqZ.js +0 -1
  399. package/dist/owletto/dist/assets/organization-BgdBg-PJ.js +0 -1
  400. package/dist/owletto/dist/assets/pending-seed-CPbfgnLX.js +0 -1
  401. package/dist/owletto/dist/assets/proposal-review-shell-D4YNrrye.js +0 -1
  402. package/dist/owletto/dist/assets/reset-password-B8tWPtIj.js +0 -1
  403. package/dist/owletto/dist/assets/runs-oHveuEUB.js +0 -1
  404. package/dist/owletto/dist/assets/runs-panel-C56GDaJm.js +0 -1
  405. package/dist/owletto/dist/assets/runs-table-BUKDjiBc.js +0 -1
  406. package/dist/owletto/dist/assets/schema-value-normalization-3JuM_r1H.js +0 -1
  407. package/dist/owletto/dist/assets/settings-DaKg6U5O.js +0 -1
  408. package/dist/owletto/dist/assets/settings-DhnRi2nq.js +0 -1
  409. package/dist/owletto/dist/assets/skills-BpQncuMC.js +0 -1
  410. package/dist/owletto/dist/assets/switch-BQ40_DMb.js +0 -1
  411. package/dist/owletto/dist/assets/use-applied-views-B-Z-Weji.js +0 -1
  412. package/dist/owletto/dist/assets/view-frame-C7ciEoLo.js +0 -1
  413. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  414. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
  415. package/vendor/core/dist/sentry.d.ts +0 -26
  416. package/vendor/core/dist/sentry.js +0 -133
  417. package/vendor/core/dist/tool-policy.d.ts +0 -74
  418. package/vendor/core/dist/tool-policy.js +0 -305
  419. package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
  420. package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
@@ -1,55 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * `@lobu/views` authoring surface (brief §1.4): `defineView`, `useParams`,
4
- * `useScope`, `useQuery`, `useAction`, `sql`, plus the `mountView` entry the
5
- * compiled bundle calls once. Thin layer over the hand-written `ViewBridge` —
6
- * nothing here talks to the API directly; every read and action goes through
7
- * the host as `tools/call`, every param change through
8
- * `ui/update-model-context`.
9
- *
10
- * Contract with the host (our web host, Claude, any MCP Apps host):
11
- * - `ui/notifications/tool-input` `arguments` = `{ scope, params }`
12
- * (in Claude these are the `open_view` tool arguments).
13
- * - reads: `query_sql`, `query_sdk`, and tools the registry marks
14
- * `readOnlyHint` (`read_knowledge`, `get_automation`, `query_metric`, …);
15
- * actions: `invoke_view_action`. The web host refuses every other tool, so
16
- * mixed read/write tools such as `manage_connections` are not reachable
17
- * from a view: read that data with a `query_sdk` script
18
- * (`client.connections.list()`) instead.
19
- * - `setParams` → `ui/update-model-context` `{ structuredContent: { view,
20
- * params } }`; the web host mirrors it into the address bar. Hosts without
21
- * that capability keep params local to the frame.
22
- *
23
- * Read budget: reads run on a user-facing path, when the host is ready and
24
- * the query changes or `refetch()` is called.
25
- * `query_sql` runs in a read-only, org-scoped transaction with a 5 second
26
- * statement timeout and returns at most 500 rows; `useQuery` reports a hit as
27
- * `errorCode: "UPSTREAM_TIMEOUT"` or `truncated: true`, so render those
28
- * states instead of an empty or partial table. Never aggregate history in a
29
- * view: no `GROUP BY`, `DISTINCT ON`, per-row regexp, or leading-wildcard
30
- * `LIKE` over `events` (or any other table that grows with history). History
31
- * grows; the answer a view shows does not.
32
- *
33
- * For "latest state" views, compute state at write time. One event-based
34
- * pattern is an Automation bound to the entity declaring a keyed event output
35
- * (`outputs: { status: { event: "account_status", key: ["account"] } }`), so
36
- * each emitted update supersedes the previous event with the same output
37
- * identity. The view reads current events with `read_knowledge`
38
- * (registry-marked `readOnlyHint`, so the host lets a view call it), which
39
- * skips superseded rows:
40
- *
41
- * ```tsx
42
- * const { entity } = useScope();
43
- * const status = useQuery<{ content: Array<{ title: string | null;
44
- * metadata: Record<string, unknown> }> }>(
45
- * typeof entity === "number"
46
- * ? tool("read_knowledge", { entity_id: entity,
47
- * semantic_type: "account_status", sort_by: "date", limit: 1 })
48
- * : null
49
- * );
50
- * const current = status.data?.content[0];
51
- * ```
52
- */
53
2
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
54
3
  import { createRoot } from "react-dom/client";
55
4
  import { ViewBridge } from "./bridge.js";
@@ -210,6 +159,16 @@ export function useQuery(query) {
210
159
  loading: query !== null,
211
160
  });
212
161
  const [tick, setTick] = useState(0);
162
+ // A host data change re-reads the same query in the background: the rows
163
+ // already on screen stay until the fresh ones land, so a live view never
164
+ // flashes its loading state on every write.
165
+ const lastRead = useRef(null);
166
+ // Reads are numbered so a newer read never discards an older one still in
167
+ // flight for the same key: under a steady stream of writes every re-read
168
+ // would be superseded before it answered. Only a key change, or a newer
169
+ // answer already on screen, drops a result.
170
+ const readSeq = useRef(0);
171
+ const shownSeq = useRef(0);
213
172
  const key = query === null
214
173
  ? null
215
174
  : typeof query === "string"
@@ -217,18 +176,29 @@ export function useQuery(query) {
217
176
  : query.kind === "tool"
218
177
  ? `tool:${query.name}:${JSON.stringify(query.args)}`
219
178
  : `sql:${query.text}`;
220
- // biome-ignore lint/correctness/useExhaustiveDependencies: key is the stable identity of query (listing query itself refetches every render); rt.callTool is stable and tick is the intentional refetch trigger.
179
+ // biome-ignore lint/correctness/useExhaustiveDependencies: key is the stable identity of query (listing query itself refetches every render); rt.callTool is stable; tick and rt.dataVersion are the intentional refetch triggers.
221
180
  useEffect(() => {
222
181
  // A skipped query is idle, even when the previous request is in flight.
223
182
  if (key === null) {
183
+ lastRead.current = null;
224
184
  setState((s) => (s.loading ? { ...s, loading: false } : s));
225
185
  return;
226
186
  }
227
187
  // Queries still wait for the host to seed scope and params.
228
188
  if (!rt.ready)
229
189
  return;
230
- let cancelled = false;
231
- setState((s) => ({ ...s, loading: true }));
190
+ const seq = ++readSeq.current;
191
+ const show = (next) => {
192
+ if (lastRead.current?.key !== key || seq < shownSeq.current)
193
+ return;
194
+ shownSeq.current = seq;
195
+ setState(next);
196
+ };
197
+ const background = lastRead.current?.key === key &&
198
+ lastRead.current.dataVersion !== rt.dataVersion;
199
+ lastRead.current = { key, dataVersion: rt.dataVersion };
200
+ if (!background)
201
+ setState((s) => ({ ...s, loading: true }));
232
202
  const q = query;
233
203
  const call = typeof q === "string"
234
204
  ? rt.callTool("query_sdk", { script: q })
@@ -237,15 +207,11 @@ export function useQuery(query) {
237
207
  : rt.callTool("query_sql", { sql: q.text, limit: 500 });
238
208
  call
239
209
  .then((result) => {
240
- if (cancelled)
241
- return;
242
210
  const out = queryResult(typeof q === "string" ? "sdk" : q.kind === "tool" ? "tool" : "sql", result);
243
- setState({ ...out, loading: false });
211
+ show({ ...out, loading: false });
244
212
  })
245
213
  .catch((e) => {
246
- if (cancelled)
247
- return;
248
- setState({
214
+ show({
249
215
  data: null,
250
216
  error: e instanceof Error ? e.message : String(e),
251
217
  errorCode: null,
@@ -253,53 +219,76 @@ export function useQuery(query) {
253
219
  loading: false,
254
220
  });
255
221
  });
256
- return () => {
257
- cancelled = true;
258
- };
259
- }, [key, rt.ready, tick]);
222
+ }, [key, rt.ready, tick, rt.dataVersion]);
260
223
  const refetch = useCallback(() => setTick((t) => t + 1), []);
261
224
  return { ...state, refetch };
262
225
  }
263
- /** Mint the per-click interaction id the action tool requires (browser retry
264
- * id on web): a UUID where available, else a time + random fallback. */
226
+ /** Mint one id for a deliberate submission, retained by its retry closure. */
265
227
  export function mintInteractionId() {
266
228
  if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
267
229
  return crypto.randomUUID();
268
230
  }
269
231
  return `${Date.now()}-${Math.floor(Math.random() * 1e9)}`;
270
232
  }
271
- /** A declared action → `invoke_view_action { view, action, value }`. The name
272
- * must exist on the CURRENT view definition; a removed button throws here
273
- * instead of emitting a stale event. */
233
+ /** Submit a declared action. Failed acknowledgements expose an explicit retry
234
+ * that keeps the original value, event subject and interaction id. */
274
235
  export function useAction(name) {
275
236
  const rt = useRuntime();
276
237
  if (!rt.def.actions?.[name]) {
277
238
  throw new Error(`Action "${name}" is not declared on view "${rt.def.key}"`);
278
239
  }
279
240
  return useCallback(async (value = {}) => {
241
+ if (!rt.ready) {
242
+ return {
243
+ ok: false,
244
+ error: "The host has not supplied the view subject.",
245
+ result: null,
246
+ retry: null,
247
+ };
248
+ }
249
+ let args;
280
250
  try {
281
- // The tool requires an interaction id (browser retry id on web):
282
- // mint one per click so retries stay idempotent.
283
- const result = await rt.callTool("invoke_view_action", {
251
+ // Snapshot JSON before the first send; edits to a form after a failure
252
+ // must not change the meaning of an already accepted submission.
253
+ args = JSON.parse(JSON.stringify({
284
254
  view: rt.def.key,
285
255
  action: name,
286
256
  value,
257
+ ...(rt.scope.event === undefined
258
+ ? {}
259
+ : { scope: { event: rt.scope.event } }),
287
260
  interaction_id: mintInteractionId(),
288
- });
289
- const err = resultError(result);
290
- return {
291
- ok: !err,
292
- error: err,
293
- result: result.structuredContent ?? null,
294
- };
261
+ }));
295
262
  }
296
- catch (e) {
263
+ catch (error) {
297
264
  return {
298
265
  ok: false,
299
- error: e instanceof Error ? e.message : String(e),
266
+ error: error instanceof Error ? error.message : String(error),
300
267
  result: null,
268
+ retry: null,
301
269
  };
302
270
  }
271
+ const submit = async () => {
272
+ try {
273
+ const result = await rt.callTool("invoke_view_action", args);
274
+ const error = resultError(result);
275
+ return {
276
+ ok: !error,
277
+ error,
278
+ result: result.structuredContent ?? null,
279
+ retry: error ? submit : null,
280
+ };
281
+ }
282
+ catch (error) {
283
+ return {
284
+ ok: false,
285
+ error: error instanceof Error ? error.message : String(error),
286
+ result: null,
287
+ retry: submit,
288
+ };
289
+ }
290
+ };
291
+ return submit();
303
292
  }, [rt, name]);
304
293
  }
305
294
  export function defaultsFor(def) {
@@ -345,6 +334,19 @@ export function coerceScope(raw) {
345
334
  if (typeof scope.event === "number" && Number.isInteger(scope.event)) {
346
335
  out.event = scope.event;
347
336
  }
337
+ if (scope.collection !== undefined) {
338
+ if (!out.type || out.entity !== undefined || out.event !== undefined) {
339
+ throw new Error("Collection selection requires a type page");
340
+ }
341
+ if (!scope.collection ||
342
+ typeof scope.collection !== "object" ||
343
+ Array.isArray(scope.collection)) {
344
+ throw new Error("Collection selection must be an object");
345
+ }
346
+ // The host validates selection. Preserve it for the validating read API;
347
+ // never drop an unfamiliar filter and silently widen the collection.
348
+ out.collection = scope.collection;
349
+ }
348
350
  return out;
349
351
  }
350
352
  function themeFromContext(ctx) {
@@ -366,6 +368,7 @@ export function Provider({ def, bridge, children, }) {
366
368
  const [scope, setScope] = useState({});
367
369
  const [params, setParamsState] = useState(() => defaultsFor(def));
368
370
  const [theme, setTheme] = useState("light");
371
+ const [dataVersion, setDataVersion] = useState(0);
369
372
  const bridgeRef = useRef(bridge ?? null);
370
373
  if (bridge)
371
374
  bridgeRef.current = bridge;
@@ -383,11 +386,20 @@ export function Provider({ def, bridge, children, }) {
383
386
  setParamsState(coerceParams(def, input.params));
384
387
  setReady(true);
385
388
  });
389
+ // MCP hosts initially send the permalink arguments. The opening result
390
+ // supplies the exact readable version, including after a supersession.
391
+ const offResult = b.onToolResult((result) => {
392
+ const resolved = result.structuredContent;
393
+ if (resolved?.view === def.key && resolved.scope) {
394
+ setScope(coerceScope(resolved.scope));
395
+ }
396
+ });
386
397
  const offCtx = b.onHostContext((ctx) => {
387
398
  const next = themeFromContext(ctx);
388
399
  setTheme(next);
389
400
  applyTheme(next);
390
401
  });
402
+ const offData = b.onDataChanged(() => setDataVersion((v) => v + 1));
391
403
  b.connect()
392
404
  .then((ctx) => {
393
405
  const next = themeFromContext(ctx);
@@ -400,7 +412,9 @@ export function Provider({ def, bridge, children, }) {
400
412
  .catch((e) => console.error("[lobu-views] connect failed", e));
401
413
  return () => {
402
414
  offInput();
415
+ offResult();
403
416
  offCtx();
417
+ offData();
404
418
  };
405
419
  }, [def]);
406
420
  const setParams = useCallback((patch) => {
@@ -431,9 +445,22 @@ export function Provider({ def, bridge, children, }) {
431
445
  params,
432
446
  setParams,
433
447
  theme,
448
+ dataVersion,
449
+ callTool,
450
+ }), [
451
+ def,
452
+ connected,
453
+ ready,
454
+ scope,
455
+ params,
456
+ setParams,
457
+ theme,
458
+ dataVersion,
434
459
  callTool,
435
- }), [def, connected, ready, scope, params, setParams, theme, callTool]);
436
- return _jsx(Ctx.Provider, { value: value, children: children });
460
+ ]);
461
+ // A host-resolved replacement is a new form, including in MCP hosts that
462
+ // keep the iframe mounted while delivering the opening result.
463
+ return (_jsx(Ctx.Provider, { value: value, children: children }, scope.event ?? "unbound"));
437
464
  }
438
465
  /** Entry point the compiled bundle calls once. Mounts the component into
439
466
  * `#root` and connects to the host. */
@@ -68,6 +68,7 @@ export declare class ViewBridge {
68
68
  private toolResultListeners;
69
69
  private toolCancelledListeners;
70
70
  private hostContextListeners;
71
+ private dataChangedListeners;
71
72
  /** Set by the first `tool-input` and never cleared: queries must not fire
72
73
  * before it (the host seeds scope + params there; anything read earlier
73
74
  * runs against defaults and double-fetches). */
@@ -93,6 +94,9 @@ export declare class ViewBridge {
93
94
  onToolResult(listener: (result: ToolResult) => void): () => void;
94
95
  onToolCancelled(listener: (reason: string | null) => void): () => void;
95
96
  onHostContext(listener: (ctx: HostContext) => void): () => void;
97
+ /** The host saw workspace data change (Lobu hosts only; other hosts never
98
+ * send it, and reads then refresh on their own triggers). */
99
+ onDataChanged(listener: () => void): () => void;
96
100
  /**
97
101
  * Run the `ui/initialize` handshake, then announce readiness. Resolves with
98
102
  * the host context. Rejects when the host answers with an error or stays
@@ -20,6 +20,9 @@ const HANDOFF_NOTIFICATIONS = new Set([
20
20
  "ui/notifications/tool-cancelled",
21
21
  ]);
22
22
  const PROTOCOL_VERSION = "2026-01-26";
23
+ /** Lobu host → guest: workspace data changed, re-read. Not an MCP Apps
24
+ * method; hosts that do not speak it simply never send it. */
25
+ const DATA_CHANGED_NOTIFICATION = "lobu/notifications/data-changed";
23
26
  const DEFAULT_TIMEOUT_MS = 60_000;
24
27
  function isRecord(value) {
25
28
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -42,6 +45,7 @@ export class ViewBridge {
42
45
  toolResultListeners = new Set();
43
46
  toolCancelledListeners = new Set();
44
47
  hostContextListeners = new Set();
48
+ dataChangedListeners = new Set();
45
49
  /** Set by the first `tool-input` and never cleared: queries must not fire
46
50
  * before it (the host seeds scope + params there; anything read earlier
47
51
  * runs against defaults and double-fetches). */
@@ -113,6 +117,12 @@ export class ViewBridge {
113
117
  this.hostContextListeners.add(listener);
114
118
  return () => this.hostContextListeners.delete(listener);
115
119
  }
120
+ /** The host saw workspace data change (Lobu hosts only; other hosts never
121
+ * send it, and reads then refresh on their own triggers). */
122
+ onDataChanged(listener) {
123
+ this.dataChangedListeners.add(listener);
124
+ return () => this.dataChangedListeners.delete(listener);
125
+ }
116
126
  /**
117
127
  * Run the `ui/initialize` handshake, then announce readiness. Resolves with
118
128
  * the host context. Rejects when the host answers with an error or stays
@@ -312,6 +322,11 @@ export class ViewBridge {
312
322
  listener(snapshot);
313
323
  break;
314
324
  }
325
+ case DATA_CHANGED_NOTIFICATION: {
326
+ for (const listener of [...this.dataChangedListeners])
327
+ listener();
328
+ break;
329
+ }
315
330
  default:
316
331
  break;
317
332
  }
@@ -5,6 +5,7 @@
5
5
  * frame. The module declares itself with `defineView` and mounts once with
6
6
  * `mountView`; hooks bridge params, scope, reads and actions to the host.
7
7
  */
8
+ export type { AttributeFilter, CollectionSelection, } from "@lobu/core/contracts/tools/collection-selection";
8
9
  export { ViewBridge } from "./bridge.js";
9
10
  export type { BridgeOptions, HostContext, ToolResult, ViewHandoff, } from "./bridge.js";
10
11
  export { coerceParams, defaultsFor, defineView, escapeLiteral, mintInteractionId, mountView, Provider, sql, tool, useAction, useHost, useParams, useQuery, useScope, } from "./api.js";
@@ -1,10 +1,3 @@
1
- /**
2
- * `@lobu/views` — authoring runtime for Lobu views.
3
- *
4
- * A view is an ordinary React module rendered in the sandboxed MCP Apps
5
- * frame. The module declares itself with `defineView` and mounts once with
6
- * `mountView`; hooks bridge params, scope, reads and actions to the host.
7
- */
8
1
  export { ViewBridge } from "./bridge.js";
9
2
  export { coerceParams, defaultsFor, defineView, escapeLiteral, mintInteractionId, mountView, Provider, sql, tool, useAction, useHost, useParams, useQuery, useScope, } from "./api.js";
10
3
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/views",
3
- "version": "21.2.1",
3
+ "version": "23.0.0",
4
4
  "description": "Authoring runtime for Lobu views — React modules rendered in the sandboxed MCP Apps frame",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,6 +21,9 @@
21
21
  "dist",
22
22
  "!**/*.map"
23
23
  ],
24
+ "dependencies": {
25
+ "@lobu/core": "file:../core"
26
+ },
24
27
  "peerDependencies": {
25
28
  "react": "^19.0.0",
26
29
  "react-dom": "^19.0.0"
@@ -1 +0,0 @@
1
- import{cm as t,j as p,cn as m}from"./index-B2AmRqYh.js";import{A as e}from"./activity-route-view-BwThvdGs.js";import"./device-automation-BIjs7DZJ.js";import"./agent-thread-storage-U6htL3ad.js";import"./pending-seed-CPbfgnLX.js";import"./clients-Cp1BJ28u.js";import"./client-rows-EJSKR6z1.js";import"./connection-label-BobuYiAG.js";import"./events-feed-DK35T4g7.js";import"./use-applied-views-B-Z-Weji.js";import"./renderer-DgPLyEbx.js";import"./card-CMmh2mzo.js";import"./calendar-DAiyi1ZL.js";import"./agent-loading-shells-OagauQzV.js";import"./member-scope-gate-DXOCfx-v.js";function w(){const{owner:o,_splat:r}=t.useParams(),i=t.useSearch();return p.jsx(e,{owner:o,search:i,attentionLens:!1,entityScope:m(r||"").path})}export{w as component};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/entity-page-ijZe_1-6.js","assets/index-B2AmRqYh.js","assets/index-BmAuAhub.css","assets/schema-value-normalization-3JuM_r1H.js","assets/calendar-DAiyi1ZL.js","assets/view-frame-C7ciEoLo.js","assets/app-bridge-BH3g2mKG.js","assets/missing-view-DrZ8m8yo.js","assets/use-applied-views-B-Z-Weji.js"])))=>i.map(i=>d[i]);
2
- import{r as n,aV as j,aW as m,aX as v,aY as P,l as R,p as _,_ as E,V as S,j as e,aZ as w,a_ as b,a$ as N}from"./index-B2AmRqYh.js";function h(){return n.useEffect(()=>{j()},[]),null}const F=b(async()=>({default:(await N(async()=>{const{EntityPage:s}=await import("./entity-page-ijZe_1-6.js");return{EntityPage:s}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).EntityPage}));function r(){return e.jsx("div",{"data-public-loading":"true",children:e.jsx(w,{})})}function k(){const{owner:s,_splat:x}=m.useParams(),a=m.useSearch(),i=v(x||""),o=i?.viewKey,{path:f}=P(s,i?.entityPath),{data:t,isLoading:c,error:d}=R(f,{slug:s},{includeBootstrap:!0}),{session:y,isReady:l}=_(),u=E();if(n.useEffect(()=>{t?.redirect&&u({to:t.redirect.to,replace:!0})},[t?.redirect,u]),S({active:!c&&l&&!y&&(!!d||!t),owner:s}),c||!l&&!t)return e.jsx(r,{});if(t?.redirect)return e.jsx(r,{});if(d||!t||!t.entity)return e.jsxs(e.Fragment,{children:[e.jsx(h,{}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Not Found"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"We couldn't resolve this path."})]})]});const g=!o&&typeof a.merged_from=="string"&&t.entity.merged_records?.some(p=>p.name===a.merged_from)?a.merged_from:void 0;return e.jsxs(e.Fragment,{children:[e.jsx(h,{}),e.jsx(n.Suspense,{fallback:e.jsx(r,{}),children:e.jsx(F,{namespace:t.workspace,path:t.path,entity:t.entity,mergedFrom:g,viewKey:o})})]})}export{k as component};
@@ -1 +0,0 @@
1
- import{_ as L,gE as w,r as u,j as n,af as D,cv as k,p as E,q as P,bt as M,bk as N,bF as R,cx as O,gF as F,gG as Q,bQ as $,a3 as B}from"./index-B2AmRqYh.js";import{L as _,A as q}from"./agent-thread-B9-cdkaV.js";import{n as b}from"./agent-thread-storage-U6htL3ad.js";import{A as z,C as G}from"./agent-loading-shells-OagauQzV.js";import"./app-bridge-BH3g2mKG.js";import"./pending-seed-CPbfgnLX.js";import"./use-mention-search-B4DfZFm5.js";import"./index-Vcq4gwWv.js";function H({owner:t,agent:s,threadId:e,afterMessagesContent:d,className:r,initialDraft:x,newChatRequested:m=!1,preventAutoNavigate:g}){const o=L(),i=s.agentId,{data:a=[]}=w(i,{orgSlug:t}),[l,p]=u.useState(()=>b()),[h,A]=u.useState(null);u.useEffect(()=>{!m||e||(p(b()),A(null),o({to:".",search:(f=>{const{new:C,...S}=f;return S}),replace:!0}))},[m,e,o]);const v=u.useMemo(()=>!h||a.some(f=>f.id===h.id)?a:[h,...a],[a,h]),c=e??l,T=!e||!v.some(f=>f.id===e),j=u.useCallback(()=>{if(v.some(C=>C.id===c))return;A({id:c,title:`Conversation ${v.length+1}`,createdAt:Date.now(),updatedAt:Date.now()});const f=k(t,i,c);o({...f,replace:!0})},[v,c,o,t,i]),y=u.useCallback(()=>{T&&!g&&j()},[T,j,g]);return n.jsx("div",{className:D("flex min-h-0 flex-1 flex-col",r),children:n.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:n.jsx(_,{agentId:i,workspaceSlug:t,thread:c,loadHistory:!!e,onFirstUserMessage:y,initialDraft:x,children:n.jsx(q,{afterMessagesContent:d})},`${i}:${c}`)})})}function U({owner:t,agentId:s,threadId:e,initialDraft:d,newChatRequested:r,afterMessagesContent:x,preventAutoNavigate:m}){const{isAuthenticated:g}=E(),{isMember:o,isLoading:i}=P(),a=g&&o,{data:l=[],isLoading:p}=M({enabled:a}),h=s??null,A=l.find(c=>c.agentId===h)??null;return a&&p||i?n.jsx(z,{}):A?n.jsx(H,{owner:t,agent:A,threadId:e,initialDraft:d,newChatRequested:r,afterMessagesContent:x,preventAutoNavigate:m,className:"min-h-0 flex-1 overflow-hidden"}):n.jsx(N,{icon:R,title:"Agent not found",description:"This agent may have been removed."})}function W(t){return[...t].sort((s,e)=>e.updatedAt-s.updatedAt)[0]}function J({owner:t,agentId:s,threadId:e,initialDraft:d,forceComposer:r=!1,newChatRequested:x=!1,afterMessagesContent:m,preventAutoNavigate:g}){const o=L(),{data:i=[],isLoading:a}=O(F(t,s,{strict:!1})),l=u.useMemo(()=>W(i),[i]);return u.useEffect(()=>{if(e||r||a||!l)return;const p=k(t,s,l.id);o({...p,replace:!0})},[s,a,l,o,t,e,r]),!e&&!r&&(a||l)?n.jsx(G,{}):n.jsx(U,{owner:t,agentId:s,threadId:e,initialDraft:d,newChatRequested:x,afterMessagesContent:m,preventAutoNavigate:g})}function se(){const{owner:t,agentId:s}=Q.useParams(),{threadId:e}=$({strict:!1}),{new:d,prompt:r}=B({strict:!1});return n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 lg:px-6 lg:py-6",children:n.jsx("div",{className:"mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col",children:n.jsx(J,{owner:t,agentId:s,threadId:e,initialDraft:r,forceComposer:!e,newChatRequested:!!d})})})}export{se as component};
@@ -1 +0,0 @@
1
- import{gP as r,j as e}from"./index-B2AmRqYh.js";import{A as n}from"./agents-workbench-C2sr5h82.js";import"./agent-editor-form-BYC4uSNz.js";import"./model-selector-CapL1ARf.js";import"./proposal-review-shell-D4YNrrye.js";import"./runs-oHveuEUB.js";function c(){const{owner:o,agentId:t}=r.useParams();return e.jsx(n,{owner:o,agentId:t})}export{c as component};
@@ -1 +0,0 @@
1
- import{_ as N,Z as k,l as A,p as L,q as C,D as y,j as t,B as n,eD as D,bF as _,S as b,L as R,F as $,gI as p,aS as O}from"./index-B2AmRqYh.js";import{a as S}from"./automation-detail-content-9Rjb_I9j.js";import"./create-automation-form-CuxiIRCF.js";import"./cronstrue-2GHCtD7h.js";import"./entity-options-CrbS6K-i.js";import"./connection-label-BobuYiAG.js";import"./switch-BQ40_DMb.js";import"./device-automation-BIjs7DZJ.js";import"./model-selector-CapL1ARf.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-CYsR2VBP.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-B4DfZFm5.js";import"./proposal-review-shell-D4YNrrye.js";import"./runs-oHveuEUB.js";import"./json-diff-ClBBYBQD.js";import"./deployments-ByBv1DW-.js";import"./agent-loading-shells-OagauQzV.js";import"./agent-thread-B9-cdkaV.js";import"./app-bridge-BH3g2mKG.js";import"./pending-seed-CPbfgnLX.js";import"./events-feed-DK35T4g7.js";import"./use-applied-views-B-Z-Weji.js";import"./clients-Cp1BJ28u.js";import"./renderer-DgPLyEbx.js";import"./card-CMmh2mzo.js";function z({owner:o,automationId:e,view:a,runId:s}){const r=N(),{orgContext:u,hasOrgContext:x}=k(),{data:g,isLoading:m}=A(`/${o}`,u),{isAuthenticated:h}=L(),{isLoading:c}=C(),f=g?.workspace?.id??"",v=h?!x||m||c:m||c,i=y(e,void 0,f).data?.automation,j=i?.automation_name??"Automation",l=()=>void r({to:"/$owner/automations",params:{owner:o}}),d=()=>void r({to:"/$owner/automations/$automationId",params:{owner:o,automationId:e},search:{view:"activity",run_id:void 0}}),w=!s&&a==="definition";return t.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:t.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsxs(n,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:l,children:[t.jsx(D,{className:"h-3.5 w-3.5"}),"Automations"]}),t.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[t.jsx(_,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),v&&!i?t.jsx(b,{className:"h-5 w-40"}):s?"Review change":j]})]}),s?null:w?t.jsx(n,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-muted-foreground hover:text-foreground",onClick:d,children:"Done"}):t.jsx(n,{asChild:!0,variant:"ghost",size:"sm",className:"h-8 gap-1.5",children:t.jsxs(R,{to:"/$owner/automations/$automationId",params:{owner:o,automationId:e},search:{view:"definition",run_id:void 0},children:[t.jsx($,{className:"h-3.5 w-3.5"}),"Edit"]})})]}),t.jsx(S,{owner:o,agentId:i?.managed_agent_id??null,automationId:e,view:a,runId:s,onDone:s?l:d})]})})}function ct(){const{owner:o,automationId:e}=p.useParams(),a=p.useSearch();return t.jsx(O,{owner:o,children:()=>t.jsx(z,{owner:o,automationId:e,view:a.view,runId:a.run_id})})}export{ct as component};
@@ -1 +0,0 @@
1
- import{h$ as F,j as e,aS as P,_ as W,b9 as H,a as O,d7 as V,i as G,S as L,L as h,gC as v,gA as U,bp as q,de as z,gB as J,hk as A,a4 as Q}from"./index-B2AmRqYh.js";import{R as X,c as Y,C as Z}from"./device-pin-tombstone-Bd6vS2zu.js";import{a as K}from"./connector-provenance-BjKiUhYE.js";import{f as ee,C as ne,F as se,b as ae,a as oe,A as te,c as ce}from"./connection-feed-detail-D1whY5hL.js";import{S as ie,g as re}from"./runs-table-BUKDjiBc.js";import{c as de}from"./connection-label-BobuYiAG.js";import{c as le}from"./device-rows-Bwf8qDte.js";import"./runs-panel-C56GDaJm.js";import"./runs-oHveuEUB.js";import"./entity-options-CrbS6K-i.js";function _e(){const{owner:r,connectorKey:a,connectionId:f}=F.useParams(),{addFeed:o,feedId:d,settings:u,auth_result:c}=F.useSearch();return e.jsx(P,{owner:r,children:l=>e.jsx(me,{organizationId:l.organizationId,ownerSlug:l.ownerSlug,isWorkspaceLoading:l.isWorkspaceLoading,connectorKey:a,connectionId:Number(f),showAddFeed:o===!0,feedId:d,openSettings:u===!0,authResult:c})})}function me({organizationId:r,ownerSlug:a,isWorkspaceLoading:f,connectorKey:o,connectionId:d,showAddFeed:u,feedId:c,openSettings:l,authResult:R}){const S=W(),{data:I=[]}=H(),{data:B=[],isLoading:E}=O(r??"",{connectorKey:o}),{data:C=[]}=V(r??""),{data:M=[]}=G(c?d:null),n=B.find(t=>t.id===d),s=C.find(t=>t.key===o),i=c?M.find(t=>t.id===c):null;if(f||E||!r)return e.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[e.jsx(L,{className:"h-7 w-56"}),e.jsx(L,{className:"h-4 w-24"})]}),e.jsx(X,{})]});if(!n)return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connection not found."}),e.jsxs(h,{to:"/$owner/connectors/$connectorKey",params:{owner:a,connectorKey:o},className:"mt-2 inline-block text-sm text-primary hover:underline",children:["Back to ",s?.name??o]})]});const D=de({...n,connector_name:n.connector_name??s?.name??null}),p=!c&&!u,T=()=>void S({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:o,connectionId:String(d)},search:{},replace:!0});let m,x=D,g,_,j;c?i?(x=ee(i,s),i.store==="channel_messages"?(m=e.jsx(ne,{feed:i,hideHeader:!0}),j="chat channel"):(g=e.jsx(se,{feed:i,ownerSlug:a}),_=e.jsx(ae,{feed:i}),m=e.jsx(oe,{feed:i,connectorDef:s,ownerSlug:a}))):(m=e.jsx("p",{className:"text-sm text-muted-foreground",children:"Feed not found."}),x="Feed"):u&&(m=e.jsx(te,{onClose:T,organizationId:r,connections:[n],connectorDefinitions:C}),x="Add feed",j=ce);const N=[e.jsx(h,{to:"/$owner/connectors",params:{owner:a},className:v,children:"Connectors"},"connectors"),e.jsx(h,{to:"/$owner/connectors/$connectorKey",params:{owner:a,connectorKey:o},search:{},className:v,children:s?.name??o},"connector")];p||N.push(e.jsx(h,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:o,connectionId:String(d)},search:{},className:v,children:D},"connection"));const $=p?Y(n):null,y=j??$??void 0,b=e.jsx(U,{breadcrumb:e.jsx(J,{crumbs:N}),icon:s?e.jsx(q,{icon:s.icon,name:s.name,faviconDomain:s.favicon_domain??z(s.auth_schema)}):null,title:x,status:g??e.jsx(ie,{status:re(n.status),showDot:!0,children:n.status}),meta:_,caption:y,captionTone:$?"error":"muted"});if(!p)return e.jsx(A,{header:b,children:e.jsx("div",{className:"mt-0",children:m})});const k=s&&le(s)?I.find(t=>t.id===n.device_worker_id&&t.connectors.some(w=>w.connection_id===n.id&&w.organization_slug===a)):void 0;return k?e.jsx(Q,{to:"/$owner/connectors/device/$deviceId",params:{owner:a,deviceId:k.id},search:{connection:n.id,settings:l||void 0},hash:`connection-${n.id}`,replace:!0}):e.jsxs(A,{header:b,children:[e.jsx(K,{connectorDef:s,connectorKey:o,ownerSlug:a,deviceWorkerId:n.device_worker_id,deviceLabel:n.device_label}),e.jsx(Z,{connection:n,connectorDef:s,ownerSlug:a,openSettings:l,authResult:R},n.id)]})}export{_e as component};
@@ -1 +0,0 @@
1
- import{h4 as Xe,am as Ze,h5 as re,r as h,h6 as ye,h7 as Je,cw as es,h8 as Ne,aA as K,h9 as be,j as e,a6 as P,bR as we,bS as Se,bT as Ae,bU as _e,bV as Pe,gW as ss,a7 as $,B as g,b_ as Y,n as T,R as Ce,ha as ts,hb as as,x as ns,hc as rs,bu as ie,hd as is,he as ls,hf as De,hg as Le,hh as $e,aP as J,ab as M,bD as ae,hi as os,g1 as cs,hj as ds,fL as W,hk as le,hl as us,S as L,eL as I,p as ms,hm as hs,hn as xs,ho as ps,hp as fs,hq as gs,hr as js,hs as vs,ht as ys,cc as Z,hu as Ns,hv as bs,cb as Cs,eh as ks,e3 as ws,af as ee,dL as Ss,cf as As,P as Fe,hw as se,hx as _s,aS as Ps,hy as Oe,b5 as te,o as Ee,eN as Re,bd as Ds,hz as Be,eM as Ls,hA as Ue,L as G,hB as $s,ek as Fs,u as Os,a as Es,bl as Rs,ba as V,cD as Ie,_ as q,hC as Bs,b8 as Us,hD as Is,gA as oe,bq as Me,bp as ce,bm as Ms,gB as de,gC as ue,b6 as zs,b7 as Ts,hE as Ks,de as Vs}from"./index-B2AmRqYh.js";import{C as qs}from"./connector-provenance-BjKiUhYE.js";import{a as Ys}from"./runs-table-BUKDjiBc.js";import{R as Ws}from"./runs-panel-C56GDaJm.js";import"./connection-label-BobuYiAG.js";import"./runs-oHveuEUB.js";function Gs({catalog:s,initialProvider:t,initialModel:a,onDone:n}){const r=Xe(),i=Ze(),o=s.find(l=>l.slug===t)??s[0],p=o&&re(o)?"oauth":"api-key",[d,x]=h.useState(o?.slug??""),[u,c]=h.useState(o?.slug??""),[v,y]=h.useState(o?.displayName??""),[j,N]=h.useState(o?.baseUrl??""),[C,D]=h.useState(a??o?.defaultModel??""),[S,k]=h.useState(""),[z,w]=h.useState(o?.apiKeyPlaceholder??""),[R,F]=h.useState(p),[E,B]=h.useState(""),[f,m]=h.useState(null),[A,U]=h.useState(!1),[Q,me]=h.useState(!1),b=s.find(l=>l.slug===d),H=ye(b?.modalities??[]),he=b?re(b):!1,xe=b?Je(b):!1,pe=he&&R==="oauth",fe=xe&&!pe,O=es().slug,X=h.useCallback(()=>{me(!0),i.invalidateQueries({queryKey:["inference-providers"]})},[i]),Ke=h.useCallback(()=>{i.invalidateQueries({queryKey:["inference-providers"]}),n()},[i,n]),Ve=h.useCallback(async()=>{if(!(!O||!b)){U(!0);try{const l=await Ne(O,b.slug);if(l.mode!=="redirect")throw new Error("Unexpected sign-in mode");window.open(l.authorizeUrl,"_blank","noreferrer")}catch(l){K.error(l instanceof Error?l.message:"Failed to start sign-in")}finally{U(!1)}}},[O,b]),qe=h.useCallback(async()=>{if(!(!O||!b||!E.trim())){U(!0);try{const l=await be(O,b.slug,{code:E.trim()});if(l.status!=="success")throw new Error(l.error||"Sign-in not complete");X(),K.success(`Signed in with ${b.displayName}`)}catch(l){K.error(l instanceof Error?l.message:"Failed to complete sign-in")}finally{U(!1)}}},[O,b,E,X]),Ye=h.useCallback(async()=>{if(!(!O||!b)){U(!0);try{const l=await Ne(O,b.slug);if(l.mode!=="device")throw new Error("Unexpected sign-in mode");m({userCode:l.userCode,deviceAuthId:l.deviceAuthId,verificationUrl:l.verificationUrl}),window.open(l.verificationUrl,"_blank","noreferrer")}catch(l){K.error(l instanceof Error?l.message:"Failed to start sign-in")}finally{U(!1)}}},[O,b]),We=h.useCallback(async()=>{if(!(!O||!b||!f)){U(!0);try{const l=await be(O,b.slug,{deviceAuthId:f.deviceAuthId,userCode:f.userCode});if(l.status==="success"){X(),K.success(`Signed in with ${b.displayName}`);return}m(_=>_&&{..._,message:l.error||"Waiting for approval..."})}catch(l){K.error(l instanceof Error?l.message:"Failed to check status")}finally{U(!1)}}},[O,b,f,X]),Ge=b?.supportedAuthTypes.includes("device-code")??!1,Qe=l=>{x(l);const _=s.find(ne=>ne.slug===l);_&&(c(_.slug),y(_.displayName),N(_.baseUrl),D(_.slug===t&&a?a:_.defaultModel??""),w(_.apiKeyPlaceholder),F(re(_)?"oauth":"api-key"),B(""),m(null),me(!1))},ge=/^[a-z0-9][a-z0-9-]*$/.test(u),je=ge&&fe&&S.trim().length>0&&!r.isPending,He=l=>{if(l.preventDefault(),!je)return;const _={};j.trim()&&(_.base_url=j.trim()),C.trim()&&(_.model=C.trim());const ne=Object.keys(_).length>0?{text:_}:void 0;r.mutate({slug:u.trim(),kind:d,displayName:v.trim()||void 0,apiKey:S.trim(),capabilities:ne},{onSuccess:()=>n()})},ve=!!(t&&s.some(l=>l.slug===t));return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:ve&&b?`Connect ${b.displayName}`:"Add an inference provider"}),e.jsxs("form",{onSubmit:He,className:"grid max-w-md gap-3",children:[ve&&b?e.jsx("p",{className:"text-xs text-muted-foreground",children:H.length>0?`Serves text, plus ${H.join(", ").toLowerCase()}.`:"Serves text (chat)."}):e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"ip-provider",children:"Provider"}),e.jsxs(we,{value:d,onValueChange:Qe,children:[e.jsx(Se,{id:"ip-provider",className:"w-full",children:e.jsx(Ae,{})}),e.jsx(_e,{children:s.map(l=>{const _=ye(l.modalities);return e.jsx(Pe,{value:l.slug,children:e.jsxs("span",{className:"flex items-center gap-2",children:[l.iconUrl?e.jsx("img",{src:l.iconUrl,alt:"",className:"h-4 w-4 shrink-0 rounded-sm",loading:"lazy"}):e.jsx(ss,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),l.displayName,_.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",_.join(", ")]}):null]})},l.slug)})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:H.length>0?`Serves text, plus ${H.join(", ").toLowerCase()}.`:"Serves text (chat)."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"ip-display",children:"Name"}),e.jsx($,{id:"ip-display",placeholder:"Friendly name",value:v,onChange:l=>y(l.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(P,{htmlFor:"ip-slug",children:["Slug ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx($,{id:"ip-slug",placeholder:"my-provider",value:u,onChange:l=>c(l.target.value),autoComplete:"off",required:!0}),u&&!ge?e.jsx("p",{className:"text-xs text-destructive",children:"Lowercase letters, numbers, and hyphens only."}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"A stable identifier agents reference this provider by."})]}),he&&xe?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{children:"Auth method"}),e.jsxs("div",{className:"inline-flex w-fit rounded-md border border-border p-1",children:[e.jsx(g,{type:"button",size:"sm",variant:R==="oauth"?"secondary":"ghost",onClick:()=>F("oauth"),children:"Sign in"}),e.jsx(g,{type:"button",size:"sm",variant:R==="api-key"?"secondary":"ghost",onClick:()=>F("api-key"),children:"API key"})]})]}):null,fe?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"ip-base-url",children:"Base URL"}),e.jsx($,{id:"ip-base-url",placeholder:"https://api.example.com/v1",value:j,onChange:l=>N(l.target.value),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Override the upstream URL — e.g. a self-hosted vLLM, Azure, or LiteLLM endpoint."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"ip-model",children:"Default model"}),e.jsx($,{id:"ip-model",placeholder:"gpt-4o-mini",value:C,onChange:l=>D(l.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(P,{htmlFor:"ip-key",children:["API key ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx($,{id:"ip-key",type:"password",placeholder:z||void 0,value:S,onChange:l=>k(l.target.value),autoComplete:"off",required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Stored encrypted in the vault. It's never shown again — rotate it here if it changes."})]}),e.jsx(Y,{onCancel:n,children:e.jsx(g,{type:"submit",disabled:!je,children:r.isPending?e.jsxs(e.Fragment,{children:[e.jsx(T,{size:"lg",className:"mr-2"}),"Creating..."]}):"Create provider"})})]}):pe?e.jsxs("div",{className:"grid gap-3",children:[Q?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Signed in with ",b?.displayName??"provider",". This covers your agents in this org."]}):Ge?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void Ye(),disabled:A||!O,children:f?"Get a new code":"Get device code"}),f?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"ip-device-code",children:"Device code"}),e.jsx($,{id:"ip-device-code",readOnly:!0,value:f.userCode}),e.jsx(g,{type:"button",variant:"default",className:"justify-self-start",asChild:!0,children:e.jsxs("a",{href:f.verificationUrl,target:"_blank",rel:"noreferrer",children:["Open ",b?.displayName??"provider"," to approve",e.jsx(Ce,{className:"h-4 w-4"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.message||"We opened the approval page. Enter the code above if asked, approve, then check status."}),e.jsx(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void We(),disabled:A,children:A?"Checking...":"Check status"})]}):null]}):e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void Ve(),disabled:A||!O,children:["Sign in with ",b?.displayName??"provider",e.jsx(Ce,{className:"h-4 w-4"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"ip-oauth-code",children:"Paste code#state"}),e.jsx($,{id:"ip-oauth-code",placeholder:"code#state",value:E,onChange:l=>B(l.target.value),autoComplete:"off"})]}),e.jsx(g,{type:"button",className:"justify-self-start",onClick:()=>void qe(),disabled:A||!E.trim(),children:A?"Finishing...":"Finish sign-in"})]}),e.jsx(Y,{onCancel:n,children:e.jsx(g,{type:"button",onClick:Ke,disabled:!Q,children:"Done"})})]}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This provider cannot be added from the catalog yet."}),e.jsx(Y,{onCancel:n})]})]})]})}const Qs={text:"Text",image:"Image",stt:"Speech-to-text",tts:"Text-to-speech"};function Hs({provider:s,catalog:t,autoOpenEdit:a}){const n=ts(),[r,i]=h.useState(a?"edit":null),o=as(s.kind,t);h.useEffect(()=>{a&&i("edit")},[a]);const d=(t.find(c=>c.slug===s.kind)?.modalities??["text"]).filter(c=>c!=="text"),x=o&&d.length>0,u=c=>i(v=>v===c?null:c);return e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:"Credential"}),e.jsxs("p",{className:"truncate text-[11px] text-muted-foreground",children:[s.slug,s.createdAt?` · created ${ns(s.createdAt)}`:""]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.isDefault?null:e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:n.isPending,onClick:()=>n.mutate({providerSlug:s.slug}),children:"Set as default"}),x?e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>u("capabilities"),children:"Configure"}):null,e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>u("edit"),children:"Edit"})]})]}),r==="edit"?e.jsx("div",{className:"border-t px-3 py-3",children:e.jsx(Zs,{provider:s,supportsUpstreamConfig:o,onDone:()=>i(null)})}):null,r==="capabilities"&&x?e.jsx("div",{className:"border-t px-3 py-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Other modalities (optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This provider's text base URL and model are set under Edit. Only set these if you want a modality routed to a different endpoint — otherwise it uses the provider's defaults."})]}),d.map(c=>e.jsx(Js,{providerSlug:s.slug,modality:c,block:s.capabilities[c]??{}},c))]})}):null]})}function Xs({provider:s,onDeleted:t}){const a=rs(),[n,r]=h.useState(!1);return e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Delete provider"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Removes ",s.displayName||s.slug," and its stored key from this workspace. Agents referencing it will need another connected provider before they can run."]}),e.jsx("div",{className:"mt-3",children:n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(g,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate({providerSlug:s.slug},{onSuccess:t,onSettled:()=>r(!1)}),children:[a.isPending?e.jsx(T,{size:"md",className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(g,{variant:"ghost",size:"sm",disabled:a.isPending,onClick:()=>r(!1),children:"Cancel"})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",disabled:a.isPending,onClick:()=>r(!0),children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete provider"]})})]})}function Zs({provider:s,supportsUpstreamConfig:t,onDone:a}){const n=is(),r=ls(),i=De(),[o,p]=h.useState(s.displayName??""),[d,x]=h.useState(""),u=s.capabilities.text??{},[c,v]=h.useState(u.base_url??""),[y,j]=h.useState(u.model??""),[N,C]=h.useState(null),D=o.trim().length>0&&o.trim()!==(s.displayName??""),S=t&&d.trim().length>0,k=c.trim()!==(u.base_url??""),z=y.trim()!==(u.model??""),w=t&&(k||z),R={base_url:c.trim()||void 0,model:y.trim()||void 0,models_endpoint:u.models_endpoint},F=Le(R),E=t&&w&&$e(F),B=n.isPending||r.isPending||i.isPending,f=(D||S||w)&&!E&&!B,m=async A=>{if(A.preventDefault(),!!f){C(null);try{await Promise.all([D?n.mutateAsync({providerSlug:s.slug,displayName:o.trim()}):Promise.resolve(),w?i.mutateAsync({providerSlug:s.slug,modality:"text",block:R}):Promise.resolve(),S?r.mutateAsync({providerSlug:s.slug,value:d.trim()}):Promise.resolve()]),a()}catch{C("Some changes could not be saved. Review the fields and try again.")}}};return e.jsxs("form",{onSubmit:m,className:"grid max-w-md gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:`edit-name-${s.slug}`,children:"Name"}),e.jsx($,{id:`edit-name-${s.slug}`,value:o,onChange:A=>p(A.target.value),placeholder:s.slug}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["The slug (",e.jsx("code",{children:s.slug}),") is fixed — agents reference it."]})]}),t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:`edit-base-${s.slug}`,children:"Base URL"}),e.jsx($,{id:`edit-base-${s.slug}`,placeholder:"https://api.example.com/v1",value:c,onChange:A=>v(A.target.value),autoComplete:"off"}),F.base_url?e.jsx("p",{className:"text-xs text-destructive",children:F.base_url}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:`edit-model-${s.slug}`,children:"Default model"}),e.jsx($,{id:`edit-model-${s.slug}`,placeholder:"gpt-4o-mini",value:y,onChange:A=>j(A.target.value),autoComplete:"off"}),F.model?e.jsx("p",{className:"text-xs text-destructive",children:F.model}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:`edit-key-${s.slug}`,children:"New API key"}),e.jsx($,{id:`edit-key-${s.slug}`,type:"password",value:d,onChange:A=>x(A.target.value),autoComplete:"off",placeholder:"Leave blank to keep the current key"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter a value only to replace the stored key. The old key is discarded."})]})]}):null,N?e.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:N}):null,e.jsx(Y,{onCancel:a,children:e.jsx(g,{type:"submit",disabled:!f,children:B?e.jsxs(e.Fragment,{children:[e.jsx(T,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})})]})}function Js({providerSlug:s,modality:t,block:a}){const n=De(),[r,i]=h.useState(!1),[o,p]=h.useState(a.base_url??""),[d,x]=h.useState(a.model??""),[u,c]=h.useState(a.models_endpoint??""),[v,y]=h.useState(!!a.models_endpoint),j=!!(a.base_url||a.model||a.models_endpoint),N={base_url:o.trim()||void 0,model:d.trim()||void 0,models_endpoint:u.trim()||void 0},C=Le(N),D=$e(C),S=()=>{D||n.mutate({providerSlug:s,modality:t,block:N})};return e.jsxs("div",{className:J,children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-3 py-2 text-left",onClick:()=>i(k=>!k),children:[e.jsx("span",{className:"text-sm font-medium",children:Qs[t]}),j?e.jsx(M,{variant:"outline",children:"Custom"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Static"})]}),r?e.jsxs("div",{className:"grid gap-3 border-t px-3 py-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:`base-${s}-${t}`,children:"Base URL"}),e.jsx($,{id:`base-${s}-${t}`,placeholder:"https://api.example.com/v1",value:o,onChange:k=>p(k.target.value),autoComplete:"off"}),C.base_url?e.jsx("p",{className:"text-xs text-destructive",children:C.base_url}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:`model-${s}-${t}`,children:"Model"}),e.jsx($,{id:`model-${s}-${t}`,placeholder:"gpt-4o-mini",value:d,onChange:k=>x(k.target.value),autoComplete:"off"}),C.model?e.jsx("p",{className:"text-xs text-destructive",children:C.model}):null]}),v?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:`endpoint-${s}-${t}`,children:"Models endpoint"}),e.jsx($,{id:`endpoint-${s}-${t}`,placeholder:"/v1/models",value:u,onChange:k=>c(k.target.value),autoComplete:"off"}),C.models_endpoint?e.jsx("p",{className:"text-xs text-destructive",children:C.models_endpoint}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Path used to list this modality's models (e.g. /v1/models)."})]}):e.jsx("button",{type:"button",className:"justify-self-start text-xs text-muted-foreground hover:text-foreground",onClick:()=>y(!0),children:"Advanced"}),e.jsx(Y,{onCancel:()=>i(!1),children:e.jsx(g,{size:"sm",disabled:D||n.isPending,onClick:S,children:n.isPending?e.jsxs(e.Fragment,{children:[e.jsx(T,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})})]}):null]})}function et({sandbox:s}){const t=Object.entries(s.details??{});return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(tt,{kind:s.providerKind}),e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx(M,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] uppercase tracking-wide",children:s.providerKind}),s.connected?e.jsx(M,{className:"h-4 border-transparent bg-emerald-500/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-emerald-500",children:"Connected"}):e.jsx(M,{variant:"destructive",className:"h-4 border-transparent bg-destructive/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-destructive",children:"No credential"})]}),t.length>0?e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:t.map(([a,n])=>`${a}: ${n}`).join(" | ")}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remote sandbox agents execute in instead of the built-in local runtime."}),s.connected?null:e.jsxs("div",{className:"flex gap-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:[e.jsx(ae,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("p",{children:"This sandbox has no vault credential. Delete it and re-add the provider with a valid key, or set the credential via the API."})]})]})})}function st({sandbox:s,onDeleted:t}){const a=os(),[n,r]=h.useState(!1);return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rounded-lg border border-destructive/30 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Remove sandbox"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents pinned to this runtime fall back to the built-in local sandbox."})]})]}),n?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate({id:s.id},{onSuccess:t}),children:a.isPending?e.jsx(T,{}):"Delete permanently"}),e.jsx(g,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"})]}):e.jsx(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>r(!0),children:"Delete sandbox"})]})})}function tt({kind:s}){return s==="vercel"?e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4 w-4 shrink-0 fill-foreground","aria-hidden":!0,children:[e.jsx("title",{children:"Vercel"}),e.jsx("path",{d:"M12 3 22 20H2L12 3Z"})]}):s==="builtin"?e.jsx(cs,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(ds,{className:"h-4 w-4 shrink-0 text-muted-foreground"})}const at={data:!1,chat:!1,actions:!1,audience:!1,inference:!0,runtime:!1},nt={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function Dt(){const{owner:s,connectorKey:t}=se.useParams(),{kind:a,id:n}=_s(t);return e.jsx(Ps,{owner:s,children:({ownerSlug:r,organizationId:i,isWorkspaceLoading:o})=>{switch(a){case"inference":return e.jsx(lt,{ownerSlug:r,providerSlug:n});case"sandbox":return e.jsx(it,{ownerSlug:r,sandboxId:n});case"sandbox-provider":return e.jsx(rt,{ownerSlug:r,providerKind:n});default:return e.jsx(ut,{ownerSlug:r,organizationId:i,isWorkspaceLoading:o,connectorKey:t})}}})}function rt({ownerSlug:s,providerKind:t}){const a=q();return h.useEffect(()=>{a({to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:`${Bs}${t}`},replace:!0})},[a,s,t]),null}function it({ownerSlug:s,sandboxId:t}){const a=q(),{data:n,isLoading:r}=Us(),i=n?.sandboxes.find(p=>p.id===t)??null;if(r)return e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-6 w-6 rounded"}),e.jsx(L,{className:"h-5 w-40"})]}),e.jsx(L,{className:"h-24 w-full rounded-lg"})]});if(!i)return e.jsxs(V,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This sandbox isn't in this workspace, so its details aren't available."}),e.jsx(g,{variant:"outline",size:"sm",onClick:()=>void a({to:"/$owner/connectors",params:{owner:s}}),children:"Back to connectors"})]});const o=i.name||Is(i.providerKind);return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(le,{header:e.jsx(oe,{breadcrumb:e.jsx(de,{crumbs:[e.jsx(G,{to:"/$owner/connectors",params:{owner:s},className:ue,children:"Connectors"},"connectors")]}),icon:e.jsx(ce,{name:o,faviconDomain:Ms(i.providerKind)}),title:o,badge:e.jsxs(e.Fragment,{children:[e.jsx(M,{variant:"secondary",children:i.providerKind}),i.connected?e.jsx(M,{className:"border-transparent bg-emerald-500/10 text-emerald-500",children:"Connected"}):e.jsx(M,{variant:"destructive",children:"No credential"})]}),status:e.jsx(Me,{facets:nt})}),children:[e.jsx(et,{sandbox:i}),e.jsx(I,{title:"Settings",muted:!0,children:e.jsx(st,{sandbox:i,onDeleted:()=>void a({to:"/$owner/connectors",params:{owner:s}})})})]})})}function lt({ownerSlug:s,providerSlug:t}){const a=q(),{model:n,reason:r,agentId:i}=se.useSearch(),{data:o=[],isLoading:p}=zs(),d=Ts(),{data:x=[],isLoading:u}=d,c=o.find(D=>D.slug===t)??null,v=x.find(D=>D.slug===(c?.kind??t))??null;if(p||u)return e.jsx("div",{children:e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-6 w-6 rounded"}),e.jsx(L,{className:"h-5 w-40"})]}),e.jsx(L,{className:"h-16 w-full rounded-lg"}),e.jsx(L,{className:"h-24 w-full rounded-lg"}),e.jsx(L,{className:"h-32 w-full rounded-lg"})]})});if(!c&&!v&&!d.isError)return e.jsxs(V,{className:"space-y-3",children:[e.jsx(Ie,{connector:{key:t,name:t},showDescription:!1,className:"gap-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector isn't installed in this workspace, so its details aren't available."})]});const y=c?.displayName||v?.displayName||t,j=c!==null,N=r?e.jsx(dt,{agentId:i,model:n,providerName:y}):n?e.jsx(ct,{providerName:y,model:n,isConnected:j}):null,C=e.jsx(oe,{breadcrumb:e.jsx(de,{crumbs:[e.jsx(G,{to:"/$owner/connectors",params:{owner:s},className:ue,children:"Connectors"},"connectors")]}),icon:e.jsx(ce,{iconUrl:v?.iconUrl,name:y}),title:y,badge:c?e.jsxs(e.Fragment,{children:[c.isDefault?e.jsx(M,{variant:"secondary",children:"Default"}):null,c.status?e.jsx(M,{variant:"outline",children:c.status}):null,c.hasCustomUpstream?e.jsx(M,{variant:"outline",children:"Custom upstream"}):null]}):null,status:e.jsx(Me,{facets:at})});return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(le,{header:C,children:[N,e.jsx("div",{className:"space-y-6",children:c?e.jsx(Hs,{provider:c,catalog:x,autoOpenEdit:!!n}):e.jsx(ot,{ownerSlug:s,providerSlug:t,catalog:x,catalogError:d.isError?d.error:null,model:n})}),c?e.jsx(I,{title:"Settings",muted:!0,children:e.jsx(Xs,{provider:c,onDeleted:()=>void a({to:"/$owner/connectors",params:{owner:s}})})}):null]})})}function ot({ownerSlug:s,providerSlug:t,catalog:a,catalogError:n,model:r}){const i=q();return n?e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Failed to load provider catalog."}),e.jsx("p",{className:"mt-1 text-xs",children:n instanceof Error?n.message:"Check the workspace URL and try again."})]})]})}):e.jsx("div",{className:"rounded-lg border p-4",children:e.jsx(Gs,{catalog:a,initialProvider:t,initialModel:r?.includes("/")?r.split("/").slice(1).join("/"):r,onDone:()=>void i({to:"/$owner/connectors",params:{owner:s}})},`${a.length}:${t}`)})}function ct({providerName:s,model:t,isConnected:a}){return e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review ",e.jsx("strong",{children:s})," for model"," ",e.jsx("strong",{children:t}),"."," ",a?"Its edit controls are open.":"It is not connected yet; add it to continue."]})]})})}function dt({agentId:s,model:t,providerName:a}){return e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"This agent needs a model provider before it can reply."}),e.jsxs("p",{children:[s?e.jsxs("span",{children:["Agent ",e.jsx("strong",{children:s})," is"," "]}):null,"configured to use ",t?e.jsx("strong",{children:t}):"a model"," ","from ",e.jsx("strong",{children:a}),", but that provider is not ready in this workspace."]}),e.jsx("p",{children:"Connect the provider below, then retry the message."})]})]})})}function ut({ownerSlug:s,organizationId:t,isWorkspaceLoading:a,connectorKey:n}){const{data:r=[],isLoading:i}=Os(t??""),{data:o=[],isLoading:p,refetch:d}=Es(t??"",{connectorKey:n}),x=h.useMemo(()=>r.find(v=>v.key===n),[r,n]),u=h.useMemo(()=>Rs(n,r,{name:o[0]?.connector_name??n}),[n,r,o]);if(a||i)return e.jsx("div",{children:e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-6 w-6 rounded"}),e.jsx(L,{className:"h-5 w-40"})]}),e.jsx(L,{className:"h-16 w-full rounded-lg"}),e.jsx(L,{className:"h-24 w-full rounded-lg"}),e.jsx(L,{className:"h-32 w-full rounded-lg"})]})});const c=x?e.jsx(ht,{connector:x,ownerSlug:s}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ie,{connector:u,showDescription:!1,className:"gap-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This connector isn't installed in this workspace, so its details aren't available.",o.length>0?" Existing connections keep working.":""]})]});return e.jsx("div",{className:"flex flex-1 flex-col",children:x&&t?e.jsx(mt,{hero:c,connector:x,organizationId:t,ownerSlug:s,connectorKey:n,connections:o,isLoading:p,refetchConnections:d}):e.jsxs(V,{className:"space-y-6",children:[c,e.jsx(ze,{organizationId:t??"",ownerSlug:s,connectorKey:n,connections:o,isLoading:p})]})})}function mt({hero:s,connector:t,organizationId:a,ownerSlug:n,connectorKey:r,connections:i,isLoading:o,refetchConnections:p}){const{isAdmin:d,isLoading:x}=W(a),u=(t.operations_summary?.total??0)>0;return e.jsxs(le,{header:s,children:[e.jsx(us,{organizationId:a,connectorKey:r}),e.jsx(vt,{connector:t,organizationId:a,ownerSlug:n,connectorKey:r,connections:i,isLoading:o,refetchConnections:p}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:auto-cols-fr sm:grid-flow-col",children:[e.jsx(Ys,{connections:i,connectorDef:t,organizationId:a,ownerSlug:n,connectorKey:r,isLoading:o}),e.jsx(Nt,{connector:t,organizationId:a,ownerSlug:n}),u&&x?e.jsx(L,{className:"h-20 w-full rounded-lg"}):u&&d?e.jsx(ft,{connector:t,organizationId:a,ownerSlug:n}):u&&!d?e.jsx(I,{title:"Actions",muted:!0,children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Only workspace admins can view and configure connector actions."})}):null]}),e.jsx(xt,{connector:t,organizationId:a,ownerSlug:n,connectionCount:i.length}),!o&&i.length>0?e.jsx(I,{title:"Recent activity",children:e.jsx(Ws,{scope:{connectorKey:r},ownerSlug:n})}):null]})}function ht({connector:s,ownerSlug:t}){return e.jsx(oe,{breadcrumb:e.jsx(de,{crumbs:[e.jsx(G,{to:"/$owner/connectors",params:{owner:t},className:ue,children:"Connectors"},"connectors")]}),icon:e.jsx(ce,{icon:s.icon,name:s.name,faviconDomain:s.favicon_domain??Vs(s.auth_schema),className:"h-10 w-10"}),title:s.name,badge:e.jsx(qs,{connectorDef:s,ownerSlug:t}),caption:s.description})}function xt({connector:s,organizationId:t,ownerSlug:a,connectionCount:n}){const r=Oe(s.auth_schema),i=Ds(s.auth_schema),o=r.find(S=>S.type==="oauth"),p=Be(s.auth_schema),d=r.some(S=>S.type==="env_keys"),x=r.some(S=>S.type==="browser"),u=i.some(S=>S.type==="interactive"),c=!!(o||p||d||x),v=Ls(s),{isAdmin:y}=W(t),{data:j=[]}=te(t,{connectorKey:s.key,profileKind:"env"}),{data:N=[]}=te(t,{profileKind:"browser_session"}),C=y&&s.installed!==!1;return!!(o||p)||d&&j.length>0||x&&N.length>0||!c||C?e.jsxs("div",{className:"space-y-6",children:[o?e.jsx(gt,{connector:s,organizationId:t,oauthMethod:o}):null,p?e.jsx(I,{title:"App installation",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Install the ",s.name," app to create or repair the workspace connection."]}),e.jsx(Ue,{organizationId:t,connectorKey:s.key,provider:p.provider,providerLabel:s.name,installShape:p.installShape,variant:"outline"})]})}):null,d&&j.length>0?e.jsx(ke,{profiles:j,type:"env"}):null,x&&N.length>0?e.jsx(ke,{profiles:N,type:"browser_session"}):null,c?null:v?e.jsx(I,{title:"Device runtime",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.name," runs on a linked device — there are no workspace credentials to configure here. Pair a device, then create a connection pinned to it."]}),e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(G,{to:"/$owner/connectors",params:{owner:a},search:{},children:"View devices"})})]})}):u?e.jsx(I,{title:"Authentication",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.name," pairs when you create a connection — there is no workspace-level credential to configure here."]})}):e.jsx(I,{title:"Authentication",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector doesn't need workspace credentials. Create a connection from Overview to get started."})}),e.jsx(pt,{connector:s,organizationId:t,ownerSlug:a,connectionCount:n})]}):null}function pt({connector:s,organizationId:t,ownerSlug:a,connectionCount:n}){const r=q(),{isAdmin:i}=W(t),o=Ks(),[p,d]=h.useState(!1),[x,u]=h.useState(null),c=s.installed!==!1;if(!i||!c)return null;const v=n>0,y=o.isPending,j=()=>{u(null),o.mutate({connector_key:s.key},{onSuccess:()=>{r({to:"/$owner/connectors",params:{owner:a}})},onError:N=>{u(N instanceof Error?N.message:"Failed to remove connector"),d(!1)}})};return e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Remove connector"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Archives ",s.name," in this workspace. Existing synced data stays in memory."]}),v?e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Delete"," ",e.jsxs("span",{className:"font-medium text-foreground",children:[n," connection",n===1?"":"s"]})," ","first — uninstall is blocked while any connection still references this connector."]}):null,x?e.jsx("p",{className:"mt-2 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}):null,e.jsx("div",{className:"mt-3",children:p?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(g,{variant:"destructive",size:"sm",disabled:y,onClick:j,children:[y?e.jsx(T,{size:"md",className:"mr-1.5"}):null,"Confirm remove"]}),e.jsx(g,{variant:"ghost",size:"sm",disabled:y,onClick:()=>d(!1),children:"Cancel"})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",disabled:y||v,onClick:()=>d(!0),children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove connector"]})})]})}function ft({connector:s,organizationId:t,ownerSlug:a}){const n=Ee();return e.jsx(Re,{title:"Actions",summary:`${s.operations_summary?.total??0} actions · organization policies`,onOpen:()=>n?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectorKey:s.key,organizationId:t,ownerSlug:a}})})}function gt({connector:s,organizationId:t,oauthMethod:a}){const{isAdmin:n,isLoading:r}=W(t),{setup:i}=se.useSearch(),o=se.useNavigate(),{data:p=[],refetch:d,isLoading:x,isError:u}=te(t,{connectorKey:s.key,provider:a.provider}),c=p.filter(v=>v.profile_kind==="oauth_app");return r||x?e.jsx(L,{className:"h-28 w-full"}):u?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load OAuth apps. Reload the page to try again."}):e.jsx(jt,{connector:s,oauthMethod:a,appProfiles:c,isAdmin:n,initialOpen:i==="oauth_app",onClose:()=>{i==="oauth_app"&&o({search:v=>({...v,setup:void 0}),hash:"",replace:!0})},refetchProfiles:d})}function jt({initialOpen:s=!1,onClose:t,connector:a,oauthMethod:n,appProfiles:r,isAdmin:i,refetchProfiles:o}){const p=vs(),d=ys(),[x,u]=Z(a.key,s&&i),[c,v]=h.useState(!1);h.useEffect(()=>{s&&i&&u(!0)},[s,i,u]);const y=`${Ns()}/connect/oauth/callback`,[j,N]=Z(a.key,`${a.name} OAuth App`),[C,D]=Z(a.key,""),[S,k]=Z(a.key,null),z=bs(n),w=Cs(`${a.key}:${x}`,ks(z),z),{values:R,setValues:F}=w,E=r.find(f=>f.is_default_for_connector&&f.connector_key===a.key),B=()=>{w.canSubmit&&(k(null),p.mutate({connector_key:a.key,profile_kind:"oauth_app",display_name:j.trim()||`${a.name} OAuth App`,slug:C.trim()||void 0,credentials:Ct(Fs(R))},{onSuccess:f=>{const m=f.auth_profile?.slug;m&&!E&&d.mutate({connector_key:a.key,auth_profile_slug:m}),u(!1),t?.(),N(`${a.name} OAuth App`),D(""),o()},onError:f=>{k(f instanceof Error?f.message:"Failed to add OAuth app")}}))};return e.jsxs(I,{id:"connector-oauth-apps",title:`${bt(n.provider)} app configuration`,action:i&&!x?e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>u(!0),children:[e.jsx(Fe,{className:"size-3.5"}),"Add OAuth app"]}):null,children:[i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"OAuth callback URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs",children:y}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(y).then(()=>v(!0)).catch(()=>k("Could not copy the callback URL. Select and copy it above."))},children:[e.jsx(ws,{className:"mr-1.5 h-3.5 w-3.5"}),c?"Copied":"Copy callback URL"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Register this exact URL in your provider’s app settings before saving the client configuration."})]}),r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No app configured on this server. Choose a managed option if available, or add your own app here."}):e.jsx("div",{className:"space-y-2",children:r.map(f=>e.jsxs("div",{className:ee(J,"flex flex-wrap items-center gap-3 p-3"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:f.display_name}),f.is_default_for_connector&&f.connector_key===a.key?e.jsx(M,{variant:"secondary",className:"text-[10px]",children:"Default"}):null,e.jsx(Te,{status:f.status})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:f.slug})]}),i&&!f.is_default_for_connector&&f.connector_key===a.key&&f.status==="active"?e.jsx(g,{variant:"outline",size:"sm",disabled:d.isPending,onClick:()=>d.mutate({connector_key:a.key,auth_profile_slug:f.slug}),children:"Set default"}):null]},f.slug))}),i&&x?e.jsxs("div",{className:ee(J,"space-y-3 p-3"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"oauth-app-name",children:"Display name"}),e.jsx($,{id:"oauth-app-name",value:j,onChange:f=>N(f.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"oauth-app-slug",children:"Slug"}),e.jsx($,{id:"oauth-app-slug",placeholder:"optional",value:C,onChange:f=>D(f.target.value)})]}),e.jsx(Ss,{schema:w.revision??void 0,values:R,onValuesChange:F,fieldIdPrefix:"oauth-app-"}),e.jsx(As,{visible:w.hasConflict,onReload:w.reset}),S?e.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:S}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g,{variant:"outline",size:"sm",disabled:p.isPending,onClick:()=>{u(!1),t?.()},children:"Cancel"}),e.jsxs(g,{size:"sm",disabled:p.isPending||!w.canSubmit,onClick:B,children:[p.isPending?e.jsx(T,{size:"md",className:"mr-1.5"}):null,"Save OAuth app"]})]})]}):null]})}function vt({connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i,refetchConnections:o}){const d=Oe(s.auth_schema).find(y=>y.type==="oauth"),{data:x=[],refetch:u,isLoading:c,isError:v}=te(t,{connectorKey:s.key,provider:d?.provider});if(d){if(v)return e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load accounts. Reload the page to try again."});const y=x.filter(N=>N.profile_kind==="oauth_app"),j=x.filter(N=>N.profile_kind==="oauth_account");return e.jsx(yt,{connector:s,organizationId:t,oauthMethod:d,appProfiles:y,accounts:j,connections:r,isLoading:i||c,refetchProfiles:u,refetchConnections:o})}return e.jsx(ze,{connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i})}function yt({connector:s,organizationId:t,oauthMethod:a,appProfiles:n,accounts:r,connections:i,isLoading:o,refetchProfiles:p,refetchConnections:d}){const{session:x}=ms(),{isAdmin:u,isLoading:c}=W(t),v=hs(),y=xs(),j=ps(),[N,C]=h.useState(""),[D,S]=h.useState([]),k=n.filter(m=>m.status==="active"),z=k.find(m=>m.is_default_for_connector&&m.connector_key===s.key),w=(u?k.find(m=>m.slug===N):void 0)??z??(u&&k.length===1?k[0]:void 0),R=new Set(i.map(m=>m.auth_profile_slug)),F=r.filter(m=>m.created_by===x?.user?.id),E=F.filter(m=>!R.has(m.slug)),B=!i.some(m=>m.created_by===x?.user?.id)&&F.length===0;if(o||c||!x?.user?.id||!B&&E.length===0&&!j.error&&!j.continueUrl)return null;const f=m=>j.begin(async()=>{const A=await v.mutateAsync({connector_key:s.key,app_auth_profile_slug:m,requested_scopes:$s(a,D)});return p(),d(),A});return e.jsxs(I,{title:B?"Connect your account":"Your accounts",children:[B&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your own account to grant access. Your connection is private to you."}),u&&k.length>1?e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{children:"App used for this account"}),e.jsxs(we,{value:w?.slug??"",onValueChange:C,children:[e.jsx(Se,{"aria-label":"App used for this account",children:e.jsx(Ae,{placeholder:"Choose an OAuth app"})}),e.jsx(_e,{children:k.map(m=>e.jsxs(Pe,{value:m.slug,children:[m.display_name,m.is_default_for_connector&&m.connector_key===s.key?" (workspace default)":""]},m.slug))})]})]}):w?e.jsxs("p",{className:"text-sm",children:["App: ",w.display_name,w.is_default_for_connector&&w.connector_key===s.key?" (workspace default)":""]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Configure an OAuth app below, then connect your account.":"Ask an administrator to configure and set the workspace-default OAuth app."}),w&&e.jsx(fs,{requiredScopes:js(a),optionalScopes:gs(a),selectedOptionalScopes:D,onToggleOptionalScope:(m,A)=>S(U=>A?[...new Set([...U,m])]:U.filter(Q=>Q!==m))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(g,{size:"sm",disabled:!w||j.pending,onClick:()=>{w&&f(w.slug)},children:"Connect account"}),u&&e.jsx(g,{asChild:!0,size:"sm",variant:"outline",children:e.jsx("a",{href:"#connector-oauth-apps",children:"Manage app"})})]})]}),E.map(m=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-2",children:[e.jsx("span",{className:"text-sm",children:m.display_name}),e.jsx(g,{variant:"outline",size:"sm",disabled:j.pending,onClick:()=>void j.begin(()=>m.status==="active"?v.mutateAsync({connector_key:s.key,auth_profile_slug:m.slug}):y.mutateAsync({auth_profile_slug:m.slug})),children:m.status==="active"?"Use this account":"Reconnect"})]},m.slug)),j.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:j.error}),j.continueUrl&&e.jsx("a",{href:j.continueUrl,target:"_blank",rel:"noreferrer",className:"text-sm underline",children:"Continue authorization in your browser"})]})}function ke({profiles:s,type:t}){const a=t==="env"?"Credentials":"Browser sessions";return e.jsx(I,{title:a,children:e.jsx("div",{className:"space-y-2",children:s.map(n=>e.jsxs("div",{className:ee(J,"p-3"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:n.display_name}),e.jsx(Te,{status:n.status})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.slug})]},n.slug))})})}function Nt({connector:s,organizationId:t,ownerSlug:a}){const n=Ee(),r=Object.keys(s.feeds_schema??{}).length;return r?e.jsx(Re,{title:"Feeds",summary:`${r} ${r===1?"feed type":"feed types"}`,onOpen:()=>n?.open({href:"",title:"Feeds",connectorPanel:{section:"feeds",connectorKey:s.key,organizationId:t,ownerSlug:a}})}):null}function ze({connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i}){const o=q(),p=Be(s?.auth_schema);if(i)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{className:"h-4 w-24"}),e.jsx(L,{className:"h-16 w-full rounded-lg"})]});if(r.length===0){const d=s&&p?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ue,{organizationId:t,connectorKey:n,provider:p.provider,providerLabel:s.name,installShape:p.installShape,size:"default",label:`Install ${s.name}`}),e.jsx(g,{asChild:!0,variant:"outline",children:e.jsx(G,{to:"/$owner/connectors/create/$connectorKey",params:{owner:a,connectorKey:n},children:"Use your own app"})})]}):e.jsxs(g,{size:"default",onClick:()=>o({to:"/$owner/connectors/create/$connectorKey",params:{owner:a,connectorKey:n}}),children:[e.jsx(Fe,{className:"mr-1.5 h-4 w-4"}),"Create connection"]});return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:d})}return null}function Te({status:s}){const t=s==="active"?"text-green-500":s==="error"||s==="revoked"?"text-destructive":"text-amber-500";return e.jsxs("span",{className:ee("text-xs",t),children:["· ",s]})}function bt(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Ct(s){const t={};for(const[a,n]of Object.entries(s))typeof n=="string"&&n.trim()?t[a]=n.trim():(typeof n=="number"||typeof n=="boolean")&&(t[a]=String(n));return t}export{mt as ConnectorDetailShell,yt as OAuthAccountsSection,jt as OAuthAppProfilesSection,Dt as component};
@@ -1 +0,0 @@
1
- import{j as e,eo as M,af as h,ik as w,r as j,q as z,a as C,il as k}from"./index-B2AmRqYh.js";import{A as N}from"./agent-loading-shells-OagauQzV.js";import{s as b,R as y,A as L}from"./agent-thread-B9-cdkaV.js";import"./app-bridge-BH3g2mKG.js";import"./pending-seed-CPbfgnLX.js";import"./use-mention-search-B4DfZFm5.js";import"./index-Vcq4gwWv.js";const m={path:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z",hex:"5865F2"},d={path:"M1.637 0C.733 0 0 .733 0 1.637v16.5c0 .904.733 1.636 1.637 1.636h3.955v3.323c0 .804.97 1.207 1.539.638l3.963-3.96h11.27c.903 0 1.636-.733 1.636-1.637V5.592L18.408 0Zm3.955 5.592h12.816v8.59H8.455l-2.863 2.863Z",hex:"34A853"},p={path:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z",hex:"26A5E4"},x={path:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z",hex:"25D366"},O={discord:{hex:`#${m.hex}`,path:m.path},gchat:{hex:`#${d.hex}`,path:d.path},slack:{hex:"#4A154B",path:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"},teams:{imgSrc:"https://www.google.com/s2/favicons?domain=teams.microsoft.com&sz=64"},telegram:{hex:`#${p.hex}`,path:p.path},whatsapp:{hex:`#${x.hex}`,path:x.path}};function T({platform:s,className:t}){const a=s?O[s]:null;return a?"imgSrc"in a?e.jsx("img",{src:a.imgSrc,alt:"","aria-hidden":"true",className:h("rounded-sm",t),loading:"lazy"}):e.jsx("svg",{viewBox:a.viewBox??"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:t,style:{color:a.hex},children:e.jsx("path",{d:a.path})}):e.jsx(M,{className:h("text-muted-foreground",t),"aria-hidden":"true"})}const I={slack:"Slack",telegram:"Telegram",whatsapp:"WhatsApp",discord:"Discord",web:"Web"};function R(s,t,a){return s==="slack"&&a?.teamId&&t?`https://app.slack.com/client/${a.teamId}/${t}`:null}function S({owner:s,agentId:t,conversationId:a}){const{data:n=[],isLoading:u}=w(t,a,{orgSlug:s}),c=j.useMemo(()=>n.map(r=>b(r,{showToolCalls:!0})).filter(r=>r!==null),[n]),[o,g]=a.split(":"),i=I[o]??"the source app",{org:f}=z(),{data:v=[]}=C(f?.id??"",{connectorKey:o}),A=v[0]?.config?.chatMetadata,l=R(o,g,A);return e.jsx("div",{className:"mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col pb-6",children:u?e.jsx(N,{readOnly:!0}):c.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No messages in this conversation."}):e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e.jsx(y,{messages:c,children:e.jsx(L,{readOnly:!0})}),l?e.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"mt-4 flex items-center gap-3 rounded-lg border border-border bg-muted/40 px-4 py-3 text-sm transition-colors hover:bg-muted",children:[e.jsx(T,{platform:o,className:"size-5 shrink-0"}),e.jsxs("span",{className:"text-muted-foreground",children:["This is a read-only copy. Continue the conversation with this agent in ",i,"."]}),e.jsxs("span",{className:"ml-auto shrink-0 whitespace-nowrap font-medium text-foreground",children:["Open ",i," →"]})]}):null]})})}function _(){const{owner:s,agentId:t,conversationId:a}=k.useParams();return e.jsx(S,{owner:s,agentId:t,conversationId:a})}export{_ as component};
@@ -1 +0,0 @@
1
- import{j as e,L as h,eD as f,c6 as j,c7 as g,bk as d,h1 as y,h0 as N,en as m,x as o,ab as b,af as v,aP as D,e3 as w,aA as S,hX as A}from"./index-B2AmRqYh.js";import{c as x,d as C}from"./deployments-body-Bm2upStd.js";import{J as I}from"./json-diff-ClBBYBQD.js";import{b as k,a as B}from"./deployments-ByBv1DW-.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";const c="change-";function L({owner:t,deploymentId:s}){const a=s.startsWith(c),r=k(a?null:s),l=B(a?s.slice(c.length):null),i=a?l:r;return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs(h,{to:"/$owner/connectors/deployments",params:{owner:t},className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(f,{className:"h-3 w-3"}),"All deployments"]}),i.isLoading?e.jsx(j,{label:"deployment",variant:"panel"}):i.isError?e.jsx(g,{label:"deployment"}):a?l.data?e.jsx(E,{change:l.data}):e.jsx(d,{icon:y,title:"Change not found",description:"This config change is not in the audit trail, or the server predates the deployments API."}):r.data?e.jsx($,{detail:r.data}):e.jsx(d,{icon:N,title:"Deployment not found",description:"This apply run is not in the audit trail, or the server predates the deployments API."})]})}function $({detail:t}){const{deployment:s,changes:a}=t;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("h2",{className:"text-lg font-semibold",children:["Deployment ",s.applyId?.slice(4,12)??s.id]}),C(s.status),s.gitDirty?e.jsx(b,{variant:"outline",children:"Dirty working tree"}):null]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[m(s.createdAt)," (",o(s.createdAt),")",s.createdBy?` · by ${s.createdBy}`:""]}),e.jsxs("dl",{className:"grid gap-1.5 text-xs",children:[s.applyId?e.jsx(n,{label:"Apply id",value:s.applyId,copyable:!0}):null,s.manifestHash?e.jsx(n,{label:"Manifest hash",value:s.manifestHash,copyable:!0}):null,s.gitSha?e.jsx(n,{label:"Git SHA",value:s.gitDirty?`${s.gitSha} (dirty)`:s.gitSha,copyValue:s.gitSha,copyable:!0}):null,s.cliVersion?e.jsx(n,{label:"CLI version",value:s.cliVersion,copyable:!0}):null]}),s.status==="partial_failure"&&s.error?e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:s.error}):null]}),s.gitSha?e.jsxs("section",{className:v(D,"space-y-2 p-4"),children:[e.jsx("p",{className:"text-sm font-medium",children:"Rollback"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback is git-first: revert the commit that produced this deployment, then re-apply."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"font-mono text-xs",children:["git revert ",s.gitSha," && lobu apply"]}),e.jsx(p,{value:`git revert ${s.gitSha} && lobu apply`,label:"rollback command"})]})]}):null,e.jsxs("section",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-medium",children:["Changes",e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:a.length})]}),a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No config changes in this apply run."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:a.map((r,l)=>e.jsx(u,{change:r,isLast:l===a.length-1},r.id))})]})]})}function E({change:t}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("h2",{className:"text-lg font-semibold",children:[t.resourceKind??"config",t.resourceId?e.jsxs("span",{className:"text-muted-foreground",children:[" ",t.resourceId]}):null]}),x(t.op)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[m(t.createdAt)," (",o(t.createdAt),")",t.actorSource?` · via ${t.actorSource}`:"",t.createdBy?` · by ${t.createdBy}`:""]})]}),e.jsx("section",{className:"overflow-hidden rounded-lg border",children:e.jsx(u,{change:t,isLast:!0})})]})}function u({change:t,isLast:s}){return e.jsxs("div",{className:`px-3 py-2.5 ${s?"":"border-b"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[t.resourceKind??"config",t.resourceId?e.jsxs("span",{className:"text-muted-foreground",children:[" ",t.resourceId]}):null]}),x(t.op),e.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:o(t.createdAt)})]}),t.changedFields&&t.changedFields.length>0?e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Changed: ",t.changedFields.join(", ")]}):null,e.jsx(I,{before:t.before,after:t.after})]})}function n({label:t,value:s,copyValue:a,copyable:r}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e.jsxs("dd",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("span",{className:"truncate font-mono",children:s}),r?e.jsx(p,{value:a??s,label:t}):null]})]})}function p({value:t,label:s}){return e.jsx("button",{type:"button","aria-label":`Copy ${s}`,className:"shrink-0 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>{navigator.clipboard.writeText(t),S.success("Copied to clipboard")},children:e.jsx(w,{className:"h-3 w-3"})})}function X(){const{owner:t,deploymentId:s}=A.useParams();return e.jsx(L,{owner:t,deploymentId:s})}export{X as component};
@@ -1 +0,0 @@
1
- import{ij as a,j as e}from"./index-B2AmRqYh.js";import{b as i}from"./agent-guardrails-route-Dp02G1AQ.js";import"./model-selector-CapL1ARf.js";import"./agent-subpage-shell-Dz8I-GUt.js";import"./agent-loading-shells-OagauQzV.js";import"./agent-card-controls-B3RhzsPz.js";import"./switch-BQ40_DMb.js";function l(){const{owner:t,agentId:r,name:o}=a.useParams();return e.jsx(i,{owner:t,agentId:r,name:o})}export{l as component};