@powerhousedao/ph-cli 6.2.3-dev.63 → 6.2.3-dev.64

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 (61) hide show
  1. package/dist/{cli-connect-override-DP5vRA7N.mjs → cli-connect-override-Cf7WutqU.mjs} +4 -4
  2. package/dist/{cli-connect-override-DP5vRA7N.mjs.map → cli-connect-override-Cf7WutqU.mjs.map} +1 -1
  3. package/dist/cli.mjs +4 -4
  4. package/dist/{connect-build-xRrXk9-p.mjs → connect-build-DO93w0f7.mjs} +9 -4
  5. package/dist/connect-build-DO93w0f7.mjs.map +1 -0
  6. package/dist/{connect-config-BvS0chVq.mjs → connect-config-9EZB_0H_.mjs} +4 -4
  7. package/dist/{connect-config-BvS0chVq.mjs.map → connect-config-9EZB_0H_.mjs.map} +1 -1
  8. package/dist/{connect-preview-BW6XnRtj.mjs → connect-preview-DqWtPruk.mjs} +62 -16
  9. package/dist/connect-preview-DqWtPruk.mjs.map +1 -0
  10. package/dist/{connect-studio-8EyDblpG.mjs → connect-studio-FEEyWfwB.mjs} +4 -4
  11. package/dist/{connect-studio-8EyDblpG.mjs.map → connect-studio-FEEyWfwB.mjs.map} +1 -1
  12. package/dist/{connect-studio-NxCVdXDv.mjs → connect-studio-k5vB41GX.mjs} +3 -3
  13. package/dist/dist-BqeDFgEy.mjs +2 -2
  14. package/dist/dist-BqeDFgEy.mjs.map +1 -1
  15. package/dist/{explain-D6gLYBd0.mjs → explain-BDHmXgw3.mjs} +4 -4
  16. package/dist/{explain-D6gLYBd0.mjs.map → explain-BDHmXgw3.mjs.map} +1 -1
  17. package/dist/{generate-all-CRfVwLJ9.mjs → generate-all-C_sPGBuk.mjs} +5 -5
  18. package/dist/{generate-all-CRfVwLJ9.mjs.map → generate-all-C_sPGBuk.mjs.map} +1 -1
  19. package/dist/{generate-desktop-shell-itIzf77U.mjs → generate-desktop-shell-BBSGpmud.mjs} +4 -4
  20. package/dist/generate-desktop-shell-BBSGpmud.mjs.map +1 -0
  21. package/dist/{generate-document-model-ChkXjM1s.mjs → generate-document-model-BfFIQ35q.mjs} +5 -5
  22. package/dist/{generate-document-model-ChkXjM1s.mjs.map → generate-document-model-BfFIQ35q.mjs.map} +1 -1
  23. package/dist/{generate-subgraph-DmcQWVbd.mjs → generate-subgraph-CVlTo7qk.mjs} +5 -5
  24. package/dist/{generate-subgraph-DmcQWVbd.mjs.map → generate-subgraph-CVlTo7qk.mjs.map} +1 -1
  25. package/dist/{host-schemas-CL_wFpY7-B_pY14Jy.mjs → host-schemas-CtPNRr5v-BQyKKFbS.mjs} +18 -4
  26. package/dist/host-schemas-CtPNRr5v-BQyKKFbS.mjs.map +1 -0
  27. package/dist/{ph-cli-commands-CLJP7yKV.mjs → ph-cli-commands-ifxjNJoa.mjs} +16 -16
  28. package/dist/{ph-cli-commands-CLJP7yKV.mjs.map → ph-cli-commands-ifxjNJoa.mjs.map} +1 -1
  29. package/dist/ph-cli-commands-qdvATJ2S.mjs +4 -0
  30. package/dist/precompress-P6cJDPVC.mjs +77 -0
  31. package/dist/precompress-P6cJDPVC.mjs.map +1 -0
  32. package/dist/{run-sugar-DveBlJqh.mjs → run-sugar-BdjKTPGO.mjs} +4 -4
  33. package/dist/{run-sugar-DveBlJqh.mjs.map → run-sugar-BdjKTPGO.mjs.map} +1 -1
  34. package/dist/runners/compound.mjs +2 -2
  35. package/dist/runners/connect.mjs +4 -4
  36. package/dist/runners/switchboard.d.mts +59 -0
  37. package/dist/runners/switchboard.d.mts.map +1 -1
  38. package/dist/runners/switchboard.mjs +49 -19
  39. package/dist/runners/switchboard.mjs.map +1 -1
  40. package/dist/{start-run-CASbiOWI.mjs → start-run-CmDxyMw0.mjs} +4 -4
  41. package/dist/{start-run-CASbiOWI.mjs.map → start-run-CmDxyMw0.mjs.map} +1 -1
  42. package/dist/switchboard-C5zgkRl2.mjs +4 -0
  43. package/dist/{switchboard-tQS3fhqa.mjs → switchboard-h4-XgP1h.mjs} +3 -6
  44. package/dist/switchboard-h4-XgP1h.mjs.map +1 -0
  45. package/dist/{switchboard-reset-CX_Lzw3O.mjs → switchboard-reset-MtTB_GAI.mjs} +7 -5
  46. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  47. package/dist/{vetra-BV5F0YeG.mjs → vetra-DPN1SpOC.mjs} +9 -9
  48. package/dist/vetra-DPN1SpOC.mjs.map +1 -0
  49. package/dist/{warn-subgraph-type-conflicts-Jd6SeN-M.mjs → warn-subgraph-type-conflicts-BOHBmThq.mjs} +5 -5
  50. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  51. package/package.json +15 -14
  52. package/dist/connect-build-xRrXk9-p.mjs.map +0 -1
  53. package/dist/connect-preview-BW6XnRtj.mjs.map +0 -1
  54. package/dist/generate-desktop-shell-itIzf77U.mjs.map +0 -1
  55. package/dist/host-schemas-CL_wFpY7-B_pY14Jy.mjs.map +0 -1
  56. package/dist/ph-cli-commands-NHDoX5i7.mjs +0 -4
  57. package/dist/switchboard-BUMqobK4.mjs +0 -4
  58. package/dist/switchboard-reset-CX_Lzw3O.mjs.map +0 -1
  59. package/dist/switchboard-tQS3fhqa.mjs.map +0 -1
  60. package/dist/vetra-BV5F0YeG.mjs.map +0 -1
  61. package/dist/warn-subgraph-type-conflicts-Jd6SeN-M.mjs.map +0 -1
@@ -0,0 +1,77 @@
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]="086e4584-357c-55a5-b622-69bf2833d67f")}catch(e){}}();
3
+ import { join } from "node:path";
4
+ import { createHash } from "node:crypto";
5
+ import { readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
6
+ import { promisify } from "node:util";
7
+ import { gzip } from "node:zlib";
8
+ //#region src/utils/precompress.ts
9
+ const gzipAsync = promisify(gzip);
10
+ /** Extensions whose files get `.gz` siblings. */
11
+ const PRECOMPRESS_EXTENSIONS = [".wasm", ".data"];
12
+ /** A sibling is written only when it is at most this fraction of the source. */
13
+ const MAX_RATIO = .9;
14
+ async function findTargets(dir) {
15
+ return (await readdir(dir, {
16
+ recursive: true,
17
+ withFileTypes: true
18
+ })).filter((e) => e.isFile() && PRECOMPRESS_EXTENSIONS.some((ext) => e.name.endsWith(ext))).map((e) => join(e.parentPath, e.name));
19
+ }
20
+ async function isFresh(source, sibling) {
21
+ try {
22
+ const [s, c] = await Promise.all([stat(source), stat(sibling)]);
23
+ return c.mtimeMs >= s.mtimeMs;
24
+ } catch {
25
+ return false;
26
+ }
27
+ }
28
+ /** Write gzip siblings for every `.wasm`/`.data` under `dir`. */
29
+ async function precompressAssets(dir) {
30
+ const start = performance.now();
31
+ const targets = await findTargets(dir);
32
+ const result = {
33
+ files: targets.length,
34
+ written: 0,
35
+ skipped: 0,
36
+ inputBytes: 0,
37
+ outputBytes: 0,
38
+ ms: 0
39
+ };
40
+ const byHash = /* @__PURE__ */ new Map();
41
+ await Promise.all(targets.map(async (file) => {
42
+ const sibling = file + ".gz";
43
+ if (await isFresh(file, sibling)) {
44
+ result.skipped += 1;
45
+ return;
46
+ }
47
+ const source = await readFile(file);
48
+ result.inputBytes += source.length;
49
+ const hash = createHash("sha256").update(source).digest("hex");
50
+ let compressed = byHash.get(hash);
51
+ if (!compressed) {
52
+ compressed = gzipAsync(source, { level: 9 }).then((out) => out.length <= source.length * MAX_RATIO ? out : null);
53
+ byHash.set(hash, compressed);
54
+ }
55
+ const out = await compressed;
56
+ if (!out) {
57
+ await rm(sibling, { force: true });
58
+ result.skipped += 1;
59
+ return;
60
+ }
61
+ await writeFile(sibling, out);
62
+ result.written += 1;
63
+ result.outputBytes += out.length;
64
+ }));
65
+ result.ms = Math.round(performance.now() - start);
66
+ return result;
67
+ }
68
+ /** On by default; PH_CONNECT_PRECOMPRESS=0|false disables it. */
69
+ function isPrecompressEnabled(env = process.env) {
70
+ const raw = env.PH_CONNECT_PRECOMPRESS ?? "1";
71
+ return raw !== "0" && raw !== "false";
72
+ }
73
+ //#endregion
74
+ export { isPrecompressEnabled as n, precompressAssets as r, PRECOMPRESS_EXTENSIONS as t };
75
+
76
+ //# sourceMappingURL=precompress-P6cJDPVC.mjs.map
77
+ //# debugId=086e4584-357c-55a5-b622-69bf2833d67f
@@ -0,0 +1 @@
1
+ {"version":3,"file":"precompress-P6cJDPVC.mjs","sources":["../src/utils/precompress.ts"],"sourcesContent":["import { 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\n/** Extensions whose files get `.gz` siblings. */\nexport const PRECOMPRESS_EXTENSIONS = [\".wasm\", \".data\"] as const;\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"],"names":[],"mappings":";;;;;;;;AAMA,MAAM,YAAY,UAAU,IAAI;;AAGhC,MAAa,yBAAyB,CAAC,SAAS,OAAO;;AAGvD,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,WAAW,QAAQ,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,OAAO,KAAK;EAC7D,IAAI,aAAa,OAAO,IAAI,IAAI;EAChC,IAAI,CAAC,YAAY;GACf,aAAa,UAAU,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,QACjD,IAAI,UAAU,OAAO,SAAS,YAAY,MAAM,IAClD;GACA,OAAO,IAAI,MAAM,UAAU;EAC7B;EACA,MAAM,MAAM,MAAM;EAClB,IAAI,CAAC,KAAK;GACR,MAAM,GAAG,SAAS,EAAE,OAAO,KAAK,CAAC;GACjC,OAAO,WAAW;GAClB;EACF;EACA,MAAM,UAAU,SAAS,GAAG;EAC5B,OAAO,WAAW;EAClB,OAAO,eAAe,IAAI;CAC5B,CAAC,CACH;CAEA,OAAO,KAAK,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK;CAChD,OAAO;AACT;;AAGA,SAAgB,qBACd,MAAyB,QAAQ,KACxB;CACT,MAAM,MAAM,IAAI,0BAA0B;CAC1C,OAAO,QAAQ,OAAO,QAAQ;AAChC","debug_id":"086e4584-357c-55a5-b622-69bf2833d67f"}
@@ -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]="39b8ffa0-efd8-5cc5-acb9-42b46ae64498")}catch(e){}}();
3
- import { s as probeHostsFolder } from "./host-schemas-CL_wFpY7-B_pY14Jy.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]="4215cd45-e234-54eb-a8bd-ccea24ef2f64")}catch(e){}}();
3
+ import { s as probeHostsFolder } from "./host-schemas-CtPNRr5v-BQyKKFbS.mjs";
4
4
  //#region src/utils/run-sugar.ts
