github-router 0.3.373 → 0.3.374

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 (151) hide show
  1. package/dist/ado-tools-BOW1k1KW.js +1 -0
  2. package/dist/{aic-ledger-Cp7Yk9-Q.js → aic-ledger-CeSXqTEE.js} +5 -7
  3. package/dist/{aic-ledger-Cp7Yk9-Q.js.map → aic-ledger-CeSXqTEE.js.map} +1 -1
  4. package/dist/{aic-statusline-settings-B5EMMSFC.js → aic-statusline-settings-BKveu679.js} +3 -4
  5. package/dist/{aic-statusline-settings-B5EMMSFC.js.map → aic-statusline-settings-BKveu679.js.map} +1 -1
  6. package/dist/{attribution-settings-DZ8fEfvP.js → attribution-settings-BLTnz2_A.js} +33 -53
  7. package/dist/{attribution-settings-DZ8fEfvP.js.map → attribution-settings-BLTnz2_A.js.map} +1 -1
  8. package/dist/{auth-B1egtvt4.js → auth-BZHpTtfF.js} +5 -6
  9. package/dist/{auth-B1egtvt4.js.map → auth-BZHpTtfF.js.map} +1 -1
  10. package/dist/{balanced-profile-contract-Dm_usmw7.js → balanced-profile-contract-B6pSoWjm.js} +2 -3
  11. package/dist/{balanced-profile-contract-Dm_usmw7.js.map → balanced-profile-contract-B6pSoWjm.js.map} +1 -1
  12. package/dist/{bluebird-client-ByCRusGQ.js → bluebird-client-BasIdv5J.js} +8 -12
  13. package/dist/{bluebird-client-ByCRusGQ.js.map → bluebird-client-BasIdv5J.js.map} +1 -1
  14. package/dist/{bluebird-client-CY6NBHQu.js → bluebird-client-BvoMTmEv.js} +1 -1
  15. package/dist/browser-bridge/index.js +84 -55
  16. package/dist/browser-ext/manifest.json +1 -1
  17. package/dist/{check-usage-T_z84Pgc.js → check-usage-BlIWDuV2.js} +5 -6
  18. package/dist/{check-usage-T_z84Pgc.js.map → check-usage-BlIWDuV2.js.map} +1 -1
  19. package/dist/{claude-8ksmV0dC.js → claude-DSXrdz0v.js} +37 -43
  20. package/dist/{claude-8ksmV0dC.js.map → claude-DSXrdz0v.js.map} +1 -1
  21. package/dist/{claude-md-injection-BnzVv_aB.js → claude-md-injection-DU5KYXNc.js} +6 -7
  22. package/dist/{claude-md-injection-BnzVv_aB.js.map → claude-md-injection-DU5KYXNc.js.map} +1 -1
  23. package/dist/{client-CQMfroGV.js → client-Bjp3XAMK.js} +3 -5
  24. package/dist/{client-CQMfroGV.js.map → client-Bjp3XAMK.js.map} +1 -1
  25. package/dist/{codex-C89FoaaG.js → codex-DGMUk65v.js} +10 -11
  26. package/dist/{codex-C89FoaaG.js.map → codex-DGMUk65v.js.map} +1 -1
  27. package/dist/{copilot-discount-T-cfWmc4.js → copilot-discount-CHNQLYDJ.js} +3 -4
  28. package/dist/{copilot-discount-T-cfWmc4.js.map → copilot-discount-CHNQLYDJ.js.map} +1 -1
  29. package/dist/{debug-DL2JsRqY.js → debug-1HUHCWFl.js} +3 -4
  30. package/dist/{debug-DL2JsRqY.js.map → debug-1HUHCWFl.js.map} +1 -1
  31. package/dist/engine-BC4TF4pt.js +1 -0
  32. package/dist/{exec-Bf8g_bIR.js → exec-BC0MAnoA.js} +2 -3
  33. package/dist/{exec-Bf8g_bIR.js.map → exec-BC0MAnoA.js.map} +1 -1
  34. package/dist/{fast-profile-contract-JOnZBgFB.js → fast-profile-contract-BLnKg0Ay.js} +2 -3
  35. package/dist/{fast-profile-contract-JOnZBgFB.js.map → fast-profile-contract-BLnKg0Ay.js.map} +1 -1
  36. package/dist/{gate-discovery-Bc9FdRwg.js → gate-discovery-DiXu_olc.js} +8 -10
  37. package/dist/{gate-discovery-Bc9FdRwg.js.map → gate-discovery-DiXu_olc.js.map} +1 -1
  38. package/dist/{get-copilot-usage-BSXeQEx8.js → get-copilot-usage-CKg42gSH.js} +5 -6
  39. package/dist/{get-copilot-usage-BSXeQEx8.js.map → get-copilot-usage-CKg42gSH.js.map} +1 -1
  40. package/dist/{hook-mcp-client-DERIkeR7.js → hook-mcp-client-CYx10nlU.js} +2 -3
  41. package/dist/hook-mcp-client-CYx10nlU.js.map +1 -0
  42. package/dist/hooks.mjs +1766 -1548
  43. package/dist/hooks.sha256 +1 -1
  44. package/dist/{index-cmd-DOhwt92u.js → index-cmd-BPXhTfGQ.js} +8 -9
  45. package/dist/index-cmd-BPXhTfGQ.js.map +1 -0
  46. package/dist/{internal-aic-status-CY0QxSa7.js → internal-aic-status-FQB1DQzX.js} +6 -8
  47. package/dist/{internal-aic-status-CY0QxSa7.js.map → internal-aic-status-FQB1DQzX.js.map} +1 -1
  48. package/dist/{internal-artifact-open-NAGn9Mgt.js → internal-artifact-open-DbHjipxU.js} +5 -7
  49. package/dist/{internal-artifact-open-NAGn9Mgt.js.map → internal-artifact-open-DbHjipxU.js.map} +1 -1
  50. package/dist/{internal-fast-dispatch-guard-De_DJOyZ.js → internal-fast-dispatch-guard-DMzqs-r8.js} +1 -1
  51. package/dist/{internal-fast-dispatch-guard-_n-A8hgo.js → internal-fast-dispatch-guard-PDdlkPU3.js} +6 -8
  52. package/dist/{internal-fast-dispatch-guard-_n-A8hgo.js.map → internal-fast-dispatch-guard-PDdlkPU3.js.map} +1 -1
  53. package/dist/{internal-first-mate-guard-GufCUMl3.js → internal-first-mate-guard-4Yro9xNM.js} +5 -7
  54. package/dist/{internal-first-mate-guard-GufCUMl3.js.map → internal-first-mate-guard-4Yro9xNM.js.map} +1 -1
  55. package/dist/{internal-first-mate-guard-C8GwLbaX.js → internal-first-mate-guard-BxPDUsV3.js} +1 -1
  56. package/dist/{internal-max-dispatch-guard-4rh6KSd8.js → internal-max-dispatch-guard-D3L00YXj.js} +5 -7
  57. package/dist/{internal-max-dispatch-guard-4rh6KSd8.js.map → internal-max-dispatch-guard-D3L00YXj.js.map} +1 -1
  58. package/dist/{internal-max-dispatch-guard-CKnzgJje.js → internal-max-dispatch-guard-fhBX_w49.js} +1 -1
  59. package/dist/{internal-plan-review-ChFx8wTX.js → internal-plan-review-BfHLeszV.js} +6 -7
  60. package/dist/{internal-plan-review-ChFx8wTX.js.map → internal-plan-review-BfHLeszV.js.map} +1 -1
  61. package/dist/{internal-prompt-submit-BW5g3MjD.js → internal-prompt-submit-BbnaMF2R.js} +7 -8
  62. package/dist/{internal-prompt-submit-BW5g3MjD.js.map → internal-prompt-submit-BbnaMF2R.js.map} +1 -1
  63. package/dist/{internal-prompt-submit-C4uDwr7G.js → internal-prompt-submit-DKzCckz-.js} +2 -2
  64. package/dist/{internal-rebrief-DvBS8myn.js → internal-rebrief-aEvxp7jw.js} +7 -9
  65. package/dist/{internal-rebrief-DvBS8myn.js.map → internal-rebrief-aEvxp7jw.js.map} +1 -1
  66. package/dist/{internal-session-bind-dsUOcKxU.js → internal-session-bind-pN1V11Mn.js} +3 -4
  67. package/dist/{internal-session-bind-dsUOcKxU.js.map → internal-session-bind-pN1V11Mn.js.map} +1 -1
  68. package/dist/{internal-stop-hook-nS91Jkda.js → internal-stop-hook-VQuOYpUC.js} +9 -10
  69. package/dist/{internal-stop-hook-nS91Jkda.js.map → internal-stop-hook-VQuOYpUC.js.map} +1 -1
  70. package/dist/{internal-stop-review-D_KEV_04.js → internal-stop-review-BWp-4XWW.js} +4 -5
  71. package/dist/{internal-stop-review-D_KEV_04.js.map → internal-stop-review-BWp-4XWW.js.map} +1 -1
  72. package/dist/{internal-worker-guard-DB6shBIn.js → internal-worker-guard-C9OZPgzu.js} +3 -4
  73. package/dist/{internal-worker-guard-DB6shBIn.js.map → internal-worker-guard-C9OZPgzu.js.map} +1 -1
  74. package/dist/{internal-workspace-header-DBg5Y7oN.js → internal-workspace-header-B4TXFBLU.js} +3 -4
  75. package/dist/{internal-workspace-header-DBg5Y7oN.js.map → internal-workspace-header-B4TXFBLU.js.map} +1 -1
  76. package/dist/lib/tree-sitter-pool/{lifecycle-Dx0SnP7Z.js → lifecycle-BPpOigPZ.js} +1 -2
  77. package/dist/lib/tree-sitter-pool/{lifecycle-C7W8D2lx.js → lifecycle-C3vsqXjS.js} +1 -3
  78. package/dist/lib/tree-sitter-pool/worker.js +29 -35
  79. package/dist/lifecycle-BENRuuX6.js +1 -0
  80. package/dist/{lifecycle-K9oVtGde.mjs → lifecycle-DBKu1T5r.mjs} +0 -1
  81. package/dist/{lifecycle-Gge2Dadd.js → lifecycle-Dh9y8OF1.js} +3 -4
  82. package/dist/{lifecycle-Gge2Dadd.js.map → lifecycle-Dh9y8OF1.js.map} +1 -1
  83. package/dist/lifecycle-Dli9vGI2.js +1 -0
  84. package/dist/{lifecycle-9nX09dBl.js → lifecycle-vjHAFCaY.js} +4 -6
  85. package/dist/{lifecycle-9nX09dBl.js.map → lifecycle-vjHAFCaY.js.map} +1 -1
  86. package/dist/main.js +26 -27
  87. package/dist/{max-profile-contract-CRj7N211.js → max-profile-contract-DLLTsSs2.js} +5 -8
  88. package/dist/{max-profile-contract-CRj7N211.js.map → max-profile-contract-DLLTsSs2.js.map} +1 -1
  89. package/dist/{mcp-workspace-header-Xw9B1W6T.js → mcp-workspace-header-C5-dOWNa.js} +3 -4
  90. package/dist/{mcp-workspace-header-Xw9B1W6T.js.map → mcp-workspace-header-C5-dOWNa.js.map} +1 -1
  91. package/dist/{models-Ca-HQTYi.js → models-B6nH1sS6.js} +4 -5
  92. package/dist/{models-Ca-HQTYi.js.map → models-B6nH1sS6.js.map} +1 -1
  93. package/dist/{orchestration-D3-2ulhX.js → orchestration-B93jxrWI.js} +4 -5
  94. package/dist/{orchestration-D3-2ulhX.js.map → orchestration-B93jxrWI.js.map} +1 -1
  95. package/dist/{package-root-B-osctCk.js → package-root-BXgdIM3q.js} +2 -3
  96. package/dist/{package-root-B-osctCk.js.map → package-root-BXgdIM3q.js.map} +1 -1
  97. package/dist/paths-Be9_ujQ3.js +1 -0
  98. package/dist/{paths-C5477RGC.js → paths-CVEO8jEH.js} +5 -7
  99. package/dist/{paths-C5477RGC.js.map → paths-CVEO8jEH.js.map} +1 -1
  100. package/dist/{peer-mcp-personas-BSxDj9sJ.js → peer-mcp-personas-Cv21q_YR.js} +244 -372
  101. package/dist/peer-mcp-personas-Cv21q_YR.js.map +1 -0
  102. package/dist/{pi-BglhJ6n_.js → pi-DI2QtaiZ.js} +26 -34
  103. package/dist/{pi-BglhJ6n_.js.map → pi-DI2QtaiZ.js.map} +1 -1
  104. package/dist/{pi-memory-bridge-DEU1SUDz.js → pi-memory-bridge-Dvj1T3e3.js} +2 -3
  105. package/dist/{pi-memory-bridge-DEU1SUDz.js.map → pi-memory-bridge-Dvj1T3e3.js.map} +1 -1
  106. package/dist/{plan-review-hook-C9K-em4D.js → plan-review-hook-MhjK92wq.js} +5 -6
  107. package/dist/{plan-review-hook-C9K-em4D.js.map → plan-review-hook-MhjK92wq.js.map} +1 -1
  108. package/dist/{provision-B0GNohdl.js → provision-CRmtV6ew.js} +10 -14
  109. package/dist/{provision-B0GNohdl.js.map → provision-CRmtV6ew.js.map} +1 -1
  110. package/dist/rolldown-runtime-D3PmRqjj.js +4 -0
  111. package/dist/{self-invocation-BtcGj-lY.js → self-invocation-DMUnXVGT.js} +5 -7
  112. package/dist/{self-invocation-BtcGj-lY.js.map → self-invocation-DMUnXVGT.js.map} +1 -1
  113. package/dist/{serve-BxZq9vNl.js → serve-DRASJ-ZO.js} +24 -30
  114. package/dist/{serve-BxZq9vNl.js.map → serve-DRASJ-ZO.js.map} +1 -1
  115. package/dist/{server-setup-BLdWCcby.js → server-setup-DldGizZR.js} +67 -117
  116. package/dist/{server-setup-BLdWCcby.js.map → server-setup-DldGizZR.js.map} +1 -1
  117. package/dist/{service-backend-BV2hHjuB.js → service-backend-Ce6b2XEe.js} +112 -130
  118. package/dist/service-backend-Ce6b2XEe.js.map +1 -0
  119. package/dist/{start-C3Zb8XMT.js → start-C0gngUPK.js} +6 -8
  120. package/dist/{start-C3Zb8XMT.js.map → start-C0gngUPK.js.map} +1 -1
  121. package/dist/{state-DzsaGHr9.js → state-CCGDJ43X.js} +2 -3
  122. package/dist/{state-DzsaGHr9.js.map → state-CCGDJ43X.js.map} +1 -1
  123. package/dist/{static-context-pack-CsOAC87F.js → static-context-pack-DwC69_VA.js} +14 -24
  124. package/dist/{static-context-pack-CsOAC87F.js.map → static-context-pack-DwC69_VA.js.map} +1 -1
  125. package/dist/{stop-gate-hook-DnLC09Lg.js → stop-gate-hook-CBVLD8iB.js} +9 -14
  126. package/dist/{stop-gate-hook-DnLC09Lg.js.map → stop-gate-hook-CBVLD8iB.js.map} +1 -1
  127. package/dist/{stop-gate-policy-Dx9c98_d.js → stop-gate-policy-BehNiNix.js} +4 -5
  128. package/dist/{stop-gate-policy-Dx9c98_d.js.map → stop-gate-policy-BehNiNix.js.map} +1 -1
  129. package/dist/{token-Dqjs5ixP.js → token-CPzYxU4Y.js} +16 -28
  130. package/dist/{token-Dqjs5ixP.js.map → token-CPzYxU4Y.js.map} +1 -1
  131. package/dist/{token-CVG0yI_j.js → token-DHEkiO4g.js} +3 -4
  132. package/dist/{token-CVG0yI_j.js.map → token-DHEkiO4g.js.map} +1 -1
  133. package/dist/{upstream-retry-i1k1Xai2.js → upstream-retry-VNR-bCuT.js} +2 -3
  134. package/dist/{upstream-retry-i1k1Xai2.js.map → upstream-retry-VNR-bCuT.js.map} +1 -1
  135. package/dist/{version-C8x2hQrZ.js → version-CTqwKr26.js} +3 -4
  136. package/dist/{version-C8x2hQrZ.js.map → version-CTqwKr26.js.map} +1 -1
  137. package/dist/{worker-dispatch-B1w2qfjX.js → worker-dispatch-C7RtNOXv.js} +3 -4
  138. package/dist/{worker-dispatch-B1w2qfjX.js.map → worker-dispatch-C7RtNOXv.js.map} +1 -1
  139. package/dist/{workiq-qnJR5_n2.js → workiq-CQauEAMc.js} +3 -4
  140. package/dist/{workiq-qnJR5_n2.js.map → workiq-CQauEAMc.js.map} +1 -1
  141. package/dist/{workiq-tools-C6LAF_vA.js → workiq-tools-7n2xXMrQ.js} +1 -1
  142. package/package.json +18 -15
  143. package/dist/ado-tools-WDyisN8w.js +0 -1
  144. package/dist/engine-C207cikp.js +0 -1
  145. package/dist/hook-mcp-client-DERIkeR7.js.map +0 -1
  146. package/dist/index-cmd-DOhwt92u.js.map +0 -1
  147. package/dist/lifecycle-C_CT13c9.js +0 -1
  148. package/dist/lifecycle-DibiH857.js +0 -1
  149. package/dist/paths-CEswtFj5.js +0 -1
  150. package/dist/peer-mcp-personas-BSxDj9sJ.js.map +0 -1
  151. package/dist/service-backend-BV2hHjuB.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { t as PACKAGE_ROOT_FLAG } from "./package-root-B-osctCk.js";
