@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,133 +0,0 @@
1
- import { CapabilityPresetSchema, DEFAULT_CAPABILITY_PRESET_ID, init_schema } from "../../agent-manifest/schema.js";
2
- import { ConfigSchema, init_schema as init_schema$1 } from "../../config/schema.js";
3
- import { existsSync, readFileSync } from "node:fs";
4
- //#region src/migrations/config/default-capability-preset.ts
5
- init_schema();
6
- init_schema$1();
7
- const DEFAULT_CAPABILITY_PRESET_MIGRATION_ID = "2026-07-ensure-default-capability-preset";
8
- function createDefaultCapabilityPreset() {
9
- return {
10
- id: DEFAULT_CAPABILITY_PRESET_ID,
11
- name: "Global defaults",
12
- description: "Default capabilities inherited by every agent.",
13
- version: 1,
14
- models: {
15
- defaultRole: "deep",
16
- roles: {}
17
- }
18
- };
19
- }
20
- function ensureDefaultCapabilityPresetInitialized(config) {
21
- const agents = config.agents;
22
- const capabilityPresets = { ...agents.capabilityPresets ?? {} };
23
- let changed = false;
24
- if (!capabilityPresets["default"]) {
25
- capabilityPresets[DEFAULT_CAPABILITY_PRESET_ID] = createDefaultCapabilityPreset();
26
- changed = true;
27
- }
28
- const defaultPreset = agents.defaultPreset?.trim() || "default";
29
- if (defaultPreset !== agents.defaultPreset) changed = true;
30
- if (!changed) return {
31
- config,
32
- changed: false
33
- };
34
- return {
35
- config: ConfigSchema.parse({
36
- ...config,
37
- agents: {
38
- ...agents,
39
- defaultPreset,
40
- capabilityPresets
41
- }
42
- }),
43
- changed: true
44
- };
45
- }
46
- function planned(message, details) {
47
- return {
48
- id: DEFAULT_CAPABILITY_PRESET_MIGRATION_ID,
49
- title: "Initialize global default capability preset",
50
- kind: "config",
51
- safety: "auto",
52
- status: "planned",
53
- message,
54
- details
55
- };
56
- }
57
- function conflict(message, details) {
58
- return {
59
- id: DEFAULT_CAPABILITY_PRESET_MIGRATION_ID,
60
- title: "Initialize global default capability preset",
61
- kind: "config",
62
- safety: "manual",
63
- status: "conflict",
64
- message,
65
- details
66
- };
67
- }
68
- function readRawConfigObject(configPath) {
69
- if (!existsSync(configPath)) return null;
70
- const raw = readFileSync(configPath, "utf8");
71
- const parsed = JSON.parse(raw);
72
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Config root must be an object");
73
- return parsed;
74
- }
75
- const defaultCapabilityPresetMigration = {
76
- id: DEFAULT_CAPABILITY_PRESET_MIGRATION_ID,
77
- kind: "config",
78
- safety: "auto",
79
- detect(ctx) {
80
- const raw = readRawConfigObject(ctx.configPath);
81
- if (!raw) return null;
82
- const rawAgents = raw.agents;
83
- if (rawAgents !== void 0 && (rawAgents === null || typeof rawAgents !== "object" || Array.isArray(rawAgents))) return conflict("agents config is not an object; cannot initialize global defaults automatically.");
84
- const agents = rawAgents ?? {};
85
- const rawPresets = agents.capabilityPresets;
86
- if (rawPresets !== void 0 && (rawPresets === null || typeof rawPresets !== "object" || Array.isArray(rawPresets))) return conflict("agents.capabilityPresets is not an object; cannot initialize global defaults automatically.");
87
- const existingDefault = (rawPresets ?? {})[DEFAULT_CAPABILITY_PRESET_ID];
88
- if (existingDefault !== void 0) {
89
- const parsedPreset = CapabilityPresetSchema.safeParse(existingDefault);
90
- if (!parsedPreset.success) return conflict("Existing default capability preset is invalid; please repair it manually.", { issues: parsedPreset.error.issues.slice(0, 5).map((issue) => ({
91
- path: issue.path.join("."),
92
- message: issue.message
93
- })) });
94
- }
95
- const needsDefaultPresetPointer = typeof agents.defaultPreset !== "string" || agents.defaultPreset.trim().length === 0;
96
- const needsDefaultPresetObject = existingDefault === void 0;
97
- if (!needsDefaultPresetPointer && !needsDefaultPresetObject) return null;
98
- return planned("Global default capability preset is missing and will be initialized.", {
99
- addDefaultPresetPointer: needsDefaultPresetPointer,
100
- addDefaultPresetObject: needsDefaultPresetObject
101
- });
102
- },
103
- apply(ctx) {
104
- const detected = this.detect(ctx);
105
- if (!detected) return {
106
- id: this.id,
107
- title: "Initialize global default capability preset",
108
- kind: "config",
109
- safety: "auto",
110
- status: "not_needed",
111
- message: "Global default capability preset is already initialized."
112
- };
113
- if (detected.status === "conflict") return detected;
114
- const raw = readRawConfigObject(ctx.configPath);
115
- const ensured = ensureDefaultCapabilityPresetInitialized(ConfigSchema.parse(raw ?? void 0));
116
- if (!ensured.changed) return {
117
- ...detected,
118
- status: "not_needed",
119
- message: "Global default capability preset is already initialized."
120
- };
121
- return {
122
- ...detected,
123
- status: "applied",
124
- message: "Initialized global default capability preset.",
125
- details: {
126
- ...detected.details,
127
- config: ensured.config
128
- }
129
- };
130
- }
131
- };
132
- //#endregion
133
- export { DEFAULT_CAPABILITY_PRESET_MIGRATION_ID, createDefaultCapabilityPreset, defaultCapabilityPresetMigration, ensureDefaultCapabilityPresetInitialized };
@@ -1,8 +0,0 @@
1
- import type { Config } from '../config/schema.js';
2
- export declare function applyLanPairingGatewayPatch(config: Config): {
3
- ok: true;
4
- changed: boolean;
5
- } | {
6
- ok: false;
7
- message: string;
8
- };
@@ -1,41 +0,0 @@
1
- import { assertGatewayAuthConfigured, resolveGatewayAuth } from "../gateway/auth.js";
2
- import { assertGatewayRuntimeConfig } from "../gateway/runtime-config.js";
3
- //#region src/tunnel/enable-lan-pairing.ts
4
- function applyLanPairingGatewayPatch(config) {
5
- if (!config.gateway) return {
6
- ok: false,
7
- message: "Gateway section missing from config"
8
- };
9
- const previousGateway = JSON.stringify(config.gateway);
10
- const nextGateway = {
11
- ...config.gateway,
12
- bind: "lan"
13
- };
14
- delete nextGateway.customBindHost;
15
- const candidate = {
16
- ...config,
17
- gateway: nextGateway
18
- };
19
- const port = nextGateway.port ?? 18790;
20
- try {
21
- const auth = resolveGatewayAuth({ authConfig: candidate.gateway.auth });
22
- assertGatewayAuthConfigured(auth);
23
- assertGatewayRuntimeConfig({
24
- cfg: candidate,
25
- auth,
26
- port
27
- });
28
- } catch (err) {
29
- return {
30
- ok: false,
31
- message: err instanceof Error ? err.message : String(err)
32
- };
33
- }
34
- config.gateway = candidate.gateway;
35
- return {
36
- ok: true,
37
- changed: previousGateway !== JSON.stringify(config.gateway)
38
- };
39
- }
40
- //#endregion
41
- export { applyLanPairingGatewayPatch };
@@ -1,36 +0,0 @@
1
- import type { Config } from '../config/schema.js';
2
- import type { GatewayBindMode } from '../config/schema.js';
3
- export type MobilePairCandidateKind = 'lan' | 'tunnel' | 'reverse-proxy';
4
- export type MobilePairBlockReason = 'GATEWAY_LOOPBACK_ONLY' | 'NO_REACHABLE_URL';
5
- export type MobilePairCandidate = {
6
- kind: MobilePairCandidateKind;
7
- url: string;
8
- label?: string;
9
- reachable: boolean;
10
- note?: string;
11
- };
12
- export type MobilePairContext = {
13
- port: number;
14
- bindMode: GatewayBindMode;
15
- listenHost: string;
16
- pairingReady: boolean;
17
- blockReason?: MobilePairBlockReason;
18
- candidates: MobilePairCandidate[];
19
- recommended: {
20
- mode: MobilePairCandidateKind | null;
21
- url: string | null;
22
- };
23
- /** Ordered URLs for mobile clients (LAN first when available, then tunnel). */
24
- connectUrls: string[];
25
- };
26
- export declare function buildMobilePairContext(params: {
27
- config: Config;
28
- tunnelPublicUrl?: string | null;
29
- tunnelConnected?: boolean;
30
- /**
31
- * Optional override for `gateway.publicUrl`. Falls back to the configured
32
- * value when omitted; useful for transient candidates (e.g. UI auto-detect
33
- * from `window.location.origin` before the user persists the value).
34
- */
35
- reverseProxyPublicUrl?: string | null;
36
- }): MobilePairContext;
@@ -1,77 +0,0 @@
1
- import { init_public_url, normalizePublicUrlOrNull } from "../config/public-url.js";
2
- import { enumerateLanGatewayCandidates } from "../gateway/host.js";
3
- import { isNetworkAccessibleBindHost, resolveGatewayBindMode, resolveGatewayEffectiveHost } from "../config/gateway-bind.js";
4
- import { buildMobileConnectUrlOrder } from "./pair-url.js";
5
- //#region src/tunnel/pair-context.ts
6
- init_public_url();
7
- function buildMobilePairContext(params) {
8
- const port = params.config.gateway?.port ?? 18790;
9
- const bindMode = resolveGatewayBindMode(params.config);
10
- const listenHost = resolveGatewayEffectiveHost(params.config);
11
- const lanListenReady = isNetworkAccessibleBindHost(listenHost);
12
- const lanEnumerated = enumerateLanGatewayCandidates(port);
13
- const candidates = lanEnumerated.map((entry) => ({
14
- kind: "lan",
15
- url: entry.url,
16
- label: entry.interfaceName,
17
- reachable: lanListenReady,
18
- ...lanListenReady ? {} : { note: "requires_lan_bind" }
19
- }));
20
- const tunnelUrl = params.tunnelPublicUrl?.trim() || null;
21
- const tunnelConnected = params.tunnelConnected === true && Boolean(tunnelUrl);
22
- if (tunnelConnected && tunnelUrl) candidates.unshift({
23
- kind: "tunnel",
24
- url: tunnelUrl,
25
- reachable: true
26
- });
27
- const configuredReverseProxy = normalizePublicUrlOrNull(params.config.gateway?.publicUrl);
28
- const reverseProxyUrl = params.reverseProxyPublicUrl !== void 0 ? normalizePublicUrlOrNull(params.reverseProxyPublicUrl) : configuredReverseProxy;
29
- if (reverseProxyUrl) candidates.unshift({
30
- kind: "reverse-proxy",
31
- url: reverseProxyUrl,
32
- reachable: true
33
- });
34
- let recommended = {
35
- mode: null,
36
- url: null
37
- };
38
- if (reverseProxyUrl) recommended = {
39
- mode: "reverse-proxy",
40
- url: reverseProxyUrl
41
- };
42
- else if (tunnelConnected && tunnelUrl) recommended = {
43
- mode: "tunnel",
44
- url: tunnelUrl
45
- };
46
- else if (lanListenReady && lanEnumerated[0]) recommended = {
47
- mode: "lan",
48
- url: lanEnumerated[0].url
49
- };
50
- else if (lanEnumerated[0]) recommended = {
51
- mode: "lan",
52
- url: lanEnumerated[0].url
53
- };
54
- const pairingReady = Boolean(reverseProxyUrl || tunnelConnected || lanListenReady && lanEnumerated.length > 0);
55
- let blockReason;
56
- if (!pairingReady) blockReason = !lanListenReady && !tunnelConnected ? "GATEWAY_LOOPBACK_ONLY" : "NO_REACHABLE_URL";
57
- const lanUrlForConnect = lanListenReady && lanEnumerated[0] ? lanEnumerated[0].url : null;
58
- const hasUpstream = Boolean(reverseProxyUrl) || tunnelConnected;
59
- const connectUrls = buildMobileConnectUrlOrder({
60
- reverseProxyUrl,
61
- baseUrl: reverseProxyUrl ? reverseProxyUrl : tunnelConnected && tunnelUrl ? tunnelUrl : lanListenReady && recommended.url ? recommended.url : null,
62
- lanUrl: hasUpstream ? lanUrlForConnect : null,
63
- tunnelUrl: tunnelConnected ? tunnelUrl : null
64
- });
65
- return {
66
- port,
67
- bindMode,
68
- listenHost,
69
- pairingReady,
70
- ...blockReason ? { blockReason } : {},
71
- candidates,
72
- recommended,
73
- connectUrls
74
- };
75
- }
76
- //#endregion
77
- export { buildMobilePairContext };
@@ -1,43 +0,0 @@
1
- import type { Config } from '../config/schema.js';
2
- export type MobilePairUrlValidationCode = 'INVALID_URL' | 'LOOPBACK_NOT_REACHABLE';
3
- export type MobilePairUrlValidationResult = {
4
- ok: true;
5
- url: string;
6
- loopback: false;
7
- } | {
8
- ok: false;
9
- code: MobilePairUrlValidationCode;
10
- message: string;
11
- };
12
- /** Normalize a gateway root URL (no trailing slash, no path). */
13
- export declare function normalizeGatewayBaseUrl(raw: string): string | null;
14
- /** True when a phone on the network cannot reach this gateway root URL. */
15
- export declare function isLoopbackGatewayBaseUrl(raw: string): boolean;
16
- export declare function validateMobilePairBaseUrl(raw: string): MobilePairUrlValidationResult;
17
- export type ParsedMobileConnectDeepLink = {
18
- baseUrl: string;
19
- lanUrl: string | null;
20
- pairingSecret: string;
21
- };
22
- /** Parse `xopc://gateway/mobile-connect?...` payloads from QR codes. */
23
- export declare function parseMobileConnectDeepLink(raw: string): ParsedMobileConnectDeepLink | null;
24
- /**
25
- * Ordered URLs for mobile clients. Priority:
26
- * 1. reverse-proxy public URL (user-deployed HTTPS, typically fastest + works on cellular)
27
- * 2. LAN URL (zero-RTT on same network)
28
- * 3. baseUrl (legacy: usually the FRP tunnel public URL, kept for callers that
29
- * do not yet split reverseProxyUrl from tunnelUrl)
30
- * 4. tunnelUrl (explicit FRP tunnel URL, kept as a fallback even when a
31
- * reverse-proxy URL is also configured)
32
- *
33
- * Loopback URLs are dropped (they only work on the gateway host) and
34
- * duplicates are de-duped while preserving first occurrence order.
35
- */
36
- export declare function buildMobileConnectUrlOrder(params: {
37
- baseUrl: string | null | undefined;
38
- lanUrl: string | null | undefined;
39
- reverseProxyUrl?: string | null | undefined;
40
- tunnelUrl?: string | null | undefined;
41
- }): string[];
42
- /** First LAN URL when the gateway listens on a network-accessible bind host. */
43
- export declare function resolveMobilePairLanUrl(config: Config): string | null;
@@ -1,117 +0,0 @@
1
- import { enumerateLanGatewayCandidates } from "../gateway/host.js";
2
- import { isNetworkAccessibleBindHost, resolveGatewayEffectiveHost } from "../config/gateway-bind.js";
3
- import net from "node:net";
4
- //#region src/tunnel/pair-url.ts
5
- /** Normalize a gateway root URL (no trailing slash, no path). */
6
- function normalizeGatewayBaseUrl(raw) {
7
- const trimmed = raw.trim();
8
- if (!trimmed) return null;
9
- try {
10
- const u = new URL(trimmed);
11
- if (u.protocol !== "http:" && u.protocol !== "https:") return null;
12
- if (u.username || u.password) return null;
13
- if (u.pathname && u.pathname !== "/") return null;
14
- if (u.search || u.hash) return null;
15
- const portSuffix = u.port ? `:${u.port}` : "";
16
- return `${u.protocol}//${u.hostname}${portSuffix}`;
17
- } catch {
18
- return null;
19
- }
20
- }
21
- /** True when a phone on the network cannot reach this gateway root URL. */
22
- function isLoopbackGatewayBaseUrl(raw) {
23
- const normalized = normalizeGatewayBaseUrl(raw);
24
- if (!normalized) return false;
25
- try {
26
- const host = new URL(normalized).hostname.trim().toLowerCase();
27
- if (host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]") return true;
28
- if (net.isIP(host) === 4) {
29
- const parts = host.split(".").map((p) => Number(p));
30
- if (parts.length === 4 && parts.every((n) => Number.isInteger(n)) && parts[0] === 127) return true;
31
- }
32
- return false;
33
- } catch {
34
- return false;
35
- }
36
- }
37
- function validateMobilePairBaseUrl(raw) {
38
- const url = normalizeGatewayBaseUrl(raw);
39
- if (!url) return {
40
- ok: false,
41
- code: "INVALID_URL",
42
- message: "Enter an absolute gateway URL starting with http:// or https:// (no path)."
43
- };
44
- if (isLoopbackGatewayBaseUrl(url)) return {
45
- ok: false,
46
- code: "LOOPBACK_NOT_REACHABLE",
47
- message: "127.0.0.1 and localhost only work on the gateway machine. Use a LAN IP or tunnel URL instead."
48
- };
49
- return {
50
- ok: true,
51
- url,
52
- loopback: false
53
- };
54
- }
55
- /** Parse `xopc://gateway/mobile-connect?...` payloads from QR codes. */
56
- function parseMobileConnectDeepLink(raw) {
57
- const trimmed = raw.trim();
58
- if (!trimmed) return null;
59
- try {
60
- const u = new URL(trimmed);
61
- if (u.protocol !== "xopc:" || u.hostname !== "gateway" || u.pathname !== "/mobile-connect") return null;
62
- const baseUrl = u.searchParams.get("baseUrl")?.trim() ?? "";
63
- const psRaw = u.searchParams.get("ps")?.trim() ?? "";
64
- let pairingSecret = psRaw;
65
- if (psRaw) try {
66
- pairingSecret = decodeURIComponent(psRaw);
67
- } catch {
68
- pairingSecret = psRaw;
69
- }
70
- if (!baseUrl || !pairingSecret) return null;
71
- const lanRaw = u.searchParams.get("lanUrl")?.trim() ?? "";
72
- const lanUrl = lanRaw ? normalizeGatewayBaseUrl(lanRaw) : null;
73
- const normalizedBase = normalizeGatewayBaseUrl(baseUrl);
74
- if (!normalizedBase) return null;
75
- return {
76
- baseUrl: normalizedBase,
77
- lanUrl,
78
- pairingSecret
79
- };
80
- } catch {
81
- return null;
82
- }
83
- }
84
- /**
85
- * Ordered URLs for mobile clients. Priority:
86
- * 1. reverse-proxy public URL (user-deployed HTTPS, typically fastest + works on cellular)
87
- * 2. LAN URL (zero-RTT on same network)
88
- * 3. baseUrl (legacy: usually the FRP tunnel public URL, kept for callers that
89
- * do not yet split reverseProxyUrl from tunnelUrl)
90
- * 4. tunnelUrl (explicit FRP tunnel URL, kept as a fallback even when a
91
- * reverse-proxy URL is also configured)
92
- *
93
- * Loopback URLs are dropped (they only work on the gateway host) and
94
- * duplicates are de-duped while preserving first occurrence order.
95
- */
96
- function buildMobileConnectUrlOrder(params) {
97
- const ordered = [];
98
- const seen = /* @__PURE__ */ new Set();
99
- const push = (raw) => {
100
- const url = raw ? normalizeGatewayBaseUrl(raw) : null;
101
- if (!url || isLoopbackGatewayBaseUrl(url) || seen.has(url)) return;
102
- seen.add(url);
103
- ordered.push(url);
104
- };
105
- push(params.reverseProxyUrl);
106
- push(params.lanUrl);
107
- push(params.baseUrl);
108
- push(params.tunnelUrl);
109
- return ordered;
110
- }
111
- /** First LAN URL when the gateway listens on a network-accessible bind host. */
112
- function resolveMobilePairLanUrl(config) {
113
- if (!isNetworkAccessibleBindHost(resolveGatewayEffectiveHost(config))) return null;
114
- return enumerateLanGatewayCandidates(config.gateway?.port ?? 18790)[0]?.url ?? null;
115
- }
116
- //#endregion
117
- export { buildMobileConnectUrlOrder, isLoopbackGatewayBaseUrl, normalizeGatewayBaseUrl, parseMobileConnectDeepLink, resolveMobilePairLanUrl, validateMobilePairBaseUrl };
@@ -1,12 +0,0 @@
1
- export type PairingFailureLimitResult = {
2
- allowed: boolean;
3
- retryAfterMs: number;
4
- };
5
- /**
6
- * Records a failed pairing exchange and returns whether subsequent attempts
7
- * are still permitted. Called from the route handler on every invalid /
8
- * expired pairing secret — successful exchanges do NOT call this.
9
- */
10
- export declare function consumePairingExchangeFailLimit(clientKey: string): PairingFailureLimitResult;
11
- /** @internal */
12
- export declare function resetPairingExchangeLimitsForTests(): void;
@@ -1,28 +0,0 @@
1
- import { buckets } from "../gateway/rate-limit/buckets.js";
2
- import "../gateway/rate-limit/index.js";
3
- //#region src/tunnel/pairing-rate-limit.ts
4
- /**
5
- * Records a failed pairing exchange and returns whether subsequent attempts
6
- * are still permitted. Called from the route handler on every invalid /
7
- * expired pairing secret — successful exchanges do NOT call this.
8
- */
9
- function consumePairingExchangeFailLimit(clientKey) {
10
- const fl = buckets.pairingExchange();
11
- const key = clientKey.trim() || "unknown";
12
- fl.fail(key);
13
- const status = fl.check(key);
14
- if (status.blocked) return {
15
- allowed: false,
16
- retryAfterMs: status.retryAfterSec * 1e3
17
- };
18
- return {
19
- allowed: true,
20
- retryAfterMs: 0
21
- };
22
- }
23
- /** @internal */
24
- function resetPairingExchangeLimitsForTests() {
25
- buckets.pairingExchange().resetForTests();
26
- }
27
- //#endregion
28
- export { consumePairingExchangeFailLimit, resetPairingExchangeLimitsForTests };
@@ -1,21 +0,0 @@
1
- export type PairingSecretResult = {
2
- secret: string;
3
- expiresAt: Date;
4
- };
5
- export type PairingExchangePayload = {
6
- token: string;
7
- baseUrl: string | null;
8
- lanUrl: string | null;
9
- connectUrls: string[];
10
- };
11
- export declare function cachePairingExchange(secret: string, payload: PairingExchangePayload): void;
12
- export declare function getCachedPairingExchange(secret: string): PairingExchangePayload | null;
13
- /**
14
- * Consume a pairing secret once and build the exchange payload.
15
- * Concurrent requests for the same secret share one in-flight exchange (mobile cold-start deeplink).
16
- */
17
- export declare function exchangePairingSecretOnce(secret: string, buildPayload: () => PairingExchangePayload): Promise<PairingExchangePayload | null>;
18
- export declare function createPairingSecret(): PairingSecretResult;
19
- export declare function consumePairingSecret(secret: string): boolean;
20
- /** @internal */
21
- export declare function resetPairingSessionsForTests(): void;
@@ -1,103 +0,0 @@
1
- import { createLogger } from "../utils/logger/index.js";
2
- import { init_logger } from "../utils/logger.js";
3
- import { randomBytes } from "node:crypto";
4
- //#region src/tunnel/pairing.ts
5
- init_logger();
6
- const log = createLogger("TunnelPairing");
7
- const PAIRING_TTL_MS = 5 * 6e4;
8
- const CLEANUP_INTERVAL_MS = 6e4;
9
- const sessions = /* @__PURE__ */ new Map();
10
- let cleanupTimer = null;
11
- function ensureCleanupTimer() {
12
- if (cleanupTimer) return;
13
- cleanupTimer = setInterval(() => {
14
- const now = Date.now();
15
- for (const [key, session] of sessions) if (now > session.expiresAt.getTime()) sessions.delete(key);
16
- }, CLEANUP_INTERVAL_MS);
17
- cleanupTimer.unref?.();
18
- }
19
- const EXCHANGE_REPLAY_MS = 6e4;
20
- const exchangeReplayCache = /* @__PURE__ */ new Map();
21
- function cachePairingExchange(secret, payload) {
22
- exchangeReplayCache.set(secret, {
23
- expiresAt: Date.now() + EXCHANGE_REPLAY_MS,
24
- payload
25
- });
26
- }
27
- function getCachedPairingExchange(secret) {
28
- const entry = exchangeReplayCache.get(secret);
29
- if (!entry) return null;
30
- if (Date.now() > entry.expiresAt) {
31
- exchangeReplayCache.delete(secret);
32
- return null;
33
- }
34
- return entry.payload;
35
- }
36
- const inflightExchanges = /* @__PURE__ */ new Map();
37
- /**
38
- * Consume a pairing secret once and build the exchange payload.
39
- * Concurrent requests for the same secret share one in-flight exchange (mobile cold-start deeplink).
40
- */
41
- async function exchangePairingSecretOnce(secret, buildPayload) {
42
- const key = secret.trim();
43
- if (!key) return null;
44
- const replay = getCachedPairingExchange(key);
45
- if (replay) return replay;
46
- let inflight = inflightExchanges.get(key);
47
- if (!inflight) {
48
- inflight = (async () => {
49
- const cached = getCachedPairingExchange(key);
50
- if (cached) return cached;
51
- if (!consumePairingSecret(key)) return getCachedPairingExchange(key);
52
- const payload = buildPayload();
53
- cachePairingExchange(key, payload);
54
- return payload;
55
- })();
56
- inflightExchanges.set(key, inflight);
57
- }
58
- try {
59
- return await inflight;
60
- } finally {
61
- if (inflightExchanges.get(key) === inflight) inflightExchanges.delete(key);
62
- }
63
- }
64
- function createPairingSecret() {
65
- ensureCleanupTimer();
66
- const secret = randomBytes(32).toString("base64url");
67
- const expiresAt = new Date(Date.now() + PAIRING_TTL_MS);
68
- sessions.set(secret, {
69
- expiresAt,
70
- consumed: false
71
- });
72
- log.info({ expiresAt: expiresAt.toISOString() }, "Pairing session created");
73
- return {
74
- secret,
75
- expiresAt
76
- };
77
- }
78
- function consumePairingSecret(secret) {
79
- if (!secret.trim()) return false;
80
- const session = sessions.get(secret);
81
- if (!session) return false;
82
- if (session.consumed) return false;
83
- if (Date.now() > session.expiresAt.getTime()) {
84
- sessions.delete(secret);
85
- return false;
86
- }
87
- session.consumed = true;
88
- sessions.delete(secret);
89
- log.info("Pairing session consumed");
90
- return true;
91
- }
92
- /** @internal */
93
- function resetPairingSessionsForTests() {
94
- sessions.clear();
95
- exchangeReplayCache.clear();
96
- inflightExchanges.clear();
97
- if (cleanupTimer) {
98
- clearInterval(cleanupTimer);
99
- cleanupTimer = null;
100
- }
101
- }
102
- //#endregion
103
- export { cachePairingExchange, consumePairingSecret, createPairingSecret, exchangePairingSecretOnce, getCachedPairingExchange, resetPairingSessionsForTests };
@@ -1,9 +0,0 @@
1
- import type { TunnelQrPayload } from './tunnel-types.js';
2
- /** First non-internal IPv4 suitable for LAN QR (when gateway listens on 0.0.0.0). */
3
- export declare function resolveLanGatewayUrl(gatewayHost: string, gatewayPort: number): string | null;
4
- export declare function buildMobileConnectQrPayload(input: {
5
- publicUrl: string;
6
- lanUrl: string | null;
7
- pairingSecret: string;
8
- expiresAt?: string;
9
- }): TunnelQrPayload;
@@ -1,29 +0,0 @@
1
- import { enumerateLanGatewayCandidates } from "../gateway/host.js";
2
- //#region src/tunnel/tunnel-qr.ts
3
- function trimBase(raw) {
4
- return raw.trim().replace(/\/+$/, "");
5
- }
6
- /** First non-internal IPv4 suitable for LAN QR (when gateway listens on 0.0.0.0). */
7
- function resolveLanGatewayUrl(gatewayHost, gatewayPort) {
8
- const host = gatewayHost.trim().toLowerCase();
9
- if (host === "127.0.0.1" || host === "localhost" || host === "::1") return null;
10
- let ip;
11
- if (host === "0.0.0.0" || host === "::" || host === "") ip = enumerateLanGatewayCandidates(gatewayPort)[0]?.address;
12
- else if (!host.includes(":")) ip = host;
13
- if (!ip) return null;
14
- return trimBase(`http://${ip}:${gatewayPort}`);
15
- }
16
- function buildMobileConnectQrPayload(input) {
17
- const params = new URLSearchParams();
18
- params.set("baseUrl", input.publicUrl);
19
- if (input.lanUrl) params.set("lanUrl", input.lanUrl);
20
- if (input.pairingSecret) params.set("ps", input.pairingSecret);
21
- return {
22
- qrPayload: `xopc://gateway/mobile-connect?${params.toString()}`,
23
- publicUrl: input.publicUrl,
24
- lanUrl: input.lanUrl,
25
- expiresAt: input.expiresAt
26
- };
27
- }
28
- //#endregion
29
- export { buildMobileConnectQrPayload, resolveLanGatewayUrl };