@xopcai/xopc 0.0.230 → 0.0.232

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 (384) hide show
  1. package/README.md +1 -0
  2. package/README.zh-CN.md +1 -0
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/feishu/src/schema/config-schema.d.ts +3 -3
  5. package/dist/extensions/telegram/src/config-schema.d.ts +4 -4
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/extensions/weixin/src/config-schema.d.ts +3 -3
  8. package/dist/gateway/static/root/assets/{activity-store-M0nAY5XB.js → activity-store-VXCWz43N.js} +1 -1
  9. package/dist/gateway/static/root/assets/agent-avatar-dicebear-BXRaZYW8.js +1 -0
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-dR7HMaRX.js +1 -0
  11. package/dist/gateway/static/root/assets/agents-Bileycwe.js +1 -0
  12. package/dist/gateway/static/root/assets/api-wGPgL8xY.js +1 -0
  13. package/dist/gateway/static/root/assets/{app-management-settings-panel-CwAPK4Jm.js → app-management-settings-panel-BJfClfPx.js} +1 -1
  14. package/dist/gateway/static/root/assets/{appearance-settings-DsGLvqTb.js → appearance-settings-C_R0vUAu.js} +1 -1
  15. package/dist/gateway/static/root/assets/{apps-page-Ee9qOQEx.js → apps-page-CBow8pBI.js} +1 -1
  16. package/dist/gateway/static/root/assets/{archive-plugin-7_DXaMTP.js → archive-plugin-DnFHkSHE.js} +1 -1
  17. package/dist/gateway/static/root/assets/{attachment-load-B4qqigAQ.js → attachment-load-DZrEwytM.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automations-page-B8ImehSW.js → automations-page-DpkKajui.js} +1 -1
  19. package/dist/gateway/static/root/assets/automations-workspace-BBntVWgv.js +6 -0
  20. package/dist/gateway/static/root/assets/{binary-plugins-DaJbyYc2.js → binary-plugins-Ckc_Csue.js} +1 -1
  21. package/dist/gateway/static/root/assets/{block-editor-Kl25XWJc.js → block-editor-DAC6w-iV.js} +4 -4
  22. package/dist/gateway/static/root/assets/browser-settings-page-DrsMd-Po.js +8 -0
  23. package/dist/gateway/static/root/assets/browser-workflow-inputs-BGd7R8GO.js +1 -0
  24. package/dist/gateway/static/root/assets/{browser-workflows-page-DjMxs33B.js → browser-workflows-page-DUfj7ntM.js} +2 -2
  25. package/dist/gateway/static/root/assets/capabilities-settings-panel-97gkGeSV.js +7 -0
  26. package/dist/gateway/static/root/assets/channels-settings-CuBsz8UI.js +1 -0
  27. package/dist/gateway/static/root/assets/{channel-recipient-api-C5ABr73b.js → channels-status-swr-CfboECLt.js} +1 -1
  28. package/dist/gateway/static/root/assets/{chat-terminal-dock-BiU_4Rq6.js → chat-terminal-dock-CA9fndbZ.js} +2 -2
  29. package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +1 -0
  30. package/dist/gateway/static/root/assets/{code-editor-dFzqyDXS.js → code-editor-D4_k-6QN.js} +1 -1
  31. package/dist/gateway/static/root/assets/connectors-page-SuL7td7Z.js +2 -0
  32. package/dist/gateway/static/root/assets/cron-expression-CqPu7HYJ.js +2 -0
  33. package/dist/gateway/static/root/assets/date-picker-C8dJsCgk.js +1 -0
  34. package/dist/gateway/static/root/assets/dependency-picker-Iz2wYimy.js +1 -0
  35. package/dist/gateway/static/root/assets/{desktop-pet-ux9DxchT.js → desktop-pet-C3h40FmG.js} +1 -1
  36. package/dist/gateway/static/root/assets/{desktop-pet-settings-BVVCBgYK.js → desktop-pet-settings-YfeVVzLe.js} +1 -1
  37. package/dist/gateway/static/root/assets/dist-DqPZM2MH2.js +1 -0
  38. package/dist/gateway/static/root/assets/{extension-debug-page-Dh6DDuvQ.js → extension-debug-page-CChgztz_.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-page-8OKQDEat.js → extension-page-DF6ct6_y.js} +1 -1
  40. package/dist/gateway/static/root/assets/extension-settings-page-jgBsjn0F.js +1 -0
  41. package/dist/gateway/static/root/assets/files-Dp8_uGTO.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-config-api-Dlc6eaTG.js → gateway-config-api-CVajuIGL.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-config-swr-BGQn8duh.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-settings-DqQgiAUv.js → gateway-settings-BbssNGid.js} +1 -1
  45. package/dist/gateway/static/root/assets/{gateway-startup-retry-B_zrtccP.js → gateway-startup-retry-D2Rnh9fX.js} +1 -1
  46. package/dist/gateway/static/root/assets/heartbeat-settings-CJtXu8iD.js +1 -0
  47. package/dist/gateway/static/root/assets/home-page-Be1o1AXQ.js +1 -0
  48. package/dist/gateway/static/root/assets/html-workspace-editor-C3DKAkMc.js +1 -0
  49. package/dist/gateway/static/root/assets/{image-generation-api-YKP2me5Z.js → image-generation-api-D7W2p5_8.js} +1 -1
  50. package/dist/gateway/static/root/assets/index-B2OJSXX9.js +70 -0
  51. package/dist/gateway/static/root/assets/index-rHjAElxG.css +2 -0
  52. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BSFNqxzY.js → keyboard-shortcuts-settings-BvHYyNus.js} +1 -1
  53. package/dist/gateway/static/root/assets/local-app-workbench-page-COfelgk7.js +2 -0
  54. package/dist/gateway/static/root/assets/{local-apps-page-DzU6yZ9-.js → local-apps-page-Cb8t2wWM.js} +1 -1
  55. package/dist/gateway/static/root/assets/locale-store-DLwVxS3V.js +1 -0
  56. package/dist/gateway/static/root/assets/logs-page-DA8oDjeB.js +2 -0
  57. package/dist/gateway/static/root/assets/management-settings-B8Jie4-J.js +1 -0
  58. package/dist/gateway/static/root/assets/markdown-editor-nDLmA_LF.js +2 -0
  59. package/dist/gateway/static/root/assets/markdown-split-BD1r4o2i.js +1 -0
  60. package/dist/gateway/static/root/assets/{markdown-view-DvM5PWEH.js → markdown-view-B-BHEcNd.js} +1 -1
  61. package/dist/gateway/static/root/assets/markdown-view-B1bGSQqt.css +1 -0
  62. package/dist/gateway/static/root/assets/{media-plugins-B8vMe5VX.js → media-plugins-BCev8fkW.js} +1 -1
  63. package/dist/gateway/static/root/assets/messages-Dp1OxSKt.js +3 -0
  64. package/dist/gateway/static/root/assets/mobile-device-api-DACoHhhk.js +1 -0
  65. package/dist/gateway/static/root/assets/models-hub-cache-C8zjqmIv.js +1 -0
  66. package/dist/gateway/static/root/assets/{notes-api-BFsOGYkd.js → notes-api-DEdNKw0I.js} +1 -1
  67. package/dist/gateway/static/root/assets/{notes-page-B-YZ7iuK.js → notes-page-BBTLjJwa.js} +1 -1
  68. package/dist/gateway/static/root/assets/notes-workbench-DICgUGPv.js +4 -0
  69. package/dist/gateway/static/root/assets/oauth-api-BNCO2YK5.js +1 -0
  70. package/dist/gateway/static/root/assets/popover-select-3E24E65N.js +1 -0
  71. package/dist/gateway/static/root/assets/{product-open-page-DkWcyki5.js → product-open-page-fEBbRekH.js} +1 -1
  72. package/dist/gateway/static/root/assets/project-detail-page-CqdkznYJ.js +1 -0
  73. package/dist/gateway/static/root/assets/projects-page-dHDXpMCg.js +1 -0
  74. package/dist/gateway/static/root/assets/{registry-api-BFZrVYfy.js → registry-api-Cvr4Qm7N.js} +1 -1
  75. package/dist/gateway/static/root/assets/remote-access-hub-2feZudJw.js +1 -0
  76. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bq_ETeal.js → runtime-tools-settings-panel-BT5B74IH.js} +2 -2
  77. package/dist/gateway/static/root/assets/{schema-form-BogTlrsP.js → schema-form-C4tB34S5.js} +1 -1
  78. package/dist/gateway/static/root/assets/sessions-page-CO2JCFdy.js +1 -0
  79. package/dist/gateway/static/root/assets/settings-advanced-gate-DxMVaqdn.js +1 -0
  80. package/dist/gateway/static/root/assets/{settings-form-section-Coy1Cbp6.js → settings-form-section-D1oXhkgI.js} +1 -1
  81. package/dist/gateway/static/root/assets/settings-loading-skeleton-CldfX6FJ.js +1 -0
  82. package/dist/gateway/static/root/assets/settings-page-c3LJnbvE.js +1 -0
  83. package/dist/gateway/static/root/assets/settings-shell-layer-context-DCp6ykjQ.js +1 -0
  84. package/dist/gateway/static/root/assets/setup-status-panel-DZNHb6A5.js +1 -0
  85. package/dist/gateway/static/root/assets/share-preview-page-DptCK_mk.js +2 -0
  86. package/dist/gateway/static/root/assets/shares-settings-DakZ2AGN.js +1 -0
  87. package/dist/gateway/static/root/assets/skill-reload-api-BOiNkWJC.js +1 -0
  88. package/dist/gateway/static/root/assets/{skills-page-Brxb6QnW.js → skills-page-OHBeBtSg.js} +1 -1
  89. package/dist/gateway/static/root/assets/{skills-page.utils-FB5LtEGm.js → skills-page.utils-B9WZbOLC.js} +1 -1
  90. package/dist/gateway/static/root/assets/{system-settings-panel-ChosWt8n.js → system-settings-panel-Dj_DpOGw.js} +1 -1
  91. package/dist/gateway/static/root/assets/task-detail-page-D5Nbe3C8.js +1 -0
  92. package/dist/gateway/static/root/assets/theme-store-Cpd3Gd5R.js +1 -0
  93. package/dist/gateway/static/root/assets/{use-autosave-2SqnmSKD.js → use-autosave-DCl5Yq7N.js} +1 -1
  94. package/dist/gateway/static/root/assets/user-context-page-CAPSUK8B.js +1 -0
  95. package/dist/gateway/static/root/assets/{vendor-codemirror-DRr7hFaD.js → vendor-codemirror--gTq3YAI.js} +16 -16
  96. package/dist/gateway/static/root/assets/voice-api-key-field-BB_ZQV8F.js +1 -0
  97. package/dist/gateway/static/root/assets/voice-config-api-BNiYmpl5.js +1 -0
  98. package/dist/gateway/static/root/assets/{work-discovery-overlay-CK3aZDdE.js → work-discovery-overlay-BrIdtdum.js} +1 -1
  99. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BjOuddkX.js → workflow-run-setup-panel-hKh-uCLo.js} +2 -2
  100. package/dist/gateway/static/root/assets/workflows-page-ahDvypGO.js +5 -0
  101. package/dist/gateway/static/root/index.html +19 -15
  102. package/dist/package.js +1 -1
  103. package/dist/src/agent/agent-manager.d.ts +1 -2
  104. package/dist/src/agent/agent-manager.js +29 -44
  105. package/dist/src/agent/background-review/run-background-review.js +10 -15
  106. package/dist/src/agent/embedded/run-for-session.js +1 -1
  107. package/dist/src/agent/external-tools/mcp-provider.js +3 -13
  108. package/dist/src/agent/image/generation/runtime.js +1 -1
  109. package/dist/src/agent/image/tool-model-config.js +13 -14
  110. package/dist/src/agent/mcp/bundle-mcp-policy.d.ts +0 -9
  111. package/dist/src/agent/mcp/bundle-mcp-policy.js +1 -13
  112. package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
  113. package/dist/src/agent/mcp/index.js +2 -2
  114. package/dist/src/agent/media-generation/runtime-shared.d.ts +1 -1
  115. package/dist/src/agent/media-generation/runtime-shared.js +1 -1
  116. package/dist/src/agent/memory/create-memory-manager.js +1 -1
  117. package/dist/src/agent/memory/manager.d.ts +1 -1
  118. package/dist/src/{agent-runtime/memory-runtime.d.ts → agent/memory/runtime.d.ts} +1 -1
  119. package/dist/src/{agent-runtime/memory-runtime.js → agent/memory/runtime.js} +2 -3
  120. package/dist/src/agent/orchestration/agent-orchestrator.d.ts +0 -3
  121. package/dist/src/agent/orchestration/agent-orchestrator.js +1 -3
  122. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +2 -2
  123. package/dist/src/agent/service.d.ts +1 -0
  124. package/dist/src/agent/service.js +5 -3
  125. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  126. package/dist/src/agent/starter-agents.js +1 -8
  127. package/dist/src/agent/tools/executor.d.ts +1 -1
  128. package/dist/src/agent/tools/workflow-tool.js +1 -5
  129. package/dist/src/agent/tools/write.js +9 -12
  130. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  131. package/dist/src/agent-config/index.d.ts +2 -0
  132. package/dist/src/agent-config/index.js +11 -0
  133. package/dist/src/agent-config/resolver.d.ts +11 -0
  134. package/dist/src/agent-config/resolver.js +113 -0
  135. package/dist/src/agent-config/schema.d.ts +491 -0
  136. package/dist/src/agent-config/schema.js +172 -0
  137. package/dist/src/auth/oauth/index.js +2 -2
  138. package/dist/src/auth/oauth/registry.d.ts +1 -1
  139. package/dist/src/auth/oauth/registry.js +5 -1
  140. package/dist/src/auth/oauth/xopc-cloud.d.ts +1 -0
  141. package/dist/src/auth/oauth/xopc-cloud.js +8 -2
  142. package/dist/src/chat-commands/builtins/config.js +2 -2
  143. package/dist/src/chat-commands/builtins/review.js +1 -1
  144. package/dist/src/chat-commands/config-paths.js +1 -1
  145. package/dist/src/cli/commands/agents.js +2 -1
  146. package/dist/src/cli/commands/config.js +1 -1
  147. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  148. package/dist/src/cli/commands/doctor/checks/provider-auth.js +12 -4
  149. package/dist/src/cli/commands/image.js +3 -4
  150. package/dist/src/cli/commands/models.js +9 -3
  151. package/dist/src/cli/commands/onboard/model.js +12 -11
  152. package/dist/src/cli/commands/onboard.js +1 -1
  153. package/dist/src/cli/commands/tunnel.js +3 -18
  154. package/dist/src/cli/utils/init-workspace-core.d.ts +1 -1
  155. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  156. package/dist/src/commands/agents.config.d.ts +1 -3
  157. package/dist/src/commands/agents.config.js +9 -26
  158. package/dist/src/config/agent-model-intents.d.ts +10 -0
  159. package/dist/src/config/agent-model-intents.js +39 -0
  160. package/dist/src/config/agent-profile.d.ts +7 -9
  161. package/dist/src/config/agent-profile.js +30 -28
  162. package/dist/src/config/default-model.d.ts +1 -11
  163. package/dist/src/config/default-model.js +3 -11
  164. package/dist/src/config/index.js +3 -3
  165. package/dist/src/config/integration.d.ts +1 -1
  166. package/dist/src/config/reload.js +1 -1
  167. package/dist/src/config/rules.js +3 -3
  168. package/dist/src/config/schema.d.ts +187 -452
  169. package/dist/src/config/schema.js +53 -131
  170. package/dist/src/extensions/activation-context.js +7 -11
  171. package/dist/src/files/file-service.d.ts +36 -0
  172. package/dist/src/files/file-service.js +282 -0
  173. package/dist/src/gateway/agent-builtin-tools.d.ts +250 -6
  174. package/dist/src/gateway/agent-builtin-tools.js +284 -46
  175. package/dist/src/gateway/agents-admin.d.ts +20 -62
  176. package/dist/src/gateway/agents-admin.js +36 -228
  177. package/dist/src/gateway/device-routes.d.ts +3 -0
  178. package/dist/src/gateway/device-routes.js +47 -0
  179. package/dist/src/gateway/global-defaults-admin.d.ts +6 -20
  180. package/dist/src/gateway/global-defaults-admin.js +20 -120
  181. package/dist/src/gateway/heartbeat/service.js +1 -1
  182. package/dist/src/gateway/hono/app.js +6 -4
  183. package/dist/src/gateway/hono/lib/config-payload.d.ts +54 -137
  184. package/dist/src/gateway/hono/lib/config-payload.js +2 -4
  185. package/dist/src/gateway/hono/middleware/auth.js +33 -1
  186. package/dist/src/gateway/hono/middleware/scopes.d.ts +2 -12
  187. package/dist/src/gateway/hono/middleware/scopes.js +9 -18
  188. package/dist/src/gateway/hono/routes/agents.js +64 -100
  189. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  190. package/dist/src/gateway/hono/routes/device-push.d.ts +2 -0
  191. package/dist/src/gateway/hono/routes/{mobile.js → device-push.js} +40 -18
  192. package/dist/src/gateway/hono/routes/devices.d.ts +4 -0
  193. package/dist/src/gateway/hono/routes/devices.js +214 -0
  194. package/dist/src/gateway/hono/routes/files.d.ts +3 -0
  195. package/dist/src/gateway/hono/routes/files.js +176 -0
  196. package/dist/src/gateway/hono/routes/global-defaults.js +5 -9
  197. package/dist/src/gateway/hono/routes/index.js +4 -2
  198. package/dist/src/gateway/hono/routes/lazy-bundles.js +12 -20
  199. package/dist/src/gateway/hono/routes/models.js +2 -2
  200. package/dist/src/gateway/hono/routes/projects.js +0 -508
  201. package/dist/src/gateway/hono/routes/realtime.js +8 -1
  202. package/dist/src/gateway/hono/routes/shares.js +410 -21
  203. package/dist/src/gateway/hono/routes/status.js +9 -16
  204. package/dist/src/gateway/hono/routes/tunnel.d.ts +0 -2
  205. package/dist/src/gateway/hono/routes/tunnel.js +10 -199
  206. package/dist/src/gateway/hono/routes/voice.js +1 -1
  207. package/dist/src/gateway/hono/routes/workspace.js +15 -974
  208. package/dist/src/gateway/image-generation-setup.d.ts +2 -2
  209. package/dist/src/gateway/image-generation-setup.js +8 -7
  210. package/dist/src/gateway/public-url.d.ts +1 -1
  211. package/dist/src/gateway/security/gateway-principal.d.ts +11 -0
  212. package/dist/src/gateway/security/gateway-principal.js +12 -0
  213. package/dist/src/gateway/security/gateway-scopes.d.ts +7 -0
  214. package/dist/src/gateway/security/gateway-scopes.js +66 -0
  215. package/dist/src/gateway/security/index.d.ts +2 -1
  216. package/dist/src/gateway/security/index.js +3 -2
  217. package/dist/src/gateway/service.js +4 -4
  218. package/dist/src/gateway/xopc-cloud-capability-setup.js +19 -21
  219. package/dist/src/heartbeat/index.js +1 -1
  220. package/dist/src/migrations/index.d.ts +0 -1
  221. package/dist/src/migrations/index.js +1 -2
  222. package/dist/src/migrations/runner.js +1 -2
  223. package/dist/src/notifications/device-store.d.ts +1 -1
  224. package/dist/src/notifications/device-store.js +11 -11
  225. package/dist/src/notifications/store.js +3 -3
  226. package/dist/src/providers/index.js +1 -1
  227. package/dist/src/providers/model-reference-auditor.js +14 -9
  228. package/dist/src/realtime/runtime.d.ts +2 -0
  229. package/dist/src/realtime/runtime.js +27 -3
  230. package/dist/src/realtime/tickets.d.ts +6 -1
  231. package/dist/src/realtime/tickets.js +2 -1
  232. package/dist/src/remote-access/exposure-manager.js +3 -3
  233. package/dist/src/share/hosted-session-share.d.ts +104 -0
  234. package/dist/src/share/hosted-session-share.js +276 -0
  235. package/dist/src/share/note-share-service.js +4 -24
  236. package/dist/src/share/session-share-projector.d.ts +31 -0
  237. package/dist/src/share/session-share-projector.js +79 -0
  238. package/dist/src/share/session-share-service.d.ts +89 -0
  239. package/dist/src/share/session-share-service.js +325 -0
  240. package/dist/src/share/share-asset-ticket.d.ts +7 -0
  241. package/dist/src/share/share-asset-ticket.js +30 -0
  242. package/dist/src/share/share-landing.d.ts +4 -3
  243. package/dist/src/share/share-landing.js +5 -5
  244. package/dist/src/share/share-store.d.ts +27 -2
  245. package/dist/src/share/share-store.js +71 -8
  246. package/dist/src/share/share-types.d.ts +17 -2
  247. package/dist/src/share/share-url.js +2 -2
  248. package/dist/src/storage/sqlite/device-access-repository.d.ts +54 -0
  249. package/dist/src/storage/sqlite/device-access-repository.js +194 -0
  250. package/dist/src/storage/sqlite/device-pairing-repository.d.ts +22 -0
  251. package/dist/src/storage/sqlite/device-pairing-repository.js +86 -0
  252. package/dist/src/storage/sqlite/gateway-identity-repository.d.ts +10 -0
  253. package/dist/src/storage/sqlite/gateway-identity-repository.js +50 -0
  254. package/dist/src/storage/sqlite/index.d.ts +3 -0
  255. package/dist/src/storage/sqlite/index.js +4 -1
  256. package/dist/src/storage/sqlite/migrations/138_device_access.sql +96 -0
  257. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  258. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  259. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  260. package/dist/src/storage/sqlite/schema.js +1 -1
  261. package/dist/src/tui/backends/embedded-backend.js +1 -1
  262. package/dist/src/tui/backends/gateway-realtime-backend.js +11 -3
  263. package/dist/src/tunnel/consent.d.ts +1 -1
  264. package/dist/src/tunnel/consent.js +1 -1
  265. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  266. package/dist/src/tunnel/index.d.ts +1 -4
  267. package/dist/src/tunnel/index.js +3 -5
  268. package/dist/src/tunnel/tunnel-audit.d.ts +1 -1
  269. package/dist/src/tunnel/tunnel-config.js +1 -1
  270. package/dist/src/tunnel/tunnel-service.d.ts +2 -3
  271. package/dist/src/tunnel/tunnel-service.js +1 -20
  272. package/dist/src/tunnel/tunnel-types.d.ts +0 -6
  273. package/dist/src/workflows/draft/workflow-draft-service.js +2 -2
  274. package/dist/src/workflows/service/workflow-run-service.js +3 -3
  275. package/package.json +3 -3
  276. package/dist/gateway/static/root/assets/agent-avatar-dicebear-Bp_wmuGW.js +0 -1
  277. package/dist/gateway/static/root/assets/agents-CKG93dlc.js +0 -68
  278. package/dist/gateway/static/root/assets/api-BywYxpaS.js +0 -1
  279. package/dist/gateway/static/root/assets/automations-workspace-BNFAfNwC.js +0 -6
  280. package/dist/gateway/static/root/assets/browser-settings-page-Cg6NgwE_.js +0 -8
  281. package/dist/gateway/static/root/assets/browser-workflow-inputs-8NC2qDRF.js +0 -1
  282. package/dist/gateway/static/root/assets/capabilities-settings-panel-NvJKgF1u.js +0 -7
  283. package/dist/gateway/static/root/assets/capability-presets-api-o0y9WgAI.js +0 -1
  284. package/dist/gateway/static/root/assets/capability-presets-settings-panel-C2uBdALe.js +0 -3
  285. package/dist/gateway/static/root/assets/channels-settings-CIcYKMEs.js +0 -1
  286. package/dist/gateway/static/root/assets/channels-status-swr-38FsOnR0.js +0 -1
  287. package/dist/gateway/static/root/assets/connectors-page-CEEcmUiP.js +0 -2
  288. package/dist/gateway/static/root/assets/cron-expression-Cs_5pUPT.js +0 -2
  289. package/dist/gateway/static/root/assets/date-picker-y1kWrFVU.js +0 -1
  290. package/dist/gateway/static/root/assets/dependency-picker-skc62zrn.js +0 -1
  291. package/dist/gateway/static/root/assets/directory-picker-path-field-V8vZP0Dy.js +0 -1
  292. package/dist/gateway/static/root/assets/dist-J_ySZvz0.js +0 -1
  293. package/dist/gateway/static/root/assets/extension-settings-page-BgSV0Nny.js +0 -1
  294. package/dist/gateway/static/root/assets/file-code-corner-byQA1VfD.js +0 -1
  295. package/dist/gateway/static/root/assets/gateway-config-swr-BWGjnmDl.js +0 -1
  296. package/dist/gateway/static/root/assets/heartbeat-settings-Pxqk5GFH.js +0 -1
  297. package/dist/gateway/static/root/assets/home-page-1xjo6wE4.js +0 -1
  298. package/dist/gateway/static/root/assets/html-workspace-editor-bXK5tq64.js +0 -1
  299. package/dist/gateway/static/root/assets/index-Bbd_dXui.js +0 -70
  300. package/dist/gateway/static/root/assets/index-D_hrEKXM.css +0 -2
  301. package/dist/gateway/static/root/assets/local-app-workbench-page-heQ4-PJ7.js +0 -2
  302. package/dist/gateway/static/root/assets/locale-store-CXhjfe4q.js +0 -1
  303. package/dist/gateway/static/root/assets/logs-page-BblnS6Jy.js +0 -2
  304. package/dist/gateway/static/root/assets/management-settings-B8hM56HS.js +0 -1
  305. package/dist/gateway/static/root/assets/markdown-editor-TWGaF7Xa.js +0 -2
  306. package/dist/gateway/static/root/assets/markdown-split-DRbZjxMK.js +0 -1
  307. package/dist/gateway/static/root/assets/markdown-view-CLzTdVLW.css +0 -1
  308. package/dist/gateway/static/root/assets/messages-BMdD0LWk.js +0 -3
  309. package/dist/gateway/static/root/assets/notes-workbench-CAM09C8b.js +0 -4
  310. package/dist/gateway/static/root/assets/popover-select-CccGri5Y.js +0 -1
  311. package/dist/gateway/static/root/assets/project-detail-page-BIPIwgU2.js +0 -1
  312. package/dist/gateway/static/root/assets/projects-page-B_kzTn1K.js +0 -1
  313. package/dist/gateway/static/root/assets/remote-access-hub-CtD8DsD-.js +0 -1
  314. package/dist/gateway/static/root/assets/sessions-page-B8n9HI1y.js +0 -1
  315. package/dist/gateway/static/root/assets/settings-advanced-gate-xlhdRTME.js +0 -1
  316. package/dist/gateway/static/root/assets/settings-loading-skeleton-B5GU7iCG.js +0 -1
  317. package/dist/gateway/static/root/assets/settings-page-Dd-BRu12.js +0 -1
  318. package/dist/gateway/static/root/assets/setup-status-panel-CwEFAVWx.js +0 -1
  319. package/dist/gateway/static/root/assets/share-preview-page-DzXw9UQJ.js +0 -2
  320. package/dist/gateway/static/root/assets/shares-settings-Bk6UQOwS.js +0 -1
  321. package/dist/gateway/static/root/assets/skill-reload-api-DrmQZ3Au.js +0 -1
  322. package/dist/gateway/static/root/assets/task-detail-page-CW2sJbdc.js +0 -1
  323. package/dist/gateway/static/root/assets/theme-store-DOdCjyuw.js +0 -1
  324. package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +0 -1
  325. package/dist/gateway/static/root/assets/user-context-page-Bq9KB-Oj.js +0 -1
  326. package/dist/gateway/static/root/assets/voice-api-key-field-DtTIF6M8.js +0 -1
  327. package/dist/gateway/static/root/assets/workflows-page-CcbGEQol.js +0 -5
  328. package/dist/src/agent-manifest/index.d.ts +0 -5
  329. package/dist/src/agent-manifest/index.js +0 -10
  330. package/dist/src/agent-manifest/preset-chain.d.ts +0 -10
  331. package/dist/src/agent-manifest/preset-chain.js +0 -30
  332. package/dist/src/agent-manifest/prompt.d.ts +0 -2
  333. package/dist/src/agent-manifest/prompt.js +0 -49
  334. package/dist/src/agent-manifest/resolver.d.ts +0 -32
  335. package/dist/src/agent-manifest/resolver.js +0 -114
  336. package/dist/src/agent-manifest/schema.d.ts +0 -695
  337. package/dist/src/agent-manifest/schema.js +0 -226
  338. package/dist/src/agent-manifest/validator.d.ts +0 -25
  339. package/dist/src/agent-manifest/validator.js +0 -74
  340. package/dist/src/agent-runtime/boundary-guard.d.ts +0 -12
  341. package/dist/src/agent-runtime/boundary-guard.js +0 -21
  342. package/dist/src/agent-runtime/index.d.ts +0 -7
  343. package/dist/src/agent-runtime/index.js +0 -8
  344. package/dist/src/agent-runtime/model-router.d.ts +0 -11
  345. package/dist/src/agent-runtime/model-router.js +0 -14
  346. package/dist/src/agent-runtime/run-trace.d.ts +0 -27
  347. package/dist/src/agent-runtime/run-trace.js +0 -51
  348. package/dist/src/agent-runtime/runtime-profile.d.ts +0 -26
  349. package/dist/src/agent-runtime/runtime-profile.js +0 -42
  350. package/dist/src/agent-runtime/tool-registry.d.ts +0 -28
  351. package/dist/src/agent-runtime/tool-registry.js +0 -50
  352. package/dist/src/agent-runtime/workflow-runtime.d.ts +0 -31
  353. package/dist/src/agent-runtime/workflow-runtime.js +0 -32
  354. package/dist/src/config/agent-typed-models.d.ts +0 -13
  355. package/dist/src/config/agent-typed-models.js +0 -48
  356. package/dist/src/gateway/capability-presets-admin.d.ts +0 -88
  357. package/dist/src/gateway/capability-presets-admin.js +0 -303
  358. package/dist/src/gateway/file-path-classifier.d.ts +0 -30
  359. package/dist/src/gateway/file-path-classifier.js +0 -105
  360. package/dist/src/gateway/file-reference-errors.d.ts +0 -6
  361. package/dist/src/gateway/file-reference-errors.js +0 -21
  362. package/dist/src/gateway/file-reference-registry.d.ts +0 -34
  363. package/dist/src/gateway/file-reference-registry.js +0 -45
  364. package/dist/src/gateway/hono/lib/agent-model.d.ts +0 -35
  365. package/dist/src/gateway/hono/lib/agent-model.js +0 -97
  366. package/dist/src/gateway/hono/routes/capability-presets.d.ts +0 -3
  367. package/dist/src/gateway/hono/routes/capability-presets.js +0 -187
  368. package/dist/src/gateway/hono/routes/mobile.d.ts +0 -3
  369. package/dist/src/gateway/security/operator-scopes.d.ts +0 -37
  370. package/dist/src/gateway/security/operator-scopes.js +0 -147
  371. package/dist/src/migrations/config/default-capability-preset.d.ts +0 -10
  372. package/dist/src/migrations/config/default-capability-preset.js +0 -133
  373. package/dist/src/tunnel/enable-lan-pairing.d.ts +0 -8
  374. package/dist/src/tunnel/enable-lan-pairing.js +0 -41
  375. package/dist/src/tunnel/pair-context.d.ts +0 -36
  376. package/dist/src/tunnel/pair-context.js +0 -77
  377. package/dist/src/tunnel/pair-url.d.ts +0 -43
  378. package/dist/src/tunnel/pair-url.js +0 -117
  379. package/dist/src/tunnel/pairing-rate-limit.d.ts +0 -12
  380. package/dist/src/tunnel/pairing-rate-limit.js +0 -28
  381. package/dist/src/tunnel/pairing.d.ts +0 -21
  382. package/dist/src/tunnel/pairing.js +0 -103
  383. package/dist/src/tunnel/tunnel-qr.d.ts +0 -9
  384. package/dist/src/tunnel/tunnel-qr.js +0 -29
