@powerhousedao/ph-cli 6.2.3-dev.101 → 6.2.3-dev.103
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/dist/{build-CojYJHNn.mjs → build-CxaXbGFz.mjs} +63 -11
- package/dist/build-CxaXbGFz.mjs.map +1 -0
- package/dist/build-pOI4h7Mm.mjs +4 -0
- package/dist/{check-DWvobZrP.mjs → check-D-Ieo-Xn.mjs} +32 -11
- package/dist/check-D-Ieo-Xn.mjs.map +1 -0
- package/dist/{check-BBd5xzUi.mjs → check-p5QqYXKY.mjs} +3 -3
- package/dist/cli.mjs +3 -3
- package/dist/{connect-build-B9Btboix.mjs → connect-build-CWR-WRE1.mjs} +4 -4
- package/dist/{connect-build-B9Btboix.mjs.map → connect-build-CWR-WRE1.mjs.map} +1 -1
- package/dist/definitions-worker.d.mts.map +1 -1
- package/dist/definitions-worker.mjs +5 -5
- package/dist/definitions-worker.mjs.map +1 -1
- package/dist/{evidence-Dchpoogs.mjs → evidence-CavwC5YV.mjs} +23 -9
- package/dist/evidence-CavwC5YV.mjs.map +1 -0
- package/dist/{generate-all-_7S0Iii2.mjs → generate-all-cgygbYEX.mjs} +5 -5
- package/dist/generate-all-cgygbYEX.mjs.map +1 -0
- package/dist/{generate-document-model-DCjzz3Sa.mjs → generate-document-model-OQPfeHs-.mjs} +25 -21
- package/dist/generate-document-model-OQPfeHs-.mjs.map +1 -0
- package/dist/{generate-editor-DdoapkEK.mjs → generate-editor-DBj_Pxwa.mjs} +7 -7
- package/dist/generate-editor-DBj_Pxwa.mjs.map +1 -0
- package/dist/{generate-subgraph-CrHbYK91.mjs → generate-subgraph-DJZCr0Tk.mjs} +34 -12
- package/dist/generate-subgraph-DJZCr0Tk.mjs.map +1 -0
- package/dist/{get-version-DUG29IeG.mjs → get-version-CMI7e-aF.mjs} +4 -4
- package/dist/{get-version-DUG29IeG.mjs.map → get-version-CMI7e-aF.mjs.map} +1 -1
- package/dist/{inspect-BpVHe9vz.mjs → inspect-CulIpVsF.mjs} +13 -7
- package/dist/inspect-CulIpVsF.mjs.map +1 -0
- package/dist/{mcp-DEBeM-ZV.mjs → mcp-BXt2elBt.mjs} +4 -4
- package/dist/{mcp-DEBeM-ZV.mjs.map → mcp-BXt2elBt.mjs.map} +1 -1
- package/dist/migrate-subgraphs-Cm7DDcDd.mjs +214 -0
- package/dist/migrate-subgraphs-Cm7DDcDd.mjs.map +1 -0
- package/dist/module-dir-1avCXsBi.mjs +2 -2
- package/dist/module-dir-1avCXsBi.mjs.map +1 -1
- package/dist/ph-cli-commands-3gef5MBB.mjs +4 -0
- package/dist/{ph-cli-commands-BG9deyv9.mjs → ph-cli-commands-BakV37_D.mjs} +43 -22
- package/dist/ph-cli-commands-BakV37_D.mjs.map +1 -0
- package/dist/render-3M3DwFzO.mjs +4 -0
- package/dist/{render-BO-Nwn2H.mjs → render-SVfj3m8A.mjs} +19 -13
- package/dist/render-SVfj3m8A.mjs.map +1 -0
- package/dist/{run-DEKE4MJY.mjs → run--de_-WAz.mjs} +5 -4
- package/dist/run--de_-WAz.mjs.map +1 -0
- package/dist/{run-DP3fNgPv.mjs → run-LRGy7zGo.mjs} +3 -3
- package/dist/runners/connect.mjs +1 -1
- package/dist/runners/switchboard.mjs +1 -1
- package/dist/subgraph-gate-BJ2PWXVY.mjs +26 -0
- package/dist/subgraph-gate-BJ2PWXVY.mjs.map +1 -0
- package/dist/subgraph-gate-j9ywj6KA.mjs +4 -0
- package/dist/subgraphs-7OYWwP-C.mjs +134 -0
- package/dist/subgraphs-7OYWwP-C.mjs.map +1 -0
- package/dist/{switchboard-migrate-Docb8Cjv.mjs → switchboard-migrate-BqSdKJ7u.mjs} +3 -4
- package/dist/switchboard-migrate-BqSdKJ7u.mjs.map +1 -0
- package/dist/{verify-CT24vch8.mjs → verify-B33saw-g.mjs} +4 -4
- package/dist/{verify-CT24vch8.mjs.map → verify-B33saw-g.mjs.map} +1 -1
- package/dist/{vetra-DSFzAl_1.mjs → vetra-DjNt0-L6.mjs} +4 -4
- package/dist/{vetra-DSFzAl_1.mjs.map → vetra-DjNt0-L6.mjs.map} +1 -1
- package/package.json +16 -16
- package/dist/authoring-mode-DWbbsuWh.mjs +0 -23
- package/dist/authoring-mode-DWbbsuWh.mjs.map +0 -1
- package/dist/build-CojYJHNn.mjs.map +0 -1
- package/dist/build-CsUTeki9.mjs +0 -4
- package/dist/check-DWvobZrP.mjs.map +0 -1
- package/dist/evidence-Dchpoogs.mjs.map +0 -1
- package/dist/generate-all-_7S0Iii2.mjs.map +0 -1
- package/dist/generate-document-model-DCjzz3Sa.mjs.map +0 -1
- package/dist/generate-editor-DdoapkEK.mjs.map +0 -1
- package/dist/generate-subgraph-CrHbYK91.mjs.map +0 -1
- package/dist/inspect-BpVHe9vz.mjs.map +0 -1
- package/dist/ph-cli-commands-BG9deyv9.mjs.map +0 -1
- package/dist/ph-cli-commands-Dn56Erg5.mjs +0 -4
- package/dist/render-BO-Nwn2H.mjs.map +0 -1
- package/dist/render-DdieUjtg.mjs +0 -4
- package/dist/run-DEKE4MJY.mjs.map +0 -1
- package/dist/switchboard-migrate-Docb8Cjv.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run--de_-WAz.mjs","sources":["../src/services/model/project.ts","../src/services/model/run.ts"],"sourcesContent":["import {\n uncachedDefinitionSourceRevision,\n ViteTypeScriptSourceImportAdapter,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n DefinitionSourceLoader,\n loadProjectDefinitions,\n type ProjectDefinitions,\n} from \"document-model/tooling\";\nimport { join } from \"node:path\";\n\n/** Imports more of the package through the importer that loaded its definitions. */\nexport type ProjectModules = {\n readonly importModule: (\n specifier: `./${string}`,\n ) => Promise<Readonly<Record<string, unknown>>>;\n};\n\n/**\n * Loads the package's definitions with codegen's Vite importer, hands them to\n * `read`, then disposes the loader. The package's own modules are imported\n * into this process: `ph model` runs it in its own process, `ph build` in the\n * definitions worker.\n */\nexport async function readProjectDefinitions<R>(\n projectRoot: string,\n read: (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ) => R | Promise<R>,\n options: { readonly allowMissingConfig?: boolean } = {},\n): Promise<R> {\n const importer = new ViteTypeScriptSourceImportAdapter();\n const loader = new DefinitionSourceLoader(importer);\n const packageRevision = uncachedDefinitionSourceRevision();\n try {\n const project = await loadProjectDefinitions({\n loader,\n configFile: join(projectRoot, \"powerhouse.config.json\"),\n ...(options.allowMissingConfig === true && { allowMissingConfig: true }),\n packageRevision,\n importedFiles: (specifier) => importer.filesImportedBy(specifier),\n });\n return await read(project, {\n importModule: (specifier) =>\n importer.importModule({\n packageRoot: project.packageRoot,\n specifier,\n packageRevision,\n }),\n });\n } finally {\n await loader.dispose();\n }\n}\n","import type { DefinitionCheckReport } from \"@powerhousedao/shared/document-model\";\nimport type { ProjectDefinitions } from \"document-model/tooling\";\nimport { type ProjectModules, readProjectDefinitions } from \"./project.js\";\n\nexport type ModelStreams = {\n readonly out: (text: string) => void;\n readonly err: (text: string) => void;\n};\n\nexport type ModelRunOptions = {\n /** Default: the directory ph-cli runs in, which ph-cmd sets to the project root. */\n readonly projectRoot?: string;\n readonly streams?: ModelStreams;\n};\n\ntype Status = DefinitionCheckReport[\"status\"];\n\nconst EXIT_CODES: Readonly<Record<Status, 0 | 1 | 2>> = {\n ok: 0,\n skipped: 0,\n invalid: 1,\n failed: 2,\n};\n\nexport const processStreams: ModelStreams = {\n out: (text) => void process.stdout.write(text),\n err: (text) => void process.stderr.write(text),\n};\n\n/** Sends what is written to stdout to `write` until the returned restore runs. */\nfunction redirectStdout(write: (text: string) => void): () => void {\n const original = process.stdout.write.bind(process.stdout);\n process.stdout.write = ((chunk: string | Uint8Array, ...rest: unknown[]) => {\n write(typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString());\n const callback = rest.find((value) => typeof value === \"function\");\n (callback as (() => void) | undefined)?.();\n return true;\n }) as typeof process.stdout.write;\n return () => {\n process.stdout.write = original;\n };\n}\n\n/** Vite and the package's own modules may print while they load. */\nasync function stdoutTo<T>(\n write: (text: string) => void,\n work: () => Promise<T>,\n): Promise<T> {\n const restore = redirectStdout(write);\n try {\n return await work();\n } finally {\n restore();\n }\n}\n\n/**\n * Loads the project once, builds a report from it and prints the report.\n * Returns the exit code: 0 ok or skipped, 1 invalid, 2 failed or not run.\n * Any throw, from loading through printing, is exit 2: exit 1 means the\n * models were read and one is wrong.\n */\nexport async function runModelCommand<R extends { readonly status: Status }>(\n request: {\n readonly name: string;\n readonly json: boolean;\n readonly read: (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ) => R | Promise<R>;\n readonly render: (report: R) => string;\n },\n options: ModelRunOptions,\n): Promise<number> {\n const streams = options.streams ?? processStreams;\n const projectRoot = options.projectRoot ?? process.cwd();\n try {\n const report = await stdoutTo(streams.err, () =>\n readProjectDefinitions(projectRoot, request.read),\n );\n const text = request.json ? JSON.stringify(report) : request.render(report);\n streams.out(`${text}\\n`);\n return EXIT_CODES[report.status];\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n streams.err(`${request.name} could not run: ${message}\\n`);\n return 2;\n }\n}\n\n/**\n * Runs a `ph model` command as the process and exits with its code once\n * stdout and stderr have flushed. Returning instead would let a timer that a\n * package module started keep the process alive after the report.\n *\n * With `--json`, stdout belongs to the report for the whole run: anything\n * else printed, even by a module's timer after loading, goes to stderr. The\n * report goes out through the writer saved before the redirect.\n */\nexport async function exitWithModelCommand(\n json: boolean,\n run: (streams: ModelStreams) => Promise<number>,\n): Promise<never> {\n const writeStdout = process.stdout.write.bind(process.stdout);\n const streams: ModelStreams = json\n ? { out: (text) => void writeStdout(text), err: processStreams.err }\n : processStreams;\n if (json) redirectStdout(processStreams.err);\n const code = await run(streams);\n return await new Promise<never>(() => {\n process.stderr.write(\"\", () => writeStdout(\"\", () => process.exit(code)));\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBA,eAAsB,uBACpB,aACA,MAIA,UAAqD,CA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AAI;CACvD,IAAI;EACF,MAAM,SAAS,MAAM,SAAS,QAAQ,WACpC,uBAAuB,aAAa,QAAQ,IAAI,CAClD;EACA,MAAM,OAAO,QAAQ,OAAO,KAAK,UAAU,MAAM,IAAI,QAAQ,OAAO,MAAM;EAC1E,QAAQ,IAAI,GAAG,KAAK,GAAG;EACvB,OAAO,WAAW,OAAO;CAC3B,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,QAAQ,IAAI,GAAG,QAAQ,KAAK,kBAAkB,QAAQ,GAAG;EACzD,OAAO;CACT;AACF;;;;;;;;;;AAWA,eAAsB,qBACpB,MACA,KACgB;CAChB,MAAM,cAAc,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;CAC5D,MAAM,UAAwB,OAC1B;EAAE,MAAM,SAAS,KAAK,YAAY,IAAI;EAAG,KAAK,eAAe;CAAI,IACjE;CACJ,IAAI,MAAM,eAAe,eAAe,GAAG;CAC3C,MAAM,OAAO,MAAM,IAAI,OAAO;CAC9B,OAAO,MAAM,IAAI,cAAqB;EACpC,QAAQ,OAAO,MAAM,UAAU,YAAY,UAAU,QAAQ,KAAK,IAAI,CAAC,CAAC;CAC1E,CAAC;AACH","debug_id":"66d6833e-9bf6-50d7-896a-8bee425c7813"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as processStreams, r as runModelCommand, t as exitWithModelCommand } from "./run-
|
|
1
|
+
import { n as processStreams, r as runModelCommand, t as exitWithModelCommand } from "./run--de_-WAz.mjs";
|
|
2
2
|
export { exitWithModelCommand, processStreams, runModelCommand };
|
|
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]="
|
|
4
|
-
//# debugId=
|
|
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]="dc8c8bd5-b7a2-5113-aa54-15d42584cad0")}catch(e){}}();
|
|
4
|
+
//# debugId=dc8c8bd5-b7a2-5113-aa54-15d42584cad0
|
package/dist/runners/connect.mjs
CHANGED
|
@@ -46,7 +46,7 @@ const run = dev;
|
|
|
46
46
|
/** P3.3 — `build`: the SAME service as classic `ph connect build`. */
|
|
47
47
|
async function build(host, ctx) {
|
|
48
48
|
await validateComposition(host, ctx);
|
|
49
|
-
const { runConnectBuild } = await import("../connect-build-
|
|
49
|
+
const { runConnectBuild } = await import("../connect-build-CWR-WRE1.mjs");
|
|
50
50
|
await runConnectBuild({ outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR }, callerOverride(host, ctx, ctx.verb), { routes: host.runner.routes });
|
|
51
51
|
}
|
|
52
52
|
/** Opening a browser is a developer's convenience, and vite's to give, which
|
|
@@ -11,7 +11,7 @@ const verbs = [
|
|
|
11
11
|
/** Build the project's reactor package (the SAME service as `ph build`) — what
|
|
12
12
|
* this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
|
|
13
13
|
async function build(host, _ctx) {
|
|
14
|
-
const { runBuild } = await import("../build-
|
|
14
|
+
const { runBuild } = await import("../build-pOI4h7Mm.mjs");
|
|
15
15
|
await runBuild({ outDir: host.runner.outDir ?? "dist" });
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
@@ -0,0 +1,26 @@
|
|
|
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]="f0cdc57f-1f84-5df8-b36b-c959c435cfc3")}catch(e){}}();
|
|
3
|
+
import { statSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { subgraphDirStyles } from "@powerhousedao/codegen/utils";
|
|
6
|
+
//#region src/services/model/subgraph-gate.ts
|
|
7
|
+
const SUBGRAPHS_ENTRY = "./subgraphs/index.ts";
|
|
8
|
+
/** A project without `subgraphs/index.ts` serves no subgraph, so it has none. */
|
|
9
|
+
function scanSubgraphs(projectRoot) {
|
|
10
|
+
const entry = join(projectRoot, SUBGRAPHS_ENTRY);
|
|
11
|
+
if (!(statSync(entry, { throwIfNoEntry: false })?.isFile() ?? false)) return {
|
|
12
|
+
hasCodeFirst: false,
|
|
13
|
+
schemaFirstUnits: []
|
|
14
|
+
};
|
|
15
|
+
const dirs = subgraphDirStyles(join(projectRoot, "subgraphs"));
|
|
16
|
+
return {
|
|
17
|
+
hasCodeFirst: dirs.some(({ style }) => style === "code-first"),
|
|
18
|
+
schemaFirstUnits: dirs.filter(({ style }) => style === "schema-first").map(({ dirName }) => dirName)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const hasCodeFirstSubgraph = (projectRoot) => scanSubgraphs(projectRoot).hasCodeFirst;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { hasCodeFirstSubgraph as n, scanSubgraphs as r, SUBGRAPHS_ENTRY as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=subgraph-gate-BJ2PWXVY.mjs.map
|
|
26
|
+
//# debugId=f0cdc57f-1f84-5df8-b36b-c959c435cfc3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-gate-BJ2PWXVY.mjs","sources":["../src/services/model/subgraph-gate.ts"],"sourcesContent":["import { subgraphDirStyles } from \"@powerhousedao/codegen/utils\";\nimport { statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport const SUBGRAPHS_ENTRY = \"./subgraphs/index.ts\";\n\nexport type SubgraphStyles = {\n readonly hasCodeFirst: boolean;\n readonly schemaFirstUnits: readonly string[];\n};\n\n/** A project without `subgraphs/index.ts` serves no subgraph, so it has none. */\nexport function scanSubgraphs(projectRoot: string): SubgraphStyles {\n const entry = join(projectRoot, SUBGRAPHS_ENTRY);\n if (!(statSync(entry, { throwIfNoEntry: false })?.isFile() ?? false))\n return { hasCodeFirst: false, schemaFirstUnits: [] };\n const dirs = subgraphDirStyles(join(projectRoot, \"subgraphs\"));\n return {\n hasCodeFirst: dirs.some(({ style }) => style === \"code-first\"),\n schemaFirstUnits: dirs\n .filter(({ style }) => style === \"schema-first\")\n .map(({ dirName }) => dirName),\n };\n}\n\nexport const hasCodeFirstSubgraph = (projectRoot: string) =>\n scanSubgraphs(projectRoot).hasCodeFirst;\n"],"names":[],"mappings":";;;;;;AAIA,MAAa,kBAAkB;;AAQ/B,SAAgB,cAAc,aAAqC;CACjE,MAAM,QAAQ,KAAK,aAAa,eAAe;CAC/C,IAAI,EAAE,SAAS,OAAO,EAAE,gBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,KAAK,QAC5D,OAAO;EAAE,cAAc;EAAO,kBAAkB,CAAC;CAAE;CACrD,MAAM,OAAO,kBAAkB,KAAK,aAAa,WAAW,CAAC;CAC7D,OAAO;EACL,cAAc,KAAK,MAAM,EAAE,YAAY,UAAU,YAAY;EAC7D,kBAAkB,KACf,QAAQ,EAAE,YAAY,UAAU,cAAc,CAAC,CAC/C,KAAK,EAAE,cAAc,OAAO;CACjC;AACF;AAEA,MAAa,wBAAwB,gBACnC,cAAc,WAAW,CAAC,CAAC","debug_id":"f0cdc57f-1f84-5df8-b36b-c959c435cfc3"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { n as hasCodeFirstSubgraph } from "./subgraph-gate-BJ2PWXVY.mjs";
|
|
2
|
+
export { hasCodeFirstSubgraph };
|
|
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]="5eaba0b5-4ee9-5473-b64d-7418a6e9e9db")}catch(e){}}();
|
|
4
|
+
//# debugId=5eaba0b5-4ee9-5473-b64d-7418a6e9e9db
|
|
@@ -0,0 +1,134 @@
|
|
|
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]="1d9c1c84-45e5-55d7-970d-52f2a0d6a487")}catch(e){}}();
|
|
3
|
+
import { r as scanSubgraphs, t as SUBGRAPHS_ENTRY } from "./subgraph-gate-BJ2PWXVY.mjs";
|
|
4
|
+
import { readFileSync, statSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { readSubgraphDefinitions, subgraphCheckInput } from "document-model/tooling";
|
|
7
|
+
import { projectSubgraphGraphQL } from "document-model";
|
|
8
|
+
import { parse, print } from "graphql";
|
|
9
|
+
//#region src/services/model/schema-first/sdl-sources.ts
|
|
10
|
+
const SDL_FILES = [
|
|
11
|
+
["schema.graphql", "graphql"],
|
|
12
|
+
["schema.ts", "typescript"],
|
|
13
|
+
["index.ts", "typescript"]
|
|
14
|
+
];
|
|
15
|
+
const LITERAL_NAME = /\bname(?:\s*:\s*string)?\s*=\s*["'`]([^"'`$]+)["'`]/;
|
|
16
|
+
function readText(path) {
|
|
17
|
+
if (!(statSync(path, { throwIfNoEntry: false })?.isFile() ?? false)) return null;
|
|
18
|
+
return readFileSync(path, "utf8");
|
|
19
|
+
}
|
|
20
|
+
function schemaFirstSource(projectRoot, dir) {
|
|
21
|
+
const unit = `./subgraphs/${dir}/`;
|
|
22
|
+
const name = readText(join(projectRoot, "subgraphs", dir, "index.ts"))?.match(LITERAL_NAME)?.[1] ?? null;
|
|
23
|
+
for (const [file, language] of SDL_FILES) {
|
|
24
|
+
const text = readText(join(projectRoot, "subgraphs", dir, file));
|
|
25
|
+
if (text !== null) return {
|
|
26
|
+
unit,
|
|
27
|
+
name,
|
|
28
|
+
source: { specifier: `${unit}${file}` },
|
|
29
|
+
language,
|
|
30
|
+
text
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
unit,
|
|
35
|
+
name,
|
|
36
|
+
source: { specifier: `${unit}index.ts` },
|
|
37
|
+
language: "typescript",
|
|
38
|
+
text: null
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/services/model/subgraphs.ts
|
|
43
|
+
const SCALARS_ENTRY = "./scalars/index.ts";
|
|
44
|
+
/** A module that hangs on a top-level await must not hang `ph model`. */
|
|
45
|
+
const IMPORT_TIMEOUT_MS = 6e4;
|
|
46
|
+
async function importModule(modules, specifier, packageRoot, timeoutMs) {
|
|
47
|
+
let timer;
|
|
48
|
+
const timeout = new Promise((_, reject) => {
|
|
49
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`it did not finish loading within ${timeoutMs / 1e3} seconds`)), timeoutMs);
|
|
50
|
+
timer.unref();
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
return {
|
|
54
|
+
ok: true,
|
|
55
|
+
namespace: await Promise.race([modules.importModule(specifier), timeout])
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
failure: {
|
|
61
|
+
specifier,
|
|
62
|
+
reason: (error instanceof Error ? error.message : String(error)).replaceAll(packageRoot, ".")
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
} finally {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** The host's admission of the code-first subgraphs, replayed against its built-in subgraphs and the package's document models. */
|
|
70
|
+
async function replayHostAdmission({ subgraphs }, artifacts) {
|
|
71
|
+
if (subgraphs.length === 0) return [];
|
|
72
|
+
const models = new Map(artifacts.map(({ documentType, documentModel }) => [documentType, documentModel.global]));
|
|
73
|
+
const { findPackageSubgraphConflicts } = await import("@powerhousedao/reactor-api/subgraph-types");
|
|
74
|
+
const { conflicts } = await findPackageSubgraphConflicts(subgraphs.map(({ name, definition }) => ({
|
|
75
|
+
name,
|
|
76
|
+
typeDefs: parse(print(projectSubgraphGraphQL(definition)))
|
|
77
|
+
})), [...models.values()]);
|
|
78
|
+
return Array.from(conflicts).flatMap(([subgraph, { nameHeldBy, claims }]) => nameHeldBy === "package" ? [] : [{
|
|
79
|
+
subgraph,
|
|
80
|
+
...nameHeldBy !== void 0 && { nameHeldBy },
|
|
81
|
+
claims
|
|
82
|
+
}]);
|
|
83
|
+
}
|
|
84
|
+
const usesPackageScalars = ({ subgraphs }) => subgraphs.some(({ definition }) => definition.scalars.some(({ implementation }) => implementation.startsWith("package#")));
|
|
85
|
+
/**
|
|
86
|
+
* `undefined` when the project has no code-first subgraph: then nothing here
|
|
87
|
+
* imports a module, and projects without one keep the reports they had. A
|
|
88
|
+
* module that fails or outlives `timeoutMs` becomes a diagnostic.
|
|
89
|
+
*/
|
|
90
|
+
async function readProjectSubgraphs(project, modules, timeoutMs = IMPORT_TIMEOUT_MS) {
|
|
91
|
+
const root = project.packageRoot;
|
|
92
|
+
const styles = scanSubgraphs(root);
|
|
93
|
+
if (!styles.hasCodeFirst) return void 0;
|
|
94
|
+
const schemaFirst = styles.schemaFirstUnits.map((dir) => schemaFirstSource(root, dir));
|
|
95
|
+
const subgraphs = await importModule(modules, SUBGRAPHS_ENTRY, root, timeoutMs);
|
|
96
|
+
if (!subgraphs.ok) return subgraphCheckInput({
|
|
97
|
+
definitions: {
|
|
98
|
+
subgraphs: [],
|
|
99
|
+
diagnostics: []
|
|
100
|
+
},
|
|
101
|
+
schemaFirst,
|
|
102
|
+
importFailures: [subgraphs.failure]
|
|
103
|
+
});
|
|
104
|
+
const definitions = readSubgraphDefinitions(subgraphs.namespace, { specifier: SUBGRAPHS_ENTRY });
|
|
105
|
+
const hostConflicts = await replayHostAdmission(definitions, project.artifacts);
|
|
106
|
+
if (!usesPackageScalars(definitions)) return subgraphCheckInput({
|
|
107
|
+
definitions,
|
|
108
|
+
schemaFirst,
|
|
109
|
+
hostConflicts
|
|
110
|
+
});
|
|
111
|
+
if (!(statSync(join(root, SCALARS_ENTRY), { throwIfNoEntry: false })?.isFile() ?? false)) return subgraphCheckInput({
|
|
112
|
+
definitions,
|
|
113
|
+
schemaFirst,
|
|
114
|
+
hostConflicts,
|
|
115
|
+
scalars: null
|
|
116
|
+
});
|
|
117
|
+
const scalars = await importModule(modules, SCALARS_ENTRY, root, timeoutMs);
|
|
118
|
+
return subgraphCheckInput(scalars.ok ? {
|
|
119
|
+
definitions,
|
|
120
|
+
schemaFirst,
|
|
121
|
+
hostConflicts,
|
|
122
|
+
scalars: scalars.namespace
|
|
123
|
+
} : {
|
|
124
|
+
definitions,
|
|
125
|
+
schemaFirst,
|
|
126
|
+
hostConflicts,
|
|
127
|
+
importFailures: [scalars.failure]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
export { readProjectSubgraphs as t };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=subgraphs-7OYWwP-C.mjs.map
|
|
134
|
+
//# debugId=1d9c1c84-45e5-55d7-970d-52f2a0d6a487
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraphs-7OYWwP-C.mjs","sources":["../src/services/model/schema-first/sdl-sources.ts","../src/services/model/subgraphs.ts"],"sourcesContent":["import type { SchemaFirstSubgraphSource } from \"document-model/tooling\";\nimport { readFileSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst SDL_FILES: readonly (readonly [\n string,\n SchemaFirstSubgraphSource[\"language\"],\n])[] = [\n [\"schema.graphql\", \"graphql\"],\n [\"schema.ts\", \"typescript\"],\n [\"index.ts\", \"typescript\"],\n];\n\nconst LITERAL_NAME = /\\bname(?:\\s*:\\s*string)?\\s*=\\s*[\"'`]([^\"'`$]+)[\"'`]/;\n\nfunction readText(path: string): string | null {\n if (!(statSync(path, { throwIfNoEntry: false })?.isFile() ?? false)) {\n return null;\n }\n return readFileSync(path, \"utf8\");\n}\n\nexport function schemaFirstSource(\n projectRoot: string,\n dir: string,\n): SchemaFirstSubgraphSource {\n const unit = `./subgraphs/${dir}/` as const;\n const index = readText(join(projectRoot, \"subgraphs\", dir, \"index.ts\"));\n const name = index?.match(LITERAL_NAME)?.[1] ?? null;\n for (const [file, language] of SDL_FILES) {\n const text = readText(join(projectRoot, \"subgraphs\", dir, file));\n if (text !== null) {\n return {\n unit,\n name,\n source: { specifier: `${unit}${file}` },\n language,\n text,\n };\n }\n }\n return {\n unit,\n name,\n source: { specifier: `${unit}index.ts` },\n language: \"typescript\",\n text: null,\n };\n}\n","import { projectSubgraphGraphQL } from \"document-model\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport {\n type ProjectDefinitions,\n readSubgraphDefinitions,\n subgraphCheckInput,\n type SubgraphCheckInput,\n type SubgraphDefinitions,\n type SubgraphHostConflict,\n type SubgraphImportFailure,\n type SubgraphInventoryEntry,\n} from \"document-model/tooling\";\nimport { statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ProjectModules } from \"./project.js\";\nimport { schemaFirstSource } from \"./schema-first/sdl-sources.js\";\nimport { scanSubgraphs, SUBGRAPHS_ENTRY } from \"./subgraph-gate.js\";\n\nconst SCALARS_ENTRY = \"./scalars/index.ts\";\n\n/** A module that hangs on a top-level await must not hang `ph model`. */\nconst IMPORT_TIMEOUT_MS = 60_000;\n\nexport type ProjectSubgraphs = {\n readonly input: SubgraphCheckInput;\n readonly inventory: readonly SubgraphInventoryEntry[];\n};\n\ntype Imported =\n | { readonly ok: true; readonly namespace: object }\n | { readonly ok: false; readonly failure: SubgraphImportFailure };\n\nasync function importModule(\n modules: ProjectModules,\n specifier: `./${string}`,\n packageRoot: string,\n timeoutMs: number,\n): Promise<Imported> {\n let timer: NodeJS.Timeout | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () =>\n reject(\n new Error(\n `it did not finish loading within ${timeoutMs / 1000} seconds`,\n ),\n ),\n timeoutMs,\n );\n timer.unref();\n });\n try {\n return {\n ok: true,\n namespace: await Promise.race([modules.importModule(specifier), timeout]),\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n ok: false,\n failure: { specifier, reason: message.replaceAll(packageRoot, \".\") },\n };\n } finally {\n clearTimeout(timer);\n }\n}\n\n/** The host's admission of the code-first subgraphs, replayed against its built-in subgraphs and the package's document models. */\nasync function replayHostAdmission(\n { subgraphs }: SubgraphDefinitions,\n artifacts: ProjectDefinitions[\"artifacts\"],\n): Promise<readonly SubgraphHostConflict[]> {\n if (subgraphs.length === 0) return [];\n const models = new Map(\n artifacts.map(({ documentType, documentModel }) => [\n documentType,\n documentModel.global,\n ]),\n );\n const { findPackageSubgraphConflicts } =\n await import(\"@powerhousedao/reactor-api/subgraph-types\");\n const { conflicts } = await findPackageSubgraphConflicts(\n subgraphs.map(({ name, definition }) => ({\n name,\n // The host serves the printed projection, parsed again.\n typeDefs: parse(\n print(projectSubgraphGraphQL(definition) as unknown as DocumentNode),\n ),\n })),\n [...models.values()],\n );\n return Array.from(conflicts).flatMap(\n ([subgraph, { nameHeldBy, claims }]): SubgraphHostConflict[] =>\n nameHeldBy === \"package\"\n ? []\n : [\n {\n subgraph,\n ...(nameHeldBy !== undefined && { nameHeldBy }),\n claims,\n },\n ],\n );\n}\n\nconst usesPackageScalars = ({ subgraphs }: SubgraphDefinitions) =>\n subgraphs.some(({ definition }) =>\n definition.scalars.some(({ implementation }) =>\n implementation.startsWith(\"package#\"),\n ),\n );\n\n/**\n * `undefined` when the project has no code-first subgraph: then nothing here\n * imports a module, and projects without one keep the reports they had. A\n * module that fails or outlives `timeoutMs` becomes a diagnostic.\n */\nexport async function readProjectSubgraphs(\n project: Pick<ProjectDefinitions, \"packageRoot\" | \"artifacts\">,\n modules: ProjectModules,\n timeoutMs: number = IMPORT_TIMEOUT_MS,\n): Promise<ProjectSubgraphs | undefined> {\n const root = project.packageRoot;\n const styles = scanSubgraphs(root);\n if (!styles.hasCodeFirst) return undefined;\n const schemaFirst = styles.schemaFirstUnits.map((dir) =>\n schemaFirstSource(root, dir),\n );\n const subgraphs = await importModule(\n modules,\n SUBGRAPHS_ENTRY,\n root,\n timeoutMs,\n );\n if (!subgraphs.ok) {\n return subgraphCheckInput({\n definitions: { subgraphs: [], diagnostics: [] },\n schemaFirst,\n importFailures: [subgraphs.failure],\n });\n }\n const definitions = readSubgraphDefinitions(subgraphs.namespace, {\n specifier: SUBGRAPHS_ENTRY,\n });\n const hostConflicts = await replayHostAdmission(\n definitions,\n project.artifacts,\n );\n if (!usesPackageScalars(definitions)) {\n return subgraphCheckInput({ definitions, schemaFirst, hostConflicts });\n }\n if (\n !(\n statSync(join(root, SCALARS_ENTRY), {\n throwIfNoEntry: false,\n })?.isFile() ?? false\n )\n ) {\n return subgraphCheckInput({\n definitions,\n schemaFirst,\n hostConflicts,\n scalars: null,\n });\n }\n const scalars = await importModule(modules, SCALARS_ENTRY, root, timeoutMs);\n return subgraphCheckInput(\n scalars.ok\n ? { definitions, schemaFirst, hostConflicts, scalars: scalars.namespace }\n : {\n definitions,\n schemaFirst,\n hostConflicts,\n importFailures: [scalars.failure],\n },\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,YAGC;CACL,CAAC,kBAAkB,SAAS;CAC5B,CAAC,aAAa,YAAY;CAC1B,CAAC,YAAY,YAAY;AAC3B;AAEA,MAAM,eAAe;AAErB,SAAS,SAAS,MAA6B;CAC7C,IAAI,EAAE,SAAS,MAAM,EAAE,gBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,KAAK,QAC3D,OAAO;CAET,OAAO,aAAa,MAAM,MAAM;AAClC;AAEA,SAAgB,kBACd,aACA,KAC2B;CAC3B,MAAM,OAAO,eAAe,IAAI;CAEhC,MA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C1E,OAAO,mBACL,QAAQ,KACJ;EAAE;EAAa;EAAa;EAAe,SAAS,QAAQ;CAAU,IACtE;EACE;EACA;EACA;EACA,gBAAgB,CAAC,QAAQ,OAAO;CAClC,CACN;AACF","debug_id":"1d9c1c84-45e5-55d7-970d-52f2a0d6a487"}
|
|
@@ -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]="a4590bf9-a7c1-5c1d-acb0-f386667abb71")}catch(e){}}();
|
|
3
3
|
import { REACTOR_SCHEMA, getMigrationStatus, runMigrations } from "@powerhousedao/reactor";
|
|
4
4
|
import { Kysely, PostgresDialect } from "kysely";
|
|
5
5
|
import { Pool } from "pg";
|
|
@@ -14,7 +14,6 @@ async function runSwitchboardMigrations(options) {
|
|
|
14
14
|
console.log("(PGlite migrations are handled automatically on startup)");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
console.log(`Database: ${dbPath}`);
|
|
18
17
|
const pool = new Pool({ connectionString: dbPath });
|
|
19
18
|
const db = new Kysely({ dialect: new PostgresDialect({ pool }) });
|
|
20
19
|
try {
|
|
@@ -50,5 +49,5 @@ async function runSwitchboardMigrations(options) {
|
|
|
50
49
|
//#endregion
|
|
51
50
|
export { runSwitchboardMigrations };
|
|
52
51
|
|
|
53
|
-
//# sourceMappingURL=switchboard-migrate-
|
|
54
|
-
//# debugId=
|
|
52
|
+
//# sourceMappingURL=switchboard-migrate-BqSdKJ7u.mjs.map
|
|
53
|
+
//# debugId=a4590bf9-a7c1-5c1d-acb0-f386667abb71
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switchboard-migrate-BqSdKJ7u.mjs","sources":["../src/services/switchboard-migrate.ts"],"sourcesContent":["import { Kysely, PostgresDialect } from \"kysely\";\nimport { Pool } from \"pg\";\nimport {\n runMigrations,\n getMigrationStatus,\n REACTOR_SCHEMA,\n} from \"@powerhousedao/reactor\";\n\ninterface MigrationOptions {\n dbPath?: string;\n statusOnly?: boolean;\n}\n\nfunction isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nexport async function runSwitchboardMigrations(\n options: MigrationOptions,\n): Promise<void> {\n const dbPath =\n options.dbPath ??\n process.env.PH_REACTOR_DATABASE_URL ??\n process.env.DATABASE_URL;\n\n if (!dbPath || !isPostgresUrl(dbPath)) {\n console.log(\"No PostgreSQL URL configured. Skipping migrations.\");\n console.log(\"(PGlite migrations are handled automatically on startup)\");\n return;\n }\n\n const pool = new Pool({ connectionString: dbPath });\n\n const db = new Kysely<any>({\n dialect: new PostgresDialect({ pool }),\n });\n\n try {\n if (options.statusOnly) {\n console.log(\"\\nChecking migration status...\");\n const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);\n\n console.log(\"\\nMigration Status:\");\n console.log(\"=================\");\n\n for (const migration of migrations) {\n const status = migration.executedAt\n ? `[OK] Executed at ${migration.executedAt.toISOString()}`\n : \"[--] Pending\";\n console.log(`${status} - ${migration.name}`);\n }\n } else {\n console.log(\"\\nRunning migrations...\");\n const result = await runMigrations(db, REACTOR_SCHEMA);\n\n if (!result.success) {\n console.error(\"Migration failed:\", result.error?.message);\n process.exit(1);\n }\n\n if (result.migrationsExecuted.length === 0) {\n console.log(\"No migrations to run - database is up to date\");\n } else {\n console.log(\n `Successfully executed ${result.migrationsExecuted.length} migration(s):`,\n );\n for (const name of result.migrationsExecuted) {\n console.log(` - ${name}`);\n }\n }\n }\n } catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n"],"names":[],"mappings":";;;;;;AAaA,SAAS,cAAc,KAAsB;CAC3C,OAAO,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,aAAa;AACxE;AAEA,eAAsB,yBACpB,SACe;CACf,MAAM,SACJ,QAAQ,UACR,QAAQ,IAAI,2BACZ,QAAQ,IAAI;CAEd,IAAI,CAAC,UAAU,CAAC,cAAc,MAAM,GAAG;EACrC,QAAQ,IAAI,oDAAoD;EAChE,QAAQ,IAAI,0DAA0D;EACtE;CACF;CAEA,MAAM,OAAO,IAAI,KAAK,EAAE,kBAAkB,OAAO,CAAC;CAElD,MAAM,KAAK,IAAI,OAAY,EACzB,SAAS,IAAI,gBAAgB,EAAE,KAAK,CAAC,EACvC,CAAC;CAED,IAAI;EACF,IAAI,QAAQ,YAAY;GACtB,QAAQ,IAAI,gCAAgC;GAC5C,MAAM,aAAa,MAAM,mBAAmB,IAAI,cAAc;GAE9D,QAAQ,IAAI,qBAAqB;GACjC,QAAQ,IAAI,mBAAmB;GAE/B,KAAK,MAAM,aAAa,YAAY;IAClC,MAAM,SAAS,UAAU,aACrB,oBAAoB,UAAU,WAAW,YAAY,MACrD;IACJ,QAAQ,IAAI,GAAG,OAAO,KAAK,UAAU,MAAM;GAC7C;EACF,OAAO;GACL,QAAQ,IAAI,yBAAyB;GACrC,MAAM,SAAS,MAAM,cAAc,IAAI,cAAc;GAErD,IAAI,CAAC,OAAO,SAAS;IACnB,QAAQ,MAAM,qBAAqB,OAAO,OAAO,OAAO;IACxD,QAAQ,KAAK,CAAC;GAChB;GAEA,IAAI,OAAO,mBAAmB,WAAW,GACvC,QAAQ,IAAI,+CAA+C;QACtD;IACL,QAAQ,IACN,yBAAyB,OAAO,mBAAmB,OAAO,eAC5D;IACA,KAAK,MAAM,QAAQ,OAAO,oBACxB,QAAQ,IAAI,OAAO,MAAM;GAE7B;EACF;CACF,SAAS,OAAO;EACd,QAAQ,MACN,UACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;EACA,QAAQ,KAAK,CAAC;CAChB,UAAU;EACR,MAAM,GAAG,QAAQ;CACnB;AACF","debug_id":"a4590bf9-a7c1-5c1d-acb0-f386667abb71"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { t as getVersion } from "./get-version-
|
|
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]="e666c3a1-863a-5349-be62-fcbc75e4f3f7")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-CMI7e-aF.mjs";
|
|
4
4
|
import { f as verifyReleaseApproval, i as revisionFiles, n as publishedFiles, o as packRelease, r as readReleaseApproval, s as packedDigests, u as decisionWithoutApproval } from "./files-D6_euBBn.mjs";
|
|
5
5
|
//#region src/services/release/verify.ts
|
|
6
6
|
/**
|
|
@@ -67,5 +67,5 @@ function checkApprovalBeforePublish(packageRoot, required) {
|
|
|
67
67
|
//#endregion
|
|
68
68
|
export { checkApprovalBeforePublish, renderReleaseDecision, verifyRelease };
|
|
69
69
|
|
|
70
|
-
//# sourceMappingURL=verify-
|
|
71
|
-
//# debugId=
|
|
70
|
+
//# sourceMappingURL=verify-B33saw-g.mjs.map
|
|
71
|
+
//# debugId=e666c3a1-863a-5349-be62-fcbc75e4f3f7
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-B33saw-g.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OAAqB,oBAAoB,WAAW,GACpD,WACiB;CACjB,IAAI,KAAK,SAAS,SAAS,OAAO,wBAAwB,IAAI;CAC9D,MAAM,EAAE,aAAa;CACrB,OAAO,sBAAsB,UAAU;EACrC,cAAc,WAAW;EACzB,OAAO,cAAc,aAAa,CAChC,SAAS,QACT,GAAG,SAAS,gBAAgB,QAC9B,CAAC;EACD,gBAAgB,aAAa,eAAe,WAAW;CACzD,CAAC;AACH;AAEA,MAAM,YAAmE;CACvE,UAAU;CACV,SAAS;CACT,YAAY;CACZ,OAAO;CACP,SAAS;AACX;;AAGA,SAAgB,sBAAsB,UAAmC;CACvE,OAAO,CACL,GAAG,SAAS,SAAS,IAAI,UAAU,SAAS,aAC5C,GAAG,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,CACrD,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;;AAiBA,SAAgB,2BACd,aACA,UACc;CACd,MAAM,OAAO,oBAAoB,WAAW;CAC5C,IAAI,KAAK,SAAS,aAAa,CAAC,UAAU,OAAO,EAAE,SAAS,KAAK;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CACf,IAAI;EACF,IAAI,YAAY,KAAK,SAAS,SAAS,SAAS,YAAY,WAAW;EACvE,MAAM,WAAW,cACf,aACA,MACA,UAAU,cAAc,MAAM,CAChC;EACA,WAAW,SAAS,aAAa;EACjC,OAAO,sBAAsB,QAAQ;CACvC,SAAS,OAAO;EACd,OAAO,8CAA8C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC5G;CACA,IAAI,UAAU;EACZ,QAAQ,IAAI,KAAK,MAAM;EACvB,OAAO;GAAE,SAAS;GAAM;EAAO;CACjC;CACA,QAAQ,QAAQ;CAChB,IAAI,UAAU;EACZ,QAAQ,MACN,KAAK,KAAK,gHACZ;EACA,OAAO,EAAE,SAAS,MAAM;CAC1B;CACA,QAAQ,KACN,KAAK,KAAK,sHACZ;CACA,OAAO,EAAE,SAAS,KAAK;AACzB","debug_id":"e666c3a1-863a-5349-be62-fcbc75e4f3f7"}
|
|
@@ -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]="5b1c4e98-eac3-5feb-a1ed-c7534fa307d2")}catch(e){}}();
|
|
3
3
|
import { i as mergeDefaultDrives, o as rebaseDriveUrl } from "./dist-B-_lMGlB.mjs";
|
|
4
4
|
import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed } from "./cli-connect-override-D3N3gbp_.mjs";
|
|
5
5
|
import { t as runConnectStudio } from "./connect-studio-C7Bbh50O.mjs";
|
|
@@ -9,11 +9,11 @@ import { join } from "node:path";
|
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
10
|
import { blue, green, red, yellow } from "colorette";
|
|
11
11
|
import { getConfig } from "@powerhousedao/shared/clis";
|
|
12
|
+
import { childLogger, setLogLevel } from "document-model";
|
|
12
13
|
import { createLogger } from "vite";
|
|
13
14
|
import { createVetraDocument, getVetraDocuments, setPackageGithubUrl } from "@powerhousedao/common/utils";
|
|
14
15
|
import { VETRA_PROCESSOR_CONFIG_KEY } from "@powerhousedao/config";
|
|
15
16
|
import { addDefaultDrive } from "@powerhousedao/switchboard/utils";
|
|
16
|
-
import { childLogger, setLogLevel } from "document-model";
|
|
17
17
|
import { createInterface } from "node:readline";
|
|
18
18
|
import { isPortAvailable } from "@powerhousedao/switchboard/server";
|
|
19
19
|
import { POWERHOUSE_DRIVE_ICON, seedWorkflowsDrive, startSwitchboard } from "@powerhousedao/ph-run/switchboard";
|
|
@@ -542,5 +542,5 @@ async function startVetra(args) {
|
|
|
542
542
|
//#endregion
|
|
543
543
|
export { startVetra };
|
|
544
544
|
|
|
545
|
-
//# sourceMappingURL=vetra-
|
|
546
|
-
//# debugId=
|
|
545
|
+
//# sourceMappingURL=vetra-DjNt0-L6.mjs.map
|
|
546
|
+
//# debugId=5b1c4e98-eac3-5feb-a1ed-c7534fa307d2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vetra-DSFzAl_1.mjs","sources":["../src/utils/configure-vetra-github-url.ts","../src/utils/resolve-switchboard-port.ts","../src/services/vetra.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 { isPortAvailable } from \"@powerhousedao/switchboard/server\";\nimport { yellow } from \"colorette\";\n\nconst MAX_FALLBACK_ATTEMPTS = 20;\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nasync function findFreePort(start: number): Promise<number | null> {\n for (let i = 0; i < MAX_FALLBACK_ATTEMPTS; i++) {\n const candidate = start + i;\n if (await isPortAvailable(candidate)) return candidate;\n }\n return null;\n}\n\n/**\n * Resolve the port switchboard should bind to. If the requested port is free,\n * returns it unchanged. If it's in use, walks forward for the next free port\n * and — in an interactive terminal — asks the user to confirm the fallback.\n * In CI / piped contexts the fallback is applied automatically so scripts\n * don't hang on an unanswered prompt.\n *\n * Throws a process.exit(1) when the user declines the prompt or when no free\n * port is available in the search window.\n */\nexport async function resolveSwitchboardPort(\n requested: number,\n): Promise<number> {\n if (await isPortAvailable(requested)) return requested;\n\n const candidate = await findFreePort(requested + 1);\n if (candidate === null) {\n console.error(\n `Port ${requested} is in use and no free port was found in the range ${requested}-${requested + MAX_FALLBACK_ATTEMPTS - 1}.`,\n );\n process.exit(1);\n }\n\n if (!isInteractive()) {\n console.log(\n yellow(\n `Port ${requested} is in use. Falling back to port ${candidate} (non-interactive; skipping confirmation).`,\n ),\n );\n return candidate;\n }\n\n const enquirer = await import(\"enquirer\");\n\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `Port ${requested} is in use. Use port ${candidate} instead?`,\n initial: true,\n });\n confirmed = answer.confirmed;\n } catch {\n // user aborted the prompt (Ctrl-C); treat as decline\n confirmed = false;\n }\n\n if (!confirmed) {\n console.error(\n `Aborted. Free port ${requested} or pass --switchboard-port <port> to choose a different port.`,\n );\n process.exit(1);\n }\n\n return candidate;\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport {\n getConfig,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { join } from \"node:path\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport {\n generateProjectDriveId,\n getProjectInfo,\n POWERHOUSE_CONFIG_FILE,\n} from \"../utils.js\";\nimport { wasFlagExplicitlyPassed } from \"../utils/cli-connect-override.js\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\nimport { mergeDefaultDrives, rebaseDriveUrl } from \"@powerhousedao/host-core\";\nimport { parseDefaultDrivesUrl } from \"../utils/parse-default-drives.js\";\nimport { resolveSwitchboardPort } from \"../utils/resolve-switchboard-port.js\";\nimport {\n clearVetraRuntime,\n legacyMcpConfigs,\n probeVetraRuntime,\n syncMcpPort,\n writeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"../utils/vetra-runtime.js\";\nimport { stopVetra } from \"../utils/vetra-launch.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport {\n POWERHOUSE_DRIVE_ICON,\n seedWorkflowsDrive,\n startSwitchboard,\n} from \"@powerhousedao/ph-run/switchboard\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\nconst getDriveId = (driveUrl: string | undefined): string =>\n driveUrl?.split(\"/\").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);\n\n// rebaseDriveUrl moved to @powerhousedao/host-core (uniform-runners P1.4) —\n// one implementation shared by this classic path and the generic compound.\n\nfunction createViteLogger(color: Color) {\n const customLogger = createLogger(\"info\");\n const loggerInfo = customLogger.info.bind(customLogger);\n customLogger.info = (msg, options) => {\n loggerInfo(color(msg), options);\n };\n const loggerWarn = customLogger.warn.bind(customLogger);\n customLogger.warn = (msg, options) => {\n loggerWarn(yellow(msg), options);\n };\n const loggerError = customLogger.error.bind(customLogger);\n customLogger.error = (msg, options) => {\n loggerError(red(msg), options);\n };\n\n const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n customLogger.warnOnce = (msg, options) => {\n loggerWarnOnce(yellow(msg), options);\n };\n return customLogger;\n}\n\n/** Creates the Vetra Preview drive, or opens it, and opens it in `app` when given. */\nexport async function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n app?: string,\n): Promise<string | null> {\n const previewDriveId = generateProjectDriveId(\"preview\");\n\n const previewDrive = {\n id: previewDriveId,\n slug: previewDriveId,\n global: {\n name: \"Vetra Preview\",\n icon: POWERHOUSE_DRIVE_ICON,\n nodes: [],\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(\n reactor,\n { ...previewDrive, preferredEditor: app },\n port,\n );\n\n if (app && driveUrl) {\n await openDriveIn(reactor, previewDriveId, app);\n }\n\n if (verbose && driveUrl) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl ?? null;\n}\n\n/** Sets the drive's app unless it already has it; a drive from an earlier run keeps its old one otherwise. */\nasync function openDriveIn(\n reactor: IReactorClient,\n driveId: string,\n app: string,\n): Promise<void> {\n const drive = await reactor.read.get(driveId);\n if (drive.header.meta?.preferredEditor === app) {\n return;\n }\n const handle = await reactor.write.setPreferredEditor(driveId, app);\n await handle.readable;\n}\n\n// Studio's drives, read and written on the local Switchboard, so Studio and agents see one set\n// of drives (not with a remote Vetra drive, or a project that sets multiReactor or reactorClient), and no cookie banner.\nexport function buildVetraStudioOverride(\n defaultDrives: PHConnectDefaultDrive[],\n options: {\n remoteDrive?: string;\n projectConnect?: PHConnectRuntimeConfig;\n } = {},\n): PHConnectRuntimeConfig {\n const override: PHConnectRuntimeConfig = {\n drives: { defaultDrives, preserveStrategy: \"preserve-all\" },\n };\n // A first visit's cookie dialog covers the local Studio, agents' browsers included.\n if (options.projectConnect?.app?.cookieBanner === undefined) {\n override.app = { cookieBanner: false };\n }\n const instance = options.projectConnect?.instance;\n if (\n !options.remoteDrive &&\n instance?.multiReactor === undefined &&\n instance?.reactorClient === undefined\n ) {\n override.instance = {\n reactorClient: \"remote\",\n } as typeof override.instance;\n }\n return override;\n}\n\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n const {\n connectPort,\n switchboardPort,\n dev,\n packages,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n remoteDrive,\n interactive,\n watch,\n verbose,\n } = args;\n\n // Convert single remote drive to array if provided\n const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n const vetraProcessorConfig: VetraProcessorConfigType = {\n interactive,\n driveUrl: remoteDrive ?? getDefaultVetraUrl(connectPort),\n driveId: getDriveId(remoteDrive),\n };\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n // When the user didn't opt into strict-port semantics, check for a port\n // conflict up front and ask for confirmation before binding a fallback.\n // Doing this in the CLI layer keeps the interactive prompt out of the\n // switchboard server package and aligns with the existing prerelease-tag\n // confirmation flow in `ph publish`.\n const resolvedSwitchboardPort = args.strictPort\n ? switchboardPort\n : await resolveSwitchboardPort(switchboardPort);\n\n try {\n const switchboard = await startSwitchboard(\n {\n ...args,\n useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n mcp: true,\n port: resolvedSwitchboardPort,\n // We've already probed and (when interactive) confirmed the port with\n // the user, so keep the server from running its own fallback on top.\n strictPort: true,\n dev,\n packages,\n remoteDrives,\n vetraDriveId,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n processorConfig,\n basePath: undefined,\n keypairPath: undefined,\n dbPath: args.dbPath,\n useIdentity: undefined,\n migrate: undefined,\n migrateStatus: undefined,\n reset: undefined,\n yes: undefined,\n requireIdentity: undefined,\n },\n logger,\n );\n\n const actualSwitchboardPort = switchboard.port;\n\n // Add preview drive (only in watch mode)\n let previewDriveUrl: string | null = null;\n if (watch) {\n try {\n previewDriveUrl = await startVetraPreviewDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n verbose,\n getConfig(join(process.cwd(), POWERHOUSE_CONFIG_FILE)).vetra\n ?.previewDrive?.app,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n let workflowsDriveUrl: string | null = null;\n if (switchboard.workflowsEnabled) {\n try {\n // Opens in Workflow Studio.\n workflowsDriveUrl = await seedWorkflowsDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n getProjectInfo().path,\n );\n if (verbose && workflowsDriveUrl) {\n console.log(\n blue(`Vetra Switchboard: Workflows drive: ${workflowsDriveUrl}`),\n );\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n 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:${actualSwitchboardPort}/graphql`,\n ),\n );\n console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));\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 return {\n driveUrl: switchboard.defaultDriveUrl || \"\",\n previewDriveUrl: previewDriveUrl,\n workflowsDriveUrl,\n switchboardPort: actualSwitchboardPort,\n };\n } catch (error) {\n console.error(\n red(\n `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n throw error instanceof Error ? error : new Error(String(error));\n }\n}\n\nexport async function startVetra(args: VetraArgs) {\n const {\n connectPort,\n verbose,\n remoteDrive,\n disableConnect,\n debug,\n httpsCertFile,\n httpsKeyFile,\n disableLocalPackages,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n watchTimeout,\n } = args;\n\n const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n // One Vetra per project. Two instances over one working tree would contend\n // for the same `.ph/read-model.db` and `.ph/reactor-storage`, and leave the\n // project with two drives that diverge.\n const projectDir = process.cwd();\n const { readPackageSync } = await import(\"read-pkg\");\n const projectName = readPackageSync({ cwd: projectDir }).name;\n let probe = await probeVetraRuntime(projectDir, projectName);\n\n if (\n args.restart &&\n (probe.status === \"live\" || probe.status === \"starting\")\n ) {\n console.log(`Stopping this project's Vetra (pid ${probe.record.pid})...`);\n await stopVetra({ projectDir, projectName });\n probe = await probeVetraRuntime(projectDir, projectName);\n }\n\n if (probe.status === \"live\" || probe.status === \"starting\") {\n console.log();\n console.log(\n green(\n probe.status === \"live\"\n ? \"Vetra is already running for this project.\"\n : \"Vetra is already starting for this project.\",\n ),\n );\n const { record } = probe;\n console.log(\n green(\n ` ➜ Connect: ${record.connectUrl ?? `http://localhost:${record.connectPort}`}`,\n ),\n );\n console.log(\n green(\n ` ➜ Switchboard: ${record.switchboardUrl ?? `http://localhost:${record.switchboardPort}/graphql`}`,\n ),\n );\n console.log(\n `Run \\`ph vetra --restart\\` to restart it, or stop it (pid ${probe.record.pid}).`,\n );\n return;\n }\n\n if (probe.status === \"foreign\") {\n console.error(\n red(\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`,\n ),\n );\n process.exit(1);\n }\n\n try {\n // Set default log level to info if not already specified\n if (!process.env.LOG_LEVEL) {\n setLogLevel(\"info\");\n }\n\n if (verbose) {\n switchboardLogger.info(\"Starting Vetra Switchboard...\");\n if (remoteDrive) {\n const source = remoteDrive\n ? \"command line argument\"\n : \"powerhouse.config.json\";\n switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n }\n }\n const switchboardResult = await startLocalVetraSwitchboard(\n {\n ...args,\n dev: true, // Vetra always runs in dev mode to load local packages\n httpsKeyFile,\n httpsCertFile,\n disableLocalPackages,\n debug,\n },\n switchboardLogger,\n );\n const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n const previewDriveUrl = switchboardResult.previewDriveUrl;\n const workflowsDriveUrl = switchboardResult.workflowsDriveUrl;\n const actualSwitchboardPort = switchboardResult.switchboardPort;\n\n // Record what we actually bound, so a second `ph vetra` can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n const runtimeRecord: VetraRuntimeRecord = {\n pid: process.pid,\n projectName,\n switchboardPort: actualSwitchboardPort,\n connectPort,\n switchboardUrl: `http://localhost:${actualSwitchboardPort}/graphql`,\n mcpUrl: `http://localhost:${actualSwitchboardPort}/mcp`,\n ...(disableConnect\n ? {}\n : { connectUrl: `http://localhost:${connectPort}/` }),\n startedAt: new Date().toISOString(),\n };\n writeVetraRuntime(projectDir, runtimeRecord);\n // A restarted Vetra may already have written its own.\n const releaseRuntimeRecord = () =>\n clearVetraRuntime(projectDir, process.pid);\n process.on(\"exit\", releaseRuntimeRecord);\n process.on(\"SIGINT\", () => {\n releaseRuntimeRecord();\n process.exit(130);\n });\n process.on(\"SIGTERM\", () => {\n releaseRuntimeRecord();\n process.exit(143);\n });\n\n // An MCP client resolved `.mcp.json` before this process started and\n // cannot re-read it, so a drifted literal means the agent is pointed at\n // the wrong port — possibly another project's reactor. Correct the file\n // and say so plainly; we cannot fix the already-open client ourselves.\n const driftedMcpFiles = syncMcpPort(projectDir, actualSwitchboardPort);\n if (driftedMcpFiles.length > 0) {\n console.log(\n yellow(\n `Updated ${driftedMcpFiles.join(\" and \")} to port ${actualSwitchboardPort}. ` +\n `Reconnect your MCP client (/mcp) to pick it up. ` +\n `This edit is local — do not commit it.`,\n ),\n );\n }\n if (legacyMcpConfigs(projectDir).length > 0) {\n console.log(\n yellow(\n \"reactor-mcp still points at a URL; run `ph migrate` to switch it to the `ph mcp` launcher.\",\n ),\n );\n }\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(\n actualSwitchboardPort,\n remoteDrive,\n verbose,\n );\n\n // give some time for the user to read log messages\n await sleep(2000);\n }\n\n if (verbose) {\n console.log(\"Starting Codegen Reactor...\");\n }\n\n // Start Connect pointing to the drive (unless disabled)\n if (!disableConnect) {\n // --drives-public-base: advertise proxy-reachable drive URLs to the\n // browser instead of the switchboard's localhost origin.\n const publicBase = args.drivesPublicBase;\n const browserDriveUrl = publicBase\n ? rebaseDriveUrl(driveUrl, publicBase)\n : driveUrl;\n const browserPreviewDriveUrl =\n previewDriveUrl && publicBase\n ? rebaseDriveUrl(previewDriveUrl, publicBase)\n : previewDriveUrl;\n const browserWorkflowsDriveUrl =\n workflowsDriveUrl && publicBase\n ? rebaseDriveUrl(workflowsDriveUrl, publicBase)\n : workflowsDriveUrl;\n\n // The resolved default-drive list: vetra's own drives first (the\n // Vetra drive, the preview drive in watch mode, and the Workflows\n // drive when workflows are on), then the\n // project's configured `connect.drives.defaultDrives` from\n // powerhouse.config.json (issue #3023). A drive vetra also starts is\n // listed only once. An explicit `--default-drives-url` is appended on\n // top of this list by buildStudioConnectOverride — it never replaces\n // the vetra drives.\n const vetraDriveEntries = [\n ...(browserDriveUrl\n ? [{ url: browserDriveUrl, name: null, icon: null }]\n : []),\n ...(browserPreviewDriveUrl\n ? [{ url: browserPreviewDriveUrl, name: null, icon: null }]\n : []),\n ...(browserWorkflowsDriveUrl\n ? [{ url: browserWorkflowsDriveUrl, name: null, icon: null }]\n : []),\n ];\n // Read again each time Studio restarts for a changed powerhouse.config.json.\n const studioDrives = () => {\n const projectConnect = getConfig(\n join(projectDir, POWERHOUSE_CONFIG_FILE),\n ).connect;\n const drives = mergeDefaultDrives(\n vetraDriveEntries,\n projectConnect?.drives?.defaultDrives ?? [],\n );\n return { projectConnect, drives };\n };\n const resolvedDefaultDrives = studioDrives().drives;\n\n if (verbose) {\n console.log(\"Starting Connect...\");\n // Mirror buildStudioConnectOverride: an explicit\n // --default-drives-url is appended to the resolved list.\n const flagDefaultDrives = wasFlagExplicitlyPassed(\"default-drives-url\")\n ? parseDefaultDrivesUrl(args.defaultDrivesUrl ?? \"\")\n : [];\n const printedDefaultDrives = mergeDefaultDrives(\n resolvedDefaultDrives,\n flagDefaultDrives,\n );\n console.log(\n ` ➜ Connect will use default drives: ${printedDefaultDrives\n .map((d) => (\"url\" in d ? d.url : `local:${d.id}`))\n .join(\", \")}`,\n );\n }\n console.log();\n console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n const customViteLogger = createViteLogger(green);\n\n // Programmatic override forwarded to the Connect runtime config —\n // vetra always sets these regardless of what the user typed on the\n // command line. We pass it as the explicit third arg to\n // runConnectStudio so it survives the `wasFlagExplicitlyPassed`\n // gating (the user didn't pass --default-drives-url; vetra is setting\n // it itself).\n const vetraDrivesOverride = () => {\n const { projectConnect, drives } = studioDrives();\n return buildVetraStudioOverride(drives, {\n remoteDrive,\n projectConnect,\n });\n };\n\n const studio = await runConnectStudio(\n {\n ...args,\n port: connectPort,\n disableLocalPackages,\n debug,\n host: host,\n open: open,\n cors: cors,\n strictPort: strictPort,\n printUrls: printUrls,\n bindCLIShortcuts: bindCLIShortcuts,\n watchTimeout: watchTimeout,\n },\n customViteLogger,\n vetraDrivesOverride,\n { reloadOnConfigChange: true },\n );\n // Vite may have taken another port, and the base path is Connect's.\n const connectUrl = studio.resolvedUrls?.local[0];\n if (connectUrl && connectUrl !== runtimeRecord.connectUrl) {\n writeVetraRuntime(projectDir, {\n ...runtimeRecord,\n connectPort: Number(new URL(connectUrl).port) || connectPort,\n connectUrl,\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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,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Aa,MAnBE,iBACnB;IACE,GAAG;IACH,MAAM;IACN;IACA;IACM;IACA;IACA;IACM;IACD;IACO;IACJ;GAChB,GACA,kBACA,qBACA,EAAE,sBAAsB,KAAK,CAC/B,EAAA,CAE0B,cAAc,MAAM;GAC9C,IAAI,cAAc,eAAe,cAAc,YAC7C,kBAAkB,YAAY;IAC5B,GAAG;IACH,aAAa,OAAO,IAAI,IAAI,UAAU,CAAC,CAAC,IAAI,KAAK;IACjD;GACF,CAAC;EAEL;CACF,SAAS,OAAO;EACd,QAAQ,MAAM,KAAK;CACrB;AACF","debug_id":"6d4d7ec4-0999-506b-bbe0-7a8a8f05ed5d"}
|
|
1
|
+
{"version":3,"file":"vetra-DjNt0-L6.mjs","sources":["../src/utils/configure-vetra-github-url.ts","../src/utils/resolve-switchboard-port.ts","../src/services/vetra.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 { isPortAvailable } from \"@powerhousedao/switchboard/server\";\nimport { yellow } from \"colorette\";\n\nconst MAX_FALLBACK_ATTEMPTS = 20;\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nasync function findFreePort(start: number): Promise<number | null> {\n for (let i = 0; i < MAX_FALLBACK_ATTEMPTS; i++) {\n const candidate = start + i;\n if (await isPortAvailable(candidate)) return candidate;\n }\n return null;\n}\n\n/**\n * Resolve the port switchboard should bind to. If the requested port is free,\n * returns it unchanged. If it's in use, walks forward for the next free port\n * and — in an interactive terminal — asks the user to confirm the fallback.\n * In CI / piped contexts the fallback is applied automatically so scripts\n * don't hang on an unanswered prompt.\n *\n * Throws a process.exit(1) when the user declines the prompt or when no free\n * port is available in the search window.\n */\nexport async function resolveSwitchboardPort(\n requested: number,\n): Promise<number> {\n if (await isPortAvailable(requested)) return requested;\n\n const candidate = await findFreePort(requested + 1);\n if (candidate === null) {\n console.error(\n `Port ${requested} is in use and no free port was found in the range ${requested}-${requested + MAX_FALLBACK_ATTEMPTS - 1}.`,\n );\n process.exit(1);\n }\n\n if (!isInteractive()) {\n console.log(\n yellow(\n `Port ${requested} is in use. Falling back to port ${candidate} (non-interactive; skipping confirmation).`,\n ),\n );\n return candidate;\n }\n\n const enquirer = await import(\"enquirer\");\n\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `Port ${requested} is in use. Use port ${candidate} instead?`,\n initial: true,\n });\n confirmed = answer.confirmed;\n } catch {\n // user aborted the prompt (Ctrl-C); treat as decline\n confirmed = false;\n }\n\n if (!confirmed) {\n console.error(\n `Aborted. Free port ${requested} or pass --switchboard-port <port> to choose a different port.`,\n );\n process.exit(1);\n }\n\n return candidate;\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport {\n getConfig,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { join } from \"node:path\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport {\n generateProjectDriveId,\n getProjectInfo,\n POWERHOUSE_CONFIG_FILE,\n} from \"../utils.js\";\nimport { wasFlagExplicitlyPassed } from \"../utils/cli-connect-override.js\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\nimport { mergeDefaultDrives, rebaseDriveUrl } from \"@powerhousedao/host-core\";\nimport { parseDefaultDrivesUrl } from \"../utils/parse-default-drives.js\";\nimport { resolveSwitchboardPort } from \"../utils/resolve-switchboard-port.js\";\nimport {\n clearVetraRuntime,\n legacyMcpConfigs,\n probeVetraRuntime,\n syncMcpPort,\n writeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"../utils/vetra-runtime.js\";\nimport { stopVetra } from \"../utils/vetra-launch.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport {\n POWERHOUSE_DRIVE_ICON,\n seedWorkflowsDrive,\n startSwitchboard,\n} from \"@powerhousedao/ph-run/switchboard\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\nconst getDriveId = (driveUrl: string | undefined): string =>\n driveUrl?.split(\"/\").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);\n\n// rebaseDriveUrl moved to @powerhousedao/host-core (uniform-runners P1.4) —\n// one implementation shared by this classic path and the generic compound.\n\nfunction createViteLogger(color: Color) {\n const customLogger = createLogger(\"info\");\n const loggerInfo = customLogger.info.bind(customLogger);\n customLogger.info = (msg, options) => {\n loggerInfo(color(msg), options);\n };\n const loggerWarn = customLogger.warn.bind(customLogger);\n customLogger.warn = (msg, options) => {\n loggerWarn(yellow(msg), options);\n };\n const loggerError = customLogger.error.bind(customLogger);\n customLogger.error = (msg, options) => {\n loggerError(red(msg), options);\n };\n\n const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n customLogger.warnOnce = (msg, options) => {\n loggerWarnOnce(yellow(msg), options);\n };\n return customLogger;\n}\n\n/** Creates the Vetra Preview drive, or opens it, and opens it in `app` when given. */\nexport async function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n app?: string,\n): Promise<string | null> {\n const previewDriveId = generateProjectDriveId(\"preview\");\n\n const previewDrive = {\n id: previewDriveId,\n slug: previewDriveId,\n global: {\n name: \"Vetra Preview\",\n icon: POWERHOUSE_DRIVE_ICON,\n nodes: [],\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(\n reactor,\n { ...previewDrive, preferredEditor: app },\n port,\n );\n\n if (app && driveUrl) {\n await openDriveIn(reactor, previewDriveId, app);\n }\n\n if (verbose && driveUrl) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl ?? null;\n}\n\n/** Sets the drive's app unless it already has it; a drive from an earlier run keeps its old one otherwise. */\nasync function openDriveIn(\n reactor: IReactorClient,\n driveId: string,\n app: string,\n): Promise<void> {\n const drive = await reactor.read.get(driveId);\n if (drive.header.meta?.preferredEditor === app) {\n return;\n }\n const handle = await reactor.write.setPreferredEditor(driveId, app);\n await handle.readable;\n}\n\n// Studio's drives, read and written on the local Switchboard, so Studio and agents see one set\n// of drives (not with a remote Vetra drive, or a project that sets multiReactor or reactorClient), and no cookie banner.\nexport function buildVetraStudioOverride(\n defaultDrives: PHConnectDefaultDrive[],\n options: {\n remoteDrive?: string;\n projectConnect?: PHConnectRuntimeConfig;\n } = {},\n): PHConnectRuntimeConfig {\n const override: PHConnectRuntimeConfig = {\n drives: { defaultDrives, preserveStrategy: \"preserve-all\" },\n };\n // A first visit's cookie dialog covers the local Studio, agents' browsers included.\n if (options.projectConnect?.app?.cookieBanner === undefined) {\n override.app = { cookieBanner: false };\n }\n const instance = options.projectConnect?.instance;\n if (\n !options.remoteDrive &&\n instance?.multiReactor === undefined &&\n instance?.reactorClient === undefined\n ) {\n override.instance = {\n reactorClient: \"remote\",\n } as typeof override.instance;\n }\n return override;\n}\n\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n const {\n connectPort,\n switchboardPort,\n dev,\n packages,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n remoteDrive,\n interactive,\n watch,\n verbose,\n } = args;\n\n // Convert single remote drive to array if provided\n const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n const vetraProcessorConfig: VetraProcessorConfigType = {\n interactive,\n driveUrl: remoteDrive ?? getDefaultVetraUrl(connectPort),\n driveId: getDriveId(remoteDrive),\n };\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n // When the user didn't opt into strict-port semantics, check for a port\n // conflict up front and ask for confirmation before binding a fallback.\n // Doing this in the CLI layer keeps the interactive prompt out of the\n // switchboard server package and aligns with the existing prerelease-tag\n // confirmation flow in `ph publish`.\n const resolvedSwitchboardPort = args.strictPort\n ? switchboardPort\n : await resolveSwitchboardPort(switchboardPort);\n\n try {\n const switchboard = await startSwitchboard(\n {\n ...args,\n useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n mcp: true,\n port: resolvedSwitchboardPort,\n // We've already probed and (when interactive) confirmed the port with\n // the user, so keep the server from running its own fallback on top.\n strictPort: true,\n dev,\n packages,\n remoteDrives,\n vetraDriveId,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n processorConfig,\n basePath: undefined,\n keypairPath: undefined,\n dbPath: args.dbPath,\n useIdentity: undefined,\n migrate: undefined,\n migrateStatus: undefined,\n reset: undefined,\n yes: undefined,\n requireIdentity: undefined,\n },\n logger,\n );\n\n const actualSwitchboardPort = switchboard.port;\n\n // Add preview drive (only in watch mode)\n let previewDriveUrl: string | null = null;\n if (watch) {\n try {\n previewDriveUrl = await startVetraPreviewDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n verbose,\n getConfig(join(process.cwd(), POWERHOUSE_CONFIG_FILE)).vetra\n ?.previewDrive?.app,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n let workflowsDriveUrl: string | null = null;\n if (switchboard.workflowsEnabled) {\n try {\n // Opens in Workflow Studio.\n workflowsDriveUrl = await seedWorkflowsDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n getProjectInfo().path,\n );\n if (verbose && workflowsDriveUrl) {\n console.log(\n blue(`Vetra Switchboard: Workflows drive: ${workflowsDriveUrl}`),\n );\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n 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:${actualSwitchboardPort}/graphql`,\n ),\n );\n console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));\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 return {\n driveUrl: switchboard.defaultDriveUrl || \"\",\n previewDriveUrl: previewDriveUrl,\n workflowsDriveUrl,\n switchboardPort: actualSwitchboardPort,\n };\n } catch (error) {\n console.error(\n red(\n `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n throw error instanceof Error ? error : new Error(String(error));\n }\n}\n\nexport async function startVetra(args: VetraArgs) {\n const {\n connectPort,\n verbose,\n remoteDrive,\n disableConnect,\n debug,\n httpsCertFile,\n httpsKeyFile,\n disableLocalPackages,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n watchTimeout,\n } = args;\n\n const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n // One Vetra per project. Two instances over one working tree would contend\n // for the same `.ph/read-model.db` and `.ph/reactor-storage`, and leave the\n // project with two drives that diverge.\n const projectDir = process.cwd();\n const { readPackageSync } = await import(\"read-pkg\");\n const projectName = readPackageSync({ cwd: projectDir }).name;\n let probe = await probeVetraRuntime(projectDir, projectName);\n\n if (\n args.restart &&\n (probe.status === \"live\" || probe.status === \"starting\")\n ) {\n console.log(`Stopping this project's Vetra (pid ${probe.record.pid})...`);\n await stopVetra({ projectDir, projectName });\n probe = await probeVetraRuntime(projectDir, projectName);\n }\n\n if (probe.status === \"live\" || probe.status === \"starting\") {\n console.log();\n console.log(\n green(\n probe.status === \"live\"\n ? \"Vetra is already running for this project.\"\n : \"Vetra is already starting for this project.\",\n ),\n );\n const { record } = probe;\n console.log(\n green(\n ` ➜ Connect: ${record.connectUrl ?? `http://localhost:${record.connectPort}`}`,\n ),\n );\n console.log(\n green(\n ` ➜ Switchboard: ${record.switchboardUrl ?? `http://localhost:${record.switchboardPort}/graphql`}`,\n ),\n );\n console.log(\n `Run \\`ph vetra --restart\\` to restart it, or stop it (pid ${probe.record.pid}).`,\n );\n return;\n }\n\n if (probe.status === \"foreign\") {\n console.error(\n red(\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`,\n ),\n );\n process.exit(1);\n }\n\n try {\n // Set default log level to info if not already specified\n if (!process.env.LOG_LEVEL) {\n setLogLevel(\"info\");\n }\n\n if (verbose) {\n switchboardLogger.info(\"Starting Vetra Switchboard...\");\n if (remoteDrive) {\n const source = remoteDrive\n ? \"command line argument\"\n : \"powerhouse.config.json\";\n switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n }\n }\n const switchboardResult = await startLocalVetraSwitchboard(\n {\n ...args,\n dev: true, // Vetra always runs in dev mode to load local packages\n httpsKeyFile,\n httpsCertFile,\n disableLocalPackages,\n debug,\n },\n switchboardLogger,\n );\n const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n const previewDriveUrl = switchboardResult.previewDriveUrl;\n const workflowsDriveUrl = switchboardResult.workflowsDriveUrl;\n const actualSwitchboardPort = switchboardResult.switchboardPort;\n\n // Record what we actually bound, so a second `ph vetra` can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n const runtimeRecord: VetraRuntimeRecord = {\n pid: process.pid,\n projectName,\n switchboardPort: actualSwitchboardPort,\n connectPort,\n switchboardUrl: `http://localhost:${actualSwitchboardPort}/graphql`,\n mcpUrl: `http://localhost:${actualSwitchboardPort}/mcp`,\n ...(disableConnect\n ? {}\n : { connectUrl: `http://localhost:${connectPort}/` }),\n startedAt: new Date().toISOString(),\n };\n writeVetraRuntime(projectDir, runtimeRecord);\n // A restarted Vetra may already have written its own.\n const releaseRuntimeRecord = () =>\n clearVetraRuntime(projectDir, process.pid);\n process.on(\"exit\", releaseRuntimeRecord);\n process.on(\"SIGINT\", () => {\n releaseRuntimeRecord();\n process.exit(130);\n });\n process.on(\"SIGTERM\", () => {\n releaseRuntimeRecord();\n process.exit(143);\n });\n\n // An MCP client resolved `.mcp.json` before this process started and\n // cannot re-read it, so a drifted literal means the agent is pointed at\n // the wrong port — possibly another project's reactor. Correct the file\n // and say so plainly; we cannot fix the already-open client ourselves.\n const driftedMcpFiles = syncMcpPort(projectDir, actualSwitchboardPort);\n if (driftedMcpFiles.length > 0) {\n console.log(\n yellow(\n `Updated ${driftedMcpFiles.join(\" and \")} to port ${actualSwitchboardPort}. ` +\n `Reconnect your MCP client (/mcp) to pick it up. ` +\n `This edit is local — do not commit it.`,\n ),\n );\n }\n if (legacyMcpConfigs(projectDir).length > 0) {\n console.log(\n yellow(\n \"reactor-mcp still points at a URL; run `ph migrate` to switch it to the `ph mcp` launcher.\",\n ),\n );\n }\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(\n actualSwitchboardPort,\n remoteDrive,\n verbose,\n );\n\n // give some time for the user to read log messages\n await sleep(2000);\n }\n\n if (verbose) {\n console.log(\"Starting Codegen Reactor...\");\n }\n\n // Start Connect pointing to the drive (unless disabled)\n if (!disableConnect) {\n // --drives-public-base: advertise proxy-reachable drive URLs to the\n // browser instead of the switchboard's localhost origin.\n const publicBase = args.drivesPublicBase;\n const browserDriveUrl = publicBase\n ? rebaseDriveUrl(driveUrl, publicBase)\n : driveUrl;\n const browserPreviewDriveUrl =\n previewDriveUrl && publicBase\n ? rebaseDriveUrl(previewDriveUrl, publicBase)\n : previewDriveUrl;\n const browserWorkflowsDriveUrl =\n workflowsDriveUrl && publicBase\n ? rebaseDriveUrl(workflowsDriveUrl, publicBase)\n : workflowsDriveUrl;\n\n // The resolved default-drive list: vetra's own drives first (the\n // Vetra drive, the preview drive in watch mode, and the Workflows\n // drive when workflows are on), then the\n // project's configured `connect.drives.defaultDrives` from\n // powerhouse.config.json (issue #3023). A drive vetra also starts is\n // listed only once. An explicit `--default-drives-url` is appended on\n // top of this list by buildStudioConnectOverride — it never replaces\n // the vetra drives.\n const vetraDriveEntries = [\n ...(browserDriveUrl\n ? [{ url: browserDriveUrl, name: null, icon: null }]\n : []),\n ...(browserPreviewDriveUrl\n ? [{ url: browserPreviewDriveUrl, name: null, icon: null }]\n : []),\n ...(browserWorkflowsDriveUrl\n ? [{ url: browserWorkflowsDriveUrl, name: null, icon: null }]\n : []),\n ];\n // Read again each time Studio restarts for a changed powerhouse.config.json.\n const studioDrives = () => {\n const projectConnect = getConfig(\n join(projectDir, POWERHOUSE_CONFIG_FILE),\n ).connect;\n const drives = mergeDefaultDrives(\n vetraDriveEntries,\n projectConnect?.drives?.defaultDrives ?? [],\n );\n return { projectConnect, drives };\n };\n const resolvedDefaultDrives = studioDrives().drives;\n\n if (verbose) {\n console.log(\"Starting Connect...\");\n // Mirror buildStudioConnectOverride: an explicit\n // --default-drives-url is appended to the resolved list.\n const flagDefaultDrives = wasFlagExplicitlyPassed(\"default-drives-url\")\n ? parseDefaultDrivesUrl(args.defaultDrivesUrl ?? \"\")\n : [];\n const printedDefaultDrives = mergeDefaultDrives(\n resolvedDefaultDrives,\n flagDefaultDrives,\n );\n console.log(\n ` ➜ Connect will use default drives: ${printedDefaultDrives\n .map((d) => (\"url\" in d ? d.url : `local:${d.id}`))\n .join(\", \")}`,\n );\n }\n console.log();\n console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n const customViteLogger = createViteLogger(green);\n\n // Programmatic override forwarded to the Connect runtime config —\n // vetra always sets these regardless of what the user typed on the\n // command line. We pass it as the explicit third arg to\n // runConnectStudio so it survives the `wasFlagExplicitlyPassed`\n // gating (the user didn't pass --default-drives-url; vetra is setting\n // it itself).\n const vetraDrivesOverride = () => {\n const { projectConnect, drives } = studioDrives();\n return buildVetraStudioOverride(drives, {\n remoteDrive,\n projectConnect,\n });\n };\n\n const studio = await runConnectStudio(\n {\n ...args,\n port: connectPort,\n disableLocalPackages,\n debug,\n host: host,\n open: open,\n cors: cors,\n strictPort: strictPort,\n printUrls: printUrls,\n bindCLIShortcuts: bindCLIShortcuts,\n watchTimeout: watchTimeout,\n },\n customViteLogger,\n vetraDrivesOverride,\n { reloadOnConfigChange: true },\n );\n // Vite may have taken another port, and the base path is Connect's.\n const connectUrl = studio.resolvedUrls?.local[0];\n if (connectUrl && connectUrl !== runtimeRecord.connectUrl) {\n writeVetraRuntime(projectDir, {\n ...runtimeRecord,\n connectPort: Number(new URL(connectUrl).port) || connectPort,\n connectUrl,\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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,YAA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