@xrkseek/harness-cli 0.1.3 → 0.1.4

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 (278) hide show
  1. package/README.md +41 -22
  2. package/dist/commands/plugin.js +16 -16
  3. package/dist/commands/plugin.js.map +1 -1
  4. package/dist/commands/serve.d.ts.map +1 -1
  5. package/dist/commands/serve.js +34 -3
  6. package/dist/commands/serve.js.map +1 -1
  7. package/dist/log.d.ts +6 -1
  8. package/dist/log.d.ts.map +1 -1
  9. package/dist/log.js +20 -6
  10. package/dist/log.js.map +1 -1
  11. package/dist/parse-args.js +8 -8
  12. package/dist/plugin/index.js +5 -5
  13. package/dist/plugin/index.js.map +1 -1
  14. package/dist/plugin/remap-inject.d.ts.map +1 -1
  15. package/dist/plugin/remap-inject.js +1 -0
  16. package/dist/plugin/remap-inject.js.map +1 -1
  17. package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
  18. package/node_modules/@xrkseek/server-face/dist/handlers/cost-meter.d.ts +15 -22
  19. package/node_modules/@xrkseek/server-face/dist/handlers/cost-meter.d.ts.map +1 -1
  20. package/node_modules/@xrkseek/server-face/dist/handlers/cost-meter.js +19 -16
  21. package/node_modules/@xrkseek/server-face/dist/handlers/cost-meter.js.map +1 -1
  22. package/node_modules/@xrkseek/server-face/dist/index.d.ts +2 -1
  23. package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
  24. package/node_modules/@xrkseek/server-face/dist/index.js +2 -1
  25. package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
  26. package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
  27. package/node_modules/@xrkseek/server-host/dist/index.js +12 -4
  28. package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
  29. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.d.ts +10 -0
  30. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.d.ts.map +1 -0
  31. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js +131 -0
  32. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js.map +1 -0
  33. package/node_modules/@xrkseek/server-host/dist/wallet-bridge.d.ts.map +1 -1
  34. package/node_modules/@xrkseek/server-host/dist/wallet-bridge.js +29 -1
  35. package/node_modules/@xrkseek/server-host/dist/wallet-bridge.js.map +1 -1
  36. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.d.ts.map +1 -1
  37. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js +3 -1
  38. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js.map +1 -1
  39. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts +4 -1
  40. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts.map +1 -1
  41. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js +1 -1
  42. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js.map +1 -1
  43. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-discovery.d.ts +41 -0
  44. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-discovery.d.ts.map +1 -0
  45. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-discovery.js +422 -0
  46. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-discovery.js.map +1 -0
  47. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-registry.d.ts +21 -0
  48. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-registry.d.ts.map +1 -0
  49. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-registry.js +34 -0
  50. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import-registry.js.map +1 -0
  51. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import.d.ts +1 -1
  52. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import.d.ts.map +1 -1
  53. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import.js +277 -23
  54. package/node_modules/@xrkseek/server-http/dist/dsh-compat/chat-import.js.map +1 -1
  55. package/node_modules/@xrkseek/server-http/dist/dsh-compat/community-root-http.d.ts +1 -1
  56. package/node_modules/@xrkseek/server-http/dist/dsh-compat/community-root-http.js +1 -1
  57. package/node_modules/@xrkseek/server-http/dist/dsh-compat/community-root-http.js.map +1 -1
  58. package/node_modules/@xrkseek/server-http/dist/dsh-compat/cordis-registry.d.ts +1 -1
  59. package/node_modules/@xrkseek/server-http/dist/dsh-compat/cordis-registry.d.ts.map +1 -1
  60. package/node_modules/@xrkseek/server-http/dist/dsh-compat/cordis-registry.js +2 -2
  61. package/node_modules/@xrkseek/server-http/dist/dsh-compat/cordis-registry.js.map +1 -1
  62. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-community-infer.js +1 -1
  63. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-community-infer.js.map +1 -1
  64. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.d.ts +4 -4
  65. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.d.ts.map +1 -1
  66. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js +26 -26
  67. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js.map +1 -1
  68. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-envelope.js +1 -1
  69. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-envelope.js.map +1 -1
  70. package/node_modules/@xrkseek/server-http/dist/dsh-compat/generic-dsh-http.d.ts +2 -2
  71. package/node_modules/@xrkseek/server-http/dist/dsh-compat/generic-dsh-http.js +1 -1
  72. package/node_modules/@xrkseek/server-http/dist/dsh-compat/generic-dsh-http.js.map +1 -1
  73. package/node_modules/@xrkseek/server-http/dist/dsh-compat/generic-plugin-http.js +3 -3
  74. package/node_modules/@xrkseek/server-http/dist/dsh-compat/generic-plugin-http.js.map +1 -1
  75. package/node_modules/@xrkseek/server-http/dist/dsh-compat/genui.js +1 -1
  76. package/node_modules/@xrkseek/server-http/dist/dsh-compat/genui.js.map +1 -1
  77. package/node_modules/@xrkseek/server-http/dist/dsh-compat/honest-http-catchall.js +3 -3
  78. package/node_modules/@xrkseek/server-http/dist/dsh-compat/honest-http-catchall.js.map +1 -1
  79. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-messaging-bridge.d.ts +2 -0
  80. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-messaging-bridge.d.ts.map +1 -1
  81. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-messaging-bridge.js +53 -1
  82. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-messaging-bridge.js.map +1 -1
  83. package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.d.ts +21 -18
  84. package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.d.ts.map +1 -1
  85. package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.js +28 -15
  86. package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.js.map +1 -1
  87. package/node_modules/@xrkseek/server-http/dist/dsh-compat/market.js +1 -1
  88. package/node_modules/@xrkseek/server-http/dist/dsh-compat/market.js.map +1 -1
  89. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memento.d.ts +1 -0
  90. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memento.d.ts.map +1 -1
  91. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memento.js +77 -24
  92. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memento.js.map +1 -1
  93. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mnemon.d.ts +24 -0
  94. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mnemon.d.ts.map +1 -1
  95. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mnemon.js +39 -10
  96. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mnemon.js.map +1 -1
  97. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-auth.d.ts +71 -0
  98. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-auth.d.ts.map +1 -0
  99. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-auth.js +349 -0
  100. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-auth.js.map +1 -0
  101. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-cpolar-component.d.ts +53 -0
  102. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-cpolar-component.d.ts.map +1 -0
  103. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-cpolar-component.js +233 -0
  104. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-cpolar-component.js.map +1 -0
  105. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-funnel-sidecar.d.ts +4 -0
  106. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-funnel-sidecar.d.ts.map +1 -0
  107. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-funnel-sidecar.js +86 -0
  108. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-funnel-sidecar.js.map +1 -0
  109. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-gate.d.ts +15 -0
  110. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-gate.d.ts.map +1 -0
  111. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-gate.js +41 -0
  112. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-gate.js.map +1 -0
  113. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-local-gateway.d.ts +22 -0
  114. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-local-gateway.d.ts.map +1 -0
  115. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-local-gateway.js +183 -0
  116. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-local-gateway.js.map +1 -0
  117. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-controllers.d.ts +68 -0
  118. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-controllers.d.ts.map +1 -0
  119. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-controllers.js +511 -0
  120. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-controllers.js.map +1 -0
  121. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-runtime.d.ts +34 -0
  122. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-runtime.d.ts.map +1 -0
  123. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-runtime.js +179 -0
  124. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote-runtime.js.map +1 -0
  125. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote.d.ts +19 -0
  126. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote.d.ts.map +1 -0
  127. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote.js +102 -0
  128. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access-remote.js.map +1 -0
  129. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access.d.ts +31 -4
  130. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access.d.ts.map +1 -1
  131. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access.js +698 -33
  132. package/node_modules/@xrkseek/server-http/dist/dsh-compat/mobile-access.js.map +1 -1
  133. package/node_modules/@xrkseek/server-http/dist/dsh-compat/modlens.js +1 -1
  134. package/node_modules/@xrkseek/server-http/dist/dsh-compat/modlens.js.map +1 -1
  135. package/node_modules/@xrkseek/server-http/dist/dsh-compat/modsearch.d.ts.map +1 -1
  136. package/node_modules/@xrkseek/server-http/dist/dsh-compat/modsearch.js +4 -1
  137. package/node_modules/@xrkseek/server-http/dist/dsh-compat/modsearch.js.map +1 -1
  138. package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.js +1 -1
  139. package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.js.map +1 -1
  140. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket-qrcode.d.ts +3 -0
  141. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket-qrcode.d.ts.map +1 -0
  142. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket-qrcode.js +18 -0
  143. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket-qrcode.js.map +1 -0
  144. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket.d.ts +6 -3
  145. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket.d.ts.map +1 -1
  146. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket.js +204 -54
  147. package/node_modules/@xrkseek/server-http/dist/dsh-compat/pocket.js.map +1 -1
  148. package/node_modules/@xrkseek/server-http/dist/dsh-compat/releases.js +1 -1
  149. package/node_modules/@xrkseek/server-http/dist/dsh-compat/releases.js.map +1 -1
  150. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-adapter.d.ts +3 -0
  151. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-adapter.d.ts.map +1 -1
  152. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-adapter.js +185 -21
  153. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-adapter.js.map +1 -1
  154. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-browser.d.ts +3 -0
  155. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-browser.d.ts.map +1 -0
  156. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-browser.js +82 -0
  157. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-browser.js.map +1 -0
  158. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-face-bridge.d.ts +43 -0
  159. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-face-bridge.d.ts.map +1 -0
  160. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-face-bridge.js +2 -0
  161. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-face-bridge.js.map +1 -0
  162. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-git.d.ts +47 -13
  163. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-git.d.ts.map +1 -1
  164. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-git.js +146 -27
  165. package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-git.js.map +1 -1
  166. package/node_modules/@xrkseek/server-http/dist/dsh-compat/skin-market.js +1 -1
  167. package/node_modules/@xrkseek/server-http/dist/dsh-compat/skin-market.js.map +1 -1
  168. package/node_modules/@xrkseek/server-http/dist/dsh-compat/tokenledger.d.ts.map +1 -1
  169. package/node_modules/@xrkseek/server-http/dist/dsh-compat/tokenledger.js +22 -4
  170. package/node_modules/@xrkseek/server-http/dist/dsh-compat/tokenledger.js.map +1 -1
  171. package/node_modules/@xrkseek/server-http/dist/dsh-compat/tongflow.d.ts.map +1 -1
  172. package/node_modules/@xrkseek/server-http/dist/dsh-compat/tongflow.js +21 -2
  173. package/node_modules/@xrkseek/server-http/dist/dsh-compat/tongflow.js.map +1 -1
  174. package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind-workspace.js +1 -1
  175. package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind-workspace.js.map +1 -1
  176. package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind.d.ts +2 -0
  177. package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind.d.ts.map +1 -1
  178. package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind.js +42 -3
  179. package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind.js.map +1 -1
  180. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/contracts/wallet-port.d.ts +25 -7
  181. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/contracts/wallet-port.d.ts.map +1 -1
  182. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/contracts/wallet-port.js +2 -2
  183. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/doc-store.d.ts +2 -2
  184. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/doc-store.js +2 -2
  185. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/http-json.d.ts +12 -0
  186. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/http-json.d.ts.map +1 -0
  187. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/http-json.js +40 -0
  188. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/http-json.js.map +1 -0
  189. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/http-kit.d.ts +1 -1
  190. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/http-kit.js +1 -1
  191. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/http-kit.js.map +1 -1
  192. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/index.d.ts +7 -12
  193. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/index.d.ts.map +1 -1
  194. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/index.js +5 -8
  195. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/index.js.map +1 -1
  196. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/json-store.d.ts +5 -0
  197. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/json-store.d.ts.map +1 -0
  198. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/json-store.js +31 -0
  199. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/json-store.js.map +1 -0
  200. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/mobile-gate-kit.d.ts +37 -0
  201. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/mobile-gate-kit.d.ts.map +1 -0
  202. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/mobile-gate-kit.js +96 -0
  203. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/mobile-gate-kit.js.map +1 -0
  204. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/public-handler.d.ts +6 -0
  205. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/public-handler.d.ts.map +1 -0
  206. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/public-handler.js +2 -0
  207. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/public-handler.js.map +1 -0
  208. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/wallet-service.d.ts.map +1 -1
  209. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/wallet-service.js +66 -4
  210. package/node_modules/@xrkseek/server-http/dist/dsh-compat/underlying/wallet-service.js.map +1 -1
  211. package/node_modules/@xrkseek/server-http/dist/dsh-compat/undo.js +2 -2
  212. package/node_modules/@xrkseek/server-http/dist/dsh-compat/undo.js.map +1 -1
  213. package/node_modules/@xrkseek/server-http/dist/dsh-compat/usage-stats.js +1 -1
  214. package/node_modules/@xrkseek/server-http/dist/dsh-compat/usage-stats.js.map +1 -1
  215. package/node_modules/@xrkseek/server-http/dist/dsh-compat/vision.js +1 -1
  216. package/node_modules/@xrkseek/server-http/dist/dsh-compat/vision.js.map +1 -1
  217. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wallet.d.ts +2 -2
  218. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wallet.d.ts.map +1 -1
  219. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wallet.js +2 -2
  220. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wallet.js.map +1 -1
  221. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wallpaper.js +2 -2
  222. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wallpaper.js.map +1 -1
  223. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wire/settings-provider.d.ts +1 -1
  224. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wire/stub-handlers.js +1 -1
  225. package/node_modules/@xrkseek/server-http/dist/dsh-compat/wire/stub-handlers.js.map +1 -1
  226. package/node_modules/@xrkseek/server-http/dist/dsh-compat/xrk-json-store.js +3 -3
  227. package/node_modules/@xrkseek/server-http/dist/dsh-compat/xrk-json-store.js.map +1 -1
  228. package/node_modules/@xrkseek/server-http/dist/index.d.ts +1 -1
  229. package/node_modules/@xrkseek/server-http/dist/index.d.ts.map +1 -1
  230. package/node_modules/@xrkseek/server-http/dist/index.js +1 -1
  231. package/node_modules/@xrkseek/server-http/dist/index.js.map +1 -1
  232. package/node_modules/@xrkseek/server-http/package.json +7 -1
  233. package/node_modules/qrcode-generator/README.md +101 -0
  234. package/node_modules/qrcode-generator/package.json +30 -0
  235. package/node_modules/qrcode-generator/qrcode.d.ts +57 -0
  236. package/node_modules/qrcode-generator/qrcode.js +2297 -0
  237. package/node_modules/qrcode-generator/qrcode_SJIS.js +30 -0
  238. package/node_modules/qrcode-generator/qrcode_UTF8.js +26 -0
  239. package/node_modules/qrcode-generator/sample.html +49 -0
  240. package/node_modules/qrcode-generator/sample.js +49 -0
  241. package/node_modules/qrcode-generator/test/qrcode.js +118 -0
  242. package/package.json +4 -2
  243. package/product-web/assets/index-BNGm-t1O.js +112 -0
  244. package/product-web/assets/index-BNGm-t1O.js.map +1 -0
  245. package/product-web/boot.json +1 -1
  246. package/product-web/index.html +1 -1
  247. package/product-web/plugins/@xrkseek/client-locale/client.js +3 -3
  248. package/product-web/plugins/@xrkseek/client-modules/client.js +7 -6
  249. package/product-web/plugins/@xrkseek/client-runtime/client.js +7 -0
  250. package/product-web/plugins/@xrkseek/client-ui-agent-preset/client.js +37 -37
  251. package/product-web/plugins/@xrkseek/client-ui-attachment/client.js +14 -14
  252. package/product-web/plugins/@xrkseek/client-ui-commands/client.js +8 -8
  253. package/product-web/plugins/@xrkseek/client-ui-conversation/client.js +186 -193
  254. package/product-web/plugins/@xrkseek/client-ui-deliverables/client.js +5 -5
  255. package/product-web/plugins/@xrkseek/client-ui-directory-picker-browse/client.js +30 -30
  256. package/product-web/plugins/@xrkseek/client-ui-goal/client.js +8 -8
  257. package/product-web/plugins/@xrkseek/client-ui-input-trigger/client.js +5 -5
  258. package/product-web/plugins/@xrkseek/client-ui-jobs/client.js +9 -9
  259. package/product-web/plugins/@xrkseek/client-ui-layout/client.js +3 -3
  260. package/product-web/plugins/@xrkseek/client-ui-message-feedback/client.js +5 -5
  261. package/product-web/plugins/@xrkseek/client-ui-model-selection/client.js +18 -18
  262. package/product-web/plugins/@xrkseek/client-ui-permission-presets/client.js +3 -3
  263. package/product-web/plugins/@xrkseek/client-ui-plan/client.js +2 -2
  264. package/product-web/plugins/@xrkseek/client-ui-settings-general/client.js +27 -19
  265. package/product-web/plugins/@xrkseek/client-ui-settings-models/client.js +54 -54
  266. package/product-web/plugins/@xrkseek/client-ui-settings-plugin-inventory/client.js +13 -13
  267. package/product-web/plugins/@xrkseek/client-ui-settings-plugins/client.js +42 -42
  268. package/product-web/plugins/@xrkseek/client-ui-sidebar/client.js +16 -16
  269. package/product-web/plugins/@xrkseek/client-ui-skill/client.js +11 -11
  270. package/product-web/plugins/@xrkseek/client-ui-subagent/client.js +22 -22
  271. package/product-web/plugins/@xrkseek/client-ui-theme/client.js +4 -4
  272. package/product-web/plugins/@xrkseek/client-ui-tool/client.js +38 -38
  273. package/product-web/plugins/@xrkseek/client-ui-trajectory/client.js +144 -144
  274. package/product-web/plugins/@xrkseek/client-ui-user-questions/client.js +31 -31
  275. package/product-web/plugins/@xrkseek/client-ui-workflow-run/client.js +17 -17
  276. package/product-web/plugins/@xrkseek/client-ui-workspace/client.js +53 -53
  277. package/product-web/assets/index-C_NG-17x.js +0 -112
  278. package/product-web/assets/index-C_NG-17x.js.map +0 -1
