@xopcai/xopc 0.0.321 → 0.0.323

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 (281) hide show
  1. package/dist/browser-ext/dist/assets/{auth-DKo-NMUY.js → auth-DocRzRlS.js} +95 -21
  2. package/dist/browser-ext/dist/background.js +1 -1
  3. package/dist/browser-ext/dist/sidepanel.html +1 -1
  4. package/dist/browser-ext/dist/sidepanel.js +18 -2
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C69p1Gbr.js → agent-avatar-dicebear-DFzmThVi.js} +1 -1
  8. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CAFHadiy.js +1 -0
  9. package/dist/gateway/static/root/assets/agent-plugin-dialog-DYFYiuig.js +1 -0
  10. package/dist/gateway/static/root/assets/{agents-CWR3p3t3.js → agents-BqIlB5Co.js} +1 -1
  11. package/dist/gateway/static/root/assets/{app-link-nL8iPwEr.js → app-link-C6gA5Nck.js} +1 -1
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-D98bt40S.js → app-management-settings-panel-BgvMRGWe.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-ChMUELAZ.js → appearance-settings-CliHU03A.js} +1 -1
  14. package/dist/gateway/static/root/assets/apps-page-Drt3Foi9.js +1 -0
  15. package/dist/gateway/static/root/assets/{archive-plugin-BIIiu6uP.js → archive-plugin-DnuPpm0u.js} +1 -1
  16. package/dist/gateway/static/root/assets/{attachment-load-CDJpcsCp.js → attachment-load-BiwaK0ie.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automations-page-Cb5a_WOk.js → automations-page-CJSISGQH.js} +1 -1
  18. package/dist/gateway/static/root/assets/automations-workspace-B-Eduqwz.js +7 -0
  19. package/dist/gateway/static/root/assets/{binary-plugins-zp55zQPu.js → binary-plugins-KDjduQZO.js} +1 -1
  20. package/dist/gateway/static/root/assets/{block-editor-B0CTIZb-.js → block-editor-bclvgove.js} +3 -3
  21. package/dist/gateway/static/root/assets/{browser-automation-inputs-Bx3W4J4H.js → browser-automation-inputs-CfQ2T9t6.js} +1 -1
  22. package/dist/gateway/static/root/assets/{browser-automations-page-D5Lr9b8a.js → browser-automations-page-Cxq38Nnp.js} +2 -2
  23. package/dist/gateway/static/root/assets/browser-settings-page-Dwgir6mu.js +3 -0
  24. package/dist/gateway/static/root/assets/capabilities-settings-panel-H5L5vynP.js +8 -0
  25. package/dist/gateway/static/root/assets/capabilities-uFKh3Hd0.js +1 -0
  26. package/dist/gateway/static/root/assets/channels-settings-RFBRYe5S.js +1 -0
  27. package/dist/gateway/static/root/assets/{chat-terminal-dock-1I1PdIq0.js → chat-terminal-dock-DKQC62nQ.js} +2 -2
  28. package/dist/gateway/static/root/assets/{computer-settings-page-BT-EfoI6.js → computer-settings-page-D1whpIqL.js} +1 -1
  29. package/dist/gateway/static/root/assets/{connector-service-page-mhQ-19tj.js → connector-service-page-BAuYTgf5.js} +1 -1
  30. package/dist/gateway/static/root/assets/connectors-page-Px-v3Q6Q.js +2 -0
  31. package/dist/gateway/static/root/assets/{date-picker-BqcldZoN.js → date-picker-CfCo3lqh.js} +1 -1
  32. package/dist/gateway/static/root/assets/{dependency-picker-DLDLJx3D.js → dependency-picker-DOuVO2M1.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-kSFeHyrt.js → desktop-pet-D9tu6Bhu.js} +1 -1
  34. package/dist/gateway/static/root/assets/{desktop-pet-settings-BjY7DqD7.js → desktop-pet-settings-CQPXub2f.js} +1 -1
  35. package/dist/gateway/static/root/assets/device-pairing-wizard-DxkOYSut.js +1 -0
  36. package/dist/gateway/static/root/assets/{extension-debug-page-DbWJDT4X.js → extension-debug-page-CtWClPz-.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-lAC_2xWA.js → extension-page-BHh9HLCz.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-settings-page-jFy1NJg9.js → extension-settings-page-BdT3v5Uh.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-config-swr-B7WpH3VW.js → gateway-config-swr-1eqyz9vZ.js} +1 -1
  40. package/dist/gateway/static/root/assets/gateway-settings-CZas_Ekx.js +1 -0
  41. package/dist/gateway/static/root/assets/{gateway-startup-retry-C8F_z865.js → gateway-startup-retry-C4rsW6vJ.js} +1 -1
  42. package/dist/gateway/static/root/assets/home-page-w3_aWeNt.js +1 -0
  43. package/dist/gateway/static/root/assets/{image-generation-api-Dc7d0_7q.js → image-generation-api-B5DXMylk.js} +1 -1
  44. package/dist/gateway/static/root/assets/{imports-page-_fMvJvzM.js → imports-page-B1JH0G5j.js} +1 -1
  45. package/dist/gateway/static/root/assets/index--3c0awkr.js +121 -0
  46. package/dist/gateway/static/root/assets/index-CNc4N4TX.css +1 -0
  47. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CHnZYx1U.js → keyboard-shortcuts-settings-DGrLJ8Yh.js} +1 -1
  48. package/dist/gateway/static/root/assets/local-app-workbench-page-BYKrJpFF.js +1 -0
  49. package/dist/gateway/static/root/assets/local-apps-Bpja8nC6.js +1 -0
  50. package/dist/gateway/static/root/assets/local-apps-page-DqjStqbL.js +1 -0
  51. package/dist/gateway/static/root/assets/{locale-store-D9krC43K.js → locale-store-BIkcRr3t.js} +1 -1
  52. package/dist/gateway/static/root/assets/{logs-page-COxOJsgX.js → logs-page-Dl4kM4Na.js} +2 -2
  53. package/dist/gateway/static/root/assets/management-settings-gCfH4cwH.js +1 -0
  54. package/dist/gateway/static/root/assets/{markdown-view-CurpvCbB.js → markdown-view-Ck_5MADq.js} +1 -1
  55. package/dist/gateway/static/root/assets/{media-plugins-CYldyH6K.js → media-plugins-DTsZqgo6.js} +1 -1
  56. package/dist/gateway/static/root/assets/messages-7VAhscYe.js +3 -0
  57. package/dist/gateway/static/root/assets/note-detail-panel-j6sioeL1.js +5 -0
  58. package/dist/gateway/static/root/assets/notes-page-CMvvHv0f.js +8 -0
  59. package/dist/gateway/static/root/assets/{page-context-capture-button-DZOiI84c.js → page-context-capture-button-DTI_g4tz.js} +1 -1
  60. package/dist/gateway/static/root/assets/{page-tabs-C-XCf9cR.js → page-tabs-CfW_Q-K5.js} +1 -1
  61. package/dist/gateway/static/root/assets/{preview-open-alternatives-CvgeoEU8.js → preview-open-alternatives-CuPN-vAn.js} +1 -1
  62. package/dist/gateway/static/root/assets/product-delivery-bv3z8Xkh.js +1 -0
  63. package/dist/gateway/static/root/assets/product-open-page-BHjxRz1E.js +1 -0
  64. package/dist/gateway/static/root/assets/project-detail-page-C9K_e-EV.js +1 -0
  65. package/dist/gateway/static/root/assets/projects-page-Bk-es4i9.js +1 -0
  66. package/dist/gateway/static/root/assets/{registry-api-cK-g8BDq.js → registry-api-BAAZUGnU.js} +1 -1
  67. package/dist/gateway/static/root/assets/remote-access-hub-CLGJNA42.js +1 -0
  68. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DlUodTo-.js → runtime-tools-settings-panel-CHJBJKL1.js} +2 -2
  69. package/dist/gateway/static/root/assets/{scenes-page-DO8vGorm.js → scenes-page-ClLAD1pz.js} +2 -2
  70. package/dist/gateway/static/root/assets/{schema-form-BfboLCeN.js → schema-form-FQAit5HL.js} +1 -1
  71. package/dist/gateway/static/root/assets/sessions-page-Xj8MkXN1.js +1 -0
  72. package/dist/gateway/static/root/assets/settings-advanced-gate-DwALV8mi.js +1 -0
  73. package/dist/gateway/static/root/assets/{settings-form-section-BytEfCGo.js → settings-form-section-BDc6bw1q.js} +1 -1
  74. package/dist/gateway/static/root/assets/{settings-page-Da2ql9KX.js → settings-page-DnhxBJjV.js} +1 -1
  75. package/dist/gateway/static/root/assets/{settings-page-layout-CBfB_7yz.js → settings-page-layout-D3KNSQ5g.js} +1 -1
  76. package/dist/gateway/static/root/assets/{setup-status-panel-DElF2sgq.js → setup-status-panel-F0rCQ-2a.js} +1 -1
  77. package/dist/gateway/static/root/assets/{share-preview-page-B8J0Saj5.js → share-preview-page-DVQCRxwK.js} +1 -1
  78. package/dist/gateway/static/root/assets/shares-settings-C7hf6Cov.js +1 -0
  79. package/dist/gateway/static/root/assets/skill-reload-api-xPrFejRE.js +1 -0
  80. package/dist/gateway/static/root/assets/{skills-page-CNQHhsiv.js → skills-page-RdDYu7Yj.js} +1 -1
  81. package/dist/gateway/static/root/assets/{skills-page.utils-B53tyGx5.js → skills-page.utils-mDwC9UJ-.js} +1 -1
  82. package/dist/gateway/static/root/assets/{system-settings-panel-0HAvlVtR.js → system-settings-panel-Bk7GrMij.js} +1 -1
  83. package/dist/gateway/static/root/assets/task-detail-page-2A966jFY.js +1 -0
  84. package/dist/gateway/static/root/assets/{tunnel-api-DJsxU6q_.js → tunnel-api-D3Aquraj.js} +1 -1
  85. package/dist/gateway/static/root/assets/{use-autosave-eIELzAOD.js → use-autosave-C1xQ-sHn.js} +1 -1
  86. package/dist/gateway/static/root/assets/user-model-page-CnBxPBVe.js +2 -0
  87. package/dist/gateway/static/root/assets/{voice-api-key-field-BJ59ZCAn.js → voice-api-key-field-DCNECvcp.js} +1 -1
  88. package/dist/gateway/static/root/assets/{voice-config-api-DBXZJWLS.js → voice-config-api-B-_niUTU.js} +1 -1
  89. package/dist/gateway/static/root/assets/{work-discovery-overlay-BpSxdIgB.js → work-discovery-overlay-BrGx_JS_.js} +1 -1
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Bhlv3VUX.js → workflow-run-setup-panel-CmmC2Pdr.js} +2 -2
  91. package/dist/gateway/static/root/assets/workflows-page-BZVpqw4T.js +6 -0
  92. package/dist/gateway/static/root/index.html +12 -11
  93. package/dist/package.js +1 -1
  94. package/dist/packages/gateway-contract/src/capabilities.js +4 -110
  95. package/dist/packages/gateway-contract/src/chat-previews.js +73 -0
  96. package/dist/packages/gateway-contract/src/index.js +6 -0
  97. package/dist/packages/gateway-contract/src/local-apps.js +215 -0
  98. package/dist/packages/gateway-contract/src/product-delivery.js +62 -17
  99. package/dist/packages/gateway-contract/src/user-turn-document.js +60 -0
  100. package/dist/src/agent/agent-manager.d.ts +1 -0
  101. package/dist/src/agent/agent-manager.js +1 -0
  102. package/dist/src/agent/embedded/transcript-runtime.d.ts +3 -0
  103. package/dist/src/agent/embedded/transcript-runtime.js +6 -0
  104. package/dist/src/agent/external-tools/cliProvider.js +4 -1
  105. package/dist/src/agent/external-tools/composio-provider.js +9 -3
  106. package/dist/src/agent/external-tools/gateway-tools.js +17 -10
  107. package/dist/src/agent/external-tools/mcp-provider.d.ts +3 -1
  108. package/dist/src/agent/external-tools/mcp-provider.js +91 -6
  109. package/dist/src/agent/external-tools/service.d.ts +2 -1
  110. package/dist/src/agent/external-tools/service.js +8 -3
  111. package/dist/src/agent/external-tools/types.d.ts +9 -0
  112. package/dist/src/agent/mcp/bundle-mcp-config.js +37 -5
  113. package/dist/src/agent/mcp/bundle-mcp-gateway.d.ts +1 -0
  114. package/dist/src/agent/mcp/bundle-mcp-gateway.js +1 -0
  115. package/dist/src/agent/mcp/bundle-mcp-names.js +2 -1
  116. package/dist/src/agent/mcp/bundle-mcp-runtime.js +33 -1
  117. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +4 -0
  118. package/dist/src/agent/mcp/index.js +1 -1
  119. package/dist/src/agent/mcp/mcp-stdio-transport.d.ts +1 -0
  120. package/dist/src/agent/mcp/mcp-stdio-transport.js +10 -0
  121. package/dist/src/agent/mcp/mcp-transport.js +12 -8
  122. package/dist/src/agent/mcp/oauth/index.js +1 -1
  123. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.d.ts +6 -1
  124. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +70 -14
  125. package/dist/src/agent/mcp/oauth/mcp-oauth-provider.js +1 -1
  126. package/dist/src/agent/mcp/oauth/mcp-oauth-session.d.ts +2 -0
  127. package/dist/src/agent/mcp/oauth/mcp-oauth-session.js +12 -0
  128. package/dist/src/agent/mcp/oauth/mcp-oauth-store.d.ts +3 -0
  129. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +13 -1
  130. package/dist/src/agent/mcp/plugin-http-fetch.d.ts +2 -0
  131. package/dist/src/agent/mcp/plugin-http-fetch.js +56 -0
  132. package/dist/src/agent/service/process-direct-streaming.js +27 -12
  133. package/dist/src/agent/service.js +1 -0
  134. package/dist/src/agent/service.types.d.ts +2 -0
  135. package/dist/src/agent/skills/hub-pull.js +1 -1
  136. package/dist/src/agent/skills/index.js +8 -1
  137. package/dist/src/agent/skills/skill-manager.d.ts +2 -0
  138. package/dist/src/agent/skills/skill-manager.js +8 -0
  139. package/dist/src/agent/skills/skill-sources.js +17 -0
  140. package/dist/src/agent/skills/types.d.ts +3 -1
  141. package/dist/src/agent/source-context/injector.js +10 -5
  142. package/dist/src/agent/source-context/types.d.ts +3 -0
  143. package/dist/src/agent/source-context/types.js +8 -2
  144. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  145. package/dist/src/agent/tool-manuals/xopc-use.js +12 -2
  146. package/dist/src/agent/tools/automation-tool.js +1 -1
  147. package/dist/src/agent/tools/factory.d.ts +1 -0
  148. package/dist/src/agent/tools/factory.js +2 -1
  149. package/dist/src/agent/tools/workflow-tool.js +1 -1
  150. package/dist/src/agent/tools/write.js +1 -1
  151. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  152. package/dist/src/agent/tools/xopc-use-tool.js +120 -12
  153. package/dist/src/chat-previews/index.d.ts +2 -0
  154. package/dist/src/chat-previews/index.js +3 -0
  155. package/dist/src/chat-previews/service.d.ts +27 -0
  156. package/dist/src/chat-previews/service.js +106 -0
  157. package/dist/src/chat-previews/store.d.ts +28 -0
  158. package/dist/src/chat-previews/store.js +77 -0
  159. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  160. package/dist/src/cli/commands/extension-agent-plugin.d.ts +8 -0
  161. package/dist/src/cli/commands/extension-agent-plugin.js +82 -0
  162. package/dist/src/cli/commands/extension-marketplace.js +44 -4
  163. package/dist/src/cli/commands/extension.js +35 -3
  164. package/dist/src/connectors/account-selection.js +1 -1
  165. package/dist/src/connectors/connection-candidates.d.ts +4 -1
  166. package/dist/src/connectors/connection-candidates.js +8 -2
  167. package/dist/src/connectors/connection-capabilities.d.ts +2 -2
  168. package/dist/src/connectors/connection-capabilities.js +3 -1
  169. package/dist/src/connectors/connection-recovery-service.d.ts +6 -1
  170. package/dist/src/connectors/connection-recovery-service.js +138 -26
  171. package/dist/src/connectors/plugin-mcp-recovery.d.ts +28 -0
  172. package/dist/src/connectors/plugin-mcp-recovery.js +90 -0
  173. package/dist/src/extensions/agent-plugins/auth.d.ts +39 -0
  174. package/dist/src/extensions/agent-plugins/auth.js +156 -0
  175. package/dist/src/extensions/agent-plugins/connection.d.ts +8 -0
  176. package/dist/src/extensions/agent-plugins/connection.js +41 -0
  177. package/dist/src/extensions/agent-plugins/health.d.ts +4 -0
  178. package/dist/src/extensions/agent-plugins/health.js +48 -0
  179. package/dist/src/extensions/agent-plugins/inventory.d.ts +53 -0
  180. package/dist/src/extensions/agent-plugins/inventory.js +34 -0
  181. package/dist/src/extensions/agent-plugins/mcp-adapter.d.ts +3 -0
  182. package/dist/src/extensions/agent-plugins/mcp-adapter.js +47 -0
  183. package/dist/src/extensions/agent-plugins/sources.d.ts +5 -0
  184. package/dist/src/extensions/agent-plugins/sources.js +72 -0
  185. package/dist/src/extensions/agent-plugins/store.d.ts +61 -0
  186. package/dist/src/extensions/agent-plugins/store.js +305 -0
  187. package/dist/src/extensions/agent-plugins/validation.d.ts +59 -0
  188. package/dist/src/extensions/agent-plugins/validation.js +211 -0
  189. package/dist/src/extensions/update.js +1 -1
  190. package/dist/src/gateway/chat-stream/mapper.js +10 -3
  191. package/dist/src/gateway/hono/routes/agent-plugins.d.ts +3 -0
  192. package/dist/src/gateway/hono/routes/agent-plugins.js +166 -0
  193. package/dist/src/gateway/hono/routes/agent-stream.js +14 -0
  194. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +4 -2
  195. package/dist/src/gateway/hono/routes/chat-previews.d.ts +3 -0
  196. package/dist/src/gateway/hono/routes/chat-previews.js +41 -0
  197. package/dist/src/gateway/hono/routes/connection-waits.js +4 -2
  198. package/dist/src/gateway/hono/routes/index.js +2 -0
  199. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  200. package/dist/src/gateway/hono/routes/local-apps.js +71 -39
  201. package/dist/src/gateway/hono/routes/mcp.js +48 -21
  202. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +4 -0
  203. package/dist/src/gateway/hono/routes/session-input-handler.js +22 -0
  204. package/dist/src/gateway/hono/routes/side-chats.js +11 -0
  205. package/dist/src/gateway/service/agent-runner.js +7 -1
  206. package/dist/src/gateway/service/marketplace-service.d.ts +1 -0
  207. package/dist/src/gateway/service/marketplace-service.js +15 -1
  208. package/dist/src/gateway/service/session-input-coordinator.js +3 -3
  209. package/dist/src/gateway/service.d.ts +5 -1
  210. package/dist/src/gateway/service.js +14 -0
  211. package/dist/src/gateway/side-chat/index.d.ts +3 -1
  212. package/dist/src/gateway/side-chat/index.js +2 -1
  213. package/dist/src/gateway/side-chat/manager.d.ts +16 -0
  214. package/dist/src/gateway/side-chat/manager.js +40 -6
  215. package/dist/src/gateway/side-chat/promotion-service.d.ts +19 -0
  216. package/dist/src/gateway/side-chat/promotion-service.js +111 -0
  217. package/dist/src/gateway/side-chat/run-service.js +1 -0
  218. package/dist/src/gateway/side-chat/types.d.ts +1 -1
  219. package/dist/src/local-apps/artifact-files.d.ts +3 -0
  220. package/dist/src/local-apps/artifact-files.js +45 -0
  221. package/dist/src/local-apps/capabilities/write.js +1 -1
  222. package/dist/src/local-apps/fix-guidance.d.ts +3 -0
  223. package/dist/src/local-apps/fix-guidance.js +75 -0
  224. package/dist/src/local-apps/index.d.ts +2 -1
  225. package/dist/src/local-apps/scaffold.d.ts +5 -0
  226. package/dist/src/local-apps/scaffold.js +18 -5
  227. package/dist/src/local-apps/service.d.ts +18 -3
  228. package/dist/src/local-apps/service.js +106 -64
  229. package/dist/src/local-apps/snapshot-store.d.ts +8 -0
  230. package/dist/src/local-apps/snapshot-store.js +68 -0
  231. package/dist/src/local-apps/types.d.ts +4 -87
  232. package/dist/src/session/client-history.d.ts +3 -1
  233. package/dist/src/session/client-history.js +10 -3
  234. package/dist/src/session/index.d.ts +1 -1
  235. package/dist/src/session/manager.d.ts +4 -0
  236. package/dist/src/session/manager.js +6 -0
  237. package/dist/src/session/session-context-for-llm.d.ts +12 -1
  238. package/dist/src/session/session-context-for-llm.js +16 -2
  239. package/dist/src/session/store.d.ts +14 -0
  240. package/dist/src/session/store.js +17 -0
  241. package/dist/src/session/stored-rows-to-file-entries.js +10 -1
  242. package/dist/src/session/transcript-outline.js +10 -3
  243. package/dist/src/storage/sqlite/connection-wait-repository.js +9 -3
  244. package/dist/src/storage/sqlite/migrations/202_chat_previews.sql +26 -0
  245. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  246. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  247. package/dist/src/storage/sqlite/row-mappers.js +6 -1
  248. package/dist/src/storage/sqlite/schema.js +1 -1
  249. package/package.json +3 -3
  250. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DWLXHWXg.js +0 -1
  251. package/dist/gateway/static/root/assets/api-Df2D6d3C.js +0 -1
  252. package/dist/gateway/static/root/assets/apps-page-BzytHIn1.js +0 -1
  253. package/dist/gateway/static/root/assets/automations-workspace-CtSV8tp-.js +0 -7
  254. package/dist/gateway/static/root/assets/browser-settings-page-DrvNA-G2.js +0 -3
  255. package/dist/gateway/static/root/assets/capabilities-D0S3DuAD.js +0 -1
  256. package/dist/gateway/static/root/assets/capabilities-settings-panel-c0k2virA.js +0 -8
  257. package/dist/gateway/static/root/assets/channels-settings-Bkl9fDHc.js +0 -1
  258. package/dist/gateway/static/root/assets/connectors-page-Dw_h-5Qh.js +0 -2
  259. package/dist/gateway/static/root/assets/device-pairing-wizard-C5f4FRpE.js +0 -1
  260. package/dist/gateway/static/root/assets/gateway-settings-D7XbH6Hk.js +0 -1
  261. package/dist/gateway/static/root/assets/home-page-CFJypY6Y.js +0 -1
  262. package/dist/gateway/static/root/assets/index-B4Vwh0H-.css +0 -1
  263. package/dist/gateway/static/root/assets/index-BNubE2Zi.js +0 -89
  264. package/dist/gateway/static/root/assets/local-app-workbench-page-BLKCFXvr.js +0 -2
  265. package/dist/gateway/static/root/assets/local-apps-page-BNFmOkxs.js +0 -1
  266. package/dist/gateway/static/root/assets/management-settings-BX5NtnQ2.js +0 -1
  267. package/dist/gateway/static/root/assets/messages-B1sTgIrE.js +0 -3
  268. package/dist/gateway/static/root/assets/note-detail-panel-DZ0IWx1R.js +0 -5
  269. package/dist/gateway/static/root/assets/notes-page-B9F1uue_.js +0 -8
  270. package/dist/gateway/static/root/assets/product-delivery-chCjIpvu.js +0 -1
  271. package/dist/gateway/static/root/assets/product-open-page-DEYWx__w.js +0 -1
  272. package/dist/gateway/static/root/assets/project-detail-page-9qMDEKVd.js +0 -1
  273. package/dist/gateway/static/root/assets/projects-page-D4UTOpEm.js +0 -1
  274. package/dist/gateway/static/root/assets/remote-access-hub-CPmOucUB.js +0 -1
  275. package/dist/gateway/static/root/assets/sessions-page-zu5P0dk5.js +0 -1
  276. package/dist/gateway/static/root/assets/settings-advanced-gate-ClEw-i1l.js +0 -1
  277. package/dist/gateway/static/root/assets/shares-settings-MLolJfoV.js +0 -1
  278. package/dist/gateway/static/root/assets/skill-reload-api-DTPsW9TY.js +0 -1
  279. package/dist/gateway/static/root/assets/task-detail-page-Dc30oS9J.js +0 -1
  280. package/dist/gateway/static/root/assets/user-model-page-Bq6ab5WJ.js +0 -2
  281. package/dist/gateway/static/root/assets/workflows-page-Ci-4HAYm.js +0 -6
