@powerhousedao/ph-cli 6.2.3-dev.7 → 6.2.3-dev.71

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 (128) hide show
  1. package/dist/{auth-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
  2. package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
  3. package/dist/auth-CNhbN5UM.mjs +4 -0
  4. package/dist/build-C78yPntL.mjs +4 -0
  5. package/dist/build-Dj8qfSSe.mjs +349 -0
  6. package/dist/build-Dj8qfSSe.mjs.map +1 -0
  7. package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-CEJhQWRX.mjs} +39 -27
  8. package/dist/cli-connect-override-CEJhQWRX.mjs.map +1 -0
  9. package/dist/cli.d.mts +2 -1
  10. package/dist/cli.mjs +31 -1175
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs +2459 -0
  13. package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs.map +1 -0
  14. package/dist/connect-build-BfhOGbha.mjs +253 -0
  15. package/dist/connect-build-BfhOGbha.mjs.map +1 -0
  16. package/dist/{connect-config-BWGiW3IB.mjs → connect-config-DblqJgxR.mjs} +19 -12
  17. package/dist/connect-config-DblqJgxR.mjs.map +1 -0
  18. package/dist/connect-plugin-configs-D2fwYpMw.mjs +50 -0
  19. package/dist/connect-plugin-configs-D2fwYpMw.mjs.map +1 -0
  20. package/dist/connect-preview-8-qLgWKt.mjs +215 -0
  21. package/dist/connect-preview-8-qLgWKt.mjs.map +1 -0
  22. package/dist/{connect-studio-D6rfWCNB.mjs → connect-studio-DX7r4iyI.mjs} +18 -11
  23. package/dist/connect-studio-DX7r4iyI.mjs.map +1 -0
  24. package/dist/connect-studio-DmjcV8I2.mjs +4 -0
  25. package/dist/dist-CCLkwpTS.mjs +313 -0
  26. package/dist/dist-CCLkwpTS.mjs.map +1 -0
  27. package/dist/explain-DUXbB9jf.mjs +241 -0
  28. package/dist/explain-DUXbB9jf.mjs.map +1 -0
  29. package/dist/feature-flags-xwqcHEWC.mjs +4 -0
  30. package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-Dgyy_kT-.mjs} +9 -3
  31. package/dist/generate-all-Dgyy_kT-.mjs.map +1 -0
  32. package/dist/{generate-app-DNNqA-H3.mjs → generate-app-BTs1u-9l.mjs} +7 -5
  33. package/dist/{generate-app-DNNqA-H3.mjs.map → generate-app-BTs1u-9l.mjs.map} +1 -1
  34. package/dist/generate-desktop-shell-Bj_3bJDL.mjs +317 -0
  35. package/dist/generate-desktop-shell-Bj_3bJDL.mjs.map +1 -0
  36. package/dist/{generate-document-model-BJXyODfm.mjs → generate-document-model-BfFIQ35q.mjs} +19 -7
  37. package/dist/generate-document-model-BfFIQ35q.mjs.map +1 -0
  38. package/dist/{generate-editor-BejvaVVT.mjs → generate-editor-CW7Do69u.mjs} +7 -5
  39. package/dist/{generate-editor-BejvaVVT.mjs.map → generate-editor-CW7Do69u.mjs.map} +1 -1
  40. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  41. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  42. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  43. package/dist/generate-piece-QTt-ddt2.mjs +65 -0
  44. package/dist/generate-piece-QTt-ddt2.mjs.map +1 -0
  45. package/dist/generate-piece-action-DbxrzfKY.mjs +29 -0
  46. package/dist/generate-piece-action-DbxrzfKY.mjs.map +1 -0
  47. package/dist/generate-piece-trigger-CqVOcL9g.mjs +30 -0
  48. package/dist/generate-piece-trigger-CqVOcL9g.mjs.map +1 -0
  49. package/dist/{generate-processor-_WOx-mMe.mjs → generate-processor-DBtTkgo5.mjs} +15 -8
  50. package/dist/generate-processor-DBtTkgo5.mjs.map +1 -0
  51. package/dist/{generate-subgraph-BsHUstpl.mjs → generate-subgraph-CVlTo7qk.mjs} +12 -6
  52. package/dist/generate-subgraph-CVlTo7qk.mjs.map +1 -0
  53. package/dist/index-BIbx17vt.d.mts +4459 -0
  54. package/dist/index-BIbx17vt.d.mts.map +1 -0
  55. package/dist/{init-BZP6gvYd.mjs → init-ScuT3z7P.mjs} +7 -5
  56. package/dist/init-ScuT3z7P.mjs.map +1 -0
  57. package/dist/{inspect-DXjbQEV_.mjs → inspect-zWJnBDMJ.mjs} +11 -4
  58. package/dist/inspect-zWJnBDMJ.mjs.map +1 -0
  59. package/dist/install-added-dependencies-DVSbzler.mjs +33 -0
  60. package/dist/install-added-dependencies-DVSbzler.mjs.map +1 -0
  61. package/dist/{migrate-jGKfE02L.mjs → migrate-DK4HK7Dn.mjs} +4 -4
  62. package/dist/{migrate-jGKfE02L.mjs.map → migrate-DK4HK7Dn.mjs.map} +1 -1
  63. package/dist/ph-cli-commands-BhzvcuzR.mjs +4 -0
  64. package/dist/ph-cli-commands-pyxDifSE.mjs +1493 -0
  65. package/dist/ph-cli-commands-pyxDifSE.mjs.map +1 -0
  66. package/dist/precompress-P6cJDPVC.mjs +77 -0
  67. package/dist/precompress-P6cJDPVC.mjs.map +1 -0
  68. package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
  69. package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
  70. package/dist/run-sugar-Ns53R6lU.mjs +39 -0
  71. package/dist/run-sugar-Ns53R6lU.mjs.map +1 -0
  72. package/dist/runners/connect.d.mts +1173 -0
  73. package/dist/runners/connect.d.mts.map +1 -0
  74. package/dist/runners/connect.mjs +270 -0
  75. package/dist/runners/connect.mjs.map +1 -0
  76. package/dist/runners/switchboard.d.mts +340 -0
  77. package/dist/runners/switchboard.d.mts.map +1 -0
  78. package/dist/runners/switchboard.mjs +294 -0
  79. package/dist/runners/switchboard.mjs.map +1 -0
  80. package/dist/schemas-D5N5U_Mf.mjs +5738 -0
  81. package/dist/schemas-D5N5U_Mf.mjs.map +1 -0
  82. package/dist/scripts/emit-runner-schemas.ts +24 -0
  83. package/dist/scripts/generate-commands-docs.ts +8 -0
  84. package/dist/scripts/manage-environment +0 -0
  85. package/dist/scripts/setup.sh +0 -0
  86. package/dist/start-run-BIaYSpHh.mjs +124 -0
  87. package/dist/start-run-BIaYSpHh.mjs.map +1 -0
  88. package/dist/superseded-config-CbSTFun2.mjs +53 -0
  89. package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
  90. package/dist/switchboard-C5zgkRl2.mjs +4 -0
  91. package/dist/switchboard-h4-XgP1h.mjs +129 -0
  92. package/dist/switchboard-h4-XgP1h.mjs.map +1 -0
  93. package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-7JQZM7-5.mjs} +5 -4
  94. package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-7JQZM7-5.mjs.map} +1 -1
  95. package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  96. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  97. package/dist/{utils-C4isxXSO.mjs → utils-9KyRM0mf.mjs} +6 -34
  98. package/dist/{utils-C4isxXSO.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  99. package/dist/utils-DAux4Ga7.mjs +4 -0
  100. package/dist/{vetra-DkF6EJMY.mjs → vetra-CnrGDPX0.mjs} +70 -35
  101. package/dist/vetra-CnrGDPX0.mjs.map +1 -0
  102. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  103. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  104. package/package.json +39 -18
  105. package/dist/auth-BNkN6kS9.mjs +0 -4
  106. package/dist/build-C-A5-ipO.mjs +0 -4
  107. package/dist/build-uQXq6_HU.mjs +0 -71
  108. package/dist/build-uQXq6_HU.mjs.map +0 -1
  109. package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
  110. package/dist/connect-build-WL4axo4z.mjs +0 -43
  111. package/dist/connect-build-WL4axo4z.mjs.map +0 -1
  112. package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
  113. package/dist/connect-preview-D7ypzFDc.mjs +0 -28
  114. package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
  115. package/dist/connect-studio-BIQzyq5B.mjs +0 -5
  116. package/dist/connect-studio-D6rfWCNB.mjs.map +0 -1
  117. package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
  118. package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
  119. package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
  120. package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
  121. package/dist/init-BZP6gvYd.mjs.map +0 -1
  122. package/dist/inspect-DXjbQEV_.mjs.map +0 -1
  123. package/dist/switchboard-CJMoMzWx.mjs +0 -75
  124. package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
  125. package/dist/switchboard-iRFugh8I.mjs +0 -4
  126. package/dist/switchboard-reset-BcQXlcVf.mjs.map +0 -1
  127. package/dist/utils-BzwczAW-.mjs +0 -4
  128. package/dist/vetra-DkF6EJMY.mjs.map +0 -1
@@ -0,0 +1,294 @@
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]="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";
6
+ import { command, runSafely } from "cmd-ts";
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
33
+ //#region src/services/classic-args.ts
34
+ /**
35
+ * The classic `ph switchboard` argument shape, produced by the SAME cmd-ts
36
+ * definitions the classic command parses — not re-derived by hand. A runner
37
+ * starts from this object and overlays only the keys its host file owns, so
38
+ * every key the classic command carries (including the ones it carries as
39
+ * `undefined`, e.g. `dbPath`) reaches the service exactly as it does on the
40
+ * classic path. The uniform-runners switchboard runner once hand-built a
41
+ * partial object that omitted `dbPath`; the service's then-default
42
+ * `.ph/read-model.db` became both the reactor and the read-model PGlite dir —
43
+ * two instances on one PGDATA (see uniform-runners-plan/legacy-parity-rectification.md).
44
+ */
45
+ const classicSwitchboard = command({
46
+ name: "switchboard",
47
+ args: switchboardArgs,
48
+ handler: (args) => args
49
+ });
50
+ async function classicSwitchboardArgs(argv = []) {
51
+ const result = await runSafely(classicSwitchboard, argv);
52
+ if (result._tag === "error") throw new Error(`classic switchboard args did not parse: ${result.error.config.message}`);
53
+ return result.value;
54
+ }
55
+ //#endregion
56
+ //#region src/runners/switchboard.ts
57
+ /**
58
+ * BRIDGE runner for Switchboard hosts (uniform-runners phase 0): maps a
59
+ * hosts/switchboard/host.js definition onto the SAME `startSwitchboard`
60
+ * service the classic command calls. `run` = production loaders, `dev` =
61
+ * Vite package loader (worker pools refused by the server, as always).
62
+ */
63
+ const kind = "reactor";
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()
97
+ }),
98
+ drives: record(string$1(), switchboardDriveOutputSchema)
99
+ });
100
+ /**
101
+ * Start from the classic `ph switchboard` args (parsed by the classic
102
+ * definitions, no flags) and overlay ONLY the keys the host file owns. Every
103
+ * other key — including the ones the classic command carries as `undefined`,
104
+ * such as `dbPath` — reaches the service exactly as on the classic path. No
105
+ * cast: a key the classic shape has and this object lacks is a type error.
106
+ */
107
+ async function toSwitchboardArgs(host, devMode, dbPath, composed) {
108
+ const classic = await classicSwitchboardArgs();
109
+ const runner = host.runner;
110
+ return {
111
+ ...classic,
112
+ port: runner.port ?? classic.port,
113
+ dev: devMode || runner.dev === true ? true : classic.dev,
114
+ mcp: composed ? void 0 : classic.mcp,
115
+ dbPath: dbPath ?? classic.dbPath
116
+ };
117
+ }
118
+ /** The drive the switchboard service creates by default
119
+ * (services/switchboard.ts `defaultSwitchboardOptions.drive`). */
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
+ }
152
+ /** Poll the default drive endpoint until the server answers — the compound's
153
+ * readiness gate: Connect auto-connects the drive on first load, so the drive
154
+ * must answer before the connect member serves (the sidecar's
155
+ * waitForSwitchboard, moved behind the handle contract). */
156
+ async function waitForDrive(url, timeoutMs) {
157
+ const deadline = Date.now() + timeoutMs;
158
+ for (;;) {
159
+ try {
160
+ if ((await fetch(url, { signal: AbortSignal.timeout(3e3) })).ok) return;
161
+ } catch {}
162
+ if (Date.now() > deadline) throw new Error(`Switchboard drive ${url} did not answer within ${timeoutMs}ms.`);
163
+ await new Promise((resolve) => setTimeout(resolve, 400));
164
+ }
165
+ }
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) {
176
+ return {
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
+ },
186
+ createDrive: async (drive) => {
187
+ seededIds.set(drive.slug, drive.id);
188
+ const { addDefaultDrive } = await import("@powerhousedao/switchboard/utils");
189
+ await addDefaultDrive(reactor, {
190
+ id: drive.id,
191
+ slug: drive.slug,
192
+ global: {
193
+ name: drive.name,
194
+ icon: drive.icon
195
+ },
196
+ ...drive.preferredEditor ? { preferredEditor: drive.preferredEditor } : {},
197
+ local: {
198
+ availableOffline: drive.availableOffline,
199
+ listeners: [],
200
+ sharingType: drive.sharingType,
201
+ triggers: []
202
+ }
203
+ }, port);
204
+ },
205
+ attachRemoteDrive: () => Promise.resolve()
206
+ };
207
+ }
208
+ async function start(host, ctx, devMode) {
209
+ const options = applyReactorEnvProjection(host.reactor, `hosts/${host.name}/host.js`);
210
+ const { startSwitchboard } = await import("../switchboard-C5zgkRl2.mjs");
211
+ const entries = host.runner.plugins;
212
+ const entriesDeclared = entries !== void 0;
213
+ const args = await toSwitchboardArgs(host, devMode, options.dbPath, entriesDeclared);
214
+ let pluginComposition;
215
+ if (entries !== void 0) {
216
+ process.env.FEATURE_PLUGIN_HOST_ENABLED = "1";
217
+ pluginComposition = await resolveHostPlugins(ctx.projectRoot, "switchboard", ctx.verb, entries, `hosts/${host.name}/host.js`);
218
+ }
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] : []);
226
+ const switchboard = await startSwitchboard({
227
+ ...args,
228
+ ...pluginComposition ? { pluginComposition } : {},
229
+ ...hostDrives.length > 0 ? { drive: void 0 } : {},
230
+ ...remoteDrives.length > 0 ? { remoteDrives } : {},
231
+ ...ctx.parent ? { signalHandlers: false } : {}
232
+ });
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-CnrGDPX0.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
+ };
259
+ }
260
+ const ready = waitForDrive(driveUrl, 18e4);
261
+ ready.catch(() => void 0);
262
+ const graphql = `${origin}/graphql`;
263
+ let stopping;
264
+ return {
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()
275
+ };
276
+ }
277
+ async function run(host, ctx) {
278
+ return start(host, ctx, false);
279
+ }
280
+ const serve = run;
281
+ async function dev(host, ctx) {
282
+ return start(host, ctx, true);
283
+ }
284
+ /** Build the project's reactor package (the SAME service as `ph build`) — what
285
+ * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
286
+ async function build(host, _ctx) {
287
+ const { runBuild } = await import("../build-C78yPntL.mjs");
288
+ await runBuild({ outDir: host.runner.outDir ?? "dist" });
289
+ }
290
+ //#endregion
291
+ export { build, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, switchboardDriveOutputSchema };
292
+
293
+ //# sourceMappingURL=switchboard.mjs.map
294
+ //# debugId=8604c920-467f-5ac7-b870-1d3fd5a160e6
@@ -0,0 +1 @@
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,qBAA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