@powerhousedao/ph-cli 6.2.3-dev.79 → 6.2.3-dev.80

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 (75) hide show
  1. package/dist/{build-DUzhIPb7.mjs → build-t5pFQx0f.mjs} +37 -35
  2. package/dist/build-t5pFQx0f.mjs.map +1 -0
  3. package/dist/build-wvc_NiGr.mjs +4 -0
  4. package/dist/{check-DDy1o6Vr.mjs → check-ecwBLzrg.mjs} +5 -5
  5. package/dist/{check-DDy1o6Vr.mjs.map → check-ecwBLzrg.mjs.map} +1 -1
  6. package/dist/{cli-connect-override-By7u9IVR.mjs → cli-connect-override-DW7OYAGx.mjs} +4 -4
  7. package/dist/{cli-connect-override-By7u9IVR.mjs.map → cli-connect-override-DW7OYAGx.mjs.map} +1 -1
  8. package/dist/cli.mjs +4 -4
  9. package/dist/{compound-Cfqa5Jal-B5rkCmIj.mjs → compound-C7GuPnTP-Ba4ce2Xa.mjs} +251 -17
  10. package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs.map +1 -0
  11. package/dist/{connect-build-BBAZuqpo.mjs → connect-build-7nmQw9c5.mjs} +5 -5
  12. package/dist/{connect-build-BBAZuqpo.mjs.map → connect-build-7nmQw9c5.mjs.map} +1 -1
  13. package/dist/{connect-config-ghJlOd-x.mjs → connect-config-CfQwxG8G.mjs} +4 -4
  14. package/dist/{connect-config-ghJlOd-x.mjs.map → connect-config-CfQwxG8G.mjs.map} +1 -1
  15. package/dist/{connect-plugin-configs-BoPbxD9u.mjs → connect-plugin-configs-CXN8_KL0.mjs} +4 -4
  16. package/dist/{connect-plugin-configs-BoPbxD9u.mjs.map → connect-plugin-configs-CXN8_KL0.mjs.map} +1 -1
  17. package/dist/{connect-preview-8-qLgWKt.mjs → connect-preview-l0Car-nX.mjs} +7 -5
  18. package/dist/connect-preview-l0Car-nX.mjs.map +1 -0
  19. package/dist/{connect-studio-BaVeuul3.mjs → connect-studio-Cac3eE_U.mjs} +11 -8
  20. package/dist/connect-studio-Cac3eE_U.mjs.map +1 -0
  21. package/dist/{connect-studio-CfggUldW.mjs → connect-studio-Cf6UZvOo.mjs} +3 -3
  22. package/dist/{dist-Bd6sSt7Y.mjs → dist-DcARVrSg.mjs} +8 -6
  23. package/dist/dist-DcARVrSg.mjs.map +1 -0
  24. package/dist/{explain-C9zER5xn.mjs → explain-Rx7JW1OU.mjs} +5 -5
  25. package/dist/{explain-C9zER5xn.mjs.map → explain-Rx7JW1OU.mjs.map} +1 -1
  26. package/dist/{export-CrIz2spe.mjs → export-ZnJeAtLS.mjs} +4 -4
  27. package/dist/{export-CrIz2spe.mjs.map → export-ZnJeAtLS.mjs.map} +1 -1
  28. package/dist/{generate-all-DgEFOXwU.mjs → generate-all-5Om0CB4N.mjs} +4 -4
  29. package/dist/{generate-all-DgEFOXwU.mjs.map → generate-all-5Om0CB4N.mjs.map} +1 -1
  30. package/dist/{generate-desktop-shell-BXcGvbms.mjs → generate-desktop-shell-DzEzNspp.mjs} +4 -4
  31. package/dist/{generate-desktop-shell-BXcGvbms.mjs.map → generate-desktop-shell-DzEzNspp.mjs.map} +1 -1
  32. package/dist/{get-version-_coBX13A.mjs → get-version-C-oL2owF.mjs} +4 -4
  33. package/dist/{get-version-_coBX13A.mjs.map → get-version-C-oL2owF.mjs.map} +1 -1
  34. package/dist/{index-DdpGYzN0.d.mts → index-CJN_BRkc.d.mts} +5 -3
  35. package/dist/index-CJN_BRkc.d.mts.map +1 -0
  36. package/dist/{mcp-CZ02pj76.mjs → mcp-DvyBEajv.mjs} +4 -4
  37. package/dist/{mcp-CZ02pj76.mjs.map → mcp-DvyBEajv.mjs.map} +1 -1
  38. package/dist/{member-config-8Vwys-4O.mjs → member-config-0tHtiVN_.mjs} +5 -5
  39. package/dist/{member-config-8Vwys-4O.mjs.map → member-config-0tHtiVN_.mjs.map} +1 -1
  40. package/dist/{ph-cli-commands-B37zr8uN.mjs → ph-cli-commands-C8eWT5mr.mjs} +19 -18
  41. package/dist/ph-cli-commands-C8eWT5mr.mjs.map +1 -0
  42. package/dist/ph-cli-commands-DviLBBKz.mjs +4 -0
  43. package/dist/{run-sugar-BzGnofrW.mjs → run-sugar-CRzZsmVo.mjs} +4 -4
  44. package/dist/{run-sugar-BzGnofrW.mjs.map → run-sugar-CRzZsmVo.mjs.map} +1 -1
  45. package/dist/runners/connect.d.mts +11 -3
  46. package/dist/runners/connect.d.mts.map +1 -1
  47. package/dist/runners/connect.mjs +36 -12
  48. package/dist/runners/connect.mjs.map +1 -1
  49. package/dist/runners/switchboard.d.mts +20 -5
  50. package/dist/runners/switchboard.d.mts.map +1 -1
  51. package/dist/runners/switchboard.mjs +49 -17
  52. package/dist/runners/switchboard.mjs.map +1 -1
  53. package/dist/{schemas-Cnv5AnQT.mjs → schemas-ByfuhvAb.mjs} +4 -4
  54. package/dist/{schemas-Cnv5AnQT.mjs.map → schemas-ByfuhvAb.mjs.map} +1 -1
  55. package/dist/{start-run-BAQDM5Bu.mjs → start-run-CRVBqQ8L.mjs} +4 -4
  56. package/dist/{start-run-BAQDM5Bu.mjs.map → start-run-CRVBqQ8L.mjs.map} +1 -1
  57. package/dist/switchboard-B7mvNWcd.mjs +4 -0
  58. package/dist/{switchboard-BI35F5H7.mjs → switchboard-Cqs5IBNF.mjs} +19 -12
  59. package/dist/switchboard-Cqs5IBNF.mjs.map +1 -0
  60. package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
  61. package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
  62. package/dist/{vetra-C9fsChId.mjs → vetra-DZYtcHqV.mjs} +7 -7
  63. package/dist/{vetra-C9fsChId.mjs.map → vetra-DZYtcHqV.mjs.map} +1 -1
  64. package/package.json +14 -14
  65. package/dist/build-DUzhIPb7.mjs.map +0 -1
  66. package/dist/build-FoZl36TM.mjs +0 -4
  67. package/dist/compound-Cfqa5Jal-B5rkCmIj.mjs.map +0 -1
  68. package/dist/connect-preview-8-qLgWKt.mjs.map +0 -1
  69. package/dist/connect-studio-BaVeuul3.mjs.map +0 -1
  70. package/dist/dist-Bd6sSt7Y.mjs.map +0 -1
  71. package/dist/index-DdpGYzN0.d.mts.map +0 -1
  72. package/dist/ph-cli-commands-B37zr8uN.mjs.map +0 -1
  73. package/dist/ph-cli-commands-S3ArIR8q.mjs +0 -4
  74. package/dist/switchboard-BI35F5H7.mjs.map +0 -1
  75. package/dist/switchboard-DohZ1tbp.mjs +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"run-sugar-BzGnofrW.mjs","sources":["../src/utils/run-sugar.ts"],"sourcesContent":["import { probeHostsFolder } from \"@powerhousedao/host-core\";\n\nexport interface RunSugarResult {\n args: string[];\n /** Set when hosts/ exists but is empty — the guard state: warn loudly, stay legacy. */\n warning?: string;\n}\n\n/**\n * `ph <host-name> [verb]` sugar: when the first arg is not a registered\n * command and names a host in the project's hosts/ folder, splice in `run`\n * (mirrors the connect→`connect studio` default-subcommand rewrite).\n * Built-in commands win collisions by construction — the known-command check\n * runs first. Callers only invoke this when the uniform-runners flag is on.\n */\n/** Classic commands that route through `ph run` in a hosts project — BARE\n * invocations only: extra flags are not representable on `ph run` yet, and\n * the classic path calls the same service, so flagged invocations stay\n * classic until the host-core compound takes over (phase 1). */\nconst CLASSIC_ALIASES = new Set([\"vetra\"]);\n\nexport function applyRunSugar(\n args: string[],\n knownCommands: ReadonlySet<string>,\n projectRoot: string,\n): RunSugarResult {\n const first = args[0];\n if (!first || first.startsWith(\"-\")) {\n return { args };\n }\n if (knownCommands.has(first)) {\n if (CLASSIC_ALIASES.has(first) && args.length === 1) {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", first] };\n }\n }\n return { args };\n }\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"empty\") {\n return {\n args,\n warning:\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js — ` +\n \"uniform-runners stays inactive (legacy command handling).\",\n };\n }\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n return { args };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAM,kCAAkB,IAAI,IAAI,CAAC,OAAO,CAAC;AAEzC,SAAgB,cACd,MACA,eACA,aACgB;CAChB,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,GAChC,OAAO,EAAE,KAAK;CAEhB,IAAI,cAAc,IAAI,KAAK,GAAG;EAC5B,IAAI,gBAAgB,IAAI,KAAK,KAAK,KAAK,WAAW,GAAG;GACnD,MAAM,QAAQ,iBAAiB,WAAW;GAC1C,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,EAAE;EAElC;EACA,OAAO,EAAE,KAAK;CAChB;CACA,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,IAAI,MAAM,SAAS,SACjB,OAAO;EACL;EACA,SACE,oBAAoB,MAAM,IAAI;CAElC;CAEF,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;CAElC,OAAO,EAAE,KAAK;AAChB","debug_id":"6b024114-e842-51b4-8e59-0be3c6302da1"}