5
5
  /**
6
6
  * `ph <host-name> [verb]` sugar: when the first arg is not a registered
@@ -35,5 +35,5 @@ function applyRunSugar(args, knownCommands, projectRoot) {
35
35
  //#endregion
36
36
  export { applyRunSugar };
37
37
 
38
- //# sourceMappingURL=run-sugar-DveBlJqh.mjs.map
39
- //# debugId=39b8ffa0-efd8-5cc5-acb9-42b46ae64498
38
+ //# sourceMappingURL=run-sugar-BdjKTPGO.mjs.map
39
+ //# debugId=4215cd45-e234-54eb-a8bd-ccea24ef2f64
@@ -1 +1 @@
1
- {"version":3,"file":"run-sugar-DveBlJqh.mjs","sources":["../src/utils/run-sugar.ts"],"sourcesContent":["import { probeHostsFolder } from \"@powerhousedao/host-core\";\n\nexport interface RunSugarResult {\n args: string[];\n /** Set when hosts/ exists but is empty — the guard state: warn loudly, stay legacy. */\n warning?: string;\n}\n\n/**\n * `ph <host-name> [verb]` sugar: when the first arg is not a registered\n * command and names a host in the project's hosts/ folder, splice in `run`\n * (mirrors the connect→`connect studio` default-subcommand rewrite).\n * Built-in commands win collisions by construction — the known-command check\n * runs first. Callers only invoke this when the uniform-runners flag is on.\n */\n/** Classic commands that route through `ph run` in a hosts project — BARE\n * invocations only: extra flags are not representable on `ph run` yet, and\n * the classic path calls the same service, so flagged invocations stay\n * classic until the host-core compound takes over (phase 1). */\nconst CLASSIC_ALIASES = new Set([\"vetra\"]);\n\nexport function applyRunSugar(\n args: string[],\n knownCommands: ReadonlySet<string>,\n projectRoot: string,\n): RunSugarResult {\n const first = args[0];\n if (!first || first.startsWith(\"-\")) {\n return { args };\n }\n if (knownCommands.has(first)) {\n if (CLASSIC_ALIASES.has(first) && args.length === 1) {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", first] };\n }\n }\n return { args };\n }\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"empty\") {\n return {\n args,\n warning:\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js — ` +\n \"uniform-runners stays inactive (legacy command handling).\",\n };\n }\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n return { args };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAM,kCAAkB,IAAI,IAAI,CAAC,OAAO,CAAC;AAEzC,SAAgB,cACd,MACA,eACA,aACgB;CAChB,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,GAChC,OAAO,EAAE,KAAK;CAEhB,IAAI,cAAc,IAAI,KAAK,GAAG;EAC5B,IAAI,gBAAgB,IAAI,KAAK,KAAK,KAAK,WAAW,GAAG;GACnD,MAAM,QAAQ,iBAAiB,WAAW;GAC1C,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,EAAE;EAElC;EACA,OAAO,EAAE,KAAK;CAChB;CACA,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,IAAI,MAAM,SAAS,SACjB,OAAO;EACL;EACA,SACE,oBAAoB,MAAM,IAAI;CAElC;CAEF,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;CAElC,OAAO,EAAE,KAAK;AAChB","debug_id":"39b8ffa0-efd8-5cc5-acb9-42b46ae64498"}
1
+ {"version":3,"file":"run-sugar-BdjKTPGO.mjs","sources":["../src/utils/run-sugar.ts"],"sourcesContent":["import { probeHostsFolder } from \"@powerhousedao/host-core\";\n\nexport interface RunSugarResult {\n args: string[];\n /** Set when hosts/ exists but is empty — the guard state: warn loudly, stay legacy. */\n warning?: string;\n}\n\n/**\n * `ph <host-name> [verb]` sugar: when the first arg is not a registered\n * command and names a host in the project's hosts/ folder, splice in `run`\n * (mirrors the connect→`connect studio` default-subcommand rewrite).\n * Built-in commands win collisions by construction — the known-command check\n * runs first. Callers only invoke this when the uniform-runners flag is on.\n */\n/** Classic commands that route through `ph run` in a hosts project — BARE\n * invocations only: extra flags are not representable on `ph run` yet, and\n * the classic path calls the same service, so flagged invocations stay\n * classic until the host-core compound takes over (phase 1). */\nconst CLASSIC_ALIASES = new Set([\"vetra\"]);\n\nexport function applyRunSugar(\n args: string[],\n knownCommands: ReadonlySet<string>,\n projectRoot: string,\n): RunSugarResult {\n const first = args[0];\n if (!first || first.startsWith(\"-\")) {\n return { args };\n }\n if (knownCommands.has(first)) {\n if (CLASSIC_ALIASES.has(first) && args.length === 1) {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", first] };\n }\n }\n return { args };\n }\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"empty\") {\n return {\n args,\n warning:\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js — ` +\n \"uniform-runners stays inactive (legacy command handling).\",\n };\n }\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n return { args };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAM,kCAAkB,IAAI,IAAI,CAAC,OAAO,CAAC;AAEzC,SAAgB,cACd,MACA,eACA,aACgB;CAChB,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,GAChC,OAAO,EAAE,KAAK;CAEhB,IAAI,cAAc,IAAI,KAAK,GAAG;EAC5B,IAAI,gBAAgB,IAAI,KAAK,KAAK,KAAK,WAAW,GAAG;GACnD,MAAM,QAAQ,iBAAiB,WAAW;GAC1C,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,EAAE;EAElC;EACA,OAAO,EAAE,KAAK;CAChB;CACA,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,IAAI,MAAM,SAAS,SACjB,OAAO;EACL;EACA,SACE,oBAAoB,MAAM,IAAI;CAElC;CAEF,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;CAElC,OAAO,EAAE,KAAK;AAChB","debug_id":"4215cd45-e234-54eb-a8bd-ccea24ef2f64"}
@@ -1,7 +1,7 @@
1
1
 
2
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]="33908ac1-e0c2-5b7a-b255-a5d71dbe11d6")}catch(e){}}();
3
3
  import { a as looseObject, l as string } from "../schemas-BQSPev1x.mjs";
4
- import { c as profileSchema, i as loadHost, t as childrenSchema } from "../host-schemas-CL_wFpY7-B_pY14Jy.mjs";
4
+ import { c as profileSchema, i as loadHost, t as childrenSchema } from "../host-schemas-CtPNRr5v-BQyKKFbS.mjs";
5
5
  //#region src/runners/compound.ts
6
6
  /**
7
7
  * BRIDGE compound runner (uniform-runners phase 0): args derivation, not
@@ -62,7 +62,7 @@ async function run(host, ctx) {
62
62
  connectPort,
63
63
  switchboardPort
64
64
  };
65
- const { startVetra } = await import("../vetra-BV5F0YeG.mjs");
65
+ const { startVetra } = await import("../vetra-DPN1SpOC.mjs");
66
66
  await startVetra(args);
67
67
  }
68
68
  //#endregion
@@ -2,7 +2,7 @@
2
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]="d719951d-9c03-52c7-ab89-60c9ed3ca97c")}catch(e){}}();
3
3
  import { a as looseObject, l as string, n as array, o as number, r as boolean } from "../schemas-BQSPev1x.mjs";
4
4
  import { a as pluginEntrySchema, i as normalizePluginEntries, n as entryActiveForVerb } from "../plugins-CHVv4qup.mjs";
5
- import { a as mergeDefaultDrives, c as profileSchema, f as resolveDriveDeclaration, l as projectDrivesIntoConnect, u as reactorSchema } from "../host-schemas-CL_wFpY7-B_pY14Jy.mjs";
5
+ import { a as mergeDefaultDrives, c as profileSchema, f as resolveDriveDeclaration, l as projectDrivesIntoConnect, u as reactorSchema } from "../host-schemas-CtPNRr5v-BQyKKFbS.mjs";
6
6
  import { i as projectReactorToConnect, n as isStructuralMultiReactor, o as remoteBackendUrls } from "../dist-BqeDFgEy.mjs";
7
7
  import { DEFAULT_CONNECT_STUDIO_PORT } from "@powerhousedao/shared/clis";
8
8
  //#region src/runners/connect.ts
@@ -141,7 +141,7 @@ function callerOverride(host, ctx, verb = "dev") {
141
141
  };
142
142
  }
143
143
  async function dev(host, ctx) {
144
- const { runConnectStudio } = await import("../connect-studio-NxCVdXDv.mjs");
144
+ const { runConnectStudio } = await import("../connect-studio-k5vB41GX.mjs");
145
145
  await runConnectStudio(toStudioArgs(host), void 0, callerOverride(host, ctx, ctx.verb ?? "dev"));
146
146
  }
147
147
  /** `run` is dev-studio until the plugin phases give hosts a production
@@ -149,7 +149,7 @@ async function dev(host, ctx) {
149
149
  const run = dev;
150
150
  /** P3.3 — `build`: the SAME service as classic `ph connect build`. */
151
151
  async function build(host, _ctx) {
152
- const { runConnectBuild } = await import("../connect-build-xRrXk9-p.mjs");
152
+ const { runConnectBuild } = await import("../connect-build-DO93w0f7.mjs");
153
153
  const runner = host.runner;
154
154
  await runConnectBuild({ outDir: typeof runner.outDir === "string" ? runner.outDir : "dist" });
155
155
  }
