@powerhousedao/ph-cli 6.3.0-dev.3 → 6.3.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/{build-CgLN1cEZ.mjs → build-BzYMwDBA.mjs} +4 -4
  2. package/dist/{build-CgLN1cEZ.mjs.map → build-BzYMwDBA.mjs.map} +1 -1
  3. package/dist/build-DKS03LRl.mjs +4 -0
  4. package/dist/{check-VPcldr0Q.mjs → check-B-L_Fi2h.mjs} +4 -4
  5. package/dist/{check-VPcldr0Q.mjs.map → check-B-L_Fi2h.mjs.map} +1 -1
  6. package/dist/{check-D0b-uWwK.mjs → check-B8oqVMg7.mjs} +4 -4
  7. package/dist/{check-D0b-uWwK.mjs.map → check-B8oqVMg7.mjs.map} +1 -1
  8. package/dist/{check-C_x7U-2Y.mjs → check-CwvNG1y5.mjs} +3 -3
  9. package/dist/{classic-warnings-kQsFGSeA.mjs → classic-warnings-BR0S6lr5.mjs} +4 -4
  10. package/dist/{classic-warnings-kQsFGSeA.mjs.map → classic-warnings-BR0S6lr5.mjs.map} +1 -1
  11. package/dist/{cli-connect-override-31gBnNxd.mjs → cli-connect-override-D22yFWlC.mjs} +4 -4
  12. package/dist/{cli-connect-override-31gBnNxd.mjs.map → cli-connect-override-D22yFWlC.mjs.map} +1 -1
  13. package/dist/cli.mjs +5 -5
  14. package/dist/{compound-CDrU3CLt-gW8JNJQK.mjs → compound-DKi56SSx-CXQHhS6t.mjs} +5 -4
  15. package/dist/{compound-CDrU3CLt-gW8JNJQK.mjs.map → compound-DKi56SSx-CXQHhS6t.mjs.map} +1 -1
  16. package/dist/{connect-build-q1QDwrH9.mjs → connect-build-Bwz5FCLl.mjs} +5 -5
  17. package/dist/{connect-build-q1QDwrH9.mjs.map → connect-build-Bwz5FCLl.mjs.map} +1 -1
  18. package/dist/{connect-config-Dj3E8CaW.mjs → connect-config-CVU4xhti.mjs} +4 -4
  19. package/dist/{connect-config-Dj3E8CaW.mjs.map → connect-config-CVU4xhti.mjs.map} +1 -1
  20. package/dist/{connect-studio-Ds-mfXJI.mjs → connect-studio-BnfhpIv8.mjs} +4 -4
  21. package/dist/{connect-studio-Ds-mfXJI.mjs.map → connect-studio-BnfhpIv8.mjs.map} +1 -1
  22. package/dist/{connect-studio-KdRWcq-A.mjs → connect-studio-D58ByAAn.mjs} +3 -3
  23. package/dist/definitions-worker.mjs +1 -1
  24. package/dist/{dist-seTzvoSw.mjs → dist-DXcB8fAF.mjs} +67 -5
  25. package/dist/dist-DXcB8fAF.mjs.map +1 -0
  26. package/dist/{explain-DTa32gEY.mjs → explain-8OEXF2Dy.mjs} +5 -5
  27. package/dist/{explain-DTa32gEY.mjs.map → explain-8OEXF2Dy.mjs.map} +1 -1
  28. package/dist/{export-YEBE-Gvl.mjs → export-DqbcbFU5.mjs} +4 -4
  29. package/dist/{export-YEBE-Gvl.mjs.map → export-DqbcbFU5.mjs.map} +1 -1
  30. package/dist/{generate-all-DKuaLgz1.mjs → generate-all-0YOnlZM0.mjs} +4 -4
  31. package/dist/{generate-all-DKuaLgz1.mjs.map → generate-all-0YOnlZM0.mjs.map} +1 -1
  32. package/dist/{get-version-L0a1H7iV.mjs → get-version-DrPnQWsE.mjs} +4 -4
  33. package/dist/{get-version-L0a1H7iV.mjs.map → get-version-DrPnQWsE.mjs.map} +1 -1
  34. package/dist/{index-Dy3U1WqW.d.mts → index-H3AYe65i.d.mts} +2 -1
  35. package/dist/index-H3AYe65i.d.mts.map +1 -0
  36. package/dist/{mcp-CfSjPzKW.mjs → mcp-CxF7arQA.mjs} +6 -6
  37. package/dist/{mcp-CfSjPzKW.mjs.map → mcp-CxF7arQA.mjs.map} +1 -1
  38. package/dist/{migrate-C5sxTyiG.mjs → migrate-BWfVrOD7.mjs} +4 -4
  39. package/dist/{migrate-C5sxTyiG.mjs.map → migrate-BWfVrOD7.mjs.map} +1 -1
  40. package/dist/{migrate-document-models-B1TXNVes.mjs → migrate-document-models-GPxMBuO3.mjs} +4 -4
  41. package/dist/{migrate-document-models-B1TXNVes.mjs.map → migrate-document-models-GPxMBuO3.mjs.map} +1 -1
  42. package/dist/migrate-subgraphs-CWlZxwiL.mjs +4 -0
  43. package/dist/{migrate-subgraphs-Cn7bX56b.mjs → migrate-subgraphs-p6K0q-6V.mjs} +5 -5
  44. package/dist/{migrate-subgraphs-Cn7bX56b.mjs.map → migrate-subgraphs-p6K0q-6V.mjs.map} +1 -1
  45. package/dist/{ph-cli-commands-Ctnl0Ckw.mjs → ph-cli-commands-CGcyoFMZ.mjs} +29 -19
  46. package/dist/{ph-cli-commands-Ctnl0Ckw.mjs.map → ph-cli-commands-CGcyoFMZ.mjs.map} +1 -1
  47. package/dist/ph-cli-commands-u7JueqJc.mjs +4 -0
  48. package/dist/{run-sugar-ByAIbE2x.mjs → run-sugar-DpznOP1e.mjs} +4 -4
  49. package/dist/{run-sugar-ByAIbE2x.mjs.map → run-sugar-DpznOP1e.mjs.map} +1 -1
  50. package/dist/runners/connect.d.mts +1 -1
  51. package/dist/runners/connect.mjs +2 -2
  52. package/dist/runners/switchboard.d.mts +1 -1
  53. package/dist/runners/switchboard.mjs +3 -3
  54. package/dist/{verify-DxhwtFdv.mjs → verify-fPOZMFVM.mjs} +4 -4
  55. package/dist/{verify-DxhwtFdv.mjs.map → verify-fPOZMFVM.mjs.map} +1 -1
  56. package/dist/{vetra-BmluhGRB.mjs → vetra-CVNZ46pK.mjs} +9 -8
  57. package/dist/vetra-CVNZ46pK.mjs.map +1 -0
  58. package/dist/{vetra-host-C0Q0oMUW.mjs → vetra-host-ChTpJiBJ.mjs} +5 -5
  59. package/dist/{vetra-host-C0Q0oMUW.mjs.map → vetra-host-ChTpJiBJ.mjs.map} +1 -1
  60. package/dist/{vetra-instance-B0bXPj7g.mjs → vetra-instance-CzhYIjxL.mjs} +4 -4
  61. package/dist/{vetra-instance-B0bXPj7g.mjs.map → vetra-instance-CzhYIjxL.mjs.map} +1 -1
  62. package/dist/{vetra-launch-T_uLKaR3.mjs → vetra-launch-qi10Unax.mjs} +7 -6
  63. package/dist/vetra-launch-qi10Unax.mjs.map +1 -0
  64. package/package.json +16 -16
  65. package/dist/build-BdQFCpwz.mjs +0 -4
  66. package/dist/dist-seTzvoSw.mjs.map +0 -1
  67. package/dist/index-Dy3U1WqW.d.mts.map +0 -1
  68. package/dist/migrate-subgraphs-SdawH0GP.mjs +0 -4
  69. package/dist/ph-cli-commands-DPhz3gjb.mjs +0 -4
  70. package/dist/vetra-BmluhGRB.mjs.map +0 -1
  71. package/dist/vetra-launch-T_uLKaR3.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"run-sugar-ByAIbE2x.mjs","sources":["../src/utils/run-sugar.ts"],"sourcesContent":["import { probeHostsFolder, splitRunArgv } from \"@powerhousedao/host-core\";\n\nexport interface RunSugarResult {\n args: string[];\n /** Set when hosts/ exists but is empty — the guard state: warn loudly, stay classic. */\n warning?: string;\n}\n\n/**\n * `ph <host-name> [verb]` sugar: when the first arg is not a registered\n * command and names a host in the project's hosts/ folder, splice in `run`\n * (mirrors the connect→`connect studio` default-subcommand rewrite).\n * Built-in commands win collisions by construction — the known-command check\n * runs first.\n */\n/** Classic commands that route through `ph run` in a hosts project, flags\n * included: the host's runner takes them as its arguments. */\nconst CLASSIC_ALIASES = new Set([\"vetra\"]);\n\nexport function applyRunSugar(\n args: string[],\n knownCommands: ReadonlySet<string>,\n projectRoot: string,\n): RunSugarResult {\n const first = args[0];\n if (!first || first.startsWith(\"-\")) {\n return { args };\n }\n if (knownCommands.has(first)) {\n if (CLASSIC_ALIASES.has(first)) {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n }\n return { args };\n }\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"empty\") {\n return {\n args,\n warning:\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js — ` +\n \"no host is defined, so commands keep their classic handling.\",\n };\n }\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n return { args };\n}\n\n/**\n * `ph run <host> [verb] <runner arguments>`: moves the runner's arguments\n * behind a `--`, so the `run` command takes them as they are instead of\n * refusing the ones it does not know. The verb is spelled out: after the `--`\n * nothing is read as one. Any other invocation is returned as it is.\n */\nexport function forwardRunnerArgv(args: string[]): string[] {\n if (args[0] !== \"run\") return args;\n const { host, verb, own, argv } = splitRunArgv(args.slice(1));\n if (host === undefined || argv.length === 0) return args;\n return [\"run\", host, verb ?? \"run\", ...own, \"--\", ...argv];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,kCAAkB,IAAI,IAAI,CAAC,OAAO,CAAC;AAEzC,SAAgB,cACd,MACA,eACA,aACgB;CAChB,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,GAChC,OAAO,EAAE,KAAK;CAEhB,IAAI,cAAc,IAAI,KAAK,GAAG;EAC5B,IAAI,gBAAgB,IAAI,KAAK,GAAG;GAC9B,MAAM,QAAQ,iBAAiB,WAAW;GAC1C,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;EAEpC;EACA,OAAO,EAAE,KAAK;CAChB;CACA,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,IAAI,MAAM,SAAS,SACjB,OAAO;EACL;EACA,SACE,oBAAoB,MAAM,IAAI;CAElC;CAEF,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;CAElC,OAAO,EAAE,KAAK;AAChB;;;;;;;AAQA,SAAgB,kBAAkB,MAA0B;CAC1D,IAAI,KAAK,OAAO,OAAO,OAAO;CAC9B,MAAM,EAAE,MAAM,MAAM,KAAK,SAAS,aAAa,KAAK,MAAM,CAAC,CAAC;CAC5D,IAAI,SAAS,KAAA,KAAa,KAAK,WAAW,GAAG,OAAO;CACpD,OAAO;EAAC;EAAO;EAAM,QAAQ;EAAO,GAAG;EAAK;EAAM,GAAG;CAAI;AAC3D","debug_id":"f53f6a09-ac0f-522f-bc76-1484380e014f"}
