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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{build-CBKlv5E3.mjs → build-CGnPJwut.mjs} +4 -4
  2. package/dist/{build-CBKlv5E3.mjs.map → build-CGnPJwut.mjs.map} +1 -1
  3. package/dist/build-mTLB2w-Q.mjs +4 -0
  4. package/dist/{check-DhFd9tO8.mjs → check-Ch1obo1o.mjs} +3 -3
  5. package/dist/{check-Cx_AeBQe.mjs → check-DQnWxQCS.mjs} +4 -4
  6. package/dist/{check-Cx_AeBQe.mjs.map → check-DQnWxQCS.mjs.map} +1 -1
  7. package/dist/cli.mjs +4 -4
  8. package/dist/{connect-build-DpGUrtct.mjs → connect-build-CQgSyKm1.mjs} +7 -9
  9. package/dist/connect-build-CQgSyKm1.mjs.map +1 -0
  10. package/dist/{connect-studio-BPZOcwUM.mjs → connect-studio-SH4U0Cpm.mjs} +4 -4
  11. package/dist/{connect-studio-BPZOcwUM.mjs.map → connect-studio-SH4U0Cpm.mjs.map} +1 -1
  12. package/dist/definitions-worker.mjs +1 -1
  13. package/dist/{get-version-CTP__ORu.mjs → get-version-Cz5WJkpH.mjs} +4 -4
  14. package/dist/{get-version-CTP__ORu.mjs.map → get-version-Cz5WJkpH.mjs.map} +1 -1
  15. package/dist/{mcp-gcG7SW9L.mjs → mcp-Cx2HhCsK.mjs} +4 -4
  16. package/dist/{mcp-gcG7SW9L.mjs.map → mcp-Cx2HhCsK.mjs.map} +1 -1
  17. package/dist/{migrate-BaWZhorc.mjs → migrate-BzPAS4zM.mjs} +4 -4
  18. package/dist/{migrate-BaWZhorc.mjs.map → migrate-BzPAS4zM.mjs.map} +1 -1
  19. package/dist/{migrate-document-models-DYmkJzq3.mjs → migrate-document-models-BcrQKkDB.mjs} +4 -4
  20. package/dist/{migrate-document-models-DYmkJzq3.mjs.map → migrate-document-models-BcrQKkDB.mjs.map} +1 -1
  21. package/dist/migrate-subgraphs-ChQdt6w7.mjs +4 -0
  22. package/dist/{migrate-subgraphs-BUgTeHcm.mjs → migrate-subgraphs-Dw5UFCQ3.mjs} +5 -5
  23. package/dist/{migrate-subgraphs-BUgTeHcm.mjs.map → migrate-subgraphs-Dw5UFCQ3.mjs.map} +1 -1
  24. package/dist/ph-cli-commands-BcDloXsM.mjs +4 -0
  25. package/dist/{ph-cli-commands-B5VkGW99.mjs → ph-cli-commands-CGR5p3vg.mjs} +11 -11
  26. package/dist/{ph-cli-commands-B5VkGW99.mjs.map → ph-cli-commands-CGR5p3vg.mjs.map} +1 -1
  27. package/dist/runners/connect.mjs +2 -2
  28. package/dist/runners/switchboard.mjs +1 -1
  29. package/dist/{verify-BLn76w09.mjs → verify-B3CKpYI8.mjs} +4 -4
  30. package/dist/{verify-BLn76w09.mjs.map → verify-B3CKpYI8.mjs.map} +1 -1
  31. package/dist/{vetra-gateway-D30pZgha.mjs → vetra-gateway-BZJEJiGT.mjs} +4 -4
  32. package/dist/{vetra-gateway-D30pZgha.mjs.map → vetra-gateway-BZJEJiGT.mjs.map} +1 -1
  33. package/dist/vetra-gateway-CeWIXaAl.mjs +4 -0
  34. package/package.json +17 -17
  35. package/dist/build-Dr1lnv4h.mjs +0 -4
  36. package/dist/connect-build-DpGUrtct.mjs.map +0 -1
  37. package/dist/migrate-subgraphs-ChhXynqd.mjs +0 -4
  38. package/dist/ph-cli-commands-CGXSo1wx.mjs +0 -4
  39. package/dist/vetra-gateway-DE5Hc0Fp.mjs +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"verify-BLn76w09.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":"24d0ac5e-096b-5909-b0b0-4bebb65e7304"}
1
+ {"version":3,"file":"verify-B3CKpYI8.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":"d4bd76b8-0bc2-5659-afc3-352dbdc2f05c"}
@@ -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]="095468ff-56b1-5405-8789-37d4846f9fc8")}catch(e){}}();
3
- import { t as getVersion } from "./get-version-CTP__ORu.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c706a387-cc5f-5c1d-8c47-db0b80688ee2")}catch(e){}}();
3
+ import { t as getVersion } from "./get-version-Cz5WJkpH.mjs";
4
4
  import { W as resolvePackageRoot } from "./compound-g6x_KkWp-Bs7olmlI.mjs";
5
5
  import { readFileSync } from "node:fs";
6
6
  import path from "node:path";