@@ -162,7 +162,7 @@ async function build(host, _ctx) {
162
162
  * CSP's script-src for the runtime registry — together these replace the
163
163
  * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */
164
164
  async function serve(host, ctx) {
165
- const { runConnectPreview } = await import("../connect-preview-BW6XnRtj.mjs");
165
+ const { runConnectPreview } = await import("../connect-preview-DqWtPruk.mjs");
166
166
  const runner = host.runner;
167
167
  await runConnectPreview({
168
168
  port: typeof runner.port === "number" ? runner.port : DEFAULT_CONNECT_STUDIO_PORT,
@@ -1,4 +1,59 @@
1
1
  import { a as ZodBoolean, c as ZodNumber, d as ZodRecord, f as ZodString, g as $strict, h as $loose, i as ZodArray, l as ZodObject, m as ZodUnknown, n as RunnerContext, o as ZodEnum, p as ZodUnion, r as external_d_exports, s as ZodLiteral, t as HostDefinition, u as ZodOptional } from "../index-CspiP73o.mjs";
2
+ import { ParsedCmdResult } from "@powerhousedao/shared/clis";
3
+ //#region src/commands/switchboard.d.ts
4
+ declare const switchboard: Partial<import("cmd-ts/dist/cjs/argparser.js").Register> & {
5
+ parse(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
6
+ debug: boolean | undefined;
7
+ https: boolean | undefined;
8
+ httpsKeyFile: string | undefined;
9
+ httpsCertFile: string | undefined;
10
+ dev: boolean | undefined;
11
+ remoteDrives: string[];
12
+ disableLocalPackages: boolean;
13
+ packages: string | undefined;
14
+ port: number;
15
+ basePath: string | undefined;
16
+ keypairPath: string | undefined;
17
+ vetraDriveId: string;
18
+ dbPath: string | undefined;
19
+ useIdentity: boolean | undefined;
20
+ requireIdentity: boolean | undefined;
21
+ migrate: boolean | undefined;
22
+ migrateStatus: boolean | undefined;
23
+ reset: boolean | undefined;
24
+ yes: boolean | undefined;
25
+ mcp: boolean;
26
+ useVetraDrive: boolean;
27
+ }>>;
28
+ } & import("cmd-ts/dist/cjs/helpdoc.js").PrintHelp & import("cmd-ts/dist/cjs/helpdoc.js").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc.js").Named & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/argparser.js").Register & import("cmd-ts/dist/cjs/runner.js").Handling<{
29
+ debug: boolean | undefined;
30
+ https: boolean | undefined;
31
+ httpsKeyFile: string | undefined;
32
+ httpsCertFile: string | undefined;
33
+ dev: boolean | undefined;
34
+ remoteDrives: string[];
35
+ disableLocalPackages: boolean;
36
+ packages: string | undefined;
37
+ port: number;
38
+ basePath: string | undefined;
39
+ keypairPath: string | undefined;
40
+ vetraDriveId: string;
41
+ dbPath: string | undefined;
42
+ useIdentity: boolean | undefined;
43
+ requireIdentity: boolean | undefined;
44
+ migrate: boolean | undefined;
45
+ migrateStatus: boolean | undefined;
46
+ reset: boolean | undefined;
47
+ yes: boolean | undefined;
48
+ mcp: boolean;
49
+ useVetraDrive: boolean;
50
+ }, Promise<void>> & {
51
+ run(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<Promise<void>>>;
52
+ } & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned & import("cmd-ts/dist/cjs/helpdoc.js").Descriptive & import("cmd-ts/dist/cjs/helpdoc.js").Aliased>;
53
+ //#endregion
54
+ //#region src/types.d.ts
55
+ type SwitchboardArgs = ParsedCmdResult<typeof switchboard>;
56
+ //#endregion
2
57
  //#region src/runners/switchboard.d.ts
3
58
  /**
4
59
  * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a
@@ -120,6 +175,10 @@ export declare const hostSchema: ZodObject<{
120
175
  }, $strict>>>;
121
176
  }, $strict>>;
122
177
  }, $loose>;
178
+ /** The classic arg shape with the one switch a composition may leave unset. */
179
+ export type SwitchboardRunnerArgs = Omit<SwitchboardArgs, "mcp"> & {
180
+ mcp: boolean | undefined;
181
+ };
123
182
  /** What a started switchboard reports to a supervising compound: its port and
124
183
  * the drive it serves (projected into a connect member's defaultDrives). */
125
184
  export interface SwitchboardHandle {
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.d.mts","names":[],"sources":["../../src/runners/switchboard.ts"],"mappings":";;;;;;;;;qBAgCa;;qBAGA,YAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAcrB;;;iBAoDe;EACf;EACA;EACA,WAAW;EACX,OAAO;;wBAgJa,IACpB,MAAM,gBACN,KAAK,gBACJ,QAAQ;qBAIE,cAAK;wBAEI,IACpB,MAAM,gBACN,KAAK,gBACJ,QAAQ;;;wBAMW,MACpB,MAAM,gBACN,MAAM,gBACL"}
1
+ {"version":3,"file":"switchboard.d.mts","names":[],"sources":["../../src/commands/switchboard.ts","../../src/types.ts","../../src/runners/switchboard.ts"],"mappings":";;;cAGa,aAAW,+CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgDtB,6CAAA,iDAAA,mDAAA;;;KCWU,kBAAkB,uBAAuB;;;;;;;;;;qBCjCxC;;qBAGA,YAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAcrB;;YAGU,wBAAwB,KAAK;EACvC;;;;iBA+De;EACf;EACA;EACA,WAAW;EACX,OAAO;;wBAgJa,IACpB,MAAM,gBACN,KAAK,gBACJ,QAAQ;qBAIE,cAAK;wBAEI,IACpB,MAAM,gBACN,KAAK,gBACJ,QAAQ;;;wBAMW,MACpB,MAAM,gBACN,MAAM,gBACL"}
@@ -1,11 +1,35 @@
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]="4c7bfb64-88a2-57bf-b4d9-3418e87fcd29")}catch(e){}}();
3
- import { a as looseObject, l as string, n as array, o as number, r as boolean } from "../schemas-BQSPev1x.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]="ad7a5128-0c7d-5e23-800d-238273f138ce")}catch(e){}}();
3
+ import { a as looseObject, l as string$1, n as array, o as number, r as boolean$1 } from "../schemas-BQSPev1x.mjs";
4
4
  import { a as pluginEntrySchema } from "../plugins-CHVv4qup.mjs";
5
- import { c as profileSchema, f as resolveDriveDeclaration, m as seedDrives, u as reactorSchema } from "../host-schemas-CL_wFpY7-B_pY14Jy.mjs";
5
+ import { c as profileSchema, f as resolveDriveDeclaration, m as seedDrives, u as reactorSchema } from "../host-schemas-CtPNRr5v-BQyKKFbS.mjs";
6
6
  import { s as resolveHostPlugins } from "../dist-BqeDFgEy.mjs";
7
7
  import { t as applyReactorEnvProjection } from "../reactor-env-BbR86_Li.mjs";
8
- import { DEFAULT_SWITCHBOARD_PORT, DEFAULT_VETRA_DRIVE_ID } from "@powerhousedao/shared/clis";
8
+ import { command, runSafely } from "cmd-ts";
9
+ import { switchboardArgs } from "@powerhousedao/shared/clis/args";
10
+ //#region src/services/classic-args.ts
11
+ /**
12
+ * The classic `ph switchboard` argument shape, produced by the SAME cmd-ts
13
+ * definitions the classic command parses — not re-derived by hand. A runner
14
+ * starts from this object and overlays only the keys its host file owns, so
15
+ * every key the classic command carries (including the ones it carries as
16
+ * `undefined`, e.g. `dbPath`) reaches the service exactly as it does on the
17
+ * classic path. The uniform-runners switchboard runner once hand-built a
18
+ * partial object that omitted `dbPath`; the service's then-default
19
+ * `.ph/read-model.db` became both the reactor and the read-model PGlite dir —
20
+ * two instances on one PGDATA (see uniform-runners-plan/legacy-parity-rectification.md).
21
+ */
22
+ const classicSwitchboard = command({
23
+ name: "switchboard",
24
+ args: switchboardArgs,
25
+ handler: (args) => args
26
+ });
27
+ async function classicSwitchboardArgs(argv = []) {
28
+ const result = await runSafely(classicSwitchboard, argv);
29
+ if (result._tag === "error") throw new Error(`classic switchboard args did not parse: ${result.error.config.message}`);
30
+ return result.value;
31
+ }
32
+ //#endregion
9
33
  //#region src/runners/switchboard.ts
10
34
  /**
11
35
  * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a
@@ -17,27 +41,33 @@ import { DEFAULT_SWITCHBOARD_PORT, DEFAULT_VETRA_DRIVE_ID } from "@powerhousedao
17
41
  const kind = "reactor";
18
42
  /** Phase-2 schema (D2.d): `reactor`/`profile` strict via host-core. */
19
43
  const hostSchema = looseObject({
20
- name: string().min(1),
44
+ name: string$1().min(1),
21
45
  runner: looseObject({
22
- module: string(),
46
+ module: string$1(),
23
47
  port: number().int().positive().optional(),
24
- https: boolean().optional(),
48
+ https: boolean$1().optional(),
25
49
  plugins: array(pluginEntrySchema).optional()
26
50
  }),
27
51
  config: looseObject({}).optional(),
28
52
  profile: profileSchema,
29
53
  reactor: reactorSchema.optional()
30
54
  });
31
- function toSwitchboardArgs(host, devMode, dbPath, composed) {
55
+ /**
56
+ * Start from the classic `ph switchboard` args (parsed by the classic
57
+ * definitions, no flags) and overlay ONLY the keys the host file owns. Every
58
+ * other key — including the ones the classic command carries as `undefined`,
59
+ * such as `dbPath` — reaches the service exactly as on the classic path. No
60
+ * cast: a key the classic shape has and this object lacks is a type error.
61
+ */
62
+ async function toSwitchboardArgs(host, devMode, dbPath, composed) {
63
+ const classic = await classicSwitchboardArgs();
32
64
  const runner = host.runner;
33
65
  return {
34
- port: typeof runner.port === "number" ? runner.port : DEFAULT_SWITCHBOARD_PORT,
35
- vetraDriveId: DEFAULT_VETRA_DRIVE_ID,
36
- mcp: composed ? void 0 : true,
37
- useVetraDrive: false,
38
- remoteDrives: [],
39
- dev: devMode || runner.dev === true,
40
- ...dbPath ? { dbPath } : {}
66
+ ...classic,
67
+ port: typeof runner.port === "number" ? runner.port : classic.port,
68
+ dev: devMode || runner.dev === true ? true : classic.dev,
69
+ mcp: composed ? void 0 : classic.mcp,
70
+ dbPath: dbPath ?? classic.dbPath
41
71
  };
42
72
  }
43
73
  /** The slug of the drive the switchboard creates by default
@@ -85,9 +115,9 @@ function seederClient(reactor, port) {
85
115
  }
86
116
  async function start(host, ctx, devMode) {
87
117
  const options = applyReactorEnvProjection(host.reactor, `hosts/${host.name}/host.js`);
88
- const { startSwitchboard } = await import("../switchboard-BUMqobK4.mjs");
118
+ const { startSwitchboard } = await import("../switchboard-C5zgkRl2.mjs");
89
119
  const entriesDeclared = host.runner.plugins !== void 0;
90
- const args = toSwitchboardArgs(host, devMode, options.dbPath, entriesDeclared);
120
+ const args = await toSwitchboardArgs(host, devMode, options.dbPath, entriesDeclared);
91
121
  const entries = host.runner.plugins;
92
122
  let pluginComposition;
93
123
  if (entries !== void 0) {
@@ -109,7 +139,7 @@ async function start(host, ctx, devMode) {
109
139
  const driveUrl = `http://localhost:${port}/d/${localDrives.length > 0 ? localDrives[0].slug : typeof host.runner.driveSlug === "string" ? host.runner.driveSlug : DEFAULT_DRIVE_SLUG}`;
110
140
  const driveUrls = localDrives.length > 0 ? localDrives.map((d) => `http://localhost:${port}/d/${d.slug}`) : [driveUrl];
111
141
  if (switchboard?.workflowsEnabled) {
112
- const { seedWorkflowsDrive } = await import("../vetra-BV5F0YeG.mjs");
142
+ const { seedWorkflowsDrive } = await import("../vetra-DPN1SpOC.mjs");
113
143
  driveUrls.push(await seedWorkflowsDrive(switchboard.reactor, port));
114
144
  }
115
145
  const ready = waitForDrive(driveUrl, 18e4);
@@ -139,4 +169,4 @@ async function build(host, _ctx) {
139
169
  export { build, dev, hostSchema, kind, run, serve };
140
170
 
141
171
  //# sourceMappingURL=switchboard.mjs.map
142
- //# debugId=4c7bfb64-88a2-57bf-b4d9-3418e87fcd29
172
+ //# debugId=ad7a5128-0c7d-5e23-800d-238273f138ce
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.mjs","sources":["../../src/runners/switchboard.ts"],"sourcesContent":["import {\n DEFAULT_SWITCHBOARD_PORT,\n DEFAULT_VETRA_DRIVE_ID,\n} from \"@powerhousedao/shared/clis\";\nimport {\n profileSchema,\n reactorSchema,\n type HostDefinition,\n type ReactorConfig,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport {\n pluginEntrySchema,\n resolveDriveDeclaration,\n resolveHostPlugins,\n seedDrives,\n type DriveDeclaration,\n type DriveSeederClient,\n type ResolvedDrive,\n} from \"@powerhousedao/host-core\";\nimport { applyReactorEnvProjection } from \"./reactor-env.js\";\nimport { z } from \"zod\";\nimport type { BuildArgs, SwitchboardArgs } from \"../types.js\";\n\n/**\n * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a\n * hosts/switchboard/host.js definition onto the SAME `startSwitchboard`\n * service the classic command calls. `run` = production loaders, `dev` =\n * Vite package loader (worker pools refused by the server, as always).\n * There is deliberately no `build` verb — the switchboard has none.\n */\n\nexport const kind = \"reactor\";\n\n/** Phase-2 schema (D2.d): `reactor`/`profile` strict via host-core. */\nexport const hostSchema = z.looseObject({\n name: z.string().min(1),\n runner: z.looseObject({\n module: z.string(),\n port: z.number().int().positive().optional(),\n https: z.boolean().optional(),\n // THE COMPOSITION (rewire R2): plugin entries, presence is activation.\n // (The classic packages-CSV meaning of this field is retired — packages\n // load via reactor.backends.*.packages / the package manager.)\n plugins: z.array(pluginEntrySchema).optional(),\n }),\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n reactor: reactorSchema.optional(),\n});\n\nfunction toSwitchboardArgs(\n host: HostDefinition,\n devMode: boolean,\n dbPath: string | undefined,\n composed: boolean,\n): SwitchboardArgs {\n const runner = host.runner;\n const args: Partial<SwitchboardArgs> = {\n port:\n typeof runner.port === \"number\" ? runner.port : DEFAULT_SWITCHBOARD_PORT,\n vetraDriveId: DEFAULT_VETRA_DRIVE_ID,\n // A declared composition owns the carved switches; the plugins set them.\n // Classic path keeps the bridge defaults.\n mcp: composed ? undefined : true,\n useVetraDrive: false,\n remoteDrives: [],\n dev: devMode || runner.dev === true,\n ...(dbPath ? { dbPath } : {}),\n };\n return args as SwitchboardArgs;\n}\n\n/** The slug of the drive the switchboard creates by default\n * (apps/switchboard config); `runner.driveSlug` overrides. */\nconst DEFAULT_DRIVE_SLUG = \"powerhouse\";\n\n/** Poll the default drive endpoint until the server answers — the compound's\n * readiness gate: Connect auto-connects the drive on first load, so the drive\n * must answer before the connect member serves (the sidecar's\n * waitForSwitchboard, moved behind the handle contract). */\nasync function waitForDrive(url: string, timeoutMs: number): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n try {\n const res = await fetch(url, { signal: AbortSignal.timeout(3000) });\n if (res.ok) return;\n } catch {\n // not listening yet\n }\n if (Date.now() > deadline) {\n throw new Error(\n `Switchboard drive ${url} did not answer within ${timeoutMs}ms.`,\n );\n }\n await new Promise((resolve) => setTimeout(resolve, 400));\n }\n}\n\n/** What a started switchboard reports to a supervising compound: its port and\n * the drive it serves (projected into a connect member's defaultDrives). */\nexport interface SwitchboardHandle {\n port: number;\n driveUrls: string[];\n endpoints: Record<string, string>;\n ready: Promise<void>;\n}\n\n/** Adapter from the switchboard's reactor client onto the host-core seeder.\n * addDefaultDrive is slug-idempotent itself, so findDriveBySlug delegates. */\nfunction seederClient(reactor: unknown, port: number): DriveSeederClient {\n return {\n findDriveBySlug: () => Promise.resolve(undefined),\n createDrive: async (drive: ResolvedDrive) => {\n const { addDefaultDrive } =\n await import(\"@powerhousedao/switchboard/utils\");\n await addDefaultDrive(\n reactor as Parameters<typeof addDefaultDrive>[0],\n {\n id: drive.id,\n slug: drive.slug,\n global: { name: drive.name, icon: drive.icon },\n ...(drive.preferredEditor\n ? { preferredEditor: drive.preferredEditor }\n : {}),\n local: {\n availableOffline: drive.availableOffline,\n listeners: [],\n sharingType: drive.sharingType,\n triggers: [],\n },\n } as Parameters<typeof addDefaultDrive>[1],\n port,\n );\n },\n attachRemoteDrive: () => Promise.resolve(), // remotes ride options.remoteDrives\n };\n}\n\nasync function start(\n host: HostDefinition,\n ctx: RunnerContext,\n devMode: boolean,\n): Promise<SwitchboardHandle> {\n const options = applyReactorEnvProjection(\n host.reactor as ReactorConfig | undefined,\n `hosts/${host.name}/host.js`,\n );\n const { startSwitchboard } = await import(\"../services/switchboard.js\");\n const entriesDeclared =\n (host.runner as { plugins?: unknown }).plugins !== undefined;\n const args = toSwitchboardArgs(\n host,\n devMode,\n options.dbPath,\n entriesDeclared,\n );\n\n // R2 step 2: a declared composition activates the plugin pipeline — the\n // runner resolves the entries against the PROJECT dependency tree and the\n // flag drives server-side activation. No plugins key = classic path.\n const entries = (host.runner as { plugins?: unknown }).plugins as\n | Parameters<typeof resolveHostPlugins>[3]\n | undefined;\n let pluginComposition;\n if (entries !== undefined) {\n process.env.FEATURE_PLUGIN_HOST_ENABLED = \"1\";\n pluginComposition = await resolveHostPlugins(\n ctx.projectRoot,\n \"switchboard\",\n ctx.verb ?? (devMode ? \"dev\" : \"run\"),\n entries,\n `hosts/${host.name}/host.js`,\n );\n }\n\n // Core drive declarations (reactor.drives): locals seed after boot via the\n // host-core seeder; remotes ride the existing remoteDrives option; the\n // implicit default powerhouse drive is replaced by the declared set.\n const declarations = (\n host.reactor as { drives?: DriveDeclaration[] } | undefined\n )?.drives;\n const resolvedDrives = (declarations ?? []).map((declaration) =>\n resolveDriveDeclaration(ctx.projectRoot, declaration),\n );\n const serverArgs = {\n ...args,\n ...(pluginComposition ? { pluginComposition } : {}),\n ...(resolvedDrives.length > 0\n ? {\n drive: undefined,\n remoteDrives: resolvedDrives\n .filter((d) => d.kind === \"remote\")\n .map((d) => d.remoteUrl!),\n }\n : {}),\n };\n\n const switchboard = await startSwitchboard(serverArgs as typeof args);\n const port = args.port;\n\n const localDrives = resolvedDrives.filter((d) => d.kind === \"local\");\n if (localDrives.length > 0 && switchboard) {\n await seedDrives(seederClient(switchboard.reactor, port), localDrives);\n }\n\n const slug =\n localDrives.length > 0\n ? localDrives[0].slug\n : typeof host.runner.driveSlug === \"string\"\n ? host.runner.driveSlug\n : DEFAULT_DRIVE_SLUG;\n const driveUrl = `http://localhost:${port}/d/${slug}`;\n const driveUrls =\n localDrives.length > 0\n ? localDrives.map((d) => `http://localhost:${port}/d/${d.slug}`)\n : [driveUrl];\n\n // Workflows on → seed the SAME project-hashed workflows drive the vetra\n // path seeds (opens in Workflow Studio); it rides the handle so a\n // supervising compound projects it into the connect member's drives.\n if (switchboard?.workflowsEnabled) {\n const { seedWorkflowsDrive } = await import(\"../services/vetra.js\");\n driveUrls.push(await seedWorkflowsDrive(switchboard.reactor, port));\n }\n\n const ready = waitForDrive(driveUrl, 180_000);\n // A supervisor awaits `ready` and sees the rejection; an unsupervised caller\n // (or a test with the service mocked) must not die of an unhandled one.\n ready.catch(() => undefined);\n return {\n port,\n driveUrls,\n endpoints: { graphql: `http://localhost:${port}/graphql` },\n ready,\n };\n}\n\n// The four verbs are orthogonal: each does ONE job.\n// - `run`/`serve`: START the server in production mode (serves the built\n// project package). `serve` is run's alias — a server IS its served stack,\n// and it lets the compound forward one `serve` verb to every member.\n// - `dev`: START the server in dev mode (watch / the Vite package loader).\n// - `build`: PRODUCE the project package this switchboard serves, and start\n// NOTHING. The analog of `ph connect build` on the server side: legacy\n// `ph switchboard build` never existed, but the project still has a build.\n// `build` is what lets a compound forward a single `build` verb to all members\n// (desktop/cli) without the switchboard member failing on an unknown verb.\n\nexport async function run(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<SwitchboardHandle> {\n return start(host, ctx, false);\n}\n\nexport const serve = run;\n\nexport async function dev(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<SwitchboardHandle> {\n return start(host, ctx, true);\n}\n\n/** Build the project's reactor package (the SAME service as `ph build`) — what\n * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */\nexport async function build(\n host: HostDefinition,\n _ctx: RunnerContext,\n): Promise<void> {\n const { runBuild } = await import(\"../services/build.js\");\n const runner = host.runner;\n const args: Partial<BuildArgs> = {\n outDir: typeof runner.outDir === \"string\" ? runner.outDir : \"dist\",\n };\n await runBuild(args as BuildArgs);\n}\n"],"names":["z.looseObject","z.string","z.number","z.boolean","z.array"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAa,OAAO;;AAGpB,MAAa,aAAaA,YAAc;CACtC,MAAMC,OAAS,CAAC,CAAC,IAAI,CAAC;CACtB,QAAQD,YAAc;EACpB,QAAQC,OAAS;EACjB,MAAMC,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;EAC3C,OAAOC,QAAU,CAAC,CAAC,SAAS;EAI5B,SAASC,MAAQ,iBAAiB,CAAC,CAAC,SAAS;CAC/C,CAAC;CACD,QAAQJ,YAAc,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS;CACT,SAAS,cAAc,SAAS;AAClC,CAAC;AAED,SAAS,kBACP,MACA,SACA,QACA,UACiB;CACjB,MAAM,SAAS,KAAK;CAapB,OAAO;EAXL,MACE,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO;EAClD,cAAc;EAGd,KAAK,WAAW,KAAA,IAAY;EAC5B,eAAe;EACf,cAAc,CAAC;EACf,KAAK,WAAW,OAAO,QAAQ;EAC/B,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;CAEnB;AACZ;;;AAIA,MAAM,qBAAqB;;;;;AAM3B,eAAe,aAAa,KAAa,WAAkC;CACzE,MAAM,WAAW,KAAK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EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,SAAS,KAAK;CAIpB,MAAM,SAAS,EAFb,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS,OAE5C,CAAc;AAClC","debug_id":"4c7bfb64-88a2-57bf-b4d9-3418e87fcd29"}
1
+ {"version":3,"file":"switchboard.mjs","sources":["../../src/services/classic-args.ts","../../src/runners/switchboard.ts"],"sourcesContent":["import { switchboardArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, runSafely } from \"cmd-ts\";\nimport type { SwitchboardArgs } from \"../types.js\";\n\n/**\n * The classic `ph switchboard` argument shape, produced by the SAME cmd-ts\n * definitions the classic command parses — not re-derived by hand. A runner\n * starts from this object and overlays only the keys its host file owns, so\n * every key the classic command carries (including the ones it carries as\n * `undefined`, e.g. `dbPath`) reaches the service exactly as it does on the\n * classic path. The uniform-runners switchboard runner once hand-built a\n * partial object that omitted `dbPath`; the service's then-default\n * `.ph/read-model.db` became both the reactor and the read-model PGlite dir —\n * two instances on one PGDATA (see uniform-runners-plan/legacy-parity-rectification.md).\n */\nconst classicSwitchboard = command({\n name: \"switchboard\",\n args: switchboardArgs,\n handler: (args) => args,\n});\n\nexport async function classicSwitchboardArgs(\n argv: string[] = [],\n): Promise<SwitchboardArgs> {\n const result = await runSafely(classicSwitchboard, argv);\n if (result._tag === \"error\") {\n throw new Error(\n `classic switchboard args did not parse: ${result.error.config.message}`,\n );\n }\n return result.value;\n}\n","import {\n profileSchema,\n reactorSchema,\n type HostDefinition,\n type ReactorConfig,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport {\n pluginEntrySchema,\n resolveDriveDeclaration,\n resolveHostPlugins,\n seedDrives,\n type DriveDeclaration,\n type DriveSeederClient,\n type ResolvedDrive,\n} from \"@powerhousedao/host-core\";\nimport { applyReactorEnvProjection } from \"./reactor-env.js\";\nimport { z } from \"zod\";\nimport { classicSwitchboardArgs } from \"../services/classic-args.js\";\nimport type { BuildArgs, SwitchboardArgs } from \"../types.js\";\n\n/**\n * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a\n * hosts/switchboard/host.js definition onto the SAME `startSwitchboard`\n * service the classic command calls. `run` = production loaders, `dev` =\n * Vite package loader (worker pools refused by the server, as always).\n * There is deliberately no `build` verb — the switchboard has none.\n */\n\nexport const kind = \"reactor\";\n\n/** Phase-2 schema (D2.d): `reactor`/`profile` strict via host-core. */\nexport const hostSchema = z.looseObject({\n name: z.string().min(1),\n runner: z.looseObject({\n module: z.string(),\n port: z.number().int().positive().optional(),\n https: z.boolean().optional(),\n // THE COMPOSITION (rewire R2): plugin entries, presence is activation.\n // (The classic packages-CSV meaning of this field is retired — packages\n // load via reactor.backends.*.packages / the package manager.)\n plugins: z.array(pluginEntrySchema).optional(),\n }),\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n reactor: reactorSchema.optional(),\n});\n\n/** The classic arg shape with the one switch a composition may leave unset. */\nexport type SwitchboardRunnerArgs = Omit<SwitchboardArgs, \"mcp\"> & {\n mcp: boolean | undefined;\n};\n\n/**\n * Start from the classic `ph switchboard` args (parsed by the classic\n * definitions, no flags) and overlay ONLY the keys the host file owns. Every\n * other key — including the ones the classic command carries as `undefined`,\n * such as `dbPath` — reaches the service exactly as on the classic path. No\n * cast: a key the classic shape has and this object lacks is a type error.\n */\nasync function toSwitchboardArgs(\n host: HostDefinition,\n devMode: boolean,\n dbPath: string | undefined,\n composed: boolean,\n): Promise<SwitchboardRunnerArgs> {\n const classic = await classicSwitchboardArgs();\n const runner = host.runner;\n return {\n ...classic,\n port: typeof runner.port === \"number\" ? runner.port : classic.port,\n // The verb owns dev mode; `runner.dev` is the host-file spelling of it.\n dev: devMode || runner.dev === true ? true : classic.dev,\n // A declared composition owns the carved switches (R2): the mcp plugin's\n // presence sets it, its absence must deactivate. Classic path: classic.\n mcp: composed ? undefined : classic.mcp,\n // The host file's readModel.url. Absent, the key stays present and\n // undefined exactly as the classic command carries it, so the server's\n // own split defaults (.ph/reactor-storage + .ph/read-storage) apply.\n // Omitting the key resurrected a dead service default and put the\n // reactor and the read model on ONE PGlite dir (two writers, one PGDATA).\n dbPath: dbPath ?? classic.dbPath,\n };\n}\n\n/** The slug of the drive the switchboard creates by default\n * (apps/switchboard config); `runner.driveSlug` overrides. */\nconst DEFAULT_DRIVE_SLUG = \"powerhouse\";\n\n/** Poll the default drive endpoint until the server answers — the compound's\n * readiness gate: Connect auto-connects the drive on first load, so the drive\n * must answer before the connect member serves (the sidecar's\n * waitForSwitchboard, moved behind the handle contract). */\nasync function waitForDrive(url: string, timeoutMs: number): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n try {\n const res = await fetch(url, { signal: AbortSignal.timeout(3000) });\n if (res.ok) return;\n } catch {\n // not listening yet\n }\n if (Date.now() > deadline) {\n throw new Error(\n `Switchboard drive ${url} did not answer within ${timeoutMs}ms.`,\n );\n }\n await new Promise((resolve) => setTimeout(resolve, 400));\n }\n}\n\n/** What a started switchboard reports to a supervising compound: its port and\n * the drive it serves (projected into a connect member's defaultDrives). */\nexport interface SwitchboardHandle {\n port: number;\n driveUrls: string[];\n endpoints: Record<string, string>;\n ready: Promise<void>;\n}\n\n/** Adapter from the switchboard's reactor client onto the host-core seeder.\n * addDefaultDrive is slug-idempotent itself, so findDriveBySlug delegates. */\nfunction seederClient(reactor: unknown, port: number): DriveSeederClient {\n return {\n findDriveBySlug: () => Promise.resolve(undefined),\n createDrive: async (drive: ResolvedDrive) => {\n const { addDefaultDrive } =\n await import(\"@powerhousedao/switchboard/utils\");\n await addDefaultDrive(\n reactor as Parameters<typeof addDefaultDrive>[0],\n {\n id: drive.id,\n slug: drive.slug,\n global: { name: drive.name, icon: drive.icon },\n ...(drive.preferredEditor\n ? { preferredEditor: drive.preferredEditor }\n : {}),\n local: {\n availableOffline: drive.availableOffline,\n listeners: [],\n sharingType: drive.sharingType,\n triggers: [],\n },\n } as Parameters<typeof addDefaultDrive>[1],\n port,\n );\n },\n attachRemoteDrive: () => Promise.resolve(), // remotes ride options.remoteDrives\n };\n}\n\nasync function start(\n host: HostDefinition,\n ctx: RunnerContext,\n devMode: boolean,\n): Promise<SwitchboardHandle> {\n const options = applyReactorEnvProjection(\n host.reactor as ReactorConfig | undefined,\n `hosts/${host.name}/host.js`,\n );\n const { startSwitchboard } = await import(\"../services/switchboard.js\");\n const entriesDeclared =\n (host.runner as { plugins?: unknown }).plugins !== undefined;\n const args = await toSwitchboardArgs(\n host,\n devMode,\n options.dbPath,\n entriesDeclared,\n );\n\n // R2 step 2: a declared composition activates the plugin pipeline — the\n // runner resolves the entries against the PROJECT dependency tree and the\n // flag drives server-side activation. No plugins key = classic path.\n const entries = (host.runner as { plugins?: unknown }).plugins as\n | Parameters<typeof resolveHostPlugins>[3]\n | undefined;\n let pluginComposition;\n if (entries !== undefined) {\n process.env.FEATURE_PLUGIN_HOST_ENABLED = \"1\";\n pluginComposition = await resolveHostPlugins(\n ctx.projectRoot,\n \"switchboard\",\n ctx.verb ?? (devMode ? \"dev\" : \"run\"),\n entries,\n `hosts/${host.name}/host.js`,\n );\n }\n\n // Core drive declarations (reactor.drives): locals seed after boot via the\n // host-core seeder; remotes ride the existing remoteDrives option; the\n // implicit default powerhouse drive is replaced by the declared set.\n const declarations = (\n host.reactor as { drives?: DriveDeclaration[] } | undefined\n )?.drives;\n const resolvedDrives = (declarations ?? []).map((declaration) =>\n resolveDriveDeclaration(ctx.projectRoot, declaration),\n );\n const serverArgs = {\n ...args,\n ...(pluginComposition ? { pluginComposition } : {}),\n ...(resolvedDrives.length > 0\n ? {\n drive: undefined,\n remoteDrives: resolvedDrives\n .filter((d) => d.kind === \"remote\")\n .map((d) => d.remoteUrl!),\n }\n : {}),\n };\n\n const switchboard = await startSwitchboard(serverArgs);\n const port = args.port;\n\n const localDrives = resolvedDrives.filter((d) => d.kind === \"local\");\n if (localDrives.length > 0 && switchboard) {\n await seedDrives(seederClient(switchboard.reactor, port), localDrives);\n }\n\n const slug =\n localDrives.length > 0\n ? localDrives[0].slug\n : typeof host.runner.driveSlug === \"string\"\n ? host.runner.driveSlug\n : DEFAULT_DRIVE_SLUG;\n const driveUrl = `http://localhost:${port}/d/${slug}`;\n const driveUrls =\n localDrives.length > 0\n ? localDrives.map((d) => `http://localhost:${port}/d/${d.slug}`)\n : [driveUrl];\n\n // Workflows on → seed the SAME project-hashed workflows drive the vetra\n // path seeds (opens in Workflow Studio); it rides the handle so a\n // supervising compound projects it into the connect member's drives.\n if (switchboard?.workflowsEnabled) {\n const { seedWorkflowsDrive } = await import(\"../services/vetra.js\");\n driveUrls.push(await seedWorkflowsDrive(switchboard.reactor, port));\n }\n\n const ready = waitForDrive(driveUrl, 180_000);\n // A supervisor awaits `ready` and sees the rejection; an unsupervised caller\n // (or a test with the service mocked) must not die of an unhandled one.\n ready.catch(() => undefined);\n return {\n port,\n driveUrls,\n endpoints: { graphql: `http://localhost:${port}/graphql` },\n ready,\n };\n}\n\n// The four verbs are orthogonal: each does ONE job.\n// - `run`/`serve`: START the server in production mode (serves the built\n// project package). `serve` is run's alias — a server IS its served stack,\n// and it lets the compound forward one `serve` verb to every member.\n// - `dev`: START the server in dev mode (watch / the Vite package loader).\n// - `build`: PRODUCE the project package this switchboard serves, and start\n// NOTHING. The analog of `ph connect build` on the server side: legacy\n// `ph switchboard build` never existed, but the project still has a build.\n// `build` is what lets a compound forward a single `build` verb to all members\n// (desktop/cli) without the switchboard member failing on an unknown verb.\n\nexport async function run(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<SwitchboardHandle> {\n return start(host, ctx, false);\n}\n\nexport const serve = run;\n\nexport async function dev(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<SwitchboardHandle> {\n return start(host, ctx, true);\n}\n\n/** Build the project's reactor package (the SAME service as `ph build`) — what\n * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */\nexport async function build(\n host: HostDefinition,\n _ctx: RunnerContext,\n): Promise<void> {\n const { runBuild } = await import(\"../services/build.js\");\n const runner = host.runner;\n const args: Partial<BuildArgs> = {\n outDir: typeof runner.outDir === \"string\" ? runner.outDir : \"dist\",\n };\n await runBuild(args as BuildArgs);\n}\n"],"names":["z.looseObject","z.string","z.number","z.boolean","z.array"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,qBAAqB,QAAQ;CACjC,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAED,eAAsB,uBACpB,OAAiB,CAAC,GACQ;CAC1B,MAAM,SAAS,MAAM,UAAU,oBAAoB,IAAI;CACvD,IAAI,OAAO,SAAS,SAClB,MAAM,IAAI,MACR,2CAA2C,OAAO,MAAM,OAAO,SACjE;CAEF,OAAO,OAAO;AAChB;;;;;;;;;;ACFA,MAAa,OAAO;;AAGpB,MAAa,aAAaA,YAAc;CACtC,MAAMC,SAAS,CAAC,CAAC,IAAI,CAAC;CACtB,QAAQD,YAAc;EACpB,QAAQC,SAAS;EACjB,MAAMC,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;EAC3C,OAAOC,UAAU,CAAC,CAAC,SAAS;EAI5B,SAASC,MAAQ,iBAAiB,CAAC,CAAC,SAAS;CAC/C,CAAC;CACD,QAAQJ,YAAc,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS;CACT,SAAS,cAAc,SAAS;AAClC,CAAC;;;;;;;;AAcD,eAAe,kBACb,MACA,SACA,QACA,UACgC;CAChC,MAAM,UAAU,MAAM,uBAAuB;CAC7C,MAAM,SAAS,KAAK;CACpB,OAAO;EACL,GAAG;EACH,MAAM,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO,QAAQ;EAE9D,KAAK,WAAW,OAAO,QAAQ,OAAO,OAAO,QAAQ;EAGrD,KAAK,WAAW,KAAA,IAAY,QAAQ;EAMpC,QAAQ,UAAU,QAAQ;CAC5B;AACF;;;AAIA,MAAM,qBAAqB;;;;;AAM3B,eAAe,aAAa,KAAa,WAAkC;CACzE,MAAM,WAAW,KAAK,IA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M,EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,SAAS,KAAK;CAIpB,MAAM,SAAS,EAFb,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS,OAE5C,CAAc;AAClC","debug_id":"ad7a5128-0c7d-5e23-800d-238273f138ce"}
@@ -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]="c4ec0847-06a9-5283-ad6e-6b1ebb2fa145")}catch(e){}}();
3
- import { h as validateHost, i as loadHost, p as resolveRunnerModule, r as getVerb } from "./host-schemas-CL_wFpY7-B_pY14Jy.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]="41508b94-7cca-5a19-a64c-dee707c28676")}catch(e){}}();
3
+ import { h as validateHost, i as loadHost, p as resolveRunnerModule, r as getVerb } from "./host-schemas-CtPNRr5v-BQyKKFbS.mjs";
4
4
  //#region src/services/run/start-run.ts