@@ -1,83 +1,40 @@
1
- import { ToolPolicySetSchema, init_schema } from "../../../agent-manifest/schema.js";
2
- import { AgentModelsSchema, init_schema as init_schema$1 } from "../../../config/schema.js";
1
+ import { AgentModelsOverrideSchema, AgentProfileSchema, RuntimePolicySchema, SkillOverrideSchema, ToolPoliciesSchema, WorkflowPolicySchema } from "../../../agent-config/schema.js";
2
+ import { init_agent_config } from "../../../agent-config/index.js";
3
3
  import { init_agent_scope, normalizeAgentId } from "../../../agent/agent-scope.js";
4
- import { deleteAgentAvatarFile, finalizeCreateAgentDirs, getGatewayAgentEffectiveManifest, listAgentProfileFiles, listGatewayAgents, prepareCreateAgent, prepareDeleteAgent, prepareUpdateAgent, readAgentAvatarFile, readAgentProfileFile, runAfterDeletePurge, writeAgentAvatarFromBase64, writeAgentProfileFile } from "../../agents-admin.js";
4
+ import { deleteAgentAvatarFile, finalizeCreateAgentDirs, getGatewayAgentEffectiveConfig, listAgentProfileFiles, listGatewayAgents, prepareCreateAgent, prepareDeleteAgent, prepareUpdateAgent, readAgentAvatarFile, readAgentProfileFile, runAfterDeletePurge, writeAgentAvatarFromBase64, writeAgentProfileFile } from "../../agents-admin.js";
5
5
  import { getVoiceModelsConfig } from "../../../config/voice.js";
