@powerhousedao/ph-run 6.2.3-dev.89 → 6.2.3-dev.91

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 (33) hide show
  1. package/dist/classic-args-BYccyIIC.mjs +4 -1
  2. package/dist/classic-args-BYccyIIC.mjs.map +1 -1
  3. package/dist/cli.mjs +4 -1
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/connect-plugin-configs-CPRA8hQJ.mjs +4 -1
  6. package/dist/connect-plugin-configs-CPRA8hQJ.mjs.map +1 -1
  7. package/dist/connect-serve-0fIQ7xCs.mjs +4 -1
  8. package/dist/connect-serve-0fIQ7xCs.mjs.map +1 -1
  9. package/dist/member-config-BcEWRVq4.mjs +4 -1
  10. package/dist/member-config-BcEWRVq4.mjs.map +1 -1
  11. package/dist/runners/connect.d.mts +6 -0
  12. package/dist/runners/connect.d.mts.map +1 -1
  13. package/dist/runners/connect.mjs +5 -2
  14. package/dist/runners/connect.mjs.map +1 -1
  15. package/dist/runners/member-config.d.mts +4 -0
  16. package/dist/runners/member-config.d.mts.map +1 -1
  17. package/dist/runners/member-config.mjs +2 -0
  18. package/dist/runners/switchboard.d.mts +10 -0
  19. package/dist/runners/switchboard.d.mts.map +1 -1
  20. package/dist/runners/switchboard.mjs +4 -1
  21. package/dist/runners/switchboard.mjs.map +1 -1
  22. package/dist/services/classic-args.mjs +2 -0
  23. package/dist/services/connect-serve.mjs +2 -0
  24. package/dist/services/connect-server.mjs +4 -1
  25. package/dist/services/connect-server.mjs.map +1 -1
  26. package/dist/services/run/start-run.mjs +2 -0
  27. package/dist/services/switchboard.mjs +4 -1
  28. package/dist/services/switchboard.mjs.map +1 -1
  29. package/dist/start-run-DWn2cVyi.mjs +4 -1
  30. package/dist/start-run-DWn2cVyi.mjs.map +1 -1
  31. package/dist/superseded-config-CpHrCuNq.mjs +4 -1
  32. package/dist/superseded-config-CpHrCuNq.mjs.map +1 -1
  33. package/package.json +7 -7
@@ -1,3 +1,5 @@
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]="25f4ecc9-e49b-546f-9baa-cec84d0ddc4d")}catch(e){}}();
1
3
  import { connectPreviewArgs, switchboardArgs } from "@powerhousedao/shared/clis/args";
2
4
  import { command, runSafely } from "cmd-ts";
3
5
  //#region src/services/classic-args.ts
@@ -30,4 +32,5 @@ async function classicSwitchboardArgs(argv = []) {
30
32
  //#endregion
31
33
  export { classicSwitchboardArgs as t };
32
34
 
33
- //# sourceMappingURL=classic-args-BYccyIIC.mjs.map
35
+ //# sourceMappingURL=classic-args-BYccyIIC.mjs.map
36
+ //# debugId=25f4ecc9-e49b-546f-9baa-cec84d0ddc4d
@@ -1 +1 @@
1
- {"version":3,"file":"classic-args-BYccyIIC.mjs","names":[],"sources":["../src/services/classic-args.ts"],"sourcesContent":["import type { ParsedCmdResult } from \"@powerhousedao/shared/clis\";\nimport {\n connectPreviewArgs,\n switchboardArgs,\n} from \"@powerhousedao/shared/clis/args\";\nimport { command, runSafely } from \"cmd-ts\";\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\nconst classicConnectPreview = command({\n name: \"preview\",\n args: connectPreviewArgs,\n handler: (args) => args,\n});\n\nexport type SwitchboardArgs = ParsedCmdResult<typeof classicSwitchboard>;\nexport type ConnectPreviewArgs = ParsedCmdResult<typeof classicConnectPreview>;\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"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB,QAAQ;CACjC,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAE6B,QAAQ;CACpC,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAKD,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"}
1
+ {"version":3,"file":"classic-args-BYccyIIC.mjs","sources":["../src/services/classic-args.ts"],"sourcesContent":["import type { ParsedCmdResult } from \"@powerhousedao/shared/clis\";\nimport {\n connectPreviewArgs,\n switchboardArgs,\n} from \"@powerhousedao/shared/clis/args\";\nimport { command, runSafely } from \"cmd-ts\";\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\nconst classicConnectPreview = command({\n name: \"preview\",\n args: connectPreviewArgs,\n handler: (args) => args,\n});\n\nexport type SwitchboardArgs = ParsedCmdResult<typeof classicSwitchboard>;\nexport type ConnectPreviewArgs = ParsedCmdResult<typeof classicConnectPreview>;\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"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB,QAAQ;CACjC,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAE6B,QAAQ;CACpC,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAKD,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","debug_id":"25f4ecc9-e49b-546f-9baa-cec84d0ddc4d"}
package/dist/cli.mjs CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3109cda4-a037-595b-8c8a-1725272205e1")}catch(e){}}();
2
4
  import { t as startRun } from "./start-run-DWn2cVyi.mjs";
3
5
  import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
4
6
  //#region src/cli.ts
@@ -26,4 +28,5 @@ await main(process.argv.slice(2)).catch((error) => {
26
28
  //#endregion
27
29
  export {};
28
30
 
29
- //# sourceMappingURL=cli.mjs.map
31
+ //# sourceMappingURL=cli.mjs.map
32
+ //# debugId=3109cda4-a037-595b-8c8a-1725272205e1
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { assertNodeVersion } from \"@powerhousedao/shared/clis/utils\";\nimport { startRun } from \"./services/run/start-run.js\";\n\n/**\n * `ph-run run <host> [verb]`: what `ph run` does and nothing else `ph` does, so\n * a packaged app can run a host with none of the tools that build one. It takes\n * `run` as its first word so a supervisor can start either of the two the same\n * way.\n */\nasync function main(args: string[]) {\n assertNodeVersion();\n const debug = args.includes(\"--debug\");\n const [command, host, verb] = args.filter((arg) => arg !== \"--debug\");\n if (command !== \"run\" || !host) {\n throw new Error(\"Usage: ph-run run <host> [verb] [--debug]\");\n }\n await startRun({ host, verb, debug });\n}\n\nawait main(process.argv.slice(2)).catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;AAUA,eAAe,KAAK,MAAgB;CAClC,kBAAkB;CAClB,MAAM,QAAQ,KAAK,SAAS,SAAS;CACrC,MAAM,CAAC,SAAS,MAAM,QAAQ,KAAK,QAAQ,QAAQ,QAAQ,SAAS;CACpE,IAAI,YAAY,SAAS,CAAC,MACxB,MAAM,IAAI,MAAM,2CAA2C;CAE7D,MAAM,SAAS;EAAE;EAAM;EAAM;CAAM,CAAC;AACtC;AAEA,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,UAAmB;CAC1D,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;CAC5D,QAAQ,KAAK,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"cli.mjs","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { assertNodeVersion } from \"@powerhousedao/shared/clis/utils\";\nimport { startRun } from \"./services/run/start-run.js\";\n\n/**\n * `ph-run run <host> [verb]`: what `ph run` does and nothing else `ph` does, so\n * a packaged app can run a host with none of the tools that build one. It takes\n * `run` as its first word so a supervisor can start either of the two the same\n * way.\n */\nasync function main(args: string[]) {\n assertNodeVersion();\n const debug = args.includes(\"--debug\");\n const [command, host, verb] = args.filter((arg) => arg !== \"--debug\");\n if (command !== \"run\" || !host) {\n throw new Error(\"Usage: ph-run run <host> [verb] [--debug]\");\n }\n await startRun({ host, verb, debug });\n}\n\nawait main(process.argv.slice(2)).catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"],"names":[],"mappings":";;;;;;;;;;;;AAUA,eAAe,KAAK,MAAgB;CAClC,kBAAkB;CAClB,MAAM,QAAQ,KAAK,SAAS,SAAS;CACrC,MAAM,CAAC,SAAS,MAAM,QAAQ,KAAK,QAAQ,QAAQ,QAAQ,SAAS;CACpE,IAAI,YAAY,SAAS,CAAC,MACxB,MAAM,IAAI,MAAM,2CAA2C;CAE7D,MAAM,SAAS;EAAE;EAAM;EAAM;CAAM,CAAC;AACtC;AAEA,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,UAAmB;CAC1D,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;CAC5D,QAAQ,KAAK,CAAC;AAChB,CAAC","debug_id":"3109cda4-a037-595b-8c8a-1725272205e1"}
@@ -1,3 +1,5 @@
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]="343788e5-4606-5080-b02b-274217034899")}catch(e){}}();
1
3
  import { createRequire } from "node:module";
2
4
  import { PluginError, entryActiveForVerb, isSchemaLike, normalizePluginEntries } from "@powerhousedao/host-core";
3
5
  import path from "node:path";
@@ -44,4 +46,5 @@ async function loadPluginConfigSchemas(projectRoot) {
44
46
  //#endregion
45
47
  export { validateConnectPluginConfigs };
46
48
 
47
- //# sourceMappingURL=connect-plugin-configs-CPRA8hQJ.mjs.map
49
+ //# sourceMappingURL=connect-plugin-configs-CPRA8hQJ.mjs.map
50
+ //# debugId=343788e5-4606-5080-b02b-274217034899
@@ -1 +1 @@
1
- {"version":3,"file":"connect-plugin-configs-CPRA8hQJ.mjs","names":[],"sources":["../src/runners/connect-plugin-configs.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n entryActiveForVerb,\n isSchemaLike,\n normalizePluginEntries,\n PluginError,\n type PluginEntryData,\n} from \"@powerhousedao/host-core\";\n\n/** The zod-only entry Connect publishes with every built-in plugin's entry\n * config schema, keyed by plugin specifier. */\nconst PLUGIN_CONFIGS_ENTRY = \"@powerhousedao/connect/plugin-configs\";\n\n/**\n * Validate the entry configs of the Connect plugins composed for `verb`\n * before Connect boots, so a typo fails at `ph run` naming the plugin and the\n * key instead of at browser boot. The schemas come from the project's own\n * `@powerhousedao/connect/plugin-configs` (resolved from the project tree,\n * like runner and plugin modules); without it, or for a specifier it has no\n * schema for, the browser's own validation stays the only check.\n */\nexport async function validateConnectPluginConfigs(\n projectRoot: string,\n entries: readonly PluginEntryData[] | undefined,\n verb: string,\n where: string,\n): Promise<void> {\n if (entries === undefined || entries.length === 0) return;\n const schemas = await loadPluginConfigSchemas(projectRoot);\n if (!schemas) return;\n for (const entry of normalizePluginEntries(entries, where)) {\n if (!entryActiveForVerb(entry, verb)) continue;\n const schema = schemas[entry.module];\n if (!isSchemaLike(schema)) continue;\n const parsed = schema.safeParse(entry.config);\n if (parsed.success) continue;\n const issues = parsed.error.issues.map((issue) => {\n const key = [\"config\", ...issue.path.map(String)].join(\".\");\n return ` - ${key}: ${issue.message}`;\n });\n throw new PluginError(\n `${where}: config for plugin \"${entry.module}\" is invalid:\\n${issues.join(\"\\n\")}`,\n );\n }\n}\n\nasync function loadPluginConfigSchemas(\n projectRoot: string,\n): Promise<Record<string, unknown> | undefined> {\n const projectRequire = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n let file: string;\n try {\n file = projectRequire.resolve(PLUGIN_CONFIGS_ENTRY);\n } catch {\n return undefined;\n }\n const module = (await import(pathToFileURL(file).href)) as {\n connectPluginConfigSchemas?: unknown;\n };\n const schemas = module.connectPluginConfigSchemas;\n return typeof schemas === \"object\" && schemas !== null\n ? (schemas as Record<string, unknown>)\n : undefined;\n}\n"],"mappings":";;;;;;;AAaA,MAAM,uBAAuB;;;;;;;;;AAU7B,eAAsB,6BACpB,aACA,SACA,MACA,OACe;CACf,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,GAAG;CACnD,MAAM,UAAU,MAAM,wBAAwB,WAAW;CACzD,IAAI,CAAC,SAAS;CACd,KAAK,MAAM,SAAS,uBAAuB,SAAS,KAAK,GAAG;EAC1D,IAAI,CAAC,mBAAmB,OAAO,IAAI,GAAG;EACtC,MAAM,SAAS,QAAQ,MAAM;EAC7B,IAAI,CAAC,aAAa,MAAM,GAAG;EAC3B,MAAM,SAAS,OAAO,UAAU,MAAM,MAAM;EAC5C,IAAI,OAAO,SAAS;EACpB,MAAM,SAAS,OAAO,MAAM,OAAO,KAAK,UAAU;GAEhD,OAAO,OADK,CAAC,UAAU,GAAG,MAAM,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GACvC,EAAE,IAAI,MAAM;EAC9B,CAAC;EACD,MAAM,IAAI,YACR,GAAG,MAAM,uBAAuB,MAAM,OAAO,iBAAiB,OAAO,KAAK,IAAI,GAChF;CACF;AACF;AAEA,eAAe,wBACb,aAC8C;CAC9C,MAAM,iBAAiB,cACrB,cAAc,KAAK,KAAK,aAAa,cAAc,CAAC,CAAC,CAAC,IACxD;CACA,IAAI;CACJ,IAAI;EACF,OAAO,eAAe,QAAQ,oBAAoB;CACpD,QAAQ;EACN;CACF;CAIA,MAAM,WAAU,MAHM,OAAO,cAAc,IAAI,CAAC,CAAC,MAAA,CAG1B;CACvB,OAAO,OAAO,YAAY,YAAY,YAAY,OAC7C,UACD,KAAA;AACN"}
1
+ {"version":3,"file":"connect-plugin-configs-CPRA8hQJ.mjs","sources":["../src/runners/connect-plugin-configs.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n entryActiveForVerb,\n isSchemaLike,\n normalizePluginEntries,\n PluginError,\n type PluginEntryData,\n} from \"@powerhousedao/host-core\";\n\n/** The zod-only entry Connect publishes with every built-in plugin's entry\n * config schema, keyed by plugin specifier. */\nconst PLUGIN_CONFIGS_ENTRY = \"@powerhousedao/connect/plugin-configs\";\n\n/**\n * Validate the entry configs of the Connect plugins composed for `verb`\n * before Connect boots, so a typo fails at `ph run` naming the plugin and the\n * key instead of at browser boot. The schemas come from the project's own\n * `@powerhousedao/connect/plugin-configs` (resolved from the project tree,\n * like runner and plugin modules); without it, or for a specifier it has no\n * schema for, the browser's own validation stays the only check.\n */\nexport async function validateConnectPluginConfigs(\n projectRoot: string,\n entries: readonly PluginEntryData[] | undefined,\n verb: string,\n where: string,\n): Promise<void> {\n if (entries === undefined || entries.length === 0) return;\n const schemas = await loadPluginConfigSchemas(projectRoot);\n if (!schemas) return;\n for (const entry of normalizePluginEntries(entries, where)) {\n if (!entryActiveForVerb(entry, verb)) continue;\n const schema = schemas[entry.module];\n if (!isSchemaLike(schema)) continue;\n const parsed = schema.safeParse(entry.config);\n if (parsed.success) continue;\n const issues = parsed.error.issues.map((issue) => {\n const key = [\"config\", ...issue.path.map(String)].join(\".\");\n return ` - ${key}: ${issue.message}`;\n });\n throw new PluginError(\n `${where}: config for plugin \"${entry.module}\" is invalid:\\n${issues.join(\"\\n\")}`,\n );\n }\n}\n\nasync function loadPluginConfigSchemas(\n projectRoot: string,\n): Promise<Record<string, unknown> | undefined> {\n const projectRequire = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n let file: string;\n try {\n file = projectRequire.resolve(PLUGIN_CONFIGS_ENTRY);\n } catch {\n return undefined;\n }\n const module = (await import(pathToFileURL(file).href)) as {\n connectPluginConfigSchemas?: unknown;\n };\n const schemas = module.connectPluginConfigSchemas;\n return typeof schemas === \"object\" && schemas !== null\n ? (schemas as Record<string, unknown>)\n : undefined;\n}\n"],"names":[],"mappings":";;;;;;;;;AAaA,MAAM,uBAAuB;;;;;;;;;AAU7B,eAAsB,6BACpB,aACA,SACA,MACA,OACe;CACf,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,GAAG;CACnD,MAAM,UAAU,MAAM,wBAAwB,WAAW;CACzD,IAAI,CAAC,SAAS;CACd,KAAK,MAAM,SAAS,uBAAuB,SAAS,KAAK,GAAG;EAC1D,IAAI,CAAC,mBAAmB,OAAO,IAAI,GAAG;EACtC,MAAM,SAAS,QAAQ,MAAM;EAC7B,IAAI,CAAC,aAAa,MAAM,GAAG;EAC3B,MAAM,SAAS,OAAO,UAAU,MAAM,MAAM;EAC5C,IAAI,OAAO,SAAS;EACpB,MAAM,SAAS,OAAO,MAAM,OAAO,KAAK,UAAU;GAEhD,OAAO,OADK,CAAC,UAAU,GAAG,MAAM,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GACvC,EAAE,IAAI,MAAM;EAC9B,CAAC;EACD,MAAM,IAAI,YACR,GAAG,MAAM,uBAAuB,MAAM,OAAO,iBAAiB,OAAO,KAAK,IAAI,GAChF;CACF;AACF;AAEA,eAAe,wBACb,aAC8C;CAC9C,MAAM,iBAAiB,cACrB,cAAc,KAAK,KAAK,aAAa,cAAc,CAAC,CAAC,CAAC,IACxD;CACA,IAAI;CACJ,IAAI;EACF,OAAO,eAAe,QAAQ,oBAAoB;CACpD,QAAQ;EACN;CACF;CAIA,MAAM,WAAU,MAHM,OAAO,cAAc,IAAI,CAAC,CAAC,MAAA,CAG1B;CACvB,OAAO,OAAO,YAAY,YAAY,YAAY,OAC7C,UACD,KAAA;AACN","debug_id":"343788e5-4606-5080-b02b-274217034899"}
@@ -1,3 +1,5 @@
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]="ef5981b8-2ad0-5e02-946f-95d7ad4685ac")}catch(e){}}();
1
3
  import { isHtmlNavigation, isSwitchboardProxyPath } from "@powerhousedao/shared/connect/origin-placeholder";
