@powerhousedao/ph-cli 6.2.3-dev.70 → 6.2.3-dev.72

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 (79) hide show
  1. package/dist/{cli-connect-override-Cf7WutqU.mjs → cli-connect-override-CEJhQWRX.mjs} +5 -5
  2. package/dist/cli-connect-override-CEJhQWRX.mjs.map +1 -0
  3. package/dist/cli.mjs +4 -4
  4. package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs +2459 -0
  5. package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs.map +1 -0
  6. package/dist/{connect-build-BtKpvcQK.mjs → connect-build-BfhOGbha.mjs} +4 -4
  7. package/dist/{connect-build-BtKpvcQK.mjs.map → connect-build-BfhOGbha.mjs.map} +1 -1
  8. package/dist/{connect-config-9EZB_0H_.mjs → connect-config-DblqJgxR.mjs} +4 -4
  9. package/dist/{connect-config-9EZB_0H_.mjs.map → connect-config-DblqJgxR.mjs.map} +1 -1
  10. package/dist/connect-plugin-configs-D2fwYpMw.mjs +50 -0
  11. package/dist/connect-plugin-configs-D2fwYpMw.mjs.map +1 -0
  12. package/dist/{connect-studio-Bhlc77WI.mjs → connect-studio-B1_4TNEb.mjs} +8 -6
  13. package/dist/connect-studio-B1_4TNEb.mjs.map +1 -0
  14. package/dist/{connect-studio-BehPZzN7.mjs → connect-studio-BS26pchr.mjs} +3 -3
  15. package/dist/{dist-BqeDFgEy.mjs → dist-CCLkwpTS.mjs} +199 -109
  16. package/dist/dist-CCLkwpTS.mjs.map +1 -0
  17. package/dist/explain-DUXbB9jf.mjs +241 -0
  18. package/dist/explain-DUXbB9jf.mjs.map +1 -0
  19. package/dist/{generate-all-C_sPGBuk.mjs → generate-all-Dgyy_kT-.mjs} +7 -3
  20. package/dist/generate-all-Dgyy_kT-.mjs.map +1 -0
  21. package/dist/{generate-desktop-shell-BBSGpmud.mjs → generate-desktop-shell-BdXDiS5o.mjs} +113 -7
  22. package/dist/generate-desktop-shell-BdXDiS5o.mjs.map +1 -0
  23. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  24. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  25. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  26. package/dist/{index-CspiP73o.d.mts → index-BIbx17vt.d.mts} +178 -14
  27. package/dist/index-BIbx17vt.d.mts.map +1 -0
  28. package/dist/{ph-cli-commands-3ptdQ0NI.mjs → ph-cli-commands-DSAhaETu.mjs} +156 -139
  29. package/dist/ph-cli-commands-DSAhaETu.mjs.map +1 -0
  30. package/dist/ph-cli-commands-d5XjMWW0.mjs +4 -0
  31. package/dist/{run-sugar-BdjKTPGO.mjs → run-sugar-Ns53R6lU.mjs} +4 -4
  32. package/dist/{run-sugar-BdjKTPGO.mjs.map → run-sugar-Ns53R6lU.mjs.map} +1 -1
  33. package/dist/runners/connect.d.mts +1054 -26
  34. package/dist/runners/connect.d.mts.map +1 -1
  35. package/dist/runners/connect.mjs +127 -50
  36. package/dist/runners/connect.mjs.map +1 -1
  37. package/dist/runners/switchboard.d.mts +170 -28
  38. package/dist/runners/switchboard.d.mts.map +1 -1
  39. package/dist/runners/switchboard.mjs +171 -49
  40. package/dist/runners/switchboard.mjs.map +1 -1
  41. package/dist/{schemas-BQSPev1x.mjs → schemas-D5N5U_Mf.mjs} +205 -4
  42. package/dist/{schemas-BQSPev1x.mjs.map → schemas-D5N5U_Mf.mjs.map} +1 -1
  43. package/dist/scripts/emit-runner-schemas.ts +24 -0
  44. package/dist/start-run-BIaYSpHh.mjs +124 -0
  45. package/dist/start-run-BIaYSpHh.mjs.map +1 -0
  46. package/dist/{superseded-config-9D7BdLvd.mjs → superseded-config-CbSTFun2.mjs} +4 -4
  47. package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
  48. package/dist/switchboard-h4-XgP1h.mjs +2 -2
  49. package/dist/switchboard-h4-XgP1h.mjs.map +1 -1
  50. package/dist/utils-DAux4Ga7.mjs +4 -0
  51. package/dist/{vetra-BD-34wGs.mjs → vetra-UQsfYM_Q.mjs} +10 -10
  52. package/dist/vetra-UQsfYM_Q.mjs.map +1 -0
  53. package/package.json +15 -20
  54. package/dist/cli-connect-override-Cf7WutqU.mjs.map +0 -1
  55. package/dist/connect-studio-Bhlc77WI.mjs.map +0 -1
  56. package/dist/dist-BqeDFgEy.mjs.map +0 -1
  57. package/dist/explain-BDHmXgw3.mjs +0 -27
  58. package/dist/explain-BDHmXgw3.mjs.map +0 -1
  59. package/dist/generate-all-C_sPGBuk.mjs.map +0 -1
  60. package/dist/generate-desktop-shell-BBSGpmud.mjs.map +0 -1
  61. package/dist/host-schemas-CtPNRr5v-BQyKKFbS.mjs +0 -493
  62. package/dist/host-schemas-CtPNRr5v-BQyKKFbS.mjs.map +0 -1
  63. package/dist/index-CspiP73o.d.mts.map +0 -1
  64. package/dist/ph-cli-commands-3ptdQ0NI.mjs.map +0 -1
  65. package/dist/ph-cli-commands-Dx8hNj6W.mjs +0 -4
  66. package/dist/plugins-CHVv4qup.mjs +0 -91
  67. package/dist/plugins-CHVv4qup.mjs.map +0 -1
  68. package/dist/reactor-env-BbR86_Li.mjs +0 -29
  69. package/dist/reactor-env-BbR86_Li.mjs.map +0 -1
  70. package/dist/reactor-env-D_EvBtLB.mjs +0 -4
  71. package/dist/runners/compound.d.mts +0 -127
  72. package/dist/runners/compound.d.mts.map +0 -1
  73. package/dist/runners/compound.mjs +0 -72
  74. package/dist/runners/compound.mjs.map +0 -1
  75. package/dist/start-run-CmDxyMw0.mjs +0 -36
  76. package/dist/start-run-CmDxyMw0.mjs.map +0 -1
  77. package/dist/superseded-config-9D7BdLvd.mjs.map +0 -1
  78. package/dist/utils-TO9lB8Xs.mjs +0 -4
  79. package/dist/vetra-BD-34wGs.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.mts","names":[],"sources":["../../src/runners/connect.ts"],"mappings":";;;;;;;;;qBAuCa;;;;qBAKA,YAAU;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAqB;;YAGhC,cAAc,aAAe;;YAE7B,oBAAoB,cAAgB;;;qBAInC,eAAa;;;;;GAGxB;YACU,iBAAiB,gBAAe;QAEpC;YACI;IACR;MACE,MAAM;MACN,SAAS;;;;wBAyPC,mBAAmB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiBrB,IACpB,MAAM,mBACN,KAAK,gBACJ,QAAQ,aAAa;;;qBAgBX,YAAG;;wBAGM,MACpB,MAAM,mBACN,KAAK,gBACJ;;;;;;;;;wBAuBmB,MACpB,MAAM,mBACN,KAAK,gBACJ,QAAQ,aAAa"}
@@ -1,44 +1,76 @@
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]="89f11518-df5f-57f9-9d5a-04d707d8f29c")}catch(e){}}();
3
- import { a as looseObject, i as literal, l as string, n as array, o as number, r as boolean, u as union } from "../schemas-BQSPev1x.mjs";
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-CtPNRr5v-BQyKKFbS.mjs";
6
- import { i as projectReactorToConnect, n as isStructuralMultiReactor, o as remoteBackendUrls } from "../dist-BqeDFgEy.mjs";
7
- import { DEFAULT_CONNECT_STUDIO_PORT } from "@powerhousedao/shared/clis";
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]="7cd9d76a-0126-553f-ac1f-1cdb2d9cc69e")}catch(e){}}();
3
+ import { c as strictObject, f as url, i as literal, l as string, r as boolean, u as union } from "../schemas-D5N5U_Mf.mjs";
4
+ import { c as defineHostSchemas, d as entryActiveForVerb, p as findDeadConnectConfig, x as normalizePluginEntries } from "../compound-B6RZMA0Y-Cv3XMQ3Y.mjs";
5
+ import { c as projectReactorToConnect, d as remoteBackendUrls, f as resolveDriveDeclaration, i as mergeDefaultDrives, r as isStructuralMultiReactor, s as projectDrivesIntoConnect } from "../dist-CCLkwpTS.mjs";
6
+ import { join } from "node:path";
7
+ import { DEFAULT_CONNECT_OUTDIR, DEFAULT_CONNECT_STUDIO_PORT } from "@powerhousedao/shared/clis";
8
+ import { connectConfigSchemaWith } from "@powerhousedao/shared/connect/connect-config-schema";
9
+ import { isPassthroughImageRef } from "@powerhousedao/shared/connect/image-ref";
8
10
  //#region src/runners/connect.ts
