@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.
- package/dist/{cli-connect-override-Cf7WutqU.mjs → cli-connect-override-CEJhQWRX.mjs} +5 -5
- package/dist/cli-connect-override-CEJhQWRX.mjs.map +1 -0
- package/dist/cli.mjs +4 -4
- package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs +2459 -0
- package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs.map +1 -0
- package/dist/{connect-build-BtKpvcQK.mjs → connect-build-BfhOGbha.mjs} +4 -4
- package/dist/{connect-build-BtKpvcQK.mjs.map → connect-build-BfhOGbha.mjs.map} +1 -1
- package/dist/{connect-config-9EZB_0H_.mjs → connect-config-DblqJgxR.mjs} +4 -4
- package/dist/{connect-config-9EZB_0H_.mjs.map → connect-config-DblqJgxR.mjs.map} +1 -1
- package/dist/connect-plugin-configs-D2fwYpMw.mjs +50 -0
- package/dist/connect-plugin-configs-D2fwYpMw.mjs.map +1 -0
- package/dist/{connect-studio-Bhlc77WI.mjs → connect-studio-B1_4TNEb.mjs} +8 -6
- package/dist/connect-studio-B1_4TNEb.mjs.map +1 -0
- package/dist/{connect-studio-BehPZzN7.mjs → connect-studio-BS26pchr.mjs} +3 -3
- package/dist/{dist-BqeDFgEy.mjs → dist-CCLkwpTS.mjs} +199 -109
- package/dist/dist-CCLkwpTS.mjs.map +1 -0
- package/dist/explain-DUXbB9jf.mjs +241 -0
- package/dist/explain-DUXbB9jf.mjs.map +1 -0
- package/dist/{generate-all-C_sPGBuk.mjs → generate-all-Dgyy_kT-.mjs} +7 -3
- package/dist/generate-all-Dgyy_kT-.mjs.map +1 -0
- package/dist/{generate-desktop-shell-BBSGpmud.mjs → generate-desktop-shell-BdXDiS5o.mjs} +113 -7
- package/dist/generate-desktop-shell-BdXDiS5o.mjs.map +1 -0
- package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
- package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
- package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
- package/dist/{index-CspiP73o.d.mts → index-BIbx17vt.d.mts} +178 -14
- package/dist/index-BIbx17vt.d.mts.map +1 -0
- package/dist/{ph-cli-commands-3ptdQ0NI.mjs → ph-cli-commands-DSAhaETu.mjs} +156 -139
- package/dist/ph-cli-commands-DSAhaETu.mjs.map +1 -0
- package/dist/ph-cli-commands-d5XjMWW0.mjs +4 -0
- package/dist/{run-sugar-BdjKTPGO.mjs → run-sugar-Ns53R6lU.mjs} +4 -4
- package/dist/{run-sugar-BdjKTPGO.mjs.map → run-sugar-Ns53R6lU.mjs.map} +1 -1
- package/dist/runners/connect.d.mts +1054 -26
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +127 -50
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +170 -28
- package/dist/runners/switchboard.d.mts.map +1 -1
- package/dist/runners/switchboard.mjs +171 -49
- package/dist/runners/switchboard.mjs.map +1 -1
- package/dist/{schemas-BQSPev1x.mjs → schemas-D5N5U_Mf.mjs} +205 -4
- package/dist/{schemas-BQSPev1x.mjs.map → schemas-D5N5U_Mf.mjs.map} +1 -1
- package/dist/scripts/emit-runner-schemas.ts +24 -0
- package/dist/start-run-BIaYSpHh.mjs +124 -0
- package/dist/start-run-BIaYSpHh.mjs.map +1 -0
- package/dist/{superseded-config-9D7BdLvd.mjs → superseded-config-CbSTFun2.mjs} +4 -4
- package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
- package/dist/switchboard-h4-XgP1h.mjs +2 -2
- package/dist/switchboard-h4-XgP1h.mjs.map +1 -1
- package/dist/utils-DAux4Ga7.mjs +4 -0
- package/dist/{vetra-BD-34wGs.mjs → vetra-UQsfYM_Q.mjs} +10 -10
- package/dist/vetra-UQsfYM_Q.mjs.map +1 -0
- package/package.json +15 -20
- package/dist/cli-connect-override-Cf7WutqU.mjs.map +0 -1
- package/dist/connect-studio-Bhlc77WI.mjs.map +0 -1
- package/dist/dist-BqeDFgEy.mjs.map +0 -1
- package/dist/explain-BDHmXgw3.mjs +0 -27
- package/dist/explain-BDHmXgw3.mjs.map +0 -1
- package/dist/generate-all-C_sPGBuk.mjs.map +0 -1
- package/dist/generate-desktop-shell-BBSGpmud.mjs.map +0 -1
- package/dist/host-schemas-CtPNRr5v-BQyKKFbS.mjs +0 -493
- package/dist/host-schemas-CtPNRr5v-BQyKKFbS.mjs.map +0 -1
- package/dist/index-CspiP73o.d.mts.map +0 -1
- package/dist/ph-cli-commands-3ptdQ0NI.mjs.map +0 -1
- package/dist/ph-cli-commands-Dx8hNj6W.mjs +0 -4
- package/dist/plugins-CHVv4qup.mjs +0 -91
- package/dist/plugins-CHVv4qup.mjs.map +0 -1
- package/dist/reactor-env-BbR86_Li.mjs +0 -29
- package/dist/reactor-env-BbR86_Li.mjs.map +0 -1
- package/dist/reactor-env-D_EvBtLB.mjs +0 -4
- package/dist/runners/compound.d.mts +0 -127
- package/dist/runners/compound.d.mts.map +0 -1
- package/dist/runners/compound.mjs +0 -72
- package/dist/runners/compound.mjs.map +0 -1
- package/dist/start-run-CmDxyMw0.mjs +0 -36
- package/dist/start-run-CmDxyMw0.mjs.map +0 -1
- package/dist/superseded-config-9D7BdLvd.mjs.map +0 -1
- package/dist/utils-TO9lB8Xs.mjs +0 -4
- package/dist/vetra-BD-34wGs.mjs.map +0 -1
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { s as resolveHostPlugins } from "../dist-BqeDFgEy.mjs";
|
|
7
|
-
import { t as applyReactorEnvProjection } from "../reactor-env-BbR86_Li.mjs";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8604c920-467f-5ac7-b870-1d3fd5a160e6")}catch(e){}}();
|
|
3
|
+
import { c as strictObject, f as url, l as string$1, m as prettifyError, r as boolean$1, s as record } from "../schemas-D5N5U_Mf.mjs";
|
|
4
|
+
import { P as resolveHostPlugins, c as defineHostSchemas, u as drivesSchema } from "../compound-B6RZMA0Y-Cv3XMQ3Y.mjs";
|
|
5
|
+
import { a as mergeDrivePlan, f as resolveDriveDeclaration, l as projectReactorToSwitchboard, o as primaryBackend, p as seedDrives, t as assertProtocolConsistency } from "../dist-CCLkwpTS.mjs";
|
|
8
6
|
import { command, runSafely } from "cmd-ts";
|
|
9
7
|
import { switchboardArgs } from "@powerhousedao/shared/clis/args";
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
//#region src/runners/reactor-env.ts
|
|
10
|
+
/**
|
|
11
|
+
* Apply a host's reactor block to the CURRENT process env, the way the
|
|
12
|
+
* in-process switchboard server reads it at boot (D2.c: env derivation
|
|
13
|
+
* immediately before the member starts; sequential boots make this safe).
|
|
14
|
+
* Single-sourcing teeth first: a pre-set env contradicting the protocol block
|
|
15
|
+
* fails loudly. Then set-if-absent, so an operator's explicit (agreeing) env
|
|
16
|
+
* still wins during the transition. Returns the non-env options (dbPath).
|
|
17
|
+
*
|
|
18
|
+
* Lives OUTSIDE the runner modules on purpose: every export of a runner
|
|
19
|
+
* module reads as a dispatchable verb, and this is not one.
|
|
20
|
+
*/
|
|
21
|
+
function applyReactorEnvProjection(reactor, hostFileLabel) {
|
|
22
|
+
const { env, options } = projectReactorToSwitchboard(reactor);
|
|
23
|
+
assertProtocolConsistency(reactor?.protocol, process.env, hostFileLabel);
|
|
24
|
+
for (const [name, value] of Object.entries(env)) if (process.env[name] === void 0) process.env[name] = value;
|
|
25
|
+
const storage = primaryBackend(reactor)?.storage;
|
|
26
|
+
if (storage?.kind === "path" && storage.dataDir) {
|
|
27
|
+
if (/\$\{(userData|projectRoot)\}/.test(storage.dataDir)) throw new Error(`${hostFileLabel}: storage.dataDir "${storage.dataDir}" was not resolved; resolve the host (resolveHostOutputs) before starting it.`);
|
|
28
|
+
fs.mkdirSync(storage.dataDir, { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
return options;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
10
33
|
//#region src/services/classic-args.ts
|
|
11
34
|
/**
|
|
12
35
|
* The classic `ph switchboard` argument shape, produced by the SAME cmd-ts
|
|
@@ -36,21 +59,43 @@ async function classicSwitchboardArgs(argv = []) {
|
|
|
36
59
|
* hosts/switchboard/host.js definition onto the SAME `startSwitchboard`
|
|
37
60
|
* service the classic command calls. `run` = production loaders, `dev` =
|
|
38
61
|
* Vite package loader (worker pools refused by the server, as always).
|
|
39
|
-
* There is deliberately no `build` verb — the switchboard has none.
|
|
40
62
|
*/
|
|
41
63
|
const kind = "reactor";
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
/** The switchboard host: the host-core reactor host with every runner option
|
|
65
|
+
* this module reads declared (strict: an unknown runner key fails). The
|
|
66
|
+
* runner reads nothing from `config`, so only an empty one is accepted.
|
|
67
|
+
* One definition, two schemas: `declaredHostSchema` (token-able fields take
|
|
68
|
+
* output tokens; types host files) and `hostSchema` (resolved; checked
|
|
69
|
+
* right before the verb). */
|
|
70
|
+
const schemas = defineHostSchemas((s) => s.reactorHostSchema.extend({
|
|
71
|
+
runner: s.runnerBaseSchema.extend({
|
|
72
|
+
/** Dev mode without the `dev` verb (the Vite package loader). */
|
|
73
|
+
dev: boolean$1().optional(),
|
|
74
|
+
/** The project package output dir `build` writes (default "dist"). */
|
|
75
|
+
outDir: string$1().min(1).optional()
|
|
76
|
+
}).strict(),
|
|
77
|
+
config: strictObject({}).optional()
|
|
78
|
+
}));
|
|
79
|
+
const declaredHostSchema = schemas.declaredHostSchema;
|
|
80
|
+
const hostSchema = schemas.hostSchema;
|
|
81
|
+
/** One drive the switchboard serves: its document id and its URL. */
|
|
82
|
+
const switchboardDriveOutputSchema = strictObject({
|
|
83
|
+
id: string$1().min(1),
|
|
84
|
+
url: url()
|
|
85
|
+
});
|
|
86
|
+
/** What a started switchboard produces. `origin` carries the port the server
|
|
87
|
+
* actually bound. `drives` is keyed by the DECLARED slug (a `projectHash:
|
|
88
|
+
* true` drive is reachable as `vetra`, its URL uses the hashed slug it is
|
|
89
|
+
* served under) and includes plugin-created drives (e.g. `workflows`) and
|
|
90
|
+
* the server's implicit default drive. `endpoints.mcp` is present when MCP
|
|
91
|
+
* is mounted. */
|
|
92
|
+
const outputsSchema = strictObject({
|
|
93
|
+
origin: url(),
|
|
94
|
+
endpoints: strictObject({
|
|
95
|
+
graphql: url(),
|
|
96
|
+
mcp: url().optional()
|
|
50
97
|
}),
|
|
51
|
-
|
|
52
|
-
profile: profileSchema,
|
|
53
|
-
reactor: reactorSchema.optional()
|
|
98
|
+
drives: record(string$1(), switchboardDriveOutputSchema)
|
|
54
99
|
});
|
|
55
100
|
/**
|
|
56
101
|
* Start from the classic `ph switchboard` args (parsed by the classic
|
|
@@ -64,15 +109,46 @@ async function toSwitchboardArgs(host, devMode, dbPath, composed) {
|
|
|
64
109
|
const runner = host.runner;
|
|
65
110
|
return {
|
|
66
111
|
...classic,
|
|
67
|
-
port:
|
|
112
|
+
port: runner.port ?? classic.port,
|
|
68
113
|
dev: devMode || runner.dev === true ? true : classic.dev,
|
|
69
114
|
mcp: composed ? void 0 : classic.mcp,
|
|
70
115
|
dbPath: dbPath ?? classic.dbPath
|
|
71
116
|
};
|
|
72
117
|
}
|
|
73
|
-
/** The
|
|
74
|
-
* (
|
|
118
|
+
/** The drive the switchboard service creates by default
|
|
119
|
+
* (services/switchboard.ts `defaultSwitchboardOptions.drive`). */
|
|
75
120
|
const DEFAULT_DRIVE_SLUG = "powerhouse";
|
|
121
|
+
/** The `<slug>` of the server-reported `…/d/<slug>` default drive URL. */
|
|
122
|
+
function defaultDriveSlug(url) {
|
|
123
|
+
const match = url ? /\/d\/([^/?#]+)\/?$/.exec(url) : null;
|
|
124
|
+
return match ? decodeURIComponent(match[1]) : DEFAULT_DRIVE_SLUG;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The drives the composition's plugins contribute, resolved and in plan
|
|
128
|
+
* order, minus the slugs the host declares itself (mergeDrivePlan: the host
|
|
129
|
+
* file wins). A contribution that is not a valid drive declaration fails the
|
|
130
|
+
* boot naming the plugin.
|
|
131
|
+
*/
|
|
132
|
+
function pluginDrives(projectRoot, hostDrives, composition, where) {
|
|
133
|
+
if (!composition) return [];
|
|
134
|
+
const contributed = composition.flatMap((resolved) => {
|
|
135
|
+
const drives = resolved.plugin.contributions?.drives ?? [];
|
|
136
|
+
if (drives.length === 0) return [];
|
|
137
|
+
const parsed = drivesSchema.safeParse(drives);
|
|
138
|
+
if (!parsed.success) throw new Error(`${where}: plugin "${resolved.plugin.name}" contributes an invalid drive declaration:\n${prettifyError(parsed.error)}`);
|
|
139
|
+
return parsed.data.map((declaration) => ({
|
|
140
|
+
declaration,
|
|
141
|
+
source: resolved.plugin.name
|
|
142
|
+
}));
|
|
143
|
+
});
|
|
144
|
+
if (contributed.length === 0) return [];
|
|
145
|
+
const declaredSlugs = new Map(contributed.map(({ declaration }) => [resolveDriveDeclaration(projectRoot, declaration).slug, declaration.slug]));
|
|
146
|
+
const hostSlugs = new Set(hostDrives.map((d) => d.drive.slug));
|
|
147
|
+
return mergeDrivePlan(projectRoot, [], contributed).map((entry) => entry.drive).filter((drive) => !hostSlugs.has(drive.slug)).map((drive) => ({
|
|
148
|
+
declaredSlug: declaredSlugs.get(drive.slug) ?? drive.slug,
|
|
149
|
+
drive
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
76
152
|
/** Poll the default drive endpoint until the server answers — the compound's
|
|
77
153
|
* readiness gate: Connect auto-connects the drive on first load, so the drive
|
|
78
154
|
* must answer before the connect member serves (the sidecar's
|
|
@@ -87,12 +163,28 @@ async function waitForDrive(url, timeoutMs) {
|
|
|
87
163
|
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
88
164
|
}
|
|
89
165
|
}
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Adapter from the switchboard's reactor client onto the host-core seeder.
|
|
168
|
+
* Seeding is SLUG-keyed: a live drive that already serves the slug — under
|
|
169
|
+
* whatever id (a store from a run that hashed the project path differently,
|
|
170
|
+
* or a hand-made drive) — is the drive, and nothing is created. addDefaultDrive
|
|
171
|
+
* alone only knows ids: with a different id it would try to create a second
|
|
172
|
+
* drive for the slug, and against a deleted document with that id the create
|
|
173
|
+
* fails on every boot.
|
|
174
|
+
*/
|
|
175
|
+
function seederClient(reactor, port, seededIds) {
|
|
93
176
|
return {
|
|
94
|
-
findDriveBySlug: () =>
|
|
177
|
+
findDriveBySlug: async (slug) => {
|
|
178
|
+
try {
|
|
179
|
+
const id = await reactor.resolveIdOrSlug(slug);
|
|
180
|
+
if (id) seededIds.set(slug, id);
|
|
181
|
+
return id || void 0;
|
|
182
|
+
} catch {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
95
186
|
createDrive: async (drive) => {
|
|
187
|
+
seededIds.set(drive.slug, drive.id);
|
|
96
188
|
const { addDefaultDrive } = await import("@powerhousedao/switchboard/utils");
|
|
97
189
|
await addDefaultDrive(reactor, {
|
|
98
190
|
id: drive.id,
|
|
@@ -116,39 +208,70 @@ function seederClient(reactor, port) {
|
|
|
116
208
|
async function start(host, ctx, devMode) {
|
|
117
209
|
const options = applyReactorEnvProjection(host.reactor, `hosts/${host.name}/host.js`);
|
|
118
210
|
const { startSwitchboard } = await import("../switchboard-C5zgkRl2.mjs");
|
|
119
|
-
const entriesDeclared = host.runner.plugins !== void 0;
|
|
120
|
-
const args = await toSwitchboardArgs(host, devMode, options.dbPath, entriesDeclared);
|
|
121
211
|
const entries = host.runner.plugins;
|
|
212
|
+
const entriesDeclared = entries !== void 0;
|
|
213
|
+
const args = await toSwitchboardArgs(host, devMode, options.dbPath, entriesDeclared);
|
|
122
214
|
let pluginComposition;
|
|
123
215
|
if (entries !== void 0) {
|
|
124
216
|
process.env.FEATURE_PLUGIN_HOST_ENABLED = "1";
|
|
125
|
-
pluginComposition = await resolveHostPlugins(ctx.projectRoot, "switchboard", ctx.verb
|
|
217
|
+
pluginComposition = await resolveHostPlugins(ctx.projectRoot, "switchboard", ctx.verb, entries, `hosts/${host.name}/host.js`);
|
|
126
218
|
}
|
|
127
|
-
const
|
|
219
|
+
const hostDrives = (host.reactor?.drives ?? []).map((declaration) => ({
|
|
220
|
+
declaredSlug: declaration.slug,
|
|
221
|
+
drive: resolveDriveDeclaration(ctx.projectRoot, declaration)
|
|
222
|
+
}));
|
|
223
|
+
const contributedDrives = pluginDrives(ctx.projectRoot, hostDrives, pluginComposition, `hosts/${host.name}/host.js`);
|
|
224
|
+
const planned = [...hostDrives, ...contributedDrives];
|
|
225
|
+
const remoteDrives = planned.map((p) => p.drive).flatMap((d) => d.kind === "remote" && d.remoteUrl ? [d.remoteUrl] : []);
|
|
128
226
|
const switchboard = await startSwitchboard({
|
|
129
227
|
...args,
|
|
130
228
|
...pluginComposition ? { pluginComposition } : {},
|
|
131
|
-
...
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
} : {}
|
|
229
|
+
...hostDrives.length > 0 ? { drive: void 0 } : {},
|
|
230
|
+
...remoteDrives.length > 0 ? { remoteDrives } : {},
|
|
231
|
+
...ctx.parent ? { signalHandlers: false } : {}
|
|
135
232
|
});
|
|
136
|
-
const port =
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
if (switchboard
|
|
142
|
-
|
|
143
|
-
|
|
233
|
+
const port = switchboard.port;
|
|
234
|
+
const origin = `http://localhost:${port}`;
|
|
235
|
+
const driveUrlOf = (slug) => `${origin}/d/${slug}`;
|
|
236
|
+
const seededIds = /* @__PURE__ */ new Map();
|
|
237
|
+
const localPlanned = planned.filter((p) => p.drive.kind === "local");
|
|
238
|
+
if (localPlanned.length > 0) await seedDrives(seederClient(switchboard.reactor, port, seededIds), localPlanned.map((p) => p.drive));
|
|
239
|
+
const drives = {};
|
|
240
|
+
const localHostDrives = hostDrives.filter((d) => d.drive.kind === "local");
|
|
241
|
+
const defaultSlug = defaultDriveSlug(switchboard.defaultDriveUrl);
|
|
242
|
+
if (hostDrives.length === 0 && remoteDrives.length === 0) drives[defaultSlug] = {
|
|
243
|
+
id: defaultSlug,
|
|
244
|
+
url: driveUrlOf(defaultSlug)
|
|
245
|
+
};
|
|
246
|
+
for (const { declaredSlug, drive } of localPlanned) drives[declaredSlug] = {
|
|
247
|
+
id: seededIds.get(drive.slug) ?? drive.id,
|
|
248
|
+
url: driveUrlOf(drive.slug)
|
|
249
|
+
};
|
|
250
|
+
const driveUrl = driveUrlOf(localHostDrives.length > 0 ? localHostDrives[0].drive.slug : defaultSlug);
|
|
251
|
+
if (entries === void 0 && switchboard.workflowsEnabled) {
|
|
252
|
+
const { seedWorkflowsDrive } = await import("../vetra-UQsfYM_Q.mjs");
|
|
253
|
+
const { generateProjectDriveId } = await import("../utils-DAux4Ga7.mjs");
|
|
254
|
+
const url = await seedWorkflowsDrive(switchboard.reactor, port);
|
|
255
|
+
if (url) drives.workflows = {
|
|
256
|
+
id: generateProjectDriveId("workflows"),
|
|
257
|
+
url
|
|
258
|
+
};
|
|
144
259
|
}
|
|
145
260
|
const ready = waitForDrive(driveUrl, 18e4);
|
|
146
261
|
ready.catch(() => void 0);
|
|
262
|
+
const graphql = `${origin}/graphql`;
|
|
263
|
+
let stopping;
|
|
147
264
|
return {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
265
|
+
outputs: outputsSchema.parse({
|
|
266
|
+
origin,
|
|
267
|
+
endpoints: {
|
|
268
|
+
graphql,
|
|
269
|
+
...switchboard.mcpEnabled ? { mcp: `${origin}/mcp` } : {}
|
|
270
|
+
},
|
|
271
|
+
drives
|
|
272
|
+
}),
|
|
273
|
+
ready,
|
|
274
|
+
shutdown: () => stopping ??= switchboard.shutdown()
|
|
152
275
|
};
|
|
153
276
|
}
|
|
154
277
|
async function run(host, ctx) {
|
|
@@ -162,11 +285,10 @@ async function dev(host, ctx) {
|
|
|
162
285
|
* this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
|
|
163
286
|
async function build(host, _ctx) {
|
|
164
287
|
const { runBuild } = await import("../build-C78yPntL.mjs");
|
|
165
|
-
|
|
166
|
-
await runBuild({ outDir: typeof runner.outDir === "string" ? runner.outDir : "dist" });
|
|
288
|
+
await runBuild({ outDir: host.runner.outDir ?? "dist" });
|
|
167
289
|
}
|
|
168
290
|
//#endregion
|
|
169
|
-
export { build, dev, hostSchema, kind, run, serve };
|
|
291
|
+
export { build, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, switchboardDriveOutputSchema };
|
|
170
292
|
|
|
171
293
|
//# sourceMappingURL=switchboard.mjs.map
|
|
172
|
-
//# debugId=
|
|
294
|
+
//# debugId=8604c920-467f-5ac7-b870-1d3fd5a160e6
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard.mjs","sources":["../../src/services/classic-args.ts","../../src/runners/switchboard.ts"],"sourcesContent":["import { switchboardArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, runSafely } from \"cmd-ts\";\nimport type { SwitchboardArgs } from \"../types.js\";\n\n/**\n * The classic `ph switchboard` argument shape, produced by the SAME cmd-ts\n * definitions the classic command parses — not re-derived by hand. A runner\n * starts from this object and overlays only the keys its host file owns, so\n * every key the classic command carries (including the ones it carries as\n * `undefined`, e.g. `dbPath`) reaches the service exactly as it does on the\n * classic path. The uniform-runners switchboard runner once hand-built a\n * partial object that omitted `dbPath`; the service's then-default\n * `.ph/read-model.db` became both the reactor and the read-model PGlite dir —\n * two instances on one PGDATA (see uniform-runners-plan/legacy-parity-rectification.md).\n */\nconst classicSwitchboard = command({\n name: \"switchboard\",\n args: switchboardArgs,\n handler: (args) => args,\n});\n\nexport async function classicSwitchboardArgs(\n argv: string[] = [],\n): Promise<SwitchboardArgs> {\n const result = await runSafely(classicSwitchboard, argv);\n if (result._tag === \"error\") {\n throw new Error(\n `classic switchboard args did not parse: ${result.error.config.message}`,\n );\n }\n return result.value;\n}\n","import {\n profileSchema,\n reactorSchema,\n type HostDefinition,\n type ReactorConfig,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport {\n pluginEntrySchema,\n resolveDriveDeclaration,\n resolveHostPlugins,\n seedDrives,\n type DriveDeclaration,\n type DriveSeederClient,\n type ResolvedDrive,\n} from \"@powerhousedao/host-core\";\nimport { applyReactorEnvProjection } from \"./reactor-env.js\";\nimport { z } from \"zod\";\nimport { classicSwitchboardArgs } from \"../services/classic-args.js\";\nimport type { BuildArgs, SwitchboardArgs } from \"../types.js\";\n\n/**\n * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a\n * hosts/switchboard/host.js definition onto the SAME `startSwitchboard`\n * service the classic command calls. `run` = production loaders, `dev` =\n * Vite package loader (worker pools refused by the server, as always).\n * There is deliberately no `build` verb — the switchboard has none.\n */\n\nexport const kind = \"reactor\";\n\n/** Phase-2 schema (D2.d): `reactor`/`profile` strict via host-core. */\nexport const hostSchema = z.looseObject({\n name: z.string().min(1),\n runner: z.looseObject({\n module: z.string(),\n port: z.number().int().positive().optional(),\n https: z.boolean().optional(),\n // THE COMPOSITION (rewire R2): plugin entries, presence is activation.\n // (The classic packages-CSV meaning of this field is retired — packages\n // load via reactor.backends.*.packages / the package manager.)\n plugins: z.array(pluginEntrySchema).optional(),\n }),\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n reactor: reactorSchema.optional(),\n});\n\n/** The classic arg shape with the one switch a composition may leave unset. */\nexport type SwitchboardRunnerArgs = Omit<SwitchboardArgs, \"mcp\"> & {\n mcp: boolean | undefined;\n};\n\n/**\n * Start from the classic `ph switchboard` args (parsed by the classic\n * definitions, no flags) and overlay ONLY the keys the host file owns. Every\n * other key — including the ones the classic command carries as `undefined`,\n * such as `dbPath` — reaches the service exactly as on the classic path. No\n * cast: a key the classic shape has and this object lacks is a type error.\n */\nasync function toSwitchboardArgs(\n host: HostDefinition,\n devMode: boolean,\n dbPath: string | undefined,\n composed: boolean,\n): Promise<SwitchboardRunnerArgs> {\n const classic = await classicSwitchboardArgs();\n const runner = host.runner;\n return {\n ...classic,\n port: typeof runner.port === \"number\" ? runner.port : classic.port,\n // The verb owns dev mode; `runner.dev` is the host-file spelling of it.\n dev: devMode || runner.dev === true ? true : classic.dev,\n // A declared composition owns the carved switches (R2): the mcp plugin's\n // presence sets it, its absence must deactivate. Classic path: classic.\n mcp: composed ? undefined : classic.mcp,\n // The host file's readModel.url. Absent, the key stays present and\n // undefined exactly as the classic command carries it, so the server's\n // own split defaults (.ph/reactor-storage + .ph/read-storage) apply.\n // Omitting the key resurrected a dead service default and put the\n // reactor and the read model on ONE PGlite dir (two writers, one PGDATA).\n dbPath: dbPath ?? classic.dbPath,\n };\n}\n\n/** The slug of the drive the switchboard creates by default\n * (apps/switchboard config); `runner.driveSlug` overrides. */\nconst DEFAULT_DRIVE_SLUG = \"powerhouse\";\n\n/** Poll the default drive endpoint until the server answers — the compound's\n * readiness gate: Connect auto-connects the drive on first load, so the drive\n * must answer before the connect member serves (the sidecar's\n * waitForSwitchboard, moved behind the handle contract). */\nasync function waitForDrive(url: string, timeoutMs: number): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n try {\n const res = await fetch(url, { signal: AbortSignal.timeout(3000) });\n if (res.ok) return;\n } catch {\n // not listening yet\n }\n if (Date.now() > deadline) {\n throw new Error(\n `Switchboard drive ${url} did not answer within ${timeoutMs}ms.`,\n );\n }\n await new Promise((resolve) => setTimeout(resolve, 400));\n }\n}\n\n/** What a started switchboard reports to a supervising compound: its port and\n * the drive it serves (projected into a connect member's defaultDrives). */\nexport interface SwitchboardHandle {\n port: number;\n driveUrls: string[];\n endpoints: Record<string, string>;\n ready: Promise<void>;\n}\n\n/** Adapter from the switchboard's reactor client onto the host-core seeder.\n * addDefaultDrive is slug-idempotent itself, so findDriveBySlug delegates. */\nfunction seederClient(reactor: unknown, port: number): DriveSeederClient {\n return {\n findDriveBySlug: () => Promise.resolve(undefined),\n createDrive: async (drive: ResolvedDrive) => {\n const { addDefaultDrive } =\n await import(\"@powerhousedao/switchboard/utils\");\n await addDefaultDrive(\n reactor as Parameters<typeof addDefaultDrive>[0],\n {\n id: drive.id,\n slug: drive.slug,\n global: { name: drive.name, icon: drive.icon },\n ...(drive.preferredEditor\n ? { preferredEditor: drive.preferredEditor }\n : {}),\n local: {\n availableOffline: drive.availableOffline,\n listeners: [],\n sharingType: drive.sharingType,\n triggers: [],\n },\n } as Parameters<typeof addDefaultDrive>[1],\n port,\n );\n },\n attachRemoteDrive: () => Promise.resolve(), // remotes ride options.remoteDrives\n };\n}\n\nasync function start(\n host: HostDefinition,\n ctx: RunnerContext,\n devMode: boolean,\n): Promise<SwitchboardHandle> {\n const options = applyReactorEnvProjection(\n host.reactor as ReactorConfig | undefined,\n `hosts/${host.name}/host.js`,\n );\n const { startSwitchboard } = await import(\"../services/switchboard.js\");\n const entriesDeclared =\n (host.runner as { plugins?: unknown }).plugins !== undefined;\n const args = await toSwitchboardArgs(\n host,\n devMode,\n options.dbPath,\n entriesDeclared,\n );\n\n // R2 step 2: a declared composition activates the plugin pipeline — the\n // runner resolves the entries against the PROJECT dependency tree and the\n // flag drives server-side activation. No plugins key = classic path.\n const entries = (host.runner as { plugins?: unknown }).plugins as\n | Parameters<typeof resolveHostPlugins>[3]\n | undefined;\n let pluginComposition;\n if (entries !== undefined) {\n process.env.FEATURE_PLUGIN_HOST_ENABLED = \"1\";\n pluginComposition = await resolveHostPlugins(\n ctx.projectRoot,\n \"switchboard\",\n ctx.verb ?? (devMode ? \"dev\" : \"run\"),\n entries,\n `hosts/${host.name}/host.js`,\n );\n }\n\n // Core drive declarations (reactor.drives): locals seed after boot via the\n // host-core seeder; remotes ride the existing remoteDrives option; the\n // implicit default powerhouse drive is replaced by the declared set.\n const declarations = (\n host.reactor as { drives?: DriveDeclaration[] } | undefined\n )?.drives;\n const resolvedDrives = (declarations ?? []).map((declaration) =>\n resolveDriveDeclaration(ctx.projectRoot, declaration),\n );\n const serverArgs = {\n ...args,\n ...(pluginComposition ? { pluginComposition } : {}),\n ...(resolvedDrives.length > 0\n ? {\n drive: undefined,\n remoteDrives: resolvedDrives\n .filter((d) => d.kind === \"remote\")\n .map((d) => d.remoteUrl!),\n }\n : {}),\n };\n\n const switchboard = await startSwitchboard(serverArgs);\n const port = args.port;\n\n const localDrives = resolvedDrives.filter((d) => d.kind === \"local\");\n if (localDrives.length > 0 && switchboard) {\n await seedDrives(seederClient(switchboard.reactor, port), localDrives);\n }\n\n const slug =\n localDrives.length > 0\n ? localDrives[0].slug\n : typeof host.runner.driveSlug === \"string\"\n ? host.runner.driveSlug\n : DEFAULT_DRIVE_SLUG;\n const driveUrl = `http://localhost:${port}/d/${slug}`;\n const driveUrls =\n localDrives.length > 0\n ? localDrives.map((d) => `http://localhost:${port}/d/${d.slug}`)\n : [driveUrl];\n\n // Workflows on → seed the SAME project-hashed workflows drive the vetra\n // path seeds (opens in Workflow Studio); it rides the handle so a\n // supervising compound projects it into the connect member's drives.\n if (switchboard?.workflowsEnabled) {\n const { seedWorkflowsDrive } = await import(\"../services/vetra.js\");\n driveUrls.push(await seedWorkflowsDrive(switchboard.reactor, port));\n }\n\n const ready = waitForDrive(driveUrl, 180_000);\n // A supervisor awaits `ready` and sees the rejection; an unsupervised caller\n // (or a test with the service mocked) must not die of an unhandled one.\n ready.catch(() => undefined);\n return {\n port,\n driveUrls,\n endpoints: { graphql: `http://localhost:${port}/graphql` },\n ready,\n };\n}\n\n// The four verbs are orthogonal: each does ONE job.\n// - `run`/`serve`: START the server in production mode (serves the built\n// project package). `serve` is run's alias — a server IS its served stack,\n// and it lets the compound forward one `serve` verb to every member.\n// - `dev`: START the server in dev mode (watch / the Vite package loader).\n// - `build`: PRODUCE the project package this switchboard serves, and start\n// NOTHING. The analog of `ph connect build` on the server side: legacy\n// `ph switchboard build` never existed, but the project still has a build.\n// `build` is what lets a compound forward a single `build` verb to all members\n// (desktop/cli) without the switchboard member failing on an unknown verb.\n\nexport async function run(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<SwitchboardHandle> {\n return start(host, ctx, false);\n}\n\nexport const serve = run;\n\nexport async function dev(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<SwitchboardHandle> {\n return start(host, ctx, true);\n}\n\n/** Build the project's reactor package (the SAME service as `ph build`) — what\n * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */\nexport async function build(\n host: HostDefinition,\n _ctx: RunnerContext,\n): Promise<void> {\n const { runBuild } = await import(\"../services/build.js\");\n const runner = host.runner;\n const args: Partial<BuildArgs> = {\n outDir: typeof runner.outDir === \"string\" ? runner.outDir : \"dist\",\n };\n await runBuild(args as BuildArgs);\n}\n"],"names":["z.looseObject","z.string","z.number","z.boolean","z.array"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,qBAAqB,QAAQ;CACjC,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAED,eAAsB,uBACpB,OAAiB,CAAC,GACQ;CAC1B,MAAM,SAAS,MAAM,UAAU,oBAAoB,IAAI;CACvD,IAAI,OAAO,SAAS,SAClB,MAAM,IAAI,MACR,2CAA2C,OAAO,MAAM,OAAO,SACjE;CAEF,OAAO,OAAO;AAChB;;;;;;;;;;ACFA,MAAa,OAAO;;AAGpB,MAAa,aAAaA,YAAc;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SAAS,IAAI,GAAG,WAAW;CASvE,MAAM,WAAW,oBAAoB,KAAK,KALxC,YAAY,SAAS,IACjB,YAAY,EAAE,CAAC,OACf,OAAO,KAAK,OAAO,cAAc,WAC/B,KAAK,OAAO,YACZ;CAER,MAAM,YACJ,YAAY,SAAS,IACjB,YAAY,KAAK,MAAM,oBAAoB,KAAK,KAAK,EAAE,MAAM,IAC7D,CAAC,QAAQ;CAKf,IAAI,aAAa,kBAAkB;EACjC,MAAM,EAAE,uBAAuB,MAAM,OAAO;EAC5C,UAAU,KAAK,MAAM,mBAAmB,YAAY,SAAS,IAAI,CAAC;CACpE;CAEA,MAAM,QAAQ,aAAa,UAAU,IAAO;CAG5C,MAAM,YAAY,KAAA,CAAS;CAC3B,OAAO;EACL;EACA;EACA,WAAW,EAAE,SAAS,oBAAoB,KAAK,UAAU;EACzD;CACF;AACF;AAaA,eAAsB,IACpB,MACA,KAC4B;CAC5B,OAAO,MAAM,MAAM,KAAK,KAAK;AAC/B;AAEA,MAAa,QAAQ;AAErB,eAAsB,IACpB,MACA,KAC4B;CAC5B,OAAO,MAAM,MAAM,KAAK,IAAI;AAC9B;;;AAIA,eAAsB,MACpB,MACA,MACe;CACf,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,SAAS,KAAK;CAIpB,MAAM,SAAS,EAFb,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS,OAE5C,CAAc;AAClC","debug_id":"ad7a5128-0c7d-5e23-800d-238273f138ce"}
|
|
1
|
+
{"version":3,"file":"switchboard.mjs","sources":["../../src/runners/reactor-env.ts","../../src/services/classic-args.ts","../../src/runners/switchboard.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport {\n assertProtocolConsistency,\n primaryBackend,\n projectReactorToSwitchboard,\n type ReactorConfig,\n} from \"@powerhousedao/host-core\";\n\n/**\n * Apply a host's reactor block to the CURRENT process env, the way the\n * in-process switchboard server reads it at boot (D2.c: env derivation\n * immediately before the member starts; sequential boots make this safe).\n * Single-sourcing teeth first: a pre-set env contradicting the protocol block\n * fails loudly. Then set-if-absent, so an operator's explicit (agreeing) env\n * still wins during the transition. Returns the non-env options (dbPath).\n *\n * Lives OUTSIDE the runner modules on purpose: every export of a runner\n * module reads as a dispatchable verb, and this is not one.\n */\nexport function applyReactorEnvProjection(\n reactor: ReactorConfig | undefined,\n hostFileLabel: string,\n): { dbPath?: string } {\n const { env, options } = projectReactorToSwitchboard(reactor);\n assertProtocolConsistency(reactor?.protocol, process.env, hostFileLabel);\n for (const [name, value] of Object.entries(env)) {\n if (process.env[name] === undefined) process.env[name] = value;\n }\n // A path-storage data dir must exist before the server boots — its own\n // mkdir is not recursive (the ph-win sidecar did this too).\n const storage = primaryBackend(reactor)?.storage;\n if (storage?.kind === \"path\" && storage.dataDir) {\n // `ph run` resolves `$env` and the `${userData}` sugar before the verb;\n // an unresolved one here would mkdir a literal \"${userData}\" folder.\n if (/\\$\\{(userData|projectRoot)\\}/.test(storage.dataDir)) {\n throw new Error(\n `${hostFileLabel}: storage.dataDir \"${storage.dataDir}\" was not resolved; resolve the host (resolveHostOutputs) before starting it.`,\n );\n }\n fs.mkdirSync(storage.dataDir, { recursive: true });\n }\n return options;\n}\n","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 defineHostSchemas,\n drivesSchema,\n mergeDrivePlan,\n resolveDriveDeclaration,\n resolveHostPlugins,\n seedDrives,\n type DriveSeederClient,\n type ResolvedDrive,\n type ResolvedPlugin,\n type RunnerContext,\n type RunnerHandle,\n} from \"@powerhousedao/host-core\";\nimport { applyReactorEnvProjection } from \"./reactor-env.js\";\nimport { z } from \"zod\";\nimport { classicSwitchboardArgs } from \"../services/classic-args.js\";\nimport type { BuildArgs, SwitchboardArgs } from \"../types.js\";\n\n/**\n * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a\n * hosts/switchboard/host.js definition onto the SAME `startSwitchboard`\n * service the classic command calls. `run` = production loaders, `dev` =\n * Vite package loader (worker pools refused by the server, as always).\n */\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). The\n * runner reads nothing from `config`, so only an empty one is accepted.\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 /** 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.strictObject({}).optional(),\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 dbPath: string | undefined,\n composed: boolean,\n): Promise<SwitchboardRunnerArgs> {\n const classic = await classicSwitchboardArgs();\n const runner = host.runner;\n return {\n ...classic,\n port: runner.port ?? classic.port,\n // The verb owns dev mode; `runner.dev` is the host-file spelling of it.\n dev: devMode || runner.dev === true ? true : classic.dev,\n // A declared composition owns the carved switches (R2): the mcp plugin's\n // presence sets it, its absence must deactivate. Classic path: classic.\n mcp: composed ? undefined : classic.mcp,\n // The host file's readModel.url. Absent, the key stays present and\n // undefined exactly as the classic command carries it, so the server's\n // own split defaults (.ph/reactor-storage + .ph/read-storage) apply.\n // Omitting the key resurrected a dead service default and put the\n // reactor and the read model on ONE PGlite dir (two writers, one PGDATA).\n dbPath: dbPath ?? classic.dbPath,\n };\n}\n\n/** The 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). */\nasync function waitForDrive(url: string, timeoutMs: number): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n try {\n const res = await fetch(url, { signal: AbortSignal.timeout(3000) });\n if (res.ok) return;\n } catch {\n // not listening yet\n }\n if (Date.now() > deadline) {\n throw new Error(\n `Switchboard drive ${url} did not answer within ${timeoutMs}ms.`,\n );\n }\n await new Promise((resolve) => setTimeout(resolve, 400));\n }\n}\n\n/** What a started switchboard 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 seededIds.set(drive.slug, drive.id);\n const { addDefaultDrive } =\n await import(\"@powerhousedao/switchboard/utils\");\n await addDefaultDrive(\n reactor as Parameters<typeof addDefaultDrive>[0],\n {\n id: drive.id,\n slug: drive.slug,\n global: { name: drive.name, icon: drive.icon },\n ...(drive.preferredEditor\n ? { preferredEditor: drive.preferredEditor }\n : {}),\n local: {\n availableOffline: drive.availableOffline,\n listeners: [],\n sharingType: drive.sharingType,\n triggers: [],\n },\n } as Parameters<typeof addDefaultDrive>[1],\n port,\n );\n },\n attachRemoteDrive: () => Promise.resolve(), // remotes ride options.remoteDrives\n };\n}\n\nasync function start(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n devMode: boolean,\n): Promise<SwitchboardHandle> {\n const options = applyReactorEnvProjection(\n host.reactor,\n `hosts/${host.name}/host.js`,\n );\n const { startSwitchboard } = await import(\"../services/switchboard.js\");\n const entries = host.runner.plugins;\n const entriesDeclared = entries !== undefined;\n const args = await toSwitchboardArgs(\n host,\n devMode,\n options.dbPath,\n entriesDeclared,\n );\n\n // R2 step 2: a declared composition activates the plugin pipeline — the\n // runner resolves the entries against the PROJECT dependency tree and the\n // flag drives server-side activation. No plugins key = classic path.\n let pluginComposition;\n if (entries !== undefined) {\n process.env.FEATURE_PLUGIN_HOST_ENABLED = \"1\";\n pluginComposition = await resolveHostPlugins(\n ctx.projectRoot,\n \"switchboard\",\n ctx.verb,\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(serverArgs);\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 const ready = waitForDrive(driveUrl, 180_000);\n // A supervisor awaits `ready` and sees the rejection; an unsupervised caller\n // (or a test with the service mocked) must not die of an unhandled one.\n ready.catch(() => undefined);\n 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: () => (stopping ??= switchboard.shutdown()),\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/** 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.boolean","z.string","z.strictObject","z.url","z.record","z.prettifyError"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,0BACd,SACA,eACqB;CACrB,MAAM,EAAE,KAAK,YAAY,4BAA4B,OAAO;CAC5D,0BAA0B,SAAS,UAAU,QAAQ,KAAK,aAAa;CACvE,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,GAAG,GAC5C,IAAI,QAAQ,IAAI,UAAU,KAAA,GAAW,QAAQ,IAAI,QAAQ;CAI3D,MAAM,UAAU,eAAe,OAAO,CAAC,EAAE;CACzC,IAAI,SAAS,SAAS,UAAU,QAAQ,SAAS;EAG/C,IAAI,+BAA+B,KAAK,QAAQ,OAAO,GACrD,MAAM,IAAI,MACR,GAAG,cAAc,qBAAqB,QAAQ,QAAQ,8EACxD;EAEF,GAAG,UAAU,QAAQ,SAAS,EAAE,WAAW,KAAK,CAAC;CACnD;CACA,OAAO;AACT;;;;;;;;;;;;;;AC3BA,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;;;;;;;;;ACNA,MAAa,OAAO;;;;;;;AAQpB,MAAM,UAAU,mBAAmB,MACjC,EAAE,kBAAkB,OAAO;CACzB,QAAQ,EAAE,iBACP,OAAO;;EAEN,KAAKA,UAAU,CAAC,CAAC,SAAS;;EAE1B,QAAQC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,S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