5
5
  /**
6
6
  * `ph run <host> [verb]`: load hosts/<host>/host.js, resolve its declared
@@ -32,5 +32,5 @@ async function startRun(args) {
32
32
  //#endregion
33
33
  export { startRun };
34
34
 
35
- //# sourceMappingURL=start-run-CASbiOWI.mjs.map
36
- //# debugId=c4ec0847-06a9-5283-ad6e-6b1ebb2fa145
35
+ //# sourceMappingURL=start-run-CmDxyMw0.mjs.map
36
+ //# debugId=41508b94-7cca-5a19-a64c-dee707c28676
@@ -1 +1 @@
1
- {"version":3,"file":"start-run-CASbiOWI.mjs","sources":["../src/services/run/start-run.ts"],"sourcesContent":["import { loadHost } from \"@powerhousedao/host-core\";\nimport {\n getVerb,\n resolveRunnerModule,\n validateHost,\n} from \"@powerhousedao/host-core\";\n\nexport interface StartRunArgs {\n host: string;\n verb?: string;\n projectRoot?: string;\n debug?: boolean;\n}\n\n/**\n * `ph run <host> [verb]`: load hosts/<host>/host.js, resolve its declared\n * runner from the project's dependency tree, validate, dispatch the verb\n * (default `run`). There is deliberately no type→runner registry — what a\n * host does is written in its own file.\n */\nexport async function startRun(args: StartRunArgs): Promise<unknown> {\n const projectRoot = args.projectRoot ?? process.cwd();\n const loaded = await loadHost(projectRoot, args.host);\n const { warnSupersededConfigKeys } = await import(\"./superseded-config.js\");\n warnSupersededConfigKeys(projectRoot);\n const specifier = loaded.host.runner.module;\n const runner = await resolveRunnerModule(projectRoot, specifier);\n validateHost(runner, specifier, loaded.host, loaded.file);\n const verb = args.verb ?? \"run\";\n const fn = getVerb(runner, specifier, verb);\n if (args.debug) {\n console.log({ host: loaded.host.name, runner: specifier, verb });\n }\n return fn(loaded.host, { projectRoot, verb, env: process.env });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAoBA,eAAsB,SAAS,MAAsC;CACnE,MAAM,cAAc,KAAK,eAAe,QAAQ,IAAI;CACpD,MAAM,SAAS,MAAM,SAAS,aAAa,KAAK,IAAI;CACpD,MAAM,EAAE,6BAA6B,MAAM,OAAO;CAClD,yBAAyB,WAAW;CACpC,MAAM,YAAY,OAAO,KAAK,OAAO;CACrC,MAAM,SAAS,MAAM,oBAAoB,aAAa,SAAS;CAC/D,aAAa,QAAQ,WAAW,OAAO,MAAM,OAAO,IAAI;CACxD,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,KAAK,QAAQ,QAAQ,WAAW,IAAI;CAC1C,IAAI,KAAK,OACP,QAAQ,IAAI;EAAE,MAAM,OAAO,KAAK;EAAM,QAAQ;EAAW;CAAK,CAAC;CAEjE,OAAO,GAAG,OAAO,MAAM;EAAE;EAAa;EAAM,KAAK,QAAQ;CAAI,CAAC;AAChE","debug_id":"c4ec0847-06a9-5283-ad6e-6b1ebb2fa145"}
1
+ {"version":3,"file":"start-run-CmDxyMw0.mjs","sources":["../src/services/run/start-run.ts"],"sourcesContent":["import { loadHost } from \"@powerhousedao/host-core\";\nimport {\n getVerb,\n resolveRunnerModule,\n validateHost,\n} from \"@powerhousedao/host-core\";\n\nexport interface StartRunArgs {\n host: string;\n verb?: string;\n projectRoot?: string;\n debug?: boolean;\n}\n\n/**\n * `ph run <host> [verb]`: load hosts/<host>/host.js, resolve its declared\n * runner from the project's dependency tree, validate, dispatch the verb\n * (default `run`). There is deliberately no type→runner registry — what a\n * host does is written in its own file.\n */\nexport async function startRun(args: StartRunArgs): Promise<unknown> {\n const projectRoot = args.projectRoot ?? process.cwd();\n const loaded = await loadHost(projectRoot, args.host);\n const { warnSupersededConfigKeys } = await import(\"./superseded-config.js\");\n warnSupersededConfigKeys(projectRoot);\n const specifier = loaded.host.runner.module;\n const runner = await resolveRunnerModule(projectRoot, specifier);\n validateHost(runner, specifier, loaded.host, loaded.file);\n const verb = args.verb ?? \"run\";\n const fn = getVerb(runner, specifier, verb);\n if (args.debug) {\n console.log({ host: loaded.host.name, runner: specifier, verb });\n }\n return fn(loaded.host, { projectRoot, verb, env: process.env });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAoBA,eAAsB,SAAS,MAAsC;CACnE,MAAM,cAAc,KAAK,eAAe,QAAQ,IAAI;CACpD,MAAM,SAAS,MAAM,SAAS,aAAa,KAAK,IAAI;CACpD,MAAM,EAAE,6BAA6B,MAAM,OAAO;CAClD,yBAAyB,WAAW;CACpC,MAAM,YAAY,OAAO,KAAK,OAAO;CACrC,MAAM,SAAS,MAAM,oBAAoB,aAAa,SAAS;CAC/D,aAAa,QAAQ,WAAW,OAAO,MAAM,OAAO,IAAI;CACxD,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,KAAK,QAAQ,QAAQ,WAAW,IAAI;CAC1C,IAAI,KAAK,OACP,QAAQ,IAAI;EAAE,MAAM,OAAO,KAAK;EAAM,QAAQ;EAAW;CAAK,CAAC;CAEjE,OAAO,GAAG,OAAO,MAAM;EAAE;EAAa;EAAM,KAAK,QAAQ;CAAI,CAAC;AAChE","debug_id":"41508b94-7cca-5a19-a64c-dee707c28676"}
@@ -0,0 +1,4 @@
1
+ import { r as startSwitchboard } from "./switchboard-h4-XgP1h.mjs";
2
+ export { startSwitchboard };
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]="bbd84a3f-e32a-5edc-b543-3e3bee0152b8")}catch(e){}}();
4
+ //# debugId=bbd84a3f-e32a-5edc-b543-3e3bee0152b8
@@ -1,6 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f2520f1a-0b2d-5086-beca-ab486259ddfe")}catch(e){}}();
3
- import path from "node:path";
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]="7891908b-56ad-54bc-85a7-79e514bd85c8")}catch(e){}}();
4
3
  import { DEFAULT_DRIVE_ICON } from "@powerhousedao/shared/clis";
