@powerhousedao/ph-cli 6.2.3-dev.8 → 6.2.3-dev.81

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 (162) hide show
  1. package/dist/{auth-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
  2. package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
  3. package/dist/auth-CNhbN5UM.mjs +4 -0
  4. package/dist/build-t5pFQx0f.mjs +304 -0
  5. package/dist/build-t5pFQx0f.mjs.map +1 -0
  6. package/dist/build-wvc_NiGr.mjs +4 -0
  7. package/dist/check-ecwBLzrg.mjs +56 -0
  8. package/dist/check-ecwBLzrg.mjs.map +1 -0
  9. package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-DW7OYAGx.mjs} +39 -27
  10. package/dist/cli-connect-override-DW7OYAGx.mjs.map +1 -0
  11. package/dist/cli.d.mts +2 -1
  12. package/dist/cli.mjs +35 -1179
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs +2813 -0
  15. package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs.map +1 -0
  16. package/dist/connect-build-7nmQw9c5.mjs +253 -0
  17. package/dist/connect-build-7nmQw9c5.mjs.map +1 -0
  18. package/dist/{connect-config-BWGiW3IB.mjs → connect-config-CfQwxG8G.mjs} +19 -12
  19. package/dist/connect-config-CfQwxG8G.mjs.map +1 -0
  20. package/dist/connect-plugin-configs-CXN8_KL0.mjs +50 -0
  21. package/dist/connect-plugin-configs-CXN8_KL0.mjs.map +1 -0
  22. package/dist/connect-preview-Ckoqw_XU.mjs +231 -0
  23. package/dist/connect-preview-Ckoqw_XU.mjs.map +1 -0
  24. package/dist/connect-studio-Cac3eE_U.mjs +81 -0
  25. package/dist/connect-studio-Cac3eE_U.mjs.map +1 -0
  26. package/dist/connect-studio-Cf6UZvOo.mjs +4 -0
  27. package/dist/dist-DcARVrSg.mjs +643 -0
  28. package/dist/dist-DcARVrSg.mjs.map +1 -0
  29. package/dist/explain-Rx7JW1OU.mjs +230 -0
  30. package/dist/explain-Rx7JW1OU.mjs.map +1 -0
  31. package/dist/export-ZnJeAtLS.mjs +42 -0
  32. package/dist/export-ZnJeAtLS.mjs.map +1 -0
  33. package/dist/feature-flags-xwqcHEWC.mjs +4 -0
  34. package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-5Om0CB4N.mjs} +9 -3
  35. package/dist/generate-all-5Om0CB4N.mjs.map +1 -0
  36. package/dist/generate-app-hm6CJ_4O.mjs +72 -0
  37. package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
  38. package/dist/generate-desktop-shell-DzEzNspp.mjs +318 -0
  39. package/dist/generate-desktop-shell-DzEzNspp.mjs.map +1 -0
  40. package/dist/generate-document-model-CiW13Vf7.mjs +60 -0
  41. package/dist/generate-document-model-CiW13Vf7.mjs.map +1 -0
  42. package/dist/generate-editor-kTiUOmDW.mjs +64 -0
  43. package/dist/generate-editor-kTiUOmDW.mjs.map +1 -0
  44. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  45. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  46. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  47. package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
  48. package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
  49. package/dist/generate-piece-C6ymlErL.mjs +73 -0
  50. package/dist/generate-piece-C6ymlErL.mjs.map +1 -0
  51. package/dist/generate-piece-action-DqR8BcoO.mjs +31 -0
  52. package/dist/generate-piece-action-DqR8BcoO.mjs.map +1 -0
  53. package/dist/generate-piece-trigger-CZaDD-cc.mjs +30 -0
  54. package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
  55. package/dist/generate-processor-BVjOsfjJ.mjs +58 -0
  56. package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
  57. package/dist/generate-subgraph-CrHbYK91.mjs +64 -0
  58. package/dist/generate-subgraph-CrHbYK91.mjs.map +1 -0
  59. package/dist/get-version-CJulKHJ0.mjs +11 -0
  60. package/dist/get-version-CJulKHJ0.mjs.map +1 -0
  61. package/dist/index-CJN_BRkc.d.mts +4459 -0
  62. package/dist/index-CJN_BRkc.d.mts.map +1 -0
  63. package/dist/{init-BZP6gvYd.mjs → init-Ch1rCksS.mjs} +16 -12
  64. package/dist/init-Ch1rCksS.mjs.map +1 -0
  65. package/dist/{inspect-DXjbQEV_.mjs → inspect-zWJnBDMJ.mjs} +11 -4
  66. package/dist/inspect-zWJnBDMJ.mjs.map +1 -0
  67. package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
  68. package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
  69. package/dist/mcp-Cz9CubZa.mjs +262 -0
  70. package/dist/mcp-Cz9CubZa.mjs.map +1 -0
  71. package/dist/member-config-0tHtiVN_.mjs +154 -0
  72. package/dist/member-config-0tHtiVN_.mjs.map +1 -0
  73. package/dist/migrate-CIJaE3iZ.mjs +177 -0
  74. package/dist/migrate-CIJaE3iZ.mjs.map +1 -0
  75. package/dist/module-dir-1avCXsBi.mjs +17 -0
  76. package/dist/module-dir-1avCXsBi.mjs.map +1 -0
  77. package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
  78. package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
  79. package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
  80. package/dist/ph-cli-commands-C4gwBRyw.mjs +4 -0
  81. package/dist/ph-cli-commands-DFmTGL-H.mjs +1610 -0
  82. package/dist/ph-cli-commands-DFmTGL-H.mjs.map +1 -0
  83. package/dist/precompress-P6cJDPVC.mjs +77 -0
  84. package/dist/precompress-P6cJDPVC.mjs.map +1 -0
  85. package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
  86. package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
  87. package/dist/run-sugar-CRzZsmVo.mjs +39 -0
  88. package/dist/run-sugar-CRzZsmVo.mjs.map +1 -0
  89. package/dist/runners/connect.d.mts +1153 -0
  90. package/dist/runners/connect.d.mts.map +1 -0
  91. package/dist/runners/connect.mjs +300 -0
  92. package/dist/runners/connect.mjs.map +1 -0
  93. package/dist/runners/switchboard.d.mts +1481 -0
  94. package/dist/runners/switchboard.d.mts.map +1 -0
  95. package/dist/runners/switchboard.mjs +550 -0
  96. package/dist/runners/switchboard.mjs.map +1 -0
  97. package/dist/schemas-ByfuhvAb.mjs +5752 -0
  98. package/dist/schemas-ByfuhvAb.mjs.map +1 -0
  99. package/dist/scripts/emit-runner-schemas.ts +24 -0
  100. package/dist/scripts/generate-commands-docs.ts +12 -0
  101. package/dist/scripts/manage-environment +0 -0
  102. package/dist/scripts/setup.sh +0 -0
  103. package/dist/start-run-CRVBqQ8L.mjs +124 -0
  104. package/dist/start-run-CRVBqQ8L.mjs.map +1 -0
  105. package/dist/superseded-config-CbSTFun2.mjs +53 -0
  106. package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
  107. package/dist/switchboard-B7mvNWcd.mjs +4 -0
  108. package/dist/switchboard-Cqs5IBNF.mjs +168 -0
  109. package/dist/switchboard-Cqs5IBNF.mjs.map +1 -0
  110. package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-Docb8Cjv.mjs} +6 -5
  111. package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-Docb8Cjv.mjs.map} +1 -1
  112. package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
  113. package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
  114. package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  115. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  116. package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
  117. package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
  118. package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
  119. package/dist/{utils-C4isxXSO.mjs → utils-9KyRM0mf.mjs} +6 -34
  120. package/dist/{utils-C4isxXSO.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  121. package/dist/utils-DAux4Ga7.mjs +4 -0
  122. package/dist/{vetra-DkF6EJMY.mjs → vetra-DZYtcHqV.mjs} +130 -147
  123. package/dist/vetra-DZYtcHqV.mjs.map +1 -0
  124. package/dist/vetra-launch-DQDZxGTV.mjs +343 -0
  125. package/dist/vetra-launch-DQDZxGTV.mjs.map +1 -0
  126. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  127. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  128. package/package.json +42 -18
  129. package/dist/auth-BNkN6kS9.mjs +0 -4
  130. package/dist/build-C-A5-ipO.mjs +0 -4
  131. package/dist/build-uQXq6_HU.mjs +0 -71
  132. package/dist/build-uQXq6_HU.mjs.map +0 -1
  133. package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
  134. package/dist/connect-build-WL4axo4z.mjs +0 -43
  135. package/dist/connect-build-WL4axo4z.mjs.map +0 -1
  136. package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
  137. package/dist/connect-preview-D7ypzFDc.mjs +0 -28
  138. package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
  139. package/dist/connect-studio-BIQzyq5B.mjs +0 -5
  140. package/dist/connect-studio-D6rfWCNB.mjs +0 -31
  141. package/dist/connect-studio-D6rfWCNB.mjs.map +0 -1
  142. package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
  143. package/dist/generate-app-DNNqA-H3.mjs +0 -48
  144. package/dist/generate-app-DNNqA-H3.mjs.map +0 -1
  145. package/dist/generate-document-model-BJXyODfm.mjs +0 -34
  146. package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
  147. package/dist/generate-editor-BejvaVVT.mjs +0 -48
  148. package/dist/generate-editor-BejvaVVT.mjs.map +0 -1
  149. package/dist/generate-processor-_WOx-mMe.mjs +0 -40
  150. package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
  151. package/dist/generate-subgraph-BsHUstpl.mjs +0 -38
  152. package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
  153. package/dist/init-BZP6gvYd.mjs.map +0 -1
  154. package/dist/inspect-DXjbQEV_.mjs.map +0 -1
  155. package/dist/migrate-jGKfE02L.mjs +0 -83
  156. package/dist/migrate-jGKfE02L.mjs.map +0 -1
  157. package/dist/switchboard-CJMoMzWx.mjs +0 -75
  158. package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
  159. package/dist/switchboard-iRFugh8I.mjs +0 -4
  160. package/dist/switchboard-reset-BcQXlcVf.mjs.map +0 -1
  161. package/dist/utils-BzwczAW-.mjs +0 -4
  162. package/dist/vetra-DkF6EJMY.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard.d.mts","names":[],"sources":["../../src/commands/switchboard.ts","../../src/types.ts","../../src/runners/switchboard.ts"],"mappings":";;;cAGa,aAAW,+CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6CtB,6CAAA,iDAAA,mDAAA;;;KCkBU,kBAAkB,uBAAuB;;;;;;;;;qBCxBxC;qBAoCA,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAqB;;YAGhC,kBAAkB,aAAe;;YAEjC,wBAAwB,cAAgB;;qBAGvC,8BAA4B;;;GAGvC;;;;;;;qBAQW,eAAa;;;;;;;;;;GAOxB;YACU,qBAAqB,gBAAe;QAExC;YACI;IACR;MACE,MAAM;MACN,SAAS;;;;;YAMH,wBAAwB,KAAK;EACvC;;;;;;;;;;;;;;wBAqGoB,aACpB,aACA,mBACA,eAAe,kBACf,mBAAkB,QACjB;;YAqBS,oBAAoB,aAAa;wBAqRvB,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;qBAIE,cAAK;wBAEI,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;;wBAKW,UACpB,MAAM,uBACN,KAAK,mBACJ,QAAQ;;;wBA+CW,MACpB,MAAM,uBACN,MAAM,gBACL"}
@@ -0,0 +1,550 @@
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]="1560181e-5198-54d9-bece-95dd5ba73fe2")}catch(e){}}();
3
+ import { c as number$1, d as string$1, g as prettifyError, i as boolean$1, l as record, m as url, u as strictObject } from "../schemas-ByfuhvAb.mjs";
4
+ import { g as drivesSchema, m as defineHostSchemas, q as resolveHostPlugins } from "../compound-C7GuPnTP-Ba4ce2Xa.mjs";
5
+ import { _ as seedDrives, d as protocolConflicts, g as resolveDriveDeclaration, s as mergeDrivePlan } from "../dist-DcARVrSg.mjs";
6
+ import { a as reactorBlockConflicts, c as switchboardDevMode, i as prepareMemberStorage, n as memberSwitchboardConfig, o as readModelAsReactorStore, r as memberSwitchboardConfigSchema, t as memberEnvOf } from "../member-config-0tHtiVN_.mjs";
7
+ import { command, runSafely } from "cmd-ts";
8
+ import { switchboardArgs } from "@powerhousedao/shared/clis/args";
9
+ import path from "node:path";
10
+ import { computeProgress } from "@powerhousedao/reactor";
11
+ //#region src/services/classic-args.ts
12
+ /**
13
+ * The classic `ph switchboard` argument shape, produced by the SAME cmd-ts
14
+ * definitions the classic command parses — not re-derived by hand. A runner
15
+ * starts from this object and overlays only the keys its host file owns, so
16
+ * every key the classic command carries (including the ones it carries as
17
+ * `undefined`, e.g. `dbPath`) reaches the service exactly as it does on the
18
+ * classic path. The uniform-runners switchboard runner once hand-built a
19
+ * partial object that omitted `dbPath`; the service's then-default
20
+ * `.ph/read-model.db` became both the reactor and the read-model PGlite dir —
21
+ * two instances on one PGDATA (see uniform-runners-plan/legacy-parity-rectification.md).
22
+ */
23
+ const classicSwitchboard = command({
24
+ name: "switchboard",
25
+ args: switchboardArgs,
26
+ handler: (args) => args
27
+ });
28
+ async function classicSwitchboardArgs(argv = []) {
29
+ const result = await runSafely(classicSwitchboard, argv);
30
+ if (result._tag === "error") throw new Error(`classic switchboard args did not parse: ${result.error.config.message}`);
31
+ return result.value;
32
+ }
33
+ //#endregion
34
+ //#region src/services/run/catch-up-progress.ts
35
+ function withDrives(label, driveCount) {
36
+ return `${label} (${driveCount} ${driveCount === 1 ? "drive" : "drives"})`;
37
+ }
38
+ /** One row per processor factory, then one per reactor read model. */
39
+ function progressRows(progress) {
40
+ const factories = progress.factories.map((factory) => ({
41
+ label: withDrives(factory.label, factory.driveCount),
42
+ fraction: factory.fraction,
43
+ state: factory.phase === "errored" ? "errored" : factory.phase === "catching-up" ? "catching-up" : "done"
44
+ }));
45
+ const readModels = progress.readModels.map((model) => ({
46
+ label: model.consumerId,
47
+ fraction: model.fraction,
48
+ state: model.blocked ? "errored" : model.complete ? "done" : "catching-up"
49
+ }));
50
+ return [...factories, ...readModels];
51
+ }
52
+ /** Rows from a reactor's inspector: its processors, catch-up status and priority. */
53
+ function inspectorProgressSource(inspector) {
54
+ return async () => {
55
+ const processors = await inspector.getProcessors();
56
+ let catchUp;
57
+ try {
58
+ catchUp = await inspector.getCatchUpStatus();
59
+ } catch {
60
+ catchUp = void 0;
61
+ }
62
+ let priority;
63
+ try {
64
+ const state = await inspector.getCatchUpPriority();
65
+ priority = {
66
+ mode: state.mode,
67
+ level: state.level,
68
+ reason: state.reason
69
+ };
70
+ } catch {
71
+ priority = void 0;
72
+ }
73
+ return {
74
+ rows: progressRows(computeProgress(processors, catchUp)),
75
+ priority
76
+ };
77
+ };
78
+ }
79
+ /** `catch-up priority 6 (dynamic, idle 14 s)`, or `catch-up priority 3 (fixed)`. */
80
+ function renderPriority(priority) {
81
+ const why = priority.mode === "dynamic" ? `dynamic, ${priority.reason}` : "fixed";
82
+ return `catch-up priority ${priority.level} (${why})`;
83
+ }
84
+ /** The console width the bars are sized for: a reported width, else 80. */
85
+ function widthOf(stream) {
86
+ const columns = stream.columns;
87
+ return typeof columns === "number" && columns > 0 ? columns : 80;
88
+ }
89
+ const DEFAULT_POLL_MS = 1e3;
90
+ const DEFAULT_LINE_MS = 1e4;
91
+ const MIN_BAR = 10;
92
+ const MAX_LABEL = 32;
93
+ function percent(row) {
94
+ if (row.state === "errored") return "errored";
95
+ if (row.state === "done") return "done";
96
+ return `${Math.floor(Math.min(Math.max(row.fraction, 0), 1) * 100)}%`;
97
+ }
98
+ function fit(label, width) {
99
+ return label.length <= width ? label.padEnd(width) : `…${label.slice(label.length - width + 1)}`;
100
+ }
101
+ /**
102
+ * The bar block, one line per row, under the priority when known. Every line
103
+ * stays short of the terminal's last column: a line that fills it wraps on
104
+ * xterm-based terminals (VS Code, Windows Terminal), and the erase would then
105
+ * lift fewer lines than are on screen, leaving old bars behind. On a narrow
106
+ * terminal the label gives way before the bar.
107
+ */
108
+ function renderBars(rows, columns, priority) {
109
+ const width = Math.max(columns - 1, 1);
110
+ const fixed = 9;
111
+ const longest = Math.max(...rows.map((row) => row.label.length), 0);
112
+ const labelWidth = Math.max(1, Math.min(MAX_LABEL, longest, width - fixed - MIN_BAR));
113
+ const barWidth = Math.max(MIN_BAR, width - labelWidth - fixed);
114
+ const bars = rows.map((row) => {
115
+ const fraction = row.state === "done" ? 1 : row.fraction;
116
+ const filled = Math.round(Math.min(Math.max(fraction, 0), 1) * barWidth);
117
+ const bar = "█".repeat(filled) + "░".repeat(barWidth - filled);
118
+ return `${fit(row.label, labelWidth)} ${bar} ${percent(row).padStart(7)}`.slice(0, width);
119
+ });
120
+ if (!priority) return bars;
121
+ return [renderPriority(priority).slice(0, width), ...bars];
122
+ }
123
+ /** One line for a log without a TTY, listing only what is still catching up. */
124
+ function renderLine(rows, priority) {
125
+ const line = `catch-up: ${rows.filter((row) => row.state !== "done").map((row) => `${row.label} ${percent(row)}`).join(" · ")}`;
126
+ return priority ? `${line} · priority ${priority.level} ${priority.mode}` : line;
127
+ }
128
+ function busy(rows) {
129
+ return rows.some((row) => row.state !== "done");
130
+ }
131
+ /**
132
+ * Shows catch-up progress while any row is not done. In a terminal the bars
133
+ * sit below the output and every other write is printed above them; without
134
+ * one, a progress line is printed every `lineMs`.
135
+ */
136
+ function startProgressDisplay(source, options) {
137
+ const { stdout, stderr } = options;
138
+ const tty = stdout.isTTY === true;
139
+ let rows = [];
140
+ let priority;
141
+ let drawn = 0;
142
+ let atLineStart = true;
143
+ let lastLine = 0;
144
+ let stopped = false;
145
+ let reading = false;
146
+ const restoreOut = stdout.write;
147
+ const restoreErr = stderr.write;
148
+ const originalOut = restoreOut.bind(stdout);
149
+ const originalErr = restoreErr.bind(stderr);
150
+ const erase = () => {
151
+ if (drawn > 0) originalOut(`\x1b[${drawn}A\r\x1b[0J`);
152
+ drawn = 0;
153
+ };
154
+ const draw = () => {
155
+ if (!tty || stopped || !atLineStart || !busy(rows)) return;
156
+ const lines = renderBars(rows, widthOf(stdout), priority);
157
+ originalOut(`${lines.join("\n")}\n`);
158
+ drawn = lines.length;
159
+ };
160
+ const above = (write) => (chunk, ...rest) => {
161
+ erase();
162
+ const result = write(chunk, ...rest);
163
+ const text = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString();
164
+ if (text.length > 0) atLineStart = text.endsWith("\n");
165
+ draw();
166
+ return result;
167
+ };
168
+ const onResize = () => {
169
+ if (stopped) return;
170
+ erase();
171
+ draw();
172
+ };
173
+ if (tty) {
174
+ stdout.write = above(originalOut);
175
+ stderr.write = above(originalErr);
176
+ stdout.on?.("resize", onResize);
177
+ }
178
+ const tick = async () => {
179
+ if (reading || stopped) return;
180
+ reading = true;
181
+ try {
182
+ ({rows, priority} = await source());
183
+ } catch {} finally {
184
+ reading = false;
185
+ }
186
+ if (stopped) return;
187
+ if (tty) {
188
+ erase();
189
+ draw();
190
+ return;
191
+ }
192
+ const now = Date.now();
193
+ if (busy(rows) && now - lastLine >= (options.lineMs ?? DEFAULT_LINE_MS)) {
194
+ originalOut(`${renderLine(rows, priority)}\n`);
195
+ lastLine = now;
196
+ }
197
+ };
198
+ const timer = setInterval(() => void tick(), options.pollMs ?? DEFAULT_POLL_MS);
199
+ timer.unref?.();
200
+ tick();
201
+ return { stop() {
202
+ if (stopped) return;
203
+ stopped = true;
204
+ clearInterval(timer);
205
+ erase();
206
+ if (tty) {
207
+ stdout.off?.("resize", onResize);
208
+ stdout.write = restoreOut;
209
+ stderr.write = restoreErr;
210
+ }
211
+ } };
212
+ }
213
+ //#endregion
214
+ //#region src/runners/switchboard.ts
215
+ /**
216
+ * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a
217
+ * hosts/switchboard/host.js definition onto the SAME `startSwitchboard`
218
+ * service the classic command calls. `run` = production loaders, `dev` =
219
+ * Vite package loader (worker pools refused by the server, as always).
220
+ */
221
+ const kind = "reactor";
222
+ /** The switchboard host: the host-core reactor host with every runner option
223
+ * this module reads declared (strict: an unknown runner key fails).
224
+ * `config.switchboard` is this member's own switchboard config (auth,
225
+ * inspection, workers, ...); a key the reactor block also sets is refused.
226
+ * One definition, two schemas: `declaredHostSchema` (token-able fields take
227
+ * output tokens; types host files) and `hostSchema` (resolved; checked
228
+ * right before the verb). */
229
+ const schemas = defineHostSchemas((s) => s.reactorHostSchema.extend({
230
+ runner: s.runnerBaseSchema.extend({
231
+ /** 0 binds a port the OS picks; `origin` reports it. */
232
+ port: number$1().int().min(0).max(65535).optional(),
233
+ /** Dev mode without the `dev` verb (the Vite package loader). */
234
+ dev: boolean$1().optional(),
235
+ /** The project package output dir `build` writes (default "dist"). */
236
+ outDir: string$1().min(1).optional()
237
+ }).strict(),
238
+ config: strictObject({ switchboard: memberSwitchboardConfigSchema.optional() }).optional()
239
+ }).superRefine((host, ctx) => {
240
+ for (const message of reactorBlockConflicts(host)) ctx.addIssue({
241
+ code: "custom",
242
+ path: ["config", "switchboard"],
243
+ message
244
+ });
245
+ }));
246
+ const declaredHostSchema = schemas.declaredHostSchema;
247
+ const hostSchema = schemas.hostSchema;
248
+ /** One drive the switchboard serves: its document id and its URL. */
249
+ const switchboardDriveOutputSchema = strictObject({
250
+ id: string$1().min(1),
251
+ url: url()
252
+ });
253
+ /** What a started switchboard produces. `origin` carries the port the server
254
+ * actually bound. `drives` is keyed by the DECLARED slug (a `projectHash:
255
+ * true` drive is reachable as `vetra`, its URL uses the hashed slug it is
256
+ * served under) and includes plugin-created drives (e.g. `workflows`) and
257
+ * the server's implicit default drive. `endpoints.mcp` is present when MCP
258
+ * is mounted. */
259
+ const outputsSchema = strictObject({
260
+ origin: url(),
261
+ endpoints: strictObject({
262
+ graphql: url(),
263
+ mcp: url().optional()
264
+ }),
265
+ drives: record(string$1(), switchboardDriveOutputSchema)
266
+ });
267
+ /**
268
+ * Start from the classic `ph switchboard` args (parsed by the classic
269
+ * definitions, no flags) and overlay ONLY the keys the host file owns. Every
270
+ * other key — including the ones the classic command carries as `undefined`,
271
+ * such as `dbPath` — reaches the service exactly as on the classic path. No
272
+ * cast: a key the classic shape has and this object lacks is a type error.
273
+ */
274
+ async function toSwitchboardArgs(host, devMode, composed) {
275
+ const classic = await classicSwitchboardArgs();
276
+ const runner = host.runner;
277
+ return {
278
+ ...classic,
279
+ port: runner.port ?? classic.port,
280
+ dev: switchboardDevMode(devMode, runner) ? true : classic.dev,
281
+ mcp: composed ? void 0 : classic.mcp
282
+ };
283
+ }
284
+ /** The drive the switchboard service creates by default
285
+ * (services/switchboard.ts `defaultSwitchboardOptions.drive`). */
286
+ const DEFAULT_DRIVE_SLUG = "powerhouse";
287
+ /** The `<slug>` of the server-reported `…/d/<slug>` default drive URL. */
288
+ function defaultDriveSlug(url) {
289
+ const match = url ? /\/d\/([^/?#]+)\/?$/.exec(url) : null;
290
+ return match ? decodeURIComponent(match[1]) : DEFAULT_DRIVE_SLUG;
291
+ }
292
+ /**
293
+ * The drives the composition's plugins contribute, resolved and in plan
294
+ * order, minus the slugs the host declares itself (mergeDrivePlan: the host
295
+ * file wins). A contribution that is not a valid drive declaration fails the
296
+ * boot naming the plugin.
297
+ */
298
+ function pluginDrives(projectRoot, hostDrives, composition, where) {
299
+ if (!composition) return [];
300
+ const contributed = composition.flatMap((resolved) => {
301
+ const drives = resolved.plugin.contributions?.drives ?? [];
302
+ if (drives.length === 0) return [];
303
+ const parsed = drivesSchema.safeParse(drives);
304
+ if (!parsed.success) throw new Error(`${where}: plugin "${resolved.plugin.name}" contributes an invalid drive declaration:\n${prettifyError(parsed.error)}`);
305
+ return parsed.data.map((declaration) => ({
306
+ declaration,
307
+ source: resolved.plugin.name
308
+ }));
309
+ });
310
+ if (contributed.length === 0) return [];
311
+ const declaredSlugs = new Map(contributed.map(({ declaration }) => [resolveDriveDeclaration(projectRoot, declaration).slug, declaration.slug]));
312
+ const hostSlugs = new Set(hostDrives.map((d) => d.drive.slug));
313
+ return mergeDrivePlan(projectRoot, [], contributed).map((entry) => entry.drive).filter((drive) => !hostSlugs.has(drive.slug)).map((drive) => ({
314
+ declaredSlug: declaredSlugs.get(drive.slug) ?? drive.slug,
315
+ drive
316
+ }));
317
+ }
318
+ /** Poll the default drive endpoint until the server answers — the compound's
319
+ * readiness gate: Connect auto-connects the drive on first load, so the drive
320
+ * must answer before the connect member serves (the sidecar's
321
+ * waitForSwitchboard, moved behind the handle contract).
322
+ *
323
+ * The probe is anonymous, and a host with authentication on hides a drive
324
+ * from a caller it refuses (`/d/:drive` answers 404 to anyone who may not
325
+ * read it, 401 under the authenticated-caller floor). Those answers prove
326
+ * the server is listening but not whether the drive exists, so `served`,
327
+ * the reactor's own view of the drive, decides then; without it an
328
+ * ADMIN_ONLY host never passes this gate and the compound tears down after
329
+ * the timeout. */
330
+ async function waitForDrive(url, timeoutMs, served, fetchImpl = fetch) {
331
+ const deadline = Date.now() + timeoutMs;
332
+ const HIDDEN = /* @__PURE__ */ new Set([
333
+ 401,
334
+ 403,
335
+ 404
336
+ ]);
337
+ for (;;) {
338
+ try {
339
+ const res = await fetchImpl(url, { signal: AbortSignal.timeout(3e3) });
340
+ if (res.ok) return;
341
+ if (HIDDEN.has(res.status) && served && await served()) return;
342
+ } catch {}
343
+ if (Date.now() > deadline) throw new Error(`Switchboard drive ${url} did not answer within ${timeoutMs}ms.`);
344
+ await new Promise((resolve) => setTimeout(resolve, 400));
345
+ }
346
+ }
347
+ /**
348
+ * Adapter from the switchboard's reactor client onto the host-core seeder.
349
+ * Seeding is SLUG-keyed: a live drive that already serves the slug — under
350
+ * whatever id (a store from a run that hashed the project path differently,
351
+ * or a hand-made drive) — is the drive, and nothing is created. addDefaultDrive
352
+ * alone only knows ids: with a different id it would try to create a second
353
+ * drive for the slug, and against a deleted document with that id the create
354
+ * fails on every boot.
355
+ */
356
+ function seederClient(reactor, port, seededIds) {
357
+ return {
358
+ findDriveBySlug: async (slug) => {
359
+ try {
360
+ const id = await reactor.resolveIdOrSlug(slug);
361
+ if (id) seededIds.set(slug, id);
362
+ return id || void 0;
363
+ } catch {
364
+ return;
365
+ }
366
+ },
367
+ createDrive: async (drive) => {
368
+ const { addDefaultDrive } = await import("@powerhousedao/switchboard/utils");
369
+ try {
370
+ await createDeclaredDrive(addDefaultDrive, reactor, drive, port);
371
+ } catch (error) {
372
+ console.error(`The drive "${drive.slug}" was not created: ${error instanceof Error ? error.message : String(error)}`);
373
+ return;
374
+ }
375
+ let id;
376
+ try {
377
+ id = await reactor.resolveIdOrSlug(drive.slug);
378
+ } catch {
379
+ id = void 0;
380
+ }
381
+ seededIds.set(drive.slug, id || drive.id);
382
+ },
383
+ attachRemoteDrive: () => Promise.resolve()
384
+ };
385
+ }
386
+ /** A declared local drive, through the switchboard's own default-drive path. */
387
+ async function createDeclaredDrive(addDefaultDrive, reactor, drive, port) {
388
+ await addDefaultDrive(reactor, {
389
+ id: drive.id,
390
+ slug: drive.slug,
391
+ global: {
392
+ name: drive.name,
393
+ icon: drive.icon
394
+ },
395
+ ...drive.preferredEditor ? { preferredEditor: drive.preferredEditor } : {},
396
+ local: {
397
+ availableOffline: drive.availableOffline,
398
+ listeners: [],
399
+ sharingType: drive.sharingType,
400
+ triggers: []
401
+ }
402
+ }, port);
403
+ }
404
+ async function start(host, ctx, devMode) {
405
+ const hostFile = `hosts/${host.name}/host.js`;
406
+ const env = memberEnvOf(ctx.env);
407
+ prepareMemberStorage(host.reactor, env.shell, hostFile);
408
+ const legacyStore = readModelAsReactorStore(host.reactor, env.shell, hostFile);
409
+ if (legacyStore) console.warn(legacyStore.warning);
410
+ const { startSwitchboard } = await import("../switchboard-B7mvNWcd.mjs");
411
+ const entries = host.runner.plugins;
412
+ const entriesDeclared = entries !== void 0;
413
+ const classic = await toSwitchboardArgs(host, devMode, entriesDeclared);
414
+ const { https } = classic;
415
+ const args = {
416
+ ...classic,
417
+ https: void 0
418
+ };
419
+ const memberConfig = await memberSwitchboardConfig(host, env, {
420
+ pluginHost: entriesDeclared,
421
+ defaults: https === void 0 ? {} : { server: { https } }
422
+ });
423
+ let pluginComposition;
424
+ if (entries !== void 0) pluginComposition = await resolveHostPlugins(ctx.projectRoot, "switchboard", ctx.verb, entries, `hosts/${host.name}/host.js`);
425
+ const hostDrives = (host.reactor?.drives ?? []).map((declaration) => ({
426
+ declaredSlug: declaration.slug,
427
+ drive: resolveDriveDeclaration(ctx.projectRoot, declaration)
428
+ }));
429
+ const contributedDrives = pluginDrives(ctx.projectRoot, hostDrives, pluginComposition, `hosts/${host.name}/host.js`);
430
+ const planned = [...hostDrives, ...contributedDrives];
431
+ const remoteDrives = planned.map((p) => p.drive).flatMap((d) => d.kind === "remote" && d.remoteUrl ? [d.remoteUrl] : []);
432
+ const switchboard = await startSwitchboard({
433
+ ...args,
434
+ ...pluginComposition ? { pluginComposition } : {},
435
+ ...hostDrives.length > 0 ? { drive: void 0 } : {},
436
+ ...remoteDrives.length > 0 ? { remoteDrives } : {},
437
+ ...ctx.parent ? { signalHandlers: false } : {}
438
+ }, void 0, memberConfig);
439
+ const progress = switchboard.inspector && process.env.PH_CATCH_UP_PROGRESS !== "false" ? startProgressDisplay(inspectorProgressSource(switchboard.inspector), {
440
+ stdout: process.stdout,
441
+ stderr: process.stderr
442
+ }) : void 0;
443
+ const port = switchboard.port;
444
+ const origin = `http://localhost:${port}`;
445
+ const driveUrlOf = (slug) => `${origin}/d/${slug}`;
446
+ const seededIds = /* @__PURE__ */ new Map();
447
+ const localPlanned = planned.filter((p) => p.drive.kind === "local");
448
+ if (localPlanned.length > 0) await seedDrives(seederClient(switchboard.reactor, port, seededIds), localPlanned.map((p) => p.drive));
449
+ const drives = {};
450
+ const localHostDrives = hostDrives.filter((d) => d.drive.kind === "local");
451
+ const defaultSlug = defaultDriveSlug(switchboard.defaultDriveUrl);
452
+ if (hostDrives.length === 0 && remoteDrives.length === 0) drives[defaultSlug] = {
453
+ id: defaultSlug,
454
+ url: driveUrlOf(defaultSlug)
455
+ };
456
+ for (const { declaredSlug, drive } of localPlanned) drives[declaredSlug] = {
457
+ id: seededIds.get(drive.slug) ?? drive.id,
458
+ url: driveUrlOf(drive.slug)
459
+ };
460
+ const slug = localHostDrives.length > 0 ? localHostDrives[0].drive.slug : defaultSlug;
461
+ const driveUrl = driveUrlOf(slug);
462
+ if (entries === void 0 && switchboard.workflowsEnabled) {
463
+ const { seedWorkflowsDrive } = await import("../vetra-DZYtcHqV.mjs");
464
+ const { generateProjectDriveId } = await import("../utils-DAux4Ga7.mjs");
465
+ const url = await seedWorkflowsDrive(switchboard.reactor, port);
466
+ if (url) drives.workflows = {
467
+ id: generateProjectDriveId("workflows"),
468
+ url
469
+ };
470
+ }
471
+ const served = async () => {
472
+ try {
473
+ const id = await switchboard.reactor.resolveIdOrSlug(slug);
474
+ return Boolean(id);
475
+ } catch {
476
+ return false;
477
+ }
478
+ };
479
+ const ready = waitForDrive(driveUrl, 18e4, served);
480
+ ready.catch(() => void 0);
481
+ const graphql = `${origin}/graphql`;
482
+ let stopping;
483
+ return {
484
+ outputs: outputsSchema.parse({
485
+ origin,
486
+ endpoints: {
487
+ graphql,
488
+ ...switchboard.mcpEnabled ? { mcp: `${origin}/mcp` } : {}
489
+ },
490
+ drives
491
+ }),
492
+ ready,
493
+ shutdown: () => {
494
+ progress?.stop();
495
+ return stopping ??= switchboard.shutdown();
496
+ }
497
+ };
498
+ }
499
+ async function run(host, ctx) {
500
+ return start(host, ctx, false);
501
+ }
502
+ const serve = run;
503
+ async function dev(host, ctx) {
504
+ return start(host, ctx, true);
505
+ }
506
+ /** What the server would refuse at boot for this host, `ctx.verb` and `ctx.env` (`ph host check`). */
507
+ async function checkBoot(host, ctx) {
508
+ const env = memberEnvOf(ctx.env, ctx.projectRoot);
509
+ const issues = protocolConflicts(host.reactor?.protocol, env.shell, ctx.file).map((message) => ({
510
+ path: "reactor.protocol",
511
+ message
512
+ }));
513
+ const legacyStore = readModelAsReactorStore(host.reactor, env.shell, ctx.file);
514
+ if (legacyStore) issues.push({
515
+ path: "reactor.backends",
516
+ message: legacyStore.warning
517
+ });
518
+ const { getConfig } = await import("@powerhousedao/config/node");
519
+ const { switchboardBootFactsOf, switchboardBootIssues } = await import("@powerhousedao/switchboard/boot");
520
+ let config;
521
+ try {
522
+ config = await memberSwitchboardConfig(host, env, { pluginHost: host.runner.plugins !== void 0 });
523
+ } catch (error) {
524
+ issues.push({
525
+ path: "",
526
+ message: error instanceof Error ? error.message : String(error)
527
+ });
528
+ return issues;
529
+ }
530
+ const facts = await switchboardBootFactsOf(config, {
531
+ dev: switchboardDevMode(ctx.verb === "dev", host.runner),
532
+ configuredRenown: getConfig(path.join(ctx.projectRoot, "powerhouse.config.json")).auth?.renown
533
+ });
534
+ for (const message of switchboardBootIssues(facts)) issues.push({
535
+ path: "",
536
+ message
537
+ });
538
+ return issues;
539
+ }
540
+ /** Build the project's reactor package (the SAME service as `ph build`) — what
541
+ * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
542
+ async function build(host, _ctx) {
543
+ const { runBuild } = await import("../build-wvc_NiGr.mjs");
544
+ await runBuild({ outDir: host.runner.outDir ?? "dist" });
545
+ }
546
+ //#endregion
547
+ export { build, checkBoot, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, switchboardDriveOutputSchema, waitForDrive };
548
+
549
+ //# sourceMappingURL=switchboard.mjs.map
550
+ //# debugId=1560181e-5198-54d9-bece-95dd5ba73fe2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard.mjs","sources":["../../src/services/classic-args.ts","../../src/services/run/catch-up-progress.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 computeProgress,\n type CatchUpPriorityState,\n type IInspector,\n type ReactorProgress,\n} from \"@powerhousedao/reactor\";\n\n/** One bar: a processor factory or a read model, and how far its catch-up has got. */\nexport type ProgressRow = {\n readonly label: string;\n /** 0..1 of the current run. */\n readonly fraction: number;\n readonly state: \"catching-up\" | \"done\" | \"errored\";\n};\n\n/** The catch-up priority as the progress display states it. */\nexport type ProgressPriority = {\n readonly mode: CatchUpPriorityState[\"mode\"];\n readonly level: number;\n readonly reason: string;\n};\n\n/** What one read of the source shows: the bars, and the priority when known. */\nexport type ProgressSnapshot = {\n readonly rows: readonly ProgressRow[];\n readonly priority: ProgressPriority | undefined;\n};\n\n/** Reads the current rows; rejects while the reactor cannot answer. */\nexport type ProgressSource = () => Promise<ProgressSnapshot>;\n\nfunction withDrives(label: string, driveCount: number): string {\n return `${label} (${driveCount} ${driveCount === 1 ? \"drive\" : \"drives\"})`;\n}\n\n/** One row per processor factory, then one per reactor read model. */\nexport function progressRows(progress: ReactorProgress): ProgressRow[] {\n const factories = progress.factories.map((factory): ProgressRow => ({\n label: withDrives(factory.label, factory.driveCount),\n fraction: factory.fraction,\n state:\n factory.phase === \"errored\"\n ? \"errored\"\n : factory.phase === \"catching-up\"\n ? \"catching-up\"\n : \"done\",\n }));\n const readModels = progress.readModels.map((model): ProgressRow => ({\n label: model.consumerId,\n fraction: model.fraction,\n state: model.blocked ? \"errored\" : model.complete ? \"done\" : \"catching-up\",\n }));\n return [...factories, ...readModels];\n}\n\n/** Rows from a reactor's inspector: its processors, catch-up status and priority. */\nexport function inspectorProgressSource(inspector: IInspector): ProgressSource {\n return async () => {\n const processors = await inspector.getProcessors();\n let catchUp:\n | Awaited<ReturnType<IInspector[\"getCatchUpStatus\"]>>\n | undefined;\n try {\n catchUp = await inspector.getCatchUpStatus();\n } catch {\n catchUp = undefined;\n }\n let priority: ProgressPriority | undefined;\n try {\n const state = await inspector.getCatchUpPriority();\n priority = { mode: state.mode, level: state.level, reason: state.reason };\n } catch {\n priority = undefined;\n }\n return {\n rows: progressRows(computeProgress(processors, catchUp)),\n priority,\n };\n };\n}\n\n/** `catch-up priority 6 (dynamic, idle 14 s)`, or `catch-up priority 3 (fixed)`. */\nexport function renderPriority(priority: ProgressPriority): string {\n const why =\n priority.mode === \"dynamic\" ? `dynamic, ${priority.reason}` : \"fixed\";\n return `catch-up priority ${priority.level} (${why})`;\n}\n\n/** The slice of a TTY stream the display writes to and intercepts. */\nexport type ProgressStream = {\n write: NodeJS.WriteStream[\"write\"];\n readonly isTTY?: boolean;\n readonly columns?: number;\n /** A TTY stream emits \"resize\" when the terminal's size changes. */\n on?(event: \"resize\", listener: () => void): unknown;\n off?(event: \"resize\", listener: () => void): unknown;\n};\n\n/** The console width the bars are sized for: a reported width, else 80. */\nfunction widthOf(stream: ProgressStream): number {\n const columns = stream.columns;\n return typeof columns === \"number\" && columns > 0 ? columns : 80;\n}\n\nexport type ProgressDisplayOptions = {\n readonly stdout: ProgressStream;\n readonly stderr: ProgressStream;\n /** How often the source is read. */\n readonly pollMs?: number;\n /** Without a TTY: how often a progress line is printed while catching up. */\n readonly lineMs?: number;\n};\n\nexport type ProgressDisplay = {\n /** Stops polling, removes the bars and restores the streams. */\n stop(): void;\n};\n\nconst DEFAULT_POLL_MS = 1_000;\nconst DEFAULT_LINE_MS = 10_000;\nconst MIN_BAR = 10;\nconst MAX_LABEL = 32;\n\nfunction percent(row: ProgressRow): string {\n if (row.state === \"errored\") return \"errored\";\n if (row.state === \"done\") return \"done\";\n return `${Math.floor(Math.min(Math.max(row.fraction, 0), 1) * 100)}%`;\n}\n\nfunction fit(label: string, width: number): string {\n return label.length <= width\n ? label.padEnd(width)\n : `…${label.slice(label.length - width + 1)}`;\n}\n\n/**\n * The bar block, one line per row, under the priority when known. Every line\n * stays short of the terminal's last column: a line that fills it wraps on\n * xterm-based terminals (VS Code, Windows Terminal), and the erase would then\n * lift fewer lines than are on screen, leaving old bars behind. On a narrow\n * terminal the label gives way before the bar.\n */\nexport function renderBars(\n rows: readonly ProgressRow[],\n columns: number,\n priority?: ProgressPriority,\n): string[] {\n const width = Math.max(columns - 1, 1);\n // label, space, bar, space, 7 for \"errored\" / \"100%\"\n const fixed = 9;\n const longest = Math.max(...rows.map((row) => row.label.length), 0);\n const labelWidth = Math.max(\n 1,\n Math.min(MAX_LABEL, longest, width - fixed - MIN_BAR),\n );\n const barWidth = Math.max(MIN_BAR, width - labelWidth - fixed);\n const bars = rows.map((row) => {\n const fraction = row.state === \"done\" ? 1 : row.fraction;\n const filled = Math.round(Math.min(Math.max(fraction, 0), 1) * barWidth);\n const bar = \"█\".repeat(filled) + \"░\".repeat(barWidth - filled);\n return `${fit(row.label, labelWidth)} ${bar} ${percent(row).padStart(7)}`.slice(\n 0,\n width,\n );\n });\n if (!priority) return bars;\n return [renderPriority(priority).slice(0, width), ...bars];\n}\n\n/** One line for a log without a TTY, listing only what is still catching up. */\nexport function renderLine(\n rows: readonly ProgressRow[],\n priority?: ProgressPriority,\n): string {\n const busy = rows.filter((row) => row.state !== \"done\");\n const line = `catch-up: ${busy.map((row) => `${row.label} ${percent(row)}`).join(\" · \")}`;\n return priority\n ? `${line} · priority ${priority.level} ${priority.mode}`\n : line;\n}\n\nfunction busy(rows: readonly ProgressRow[]): boolean {\n return rows.some((row) => row.state !== \"done\");\n}\n\n/**\n * Shows catch-up progress while any row is not done. In a terminal the bars\n * sit below the output and every other write is printed above them; without\n * one, a progress line is printed every `lineMs`.\n */\nexport function startProgressDisplay(\n source: ProgressSource,\n options: ProgressDisplayOptions,\n): ProgressDisplay {\n const { stdout, stderr } = options;\n const tty = stdout.isTTY === true;\n let rows: readonly ProgressRow[] = [];\n let priority: ProgressPriority | undefined;\n let drawn = 0;\n let atLineStart = true;\n let lastLine = 0;\n let stopped = false;\n let reading = false;\n\n const restoreOut = stdout.write;\n const restoreErr = stderr.write;\n const originalOut = restoreOut.bind(stdout);\n const originalErr = restoreErr.bind(stderr);\n\n const erase = () => {\n if (drawn > 0) originalOut(`\\x1b[${drawn}A\\r\\x1b[0J`);\n drawn = 0;\n };\n const draw = () => {\n if (!tty || stopped || !atLineStart || !busy(rows)) return;\n const lines = renderBars(rows, widthOf(stdout), priority);\n originalOut(`${lines.join(\"\\n\")}\\n`);\n drawn = lines.length;\n };\n\n // Every other write goes above the bars: lift them, write, put them back.\n const above =\n (write: (chunk: string | Uint8Array, ...rest: never[]) => boolean) =>\n (chunk: string | Uint8Array, ...rest: never[]): boolean => {\n erase();\n const result = write(chunk, ...rest);\n const text =\n typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString();\n if (text.length > 0) atLineStart = text.endsWith(\"\\n\");\n draw();\n return result;\n };\n // A resized terminal has already reflowed the drawn lines; redraw for the\n // new width right away rather than at the next poll.\n const onResize = () => {\n if (stopped) return;\n erase();\n draw();\n };\n if (tty) {\n stdout.write = above(originalOut as never) as NodeJS.WriteStream[\"write\"];\n stderr.write = above(originalErr as never) as NodeJS.WriteStream[\"write\"];\n stdout.on?.(\"resize\", onResize);\n }\n\n const tick = async () => {\n if (reading || stopped) return;\n reading = true;\n try {\n ({ rows, priority } = await source());\n } catch {\n // The reactor did not answer; keep the last rows until it does.\n } finally {\n reading = false;\n }\n if (stopped) return;\n if (tty) {\n erase();\n draw();\n return;\n }\n const now = Date.now();\n if (busy(rows) && now - lastLine >= (options.lineMs ?? DEFAULT_LINE_MS)) {\n originalOut(`${renderLine(rows, priority)}\\n`);\n lastLine = now;\n }\n };\n\n const timer = setInterval(\n () => void tick(),\n options.pollMs ?? DEFAULT_POLL_MS,\n );\n (timer as { unref?: () => void }).unref?.();\n void tick();\n\n return {\n stop() {\n if (stopped) return;\n stopped = true;\n clearInterval(timer);\n erase();\n if (tty) {\n stdout.off?.(\"resize\", onResize);\n stdout.write = restoreOut;\n stderr.write = restoreErr;\n }\n },\n };\n}\n","import type * as SwitchboardUtils from \"@powerhousedao/switchboard/utils\";\nimport {\n defineHostSchemas,\n drivesSchema,\n mergeDrivePlan,\n protocolConflicts,\n resolveDriveDeclaration,\n resolveHostPlugins,\n seedDrives,\n type BootCheckContext,\n type BootIssue,\n type DriveSeederClient,\n type ResolvedDrive,\n type ResolvedPlugin,\n type RunnerContext,\n type RunnerHandle,\n} from \"@powerhousedao/host-core\";\nimport path from \"node:path\";\nimport {\n memberEnvOf,\n memberSwitchboardConfig,\n memberSwitchboardConfigSchema,\n prepareMemberStorage,\n reactorBlockConflicts,\n readModelAsReactorStore,\n switchboardDevMode,\n} from \"./member-config.js\";\nimport { z } from \"zod\";\nimport { classicSwitchboardArgs } from \"../services/classic-args.js\";\nimport {\n inspectorProgressSource,\n startProgressDisplay,\n} from \"../services/run/catch-up-progress.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 */\n\nexport const kind = \"reactor\";\n\n/** The switchboard host: the host-core reactor host with every runner option\n * this module reads declared (strict: an unknown runner key fails).\n * `config.switchboard` is this member's own switchboard config (auth,\n * inspection, workers, ...); a key the reactor block also sets is refused.\n * One definition, two schemas: `declaredHostSchema` (token-able fields take\n * output tokens; types host files) and `hostSchema` (resolved; checked\n * right before the verb). */\nconst schemas = defineHostSchemas((s) =>\n s.reactorHostSchema\n .extend({\n runner: s.runnerBaseSchema\n .extend({\n /** 0 binds a port the OS picks; `origin` reports it. */\n port: z.number().int().min(0).max(65535).optional(),\n /** Dev mode without the `dev` verb (the Vite package loader). */\n dev: z.boolean().optional(),\n /** The project package output dir `build` writes (default \"dist\"). */\n outDir: z.string().min(1).optional(),\n })\n .strict(),\n config: z\n .strictObject({ switchboard: memberSwitchboardConfigSchema.optional() })\n .optional(),\n })\n .superRefine((host, ctx) => {\n for (const message of reactorBlockConflicts(host)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"config\", \"switchboard\"],\n message,\n });\n }\n }),\n);\nexport const declaredHostSchema = schemas.declaredHostSchema;\nexport const hostSchema = schemas.hostSchema;\n\n/** What a switchboard host.js author writes. */\nexport type SwitchboardHost = z.input<typeof declaredHostSchema>;\n/** What a verb receives (defaults applied). */\nexport type SwitchboardHostParsed = z.output<typeof hostSchema>;\n\n/** One drive the switchboard serves: its document id and its URL. */\nexport const switchboardDriveOutputSchema = z.strictObject({\n id: z.string().min(1),\n url: z.url(),\n});\n\n/** What a started switchboard produces. `origin` carries the port the server\n * actually bound. `drives` is keyed by the DECLARED slug (a `projectHash:\n * true` drive is reachable as `vetra`, its URL uses the hashed slug it is\n * served under) and includes plugin-created drives (e.g. `workflows`) and\n * the server's implicit default drive. `endpoints.mcp` is present when MCP\n * is mounted. */\nexport const outputsSchema = z.strictObject({\n origin: z.url(),\n endpoints: z.strictObject({\n graphql: z.url(),\n mcp: z.url().optional(),\n }),\n drives: z.record(z.string(), switchboardDriveOutputSchema),\n});\nexport type SwitchboardOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/ph-cli/runners/switchboard\": {\n host: SwitchboardHost;\n outputs: SwitchboardOutputs;\n };\n }\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: SwitchboardHostParsed,\n devMode: boolean,\n composed: boolean,\n): Promise<SwitchboardRunnerArgs> {\n const classic = await classicSwitchboardArgs();\n const runner = host.runner;\n return {\n ...classic,\n port: runner.port ?? classic.port,\n dev: switchboardDevMode(devMode, runner) ? 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 };\n}\n\n/** The drive the switchboard service creates by default\n * (services/switchboard.ts `defaultSwitchboardOptions.drive`). */\nconst DEFAULT_DRIVE_SLUG = \"powerhouse\";\n\n/** The `<slug>` of the server-reported `…/d/<slug>` default drive URL. */\nfunction defaultDriveSlug(url: string | undefined): string {\n const match = url ? /\\/d\\/([^/?#]+)\\/?$/.exec(url) : null;\n return match ? decodeURIComponent(match[1]) : DEFAULT_DRIVE_SLUG;\n}\n\n/** A drive in the plan with the slug its declaration used (a `projectHash:\n * true` drive is served under its hashed slug; outputs key it by this one). */\ninterface PlannedDrive {\n declaredSlug: string;\n drive: ResolvedDrive;\n}\n\n/**\n * The drives the composition's plugins contribute, resolved and in plan\n * order, minus the slugs the host declares itself (mergeDrivePlan: the host\n * file wins). A contribution that is not a valid drive declaration fails the\n * boot naming the plugin.\n */\nfunction pluginDrives(\n projectRoot: string,\n hostDrives: readonly PlannedDrive[],\n composition: readonly ResolvedPlugin[] | undefined,\n where: string,\n): PlannedDrive[] {\n if (!composition) return [];\n const contributed = composition.flatMap((resolved) => {\n const drives = resolved.plugin.contributions?.drives ?? [];\n if (drives.length === 0) return [];\n const parsed = drivesSchema.safeParse(drives);\n if (!parsed.success) {\n throw new Error(\n `${where}: plugin \"${resolved.plugin.name}\" contributes an invalid drive declaration:\\n${z.prettifyError(parsed.error)}`,\n );\n }\n return parsed.data.map((declaration) => ({\n declaration,\n source: resolved.plugin.name,\n }));\n });\n if (contributed.length === 0) return [];\n // served slug -> declared slug, for the outputs' keys\n const declaredSlugs = new Map(\n contributed.map(({ declaration }) => [\n resolveDriveDeclaration(projectRoot, declaration).slug,\n declaration.slug,\n ]),\n );\n const hostSlugs = new Set(hostDrives.map((d) => d.drive.slug));\n return mergeDrivePlan(projectRoot, [], contributed)\n .map((entry) => entry.drive)\n .filter((drive) => !hostSlugs.has(drive.slug))\n .map((drive) => ({\n declaredSlug: declaredSlugs.get(drive.slug) ?? drive.slug,\n drive,\n }));\n}\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).\n *\n * The probe is anonymous, and a host with authentication on hides a drive\n * from a caller it refuses (`/d/:drive` answers 404 to anyone who may not\n * read it, 401 under the authenticated-caller floor). Those answers prove\n * the server is listening but not whether the drive exists, so `served`,\n * the reactor's own view of the drive, decides then; without it an\n * ADMIN_ONLY host never passes this gate and the compound tears down after\n * the timeout. */\nexport async function waitForDrive(\n url: string,\n timeoutMs: number,\n served?: () => Promise<boolean>,\n fetchImpl: typeof fetch = fetch,\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n const HIDDEN = new Set([401, 403, 404]);\n for (;;) {\n try {\n const res = await fetchImpl(url, { signal: AbortSignal.timeout(3000) });\n if (res.ok) return;\n if (HIDDEN.has(res.status) && served && (await served())) 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 returns. */\nexport type SwitchboardHandle = RunnerHandle<SwitchboardOutputs>;\n\n/** The slice of the switchboard's reactor client (IReactorClient) the seeder\n * reads: id-or-slug resolution against the read model (live documents). */\ninterface SlugLookupClient {\n resolveIdOrSlug(identifier: string): Promise<string | undefined>;\n}\n\n/**\n * Adapter from the switchboard's reactor client onto the host-core seeder.\n * Seeding is SLUG-keyed: a live drive that already serves the slug — under\n * whatever id (a store from a run that hashed the project path differently,\n * or a hand-made drive) — is the drive, and nothing is created. addDefaultDrive\n * alone only knows ids: with a different id it would try to create a second\n * drive for the slug, and against a deleted document with that id the create\n * fails on every boot.\n */\nfunction seederClient(\n reactor: unknown,\n port: number,\n seededIds: Map<string, string>,\n): DriveSeederClient {\n return {\n findDriveBySlug: async (slug: string) => {\n try {\n const id = await (reactor as SlugLookupClient).resolveIdOrSlug(slug);\n if (id) seededIds.set(slug, id);\n return id || undefined;\n } catch {\n // not found (or ambiguous): seed as declared\n return undefined;\n }\n },\n createDrive: async (drive: ResolvedDrive) => {\n const { addDefaultDrive } =\n await import(\"@powerhousedao/switchboard/utils\");\n // One drive that cannot be made must not keep the server from starting\n try {\n await createDeclaredDrive(addDefaultDrive, reactor, drive, port);\n } catch (error) {\n console.error(\n `The drive \"${drive.slug}\" was not created: ${error instanceof Error ? error.message : String(error)}`,\n );\n return;\n }\n // Its id: the declared one, or a new one where the store could not take\n // a pinned id (addDefaultDrive then made it under the slug)\n let id: string | undefined;\n try {\n id = await (reactor as SlugLookupClient).resolveIdOrSlug(drive.slug);\n } catch {\n id = undefined;\n }\n seededIds.set(drive.slug, id || drive.id);\n },\n attachRemoteDrive: () => Promise.resolve(), // remotes ride options.remoteDrives\n };\n}\n\n/** A declared local drive, through the switchboard's own default-drive path. */\nasync function createDeclaredDrive(\n addDefaultDrive: typeof SwitchboardUtils.addDefaultDrive,\n reactor: unknown,\n drive: ResolvedDrive,\n port: number,\n): Promise<void> {\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\nasync function start(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n devMode: boolean,\n): Promise<SwitchboardHandle> {\n const hostFile = `hosts/${host.name}/host.js`;\n // Split before the server import loads the project .env into the env.\n const env = memberEnvOf(ctx.env);\n prepareMemberStorage(host.reactor, env.shell, hostFile);\n const legacyStore = readModelAsReactorStore(\n host.reactor,\n env.shell,\n hostFile,\n );\n if (legacyStore) console.warn(legacyStore.warning);\n const { startSwitchboard } = await import(\"../services/switchboard.js\");\n const entries = host.runner.plugins;\n const entriesDeclared = entries !== undefined;\n const classic = await toSwitchboardArgs(host, devMode, entriesDeclared);\n // powerhouse.config.json `reactor.https` is a default, not a flag: it goes\n // under the member's own config instead of over it.\n const { https } = classic;\n const args = { ...classic, https: undefined };\n // This member's own config, under the args: nothing is written to the\n // process env, so compound members do not see each other's settings.\n const memberConfig = await memberSwitchboardConfig(host, env, {\n pluginHost: entriesDeclared,\n defaults: https === undefined ? {} : { server: { https } },\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\n // `features.pluginHost` drives server-side activation. No plugins key =\n // classic path.\n let pluginComposition;\n if (entries !== undefined) {\n pluginComposition = await resolveHostPlugins(\n ctx.projectRoot,\n \"switchboard\",\n ctx.verb,\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 hostDrives: PlannedDrive[] = (host.reactor?.drives ?? []).map(\n (declaration) => ({\n declaredSlug: declaration.slug,\n drive: resolveDriveDeclaration(ctx.projectRoot, declaration),\n }),\n );\n // Plugin-contributed drives (e.g. the workflows plugin's Workflows drive)\n // join the plan after the host's own: a host declaration with the same slug\n // wins, and the host's drives stay first (the first local one is the\n // readiness gate and the compound's primary drive).\n const contributedDrives = pluginDrives(\n ctx.projectRoot,\n hostDrives,\n pluginComposition,\n `hosts/${host.name}/host.js`,\n );\n const planned = [...hostDrives, ...contributedDrives];\n const resolvedDrives = planned.map((p) => p.drive);\n const remoteDrives = resolvedDrives.flatMap((d) =>\n d.kind === \"remote\" && d.remoteUrl ? [d.remoteUrl] : [],\n );\n const serverArgs = {\n ...args,\n ...(pluginComposition ? { pluginComposition } : {}),\n // Only the HOST's declarations replace the implicit default drive; a\n // contribution adds to whatever the host serves.\n ...(hostDrives.length > 0 ? { drive: undefined } : {}),\n ...(remoteDrives.length > 0 ? { remoteDrives } : {}),\n // A compound member: the compound owns SIGINT/SIGTERM and the exit, and\n // stops this reactor through the handle's shutdown().\n ...(ctx.parent ? { signalHandlers: false } : {}),\n };\n\n const switchboard = await startSwitchboard(\n serverArgs,\n undefined,\n memberConfig,\n );\n // Bars for processor and read-model catch-up, below the server's output;\n // PH_CATCH_UP_PROGRESS=false leaves the output as it was.\n const progress =\n switchboard.inspector && process.env.PH_CATCH_UP_PROGRESS !== \"false\"\n ? startProgressDisplay(inspectorProgressSource(switchboard.inspector), {\n stdout: process.stdout,\n stderr: process.stderr,\n })\n : undefined;\n // The port the server actually bound (it may move off a taken one).\n const port = switchboard.port;\n const origin = `http://localhost:${port}`;\n const driveUrlOf = (slug: string) => `${origin}/d/${slug}`;\n\n const seededIds = new Map<string, string>();\n const localPlanned = planned.filter((p) => p.drive.kind === \"local\");\n if (localPlanned.length > 0) {\n await seedDrives(\n seederClient(switchboard.reactor, port, seededIds),\n localPlanned.map((p) => p.drive),\n );\n }\n\n const drives: SwitchboardOutputs[\"drives\"] = {};\n // The server creates its implicit default drive only when nothing replaces\n // it: no host declaration and no remote drive (services/switchboard.ts).\n const localHostDrives = hostDrives.filter((d) => d.drive.kind === \"local\");\n const defaultSlug = defaultDriveSlug(switchboard.defaultDriveUrl);\n if (hostDrives.length === 0 && remoteDrives.length === 0) {\n drives[defaultSlug] = { id: defaultSlug, url: driveUrlOf(defaultSlug) };\n }\n for (const { declaredSlug, drive } of localPlanned) {\n drives[declaredSlug] = {\n id: seededIds.get(drive.slug) ?? drive.id,\n url: driveUrlOf(drive.slug),\n };\n }\n\n const slug =\n localHostDrives.length > 0 ? localHostDrives[0].drive.slug : defaultSlug;\n const driveUrl = driveUrlOf(slug);\n\n // No composition declared (the deprecated `reactor.workflows` switch): the\n // workflows flag still seeds the SAME project-hashed drive the classic\n // vetra path seeds. With a composition the workflows PLUGIN declares that\n // drive (contributions.drives above), so nothing implicit happens here.\n if (entries === undefined && switchboard.workflowsEnabled) {\n const { seedWorkflowsDrive } = await import(\"../services/vetra.js\");\n const { generateProjectDriveId } = await import(\"../utils.js\");\n const url = await seedWorkflowsDrive(switchboard.reactor, port);\n if (url)\n drives.workflows = { id: generateProjectDriveId(\"workflows\"), url };\n }\n\n // Under an authenticating host the anonymous probe cannot see the drive;\n // the reactor's slug lookup (the seeder's) answers for it.\n const served = async () => {\n try {\n const id = await (\n switchboard.reactor as SlugLookupClient\n ).resolveIdOrSlug(slug);\n return Boolean(id);\n } catch {\n return false;\n }\n };\n const ready = waitForDrive(driveUrl, 180_000, served);\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 const graphql = `${origin}/graphql`;\n // Stops the reactor the server owns, then drains the HTTP server (freeing\n // the port), GraphQL, MCP, attachments, the plugins' onShutdown and the\n // read-model db, then closes the reactor database. SwitchboardReactor\n // memoizes it; standalone, SIGINT/SIGTERM run the same teardown, so a\n // shutdown() during or after a signal joins it instead of draining twice.\n let stopping: Promise<void> | undefined;\n return {\n outputs: outputsSchema.parse({\n origin,\n endpoints: {\n graphql,\n ...(switchboard.mcpEnabled ? { mcp: `${origin}/mcp` } : {}),\n },\n drives,\n }),\n ready,\n shutdown: () => {\n progress?.stop();\n return (stopping ??= switchboard.shutdown());\n },\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: SwitchboardHostParsed,\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: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<SwitchboardHandle> {\n return start(host, ctx, true);\n}\n\n/** What the server would refuse at boot for this host, `ctx.verb` and `ctx.env` (`ph host check`). */\nexport async function checkBoot(\n host: SwitchboardHostParsed,\n ctx: BootCheckContext,\n): Promise<BootIssue[]> {\n // As `start` splits it: the project .env sits under the host file.\n const env = memberEnvOf(ctx.env, ctx.projectRoot);\n const issues: BootIssue[] = protocolConflicts(\n host.reactor?.protocol,\n env.shell,\n ctx.file,\n ).map((message) => ({ path: \"reactor.protocol\", message }));\n const legacyStore = readModelAsReactorStore(\n host.reactor,\n env.shell,\n ctx.file,\n );\n if (legacyStore) {\n issues.push({ path: \"reactor.backends\", message: legacyStore.warning });\n }\n const { getConfig } = await import(\"@powerhousedao/config/node\");\n const { switchboardBootFactsOf, switchboardBootIssues } =\n await import(\"@powerhousedao/switchboard/boot\");\n let config;\n try {\n // As `start` builds it; an env parse error becomes the issue.\n config = await memberSwitchboardConfig(host, env, {\n pluginHost: host.runner.plugins !== undefined,\n });\n } catch (error) {\n issues.push({\n path: \"\",\n message: error instanceof Error ? error.message : String(error),\n });\n return issues;\n }\n const facts = await switchboardBootFactsOf(config, {\n // As the `dev` verb starts it.\n dev: switchboardDevMode(ctx.verb === \"dev\", host.runner),\n configuredRenown: getConfig(\n path.join(ctx.projectRoot, \"powerhouse.config.json\"),\n ).auth?.renown,\n });\n for (const message of switchboardBootIssues(facts)) {\n issues.push({ path: \"\", message });\n }\n return issues;\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: SwitchboardHostParsed,\n _ctx: RunnerContext,\n): Promise<void> {\n const { runBuild } = await import(\"../services/build.js\");\n const args: Partial<BuildArgs> = {\n outDir: host.runner.outDir ?? \"dist\",\n };\n await runBuild(args as BuildArgs);\n}\n"],"names":["z.number","z.boolean","z.string","z\n .strictObject","z.strictObject","z.url","z.record","z.prettifyError"],"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;;;ACAA,SAAS,WAAW,OAAe,YAA4B;CAC7D,OAAO,GAAG,MAAM,IAAI,WAAW,GAAG,eAAe,IAAI,UAAU,SAAS;AAC1E;;AAGA,SAAgB,aAAa,UAA0C;CACrE,MAAM,YAAY,SAAS,UAAU,KAAK,aAA0B;EAClE,OAAO,WAAW,QAAQ,OAAO,QAAQ,UAAU;EACnD,UAAU,QAAQ;EAClB,OACE,QAAQ,UAAU,YACd,YACA,QAAQ,UAAU,gBAChB,gBACA;CACV,EAAE;CACF,MAAM,aAAa,SAAS,WAAW,KAAK,WAAwB;EAClE,OAAO,MAAM;EACb,UAAU,MAAM;EAChB,OAAO,MAAM,UAAU,YAAY,MAAM,WAAW,SAAS;CAC/D,EAAE;CACF,OAAO,CAAC,GAAG,WAAW,GAAG,UAAU;AACrC;;AAGA,SAAgB,wBAAwB,WAAuC;CAC7E,OAAO,YAAY;EACjB,MAAM,aAAa,MAAM,UAAU,cAAc;EACjD,IAAI;EAGJ,IAAI;GACF,UAAU,MAAM,UAAU,iBAAiB;EAC7C,QAAQ;GACN,UAAU,KAAA;EACZ;EACA,IAAI;EACJ,IAAI;GACF,MAAM,QAAQ,MAAM,UAAU,mBAAmB;GACjD,WA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