@powerhousedao/switchboard 6.2.3-dev.9 → 6.2.3-dev.90

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 (306) hide show
  1. package/.tsbuild/test/ai-gateway.test.d.ts +2 -0
  2. package/.tsbuild/test/ai-gateway.test.d.ts.map +1 -0
  3. package/.tsbuild/test/attachments/byte-grants.test.d.ts +2 -0
  4. package/.tsbuild/test/attachments/byte-grants.test.d.ts.map +1 -0
  5. package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts +2 -0
  6. package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts.map +1 -0
  7. package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts +2 -0
  8. package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts.map +1 -0
  9. package/.tsbuild/test/attachments/url-signer.test.d.ts +2 -0
  10. package/.tsbuild/test/attachments/url-signer.test.d.ts.map +1 -0
  11. package/.tsbuild/test/boot-auth-config.test.d.ts +2 -0
  12. package/.tsbuild/test/boot-auth-config.test.d.ts.map +1 -0
  13. package/.tsbuild/test/boot-create-signature-policy.test.d.ts +2 -0
  14. package/.tsbuild/test/boot-create-signature-policy.test.d.ts.map +1 -0
  15. package/.tsbuild/test/boot-desktop-auth.test.d.ts +2 -0
  16. package/.tsbuild/test/boot-desktop-auth.test.d.ts.map +1 -0
  17. package/.tsbuild/test/boot-env-isolation.test.d.ts +2 -0
  18. package/.tsbuild/test/boot-env-isolation.test.d.ts.map +1 -0
  19. package/.tsbuild/test/boot-helpers.d.ts +5 -0
  20. package/.tsbuild/test/boot-helpers.d.ts.map +1 -0
  21. package/.tsbuild/test/boot-inspection-enabled.test.d.ts +2 -0
  22. package/.tsbuild/test/boot-inspection-enabled.test.d.ts.map +1 -0
  23. package/.tsbuild/test/boot-mcp-auth.test.d.ts +2 -0
  24. package/.tsbuild/test/boot-mcp-auth.test.d.ts.map +1 -0
  25. package/.tsbuild/test/boot-mcp-enabled.test.d.ts +2 -0
  26. package/.tsbuild/test/boot-mcp-enabled.test.d.ts.map +1 -0
  27. package/.tsbuild/test/boot-port-zero.test.d.ts +2 -0
  28. package/.tsbuild/test/boot-port-zero.test.d.ts.map +1 -0
  29. package/.tsbuild/test/boot-preconditions.test.d.ts +2 -0
  30. package/.tsbuild/test/boot-preconditions.test.d.ts.map +1 -0
  31. package/.tsbuild/test/boot-privacy.test.d.ts +2 -0
  32. package/.tsbuild/test/boot-privacy.test.d.ts.map +1 -0
  33. package/.tsbuild/test/boot-ready-drives.test.d.ts +2 -0
  34. package/.tsbuild/test/boot-ready-drives.test.d.ts.map +1 -0
  35. package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts +2 -0
  36. package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts.map +1 -0
  37. package/.tsbuild/test/boot-without-renown.test.d.ts +2 -0
  38. package/.tsbuild/test/boot-without-renown.test.d.ts.map +1 -0
  39. package/.tsbuild/test/boot-without-require-signatures.test.d.ts +2 -0
  40. package/.tsbuild/test/boot-without-require-signatures.test.d.ts.map +1 -0
  41. package/.tsbuild/test/boot-worker-trust-policy.test.d.ts +2 -0
  42. package/.tsbuild/test/boot-worker-trust-policy.test.d.ts.map +1 -0
  43. package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts +2 -0
  44. package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts.map +1 -0
  45. package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts +2 -0
  46. package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts.map +1 -0
  47. package/.tsbuild/test/builder-defaults.test.d.ts +2 -0
  48. package/.tsbuild/test/builder-defaults.test.d.ts.map +1 -0
  49. package/.tsbuild/test/config-from-env.test.d.ts +2 -0
  50. package/.tsbuild/test/config-from-env.test.d.ts.map +1 -0
  51. package/.tsbuild/test/config-merge.test.d.ts +2 -0
  52. package/.tsbuild/test/config-merge.test.d.ts.map +1 -0
  53. package/.tsbuild/test/config-schema.test.d.ts +2 -0
  54. package/.tsbuild/test/config-schema.test.d.ts.map +1 -0
  55. package/.tsbuild/test/create-signature-policy.test.d.ts +2 -0
  56. package/.tsbuild/test/create-signature-policy.test.d.ts.map +1 -0
  57. package/.tsbuild/test/default-drive-protocol-versions.test.d.ts +2 -0
  58. package/.tsbuild/test/default-drive-protocol-versions.test.d.ts.map +1 -0
  59. package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
  60. package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
  61. package/.tsbuild/test/delegated-publish.test.d.ts +2 -0
  62. package/.tsbuild/test/delegated-publish.test.d.ts.map +1 -0
  63. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
  64. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
  65. package/.tsbuild/test/fatal-shutdown.test.d.ts +2 -0
  66. package/.tsbuild/test/fatal-shutdown.test.d.ts.map +1 -0
  67. package/.tsbuild/test/inspection-throttle.test.d.ts +2 -0
  68. package/.tsbuild/test/inspection-throttle.test.d.ts.map +1 -0
  69. package/.tsbuild/test/keyframe-reclaim-store.test.d.ts +2 -0
  70. package/.tsbuild/test/keyframe-reclaim-store.test.d.ts.map +1 -0
  71. package/.tsbuild/test/observability-signals.test.d.ts +2 -0
  72. package/.tsbuild/test/observability-signals.test.d.ts.map +1 -0
  73. package/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
  74. package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
  75. package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
  76. package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
  77. package/.tsbuild/test/pglite-storage-dirs.test.d.ts +2 -0
  78. package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
  79. package/.tsbuild/test/pglite-store.test.d.ts +2 -0
  80. package/.tsbuild/test/pglite-store.test.d.ts.map +1 -0
  81. package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
  82. package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
  83. package/.tsbuild/test/plugin-presence.test.d.ts +2 -0
  84. package/.tsbuild/test/plugin-presence.test.d.ts.map +1 -0
  85. package/.tsbuild/test/port-probe.test.d.ts +2 -0
  86. package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
  87. package/.tsbuild/test/processor-timing-log.test.d.ts +2 -0
  88. package/.tsbuild/test/processor-timing-log.test.d.ts.map +1 -0
  89. package/.tsbuild/test/renown-storage-path.test.d.ts +2 -0
  90. package/.tsbuild/test/renown-storage-path.test.d.ts.map +1 -0
  91. package/.tsbuild/test/renown-trust-policy.test.d.ts +2 -0
  92. package/.tsbuild/test/renown-trust-policy.test.d.ts.map +1 -0
  93. package/.tsbuild/test/served-schemas.test.d.ts +2 -0
  94. package/.tsbuild/test/served-schemas.test.d.ts.map +1 -0
  95. package/.tsbuild/test/shutdown.test.d.ts +2 -0
  96. package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
  97. package/.tsbuild/test/snapshot-writer.d.ts +18 -0
  98. package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
  99. package/.tsbuild/test/store-lock.test.d.ts +2 -0
  100. package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
  101. package/.tsbuild/test/two-switchboards.test.d.ts +2 -0
  102. package/.tsbuild/test/two-switchboards.test.d.ts.map +1 -0
  103. package/.tsbuild/test/unsupported-stored-documents.test.d.ts +2 -0
  104. package/.tsbuild/test/unsupported-stored-documents.test.d.ts.map +1 -0
  105. package/.tsbuild/test/workflow/harness.d.ts +56 -0
  106. package/.tsbuild/test/workflow/harness.d.ts.map +1 -0
  107. package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts +2 -0
  108. package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts.map +1 -0
  109. package/.tsbuild/test/workflow/oauth.test.d.ts +2 -0
  110. package/.tsbuild/test/workflow/oauth.test.d.ts.map +1 -0
  111. package/.tsbuild/test/workflow/resolvers.test.d.ts +2 -0
  112. package/.tsbuild/test/workflow/resolvers.test.d.ts.map +1 -0
  113. package/.tsbuild/test/workflow/runtime-host.test.d.ts +2 -0
  114. package/.tsbuild/test/workflow/runtime-host.test.d.ts.map +1 -0
  115. package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts +2 -0
  116. package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts.map +1 -0
  117. package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts +2 -0
  118. package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts.map +1 -0
  119. package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts +2 -0
  120. package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts.map +1 -0
  121. package/.tsbuild/test/workflow/webhook-signed.test.d.ts +2 -0
  122. package/.tsbuild/test/workflow/webhook-signed.test.d.ts.map +1 -0
  123. package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts +2 -0
  124. package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts.map +1 -0
  125. package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts +2 -0
  126. package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts.map +1 -0
  127. package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
  128. package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
  129. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
  130. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
  131. package/.tsbuild/test/workflow-read-gate.test.d.ts +2 -0
  132. package/.tsbuild/test/workflow-read-gate.test.d.ts.map +1 -0
  133. package/.tsbuild/test/workflow-runtime.test.d.ts +2 -0
  134. package/.tsbuild/test/workflow-runtime.test.d.ts.map +1 -0
  135. package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
  136. package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
  137. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  138. package/.tsbuild/tsdown.config.d.ts.map +1 -1
  139. package/.tsbuild/vitest.config.d.ts.map +1 -1
  140. package/Auth.md +144 -2
  141. package/CHANGELOG.md +1206 -0
  142. package/README.md +88 -14
  143. package/dist/boot.d.mts +46 -0
  144. package/dist/boot.d.mts.map +1 -0
  145. package/dist/boot.mjs +67 -0
  146. package/dist/boot.mjs.map +1 -0
  147. package/dist/config/from-env.d.mts +15 -0
  148. package/dist/config/from-env.d.mts.map +1 -0
  149. package/dist/config/from-env.mjs +4 -0
  150. package/dist/config/schema.d.mts +3 -0
  151. package/dist/config/schema.mjs +4 -0
  152. package/dist/from-env-DJ4iQ3QZ.mjs +473 -0
  153. package/dist/from-env-DJ4iQ3QZ.mjs.map +1 -0
  154. package/dist/index.d.mts +2 -1
  155. package/dist/index.mjs +84 -84
  156. package/dist/index.mjs.map +1 -1
  157. package/dist/install-packages.d.mts +2 -1
  158. package/dist/install-packages.mjs +2 -2
  159. package/dist/install-packages.mjs.map +1 -1
  160. package/dist/mcp-SsBK14Jm.mjs +32 -0
  161. package/dist/mcp-SsBK14Jm.mjs.map +1 -0
  162. package/dist/migrate.d.mts +2 -1
  163. package/dist/migrate.mjs +7 -5
  164. package/dist/migrate.mjs.map +1 -1
  165. package/dist/plugin-host-BHEUSn9G.d.mts +46 -0
  166. package/dist/plugin-host-BHEUSn9G.d.mts.map +1 -0
  167. package/dist/plugins/ai.d.mts +37 -0
  168. package/dist/plugins/ai.d.mts.map +1 -0
  169. package/dist/plugins/ai.mjs +400 -0
  170. package/dist/plugins/ai.mjs.map +1 -0
  171. package/dist/plugins/attachments.d.mts +33 -0
  172. package/dist/plugins/attachments.d.mts.map +1 -0
  173. package/dist/plugins/attachments.mjs +4 -0
  174. package/dist/plugins/mcp.d.mts +31 -0
  175. package/dist/plugins/mcp.d.mts.map +1 -0
  176. package/dist/plugins/mcp.mjs +4 -0
  177. package/dist/plugins/privacy.d.mts +22 -0
  178. package/dist/plugins/privacy.d.mts.map +1 -0
  179. package/dist/plugins/privacy.mjs +4 -0
  180. package/dist/plugins/workflows.d.mts +79 -0
  181. package/dist/plugins/workflows.d.mts.map +1 -0
  182. package/dist/plugins/workflows.mjs +4 -0
  183. package/dist/postgres-url-DTDhBjXX.mjs +11 -0
  184. package/dist/postgres-url-DTDhBjXX.mjs.map +1 -0
  185. package/dist/privacy-BO8Q25xI.mjs +44 -0
  186. package/dist/privacy-BO8Q25xI.mjs.map +1 -0
  187. package/dist/privacy-DxIJGH4P.mjs +91 -0
  188. package/dist/privacy-DxIJGH4P.mjs.map +1 -0
  189. package/dist/renown-layers-COZsrGQT.mjs +40 -0
  190. package/dist/renown-layers-COZsrGQT.mjs.map +1 -0
  191. package/dist/schema-1yj85yQD.mjs +326 -0
  192. package/dist/schema-1yj85yQD.mjs.map +1 -0
  193. package/dist/schema-ugrJupVH.d.mts +246 -0
  194. package/dist/schema-ugrJupVH.d.mts.map +1 -0
  195. package/dist/server-CgDvrUqE.mjs +2729 -0
  196. package/dist/server-CgDvrUqE.mjs.map +1 -0
  197. package/dist/server.d.mts +129 -189
  198. package/dist/server.d.mts.map +1 -1
  199. package/dist/server.mjs +5 -5
  200. package/dist/types-DzO3_320.d.mts +308 -0
  201. package/dist/types-DzO3_320.d.mts.map +1 -0
  202. package/dist/utils-Cm0TE6dP.mjs +148 -0
  203. package/dist/utils-Cm0TE6dP.mjs.map +1 -0
  204. package/dist/utils.d.mts +30 -5
  205. package/dist/utils.d.mts.map +1 -1
  206. package/dist/utils.mjs +5 -4
  207. package/dist/worker-pool-gyxJnCxA.mjs +304 -0
  208. package/dist/worker-pool-gyxJnCxA.mjs.map +1 -0
  209. package/dist/workflow-runtime-CF5pc8mt.d.mts +33 -0
  210. package/dist/workflow-runtime-CF5pc8mt.d.mts.map +1 -0
  211. package/dist/workflows-C9BQlyT0.mjs +1943 -0
  212. package/dist/workflows-C9BQlyT0.mjs.map +1 -0
  213. package/package.json +85 -24
  214. package/scripts/install-packages.sh +0 -0
  215. package/test/ai-gateway.test.ts +612 -0
  216. package/test/attachment-reference-read-model.test.ts +28 -20
  217. package/test/attachments/auth.test.ts +85 -0
  218. package/test/attachments/byte-grants.test.ts +290 -0
  219. package/test/attachments/byte-routes-read-gate.integration.test.ts +314 -0
  220. package/test/attachments/download-target.test.ts +211 -32
  221. package/test/attachments/index.test.ts +47 -4
  222. package/test/attachments/reserve-metadata-parity.test.ts +96 -0
  223. package/test/attachments/routes-integration.test.ts +60 -4
  224. package/test/attachments/routes.test.ts +297 -35
  225. package/test/attachments/service-config.test.ts +41 -19
  226. package/test/attachments/url-signer.test.ts +105 -0
  227. package/test/boot-auth-config.test.ts +109 -0
  228. package/test/boot-create-signature-policy.test.ts +110 -0
  229. package/test/boot-desktop-auth.test.ts +278 -0
  230. package/test/boot-env-isolation.test.ts +26 -0
  231. package/test/boot-helpers.ts +19 -0
  232. package/test/boot-inspection-enabled.test.ts +140 -0
  233. package/test/boot-mcp-auth.test.ts +449 -0
  234. package/test/boot-mcp-enabled.test.ts +119 -0
  235. package/test/boot-port-zero.test.ts +101 -0
  236. package/test/boot-preconditions.test.ts +213 -0
  237. package/test/boot-privacy.test.ts +232 -0
  238. package/test/boot-ready-drives.test.ts +141 -0
  239. package/test/boot-unsupported-stored-documents.test.ts +214 -0
  240. package/test/boot-without-renown.test.ts +83 -0
  241. package/test/boot-without-require-signatures.test.ts +76 -0
  242. package/test/boot-worker-trust-policy.test.ts +91 -0
  243. package/test/boot-workflow-singleton-conflict.test.ts +109 -0
  244. package/test/boot-workflow-singleton-retry.test.ts +122 -0
  245. package/test/builder-defaults.test.ts +80 -0
  246. package/test/config-from-env.test.ts +942 -0
  247. package/test/config-merge.test.ts +226 -0
  248. package/test/config-schema.test.ts +156 -0
  249. package/test/create-signature-policy.test.ts +69 -0
  250. package/test/default-drive-protocol-versions.test.ts +79 -0
  251. package/test/default-drive-slug.test.ts +265 -0
  252. package/test/delegated-publish.test.ts +435 -0
  253. package/test/durable-node-fs-pg16.test.ts +80 -0
  254. package/test/fatal-shutdown.test.ts +205 -0
  255. package/test/goldens/packages.graphql +797 -0
  256. package/test/goldens/privacy.graphql +853 -0
  257. package/test/goldens/reactor-drive-nodes.graphql +827 -0
  258. package/test/goldens/resolvers.json +327 -0
  259. package/test/goldens/supergraph.graphql +5918 -0
  260. package/test/goldens/workflow-runtime.graphql +1548 -0
  261. package/test/inspection-throttle.test.ts +23 -0
  262. package/test/keyframe-reclaim-store.test.ts +156 -0
  263. package/test/observability-signals.test.ts +131 -0
  264. package/test/permissions-backfill.test.ts +486 -0
  265. package/test/pglite-dialect.test.ts +237 -2
  266. package/test/pglite-preflight.test.ts +313 -0
  267. package/test/pglite-storage-dirs.test.ts +113 -0
  268. package/test/pglite-store.test.ts +441 -0
  269. package/test/pglite-version.test.ts +9 -1
  270. package/test/plugin-config-schemas.test.ts +83 -0
  271. package/test/plugin-presence.test.ts +262 -0
  272. package/test/port-probe.test.ts +45 -0
  273. package/test/processor-timing-log.test.ts +109 -0
  274. package/test/redact-webhook-path.test.ts +9 -0
  275. package/test/renown-storage-path.test.ts +40 -0
  276. package/test/renown-trust-policy.test.ts +313 -0
  277. package/test/served-schemas.test.ts +134 -0
  278. package/test/shutdown.test.ts +278 -0
  279. package/test/snapshot-writer.ts +94 -0
  280. package/test/store-lock.test.ts +65 -0
  281. package/test/two-switchboards.test.ts +146 -0
  282. package/test/unsupported-stored-documents.test.ts +72 -0
  283. package/test/worker-pool.test.ts +27 -1
  284. package/test/workflow/harness.ts +289 -0
  285. package/test/workflow/oauth-apps-config.test.ts +66 -0
  286. package/test/workflow/oauth.test.ts +286 -0
  287. package/test/workflow/resolvers.test.ts +488 -0
  288. package/test/workflow/runtime-host.test.ts +19 -0
  289. package/test/workflow/waitpoint-routes.test.ts +306 -0
  290. package/test/workflow/waitpoint-runtime.test.ts +204 -0
  291. package/test/workflow/webhook-dedupe.test.ts +295 -0
  292. package/test/workflow/webhook-signed.test.ts +509 -0
  293. package/test/workflow/webhook-trigger-test.test.ts +82 -0
  294. package/test/workflow/webhook-unsigned.test.ts +345 -0
  295. package/test/workflow-reactor-access.test.ts +384 -0
  296. package/test/workflow-reactor-enforcement.test.ts +808 -0
  297. package/test/workflow-read-gate.test.ts +213 -0
  298. package/test/workflow-runtime.test.ts +1254 -0
  299. package/test/workflows-plugin-config.test.ts +77 -0
  300. package/tsconfig.json +11 -2
  301. package/tsdown.config.ts +13 -1
  302. package/vitest.config.ts +65 -0
  303. package/dist/server-CiKkVE6g.mjs +0 -1555
  304. package/dist/server-CiKkVE6g.mjs.map +0 -1
  305. package/dist/utils-Baw7rThP.mjs +0 -80
  306. package/dist/utils-Baw7rThP.mjs.map +0 -1