9
11
  /**
10
12
  * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a
11
13
  * hosts/connect/host.js definition onto the SAME service the classic
12
- * `ph connect studio` command calls — no forked behavior. Real verbs
13
- * (`build`, `serve`) arrive with later phases; their absence here is
14
- * deliberate and surfaces through the verb-listing error.
14
+ * `ph connect studio` (dev/run), `ph connect build` and `ph connect preview`
15
+ * (serve) commands call — no forked behavior.
15
16
  */
16
17
  const kind = "reactor";
17
- /** Phase-2 schema (D2.d): `reactor` and `profile` validate strictly via the
18
- * shared host-core schemas — a typo'd protocol key fails instead of silently
19
- * not applying. `config` stays loose: it is runner-defined by design. */
20
- const hostSchema = looseObject({
21
- name: string().min(1),
22
- runner: looseObject({
23
- module: string(),
24
- port: number().int().positive().optional(),
25
- host: string().optional(),
26
- https: boolean().optional(),
18
+ /** The connect host: the host-core reactor host with every runner option
19
+ * this module reads declared (strict: an unknown runner key fails), and
20
+ * `config` typed by Connect's own zod schema (the authored `connect` block),
21
+ * whose URL fields that name another host's outputs
22
+ * (`drives.defaultDrives[].url`, `renown.switchboardUrl`) are token-able.
23
+ * One definition, two schemas: `declaredHostSchema` (token-able fields take
24
+ * output tokens; types host files) and `hostSchema` (resolved; checked
25
+ * right before the verb). */
26
+ const schemas = defineHostSchemas((s) => s.reactorHostSchema.extend({
27
+ runner: s.runnerBaseSchema.extend({
28
+ /** Open a browser tab once listening (dev/serve). */
27
29
  openBrowser: boolean().optional(),
28
- routes: union([string(), literal(false)]).optional(),
29
- plugins: array(pluginEntrySchema).optional()
30
- }),
31
- config: looseObject({}).optional(),
32
- profile: profileSchema,
33
- reactor: reactorSchema.optional()
30
+ /** Fail instead of moving to the next free port when `port` is taken. */
31
+ strictPort: boolean().optional(),
32
+ /** The Connect build output dir (`build` writes it, `serve` serves it). */
33
+ outDir: string().min(1).optional(),
34
+ /** Patch the baked CSP for the runtime registry (`serve`); a
35
+ * compound's wiring sets it on its connect member. */
36
+ cspRegistrySync: boolean().optional(),
37
+ /** The host's routes folder, project-relative; false for none.
38
+ * Default: hosts/connect/routes. */
39
+ routes: union([string(), literal(false)]).optional()
40
+ }).strict(),
41
+ config: connectConfigSchemaWith(s.tokenable).optional()
42
+ }));
43
+ const declaredHostSchema = schemas.declaredHostSchema;
44
+ const hostSchema = schemas.hostSchema;
45
+ /** What a started Connect (`dev`/`run`/`serve`) produces: the origin it
46
+ * actually listens on and the app URL (origin plus base path). */
47
+ const outputsSchema = strictObject({
48
+ origin: url(),
49
+ endpoints: strictObject({ connect: url() })
34
50
  });
51
+ /** A started Connect as a runner handle. vite has already listened when the
52
+ * service returns, so `ready` is settled; the outputs carry the URL vite
53
+ * resolved (the port it actually bound), falling back to the requested one. */
54
+ function connectHandle(server, requested) {
55
+ const fallback = `http://${requested.host}:${requested.port}/`;
56
+ const app = server.resolvedUrls?.local[0] ?? fallback;
57
+ let closing;
58
+ return {
59
+ outputs: outputsSchema.parse({
60
+ origin: new URL(app).origin,
61
+ endpoints: { connect: app }
62
+ }),
63
+ ready: Promise.resolve(),
64
+ shutdown: () => closing ??= server.close()
65
+ };
66
+ }
35
67
  /** The studio arg surface is wide (commonArgs + server args); the service only
36
68
  * reads a known subset, and the repo's own tests build these objects the same
37
69
  * way (Partial + cast — see connect-build.test.ts `mk()`). */
38
70
  function toStudioArgs(host) {
39
71
  const runner = host.runner;
40
72
  return {
41
- port: typeof runner.port === "number" ? runner.port : DEFAULT_CONNECT_STUDIO_PORT,
73
+ port: runner.port ?? DEFAULT_CONNECT_STUDIO_PORT,
42
74
  open: runner.openBrowser === true,
43
75
  strictPort: runner.strictPort === true,
44
76
  printUrls: true,
@@ -74,7 +106,7 @@ function declaredDrivesToDefaults(projectRoot, declarations) {
74
106
  });
75
107
  }
76
108
  function callerOverride(host, ctx, verb = "dev") {
77
- const base = host.config ?? {};
109
+ const base = { ...host.config };
78
110
  const reactor = host.reactor;
79
111
  const entries = host.runner.plugins;
80
112
  const composition = entries === void 0 ? void 0 : normalizePluginEntries(entries, `hosts/${host.name}/host.js`).filter((entry) => entryActiveForVerb(entry, verb)).map((entry) => ({
@@ -87,10 +119,11 @@ function callerOverride(host, ctx, verb = "dev") {
87
119
  for (const entry of all) {
88
120
  const active = entryActiveForVerb(entry, verb);
89
121
  const scope = entry.verbs === "*" ? "" : ` verbs=[${entry.verbs.join(",")}]`;
90
- const cfg = Object.keys(entry.config ?? {});
122
+ const cfg = Object.keys(entry.config);
91
123
  console.log(`[connect] ${active ? "•" : "○"} ${entry.module}${scope}` + (cfg.length ? ` config: {${cfg.join(", ")}}` : "") + (active ? "" : " (inactive for this verb)"));
92
124
  }
93
125
  }
126
+ for (const warning of findDeadConnectConfig(host.config, entries, verb, `hosts/${host.name}/host.js`)) console.warn(warning.message);
94
127
  const declared = reactor?.drives;
95
128
  const declaredDefaults = declared && ctx ? declaredDrivesToDefaults(ctx.projectRoot, declared) : void 0;
96
129
  const reactorRenown = reactor?.renown;
@@ -111,7 +144,7 @@ function callerOverride(host, ctx, verb = "dev") {
111
144
  };
112
145
  const { connect } = projectReactorToConnect(reactor);
113
146
  const structural = isStructuralMultiReactor(reactor);
114
- if (!connect.reactor && !connect.instance && !connect.app && !structural) return host.config !== void 0 || composition ? base : void 0;
147
+ if (!connect.reactor && !connect.instance && !connect.app && !structural) return host.config !== void 0 || composition || declaredDefaults ? base : void 0;
115
148
  const drives = structural ? projectDrivesIntoConnect({
116
149
  createdDriveUrls: remoteBackendUrls(reactor),
117
150
  configuredDefaultDrives: base.drives?.defaultDrives
@@ -141,30 +174,66 @@ function callerOverride(host, ctx, verb = "dev") {
141
174
  } } : {}
142
175
  };
143
176
  }
144
- function withoutFavicon(config) {
145
- if (config?.branding?.favicon === void 0) return config;
146
- const { favicon: _, ...branding } = config.branding;
177
+ /**
178
+ * Start a server; under a supervising compound (`ctx.parent`), drop the
179
+ * process-exiting signal listeners it installed (vite's dev and preview
180
+ * servers exit on SIGTERM): the compound owns the exit and stops members in
181
+ * reverse dependency order through their handles.
182
+ */
183
+ async function startUnderSupervisor(ctx, start) {
184
+ if (!ctx.parent) return start();
185
+ const signals = ["SIGINT", "SIGTERM"];
186
+ const before = new Map(signals.map((signal) => [signal, new Set(process.listeners(signal))]));
187
+ try {
188
+ return await start();
189
+ } finally {
190
+ for (const signal of signals) for (const listener of process.listeners(signal)) if (!before.get(signal)?.has(listener)) process.off(signal, listener);
191
+ }
192
+ }
193
+ /** Fail at `ph run`, naming the plugin and key, when a composed Connect
194
+ * plugin's entry config does not match its schema. */
195
+ async function validateComposition(host, ctx) {
196
+ const { validateConnectPluginConfigs } = await import("../connect-plugin-configs-D2fwYpMw.mjs");
197
+ await validateConnectPluginConfigs(ctx.projectRoot, host.runner.plugins, ctx.verb, `hosts/${host.name}/host.js`);
198
+ }
199
+ /** A project file the build resolved: the built dist has it (as icon.ico or
200
+ * a data URI); served, its path would mean nothing. */
201
+ function isBuiltImage(ref) {
202
+ const src = typeof ref === "object" && ref !== null && "src" in ref ? ref.src : ref;
203
+ return typeof src === "string" && !isPassthroughImageRef(src);
204
+ }
205
+ function withoutBuiltImages(config) {
206
+ const branding = config?.branding;
207
+ if (!branding) return config;
208
+ const { favicon: _, ...served } = branding;
209
+ if (isBuiltImage(served.icon)) delete served.icon;
210
+ if (isBuiltImage(served.loader)) delete served.loader;
147
211
  return {
148
212
  ...config,
149
- branding
213
+ branding: served
150
214
  };
151
215
  }
152
- const routesOf = (host) => {
153
- const routes = host.runner.routes;
154
- return typeof routes === "string" || routes === false ? routes : void 0;
155
- };
216
+ const viteCacheOf = (host, ctx) => join(ctx.projectRoot, "node_modules", `.vite-${host.name.replace(/[^\w.-]/g, "_")}`);
156
217
  async function dev(host, ctx) {
157
- const { runConnectStudio } = await import("../connect-studio-BehPZzN7.mjs");
158
- await runConnectStudio(toStudioArgs(host), void 0, callerOverride(host, ctx, ctx.verb ?? "dev"), { routes: routesOf(host) });
218
+ await validateComposition(host, ctx);
219
+ const { runConnectStudio } = await import("../connect-studio-BS26pchr.mjs");
220
+ const args = toStudioArgs(host);
221
+ return connectHandle(await startUnderSupervisor(ctx, () => runConnectStudio(args, void 0, callerOverride(host, ctx, ctx.verb), {
222
+ routes: host.runner.routes,
223
+ cacheDir: viteCacheOf(host, ctx)
224
+ })), {
225
+ host: "localhost",
226
+ port: args.port
227
+ });
159
228
  }
160
229
  /** `run` is dev-studio until the plugin phases give hosts a production
161
230
  * runtime; `serve` (below) is the static production server. */
162
231
  const run = dev;
163
232
  /** P3.3 — `build`: the SAME service as classic `ph connect build`. */
164
233
  async function build(host, ctx) {
165
- const { runConnectBuild } = await import("../connect-build-BtKpvcQK.mjs");
166
- const runner = host.runner;
167
- await runConnectBuild({ outDir: typeof runner.outDir === "string" ? runner.outDir : "dist" }, callerOverride(host, ctx, ctx.verb ?? "build"), { routes: routesOf(host) });
234
+ await validateComposition(host, ctx);
235
+ const { runConnectBuild } = await import("../connect-build-BfhOGbha.mjs");
236
+ await runConnectBuild({ outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR }, callerOverride(host, ctx, ctx.verb), { routes: host.runner.routes });
168
237
  }
169
238
  /** P3.3 — `serve`: the SAME vite preview server as classic
170
239
  * `ph connect preview` (static serve of a built Connect; run `build` first).
@@ -175,24 +244,32 @@ async function build(host, ctx) {
175
244
  * CSP's script-src for the runtime registry — together these replace the
176
245
  * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */
177
246
  async function serve(host, ctx) {
247
+ await validateComposition(host, ctx);
178
248
  const { runConnectPreview } = await import("../connect-preview-8-qLgWKt.mjs");
179
249
  const runner = host.runner;
180
- await runConnectPreview({
181
- port: typeof runner.port === "number" ? runner.port : DEFAULT_CONNECT_STUDIO_PORT,
182
- outDir: typeof runner.outDir === "string" ? runner.outDir : "dist",
250
+ const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;
251
+ const bind = runner.host ?? "127.0.0.1";
252
+ const args = {
253
+ port,
254
+ outDir: runner.outDir ?? DEFAULT_CONNECT_OUTDIR,
183
255
  open: runner.openBrowser === true,
184
256
  strictPort: runner.strictPort === true,
185
257
  cors: true,
186
258
  printUrls: true,
187
259
  bindCLIShortcuts: false,
188
- host: typeof runner.host === "string" ? runner.host : "127.0.0.1"
189
- }, {
190
- connect: withoutFavicon(callerOverride(host, ctx, ctx.verb ?? "serve")),
260
+ host: bind
261
+ };
262
+ const override = withoutBuiltImages(callerOverride(host, ctx, ctx.verb));
263
+ return connectHandle(await startUnderSupervisor(ctx, () => runConnectPreview(args, {
264
+ connect: override,
191
265
  cspRegistrySync: runner.cspRegistrySync === true
266
+ })), {
267
+ host: bind,
268
+ port
192
269
  });
193
270
  }
194
271
  //#endregion
195
- export { build, dev, hostSchema, kind, run, serve };
272
+ export { build, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, withoutBuiltImages };
196
273
 
197
274
  //# sourceMappingURL=connect.mjs.map
198
- //# debugId=89f11518-df5f-57f9-9d5a-04d707d8f29c
275
+ //# debugId=7cd9d76a-0126-553f-ac1f-1cdb2d9cc69e
@@ -1 +1 @@
1
- {"version":3,"file":"connect.mjs","sources":["../../src/runners/connect.ts"],"sourcesContent":["import {\n DEFAULT_CONNECT_STUDIO_PORT,\n type PHConnectCompositionEntry,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport {\n entryActiveForVerb,\n isStructuralMultiReactor,\n mergeDefaultDrives,\n normalizePluginEntries,\n pluginEntrySchema,\n profileSchema,\n resolveDriveDeclaration,\n type DriveDeclaration,\n type PluginEntry,\n projectDrivesIntoConnect,\n projectReactorToConnect,\n reactorSchema,\n remoteBackendUrls,\n type HostDefinition,\n type ReactorConfig,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport { z } from \"zod\";\nimport type {\n ConnectBuildArgs,\n ConnectPreviewArgs,\n ConnectStudioArgs,\n} from \"../types.js\";\n\n/**\n * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a\n * hosts/connect/host.js definition onto the SAME service the classic\n * `ph connect studio` command calls — no forked behavior. Real verbs\n * (`build`, `serve`) arrive with later phases; their absence here is\n * deliberate and surfaces through the verb-listing error.\n */\n\nexport const kind = \"reactor\";\n\n/** Phase-2 schema (D2.d): `reactor` and `profile` validate strictly via the\n * shared host-core schemas — a typo'd protocol key fails instead of silently\n * not applying. `config` stays loose: it is runner-defined by design. */\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 host: z.string().optional(),\n https: z.boolean().optional(),\n openBrowser: z.boolean().optional(),\n // The host's routes folder, project-relative; false for none. Default: hosts/connect/routes.\n routes: z.union([z.string(), z.literal(false)]).optional(),\n // THE COMPOSITION (rewire R3): plugin entries, presence is activation.\n plugins: z.array(pluginEntrySchema).optional(),\n }),\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n reactor: reactorSchema.optional(),\n});\n\n/** The studio arg surface is wide (commonArgs + server args); the service only\n * reads a known subset, and the repo's own tests build these objects the same\n * way (Partial + cast — see connect-build.test.ts `mk()`). */\nfunction toStudioArgs(host: HostDefinition): ConnectStudioArgs {\n const runner = host.runner;\n const args: Partial<ConnectStudioArgs> = {\n port:\n typeof runner.port === \"number\"\n ? runner.port\n : DEFAULT_CONNECT_STUDIO_PORT,\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n printUrls: true,\n bindCLIShortcuts: false,\n };\n return args as ConnectStudioArgs;\n}\n\n/** Merge the reactor-block projection (protocol → connect.reactor,\n * backend kind → instance.reactorWorker, workflows → app.workflowsEnabled)\n * into the host's connect config, which rides the studio caller-override.\n * The host config wins on conflict (an explicit connect.* value is intent) —\n * EXCEPT structural multi-reactor (P4.2): declaring a remote backend next to\n * a local one IS the intent, so it beats a scaffold-default\n * instance.multiReactor: false, and the remote's drive url merges FIRST into\n * drives.defaultDrives (the first url entry is what the routing client dials). */\n/** host.js reactor.drives -> the served drives.defaultDrives shapes: locals\n * carry id/name/icon and the preferredEditor under its Connect alias `app`;\n * remotes carry their URL. */\nfunction declaredDrivesToDefaults(\n projectRoot: string,\n declarations: readonly DriveDeclaration[],\n): PHConnectDefaultDrive[] {\n return declarations.map((declaration) => {\n const drive = resolveDriveDeclaration(projectRoot, declaration);\n if (drive.kind === \"remote\") {\n return {\n url: drive.remoteUrl!,\n name: drive.name,\n icon: drive.icon ?? null,\n };\n }\n return {\n local: true as const,\n id: drive.id,\n name: drive.name,\n icon: drive.icon ?? null,\n ...(drive.preferredEditor ? { app: drive.preferredEditor } : {}),\n };\n });\n}\n\nfunction callerOverride(\n host: HostDefinition,\n ctx?: RunnerContext,\n verb = \"dev\",\n): PHConnectRuntimeConfig | undefined {\n const base = (host.config ?? {}) as PHConnectRuntimeConfig;\n const reactor = host.reactor as ReactorConfig | undefined;\n\n // R3: the composition (verb-filtered, projected as DATA — the browser\n // pipeline resolves and runs the entries), declared drives, and the\n // reactor-core identity/namespace keys.\n const entries = (host.runner as { plugins?: PluginEntry[] }).plugins;\n const composition: PHConnectCompositionEntry[] | undefined =\n entries === undefined\n ? undefined\n : normalizePluginEntries(entries, `hosts/${host.name}/host.js`)\n .filter((entry) => entryActiveForVerb(entry, verb))\n .map((entry) => ({ module: entry.module, config: entry.config }));\n if (entries !== undefined) {\n // Change 2: show the composition plan on the `ph run connect` terminal.\n // The pipeline itself runs in the browser (hook execution logs to the\n // browser console); here we report WHAT will be served and for which verb.\n const all = normalizePluginEntries(entries, `hosts/${host.name}/host.js`);\n console.log(\n `[connect] composition plan (verb=${verb}): ${composition?.length ?? 0} active of ${all.length} declared`,\n );\n for (const entry of all) {\n const active = entryActiveForVerb(entry, verb);\n const scope =\n entry.verbs === \"*\"\n ? \"\"\n : ` verbs=[${(entry.verbs as string[]).join(\",\")}]`;\n const cfg = Object.keys(entry.config ?? {});\n console.log(\n `[connect] ${active ? \"•\" : \"○\"} ${entry.module}${scope}` +\n (cfg.length ? ` config: {${cfg.join(\", \")}}` : \"\") +\n (active ? \"\" : \" (inactive for this verb)\"),\n );\n }\n }\n const declared = (reactor as { drives?: DriveDeclaration[] } | undefined)\n ?.drives;\n const declaredDefaults =\n declared && ctx\n ? declaredDrivesToDefaults(ctx.projectRoot, declared)\n : undefined;\n const reactorRenown = (reactor as { renown?: unknown } | undefined)?.renown;\n const reactorNamespace = (reactor as { namespace?: string } | undefined)\n ?.namespace;\n base.drives = declaredDefaults\n ? {\n ...base.drives,\n defaultDrives: mergeDefaultDrives(\n declaredDefaults,\n base.drives?.defaultDrives ?? [],\n ),\n preserveStrategy: base.drives?.preserveStrategy ?? \"preserve-all\",\n }\n : base.drives;\n if (composition) base.composition = composition;\n if (reactorRenown)\n base.renown = { ...(reactorRenown as object), ...base.renown };\n if (reactorNamespace !== undefined)\n base.instance = {\n ...base.instance,\n namespace: base.instance?.namespace ?? reactorNamespace,\n } as typeof base.instance;\n const { connect } = projectReactorToConnect(reactor);\n const structural = isStructuralMultiReactor(reactor);\n if (!connect.reactor && !connect.instance && !connect.app && !structural) {\n // `base` is host.config when there is one; without, it may still carry the composition.\n return host.config !== undefined || composition ? base : undefined;\n }\n const drives = structural\n ? projectDrivesIntoConnect({\n createdDriveUrls: remoteBackendUrls(reactor),\n configuredDefaultDrives: base.drives?.defaultDrives,\n }).drives\n : base.drives;\n // When the host DECLARES backends, instance facts derive from them and win\n // over config defaults (declaring `kind: \"worker\"` is more explicit intent\n // than a scaffold's `reactorWorker: false`); without backends the P2 rule\n // stands — an explicit connect.* value wins over descriptive projection.\n const declaresBackends = Object.keys(reactor?.backends ?? {}).length > 0;\n const instance = declaresBackends\n ? {\n ...base.instance,\n ...connect.instance,\n ...(structural ? { multiReactor: true } : {}),\n }\n : { ...connect.instance, ...base.instance };\n return {\n ...base,\n reactor: { ...connect.reactor, ...base.reactor },\n instance: instance as never,\n app: { ...connect.app, ...base.app },\n ...(drives ? { drives: { ...base.drives, ...drives } } : {}),\n };\n}\n\n// The favicon was built into the dist; served, its path would mean nothing.\nfunction withoutFavicon(config: PHConnectRuntimeConfig | undefined) {\n if (config?.branding?.favicon === undefined) return config;\n const { favicon: _, ...branding } = config.branding;\n return { ...config, branding };\n}\n\nconst routesOf = (host: HostDefinition) => {\n const routes = host.runner.routes;\n return typeof routes === \"string\" || routes === false ? routes : undefined;\n};\n\nexport async function dev(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<void> {\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n await runConnectStudio(\n toStudioArgs(host),\n undefined,\n callerOverride(host, ctx, ctx.verb ?? \"dev\"),\n { routes: routesOf(host) },\n );\n}\n\n/** `run` is dev-studio until the plugin phases give hosts a production\n * runtime; `serve` (below) is the static production server. */\nexport const run = dev;\n\n/** P3.3 — `build`: the SAME service as classic `ph connect build`. */\nexport async function build(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<void> {\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n const runner = host.runner;\n const args: Partial<ConnectBuildArgs> = {\n outDir: typeof runner.outDir === \"string\" ? runner.outDir : \"dist\",\n };\n // The host's config bakes in: its title, favicon, manifest, base path and loading shell.\n await runConnectBuild(\n args as ConnectBuildArgs,\n callerOverride(host, ctx, ctx.verb ?? \"build\"),\n { routes: routesOf(host) },\n );\n}\n\n/** P3.3 — `serve`: the SAME vite preview server as classic\n * `ph connect preview` (static serve of a built Connect; run `build` first).\n * The host's connect config (including a supervising compound's projected\n * drives and the reactor projection) rides a serve override: the baked\n * powerhouse.config.json merges with it at request time, and\n * `runner.cspRegistrySync` (set by the compound's wiring) patches the baked\n * CSP's script-src for the runtime registry — together these replace the\n * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */\nexport async function serve(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<void> {\n const { runConnectPreview } = await import(\"../services/connect-preview.js\");\n const runner = host.runner;\n const args: Partial<ConnectPreviewArgs> = {\n port:\n typeof runner.port === \"number\"\n ? runner.port\n : DEFAULT_CONNECT_STUDIO_PORT,\n outDir: typeof runner.outDir === \"string\" ? runner.outDir : \"dist\",\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n cors: true,\n printUrls: true,\n bindCLIShortcuts: false,\n // Explicit IPv4 loopback (runner.host overrides): vite's default\n // \"localhost\" can bind ::1 only on Windows, and a supervising shell\n // (ph-win) probes 127.0.0.1 — the sidecar this replaces bound 127.0.0.1.\n host: typeof runner.host === \"string\" ? runner.host : \"127.0.0.1\",\n };\n const override = withoutFavicon(\n callerOverride(host, ctx, ctx.verb ?? \"serve\"),\n );\n await runConnectPreview(args as ConnectPreviewArgs, {\n connect: override,\n cspRegistrySync: runner.cspRegistrySync === true,\n });\n}\n"],"names":["z.looseObject","z.string","z.number","z.boolean","z.union","z.literal","z.array"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAa,OAAO;;;;AAKpB,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,MAAMD,OAAS,CAAC,CAAC,SAAS;EAC1B,OAAOE,QAAU,CAAC,CAAC,SAAS;EAC5B,aAAaA,QAAU,CAAC,CAAC,SAAS;EAElC,QAAQC,MAAQ,CAACH,OAAS,GAAGI,QAAU,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;EAEzD,SAASC,MAAQ,iBAAiB,CAAC,CAAC,SAAS;CAC/C,CAAC;CACD,QAAQN,YAAc,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS;CACT,SAAS,cAAc,SAAS;AAClC,CAAC;;;;AAKD,SAAS,aAAa,MAAyC;CAC7D,MAAM,SAAS,KAAK;CAWpB,OAAO;EATL,MACE,OAAO,OAAO,SAAS,WACnB,OAAO,OACP;EACN,MAAM,OAAO,gBAAgB;EAC7B,YAAY,OAAO,eAAe;EAClC,WAAW;EACX,kBAAkB;CAEV;AACZ;;;;;;;;;;;;AAaA,SAAS,yBACP,aACA,cACyB;CACzB,OAAO,aAAa,KAAK,gBAAgB;EACvC,MAAM,QAAQ,wBAAwB,aAAa,WAAW;EAC9D,IAAI,MAAM,SAAS,UACjB,OAAO;GACL,KAAK,MAAM;GACX,MAAM,MAAM;GACZ,MAAM,MAAM,QAAQ;EACtB;EAEF,OAAO;GACL,OAAO;GACP,IAAI,MAAM;GACV,MAAM,MAAM;GACZ,MAAM,MAAM,QAAQ;GACpB,G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,YAAY,WAAW,QAAQ,SAAS,KAAA;AACnE;AAEA,eAAsB,IACpB,MACA,KACe;CACf,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,iBACJ,aAAa,IAAI,GACjB,KAAA,GACA,eAAe,MAAM,KAAK,IAAI,QAAQ,KAAK,GAC3C,EAAE,QAAQ,SAAS,IAAI,EAAE,CAC3B;AACF;;;AAIA,MAAa,MAAM;;AAGnB,eAAsB,MACpB,MACA,KACe;CACf,MAAM,EAAE,oBAAoB,MAAM,OAAO;CACzC,MAAM,SAAS,KAAK;CAKpB,MAAM,gBACJ,EAJA,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS,OAIzD,GACH,eAAe,MAAM,KAAK,IAAI,QAAQ,OAAO,GAC7C,EAAE,QAAQ,SAAS,IAAI,EAAE,CAC3B;AACF;;;;;;;;;AAUA,eAAsB,MACpB,MACA,KACe;CACf,MAAM,EAAE,sBAAsB,MAAM,OAAO;CAC3C,MAAM,SAAS,KAAK;CAoBpB,MAAM,kBAAkB;EAlBtB,MACE,OAAO,OAAO,SAAS,WACnB,OAAO,OACP;EACN,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;EAC5D,MAAM,OAAO,gBAAgB;EAC7B,YAAY,OAAO,eAAe;EAClC,MAAM;EACN,WAAW;EACX,kBAAkB;EAIlB,MAAM,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO;CAK7B,GAAyB;EAClD,SAJe,eACf,eAAe,MAAM,KAAK,IAAI,QAAQ,OAAO,CAG7B;EAChB,iBAAiB,OAAO,oBAAoB;CAC9C,CAAC;AACH","debug_id":"89f11518-df5f-57f9-9d5a-04d707d8f29c"}
1
+ {"version":3,"file":"connect.mjs","sources":["../../src/runners/connect.ts"],"sourcesContent":["import {\n DEFAULT_CONNECT_OUTDIR,\n DEFAULT_CONNECT_STUDIO_PORT,\n type PHConnectCompositionEntry,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { connectConfigSchemaWith } from \"@powerhousedao/shared/connect/connect-config-schema\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\nimport {\n defineHostSchemas,\n entryActiveForVerb,\n findDeadConnectConfig,\n isStructuralMultiReactor,\n mergeDefaultDrives,\n normalizePluginEntries,\n resolveDriveDeclaration,\n type DriveDeclaration,\n projectDrivesIntoConnect,\n projectReactorToConnect,\n remoteBackendUrls,\n type ReactorConfig,\n type RunnerContext,\n type RunnerHandle,\n} from \"@powerhousedao/host-core\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport type {\n ConnectBuildArgs,\n ConnectPreviewArgs,\n ConnectStudioArgs,\n} from \"../types.js\";\n\n/**\n * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a\n * hosts/connect/host.js definition onto the SAME service the classic\n * `ph connect studio` (dev/run), `ph connect build` and `ph connect preview`\n * (serve) commands call — no forked behavior.\n */\n\nexport const kind = \"reactor\";\n\n/** The connect host: the host-core reactor host with every runner option\n * this module reads declared (strict: an unknown runner key fails), and\n * `config` typed by Connect's own zod schema (the authored `connect` block),\n * whose URL fields that name another host's outputs\n * (`drives.defaultDrives[].url`, `renown.switchboardUrl`) are token-able.\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.extend({\n runner: s.runnerBaseSchema\n .extend({\n /** Open a browser tab once listening (dev/serve). */\n openBrowser: z.boolean().optional(),\n /** Fail instead of moving to the next free port when `port` is taken. */\n strictPort: z.boolean().optional(),\n /** The Connect build output dir (`build` writes it, `serve` serves it). */\n outDir: z.string().min(1).optional(),\n /** Patch the baked CSP for the runtime registry (`serve`); a\n * compound's wiring sets it on its connect member. */\n cspRegistrySync: z.boolean().optional(),\n /** The host's routes folder, project-relative; false for none.\n * Default: hosts/connect/routes. */\n routes: z.union([z.string(), z.literal(false)]).optional(),\n })\n .strict(),\n config: connectConfigSchemaWith(s.tokenable).optional(),\n }),\n);\nexport const declaredHostSchema = schemas.declaredHostSchema;\nexport const hostSchema = schemas.hostSchema;\n\n/** What a connect host.js author writes. */\nexport type ConnectHost = z.input<typeof declaredHostSchema>;\n/** What a verb receives (defaults applied). */\nexport type ConnectHostParsed = z.output<typeof hostSchema>;\n\n/** What a started Connect (`dev`/`run`/`serve`) produces: the origin it\n * actually listens on and the app URL (origin plus base path). */\nexport const outputsSchema = z.strictObject({\n origin: z.url(),\n endpoints: z.strictObject({ connect: z.url() }),\n});\nexport type ConnectOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/ph-cli/runners/connect\": {\n host: ConnectHost;\n outputs: ConnectOutputs;\n };\n }\n}\n\n/** The slice of a vite dev/preview server a handle needs. */\ninterface ListeningServer {\n resolvedUrls: { local: string[] } | null;\n close(): Promise<void>;\n}\n\n/** A started Connect as a runner handle. vite has already listened when the\n * service returns, so `ready` is settled; the outputs carry the URL vite\n * resolved (the port it actually bound), falling back to the requested one. */\nfunction connectHandle(\n server: ListeningServer,\n requested: { host: string; port: number },\n): RunnerHandle<ConnectOutputs> {\n const fallback = `http://${requested.host}:${requested.port}/`;\n const app = server.resolvedUrls?.local[0] ?? fallback;\n let closing: Promise<void> | undefined;\n return {\n outputs: outputsSchema.parse({\n origin: new URL(app).origin,\n endpoints: { connect: app },\n }),\n ready: Promise.resolve(),\n shutdown: () => (closing ??= server.close()),\n };\n}\n\n/** The studio arg surface is wide (commonArgs + server args); the service only\n * reads a known subset, and the repo's own tests build these objects the same\n * way (Partial + cast — see connect-build.test.ts `mk()`). */\nfunction toStudioArgs(host: ConnectHostParsed): ConnectStudioArgs {\n const runner = host.runner;\n const args: Partial<ConnectStudioArgs> = {\n port: runner.port ?? DEFAULT_CONNECT_STUDIO_PORT,\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n printUrls: true,\n bindCLIShortcuts: false,\n };\n return args as ConnectStudioArgs;\n}\n\n/** Merge the reactor-block projection (protocol → connect.reactor,\n * backend kind → instance.reactorWorker, workflows → app.workflowsEnabled)\n * into the host's connect config, which rides the studio caller-override.\n * The host config wins on conflict (an explicit connect.* value is intent) —\n * EXCEPT structural multi-reactor (P4.2): declaring a remote backend next to\n * a local one IS the intent, so it beats a scaffold-default\n * instance.multiReactor: false, and the remote's drive url merges FIRST into\n * drives.defaultDrives (the first url entry is what the routing client dials). */\n/** host.js reactor.drives -> the served drives.defaultDrives shapes: locals\n * carry id/name/icon and the preferredEditor under its Connect alias `app`;\n * remotes carry their URL. */\nfunction declaredDrivesToDefaults(\n projectRoot: string,\n declarations: readonly DriveDeclaration[],\n): PHConnectDefaultDrive[] {\n return declarations.map((declaration) => {\n const drive = resolveDriveDeclaration(projectRoot, declaration);\n if (drive.kind === \"remote\") {\n return {\n url: drive.remoteUrl!,\n name: drive.name,\n icon: drive.icon ?? null,\n };\n }\n return {\n local: true as const,\n id: drive.id,\n name: drive.name,\n icon: drive.icon ?? null,\n ...(drive.preferredEditor ? { app: drive.preferredEditor } : {}),\n };\n });\n}\n\nfunction callerOverride(\n host: ConnectHostParsed,\n ctx?: RunnerContext,\n verb = \"dev\",\n): PHConnectRuntimeConfig | undefined {\n // A copy: the projection below adds served-only keys (composition, …).\n const base: PHConnectRuntimeConfig = { ...host.config };\n const reactor: ReactorConfig | undefined = host.reactor;\n\n // R3: the composition (verb-filtered, projected as DATA — the browser\n // pipeline resolves and runs the entries), declared drives, and the\n // reactor-core identity/namespace keys.\n const entries = host.runner.plugins;\n const composition: PHConnectCompositionEntry[] | undefined =\n entries === undefined\n ? undefined\n : normalizePluginEntries(entries, `hosts/${host.name}/host.js`)\n .filter((entry) => entryActiveForVerb(entry, verb))\n .map((entry) => ({ module: entry.module, config: entry.config }));\n // Entry configs arrive RESOLVED: output tokens (e.g. the workflows\n // plugin's `drive: switchboard.drives.workflows.url`) were replaced by\n // `ph run` (standalone: the producer's run record; in a compound: the\n // member's live outputs) before validateHost let this verb run.\n if (entries !== undefined) {\n // Change 2: show the composition plan on the `ph run connect` terminal.\n // The pipeline itself runs in the browser (hook execution logs to the\n // browser console); here we report WHAT will be served and for which verb.\n const all = normalizePluginEntries(entries, `hosts/${host.name}/host.js`);\n console.log(\n `[connect] composition plan (verb=${verb}): ${composition?.length ?? 0} active of ${all.length} declared`,\n );\n for (const entry of all) {\n const active = entryActiveForVerb(entry, verb);\n const scope =\n entry.verbs === \"*\" ? \"\" : ` verbs=[${entry.verbs.join(\",\")}]`;\n const cfg = Object.keys(entry.config);\n console.log(\n `[connect] ${active ? \"•\" : \"○\"} ${entry.module}${scope}` +\n (cfg.length ? ` config: {${cfg.join(\", \")}}` : \"\") +\n (active ? \"\" : \" (inactive for this verb)\"),\n );\n }\n }\n // Config a Connect plugin owns, set on the host while that plugin is not\n // composed for this verb: Connect serves the plugin-absent value instead.\n for (const warning of findDeadConnectConfig(\n host.config,\n entries,\n verb,\n `hosts/${host.name}/host.js`,\n )) {\n console.warn(warning.message);\n }\n const declared = reactor?.drives;\n const declaredDefaults =\n declared && ctx\n ? declaredDrivesToDefaults(ctx.projectRoot, declared)\n : undefined;\n const reactorRenown = reactor?.renown;\n const reactorNamespace = reactor?.namespace;\n base.drives = declaredDefaults\n ? {\n ...base.drives,\n defaultDrives: mergeDefaultDrives(\n declaredDefaults,\n base.drives?.defaultDrives ?? [],\n ),\n preserveStrategy: base.drives?.preserveStrategy ?? \"preserve-all\",\n }\n : base.drives;\n if (composition) base.composition = composition;\n if (reactorRenown) base.renown = { ...reactorRenown, ...base.renown };\n if (reactorNamespace !== undefined)\n base.instance = {\n ...base.instance,\n namespace: base.instance?.namespace ?? reactorNamespace,\n } as typeof base.instance;\n const { connect } = projectReactorToConnect(reactor);\n const structural = isStructuralMultiReactor(reactor);\n if (!connect.reactor && !connect.instance && !connect.app && !structural) {\n // `base` IS host.config when the host has one; a host without a config\n // block still carries its composition and drives (set on `base` above).\n // With none of the three, there is no override: a classic build.\n return host.config !== undefined || composition || declaredDefaults\n ? base\n : undefined;\n }\n const drives = structural\n ? projectDrivesIntoConnect({\n createdDriveUrls: remoteBackendUrls(reactor),\n configuredDefaultDrives: base.drives?.defaultDrives,\n }).drives\n : base.drives;\n // When the host DECLARES backends, instance facts derive from them and win\n // over config defaults (declaring `kind: \"worker\"` is more explicit intent\n // than a scaffold's `reactorWorker: false`); without backends the P2 rule\n // stands — an explicit connect.* value wins over descriptive projection.\n const declaresBackends = Object.keys(reactor?.backends ?? {}).length > 0;\n const instance = declaresBackends\n ? {\n ...base.instance,\n ...connect.instance,\n ...(structural ? { multiReactor: true } : {}),\n }\n : { ...connect.instance, ...base.instance };\n return {\n ...base,\n reactor: { ...connect.reactor, ...base.reactor },\n instance: instance as never,\n app: { ...connect.app, ...base.app },\n ...(drives ? { drives: { ...base.drives, ...drives } } : {}),\n };\n}\n\n/**\n * Start a server; under a supervising compound (`ctx.parent`), drop the\n * process-exiting signal listeners it installed (vite's dev and preview\n * servers exit on SIGTERM): the compound owns the exit and stops members in\n * reverse dependency order through their handles.\n */\nasync function startUnderSupervisor<T>(\n ctx: RunnerContext,\n start: () => Promise<T>,\n): Promise<T> {\n if (!ctx.parent) return start();\n const signals = [\"SIGINT\", \"SIGTERM\"] as const;\n const before = new Map(\n signals.map((signal) => [signal, new Set(process.listeners(signal))]),\n );\n try {\n return await start();\n } finally {\n for (const signal of signals) {\n for (const listener of process.listeners(signal)) {\n if (!before.get(signal)?.has(listener)) {\n process.off(signal, listener);\n }\n }\n }\n }\n}\n\n/** Fail at `ph run`, naming the plugin and key, when a composed Connect\n * plugin's entry config does not match its schema. */\nasync function validateComposition(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n const { validateConnectPluginConfigs } =\n await import(\"./connect-plugin-configs.js\");\n await validateConnectPluginConfigs(\n ctx.projectRoot,\n host.runner.plugins,\n ctx.verb,\n `hosts/${host.name}/host.js`,\n );\n}\n\n/** A project file the build resolved: the built dist has it (as icon.ico or\n * a data URI); served, its path would mean nothing. */\nfunction isBuiltImage(ref: unknown): boolean {\n const src =\n typeof ref === \"object\" && ref !== null && \"src\" in ref ? ref.src : ref;\n return typeof src === \"string\" && !isPassthroughImageRef(src);\n}\n\n// The served config keeps the build's images: the favicon and any branding\n// image given as a project path were resolved into the dist, and merged over\n// it a path would replace the built data URI with a URL that 404s.\nexport function withoutBuiltImages(config: PHConnectRuntimeConfig | undefined) {\n const branding = config?.branding;\n if (!branding) return config;\n const { favicon: _, ...served } = branding;\n if (isBuiltImage(served.icon)) delete served.icon;\n if (isBuiltImage(served.loader)) delete served.loader;\n return { ...config, branding: served };\n}\n\n// Per host: Studio and other hosts' dev servers run side by side in one project.\nconst viteCacheOf = (host: ConnectHostParsed, ctx: RunnerContext) =>\n join(\n ctx.projectRoot,\n \"node_modules\",\n `.vite-${host.name.replace(/[^\\w.-]/g, \"_\")}`,\n );\n\nexport async function dev(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n const args = toStudioArgs(host);\n const server = await startUnderSupervisor(ctx, () =>\n runConnectStudio(args, undefined, callerOverride(host, ctx, ctx.verb), {\n routes: host.runner.routes,\n cacheDir: viteCacheOf(host, ctx),\n }),\n );\n // vite's dev server binds its default host (\"localhost\") here.\n return connectHandle(server, { host: \"localhost\", port: args.port });\n}\n\n/** `run` is dev-studio until the plugin phases give hosts a production\n * runtime; `serve` (below) is the static production server. */\nexport const run = dev;\n\n/** P3.3 — `build`: the SAME service as classic `ph connect build`. */\nexport async function build(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await validateComposition(host, ctx);\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n const args: Partial<ConnectBuildArgs> = {\n // Classic `ph connect`'s default: `dist/` is the package `ph build` writes.\n outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n };\n // The host's config bakes in: its title, favicon, manifest, base path and loading shell.\n await runConnectBuild(\n args as ConnectBuildArgs,\n callerOverride(host, ctx, ctx.verb),\n { routes: host.runner.routes },\n );\n}\n\n/** P3.3 — `serve`: the SAME vite preview server as classic\n * `ph connect preview` (static serve of a built Connect; run `build` first).\n * The host's connect config (including a supervising compound's projected\n * drives and the reactor projection) rides a serve override: the baked\n * powerhouse.config.json merges with it at request time, and\n * `runner.cspRegistrySync` (set by the compound's wiring) patches the baked\n * CSP's script-src for the runtime registry — together these replace the\n * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */\nexport async function serve(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectPreview } = await import(\"../services/connect-preview.js\");\n const runner = host.runner;\n const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;\n const bind = runner.host ?? \"127.0.0.1\";\n const args: Partial<ConnectPreviewArgs> = {\n port,\n outDir: runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n cors: true,\n printUrls: true,\n bindCLIShortcuts: false,\n // Explicit IPv4 loopback (runner.host overrides): vite's default\n // \"localhost\" can bind ::1 only on Windows, and a supervising shell\n // (ph-win) probes 127.0.0.1 — the sidecar this replaces bound 127.0.0.1.\n host: bind,\n };\n const override = withoutBuiltImages(callerOverride(host, ctx, ctx.verb));\n const server = await startUnderSupervisor(ctx, () =>\n runConnectPreview(args as ConnectPreviewArgs, {\n connect: override,\n cspRegistrySync: runner.cspRegistrySync === true,\n }),\n );\n return connectHandle(server, { host: bind, port });\n}\n"],"names":["z.boolean","z.string","z.union","z.literal","z.strictObject","z.url"],"mappings":";;;;;;;;;;;;;;;;AAwCA,MAAa,OAAO;;;;;;;;;AAUpB,MAAM,UAAU,mBAAmB,MACjC,EAAE,kBAAkB,OAAO;CACzB,QAAQ,EAAE,iBACP,OAAO;;E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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";
1
+ import { C as ZodUnknown, E as $strict, S as ZodUnion, T as $loose, _ as ZodObject, a as RunnerContext, b as ZodString, c as external_d_exports, d as ZodArray, f as ZodBoolean, g as ZodNumber, l as input, m as ZodLiteral, n as EnvToken, o as RunnerHandle, p as ZodEnum, s as TokenableSchema, u as output, v as ZodOptional, w as output$1, x as ZodURL, y as ZodRecord } from "../index-BIbx17vt.mjs";
2
2
  import { ParsedCmdResult } from "@powerhousedao/shared/clis";
3
3
  //#region src/commands/switchboard.d.ts
4
4
  declare const switchboard: Partial<import("cmd-ts/dist/cjs/argparser.js").Register> & {
@@ -60,24 +60,123 @@ type SwitchboardArgs = ParsedCmdResult<typeof switchboard>;
60
60
  * hosts/switchboard/host.js definition onto the SAME `startSwitchboard`
61
61
  * service the classic command calls. `run` = production loaders, `dev` =
62
62
  * Vite package loader (worker pools refused by the server, as always).
63
- * There is deliberately no `build` verb — the switchboard has none.
64
63
  */
65
64
  export declare const kind = "reactor";
66
- /** Phase-2 schema (D2.d): `reactor`/`profile` strict via host-core. */
67
- export declare const hostSchema: ZodObject<{
65
+ export declare const declaredHostSchema: ZodObject<{
68
66
  name: ZodString;
67
+ profile: ZodOptional<ZodObject<{
68
+ appId: ZodOptional<ZodString>;
69
+ name: ZodOptional<ZodString>;
70
+ description: ZodOptional<ZodString>;
71
+ icon: ZodOptional<ZodString>;
72
+ }, $strict>>;
73
+ reactor: ZodOptional<ZodObject<{
74
+ backends: ZodOptional<ZodRecord<ZodString, ZodObject<{
75
+ kind: ZodEnum<{
76
+ "in-process": "in-process";
77
+ remote: "remote";
78
+ worker: "worker";
79
+ }>;
80
+ storage: ZodOptional<ZodObject<{
81
+ kind: ZodEnum<{
82
+ idb: "idb";
83
+ memory: "memory";
84
+ path: "path";
85
+ postgres: "postgres";
86
+ }>;
87
+ dataDir: ZodOptional<TokenableSchema<ZodString, EnvToken>>;
88
+ url: ZodOptional<ZodString>;
89
+ }, $strict>>;
90
+ readModel: ZodOptional<ZodObject<{
91
+ url: ZodOptional<ZodString>;
92
+ }, $strict>>;
93
+ packages: ZodOptional<ZodObject<{
94
+ cdnUrl: ZodOptional<ZodString>;
95
+ specs: ZodOptional<ZodArray<ZodString>>;
96
+ dynamic: ZodOptional<ZodBoolean>;
97
+ }, $strict>>;
98
+ remote: ZodOptional<ZodObject<{
99
+ url: TokenableSchema<ZodURL>;
100
+ }, $strict>>;
101
+ projection: ZodOptional<ZodObject<{
102
+ enabled: ZodOptional<ZodBoolean>;
103
+ dbPoolSize: ZodOptional<ZodNumber>;
104
+ }, $strict>>;
105
+ executors: ZodOptional<ZodObject<{
106
+ numWorkers: ZodOptional<ZodUnion<readonly [ZodNumber, ZodLiteral<"auto">]>>;
107
+ }, $strict>>;
108
+ }, $strict>>>;
109
+ placement: ZodOptional<ZodObject<{
110
+ primary: ZodOptional<ZodString>;
111
+ default: ZodOptional<ZodObject<{}, $loose>>;
112
+ }, $strict>>;
113
+ protocol: ZodOptional<ZodObject<{
114
+ featureFlags: ZodOptional<ZodObject<{
115
+ documentDecisions: ZodOptional<ZodBoolean>;
116
+ authEnforcement: ZodOptional<ZodBoolean>;
117
+ authGroups: ZodOptional<ZodBoolean>;
118
+ authConditions: ZodOptional<ZodBoolean>;
119
+ }, $strict>>;
120
+ createSignaturePolicy: ZodOptional<ZodEnum<{
121
+ legacy: "legacy";
122
+ "v2-required": "v2-required";
123
+ }>>;
124
+ unsupportedStoredDocuments: ZodOptional<ZodEnum<{
125
+ "read-only": "read-only";
126
+ refuse: "refuse";
127
+ }>>;
128
+ }, $strict>>;
129
+ workflows: ZodOptional<ZodBoolean>;
130
+ renown: ZodOptional<ZodObject<{
131
+ url: ZodOptional<ZodString>;
132
+ networkId: ZodOptional<ZodString>;
133
+ chainId: ZodOptional<ZodNumber>;
134
+ }, $strict>>;
135
+ packages: ZodOptional<ZodObject<{
136
+ registryUrl: ZodOptional<ZodString>;
137
+ }, $strict>>;
138
+ namespace: ZodOptional<ZodString>;
139
+ auth: ZodOptional<ZodObject<{
140
+ enabled: ZodOptional<ZodBoolean>;
141
+ admins: ZodOptional<ZodArray<ZodString>>;
142
+ renown: ZodOptional<ZodObject<{}, $loose>>;
143
+ }, $strict>>;
144
+ drives: ZodOptional<TokenableSchema<ZodArray<ZodObject<{
145
+ slug: ZodString;
146
+ id: ZodOptional<ZodString>;
147
+ projectHash: ZodOptional<ZodUnion<readonly [ZodBoolean, ZodLiteral<"id">]>>;
148
+ name: ZodOptional<ZodString>;
149
+ icon: ZodOptional<ZodString>;
150
+ preferredEditor: ZodOptional<ZodString>;
151
+ sharingType: ZodOptional<ZodEnum<{
152
+ private: "private";
153
+ public: "public";
154
+ shared: "shared";
155
+ }>>;
156
+ availableOffline: ZodOptional<ZodBoolean>;
157
+ remote: ZodOptional<ZodObject<{
158
+ url: TokenableSchema<ZodString>;
159
+ }, $strict>>;
160
+ }, $strict>>>>;
161
+ }, $strict>>;
69
162
  runner: ZodObject<{
70
163
  module: ZodString;
164
+ defaultVerb: ZodOptional<ZodString>;
71
165
  port: ZodOptional<ZodNumber>;
72
- https: ZodOptional<ZodBoolean>;
166
+ host: ZodOptional<ZodString>;
73
167
  plugins: ZodOptional<ZodArray<ZodUnion<readonly [ZodString, ZodObject<{
74
168
  module: ZodString;
75
169
  enabled: ZodOptional<ZodBoolean>;
76
170
  verbs: ZodOptional<ZodUnion<readonly [ZodLiteral<"*">, ZodArray<ZodString>]>>;
77
171
  config: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
78
172
  }, $strict>]>>>;
79
- }, $loose>;
80
- config: ZodOptional<ZodObject<{}, $loose>>;
173
+ dev: ZodOptional<ZodBoolean>;
174
+ outDir: ZodOptional<ZodString>;
175
+ }, $strict>;
176
+ config: ZodOptional<ZodObject<{}, $strict>>;
177
+ }, $strict>;
178
+ export declare const hostSchema: ZodObject<{
179
+ name: ZodString;
81
180
  profile: ZodOptional<ZodObject<{
82
181
  appId: ZodOptional<ZodString>;
83
182
  name: ZodOptional<ZodString>;
@@ -86,11 +185,11 @@ export declare const hostSchema: ZodObject<{
86
185
  }, $strict>>;
87
186
  reactor: ZodOptional<ZodObject<{
88
187
  backends: ZodOptional<ZodRecord<ZodString, ZodObject<{
89
- kind: ZodOptional<ZodEnum<{
188
+ kind: ZodEnum<{
90
189
  "in-process": "in-process";
91
190
  remote: "remote";
92
191
  worker: "worker";
93
- }>>;
192
+ }>;
94
193
  storage: ZodOptional<ZodObject<{
95
194
  kind: ZodEnum<{
96
195
  idb: "idb";
@@ -98,7 +197,7 @@ export declare const hostSchema: ZodObject<{
98
197
  path: "path";
99
198
  postgres: "postgres";
100
199
  }>;
101
- dataDir: ZodOptional<ZodString>;
200
+ dataDir: ZodOptional<TokenableSchema<ZodString, EnvToken>>;
102
201
  url: ZodOptional<ZodString>;
103
202
  }, $strict>>;
104
203
  readModel: ZodOptional<ZodObject<{
@@ -110,8 +209,7 @@ export declare const hostSchema: ZodObject<{
110
209
  dynamic: ZodOptional<ZodBoolean>;
111
210
  }, $strict>>;
112
211
  remote: ZodOptional<ZodObject<{
113
- host: ZodOptional<ZodString>;
114
- url: ZodOptional<ZodString>;
212
+ url: TokenableSchema<ZodURL>;
115
213
  }, $strict>>;
116
214
  projection: ZodOptional<ZodObject<{
117
215
  enabled: ZodOptional<ZodBoolean>;
@@ -156,10 +254,10 @@ export declare const hostSchema: ZodObject<{
156
254
  admins: ZodOptional<ZodArray<ZodString>>;
157
255
  renown: ZodOptional<ZodObject<{}, $loose>>;
158
256
  }, $strict>>;
159
- drives: ZodOptional<ZodArray<ZodObject<{
257
+ drives: ZodOptional<TokenableSchema<ZodArray<ZodObject<{
160
258
  slug: ZodString;
161
259
  id: ZodOptional<ZodString>;
162
- projectHash: ZodOptional<ZodBoolean>;
260
+ projectHash: ZodOptional<ZodUnion<readonly [ZodBoolean, ZodLiteral<"id">]>>;
163
261
  name: ZodOptional<ZodString>;
164
262
  icon: ZodOptional<ZodString>;
165
263
  preferredEditor: ZodOptional<ZodString>;
@@ -170,29 +268,73 @@ export declare const hostSchema: ZodObject<{
170
268
  }>>;
171
269
  availableOffline: ZodOptional<ZodBoolean>;
172
270
  remote: ZodOptional<ZodObject<{
173
- url: ZodString;
271
+ url: TokenableSchema<ZodString>;
174
272
  }, $strict>>;
175
- }, $strict>>>;
273
+ }, $strict>>>>;
176
274
  }, $strict>>;
177
- }, $loose>;
275
+ runner: ZodObject<{
276
+ module: ZodString;
277
+ defaultVerb: ZodOptional<ZodString>;
278
+ port: ZodOptional<ZodNumber>;
279
+ host: ZodOptional<ZodString>;
280
+ plugins: ZodOptional<ZodArray<ZodUnion<readonly [ZodString, ZodObject<{
281
+ module: ZodString;
282
+ enabled: ZodOptional<ZodBoolean>;
283
+ verbs: ZodOptional<ZodUnion<readonly [ZodLiteral<"*">, ZodArray<ZodString>]>>;
284
+ config: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
285
+ }, $strict>]>>>;
286
+ dev: ZodOptional<ZodBoolean>;
287
+ outDir: ZodOptional<ZodString>;
288
+ }, $strict>;
289
+ config: ZodOptional<ZodObject<{}, $strict>>;
290
+ }, $strict>;
291
+ /** What a switchboard host.js author writes. */
292
+ export type SwitchboardHost = input<typeof declaredHostSchema>;
293
+ /** What a verb receives (defaults applied). */
294
+ export type SwitchboardHostParsed = output<typeof hostSchema>;
295
+ /** One drive the switchboard serves: its document id and its URL. */
296
+ export declare const switchboardDriveOutputSchema: ZodObject<{
297
+ id: ZodString;
298
+ url: ZodURL;
299
+ }, $strict>;
300
+ /** What a started switchboard produces. `origin` carries the port the server
301
+ * actually bound. `drives` is keyed by the DECLARED slug (a `projectHash:
302
+ * true` drive is reachable as `vetra`, its URL uses the hashed slug it is
303
+ * served under) and includes plugin-created drives (e.g. `workflows`) and
304
+ * the server's implicit default drive. `endpoints.mcp` is present when MCP
305
+ * is mounted. */
306
+ export declare const outputsSchema: ZodObject<{
307
+ origin: ZodURL;
308
+ endpoints: ZodObject<{
309
+ graphql: ZodURL;
310
+ mcp: ZodOptional<ZodURL>;
311
+ }, $strict>;
312
+ drives: ZodRecord<ZodString, ZodObject<{
313
+ id: ZodString;
314
+ url: ZodURL;
315
+ }, $strict>>;
316
+ }, $strict>;
317
+ export type SwitchboardOutputs = output$1<typeof outputsSchema>;
318
+ declare global {
319
+ interface PHHostRunners {
320
+ "@powerhousedao/ph-cli/runners/switchboard": {
321
+ host: SwitchboardHost;
322
+ outputs: SwitchboardOutputs;
323
+ };
324
+ }
325
+ }
178
326
  /** The classic arg shape with the one switch a composition may leave unset. */
179
327
  export type SwitchboardRunnerArgs = Omit<SwitchboardArgs, "mcp"> & {
180
328
  mcp: boolean | undefined;
181
329
  };
182
- /** What a started switchboard reports to a supervising compound: its port and
183
- * the drive it serves (projected into a connect member's defaultDrives). */
184
- export interface SwitchboardHandle {
185
- port: number;
186
- driveUrls: string[];
187
- endpoints: Record<string, string>;
188
- ready: Promise<void>;
189
- }
190
- export declare function run(host: HostDefinition, ctx: RunnerContext): Promise<SwitchboardHandle>;
330
+ /** What a started switchboard returns. */
331
+ export type SwitchboardHandle = RunnerHandle<SwitchboardOutputs>;
332
+ export declare function run(host: SwitchboardHostParsed, ctx: RunnerContext): Promise<SwitchboardHandle>;
191
333
  export declare const serve: typeof run;
192
- export declare function dev(host: HostDefinition, ctx: RunnerContext): Promise<SwitchboardHandle>;
334
+ export declare function dev(host: SwitchboardHostParsed, ctx: RunnerContext): Promise<SwitchboardHandle>;
193
335
  /** Build the project's reactor package (the SAME service as `ph build`) — what
194
336
  * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
195
- export declare function build(host: HostDefinition, _ctx: RunnerContext): Promise<void>;
337
+ export declare function build(host: SwitchboardHostParsed, _ctx: RunnerContext): Promise<void>;
196
338
  //#endregion
197
339
  export {};
198
340
  //# sourceMappingURL=switchboard.d.mts.map
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
+ {"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;;;;;;;;;qBCrCxC;qBAqBA,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6B;qBAC/C,YAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;YAwHU,oBAAoB,aAAa;wBAoNvB,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;qBAIE,cAAK;wBAEI,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;;;wBAMW,MACpB,MAAM,uBACN,MAAM,gBACL"}