@ait-co/devtools 0.1.143 → 0.2.0

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 (223) hide show
  1. package/README.en.md +65 -163
  2. package/README.md +65 -192
  3. package/dist/in-app/auto.d.ts +1 -138
  4. package/dist/in-app/auto.js +28 -1102
  5. package/dist/in-app/auto.js.map +1 -1
  6. package/dist/in-app/index.d.ts +38 -547
  7. package/dist/in-app/index.d.ts.map +1 -1
  8. package/dist/in-app/index.js +62 -939
  9. package/dist/in-app/index.js.map +1 -1
  10. package/dist/mcp/cli.d.ts +1 -54
  11. package/dist/mcp/cli.js +33 -9720
  12. package/dist/mcp/cli.js.map +1 -1
  13. package/dist/mcp/server.d.ts +1 -88
  14. package/dist/mcp/server.js +36 -1076
  15. package/dist/mcp/server.js.map +1 -1
  16. package/dist/mock/index.d.ts +19 -20
  17. package/dist/mock/index.d.ts.map +1 -1
  18. package/dist/mock/index.js.map +1 -1
  19. package/dist/optional-peers-CDEFhlhJ.cjs +131 -0
  20. package/dist/optional-peers-CDEFhlhJ.cjs.map +1 -0
  21. package/dist/optional-peers-FdVbUJst.js +96 -0
  22. package/dist/optional-peers-FdVbUJst.js.map +1 -0
  23. package/dist/panel/index.js +1 -103
  24. package/dist/panel/index.js.map +1 -1
  25. package/dist/relay-url-store-CPZAn-T5.js +107 -0
  26. package/dist/relay-url-store-CPZAn-T5.js.map +1 -0
  27. package/dist/relay-url-store-DLjlvMSA.cjs +108 -0
  28. package/dist/relay-url-store-DLjlvMSA.cjs.map +1 -0
  29. package/dist/stubs/bin-devtools-mcp.js +58 -0
  30. package/dist/stubs/bin-devtools-mcp.js.map +1 -0
  31. package/dist/stubs/bin-devtools-test.d.ts +2 -0
  32. package/dist/stubs/bin-devtools-test.js +55 -0
  33. package/dist/stubs/bin-devtools-test.js.map +1 -0
  34. package/dist/test-runner/config.d.ts +1 -231
  35. package/dist/test-runner/config.js +41 -45
  36. package/dist/test-runner/config.js.map +1 -1
  37. package/dist/{tunnel-BVSMXctM.cjs → tunnel-BKZkOyQp.cjs} +27 -75
  38. package/dist/tunnel-BKZkOyQp.cjs.map +1 -0
  39. package/dist/{tunnel-D7xkimBu.js → tunnel-CqSCIrdU.js} +27 -75
  40. package/dist/tunnel-CqSCIrdU.js.map +1 -0
  41. package/dist/unplugin/index.cjs +17 -30
  42. package/dist/unplugin/index.cjs.map +1 -1
  43. package/dist/unplugin/index.d.cts +34 -5
  44. package/dist/unplugin/index.d.cts.map +1 -1
  45. package/dist/unplugin/index.d.ts +35 -6
  46. package/dist/unplugin/index.d.ts.map +1 -1
  47. package/dist/unplugin/index.js +17 -30
  48. package/dist/unplugin/index.js.map +1 -1
  49. package/dist/unplugin/tunnel.cjs +61 -74
  50. package/dist/unplugin/tunnel.cjs.map +1 -1
  51. package/dist/unplugin/tunnel.d.cts +22 -16
  52. package/dist/unplugin/tunnel.d.cts.map +1 -1
  53. package/dist/unplugin/tunnel.d.ts +22 -16
  54. package/dist/unplugin/tunnel.d.ts.map +1 -1
  55. package/dist/unplugin/tunnel.js +61 -74
  56. package/dist/unplugin/tunnel.js.map +1 -1
  57. package/package.json +17 -22
  58. package/dist/attach-orchestrator-0F0m_UqQ.js +0 -1845
  59. package/dist/attach-orchestrator-0F0m_UqQ.js.map +0 -1
  60. package/dist/attach-orchestrator-D65KxFy_.js +0 -1831
  61. package/dist/attach-orchestrator-D65KxFy_.js.map +0 -1
  62. package/dist/attach-orchestrator-DL3NQ9ca.js +0 -1846
  63. package/dist/attach-orchestrator-DL3NQ9ca.js.map +0 -1
  64. package/dist/bundle-C796JIwG.d.ts +0 -159
  65. package/dist/bundle-C796JIwG.d.ts.map +0 -1
  66. package/dist/capture-DsP525OZ.d.ts +0 -58
  67. package/dist/capture-DsP525OZ.d.ts.map +0 -1
  68. package/dist/cdp-connection-rP1WdnH5.d.ts +0 -287
  69. package/dist/cdp-connection-rP1WdnH5.d.ts.map +0 -1
  70. package/dist/cell-BaLvusOl.js +0 -68
  71. package/dist/cell-BaLvusOl.js.map +0 -1
  72. package/dist/cell-CBUS3-nT.js +0 -274
  73. package/dist/cell-CBUS3-nT.js.map +0 -1
  74. package/dist/cell-EBKKpAAT.js +0 -307
  75. package/dist/cell-EBKKpAAT.js.map +0 -1
  76. package/dist/chii-relay-BZ3HqWL5.js +0 -304
  77. package/dist/chii-relay-BZ3HqWL5.js.map +0 -1
  78. package/dist/chii-relay-D7eK2acz.cjs +0 -304
  79. package/dist/chii-relay-D7eK2acz.cjs.map +0 -1
  80. package/dist/debug-server-B3ABDrRI.js +0 -456
  81. package/dist/debug-server-B3ABDrRI.js.map +0 -1
  82. package/dist/debug-server-BWhwrVXa.js +0 -1158
  83. package/dist/debug-server-BWhwrVXa.js.map +0 -1
  84. package/dist/debug-server-CfQNxxGW.js +0 -600
  85. package/dist/debug-server-CfQNxxGW.js.map +0 -1
  86. package/dist/deeplink-B5-Hxu0Q.js +0 -62
  87. package/dist/deeplink-B5-Hxu0Q.js.map +0 -1
  88. package/dist/deeplink-BpO9qc-D.js +0 -62
  89. package/dist/deeplink-BpO9qc-D.js.map +0 -1
  90. package/dist/deeplink-BzdbA1gV.cjs +0 -62
  91. package/dist/deeplink-BzdbA1gV.cjs.map +0 -1
  92. package/dist/deeplink-DCScMYcp.cjs +0 -62
  93. package/dist/deeplink-DCScMYcp.cjs.map +0 -1
  94. package/dist/devtools-opener-3Drge_RJ.js +0 -75
  95. package/dist/devtools-opener-3Drge_RJ.js.map +0 -1
  96. package/dist/devtools-opener-B8nxrxqu.js +0 -71
  97. package/dist/devtools-opener-B8nxrxqu.js.map +0 -1
  98. package/dist/devtools-opener-BDY0w3_0.cjs +0 -68
  99. package/dist/devtools-opener-BDY0w3_0.cjs.map +0 -1
  100. package/dist/devtools-opener-BTl5A6Cd.js +0 -71
  101. package/dist/devtools-opener-BTl5A6Cd.js.map +0 -1
  102. package/dist/devtools-opener-CJpEsXXQ.js +0 -76
  103. package/dist/devtools-opener-CJpEsXXQ.js.map +0 -1
  104. package/dist/devtools-opener-CxtryS8c.js +0 -75
  105. package/dist/devtools-opener-CxtryS8c.js.map +0 -1
  106. package/dist/devtools-opener-iv1OwfJN.cjs +0 -68
  107. package/dist/devtools-opener-iv1OwfJN.cjs.map +0 -1
  108. package/dist/in-app/auto.d.ts.map +0 -1
  109. package/dist/mcp/cli.d.ts.map +0 -1
  110. package/dist/mcp/server.d.ts.map +0 -1
  111. package/dist/pool-DcaaOwUq.d.ts +0 -14761
  112. package/dist/pool-DcaaOwUq.d.ts.map +0 -1
  113. package/dist/qr-http-server--gl2-WKc.cjs +0 -1644
  114. package/dist/qr-http-server--gl2-WKc.cjs.map +0 -1
  115. package/dist/qr-http-server-Bb7lMeqi.js +0 -1644
  116. package/dist/qr-http-server-Bb7lMeqi.js.map +0 -1
  117. package/dist/qr-http-server-C_lqOrgc.js +0 -1644
  118. package/dist/qr-http-server-C_lqOrgc.js.map +0 -1
  119. package/dist/qr-http-server-CopuMbub.js +0 -1644
  120. package/dist/qr-http-server-CopuMbub.js.map +0 -1
  121. package/dist/qr-http-server-D-Off6K1.cjs +0 -1644
  122. package/dist/qr-http-server-D-Off6K1.cjs.map +0 -1
  123. package/dist/qr-http-server-DrbIVDjO.js +0 -1645
  124. package/dist/qr-http-server-DrbIVDjO.js.map +0 -1
  125. package/dist/qr-http-server-n1twN18z.js +0 -1644
  126. package/dist/qr-http-server-n1twN18z.js.map +0 -1
  127. package/dist/relay-factory-N9QobQxG.js +0 -206
  128. package/dist/relay-factory-N9QobQxG.js.map +0 -1
  129. package/dist/relay-secret-store-BPhN1upr.js +0 -240
  130. package/dist/relay-secret-store-BPhN1upr.js.map +0 -1
  131. package/dist/relay-secret-store-Bmyleu0A.js +0 -154
  132. package/dist/relay-secret-store-Bmyleu0A.js.map +0 -1
  133. package/dist/relay-secret-store-CQenfcSL.js +0 -154
  134. package/dist/relay-secret-store-CQenfcSL.js.map +0 -1
  135. package/dist/relay-secret-store-DKxs7zwq.js +0 -153
  136. package/dist/relay-secret-store-DKxs7zwq.js.map +0 -1
  137. package/dist/relay-secret-store-DWKdV-eY.cjs +0 -241
  138. package/dist/relay-secret-store-DWKdV-eY.cjs.map +0 -1
  139. package/dist/relay-secret-store-WJ8EGkIl.js +0 -153
  140. package/dist/relay-secret-store-WJ8EGkIl.js.map +0 -1
  141. package/dist/relay-url-store-1FGuSYAn.cjs +0 -115
  142. package/dist/relay-url-store-1FGuSYAn.cjs.map +0 -1
  143. package/dist/relay-url-store-BR2XodiO.js +0 -123
  144. package/dist/relay-url-store-BR2XodiO.js.map +0 -1
  145. package/dist/relay-url-store-Bskcyeg8.js +0 -114
  146. package/dist/relay-url-store-Bskcyeg8.js.map +0 -1
  147. package/dist/relay-url-store-CH63fVCm.js +0 -122
  148. package/dist/relay-url-store-CH63fVCm.js.map +0 -1
  149. package/dist/relay-url-store-DaY1QPes.js +0 -123
  150. package/dist/relay-url-store-DaY1QPes.js.map +0 -1
  151. package/dist/relay-url-store-xmUuTjXA.js +0 -122
  152. package/dist/relay-url-store-xmUuTjXA.js.map +0 -1
  153. package/dist/relay-worker-B5HKkGUY.js +0 -832
  154. package/dist/relay-worker-B5HKkGUY.js.map +0 -1
  155. package/dist/relay-worker-YdlpZQl9.d.ts +0 -214
  156. package/dist/relay-worker-YdlpZQl9.d.ts.map +0 -1
  157. package/dist/rolldown-runtime-DGkTqVfb.js +0 -15
  158. package/dist/rolldown-runtime-DUslC3ob.js +0 -14
  159. package/dist/runtime-kn9DxOeg.d.ts +0 -249
  160. package/dist/runtime-kn9DxOeg.d.ts.map +0 -1
  161. package/dist/test-runner/bin.js +0 -2584
  162. package/dist/test-runner/bin.js.map +0 -1
  163. package/dist/test-runner/bridge-stub.d.ts +0 -125
  164. package/dist/test-runner/bridge-stub.d.ts.map +0 -1
  165. package/dist/test-runner/bridge-stub.js +0 -92
  166. package/dist/test-runner/bridge-stub.js.map +0 -1
  167. package/dist/test-runner/bundle.d.ts +0 -2
  168. package/dist/test-runner/bundle.js +0 -439
  169. package/dist/test-runner/bundle.js.map +0 -1
  170. package/dist/test-runner/capture.d.ts +0 -2
  171. package/dist/test-runner/capture.js +0 -44
  172. package/dist/test-runner/capture.js.map +0 -1
  173. package/dist/test-runner/config.d.ts.map +0 -1
  174. package/dist/test-runner/method-pace.d.ts +0 -82
  175. package/dist/test-runner/method-pace.d.ts.map +0 -1
  176. package/dist/test-runner/method-pace.js +0 -120
  177. package/dist/test-runner/method-pace.js.map +0 -1
  178. package/dist/test-runner/pool.d.ts +0 -2
  179. package/dist/test-runner/pool.js +0 -136
  180. package/dist/test-runner/pool.js.map +0 -1
  181. package/dist/test-runner/relay-factory.d.ts +0 -11245
  182. package/dist/test-runner/relay-factory.d.ts.map +0 -1
  183. package/dist/test-runner/relay-factory.js +0 -206
  184. package/dist/test-runner/relay-factory.js.map +0 -1
  185. package/dist/test-runner/relay-worker.d.ts +0 -2
  186. package/dist/test-runner/relay-worker.js +0 -2
  187. package/dist/test-runner/report.d.ts +0 -163
  188. package/dist/test-runner/report.d.ts.map +0 -1
  189. package/dist/test-runner/report.js +0 -198
  190. package/dist/test-runner/report.js.map +0 -1
  191. package/dist/test-runner/rpc.d.ts +0 -56
  192. package/dist/test-runner/rpc.d.ts.map +0 -1
  193. package/dist/test-runner/rpc.js +0 -98
  194. package/dist/test-runner/rpc.js.map +0 -1
  195. package/dist/test-runner/runtime.d.ts +0 -2
  196. package/dist/test-runner/runtime.js +0 -659
  197. package/dist/test-runner/runtime.js.map +0 -1
  198. package/dist/test-runner/task-graph.d.ts +0 -38
  199. package/dist/test-runner/task-graph.d.ts.map +0 -1
  200. package/dist/test-runner/task-graph.js +0 -182
  201. package/dist/test-runner/task-graph.js.map +0 -1
  202. package/dist/throttle-DKKzX1qC.js +0 -59
  203. package/dist/throttle-DKKzX1qC.js.map +0 -1
  204. package/dist/totp-95OAa20j.js +0 -64
  205. package/dist/totp-95OAa20j.js.map +0 -1
  206. package/dist/totp-BjtoQNfu.cjs +0 -64
  207. package/dist/totp-BjtoQNfu.cjs.map +0 -1
  208. package/dist/totp-CZLLKfOC.js +0 -200
  209. package/dist/totp-CZLLKfOC.js.map +0 -1
  210. package/dist/totp-DAxys-r0.js +0 -199
  211. package/dist/totp-DAxys-r0.js.map +0 -1
  212. package/dist/totp-DIbrZtI7.js +0 -189
  213. package/dist/totp-DIbrZtI7.js.map +0 -1
  214. package/dist/totp-Df252ZdA.cjs +0 -192
  215. package/dist/totp-Df252ZdA.cjs.map +0 -1
  216. package/dist/totp-DfekTBk3.js +0 -211
  217. package/dist/totp-DfekTBk3.js.map +0 -1
  218. package/dist/totp-Dwft0Kz7.js +0 -3
  219. package/dist/totp-WY6l0ysP.js +0 -190
  220. package/dist/totp-WY6l0ysP.js.map +0 -1
  221. package/dist/tunnel-BVSMXctM.cjs.map +0 -1
  222. package/dist/tunnel-D7xkimBu.js.map +0 -1
  223. /package/dist/{test-runner/bin.d.ts → stubs/bin-devtools-mcp.d.ts} +0 -0