2
4
  import path from "node:path";
3
5
  import { existsSync, readFileSync } from "node:fs";
@@ -184,4 +186,5 @@ function connectBaseOf(args, outDirAbs, dirname) {
184
186
  //#endregion
185
187
  export { overrideFromEnv as a, previewCacheControl as c, shellSwapFor as d, stripBase as f, isProxiedRequest as i, resolvePreviewBase as l, cacheHeaders as n, patchCspScriptSrc as o, connectBaseOf as r, precompressedAssets as s, PRECOMPRESS_EXTENSIONS as t, serveOverrideStep as u };
186
188
 
187
- //# sourceMappingURL=connect-serve-0fIQ7xCs.mjs.map
189
+ //# sourceMappingURL=connect-serve-0fIQ7xCs.mjs.map
190
+ //# debugId=ef5981b8-2ad0-5e02-946f-95d7ad4685ac
@@ -1 +1 @@
1
- {"version":3,"file":"connect-serve-0fIQ7xCs.mjs","names":[],"sources":["../src/services/connect-serve.ts"],"sourcesContent":["import { getConfig } from \"@powerhousedao/config/node\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport { deepMerge, normalizeBasePath } from \"@powerhousedao/shared/connect\";\nimport {\n APP_SHELLS_FILE,\n appShellVariant,\n appShellVariantOf,\n readShellPluginsIn,\n swapAppShell,\n withShellAppName,\n type AppShells,\n} from \"@powerhousedao/shared/connect/app-shell\";\nimport {\n isHtmlNavigation,\n isSwitchboardProxyPath,\n} from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport path from \"node:path\";\nimport sirv from \"sirv\";\nimport type { ConnectPreviewArgs } from \"./classic-args.js\";\n\n/**\n * Runtime shaping for a served (built) Connect, desktop shape: the compound\n * projects the live switchboard's drive into the connect member's config, and\n * this override makes the STATIC dist serve it — the built\n * powerhouse.config.json is baked, so without this the drive injection never\n * reaches the SPA. `cspRegistrySync` additionally patches the baked CSP's\n * script-src with the runtime registry (the build bakes the CSP for the\n * registry it was built against; setting the registry at run time breaks that\n * coupling and every package import gets blocked otherwise).\n */\nexport interface ConnectServeOverride {\n connect?: PHConnectRuntimeConfig;\n cspRegistrySync?: boolean;\n /** Overrides the baked top-level packageRegistryUrl in the served config. */\n packageRegistryUrl?: string;\n}\n\n/**\n * The env contract a supervisor can drive the preview with — the same\n * variables the Docker entrypoint and clint's service manager already speak:\n * PH_CONNECT_DEFAULT_DRIVES_URL (comma-separated drive urls, injected into\n * drives.defaultDrives), PH_CONNECT_DRIVES_PRESERVE_STRATEGY, and\n * PH_CONNECT_PACKAGES_REGISTRY (runtime registry: served config + baked-CSP\n * patch). Lets `ph connect preview` replace hand-rolled static servers\n * (clint's connect-server, the ph-win sidecar) without losing injection.\n */\nexport function overrideFromEnv(\n env: Record<string, string | undefined> = process.env,\n): ConnectServeOverride | undefined {\n const drivesUrl = env.PH_CONNECT_DEFAULT_DRIVES_URL;\n const registry = env.PH_CONNECT_PACKAGES_REGISTRY;\n if (!drivesUrl && !registry) return undefined;\n const override: ConnectServeOverride = {};\n if (drivesUrl) {\n override.connect = {\n drives: {\n defaultDrives: drivesUrl\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean)\n .map((url) => ({ url, name: null, icon: null })),\n preserveStrategy:\n env.PH_CONNECT_DRIVES_PRESERVE_STRATEGY ?? \"preserve-all\",\n },\n } as PHConnectRuntimeConfig;\n }\n if (registry) {\n override.packageRegistryUrl = registry;\n override.cspRegistrySync = true;\n }\n return override;\n}\n\nfunction mergedConfigBody(\n outDir: string,\n override: ConnectServeOverride,\n): string {\n const file = path.join(outDir, \"powerhouse.config.json\");\n const baked = existsSync(file)\n ? (JSON.parse(readFileSync(file, \"utf8\")) as Record<string, unknown>)\n : {};\n const connect = override.connect\n ? deepMerge(\n (baked.connect ?? {}) as PHConnectRuntimeConfig,\n override.connect,\n )\n : baked.connect;\n return JSON.stringify({\n ...baked,\n connect,\n ...(override.packageRegistryUrl\n ? { packageRegistryUrl: override.packageRegistryUrl }\n : {}),\n });\n}\n\n/**\n * Append the registry origin to the baked CSP's script-src. The attribute\n * value is HTML-escaped (every CSP keyword is `&#39;`-quoted, which contains a\n * semicolon), so decode before touching directives and re-escape after —\n * ported from the ph-win-desktop sidecar, which this path replaces.\n */\nexport function patchCspScriptSrc(html: string, registryUrl: string): string {\n return html.replace(\n /(<meta\\s+http-equiv=\"Content-Security-Policy\"\\s+content=\")([^\"]*)(\")/i,\n (_match, open: string, escaped: string, close: string) => {\n const policy = escaped.replace(/&amp;/g, \"&\").replace(/&#39;/g, \"'\");\n if (policy.includes(registryUrl)) return open + escaped + close;\n const patched = policy.replace(\n /script-src\\s+([^;]*)/i,\n (_directive, sources: string) =>\n `script-src ${sources.trim()} ${registryUrl}`,\n );\n const reEscaped = patched.replace(/&/g, \"&amp;\").replace(/'/g, \"&#39;\");\n return open + reEscaped + close;\n },\n );\n}\n\n// The serve base: an explicit `--base`, else the basePath the dist was built with.\nexport function resolvePreviewBase(\n argBase: string | undefined,\n outDirAbs: string,\n): string | undefined {\n if (argBase && argBase !== \"/\") return normalizeBasePath(argBase);\n try {\n const built = JSON.parse(\n readFileSync(path.join(outDirAbs, \"powerhouse.config.json\"), \"utf8\"),\n ) as { connect?: { app?: { basePath?: unknown } } };\n const basePath = built.connect?.app?.basePath;\n if (typeof basePath === \"string\" && basePath) {\n return normalizeBasePath(basePath);\n }\n } catch {\n // no readable dist config\n }\n return undefined;\n}\n\n// `pathname` relative to the deploy base (\"/\" + rest), or itself when outside it.\nexport function stripBase(pathname: string, base: string): string {\n return base !== \"/\" && pathname.startsWith(base)\n ? `/${pathname.slice(base.length)}`\n : pathname;\n}\n\n/** The steps both Connect servers run, in the order they run them. */\nexport type ConnectMiddleware = (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void,\n) => void;\n\nconst IMMUTABLE = \"public, max-age=31536000, immutable\";\n\nconst HASHED_DIRS = [\"/assets/\", \"/fonts/\", \"/__reactor_worker__/assets/\"];\n\n// Content-addressed output (hashed names, or a `v` query on the worker's), as in the nginx image.\nexport function previewCacheControl(\n pathname: string,\n search: string,\n): string | undefined {\n if (HASHED_DIRS.some((dir) => pathname.startsWith(dir))) return IMMUTABLE;\n if (pathname.startsWith(\"/__vendor__/\")) {\n return /\\/(shared-deps|import-map)\\.js(on)?$/.test(pathname)\n ? \"no-cache\"\n : IMMUTABLE;\n }\n if (pathname.startsWith(\"/__react__/\")) return IMMUTABLE;\n if (pathname.startsWith(\"/__reactor_worker__/\")) {\n return new URLSearchParams(search).has(\"v\") ? IMMUTABLE : \"no-cache\";\n }\n return undefined;\n}\n\nexport function cacheHeaders(outDir: string, base: string): ConnectMiddleware {\n return (req, res, next) => {\n const [rawPath, search = \"\"] = (req.url ?? \"/\").split(\"?\");\n const rel = stripBase(rawPath, base);\n let value = previewCacheControl(rel, search);\n // A cached 404 would outlive the next deploy.\n if (value === IMMUTABLE && !existsSync(path.join(outDir, rel))) {\n value = undefined;\n }\n if (value) res.setHeader(\"Cache-Control\", value);\n next();\n };\n}\n\ntype HtmlTransform = (html: string) => string;\n\n/** The dist's shell for the served config: its composition's variant and its app name. */\nexport function shellSwapFor(\n outDir: string,\n override: ConnectServeOverride,\n base = \"/\",\n): HtmlTransform | undefined {\n const composition = override.connect?.composition;\n const renamed = override.connect?.branding?.appName !== undefined;\n if (!composition && !renamed) return undefined;\n const file = path.join(outDir, APP_SHELLS_FILE);\n // The manifest the build copied from the Connect it used.\n const variant =\n composition && appShellVariant(composition, readShellPluginsIn(outDir));\n const shell =\n variant && existsSync(file)\n ? (JSON.parse(readFileSync(file, \"utf8\")) as AppShells)[variant]\n : undefined;\n // The name the app will title itself with: the served (baked + override) config's.\n const appName = (\n JSON.parse(mergedConfigBody(outDir, override)) as {\n connect?: { branding?: { appName?: string } };\n }\n ).connect?.branding?.appName;\n return (html) =>\n shell && appShellVariantOf(html) !== variant\n ? swapAppShell(html, shell, base, appName)\n : withShellAppName(html, appName);\n}\n\n/**\n * Whether a request on a proxying server belongs to the switchboard: its\n * paths go to the proxy, untouched, except a browser navigation under `/d/`\n * (Connect's own drive routes), as switchboardProxy splits them.\n */\nexport function isProxiedRequest(urlPath: string, accept: string | undefined) {\n if (!isSwitchboardProxyPath(urlPath)) return false;\n return !(urlPath.startsWith(\"/d/\") && isHtmlNavigation(accept));\n}\n\nexport function serveOverrideStep(\n outDir: string,\n override: ConnectServeOverride,\n base = \"/\",\n swapShell?: HtmlTransform,\n proxied = false,\n): ConnectMiddleware {\n return (req, res, next) => {\n const urlPath = stripBase((req.url ?? \"/\").split(\"?\")[0], base);\n if (urlPath === \"/powerhouse.config.json\") {\n res.writeHead(200, {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store\",\n });\n res.end(mergedConfigBody(outDir, override));\n return;\n }\n // The switchboard's paths are the proxy's, which runs after this:\n // served the SPA shell instead, /graphql would never reach it.\n if (proxied && isProxiedRequest(urlPath, req.headers.accept)) {\n next();\n return;\n }\n // index.html and extensionless SPA routes get the CSP patch.\n const isHtml =\n urlPath === \"/\" ||\n urlPath.endsWith(\"/index.html\") ||\n !path.extname(urlPath);\n if ((override.cspRegistrySync || swapShell) && isHtml) {\n const file = path.join(outDir, \"index.html\");\n if (existsSync(file)) {\n let html = readFileSync(file, \"utf8\");\n if (override.cspRegistrySync) {\n const merged = JSON.parse(mergedConfigBody(outDir, override)) as {\n packageRegistryUrl?: string;\n };\n const registry = merged.packageRegistryUrl;\n if (registry) html = patchCspScriptSrc(html, registry);\n }\n if (swapShell) html = swapShell(html);\n res.writeHead(200, {\n \"content-type\": \"text/html; charset=utf-8\",\n \"cache-control\": \"no-store\",\n });\n res.end(html);\n return;\n }\n }\n next();\n };\n}\n\n/** Extensions whose files have `.gz` siblings. */\nexport const PRECOMPRESS_EXTENSIONS = [\".wasm\", \".data\"] as const;\n\nconst PRECOMPRESSED_TYPES: Record<string, string> = {\n \".wasm\": \"application/wasm\",\n \".data\": \"application/octet-stream\",\n};\n\n// Serves the build's `.gz` siblings of wasm/data, which the main sirv ignores.\nexport function precompressedAssets(\n outDir: string,\n base = \"/\",\n): ConnectMiddleware {\n const serve = sirv(outDir, {\n dev: true,\n etag: true,\n gzip: true,\n extensions: [],\n setHeaders(res, pathname) {\n res.setHeader(\n \"Content-Type\",\n PRECOMPRESSED_TYPES[path.extname(pathname)],\n );\n },\n });\n return (req, res, next) => {\n const url = req.url ?? \"/\";\n const [rawPath, search] = url.split(\"?\");\n const rel = stripBase(rawPath, base);\n // Ranges are byte offsets into the identity body: leave them to the server.\n if (\n !(PRECOMPRESS_EXTENSIONS as readonly string[]).includes(\n path.extname(rel),\n ) ||\n req.headers.range ||\n (base !== \"/\" && rel === rawPath)\n ) {\n next();\n return;\n }\n req.url = search === undefined ? rel : `${rel}?${search}`;\n serve(req, res, () => {\n req.url = url;\n next();\n });\n };\n}\n\n/** The served base: `--base`, else what the dist or the project was built with. */\nexport function connectBaseOf(\n args: Pick<ConnectPreviewArgs, \"connectBasePath\">,\n outDirAbs: string,\n dirname: string,\n): string {\n // Serving a dist needs only its base, not the build's plugin stack.\n const sourceBasePath = getConfig(path.join(dirname, \"powerhouse.config.json\"))\n .connect?.app?.basePath;\n return (\n resolvePreviewBase(args.connectBasePath, outDirAbs) ??\n (sourceBasePath ? normalizeBasePath(sourceBasePath) : \"/\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgDA,SAAgB,gBACd,MAA0C,QAAQ,KAChB;CAClC,MAAM,YAAY,IAAI;CACtB,MAAM,WAAW,IAAI;CACrB,IAAI,CAAC,aAAa,CAAC,UAAU,OAAO,KAAA;CACpC,MAAM,WAAiC,CAAC;CACxC,IAAI,WACF,SAAS,UAAU,EACjB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AAkB,MAAM,QAAQ;IACvD;IACA,IAAI,WAAW,OAAO,UAAU,IAAI;IACpC,IAAI,UAAU,KAAK;KACjB,gBAAgB;KAChB,iBAAiB;IACnB,CAAC;IACD,IAAI,IAAI,IAAI;IACZ;GACF;EACF;EACA,KAAK;CACP;AACF;;AAGA,MAAa,yBAAyB,CAAC,SAAS,OAAO;AAEvD,MAAM,sBAA8C;CAClD,SAAS;CACT,SAAS;AACX;AAGA,SAAgB,oBACd,QACA,OAAO,KACY;CACnB,MAAM,QAAQ,KAAK,QAAQ;EACzB,KAAK;EACL,MAAM;EACN,MAAM;EACN,YAAY,CAAC;EACb,WAAW,KAAK,UAAU;GACxB,IAAI,UACF,gBACA,oBAAoB,KAAK,QAAQ,QAAQ,EAC3C;EACF;CACF,CAAC;CACD,QAAQ,KAAK,KAAK,SAAS;EACzB,MAAM,MAAM,IAAI,OAAO;EACvB,MAAM,CAAC,SAAS,UAAU,IAAI,MAAM,GAAG;EACvC,MAAM,MAAM,UAAU,SAAS,IAAI;EAEnC,IACE,CAAE,uBAA6C,SAC7C,KAAK,QAAQ,GAAG,CAClB,KACA,IAAI,QAAQ,SACX,SAAS,OAAO,QAAQ,SACzB;GACA,KAAK;GACL;EACF;EACA,IAAI,MAAM,WAAW,KAAA,IAAY,MAAM,GAAG,IAAI,GAAG;EACjD,MAAM,KAAK,WAAW;GACpB,IAAI,MAAM;GACV,KAAK;EACP,CAAC;CACH;AACF;;AAGA,SAAgB,cACd,MACA,WACA,SACQ;CAER,MAAM,iBAAiB,UAAU,KAAK,KAAK,SAAS,wBAAwB,CAAC,CAAC,CAC3E,SAAS,KAAK;CACjB,OACE,mBAAmB,KAAK,iBAAiB,SAAS,MACjD,iBAAiB,kBAAkB,cAAc,IAAI;AAE1D"}
1
+ {"version":3,"file":"connect-serve-0fIQ7xCs.mjs","sources":["../src/services/connect-serve.ts"],"sourcesContent":["import { getConfig } from \"@powerhousedao/config/node\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport { deepMerge, normalizeBasePath } from \"@powerhousedao/shared/connect\";\nimport {\n APP_SHELLS_FILE,\n appShellVariant,\n appShellVariantOf,\n readShellPluginsIn,\n swapAppShell,\n withShellAppName,\n type AppShells,\n} from \"@powerhousedao/shared/connect/app-shell\";\nimport {\n isHtmlNavigation,\n isSwitchboardProxyPath,\n} from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport path from \"node:path\";\nimport sirv from \"sirv\";\nimport type { ConnectPreviewArgs } from \"./classic-args.js\";\n\n/**\n * Runtime shaping for a served (built) Connect, desktop shape: the compound\n * projects the live switchboard's drive into the connect member's config, and\n * this override makes the STATIC dist serve it — the built\n * powerhouse.config.json is baked, so without this the drive injection never\n * reaches the SPA. `cspRegistrySync` additionally patches the baked CSP's\n * script-src with the runtime registry (the build bakes the CSP for the\n * registry it was built against; setting the registry at run time breaks that\n * coupling and every package import gets blocked otherwise).\n */\nexport interface ConnectServeOverride {\n connect?: PHConnectRuntimeConfig;\n cspRegistrySync?: boolean;\n /** Overrides the baked top-level packageRegistryUrl in the served config. */\n packageRegistryUrl?: string;\n}\n\n/**\n * The env contract a supervisor can drive the preview with — the same\n * variables the Docker entrypoint and clint's service manager already speak:\n * PH_CONNECT_DEFAULT_DRIVES_URL (comma-separated drive urls, injected into\n * drives.defaultDrives), PH_CONNECT_DRIVES_PRESERVE_STRATEGY, and\n * PH_CONNECT_PACKAGES_REGISTRY (runtime registry: served config + baked-CSP\n * patch). Lets `ph connect preview` replace hand-rolled static servers\n * (clint's connect-server, the ph-win sidecar) without losing injection.\n */\nexport function overrideFromEnv(\n env: Record<string, string | undefined> = process.env,\n): ConnectServeOverride | undefined {\n const drivesUrl = env.PH_CONNECT_DEFAULT_DRIVES_URL;\n const registry = env.PH_CONNECT_PACKAGES_REGISTRY;\n if (!drivesUrl && !registry) return undefined;\n const override: ConnectServeOverride = {};\n if (drivesUrl) {\n override.connect = {\n drives: {\n defaultDrives: drivesUrl\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean)\n .map((url) => ({ url, name: null, icon: null })),\n preserveStrategy:\n env.PH_CONNECT_DRIVES_PRESERVE_STRATEGY ?? \"preserve-all\",\n },\n } as PHConnectRuntimeConfig;\n }\n if (registry) {\n override.packageRegistryUrl = registry;\n override.cspRegistrySync = true;\n }\n return override;\n}\n\nfunction mergedConfigBody(\n outDir: string,\n override: ConnectServeOverride,\n): string {\n const file = path.join(outDir, \"powerhouse.config.json\");\n const baked = existsSync(file)\n ? (JSON.parse(readFileSync(file, \"utf8\")) as Record<string, unknown>)\n : {};\n const connect = override.connect\n ? deepMerge(\n (baked.connect ?? {}) as PHConnectRuntimeConfig,\n override.connect,\n )\n : baked.connect;\n return JSON.stringify({\n ...baked,\n connect,\n ...(override.packageRegistryUrl\n ? { packageRegistryUrl: override.packageRegistryUrl }\n : {}),\n });\n}\n\n/**\n * Append the registry origin to the baked CSP's script-src. The attribute\n * value is HTML-escaped (every CSP keyword is `&#39;`-quoted, which contains a\n * semicolon), so decode before touching directives and re-escape after —\n * ported from the ph-win-desktop sidecar, which this path replaces.\n */\nexport function patchCspScriptSrc(html: string, registryUrl: string): string {\n return html.replace(\n /(<meta\\s+http-equiv=\"Content-Security-Policy\"\\s+content=\")([^\"]*)(\")/i,\n (_match, open: string, escaped: string, close: string) => {\n const policy = escaped.replace(/&amp;/g, \"&\").replace(/&#39;/g, \"'\");\n if (policy.includes(registryUrl)) return open + escaped + close;\n const patched = policy.replace(\n /script-src\\s+([^;]*)/i,\n (_directive, sources: string) =>\n `script-src ${sources.trim()} ${registryUrl}`,\n );\n const reEscaped = patched.replace(/&/g, \"&amp;\").replace(/'/g, \"&#39;\");\n return open + reEscaped + close;\n },\n );\n}\n\n// The serve base: an explicit `--base`, else the basePath the dist was built with.\nexport function resolvePreviewBase(\n argBase: string | undefined,\n outDirAbs: string,\n): string | undefined {\n if (argBase && argBase !== \"/\") return normalizeBasePath(argBase);\n try {\n const built = JSON.parse(\n readFileSync(path.join(outDirAbs, \"powerhouse.config.json\"), \"utf8\"),\n ) as { connect?: { app?: { basePath?: unknown } } };\n const basePath = built.connect?.app?.basePath;\n if (typeof basePath === \"string\" && basePath) {\n return normalizeBasePath(basePath);\n }\n } catch {\n // no readable dist config\n }\n return undefined;\n}\n\n// `pathname` relative to the deploy base (\"/\" + rest), or itself when outside it.\nexport function stripBase(pathname: string, base: string): string {\n return base !== \"/\" && pathname.startsWith(base)\n ? `/${pathname.slice(base.length)}`\n : pathname;\n}\n\n/** The steps both Connect servers run, in the order they run them. */\nexport type ConnectMiddleware = (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void,\n) => void;\n\nconst IMMUTABLE = \"public, max-age=31536000, immutable\";\n\nconst HASHED_DIRS = [\"/assets/\", \"/fonts/\", \"/__reactor_worker__/assets/\"];\n\n// Content-addressed output (hashed names, or a `v` query on the worker's), as in the nginx image.\nexport function previewCacheControl(\n pathname: string,\n search: string,\n): string | undefined {\n if (HASHED_DIRS.some((dir) => pathname.startsWith(dir))) return IMMUTABLE;\n if (pathname.startsWith(\"/__vendor__/\")) {\n return /\\/(shared-deps|import-map)\\.js(on)?$/.test(pathname)\n ? \"no-cache\"\n : IMMUTABLE;\n }\n if (pathname.startsWith(\"/__react__/\")) return IMMUTABLE;\n if (pathname.startsWith(\"/__reactor_worker__/\")) {\n return new URLSearchParams(search).has(\"v\") ? IMMUTABLE : \"no-cache\";\n }\n return undefined;\n}\n\nexport function cacheHeaders(outDir: string, base: string): ConnectMiddleware {\n return (req, res, next) => {\n const [rawPath, search = \"\"] = (req.url ?? \"/\").split(\"?\");\n const rel = stripBase(rawPath, base);\n let value = previewCacheControl(rel, search);\n // A cached 404 would outlive the next deploy.\n if (value === IMMUTABLE && !existsSync(path.join(outDir, rel))) {\n value = undefined;\n }\n if (value) res.setHeader(\"Cache-Control\", value);\n next();\n };\n}\n\ntype HtmlTransform = (html: string) => string;\n\n/** The dist's shell for the served config: its composition's variant and its app name. */\nexport function shellSwapFor(\n outDir: string,\n override: ConnectServeOverride,\n base = \"/\",\n): HtmlTransform | undefined {\n const composition = override.connect?.composition;\n const renamed = override.connect?.branding?.appName !== undefined;\n if (!composition && !renamed) return undefined;\n const file = path.join(outDir, APP_SHELLS_FILE);\n // The manifest the build copied from the Connect it used.\n const variant =\n composition && appShellVariant(composition, readShellPluginsIn(outDir));\n const shell =\n variant && existsSync(file)\n ? (JSON.parse(readFileSync(file, \"utf8\")) as AppShells)[variant]\n : undefined;\n // The name the app will title itself with: the served (baked + override) config's.\n const appName = (\n JSON.parse(mergedConfigBody(outDir, override)) as {\n connect?: { branding?: { appName?: string } };\n }\n ).connect?.branding?.appName;\n return (html) =>\n shell && appShellVariantOf(html) !== variant\n ? swapAppShell(html, shell, base, appName)\n : withShellAppName(html, appName);\n}\n\n/**\n * Whether a request on a proxying server belongs to the switchboard: its\n * paths go to the proxy, untouched, except a browser navigation under `/d/`\n * (Connect's own drive routes), as switchboardProxy splits them.\n */\nexport function isProxiedRequest(urlPath: string, accept: string | undefined) {\n if (!isSwitchboardProxyPath(urlPath)) return false;\n return !(urlPath.startsWith(\"/d/\") && isHtmlNavigation(accept));\n}\n\nexport function serveOverrideStep(\n outDir: string,\n override: ConnectServeOverride,\n base = \"/\",\n swapShell?: HtmlTransform,\n proxied = false,\n): ConnectMiddleware {\n return (req, res, next) => {\n const urlPath = stripBase((req.url ?? \"/\").split(\"?\")[0], base);\n if (urlPath === \"/powerhouse.config.json\") {\n res.writeHead(200, {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store\",\n });\n res.end(mergedConfigBody(outDir, override));\n return;\n }\n // The switchboard's paths are the proxy's, which runs after this:\n // served the SPA shell instead, /graphql would never reach it.\n if (proxied && isProxiedRequest(urlPath, req.headers.accept)) {\n next();\n return;\n }\n // index.html and extensionless SPA routes get the CSP patch.\n const isHtml =\n urlPath === \"/\" ||\n urlPath.endsWith(\"/index.html\") ||\n !path.extname(urlPath);\n if ((override.cspRegistrySync || swapShell) && isHtml) {\n const file = path.join(outDir, \"index.html\");\n if (existsSync(file)) {\n let html = readFileSync(file, \"utf8\");\n if (override.cspRegistrySync) {\n const merged = JSON.parse(mergedConfigBody(outDir, override)) as {\n packageRegistryUrl?: string;\n };\n const registry = merged.packageRegistryUrl;\n if (registry) html = patchCspScriptSrc(html, registry);\n }\n if (swapShell) html = swapShell(html);\n res.writeHead(200, {\n \"content-type\": \"text/html; charset=utf-8\",\n \"cache-control\": \"no-store\",\n });\n res.end(html);\n return;\n }\n }\n next();\n };\n}\n\n/** Extensions whose files have `.gz` siblings. */\nexport const PRECOMPRESS_EXTENSIONS = [\".wasm\", \".data\"] as const;\n\nconst PRECOMPRESSED_TYPES: Record<string, string> = {\n \".wasm\": \"application/wasm\",\n \".data\": \"application/octet-stream\",\n};\n\n// Serves the build's `.gz` siblings of wasm/data, which the main sirv ignores.\nexport function precompressedAssets(\n outDir: string,\n base = \"/\",\n): ConnectMiddleware {\n const serve = sirv(outDir, {\n dev: true,\n etag: true,\n gzip: true,\n extensions: [],\n setHeaders(res, pathname) {\n res.setHeader(\n \"Content-Type\",\n PRECOMPRESSED_TYPES[path.extname(pathname)],\n );\n },\n });\n return (req, res, next) => {\n const url = req.url ?? \"/\";\n const [rawPath, search] = url.split(\"?\");\n const rel = stripBase(rawPath, base);\n // Ranges are byte offsets into the identity body: leave them to the server.\n if (\n !(PRECOMPRESS_EXTENSIONS as readonly string[]).includes(\n path.extname(rel),\n ) ||\n req.headers.range ||\n (base !== \"/\" && rel === rawPath)\n ) {\n next();\n return;\n }\n req.url = search === undefined ? rel : `${rel}?${search}`;\n serve(req, res, () => {\n req.url = url;\n next();\n });\n };\n}\n\n/** The served base: `--base`, else what the dist or the project was built with. */\nexport function connectBaseOf(\n args: Pick<ConnectPreviewArgs, \"connectBasePath\">,\n outDirAbs: string,\n dirname: string,\n): string {\n // Serving a dist needs only its base, not the build's plugin stack.\n const sourceBasePath = getConfig(path.join(dirname, \"powerhouse.config.json\"))\n .connect?.app?.basePath;\n return (\n resolvePreviewBase(args.connectBasePath, outDirAbs) ??\n (sourceBasePath ? normalizeBasePath(sourceBasePath) : \"/\")\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,gBACd,MAA0C,QAAQ,KAChB;CAClC,MAAM,YAAY,IAAI;CACtB,MAAM,WAAW,IAAI;CACrB,IAAI,CAAC,aAAa,CAAC,UAAU,OAAO,KAAA;CACpC,MAAM,WAAiC,CAAC;CACxC,IAAI,WACF,SAAS,UAAU,EACjB,QAAQ;EACN,eAAe,UACZ,MAAM,GAAG,CAAC,CACV,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,CACpB,OAAO,OAAO,CAAC,CACf,KAAK,SAAS;GAAE;GAAK,MAAM;GAAM,MAAM;EAAK,EAAE;EACjD,kBACE,IAAI,uCAAuC;CAC/C,EACF;CAEF,IAAI,UAAU;EACZ,SAAS,qBAAqB;EAC9B,SAAS,kBAAkB;CAC7B;CACA,OAAO;AACT;AAEA,SAAS,iBACP,QACA,UACQ;CACR,MAAM,OAAO,KAAK,KAAK,QAAQ,wBAAwB;CACvD,MAAM,QAAQ,WAAW,IAAI,IACxB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,IACtC,CAAC;CACL,MAAM,UAAU,SAAS,UACrB,UACG,MAAM,WAAW,CAAC,GACnB,SAAS,OACX,IACA,MAAM;CACV,OAAO,KAAK,UAAU;EACpB,GAAG;EACH;EACA,GAAI,SAAS,qBACT,EAAE,oBAAoB,SAAS,mBAAmB,IAClD,CAAC;CACP,CAAC;AACH;;;;;;;AAQA,SAAgB,kBAAkB,MAAc,aAA6B;CAC3E,OAAO,KAAK,QACV,0EACC,QAAQ,MAAc,SAAiB,UAAkB;EACxD,MAAM,SAAS,QAAQ,QAAQ,UAAU,GAAG,CAAC,CAAC,QAAQ,UAAU,GAAG;EACnE,IAAI,OAAO,S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W;GACpB,IAAI,MAAM;GACV,KAAK;EACP,CAAC;CACH;AACF;;AAGA,SAAgB,cACd,MACA,WACA,SACQ;CAER,MAAM,iBAAiB,UAAU,KAAK,KAAK,SAAS,wBAAwB,CAAC,CAAC,CAC3E,SAAS,KAAK;CACjB,OACE,mBAAmB,KAAK,iBAAiB,SAAS,MACjD,iBAAiB,kBAAkB,cAAc,IAAI;AAE1D","debug_id":"ef5981b8-2ad0-5e02-946f-95d7ad4685ac"}
@@ -1,3 +1,5 @@
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]="397b5602-ebe3-50b3-89af-8add364d7c0d")}catch(e){}}();
1
3
  import { assertProtocolConsistency, primaryBackend, protocolEnv, reactorBlockToSwitchboardConfig } from "@powerhousedao/host-core";