6
6
  //#region src/gateway/hono/routes/agents.ts
7
- init_schema$1();
8
- init_schema();
7
+ init_agent_config();
9
8
  init_agent_scope();
10
- function parseProfileFiles(raw) {
11
- if (raw === void 0) return;
12
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return { error: "profileFiles must be an object" };
13
- const profileFiles = {};
14
- for (const [name, content] of Object.entries(raw)) {
15
- if (typeof content !== "string") return { error: `profileFiles["${name}"] must be a string` };
16
- profileFiles[name] = content;
17
- }
18
- return profileFiles;
19
- }
20
9
  function isParseError(value) {
21
10
  return typeof value === "object" && value !== null && "error" in value && typeof value.error === "string";
22
11
  }
23
12
  function parseCreateAgentBody(raw) {
24
13
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return { error: "each agent must be an object" };
25
14
  const body = raw;
26
- if (Object.hasOwn(body, "model")) return { error: "model is not supported; use models.defaultRole and models.roles" };
27
- if (Object.hasOwn(body, "toolsDisable")) return { error: "toolsDisable was removed; use tools.builtin policies" };
28
- if (Object.hasOwn(body, "typedModels")) return { error: "typedModels is not supported; use models.roles" };
29
- if (Object.hasOwn(body, "agentDir")) return { error: "agentDir was removed from agent manifests" };
30
- if (Object.hasOwn(body, "name")) return { error: "name is not supported; write IDENTITY.md in profileFiles" };
31
- if (Object.hasOwn(body, "description")) return { error: "description is not supported; write IDENTITY.md in profileFiles" };
32
- const workspace = typeof body.workspace === "string" ? body.workspace : "";
33
- const models = Object.hasOwn(body, "models") ? AgentModelsSchema.safeParse(body.models) : void 0;
34
- if (models && !models.success) return { error: `models ${models.error.issues[0]?.message ?? "is invalid"}` };
15
+ const allowedKeys = new Set([
16
+ "id",
17
+ "workspace",
18
+ "profile"
19
+ ]);
20
+ const unknownKey = Object.keys(body).find((key) => !allowedKeys.has(key));
21
+ if (unknownKey) return { error: `unknown create-agent field "${unknownKey}"` };
22
+ const workspace = typeof body.workspace === "string" ? body.workspace : void 0;
23
+ const profile = AgentProfileSchema.safeParse(body.profile);
24
+ if (!profile.success) return { error: `profile ${profile.error.issues[0]?.message ?? "is required"}` };
35
25
  const id = typeof body.id === "string" ? body.id : void 0;
36
- const presetIds = Object.hasOwn(body, "extends") ? Array.isArray(body.extends) ? body.extends.map((x) => normalizeAgentId(String(x))).filter(Boolean) : null : void 0;
37
- if (presetIds === null) return { error: "extends must be an array" };
38
- const skills = Object.hasOwn(body, "skills") ? Array.isArray(body.skills) ? body.skills.map((x) => String(x).trim()).filter(Boolean) : null : void 0;
39
- if (skills === null) return { error: "skills must be an array" };
40
- const toolsRaw = Object.hasOwn(body, "tools") ? body.tools : void 0;
41
- let tools;
42
- if (toolsRaw !== void 0) {
43
- if (toolsRaw === null || typeof toolsRaw !== "object" || Array.isArray(toolsRaw)) return { error: "tools must be an object" };
44
- const parsedTools = ToolPolicySetSchema.safeParse(toolsRaw);
45
- if (!parsedTools.success) return { error: `tools ${parsedTools.error.issues[0]?.message ?? "is invalid"}` };
46
- tools = parsedTools.data;
47
- }
48
- let profileFiles;
49
- if (Object.hasOwn(body, "profileFiles")) {
50
- const parsed = parseProfileFiles(body.profileFiles);
51
- if (isParseError(parsed)) return parsed;
52
- profileFiles = parsed;
53
- }
54
- if (!profileFiles?.["IDENTITY.md"] && typeof body.cloneFrom !== "string") return { error: "profileFiles.IDENTITY.md is required" };
55
- const cloneFrom = typeof body.cloneFrom === "string" ? body.cloneFrom : void 0;
56
26
  return {
57
27
  workspace,
58
- ...models && models.data !== void 0 ? { models: models.data } : {},
59
- ...id !== void 0 ? { id } : {},
60
- ...presetIds !== void 0 ? { extends: presetIds } : {},
61
- ...skills !== void 0 ? { skills } : {},
62
- ...tools !== void 0 ? { tools } : {},
63
- ...profileFiles !== void 0 ? { profileFiles } : {},
64
- ...cloneFrom !== void 0 ? { cloneFrom } : {}
28
+ profile: profile.data,
29
+ ...id !== void 0 ? { id } : {}
65
30
  };
66
31
  }
