@powerhousedao/ph-cli 6.2.3-dev.82 → 6.2.3-dev.83

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 (48) hide show
  1. package/dist/{check-DkH9B91Z.mjs → check-D2r9Qbyf.mjs} +5 -5
  2. package/dist/{check-DkH9B91Z.mjs.map → check-D2r9Qbyf.mjs.map} +1 -1
  3. package/dist/{cli-connect-override-CpHjVMDt.mjs → cli-connect-override-Bv5y96A5.mjs} +4 -4
  4. package/dist/{cli-connect-override-CpHjVMDt.mjs.map → cli-connect-override-Bv5y96A5.mjs.map} +1 -1
  5. package/dist/cli.mjs +4 -4
  6. package/dist/{compound-YHuVvCFd-C5NLunJf.mjs → compound-GhJAA2dK-Cj36zhoQ.mjs} +16 -4
  7. package/dist/compound-GhJAA2dK-Cj36zhoQ.mjs.map +1 -0
  8. package/dist/{connect-build-BxFswE45.mjs → connect-build-_HyX7OUY.mjs} +4 -4
  9. package/dist/{connect-build-BxFswE45.mjs.map → connect-build-_HyX7OUY.mjs.map} +1 -1
  10. package/dist/{connect-config-4WOy_Zua.mjs → connect-config-BD1WzHpY.mjs} +4 -4
  11. package/dist/{connect-config-4WOy_Zua.mjs.map → connect-config-BD1WzHpY.mjs.map} +1 -1
  12. package/dist/{connect-plugin-configs-uOxnR-7b.mjs → connect-plugin-configs-tVn11Qb_.mjs} +4 -4
  13. package/dist/{connect-plugin-configs-uOxnR-7b.mjs.map → connect-plugin-configs-tVn11Qb_.mjs.map} +1 -1
  14. package/dist/{connect-studio-DrwbiFVf.mjs → connect-studio-7Bx53D6Z.mjs} +3 -3
  15. package/dist/{connect-studio-qmgFWSt8.mjs → connect-studio-C0LLX1TD.mjs} +4 -4
  16. package/dist/{connect-studio-qmgFWSt8.mjs.map → connect-studio-C0LLX1TD.mjs.map} +1 -1
  17. package/dist/{dist-BlpdH3RP.mjs → dist-BiB5aiS6.mjs} +124 -66
  18. package/dist/dist-BiB5aiS6.mjs.map +1 -0
  19. package/dist/{explain-DARxM6-8.mjs → explain-DnKF_KNm.mjs} +5 -5
  20. package/dist/{explain-DARxM6-8.mjs.map → explain-DnKF_KNm.mjs.map} +1 -1
  21. package/dist/{export-DCMLPFSh.mjs → export-1QvYpjR1.mjs} +4 -4
  22. package/dist/{export-DCMLPFSh.mjs.map → export-1QvYpjR1.mjs.map} +1 -1
  23. package/dist/{generate-all-tbCt5ty4.mjs → generate-all-BVRk64NX.mjs} +4 -4
  24. package/dist/{generate-all-tbCt5ty4.mjs.map → generate-all-BVRk64NX.mjs.map} +1 -1
  25. package/dist/{get-version-CeWPXpXy.mjs → get-version-D7KfXhrX.mjs} +4 -4
  26. package/dist/{get-version-CeWPXpXy.mjs.map → get-version-D7KfXhrX.mjs.map} +1 -1
  27. package/dist/{mcp-YVqVelqp.mjs → mcp-DxrRkBBm.mjs} +4 -4
  28. package/dist/{mcp-YVqVelqp.mjs.map → mcp-DxrRkBBm.mjs.map} +1 -1
  29. package/dist/{member-config-BMqPMA0P.mjs → member-config-ZEe4PlHE.mjs} +4 -4
  30. package/dist/{member-config-BMqPMA0P.mjs.map → member-config-ZEe4PlHE.mjs.map} +1 -1
  31. package/dist/{ph-cli-commands-DPINuS0Q.mjs → ph-cli-commands-D3NH12Ot.mjs} +13 -13
  32. package/dist/{ph-cli-commands-DPINuS0Q.mjs.map → ph-cli-commands-D3NH12Ot.mjs.map} +1 -1
  33. package/dist/ph-cli-commands-wRaHQaC5.mjs +4 -0
  34. package/dist/{run-sugar-BaVU46_Q.mjs → run-sugar-DWPDmuRj.mjs} +4 -4
  35. package/dist/{run-sugar-BaVU46_Q.mjs.map → run-sugar-DWPDmuRj.mjs.map} +1 -1
  36. package/dist/runners/connect.d.mts +88 -68
  37. package/dist/runners/connect.d.mts.map +1 -1
  38. package/dist/runners/connect.mjs +14 -17
  39. package/dist/runners/connect.mjs.map +1 -1
  40. package/dist/runners/switchboard.mjs +4 -4
  41. package/dist/{start-run-BogXSscB.mjs → start-run-CuQEMKRZ.mjs} +4 -4
  42. package/dist/{start-run-BogXSscB.mjs.map → start-run-CuQEMKRZ.mjs.map} +1 -1
  43. package/dist/{vetra-DUONHuYK.mjs → vetra-Ch4M1DtV.mjs} +6 -6
  44. package/dist/{vetra-DUONHuYK.mjs.map → vetra-Ch4M1DtV.mjs.map} +1 -1
  45. package/package.json +14 -14
  46. package/dist/compound-YHuVvCFd-C5NLunJf.mjs.map +0 -1
  47. package/dist/dist-BlpdH3RP.mjs.map +0 -1
  48. package/dist/ph-cli-commands-B5zSKfeX.mjs +0 -4