1
+ {"version":3,"file":"run-sugar-DpznOP1e.mjs","sources":["../src/utils/run-sugar.ts"],"sourcesContent":["import { probeHostsFolder, splitRunArgv } from \"@powerhousedao/host-core\";\n\nexport interface RunSugarResult {\n args: string[];\n /** Set when hosts/ exists but is empty — the guard state: warn loudly, stay classic. */\n warning?: string;\n}\n\n/**\n * `ph <host-name> [verb]` sugar: when the first arg is not a registered\n * command and names a host in the project's hosts/ folder, splice in `run`\n * (mirrors the connect→`connect studio` default-subcommand rewrite).\n * Built-in commands win collisions by construction — the known-command check\n * runs first.\n */\n/** Classic commands that route through `ph run` in a hosts project, flags\n * included: the host's runner takes them as its arguments. */\nconst CLASSIC_ALIASES = new Set([\"vetra\"]);\n\nexport function applyRunSugar(\n args: string[],\n knownCommands: ReadonlySet<string>,\n projectRoot: string,\n): RunSugarResult {\n const first = args[0];\n if (!first || first.startsWith(\"-\")) {\n return { args };\n }\n if (knownCommands.has(first)) {\n if (CLASSIC_ALIASES.has(first)) {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n }\n return { args };\n }\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"empty\") {\n return {\n args,\n warning:\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js — ` +\n \"no host is defined, so commands keep their classic handling.\",\n };\n }\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n return { args };\n}\n\n/**\n * `ph run <host> [verb] <runner arguments>`: moves the runner's arguments\n * behind a `--`, so the `run` command takes them as they are instead of\n * refusing the ones it does not know. The verb is spelled out: after the `--`\n * nothing is read as one. Any other invocation is returned as it is.\n */\nexport function forwardRunnerArgv(args: string[]): string[] {\n if (args[0] !== \"run\") return args;\n const { host, verb, own, argv } = splitRunArgv(args.slice(1));\n if (host === undefined || argv.length === 0) return args;\n return [\"run\", host, verb ?? \"run\", ...own, \"--\", ...argv];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,kCAAkB,IAAI,IAAI,CAAC,OAAO,CAAC;AAEzC,SAAgB,cACd,MACA,eACA,aACgB;CAChB,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,GAChC,OAAO,EAAE,KAAK;CAEhB,IAAI,cAAc,IAAI,KAAK,GAAG;EAC5B,IAAI,gBAAgB,IAAI,KAAK,GAAG;GAC9B,MAAM,QAAQ,iBAAiB,WAAW;GAC1C,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;EAEpC;EACA,OAAO,EAAE,KAAK;CAChB;CACA,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,IAAI,MAAM,SAAS,SACjB,OAAO;EACL;EACA,SACE,oBAAoB,MAAM,IAAI;CAElC;CAEF,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;CAElC,OAAO,EAAE,KAAK;AAChB;;;;;;;AAQA,SAAgB,kBAAkB,MAA0B;CAC1D,IAAI,KAAK,OAAO,OAAO,OAAO;CAC9B,MAAM,EAAE,MAAM,MAAM,KAAK,SAAS,aAAa,KAAK,MAAM,CAAC,CAAC;CAC5D,IAAI,SAAS,KAAA,KAAa,KAAK,WAAW,GAAG,OAAO;CACpD,OAAO;EAAC;EAAO;EAAM,QAAQ;EAAO,GAAG;EAAK;EAAM,GAAG;CAAI;AAC3D","debug_id":"e23fc75f-8869-53a6-ab18-158238bfc87e"}
@@ -1,4 +1,4 @@
1
- import { n as RunnerHandle, t as RunnerContext } from "../index-Dy3U1WqW.mjs";
1
+ import { n as RunnerHandle, t as RunnerContext } from "../index-H3AYe65i.mjs";
2
2
  import { ConnectHostParsed, ConnectOutputs } from "@powerhousedao/ph-run/runners/connect";
3
3
  export * from "@powerhousedao/ph-run/runners/connect";
4
4
  //#region src/runners/connect.d.ts
@@ -31,7 +31,7 @@ async function toStudioArgs(host, passed) {
31
31
  const viteCacheOf = (host, ctx) => join(ctx.projectRoot, "node_modules", `.vite-${host.name.replace(/[^\w.-]/g, "_")}`);
32
32
  async function dev(host, ctx) {
33
33
  await validateComposition(host, ctx);
34
- const { runConnectStudio } = await import("../connect-studio-KdRWcq-A.mjs");
34
+ const { runConnectStudio } = await import("../connect-studio-D58ByAAn.mjs");
35
35
  const args = await toStudioArgs(host, await connectInvocationArgs(host, ctx));
36
36
  const studio = {};
37
37
  const override = callerOverride(host, ctx, ctx.verb);
@@ -61,7 +61,7 @@ const run = dev;
61
61
  /** P3.3 — `build`: the SAME service as classic `ph connect build`. */
62
62
  async function build(host, ctx) {
63
63
  await validateComposition(host, ctx);
64
- const { runConnectBuild } = await import("../connect-build-q1QDwrH9.mjs");
64
+ const { runConnectBuild } = await import("../connect-build-Bwz5FCLl.mjs");
65
65
  const { classicConnectBuildArgs } = await import("../classic-args-mH_DVsgC.mjs");
66
66
  const classic = await classicConnectBuildArgs();
67
67
  await runConnectBuild({
@@ -1,4 +1,4 @@
1
- import { t as RunnerContext } from "../index-Dy3U1WqW.mjs";
1
+ import { t as RunnerContext } from "../index-H3AYe65i.mjs";
2
2
  import { SwitchboardHandle, SwitchboardHostParsed } from "@powerhousedao/ph-run/runners/switchboard";
3
3
  export * from "@powerhousedao/ph-run/runners/switchboard";
4
4
  //#region src/runners/switchboard.d.ts
@@ -1,7 +1,7 @@
1
1
 
2
2
  !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0de87e24-afd6-5e67-bda7-2d34eb9241c2")}catch(e){}}();
3
- import { A as normalizePluginEntries, h as entryActiveForVerb, j as normalizePluginEntry } from "../compound-CDrU3CLt-gW8JNJQK.mjs";
4
- import { c as resolveDriveDeclaration, o as projectDriveId } from "../dist-seTzvoSw.mjs";
3
+ import { A as normalizePluginEntries, h as entryActiveForVerb, j as normalizePluginEntry } from "../compound-DKi56SSx-CXQHhS6t.mjs";
4
+ import { s as projectDriveId, u as resolveDriveDeclaration } from "../dist-DXcB8fAF.mjs";
5
5
  import { DEFAULT_SWITCHBOARD_PORT } from "@powerhousedao/shared/clis/constants";
6
6
  import { VETRA_PROCESSOR_CONFIG_KEY } from "@powerhousedao/config";
7
7
  import { dev as dev$1, run as run$1 } from "@powerhousedao/ph-run/runners/switchboard";
@@ -19,7 +19,7 @@ const verbs = [
19
19
  /** Build the project's reactor package (the SAME service as `ph build`) — what
20
20
  * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
21
21
  async function build(host, _ctx) {
22
- const { runBuild } = await import("../build-BdQFCpwz.mjs");
22
+ const { runBuild } = await import("../build-DKS03LRl.mjs");
23
23
  const { classicBuildArgs } = await import("../classic-args-mH_DVsgC.mjs");
24
24
  const classic = await classicBuildArgs();
25
25
  await runBuild({
@@ -1,6 +1,6 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1f4c75ad-91d6-5484-817f-d5377a1a18be")}catch(e){}}();
3
- import { t as getVersion } from "./get-version-L0a1H7iV.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8bca089f-cd80-5d57-9f52-adabd577f8ef")}catch(e){}}();
3
+ import { t as getVersion } from "./get-version-DrPnQWsE.mjs";
4
4
  import { f as verifyReleaseApproval, i as revisionFiles, n as publishedFiles, o as packRelease, r as readReleaseApproval, s as packedDigests, u as decisionWithoutApproval } from "./files-D6_euBBn.mjs";
5
5
  //#region src/services/release/verify.ts
6
6
  /**
@@ -67,5 +67,5 @@ function checkApprovalBeforePublish(packageRoot, required) {
67
67
  //#endregion
68
68
  export { checkApprovalBeforePublish, renderReleaseDecision, verifyRelease };
69
69
 
70
- //# sourceMappingURL=verify-DxhwtFdv.mjs.map
71
- //# debugId=1f4c75ad-91d6-5484-817f-d5377a1a18be
70
+ //# sourceMappingURL=verify-fPOZMFVM.mjs.map
71
+ //# debugId=8bca089f-cd80-5d57-9f52-adabd577f8ef
@@ -1 +1 @@
1
- {"version":3,"file":"verify-DxhwtFdv.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OA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_id":"1f4c75ad-91d6-5484-817f-d5377a1a18be"}
1
+ {"version":3,"file":"verify-fPOZMFVM.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OAAqB,oBAAoB,WAAW,GACpD,WACiB;CACjB,IAAI,KAAK,SAAS,SAAS,OAAO,wBAAwB,IAAI;CAC9D,MAAM,EAAE,aAAa;CACrB,OAAO,sBAAsB,UAAU;EACrC,cAAc,WAAW;EACzB,OAAO,cAAc,aAAa,CAChC,SAAS,QACT,GAAG,SAAS,gBAAgB,QAC9B,CAAC;EACD,gBAAgB,aAAa,eAAe,WAAW;CACzD,CAAC;AACH;AAEA,MAAM,YAAmE;CACvE,UAAU;CACV,SAAS;CACT,YAAY;CACZ,OAAO;CACP,SAAS;AACX;;AAGA,SAAgB,sBAAsB,UAAmC;CACvE,OAAO,CACL,GAAG,SAAS,SAAS,IAAI,UAAU,SAAS,aAC5C,GAAG,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,CACrD,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;;AAiBA,SAAgB,2BACd,aACA,UACc;CACd,MAAM,OAAO,oBAAoB,WAAW;CAC5C,IAAI,KAAK,SAAS,aAAa,CAAC,UAAU,OAAO,EAAE,SAAS,KAAK;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CACf,IAAI;EACF,IAAI,YAAY,KAAK,SAAS,SAAS,SAAS,YAAY,WAAW;EACvE,MAAM,WAAW,cACf,aACA,MACA,UAAU,cAAc,MAAM,CAChC;EACA,WAAW,SAAS,aAAa;EACjC,OAAO,sBAAsB,QAAQ;CACvC,SAAS,OAAO;EACd,OAAO,8CAA8C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC5G;CACA,IAAI,UAAU;EACZ,QAAQ,IAAI,KAAK,MAAM;EACvB,OAAO;GAAE,SAAS;GAAM;EAAO;CACjC;CACA,QAAQ,QAAQ;CAChB,IAAI,UAAU;EACZ,QAAQ,MACN,KAAK,KAAK,gHACZ;EACA,OAAO,EAAE,SAAS,MAAM;CAC1B;CACA,QAAQ,KACN,KAAK,KAAK,sHACZ;CACA,OAAO,EAAE,SAAS,KAAK;AACzB","debug_id":"8bca089f-cd80-5d57-9f52-adabd577f8ef"}
@@ -1,11 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c707015a-3471-5138-870f-09b3d88af64d")}catch(e){}}();
3
- import { i as mergeDefaultDrives, s as rebaseDriveUrl } from "./dist-seTzvoSw.mjs";
4
- import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed } from "./cli-connect-override-31gBnNxd.mjs";
5
- import { t as runConnectStudio } from "./connect-studio-Ds-mfXJI.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3ed4dd04-66f1-5195-a6c4-f37a92626c40")}catch(e){}}();
3
+ import { a as mergeDefaultDrives, c as rebaseDriveUrl, i as installStopChannel } from "./dist-DXcB8fAF.mjs";
4
+ import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed } from "./cli-connect-override-D22yFWlC.mjs";
5
+ import { t as runConnectStudio } from "./connect-studio-BnfhpIv8.mjs";
6
6
  import { a as generateProjectDriveId, s as getProjectInfo, t as POWERHOUSE_CONFIG_FILE } from "./utils-9KyRM0mf.mjs";
7
- import { c as syncMcpPortNotices, i as clearVetraRuntime, l as vetraRuntimeRecord, n as runVetraRefusal, o as probeVetraRuntime, u as writeVetraRuntime } from "./vetra-instance-B0bXPj7g.mjs";
8
- import { i as stopVetra } from "./vetra-launch-T_uLKaR3.mjs";
7
+ import { c as syncMcpPortNotices, i as clearVetraRuntime, l as vetraRuntimeRecord, n as runVetraRefusal, o as probeVetraRuntime, u as writeVetraRuntime } from "./vetra-instance-CzhYIjxL.mjs";
8
+ import { i as stopVetra } from "./vetra-launch-qi10Unax.mjs";
9
9
  import { n as printVetraSwitchboardUrls, r as vetraProcessorConfigOf, t as configureVetraRemoteDrive } from "./vetra-switchboard-tzdc14KA.mjs";
10
10
  import { join } from "node:path";
11
11
  import { blue, green, red, yellow } from "colorette";
@@ -264,6 +264,7 @@ async function startVetra(args) {
264
264
  writeVetraRuntime(projectDir, runtimeRecord);
265
265
  const releaseRuntimeRecord = () => clearVetraRuntime(projectDir, process.pid);
266
266
  process.on("exit", releaseRuntimeRecord);
267
+ installStopChannel();
267
268
  process.on("SIGINT", () => {
268
269
  releaseRuntimeRecord();
269
270
  process.exit(130);
@@ -347,5 +348,5 @@ async function startVetra(args) {
347
348
  //#endregion
348
349
  export { startVetra };
349
350
 
350
- //# sourceMappingURL=vetra-BmluhGRB.mjs.map
351
- //# debugId=c707015a-3471-5138-870f-09b3d88af64d
351
+ //# sourceMappingURL=vetra-CVNZ46pK.mjs.map
352
+ //# debugId=3ed4dd04-66f1-5195-a6c4-f37a92626c40
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vetra-CVNZ46pK.mjs","sources":["../src/utils/resolve-switchboard-port.ts","../src/services/vetra.ts"],"sourcesContent":["import { isPortAvailable } from \"@powerhousedao/switchboard/server\";\nimport { yellow } from \"colorette\";\n\nconst MAX_FALLBACK_ATTEMPTS = 20;\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nasync function findFreePort(start: number): Promise<number | null> {\n for (let i = 0; i < MAX_FALLBACK_ATTEMPTS; i++) {\n const candidate = start + i;\n if (await isPortAvailable(candidate)) return candidate;\n }\n return null;\n}\n\n/**\n * Resolve the port switchboard should bind to. If the requested port is free,\n * returns it unchanged. If it's in use, walks forward for the next free port\n * and — in an interactive terminal — asks the user to confirm the fallback.\n * In CI / piped contexts the fallback is applied automatically so scripts\n * don't hang on an unanswered prompt.\n *\n * Throws a process.exit(1) when the user declines the prompt or when no free\n * port is available in the search window.\n */\nexport async function resolveSwitchboardPort(\n requested: number,\n): Promise<number> {\n if (await isPortAvailable(requested)) return requested;\n\n const candidate = await findFreePort(requested + 1);\n if (candidate === null) {\n console.error(\n `Port ${requested} is in use and no free port was found in the range ${requested}-${requested + MAX_FALLBACK_ATTEMPTS - 1}.`,\n );\n process.exit(1);\n }\n\n if (!isInteractive()) {\n console.log(\n yellow(\n `Port ${requested} is in use. Falling back to port ${candidate} (non-interactive; skipping confirmation).`,\n ),\n );\n return candidate;\n }\n\n const enquirer = await import(\"enquirer\");\n\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `Port ${requested} is in use. Use port ${candidate} instead?`,\n initial: true,\n });\n confirmed = answer.confirmed;\n } catch {\n // user aborted the prompt (Ctrl-C); treat as decline\n confirmed = false;\n }\n\n if (!confirmed) {\n console.error(\n `Aborted. Free port ${requested} or pass --switchboard-port <port> to choose a different port.`,\n );\n process.exit(1);\n }\n\n return candidate;\n}\n","import { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport {\n getConfig,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { join } from \"node:path\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport {\n generateProjectDriveId,\n getProjectInfo,\n POWERHOUSE_CONFIG_FILE,\n} from \"../utils.js\";\nimport { wasFlagExplicitlyPassed } from \"../utils/cli-connect-override.js\";\nimport {\n installStopChannel,\n mergeDefaultDrives,\n rebaseDriveUrl,\n} from \"@powerhousedao/host-core\";\nimport { parseDefaultDrivesUrl } from \"../utils/parse-default-drives.js\";\nimport { resolveSwitchboardPort } from \"../utils/resolve-switchboard-port.js\";\nimport {\n clearVetraRuntime,\n probeVetraRuntime,\n syncMcpPortNotices,\n vetraRuntimeRecord,\n writeVetraRuntime,\n} from \"../utils/vetra-runtime.js\";\nimport { stopVetra } from \"../utils/vetra-launch.js\";\nimport { runVetraRefusal } from \"../utils/vetra-instance.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport {\n configureVetraRemoteDrive,\n printVetraSwitchboardUrls,\n vetraProcessorConfigOf,\n} from \"./vetra-switchboard.js\";\nimport {\n POWERHOUSE_DRIVE_ICON,\n seedWorkflowsDrive,\n startSwitchboard,\n} from \"@powerhousedao/ph-run/switchboard\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\n// rebaseDriveUrl moved to @powerhousedao/host-core (uniform-runners P1.4) —\n// one implementation shared by this classic path and the generic compound.\n\nfunction createViteLogger(color: Color) {\n const customLogger = createLogger(\"info\");\n const loggerInfo = customLogger.info.bind(customLogger);\n customLogger.info = (msg, options) => {\n loggerInfo(color(msg), options);\n };\n const loggerWarn = customLogger.warn.bind(customLogger);\n customLogger.warn = (msg, options) => {\n loggerWarn(yellow(msg), options);\n };\n const loggerError = customLogger.error.bind(customLogger);\n customLogger.error = (msg, options) => {\n loggerError(red(msg), options);\n };\n\n const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n customLogger.warnOnce = (msg, options) => {\n loggerWarnOnce(yellow(msg), options);\n };\n return customLogger;\n}\n\n/** Creates the Vetra Preview drive, or opens it, and opens it in `app` when given. */\nexport async function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n app?: string,\n): Promise<string | null> {\n const previewDriveId = generateProjectDriveId(\"preview\");\n\n const previewDrive = {\n id: previewDriveId,\n slug: previewDriveId,\n global: {\n name: \"Vetra Preview\",\n icon: POWERHOUSE_DRIVE_ICON,\n nodes: [],\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(\n reactor,\n { ...previewDrive, preferredEditor: app },\n port,\n );\n\n if (app && driveUrl) {\n await openDriveIn(reactor, previewDriveId, app);\n }\n\n if (verbose && driveUrl) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl ?? null;\n}\n\n/** Sets the drive's app unless it already has it; a drive from an earlier run keeps its old one otherwise. */\nasync function openDriveIn(\n reactor: IReactorClient,\n driveId: string,\n app: string,\n): Promise<void> {\n const drive = await reactor.read.get(driveId);\n if (drive.header.meta?.preferredEditor === app) {\n return;\n }\n const handle = await reactor.write.setPreferredEditor(driveId, app);\n await handle.readable;\n}\n\n// Studio's drives, read and written on the local Switchboard, so Studio and agents see one set\n// of drives (not with a remote Vetra drive, or a project that sets multiReactor or reactorClient), and no cookie banner.\nexport function buildVetraStudioOverride(\n defaultDrives: PHConnectDefaultDrive[],\n options: {\n remoteDrive?: string;\n projectConnect?: PHConnectRuntimeConfig;\n } = {},\n): PHConnectRuntimeConfig {\n const override: PHConnectRuntimeConfig = {\n drives: { defaultDrives, preserveStrategy: \"preserve-all\" },\n };\n // A first visit's cookie dialog covers the local Studio, agents' browsers included.\n if (options.projectConnect?.app?.cookieBanner === undefined) {\n override.app = { cookieBanner: false };\n }\n const instance = options.projectConnect?.instance;\n if (\n !options.remoteDrive &&\n instance?.multiReactor === undefined &&\n instance?.reactorClient === undefined\n ) {\n override.instance = {\n reactorClient: \"remote\",\n } as typeof override.instance;\n }\n return override;\n}\n\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n const {\n connectPort,\n switchboardPort,\n dev,\n packages,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n remoteDrive,\n interactive,\n watch,\n verbose,\n } = args;\n\n // Convert single remote drive to array if provided\n const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n const vetraProcessorConfig = vetraProcessorConfigOf({\n interactive,\n remoteDrive,\n localDriveUrl: getDefaultVetraUrl(connectPort),\n localDriveId: vetraDriveId,\n });\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n // When the user didn't opt into strict-port semantics, check for a port\n // conflict up front and ask for confirmation before binding a fallback.\n // Doing this in the CLI layer keeps the interactive prompt out of the\n // switchboard server package and aligns with the existing prerelease-tag\n // confirmation flow in `ph publish`.\n const resolvedSwitchboardPort = args.strictPort\n ? switchboardPort\n : await resolveSwitchboardPort(switchboardPort);\n\n try {\n const switchboard = await startSwitchboard(\n {\n ...args,\n useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n mcp: true,\n port: resolvedSwitchboardPort,\n // We've already probed and (when interactive) confirmed the port with\n // the user, so keep the server from running its own fallback on top.\n strictPort: true,\n dev,\n packages,\n remoteDrives,\n vetraDriveId,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n processorConfig,\n basePath: undefined,\n keypairPath: undefined,\n dbPath: args.dbPath,\n useIdentity: undefined,\n migrate: undefined,\n migrateStatus: undefined,\n reset: undefined,\n yes: undefined,\n requireIdentity: undefined,\n },\n logger,\n );\n\n const actualSwitchboardPort = switchboard.port;\n\n // Add preview drive (only in watch mode)\n let previewDriveUrl: string | null = null;\n if (watch) {\n try {\n previewDriveUrl = await startVetraPreviewDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n verbose,\n getConfig(join(process.cwd(), POWERHOUSE_CONFIG_FILE)).vetra\n ?.previewDrive?.app,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n let workflowsDriveUrl: string | null = null;\n if (switchboard.workflowsEnabled) {\n try {\n // Opens in Workflow Studio.\n workflowsDriveUrl = await seedWorkflowsDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n getProjectInfo().path,\n );\n if (verbose && workflowsDriveUrl) {\n console.log(\n blue(`Vetra Switchboard: Workflows drive: ${workflowsDriveUrl}`),\n );\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n printVetraSwitchboardUrls({\n verbose,\n remoteDrive,\n switchboardPort: actualSwitchboardPort,\n driveUrl: switchboard.defaultDriveUrl,\n previewDriveUrl,\n workflowsDriveUrl,\n });\n return {\n driveUrl: switchboard.defaultDriveUrl || \"\",\n previewDriveUrl: previewDriveUrl,\n workflowsDriveUrl,\n switchboardPort: actualSwitchboardPort,\n };\n } catch (error) {\n console.error(\n red(\n `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n throw error instanceof Error ? error : new Error(String(error));\n }\n}\n\nexport async function startVetra(args: VetraArgs) {\n const {\n connectPort,\n verbose,\n remoteDrive,\n disableConnect,\n debug,\n httpsCertFile,\n httpsKeyFile,\n disableLocalPackages,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n watchTimeout,\n } = args;\n\n const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n // One Vetra per project. Two instances over one working tree would contend\n // for the same `.ph/read-model.db` and `.ph/reactor-storage`, and leave the\n // project with two drives that diverge.\n const projectDir = process.cwd();\n const { readPackageSync } = await import(\"read-pkg\");\n const projectName = readPackageSync({ cwd: projectDir }).name;\n let probe = await probeVetraRuntime(projectDir, projectName);\n\n if (\n args.restart &&\n (probe.status === \"live\" || probe.status === \"starting\")\n ) {\n console.log(`Stopping this project's Vetra (pid ${probe.record.pid})...`);\n await stopVetra({ projectDir, projectName });\n probe = await probeVetraRuntime(projectDir, projectName);\n }\n\n if (probe.status === \"live\" || probe.status === \"starting\") {\n console.log();\n console.log(\n green(\n probe.status === \"live\"\n ? \"Vetra is already running for this project.\"\n : \"Vetra is already starting for this project.\",\n ),\n );\n const { record } = probe;\n console.log(\n green(\n ` ➜ Connect: ${record.connectUrl ?? `http://localhost:${record.connectPort}`}`,\n ),\n );\n console.log(\n green(\n ` ➜ Switchboard: ${record.switchboardUrl ?? `http://localhost:${record.switchboardPort}/graphql`}`,\n ),\n );\n console.log(\n `Run \\`ph vetra --restart\\` to restart it, or stop it (pid ${probe.record.pid}).`,\n );\n return;\n }\n\n if (probe.status === \"foreign\") {\n console.error(\n red(\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`,\n ),\n );\n process.exit(1);\n }\n\n // The same project may be held by `ph run vetra` instead: its stack opens\n // the same stores, and publishes this record only once it is ready.\n const hostsRefusal = runVetraRefusal(projectDir, projectName);\n if (hostsRefusal) {\n console.error(red(hostsRefusal));\n process.exit(1);\n }\n\n try {\n // Set default log level to info if not already specified\n if (!process.env.LOG_LEVEL) {\n setLogLevel(\"info\");\n }\n\n if (verbose) {\n switchboardLogger.info(\"Starting Vetra Switchboard...\");\n if (remoteDrive) {\n const source = remoteDrive\n ? \"command line argument\"\n : \"powerhouse.config.json\";\n switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n }\n }\n const switchboardResult = await startLocalVetraSwitchboard(\n {\n ...args,\n dev: true, // Vetra always runs in dev mode to load local packages\n httpsKeyFile,\n httpsCertFile,\n disableLocalPackages,\n debug,\n },\n switchboardLogger,\n );\n const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n const previewDriveUrl = switchboardResult.previewDriveUrl;\n const workflowsDriveUrl = switchboardResult.workflowsDriveUrl;\n const actualSwitchboardPort = switchboardResult.switchboardPort;\n\n // Record what we actually bound, so a second `ph vetra` can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n const runtimeRecord = vetraRuntimeRecord({\n projectName,\n switchboardPort: actualSwitchboardPort,\n connectPort,\n ...(disableConnect\n ? {}\n : { connectUrl: `http://localhost:${connectPort}/` }),\n });\n writeVetraRuntime(projectDir, runtimeRecord);\n // A restarted Vetra may already have written its own.\n const releaseRuntimeRecord = () =>\n clearVetraRuntime(projectDir, process.pid);\n process.on(\"exit\", releaseRuntimeRecord);\n // `ph vetra --restart` stops this one through it on Windows.\n installStopChannel();\n process.on(\"SIGINT\", () => {\n releaseRuntimeRecord();\n process.exit(130);\n });\n process.on(\"SIGTERM\", () => {\n releaseRuntimeRecord();\n process.exit(143);\n });\n\n for (const notice of syncMcpPortNotices(\n projectDir,\n actualSwitchboardPort,\n )) {\n console.log(yellow(notice));\n }\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n await configureVetraRemoteDrive(\n actualSwitchboardPort,\n remoteDrive,\n verbose,\n );\n }\n\n if (verbose) {\n console.log(\"Starting Codegen Reactor...\");\n }\n\n // Start Connect pointing to the drive (unless disabled)\n if (!disableConnect) {\n // --drives-public-base: advertise proxy-reachable drive URLs to the\n // browser instead of the switchboard's localhost origin.\n const publicBase = args.drivesPublicBase;\n const browserDriveUrl = publicBase\n ? rebaseDriveUrl(driveUrl, publicBase)\n : driveUrl;\n const browserPreviewDriveUrl =\n previewDriveUrl && publicBase\n ? rebaseDriveUrl(previewDriveUrl, publicBase)\n : previewDriveUrl;\n const browserWorkflowsDriveUrl =\n workflowsDriveUrl && publicBase\n ? rebaseDriveUrl(workflowsDriveUrl, publicBase)\n : workflowsDriveUrl;\n\n // The resolved default-drive list: vetra's own drives first (the\n // Vetra drive, the preview drive in watch mode, and the Workflows\n // drive when workflows are on), then the\n // project's configured `connect.drives.defaultDrives` from\n // powerhouse.config.json (issue #3023). A drive vetra also starts is\n // listed only once. An explicit `--default-drives-url` is appended on\n // top of this list by buildStudioConnectOverride — it never replaces\n // the vetra drives.\n const vetraDriveEntries = [\n ...(browserDriveUrl\n ? [{ url: browserDriveUrl, name: null, icon: null }]\n : []),\n ...(browserPreviewDriveUrl\n ? [{ url: browserPreviewDriveUrl, name: null, icon: null }]\n : []),\n ...(browserWorkflowsDriveUrl\n ? [{ url: browserWorkflowsDriveUrl, name: null, icon: null }]\n : []),\n ];\n // Read again each time Studio restarts for a changed powerhouse.config.json.\n const studioDrives = () => {\n const projectConnect = getConfig(\n join(projectDir, POWERHOUSE_CONFIG_FILE),\n ).connect;\n const drives = mergeDefaultDrives(\n vetraDriveEntries,\n projectConnect?.drives?.defaultDrives ?? [],\n );\n return { projectConnect, drives };\n };\n const resolvedDefaultDrives = studioDrives().drives;\n\n if (verbose) {\n console.log(\"Starting Connect...\");\n // Mirror buildStudioConnectOverride: an explicit\n // --default-drives-url is appended to the resolved list.\n const flagDefaultDrives = wasFlagExplicitlyPassed(\"default-drives-url\")\n ? parseDefaultDrivesUrl(args.defaultDrivesUrl ?? \"\")\n : [];\n const printedDefaultDrives = mergeDefaultDrives(\n resolvedDefaultDrives,\n flagDefaultDrives,\n );\n console.log(\n ` ➜ Connect will use default drives: ${printedDefaultDrives\n .map((d) => (\"url\" in d ? d.url : `local:${d.id}`))\n .join(\", \")}`,\n );\n }\n console.log();\n console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n const customViteLogger = createViteLogger(green);\n\n // Programmatic override forwarded to the Connect runtime config —\n // vetra always sets these regardless of what the user typed on the\n // command line. We pass it as the explicit third arg to\n // runConnectStudio so it survives the `wasFlagExplicitlyPassed`\n // gating (the user didn't pass --default-drives-url; vetra is setting\n // it itself).\n const vetraDrivesOverride = () => {\n const { projectConnect, drives } = studioDrives();\n return buildVetraStudioOverride(drives, {\n remoteDrive,\n projectConnect,\n });\n };\n\n const studio = await runConnectStudio(\n {\n ...args,\n port: connectPort,\n disableLocalPackages,\n debug,\n host: host,\n open: open,\n cors: cors,\n strictPort: strictPort,\n printUrls: printUrls,\n bindCLIShortcuts: bindCLIShortcuts,\n watchTimeout: watchTimeout,\n },\n customViteLogger,\n vetraDrivesOverride,\n { reloadOnConfigChange: true },\n );\n // Vite may have taken another port, and the base path is Connect's.\n const connectUrl = studio.resolvedUrls?.local[0];\n if (connectUrl && connectUrl !== runtimeRecord.connectUrl) {\n writeVetraRuntime(projectDir, {\n ...runtimeRecord,\n connectPort: Number(new URL(connectUrl).port) || connectPort,\n connectUrl,\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAM,wBAAwB;AAE9B,SAAS,gBAAyB;CAChC,OAAO,QAAQ,QAAQ,MAAM,KAAK,KAAK,CAAC,QAAQ,IAAI;AACtD;AAEA,eAAe,aAAa,OAAuC;CACjE,KAAK,IAAI,IAAI,GAAG,IAAI,uBAAuB,KAAK;EAC9C,MAAM,YAAY,QAAQ;EAC1B,IAAI,MAAM,gBAAgB,SAAS,GAAG,OAAO;CAC/C;CACA,OAAO;AACT;;;;;;;;;;;AAYA,eAAsB,uBACpB,WACiB;CACjB,IAAI,MAAM,gBAAgB,SAAS,GAAG,OAAO;CAE7C,MAAM,YAAY,MAAM,aAAa,YAAY,CAA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AU,CAAC,CAAC,IAAI,KAAK;IACjD;GACF,CAAC;EAEL;CACF,SAAS,OAAO;EACd,QAAQ,MAAM,KAAK;CACrB;AACF","debug_id":"3ed4dd04-66f1-5195-a6c4-f37a92626c40"}
@@ -1,8 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7f64d2a7-d7f3-5205-876c-f47e33a9ff8a")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1470d939-01fa-5c41-9230-80a579f38546")}catch(e){}}();
3
3
  import { _ as unknown, d as object, r as array } from "./schemas-DzgKfQIx.mjs";
4
- import { V as readProjectName, i as STORE_VERBS, r as ONE_SHOT_VERBS } from "./compound-CDrU3CLt-gW8JNJQK.mjs";
5
- import { c as syncMcpPortNotices, i as clearVetraRuntime, l as vetraRuntimeRecord, r as vetraRuntimeRefusal, u as writeVetraRuntime } from "./vetra-instance-B0bXPj7g.mjs";
4
+ import { V as readProjectName, i as STORE_VERBS, r as ONE_SHOT_VERBS } from "./compound-DKi56SSx-CXQHhS6t.mjs";
5
+ import { c as syncMcpPortNotices, i as clearVetraRuntime, l as vetraRuntimeRecord, r as vetraRuntimeRefusal, u as writeVetraRuntime } from "./vetra-instance-CzhYIjxL.mjs";
6
6
  import { yellow } from "colorette";
7
7
  import { outputsSchema } from "@powerhousedao/ph-run/runners/connect";
8
8
  import { outputsSchema as outputsSchema$1 } from "@powerhousedao/ph-run/runners/switchboard";
@@ -75,5 +75,5 @@ function publishVetraRuntime(projectDir, projectName, result) {
75
75
  //#endregion
76
76
  export { runVetraHost };
77
77
 
78
- //# sourceMappingURL=vetra-host-C0Q0oMUW.mjs.map
79
- //# debugId=7f64d2a7-d7f3-5205-876c-f47e33a9ff8a
78
+ //# sourceMappingURL=vetra-host-ChTpJiBJ.mjs.map
79
+ //# debugId=1470d939-01fa-5c41-9230-80a579f38546
@@ -1 +1 @@
1
- {"version":3,"file":"vetra-host-C0Q0oMUW.mjs","sources":["../src/services/run/vetra-host.ts"],"sourcesContent":["import {\n ONE_SHOT_VERBS,\n readProjectName,\n STORE_VERBS,\n} from \"@powerhousedao/host-core\";\nimport { outputsSchema as connectOutputsSchema } from \"@powerhousedao/ph-run/runners/connect\";\nimport { outputsSchema as switchboardOutputsSchema } from \"@powerhousedao/ph-run/runners/switchboard\";\nimport { startRun, type StartRunArgs } from \"@powerhousedao/ph-run/start-run\";\nimport { yellow } from \"colorette\";\nimport { z } from \"zod\";\nimport { vetraRuntimeRefusal } from \"../../utils/vetra-instance.js\";\nimport {\n clearVetraRuntime,\n syncMcpPortNotices,\n vetraRuntimeRecord,\n writeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"../../utils/vetra-runtime.js\";\n\n/**\n * `ph run vetra`: the vetra host is the generic compound runner over a\n * switchboard and a connect member, so nothing below `ph run` knows it is\n * Vetra. What `ph vetra` does around its own start is done here around\n * startRun instead, with the same helpers: refuse while another Vetra holds\n * the project, publish `.ph/vetra-runtime.json` once the stack is ready,\n * clear it on exit, and correct a drifted `.mcp.json`.\n */\nexport async function runVetraHost(args: StartRunArgs): Promise<unknown> {\n const verb = args.verb ?? \"run\";\n // `build` starts nothing; a store verb is refused for a compound.\n if (ONE_SHOT_VERBS.has(verb) || STORE_VERBS.has(verb)) {\n return startRun(args);\n }\n const projectDir = args.projectRoot ?? process.cwd();\n const projectName = readProjectName(projectDir);\n const refusal = await vetraRuntimeRefusal(projectDir, projectName);\n if (refusal) throw new Error(refusal);\n\n const result = await startRun(args);\n publishVetraRuntime(projectDir, projectName, result);\n return result;\n}\n\nconst startedSchema = z.object({\n started: z.array(z.object({ outputs: z.unknown() })),\n});\n\nconst portOf = (url: string) => Number(new URL(url).port);\n\nfunction firstMatch<T>(\n schema: z.ZodType<T>,\n candidates: unknown[],\n): T | undefined {\n for (const candidate of candidates) {\n const match = schema.safeParse(candidate);\n if (match.success) return match.data;\n }\n return undefined;\n}\n\n/**\n * The record of a ready compound: its members are told apart by the outputs\n * their runners publish, since a host file is free to name them.\n */\nexport function vetraRecordOfRun(\n projectName: string,\n result: unknown,\n): VetraRuntimeRecord | undefined {\n const parsed = startedSchema.safeParse(result);\n const outputs = parsed.success\n ? parsed.data.started.map((member) => member.outputs)\n : [];\n const switchboard = firstMatch(switchboardOutputsSchema, outputs);\n if (!switchboard) return undefined;\n const connect = firstMatch(connectOutputsSchema, outputs);\n return vetraRuntimeRecord({\n projectName,\n switchboardPort: portOf(switchboard.origin),\n // Vite may have taken another port, and the base path is Connect's.\n connectPort: connect ? portOf(connect.origin) : 0,\n switchboardUrl: switchboard.endpoints.graphql,\n mcpUrl: switchboard.endpoints.mcp,\n connectUrl: connect?.endpoints.connect,\n });\n}\n\n/**\n * Publishes the record of the stack startRun returned and syncs the MCP\n * configs to its port. Returns what clears the record again; it also runs on\n * exit. No SIGINT/SIGTERM handler: the compound owns the exit, and its\n * process.exit reaches the exit event.\n */\nexport function publishVetraRuntime(\n projectDir: string,\n projectName: string,\n result: unknown,\n): () => void {\n const record = vetraRecordOfRun(projectName, result);\n if (!record) {\n console.warn(\n yellow(\n \"No switchboard member is running, so .ph/vetra-runtime.json is not written and `ph mcp` will not find this stack.\",\n ),\n );\n return () => {};\n }\n // Record what the stack actually bound, so a second Vetra can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n writeVetraRuntime(projectDir, record);\n // A restarted Vetra may already have written its own.\n const release = () => clearVetraRuntime(projectDir, process.pid);\n process.on(\"exit\", release);\n\n for (const notice of syncMcpPortNotices(projectDir, record.switchboardPort)) {\n console.log(yellow(notice));\n }\n return release;\n}\n"],"names":["z.object","z.array","z.unknown","switchbo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AAgB,oBACd,YACA,aACA,QACY;CACZ,MAAM,SAAS,iBAAiB,aAAa,MAAM;CACnD,IAAI,CAAC,QAAQ;EACX,QAAQ,KACN,OACE,mHACF,CACF;EACA,aAAa,CAAC;CAChB;CAGA,kBAAkB,YAAY,MAAM;CAEpC,MAAM,gBAAgB,kBAAkB,YAAY,QAAQ,GAAG;CAC/D,QAAQ,GAAG,QAAQ,OAAO;CAE1B,KAAK,MAAM,UAAU,mBAAmB,YAAY,OAAO,eAAe,GACxE,QAAQ,IAAI,OAAO,MAAM,CAAC;CAE5B,OAAO;AACT","debug_id":"7f64d2a7-d7f3-5205-876c-f47e33a9ff8a"}
1
+ {"version":3,"file":"vetra-host-ChTpJiBJ.mjs","sources":["../src/services/run/vetra-host.ts"],"sourcesContent":["import {\n ONE_SHOT_VERBS,\n readProjectName,\n STORE_VERBS,\n} from \"@powerhousedao/host-core\";\nimport { outputsSchema as connectOutputsSchema } from \"@powerhousedao/ph-run/runners/connect\";\nimport { outputsSchema as switchboardOutputsSchema } from \"@powerhousedao/ph-run/runners/switchboard\";\nimport { startRun, type StartRunArgs } from \"@powerhousedao/ph-run/start-run\";\nimport { yellow } from \"colorette\";\nimport { z } from \"zod\";\nimport { vetraRuntimeRefusal } from \"../../utils/vetra-instance.js\";\nimport {\n clearVetraRuntime,\n syncMcpPortNotices,\n vetraRuntimeRecord,\n writeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"../../utils/vetra-runtime.js\";\n\n/**\n * `ph run vetra`: the vetra host is the generic compound runner over a\n * switchboard and a connect member, so nothing below `ph run` knows it is\n * Vetra. What `ph vetra` does around its own start is done here around\n * startRun instead, with the same helpers: refuse while another Vetra holds\n * the project, publish `.ph/vetra-runtime.json` once the stack is ready,\n * clear it on exit, and correct a drifted `.mcp.json`.\n */\nexport async function runVetraHost(args: StartRunArgs): Promise<unknown> {\n const verb = args.verb ?? \"run\";\n // `build` starts nothing; a store verb is refused for a compound.\n if (ONE_SHOT_VERBS.has(verb) || STORE_VERBS.has(verb)) {\n return startRun(args);\n }\n const projectDir = args.projectRoot ?? process.cwd();\n const projectName = readProjectName(projectDir);\n const refusal = await vetraRuntimeRefusal(projectDir, projectName);\n if (refusal) throw new Error(refusal);\n\n const result = await startRun(args);\n publishVetraRuntime(projectDir, projectName, result);\n return result;\n}\n\nconst startedSchema = z.object({\n started: z.array(z.object({ outputs: z.unknown() })),\n});\n\nconst portOf = (url: string) => Number(new URL(url).port);\n\nfunction firstMatch<T>(\n schema: z.ZodType<T>,\n candidates: unknown[],\n): T | undefined {\n for (const candidate of candidates) {\n const match = schema.safeParse(candidate);\n if (match.success) return match.data;\n }\n return undefined;\n}\n\n/**\n * The record of a ready compound: its members are told apart by the outputs\n * their runners publish, since a host file is free to name them.\n */\nexport function vetraRecordOfRun(\n projectName: string,\n result: unknown,\n): VetraRuntimeRecord | undefined {\n const parsed = startedSchema.safeParse(result);\n const outputs = parsed.success\n ? parsed.data.started.map((member) => member.outputs)\n : [];\n const switchboard = firstMatch(switchboardOutputsSchema, outputs);\n if (!switchboard) return undefined;\n const connect = firstMatch(connectOutputsSchema, outputs);\n return vetraRuntimeRecord({\n projectName,\n switchboardPort: portOf(switchboard.origin),\n // Vite may have taken another port, and the base path is Connect's.\n connectPort: connect ? portOf(connect.origin) : 0,\n switchboardUrl: switchboard.endpoints.graphql,\n mcpUrl: switchboard.endpoints.mcp,\n connectUrl: connect?.endpoints.connect,\n });\n}\n\n/**\n * Publishes the record of the stack startRun returned and syncs the MCP\n * configs to its port. Returns what clears the record again; it also runs on\n * exit. No SIGINT/SIGTERM handler: the compound owns the exit, and its\n * process.exit reaches the exit event.\n */\nexport function publishVetraRuntime(\n projectDir: string,\n projectName: string,\n result: unknown,\n): () => void {\n const record = vetraRecordOfRun(projectName, result);\n if (!record) {\n console.warn(\n yellow(\n \"No switchboard member is running, so .ph/vetra-runtime.json is not written and `ph mcp` will not find this stack.\",\n ),\n );\n return () => {};\n }\n // Record what the stack actually bound, so a second Vetra can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n writeVetraRuntime(projectDir, record);\n // A restarted Vetra may already have written its own.\n const release = () => clearVetraRuntime(projectDir, process.pid);\n process.on(\"exit\", release);\n\n for (const notice of syncMcpPortNotices(projectDir, record.switchboardPort)) {\n console.log(yellow(notice));\n }\n return release;\n}\n"],"names":["z.object","z.array","z.unknown","switchboardOutputsSchema","connectOutputsSchema"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,eAAsB,aAAa,MAAsC;CACvE,MAAM,OAAO,KAAK,QAAQ;CAE1B,IAAI,eAAe,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,GAClD,OAAO,SAAS,IAAI;CAEtB,MAAM,aAAa,KAAK,eAAe,QAAQ,IAAI;CACnD,MAAM,cAAc,gBAAgB,UAAU;CAC9C,MAAM,UAAU,MAAM,oBAAoB,YAAY,WAAW;CACjE,IAAI,SAAS,MAAM,IAAI,MAAM,OAAO;CAEpC,MAAM,SAAS,MAAM,SAAS,IAAI;CAClC,oBAAoB,YAAY,aAAa,MAAM;CACnD,OAAO;AACT;AAEA,MAAM,gBAAgBA,OAAS,EAC7B,SAASC,MAAQD,OAAS,EAAE,SAASE,QAAU,EAAE,CAAC,CAAC,EACrD,CAAC;AAED,MAAM,UAAU,QAAgB,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI;AAExD,SAAS,WACP,QACA,YACe;CACf,KAAK,MAAM,aAAa,YAAY;EAClC,MAAM,QAAQ,OAAO,UAAU,SAAS;EACxC,IAAI,MAAM,SAAS,OAAO,MAAM;CAClC;AAEF;;;;;AAMA,SAAgB,iBACd,aACA,QACgC;CAChC,MAAM,SAAS,cAAc,UAAU,MAAM;CAC7C,MAAM,UAAU,OAAO,UACnB,OAAO,KAAK,QAAQ,KAAK,WAAW,OAAO,OAAO,IAClD,CAAC;CACL,MAAM,cAAc,WAAWC,iBAA0B,OAAO;CAChE,IAAI,CAAC,aAAa,OAAO,KAAA;CACzB,MAAM,UAAU,WAAWC,eAAsB,OAAO;CACxD,OAAO,mBAAmB;EACxB;EACA,iBAAiB,OAAO,YAAY,MAAM;EAE1C,aAAa,UAAU,OAAO,QAAQ,MAAM,IAAI;EAChD,gBAAgB,YAAY,UAAU;EACtC,QAAQ,YAAY,UAAU;EAC9B,YAAY,SAAS,UAAU;CACjC,CAAC;AACH;;;;;;;AAQA,SAAgB,oBACd,YACA,aACA,QACY;CACZ,MAAM,SAAS,iBAAiB,aAAa,MAAM;CACnD,IAAI,CAAC,QAAQ;EACX,QAAQ,KACN,OACE,mHACF,CACF;EACA,aAAa,CAAC;CAChB;CAGA,kBAAkB,YAAY,MAAM;CAEpC,MAAM,gBAAgB,kBAAkB,YAAY,QAAQ,GAAG;CAC/D,QAAQ,GAAG,QAAQ,OAAO;CAE1B,KAAK,MAAM,UAAU,mBAAmB,YAAY,OAAO,eAAe,GACxE,QAAQ,IAAI,OAAO,MAAM,CAAC;CAE5B,OAAO;AACT","debug_id":"1470d939-01fa-5c41-9230-80a579f38546"}
@@ -1,6 +1,6 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ad01a2f1-f8cb-5b4f-b17a-43c2cdabcde1")}catch(e){}}();
3
- import { L as probeRun } from "./compound-CDrU3CLt-gW8JNJQK.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f83d5f31-5268-587e-aef9-c05f9e0318fc")}catch(e){}}();
3
+ import { L as probeRun } from "./compound-DKi56SSx-CXQHhS6t.mjs";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
@@ -197,5 +197,5 @@ async function vetraRuntimeRefusal(projectDir, projectName) {
197
197
  //#endregion
198
198
  export { isPortInUse as a, syncMcpPortNotices as c, clearVetraRuntime as i, vetraRuntimeRecord as l, runVetraRefusal as n, probeVetraRuntime as o, vetraRuntimeRefusal as r, readVetraRuntime as s, VETRA_HOST as t, writeVetraRuntime as u };
199
199
 
200
- //# sourceMappingURL=vetra-instance-B0bXPj7g.mjs.map
201
- //# debugId=ad01a2f1-f8cb-5b4f-b17a-43c2cdabcde1
200
+ //# sourceMappingURL=vetra-instance-CzhYIjxL.mjs.map
201
+ //# debugId=f83d5f31-5268-587e-aef9-c05f9e0318fc
@@ -1 +1 @@
1
- {"version":3,"file":"vetra-instance-B0bXPj7g.mjs","sources":["../src/utils/vetra-runtime.ts","../src/utils/vetra-instance.ts"],"sourcesContent":["import { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport fs from \"node:fs\";\nimport net from \"node:net\";\nimport path from \"node:path\";\n\nexport type VetraRuntimeRecord = {\n pid: number;\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n /** The Switchboard's GraphQL endpoint; absent in records from before it was written. */\n switchboardUrl?: string;\n mcpUrl: string;\n /** Vetra Studio; absent with --disable-connect. */\n connectUrl?: string;\n startedAt: string;\n};\n\nexport type VetraProbe =\n | { status: \"none\" }\n | { status: \"stale\" }\n | { status: \"starting\"; record: VetraRuntimeRecord }\n | { status: \"live\"; record: VetraRuntimeRecord }\n | { status: \"foreign\"; record: VetraRuntimeRecord };\n\nconst READY_TIMEOUT_MS = 2000;\n\n// Under the project's .ph tree — relocated with it by PH_USER_DATA_DIR.\nconst recordPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-runtime.json\");\n\nexport function readVetraRuntime(\n projectDir: string,\n): VetraRuntimeRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(recordPath(projectDir), \"utf8\"),\n ) as VetraRuntimeRecord;\n } catch {\n // Missing or corrupt: either way there is no usable record.\n return undefined;\n }\n}\n\nexport function writeVetraRuntime(\n projectDir: string,\n record: VetraRuntimeRecord,\n): void {\n const target = recordPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\n/**\n * The record this process publishes for the Vetra it started. `ph vetra` and\n * `ph run vetra` both build it here, so the two write the same fields. The\n * Switchboard's URLs follow from its port unless the caller knows them.\n */\nexport function vetraRuntimeRecord(input: {\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n switchboardUrl?: string;\n mcpUrl?: string;\n /** Left out when no Vetra Studio runs. */\n connectUrl?: string;\n}): VetraRuntimeRecord {\n const { switchboardPort, connectUrl } = input;\n return {\n pid: process.pid,\n projectName: input.projectName,\n switchboardPort,\n connectPort: input.connectPort,\n switchboardUrl:\n input.switchboardUrl ?? `http://localhost:${switchboardPort}/graphql`,\n mcpUrl: input.mcpUrl ?? `http://localhost:${switchboardPort}/mcp`,\n ...(connectUrl ? { connectUrl } : {}),\n startedAt: new Date().toISOString(),\n };\n}\n\n/** Deletes the record; with `pid`, only the record of that process. */\nexport function clearVetraRuntime(projectDir: string, pid?: number): void {\n if (pid !== undefined && readVetraRuntime(projectDir)?.pid !== pid) return;\n try {\n fs.rmSync(recordPath(projectDir));\n } catch {\n // Already gone.\n }\n}\n\nfunction isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means the process exists but belongs to another user.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nexport function isPortInUse(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = net.connect({ port, host: \"localhost\" });\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"error\", () => resolve(false));\n });\n}\n\nasync function isReady(port: number): Promise<boolean> {\n try {\n const response = await fetch(`http://localhost:${port}/ready`, {\n signal: AbortSignal.timeout(READY_TIMEOUT_MS),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * Decide whether the recorded instance is actually serving this project.\n *\n * All three checks are load-bearing. A pid can be reused by an unrelated\n * process, so a live pid proves nothing on its own. Another project's\n * switchboard would answer `/ready` on its own port, so a healthy `/ready`\n * proves nothing either. And the recorded `projectName` is what separates\n * \"my instance\" from \"someone else's instance that happens to hold this\n * port\" — which is precisely the confusion that let an agent write document\n * models into a different project's drive.\n *\n * A stale record is deleted so the next start is unblocked. A foreign one is\n * left alone: it describes something that is alive.\n */\nexport async function probeVetraRuntime(\n projectDir: string,\n projectName: string,\n): Promise<VetraProbe> {\n const record = readVetraRuntime(projectDir);\n if (!record) return { status: \"none\" };\n\n const alive = isPidAlive(record.pid);\n const ready = alive && (await isReady(record.switchboardPort));\n // The record lands once the port is bound; `/ready` turns 200 later.\n const starting =\n alive && !ready && (await isPortInUse(record.switchboardPort));\n if (!ready && !starting) {\n clearVetraRuntime(projectDir);\n return { status: \"stale\" };\n }\n\n if (record.projectName !== projectName) {\n return { status: \"foreign\", record };\n }\n return ready ? { status: \"live\", record } : { status: \"starting\", record };\n}\n\nconst MCP_FILES = [\n \".mcp.json\",\n path.join(\".cursor\", \"mcp.json\"),\n path.join(\".gemini\", \"settings.json\"),\n];\n\ntype McpConfig = { mcpServers?: Record<string, { url?: string }> };\ntype UrlMcpConfig = [string, McpConfig, { url?: string }];\n\n/** Each MCP config whose `reactor-mcp` entry still points at a URL. */\nfunction urlMcpConfigs(projectDir: string): UrlMcpConfig[] {\n const found: UrlMcpConfig[] = [];\n for (const rel of MCP_FILES) {\n const target = path.join(projectDir, rel);\n if (!fs.existsSync(target)) continue;\n let parsed: McpConfig;\n try {\n parsed = JSON.parse(fs.readFileSync(target, \"utf8\")) as McpConfig;\n } catch {\n // Hand-broken JSON is the author's to fix; don't clobber it.\n continue;\n }\n const server = parsed.mcpServers?.[\"reactor-mcp\"];\n if (server?.url) found.push([rel, parsed, server]);\n }\n return found;\n}\n\n/** The MCP configs `ph migrate` would move to the `ph mcp` launcher. */\nexport function legacyMcpConfigs(projectDir: string): string[] {\n return urlMcpConfigs(projectDir).map(([rel]) => rel);\n}\n\n/**\n * Point every URL-style `reactor-mcp` entry at `port`, returning the files\n * changed. Stdio entries (`ph mcp`) carry no port and are left alone; this\n * keeps projects that have not run `ph migrate` working.\n */\nexport function syncMcpPort(projectDir: string, port: number): string[] {\n const changed: string[] = [];\n const wanted = `http://localhost:${port}/mcp`;\n for (const [rel, parsed, server] of urlMcpConfigs(projectDir)) {\n if (server.url === wanted) continue;\n server.url = wanted;\n fs.writeFileSync(\n path.join(projectDir, rel),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n );\n changed.push(rel);\n }\n return changed;\n}\n\n/**\n * {@link syncMcpPort} for a Vetra that just bound `port`, returning what to\n * tell the user. An MCP client resolved `.mcp.json` before this process\n * started and cannot re-read it, so a drifted literal means the agent is\n * pointed at the wrong port — possibly another project's reactor. Correct the\n * file and say so plainly; we cannot fix the already-open client ourselves.\n */\nexport function syncMcpPortNotices(projectDir: string, port: number): string[] {\n const notices: string[] = [];\n const driftedMcpFiles = syncMcpPort(projectDir, port);\n if (driftedMcpFiles.length > 0) {\n notices.push(\n `Updated ${driftedMcpFiles.join(\" and \")} to port ${port}. ` +\n `Reconnect your MCP client (/mcp) to pick it up. ` +\n `This edit is local — do not commit it.`,\n );\n }\n if (legacyMcpConfigs(projectDir).length > 0) {\n notices.push(\n \"reactor-mcp still points at a URL; run `ph migrate` to switch it to the `ph mcp` launcher.\",\n );\n }\n return notices;\n}\n","import { probeRun } from \"@powerhousedao/host-core\";\nimport { probeVetraRuntime } from \"./vetra-runtime.js\";\n\n/**\n * One Vetra per project, whichever command started it. `ph vetra` records\n * itself in `.ph/vetra-runtime.json`; `ph run vetra` records its stack in\n * `.ph/run/vetra.json` and, once ready, in `.ph/vetra-runtime.json` too.\n * Each start asks here whether the other kind holds the project.\n */\n\n/** The host folder `ph vetra` routes to, and the name its host file carries. */\nexport const VETRA_HOST = \"vetra\";\n\n/** Why `ph vetra` must not start: a live `ph run vetra` holds the project. */\nexport function runVetraRefusal(\n projectDir: string,\n projectName: string,\n): string | undefined {\n const probe = probeRun(projectDir, VETRA_HOST, projectName);\n if (probe.status === \"live\" && probe.record.pid !== process.pid) {\n return (\n `Vetra is already running for this project through \\`ph run ${VETRA_HOST}\\` ` +\n `(pid ${probe.record.pid}). Stop it before starting another.`\n );\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/run/${VETRA_HOST}.json describes a live \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance.`\n );\n }\n return undefined;\n}\n\n/** Why `ph run vetra` must not start: a live Vetra holds the project. */\nexport async function vetraRuntimeRefusal(\n projectDir: string,\n projectName: string,\n): Promise<string | undefined> {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\" || probe.status === \"starting\") {\n if (probe.record.pid === process.pid) return undefined;\n return `Vetra is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`;\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`\n );\n }\n return undefined;\n}\n"],"names":[],"mappings":";;;;;;;;AAyBA,MAAM,mBAAmB;AAGzB,MAAM,cAAc,eAClB,KAAK,KAAK,aAAa,UAAU,GAAG,oBAAoB;AAE1D,SAAgB,iBACd,YACgC;CAChC,IAAI;EACF,OAAO,KAAK,MACV,GAAG,aAAa,WAAW,UAAU,GAAG,MAAM,CAChD;CACF,QAAQ;EAEN;CACF;AACF;AAEA,SAAgB,kBACd,YACA,QACM;CACN,MAAM,SAAS,WAAW,UAAU;CACpC,GAAG,UAAU,KAAK,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;CACtD,GAAG,cAAc,QAAQ,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,GAAG;AACjE;;;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AAC,EAAE,GACrC;EACA,QAAQ,KAAK,GAAG;CAClB;CACA,OAAO;AACT;;;;;;;;AASA,SAAgB,mBAAmB,YAAoB,MAAwB;CAC7E,MAAM,UAAoB,CAAC;CAC3B,MAAM,kBAAkB,YAAY,YAAY,IAAI;CACpD,IAAI,gBAAgB,SAAS,GAC3B,QAAQ,KACN,WAAW,gBAAgB,KAAK,OAAO,EAAE,WAAW,KAAK,yFAG3D;CAEF,IAAI,iBAAiB,UAAU,CAAC,CAAC,SAAS,GACxC,QAAQ,KACN,4FACF;CAEF,OAAO;AACT;;;;;;;;;;ACjOA,MAAa,aAAa;;AAG1B,SAAgB,gBACd,YACA,aACoB;CACpB,MAAM,QAAQ,SAAS,YAAY,YAAY,WAAW;CAC1D,IAAI,MAAM,WAAW,UAAU,MAAM,OAAO,QAAQ,QAAQ,KAC1D,OACE,8DAA8D,WAAW,UACjE,MAAM,OAAO,IAAI;CAG7B,IAAI,MAAM,WAAW,WACnB,OACE,WAAW,WAAW,0BAA0B,MAAM,OAAO,YAAY,0BACjD,YAAY;AAI1C;;AAGA,eAAsB,oBACpB,YACA,aAC6B;CAC7B,MAAM,QAAQ,MAAM,kBAAkB,YAAY,WAAW;CAC7D,IAAI,MAAM,WAAW,UAAU,MAAM,WAAW,YAAY;EAC1D,IAAI,MAAM,OAAO,QAAQ,QAAQ,KAAK,OAAO,KAAA;EAC7C,OAAO,kDAAkD,MAAM,OAAO,IAAI;CAC5E;CACA,IAAI,MAAM,WAAW,WACnB,OACE,sDAAsD,MAAM,OAAO,YAAY,0BACvD,YAAY;AAK1C","debug_id":"ad01a2f1-f8cb-5b4f-b17a-43c2cdabcde1"}
1
+ {"version":3,"file":"vetra-instance-CzhYIjxL.mjs","sources":["../src/utils/vetra-runtime.ts","../src/utils/vetra-instance.ts"],"sourcesContent":["import { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport fs from \"node:fs\";\nimport net from \"node:net\";\nimport path from \"node:path\";\n\nexport type VetraRuntimeRecord = {\n pid: number;\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n /** The Switchboard's GraphQL endpoint; absent in records from before it was written. */\n switchboardUrl?: string;\n mcpUrl: string;\n /** Vetra Studio; absent with --disable-connect. */\n connectUrl?: string;\n startedAt: string;\n};\n\nexport type VetraProbe =\n | { status: \"none\" }\n | { status: \"stale\" }\n | { status: \"starting\"; record: VetraRuntimeRecord }\n | { status: \"live\"; record: VetraRuntimeRecord }\n | { status: \"foreign\"; record: VetraRuntimeRecord };\n\nconst READY_TIMEOUT_MS = 2000;\n\n// Under the project's .ph tree — relocated with it by PH_USER_DATA_DIR.\nconst recordPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-runtime.json\");\n\nexport function readVetraRuntime(\n projectDir: string,\n): VetraRuntimeRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(recordPath(projectDir), \"utf8\"),\n ) as VetraRuntimeRecord;\n } catch {\n // Missing or corrupt: either way there is no usable record.\n return undefined;\n }\n}\n\nexport function writeVetraRuntime(\n projectDir: string,\n record: VetraRuntimeRecord,\n): void {\n const target = recordPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\n/**\n * The record this process publishes for the Vetra it started. `ph vetra` and\n * `ph run vetra` both build it here, so the two write the same fields. The\n * Switchboard's URLs follow from its port unless the caller knows them.\n */\nexport function vetraRuntimeRecord(input: {\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n switchboardUrl?: string;\n mcpUrl?: string;\n /** Left out when no Vetra Studio runs. */\n connectUrl?: string;\n}): VetraRuntimeRecord {\n const { switchboardPort, connectUrl } = input;\n return {\n pid: process.pid,\n projectName: input.projectName,\n switchboardPort,\n connectPort: input.connectPort,\n switchboardUrl:\n input.switchboardUrl ?? `http://localhost:${switchboardPort}/graphql`,\n mcpUrl: input.mcpUrl ?? `http://localhost:${switchboardPort}/mcp`,\n ...(connectUrl ? { connectUrl } : {}),\n startedAt: new Date().toISOString(),\n };\n}\n\n/** Deletes the record; with `pid`, only the record of that process. */\nexport function clearVetraRuntime(projectDir: string, pid?: number): void {\n if (pid !== undefined && readVetraRuntime(projectDir)?.pid !== pid) return;\n try {\n fs.rmSync(recordPath(projectDir));\n } catch {\n // Already gone.\n }\n}\n\nfunction isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means the process exists but belongs to another user.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nexport function isPortInUse(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = net.connect({ port, host: \"localhost\" });\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"error\", () => resolve(false));\n });\n}\n\nasync function isReady(port: number): Promise<boolean> {\n try {\n const response = await fetch(`http://localhost:${port}/ready`, {\n signal: AbortSignal.timeout(READY_TIMEOUT_MS),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * Decide whether the recorded instance is actually serving this project.\n *\n * All three checks are load-bearing. A pid can be reused by an unrelated\n * process, so a live pid proves nothing on its own. Another project's\n * switchboard would answer `/ready` on its own port, so a healthy `/ready`\n * proves nothing either. And the recorded `projectName` is what separates\n * \"my instance\" from \"someone else's instance that happens to hold this\n * port\" — which is precisely the confusion that let an agent write document\n * models into a different project's drive.\n *\n * A stale record is deleted so the next start is unblocked. A foreign one is\n * left alone: it describes something that is alive.\n */\nexport async function probeVetraRuntime(\n projectDir: string,\n projectName: string,\n): Promise<VetraProbe> {\n const record = readVetraRuntime(projectDir);\n if (!record) return { status: \"none\" };\n\n const alive = isPidAlive(record.pid);\n const ready = alive && (await isReady(record.switchboardPort));\n // The record lands once the port is bound; `/ready` turns 200 later.\n const starting =\n alive && !ready && (await isPortInUse(record.switchboardPort));\n if (!ready && !starting) {\n clearVetraRuntime(projectDir);\n return { status: \"stale\" };\n }\n\n if (record.projectName !== projectName) {\n return { status: \"foreign\", record };\n }\n return ready ? { status: \"live\", record } : { status: \"starting\", record };\n}\n\nconst MCP_FILES = [\n \".mcp.json\",\n path.join(\".cursor\", \"mcp.json\"),\n path.join(\".gemini\", \"settings.json\"),\n];\n\ntype McpConfig = { mcpServers?: Record<string, { url?: string }> };\ntype UrlMcpConfig = [string, McpConfig, { url?: string }];\n\n/** Each MCP config whose `reactor-mcp` entry still points at a URL. */\nfunction urlMcpConfigs(projectDir: string): UrlMcpConfig[] {\n const found: UrlMcpConfig[] = [];\n for (const rel of MCP_FILES) {\n const target = path.join(projectDir, rel);\n if (!fs.existsSync(target)) continue;\n let parsed: McpConfig;\n try {\n parsed = JSON.parse(fs.readFileSync(target, \"utf8\")) as McpConfig;\n } catch {\n // Hand-broken JSON is the author's to fix; don't clobber it.\n continue;\n }\n const server = parsed.mcpServers?.[\"reactor-mcp\"];\n if (server?.url) found.push([rel, parsed, server]);\n }\n return found;\n}\n\n/** The MCP configs `ph migrate` would move to the `ph mcp` launcher. */\nexport function legacyMcpConfigs(projectDir: string): string[] {\n return urlMcpConfigs(projectDir).map(([rel]) => rel);\n}\n\n/**\n * Point every URL-style `reactor-mcp` entry at `port`, returning the files\n * changed. Stdio entries (`ph mcp`) carry no port and are left alone; this\n * keeps projects that have not run `ph migrate` working.\n */\nexport function syncMcpPort(projectDir: string, port: number): string[] {\n const changed: string[] = [];\n const wanted = `http://localhost:${port}/mcp`;\n for (const [rel, parsed, server] of urlMcpConfigs(projectDir)) {\n if (server.url === wanted) continue;\n server.url = wanted;\n fs.writeFileSync(\n path.join(projectDir, rel),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n );\n changed.push(rel);\n }\n return changed;\n}\n\n/**\n * {@link syncMcpPort} for a Vetra that just bound `port`, returning what to\n * tell the user. An MCP client resolved `.mcp.json` before this process\n * started and cannot re-read it, so a drifted literal means the agent is\n * pointed at the wrong port — possibly another project's reactor. Correct the\n * file and say so plainly; we cannot fix the already-open client ourselves.\n */\nexport function syncMcpPortNotices(projectDir: string, port: number): string[] {\n const notices: string[] = [];\n const driftedMcpFiles = syncMcpPort(projectDir, port);\n if (driftedMcpFiles.length > 0) {\n notices.push(\n `Updated ${driftedMcpFiles.join(\" and \")} to port ${port}. ` +\n `Reconnect your MCP client (/mcp) to pick it up. ` +\n `This edit is local — do not commit it.`,\n );\n }\n if (legacyMcpConfigs(projectDir).length > 0) {\n notices.push(\n \"reactor-mcp still points at a URL; run `ph migrate` to switch it to the `ph mcp` launcher.\",\n );\n }\n return notices;\n}\n","import { probeRun } from \"@powerhousedao/host-core\";\nimport { probeVetraRuntime } from \"./vetra-runtime.js\";\n\n/**\n * One Vetra per project, whichever command started it. `ph vetra` records\n * itself in `.ph/vetra-runtime.json`; `ph run vetra` records its stack in\n * `.ph/run/vetra.json` and, once ready, in `.ph/vetra-runtime.json` too.\n * Each start asks here whether the other kind holds the project.\n */\n\n/** The host folder `ph vetra` routes to, and the name its host file carries. */\nexport const VETRA_HOST = \"vetra\";\n\n/** Why `ph vetra` must not start: a live `ph run vetra` holds the project. */\nexport function runVetraRefusal(\n projectDir: string,\n projectName: string,\n): string | undefined {\n const probe = probeRun(projectDir, VETRA_HOST, projectName);\n if (probe.status === \"live\" && probe.record.pid !== process.pid) {\n return (\n `Vetra is already running for this project through \\`ph run ${VETRA_HOST}\\` ` +\n `(pid ${probe.record.pid}). Stop it before starting another.`\n );\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/run/${VETRA_HOST}.json describes a live \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance.`\n );\n }\n return undefined;\n}\n\n/** Why `ph run vetra` must not start: a live Vetra holds the project. */\nexport async function vetraRuntimeRefusal(\n projectDir: string,\n projectName: string,\n): Promise<string | undefined> {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\" || probe.status === \"starting\") {\n if (probe.record.pid === process.pid) return undefined;\n return `Vetra is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`;\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`\n );\n }\n return undefined;\n}\n"],"names":[],"mappings":";;;;;;;;AAyBA,MAAM,mBAAmB;AAGzB,MAAM,cAAc,eAClB,KAAK,KAAK,aAAa,UAAU,GAAG,oBAAoB;AAE1D,SAAgB,iBACd,YACgC;CAChC,IAAI;EACF,OAAO,KAAK,MACV,GAAG,aAAa,WAAW,UAAU,GAAG,MAAM,CAChD;CACF,QAAQ;EAEN;CACF;AACF;AAEA,SAAgB,kBACd,YACA,QACM;CACN,MAAM,SAAS,WAAW,UAAU;CACpC,GAAG,UAAU,KAAK,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;CACtD,GAAG,cAAc,QAAQ,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,GAAG;AACjE;;;;;;AAOA,SAAgB,mBAAmB,OAQZ;CACrB,MAAM,EAAE,iBAAiB,eAAe;CACxC,OAAO;EACL,KAAK,QAAQ;EACb,aAAa,MAAM;EACnB;EACA,aAAa,MAAM;EACnB,gBACE,MAAM,kBAAkB,oBAAoB,gBAAgB;EAC9D,QAAQ,MAAM,UAAU,oBAAoB,gBAAgB;EAC5D,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;EACnC,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;CACpC;AACF;;AAGA,SAAgB,kBAAkB,YAAoB,KAAoB;CACxE,IAAI,QAAQ,KAAA,KAAa,iBAAiB,UAAU,CAAC,EAAE,QAAQ,KAAK;CACpE,IAAI;EACF,GAAG,OAAO,WAAW,UAAU,CAAC;CAClC,QAAQ,CAER;AACF;AAEA,SAAS,WAAW,KAAsB;CACxC,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EAEd,OAAQ,MAAgC,SAAS;CACnD;AAC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AAM,OAAO,YAAY,0BACjD,YAAY;AAI1C;;AAGA,eAAsB,oBACpB,YACA,aAC6B;CAC7B,MAAM,QAAQ,MAAM,kBAAkB,YAAY,WAAW;CAC7D,IAAI,MAAM,WAAW,UAAU,MAAM,WAAW,YAAY;EAC1D,IAAI,MAAM,OAAO,QAAQ,QAAQ,KAAK,OAAO,KAAA;EAC7C,OAAO,kDAAkD,MAAM,OAAO,IAAI;CAC5E;CACA,IAAI,MAAM,WAAW,WACnB,OACE,sDAAsD,MAAM,OAAO,YAAY,0BACvD,YAAY;AAK1C","debug_id":"f83d5f31-5268-587e-aef9-c05f9e0318fc"}
@@ -1,7 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3159fb33-5304-5abc-b690-9d71c181c70d")}catch(e){}}();
3
- import { I as probeHostsFolder } from "./compound-CDrU3CLt-gW8JNJQK.mjs";
4
- import { a as isPortInUse, i as clearVetraRuntime, o as probeVetraRuntime, t as VETRA_HOST } from "./vetra-instance-B0bXPj7g.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="827f4b69-ceb4-5e81-8ca7-b0a8261da2e0")}catch(e){}}();
3
+ import { I as probeHostsFolder } from "./compound-DKi56SSx-CXQHhS6t.mjs";
4
+ import { l as requestStop } from "./dist-DXcB8fAF.mjs";
5
+ import { a as isPortInUse, i as clearVetraRuntime, o as probeVetraRuntime, t as VETRA_HOST } from "./vetra-instance-CzhYIjxL.mjs";
5
6
  import fs from "node:fs";
6
7
  import path from "node:path";
7
8
  import { spawn } from "node:child_process";
@@ -209,7 +210,7 @@ async function stopVetra(options) {
209
210
  } catch {}
210
211
  };
211
212
  options.onProgress?.(`Stopping Vetra (pid ${record.pid})...`);
212
- signal("SIGTERM");
213
+ if (!await requestStop(record.pid)) signal("SIGTERM");
213
214
  if (!await waitForExit(record, Date.now() + timeoutMs)) {
214
215
  signal("SIGKILL");
215
216
  if (!await waitForExit(record, Date.now() + timeoutMs)) throw new VetraStartError(`Vetra (pid ${record.pid}) did not stop within ${Math.round(2 * timeoutMs / 1e3)}s.`);
@@ -232,5 +233,5 @@ async function restartVetra(options) {
232
233
  //#endregion
233
234
  export { vetraCommandFor as a, stopVetra as i, ensureVetra as n, restartVetra as r, VetraStartError as t };
234
235
 
235
- //# sourceMappingURL=vetra-launch-T_uLKaR3.mjs.map
236
- //# debugId=3159fb33-5304-5abc-b690-9d71c181c70d
236
+ //# sourceMappingURL=vetra-launch-qi10Unax.mjs.map
237
+ //# debugId=827f4b69-ceb4-5e81-8ca7-b0a8261da2e0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vetra-launch-qi10Unax.mjs","sources":["../src/utils/vetra-launch.ts"],"sourcesContent":["import { probeHostsFolder, requestStop } from \"@powerhousedao/host-core\";\nimport { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { stripVTControlCharacters } from \"node:util\";\nimport { VETRA_HOST } from \"./vetra-instance.js\";\nimport {\n clearVetraRuntime,\n isPortInUse,\n probeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"./vetra-runtime.js\";\n\nexport type VetraCommand = {\n command: string;\n args: string[];\n /** How messages name it; `ph vetra` when left out. */\n label?: string;\n};\n\nexport type EnsureVetraOptions = {\n projectDir: string;\n projectName: string;\n /** The port a strict-port Vetra will bind. */\n switchboardPort: number;\n command: VetraCommand;\n timeoutMs: number;\n pollMs?: number;\n /** Told what it waits on while Vetra is not ready yet, about once a second. */\n onProgress?: (message: string) => void;\n};\n\nexport class VetraStartError extends Error {}\n\nconst LOG_TAIL_LINES = 60;\nconst PORT_GRACE_MS = 10_000;\nconst STOP_TIMEOUT_MS = 15_000;\nconst PROGRESS_EVERY_MS = 1000;\n\nconst lockPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-start.lock\");\n\nexport const vetraLogPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra.log\");\n\n// Forward slashes, so messages read the same on every platform.\nconst shownLogPath = (projectDir: string) =>\n path.relative(projectDir, vetraLogPath(projectDir)).split(path.sep).join(\"/\");\n\n/** `ph vetra --strictPort --watch` run by the ph-cli executing this code. */\nexport function currentPhCliVetraCommand(): VetraCommand {\n return {\n command: process.execPath,\n args: [process.argv[1], \"vetra\", \"--strictPort\", \"--watch\"],\n };\n}\n\n/** `ph run vetra --strictPort` run by the ph-cli executing this code. */\nexport function currentPhCliRunVetraCommand(): VetraCommand {\n return {\n command: process.execPath,\n args: [process.argv[1], \"run\", VETRA_HOST, \"--strictPort\"],\n label: `ph run ${VETRA_HOST}`,\n };\n}\n\n/**\n * What starts this project's Vetra: its `hosts/vetra` host when it has one,\n * as `ph vetra` itself routes there (run-sugar.ts), else classic `ph vetra`.\n * The host's own defaultVerb picks the verb; `--watch` is not a host argument.\n */\nexport function vetraCommandFor(projectDir: string): VetraCommand {\n const probe = probeHostsFolder(projectDir);\n return probe.kind === \"present\" && probe.hosts.includes(VETRA_HOST)\n ? currentPhCliRunVetraCommand()\n : currentPhCliVetraCommand();\n}\n\nfunction isPidAlive(pid: number | undefined): boolean {\n if (!pid) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\ntype LockRecord = { pid: number; vetraPid?: number };\n\nfunction readLock(projectDir: string): LockRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(lockPath(projectDir), \"utf8\"),\n ) as LockRecord;\n } catch {\n return undefined;\n }\n}\n\nfunction isLockHeld(lock: LockRecord | undefined): boolean {\n return !!lock && (isPidAlive(lock.pid) || isPidAlive(lock.vetraPid));\n}\n\n/** Held while the launcher or the Vetra it started is alive. */\nfunction tryAcquireLock(projectDir: string): boolean {\n const target = lockPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n for (let attempt = 0; attempt < 2; attempt++) {\n try {\n fs.writeFileSync(target, JSON.stringify({ pid: process.pid }), {\n flag: \"wx\",\n });\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (isLockHeld(readLock(projectDir))) return false;\n fs.rmSync(target, { force: true });\n }\n }\n return false;\n}\n\nfunction releaseLock(projectDir: string): void {\n if (readLock(projectDir)?.pid === process.pid) {\n fs.rmSync(lockPath(projectDir), { force: true });\n }\n}\n\nexport function readLogTail(projectDir: string): string {\n try {\n const text = fs.readFileSync(vetraLogPath(projectDir), \"utf8\");\n const lines = stripVTControlCharacters(text).trimEnd().split(\"\\n\");\n return lines.slice(-LOG_TAIL_LINES).join(\"\\n\");\n } catch {\n return \"\";\n }\n}\n\nfunction withOutput(message: string, projectDir: string): VetraStartError {\n const tail = readLogTail(projectDir);\n const where = shownLogPath(projectDir);\n return new VetraStartError(\n tail\n ? `${message}\\n\\nVetra output (last lines of ${where}):\\n${tail}`\n : message,\n );\n}\n\nfunction foreignError(record: VetraRuntimeRecord): VetraStartError {\n return new VetraStartError(\n `.ph/vetra-runtime.json describes a live Vetra for \"${record.projectName}\" (pid ${record.pid}), not this project. ` +\n `Refusing to start a second reactor. Delete .ph/vetra-runtime.json if that record is wrong.`,\n );\n}\n\nasync function waitForLive(\n options: EnsureVetraOptions,\n deadline: number,\n stillStarting: () => boolean,\n): Promise<VetraRuntimeRecord | undefined> {\n const { projectDir, projectName, pollMs = 250, onProgress } = options;\n const startedAt = Date.now();\n let reportedAt = startedAt;\n while (Date.now() < deadline) {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\") return probe.record;\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status !== \"starting\" && !stillStarting()) return undefined;\n if (onProgress && Date.now() - reportedAt >= PROGRESS_EVERY_MS) {\n reportedAt = Date.now();\n const seconds = Math.round((reportedAt - startedAt) / 1000);\n onProgress(`Waiting for Vetra to be ready (${seconds}s)...`);\n }\n await sleep(pollMs);\n }\n return undefined;\n}\n\n/** This project's live Vetra, or a detached `ph vetra` started and awaited; never a second reactor. */\nexport async function ensureVetra(\n options: EnsureVetraOptions,\n): Promise<VetraRuntimeRecord> {\n const { projectDir, projectName, switchboardPort, timeoutMs } = options;\n const deadline = Date.now() + timeoutMs;\n const seconds = Math.round(timeoutMs / 1000);\n const report = options.onProgress ?? (() => {});\n\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\") return probe.record;\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status === \"starting\") {\n report(`Vetra (pid ${probe.record.pid}) is starting; waiting for it...`);\n const record = await waitForLive(options, deadline, () => false);\n if (record) return record;\n throw withOutput(\n `Vetra (pid ${probe.record.pid}) is running but did not answer /ready within ${seconds}s.`,\n projectDir,\n );\n }\n\n while (!tryAcquireLock(projectDir)) {\n // Another launcher is starting Vetra for this project.\n report(\"Another process is starting Vetra for this project; waiting...\");\n const record = await waitForLive(options, deadline, () =>\n isLockHeld(readLock(projectDir)),\n );\n if (record) return record;\n if (Date.now() >= deadline) {\n throw withOutput(\n `Another process is starting Vetra for this project and it did not become ready within ${seconds}s.`,\n projectDir,\n );\n }\n }\n\n let keepLock = false;\n try {\n const again = await probeVetraRuntime(projectDir, projectName);\n if (again.status === \"live\") return again.record;\n if (again.status === \"foreign\") throw foreignError(again.record);\n\n if (again.status === \"starting\" || (await isPortInUse(switchboardPort))) {\n // Maybe a Vetra that bound the port but has not written its record yet.\n const grace = Date.now() + PORT_GRACE_MS;\n const record = await waitForLive(\n options,\n deadline,\n () => Date.now() < grace,\n );\n if (record) return record;\n throw new VetraStartError(\n `Port ${switchboardPort} is in use, but .ph/vetra-runtime.json names no live Vetra for this project. ` +\n `Stop whatever holds the port, or move this project's port (reactor.port in powerhouse.config.json).`,\n );\n }\n\n const logFile = vetraLogPath(projectDir);\n report(`Starting Vetra; its output goes to ${shownLogPath(projectDir)}...`);\n const logFd = fs.openSync(logFile, \"w\");\n let exit: { code: number | null; signal: string | null } | undefined;\n let spawnError: Error | undefined;\n const child = spawn(options.command.command, options.command.args, {\n cwd: projectDir,\n detached: true,\n stdio: [\"ignore\", logFd, logFd],\n windowsHide: true,\n });\n fs.closeSync(logFd);\n child.once(\"error\", (error) => (spawnError = error));\n child.once(\"exit\", (code, signal) => (exit = { code, signal }));\n child.unref();\n if (child.pid) {\n fs.writeFileSync(\n lockPath(projectDir),\n JSON.stringify({ pid: process.pid, vetraPid: child.pid }),\n );\n }\n\n const record = await waitForLive(\n options,\n deadline,\n () => !exit && !spawnError,\n );\n if (record) return record;\n\n if (spawnError) {\n throw new VetraStartError(\n `Could not run \\`${options.command.command}\\`: ${spawnError.message}`,\n );\n }\n if (exit) {\n const how =\n exit.signal !== null\n ? `was killed by ${exit.signal}`\n : `exited with code ${exit.code}`;\n throw withOutput(\n `\\`${options.command.label ?? \"ph vetra\"}\\` ${how} before it was ready.`,\n projectDir,\n );\n }\n // Still booting: keep the lock on its pid so the next call waits instead of spawning.\n keepLock = true;\n throw withOutput(\n `Vetra (pid ${child.pid}) did not answer /ready on port ${switchboardPort} within ${seconds}s. ` +\n `It is still running; the next tool call waits for it again.`,\n projectDir,\n );\n } finally {\n if (!keepLock) releaseLock(projectDir);\n }\n}\n\nasync function waitForExit(\n record: VetraRuntimeRecord,\n deadline: number,\n): Promise<boolean> {\n while (Date.now() < deadline) {\n const gone =\n !isPidAlive(record.pid) && !(await isPortInUse(record.switchboardPort));\n if (gone) return true;\n await sleep(100);\n }\n return false;\n}\n\n/** Stops this project's running Vetra, if any; resolves to the record it stopped. */\nexport async function stopVetra(options: {\n projectDir: string;\n projectName: string;\n timeoutMs?: number;\n onProgress?: (message: string) => void;\n}): Promise<VetraRuntimeRecord | undefined> {\n const { projectDir, projectName, timeoutMs = STOP_TIMEOUT_MS } = options;\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status !== \"live\" && probe.status !== \"starting\") return undefined;\n const { record } = probe;\n const signal = (name: NodeJS.Signals) => {\n try {\n process.kill(record.pid, name);\n } catch {\n // Already gone.\n }\n };\n options.onProgress?.(`Stopping Vetra (pid ${record.pid})...`);\n // On Windows SIGTERM is a kill: ask through the stop channel, and signal\n // only a Vetra that has none.\n if (!(await requestStop(record.pid))) signal(\"SIGTERM\");\n if (!(await waitForExit(record, Date.now() + timeoutMs))) {\n signal(\"SIGKILL\");\n if (!(await waitForExit(record, Date.now() + timeoutMs))) {\n throw new VetraStartError(\n `Vetra (pid ${record.pid}) did not stop within ${Math.round((2 * timeoutMs) / 1000)}s.`,\n );\n }\n }\n clearVetraRuntime(projectDir, record.pid);\n if (readLock(projectDir)?.vetraPid === record.pid) {\n fs.rmSync(lockPath(projectDir), { force: true });\n }\n return record;\n}\n\n/** Stops this project's Vetra and starts it again, detached, as {@link ensureVetra} does. */\nexport async function restartVetra(\n options: EnsureVetraOptions,\n): Promise<VetraRuntimeRecord> {\n const { projectDir, projectName, onProgress } = options;\n const stopped = await stopVetra({ projectDir, projectName, onProgress });\n if (stopped) onProgress?.(`Stopped Vetra (pid ${stopped.pid}).`);\n return ensureVetra(options);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiCA,IAAa,kBAAb,cAAqC,MAAM,CAAC;AAG5C,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAE1B,MAAM,YAAY,eAChB,KAAK,KAAK,aAAa,UAAU,GAAG,kBAAkB;AAExD,MAAa,gBAAgB,eAC3B,KAAK,KAAK,aAAa,UAAU,GAAG,WAAW;AAGjD,MAAM,gBAAg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AAI,GAAG;CAC/D,OAAO,YAAY,OAAO;AAC5B","debug_id":"827f4b69-ceb4-5e81-8ca7-b0a8261da2e0"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "6.3.0-dev.3",
3
+ "version": "6.3.0-dev.4",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -40,18 +40,18 @@
40
40
  "dependencies": {
41
41
  "@modelcontextprotocol/sdk": "1.29.0",
42
42
  "@originjs/vite-plugin-commonjs": "^1.0.3",
43
- "@powerhousedao/builder-tools": "6.3.0-dev.3",
44
- "@powerhousedao/codegen": "6.3.0-dev.3",
45
- "@powerhousedao/common": "6.3.0-dev.3",
46
- "@powerhousedao/config": "6.3.0-dev.3",
47
- "@powerhousedao/ph-run": "6.3.0-dev.3",
48
- "@powerhousedao/reactor": "6.3.0-dev.3",
49
- "@powerhousedao/reactor-api": "6.3.0-dev.3",
50
- "@powerhousedao/reactor-mcp": "6.3.0-dev.3",
51
- "@powerhousedao/shared": "6.3.0-dev.3",
52
- "@powerhousedao/switchboard": "6.3.0-dev.3",
53
- "@powerhousedao/vetra": "6.3.0-dev.3",
54
- "@renown/sdk": "6.3.0-dev.3",
43
+ "@powerhousedao/builder-tools": "6.3.0-dev.4",
44
+ "@powerhousedao/codegen": "6.3.0-dev.4",
45
+ "@powerhousedao/common": "6.3.0-dev.4",
46
+ "@powerhousedao/config": "6.3.0-dev.4",
47
+ "@powerhousedao/ph-run": "6.3.0-dev.4",
48
+ "@powerhousedao/reactor": "6.3.0-dev.4",
49
+ "@powerhousedao/reactor-api": "6.3.0-dev.4",
50
+ "@powerhousedao/reactor-mcp": "6.3.0-dev.4",
51
+ "@powerhousedao/shared": "6.3.0-dev.4",
52
+ "@powerhousedao/switchboard": "6.3.0-dev.4",
53
+ "@powerhousedao/vetra": "6.3.0-dev.4",
54
+ "@renown/sdk": "6.3.0-dev.4",
55
55
  "@sentry/node-core": "^10.52.0",
56
56
  "@tsdown/css": "0.23.0",
57
57
  "@vercel/nft": "^1.11.0",
@@ -60,7 +60,7 @@
60
60
  "change-case": "5.4.4",
61
61
  "cmd-ts": "0.15.0",
62
62
  "colorette": "2.0.20",
63
- "document-model": "6.3.0-dev.3",
63
+ "document-model": "6.3.0-dev.4",
64
64
  "dotenv": "16.4.7",
65
65
  "enquirer": "2.4.1",
66
66
  "graphql": "^16",
@@ -82,8 +82,8 @@
82
82
  "copyfiles": "2.4.1",
83
83
  "write-package": "7.2.0",
84
84
  "zod": "^4.5.4",
85
- "@powerhousedao/desktop": "6.3.0-dev.3",
86
- "@powerhousedao/host-core": "6.3.0-dev.3"
85
+ "@powerhousedao/desktop": "6.3.0-dev.4",
86
+ "@powerhousedao/host-core": "6.3.0-dev.4"
87
87
  },
88
88
  "scripts": {
89
89
  "tsc": "tsc",
@@ -1,4 +0,0 @@
1
- import { t as runBuild } from "./build-CgLN1cEZ.mjs";
2
- export { runBuild };
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8c4f0b3c-5c93-501c-9f85-339b04526dc2")}catch(e){}}();
4
- //# debugId=8c4f0b3c-5c93-501c-9f85-339b04526dc2