67
32
  function parsePatchModels(raw) {
68
33
  if (raw === void 0) return;
69
34
  if (raw === null) return null;
70
35
  if (typeof raw !== "object" || Array.isArray(raw)) return { error: "models must be an object or null" };
71
- const body = raw;
72
- const out = {};
73
- if (Object.hasOwn(body, "defaultRole")) out.defaultRole = body.defaultRole === null ? null : String(body.defaultRole ?? "").trim();
74
- if (Object.hasOwn(body, "roles")) if (body.roles === null) return { error: "models.roles must be an object" };
75
- else {
76
- const parsed = AgentModelsSchema.safeParse({ roles: body.roles });
77
- if (!parsed.success) return { error: `models.roles ${parsed.error.issues[0]?.message ?? "is invalid"}` };
78
- out.roles = parsed.data?.roles;
79
- }
80
- return out;
36
+ const parsed = AgentModelsOverrideSchema.safeParse(raw);
37
+ return parsed.success ? parsed.data : { error: `models ${parsed.error.issues[0]?.message ?? "is invalid"}` };
81
38
  }
82
39
  function registerAgentsRoutes(authenticated, deps) {
83
40
  const { service, strictRateLimitMiddleware } = deps;
@@ -115,10 +72,7 @@ function registerAgentsRoutes(authenticated, deps) {
115
72
  ok: false,
116
73
  error: { message: save.error ?? "save failed" }
117
74
  }, 500);