2
- import { t as PATHS } from "./paths-C5477RGC.js";
1
+ import { t as PACKAGE_ROOT_FLAG } from "./package-root-BXgdIM3q.js";
2
+ import { t as PATHS } from "./paths-CVEO8jEH.js";
3
3
  import consola from "consola";
4
4
  import { chmodSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { createHash } from "node:crypto";
8
8
  import os from "node:os";
9
- //#region src/lib/hook-launcher/provision.ts
9
+ // src/lib/hook-launcher/provision.ts
10
10
  /**
11
11
  * Publish the self-contained hook launcher (`dist/hooks.mjs`) to a stable,
12
12
  * content-addressed path under `<APP_DIR>/hooks/`.
@@ -236,8 +236,7 @@ function publishLauncherFrom(bundlePath) {
236
236
  return;
237
237
  }
238
238
  }
239
- //#endregion
240
- //#region src/lib/hook-launcher/self-invocation.ts
239
+ // src/lib/hook-launcher/self-invocation.ts
241
240
  /**
242
241
  * How this process names ITSELF in a command string that gets persisted to
243
242
  * disk and executed later by someone else.
@@ -374,7 +373,6 @@ function realpathIfPossible(p) {
374
373
  return p;
375
374
  }
376
375
  }
377
- //#endregion
378
376
  export { hookLauncherDegradedWarning as n, resolveSelfInvocation as r, buildSelfCommand as t };
379
377
 
380
- //# sourceMappingURL=self-invocation-BtcGj-lY.js.map
378
+ //# sourceMappingURL=self-invocation-DMUnXVGT.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"self-invocation-BtcGj-lY.js","names":[],"sources":["../src/lib/hook-launcher/provision.ts","../src/lib/hook-launcher/self-invocation.ts"],"sourcesContent":["/**\n * Publish the self-contained hook launcher (`dist/hooks.mjs`) to a stable,\n * content-addressed path under `<APP_DIR>/hooks/`.\n *\n * Why this exists: `github-router claude` persists Claude Code hook commands\n * into a settings.json that outlives the process that wrote it, built from\n * `process.argv[1]`. Under `bunx` that path is inside `$TMPDIR`, and macOS's\n * per-user temp reaper deletes files there (keeping the directory skeleton) —\n * so `node <tmp>/…/dist/main.js` died on its first bare import with\n * `ERR_MODULE_NOT_FOUND` and EVERY hook in a long-running session failed until\n * the tree happened to be re-extracted. `bunx pkg@latest` also re-extracts in\n * place whenever npm's `latest` advances, so a live session's hooks could\n * silently start executing a different version's code.\n *\n * Deliberate departures from `provisionBrowserAssets()`, which this otherwise\n * mirrors:\n *\n * - **Content-addressed, immutable names.** The digest IS the filename, so a\n * new build never overwrites an old launcher and there is nothing to\n * garbage-collect. Version-keyed names would need GC, and GC across\n * concurrent proxies is a race: proxy N deleting N+1's launcher (or the\n * reverse) breaks a live session's hooks. At ~1.5 MB, keeping stale\n * launchers costs less than the race would.\n *\n * - **The source is verified before it is published.** Hashing the bytes\n * read from `dist/hooks.mjs` only identifies those bytes; it does not\n * prove they are a complete artifact. A concurrent in-place `bunx`\n * extraction can hand over a truncated file, which content-addressing\n * would happily preserve forever under its own hash. The build writes a\n * `dist/hooks.sha256` sidecar and we publish only on a match.\n *\n * - **Failures are not latched.** A transient `EBUSY` (Windows antivirus, a\n * concurrent reader) must not disable provisioning for the process\n * lifetime, so only success is cached.\n *\n * Never throws: the caller degrades to `process.argv[1]` with a visible\n * warning rather than failing the launch.\n */\n\nimport { createHash } from \"node:crypto\"\nimport {\n chmodSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n utimesSync,\n writeFileSync,\n} from \"node:fs\"\nimport path from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport consola from \"consola\"\n\nimport { PATHS } from \"../paths\"\n\n/** Sidecar written by `scripts/stamp-hooks-digest.ts` next to the bundle. */\nconst DIGEST_SIDECAR = \"hooks.sha256\"\n\n/** Basename of the built launcher bundle. */\nconst BUNDLE_NAME = \"hooks.mjs\"\n\n/**\n * Publish retries. A rename can lose a race with another proxy publishing the\n * same digest, or hit a Windows sharing violation while an antivirus scanner\n * holds the temp file. Both clear in milliseconds.\n */\nconst PUBLISH_ATTEMPTS = 3\n\nlet _published: string | undefined\nlet _inFlight: Promise<string | undefined> | undefined\n\n/** @internal — reset module state between test cases. */\nexport function __resetHookLauncherForTests(): void {\n _published = undefined\n _inFlight = undefined\n}\n\n/**\n * Resolve the built bundle that sits beside the running code.\n *\n * In a built layout every chunk lives in `dist/`, so a sibling lookup finds\n * `dist/hooks.mjs`. Running from source it resolves to\n * `src/lib/hook-launcher/hooks.mjs`, which does not exist — which is exactly\n * the wanted behaviour: a `bun run dev` session must keep using\n * `process.argv[1]` rather than silently adopting a stale bundle from some\n * earlier build.\n */\nfunction bundledLauncherPath(): string | undefined {\n try {\n return path.join(path.dirname(fileURLToPath(import.meta.url)), BUNDLE_NAME)\n } catch {\n return undefined\n }\n}\n\nfunction sha256(buf: Buffer): string {\n return createHash(\"sha256\").update(buf).digest(\"hex\")\n}\n\n/**\n * Read the build's expected digest. Absent or malformed means \"cannot verify\",\n * which is treated as a refusal to publish rather than as permission to skip\n * the check — an unverified source is the one thing content-addressing cannot\n * recover from.\n */\nfunction expectedDigest(bundlePath: string): string | undefined {\n try {\n const raw = readFileSync(\n path.join(path.dirname(bundlePath), DIGEST_SIDECAR),\n \"utf8\",\n ).trim()\n return /^[0-9a-f]{64}$/.test(raw) ? raw : undefined\n } catch {\n return undefined\n }\n}\n\n/** True when `target` already holds exactly the bytes its name claims. */\nfunction targetIsValid(target: string, digest: string): boolean {\n try {\n return sha256(readFileSync(target)) === digest\n } catch {\n return false\n }\n}\n\n/**\n * Write `bytes` to `target` via a unique same-directory temp file plus a\n * rename, so a crash mid-write can never leave a partial file under the name\n * a hook command points at.\n *\n * The target is never deleted first: on Windows that would open a window where\n * a concurrently-launching session finds no launcher at all. A rename onto an\n * existing path can fail there, so a losing racer validates what the winner\n * wrote and accepts it.\n */\nfunction publish(target: string, bytes: Buffer, digest: string): boolean {\n // Checked once up front rather than per attempt: validation re-hashes ~1.5 MB\n // and the retries exist for rename contention, which revalidating cannot fix.\n if (targetIsValid(target, digest)) return true\n for (let attempt = 0; attempt < PUBLISH_ATTEMPTS; attempt++) {\n const tmp = `${target}.${process.pid}-${attempt}.tmp`\n try {\n writeFileSync(tmp, bytes, { mode: 0o600 })\n renameSync(tmp, target)\n return true\n } catch {\n try {\n rmSync(tmp, { force: true })\n } catch {\n // Best-effort. A Windows sharing violation can strand the temp file;\n // `sweepStaleLaunchers` reaps it later rather than leaking 1.5 MB.\n }\n }\n }\n return targetIsValid(target, digest)\n}\n\n/** A stranded publish temp is dead well inside this. */\nconst TMP_MAX_AGE_MS = 24 * 60 * 60 * 1000\n\n/**\n * Launchers older than this are reaped. Generous on purpose — see the residual\n * risk in `sweepStaleLaunchers`.\n */\nconst LAUNCHER_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000\n\n/**\n * Reap stranded publish temps and long-unused launchers.\n *\n * Without this the directory grows by ~1.5 MB per shipped version forever, and\n * this project ships a patch release per PR with self-update on by default.\n *\n * The immutable content-addressed naming exists to avoid a GC race, so the\n * sweep is built to not reintroduce one: it never touches the digest THIS\n * launch resolved, and every launch refreshes its own launcher's mtime, so a\n * file survives for as long as some proxy keeps launching against it. Residual\n * risk, stated plainly: a single proxy running continuously for more than 30\n * days without relaunching could have its launcher reaped by a newer proxy.\n * That is bounded and far rarer than the unbounded growth it prevents, but it\n * is not zero — a PID-liveness marker would close it if it ever bites.\n */\nfunction sweepStaleLaunchers(dir: string, keep: string): void {\n const now = Date.now()\n let entries: Array<string>\n try {\n entries = readdirSync(dir)\n } catch {\n return\n }\n for (const name of entries) {\n if (name === path.basename(keep)) continue\n const isTmp = name.endsWith(\".tmp\")\n // Strict shape match, like sweepAgedWorkerDiffs: this directory is ours,\n // but a name-shape check means a false positive can only ever cost a file\n // the next launch regenerates.\n const isLauncher = /^hooks-[0-9a-f]{64}\\.mjs$/.test(name)\n if (!isTmp && !isLauncher) continue\n const target = path.join(dir, name)\n try {\n const age = now - statSync(target).mtimeMs\n if (age > (isTmp ? TMP_MAX_AGE_MS : LAUNCHER_MAX_AGE_MS)) {\n rmSync(target, { force: true })\n }\n } catch {\n /* best-effort */\n }\n }\n}\n\n/**\n * Materialize the launcher and return its stable absolute path, or undefined\n * when it could not be published (running from source, bundle missing or\n * unverifiable, filesystem refusing the write).\n *\n * Single-flight so the startup call and any lazy caller collapse to one run.\n */\nexport function provisionHookLauncher(): Promise<string | undefined> {\n if (_published) return Promise.resolve(_published)\n if (_inFlight) return _inFlight\n _inFlight = Promise.resolve()\n .then(() => provisionImpl())\n .then((result) => {\n // Cache SUCCESS only. Latching a transient failure would disable the\n // stable launcher for the whole process lifetime.\n if (result) _published = result\n return result\n })\n .finally(() => {\n _inFlight = undefined\n })\n return _inFlight\n}\n\nfunction provisionImpl(): string | undefined {\n const bundlePath = bundledLauncherPath()\n if (!bundlePath) return undefined\n return publishLauncherFrom(bundlePath)\n}\n\n/**\n * Verify and publish one specific bundle. Split out from the source resolution\n * above so the publication semantics are testable: running from source,\n * `bundledLauncherPath()` deliberately points at a file that does not exist,\n * which is the right behaviour but leaves nothing to exercise.\n *\n * @internal — production callers go through `provisionHookLauncher()`.\n */\nexport function publishLauncherFrom(bundlePath: string): string | undefined {\n try {\n let bytes: Buffer\n try {\n bytes = readFileSync(bundlePath)\n } catch {\n // Running from source, or the package tree was reaped out from under us.\n // Either way there is nothing to publish; a launcher published by an\n // earlier launch still stands.\n return undefined\n }\n\n const digest = sha256(bytes)\n const expected = expectedDigest(bundlePath)\n if (!expected) {\n // \"Cannot verify\" and \"verified bad\" both mean do-not-publish. Treating\n // an absent sidecar as permission would delete the integrity check in\n // exactly the degraded conditions it exists for.\n consola.debug(\n \"[hook-launcher] no digest sidecar beside the bundle; not publishing\",\n )\n return undefined\n }\n if (expected !== digest) {\n // The classic cause is reading mid-`bunx`-re-extraction. Publishing here\n // would freeze a torn bundle under a stable name forever, because\n // content-addressing gives a truncated file its own perfectly valid hash.\n consola.debug(\n \"[hook-launcher] bundle digest does not match the build; not publishing\",\n )\n return undefined\n }\n\n const dir = PATHS.HOOK_LAUNCHER_DIR\n // 0o700 / 0o600, matching the convention for the runtime dir in paths.ts.\n // This is not incidental hygiene: the published file is EXECUTED by node on\n // every prompt of every session, so a group- or world-writable path here\n // would let a local attacker swap the launcher and run code inside the\n // user's agent. chmod is best-effort — it is a no-op on Windows, where the\n // ACL inherited from APP_DIR governs.\n mkdirSync(dir, { recursive: true, mode: 0o700 })\n try {\n chmodSync(dir, 0o700)\n } catch {\n /* best-effort: Windows, or a dir we do not own */\n }\n const target = path.join(dir, `hooks-${digest}.mjs`)\n if (!publish(target, bytes, digest)) return undefined\n\n // Mark this launcher as still in use before sweeping, so a long-lived\n // install that keeps relaunching against an old version is never reaped by\n // a newer proxy's sweep.\n try {\n const now = new Date()\n utimesSync(target, now, now)\n } catch {\n /* best-effort */\n }\n sweepStaleLaunchers(dir, target)\n return target\n } catch (err) {\n consola.debug(\"[hook-launcher] provisioning skipped:\", err)\n return undefined\n }\n}\n","/**\n * How this process names ITSELF in a command string that gets persisted to\n * disk and executed later by someone else.\n *\n * Every Claude Code hook, the MCP `headersHelper`, and the worker-guard are\n * registered as shell commands inside a settings.json that outlives the\n * process that wrote it. They were built from `(process.execPath,\n * process.argv[1])`, which under `bunx` points into `$TMPDIR` — a directory\n * macOS reaps and `bunx pkg@latest` re-extracts in place. A persisted command\n * pointing there stops working mid-session (see\n * `src/lib/hook-launcher/provision.ts` for the failure in full).\n *\n * So the pair is resolved ONCE per launch, through the stable relocated\n * launcher when one can be published, and every builder composes its command\n * from that single answer.\n */\n\nimport { readFileSync, realpathSync } from \"node:fs\"\nimport os from \"node:os\"\nimport path from \"node:path\"\n\nimport { PACKAGE_ROOT_FLAG } from \"../package-root\"\nimport { PATHS } from \"../paths\"\nimport { provisionHookLauncher } from \"./provision\"\n\n/** The binary + script + package root a persisted command should name. */\nexport interface SelfInvocation {\n /** The node/bun binary to exec. */\n execPath: string\n /** Script to pass to it, omitted for a packaged single-file build. */\n scriptPath?: string\n /**\n * The github-router package root, baked in only when `scriptPath` is the\n * relocated launcher. From `<APP_DIR>/hooks/` nothing can derive it: the\n * pre-existing walk in `browser-mcp/native-host-installer.ts` falls back to\n * `process.cwd()`, which would silently resolve to the USER'S WORKSPACE.\n */\n packageRoot?: string\n}\n\nfunction quote(s: string): string {\n return `\"${s}\"`\n}\n\n/**\n * Compose a persisted command string: the binary, the script when it differs\n * from the binary, the baked package root when there is one, then the args.\n *\n * Every builder in the codebase routes through here so the three parts cannot\n * drift apart — and so a future part is added in one place, not eleven.\n */\nexport function buildSelfCommand(inv: SelfInvocation, args: string): string {\n const parts = [quote(inv.execPath)]\n if (inv.scriptPath && inv.scriptPath !== inv.execPath) {\n parts.push(quote(inv.scriptPath))\n }\n if (inv.packageRoot) {\n parts.push(PACKAGE_ROOT_FLAG, quote(inv.packageRoot))\n }\n if (args) parts.push(args)\n return parts.join(\" \")\n}\n\n/** The invocation describing the currently running entrypoint, unrelocated. */\nexport function currentInvocation(): SelfInvocation {\n return { execPath: process.execPath, scriptPath: process.argv[1] }\n}\n\nlet _resolved: SelfInvocation | undefined\n\n/** @internal — reset module state between test cases. */\nexport function __resetSelfInvocationForTests(): void {\n _resolved = undefined\n}\n\n/**\n * Resolve the invocation to bake into every persisted command this launch\n * writes. Awaited BEFORE the settings are written, never fire-and-forget: a\n * command persisted while provisioning is still pending would name the very\n * temp path this exists to avoid, and the session would stay broken however\n * well provisioning later went.\n *\n * Falls back to the running entrypoint if the launcher cannot be published, so\n * a provisioning failure degrades rather than breaking a launch. The caller is\n * responsible for surfacing that fallback — see `hookLauncherDegradedWarning`.\n */\nexport async function resolveSelfInvocation(): Promise<SelfInvocation> {\n if (_resolved) return _resolved\n const launcher = await provisionHookLauncher()\n _resolved =\n launcher ?\n {\n execPath: process.execPath,\n scriptPath: launcher,\n packageRoot: currentPackageRoot(),\n }\n : currentInvocation()\n return _resolved\n}\n\n/**\n * A human-facing warning when this launch is about to persist hook commands\n * pointing into a directory the OS may reap — the exact configuration that\n * produced the original bug.\n *\n * Returns the message rather than logging it, mirroring\n * `colbertDegradedWarning`: `claude` and `codex` call `enableFileLogging()`,\n * which redirects `consola.warn` to the error log, so a warning logged here\n * would be invisible on the one path where it matters most. The caller writes\n * it to stderr next to the readiness line instead.\n *\n * Silent when running from source, which has no bundle to publish and is not a\n * degraded state.\n */\nexport function hookLauncherDegradedWarning(\n inv: SelfInvocation,\n): string | null {\n if (!inv.scriptPath) return null\n // Our own published launcher is checked FIRST, and is authoritative: we know\n // we published it, so it can never warrant the \"could not publish\" message\n // below even if APP_DIR itself sits somewhere unusual.\n if (inv.scriptPath.startsWith(PATHS.HOOK_LAUNCHER_DIR)) {\n if (inv.packageRoot) return null\n // Relocated but rootless. Today this only degrades `--version` inside the\n // launcher, because nothing in the hook graph consumes the package root for\n // anything else. It is reported anyway because it is a trap rather than a\n // bug: the day a hook subcommand pulls in code_search or the browser\n // installer, `packageRoot()` falls through to `process.cwd()` and starts\n // resolving against the user's REPO with no signal at all.\n return (\n \"Hook launcher published without a package root; hook version reporting \"\n + \"will be degraded. This usually means the install tree is partially \"\n + \"missing — reinstall github-router.\"\n )\n }\n if (isUnderVolatileRoot(inv.scriptPath)) {\n return (\n \"Hook commands point into a temporary directory and will stop working \"\n + \"when the OS reaps it (the stable launcher could not be published). \"\n + \"Reinstall with `npm install -g github-router` to avoid this.\"\n )\n }\n return null\n}\n\n/**\n * The package root of the RUNNING code, derived while we are still inside the\n * package tree — the one moment it is knowable without guessing.\n *\n * The name is checked, not just the presence of a package.json: this value is\n * baked into a persisted command and consumed by `packageRoot()` as the\n * highest-priority source, so handing it the WRONG root would be worse than\n * handing it none. Matches `findPackageRoot()` in\n * `browser-mcp/native-host-installer.ts`, whose fallbacks this supersedes.\n */\nfunction currentPackageRoot(): string | undefined {\n const entry = typeof process.argv[1] === \"string\" ? process.argv[1] : undefined\n if (!entry) return undefined\n let cur = path.dirname(entry)\n for (let i = 0; i < 10; i++) {\n try {\n const pkg = JSON.parse(\n readFileSync(path.join(cur, \"package.json\"), \"utf8\"),\n ) as { name?: unknown }\n if (typeof pkg.name === \"string\" && pkg.name.includes(\"github-router\")) {\n return cur\n }\n } catch {\n // Not here, or unreadable; walk up.\n }\n const parent = path.dirname(cur)\n if (parent === cur) break\n cur = parent\n }\n return undefined\n}\n\n/**\n * Whether a path sits under a directory the OS is entitled to clean out from\n * under a running session: the per-user temp dir on every platform, which is\n * where `bunx` (unlike `npx`, which uses a cache under $HOME) installs.\n *\n * Both sides are compared in resolved AND unresolved form. macOS reports\n * `$TMPDIR` as `/var/folders/…` while a process sees `/private/var/folders/…`,\n * so a single-form prefix test silently never matches; and `realpathSync`\n * fails on a path that does not exist, which would otherwise make the answer\n * depend on whether the file happens to be there.\n */\nexport function isUnderVolatileRoot(target: string): boolean {\n try {\n const prefixes = new Set<string>()\n for (const root of [os.tmpdir(), realpathIfPossible(os.tmpdir())]) {\n prefixes.add(root.endsWith(path.sep) ? root : root + path.sep)\n }\n const targets = [target, realpathIfPossible(target)]\n return targets.some((t) => [...prefixes].some((p) => t.startsWith(p)))\n } catch {\n return false\n }\n}\n\nfunction realpathIfPossible(p: string): string {\n try {\n return realpathSync(p)\n } catch {\n return p\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,iBAAiB;;AAGvB,MAAM,cAAc;;;;;;AAOpB,MAAM,mBAAmB;AAEzB,IAAI;AACJ,IAAI;;;;;;;;;;;AAkBJ,SAAS,sBAA0C;CACjD,IAAI;EACF,OAAO,KAAK,KAAK,KAAK,QAAQ,cAAc,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AW,QAAQ,KAAK,KAAK,KAAA;CACtE,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI,MAAM,KAAK,QAAQ,KAAK;CAC5B,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;EAC3B,IAAI;GACF,MAAM,MAAM,KAAK,MACf,aAAa,KAAK,KAAK,KAAK,cAAc,GAAG,MAAM,CACrD;GACA,IAAI,OAAO,IAAI,SAAS,YAAY,IAAI,KAAK,SAAS,eAAe,GACnE,OAAO;EAEX,QAAQ,CAER;EACA,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK;EACpB,MAAM;CACR;AAEF;;;;;;;;;;;;AAaA,SAAgB,oBAAoB,QAAyB;CAC3D,IAAI;EACF,MAAM,2BAAW,IAAI,IAAY;EACjC,KAAK,MAAM,QAAQ,CAAC,GAAG,OAAO,GAAG,mBAAmB,GAAG,OAAO,CAAC,CAAC,GAC9D,SAAS,IAAI,KAAK,SAAS,KAAK,GAAG,IAAI,OAAO,OAAO,KAAK,GAAG;EAG/D,OAAO,CADU,QAAQ,mBAAmB,MAAM,CACrC,CAAC,CAAC,MAAM,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;CACvE,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,mBAAmB,GAAmB;CAC7C,IAAI;EACF,OAAO,aAAa,CAAC;CACvB,QAAQ;EACN,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"self-invocation-DMUnXVGT.js","names":[],"sources":["../src/lib/hook-launcher/provision.ts","../src/lib/hook-launcher/self-invocation.ts"],"sourcesContent":["/**\n * Publish the self-contained hook launcher (`dist/hooks.mjs`) to a stable,\n * content-addressed path under `<APP_DIR>/hooks/`.\n *\n * Why this exists: `github-router claude` persists Claude Code hook commands\n * into a settings.json that outlives the process that wrote it, built from\n * `process.argv[1]`. Under `bunx` that path is inside `$TMPDIR`, and macOS's\n * per-user temp reaper deletes files there (keeping the directory skeleton) —\n * so `node <tmp>/…/dist/main.js` died on its first bare import with\n * `ERR_MODULE_NOT_FOUND` and EVERY hook in a long-running session failed until\n * the tree happened to be re-extracted. `bunx pkg@latest` also re-extracts in\n * place whenever npm's `latest` advances, so a live session's hooks could\n * silently start executing a different version's code.\n *\n * Deliberate departures from `provisionBrowserAssets()`, which this otherwise\n * mirrors:\n *\n * - **Content-addressed, immutable names.** The digest IS the filename, so a\n * new build never overwrites an old launcher and there is nothing to\n * garbage-collect. Version-keyed names would need GC, and GC across\n * concurrent proxies is a race: proxy N deleting N+1's launcher (or the\n * reverse) breaks a live session's hooks. At ~1.5 MB, keeping stale\n * launchers costs less than the race would.\n *\n * - **The source is verified before it is published.** Hashing the bytes\n * read from `dist/hooks.mjs` only identifies those bytes; it does not\n * prove they are a complete artifact. A concurrent in-place `bunx`\n * extraction can hand over a truncated file, which content-addressing\n * would happily preserve forever under its own hash. The build writes a\n * `dist/hooks.sha256` sidecar and we publish only on a match.\n *\n * - **Failures are not latched.** A transient `EBUSY` (Windows antivirus, a\n * concurrent reader) must not disable provisioning for the process\n * lifetime, so only success is cached.\n *\n * Never throws: the caller degrades to `process.argv[1]` with a visible\n * warning rather than failing the launch.\n */\n\nimport { createHash } from \"node:crypto\"\nimport {\n chmodSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n utimesSync,\n writeFileSync,\n} from \"node:fs\"\nimport path from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport consola from \"consola\"\n\nimport { PATHS } from \"../paths\"\n\n/** Sidecar written by `scripts/stamp-hooks-digest.ts` next to the bundle. */\nconst DIGEST_SIDECAR = \"hooks.sha256\"\n\n/** Basename of the built launcher bundle. */\nconst BUNDLE_NAME = \"hooks.mjs\"\n\n/**\n * Publish retries. A rename can lose a race with another proxy publishing the\n * same digest, or hit a Windows sharing violation while an antivirus scanner\n * holds the temp file. Both clear in milliseconds.\n */\nconst PUBLISH_ATTEMPTS = 3\n\nlet _published: string | undefined\nlet _inFlight: Promise<string | undefined> | undefined\n\n/** @internal — reset module state between test cases. */\nexport function __resetHookLauncherForTests(): void {\n _published = undefined\n _inFlight = undefined\n}\n\n/**\n * Resolve the built bundle that sits beside the running code.\n *\n * In a built layout every chunk lives in `dist/`, so a sibling lookup finds\n * `dist/hooks.mjs`. Running from source it resolves to\n * `src/lib/hook-launcher/hooks.mjs`, which does not exist — which is exactly\n * the wanted behaviour: a `bun run dev` session must keep using\n * `process.argv[1]` rather than silently adopting a stale bundle from some\n * earlier build.\n */\nfunction bundledLauncherPath(): string | undefined {\n try {\n return path.join(path.dirname(fileURLToPath(import.meta.url)), BUNDLE_NAME)\n } catch {\n return undefined\n }\n}\n\nfunction sha256(buf: Buffer): string {\n return createHash(\"sha256\").update(buf).digest(\"hex\")\n}\n\n/**\n * Read the build's expected digest. Absent or malformed means \"cannot verify\",\n * which is treated as a refusal to publish rather than as permission to skip\n * the check — an unverified source is the one thing content-addressing cannot\n * recover from.\n */\nfunction expectedDigest(bundlePath: string): string | undefined {\n try {\n const raw = readFileSync(\n path.join(path.dirname(bundlePath), DIGEST_SIDECAR),\n \"utf8\",\n ).trim()\n return /^[0-9a-f]{64}$/.test(raw) ? raw : undefined\n } catch {\n return undefined\n }\n}\n\n/** True when `target` already holds exactly the bytes its name claims. */\nfunction targetIsValid(target: string, digest: string): boolean {\n try {\n return sha256(readFileSync(target)) === digest\n } catch {\n return false\n }\n}\n\n/**\n * Write `bytes` to `target` via a unique same-directory temp file plus a\n * rename, so a crash mid-write can never leave a partial file under the name\n * a hook command points at.\n *\n * The target is never deleted first: on Windows that would open a window where\n * a concurrently-launching session finds no launcher at all. A rename onto an\n * existing path can fail there, so a losing racer validates what the winner\n * wrote and accepts it.\n */\nfunction publish(target: string, bytes: Buffer, digest: string): boolean {\n // Checked once up front rather than per attempt: validation re-hashes ~1.5 MB\n // and the retries exist for rename contention, which revalidating cannot fix.\n if (targetIsValid(target, digest)) return true\n for (let attempt = 0; attempt < PUBLISH_ATTEMPTS; attempt++) {\n const tmp = `${target}.${process.pid}-${attempt}.tmp`\n try {\n writeFileSync(tmp, bytes, { mode: 0o600 })\n renameSync(tmp, target)\n return true\n } catch {\n try {\n rmSync(tmp, { force: true })\n } catch {\n // Best-effort. A Windows sharing violation can strand the temp file;\n // `sweepStaleLaunchers` reaps it later rather than leaking 1.5 MB.\n }\n }\n }\n return targetIsValid(target, digest)\n}\n\n/** A stranded publish temp is dead well inside this. */\nconst TMP_MAX_AGE_MS = 24 * 60 * 60 * 1000\n\n/**\n * Launchers older than this are reaped. Generous on purpose — see the residual\n * risk in `sweepStaleLaunchers`.\n */\nconst LAUNCHER_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000\n\n/**\n * Reap stranded publish temps and long-unused launchers.\n *\n * Without this the directory grows by ~1.5 MB per shipped version forever, and\n * this project ships a patch release per PR with self-update on by default.\n *\n * The immutable content-addressed naming exists to avoid a GC race, so the\n * sweep is built to not reintroduce one: it never touches the digest THIS\n * launch resolved, and every launch refreshes its own launcher's mtime, so a\n * file survives for as long as some proxy keeps launching against it. Residual\n * risk, stated plainly: a single proxy running continuously for more than 30\n * days without relaunching could have its launcher reaped by a newer proxy.\n * That is bounded and far rarer than the unbounded growth it prevents, but it\n * is not zero — a PID-liveness marker would close it if it ever bites.\n */\nfunction sweepStaleLaunchers(dir: string, keep: string): void {\n const now = Date.now()\n let entries: Array<string>\n try {\n entries = readdirSync(dir)\n } catch {\n return\n }\n for (const name of entries) {\n if (name === path.basename(keep)) continue\n const isTmp = name.endsWith(\".tmp\")\n // Strict shape match, like sweepAgedWorkerDiffs: this directory is ours,\n // but a name-shape check means a false positive can only ever cost a file\n // the next launch regenerates.\n const isLauncher = /^hooks-[0-9a-f]{64}\\.mjs$/.test(name)\n if (!isTmp && !isLauncher) continue\n const target = path.join(dir, name)\n try {\n const age = now - statSync(target).mtimeMs\n if (age > (isTmp ? TMP_MAX_AGE_MS : LAUNCHER_MAX_AGE_MS)) {\n rmSync(target, { force: true })\n }\n } catch {\n /* best-effort */\n }\n }\n}\n\n/**\n * Materialize the launcher and return its stable absolute path, or undefined\n * when it could not be published (running from source, bundle missing or\n * unverifiable, filesystem refusing the write).\n *\n * Single-flight so the startup call and any lazy caller collapse to one run.\n */\nexport function provisionHookLauncher(): Promise<string | undefined> {\n if (_published) return Promise.resolve(_published)\n if (_inFlight) return _inFlight\n _inFlight = Promise.resolve()\n .then(() => provisionImpl())\n .then((result) => {\n // Cache SUCCESS only. Latching a transient failure would disable the\n // stable launcher for the whole process lifetime.\n if (result) _published = result\n return result\n })\n .finally(() => {\n _inFlight = undefined\n })\n return _inFlight\n}\n\nfunction provisionImpl(): string | undefined {\n const bundlePath = bundledLauncherPath()\n if (!bundlePath) return undefined\n return publishLauncherFrom(bundlePath)\n}\n\n/**\n * Verify and publish one specific bundle. Split out from the source resolution\n * above so the publication semantics are testable: running from source,\n * `bundledLauncherPath()` deliberately points at a file that does not exist,\n * which is the right behaviour but leaves nothing to exercise.\n *\n * @internal — production callers go through `provisionHookLauncher()`.\n */\nexport function publishLauncherFrom(bundlePath: string): string | undefined {\n try {\n let bytes: Buffer\n try {\n bytes = readFileSync(bundlePath)\n } catch {\n // Running from source, or the package tree was reaped out from under us.\n // Either way there is nothing to publish; a launcher published by an\n // earlier launch still stands.\n return undefined\n }\n\n const digest = sha256(bytes)\n const expected = expectedDigest(bundlePath)\n if (!expected) {\n // \"Cannot verify\" and \"verified bad\" both mean do-not-publish. Treating\n // an absent sidecar as permission would delete the integrity check in\n // exactly the degraded conditions it exists for.\n consola.debug(\n \"[hook-launcher] no digest sidecar beside the bundle; not publishing\",\n )\n return undefined\n }\n if (expected !== digest) {\n // The classic cause is reading mid-`bunx`-re-extraction. Publishing here\n // would freeze a torn bundle under a stable name forever, because\n // content-addressing gives a truncated file its own perfectly valid hash.\n consola.debug(\n \"[hook-launcher] bundle digest does not match the build; not publishing\",\n )\n return undefined\n }\n\n const dir = PATHS.HOOK_LAUNCHER_DIR\n // 0o700 / 0o600, matching the convention for the runtime dir in paths.ts.\n // This is not incidental hygiene: the published file is EXECUTED by node on\n // every prompt of every session, so a group- or world-writable path here\n // would let a local attacker swap the launcher and run code inside the\n // user's agent. chmod is best-effort — it is a no-op on Windows, where the\n // ACL inherited from APP_DIR governs.\n mkdirSync(dir, { recursive: true, mode: 0o700 })\n try {\n chmodSync(dir, 0o700)\n } catch {\n /* best-effort: Windows, or a dir we do not own */\n }\n const target = path.join(dir, `hooks-${digest}.mjs`)\n if (!publish(target, bytes, digest)) return undefined\n\n // Mark this launcher as still in use before sweeping, so a long-lived\n // install that keeps relaunching against an old version is never reaped by\n // a newer proxy's sweep.\n try {\n const now = new Date()\n utimesSync(target, now, now)\n } catch {\n /* best-effort */\n }\n sweepStaleLaunchers(dir, target)\n return target\n } catch (err) {\n consola.debug(\"[hook-launcher] provisioning skipped:\", err)\n return undefined\n }\n}\n","/**\n * How this process names ITSELF in a command string that gets persisted to\n * disk and executed later by someone else.\n *\n * Every Claude Code hook, the MCP `headersHelper`, and the worker-guard are\n * registered as shell commands inside a settings.json that outlives the\n * process that wrote it. They were built from `(process.execPath,\n * process.argv[1])`, which under `bunx` points into `$TMPDIR` — a directory\n * macOS reaps and `bunx pkg@latest` re-extracts in place. A persisted command\n * pointing there stops working mid-session (see\n * `src/lib/hook-launcher/provision.ts` for the failure in full).\n *\n * So the pair is resolved ONCE per launch, through the stable relocated\n * launcher when one can be published, and every builder composes its command\n * from that single answer.\n */\n\nimport { readFileSync, realpathSync } from \"node:fs\"\nimport os from \"node:os\"\nimport path from \"node:path\"\n\nimport { PACKAGE_ROOT_FLAG } from \"../package-root\"\nimport { PATHS } from \"../paths\"\nimport { provisionHookLauncher } from \"./provision\"\n\n/** The binary + script + package root a persisted command should name. */\nexport interface SelfInvocation {\n /** The node/bun binary to exec. */\n execPath: string\n /** Script to pass to it, omitted for a packaged single-file build. */\n scriptPath?: string\n /**\n * The github-router package root, baked in only when `scriptPath` is the\n * relocated launcher. From `<APP_DIR>/hooks/` nothing can derive it: the\n * pre-existing walk in `browser-mcp/native-host-installer.ts` falls back to\n * `process.cwd()`, which would silently resolve to the USER'S WORKSPACE.\n */\n packageRoot?: string\n}\n\nfunction quote(s: string): string {\n return `\"${s}\"`\n}\n\n/**\n * Compose a persisted command string: the binary, the script when it differs\n * from the binary, the baked package root when there is one, then the args.\n *\n * Every builder in the codebase routes through here so the three parts cannot\n * drift apart — and so a future part is added in one place, not eleven.\n */\nexport function buildSelfCommand(inv: SelfInvocation, args: string): string {\n const parts = [quote(inv.execPath)]\n if (inv.scriptPath && inv.scriptPath !== inv.execPath) {\n parts.push(quote(inv.scriptPath))\n }\n if (inv.packageRoot) {\n parts.push(PACKAGE_ROOT_FLAG, quote(inv.packageRoot))\n }\n if (args) parts.push(args)\n return parts.join(\" \")\n}\n\n/** The invocation describing the currently running entrypoint, unrelocated. */\nexport function currentInvocation(): SelfInvocation {\n return { execPath: process.execPath, scriptPath: process.argv[1] }\n}\n\nlet _resolved: SelfInvocation | undefined\n\n/** @internal — reset module state between test cases. */\nexport function __resetSelfInvocationForTests(): void {\n _resolved = undefined\n}\n\n/**\n * Resolve the invocation to bake into every persisted command this launch\n * writes. Awaited BEFORE the settings are written, never fire-and-forget: a\n * command persisted while provisioning is still pending would name the very\n * temp path this exists to avoid, and the session would stay broken however\n * well provisioning later went.\n *\n * Falls back to the running entrypoint if the launcher cannot be published, so\n * a provisioning failure degrades rather than breaking a launch. The caller is\n * responsible for surfacing that fallback — see `hookLauncherDegradedWarning`.\n */\nexport async function resolveSelfInvocation(): Promise<SelfInvocation> {\n if (_resolved) return _resolved\n const launcher = await provisionHookLauncher()\n _resolved =\n launcher ?\n {\n execPath: process.execPath,\n scriptPath: launcher,\n packageRoot: currentPackageRoot(),\n }\n : currentInvocation()\n return _resolved\n}\n\n/**\n * A human-facing warning when this launch is about to persist hook commands\n * pointing into a directory the OS may reap — the exact configuration that\n * produced the original bug.\n *\n * Returns the message rather than logging it, mirroring\n * `colbertDegradedWarning`: `claude` and `codex` call `enableFileLogging()`,\n * which redirects `consola.warn` to the error log, so a warning logged here\n * would be invisible on the one path where it matters most. The caller writes\n * it to stderr next to the readiness line instead.\n *\n * Silent when running from source, which has no bundle to publish and is not a\n * degraded state.\n */\nexport function hookLauncherDegradedWarning(\n inv: SelfInvocation,\n): string | null {\n if (!inv.scriptPath) return null\n // Our own published launcher is checked FIRST, and is authoritative: we know\n // we published it, so it can never warrant the \"could not publish\" message\n // below even if APP_DIR itself sits somewhere unusual.\n if (inv.scriptPath.startsWith(PATHS.HOOK_LAUNCHER_DIR)) {\n if (inv.packageRoot) return null\n // Relocated but rootless. Today this only degrades `--version` inside the\n // launcher, because nothing in the hook graph consumes the package root for\n // anything else. It is reported anyway because it is a trap rather than a\n // bug: the day a hook subcommand pulls in code_search or the browser\n // installer, `packageRoot()` falls through to `process.cwd()` and starts\n // resolving against the user's REPO with no signal at all.\n return (\n \"Hook launcher published without a package root; hook version reporting \"\n + \"will be degraded. This usually means the install tree is partially \"\n + \"missing — reinstall github-router.\"\n )\n }\n if (isUnderVolatileRoot(inv.scriptPath)) {\n return (\n \"Hook commands point into a temporary directory and will stop working \"\n + \"when the OS reaps it (the stable launcher could not be published). \"\n + \"Reinstall with `npm install -g github-router` to avoid this.\"\n )\n }\n return null\n}\n\n/**\n * The package root of the RUNNING code, derived while we are still inside the\n * package tree — the one moment it is knowable without guessing.\n *\n * The name is checked, not just the presence of a package.json: this value is\n * baked into a persisted command and consumed by `packageRoot()` as the\n * highest-priority source, so handing it the WRONG root would be worse than\n * handing it none. Matches `findPackageRoot()` in\n * `browser-mcp/native-host-installer.ts`, whose fallbacks this supersedes.\n */\nfunction currentPackageRoot(): string | undefined {\n const entry = typeof process.argv[1] === \"string\" ? process.argv[1] : undefined\n if (!entry) return undefined\n let cur = path.dirname(entry)\n for (let i = 0; i < 10; i++) {\n try {\n const pkg = JSON.parse(\n readFileSync(path.join(cur, \"package.json\"), \"utf8\"),\n ) as { name?: unknown }\n if (typeof pkg.name === \"string\" && pkg.name.includes(\"github-router\")) {\n return cur\n }\n } catch {\n // Not here, or unreadable; walk up.\n }\n const parent = path.dirname(cur)\n if (parent === cur) break\n cur = parent\n }\n return undefined\n}\n\n/**\n * Whether a path sits under a directory the OS is entitled to clean out from\n * under a running session: the per-user temp dir on every platform, which is\n * where `bunx` (unlike `npx`, which uses a cache under $HOME) installs.\n *\n * Both sides are compared in resolved AND unresolved form. macOS reports\n * `$TMPDIR` as `/var/folders/…` while a process sees `/private/var/folders/…`,\n * so a single-form prefix test silently never matches; and `realpathSync`\n * fails on a path that does not exist, which would otherwise make the answer\n * depend on whether the file happens to be there.\n */\nexport function isUnderVolatileRoot(target: string): boolean {\n try {\n const prefixes = new Set<string>()\n for (const root of [os.tmpdir(), realpathIfPossible(os.tmpdir())]) {\n prefixes.add(root.endsWith(path.sep) ? root : root + path.sep)\n }\n const targets = [target, realpathIfPossible(target)]\n return targets.some((t) => [...prefixes].some((p) => t.startsWith(p)))\n } catch {\n return false\n }\n}\n\nfunction realpathIfPossible(p: string): string {\n try {\n return realpathSync(p)\n } catch {\n return p\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,iBAAiB;;AAGvB,MAAM,cAAc;;;;;;AAOpB,MAAM,mBAAmB;AAEzB,IAAI;AACJ,IAAI;;;;;;;;;;;AAkBJ,SAAS,sBAA0C;CACjD,IAAI;EACF,OAAO,KAAK,KAAK,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,WAAW;CAC5E,QAAQ;EACN;CACF;AACF;AAEA,SAAS,OAAO,KAAqB;CACnC,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,KAAK;AACtD;;;;;;;AAQA,SAAS,eAAe,YAAwC;CAC9D,IAAI;EACF,MAAM,MAAM,aACV,KAAK,KAAK,KAAK,QAAQ,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IAAI,SAAS,YAAY,IAAI,KAAK,SAAS,eAAe,GACnE,OAAO;EAEX,QAAQ,CAER;EACA,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK;EACpB,MAAM;CACR;AAEF;;;;;;;;;;;;AAaA,SAAgB,oBAAoB,QAAyB;CAC3D,IAAI;EACF,MAAM,2BAAW,IAAI,IAAY;EACjC,KAAK,MAAM,QAAQ,CAAC,GAAG,OAAO,GAAG,mBAAmB,GAAG,OAAO,CAAC,CAAC,GAC9D,SAAS,IAAI,KAAK,SAAS,KAAK,GAAG,IAAI,OAAO,OAAO,KAAK,GAAG;EAG/D,OAAO,CADU,QAAQ,mBAAmB,MAAM,CACrC,CAAC,CAAC,MAAM,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;CACvE,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,mBAAmB,GAAmB;CAC7C,IAAI;EACF,OAAO,aAAa,CAAC;CACvB,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -1,20 +1,20 @@
1
- import { P as warmTreeSitterPool } from "./service-backend-BV2hHjuB.js";
2
- import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
3
- import { r as ensureClaudeConfigMirror, s as removeOwnClaudeConfigMirror, t as PATHS } from "./paths-C5477RGC.js";
4
- import { t as state } from "./state-DzsaGHr9.js";
5
- import { f as resolveModel, h as getGitHubUser } from "./token-Dqjs5ixP.js";
6
- import { c as runCommandCapture, r as killChildProcessTree, s as resolveExecutable } from "./exec-Bf8g_bIR.js";
7
- import { U as resolveLaunchProfile, Z as runSelfUpdate, a as setupAndServe, b as injectModelPickerSettingsFile, i as parseSharedArgs, o as sharedServerArgs, t as getClaudeCodeEnvVars, v as startKeepAwake, y as stopKeepAwake } from "./server-setup-BLdWCcby.js";
8
- import { $t as nativeSubagentModel, At as brainstormModel, Bt as cloudAgentToolsEnabled, D as toolbeltEnabled, E as buildToolbeltAwareness, Et as agentToolsEnabled, Jt as fleetToolsEnabled, Mn as provisionBrowserAssets, Mt as browserCompoundToolsEnabled, Nt as browserToolsEnabled, Qt as kustoToolsEnabled, T as availableToolCommands, Tt as adoToolsEnabled, Vn as provisionAndIndexColbert, Xn as DEFAULT_CLAUDE_MODEL_FALLBACKS, Xt as generalPurposeFastModel, Yt as geminiAvailable, Zt as implementerFastModel, an as standInToolEnabled, ar as resolveLeadSlugArg, c as enumerateInjectedMcpToolNames, en as resolveGeminiReviewModel, in as scribeModel, ir as pickClaudeDefault, jt as browseAgentEnabled, nn as reviewerModel, o as buildPeerAwarenessSnippet, on as workerToolsEnabled, rn as scoutModel, sn as workiqToolsEnabled, tn as reviewerFastModel, w as buildEnv, xt as disposeAdoClients } from "./peer-mcp-personas-BSxDj9sJ.js";
9
- import { r as buildPromptSubmitHookCommand } from "./static-context-pack-CsOAC87F.js";
10
- import { n as hookLauncherDegradedWarning, r as resolveSelfInvocation } from "./self-invocation-BtcGj-lY.js";
11
- import { r as getCodexVersion, t as provisionToolbelt } from "./provision-B0GNohdl.js";
12
- import { c as disposeBluebirdClients } from "./bluebird-client-ByCRusGQ.js";
13
- import { s as injectStopHookIntoSettingsFile } from "./stop-gate-hook-DnLC09Lg.js";
14
- import { l as guardToolMatcher, n as activeDispatchModes, r as buildWorkerGuardHookCommand } from "./worker-dispatch-B1w2qfjX.js";
15
- import { c as injectAllowRules, d as BUILTIN_SUBAGENT_DEFINITIONS, f as injectPeerMcpIntoMirror, g as writePeerMcpRuntimeFiles, h as workersKeyOf, i as writeInjectedSkill, l as planModeAllowRules, m as resolveGroupKeysFromMirror, n as getInjectedSkills, o as SEAMLESS_BUILTIN_TOOLS, p as resolveCodexCliBackend, s as configureServeDefaultPermissionMode, t as injectAttributionSuppressionIntoSettingsFile, u as sanitizeServeSettingsEnv } from "./attribution-settings-DZ8fEfvP.js";
16
- import { i as planReviewEnabled, t as buildPlanReviewHookCommand } from "./plan-review-hook-C9K-em4D.js";
17
- import { a as buildOperatingDefaultsDirective, c as prependOperatingDefaultsToMirroredClaudeMd, l as prependStyleDirectiveToMirroredClaudeMd, n as appendPeerAwarenessToMirroredClaudeMd, r as appendToolbeltAwarenessToMirroredClaudeMd } from "./claude-md-injection-BnzVv_aB.js";
1
+ import { $t as nativeSubagentModel, At as brainstormModel, Bt as cloudAgentToolsEnabled, D as toolbeltEnabled, E as buildToolbeltAwareness, Et as agentToolsEnabled, Jt as fleetToolsEnabled, Mn as provisionBrowserAssets, Mt as browserCompoundToolsEnabled, Nt as browserToolsEnabled, Qt as kustoToolsEnabled, T as availableToolCommands, Tt as adoToolsEnabled, Vn as provisionAndIndexColbert, Xn as DEFAULT_CLAUDE_MODEL_FALLBACKS, Xt as generalPurposeFastModel, Yt as geminiAvailable, Zt as implementerFastModel, an as standInToolEnabled, ar as resolveLeadSlugArg, c as enumerateInjectedMcpToolNames, en as resolveGeminiReviewModel, in as scribeModel, ir as pickClaudeDefault, jt as browseAgentEnabled, nn as reviewerModel, o as buildPeerAwarenessSnippet, on as workerToolsEnabled, rn as scoutModel, sn as workiqToolsEnabled, tn as reviewerFastModel, w as buildEnv, xt as disposeAdoClients } from "./peer-mcp-personas-Cv21q_YR.js";
2
+ import { c as disposeBluebirdClients } from "./bluebird-client-BasIdv5J.js";
3
+ import { c as injectAllowRules, d as BUILTIN_SUBAGENT_DEFINITIONS, f as injectPeerMcpIntoMirror, g as writePeerMcpRuntimeFiles, h as workersKeyOf, i as writeInjectedSkill, l as planModeAllowRules, m as resolveGroupKeysFromMirror, n as getInjectedSkills, o as SEAMLESS_BUILTIN_TOOLS, p as resolveCodexCliBackend, s as configureServeDefaultPermissionMode, t as injectAttributionSuppressionIntoSettingsFile, u as sanitizeServeSettingsEnv } from "./attribution-settings-BLTnz2_A.js";
4
+ import { c as runCommandCapture, r as killChildProcessTree, s as resolveExecutable } from "./exec-BC0MAnoA.js";
5
+ import { U as resolveLaunchProfile, Z as runSelfUpdate, a as setupAndServe, b as injectModelPickerSettingsFile, i as parseSharedArgs, o as sharedServerArgs, t as getClaudeCodeEnvVars, v as startKeepAwake, y as stopKeepAwake } from "./server-setup-DldGizZR.js";
6
+ import { n as hookLauncherDegradedWarning, r as resolveSelfInvocation } from "./self-invocation-DMUnXVGT.js";
7
+ import { r as getCodexVersion, t as provisionToolbelt } from "./provision-CRmtV6ew.js";
8
+ import { r as ensureClaudeConfigMirror, s as removeOwnClaudeConfigMirror, t as PATHS } from "./paths-CVEO8jEH.js";
9
+ import { a as buildOperatingDefaultsDirective, c as prependOperatingDefaultsToMirroredClaudeMd, l as prependStyleDirectiveToMirroredClaudeMd, n as appendPeerAwarenessToMirroredClaudeMd, r as appendToolbeltAwarenessToMirroredClaudeMd } from "./claude-md-injection-DU5KYXNc.js";
10
+ import { i as planReviewEnabled, t as buildPlanReviewHookCommand } from "./plan-review-hook-MhjK92wq.js";
11
+ import { r as buildPromptSubmitHookCommand } from "./static-context-pack-DwC69_VA.js";
12
+ import { s as injectStopHookIntoSettingsFile } from "./stop-gate-hook-CBVLD8iB.js";
13
+ import { t as state } from "./state-CCGDJ43X.js";
14
+ import { l as guardToolMatcher, n as activeDispatchModes, r as buildWorkerGuardHookCommand } from "./worker-dispatch-C7RtNOXv.js";
15
+ import { t as getPackageVersion } from "./version-CTqwKr26.js";
16
+ import { P as warmTreeSitterPool } from "./service-backend-Ce6b2XEe.js";
17
+ import { f as resolveModel, h as getGitHubUser } from "./token-CPzYxU4Y.js";
18
18
  import { defineCommand } from "citty";
19
19
  import consola from "consola";
20
20
  import fs from "node:fs";
@@ -25,7 +25,7 @@ import os from "node:os";
25
25
  import process$1 from "node:process";
26
26
  import { spawn } from "node:child_process";
27
27
  import http from "node:http";
28
- //#region src/lib/serve/cloudcli.ts
28
+ // src/lib/serve/cloudcli.ts
29
29
  const CLOUDCLI_PACKAGE = "@cloudcli-ai/cloudcli";
30
30
  /**
31
31
  * Build the env handed to the CloudCLI child. Starts from `buildEnv()` — the
@@ -244,8 +244,7 @@ async function mintJwt(port, username, needsSetup) {
244
244
  }
245
245
  throw new Error(`Could not obtain a CloudCLI session token (status ${r.status}). If a stale isolated DB exists, delete ${path.join(PATHS.CLOUDCLI_HOME, "auth.db")} and retry.`);
246
246
  }
247
- //#endregion
248
- //#region src/lib/serve/devtunnel.ts
247
+ // src/lib/serve/devtunnel.ts
249
248
  const SERVE_TUNNEL_LABEL = "github-router-serve";
250
249
  function serveTunnelMachineLabel(hostname = os.hostname()) {
251
250
  return `ghr-machine-${createHash("sha256").update(hostname).digest("hex").slice(0, 12)}`;
@@ -510,8 +509,7 @@ async function startDevtunnel(port, opts = {}) {
510
509
  "github-router-serve-control-plane"
511
510
  ], timeoutMs);
512
511
  }
513
- //#endregion
514
- //#region src/lib/serve/enhancements.ts
512
+ // src/lib/serve/enhancements.ts
515
513
  const NOOP = { cleanup: async () => {} };
516
514
  function resolveServeNativeAgentOptions() {
517
515
  const models = {
@@ -674,8 +672,7 @@ async function provisionServeEnhancements(serverUrl, opts) {
674
672
  return NOOP;
675
673
  }
676
674
  }
677
- //#endregion
678
- //#region src/lib/serve/provider-facade.ts
675
+ // src/lib/serve/provider-facade.ts
679
676
  function isObject(value) {
680
677
  return value !== null && typeof value === "object" && !Array.isArray(value);
681
678
  }
@@ -944,8 +941,7 @@ function normalizeRelative(value) {
944
941
  function countCommands(builtIn) {
945
942
  return Array.isArray(builtIn) ? builtIn.length : 0;
946
943
  }
947
- //#endregion
948
- //#region src/lib/serve/reverse-proxy.ts
944
+ // src/lib/serve/reverse-proxy.ts
949
945
  /**
950
946
  * Loopback-only identity endpoint served directly by the reverse proxy (never
951
947
  * forwarded to CloudCLI). A second `github-router serve` probes this on the
@@ -1204,8 +1200,7 @@ async function startReverseProxy(opts) {
1204
1200
  })
1205
1201
  };
1206
1202
  }
1207
- //#endregion
1208
- //#region src/serve.ts
1203
+ // src/serve.ts
1209
1204
  function assertStandardServeModel(model) {
1210
1205
  const requestedProfile = resolveLaunchProfile(model);
1211
1206
  if (requestedProfile === "standard") return;
@@ -1607,7 +1602,6 @@ const serve = defineCommand({
1607
1602
  if (args["no-open"] !== true) openBrowser(reverse.url);
1608
1603
  }
1609
1604
  });
1610
- //#endregion
1611
1605
  export { serve };
1612
1606
 
1613
- //# sourceMappingURL=serve-BxZq9vNl.js.map
1607
+ //# sourceMappingURL=serve-DRASJ-ZO.js.map