2
4
  import path from "node:path";
3
5
  import fs from "node:fs";
@@ -149,4 +151,5 @@ function switchboardDevMode(devVerb, runner) {
149
151
  //#endregion
150
152
  export { prepareMemberStorage as a, rememberShellNames as c, overlappingKeys as i, switchboardDevMode as l, memberSwitchboardConfig as n, reactorBlockConflicts as o, memberSwitchboardConfigSchema as r, readModelAsReactorStore as s, memberEnvOf as t };
151
153
 
152
- //# sourceMappingURL=member-config-BcEWRVq4.mjs.map
154
+ //# sourceMappingURL=member-config-BcEWRVq4.mjs.map
155
+ //# debugId=397b5602-ebe3-50b3-89af-8add364d7c0d
@@ -1 +1 @@
1
- {"version":3,"file":"member-config-BcEWRVq4.mjs","names":[],"sources":["../src/runners/member-config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n assertProtocolConsistency,\n primaryBackend,\n protocolEnv,\n reactorBlockToSwitchboardConfig,\n type ReactorConfig,\n} from \"@powerhousedao/host-core\";\nimport {\n mergeSwitchboardConfig,\n switchboardConfigLayerSchema,\n type SwitchboardConfigInput,\n} from \"@powerhousedao/switchboard/config\";\nimport {\n envNamesBeforeProjectEnv,\n isDotenvDisabled,\n} from \"@powerhousedao/shared/clis/project-env\";\nimport type { ILogger } from \"document-model\";\nimport dotenv from \"dotenv\";\n\ntype Env = Readonly<Record<string, string | undefined>>;\n\n/** The operator's env, split by where each value came from. */\nexport interface MemberEnv {\n /** Set by the shell: wins over the host file. */\n shell: Env;\n /** Only in the project `.env`: the host file's keys win over these. */\n dotenv: Env;\n}\n\n// The server's dotenv.config() ignores a file it cannot read.\nfunction readDotenv(cwd: string): Record<string, string> {\n try {\n return dotenv.parse(fs.readFileSync(path.join(cwd, \".env\")));\n } catch {\n return {};\n }\n}\n\nconst shellNamesByEnv = new WeakMap<object, ReadonlySet<string>>();\n\n/** Records which names of `env` the shell set, before a `.env` loads into it. */\nexport function rememberShellNames(env: Env, names: Iterable<string>): void {\n shellNamesByEnv.set(env, new Set(names));\n}\n\n// Taken the first time an env is seen: before the first member's server\n// import loads the .env into it, and reused for every later member.\nfunction shellNamesOf(env: Env): ReadonlySet<string> {\n let names = shellNamesByEnv.get(env);\n if (!names) {\n names =\n (env === process.env ? envNamesBeforeProjectEnv() : undefined) ??\n new Set(Object.keys(env));\n shellNamesByEnv.set(env, names);\n }\n return names;\n}\n\n/**\n * Splits `env` into the shell's values and the `.env` the switchboard server\n * loads from `cwd` (the same file). A name the shell set stays the shell's,\n * whatever the file says.\n */\nexport function memberEnvOf(env: Env, cwd: string = process.cwd()): MemberEnv {\n const file = isDotenvDisabled({ ...env }) ? {} : readDotenv(cwd);\n const shellNames = shellNamesOf(env);\n const shell: Record<string, string | undefined> = {};\n for (const [name, value] of Object.entries(env)) {\n if (file[name] === undefined || shellNames.has(name)) shell[name] = value;\n }\n const fromFile: Record<string, string> = {};\n for (const [name, value] of Object.entries(file)) {\n if (!shellNames.has(name)) fromFile[name] = value;\n }\n return { shell, dotenv: fromFile };\n}\n\n/** The env vars the block sets, which a `.env` value does not override. */\nfunction blockEnvNames(reactor: ReactorConfig | undefined): string[] {\n const block = reactorBlockToSwitchboardConfig(reactor);\n return [\n ...Object.keys(protocolEnv(reactor?.protocol)),\n ...(block.packages?.dynamic ? [\"DYNAMIC_MODEL_LOADING\"] : []),\n ...(block.features ? [\"PH_WORKFLOWS_ENABLED\"] : []),\n ];\n}\n\n/** `config.switchboard`: a member's own switchboard config. The omitted keys\n * live in the reactor block (storage, protocol, dynamic packages) or the\n * runner (port, dev verb, drives, plugins), or are process-wide or not JSON. */\nexport const memberSwitchboardConfigSchema = switchboardConfigLayerSchema([\n \"logLevel\",\n \"server.port\",\n \"server.dev\",\n \"storage.reactor\",\n \"storage.readModel\",\n \"protocol\",\n \"telemetry\",\n \"packages.dynamic\",\n \"drive\",\n \"remoteDrives\",\n \"features.pluginHost\",\n \"processorConfig\",\n]);\n\nexport interface SwitchboardMember {\n reactor?: ReactorConfig;\n config?: { switchboard?: SwitchboardConfigInput };\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\n/** The dotted keys both layers set. */\nexport function overlappingKeys(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n path = \"\",\n): string[] {\n return Object.entries(b).flatMap(([key, value]) => {\n const other = a[key];\n if (value === undefined || other === undefined) return [];\n const at = path ? `${path}.${key}` : key;\n return isPlainObject(value) && isPlainObject(other)\n ? overlappingKeys(other, value, at)\n : [at];\n });\n}\n\n/** Each `config.switchboard` key the reactor block already sets. */\nexport function reactorBlockConflicts(member: SwitchboardMember): string[] {\n const own = member.config?.switchboard;\n if (!own) return [];\n return overlappingKeys(\n reactorBlockToSwitchboardConfig(member.reactor) as Record<string, unknown>,\n own as Record<string, unknown>,\n ).map(\n (key) =>\n `config.switchboard.${key} is also set by the reactor block; set it in one place.`,\n );\n}\n\n/**\n * The deprecation notice for a block whose `readModel.url` still names the\n * reactor store too: nothing else names the store, as it did when\n * readModel.url rode `dbPath`.\n */\nexport function readModelAsReactorStore(\n reactor: ReactorConfig | undefined,\n env: Env,\n hostFileLabel: string,\n): { url: string; warning: string } | undefined {\n const storage = reactorBlockToSwitchboardConfig(reactor).storage;\n const url = storage?.readModel?.url;\n if (\n !url ||\n storage.reactor ||\n env.PH_REACTOR_DATABASE_URL !== undefined ||\n env.PH_SWITCHBOARD_DATABASE_URL !== undefined\n ) {\n return undefined;\n }\n return {\n url,\n warning:\n `${hostFileLabel}: reactor readModel.url (${url}) also holds the reactor store, because no storage names one. ` +\n \"This is deprecated: set the backend's storage explicitly (the same Postgres url, or a path dataDir).\",\n };\n}\n\n/**\n * The member's switchboard config under the runner's own arguments: its\n * reactor block, then `config.switchboard`, then the env over both, mapped\n * once as the server read it (the shell over the `.env`, whose values for the\n * block's own vars are dropped). The block keeps the precedence it had as\n * set-if-absent env and `dbPath`: only a shell PH_REACTOR_DATABASE_URL\n * overrides its store, and no env var overrides its read model. Writes nothing.\n */\nexport async function memberSwitchboardConfig(\n member: SwitchboardMember,\n env: MemberEnv,\n options: {\n pluginHost: boolean;\n logger?: ILogger;\n /** Under everything else: values no flag or host file set. */\n defaults?: SwitchboardConfigInput;\n },\n): Promise<SwitchboardConfigInput> {\n // Lazy: the env mapping loads reactor-api, which the runner module must not.\n const { switchboardConfigFromEnv } =\n await import(\"@powerhousedao/switchboard/config/env\");\n const block = reactorBlockToSwitchboardConfig(member.reactor);\n const legacy = readModelAsReactorStore(member.reactor, env.shell, \"\");\n if (legacy) {\n block.storage = { ...block.storage, reactor: { url: legacy.url } };\n }\n // One env, as the server read it: the .env under the block's own vars,\n // the shell over both.\n const dotenvValues: Record<string, string | undefined> = { ...env.dotenv };\n for (const name of blockEnvNames(member.reactor)) delete dotenvValues[name];\n const fromEnv = switchboardConfigFromEnv(\n { ...dotenvValues, ...env.shell },\n { logger: options.logger },\n );\n const storage = { ...fromEnv.storage };\n if (\n block.storage?.reactor &&\n env.shell.PH_REACTOR_DATABASE_URL === undefined\n ) {\n delete storage.reactor;\n }\n if (block.storage?.readModel) delete storage.readModel;\n return mergeSwitchboardConfig(\n options.defaults ?? {},\n block,\n member.config?.switchboard ?? {},\n { ...fromEnv, storage },\n // A declared composition turns the plugin host on, whatever the env says.\n options.pluginHost ? { features: { pluginHost: true } } : {},\n );\n}\n\n/**\n * Fails when the operator's env contradicts the member's protocol block, then\n * creates the block's path-storage dir (the server's own mkdir is not\n * recursive).\n */\nexport function prepareMemberStorage(\n reactor: ReactorConfig | undefined,\n env: Env,\n hostFileLabel: string,\n): void {\n assertProtocolConsistency(reactor?.protocol, { ...env }, hostFileLabel);\n const storage = primaryBackend(reactor)?.storage;\n if (storage?.kind !== \"path\" || !storage.dataDir) return;\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\n/** The verb owns dev mode; `runner.dev` is the host-file spelling of it. */\nexport function switchboardDevMode(\n devVerb: boolean,\n runner: { dev?: boolean },\n): boolean {\n return devVerb || runner.dev === true;\n}\n"],"mappings":";;;;;;;AAgCA,SAAS,WAAW,KAAqC;CACvD,IAAI;EACF,OAAO,OAAO,MAAM,GAAG,aAAa,KAAK,KAAK,KAAK,MAAM,CAAC,CAAC;CAC7D,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,MAAM,kCAAkB,IAAI,QAAqC;;AAGjE,SAAgB,mBAAmB,KAAU,OAA+B;CAC1E,gBAAgB,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC;AACzC;AAIA,SAAS,aAAa,KAA+B;CACnD,IAAI,QAAQ,gBAAgB,IAAI,GAAG;CACnC,IAAI,CAAC,OAAO;EACV,SACG,QAAQ,QAAQ,MAAM,yBA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tC,OAAO,QAAQ;CAEjB,IAAI,MAAM,SAAS,WAAW,OAAO,QAAQ;CAC7C,OAAO,uBACL,QAAQ,YAAY,CAAC,GACrB,OACA,OAAO,QAAQ,eAAe,CAAC,GAC/B;EAAE,GAAG;EAAS;CAAQ,GAEtB,QAAQ,aAAa,EAAE,UAAU,EAAE,YAAY,KAAK,EAAE,IAAI,CAAC,CAC7D;AACF;;;;;;AAOA,SAAgB,qBACd,SACA,KACA,eACM;CACN,0BAA0B,SAAS,UAAU,EAAE,GAAG,IAAI,GAAG,aAAa;CACtE,MAAM,UAAU,eAAe,OAAO,CAAC,EAAE;CACzC,IAAI,SAAS,SAAS,UAAU,CAAC,QAAQ,SAAS;CAGlD,IAAI,+BAA+B,KAAK,QAAQ,OAAO,GACrD,MAAM,IAAI,MACR,GAAG,cAAc,qBAAqB,QAAQ,QAAQ,8EACxD;CAEF,GAAG,UAAU,QAAQ,SAAS,EAAE,WAAW,KAAK,CAAC;AACnD;;AAGA,SAAgB,mBACd,SACA,QACS;CACT,OAAO,WAAW,OAAO,QAAQ;AACnC"}
1
+ {"version":3,"file":"member-config-BcEWRVq4.mjs","sources":["../src/runners/member-config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n assertProtocolConsistency,\n primaryBackend,\n protocolEnv,\n reactorBlockToSwitchboardConfig,\n type ReactorConfig,\n} from \"@powerhousedao/host-core\";\nimport {\n mergeSwitchboardConfig,\n switchboardConfigLayerSchema,\n type SwitchboardConfigInput,\n} from \"@powerhousedao/switchboard/config\";\nimport {\n envNamesBeforeProjectEnv,\n isDotenvDisabled,\n} from \"@powerhousedao/shared/clis/project-env\";\nimport type { ILogger } from \"document-model\";\nimport dotenv from \"dotenv\";\n\ntype Env = Readonly<Record<string, string | undefined>>;\n\n/** The operator's env, split by where each value came from. */\nexport interface MemberEnv {\n /** Set by the shell: wins over the host file. */\n shell: Env;\n /** Only in the project `.env`: the host file's keys win over these. */\n dotenv: Env;\n}\n\n// The server's dotenv.config() ignores a file it cannot read.\nfunction readDotenv(cwd: string): Record<string, string> {\n try {\n return dotenv.parse(fs.readFileSync(path.join(cwd, \".env\")));\n } catch {\n return {};\n }\n}\n\nconst shellNamesByEnv = new WeakMap<object, ReadonlySet<string>>();\n\n/** Records which names of `env` the shell set, before a `.env` loads into it. */\nexport function rememberShellNames(env: Env, names: Iterable<string>): void {\n shellNamesByEnv.set(env, new Set(names));\n}\n\n// Taken the first time an env is seen: before the first member's server\n// import loads the .env into it, and reused for every later member.\nfunction shellNamesOf(env: Env): ReadonlySet<string> {\n let names = shellNamesByEnv.get(env);\n if (!names) {\n names =\n (env === process.env ? envNamesBeforeProjectEnv() : undefined) ??\n new Set(Object.keys(env));\n shellNamesByEnv.set(env, names);\n }\n return names;\n}\n\n/**\n * Splits `env` into the shell's values and the `.env` the switchboard server\n * loads from `cwd` (the same file). A name the shell set stays the shell's,\n * whatever the file says.\n */\nexport function memberEnvOf(env: Env, cwd: string = process.cwd()): MemberEnv {\n const file = isDotenvDisabled({ ...env }) ? {} : readDotenv(cwd);\n const shellNames = shellNamesOf(env);\n const shell: Record<string, string | undefined> = {};\n for (const [name, value] of Object.entries(env)) {\n if (file[name] === undefined || shellNames.has(name)) shell[name] = value;\n }\n const fromFile: Record<string, string> = {};\n for (const [name, value] of Object.entries(file)) {\n if (!shellNames.has(name)) fromFile[name] = value;\n }\n return { shell, dotenv: fromFile };\n}\n\n/** The env vars the block sets, which a `.env` value does not override. */\nfunction blockEnvNames(reactor: ReactorConfig | undefined): string[] {\n const block = reactorBlockToSwitchboardConfig(reactor);\n return [\n ...Object.keys(protocolEnv(reactor?.protocol)),\n ...(block.packages?.dynamic ? [\"DYNAMIC_MODEL_LOADING\"] : []),\n ...(block.features ? [\"PH_WORKFLOWS_ENABLED\"] : []),\n ];\n}\n\n/** `config.switchboard`: a member's own switchboard config. The omitted keys\n * live in the reactor block (storage, protocol, dynamic packages) or the\n * runner (port, dev verb, drives, plugins), or are process-wide or not JSON. */\nexport const memberSwitchboardConfigSchema = switchboardConfigLayerSchema([\n \"logLevel\",\n \"server.port\",\n \"server.dev\",\n \"storage.reactor\",\n \"storage.readModel\",\n \"protocol\",\n \"telemetry\",\n \"packages.dynamic\",\n \"drive\",\n \"remoteDrives\",\n \"features.pluginHost\",\n \"processorConfig\",\n]);\n\nexport interface SwitchboardMember {\n reactor?: ReactorConfig;\n config?: { switchboard?: SwitchboardConfigInput };\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\n/** The dotted keys both layers set. */\nexport function overlappingKeys(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n path = \"\",\n): string[] {\n return Object.entries(b).flatMap(([key, value]) => {\n const other = a[key];\n if (value === undefined || other === undefined) return [];\n const at = path ? `${path}.${key}` : key;\n return isPlainObject(value) && isPlainObject(other)\n ? overlappingKeys(other, value, at)\n : [at];\n });\n}\n\n/** Each `config.switchboard` key the reactor block already sets. */\nexport function reactorBlockConflicts(member: SwitchboardMember): string[] {\n const own = member.config?.switchboard;\n if (!own) return [];\n return overlappingKeys(\n reactorBlockToSwitchboardConfig(member.reactor) as Record<string, unknown>,\n own as Record<string, unknown>,\n ).map(\n (key) =>\n `config.switchboard.${key} is also set by the reactor block; set it in one place.`,\n );\n}\n\n/**\n * The deprecation notice for a block whose `readModel.url` still names the\n * reactor store too: nothing else names the store, as it did when\n * readModel.url rode `dbPath`.\n */\nexport function readModelAsReactorStore(\n reactor: ReactorConfig | undefined,\n env: Env,\n hostFileLabel: string,\n): { url: string; warning: string } | undefined {\n const storage = reactorBlockToSwitchboardConfig(reactor).storage;\n const url = storage?.readModel?.url;\n if (\n !url ||\n storage.reactor ||\n env.PH_REACTOR_DATABASE_URL !== undefined ||\n env.PH_SWITCHBOARD_DATABASE_URL !== undefined\n ) {\n return undefined;\n }\n return {\n url,\n warning:\n `${hostFileLabel}: reactor readModel.url (${url}) also holds the reactor store, because no storage names one. ` +\n \"This is deprecated: set the backend's storage explicitly (the same Postgres url, or a path dataDir).\",\n };\n}\n\n/**\n * The member's switchboard config under the runner's own arguments: its\n * reactor block, then `config.switchboard`, then the env over both, mapped\n * once as the server read it (the shell over the `.env`, whose values for the\n * block's own vars are dropped). The block keeps the precedence it had as\n * set-if-absent env and `dbPath`: only a shell PH_REACTOR_DATABASE_URL\n * overrides its store, and no env var overrides its read model. Writes nothing.\n */\nexport async function memberSwitchboardConfig(\n member: SwitchboardMember,\n env: MemberEnv,\n options: {\n pluginHost: boolean;\n logger?: ILogger;\n /** Under everything else: values no flag or host file set. */\n defaults?: SwitchboardConfigInput;\n },\n): Promise<SwitchboardConfigInput> {\n // Lazy: the env mapping loads reactor-api, which the runner module must not.\n const { switchboardConfigFromEnv } =\n await import(\"@powerhousedao/switchboard/config/env\");\n const block = reactorBlockToSwitchboardConfig(member.reactor);\n const legacy = readModelAsReactorStore(member.reactor, env.shell, \"\");\n if (legacy) {\n block.storage = { ...block.storage, reactor: { url: legacy.url } };\n }\n // One env, as the server read it: the .env under the block's own vars,\n // the shell over both.\n const dotenvValues: Record<string, string | undefined> = { ...env.dotenv };\n for (const name of blockEnvNames(member.reactor)) delete dotenvValues[name];\n const fromEnv = switchboardConfigFromEnv(\n { ...dotenvValues, ...env.shell },\n { logger: options.logger },\n );\n const storage = { ...fromEnv.storage };\n if (\n block.storage?.reactor &&\n env.shell.PH_REACTOR_DATABASE_URL === undefined\n ) {\n delete storage.reactor;\n }\n if (block.storage?.readModel) delete storage.readModel;\n return mergeSwitchboardConfig(\n options.defaults ?? {},\n block,\n member.config?.switchboard ?? {},\n { ...fromEnv, storage },\n // A declared composition turns the plugin host on, whatever the env says.\n options.pluginHost ? { features: { pluginHost: true } } : {},\n );\n}\n\n/**\n * Fails when the operator's env contradicts the member's protocol block, then\n * creates the block's path-storage dir (the server's own mkdir is not\n * recursive).\n */\nexport function prepareMemberStorage(\n reactor: ReactorConfig | undefined,\n env: Env,\n hostFileLabel: string,\n): void {\n assertProtocolConsistency(reactor?.protocol, { ...env }, hostFileLabel);\n const storage = primaryBackend(reactor)?.storage;\n if (storage?.kind !== \"path\" || !storage.dataDir) return;\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\n/** The verb owns dev mode; `runner.dev` is the host-file spelling of it. */\nexport function switchboardDevMode(\n devVerb: boolean,\n runner: { dev?: boolean },\n): boolean {\n return devVerb || runner.dev === true;\n}\n"],"names":[],"mappings":";;;;;;;;;AAgCA,SAAS,WAAW,KAAqC;CACvD,IAAI;EACF,OAAO,OAAO,MAAM,GAAG,aAAa,KAAK,KAAK,KAAK,MAAM,CAAC,CAAC;CAC7D,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,MAAM,kCAAkB,IAAI,QAAqC;;AAGjE,SAAgB,mBAAmB,KAAU,OAA+B;CAC1E,gBAAgB,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC;AACzC;AAIA,SAAS,aAAa,KAA+B;CACnD,IAAI,QAAQ,gBAAgB,IAAI,GAAG;CACnC,IAAI,CAAC,OAAO;EACV,SACG,QAAQ,QAAQ,MAAM,yBAAyB,IAAI,KAAA,MACpD,IAAI,IAAI,OAAO,KAAK,GAAG,CAAC;EAC1B,gBAAgB,IAAI,KAAK,KAAK;CAChC;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,KAAU,MAAc,QAAQ,IAAI,GAAc;CAC5E,MAAM,OAAO,iBAAiB,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,WAAW,GAAG;CAC/D,MAAM,aAAa,aAAa,GAAG;CACnC,MAAM,QAA4C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SAAS,UAAU,EAAE,GAAG,IAAI,GAAG,aAAa;CACtE,MAAM,UAAU,eAAe,OAAO,CAAC,EAAE;CACzC,IAAI,SAAS,SAAS,UAAU,CAAC,QAAQ,SAAS;CAGlD,IAAI,+BAA+B,KAAK,QAAQ,OAAO,GACrD,MAAM,IAAI,MACR,GAAG,cAAc,qBAAqB,QAAQ,QAAQ,8EACxD;CAEF,GAAG,UAAU,QAAQ,SAAS,EAAE,WAAW,KAAK,CAAC;AACnD;;AAGA,SAAgB,mBACd,SACA,QACS;CACT,OAAO,WAAW,OAAO,QAAQ;AACnC","debug_id":"397b5602-ebe3-50b3-89af-8add364d7c0d"}
@@ -69,6 +69,7 @@ export declare const declaredHostSchema: z.ZodObject<{
69
69
  authEnforcement: z.ZodOptional<z.ZodBoolean>;
70
70
  authGroups: z.ZodOptional<z.ZodBoolean>;
71
71
  authConditions: z.ZodOptional<z.ZodBoolean>;
72
+ undoV3: z.ZodOptional<z.ZodBoolean>;
72
73
  }, z.core.$strict>>;
73
74
  createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
74
75
  legacy: "legacy";
@@ -218,6 +219,7 @@ export declare const declaredHostSchema: z.ZodObject<{
218
219
  authEnforcement: z.ZodOptional<z.ZodBoolean>;
219
220
  authGroups: z.ZodOptional<z.ZodBoolean>;
220
221
  authConditions: z.ZodOptional<z.ZodBoolean>;
222
+ undoV3: z.ZodOptional<z.ZodBoolean>;
221
223
  }, z.core.$strict>>;
222
224
  createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
223
225
  legacy: "legacy";
@@ -435,6 +437,7 @@ export declare const hostSchema: z.ZodObject<{
435
437
  authEnforcement: z.ZodOptional<z.ZodBoolean>;
436
438
  authGroups: z.ZodOptional<z.ZodBoolean>;
437
439
  authConditions: z.ZodOptional<z.ZodBoolean>;
440
+ undoV3: z.ZodOptional<z.ZodBoolean>;
438
441
  }, z.core.$strict>>;
439
442
  createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
440
443
  legacy: "legacy";
@@ -584,6 +587,7 @@ export declare const hostSchema: z.ZodObject<{
584
587
  authEnforcement: z.ZodOptional<z.ZodBoolean>;
585
588
  authGroups: z.ZodOptional<z.ZodBoolean>;
586
589
  authConditions: z.ZodOptional<z.ZodBoolean>;
590
+ undoV3: z.ZodOptional<z.ZodBoolean>;
587
591
  }, z.core.$strict>>;
588
592
  createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
589
593
  legacy: "legacy";
@@ -891,6 +895,7 @@ export declare function withoutBuiltImages(config: PHConnectRuntimeConfig | unde
891
895
  authEnforcement?: boolean | undefined;
892
896
  authGroups?: boolean | undefined;
893
897
  authConditions?: boolean | undefined;
898
+ undoV3?: boolean | undefined;
894
899
  } | undefined;
895
900
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
896
901
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -1103,6 +1108,7 @@ export declare function withoutBuiltImages(config: PHConnectRuntimeConfig | unde
1103
1108
  authEnforcement?: boolean | undefined;
1104
1109
  authGroups?: boolean | undefined;
1105
1110
  authConditions?: boolean | undefined;
1111
+ undoV3?: boolean | undefined;
1106
1112
  } | undefined;
1107
1113
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
1108
1114
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.mts","names":[],"sources":["../../src/runners/connect.ts"],"mappings":";;;;;;;;;;;;qBAuCa;qBA0CA,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAU/B,sBACV,MAAM,oBACN,WAAW,sBACX,kBACA;EAAY;MACT,QAAQ;;;;;;;wBAQS,UACpB,OAAO,oBACP,MAAM,mBACN,KAAK,gBACJ,QAAQ,aAAa;;;wBAmCF,MACpB,MAAM,mBACN,KAAK,gBACJ,QAAQ,aAAa;;qBAMX,YAAG;qBAEH"}
@@ -1,3 +1,5 @@
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]="1afe3171-4423-5b61-896d-d2141ebf418a")}catch(e){}}();
1
3
  import { defineHostSchemas, entryActiveForVerb, findDeadConnectConfig, isStructuralMultiReactor, mergeDefaultDrives, normalizePluginEntries, placeConnectDrives, projectDrivesIntoConnect, projectReactorToConnect, refineConnectReactor, remoteBackendUrls, resolveDriveDeclaration } from "@powerhousedao/host-core";