118
- const finalized = await finalizeCreateAgentDirs(service.currentConfig, agentId, {
119
- ...parsed.profileFiles !== void 0 ? { profileFiles: parsed.profileFiles } : {},
120
- ...parsed.cloneFrom ? { cloneFrom: parsed.cloneFrom } : {}
121
- });
75
+ const finalized = await finalizeCreateAgentDirs(service.currentConfig, agentId);
122
76
  if (finalized.ok === false) return c.json({
123
77
  ok: false,
124
78
  error: { message: finalized.error }
@@ -133,9 +87,9 @@ function registerAgentsRoutes(authenticated, deps) {
133
87
  }
134
88
  });
135
89
  });
136
- authenticated.get("/api/agents/:id/effective-manifest", async (c) => {
90
+ authenticated.get("/api/agents/:id/effective-config", async (c) => {
137
91
  const id = normalizeAgentId(c.req.param("id") ?? "");
138
- const res = getGatewayAgentEffectiveManifest(service.currentConfig, id);
92
+ const res = getGatewayAgentEffectiveConfig(service.currentConfig, id);
139
93
  if (res.ok === false) return c.json({
140
94
  ok: false,
141
95
  error: { message: res.error }
@@ -156,40 +110,30 @@ function registerAgentsRoutes(authenticated, deps) {
156
110
  error: { message: "Invalid JSON" }
157
111
  }, 400);
158
112
  }
159
- if (Object.hasOwn(body, "model")) return c.json({
160
- ok: false,
161
- error: { message: "model is not supported; use models.defaultRole and models.roles" }
162
- }, 400);
163
- if (Object.hasOwn(body, "typedModels")) return c.json({
164
- ok: false,
165
- error: { message: "typedModels is not supported; use models.roles" }
166
- }, 400);
167
- if (Object.hasOwn(body, "toolsDisable")) return c.json({
168
- ok: false,
169
- error: { message: "toolsDisable was removed; use tools.builtin policies" }
170
- }, 400);
171
- if (Object.hasOwn(body, "agentDir")) return c.json({
113
+ const allowedPatchKeys = new Set([
114
+ "workspace",
115
+ "profile",
116
+ "models",
117
+ "skills",
118
+ "tools",
119
+ "workflows",
120
+ "runtime",
121
+ "setDefault"
122
+ ]);
123
+ const unknownPatchKey = Object.keys(body).find((key) => !allowedPatchKeys.has(key));
124
+ if (unknownPatchKey) return c.json({
172
125
  ok: false,
173
- error: { message: "agentDir was removed from agent manifests" }
126
+ error: { message: `unknown agent field "${unknownPatchKey}"` }
174
127
  }, 400);
175
- if (Object.hasOwn(body, "name")) return c.json({
128
+ const skillsPatch = body.skills === null ? null : Object.hasOwn(body, "skills") ? SkillOverrideSchema.safeParse(body.skills) : void 0;
129
+ if (skillsPatch && skillsPatch !== null && !skillsPatch.success) return c.json({
176
130
  ok: false,
177
- error: { message: "name is not supported; edit IDENTITY.md" }
178
- }, 400);
179
- if (Object.hasOwn(body, "description")) return c.json({
180
- ok: false,
181
- error: { message: "description is not supported; edit IDENTITY.md" }
182
- }, 400);
183
- const skillsPatch = body.skills === null ? null : Array.isArray(body.skills) ? body.skills.map((x) => String(x).trim()).filter(Boolean) : void 0;
184
- const extendsPatch = Object.hasOwn(body, "extends") ? Array.isArray(body.extends) ? body.extends.map((x) => String(x).trim()).filter(Boolean) : void 0 : void 0;
185
- if (Object.hasOwn(body, "extends") && extendsPatch === void 0) return c.json({
186
- ok: false,
187
- error: { message: "extends must be an array" }
131
+ error: { message: `skills ${skillsPatch.error.issues[0]?.message ?? "is invalid"}` }
188
132
  }, 400);
189
133
  let toolsPatch;
190
134
  if (Object.hasOwn(body, "tools")) if (body.tools === null) toolsPatch = null;
191
135
  else if (typeof body.tools === "object" && !Array.isArray(body.tools)) {
192
- const parsedTools = ToolPolicySetSchema.safeParse(body.tools);
136
+ const parsedTools = ToolPoliciesSchema.safeParse(body.tools);
193
137
  if (!parsedTools.success) return c.json({
194
138
  ok: false,
195
139
  error: { message: `tools ${parsedTools.error.issues[0]?.message ?? "is invalid"}` }
@@ -204,17 +148,37 @@ function registerAgentsRoutes(authenticated, deps) {
204
148
  ok: false,
205
149
  error: { message: modelsPatch.error }
206
150
  }, 400);
207
- if (Object.hasOwn(body, "memory")) return c.json({
151
+ const profilePatch = body.profile === null ? null : Object.hasOwn(body, "profile") ? AgentProfileSchema.safeParse(body.profile) : void 0;
152
+ if (profilePatch && profilePatch !== null && !profilePatch.success) return c.json({
153
+ ok: false,
154
+ error: { message: `profile ${profilePatch.error.issues[0]?.message ?? "is invalid"}` }
155
+ }, 400);
156
+ const workflowsPatch = body.workflows === null ? null : Object.hasOwn(body, "workflows") ? WorkflowPolicySchema.safeParse(body.workflows) : void 0;
157
+ if (workflowsPatch && workflowsPatch !== null && !workflowsPatch.success) return c.json({
158
+ ok: false,
159
+ error: { message: `workflows ${workflowsPatch.error.issues[0]?.message ?? "is invalid"}` }
160
+ }, 400);
161
+ const runtimePatch = body.runtime === null ? null : Object.hasOwn(body, "runtime") ? RuntimePolicySchema.safeParse(body.runtime) : void 0;
162
+ if (runtimePatch && runtimePatch !== null && !runtimePatch.success) return c.json({
163
+ ok: false,
164
+ error: { message: `runtime ${runtimePatch.error.issues[0]?.message ?? "is invalid"}` }
165
+ }, 400);
166
+ let workspacePatch;
167
+ if (Object.hasOwn(body, "workspace")) if (body.workspace === null) workspacePatch = null;
168
+ else if (typeof body.workspace === "string") workspacePatch = body.workspace;
169
+ else return c.json({
208
170
  ok: false,
209
- error: { message: "Agent memory configuration is not supported; use userContext" }
171
+ error: { message: "workspace must be a string or null" }
210
172
  }, 400);
211
173
  const prep = prepareUpdateAgent(service.currentConfig, id, {
212
- workspace: typeof body.workspace === "string" ? body.workspace : void 0,
213
- ...extendsPatch !== void 0 ? { extends: extendsPatch } : {},
174
+ ...workspacePatch !== void 0 ? { workspace: workspacePatch } : {},
175
+ ...profilePatch !== void 0 ? { profile: profilePatch === null ? null : profilePatch.data } : {},
214
176
  ...modelsPatch !== void 0 ? { models: modelsPatch } : {},
215
177
  setDefault: body.setDefault === true,
216
- ...skillsPatch !== void 0 ? { skills: skillsPatch } : {},
217
- ...toolsPatch !== void 0 ? { tools: toolsPatch } : {}
178
+ ...skillsPatch !== void 0 ? { skills: skillsPatch === null ? null : skillsPatch.data } : {},
179
+ ...toolsPatch !== void 0 ? { tools: toolsPatch } : {},
180
+ ...workflowsPatch !== void 0 ? { workflows: workflowsPatch === null ? null : workflowsPatch.data } : {},
181
+ ...runtimePatch !== void 0 ? { runtime: runtimePatch === null ? null : runtimePatch.data } : {}
218
182
  });
219
183
  if (prep.ok === false) return c.json({
220
184
  ok: false,
@@ -514,7 +514,7 @@ function registerConnectorRoutes(authenticated, deps) {
514
514
  const policy = getComposioInstallationPolicy(config, c.req.param("toolkit"));
515
515
  const agents = config.agents.list.filter((agent) => agent.enabled).map((agent) => ({
516
516
  id: agent.id,
517
- name: agent.identity?.name ?? agent.id
517
+ name: agent.id
518
518
  }));
519
519
  return c.json({
520
520
  ok: true,
@@ -0,0 +1,2 @@
1
+ import type { Hono } from 'hono';
2
+ export declare function registerDevicePushRoutes(authenticated: Hono): void;
@@ -1,5 +1,6 @@
1
1
  import { registerNotificationDevice, removeNotificationDevice, updateNotificationDevicePreferences } from "../../../notifications/device-store.js";
2
- //#region src/gateway/hono/routes/mobile.ts
2
+ import { getGatewayPrincipal } from "../../security/gateway-principal.js";
3
+ //#region src/gateway/hono/routes/device-push.ts
3
4
  function stringField(value, maxLength) {
4
5
  return typeof value === "string" && value.trim().length > 0 && value.trim().length <= maxLength ? value.trim() : null;
5
6
  }
@@ -34,22 +35,34 @@ function parsePermission(value) {
34
35
  function parseLocale(value) {
35
36
  return value === "en" || value === "zh" ? value : null;
36
37
  }
37
- function registerMobileRoutes(authenticated, _deps) {
38
- authenticated.post("/api/mobile/devices/register", async (c) => {
38
+ function currentDeviceId(c) {
39
+ const principal = getGatewayPrincipal(c);
40
+ return principal.kind === "device" && principal.deviceId ? principal.deviceId : null;
41
+ }
42
+ function registerDevicePushRoutes(authenticated) {
43
+ authenticated.put("/api/devices/me/push", async (c) => {
44
+ const deviceId = currentDeviceId(c);
45
+ if (!deviceId) return c.json({
46
+ ok: false,
47
+ error: "Device access required"
48
+ }, 403);
39
49
  const body = await c.req.json().catch(() => null);
40
- const id = stringField(body?.id, 160);
50
+ if (body && ("id" in body || "deviceId" in body)) return c.json({
51
+ ok: false,
52
+ error: "Device identity must come from authentication"
53
+ }, 400);
41
54
  const pushToken = stringField(body?.pushToken, 1024);
42
55
  const platform = parsePlatform(body?.platform);
43
56
  const permissions = parsePermission(body?.permissions);
44
57
  const preferences = parsePreferences(body?.preferences);
45
58
  const locale = parseLocale(body?.locale);
46
59
  const appVersion = body?.appVersion === void 0 ? void 0 : stringField(body.appVersion, 128);
47
- if (!id || !pushToken || !platform || !permissions || !locale || preferences === null || appVersion === null) return c.json({
60
+ if (!pushToken || !platform || !permissions || !locale || preferences === null || appVersion === null) return c.json({
48
61
  ok: false,
49
- error: "Invalid mobile device registration"
62
+ error: "Invalid push registration"
50
63
  }, 400);
51
64
  const device = registerNotificationDevice({
52
- id,
65
+ deviceId,
53
66
  pushToken,
54
67
  platform,
55
68
  permissions,
@@ -62,28 +75,37 @@ function registerMobileRoutes(authenticated, _deps) {
62
75
  device
63
76
  }, 201);
64
77
  });
65
- authenticated.patch("/api/mobile/devices/:id/preferences", async (c) => {
78
+ authenticated.patch("/api/devices/me/push/preferences", async (c) => {
79
+ const deviceId = currentDeviceId(c);
80
+ if (!deviceId) return c.json({
81
+ ok: false,
82
+ error: "Device access required"
83
+ }, 403);
66
84
  const preferences = parsePreferences(await c.req.json().catch(() => null));
67
85
  if (preferences === null || preferences === void 0) return c.json({
68
86
  ok: false,
69
87
  error: "Invalid notification preferences"
70
88
  }, 400);
71
- const device = updateNotificationDevicePreferences(c.req.param("id"), preferences);
72
- if (!device) return c.json({
73
- ok: false,
74
- error: "Mobile device not found"
75
- }, 404);
76
- return c.json({
89
+ const device = updateNotificationDevicePreferences(deviceId, preferences);
90
+ return device ? c.json({
77
91
  ok: true,
78
92
  device
79
- });
93
+ }) : c.json({
94
+ ok: false,
95
+ error: "Push registration not found"
96
+ }, 404);
80
97
  });
81
- authenticated.delete("/api/mobile/devices/:id", (c) => {
98
+ authenticated.delete("/api/devices/me/push", (c) => {
99
+ const deviceId = currentDeviceId(c);
100
+ if (!deviceId) return c.json({
101
+ ok: false,
102
+ error: "Device access required"
103
+ }, 403);
82
104
  return c.json({
83
105
  ok: true,
84
- removed: removeNotificationDevice(c.req.param("id"))
106
+ removed: removeNotificationDevice(deviceId)
85
107
  });
86
108
  });
87
109
  }
88
110
  //#endregion
89
- export { registerMobileRoutes };
111
+ export { registerDevicePushRoutes };
@@ -0,0 +1,4 @@
1
+ import type { Hono } from 'hono';
2
+ import type { AuthenticatedRouteDeps } from './deps.js';
3
+ export declare function registerDeviceAuthPublicRoutes(app: Hono): void;
4
+ export declare function registerDeviceRoutes(authenticated: Hono, deps: AuthenticatedRouteDeps): void;
@@ -0,0 +1,214 @@
1
+ import { runSqliteWriteTransaction } from "../../../storage/sqlite/transaction.js";
2
+ import { DEFAULT_MOBILE_SCOPES } from "../../security/gateway-scopes.js";
3
+ import { createDevice, issueDeviceTokenPair, listDevices, revokeDevice, rotateDeviceRefreshToken } from "../../../storage/sqlite/device-access-repository.js";
4
+ import { getGatewayIdentityPublicKeyRaw, getOrCreateGatewayIdentity, signGatewayPayload } from "../../../storage/sqlite/gateway-identity-repository.js";
5
+ import { consumeDevicePairingToken, createDevicePairingSetup, isDevicePairingSetupActive } from "../../../storage/sqlite/device-pairing-repository.js";
6
+ import { resolveSecureDeviceRoutes } from "../../device-routes.js";
7
+ import { getGatewayPrincipal } from "../../security/gateway-principal.js";
8
+ import os from "node:os";
9
+ import { z } from "zod";
10
+ //#region src/gateway/hono/routes/devices.ts
11
+ const refreshRequestSchema = z.strictObject({
12
+ refreshToken: z.string().min(1).max(256),
13
+ timestamp: z.number().int().positive(),
14
+ nonce: z.string().min(16).max(128),
15
+ requestId: z.string().uuid(),
16
+ nextRefreshToken: z.string().min(80).max(256),
17
+ signature: z.string().min(1).max(256)
18
+ });
19
+ const pairingExchangeSchema = z.strictObject({
20
+ pairingToken: z.string().min(1).max(256),
21
+ device: z.strictObject({
22
+ displayName: z.string().trim().min(1).max(80),
23
+ platform: z.enum(["ios", "android"]),
24
+ publicKeyJwk: z.strictObject({
25
+ kty: z.literal("EC"),
26
+ crv: z.literal("P-256"),
27
+ x: z.string().min(40).max(64),
28
+ y: z.string().min(40).max(64)
29
+ })
30
+ })
31
+ });
32
+ const pairingProbeSchema = z.strictObject({ pairingId: z.string().uuid() });
33
+ function pairingLinkPayload(input) {
34
+ return Buffer.from(JSON.stringify({
35
+ version: 2,
36
+ ...input
37
+ })).toString("base64url");
38
+ }
39
+ function registerDeviceAuthPublicRoutes(app) {
40
+ app.post("/api/device-auth/refresh", async (c) => {
41
+ const parsed = refreshRequestSchema.safeParse(await c.req.json().catch(() => null));
42
+ if (!parsed.success) return c.json({
43
+ ok: false,
44
+ error: {
45
+ code: "BAD_REQUEST",
46
+ message: "Invalid refresh request"
47
+ }
48
+ }, 400);
49
+ try {
50
+ return c.json({
51
+ ok: true,
52
+ payload: rotateDeviceRefreshToken(parsed.data)
53
+ });
54
+ } catch (error) {
55
+ return c.json({
56
+ ok: false,
57
+ error: {
58
+ code: "REFRESH_DENIED",
59
+ message: error instanceof Error ? error.message : "Refresh denied"
60
+ }
61
+ }, 401);
62
+ }
63
+ });
64
+ app.post("/api/device-pairing/probe", async (c) => {
65
+ const parsed = pairingProbeSchema.safeParse(await c.req.json().catch(() => null));
66
+ if (!parsed.success || !isDevicePairingSetupActive(parsed.data.pairingId)) return c.json({
67
+ ok: false,
68
+ error: {
69
+ code: "PAIRING_NOT_FOUND",
70
+ message: "Pairing setup not found"
71
+ }
72
+ }, 404);
73
+ const identity = getOrCreateGatewayIdentity();
74
+ const payload = Buffer.from(JSON.stringify({
75
+ gatewayId: identity.id,
76
+ pairingId: parsed.data.pairingId,
77
+ issuedAt: Date.now()
78
+ })).toString("base64url");
79
+ return c.json({
80
+ ok: true,
81
+ signedPayload: payload,
82
+ signature: signGatewayPayload(payload)
83
+ });
84
+ });
85
+ app.post("/api/device-pairing/exchange", async (c) => {
86
+ const parsed = pairingExchangeSchema.safeParse(await c.req.json().catch(() => null));
87
+ if (!parsed.success) return c.json({
88
+ ok: false,
89
+ error: {
90
+ code: "BAD_REQUEST",
91
+ message: "Invalid pairing request"
92
+ }
93
+ }, 400);
94
+ const completed = runSqliteWriteTransaction(() => {
95
+ const pairing = consumeDevicePairingToken(parsed.data.pairingToken);
96
+ if (!pairing.ok && "reason" in pairing) return {
97
+ success: false,
98
+ reason: pairing.reason
99
+ };
100
+ const device = createDevice({
101
+ displayName: parsed.data.device.displayName,
102
+ platform: parsed.data.device.platform,
103
+ publicKeyJwk: parsed.data.device.publicKeyJwk,
104
+ scopes: DEFAULT_MOBILE_SCOPES
105
+ });
106
+ return {
107
+ success: true,
108
+ device,
109
+ routes: pairing.routes,
110
+ tokens: issueDeviceTokenPair(device.id)
111
+ };
112
+ });
113
+ if ("reason" in completed) return c.json({
114
+ ok: false,
115
+ error: {
116
+ code: "PAIRING_DENIED",
117
+ message: `Pairing ${completed.reason}`
118
+ }
119
+ }, 401);
120
+ const identity = getOrCreateGatewayIdentity();
121
+ const payload = Buffer.from(JSON.stringify({
122
+ gateway: {
123
+ id: identity.id,
124
+ name: os.hostname()
125
+ },
126
+ device: {
127
+ id: completed.device.id,
128
+ scopes: completed.device.scopes
129
+ },
130
+ routes: completed.routes,
131
+ tokens: completed.tokens
132
+ })).toString("base64url");
133
+ return c.json({
134
+ ok: true,
135
+ signedPayload: payload,
136
+ signature: signGatewayPayload(payload)
137
+ }, 201);
138
+ });
139
+ }
140
+ function registerDeviceRoutes(authenticated, deps) {
141
+ authenticated.get("/api/device-pairing/readiness", (c) => {
142
+ const routes = resolveSecureDeviceRoutes(deps.service.currentConfig);
143
+ return c.json({
144
+ ok: true,
145
+ ready: routes.length > 0,
146
+ routes
147
+ });
148
+ });
149
+ authenticated.post("/api/device-pairing/setups", (c) => {
150
+ const routes = resolveSecureDeviceRoutes(deps.service.currentConfig);
151
+ if (routes.length === 0) return c.json({
152
+ ok: false,
153
+ error: {
154
+ code: "NO_SECURE_ROUTE",
155
+ message: "Configure XOPC Secure Link, Tailscale Serve, or an HTTPS public URL first"
156
+ }
157
+ }, 409);
158
+ const setup = createDevicePairingSetup(routes);
159
+ const identity = getOrCreateGatewayIdentity();
160
+ const encoded = pairingLinkPayload({
161
+ pairingToken: setup.token,
162
+ gatewayId: identity.id,
163
+ gatewayName: os.hostname(),
164
+ gatewayPublicKey: getGatewayIdentityPublicKeyRaw(identity),
165
+ routes,
166
+ expiresAt: setup.expiresAt
167
+ });
168
+ return c.json({
169
+ ok: true,
170
+ setup: {
171
+ id: setup.id,
172
+ universalLink: `https://link.xopc.ai/connect#p=${encoded}`,
173
+ expiresAt: setup.expiresAt,
174
+ routes
175
+ }
176
+ }, 201);
177
+ });
178
+ authenticated.get("/api/devices", (c) => c.json({
179
+ ok: true,
180
+ devices: listDevices()
181
+ }));
182
+ authenticated.get("/api/devices/me", (c) => {
183
+ const principal = getGatewayPrincipal(c);
184
+ if (principal.kind !== "device" || !principal.deviceId) return c.json({
185
+ ok: false,
186
+ error: {
187
+ code: "DEVICE_REQUIRED",
188
+ message: "Device access required"
189
+ }
190
+ }, 403);
191
+ const device = listDevices().find((candidate) => candidate.id === principal.deviceId);
192
+ return device ? c.json({
193
+ ok: true,
194
+ device
195
+ }) : c.json({
196
+ ok: false,
197
+ error: {
198
+ code: "NOT_FOUND",
199
+ message: "Device not found"
200
+ }
201
+ }, 404);
202
+ });
203
+ authenticated.delete("/api/devices/:deviceId", (c) => {
204
+ const deviceId = c.req.param("deviceId");
205
+ const revoked = revokeDevice(deviceId);
206
+ if (revoked) deps.service.realtime.disconnectPrincipal(deviceId);
207
+ return c.json({
208
+ ok: true,
209
+ revoked
210
+ });
211
+ });
212
+ }
213
+ //#endregion
214
+ export { registerDeviceAuthPublicRoutes, registerDeviceRoutes };
@@ -0,0 +1,3 @@
1
+ import type { Hono } from 'hono';
2
+ import type { AuthenticatedRouteDeps } from './deps.js';
3
+ export declare function registerFilesRoutes(authenticated: Hono, deps: AuthenticatedRouteDeps): void;