@powerhousedao/ph-cli 6.4.0-next.2 → 6.4.0-next.5

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 (146) hide show
  1. package/README.md +6 -5
  2. package/dist/auth-5bqHASGL.mjs +4 -0
  3. package/dist/auth-DYknkWfW.mjs +23 -0
  4. package/dist/auth-DYknkWfW.mjs.map +1 -0
  5. package/dist/{build-C7RBpPwa.mjs → build-CBKlv5E3.mjs} +6 -6
  6. package/dist/{build-C7RBpPwa.mjs.map → build-CBKlv5E3.mjs.map} +1 -1
  7. package/dist/build-Dr1lnv4h.mjs +4 -0
  8. package/dist/{check-1Hfe0lVO.mjs → check-CW81vbe9.mjs} +4 -4
  9. package/dist/{check-1Hfe0lVO.mjs.map → check-CW81vbe9.mjs.map} +1 -1
  10. package/dist/{check-MBdw9Lbm.mjs → check-Cx_AeBQe.mjs} +7 -7
  11. package/dist/check-Cx_AeBQe.mjs.map +1 -0
  12. package/dist/{check-ClxYRer4.mjs → check-DhFd9tO8.mjs} +3 -3
  13. package/dist/{cli-connect-override-DsuuectH.mjs → cli-connect-override-DKxY3lCi.mjs} +4 -4
  14. package/dist/{cli-connect-override-DsuuectH.mjs.map → cli-connect-override-DKxY3lCi.mjs.map} +1 -1
  15. package/dist/cli.mjs +9 -8
  16. package/dist/cli.mjs.map +1 -1
  17. package/dist/{compound-Q9sZSEZF-zZWzQ7VC.mjs → compound-g6x_KkWp-Bs7olmlI.mjs} +464 -360
  18. package/dist/compound-g6x_KkWp-Bs7olmlI.mjs.map +1 -0
  19. package/dist/{connect-build-DAnGPSF5.mjs → connect-build-DpGUrtct.mjs} +5 -5
  20. package/dist/{connect-build-DAnGPSF5.mjs.map → connect-build-DpGUrtct.mjs.map} +1 -1
  21. package/dist/{connect-config-C0QZ7zTf.mjs → connect-config-BpzwJln3.mjs} +4 -4
  22. package/dist/{connect-config-C0QZ7zTf.mjs.map → connect-config-BpzwJln3.mjs.map} +1 -1
  23. package/dist/{connect-preview-BvxXGo_W.mjs → connect-preview-B_E4SIV6.mjs} +21 -4
  24. package/dist/connect-preview-B_E4SIV6.mjs.map +1 -0
  25. package/dist/connect-studio-BPZOcwUM.mjs +214 -0
  26. package/dist/connect-studio-BPZOcwUM.mjs.map +1 -0
  27. package/dist/credentials-CmtYywgk.mjs +132 -0
  28. package/dist/credentials-CmtYywgk.mjs.map +1 -0
  29. package/dist/definitions-worker.mjs +4 -4
  30. package/dist/definitions-worker.mjs.map +1 -1
  31. package/dist/dev-host-CM-Jg2kY.mjs +19 -0
  32. package/dist/dev-host-CM-Jg2kY.mjs.map +1 -0
  33. package/dist/{dist-CRR5Anp2.mjs → dist-DPj_FB8H.mjs} +5 -5
  34. package/dist/dist-DPj_FB8H.mjs.map +1 -0
  35. package/dist/{explain-BfOC7Ngv.mjs → explain-DQ5ymlco.mjs} +5 -5
  36. package/dist/{explain-BfOC7Ngv.mjs.map → explain-DQ5ymlco.mjs.map} +1 -1
  37. package/dist/{export-CdTqYviH.mjs → export-CzeF8pob.mjs} +4 -4
  38. package/dist/{export-CdTqYviH.mjs.map → export-CzeF8pob.mjs.map} +1 -1
  39. package/dist/{generate-all-HujZHqCG.mjs → generate-all-B9MwWXlq.mjs} +6 -21
  40. package/dist/generate-all-B9MwWXlq.mjs.map +1 -0
  41. package/dist/{generate-app-hm6CJ_4O.mjs → generate-app-C7n0j8Ak.mjs} +5 -18
  42. package/dist/generate-app-C7n0j8Ak.mjs.map +1 -0
  43. package/dist/{generate-document-model-BiD6ovXc.mjs → generate-document-model-D3LKY1D7.mjs} +11 -35
  44. package/dist/generate-document-model-D3LKY1D7.mjs.map +1 -0
  45. package/dist/{generate-editor-DBj_Pxwa.mjs → generate-editor-DKuRUeIt.mjs} +5 -18
  46. package/dist/generate-editor-DKuRUeIt.mjs.map +1 -0
  47. package/dist/{generate-processor-BVjOsfjJ.mjs → generate-processor-CwJvJDpd.mjs} +5 -18
  48. package/dist/generate-processor-CwJvJDpd.mjs.map +1 -0
  49. package/dist/{generate-subgraph-DJZCr0Tk.mjs → generate-subgraph-Q1VLh3SC.mjs} +13 -39
  50. package/dist/generate-subgraph-Q1VLh3SC.mjs.map +1 -0
  51. package/dist/{get-version-DAYhm6MX.mjs → get-version-CTP__ORu.mjs} +4 -4
  52. package/dist/{get-version-DAYhm6MX.mjs.map → get-version-CTP__ORu.mjs.map} +1 -1
  53. package/dist/identity-DXZFeQfC.mjs +137 -0
  54. package/dist/identity-DXZFeQfC.mjs.map +1 -0
  55. package/dist/{index-Bs1PfL3W.d.mts → index-aosqo7aM.d.mts} +5 -4
  56. package/dist/index-aosqo7aM.d.mts.map +1 -0
  57. package/dist/{inspect-CulIpVsF.mjs → inspect-BgKI8Fhd.mjs} +6 -6
  58. package/dist/{inspect-CulIpVsF.mjs.map → inspect-BgKI8Fhd.mjs.map} +1 -1
  59. package/dist/{keyframes-bFo9iDhT.mjs → keyframes-BkeORfEu.mjs} +4 -4
  60. package/dist/{keyframes-bFo9iDhT.mjs.map → keyframes-BkeORfEu.mjs.map} +1 -1
  61. package/dist/{mcp-rtMGg307.mjs → mcp-gcG7SW9L.mjs} +152 -10
  62. package/dist/mcp-gcG7SW9L.mjs.map +1 -0
  63. package/dist/{migrate-CWCJP19Q.mjs → migrate-BaWZhorc.mjs} +4 -4
  64. package/dist/{migrate-CWCJP19Q.mjs.map → migrate-BaWZhorc.mjs.map} +1 -1
  65. package/dist/{migrate-document-models-DTxM7D7p.mjs → migrate-document-models-DYmkJzq3.mjs} +5 -6
  66. package/dist/migrate-document-models-DYmkJzq3.mjs.map +1 -0
  67. package/dist/{migrate-subgraphs-_yRnF7xt.mjs → migrate-subgraphs-BUgTeHcm.mjs} +6 -7
  68. package/dist/migrate-subgraphs-BUgTeHcm.mjs.map +1 -0
  69. package/dist/migrate-subgraphs-ChhXynqd.mjs +4 -0
  70. package/dist/{ph-cli-commands-FLZClR4x.mjs → ph-cli-commands-B5VkGW99.mjs} +179 -190
  71. package/dist/ph-cli-commands-B5VkGW99.mjs.map +1 -0
  72. package/dist/ph-cli-commands-CGXSo1wx.mjs +4 -0
  73. package/dist/{registry-auth-Bm5AR-fB.mjs → registry-auth-C8D5cno2.mjs} +4 -4
  74. package/dist/{registry-auth-Bm5AR-fB.mjs.map → registry-auth-C8D5cno2.mjs.map} +1 -1
  75. package/dist/render-BQE20Cnd.mjs +4 -0
  76. package/dist/{render-SVfj3m8A.mjs → render-CQdi685k.mjs} +6 -6
  77. package/dist/render-CQdi685k.mjs.map +1 -0
  78. package/dist/{run-LRGy7zGo.mjs → run-C6Vha5VN.mjs} +3 -3
  79. package/dist/{run--de_-WAz.mjs → run-sVzTTEUx.mjs} +5 -36
  80. package/dist/run-sVzTTEUx.mjs.map +1 -0
  81. package/dist/{run-sugar-DUiDFl_T.mjs → run-sugar-BuxOaRzE.mjs} +16 -8
  82. package/dist/run-sugar-BuxOaRzE.mjs.map +1 -0
  83. package/dist/{run-sugar-YDxw0iV9.mjs → run-sugar-Dz-rpeMO.mjs} +3 -3
  84. package/dist/runners/connect.d.mts +20 -3
  85. package/dist/runners/connect.d.mts.map +1 -1
  86. package/dist/runners/connect.mjs +37 -15
  87. package/dist/runners/connect.mjs.map +1 -1
  88. package/dist/runners/switchboard.d.mts +1 -1
  89. package/dist/runners/switchboard.mjs +3 -3
  90. package/dist/scripts/generate-commands-docs.ts +12 -0
  91. package/dist/{subgraphs-7OYWwP-C.mjs → subgraphs-Bm9NHTCn.mjs} +5 -38
  92. package/dist/subgraphs-Bm9NHTCn.mjs.map +1 -0
  93. package/dist/{sugar-checks-BFu3sfFJ.mjs → sugar-checks-DL-J3l2y.mjs} +16 -15
  94. package/dist/sugar-checks-DL-J3l2y.mjs.map +1 -0
  95. package/dist/{verify-Dkb6K1fc.mjs → verify-BLn76w09.mjs} +4 -4
  96. package/dist/{verify-Dkb6K1fc.mjs.map → verify-BLn76w09.mjs.map} +1 -1
  97. package/dist/{vetra-gateway-BMzq0mqX.mjs → vetra-gateway-D30pZgha.mjs} +5 -5
  98. package/dist/{vetra-gateway-BMzq0mqX.mjs.map → vetra-gateway-D30pZgha.mjs.map} +1 -1
  99. package/dist/vetra-gateway-DE5Hc0Fp.mjs +4 -0
  100. package/dist/vetra-host-0rSW35_r.mjs +230 -0
  101. package/dist/vetra-host-0rSW35_r.mjs.map +1 -0
  102. package/dist/{vetra-launcher-Dq0tWyNW.mjs → vetra-launcher-6NKfi6Au.mjs} +56 -13
  103. package/dist/vetra-launcher-6NKfi6Au.mjs.map +1 -0
  104. package/dist/vetra-launcher-XMk_Hv0c.mjs +4 -0
  105. package/dist/{vetra-instance-CLUzbtbh.mjs → vetra-runtime-Bk6CW-BE.mjs} +6 -24
  106. package/dist/vetra-runtime-Bk6CW-BE.mjs.map +1 -0
  107. package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs +131 -0
  108. package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs.map +1 -0
  109. package/package.json +17 -16
  110. package/dist/auth-BFUq7CvE.mjs +0 -18
  111. package/dist/auth-BFUq7CvE.mjs.map +0 -1
  112. package/dist/auth-CNhbN5UM.mjs +0 -4
  113. package/dist/build-BUpe1j4m.mjs +0 -4
  114. package/dist/check-MBdw9Lbm.mjs.map +0 -1
  115. package/dist/compound-Q9sZSEZF-zZWzQ7VC.mjs.map +0 -1
  116. package/dist/connect-preview-BvxXGo_W.mjs.map +0 -1
  117. package/dist/connect-studio-BUth3UYP.mjs +0 -106
  118. package/dist/connect-studio-BUth3UYP.mjs.map +0 -1
  119. package/dist/dist-CRR5Anp2.mjs.map +0 -1
  120. package/dist/generate-all-HujZHqCG.mjs.map +0 -1
  121. package/dist/generate-app-hm6CJ_4O.mjs.map +0 -1
  122. package/dist/generate-document-model-BiD6ovXc.mjs.map +0 -1
  123. package/dist/generate-editor-DBj_Pxwa.mjs.map +0 -1
  124. package/dist/generate-processor-BVjOsfjJ.mjs.map +0 -1
  125. package/dist/generate-subgraph-DJZCr0Tk.mjs.map +0 -1
  126. package/dist/index-Bs1PfL3W.d.mts.map +0 -1
  127. package/dist/mcp-rtMGg307.mjs.map +0 -1
  128. package/dist/migrate-document-models-DTxM7D7p.mjs.map +0 -1
  129. package/dist/migrate-subgraphs-DcJjLMFd.mjs +0 -4
  130. package/dist/migrate-subgraphs-_yRnF7xt.mjs.map +0 -1
  131. package/dist/ph-cli-commands-CRwA1aVX.mjs +0 -4
  132. package/dist/ph-cli-commands-FLZClR4x.mjs.map +0 -1
  133. package/dist/render-3M3DwFzO.mjs +0 -4
  134. package/dist/render-SVfj3m8A.mjs.map +0 -1
  135. package/dist/run--de_-WAz.mjs.map +0 -1
  136. package/dist/run-sugar-DUiDFl_T.mjs.map +0 -1
  137. package/dist/subgraphs-7OYWwP-C.mjs.map +0 -1
  138. package/dist/sugar-checks-BFu3sfFJ.mjs.map +0 -1
  139. package/dist/vetra-gateway-BP6Catg4.mjs +0 -4
  140. package/dist/vetra-host-C37IGwBM.mjs +0 -94
  141. package/dist/vetra-host-C37IGwBM.mjs.map +0 -1
  142. package/dist/vetra-instance-CLUzbtbh.mjs.map +0 -1
  143. package/dist/vetra-launcher-CJ01qmS1.mjs +0 -4
  144. package/dist/vetra-launcher-Dq0tWyNW.mjs.map +0 -1
  145. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +0 -19
  146. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +0 -1