2
4
  import { DEFAULT_CONNECT_OUTDIR, DEFAULT_CONNECT_STUDIO_PORT } from "@powerhousedao/shared/clis";
3
5
  import { connectConfigSchemaWith } from "@powerhousedao/shared/connect/connect-config-schema";
@@ -149,7 +151,7 @@ function callerOverrideRaw(host, ctx, verb = "dev") {
149
151
  };
150
152
  const { connect } = projectReactorToConnect(reactor);
151
153
  const structural = isStructuralMultiReactor(reactor);
152
- if (!connect.reactor && !connect.instance && !connect.app && !structural) return host.config !== void 0 || composition || declaredDefaults ? base : void 0;
154
+ if (!connect.reactor && !connect.instance && !connect.app && !structural) return host.config !== void 0 || composition || declaredDefaults || base.renown !== void 0 || base.instance !== void 0 ? base : void 0;
153
155
  const projected = structural ? projectDrivesIntoConnect({
154
156
  createdDriveUrls: remoteBackendUrls(reactor),
155
157
  configuredDefaultDrives: base.drives?.defaultDrives
@@ -265,4 +267,5 @@ const verbs = ["run", "serve"];
265
267
  //#endregion
266
268
  export { callerOverride, connectHandle, declaredHostSchema, hostSchema, kind, outputsSchema, run, serve, serveWith, startUnderSupervisor, validateComposition, verbs, withoutBuiltImages };
267
269
 
268
- //# sourceMappingURL=connect.mjs.map
270
+ //# sourceMappingURL=connect.mjs.map
271
+ //# debugId=1afe3171-4423-5b61-896d-d2141ebf418a
@@ -1 +1 @@
1
- {"version":3,"file":"connect.mjs","names":[],"sources":["../../src/runners/connect.ts"],"sourcesContent":["import {\n DEFAULT_CONNECT_OUTDIR,\n DEFAULT_CONNECT_STUDIO_PORT,\n type PHConnectCompositionEntry,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { connectConfigSchemaWith } from \"@powerhousedao/shared/connect/connect-config-schema\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\nimport { withOriginPlaceholders } from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport {\n defineHostSchemas,\n entryActiveForVerb,\n findDeadConnectConfig,\n isStructuralMultiReactor,\n mergeDefaultDrives,\n normalizePluginEntries,\n placeConnectDrives,\n resolveDriveDeclaration,\n type DriveDeclaration,\n projectDrivesIntoConnect,\n projectReactorToConnect,\n refineConnectReactor,\n remoteBackendUrls,\n type ReactorConfig,\n type RunnerContext,\n type RunnerHandle,\n} from \"@powerhousedao/host-core\";\nimport { z } from \"zod\";\nimport type { ConnectPreviewArgs } from \"../services/classic-args.js\";\nimport type { ConnectServeOverride } from \"../services/connect-serve.js\";\n\n/**\n * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a\n * hosts/connect/host.js definition onto the SAME service the classic\n * `ph connect studio` (dev/run), `ph connect build` and `ph connect preview`\n * (serve) commands call — no forked behavior.\n */\n\nexport const kind = \"reactor\";\n\n/** The connect host: the host-core reactor host with every runner option\n * this module reads declared (strict: an unknown runner key fails), and\n * `config` typed by Connect's own zod schema (the authored `connect` block),\n * whose URL fields that name another host's outputs\n * (`drives.defaultDrives[].url`, `renown.switchboardUrl`) are token-able.\n * One definition, two schemas: `declaredHostSchema` (token-able fields take\n * output tokens; types host files) and `hostSchema` (resolved; checked\n * right before the verb). */\nconst schemas = defineHostSchemas((s) =>\n s.reactorHostSchema\n .extend({\n runner: s.runnerBaseSchema\n .extend({\n /** Open a browser tab once listening (dev/serve). */\n openBrowser: z.boolean().optional(),\n /** Fail instead of moving to the next free port when `port` is taken. */\n strictPort: z.boolean().optional(),\n /** The Connect build output dir (`build` writes it, `serve` serves it). */\n outDir: z.string().min(1).optional(),\n /** Patch the baked CSP for the runtime registry (`serve`); a\n * compound's wiring sets it on its connect member. */\n cspRegistrySync: z.boolean().optional(),\n /** The host's routes folder, project-relative; false for none.\n * Default: hosts/connect/routes. */\n routes: z.union([z.string(), z.literal(false)]).optional(),\n /** The switchboard this Connect is served next to: its server\n * (dev and serve) proxies the switchboard's paths (`/graphql`,\n * `/d/*`, `/attachments`, `/mcp`, `/api/*`) to `target`, and the\n * served config names that switchboard as `${origin}`, resolved by\n * the browser against the page's origin. So one config holds from\n * the developer's `localhost` and from a published site alike, with\n * every call on the page's own origin. Typically a sibling's\n * `origin` output token. */\n proxy: z.strictObject({ target: s.tokenable(z.url()) }).optional(),\n })\n .strict(),\n config: connectConfigSchemaWith(s.tokenable).optional(),\n })\n .superRefine(refineConnectReactor),\n);\nexport const declaredHostSchema = schemas.declaredHostSchema;\nexport const hostSchema = schemas.hostSchema;\n\n/** What a connect host.js author writes. */\nexport type ConnectHost = z.input<typeof declaredHostSchema>;\n/** What a verb receives (defaults applied). */\nexport type ConnectHostParsed = z.output<typeof hostSchema>;\n\n/** What a started Connect (`dev`/`run`/`serve`) produces: the origin it\n * actually listens on and the app URL (origin plus base path). */\nexport const outputsSchema = z.strictObject({\n origin: z.url(),\n endpoints: z.strictObject({ connect: z.url() }),\n});\nexport type ConnectOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/ph-cli/runners/connect\": {\n host: ConnectHost;\n outputs: ConnectOutputs;\n };\n }\n}\n\n/** The slice of a vite dev/preview server a handle needs. */\nexport interface ListeningServer {\n resolvedUrls: { local: string[] } | null;\n close(): Promise<void>;\n}\n\n/** A started Connect as a runner handle. vite has already listened when the\n * service returns, so `ready` is settled; the outputs carry the URL vite\n * resolved (the port it actually bound), falling back to the requested one. */\nexport function connectHandle(\n server: ListeningServer,\n requested: { host: string; port: number },\n): RunnerHandle<ConnectOutputs> {\n const fallback = `http://${requested.host}:${requested.port}/`;\n const app = server.resolvedUrls?.local[0] ?? fallback;\n let closing: Promise<void> | undefined;\n return {\n outputs: outputsSchema.parse({\n origin: new URL(app).origin,\n endpoints: { connect: app },\n }),\n ready: Promise.resolve(),\n shutdown: () => (closing ??= server.close()),\n };\n}\n\n/** host.js reactor.drives -> the served drives.defaultDrives shapes: locals\n * carry id/name/icon and the preferredEditor under its Connect alias `app`;\n * remotes carry their URL. */\nfunction declaredDrivesToDefaults(\n projectRoot: string,\n declarations: readonly DriveDeclaration[],\n): PHConnectDefaultDrive[] {\n return declarations.map((declaration) => {\n const drive = resolveDriveDeclaration(projectRoot, declaration);\n if (drive.kind === \"remote\") {\n return {\n url: drive.remoteUrl!,\n name: drive.name,\n icon: drive.icon ?? null,\n };\n }\n return {\n local: true as const,\n // A local drive is skipped on later boots by this id, so it stays fixed.\n id: drive.id ?? drive.slug,\n name: drive.name,\n icon: drive.icon ?? null,\n ...(drive.preferredEditor ? { app: drive.preferredEditor } : {}),\n };\n });\n}\n\n/**\n * The served override. With `runner.proxy`, every URL on the proxied\n * switchboard's origin (drives, backends, plugin configs, however they were\n * written or resolved from output tokens) is served as `${origin}…`: the\n * browser reaches the switchboard through the page's own origin, which this\n * Connect's server proxies, so the config holds wherever the page is loaded\n * from. A host may also write `${origin}/…` itself; that passes through.\n */\nexport function callerOverride(\n host: ConnectHostParsed,\n ctx?: RunnerContext,\n verb = \"dev\",\n): PHConnectRuntimeConfig | undefined {\n const override = callerOverrideRaw(host, ctx, verb);\n const target = host.runner.proxy?.target;\n return override && target\n ? withOriginPlaceholders(override, target)\n : override;\n}\n\nfunction callerOverrideRaw(\n host: ConnectHostParsed,\n ctx?: RunnerContext,\n verb = \"dev\",\n): PHConnectRuntimeConfig | undefined {\n // A copy: the projection below adds served-only keys (composition, …).\n const base: PHConnectRuntimeConfig = { ...host.config };\n const reactor: ReactorConfig | undefined = host.reactor;\n\n // The Renown instance a person chose at start, under the names the\n // switchboard reads, so the two can't disagree.\n const renownUrl = ctx?.env.RENOWN_URL?.trim();\n const renownSwitchboardUrl = ctx?.env.SWITCHBOARD_URL?.trim();\n if (renownUrl || renownSwitchboardUrl) {\n base.renown = {\n ...base.renown,\n ...(renownUrl ? { url: renownUrl } : {}),\n ...(renownSwitchboardUrl ? { switchboardUrl: renownSwitchboardUrl } : {}),\n };\n }\n\n // R3: the composition (verb-filtered, projected as DATA — the browser\n // pipeline resolves and runs the entries), declared drives, and the\n // reactor-core identity/namespace keys.\n const entries = host.runner.plugins;\n const composition: PHConnectCompositionEntry[] | undefined =\n entries === undefined\n ? undefined\n : normalizePluginEntries(entries, `hosts/${host.name}/host.js`)\n .filter((entry) => entryActiveForVerb(entry, verb))\n .map((entry) => ({ module: entry.module, config: entry.config }));\n // Entry configs arrive RESOLVED: output tokens (e.g. the workflows\n // plugin's `drive: switchboard.drives.workflows.url`) were replaced by\n // `ph run` (standalone: the producer's run record; in a compound: the\n // member's live outputs) before validateHost let this verb run.\n if (entries !== undefined) {\n // Change 2: show the composition plan on the `ph run connect` terminal.\n // The pipeline itself runs in the browser (hook execution logs to the\n // browser console); here we report WHAT will be served and for which verb.\n const all = normalizePluginEntries(entries, `hosts/${host.name}/host.js`);\n console.log(\n `[connect] composition plan (verb=${verb}): ${composition?.length ?? 0} active of ${all.length} declared`,\n );\n for (const entry of all) {\n const active = entryActiveForVerb(entry, verb);\n const scope =\n entry.verbs === \"*\" ? \"\" : ` verbs=[${entry.verbs.join(\",\")}]`;\n const cfg = Object.keys(entry.config);\n console.log(\n `[connect] ${active ? \"•\" : \"○\"} ${entry.module}${scope}` +\n (cfg.length ? ` config: {${cfg.join(\", \")}}` : \"\") +\n (active ? \"\" : \" (inactive for this verb)\"),\n );\n }\n }\n // Config a Connect plugin owns, set on the host while that plugin is not\n // composed for this verb: Connect serves the plugin-absent value instead.\n for (const warning of findDeadConnectConfig(\n host.config,\n entries,\n verb,\n `hosts/${host.name}/host.js`,\n )) {\n console.warn(warning.message);\n }\n const declared = reactor?.drives;\n const declaredDefaults =\n declared && ctx\n ? declaredDrivesToDefaults(ctx.projectRoot, declared)\n : undefined;\n const reactorRenown = reactor?.renown;\n const reactorNamespace = reactor?.namespace;\n base.drives = declaredDefaults\n ? {\n ...base.drives,\n defaultDrives: mergeDefaultDrives(\n declaredDefaults,\n base.drives?.defaultDrives ?? [],\n ),\n preserveStrategy: base.drives?.preserveStrategy ?? \"preserve-all\",\n }\n : base.drives;\n if (composition) base.composition = composition;\n if (reactorRenown) base.renown = { ...reactorRenown, ...base.renown };\n if (reactorNamespace !== undefined)\n base.instance = {\n ...base.instance,\n namespace: base.instance?.namespace ?? reactorNamespace,\n } as typeof base.instance;\n const { connect } = projectReactorToConnect(reactor);\n const structural = isStructuralMultiReactor(reactor);\n if (!connect.reactor && !connect.instance && !connect.app && !structural) {\n // `base` IS host.config when the host has one; a host without a config\n // block still carries its composition and drives (set on `base` above).\n // With none of the three, there is no override: a classic build.\n return host.config !== undefined || composition || declaredDefaults\n ? base\n : undefined;\n }\n const projected = structural\n ? projectDrivesIntoConnect({\n createdDriveUrls: remoteBackendUrls(reactor),\n configuredDefaultDrives: base.drives?.defaultDrives,\n }).drives\n : base.drives;\n const placed = placeConnectDrives(reactor, projected?.defaultDrives ?? []);\n const drives =\n projected?.defaultDrives === undefined\n ? projected\n : { ...projected, defaultDrives: placed.defaultDrives };\n // When the host DECLARES backends, instance facts derive from them and win\n // over config defaults (declaring `kind: \"worker\"` is more explicit intent\n // than a scaffold's `reactorWorker: false`); without backends the P2 rule\n // stands — an explicit connect.* value wins over descriptive projection.\n const declaresBackends = Object.keys(reactor?.backends ?? {}).length > 0;\n const instance = declaresBackends\n ? {\n ...base.instance,\n ...connect.instance,\n ...(placed.collections ? { collections: placed.collections } : {}),\n }\n : { ...connect.instance, ...base.instance };\n return {\n ...base,\n reactor: { ...connect.reactor, ...base.reactor },\n instance: instance as never,\n app: { ...connect.app, ...base.app },\n ...(drives ? { drives: { ...base.drives, ...drives } } : {}),\n };\n}\n\n/**\n * Start a server; under a supervising compound (`ctx.parent`), drop the\n * process-exiting signal listeners it installed (vite's dev and preview\n * servers exit on SIGTERM): the compound owns the exit and stops members in\n * reverse dependency order through their handles.\n */\nexport async function startUnderSupervisor<T>(\n ctx: RunnerContext,\n start: () => Promise<T>,\n): Promise<T> {\n if (!ctx.parent) return start();\n const signals = [\"SIGINT\", \"SIGTERM\"] as const;\n const before = new Map(\n signals.map((signal) => [signal, new Set(process.listeners(signal))]),\n );\n try {\n return await start();\n } finally {\n for (const signal of signals) {\n for (const listener of process.listeners(signal)) {\n if (!before.get(signal)?.has(listener)) {\n process.off(signal, listener);\n }\n }\n }\n }\n}\n\n/** Fail at `ph run`, naming the plugin and key, when a composed Connect\n * plugin's entry config does not match its schema. */\nexport async function validateComposition(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n const { validateConnectPluginConfigs } =\n await import(\"./connect-plugin-configs.js\");\n await validateConnectPluginConfigs(\n ctx.projectRoot,\n host.runner.plugins,\n ctx.verb,\n `hosts/${host.name}/host.js`,\n );\n}\n\n/** A project file the build resolved: the built dist has it (as icon.ico or\n * a data URI); served, its path would mean nothing. */\nfunction isBuiltImage(ref: unknown): boolean {\n const src =\n typeof ref === \"object\" && ref !== null && \"src\" in ref ? ref.src : ref;\n return typeof src === \"string\" && !isPassthroughImageRef(src);\n}\n\n// The served config keeps the build's images: the favicon and any branding\n// image given as a project path were resolved into the dist, and merged over\n// it a path would replace the built data URI with a URL that 404s.\nexport function withoutBuiltImages(config: PHConnectRuntimeConfig | undefined) {\n const branding = config?.branding;\n if (!branding) return config;\n const { favicon: _, ...served } = branding;\n if (isBuiltImage(served.icon)) delete served.icon;\n if (isBuiltImage(served.loader)) delete served.loader;\n return { ...config, branding: served };\n}\n\n/** A server for a built Connect, given what to serve and how. */\nexport type ConnectServerStart = (\n args: ConnectPreviewArgs,\n override?: ConnectServeOverride,\n dirname?: string,\n options?: { proxy?: string },\n) => Promise<ListeningServer>;\n\n/** `serve` on a given server. The host's connect config (including a\n * supervising compound's projected drives and the reactor projection) rides a\n * serve override: the baked powerhouse.config.json merges with it at request\n * time, and `runner.cspRegistrySync` (set by the compound's wiring) patches the\n * baked CSP's script-src for the runtime registry. Together these replace the\n * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */\nexport async function serveWith(\n start: ConnectServerStart,\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const runner = host.runner;\n const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;\n const bind = runner.host ?? \"127.0.0.1\";\n const args: Partial<ConnectPreviewArgs> = {\n port,\n outDir: runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n cors: true,\n printUrls: true,\n bindCLIShortcuts: false,\n // Explicit IPv4 loopback (runner.host overrides): vite's default\n // \"localhost\" can bind ::1 only on Windows, and a supervising shell\n // (ph-win) probes 127.0.0.1 — the sidecar this replaces bound 127.0.0.1.\n host: bind,\n };\n const override = withoutBuiltImages(callerOverride(host, ctx, ctx.verb));\n const server = await startUnderSupervisor<ListeningServer>(ctx, () =>\n start(\n args as ConnectPreviewArgs,\n {\n connect: override,\n cspRegistrySync: runner.cspRegistrySync === true,\n },\n undefined,\n { proxy: runner.proxy?.target },\n ),\n );\n return connectHandle(server, { host: bind, port });\n}\n\n/** Serves a built Connect (run `build` first) with nothing but what a running\n * app has. ph-cli's runner adds the verbs that need build tools. */\nexport async function serve(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n const { runConnectServer } = await import(\"../services/connect-server.js\");\n return serveWith(runConnectServer, host, ctx);\n}\n\n/** With no Studio here, running Connect is serving its build. */\nexport const run = serve;\n\nexport const verbs = [\"run\", \"serve\"];\n"],"mappings":";;;;;;;;;;;;;AAuCA,MAAa,OAAO;;;;;;;;;AAUpB,MAAM,UAAU,mBAAmB,MACjC,EAAE,kBACC,OAAO;CACN,QAAQ,EAAE,iBACP,OAAO;;EAEN,aAAa,EAAE,QAAQ,CAAC,CAAC,SAAS;;EAElC,YAAY,EAAE,QAAQ,CAAC,CAAC,SAAS;;EAEjC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;;EAGnC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,SAAS;;;EAGtC,QAAQ,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;;;;;;;;;EASzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;CACnE,CAAC,CAAC,CACD,OAAO;CACV,QAAQ,wBAAwB,EAAE,SAAS,CAAC,CAAC,SAAS;AACxD,CAAC,CAAC,CACD,YAAY,oBAAoB,CACrC;AACA,MAAa,qBAAqB,QAAQ;AAC1C,MAAa,aAAa,QAAQ;;;AASlC,MAAa,gBAAgB,EAAE,aAAa;CAC1C,QAAQ,EAAE,IAAI;CACd,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAChD,CAAC;;;;AAqBD,SAAgB,cACd,QACA,WAC8B;CAC9B,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eAAe,MAAM,KAAK,IAAI,IAAI,CAAC;CAYvE,OAAO,cAAc,MAXA,qBAAsC,WACzD,MACE,MACA;EACE,SAAS;EACT,iBAAiB,OAAO,oBAAoB;CAC9C,GACA,KAAA,GACA,EAAE,OAAO,OAAO,OAAO,OAAO,CAChC,CACF,GAC6B;EAAE,MAAM;EAAM;CAAK,CAAC;AACnD;;;AAIA,eAAsB,MACpB,MACA,KACuC;CACvC,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,OAAO,UAAU,kBAAkB,MAAM,GAAG;AAC9C;;AAGA,MAAa,MAAM;AAEnB,MAAa,QAAQ,CAAC,OAAO,OAAO"}
1
+ {"version":3,"file":"connect.mjs","sources":["../../src/runners/connect.ts"],"sourcesContent":["import {\n DEFAULT_CONNECT_OUTDIR,\n DEFAULT_CONNECT_STUDIO_PORT,\n type PHConnectCompositionEntry,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { connectConfigSchemaWith } from \"@powerhousedao/shared/connect/connect-config-schema\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\nimport { withOriginPlaceholders } from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport {\n defineHostSchemas,\n entryActiveForVerb,\n findDeadConnectConfig,\n isStructuralMultiReactor,\n mergeDefaultDrives,\n normalizePluginEntries,\n placeConnectDrives,\n resolveDriveDeclaration,\n type DriveDeclaration,\n projectDrivesIntoConnect,\n projectReactorToConnect,\n refineConnectReactor,\n remoteBackendUrls,\n type ReactorConfig,\n type RunnerContext,\n type RunnerHandle,\n} from \"@powerhousedao/host-core\";\nimport { z } from \"zod\";\nimport type { ConnectPreviewArgs } from \"../services/classic-args.js\";\nimport type { ConnectServeOverride } from \"../services/connect-serve.js\";\n\n/**\n * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a\n * hosts/connect/host.js definition onto the SAME service the classic\n * `ph connect studio` (dev/run), `ph connect build` and `ph connect preview`\n * (serve) commands call — no forked behavior.\n */\n\nexport const kind = \"reactor\";\n\n/** The connect host: the host-core reactor host with every runner option\n * this module reads declared (strict: an unknown runner key fails), and\n * `config` typed by Connect's own zod schema (the authored `connect` block),\n * whose URL fields that name another host's outputs\n * (`drives.defaultDrives[].url`, `renown.switchboardUrl`) are token-able.\n * One definition, two schemas: `declaredHostSchema` (token-able fields take\n * output tokens; types host files) and `hostSchema` (resolved; checked\n * right before the verb). */\nconst schemas = defineHostSchemas((s) =>\n s.reactorHostSchema\n .extend({\n runner: s.runnerBaseSchema\n .extend({\n /** Open a browser tab once listening (dev/serve). */\n openBrowser: z.boolean().optional(),\n /** Fail instead of moving to the next free port when `port` is taken. */\n strictPort: z.boolean().optional(),\n /** The Connect build output dir (`build` writes it, `serve` serves it). */\n outDir: z.string().min(1).optional(),\n /** Patch the baked CSP for the runtime registry (`serve`); a\n * compound's wiring sets it on its connect member. */\n cspRegistrySync: z.boolean().optional(),\n /** The host's routes folder, project-relative; false for none.\n * Default: hosts/connect/routes. */\n routes: z.union([z.string(), z.literal(false)]).optional(),\n /** The switchboard this Connect is served next to: its server\n * (dev and serve) proxies the switchboard's paths (`/graphql`,\n * `/d/*`, `/attachments`, `/mcp`, `/api/*`) to `target`, and the\n * served config names that switchboard as `${origin}`, resolved by\n * the browser against the page's origin. So one config holds from\n * the developer's `localhost` and from a published site alike, with\n * every call on the page's own origin. Typically a sibling's\n * `origin` output token. */\n proxy: z.strictObject({ target: s.tokenable(z.url()) }).optional(),\n })\n .strict(),\n config: connectConfigSchemaWith(s.tokenable).optional(),\n })\n .superRefine(refineConnectReactor),\n);\nexport const declaredHostSchema = schemas.declaredHostSchema;\nexport const hostSchema = schemas.hostSchema;\n\n/** What a connect host.js author writes. */\nexport type ConnectHost = z.input<typeof declaredHostSchema>;\n/** What a verb receives (defaults applied). */\nexport type ConnectHostParsed = z.output<typeof hostSchema>;\n\n/** What a started Connect (`dev`/`run`/`serve`) produces: the origin it\n * actually listens on and the app URL (origin plus base path). */\nexport const outputsSchema = z.strictObject({\n origin: z.url(),\n endpoints: z.strictObject({ connect: z.url() }),\n});\nexport type ConnectOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/ph-cli/runners/connect\": {\n host: ConnectHost;\n outputs: ConnectOutputs;\n };\n }\n}\n\n/** The slice of a vite dev/preview server a handle needs. */\nexport interface ListeningServer {\n resolvedUrls: { local: string[] } | null;\n close(): Promise<void>;\n}\n\n/** A started Connect as a runner handle. vite has already listened when the\n * service returns, so `ready` is settled; the outputs carry the URL vite\n * resolved (the port it actually bound), falling back to the requested one. */\nexport function connectHandle(\n server: ListeningServer,\n requested: { host: string; port: number },\n): RunnerHandle<ConnectOutputs> {\n const fallback = `http://${requested.host}:${requested.port}/`;\n const app = server.resolvedUrls?.local[0] ?? fallback;\n let closing: Promise<void> | undefined;\n return {\n outputs: outputsSchema.parse({\n origin: new URL(app).origin,\n endpoints: { connect: app },\n }),\n ready: Promise.resolve(),\n shutdown: () => (closing ??= server.close()),\n };\n}\n\n/** host.js reactor.drives -> the served drives.defaultDrives shapes: locals\n * carry id/name/icon and the preferredEditor under its Connect alias `app`;\n * remotes carry their URL. */\nfunction declaredDrivesToDefaults(\n projectRoot: string,\n declarations: readonly DriveDeclaration[],\n): PHConnectDefaultDrive[] {\n return declarations.map((declaration) => {\n const drive = resolveDriveDeclaration(projectRoot, declaration);\n if (drive.kind === \"remote\") {\n return {\n url: drive.remoteUrl!,\n name: drive.name,\n icon: drive.icon ?? null,\n };\n }\n return {\n local: true as const,\n // A local drive is skipped on later boots by this id, so it stays fixed.\n id: drive.id ?? drive.slug,\n name: drive.name,\n icon: drive.icon ?? null,\n ...(drive.preferredEditor ? { app: drive.preferredEditor } : {}),\n };\n });\n}\n\n/**\n * The served override. With `runner.proxy`, every URL on the proxied\n * switchboard's origin (drives, backends, plugin configs, however they were\n * written or resolved from output tokens) is served as `${origin}…`: the\n * browser reaches the switchboard through the page's own origin, which this\n * Connect's server proxies, so the config holds wherever the page is loaded\n * from. A host may also write `${origin}/…` itself; that passes through.\n */\nexport function callerOverride(\n host: ConnectHostParsed,\n ctx?: RunnerContext,\n verb = \"dev\",\n): PHConnectRuntimeConfig | undefined {\n const override = callerOverrideRaw(host, ctx, verb);\n const target = host.runner.proxy?.target;\n return override && target\n ? withOriginPlaceholders(override, target)\n : override;\n}\n\nfunction callerOverrideRaw(\n host: ConnectHostParsed,\n ctx?: RunnerContext,\n verb = \"dev\",\n): PHConnectRuntimeConfig | undefined {\n // A copy: the projection below adds served-only keys (composition, …).\n const base: PHConnectRuntimeConfig = { ...host.config };\n const reactor: ReactorConfig | undefined = host.reactor;\n\n // The Renown instance a person chose at start, under the names the\n // switchboard reads, so the two can't disagree.\n const renownUrl = ctx?.env.RENOWN_URL?.trim();\n const renownSwitchboardUrl = ctx?.env.SWITCHBOARD_URL?.trim();\n if (renownUrl || renownSwitchboardUrl) {\n base.renown = {\n ...base.renown,\n ...(renownUrl ? { url: renownUrl } : {}),\n ...(renownSwitchboardUrl ? { switchboardUrl: renownSwitchboardUrl } : {}),\n };\n }\n\n // R3: the composition (verb-filtered, projected as DATA — the browser\n // pipeline resolves and runs the entries), declared drives, and the\n // reactor-core identity/namespace keys.\n const entries = host.runner.plugins;\n const composition: PHConnectCompositionEntry[] | undefined =\n entries === undefined\n ? undefined\n : normalizePluginEntries(entries, `hosts/${host.name}/host.js`)\n .filter((entry) => entryActiveForVerb(entry, verb))\n .map((entry) => ({ module: entry.module, config: entry.config }));\n // Entry configs arrive RESOLVED: output tokens (e.g. the workflows\n // plugin's `drive: switchboard.drives.workflows.url`) were replaced by\n // `ph run` (standalone: the producer's run record; in a compound: the\n // member's live outputs) before validateHost let this verb run.\n if (entries !== undefined) {\n // Change 2: show the composition plan on the `ph run connect` terminal.\n // The pipeline itself runs in the browser (hook execution logs to the\n // browser console); here we report WHAT will be served and for which verb.\n const all = normalizePluginEntries(entries, `hosts/${host.name}/host.js`);\n console.log(\n `[connect] composition plan (verb=${verb}): ${composition?.length ?? 0} active of ${all.length} declared`,\n );\n for (const entry of all) {\n const active = entryActiveForVerb(entry, verb);\n const scope =\n entry.verbs === \"*\" ? \"\" : ` verbs=[${entry.verbs.join(\",\")}]`;\n const cfg = Object.keys(entry.config);\n console.log(\n `[connect] ${active ? \"•\" : \"○\"} ${entry.module}${scope}` +\n (cfg.length ? ` config: {${cfg.join(\", \")}}` : \"\") +\n (active ? \"\" : \" (inactive for this verb)\"),\n );\n }\n }\n // Config a Connect plugin owns, set on the host while that plugin is not\n // composed for this verb: Connect serves the plugin-absent value instead.\n for (const warning of findDeadConnectConfig(\n host.config,\n entries,\n verb,\n `hosts/${host.name}/host.js`,\n )) {\n console.warn(warning.message);\n }\n const declared = reactor?.drives;\n const declaredDefaults =\n declared && ctx\n ? declaredDrivesToDefaults(ctx.projectRoot, declared)\n : undefined;\n const reactorRenown = reactor?.renown;\n const reactorNamespace = reactor?.namespace;\n base.drives = declaredDefaults\n ? {\n ...base.drives,\n defaultDrives: mergeDefaultDrives(\n declaredDefaults,\n base.drives?.defaultDrives ?? [],\n ),\n preserveStrategy: base.drives?.preserveStrategy ?? \"preserve-all\",\n }\n : base.drives;\n if (composition) base.composition = composition;\n if (reactorRenown) base.renown = { ...reactorRenown, ...base.renown };\n if (reactorNamespace !== undefined)\n base.instance = {\n ...base.instance,\n namespace: base.instance?.namespace ?? reactorNamespace,\n } as typeof base.instance;\n const { connect } = projectReactorToConnect(reactor);\n const structural = isStructuralMultiReactor(reactor);\n if (!connect.reactor && !connect.instance && !connect.app && !structural) {\n // `base` IS host.config when the host has one; a host without a config\n // block still carries its composition, drives, Renown and namespace (set\n // on `base` above). With none of them, there is no override: a classic\n // build.\n return host.config !== undefined ||\n composition ||\n declaredDefaults ||\n base.renown !== undefined ||\n base.instance !== undefined\n ? base\n : undefined;\n }\n const projected = structural\n ? projectDrivesIntoConnect({\n createdDriveUrls: remoteBackendUrls(reactor),\n configuredDefaultDrives: base.drives?.defaultDrives,\n }).drives\n : base.drives;\n const placed = placeConnectDrives(reactor, projected?.defaultDrives ?? []);\n const drives =\n projected?.defaultDrives === undefined\n ? projected\n : { ...projected, defaultDrives: placed.defaultDrives };\n // When the host DECLARES backends, instance facts derive from them and win\n // over config defaults (declaring `kind: \"worker\"` is more explicit intent\n // than a scaffold's `reactorWorker: false`); without backends the P2 rule\n // stands — an explicit connect.* value wins over descriptive projection.\n const declaresBackends = Object.keys(reactor?.backends ?? {}).length > 0;\n const instance = declaresBackends\n ? {\n ...base.instance,\n ...connect.instance,\n ...(placed.collections ? { collections: placed.collections } : {}),\n }\n : { ...connect.instance, ...base.instance };\n return {\n ...base,\n reactor: { ...connect.reactor, ...base.reactor },\n instance: instance as never,\n app: { ...connect.app, ...base.app },\n ...(drives ? { drives: { ...base.drives, ...drives } } : {}),\n };\n}\n\n/**\n * Start a server; under a supervising compound (`ctx.parent`), drop the\n * process-exiting signal listeners it installed (vite's dev and preview\n * servers exit on SIGTERM): the compound owns the exit and stops members in\n * reverse dependency order through their handles.\n */\nexport async function startUnderSupervisor<T>(\n ctx: RunnerContext,\n start: () => Promise<T>,\n): Promise<T> {\n if (!ctx.parent) return start();\n const signals = [\"SIGINT\", \"SIGTERM\"] as const;\n const before = new Map(\n signals.map((signal) => [signal, new Set(process.listeners(signal))]),\n );\n try {\n return await start();\n } finally {\n for (const signal of signals) {\n for (const listener of process.listeners(signal)) {\n if (!before.get(signal)?.has(listener)) {\n process.off(signal, listener);\n }\n }\n }\n }\n}\n\n/** Fail at `ph run`, naming the plugin and key, when a composed Connect\n * plugin's entry config does not match its schema. */\nexport async function validateComposition(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n const { validateConnectPluginConfigs } =\n await import(\"./connect-plugin-configs.js\");\n await validateConnectPluginConfigs(\n ctx.projectRoot,\n host.runner.plugins,\n ctx.verb,\n `hosts/${host.name}/host.js`,\n );\n}\n\n/** A project file the build resolved: the built dist has it (as icon.ico or\n * a data URI); served, its path would mean nothing. */\nfunction isBuiltImage(ref: unknown): boolean {\n const src =\n typeof ref === \"object\" && ref !== null && \"src\" in ref ? ref.src : ref;\n return typeof src === \"string\" && !isPassthroughImageRef(src);\n}\n\n// The served config keeps the build's images: the favicon and any branding\n// image given as a project path were resolved into the dist, and merged over\n// it a path would replace the built data URI with a URL that 404s.\nexport function withoutBuiltImages(config: PHConnectRuntimeConfig | undefined) {\n const branding = config?.branding;\n if (!branding) return config;\n const { favicon: _, ...served } = branding;\n if (isBuiltImage(served.icon)) delete served.icon;\n if (isBuiltImage(served.loader)) delete served.loader;\n return { ...config, branding: served };\n}\n\n/** A server for a built Connect, given what to serve and how. */\nexport type ConnectServerStart = (\n args: ConnectPreviewArgs,\n override?: ConnectServeOverride,\n dirname?: string,\n options?: { proxy?: string },\n) => Promise<ListeningServer>;\n\n/** `serve` on a given server. The host's connect config (including a\n * supervising compound's projected drives and the reactor projection) rides a\n * serve override: the baked powerhouse.config.json merges with it at request\n * time, and `runner.cspRegistrySync` (set by the compound's wiring) patches the\n * baked CSP's script-src for the runtime registry. Together these replace the\n * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */\nexport async function serveWith(\n start: ConnectServerStart,\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const runner = host.runner;\n const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;\n const bind = runner.host ?? \"127.0.0.1\";\n const args: Partial<ConnectPreviewArgs> = {\n port,\n outDir: runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n cors: true,\n printUrls: true,\n bindCLIShortcuts: false,\n // Explicit IPv4 loopback (runner.host overrides): vite's default\n // \"localhost\" can bind ::1 only on Windows, and a supervising shell\n // (ph-win) probes 127.0.0.1 — the sidecar this replaces bound 127.0.0.1.\n host: bind,\n };\n const override = withoutBuiltImages(callerOverride(host, ctx, ctx.verb));\n const server = await startUnderSupervisor<ListeningServer>(ctx, () =>\n start(\n args as ConnectPreviewArgs,\n {\n connect: override,\n cspRegistrySync: runner.cspRegistrySync === true,\n },\n undefined,\n { proxy: runner.proxy?.target },\n ),\n );\n return connectHandle(server, { host: bind, port });\n}\n\n/** Serves a built Connect (run `build` first) with nothing but what a running\n * app has. ph-cli's runner adds the verbs that need build tools. */\nexport async function serve(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n const { runConnectServer } = await import(\"../services/connect-server.js\");\n return serveWith(runConnectServer, host, ctx);\n}\n\n/** With no Studio here, running Connect is serving its build. */\nexport const run = serve;\n\nexport const verbs = [\"run\", \"serve\"];\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAa,OAAO;;;;;;;;;AAUpB,MAAM,UAAU,mBAAmB,MACjC,EAAE,kBACC,OAAO;CACN,QAAQ,EAAE,iBACP,OAAO;;EAEN,aAAa,EAAE,QAAQ,CAAC,CAAC,SAAS;;EAElC,YAAY,EAAE,QAAQ,CAAC,CAAC,SAAS;;EAEjC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;;EAGnC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,SAAS;;;EAGtC,QAAQ,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;;;;;;;;;EASzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;CACnE,CAAC,CAAC,CACD,OAAO;CACV,QAAQ,wBAAwB,EAAE,SAAS,CAAC,CAAC,SAAS;AACxD,CAAC,CAAC,CACD,YAAY,oBAAoB,CACrC;AACA,MAAa,qBAAqB,QAAQ;AAC1C,MAAa,aAAa,QAAQ;;;AASlC,MAAa,gBAAgB,EAAE,aAAa;CAC1C,QAAQ,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,OAAoC;EACxC;EACA,QAAQ,OAAO,UAAU;EACzB,MAAM,OAAO,gBAAgB;EAC7B,YAAY,OAAO,eAAe;EAClC,MAAM;EACN,WAAW;EACX,kBAAkB;EAIlB,MAAM;CACR;CACA,MAAM,WAAW,mBAAmB,eAAe,MAAM,KAAK,IAAI,IAAI,CAAC;CAYvE,OAAO,cAAc,MAXA,qBAAsC,WACzD,MACE,MACA;EACE,SAAS;EACT,iBAAiB,OAAO,oBAAoB;CAC9C,GACA,KAAA,GACA,EAAE,OAAO,OAAO,OAAO,OAAO,CAChC,CACF,GAC6B;EAAE,MAAM;EAAM;CAAK,CAAC;AACnD;;;AAIA,eAAsB,MACpB,MACA,KACuC;CACvC,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,OAAO,UAAU,kBAAkB,MAAM,GAAG;AAC9C;;AAGA,MAAa,MAAM;AAEnB,MAAa,QAAQ,CAAC,OAAO,OAAO","debug_id":"1afe3171-4423-5b61-896d-d2141ebf418a"}
@@ -75,6 +75,7 @@ export declare const memberSwitchboardConfigSchema: import("zod").ZodType<{
75
75
  authEnforcement?: boolean | undefined;
76
76
  authGroups?: boolean | undefined;
77
77
  authConditions?: boolean | undefined;
78
+ undoV3?: boolean | undefined;
78
79
  } | undefined;
79
80
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
80
81
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -254,6 +255,7 @@ export declare const memberSwitchboardConfigSchema: import("zod").ZodType<{
254
255
  authEnforcement?: boolean | undefined;
255
256
  authGroups?: boolean | undefined;
256
257
  authConditions?: boolean | undefined;
258
+ undoV3?: boolean | undefined;
257
259
  } | undefined;
258
260
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
259
261
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -433,6 +435,7 @@ export declare const memberSwitchboardConfigSchema: import("zod").ZodType<{
433
435
  authEnforcement?: boolean | undefined;
434
436
  authGroups?: boolean | undefined;
435
437
  authConditions?: boolean | undefined;
438
+ undoV3?: boolean | undefined;
436
439
  } | undefined;
437
440
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
438
441
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -612,6 +615,7 @@ export declare const memberSwitchboardConfigSchema: import("zod").ZodType<{
612
615
  authEnforcement?: boolean | undefined;
613
616
  authGroups?: boolean | undefined;
614
617
  authConditions?: boolean | undefined;
618
+ undoV3?: boolean | undefined;
615
619
  } | undefined;
616
620
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
617
621
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"member-config.d.mts","names":[],"sources":["../../src/runners/member-config.ts"],"mappings":";;;;KAqBK,MAAM,SAAS;;iBAGH;;EAEf,OAAO;;EAEP,QAAQ;;;wBAeM,mBAAmB,KAAK,KAAK,OAAO;;;;;;wBAsBpC,YAAY,KAAK,KAAK,eAA8B;;;;qBA2BvD,6CAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAezB;EACf,UAAU;EACV;IAAW,cAAc;;;;wBAYX,gBACd,GAAG,yBACH,GAAG,yBACH;;wBAac,sBAAsB,QAAQ;;;;;;wBAiB9B,wBACd,SAAS,2BACT,KAAK,KACL;EACG;EAAa;;;;;;;;;;wBA2BI,wBACpB,QAAQ,mBACR,KAAK,WACL;EACE;EACA,SAAS;;EAET,WAAW;IAEZ,QAAQ;;;;;;wBAwCK,qBACd,SAAS,2BACT,KAAK,KACL;;wBAgBc,mBACd,kBACA;EAAU"}
@@ -1,2 +1,4 @@
1
1
  import { a as prepareMemberStorage, c as rememberShellNames, i as overlappingKeys, l as switchboardDevMode, n as memberSwitchboardConfig, o as reactorBlockConflicts, r as memberSwitchboardConfigSchema, s as readModelAsReactorStore, t as memberEnvOf } from "../member-config-BcEWRVq4.mjs";
2
2
  export { memberEnvOf, memberSwitchboardConfig, memberSwitchboardConfigSchema, overlappingKeys, prepareMemberStorage, reactorBlockConflicts, readModelAsReactorStore, rememberShellNames, switchboardDevMode };
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="27ff0f7e-1306-5044-9670-e780f06322fc")}catch(e){}}();
4
+ //# debugId=27ff0f7e-1306-5044-9670-e780f06322fc
@@ -67,6 +67,7 @@ export declare const declaredHostSchema: z.ZodObject<{
67
67
  authEnforcement: z.ZodOptional<z.ZodBoolean>;
68
68
  authGroups: z.ZodOptional<z.ZodBoolean>;
69
69
  authConditions: z.ZodOptional<z.ZodBoolean>;
70
+ undoV3: z.ZodOptional<z.ZodBoolean>;
70
71
  }, z.core.$strict>>;
