@powerhousedao/ph-cli 6.3.0-dev.9 → 6.4.0-next.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.
- package/README.md +1 -1
- package/dist/{build-DuNe06I0.mjs → build-C490lBnu.mjs} +90 -18
- package/dist/build-C490lBnu.mjs.map +1 -0
- package/dist/build-DblrRe4z.mjs +4 -0
- package/dist/{check-EzkmRLx6.mjs → check-D84ta1Dh.mjs} +4 -4
- package/dist/{check-EzkmRLx6.mjs.map → check-D84ta1Dh.mjs.map} +1 -1
- package/dist/{check-B8oqVMg7.mjs → check-DIK1LTss.mjs} +5 -5
- package/dist/{check-B8oqVMg7.mjs.map → check-DIK1LTss.mjs.map} +1 -1
- package/dist/{check-VOIkykDt.mjs → check-F3nwJiG-.mjs} +3 -3
- package/dist/{cli-connect-override-D22yFWlC.mjs → cli-connect-override-BMU4Qldg.mjs} +8 -8
- package/dist/cli-connect-override-BMU4Qldg.mjs.map +1 -0
- package/dist/cli.mjs +21 -31
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-DKi56SSx-CXQHhS6t.mjs → compound-BWLJ0KBw-8hKyrfjG.mjs} +659 -276
- package/dist/compound-BWLJ0KBw-8hKyrfjG.mjs.map +1 -0
- package/dist/{connect-build-Be8C4skj.mjs → connect-build-DW1fFVbU.mjs} +6 -6
- package/dist/{connect-build-Be8C4skj.mjs.map → connect-build-DW1fFVbU.mjs.map} +1 -1
- package/dist/{connect-config-CVU4xhti.mjs → connect-config-DVubBBLb.mjs} +4 -4
- package/dist/{connect-config-CVU4xhti.mjs.map → connect-config-DVubBBLb.mjs.map} +1 -1
- package/dist/{connect-preview-CdFvlANO.mjs → connect-preview-BvxXGo_W.mjs} +7 -6
- package/dist/connect-preview-BvxXGo_W.mjs.map +1 -0
- package/dist/{connect-studio-BnfhpIv8.mjs → connect-studio-CQC-LDSg.mjs} +16 -7
- package/dist/connect-studio-CQC-LDSg.mjs.map +1 -0
- package/dist/definitions-worker.mjs +1 -1
- package/dist/{dist-DXcB8fAF.mjs → dist-BFMRL5C0.mjs} +52 -105
- package/dist/dist-BFMRL5C0.mjs.map +1 -0
- package/dist/{explain-8OEXF2Dy.mjs → explain-YPD3n6t8.mjs} +67 -21
- package/dist/explain-YPD3n6t8.mjs.map +1 -0
- package/dist/{export-DqbcbFU5.mjs → export-DjQL6zkr.mjs} +5 -5
- package/dist/{export-DqbcbFU5.mjs.map → export-DjQL6zkr.mjs.map} +1 -1
- package/dist/{generate-all-0YOnlZM0.mjs → generate-all-BLot_H9Z.mjs} +4 -4
- package/dist/{generate-all-0YOnlZM0.mjs.map → generate-all-BLot_H9Z.mjs.map} +1 -1
- package/dist/{generate-desktop-shell-BovoRsR6.mjs → generate-desktop-shell-CTrfzM9P.mjs} +6 -16
- package/dist/generate-desktop-shell-CTrfzM9P.mjs.map +1 -0
- package/dist/{get-version-JkZQOcO1.mjs → get-version-CcYVboCW.mjs} +4 -4
- package/dist/{get-version-JkZQOcO1.mjs.map → get-version-CcYVboCW.mjs.map} +1 -1
- package/dist/{index-H3AYe65i.d.mts → index-D3H9pQ8u.d.mts} +58 -4
- package/dist/index-D3H9pQ8u.d.mts.map +1 -0
- package/dist/{init-Ltg4cJzm.mjs → init-IQ0VS0JK.mjs} +4 -4
- package/dist/{init-Ltg4cJzm.mjs.map → init-IQ0VS0JK.mjs.map} +1 -1
- package/dist/{inspect-zWJnBDMJ.mjs → inspect-Bxa9y7zM.mjs} +4 -4
- package/dist/{inspect-zWJnBDMJ.mjs.map → inspect-Bxa9y7zM.mjs.map} +1 -1
- package/dist/{mcp-vSCc5KHI.mjs → mcp-B3l1mtBq.mjs} +7 -7
- package/dist/mcp-B3l1mtBq.mjs.map +1 -0
- package/dist/{migrate-C27-tFFC.mjs → migrate-CzcBEypc.mjs} +6 -6
- package/dist/{migrate-C27-tFFC.mjs.map → migrate-CzcBEypc.mjs.map} +1 -1
- package/dist/{migrate-document-models-CKnqQnRh.mjs → migrate-document-models-D0HSo4WN.mjs} +4 -4
- package/dist/{migrate-document-models-CKnqQnRh.mjs.map → migrate-document-models-D0HSo4WN.mjs.map} +1 -1
- package/dist/{migrate-subgraphs-B2nTiJ-j.mjs → migrate-subgraphs-CfSMlcJD.mjs} +55 -15
- package/dist/migrate-subgraphs-CfSMlcJD.mjs.map +1 -0
- package/dist/migrate-subgraphs-Hc5w9Mpk.mjs +4 -0
- package/dist/{ph-cli-commands-DhoNXWGf.mjs → ph-cli-commands-CQXdWQ74.mjs} +52 -184
- package/dist/ph-cli-commands-CQXdWQ74.mjs.map +1 -0
- package/dist/ph-cli-commands-YE0ciOSX.mjs +4 -0
- package/dist/run-sugar-BfnRBv7h.mjs +4 -0
- package/dist/run-sugar-hGKprsKz.mjs +96 -0
- package/dist/run-sugar-hGKprsKz.mjs.map +1 -0
- package/dist/runners/connect.d.mts +2 -2
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +30 -18
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +3 -3
- package/dist/runners/switchboard.mjs +11 -11
- package/dist/runners/switchboard.mjs.map +1 -1
- package/dist/scripts/generate-commands-docs.ts +3 -7
- package/dist/service-args-D6y3L0bm.mjs +49 -0
- package/dist/service-args-D6y3L0bm.mjs.map +1 -0
- package/dist/sugar-checks-CTCsK5DJ.mjs +175 -0
- package/dist/sugar-checks-CTCsK5DJ.mjs.map +1 -0
- package/dist/{switchboard-reset-MtTB_GAI.mjs → switchboard-reset-BP7KwUc_.mjs} +5 -5
- package/dist/switchboard-reset-BP7KwUc_.mjs.map +1 -0
- package/dist/utils-BU25LHRE.mjs +4 -0
- package/dist/{utils-9KyRM0mf.mjs → utils-D5VlY5AZ.mjs} +4 -15
- package/dist/utils-D5VlY5AZ.mjs.map +1 -0
- package/dist/{verify-DCf_nRt8.mjs → verify-NK6a_7j8.mjs} +4 -4
- package/dist/{verify-DCf_nRt8.mjs.map → verify-NK6a_7j8.mjs.map} +1 -1
- package/dist/vetra-gateway-Bpe50oGk.mjs +4 -0
- package/dist/vetra-gateway-BxcduYAI.mjs +173 -0
- package/dist/vetra-gateway-BxcduYAI.mjs.map +1 -0
- package/dist/{vetra-host-ChTpJiBJ.mjs → vetra-host-BrLdIMRP.mjs} +24 -9
- package/dist/vetra-host-BrLdIMRP.mjs.map +1 -0
- package/dist/{vetra-instance-CzhYIjxL.mjs → vetra-instance-CPNIsaxh.mjs} +9 -17
- package/dist/vetra-instance-CPNIsaxh.mjs.map +1 -0
- package/dist/vetra-launcher-BtDWQBuh.mjs +4 -0
- package/dist/{vetra-launch-qi10Unax.mjs → vetra-launcher-Dokr1aDK.mjs} +14 -32
- package/dist/vetra-launcher-Dokr1aDK.mjs.map +1 -0
- package/dist/{vetra-switchboard-tzdc14KA.mjs → vetra-switchboard-Ctje6iR1.mjs} +4 -4
- package/dist/{vetra-switchboard-tzdc14KA.mjs.map → vetra-switchboard-Ctje6iR1.mjs.map} +1 -1
- package/package.json +16 -16
- package/dist/build-CnTFRBft.mjs +0 -4
- package/dist/build-DuNe06I0.mjs.map +0 -1
- package/dist/classic-args-mH_DVsgC.mjs +0 -48
- package/dist/classic-args-mH_DVsgC.mjs.map +0 -1
- package/dist/classic-warnings-BR0S6lr5.mjs +0 -179
- package/dist/classic-warnings-BR0S6lr5.mjs.map +0 -1
- package/dist/cli-connect-override-D22yFWlC.mjs.map +0 -1
- package/dist/compound-DKi56SSx-CXQHhS6t.mjs.map +0 -1
- package/dist/connect-preview-CdFvlANO.mjs.map +0 -1
- package/dist/connect-studio-BnfhpIv8.mjs.map +0 -1
- package/dist/connect-studio-D58ByAAn.mjs +0 -4
- package/dist/dist-DXcB8fAF.mjs.map +0 -1
- package/dist/explain-8OEXF2Dy.mjs.map +0 -1
- package/dist/generate-desktop-shell-BovoRsR6.mjs.map +0 -1
- package/dist/index-H3AYe65i.d.mts.map +0 -1
- package/dist/mcp-vSCc5KHI.mjs.map +0 -1
- package/dist/migrate-subgraphs-B1_NRwV7.mjs +0 -4
- package/dist/migrate-subgraphs-B2nTiJ-j.mjs.map +0 -1
- package/dist/ph-cli-commands-DhoNXWGf.mjs.map +0 -1
- package/dist/ph-cli-commands-LIME9alJ.mjs +0 -4
- package/dist/run-sugar-DpznOP1e.mjs +0 -56
- package/dist/run-sugar-DpznOP1e.mjs.map +0 -1
- package/dist/scripts/manage-environment +0 -199
- package/dist/scripts/setup-environment +0 -423
- package/dist/scripts/setup-environment.ps1 +0 -313
- package/dist/switchboard-reset-MtTB_GAI.mjs.map +0 -1
- package/dist/utils-9KyRM0mf.mjs.map +0 -1
- package/dist/utils-TO9lB8Xs.mjs +0 -4
- package/dist/vetra-CVNZ46pK.mjs +0 -352
- package/dist/vetra-CVNZ46pK.mjs.map +0 -1
- package/dist/vetra-host-ChTpJiBJ.mjs.map +0 -1
- package/dist/vetra-instance-CzhYIjxL.mjs.map +0 -1
- package/dist/vetra-launch-qi10Unax.mjs.map +0 -1
- package/dist/vetra-switchboard-BrkozIm7.mjs +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { c as vetraGateway } from "./vetra-gateway-BxcduYAI.mjs";
|
|
2
|
+
export { vetraGateway };
|
|
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]="f913a474-09a0-5aab-b591-da9ce2601fed")}catch(e){}}();
|
|
4
|
+
//# debugId=f913a474-09a0-5aab-b591-da9ce2601fed
|
|
@@ -0,0 +1,173 @@
|
|
|
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]="46e3ee35-2128-5e5e-a250-776548e23331")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-CcYVboCW.mjs";
|
|
4
|
+
import { Q as resolvePackageRoot } from "./compound-BWLJ0KBw-8hKyrfjG.mjs";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { CALLER_CWD_ENV } from "@powerhousedao/shared/clis/command-names";
|
|
9
|
+
import { yellow } from "colorette";
|
|
10
|
+
import { resolveCommand } from "package-manager-detector";
|
|
11
|
+
import { valid } from "semver";
|
|
12
|
+
//#region src/services/vetra-gateway.ts
|
|
13
|
+
/**
|
|
14
|
+
* `ph vetra` is the gateway to Vetra Studio, the host `studio` that the
|
|
15
|
+
* package @powerhousedao/vetra-cli supplies. ph-cli names the package and the
|
|
16
|
+
* host and nothing else of it: `ph vetra [verb] [args]` is
|
|
17
|
+
* `ph run @powerhousedao/vetra-cli/studio [verb] [args]`, once the project
|
|
18
|
+
* has the package. A project without it gets it first, as a devDependency at
|
|
19
|
+
* this ph-cli's version: the two are released with the same version numbers.
|
|
20
|
+
*/
|
|
21
|
+
const VETRA_STUDIO_PACKAGE = "@powerhousedao/vetra-cli";
|
|
22
|
+
const VETRA_STUDIO_HOST = `${VETRA_STUDIO_PACKAGE}/studio`;
|
|
23
|
+
/** Set on the ph-cli started after an install: it finds the package, or
|
|
24
|
+
* fails, and never installs it again. */
|
|
25
|
+
const VETRA_GATEWAY_ENV = "PH_VETRA_GATEWAY_INSTALLED";
|
|
26
|
+
/** The command line that adds the package at ph-cli's version as a
|
|
27
|
+
* devDependency, with the project's package manager. */
|
|
28
|
+
function studioInstallCommand(agent, phCliVersion) {
|
|
29
|
+
const version = valid(phCliVersion) ?? "latest";
|
|
30
|
+
const releaseAge = agent.startsWith("pnpm") ? ["--config.minimum-release-age=0"] : [];
|
|
31
|
+
const resolved = resolveCommand(agent, "add", [
|
|
32
|
+
"-D",
|
|
33
|
+
`${VETRA_STUDIO_PACKAGE}@${version}`,
|
|
34
|
+
...releaseAge
|
|
35
|
+
]);
|
|
36
|
+
if (!resolved) throw new Error(`Could not resolve an install command for package manager "${agent}".`);
|
|
37
|
+
return [resolved.command, ...resolved.args].join(" ");
|
|
38
|
+
}
|
|
39
|
+
/** What `ph vetra` does in a project: install the package, or run its host,
|
|
40
|
+
* warning when the installed version is not ph-cli's. */
|
|
41
|
+
function planVetraGateway(facts) {
|
|
42
|
+
const { installed, phCliVersion, packageManager } = facts;
|
|
43
|
+
const command = studioInstallCommand(packageManager, phCliVersion);
|
|
44
|
+
if (installed === void 0) return {
|
|
45
|
+
action: "install",
|
|
46
|
+
notice: `Vetra Studio is the package ${VETRA_STUDIO_PACKAGE}, which this project does not have yet. Installing it as a devDependency with ${packageManager}:`,
|
|
47
|
+
command
|
|
48
|
+
};
|
|
49
|
+
const { version } = installed;
|
|
50
|
+
if (version !== void 0 && valid(phCliVersion) !== null && version !== phCliVersion) return {
|
|
51
|
+
action: "run",
|
|
52
|
+
warning: `${VETRA_STUDIO_PACKAGE} ${version} is installed, but this ph-cli is ${phCliVersion}: align them with \`${command}\`.`
|
|
53
|
+
};
|
|
54
|
+
return { action: "run" };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* `ph vetra [verb] [args]` (`rest`) in the project: the `ph run` command line
|
|
58
|
+
* of the studio host when the package is there. Otherwise it installs the
|
|
59
|
+
* package and runs that command line in a new ph-cli, since a package
|
|
60
|
+
* installed while this one runs is not reliably resolved by it (Node caches
|
|
61
|
+
* lookups, and the install may relink what it imports later).
|
|
62
|
+
*/
|
|
63
|
+
async function openVetraStudio(rest, deps) {
|
|
64
|
+
const { projectPath, packageManager } = await deps.project();
|
|
65
|
+
if (projectPath === void 0) throw new Error("No Powerhouse project found, so `ph vetra` cannot open Vetra Studio: it installs into and runs in a project. Run it in one, or create one with `ph init`.");
|
|
66
|
+
const runArgs = [
|
|
67
|
+
"run",
|
|
68
|
+
VETRA_STUDIO_HOST,
|
|
69
|
+
...rest
|
|
70
|
+
];
|
|
71
|
+
const plan = planVetraGateway({
|
|
72
|
+
installed: deps.installedStudio(projectPath),
|
|
73
|
+
phCliVersion: deps.phCliVersion,
|
|
74
|
+
packageManager
|
|
75
|
+
});
|
|
76
|
+
if (plan.action === "run") {
|
|
77
|
+
if (plan.warning) deps.warn(plan.warning);
|
|
78
|
+
return {
|
|
79
|
+
args: runArgs,
|
|
80
|
+
projectRoot: projectPath
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (rest.includes("--stop")) return {
|
|
84
|
+
args: runArgs,
|
|
85
|
+
projectRoot: projectPath
|
|
86
|
+
};
|
|
87
|
+
const manual = `Install it yourself, then run \`ph vetra\` again:\n ${plan.command}`;
|
|
88
|
+
if (deps.env["PH_VETRA_GATEWAY_INSTALLED"]) throw new Error(`${VETRA_STUDIO_PACKAGE} was installed, but this ph-cli does not find it from ${projectPath}. ${manual}`);
|
|
89
|
+
deps.log(plan.notice);
|
|
90
|
+
deps.log(`> ${plan.command}`);
|
|
91
|
+
const code = await deps.install(plan.command, projectPath);
|
|
92
|
+
if (code !== 0) {
|
|
93
|
+
const how = code === null ? "could not run" : `exited with code ${code}`;
|
|
94
|
+
throw new Error(`The install of ${VETRA_STUDIO_PACKAGE} ${how}, so Vetra Studio cannot start. ${manual}`);
|
|
95
|
+
}
|
|
96
|
+
if (deps.installedStudio(projectPath) === void 0) throw new Error(`The install passed, but ${VETRA_STUDIO_PACKAGE} does not resolve from ${projectPath}. ${manual}`);
|
|
97
|
+
return { exitCode: await deps.reexec(runArgs, projectPath) };
|
|
98
|
+
}
|
|
99
|
+
/** The package's version as `ph run <package>/<host>` finds it: from the
|
|
100
|
+
* project root, by its package.json, without importing it. */
|
|
101
|
+
function installedStudio(projectRoot) {
|
|
102
|
+
const root = resolvePackageRoot(projectRoot, VETRA_STUDIO_PACKAGE);
|
|
103
|
+
if (root === void 0) return void 0;
|
|
104
|
+
try {
|
|
105
|
+
const { version } = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
|
|
106
|
+
return { version: typeof version === "string" ? version : void 0 };
|
|
107
|
+
} catch {
|
|
108
|
+
return { version: void 0 };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function runInstall(command, cwd) {
|
|
112
|
+
return new Promise((resolve) => {
|
|
113
|
+
const child = spawn(command, {
|
|
114
|
+
cwd,
|
|
115
|
+
stdio: "inherit",
|
|
116
|
+
shell: true,
|
|
117
|
+
windowsHide: true
|
|
118
|
+
});
|
|
119
|
+
child.once("error", () => resolve(null));
|
|
120
|
+
child.once("close", (code) => resolve(code));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function reexecPhCli(args, cwd) {
|
|
124
|
+
const child = spawn(process.execPath, [process.argv[1], ...args], {
|
|
125
|
+
cwd,
|
|
126
|
+
stdio: "inherit",
|
|
127
|
+
env: {
|
|
128
|
+
...process.env,
|
|
129
|
+
[VETRA_GATEWAY_ENV]: "1"
|
|
130
|
+
},
|
|
131
|
+
windowsHide: true
|
|
132
|
+
});
|
|
133
|
+
const ignore = () => {};
|
|
134
|
+
const forward = (signal) => child.kill(signal);
|
|
135
|
+
process.on("SIGINT", ignore);
|
|
136
|
+
process.on("SIGTERM", forward);
|
|
137
|
+
return new Promise((resolve) => {
|
|
138
|
+
const done = (code) => {
|
|
139
|
+
process.off("SIGINT", ignore);
|
|
140
|
+
process.off("SIGTERM", forward);
|
|
141
|
+
resolve(code);
|
|
142
|
+
};
|
|
143
|
+
child.once("error", () => done(1));
|
|
144
|
+
child.once("exit", (code) => done(code ?? 1));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** cli.ts's `ph vetra`: the command line to go on with, in the project root,
|
|
148
|
+
* or the exit code of the ph-cli that ran it. */
|
|
149
|
+
async function vetraGateway(rest) {
|
|
150
|
+
const result = await openVetraStudio(rest, {
|
|
151
|
+
project: async () => {
|
|
152
|
+
const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
|
|
153
|
+
return getPowerhouseProjectInfo(void 0, { silent: true });
|
|
154
|
+
},
|
|
155
|
+
phCliVersion: getVersion(),
|
|
156
|
+
installedStudio,
|
|
157
|
+
install: runInstall,
|
|
158
|
+
reexec: reexecPhCli,
|
|
159
|
+
env: process.env,
|
|
160
|
+
log: (message) => console.log(message),
|
|
161
|
+
warn: (message) => console.warn(yellow(message))
|
|
162
|
+
});
|
|
163
|
+
if ("args" in result && path.resolve(result.projectRoot) !== process.cwd()) {
|
|
164
|
+
process.env[CALLER_CWD_ENV] ??= process.cwd();
|
|
165
|
+
process.chdir(result.projectRoot);
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { openVetraStudio as a, vetraGateway as c, installedStudio as i, VETRA_STUDIO_HOST as n, planVetraGateway as o, VETRA_STUDIO_PACKAGE as r, studioInstallCommand as s, VETRA_GATEWAY_ENV as t };
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=vetra-gateway-BxcduYAI.mjs.map
|
|
173
|
+
//# debugId=46e3ee35-2128-5e5e-a250-776548e23331
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vetra-gateway-BxcduYAI.mjs","sources":["../src/services/vetra-gateway.ts"],"sourcesContent":["import { resolvePackageRoot } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport { yellow } from \"colorette\";\nimport { spawn } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { resolveCommand, type Agent } from \"package-manager-detector\";\nimport { valid } from \"semver\";\nimport { getVersion } from \"../get-version.js\";\n\n/**\n * `ph vetra` is the gateway to Vetra Studio, the host `studio` that the\n * package @powerhousedao/vetra-cli supplies. ph-cli names the package and the\n * host and nothing else of it: `ph vetra [verb] [args]` is\n * `ph run @powerhousedao/vetra-cli/studio [verb] [args]`, once the project\n * has the package. A project without it gets it first, as a devDependency at\n * this ph-cli's version: the two are released with the same version numbers.\n */\nexport const VETRA_STUDIO_PACKAGE = \"@powerhousedao/vetra-cli\";\nexport const VETRA_STUDIO_HOST = `${VETRA_STUDIO_PACKAGE}/studio`;\n\n/** Set on the ph-cli started after an install: it finds the package, or\n * fails, and never installs it again. */\nexport const VETRA_GATEWAY_ENV = \"PH_VETRA_GATEWAY_INSTALLED\";\n\n/** The package as the project has it; undefined when it has none. */\nexport type InstalledStudio = { version: string | undefined } | undefined;\n\nexport type VetraGatewayPlan =\n | { action: \"run\"; warning?: string }\n | { action: \"install\"; notice: string; command: string };\n\n/** The command line that adds the package at ph-cli's version as a\n * devDependency, with the project's package manager. */\nexport function studioInstallCommand(\n agent: Agent,\n phCliVersion: string,\n): string {\n // A build that does not know its version takes the latest release.\n const version = valid(phCliVersion) ?? \"latest\";\n // As `ph install --local`: on a release day the packages are younger than\n // pnpm 11's minimumReleaseAge.\n const releaseAge = agent.startsWith(\"pnpm\")\n ? [\"--config.minimum-release-age=0\"]\n : [];\n const resolved = resolveCommand(agent, \"add\", [\n \"-D\",\n `${VETRA_STUDIO_PACKAGE}@${version}`,\n ...releaseAge,\n ]);\n if (!resolved) {\n throw new Error(\n `Could not resolve an install command for package manager \"${agent}\".`,\n );\n }\n return [resolved.command, ...resolved.args].join(\" \");\n}\n\n/** What `ph vetra` does in a project: install the package, or run its host,\n * warning when the installed version is not ph-cli's. */\nexport function planVetraGateway(facts: {\n installed: InstalledStudio;\n phCliVersion: string;\n packageManager: Agent;\n}): VetraGatewayPlan {\n const { installed, phCliVersion, packageManager } = facts;\n const command = studioInstallCommand(packageManager, phCliVersion);\n if (installed === undefined) {\n return {\n action: \"install\",\n notice:\n `Vetra Studio is the package ${VETRA_STUDIO_PACKAGE}, which this project does not have yet. ` +\n `Installing it as a devDependency with ${packageManager}:`,\n command,\n };\n }\n const { version } = installed;\n if (\n version !== undefined &&\n valid(phCliVersion) !== null &&\n version !== phCliVersion\n ) {\n return {\n action: \"run\",\n warning: `${VETRA_STUDIO_PACKAGE} ${version} is installed, but this ph-cli is ${phCliVersion}: align them with \\`${command}\\`.`,\n };\n }\n return { action: \"run\" };\n}\n\nexport interface VetraGatewayDeps {\n /** The project root, undefined outside a project, and its package manager. */\n project: () => Promise<{ projectPath?: string; packageManager: Agent }>;\n phCliVersion: string;\n installedStudio: (projectRoot: string) => InstalledStudio;\n /** Runs an install command line in `cwd`; resolves to its exit code. */\n install: (command: string, cwd: string) => Promise<number | null>;\n /** Runs this ph-cli with `args` in a new process; resolves to its exit code. */\n reexec: (args: string[], cwd: string) => Promise<number>;\n env: NodeJS.ProcessEnv;\n log: (message: string) => void;\n warn: (message: string) => void;\n}\n\nexport type VetraGatewayResult =\n /** Go on with this command line, in the project root. */\n | { args: string[]; projectRoot: string }\n /** A new ph-cli ran it, after the install. */\n | { exitCode: number };\n\n/**\n * `ph vetra [verb] [args]` (`rest`) in the project: the `ph run` command line\n * of the studio host when the package is there. Otherwise it installs the\n * package and runs that command line in a new ph-cli, since a package\n * installed while this one runs is not reliably resolved by it (Node caches\n * lookups, and the install may relink what it imports later).\n */\nexport async function openVetraStudio(\n rest: readonly string[],\n deps: VetraGatewayDeps,\n): Promise<VetraGatewayResult> {\n const { projectPath, packageManager } = await deps.project();\n if (projectPath === undefined) {\n throw new Error(\n \"No Powerhouse project found, so `ph vetra` cannot open Vetra Studio: it installs into and runs in a project. \" +\n \"Run it in one, or create one with `ph init`.\",\n );\n }\n const runArgs = [\"run\", VETRA_STUDIO_HOST, ...rest];\n const plan = planVetraGateway({\n installed: deps.installedStudio(projectPath),\n phCliVersion: deps.phCliVersion,\n packageManager,\n });\n if (plan.action === \"run\") {\n if (plan.warning) deps.warn(plan.warning);\n return { args: runArgs, projectRoot: projectPath };\n }\n // A stop reads the run record only: there is nothing to install for it.\n if (rest.includes(\"--stop\"))\n return { args: runArgs, projectRoot: projectPath };\n const manual = `Install it yourself, then run \\`ph vetra\\` again:\\n ${plan.command}`;\n if (deps.env[VETRA_GATEWAY_ENV]) {\n throw new Error(\n `${VETRA_STUDIO_PACKAGE} was installed, but this ph-cli does not find it from ${projectPath}. ${manual}`,\n );\n }\n deps.log(plan.notice);\n deps.log(`> ${plan.command}`);\n const code = await deps.install(plan.command, projectPath);\n if (code !== 0) {\n const how = code === null ? \"could not run\" : `exited with code ${code}`;\n throw new Error(\n `The install of ${VETRA_STUDIO_PACKAGE} ${how}, so Vetra Studio cannot start. ${manual}`,\n );\n }\n if (deps.installedStudio(projectPath) === undefined) {\n throw new Error(\n `The install passed, but ${VETRA_STUDIO_PACKAGE} does not resolve from ${projectPath}. ${manual}`,\n );\n }\n return { exitCode: await deps.reexec(runArgs, projectPath) };\n}\n\n/** The package's version as `ph run <package>/<host>` finds it: from the\n * project root, by its package.json, without importing it. */\nexport function installedStudio(projectRoot: string): InstalledStudio {\n const root = resolvePackageRoot(projectRoot, VETRA_STUDIO_PACKAGE);\n if (root === undefined) return undefined;\n try {\n const { version } = JSON.parse(\n readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as { version?: unknown };\n return { version: typeof version === \"string\" ? version : undefined };\n } catch {\n return { version: undefined };\n }\n}\n\nfunction runInstall(command: string, cwd: string): Promise<number | null> {\n return new Promise((resolve) => {\n // One command line, as printed: a shell runs the package manager's shim.\n const child = spawn(command, {\n cwd,\n stdio: \"inherit\",\n shell: true,\n windowsHide: true,\n });\n child.once(\"error\", () => resolve(null));\n child.once(\"close\", (code) => resolve(code));\n });\n}\n\nfunction reexecPhCli(args: string[], cwd: string): Promise<number> {\n const child = spawn(process.execPath, [process.argv[1], ...args], {\n cwd,\n stdio: \"inherit\",\n env: { ...process.env, [VETRA_GATEWAY_ENV]: \"1\" },\n windowsHide: true,\n });\n // Ctrl-C reaches the child from the terminal as well: wait while it stops.\n const ignore = () => {};\n const forward = (signal: NodeJS.Signals) => child.kill(signal);\n process.on(\"SIGINT\", ignore);\n process.on(\"SIGTERM\", forward);\n return new Promise<number>((resolve) => {\n const done = (code: number) => {\n process.off(\"SIGINT\", ignore);\n process.off(\"SIGTERM\", forward);\n resolve(code);\n };\n child.once(\"error\", () => done(1));\n child.once(\"exit\", (code) => done(code ?? 1));\n });\n}\n\n/** cli.ts's `ph vetra`: the command line to go on with, in the project root,\n * or the exit code of the ph-cli that ran it. */\nexport async function vetraGateway(\n rest: readonly string[],\n): Promise<{ args: string[] } | { exitCode: number }> {\n const result = await openVetraStudio(rest, {\n project: async () => {\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n return getPowerhouseProjectInfo(undefined, { silent: true });\n },\n phCliVersion: getVersion(),\n installedStudio,\n install: runInstall,\n reexec: reexecPhCli,\n env: process.env,\n log: (message) => console.log(message),\n warn: (message) => console.warn(yellow(message)),\n });\n if (\"args\" in result && path.resolve(result.projectRoot) !== process.cwd()) {\n // As ph-cmd runs ph-cli: in the project root, with relative paths still\n // meaning the caller's cwd.\n process.env[CALLER_CWD_ENV] ??= process.cwd();\n process.chdir(result.projectRoot);\n }\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,uBAAuB;AACpC,MAAa,oBAAoB,GAAG,qBAAqB;;;AAIzD,MAAa,oBAAoB;;;AAWjC,SAAgB,qBACd,OACA,cACQ;CAER,MAAM,UAAU,MAAM,YAAY,KAAK;CAGvC,MAAM,aAAa,MAAM,WAAW,MAAM,IACtC,CAAC,gCAAgC,IACjC,CAAC;CACL,MAAM,WAAW,eAAe,OAAO,OAAO;EAC5C;EACA,GAAG,qBAAqB,GAAG;EAC3B,GAAG;CACL,CAAC;CACD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6DAA6D,MAAM,GACrE;CAEF,OAAO,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,GAAG;AACtD;;;AAIA,SAAgB,iBAAiB,OAIZ;CACnB,MAAM,EAAE,WAAW,cAAc,mBAAmB;CACpD,MAAM,UAAU,qBAAqB,gBAAgB,YAAY;CACjE,IAAI,cAAc,KAA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AAC;EACjC,MAAM,KAAK,SAAS,SAAS,KAAK,QAAQ,CAAC,CAAC;CAC9C,CAAC;AACH;;;AAIA,eAAsB,aACpB,MACoD;CACpD,MAAM,SAAS,MAAM,gBAAgB,MAAM;EACzC,SAAS,YAAY;GACnB,MAAM,EAAE,6BACN,MAAM,OAAO;GACf,OAAO,yBAAyB,KAAA,GAAW,EAAE,QAAQ,KAAK,CAAC;EAC7D;EACA,cAAc,WAAW;EACzB;EACA,SAAS;EACT,QAAQ;EACR,KAAK,QAAQ;EACb,MAAM,YAAY,QAAQ,IAAI,OAAO;EACrC,OAAO,YAAY,QAAQ,KAAK,OAAO,OAAO,CAAC;CACjD,CAAC;CACD,IAAI,UAAU,UAAU,KAAK,QAAQ,OAAO,WAAW,MAAM,QAAQ,IAAI,GAAG;EAG1E,QAAQ,IAAI,oBAAoB,QAAQ,IAAI;EAC5C,QAAQ,MAAM,OAAO,WAAW;CAClC;CACA,OAAO;AACT","debug_id":"46e3ee35-2128-5e5e-a250-776548e23331"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
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]="9b004534-e9d0-589a-8a74-a3c6fcc69596")}catch(e){}}();
|
|
3
3
|
import { _ as unknown, d as object, r as array } from "./schemas-DzgKfQIx.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { c as
|
|
4
|
+
import { J as readProjectName, a as STORE_VERBS, r as ONE_SHOT_VERBS } from "./compound-BWLJ0KBw-8hKyrfjG.mjs";
|
|
5
|
+
import { c as vetraRuntimeRecord, l as writeVetraRuntime, n as vetraRuntimeRefusal, r as clearVetraRuntime, s as syncMcpPortNotices } from "./vetra-instance-CPNIsaxh.mjs";
|
|
6
6
|
import { yellow } from "colorette";
|
|
7
7
|
import { outputsSchema } from "@powerhousedao/ph-run/runners/connect";
|
|
8
8
|
import { outputsSchema as outputsSchema$1 } from "@powerhousedao/ph-run/runners/switchboard";
|
|
@@ -11,22 +11,37 @@ import { startRun } from "@powerhousedao/ph-run/start-run";
|
|
|
11
11
|
/**
|
|
12
12
|
* `ph run vetra`: the vetra host is the generic compound runner over a
|
|
13
13
|
* switchboard and a connect member, so nothing below `ph run` knows it is
|
|
14
|
-
* Vetra. What
|
|
15
|
-
* startRun
|
|
14
|
+
* Vetra. What makes the stack the project's Vetra is done here around
|
|
15
|
+
* startRun: refuse while another Vetra holds
|
|
16
16
|
* the project, publish `.ph/vetra-runtime.json` once the stack is ready,
|
|
17
|
-
* clear it on exit, and correct a drifted `.mcp.json`.
|
|
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.
|
|
18
19
|
*/
|
|
19
20
|
async function runVetraHost(args) {
|
|
20
21
|
const verb = args.verb ?? "run";
|
|
21
22
|
if (ONE_SHOT_VERBS.has(verb) || STORE_VERBS.has(verb)) return startRun(args);
|
|
22
23
|
const projectDir = args.projectRoot ?? process.cwd();
|
|
23
24
|
const projectName = readProjectName(projectDir);
|
|
25
|
+
const restart = args.argv?.includes(RESTART_FLAG) ?? false;
|
|
26
|
+
if (restart) {
|
|
27
|
+
const { stopVetra } = await import("./vetra-launcher-BtDWQBuh.mjs");
|
|
28
|
+
await stopVetra({
|
|
29
|
+
projectDir,
|
|
30
|
+
projectName,
|
|
31
|
+
onProgress: (message) => console.log(message)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
24
34
|
const refusal = await vetraRuntimeRefusal(projectDir, projectName);
|
|
25
35
|
if (refusal) throw new Error(refusal);
|
|
26
|
-
const result = await startRun(
|
|
36
|
+
const result = await startRun(restart ? {
|
|
37
|
+
...args,
|
|
38
|
+
argv: args.argv?.filter((arg) => arg !== RESTART_FLAG)
|
|
39
|
+
} : args);
|
|
27
40
|
publishVetraRuntime(projectDir, projectName, result);
|
|
28
41
|
return result;
|
|
29
42
|
}
|
|
43
|
+
/** `ph run vetra --restart`, which `ph dev --restart` is sugar for. */
|
|
44
|
+
const RESTART_FLAG = "--restart";
|
|
30
45
|
const startedSchema = object({ started: array(object({ outputs: unknown() })) });
|
|
31
46
|
const portOf = (url) => Number(new URL(url).port);
|
|
32
47
|
function firstMatch(schema, candidates) {
|
|
@@ -75,5 +90,5 @@ function publishVetraRuntime(projectDir, projectName, result) {
|
|
|
75
90
|
//#endregion
|
|
76
91
|
export { runVetraHost };
|
|
77
92
|
|
|
78
|
-
//# sourceMappingURL=vetra-host-
|
|
79
|
-
//# debugId=
|
|
93
|
+
//# sourceMappingURL=vetra-host-BrLdIMRP.mjs.map
|
|
94
|
+
//# debugId=9b004534-e9d0-589a-8a74-a3c6fcc69596
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vetra-host-BrLdIMRP.mjs","sources":["../src/services/run/vetra-host.ts"],"sourcesContent":["import {\n ONE_SHOT_VERBS,\n readProjectName,\n STORE_VERBS,\n} from \"@powerhousedao/host-core\";\nimport { outputsSchema as connectOutputsSchema } from \"@powerhousedao/ph-run/runners/connect\";\nimport { outputsSchema as switchboardOutputsSchema } from \"@powerhousedao/ph-run/runners/switchboard\";\nimport { startRun, type StartRunArgs } from \"@powerhousedao/ph-run/start-run\";\nimport { yellow } from \"colorette\";\nimport { z } from \"zod\";\nimport { vetraRuntimeRefusal } from \"../../utils/vetra-instance.js\";\nimport {\n clearVetraRuntime,\n syncMcpPortNotices,\n vetraRuntimeRecord,\n writeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"../../utils/vetra-runtime.js\";\n\n/**\n * `ph run vetra`: the vetra host is the generic compound runner over a\n * switchboard and a connect member, so nothing below `ph run` knows it is\n * Vetra. What makes the stack the project's Vetra is done here around\n * startRun: refuse while another Vetra holds\n * the project, publish `.ph/vetra-runtime.json` once the stack is ready,\n * clear it on exit, and correct a drifted `.mcp.json`. `--restart` is its own\n * argument, not a runner's: it stops the recorded Vetra first.\n */\nexport async function runVetraHost(args: StartRunArgs): Promise<unknown> {\n const verb = args.verb ?? \"run\";\n // `build` starts nothing; a store verb is refused for a compound.\n if (ONE_SHOT_VERBS.has(verb) || STORE_VERBS.has(verb)) {\n return startRun(args);\n }\n const projectDir = args.projectRoot ?? process.cwd();\n const projectName = readProjectName(projectDir);\n const restart = args.argv?.includes(RESTART_FLAG) ?? false;\n if (restart) {\n const { stopVetra } = await import(\"../../utils/vetra-launcher.js\");\n await stopVetra({\n projectDir,\n projectName,\n onProgress: (message) => console.log(message),\n });\n }\n const refusal = await vetraRuntimeRefusal(projectDir, projectName);\n if (refusal) throw new Error(refusal);\n\n const result = await startRun(\n restart\n ? { ...args, argv: args.argv?.filter((arg) => arg !== RESTART_FLAG) }\n : args,\n );\n publishVetraRuntime(projectDir, projectName, result);\n return result;\n}\n\n/** `ph run vetra --restart`, which `ph dev --restart` is sugar for. */\nconst RESTART_FLAG = \"--restart\";\n\nconst startedSchema = z.object({\n started: z.array(z.object({ outputs: z.unknown() })),\n});\n\nconst portOf = (url: string) => Number(new URL(url).port);\n\nfunction firstMatch<T>(\n schema: z.ZodType<T>,\n candidates: unknown[],\n): T | undefined {\n for (const candidate of candidates) {\n const match = schema.safeParse(candidate);\n if (match.success) return match.data;\n }\n return undefined;\n}\n\n/**\n * The record of a ready compound: its members are told apart by the outputs\n * their runners publish, since a host file is free to name them.\n */\nexport function vetraRecordOfRun(\n projectName: string,\n result: unknown,\n): VetraRuntimeRecord | undefined {\n const parsed = startedSchema.safeParse(result);\n const outputs = parsed.success\n ? parsed.data.started.map((member) => member.outputs)\n : [];\n const switchboard = firstMatch(switchboardOutputsSchema, outputs);\n if (!switchboard) return undefined;\n const connect = firstMatch(connectOutputsSchema, outputs);\n return vetraRuntimeRecord({\n projectName,\n switchboardPort: portOf(switchboard.origin),\n // Vite may have taken another port, and the base path is Connect's.\n connectPort: connect ? portOf(connect.origin) : 0,\n switchboardUrl: switchboard.endpoints.graphql,\n mcpUrl: switchboard.endpoints.mcp,\n connectUrl: connect?.endpoints.connect,\n });\n}\n\n/**\n * Publishes the record of the stack startRun returned and syncs the MCP\n * configs to its port. Returns what clears the record again; it also runs on\n * exit. No SIGINT/SIGTERM handler: the compound owns the exit, and its\n * process.exit reaches the exit event.\n */\nexport function publishVetraRuntime(\n projectDir: string,\n projectName: string,\n result: unknown,\n): () => void {\n const record = vetraRecordOfRun(projectName, result);\n if (!record) {\n console.warn(\n yellow(\n \"No switchboard member is running, so .ph/vetra-runtime.json is not written and `ph mcp` will not find this stack.\",\n ),\n );\n return () => {};\n }\n // Record what the stack actually bound, so a second Vetra can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n writeVetraRuntime(projectDir, record);\n // A restarted Vetra may already have written its own.\n const release = () => clearVetraRuntime(projectDir, process.pid);\n process.on(\"exit\", release);\n\n for (const notice of syncMcpPortNotices(projectDir, record.switchboardPort)) {\n console.log(yellow(notice));\n }\n return release;\n}\n"],"names":["z.object","z.array","z.unknown","switchboardOutputsSchema","connectOutputsSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,aAAa,MAAsC;CACvE,MAAM,OAAO,KAAK,QAAQ;CAE1B,IAAI,eAAe,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,GAClD,OAAO,SAAS,IAAI;CAEtB,MAAM,aAAa,KAAK,eAAe,QAAQ,IAAI;CACnD,MAAM,cAAc,gBAAgB,UAAU;CAC9C,MAAM,UAAU,KAAK,MAAM,SAAS,YAAY,KAAK;CACrD,IAAI,SAAS;EACX,MAAM,EAAE,cAAc,MAAM,OAAO;EACnC,MAAM,UAAU;GACd;GACA;GACA,aA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A,aAAa,CAAC;CAChB;CAGA,kBAAkB,YAAY,MAAM;CAEpC,MAAM,gBAAgB,kBAAkB,YAAY,QAAQ,GAAG;CAC/D,QAAQ,GAAG,QAAQ,OAAO;CAE1B,KAAK,MAAM,UAAU,mBAAmB,YAAY,OAAO,eAAe,GACxE,QAAQ,IAAI,OAAO,MAAM,CAAC;CAE5B,OAAO;AACT","debug_id":"9b004534-e9d0-589a-8a74-a3c6fcc69596"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { L as probeRun } from "./compound-DKi56SSx-CXQHhS6t.mjs";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ca914e2a-3bcb-5ccb-b73b-6d381ea2e1e8")}catch(e){}}();
|
|
4
3
|
import fs from "node:fs";
|
|
5
4
|
import path from "node:path";
|
|
6
5
|
import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
|
|
@@ -21,7 +20,7 @@ function writeVetraRuntime(projectDir, record) {
|
|
|
21
20
|
fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\n`);
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
|
-
* The record this process publishes for the Vetra it started. `ph
|
|
23
|
+
* The record this process publishes for the Vetra it started. `ph dev` and
|
|
25
24
|
* `ph run vetra` both build it here, so the two write the same fields. The
|
|
26
25
|
* Switchboard's URLs follow from its port unless the caller knows them.
|
|
27
26
|
*/
|
|
@@ -172,19 +171,12 @@ function syncMcpPortNotices(projectDir, port) {
|
|
|
172
171
|
//#endregion
|
|
173
172
|
//#region src/utils/vetra-instance.ts
|
|
174
173
|
/**
|
|
175
|
-
* One Vetra per project
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* Each start asks here whether the other kind holds the project.
|
|
174
|
+
* One Vetra per project. `ph run vetra` records its stack in
|
|
175
|
+
* `.ph/run/vetra.json` and, once ready, in `.ph/vetra-runtime.json`, which is
|
|
176
|
+
* what a start asks here: whether a Vetra already holds the project.
|
|
179
177
|
*/
|
|
180
|
-
/** The host folder `ph
|
|
178
|
+
/** The host folder `ph dev` runs, and the name its host file carries. */
|
|
181
179
|
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
180
|
/** Why `ph run vetra` must not start: a live Vetra holds the project. */
|
|
189
181
|
async function vetraRuntimeRefusal(projectDir, projectName) {
|
|
190
182
|
const probe = await probeVetraRuntime(projectDir, projectName);
|
|
@@ -195,7 +187,7 @@ async function vetraRuntimeRefusal(projectDir, projectName) {
|
|
|
195
187
|
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
188
|
}
|
|
197
189
|
//#endregion
|
|
198
|
-
export {
|
|
190
|
+
export { probeVetraRuntime as a, vetraRuntimeRecord as c, isPortInUse as i, writeVetraRuntime as l, vetraRuntimeRefusal as n, readVetraRuntime as o, clearVetraRuntime as r, syncMcpPortNotices as s, VETRA_HOST as t };
|
|
199
191
|
|
|
200
|
-
//# sourceMappingURL=vetra-instance-
|
|
201
|
-
//# debugId=
|
|
192
|
+
//# sourceMappingURL=vetra-instance-CPNIsaxh.mjs.map
|
|
193
|
+
//# debugId=ca914e2a-3bcb-5ccb-b73b-6d381ea2e1e8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vetra-instance-CPNIsaxh.mjs","sources":["../src/utils/vetra-runtime.ts","../src/utils/vetra-instance.ts"],"sourcesContent":["import { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport fs from \"node:fs\";\nimport net from \"node:net\";\nimport path from \"node:path\";\n\nexport type VetraRuntimeRecord = {\n pid: number;\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n /** The Switchboard's GraphQL endpoint; absent in records from before it was written. */\n switchboardUrl?: string;\n mcpUrl: string;\n /** Vetra Studio; absent with --disable-connect. */\n connectUrl?: string;\n startedAt: string;\n};\n\nexport type VetraProbe =\n | { status: \"none\" }\n | { status: \"stale\" }\n | { status: \"starting\"; record: VetraRuntimeRecord }\n | { status: \"live\"; record: VetraRuntimeRecord }\n | { status: \"foreign\"; record: VetraRuntimeRecord };\n\nconst READY_TIMEOUT_MS = 2000;\n\n// Under the project's .ph tree — relocated with it by PH_USER_DATA_DIR.\nconst recordPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-runtime.json\");\n\nexport function readVetraRuntime(\n projectDir: string,\n): VetraRuntimeRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(recordPath(projectDir), \"utf8\"),\n ) as VetraRuntimeRecord;\n } catch {\n // Missing or corrupt: either way there is no usable record.\n return undefined;\n }\n}\n\nexport function writeVetraRuntime(\n projectDir: string,\n record: VetraRuntimeRecord,\n): void {\n const target = recordPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\n/**\n * The record this process publishes for the Vetra it started. `ph dev` and\n * `ph run vetra` both build it here, so the two write the same fields. The\n * Switchboard's URLs follow from its port unless the caller knows them.\n */\nexport function vetraRuntimeRecord(input: {\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n switchboardUrl?: string;\n mcpUrl?: string;\n /** Left out when no Vetra Studio runs. */\n connectUrl?: string;\n}): VetraRuntimeRecord {\n const { switchboardPort, connectUrl } = input;\n return {\n pid: process.pid,\n projectName: input.projectName,\n switchboardPort,\n connectPort: input.connectPort,\n switchboardUrl:\n input.switchboardUrl ?? `http://localhost:${switchboardPort}/graphql`,\n mcpUrl: input.mcpUrl ?? `http://localhost:${switchboardPort}/mcp`,\n ...(connectUrl ? { connectUrl } : {}),\n startedAt: new Date().toISOString(),\n };\n}\n\n/** Deletes the record; with `pid`, only the record of that process. */\nexport function clearVetraRuntime(projectDir: string, pid?: number): void {\n if (pid !== undefined && readVetraRuntime(projectDir)?.pid !== pid) return;\n try {\n fs.rmSync(recordPath(projectDir));\n } catch {\n // Already gone.\n }\n}\n\nfunction isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means the process exists but belongs to another user.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nexport function isPortInUse(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = net.connect({ port, host: \"localhost\" });\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"error\", () => resolve(false));\n });\n}\n\nasync function isReady(port: number): Promise<boolean> {\n try {\n const response = await fetch(`http://localhost:${port}/ready`, {\n signal: AbortSignal.timeout(READY_TIMEOUT_MS),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * Decide whether the recorded instance is actually serving this project.\n *\n * All three checks are load-bearing. A pid can be reused by an unrelated\n * process, so a live pid proves nothing on its own. Another project's\n * switchboard would answer `/ready` on its own port, so a healthy `/ready`\n * proves nothing either. And the recorded `projectName` is what separates\n * \"my instance\" from \"someone else's instance that happens to hold this\n * port\" — which is precisely the confusion that let an agent write document\n * models into a different project's drive.\n *\n * A stale record is deleted so the next start is unblocked. A foreign one is\n * left alone: it describes something that is alive.\n */\nexport async function probeVetraRuntime(\n projectDir: string,\n projectName: string,\n): Promise<VetraProbe> {\n const record = readVetraRuntime(projectDir);\n if (!record) return { status: \"none\" };\n\n const alive = isPidAlive(record.pid);\n const ready = alive && (await isReady(record.switchboardPort));\n // The record lands once the port is bound; `/ready` turns 200 later.\n const starting =\n alive && !ready && (await isPortInUse(record.switchboardPort));\n if (!ready && !starting) {\n clearVetraRuntime(projectDir);\n return { status: \"stale\" };\n }\n\n if (record.projectName !== projectName) {\n return { status: \"foreign\", record };\n }\n return ready ? { status: \"live\", record } : { status: \"starting\", record };\n}\n\nconst MCP_FILES = [\n \".mcp.json\",\n path.join(\".cursor\", \"mcp.json\"),\n path.join(\".gemini\", \"settings.json\"),\n];\n\ntype McpConfig = { mcpServers?: Record<string, { url?: string }> };\ntype UrlMcpConfig = [string, McpConfig, { url?: string }];\n\n/** Each MCP config whose `reactor-mcp` entry still points at a URL. */\nfunction urlMcpConfigs(projectDir: string): UrlMcpConfig[] {\n const found: UrlMcpConfig[] = [];\n for (const rel of MCP_FILES) {\n const target = path.join(projectDir, rel);\n if (!fs.existsSync(target)) continue;\n let parsed: McpConfig;\n try {\n parsed = JSON.parse(fs.readFileSync(target, \"utf8\")) as McpConfig;\n } catch {\n // Hand-broken JSON is the author's to fix; don't clobber it.\n continue;\n }\n const server = parsed.mcpServers?.[\"reactor-mcp\"];\n if (server?.url) found.push([rel, parsed, server]);\n }\n return found;\n}\n\n/** The MCP configs `ph migrate` would move to the `ph mcp` launcher. */\nexport function legacyMcpConfigs(projectDir: string): string[] {\n return urlMcpConfigs(projectDir).map(([rel]) => rel);\n}\n\n/**\n * Point every URL-style `reactor-mcp` entry at `port`, returning the files\n * changed. Stdio entries (`ph mcp`) carry no port and are left alone; this\n * keeps projects that have not run `ph migrate` working.\n */\nexport function syncMcpPort(projectDir: string, port: number): string[] {\n const changed: string[] = [];\n const wanted = `http://localhost:${port}/mcp`;\n for (const [rel, parsed, server] of urlMcpConfigs(projectDir)) {\n if (server.url === wanted) continue;\n server.url = wanted;\n fs.writeFileSync(\n path.join(projectDir, rel),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n );\n changed.push(rel);\n }\n return changed;\n}\n\n/**\n * {@link syncMcpPort} for a Vetra that just bound `port`, returning what to\n * tell the user. An MCP client resolved `.mcp.json` before this process\n * started and cannot re-read it, so a drifted literal means the agent is\n * pointed at the wrong port — possibly another project's reactor. Correct the\n * file and say so plainly; we cannot fix the already-open client ourselves.\n */\nexport function syncMcpPortNotices(projectDir: string, port: number): string[] {\n const notices: string[] = [];\n const driftedMcpFiles = syncMcpPort(projectDir, port);\n if (driftedMcpFiles.length > 0) {\n notices.push(\n `Updated ${driftedMcpFiles.join(\" and \")} to port ${port}. ` +\n `Reconnect your MCP client (/mcp) to pick it up. ` +\n `This edit is local — do not commit it.`,\n );\n }\n if (legacyMcpConfigs(projectDir).length > 0) {\n notices.push(\n \"reactor-mcp still points at a URL; run `ph migrate` to switch it to the `ph mcp` launcher.\",\n );\n }\n return notices;\n}\n","import { probeVetraRuntime } from \"./vetra-runtime.js\";\n\n/**\n * One Vetra per project. `ph run vetra` records its stack in\n * `.ph/run/vetra.json` and, once ready, in `.ph/vetra-runtime.json`, which is\n * what a start asks here: whether a Vetra already holds the project.\n */\n\n/** The host folder `ph dev` runs, and the name its host file carries. */\nexport const VETRA_HOST = \"vetra\";\n\n/** Why `ph run vetra` must not start: a live Vetra holds the project. */\nexport async function vetraRuntimeRefusal(\n projectDir: string,\n projectName: string,\n): Promise<string | undefined> {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\" || probe.status === \"starting\") {\n if (probe.record.pid === process.pid) return undefined;\n return `Vetra is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`;\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`\n );\n }\n return undefined;\n}\n"],"names":[],"mappings":";;;;;;;AAyBA,MAAM,mBAAmB;AAGzB,MAAM,cAAc,eAClB,KAAK,KAAK,aAAa,UAAU,GAAG,oBAAoB;AAE1D,SAAgB,iBACd,YACgC;CAChC,IAAI;EACF,OAAO,KAAK,MACV,GAAG,aAAa,WAAW,UAAU,GAAG,MAAM,CAChD;CACF,QAAQ;EAEN;CACF;AACF;AAEA,SAAgB,kBACd,YACA,QACM;CACN,MAAM,SAAS,WAAW,UAAU;CACpC,GAAG,UAAU,KAAK,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;CACtD,GAAG,cAAc,QAAQ,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,GAAG;AACjE;;;;;;AAOA,SAAgB,mBAAmB,OAQZ;CACrB,MAAM,EAAE,iBAAiB,eAAe;CACxC,OAAO;EACL,KAAK,QAAQ;EACb,aAAa,MAAM;EACnB;EACA,aAAa,MAAM;EACnB,gBACE,MAAM,kBAAkB,oBAAoB,gBAAgB;EAC9D,QAAQ,MAAM,UAAU,oBAAoB,gBAAgB;EAC5D,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;EACnC,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;CACpC;AACF;;AAGA,SAAgB,kBAAkB,YAAoB,KAAoB;CACxE,IAAI,QAAQ,KAAA,KAAa,iBAAiB,UAAU,CAAC,EAAE,QAAQ,KAAK;CACpE,IAAI;EACF,GAAG,OAAO,WAAW,UAAU,CAAC;CAClC,QAAQ,CAER;AACF;AAEA,SAAS,WAAW,KAAsB;CACxC,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EAEd,OAAQ,MAAgC,SAAS;CACnD;AACF;AAEA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M,WAAW,WACnB,OACE,sDAAsD,MAAM,OAAO,YAAY,0BACvD,YAAY;AAK1C","debug_id":"ca914e2a-3bcb-5ccb-b73b-6d381ea2e1e8"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { o as stopVetra } from "./vetra-launcher-Dokr1aDK.mjs";
|
|
2
|
+
export { stopVetra };
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2131716e-47fc-5dc3-a00b-0ec15d9d82ee")}catch(e){}}();
|
|
4
|
+
//# debugId=2131716e-47fc-5dc3-a00b-0ec15d9d82ee
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as isPortInUse, i as clearVetraRuntime, o as probeVetraRuntime, t as VETRA_HOST } from "./vetra-instance-CzhYIjxL.mjs";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e35415c1-3b9c-52c8-b997-4219f0c52968")}catch(e){}}();
|
|
3
|
+
import { X as requestStop } from "./compound-BWLJ0KBw-8hKyrfjG.mjs";
|
|
4
|
+
import { a as probeVetraRuntime, i as isPortInUse, r as clearVetraRuntime, t as VETRA_HOST } from "./vetra-instance-CPNIsaxh.mjs";
|
|
6
5
|
import fs from "node:fs";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import { spawn } from "node:child_process";
|
|
9
8
|
import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
|
|
10
9
|
import { stripVTControlCharacters } from "node:util";
|
|
11
|
-
//#region src/utils/vetra-
|
|
10
|
+
//#region src/utils/vetra-launcher.ts
|
|
12
11
|
var VetraStartError = class extends Error {};
|
|
13
12
|
const PORT_GRACE_MS = 1e4;
|
|
14
13
|
const STOP_TIMEOUT_MS = 15e3;
|
|
@@ -16,19 +15,11 @@ const PROGRESS_EVERY_MS = 1e3;
|
|
|
16
15
|
const lockPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra-start.lock");
|
|
17
16
|
const vetraLogPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra.log");
|
|
18
17
|
const shownLogPath = (projectDir) => path.relative(projectDir, vetraLogPath(projectDir)).split(path.sep).join("/");
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
process.argv[1],
|
|
25
|
-
"vetra",
|
|
26
|
-
"--strictPort",
|
|
27
|
-
"--watch"
|
|
28
|
-
]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/** `ph run vetra --strictPort` run by the ph-cli executing this code. */
|
|
18
|
+
/**
|
|
19
|
+
* What starts a project's Vetra: `ph run vetra --strictPort`, run by the
|
|
20
|
+
* ph-cli executing this code. The host's own defaultVerb picks the verb. In
|
|
21
|
+
* a project without the host it fails, and its output says why.
|
|
22
|
+
*/
|
|
32
23
|
function currentPhCliRunVetraCommand() {
|
|
33
24
|
return {
|
|
34
25
|
command: process.execPath,
|
|
@@ -41,15 +32,6 @@ function currentPhCliRunVetraCommand() {
|
|
|
41
32
|
label: `ph run ${VETRA_HOST}`
|
|
42
33
|
};
|
|
43
34
|
}
|
|
44
|
-
/**
|
|
45
|
-
* What starts this project's Vetra: its `hosts/vetra` host when it has one,
|
|
46
|
-
* as `ph vetra` itself routes there (run-sugar.ts), else classic `ph vetra`.
|
|
47
|
-
* The host's own defaultVerb picks the verb; `--watch` is not a host argument.
|
|
48
|
-
*/
|
|
49
|
-
function vetraCommandFor(projectDir) {
|
|
50
|
-
const probe = probeHostsFolder(projectDir);
|
|
51
|
-
return probe.kind === "present" && probe.hosts.includes("vetra") ? currentPhCliRunVetraCommand() : currentPhCliVetraCommand();
|
|
52
|
-
}
|
|
53
35
|
function isPidAlive(pid) {
|
|
54
36
|
if (!pid) return false;
|
|
55
37
|
try {
|
|
@@ -119,7 +101,7 @@ async function waitForLive(options, deadline, stillStarting) {
|
|
|
119
101
|
await sleep(pollMs);
|
|
120
102
|
}
|
|
121
103
|
}
|
|
122
|
-
/** This project's live Vetra, or a detached `ph vetra` started and awaited; never a second reactor. */
|
|
104
|
+
/** This project's live Vetra, or a detached `ph run vetra` started and awaited; never a second reactor. */
|
|
123
105
|
async function ensureVetra(options) {
|
|
124
106
|
const { projectDir, projectName, switchboardPort, timeoutMs } = options;
|
|
125
107
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -182,7 +164,7 @@ async function ensureVetra(options) {
|
|
|
182
164
|
if (spawnError) throw new VetraStartError(`Could not run \`${options.command.command}\`: ${spawnError.message}`);
|
|
183
165
|
if (exit) {
|
|
184
166
|
const how = exit.signal !== null ? `was killed by ${exit.signal}` : `exited with code ${exit.code}`;
|
|
185
|
-
throw withOutput(`\`${options.command.label ??
|
|
167
|
+
throw withOutput(`\`${options.command.label ?? `ph run vetra`}\` ${how} before it was ready.`, projectDir);
|
|
186
168
|
}
|
|
187
169
|
keepLock = true;
|
|
188
170
|
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);
|
|
@@ -231,7 +213,7 @@ async function restartVetra(options) {
|
|
|
231
213
|
return ensureVetra(options);
|
|
232
214
|
}
|
|
233
215
|
//#endregion
|
|
234
|
-
export {
|
|
216
|
+
export { restartVetra as a, readLogTail as i, currentPhCliRunVetraCommand as n, stopVetra as o, ensureVetra as r, vetraLogPath as s, VetraStartError as t };
|
|
235
217
|
|
|
236
|
-
//# sourceMappingURL=vetra-
|
|
237
|
-
//# debugId=
|
|
218
|
+
//# sourceMappingURL=vetra-launcher-Dokr1aDK.mjs.map
|
|
219
|
+
//# debugId=e35415c1-3b9c-52c8-b997-4219f0c52968
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vetra-launcher-Dokr1aDK.mjs","sources":["../src/utils/vetra-launcher.ts"],"sourcesContent":["import { requestStop } from \"@powerhousedao/host-core\";\nimport { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { stripVTControlCharacters } from \"node:util\";\nimport { VETRA_HOST } from \"./vetra-instance.js\";\nimport {\n clearVetraRuntime,\n isPortInUse,\n probeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"./vetra-runtime.js\";\n\nexport type VetraCommand = {\n command: string;\n args: string[];\n /** How messages name it; `ph run vetra` when left out. */\n label?: string;\n};\n\nexport type EnsureVetraOptions = {\n projectDir: string;\n projectName: string;\n /** The port a strict-port Vetra will bind. */\n switchboardPort: number;\n command: VetraCommand;\n timeoutMs: number;\n pollMs?: number;\n /** Told what it waits on while Vetra is not ready yet, about once a second. */\n onProgress?: (message: string) => void;\n};\n\nexport class VetraStartError extends Error {}\n\nconst LOG_TAIL_LINES = 60;\nconst PORT_GRACE_MS = 10_000;\nconst STOP_TIMEOUT_MS = 15_000;\nconst PROGRESS_EVERY_MS = 1000;\n\nconst lockPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-start.lock\");\n\nexport const vetraLogPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra.log\");\n\n// Forward slashes, so messages read the same on every platform.\nconst shownLogPath = (projectDir: string) =>\n path.relative(projectDir, vetraLogPath(projectDir)).split(path.sep).join(\"/\");\n\n/**\n * What starts a project's Vetra: `ph run vetra --strictPort`, run by the\n * ph-cli executing this code. The host's own defaultVerb picks the verb. In\n * a project without the host it fails, and its output says why.\n */\nexport function currentPhCliRunVetraCommand(): VetraCommand {\n return {\n command: process.execPath,\n args: [process.argv[1], \"run\", VETRA_HOST, \"--strictPort\"],\n label: `ph run ${VETRA_HOST}`,\n };\n}\n\nfunction isPidAlive(pid: number | undefined): boolean {\n if (!pid) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\ntype LockRecord = { pid: number; vetraPid?: number };\n\nfunction readLock(projectDir: string): LockRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(lockPath(projectDir), \"utf8\"),\n ) as LockRecord;\n } catch {\n return undefined;\n }\n}\n\nfunction isLockHeld(lock: LockRecord | undefined): boolean {\n return !!lock && (isPidAlive(lock.pid) || isPidAlive(lock.vetraPid));\n}\n\n/** Held while the launcher or the Vetra it started is alive. */\nfunction tryAcquireLock(projectDir: string): boolean {\n const target = lockPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n for (let attempt = 0; attempt < 2; attempt++) {\n try {\n fs.writeFileSync(target, JSON.stringify({ pid: process.pid }), {\n flag: \"wx\",\n });\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (isLockHeld(readLock(projectDir))) return false;\n fs.rmSync(target, { force: true });\n }\n }\n return false;\n}\n\nfunction releaseLock(projectDir: string): void {\n if (readLock(projectDir)?.pid === process.pid) {\n fs.rmSync(lockPath(projectDir), { force: true });\n }\n}\n\nexport function readLogTail(projectDir: string): string {\n try {\n const text = fs.readFileSync(vetraLogPath(projectDir), \"utf8\");\n const lines = stripVTControlCharacters(text).trimEnd().split(\"\\n\");\n return lines.slice(-LOG_TAIL_LINES).join(\"\\n\");\n } catch {\n return \"\";\n }\n}\n\nfunction withOutput(message: string, projectDir: string): VetraStartError {\n const tail = readLogTail(projectDir);\n const where = shownLogPath(projectDir);\n return new VetraStartError(\n tail\n ? `${message}\\n\\nVetra output (last lines of ${where}):\\n${tail}`\n : message,\n );\n}\n\nfunction foreignError(record: VetraRuntimeRecord): VetraStartError {\n return new VetraStartError(\n `.ph/vetra-runtime.json describes a live Vetra for \"${record.projectName}\" (pid ${record.pid}), not this project. ` +\n `Refusing to start a second reactor. Delete .ph/vetra-runtime.json if that record is wrong.`,\n );\n}\n\nasync function waitForLive(\n options: EnsureVetraOptions,\n deadline: number,\n stillStarting: () => boolean,\n): Promise<VetraRuntimeRecord | undefined> {\n const { projectDir, projectName, pollMs = 250, onProgress } = options;\n const startedAt = Date.now();\n let reportedAt = startedAt;\n while (Date.now() < deadline) {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\") return probe.record;\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status !== \"starting\" && !stillStarting()) return undefined;\n if (onProgress && Date.now() - reportedAt >= PROGRESS_EVERY_MS) {\n reportedAt = Date.now();\n const seconds = Math.round((reportedAt - startedAt) / 1000);\n onProgress(`Waiting for Vetra to be ready (${seconds}s)...`);\n }\n await sleep(pollMs);\n }\n return undefined;\n}\n\n/** This project's live Vetra, or a detached `ph run vetra` started and awaited; never a second reactor. */\nexport async function ensureVetra(\n options: EnsureVetraOptions,\n): Promise<VetraRuntimeRecord> {\n const { projectDir, projectName, switchboardPort, timeoutMs } = options;\n const deadline = Date.now() + timeoutMs;\n const seconds = Math.round(timeoutMs / 1000);\n const report = options.onProgress ?? (() => {});\n\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\") return probe.record;\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status === \"starting\") {\n report(`Vetra (pid ${probe.record.pid}) is starting; waiting for it...`);\n const record = await waitForLive(options, deadline, () => false);\n if (record) return record;\n throw withOutput(\n `Vetra (pid ${probe.record.pid}) is running but did not answer /ready within ${seconds}s.`,\n projectDir,\n );\n }\n\n while (!tryAcquireLock(projectDir)) {\n // Another launcher is starting Vetra for this project.\n report(\"Another process is starting Vetra for this project; waiting...\");\n const record = await waitForLive(options, deadline, () =>\n isLockHeld(readLock(projectDir)),\n );\n if (record) return record;\n if (Date.now() >= deadline) {\n throw withOutput(\n `Another process is starting Vetra for this project and it did not become ready within ${seconds}s.`,\n projectDir,\n );\n }\n }\n\n let keepLock = false;\n try {\n const again = await probeVetraRuntime(projectDir, projectName);\n if (again.status === \"live\") return again.record;\n if (again.status === \"foreign\") throw foreignError(again.record);\n\n if (again.status === \"starting\" || (await isPortInUse(switchboardPort))) {\n // Maybe a Vetra that bound the port but has not written its record yet.\n const grace = Date.now() + PORT_GRACE_MS;\n const record = await waitForLive(\n options,\n deadline,\n () => Date.now() < grace,\n );\n if (record) return record;\n throw new VetraStartError(\n `Port ${switchboardPort} is in use, but .ph/vetra-runtime.json names no live Vetra for this project. ` +\n `Stop whatever holds the port, or move this project's port (reactor.port in powerhouse.config.json).`,\n );\n }\n\n const logFile = vetraLogPath(projectDir);\n report(`Starting Vetra; its output goes to ${shownLogPath(projectDir)}...`);\n const logFd = fs.openSync(logFile, \"w\");\n let exit: { code: number | null; signal: string | null } | undefined;\n let spawnError: Error | undefined;\n const child = spawn(options.command.command, options.command.args, {\n cwd: projectDir,\n detached: true,\n stdio: [\"ignore\", logFd, logFd],\n windowsHide: true,\n });\n fs.closeSync(logFd);\n child.once(\"error\", (error) => (spawnError = error));\n child.once(\"exit\", (code, signal) => (exit = { code, signal }));\n child.unref();\n if (child.pid) {\n fs.writeFileSync(\n lockPath(projectDir),\n JSON.stringify({ pid: process.pid, vetraPid: child.pid }),\n );\n }\n\n const record = await waitForLive(\n options,\n deadline,\n () => !exit && !spawnError,\n );\n if (record) return record;\n\n if (spawnError) {\n throw new VetraStartError(\n `Could not run \\`${options.command.command}\\`: ${spawnError.message}`,\n );\n }\n if (exit) {\n const how =\n exit.signal !== null\n ? `was killed by ${exit.signal}`\n : `exited with code ${exit.code}`;\n throw withOutput(\n `\\`${options.command.label ?? `ph run ${VETRA_HOST}`}\\` ${how} before it was ready.`,\n projectDir,\n );\n }\n // Still booting: keep the lock on its pid so the next call waits instead of spawning.\n keepLock = true;\n throw withOutput(\n `Vetra (pid ${child.pid}) did not answer /ready on port ${switchboardPort} within ${seconds}s. ` +\n `It is still running; the next tool call waits for it again.`,\n projectDir,\n );\n } finally {\n if (!keepLock) releaseLock(projectDir);\n }\n}\n\nasync function waitForExit(\n record: VetraRuntimeRecord,\n deadline: number,\n): Promise<boolean> {\n while (Date.now() < deadline) {\n const gone =\n !isPidAlive(record.pid) && !(await isPortInUse(record.switchboardPort));\n if (gone) return true;\n await sleep(100);\n }\n return false;\n}\n\n/** Stops this project's running Vetra, if any; resolves to the record it stopped. */\nexport async function stopVetra(options: {\n projectDir: string;\n projectName: string;\n timeoutMs?: number;\n onProgress?: (message: string) => void;\n}): Promise<VetraRuntimeRecord | undefined> {\n const { projectDir, projectName, timeoutMs = STOP_TIMEOUT_MS } = options;\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"foreign\") throw foreignError(probe.record);\n if (probe.status !== \"live\" && probe.status !== \"starting\") return undefined;\n const { record } = probe;\n const signal = (name: NodeJS.Signals) => {\n try {\n process.kill(record.pid, name);\n } catch {\n // Already gone.\n }\n };\n options.onProgress?.(`Stopping Vetra (pid ${record.pid})...`);\n // On Windows SIGTERM is a kill: ask through the stop channel, and signal\n // only a Vetra that has none.\n if (!(await requestStop(record.pid))) signal(\"SIGTERM\");\n if (!(await waitForExit(record, Date.now() + timeoutMs))) {\n signal(\"SIGKILL\");\n if (!(await waitForExit(record, Date.now() + timeoutMs))) {\n throw new VetraStartError(\n `Vetra (pid ${record.pid}) did not stop within ${Math.round((2 * timeoutMs) / 1000)}s.`,\n );\n }\n }\n clearVetraRuntime(projectDir, record.pid);\n if (readLock(projectDir)?.vetraPid === record.pid) {\n fs.rmSync(lockPath(projectDir), { force: true });\n }\n return record;\n}\n\n/** Stops this project's Vetra and starts it again, detached, as {@link ensureVetra} does. */\nexport async function restartVetra(\n options: EnsureVetraOptions,\n): Promise<VetraRuntimeRecord> {\n const { projectDir, projectName, onProgress } = options;\n const stopped = await stopVetra({ projectDir, projectName, onProgress });\n if (stopped) onProgress?.(`Stopped 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;;;;;;AAO9E,SAAgB,8BAA4C;CAC1D,OAAO;EACL,SAAS,QAAQ;EACjB,MAAM;GAAC,QAAQ,KAAK;GAAI;GAAO;GAAY;EAAc;EACzD,OAAO,UAAU;CACnB;AACF;AAEA,SAAS,WAAW,KAAkC;CACpD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EACd,OAAQ,MAAgC,SAAS;CACnD;AACF;AAEA,MAAM,SAAS,OAAe,IAAI,SAAS,MAAM,WAAW,GAAG,EAAE,CAAC;AAIlE,SAAS,SAAS,YAA4C;CAC5D,IAAI;EACF,OAAO,KAAK,MACV,GAAG,aAAa,SAAS,UAAU,GAAG,MAAM,CAC9C;CACF,QAAQ;EACN;CACF;AACF;AAEA,SAAS,WAAW,MAAuC;CACzD,OAAO,CAAC,CAAC,SAAS,WAAW,KAAK,GAAG,KAAK,WAAW,KAAK,QAAQ;AACpE;;AAGA,SA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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":"e35415c1-3b9c-52c8-b997-4219f0c52968"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
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]="a19cf5cb-2b76-5a61-91e5-166968be43f0")}catch(e){}}();
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
4
|
import { blue, red } from "colorette";
|
|
5
5
|
import { createVetraDocument, getVetraDocuments, setPackageGithubUrl } from "@powerhousedao/common/utils";
|
|
@@ -224,7 +224,7 @@ async function configureVetraRemoteDrive(switchboardPort, remoteDrive, verbose)
|
|
|
224
224
|
await sleep(2e3);
|
|
225
225
|
}
|
|
226
226
|
//#endregion
|
|
227
|
-
export { printVetraSwitchboardUrls
|
|
227
|
+
export { configureVetraRemoteDrive, printVetraSwitchboardUrls, vetraProcessorConfigOf };
|
|
228
228
|
|
|
229
|
-
//# sourceMappingURL=vetra-switchboard-
|
|
230
|
-
//# debugId=
|
|
229
|
+
//# sourceMappingURL=vetra-switchboard-Ctje6iR1.mjs.map
|
|
230
|
+
//# debugId=a19cf5cb-2b76-5a61-91e5-166968be43f0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vetra-switchboard-tzdc14KA.mjs","sources":["../src/utils/configure-vetra-github-url.ts","../src/services/vetra-switchboard.ts"],"sourcesContent":["import {\n createVetraDocument,\n getVetraDocuments,\n setPackageGithubUrl,\n} from \"@powerhousedao/common/utils\";\nimport { red } from \"colorette\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\n/**\n * Get git remote URL (origin)\n * @returns Git remote URL or null if not configured\n */\nfunction getGitRemoteUrl(): string | null {\n try {\n const url = execSync(\"git remote get-url origin\", {\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim();\n return url || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Prompt user to enter a custom GitHub URL\n */\nasync function promptForCustomUrl(): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(\"\\nEnter GitHub URL (or press Enter to skip): \");\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const url = answer.trim();\n resolve(url || null);\n });\n });\n}\n\n/**\n * Prompt yes/no question\n */\nasync function promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(`\\n${question} (y/n): `);\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const response = answer.trim().toLowerCase();\n resolve(response === \"y\" || response === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user to select or enter GitHub URL\n * @param gitRemoteUrl - Git remote URL if available\n * @returns Selected URL or null if skipped\n */\nasync function promptForGithubUrl(\n gitRemoteUrl: string | null,\n): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"🔍 Vetra Package Configuration\");\n console.log(\"=\".repeat(50));\n console.log(\n \"\\nWe detected a Vetra package document in your remote drive without a GitHub URL configured.\",\n );\n console.log(\"\\nWould you like to configure the GitHub URL now?\");\n\n if (gitRemoteUrl) {\n console.log(`\\nGit remote URL detected: ${gitRemoteUrl}`);\n console.log(\"\\nOptions:\");\n console.log(\"1. Use detected URL\");\n console.log(\"2. Enter a different URL\");\n console.log(\"3. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-3): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n resolve(gitRemoteUrl);\n } else if (choice === \"2\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"3\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-3): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n } else {\n console.log(\"\\nNo git remote URL detected.\");\n console.log(\"\\nOptions:\");\n console.log(\"1. Enter GitHub URL manually\");\n console.log(\"2. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-2): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"2\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-2): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n }\n });\n}\n\n/**\n * Set git remote URL (origin)\n */\nfunction setGitRemoteUrl(url: string): void {\n try {\n execSync(`git remote add origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin set to: ${url}`);\n } catch {\n try {\n execSync(`git remote set-url origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin updated to: ${url}`);\n } catch {\n console.error(red(`❌ Failed to set git remote URL`));\n }\n }\n}\n\n/**\n * Validates documents and returns the target document to use\n * Warns if multiple documents found\n */\nfunction validateAndSelectDocument<T>(documents: T[]): T | null {\n if (documents.length === 0) {\n return null;\n }\n\n if (documents.length > 1) {\n console.warn(\n `⚠️ Warning: Multiple Vetra documents found (${documents.length}). Using first document.`,\n );\n }\n\n return documents[0];\n}\n\nasync function applyGithubUrlConfiguration(\n graphqlEndpoint: string,\n vetraDriveId: string,\n documentId: string,\n selectedUrl: string,\n shouldSetRemote: boolean,\n): Promise<void> {\n // Set package GitHub URL\n await setPackageGithubUrl(\n graphqlEndpoint,\n vetraDriveId,\n documentId,\n selectedUrl,\n );\n\n console.log(`✅ GitHub URL configured: ${selectedUrl}`);\n\n // Set git remote URL if requested\n if (shouldSetRemote) {\n setGitRemoteUrl(selectedUrl);\n }\n}\n\nfunction logVerbose(message: string, verbose?: boolean): void {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sleep for a specified number of milliseconds\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Configure GitHub URL for Vetra documents\n * @param switchboardPort - Port where switchboard is running\n * @param vetraDriveUrl - Remote drive URL\n * @param verbose - Enable verbose logging\n */\nexport async function configureVetraGithubUrl(\n switchboardPort: number,\n vetraDriveUrl: string,\n verbose?: boolean,\n): Promise<void> {\n logVerbose(\"Checking GitHub URL configuration...\", verbose);\n\n try {\n const graphqlEndpoint = `http://localhost:${switchboardPort}/graphql`;\n const vetraDriveId = vetraDriveUrl.split(\"/\").pop();\n if (!vetraDriveId) {\n throw new Error(\"Invalid vetraDriveUrl: unable to extract drive ID\");\n }\n\n const documents = await getVetraDocuments(graphqlEndpoint, vetraDriveId);\n\n // Skip if already configured\n if (documents.some((doc) => doc.githubUrl)) {\n logVerbose(\"GitHub URL already configured, skipping setup\", verbose);\n return;\n }\n\n // Get or create target document\n let targetDocumentId: string;\n const targetDocument = validateAndSelectDocument(documents);\n\n // Collect user input\n const gitRemoteUrl = getGitRemoteUrl();\n const selectedUrl = await promptForGithubUrl(gitRemoteUrl);\n\n if (!selectedUrl) {\n logVerbose(\"GitHub URL configuration skipped\", verbose);\n return;\n }\n\n let shouldSetRemote = false;\n if (selectedUrl !== gitRemoteUrl && !gitRemoteUrl) {\n shouldSetRemote = await promptYesNo(\"Set this as your git remote URL?\");\n }\n\n if (!targetDocument) {\n logVerbose(\"No Vetra documents found, creating new document...\", verbose);\n\n targetDocumentId = await createVetraDocument(\n graphqlEndpoint,\n vetraDriveId,\n \"vetra-package\",\n );\n\n logVerbose(`Created new document: ${targetDocumentId}`, verbose);\n } else {\n targetDocumentId = targetDocument.id;\n }\n\n await applyGithubUrlConfiguration(\n graphqlEndpoint,\n vetraDriveId,\n targetDocumentId,\n selectedUrl,\n shouldSetRemote,\n );\n } catch (error) {\n console.error(\n red(\n `⚠️ GitHub URL configuration failed: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n logVerbose(String(error), verbose);\n }\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { blue } from \"colorette\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\n\n/**\n * What makes a started switchboard the VETRA switchboard, shared by the two\n * ways to start one: classic `ph vetra` (services/vetra.ts) and the vetra\n * host's switchboard member (runners/switchboard.ts). One implementation, so\n * the two cannot drift.\n */\n\nexport interface VetraDriveSource {\n interactive: boolean | undefined;\n /** `--remote-drive` (or the host's declared remote vetra drive). */\n remoteDrive: string | undefined;\n /** The project's own vetra drive, used when no remote one is given. */\n localDriveUrl: string;\n localDriveId: string;\n}\n\n/** The codegen processor's config (`VetraConfig`): the drive it generates\n * from is the remote drive when one is given, else the project's own. */\nexport function vetraProcessorConfigOf(\n source: VetraDriveSource,\n): VetraProcessorConfigType {\n const { interactive, remoteDrive, localDriveUrl, localDriveId } = source;\n return {\n interactive,\n driveUrl: remoteDrive ?? localDriveUrl,\n driveId: remoteDrive?.split(\"/\").pop() ?? localDriveId,\n };\n}\n\nexport interface VetraSwitchboardUrls {\n verbose: boolean | undefined;\n remoteDrive: string | undefined;\n switchboardPort: number;\n driveUrl: string | undefined;\n previewDriveUrl?: string | null;\n workflowsDriveUrl?: string | null;\n}\n\n/** The lines a started Vetra switchboard prints: where it listens and the\n * drives it serves. */\nexport function printVetraSwitchboardUrls(urls: VetraSwitchboardUrls): void {\n const { verbose, remoteDrive, previewDriveUrl, workflowsDriveUrl } = urls;\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Started successfully`));\n if (remoteDrive) {\n console.log(\n blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`),\n );\n }\n } else {\n console.log();\n console.log(\n blue(\n `Vetra Switchboard: http://localhost:${urls.switchboardPort}/graphql`,\n ),\n );\n console.log(blue(` ➜ Drive URL: ${urls.driveUrl}`));\n if (previewDriveUrl) {\n console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));\n }\n if (workflowsDriveUrl) {\n console.log(blue(` ➜ Workflows Drive URL: ${workflowsDriveUrl}`));\n }\n }\n}\n\n/** Configure the GitHub URL of the package document in a remote vetra drive. */\nexport async function configureVetraRemoteDrive(\n switchboardPort: number,\n remoteDrive: string,\n verbose: boolean | undefined,\n): Promise<void> {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(switchboardPort, remoteDrive, verbose);\n\n // give some time for the user to read log messages\n await sleep(2000);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAaA,SAAS,kBAAiC;CACxC,IAAI;EAKF,OAJY,SAAS,6BAA6B;GAChD,UAAU;GACV,OAAO;IAAC;IAAQ;IAAQ;GAAM;EAChC,CAAC,CAAC,CAAC,KACM,KAAK;CAChB,QAAQ;EACN,OAAO;CACT;AACF;;;;AAKA,eAAe,qBAA6C;CAC1D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,gBAAgB;GACzB,OAAO,QAAQ;GACf,QAAQ,QAAQ;EAClB,CAAC;EAED,QAAQ,OAAO,MAAM,+CAA+C;EAEpE,GAAG,GAAG,SAAS,WAAmB;GACh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,aAAa,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK;CAC5C;AACF;;;AAaA,SAAgB,0BAA0B,MAAkC;CAC1E,MAAM,EAAE,SAAS,aAAa,iBAAiB,sBAAsB;CACrE,IAAI,SAAS;EACX,QAAQ,IAAI,KAAK,yCAAyC,CAAC;EAC3D,IAAI,aACF,QAAQ,IACN,KAAK,iDAAiD,aAAa,CACrE;CAEJ,OAAO;EACL,QAAQ,IAAI;EACZ,QAAQ,IACN,KACE,uCAAuC,KAAK,gBAAgB,SAC9D,CACF;EACA,QAAQ,IAAI,KAAK,mBAAmB,KAAK,UAAU,CAAC;EACpD,IAAI,iBACF,QAAQ,IAAI,KAAK,2BAA2B,iBAAiB,CAAC;EAEhE,IAAI,mBACF,QAAQ,IAAI,KAAK,6BAA6B,mBAAmB,CAAC;CAEtE;AACF;;AAGA,eAAsB,0BACpB,iBACA,aACA,SACe;CAEf,MAAM,MAAM,GAAI;CAEhB,MAAM,wBAAwB,iBAAiB,aAAa,OAAO;CAGnE,MAAM,MAAM,GAAI;AAClB","debug_id":"d71f6466-ff25-5de5-bc44-df507c1c209a"}
|
|
1
|
+
{"version":3,"file":"vetra-switchboard-Ctje6iR1.mjs","sources":["../src/utils/configure-vetra-github-url.ts","../src/services/vetra-switchboard.ts"],"sourcesContent":["import {\n createVetraDocument,\n getVetraDocuments,\n setPackageGithubUrl,\n} from \"@powerhousedao/common/utils\";\nimport { red } from \"colorette\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\n/**\n * Get git remote URL (origin)\n * @returns Git remote URL or null if not configured\n */\nfunction getGitRemoteUrl(): string | null {\n try {\n const url = execSync(\"git remote get-url origin\", {\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim();\n return url || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Prompt user to enter a custom GitHub URL\n */\nasync function promptForCustomUrl(): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(\"\\nEnter GitHub URL (or press Enter to skip): \");\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const url = answer.trim();\n resolve(url || null);\n });\n });\n}\n\n/**\n * Prompt yes/no question\n */\nasync function promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(`\\n${question} (y/n): `);\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const response = answer.trim().toLowerCase();\n resolve(response === \"y\" || response === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user to select or enter GitHub URL\n * @param gitRemoteUrl - Git remote URL if available\n * @returns Selected URL or null if skipped\n */\nasync function promptForGithubUrl(\n gitRemoteUrl: string | null,\n): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"🔍 Vetra Package Configuration\");\n console.log(\"=\".repeat(50));\n console.log(\n \"\\nWe detected a Vetra package document in your remote drive without a GitHub URL configured.\",\n );\n console.log(\"\\nWould you like to configure the GitHub URL now?\");\n\n if (gitRemoteUrl) {\n console.log(`\\nGit remote URL detected: ${gitRemoteUrl}`);\n console.log(\"\\nOptions:\");\n console.log(\"1. Use detected URL\");\n console.log(\"2. Enter a different URL\");\n console.log(\"3. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-3): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n resolve(gitRemoteUrl);\n } else if (choice === \"2\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"3\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-3): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n } else {\n console.log(\"\\nNo git remote URL detected.\");\n console.log(\"\\nOptions:\");\n console.log(\"1. Enter GitHub URL manually\");\n console.log(\"2. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-2): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"2\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-2): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n }\n });\n}\n\n/**\n * Set git remote URL (origin)\n */\nfunction setGitRemoteUrl(url: string): void {\n try {\n execSync(`git remote add origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin set to: ${url}`);\n } catch {\n try {\n execSync(`git remote set-url origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin updated to: ${url}`);\n } catch {\n console.error(red(`❌ Failed to set git remote URL`));\n }\n }\n}\n\n/**\n * Validates documents and returns the target document to use\n * Warns if multiple documents found\n */\nfunction validateAndSelectDocument<T>(documents: T[]): T | null {\n if (documents.length === 0) {\n return null;\n }\n\n if (documents.length > 1) {\n console.warn(\n `⚠️ Warning: Multiple Vetra documents found (${documents.length}). Using first document.`,\n );\n }\n\n return documents[0];\n}\n\nasync function applyGithubUrlConfiguration(\n graphqlEndpoint: string,\n vetraDriveId: string,\n documentId: string,\n selectedUrl: string,\n shouldSetRemote: boolean,\n): Promise<void> {\n // Set package GitHub URL\n await setPackageGithubUrl(\n graphqlEndpoint,\n vetraDriveId,\n documentId,\n selectedUrl,\n );\n\n console.log(`✅ GitHub URL configured: ${selectedUrl}`);\n\n // Set git remote URL if requested\n if (shouldSetRemote) {\n setGitRemoteUrl(selectedUrl);\n }\n}\n\nfunction logVerbose(message: string, verbose?: boolean): void {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sleep for a specified number of milliseconds\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Configure GitHub URL for Vetra documents\n * @param switchboardPort - Port where switchboard is running\n * @param vetraDriveUrl - Remote drive URL\n * @param verbose - Enable verbose logging\n */\nexport async function configureVetraGithubUrl(\n switchboardPort: number,\n vetraDriveUrl: string,\n verbose?: boolean,\n): Promise<void> {\n logVerbose(\"Checking GitHub URL configuration...\", verbose);\n\n try {\n const graphqlEndpoint = `http://localhost:${switchboardPort}/graphql`;\n const vetraDriveId = vetraDriveUrl.split(\"/\").pop();\n if (!vetraDriveId) {\n throw new Error(\"Invalid vetraDriveUrl: unable to extract drive ID\");\n }\n\n const documents = await getVetraDocuments(graphqlEndpoint, vetraDriveId);\n\n // Skip if already configured\n if (documents.some((doc) => doc.githubUrl)) {\n logVerbose(\"GitHub URL already configured, skipping setup\", verbose);\n return;\n }\n\n // Get or create target document\n let targetDocumentId: string;\n const targetDocument = validateAndSelectDocument(documents);\n\n // Collect user input\n const gitRemoteUrl = getGitRemoteUrl();\n const selectedUrl = await promptForGithubUrl(gitRemoteUrl);\n\n if (!selectedUrl) {\n logVerbose(\"GitHub URL configuration skipped\", verbose);\n return;\n }\n\n let shouldSetRemote = false;\n if (selectedUrl !== gitRemoteUrl && !gitRemoteUrl) {\n shouldSetRemote = await promptYesNo(\"Set this as your git remote URL?\");\n }\n\n if (!targetDocument) {\n logVerbose(\"No Vetra documents found, creating new document...\", verbose);\n\n targetDocumentId = await createVetraDocument(\n graphqlEndpoint,\n vetraDriveId,\n \"vetra-package\",\n );\n\n logVerbose(`Created new document: ${targetDocumentId}`, verbose);\n } else {\n targetDocumentId = targetDocument.id;\n }\n\n await applyGithubUrlConfiguration(\n graphqlEndpoint,\n vetraDriveId,\n targetDocumentId,\n selectedUrl,\n shouldSetRemote,\n );\n } catch (error) {\n console.error(\n red(\n `⚠️ GitHub URL configuration failed: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n logVerbose(String(error), verbose);\n }\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { blue } from \"colorette\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\n\n/**\n * What makes a started switchboard the VETRA switchboard: used by the vetra\n * host's switchboard member (runners/switchboard.ts).\n */\n\nexport interface VetraDriveSource {\n interactive: boolean | undefined;\n /** `--remote-drive` (or the host's declared remote vetra drive). */\n remoteDrive: string | undefined;\n /** The project's own vetra drive, used when no remote one is given. */\n localDriveUrl: string;\n localDriveId: string;\n}\n\n/** The codegen processor's config (`VetraConfig`): the drive it generates\n * from is the remote drive when one is given, else the project's own. */\nexport function vetraProcessorConfigOf(\n source: VetraDriveSource,\n): VetraProcessorConfigType {\n const { interactive, remoteDrive, localDriveUrl, localDriveId } = source;\n return {\n interactive,\n driveUrl: remoteDrive ?? localDriveUrl,\n driveId: remoteDrive?.split(\"/\").pop() ?? localDriveId,\n };\n}\n\nexport interface VetraSwitchboardUrls {\n verbose: boolean | undefined;\n remoteDrive: string | undefined;\n switchboardPort: number;\n driveUrl: string | undefined;\n previewDriveUrl?: string | null;\n workflowsDriveUrl?: string | null;\n}\n\n/** The lines a started Vetra switchboard prints: where it listens and the\n * drives it serves. */\nexport function printVetraSwitchboardUrls(urls: VetraSwitchboardUrls): void {\n const { verbose, remoteDrive, previewDriveUrl, workflowsDriveUrl } = urls;\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Started successfully`));\n if (remoteDrive) {\n console.log(\n blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`),\n );\n }\n } else {\n console.log();\n console.log(\n blue(\n `Vetra Switchboard: http://localhost:${urls.switchboardPort}/graphql`,\n ),\n );\n console.log(blue(` ➜ Drive URL: ${urls.driveUrl}`));\n if (previewDriveUrl) {\n console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));\n }\n if (workflowsDriveUrl) {\n console.log(blue(` ➜ Workflows Drive URL: ${workflowsDriveUrl}`));\n }\n }\n}\n\n/** Configure the GitHub URL of the package document in a remote vetra drive. */\nexport async function configureVetraRemoteDrive(\n switchboardPort: number,\n remoteDrive: string,\n verbose: boolean | undefined,\n): Promise<void> {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(switchboardPort, remoteDrive, verbose);\n\n // give some time for the user to read log messages\n await sleep(2000);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAaA,SAAS,kBAAiC;CACxC,IAAI;EAKF,OAJY,SAAS,6BAA6B;GAChD,UAAU;GACV,OAAO;IAAC;IAAQ;IAAQ;GAAM;EAChC,CAAC,CAAC,CAAC,KACM,KAAK;CAChB,QAAQ;EACN,OAAO;CACT;AACF;;;;AAKA,eAAe,qBAA6C;CAC1D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,gBAAgB;GACzB,OAAO,QAAQ;GACf,QAAQ,QAAQ;EAClB,CAAC;EAED,QAAQ,OAAO,MAAM,+CAA+C;EAEpE,GAAG,GAAG,SAAS,WAAmB;GAChC,GAAG,MAAM;GAET,QADY,OAAO,KACT,KAAK,IAAI;EACrB,CAAC;CACH,CAAC;AACH;;;;AAKA,eAAe,YAAY,UAAoC;CAC7D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,gBAAgB;GACzB,OAAO,QAAQ;GACf,QAAQ,QAAQ;EAClB,CAAC;EAED,QAAQ,OAAO,MAAM,KAAK,SAAS,SAAS;EAE5C,GAAG,GAAG,SAAS,WAAmB;GAChC,GAAG,MAAM;GACT,MAAM,WAAW,OAAO,KAAK,CAAC,CAAC,YAAY;GAC3C,QAAQ,aAAa,OAAO,aAAa,KAAK;EAChD,CAAC;CACH,CAAC;AACH;;;;;;AAOA,eAAe,mBACb,cACwB;CACxB,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,gBAAgB;GACzB,OAAO,QAAQ;GACf,QAAQ,QAAQ;EAClB,CAAC;EAED,QAAQ,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;EACjC,QAAQ,IAAI,gCAAgC;EAC5C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