@@ -1,7 +1,37 @@
1
- import { randomBytes } from "node:crypto";
2
- import { sendJson } from "../http-json.js";
1
+ import { randomBytes, createHash } from "node:crypto";
2
+ import { networkInterfaces } from "node:os";
3
+ import { sendJson } from "./underlying/http-json.js";
3
4
  import { createXrkDocStore } from "./underlying/doc-store.js";
4
5
  import { httpMethod, isMutatingMethod, parseJsonBody } from "./underlying/http-kit.js";
6
+ import { DEVICE_COOKIE, LAN_PIN_COOKIE, LAN_PIN_PAGE_HTML, LAN_PIN_PAGE_JS, LOGIN_PAGE_HTML, LOGIN_PAGE_JS, mintPairingWindow, pairDevice, PAIR_PAGE_HTML, PAIR_PAGE_JS, parseCookieHeader, pruneMobileAuth, publicDevice, renewSession, SESSION_COOKIE, setAccessPinCookie, setMobileSessionCookies, WAN_PIN_COOKIE, WAN_PIN_PAGE_HTML, WAN_PIN_PAGE_JS, } from "./mobile-access-auth.js";
7
+ import { getMobileRemoteRuntime, } from "./mobile-access-remote-runtime.js";
8
+ import { qrSvgForText } from "./pocket-qrcode.js";
9
+ /**
10
+ * Product-shell mobile seam for `/mobile-access/custom.css`.
11
+ * Clears session header chrome that collides with dsh-mobile / pocket nav.
12
+ */
13
+ export const XRK_MOBILE_SHELL_CSS = `/* XRK shell mobile seam */
14
+ @media (max-width: 900px) {
15
+ [data-slot="conversation.session.header.actions"],
16
+ [data-slot="conversation.session.header.utilities"] {
17
+ display: none !important;
18
+ }
19
+ [role="tablist"] {
20
+ padding-inline: 44px;
21
+ }
22
+ }
23
+ `;
24
+ /** Inject shell seam stylesheet into product index (works without dsh-mobile fetch). */
25
+ export function injectMobileAccessShellIntoHtml(html) {
26
+ if (html.includes("/mobile-access/custom.css"))
27
+ return html;
28
+ const link = `<link rel="stylesheet" href="/mobile-access/custom.css">`;
29
+ const idx = html.toLowerCase().lastIndexOf("</head>");
30
+ if (idx >= 0) {
31
+ return `${html.slice(0, idx)}${link}${html.slice(idx)}`;
32
+ }
33
+ return `${link}${html}`;
34
+ }
5
35
  const DEFAULT_STATE = {
6
36
  running: false,
7
37
  appKey: "",
@@ -9,15 +39,62 @@ const DEFAULT_STATE = {
9
39
  customCss: "",
10
40
  customJs: "",
11
41
  origin: "",
42
+ instanceId: "",
43
+ pairingToken: "",
44
+ pairingExpiresAt: 0,
45
+ devices: [],
46
+ sessions: [],
47
+ remoteProvider: "tailscale",
48
+ remoteEnabled: false,
49
+ lanIpOverride: "",
50
+ lanAuthEnabled: true,
51
+ lanToken: "",
52
+ wanToken: "",
53
+ lanPinCustom: false,
54
+ wanPinCustom: false,
55
+ restartNotice: false,
12
56
  };
13
57
  const MOBILE_STORE = createXrkDocStore(["mobile-access", "state.json"], { ...DEFAULT_STATE });
14
58
  function loadState(options) {
15
- return { ...DEFAULT_STATE, ...MOBILE_STORE.read(options.xrkHome).data };
59
+ const row = MOBILE_STORE.read(options.xrkHome).data;
60
+ const devices = Array.isArray(row.devices)
61
+ ? row.devices
62
+ : [];
63
+ const sessions = Array.isArray(row.sessions)
64
+ ? row.sessions
65
+ : [];
66
+ const merged = {
67
+ ...DEFAULT_STATE,
68
+ ...row,
69
+ devices,
70
+ sessions,
71
+ remoteProvider: row.remoteProvider === "cpolar" ? "cpolar" : "tailscale",
72
+ remoteEnabled: row.remoteEnabled === true,
73
+ lanIpOverride: typeof row.lanIpOverride === "string" ? row.lanIpOverride : "",
74
+ lanAuthEnabled: row.lanAuthEnabled !== false,
75
+ lanToken: typeof row.lanToken === "string" ? row.lanToken : "",
76
+ wanToken: typeof row.wanToken === "string" ? row.wanToken : "",
77
+ lanPinCustom: row.lanPinCustom === true,
78
+ wanPinCustom: row.wanPinCustom === true,
79
+ restartNotice: row.restartNotice === true,
80
+ };
81
+ const pruned = pruneMobileAuth({
82
+ pairingToken: merged.pairingToken,
83
+ pairingExpiresAt: merged.pairingExpiresAt,
84
+ devices: merged.devices,
85
+ sessions: merged.sessions,
86
+ });
87
+ return { ...merged, ...pruned };
16
88
  }
17
89
  function saveState(options, state) {
18
90
  return MOBILE_STORE.write(options.xrkHome, state).revision;
19
91
  }
20
- /** Pocket / IM 只读 mobile-access 运行态(revision 信封下的 data)。 */
92
+ function ensureInstanceId(state) {
93
+ if (state.instanceId)
94
+ return state;
95
+ return { ...state, instanceId: randomBytes(8).toString("hex") };
96
+ }
97
+ /** Read-only mobile-access runtime snapshot (revision envelope `data`). */
21
98
  export function readMobileAccessSnapshot(options) {
22
99
  const state = loadState(options);
23
100
  return {
@@ -26,9 +103,85 @@ export function readMobileAccessSnapshot(options) {
26
103
  appKey: state.appKey,
27
104
  };
28
105
  }
106
+ export function readMobileAccessState(options) {
107
+ return loadState(options);
108
+ }
109
+ export function patchMobileAccessState(options, patch) {
110
+ const next = { ...loadState(options), ...patch };
111
+ saveState(options, next);
112
+ return next;
113
+ }
114
+ export function mint8DigitPin() {
115
+ let pin = "";
116
+ for (let i = 0; i < 8; i += 1) {
117
+ pin += String(randomBytes(1)[0] % 10);
118
+ }
119
+ return pin;
120
+ }
121
+ export function listLanIPv4Candidates() {
122
+ const ips = [];
123
+ for (const entries of Object.values(networkInterfaces())) {
124
+ if (!entries)
125
+ continue;
126
+ for (const net of entries) {
127
+ if (net.family === "IPv4" && !net.internal)
128
+ ips.push(net.address);
129
+ }
130
+ }
131
+ return [...new Set(ips)];
132
+ }
133
+ export function buildMobileLanUrl(state, req) {
134
+ if (!state.running)
135
+ return "";
136
+ const base = state.origin || (req ? requestLanOrigin(req) : "");
137
+ if (!base)
138
+ return "";
139
+ try {
140
+ const url = new URL(base);
141
+ if (state.lanIpOverride)
142
+ url.hostname = state.lanIpOverride;
143
+ return url.toString().replace(/\/$/, "");
144
+ }
145
+ catch {
146
+ return base.replace(/\/$/, "");
147
+ }
148
+ }
149
+ /** Lazy-start LAN access when dsh-pocket settings opens (matches DSH pocket auto-proxy). */
150
+ export function ensureMobileAccessRunning(options, req) {
151
+ let state = ensureInstanceId(loadState(options));
152
+ if (state.running)
153
+ return state;
154
+ const port = process.env.XRK_SERVE_PORT?.trim() || "8099";
155
+ const fallbackOrigin = `http://127.0.0.1:${port}`;
156
+ state = {
157
+ ...state,
158
+ running: true,
159
+ origin: req?.headers?.host ? requestLanOrigin(req) : fallbackOrigin,
160
+ };
161
+ if (!state.csrf)
162
+ state.csrf = mintToken();
163
+ if (!state.lanToken)
164
+ state.lanToken = mint8DigitPin();
165
+ if (!state.wanToken)
166
+ state.wanToken = mint8DigitPin();
167
+ saveState(options, state);
168
+ return state;
169
+ }
29
170
  function mintToken() {
30
171
  return randomBytes(24).toString("base64url");
31
172
  }
173
+ function firstLanIPv4() {
174
+ const nets = networkInterfaces();
175
+ for (const entries of Object.values(nets)) {
176
+ if (!entries)
177
+ continue;
178
+ for (const net of entries) {
179
+ if (net.family === "IPv4" && !net.internal)
180
+ return net.address;
181
+ }
182
+ }
183
+ return undefined;
184
+ }
32
185
  function requestOrigin(req) {
33
186
  const host = req.headers.host?.trim();
34
187
  if (!host)
@@ -37,12 +190,292 @@ function requestOrigin(req) {
37
190
  "http";
38
191
  return `${proto}://${host}`;
39
192
  }
193
+ function requestTls(req) {
194
+ return (req.headers["x-forwarded-proto"]
195
+ ?.split(",")[0]
196
+ ?.trim() === "https");
197
+ }
198
+ /** Prefer LAN IPv4 when the Host header is loopback (phone cannot reach 127.0.0.1). */
199
+ export function requestLanOrigin(req) {
200
+ const direct = requestOrigin(req);
201
+ if (!direct)
202
+ return direct;
203
+ try {
204
+ const url = new URL(direct);
205
+ const loopback = url.hostname === "127.0.0.1" ||
206
+ url.hostname === "localhost" ||
207
+ url.hostname === "::1";
208
+ if (!loopback)
209
+ return direct;
210
+ const lanIp = firstLanIPv4();
211
+ if (!lanIp)
212
+ return direct;
213
+ url.hostname = lanIp;
214
+ return url.toString().replace(/\/$/, "");
215
+ }
216
+ catch {
217
+ return direct;
218
+ }
219
+ }
40
220
  function setCsrfCookie(res, csrf) {
41
221
  res.setHeader("set-cookie", `dsh_ma_csrf=${encodeURIComponent(csrf)}; Path=/; SameSite=Strict; HttpOnly`);
42
222
  }
223
+ function componentErrorResponse(err) {
224
+ const error = err instanceof Error ? err.message : String(err ?? "unknown_error");
225
+ const status = error.includes("unsupported") ||
226
+ error.includes("invalid") ||
227
+ error.includes("authtoken")
228
+ ? 400
229
+ : 500;
230
+ return { status, body: { ok: false, error } };
231
+ }
232
+ async function prepareRemoteRuntime(options, state, syncEnabled = false) {
233
+ const withId = ensureInstanceId(state);
234
+ const runtime = getMobileRemoteRuntime(options.xrkHome);
235
+ await runtime.ensureInitialized(withId.instanceId);
236
+ if (runtime.getProvider() !== withId.remoteProvider) {
237
+ await runtime.selectProvider(withId.remoteProvider);
238
+ }
239
+ if (syncEnabled &&
240
+ runtime.activeController().status().enabled !== withId.remoteEnabled) {
241
+ await runtime.setRemoteEnabled(withId.remoteEnabled);
242
+ }
243
+ return { runtime, state: withId };
244
+ }
245
+ function lanPayload(state) {
246
+ return {
247
+ running: state.running,
248
+ ...(state.running && state.origin ? { origin: state.origin } : {}),
249
+ extensions: { loaded: 0, failed: 0 },
250
+ };
251
+ }
252
+ function openLanPairing(state, req, ttlMs) {
253
+ const opened = mintPairingWindow(typeof ttlMs === "number" && ttlMs >= 10_000 ? ttlMs : 300_000);
254
+ const withInstance = ensureInstanceId(state);
255
+ const origin = withInstance.origin || requestLanOrigin(req);
256
+ const pairUrl = `${origin}/mobile-access/pair#instance=${withInstance.instanceId}&token=${opened.token}`;
257
+ const appKey = `dsh1.${withInstance.instanceId}.${opened.token}`;
258
+ const qrSvg = (() => {
259
+ try {
260
+ return pairUrl ? qrSvgForText(pairUrl, "pair") : "";
261
+ }
262
+ catch {
263
+ return "";
264
+ }
265
+ })();
266
+ const next = {
267
+ ...withInstance,
268
+ pairingToken: opened.token,
269
+ pairingExpiresAt: opened.expiresAt,
270
+ appKey,
271
+ };
272
+ return {
273
+ token: opened.token,
274
+ expiresAt: opened.expiresAt,
275
+ appKey,
276
+ pairUrl,
277
+ appPairUrl: pairUrl,
278
+ qrSvg,
279
+ next,
280
+ };
281
+ }
282
+ async function setRunning(options, req, res, running) {
283
+ let state = ensureInstanceId(loadState(options));
284
+ state = { ...state, running };
285
+ if (!state.csrf)
286
+ state.csrf = mintToken();
287
+ if (running) {
288
+ state.origin = requestLanOrigin(req);
289
+ if (!state.lanToken)
290
+ state.lanToken = mint8DigitPin();
291
+ if (!state.wanToken)
292
+ state.wanToken = mint8DigitPin();
293
+ }
294
+ else {
295
+ state.origin = "";
296
+ state.pairingToken = "";
297
+ state.pairingExpiresAt = 0;
298
+ state.appKey = "";
299
+ }
300
+ saveState(options, state);
301
+ setCsrfCookie(res, state.csrf);
302
+ sendJson(res, 200, lanPayload(state));
303
+ }
304
+ function sendHtml(res, body, contentType) {
305
+ res.writeHead(200, {
306
+ "content-type": `${contentType}; charset=utf-8`,
307
+ "cache-control": "no-cache",
308
+ "content-length": String(Buffer.byteLength(body)),
309
+ });
310
+ res.end(body);
311
+ }
43
312
  export async function handleMobileAccessHttp(req, res, pathname, options) {
313
+ const method = httpMethod(req);
314
+ const tls = requestTls(req);
315
+ if (pathname === "/mobile-access/pair" && (method === "GET" || method === "HEAD")) {
316
+ sendHtml(res, PAIR_PAGE_HTML, "text/html");
317
+ return true;
318
+ }
319
+ if (pathname === "/mobile-access/pair.js" && (method === "GET" || method === "HEAD")) {
320
+ sendHtml(res, PAIR_PAGE_JS, "application/javascript");
321
+ return true;
322
+ }
323
+ if (pathname === "/mobile-access/login" && (method === "GET" || method === "HEAD")) {
324
+ sendHtml(res, LOGIN_PAGE_HTML, "text/html");
325
+ return true;
326
+ }
327
+ if (pathname === "/mobile-access/login.js" && (method === "GET" || method === "HEAD")) {
328
+ sendHtml(res, LOGIN_PAGE_JS, "application/javascript");
329
+ return true;
330
+ }
331
+ if (pathname === "/mobile-access/lan-pin" && (method === "GET" || method === "HEAD")) {
332
+ sendHtml(res, LAN_PIN_PAGE_HTML, "text/html");
333
+ return true;
334
+ }
335
+ if (pathname === "/mobile-access/lan-pin.js" && (method === "GET" || method === "HEAD")) {
336
+ sendHtml(res, LAN_PIN_PAGE_JS, "application/javascript");
337
+ return true;
338
+ }
339
+ if (pathname === "/mobile-access/wan-pin" && (method === "GET" || method === "HEAD")) {
340
+ sendHtml(res, WAN_PIN_PAGE_HTML, "text/html");
341
+ return true;
342
+ }
343
+ if (pathname === "/mobile-access/wan-pin.js" && (method === "GET" || method === "HEAD")) {
344
+ sendHtml(res, WAN_PIN_PAGE_JS, "application/javascript");
345
+ return true;
346
+ }
347
+ if (pathname === "/mobile-access/auth/lan-pin" || pathname === "/mobile-access/auth/wan-pin") {
348
+ if (!isMutatingMethod(method)) {
349
+ sendJson(res, 405, { error: "method not allowed" });
350
+ return true;
351
+ }
352
+ const body = await parseJsonBody(req);
353
+ const pin = typeof body.pin === "string" ? body.pin.trim() : "";
354
+ const state = ensureInstanceId(loadState(options));
355
+ if (!state.running) {
356
+ sendJson(res, 409, { error: "mobile access is not running" });
357
+ return true;
358
+ }
359
+ const expected = pathname.endsWith("/wan-pin") ? state.wanToken : state.lanToken;
360
+ if (!expected || pin !== expected) {
361
+ sendJson(res, 401, { error: "authentication_failed" });
362
+ return true;
363
+ }
364
+ setAccessPinCookie(res, pathname.endsWith("/wan-pin") ? WAN_PIN_COOKIE : LAN_PIN_COOKIE, pin, state.instanceId, tls);
365
+ sendJson(res, 200, { ok: true });
366
+ return true;
367
+ }
368
+ if (pathname === "/mobile-access/health" && (method === "GET" || method === "HEAD")) {
369
+ sendJson(res, 200, { ok: true, service: "xrk-mobile-access" });
370
+ return true;
371
+ }
372
+ if (pathname === "/mobile-access/discovery" && (method === "GET" || method === "HEAD")) {
373
+ const state = loadState(options);
374
+ sendJson(res, 200, {
375
+ instanceId: state.instanceId || ensureInstanceId(state).instanceId,
376
+ origin: state.origin || requestLanOrigin(req),
377
+ running: state.running,
378
+ });
379
+ return true;
380
+ }
381
+ if (pathname === "/mobile-access/auth/pair" ||
382
+ pathname === "/mobile-access/auth/native-pair") {
383
+ if (!isMutatingMethod(method)) {
384
+ sendJson(res, 405, { error: "method not allowed" });
385
+ return true;
386
+ }
387
+ const body = await parseJsonBody(req);
388
+ const token = typeof body.token === "string" ? body.token.trim() : "";
389
+ const label = typeof body.label === "string" ? body.label : undefined;
390
+ const state = loadState(options);
391
+ if (!state.running) {
392
+ sendJson(res, 409, { error: "mobile access is not running" });
393
+ return true;
394
+ }
395
+ try {
396
+ const paired = pairDevice(state, token, label);
397
+ saveState(options, { ...state, ...paired.state });
398
+ setMobileSessionCookies(res, {
399
+ deviceToken: paired.deviceToken,
400
+ sessionToken: paired.sessionToken,
401
+ csrfToken: paired.csrfToken,
402
+ deviceExpiresAt: paired.deviceExpiresAt,
403
+ sessionExpiresAt: paired.sessionExpiresAt,
404
+ }, tls);
405
+ if (pathname.endsWith("/native-pair")) {
406
+ sendJson(res, 201, {
407
+ instanceId: state.instanceId,
408
+ deviceId: paired.deviceId,
409
+ deviceToken: paired.deviceToken,
410
+ deviceExpiresAt: paired.deviceExpiresAt,
411
+ sessionToken: paired.sessionToken,
412
+ csrfToken: paired.csrfToken,
413
+ sessionExpiresAt: paired.sessionExpiresAt,
414
+ });
415
+ }
416
+ else {
417
+ sendJson(res, 200, { ok: true, deviceId: paired.deviceId });
418
+ }
419
+ }
420
+ catch {
421
+ sendJson(res, 401, { error: "authentication_failed" });
422
+ }
423
+ return true;
424
+ }
425
+ if (pathname === "/mobile-access/auth/renew") {
426
+ if (!isMutatingMethod(method)) {
427
+ sendJson(res, 405, { error: "method not allowed" });
428
+ return true;
429
+ }
430
+ await parseJsonBody(req);
431
+ const deviceToken = parseCookieHeader(req.headers.cookie, DEVICE_COOKIE);
432
+ if (!deviceToken) {
433
+ sendJson(res, 401, { error: "authentication_failed" });
434
+ return true;
435
+ }
436
+ const state = loadState(options);
437
+ try {
438
+ const renewed = renewSession(state, deviceToken);
439
+ const device = renewed.state.devices.find((d) => d.tokenDigest === createHash("sha256").update(deviceToken).digest("hex"));
440
+ saveState(options, { ...state, ...renewed.state });
441
+ setMobileSessionCookies(res, {
442
+ deviceToken,
443
+ sessionToken: renewed.sessionToken,
444
+ csrfToken: renewed.csrfToken,
445
+ deviceExpiresAt: device?.expiresAt ?? Date.now() + 90 * 24 * 60 * 60 * 1000,
446
+ sessionExpiresAt: renewed.sessionExpiresAt,
447
+ }, tls);
448
+ sendJson(res, 200, { ok: true });
449
+ }
450
+ catch {
451
+ sendJson(res, 401, { error: "authentication_failed" });
452
+ }
453
+ return true;
454
+ }
455
+ if (pathname === "/mobile-access/auth/logout") {
456
+ if (!isMutatingMethod(method)) {
457
+ sendJson(res, 405, { error: "method not allowed" });
458
+ return true;
459
+ }
460
+ await parseJsonBody(req);
461
+ const sessionKey = parseCookieHeader(req.headers.cookie, SESSION_COOKIE);
462
+ let state = loadState(options);
463
+ if (sessionKey) {
464
+ const digest = createHash("sha256").update(sessionKey).digest("hex");
465
+ state = {
466
+ ...state,
467
+ sessions: state.sessions.filter((s) => s.key !== digest),
468
+ };
469
+ saveState(options, state);
470
+ }
471
+ res.setHeader("set-cookie", [
472
+ `${DEVICE_COOKIE}=; Path=/mobile-access/auth/renew; Max-Age=0`,
473
+ `${SESSION_COOKIE}=; Path=/; Max-Age=0`,
474
+ ]);
475
+ sendJson(res, 200, { ok: true });
476
+ return true;
477
+ }
44
478
  if (pathname === "/api/mobile-access/settings") {
45
- const method = httpMethod(req);
46
479
  const state = loadState(options);
47
480
  if (method === "GET" || method === "HEAD") {
48
481
  sendJson(res, 200, {
@@ -70,45 +503,28 @@ export async function handleMobileAccessHttp(req, res, pathname, options) {
70
503
  return true;
71
504
  }
72
505
  }
73
- if (pathname === "/api/mobile-access/control") {
74
- const method = httpMethod(req);
506
+ const lanControl = pathname === "/api/mobile-access/control" ||
507
+ pathname === "/api/mobile-access/lan/control";
508
+ if (lanControl) {
75
509
  const state = loadState(options);
76
510
  if (method === "GET" || method === "HEAD") {
77
- const origin = state.origin || requestOrigin(req);
511
+ const origin = state.origin || requestLanOrigin(req);
512
+ if (state.running && state.csrf)
513
+ setCsrfCookie(res, state.csrf);
78
514
  sendJson(res, 200, {
79
- running: state.running,
515
+ ...lanPayload(state),
80
516
  ...(state.running && origin ? { origin } : {}),
81
517
  });
82
518
  return true;
83
519
  }
84
520
  if (method === "POST" || method === "PUT") {
85
521
  const body = await parseJsonBody(req);
86
- const next = { ...state };
87
- if (typeof body.running === "boolean") {
88
- next.running = body.running;
89
- }
90
- else {
91
- next.running = !state.running;
92
- }
93
- if (!next.csrf)
94
- next.csrf = mintToken();
95
- if (next.running) {
96
- next.origin = requestOrigin(req);
97
- }
98
- else {
99
- next.origin = "";
100
- }
101
- saveState(options, next);
102
- setCsrfCookie(res, next.csrf);
103
- sendJson(res, 200, {
104
- running: next.running,
105
- ...(next.running && next.origin ? { origin: next.origin } : {}),
106
- });
522
+ const running = typeof body.running === "boolean" ? body.running : !state.running;
523
+ await setRunning(options, req, res, running);
107
524
  return true;
108
525
  }
109
526
  }
110
527
  if (pathname === "/api/mobile-access/pairing/open") {
111
- const method = httpMethod(req);
112
528
  if (isMutatingMethod(method))
113
529
  await parseJsonBody(req);
114
530
  const state = loadState(options);
@@ -116,7 +532,8 @@ export async function handleMobileAccessHttp(req, res, pathname, options) {
116
532
  sendJson(res, 200, { ok: false, error: "mobile access is not running" });
117
533
  return true;
118
534
  }
119
- const next = { ...state, appKey: mintToken() };
535
+ const opened = openLanPairing(state, req);
536
+ const next = opened.next;
120
537
  if (!next.csrf)
121
538
  next.csrf = mintToken();
122
539
  saveState(options, next);
@@ -124,9 +541,253 @@ export async function handleMobileAccessHttp(req, res, pathname, options) {
124
541
  sendJson(res, 200, { ok: true, appKey: next.appKey });
125
542
  return true;
126
543
  }
544
+ if (pathname === "/api/mobile-access/lan/pairing/open") {
545
+ if (!isMutatingMethod(method)) {
546
+ sendJson(res, 405, { error: "method not allowed" });
547
+ return true;
548
+ }
549
+ try {
550
+ const body = await parseJsonBody(req);
551
+ const state = loadState(options);
552
+ if (!state.running) {
553
+ sendJson(res, 409, { error: "mobile access is not running" });
554
+ return true;
555
+ }
556
+ const ttlMs = typeof body.ttlMs === "number" ? body.ttlMs : undefined;
557
+ const opened = openLanPairing(state, req, ttlMs);
558
+ const next = opened.next;
559
+ if (!next.csrf)
560
+ next.csrf = mintToken();
561
+ saveState(options, next);
562
+ setCsrfCookie(res, next.csrf);
563
+ sendJson(res, 200, {
564
+ token: opened.token,
565
+ expiresAt: opened.expiresAt,
566
+ appKey: opened.appKey,
567
+ pairUrl: opened.pairUrl,
568
+ appPairUrl: opened.appPairUrl,
569
+ qrSvg: opened.qrSvg,
570
+ });
571
+ return true;
572
+ }
573
+ catch (err) {
574
+ sendJson(res, 500, {
575
+ error: err instanceof Error ? err.message : "pairing_open_failed",
576
+ });
577
+ return true;
578
+ }
579
+ }
580
+ if (pathname === "/api/mobile-access/lan/devices") {
581
+ const state = loadState(options);
582
+ sendJson(res, 200, {
583
+ devices: state.devices.map(publicDevice),
584
+ });
585
+ return true;
586
+ }
587
+ if (pathname === "/api/mobile-access/lan/devices/revoke") {
588
+ const body = await parseJsonBody(req);
589
+ const deviceId = typeof body.deviceId === "string" ? body.deviceId.trim() : "";
590
+ if (!deviceId) {
591
+ sendJson(res, 400, { error: "deviceId required" });
592
+ return true;
593
+ }
594
+ const state = loadState(options);
595
+ const next = {
596
+ ...state,
597
+ devices: state.devices.map((d) => d.id === deviceId ? { ...d, revokedAt: Date.now() } : d),
598
+ };
599
+ if (!next.devices.some((d) => d.id === deviceId)) {
600
+ sendJson(res, 404, { error: "not_found" });
601
+ return true;
602
+ }
603
+ saveState(options, pruneMobileAuth(next));
604
+ sendJson(res, 200, { revoked: true });
605
+ return true;
606
+ }
607
+ if (pathname === "/api/mobile-access/lan/devices/reset") {
608
+ const body = await parseJsonBody(req);
609
+ if (body.confirm !== true) {
610
+ sendJson(res, 400, { error: "confirm required" });
611
+ return true;
612
+ }
613
+ const state = loadState(options);
614
+ saveState(options, { ...state, devices: [], sessions: [] });
615
+ sendJson(res, 200, { reset: true });
616
+ return true;
617
+ }
618
+ if (pathname === "/api/mobile-access/remote/control") {
619
+ const state = loadState(options);
620
+ if (method === "GET" || method === "HEAD") {
621
+ const { runtime } = await prepareRemoteRuntime(options, state);
622
+ sendJson(res, 200, runtime.buildRemotePayload());
623
+ return true;
624
+ }
625
+ if (method === "POST") {
626
+ const body = await parseJsonBody(req);
627
+ const wantRunning = body.running === true;
628
+ const { runtime, state: withId } = await prepareRemoteRuntime(options, state);
629
+ if (wantRunning && withId.remoteProvider === "cpolar") {
630
+ const component = runtime.cpolarComponent.status();
631
+ if (!component.supported) {
632
+ sendJson(res, 400, {
633
+ error: "cpolar_component_unsupported",
634
+ component,
635
+ });
636
+ return true;
637
+ }
638
+ if (!component.installed) {
639
+ sendJson(res, 503, {
640
+ error: "cpolar_component_missing",
641
+ state: "unavailable",
642
+ component,
643
+ });
644
+ return true;
645
+ }
646
+ if (!component.configured) {
647
+ sendJson(res, 503, {
648
+ error: "cpolar_not_configured",
649
+ state: "unavailable",
650
+ component,
651
+ });
652
+ return true;
653
+ }
654
+ }
655
+ const payload = await runtime.setRemoteEnabled(wantRunning);
656
+ const next = { ...withId, remoteEnabled: wantRunning };
657
+ saveState(options, next);
658
+ sendJson(res, 200, payload);
659
+ return true;
660
+ }
661
+ }
662
+ if (pathname === "/api/mobile-access/remote/provider") {
663
+ const body = await parseJsonBody(req);
664
+ const provider = body.provider === "cpolar" ? "cpolar" : "tailscale";
665
+ const state = loadState(options);
666
+ const { runtime, state: withId } = await prepareRemoteRuntime(options, state);
667
+ await runtime.selectProvider(provider);
668
+ const next = { ...withId, remoteProvider: provider };
669
+ saveState(options, next);
670
+ sendJson(res, 200, runtime.buildRemotePayload());
671
+ return true;
672
+ }
673
+ if (pathname === "/api/mobile-access/remote/reconnect" ||
674
+ pathname === "/api/mobile-access/remote/pairing/open") {
675
+ const state = loadState(options);
676
+ const { runtime } = await prepareRemoteRuntime(options, state);
677
+ const payload = await runtime.reconnect();
678
+ sendJson(res, 200, { ...payload, reopened: true });
679
+ return true;
680
+ }
681
+ if (pathname === "/api/mobile-access/remote/devices" ||
682
+ pathname === "/api/mobile-access/remote/devices/revoke" ||
683
+ pathname === "/api/mobile-access/remote/reset" ||
684
+ pathname === "/api/mobile-access/remote/cpolar/component/install" ||
685
+ pathname === "/api/mobile-access/remote/cpolar/configure" ||
686
+ pathname === "/api/mobile-access/remote/cpolar/component/purge") {
687
+ const state = loadState(options);
688
+ const { runtime } = await prepareRemoteRuntime(options, state);
689
+ if (pathname.endsWith("/devices")) {
690
+ sendJson(res, 200, {
691
+ devices: state.devices.map(publicDevice),
692
+ });
693
+ return true;
694
+ }
695
+ if (pathname.endsWith("/devices/revoke")) {
696
+ const body = await parseJsonBody(req);
697
+ const deviceId = typeof body.deviceId === "string" ? body.deviceId.trim() : "";
698
+ if (!deviceId) {
699
+ sendJson(res, 400, { error: "deviceId required" });
700
+ return true;
701
+ }
702
+ const next = {
703
+ ...state,
704
+ devices: state.devices.map((d) => d.id === deviceId ? { ...d, revokedAt: Date.now() } : d),
705
+ };
706
+ if (!next.devices.some((d) => d.id === deviceId)) {
707
+ sendJson(res, 404, { error: "not_found" });
708
+ return true;
709
+ }
710
+ saveState(options, pruneMobileAuth(next));
711
+ sendJson(res, 200, { revoked: true });
712
+ return true;
713
+ }
714
+ if (pathname.endsWith("/reset")) {
715
+ const payload = await runtime.resetRemote();
716
+ saveState(options, { ...state, remoteEnabled: false });
717
+ sendJson(res, 200, { ...payload, reset: true });
718
+ return true;
719
+ }
720
+ if (pathname.endsWith("/component/install")) {
721
+ if (!isMutatingMethod(method)) {
722
+ sendJson(res, 405, { error: "method not allowed" });
723
+ return true;
724
+ }
725
+ try {
726
+ await runtime.cpolarComponent.install();
727
+ sendJson(res, 200, {
728
+ ok: true,
729
+ component: runtime.cpolarComponent.status(),
730
+ });
731
+ }
732
+ catch (err) {
733
+ const mapped = componentErrorResponse(err);
734
+ sendJson(res, mapped.status, {
735
+ ...mapped.body,
736
+ component: runtime.cpolarComponent.status(),
737
+ });
738
+ }
739
+ return true;
740
+ }
741
+ if (pathname.endsWith("/configure")) {
742
+ if (!isMutatingMethod(method)) {
743
+ sendJson(res, 405, { error: "method not allowed" });
744
+ return true;
745
+ }
746
+ const body = await parseJsonBody(req);
747
+ const authtoken = typeof body.authtoken === "string" ? body.authtoken : "";
748
+ if (!authtoken.trim()) {
749
+ sendJson(res, 400, { error: "authtoken required" });
750
+ return true;
751
+ }
752
+ try {
753
+ await runtime.cpolarComponent.configure(authtoken);
754
+ sendJson(res, 200, {
755
+ ok: true,
756
+ component: runtime.cpolarComponent.status(),
757
+ });
758
+ }
759
+ catch (err) {
760
+ const mapped = componentErrorResponse(err);
761
+ sendJson(res, mapped.status, {
762
+ ...mapped.body,
763
+ component: runtime.cpolarComponent.status(),
764
+ });
765
+ }
766
+ return true;
767
+ }
768
+ if (pathname.endsWith("/component/purge")) {
769
+ if (!isMutatingMethod(method)) {
770
+ sendJson(res, 405, { error: "method not allowed" });
771
+ return true;
772
+ }
773
+ try {
774
+ await runtime.cpolarComponent.purge();
775
+ sendJson(res, 200, {
776
+ ok: true,
777
+ component: runtime.cpolarComponent.status(),
778
+ });
779
+ }
780
+ catch (err) {
781
+ const mapped = componentErrorResponse(err);
782
+ sendJson(res, mapped.status, mapped.body);
783
+ }
784
+ return true;
785
+ }
786
+ }
127
787
  if (pathname === "/mobile-access/custom.css") {
128
788
  const state = loadState(options);
129
- const body = state.customCss || "/* dsh-mobile custom css */\n";
789
+ const custom = state.customCss || "/* dsh-mobile custom css */\n";
790
+ const body = `${XRK_MOBILE_SHELL_CSS}\n${custom}`;
130
791
  res.writeHead(200, {
131
792
  "content-type": "text/css; charset=utf-8",
132
793
  "cache-control": "no-cache",
@@ -146,6 +807,10 @@ export async function handleMobileAccessHttp(req, res, pathname, options) {
146
807
  res.end(body);
147
808
  return true;
148
809
  }
810
+ if (pathname === "/mobile-access/extensions/manifest") {
811
+ sendJson(res, 200, { extensions: [] });
812
+ return true;
813
+ }
149
814
  return false;
150
815
  }
151
816
  export function isMobileAccessPath(pathname) {