@@ -161,31 +161,37 @@ interface StartTunnelDashboardOptions {
161
161
  name?: string;
162
162
  }
163
163
  /**
164
- * Env-2 UX parity with env 3/4 (issue #408): when CDP wiring is on and a GUI is
164
+ * Env-2 UX parity with env 3 (issue #408): when CDP wiring is on and a GUI is
165
165
  * available, start the SAME `127.0.0.1` HTML dashboard (QR image + connect steps
166
- * + FAQ) that the MCP `start_attach` path serves, and auto-open it in the
166
+ * + FAQ) the debug daemon's `start_attach` path serves, and auto-open it in the
167
167
  * browser. headless / opt-out falls back to the terminal ASCII QR (printed
168
168
  * separately by {@link printTunnelBanner}).
169
169
  *
170
- * Every part the install-graph invariant depends on (`qrcode`, the MCP HTTP
171
- * server, the opener) is reached only through dynamic `import()` here, inside
172
- * the already-lazy `tunnel.js` chunk nothing is added to the common build
173
- * graph or the MCP-only install graph.
170
+ * DELEGATED (issue #817): the implementation now lives in `@ait-co/debugger`'s
171
+ * `/dev-bridge` subpath the one cross-repo code delegation of the package
172
+ * split. The dashboard needs the daemon's QR HTTP server, deep-link builder and
173
+ * TOTP minting, all of which moved into that package; keeping a second copy here
174
+ * would fork them. `@ait-co/debugger` is an OPTIONAL peer, so a consumer who
175
+ * never asks for env-2 CDP installs nothing extra.
174
176
  *
175
- * TOTP encapsulation: the dashboard's `getDashboardState` closure mints a FRESH
176
- * TOTP `at=` code on every call via `generateTotp(secret, Date.now())` and folds
177
- * it into a fresh `buildLauncherAttachUrl(...)`. Because the QR is re-rendered on
178
- * each SSE push / page reload from this closure, the code a phone scans is always
179
- * within its 30 s window no stale code is baked into static HTML.
177
+ * Why this is not a separate plugin: the relay `wss://` URL must exist BEFORE
178
+ * the QR banner is printed (the launcher QR carries `&relay=`), so the relay and
179
+ * the dashboard are order-dependent and stay one composed call in the dev loop.
180
+ *
181
+ * Degradation: when `@ait-co/debugger` is not installed the import fails and we
182
+ * return `undefined` — exactly the same "no dashboard" outcome as a closed GUI
183
+ * gate, with the terminal ASCII QR standing alone. We do NOT fall back to a
184
+ * local copy of the daemon code. The caller (`./index.ts`) prints the install
185
+ * hint once when CDP was requested without the package.
180
186
  *
181
187
  * SECRET-HANDLING: the tunnel host, relay wssUrl, TOTP code, and `.ait_relay`
182
- * value/path are NEVER written to stdout/stderr/logs here. They live only inside
183
- * the attach URL (HTML body + `/qr.png` query, per qr-http-server's invariant).
184
- * The only thing opened/logged is `http://127.0.0.1:<port>` (local, safe).
188
+ * value/path are NEVER written to stdout/stderr/logs — neither here nor in the
189
+ * delegate. The only thing opened/logged is `http://127.0.0.1:<port>` (local).
185
190
  *
186
191
  * @returns the dashboard handle when it started (caller wires `close()` into the
187
- * tunnel cleanup), or `undefined` when skipped (no relay, `qr:false`, headless,
188
- * opt-out, or a start failure) — in which case ASCII QR fallback stands alone.
192
+ * tunnel cleanup), or `undefined` when skipped (package absent, no relay,
193
+ * `qr:false`, headless, opt-out, or a start failure) — in which case the ASCII
194
+ * QR fallback stands alone.
189
195
  */
190
196
  declare function startTunnelDashboard(opts: StartTunnelDashboardOptions): Promise<TunnelDashboard | undefined>;