5
4
  import { startSwitchboard } from "@powerhousedao/switchboard/server";
6
5
  //#region src/utils/drive-icons.ts
@@ -57,7 +56,6 @@ function allowLocalhostEgress(env = process.env) {
57
56
  }
58
57
  const defaultSwitchboardOptions = {
59
58
  port: 4001,
60
- dbPath: path.join(process.cwd(), ".ph/read-model.db"),
61
59
  drive: {
62
60
  id: "powerhouse",
63
61
  slug: "powerhouse",
@@ -77,7 +75,6 @@ const defaultSwitchboardOptions = {
77
75
  function getDefaultVetraSwitchboardOptions(vetraDriveId) {
78
76
  return {
79
77
  port: 4001,
80
- dbPath: path.join(process.cwd(), ".ph/read-model.db"),
81
78
  drive: {
82
79
  id: vetraDriveId,
83
80
  slug: vetraDriveId,
@@ -128,5 +125,5 @@ async function startSwitchboard$1(options, logger) {
128
125
  //#endregion
129
126
  export { POWERHOUSE_DRIVE_ICON as i, defaultSwitchboardOptions as n, startSwitchboard$1 as r, allowLocalhostEgress as t };
130
127
 
131
- //# sourceMappingURL=switchboard-tQS3fhqa.mjs.map
132
- //# debugId=f2520f1a-0b2d-5086-beca-ab486259ddfe
128
+ //# sourceMappingURL=switchboard-h4-XgP1h.mjs.map
129
+ //# debugId=7891908b-56ad-54bc-85a7-79e514bd85c8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard-h4-XgP1h.mjs","sources":["../src/utils/drive-icons.ts","../src/services/switchboard.ts"],"sourcesContent":["/**\n * Icon for the drives ph-cli creates, inlined as a data URI.\n *\n * This used to be an IPFS URL on a private gateway, which now answers 403 -\n * and a drive stores its icon as a plain URL in document state, so the moment\n * that URL rots every client renders a broken image, for as long as the drive\n * exists. A public gateway would only move the problem: IPFS gateways are\n * frequently overloaded, and a drive icon must not depend on the network at\n * all.\n *\n * A data URI keeps the asset inside this package and inside the drive: no\n * fetch, no gateway, no deploy-base or cross-origin question, and nothing to\n * 404. A few hundred bytes - the size of the string below is the entire cost,\n * paid once in the drive's state.\n *\n * Kept URL-encoded rather than base64 so the markup stays readable and\n * reviewable (`#` must be `%23`; `<`, `>`, `\"` and the CSS braces are legal\n * enough in a data URI but are encoded so the value is also safe to paste\n * into markup).\n */\n\n/** Encodes an SVG for use in a `data:` URI, smaller than base64 and readable. */\nfunction svgDataUri(svg: string): string {\n const compact = svg.replace(/\\s+/g, \" \").trim();\n return `data:image/svg+xml,${compact\n .replace(/%/g, \"%25\")\n .replace(/#/g, \"%23\")\n .replace(/</g, \"%3C\")\n .replace(/>/g, \"%3E\")\n .replace(/\"/g, \"%22\")\n .replace(/\\{/g, \"%7B\")\n .replace(/\\}/g, \"%7D\")}`;\n}\n\n// The Powerhouse mark: four petals on a 64 grid, each a square with one\n// quarter-circle bite taken out of its inner corner.\nconst PETALS = [\n \"M0 4.6C0 2.1 2.1 0 4.6 0h21.2c2.5 0 4.6 2.1 4.6 4.6v2.8c0 12.7-10.3 23-23 23H4.6C2.1 30.4 0 28.4 0 25.8V4.6Z\",\n \"M33.6 56.6c0-12.7 10.3-23 23-23h2.8c2.5 0 4.6 2.1 4.6 4.6v21.2c0 2.5-2.1 4.6-4.6 4.6H38.2c-2.5 0-4.6-2.1-4.6-4.6v-2.8Z\",\n \"M0 38.2c0-2.5 2.1-4.6 4.6-4.6h2.8c12.7 0 23 10.3 23 23v2.8c0 2.5-2.1 4.6-4.6 4.6H4.6C2.1 64 0 61.9 0 59.4V38.2Z\",\n \"M33.6 4.6C33.6 2.1 35.6 0 38.2 0h21.2C61.9 0 64 2.1 64 4.6v21.2c0 2.5-2.1 4.6-4.6 4.6h-2.8c-12.7 0-23-10.3-23-23V4.6Z\",\n];\n\n/** The mark in the light theme's grey. */\nconst LIGHT_FILL = \"#404345\";\n\n/** The mark in the dark theme's grey. */\nconst DARK_FILL = \"#F3F5F7\";\n\n// Drawn in one grey that follows the theme, so the icon sits in the sidebar\n// beside the single-tone `currentcolor` glyphs of the other drives instead of\n// competing with them.\n//\n// A data URI rendered through an `<img>` is its own document and cannot see\n// the host page's `.dark` class, so the theme is read from the embedded\n// document's own color scheme. That is the OS preference by default; the\n// renderer propagates an explicit in-app theme choice by setting\n// `color-scheme` on the `<img>`, which overrides it where the browser\n// supports the propagation.\nconst MARK_SVG = `\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" width=\"32\" height=\"32\">\n <style>\n path { fill: ${LIGHT_FILL} }\n @media (prefers-color-scheme: dark) { path { fill: ${DARK_FILL} } }\n </style>\n <path d=\"${PETALS[0]}\"/>\n <path d=\"${PETALS[1]}\"/>\n <path d=\"${PETALS[2]}\"/>\n <path d=\"${PETALS[3]}\"/>\n</svg>`;\n\n/** Icon for the drives ph-cli creates. */\nexport const POWERHOUSE_DRIVE_ICON = svgDataUri(MARK_SVG);\n","import type {\n IdentityOptions,\n StartServerOptions,\n} from \"@powerhousedao/switchboard/server\";\nimport { DEFAULT_DRIVE_ICON } from \"@powerhousedao/shared/clis\";\nimport { startSwitchboard as startSwitchboardServer } from \"@powerhousedao/switchboard/server\";\nimport type { ILogger } from \"document-model\";\nimport type { SwitchboardArgs } from \"../types.js\";\nimport { POWERHOUSE_DRIVE_ICON } from \"../utils/drive-icons.js\";\n\nconst EGRESS_ALLOW_ENV = \"PH_WORKFLOWS_EGRESS_ALLOW_ADDRESSES\";\nconst LOCALHOST_ADDRESSES = [\"127.0.0.1/32\", \"::1/128\"];\n\n// Lets pieces reach services on this machine, keeping any addresses already set\nexport function allowLocalhostEgress(env: NodeJS.ProcessEnv = process.env) {\n const current = (env[EGRESS_ALLOW_ENV] ?? \"\")\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry !== \"\");\n const missing = LOCALHOST_ADDRESSES.filter(\n (address) => !current.includes(address),\n );\n if (missing.length > 0)\n env[EGRESS_ALLOW_ENV] = [...current, ...missing].join(\",\");\n}\n\n// No `dbPath` default here: the classic commands always carry the parsed\n// `dbPath` key (undefined without --db-path) and so always overrode it — the\n// server's own split defaults (`.ph/reactor-storage` for the reactor,\n// `.ph/read-storage` for the read model) are the legacy layout. A default\n// here resurfaces for any caller that omits the key and then names ONE dir\n// for both PGlite stores (two writers on one PGDATA).\nexport const defaultSwitchboardOptions = {\n port: 4001,\n drive: {\n id: \"powerhouse\",\n slug: \"powerhouse\",\n global: {\n name: \"Powerhouse\",\n icon: DEFAULT_DRIVE_ICON,\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n mcp: true,\n} satisfies StartServerOptions;\n\nfunction getDefaultVetraSwitchboardOptions(\n vetraDriveId: string,\n): Partial<StartServerOptions> {\n return {\n port: 4001,\n drive: {\n id: vetraDriveId,\n slug: vetraDriveId,\n global: {\n name: \"Vetra\",\n icon: POWERHOUSE_DRIVE_ICON,\n },\n preferredEditor: \"vetra-drive-app\",\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n };\n}\n\nexport async function startSwitchboard(\n options: Omit<SwitchboardArgs, \"mcp\"> & {\n /** A declared composition (R2) leaves this unset: the mcp plugin's presence sets it. */\n mcp?: boolean;\n /** `undefined` suppresses the default drive (declared drives replace it). */\n drive?: StartServerOptions[\"drive\"];\n strictPort?: boolean;\n processorConfig?: Map<string, unknown>;\n },\n logger?: ILogger,\n) {\n const {\n packages: packagesString,\n remoteDrives,\n useVetraDrive,\n vetraDriveId,\n useIdentity,\n keypairPath,\n requireIdentity,\n ...serverOptions\n } = options;\n\n // Vetra and dev mode run against local services\n if (useVetraDrive || serverOptions.dev) allowLocalhostEgress();\n\n // Choose the appropriate default configuration\n const defaultOptions = useVetraDrive\n ? getDefaultVetraSwitchboardOptions(vetraDriveId)\n : defaultSwitchboardOptions;\n\n // Build identity options if enabled\n const identity: IdentityOptions | undefined =\n useIdentity || keypairPath || requireIdentity\n ? {\n keypairPath,\n requireExisting: requireIdentity,\n }\n : undefined;\n\n const packages = packagesString?.split(\",\");\n\n // Only include the default drive if no remote drives are provided\n const finalOptions =\n remoteDrives.length > 0\n ? {\n ...defaultOptions,\n drive: undefined, // Don't create default drive when syncing with remote\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n }\n : {\n ...defaultOptions,\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n };\n\n const reactor = await startSwitchboardServer({\n ...finalOptions,\n fatalErrorShutdown: true,\n });\n\n return reactor;\n}\n"],"names":["startSwitchboard","startSwitchboardServer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,WAAW,KAAqB;CAEvC,OAAO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Z,aAAa;IACb,UAAU,CAAC;GACb;EACF;CACF;AACF;AAEA,eAAsBA,mBACpB,SAQA,QACA;CACA,MAAM,EACJ,UAAU,gBACV,cACA,eACA,cACA,aACA,aACA,iBACA,GAAG,kBACD;CAGJ,IAAI,iBAAiB,cAAc,KAAK,qBAAqB;CAG7D,MAAM,iBAAiB,gBACnB,kCAAkC,YAAY,IAC9C;CAGJ,MAAM,WACJ,eAAe,eAAe,kBAC1B;EACE;EACA,iBAAiB;CACnB,IACA,KAAA;CAEN,MAAM,WAAW,gBAAgB,MAAM,GAAG;CAG1C,MAAM,eACJ,aAAa,SAAS,IAClB;EACE,GAAG;EACH,OAAO,KAAA;EACP,GAAG;EACH;EACA;EACA;EACA;CACF,IACA;EACE,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;CACF;CAON,OAAO,MALeC,iBAAuB;EAC3C,GAAG;EACH,oBAAoB;CACtB,CAAC;AAGH","debug_id":"7891908b-56ad-54bc-85a7-79e514bd85c8"}
@@ -1,7 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7ed66b10-4157-58df-9f3d-8a23c6950440")}catch(e){}}();
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]="44d0c080-10cc-5316-947d-b0281777aade")}catch(e){}}();
3
3
  import { promises } from "node:fs";
4
4
  import { cyan, green, red, yellow } from "colorette";
5
+ import { defaultStoreDirs } from "@powerhousedao/shared/clis/ph-dir";
5
6
  //#region src/services/switchboard-reset.ts
6
7
  const CONFIRMATION_TOKEN = "reset";
7
8
  function isPostgresUrl(url) {
@@ -18,10 +19,11 @@ function isInteractive() {
18
19
  * caller can refuse.
19
20
  */
20
21
  function resolveResetPaths(options, env = process.env) {
22
+ const defaults = defaultStoreDirs(env);
21
23
  const readModelDbPath = options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;
22
- const readModelPath = readModelDbPath || ".ph/read-storage";
24
+ const readModelPath = readModelDbPath || defaults.readModel;
23
25
  const reactorDbUrl = options.dbPath ?? env.PH_REACTOR_DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;
24
- const reactorPath = reactorDbUrl || "./.ph/reactor-storage";
26
+ const reactorPath = reactorDbUrl || defaults.reactor;
25
27
  const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);
26
28
  const readModelIsPostgres = !!readModelDbPath && isPostgresUrl(readModelDbPath);
27
29
  let postgresUrl = null;
@@ -83,5 +85,5 @@ async function resetSwitchboardDatabase(options) {
83
85
  //#endregion
84
86
  export { resetSwitchboardDatabase };
85
87
 
86
- //# sourceMappingURL=switchboard-reset-CX_Lzw3O.mjs.map
87
- //# debugId=7ed66b10-4157-58df-9f3d-8a23c6950440
88
+ //# sourceMappingURL=switchboard-reset-MtTB_GAI.mjs.map
89
+ //# debugId=44d0c080-10cc-5316-947d-b0281777aade
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard-reset-MtTB_GAI.mjs","sources":["../src/services/switchboard-reset.ts"],"sourcesContent":["import { defaultStoreDirs } from \"@powerhousedao/shared/clis/ph-dir\";\nimport { yellow, red, green, cyan } from \"colorette\";\nimport { promises as fs } from \"node:fs\";\n\nexport interface ResetSwitchboardOptions {\n dbPath?: string;\n yes?: boolean;\n}\n\nexport interface ResolvedResetPaths {\n reactorDir: string | null;\n readModelDir: string | null;\n postgresUrl: string | null;\n}\n\nconst CONFIRMATION_TOKEN = \"reset\";\n\nexport function isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\n/**\n * Resolves the on-disk PGlite directories that `--reset` would delete.\n * Mirrors the resolution in apps/switchboard/src/server.mts so we touch the\n * same paths the running switchboard uses. When a Postgres URL is configured\n * the corresponding directory is null and `postgresUrl` is populated so the\n * caller can refuse.\n */\nexport function resolveResetPaths(\n options: ResetSwitchboardOptions,\n env: NodeJS.ProcessEnv = process.env,\n): ResolvedResetPaths {\n const defaults = defaultStoreDirs(env);\n const readModelDbPath =\n options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;\n const readModelPath = readModelDbPath || defaults.readModel;\n const reactorDbUrl =\n options.dbPath ??\n env.PH_REACTOR_DATABASE_URL ??\n env.PH_SWITCHBOARD_DATABASE_URL;\n const reactorPath = reactorDbUrl || defaults.reactor;\n\n const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);\n const readModelIsPostgres =\n !!readModelDbPath && isPostgresUrl(readModelDbPath);\n\n let postgresUrl: string | null = null;\n if (reactorIsPostgres) postgresUrl = reactorDbUrl as string;\n else if (readModelIsPostgres) postgresUrl = readModelDbPath as string;\n\n return {\n reactorDir: reactorIsPostgres ? null : reactorPath,\n readModelDir: readModelIsPostgres ? null : readModelPath,\n postgresUrl,\n };\n}\n\nasync function promptForConfirmation(): Promise<boolean> {\n const enquirer = await import(\"enquirer\");\n try {\n const answer = await enquirer.default.prompt<{ confirmation: string }>({\n type: \"input\",\n name: \"confirmation\",\n message: `Type \"${CONFIRMATION_TOKEN}\" to confirm wiping the local switchboard databases:`,\n });\n return answer.confirmation.trim() === CONFIRMATION_TOKEN;\n } catch {\n return false;\n }\n}\n\nexport async function resetSwitchboardDatabase(\n options: ResetSwitchboardOptions,\n): Promise<void> {\n const paths = resolveResetPaths(options);\n\n if (paths.postgresUrl) {\n console.error(\n red(\n `Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`,\n ),\n );\n console.error(\n yellow(\n \"`ph switchboard --reset` only wipes the local PGlite stores. \" +\n \"To reset a Postgres-backed switchboard, drop/recreate the database manually.\",\n ),\n );\n process.exit(1);\n }\n\n const targets = [paths.reactorDir, paths.readModelDir].filter(\n (d): d is string => d !== null,\n );\n\n if (targets.length === 0) {\n console.error(red(\"No local PGlite directories resolved; nothing to do.\"));\n process.exit(1);\n }\n\n console.log(yellow(\"The following directories will be permanently deleted:\"));\n for (const dir of targets) {\n console.log(` - ${dir}`);\n }\n console.log(\n yellow(\n \"This will wipe all local switchboard state. Migrations will re-run on next `ph switchboard`.\",\n ),\n );\n\n let confirmed = false;\n if (options.yes) {\n confirmed = true;\n } else if (isInteractive()) {\n confirmed = await promptForConfirmation();\n } else {\n console.error(\n red(\n \"Refusing to reset in a non-interactive context without --yes. Re-run with --yes to confirm.\",\n ),\n );\n process.exit(1);\n }\n\n if (!confirmed) {\n console.error(red(\"Aborted: confirmation not provided.\"));\n process.exit(1);\n }\n\n for (const dir of targets) {\n await fs.rm(dir, { recursive: true, force: true });\n console.log(cyan(`Removed ${dir}`));\n }\n\n console.log(\n green(\n \"Switchboard local storage reset. Run `ph switchboard` to re-initialize.\",\n ),\n );\n}\n"],"names":["fs"],"mappings":";;;;;;AAeA,MAAM,qBAAqB;AAE3B,SAAgB,cAAc,KAAsB;CAClD,OAAO,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,aAAa;AACxE;AAEA,SAAS,gBAAyB;CAChC,OAAO,QAAQ,QAAQ,MAAM,KAAK,KAAK,CAAC,QAAQ,IAAI;AACtD;;;;;;;;AASA,SAAgB,kBACd,SACA,MAAyB,QAAQ,KACb;CACpB,MAAM,WAAW,iBAAiB,GAAG;CACrC,MAAM,kBACJ,QAAQ,UAAU,IAAI,gBAAgB,IAAI;CAC5C,MAAM,gBAAgB,mBAAmB,SAAS;CAClD,MAAM,eACJ,QAAQ,UACR,IAAI,2BACJ,IAAI;CACN,MAAM,cAAc,gBAAgB,SAAS;CAE7C,MAAM,oBAAoB,CAAC,C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