1
+ {"version":3,"file":"run-sugar-CRzZsmVo.mjs","sources":["../src/utils/run-sugar.ts"],"sourcesContent":["import { probeHostsFolder } from \"@powerhousedao/host-core\";\n\nexport interface RunSugarResult {\n args: string[];\n /** Set when hosts/ exists but is empty — the guard state: warn loudly, stay legacy. */\n warning?: string;\n}\n\n/**\n * `ph <host-name> [verb]` sugar: when the first arg is not a registered\n * command and names a host in the project's hosts/ folder, splice in `run`\n * (mirrors the connect→`connect studio` default-subcommand rewrite).\n * Built-in commands win collisions by construction — the known-command check\n * runs first. Callers only invoke this when the uniform-runners flag is on.\n */\n/** Classic commands that route through `ph run` in a hosts project — BARE\n * invocations only: extra flags are not representable on `ph run` yet, and\n * the classic path calls the same service, so flagged invocations stay\n * classic until the host-core compound takes over (phase 1). */\nconst CLASSIC_ALIASES = new Set([\"vetra\"]);\n\nexport function applyRunSugar(\n args: string[],\n knownCommands: ReadonlySet<string>,\n projectRoot: string,\n): RunSugarResult {\n const first = args[0];\n if (!first || first.startsWith(\"-\")) {\n return { args };\n }\n if (knownCommands.has(first)) {\n if (CLASSIC_ALIASES.has(first) && args.length === 1) {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", first] };\n }\n }\n return { args };\n }\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"empty\") {\n return {\n args,\n warning:\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js — ` +\n \"uniform-runners stays inactive (legacy command handling).\",\n };\n }\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n return { args };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAM,kCAAkB,IAAI,IAAI,CAAC,OAAO,CAAC;AAEzC,SAAgB,cACd,MACA,eACA,aACgB;CAChB,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,GAChC,OAAO,EAAE,KAAK;CAEhB,IAAI,cAAc,IAAI,KAAK,GAAG;EAC5B,IAAI,gBAAgB,IAAI,KAAK,KAAK,KAAK,WAAW,GAAG;GACnD,MAAM,QAAQ,iBAAiB,WAAW;GAC1C,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,EAAE;EAElC;EACA,OAAO,EAAE,KAAK;CAChB;CACA,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,IAAI,MAAM,SAAS,SACjB,OAAO;EACL;EACA,SACE,oBAAoB,MAAM,IAAI;CAElC;CAEF,IAAI,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK,GACxD,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;CAElC,OAAO,EAAE,KAAK;AAChB","debug_id":"75a98593-127e-5938-a937-f024d6f0ffd0"}
@@ -1,4 +1,4 @@
1
- import { D as output$1, E as ZodUnknown, S as ZodString, T as ZodUnion, _ as ZodNullable, a as ItemToken, b as ZodOptional, c as RunnerHandle, d as input, f as output, g as ZodLiteral, h as ZodEnum, i as EnvToken, k as $strict, l as TokenableSchema, m as ZodBoolean, o as OutputToken, p as ZodArray, r as ConcatToken, s as RunnerContext, u as external_d_exports, v as ZodNumber, w as ZodURL, x as ZodRecord, y as ZodObject } from "../index-DdpGYzN0.mjs";
1
+ import { D as output$1, E as ZodUnknown, S as ZodString, T as ZodUnion, _ as ZodNullable, a as ItemToken, b as ZodOptional, c as RunnerHandle, d as input, f as output, g as ZodLiteral, h as ZodEnum, i as EnvToken, k as $strict, l as TokenableSchema, m as ZodBoolean, o as OutputToken, p as ZodArray, r as ConcatToken, s as RunnerContext, u as external_d_exports, v as ZodNumber, w as ZodURL, x as ZodRecord, y as ZodObject } from "../index-CJN_BRkc.mjs";
2
2
  import { PHConnectRuntimeConfig } from "@powerhousedao/shared/clis";
3
3
  //#region src/runners/connect.d.ts
4
4
  /**
@@ -42,11 +42,12 @@ export declare const declaredHostSchema: ZodObject<{
42
42
  dynamic: ZodOptional<ZodBoolean>;
43
43
  }, $strict>>;
44
44
  remote: ZodOptional<ZodObject<{
45
- url: TokenableSchema<ZodURL>;
45
+ url: TokenableSchema<ZodUnion<readonly [ZodURL, ZodString]>>;
46
46
  }, $strict>>;
47
47
  }, $strict>>>;
48
48
  placement: ZodOptional<ZodObject<{
49
49
  primary: ZodOptional<ZodString>;
50
+ drives: ZodOptional<ZodRecord<ZodString, ZodString>>;
50
51
  }, $strict>>;
51
52
  protocol: ZodOptional<ZodObject<{
52
53
  featureFlags: ZodOptional<ZodObject<{
@@ -105,6 +106,9 @@ export declare const declaredHostSchema: ZodObject<{
105
106
  outDir: ZodOptional<ZodString>;
106
107
  cspRegistrySync: ZodOptional<ZodBoolean>;
107
108
  routes: ZodOptional<ZodUnion<readonly [ZodString, ZodLiteral<false>]>>;
109
+ proxy: ZodOptional<ZodObject<{
110
+ target: TokenableSchema<ZodURL>;
111
+ }, $strict>>;
108
112
  }, $strict>;
109
113
  config: ZodOptional<ZodObject<{
110
114
  branding: ZodOptional<ZodObject<{
@@ -389,11 +393,12 @@ export declare const hostSchema: ZodObject<{
389
393
  dynamic: ZodOptional<ZodBoolean>;
390
394
  }, $strict>>;
391
395
  remote: ZodOptional<ZodObject<{
392
- url: TokenableSchema<ZodURL>;
396
+ url: TokenableSchema<ZodUnion<readonly [ZodURL, ZodString]>>;
393
397
  }, $strict>>;
394
398
  }, $strict>>>;
395
399
  placement: ZodOptional<ZodObject<{
396
400
  primary: ZodOptional<ZodString>;
401
+ drives: ZodOptional<ZodRecord<ZodString, ZodString>>;
397
402
  }, $strict>>;
398
403
  protocol: ZodOptional<ZodObject<{
399
404
  featureFlags: ZodOptional<ZodObject<{
@@ -452,6 +457,9 @@ export declare const hostSchema: ZodObject<{
452
457
  outDir: ZodOptional<ZodString>;
453
458
  cspRegistrySync: ZodOptional<ZodBoolean>;
454
459
  routes: ZodOptional<ZodUnion<readonly [ZodString, ZodLiteral<false>]>>;
460
+ proxy: ZodOptional<ZodObject<{
461
+ target: TokenableSchema<ZodURL>;
462
+ }, $strict>>;
455
463
  }, $strict>;
456
464
  config: ZodOptional<ZodObject<{
457
465
  branding: ZodOptional<ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.mts","names":[],"sources":["../../src/runners/connect.ts"],"mappings":";;;;;;;;;qBAwCa;qBA+BA,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;GAAqB;;YAGhC,cAAc,aAAe;;YAE7B,oBAAoB,cAAgB;;;qBAInC,eAAa;;;;;GAGxB;YACU,iBAAiB,gBAAe;QAEpC;YACI;IACR;MACE,MAAM;MACN,SAAS;;;;wBA+QC,mBAAmB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiBrB,IACpB,MAAM,mBACN,KAAK,gBACJ,QAAQ,aAAa;;;qBAiBX,YAAG;;wBAGM,MACpB,MAAM,mBACN,KAAK,gBACJ;;;;;;;;;wBAuBmB,MACpB,MAAM,mBACN,KAAK,gBACJ,QAAQ,aAAa"}
@@ -1,12 +1,13 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bc999a09-5124-54df-901c-a561fbab3730")}catch(e){}}();
3
- import { a as literal, d as union, l as strictObject, p as url, r as boolean, u as string } from "../schemas-Cnv5AnQT.mjs";
4
- import { N as normalizePluginEntries, _ as entryActiveForVerb, m as defineHostSchemas, y as findDeadConnectConfig } from "../compound-Cfqa5Jal-B5rkCmIj.mjs";
5
- import { a as isStructuralMultiReactor, g as resolveDriveDeclaration, h as remoteBackendUrls, l as projectDrivesIntoConnect, o as mergeDefaultDrives, u as projectReactorToConnect } from "../dist-Bd6sSt7Y.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="54404818-de56-5e01-936d-7c1f24806021")}catch(e){}}();
3
+ import { d as string, f as union, i as boolean, m as url, o as literal, u as strictObject } from "../schemas-ByfuhvAb.mjs";
4
+ import { N as normalizePluginEntries, _ as entryActiveForVerb, m as defineHostSchemas, y as findDeadConnectConfig } from "../compound-C7GuPnTP-Ba4ce2Xa.mjs";
5
+ import { a as isStructuralMultiReactor, g as resolveDriveDeclaration, h as remoteBackendUrls, l as projectDrivesIntoConnect, o as mergeDefaultDrives, u as projectReactorToConnect } from "../dist-DcARVrSg.mjs";
6
6
  import { join } from "node:path";
7
7
  import { DEFAULT_CONNECT_OUTDIR, DEFAULT_CONNECT_STUDIO_PORT } from "@powerhousedao/shared/clis";
8
8
  import { connectConfigSchemaWith } from "@powerhousedao/shared/connect/connect-config-schema";
9
9
  import { isPassthroughImageRef } from "@powerhousedao/shared/connect/image-ref";
10
+ import { withOriginPlaceholders } from "@powerhousedao/shared/connect/origin-placeholder";
10
11
  //#region src/runners/connect.ts
11
12
  /**
12
13
  * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a
@@ -36,7 +37,16 @@ const schemas = defineHostSchemas((s) => s.reactorHostSchema.extend({
36
37
  cspRegistrySync: boolean().optional(),
37
38
  /** The host's routes folder, project-relative; false for none.
38
39
  * Default: hosts/connect/routes. */