@@ -0,0 +1,4 @@
1
+ import { n as phCliCommands } from "./ph-cli-commands-D3NH12Ot.mjs";
2
+ export { phCliCommands };
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]="2cd6e717-d43c-5a56-a775-a6e55d5bd015")}catch(e){}}();
4
+ //# debugId=2cd6e717-d43c-5a56-a775-a6e55d5bd015
@@ -1,6 +1,6 @@
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]="541fab62-08ef-505a-9de5-1652aed5fad4")}catch(e){}}();
3
- import { R as probeHostsFolder } from "./compound-YHuVvCFd-C5NLunJf.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]="d9cea747-4542-50d1-95bf-d4c2176d640b")}catch(e){}}();
3
+ import { R as probeHostsFolder } from "./compound-GhJAA2dK-Cj36zhoQ.mjs";
4
4
  //#region src/utils/run-sugar.ts
5
5
  /**
6
6
  * `ph <host-name> [verb]` sugar: when the first arg is not a registered
@@ -35,5 +35,5 @@ function applyRunSugar(args, knownCommands, projectRoot) {
35
35
  //#endregion
36
36
  export { applyRunSugar };
37
37
 
38
- //# sourceMappingURL=run-sugar-BaVU46_Q.mjs.map
39
- //# debugId=541fab62-08ef-505a-9de5-1652aed5fad4
38
+ //# sourceMappingURL=run-sugar-DWPDmuRj.mjs.map
39
+ //# debugId=d9cea747-4542-50d1-95bf-d4c2176d640b
@@ -1 +1 @@
1
- {"version":3,"file":"run-sugar-BaVU46_Q.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":"541fab62-08ef-505a-9de5-1652aed5fad4"}
1
+ {"version":3,"file":"run-sugar-DWPDmuRj.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":"d9cea747-4542-50d1-95bf-d4c2176d640b"}
@@ -790,40 +790,6 @@ export declare function withoutBuiltImages(config: PHConnectRuntimeConfig | unde
790
790
  externalEnabled?: boolean | undefined;
791
791
  liveReload?: boolean | undefined;
792
792
  } | undefined;
793
- drives?: {
794
- allowAddDrive?: boolean | undefined;
795
- defaultDrives?: ({
796
- url: string;
797
- name?: string | null | undefined;
798
- icon?: string | null | undefined;
799
- } | {
800
- local: true;
801
- id: string;
802
- name?: string | null | undefined;
803
- icon?: string | null | undefined;
804
- app?: string | undefined;
805
- })[] | undefined;
806
- preserveStrategy?: "preserve-all" | "preserve-by-url-and-detach" | undefined;
807
- sections?: {
808
- remote?: {
809
- enabled?: boolean | undefined;
810
- allowAdd?: boolean | undefined;
811
- allowDelete?: boolean | undefined;
812
- } | undefined;
813
- local?: {
814
- enabled?: boolean | undefined;
815
- allowAdd?: boolean | undefined;
816
- allowDelete?: boolean | undefined;
817
- } | undefined;
818
- } | undefined;
819
- icons?: {
820
- localDrive?: string | null | undefined;
821
- remoteDrive?: string | null | undefined;
822
- folder?: string | null | undefined;
823
- document?: string | null | undefined;
824
- documents?: Record<string, string> | null | undefined;
825
- } | null | undefined;
826
- } | undefined;
827
793
  renown?: {
828
794
  url?: string | undefined;
829
795
  networkId?: string | undefined;
@@ -867,11 +833,55 @@ export declare function withoutBuiltImages(config: PHConnectRuntimeConfig | unde
867
833
  module: string;
868
834
  config?: Record<string, unknown> | undefined;
869
835
  }[] | undefined;
836
+ drives?: {
837
+ allowAddDrive?: boolean | undefined;
838
+ preserveStrategy?: "preserve-all" | "preserve-by-url-and-detach" | undefined;
839
+ sections?: {
840
+ remote?: {
841
+ enabled?: boolean | undefined;
842
+ allowAdd?: boolean | undefined;
843
+ allowDelete?: boolean | undefined;
844
+ } | undefined;
845
+ local?: {
846
+ enabled?: boolean | undefined;
847
+ allowAdd?: boolean | undefined;
848
+ allowDelete?: boolean | undefined;
849
+ } | undefined;
850
+ } | undefined;
851
+ icons?: {
852
+ localDrive?: string | null | undefined;
853
+ remoteDrive?: string | null | undefined;
854
+ folder?: string | null | undefined;
855
+ document?: string | null | undefined;
856
+ documents?: Record<string, string> | null | undefined;
857
+ } | null | undefined;
858
+ defaultDrives?: ({
859
+ url: string;
860
+ name?: string | null | undefined;
861
+ icon?: string | null | undefined;
862
+ backend?: string | undefined;
863
+ sync?: boolean | undefined;
864
+ } | {
865
+ local: true;
866
+ id: string;
867
+ name?: string | null | undefined;
868
+ icon?: string | null | undefined;
869
+ app?: string | undefined;
870
+ })[] | undefined;
871
+ } | undefined;
870
872
  instance?: {
871
873
  namespace: string | null;
872
874
  reactorWorker: boolean;
873
875
  multiReactor?: boolean | undefined;
874
876
  reactorClient?: "in-process" | "remote" | "router" | "worker" | undefined;
877
+ remoteBackends?: {
878
+ name: string;
879
+ url: string;
880
+ }[] | undefined;
881
+ collections?: Record<string, {
882
+ backend: string;
883
+ sync?: boolean | undefined;
884
+ }> | undefined;
875
885
  } | undefined;
876
886
  pwa?: {
877
887
  globPatterns?: string[] | undefined;
@@ -981,40 +991,6 @@ export declare function withoutBuiltImages(config: PHConnectRuntimeConfig | unde
981
991
  externalEnabled?: boolean | undefined;
982
992
  liveReload?: boolean | undefined;
983
993
  } | undefined;
984
- drives?: {
985
- allowAddDrive?: boolean | undefined;
986
- defaultDrives?: ({
987
- url: string;
988
- name?: string | null | undefined;
989
- icon?: string | null | undefined;
990
- } | {
991
- local: true;
992
- id: string;
993
- name?: string | null | undefined;
994
- icon?: string | null | undefined;
995
- app?: string | undefined;
996
- })[] | undefined;
997
- preserveStrategy?: "preserve-all" | "preserve-by-url-and-detach" | undefined;
998
- sections?: {
999
- remote?: {
1000
- enabled?: boolean | undefined;
1001
- allowAdd?: boolean | undefined;
1002
- allowDelete?: boolean | undefined;
1003
- } | undefined;
1004
- local?: {
1005
- enabled?: boolean | undefined;
1006
- allowAdd?: boolean | undefined;
1007
- allowDelete?: boolean | undefined;
1008
- } | undefined;
1009
- } | undefined;
1010
- icons?: {
1011
- localDrive?: string | null | undefined;
1012
- remoteDrive?: string | null | undefined;
1013
- folder?: string | null | undefined;
1014
- document?: string | null | undefined;
1015
- documents?: Record<string, string> | null | undefined;
1016
- } | null | undefined;
1017
- } | undefined;
1018
994
  renown?: {
1019
995
  url?: string | undefined;
1020
996
  networkId?: string | undefined;
@@ -1058,11 +1034,55 @@ export declare function withoutBuiltImages(config: PHConnectRuntimeConfig | unde
1058
1034
  module: string;
1059
1035
  config?: Record<string, unknown> | undefined;
1060
1036
  }[] | undefined;
1037
+ drives?: {
1038
+ allowAddDrive?: boolean | undefined;
1039
+ preserveStrategy?: "preserve-all" | "preserve-by-url-and-detach" | undefined;
1040
+ sections?: {
1041
+ remote?: {
1042
+ enabled?: boolean | undefined;
1043
+ allowAdd?: boolean | undefined;
1044
+ allowDelete?: boolean | undefined;
1045
+ } | undefined;
1046
+ local?: {
1047
+ enabled?: boolean | undefined;
1048
+ allowAdd?: boolean | undefined;
1049
+ allowDelete?: boolean | undefined;
1050
+ } | undefined;
1051
+ } | undefined;
1052
+ icons?: {
1053
+ localDrive?: string | null | undefined;
1054
+ remoteDrive?: string | null | undefined;
1055
+ folder?: string | null | undefined;
1056
+ document?: string | null | undefined;
1057
+ documents?: Record<string, string> | null | undefined;
1058
+ } | null | undefined;
1059
+ defaultDrives?: ({
1060
+ url: string;
1061
+ name?: string | null | undefined;
1062
+ icon?: string | null | undefined;
1063
+ backend?: string | undefined;
1064
+ sync?: boolean | undefined;
1065
+ } | {
1066
+ local: true;
1067
+ id: string;
1068
+ name?: string | null | undefined;
1069
+ icon?: string | null | undefined;
1070
+ app?: string | undefined;
1071
+ })[] | undefined;
1072
+ } | undefined;
1061
1073
  instance?: {
1062
1074
  namespace: string | null;
1063
1075
  reactorWorker: boolean;
1064
1076
  multiReactor?: boolean | undefined;
1065
1077
  reactorClient?: "in-process" | "remote" | "router" | "worker" | undefined;
1078
+ remoteBackends?: {
1079
+ name: string;
1080
+ url: string;
1081
+ }[] | undefined;
1082
+ collections?: Record<string, {
1083
+ backend: string;
1084
+ sync?: boolean | undefined;
1085
+ }> | undefined;
1066
1086
  } | undefined;
1067
1087
  pwa?: {
1068
1088
  globPatterns?: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.mts","names":[],"sources":["../../src/runners/connect.ts"],"mappings":";;;;;;;;;qBAyCa;qBAwCA,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6B;qBAC/C,YAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;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,8 +1,8 @@
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]="54404818-de56-5e01-936d-7c1f24806021")}catch(e){}}();
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]="157d6b2b-5c01-569b-97ac-5411de6453f9")}catch(e){}}();
3
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-YHuVvCFd-C5NLunJf.mjs";
5
- import { a as isStructuralMultiReactor, g as resolveDriveDeclaration, h as remoteBackendUrls, l as projectDrivesIntoConnect, o as mergeDefaultDrives, u as projectReactorToConnect } from "../dist-BlpdH3RP.mjs";
4
+ import { N as normalizePluginEntries, _ as entryActiveForVerb, m as defineHostSchemas, y as findDeadConnectConfig } from "../compound-GhJAA2dK-Cj36zhoQ.mjs";
5
+ import { _ as resolveDriveDeclaration, a as isStructuralMultiReactor, c as placeConnectDrives, d as projectReactorToConnect, g as remoteBackendUrls, o as mergeDefaultDrives, u as projectDrivesIntoConnect } from "../dist-BiB5aiS6.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";
@@ -88,14 +88,6 @@ function toStudioArgs(host) {
88
88
  bindCLIShortcuts: false
89
89
  };
90
90
  }
91
- /** Merge the reactor-block projection (protocol → connect.reactor,
92
- * backend kind → instance.reactorWorker, workflows → app.workflowsEnabled)
93
- * into the host's connect config, which rides the studio caller-override.
94
- * The host config wins on conflict (an explicit connect.* value is intent) —
95
- * EXCEPT structural multi-reactor (P4.2): declaring a remote backend next to
96
- * a local one IS the intent, so it beats a scaffold-default
97
- * instance.multiReactor: false, and the remote's drive url merges FIRST into
98
- * drives.defaultDrives (the first url entry is what the routing client dials). */
99
91
  /** host.js reactor.drives -> the served drives.defaultDrives shapes: locals
100
92
  * carry id/name/icon and the preferredEditor under its Connect alias `app`;
101
93
  * remotes carry their URL. */
