@lobu/runtime-server 24.0.0 → 24.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/connectors/x-dm-adapter.js +65 -30
  3. package/dist/db/migrations/20261021010000_views_compile_config_hash.sql +16 -0
  4. package/dist/dependencies.bun.lock +1 -1
  5. package/dist/owletto/dist/assets/{_-CC8cTmRg.js → _-BorucF19.js} +3 -3
  6. package/dist/owletto/dist/assets/_-CkGyNi0G.js +2 -0
  7. package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +2 -0
  8. package/dist/owletto/dist/assets/{_agentId-DWUFSrVp.js → _agentId-DgRrCE2B.js} +2 -2
  9. package/dist/owletto/dist/assets/{_automationId-BnHqdXOC.js → _automationId-DSrZIYcs.js} +2 -2
  10. package/dist/owletto/dist/assets/{_connectorKey._connectionId-CefXIqy2.js → _connectorKey._connectionId-DWxv1uoi.js} +2 -2
  11. package/dist/owletto/dist/assets/{_connectorKey.index-C1QPGf9E.js → _connectorKey.index-BTP5ijdT.js} +2 -2
  12. package/dist/owletto/dist/assets/{_conversationId-DinuPCUp.js → _conversationId-98Y3RuRO.js} +2 -2
  13. package/dist/owletto/dist/assets/{_deploymentId-BeyzVjRm.js → _deploymentId-B1UWPY0i.js} +2 -2
  14. package/dist/owletto/dist/assets/{_eventId-3L_qeL_l.js → _eventId-BAnr8g8z.js} +2 -2
  15. package/dist/owletto/dist/assets/_name-BUfFO_A0.js +2 -0
  16. package/dist/owletto/dist/assets/{_owner-DbrKma4e.js → _owner-C79BwQ0I.js} +3 -3
  17. package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +2 -0
  18. package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +2 -0
  19. package/dist/owletto/dist/assets/{_slug-ndDr_CUg.js → _slug-DbPdDc-5.js} +2 -2
  20. package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +2 -0
  21. package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +2 -0
  22. package/dist/owletto/dist/assets/{accept-invitation-CRKbM2Xy.js → accept-invitation-UXU5Fx2G.js} +2 -2
  23. package/dist/owletto/dist/assets/{activity-route-view-CFLNukhD.js → activity-route-view-D7ORHntE.js} +2 -2
  24. package/dist/owletto/dist/assets/{agent-card-controls-Be1Okb2C.js → agent-card-controls-CplnPhbv.js} +2 -2
  25. package/dist/owletto/dist/assets/{agent-client-setup-list-BA8dU_C6.js → agent-client-setup-list-BlXB4SE5.js} +2 -2
  26. package/dist/owletto/dist/assets/{agent-connect-pages-CAV-yXus.js → agent-connect-pages-BmknviTI.js} +2 -2
  27. package/dist/owletto/dist/assets/{agent-editor-form-Bi6WvYX-.js → agent-editor-form-DsSoeQeF.js} +2 -2
  28. package/dist/owletto/dist/assets/{agent-guardrails-route-DMOjG1D4.js → agent-guardrails-route-TdvvIc_J.js} +2 -2
  29. package/dist/owletto/dist/assets/{agent-loading-shells-De_2d8Lr.js → agent-loading-shells-B7v6Cffw.js} +2 -2
  30. package/dist/owletto/dist/assets/{agent-permissions-matrix-gZWl6mAe.js → agent-permissions-matrix-BkZu1LYE.js} +2 -2
  31. package/dist/owletto/dist/assets/{agent-skill-context-JLaTamGR.js → agent-skill-context-DFucg4c4.js} +2 -2
  32. package/dist/owletto/dist/assets/{agent-skills-route-DcK41PWj.js → agent-skills-route-B3vvvZZe.js} +2 -2
  33. package/dist/owletto/dist/assets/{agent-subpage-shell-BBJoyTuC.js → agent-subpage-shell-CZJvnjNC.js} +2 -2
  34. package/dist/owletto/dist/assets/agent-thread-D38STyeu.js +6 -0
  35. package/dist/owletto/dist/assets/agents-DAOln24A.js +2 -0
  36. package/dist/owletto/dist/assets/{agents-workbench-CqaKGggb.js → agents-workbench-DJ67GZ93.js} +2 -2
  37. package/dist/owletto/dist/assets/{app._appId-Cl1fTuIt.js → app._appId-Cp78oEZ9.js} +2 -2
  38. package/dist/owletto/dist/assets/{automation-detail-content-BMLL4lxO.js → automation-detail-content-DSwbRpbx.js} +2 -2
  39. package/dist/owletto/dist/assets/automations-DAOln24A.js +2 -0
  40. package/dist/owletto/dist/assets/{callback-DTKKsfkz.js → callback-CBexCo3F.js} +2 -2
  41. package/dist/owletto/dist/assets/{card-yU0TmNRH.js → card-jzhQrMDP.js} +2 -2
  42. package/dist/owletto/dist/assets/{claim-DJfTvlT2.js → claim-B-wq745Q.js} +2 -2
  43. package/dist/owletto/dist/assets/{client-rows--FrZfJol.js → client-rows-BYbsXGy9.js} +2 -2
  44. package/dist/owletto/dist/assets/{clients-L4K1UT8c.js → clients-BhNl1tVq.js} +2 -2
  45. package/dist/owletto/dist/assets/{code-editor-U54Gwjit.js → code-editor-CEqoCky-.js} +2 -2
  46. package/dist/owletto/dist/assets/connect-wx-qqLir.js +2 -0
  47. package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +2 -0
  48. package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +2 -0
  49. package/dist/owletto/dist/assets/{connected._clientId.activity-DTpSW1Xy.js → connected._clientId.activity-BqprYeOX.js} +2 -2
  50. package/dist/owletto/dist/assets/{connected._clientId.index-h9X5H1x8.js → connected._clientId.index-DhRoSzBr.js} +2 -2
  51. package/dist/owletto/dist/assets/{connection-ByvKkyFm.js → connection-CNm2ukrI.js} +2 -2
  52. package/dist/owletto/dist/assets/{connection-feed-detail-DWM9lTao.js → connection-feed-detail-WcGCA6qY.js} +2 -2
  53. package/dist/owletto/dist/assets/{connections-browser-CEwYrYqt.js → connections-browser-CrtnAs0Q.js} +2 -2
  54. package/dist/owletto/dist/assets/{connector-provenance-BocTm__v.js → connector-provenance-D-ECOlMJ.js} +2 -2
  55. package/dist/owletto/dist/assets/{connector-scope-lists-OYDOydtz.js → connector-scope-lists-CRFEpSvk.js} +2 -2
  56. package/dist/owletto/dist/assets/{connectors-CyZpcE5f.js → connectors-CH4KBZyT.js} +2 -2
  57. package/dist/owletto/dist/assets/{consent-DdfINrVp.js → consent-C9ZpHb7V.js} +2 -2
  58. package/dist/owletto/dist/assets/{conversations-table-BSznfdYt.js → conversations-table-D_HOe1jN.js} +2 -2
  59. package/dist/owletto/dist/assets/{core.esm-Dr7tcIB-.js → core.esm-BupT3V0i.js} +2 -2
  60. package/dist/owletto/dist/assets/create-C4lptGWj.js +2 -0
  61. package/dist/owletto/dist/assets/{create-CBGwASon.js → create-CCjZxIkK.js} +2 -2
  62. package/dist/owletto/dist/assets/create-DkgUQAbB.js +2 -0
  63. package/dist/owletto/dist/assets/{create-automation-form-9T5WnoUs.js → create-automation-form-Bpy92SM5.js} +2 -2
  64. package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +2 -0
  65. package/dist/owletto/dist/assets/{cronstrue-BWFEyy_P.js → cronstrue-CWImw-kf.js} +2 -2
  66. package/dist/owletto/dist/assets/{deployments-wG_8QzOF.js → deployments-C5hvipQh.js} +2 -2
  67. package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +2 -0
  68. package/dist/owletto/dist/assets/{deployments-body-2xKS8gRo.js → deployments-body-DGII20dQ.js} +2 -2
  69. package/dist/owletto/dist/assets/{device-6z-xgsoW.js → device-D-7WBe9E.js} +2 -2
  70. package/dist/owletto/dist/assets/{device-pin-tombstone-Cwq88RMU.js → device-pin-tombstone-2U0UMu3_.js} +2 -2
  71. package/dist/owletto/dist/assets/{device._deviceId-BDerBfD9.js → device._deviceId-Bn37UpWH.js} +2 -2
  72. package/dist/owletto/dist/assets/{entity-avatar-Cc1CuI-0.js → entity-avatar-mdh7Kq5D.js} +2 -2
  73. package/dist/owletto/dist/assets/{entity-options-DHdMC1Lx.js → entity-options-Clz_WXK-.js} +2 -2
  74. package/dist/owletto/dist/assets/{entity-page--OkXmlNP.js → entity-page-D3e4iPle.js} +2 -2
  75. package/dist/owletto/dist/assets/{entity-type-page-89RoK_-P.js → entity-type-page-DebN1vCM.js} +2 -2
  76. package/dist/owletto/dist/assets/{event-detail-D4YZRtrA.js → event-detail-DV_zfWnC.js} +2 -2
  77. package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +2 -0
  78. package/dist/owletto/dist/assets/{filter-editors-B1_QUpg_.js → filter-editors-Bwhqj7lY.js} +2 -2
  79. package/dist/owletto/dist/assets/{full-page-spinner-Cqih-8IW.js → full-page-spinner-BVbcpW3R.js} +2 -2
  80. package/dist/owletto/dist/assets/guardrails-BiJollCA.js +2 -0
  81. package/dist/owletto/dist/assets/identity-HCFWtdaI.js +2 -0
  82. package/dist/owletto/dist/assets/index-8wxsyxqt.js +2 -0
  83. package/dist/owletto/dist/assets/{index-DYCqXaMf.js → index-9YuSRymd.js} +4 -4
  84. package/dist/owletto/dist/assets/index-B3c-0eZG.js +2 -0
  85. package/dist/owletto/dist/assets/{index-TgRS2v_F.js → index-B64PGxQm.js} +2 -2
  86. package/dist/owletto/dist/assets/{index-DfyDUpuI.js → index-BTlx9K_t.js} +2 -2
  87. package/dist/owletto/dist/assets/index-BX0EA_oB.js +2 -0
  88. package/dist/owletto/dist/assets/index-CdJJaQDX.js +2 -0
  89. package/dist/owletto/dist/assets/index-CfT_W8Vo.js +2 -0
  90. package/dist/owletto/dist/assets/{index-DYzWV5_z.js → index-CxF2XXzl.js} +2 -2
  91. package/dist/owletto/dist/assets/index-D3WHeGql.js +2 -0
  92. package/dist/owletto/dist/assets/{index-ZNlrDc_f.js → index-D7gHOpfg.js} +2 -2
  93. package/dist/owletto/dist/assets/{index-DKPwCasf.js → index-DB1iWI_a.js} +2 -2
  94. package/dist/owletto/dist/assets/index-DMNzF8Lf.js +2 -0
  95. package/dist/owletto/dist/assets/index-DyB3IzOA.js +2 -0
  96. package/dist/owletto/dist/assets/{index-DAOyXG1X.js → index-fgAJydgX.js} +2 -2
  97. package/dist/owletto/dist/assets/{json-diff-DFvYINBT.js → json-diff-DIN5Jhfx.js} +2 -2
  98. package/dist/owletto/dist/assets/{list-skeleton-DFsEqLU1.js → list-skeleton-CepswBka.js} +2 -2
  99. package/dist/owletto/dist/assets/{login-DO0j-AYr.js → login-DxGYyE4n.js} +2 -2
  100. package/dist/owletto/dist/assets/{logout-BmNwoAf7.js → logout-Bkzc7J44.js} +2 -2
  101. package/dist/owletto/dist/assets/{member-scope-gate-B2LrMWBU.js → member-scope-gate-DD4YBFn-.js} +2 -2
  102. package/dist/owletto/dist/assets/{memory-browse-page-Cjpl8EbB.js → memory-browse-page-D_UlBa27.js} +2 -2
  103. package/dist/owletto/dist/assets/{model-selector-TQcA93xm.js → model-selector-CDrAjH31.js} +2 -2
  104. package/dist/owletto/dist/assets/models-BAVeysNq.js +2 -0
  105. package/dist/owletto/dist/assets/{new-BMrFy5Qa.js → new-C2av0diq.js} +2 -2
  106. package/dist/owletto/dist/assets/{new-ByBhteWA.js → new-ktz9Cs_P.js} +2 -2
  107. package/dist/owletto/dist/assets/{new-DWp3deoW.js → new-snm1ctHn.js} +2 -2
  108. package/dist/owletto/dist/assets/{oauth-workspace-access-D_5uESuz.js → oauth-workspace-access-lZNZ9gul.js} +2 -2
  109. package/dist/owletto/dist/assets/{organization-DTFoYP4V.js → organization-Cb0W823y.js} +2 -2
  110. package/dist/owletto/dist/assets/{peek-pane-content-DF5iGC3c.js → peek-pane-content-BNR9ImQY.js} +2 -2
  111. package/dist/owletto/dist/assets/{permissions-C_auqxfP.js → permissions-Dv39zWKt.js} +2 -2
  112. package/dist/owletto/dist/assets/{proposal-review-shell-DsNiavG_.js → proposal-review-shell-CFhOqCLf.js} +2 -2
  113. package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +2 -0
  114. package/dist/owletto/dist/assets/{recent-3d99S2IE.js → recent-QhnLDU1_.js} +2 -2
  115. package/dist/owletto/dist/assets/{record-activity-C9KfBkXb.js → record-activity-ZJntBfN_.js} +2 -2
  116. package/dist/owletto/dist/assets/{record-field-peek-BBZcRuGT.js → record-field-peek-Brh1IQGy.js} +2 -2
  117. package/dist/owletto/dist/assets/{record-session-BizRugWs.js → record-session-Pbr5czGw.js} +2 -2
  118. package/dist/owletto/dist/assets/{reset-password-DqfcSn8M.js → reset-password-CzZw6RcC.js} +2 -2
  119. package/dist/owletto/dist/assets/{runs-panel-T1ZxTVz6.js → runs-panel-C0_DNTcq.js} +2 -2
  120. package/dist/owletto/dist/assets/{runs-table-D_8QlCCN.js → runs-table-B1APZv7d.js} +2 -2
  121. package/dist/owletto/dist/assets/{schema-value-normalization-CylKX3PK.js → schema-value-normalization-CKdPjdPC.js} +2 -2
  122. package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +2 -0
  123. package/dist/owletto/dist/assets/{settings-B_ClYztB.js → settings-VDNiffKU.js} +2 -2
  124. package/dist/owletto/dist/assets/skills-DgDGscm5.js +2 -0
  125. package/dist/owletto/dist/assets/{source-record-panels-Cg249m1S.js → source-record-panels-BdfOVPWn.js} +2 -2
  126. package/dist/owletto/dist/assets/{use-mention-search-BYbFvHbJ.js → use-mention-search-Dcunv4L0.js} +2 -2
  127. package/dist/owletto/dist/assets/{view-param-filters-DMSqkN2J.js → view-param-filters-B0quibBi.js} +2 -2
  128. package/dist/owletto/dist/index.html +1 -1
  129. package/dist/server-main.bundle.mjs +455 -201
  130. package/npm-shrinkwrap.json +8 -8
  131. package/package.json +1 -1
  132. package/vendor/connector-sdk/package.json +1 -1
  133. package/vendor/core/dist/contracts/tools/view-runtime.d.ts +74 -0
  134. package/vendor/core/dist/contracts/tools/view-runtime.js +86 -0
  135. package/vendor/core/package.json +6 -1
  136. package/vendor/views/package.json +1 -1
  137. package/dist/owletto/dist/assets/_-ksFp4zVf.js +0 -2
  138. package/dist/owletto/dist/assets/_agentId-MENLoohA.js +0 -2
  139. package/dist/owletto/dist/assets/_name-Dgedji78.js +0 -2
  140. package/dist/owletto/dist/assets/_shape-DtVfRFz_.js +0 -2
  141. package/dist/owletto/dist/assets/_skillKey-CqLHzm7L.js +0 -2
  142. package/dist/owletto/dist/assets/_viewKey-3CH5w8mr.js +0 -2
  143. package/dist/owletto/dist/assets/_viewKey-DHQY9A8u.js +0 -2
  144. package/dist/owletto/dist/assets/agent-thread-Buz3naVF.js +0 -6
  145. package/dist/owletto/dist/assets/agents-C-ReckCa.js +0 -2
  146. package/dist/owletto/dist/assets/automations-C-ReckCa.js +0 -2
  147. package/dist/owletto/dist/assets/connect-4zqtnDHb.js +0 -2
  148. package/dist/owletto/dist/assets/connect._clientId-Dj0SqgbE.js +0 -2
  149. package/dist/owletto/dist/assets/connected._clientId-sgtocSvf.js +0 -2
  150. package/dist/owletto/dist/assets/create-Cf5hp6Z8.js +0 -2
  151. package/dist/owletto/dist/assets/create-CwThQtd3.js +0 -2
  152. package/dist/owletto/dist/assets/create._connectorKey-sNHQHNpg.js +0 -2
  153. package/dist/owletto/dist/assets/deployments-DHh9dyzv.js +0 -2
  154. package/dist/owletto/dist/assets/events-feed-DsrkV2ix.js +0 -2
  155. package/dist/owletto/dist/assets/guardrails-B8Rs1be3.js +0 -2
  156. package/dist/owletto/dist/assets/identity-B0nH4yiC.js +0 -2
  157. package/dist/owletto/dist/assets/index-4TSkcsth.js +0 -2
  158. package/dist/owletto/dist/assets/index-BgkhXElB.js +0 -2
  159. package/dist/owletto/dist/assets/index-CoW4Bz3w.js +0 -2
  160. package/dist/owletto/dist/assets/index-Codw-Qqi.js +0 -2
  161. package/dist/owletto/dist/assets/index-DMyXd3bJ.js +0 -2
  162. package/dist/owletto/dist/assets/index-DYYZLcJ0.js +0 -2
  163. package/dist/owletto/dist/assets/index-Da6CrGEu.js +0 -2
  164. package/dist/owletto/dist/assets/index-DneshLbf.js +0 -2
  165. package/dist/owletto/dist/assets/models-D7aED5Sa.js +0 -2
  166. package/dist/owletto/dist/assets/public-shell-ready-B2NUI89V.js +0 -2
  167. package/dist/owletto/dist/assets/settings-DgX1-xo7.js +0 -2
  168. package/dist/owletto/dist/assets/skills-Drw5tcZw.js +0 -2
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@lobu/runtime-server",
3
- "version": "24.0.0",
3
+ "version": "24.1.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@lobu/runtime-server",
9
- "version": "24.0.0",
9
+ "version": "24.1.1",
10
10
  "license": "BUSL-1.1",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "1.4.0",