71
72
  createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
72
73
  legacy: "legacy";
@@ -175,6 +176,7 @@ export declare const declaredHostSchema: z.ZodObject<{
175
176
  authEnforcement?: boolean | undefined;
176
177
  authGroups?: boolean | undefined;
177
178
  authConditions?: boolean | undefined;
179
+ undoV3?: boolean | undefined;
178
180
  } | undefined;
179
181
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
180
182
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -354,6 +356,7 @@ export declare const declaredHostSchema: z.ZodObject<{
354
356
  authEnforcement?: boolean | undefined;
355
357
  authGroups?: boolean | undefined;
356
358
  authConditions?: boolean | undefined;
359
+ undoV3?: boolean | undefined;
357
360
  } | undefined;
358
361
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
359
362
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -533,6 +536,7 @@ export declare const declaredHostSchema: z.ZodObject<{
533
536
  authEnforcement?: boolean | undefined;
534
537
  authGroups?: boolean | undefined;
535
538
  authConditions?: boolean | undefined;
539
+ undoV3?: boolean | undefined;
536
540
  } | undefined;
537
541
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
538
542
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -712,6 +716,7 @@ export declare const declaredHostSchema: z.ZodObject<{
712
716
  authEnforcement?: boolean | undefined;
713
717
  authGroups?: boolean | undefined;
714
718
  authConditions?: boolean | undefined;
719
+ undoV3?: boolean | undefined;
715
720
  } | undefined;
