@powerhousedao/ph-cli 6.4.0-next.1 → 6.4.0-next.3

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 (107) hide show
  1. package/README.md +6 -5
  2. package/dist/{build-C490lBnu.mjs → build-B-rPwjM8.mjs} +7 -7
  3. package/dist/{build-C490lBnu.mjs.map → build-B-rPwjM8.mjs.map} +1 -1
  4. package/dist/build-DuwAPWMY.mjs +4 -0
  5. package/dist/{check-DIK1LTss.mjs → check-B7C3Vi_b.mjs} +4 -4
  6. package/dist/{check-DIK1LTss.mjs.map → check-B7C3Vi_b.mjs.map} +1 -1
  7. package/dist/{check-D84ta1Dh.mjs → check-DM7UdFTK.mjs} +4 -4
  8. package/dist/{check-D84ta1Dh.mjs.map → check-DM7UdFTK.mjs.map} +1 -1
  9. package/dist/{check-F3nwJiG-.mjs → check-DeUTd514.mjs} +3 -3
  10. package/dist/{cli-connect-override-BMU4Qldg.mjs → cli-connect-override-Bx_g3-ZE.mjs} +4 -4
  11. package/dist/{cli-connect-override-BMU4Qldg.mjs.map → cli-connect-override-Bx_g3-ZE.mjs.map} +1 -1
  12. package/dist/cli.mjs +8 -8
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/{compound-BWLJ0KBw-8hKyrfjG.mjs → compound-Q9sZSEZF-DQvtoigb.mjs} +6 -6
  15. package/dist/compound-Q9sZSEZF-DQvtoigb.mjs.map +1 -0
  16. package/dist/{connect-build-DW1fFVbU.mjs → connect-build-CaTxdYcc.mjs} +5 -5
  17. package/dist/{connect-build-DW1fFVbU.mjs.map → connect-build-CaTxdYcc.mjs.map} +1 -1
  18. package/dist/{connect-config-DVubBBLb.mjs → connect-config-A-U83U8U.mjs} +4 -4
  19. package/dist/{connect-config-DVubBBLb.mjs.map → connect-config-A-U83U8U.mjs.map} +1 -1
  20. package/dist/{connect-studio-CQC-LDSg.mjs → connect-studio-B2gugCJU.mjs} +4 -4
  21. package/dist/{connect-studio-CQC-LDSg.mjs.map → connect-studio-B2gugCJU.mjs.map} +1 -1
  22. package/dist/definitions-worker.mjs +1 -1
  23. package/dist/dev-host-RhWeATKB.mjs +19 -0
  24. package/dist/dev-host-RhWeATKB.mjs.map +1 -0
  25. package/dist/{dist-BFMRL5C0.mjs → dist-D_UjZsgt.mjs} +4 -4
  26. package/dist/dist-D_UjZsgt.mjs.map +1 -0
  27. package/dist/{explain-YPD3n6t8.mjs → explain-DbbHpa61.mjs} +5 -5
  28. package/dist/{explain-YPD3n6t8.mjs.map → explain-DbbHpa61.mjs.map} +1 -1
  29. package/dist/{export-DjQL6zkr.mjs → export-FduYVQEM.mjs} +4 -4
  30. package/dist/{export-DjQL6zkr.mjs.map → export-FduYVQEM.mjs.map} +1 -1
  31. package/dist/{files-D6_euBBn.mjs → files-DEHg350R.mjs} +4 -4
  32. package/dist/{files-D6_euBBn.mjs.map → files-DEHg350R.mjs.map} +1 -1
  33. package/dist/{generate-all-BLot_H9Z.mjs → generate-all-BE8UmbJv.mjs} +6 -21
  34. package/dist/generate-all-BE8UmbJv.mjs.map +1 -0
  35. package/dist/{generate-app-hm6CJ_4O.mjs → generate-app-C7n0j8Ak.mjs} +5 -18
  36. package/dist/generate-app-C7n0j8Ak.mjs.map +1 -0
  37. package/dist/{generate-document-model-BiD6ovXc.mjs → generate-document-model-DSYPTMZg.mjs} +9 -31
  38. package/dist/generate-document-model-DSYPTMZg.mjs.map +1 -0
  39. package/dist/{generate-editor-DBj_Pxwa.mjs → generate-editor-DKuRUeIt.mjs} +5 -18
  40. package/dist/generate-editor-DKuRUeIt.mjs.map +1 -0
  41. package/dist/{generate-processor-BVjOsfjJ.mjs → generate-processor-CwJvJDpd.mjs} +5 -18
  42. package/dist/generate-processor-CwJvJDpd.mjs.map +1 -0
  43. package/dist/{generate-subgraph-DJZCr0Tk.mjs → generate-subgraph-EQ2ZjMp9.mjs} +6 -25
  44. package/dist/generate-subgraph-EQ2ZjMp9.mjs.map +1 -0
  45. package/dist/{get-version-CcYVboCW.mjs → get-version-7oKMD8Gt.mjs} +4 -4
  46. package/dist/{get-version-CcYVboCW.mjs.map → get-version-7oKMD8Gt.mjs.map} +1 -1
  47. package/dist/{index-D3H9pQ8u.d.mts → index-Bs1PfL3W.d.mts} +17 -4
  48. package/dist/index-Bs1PfL3W.d.mts.map +1 -0
  49. package/dist/{mcp-B3l1mtBq.mjs → mcp-CcZT9zT9.mjs} +8 -8
  50. package/dist/mcp-CcZT9zT9.mjs.map +1 -0
  51. package/dist/{migrate-CzcBEypc.mjs → migrate-Ddr7YAtM.mjs} +4 -4
  52. package/dist/{migrate-CzcBEypc.mjs.map → migrate-Ddr7YAtM.mjs.map} +1 -1
  53. package/dist/{migrate-document-models-D0HSo4WN.mjs → migrate-document-models-X_mVTljj.mjs} +4 -4
  54. package/dist/{migrate-document-models-D0HSo4WN.mjs.map → migrate-document-models-X_mVTljj.mjs.map} +1 -1
  55. package/dist/migrate-subgraphs-DEqWkLoh.mjs +4 -0
  56. package/dist/{migrate-subgraphs-CfSMlcJD.mjs → migrate-subgraphs-Ffwwm7Oy.mjs} +5 -5
  57. package/dist/{migrate-subgraphs-CfSMlcJD.mjs.map → migrate-subgraphs-Ffwwm7Oy.mjs.map} +1 -1
  58. package/dist/{ph-cli-commands-CQXdWQ74.mjs → ph-cli-commands-D4Z6YSwd.mjs} +39 -104
  59. package/dist/ph-cli-commands-D4Z6YSwd.mjs.map +1 -0
  60. package/dist/ph-cli-commands-p9cO6MsE.mjs +4 -0
  61. package/dist/{run-sugar-hGKprsKz.mjs → run-sugar-CkuGJuPg.mjs} +16 -8
  62. package/dist/run-sugar-CkuGJuPg.mjs.map +1 -0
  63. package/dist/{run-sugar-BfnRBv7h.mjs → run-sugar-Dd_Mu058.mjs} +3 -3
  64. package/dist/runners/connect.d.mts +1 -1
  65. package/dist/runners/connect.mjs +2 -2
  66. package/dist/runners/switchboard.d.mts +1 -1
  67. package/dist/runners/switchboard.mjs +3 -3
  68. package/dist/{sugar-checks-CTCsK5DJ.mjs → sugar-checks-CAtgUIem.mjs} +16 -15
  69. package/dist/sugar-checks-CAtgUIem.mjs.map +1 -0
  70. package/dist/{verify-NK6a_7j8.mjs → verify-DXrs0JUp.mjs} +5 -5
  71. package/dist/{verify-NK6a_7j8.mjs.map → verify-DXrs0JUp.mjs.map} +1 -1
  72. package/dist/{vetra-gateway-BxcduYAI.mjs → vetra-gateway-BHuz7pvS.mjs} +5 -5
  73. package/dist/{vetra-gateway-BxcduYAI.mjs.map → vetra-gateway-BHuz7pvS.mjs.map} +1 -1
  74. package/dist/vetra-gateway-ag33E_Ta.mjs +4 -0
  75. package/dist/{vetra-host-BrLdIMRP.mjs → vetra-host-CYdbd3J3.mjs} +28 -11
  76. package/dist/vetra-host-CYdbd3J3.mjs.map +1 -0
  77. package/dist/{vetra-launcher-Dokr1aDK.mjs → vetra-launcher-B5L3yXPo.mjs} +16 -13
  78. package/dist/vetra-launcher-B5L3yXPo.mjs.map +1 -0
  79. package/dist/vetra-launcher-BUO9e74r.mjs +4 -0
  80. package/dist/{vetra-instance-CPNIsaxh.mjs → vetra-runtime-Bk6CW-BE.mjs} +7 -25
  81. package/dist/vetra-runtime-Bk6CW-BE.mjs.map +1 -0
  82. package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs +131 -0
  83. package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs.map +1 -0
  84. package/package.json +15 -16
  85. package/dist/build-DblrRe4z.mjs +0 -4
  86. package/dist/compound-BWLJ0KBw-8hKyrfjG.mjs.map +0 -1
  87. package/dist/dist-BFMRL5C0.mjs.map +0 -1
  88. package/dist/generate-all-BLot_H9Z.mjs.map +0 -1
  89. package/dist/generate-app-hm6CJ_4O.mjs.map +0 -1
  90. package/dist/generate-document-model-BiD6ovXc.mjs.map +0 -1
  91. package/dist/generate-editor-DBj_Pxwa.mjs.map +0 -1
  92. package/dist/generate-processor-BVjOsfjJ.mjs.map +0 -1
  93. package/dist/generate-subgraph-DJZCr0Tk.mjs.map +0 -1
  94. package/dist/index-D3H9pQ8u.d.mts.map +0 -1
  95. package/dist/mcp-B3l1mtBq.mjs.map +0 -1
  96. package/dist/migrate-subgraphs-Hc5w9Mpk.mjs +0 -4
  97. package/dist/ph-cli-commands-CQXdWQ74.mjs.map +0 -1
  98. package/dist/ph-cli-commands-YE0ciOSX.mjs +0 -4
  99. package/dist/run-sugar-hGKprsKz.mjs.map +0 -1
  100. package/dist/sugar-checks-CTCsK5DJ.mjs.map +0 -1
  101. package/dist/vetra-gateway-Bpe50oGk.mjs +0 -4
  102. package/dist/vetra-host-BrLdIMRP.mjs.map +0 -1
  103. package/dist/vetra-instance-CPNIsaxh.mjs.map +0 -1
  104. package/dist/vetra-launcher-BtDWQBuh.mjs +0 -4
  105. package/dist/vetra-launcher-Dokr1aDK.mjs.map +0 -1
  106. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +0 -19
  107. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-sugar-hGKprsKz.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: no host is defined, so nothing is rewritten. */\n warning?: string;\n}\n\n/** A host every scaffold has. */\nexport type SugarHost = \"vetra\" | \"connect\" | \"switchboard\";\n\n/**\n * The commands that run a host every scaffold has, and the host: `ph dev`,\n * `ph connect` and `ph switchboard` are `ph run <host>` and have no code of\n * their own. `ph dev` runs hosts/vetra, the dev mode. They are rewritten\n * whatever the project holds, so a project without the host gets the error\n * of `ph run` (sugar-checks.ts says it first, as typed).\n */\nexport const HOST_COMMANDS: Readonly<Record<string, SugarHost>> = {\n dev: \"vetra\",\n connect: \"connect\",\n switchboard: \"switchboard\",\n};\n\n/** `ph connect <subcommand>` and the verb of the connect host it stands for. */\nexport const CONNECT_VERBS: Readonly<Record<string, string>> = {\n studio: \"dev\",\n build: \"build\",\n preview: \"serve\",\n};\n\nconst isHelp = (arg: string | undefined) => arg === \"--help\" || arg === \"-h\";\n\n/**\n * `ph connect [studio|build|preview]` → `ph run connect <dev|build|serve>`.\n * Without a subcommand it is `studio`, as it always was. `ph connect config`\n * and `ph connect --help` stay the `connect` command: a tool, not a host.\n * Any other word is a verb of the host (`ph connect serve`).\n */\nfunction connectSugar(args: string[]): string[] {\n const rest = args.slice(1);\n if (rest[0] === \"config\" || isHelp(rest[0])) return args;\n if (rest.length === 0 || rest[0].startsWith(\"-\")) {\n return [\"run\", \"connect\", CONNECT_VERBS.studio, ...rest];\n }\n if (Object.hasOwn(CONNECT_VERBS, rest[0])) {\n return [\"run\", \"connect\", CONNECT_VERBS[rest[0]], ...rest.slice(1)];\n }\n return [\"run\", ...args];\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 * Built-in commands win collisions by construction — the known-command check\n * runs first. {@link HOST_COMMANDS} are sugar in every project. `ph vetra` is\n * a command, the gateway to Vetra Studio (services/vetra-gateway.ts), and\n * never a host.\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 (first === \"connect\") {\n return { args: connectSugar(args) };\n }\n if (Object.hasOwn(HOST_COMMANDS, first)) {\n return { args: [\"run\", HOST_COMMANDS[first], ...args.slice(1)] };\n }\n if (knownCommands.has(first)) {\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. Run `ph migrate` to add the host files.\",\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":";;;;;;;;;;;AAkBA,MAAa,gBAAqD;CAChE,KAAK;CACL,SAAS;CACT,aAAa;AACf;;AAGA,MAAa,gBAAkD;CAC7D,QAAQ;CACR,OAAO;CACP,SAAS;AACX;AAEA,MAAM,UAAU,QAA4B,QAAQ,YAAY,QAAQ;;;;;;;AAQxE,SAAS,aAAa,MAA0B;CAC9C,MAAM,OAAO,KAAK,MAAM,CAAC;CACzB,IAAI,KAAK,OAAO,YAAY,OAAO,KAAK,EAAE,GAAG,OAAO;CACpD,IAAI,KAAK,WAAW,KAAK,KAAK,EAAE,CAAC,WAAW,GAAG,GAC7C,OAAO;EAAC;EAAO;EAAW,cAAc;EAAQ,GAAG;CAAI;CAEzD,IAAI,OAAO,OAAO,eAAe,KAAK,EAAE,GACtC,OAAO;EAAC;EAAO;EAAW,cAAc,KAAK;EAAK,GAAG,KAAK,MAAM,CAAC;CAAC;CAEpE,OAAO,CAAC,OAAO,GAAG,IAAI;AACxB;;;;;;;;;AAUA,SAAgB,cACd,MACA,eACA,aACgB;CAChB,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,GAChC,OAAO,EAAE,KAAK;CAEhB,IAAI,UAAU,WACZ,OAAO,EAAE,MAAM,aAAa,IAAI,EAAE;CAEpC,IAAI,OAAO,OAAO,eAAe,KAAK,GACpC,OAAO,EAAE,MAAM;EAAC;EAAO,cAAc;EAAQ,GAAG,KAAK,MAAM,CAAC;CAAC,EAAE;CAEjE,IAAI,cAAc,IAAI,KAAK,GACzB,OAAO,EAAE,KAAK;CAEhB,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":"9df81c49-05f9-595a-9ce7-5f3bd50815f0"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sugar-checks-CTCsK5DJ.mjs","sources":["../src/utils/sugar-checks.ts"],"sourcesContent":["import {\n loadHost,\n probeHostsFolder,\n withoutHostsMessage,\n type RunnerArgsSchema,\n} from \"@powerhousedao/host-core\";\nimport {\n DEPRECATIONS_REMOVED_IN,\n MIGRATION_GUIDE_URL,\n} from \"@powerhousedao/shared/clis/deprecations\";\nimport { CONNECT_VERBS, HOST_COMMANDS, type SugarHost } from \"./run-sugar.js\";\n\n/**\n * What `ph dev`, `ph connect` and `ph switchboard` are refused for, before\n * they become `ph run <host>` (run-sugar.ts): a project without the host\n * file, and the flags of the commands they once were that `ph run` has no\n * argument for. `ph run` is not checked here, nor is any other host name: a\n * runner refuses the arguments it does not know itself. Nor are the flags of\n * a host on a runner of its own: they are checked against the stock runners.\n */\n\n/** `ph switchboard` flags that are verbs of the host. */\nconst SWITCHBOARD_VERB_FLAGS: Readonly<Record<string, string>> = {\n \"--migrate\": \"migrate\",\n \"--migrate-status\": \"migrate-status\",\n \"--reset\": \"reset\",\n \"--dev\": \"dev\",\n};\n\n/** Read by the CLI itself, before any command. */\nconst CLI_FLAGS = new Set([\"--debug\"]);\n\n/** The runner argument schemas the flags are checked against. */\nexport interface SugarArgSchemas {\n switchboard: RunnerArgsSchema;\n connect: RunnerArgsSchema;\n}\n\ninterface SugarInvocation {\n /** As typed: `ph connect build`. */\n typed: string;\n /** The host it runs. */\n host: SugarHost;\n /** What it is sugar for: `ph run <host> [verb]`. */\n replacement: string;\n /** The flags passed, by name, without their values. */\n flags: string[];\n}\n\nfunction sugarInvocation(args: readonly string[]): SugarInvocation | undefined {\n const [command, ...rest] = args;\n if (command === undefined || !Object.hasOwn(HOST_COMMANDS, command)) {\n return undefined;\n }\n if (rest.some((arg) => arg === \"--help\" || arg === \"-h\")) return undefined;\n const flags = [\n ...new Set(\n rest\n .filter((arg) => arg.startsWith(\"-\") && arg !== \"--\")\n .map((arg) => arg.split(\"=\")[0]),\n ),\n ].filter((name) => !CLI_FLAGS.has(name));\n // A word right after the command is the subcommand or the verb.\n const word =\n rest.length > 0 && !rest[0].startsWith(\"-\") ? rest[0] : undefined;\n if (command === \"connect\") {\n // `ph connect config` reads and writes the config: a tool, not a host.\n if (word === \"config\") return undefined;\n const verb =\n word === undefined\n ? CONNECT_VERBS.studio\n : Object.hasOwn(CONNECT_VERBS, word)\n ? CONNECT_VERBS[word]\n : word;\n return {\n typed: word ? `ph connect ${word}` : \"ph connect\",\n host: \"connect\",\n replacement: `ph run connect ${verb}`,\n flags,\n };\n }\n // `ph dev` runs hosts/vetra.\n const host = HOST_COMMANDS[command];\n return {\n typed: word ? `ph ${command} ${word}` : `ph ${command}`,\n host,\n replacement: word ? `ph run ${host} ${word}` : `ph run ${host}`,\n flags,\n };\n}\n\n/**\n * `ph reactor` was an alias of `ph switchboard`. It is gone, unless the\n * project names a host of its own that.\n */\nfunction removedAliasError(\n args: readonly string[],\n projectRoot: string,\n): string | undefined {\n if (args[0] !== \"reactor\") return undefined;\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(\"reactor\")) {\n return undefined;\n }\n return (\n `\\`ph reactor\\` was removed in ${DEPRECATIONS_REMOVED_IN}. ` +\n \"Use `ph switchboard` or `ph run switchboard` instead.\"\n );\n}\n\n/**\n * Why the command cannot run in this project: it has no hosts (the wording\n * of `ph run`, naming `ph migrate`), or it has hosts and not this one.\n * Undefined for anything else, for help, and for a project with the host.\n */\nexport function withoutHostError(\n args: readonly string[],\n projectRoot: string,\n): string | undefined {\n const invocation = sugarInvocation(args);\n if (!invocation) return undefined;\n const { typed, host } = invocation;\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind !== \"present\") {\n return withoutHostsMessage(probe, `\\`${typed}\\``);\n }\n if (probe.hosts.includes(host)) return undefined;\n // `ph migrate` adds the hosts to a project that has none, and only then.\n return (\n `This project has no hosts/${host}/host.js, so \\`${typed}\\` cannot run. ` +\n `\\`ph migrate\\` adds the host files to a project without hosts only: add hosts/${host}/host.js to this one. ` +\n `See ${MIGRATION_GUIDE_URL}`\n );\n}\n\n/**\n * The flags `ph run <host>` has no argument for, as one error. A flag the\n * runner takes passes, under its member name for `ph dev`\n * (`--switchboard-port`); a flag the runner retired passes too, and the\n * runner says so. Undefined when every flag passes.\n */\nexport function removedFlagsError(\n args: readonly string[],\n schemas: SugarArgSchemas,\n): string | undefined {\n const invocation = sugarInvocation(args);\n if (!invocation) return undefined;\n const { typed, host, replacement } = invocation;\n // A compound hands each member its arguments; a member option goes by its\n // member name there (`--switchboard-port`), never by its plain one.\n const members =\n host === \"vetra\" ? [schemas.switchboard, schemas.connect] : [schemas[host]];\n const scoped = new Set(\n members.flatMap((schema) => Object.values(schema.memberOptions ?? {})),\n );\n const accepts = (name: string): boolean =>\n host === \"vetra\"\n ? // `ph run vetra` takes --restart itself (vetra-host.ts).\n name === \"--restart\" ||\n members.some(\n (schema) =>\n schema.memberOptions?.[name] !== undefined ||\n (!scoped.has(name) &&\n [...schema.options, ...schema.flags].includes(name)),\n )\n : [...members[0].options, ...members[0].flags].includes(name);\n const errors: string[] = [];\n const unsupported: string[] = [];\n for (const name of invocation.flags) {\n const verb =\n host === \"switchboard\" ? SWITCHBOARD_VERB_FLAGS[name] : undefined;\n const retired = members.some(\n (schema) => schema.retired?.[name] !== undefined,\n );\n if (verb !== undefined) {\n errors.push(\n `\\`${typed} ${name}\\` was removed in ${DEPRECATIONS_REMOVED_IN}. Use \\`ph run switchboard ${verb}\\` instead.`,\n );\n } else if (accepts(name) || retired) {\n continue;\n } else {\n unsupported.push(name);\n }\n }\n if (unsupported.length > 0) {\n const one = unsupported.length === 1;\n const subject = one\n ? `\\`${typed} ${unsupported[0]}\\` was removed in ${DEPRECATIONS_REMOVED_IN}: \\`${replacement}\\` has no such argument.`\n : `The \\`${typed}\\` flags ${unsupported.join(\", \")} were removed in ${DEPRECATIONS_REMOVED_IN}: \\`${replacement}\\` has no such arguments.`;\n errors.push(\n `${subject} Set what ${one ? \"it configures\" : \"they configure\"} in the host files under hosts/ instead. ` +\n `See ${MIGRATION_GUIDE_URL}`,\n );\n }\n return errors.length > 0 ? errors.join(\"\\n\") : undefined;\n}\n\n/** The runners the scaffold's hosts name, whose schemas the flags are\n * checked against. ph-cli's are the ph-run ones, re-exported. */\nconst STOCK_RUNNERS: Readonly<Record<string, readonly string[]>> = {\n connect: [\n \"@powerhousedao/ph-cli/runners/connect\",\n \"@powerhousedao/ph-run/runners/connect\",\n ],\n switchboard: [\n \"@powerhousedao/ph-cli/runners/switchboard\",\n \"@powerhousedao/ph-run/runners/switchboard\",\n ],\n};\nconst COMPOUND_RUNNER = \"@powerhousedao/host-core/runners/compound\";\n\nasync function runnerModuleOf(\n projectRoot: string,\n host: string,\n): Promise<{ module: string; children?: unknown } | undefined> {\n try {\n const { host: definition } = await loadHost(projectRoot, host);\n return {\n module: definition.runner.module,\n children: (definition as { children?: unknown }).children,\n };\n } catch {\n // `ph run` loads it next and says what is wrong with it.\n return undefined;\n }\n}\n\n/**\n * Whether the host runs the stock runner of its command: the connect or\n * switchboard runner, or for `ph dev` the compound over members that are\n * the project's connect and switchboard hosts, each on its stock runner.\n * Anything else has arguments of its own, which its runner checks.\n */\nexport async function runsStockRunner(\n projectRoot: string,\n host: SugarHost,\n): Promise<boolean> {\n const loaded = await runnerModuleOf(projectRoot, host);\n if (!loaded) return false;\n if (host !== \"vetra\") return STOCK_RUNNERS[host].includes(loaded.module);\n if (loaded.module !== COMPOUND_RUNNER) return false;\n const children = loaded.children;\n if (typeof children !== \"object\" || children === null) return false;\n const members = new Set<string>();\n for (const child of Object.values(children as Record<string, unknown>)) {\n const { host: member, runner } = (child ?? {}) as {\n host?: unknown;\n runner?: { module?: unknown };\n };\n if (typeof member !== \"string\" || !Object.hasOwn(STOCK_RUNNERS, member)) {\n return false;\n }\n // A member that names a runner module is not on its sibling's.\n if (runner?.module !== undefined) return false;\n members.add(member);\n }\n for (const member of members) {\n const sibling = await runnerModuleOf(projectRoot, member);\n if (!sibling || !STOCK_RUNNERS[member].includes(sibling.module)) {\n return false;\n }\n }\n return true;\n}\n\nasync function loadArgSchemas(): Promise<SugarArgSchemas | undefined> {\n try {\n const [switchboard, connect] = await Promise.all([\n import(\"@powerhousedao/ph-run/runners/switchboard\"),\n import(\"@powerhousedao/ph-run/runners/connect\"),\n ]);\n return {\n switchboard: switchboard.argsSchema,\n connect: connect.argsSchema,\n };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Run by the CLI on the command line as typed, before the host sugar: the\n * error the invocation ends with, if any. `args` is untouched either way.\n */\nexport async function sugarError(\n args: readonly string[],\n projectRoot: string,\n): Promise<string | undefined> {\n const removed = removedAliasError(args, projectRoot);\n if (removed !== undefined) return removed;\n const withoutHost = withoutHostError(args, projectRoot);\n if (withoutHost !== undefined) return withoutHost;\n const invocation = sugarInvocation(args);\n if (!invocation || invocation.flags.length === 0) return undefined;\n // A runner of the project's own takes the arguments it declares.\n if (!(await runsStockRunner(projectRoot, invocation.host))) return undefined;\n // Without the schemas the runner still refuses what it does not accept.\n const schemas = await loadArgSchemas();\n return schemas ? removedFlagsError(args, schemas) : undefined;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAM,yBAA2D;CAC/D,aAAa;CACb,oBAAoB;CACpB,WAAW;CACX,SAAS;AACX;;AAGA,MAAM,4BAAY,IAAI,IAAI,CAAC,SAAS,CAAC;AAmBrC,SAAS,gBAAgB,MAAsD;CAC7E,MAAM,CAAC,SAAS,GAAG,QAAQ;CAC3B,IAAI,YAAY,KAAA,KAAa,CAAC,OAAO,OAAO,eAAe,OAAO,GAChE;CAEF,IAAI,KAAK,MAAM,QAAQ,QAAQ,YAAY,QAAQ,IAAI,GAAG,OAAO,KAAA;CACjE,MAAM,QAAQ,CACZ,GAAG,IAAI,IACL,KACG,QAAQ,QAAQ,IAAI,WAAW,GAAG,KAAK,QAAQ,IAAI,CAAC,CACpD,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CACnC,CACF,CAAC,CAAC,QAAQ,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC;CAEvC,MAAM,OACJ,KAAK,SAAS,KAAK,CAAC,KAAK,EAAE,CAAC,WAAW,GAAG,IAAI,KAAK,KAAK,KAAA;CAC1D,IAAI,YAAY,WAAW;EAEzB,IAAI,SAAS,UAAU,OAAO,KAAA;EAC9B,MAAM,OACJ,SAAS,KAAA,IACL,cAAc,SACd,OAAO,OAAO,eAAe,IAAI,IAC/B,cAAc,QACd;EACR,OAAO;GACL,OAAO,OAAO,cAAc,SAAS;GACrC,MAAM;GACN,aAAa,kBAAkB;GAC/B;EACF;CACF;CAEA,MAAM,OAAO,cAAc;CAC3B,OAAO;EACL,OAAO,OAAO,MAAM,QAAQ,GAAG,SAAS,MAAM;EAC9C;EACA,aAAa,OAAO,UAAU,KAAK,GAAG,SAAS,UAAU;EACzD;CACF;AACF;;;;;AAMA,SAAS,kBACP,MACA,aACoB;CACpB,IAAI,KA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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]="f913a474-09a0-5aab-b591-da9ce2601fed")}catch(e){}}();