@@ -169,14 +161,19 @@ function callerOverrideRaw(host, ctx, verb = "dev") {
169
161
  const { connect } = projectReactorToConnect(reactor);
170
162
  const structural = isStructuralMultiReactor(reactor);
171
163
  if (!connect.reactor && !connect.instance && !connect.app && !structural) return host.config !== void 0 || composition || declaredDefaults ? base : void 0;
172
- const drives = structural ? projectDrivesIntoConnect({
164
+ const projected = structural ? projectDrivesIntoConnect({
173
165
  createdDriveUrls: remoteBackendUrls(reactor),
174
166
  configuredDefaultDrives: base.drives?.defaultDrives
175
167
  }).drives : base.drives;
168
+ const placed = placeConnectDrives(reactor, projected?.defaultDrives ?? []);
169
+ const drives = projected?.defaultDrives === void 0 ? projected : {
170
+ ...projected,
171
+ defaultDrives: placed.defaultDrives
172
+ };
176
173
  const instance = Object.keys(reactor?.backends ?? {}).length > 0 ? {
177
174
  ...base.instance,
178
175
  ...connect.instance,
179
- ...structural ? { multiReactor: true } : {}
176
+ ...placed.collections ? { collections: placed.collections } : {}
180
177
  } : {
181
178
  ...connect.instance,
182
179
  ...base.instance
@@ -217,7 +214,7 @@ async function startUnderSupervisor(ctx, start) {
217
214
  /** Fail at `ph run`, naming the plugin and key, when a composed Connect
218
215
  * plugin's entry config does not match its schema. */
219
216
  async function validateComposition(host, ctx) {
220
- const { validateConnectPluginConfigs } = await import("../connect-plugin-configs-uOxnR-7b.mjs");
217
+ const { validateConnectPluginConfigs } = await import("../connect-plugin-configs-tVn11Qb_.mjs");
221
218
  await validateConnectPluginConfigs(ctx.projectRoot, host.runner.plugins, ctx.verb, `hosts/${host.name}/host.js`);
222
219
  }
223
220
  /** A project file the build resolved: the built dist has it (as icon.ico or
@@ -240,7 +237,7 @@ function withoutBuiltImages(config) {
240
237
  const viteCacheOf = (host, ctx) => join(ctx.projectRoot, "node_modules", `.vite-${host.name.replace(/[^\w.-]/g, "_")}`);
241
238
  async function dev(host, ctx) {
242
239
  await validateComposition(host, ctx);
243
- const { runConnectStudio } = await import("../connect-studio-DrwbiFVf.mjs");
240
+ const { runConnectStudio } = await import("../connect-studio-7Bx53D6Z.mjs");
244
241
  const args = toStudioArgs(host);
245
242
  return connectHandle(await startUnderSupervisor(ctx, () => runConnectStudio(args, void 0, callerOverride(host, ctx, ctx.verb), {
246
243
  routes: host.runner.routes,
@@ -257,7 +254,7 @@ const run = dev;
257
254
  /** P3.3 — `build`: the SAME service as classic `ph connect build`. */
258
255
  async function build(host, ctx) {
259
256
  await validateComposition(host, ctx);
260
- const { runConnectBuild } = await import("../connect-build-BxFswE45.mjs");
257
+ const { runConnectBuild } = await import("../connect-build-_HyX7OUY.mjs");
261
258
  await runConnectBuild({ outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR }, callerOverride(host, ctx, ctx.verb), { routes: host.runner.routes });
262
259
  }
263
260
  /** P3.3 — `serve`: the SAME vite preview server as classic
@@ -297,4 +294,4 @@ async function serve(host, ctx) {
297
294
  export { build, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, withoutBuiltImages };
298
295
 
299
296
  //# sourceMappingURL=connect.mjs.map
300
- //# debugId=54404818-de56-5e01-936d-7c1f24806021
297
+ //# debugId=157d6b2b-5c01-569b-97ac-5411de6453f9
@@ -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 { 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,QAA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A,EAAE,OAAO,OAAO,OAAO,OAAO,CAChC,CACF,GAC6B;EAAE,MAAM;EAAM;CAAK,CAAC;AACnD","debug_id":"54404818-de56-5e01-936d-7c1f24806021"}
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 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/** 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 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 */\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":";;;;;;;;;;;;;;;;;AA0CA,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,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qB,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":"157d6b2b-5c01-569b-97ac-5411de6453f9"}
@@ -1,9 +1,9 @@
1
1
 
2
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]="ee4e0810-101f-5cb0-a070-1c0e240ceee3")}catch(e){}}();
3
3
  import { c as number$1, 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-YHuVvCFd-C5NLunJf.mjs";
5
- import { _ as seedDrives, d as protocolConflicts, g as resolveDriveDeclaration, s as mergeDrivePlan } from "../dist-BlpdH3RP.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-BMqPMA0P.mjs";
4
+ import { g as drivesSchema, m as defineHostSchemas, q as resolveHostPlugins } from "../compound-GhJAA2dK-Cj36zhoQ.mjs";
5
+ import { _ as resolveDriveDeclaration, f as protocolConflicts, s as mergeDrivePlan, v as seedDrives } from "../dist-BiB5aiS6.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-ZEe4PlHE.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";
@@ -479,7 +479,7 @@ async function start(host, ctx, devMode) {
479
479
  const slug = localHostDrives.length > 0 ? localHostDrives[0].drive.slug : defaultSlug;
480
480
  const driveUrl = driveUrlOf(slug);
481
481
  if (entries === void 0 && switchboard.workflowsEnabled) {
482
- const { seedWorkflowsDrive } = await import("../vetra-DUONHuYK.mjs");
482
+ const { seedWorkflowsDrive } = await import("../vetra-Ch4M1DtV.mjs");
483
483
  const { generateProjectDriveId } = await import("../utils-DAux4Ga7.mjs");
484
484
  const url = await seeding(seedWorkflowsDrive(switchboard.reactor, port));
485
485
  if (url) drives.workflows = {
@@ -1,6 +1,6 @@
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]="18c29c7f-5d4b-56b5-8fe5-ea43f30be810")}catch(e){}}();
3
- import { A as loadProducers, B as processResolveEnv, E as isSchemaLike, K as resolveHostOutputs, P as outputRefsOf, S as getVerb, U as readProjectName, V as producerOutputsSchemas, W as readRunRecord, X as runRecordOutputSource, Y as resolveRunnerModule, et as toStartedHandle, it as writeRunRecord, k as loadHost, l as clearRunRecord, nt as validateDeclaredHost, r as ONE_SHOT_VERBS, rt as validateHost, z as probeRun } from "./compound-YHuVvCFd-C5NLunJf.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]="c5ec0091-ad36-544c-acd9-105162370681")}catch(e){}}();
3
+ import { A as loadProducers, B as processResolveEnv, E as isSchemaLike, K as resolveHostOutputs, P as outputRefsOf, S as getVerb, U as readProjectName, V as producerOutputsSchemas, W as readRunRecord, X as runRecordOutputSource, Y as resolveRunnerModule, et as toStartedHandle, it as writeRunRecord, k as loadHost, l as clearRunRecord, nt as validateDeclaredHost, r as ONE_SHOT_VERBS, rt as validateHost, z as probeRun } from "./compound-GhJAA2dK-Cj36zhoQ.mjs";
4
4
  //#region src/services/run/start-run.ts
5
5
  /**
6
6
  * `ph run <host> [verb]`: dispatch the verb (default `run`) of the host's
@@ -120,5 +120,5 @@ async function publishOutputs(runner, result, target) {
120
120
  //#endregion
121
121
  export { startRun };
122
122
 
123
- //# sourceMappingURL=start-run-BogXSscB.mjs.map
124
- //# debugId=18c29c7f-5d4b-56b5-8fe5-ea43f30be810
123
+ //# sourceMappingURL=start-run-CuQEMKRZ.mjs.map
124
+ //# debugId=c5ec0091-ad36-544c-acd9-105162370681
@@ -1 +1 @@
1
- {"version":3,"file":"start-run-BogXSscB.mjs","sources":["../src/services/run/start-run.ts"],"sourcesContent":["import {\n clearRunRecord,\n getVerb,\n isSchemaLike,\n loadHost,\n loadProducers,\n ONE_SHOT_VERBS,\n outputRefsOf,\n probeRun,\n processResolveEnv,\n producerOutputsSchemas,\n readProjectName,\n readRunRecord,\n resolveHostOutputs,\n resolveRunnerModule,\n runRecordOutputSource,\n toStartedHandle,\n validateDeclaredHost,\n validateHost,\n writeRunRecord,\n type RunnerModule,\n} from \"@powerhousedao/host-core\";\n\nexport interface StartRunArgs {\n host: string;\n verb?: string;\n projectRoot?: string;\n debug?: boolean;\n}\n\n/**\n * `ph run <host> [verb]`: dispatch the verb (default `run`) of the host's\n * declared runner. There is deliberately no type→runner registry — what a\n * host does is written in its own file.\n *\n * The pipeline (typed-host-configs 3.5): declared validation (token shapes,\n * `$output` paths against the producers' outputsSchemas, the runner's\n * declaredHostSchema), the live-instance lock, resolution (`$output` from\n * the producers' live run records, `$env` from this process, the\n * `${userData}` sugar), resolved validation, then the verb with the parsed\n * host. A compound runner gets its declared host: its members resolve their\n * own tokens as they start.\n *\n * A reactor runner that exports `outputsSchema` has its handle's outputs\n * published in a v2 `.ph/run/<name>.json` record once ready; this is the only\n * standalone writer (mastra included). Compounds write their own record with\n * the members in it; one-shot verbs (`build`) return nothing and write none.\n */\nexport async function startRun(args: StartRunArgs): Promise<unknown> {\n const projectRoot = args.projectRoot ?? process.cwd();\n const loaded = await loadHost(projectRoot, args.host);\n const { warnSupersededConfigKeys } = await import(\"./superseded-config.js\");\n warnSupersededConfigKeys(projectRoot);\n const specifier = loaded.host.runner.module;\n const runner = await resolveRunnerModule(projectRoot, specifier);\n const verb = args.verb ?? \"run\";\n const fn = getVerb(runner, specifier, verb);\n const file = loaded.file;\n if (args.debug) {\n console.log({ host: loaded.host.name, runner: specifier, verb });\n }\n\n if (runner.kind === \"compound\") {\n validateDeclaredHost(runner, specifier, loaded.host, file);\n const host = validateHost(runner, specifier, loaded.host, file, {\n tokens: \"allow\",\n });\n return fn(host, { projectRoot, verb, env: process.env });\n }\n\n const projectName = readProjectName(projectRoot);\n const producers = await loadProducers(projectRoot, outputRefsOf(loaded.host));\n validateDeclaredHost(runner, specifier, loaded.host, file, {\n outputsSchemaOf: producerOutputsSchemas(producers),\n });\n const oneShot = ONE_SHOT_VERBS.has(verb);\n if (oneShot) {\n // `build` reads no other host's outputs: no producer needs to run.\n const host = validateHost(runner, specifier, loaded.host, file, {\n tokens: \"allow\",\n });\n return fn(host, { projectRoot, verb, env: process.env });\n }\n const publishes = isSchemaLike(runner.outputsSchema);\n // Before the verb starts anything: a second live instance would take\n // over the first one's record (and clear it on exit).\n if (publishes) assertNotRunning(projectRoot, loaded.host.name, projectName);\n const resolved = resolveHostOutputs(loaded.host, {\n outputs: runRecordOutputSource(projectRoot, {\n consumer: args.host,\n producers,\n projectName,\n }),\n ...processResolveEnv(projectRoot),\n where: `hosts/${args.host}/host.js`,\n });\n const host = validateHost(runner, specifier, resolved, file);\n const result = await fn(host, { projectRoot, verb, env: process.env });\n if (publishes && result !== undefined && result !== null) {\n await publishOutputs(runner, result, {\n projectRoot,\n projectName,\n hostName: loaded.host.name,\n specifier,\n verb,\n });\n }\n return result;\n}\n\nfunction assertNotRunning(\n projectRoot: string,\n hostName: string,\n projectName: string,\n): void {\n const probe = probeRun(projectRoot, hostName, projectName);\n if (probe.status === \"live\" && probe.record.pid !== process.pid) {\n throw new Error(\n `${hostName} is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`,\n );\n }\n if (probe.status === \"foreign\") {\n throw new Error(\n `.ph/run/${hostName}.json describes a live \"${probe.record.projectName}\", but this project is \"${projectName}\". Refusing to start a second instance.`,\n );\n }\n}\n\ninterface PublishTarget {\n projectRoot: string;\n projectName: string;\n hostName: string;\n specifier: string;\n verb: string;\n}\n\n/** Await `ready`, validate the outputs, write the v2 record and clear it on\n * exit. A handle that never gets ready or reports invalid outputs is shut\n * down before the error propagates. */\nasync function publishOutputs(\n runner: RunnerModule,\n result: unknown,\n target: PublishTarget,\n): Promise<void> {\n const where = `${target.specifier} ${target.verb}`;\n const handle = toStartedHandle(result, where);\n const name = target.projectName;\n let outputs: unknown;\n try {\n if (!isSchemaLike(runner.outputsSchema)) return;\n // Checked again after the start: an instance that started meanwhile.\n assertNotRunning(target.projectRoot, target.hostName, name);\n if (handle.ready) await handle.ready;\n const parsed = runner.outputsSchema.safeParse(handle.outputs);\n if (!parsed.success) {\n const issues = parsed.error.issues\n .map(\n (issue) =>\n ` - ${issue.path.map(String).join(\".\") || \"<root>\"}: ${issue.message}`,\n )\n .join(\"\\n\");\n throw new Error(\n `${where} reported outputs that fail its outputsSchema:\\n${issues}`,\n );\n }\n outputs = parsed.data;\n } catch (error) {\n await handle.shutdown?.();\n throw error;\n }\n\n writeRunRecord(target.projectRoot, {\n version: 2,\n host: target.hostName,\n projectName: name,\n kind: \"reactor\",\n verb: target.verb,\n pid: process.pid,\n startedAt: new Date().toISOString(),\n outputs: outputs as Record<string, unknown>,\n });\n // No SIGINT/SIGTERM handler: the switchboard reactor's own handler kills\n // the reactor before draining the api, and a parallel shutdown() would\n // break that order. Without an exit event the record keeps a dead pid,\n // which probeRun reports as stale.\n process.on(\"exit\", () => {\n if (readRunRecord(target.projectRoot, target.host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KAAK,IAAI;GACZ,MAAM,IAAI,MACR,GAAG,MAAM,kDAAkD,QAC7D;EACF;EACA,UAAU,OAAO;CACnB,SAAS,OAAO;EACd,MAAM,OAAO,WAAW;EACxB,MAAM;CACR;CAEA,eAAe,OAAO,aAAa;EACjC,SAAS;EACT,MAAM,OAAO;EACb,aAAa;EACb,MAAM;EACN,MAAM,OAAO;EACb,KAAK,QAAQ;EACb,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;EACzB;CACX,CAAC;CAKD,QAAQ,GAAG,cAAc;EACvB,IAAI,cAAc,OAAO,aAAa,OAAO,QAAQ,CAAC,EAAE,QAAQ,QAAQ,KACtE,eAAe,OAAO,aAAa,OAAO,QAAQ;CACtD,CAAC;AACH","debug_id":"18c29c7f-5d4b-56b5-8fe5-ea43f30be810"}
1
+ {"version":3,"file":"start-run-CuQEMKRZ.mjs","sources":["../src/services/run/start-run.ts"],"sourcesContent":["import {\n clearRunRecord,\n getVerb,\n isSchemaLike,\n loadHost,\n loadProducers,\n ONE_SHOT_VERBS,\n outputRefsOf,\n probeRun,\n processResolveEnv,\n producerOutputsSchemas,\n readProjectName,\n readRunRecord,\n resolveHostOutputs,\n resolveRunnerModule,\n runRecordOutputSource,\n toStartedHandle,\n validateDeclaredHost,\n validateHost,\n writeRunRecord,\n type RunnerModule,\n} from \"@powerhousedao/host-core\";\n\nexport interface StartRunArgs {\n host: string;\n verb?: string;\n projectRoot?: string;\n debug?: boolean;\n}\n\n/**\n * `ph run <host> [verb]`: dispatch the verb (default `run`) of the host's\n * declared runner. There is deliberately no type→runner registry — what a\n * host does is written in its own file.\n *\n * The pipeline (typed-host-configs 3.5): declared validation (token shapes,\n * `$output` paths against the producers' outputsSchemas, the runner's\n * declaredHostSchema), the live-instance lock, resolution (`$output` from\n * the producers' live run records, `$env` from this process, the\n * `${userData}` sugar), resolved validation, then the verb with the parsed\n * host. A compound runner gets its declared host: its members resolve their\n * own tokens as they start.\n *\n * A reactor runner that exports `outputsSchema` has its handle's outputs\n * published in a v2 `.ph/run/<name>.json` record once ready; this is the only\n * standalone writer (mastra included). Compounds write their own record with\n * the members in it; one-shot verbs (`build`) return nothing and write none.\n */\nexport async function startRun(args: StartRunArgs): Promise<unknown> {\n const projectRoot = args.projectRoot ?? process.cwd();\n const loaded = await loadHost(projectRoot, args.host);\n const { warnSupersededConfigKeys } = await import(\"./superseded-config.js\");\n warnSupersededConfigKeys(projectRoot);\n const specifier = loaded.host.runner.module;\n const runner = await resolveRunnerModule(projectRoot, specifier);\n const verb = args.verb ?? \"run\";\n const fn = getVerb(runner, specifier, verb);\n const file = loaded.file;\n if (args.debug) {\n console.log({ host: loaded.host.name, runner: specifier, verb });\n }\n\n if (runner.kind === \"compound\") {\n validateDeclaredHost(runner, specifier, loaded.host, file);\n const host = validateHost(runner, specifier, loaded.host, file, {\n tokens: \"allow\",\n });\n return fn(host, { projectRoot, verb, env: process.env });\n }\n\n const projectName = readProjectName(projectRoot);\n const producers = await loadProducers(projectRoot, outputRefsOf(loaded.host));\n validateDeclaredHost(runner, specifier, loaded.host, file, {\n outputsSchemaOf: producerOutputsSchemas(producers),\n });\n const oneShot = ONE_SHOT_VERBS.has(verb);\n if (oneShot) {\n // `build` reads no other host's outputs: no producer needs to run.\n const host = validateHost(runner, specifier, loaded.host, file, {\n tokens: \"allow\",\n });\n return fn(host, { projectRoot, verb, env: process.env });\n }\n const publishes = isSchemaLike(runner.outputsSchema);\n // Before the verb starts anything: a second live instance would take\n // over the first one's record (and clear it on exit).\n if (publishes) assertNotRunning(projectRoot, loaded.host.name, projectName);\n const resolved = resolveHostOutputs(loaded.host, {\n outputs: runRecordOutputSource(projectRoot, {\n consumer: args.host,\n producers,\n projectName,\n }),\n ...processResolveEnv(projectRoot),\n where: `hosts/${args.host}/host.js`,\n });\n const host = validateHost(runner, specifier, resolved, file);\n const result = await fn(host, { projectRoot, verb, env: process.env });\n if (publishes && result !== undefined && result !== null) {\n await publishOutputs(runner, result, {\n projectRoot,\n projectName,\n hostName: loaded.host.name,\n specifier,\n verb,\n });\n }\n return result;\n}\n\nfunction assertNotRunning(\n projectRoot: string,\n hostName: string,\n projectName: string,\n): void {\n const probe = probeRun(projectRoot, hostName, projectName);\n if (probe.status === \"live\" && probe.record.pid !== process.pid) {\n throw new Error(\n `${hostName} is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`,\n );\n }\n if (probe.status === \"foreign\") {\n throw new Error(\n `.ph/run/${hostName}.json describes a live \"${probe.record.projectName}\", but this project is \"${projectName}\". Refusing to start a second instance.`,\n );\n }\n}\n\ninterface PublishTarget {\n projectRoot: string;\n projectName: string;\n hostName: string;\n specifier: string;\n verb: string;\n}\n\n/** Await `ready`, validate the outputs, write the v2 record and clear it on\n * exit. A handle that never gets ready or reports invalid outputs is shut\n * down before the error propagates. */\nasync function publishOutputs(\n runner: RunnerModule,\n result: unknown,\n target: PublishTarget,\n): Promise<void> {\n const where = `${target.specifier} ${target.verb}`;\n const handle = toStartedHandle(result, where);\n const name = target.projectName;\n let outputs: unknown;\n try {\n if (!isSchemaLike(runner.outputsSchema)) return;\n // Checked again after the start: an instance that started meanwhile.\n assertNotRunning(target.projectRoot, target.hostName, name);\n if (handle.ready) await handle.ready;\n const parsed = runner.outputsSchema.safeParse(handle.outputs);\n if (!parsed.success) {\n const issues = parsed.error.issues\n .map(\n (issue) =>\n ` - ${issue.path.map(String).join(\".\") || \"<root>\"}: ${issue.message}`,\n )\n .join(\"\\n\");\n throw new Error(\n `${where} reported outputs that fail its outputsSchema:\\n${issues}`,\n );\n }\n outputs = parsed.data;\n } catch (error) {\n await handle.shutdown?.();\n throw error;\n }\n\n writeRunRecord(target.projectRoot, {\n version: 2,\n host: target.hostName,\n projectName: name,\n kind: \"reactor\",\n verb: target.verb,\n pid: process.pid,\n startedAt: new Date().toISOString(),\n outputs: outputs as Record<string, unknown>,\n });\n // No SIGINT/SIGTERM handler: the switchboard reactor's own handler kills\n // the reactor before draining the api, and a parallel shutdown() would\n // break that order. Without an exit event the record keeps a dead pid,\n // which probeRun reports as stale.\n process.on(\"exit\", () => {\n if (readRunRecord(target.projectRoot, target.hostName)?.pid === process.pid)\n clearRunRecord(target.projectRoot, target.hostName);\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgDA,eAAsB,SAAS,MAAsC;CACnE,MAAM,cAAc,KAAK,eAAe,QAAQ,IAAI;CACpD,MAAM,SAAS,MAAM,SAAS,aAAa,KAAK,IAAI;CACpD,MAAM,EAAE,6BAA6B,MAAM,OAAO;CAClD,yBAAyB,WAAW;CACpC,MAAM,YAAY,OAAO,KAAK,OAAO;CACrC,MAAM,SAAS,MAAM,oBAAoB,aAAa,SAAS;CAC/D,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,KAAK,QAAQ,QAAQ,WAAW,IAAI;CAC1C,MAAM,OAAO,OAAO;CACpB,IAAI,KAAK,OACP,QAAQ,IAAI;EAAE,MAAM,OAAO,KAAK;EAAM,QAAQ;EAAW;CAAK,CAAC;CAGjE,IAAI,OAAO,SAAS,YAAY;EAC9B,qBAAqB,QAAQ,WAAW,OAAO,MAAM,IAAI;EAIzD,OAAO,GAHM,aAAa,QAAQ,WAAW,OAAO,MAAM,MAAM,EAC9D,QAAQ,QACV,CACa,GAAG;GAAE;GAAa;GAAM,KAAK,QAAQ;EAAI,CAAC;CACzD;CAEA,MAAM,cAAc,gBAAgB,WAAW;CAC/C,MAAM,YAAY,MAAM,cAAc,aAAa,aAAa,OAAO,IAAI,CAAC;CAC5E,qBAAqB,QAAQ,WAAW,OAAO,MAAM,MAAM,EACzD,iBAAiB,uBAAuB,SAAS,EACnD,CAAC;CAED,IADgB,eAAe,IAAI,IACzB,GAKR,OAAO,GAHM,aAAa,QAAQ,WAAW,OAAO,MAAM,MAAM,EAC9D,QAAQ,QACV,CACa,GAAG;EAAE;EAAa;EAAM,KAAK,QAAQ;CAAI,CAAC;CAEzD,MAAM,YAAY,aAAa,OAAO,aAAa;CAGnD,IAAI,WAAW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AAI,MAAM,CAAC,CAAC,KAAK,GAAG,KAAK,SAAS,IAAI,MAAM,SAClE,CAAC,CACA,KAAK,IAAI;GACZ,MAAM,IAAI,MACR,GAAG,MAAM,kDAAkD,QAC7D;EACF;EACA,UAAU,OAAO;CACnB,SAAS,OAAO;EACd,MAAM,OAAO,WAAW;EACxB,MAAM;CACR;CAEA,eAAe,OAAO,aAAa;EACjC,SAAS;EACT,MAAM,OAAO;EACb,aAAa;EACb,MAAM;EACN,MAAM,OAAO;EACb,KAAK,QAAQ;EACb,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;EACzB;CACX,CAAC;CAKD,QAAQ,GAAG,cAAc;EACvB,IAAI,cAAc,OAAO,aAAa,OAAO,QAAQ,CAAC,EAAE,QAAQ,QAAQ,KACtE,eAAe,OAAO,aAAa,OAAO,QAAQ;CACtD,CAAC;AACH","debug_id":"c5ec0091-ad36-544c-acd9-105162370681"}
@@ -1,8 +1,8 @@
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]="ee23c09c-a57d-58de-beeb-340689f8cab4")}catch(e){}}();
3
- import { m as rebaseDriveUrl, o as mergeDefaultDrives } from "./dist-BlpdH3RP.mjs";
4
- import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed } from "./cli-connect-override-CpHjVMDt.mjs";
5
- import { t as runConnectStudio } from "./connect-studio-qmgFWSt8.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]="e0773f2a-2b75-5778-b630-f96059011524")}catch(e){}}();
3
+ import { h as rebaseDriveUrl, o as mergeDefaultDrives } from "./dist-BiB5aiS6.mjs";
4
+ import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed } from "./cli-connect-override-Bv5y96A5.mjs";
5
+ import { t as runConnectStudio } from "./connect-studio-C0LLX1TD.mjs";
6
6
  import { a as generateProjectDriveId, t as POWERHOUSE_CONFIG_FILE } from "./utils-9KyRM0mf.mjs";
7
7
  import { a as stopVetra, c as probeVetraRuntime, d as writeVetraRuntime, o as clearVetraRuntime, s as legacyMcpConfigs, u as syncMcpPort } from "./vetra-launch-DQDZxGTV.mjs";
8
8
  import { a as POWERHOUSE_DRIVE_ICON, r as startSwitchboard$1 } from "./switchboard-JcKcWTaT.mjs";
@@ -558,5 +558,5 @@ async function startVetra(args) {
558
558
  //#endregion
559
559
  export { seedWorkflowsDrive, startVetra };
560
560
 
561
- //# sourceMappingURL=vetra-DUONHuYK.mjs.map
562
- //# debugId=ee23c09c-a57d-58de-beeb-340689f8cab4
561
+ //# sourceMappingURL=vetra-Ch4M1DtV.mjs.map
562
+ //# debugId=e0773f2a-2b75-5778-b630-f96059011524