716
721
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
717
722
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -898,6 +903,7 @@ export declare const hostSchema: z.ZodObject<{
898
903
  authEnforcement: z.ZodOptional<z.ZodBoolean>;
899
904
  authGroups: z.ZodOptional<z.ZodBoolean>;
900
905
  authConditions: z.ZodOptional<z.ZodBoolean>;
906
+ undoV3: z.ZodOptional<z.ZodBoolean>;
901
907
  }, z.core.$strict>>;
902
908
  createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
903
909
  legacy: "legacy";
@@ -1006,6 +1012,7 @@ export declare const hostSchema: z.ZodObject<{
1006
1012
  authEnforcement?: boolean | undefined;
1007
1013
  authGroups?: boolean | undefined;
1008
1014
  authConditions?: boolean | undefined;
1015
+ undoV3?: boolean | undefined;
1009
1016
  } | undefined;
1010
1017
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
1011
1018
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -1185,6 +1192,7 @@ export declare const hostSchema: z.ZodObject<{
1185
1192
  authEnforcement?: boolean | undefined;
1186
1193
  authGroups?: boolean | undefined;
1187
1194
  authConditions?: boolean | undefined;
1195
+ undoV3?: boolean | undefined;
1188
1196
  } | undefined;
1189
1197
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
1190
1198
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -1364,6 +1372,7 @@ export declare const hostSchema: z.ZodObject<{
1364
1372
  authEnforcement?: boolean | undefined;
1365
1373
  authGroups?: boolean | undefined;
1366
1374
  authConditions?: boolean | undefined;
1375
+ undoV3?: boolean | undefined;
1367
1376
  } | undefined;
1368
1377
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
1369
1378
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;
@@ -1543,6 +1552,7 @@ export declare const hostSchema: z.ZodObject<{
1543
1552
  authEnforcement?: boolean | undefined;
1544
1553
  authGroups?: boolean | undefined;
1545
1554
  authConditions?: boolean | undefined;
1555
+ undoV3?: boolean | undefined;
1546
1556
  } | undefined;
1547
1557
  createSignaturePolicy?: "legacy" | "v2-required" | undefined;
1548
1558
  unsupportedStoredDocuments?: "read-only" | "refuse" | undefined;