4
- //# debugId=f913a474-09a0-5aab-b591-da9ce2601fed
@@ -1 +0,0 @@
1
- {"version":3,"file":"vetra-host-BrLdIMRP.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 makes the stack the project's Vetra is done here around\n * startRun: 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`. `--restart` is its own\n * argument, not a runner's: it stops the recorded Vetra first.\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 restart = args.argv?.includes(RESTART_FLAG) ?? false;\n if (restart) {\n const { stopVetra } = await import(\"../../utils/vetra-launcher.js\");\n await stopVetra({\n projectDir,\n projectName,\n onProgress: (message) => console.log(message),\n });\n }\n const refusal = await vetraRuntimeRefusal(projectDir, projectName);\n if (refusal) throw new Error(refusal);\n\n const result = await startRun(\n restart\n ? { ...args, argv: args.argv?.filter((arg) => arg !== RESTART_FLAG) }\n : args,\n );\n publishVetraRuntime(projectDir, projectName, result);\n return result;\n}\n\n/** `ph run vetra --restart`, which `ph dev --restart` is sugar for. */\nconst RESTART_FLAG = \"--restart\";\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":";;;;;;;;;;;;;;;;;;;AA4BA,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,KAAK,MAAM,SAAS,YAAY,KAAK;CACrD,IAAI,SAAS;EACX,MAAM,EAAE,cAAc,MAAM,OAAO;EACnC,MAAM,UAAU;GACd;GACA;GACA,aAAa,YAAY,QAAQ,IAAI,OAAO;EAC9C,CAAC;CACH;CACA,MAAM,UAAU,MAAM,oBAAoB,YAAY,WAAW;CACjE,IAAI,SAAS,MAAM,IAAI,MAAM,OAAO;CAEpC,MAAM,SAAS,MAAM,SACnB,UACI;EAAE,GAAG;EAAM,MAAM,KAAK,MAAM,QAAQ,QAAQ,QAAQ,YAAY;CAAE,IAClE,IACN;CACA,oBAAoB,YAAY,aAAa,MAAM;CACnD,OAAO;AACT;;AAGA,MAAM,eAAe;AAErB,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":"9b004534-e9d0-589a-8a74-a3c6fcc69596"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vetra-instance-CPNIsaxh.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 dev` 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 { probeVetraRuntime } from \"./vetra-runtime.js\";\n\n/**\n * One Vetra per project. `ph run vetra` records its stack in\n * `.ph/run/vetra.json` and, once ready, in `.ph/vetra-runtime.json`, which is\n * what a start asks here: whether a Vetra already holds the project.\n */\n\n/** The host folder `ph dev` runs, and the name its host file carries. */\nexport const VETRA_HOST = \"vetra\";\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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,CAAC,KAAK,QAAQ,WAAW,cAAc,UAAU,GAAG;EAC7D,IAAI,OAAO,QAAQ,QAAQ;EAC3B,OAAO,MAAM;EACb,GAAG,cACD,KAAK,KAAK,YAAY,GAAG,GACzB,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,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;;;;;;;;;ACnOA,MAAa,aAAa;;AAG1B,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":"ca914e2a-3bcb-5ccb-b73b-6d381ea2e1e8"}
@@ -1,4 +0,0 @@
1
- import { o as stopVetra } from "./vetra-launcher-Dokr1aDK.mjs";
2
- export { stopVetra };
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]="2131716e-47fc-5dc3-a00b-0ec15d9d82ee")}catch(e){}}();
4
- //# debugId=2131716e-47fc-5dc3-a00b-0ec15d9d82ee
@@ -1 +0,0 @@
1
- {"version":3,"file":"vetra-launcher-Dokr1aDK.mjs","sources":["../src/utils/vetra-launcher.ts"],"sourcesContent":["import { 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 run 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/**\n * What starts a project's Vetra: `ph run vetra --strictPort`, run by the\n * ph-cli executing this code. The host's own defaultVerb picks the verb. In\n * a project without the host it fails, and its output says why.\n */\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\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 run 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 run ${VETRA_HOST}`}\\` ${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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;CACvE,IAAI,SAAS,aAAa,sBAAsB,QAAQ,IAAI,GAAG;CAC/D,OAAO,YAAY,OAAO;AAC5B","debug_id":"e35415c1-3b9c-52c8-b997-4219f0c52968"}
@@ -1,19 +0,0 @@
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]="8f90996d-2865-5564-b0aa-35c99867095d")}catch(e){}}();
3
- import { lintSubgraphTypes } from "@powerhousedao/vetra/codegen";
4
- //#region src/utils/warn-subgraph-type-conflicts.ts
5
- async function warnSubgraphTypeConflicts(projectDir) {
6
- let warnings;
7
- try {
8
- warnings = await lintSubgraphTypes(projectDir);
9
- } catch (error) {
10
- console.warn("⚠ Failed to check subgraph type names:", error);
11
- return;
12
- }
13
- for (const warning of warnings) console.warn(`⚠ ${warning}`);
14
- }
15
- //#endregion
16
- export { warnSubgraphTypeConflicts as t };
17
-
18
- //# sourceMappingURL=warn-subgraph-type-conflicts-BOHBmThq.mjs.map
19
- //# debugId=8f90996d-2865-5564-b0aa-35c99867095d
@@ -1 +0,0 @@
1
- {"version":3,"file":"warn-subgraph-type-conflicts-BOHBmThq.mjs","sources":["../src/utils/warn-subgraph-type-conflicts.ts"],"sourcesContent":["import { lintSubgraphTypes } from \"@powerhousedao/vetra/codegen\";\n\nexport async function warnSubgraphTypeConflicts(\n projectDir: string,\n): Promise<void> {\n let warnings: string[];\n try {\n warnings = await lintSubgraphTypes(projectDir);\n } catch (error) {\n console.warn(\"⚠ Failed to check subgraph type names:\", error);\n return;\n }\n for (const warning of warnings) console.warn(`⚠ ${warning}`);\n}\n"],"names":[],"mappings":";;;;AAEA,eAAsB,0BACpB,YACe;CACf,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,kBAAkB,UAAU;CAC/C,SAAS,OAAO;EACd,QAAQ,KAAK,0CAA0C,KAAK;EAC5D;CACF;CACA,KAAK,MAAM,WAAW,UAAU,QAAQ,KAAK,KAAK,SAAS;AAC7D","debug_id":"8f90996d-2865-5564-b0aa-35c99867095d"}