@@ -10913,9 +10913,9 @@
10913
10913
  }
10914
10914
  },
10915
10915
  "node_modules/vite": {
10916
- "version": "6.4.4",
10917
- "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.4.tgz",
10918
- "integrity": "sha512-xGjU/SyjeNyb0E4KxXBvYz/1C+3JXuujvf2hXNOtnlcE+58o5ajd9N2/n2VhkiJvpCP2qQasnUpx5PXNeI+p1Q==",
10916
+ "version": "6.4.5",
10917
+ "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.5.tgz",
10918
+ "integrity": "sha512-4enwjFfi4IwtEh0w+jPzpLVOFQiPHmmzPxcHXQOyEur47o6u0jE573DmGpjA+7irXoMLYRZD5ZaFUEneS3abPg==",
10919
10919
  "license": "MIT",
10920
10920
  "dependencies": {
10921
10921
  "esbuild": "^0.25.0",
@@ -11795,7 +11795,7 @@
11795
11795
  },
11796
11796
  "vendor/connector-sdk": {
11797
11797
  "name": "@lobu/connector-sdk",
11798
- "version": "24.0.0",
11798
+ "version": "24.1.1",
11799
11799
  "license": "BUSL-1.1",
11800
11800
  "dependencies": {
11801
11801
  "@lobu/core": "file:../core",
@@ -11810,7 +11810,7 @@
11810
11810
  },
11811
11811
  "vendor/core": {
11812
11812
  "name": "@lobu/core",
11813
- "version": "24.0.0",
11813
+ "version": "24.1.1",
11814
11814
  "license": "Apache-2.0",
11815
11815
  "dependencies": {
11816
11816
  "@opentelemetry/api": "^1.9.0",
@@ -11839,7 +11839,7 @@
11839
11839
  },
11840
11840
  "vendor/views": {
11841
11841
  "name": "@lobu/views",
11842
- "version": "24.0.0",
11842
+ "version": "24.1.1",
11843
11843
  "license": "Apache-2.0",
11844
11844
  "dependencies": {
11845
11845
  "@lobu/core": "file:../core"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/runtime-server",
3
- "version": "24.0.0",
3
+ "version": "24.1.1",
4
4
  "type": "module",
5
5
  "license": "BUSL-1.1",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-sdk",
3
- "version": "24.0.0",
3
+ "version": "24.1.1",
4
4
  "description": "Lobu memory SDK — build pluggable connectors for Lobu memory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The view runtime contract: React, React DOM and `@lobu/views` are supplied
3
+ * by the view shell, never bundled into a view. The server builds them once
4
+ * from its own installation and inlines that script ahead of every view
5
+ * bundle as `globalThis[VIEW_RUNTIME_GLOBAL]`; each view bundle reads its
6
+ * runtime imports off that global. A runtime fix reaches views using this
7
+ * contract on the next deploy, without re-saving them. A self-contained
8
+ * bundle from before the contract keeps running on its own runtime until it
9
+ * is saved again; one the server built is rebuilt when served.
10
+ *
11
+ * Every view compiler builds through these pieces — the server on save and on
12
+ * a served rebuild, and `lobu apply` in the author's checkout — so the same
13
+ * retained source compiles to the same bundle wherever it is built.
14
+ */
15
+ /** Global the shell's runtime script assigns and every view bundle reads. */
16
+ export declare const VIEW_RUNTIME_GLOBAL = "__lobuViews";
17
+ /** Module specifiers a view imports from the shell runtime. */
18
+ export declare const VIEW_RUNTIME_MODULES: readonly string[];
19
+ /** Packages behind {@link VIEW_RUNTIME_MODULES}. A view whose retained
20
+ * dependencies are all among these needs nothing but its own source files
21
+ * to compile, so the server can build it. */
22
+ export declare const VIEW_RUNTIME_PACKAGES: readonly string[];
23
+ /** Entry source that mounts the module at `specifier` through the runtime's
24
+ * `mountView`: its `view` declaration and default-export component. */
25
+ export declare function viewMountEntry(specifier: string): string;
26
+ /** Entry source for the shell runtime script: every runtime module, keyed by
27
+ * specifier on the runtime global. */
28
+ export declare function viewRuntimeEntry(): string;
29
+ /** esbuild options every view bundle and the runtime script share. */
30
+ export declare const VIEW_BUILD_OPTIONS: {
31
+ readonly bundle: true;
32
+ readonly write: false;
33
+ readonly format: "iife";
34
+ readonly platform: "browser";
35
+ readonly target: "es2022";
36
+ readonly jsx: "automatic";
37
+ readonly minify: true;
38
+ readonly sourcemap: false;
39
+ readonly legalComments: "none";
40
+ readonly define: {
41
+ readonly "process.env.NODE_ENV": "\"production\"";
42
+ };
43
+ readonly logLevel: "silent";
44
+ };
45
+ interface RuntimePluginBuild {
46
+ onResolve(options: {
47
+ filter: RegExp;
48
+ }, callback: (args: {
49
+ path: string;
50
+ }) => {
51
+ path: string;
52
+ namespace: string;
53
+ } | undefined): void;
54
+ onLoad(options: {
55
+ filter: RegExp;
56
+ namespace: string;
57
+ }, callback: (args: {
58
+ path: string;
59
+ }) => {
60
+ contents: string;
61
+ loader: "js";
62
+ }): void;
63
+ }
64
+ /**
65
+ * esbuild plugin resolving each runtime module to a shim that reads it off
66
+ * the runtime global, so the bundle carries none of the runtime. Structurally
67
+ * typed: core does not depend on esbuild.
68
+ */
69
+ export declare function viewRuntimePlugin(): {
70
+ name: string;
71
+ setup(build: RuntimePluginBuild): void;
72
+ };
73
+ export {};
74
+ //# sourceMappingURL=view-runtime.d.ts.map
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * The view runtime contract: React, React DOM and `@lobu/views` are supplied
4
+ * by the view shell, never bundled into a view. The server builds them once
5
+ * from its own installation and inlines that script ahead of every view
6
+ * bundle as `globalThis[VIEW_RUNTIME_GLOBAL]`; each view bundle reads its
7
+ * runtime imports off that global. A runtime fix reaches views using this
8
+ * contract on the next deploy, without re-saving them. A self-contained
9
+ * bundle from before the contract keeps running on its own runtime until it
10
+ * is saved again; one the server built is rebuilt when served.
11
+ *
12
+ * Every view compiler builds through these pieces — the server on save and on
13
+ * a served rebuild, and `lobu apply` in the author's checkout — so the same
14
+ * retained source compiles to the same bundle wherever it is built.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.VIEW_BUILD_OPTIONS = exports.VIEW_RUNTIME_PACKAGES = exports.VIEW_RUNTIME_MODULES = exports.VIEW_RUNTIME_GLOBAL = void 0;
18
+ exports.viewMountEntry = viewMountEntry;
19
+ exports.viewRuntimeEntry = viewRuntimeEntry;
20
+ exports.viewRuntimePlugin = viewRuntimePlugin;
21
+ /** Global the shell's runtime script assigns and every view bundle reads. */
22
+ exports.VIEW_RUNTIME_GLOBAL = "__lobuViews";
23
+ /** Module specifiers a view imports from the shell runtime. */
24
+ exports.VIEW_RUNTIME_MODULES = [
25
+ "react",
26
+ "react/jsx-runtime",
27
+ "react-dom",
28
+ "react-dom/client",
29
+ "@lobu/views",
30
+ "@lobu/views/components",
31
+ ];
32
+ /** Packages behind {@link VIEW_RUNTIME_MODULES}. A view whose retained
33
+ * dependencies are all among these needs nothing but its own source files
34
+ * to compile, so the server can build it. */
35
+ exports.VIEW_RUNTIME_PACKAGES = [
36
+ "react",
37
+ "react-dom",
38
+ "@lobu/views",
39
+ ];
40
+ const RUNTIME_NAMESPACE = "lobu-view-runtime";
41
+ /** Entry source that mounts the module at `specifier` through the runtime's
42
+ * `mountView`: its `view` declaration and default-export component. */
43
+ function viewMountEntry(specifier) {
44
+ return `import { mountView } from "@lobu/views";\nimport * as mod from ${JSON.stringify(specifier)};\nmountView(mod.view, mod.default);\n`;
45
+ }
46
+ /** Entry source for the shell runtime script: every runtime module, keyed by
47
+ * specifier on the runtime global. */
48
+ function viewRuntimeEntry() {
49
+ const imports = exports.VIEW_RUNTIME_MODULES.map((specifier, i) => `import * as m${i} from ${JSON.stringify(specifier)};`);
50
+ const entries = exports.VIEW_RUNTIME_MODULES.map((specifier, i) => `${JSON.stringify(specifier)}: m${i}`);
51
+ return `${imports.join("\n")}\nglobalThis[${JSON.stringify(exports.VIEW_RUNTIME_GLOBAL)}] = Object.freeze({ ${entries.join(", ")} });\n`;
52
+ }
53
+ /** esbuild options every view bundle and the runtime script share. */
54
+ exports.VIEW_BUILD_OPTIONS = {
55
+ bundle: true,
56
+ write: false,
57
+ format: "iife",
58
+ platform: "browser",
59
+ target: "es2022",
60
+ jsx: "automatic",
61
+ minify: true,
62
+ sourcemap: false,
63
+ legalComments: "none",
64
+ define: { "process.env.NODE_ENV": '"production"' },
65
+ logLevel: "silent",
66
+ };
67
+ /**
68
+ * esbuild plugin resolving each runtime module to a shim that reads it off
69
+ * the runtime global, so the bundle carries none of the runtime. Structurally
70
+ * typed: core does not depend on esbuild.
71
+ */
72
+ function viewRuntimePlugin() {
73
+ return {
74
+ name: "lobu-view-runtime",
75
+ setup(build) {
76
+ build.onResolve({ filter: /.*/ }, (args) => exports.VIEW_RUNTIME_MODULES.includes(args.path)
77
+ ? { path: args.path, namespace: RUNTIME_NAMESPACE }
78
+ : undefined);
79
+ build.onLoad({ filter: /.*/, namespace: RUNTIME_NAMESPACE }, (args) => ({
80
+ contents: `module.exports = globalThis[${JSON.stringify(exports.VIEW_RUNTIME_GLOBAL)}][${JSON.stringify(args.path)}];`,
81
+ loader: "js",
82
+ }));
83
+ },
84
+ };
85
+ }
86
+ //# sourceMappingURL=view-runtime.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/core",
3
- "version": "24.0.0",
3
+ "version": "24.1.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Core types and utilities for Lobu agent platform",
6
6
  "repository": {
@@ -226,6 +226,11 @@
226
226
  "import": "./dist/contracts/tools/view-definition.js",
227
227
  "require": "./dist/contracts/tools/view-definition.js"
228
228
  },
229
+ "./contracts/tools/view-runtime": {
230
+ "types": "./dist/contracts/tools/view-runtime.d.ts",
231
+ "import": "./dist/contracts/tools/view-runtime.js",
232
+ "require": "./dist/contracts/tools/view-runtime.js"
233
+ },
229
234
  "./contracts/tools/view-path": {
230
235
  "types": "./dist/contracts/tools/view-path.d.ts",
231
236
  "import": "./dist/contracts/tools/view-path.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/views",
3
- "version": "24.0.0",
3
+ "version": "24.1.1",
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",
@@ -1,2 +0,0 @@
1
- import{c3 as t,j as p,c4 as m}from"./index-DYCqXaMf.js";import{A as e}from"./activity-route-view-CFLNukhD.js";import"./record-activity-C9KfBkXb.js";import"./filter-editors-B1_QUpg_.js";import"./connection-label-BobuYiAG.js";import"./source-record-panels-Cg249m1S.js";import"./events-feed-DsrkV2ix.js";import"./conversations-table-BSznfdYt.js";import"./clients-L4K1UT8c.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./client-rows--FrZfJol.js";import"./agent-loading-shells-De_2d8Lr.js";import"./member-scope-gate-B2LrMWBU.js";import"./public-shell-ready-B2NUI89V.js";function w(){const{owner:o,_splat:r}=t.useParams(),i=t.useSearch();return p.jsx(e,{owner:o,search:i,entityScope:m(r||"").path})}export{w as component};
2
- //# sourceMappingURL=_-ksFp4zVf.js.map
@@ -1,2 +0,0 @@
1
- import{hd as r,j as e}from"./index-DYCqXaMf.js";import{A as n}from"./agents-workbench-CqaKGggb.js";import"./agent-editor-form-Bi6WvYX-.js";import"./model-selector-TQcA93xm.js";import"./proposal-review-shell-DsNiavG_.js";function i(){const{owner:o,agentId:t}=r.useParams();return e.jsx(n,{owner:o,agentId:t})}export{i as component};
2
- //# sourceMappingURL=_agentId-MENLoohA.js.map
@@ -1,2 +0,0 @@
1
- import{i$ as a,j as e}from"./index-DYCqXaMf.js";import{b as i}from"./agent-guardrails-route-DMOjG1D4.js";import"./model-selector-TQcA93xm.js";import"./agent-subpage-shell-BBJoyTuC.js";import"./agent-loading-shells-De_2d8Lr.js";import"./agent-card-controls-Be1Okb2C.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};
2
- //# sourceMappingURL=_name-Dgedji78.js.map
@@ -1,2 +0,0 @@
1
- import{iP as p,j as e,bn as m}from"./index-DYCqXaMf.js";import{M as i}from"./memory-browse-page-Cjpl8EbB.js";import"./public-shell-ready-B2NUI89V.js";import"./entity-type-page-89RoK_-P.js";import"./json-diff-DFvYINBT.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./code-editor-U54Gwjit.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./entity-avatar-Cc1CuI-0.js";import"./filter-editors-B1_QUpg_.js";import"./core.esm-Dr7tcIB-.js";import"./view-param-filters-DMSqkN2J.js";import"./app-bridge-BCm4muqj.js";import"./member-scope-gate-B2LrMWBU.js";function h(){const{owner:t,entityType:o,shape:r}=p.useParams();return e.jsx(i,{ownerSlug:t,typeScope:m(o),create:!1,shape:r})}export{h as component};
2
- //# sourceMappingURL=_shape-DtVfRFz_.js.map
@@ -1,2 +0,0 @@
1
- import{iZ as r,j as e}from"./index-DYCqXaMf.js";import{b as m}from"./agent-skills-route-DcK41PWj.js";import"./agent-subpage-shell-BBJoyTuC.js";import"./agent-skill-context-JLaTamGR.js";import"./core.esm-Dr7tcIB-.js";import"./skill-editor-D_W3QlRz.js";import"./agent-loading-shells-De_2d8Lr.js";import"./agent-card-controls-Be1Okb2C.js";function c(){const{owner:t,agentId:o,skillKey:i}=r.useParams();return e.jsx(m,{owner:t,agentId:o,skillKey:i})}export{c as component};
2
- //# sourceMappingURL=_skillKey-CqLHzm7L.js.map
@@ -1,2 +0,0 @@
1
- import{j2 as e,j as p,bn as i}from"./index-DYCqXaMf.js";import{M as m}from"./memory-browse-page-Cjpl8EbB.js";import"./public-shell-ready-B2NUI89V.js";import"./entity-type-page-89RoK_-P.js";import"./json-diff-DFvYINBT.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./code-editor-U54Gwjit.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./entity-avatar-Cc1CuI-0.js";import"./filter-editors-B1_QUpg_.js";import"./core.esm-Dr7tcIB-.js";import"./view-param-filters-DMSqkN2J.js";import"./app-bridge-BCm4muqj.js";import"./member-scope-gate-B2LrMWBU.js";function M(){const{owner:t,entityType:o,viewKey:r}=e.useParams();return p.jsx(m,{ownerSlug:t,typeScope:i(o),create:!1,viewKey:r})}export{M as component};
2
- //# sourceMappingURL=_viewKey-3CH5w8mr.js.map
@@ -1,2 +0,0 @@
1
- import{iW as t,j as m}from"./index-DYCqXaMf.js";import{M as i}from"./memory-browse-page-Cjpl8EbB.js";import"./public-shell-ready-B2NUI89V.js";import"./entity-type-page-89RoK_-P.js";import"./json-diff-DFvYINBT.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./code-editor-U54Gwjit.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./entity-avatar-Cc1CuI-0.js";import"./filter-editors-B1_QUpg_.js";import"./core.esm-Dr7tcIB-.js";import"./view-param-filters-DMSqkN2J.js";import"./app-bridge-BCm4muqj.js";import"./member-scope-gate-B2LrMWBU.js";function R(){const{owner:o,viewKey:r}=t.useParams();return m.jsx(i,{ownerSlug:o,create:!1,viewKey:r})}export{R as component};
2
- //# sourceMappingURL=_viewKey-DHQY9A8u.js.map
@@ -1,6 +0,0 @@
1
- import{j as s,r as a,aE as Ft,$ as Vt,gi as Bt,gj as Ht,W as Ze,J as Ve,Y as et,bX as zt,gk as tt,gl as Wt,gm as Kt,L as pt,Q as P,fw as qt,ef as mt,eg as Gt,gn as Xt,d$ as Yt,eh as Jt,go as Qt,ai as Zt,B as pe,et as en,gp as tn,gq as Be,X as nn,a2 as rn,cX as on,af as Ne,gr as sn,gs as ln,dr as an,dt as cn,gt as un,ds as dn,bc as fn,gu as pn,gv as mn,dX as hn,b8 as gn,gw as bn,gx as xn}from"./index-DYCqXaMf.js";import{D as vn,E as yn}from"./app-bridge-BCm4muqj.js";import{A as Rn,a as wn,b as Sn,c as qe,d as ht,e as Tn}from"./agent-loading-shells-De_2d8Lr.js";import{h as Cn,t as jn,R as Nn,i as En,u as An,M as kn,a as In}from"./use-mention-search-BYbFvHbJ.js";import{E as _n,c as On}from"./events-feed-DsrkV2ix.js";const gt=a.createContext(null);function Pn({extension:e,children:t}){return s.jsx(gt.Provider,{value:e??null,children:t})}function Ge(){return a.useContext(gt)}var Xe=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Xe||{});const Mn={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function Ln(e){if(typeof e=="string")return Object.values(Xe).includes(e)?e:void 0}const $n=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:Mn,AgentErrorCode:Xe,toAgentErrorCode:Ln},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Dn,toAgentErrorCode:Un}=$n;function nt(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function bt(e,t){const n=Un(e);if(!n)return null;const r=Dn[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const i=t.provider?`/${o}/connectors/${encodeURIComponent(`${Ft}${t.provider}`)}`:`/${o}/connectors`,c=nt(i,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const l=nt(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return l?{label:r.ctaLabel??"Open settings",href:l}:null}function xt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const rt=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Fn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function ot(e,t){const n=Fn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function st(e,t,n){try{const r=new URL(t),o=new URL(e,t),l=rt.has(o.hostname)&&rt.has(r.hostname),i=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&ot(o.hostname,n)&&ot(r.hostname,n);return o.origin!==r.origin&&(l||i)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const Vn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,vt=new Set(["suggest_actions"]),Pe="Thinking…";function Bn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,l=[];n===Pe&&l.push({type:"reasoning"}),r&&l.push({type:"error",text:r});let i=t;return n&&n!==Pe&&(i=t?`${t}
2
-
3
- ${n}`:n),i&&l.push({type:"text",text:i}),l.push(...o),l}const yt=[];function Hn(e,t,n){return e?.length?e:n===0?t:[]}const Ye=a.createContext(null);function Ee(){const e=a.useContext(Ye);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function Po({messages:e,workspaceSlug:t=null,children:n}){const r=a.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:t,currentSuggestions:null,starters:yt}),[e,t]);return s.jsx(Ye.Provider,{value:r,children:n})}const Rt=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function lt(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(Rt,"").replace(/\n{3,}/g,`
4
-
5
- `).trim()}function zn(e){const t=[];for(const n of e.matchAll(Rt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Wn(e,t={}){if(typeof e=="string"){const r=lt(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const l=lt(o.text);l&&n.push({type:"text",text:l})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!vt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function Kn(e){const t=[],n=r=>{for(const{name:o,url:l}of zn(r))t.push({id:`file-${t.length}`,name:o,url:l,isImage:Vn.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const l=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${l};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function qn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Wn(e.content,t),attachments:Kn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Gn=[],Xn=[];function Yn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function Jn(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=bt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const Qn=3e4,Zn=3*Qn,er=15e3;function at(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const ye=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function tr(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:l}=r;if(typeof o!="string"||typeof l!="string")continue;const i=o.trim(),c=l.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function Mo({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:l,children:i,initialDraft:c}){const u=Vt(),d=a.useRef(null),p=a.useRef(null),v=a.useRef(!1),m=a.useRef(o),g=a.useRef(!1),R=a.useRef(null);m.current=o;const{data:A,isLoading:x}=Bt(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),C=A?.messages??Gn,W=A?.interactions??Xn,{data:U}=Ht(e,{enabled:!!e}),G=U?.starters??yt,K=!!(U?.showToolCalls??U?.settings?.showToolCalls),[E,$]=a.useState([]),[Y,ae]=a.useState(!1),[D,X]=a.useState([]),[J,y]=a.useState(null),w=a.useRef(!1);w.current=Y;const j=a.useMemo(()=>C.map(I=>qn(I,{showToolCalls:K})).filter(I=>I!==null),[C,K]),O=a.useRef(!1);a.useEffect(()=>{if(O.current||x||w.current)return;O.current=!0;const I=Jn(W,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});$(I?[...j,I]:j),y(Yn(W))},[e,x,j,W,t]);const k=a.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),Z=a.useCallback(async()=>{if(d.current)return d.current;if(p.current)return p.current;if(!e)throw new Error("No agent selected");const I=(async()=>{const M=await Ze(`${Ve}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!M.ok)throw await et(M);const V=await M.json(),N=zt(),z={sessionId:V.agentId,sseUrl:st(V.sseUrl,Ve,N),messagesUrl:st(V.messagesUrl,Ve,N)};return d.current=z,z})();p.current=I;try{return await I}catch(M){throw d.current=null,M}finally{p.current=null}},[e,t,n]),te=a.useCallback(async(I,M,V)=>{const N=new AbortController;R.current=N;const z=S=>{$(q=>q.map(f=>f.id===V?{...f,parts:S}:f))};let ee;try{ee=await Z()}catch(S){z([{type:"text",text:`Error: ${S instanceof Error?S.message:"Could not start a session."}`}]);return}let B=await tt(ee.sseUrl,{throwOnFailure:!0});const oe=[];let me=null;const ue=()=>{const S=me;me=null,S?.()},he=S=>{oe.push(S),ue()};let ge=!1,be=null;const ke=new Promise(S=>{be=S});let xe=0,ve=Date.now();const de=S=>{ve=Date.now();const q=Number(S.lastEventId);Number.isFinite(q)&&q>xe&&(xe=q)},Ie=["output","status","complete","closed","agent-error","question","link-button","tool-approval","tool_use"],Te=S=>{S.addEventListener("open",()=>{ge=!0,be?.()}),S.addEventListener("connected",f=>{de(f),ge||(ge=!0,be?.())}),S.addEventListener("ping",de);const q=f=>h=>{de(h);const T=h;typeof T.data=="string"&&he({kind:f,payload:at(T)})};for(const f of Ie)S.addEventListener(f,q(f));S.addEventListener("error",f=>{const h=f;if(typeof h.data=="string"&&h.data){de(f),he({kind:"error",payload:at(h)});return}S.readyState===EventSource.CLOSED&&he({kind:"error",payload:{error:"Connection closed"}})})};Te(B);const _e=async()=>{B.close();let S=ee.sseUrl;if(xe){const q=new URL(ee.sseUrl,window.location.origin);q.searchParams.set("since",String(xe)),S=q.toString()}B=await tt(S,{throwOnFailure:!1}),Te(B),ve=Date.now()};await Promise.race([ke,new Promise(S=>setTimeout(S,1500))]);const Ce=()=>{B.close(),ue()};N.signal.addEventListener("abort",Ce,{once:!0});try{const S=m.current?.trim(),q=!!S&&!g.current;q&&(g.current=!0);let f;if(M.length>0){const b=new FormData;b.set("content",I),q&&S&&b.set("ephemeralContext",S);for(const _ of M)b.append("files",_,_.name);f={method:"POST",credentials:"include",body:b,timeoutMs:12e4}}else{const b={content:I};q&&S&&(b.ephemeralContext=S),f={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(b),timeoutMs:2e4}}const h=await Ze(ee.messagesUrl,f);if(!h.ok)throw d.current=null,await et(h);let T="",L=Pe,ce=null;const H=[],fe=()=>Bn({textOut:T,statusLine:L,errorText:ce,toolCalls:H});for(z(fe());!N.signal.aborted;){if(oe.length===0){let _;const ne=await Promise.race([new Promise(Fe=>{me=()=>Fe(!0)}),new Promise(Fe=>{_=setTimeout(()=>Fe(!1),er)})]);_&&clearTimeout(_),!ne&&Date.now()-ve>=Zn&&(await _e(),k());continue}const b=oe.shift();if(b){if(b.kind==="output")L=null,T+=String(b.payload.content??"");else if(b.kind==="status")L=Pe;else if(b.kind==="complete"){L=null;const _=b.payload.finalText;typeof _=="string"&&_.length>0&&(T=_);const ne=b.payload.suggestions;ne!==void 0&&y(Array.isArray(ne)?tr(ne):null),k(),z(fe());return}else if(b.kind==="closed"){d.current=null;const _=b.payload.reason;L=`Session ended${_?`: ${_}`:""}.`,k(),z(fe());return}else if(b.kind==="error"||b.kind==="agent-error"){L=null,ce=typeof b.payload.error=="string"&&b.payload.error?b.payload.error:"Agent reported an error.";const _=b.payload.errorContext&&typeof b.payload.errorContext=="object"?b.payload.errorContext:void 0,ne=bt(b.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof _?.provider=="string"?_.provider:void 0,model:typeof _?.model=="string"?_.model:void 0});ne&&H.push({type:"tool-call",toolCallId:ye("l"),toolName:"link-button",args:{label:ne.label,url:ne.href}}),k(),z(fe());return}else if(b.kind==="question")H.push({type:"tool-call",toolCallId:ye("q"),toolName:"question",args:{question:b.payload.question??"",options:b.payload.options??[]}});else if(b.kind==="tool_use"){if(L=null,vt.has(b.payload.name??"")){z(fe());continue}const _=b.payload.result_summary,ne=xt(_);if(!K&&!ne){z(fe());continue}H.push({type:"tool-call",toolCallId:b.payload.toolCallId??ye("t"),toolName:K?b.payload.name??"tool":"subscription-candidate",args:K?b.payload.input??{}:null,result:_,isError:b.payload.isError})}else if(b.kind==="link-button")H.push({type:"tool-call",toolCallId:ye("l"),toolName:"link-button",args:{label:b.payload.label??"Open link",url:b.payload.url??""}});else if(b.kind==="tool-approval"){const _=b.payload.runId;if(typeof _!="number")continue;H.push({type:"tool-call",toolCallId:`run-${_}`,toolName:"tool-approval",args:{runId:_,action:b.payload.action??null,proposal:b.payload.proposal??null,current:b.payload.current??null,fields:b.payload.fields??null,attribution:b.payload.attribution??null,resourceKind:b.payload.resourceKind??null}})}z(fe())}}}catch(S){z([{type:"text",text:`Error: ${S instanceof Error?S.message:"Send failed."}`}])}finally{N.signal.removeEventListener("abort",Ce),B.close()}},[e,Z,k,K,t]),re=a.useCallback(I=>{const M=I.trim(),V=D.map(B=>B.file);if(!M&&V.length===0||w.current||!e)return;v.current||(v.current=!0,l?.(M||V[0]?.name||""));const N={id:ye("u"),role:"user",parts:M?[{type:"text",text:M}]:[],attachments:D.map(B=>({id:B.id,name:B.name,isImage:B.isImage,imageDataUrl:B.isImage?URL.createObjectURL(B.file):void 0})),createdAt:Date.now()},z=ye("asst"),ee={id:z,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};$(B=>[...B,N,ee]),X([]),ae(!0),w.current=!0,te(M,V,z).finally(()=>{ae(!1),w.current=!1,R.current=null})},[e,l,D,te]),le=a.useCallback(()=>{R.current?.abort()},[]),Se=a.useCallback(I=>{const M=Array.from(I);X(V=>[...V,...M.map(N=>({id:crypto.randomUUID(),name:N.name,file:N,isImage:N.type.startsWith("image/")}))])},[]),Q=a.useCallback(I=>{X(M=>M.filter(V=>V.id!==I))},[]),ie=a.useRef(!1);a.useEffect(()=>{if(ie.current)return;const I=Wt(n);I&&(ie.current=!0,re(I))},[n,re]);const F=a.useMemo(()=>({messages:E,running:Y,append:re,cancel:le,pendingAttachments:D,addAttachments:Se,removeAttachment:Q,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:J,starters:G}),[E,Y,re,le,D,Se,Q,c,e,n,t,J,G]);return r&&x?s.jsx(Rn,{}):s.jsx(Ye.Provider,{value:F,children:i})}const it="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function nr({refItem:e}){const t=Nn[e.kind]??Kt;return En(e.path)?s.jsxs("span",{className:it,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(pt,{to:e.path,className:P(it,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Je=({text:e,renderText:t})=>Cn(e)?s.jsx(s.Fragment,{children:jn(e).map((n,r)=>n.type==="ref"?s.jsx(nr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),rr=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),wt=a.createContext(null),St=()=>{const e=a.useContext(wt);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Tt=a.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...l})=>{const[i,c]=qt({prop:t,defaultProp:n,onChange:r}),u=a.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(wt.Provider,{value:u,children:s.jsx("div",{className:P("not-prose max-w-prose space-y-4",e),...l,children:o})})}),Ct=a.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=St();return s.jsx(mt,{onOpenChange:o,open:r,children:s.jsxs(Gt,{className:P("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Xt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Yt,{className:P("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),jt=a.memo(({className:e,icon:t=Qt,label:n,description:r,status:o="complete",children:l,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:P("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),l]})]})}),Nt=a.memo(({className:e,children:t,...n})=>{const{isOpen:r}=St();return s.jsx(mt,{open:r,children:s.jsx(Jt,{className:P("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});Tt.displayName="ChainOfThought";Ct.displayName="ChainOfThoughtHeader";jt.displayName="ChainOfThoughtStep";Nt.displayName="ChainOfThoughtContent";function or(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function sr({ownerSlug:e,eventIds:t}){const n=t.join(","),r=a.useMemo(()=>or(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(Zt,{owner:e,children:({organizationId:o,ownerSlug:l})=>o?s.jsx(_n,{organizationId:o,ownerSlug:l,filters:r,hideOriginator:!0}):null})}function lr({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let l=He(ar(r,o),t);if(!n)return a.createElement(e,l);if(typeof n=="function")return n(l,r);if(!a.isValidElement(n))return null;let i=n.props,c={...He(l,i),ref:Ae(l.ref,i.ref)};return a.cloneElement(n,c)}function He(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let l=r[o];if(l===void 0)continue;let i=t[o];o==="className"?t[o]=[i,l].filter(Boolean).join(" "):o==="style"?t[o]={...i,...l}:o==="ref"?t[o]=Ae(i,l):cr(o)&&typeof i=="function"&&typeof l=="function"?t[o]=ir(l,i):t[o]=l}}return t}function ar(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],l=t?.[r]?.(o);if(l){Object.assign(n,l);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function ir(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function cr(e){return/^on[A-Z]/.test(e)}function Ae(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var ur=8,dr=64,fr=0,Me=.5,pr=180,mr=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),Et={start:!1,end:!1},hr=[],Le={currentAnchorId:null,visibleMessageIds:hr};function gr({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Et;let o=Qe({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function br({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:l}){if(!e||!o)return Le;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],p=null;for(let v of je(e,r)){let m=v.dataset.messageId;if(!m)continue;let g=v.dataset.scrollAnchor==="true",R=g||u?v.getBoundingClientRect():null;(u&&R?R.bottom>c&&R.top<i.bottom:l.has(m))&&d.push(m),g&&R&&R.top<=c+Me&&(p=m)}return d.length===0&&p===null?Le:{currentAnchorId:p,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function xr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function vr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function yr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function Rr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function wr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>r.top&&l.top<r.bottom)return o}return null}function Sr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let l=At(t,o),i=t.getBoundingClientRect().height,c=jr(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return l-c.start-(u-i)/2-n}if(e==="end")return l-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=l+i,d=o.scrollTop+c.start,p=o.scrollTop+o.clientHeight-c.end;return l>=d&&u<=p?o.scrollTop:l<d?l-c.start-n:u-o.clientHeight+c.end+n}return l-c.start-n}function At(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Oe(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Tr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Qe({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Qe({content:e,spacer:t,viewport:n}){let r=je(e,t),o=kt(e),l=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-l.top+i+o.end)}return c}function Cr(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function kt(e){let t=window.getComputedStyle(e);return{end:ze(t.paddingBlockEnd||t.paddingBottom),start:ze(t.paddingBlockStart||t.paddingTop)}}function jr(e){let t=e?.parentElement;return t?kt(t):{end:0,start:0}}function Nr(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return ze(n)}function ze(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Er({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:p,messageElementsRef:v,modeRef:m,pendingScrollToMessageRef:g,prependRestoreRef:R,scrollMarginRef:A,scrollPreviousItemPeekRef:x,spacerGapRef:C,spacerHeightRef:W,spacerRef:U,viewportRef:G}=e,K=a.useCallback(y=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==y&&(i.current=y,t()),y&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},pr))},[t]),E=a.useCallback(y=>{let w=U.current;if(!w)return;let j=Math.max(0,Math.ceil(y));W.current!==j&&(W.current=j,w.hidden=j===0,w.style.height=`${j}px`,w.style.marginTop=j>0?`${-C.current}px`:"")},[]),$=a.useCallback((y,{behavior:w="auto",autoscrolling:j=!1}={})=>{let O=G.current;if(!O)return;let k=Math.max(0,y);if(Math.abs(O.scrollTop-k)<=Me){O.scrollTop=k,t();return}j&&K(!0),O.scrollTo({top:k,behavior:w}),n()},[t,n,K]),Y=a.useCallback(({behavior:y="auto"}={})=>G.current?(E(0),o.current=null,m.current="free-scrolling",$(0,{behavior:y}),r(),!0):!1,[r,$,E]),ae=a.useCallback(({behavior:y="auto"}={})=>{let w=G.current;return w?(E(0),o.current=null,m.current=l.current?"following-bottom":"free-scrolling",$(Cr(w),{autoscrolling:!0,behavior:y}),r(),!0):!1},[r,$,E]),D=a.useCallback((y,{align:w="start",behavior:j="auto",scrollMargin:O=A.current}={},{keepPreviousPeek:k=!1}={})=>{let Z=u.current,te=G.current;if(!Z||!te||!Z.contains(y))return!1;let re=Sr({align:w,element:y,scrollMargin:k?O+x.current:O,spacer:U.current,viewport:te}),le=Tr({content:Z,scrollTop:re,spacer:U.current,viewport:te});return E(le),R.current={element:y,viewportTop:Oe(y,te)},m.current=k?"anchored-to-message":"settling-jump",o.current=k?y:null,$(re,{behavior:j}),r(),!0},[r,$,E]),X=a.useCallback(()=>{let y=o.current;return!y||!y.isConnected||m.current!=="anchored-to-message"?!1:D(y,{align:"start"},{keepPreviousPeek:!0})},[D]),J=a.useCallback((y,w)=>{let j=v.current.get(y);return j?(d.current=!0,D(j,w)?(g.current=null,!0):(g.current={messageId:y,options:w},!0)):p.current===0?(g.current={messageId:y,options:w},d.current=!0,!0):!1},[D]);return{flushPendingScrollToMessage:a.useCallback(()=>{let y=g.current;if(!y)return!1;let w=v.current.get(y.messageId);return!w||!D(w,y.options)?!1:(g.current=null,d.current=!0,!0)},[D]),reanchorToAnchoredMessage:X,scrollToElement:D,scrollToEnd:ae,scrollToMessage:J,scrollToStart:Y}}function It(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(l=>l()))},subscribe:(o,l,i)=>{let c=r.size===0;return r.add(o),c&&l?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function Ar(e,t){return It(e,t)}function kr(){return It(Le,_r)}function Ir(e,t){return e.start===t.start&&e.end===t.end}function _r(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Or({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=a.useRef(e),l=a.useRef(!1),i=a.useRef(null),c=a.useRef(!1),u=a.useRef(t),d=a.useRef(0),p=a.useRef(null),v=a.useRef(0),m=a.useRef(e?"following-bottom":"free-scrolling"),g=a.useRef(new Map),R=a.useRef(null),A=a.useRef(null),x=a.useRef(null),C=a.useRef(r),W=a.useRef(!0),U=a.useRef(null),G=a.useRef(n),K=a.useRef(null),E=a.useRef(0),$=a.useRef(0),Y=a.useRef(null),ae=a.useRef(null),D=a.useRef(null),X=a.useRef(null),J=a.useRef(null),y=a.useRef(null),w=a.useRef(null),j=a.useRef(null),O=a.useRef(new Set),k=a.useRef(new WeakSet);return D.current===null&&(D.current=Ar(Et,Ir)),j.current===null&&(j.current=kr()),o.current=e,u.current=t,G.current=n,C.current=r,{autoScrollRef:o,autoscrollingRef:l,autoscrollingTimeoutRef:X,streamingTurnRef:x,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:p,itemCountRef:d,lastScrollTopRef:v,messageElementsRef:g,modeRef:m,pendingScrollFrameRef:K,pendingScrollToMessageRef:R,prependRestoreRef:A,preserveScrollOnPrependRef:W,rootRef:U,scrollEdgeThresholdRef:u,scrollMarginRef:G,scrollPreviousItemPeekRef:C,spacerGapRef:E,spacerHeightRef:$,spacerRef:Y,stateFrameRef:ae,stateStore:D.current,viewportRef:J,visibilityFrameRef:y,visibilityObserverRef:w,visibilityStore:j.current,visibleMessageIdsRef:O,handledScrollAnchorsRef:k}}function ct(e,t){return a.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Pr({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=ur,scrollPreviousItemPeek:r=dr,scrollMargin:o=fr}){let l=Or({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:p,defaultScrollPositionAppliedRef:v,firstItemRef:m,itemCountRef:g,lastScrollTopRef:R,messageElementsRef:A,modeRef:x,pendingScrollFrameRef:C,pendingScrollToMessageRef:W,prependRestoreRef:U,preserveScrollOnPrependRef:G,rootRef:K,scrollEdgeThresholdRef:E,scrollMarginRef:$,scrollPreviousItemPeekRef:Y,spacerGapRef:ae,spacerHeightRef:D,spacerRef:X,stateFrameRef:J,stateStore:y,viewportRef:w,visibilityFrameRef:j,visibilityObserverRef:O,visibilityStore:k,visibleMessageIdsRef:Z,handledScrollAnchorsRef:te}=l,re=a.useRef(t);re.current!==t&&(re.current=t,v.current=!1);let le=a.useCallback(f=>{let h=K.current,T=w.current,L=[f.start&&"start",f.end&&"end"].filter(Boolean).join(" "),ce=u.current;for(let H of[h,T])H&&(L?H.setAttribute("data-scrollable",L):H.removeAttribute("data-scrollable"),H.toggleAttribute("data-autoscrolling",ce))},[]),Se=a.useCallback(f=>{let h=w.current?.scrollTop??0,T=h<R.current-Me;R.current=h,c.current&&!f.end&&x.current!=="settling-jump"&&x.current!=="anchored-to-message"?x.current="following-bottom":x.current==="following-bottom"&&f.end&&T&&!u.current&&(x.current="free-scrolling")},[]),Q=a.useCallback(()=>{let f=gr({content:p.current,scrollEdgeThreshold:E.current,spacer:X.current,viewport:w.current});Se(f);let h=x.current==="following-bottom"?{...f,end:!1}:f;le(h),y.setSnapshot(h)},[Se,y,le]),ie=a.useCallback(()=>{J.current===null&&(J.current=window.requestAnimationFrame(()=>{J.current=null,Q()}))},[Q]),F=a.useCallback(()=>{k.hasListeners()&&j.current===null&&(j.current=window.requestAnimationFrame(()=>{j.current=null,k.hasListeners()&&k.setSnapshot(br({content:p.current,scrollMargin:$.current,scrollPreviousItemPeek:Y.current,spacer:X.current,viewport:w.current,visibleMessageIds:Z.current}))}))},[k]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:M,scrollToElement:V,scrollToEnd:N,scrollToMessage:z,scrollToStart:ee}=Er({refs:l,commitScrollState:Q,scheduleStateCommit:ie,scheduleVisibilitySync:F}),B=a.useCallback(()=>{let f=U.current,h=w.current;if(!f||!h||!f.element.isConnected)return!1;let T=Oe(f.element,h)-f.viewportTop;return Math.abs(T)<=Me?!1:(h.scrollTop+=T,f.viewportTop=Oe(f.element,h),ie(),F(),!0)},[ie,F]),oe=a.useCallback(()=>{let f=p.current,h=w.current;if(!f||!h){U.current=null;return}let T=wr({content:f,spacer:X.current,viewport:h});U.current=T?{element:T,viewportTop:Oe(T,h)}:null},[]),me=a.useCallback(()=>{C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,I()&&oe()}))},[oe,I]),ue=a.useCallback(()=>{if(!t||v.current||g.current===0)return!1;let f=!1;if(t==="last-anchor"){let h=p.current,T=w.current,L=h&&T?Rr(je(h,X.current)):null;if(!h||!T||!L)f=N({behavior:"auto"});else{let ce=At(L,T);f=Qe({content:h,spacer:X.current,viewport:T})-ce<=T.clientHeight?N({behavior:"auto"}):V(L,{align:"start"},{keepPreviousPeek:!0})}}else f=t==="end"?N({behavior:"auto"}):ee({behavior:"auto"});return f?(v.current=!0,!0):!1},[t,V,N,ee]),he=a.useCallback(()=>{let f=p.current;if(!f)return;let h=je(f,X.current),T=g.current,L=m.current;g.current=h.length,m.current=h[0]??null,(()=>{if(I())return;if(T===0){if(ue()||h.length>0&&c.current&&N({behavior:"auto"}))return;Q(),F();return}let ce=L?h.indexOf(L):-1;if(G.current&&ce>0){B();return}if(h.length>T){let H=xr(h,T);if(H){if(c.current&&x.current==="following-bottom"&&yr(h,T)){N({behavior:"auto"});return}V(H,{align:"start"},{keepPreviousPeek:!0}),te.current.add(H);return}}if(h.length===T){let H=vr(h,te.current);if(H){V(H,{align:"start"},{keepPreviousPeek:!0}),te.current.add(H);return}}x.current==="following-bottom"&&c.current?N({behavior:"auto"}):(Q(),F())})(),oe()},[ue,oe,Q,I,B,F,V,N]),ge=a.useCallback(()=>{if(x.current==="following-bottom"&&c.current){N({behavior:"auto"});return}let f=D.current;if(M()){c.current&&f>0&&D.current===0&&N({behavior:"auto"});return}ie(),F()},[M,ie,F,N]),be=a.useCallback(()=>{let f=w.current;if(!(!f||!k.hasListeners())){if(typeof IntersectionObserver>"u"){F();return}O.current||(O.current=new IntersectionObserver(h=>{for(let T of h){let L=T.target.dataset.messageId;L&&(T.isIntersecting?Z.current.add(L):Z.current.delete(L))}F()},{root:f,rootMargin:`${-($.current+Y.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),A.current.forEach(h=>{O.current?.observe(h)}),F()}},[F,k]),ke=a.useCallback(()=>{j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),O.current?.disconnect(),O.current=null,Z.current.clear(),k.setSnapshot(Le)},[k]),xe=a.useCallback((f,h,T)=>{if(h){A.current.set(f,h),O.current?.observe(h),F(),W.current?.messageId===f&&me();return}T&&A.current.get(f)===T&&(A.current.delete(f),Z.current.delete(f),O.current?.unobserve(T),F())},[me,F]),ve=a.useCallback(()=>{(x.current==="following-bottom"||x.current==="anchored-to-message"||x.current==="settling-jump")&&(i.current=null,x.current="free-scrolling")},[]),de=a.useCallback(()=>le(y.getSnapshot()),[y,le]),Ie=ct(K,de),Te=ct(w,de),_e=a.useCallback(f=>{p.current=f},[]),Ce=a.useCallback(f=>{X.current=f,ae.current=Nr(f?.parentElement??null)},[]),S=a.useCallback(()=>{Q(),F(),oe()},[oe,Q,F]),q=a.useMemo(()=>({handleContentChange:he,handleResize:ge,observeVisibility:be,preserveScrollOnPrependRef:G,scrollToEnd:N,scrollToMessage:z,scrollToStart:ee,setContentElement:_e,setRootElement:Ie,setSpacerElement:Ce,setViewportElement:Te,stateStore:y,syncAfterScroll:S,unobserveVisibility:ke,userScrollIntent:ve,viewportRef:w,visibilityStore:k}),[he,ge,be,N,z,ee,_e,Ie,Ce,Te,y,S,ke,ve,k]);return a.useLayoutEffect(()=>{ue()},[ue]),a.useEffect(()=>()=>{J.current!==null&&(window.cancelAnimationFrame(J.current),J.current=null),j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),O.current?.disconnect(),O.current=null},[]),a.useLayoutEffect(()=>{if(e&&x.current==="following-bottom"&&g.current>0){N({behavior:"auto"});return}Q()},[e,Q,N]),{context:q,registerMessage:xe}}function Mr(e){let t=a.useRef(e);return t.current=e,t}var _t=a.createContext(null),Ot=a.createContext(null);function Re(){let e=a.useContext(_t);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Lr(){let e=a.useContext(Ot);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Pt(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=Re();return a.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Mt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=Re(),r=a.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return a.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function $r({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:i,registerMessage:c}=Pr({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(_t.Provider,{value:i,children:s.jsx(Ot.Provider,{value:c,children:t})})}function Dr({children:e,...t}){let{setRootElement:n}=Re();return s.jsx("div",{ref:n,...t,children:e})}function Ur({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...p}){let{handleResize:v,preserveScrollOnPrependRef:m,setViewportElement:g,syncAfterScroll:R,userScrollIntent:A,viewportRef:x}=Re();m.current=i;let C=a.useCallback(E=>{g(E),Ae(c)?.(E)},[c,g]);function W(E){R(),r?.(E)}function U(E){A(),l?.(E)}function G(E){A(),o?.(E)}function K(E){mr.has(E.key)&&A(),n?.(E)}return a.useEffect(()=>{let E=x.current;if(!E||typeof ResizeObserver>"u")return;let $=0,Y=new ResizeObserver(()=>{window.cancelAnimationFrame($),$=window.requestAnimationFrame(v)});return Y.observe(E),()=>{window.cancelAnimationFrame($),Y.disconnect()}},[v,x]),s.jsx("div",{ref:C,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:K,onScroll:W,onTouchMove:G,onWheel:U,...p,children:t})}function Fr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...l}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=Re(),p=a.useRef(null),v=a.useCallback(m=>{p.current=m,u(m),Ae(n)?.(m)},[n,u]);return a.useLayoutEffect(()=>{let m=p.current;if(!m||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(m,{childList:!0}),()=>g.disconnect()},[i]),a.useEffect(()=>{let m=p.current;if(!m||typeof ResizeObserver>"u")return;let g=0,R=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return R.observe(m),()=>{window.cancelAnimationFrame(g),R.disconnect()}},[c]),s.jsxs("div",{ref:v,role:r??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function Vr({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=Lr(),l=a.useRef(null),i=a.useCallback(c=>{let u=l.current;l.current=c,e&&o(e,c,u),Ae(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Br({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:l,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:p}=Re(),v=Mr(r),m=a.useCallback(x=>p.subscribe(x),[p]),g=a.useCallback(()=>{let x=p.getSnapshot();return n==="start"?x.start:x.end},[n,p]),R=a.useSyncExternalStore(m,g,g),A=a.useCallback(x=>{R&&(v.current?.(x),x.defaultPrevented||(x.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,R,v,u,d]);return lr({defaultTagName:"button",props:He({type:i,inert:!R,tabIndex:R?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:A},c),render:o,state:{active:R,direction:n},stateAttributesMapping:{active:x=>({"data-active":x?"true":"false"})}})}var we={Provider:$r,Root:Dr,Viewport:Ur,Content:Fr,Item:Vr,Button:Br};const Hr=we.Provider;function zr({className:e,...t}){return s.jsx(we.Root,{className:P("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Wr({className:e,...t}){return s.jsx(we.Viewport,{className:P("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function Kr({className:e,...t}){return s.jsx(we.Content,{className:P("flex h-max min-h-full flex-col",e),...t})}function qr({className:e,...t}){return s.jsx(we.Item,{className:P("min-w-0 shrink-0",e),...t})}function Gr({className:e,...t}){return s.jsx(we.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(pe,{...r,type:"button",variant:"outline",size:"icon",className:P("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(en,{})}):null,...t})}function Xr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function Yr(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const Jr="lobu-spa";function ut(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function $e(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const Lo=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:l,agentId:i,conversationId:c}=Ee(),{data:u=[]}=tn(i,{conversationId:c});return s.jsx(Pn,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(Qr,{messages:l,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:wn,children:s.jsx(No,{})})]})})},Qr=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(Hr,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(eo,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function Zr(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const eo=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:l}=Mt(),{scrollToMessage:i}=Pt(),c=a.useRef(null);a.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Yr({messageIds:e.map(p=>p.id),scrollTarget:Xr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(zr,{children:[s.jsx(Wr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(Kr,{className:P(qe,Sn),children:[e.map(d=>{const p=n==="runs"&&o?Zr(d.id):null;return s.jsx(qr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===l?"location":void 0,className:P("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===l&&"border-primary"),children:p!=null?s.jsx(ho,{message:d,onClick:()=>o?.(p)}):s.jsx(oo,{message:d})},d.id)}),t.map(d=>s.jsx(no,{trip:d},d.id)),s.jsx(ro,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(to,{messages:e,mode:n}):null,s.jsx(Gr,{})]})},to=({messages:e,mode:t})=>{const{scrollToMessage:n}=Pt(),{currentAnchorId:r,visibleMessageIds:o}=Mt(),l=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(p=>p.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(an,{children:[s.jsx(cn,{asChild:!0,children:s.jsxs(pe,{type:"button",variant:"outline",size:"icon",className:P("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",l>0&&"w-auto px-3"),"aria-label":l>0?`Open transcript outline, ${l} ${l===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(un,{}),l>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[l," waiting"]}):null]})}),s.jsxs(dn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(pe,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:P("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},no=({trip:e})=>s.jsxs("div",{className:P(qe,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(sn,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),ro=()=>{const{currentSuggestions:e,starters:t,messages:n,running:r,append:o}=Ee(),l=Hn(e,t,n.length);return r||l.length===0?null:s.jsx(ln,{prompts:l,className:P(qe,n.length===0&&"mt-auto"),onPick:i=>o(i)})},oo=({message:e})=>e.role==="user"?s.jsx(so,{message:e}):e.role==="system"?s.jsx(go,{message:e}):s.jsx(io,{message:e}),Lt=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return s.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=s.jsxs(s.Fragment,{children:[s.jsx(Be,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},so=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:ht,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(lo,{part:n},$e(e,n)))})}):s.jsx("div",{className:Tn,children:s.jsxs("div",{className:P(Ne,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx(Lt,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Je,{text:n.text,renderText:r=>r})},$e(e,n)):null)]})})},lo=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:P(Ne,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(fn,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},$t=new Set(["question","link-button","tool-approval"]),ao="subscription-candidate",io=({message:e})=>{const t=Ge(),{agentId:n,workspaceSlug:r}=Ee(),o=u=>u.type==="tool-call"&&($t.has(u.toolName)||t?.toolNames.has(u.toolName)),l=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==ao),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=xt(u.result);return d?[d]:[]});return s.jsx("div",{className:ht,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[l.length>0?s.jsx(fo,{tools:l,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(co,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(mo,{part:u},$e(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx(Lt,{attachment:u},u.id))}):null]})})},co=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:P(Ne,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(pe,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(pt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(mn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function uo(e){try{return JSON.parse(e)}catch{return null}}function Dt(e){if(Array.isArray(e)){const o=e.flatMap(l=>l?.type==="text"&&typeof l.text=="string"?Dt(l.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?uo(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const l=o&&typeof o=="object"?o.id:null;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?[l]:[]});return r.length>0?r:null}const fo=({tools:e,workspaceSlug:t})=>s.jsxs(Tt,{defaultOpen:!1,children:[s.jsx(Ct,{children:e.length===1?e[0].toolName:`${e.length} tool calls`}),s.jsx(Nt,{children:e.map(n=>{const r=n.args!==void 0&&n.args!==null,o=n.result!==void 0&&n.result!==null,l=Dt(n.result);return s.jsxs(jt,{icon:pn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:n.toolName}),n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[r?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ue(n.args)}):null,o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ue(n.result)}):null,l&&t?s.jsx(sr,{ownerSlug:t,eventIds:l}):null]},n.toolCallId)})})]}),po=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const l=JSON.parse(r[0])?.error?.message;typeof l=="string"&&l.trim()&&(t=l,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(gn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},mo=({part:e})=>{const t=Ge();return e.type==="reasoning"?s.jsx(rr,{}):e.type==="error"?s.jsx(po,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Je,{text:e.text,renderText:n=>s.jsx(hn,{text:n})}):null:e.type!=="tool-call"?null:$t.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(jo,{toolName:e.toolName,args:e.args}):null},ho=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:P(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},go=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:P(Ne,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Je,{text:t.text,renderText:n=>n})},$e(e,t)):null)})}),bo="/mcp-apps/interaction/index.html";function dt(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const xo=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const l=a.useRef(null),[i,c]=a.useState(48),u=a.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},a.useEffect(()=>{const d=l.current;if(!d?.contentWindow)return;const p=new vn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});p.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),p.oncalltool=async({name:g,arguments:R})=>{const A=await u.current.onToolCall(g,R??{});return{isError:A,content:[{type:"text",text:A?"Action failed.":"Action completed."}]}},p.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),p.addEventListener("initialized",()=>{(async()=>(await p.sendToolInput({arguments:{}}),await p.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:Jr}})))()});const v=new yn(d.contentWindow,d.contentWindow);p.connect(v).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const m=new MutationObserver(()=>{p.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return m.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{m.disconnect(),v.close()}},[]),s.jsx("iframe",{ref:l,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},vo=new Set(["action"]),yo=["name","description","identity_md"];function se(e){return e==null||e===""?"":typeof e=="string"?e:Ue(e)}function ft(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Ue(e)}function De(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Ut=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function We(e){return e&&Ut.has(e)?"warning":"default"}function Ke(e,t){return e&&Ut.has(e)?{level:"high",reason:t}:{level:"normal"}}function Ro(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(l=>({label:l,before:se(e.current?.[l]),after:se(t[l])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function wo(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},l=Object.keys(o).filter(i=>!vo.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:ft(e.current?.[i])}:{},after:ft(o[i])}));return r.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0}),{title:`${De(t)} Automation ${n}`,icon:"automation",impact:Ke(e.action,"This archives the Automation and stops future runs."),tone:We(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function So(e){if(e.resourceKind==="automation")return wo(e);if(e.fields&&Object.keys(e.fields).length>0)return Ro(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return On({...e,action:e.action});if(t){const l=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&se(e.proposal?.[d])!==se(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:se(e.current?.[d])}:{},after:se(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${De(i)} entity ${l}`,icon:"entity",impact:Ke(e.action,"This deletes the entity."),tone:We(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${l} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${l} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const l=yo.filter(i=>e.proposal?.[i]!==void 0&&se(e.proposal?.[i])!==se(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:se(e.current?.[i])}:{},after:se(e.proposal?.[i])}));o.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${De(r)} agent ${n}`,icon:"agent",impact:Ke(e.action,"This permanently deletes the agent and its configuration."),tone:We(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function To(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function Co(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const jo=({toolName:e,args:t})=>{const n=bn(),r=xn(),{append:o}=Ee(),l=Ge(),i=t??{},c=l?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},p=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const v=i.runId,m=typeof i.status=="string"?i.status:"pending",g=m==="pending",R=So(i),A=m==="confirmed"?"Approved":De(m);u=g?R:{...R,title:`${R.title??"Approval"} · ${A}`,tone:m==="failed"?"warning":"default",blocks:[...R.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${m==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${A}.`,muted:!0}],actions:(R.actions??[]).filter(x=>x.terminal===!1)},g&&(d.manage_operations=x=>{if(x.action==="approve")return dt(C=>n.mutate({run_id:v},C));if(x.action==="reject"){const C=typeof x.reason=="string"?x.reason:void 0;return dt(W=>r.mutate({run_id:v,...C?{reason:C}:{}},W))}return Promise.resolve(!0)})}else if(e==="question"){const v=Array.isArray(i.options)?i.options.filter(m=>typeof m=="string"):[];u=To(i),d.answer_question=m=>{const g=typeof m.answer=="string"?m.answer:"";return v.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!ut(i.url))return null;const v=i.url;p.add(v),u=Co(i,v)}}return u?s.jsx(xo,{src:bo,title:u.title??"Interaction",renderPayload:u,onToolCall:(v,m)=>d[v]?d[v](m):Promise.resolve(!0),onOpenLink:v=>!p.has(v)||!ut(v)?Promise.resolve(!0):(window.open(v,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Ue(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const No=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:l,initialDraft:i,currentSuggestions:c}=Ee(),u=Eo({suggestions:e?null:c}),[d,p]=a.useState(i??""),v=a.useRef(null),m=a.useRef(null),g=An(In),R=a.useRef(i??"");a.useEffect(()=>{const C=i??"";if(C===R.current)return;const W=R.current;R.current=C,C!==""&&p(U=>U===""||U===W?C:U)},[i]);const A=a.useRef(d);A.current=d;const x=()=>{e||(t(A.current),p(""),m.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(C=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(Be,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:C.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>l(C.id),children:s.jsx(nn,{className:"h-3 w-3"})})]},C.id))}):null,s.jsx(kn,{value:d,onChange:p,onSubmit:x,searchRefs:g,handleRef:m,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:C=>{C.target.files&&o(C.target.files),C.target.value=""}}),s.jsxs(pe,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>v.current?.click(),children:[s.jsx(Be,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(pe,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(rn,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(pe,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:x,children:[s.jsx(on,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function Eo({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Lo as A,Mo as L,Po as R,Jn as h,qn as s};
6
- //# sourceMappingURL=agent-thread-Buz3naVF.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-DYCqXaMf.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=agents-C-ReckCa.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-DYCqXaMf.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=automations-C-ReckCa.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-DYCqXaMf.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=connect-4zqtnDHb.js.map
@@ -1,2 +0,0 @@
1
- import{iJ as r,j as t,ai as a}from"./index-DYCqXaMf.js";import{a as i}from"./agent-connect-pages-CAV-yXus.js";import"./agent-client-setup-list-BA8dU_C6.js";import"./clients-L4K1UT8c.js";import"./client-rows--FrZfJol.js";function x(){const{owner:e,clientId:o}=r.useParams();return t.jsx(a,{owner:e,children:({ownerSlug:n})=>t.jsx(i,{owner:n,clientId:o})})}export{x as component};
2
- //# sourceMappingURL=connect._clientId-Dj0SqgbE.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as n}from"./index-DYCqXaMf.js";function e(){return t.jsx(n,{})}export{e as component};
2
- //# sourceMappingURL=connected._clientId-sgtocSvf.js.map
@@ -1,2 +0,0 @@
1
- import{i_ as o,j as e}from"./index-DYCqXaMf.js";import{a}from"./agent-guardrails-route-DMOjG1D4.js";import"./model-selector-TQcA93xm.js";import"./agent-subpage-shell-BBJoyTuC.js";import"./agent-loading-shells-De_2d8Lr.js";import"./agent-card-controls-Be1Okb2C.js";function g(){const{owner:r,agentId:t}=o.useParams();return e.jsx(a,{owner:r,agentId:t})}export{g as component};
2
- //# sourceMappingURL=create-Cf5hp6Z8.js.map
@@ -1,2 +0,0 @@
1
- import{iY as r,j as e}from"./index-DYCqXaMf.js";import{a as i}from"./agent-skills-route-DcK41PWj.js";import"./agent-subpage-shell-BBJoyTuC.js";import"./agent-skill-context-JLaTamGR.js";import"./core.esm-Dr7tcIB-.js";import"./skill-editor-D_W3QlRz.js";import"./agent-loading-shells-De_2d8Lr.js";import"./agent-card-controls-Be1Okb2C.js";function x(){const{owner:t,agentId:o}=r.useParams();return e.jsx(i,{owner:t,agentId:o})}export{x as component};
2
- //# sourceMappingURL=create-CwThQtd3.js.map
@@ -1,2 +0,0 @@
1
- import{iA as e,j as t,hq as r}from"./index-DYCqXaMf.js";function a(){const{owner:n,connectorKey:o}=e.useParams();return t.jsx(r,{owner:n,initialConnectorKey:o})}export{a as component};
2
- //# sourceMappingURL=create._connectorKey-sNHQHNpg.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-DYCqXaMf.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=deployments-DHh9dyzv.js.map