@@ -1,94 +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]="cdc8cf4a-abf8-5310-9051-2002b9e69965")}catch(e){}}();
3
- import { _ as unknown, d as object, r as array } from "./schemas-DzgKfQIx.mjs";
4
- import { J as readProjectName, a as STORE_VERBS, r as ONE_SHOT_VERBS } from "./compound-Q9sZSEZF-zZWzQ7VC.mjs";
5
- import { c as vetraRuntimeRecord, l as writeVetraRuntime, n as vetraRuntimeRefusal, r as clearVetraRuntime, s as syncMcpPortNotices } from "./vetra-instance-CLUzbtbh.mjs";
6
- import { yellow } from "colorette";
7
- import { outputsSchema } from "@powerhousedao/ph-run/runners/connect";
8
- import { outputsSchema as outputsSchema$1 } from "@powerhousedao/ph-run/runners/switchboard";
9
- import { startRun } from "@powerhousedao/ph-run/start-run";
10
- //#region src/services/run/vetra-host.ts
11
- /**
12
- * `ph run vetra`: the vetra host is the generic compound runner over a
13
- * switchboard and a connect member, so nothing below `ph run` knows it is
14
- * Vetra. What makes the stack the project's Vetra is done here around
15
- * startRun: refuse while another Vetra holds
16
- * the project, publish `.ph/vetra-runtime.json` once the stack is ready,
17
- * clear it on exit, and correct a drifted `.mcp.json`. `--restart` is its own
18
- * argument, not a runner's: it stops the recorded Vetra first.
19
- */
20
- async function runVetraHost(args) {
21
- const verb = args.verb ?? "run";
22
- if (ONE_SHOT_VERBS.has(verb) || STORE_VERBS.has(verb)) return startRun(args);
23
- const projectDir = args.projectRoot ?? process.cwd();
24
- const projectName = readProjectName(projectDir);
25
- const restart = args.argv?.includes(RESTART_FLAG) ?? false;
26
- if (restart) {
27
- const { stopVetra } = await import("./vetra-launcher-CJ01qmS1.mjs");
28
- await stopVetra({
29
- projectDir,
30
- projectName,
31
- onProgress: (message) => console.log(message)
32
- });
33
- }
34
- const refusal = await vetraRuntimeRefusal(projectDir, projectName);
35
- if (refusal) throw new Error(refusal);
36
- const result = await startRun(restart ? {
37
- ...args,
38
- argv: args.argv?.filter((arg) => arg !== RESTART_FLAG)
39
- } : args);
40
- publishVetraRuntime(projectDir, projectName, result);
41
- return result;
42
- }
43
- /** `ph run vetra --restart`, which `ph dev --restart` is sugar for. */
44
- const RESTART_FLAG = "--restart";
45
- const startedSchema = object({ started: array(object({ outputs: unknown() })) });
46
- const portOf = (url) => Number(new URL(url).port);
47
- function firstMatch(schema, candidates) {
48
- for (const candidate of candidates) {
49
- const match = schema.safeParse(candidate);
50
- if (match.success) return match.data;
51
- }
52
- }
53
- /**
54
- * The record of a ready compound: its members are told apart by the outputs
55
- * their runners publish, since a host file is free to name them.
56
- */
57
- function vetraRecordOfRun(projectName, result) {
58
- const parsed = startedSchema.safeParse(result);
59
- const outputs = parsed.success ? parsed.data.started.map((member) => member.outputs) : [];
60
- const switchboard = firstMatch(outputsSchema$1, outputs);
61
- if (!switchboard) return void 0;
62
- const connect = firstMatch(outputsSchema, outputs);
63
- return vetraRuntimeRecord({
64
- projectName,
65
- switchboardPort: portOf(switchboard.origin),
66
- connectPort: connect ? portOf(connect.origin) : 0,
67
- switchboardUrl: switchboard.endpoints.graphql,
68
- mcpUrl: switchboard.endpoints.mcp,
69
- connectUrl: connect?.endpoints.connect
70
- });
71
- }
72
- /**
73
- * Publishes the record of the stack startRun returned and syncs the MCP
74
- * configs to its port. Returns what clears the record again; it also runs on
75
- * exit. No SIGINT/SIGTERM handler: the compound owns the exit, and its
76
- * process.exit reaches the exit event.
77
- */
78
- function publishVetraRuntime(projectDir, projectName, result) {
79
- const record = vetraRecordOfRun(projectName, result);
80
- if (!record) {
81
- console.warn(yellow("No switchboard member is running, so .ph/vetra-runtime.json is not written and `ph mcp` will not find this stack."));
82
- return () => {};
83
- }
84
- writeVetraRuntime(projectDir, record);
85
- const release = () => clearVetraRuntime(projectDir, process.pid);
86
- process.on("exit", release);
87
- for (const notice of syncMcpPortNotices(projectDir, record.switchboardPort)) console.log(yellow(notice));
88
- return release;
89
- }
90
- //#endregion
91
- export { runVetraHost };
92
-
93
- //# sourceMappingURL=vetra-host-C37IGwBM.mjs.map
94
- //# debugId=cdc8cf4a-abf8-5310-9051-2002b9e69965
@@ -1 +0,0 @@
1
- {"version":3,"file":"vetra-host-C37IGwBM.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,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O;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":"cdc8cf4a-abf8-5310-9051-2002b9e69965"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vetra-instance-CLUzbtbh.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,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,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AE,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":"aadcb52a-ac65-580b-ab60-f5a4cb86ecf0"}
@@ -1,4 +0,0 @@
1
- import { o as stopVetra } from "./vetra-launcher-Dq0tWyNW.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]="8ea1e07b-cac2-51da-ac9b-e98678c19a89")}catch(e){}}();
4
- //# debugId=8ea1e07b-cac2-51da-ac9b-e98678c19a89
@@ -1 +0,0 @@
1
- {"version":3,"file":"vetra-launcher-Dq0tWyNW.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 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,gBAAgB,eACpB,KAAK,SAAS,YAAY,aAAa,UAAU,CAAC,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;;;;;;A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I,MAAM,WAAW,UAAU,MAAM,WAAW,YAAY,OAAO,KAAA;CACnE,MAAM,EAAE,WAAW;CACnB,MAAM,UAAU,SAAyB;EACvC,IAAI;GACF,QAAQ,KAAK,OAAO,KAAK,IAAI;EAC/B,QAAQ,CAER;CACF;CACA,QAAQ,aAAa,uBAAuB,OAAO,IAAI,KAAK;CAG5D,IAAI,CAAE,MAAM,YAAY,OAAO,GAAG,GAAI,OAAO,SAAS;CACtD,IAAI,CAAE,MAAM,YAAY,QAAQ,KAAK,IAAI,IAAI,SAAS,GAAI;EACxD,OAAO,SAAS;EAChB,IAAI,CAAE,MAAM,YAAY,QAAQ,KAAK,IAAI,IAAI,SAAS,GACpD,MAAM,IAAI,gBACR,cAAc,OAAO,IAAI,wBAAwB,KAAK,MAAO,IAAI,YAAa,GAAI,EAAE,GACtF;CAEJ;CACA,kBAAkB,YAAY,OAAO,GAAG;CACxC,IAAI,SAAS,UAAU,CAAC,EAAE,aAAa,OAAO,KAC5C,GAAG,OAAO,SAAS,UAAU,GAAG,EAAE,OAAO,KAAK,CAAC;CAEjD,OAAO;AACT;;AAGA,eAAsB,aACpB,SAC6B;CAC7B,MAAM,EAAE,YAAY,aAAa,eAAe;CAChD,MAAM,UAAU,MAAM,UAAU;EAAE;EAAY;EAAa;CAAW,CAAC;CACvE,IAAI,SAAS,aAAa,sBAAsB,QAAQ,IAAI,GAAG;CAC/D,OAAO,YAAY,OAAO;AAC5B","debug_id":"65ce43c7-1403-5a81-b34e-0e82d25546ca"}
@@ -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"}