191
197
  interface QuickTunnel {
@@ -1 +1 @@
1
- {"version":3,"file":"tunnel.d.cts","names":[],"sources":["../../src/unplugin/tunnel.ts"],"mappings":";;AAwBA;;;;;AAKA;;;;;;;;;;iBALgB,qBAAA,CAAsB,IAAA;AAAA,UAKrB,wBAAA;EAuCJ;EArCX,EAAA;EA6Ce;EA3Cf,GAAA,IAAO,GAAA;;;;;;;EAOP,WAAA;EAoEW;;AAiCb;;;EA/FE,IAAA;EAgGA;;;;;AAiCF;EA1HE,WAAA;;;;;;;;EAQA,iBAAA;EAqLe;;;;;;EA9Kf,WAAA;AAAA;;AAqLF;;UA7KiB,4BAAA;EA6K2B;;;;EAxK1C,WAAA;EAqLA;;;;EAhLA,IAAA;EAoNoB;;;;;;EA7MpB,WAAA;EA+MQ;;;;;;;EAvMR,iBAAA;EAwS0B;;;;AAiB5B;;EAlTE,WAAA;AAAA;;AAoUF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAnSgB,qBAAA,CACd,SAAA,UACA,WAAA,YAAuB,4BAAA;;;;;;;iBAgCH,iBAAA,CACpB,GAAA,UACA,IAAA,GAAM,wBAAA,GACL,OAAA;;UAgEc,eAAA;;EAEf,GAAA;;EAEA,KAAA,QAAa,OAAA;AAAA;AAAA,UAGE,2BAAA;;EAEf,SAAA;;EAEA,WAAA;;EAEA,EAAA;;;;;EAKA,UAAA;;EAEA,GAAA,IAAO,GAAA;;;;;;EAMP,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BoB,oBAAA,CACpB,IAAA,EAAM,2BAAA,GACL,OAAA,CAAQ,eAAA;AAAA,UAiGM,WAAA;;EAEf,GAAA;;EAEA,IAAA;AAAA;;;;;;;;;;;iBAac,yBAAA,CAA0B,IAAA;;;;;;;iBAkBpB,gBAAA,CAAiB,IAAA,WAAe,OAAA,CAAQ,WAAA"}
1
+ {"version":3,"file":"tunnel.d.cts","names":[],"sources":["../../src/unplugin/tunnel.ts"],"mappings":";;AAyBA;;;;;AAKA;;;;;;;;;;iBALgB,qBAAA,CAAsB,IAAA;AAAA,UAKrB,wBAAA;EAuCJ;EArCX,EAAA;EA6Ce;EA3Cf,GAAA,IAAO,GAAA;;;;;;;EAOP,WAAA;EAoEW;;AAiCb;;;EA/FE,IAAA;EAgGA;;;;;AAiCF;EA1HE,WAAA;;;;;;;;EAQA,iBAAA;EAiKe;;;;;;EA1Jf,WAAA;AAAA;;AAiKF;;UAzJiB,4BAAA;EAyJ2B;;;;EApJ1C,WAAA;EAiKA;;;;EA5JA,IAAA;EAsMoB;;;;;;EA/LpB,WAAA;EAiMQ;;;;;;;EAzLR,iBAAA;EA6M0B;;;;AAiB5B;;EAvNE,WAAA;AAAA;;AAyOF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAxMgB,qBAAA,CACd,SAAA,UACA,WAAA,YAAuB,4BAAA;;;;;;;iBAgCH,iBAAA,CACpB,GAAA,UACA,IAAA,GAAM,wBAAA,GACL,OAAA;;UA4Cc,eAAA;;EAEf,GAAA;;EAEA,KAAA,QAAa,OAAA;AAAA;AAAA,UAGE,2BAAA;;EAEf,SAAA;;EAEA,WAAA;;EAEA,EAAA;;;;;EAKA,UAAA;;EAEA,GAAA,IAAO,GAAA;;;;;;EAMP,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCoB,oBAAA,CACpB,IAAA,EAAM,2BAAA,GACL,OAAA,CAAQ,eAAA;AAAA,UAoBM,WAAA;;EAEf,GAAA;;EAEA,IAAA;AAAA;;;;;;;;;;;iBAac,yBAAA,CAA0B,IAAA;;;;;;;iBAkBpB,gBAAA,CAAiB,IAAA,WAAe,OAAA,CAAQ,WAAA"}
@@ -161,31 +161,37 @@ interface StartTunnelDashboardOptions {
161
161
  name?: string;
162
162
  }
163
163
  /**
164
- * Env-2 UX parity with env 3/4 (issue #408): when CDP wiring is on and a GUI is
164
+ * Env-2 UX parity with env 3 (issue #408): when CDP wiring is on and a GUI is
165
165
  * available, start the SAME `127.0.0.1` HTML dashboard (QR image + connect steps
166
- * + FAQ) that the MCP `start_attach` path serves, and auto-open it in the
166
+ * + FAQ) the debug daemon's `start_attach` path serves, and auto-open it in the
167
167
  * browser. headless / opt-out falls back to the terminal ASCII QR (printed
168
168
  * separately by {@link printTunnelBanner}).
169
169
  *
170
- * Every part the install-graph invariant depends on (`qrcode`, the MCP HTTP
171
- * server, the opener) is reached only through dynamic `import()` here, inside
172
- * the already-lazy `tunnel.js` chunk nothing is added to the common build
173
- * graph or the MCP-only install graph.
170
+ * DELEGATED (issue #817): the implementation now lives in `@ait-co/debugger`'s
171
+ * `/dev-bridge` subpath the one cross-repo code delegation of the package
172
+ * split. The dashboard needs the daemon's QR HTTP server, deep-link builder and
173
+ * TOTP minting, all of which moved into that package; keeping a second copy here
174
+ * would fork them. `@ait-co/debugger` is an OPTIONAL peer, so a consumer who
175
+ * never asks for env-2 CDP installs nothing extra.
174
176
  *
175
- * TOTP encapsulation: the dashboard's `getDashboardState` closure mints a FRESH
176
- * TOTP `at=` code on every call via `generateTotp(secret, Date.now())` and folds
177
- * it into a fresh `buildLauncherAttachUrl(...)`. Because the QR is re-rendered on
178
- * each SSE push / page reload from this closure, the code a phone scans is always
179
- * within its 30 s window no stale code is baked into static HTML.
177
+ * Why this is not a separate plugin: the relay `wss://` URL must exist BEFORE
178
+ * the QR banner is printed (the launcher QR carries `&relay=`), so the relay and
179
+ * the dashboard are order-dependent and stay one composed call in the dev loop.
180
+ *
181
+ * Degradation: when `@ait-co/debugger` is not installed the import fails and we
182
+ * return `undefined` — exactly the same "no dashboard" outcome as a closed GUI
183
+ * gate, with the terminal ASCII QR standing alone. We do NOT fall back to a
184
+ * local copy of the daemon code. The caller (`./index.ts`) prints the install
185
+ * hint once when CDP was requested without the package.
180
186
  *
181
187
  * SECRET-HANDLING: the tunnel host, relay wssUrl, TOTP code, and `.ait_relay`
182
- * value/path are NEVER written to stdout/stderr/logs here. They live only inside
183
- * the attach URL (HTML body + `/qr.png` query, per qr-http-server's invariant).
184
- * The only thing opened/logged is `http://127.0.0.1:<port>` (local, safe).
188
+ * value/path are NEVER written to stdout/stderr/logs — neither here nor in the
189
+ * delegate. The only thing opened/logged is `http://127.0.0.1:<port>` (local).
185
190
  *
186
191
  * @returns the dashboard handle when it started (caller wires `close()` into the
187
- * tunnel cleanup), or `undefined` when skipped (no relay, `qr:false`, headless,
188
- * opt-out, or a start failure) — in which case ASCII QR fallback stands alone.
192
+ * tunnel cleanup), or `undefined` when skipped (package absent, no relay,
193
+ * `qr:false`, headless, opt-out, or a start failure) — in which case the ASCII
194
+ * QR fallback stands alone.
189
195
  */
190
196
  declare function startTunnelDashboard(opts: StartTunnelDashboardOptions): Promise<TunnelDashboard | undefined>;
191
197
  interface QuickTunnel {
@@ -1 +1 @@
1
- {"version":3,"file":"tunnel.d.ts","names":[],"sources":["../../src/unplugin/tunnel.ts"],"mappings":";;AAwBA;;;;;AAKA;;;;;;;;;;iBALgB,qBAAA,CAAsB,IAAA;AAAA,UAKrB,wBAAA;EAuCJ;EArCX,EAAA;EA6Ce;EA3Cf,GAAA,IAAO,GAAA;;;;;;;EAOP,WAAA;EAoEW;;AAiCb;;;EA/FE,IAAA;EAgGA;;;;;AAiCF;EA1HE,WAAA;;;;;;;;EAQA,iBAAA;EAqLe;;;;;;EA9Kf,WAAA;AAAA;;AAqLF;;UA7KiB,4BAAA;EA6K2B;;;;EAxK1C,WAAA;EAqLA;;;;EAhLA,IAAA;EAoNoB;;;;;;EA7MpB,WAAA;EA+MQ;;;;;;;EAvMR,iBAAA;EAwS0B;;;;AAiB5B;;EAlTE,WAAA;AAAA;;AAoUF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAnSgB,qBAAA,CACd,SAAA,UACA,WAAA,YAAuB,4BAAA;;;;;;;iBAgCH,iBAAA,CACpB,GAAA,UACA,IAAA,GAAM,wBAAA,GACL,OAAA;;UAgEc,eAAA;;EAEf,GAAA;;EAEA,KAAA,QAAa,OA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;;;;;EAMP,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCoB,oBAAA,CACpB,IAAA,EAAM,2BAAA,GACL,OAAA,CAAQ,eAAA;AAAA,UAoBM,WAAA;;EAEf,GAAA;;EAEA,IAAA;AAAA;;;;;;;;;;;iBAac,yBAAA,CAA0B,IAAA;;;;;;;iBAkBpB,gBAAA,CAAiB,IAAA,WAAe,OAAA,CAAQ,WAAA"}
@@ -1,6 +1,42 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { mkdir } from "node:fs/promises";
3
3
  import { dirname } from "node:path";
4
+ //#region src/unplugin/optional-peers.ts
5
+ /**
6
+ * Optional-peer resolution gates for the debug surface (issue #817).
7
+ *
8
+ * The debug surface now ships as two SEPARATE packages, declared here as
9
+ * OPTIONAL peerDependencies of `@ait-co/devtools`:
10
+ *
11
+ * - `@ait-co/debugger` — MCP daemon / test runner / dev-bridge. devDependency
12
+ * or `npx` only; never part of an app bundle.
13
+ * - `@ait-co/debug-console` — on-device attach + eruda console. The ONLY debug
14
+ * package that can legitimately enter an app bundle.
15
+ *
16
+ * Neither may become a hard dependency. The overwhelming majority of consumers
17
+ * use environment 1 only (browser + mock SDK + panel) and must install NOTHING
18
+ * extra — that is the whole point of splitting the packages apart. So every
19
+ * call site reaches them through the resolution gates below and degrades
20
+ * gracefully when they are absent:
21
+ *
22
+ * - env-2 CDP wiring (`tunnel.cdp`) → falls back to the plain screen-preview
23
+ * tunnel (no relay, no dashboard) and prints {@link INSTALL_HINT}.
24
+ * - in-app attach injection → the snippet is simply not injected, so the
25
+ * attach code is STRUCTURALLY ABSENT from the bundle rather than merely
26
+ * gated at runtime. This gate is the technical enforcement point of the
27
+ * debug surface's security scope: no `@ait-co/debug-console` installed
28
+ * means no attach code can reach a bundle at all.
29
+ *
30
+ * The `import.meta.resolve` probe follows the `MOCK_PATH` precedent in
31
+ * `./index.ts`: resolution is attempted once at plugin-load time and a failure
32
+ * is a plain "not installed" signal, never an error.
33
+ *
34
+ * SECRET-HANDLING: nothing here touches a relay URL, tunnel host, TOTP secret
35
+ * or code. The only strings emitted are fixed specifiers and the install hint.
36
+ */
37
+ /** Subpath of `@ait-co/debugger` that the unplugin's dev loop delegates to. */
38
+ const DEBUGGER_DEV_BRIDGE_ID = "@ait-co/debugger/dev-bridge";
39
+ //#endregion
4
40
  //#region src/unplugin/tunnel.ts
5
41
  /**
6
42
  * Cloudflare quick-tunnel helper for the devtools unplugin.
@@ -105,97 +141,48 @@ async function printTunnelBanner(url, opts = {}) {
105
141
  }
106
142
  }
107
143
  /**
108
- * Heuristic: can this process open a GUI browser? Mirrors `canOpenBrowser` in
109
- * `src/mcp/tools.ts` but is re-declared here (not imported) so the tunnel path
110
- * does not statically pull the heavy MCP `tools.ts` module graph into the lazy
111
- * `import('./tunnel.js')` chunk. Kept in sync with the MCP copy.
112
- *
113
- * - macOS / Windows → assume yes (env-2 dev normally runs on the user's Mac).
114
- * - Linux → require `DISPLAY` or `WAYLAND_DISPLAY`.
115
- * - CI (`CI=true`/`CI=1`) → no.
116
- */
117
- function canOpenBrowser() {
118
- if (process.env.CI === "true" || process.env.CI === "1") return false;
119
- const platform = process.platform;
120
- if (platform === "darwin" || platform === "win32") return true;
121
- if (platform === "linux") return Boolean(process.env.DISPLAY ?? process.env.WAYLAND_DISPLAY);
122
- return false;
123
- }
124
- /**
125
- * Env-2 UX parity with env 3/4 (issue #408): when CDP wiring is on and a GUI is
144
+ * Env-2 UX parity with env 3 (issue #408): when CDP wiring is on and a GUI is
126
145
  * available, start the SAME `127.0.0.1` HTML dashboard (QR image + connect steps
127
- * + FAQ) that the MCP `start_attach` path serves, and auto-open it in the
146
+ * + FAQ) the debug daemon's `start_attach` path serves, and auto-open it in the
128
147
  * browser. headless / opt-out falls back to the terminal ASCII QR (printed
129
148
  * separately by {@link printTunnelBanner}).
130
149
  *
131
- * Every part the install-graph invariant depends on (`qrcode`, the MCP HTTP
132
- * server, the opener) is reached only through dynamic `import()` here, inside
133
- * the already-lazy `tunnel.js` chunk nothing is added to the common build
134
- * graph or the MCP-only install graph.
150
+ * DELEGATED (issue #817): the implementation now lives in `@ait-co/debugger`'s
151
+ * `/dev-bridge` subpath the one cross-repo code delegation of the package
152
+ * split. The dashboard needs the daemon's QR HTTP server, deep-link builder and
153
+ * TOTP minting, all of which moved into that package; keeping a second copy here
154
+ * would fork them. `@ait-co/debugger` is an OPTIONAL peer, so a consumer who
155
+ * never asks for env-2 CDP installs nothing extra.
156
+ *
157
+ * Why this is not a separate plugin: the relay `wss://` URL must exist BEFORE
158
+ * the QR banner is printed (the launcher QR carries `&relay=`), so the relay and
159
+ * the dashboard are order-dependent and stay one composed call in the dev loop.
135
160
  *
136
- * TOTP encapsulation: the dashboard's `getDashboardState` closure mints a FRESH
137
- * TOTP `at=` code on every call via `generateTotp(secret, Date.now())` and folds
138
- * it into a fresh `buildLauncherAttachUrl(...)`. Because the QR is re-rendered on
139
- * each SSE push / page reload from this closure, the code a phone scans is always
140
- * within its 30 s window no stale code is baked into static HTML.
161
+ * Degradation: when `@ait-co/debugger` is not installed the import fails and we
162
+ * return `undefined` exactly the same "no dashboard" outcome as a closed GUI
163
+ * gate, with the terminal ASCII QR standing alone. We do NOT fall back to a
164
+ * local copy of the daemon code. The caller (`./index.ts`) prints the install
165
+ * hint once when CDP was requested without the package.
141
166
  *
142
167
  * SECRET-HANDLING: the tunnel host, relay wssUrl, TOTP code, and `.ait_relay`
143
- * value/path are NEVER written to stdout/stderr/logs here. They live only inside
144
- * the attach URL (HTML body + `/qr.png` query, per qr-http-server's invariant).
145
- * The only thing opened/logged is `http://127.0.0.1:<port>` (local, safe).
168
+ * value/path are NEVER written to stdout/stderr/logs — neither here nor in the
169
+ * delegate. The only thing opened/logged is `http://127.0.0.1:<port>` (local).
146
170
  *
147
171
  * @returns the dashboard handle when it started (caller wires `close()` into the
148
- * tunnel cleanup), or `undefined` when skipped (no relay, `qr:false`, headless,
149
- * opt-out, or a start failure) — in which case ASCII QR fallback stands alone.
172
+ * tunnel cleanup), or `undefined` when skipped (package absent, no relay,
173
+ * `qr:false`, headless, opt-out, or a start failure) — in which case the ASCII
174
+ * QR fallback stands alone.
150
175
  */
151
176
  async function startTunnelDashboard(opts) {
152
- const log = opts.log ?? ((m) => console.log(m));
153
177
  if (!opts.relayWssUrl) return void 0;
154
178
  if (opts.qr === false) return void 0;
155
- const { isAutoDevtoolsDisabled } = await import("../devtools-opener-BTl5A6Cd.js");
156
- if (!(opts.shouldOpen ?? (() => !isAutoDevtoolsDisabled() && canOpenBrowser()))()) return void 0;
157
- const { startQrHttpServer } = await import("../qr-http-server-Bb7lMeqi.js");
158
- const { buildLauncherAttachUrl } = await import("../deeplink-BpO9qc-D.js");
159
- const { generateTotp } = await import("../totp-95OAa20j.js");
160
- const getDashboardState = () => {
161
- const secret = process.env.AIT_DEBUG_TOTP_SECRET;
162
- const totpCode = secret ? generateTotp(secret, Date.now()) : void 0;
163
- const attachUrl = buildLauncherAttachUrl(opts.tunnelUrl, opts.relayWssUrl, totpCode, { name: opts.name });
164
- return {
165
- tunnel: {
166
- up: true,
167
- wssUrl: opts.relayWssUrl
168
- },
169
- pages: null,
170
- attachUrl,
171
- inspectorUrl: null,
172
- mode: "relay-mobile",
173
- phase: "active"
174
- };
175
- };
176
- let server;
179
+ let devBridge;
177
180
  try {
178
- server = await startQrHttpServer(getDashboardState);
181
+ devBridge = await import(DEBUGGER_DEV_BRIDGE_ID);
179
182
  } catch {
180
183
  return;
181
184
  }
182
- let totpRefreshHandle = setInterval(() => {
183
- server.notifyStateChange();
184
- }, 2e4);
185
- totpRefreshHandle.unref();
186
- const dashboardUrl = `http://127.0.0.1:${server.port}`;
187
- const { openUrlInBrowser } = await import("../devtools-opener-BTl5A6Cd.js");
188
- log(openUrlInBrowser(dashboardUrl) ? ` │ Opened a QR dashboard in your browser: ${dashboardUrl}` : ` │ Open this QR dashboard in your browser: ${dashboardUrl}`);
189
- return {
190
- url: dashboardUrl,
191
- close: () => {
192
- if (totpRefreshHandle) {
193
- clearInterval(totpRefreshHandle);
194
- totpRefreshHandle = null;
195
- }
196
- return server.close();
197
- }
198
- };
185
+ return devBridge.startTunnelDashboard(opts);
199
186
  }
200
187
  /**
201
188
  * Sanitize cloudflared stderr output for error diagnostics (#421).
@@ -1 +1 @@
1
- {"version":3,"file":"tunnel.js","names":[],"sources":["../../src/unplugin/tunnel.ts"],"sourcesContent":["/**\n * Cloudflare quick-tunnel helper for the devtools unplugin.\n *\n * Loaded lazily (`await import('./tunnel.js')`) only when the `tunnel` option is\n * on, so `cloudflared` / `qrcode-terminal` are never pulled in for the common\n * case. This is the one place in `@ait-co/devtools` that depends on Node-only\n * APIs (`child_process` via the `cloudflared` wrapper) — keep it thin and out of\n * jsdom unit tests; the spawn path is verified by hand / e2e (same spirit as the\n * \"web 모드는 e2e\" rule in CLAUDE.md). The pure helpers below\n * (`parseTrycloudflareUrl`, `printTunnelBanner`) are unit-tested.\n */\n\nimport { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { dirname } from 'node:path';\n\n/** Matches the public URL cloudflared prints for an unauthenticated quick tunnel. */\nconst TRYCLOUDFLARE_RE = /https:\\/\\/[a-z0-9-]+\\.trycloudflare\\.com/i;\n\n/**\n * Extract the `https://<sub>.trycloudflare.com` URL from a line of cloudflared\n * output, or `null` if the line doesn't contain one. Pulled out as a pure\n * function so it can be unit-tested without spawning anything.\n */\nexport function parseTrycloudflareUrl(line: string): string | null {\n const m = line.match(TRYCLOUDFLARE_RE);\n return m ? m[0] : null;\n}\n\nexport interface PrintTunnelBannerOptions {\n /** Print an ASCII QR encoding the tunnel URL (default: true). */\n qr?: boolean;\n /** Sink for the banner text (default: `console.log`). Injected for testing. */\n log?: (msg: string) => void;\n /**\n * The `wss://` relay URL of the env-2 CDP tunnel, if `tunnel.cdp` is on. When\n * present the QR deep-link additionally carries `&debug=1&relay=<wss>` so the\n * framed PWA passes the in-app debug gate and attaches a Chii target — the\n * same single scan opens screen preview *and* CDP debugging.\n */\n relayWssUrl?: string;\n /**\n * Human-readable app name to embed as `name=` in the launcher deep-link (#498).\n * When provided (non-blank), the launcher partner bar shows this name instead of\n * the generic default.\n */\n name?: string;\n /**\n * The miniapp's webViewType. When `'game'`, the deep-link carries `&navBarType=game`\n * so the launcher enters game nav chrome automatically on scan (#584).\n * `'partner'` (the default) is the launcher's implicit default — not added to\n * keep the URL clean.\n */\n webViewType?: 'partner' | 'game';\n /**\n * Whether the miniapp's navigationBar has `transparentBackground: true`\n * (granite.config `navigationBar.transparentBackground`, SDK 2.8.0, #587).\n * When `true`, the deep-link carries `&navBarTransparent=1` so the launcher\n * partner bar renders with a transparent background (content shows through).\n * `false` / omitted → not added (URL clean, back-compat).\n */\n navBarTransparent?: boolean;\n /**\n * The miniapp's navigationBar theme (`granite.config `navigationBar.theme`,\n * SDK 2.8.0, #587). When `'light'` or `'dark'`, the deep-link carries\n * `&navBarTheme=<v>` so the launcher partner bar uses the matching foreground\n * colour. Omitted / other values → not added (URL clean, back-compat).\n */\n navBarTheme?: 'light' | 'dark';\n}\n\nconst LAUNCHER_URL = 'https://devtools.aitc.dev/launcher/';\n\n/**\n * Options for {@link buildLauncherDeepLink}.\n */\nexport interface BuildLauncherDeepLinkOptions {\n /**\n * `wss://` relay URL for env-2 CDP wiring. When present the deep-link carries\n * `&debug=1&relay=<wss>`.\n */\n relayWssUrl?: string;\n /**\n * Human-readable app name shown in the partner nav bar (`name=` param, #498).\n * Blank / whitespace-only values are not added.\n */\n name?: string;\n /**\n * The miniapp's webViewType. When `'game'`, adds `&navBarType=game` to the\n * deep-link so the launcher enters game nav chrome automatically on scan (#584).\n * `'partner'` (the launcher's implicit default) is not added to keep the URL\n * clean.\n */\n webViewType?: 'partner' | 'game';\n /**\n * Whether the miniapp's navigationBar has `transparentBackground: true`\n * (granite.config `navigationBar.transparentBackground`, SDK 2.8.0, #587).\n * When `true`, adds `&navBarTransparent=1` to the deep-link so the launcher\n * partner bar renders with a transparent background. Omitted when `false` /\n * undefined to keep the URL clean (back-compat).\n */\n navBarTransparent?: boolean;\n /**\n * The miniapp's navigationBar theme (granite.config `navigationBar.theme`,\n * SDK 2.8.0, #587). When `'light'` or `'dark'`, adds `&navBarTheme=<v>` to\n * the deep-link so the launcher partner bar uses the matching foreground colour.\n * Omitted when undefined / other values to keep the URL clean (back-compat).\n */\n navBarTheme?: 'light' | 'dark';\n}\n\n/**\n * Build the deep-link URL that QR codes encode: when the launcher PWA is\n * already on the phone's home screen, scanning this opens it directly into the\n * live view for `tunnelUrl` (the launcher consumes `?url=` and clears it).\n * Plain-text raw URL is no longer enough — the launcher gates its setup UI to\n * the installed PWA, so a raw tunnel URL opened in a normal browser tab would\n * land on a \"please install\" screen.\n *\n * When `opts.relayWssUrl` is given (env-2 CDP wiring), the deep-link also carries\n * `&debug=1&relay=<wss>`; the launcher folds those onto the framed tunnel URL so\n * the in-app debug gate's Layer C (`debug=1` opt-in + `relay=<wss>`) is met and\n * a Chii target.js is injected into the live view.\n *\n * When `opts.name` is given (non-blank), it is added as `&name=` so the launcher\n * partner bar shows the app name instead of the generic default (#498).\n *\n * When `opts.webViewType` is `'game'`, `&navBarType=game` is appended so the\n * launcher enters game nav chrome (floating capsule, no full bar) automatically\n * on scan. `'partner'` is the launcher's implicit default and is not added to\n * keep the URL clean (#584).\n *\n * When `opts.navBarTransparent` is `true`, `&navBarTransparent=1` is appended\n * so the launcher partner bar renders with a transparent background (#587).\n *\n * When `opts.navBarTheme` is `'light'` or `'dark'`, `&navBarTheme=<v>` is\n * appended so the launcher partner bar uses the matching foreground colour (#587).\n *\n * Back-compat: the second argument may also be a plain string (`relayWssUrl`)\n * for callers that haven't migrated to the options object yet.\n */\nexport function buildLauncherDeepLink(\n tunnelUrl: string,\n optsOrRelay?: string | BuildLauncherDeepLinkOptions,\n): string {\n // Normalise the overloaded second argument.\n const opts: BuildLauncherDeepLinkOptions =\n typeof optsOrRelay === 'string' ? { relayWssUrl: optsOrRelay } : (optsOrRelay ?? {});\n\n const base = `${LAUNCHER_URL}?url=${encodeURIComponent(tunnelUrl)}`;\n let url = base;\n if (opts.relayWssUrl) {\n url += `&debug=1&relay=${encodeURIComponent(opts.relayWssUrl)}`;\n }\n if (opts.name !== undefined && opts.name.trim() !== '') {\n url += `&name=${encodeURIComponent(opts.name.trim())}`;\n }\n if (opts.webViewType === 'game') {\n url += '&navBarType=game';\n }\n if (opts.navBarTransparent === true) {\n url += '&navBarTransparent=1';\n }\n if (opts.navBarTheme === 'light' || opts.navBarTheme === 'dark') {\n url += `&navBarTheme=${opts.navBarTheme}`;\n }\n return url;\n}\n\n/**\n * Print the terminal banner announcing the live tunnel: the public URL, an ASCII\n * QR encoding a launcher deep-link, and a one-line note that quick tunnels are\n * ephemeral, unauthenticated and not for production. Pure w.r.t. side effects\n * other than the injected `log` sink and `qrcode-terminal` — unit-tested.\n */\nexport async function printTunnelBanner(\n url: string,\n opts: PrintTunnelBannerOptions = {},\n): Promise<void> {\n const log = opts.log ?? ((m: string) => console.log(m));\n const deepLink = buildLauncherDeepLink(url, {\n relayWssUrl: opts.relayWssUrl,\n name: opts.name,\n webViewType: opts.webViewType,\n navBarTransparent: opts.navBarTransparent,\n navBarTheme: opts.navBarTheme,\n });\n const lines: string[] = [\n '',\n ' ┌─ @ait-co/devtools · live tunnel ────────────────────────────',\n ` │ ${url}`,\n ' │',\n ` │ Install the launcher PWA once: ${LAUNCHER_URL}`,\n ' │ Then scan the QR below — it opens the launcher directly',\n ' │ into this tunnel URL (no manual paste needed).',\n ...(opts.relayWssUrl\n ? [\n ' │ The same scan also attaches CDP — connect your AI host',\n ' │ to the relay and debug the live view on-device.',\n ]\n : []),\n ' │ Quick tunnels are unauthenticated, change every run, and are',\n ' │ not for production use.',\n ' └──────────────────────────────────────────────────────────────',\n '',\n ];\n log(lines.join('\\n'));\n\n if (opts.qr !== false) {\n // qrcode-terminal is only pulled in on this code path (ambient types live\n // in src/qrcode-terminal.d.ts).\n const qrcode = (await import('qrcode-terminal')).default;\n await new Promise<void>((resolve) => {\n qrcode.generate(deepLink, { small: true }, (out) => {\n log(out);\n resolve();\n });\n });\n }\n}\n\n/**\n * Heuristic: can this process open a GUI browser? Mirrors `canOpenBrowser` in\n * `src/mcp/tools.ts` but is re-declared here (not imported) so the tunnel path\n * does not statically pull the heavy MCP `tools.ts` module graph into the lazy\n * `import('./tunnel.js')` chunk. Kept in sync with the MCP copy.\n *\n * - macOS / Windows → assume yes (env-2 dev normally runs on the user's Mac).\n * - Linux → require `DISPLAY` or `WAYLAND_DISPLAY`.\n * - CI (`CI=true`/`CI=1`) → no.\n */\nfunction canOpenBrowser(): boolean {\n if (process.env.CI === 'true' || process.env.CI === '1') return false;\n const platform = process.platform;\n if (platform === 'darwin' || platform === 'win32') return true;\n if (platform === 'linux') {\n return Boolean(process.env.DISPLAY ?? process.env.WAYLAND_DISPLAY);\n }\n return false;\n}\n\n/** Handle returned by {@link startTunnelDashboard}. */\nexport interface TunnelDashboard {\n /** `http://127.0.0.1:<port>` — the local dashboard URL opened in the browser. */\n url: string;\n /** Tear down the local HTTP server. Idempotent via the underlying server. */\n close: () => Promise<void>;\n}\n\nexport interface StartTunnelDashboardOptions {\n /** The public `https://*.trycloudflare.com` app tunnel URL the launcher frames. */\n tunnelUrl: string;\n /** The `wss://` relay URL of the env-2 CDP tunnel. REQUIRED — the dashboard is a CDP-only UX. */\n relayWssUrl: string;\n /** Mirror of `tunnel.qr` — when `false` the dashboard is skipped (no browser open). */\n qr?: boolean;\n /**\n * Override the GUI/opt-out gate (testing only). When omitted the real\n * `canOpenBrowser()` + `AIT_AUTO_DEVTOOLS` checks decide.\n */\n shouldOpen?: () => boolean;\n /** Sink for the one-line \"opened in browser\" note (default: `console.log`). Injected for testing. */\n log?: (msg: string) => void;\n /**\n * Human-readable app name to embed as `name=` in the launcher deep-link (#498).\n * When provided (non-blank), the launcher partner bar shows this name instead of\n * the generic default.\n */\n name?: string;\n}\n\n/**\n * Env-2 UX parity with env 3/4 (issue #408): when CDP wiring is on and a GUI is\n * available, start the SAME `127.0.0.1` HTML dashboard (QR image + connect steps\n * + FAQ) that the MCP `start_attach` path serves, and auto-open it in the\n * browser. headless / opt-out falls back to the terminal ASCII QR (printed\n * separately by {@link printTunnelBanner}).\n *\n * Every part the install-graph invariant depends on (`qrcode`, the MCP HTTP\n * server, the opener) is reached only through dynamic `import()` here, inside\n * the already-lazy `tunnel.js` chunk — nothing is added to the common build\n * graph or the MCP-only install graph.\n *\n * TOTP encapsulation: the dashboard's `getDashboardState` closure mints a FRESH\n * TOTP `at=` code on every call via `generateTotp(secret, Date.now())` and folds\n * it into a fresh `buildLauncherAttachUrl(...)`. Because the QR is re-rendered on\n * each SSE push / page reload from this closure, the code a phone scans is always\n * within its 30 s window — no stale code is baked into static HTML.\n *\n * SECRET-HANDLING: the tunnel host, relay wssUrl, TOTP code, and `.ait_relay`\n * value/path are NEVER written to stdout/stderr/logs here. They live only inside\n * the attach URL (HTML body + `/qr.png` query, per qr-http-server's invariant).\n * The only thing opened/logged is `http://127.0.0.1:<port>` (local, safe).\n *\n * @returns the dashboard handle when it started (caller wires `close()` into the\n * tunnel cleanup), or `undefined` when skipped (no relay, `qr:false`, headless,\n * opt-out, or a start failure) — in which case ASCII QR fallback stands alone.\n */\nexport async function startTunnelDashboard(\n opts: StartTunnelDashboardOptions,\n): Promise<TunnelDashboard | undefined> {\n const log = opts.log ?? ((m: string) => console.log(m));\n\n // Gate: dashboard is a CDP-only UX (needs a relay to attach to).\n if (!opts.relayWssUrl) return undefined;\n // Opt-out via `tunnel.qr:false` (same toggle that suppresses the ASCII QR).\n if (opts.qr === false) return undefined;\n\n // GUI + AIT_AUTO_DEVTOOLS gate. Reuse the MCP opener's opt-out predicate so\n // the env-2 path honours the same `AIT_AUTO_DEVTOOLS=0` switch as env 3/4.\n const { isAutoDevtoolsDisabled } = await import('../mcp/devtools-opener.js');\n const gateOpen = opts.shouldOpen ?? (() => !isAutoDevtoolsDisabled() && canOpenBrowser());\n if (!gateOpen()) return undefined;\n\n const { startQrHttpServer } = await import('../mcp/qr-http-server.js');\n const { buildLauncherAttachUrl } = await import('../mcp/deeplink.js');\n const { generateTotp } = await import('../mcp/totp.js');\n\n // getDashboardState — mints a fresh TOTP + attach URL on every call so the QR\n // the dashboard renders (on load and on each SSE push) is never expired.\n // SECRET-HANDLING: the secret is read from env AT CALL TIME (it was injected\n // by ensureRelaySecret in the same CDP block) and is used only to compute the\n // at= code folded into attachUrl. tunnel.up is always true here — the relay\n // tunnel is already up by the time this runs.\n const getDashboardState = () => {\n const secret = process.env.AIT_DEBUG_TOTP_SECRET;\n const totpCode = secret ? generateTotp(secret, Date.now()) : undefined;\n const attachUrl = buildLauncherAttachUrl(opts.tunnelUrl, opts.relayWssUrl, totpCode, {\n name: opts.name,\n });\n // pages: null — env 2(unplugin)는 데몬이 아니라 vite 플러그인 안이라\n // startChiiRelay 핸들이 connected target을 노출하지 않는다. 라이브 page 목록을\n // 알 수 없으므로 거짓 빈 목록 대신 \"연결된 Pages\" 섹션 자체를 숨긴다(#411).\n // env 3/4(debug-server.ts)는 router.active.listTargets()로 실제 목록을 채운다.\n // mode: 'relay-mobile' — 이 대시보드는 항상 환경 2(AITC Sandbox PWA) 전용이므로\n // /attach 카피가 launcher PWA 절차(sandbox family)로 분기된다(#468).\n // inspectorUrl: null — env 2에서는 unplugin relay가 connected target ID를 노출하지\n // 않아 buildChiiInspectorUrl에 필요한 targetId를 알 수 없다. target attach 후\n // target ID가 필요하므로 env 3/4에서만 non-null이 된다(#503).\n return {\n tunnel: { up: true, wssUrl: opts.relayWssUrl },\n pages: null,\n attachUrl,\n inspectorUrl: null,\n mode: 'relay-mobile' as const,\n // phase (#730): this dev-tunnel dashboard has no CLI run lifecycle or\n // daemon shutdown signal to drive — it stays 'active' for its lifetime.\n phase: 'active' as const,\n };\n };\n\n let server: Awaited<ReturnType<typeof startQrHttpServer>>;\n try {\n server = await startQrHttpServer(getDashboardState);\n } catch {\n // SECRET-HANDLING: do not surface the error (could embed paths/hosts). The\n // ASCII QR printed by printTunnelBanner stays as the fallback.\n return undefined;\n }\n\n // TOTP periodic refresh timer — pushes a fresh at= code to SSE clients every\n // 20 s so a page left open never stales past the 90 s acceptance window (#448).\n // tunnel.ts always has relayWssUrl available here (gated above), so no\n // lastAttachParts guard is needed — getDashboardState mints a fresh TOTP on\n // every call unconditionally.\n // SECRET-HANDLING: callback is a plain trigger only — TOTP value and at= code\n // must never be logged or written to stdout.\n const TOTP_REFRESH_INTERVAL_MS = 20_000;\n let totpRefreshHandle: ReturnType<typeof setInterval> | null = setInterval(() => {\n server.notifyStateChange();\n }, TOTP_REFRESH_INTERVAL_MS);\n totpRefreshHandle.unref();\n\n const dashboardUrl = `http://127.0.0.1:${server.port}`;\n\n const { openUrlInBrowser } = await import('../mcp/devtools-opener.js');\n const opened = openUrlInBrowser(dashboardUrl);\n // SECRET-HANDLING: only the local 127.0.0.1 URL is logged — never the tunnel\n // host, relay wssUrl, or TOTP code.\n log(\n opened\n ? ` │ Opened a QR dashboard in your browser: ${dashboardUrl}`\n : ` │ Open this QR dashboard in your browser: ${dashboardUrl}`,\n );\n\n return {\n url: dashboardUrl,\n close: () => {\n if (totpRefreshHandle) {\n clearInterval(totpRefreshHandle);\n totpRefreshHandle = null;\n }\n return server.close();\n },\n };\n}\n\nexport interface QuickTunnel {\n /** The public `https://*.trycloudflare.com` URL. */\n url: string;\n /** Stop the underlying `cloudflared` process. Idempotent. */\n stop: () => void;\n}\n\n/**\n * Sanitize cloudflared stderr output for error diagnostics (#421).\n *\n * Masks `*.trycloudflare.com` hostnames and full `https://` / `wss://` URLs\n * that carry those hostnames so tunnel host values never appear in error\n * messages. Diagnostic content (error codes, reasons, JSON blobs) is preserved.\n *\n * SECRET-HANDLING: tunnel host is SECRET-class per harness policy — only\n * placeholder text is emitted.\n */\nexport function sanitizeCloudflaredOutput(line: string): string {\n // Full URL forms: https://xxx.trycloudflare.com/… and wss://xxx.trycloudflare.com/…\n let s = line.replace(/(?:https?|wss?):\\/\\/[a-z0-9-]+\\.trycloudflare\\.com(?:\\/[^\\s]*)*/gi, (m) =>\n m.replace(/[a-z0-9-]+\\.trycloudflare\\.com/i, '<HOST>.trycloudflare.com'),\n );\n // Bare hostname without scheme (e.g. printed in cloudflared JSON logs)\n s = s.replace(/[a-z0-9-]+\\.trycloudflare\\.com/gi, '<HOST>.trycloudflare.com');\n return s;\n}\n\nconst URL_TIMEOUT_MS = 20_000;\n\n/**\n * Start an unauthenticated Cloudflare quick tunnel to `http://localhost:<port>`\n * and resolve once the public URL is known. Downloads the `cloudflared` binary\n * on first use if it is not already installed. Rejects with a friendly error if\n * no URL appears within {@link URL_TIMEOUT_MS}.\n */\nexport async function startQuickTunnel(port: number): Promise<QuickTunnel> {\n const cloudflared = await import('cloudflared');\n const { bin, install, Tunnel } = cloudflared;\n\n if (!existsSync(bin)) {\n await mkdir(dirname(bin), { recursive: true });\n await install(bin);\n }\n\n const tunnel = Tunnel.quick(`http://localhost:${port}`);\n let stopped = false;\n const stop = () => {\n if (stopped) return;\n stopped = true;\n try {\n tunnel.stop();\n } catch {\n // process may already be gone\n }\n };\n\n return new Promise<QuickTunnel>((resolve, reject) => {\n // #421: accumulate stderr to attach as diagnostics on failure.\n // SECRET-HANDLING: lines are sanitized before inclusion in error messages.\n const stderrLines: string[] = [];\n\n /**\n * Format the last `n` sanitized stderr lines as a diagnostic appendix.\n * Returns an empty string when no lines have been collected.\n */\n const stderrTail = (n = 15): string => {\n if (stderrLines.length === 0) return '';\n const tail = stderrLines.slice(-n).map(sanitizeCloudflaredOutput).join('');\n return `\\ncloudflared 출력 (마지막 ${Math.min(n, stderrLines.length)}줄):\\n${tail}`;\n };\n\n const timer = setTimeout(() => {\n cleanup();\n stop();\n reject(\n new Error(\n `[@ait-co/devtools] cloudflared did not report a tunnel URL within ${\n URL_TIMEOUT_MS / 1000\n }s. Check your network connection, or run \\`cloudflared tunnel --url http://localhost:${port}\\` manually.${stderrTail()}`,\n ),\n );\n }, URL_TIMEOUT_MS);\n\n const onUrl = (line: string) => {\n const found = parseTrycloudflareUrl(line);\n if (!found) return;\n clearTimeout(timer);\n // Stop scanning further output once we have the URL.\n cleanup();\n resolve({ url: found, stop });\n };\n\n // Accumulate stderr lines for diagnostics (#421). Named so it can be\n // removed from the listener list when cleanup() runs.\n const pushStderr = (line: string) => {\n stderrLines.push(line);\n };\n\n const cleanup = () => {\n tunnel.off('stdout', onUrl);\n tunnel.off('stderr', onUrl);\n tunnel.off('stderr', pushStderr);\n };\n\n // The library emits a parsed `url` event; we also scan raw stdout/stderr in\n // case the output format shifts.\n tunnel.once('url', onUrl);\n tunnel.on('stdout', onUrl);\n tunnel.on('stderr', onUrl);\n // Second stderr listener: accumulate all lines for error diagnostics.\n tunnel.on('stderr', pushStderr);\n tunnel.once('error', (err: Error) => {\n clearTimeout(timer);\n cleanup();\n stop();\n reject(err);\n });\n tunnel.once('exit', (code: number | null) => {\n if (stopped) return;\n clearTimeout(timer);\n cleanup();\n reject(\n new Error(\n `[@ait-co/devtools] cloudflared exited (code ${code ?? 'null'}) before reporting a tunnel URL.${stderrTail()}`,\n ),\n );\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,mBAAmB;;;;;;AAOzB,SAAgB,sBAAsB,MAA6B;CACjE,MAAM,IAAI,KAAK,MAAM,iBAAiB;AACtC,QAAO,IAAI,EAAE,KAAK;;AA6CpB,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsErB,SAAgB,sBACd,WACA,aACQ;CAER,MAAM,OACJ,OAAO,gBAAgB,WAAW,EAAE,aAAa,aAAa,GAAI,eAAe,EAAE;CAGrF,IAAI,MADS,GAAG,aAAa,OAAO,mBAAmB,UAAU;AAEjE,KAAI,KAAK,YACP,QAAO,kBAAkB,mBAAmB,KAAK,YAAY;AAE/D,KAAI,KAAK,SAAS,KAAA,KAAa,KAAK,KAAK,MAAM,KAAK,GAClD,QAAO,SAAS,mBAAmB,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AAU,QAAe;AACnC,gBAAa,MAAM;AACnB,YAAS;AACT,SAAM;AACN,UAAO,IAAI;IACX;AACF,SAAO,KAAK,SAAS,SAAwB;AAC3C,OAAI,QAAS;AACb,gBAAa,MAAM;AACnB,YAAS;AACT,0BACE,IAAI,MACF,+CAA+C,QAAQ,OAAO,kCAAkC,YAAY,GAC7G,CACF;IACD;GACF"}
1
+ {"version":3,"file":"tunnel.js","names":[],"sources":["../../src/unplugin/optional-peers.ts","../../src/unplugin/tunnel.ts"],"sourcesContent":["/**\n * Optional-peer resolution gates for the debug surface (issue #817).\n *\n * The debug surface now ships as two SEPARATE packages, declared here as\n * OPTIONAL peerDependencies of `@ait-co/devtools`:\n *\n * - `@ait-co/debugger` — MCP daemon / test runner / dev-bridge. devDependency\n * or `npx` only; never part of an app bundle.\n * - `@ait-co/debug-console` — on-device attach + eruda console. The ONLY debug\n * package that can legitimately enter an app bundle.\n *\n * Neither may become a hard dependency. The overwhelming majority of consumers\n * use environment 1 only (browser + mock SDK + panel) and must install NOTHING\n * extra — that is the whole point of splitting the packages apart. So every\n * call site reaches them through the resolution gates below and degrades\n * gracefully when they are absent:\n *\n * - env-2 CDP wiring (`tunnel.cdp`) → falls back to the plain screen-preview\n * tunnel (no relay, no dashboard) and prints {@link INSTALL_HINT}.\n * - in-app attach injection → the snippet is simply not injected, so the\n * attach code is STRUCTURALLY ABSENT from the bundle rather than merely\n * gated at runtime. This gate is the technical enforcement point of the\n * debug surface's security scope: no `@ait-co/debug-console` installed\n * means no attach code can reach a bundle at all.\n *\n * The `import.meta.resolve` probe follows the `MOCK_PATH` precedent in\n * `./index.ts`: resolution is attempted once at plugin-load time and a failure\n * is a plain \"not installed\" signal, never an error.\n *\n * SECRET-HANDLING: nothing here touches a relay URL, tunnel host, TOTP secret\n * or code. The only strings emitted are fixed specifiers and the install hint.\n */\n\n/** Subpath of `@ait-co/debugger` that the unplugin's dev loop delegates to. */\nexport const DEBUGGER_DEV_BRIDGE_ID = '@ait-co/debugger/dev-bridge';\n\n/** The on-device attach package injected into a consumer entry point. */\nexport const DEBUG_CONSOLE_ID = '@ait-co/debug-console';\n\n/**\n * The pre-split in-app specifier. Still recognised for DEDUPE only — a consumer\n * who wired `@ait-co/devtools/in-app` by hand must not also receive the new\n * auto-injected snippet. It is never injected any more.\n */\nexport const LEGACY_IN_APP_ID = '@ait-co/devtools/in-app';\n\n/** One-line install hint printed whenever a gate closes on a missing package. */\nexport const INSTALL_HINT = 'pnpm add -D @ait-co/debugger @ait-co/debug-console';\n\n/**\n * Returns whether `specifier` resolves from this package's location.\n *\n * `import.meta.resolve` throws (rather than returning a falsy value) for an\n * unresolvable specifier, and is itself absent on a few older runtimes — both\n * are treated as \"not installed\", which is the safe direction: the caller then\n * takes the degraded path instead of importing something that is not there.\n */\nexport function canResolveOptionalPeer(specifier: string): boolean {\n try {\n return typeof import.meta.resolve(specifier) === 'string';\n } catch {\n return false;\n }\n}\n\n/** Whether `@ait-co/debugger`'s dev-bridge is installed (env-2 CDP path). */\nexport function hasDebugger(): boolean {\n return canResolveOptionalPeer(DEBUGGER_DEV_BRIDGE_ID);\n}\n\n/** Whether `@ait-co/debug-console` is installed (in-app attach injection). */\nexport function hasDebugConsole(): boolean {\n return canResolveOptionalPeer(DEBUG_CONSOLE_ID);\n}\n\n/**\n * Whether `code` already wires the in-app debug attach itself.\n *\n * Both the current (`@ait-co/debug-console`) and the pre-split\n * (`@ait-co/devtools/in-app`) specifier count, so a consumer who wired either\n * one by hand never gets a duplicate auto-injection.\n */\nexport function hasInAppWiring(code: string): boolean {\n return code.includes(DEBUG_CONSOLE_ID) || code.includes(LEGACY_IN_APP_ID);\n}\n\n/**\n * The gated dynamic-import snippet prepended to a consumer entry point.\n *\n * The runtime gate (`?debug=1` + a `relay` param) keeps the chunk unloaded on a\n * normal page load, and a production build dead-code-eliminates it. The\n * build-time gate is {@link hasDebugConsole} at the call site: when the package\n * is absent this snippet is never produced, so the attach code cannot be in the\n * bundle at all.\n */\nexport function buildInAppSnippet(): string {\n return [\n '// @ait-co/devtools: in-app attach auto-injected by unplugin — 수동 배선 불필요',\n \"if (typeof window !== 'undefined') {\",\n ' const __ait_p = new URLSearchParams(window.location.search);',\n \" if (__ait_p.get('debug') === '1' && __ait_p.get('relay')) {\",\n ` void import('${DEBUG_CONSOLE_ID}').then((m) => m.maybeAttach());`,\n ' }',\n '}',\n ].join('\\n');\n}\n","/**\n * Cloudflare quick-tunnel helper for the devtools unplugin.\n *\n * Loaded lazily (`await import('./tunnel.js')`) only when the `tunnel` option is\n * on, so `cloudflared` / `qrcode-terminal` are never pulled in for the common\n * case. This is the one place in `@ait-co/devtools` that depends on Node-only\n * APIs (`child_process` via the `cloudflared` wrapper) — keep it thin and out of\n * jsdom unit tests; the spawn path is verified by hand / e2e (same spirit as the\n * \"web 모드는 e2e\" rule in CLAUDE.md). The pure helpers below\n * (`parseTrycloudflareUrl`, `printTunnelBanner`) are unit-tested.\n */\n\nimport { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { DEBUGGER_DEV_BRIDGE_ID } from './optional-peers.js';\n\n/** Matches the public URL cloudflared prints for an unauthenticated quick tunnel. */\nconst TRYCLOUDFLARE_RE = /https:\\/\\/[a-z0-9-]+\\.trycloudflare\\.com/i;\n\n/**\n * Extract the `https://<sub>.trycloudflare.com` URL from a line of cloudflared\n * output, or `null` if the line doesn't contain one. Pulled out as a pure\n * function so it can be unit-tested without spawning anything.\n */\nexport function parseTrycloudflareUrl(line: string): string | null {\n const m = line.match(TRYCLOUDFLARE_RE);\n return m ? m[0] : null;\n}\n\nexport interface PrintTunnelBannerOptions {\n /** Print an ASCII QR encoding the tunnel URL (default: true). */\n qr?: boolean;\n /** Sink for the banner text (default: `console.log`). Injected for testing. */\n log?: (msg: string) => void;\n /**\n * The `wss://` relay URL of the env-2 CDP tunnel, if `tunnel.cdp` is on. When\n * present the QR deep-link additionally carries `&debug=1&relay=<wss>` so the\n * framed PWA passes the in-app debug gate and attaches a Chii target — the\n * same single scan opens screen preview *and* CDP debugging.\n */\n relayWssUrl?: string;\n /**\n * Human-readable app name to embed as `name=` in the launcher deep-link (#498).\n * When provided (non-blank), the launcher partner bar shows this name instead of\n * the generic default.\n */\n name?: string;\n /**\n * The miniapp's webViewType. When `'game'`, the deep-link carries `&navBarType=game`\n * so the launcher enters game nav chrome automatically on scan (#584).\n * `'partner'` (the default) is the launcher's implicit default — not added to\n * keep the URL clean.\n */\n webViewType?: 'partner' | 'game';\n /**\n * Whether the miniapp's navigationBar has `transparentBackground: true`\n * (granite.config `navigationBar.transparentBackground`, SDK 2.8.0, #587).\n * When `true`, the deep-link carries `&navBarTransparent=1` so the launcher\n * partner bar renders with a transparent background (content shows through).\n * `false` / omitted → not added (URL clean, back-compat).\n */\n navBarTransparent?: boolean;\n /**\n * The miniapp's navigationBar theme (`granite.config `navigationBar.theme`,\n * SDK 2.8.0, #587). When `'light'` or `'dark'`, the deep-link carries\n * `&navBarTheme=<v>` so the launcher partner bar uses the matching foreground\n * colour. Omitted / other values → not added (URL clean, back-compat).\n */\n navBarTheme?: 'light' | 'dark';\n}\n\nconst LAUNCHER_URL = 'https://devtools.aitc.dev/launcher/';\n\n/**\n * Options for {@link buildLauncherDeepLink}.\n */\nexport interface BuildLauncherDeepLinkOptions {\n /**\n * `wss://` relay URL for env-2 CDP wiring. When present the deep-link carries\n * `&debug=1&relay=<wss>`.\n */\n relayWssUrl?: string;\n /**\n * Human-readable app name shown in the partner nav bar (`name=` param, #498).\n * Blank / whitespace-only values are not added.\n */\n name?: string;\n /**\n * The miniapp's webViewType. When `'game'`, adds `&navBarType=game` to the\n * deep-link so the launcher enters game nav chrome automatically on scan (#584).\n * `'partner'` (the launcher's implicit default) is not added to keep the URL\n * clean.\n */\n webViewType?: 'partner' | 'game';\n /**\n * Whether the miniapp's navigationBar has `transparentBackground: true`\n * (granite.config `navigationBar.transparentBackground`, SDK 2.8.0, #587).\n * When `true`, adds `&navBarTransparent=1` to the deep-link so the launcher\n * partner bar renders with a transparent background. Omitted when `false` /\n * undefined to keep the URL clean (back-compat).\n */\n navBarTransparent?: boolean;\n /**\n * The miniapp's navigationBar theme (granite.config `navigationBar.theme`,\n * SDK 2.8.0, #587). When `'light'` or `'dark'`, adds `&navBarTheme=<v>` to\n * the deep-link so the launcher partner bar uses the matching foreground colour.\n * Omitted when undefined / other values to keep the URL clean (back-compat).\n */\n navBarTheme?: 'light' | 'dark';\n}\n\n/**\n * Build the deep-link URL that QR codes encode: when the launcher PWA is\n * already on the phone's home screen, scanning this opens it directly into the\n * live view for `tunnelUrl` (the launcher consumes `?url=` and clears it).\n * Plain-text raw URL is no longer enough — the launcher gates its setup UI to\n * the installed PWA, so a raw tunnel URL opened in a normal browser tab would\n * land on a \"please install\" screen.\n *\n * When `opts.relayWssUrl` is given (env-2 CDP wiring), the deep-link also carries\n * `&debug=1&relay=<wss>`; the launcher folds those onto the framed tunnel URL so\n * the in-app debug gate's Layer C (`debug=1` opt-in + `relay=<wss>`) is met and\n * a Chii target.js is injected into the live view.\n *\n * When `opts.name` is given (non-blank), it is added as `&name=` so the launcher\n * partner bar shows the app name instead of the generic default (#498).\n *\n * When `opts.webViewType` is `'game'`, `&navBarType=game` is appended so the\n * launcher enters game nav chrome (floating capsule, no full bar) automatically\n * on scan. `'partner'` is the launcher's implicit default and is not added to\n * keep the URL clean (#584).\n *\n * When `opts.navBarTransparent` is `true`, `&navBarTransparent=1` is appended\n * so the launcher partner bar renders with a transparent background (#587).\n *\n * When `opts.navBarTheme` is `'light'` or `'dark'`, `&navBarTheme=<v>` is\n * appended so the launcher partner bar uses the matching foreground colour (#587).\n *\n * Back-compat: the second argument may also be a plain string (`relayWssUrl`)\n * for callers that haven't migrated to the options object yet.\n */\nexport function buildLauncherDeepLink(\n tunnelUrl: string,\n optsOrRelay?: string | BuildLauncherDeepLinkOptions,\n): string {\n // Normalise the overloaded second argument.\n const opts: BuildLauncherDeepLinkOptions =\n typeof optsOrRelay === 'string' ? { relayWssUrl: optsOrRelay } : (optsOrRelay ?? {});\n\n const base = `${LAUNCHER_URL}?url=${encodeURIComponent(tunnelUrl)}`;\n let url = base;\n if (opts.relayWssUrl) {\n url += `&debug=1&relay=${encodeURIComponent(opts.relayWssUrl)}`;\n }\n if (opts.name !== undefined && opts.name.trim() !== '') {\n url += `&name=${encodeURIComponent(opts.name.trim())}`;\n }\n if (opts.webViewType === 'game') {\n url += '&navBarType=game';\n }\n if (opts.navBarTransparent === true) {\n url += '&navBarTransparent=1';\n }\n if (opts.navBarTheme === 'light' || opts.navBarTheme === 'dark') {\n url += `&navBarTheme=${opts.navBarTheme}`;\n }\n return url;\n}\n\n/**\n * Print the terminal banner announcing the live tunnel: the public URL, an ASCII\n * QR encoding a launcher deep-link, and a one-line note that quick tunnels are\n * ephemeral, unauthenticated and not for production. Pure w.r.t. side effects\n * other than the injected `log` sink and `qrcode-terminal` — unit-tested.\n */\nexport async function printTunnelBanner(\n url: string,\n opts: PrintTunnelBannerOptions = {},\n): Promise<void> {\n const log = opts.log ?? ((m: string) => console.log(m));\n const deepLink = buildLauncherDeepLink(url, {\n relayWssUrl: opts.relayWssUrl,\n name: opts.name,\n webViewType: opts.webViewType,\n navBarTransparent: opts.navBarTransparent,\n navBarTheme: opts.navBarTheme,\n });\n const lines: string[] = [\n '',\n ' ┌─ @ait-co/devtools · live tunnel ────────────────────────────',\n ` │ ${url}`,\n ' │',\n ` │ Install the launcher PWA once: ${LAUNCHER_URL}`,\n ' │ Then scan the QR below — it opens the launcher directly',\n ' │ into this tunnel URL (no manual paste needed).',\n ...(opts.relayWssUrl\n ? [\n ' │ The same scan also attaches CDP — connect your AI host',\n ' │ to the relay and debug the live view on-device.',\n ]\n : []),\n ' │ Quick tunnels are unauthenticated, change every run, and are',\n ' │ not for production use.',\n ' └──────────────────────────────────────────────────────────────',\n '',\n ];\n log(lines.join('\\n'));\n\n if (opts.qr !== false) {\n // qrcode-terminal is only pulled in on this code path (ambient types live\n // in src/qrcode-terminal.d.ts).\n const qrcode = (await import('qrcode-terminal')).default;\n await new Promise<void>((resolve) => {\n qrcode.generate(deepLink, { small: true }, (out) => {\n log(out);\n resolve();\n });\n });\n }\n}\n\n/** Handle returned by {@link startTunnelDashboard}. */\nexport interface TunnelDashboard {\n /** `http://127.0.0.1:<port>` — the local dashboard URL opened in the browser. */\n url: string;\n /** Tear down the local HTTP server. Idempotent via the underlying server. */\n close: () => Promise<void>;\n}\n\nexport interface StartTunnelDashboardOptions {\n /** The public `https://*.trycloudflare.com` app tunnel URL the launcher frames. */\n tunnelUrl: string;\n /** The `wss://` relay URL of the env-2 CDP tunnel. REQUIRED — the dashboard is a CDP-only UX. */\n relayWssUrl: string;\n /** Mirror of `tunnel.qr` — when `false` the dashboard is skipped (no browser open). */\n qr?: boolean;\n /**\n * Override the GUI/opt-out gate (testing only). When omitted the real\n * `canOpenBrowser()` + `AIT_AUTO_DEVTOOLS` checks decide.\n */\n shouldOpen?: () => boolean;\n /** Sink for the one-line \"opened in browser\" note (default: `console.log`). Injected for testing. */\n log?: (msg: string) => void;\n /**\n * Human-readable app name to embed as `name=` in the launcher deep-link (#498).\n * When provided (non-blank), the launcher partner bar shows this name instead of\n * the generic default.\n */\n name?: string;\n}\n\n/**\n * Env-2 UX parity with env 3 (issue #408): when CDP wiring is on and a GUI is\n * available, start the SAME `127.0.0.1` HTML dashboard (QR image + connect steps\n * + FAQ) the debug daemon's `start_attach` path serves, and auto-open it in the\n * browser. headless / opt-out falls back to the terminal ASCII QR (printed\n * separately by {@link printTunnelBanner}).\n *\n * DELEGATED (issue #817): the implementation now lives in `@ait-co/debugger`'s\n * `/dev-bridge` subpath — the one cross-repo code delegation of the package\n * split. The dashboard needs the daemon's QR HTTP server, deep-link builder and\n * TOTP minting, all of which moved into that package; keeping a second copy here\n * would fork them. `@ait-co/debugger` is an OPTIONAL peer, so a consumer who\n * never asks for env-2 CDP installs nothing extra.\n *\n * Why this is not a separate plugin: the relay `wss://` URL must exist BEFORE\n * the QR banner is printed (the launcher QR carries `&relay=`), so the relay and\n * the dashboard are order-dependent and stay one composed call in the dev loop.\n *\n * Degradation: when `@ait-co/debugger` is not installed the import fails and we\n * return `undefined` — exactly the same \"no dashboard\" outcome as a closed GUI\n * gate, with the terminal ASCII QR standing alone. We do NOT fall back to a\n * local copy of the daemon code. The caller (`./index.ts`) prints the install\n * hint once when CDP was requested without the package.\n *\n * SECRET-HANDLING: the tunnel host, relay wssUrl, TOTP code, and `.ait_relay`\n * value/path are NEVER written to stdout/stderr/logs — neither here nor in the\n * delegate. The only thing opened/logged is `http://127.0.0.1:<port>` (local).\n *\n * @returns the dashboard handle when it started (caller wires `close()` into the\n * tunnel cleanup), or `undefined` when skipped (package absent, no relay,\n * `qr:false`, headless, opt-out, or a start failure) — in which case the ASCII\n * QR fallback stands alone.\n */\nexport async function startTunnelDashboard(\n opts: StartTunnelDashboardOptions,\n): Promise<TunnelDashboard | undefined> {\n // Gate: dashboard is a CDP-only UX (needs a relay to attach to). Checked here\n // as well as in the delegate so an absent relay never even probes the package.\n if (!opts.relayWssUrl) return undefined;\n // Opt-out via `tunnel.qr:false` (same toggle that suppresses the ASCII QR).\n if (opts.qr === false) return undefined;\n\n let devBridge: { startTunnelDashboard: typeof startTunnelDashboard };\n try {\n devBridge = (await import(DEBUGGER_DEV_BRIDGE_ID)) as {\n startTunnelDashboard: typeof startTunnelDashboard;\n };\n } catch {\n // Not installed (or an unexpected load failure) — degrade to ASCII QR only.\n // SECRET-HANDLING: the error is not surfaced (it can embed local paths).\n return undefined;\n }\n return devBridge.startTunnelDashboard(opts);\n}\n\nexport interface QuickTunnel {\n /** The public `https://*.trycloudflare.com` URL. */\n url: string;\n /** Stop the underlying `cloudflared` process. Idempotent. */\n stop: () => void;\n}\n\n/**\n * Sanitize cloudflared stderr output for error diagnostics (#421).\n *\n * Masks `*.trycloudflare.com` hostnames and full `https://` / `wss://` URLs\n * that carry those hostnames so tunnel host values never appear in error\n * messages. Diagnostic content (error codes, reasons, JSON blobs) is preserved.\n *\n * SECRET-HANDLING: tunnel host is SECRET-class per harness policy — only\n * placeholder text is emitted.\n */\nexport function sanitizeCloudflaredOutput(line: string): string {\n // Full URL forms: https://xxx.trycloudflare.com/… and wss://xxx.trycloudflare.com/…\n let s = line.replace(/(?:https?|wss?):\\/\\/[a-z0-9-]+\\.trycloudflare\\.com(?:\\/[^\\s]*)*/gi, (m) =>\n m.replace(/[a-z0-9-]+\\.trycloudflare\\.com/i, '<HOST>.trycloudflare.com'),\n );\n // Bare hostname without scheme (e.g. printed in cloudflared JSON logs)\n s = s.replace(/[a-z0-9-]+\\.trycloudflare\\.com/gi, '<HOST>.trycloudflare.com');\n return s;\n}\n\nconst URL_TIMEOUT_MS = 20_000;\n\n/**\n * Start an unauthenticated Cloudflare quick tunnel to `http://localhost:<port>`\n * and resolve once the public URL is known. Downloads the `cloudflared` binary\n * on first use if it is not already installed. Rejects with a friendly error if\n * no URL appears within {@link URL_TIMEOUT_MS}.\n */\nexport async function startQuickTunnel(port: number): Promise<QuickTunnel> {\n const cloudflared = await import('cloudflared');\n const { bin, install, Tunnel } = cloudflared;\n\n if (!existsSync(bin)) {\n await mkdir(dirname(bin), { recursive: true });\n await install(bin);\n }\n\n const tunnel = Tunnel.quick(`http://localhost:${port}`);\n let stopped = false;\n const stop = () => {\n if (stopped) return;\n stopped = true;\n try {\n tunnel.stop();\n } catch {\n // process may already be gone\n }\n };\n\n return new Promise<QuickTunnel>((resolve, reject) => {\n // #421: accumulate stderr to attach as diagnostics on failure.\n // SECRET-HANDLING: lines are sanitized before inclusion in error messages.\n const stderrLines: string[] = [];\n\n /**\n * Format the last `n` sanitized stderr lines as a diagnostic appendix.\n * Returns an empty string when no lines have been collected.\n */\n const stderrTail = (n = 15): string => {\n if (stderrLines.length === 0) return '';\n const tail = stderrLines.slice(-n).map(sanitizeCloudflaredOutput).join('');\n return `\\ncloudflared 출력 (마지막 ${Math.min(n, stderrLines.length)}줄):\\n${tail}`;\n };\n\n const timer = setTimeout(() => {\n cleanup();\n stop();\n reject(\n new Error(\n `[@ait-co/devtools] cloudflared did not report a tunnel URL within ${\n URL_TIMEOUT_MS / 1000\n }s. Check your network connection, or run \\`cloudflared tunnel --url http://localhost:${port}\\` manually.${stderrTail()}`,\n ),\n );\n }, URL_TIMEOUT_MS);\n\n const onUrl = (line: string) => {\n const found = parseTrycloudflareUrl(line);\n if (!found) return;\n clearTimeout(timer);\n // Stop scanning further output once we have the URL.\n cleanup();\n resolve({ url: found, stop });\n };\n\n // Accumulate stderr lines for diagnostics (#421). Named so it can be\n // removed from the listener list when cleanup() runs.\n const pushStderr = (line: string) => {\n stderrLines.push(line);\n };\n\n const cleanup = () => {\n tunnel.off('stdout', onUrl);\n tunnel.off('stderr', onUrl);\n tunnel.off('stderr', pushStderr);\n };\n\n // The library emits a parsed `url` event; we also scan raw stdout/stderr in\n // case the output format shifts.\n tunnel.once('url', onUrl);\n tunnel.on('stdout', onUrl);\n tunnel.on('stderr', onUrl);\n // Second stderr listener: accumulate all lines for error diagnostics.\n tunnel.on('stderr', pushStderr);\n tunnel.once('error', (err: Error) => {\n clearTimeout(timer);\n cleanup();\n stop();\n reject(err);\n });\n tunnel.once('exit', (code: number | null) => {\n if (stopped) return;\n clearTimeout(timer);\n cleanup();\n reject(\n new Error(\n `[@ait-co/devtools] cloudflared exited (code ${code ?? 'null'}) before reporting a tunnel URL.${stderrTail()}`,\n ),\n );\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,yBAAyB;;;;;;;;;;;;;;;AChBtC,MAAM,mBAAmB;;;;;;AAOzB,SAAgB,sBAAsB,MAA6B;CACjE,MAAM,IAAI,KAAK,MAAM,iBAAiB;AACtC,QAAO,IAAI,EAAE,KAAK;;AA6CpB,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsErB,SAAgB,sBACd,WACA,aACQ;CAER,MAAM,OACJ,OAAO,gBAAgB,W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,KAAK;;EAGxB,MAAM,gBAAgB;AACpB,UAAO,IAAI,UAAU,MAAM;AAC3B,UAAO,IAAI,UAAU,MAAM;AAC3B,UAAO,IAAI,UAAU,WAAW;;AAKlC,SAAO,KAAK,OAAO,MAAM;AACzB,SAAO,GAAG,UAAU,MAAM;AAC1B,SAAO,GAAG,UAAU,MAAM;AAE1B,SAAO,GAAG,UAAU,WAAW;AAC/B,SAAO,KAAK,UAAU,QAAe;AACnC,gBAAa,MAAM;AACnB,YAAS;AACT,SAAM;AACN,UAAO,IAAI;IACX;AACF,SAAO,KAAK,SAAS,SAAwB;AAC3C,OAAI,QAAS;AACb,gBAAa,MAAM;AACnB,YAAS;AACT,0BACE,IAAI,MACF,+CAA+C,QAAQ,OAAO,kCAAkC,YAAY,GAC7G,CACF;IACD;GACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ait-co/devtools",
3
- "version": "0.1.143",
4
- "description": "Development tools for Apps in Toss mini-apps — mock SDK, floating devtools panel, and universal bundler plugin",
3
+ "version": "0.2.0",
4
+ "description": "Browser development tools for Apps in Toss mini-apps — mock SDK, floating devtools panel, and universal bundler plugin. devDependency only; contributes nothing to a production bundle",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=24"
@@ -48,35 +48,36 @@
48
48
  }
49
49
  },
50
50
  "bin": {
51
- "devtools-mcp": "./dist/mcp/cli.js",
52
- "devtools-test": "./dist/test-runner/bin.js"
51
+ "devtools-mcp": "./dist/stubs/bin-devtools-mcp.js",
52
+ "devtools-test": "./dist/stubs/bin-devtools-test.js"
53
53
  },
54
54
  "files": [
55
55
  "dist"
56
56
  ],
57
57
  "peerDependencies": {
58
+ "@ait-co/debug-console": "^0.1.0",
59
+ "@ait-co/debugger": "^0.1.3",
58
60
  "@apps-in-toss/web-framework": ">=2.6.0 <3.0.0"
59
61
  },
60
62
  "peerDependenciesMeta": {
63
+ "@ait-co/debug-console": {
64
+ "optional": true
65
+ },
66
+ "@ait-co/debugger": {
67
+ "optional": true
68
+ },
61
69
  "@apps-in-toss/web-framework": {
62
70
  "optional": true
63
71
  }
64
72
  },
65
73
  "dependencies": {
66
- "@modelcontextprotocol/sdk": "^1.29.0",
67
- "@vitest/expect": "^4.1.9",
68
- "@vitest/runner": "^4.1.9",
69
- "ajv": "^8.20.0",
70
- "chii": "^1.15.5",
71
74
  "cloudflared": "^0.7.1",
72
- "eruda": "^3.4.3",
73
- "esbuild": "^0.28.1",
74
- "qrcode": "^1.5.4",
75
75
  "qrcode-terminal": "^0.12.0",
76
- "unplugin": "^3.2.0",
77
- "ws": "^8.21.0"
76
+ "unplugin": "^3.2.0"
78
77
  },
79
78
  "devDependencies": {
79
+ "@ait-co/debug-console": "^0.1.3",
80
+ "@ait-co/debugger": "^0.1.3",
80
81
  "@ait-co/polyfill": "^0.1.17",
81
82
  "@apps-in-toss/web-framework": "3.0.0-beta.3051978",
82
83
  "@apps-in-toss/web-framework-2x": "npm:@apps-in-toss/web-framework@2.10.7",
@@ -86,11 +87,9 @@
86
87
  "@playwright/test": "^1.61.1",
87
88
  "@testing-library/dom": "^10.4.1",
88
89
  "@testing-library/react": "^16.3.0",
89
- "@types/qrcode": "^1.5.6",
90
90
  "@types/qrcode-terminal": "^0.12.2",
91
91
  "@types/react": "^19.2.17",
92
92
  "@types/react-dom": "^19.2.3",
93
- "@types/ws": "^8.18.0",
94
93
  "@vitejs/plugin-react": "^6.0.3",
95
94
  "jsdom": "^29.1.1",
96
95
  "qr-scanner": "^1.4.2",
@@ -130,12 +129,8 @@
130
129
  "url": "https://github.com/apps-in-toss-community/devtools/issues"
131
130
  },
132
131
  "scripts": {
133
- "build:dashboard-html": "tsx --tsconfig scripts/tsconfig.json scripts/build-dashboard-html.ts",
134
- "build": "pnpm build:dashboard-html && tsdown",
135
- "check:mcp-react-free": "bash scripts/check-mcp-react-free.sh",
136
- "check:test-runner-dist": "bash scripts/check-test-runner-dist.sh",
137
- "check:debug-surface-absent": "bash scripts/check-debug-surface-absent.sh",
138
- "check:dashboard-html-fresh": "pnpm build:dashboard-html && git diff --exit-code src/mcp/dashboard.generated.ts",
132
+ "build": "tsdown",
133
+ "check:footprint-absent": "bash scripts/check-devtools-footprint-absent.sh",
139
134
  "dev": "tsdown --watch",
140
135
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.2x.json && tsc --noEmit -p e2e/fixture/tsconfig.json && tsc --noEmit -p scripts/tsconfig.json",
141
136
  "test": "vitest run",