39
- routes: union([string(), literal(false)]).optional()
40
+ routes: union([string(), literal(false)]).optional(),
41
+ /** The switchboard this Connect is served next to: its server
42
+ * (dev and serve) proxies the switchboard's paths (`/graphql`,
43
+ * `/d/*`, `/attachments`, `/mcp`, `/api/*`) to `target`, and the
44
+ * served config names that switchboard as `${origin}`, resolved by
45
+ * the browser against the page's origin. So one config holds from
46
+ * the developer's `localhost` and from a published site alike, with
47
+ * every call on the page's own origin. Typically a sibling's
48
+ * `origin` output token. */
49
+ proxy: strictObject({ target: s.tokenable(url()) }).optional()
40
50
  }).strict(),
41
51
  config: connectConfigSchemaWith(s.tokenable).optional()
42
52
  }));
@@ -106,7 +116,20 @@ function declaredDrivesToDefaults(projectRoot, declarations) {
106
116
  };
107
117
  });
108
118
  }
119
+ /**
120
+ * The served override. With `runner.proxy`, every URL on the proxied
121
+ * switchboard's origin (drives, backends, plugin configs, however they were
122
+ * written or resolved from output tokens) is served as `${origin}…`: the
123
+ * browser reaches the switchboard through the page's own origin, which this
124
+ * Connect's server proxies, so the config holds wherever the page is loaded
125
+ * from. A host may also write `${origin}/…` itself; that passes through.
126
+ */
109
127
  function callerOverride(host, ctx, verb = "dev") {
128
+ const override = callerOverrideRaw(host, ctx, verb);
129
+ const target = host.runner.proxy?.target;
130
+ return override && target ? withOriginPlaceholders(override, target) : override;
131
+ }
132
+ function callerOverrideRaw(host, ctx, verb = "dev") {
110
133
  const base = { ...host.config };
111
134
  const reactor = host.reactor;
112
135
  const entries = host.runner.plugins;
@@ -194,7 +217,7 @@ async function startUnderSupervisor(ctx, start) {
194
217
  /** Fail at `ph run`, naming the plugin and key, when a composed Connect
195
218
  * plugin's entry config does not match its schema. */
196
219
  async function validateComposition(host, ctx) {
197
- const { validateConnectPluginConfigs } = await import("../connect-plugin-configs-BoPbxD9u.mjs");
220
+ const { validateConnectPluginConfigs } = await import("../connect-plugin-configs-CXN8_KL0.mjs");
198
221
  await validateConnectPluginConfigs(ctx.projectRoot, host.runner.plugins, ctx.verb, `hosts/${host.name}/host.js`);
199
222
  }
200
223
  /** A project file the build resolved: the built dist has it (as icon.ico or
@@ -217,11 +240,12 @@ function withoutBuiltImages(config) {
217
240
  const viteCacheOf = (host, ctx) => join(ctx.projectRoot, "node_modules", `.vite-${host.name.replace(/[^\w.-]/g, "_")}`);
218
241
  async function dev(host, ctx) {
219
242
  await validateComposition(host, ctx);
220
- const { runConnectStudio } = await import("../connect-studio-CfggUldW.mjs");
243
+ const { runConnectStudio } = await import("../connect-studio-Cf6UZvOo.mjs");
221
244
  const args = toStudioArgs(host);
222
245
  return connectHandle(await startUnderSupervisor(ctx, () => runConnectStudio(args, void 0, callerOverride(host, ctx, ctx.verb), {
223
246
  routes: host.runner.routes,
224
- cacheDir: viteCacheOf(host, ctx)
247
+ cacheDir: viteCacheOf(host, ctx),
248
+ proxy: host.runner.proxy?.target
225
249
  })), {
226
250
  host: "localhost",
227
251
  port: args.port
@@ -233,7 +257,7 @@ const run = dev;
233
257
  /** P3.3 — `build`: the SAME service as classic `ph connect build`. */
234
258
  async function build(host, ctx) {
235
259
  await validateComposition(host, ctx);
236
- const { runConnectBuild } = await import("../connect-build-BBAZuqpo.mjs");
260
+ const { runConnectBuild } = await import("../connect-build-7nmQw9c5.mjs");
237
261
  await runConnectBuild({ outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR }, callerOverride(host, ctx, ctx.verb), { routes: host.runner.routes });
238
262
  }
239
263
  /** P3.3 — `serve`: the SAME vite preview server as classic
@@ -246,7 +270,7 @@ async function build(host, ctx) {
246
270
  * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */
247
271
  async function serve(host, ctx) {
248
272
  await validateComposition(host, ctx);
249
- const { runConnectPreview } = await import("../connect-preview-8-qLgWKt.mjs");
273
+ const { runConnectPreview } = await import("../connect-preview-l0Car-nX.mjs");
250
274
  const runner = host.runner;
251
275
  const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;
252
276
  const bind = runner.host ?? "127.0.0.1";
@@ -264,7 +288,7 @@ async function serve(host, ctx) {
264
288
  return connectHandle(await startUnderSupervisor(ctx, () => runConnectPreview(args, {
265
289
  connect: override,
266
290
  cspRegistrySync: runner.cspRegistrySync === true
267
- })), {
291
+ }, void 0, { proxy: runner.proxy?.target })), {
268
292
  host: bind,
269
293
  port
270
294
  });
@@ -273,4 +297,4 @@ async function serve(host, ctx) {
273
297
  export { build, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, withoutBuiltImages };
274
298
 
275
299
  //# sourceMappingURL=connect.mjs.map
276
- //# debugId=bc999a09-5124-54df-901c-a561fbab3730
300
+ //# debugId=54404818-de56-5e01-936d-7c1f24806021
@@ -1 +1 @@
1
- {"version":3,"file":"connect.mjs","sources":["../../src/runners/connect.ts"],"sourcesContent":["import {\n DEFAULT_CONNECT_OUTDIR,\n DEFAULT_CONNECT_STUDIO_PORT,\n type PHConnectCompositionEntry,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { connectConfigSchemaWith } from \"@powerhousedao/shared/connect/connect-config-schema\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\nimport {\n defineHostSchemas,\n entryActiveForVerb,\n findDeadConnectConfig,\n isStructuralMultiReactor,\n mergeDefaultDrives,\n normalizePluginEntries,\n resolveDriveDeclaration,\n type DriveDeclaration,\n projectDrivesIntoConnect,\n projectReactorToConnect,\n remoteBackendUrls,\n type ReactorConfig,\n type RunnerContext,\n type RunnerHandle,\n} from \"@powerhousedao/host-core\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport type {\n ConnectBuildArgs,\n ConnectPreviewArgs,\n ConnectStudioArgs,\n} from \"../types.js\";\n\n/**\n * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a\n * hosts/connect/host.js definition onto the SAME service the classic\n * `ph connect studio` (dev/run), `ph connect build` and `ph connect preview`\n * (serve) commands call — no forked behavior.\n */\n\nexport const kind = \"reactor\";\n\n/** The connect host: the host-core reactor host with every runner option\n * this module reads declared (strict: an unknown runner key fails), and\n * `config` typed by Connect's own zod schema (the authored `connect` block),\n * whose URL fields that name another host's outputs\n * (`drives.defaultDrives[].url`, `renown.switchboardUrl`) are token-able.\n * One definition, two schemas: `declaredHostSchema` (token-able fields take\n * output tokens; types host files) and `hostSchema` (resolved; checked\n * right before the verb). */\nconst schemas = defineHostSchemas((s) =>\n s.reactorHostSchema.extend({\n runner: s.runnerBaseSchema\n .extend({\n /** Open a browser tab once listening (dev/serve). */\n openBrowser: z.boolean().optional(),\n /** Fail instead of moving to the next free port when `port` is taken. */\n strictPort: z.boolean().optional(),\n /** The Connect build output dir (`build` writes it, `serve` serves it). */\n outDir: z.string().min(1).optional(),\n /** Patch the baked CSP for the runtime registry (`serve`); a\n * compound's wiring sets it on its connect member. */\n cspRegistrySync: z.boolean().optional(),\n /** The host's routes folder, project-relative; false for none.\n * Default: hosts/connect/routes. */\n routes: z.union([z.string(), z.literal(false)]).optional(),\n })\n .strict(),\n config: connectConfigSchemaWith(s.tokenable).optional(),\n }),\n);\nexport const declaredHostSchema = schemas.declaredHostSchema;\nexport const hostSchema = schemas.hostSchema;\n\n/** What a connect host.js author writes. */\nexport type ConnectHost = z.input<typeof declaredHostSchema>;\n/** What a verb receives (defaults applied). */\nexport type ConnectHostParsed = z.output<typeof hostSchema>;\n\n/** What a started Connect (`dev`/`run`/`serve`) produces: the origin it\n * actually listens on and the app URL (origin plus base path). */\nexport const outputsSchema = z.strictObject({\n origin: z.url(),\n endpoints: z.strictObject({ connect: z.url() }),\n});\nexport type ConnectOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/ph-cli/runners/connect\": {\n host: ConnectHost;\n outputs: ConnectOutputs;\n };\n }\n}\n\n/** The slice of a vite dev/preview server a handle needs. */\ninterface ListeningServer {\n resolvedUrls: { local: string[] } | null;\n close(): Promise<void>;\n}\n\n/** A started Connect as a runner handle. vite has already listened when the\n * service returns, so `ready` is settled; the outputs carry the URL vite\n * resolved (the port it actually bound), falling back to the requested one. */\nfunction connectHandle(\n server: ListeningServer,\n requested: { host: string; port: number },\n): RunnerHandle<ConnectOutputs> {\n const fallback = `http://${requested.host}:${requested.port}/`;\n const app = server.resolvedUrls?.local[0] ?? fallback;\n let closing: Promise<void> | undefined;\n return {\n outputs: outputsSchema.parse({\n origin: new URL(app).origin,\n endpoints: { connect: app },\n }),\n ready: Promise.resolve(),\n shutdown: () => (closing ??= server.close()),\n };\n}\n\n/** The studio arg surface is wide (commonArgs + server args); the service only\n * reads a known subset, and the repo's own tests build these objects the same\n * way (Partial + cast — see connect-build.test.ts `mk()`). */\nfunction toStudioArgs(host: ConnectHostParsed): ConnectStudioArgs {\n const runner = host.runner;\n const args: Partial<ConnectStudioArgs> = {\n port: runner.port ?? DEFAULT_CONNECT_STUDIO_PORT,\n // The bind address (runnerBaseSchema `host`); unset keeps vite's default.\n ...(runner.host ? { host: runner.host } : {}),\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n printUrls: true,\n bindCLIShortcuts: false,\n };\n return args as ConnectStudioArgs;\n}\n\n/** Merge the reactor-block projection (protocol → connect.reactor,\n * backend kind → instance.reactorWorker, workflows → app.workflowsEnabled)\n * into the host's connect config, which rides the studio caller-override.\n * The host config wins on conflict (an explicit connect.* value is intent) —\n * EXCEPT structural multi-reactor (P4.2): declaring a remote backend next to\n * a local one IS the intent, so it beats a scaffold-default\n * instance.multiReactor: false, and the remote's drive url merges FIRST into\n * drives.defaultDrives (the first url entry is what the routing client dials). */\n/** host.js reactor.drives -> the served drives.defaultDrives shapes: locals\n * carry id/name/icon and the preferredEditor under its Connect alias `app`;\n * remotes carry their URL. */\nfunction declaredDrivesToDefaults(\n projectRoot: string,\n declarations: readonly DriveDeclaration[],\n): PHConnectDefaultDrive[] {\n return declarations.map((declaration) => {\n const drive = resolveDriveDeclaration(projectRoot, declaration);\n if (drive.kind === \"remote\") {\n return {\n url: drive.remoteUrl!,\n name: drive.name,\n icon: drive.icon ?? null,\n };\n }\n return {\n local: true as const,\n id: drive.id,\n name: drive.name,\n icon: drive.icon ?? null,\n ...(drive.preferredEditor ? { app: drive.preferredEditor } : {}),\n };\n });\n}\n\nfunction callerOverride(\n host: ConnectHostParsed,\n ctx?: RunnerContext,\n verb = \"dev\",\n): PHConnectRuntimeConfig | undefined {\n // A copy: the projection below adds served-only keys (composition, …).\n const base: PHConnectRuntimeConfig = { ...host.config };\n const reactor: ReactorConfig | undefined = host.reactor;\n\n // R3: the composition (verb-filtered, projected as DATA — the browser\n // pipeline resolves and runs the entries), declared drives, and the\n // reactor-core identity/namespace keys.\n const entries = host.runner.plugins;\n const composition: PHConnectCompositionEntry[] | undefined =\n entries === undefined\n ? undefined\n : normalizePluginEntries(entries, `hosts/${host.name}/host.js`)\n .filter((entry) => entryActiveForVerb(entry, verb))\n .map((entry) => ({ module: entry.module, config: entry.config }));\n // Entry configs arrive RESOLVED: output tokens (e.g. the workflows\n // plugin's `drive: switchboard.drives.workflows.url`) were replaced by\n // `ph run` (standalone: the producer's run record; in a compound: the\n // member's live outputs) before validateHost let this verb run.\n if (entries !== undefined) {\n // Change 2: show the composition plan on the `ph run connect` terminal.\n // The pipeline itself runs in the browser (hook execution logs to the\n // browser console); here we report WHAT will be served and for which verb.\n const all = normalizePluginEntries(entries, `hosts/${host.name}/host.js`);\n console.log(\n `[connect] composition plan (verb=${verb}): ${composition?.length ?? 0} active of ${all.length} declared`,\n );\n for (const entry of all) {\n const active = entryActiveForVerb(entry, verb);\n const scope =\n entry.verbs === \"*\" ? \"\" : ` verbs=[${entry.verbs.join(\",\")}]`;\n const cfg = Object.keys(entry.config);\n console.log(\n `[connect] ${active ? \"•\" : \"○\"} ${entry.module}${scope}` +\n (cfg.length ? ` config: {${cfg.join(\", \")}}` : \"\") +\n (active ? \"\" : \" (inactive for this verb)\"),\n );\n }\n }\n // Config a Connect plugin owns, set on the host while that plugin is not\n // composed for this verb: Connect serves the plugin-absent value instead.\n for (const warning of findDeadConnectConfig(\n host.config,\n entries,\n verb,\n `hosts/${host.name}/host.js`,\n )) {\n console.warn(warning.message);\n }\n const declared = reactor?.drives;\n const declaredDefaults =\n declared && ctx\n ? declaredDrivesToDefaults(ctx.projectRoot, declared)\n : undefined;\n const reactorRenown = reactor?.renown;\n const reactorNamespace = reactor?.namespace;\n base.drives = declaredDefaults\n ? {\n ...base.drives,\n defaultDrives: mergeDefaultDrives(\n declaredDefaults,\n base.drives?.defaultDrives ?? [],\n ),\n preserveStrategy: base.drives?.preserveStrategy ?? \"preserve-all\",\n }\n : base.drives;\n if (composition) base.composition = composition;\n if (reactorRenown) base.renown = { ...reactorRenown, ...base.renown };\n if (reactorNamespace !== undefined)\n base.instance = {\n ...base.instance,\n namespace: base.instance?.namespace ?? reactorNamespace,\n } as typeof base.instance;\n const { connect } = projectReactorToConnect(reactor);\n const structural = isStructuralMultiReactor(reactor);\n if (!connect.reactor && !connect.instance && !connect.app && !structural) {\n // `base` IS host.config when the host has one; a host without a config\n // block still carries its composition and drives (set on `base` above).\n // With none of the three, there is no override: a classic build.\n return host.config !== undefined || composition || declaredDefaults\n ? base\n : undefined;\n }\n const drives = structural\n ? projectDrivesIntoConnect({\n createdDriveUrls: remoteBackendUrls(reactor),\n configuredDefaultDrives: base.drives?.defaultDrives,\n }).drives\n : base.drives;\n // When the host DECLARES backends, instance facts derive from them and win\n // over config defaults (declaring `kind: \"worker\"` is more explicit intent\n // than a scaffold's `reactorWorker: false`); without backends the P2 rule\n // stands — an explicit connect.* value wins over descriptive projection.\n const declaresBackends = Object.keys(reactor?.backends ?? {}).length > 0;\n const instance = declaresBackends\n ? {\n ...base.instance,\n ...connect.instance,\n ...(structural ? { multiReactor: true } : {}),\n }\n : { ...connect.instance, ...base.instance };\n return {\n ...base,\n reactor: { ...connect.reactor, ...base.reactor },\n instance: instance as never,\n app: { ...connect.app, ...base.app },\n ...(drives ? { drives: { ...base.drives, ...drives } } : {}),\n };\n}\n\n/**\n * Start a server; under a supervising compound (`ctx.parent`), drop the\n * process-exiting signal listeners it installed (vite's dev and preview\n * servers exit on SIGTERM): the compound owns the exit and stops members in\n * reverse dependency order through their handles.\n */\nasync function startUnderSupervisor<T>(\n ctx: RunnerContext,\n start: () => Promise<T>,\n): Promise<T> {\n if (!ctx.parent) return start();\n const signals = [\"SIGINT\", \"SIGTERM\"] as const;\n const before = new Map(\n signals.map((signal) => [signal, new Set(process.listeners(signal))]),\n );\n try {\n return await start();\n } finally {\n for (const signal of signals) {\n for (const listener of process.listeners(signal)) {\n if (!before.get(signal)?.has(listener)) {\n process.off(signal, listener);\n }\n }\n }\n }\n}\n\n/** Fail at `ph run`, naming the plugin and key, when a composed Connect\n * plugin's entry config does not match its schema. */\nasync function validateComposition(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n const { validateConnectPluginConfigs } =\n await import(\"./connect-plugin-configs.js\");\n await validateConnectPluginConfigs(\n ctx.projectRoot,\n host.runner.plugins,\n ctx.verb,\n `hosts/${host.name}/host.js`,\n );\n}\n\n/** A project file the build resolved: the built dist has it (as icon.ico or\n * a data URI); served, its path would mean nothing. */\nfunction isBuiltImage(ref: unknown): boolean {\n const src =\n typeof ref === \"object\" && ref !== null && \"src\" in ref ? ref.src : ref;\n return typeof src === \"string\" && !isPassthroughImageRef(src);\n}\n\n// The served config keeps the build's images: the favicon and any branding\n// image given as a project path were resolved into the dist, and merged over\n// it a path would replace the built data URI with a URL that 404s.\nexport function withoutBuiltImages(config: PHConnectRuntimeConfig | undefined) {\n const branding = config?.branding;\n if (!branding) return config;\n const { favicon: _, ...served } = branding;\n if (isBuiltImage(served.icon)) delete served.icon;\n if (isBuiltImage(served.loader)) delete served.loader;\n return { ...config, branding: served };\n}\n\n// Per host: Studio and other hosts' dev servers run side by side in one project.\nconst viteCacheOf = (host: ConnectHostParsed, ctx: RunnerContext) =>\n join(\n ctx.projectRoot,\n \"node_modules\",\n `.vite-${host.name.replace(/[^\\w.-]/g, \"_\")}`,\n );\n\nexport async function dev(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n const args = toStudioArgs(host);\n const server = await startUnderSupervisor(ctx, () =>\n runConnectStudio(args, undefined, callerOverride(host, ctx, ctx.verb), {\n routes: host.runner.routes,\n cacheDir: viteCacheOf(host, ctx),\n }),\n );\n // vite's dev server binds its default host (\"localhost\") here.\n return connectHandle(server, { host: \"localhost\", port: args.port });\n}\n\n/** `run` is dev-studio until the plugin phases give hosts a production\n * runtime; `serve` (below) is the static production server. */\nexport const run = dev;\n\n/** P3.3 — `build`: the SAME service as classic `ph connect build`. */\nexport async function build(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await validateComposition(host, ctx);\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n const args: Partial<ConnectBuildArgs> = {\n // Classic `ph connect`'s default: `dist/` is the package `ph build` writes.\n outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n };\n // The host's config bakes in: its title, favicon, manifest, base path and loading shell.\n await runConnectBuild(\n args as ConnectBuildArgs,\n callerOverride(host, ctx, ctx.verb),\n { routes: host.runner.routes },\n );\n}\n\n/** P3.3 — `serve`: the SAME vite preview server as classic\n * `ph connect preview` (static serve of a built Connect; run `build` first).\n * The host's connect config (including a supervising compound's projected\n * drives and the reactor projection) rides a serve override: the baked\n * powerhouse.config.json merges with it at request time, and\n * `runner.cspRegistrySync` (set by the compound's wiring) patches the baked\n * CSP's script-src for the runtime registry — together these replace the\n * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */\nexport async function serve(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectPreview } = await import(\"../services/connect-preview.js\");\n const runner = host.runner;\n const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;\n const bind = runner.host ?? \"127.0.0.1\";\n const args: Partial<ConnectPreviewArgs> = {\n port,\n outDir: runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n cors: true,\n printUrls: true,\n bindCLIShortcuts: false,\n // Explicit IPv4 loopback (runner.host overrides): vite's default\n // \"localhost\" can bind ::1 only on Windows, and a supervising shell\n // (ph-win) probes 127.0.0.1 — the sidecar this replaces bound 127.0.0.1.\n host: bind,\n };\n const override = withoutBuiltImages(callerOverride(host, ctx, ctx.verb));\n const server = await startUnderSupervisor(ctx, () =>\n runConnectPreview(args as ConnectPreviewArgs, {\n connect: override,\n cspRegistrySync: runner.cspRegistrySync === true,\n }),\n );\n return connectHandle(server, { host: bind, port });\n}\n"],"names":["z.boolean","z.string","z.union","z.literal","z.strictObject","z.url"],"mappings":";;;;;;;;;;;;;;;;AAwCA,MAAa,OAAO;;;;;;;;;AAUpB,MAAM,UAAU,mBAAmB,MACjC,EAAE,kBAAkB,OAAO;CACzB,QAAQ,EAAE,iBACP,OAAO;;EAEN,aAAaA,QAAU,CAAC,CAAC,SAAS;;EAElC,YAAYA,QAAU,CAAC,CAAC,SAAS;;EAEjC,QAAQC,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;;EAGnC,iBAAiBD,QAAU,CAAC,CAAC,SAAS;;;EAGtC,QAAQE,MAAQ,CAACD,OAAS,GAAGE,QAAU,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;CAC3D,CAAC,CAAC,CACD,OAAO;CACV,QAAQ,wBAAwB,EAAE,SAAS,CAAC,CAAC,SAAS;AACxD,CAAC,CACH;AACA,MAAa,qBAAqB,QAAQ;AAC1C,MAAa,aAAa,QAAQ;;;AASlC,MAAa,gBAAgBC,aAAe;CAC1C,QAAQC,IAAM;CACd,WAAWD,aAAe,EAAE,SAASC,IAAM,EAAE,CAAC;AAChD,CAAC;;;;AAqBD,SAAS,cACP,QACA,WAC8B;CAC9B,MAAM,WAAW,UAAU,UAAU,KAAK,GAAG,UAAU,KAAK;CAC5D,MAAM,MAAM,OAAO,cAAc,MAAM,MAAM;CAC7C,IAAI;CACJ,OAAO;EACL,SA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OAAO;CAC3C,MAAM,SAAS,KAAK;CACpB,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,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;CAOvE,OAAO,cAAc,MANA,qBAAqB,WACxC,kBAAkB,MAA4B;EAC5C,SAAS;EACT,iBAAiB,OAAO,oBAAoB;CAC9C,CAAC,CACH,GAC6B;EAAE,MAAM;EAAM;CAAK,CAAC;AACnD","debug_id":"bc999a09-5124-54df-901c-a561fbab3730"}
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 resolveDriveDeclaration,\n type DriveDeclaration,\n projectDrivesIntoConnect,\n projectReactorToConnect,\n remoteBackendUrls,\n type ReactorConfig,\n type RunnerContext,\n type RunnerHandle,\n} from \"@powerhousedao/host-core\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport type {\n ConnectBuildArgs,\n ConnectPreviewArgs,\n ConnectStudioArgs,\n} from \"../types.js\";\n\n/**\n * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a\n * hosts/connect/host.js definition onto the SAME service the classic\n * `ph connect studio` (dev/run), `ph connect build` and `ph connect preview`\n * (serve) commands call — no forked behavior.\n */\n\nexport const kind = \"reactor\";\n\n/** The connect host: the host-core reactor host with every runner option\n * this module reads declared (strict: an unknown runner key fails), and\n * `config` typed by Connect's own zod schema (the authored `connect` block),\n * whose URL fields that name another host's outputs\n * (`drives.defaultDrives[].url`, `renown.switchboardUrl`) are token-able.\n * One definition, two schemas: `declaredHostSchema` (token-able fields take\n * output tokens; types host files) and `hostSchema` (resolved; checked\n * right before the verb). */\nconst schemas = defineHostSchemas((s) =>\n s.reactorHostSchema.extend({\n runner: s.runnerBaseSchema\n .extend({\n /** Open a browser tab once listening (dev/serve). */\n openBrowser: z.boolean().optional(),\n /** Fail instead of moving to the next free port when `port` is taken. */\n strictPort: z.boolean().optional(),\n /** The Connect build output dir (`build` writes it, `serve` serves it). */\n outDir: z.string().min(1).optional(),\n /** Patch the baked CSP for the runtime registry (`serve`); a\n * compound's wiring sets it on its connect member. */\n cspRegistrySync: z.boolean().optional(),\n /** The host's routes folder, project-relative; false for none.\n * Default: hosts/connect/routes. */\n routes: z.union([z.string(), z.literal(false)]).optional(),\n /** 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);\nexport const declaredHostSchema = schemas.declaredHostSchema;\nexport const hostSchema = schemas.hostSchema;\n\n/** What a connect host.js author writes. */\nexport type ConnectHost = z.input<typeof declaredHostSchema>;\n/** What a verb receives (defaults applied). */\nexport type ConnectHostParsed = z.output<typeof hostSchema>;\n\n/** What a started Connect (`dev`/`run`/`serve`) produces: the origin it\n * actually listens on and the app URL (origin plus base path). */\nexport const outputsSchema = z.strictObject({\n origin: z.url(),\n endpoints: z.strictObject({ connect: z.url() }),\n});\nexport type ConnectOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/ph-cli/runners/connect\": {\n host: ConnectHost;\n outputs: ConnectOutputs;\n };\n }\n}\n\n/** The slice of a vite dev/preview server a handle needs. */\ninterface ListeningServer {\n resolvedUrls: { local: string[] } | null;\n close(): Promise<void>;\n}\n\n/** A started Connect as a runner handle. vite has already listened when the\n * service returns, so `ready` is settled; the outputs carry the URL vite\n * resolved (the port it actually bound), falling back to the requested one. */\nfunction connectHandle(\n server: ListeningServer,\n requested: { host: string; port: number },\n): RunnerHandle<ConnectOutputs> {\n const fallback = `http://${requested.host}:${requested.port}/`;\n const app = server.resolvedUrls?.local[0] ?? fallback;\n let closing: Promise<void> | undefined;\n return {\n outputs: outputsSchema.parse({\n origin: new URL(app).origin,\n endpoints: { connect: app },\n }),\n ready: Promise.resolve(),\n shutdown: () => (closing ??= server.close()),\n };\n}\n\n/** The studio arg surface is wide (commonArgs + server args); the service only\n * reads a known subset, and the repo's own tests build these objects the same\n * way (Partial + cast — see connect-build.test.ts `mk()`). */\nfunction toStudioArgs(host: ConnectHostParsed): ConnectStudioArgs {\n const runner = host.runner;\n const args: Partial<ConnectStudioArgs> = {\n port: runner.port ?? DEFAULT_CONNECT_STUDIO_PORT,\n // The bind address (runnerBaseSchema `host`); unset keeps vite's default.\n ...(runner.host ? { host: runner.host } : {}),\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n printUrls: true,\n bindCLIShortcuts: false,\n };\n return args as ConnectStudioArgs;\n}\n\n/** Merge the reactor-block projection (protocol → connect.reactor,\n * backend kind → instance.reactorWorker, workflows → app.workflowsEnabled)\n * into the host's connect config, which rides the studio caller-override.\n * The host config wins on conflict (an explicit connect.* value is intent) —\n * EXCEPT structural multi-reactor (P4.2): declaring a remote backend next to\n * a local one IS the intent, so it beats a scaffold-default\n * instance.multiReactor: false, and the remote's drive url merges FIRST into\n * drives.defaultDrives (the first url entry is what the routing client dials). */\n/** host.js reactor.drives -> the served drives.defaultDrives shapes: locals\n * carry id/name/icon and the preferredEditor under its Connect alias `app`;\n * remotes carry their URL. */\nfunction declaredDrivesToDefaults(\n projectRoot: string,\n declarations: readonly DriveDeclaration[],\n): PHConnectDefaultDrive[] {\n return declarations.map((declaration) => {\n const drive = resolveDriveDeclaration(projectRoot, declaration);\n if (drive.kind === \"remote\") {\n return {\n url: drive.remoteUrl!,\n name: drive.name,\n icon: drive.icon ?? null,\n };\n }\n return {\n local: true as const,\n id: drive.id,\n name: drive.name,\n icon: drive.icon ?? null,\n ...(drive.preferredEditor ? { app: drive.preferredEditor } : {}),\n };\n });\n}\n\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 */\nfunction 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 // R3: the composition (verb-filtered, projected as DATA — the browser\n // pipeline resolves and runs the entries), declared drives, and the\n // reactor-core identity/namespace keys.\n const entries = host.runner.plugins;\n const composition: PHConnectCompositionEntry[] | undefined =\n entries === undefined\n ? undefined\n : normalizePluginEntries(entries, `hosts/${host.name}/host.js`)\n .filter((entry) => entryActiveForVerb(entry, verb))\n .map((entry) => ({ module: entry.module, config: entry.config }));\n // Entry configs arrive RESOLVED: output tokens (e.g. the workflows\n // plugin's `drive: switchboard.drives.workflows.url`) were replaced by\n // `ph run` (standalone: the producer's run record; in a compound: the\n // member's live outputs) before validateHost let this verb run.\n if (entries !== undefined) {\n // Change 2: show the composition plan on the `ph run connect` terminal.\n // The pipeline itself runs in the browser (hook execution logs to the\n // browser console); here we report WHAT will be served and for which verb.\n const all = normalizePluginEntries(entries, `hosts/${host.name}/host.js`);\n console.log(\n `[connect] composition plan (verb=${verb}): ${composition?.length ?? 0} active of ${all.length} declared`,\n );\n for (const entry of all) {\n const active = entryActiveForVerb(entry, verb);\n const scope =\n entry.verbs === \"*\" ? \"\" : ` verbs=[${entry.verbs.join(\",\")}]`;\n const cfg = Object.keys(entry.config);\n console.log(\n `[connect] ${active ? \"•\" : \"○\"} ${entry.module}${scope}` +\n (cfg.length ? ` config: {${cfg.join(\", \")}}` : \"\") +\n (active ? \"\" : \" (inactive for this verb)\"),\n );\n }\n }\n // Config a Connect plugin owns, set on the host while that plugin is not\n // composed for this verb: Connect serves the plugin-absent value instead.\n for (const warning of findDeadConnectConfig(\n host.config,\n entries,\n verb,\n `hosts/${host.name}/host.js`,\n )) {\n console.warn(warning.message);\n }\n const declared = reactor?.drives;\n const declaredDefaults =\n declared && ctx\n ? declaredDrivesToDefaults(ctx.projectRoot, declared)\n : undefined;\n const reactorRenown = reactor?.renown;\n const reactorNamespace = reactor?.namespace;\n base.drives = declaredDefaults\n ? {\n ...base.drives,\n defaultDrives: mergeDefaultDrives(\n declaredDefaults,\n base.drives?.defaultDrives ?? [],\n ),\n preserveStrategy: base.drives?.preserveStrategy ?? \"preserve-all\",\n }\n : base.drives;\n if (composition) base.composition = composition;\n if (reactorRenown) base.renown = { ...reactorRenown, ...base.renown };\n if (reactorNamespace !== undefined)\n base.instance = {\n ...base.instance,\n namespace: base.instance?.namespace ?? reactorNamespace,\n } as typeof base.instance;\n const { connect } = projectReactorToConnect(reactor);\n const structural = isStructuralMultiReactor(reactor);\n if (!connect.reactor && !connect.instance && !connect.app && !structural) {\n // `base` IS host.config when the host has one; a host without a config\n // block still carries its composition and drives (set on `base` above).\n // With none of the three, there is no override: a classic build.\n return host.config !== undefined || composition || declaredDefaults\n ? base\n : undefined;\n }\n const drives = structural\n ? projectDrivesIntoConnect({\n createdDriveUrls: remoteBackendUrls(reactor),\n configuredDefaultDrives: base.drives?.defaultDrives,\n }).drives\n : base.drives;\n // When the host DECLARES backends, instance facts derive from them and win\n // over config defaults (declaring `kind: \"worker\"` is more explicit intent\n // than a scaffold's `reactorWorker: false`); without backends the P2 rule\n // stands — an explicit connect.* value wins over descriptive projection.\n const declaresBackends = Object.keys(reactor?.backends ?? {}).length > 0;\n const instance = declaresBackends\n ? {\n ...base.instance,\n ...connect.instance,\n ...(structural ? { multiReactor: true } : {}),\n }\n : { ...connect.instance, ...base.instance };\n return {\n ...base,\n reactor: { ...connect.reactor, ...base.reactor },\n instance: instance as never,\n app: { ...connect.app, ...base.app },\n ...(drives ? { drives: { ...base.drives, ...drives } } : {}),\n };\n}\n\n/**\n * Start a server; under a supervising compound (`ctx.parent`), drop the\n * process-exiting signal listeners it installed (vite's dev and preview\n * servers exit on SIGTERM): the compound owns the exit and stops members in\n * reverse dependency order through their handles.\n */\nasync function startUnderSupervisor<T>(\n ctx: RunnerContext,\n start: () => Promise<T>,\n): Promise<T> {\n if (!ctx.parent) return start();\n const signals = [\"SIGINT\", \"SIGTERM\"] as const;\n const before = new Map(\n signals.map((signal) => [signal, new Set(process.listeners(signal))]),\n );\n try {\n return await start();\n } finally {\n for (const signal of signals) {\n for (const listener of process.listeners(signal)) {\n if (!before.get(signal)?.has(listener)) {\n process.off(signal, listener);\n }\n }\n }\n }\n}\n\n/** Fail at `ph run`, naming the plugin and key, when a composed Connect\n * plugin's entry config does not match its schema. */\nasync function validateComposition(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n const { validateConnectPluginConfigs } =\n await import(\"./connect-plugin-configs.js\");\n await validateConnectPluginConfigs(\n ctx.projectRoot,\n host.runner.plugins,\n ctx.verb,\n `hosts/${host.name}/host.js`,\n );\n}\n\n/** A project file the build resolved: the built dist has it (as icon.ico or\n * a data URI); served, its path would mean nothing. */\nfunction isBuiltImage(ref: unknown): boolean {\n const src =\n typeof ref === \"object\" && ref !== null && \"src\" in ref ? ref.src : ref;\n return typeof src === \"string\" && !isPassthroughImageRef(src);\n}\n\n// The served config keeps the build's images: the favicon and any branding\n// image given as a project path were resolved into the dist, and merged over\n// it a path would replace the built data URI with a URL that 404s.\nexport function withoutBuiltImages(config: PHConnectRuntimeConfig | undefined) {\n const branding = config?.branding;\n if (!branding) return config;\n const { favicon: _, ...served } = branding;\n if (isBuiltImage(served.icon)) delete served.icon;\n if (isBuiltImage(served.loader)) delete served.loader;\n return { ...config, branding: served };\n}\n\n// Per host: Studio and other hosts' dev servers run side by side in one project.\nconst viteCacheOf = (host: ConnectHostParsed, ctx: RunnerContext) =>\n join(\n ctx.projectRoot,\n \"node_modules\",\n `.vite-${host.name.replace(/[^\\w.-]/g, \"_\")}`,\n );\n\nexport async function dev(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n const args = toStudioArgs(host);\n const server = await startUnderSupervisor(ctx, () =>\n runConnectStudio(args, undefined, callerOverride(host, ctx, ctx.verb), {\n routes: host.runner.routes,\n cacheDir: viteCacheOf(host, ctx),\n proxy: host.runner.proxy?.target,\n }),\n );\n // vite's dev server binds its default host (\"localhost\") here.\n return connectHandle(server, { host: \"localhost\", port: args.port });\n}\n\n/** `run` is dev-studio until the plugin phases give hosts a production\n * runtime; `serve` (below) is the static production server. */\nexport const run = dev;\n\n/** P3.3 — `build`: the SAME service as classic `ph connect build`. */\nexport async function build(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await validateComposition(host, ctx);\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n const args: Partial<ConnectBuildArgs> = {\n // Classic `ph connect`'s default: `dist/` is the package `ph build` writes.\n outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n };\n // The host's config bakes in: its title, favicon, manifest, base path and loading shell.\n await runConnectBuild(\n args as ConnectBuildArgs,\n callerOverride(host, ctx, ctx.verb),\n { routes: host.runner.routes },\n );\n}\n\n/** P3.3 — `serve`: the SAME vite preview server as classic\n * `ph connect preview` (static serve of a built Connect; run `build` first).\n * The host's connect config (including a supervising compound's projected\n * drives and the reactor projection) rides a serve override: the baked\n * powerhouse.config.json merges with it at request time, and\n * `runner.cspRegistrySync` (set by the compound's wiring) patches the baked\n * CSP's script-src for the runtime registry — together these replace the\n * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */\nexport async function serve(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectPreview } = await import(\"../services/connect-preview.js\");\n const runner = host.runner;\n const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;\n const bind = runner.host ?? \"127.0.0.1\";\n const args: Partial<ConnectPreviewArgs> = {\n port,\n outDir: runner.outDir ?? DEFAULT_CONNECT_OUTDIR,\n open: runner.openBrowser === true,\n strictPort: runner.strictPort === true,\n cors: true,\n printUrls: true,\n bindCLIShortcuts: false,\n // Explicit IPv4 loopback (runner.host overrides): vite's default\n // \"localhost\" can bind ::1 only on Windows, and a supervising shell\n // (ph-win) probes 127.0.0.1 — the sidecar this replaces bound 127.0.0.1.\n host: bind,\n };\n const override = withoutBuiltImages(callerOverride(host, ctx, ctx.verb));\n const server = await startUnderSupervisor(ctx, () =>\n runConnectPreview(\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"],"names":["z.boolean","z.string","z.union","z.literal","z.strictObject","z.url"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,MAAa,OAAO;;;;;;;;;AAUpB,MAAM,UAAU,mBAAmB,MACjC,EAAE,kBAAkB,OAAO;CACzB,QAAQ,EAAE,iBACP,OAAO;;EAEN,aAAaA,QAAU,CAAC,CAAC,SAAS;;EAElC,YAAYA,QAAU,CAAC,CAAC,SAAS;;EAEjC,QAAQC,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;;EAGnC,iBAAiBD,QAAU,CAAC,CAAC,SAAS;;;EAGtC,QAAQE,MAAQ,CAACD,OAAS,GAAGE,QAAU,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;;;;;;;;;EASzD,OAAOC,aAAe,EAAE,QAAQ,EAAE,UAAUC,IAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;CACnE,CAAC,CAAC,CACD,OAAO;CACV,QAAQ,wBAAwB,EAAE,SAAS,CAAC,CAAC,SAAS;AACxD,CAAC,CACH;AACA,MAAa,qBAAqB,QAAQ;AAC1C,MAAa,aAAa,QAAQ;;;AASlC,MAAa,gBAAgBD,aAAe;CAC1C,QAAQC,IAAM;CACd,WAAWD,aAAe,EAAE,SAASC,IAAM,EAAE,CAAC;AAChD,CAAC;;;;AAqBD,SAAS,cACP,QACA,WAC8B;CAC9B,MAAM,WAAW,UAAU,UAAU,KAAK,GAAG,UAAU,KAAK;CAC5D,MAAM,MAAM,OAAO,cAAc,MAAM,MAAM;CAC7C,IAAI;CACJ,OAAO;EACL,SAAS,cAAc,MAAM;GAC3B,QAAQ,IAAI,IAAI,GAAG,CAAC,CAAC;GACrB,WAAW,EAAE,SAAS,IAAI;EAC5B,CAAC;EACD,OAAO,QAAQ,QAAQ;EACvB,gBAAiB,YAAY,OAAO,MAAM;CAC5C;AACF;;;;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GAAG;CACnC,MAAM,EAAE,sBAAsB,MAAM,OAAO;CAC3C,MAAM,SAAS,KAAK;CACpB,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,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,qBAAqB,WACxC,kBACE,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","debug_id":"54404818-de56-5e01-936d-7c1f24806021"}
@@ -1,4 +1,4 @@
1
- import { C as ZodType, D as output$1, E as ZodUnknown, O as $ZodTypeInternals, S as ZodString, T as ZodUnion, b as ZodOptional, c as RunnerHandle, d as input, f as output, g as ZodLiteral, h as ZodEnum, i as EnvToken, k as $strict, l as TokenableSchema, m as ZodBoolean, n as BootIssue, p as ZodArray, s as RunnerContext, t as BootCheckContext, u as external_d_exports, v as ZodNumber, w as ZodURL, x as ZodRecord, y as ZodObject } from "../index-DdpGYzN0.mjs";
1
+ import { C as ZodType, D as output$1, E as ZodUnknown, O as $ZodTypeInternals, S as ZodString, T as ZodUnion, b as ZodOptional, c as RunnerHandle, d as input, f as output, g as ZodLiteral, h as ZodEnum, i as EnvToken, k as $strict, l as TokenableSchema, m as ZodBoolean, n as BootIssue, p as ZodArray, s as RunnerContext, t as BootCheckContext, u as external_d_exports, v as ZodNumber, w as ZodURL, x as ZodRecord, y as ZodObject } from "../index-CJN_BRkc.mjs";
2
2
  import { ParsedCmdResult } from "@powerhousedao/shared/clis";
3
3
  //#region src/commands/switchboard.d.ts
4
4
  declare const switchboard: Partial<import("cmd-ts/dist/cjs/argparser.js").Register> & {
@@ -9,7 +9,7 @@ declare const switchboard: Partial<import("cmd-ts/dist/cjs/argparser.js").Regist
9
9
  httpsCertFile: string | undefined;
10
10
  dev: boolean | undefined;
11
11
  remoteDrives: string[];
12
- disableLocalPackages: boolean;
12
+ disableLocalPackages: boolean | undefined;
13
13
  packages: string | undefined;
14
14
  port: number;
15
15
  basePath: string | undefined;
@@ -32,7 +32,7 @@ declare const switchboard: Partial<import("cmd-ts/dist/cjs/argparser.js").Regist
32
32
  httpsCertFile: string | undefined;
33
33
  dev: boolean | undefined;
34
34
  remoteDrives: string[];
35
- disableLocalPackages: boolean;
35
+ disableLocalPackages: boolean | undefined;
36
36
  packages: string | undefined;
37
37
  port: number;
38
38
  basePath: string | undefined;
@@ -96,11 +96,12 @@ export declare const declaredHostSchema: ZodObject<{
96
96
  dynamic: ZodOptional<ZodBoolean>;
97
97
  }, $strict>>;
98
98
  remote: ZodOptional<ZodObject<{
99
- url: TokenableSchema<ZodURL>;
99
+ url: TokenableSchema<ZodUnion<readonly [ZodURL, ZodString]>>;
100
100
  }, $strict>>;
101
101
  }, $strict>>>;
102
102
  placement: ZodOptional<ZodObject<{
103
103
  primary: ZodOptional<ZodString>;
104
+ drives: ZodOptional<ZodRecord<ZodString, ZodString>>;
104
105
  }, $strict>>;
105
106
  protocol: ZodOptional<ZodObject<{
106
107
  featureFlags: ZodOptional<ZodObject<{
@@ -771,11 +772,12 @@ export declare const hostSchema: ZodObject<{
771
772
  dynamic: ZodOptional<ZodBoolean>;
772
773
  }, $strict>>;
773
774
  remote: ZodOptional<ZodObject<{
774
- url: TokenableSchema<ZodURL>;
775
+ url: TokenableSchema<ZodUnion<readonly [ZodURL, ZodString]>>;
775
776
  }, $strict>>;
776
777
  }, $strict>>>;
777
778
  placement: ZodOptional<ZodObject<{
778
779
  primary: ZodOptional<ZodString>;
780
+ drives: ZodOptional<ZodRecord<ZodString, ZodString>>;
779
781
  }, $strict>>;
780
782
  protocol: ZodOptional<ZodObject<{
781
783
  featureFlags: ZodOptional<ZodObject<{
@@ -1451,6 +1453,19 @@ declare global {
1451
1453
  export type SwitchboardRunnerArgs = Omit<SwitchboardArgs, "mcp"> & {
1452
1454
  mcp: boolean | undefined;
1453
1455
  };
1456
+ /** Poll the default drive endpoint until the server answers — the compound's
1457
+ * readiness gate: Connect auto-connects the drive on first load, so the drive
1458
+ * must answer before the connect member serves (the sidecar's
1459
+ * waitForSwitchboard, moved behind the handle contract).
1460
+ *
1461
+ * The probe is anonymous, and a host with authentication on hides a drive
1462
+ * from a caller it refuses (`/d/:drive` answers 404 to anyone who may not
1463
+ * read it, 401 under the authenticated-caller floor). Those answers prove
1464
+ * the server is listening but not whether the drive exists, so `served`,
1465
+ * the reactor's own view of the drive, decides then; without it an
1466
+ * ADMIN_ONLY host never passes this gate and the compound tears down after
1467
+ * the timeout. */
1468
+ export declare function waitForDrive(url: string, timeoutMs: number, served?: () => Promise<boolean>, fetchImpl?: typeof fetch): Promise<void>;
1454
1469
  /** What a started switchboard returns. */
1455
1470
  export type SwitchboardHandle = RunnerHandle<SwitchboardOutputs>;
1456
1471
  export declare function run(host: SwitchboardHostParsed, ctx: RunnerContext): Promise<SwitchboardHandle>;
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.d.mts","names":[],"sources":["../../src/commands/switchboard.ts","../../src/types.ts","../../src/runners/switchboard.ts"],"mappings":";;;cAGa,aAAW,+CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6CtB,6CAAA,iDAAA,mDAAA;;;KCkBU,kBAAkB,uBAAuB;;;;;;;;;qBCzBxC;qBAoCA,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAqB;;YAGhC,kBAAkB,aAAe;;YAEjC,wBAAwB,cAAgB;;qBAGvC,8BAA4B;;;GAGvC;;;;;;;qBAQW,eAAa;;;;;;;;;;GAOxB;YACU,qBAAqB,gBAAe;QAExC;YACI;IACR;MACE,MAAM;MACN,SAAS;;;;;YAMH,wBAAwB,KAAK;EACvC;;;YAgHU,oBAAoB,aAAa;wBA0OvB,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;qBAIE,cAAK;wBAEI,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;;wBAKW,UACpB,MAAM,uBACN,KAAK,mBACJ,QAAQ;;;wBA+CW,MACpB,MAAM,uBACN,MAAM,gBACL"}
1
+ {"version":3,"file":"switchboard.d.mts","names":[],"sources":["../../src/commands/switchboard.ts","../../src/types.ts","../../src/runners/switchboard.ts"],"mappings":";;;cAGa,aAAW,+CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6CtB,6CAAA,iDAAA,mDAAA;;;KCkBU,kBAAkB,uBAAuB;;;;;;;;;qBCzBxC;qBAoCA,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAqB;;YAGhC,kBAAkB,aAAe;;YAEjC,wBAAwB,cAAgB;;qBAGvC,8BAA4B;;;GAGvC;;;;;;;qBAQW,eAAa;;;;;;;;;;GAOxB;YACU,qBAAqB,gBAAe;QAExC;YACI;IACR;MACE,MAAM;MACN,SAAS;;;;;YAMH,wBAAwB,KAAK;EACvC;;;;;;;;;;;;;;wBAqGoB,aACpB,aACA,mBACA,eAAe,kBACf,mBAAkB,QACjB;;YAqBS,oBAAoB,aAAa;wBA2PvB,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;qBAIE,cAAK;wBAEI,IACpB,MAAM,uBACN,KAAK,gBACJ,QAAQ;;wBAKW,UACpB,MAAM,uBACN,KAAK,mBACJ,QAAQ;;;wBA+CW,MACpB,MAAM,uBACN,MAAM,gBACL"}
@@ -1,9 +1,9 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1819c7f8-3860-5090-85e5-aa961b217309")}catch(e){}}();
3
- import { c as record, h as prettifyError, l as strictObject, p as url, r as boolean$1, s as number, u as string$1 } from "../schemas-Cnv5AnQT.mjs";
4
- import { g as drivesSchema, m as defineHostSchemas, q as resolveHostPlugins } from "../compound-Cfqa5Jal-B5rkCmIj.mjs";
5
- import { _ as seedDrives, d as protocolConflicts, g as resolveDriveDeclaration, s as mergeDrivePlan } from "../dist-Bd6sSt7Y.mjs";
6
- import { a as reactorBlockConflicts, c as switchboardDevMode, i as prepareMemberStorage, n as memberSwitchboardConfig, o as readModelAsReactorStore, r as memberSwitchboardConfigSchema, t as memberEnvOf } from "../member-config-8Vwys-4O.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="af87578f-bf2a-53ca-8327-99180580fc49")}catch(e){}}();
3
+ import { c as number, d as string$1, g as prettifyError, i as boolean$1, l as record, m as url, u as strictObject } from "../schemas-ByfuhvAb.mjs";
4
+ import { g as drivesSchema, m as defineHostSchemas, q as resolveHostPlugins } from "../compound-C7GuPnTP-Ba4ce2Xa.mjs";
5
+ import { _ as seedDrives, d as protocolConflicts, g as resolveDriveDeclaration, s as mergeDrivePlan } from "../dist-DcARVrSg.mjs";
6
+ import { a as reactorBlockConflicts, c as switchboardDevMode, i as prepareMemberStorage, n as memberSwitchboardConfig, o as readModelAsReactorStore, r as memberSwitchboardConfigSchema, t as memberEnvOf } from "../member-config-0tHtiVN_.mjs";
7
7
  import { command, runSafely } from "cmd-ts";
8
8
  import { switchboardArgs } from "@powerhousedao/shared/clis/args";
9
9
  import path from "node:path";
@@ -318,12 +318,27 @@ function pluginDrives(projectRoot, hostDrives, composition, where) {
318
318
  /** Poll the default drive endpoint until the server answers — the compound's
319
319
  * readiness gate: Connect auto-connects the drive on first load, so the drive
320
320
  * must answer before the connect member serves (the sidecar's
321
- * waitForSwitchboard, moved behind the handle contract). */
322
- async function waitForDrive(url, timeoutMs) {
321
+ * waitForSwitchboard, moved behind the handle contract).
322
+ *
323
+ * The probe is anonymous, and a host with authentication on hides a drive
324
+ * from a caller it refuses (`/d/:drive` answers 404 to anyone who may not
325
+ * read it, 401 under the authenticated-caller floor). Those answers prove
326
+ * the server is listening but not whether the drive exists, so `served`,
327
+ * the reactor's own view of the drive, decides then; without it an
328
+ * ADMIN_ONLY host never passes this gate and the compound tears down after
329
+ * the timeout. */
330
+ async function waitForDrive(url, timeoutMs, served, fetchImpl = fetch) {
323
331
  const deadline = Date.now() + timeoutMs;
332
+ const HIDDEN = /* @__PURE__ */ new Set([
333
+ 401,
334
+ 403,
335
+ 404
336
+ ]);
324
337
  for (;;) {
325
338
  try {
326
- if ((await fetch(url, { signal: AbortSignal.timeout(3e3) })).ok) return;
339
+ const res = await fetchImpl(url, { signal: AbortSignal.timeout(3e3) });
340
+ if (res.ok) return;
341
+ if (HIDDEN.has(res.status) && served && await served()) return;
327
342
  } catch {}
328
343
  if (Date.now() > deadline) throw new Error(`Switchboard drive ${url} did not answer within ${timeoutMs}ms.`);
329
344
  await new Promise((resolve) => setTimeout(resolve, 400));
@@ -377,11 +392,19 @@ async function start(host, ctx, devMode) {
377
392
  prepareMemberStorage(host.reactor, env.shell, hostFile);
378
393
  const legacyStore = readModelAsReactorStore(host.reactor, env.shell, hostFile);
379
394
  if (legacyStore) console.warn(legacyStore.warning);
380
- const { startSwitchboard } = await import("../switchboard-DohZ1tbp.mjs");
395
+ const { startSwitchboard } = await import("../switchboard-B7mvNWcd.mjs");
381
396
  const entries = host.runner.plugins;
382
397
  const entriesDeclared = entries !== void 0;
383
- const args = await toSwitchboardArgs(host, devMode, entriesDeclared);
384
- const memberConfig = await memberSwitchboardConfig(host, env, { pluginHost: entriesDeclared });
398
+ const classic = await toSwitchboardArgs(host, devMode, entriesDeclared);
399
+ const { https } = classic;
400
+ const args = {
401
+ ...classic,
402
+ https: void 0
403
+ };
404
+ const memberConfig = await memberSwitchboardConfig(host, env, {
405
+ pluginHost: entriesDeclared,
406
+ defaults: https === void 0 ? {} : { server: { https } }
407
+ });
385
408
  let pluginComposition;
386
409
  if (entries !== void 0) pluginComposition = await resolveHostPlugins(ctx.projectRoot, "switchboard", ctx.verb, entries, `hosts/${host.name}/host.js`);
387
410
  const hostDrives = (host.reactor?.drives ?? []).map((declaration) => ({
@@ -419,9 +442,10 @@ async function start(host, ctx, devMode) {
419
442
  id: seededIds.get(drive.slug) ?? drive.id,
420
443
  url: driveUrlOf(drive.slug)
421
444
  };
422
- const driveUrl = driveUrlOf(localHostDrives.length > 0 ? localHostDrives[0].drive.slug : defaultSlug);
445
+ const slug = localHostDrives.length > 0 ? localHostDrives[0].drive.slug : defaultSlug;
446
+ const driveUrl = driveUrlOf(slug);
423
447
  if (entries === void 0 && switchboard.workflowsEnabled) {
424
- const { seedWorkflowsDrive } = await import("../vetra-C9fsChId.mjs");
448
+ const { seedWorkflowsDrive } = await import("../vetra-DZYtcHqV.mjs");
425
449
  const { generateProjectDriveId } = await import("../utils-DAux4Ga7.mjs");
426
450
  const url = await seedWorkflowsDrive(switchboard.reactor, port);
427
451
  if (url) drives.workflows = {
@@ -429,7 +453,15 @@ async function start(host, ctx, devMode) {
429
453
  url
430
454
  };
431
455
  }
432
- const ready = waitForDrive(driveUrl, 18e4);
456
+ const served = async () => {
457
+ try {
458
+ const id = await switchboard.reactor.resolveIdOrSlug(slug);
459
+ return Boolean(id);
460
+ } catch {
461
+ return false;
462
+ }
463
+ };
464
+ const ready = waitForDrive(driveUrl, 18e4, served);
433
465
  ready.catch(() => void 0);
434
466
  const graphql = `${origin}/graphql`;
435
467
  let stopping;
@@ -493,11 +525,11 @@ async function checkBoot(host, ctx) {
493
525
  /** Build the project's reactor package (the SAME service as `ph build`) — what
494
526
  * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
495
527
  async function build(host, _ctx) {
496
- const { runBuild } = await import("../build-FoZl36TM.mjs");
528
+ const { runBuild } = await import("../build-wvc_NiGr.mjs");
497
529
  await runBuild({ outDir: host.runner.outDir ?? "dist" });
498
530
  }
499
531
  //#endregion
500
- export { build, checkBoot, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, switchboardDriveOutputSchema };
532
+ export { build, checkBoot, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, switchboardDriveOutputSchema, waitForDrive };
501
533
 
502
534
  //# sourceMappingURL=switchboard.mjs.map
503
- //# debugId=1819c7f8-3860-5090-85e5-aa961b217309
535
+ //# debugId=af87578f-bf2a-53ca-8327-99180580fc49