@powerhousedao/ph-cli 6.2.3-staging.0 → 6.3.0-dev.1

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 (191) hide show
  1. package/README.md +21 -0
  2. package/dist/build-1BN9BD49.mjs +4 -0
  3. package/dist/build-CWm9MOFJ.mjs +3063 -0
  4. package/dist/build-CWm9MOFJ.mjs.map +1 -0
  5. package/dist/check-BZOXiSys.mjs +4 -0
  6. package/dist/check-C9kQub0h.mjs +81 -0
  7. package/dist/check-C9kQub0h.mjs.map +1 -0
  8. package/dist/check-D0b-uWwK.mjs +65 -0
  9. package/dist/check-D0b-uWwK.mjs.map +1 -0
  10. package/dist/classic-args-mH_DVsgC.mjs +48 -0
  11. package/dist/classic-args-mH_DVsgC.mjs.map +1 -0
  12. package/dist/classic-warnings-kQsFGSeA.mjs +179 -0
  13. package/dist/classic-warnings-kQsFGSeA.mjs.map +1 -0
  14. package/dist/{cli-connect-override-b4kKqgOZ.mjs → cli-connect-override-31gBnNxd.mjs} +6 -29
  15. package/dist/cli-connect-override-31gBnNxd.mjs.map +1 -0
  16. package/dist/cli.mjs +46 -1341
  17. package/dist/cli.mjs.map +1 -1
  18. package/dist/compound-CDrU3CLt-gW8JNJQK.mjs +2910 -0
  19. package/dist/compound-CDrU3CLt-gW8JNJQK.mjs.map +1 -0
  20. package/dist/connect-build-is3cmf0E.mjs +322 -0
  21. package/dist/connect-build-is3cmf0E.mjs.map +1 -0
  22. package/dist/{connect-config-_kiSMsbG.mjs → connect-config-Dj3E8CaW.mjs} +5 -5
  23. package/dist/{connect-config-_kiSMsbG.mjs.map → connect-config-Dj3E8CaW.mjs.map} +1 -1
  24. package/dist/connect-preview-CdFvlANO.mjs +49 -0
  25. package/dist/connect-preview-CdFvlANO.mjs.map +1 -0
  26. package/dist/{connect-studio-f3K1qPWd.mjs → connect-studio-BNSe_8PI.mjs} +3 -3
  27. package/dist/connect-studio-CBtduPet.mjs +94 -0
  28. package/dist/connect-studio-CBtduPet.mjs.map +1 -0
  29. package/dist/definitions-worker.d.mts +98 -0
  30. package/dist/definitions-worker.d.mts.map +1 -0
  31. package/dist/definitions-worker.mjs +28 -0
  32. package/dist/definitions-worker.mjs.map +1 -0
  33. package/dist/dist-seTzvoSw.mjs +480 -0
  34. package/dist/dist-seTzvoSw.mjs.map +1 -0
  35. package/dist/evidence-CavwC5YV.mjs +134 -0
  36. package/dist/evidence-CavwC5YV.mjs.map +1 -0
  37. package/dist/explain-DTa32gEY.mjs +230 -0
  38. package/dist/explain-DTa32gEY.mjs.map +1 -0
  39. package/dist/export-YEBE-Gvl.mjs +42 -0
  40. package/dist/export-YEBE-Gvl.mjs.map +1 -0
  41. package/dist/external-M25AgDIE.d.mts +4277 -0
  42. package/dist/external-M25AgDIE.d.mts.map +1 -0
  43. package/dist/files-D6_euBBn.mjs +457 -0
  44. package/dist/files-D6_euBBn.mjs.map +1 -0
  45. package/dist/{generate-all-CIwP-3aa.mjs → generate-all-DKuaLgz1.mjs} +10 -5
  46. package/dist/generate-all-DKuaLgz1.mjs.map +1 -0
  47. package/dist/generate-app-hm6CJ_4O.mjs +72 -0
  48. package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
  49. package/dist/generate-desktop-shell-Dh9_bhLa.mjs +372 -0
  50. package/dist/generate-desktop-shell-Dh9_bhLa.mjs.map +1 -0
  51. package/dist/generate-document-model-OQPfeHs-.mjs +118 -0
  52. package/dist/generate-document-model-OQPfeHs-.mjs.map +1 -0
  53. package/dist/generate-editor-DBj_Pxwa.mjs +64 -0
  54. package/dist/generate-editor-DBj_Pxwa.mjs.map +1 -0
  55. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  56. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  57. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  58. package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
  59. package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
  60. package/dist/{generate-piece-QTt-ddt2.mjs → generate-piece-5Nyr2UZj.mjs} +18 -10
  61. package/dist/generate-piece-5Nyr2UZj.mjs.map +1 -0
  62. package/dist/{generate-piece-action-C5WTHsqu.mjs → generate-piece-action-DqR8BcoO.mjs} +10 -7
  63. package/dist/generate-piece-action-DqR8BcoO.mjs.map +1 -0
  64. package/dist/{generate-piece-trigger-DR10CPOG.mjs → generate-piece-trigger-CZaDD-cc.mjs} +8 -7
  65. package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
  66. package/dist/{generate-processor-DBtTkgo5.mjs → generate-processor-BVjOsfjJ.mjs} +20 -9
  67. package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
  68. package/dist/generate-subgraph-DJZCr0Tk.mjs +86 -0
  69. package/dist/generate-subgraph-DJZCr0Tk.mjs.map +1 -0
  70. package/dist/get-version-CrerlHgg.mjs +11 -0
  71. package/dist/get-version-CrerlHgg.mjs.map +1 -0
  72. package/dist/index-Dy3U1WqW.d.mts +192 -0
  73. package/dist/index-Dy3U1WqW.d.mts.map +1 -0
  74. package/dist/{init-CIEMyAug.mjs → init-CJB6RiIy.mjs} +23 -13
  75. package/dist/init-CJB6RiIy.mjs.map +1 -0
  76. package/dist/inspect-CulIpVsF.mjs +52 -0
  77. package/dist/inspect-CulIpVsF.mjs.map +1 -0
  78. package/dist/{inspect-BpCB0TPo.mjs → inspect-zWJnBDMJ.mjs} +4 -4
  79. package/dist/{inspect-BpCB0TPo.mjs.map → inspect-zWJnBDMJ.mjs.map} +1 -1
  80. package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
  81. package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
  82. package/dist/keyframes-bFo9iDhT.mjs +201 -0
  83. package/dist/keyframes-bFo9iDhT.mjs.map +1 -0
  84. package/dist/mcp-DJKiREkL.mjs +263 -0
  85. package/dist/mcp-DJKiREkL.mjs.map +1 -0
  86. package/dist/migrate-Bg-HBsYa.mjs +208 -0
  87. package/dist/migrate-Bg-HBsYa.mjs.map +1 -0
  88. package/dist/migrate-subgraphs-Bm3zpsO9.mjs +214 -0
  89. package/dist/migrate-subgraphs-Bm3zpsO9.mjs.map +1 -0
  90. package/dist/migrate-subgraphs-De_rX4Hv.mjs +4 -0
  91. package/dist/module-dir-1avCXsBi.mjs +17 -0
  92. package/dist/module-dir-1avCXsBi.mjs.map +1 -0
  93. package/dist/npm-args-g1Tgel4s.mjs +78 -0
  94. package/dist/npm-args-g1Tgel4s.mjs.map +1 -0
  95. package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
  96. package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
  97. package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
  98. package/dist/ph-cli-commands-C6cJJQlA.mjs +1787 -0
  99. package/dist/ph-cli-commands-C6cJJQlA.mjs.map +1 -0
  100. package/dist/ph-cli-commands-CCCVUIzM.mjs +4 -0
  101. package/dist/render-3M3DwFzO.mjs +4 -0
  102. package/dist/render-SVfj3m8A.mjs +77 -0
  103. package/dist/render-SVfj3m8A.mjs.map +1 -0
  104. package/dist/run--de_-WAz.mjs +112 -0
  105. package/dist/run--de_-WAz.mjs.map +1 -0
  106. package/dist/run-LRGy7zGo.mjs +4 -0
  107. package/dist/run-sugar-ByAIbE2x.mjs +56 -0
  108. package/dist/run-sugar-ByAIbE2x.mjs.map +1 -0
  109. package/dist/runners/connect.d.mts +17 -0
  110. package/dist/runners/connect.d.mts.map +1 -0
  111. package/dist/runners/connect.mjs +83 -0
  112. package/dist/runners/connect.mjs.map +1 -0
  113. package/dist/runners/switchboard.d.mts +24 -0
  114. package/dist/runners/switchboard.d.mts.map +1 -0
  115. package/dist/runners/switchboard.mjs +178 -0
  116. package/dist/runners/switchboard.mjs.map +1 -0
  117. package/dist/schemas-DzgKfQIx.mjs +6024 -0
  118. package/dist/schemas-DzgKfQIx.mjs.map +1 -0
  119. package/dist/scripts/emit-runner-schemas.ts +24 -0
  120. package/dist/scripts/generate-commands-docs.ts +19 -0
  121. package/dist/scripts/manage-environment +0 -0
  122. package/dist/scripts/setup.sh +0 -0
  123. package/dist/subgraph-gate-BJ2PWXVY.mjs +26 -0
  124. package/dist/subgraph-gate-BJ2PWXVY.mjs.map +1 -0
  125. package/dist/subgraph-gate-j9ywj6KA.mjs +4 -0
  126. package/dist/subgraphs-7OYWwP-C.mjs +134 -0
  127. package/dist/subgraphs-7OYWwP-C.mjs.map +1 -0
  128. package/dist/{switchboard-migrate-7JQZM7-5.mjs → switchboard-migrate-BqSdKJ7u.mjs} +4 -5
  129. package/dist/switchboard-migrate-BqSdKJ7u.mjs.map +1 -0
  130. package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
  131. package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
  132. package/dist/{switchboard-reset-Ctegiqdm.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  133. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  134. package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
  135. package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
  136. package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
  137. package/dist/{utils-CvmDmCVd.mjs → utils-9KyRM0mf.mjs} +6 -34
  138. package/dist/{utils-CvmDmCVd.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  139. package/dist/utils-TO9lB8Xs.mjs +4 -0
  140. package/dist/verify-CIWOkZZV.mjs +71 -0
  141. package/dist/verify-CIWOkZZV.mjs.map +1 -0
  142. package/dist/vetra-CmTg8Lja.mjs +351 -0
  143. package/dist/vetra-CmTg8Lja.mjs.map +1 -0
  144. package/dist/vetra-host-C0Q0oMUW.mjs +79 -0
  145. package/dist/vetra-host-C0Q0oMUW.mjs.map +1 -0
  146. package/dist/vetra-instance-B0bXPj7g.mjs +201 -0
  147. package/dist/vetra-instance-B0bXPj7g.mjs.map +1 -0
  148. package/dist/vetra-launch-T_uLKaR3.mjs +236 -0
  149. package/dist/vetra-launch-T_uLKaR3.mjs.map +1 -0
  150. package/dist/vetra-switchboard-BrkozIm7.mjs +4 -0
  151. package/dist/vetra-switchboard-tzdc14KA.mjs +230 -0
  152. package/dist/vetra-switchboard-tzdc14KA.mjs.map +1 -0
  153. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  154. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  155. package/package.json +40 -14
  156. package/dist/build-CTvPQFMi.mjs +0 -4
  157. package/dist/build-sO3PcZxl.mjs +0 -166
  158. package/dist/build-sO3PcZxl.mjs.map +0 -1
  159. package/dist/cli-connect-override-b4kKqgOZ.mjs.map +0 -1
  160. package/dist/connect-build-BMaR9w4G.mjs +0 -153
  161. package/dist/connect-build-BMaR9w4G.mjs.map +0 -1
  162. package/dist/connect-preview-CzDqR-JN.mjs +0 -32
  163. package/dist/connect-preview-CzDqR-JN.mjs.map +0 -1
  164. package/dist/connect-studio-_-O1-oef.mjs +0 -36
  165. package/dist/connect-studio-_-O1-oef.mjs.map +0 -1
  166. package/dist/generate-all-CIwP-3aa.mjs.map +0 -1
  167. package/dist/generate-app-BTs1u-9l.mjs +0 -50
  168. package/dist/generate-app-BTs1u-9l.mjs.map +0 -1
  169. package/dist/generate-document-model-DhDQ_06X.mjs +0 -44
  170. package/dist/generate-document-model-DhDQ_06X.mjs.map +0 -1
  171. package/dist/generate-editor-CW7Do69u.mjs +0 -50
  172. package/dist/generate-editor-CW7Do69u.mjs.map +0 -1
  173. package/dist/generate-piece-QTt-ddt2.mjs.map +0 -1
  174. package/dist/generate-piece-action-C5WTHsqu.mjs.map +0 -1
  175. package/dist/generate-piece-trigger-DR10CPOG.mjs.map +0 -1
  176. package/dist/generate-processor-DBtTkgo5.mjs.map +0 -1
  177. package/dist/generate-subgraph-Dm27O59o.mjs +0 -42
  178. package/dist/generate-subgraph-Dm27O59o.mjs.map +0 -1
  179. package/dist/init-CIEMyAug.mjs.map +0 -1
  180. package/dist/install-added-dependencies-DVSbzler.mjs +0 -33
  181. package/dist/install-added-dependencies-DVSbzler.mjs.map +0 -1
  182. package/dist/migrate-B6QBYDNX.mjs +0 -83
  183. package/dist/migrate-B6QBYDNX.mjs.map +0 -1
  184. package/dist/switchboard-CgVB4U76.mjs +0 -87
  185. package/dist/switchboard-CgVB4U76.mjs.map +0 -1
  186. package/dist/switchboard-migrate-7JQZM7-5.mjs.map +0 -1
  187. package/dist/switchboard-nHCI3pha.mjs +0 -4
  188. package/dist/switchboard-reset-Ctegiqdm.mjs.map +0 -1
  189. package/dist/utils-C3c5YG6v.mjs +0 -4
  190. package/dist/vetra-s8gWslse.mjs +0 -627
  191. package/dist/vetra-s8gWslse.mjs.map +0 -1
@@ -0,0 +1,201 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ad01a2f1-f8cb-5b4f-b17a-43c2cdabcde1")}catch(e){}}();
3
+ import { L as probeRun } from "./compound-CDrU3CLt-gW8JNJQK.mjs";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
7
+ import net from "node:net";
8
+ //#region src/utils/vetra-runtime.ts
9
+ const READY_TIMEOUT_MS = 2e3;
10
+ const recordPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra-runtime.json");
11
+ function readVetraRuntime(projectDir) {
12
+ try {
13
+ return JSON.parse(fs.readFileSync(recordPath(projectDir), "utf8"));
14
+ } catch {
15
+ return;
16
+ }
17
+ }
18
+ function writeVetraRuntime(projectDir, record) {
19
+ const target = recordPath(projectDir);
20
+ fs.mkdirSync(path.dirname(target), { recursive: true });
21
+ fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\n`);
22
+ }
23
+ /**
24
+ * The record this process publishes for the Vetra it started. `ph vetra` and
25
+ * `ph run vetra` both build it here, so the two write the same fields. The
26
+ * Switchboard's URLs follow from its port unless the caller knows them.
27
+ */
28
+ function vetraRuntimeRecord(input) {
29
+ const { switchboardPort, connectUrl } = input;
30
+ return {
31
+ pid: process.pid,
32
+ projectName: input.projectName,
33
+ switchboardPort,
34
+ connectPort: input.connectPort,
35
+ switchboardUrl: input.switchboardUrl ?? `http://localhost:${switchboardPort}/graphql`,
36
+ mcpUrl: input.mcpUrl ?? `http://localhost:${switchboardPort}/mcp`,
37
+ ...connectUrl ? { connectUrl } : {},
38
+ startedAt: (/* @__PURE__ */ new Date()).toISOString()
39
+ };
40
+ }
41
+ /** Deletes the record; with `pid`, only the record of that process. */
42
+ function clearVetraRuntime(projectDir, pid) {
43
+ if (pid !== void 0 && readVetraRuntime(projectDir)?.pid !== pid) return;
44
+ try {
45
+ fs.rmSync(recordPath(projectDir));
46
+ } catch {}
47
+ }
48
+ function isPidAlive(pid) {
49
+ try {
50
+ process.kill(pid, 0);
51
+ return true;
52
+ } catch (error) {
53
+ return error.code === "EPERM";
54
+ }
55
+ }
56
+ function isPortInUse(port) {
57
+ return new Promise((resolve) => {
58
+ const socket = net.connect({
59
+ port,
60
+ host: "localhost"
61
+ });
62
+ socket.once("connect", () => {
63
+ socket.destroy();
64
+ resolve(true);
65
+ });
66
+ socket.once("error", () => resolve(false));
67
+ });
68
+ }
69
+ async function isReady(port) {
70
+ try {
71
+ return (await fetch(`http://localhost:${port}/ready`, { signal: AbortSignal.timeout(READY_TIMEOUT_MS) })).ok;
72
+ } catch {
73
+ return false;
74
+ }
75
+ }
76
+ /**
77
+ * Decide whether the recorded instance is actually serving this project.
78
+ *
79
+ * All three checks are load-bearing. A pid can be reused by an unrelated
80
+ * process, so a live pid proves nothing on its own. Another project's
81
+ * switchboard would answer `/ready` on its own port, so a healthy `/ready`
82
+ * proves nothing either. And the recorded `projectName` is what separates
83
+ * "my instance" from "someone else's instance that happens to hold this
84
+ * port" — which is precisely the confusion that let an agent write document
85
+ * models into a different project's drive.
86
+ *
87
+ * A stale record is deleted so the next start is unblocked. A foreign one is
88
+ * left alone: it describes something that is alive.
89
+ */
90
+ async function probeVetraRuntime(projectDir, projectName) {
91
+ const record = readVetraRuntime(projectDir);
92
+ if (!record) return { status: "none" };
93
+ const alive = isPidAlive(record.pid);
94
+ const ready = alive && await isReady(record.switchboardPort);
95
+ const starting = alive && !ready && await isPortInUse(record.switchboardPort);
96
+ if (!ready && !starting) {
97
+ clearVetraRuntime(projectDir);
98
+ return { status: "stale" };
99
+ }
100
+ if (record.projectName !== projectName) return {
101
+ status: "foreign",
102
+ record
103
+ };
104
+ return ready ? {
105
+ status: "live",
106
+ record
107
+ } : {
108
+ status: "starting",
109
+ record
110
+ };
111
+ }
112
+ const MCP_FILES = [
113
+ ".mcp.json",
114
+ path.join(".cursor", "mcp.json"),
115
+ path.join(".gemini", "settings.json")
116
+ ];
117
+ /** Each MCP config whose `reactor-mcp` entry still points at a URL. */
118
+ function urlMcpConfigs(projectDir) {
119
+ const found = [];
120
+ for (const rel of MCP_FILES) {
121
+ const target = path.join(projectDir, rel);
122
+ if (!fs.existsSync(target)) continue;
123
+ let parsed;
124
+ try {
125
+ parsed = JSON.parse(fs.readFileSync(target, "utf8"));
126
+ } catch {
127
+ continue;
128
+ }
129
+ const server = parsed.mcpServers?.["reactor-mcp"];
130
+ if (server?.url) found.push([
131
+ rel,
132
+ parsed,
133
+ server
134
+ ]);
135
+ }
136
+ return found;
137
+ }
138
+ /** The MCP configs `ph migrate` would move to the `ph mcp` launcher. */
139
+ function legacyMcpConfigs(projectDir) {
140
+ return urlMcpConfigs(projectDir).map(([rel]) => rel);
141
+ }
142
+ /**
143
+ * Point every URL-style `reactor-mcp` entry at `port`, returning the files
144
+ * changed. Stdio entries (`ph mcp`) carry no port and are left alone; this
145
+ * keeps projects that have not run `ph migrate` working.
146
+ */
147
+ function syncMcpPort(projectDir, port) {
148
+ const changed = [];
149
+ const wanted = `http://localhost:${port}/mcp`;
150
+ for (const [rel, parsed, server] of urlMcpConfigs(projectDir)) {
151
+ if (server.url === wanted) continue;
152
+ server.url = wanted;
153
+ fs.writeFileSync(path.join(projectDir, rel), `${JSON.stringify(parsed, null, 2)}\n`);
154
+ changed.push(rel);
155
+ }
156
+ return changed;
157
+ }
158
+ /**
159
+ * {@link syncMcpPort} for a Vetra that just bound `port`, returning what to
160
+ * tell the user. An MCP client resolved `.mcp.json` before this process
161
+ * started and cannot re-read it, so a drifted literal means the agent is
162
+ * pointed at the wrong port — possibly another project's reactor. Correct the
163
+ * file and say so plainly; we cannot fix the already-open client ourselves.
164
+ */
165
+ function syncMcpPortNotices(projectDir, port) {
166
+ const notices = [];
167
+ const driftedMcpFiles = syncMcpPort(projectDir, port);
168
+ if (driftedMcpFiles.length > 0) notices.push(`Updated ${driftedMcpFiles.join(" and ")} to port ${port}. Reconnect your MCP client (/mcp) to pick it up. This edit is local — do not commit it.`);
169
+ if (legacyMcpConfigs(projectDir).length > 0) notices.push("reactor-mcp still points at a URL; run `ph migrate` to switch it to the `ph mcp` launcher.");
170
+ return notices;
171
+ }
172
+ //#endregion
173
+ //#region src/utils/vetra-instance.ts
174
+ /**
175
+ * One Vetra per project, whichever command started it. `ph vetra` records
176
+ * itself in `.ph/vetra-runtime.json`; `ph run vetra` records its stack in
177
+ * `.ph/run/vetra.json` and, once ready, in `.ph/vetra-runtime.json` too.
178
+ * Each start asks here whether the other kind holds the project.
179
+ */
180
+ /** The host folder `ph vetra` routes to, and the name its host file carries. */
181
+ const VETRA_HOST = "vetra";
182
+ /** Why `ph vetra` must not start: a live `ph run vetra` holds the project. */
183
+ function runVetraRefusal(projectDir, projectName) {
184
+ const probe = probeRun(projectDir, VETRA_HOST, projectName);
185
+ if (probe.status === "live" && probe.record.pid !== process.pid) return `Vetra is already running for this project through \`ph run ${VETRA_HOST}\` (pid ${probe.record.pid}). Stop it before starting another.`;
186
+ if (probe.status === "foreign") return `.ph/run/${VETRA_HOST}.json describes a live "${probe.record.projectName}", but this project is "${projectName}". Refusing to start a second instance.`;
187
+ }
188
+ /** Why `ph run vetra` must not start: a live Vetra holds the project. */
189
+ async function vetraRuntimeRefusal(projectDir, projectName) {
190
+ const probe = await probeVetraRuntime(projectDir, projectName);
191
+ if (probe.status === "live" || probe.status === "starting") {
192
+ if (probe.record.pid === process.pid) return void 0;
193
+ return `Vetra is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`;
194
+ }
195
+ if (probe.status === "foreign") return `.ph/vetra-runtime.json describes a live Vetra for "${probe.record.projectName}", but this project is "${projectName}". Refusing to start a second instance. Delete .ph/vetra-runtime.json if that record is wrong.`;
196
+ }
197
+ //#endregion
198
+ export { isPortInUse as a, syncMcpPortNotices as c, clearVetraRuntime as i, vetraRuntimeRecord as l, runVetraRefusal as n, probeVetraRuntime as o, vetraRuntimeRefusal as r, readVetraRuntime as s, VETRA_HOST as t, writeVetraRuntime as u };
199
+
200
+ //# sourceMappingURL=vetra-instance-B0bXPj7g.mjs.map
201
+ //# debugId=ad01a2f1-f8cb-5b4f-b17a-43c2cdabcde1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vetra-instance-B0bXPj7g.mjs","sources":["../src/utils/vetra-runtime.ts","../src/utils/vetra-instance.ts"],"sourcesContent":["import { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport fs from \"node:fs\";\nimport net from \"node:net\";\nimport path from \"node:path\";\n\nexport type VetraRuntimeRecord = {\n pid: number;\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n /** The Switchboard's GraphQL endpoint; absent in records from before it was written. */\n switchboardUrl?: string;\n mcpUrl: string;\n /** Vetra Studio; absent with --disable-connect. */\n connectUrl?: string;\n startedAt: string;\n};\n\nexport type VetraProbe =\n | { status: \"none\" }\n | { status: \"stale\" }\n | { status: \"starting\"; record: VetraRuntimeRecord }\n | { status: \"live\"; record: VetraRuntimeRecord }\n | { status: \"foreign\"; record: VetraRuntimeRecord };\n\nconst READY_TIMEOUT_MS = 2000;\n\n// Under the project's .ph tree — relocated with it by PH_USER_DATA_DIR.\nconst recordPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-runtime.json\");\n\nexport function readVetraRuntime(\n projectDir: string,\n): VetraRuntimeRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(recordPath(projectDir), \"utf8\"),\n ) as VetraRuntimeRecord;\n } catch {\n // Missing or corrupt: either way there is no usable record.\n return undefined;\n }\n}\n\nexport function writeVetraRuntime(\n projectDir: string,\n record: VetraRuntimeRecord,\n): void {\n const target = recordPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\n/**\n * The record this process publishes for the Vetra it started. `ph vetra` and\n * `ph run vetra` both build it here, so the two write the same fields. The\n * Switchboard's URLs follow from its port unless the caller knows them.\n */\nexport function vetraRuntimeRecord(input: {\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n switchboardUrl?: string;\n mcpUrl?: string;\n /** Left out when no Vetra Studio runs. */\n connectUrl?: string;\n}): VetraRuntimeRecord {\n const { switchboardPort, connectUrl } = input;\n return {\n pid: process.pid,\n projectName: input.projectName,\n switchboardPort,\n connectPort: input.connectPort,\n switchboardUrl:\n input.switchboardUrl ?? `http://localhost:${switchboardPort}/graphql`,\n mcpUrl: input.mcpUrl ?? `http://localhost:${switchboardPort}/mcp`,\n ...(connectUrl ? { connectUrl } : {}),\n startedAt: new Date().toISOString(),\n };\n}\n\n/** Deletes the record; with `pid`, only the record of that process. */\nexport function clearVetraRuntime(projectDir: string, pid?: number): void {\n if (pid !== undefined && readVetraRuntime(projectDir)?.pid !== pid) return;\n try {\n fs.rmSync(recordPath(projectDir));\n } catch {\n // Already gone.\n }\n}\n\nfunction isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means the process exists but belongs to another user.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nexport function isPortInUse(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = net.connect({ port, host: \"localhost\" });\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"error\", () => resolve(false));\n });\n}\n\nasync function isReady(port: number): Promise<boolean> {\n try {\n const response = await fetch(`http://localhost:${port}/ready`, {\n signal: AbortSignal.timeout(READY_TIMEOUT_MS),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * Decide whether the recorded instance is actually serving this project.\n *\n * All three checks are load-bearing. A pid can be reused by an unrelated\n * process, so a live pid proves nothing on its own. Another project's\n * switchboard would answer `/ready` on its own port, so a healthy `/ready`\n * proves nothing either. And the recorded `projectName` is what separates\n * \"my instance\" from \"someone else's instance that happens to hold this\n * port\" — which is precisely the confusion that let an agent write document\n * models into a different project's drive.\n *\n * A stale record is deleted so the next start is unblocked. A foreign one is\n * left alone: it describes something that is alive.\n */\nexport async function probeVetraRuntime(\n projectDir: string,\n projectName: string,\n): Promise<VetraProbe> {\n const record = readVetraRuntime(projectDir);\n if (!record) return { status: \"none\" };\n\n const alive = isPidAlive(record.pid);\n const ready = alive && (await isReady(record.switchboardPort));\n // The record lands once the port is bound; `/ready` turns 200 later.\n const starting =\n alive && !ready && (await isPortInUse(record.switchboardPort));\n if (!ready && !starting) {\n clearVetraRuntime(projectDir);\n return { status: \"stale\" };\n }\n\n if (record.projectName !== projectName) {\n return { status: \"foreign\", record };\n }\n return ready ? { status: \"live\", record } : { status: \"starting\", record };\n}\n\nconst MCP_FILES = [\n \".mcp.json\",\n path.join(\".cursor\", \"mcp.json\"),\n path.join(\".gemini\", \"settings.json\"),\n];\n\ntype McpConfig = { mcpServers?: Record<string, { url?: string }> };\ntype UrlMcpConfig = [string, McpConfig, { url?: string }];\n\n/** Each MCP config whose `reactor-mcp` entry still points at a URL. */\nfunction urlMcpConfigs(projectDir: string): UrlMcpConfig[] {\n const found: UrlMcpConfig[] = [];\n for (const rel of MCP_FILES) {\n const target = path.join(projectDir, rel);\n if (!fs.existsSync(target)) continue;\n let parsed: McpConfig;\n try {\n parsed = JSON.parse(fs.readFileSync(target, \"utf8\")) as McpConfig;\n } catch {\n // Hand-broken JSON is the author's to fix; don't clobber it.\n continue;\n }\n const server = parsed.mcpServers?.[\"reactor-mcp\"];\n if (server?.url) found.push([rel, parsed, server]);\n }\n return found;\n}\n\n/** The MCP configs `ph migrate` would move to the `ph mcp` launcher. */\nexport function legacyMcpConfigs(projectDir: string): string[] {\n return urlMcpConfigs(projectDir).map(([rel]) => rel);\n}\n\n/**\n * Point every URL-style `reactor-mcp` entry at `port`, returning the files\n * changed. Stdio entries (`ph mcp`) carry no port and are left alone; this\n * keeps projects that have not run `ph migrate` working.\n */\nexport function syncMcpPort(projectDir: string, port: number): string[] {\n const changed: string[] = [];\n const wanted = `http://localhost:${port}/mcp`;\n for (const [rel, parsed, server] of urlMcpConfigs(projectDir)) {\n if (server.url === wanted) continue;\n server.url = wanted;\n fs.writeFileSync(\n path.join(projectDir, rel),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n );\n changed.push(rel);\n }\n return changed;\n}\n\n/**\n * {@link syncMcpPort} for a Vetra that just bound `port`, returning what to\n * tell the user. An MCP client resolved `.mcp.json` before this process\n * started and cannot re-read it, so a drifted literal means the agent is\n * pointed at the wrong port — possibly another project's reactor. Correct the\n * file and say so plainly; we cannot fix the already-open client ourselves.\n */\nexport function syncMcpPortNotices(projectDir: string, port: number): string[] {\n const notices: string[] = [];\n const driftedMcpFiles = syncMcpPort(projectDir, port);\n if (driftedMcpFiles.length > 0) {\n notices.push(\n `Updated ${driftedMcpFiles.join(\" and \")} to port ${port}. ` +\n `Reconnect your MCP client (/mcp) to pick it up. ` +\n `This edit is local — do not commit it.`,\n );\n }\n if (legacyMcpConfigs(projectDir).length > 0) {\n notices.push(\n \"reactor-mcp still points at a URL; run `ph migrate` to switch it to the `ph mcp` launcher.\",\n );\n }\n return notices;\n}\n","import { probeRun } from \"@powerhousedao/host-core\";\nimport { probeVetraRuntime } from \"./vetra-runtime.js\";\n\n/**\n * One Vetra per project, whichever command started it. `ph vetra` records\n * itself in `.ph/vetra-runtime.json`; `ph run vetra` records its stack in\n * `.ph/run/vetra.json` and, once ready, in `.ph/vetra-runtime.json` too.\n * Each start asks here whether the other kind holds the project.\n */\n\n/** The host folder `ph vetra` routes to, and the name its host file carries. */\nexport const VETRA_HOST = \"vetra\";\n\n/** Why `ph vetra` must not start: a live `ph run vetra` holds the project. */\nexport function runVetraRefusal(\n projectDir: string,\n projectName: string,\n): string | undefined {\n const probe = probeRun(projectDir, VETRA_HOST, projectName);\n if (probe.status === \"live\" && probe.record.pid !== process.pid) {\n return (\n `Vetra is already running for this project through \\`ph run ${VETRA_HOST}\\` ` +\n `(pid ${probe.record.pid}). Stop it before starting another.`\n );\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/run/${VETRA_HOST}.json describes a live \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance.`\n );\n }\n return undefined;\n}\n\n/** Why `ph run vetra` must not start: a live Vetra holds the project. */\nexport async function vetraRuntimeRefusal(\n projectDir: string,\n projectName: string,\n): Promise<string | undefined> {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\" || probe.status === \"starting\") {\n if (probe.record.pid === process.pid) return undefined;\n return `Vetra is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`;\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`\n );\n }\n return undefined;\n}\n"],"names":[],"mappings":";;;;;;;;AAyBA,MAAM,mBAAmB;AAGzB,MAAM,cAAc,eAClB,KAAK,KAAK,aAAa,UAAU,GAAG,oBAAoB;AAE1D,SAAgB,iBACd,YACgC;CAChC,IAAI;EACF,OAAO,KAAK,MACV,GAAG,aAAa,WAAW,UA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AK1C","debug_id":"ad01a2f1-f8cb-5b4f-b17a-43c2cdabcde1"}
@@ -0,0 +1,236 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3159fb33-5304-5abc-b690-9d71c181c70d")}catch(e){}}();
3
+ import { I as probeHostsFolder } from "./compound-CDrU3CLt-gW8JNJQK.mjs";
4
+ import { a as isPortInUse, i as clearVetraRuntime, o as probeVetraRuntime, t as VETRA_HOST } from "./vetra-instance-B0bXPj7g.mjs";
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ import { spawn } from "node:child_process";
8
+ import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
9
+ import { stripVTControlCharacters } from "node:util";
10
+ //#region src/utils/vetra-launch.ts
11
+ var VetraStartError = class extends Error {};
12
+ const PORT_GRACE_MS = 1e4;
13
+ const STOP_TIMEOUT_MS = 15e3;
14
+ const PROGRESS_EVERY_MS = 1e3;
15
+ const lockPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra-start.lock");
16
+ const vetraLogPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra.log");
17
+ const shownLogPath = (projectDir) => path.relative(projectDir, vetraLogPath(projectDir)).split(path.sep).join("/");
18
+ /** `ph vetra --strictPort --watch` run by the ph-cli executing this code. */
19
+ function currentPhCliVetraCommand() {
20
+ return {
21
+ command: process.execPath,
22
+ args: [
23
+ process.argv[1],
24
+ "vetra",
25
+ "--strictPort",
26
+ "--watch"
27
+ ]
28
+ };
29
+ }
30
+ /** `ph run vetra --strictPort` run by the ph-cli executing this code. */
31
+ function currentPhCliRunVetraCommand() {
32
+ return {
33
+ command: process.execPath,
34
+ args: [
35
+ process.argv[1],
36
+ "run",
37
+ VETRA_HOST,
38
+ "--strictPort"
39
+ ],
40
+ label: `ph run ${VETRA_HOST}`
41
+ };
42
+ }
43
+ /**
44
+ * What starts this project's Vetra: its `hosts/vetra` host when it has one,
45
+ * as `ph vetra` itself routes there (run-sugar.ts), else classic `ph vetra`.
46
+ * The host's own defaultVerb picks the verb; `--watch` is not a host argument.
47
+ */
48
+ function vetraCommandFor(projectDir) {
49
+ const probe = probeHostsFolder(projectDir);
50
+ return probe.kind === "present" && probe.hosts.includes("vetra") ? currentPhCliRunVetraCommand() : currentPhCliVetraCommand();
51
+ }
52
+ function isPidAlive(pid) {
53
+ if (!pid) return false;
54
+ try {
55
+ process.kill(pid, 0);
56
+ return true;
57
+ } catch (error) {
58
+ return error.code === "EPERM";
59
+ }
60
+ }
61
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
62
+ function readLock(projectDir) {
63
+ try {
64
+ return JSON.parse(fs.readFileSync(lockPath(projectDir), "utf8"));
65
+ } catch {
66
+ return;
67
+ }
68
+ }
69
+ function isLockHeld(lock) {
70
+ return !!lock && (isPidAlive(lock.pid) || isPidAlive(lock.vetraPid));
71
+ }
72
+ /** Held while the launcher or the Vetra it started is alive. */
73
+ function tryAcquireLock(projectDir) {
74
+ const target = lockPath(projectDir);
75
+ fs.mkdirSync(path.dirname(target), { recursive: true });
76
+ for (let attempt = 0; attempt < 2; attempt++) try {
77
+ fs.writeFileSync(target, JSON.stringify({ pid: process.pid }), { flag: "wx" });
78
+ return true;
79
+ } catch (error) {
80
+ if (error.code !== "EEXIST") throw error;
81
+ if (isLockHeld(readLock(projectDir))) return false;
82
+ fs.rmSync(target, { force: true });
83
+ }
84
+ return false;
85
+ }
86
+ function releaseLock(projectDir) {
87
+ if (readLock(projectDir)?.pid === process.pid) fs.rmSync(lockPath(projectDir), { force: true });
88
+ }
89
+ function readLogTail(projectDir) {
90
+ try {
91
+ const text = fs.readFileSync(vetraLogPath(projectDir), "utf8");
92
+ return stripVTControlCharacters(text).trimEnd().split("\n").slice(-60).join("\n");
93
+ } catch {
94
+ return "";
95
+ }
96
+ }
97
+ function withOutput(message, projectDir) {
98
+ const tail = readLogTail(projectDir);
99
+ const where = shownLogPath(projectDir);
100
+ return new VetraStartError(tail ? `${message}\n\nVetra output (last lines of ${where}):\n${tail}` : message);
101
+ }
102
+ function foreignError(record) {
103
+ return new VetraStartError(`.ph/vetra-runtime.json describes a live Vetra for "${record.projectName}" (pid ${record.pid}), not this project. Refusing to start a second reactor. Delete .ph/vetra-runtime.json if that record is wrong.`);
104
+ }
105
+ async function waitForLive(options, deadline, stillStarting) {
106
+ const { projectDir, projectName, pollMs = 250, onProgress } = options;
107
+ const startedAt = Date.now();
108
+ let reportedAt = startedAt;
109
+ while (Date.now() < deadline) {
110
+ const probe = await probeVetraRuntime(projectDir, projectName);
111
+ if (probe.status === "live") return probe.record;
112
+ if (probe.status === "foreign") throw foreignError(probe.record);
113
+ if (probe.status !== "starting" && !stillStarting()) return void 0;
114
+ if (onProgress && Date.now() - reportedAt >= PROGRESS_EVERY_MS) {
115
+ reportedAt = Date.now();
116
+ onProgress(`Waiting for Vetra to be ready (${Math.round((reportedAt - startedAt) / 1e3)}s)...`);
117
+ }
118
+ await sleep(pollMs);
119
+ }
120
+ }
121
+ /** This project's live Vetra, or a detached `ph vetra` started and awaited; never a second reactor. */
122
+ async function ensureVetra(options) {
123
+ const { projectDir, projectName, switchboardPort, timeoutMs } = options;
124
+ const deadline = Date.now() + timeoutMs;
125
+ const seconds = Math.round(timeoutMs / 1e3);
126
+ const report = options.onProgress ?? (() => {});
127
+ const probe = await probeVetraRuntime(projectDir, projectName);
128
+ if (probe.status === "live") return probe.record;
129
+ if (probe.status === "foreign") throw foreignError(probe.record);
130
+ if (probe.status === "starting") {
131
+ report(`Vetra (pid ${probe.record.pid}) is starting; waiting for it...`);
132
+ const record = await waitForLive(options, deadline, () => false);
133
+ if (record) return record;
134
+ throw withOutput(`Vetra (pid ${probe.record.pid}) is running but did not answer /ready within ${seconds}s.`, projectDir);
135
+ }
136
+ while (!tryAcquireLock(projectDir)) {
137
+ report("Another process is starting Vetra for this project; waiting...");
138
+ const record = await waitForLive(options, deadline, () => isLockHeld(readLock(projectDir)));
139
+ if (record) return record;
140
+ if (Date.now() >= deadline) throw withOutput(`Another process is starting Vetra for this project and it did not become ready within ${seconds}s.`, projectDir);
141
+ }
142
+ let keepLock = false;
143
+ try {
144
+ const again = await probeVetraRuntime(projectDir, projectName);
145
+ if (again.status === "live") return again.record;
146
+ if (again.status === "foreign") throw foreignError(again.record);
147
+ if (again.status === "starting" || await isPortInUse(switchboardPort)) {
148
+ const grace = Date.now() + PORT_GRACE_MS;
149
+ const record = await waitForLive(options, deadline, () => Date.now() < grace);
150
+ if (record) return record;
151
+ throw new VetraStartError(`Port ${switchboardPort} is in use, but .ph/vetra-runtime.json names no live Vetra for this project. Stop whatever holds the port, or move this project's port (reactor.port in powerhouse.config.json).`);
152
+ }
153
+ const logFile = vetraLogPath(projectDir);
154
+ report(`Starting Vetra; its output goes to ${shownLogPath(projectDir)}...`);
155
+ const logFd = fs.openSync(logFile, "w");
156
+ let exit;
157
+ let spawnError;
158
+ const child = spawn(options.command.command, options.command.args, {
159
+ cwd: projectDir,
160
+ detached: true,
161
+ stdio: [
162
+ "ignore",
163
+ logFd,
164
+ logFd
165
+ ],
166
+ windowsHide: true
167
+ });
168
+ fs.closeSync(logFd);
169
+ child.once("error", (error) => spawnError = error);
170
+ child.once("exit", (code, signal) => exit = {
171
+ code,
172
+ signal
173
+ });
174
+ child.unref();
175
+ if (child.pid) fs.writeFileSync(lockPath(projectDir), JSON.stringify({
176
+ pid: process.pid,
177
+ vetraPid: child.pid
178
+ }));
179
+ const record = await waitForLive(options, deadline, () => !exit && !spawnError);
180
+ if (record) return record;
181
+ if (spawnError) throw new VetraStartError(`Could not run \`${options.command.command}\`: ${spawnError.message}`);
182
+ if (exit) {
183
+ const how = exit.signal !== null ? `was killed by ${exit.signal}` : `exited with code ${exit.code}`;
184
+ throw withOutput(`\`${options.command.label ?? "ph vetra"}\` ${how} before it was ready.`, projectDir);
185
+ }
186
+ keepLock = true;
187
+ throw withOutput(`Vetra (pid ${child.pid}) did not answer /ready on port ${switchboardPort} within ${seconds}s. It is still running; the next tool call waits for it again.`, projectDir);
188
+ } finally {
189
+ if (!keepLock) releaseLock(projectDir);
190
+ }
191
+ }
192
+ async function waitForExit(record, deadline) {
193
+ while (Date.now() < deadline) {
194
+ if (!isPidAlive(record.pid) && !await isPortInUse(record.switchboardPort)) return true;
195
+ await sleep(100);
196
+ }
197
+ return false;
198
+ }
199
+ /** Stops this project's running Vetra, if any; resolves to the record it stopped. */
200
+ async function stopVetra(options) {
201
+ const { projectDir, projectName, timeoutMs = STOP_TIMEOUT_MS } = options;
202
+ const probe = await probeVetraRuntime(projectDir, projectName);
203
+ if (probe.status === "foreign") throw foreignError(probe.record);
204
+ if (probe.status !== "live" && probe.status !== "starting") return void 0;
205
+ const { record } = probe;
206
+ const signal = (name) => {
207
+ try {
208
+ process.kill(record.pid, name);
209
+ } catch {}
210
+ };
211
+ options.onProgress?.(`Stopping Vetra (pid ${record.pid})...`);
212
+ signal("SIGTERM");
213
+ if (!await waitForExit(record, Date.now() + timeoutMs)) {
214
+ signal("SIGKILL");
215
+ if (!await waitForExit(record, Date.now() + timeoutMs)) throw new VetraStartError(`Vetra (pid ${record.pid}) did not stop within ${Math.round(2 * timeoutMs / 1e3)}s.`);
216
+ }
217
+ clearVetraRuntime(projectDir, record.pid);
218
+ if (readLock(projectDir)?.vetraPid === record.pid) fs.rmSync(lockPath(projectDir), { force: true });
219
+ return record;
220
+ }
221
+ /** Stops this project's Vetra and starts it again, detached, as {@link ensureVetra} does. */
222
+ async function restartVetra(options) {
223
+ const { projectDir, projectName, onProgress } = options;
224
+ const stopped = await stopVetra({
225
+ projectDir,
226
+ projectName,
227
+ onProgress
228
+ });
229
+ if (stopped) onProgress?.(`Stopped Vetra (pid ${stopped.pid}).`);
230
+ return ensureVetra(options);
231
+ }
232
+ //#endregion
233
+ export { vetraCommandFor as a, stopVetra as i, ensureVetra as n, restartVetra as r, VetraStartError as t };
234
+
235
+ //# sourceMappingURL=vetra-launch-T_uLKaR3.mjs.map
236
+ //# debugId=3159fb33-5304-5abc-b690-9d71c181c70d
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vetra-launch-T_uLKaR3.mjs","sources":["../src/utils/vetra-launch.ts"],"sourcesContent":["import { probeHostsFolder } from \"@powerhousedao/host-core\";\nimport { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { stripVTControlCharacters } from \"node:util\";\nimport { VETRA_HOST } from \"./vetra-instance.js\";\nimport {\n clearVetraRuntime,\n isPortInUse,\n probeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"./vetra-runtime.js\";\n\nexport type VetraCommand = {\n command: string;\n args: string[];\n /** How messages name it; `ph vetra` when left out. */\n label?: string;\n};\n\nexport type EnsureVetraOptions = {\n projectDir: string;\n projectName: string;\n /** The port a strict-port Vetra will bind. */\n switchboardPort: number;\n command: VetraCommand;\n timeoutMs: number;\n pollMs?: number;\n /** Told what it waits on while Vetra is not ready yet, about once a second. */\n onProgress?: (message: string) => void;\n};\n\nexport class VetraStartError extends Error {}\n\nconst LOG_TAIL_LINES = 60;\nconst PORT_GRACE_MS = 10_000;\nconst STOP_TIMEOUT_MS = 15_000;\nconst PROGRESS_EVERY_MS = 1000;\n\nconst lockPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-start.lock\");\n\nexport const vetraLogPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra.log\");\n\n// Forward slashes, so messages read the same on every platform.\nconst shownLogPath = (projectDir: string) =>\n path.relative(projectDir, vetraLogPath(projectDir)).split(path.sep).join(\"/\");\n\n/** `ph vetra --strictPort --watch` run by the ph-cli executing this code. */\nexport function currentPhCliVetraCommand(): VetraCommand {\n return {\n command: process.execPath,\n args: [process.argv[1], \"vetra\", \"--strictPort\", \"--watch\"],\n };\n}\n\n/** `ph run vetra --strictPort` run by the ph-cli executing this code. */\nexport function currentPhCliRunVetraCommand(): VetraCommand {\n return {\n command: process.execPath,\n args: [process.argv[1], \"run\", VETRA_HOST, \"--strictPort\"],\n label: `ph run ${VETRA_HOST}`,\n };\n}\n\n/**\n * What starts this project's Vetra: its `hosts/vetra` host when it has one,\n * as `ph vetra` itself routes there (run-sugar.ts), else classic `ph vetra`.\n * The host's own defaultVerb picks the verb; `--watch` is not a host argument.\n */\nexport function vetraCommandFor(projectDir: string): VetraCommand {\n const probe = probeHostsFolder(projectDir);\n return probe.kind === \"present\" && probe.hosts.includes(VETRA_HOST)\n ? currentPhCliRunVetraCommand()\n : currentPhCliVetraCommand();\n}\n\nfunction isPidAlive(pid: number | undefined): boolean {\n if (!pid) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\ntype LockRecord = { pid: number; vetraPid?: number };\n\nfunction readLock(projectDir: string): LockRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(lockPath(projectDir), \"utf8\"),\n ) as LockRecord;\n } catch {\n return undefined;\n }\n}\n\nfunction isLockHeld(lock: LockRecord | undefined): boolean {\n return !!lock && (isPidAlive(lock.pid) || isPidAlive(lock.vetraPid));\n}\n\n/** Held while the launcher or the Vetra it started is alive. */\nfunction tryAcquireLock(projectDir: string): boolean {\n const target = lockPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n for (let attempt = 0; attempt < 2; attempt++) {\n try {\n fs.writeFileSync(target, JSON.stringify({ pid: process.pid }), {\n flag: \"wx\",\n });\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (isLockHeld(readLock(projectDir))) return false;\n fs.rmSync(target, { force: true });\n }\n }\n return false;\n}\n\nfunction releaseLock(projectDir: string): void {\n if (readLock(projectDir)?.pid === process.pid) {\n fs.rmSync(lockPath(projectDir), { force: true });\n }\n}\n\nexport function readLogTail(projectDir: string): string {\n try {\n const text = fs.readFileSync(vetraLogPath(projectDir), \"utf8\");\n const lines = stripVTControlCharacters(text).trimEnd().split(\"\\n\");\n return lines.slice(-LOG_TAIL_LINES).join(\"\\n\");\n } catch {\n return \"\";\n }\n}\n\nfunction withOutput(message: string, projectDir: string): VetraStartError {\n const tail = readLogTail(projectDir);\n const where = shownLogPath(projectDir);\n return new VetraStartError(\n tail\n ? `${message}\\n\\nVetra output (last lines of ${where}):\\n${tail}`\n : message,\n );\n}\n\nfunction foreignError(record: VetraRuntimeRecord): VetraStartError {\n return new VetraStartError(\n `.ph/vetra-runtime.json describes a live Vetra for \"${record.projectName}\" (pid ${record.pid}), not this project. ` +\n `Refusing to start a second reactor. Delete .ph/vetra-runtime.json if that record is wrong.`,\n );\n}\n\nasync function waitForLive(\n options: EnsureVetraOptions,\n deadline: number,\n stillStarting: () => boolean,\n): Promise<VetraRuntimeRecord | undefined> {\n const { projectDir, projectName, pollMs = 250, onProgress } = options;\n const startedAt = Date.now();\n let reportedAt = startedAt;\n while (Date.now() < deadline) {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\") return probe.record;\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status !== \"starting\" && !stillStarting()) return undefined;\n if (onProgress && Date.now() - reportedAt >= PROGRESS_EVERY_MS) {\n reportedAt = Date.now();\n const seconds = Math.round((reportedAt - startedAt) / 1000);\n onProgress(`Waiting for Vetra to be ready (${seconds}s)...`);\n }\n await sleep(pollMs);\n }\n return undefined;\n}\n\n/** This project's live Vetra, or a detached `ph vetra` started and awaited; never a second reactor. */\nexport async function ensureVetra(\n options: EnsureVetraOptions,\n): Promise<VetraRuntimeRecord> {\n const { projectDir, projectName, switchboardPort, timeoutMs } = options;\n const deadline = Date.now() + timeoutMs;\n const seconds = Math.round(timeoutMs / 1000);\n const report = options.onProgress ?? (() => {});\n\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\") return probe.record;\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status === \"starting\") {\n report(`Vetra (pid ${probe.record.pid}) is starting; waiting for it...`);\n const record = await waitForLive(options, deadline, () => false);\n if (record) return record;\n throw withOutput(\n `Vetra (pid ${probe.record.pid}) is running but did not answer /ready within ${seconds}s.`,\n projectDir,\n );\n }\n\n while (!tryAcquireLock(projectDir)) {\n // Another launcher is starting Vetra for this project.\n report(\"Another process is starting Vetra for this project; waiting...\");\n const record = await waitForLive(options, deadline, () =>\n isLockHeld(readLock(projectDir)),\n );\n if (record) return record;\n if (Date.now() >= deadline) {\n throw withOutput(\n `Another process is starting Vetra for this project and it did not become ready within ${seconds}s.`,\n projectDir,\n );\n }\n }\n\n let keepLock = false;\n try {\n const again = await probeVetraRuntime(projectDir, projectName);\n if (again.status === \"live\") return again.record;\n if (again.status === \"foreign\") throw foreignError(again.record);\n\n if (again.status === \"starting\" || (await isPortInUse(switchboardPort))) {\n // Maybe a Vetra that bound the port but has not written its record yet.\n const grace = Date.now() + PORT_GRACE_MS;\n const record = await waitForLive(\n options,\n deadline,\n () => Date.now() < grace,\n );\n if (record) return record;\n throw new VetraStartError(\n `Port ${switchboardPort} is in use, but .ph/vetra-runtime.json names no live Vetra for this project. ` +\n `Stop whatever holds the port, or move this project's port (reactor.port in powerhouse.config.json).`,\n );\n }\n\n const logFile = vetraLogPath(projectDir);\n report(`Starting Vetra; its output goes to ${shownLogPath(projectDir)}...`);\n const logFd = fs.openSync(logFile, \"w\");\n let exit: { code: number | null; signal: string | null } | undefined;\n let spawnError: Error | undefined;\n const child = spawn(options.command.command, options.command.args, {\n cwd: projectDir,\n detached: true,\n stdio: [\"ignore\", logFd, logFd],\n windowsHide: true,\n });\n fs.closeSync(logFd);\n child.once(\"error\", (error) => (spawnError = error));\n child.once(\"exit\", (code, signal) => (exit = { code, signal }));\n child.unref();\n if (child.pid) {\n fs.writeFileSync(\n lockPath(projectDir),\n JSON.stringify({ pid: process.pid, vetraPid: child.pid }),\n );\n }\n\n const record = await waitForLive(\n options,\n deadline,\n () => !exit && !spawnError,\n );\n if (record) return record;\n\n if (spawnError) {\n throw new VetraStartError(\n `Could not run \\`${options.command.command}\\`: ${spawnError.message}`,\n );\n }\n if (exit) {\n const how =\n exit.signal !== null\n ? `was killed by ${exit.signal}`\n : `exited with code ${exit.code}`;\n throw withOutput(\n `\\`${options.command.label ?? \"ph vetra\"}\\` ${how} before it was ready.`,\n projectDir,\n );\n }\n // Still booting: keep the lock on its pid so the next call waits instead of spawning.\n keepLock = true;\n throw withOutput(\n `Vetra (pid ${child.pid}) did not answer /ready on port ${switchboardPort} within ${seconds}s. ` +\n `It is still running; the next tool call waits for it again.`,\n projectDir,\n );\n } finally {\n if (!keepLock) releaseLock(projectDir);\n }\n}\n\nasync function waitForExit(\n record: VetraRuntimeRecord,\n deadline: number,\n): Promise<boolean> {\n while (Date.now() < deadline) {\n const gone =\n !isPidAlive(record.pid) && !(await isPortInUse(record.switchboardPort));\n if (gone) return true;\n await sleep(100);\n }\n return false;\n}\n\n/** Stops this project's running Vetra, if any; resolves to the record it stopped. */\nexport async function stopVetra(options: {\n projectDir: string;\n projectName: string;\n timeoutMs?: number;\n onProgress?: (message: string) => void;\n}): Promise<VetraRuntimeRecord | undefined> {\n const { projectDir, projectName, timeoutMs = STOP_TIMEOUT_MS } = options;\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status !== \"live\" && probe.status !== \"starting\") return undefined;\n const { record } = probe;\n const signal = (name: NodeJS.Signals) => {\n try {\n process.kill(record.pid, name);\n } catch {\n // Already gone.\n }\n };\n options.onProgress?.(`Stopping Vetra (pid ${record.pid})...`);\n 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;;AAG9E,SAAgB,2BAAyC;CACvD,OAAO;EACL,SAAS,QAAQ;EACjB,MAAM;GAAC,QAAQ,KAAK;GAAI;GAAS;GAAgB;EAAS;CAC5D;AACF;;AAGA,SAAgB,8BAA4C;CAC1D,OAAO;EACL,SAAS,QAAQ;EACjB,MAAM;GAAC,QAAQ,KAAK;GAAI;GAAO;GAAY;EAAc;EACzD,OAAO,UAAU;CACnB;AACF;;;;;;AAOA,SAAgB,gBAAgB,YAAkC;CAChE,MAAM,QAAQ,iBAAiB,UAAU;CACzC,OAAO,MAAM,SAAS,aAAa,MAAM,MAAM,SAAA,OAAmB,IAC9D,4BAA4B,IAC5B,yBAAyB;AAC/B;AAEA,SAAS,WAAW,KAAkC;CACpD,IAAI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,QAAQ,aAAa,uBAAuB,OAAO,IAAI,KAAK;CAC5D,OAAO,SAAS;CAChB,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":"3159fb33-5304-5abc-b690-9d71c181c70d"}
@@ -0,0 +1,4 @@
1
+ import { n as printVetraSwitchboardUrls, r as vetraProcessorConfigOf, t as configureVetraRemoteDrive } from "./vetra-switchboard-tzdc14KA.mjs";
2
+ export { configureVetraRemoteDrive, printVetraSwitchboardUrls, vetraProcessorConfigOf };
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]="429f6399-2137-5f99-a944-02e51a778140")}catch(e){}}();
4
+ //# debugId=429f6399-2137-5f99-a944-02e51a778140