@xopcai/xopc 0.0.323 → 0.0.325

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 (572) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/extensions/weixin/src/plugin.js +1 -9
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DFzmThVi.js → agent-avatar-dicebear-CxfXpPWs.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CDHe8gJf.js +1 -0
  6. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DYFYiuig.js → agent-plugin-dialog-DMv-udoZ.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-BqIlB5Co.js → agents-D_xOAXgj.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-BgvMRGWe.js → app-management-settings-panel-p7fZB4dT.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-CliHU03A.js → appearance-settings-C-clVcfp.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-Dz2g7eAN.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-DnuPpm0u.js → archive-plugin-Xm6xChUX.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-BiwaK0ie.js → attachment-load-Di8kuG4L.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-CJSISGQH.js → automations-page-GUZgDhKj.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-BUZhG9aJ.js +7 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-KDjduQZO.js → binary-plugins-OCrDjC9O.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-bclvgove.js → block-editor-m9tqvu7x.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-CfQ2T9t6.js → browser-automation-inputs-DSWXq9lI.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-Cxq38Nnp.js → browser-automations-page-DuOaridE.js} +2 -2
  19. package/dist/gateway/static/root/assets/browser-settings-page-D2_PgHep.js +3 -0
  20. package/dist/gateway/static/root/assets/capabilities-sAZT4brT.js +1 -0
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-7Y_pJqyt.js +8 -0
  22. package/dist/gateway/static/root/assets/channels-settings-B-Igy1ro.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-DKQC62nQ.js → chat-terminal-dock-BfnVh8oo.js} +1 -1
  24. package/dist/gateway/static/root/assets/{computer-settings-page-D1whpIqL.js → computer-settings-page-aRG2lU4w.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connector-service-page-BAuYTgf5.js → connector-service-page-B5EhnfJH.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-7HfRt1LW.js +2 -0
  27. package/dist/gateway/static/root/assets/date-picker-CtDyij_x.js +1 -0
  28. package/dist/gateway/static/root/assets/{dependency-picker-DOuVO2M1.js → dependency-picker-z6ouWxmz.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-D9tu6Bhu.js → desktop-pet-BsIYCAkG.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-CQPXub2f.js → desktop-pet-settings-z-0aQ5ct.js} +1 -1
  31. package/dist/gateway/static/root/assets/{device-pairing-wizard-DxkOYSut.js → device-pairing-wizard-DlmhQvY5.js} +1 -1
  32. package/dist/gateway/static/root/assets/dist-3h6cXXhT.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-CtWClPz-.js → extension-debug-page-Ct9pABNW.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-BHh9HLCz.js → extension-page-BktsR4hj.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-BdT3v5Uh.js → extension-settings-page-BQJc-vXH.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-1eqyz9vZ.js → gateway-config-swr-CoQVulMd.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-settings-CZas_Ekx.js → gateway-settings-BfDVlvy6.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-C4rsW6vJ.js → gateway-startup-retry-B5GJ-CQV.js} +1 -1
  39. package/dist/gateway/static/root/assets/home-page-CI_eQTPL.js +1 -0
  40. package/dist/gateway/static/root/assets/{image-generation-api-B5DXMylk.js → image-generation-api-DvWDkbk1.js} +1 -1
  41. package/dist/gateway/static/root/assets/{imports-page-B1JH0G5j.js → imports-page-DFpQfHVU.js} +1 -1
  42. package/dist/gateway/static/root/assets/index-19rMUT3d.js +121 -0
  43. package/dist/gateway/static/root/assets/{index-CNc4N4TX.css → index-BKL5tg2f.css} +1 -1
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DGrLJ8Yh.js → keyboard-shortcuts-settings-ctJLm8TP.js} +1 -1
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-C9kaP3Dy.js +1 -0
  46. package/dist/gateway/static/root/assets/{local-apps-page-DqjStqbL.js → local-apps-page-BxC_LTqq.js} +1 -1
  47. package/dist/gateway/static/root/assets/{locale-store-BIkcRr3t.js → locale-store-BPZR8x9b.js} +1 -1
  48. package/dist/gateway/static/root/assets/logs-page-Ok5SpG-G.js +2 -0
  49. package/dist/gateway/static/root/assets/{management-settings-gCfH4cwH.js → management-settings-aOzRaQHM.js} +1 -1
  50. package/dist/gateway/static/root/assets/{markdown-view-Ck_5MADq.js → markdown-view-Dft8ASFD.js} +1 -1
  51. package/dist/gateway/static/root/assets/{media-plugins-DTsZqgo6.js → media-plugins-ni5zJ4Ok.js} +1 -1
  52. package/dist/gateway/static/root/assets/messages-kFWhF6_t.js +3 -0
  53. package/dist/gateway/static/root/assets/note-detail-panel-C9OEltN9.js +5 -0
  54. package/dist/gateway/static/root/assets/notes-page-Dj9rMgdi.js +8 -0
  55. package/dist/gateway/static/root/assets/{page-context-capture-button-DTI_g4tz.js → page-context-capture-button-BJA3d8vU.js} +1 -1
  56. package/dist/gateway/static/root/assets/{page-tabs-CfW_Q-K5.js → page-tabs-Dyc3wKkl.js} +1 -1
  57. package/dist/gateway/static/root/assets/popover-select-DcsFzD_i.js +1 -0
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-CuPN-vAn.js → preview-open-alternatives-tIOIQbNX.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-BHjxRz1E.js → product-open-page-DQctU8z3.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-Dy-EwZcc.js +1 -0
  61. package/dist/gateway/static/root/assets/{projects-page-Bk-es4i9.js → projects-page-JaGKa6rM.js} +1 -1
  62. package/dist/gateway/static/root/assets/{registry-api-BAAZUGnU.js → registry-api-DWWO6ajd.js} +1 -1
  63. package/dist/gateway/static/root/assets/remote-access-hub-Cb8-nd60.js +1 -0
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CHJBJKL1.js → runtime-tools-settings-panel-xhOSYfiX.js} +1 -1
  65. package/dist/gateway/static/root/assets/scenes-page-ClBkFdRY.js +2 -0
  66. package/dist/gateway/static/root/assets/{schema-form-FQAit5HL.js → schema-form-z8IeSdBp.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-BYW5l_nY.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-CDNwmXuH.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-form-section-BDc6bw1q.js → settings-form-section-BXTJAser.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-DnhxBJjV.js → settings-page-Br9no5e4.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-page-layout-D3KNSQ5g.js → settings-page-layout-D6745w0p.js} +1 -1
  72. package/dist/gateway/static/root/assets/setup-status-panel-D2N9764S.js +1 -0
  73. package/dist/gateway/static/root/assets/{share-preview-page-DVQCRxwK.js → share-preview-page-CE0SER59.js} +1 -1
  74. package/dist/gateway/static/root/assets/shares-settings-Dk3_QOKQ.js +1 -0
  75. package/dist/gateway/static/root/assets/skill-reload-api-CPt61fEv.js +1 -0
  76. package/dist/gateway/static/root/assets/skills-page-Db6PB2C6.js +2 -0
  77. package/dist/gateway/static/root/assets/{skills-page.utils-mDwC9UJ-.js → skills-page.utils-DrtW5FBy.js} +1 -1
  78. package/dist/gateway/static/root/assets/{system-settings-panel-Bk7GrMij.js → system-settings-panel-CuY1Zh5s.js} +1 -1
  79. package/dist/gateway/static/root/assets/task-detail-page-o7RiDUMi.js +1 -0
  80. package/dist/gateway/static/root/assets/{tunnel-api-D3Aquraj.js → tunnel-api-PGHDgvWb.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-autosave-C1xQ-sHn.js → use-autosave-B55oBQUt.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-model-page-DspelwAa.js +2 -0
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-DCNECvcp.js → voice-api-key-field-By6Lgbse.js} +1 -1
  84. package/dist/gateway/static/root/assets/{voice-config-api-B-_niUTU.js → voice-config-api-BaxITrwZ.js} +1 -1
  85. package/dist/gateway/static/root/assets/{work-discovery-overlay-BrGx_JS_.js → work-discovery-overlay-DdhgIlyf.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CmmC2Pdr.js → workflow-run-setup-panel-BOJYQaxX.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-6ObD0IQZ.js +6 -0
  88. package/dist/gateway/static/root/index.html +11 -10
  89. package/dist/package.js +1 -1
  90. package/dist/packages/gateway-contract/src/home.js +284 -55
  91. package/dist/packages/gateway-contract/src/index.js +0 -2
  92. package/dist/packages/gateway-contract/src/notifications.js +3 -10
  93. package/dist/src/activity/emitter.js +2 -1
  94. package/dist/src/activity/service.js +2 -1
  95. package/dist/src/agent/agent-manager.d.ts +3 -2
  96. package/dist/src/agent/agent-manager.js +36 -44
  97. package/dist/src/agent/agent-scope.d.ts +19 -48
  98. package/dist/src/agent/agent-scope.js +47 -169
  99. package/dist/src/agent/background-review/run-background-review.js +5 -4
  100. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  101. package/dist/src/agent/commands/command-registry.js +7 -3
  102. package/dist/src/agent/context/coordinator.js +1 -1
  103. package/dist/src/agent/context/execution-context.js +2 -1
  104. package/dist/src/agent/context/execution-scope.js +2 -1
  105. package/dist/src/agent/context/workspace-seed.d.ts +1 -2
  106. package/dist/src/agent/context/workspace-seed.js +3 -3
  107. package/dist/src/agent/context/workspace-state.js +1 -1
  108. package/dist/src/agent/embedded/run-for-session.js +2 -2
  109. package/dist/src/agent/embedded/run-turn.js +2 -1
  110. package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js +2 -1
  111. package/dist/src/agent/external-tools/cliProvider.js +2 -1
  112. package/dist/src/agent/external-tools/composio-provider.js +2 -1
  113. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  114. package/dist/src/agent/external-tools/index.js +2 -3
  115. package/dist/src/agent/external-tools/mcp-provider.js +2 -2
  116. package/dist/src/agent/image/tool-model-config.js +4 -5
  117. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  118. package/dist/src/agent/ipc/bus.js +1 -1
  119. package/dist/src/agent/ipc/socket.js +3 -3
  120. package/dist/src/agent/media-generation/runtime-shared.d.ts +1 -1
  121. package/dist/src/agent/media-generation/runtime-shared.js +1 -1
  122. package/dist/src/agent/memory/plugin-discovery.js +1 -2
  123. package/dist/src/agent/models/manager.d.ts +1 -1
  124. package/dist/src/agent/models/manager.js +2 -2
  125. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +1 -1
  126. package/dist/src/agent/prompt/response-language.js +2 -1
  127. package/dist/src/agent/prompt/service-prompt-builder.js +6 -3
  128. package/dist/src/agent/prompt/system-prompt.js +2 -1
  129. package/dist/src/agent/reply/post-compaction-context.js +2 -2
  130. package/dist/src/agent/service/build-direct-message-content.js +1 -1
  131. package/dist/src/agent/service/direct-turn-helpers.js +2 -1
  132. package/dist/src/agent/service/parse-outbound-session-key.js +2 -1
  133. package/dist/src/agent/service/process-direct-streaming.js +3 -2
  134. package/dist/src/agent/service/webchat-tts.js +2 -1
  135. package/dist/src/agent/service.d.ts +1 -1
  136. package/dist/src/agent/service.js +12 -11
  137. package/dist/src/agent/service.types.d.ts +2 -0
  138. package/dist/src/agent/session/session-inspector.js +4 -5
  139. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +5 -0
  140. package/dist/src/agent/starter-agents.d.ts +4 -5
  141. package/dist/src/agent/starter-agents.js +21 -20
  142. package/dist/src/agent/tasks/task-judge-service.js +2 -2
  143. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  144. package/dist/src/agent/tool-manuals/xopc-use.js +31 -1
  145. package/dist/src/agent/tools/delegation-parent-policy.js +2 -3
  146. package/dist/src/agent/tools/factory.d.ts +2 -0
  147. package/dist/src/agent/tools/factory.js +10 -9
  148. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  149. package/dist/src/agent/tools/workflow-tool.js +2 -3
  150. package/dist/src/agent/tools/xopc-use-tool.d.ts +3 -2
  151. package/dist/src/agent/tools/xopc-use-tool.js +54 -6
  152. package/dist/src/agent/workflow/workflow-child-tools.js +1 -2
  153. package/dist/src/agent/workspace-runtime/registry.d.ts +1 -1
  154. package/dist/src/agent/workspace-runtime/registry.js +2 -2
  155. package/dist/src/agent-catalog/capabilities.d.ts +3 -0
  156. package/dist/src/agent-catalog/capabilities.js +238 -0
  157. package/dist/src/agent-catalog/id.d.ts +15 -0
  158. package/dist/src/agent-catalog/id.js +101 -0
  159. package/dist/src/agent-catalog/index.d.ts +6 -0
  160. package/dist/src/agent-catalog/index.js +10 -0
  161. package/dist/src/agent-catalog/migrations/legacy-config-cutover.d.ts +11 -0
  162. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +195 -0
  163. package/dist/src/agent-catalog/repository.d.ts +39 -0
  164. package/dist/src/agent-catalog/repository.js +319 -0
  165. package/dist/src/agent-catalog/service.d.ts +33 -0
  166. package/dist/src/agent-catalog/service.js +202 -0
  167. package/dist/src/agent-catalog/test-support.d.ts +14 -0
  168. package/dist/src/agent-catalog/test-support.js +34 -0
  169. package/dist/src/agent-catalog/types.d.ts +26 -0
  170. package/dist/src/agent-catalog/types.js +1 -0
  171. package/dist/src/agent-config/index.js +2 -2
  172. package/dist/src/agent-config/schema.d.ts +1 -172
  173. package/dist/src/agent-config/schema.js +2 -41
  174. package/dist/src/auth/credentials.js +3 -3
  175. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  176. package/dist/src/auth/sync-provider-auth.d.ts +1 -1
  177. package/dist/src/auth/sync-provider-auth.js +5 -9
  178. package/dist/src/automations/capabilities/drafts.js +8 -7
  179. package/dist/src/automations/service/action-executor.js +2 -1
  180. package/dist/src/bootstrap/application-state.d.ts +10 -0
  181. package/dist/src/bootstrap/application-state.js +26 -0
  182. package/dist/src/browser/automations/repository.js +2 -1
  183. package/dist/src/browser/automations/schema.d.ts +1 -1
  184. package/dist/src/browser/automations/service.d.ts +1 -1
  185. package/dist/src/browser/native-messaging-host.js +5 -4
  186. package/dist/src/browser/providers/extension.js +4 -2
  187. package/dist/src/browser/providers/realtime-extension.js +2 -1
  188. package/dist/src/capabilities/readiness/from-config.js +7 -4
  189. package/dist/src/capabilities/runtime/dispatcher.d.ts +1 -0
  190. package/dist/src/capabilities/runtime/dispatcher.js +10 -4
  191. package/dist/src/capabilities/runtime/product.js +2 -0
  192. package/dist/src/channels/catalog/channel-catalog-service.js +7 -13
  193. package/dist/src/chat-commands/agent-edit.js +4 -3
  194. package/dist/src/chat-commands/builtins/config.js +6 -8
  195. package/dist/src/chat-commands/builtins/review.js +1 -1
  196. package/dist/src/chat-commands/builtins/workflow.js +1 -1
  197. package/dist/src/chat-commands/config-paths.js +1 -1
  198. package/dist/src/chat-commands/context.js +2 -3
  199. package/dist/src/chat-previews/store.js +2 -1
  200. package/dist/src/cli/command-manifest.js +1 -1
  201. package/dist/src/cli/commands/agent.js +4 -4
  202. package/dist/src/cli/commands/agents.d.ts +1 -1
  203. package/dist/src/cli/commands/agents.js +36 -48
  204. package/dist/src/cli/commands/auth.js +2 -1
  205. package/dist/src/cli/commands/browser-cli-helpers.js +1 -2
  206. package/dist/src/cli/commands/channels.js +2 -4
  207. package/dist/src/cli/commands/config.js +4 -5
  208. package/dist/src/cli/commands/connectors.js +1 -2
  209. package/dist/src/cli/commands/doctor/checks/channel-config.js +2 -4
  210. package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js +1 -2
  211. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -2
  212. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -2
  213. package/dist/src/cli/commands/doctor/checks/database-schema.js +4 -4
  214. package/dist/src/cli/commands/doctor/checks/gateway-health.js +1 -2
  215. package/dist/src/cli/commands/doctor/checks/gateway-service.js +1 -2
  216. package/dist/src/cli/commands/doctor/checks/provider-auth.js +13 -11
  217. package/dist/src/cli/commands/doctor/checks/security-audit.js +1 -2
  218. package/dist/src/cli/commands/doctor/checks/session-integrity.js +3 -3
  219. package/dist/src/cli/commands/doctor/checks/tool-runtimes.js +1 -2
  220. package/dist/src/cli/commands/doctor/checks/workspace-status.js +5 -7
  221. package/dist/src/cli/commands/extension-agent-plugin.js +1 -2
  222. package/dist/src/cli/commands/extension-dev.js +2 -4
  223. package/dist/src/cli/commands/extension-marketplace.js +1 -2
  224. package/dist/src/cli/commands/extension-pack.js +1 -2
  225. package/dist/src/cli/commands/extension.js +1 -2
  226. package/dist/src/cli/commands/gateway/run-foreground.js +3 -3
  227. package/dist/src/cli/commands/gateway/shared.js +1 -1
  228. package/dist/src/cli/commands/history.js +2 -1
  229. package/dist/src/cli/commands/image.js +2 -2
  230. package/dist/src/cli/commands/init.js +11 -30
  231. package/dist/src/cli/commands/mcp.js +1 -2
  232. package/dist/src/cli/commands/models.js +13 -11
  233. package/dist/src/cli/commands/onboard/channels/registry.js +1 -2
  234. package/dist/src/cli/commands/onboard/gateway.js +1 -2
  235. package/dist/src/cli/commands/onboard/model.d.ts +1 -1
  236. package/dist/src/cli/commands/onboard/model.js +18 -26
  237. package/dist/src/cli/commands/onboard.js +4 -2
  238. package/dist/src/cli/commands/platform.js +1 -0
  239. package/dist/src/cli/commands/project.js +3 -3
  240. package/dist/src/cli/commands/providers.js +2 -1
  241. package/dist/src/cli/commands/runtime.js +1 -2
  242. package/dist/src/cli/commands/search.js +1 -2
  243. package/dist/src/cli/commands/skills.js +1 -2
  244. package/dist/src/cli/commands/tui-runner.js +3 -2
  245. package/dist/src/cli/commands/tui.js +6 -8
  246. package/dist/src/cli/commands/tunnel.js +1 -1
  247. package/dist/src/cli/commands/voice.js +1 -2
  248. package/dist/src/cli/extension-cli-register.js +1 -1
  249. package/dist/src/cli/index.js +4 -2
  250. package/dist/src/cli/utils/gateway-client.js +1 -1
  251. package/dist/src/cli/utils/init-workspace-core.js +15 -16
  252. package/dist/src/cli/utils/session.js +1 -2
  253. package/dist/src/computer/model-config.d.ts +3 -3
  254. package/dist/src/computer/model-config.js +10 -20
  255. package/dist/src/computer/runtime.js +1 -1
  256. package/dist/src/config/agent-model-intents.js +2 -2
  257. package/dist/src/config/agent-profile.d.ts +5 -6
  258. package/dist/src/config/agent-profile.js +19 -19
  259. package/dist/src/config/config-surface.d.ts +0 -3
  260. package/dist/src/config/default-model.js +2 -6
  261. package/dist/src/config/index.js +7 -8
  262. package/dist/src/config/loader.js +12 -18
  263. package/dist/src/config/models-json.d.ts +6 -6
  264. package/dist/src/config/paths.d.ts +18 -19
  265. package/dist/src/config/paths.js +35 -35
  266. package/dist/src/config/reload.d.ts +0 -1
  267. package/dist/src/config/reload.js +1 -6
  268. package/dist/src/config/rules.js +0 -15
  269. package/dist/src/config/schema.d.ts +3 -406
  270. package/dist/src/config/schema.js +24 -86
  271. package/dist/src/config/validate-channel-configs.js +8 -14
  272. package/dist/src/config/workspace-dirs.d.ts +3 -4
  273. package/dist/src/config/workspace-dirs.js +9 -8
  274. package/dist/src/config/workspace-path-helpers.d.ts +1 -1
  275. package/dist/src/config/workspace-path-helpers.js +2 -2
  276. package/dist/src/connectors/cli/lifecycle.js +2 -1
  277. package/dist/src/connectors/composio-managed-events.js +2 -1
  278. package/dist/src/connectors/connected-source-ingestion.js +2 -1
  279. package/dist/src/connectors/connected-source-understanding.js +4 -2
  280. package/dist/src/connectors/content-enrichment.js +2 -1
  281. package/dist/src/connectors/learning-coordinator.js +2 -1
  282. package/dist/src/connectors/runtime-adapter-registry.js +2 -1
  283. package/dist/src/connectors/workflow-preflight.d.ts +8 -1
  284. package/dist/src/connectors/workflow-preflight.js +11 -3
  285. package/dist/src/discussions/analyzer.js +2 -2
  286. package/dist/src/endpoint-tools/runtime.js +2 -1
  287. package/dist/src/execution-environments/subject.js +2 -1
  288. package/dist/src/extensions/activation-context.js +3 -16
  289. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  290. package/dist/src/extensions/discover-extensions.js +9 -15
  291. package/dist/src/extensions/extension-metadata-snapshot.d.ts +1 -1
  292. package/dist/src/extensions/extension-metadata-snapshot.js +9 -16
  293. package/dist/src/extensions/index.js +4 -10
  294. package/dist/src/extensions/install.js +1 -1
  295. package/dist/src/extensions/loader.js +7 -14
  296. package/dist/src/extensions/manifest-registry.js +93 -98
  297. package/dist/src/extensions/marketplace.js +5 -2
  298. package/dist/src/extensions/normalize-manifest.js +12 -17
  299. package/dist/src/extensions/update.js +1 -2
  300. package/dist/src/files/file-service.js +7 -8
  301. package/dist/src/gateway/agents-admin.d.ts +23 -27
  302. package/dist/src/gateway/agents-admin.js +109 -130
  303. package/dist/src/gateway/file-path-classifier.js +3 -3
  304. package/dist/src/gateway/file-space-service.js +2 -1
  305. package/dist/src/gateway/global-defaults-admin.d.ts +6 -4
  306. package/dist/src/gateway/global-defaults-admin.js +21 -20
  307. package/dist/src/gateway/hono/app.js +2 -1
  308. package/dist/src/gateway/hono/lib/config-payload.js +12 -9
  309. package/dist/src/gateway/hono/middleware/auth.js +2 -1
  310. package/dist/src/gateway/hono/middleware/scopes.js +2 -1
  311. package/dist/src/gateway/hono/routes/agents.js +22 -49
  312. package/dist/src/gateway/hono/routes/browser.js +4 -2
  313. package/dist/src/gateway/hono/routes/channels.js +1 -2
  314. package/dist/src/gateway/hono/routes/cli-connectors.js +2 -1
  315. package/dist/src/gateway/hono/routes/commands-skills.js +3 -1
  316. package/dist/src/gateway/hono/routes/composer-history.js +2 -1
  317. package/dist/src/gateway/hono/routes/config-patch/index.d.ts +1 -3
  318. package/dist/src/gateway/hono/routes/config-patch/index.js +1 -2
  319. package/dist/src/gateway/hono/routes/config-patch/misc.js +18 -11
  320. package/dist/src/gateway/hono/routes/config.js +0 -2
  321. package/dist/src/gateway/hono/routes/connectors.js +8 -4
  322. package/dist/src/gateway/hono/routes/context-sources.js +4 -3
  323. package/dist/src/gateway/hono/routes/device-pairing-approval.js +2 -1
  324. package/dist/src/gateway/hono/routes/device-push.js +3 -2
  325. package/dist/src/gateway/hono/routes/devices.js +6 -3
  326. package/dist/src/gateway/hono/routes/discussions.js +2 -1
  327. package/dist/src/gateway/hono/routes/endpoint-tools.js +2 -1
  328. package/dist/src/gateway/hono/routes/global-defaults.js +8 -16
  329. package/dist/src/gateway/hono/routes/home.js +93 -4
  330. package/dist/src/gateway/hono/routes/interaction-state.js +2 -1
  331. package/dist/src/gateway/hono/routes/models.js +8 -7
  332. package/dist/src/gateway/hono/routes/notes.js +4 -5
  333. package/dist/src/gateway/hono/routes/projects.js +6 -6
  334. package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
  335. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  336. package/dist/src/gateway/hono/routes/sessions.js +4 -2
  337. package/dist/src/gateway/hono/routes/shares.js +4 -3
  338. package/dist/src/gateway/hono/routes/site-shares.js +2 -2
  339. package/dist/src/gateway/hono/routes/status.js +2 -3
  340. package/dist/src/gateway/hono/routes/tasks.js +1 -2
  341. package/dist/src/gateway/hono/routes/user-model-refresh.js +2 -1
  342. package/dist/src/gateway/hono/routes/user-model.js +3 -2
  343. package/dist/src/gateway/hono/routes/work-discovery.js +1 -1
  344. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  345. package/dist/src/gateway/image-generation-setup.d.ts +19 -10
  346. package/dist/src/gateway/image-generation-setup.js +59 -23
  347. package/dist/src/gateway/index.js +1 -4
  348. package/dist/src/gateway/lock.js +13 -18
  349. package/dist/src/gateway/memory-maintenance-automation-reconciler.js +4 -3
  350. package/dist/src/gateway/run-loop.js +2 -3
  351. package/dist/src/gateway/security/gateway-scopes.js +6 -2
  352. package/dist/src/gateway/security/index.js +4 -1
  353. package/dist/src/gateway/service/agent-runner.js +4 -2
  354. package/dist/src/gateway/service/app-context-access.js +2 -1
  355. package/dist/src/gateway/service/config-coordinator.d.ts +0 -1
  356. package/dist/src/gateway/service/config-coordinator.js +4 -22
  357. package/dist/src/gateway/service/marketplace-service.js +3 -1
  358. package/dist/src/gateway/service/run-gateway-agent.js +4 -2
  359. package/dist/src/gateway/service/session-input-coordinator.js +4 -2
  360. package/dist/src/gateway/service.d.ts +5 -0
  361. package/dist/src/gateway/service.js +109 -33
  362. package/dist/src/gateway/session-context-summary.js +4 -2
  363. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +2 -0
  364. package/dist/src/gateway/xopc-cloud-capability-setup.js +15 -10
  365. package/dist/src/home-intelligence/application-service.d.ts +31 -0
  366. package/dist/src/home-intelligence/application-service.js +134 -0
  367. package/dist/src/home-intelligence/capability-preflight.d.ts +32 -0
  368. package/dist/src/home-intelligence/capability-preflight.js +118 -0
  369. package/dist/src/home-intelligence/evaluation.d.ts +34 -0
  370. package/dist/src/home-intelligence/evaluation.js +49 -0
  371. package/dist/src/home-intelligence/generator.d.ts +125 -0
  372. package/dist/src/home-intelligence/generator.js +227 -0
  373. package/dist/src/home-intelligence/host.d.ts +53 -0
  374. package/dist/src/home-intelligence/host.js +257 -0
  375. package/dist/src/home-intelligence/notification.d.ts +8 -0
  376. package/dist/src/home-intelligence/notification.js +20 -0
  377. package/dist/src/home-intelligence/policy.d.ts +16 -0
  378. package/dist/src/home-intelligence/policy.js +152 -0
  379. package/dist/src/home-intelligence/repository.d.ts +81 -0
  380. package/dist/src/home-intelligence/repository.js +495 -0
  381. package/dist/src/home-intelligence/snapshot.d.ts +43 -0
  382. package/dist/src/home-intelligence/snapshot.js +133 -0
  383. package/dist/src/home-intelligence/strategy.d.ts +14 -0
  384. package/dist/src/home-intelligence/strategy.js +10 -0
  385. package/dist/src/home-intelligence/types.d.ts +13 -0
  386. package/dist/src/home-intelligence/types.js +1 -0
  387. package/dist/src/infra/update-restart.js +4 -2
  388. package/dist/src/knowledge/connected-knowledge-pipeline.js +2 -1
  389. package/dist/src/knowledge/ingestion-service.js +2 -1
  390. package/dist/src/knowledge-memory/repository.js +2 -1
  391. package/dist/src/local-apps/service.js +1 -1
  392. package/dist/src/local-apps/store.js +2 -1
  393. package/dist/src/mcp/channel-bridge.js +1 -2
  394. package/dist/src/mcp/channel-server.js +1 -2
  395. package/dist/src/mcp/gateway-http-client.js +1 -2
  396. package/dist/src/media/session-references.js +2 -1
  397. package/dist/src/memory-maintenance/service.js +2 -1
  398. package/dist/src/migrations/memory-config.js +1 -2
  399. package/dist/src/notes/agent-context.js +2 -1
  400. package/dist/src/notes/attachment-ref.js +8 -4
  401. package/dist/src/notes/note-attachment-sync.js +2 -1
  402. package/dist/src/notes/note-index-meta.js +14 -7
  403. package/dist/src/notes/note-markdown.js +13 -7
  404. package/dist/src/notes/service.js +6 -3
  405. package/dist/src/notes/store.js +4 -2
  406. package/dist/src/notifications/device-store.js +1 -1
  407. package/dist/src/notifications/planner.js +24 -0
  408. package/dist/src/notifications/service.d.ts +7 -14
  409. package/dist/src/notifications/service.js +13 -3
  410. package/dist/src/notifications/store.js +1 -1
  411. package/dist/src/notifications/types.d.ts +1 -1
  412. package/dist/src/notifications/types.js +1 -1
  413. package/dist/src/projects/capabilities/write.js +2 -1
  414. package/dist/src/projects/project-agent-suggestion.js +1 -1
  415. package/dist/src/projects/project-agent.js +4 -4
  416. package/dist/src/projects/project-service.js +2 -1
  417. package/dist/src/projects/workspace.js +3 -2
  418. package/dist/src/providers/index.js +3 -3
  419. package/dist/src/providers/model-reference-auditor.d.ts +1 -2
  420. package/dist/src/providers/model-reference-auditor.js +8 -5
  421. package/dist/src/realtime/runtime.js +2 -1
  422. package/dist/src/routing/binding-schema.d.ts +41 -0
  423. package/dist/src/routing/binding-schema.js +26 -0
  424. package/dist/src/routing/bindings.d.ts +4 -2
  425. package/dist/src/routing/bindings.js +4 -4
  426. package/dist/src/routing/index.d.ts +1 -1
  427. package/dist/src/routing/resolve-route.d.ts +7 -24
  428. package/dist/src/routing/resolve-route.js +17 -18
  429. package/dist/src/routing/resolve-tui-session-key.d.ts +1 -4
  430. package/dist/src/routing/resolve-tui-session-key.js +10 -9
  431. package/dist/src/scenes/execution.d.ts +1 -1
  432. package/dist/src/scenes/model.js +1 -1
  433. package/dist/src/scenes/taskFollowUp/contracts.d.ts +1 -1
  434. package/dist/src/scenes/taskFollowUp/service.js +6 -4
  435. package/dist/src/scenes/templates.d.ts +2 -2
  436. package/dist/src/session/config-store.js +2 -1
  437. package/dist/src/session/init-session-turn.js +2 -1
  438. package/dist/src/session/resolve-session.js +2 -1
  439. package/dist/src/session/session-workspace.js +1 -1
  440. package/dist/src/session/store.js +3 -2
  441. package/dist/src/storage/sqlite/activity-repository.js +6 -2
  442. package/dist/src/storage/sqlite/browser-tab-binding-repository.js +6 -2
  443. package/dist/src/storage/sqlite/clarification-wait-repository.js +13 -8
  444. package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +1 -1
  445. package/dist/src/storage/sqlite/collaboration-rule-repository.js +8 -3
  446. package/dist/src/storage/sqlite/composer-input-history-repository.js +8 -3
  447. package/dist/src/storage/sqlite/config-repository.js +9 -5
  448. package/dist/src/storage/sqlite/connector-learning-repository.js +6 -2
  449. package/dist/src/storage/sqlite/connector-sync-policy-repository.js +6 -2
  450. package/dist/src/storage/sqlite/context-evidence-repository.js +8 -3
  451. package/dist/src/storage/sqlite/context-extraction-repository.js +8 -3
  452. package/dist/src/storage/sqlite/device-access-repository.js +15 -9
  453. package/dist/src/storage/sqlite/device-pairing-approval.js +6 -2
  454. package/dist/src/storage/sqlite/device-pairing-repository.js +10 -5
  455. package/dist/src/storage/sqlite/endpoint-principal-repository.js +6 -2
  456. package/dist/src/storage/sqlite/endpoint-session-binding-repository.js +6 -2
  457. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +6 -2
  458. package/dist/src/storage/sqlite/gateway-identity-repository.js +6 -2
  459. package/dist/src/storage/sqlite/home-attention-repository.js +6 -2
  460. package/dist/src/storage/sqlite/index.d.ts +0 -1
  461. package/dist/src/storage/sqlite/index.js +72 -42
  462. package/dist/src/storage/sqlite/interaction-state-repository.js +10 -4
  463. package/dist/src/storage/sqlite/knowledge-repository.js +6 -2
  464. package/dist/src/storage/sqlite/migrations/203_remove_retired_proactive_contracts.sql +70 -0
  465. package/dist/src/storage/sqlite/migrations/204_home_intelligence.sql +78 -0
  466. package/dist/src/storage/sqlite/migrations/205_agent_catalog.sql +66 -0
  467. package/dist/src/storage/sqlite/migrations/206_home_advice_strategy_version.sql +3 -0
  468. package/dist/src/storage/sqlite/migrations/conversation-backup.d.ts +2 -0
  469. package/dist/src/storage/sqlite/migrations/conversation-backup.js +8 -4
  470. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.d.ts +7 -1
  471. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.js +2 -2
  472. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  473. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  474. package/dist/src/storage/sqlite/note-agent-context-repository.js +6 -2
  475. package/dist/src/storage/sqlite/notes-repository.js +9 -4
  476. package/dist/src/storage/sqlite/schema.js +1 -1
  477. package/dist/src/storage/sqlite/session-task-plan-repository.js +14 -9
  478. package/dist/src/storage/sqlite/session-turn-replace-repository.js +9 -5
  479. package/dist/src/storage/sqlite/sidebar-layout-repository.js +14 -9
  480. package/dist/src/storage/sqlite/transcript-repository.js +10 -6
  481. package/dist/src/storage/sqlite/user-people-repository.js +8 -3
  482. package/dist/src/storage/sqlite/user-trust-repository.js +8 -3
  483. package/dist/src/tasks/attention-governor.d.ts +0 -1
  484. package/dist/src/tasks/attention-governor.js +1 -7
  485. package/dist/src/tasks/capabilities/read.js +2 -2
  486. package/dist/src/tasks/capabilities/write.d.ts +1 -1
  487. package/dist/src/tasks/execution-context.d.ts +2 -2
  488. package/dist/src/tasks/execution-context.js +6 -5
  489. package/dist/src/tasks/home-query-service.d.ts +3 -2
  490. package/dist/src/tasks/home-query-service.js +23 -44
  491. package/dist/src/tasks/task-context-assembler.js +2 -1
  492. package/dist/src/tasks/task-context-repository.d.ts +1 -1
  493. package/dist/src/tasks/task-contract-planner.d.ts +0 -3
  494. package/dist/src/tasks/task-contract-planner.js +1 -4
  495. package/dist/src/tasks/task-handoff-service.d.ts +0 -2
  496. package/dist/src/tasks/task-handoff-service.js +3 -3
  497. package/dist/src/tasks/task-value-metrics-service.js +2 -1
  498. package/dist/src/tui/backends/embedded-backend.js +12 -14
  499. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  500. package/dist/src/tui/tui-commands.js +5 -3
  501. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  502. package/dist/src/tui/tui-startup-resources.js +3 -3
  503. package/dist/src/tui/tui.js +5 -5
  504. package/dist/src/tunnel/registration-proof.js +2 -1
  505. package/dist/src/user-context/access-policy.js +2 -1
  506. package/dist/src/user-context/domain.d.ts +1 -1
  507. package/dist/src/user-context/domain.js +18 -13
  508. package/dist/src/user-context/extraction/registry.js +2 -1
  509. package/dist/src/user-context/interaction-state.js +4 -1
  510. package/dist/src/user-context/relationship-continuity.js +2 -1
  511. package/dist/src/user-context/trust-policy.js +13 -8
  512. package/dist/src/user-model/bootstrap.js +2 -1
  513. package/dist/src/user-model/capture/executor.js +4 -2
  514. package/dist/src/user-model/capture/semantic.d.ts +1 -1
  515. package/dist/src/user-model/capture/semantic.js +1 -1
  516. package/dist/src/user-model/domain.js +7 -2
  517. package/dist/src/user-model/goals.js +2 -1
  518. package/dist/src/user-model/index.js +4 -1
  519. package/dist/src/user-model/repository.js +2 -1
  520. package/dist/src/utils/helpers.js +1 -4
  521. package/dist/src/utils/index.js +2 -2
  522. package/dist/src/utils/logger/index.d.ts +1 -1
  523. package/dist/src/utils/logger/index.js +2 -2
  524. package/dist/src/utils/logger/redact.d.ts +2 -0
  525. package/dist/src/utils/logger/redact.js +11 -3
  526. package/dist/src/utils/logger.js +2 -2
  527. package/dist/src/voice/realtime/memory-context.js +2 -1
  528. package/dist/src/voice/realtime/persona-context.js +6 -6
  529. package/dist/src/voice/tts/audio.js +1 -1
  530. package/dist/src/work-discovery/analyzer.js +3 -3
  531. package/dist/src/work-discovery/investigator.js +1 -1
  532. package/dist/src/work-discovery/service.js +12 -11
  533. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  534. package/dist/src/workflows/service/workflow-run-service.js +4 -5
  535. package/dist/src/workflows/store/paths.js +1 -1
  536. package/package.json +5 -5
  537. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CAFHadiy.js +0 -1
  538. package/dist/gateway/static/root/assets/apps-page-Drt3Foi9.js +0 -1
  539. package/dist/gateway/static/root/assets/automations-workspace-B-Eduqwz.js +0 -7
  540. package/dist/gateway/static/root/assets/browser-settings-page-Dwgir6mu.js +0 -3
  541. package/dist/gateway/static/root/assets/capabilities-settings-panel-H5L5vynP.js +0 -8
  542. package/dist/gateway/static/root/assets/capabilities-uFKh3Hd0.js +0 -1
  543. package/dist/gateway/static/root/assets/channels-settings-RFBRYe5S.js +0 -1
  544. package/dist/gateway/static/root/assets/connectors-page-Px-v3Q6Q.js +0 -2
  545. package/dist/gateway/static/root/assets/date-picker-CfCo3lqh.js +0 -1
  546. package/dist/gateway/static/root/assets/home-page-w3_aWeNt.js +0 -1
  547. package/dist/gateway/static/root/assets/index--3c0awkr.js +0 -121
  548. package/dist/gateway/static/root/assets/local-app-workbench-page-BYKrJpFF.js +0 -1
  549. package/dist/gateway/static/root/assets/logs-page-Dl4kM4Na.js +0 -2
  550. package/dist/gateway/static/root/assets/messages-7VAhscYe.js +0 -3
  551. package/dist/gateway/static/root/assets/note-detail-panel-j6sioeL1.js +0 -5
  552. package/dist/gateway/static/root/assets/notes-page-CMvvHv0f.js +0 -8
  553. package/dist/gateway/static/root/assets/popover-select-B-GDnZO9.js +0 -1
  554. package/dist/gateway/static/root/assets/project-detail-page-C9K_e-EV.js +0 -1
  555. package/dist/gateway/static/root/assets/remote-access-hub-CLGJNA42.js +0 -1
  556. package/dist/gateway/static/root/assets/scenes-page-ClLAD1pz.js +0 -2
  557. package/dist/gateway/static/root/assets/sessions-page-Xj8MkXN1.js +0 -1
  558. package/dist/gateway/static/root/assets/settings-advanced-gate-DwALV8mi.js +0 -1
  559. package/dist/gateway/static/root/assets/setup-status-panel-F0rCQ-2a.js +0 -1
  560. package/dist/gateway/static/root/assets/shares-settings-C7hf6Cov.js +0 -1
  561. package/dist/gateway/static/root/assets/skill-reload-api-xPrFejRE.js +0 -1
  562. package/dist/gateway/static/root/assets/skills-page-RdDYu7Yj.js +0 -2
  563. package/dist/gateway/static/root/assets/task-detail-page-2A966jFY.js +0 -1
  564. package/dist/gateway/static/root/assets/user-model-page-CnBxPBVe.js +0 -2
  565. package/dist/gateway/static/root/assets/workflows-page-BZVpqw4T.js +0 -6
  566. package/dist/packages/gateway-contract/src/proactive.js +0 -136
  567. package/dist/src/commands/agents.config.d.ts +0 -31
  568. package/dist/src/commands/agents.config.js +0 -129
  569. package/dist/src/gateway/hono/routes/config-patch/agents.d.ts +0 -2
  570. package/dist/src/gateway/hono/routes/config-patch/agents.js +0 -6
  571. package/dist/src/storage/sqlite/relationship-settings-repository.d.ts +0 -17
  572. package/dist/src/storage/sqlite/relationship-settings-repository.js +0 -65
@@ -0,0 +1,319 @@
1
+ import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
+ import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
3
+ import { init_sqlite } from "../storage/sqlite/index.js";
4
+ import { AgentDefaultsSchema, AgentEntrySchema, DEFAULT_AGENT_MODEL_REF, DEFAULT_SKILL_POLICY } from "../agent-config/schema.js";
5
+ import { init_agent_config } from "../agent-config/index.js";
6
+ import { DEFAULT_AGENT_ID, init_id, normalizeAgentId } from "./id.js";
7
+ import { BindingsSchema, init_binding_schema } from "../routing/binding-schema.js";
8
+ import { randomUUID } from "node:crypto";
9
+ //#region src/agent-catalog/repository.ts
10
+ function parseObject(value, label) {
11
+ const parsed = JSON.parse(value);
12
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${label} must contain a JSON object`);
13
+ return parsed;
14
+ }
15
+ function rowToAgent(row) {
16
+ const overrides = parseObject(row.overrides_json, `Agent ${row.id} overrides`);
17
+ return {
18
+ ...AgentEntrySchema.parse({
19
+ id: row.id,
20
+ enabled: row.enabled === 1,
21
+ ...row.workspace_override ? { workspace: row.workspace_override } : {},
22
+ ...row.profile_json ? { profile: JSON.parse(row.profile_json) } : {},
23
+ ...overrides
24
+ }),
25
+ revision: row.revision,
26
+ provisioningState: row.provisioning_state,
27
+ ...row.provisioning_error ? { provisioningError: row.provisioning_error } : {},
28
+ createdAt: row.created_at,
29
+ updatedAt: row.updated_at,
30
+ ...row.deleted_at === null ? {} : { deletedAt: row.deleted_at }
31
+ };
32
+ }
33
+ function splitEntry(entry) {
34
+ const { id: _id, enabled: _enabled, workspace, profile, ...overrides } = AgentEntrySchema.parse(entry);
35
+ return {
36
+ workspace: workspace ?? null,
37
+ profileJson: profile ? JSON.stringify(profile) : null,
38
+ overridesJson: JSON.stringify(overrides)
39
+ };
40
+ }
41
+ function requireSettings() {
42
+ const row = getSqliteDatabase().prepare(`SELECT default_agent_id, defaults_json, revision, created_at, updated_at
43
+ FROM agent_catalog_settings WHERE singleton_id = 1`).get();
44
+ if (!row) throw new Error("Agent catalog is not initialized");
45
+ return {
46
+ defaultAgentId: row.default_agent_id,
47
+ defaults: AgentDefaultsSchema.parse(JSON.parse(row.defaults_json)),
48
+ revision: row.revision,
49
+ createdAt: row.created_at,
50
+ updatedAt: row.updated_at
51
+ };
52
+ }
53
+ function bumpCatalogRevision(now) {
54
+ const result = getSqliteDatabase().prepare(`UPDATE agent_catalog_settings
55
+ SET revision = revision + 1, updated_at = ? WHERE singleton_id = 1`).run(now);
56
+ if (Number(result.changes) !== 1) throw new Error("Agent catalog is not initialized");
57
+ }
58
+ function defaultAgentDefaults() {
59
+ return structuredClone(DEFAULT_AGENT_DEFAULTS);
60
+ }
61
+ var DEFAULT_AGENT_DEFAULTS, AgentCatalogRepository;
62
+ var init_repository = __esmMin((() => {
63
+ init_agent_config();
64
+ init_id();
65
+ init_binding_schema();
66
+ init_sqlite();
67
+ DEFAULT_AGENT_DEFAULTS = AgentDefaultsSchema.parse({
68
+ models: {
69
+ chat: {
70
+ primary: DEFAULT_AGENT_MODEL_REF,
71
+ fallbacks: []
72
+ },
73
+ intents: {}
74
+ },
75
+ skills: DEFAULT_SKILL_POLICY
76
+ });
77
+ AgentCatalogRepository = class {
78
+ ensureInitialized(defaults = DEFAULT_AGENT_DEFAULTS) {
79
+ runSqliteWriteTransaction((db) => {
80
+ const now = Date.now();
81
+ db.prepare(`INSERT OR IGNORE INTO agents
82
+ (id, enabled, workspace_override, profile_json, overrides_json, provisioning_state,
83
+ provisioning_error, revision, created_at, updated_at, deleted_at)
84
+ VALUES (?, 1, NULL, ?, '{}', 'pending', NULL, 1, ?, ?, NULL)`).run(DEFAULT_AGENT_ID, JSON.stringify({ name: "Main" }), now, now);
85
+ db.prepare(`INSERT OR IGNORE INTO agent_catalog_settings
86
+ (singleton_id, default_agent_id, defaults_json, revision, created_at, updated_at)
87
+ VALUES (1, ?, ?, 1, ?, ?)`).run(DEFAULT_AGENT_ID, JSON.stringify(AgentDefaultsSchema.parse(defaults)), now, now);
88
+ db.prepare(`INSERT OR IGNORE INTO agent_provisioning_jobs
89
+ (agent_id, operation, state, attempts, last_error, created_at, updated_at)
90
+ VALUES (?, 'provision', 'pending', 0, NULL, ?, ?)`).run(DEFAULT_AGENT_ID, now, now);
91
+ });
92
+ }
93
+ getSettings() {
94
+ return requireSettings();
95
+ }
96
+ list(options = {}) {
97
+ const clauses = [];
98
+ if (!options.includeDeleted) clauses.push("deleted_at IS NULL");
99
+ if (options.readyOnly) clauses.push("provisioning_state = 'ready'");
100
+ const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
101
+ return getSqliteDatabase().prepare(`SELECT * FROM agents ${where} ORDER BY id`).all().map(rowToAgent);
102
+ }
103
+ get(id, options = {}) {
104
+ const agentId = normalizeAgentId(id);
105
+ const row = getSqliteDatabase().prepare(`SELECT * FROM agents WHERE id = ?${options.includeDeleted ? "" : " AND deleted_at IS NULL"}`).get(agentId);
106
+ return row ? rowToAgent(row) : null;
107
+ }
108
+ snapshot() {
109
+ const settings = requireSettings();
110
+ const agents = this.list({ readyOnly: true }).map(({ revision: _revision, provisioningState: _state, provisioningError: _error, createdAt: _created, updatedAt: _updated, deletedAt: _deleted, ...entry }) => entry);
111
+ const bindings = getSqliteDatabase().prepare(`SELECT id, agent_id, position, rule_json
112
+ FROM agent_bindings ORDER BY position, id`).all().map((row) => ({
113
+ id: row.id,
114
+ agentId: row.agent_id,
115
+ ...parseObject(row.rule_json, `Binding ${row.id}`)
116
+ }));
117
+ const surfaceDefaults = Object.fromEntries(getSqliteDatabase().prepare("SELECT surface, agent_id FROM agent_surface_defaults ORDER BY surface").all().map((row) => [row.surface, row.agent_id]));
118
+ return {
119
+ revision: settings.revision,
120
+ defaultAgentId: settings.defaultAgentId,
121
+ defaults: settings.defaults,
122
+ agents,
123
+ bindings: BindingsSchema.parse(bindings),
124
+ surfaceDefaults
125
+ };
126
+ }
127
+ create(entryInput, options = {}) {
128
+ const entry = AgentEntrySchema.parse(entryInput);
129
+ const id = normalizeAgentId(entry.id);
130
+ if (id !== entry.id) throw new Error(`Invalid normalized Agent id: ${entry.id}`);
131
+ return runSqliteWriteTransaction((db) => {
132
+ if (db.prepare("SELECT 1 FROM agents WHERE id = ?").get(id)) throw new Error(`Agent "${id}" already exists`);
133
+ const now = Date.now();
134
+ const parts = splitEntry(entry);
135
+ const state = options.ready ? "ready" : "pending";
136
+ db.prepare(`INSERT INTO agents
137
+ (id, enabled, workspace_override, profile_json, overrides_json, provisioning_state,
138
+ provisioning_error, revision, created_at, updated_at, deleted_at)
139
+ VALUES (?, ?, ?, ?, ?, ?, NULL, 1, ?, ?, NULL)`).run(id, entry.enabled === false ? 0 : 1, parts.workspace, parts.profileJson, parts.overridesJson, state, now, now);
140
+ if (!options.ready) db.prepare(`INSERT INTO agent_provisioning_jobs
141
+ (agent_id, operation, state, attempts, last_error, created_at, updated_at)
142
+ VALUES (?, 'provision', 'pending', 0, NULL, ?, ?)`).run(id, now, now);
143
+ bumpCatalogRevision(now);
144
+ return rowToAgent(db.prepare("SELECT * FROM agents WHERE id = ?").get(id));
145
+ });
146
+ }
147
+ update(id, expectedRevision, entryInput, options = {}) {
148
+ const agentId = normalizeAgentId(id);
149
+ const entry = AgentEntrySchema.parse(entryInput);
150
+ if (entry.id !== agentId) throw new Error("Agent id cannot be changed");
151
+ return runSqliteWriteTransaction((db) => {
152
+ if (entry.enabled === false) {
153
+ if (requireSettings().defaultAgentId === agentId) throw new Error("Default Agent cannot be disabled");
154
+ }
155
+ const parts = splitEntry(entry);
156
+ const now = Date.now();
157
+ const result = db.prepare(`UPDATE agents SET enabled = ?, workspace_override = ?, profile_json = ?,
158
+ overrides_json = ?, provisioning_state = ?, provisioning_error = NULL,
159
+ revision = revision + 1, updated_at = ?
160
+ WHERE id = ? AND revision = ? AND deleted_at IS NULL`).run(entry.enabled === false ? 0 : 1, parts.workspace, parts.profileJson, parts.overridesJson, options.reprovision ? "pending" : "ready", now, agentId, expectedRevision);
161
+ if (Number(result.changes) !== 1) throw new Error("Agent revision conflict");
162
+ if (options.reprovision) db.prepare(`INSERT INTO agent_provisioning_jobs
163
+ (agent_id, operation, state, attempts, last_error, created_at, updated_at)
164
+ VALUES (?, 'provision', 'pending', 0, NULL, ?, ?)
165
+ ON CONFLICT(agent_id) DO UPDATE SET operation = 'provision', state = 'pending',
166
+ attempts = 0, last_error = NULL, updated_at = excluded.updated_at`).run(agentId, now, now);
167
+ bumpCatalogRevision(now);
168
+ return rowToAgent(db.prepare("SELECT * FROM agents WHERE id = ?").get(agentId));
169
+ });
170
+ }
171
+ setDefault(agentIdRaw, expectedRevision) {
172
+ const agentId = normalizeAgentId(agentIdRaw);
173
+ return runSqliteWriteTransaction((db) => {
174
+ const agent = db.prepare(`SELECT enabled, provisioning_state, deleted_at FROM agents WHERE id = ?`).get(agentId);
175
+ if (!agent || agent.enabled !== 1 || agent.provisioning_state !== "ready" || agent.deleted_at !== null) throw new Error(`Agent "${agentId}" is not available`);
176
+ const now = Date.now();
177
+ const result = db.prepare(`UPDATE agent_catalog_settings SET default_agent_id = ?,
178
+ revision = revision + 1, updated_at = ? WHERE singleton_id = 1 AND revision = ?`).run(agentId, now, expectedRevision);
179
+ if (Number(result.changes) !== 1) throw new Error("Agent catalog revision conflict");
180
+ return requireSettings();
181
+ });
182
+ }
183
+ updateDefaults(defaultsInput, expectedRevision) {
184
+ const defaults = AgentDefaultsSchema.parse(defaultsInput);
185
+ return runSqliteWriteTransaction((db) => {
186
+ const now = Date.now();
187
+ const result = db.prepare(`UPDATE agent_catalog_settings SET defaults_json = ?,
188
+ revision = revision + 1, updated_at = ? WHERE singleton_id = 1 AND revision = ?`).run(JSON.stringify(defaults), now, expectedRevision);
189
+ if (Number(result.changes) !== 1) throw new Error("Agent catalog revision conflict");
190
+ return requireSettings();
191
+ });
192
+ }
193
+ replaceBindings(bindingsInput) {
194
+ const bindings = BindingsSchema.parse(bindingsInput);
195
+ return runSqliteWriteTransaction((db) => {
196
+ for (const binding of bindings) {
197
+ const agentId = normalizeAgentId(binding.agentId);
198
+ if (!db.prepare(`SELECT 1 FROM agents WHERE id = ? AND enabled = 1
199
+ AND provisioning_state = 'ready' AND deleted_at IS NULL`).get(agentId)) throw new Error(`Agent "${agentId}" is not available`);
200
+ }
201
+ db.prepare("DELETE FROM agent_bindings").run();
202
+ const now = Date.now();
203
+ const insert = db.prepare(`INSERT INTO agent_bindings
204
+ (id, agent_id, position, rule_json, revision, created_at, updated_at)
205
+ VALUES (?, ?, ?, ?, 1, ?, ?)`);
206
+ bindings.forEach((binding, position) => {
207
+ const { id, agentId, ...rule } = binding;
208
+ insert.run(id ?? randomUUID(), normalizeAgentId(agentId), position, JSON.stringify(rule), now, now);
209
+ });
210
+ db.prepare(`UPDATE agent_catalog_settings SET revision = revision + 1, updated_at = ? WHERE singleton_id = 1`).run(now);
211
+ return this.snapshot().bindings;
212
+ });
213
+ }
214
+ setSurfaceDefault(surfaceRaw, agentIdRaw) {
215
+ const surface = surfaceRaw.trim();
216
+ if (!surface) throw new Error("Surface is required");
217
+ const agentId = normalizeAgentId(agentIdRaw);
218
+ runSqliteWriteTransaction((db) => {
219
+ const now = Date.now();
220
+ if (!db.prepare(`SELECT 1 FROM agents WHERE id = ? AND enabled = 1
221
+ AND provisioning_state = 'ready' AND deleted_at IS NULL`).get(agentId)) throw new Error(`Agent "${agentId}" is not available`);
222
+ db.prepare(`INSERT INTO agent_surface_defaults(surface, agent_id, revision, updated_at)
223
+ VALUES (?, ?, 1, ?) ON CONFLICT(surface) DO UPDATE SET agent_id = excluded.agent_id,
224
+ revision = agent_surface_defaults.revision + 1, updated_at = excluded.updated_at`).run(surface, agentId, now);
225
+ db.prepare(`UPDATE agent_catalog_settings SET revision = revision + 1, updated_at = ? WHERE singleton_id = 1`).run(now);
226
+ });
227
+ }
228
+ clearSurfaceDefault(surfaceRaw) {
229
+ const surface = surfaceRaw.trim();
230
+ if (!surface) throw new Error("Surface is required");
231
+ runSqliteWriteTransaction((db) => {
232
+ const result = db.prepare("DELETE FROM agent_surface_defaults WHERE surface = ?").run(surface);
233
+ if (Number(result.changes) > 0) bumpCatalogRevision(Date.now());
234
+ });
235
+ }
236
+ markProvisioned(agentIdRaw) {
237
+ const agentId = normalizeAgentId(agentIdRaw);
238
+ return runSqliteWriteTransaction((db) => {
239
+ const now = Date.now();
240
+ const result = db.prepare(`UPDATE agents SET provisioning_state = 'ready', provisioning_error = NULL,
241
+ revision = revision + 1, updated_at = ? WHERE id = ? AND deleted_at IS NULL`).run(now, agentId);
242
+ if (Number(result.changes) !== 1) throw new Error(`Agent "${agentId}" not found`);
243
+ db.prepare("DELETE FROM agent_provisioning_jobs WHERE agent_id = ?").run(agentId);
244
+ bumpCatalogRevision(now);
245
+ return rowToAgent(db.prepare("SELECT * FROM agents WHERE id = ?").get(agentId));
246
+ });
247
+ }
248
+ markProvisioningFailed(agentIdRaw, errorMessage) {
249
+ const agentId = normalizeAgentId(agentIdRaw);
250
+ runSqliteWriteTransaction((db) => {
251
+ const now = Date.now();
252
+ const bounded = errorMessage.slice(0, 1e3);
253
+ db.prepare(`UPDATE agents SET provisioning_state = 'error', provisioning_error = ?,
254
+ revision = revision + 1, updated_at = ? WHERE id = ? AND deleted_at IS NULL`).run(bounded, now, agentId);
255
+ db.prepare(`UPDATE agent_provisioning_jobs SET state = 'failed', attempts = attempts + 1,
256
+ last_error = ?, updated_at = ? WHERE agent_id = ?`).run(bounded, now, agentId);
257
+ bumpCatalogRevision(now);
258
+ });
259
+ }
260
+ listPendingProvisioningAgentIds() {
261
+ return getSqliteDatabase().prepare(`SELECT agent_id FROM agent_provisioning_jobs
262
+ WHERE operation = 'provision' AND state IN ('pending', 'failed') ORDER BY created_at`).all().map((row) => row.agent_id);
263
+ }
264
+ listPendingPurgeAgentIds() {
265
+ return getSqliteDatabase().prepare(`SELECT agent_id FROM agent_provisioning_jobs
266
+ WHERE operation = 'purge' AND state IN ('pending', 'failed') ORDER BY created_at`).all().map((row) => row.agent_id);
267
+ }
268
+ markPurged(agentIdRaw) {
269
+ const agentId = normalizeAgentId(agentIdRaw);
270
+ runSqliteWriteTransaction((db) => {
271
+ const result = db.prepare("DELETE FROM agents WHERE id = ? AND deleted_at IS NOT NULL").run(agentId);
272
+ if (Number(result.changes) !== 1) throw new Error(`Deleted Agent "${agentId}" not found`);
273
+ bumpCatalogRevision(Date.now());
274
+ });
275
+ }
276
+ markPurgeFailed(agentIdRaw, errorMessage) {
277
+ const agentId = normalizeAgentId(agentIdRaw);
278
+ runSqliteWriteTransaction((db) => {
279
+ const now = Date.now();
280
+ const bounded = errorMessage.slice(0, 1e3);
281
+ db.prepare(`UPDATE agents SET provisioning_state = 'error', provisioning_error = ?,
282
+ revision = revision + 1, updated_at = ? WHERE id = ? AND deleted_at IS NOT NULL`).run(bounded, now, agentId);
283
+ db.prepare(`UPDATE agent_provisioning_jobs SET state = 'failed', attempts = attempts + 1,
284
+ last_error = ?, updated_at = ? WHERE agent_id = ? AND operation = 'purge'`).run(bounded, now, agentId);
285
+ bumpCatalogRevision(now);
286
+ });
287
+ }
288
+ delete(agentIdRaw, options = {}) {
289
+ const agentId = normalizeAgentId(agentIdRaw);
290
+ return runSqliteWriteTransaction((db) => {
291
+ const settings = requireSettings();
292
+ if (agentId === "main") throw new Error(`Agent id "${DEFAULT_AGENT_ID}" is reserved for the primary Agent`);
293
+ if (settings.defaultAgentId === agentId) throw new Error(`Agent "${agentId}" is the global default Agent`);
294
+ const surface = db.prepare("SELECT surface FROM agent_surface_defaults WHERE agent_id = ? LIMIT 1").get(agentId);
295
+ if (surface) throw new Error(`Agent "${agentId}" is the ${surface.surface} default Agent`);
296
+ const row = db.prepare("SELECT * FROM agents WHERE id = ? AND deleted_at IS NULL").get(agentId);
297
+ if (!row) throw new Error(`Agent "${agentId}" not found`);
298
+ const removedBindings = Number(db.prepare("DELETE FROM agent_bindings WHERE agent_id = ?").run(agentId).changes);
299
+ db.prepare("DELETE FROM agent_provisioning_jobs WHERE agent_id = ?").run(agentId);
300
+ const now = Date.now();
301
+ if (options.purge) {
302
+ db.prepare(`UPDATE agents SET enabled = 0, provisioning_state = 'pending', provisioning_error = NULL,
303
+ revision = revision + 1, updated_at = ?, deleted_at = ? WHERE id = ?`).run(now, now, agentId);
304
+ db.prepare(`INSERT INTO agent_provisioning_jobs
305
+ (agent_id, operation, state, attempts, last_error, created_at, updated_at)
306
+ VALUES (?, 'purge', 'pending', 0, NULL, ?, ?)`).run(agentId, now, now);
307
+ } else db.prepare("DELETE FROM agents WHERE id = ?").run(agentId);
308
+ bumpCatalogRevision(now);
309
+ return {
310
+ agent: options.purge ? rowToAgent(db.prepare("SELECT * FROM agents WHERE id = ?").get(agentId)) : rowToAgent(row),
311
+ removedBindings
312
+ };
313
+ });
314
+ }
315
+ };
316
+ }));
317
+ //#endregion
318
+ init_repository();
319
+ export { AgentCatalogRepository, defaultAgentDefaults, init_repository };
@@ -0,0 +1,33 @@
1
+ import type { AgentDefaults, AgentEntry } from '../agent-config/index.js';
2
+ import type { BindingRule } from '../routing/binding-schema.js';
3
+ import { AgentCatalogRepository } from './repository.js';
4
+ import type { AgentCatalogSettings, StoredAgent } from './types.js';
5
+ export declare class AgentCatalogService {
6
+ private readonly repository;
7
+ constructor(repository?: AgentCatalogRepository);
8
+ create(entry: AgentEntry): Promise<StoredAgent>;
9
+ resumePendingProvisioning(): Promise<void>;
10
+ /** Startup recovery for catalog rows committed before their directories were provisioned. */
11
+ resumePendingProvisioningSync(): void;
12
+ update(agentIdRaw: string, patch: Partial<Omit<AgentEntry, 'id'>>): Promise<StoredAgent>;
13
+ /** Remove data for an Agent that has already been deleted from the catalog. */
14
+ purgeEntryData(entry: AgentEntry, defaultAgentId: string): Promise<void>;
15
+ validatePurgeEntry(entry: AgentEntry, defaultAgentId: string): void;
16
+ resumePendingPurge(): Promise<string[]>;
17
+ private resumePendingPurgeSync;
18
+ setDefault(agentId: string): AgentCatalogSettings;
19
+ updateDefaults(defaults: AgentDefaults): AgentCatalogSettings;
20
+ replaceBindings(bindings: BindingRule[]): BindingRule[];
21
+ setSurfaceDefault(surface: string, agentId: string): void;
22
+ clearSurfaceDefault(surface: string): void;
23
+ delete(agentIdRaw: string, options?: {
24
+ purge?: boolean;
25
+ }): Promise<{
26
+ removedBindings: number;
27
+ }>;
28
+ private provision;
29
+ private provisionSync;
30
+ private purgeEntryDataSync;
31
+ private assertSafeWorkspacePurge;
32
+ private assertPurgeTargetsAreNotShared;
33
+ }
@@ -0,0 +1,202 @@
1
+ import { init_paths_state, resolveStateDir } from "../config/paths-state.js";
2
+ import { init_id, normalizeAgentId } from "./id.js";
3
+ import { AgentCatalogRepository, init_repository } from "./repository.js";
4
+ import { init_workspace_defaults, resolveDefaultAgentWorkspaceDir } from "../config/workspace-defaults.js";
5
+ import { init_agent_scope, resolveAgentDir, resolveAgentHomeDir, resolveAgentProfileDir, resolveUserPath } from "../agent/agent-scope.js";
6
+ import { seedAgentProfileMarkdownFiles } from "../agent/context/workspace-seed.js";
7
+ import { isAbsolute, join, parse, relative, resolve } from "node:path";
8
+ import { existsSync, mkdirSync, rmSync } from "node:fs";
9
+ import { mkdir, rm } from "node:fs/promises";
10
+ //#region src/agent-catalog/service.ts
11
+ init_agent_scope();
12
+ init_paths_state();
13
+ init_workspace_defaults();
14
+ init_id();
15
+ init_repository();
16
+ function workspaceForEntry(entry, defaultAgentId) {
17
+ if (entry.workspace?.trim()) return resolveUserPath(entry.workspace);
18
+ if (entry.id === defaultAgentId) return resolveDefaultAgentWorkspaceDir(process.env);
19
+ return join(resolveStateDir(process.env), `workspace-${entry.id}`);
20
+ }
21
+ var AgentCatalogService = class {
22
+ constructor(repository = new AgentCatalogRepository()) {
23
+ this.repository = repository;
24
+ }
25
+ async create(entry) {
26
+ const pending = this.repository.create(entry);
27
+ try {
28
+ await this.provision(pending);
29
+ return this.repository.markProvisioned(pending.id);
30
+ } catch (error) {
31
+ this.repository.markProvisioningFailed(pending.id, error instanceof Error ? error.message : String(error));
32
+ throw error;
33
+ }
34
+ }
35
+ async resumePendingProvisioning() {
36
+ for (const agentId of this.repository.listPendingProvisioningAgentIds()) {
37
+ const agent = this.repository.get(agentId);
38
+ if (!agent) continue;
39
+ try {
40
+ await this.provision(agent);
41
+ this.repository.markProvisioned(agentId);
42
+ } catch (error) {
43
+ this.repository.markProvisioningFailed(agentId, error instanceof Error ? error.message : String(error));
44
+ }
45
+ }
46
+ await this.resumePendingPurge();
47
+ }
48
+ /** Startup recovery for catalog rows committed before their directories were provisioned. */
49
+ resumePendingProvisioningSync() {
50
+ for (const agentId of this.repository.listPendingProvisioningAgentIds()) {
51
+ const agent = this.repository.get(agentId);
52
+ if (!agent) continue;
53
+ try {
54
+ this.provisionSync(agent);
55
+ this.repository.markProvisioned(agentId);
56
+ } catch (error) {
57
+ this.repository.markProvisioningFailed(agentId, error instanceof Error ? error.message : String(error));
58
+ }
59
+ }
60
+ this.resumePendingPurgeSync();
61
+ }
62
+ async update(agentIdRaw, patch) {
63
+ const agentId = normalizeAgentId(agentIdRaw);
64
+ const current = this.repository.get(agentId);
65
+ if (!current) throw new Error(`Agent "${agentId}" not found`);
66
+ const { revision, provisioningState: _state, provisioningError: _error, createdAt: _created, updatedAt: _updated, deletedAt: _deleted, ...entry } = current;
67
+ const next = {
68
+ ...entry,
69
+ ...patch,
70
+ id: agentId
71
+ };
72
+ await this.provision(next);
73
+ return this.repository.update(agentId, revision, next);
74
+ }
75
+ /** Remove data for an Agent that has already been deleted from the catalog. */
76
+ async purgeEntryData(entry, defaultAgentId) {
77
+ if (entry.id === "main") throw new Error("Refusing to purge the primary Agent");
78
+ const workspace = workspaceForEntry(entry, defaultAgentId);
79
+ const home = resolveAgentHomeDir(entry.id);
80
+ this.assertSafeWorkspacePurge(workspace);
81
+ this.assertPurgeTargetsAreNotShared(entry.id, [home, workspace], defaultAgentId);
82
+ if (existsSync(home)) await rm(home, {
83
+ recursive: true,
84
+ force: true
85
+ });
86
+ if (existsSync(workspace) && resolve(workspace) !== resolve(home)) await rm(workspace, {
87
+ recursive: true,
88
+ force: true
89
+ });
90
+ }
91
+ validatePurgeEntry(entry, defaultAgentId) {
92
+ if (entry.id === "main") throw new Error("Refusing to purge the primary Agent");
93
+ const workspace = workspaceForEntry(entry, defaultAgentId);
94
+ this.assertSafeWorkspacePurge(workspace);
95
+ this.assertPurgeTargetsAreNotShared(entry.id, [resolveAgentHomeDir(entry.id), workspace], defaultAgentId);
96
+ }
97
+ async resumePendingPurge() {
98
+ const failed = [];
99
+ for (const agentId of this.repository.listPendingPurgeAgentIds()) {
100
+ const agent = this.repository.get(agentId, { includeDeleted: true });
101
+ if (!agent) continue;
102
+ try {
103
+ await this.purgeEntryData(agent, this.repository.getSettings().defaultAgentId);
104
+ this.repository.markPurged(agentId);
105
+ } catch (error) {
106
+ this.repository.markPurgeFailed(agentId, error instanceof Error ? error.message : String(error));
107
+ failed.push(agentId);
108
+ }
109
+ }
110
+ return failed;
111
+ }
112
+ resumePendingPurgeSync() {
113
+ for (const agentId of this.repository.listPendingPurgeAgentIds()) {
114
+ const agent = this.repository.get(agentId, { includeDeleted: true });
115
+ if (!agent) continue;
116
+ try {
117
+ this.purgeEntryDataSync(agent, this.repository.getSettings().defaultAgentId);
118
+ this.repository.markPurged(agentId);
119
+ } catch (error) {
120
+ this.repository.markPurgeFailed(agentId, error instanceof Error ? error.message : String(error));
121
+ }
122
+ }
123
+ }
124
+ setDefault(agentId) {
125
+ const settings = this.repository.getSettings();
126
+ return this.repository.setDefault(agentId, settings.revision);
127
+ }
128
+ updateDefaults(defaults) {
129
+ const settings = this.repository.getSettings();
130
+ return this.repository.updateDefaults(defaults, settings.revision);
131
+ }
132
+ replaceBindings(bindings) {
133
+ return this.repository.replaceBindings(bindings);
134
+ }
135
+ setSurfaceDefault(surface, agentId) {
136
+ this.repository.setSurfaceDefault(surface, agentId);
137
+ }
138
+ clearSurfaceDefault(surface) {
139
+ this.repository.clearSurfaceDefault(surface);
140
+ }
141
+ async delete(agentIdRaw, options = {}) {
142
+ const agentId = normalizeAgentId(agentIdRaw);
143
+ const current = this.repository.get(agentId);
144
+ if (!current) throw new Error(`Agent "${agentId}" not found`);
145
+ if (options.purge) this.validatePurgeEntry(current, this.repository.getSettings().defaultAgentId);
146
+ const result = this.repository.delete(agentId, options);
147
+ if (options.purge) {
148
+ if ((await this.resumePendingPurge()).includes(agentId)) throw new Error(`Agent "${agentId}" was deleted; data purge is pending retry`);
149
+ }
150
+ return { removedBindings: result.removedBindings };
151
+ }
152
+ async provision(entry) {
153
+ const workspace = workspaceForEntry(entry, this.repository.getSettings().defaultAgentId);
154
+ const profileDir = resolveAgentProfileDir(entry.id);
155
+ await mkdir(workspace, { recursive: true });
156
+ await mkdir(resolveAgentDir(entry.id), { recursive: true });
157
+ await mkdir(profileDir, { recursive: true });
158
+ seedAgentProfileMarkdownFiles(profileDir, workspace, { displayName: entry.profile?.name ?? entry.id });
159
+ }
160
+ provisionSync(entry) {
161
+ const workspace = workspaceForEntry(entry, this.repository.getSettings().defaultAgentId);
162
+ const profileDir = resolveAgentProfileDir(entry.id);
163
+ mkdirSync(workspace, { recursive: true });
164
+ mkdirSync(resolveAgentDir(entry.id), { recursive: true });
165
+ mkdirSync(profileDir, { recursive: true });
166
+ seedAgentProfileMarkdownFiles(profileDir, workspace, { displayName: entry.profile?.name ?? entry.id });
167
+ }
168
+ purgeEntryDataSync(entry, defaultAgentId) {
169
+ if (entry.id === "main") throw new Error("Refusing to purge the primary Agent");
170
+ const workspace = workspaceForEntry(entry, defaultAgentId);
171
+ const home = resolveAgentHomeDir(entry.id);
172
+ this.assertSafeWorkspacePurge(workspace);
173
+ this.assertPurgeTargetsAreNotShared(entry.id, [home, workspace], defaultAgentId);
174
+ if (existsSync(home)) rmSync(home, {
175
+ recursive: true,
176
+ force: true
177
+ });
178
+ if (existsSync(workspace) && resolve(workspace) !== resolve(home)) rmSync(workspace, {
179
+ recursive: true,
180
+ force: true
181
+ });
182
+ }
183
+ assertSafeWorkspacePurge(workspaceRaw) {
184
+ const workspace = resolve(workspaceRaw);
185
+ const stateDir = resolve(resolveStateDir(process.env));
186
+ const rel = relative(workspace, stateDir);
187
+ if (workspace === parse(workspace).root || workspace === stateDir || rel === "" || !rel.startsWith("..") && !isAbsolute(rel)) throw new Error(`Refusing to purge unsafe workspace path: ${workspace}`);
188
+ }
189
+ assertPurgeTargetsAreNotShared(agentId, targetsRaw, defaultAgentId) {
190
+ const targets = [...new Set(targetsRaw.map((target) => resolve(target)))];
191
+ for (const other of this.repository.list()) {
192
+ if (other.id === agentId) continue;
193
+ const otherWorkspace = resolve(workspaceForEntry(other, defaultAgentId));
194
+ if (targets.some((target) => {
195
+ const rel = relative(target, otherWorkspace);
196
+ return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
197
+ })) throw new Error(`Refusing to purge workspace used by Agent "${other.id}"`);
198
+ }
199
+ }
200
+ };
201
+ //#endregion
202
+ export { AgentCatalogService };
@@ -0,0 +1,14 @@
1
+ import type { AgentDefaults, AgentEntry } from '../agent-config/index.js';
2
+ import type { BindingRule } from '../routing/binding-schema.js';
3
+ import { AgentCatalogRepository } from './repository.js';
4
+ export type TestAgentCatalogSeed = {
5
+ defaults?: AgentDefaults;
6
+ defaultAgentId?: string;
7
+ agents?: AgentEntry[];
8
+ bindings?: BindingRule[];
9
+ surfaceDefaults?: Record<string, string>;
10
+ };
11
+ /** Build an isolated, ready in-memory Agent catalog for a unit test. */
12
+ export declare function initializeTestAgentCatalog(seed?: TestAgentCatalogSeed): AgentCatalogRepository;
13
+ /** Seed the currently open test database with a ready Agent catalog. */
14
+ export declare function seedTestAgentCatalog(seed?: TestAgentCatalogSeed): AgentCatalogRepository;
@@ -0,0 +1,34 @@
1
+ import { closeXopcDatabase, openXopcDatabase } from "../storage/sqlite/connection.js";
2
+ import { init_sqlite } from "../storage/sqlite/index.js";
3
+ import { AgentCatalogRepository, init_repository } from "./repository.js";
4
+ //#region src/agent-catalog/test-support.ts
5
+ init_sqlite();
6
+ init_repository();
7
+ /** Build an isolated, ready in-memory Agent catalog for a unit test. */
8
+ function initializeTestAgentCatalog(seed = {}) {
9
+ closeXopcDatabase();
10
+ openXopcDatabase({ path: ":memory:" });
11
+ return seedTestAgentCatalog(seed);
12
+ }
13
+ /** Seed the currently open test database with a ready Agent catalog. */
14
+ function seedTestAgentCatalog(seed = {}) {
15
+ const repository = new AgentCatalogRepository();
16
+ repository.ensureInitialized(seed.defaults);
17
+ const entries = seed.agents ?? [{
18
+ id: "main",
19
+ enabled: true
20
+ }];
21
+ const main = entries.find((entry) => entry.id === "main");
22
+ if (main) {
23
+ const stored = repository.get("main");
24
+ repository.update("main", stored.revision, main);
25
+ }
26
+ repository.markProvisioned("main");
27
+ for (const entry of entries) if (entry.id !== "main") repository.create(entry, { ready: true });
28
+ if (seed.defaultAgentId && seed.defaultAgentId !== "main") repository.setDefault(seed.defaultAgentId, repository.getSettings().revision);
29
+ if (seed.bindings) repository.replaceBindings(seed.bindings);
30
+ for (const [surface, agentId] of Object.entries(seed.surfaceDefaults ?? {})) repository.setSurfaceDefault(surface, agentId);
31
+ return repository;
32
+ }
33
+ //#endregion
34
+ export { initializeTestAgentCatalog, seedTestAgentCatalog };
@@ -0,0 +1,26 @@
1
+ import type { AgentDefaults, AgentEntry } from '../agent-config/index.js';
2
+ import type { BindingRule } from '../routing/binding-schema.js';
3
+ export type AgentProvisioningState = 'pending' | 'ready' | 'error';
4
+ export interface StoredAgent extends AgentEntry {
5
+ revision: number;
6
+ provisioningState: AgentProvisioningState;
7
+ provisioningError?: string;
8
+ createdAt: number;
9
+ updatedAt: number;
10
+ deletedAt?: number;
11
+ }
12
+ export interface AgentCatalogSnapshot {
13
+ revision: number;
14
+ defaultAgentId: string;
15
+ defaults: AgentDefaults;
16
+ agents: AgentEntry[];
17
+ bindings: BindingRule[];
18
+ surfaceDefaults: Record<string, string>;
19
+ }
20
+ export interface AgentCatalogSettings {
21
+ defaultAgentId: string;
22
+ defaults: AgentDefaults;
23
+ revision: number;
24
+ createdAt: number;
25
+ updatedAt: number;
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
- import { AgentDefaultsSchema, AgentEntrySchema, AgentModelsDefaultsSchema, AgentModelsOverrideSchema, AgentProfileSchema, AgentsConfigSchema, ComputerModelRouteSchema, DEFAULT_AGENT_MODEL_REF, DEFAULT_CORE_SKILLS, DEFAULT_SKILL_POLICY, EffectiveAgentConfigSchema, ImageGenerationRouteSchema, ModelIntentSchema, ModelRefSchema, ModelRouteSchema, RuntimePolicySchema, SkillDefaultsSchema, SkillOverrideSchema, ToolModeSchema, ToolPoliciesSchema, ToolPolicySchema, WorkflowPolicySchema, init_schema } from "./schema.js";
2
+ import { AgentDefaultsSchema, AgentEntrySchema, AgentIdSchema, AgentModelsDefaultsSchema, AgentModelsOverrideSchema, AgentProfileSchema, ComputerModelRouteSchema, DEFAULT_AGENT_MODEL_REF, DEFAULT_CORE_SKILLS, DEFAULT_SKILL_POLICY, EffectiveAgentConfigSchema, ImageGenerationRouteSchema, ModelIntentSchema, ModelRefSchema, ModelRouteSchema, RuntimePolicySchema, SkillDefaultsSchema, SkillOverrideSchema, ToolModeSchema, ToolPoliciesSchema, ToolPolicySchema, WorkflowPolicySchema, init_schema } from "./schema.js";
3
3
  import { init_resolver, resolveEffectiveAgentConfig } from "./resolver.js";
4
4
  //#region src/agent-config/index.ts
5
5
  var init_agent_config = __esmMin((() => {
@@ -8,4 +8,4 @@ var init_agent_config = __esmMin((() => {
8
8
  }));
9
9
  //#endregion
10
10
  init_agent_config();
11
- export { AgentDefaultsSchema, AgentEntrySchema, AgentModelsDefaultsSchema, AgentModelsOverrideSchema, AgentProfileSchema, AgentsConfigSchema, ComputerModelRouteSchema, DEFAULT_AGENT_MODEL_REF, DEFAULT_CORE_SKILLS, DEFAULT_SKILL_POLICY, EffectiveAgentConfigSchema, ImageGenerationRouteSchema, ModelIntentSchema, ModelRefSchema, ModelRouteSchema, RuntimePolicySchema, SkillDefaultsSchema, SkillOverrideSchema, ToolModeSchema, ToolPoliciesSchema, ToolPolicySchema, WorkflowPolicySchema, init_agent_config, resolveEffectiveAgentConfig };
11
+ export { AgentDefaultsSchema, AgentEntrySchema, AgentIdSchema, AgentModelsDefaultsSchema, AgentModelsOverrideSchema, AgentProfileSchema, ComputerModelRouteSchema, DEFAULT_AGENT_MODEL_REF, DEFAULT_CORE_SKILLS, DEFAULT_SKILL_POLICY, EffectiveAgentConfigSchema, ImageGenerationRouteSchema, ModelIntentSchema, ModelRefSchema, ModelRouteSchema, RuntimePolicySchema, SkillDefaultsSchema, SkillOverrideSchema, ToolModeSchema, ToolPoliciesSchema, ToolPolicySchema, WorkflowPolicySchema, init_agent_config, resolveEffectiveAgentConfig };