@@ -169,5 +169,5 @@ async function vetraGateway(rest) {
169
169
  //#endregion
170
170
  export { openVetraStudio as a, vetraGateway as c, installedStudio as i, VETRA_STUDIO_HOST as n, planVetraGateway as o, VETRA_STUDIO_PACKAGE as r, studioInstallCommand as s, VETRA_GATEWAY_ENV as t };
171
171
 
172
- //# sourceMappingURL=vetra-gateway-D30pZgha.mjs.map
173
- //# debugId=095468ff-56b1-5405-8789-37d4846f9fc8
172
+ //# sourceMappingURL=vetra-gateway-BZJEJiGT.mjs.map
173
+ //# debugId=c706a387-cc5f-5c1d-8c47-db0b80688ee2
@@ -1 +1 @@
1
- {"version":3,"file":"vetra-gateway-D30pZgha.mjs","sources":["../src/services/vetra-gateway.ts"],"sourcesContent":["import { resolvePackageRoot } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport { yellow } from \"colorette\";\nimport { spawn } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { resolveCommand, type Agent } from \"package-manager-detector\";\nimport { valid } from \"semver\";\nimport { getVersion } from \"../get-version.js\";\n\n/**\n * `ph vetra` is the gateway to Vetra Studio, the host `studio` that the\n * package @powerhousedao/vetra-cli supplies. ph-cli names the package and the\n * host and nothing else of it: `ph vetra [verb] [args]` is\n * `ph run @powerhousedao/vetra-cli/studio [verb] [args]`, once the project\n * has the package. A project without it gets it first, as a devDependency at\n * this ph-cli's version: the two are released with the same version numbers.\n */\nexport const VETRA_STUDIO_PACKAGE = \"@powerhousedao/vetra-cli\";\nexport const VETRA_STUDIO_HOST = `${VETRA_STUDIO_PACKAGE}/studio`;\n\n/** Set on the ph-cli started after an install: it finds the package, or\n * fails, and never installs it again. */\nexport const VETRA_GATEWAY_ENV = \"PH_VETRA_GATEWAY_INSTALLED\";\n\n/** The package as the project has it; undefined when it has none. */\nexport type InstalledStudio = { version: string | undefined } | undefined;\n\nexport type VetraGatewayPlan =\n | { action: \"run\"; warning?: string }\n | { action: \"install\"; notice: string; command: string };\n\n/** The command line that adds the package at ph-cli's version as a\n * devDependency, with the project's package manager. */\nexport function studioInstallCommand(\n agent: Agent,\n phCliVersion: string,\n): string {\n // A build that does not know its version takes the latest release.\n const version = valid(phCliVersion) ?? \"latest\";\n // As `ph install --local`: on a release day the packages are younger than\n // pnpm 11's minimumReleaseAge.\n const releaseAge = agent.startsWith(\"pnpm\")\n ? [\"--config.minimum-release-age=0\"]\n : [];\n const resolved = resolveCommand(agent, \"add\", [\n \"-D\",\n `${VETRA_STUDIO_PACKAGE}@${version}`,\n ...releaseAge,\n ]);\n if (!resolved) {\n throw new Error(\n `Could not resolve an install command for package manager \"${agent}\".`,\n );\n }\n return [resolved.command, ...resolved.args].join(\" \");\n}\n\n/** What `ph vetra` does in a project: install the package, or run its host,\n * warning when the installed version is not ph-cli's. */\nexport function planVetraGateway(facts: {\n installed: InstalledStudio;\n phCliVersion: string;\n packageManager: Agent;\n}): VetraGatewayPlan {\n const { installed, phCliVersion, packageManager } = facts;\n const command = studioInstallCommand(packageManager, phCliVersion);\n if (installed === undefined) {\n return {\n action: \"install\",\n notice:\n `Vetra Studio is the package ${VETRA_STUDIO_PACKAGE}, which this project does not have yet. ` +\n `Installing it as a devDependency with ${packageManager}:`,\n command,\n };\n }\n const { version } = installed;\n if (\n version !== undefined &&\n valid(phCliVersion) !== null &&\n version !== phCliVersion\n ) {\n return {\n action: \"run\",\n warning: `${VETRA_STUDIO_PACKAGE} ${version} is installed, but this ph-cli is ${phCliVersion}: align them with \\`${command}\\`.`,\n };\n }\n return { action: \"run\" };\n}\n\nexport interface VetraGatewayDeps {\n /** The project root, undefined outside a project, and its package manager. */\n project: () => Promise<{ projectPath?: string; packageManager: Agent }>;\n phCliVersion: string;\n installedStudio: (projectRoot: string) => InstalledStudio;\n /** Runs an install command line in `cwd`; resolves to its exit code. */\n install: (command: string, cwd: string) => Promise<number | null>;\n /** Runs this ph-cli with `args` in a new process; resolves to its exit code. */\n reexec: (args: string[], cwd: string) => Promise<number>;\n env: NodeJS.ProcessEnv;\n log: (message: string) => void;\n warn: (message: string) => void;\n}\n\nexport type VetraGatewayResult =\n /** Go on with this command line, in the project root. */\n | { args: string[]; projectRoot: string }\n /** A new ph-cli ran it, after the install. */\n | { exitCode: number };\n\n/**\n * `ph vetra [verb] [args]` (`rest`) in the project: the `ph run` command line\n * of the studio host when the package is there. Otherwise it installs the\n * package and runs that command line in a new ph-cli, since a package\n * installed while this one runs is not reliably resolved by it (Node caches\n * lookups, and the install may relink what it imports later).\n */\nexport async function openVetraStudio(\n rest: readonly string[],\n deps: VetraGatewayDeps,\n): Promise<VetraGatewayResult> {\n const { projectPath, packageManager } = await deps.project();\n if (projectPath === undefined) {\n throw new Error(\n \"No Powerhouse project found, so `ph vetra` cannot open Vetra Studio: it installs into and runs in a project. \" +\n \"Run it in one, or create one with `ph init`.\",\n );\n }\n const runArgs = [\"run\", VETRA_STUDIO_HOST, ...rest];\n const plan = planVetraGateway({\n installed: deps.installedStudio(projectPath),\n phCliVersion: deps.phCliVersion,\n packageManager,\n });\n if (plan.action === \"run\") {\n if (plan.warning) deps.warn(plan.warning);\n return { args: runArgs, projectRoot: projectPath };\n }\n // A stop reads the run record only: there is nothing to install for it.\n if (rest.includes(\"--stop\"))\n return { args: runArgs, projectRoot: projectPath };\n const manual = `Install it yourself, then run \\`ph vetra\\` again:\\n ${plan.command}`;\n if (deps.env[VETRA_GATEWAY_ENV]) {\n throw new Error(\n `${VETRA_STUDIO_PACKAGE} was installed, but this ph-cli does not find it from ${projectPath}. ${manual}`,\n );\n }\n deps.log(plan.notice);\n deps.log(`> ${plan.command}`);\n const code = await deps.install(plan.command, projectPath);\n if (code !== 0) {\n const how = code === null ? \"could not run\" : `exited with code ${code}`;\n throw new Error(\n `The install of ${VETRA_STUDIO_PACKAGE} ${how}, so Vetra Studio cannot start. ${manual}`,\n );\n }\n if (deps.installedStudio(projectPath) === undefined) {\n throw new Error(\n `The install passed, but ${VETRA_STUDIO_PACKAGE} does not resolve from ${projectPath}. ${manual}`,\n );\n }\n return { exitCode: await deps.reexec(runArgs, projectPath) };\n}\n\n/** The package's version as `ph run <package>/<host>` finds it: from the\n * project root, by its package.json, without importing it. */\nexport function installedStudio(projectRoot: string): InstalledStudio {\n const root = resolvePackageRoot(projectRoot, VETRA_STUDIO_PACKAGE);\n if (root === undefined) return undefined;\n try {\n const { version } = JSON.parse(\n readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as { version?: unknown };\n return { version: typeof version === \"string\" ? version : undefined };\n } catch {\n return { version: undefined };\n }\n}\n\nfunction runInstall(command: string, cwd: string): Promise<number | null> {\n return new Promise((resolve) => {\n // One command line, as printed: a shell runs the package manager's shim.\n const child = spawn(command, {\n cwd,\n stdio: \"inherit\",\n shell: true,\n windowsHide: true,\n });\n child.once(\"error\", () => resolve(null));\n child.once(\"close\", (code) => resolve(code));\n });\n}\n\nfunction reexecPhCli(args: string[], cwd: string): Promise<number> {\n const child = spawn(process.execPath, [process.argv[1], ...args], {\n cwd,\n stdio: \"inherit\",\n env: { ...process.env, [VETRA_GATEWAY_ENV]: \"1\" },\n windowsHide: true,\n });\n // Ctrl-C reaches the child from the terminal as well: wait while it stops.\n const ignore = () => {};\n const forward = (signal: NodeJS.Signals) => child.kill(signal);\n process.on(\"SIGINT\", ignore);\n process.on(\"SIGTERM\", forward);\n return new Promise<number>((resolve) => {\n const done = (code: number) => {\n process.off(\"SIGINT\", ignore);\n process.off(\"SIGTERM\", forward);\n resolve(code);\n };\n child.once(\"error\", () => done(1));\n child.once(\"exit\", (code) => done(code ?? 1));\n });\n}\n\n/** cli.ts's `ph vetra`: the command line to go on with, in the project root,\n * or the exit code of the ph-cli that ran it. */\nexport async function vetraGateway(\n rest: readonly string[],\n): Promise<{ args: string[] } | { exitCode: number }> {\n const result = await openVetraStudio(rest, {\n project: async () => {\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n return getPowerhouseProjectInfo(undefined, { silent: true });\n },\n phCliVersion: getVersion(),\n installedStudio,\n install: runInstall,\n reexec: reexecPhCli,\n env: process.env,\n log: (message) => console.log(message),\n warn: (message) => console.warn(yellow(message)),\n });\n if (\"args\" in result && path.resolve(result.projectRoot) !== process.cwd()) {\n // As ph-cmd runs ph-cli: in the project root, with relative paths still\n // meaning the caller's cwd.\n process.env[CALLER_CWD_ENV] ??= process.cwd();\n process.chdir(result.projectRoot);\n }\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,uBAAuB;AACpC,MAAa,oBAAoB,GAAG,qBAAqB;;;AAIzD,MAAa,oBAAoB;;;AAWjC,SAAgB,qBACd,OACA,cACQ;CAER,MAAM,UAAU,MAAM,YAAY,KAAK;CAGvC,MAAM,aAAa,MAAM,WAAW,MAAM,IACtC,CAAC,gCAAgC,IACjC,CAAC;CACL,MAAM,WAAW,eAAe,OAAO,OAAO;EAC5C;EACA,GAAG,qBAAqB,GAAG;EAC3B,GAAG;CACL,CAAC;CACD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6DAA6D,MAAM,GACrE;CAEF,OAAO,CAAC,SA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AAO;CAC7B,OAAO,IAAI,SAAiB,YAAY;EACtC,MAAM,QAAQ,SAAiB;GAC7B,QAAQ,IAAI,UAAU,MAAM;GAC5B,QAAQ,IAAI,WAAW,OAAO;GAC9B,QAAQ,IAAI;EACd;EACA,MAAM,KAAK,eAAe,KAAK,CAAC,CAAC;EACjC,MAAM,KAAK,SAAS,SAAS,KAAK,QAAQ,CAAC,CAAC;CAC9C,CAAC;AACH;;;AAIA,eAAsB,aACpB,MACoD;CACpD,MAAM,SAAS,MAAM,gBAAgB,MAAM;EACzC,SAAS,YAAY;GACnB,MAAM,EAAE,6BACN,MAAM,OAAO;GACf,OAAO,yBAAyB,KAAA,GAAW,EAAE,QAAQ,KAAK,CAAC;EAC7D;EACA,cAAc,WAAW;EACzB;EACA,SAAS;EACT,QAAQ;EACR,KAAK,QAAQ;EACb,MAAM,YAAY,QAAQ,IAAI,OAAO;EACrC,OAAO,YAAY,QAAQ,KAAK,OAAO,OAAO,CAAC;CACjD,CAAC;CACD,IAAI,UAAU,UAAU,KAAK,QAAQ,OAAO,WAAW,MAAM,QAAQ,IAAI,GAAG;EAG1E,QAAQ,IAAI,oBAAoB,QAAQ,IAAI;EAC5C,QAAQ,MAAM,OAAO,WAAW;CAClC;CACA,OAAO;AACT","debug_id":"095468ff-56b1-5405-8789-37d4846f9fc8"}
1
+ {"version":3,"file":"vetra-gateway-BZJEJiGT.mjs","sources":["../src/services/vetra-gateway.ts"],"sourcesContent":["import { resolvePackageRoot } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport { yellow } from \"colorette\";\nimport { spawn } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { resolveCommand, type Agent } from \"package-manager-detector\";\nimport { valid } from \"semver\";\nimport { getVersion } from \"../get-version.js\";\n\n/**\n * `ph vetra` is the gateway to Vetra Studio, the host `studio` that the\n * package @powerhousedao/vetra-cli supplies. ph-cli names the package and the\n * host and nothing else of it: `ph vetra [verb] [args]` is\n * `ph run @powerhousedao/vetra-cli/studio [verb] [args]`, once the project\n * has the package. A project without it gets it first, as a devDependency at\n * this ph-cli's version: the two are released with the same version numbers.\n */\nexport const VETRA_STUDIO_PACKAGE = \"@powerhousedao/vetra-cli\";\nexport const VETRA_STUDIO_HOST = `${VETRA_STUDIO_PACKAGE}/studio`;\n\n/** Set on the ph-cli started after an install: it finds the package, or\n * fails, and never installs it again. */\nexport const VETRA_GATEWAY_ENV = \"PH_VETRA_GATEWAY_INSTALLED\";\n\n/** The package as the project has it; undefined when it has none. */\nexport type InstalledStudio = { version: string | undefined } | undefined;\n\nexport type VetraGatewayPlan =\n | { action: \"run\"; warning?: string }\n | { action: \"install\"; notice: string; command: string };\n\n/** The command line that adds the package at ph-cli's version as a\n * devDependency, with the project's package manager. */\nexport function studioInstallCommand(\n agent: Agent,\n phCliVersion: string,\n): string {\n // A build that does not know its version takes the latest release.\n const version = valid(phCliVersion) ?? \"latest\";\n // As `ph install --local`: on a release day the packages are younger than\n // pnpm 11's minimumReleaseAge.\n const releaseAge = agent.startsWith(\"pnpm\")\n ? [\"--config.minimum-release-age=0\"]\n : [];\n const resolved = resolveCommand(agent, \"add\", [\n \"-D\",\n `${VETRA_STUDIO_PACKAGE}@${version}`,\n ...releaseAge,\n ]);\n if (!resolved) {\n throw new Error(\n `Could not resolve an install command for package manager \"${agent}\".`,\n );\n }\n return [resolved.command, ...resolved.args].join(\" \");\n}\n\n/** What `ph vetra` does in a project: install the package, or run its host,\n * warning when the installed version is not ph-cli's. */\nexport function planVetraGateway(facts: {\n installed: InstalledStudio;\n phCliVersion: string;\n packageManager: Agent;\n}): VetraGatewayPlan {\n const { installed, phCliVersion, packageManager } = facts;\n const command = studioInstallCommand(packageManager, phCliVersion);\n if (installed === undefined) {\n return {\n action: \"install\",\n notice:\n `Vetra Studio is the package ${VETRA_STUDIO_PACKAGE}, which this project does not have yet. ` +\n `Installing it as a devDependency with ${packageManager}:`,\n command,\n };\n }\n const { version } = installed;\n if (\n version !== undefined &&\n valid(phCliVersion) !== null &&\n version !== phCliVersion\n ) {\n return {\n action: \"run\",\n warning: `${VETRA_STUDIO_PACKAGE} ${version} is installed, but this ph-cli is ${phCliVersion}: align them with \\`${command}\\`.`,\n };\n }\n return { action: \"run\" };\n}\n\nexport interface VetraGatewayDeps {\n /** The project root, undefined outside a project, and its package manager. */\n project: () => Promise<{ projectPath?: string; packageManager: Agent }>;\n phCliVersion: string;\n installedStudio: (projectRoot: string) => InstalledStudio;\n /** Runs an install command line in `cwd`; resolves to its exit code. */\n install: (command: string, cwd: string) => Promise<number | null>;\n /** Runs this ph-cli with `args` in a new process; resolves to its exit code. */\n reexec: (args: string[], cwd: string) => Promise<number>;\n env: NodeJS.ProcessEnv;\n log: (message: string) => void;\n warn: (message: string) => void;\n}\n\nexport type VetraGatewayResult =\n /** Go on with this command line, in the project root. */\n | { args: string[]; projectRoot: string }\n /** A new ph-cli ran it, after the install. */\n | { exitCode: number };\n\n/**\n * `ph vetra [verb] [args]` (`rest`) in the project: the `ph run` command line\n * of the studio host when the package is there. Otherwise it installs the\n * package and runs that command line in a new ph-cli, since a package\n * installed while this one runs is not reliably resolved by it (Node caches\n * lookups, and the install may relink what it imports later).\n */\nexport async function openVetraStudio(\n rest: readonly string[],\n deps: VetraGatewayDeps,\n): Promise<VetraGatewayResult> {\n const { projectPath, packageManager } = await deps.project();\n if (projectPath === undefined) {\n throw new Error(\n \"No Powerhouse project found, so `ph vetra` cannot open Vetra Studio: it installs into and runs in a project. \" +\n \"Run it in one, or create one with `ph init`.\",\n );\n }\n const runArgs = [\"run\", VETRA_STUDIO_HOST, ...rest];\n const plan = planVetraGateway({\n installed: deps.installedStudio(projectPath),\n phCliVersion: deps.phCliVersion,\n packageManager,\n });\n if (plan.action === \"run\") {\n if (plan.warning) deps.warn(plan.warning);\n return { args: runArgs, projectRoot: projectPath };\n }\n // A stop reads the run record only: there is nothing to install for it.\n if (rest.includes(\"--stop\"))\n return { args: runArgs, projectRoot: projectPath };\n const manual = `Install it yourself, then run \\`ph vetra\\` again:\\n ${plan.command}`;\n if (deps.env[VETRA_GATEWAY_ENV]) {\n throw new Error(\n `${VETRA_STUDIO_PACKAGE} was installed, but this ph-cli does not find it from ${projectPath}. ${manual}`,\n );\n }\n deps.log(plan.notice);\n deps.log(`> ${plan.command}`);\n const code = await deps.install(plan.command, projectPath);\n if (code !== 0) {\n const how = code === null ? \"could not run\" : `exited with code ${code}`;\n throw new Error(\n `The install of ${VETRA_STUDIO_PACKAGE} ${how}, so Vetra Studio cannot start. ${manual}`,\n );\n }\n if (deps.installedStudio(projectPath) === undefined) {\n throw new Error(\n `The install passed, but ${VETRA_STUDIO_PACKAGE} does not resolve from ${projectPath}. ${manual}`,\n );\n }\n return { exitCode: await deps.reexec(runArgs, projectPath) };\n}\n\n/** The package's version as `ph run <package>/<host>` finds it: from the\n * project root, by its package.json, without importing it. */\nexport function installedStudio(projectRoot: string): InstalledStudio {\n const root = resolvePackageRoot(projectRoot, VETRA_STUDIO_PACKAGE);\n if (root === undefined) return undefined;\n try {\n const { version } = JSON.parse(\n readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as { version?: unknown };\n return { version: typeof version === \"string\" ? version : undefined };\n } catch {\n return { version: undefined };\n }\n}\n\nfunction runInstall(command: string, cwd: string): Promise<number | null> {\n return new Promise((resolve) => {\n // One command line, as printed: a shell runs the package manager's shim.\n const child = spawn(command, {\n cwd,\n stdio: \"inherit\",\n shell: true,\n windowsHide: true,\n });\n child.once(\"error\", () => resolve(null));\n child.once(\"close\", (code) => resolve(code));\n });\n}\n\nfunction reexecPhCli(args: string[], cwd: string): Promise<number> {\n const child = spawn(process.execPath, [process.argv[1], ...args], {\n cwd,\n stdio: \"inherit\",\n env: { ...process.env, [VETRA_GATEWAY_ENV]: \"1\" },\n windowsHide: true,\n });\n // Ctrl-C reaches the child from the terminal as well: wait while it stops.\n const ignore = () => {};\n const forward = (signal: NodeJS.Signals) => child.kill(signal);\n process.on(\"SIGINT\", ignore);\n process.on(\"SIGTERM\", forward);\n return new Promise<number>((resolve) => {\n const done = (code: number) => {\n process.off(\"SIGINT\", ignore);\n process.off(\"SIGTERM\", forward);\n resolve(code);\n };\n child.once(\"error\", () => done(1));\n child.once(\"exit\", (code) => done(code ?? 1));\n });\n}\n\n/** cli.ts's `ph vetra`: the command line to go on with, in the project root,\n * or the exit code of the ph-cli that ran it. */\nexport async function vetraGateway(\n rest: readonly string[],\n): Promise<{ args: string[] } | { exitCode: number }> {\n const result = await openVetraStudio(rest, {\n project: async () => {\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n return getPowerhouseProjectInfo(undefined, { silent: true });\n },\n phCliVersion: getVersion(),\n installedStudio,\n install: runInstall,\n reexec: reexecPhCli,\n env: process.env,\n log: (message) => console.log(message),\n warn: (message) => console.warn(yellow(message)),\n });\n if (\"args\" in result && path.resolve(result.projectRoot) !== process.cwd()) {\n // As ph-cmd runs ph-cli: in the project root, with relative paths still\n // meaning the caller's cwd.\n process.env[CALLER_CWD_ENV] ??= process.cwd();\n process.chdir(result.projectRoot);\n }\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,uBAAuB;AACpC,MAAa,oBAAoB,GAAG,qBAAqB;;;AAIzD,MAAa,oBAAoB;;;AAWjC,SAAgB,qBACd,OACA,cACQ;CAER,MAAM,UAAU,MAAM,YAAY,KAAK;CAGvC,MAAM,aAAa,MAAM,WAAW,MAAM,IACtC,CAAC,gCAAgC,IACjC,CAAC;CACL,MAAM,WAAW,eAAe,OAAO,OAAO;EAC5C;EACA,GAAG,qBAAqB,GAAG;EAC3B,GAAG;CACL,CAAC;CACD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6DAA6D,MAAM,GACrE;CAEF,OAAO,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,GAAG;AACtD;;;AAIA,SAAgB,iBAA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IAAI,UAAU,MAAM;GAC5B,QAAQ,IAAI,WAAW,OAAO;GAC9B,QAAQ,IAAI;EACd;EACA,MAAM,KAAK,eAAe,KAAK,CAAC,CAAC;EACjC,MAAM,KAAK,SAAS,SAAS,KAAK,QAAQ,CAAC,CAAC;CAC9C,CAAC;AACH;;;AAIA,eAAsB,aACpB,MACoD;CACpD,MAAM,SAAS,MAAM,gBAAgB,MAAM;EACzC,SAAS,YAAY;GACnB,MAAM,EAAE,6BACN,MAAM,OAAO;GACf,OAAO,yBAAyB,KAAA,GAAW,EAAE,QAAQ,KAAK,CAAC;EAC7D;EACA,cAAc,WAAW;EACzB;EACA,SAAS;EACT,QAAQ;EACR,KAAK,QAAQ;EACb,MAAM,YAAY,QAAQ,IAAI,OAAO;EACrC,OAAO,YAAY,QAAQ,KAAK,OAAO,OAAO,CAAC;CACjD,CAAC;CACD,IAAI,UAAU,UAAU,KAAK,QAAQ,OAAO,WAAW,MAAM,QAAQ,IAAI,GAAG;EAG1E,QAAQ,IAAI,oBAAoB,QAAQ,IAAI;EAC5C,QAAQ,MAAM,OAAO,WAAW;CAClC;CACA,OAAO;AACT","debug_id":"c706a387-cc5f-5c1d-8c47-db0b80688ee2"}
@@ -0,0 +1,4 @@
1
+ import { c as vetraGateway } from "./vetra-gateway-BZJEJiGT.mjs";
2
+ export { vetraGateway };
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6fcb8f6a-1c3f-5d03-9613-0357ed1b67af")}catch(e){}}();
4
+ //# debugId=6fcb8f6a-1c3f-5d03-9613-0357ed1b67af
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "6.4.0-next.5",
3
+ "version": "6.4.0-next.6",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -40,19 +40,19 @@
40
40
  "dependencies": {
41
41
  "@modelcontextprotocol/sdk": "1.29.0",
42
42
  "@originjs/vite-plugin-commonjs": "^1.0.3",
43
- "@powerhousedao/builder-tools": "6.4.0-next.5",
44
- "@powerhousedao/codegen": "6.4.0-next.5",
45
- "@powerhousedao/common": "6.4.0-next.5",
46
- "@powerhousedao/config": "6.4.0-next.5",
47
- "@powerhousedao/devtools": "6.4.0-next.5",
48
- "@powerhousedao/ph-run": "6.4.0-next.5",
49
- "@powerhousedao/reactor": "6.4.0-next.5",
50
- "@powerhousedao/reactor-api": "6.4.0-next.5",
51
- "@powerhousedao/reactor-browser": "6.4.0-next.5",
52
- "@powerhousedao/reactor-mcp": "6.4.0-next.5",
53
- "@powerhousedao/shared": "6.4.0-next.5",
54
- "@powerhousedao/switchboard": "6.4.0-next.5",
55
- "@renown/sdk": "6.4.0-next.5",
43
+ "@powerhousedao/builder-tools": "6.4.0-next.6",
44
+ "@powerhousedao/codegen": "6.4.0-next.6",
45
+ "@powerhousedao/common": "6.4.0-next.6",
46
+ "@powerhousedao/config": "6.4.0-next.6",
47
+ "@powerhousedao/devtools": "6.4.0-next.6",
48
+ "@powerhousedao/ph-run": "6.4.0-next.6",
49
+ "@powerhousedao/reactor": "6.4.0-next.6",
50
+ "@powerhousedao/reactor-api": "6.4.0-next.6",
51
+ "@powerhousedao/reactor-browser": "6.4.0-next.6",
52
+ "@powerhousedao/reactor-mcp": "6.4.0-next.6",
53
+ "@powerhousedao/shared": "6.4.0-next.6",
54
+ "@powerhousedao/switchboard": "6.4.0-next.6",
55
+ "@renown/sdk": "6.4.0-next.6",
56
56
  "@sentry/node-core": "^10.52.0",
57
57
  "@tsdown/css": "0.23.0",
58
58
  "@vercel/nft": "^1.11.0",
@@ -61,7 +61,7 @@
61
61
  "change-case": "5.4.4",
62
62
  "cmd-ts": "0.15.0",
63
63
  "colorette": "2.0.20",
64
- "document-model": "6.4.0-next.5",
64
+ "document-model": "6.4.0-next.6",
65
65
  "dotenv": "16.4.7",
66
66
  "enquirer": "2.4.1",
67
67
  "graphql": "^16",
@@ -83,8 +83,8 @@
83
83
  "copyfiles": "2.4.1",
84
84
  "write-package": "7.2.0",
85
85
  "zod": "^4.5.4",
86
- "@powerhousedao/desktop": "6.4.0-next.5",
87
- "@powerhousedao/host-core": "6.4.0-next.5"
86
+ "@powerhousedao/desktop": "6.4.0-next.6",
87
+ "@powerhousedao/host-core": "6.4.0-next.6"
88
88
  },
89
89
  "scripts": {
90
90
  "tsc": "tsc",
@@ -1,4 +0,0 @@
1
- import { t as runBuild } from "./build-CBKlv5E3.mjs";
2
- export { runBuild };
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]="3cb62c96-d0f0-51f3-ae15-b0b9ff4ec466")}catch(e){}}();
4
- //# debugId=3cb62c96-d0f0-51f3-ae15-b0b9ff4ec466
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-build-DpGUrtct.mjs","sources":["../src/utils/precompress.ts","../src/services/connect-build.ts"],"sourcesContent":["import { PRECOMPRESS_EXTENSIONS } from \"@powerhousedao/ph-run/connect-serve\";\nimport { createHash } from \"node:crypto\";\nimport { readdir, readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { gzip } from \"node:zlib\";\n\nconst gzipAsync = promisify(gzip);\n\nexport { PRECOMPRESS_EXTENSIONS };\n\n/** A sibling is written only when it is at most this fraction of the source. */\nconst MAX_RATIO = 0.9;\n\nexport type PrecompressResult = {\n files: number;\n written: number;\n skipped: number;\n inputBytes: number;\n outputBytes: number;\n ms: number;\n};\n\nasync function findTargets(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { recursive: true, withFileTypes: true });\n return entries\n .filter(\n (e) =>\n e.isFile() &&\n PRECOMPRESS_EXTENSIONS.some((ext) => e.name.endsWith(ext)),\n )\n .map((e) => join(e.parentPath, e.name));\n}\n\nasync function isFresh(source: string, sibling: string): Promise<boolean> {\n try {\n const [s, c] = await Promise.all([stat(source), stat(sibling)]);\n return c.mtimeMs >= s.mtimeMs;\n } catch {\n return false;\n }\n}\n\n/** Write gzip siblings for every `.wasm`/`.data` under `dir`. */\nexport async function precompressAssets(\n dir: string,\n): Promise<PrecompressResult> {\n const start = performance.now();\n const targets = await findTargets(dir);\n const result: PrecompressResult = {\n files: targets.length,\n written: 0,\n skipped: 0,\n inputBytes: 0,\n outputBytes: 0,\n ms: 0,\n };\n // Vendor and worker copies share content: compress each distinct file once.\n const byHash = new Map<string, Promise<Buffer | null>>();\n\n await Promise.all(\n targets.map(async (file) => {\n const sibling = file + \".gz\";\n if (await isFresh(file, sibling)) {\n result.skipped += 1;\n return;\n }\n const source = await readFile(file);\n result.inputBytes += source.length;\n const hash = createHash(\"sha256\").update(source).digest(\"hex\");\n let compressed = byHash.get(hash);\n if (!compressed) {\n compressed = gzipAsync(source, { level: 9 }).then((out) =>\n out.length <= source.length * MAX_RATIO ? out : null,\n );\n byHash.set(hash, compressed);\n }\n const out = await compressed;\n if (!out) {\n await rm(sibling, { force: true });\n result.skipped += 1;\n return;\n }\n await writeFile(sibling, out);\n result.written += 1;\n result.outputBytes += out.length;\n }),\n );\n\n result.ms = Math.round(performance.now() - start);\n return result;\n}\n\n/** On by default; PH_CONNECT_PRECOMPRESS=0|false disables it. */\nexport function isPrecompressEnabled(\n env: NodeJS.ProcessEnv = process.env,\n): boolean {\n const raw = env.PH_CONNECT_PRECOMPRESS ?? \"1\";\n return raw !== \"0\" && raw !== \"false\";\n}\n","import {\n DEFAULT_VENDOR_INCLUDE,\n DYNAMIC_BASE_PLACEHOLDER,\n directoryContentDigest,\n findPackageRoot,\n getConnectBaseViteConfig,\n missingVendorEntries,\n prebuildConnectVendor,\n ownProjectPackage,\n prebuildReactorWorker,\n prebuildWorkerPackages,\n resolveReactorWorkerSource,\n type PrebuiltReactorWorker,\n type PrebuiltVendor,\n} from \"@powerhousedao/builder-tools\";\nimport { getConfig } from \"@powerhousedao/shared/clis\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport {\n deepMerge,\n normalizeBasePath,\n SHARED_DEP_SPECIFIERS,\n SHARED_SUBPATHS,\n} from \"@powerhousedao/shared/connect\";\nimport { existsSync, mkdirSync, readdirSync, rmSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type { InlineConfig } from \"vite\";\nimport { build, mergeConfig } from \"vite\";\nimport type { ConnectBuildArgs } from \"../types.js\";\nimport { buildCliConnectOverride } from \"../utils/cli-connect-override.js\";\nimport {\n isPrecompressEnabled,\n precompressAssets,\n} from \"../utils/precompress.js\";\nimport { runBuild } from \"./build.js\";\n\nexport async function runConnectBuild(\n args: ConnectBuildArgs,\n callerOverride?: PHConnectRuntimeConfig,\n { routes }: { routes?: string | false } = {},\n) {\n const { outDir, debug, dynamicBase, favicon } = args;\n\n const mode = \"production\";\n const dirname = process.cwd();\n\n // Build has no read mode; a bare positional `<key>` is a user error. The\n // 2-positional `<key> <value>` form is handled inside buildCliConnectOverride\n // so it layers on top of --json + flags like any other override input.\n if (args.keyPositional !== undefined && args.valuePositional === undefined) {\n throw new Error(\n \"ph connect build: positional override requires both <key> and <value> (e.g. `ph connect build connect.renown.url https://renown.staging`). To read a value, use `ph connect config <key>`.\",\n );\n }\n\n // Fail fast if any package marked as provider: \"local\" is missing from\n // node_modules — the Vite plugin that bundles them needs them on disk.\n assertLocalPackagesInstalled(dirname);\n\n // Build the CLI override layers (--json + individual flags + positional)\n // once here so a bad payload fails before we waste a build.\n // `--packages-registry` lands at the top-level `packageRegistryUrl`\n // (mirrors source-config shape); every other flag feeds the connect-block\n // precedence ladder.\n const cli = buildCliConnectOverride(args);\n const { packageRegistryUrl } = cli;\n // A runner's host config sits under the CLI's flags.\n const connectOverride = callerOverride\n ? deepMerge(callerOverride, cli.connectOverride ?? {})\n : cli.connectOverride;\n\n await runBuild({\n outDir: \"dist\",\n debug,\n // Local packages built for Connect share deps with the app vendor, same\n // as a plain `ph build`.\n noSharedDeps: false,\n ignoreTypeErrors: false,\n release: false,\n });\n\n // Production shared-dependency vendor: prebuilt into <outDir>/__vendor__\n // before the app build. On by default; PH_CONNECT_VENDOR=0|false disables\n // it. A failed prebuild fails the build — production must not ship import\n // map entries pointing at a vendor that was never built (the dev server\n // keeps its own soft fallback in the dev plugin).\n const outDirAbs = resolve(dirname, outDir);\n let vendor: PrebuiltVendor | null = null;\n // The deploy base the vendor's import-map addresses are written against.\n // Only meaningful when the vendor is built; \"/\" is the inert default.\n let appBase = \"/\";\n // The prebuild out dirs' parent must exist before the prebuilds: their\n // build locks are siblings of the out dirs, and the package build\n // (runBuild) writes to a different out dir, so nothing else creates it yet.\n mkdirSync(outDirAbs, { recursive: true });\n if (isVendorEnabled()) {\n const errorRef: { message?: string } = {};\n // The same base string the app build uses below: the dynamic-base\n // placeholder, or the normalized deploy base (CLI override wins over the\n // source config). The vendor worker appends its own segment.\n const phConfig = getConfig(join(dirname, \"powerhouse.config.json\"));\n const connectBasePath =\n connectOverride?.app?.basePath ?? phConfig.connect?.app?.basePath;\n appBase = dynamicBase\n ? DYNAMIC_BASE_PLACEHOLDER\n : connectBasePath\n ? normalizeBasePath(connectBasePath)\n : \"/\";\n vendor = await prebuildConnectVendor({\n dirname,\n include: productionVendorInclude(),\n vendorDir: join(outDirAbs, \"__vendor__\"),\n base: appBase,\n nodeEnv: \"production\",\n errorRef,\n ...connectOwnVendorDeps(dirname),\n });\n if (!vendor) {\n console.error(\n `ph connect build: the shared-dependency vendor failed to build${\n errorRef.message ? `:\\n${errorRef.message}` : \"\"\n }`,\n );\n throw new Error(\"shared-dependency vendor prebuild failed\");\n }\n }\n\n // Reactor SharedWorker bundle: the dist worker is a library artifact whose\n // bare imports no worker can resolve (import maps do not apply to workers),\n // so the deployable form is prebuilt here. With a vendor, its shared deps\n // are externalized onto ../__vendor__/ so page and worker share one cache\n // entry per dep; without one it is fully self-contained.\n const reactorWorker = await prebuildReactorWorkerBundle(\n dirname,\n outDirAbs,\n vendor,\n connectOverride,\n );\n\n // Local project models the worker cannot get from the registry, built into\n // the worker bundle's own directory so they share its vendor.\n if (reactorWorker) {\n await prebuildLocalWorkerPackages(\n dirname,\n outDirAbs,\n vendor,\n reactorWorker.vendorImports,\n );\n }\n\n const keepDirs = [\n ...(vendor ? [\"__vendor__\"] : []),\n ...(reactorWorker ? [\"__reactor_worker__\"] : []),\n ];\n // Stale top-level output goes, the prebuilt dirs stay: the app build below\n // runs with emptyOutDir: false and must not wipe them.\n if (keepDirs.length > 0) {\n cleanDistExcept(outDirAbs, keepDirs);\n }\n\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n cliConnectOverride: connectOverride,\n cliPackageRegistryUrl: packageRegistryUrl,\n dynamicBase,\n favicon,\n routes,\n // Vendor import-map entries are relative (leading slash stripped) so\n // they resolve against the page URL under any deploy base — root or\n // subpath, dynamic or concrete.\n vendor: vendor\n ? {\n imports: vendorImportMapEntries(vendor.imports, appBase),\n versions: vendor.versions,\n sharedDeps: vendorImportMapEntries(\n { sharedDeps: vendor.sharedDeps },\n appBase,\n ).sharedDeps,\n }\n : undefined,\n reactorWorkerVersion: reactorWorker\n ? directoryContentDigest(join(outDirAbs, \"__reactor_worker__\"))\n : undefined,\n });\n\n const buildConfig: InlineConfig = {\n build: {\n outDir,\n // The vendor / worker dirs were prebuilt into the out dir above; the\n // build must not empty them.\n ...(keepDirs.length > 0 ? { emptyOutDir: false } : {}),\n },\n };\n\n const config = mergeConfig(baseConfig, buildConfig);\n\n await build(config);\n\n // Last word on the shipped artifact: every specifier the page's import map\n // publishes must have a file next to it. The prebuild verifies its own\n // output, but it can return a cache hit it never rebuilt, and both the\n // stale-output clean and the app build run afterwards. An entry with no\n // file behind it ships as a URL that 404s, and a SPA answers that with\n // index.html — so the browser reports only an opaque MIME-type error with\n // no filename. Fail here instead, naming the entries.\n if (vendor) {\n const unbacked = missingVendorEntries(\n join(outDirAbs, \"__vendor__\"),\n vendor.imports,\n );\n if (unbacked.length > 0) {\n throw new Error(\n `ph connect build: the shared-dependency vendor is missing ` +\n `${unbacked.length} of the ${Object.keys(vendor.imports).length} ` +\n `entries its import map publishes:\\n` +\n unbacked.map((e) => ` ${e.spec} -> ${e.url}`).join(\"\\n\"),\n );\n }\n }\n\n // Runs after the PWA plugin, so the siblings never enter the precache list.\n if (isPrecompressEnabled()) {\n const r = await precompressAssets(outDirAbs);\n console.log(\n `ph connect build: precompressed ${r.files} wasm/data files ` +\n `(${r.written} .gz written, ${(r.outputBytes / 1e6).toFixed(1)} MB) in ${(r.ms / 1000).toFixed(1)}s`,\n );\n }\n}\n\n/**\n * The specifier set the production vendor bundles: the dev-proven heavy set\n * ∪ the package-shared set — everything the app and loaded packages\n * externalize onto the vendor.\n *\n * Two specifiers are deliberately dropped:\n *\n * - `@powerhousedao/connect`. It is in DEFAULT_VENDOR_INCLUDE because the dev\n * server vendors the app to keep rebuilds cheap, but in a production build\n * the app *is* Connect: `SHARED_DEP_SPECIFIERS` omits it, so the app build\n * never externalizes it and nothing would ever resolve its import-map\n * entry. Vendoring it is not merely dead weight — bundling Connect's dist\n * for the browser pulls in its node-only `@powerhousedao/config/node`\n * import, and so `read-pkg` -> `unicorn-magic`, whose browser entry has no\n * `toPath`. That fails the vendor build, and a failed prebuild fails\n * `ph connect build`.\n * - the bare `@powerhousedao/shared` root, whose barrel likewise reaches\n * node-only modules. Its browser-safe subpaths (SHARED_SUBPATHS) are\n * listed instead; a package importing the bare root bundles its own copy.\n */\nexport function productionVendorInclude(): string[] {\n return [\n ...new Set([\n ...DEFAULT_VENDOR_INCLUDE.filter((s) => s !== \"@powerhousedao/connect\"),\n ...SHARED_DEP_SPECIFIERS.filter((s) => s !== \"@powerhousedao/shared\"),\n ...SHARED_SUBPATHS.map((s) => `@powerhousedao/shared/${s}`),\n // Connect imports these roots too; unvendored, the app re-bundles their shared chunks.\n \"@powerhousedao/design-system\",\n \"@powerhousedao/reactor\",\n ]),\n ];\n}\n\n/** Connect's own deps that vendored packages also bundle; projects don't install them. */\nexport const CONNECT_OWN_VENDOR_DEPS = [\n \"kysely\",\n \"tailwind-merge\",\n \"@renown/sdk\",\n \"@renown/sdk/crypto\",\n \"@renown/sdk/trust\",\n \"@powerhousedao/reactor-attachments/client\",\n // One core and router for Connect and packages; the route tree, config and\n // embedded subpaths stay with the app.\n \"@powerhousedao/connect-core\",\n \"@powerhousedao/connect-core/router\",\n \"@powerhousedao/connect-core/plugins\",\n \"@powerhousedao/connect-core/runtime\",\n \"@powerhousedao/connect-core/views\",\n \"@tanstack/react-router\",\n];\n\nexport function connectOwnVendorDeps(dirname: string): {\n ownDeps?: { specs: string[]; from: string };\n} {\n const from = findPackageRoot(dirname, \"@powerhousedao/connect\");\n return from ? { ownDeps: { specs: CONNECT_OWN_VENDOR_DEPS, from } } : {};\n}\n\n/**\n * Turn the vendor's base-less URLs (`/__vendor__/x.js`) into the addresses\n * the page's import map ships, by prefixing the deploy base.\n *\n * An import map *address* must be a URL or begin with `/`, `./` or `../`;\n * anything else is a bare specifier, which the browser rejects — it drops the\n * entry, resolves the specifier to null, and every shared import then fails\n * with \"blocked by a null value\". So the base is applied rather than the\n * leading slash stripped: a root-relative address is both valid and correct\n * under a subpath deploy, and a dynamic-base build keeps its placeholder for\n * the serving proxy to substitute (the dynamic-base plugin leaves HTML\n * tokens alone by design).\n */\nexport function vendorImportMapEntries(\n imports: Record<string, string>,\n appBase: string,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(imports).map(([spec, url]) => [\n spec,\n `${appBase}/${url}`.replace(/\\/{2,}/g, \"/\"),\n ]),\n );\n}\n\n/**\n * The production vendor prebuild runs on every `ph connect build` unless\n * disabled with PH_CONNECT_VENDOR=0 or false.\n */\nexport function isVendorEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n const raw = env.PH_CONNECT_VENDOR ?? \"1\";\n return raw !== \"0\" && raw !== \"false\";\n}\n\n/**\n * The reactor worker bundle prebuild runs on every `ph connect build` unless\n * disabled with PH_CONNECT_REACTOR_WORKER=0 or false. It is built even when\n * `connect.instance.reactorWorker` is off, because the `?reactorWorker=true`\n * runtime override can enable the feature on a flag-off deployment.\n */\nexport function isReactorWorkerBundleEnabled(\n env: NodeJS.ProcessEnv = process.env,\n): boolean {\n const raw = env.PH_CONNECT_REACTOR_WORKER ?? \"1\";\n return raw !== \"0\" && raw !== \"false\";\n}\n\n/**\n * Prebuild the reactor SharedWorker bundle into `<dist>/__reactor_worker__`.\n * Returns null when the prebuild is disabled, the installed Connect ships no\n * worker entry, or the build fails. A failure only fails `ph connect build`\n * when the project explicitly enables `connect.instance.reactorWorker` —\n * otherwise the feature degrades to unavailable and the build goes on.\n */\nasync function prebuildReactorWorkerBundle(\n dirname: string,\n outDirAbs: string,\n vendor: PrebuiltVendor | null,\n connectOverride: PHConnectRuntimeConfig | undefined,\n): Promise<PrebuiltReactorWorker | null> {\n if (!isReactorWorkerBundleEnabled()) return null;\n if (!resolveReactorWorkerSource(dirname)) return null;\n\n const errorRef: { message?: string } = {};\n const bundle = await prebuildReactorWorker({\n dirname,\n outDir: join(outDirAbs, \"__reactor_worker__\"),\n vendor: vendor\n ? { imports: vendor.imports, dir: join(outDirAbs, \"__vendor__\") }\n : undefined,\n nodeEnv: \"production\",\n errorRef,\n });\n if (bundle) return bundle;\n\n const message = `ph connect build: the reactor worker bundle failed to build${\n errorRef.message ? `:\\n${errorRef.message}` : \"\"\n }`;\n const phConfig = getConfig(join(dirname, \"powerhouse.config.json\"));\n const required =\n connectOverride?.instance?.reactorWorker ??\n phConfig.connect?.instance?.reactorWorker ??\n false;\n if (required) {\n throw new Error(message);\n }\n console.warn(\n `${message}\\nThe reactorWorker feature will be unavailable in this build.`,\n );\n return null;\n}\n\n/**\n * Build the project's `provider: \"local\"` packages into worker-loadable model\n * bundles beside the worker. A failure is a warning, not a build failure: the\n * worker still runs, and documents of registry types still work - only the\n * project's own types would be unavailable in worker mode.\n */\nasync function prebuildLocalWorkerPackages(\n dirname: string,\n outDirAbs: string,\n vendor: PrebuiltVendor | null,\n safeVendorImports: Record<string, string>,\n): Promise<void> {\n const config = getConfig(join(dirname, \"powerhouse.config.json\"));\n const configured = (config.packages ?? [])\n .filter((p) => p.provider === \"local\")\n .map((p) => p.packageName);\n // The project itself is a local package in all but name: a vetra project\n // declares no entry for itself, and its models are the ones the worker\n // cannot otherwise get.\n const own = ownProjectPackage(dirname);\n const localPackages = [...new Set([...configured, ...(own ? [own] : [])])];\n\n const errorRef: { message?: string } = {};\n const built = await prebuildWorkerPackages({\n dirname,\n packages: localPackages,\n outDir: join(outDirAbs, \"__reactor_worker__\", \"packages\"),\n vendor: vendor\n ? { imports: vendor.imports, dir: join(outDirAbs, \"__vendor__\") }\n : undefined,\n safeVendorImports,\n nodeEnv: \"production\",\n errorRef,\n });\n if (!built) {\n console.warn(\n `ph connect build: the reactor worker's local package bundles failed to build${\n errorRef.message ? `:\\n${errorRef.message}` : \"\"\n }\\nDocuments of this project's own types will not load in worker mode.`,\n );\n }\n}\n\n/**\n * Remove every top-level entry of `dist` except the kept names. Used between\n * the vendor prebuild and the app build so stale app output goes but the\n * just-built vendor stays (the build then runs with emptyOutDir: false).\n * Returns the number of entries removed.\n */\nexport function cleanDistExcept(dist: string, keep: string[] = []): number {\n if (!existsSync(dist)) return 0;\n let removed = 0;\n for (const entry of readdirSync(dist)) {\n if (keep.includes(entry)) continue;\n rmSync(join(dist, entry), { recursive: true, force: true });\n removed += 1;\n }\n return removed;\n}\n\nfunction assertLocalPackagesInstalled(projectPath: string) {\n const config = getConfig(join(projectPath, \"powerhouse.config.json\"));\n const localPackages = (config.packages ?? []).filter(\n (p) => p.provider === \"local\",\n );\n if (localPackages.length === 0) return;\n\n const missing = localPackages.filter(\n (p) =>\n !existsSync(\n join(projectPath, \"node_modules\", p.packageName, \"package.json\"),\n ),\n );\n if (missing.length === 0) return;\n\n const names = missing.map((p) => p.packageName);\n throw new Error(\n `ph connect build requires these packages to be installed in node_modules (they are declared with provider: \"local\" in powerhouse.config.json):\\n` +\n names.map((n) => ` - ${n}`).join(\"\\n\") +\n `\\n\\nInstall them with:\\n ph install --local ${names.join(\" \")}`,\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAM,YAAY,UAAU,IAAI;;AAKhC,MAAM,YAAY;AAWlB,eAAe,YAAY,KAAgC;CAEzD,QAAO,MADe,QAAQ,KAAK;EAAE,WAAW;EAAM,eAAe;CAAK,CAAC,EAAA,CAExE,QACE,MACC,EAAE,OAAO,KACT,uBAAuB,MAAM,QAAQ,EAAE,KAAK,SAAS,GAAG,CAAC,CAC7D,CAAC,CACA,KAAK,MAAM,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC;AAC1C;AAEA,eAAe,QAAQ,QAAgB,SAAmC;CACxE,IAAI;EACF,MAAM,CAAC,GAAG,KAAK,MAAM,QAAQ,IAAI,CAAC,KAAK,MAAM,GAAG,KAAK,OAAO,CAAC,CAAC;EAC9D,OAAO,EAAE,WAAW,EAAE;CACxB,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,eAAsB,kBACpB,KAC4B;CAC5B,MAAM,QAAQ,YAAY,IAAI;CAC9B,MAAM,UAAU,MAAM,YAAY,GAAG;CACrC,MAAM,SAA4B;EAChC,OAAO,QAAQ;EACf,SAAS;EACT,SAAS;EACT,YAAY;EACZ,aAAa;EACb,IAAI;CACN;CAEA,MAAM,yBAAS,IAAI,IAAoC;CAEvD,MAAM,QAAQ,IACZ,QAAQ,IAAI,OAAO,SAAS;EAC1B,MAAM,UAAU,OAAO;EACvB,IAAI,MAAM,QAAQ,MAAM,OAAO,GAAG;GAChC,OAAO,WAAW;GAClB;EACF;EACA,MAAM,SAAS,MAAM,SAAS,IAAI;EAClC,OAAO,cAAc,OAAO;EAC5B,MAAM,OAAO,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mjs";
2
- export { migrateSubgraphs };
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]="2d89a6e2-c46d-5e3f-9539-356bffe4555e")}catch(e){}}();
4
- //# debugId=2d89a6e2-c46d-5e3f-9539-356bffe4555e
@@ -1,4 +0,0 @@
1
- import { t as phCliCommands } from "./ph-cli-commands-B5VkGW99.mjs";
2
- export { phCliCommands };
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]="4b8ad038-2963-5d64-93e5-41d89069becd")}catch(e){}}();
4
- //# debugId=4b8ad038-2963-5d64-93e5-41d89069becd
@@ -1,4 +0,0 @@
1
- import { c as vetraGateway } from "./vetra-gateway-D30pZgha.mjs";
2
- export { vetraGateway };
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="033a9cc4-156f-5c3b-804b-ef36519068fd")}catch(e){}}();
4
- //# debugId=033a9cc4-156f-5c3b-804b-ef36519068fd