@@ -0,0 +1,449 @@
1
+ // /mcp on a booted Switchboard with document permissions: the official MCP
2
+ // client over HTTP and GraphQL, as callers holding real did:key bearers.
3
+ import { mkdtemp, rm } from "node:fs/promises";
4
+ import { createRequire } from "node:module";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import { addFolder } from "@powerhousedao/shared/document-drive";
8
+ import { MemoryKeyStorage, RenownCryptoBuilder } from "@renown/sdk/node";
9
+ import type { ILogger } from "document-model";
10
+ import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
11
+ import type { SwitchboardReactor } from "../src/types.js";
12
+ import { bootSwitchboard } from "./boot-helpers.js";
13
+
14
+ // The SDK is reactor-mcp's dependency; the switchboard does not declare it.
15
+ const sdk = createRequire(
16
+ new URL("../../../packages/reactor-mcp/package.json", import.meta.url),
17
+ );
18
+ type ToolResult = {
19
+ structuredContent?: unknown;
20
+ isError?: boolean;
21
+ content?: unknown;
22
+ };
23
+ type McpClient = {
24
+ connect(transport: unknown): Promise<void>;
25
+ listTools(): Promise<{ tools: { name: string }[] }>;
26
+ callTool(request: {
27
+ name: string;
28
+ arguments: Record<string, unknown>;
29
+ }): Promise<ToolResult>;
30
+ close(): Promise<void>;
31
+ };
32
+ const { Client } = sdk("@modelcontextprotocol/sdk/client/index.js") as {
33
+ Client: new (info: { name: string; version: string }) => McpClient;
34
+ };
35
+ const { StreamableHTTPClientTransport } = sdk(
36
+ "@modelcontextprotocol/sdk/client/streamableHttp.js",
37
+ ) as {
38
+ StreamableHTTPClientTransport: new (
39
+ url: URL,
40
+ options: { requestInit: RequestInit },
41
+ ) => unknown;
42
+ };
43
+
44
+ const ADMIN = "0x1111111111111111111111111111111111111111";
45
+ const READER = "0x2222222222222222222222222222222222222222";
46
+ const WRITER = "0x3333333333333333333333333333333333333333";
47
+ const OUTSIDER = "0x4444444444444444444444444444444444444444";
48
+ const USERS = [ADMIN, READER, WRITER, OUTSIDER] as const;
49
+ type Caller = (typeof USERS)[number] | "anonymous";
50
+ const CALLERS: Caller[] = [...USERS, "anonymous"];
51
+
52
+ const ENV_KEYS = [
53
+ "PH_REACTOR_DATABASE_URL",
54
+ "MCP_ENABLED",
55
+ "FEATURE_PLUGIN_HOST_ENABLED",
56
+ "AUTH_ENABLED",
57
+ "ADMINS",
58
+ "RESOLVE_CALLER_IDENTITY",
59
+ "SKIP_CREDENTIAL_VERIFICATION",
60
+ ] as const;
61
+
62
+ const logger = {
63
+ verbose: vi.fn(),
64
+ debug: vi.fn(),
65
+ info: vi.fn(),
66
+ warn: vi.fn(),
67
+ error: vi.fn(),
68
+ child: () => logger,
69
+ } as unknown as ILogger;
70
+
71
+ // A Renown login's bearer: a JWT signed by a fresh did:key, naming `address`.
72
+ async function bearerFor(address: string): Promise<string> {
73
+ const crypto = await new RenownCryptoBuilder()
74
+ .withKeyPairStorage(new MemoryKeyStorage())
75
+ .build();
76
+ return crypto.getBearerToken(address);
77
+ }
78
+
79
+ let tempRoot = "";
80
+ let previous: [string, string | undefined][] = [];
81
+ let switchboard: SwitchboardReactor | undefined;
82
+ let tokens: Record<string, string> = {};
83
+ let shared = "";
84
+ let open = "";
85
+
86
+ const base = () => `http://127.0.0.1:${switchboard!.port}`;
87
+ const authorization = (caller: Caller): Record<string, string> =>
88
+ caller === "anonymous" ? {} : { authorization: `Bearer ${tokens[caller]}` };
89
+
90
+ type GraphqlResult = {
91
+ status: number;
92
+ errors?: { extensions?: { code?: string } }[];
93
+ data?: Record<string, unknown>;
94
+ };
95
+
96
+ async function graphql(
97
+ caller: Caller,
98
+ query: string,
99
+ variables: Record<string, unknown> = {},
100
+ ): Promise<GraphqlResult> {
101
+ const response = await fetch(`${base()}/graphql`, {
102
+ method: "POST",
103
+ headers: { "content-type": "application/json", ...authorization(caller) },
104
+ body: JSON.stringify({ query, variables }),
105
+ });
106
+ const body = (await response.json()) as Omit<GraphqlResult, "status">;
107
+ return { status: response.status, ...body };
108
+ }
109
+
110
+ async function graphqlOk(caller: Caller, query: string, variables = {}) {
111
+ const result = await graphql(caller, query, variables);
112
+ expect(result.errors, JSON.stringify(result.errors)).toBeUndefined();
113
+ return result.data!;
114
+ }
115
+
116
+ beforeAll(async () => {
117
+ tempRoot = await mkdtemp(join(tmpdir(), "switchboard-mcp-auth-"));
118
+ previous = ENV_KEYS.map((name) => [name, process.env[name]]);
119
+ for (const name of ENV_KEYS) delete process.env[name];
120
+ process.env.PH_REACTOR_DATABASE_URL = join(tempRoot, "reactor-storage");
121
+
122
+ switchboard = await bootSwitchboard(
123
+ {
124
+ server: { port: 0 },
125
+ storage: { readModel: { url: join(tempRoot, "read-model") } },
126
+ features: { workflows: false, mcp: true },
127
+ packages: { disableLocal: true },
128
+ identity: { keypairPath: join(tempRoot, "identity.json") },
129
+ protocol: {
130
+ featureFlags: { documentDecisions: true, authEnforcement: true },
131
+ },
132
+ auth: {
133
+ enabled: true,
134
+ admins: [ADMIN],
135
+ documentPermissions: { enabled: true },
136
+ // The bearer's signature is still verified; only the Renown lookup
137
+ // of its credential is skipped, as the boot allows under vitest.
138
+ skipCredentialVerification: true,
139
+ // No discovery request: every write here is the host's own.
140
+ renown: { switchboardUrl: "http://127.0.0.1:9/graphql" },
141
+ },
142
+ },
143
+ { logger },
144
+ );
145
+
146
+ tokens = Object.fromEntries(
147
+ await Promise.all(
148
+ USERS.map(
149
+ async (address) => [address, await bearerFor(address)] as const,
150
+ ),
151
+ ),
152
+ );
153
+
154
+ const { reactor } = switchboard;
155
+ const drive = async (name: string) => {
156
+ const handle = await reactor.write.drives.create({ global: { name } });
157
+ await handle.readable;
158
+ return handle.documentId;
159
+ };
160
+ shared = await drive("Shared");
161
+ open = await drive("Open");
162
+ // The ACL GraphQL decides with, set through GraphQL by the admin.
163
+ await graphqlOk(
164
+ ADMIN,
165
+ `mutation ($id: String!) { setDocumentProtection(documentIdOrSlug: $id, protected: true) { documentId } }`,
166
+ { id: shared },
167
+ );
168
+ for (const [user, permission] of [
169
+ [READER, "READ"],
170
+ [WRITER, "WRITE"],
171
+ ]) {
172
+ await graphqlOk(
173
+ ADMIN,
174
+ `mutation ($id: String!, $user: String!, $permission: DocumentPermissionLevel!) {
175
+ grantDocumentPermission(documentIdOrSlug: $id, userAddress: $user, permission: $permission) { documentId }
176
+ }`,
177
+ { id: shared, user, permission },
178
+ );
179
+ }
180
+ }, 60_000);
181
+
182
+ afterAll(async () => {
183
+ await switchboard?.shutdown();
184
+ for (const [name, value] of previous) {
185
+ if (value === undefined) delete process.env[name];
186
+ else process.env[name] = value;
187
+ }
188
+ await rm(tempRoot, { recursive: true, force: true });
189
+ });
190
+
191
+ async function withClient<T>(
192
+ caller: Caller,
193
+ run: (
194
+ call: (name: string, args?: object) => Promise<ToolResult>,
195
+ ) => Promise<T>,
196
+ ): Promise<T> {
197
+ const client = new Client({ name: "boot-mcp-auth", version: "1.0.0" });
198
+ await client.connect(
199
+ new StreamableHTTPClientTransport(new URL(`${base()}/mcp`), {
200
+ requestInit: { headers: authorization(caller) },
201
+ }),
202
+ );
203
+ try {
204
+ return await run((name, args = {}) =>
205
+ client.callTool({ name, arguments: args as Record<string, unknown> }),
206
+ );
207
+ } finally {
208
+ await client.close();
209
+ }
210
+ }
211
+
212
+ const forbiddenTool = (result: ToolResult) =>
213
+ result.isError === true &&
214
+ JSON.stringify(result.content).includes("FORBIDDEN");
215
+
216
+ const forbiddenGraphql = (result: GraphqlResult) =>
217
+ result.errors?.some((e) => e.extensions?.code === "FORBIDDEN") ?? false;
218
+
219
+ async function postPing(header?: string): Promise<number> {
220
+ const response = await fetch(`${base()}/mcp`, {
221
+ method: "POST",
222
+ headers: {
223
+ "content-type": "application/json",
224
+ accept: "application/json, text/event-stream",
225
+ ...(header ? { authorization: header } : {}),
226
+ },
227
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "ping" }),
228
+ });
229
+ await response.body?.cancel();
230
+ return response.status;
231
+ }
232
+
233
+ describe("Switchboard's /mcp authorizes as its GraphQL API does", () => {
234
+ it("admits the callers GraphQL admits and refuses a bad bearer", async () => {
235
+ for (const caller of CALLERS) {
236
+ expect(await postPing(authorization(caller).authorization)).toBe(200);
237
+ }
238
+ expect(await postPing("Bearer not-a-jwt")).toBe(401);
239
+ expect((await graphql(READER, "{ __typename }")).status).toBe(200);
240
+ const bad = await fetch(`${base()}/graphql`, {
241
+ method: "POST",
242
+ headers: {
243
+ "content-type": "application/json",
244
+ authorization: "Bearer not-a-jwt",
245
+ },
246
+ body: JSON.stringify({ query: "{ __typename }" }),
247
+ });
248
+ expect(bad.status).toBe(401);
249
+ });
250
+
251
+ it("refuses and allows each caller the same read", async () => {
252
+ const decisions = await Promise.all(
253
+ CALLERS.map(async (caller) => {
254
+ const viaGraphql = await graphql(
255
+ caller,
256
+ `
257
+ query ($id: String!) {
258
+ document(idOrSlug: $id) {
259
+ document {
260
+ id
261
+ }
262
+ }
263
+ }
264
+ `,
265
+ { id: shared },
266
+ );
267
+ const viaMcp = await withClient(caller, (call) =>
268
+ call("getDrive", { driveId: shared }),
269
+ );
270
+ return {
271
+ caller,
272
+ graphql: forbiddenGraphql(viaGraphql) ? "forbidden" : "allowed",
273
+ mcp: forbiddenTool(viaMcp) ? "forbidden" : "allowed",
274
+ };
275
+ }),
276
+ );
277
+
278
+ const allowed = [ADMIN, READER, WRITER];
279
+ for (const decision of decisions) {
280
+ const expected = allowed.includes(decision.caller)
281
+ ? "allowed"
282
+ : "forbidden";
283
+ expect(decision).toEqual({
284
+ caller: decision.caller,
285
+ graphql: expected,
286
+ mcp: expected,
287
+ });
288
+ }
289
+ });
290
+
291
+ it("lists the same drives to each caller", async () => {
292
+ for (const caller of [READER, OUTSIDER] as const) {
293
+ const data = await graphqlOk(
294
+ caller,
295
+ `{ findDocuments(search: { type: "powerhouse/document-drive" }) { items { id } } }`,
296
+ );
297
+ const viaGraphql = (
298
+ data.findDocuments as { items: { id: string }[] }
299
+ ).items.map((d) => d.id);
300
+ const viaMcp = await withClient(caller, async (call) =>
301
+ (
302
+ (await call("getDrives")).structuredContent as {
303
+ drives: { id: string }[];
304
+ }
305
+ ).drives.map((d) => d.id),
306
+ );
307
+ expect(viaMcp.sort()).toEqual(viaGraphql.sort());
308
+ expect(viaMcp.includes(shared)).toBe(caller === READER);
309
+ expect(viaMcp).toContain(open);
310
+ }
311
+ });
312
+
313
+ it("refuses and allows each caller the same write", async () => {
314
+ for (const caller of CALLERS) {
315
+ const folder = (via: string) => {
316
+ const { id, type, input, scope, timestampUtcMs } = addFolder({
317
+ id: `${via}-${caller}`,
318
+ name: `${via}-${caller}`,
319
+ });
320
+ return { id, type, input, scope, timestampUtcMs };
321
+ };
322
+ const viaGraphql = await graphql(
323
+ caller,
324
+ `
325
+ mutation ($id: String!, $actions: [ActionInput!]!) {
326
+ execute(documentIdOrSlug: $id, actions: $actions) {
327
+ id
328
+ }
329
+ }
330
+ `,
331
+ { id: shared, actions: [folder("graphql")] },
332
+ );
333
+ const { type, input } = folder("mcp");
334
+ const viaMcp = await withClient(caller, (call) =>
335
+ call("addActions", { documentId: shared, actions: [{ type, input }] }),
336
+ );
337
+ const mayWrite = caller === ADMIN || caller === WRITER;
338
+
339
+ expect(forbiddenGraphql(viaGraphql), caller).toBe(!mayWrite);
340
+ if (mayWrite) {
341
+ expect(viaMcp.structuredContent, caller).toMatchObject({
342
+ success: true,
343
+ });
344
+ } else if (caller !== READER) {
345
+ // addActions reads its target first, so a non-reader is refused there.
346
+ expect(forbiddenTool(viaMcp), caller).toBe(true);
347
+ } else {
348
+ expect(viaMcp.structuredContent, caller).toMatchObject({
349
+ success: false,
350
+ results: [{ index: 0, error: { kind: "denied" } }],
351
+ });
352
+ }
353
+ }
354
+ const drive = await switchboard!.reactor.read.get(shared);
355
+ const nodes = (
356
+ drive.state as unknown as { global: { nodes: { id: string }[] } }
357
+ ).global.nodes.map((n) => n.id);
358
+ expect(nodes.sort()).toEqual(
359
+ [
360
+ `graphql-${ADMIN}`,
361
+ `graphql-${WRITER}`,
362
+ `mcp-${ADMIN}`,
363
+ `mcp-${WRITER}`,
364
+ ].sort(),
365
+ );
366
+ });
367
+
368
+ it("refuses and allows each caller the same creates", async () => {
369
+ for (const caller of CALLERS) {
370
+ const inDrive = await graphql(
371
+ caller,
372
+ `
373
+ mutation ($parent: String!) {
374
+ createEmptyDocument(
375
+ documentType: "powerhouse/document-model"
376
+ parentIdOrSlug: $parent
377
+ ) {
378
+ id
379
+ }
380
+ }
381
+ `,
382
+ { parent: shared },
383
+ );
384
+ const loose = await graphql(
385
+ caller,
386
+ `
387
+ mutation {
388
+ createEmptyDocument(documentType: "powerhouse/document-model") {
389
+ id
390
+ }
391
+ }
392
+ `,
393
+ );
394
+ const viaMcp = await withClient(caller, async (call) => ({
395
+ inDrive: await call("createDocument", {
396
+ documentType: "powerhouse/document-model",
397
+ driveId: shared,
398
+ }),
399
+ loose: await call("createDocument", {
400
+ documentType: "powerhouse/document-model",
401
+ }),
402
+ }));
403
+
404
+ expect(viaMcp.inDrive.isError === true, caller).toBe(
405
+ forbiddenGraphql(inDrive),
406
+ );
407
+ expect(viaMcp.loose.isError === true, caller).toBe(
408
+ (loose.errors?.length ?? 0) > 0,
409
+ );
410
+ }
411
+ });
412
+
413
+ it("makes an MCP creator the owner GraphQL then lets manage the document", async () => {
414
+ const documentId = await withClient(OUTSIDER, async (call) => {
415
+ const created = await call("createDocument", {
416
+ documentType: "powerhouse/document-model",
417
+ });
418
+ return (created.structuredContent as { documentId: string }).documentId;
419
+ });
420
+ const data = await graphqlOk(
421
+ OUTSIDER,
422
+ `mutation ($id: String!) { setDocumentProtection(documentIdOrSlug: $id, protected: true) { documentId } }`,
423
+ { id: documentId },
424
+ );
425
+ expect(data.setDocumentProtection).toEqual({ documentId });
426
+ const refused = await withClient(READER, (call) =>
427
+ call("getDocument", { documentId }),
428
+ );
429
+ expect(forbiddenTool(refused)).toBe(true);
430
+ });
431
+
432
+ it("refuses a delete the caller may not make, as GraphQL does", async () => {
433
+ const viaGraphql = await graphql(
434
+ READER,
435
+ `
436
+ mutation ($id: String!) {
437
+ deleteDocument(idOrSlug: $id)
438
+ }
439
+ `,
440
+ { id: shared },
441
+ );
442
+ const viaMcp = await withClient(READER, (call) =>
443
+ call("deleteDrive", { documentId: shared }),
444
+ );
445
+ expect(forbiddenGraphql(viaGraphql)).toBe(true);
446
+ expect(forbiddenTool(viaMcp)).toBe(true);
447
+ await expect(switchboard!.reactor.read.get(shared)).resolves.toBeDefined();
448
+ });
449
+ });
@@ -0,0 +1,119 @@
1
+ import { mkdtemp, rm } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import type { ILogger } from "document-model";
5
+ import { describe, expect, it, vi } from "vitest";
6
+ import type { startSwitchboard } from "../src/server.mjs";
7
+ import { bootSwitchboard } from "./boot-helpers.js";
8
+
9
+ function stubLogger(): ILogger {
10
+ const logger = {
11
+ verbose: vi.fn(),
12
+ debug: vi.fn(),
13
+ info: vi.fn(),
14
+ warn: vi.fn(),
15
+ error: vi.fn(),
16
+ child: vi.fn(),
17
+ };
18
+ logger.child.mockReturnValue(logger);
19
+ return logger as unknown as ILogger;
20
+ }
21
+
22
+ async function withSwitchboard(
23
+ env: Record<string, string>,
24
+ mcp: boolean | undefined,
25
+ run: (
26
+ switchboard: Awaited<ReturnType<typeof startSwitchboard>>,
27
+ ) => Promise<void>,
28
+ ): Promise<void> {
29
+ const tempRoot = await mkdtemp(join(tmpdir(), "switchboard-mcp-enabled-"));
30
+ const names = [
31
+ "PH_REACTOR_DATABASE_URL",
32
+ "MCP_ENABLED",
33
+ // The env-flag semantics under test are the CLASSIC path's: flag-on, the
34
+ // mcp plugin owns options.mcp and MCP_ENABLED is deliberately inert
35
+ // (presence in the composition is the switch — rewire plan R2.2).
36
+ "FEATURE_PLUGIN_HOST_ENABLED",
37
+ ...Object.keys(env),
38
+ ];
39
+ const previous = names.map((name) => [name, process.env[name]] as const);
40
+ process.env.PH_REACTOR_DATABASE_URL = join(tempRoot, "reactor-storage");
41
+ delete process.env.MCP_ENABLED;
42
+ delete process.env.FEATURE_PLUGIN_HOST_ENABLED;
43
+ Object.assign(process.env, env);
44
+ let switchboard: Awaited<ReturnType<typeof startSwitchboard>> | undefined;
45
+
46
+ try {
47
+ switchboard = await bootSwitchboard(
48
+ {
49
+ server: { port: 0 },
50
+ storage: { readModel: { url: join(tempRoot, "read-model") } },
51
+ features: { workflows: false, mcp: mcp },
52
+ packages: { disableLocal: true },
53
+ identity: { keypairPath: join(tempRoot, "identity.json") },
54
+ drive: {
55
+ slug: "default-drive",
56
+ global: { name: "Default Drive" },
57
+ },
58
+ },
59
+ { logger: stubLogger() },
60
+ );
61
+ await run(switchboard);
62
+ await switchboard.shutdown();
63
+ switchboard = undefined;
64
+ } finally {
65
+ await switchboard?.shutdown();
66
+ for (const [name, value] of previous) {
67
+ if (value === undefined) {
68
+ delete process.env[name];
69
+ } else {
70
+ process.env[name] = value;
71
+ }
72
+ }
73
+ await rm(tempRoot, { recursive: true, force: true });
74
+ }
75
+ }
76
+
77
+ async function postMcp(port: number): Promise<number> {
78
+ const response = await fetch(`http://127.0.0.1:${port}/mcp`, {
79
+ method: "POST",
80
+ headers: {
81
+ "content-type": "application/json",
82
+ accept: "application/json, text/event-stream",
83
+ },
84
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "ping" }),
85
+ });
86
+ await response.body?.cancel();
87
+ return response.status;
88
+ }
89
+
90
+ describe("booting Switchboard", () => {
91
+ it("mounts /mcp by default", async () => {
92
+ await withSwitchboard({}, undefined, async ({ mcpEnabled, port }) => {
93
+ expect(mcpEnabled).toBe(true);
94
+ expect(await postMcp(port)).not.toBe(404);
95
+ });
96
+ }, 60_000);
97
+
98
+ it('leaves /mcp unmounted under MCP_ENABLED="false"', async () => {
99
+ await withSwitchboard(
100
+ { MCP_ENABLED: "false" },
101
+ undefined,
102
+ async ({ mcpEnabled, port }) => {
103
+ expect(mcpEnabled).toBe(false);
104
+ expect(await postMcp(port)).toBe(404);
105
+ },
106
+ );
107
+ }, 60_000);
108
+
109
+ it("keeps a host's mcp: false over MCP_ENABLED=true", async () => {
110
+ await withSwitchboard(
111
+ { MCP_ENABLED: "true" },
112
+ false,
113
+ async ({ mcpEnabled, port }) => {
114
+ expect(mcpEnabled).toBe(false);
115
+ expect(await postMcp(port)).toBe(404);
116
+ },
117
+ );
118
+ }, 60_000);
119
+ });
@@ -0,0 +1,101 @@
1
+ import { mkdtemp, rm } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import type { ILogger } from "document-model";
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
+ import type { startSwitchboard } from "../src/server.mjs";
7
+ import { bootSwitchboard } from "./boot-helpers.js";
8
+
9
+ type Switchboard = Awaited<ReturnType<typeof startSwitchboard>>;
10
+
11
+ function stubLogger(): ILogger {
12
+ const logger = {
13
+ verbose: vi.fn(),
14
+ debug: vi.fn(),
15
+ info: vi.fn(),
16
+ warn: vi.fn(),
17
+ error: vi.fn(),
18
+ child: vi.fn(),
19
+ };
20
+ logger.child.mockReturnValue(logger);
21
+ return logger as unknown as ILogger;
22
+ }
23
+
24
+ const ENV = ["PH_REACTOR_DATABASE_URL", "FEATURE_PLUGIN_HOST_ENABLED"];
25
+ let previousEnv: (readonly [string, string | undefined])[] = [];
26
+ let tempRoots: string[] = [];
27
+ let running: Switchboard[] = [];
28
+
29
+ beforeEach(() => {
30
+ previousEnv = ENV.map((name) => [name, process.env[name]] as const);
31
+ delete process.env.FEATURE_PLUGIN_HOST_ENABLED;
32
+ });
33
+
34
+ afterEach(async () => {
35
+ for (const switchboard of running.reverse()) await switchboard.shutdown();
36
+ running = [];
37
+ for (const [name, value] of previousEnv) {
38
+ if (value === undefined) delete process.env[name];
39
+ else process.env[name] = value;
40
+ }
41
+ for (const root of tempRoots) {
42
+ await rm(root, { recursive: true, force: true });
43
+ }
44
+ tempRoots = [];
45
+ });
46
+
47
+ // The reactor database comes from process env, so instances boot one at a time.
48
+ async function boot(): Promise<Switchboard> {
49
+ const tempRoot = await mkdtemp(join(tmpdir(), "switchboard-port-zero-"));
50
+ tempRoots.push(tempRoot);
51
+ process.env.PH_REACTOR_DATABASE_URL = join(tempRoot, "reactor-storage");
52
+ const switchboard = await bootSwitchboard(
53
+ {
54
+ server: { port: 0 },
55
+ storage: { readModel: { url: join(tempRoot, "read-model") } },
56
+ features: { workflows: false, mcp: false },
57
+ packages: { disableLocal: true },
58
+ identity: { keypairPath: join(tempRoot, "identity.json") },
59
+ drive: {
60
+ slug: "default-drive",
61
+ global: { name: "Default Drive" },
62
+ },
63
+ },
64
+ { logger: stubLogger() },
65
+ );
66
+ running.push(switchboard);
67
+ return switchboard;
68
+ }
69
+
70
+ describe("booting Switchboard on port 0", () => {
71
+ it("reports the port the OS picked", async () => {
72
+ const { port, defaultDriveUrl } = await boot();
73
+
74
+ expect(port).toBeGreaterThan(0);
75
+ expect((await fetch(`http://localhost:${port}/health`)).status).toBe(200);
76
+ const graphql = await fetch(`http://localhost:${port}/graphql`, {
77
+ method: "POST",
78
+ headers: { "content-type": "application/json" },
79
+ // Routed to a subgraph, which the gateway fetches at its own port.
80
+ body: JSON.stringify({ query: "{ system { __typename } }" }),
81
+ });
82
+ expect(await graphql.json()).toEqual({
83
+ data: { system: { __typename: "SystemInfo" } },
84
+ });
85
+ expect(defaultDriveUrl).toBe(`http://localhost:${port}/d/default-drive`);
86
+ }, 60_000);
87
+
88
+ it("gives a second instance its own port while the first runs", async () => {
89
+ const first = await boot();
90
+ const second = await boot();
91
+
92
+ expect(second.port).toBeGreaterThan(0);
93
+ expect(second.port).not.toBe(first.port);
94
+ expect((await fetch(`http://localhost:${first.port}/health`)).status).toBe(
95
+ 200,
96
+ );
97
+ expect((await fetch(`http://localhost:${second.port}/health`)).status).toBe(
98
+ 200,
99
+ );
100
+ }, 120_000);
101
+ });