@@ -0,0 +1,4 @@
1
+ export type PluginMcpHealth = 'ready' | 'authorization_required' | 'error' | 'not_tested';
2
+ export declare function readPluginMcpHealth(id: string, name: string, revision: string, stateDir?: string): PluginMcpHealth;
3
+ export declare function clearPluginMcpHealth(id: string, name: string, stateDir?: string): void;
4
+ export declare function recordPluginMcpHealth(raw: unknown, status: Exclude<PluginMcpHealth, 'not_tested'>): void;
@@ -0,0 +1,48 @@
1
+ import { init_paths_state, resolveStateDir } from "../../config/paths-state.js";
2
+ import { createLogger } from "../../utils/logger/index.js";
3
+ import { init_logger } from "../../utils/logger.js";
4
+ import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
5
+ import { pluginName } from "./validation.js";
6
+ import { join } from "node:path";
7
+ import { readFileSync, rmSync } from "node:fs";
8
+ import { createHash } from "node:crypto";
9
+ //#region src/extensions/agent-plugins/health.ts
10
+ init_paths_state();
11
+ init_write_file_atomic();
12
+ init_logger();
13
+ const log = createLogger("PluginMcpHealth");
14
+ function pathFor(id, name, stateDir) {
15
+ return join(stateDir, "plugin-health", pluginName.parse(id), `${createHash("sha256").update(name).digest("hex")}.json`);
16
+ }
17
+ function readPluginMcpHealth(id, name, revision, stateDir = resolveStateDir()) {
18
+ try {
19
+ const value = JSON.parse(readFileSync(pathFor(id, name, stateDir), "utf8"));
20
+ return value.revision === revision && [
21
+ "ready",
22
+ "authorization_required",
23
+ "error"
24
+ ].includes(value.status) ? value.status : "not_tested";
25
+ } catch {
26
+ return "not_tested";
27
+ }
28
+ }
29
+ function clearPluginMcpHealth(id, name, stateDir = resolveStateDir()) {
30
+ rmSync(pathFor(id, name, stateDir), { force: true });
31
+ }
32
+ function recordPluginMcpHealth(raw, status) {
33
+ const plugin = raw?.xopcPlugin;
34
+ if (!plugin) return;
35
+ try {
36
+ writeTextAtomicSync(pathFor(plugin.id, plugin.serverName, resolveStateDir()), JSON.stringify({
37
+ revision: plugin.revision,
38
+ status
39
+ }));
40
+ } catch (error) {
41
+ log.warn({
42
+ err: error,
43
+ pluginId: plugin.id
44
+ }, "Could not persist MCP connection status");
45
+ }
46
+ }
47
+ //#endregion
48
+ export { clearPluginMcpHealth, readPluginMcpHealth, recordPluginMcpHealth };
@@ -0,0 +1,53 @@
1
+ import { type InstalledAgentPlugin } from './store.js';
2
+ export declare function agentPluginInventoryRow(plugin: InstalledAgentPlugin): {
3
+ id: string;
4
+ pluginId: string;
5
+ format: "agent-plugin";
6
+ name: string;
7
+ version: string;
8
+ description: string;
9
+ source: string;
10
+ active: boolean;
11
+ activationEligible: boolean;
12
+ readiness: "ready" | "blocked" | "degraded" | "setup_required";
13
+ hasUi: boolean;
14
+ hasConfigSchema: boolean;
15
+ canRollback: boolean;
16
+ components: {
17
+ skills: {
18
+ name: string;
19
+ }[];
20
+ mcp: {
21
+ name: string;
22
+ id: string;
23
+ type: "sse" | "streamable-http" | "stdio";
24
+ }[];
25
+ };
26
+ diagnostics: import("./validation.js").PluginDiagnostic[];
27
+ };
28
+ export declare function listAgentPluginInventory(): {
29
+ id: string;
30
+ pluginId: string;
31
+ format: "agent-plugin";
32
+ name: string;
33
+ version: string;
34
+ description: string;
35
+ source: string;
36
+ active: boolean;
37
+ activationEligible: boolean;
38
+ readiness: "ready" | "blocked" | "degraded" | "setup_required";
39
+ hasUi: boolean;
40
+ hasConfigSchema: boolean;
41
+ canRollback: boolean;
42
+ components: {
43
+ skills: {
44
+ name: string;
45
+ }[];
46
+ mcp: {
47
+ name: string;
48
+ id: string;
49
+ type: "sse" | "streamable-http" | "stdio";
50
+ }[];
51
+ };
52
+ diagnostics: import("./validation.js").PluginDiagnostic[];
53
+ }[];
@@ -0,0 +1,34 @@
1
+ import { pluginServerId } from "./validation.js";
2
+ import { AgentPluginStore } from "./store.js";
3
+ //#region src/extensions/agent-plugins/inventory.ts
4
+ function agentPluginInventoryRow(plugin) {
5
+ return {
6
+ id: `plugin:${plugin.id}`,
7
+ pluginId: plugin.id,
8
+ format: plugin.format,
9
+ name: plugin.manifest.name,
10
+ version: plugin.manifest.version,
11
+ description: plugin.manifest.description,
12
+ source: "agent-plugin",
13
+ active: plugin.receipt.enabled && plugin.readiness !== "blocked",
14
+ activationEligible: plugin.receipt.enabled,
15
+ readiness: plugin.readiness,
16
+ hasUi: false,
17
+ hasConfigSchema: false,
18
+ canRollback: !!plugin.receipt.previous,
19
+ components: {
20
+ skills: plugin.skills.map((skill) => ({ name: skill.name })),
21
+ mcp: Object.entries(plugin.servers).map(([name, server]) => ({
22
+ name,
23
+ id: pluginServerId(plugin.id, name),
24
+ type: server.type
25
+ }))
26
+ },
27
+ diagnostics: plugin.diagnostics
28
+ };
29
+ }
30
+ function listAgentPluginInventory() {
31
+ return new AgentPluginStore().list().map(agentPluginInventoryRow);
32
+ }
33
+ //#endregion
34
+ export { agentPluginInventoryRow, listAgentPluginInventory };
@@ -0,0 +1,3 @@
1
+ import { AgentPluginStore, type InstalledAgentPlugin } from './store.js';
2
+ import { type PluginDiagnostic } from './validation.js';
3
+ export declare function materializePluginServers(plugin: InstalledAgentPlugin, store?: AgentPluginStore, diagnostics?: PluginDiagnostic[]): Record<string, Record<string, unknown>>;
@@ -0,0 +1,47 @@
1
+ import { containedPath, expandPluginVariables, pluginServerId, resolvePluginCwd } from "./validation.js";
2
+ import { AgentPluginStore } from "./store.js";
3
+ import { applyPluginAuthBinding, readPluginAuthBinding } from "./auth.js";
4
+ import { resolve } from "node:path";
5
+ //#region src/extensions/agent-plugins/mcp-adapter.ts
6
+ function materializePluginServers(plugin, store = new AgentPluginStore(), diagnostics = []) {
7
+ const root = plugin.rootDir;
8
+ const data = store.dataDir(plugin.id);
9
+ const servers = Object.create(null);
10
+ for (const [name, server] of Object.entries(plugin.servers)) try {
11
+ const origin = {
12
+ id: plugin.id,
13
+ serverName: name,
14
+ rootDir: root,
15
+ dataDir: data,
16
+ revision: plugin.receipt.revision
17
+ };
18
+ const raw = server.type !== "stdio" ? {
19
+ ...server,
20
+ xopcPlugin: origin,
21
+ ...server.type === "streamable-http" && !Object.keys(server.headers ?? {}).some((key) => key.toLowerCase() === "authorization") ? {
22
+ auth: { type: "oauth" },
23
+ xopcAutoAuth: true
24
+ } : {}
25
+ } : {
26
+ type: "stdio",
27
+ xopcPlugin: origin,
28
+ command: server.command.startsWith("./") ? containedPath(root, resolve(root, server.command)) : server.command,
29
+ args: server.args?.map((value) => expandPluginVariables(value, root, data)),
30
+ env: {
31
+ ...Object.fromEntries(Object.entries(server.env ?? {}).map(([key, value]) => [key, expandPluginVariables(value, root, data)])),
32
+ PLUGIN_ROOT: root,
33
+ PLUGIN_DATA: data
34
+ },
35
+ cwd: resolvePluginCwd(server.cwd, root, data)
36
+ };
37
+ servers[pluginServerId(plugin.id, name)] = applyPluginAuthBinding(raw, readPluginAuthBinding(store, plugin.id, name, server));
38
+ } catch (error) {
39
+ diagnostics.push({
40
+ component: `mcp:${name}`,
41
+ message: error instanceof Error ? error.message : String(error)
42
+ });
43
+ }
44
+ return servers;
45
+ }
46
+ //#endregion
47
+ export { materializePluginServers };
@@ -0,0 +1,5 @@
1
+ import type { Config } from '../../config/schema.js';
2
+ export declare function isAgentPluginArchive(buffer: Buffer): boolean;
3
+ export declare function withAgentPluginArchive<T>(buffer: Buffer, fn: (local: string) => T): T;
4
+ /** Resolve remote artifacts only for explicit inspect/install requests, never during discovery. */
5
+ export declare function withAgentPluginSource<T>(source: string, config: Config | undefined, fn: (local: string) => T): Promise<T>;
@@ -0,0 +1,72 @@
1
+ import { createPluginHttpFetch } from "../../agent/mcp/plugin-http-fetch.js";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
5
+ import AdmZip from "adm-zip";
6
+ //#region src/extensions/agent-plugins/sources.ts
7
+ function isAgentPluginArchive(buffer) {
8
+ const entries = new AdmZip(buffer).getEntries();
9
+ const paths = entries.map((entry) => entry.entryName.replace(/\/$/, ""));
10
+ const nativeMetadata = (path) => {
11
+ const entry = entries.find((item) => item.entryName === path);
12
+ if (!entry) return false;
13
+ if (entry.header.size > 1024 * 1024) throw new Error("Package metadata exceeds 1 MiB");
14
+ return Boolean(JSON.parse(entry.getData().toString("utf8"))?.xopc?.extension);
15
+ };
16
+ if (paths.includes("xopc.extension.json")) return false;
17
+ if (paths.includes("plugin.json")) return !nativeMetadata("package.json");
18
+ const first = new Set(paths.map((path) => path.split("/")[0]));
19
+ if (first.size !== 1) return false;
20
+ const root = [...first][0];
21
+ return paths.includes(`${root}/plugin.json`) && !paths.includes(`${root}/xopc.extension.json`) && !nativeMetadata(`${root}/package.json`);
22
+ }
23
+ function withAgentPluginArchive(buffer, fn) {
24
+ const dir = mkdtempSync(join(tmpdir(), "xopc-plugin-download-"));
25
+ try {
26
+ const file = join(dir, "plugin.zip");
27
+ writeFileSync(file, buffer);
28
+ return fn(file);
29
+ } finally {
30
+ rmSync(dir, {
31
+ recursive: true,
32
+ force: true
33
+ });
34
+ }
35
+ }
36
+ /** Resolve remote artifacts only for explicit inspect/install requests, never during discovery. */
37
+ async function withAgentPluginSource(source, config, fn) {
38
+ if (!source.startsWith("https://") && !source.startsWith("store:")) return fn(source);
39
+ let buffer;
40
+ if (source.startsWith("store:")) {
41
+ const { resolveExtensionZipDownloadUrl, resolveExtensionsStoreBaseUrl, downloadExtensionStoreZipBuffer, verifyStoreArtifactSha256 } = await import("../../agent/skills/marketplace/adapters/store/store-api-client.js");
42
+ const spec = source.slice(6);
43
+ const match = /^([a-z0-9.-]+)(?:@([^/]+))?$/.exec(spec);
44
+ if (!match) throw new Error("Expected store:<package>[@version]");
45
+ const base = resolveExtensionsStoreBaseUrl(config);
46
+ const artifact = await resolveExtensionZipDownloadUrl(base, match[1], match[2]);
47
+ buffer = await downloadExtensionStoreZipBuffer(base, artifact.downloadUrl);
48
+ verifyStoreArtifactSha256(buffer, artifact.sha256);
49
+ } else {
50
+ const url = new URL(source);
51
+ const response = await createPluginHttpFetch(url, {})(url, { signal: AbortSignal.timeout(3e4) });
52
+ if (!response.ok || !response.body) throw new Error(`Plugin download failed (${response.status})`);
53
+ const reader = response.body.getReader();
54
+ const chunks = [];
55
+ let size = 0;
56
+ try {
57
+ for (;;) {
58
+ const { done, value } = await reader.read();
59
+ if (done) break;
60
+ size += value.length;
61
+ if (size > 50 * 1024 * 1024) throw new Error("Plugin download exceeds 50 MiB");
62
+ chunks.push(Buffer.from(value));
63
+ }
64
+ } finally {
65
+ await reader.cancel();
66
+ }
67
+ buffer = Buffer.concat(chunks);
68
+ }
69
+ return withAgentPluginArchive(buffer, fn);
70
+ }
71
+ //#endregion
72
+ export { isAgentPluginArchive, withAgentPluginArchive, withAgentPluginSource };
@@ -0,0 +1,61 @@
1
+ import { z } from 'zod';
2
+ import { type PluginInspection } from './validation.js';
3
+ declare const receiptSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ revision: z.ZodString;
6
+ source: z.ZodString;
7
+ installedAt: z.ZodString;
8
+ enabled: z.ZodBoolean;
9
+ integrity: z.ZodString;
10
+ capabilities: z.ZodArray<z.ZodString>;
11
+ previous: z.ZodOptional<z.ZodObject<{
12
+ id: z.ZodString;
13
+ revision: z.ZodString;
14
+ source: z.ZodString;
15
+ installedAt: z.ZodString;
16
+ enabled: z.ZodBoolean;
17
+ integrity: z.ZodString;
18
+ capabilities: z.ZodArray<z.ZodString>;
19
+ }, z.core.$strip>>;
20
+ }, z.core.$strip>;
21
+ export type PluginReceipt = z.infer<typeof receiptSchema>;
22
+ export interface InstalledAgentPlugin extends PluginInspection {
23
+ id: string;
24
+ format: 'agent-plugin';
25
+ receipt: PluginReceipt;
26
+ readiness: 'ready' | 'setup_required' | 'degraded' | 'blocked';
27
+ }
28
+ export interface PluginInstallPlan extends PluginInspection {
29
+ integrity: string;
30
+ reviewHash: string;
31
+ addedCapabilities: string[];
32
+ installed: boolean;
33
+ }
34
+ export declare class AgentPluginStore {
35
+ readonly stateDir: string;
36
+ constructor(stateDir?: string);
37
+ private receiptsDir;
38
+ revisionKey(): string;
39
+ dataDir(id: string): string;
40
+ private revisionDir;
41
+ private receiptPath;
42
+ receipt(id: string): PluginReceipt | undefined;
43
+ private write;
44
+ private mutate;
45
+ get(id: string): InstalledAgentPlugin | undefined;
46
+ list(): InstalledAgentPlugin[];
47
+ active(): InstalledAgentPlugin[];
48
+ inspect(source: string): PluginInstallPlan;
49
+ private plan;
50
+ install(source: string, options?: {
51
+ reviewHash?: string;
52
+ replace?: boolean;
53
+ expectedId?: string;
54
+ sourceLabel?: string;
55
+ }): InstalledAgentPlugin;
56
+ setEnabled(id: string, enabled: boolean): InstalledAgentPlugin;
57
+ rollback(id: string): InstalledAgentPlugin;
58
+ remove(id: string, removeData?: boolean): void;
59
+ private withSource;
60
+ }
61
+ export {};
@@ -0,0 +1,305 @@
1
+ import { init_paths_state, resolveStateDir } from "../../config/paths-state.js";
2
+ import { createLogger } from "../../utils/logger/index.js";
3
+ import { init_logger } from "../../utils/logger.js";
4
+ import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
5
+ import { computeExtensionDirectoryIntegrity } from "../lockfile.js";
6
+ import { containedPath, inspectAgentPlugin, pluginName } from "./validation.js";
7
+ import { readPluginMcpHealth } from "./health.js";
8
+ import { tmpdir } from "node:os";
9
+ import { dirname, join, resolve } from "node:path";
10
+ import { cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
11
+ import { createHash, randomUUID } from "node:crypto";
12
+ import { z } from "zod";
13
+ import AdmZip from "adm-zip";
14
+ import lockfile from "proper-lockfile";
15
+ //#region src/extensions/agent-plugins/store.ts
16
+ init_paths_state();
17
+ init_write_file_atomic();
18
+ init_logger();
19
+ const receiptFields = z.object({
20
+ id: pluginName,
21
+ revision: z.string().uuid(),
22
+ source: z.string(),
23
+ installedAt: z.string(),
24
+ enabled: z.boolean(),
25
+ integrity: z.string(),
26
+ capabilities: z.array(z.string())
27
+ });
28
+ const receiptSchema = receiptFields.extend({ previous: receiptFields.optional() });
29
+ const log = createLogger("AgentPlugins");
30
+ var AgentPluginStore = class {
31
+ constructor(stateDir = resolveStateDir()) {
32
+ this.stateDir = stateDir;
33
+ }
34
+ receiptsDir() {
35
+ return join(this.stateDir, "plugin-receipts");
36
+ }
37
+ revisionKey() {
38
+ if (!existsSync(this.receiptsDir())) return "";
39
+ return readdirSync(this.receiptsDir()).filter((name) => name.endsWith(".json")).sort().map((name) => {
40
+ try {
41
+ return `${name}:${statSync(join(this.receiptsDir(), name)).mtimeMs}`;
42
+ } catch {
43
+ return "";
44
+ }
45
+ }).join("|");
46
+ }
47
+ dataDir(id) {
48
+ return containedPath(this.stateDir, join(this.stateDir, "plugin-data", pluginName.parse(id)));
49
+ }
50
+ revisionDir(id, revision) {
51
+ return join(this.stateDir, "plugins", pluginName.parse(id), z.string().uuid().parse(revision));
52
+ }
53
+ receiptPath(id) {
54
+ return join(this.receiptsDir(), `${pluginName.parse(id)}.json`);
55
+ }
56
+ receipt(id) {
57
+ const path = this.receiptPath(id);
58
+ if (!existsSync(path)) return void 0;
59
+ const receipt = receiptSchema.parse(JSON.parse(readFileSync(path, "utf8")));
60
+ if (receipt.id !== id) throw new Error("Plugin receipt identity mismatch");
61
+ return receipt;
62
+ }
63
+ write(receipt) {
64
+ writeTextAtomicSync(this.receiptPath(receipt.id), JSON.stringify(receipt));
65
+ }
66
+ mutate(fn) {
67
+ mkdirSync(this.receiptsDir(), {
68
+ recursive: true,
69
+ mode: 448
70
+ });
71
+ const release = lockfile.lockSync(this.receiptsDir());
72
+ try {
73
+ return fn();
74
+ } finally {
75
+ release();
76
+ }
77
+ }
78
+ get(id) {
79
+ const receipt = this.receipt(id);
80
+ if (!receipt) return void 0;
81
+ const rootDir = this.revisionDir(id, receipt.revision);
82
+ try {
83
+ validatePackageTree(rootDir);
84
+ const inspection = inspectAgentPlugin(rootDir, this.dataDir(id));
85
+ const valid = computeExtensionDirectoryIntegrity(rootDir) === receipt.integrity;
86
+ if (!valid) inspection.diagnostics.push({
87
+ component: "package",
88
+ message: "Installed files differ from the reviewed package"
89
+ });
90
+ const health = Object.keys(inspection.servers).map((name) => readPluginMcpHealth(id, name, receipt.revision, this.stateDir));
91
+ const readiness = !valid ? "blocked" : inspection.diagnostics.length || health.includes("error") ? "degraded" : health.some((status) => status !== "ready") ? "setup_required" : "ready";
92
+ return {
93
+ ...inspection,
94
+ id,
95
+ receipt,
96
+ format: "agent-plugin",
97
+ readiness
98
+ };
99
+ } catch (error) {
100
+ return {
101
+ id,
102
+ receipt,
103
+ format: "agent-plugin",
104
+ readiness: "blocked",
105
+ rootDir,
106
+ manifest: {
107
+ $schema: "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
108
+ name: id
109
+ },
110
+ skills: [],
111
+ servers: {},
112
+ capabilities: [],
113
+ diagnostics: [{
114
+ component: "package",
115
+ message: error instanceof Error ? error.message : String(error)
116
+ }]
117
+ };
118
+ }
119
+ }
120
+ list() {
121
+ if (!existsSync(this.receiptsDir())) return [];
122
+ return readdirSync(this.receiptsDir()).filter((name) => name.endsWith(".json")).sort().flatMap((name) => {
123
+ const id = name.slice(0, -5);
124
+ if (!pluginName.safeParse(id).success) return [];
125
+ try {
126
+ const plugin = this.get(id);
127
+ return plugin ? [plugin] : [];
128
+ } catch (error) {
129
+ log.warn({
130
+ err: error,
131
+ pluginId: id
132
+ }, "Invalid Agent Plugin receipt; package disabled");
133
+ return [];
134
+ }
135
+ });
136
+ }
137
+ active() {
138
+ if (["1", "true"].includes(process.env.XOPC_SKIP_EXTENSIONS ?? "")) return [];
139
+ return this.list().filter((p) => p.receipt.enabled && p.readiness !== "blocked");
140
+ }
141
+ inspect(source) {
142
+ return this.withSource(source, (root) => this.plan(root));
143
+ }
144
+ plan(root) {
145
+ validatePackageTree(root);
146
+ const initial = inspectAgentPlugin(root);
147
+ const inspection = inspectAgentPlugin(root, this.dataDir(initial.manifest.name));
148
+ const integrity = computeExtensionDirectoryIntegrity(root);
149
+ const current = this.receipt(inspection.manifest.name);
150
+ const addedCapabilities = inspection.capabilities.filter((c) => !current?.capabilities.includes(c));
151
+ const reviewHash = createHash("sha256").update(JSON.stringify([integrity, inspection.capabilities])).digest("hex");
152
+ return {
153
+ ...inspection,
154
+ integrity,
155
+ reviewHash,
156
+ addedCapabilities,
157
+ installed: !!current
158
+ };
159
+ }
160
+ install(source, options = {}) {
161
+ return this.mutate(() => this.withSource(source, (root) => {
162
+ const plan = this.plan(root);
163
+ const id = plan.manifest.name;
164
+ if (options.expectedId && options.expectedId !== id) throw new Error("Update package identity does not match installed plugin");
165
+ const current = this.receipt(id);
166
+ if (current && !options.replace) throw new Error("Plugin already installed; use update");
167
+ if ((!current || plan.addedCapabilities.length > 0) && options.reviewHash !== plan.reviewHash) throw new Error("Package capability review is required");
168
+ if (options.reviewHash && options.reviewHash !== plan.reviewHash) throw new Error("Package changed after review; inspect again");
169
+ validatePackageTree(root);
170
+ const revision = randomUUID();
171
+ const target = this.revisionDir(id, revision);
172
+ mkdirSync(dirname(target), { recursive: true });
173
+ try {
174
+ cpSync(root, target, {
175
+ recursive: true,
176
+ dereference: false,
177
+ verbatimSymlinks: true
178
+ });
179
+ validatePackageTree(target);
180
+ const installed = inspectAgentPlugin(target, this.dataDir(id));
181
+ const integrity = computeExtensionDirectoryIntegrity(target);
182
+ if (integrity !== plan.integrity) throw new Error("Package changed during installation");
183
+ const label = options.sourceLabel ?? source;
184
+ this.write({
185
+ id,
186
+ revision,
187
+ source: /^(https:\/\/|store:)/.test(label) ? label : resolve(label),
188
+ installedAt: (/* @__PURE__ */ new Date()).toISOString(),
189
+ enabled: current?.enabled ?? false,
190
+ integrity,
191
+ capabilities: installed.capabilities,
192
+ previous: current ? receiptFields.parse(current) : void 0
193
+ });
194
+ } catch (error) {
195
+ rmSync(target, {
196
+ recursive: true,
197
+ force: true
198
+ });
199
+ throw error;
200
+ }
201
+ return this.get(id);
202
+ }));
203
+ }
204
+ setEnabled(id, enabled) {
205
+ return this.mutate(() => {
206
+ const plugin = this.get(id);
207
+ if (!plugin) throw new Error("Plugin not installed");
208
+ if (enabled && plugin.readiness === "blocked") throw new Error("Repair the plugin before enabling it");
209
+ this.write({
210
+ ...plugin.receipt,
211
+ enabled
212
+ });
213
+ return this.get(id);
214
+ });
215
+ }
216
+ rollback(id) {
217
+ return this.mutate(() => {
218
+ const receipt = this.receipt(id);
219
+ const previous = receipt?.previous;
220
+ if (!receipt || !previous || previous.id !== id) throw new Error("No rollback revision available");
221
+ if (computeExtensionDirectoryIntegrity(this.revisionDir(id, previous.revision)) !== previous.integrity) throw new Error("Rollback revision integrity failed");
222
+ this.write({
223
+ ...previous,
224
+ enabled: receipt.enabled,
225
+ previous: receiptFields.parse(receipt)
226
+ });
227
+ return this.get(id);
228
+ });
229
+ }
230
+ remove(id, removeData = false) {
231
+ this.mutate(() => {
232
+ if (!this.receipt(id)) throw new Error("Plugin not installed");
233
+ rmSync(this.receiptPath(id));
234
+ rmSync(join(this.stateDir, "plugins", pluginName.parse(id)), {
235
+ recursive: true,
236
+ force: true
237
+ });
238
+ rmSync(join(this.stateDir, "plugin-health", id), {
239
+ recursive: true,
240
+ force: true
241
+ });
242
+ if (removeData) rmSync(this.dataDir(id), {
243
+ recursive: true,
244
+ force: true
245
+ });
246
+ });
247
+ }
248
+ withSource(source, fn) {
249
+ const path = resolve(source);
250
+ if (statSync(path).isDirectory()) return fn(path);
251
+ if (statSync(path).size > 50 * 1024 * 1024) throw new Error("Plugin archive exceeds 50 MiB");
252
+ const temp = mkdtempSync(join(tmpdir(), "xopc-agent-plugin-"));
253
+ try {
254
+ const entries = new AdmZip(path).getEntries();
255
+ if (entries.length > 1e4) throw new Error("Too many archive entries");
256
+ let bytes = 0;
257
+ const paths = /* @__PURE__ */ new Set();
258
+ for (const entry of entries) {
259
+ if (entry.entryName.includes("\\") || entry.entryName.startsWith("/") || /^[a-z]:/i.test(entry.entryName)) throw new Error("Unsafe archive path");
260
+ const target = containedPath(temp, join(temp, entry.entryName));
261
+ if (paths.has(target)) throw new Error("Duplicate archive path");
262
+ paths.add(target);
263
+ const mode = entry.attr >>> 16 & 65535;
264
+ if ((mode & 61440) === 40960) throw new Error("Archive symlinks are not supported");
265
+ bytes += entry.header.size;
266
+ if (bytes > 100 * 1024 * 1024) throw new Error("Expanded archive exceeds 100 MiB");
267
+ if (entry.isDirectory) mkdirSync(target, { recursive: true });
268
+ else {
269
+ mkdirSync(dirname(target), { recursive: true });
270
+ const data = entry.getData();
271
+ if (data.length !== entry.header.size) throw new Error("Archive size mismatch");
272
+ writeFileSync(target, data, {
273
+ mode: mode & 73 ? 493 : 420,
274
+ flag: "wx"
275
+ });
276
+ }
277
+ }
278
+ const children = readdirSync(temp);
279
+ return fn(existsSync(join(temp, "plugin.json")) ? temp : children.length === 1 ? join(temp, children[0]) : temp);
280
+ } finally {
281
+ rmSync(temp, {
282
+ recursive: true,
283
+ force: true
284
+ });
285
+ }
286
+ }
287
+ };
288
+ function validatePackageTree(root) {
289
+ let files = 0;
290
+ let bytes = 0;
291
+ const visit = (path, ancestors) => {
292
+ const safe = containedPath(root, path);
293
+ if (ancestors.has(safe)) throw new Error("Cyclic package symlink");
294
+ const stat = statSync(safe);
295
+ if (++files > 1e4 || (bytes += stat.isFile() ? stat.size : 0) > 100 * 1024 * 1024) throw new Error("Package exceeds limits");
296
+ if (stat.isDirectory()) {
297
+ const next = new Set([...ancestors, safe]);
298
+ for (const name of readdirSync(safe)) visit(join(path, name), next);
299
+ } else if (!stat.isFile()) throw new Error("Unsupported package file type");
300
+ if (lstatSync(path).isFile() && stat.nlink > 1) throw new Error("Package hardlinks are not supported");
301
+ };
302
+ visit(root, /* @__PURE__ */ new Set());
303
+ }
304
+ //#endregion
305
+ export { AgentPluginStore };