@powerhousedao/ph-cli 6.2.3-dev.8 → 6.2.3-dev.81

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 (162) hide show
  1. package/dist/{auth-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
  2. package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
  3. package/dist/auth-CNhbN5UM.mjs +4 -0
  4. package/dist/build-t5pFQx0f.mjs +304 -0
  5. package/dist/build-t5pFQx0f.mjs.map +1 -0
  6. package/dist/build-wvc_NiGr.mjs +4 -0
  7. package/dist/check-ecwBLzrg.mjs +56 -0
  8. package/dist/check-ecwBLzrg.mjs.map +1 -0
  9. package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-DW7OYAGx.mjs} +39 -27
  10. package/dist/cli-connect-override-DW7OYAGx.mjs.map +1 -0
  11. package/dist/cli.d.mts +2 -1
  12. package/dist/cli.mjs +35 -1179
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs +2813 -0
  15. package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs.map +1 -0
  16. package/dist/connect-build-7nmQw9c5.mjs +253 -0
  17. package/dist/connect-build-7nmQw9c5.mjs.map +1 -0
  18. package/dist/{connect-config-BWGiW3IB.mjs → connect-config-CfQwxG8G.mjs} +19 -12
  19. package/dist/connect-config-CfQwxG8G.mjs.map +1 -0
  20. package/dist/connect-plugin-configs-CXN8_KL0.mjs +50 -0
  21. package/dist/connect-plugin-configs-CXN8_KL0.mjs.map +1 -0
  22. package/dist/connect-preview-Ckoqw_XU.mjs +231 -0
  23. package/dist/connect-preview-Ckoqw_XU.mjs.map +1 -0
  24. package/dist/connect-studio-Cac3eE_U.mjs +81 -0
  25. package/dist/connect-studio-Cac3eE_U.mjs.map +1 -0
  26. package/dist/connect-studio-Cf6UZvOo.mjs +4 -0
  27. package/dist/dist-DcARVrSg.mjs +643 -0
  28. package/dist/dist-DcARVrSg.mjs.map +1 -0
  29. package/dist/explain-Rx7JW1OU.mjs +230 -0
  30. package/dist/explain-Rx7JW1OU.mjs.map +1 -0
  31. package/dist/export-ZnJeAtLS.mjs +42 -0
  32. package/dist/export-ZnJeAtLS.mjs.map +1 -0
  33. package/dist/feature-flags-xwqcHEWC.mjs +4 -0
  34. package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-5Om0CB4N.mjs} +9 -3
  35. package/dist/generate-all-5Om0CB4N.mjs.map +1 -0
  36. package/dist/generate-app-hm6CJ_4O.mjs +72 -0
  37. package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
  38. package/dist/generate-desktop-shell-DzEzNspp.mjs +318 -0
  39. package/dist/generate-desktop-shell-DzEzNspp.mjs.map +1 -0
  40. package/dist/generate-document-model-CiW13Vf7.mjs +60 -0
  41. package/dist/generate-document-model-CiW13Vf7.mjs.map +1 -0
  42. package/dist/generate-editor-kTiUOmDW.mjs +64 -0
  43. package/dist/generate-editor-kTiUOmDW.mjs.map +1 -0
  44. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  45. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  46. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  47. package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
  48. package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
  49. package/dist/generate-piece-C6ymlErL.mjs +73 -0
  50. package/dist/generate-piece-C6ymlErL.mjs.map +1 -0
  51. package/dist/generate-piece-action-DqR8BcoO.mjs +31 -0
  52. package/dist/generate-piece-action-DqR8BcoO.mjs.map +1 -0
  53. package/dist/generate-piece-trigger-CZaDD-cc.mjs +30 -0
  54. package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
  55. package/dist/generate-processor-BVjOsfjJ.mjs +58 -0
  56. package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
  57. package/dist/generate-subgraph-CrHbYK91.mjs +64 -0
  58. package/dist/generate-subgraph-CrHbYK91.mjs.map +1 -0
  59. package/dist/get-version-CJulKHJ0.mjs +11 -0
  60. package/dist/get-version-CJulKHJ0.mjs.map +1 -0
  61. package/dist/index-CJN_BRkc.d.mts +4459 -0
  62. package/dist/index-CJN_BRkc.d.mts.map +1 -0
  63. package/dist/{init-BZP6gvYd.mjs → init-Ch1rCksS.mjs} +16 -12
  64. package/dist/init-Ch1rCksS.mjs.map +1 -0
  65. package/dist/{inspect-DXjbQEV_.mjs → inspect-zWJnBDMJ.mjs} +11 -4
  66. package/dist/inspect-zWJnBDMJ.mjs.map +1 -0
  67. package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
  68. package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
  69. package/dist/mcp-Cz9CubZa.mjs +262 -0
  70. package/dist/mcp-Cz9CubZa.mjs.map +1 -0
  71. package/dist/member-config-0tHtiVN_.mjs +154 -0
  72. package/dist/member-config-0tHtiVN_.mjs.map +1 -0
  73. package/dist/migrate-CIJaE3iZ.mjs +177 -0
  74. package/dist/migrate-CIJaE3iZ.mjs.map +1 -0
  75. package/dist/module-dir-1avCXsBi.mjs +17 -0
  76. package/dist/module-dir-1avCXsBi.mjs.map +1 -0
  77. package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
  78. package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
  79. package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
  80. package/dist/ph-cli-commands-C4gwBRyw.mjs +4 -0
  81. package/dist/ph-cli-commands-DFmTGL-H.mjs +1610 -0
  82. package/dist/ph-cli-commands-DFmTGL-H.mjs.map +1 -0
  83. package/dist/precompress-P6cJDPVC.mjs +77 -0
  84. package/dist/precompress-P6cJDPVC.mjs.map +1 -0
  85. package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
  86. package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
  87. package/dist/run-sugar-CRzZsmVo.mjs +39 -0
  88. package/dist/run-sugar-CRzZsmVo.mjs.map +1 -0
  89. package/dist/runners/connect.d.mts +1153 -0
  90. package/dist/runners/connect.d.mts.map +1 -0
  91. package/dist/runners/connect.mjs +300 -0
  92. package/dist/runners/connect.mjs.map +1 -0
  93. package/dist/runners/switchboard.d.mts +1481 -0
  94. package/dist/runners/switchboard.d.mts.map +1 -0
  95. package/dist/runners/switchboard.mjs +550 -0
  96. package/dist/runners/switchboard.mjs.map +1 -0
  97. package/dist/schemas-ByfuhvAb.mjs +5752 -0
  98. package/dist/schemas-ByfuhvAb.mjs.map +1 -0
  99. package/dist/scripts/emit-runner-schemas.ts +24 -0
  100. package/dist/scripts/generate-commands-docs.ts +12 -0
  101. package/dist/scripts/manage-environment +0 -0
  102. package/dist/scripts/setup.sh +0 -0
  103. package/dist/start-run-CRVBqQ8L.mjs +124 -0
  104. package/dist/start-run-CRVBqQ8L.mjs.map +1 -0
  105. package/dist/superseded-config-CbSTFun2.mjs +53 -0
  106. package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
  107. package/dist/switchboard-B7mvNWcd.mjs +4 -0
  108. package/dist/switchboard-Cqs5IBNF.mjs +168 -0
  109. package/dist/switchboard-Cqs5IBNF.mjs.map +1 -0
  110. package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-Docb8Cjv.mjs} +6 -5
  111. package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-Docb8Cjv.mjs.map} +1 -1
  112. package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
  113. package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
  114. package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  115. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  116. package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
  117. package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
  118. package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
  119. package/dist/{utils-C4isxXSO.mjs → utils-9KyRM0mf.mjs} +6 -34
  120. package/dist/{utils-C4isxXSO.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  121. package/dist/utils-DAux4Ga7.mjs +4 -0
  122. package/dist/{vetra-DkF6EJMY.mjs → vetra-DZYtcHqV.mjs} +130 -147
  123. package/dist/vetra-DZYtcHqV.mjs.map +1 -0
  124. package/dist/vetra-launch-DQDZxGTV.mjs +343 -0
  125. package/dist/vetra-launch-DQDZxGTV.mjs.map +1 -0
  126. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  127. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  128. package/package.json +42 -18
  129. package/dist/auth-BNkN6kS9.mjs +0 -4
  130. package/dist/build-C-A5-ipO.mjs +0 -4
  131. package/dist/build-uQXq6_HU.mjs +0 -71
  132. package/dist/build-uQXq6_HU.mjs.map +0 -1
  133. package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
  134. package/dist/connect-build-WL4axo4z.mjs +0 -43
  135. package/dist/connect-build-WL4axo4z.mjs.map +0 -1
  136. package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
  137. package/dist/connect-preview-D7ypzFDc.mjs +0 -28
  138. package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
  139. package/dist/connect-studio-BIQzyq5B.mjs +0 -5
  140. package/dist/connect-studio-D6rfWCNB.mjs +0 -31
  141. package/dist/connect-studio-D6rfWCNB.mjs.map +0 -1
  142. package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
  143. package/dist/generate-app-DNNqA-H3.mjs +0 -48
  144. package/dist/generate-app-DNNqA-H3.mjs.map +0 -1
  145. package/dist/generate-document-model-BJXyODfm.mjs +0 -34
  146. package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
  147. package/dist/generate-editor-BejvaVVT.mjs +0 -48
  148. package/dist/generate-editor-BejvaVVT.mjs.map +0 -1
  149. package/dist/generate-processor-_WOx-mMe.mjs +0 -40
  150. package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
  151. package/dist/generate-subgraph-BsHUstpl.mjs +0 -38
  152. package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
  153. package/dist/init-BZP6gvYd.mjs.map +0 -1
  154. package/dist/inspect-DXjbQEV_.mjs.map +0 -1
  155. package/dist/migrate-jGKfE02L.mjs +0 -83
  156. package/dist/migrate-jGKfE02L.mjs.map +0 -1
  157. package/dist/switchboard-CJMoMzWx.mjs +0 -75
  158. package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
  159. package/dist/switchboard-iRFugh8I.mjs +0 -4
  160. package/dist/switchboard-reset-BcQXlcVf.mjs.map +0 -1
  161. package/dist/utils-BzwczAW-.mjs +0 -4
  162. package/dist/vetra-DkF6EJMY.mjs.map +0 -1
@@ -0,0 +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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of 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
+ import { join } from "node:path";
7
+ import { DEFAULT_CONNECT_OUTDIR, DEFAULT_CONNECT_STUDIO_PORT } from "@powerhousedao/shared/clis";
8
+ import { connectConfigSchemaWith } from "@powerhousedao/shared/connect/connect-config-schema";
9
+ import { isPassthroughImageRef } from "@powerhousedao/shared/connect/image-ref";
10
+ import { withOriginPlaceholders } from "@powerhousedao/shared/connect/origin-placeholder";
11
+ //#region src/runners/connect.ts
12
+ /**
13
+ * BRIDGE runner for Connect hosts (uniform-runners phase 0): maps a
14
+ * hosts/connect/host.js definition onto the SAME service the classic
15
+ * `ph connect studio` (dev/run), `ph connect build` and `ph connect preview`
16
+ * (serve) commands call — no forked behavior.
17
+ */
18
+ const kind = "reactor";
19
+ /** The connect host: the host-core reactor host with every runner option
20
+ * this module reads declared (strict: an unknown runner key fails), and
21
+ * `config` typed by Connect's own zod schema (the authored `connect` block),
22
+ * whose URL fields that name another host's outputs
23
+ * (`drives.defaultDrives[].url`, `renown.switchboardUrl`) are token-able.
24
+ * One definition, two schemas: `declaredHostSchema` (token-able fields take
25
+ * output tokens; types host files) and `hostSchema` (resolved; checked
26
+ * right before the verb). */
27
+ const schemas = defineHostSchemas((s) => s.reactorHostSchema.extend({
28
+ runner: s.runnerBaseSchema.extend({
29
+ /** Open a browser tab once listening (dev/serve). */
30
+ openBrowser: boolean().optional(),
31
+ /** Fail instead of moving to the next free port when `port` is taken. */
32
+ strictPort: boolean().optional(),
33
+ /** The Connect build output dir (`build` writes it, `serve` serves it). */
34
+ outDir: string().min(1).optional(),
35
+ /** Patch the baked CSP for the runtime registry (`serve`); a
36
+ * compound's wiring sets it on its connect member. */
37
+ cspRegistrySync: boolean().optional(),
38
+ /** The host's routes folder, project-relative; false for none.
39
+ * Default: hosts/connect/routes. */
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()
50
+ }).strict(),
51
+ config: connectConfigSchemaWith(s.tokenable).optional()
52
+ }));
53
+ const declaredHostSchema = schemas.declaredHostSchema;
54
+ const hostSchema = schemas.hostSchema;
55
+ /** What a started Connect (`dev`/`run`/`serve`) produces: the origin it
56
+ * actually listens on and the app URL (origin plus base path). */
57
+ const outputsSchema = strictObject({
58
+ origin: url(),
59
+ endpoints: strictObject({ connect: url() })
60
+ });
61
+ /** A started Connect as a runner handle. vite has already listened when the
62
+ * service returns, so `ready` is settled; the outputs carry the URL vite
63
+ * resolved (the port it actually bound), falling back to the requested one. */
64
+ function connectHandle(server, requested) {
65
+ const fallback = `http://${requested.host}:${requested.port}/`;
66
+ const app = server.resolvedUrls?.local[0] ?? fallback;
67
+ let closing;
68
+ return {
69
+ outputs: outputsSchema.parse({
70
+ origin: new URL(app).origin,
71
+ endpoints: { connect: app }
72
+ }),
73
+ ready: Promise.resolve(),
74
+ shutdown: () => closing ??= server.close()
75
+ };
76
+ }
77
+ /** The studio arg surface is wide (commonArgs + server args); the service only
78
+ * reads a known subset, and the repo's own tests build these objects the same
79
+ * way (Partial + cast — see connect-build.test.ts `mk()`). */
80
+ function toStudioArgs(host) {
81
+ const runner = host.runner;
82
+ return {
83
+ port: runner.port ?? DEFAULT_CONNECT_STUDIO_PORT,
84
+ ...runner.host ? { host: runner.host } : {},
85
+ open: runner.openBrowser === true,
86
+ strictPort: runner.strictPort === true,
87
+ printUrls: true,
88
+ bindCLIShortcuts: false
89
+ };
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
+ /** host.js reactor.drives -> the served drives.defaultDrives shapes: locals
100
+ * carry id/name/icon and the preferredEditor under its Connect alias `app`;
101
+ * remotes carry their URL. */
102
+ function declaredDrivesToDefaults(projectRoot, declarations) {
103
+ return declarations.map((declaration) => {
104
+ const drive = resolveDriveDeclaration(projectRoot, declaration);
105
+ if (drive.kind === "remote") return {
106
+ url: drive.remoteUrl,
107
+ name: drive.name,
108
+ icon: drive.icon ?? null
109
+ };
110
+ return {
111
+ local: true,
112
+ id: drive.id,
113
+ name: drive.name,
114
+ icon: drive.icon ?? null,
115
+ ...drive.preferredEditor ? { app: drive.preferredEditor } : {}
116
+ };
117
+ });
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
+ */
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") {
133
+ const base = { ...host.config };
134
+ const reactor = host.reactor;
135
+ const entries = host.runner.plugins;
136
+ const composition = entries === void 0 ? void 0 : normalizePluginEntries(entries, `hosts/${host.name}/host.js`).filter((entry) => entryActiveForVerb(entry, verb)).map((entry) => ({
137
+ module: entry.module,
138
+ config: entry.config
139
+ }));
140
+ if (entries !== void 0) {
141
+ const all = normalizePluginEntries(entries, `hosts/${host.name}/host.js`);
142
+ console.log(`[connect] composition plan (verb=${verb}): ${composition?.length ?? 0} active of ${all.length} declared`);
143
+ for (const entry of all) {
144
+ const active = entryActiveForVerb(entry, verb);
145
+ const scope = entry.verbs === "*" ? "" : ` verbs=[${entry.verbs.join(",")}]`;
146
+ const cfg = Object.keys(entry.config);
147
+ console.log(`[connect] ${active ? "•" : "○"} ${entry.module}${scope}` + (cfg.length ? ` config: {${cfg.join(", ")}}` : "") + (active ? "" : " (inactive for this verb)"));
148
+ }
149
+ }
150
+ for (const warning of findDeadConnectConfig(host.config, entries, verb, `hosts/${host.name}/host.js`)) console.warn(warning.message);
151
+ const declared = reactor?.drives;
152
+ const declaredDefaults = declared && ctx ? declaredDrivesToDefaults(ctx.projectRoot, declared) : void 0;
153
+ const reactorRenown = reactor?.renown;
154
+ const reactorNamespace = reactor?.namespace;
155
+ base.drives = declaredDefaults ? {
156
+ ...base.drives,
157
+ defaultDrives: mergeDefaultDrives(declaredDefaults, base.drives?.defaultDrives ?? []),
158
+ preserveStrategy: base.drives?.preserveStrategy ?? "preserve-all"
159
+ } : base.drives;
160
+ if (composition) base.composition = composition;
161
+ if (reactorRenown) base.renown = {
162
+ ...reactorRenown,
163
+ ...base.renown
164
+ };
165
+ if (reactorNamespace !== void 0) base.instance = {
166
+ ...base.instance,
167
+ namespace: base.instance?.namespace ?? reactorNamespace
168
+ };
169
+ const { connect } = projectReactorToConnect(reactor);
170
+ const structural = isStructuralMultiReactor(reactor);
171
+ if (!connect.reactor && !connect.instance && !connect.app && !structural) return host.config !== void 0 || composition || declaredDefaults ? base : void 0;
172
+ const drives = structural ? projectDrivesIntoConnect({
173
+ createdDriveUrls: remoteBackendUrls(reactor),
174
+ configuredDefaultDrives: base.drives?.defaultDrives
175
+ }).drives : base.drives;
176
+ const instance = Object.keys(reactor?.backends ?? {}).length > 0 ? {
177
+ ...base.instance,
178
+ ...connect.instance,
179
+ ...structural ? { multiReactor: true } : {}
180
+ } : {
181
+ ...connect.instance,
182
+ ...base.instance
183
+ };
184
+ return {
185
+ ...base,
186
+ reactor: {
187
+ ...connect.reactor,
188
+ ...base.reactor
189
+ },
190
+ instance,
191
+ app: {
192
+ ...connect.app,
193
+ ...base.app
194
+ },
195
+ ...drives ? { drives: {
196
+ ...base.drives,
197
+ ...drives
198
+ } } : {}
199
+ };
200
+ }
201
+ /**
202
+ * Start a server; under a supervising compound (`ctx.parent`), drop the
203
+ * process-exiting signal listeners it installed (vite's dev and preview
204
+ * servers exit on SIGTERM): the compound owns the exit and stops members in
205
+ * reverse dependency order through their handles.
206
+ */
207
+ async function startUnderSupervisor(ctx, start) {
208
+ if (!ctx.parent) return start();
209
+ const signals = ["SIGINT", "SIGTERM"];
210
+ const before = new Map(signals.map((signal) => [signal, new Set(process.listeners(signal))]));
211
+ try {
212
+ return await start();
213
+ } finally {
214
+ for (const signal of signals) for (const listener of process.listeners(signal)) if (!before.get(signal)?.has(listener)) process.off(signal, listener);
215
+ }
216
+ }
217
+ /** Fail at `ph run`, naming the plugin and key, when a composed Connect
218
+ * plugin's entry config does not match its schema. */
219
+ async function validateComposition(host, ctx) {
220
+ const { validateConnectPluginConfigs } = await import("../connect-plugin-configs-CXN8_KL0.mjs");
221
+ await validateConnectPluginConfigs(ctx.projectRoot, host.runner.plugins, ctx.verb, `hosts/${host.name}/host.js`);
222
+ }
223
+ /** A project file the build resolved: the built dist has it (as icon.ico or
224
+ * a data URI); served, its path would mean nothing. */
225
+ function isBuiltImage(ref) {
226
+ const src = typeof ref === "object" && ref !== null && "src" in ref ? ref.src : ref;
227
+ return typeof src === "string" && !isPassthroughImageRef(src);
228
+ }
229
+ function withoutBuiltImages(config) {
230
+ const branding = config?.branding;
231
+ if (!branding) return config;
232
+ const { favicon: _, ...served } = branding;
233
+ if (isBuiltImage(served.icon)) delete served.icon;
234
+ if (isBuiltImage(served.loader)) delete served.loader;
235
+ return {
236
+ ...config,
237
+ branding: served
238
+ };
239
+ }
240
+ const viteCacheOf = (host, ctx) => join(ctx.projectRoot, "node_modules", `.vite-${host.name.replace(/[^\w.-]/g, "_")}`);
241
+ async function dev(host, ctx) {
242
+ await validateComposition(host, ctx);
243
+ const { runConnectStudio } = await import("../connect-studio-Cf6UZvOo.mjs");
244
+ const args = toStudioArgs(host);
245
+ return connectHandle(await startUnderSupervisor(ctx, () => runConnectStudio(args, void 0, callerOverride(host, ctx, ctx.verb), {
246
+ routes: host.runner.routes,
247
+ cacheDir: viteCacheOf(host, ctx),
248
+ proxy: host.runner.proxy?.target
249
+ })), {
250
+ host: "localhost",
251
+ port: args.port
252
+ });
253
+ }
254
+ /** `run` is dev-studio until the plugin phases give hosts a production
255
+ * runtime; `serve` (below) is the static production server. */
256
+ const run = dev;
257
+ /** P3.3 — `build`: the SAME service as classic `ph connect build`. */
258
+ async function build(host, ctx) {
259
+ await validateComposition(host, ctx);
260
+ const { runConnectBuild } = await import("../connect-build-7nmQw9c5.mjs");
261
+ await runConnectBuild({ outDir: host.runner.outDir ?? DEFAULT_CONNECT_OUTDIR }, callerOverride(host, ctx, ctx.verb), { routes: host.runner.routes });
262
+ }
263
+ /** P3.3 — `serve`: the SAME vite preview server as classic
264
+ * `ph connect preview` (static serve of a built Connect; run `build` first).
265
+ * The host's connect config (including a supervising compound's projected
266
+ * drives and the reactor projection) rides a serve override: the baked
267
+ * powerhouse.config.json merges with it at request time, and
268
+ * `runner.cspRegistrySync` (set by the compound's wiring) patches the baked
269
+ * CSP's script-src for the runtime registry — together these replace the
270
+ * ph-win-desktop sidecar's hand-rolled static server (desktop shape). */
271
+ async function serve(host, ctx) {
272
+ await validateComposition(host, ctx);
273
+ const { runConnectPreview } = await import("../connect-preview-Ckoqw_XU.mjs");
274
+ const runner = host.runner;
275
+ const port = runner.port ?? DEFAULT_CONNECT_STUDIO_PORT;
276
+ const bind = runner.host ?? "127.0.0.1";
277
+ const args = {
278
+ port,
279
+ outDir: runner.outDir ?? DEFAULT_CONNECT_OUTDIR,
280
+ open: runner.openBrowser === true,
281
+ strictPort: runner.strictPort === true,
282
+ cors: true,
283
+ printUrls: true,
284
+ bindCLIShortcuts: false,
285
+ host: bind
286
+ };
287
+ const override = withoutBuiltImages(callerOverride(host, ctx, ctx.verb));
288
+ return connectHandle(await startUnderSupervisor(ctx, () => runConnectPreview(args, {
289
+ connect: override,
290
+ cspRegistrySync: runner.cspRegistrySync === true
291
+ }, void 0, { proxy: runner.proxy?.target })), {
292
+ host: bind,
293
+ port
294
+ });
295
+ }
296
+ //#endregion
297
+ export { build, declaredHostSchema, dev, hostSchema, kind, outputsSchema, run, serve, withoutBuiltImages };
298
+
299
+ //# sourceMappingURL=connect.mjs.map
300
+ //# debugId=54404818-de56-5e01-936d-7c1f24806021
@@ -0,0 +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,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,CAA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