@powerhousedao/switchboard 6.3.0-dev.9 → 6.4.0-next.1

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 (68) hide show
  1. package/.tsbuild/test/boot-helpers.d.ts +2 -1
  2. package/.tsbuild/test/boot-helpers.d.ts.map +1 -1
  3. package/.tsbuild/test/boot-identity-files.test.d.ts +2 -0
  4. package/.tsbuild/test/boot-identity-files.test.d.ts.map +1 -0
  5. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  6. package/CHANGELOG.md +59 -0
  7. package/README.md +12 -10
  8. package/dist/boot.d.mts +1 -1
  9. package/dist/boot.mjs +1 -1
  10. package/dist/config/from-env.d.mts +1 -1
  11. package/dist/config/from-env.d.mts.map +1 -1
  12. package/dist/config/from-env.mjs +3 -3
  13. package/dist/config/schema.d.mts +1 -1
  14. package/dist/config/schema.mjs +3 -3
  15. package/dist/{from-env-DKK_wPrO.mjs → from-env-CLImR6qa.mjs} +4 -28
  16. package/dist/from-env-CLImR6qa.mjs.map +1 -0
  17. package/dist/index.mjs +3 -3
  18. package/dist/migrate.mjs +9 -4
  19. package/dist/migrate.mjs.map +1 -1
  20. package/dist/{plugin-host-tTjDTNz0.d.mts → plugin-host-Z-4Ruypj.d.mts} +19 -2
  21. package/dist/plugin-host-Z-4Ruypj.d.mts.map +1 -0
  22. package/dist/plugins/ai.d.mts +1 -1
  23. package/dist/plugins/attachments.d.mts +1 -1
  24. package/dist/plugins/attachments.mjs +3 -3
  25. package/dist/plugins/mcp.d.mts +1 -1
  26. package/dist/plugins/privacy.d.mts +1 -1
  27. package/dist/plugins/workflows.d.mts +2 -2
  28. package/dist/plugins/workflows.mjs +3 -3
  29. package/dist/{schema-BJ-OFAox.mjs → schema-BbwISVSO.mjs} +15 -13
  30. package/dist/schema-BbwISVSO.mjs.map +1 -0
  31. package/dist/{schema-w1lShimw.d.mts → schema-CZsLzAZg.d.mts} +9 -4
  32. package/dist/schema-CZsLzAZg.d.mts.map +1 -0
  33. package/dist/{server-BS-PFzoK.mjs → server-BMRdMNvC.mjs} +172 -244
  34. package/dist/server-BMRdMNvC.mjs.map +1 -0
  35. package/dist/server.d.mts +2 -2
  36. package/dist/server.d.mts.map +1 -1
  37. package/dist/server.mjs +4 -4
  38. package/dist/{types-Bk4T4D9F.d.mts → types-Crizw8W4.d.mts} +13 -8
  39. package/dist/types-Crizw8W4.d.mts.map +1 -0
  40. package/dist/{utils-Cm0TE6dP.mjs → utils-D8yHRVjT.mjs} +4 -18
  41. package/dist/{utils-Cm0TE6dP.mjs.map → utils-D8yHRVjT.mjs.map} +1 -1
  42. package/dist/utils.d.mts +1 -6
  43. package/dist/utils.d.mts.map +1 -1
  44. package/dist/utils.mjs +4 -4
  45. package/dist/{workflows-mdYUh3Us.mjs → workflows-D2r6IKou.mjs} +4 -4
  46. package/dist/{workflows-mdYUh3Us.mjs.map → workflows-D2r6IKou.mjs.map} +1 -1
  47. package/package.json +17 -17
  48. package/test/ai-gateway.test.ts +0 -2
  49. package/test/boot-auth-config.test.ts +1 -1
  50. package/test/boot-helpers.ts +3 -1
  51. package/test/boot-identity-files.test.ts +68 -0
  52. package/test/boot-mcp-auth.test.ts +0 -1
  53. package/test/boot-mcp-enabled.test.ts +0 -2
  54. package/test/boot-port-zero.test.ts +1 -2
  55. package/test/boot-ready-drives.test.ts +1 -2
  56. package/test/config-from-env.test.ts +0 -9
  57. package/test/config-merge.test.ts +47 -47
  58. package/test/config-schema.test.ts +16 -4
  59. package/test/default-composition.test.ts +61 -65
  60. package/test/default-drive-protocol-versions.test.ts +13 -6
  61. package/test/default-drive-slug.test.ts +6 -11
  62. package/test/plugin-presence.test.ts +15 -16
  63. package/dist/from-env-DKK_wPrO.mjs.map +0 -1
  64. package/dist/plugin-host-tTjDTNz0.d.mts.map +0 -1
  65. package/dist/schema-BJ-OFAox.mjs.map +0 -1
  66. package/dist/schema-w1lShimw.d.mts.map +0 -1
  67. package/dist/server-BS-PFzoK.mjs.map +0 -1
  68. package/dist/types-Bk4T4D9F.d.mts.map +0 -1
@@ -13,6 +13,7 @@ import {
13
13
  } from "../src/config/schema.js";
14
14
  import {
15
15
  builtinSwitchboardPlugins,
16
+ configFileWorkflowsNotice,
16
17
  defaultSwitchboardPlugins,
17
18
  } from "../src/plugin-host.mjs";
18
19
  import type { startSwitchboard } from "../src/server.mjs";
@@ -74,46 +75,71 @@ describe("defaultSwitchboardPlugins", () => {
74
75
  });
75
76
  });
76
77
 
77
- describe("features.pluginHost is tri-state", () => {
78
- it("stays unset in the schema, and keeps an explicit true or false", () => {
79
- expect(switchboardConfigSchema.parse({}).features.pluginHost).toBe(
80
- undefined,
81
- );
82
- for (const pluginHost of [true, false]) {
83
- expect(
84
- switchboardConfigSchema.parse({ features: { pluginHost } }).features
85
- .pluginHost,
86
- ).toBe(pluginHost);
87
- }
78
+ describe("the retired plugin-host switch", () => {
79
+ it("is no config key: the schema drops it", () => {
80
+ expect(
81
+ switchboardConfigSchema.parse({ features: { pluginHost: false } })
82
+ .features,
83
+ ).not.toHaveProperty("pluginHost");
88
84
  });
89
85
 
90
- it.each([
91
- [undefined, undefined],
92
- ["", undefined],
93
- [" ", undefined],
94
- ["1", true],
95
- ["true", true],
96
- ["false", false],
97
- ["0", false],
98
- ["off", false],
99
- ["no", false],
100
- // Neither a yes nor a no: the default composition, as when unset.
101
- ["on", undefined],
102
- ["yes", undefined],
103
- ])("FEATURE_PLUGIN_HOST_ENABLED=%j maps to %s", (value, expected) => {
104
- expect(
105
- resolved({ FEATURE_PLUGIN_HOST_ENABLED: value }, {}).features.pluginHost,
106
- ).toBe(expected);
86
+ it.each(["1", "true", "false", "0"])(
87
+ "FEATURE_PLUGIN_HOST_ENABLED=%j changes nothing in the config",
88
+ (value) => {
89
+ expect(resolved({ FEATURE_PLUGIN_HOST_ENABLED: value }, {})).toEqual(
90
+ resolved({}, {}),
91
+ );
92
+ },
93
+ );
94
+ });
95
+
96
+ describe("workflows.enabled in powerhouse.config.json", () => {
97
+ const boot = {
98
+ declaredComposition: false,
99
+ workflows: undefined,
100
+ configFileEnabled: true,
101
+ };
102
+
103
+ it("warns that the key no longer switches workflows on, and names both ways", () => {
104
+ expect(configFileWorkflowsNotice(boot)).toBe(
105
+ "powerhouse.config.json workflows.enabled no longer switches workflows on in Switchboard since 6.4, so they stay off. " +
106
+ 'Set PH_WORKFLOWS_ENABLED=1, or list "@powerhousedao/switchboard/plugins/workflows" under runner.plugins in hosts/switchboard/host.js.',
107
+ );
107
108
  });
108
109
 
109
- it("a caller's explicit false selects the classic boot over the env", () => {
110
+ it("stays silent under a declared composition", () => {
110
111
  expect(
111
- resolved(
112
- { FEATURE_PLUGIN_HOST_ENABLED: "1" },
113
- { features: { pluginHost: false } },
114
- ).features.pluginHost,
115
- ).toBe(false);
112
+ configFileWorkflowsNotice({ ...boot, declaredComposition: true }),
113
+ ).toBe(undefined);
116
114
  });
115
+
116
+ it.each([true, false])(
117
+ "stays silent when the env or the caller says %j",
118
+ (workflows) => {
119
+ expect(configFileWorkflowsNotice({ ...boot, workflows })).toBe(undefined);
120
+ },
121
+ );
122
+
123
+ it.each([false, undefined])(
124
+ "stays silent when the key is %j",
125
+ (configFileEnabled) => {
126
+ expect(configFileWorkflowsNotice({ ...boot, configFileEnabled })).toBe(
127
+ undefined,
128
+ );
129
+ },
130
+ );
131
+
132
+ it.each(["1", "0", "true", "false"])(
133
+ "PH_WORKFLOWS_ENABLED=%j resolves the switch, so nothing is warned",
134
+ (value) => {
135
+ const { workflows } = resolved(
136
+ { PH_WORKFLOWS_ENABLED: value },
137
+ {},
138
+ ).features;
139
+ expect(workflows).not.toBe(undefined);
140
+ expect(configFileWorkflowsNotice({ ...boot, workflows })).toBe(undefined);
141
+ },
142
+ );
117
143
  });
118
144
 
119
145
  describe("the switches without a declared composition", () => {
@@ -122,7 +148,6 @@ describe("the switches without a declared composition", () => {
122
148
  { MCP_ENABLED: "true", PH_WORKFLOWS_ENABLED: "true" },
123
149
  {},
124
150
  );
125
- expect(config.features.pluginHost).toBeUndefined();
126
151
  expect(config.features.mcp).toBe(true);
127
152
  expect(config.features.workflows).toBe(true);
128
153
  });
@@ -143,7 +168,6 @@ describe("the switches without a declared composition", () => {
143
168
  { migratePglite: false, logger: silent },
144
169
  ),
145
170
  );
146
- expect(config.features.pluginHost).toBeUndefined();
147
171
  expect(config.features.mcp).toBe(false);
148
172
  });
149
173
 
@@ -151,7 +175,6 @@ describe("the switches without a declared composition", () => {
151
175
  const config = switchboardConfigSchema.parse(
152
176
  binSwitchboardConfig({}, { migratePglite: false, logger: silent }),
153
177
  );
154
- expect(config.features.pluginHost).toBeUndefined();
155
178
  expect(config.features.mcp).toBe(true);
156
179
  });
157
180
  });
@@ -159,7 +182,7 @@ describe("the switches without a declared composition", () => {
159
182
  const PLUGIN_LOG = "[switchboard:plugins]";
160
183
 
161
184
  /** Boots with the env sandboxed like plugin-presence.test.ts, and hands back
162
- * the plugin host's console lines: none means the classic inline boot ran. */
185
+ * the plugin host's console lines. */
163
186
  async function withSwitchboard(
164
187
  env: Env,
165
188
  features: NonNullable<SwitchboardConfigInput["features"]>,
@@ -175,7 +198,6 @@ async function withSwitchboard(
175
198
  "PH_REACTOR_DATABASE_URL",
176
199
  "MCP_ENABLED",
177
200
  "PH_WORKFLOWS_ENABLED",
178
- "FEATURE_PLUGIN_HOST_ENABLED",
179
201
  ];
180
202
  const previous = touched.map((name) => [name, process.env[name]] as const);
181
203
  for (const name of touched) delete process.env[name];
@@ -261,30 +283,4 @@ describe("a boot without a declared composition", () => {
261
283
  },
262
284
  );
263
285
  }, 60_000);
264
-
265
- it("an explicit features.pluginHost: false still boots the classic path", async () => {
266
- await withSwitchboard(
267
- {},
268
- { pluginHost: false },
269
- async (switchboard, pluginLines) => {
270
- expect(pluginLines).toEqual([]);
271
- expect(switchboard.mcpEnabled).toBe(true);
272
- expect(await postMcp(switchboard.port)).not.toBe(404);
273
- expect(switchboard.attachmentService).toBeDefined();
274
- },
275
- );
276
- }, 60_000);
277
-
278
- it("FEATURE_PLUGIN_HOST_ENABLED=false still boots the classic path", async () => {
279
- await withSwitchboard(
280
- { FEATURE_PLUGIN_HOST_ENABLED: "false", MCP_ENABLED: "false" },
281
- {},
282
- async (switchboard, pluginLines) => {
283
- expect(pluginLines).toEqual([]);
284
- expect(switchboard.mcpEnabled).toBe(false);
285
- expect(await postMcp(switchboard.port)).toBe(404);
286
- expect(switchboard.attachmentService).toBeDefined();
287
- },
288
- );
289
- }, 60_000);
290
286
  });
@@ -14,7 +14,7 @@ const modules = [
14
14
  reactorDriveDocumentModelModule,
15
15
  ] as unknown as DocumentModelModule[];
16
16
  import { describe, expect, it } from "vitest";
17
- import { addDefaultDrive, addDefaultReactorDrive } from "../src/utils.mjs";
17
+ import { ensureDrive } from "../src/utils.mjs";
18
18
 
19
19
  function client(): { client: IReactorClient; created: PHDocument[] } {
20
20
  const created: PHDocument[] = [];
@@ -54,13 +54,20 @@ function client(): { client: IReactorClient; created: PHDocument[] } {
54
54
  }
55
55
 
56
56
  describe.each([
57
- ["addDefaultDrive", addDefaultDrive],
58
- ["addDefaultReactorDrive", addDefaultReactorDrive],
59
- ])("%s", (_name, add) => {
57
+ "powerhouse/document-drive",
58
+ "powerhouse/reactor-drive",
59
+ ] as const)("ensureDrive of a %s", (documentType) => {
60
+ const add = (
61
+ reactor: IReactorClient,
62
+ drive: object,
63
+ port: number,
64
+ ): Promise<string | undefined> =>
65
+ ensureDrive(reactor, { ...drive, documentType } as never, port);
66
+
60
67
  it("heads the drive with the client's newDocument", async () => {
61
68
  const { client: reactor, created } = client();
62
69
 
63
- await add(reactor, { slug: "main", global: { name: "Main" } } as never, 1);
70
+ await add(reactor, { slug: "main", global: { name: "Main" } }, 1);
64
71
 
65
72
  expect(created[0].header.protocolVersions).toEqual({
66
73
  "base-reducer": 3,
@@ -71,7 +78,7 @@ describe.each([
71
78
  it("heads a drive with a configured id as legacy at the same versions", async () => {
72
79
  const { client: reactor, created } = client();
73
80
 
74
- await add(reactor, { id: "fixed", global: { name: "Main" } } as never, 1);
81
+ await add(reactor, { id: "fixed", global: { name: "Main" } }, 1);
75
82
 
76
83
  expect(created[0].header.id).toBe("fixed");
77
84
  expect(created[0].header.protocolVersions).toEqual({ "base-reducer": 3 });
@@ -15,7 +15,7 @@ import {
15
15
  import { deleteDocumentAction } from "@powerhousedao/reactor";
16
16
  import { documentModelDocumentModelModule } from "document-model";
17
17
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
18
- import { addDefaultDrive, ensureDrive } from "../src/utils.mjs";
18
+ import { ensureDrive } from "../src/utils.mjs";
19
19
 
20
20
  const PORT = 4001;
21
21
 
@@ -32,7 +32,7 @@ const workflows = (id: string): DriveInput =>
32
32
  },
33
33
  }) as DriveInput;
34
34
 
35
- describe("addDefaultDrive with a slug another document holds", () => {
35
+ describe("ensureDrive with a slug another document holds", () => {
36
36
  let module: InProcessReactorClientModule;
37
37
  const logger = { error: vi.fn() };
38
38
 
@@ -60,7 +60,7 @@ describe("addDefaultDrive with a slug another document holds", () => {
60
60
 
61
61
  it("creates the drive when the slug is free", async () => {
62
62
  await expect(
63
- addDefaultDrive(module.client, workflows("workflows-a"), PORT, logger),
63
+ ensureDrive(module.client, workflows("workflows-a"), PORT, logger),
64
64
  ).resolves.toBe(`http://localhost:${PORT}/d/workflows-a`);
65
65
  await expect(module.client.resolveIdOrSlug("workflows")).resolves.toBe(
66
66
  "workflows-a",
@@ -69,14 +69,9 @@ describe("addDefaultDrive with a slug another document holds", () => {
69
69
 
70
70
  // A project moved to another folder hashes its drive ids anew.
71
71
  it("serves the drive that holds the slug instead of creating a twin", async () => {
72
- await addDefaultDrive(
73
- module.client,
74
- workflows("workflows-a"),
75
- PORT,
76
- logger,
77
- );
72
+ await ensureDrive(module.client, workflows("workflows-a"), PORT, logger);
78
73
  await expect(
79
- addDefaultDrive(module.client, workflows("workflows-b"), PORT, logger),
74
+ ensureDrive(module.client, workflows("workflows-b"), PORT, logger),
80
75
  ).resolves.toBe(`http://localhost:${PORT}/d/workflows-a`);
81
76
  expect(await isCreated("workflows-b")).toBe(false);
82
77
  expect(logger.error).not.toHaveBeenCalled();
@@ -91,7 +86,7 @@ describe("addDefaultDrive with a slug another document holds", () => {
91
86
  await module.client.create(other);
92
87
 
93
88
  await expect(
94
- addDefaultDrive(module.client, workflows("workflows-c"), PORT, logger),
89
+ ensureDrive(module.client, workflows("workflows-c"), PORT, logger),
95
90
  ).resolves.toBeUndefined();
96
91
  expect(await isCreated("workflows-c")).toBe(false);
97
92
  expect(logger.error).toHaveBeenCalledWith(
@@ -26,7 +26,8 @@ function stubLogger(): ILogger {
26
26
  }
27
27
 
28
28
  /**
29
- * Boots with FEATURE_PLUGIN_HOST_ENABLED=1, sandboxing the env exactly like
29
+ * Boots a declared composition (every built-in plugin unless the override
30
+ * passes its own), sandboxing the env exactly like
30
31
  * boot-mcp-enabled.test.ts: temp PH_REACTOR_DATABASE_URL, MCP_ENABLED cleared
31
32
  * so it never leaks into the plugin-host composition under test, and every
32
33
  * touched env var restored in `finally`. Workflows stay off by default here
@@ -41,15 +42,10 @@ async function withPluginHostSwitchboard(
41
42
  const tempRoot = await mkdtemp(
42
43
  join(tmpdir(), "switchboard-plugin-presence-"),
43
44
  );
44
- const names = [
45
- "PH_REACTOR_DATABASE_URL",
46
- "MCP_ENABLED",
47
- "FEATURE_PLUGIN_HOST_ENABLED",
48
- ];
45
+ const names = ["PH_REACTOR_DATABASE_URL", "MCP_ENABLED"];
49
46
  const previous = names.map((name) => [name, process.env[name]] as const);
50
47
  process.env.PH_REACTOR_DATABASE_URL = join(tempRoot, "reactor-storage");
51
48
  delete process.env.MCP_ENABLED;
52
- process.env.FEATURE_PLUGIN_HOST_ENABLED = "1";
53
49
  let switchboard: Awaited<ReturnType<typeof startSwitchboard>> | undefined;
54
50
 
55
51
  try {
@@ -65,7 +61,11 @@ async function withPluginHostSwitchboard(
65
61
  global: { name: "Default Drive" },
66
62
  },
67
63
  },
68
- { logger: stubLogger(), ...override.deps },
64
+ {
65
+ logger: stubLogger(),
66
+ pluginComposition: builtinSwitchboardPlugins(),
67
+ ...override.deps,
68
+ },
69
69
  );
70
70
  await run(switchboard);
71
71
  await switchboard.shutdown();
@@ -104,8 +104,8 @@ async function getReservation(port: number): Promise<number> {
104
104
  return response.status;
105
105
  }
106
106
 
107
- describe("plugin-host composition presence (FEATURE_PLUGIN_HOST_ENABLED)", () => {
108
- it("NO composition passed (every built-in): mcp mounted, attachments present", async () => {
107
+ describe("plugin-host composition presence (a declared composition)", () => {
108
+ it("every built-in plugin: mcp mounted, attachments present", async () => {
109
109
  await withPluginHostSwitchboard({}, async (switchboard) => {
110
110
  expect(switchboard.mcpEnabled).toBe(true);
111
111
  expect(await postMcp(switchboard.port)).not.toBe(404);
@@ -123,7 +123,7 @@ describe("plugin-host composition presence (FEATURE_PLUGIN_HOST_ENABLED)", () =>
123
123
  );
124
124
  }, 60_000);
125
125
 
126
- // Presence is activation (R2.6c fix): flag-on, startSwitchboard skips the
126
+ // Presence is activation (R2.6c fix): declared, startSwitchboard skips the
127
127
  // classic mcp/workflows resolvers and initServer normalizes unset values to
128
128
  // OFF after transformServerOptions — an absent plugin actually deactivates
129
129
  // its subsystem.
@@ -153,7 +153,7 @@ describe("plugin-host composition presence (FEATURE_PLUGIN_HOST_ENABLED)", () =>
153
153
  );
154
154
  }, 60_000);
155
155
 
156
- it("an explicit mcp: false option still wins when no composition is passed", async () => {
156
+ it("an explicit mcp: false option still wins over the mcp plugin", async () => {
157
157
  await withPluginHostSwitchboard(
158
158
  { config: { features: { mcp: false } } },
159
159
  async (switchboard) => {
@@ -165,10 +165,9 @@ describe("plugin-host composition presence (FEATURE_PLUGIN_HOST_ENABLED)", () =>
165
165
  });
166
166
 
167
167
  describe("plugin-host workflows presence (transformServerOptions)", () => {
168
- // A real boot's workflows.enabled is resolved classically (env/config,
169
- // default OFF) in startSwitchboard BEFORE the plugin host is even
170
- // constructed (server.mts resolveWorkflowsEnabled ~line 1545, pluginHost
171
- // gate at ~line 407) — by the time the workflows plugin's
168
+ // A boot without a declared composition resolves workflows.enabled
169
+ // classically (env, default OFF) in startSwitchboard BEFORE the plugin host
170
+ // is even constructed — by the time the workflows plugin's
172
171
  // transformServerOptions hook runs, options.workflows.enabled is already a
173
172
  // definite boolean, so its "unless explicit false" short-circuit can never
174
173
  // observe an "unset" value through that path. Exercising the hook directly
@@ -1 +0,0 @@
1
- {"version":3,"file":"from-env-DKK_wPrO.mjs","sources":["../src/attachments/url-signer.ts","../src/inspection-throttle.mts","../src/pglite-version.ts","../src/plugin-host-flag.mts","../src/unsupported-stored-documents.mts","../src/config/drive-type.ts","../src/config/from-env.ts"],"sourcesContent":["import type { AttachmentHash } from \"@powerhousedao/reactor\";\nimport { createHmac, randomBytes, timingSafeEqual } from \"node:crypto\";\n\nexport const ATTACHMENT_URL_SIGNING_SECRET_ENV =\n \"PH_ATTACHMENT_URL_SIGNING_SECRET\";\n\nconst MIN_SECRET_LENGTH = 32;\nconst EXPIRES_PATTERN = /^[1-9]\\d{0,15}$/;\nconst SIGNATURE_PATTERN = /^[A-Za-z0-9_-]{43}$/;\n\nexport type SignedAttachmentUrl = {\n query: string;\n expiresAtUtc: string;\n};\n\n// The filesystem counterpart of an S3 presigned GET.\nexport class AttachmentUrlSigner {\n constructor(\n private readonly secret: string | Buffer,\n private readonly now: () => number = Date.now,\n ) {}\n\n sign(\n hash: AttachmentHash,\n documentId: string,\n ttlSeconds: number,\n ): SignedAttachmentUrl {\n const expires = Math.floor(this.now() / 1000) + ttlSeconds;\n const params = new URLSearchParams({\n documentId,\n expires: String(expires),\n signature: this.mac(hash, documentId, String(expires)),\n });\n return {\n query: params.toString(),\n expiresAtUtc: new Date(expires * 1000).toISOString(),\n };\n }\n\n verify(\n hash: AttachmentHash,\n documentId: string,\n expires: string,\n signature: string,\n ): boolean {\n if (!EXPIRES_PATTERN.test(expires) || !SIGNATURE_PATTERN.test(signature)) {\n return false;\n }\n if (Number(expires) * 1000 <= this.now()) {\n return false;\n }\n const expected = Buffer.from(this.mac(hash, documentId, expires));\n const presented = Buffer.from(signature);\n return (\n expected.length === presented.length &&\n timingSafeEqual(expected, presented)\n );\n }\n\n private mac(hash: string, documentId: string, expires: string): string {\n return createHmac(\"sha256\", this.secret)\n .update(\n JSON.stringify([\"attachment-download/v1\", hash, documentId, expires]),\n )\n .digest(\"base64url\");\n }\n}\n\nexport type AttachmentUrlSigning =\n | { status: \"configured\"; signer: AttachmentUrlSigner }\n | { status: \"ephemeral\"; signer: AttachmentUrlSigner }\n | { status: \"unconfigured\" };\n\n// Unset: production fails closed, anything else gets a per-process secret.\nexport function resolveAttachmentUrlSigning(\n env: Readonly<Record<string, string | undefined>>,\n): AttachmentUrlSigning {\n const secret = env[ATTACHMENT_URL_SIGNING_SECRET_ENV];\n if (secret !== undefined) {\n if (secret.trim() !== secret || secret.length < MIN_SECRET_LENGTH) {\n throw new Error(\n `${ATTACHMENT_URL_SIGNING_SECRET_ENV} must be at least ${MIN_SECRET_LENGTH} characters with no leading or trailing whitespace`,\n );\n }\n return { status: \"configured\", signer: new AttachmentUrlSigner(secret) };\n }\n if (env.NODE_ENV === \"production\") {\n return { status: \"unconfigured\" };\n }\n return {\n status: \"ephemeral\",\n signer: new AttachmentUrlSigner(randomBytes(32)),\n };\n}\n","import type { InspectionThrottleConfig } from \"@powerhousedao/reactor-api\";\nimport { parseNonNegativeInt } from \"./env.mjs\";\n\nconst NAME = \"PH_INSPECTION_CALLS_PER_MINUTE\";\n\n/** Unset keeps reactor-api's default; an invalid value fails boot. */\nexport function inspectionThrottleFromEnv(\n env: NodeJS.ProcessEnv,\n): Partial<InspectionThrottleConfig> {\n const callsPerMinute = parseNonNegativeInt(env[NAME], NAME);\n if (callsPerMinute === undefined) {\n return {};\n }\n if (callsPerMinute < 1) {\n throw new Error(`${NAME} must be at least 1, got \"${env[NAME]}\"`);\n }\n return { callsPerMinute };\n}\n","import type * as CurrentPGliteModuleNs from \"@electric-sql/pglite\";\nimport type {\n NodeFsClass,\n PGliteModuleSpec,\n VerifyHandle,\n} from \"@powerhousedao/reactor-api/pglite-node\";\nimport { promises as fs } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nexport const CURRENT_PG_MAJOR = 17;\nexport const SUPPORTED_PG_MAJORS = [16, 17] as const;\nexport type SupportedPgMajor = (typeof SUPPORTED_PG_MAJORS)[number];\n\ntype CurrentPGliteModule = typeof CurrentPGliteModuleNs;\n\nexport async function readPgVersionFile(\n dataDir: string,\n): Promise<number | null> {\n try {\n const raw = await fs.readFile(path.join(dataDir, \"PG_VERSION\"), \"utf8\");\n const major = parseInt(raw.trim(), 10);\n return Number.isFinite(major) ? major : null;\n } catch {\n return null;\n }\n}\n\nexport function isSupportedMajor(major: number): major is SupportedPgMajor {\n return (SUPPORTED_PG_MAJORS as readonly number[]).includes(major);\n}\n\n/**\n * Parses the `PH_FORCE_PG_VERSION` env var. Returns the validated major, or\n * `null` when the var is unset/empty. Throws on any value that is not a\n * supported major — invalid configuration must fail before the server starts\n * touching disk.\n */\nexport function parseForcePgVersion(\n raw: string | undefined,\n): SupportedPgMajor | null {\n if (raw === undefined || raw.trim() === \"\") return null;\n const parsed = Number(raw);\n if (Number.isInteger(parsed) && isSupportedMajor(parsed)) return parsed;\n throw new Error(\n `PH_FORCE_PG_VERSION must be one of: ${SUPPORTED_PG_MAJORS.join(\", \")} (got: ${raw})`,\n );\n}\n\nexport async function loadPGliteModule(\n major: SupportedPgMajor,\n): Promise<CurrentPGliteModule> {\n if (major === 16) {\n return (await import(\"pglite-legacy-02\")) as unknown as CurrentPGliteModule;\n }\n return import(\"@electric-sql/pglite\");\n}\n\n/**\n * Where a PGlite worker imports the module that opens `major` dirs from,\n * resolved here because the worker's own package cannot see the\n * `pglite-legacy-02` alias.\n */\nexport function pgliteModuleSpec(major: SupportedPgMajor): PGliteModuleSpec {\n const base = major === 16 ? \"pglite-legacy-02\" : \"@electric-sql/pglite\";\n return {\n pglite: resolveModuleUrl(base),\n nodefs: resolveModuleUrl(`${base}/nodefs`),\n };\n}\n\nfunction resolveModuleUrl(specifier: string): string {\n try {\n return import.meta.resolve(specifier);\n } catch {\n return pathToFileURL(createRequire(import.meta.url).resolve(specifier))\n .href;\n }\n}\n\n/** The stock NodeFS class of the PGlite module that opens `major` dirs. */\nexport async function loadNodeFsClass(\n major: SupportedPgMajor,\n): Promise<NodeFsClass> {\n if (major === 16) {\n const mod = await import(\"pglite-legacy-02/nodefs\");\n return mod.NodeFS as unknown as NodeFsClass;\n }\n const mod = await import(\"@electric-sql/pglite/nodefs\");\n return mod.NodeFS;\n}\n\n/** Opens a converted dir over stock NodeFS so the conversion can check it. */\nexport async function openForVerify(\n major: number,\n dataDir: string,\n): Promise<VerifyHandle> {\n if (!isSupportedMajor(major)) {\n throw new Error(\n `Cannot verify PGlite data dir ${dataDir}: PG_VERSION=${major} is not supported (expected one of ${SUPPORTED_PG_MAJORS.join(\", \")})`,\n );\n }\n const [{ PGlite }, NodeFS] = await Promise.all([\n loadPGliteModule(major),\n loadNodeFsClass(major),\n ]);\n const pg = new PGlite({ fs: new NodeFS(dataDir) });\n await pg.waitReady;\n return pg;\n}\n\ntype PgDumpFn = (options: {\n pg: unknown;\n}) => Promise<{ text(): Promise<string> }>;\n\nexport async function loadPgDump(major: SupportedPgMajor): Promise<PgDumpFn> {\n if (major === 16) {\n const mod = (await import(\"pglite-tools-legacy-02/pg_dump\")) as {\n pgDump: PgDumpFn;\n };\n return mod.pgDump;\n }\n const mod = (await import(\"@electric-sql/pglite-tools/pg_dump\")) as {\n pgDump: PgDumpFn;\n };\n return mod.pgDump;\n}\n","export const PLUGIN_HOST_FLAG = \"FEATURE_PLUGIN_HOST_ENABLED\";\n\nexport function isPluginHostEnabled(\n env: Record<string, string | undefined>,\n): boolean {\n const value = env[PLUGIN_HOST_FLAG]?.trim().toLowerCase();\n return value === \"1\" || value === \"true\";\n}\n\n/** The values that ask for the deprecated inline boot, the ones the\n * deprecation warning names (shared/clis FALSE_VALUES). */\nconst INLINE_BOOT_VALUES: ReadonlySet<string> = new Set([\n \"false\",\n \"0\",\n \"off\",\n \"no\",\n]);\n\n/** What the variable asks for: true the declared composition, false the\n * deprecated inline boot. Blank or any other value asks for nothing, and the\n * default composition boots. */\nexport function pluginHostFromEnv(\n env: Record<string, string | undefined>,\n): boolean | undefined {\n if (isPluginHostEnabled(env)) return true;\n const value = env[PLUGIN_HOST_FLAG]?.trim().toLowerCase();\n return value !== undefined && INLINE_BOOT_VALUES.has(value)\n ? false\n : undefined;\n}\n","import {\n storedRefusalName,\n type StoredProtocolRefusal,\n type UnsupportedStoredDocuments,\n type UnsupportedStoredProtocolError,\n} from \"@powerhousedao/reactor\";\n\nconst MODES: readonly UnsupportedStoredDocuments[] = [\"refuse\", \"read-only\"];\n\n/** From REACTOR_UNSUPPORTED_STORED_DOCUMENTS; `input` wins when defined. */\nexport function resolveUnsupportedStoredDocuments(\n input: UnsupportedStoredDocuments | undefined,\n env: NodeJS.ProcessEnv,\n): UnsupportedStoredDocuments {\n if (input !== undefined) return input;\n const raw = env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS?.trim();\n if (!raw) return \"refuse\";\n if (!(MODES as readonly string[]).includes(raw)) {\n throw new Error(\n `REACTOR_UNSUPPORTED_STORED_DOCUMENTS must be \"refuse\" or \"read-only\", got \"${raw}\"`,\n );\n }\n return raw as UnsupportedStoredDocuments;\n}\n\n/** The reactor refused to start over documents this build does not run. */\nexport class StoredDocumentsRefusedError extends Error {\n readonly versions: readonly StoredProtocolRefusal[];\n readonly documents: number;\n\n constructor(cause: UnsupportedStoredProtocolError) {\n const named = cause.versions.map(storedRefusalName).join(\", \");\n super(\n `Refusing to start: ${cause.documents} stored document(s) require ${named}, which this switchboard does not run. ` +\n `Either start a switchboard build that runs ${named}, or set REACTOR_UNSUPPORTED_STORED_DOCUMENTS=read-only to start with those documents read-only.`,\n { cause },\n );\n this.name = \"StoredDocumentsRefusedError\";\n this.versions = cause.versions;\n this.documents = cause.documents;\n }\n\n static override isError(\n error: unknown,\n ): error is StoredDocumentsRefusedError {\n return Error.isError(error) && error.name === \"StoredDocumentsRefusedError\";\n }\n}\n","import type { SwitchboardDriveDocumentType } from \"../types.js\";\n\n/** `PH_DEFAULT_DRIVE_TYPE`: the default drive's container type. */\nexport function parseDriveType(\n raw: string | undefined,\n): SwitchboardDriveDocumentType | undefined {\n if (!raw) return undefined;\n if (raw === \"powerhouse/document-drive\" || raw === \"powerhouse/reactor-drive\")\n return raw;\n throw new Error(\n `Invalid PH_DEFAULT_DRIVE_TYPE: ${raw}. Expected \"powerhouse/document-drive\" or \"powerhouse/reactor-drive\".`,\n );\n}\n","import {\n isProcessorTimingLevel,\n parseCatchUpPriority,\n parseKeyframeSettings,\n parseMemoryTelemetryOutputs,\n parseMemoryTelemetrySwitch,\n type MemoryTelemetryOutput,\n type ProcessorTimingLevel,\n} from \"@powerhousedao/reactor\";\nimport {\n type HostValidationMode,\n reactorApiConfigFromEnv,\n resolveRenownConfig,\n} from \"@powerhousedao/reactor-api\";\nimport { resolvePgliteMaintenance } from \"@powerhousedao/reactor-api/pglite-node\";\nimport { resolvePgliteWorkerMemoryMb } from \"@powerhousedao/reactor-api/pglite-node\";\nimport { isSignaturePolicy } from \"@powerhousedao/shared/document-model\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport {\n ATTACHMENT_URL_SIGNING_SECRET_ENV,\n resolveAttachmentUrlSigning,\n} from \"../attachments/url-signer.js\";\nimport { parseNonNegativeInt } from \"../env.mjs\";\nimport { inspectionThrottleFromEnv } from \"../inspection-throttle.mjs\";\nimport { parseForcePgVersion } from \"../pglite-version.js\";\nimport { pluginHostFromEnv } from \"../plugin-host-flag.mjs\";\nimport { isPostgresUrl } from \"../postgres-url.mjs\";\nimport { privacyTimingsFromEnv } from \"../privacy.mjs\";\nimport { parseOnOff } from \"../projection-worker.mjs\";\nimport { resolveUnsupportedStoredDocuments } from \"../unsupported-stored-documents.mjs\";\nimport { parseWorkerCount, resolveHostPoolSize } from \"../worker-pool.mjs\";\nimport { parseDriveType } from \"./drive-type.js\";\nimport {\n SWITCHBOARD_LOG_LEVELS,\n type SwitchboardConfigInput,\n} from \"./schema.js\";\n\ntype Env = Readonly<Record<string, string | undefined>>;\ntype Logger = ILogger;\n\nexport interface SwitchboardConfigFromEnvOptions {\n /** The bin's own keys (sb/config.ts) instead of PORT. */\n bin?: boolean;\n logger?: Logger;\n}\n\n/** Only the keys the env sets; today's boot errors throw with their messages. */\nexport function switchboardConfigFromEnv(\n env: Env,\n options: SwitchboardConfigFromEnvOptions = {},\n): SwitchboardConfigInput {\n const logger = options.logger ?? childLogger([\"switchboard\", \"config\"]);\n const api = reactorApiConfigFromEnv(env, logger);\n const reactorUrl = urlFromEnv(\n env.PH_REACTOR_DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL,\n );\n const executorCount = parseWorkerCount(env.REACTOR_WORKERS);\n const executorOn = executorCount === \"auto\" || (executorCount ?? 0) > 0;\n const projectionOn = parseOnOff(env.REACTOR_PROJECTION_WORKER);\n const privacyOn = flag(env.PH_PRIVACY_ENABLED);\n const pgliteWorkers = openFeatureFlag(env.PH_PGLITE_WORKERS);\n const telemetryOff = telemetrySwitchFromEnv(env, logger) === false;\n\n return withoutUnset({\n logLevel: logLevelFromEnv(env.LOG_LEVEL, logger),\n server: {\n ...api.server,\n port: options.bin\n ? binPortFromEnv(env.PH_SWITCHBOARD_PORT)\n : portFromEnv(env.PORT, logger),\n },\n storage: {\n reactor: { url: reactorUrl },\n readModel: {\n url: urlFromEnv(env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL),\n },\n inMemory:\n env.PH_PGLITE_IN_MEMORY === undefined\n ? undefined\n : env.PH_PGLITE_IN_MEMORY === \"1\",\n userDataDir: env.PH_USER_DATA_DIR || undefined,\n pglite: {\n fsync:\n env.PH_PGLITE_FSYNC === undefined\n ? undefined\n : env.PH_PGLITE_FSYNC !== \"0\",\n workers: pgliteWorkers,\n workerMemoryMb: gated(pgliteWorkers !== false, () =>\n isBlank(env.PH_PGLITE_WORKER_MEMORY_MB)\n ? undefined\n : resolvePgliteWorkerMemoryMb(env),\n ),\n vacuumFull: vacuumFullFromEnv(env),\n },\n migratePglite: options.bin ? flag(env.PH_MIGRATE_PGLITE) : undefined,\n forcePgVersion: options.bin\n ? (parseForcePgVersion(env.PH_FORCE_PG_VERSION) ?? undefined)\n : undefined,\n keyframes: keyframesFromEnv(env.PH_KEYFRAMES),\n },\n protocol: {\n featureFlags: {\n documentDecisions: flag(env.REACTOR_DOCUMENT_DECISIONS),\n authEnforcement: flag(env.REACTOR_AUTH_ENFORCEMENT),\n authGroups: flag(env.REACTOR_AUTH_GROUPS),\n authConditions: flag(env.REACTOR_AUTH_CONDITIONS),\n undoV3:\n env.REACTOR_UNDO_V3 === undefined\n ? undefined\n : env.REACTOR_UNDO_V3 !== \"false\",\n },\n createSignaturePolicy: createSignaturePolicyFromEnv(\n env.CREATE_SIGNATURE_POLICY,\n ),\n unsupportedStoredDocuments:\n env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS?.trim()\n ? resolveUnsupportedStoredDocuments(undefined, env)\n : undefined,\n legacyProcessorIds:\n env.REACTOR_LEGACY_PROCESSOR_IDS === undefined\n ? undefined\n : env.REACTOR_LEGACY_PROCESSOR_IDS !== \"false\",\n maxSkipThreshold: maxSkipThresholdFromEnv(env.MAX_SKIP_THRESHOLD),\n catchUpPriority: catchUpPriorityFromEnv(env.PH_CATCH_UP_PRIORITY, logger),\n processorTiming: telemetryOff\n ? \"off\"\n : processorTimingFromEnv(env.PH_PROCESSOR_TIMING, logger),\n processorTimingWindowMs: positiveIntFromEnv(\n env,\n \"PH_PROCESSOR_TIMING_WINDOW_MS\",\n logger,\n ),\n processorSlowBatchMs: positiveIntFromEnv(\n env,\n \"PH_PROCESSOR_SLOW_BATCH_MS\",\n logger,\n ),\n processorTimingLogMs: positiveIntFromEnv(\n env,\n \"PH_PROCESSOR_TIMING_LOG_MS\",\n logger,\n ),\n },\n telemetry: {\n memory: memoryTelemetryFromEnv(env, telemetryOff, logger),\n dir: blankAsUnset(env.PH_TELEMETRY_DIR),\n heapSnapshotDir: blankAsUnset(env.PH_HEAP_SNAPSHOT_DIR),\n },\n auth: {\n ...api.auth,\n renown: {\n source: renownSourceFromEnv(env, logger),\n url: blankAsUnset(env.RENOWN_URL),\n switchboardUrl: blankAsUnset(env.SWITCHBOARD_URL),\n },\n },\n inspection: {\n ...api.inspection,\n enabled: openFeatureFlag(env.INSPECTION_ENABLED),\n callsPerMinute: inspectionThrottleFromEnv(env).callsPerMinute,\n },\n workers: {\n executor: {\n count: executorCount,\n poolSize: gated(executorOn, () =>\n parseNonNegativeInt(\n env.REACTOR_DB_POOL_SIZE_WORKER,\n \"REACTOR_DB_POOL_SIZE_WORKER\",\n ),\n ),\n acquireTimeoutMs: gated(executorOn, () =>\n parseNonNegativeInt(\n env.REACTOR_DB_ACQUIRE_TIMEOUT_MS,\n \"REACTOR_DB_ACQUIRE_TIMEOUT_MS\",\n ),\n ),\n },\n hostPoolSize: gated(\n reactorUrl !== undefined && isPostgresUrl(reactorUrl),\n () =>\n isBlank(env.REACTOR_DB_POOL_SIZE_HOST)\n ? undefined\n : resolveHostPoolSize(env as NodeJS.ProcessEnv),\n ),\n projection: {\n enabled: projectionOn,\n poolSize: gated(projectionOn === true, () =>\n projectionPoolSizeFromEnv(env.REACTOR_DB_POOL_SIZE_PROJECTION),\n ),\n },\n },\n packages: {\n registryUrl: env.PH_REGISTRY_URL,\n registryPackages: env.PH_REGISTRY_PACKAGES?.split(\",\").map((p) =>\n p.trim(),\n ),\n dynamic: flag(env.DYNAMIC_MODEL_LOADING),\n hostValidation: hostValidationFromEnv(env.PH_HOST_VALIDATION),\n },\n features: {\n mcp: openFeatureFlag(env.MCP_ENABLED),\n workflows: workflowsFromEnv(env.PH_WORKFLOWS_ENABLED),\n documentModelSubgraphs: openFeatureFlag(\n env.DOCUMENT_MODEL_SUBGRAPHS_ENABLED,\n ),\n pluginHost: pluginHostFromEnv(env),\n privacy: {\n enabled: privacyOn,\n deploymentSecret: env.PH_PRIVACY_DEPLOYMENT_SECRET,\n ...gated(privacyOn === true, () =>\n privacyTimingsFromEnv(env as NodeJS.ProcessEnv),\n ),\n },\n },\n attachments: {\n ...api.attachments,\n urlSigningSecret: urlSigningSecretFromEnv(env),\n downloadTargetMaxTtlSeconds: downloadTargetTtlFromEnv(\n env.ATTACHMENT_DOWNLOAD_TARGET_MAX_TTL_SECONDS,\n logger,\n ),\n serviceUrl: env.PH_SWITCHBOARD_PUBLIC_URL,\n },\n drive: options.bin\n ? { documentType: parseDriveType(env.PH_DEFAULT_DRIVE_TYPE) }\n : undefined,\n }) as SwitchboardConfigInput;\n}\n\nfunction flag(raw: string | undefined): boolean | undefined {\n return raw === undefined ? undefined : raw === \"true\";\n}\n\n// As OpenFeature's EnvVarProvider reads a boolean.\nfunction openFeatureFlag(raw: string | undefined): boolean | undefined {\n if (raw === \"true\") return true;\n if (raw === \"false\") return false;\n return undefined;\n}\n\nfunction blankAsUnset(raw: string | undefined): string | undefined {\n const trimmed = raw?.trim();\n return trimmed ? trimmed : undefined;\n}\n\n// A set but invalid RENOWN_SOURCE still overrides the config file, as \"remote\".\nfunction renownSourceFromEnv(\n env: Env,\n logger: Logger,\n): \"self\" | \"remote\" | \"kept\" | undefined {\n if (blankAsUnset(env.RENOWN_SOURCE) === undefined) return undefined;\n return resolveRenownConfig(undefined, env, logger).source;\n}\n\nfunction isBlank(raw: string | undefined): boolean {\n return raw === undefined || raw.trim() === \"\";\n}\n\n// \"\" names no store: the server falls back to the default dir for it.\nfunction urlFromEnv(raw: string | undefined): string | undefined {\n return raw ? raw : undefined;\n}\n\n// Today these throw only once their feature is on; off, a bad value is dropped.\nfunction gated<T>(on: boolean, parse: () => T): T | undefined {\n if (on) return parse();\n try {\n return parse();\n } catch {\n return undefined;\n }\n}\n\nfunction logLevelFromEnv(\n raw: string | undefined,\n logger: Logger,\n): (typeof SWITCHBOARD_LOG_LEVELS)[number] | undefined {\n if (!raw) return undefined;\n if ((SWITCHBOARD_LOG_LEVELS as readonly string[]).includes(raw)) {\n return raw as (typeof SWITCHBOARD_LOG_LEVELS)[number];\n }\n logger.warn(\n `Ignoring invalid LOG_LEVEL=\"${raw}\" (expected one of ${SWITCHBOARD_LOG_LEVELS.join(\", \")}); using info`,\n );\n return undefined;\n}\n\n// Most edges pass a port of their own, so a bad PORT must not fail their boot.\nfunction portFromEnv(\n raw: string | undefined,\n logger: Logger,\n): number | undefined {\n if (!raw) return undefined;\n const port = Number(raw);\n if (Number.isInteger(port) && port >= 0 && port <= 65535) return port;\n logger.warn(`Ignoring invalid PORT=\"${raw}\" (expected a port number)`);\n return undefined;\n}\n\n// Not a number falls through to the config file, as the bin's own config does.\nfunction binPortFromEnv(raw: string | undefined): number | undefined {\n return raw && !isNaN(Number(raw)) ? Number(raw) : undefined;\n}\n\n// A malformed value stops the boot: running on with the defaults would keep\n// writing keyframes the operator asked to bound.\nfunction keyframesFromEnv(raw: string | undefined) {\n if (isBlank(raw)) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw as string);\n } catch (error) {\n throw new Error(\n `PH_KEYFRAMES is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n return parseKeyframeSettings(parsed, \"PH_KEYFRAMES\");\n}\n\nfunction vacuumFullFromEnv(env: Env) {\n // Throws on an unknown mode, with today's message.\n resolvePgliteMaintenance(env);\n const mode = env.PH_PGLITE_VACUUM_FULL?.trim().toLowerCase() || undefined;\n return {\n mode: mode as \"off\" | \"quiet\" | \"forced\" | undefined,\n aboveMb: nonNegativeNumber(env.PH_PGLITE_VACUUM_FULL_ABOVE_MB),\n quietMs: nonNegativeNumber(env.PH_PGLITE_VACUUM_FULL_QUIET_MS),\n maxDeferMs: nonNegativeNumber(env.PH_PGLITE_VACUUM_FULL_MAX_DEFER_MS),\n };\n}\n\n// Anything else is ignored, as resolvePgliteMaintenance ignores it.\nfunction nonNegativeNumber(raw: string | undefined): number | undefined {\n if (isBlank(raw)) return undefined;\n const parsed = Number(raw);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;\n}\n\nfunction createSignaturePolicyFromEnv(\n value: string | undefined,\n): \"legacy\" | \"v2-required\" | undefined {\n const raw = value?.trim();\n if (!raw) return undefined;\n if (!isSignaturePolicy(raw)) {\n throw new Error(\n `CREATE_SIGNATURE_POLICY must be \"legacy\" or \"v2-required\", got \"${raw}\"`,\n );\n }\n return raw;\n}\n\nfunction hostValidationFromEnv(\n value: string | undefined,\n): HostValidationMode | undefined {\n const raw = value?.trim();\n if (!raw) return undefined;\n if (raw !== \"log\" && raw !== \"refuse\") {\n throw new Error(\n `PH_HOST_VALIDATION must be \"log\" or \"refuse\", got \"${raw}\"`,\n );\n }\n return raw;\n}\n\nfunction maxSkipThresholdFromEnv(raw: string | undefined): number | undefined {\n const parsed = parseInt(raw ?? \"\", 10);\n return !isNaN(parsed) && parsed > 0 ? parsed : undefined;\n}\n\nfunction catchUpPriorityFromEnv(\n raw: string | undefined,\n logger: Logger,\n): \"dynamic\" | number | undefined {\n if (raw === undefined) return undefined;\n const setting = parseCatchUpPriority(raw);\n if (setting?.mode === \"fixed\") return setting.level;\n if (setting) return \"dynamic\";\n logger.warn(\n `PH_CATCH_UP_PRIORITY=${JSON.stringify(raw)} is neither dynamic nor a level 0-7; using dynamic`,\n );\n return undefined;\n}\n\n// PH_TELEMETRY=off is the umbrella: it wins over both specific switches.\nfunction telemetrySwitchFromEnv(env: Env, logger: Logger): boolean | undefined {\n const raw = env.PH_TELEMETRY;\n if (raw === undefined) return undefined;\n const value = parseMemoryTelemetrySwitch(raw);\n if (value === undefined) {\n logger.warn(`PH_TELEMETRY=${JSON.stringify(raw)} is neither on nor off`);\n }\n return value;\n}\n\nfunction processorTimingFromEnv(\n raw: string | undefined,\n logger: Logger,\n): ProcessorTimingLevel | undefined {\n if (raw === undefined) return undefined;\n if (isProcessorTimingLevel(raw)) return raw;\n logger.warn(\n `PH_PROCESSOR_TIMING=${JSON.stringify(raw)} is none of off, basic, detailed; using the default`,\n );\n return undefined;\n}\n\nfunction positiveIntFromEnv(\n env: Env,\n name: string,\n logger: Logger,\n): number | undefined {\n const raw = env[name];\n if (raw === undefined) return undefined;\n const value = Number(raw.trim() || Number.NaN);\n if (Number.isInteger(value) && value > 0) return value;\n logger.warn(`${name}=${JSON.stringify(raw)} is not a positive integer`);\n return undefined;\n}\n\nfunction memoryOutputsFromEnv(\n env: Env,\n logger: Logger,\n): MemoryTelemetryOutput[] | undefined {\n const raw = env.PH_MEMORY_TELEMETRY_OUTPUT;\n let outputs: MemoryTelemetryOutput[] | undefined;\n if (raw !== undefined) {\n outputs = parseMemoryTelemetryOutputs(raw);\n if (!outputs) {\n logger.warn(\n `PH_MEMORY_TELEMETRY_OUTPUT=${JSON.stringify(raw)} lists an output other than memory, file, console; using the default`,\n );\n }\n }\n // A file path implies the file output.\n if (env.PH_MEMORY_TELEMETRY_FILE?.trim() && outputs) {\n return outputs.includes(\"file\") ? outputs : [...outputs, \"file\"];\n }\n return outputs;\n}\n\nfunction memoryTelemetryFromEnv(env: Env, off: boolean, logger: Logger) {\n const raw = env.PH_MEMORY_TELEMETRY;\n let enabled = raw === undefined ? undefined : parseMemoryTelemetrySwitch(raw);\n if (raw !== undefined && enabled === undefined) {\n logger.warn(\n `PH_MEMORY_TELEMETRY=${JSON.stringify(raw)} is neither on nor off; leaving it off`,\n );\n }\n if (off) enabled = false;\n const consoleOn = env.PH_MEMORY_TELEMETRY_CONSOLE?.trim() !== \"false\";\n const outputs = memoryOutputsFromEnv(env, logger);\n return {\n enabled,\n intervalMs: positiveIntFromEnv(\n env,\n \"PH_MEMORY_TELEMETRY_INTERVAL_MS\",\n logger,\n ),\n outputs: consoleOn ? outputs : outputs?.filter((o) => o !== \"console\"),\n file: {\n path: blankAsUnset(env.PH_MEMORY_TELEMETRY_FILE),\n maxMb: positiveIntFromEnv(env, \"PH_MEMORY_TELEMETRY_FILE_MAX_MB\", logger),\n keep: positiveIntFromEnv(env, \"PH_MEMORY_TELEMETRY_FILE_KEEP\", logger),\n },\n ringSize: positiveIntFromEnv(env, \"PH_MEMORY_TELEMETRY_RING\", logger),\n consoleIntervalMs: positiveIntFromEnv(\n env,\n \"PH_MEMORY_TELEMETRY_CONSOLE_INTERVAL_MS\",\n logger,\n ),\n workers:\n env.PH_MEMORY_TELEMETRY_WORKERS === undefined\n ? undefined\n : env.PH_MEMORY_TELEMETRY_WORKERS.trim() !== \"false\",\n windowMin: positiveIntFromEnv(\n env,\n \"PH_MEMORY_TELEMETRY_WINDOW_MIN\",\n logger,\n ),\n };\n}\n\nfunction projectionPoolSizeFromEnv(raw: string | undefined) {\n const poolSize = parseNonNegativeInt(raw, \"REACTOR_DB_POOL_SIZE_PROJECTION\");\n if (poolSize !== undefined && poolSize < 1) {\n throw new Error(\n \"REACTOR_DB_POOL_SIZE_PROJECTION must be at least 1; the projection worker cannot run without a pool\",\n );\n }\n return poolSize;\n}\n\n// PH_WORKFLOWS_ENABLED also takes the 1/0 reactor-api took.\nfunction workflowsFromEnv(raw: string | undefined): boolean | undefined {\n const trimmed = raw?.trim();\n if (trimmed === \"1\") return true;\n if (trimmed === \"0\") return false;\n return openFeatureFlag(raw);\n}\n\nfunction urlSigningSecretFromEnv(env: Env): string | undefined {\n const secret = env[ATTACHMENT_URL_SIGNING_SECRET_ENV];\n if (secret === undefined) return undefined;\n // Throws on a short or padded secret, with today's message.\n resolveAttachmentUrlSigning({ [ATTACHMENT_URL_SIGNING_SECRET_ENV]: secret });\n return secret;\n}\n\nfunction downloadTargetTtlFromEnv(\n raw: string | undefined,\n logger: Logger,\n): number | undefined {\n if (raw === undefined) return undefined;\n const parsed = Number(raw);\n if (Number.isInteger(parsed) && parsed > 0) return parsed;\n logger.warn(\n `Ignoring invalid ATTACHMENT_DOWNLOAD_TARGET_MAX_TTL_SECONDS=\"${raw}\" (expected a positive integer number of seconds) — using the default`,\n );\n return undefined;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\n// A layer names only what it sets: no unset keys, no emptied sections.\nfunction withoutUnset(value: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined) continue;\n if (isPlainObject(entry)) {\n const inner = withoutUnset(entry);\n if (Object.keys(inner).length > 0) result[key] = inner;\n continue;\n }\n result[key] = entry;\n }\n return result;\n}\n"],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;AAGA,MAAa,oCACX;AAEF,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAQ1B,IAAa,sBAAb,MAAiC;CAEZ;CACA;CAFnB,YACE,QACA,MAAqC,KAAK,KAC1C;EAFiB,KAAA,SAAA;EACA,KAAA,MAAA;CAChB;CAEH,KACE,MACA,YACA,YACqB;EACrB,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI;EAMhD,OAAO;GACL,OAAO,IANU,gBAAgB;IACjC;IACA,SAAS,OAAO,OAAO;IACvB,WAAW,KAAK,IAAI,MAAM,YAAY,OAAO,OAAO,CAAC;GACvD,CAEc,CAAC,CAAC,SAAS;GACvB,+BAAc,IAAI,KAAK,UAAU,GAAI,EAAA,CAAE,YAAY;EACrD;CACF;CAEA,OACE,MACA,YACA,SACA,WACS;EACT,IAAI,CAAC,gBAAgB,KAAK,OAAO,KAAK,CAAC,kBAAkB,KAAK,SAAS,GACrE,OAAO;EAET,IAAI,OAAO,OAAO,IAAI,OAAQ,KAAK,IAAI,GACrC,OAAO;EAET,MAAM,WAAW,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,OAAO,CAAC;EAChE,MAAM,YAAY,OAAO,KAAK,SAAS;EACvC,OAC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AAK,GAAG;EAChD,IAAI,UAAU,KAAA,GAAW;EACzB,IAAI,cAAc,KAAK,GAAG;GACxB,MAAM,QAAQ,aAAa,KAAK;GAChC,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG,OAAO,OAAO;GACjD;EACF;EACA,OAAO,OAAO;CAChB;CACA,OAAO;AACT","debug_id":"07dc4fe8-4324-5fd8-a39e-c856c27d4537"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-host-tTjDTNz0.d.mts","names":[],"sources":["../src/plugin-host.mts"],"mappings":";;;;;;;;UAgDiB;;;EAGf;EACA,SAAS;;EAET,SAAS;EACT;EACA;;;EAGA;;;EAGA;EACA;;;EAGA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;EACA;EACA;;EAEA,gBAAgB;EAChB,eAAe,eAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-BJ-OFAox.mjs","sources":["../src/config/merge.ts","../src/config/schema.ts"],"sourcesContent":["import type { SwitchboardConfigInput } from \"./schema.js\";\n\ntype Layer = SwitchboardConfigInput;\ntype Section = Record<string, unknown>;\n\n// A union, not a section: its variants do not share keys.\nconst REPLACED_WHOLE = new Set([\"attachments.storage\", \"storage.keyframes\"]);\n\n// The reactor-api auth keys whose env vars override a caller's option.\nconst ENV_WINS_AUTH = [\n \"enabled\",\n \"admins\",\n \"resolveIdentity\",\n \"requireAuthenticatedCaller\",\n \"requireAuthenticatedCallerExemptPaths\",\n \"attachmentReadsFollowDocumentPolicy\",\n] as const;\n\nfunction isPlainObject(value: unknown): value is Section {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nfunction mergeSection(base: Section, over: Section, path: string): Section {\n const result: Section = { ...base };\n for (const [key, value] of Object.entries(over)) {\n if (value === undefined) continue;\n const at = path ? `${path}.${key}` : key;\n const current = result[key];\n result[key] =\n isPlainObject(value) && isPlainObject(current) && !REPLACED_WHOLE.has(at)\n ? mergeSection(current, value, at)\n : value;\n }\n return result;\n}\n\n/** Later layers win per key; arrays, maps and unions are replaced whole. */\nexport function mergeSwitchboardConfig(...layers: Layer[]): Layer {\n let merged: Section = {};\n for (const layer of layers) merged = mergeSection(merged, layer, \"\");\n return merged as Layer;\n}\n\n/** A caller's layer over the env's, keeping each key's pre-config precedence. */\nexport function callerOverEnv(env: Layer, caller: Layer): Layer {\n const merged = mergeSwitchboardConfig(env, caller);\n const features: Section = { ...merged.features };\n const inspection: Section = { ...merged.inspection };\n const auth: Section = { ...merged.auth };\n\n const envAuth: Section = env.auth ?? {};\n for (const key of ENV_WINS_AUTH) {\n if (envAuth[key] !== undefined) auth[key] = envAuth[key];\n }\n // ACCESS and VETRA_GATE_* win one by one, so a caller's gate URL survives an\n // env that only sets the token, and the env's mode is never overridden.\n if (isPlainObject(envAuth.access)) {\n auth.access = mergeSection(\n isPlainObject(auth.access) ? auth.access : {},\n envAuth.access,\n \"auth.access\",\n );\n }\n if (env.features?.documentModelSubgraphs !== undefined) {\n features.documentModelSubgraphs = env.features.documentModelSubgraphs;\n }\n // An environment false switches a capability off whatever the caller or the\n // plugin composition says; a caller's own false still wins over an env true.\n if (env.features?.mcp === false || caller.features?.mcp === false) {\n features.mcp = false;\n }\n if (\n env.inspection?.enabled === false ||\n caller.inspection?.enabled === false\n ) {\n inspection.enabled = false;\n }\n if (env.features?.workflows === false) features.workflows = false;\n if (env.features?.privacy?.enabled === false) {\n features.privacy = { ...(features.privacy as Section), enabled: false };\n }\n // Under a declared composition a plugin's presence decides mcp and\n // workflows, not their env vars, except that an env false still switches\n // them off. Without one the env vars keep deciding, as on the classic boot.\n if (features.pluginHost === true) {\n features.mcp = env.features?.mcp === false ? false : caller.features?.mcp;\n features.workflows =\n env.features?.workflows === false ? false : caller.features?.workflows;\n }\n\n return { ...merged, features, inspection, auth } as Layer;\n}\n","import type { ReactorApiConfig } from \"@powerhousedao/reactor-api\";\nimport type { AttachmentStorageConfig } from \"@powerhousedao/reactor-attachments\";\nimport { z } from \"zod\";\n\n// Zod at runtime only: the monitor, workers and host validation load this without the server.\n\nexport const SWITCHBOARD_LOG_LEVELS = [\n \"verbose\",\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n] as const;\n\nexport const SWITCHBOARD_DRIVE_DOCUMENT_TYPES = [\n \"powerhouse/document-drive\",\n \"powerhouse/reactor-drive\",\n] as const;\n\nconst port = z.number().int().min(0).max(65535);\nconst nonNegativeInt = z.number().int().min(0);\nconst positiveInt = z.number().int().min(1);\nconst nonNegative = z.number().min(0);\nconst positive = z.number().positive();\n\nconst serverSchema = z.object({\n port: port.default(4001),\n strictPort: z.boolean().default(false),\n basePath: z.string().default(\"/\"),\n /** Origin advertised in webhook URLs; a bare domain gets a scheme at use. */\n publicUrl: z.string().optional(),\n /** Address to bind; unset binds every interface. */\n host: z.string().min(1).optional(),\n gatewayAdapter: z\n .enum([\"apollo\", \"mercurius\", \"stitching\"])\n .default(\"apollo\"),\n https: z\n .union([\n z.boolean(),\n z.object({ keyPath: z.string(), certPath: z.string() }),\n ])\n .optional(),\n dev: z.boolean().default(false),\n});\n\nconst vacuumFullSchema = z.object({\n mode: z.enum([\"off\", \"quiet\", \"forced\"]).default(\"off\"),\n aboveMb: nonNegative.optional(),\n quietMs: nonNegative.optional(),\n maxDeferMs: nonNegative.optional(),\n});\n\nconst keyframeRuleSchema = z.strictObject({\n interval: positiveInt.optional(),\n /** Null keeps every keyframe. */\n keep: positiveInt.nullable().optional(),\n});\n\n/** See `KeyframeSettings` in the reactor. */\nconst keyframesSchema = z.strictObject({\n default: keyframeRuleSchema.optional(),\n types: z.record(z.string(), keyframeRuleSchema).optional(),\n});\n\nconst storageSchema = z.object({\n /** Postgres URL or PGlite data dir; unset uses the default dir. */\n reactor: z.object({ url: z.string().min(1).optional() }).prefault({}),\n /** Postgres URL or PGlite data dir; unset uses the default dir. */\n readModel: z.object({ url: z.string().min(1).optional() }).prefault({}),\n inMemory: z.boolean().default(false),\n /** Relocates the `.ph` tree (stores, identity) under this root. */\n userDataDir: z.string().min(1).optional(),\n pglite: z\n .object({\n fsync: z.boolean().default(true),\n workers: z.boolean().default(true),\n workerMemoryMb: positiveInt.optional(),\n vacuumFull: vacuumFullSchema.prefault({}),\n })\n .prefault({}),\n migratePglite: z.boolean().default(false),\n forcePgVersion: z.union([z.literal(16), z.literal(17)]).optional(),\n /** Unset: `reactor.keyframes` of the project config, then the built-in rule. */\n keyframes: keyframesSchema.optional(),\n});\n\nconst protocolSchema = z.object({\n featureFlags: z\n .object({\n documentDecisions: z.boolean().default(false),\n authEnforcement: z.boolean().default(false),\n authGroups: z.boolean().default(false),\n authConditions: z.boolean().default(false),\n /** Unset leaves the reactor's own default. */\n undoV3: z.boolean().optional(),\n })\n .prefault({}),\n /** Requested policy; without a signer the boot still falls back to legacy. */\n createSignaturePolicy: z\n .enum([\"legacy\", \"v2-required\"])\n .default(\"v2-required\"),\n unsupportedStoredDocuments: z.enum([\"refuse\", \"read-only\"]).default(\"refuse\"),\n legacyProcessorIds: z.boolean().default(true),\n maxSkipThreshold: positiveInt.optional(),\n catchUpPriority: z\n .union([z.literal(\"dynamic\"), z.number().int().min(0).max(7)])\n .default(\"dynamic\"),\n /** What processors record about their time. */\n processorTiming: z.enum([\"off\", \"basic\", \"detailed\"]).default(\"basic\"),\n processorTimingWindowMs: positiveInt.default(60_000),\n /** At `detailed`: an `onOperations` call over this logs a warning. */\n processorSlowBatchMs: positiveInt.default(1_000),\n /** Above 0: logs the slowest processors this often while catching up. */\n processorTimingLogMs: nonNegativeInt.default(0),\n});\n\nconst memoryTelemetrySchema = z.object({\n enabled: z.boolean().default(false),\n intervalMs: z.number().int().min(1000).default(30_000),\n /** `memory`, the ring, is always on while telemetry runs. */\n outputs: z\n .array(z.enum([\"memory\", \"file\", \"console\"]))\n .default([\"memory\", \"file\"]),\n file: z\n .object({\n path: z.string().min(1).optional(),\n maxMb: positiveInt.default(10),\n keep: positiveInt.default(5),\n })\n .prefault({}),\n ringSize: positiveInt.default(720),\n consoleIntervalMs: positiveInt.default(300_000),\n workers: z.boolean().default(true),\n windowMin: positiveInt.default(30),\n});\n\nconst telemetrySchema = z.object({\n memory: memoryTelemetrySchema.prefault({}),\n /** Under it go the JSONL files and heap snapshots; unset: `<phDir>/telemetry`. */\n dir: z.string().min(1).optional(),\n heapSnapshotDir: z.string().min(1).optional(),\n});\n\n/**\n * `ACCESS`. A string refined rather than an enum, so an unknown value is\n * refused by name, and `members` points at what replaces it.\n */\nconst accessModeSchema = z.string().superRefine((mode, ctx) => {\n if (mode === \"open\" || mode === \"licensed\") return;\n ctx.addIssue({\n code: \"custom\",\n message:\n mode === \"members\"\n ? \"ACCESS=members is not supported; use ACCESS=licensed with Vetra's gate\"\n : `ACCESS=${mode} is not supported: use ACCESS=open (the default) or ACCESS=licensed`,\n });\n});\n\n/** Who may use the host beyond its admins (`ACCESS`, `VETRA_GATE_*`). */\nconst accessSchema = z.object({\n mode: accessModeSchema.default(\"open\"),\n gateUrl: z.string().min(1).optional(),\n /** Secret: never logged. */\n gateToken: z.string().min(1).optional(),\n appId: z.string().min(1).optional(),\n graceMs: nonNegativeInt.optional(),\n});\n\nconst authSchema = z.object({\n enabled: z.boolean().default(false),\n /** Unset follows `enabled`. */\n resolveIdentity: z.boolean().optional(),\n requireAuthenticatedCaller: z.boolean().default(false),\n requireAuthenticatedCallerExemptPaths: z.array(z.string()).default([]),\n admins: z.array(z.string()).default([]),\n defaultProtection: z.boolean().default(false),\n attachmentReadsFollowDocumentPolicy: z.boolean().default(false),\n documentPermissions: z\n .object({\n enabled: z.boolean().default(false),\n cacheTtlMs: nonNegativeInt.optional(),\n })\n .prefault({}),\n skipCredentialVerification: z.boolean().default(false),\n /** Unset: 0 with a \"self\" renown source, else the AuthService default. */\n credentialCacheTtlMs: nonNegative.optional(),\n wsRecheckMs: nonNegative.optional(),\n /** The first verified caller becomes the admin of a host with none. */\n ownerClaim: z.boolean().default(false),\n /** Keep verified credentials, and rely on them while Renown is away. */\n offlineCredentials: z.boolean().default(false),\n access: accessSchema.prefault({}),\n renown: z\n .object({\n source: z.enum([\"self\", \"remote\", \"kept\"]).optional(),\n url: z.string().min(1).optional(),\n switchboardUrl: z.string().min(1).optional(),\n })\n .prefault({}),\n});\n\nconst inspectionSchema = z.object({\n enabled: z.boolean().default(true),\n admin: z.boolean().default(false),\n callsPerMinute: positiveInt.optional(),\n});\n\nconst workersSchema = z.object({\n executor: z\n .object({\n count: z.union([nonNegativeInt, z.literal(\"auto\")]).default(0),\n poolSize: nonNegativeInt.default(2),\n acquireTimeoutMs: nonNegativeInt.default(5000),\n })\n .prefault({}),\n hostPoolSize: positiveInt.default(16),\n projection: z\n .object({\n enabled: z.boolean().default(false),\n poolSize: positiveInt.default(8),\n })\n .prefault({}),\n});\n\nconst packagesSchema = z.object({\n registryUrl: z.string().optional(),\n registryPackages: z.array(z.string()).default([]),\n dynamic: z.boolean().default(false),\n list: z.array(z.string()).default([]),\n disableLocal: z.boolean().default(false),\n hostValidation: z.enum([\"log\", \"refuse\"]).default(\"log\"),\n});\n\nconst privacySchema = z.object({\n enabled: z.boolean().default(false),\n deploymentSecret: z.string().optional(),\n intervalMs: positive.optional(),\n deadlineMs: positive.optional(),\n markerGraceMs: positive.optional(),\n purgeTimeoutMs: positive.optional(),\n});\n\nconst featuresSchema = z.object({\n /** Unset: on unless a plugin composition leaves it out. */\n mcp: z.boolean().optional(),\n /** Unset: the config file's `workflows.enabled`, then off. */\n workflows: z.boolean().optional(),\n documentModelSubgraphs: z.boolean().default(true),\n /** Unset: the plugin host runs the default composition, the subsystems the\n * switches above turn on. `true`: it runs the declared composition, where a\n * plugin's presence is the switch. `false`: the deprecated inline boot. */\n pluginHost: z.boolean().optional(),\n privacy: privacySchema.prefault({}),\n});\n\nconst s3Schema = z.object({\n endpoint: z.string(),\n region: z.string(),\n bucket: z.string(),\n accessKeyId: z.string(),\n secretAccessKey: z.string(),\n prefix: z.string(),\n forcePathStyle: z.boolean(),\n uploadTtlSeconds: positiveInt,\n downloadTtlSeconds: positiveInt,\n});\n\nconst attachmentsSchema = z.object({\n storage: z\n .discriminatedUnion(\"kind\", [\n z.object({ kind: z.literal(\"filesystem\") }),\n z.object({ kind: z.literal(\"s3\"), s3: s3Schema }),\n ])\n .default({ kind: \"filesystem\" }),\n /** Unset: production refuses signed downloads, elsewhere a per-process secret. */\n urlSigningSecret: z.string().optional(),\n downloadTargetMaxTtlSeconds: positiveInt.optional(),\n /** Unset: `http(s)://localhost:<port>`. */\n serviceUrl: z.string().optional(),\n});\n\nconst identitySchema = z.object({\n keypairPath: z.string().optional(),\n requireExisting: z.boolean().optional(),\n baseUrl: z.string().optional(),\n});\n\nconst driveSchema = z.looseObject({\n id: z.string().optional(),\n slug: z.string().optional(),\n documentType: z.enum(SWITCHBOARD_DRIVE_DOCUMENT_TYPES).optional(),\n});\n\n/** Every field is optional on input, so `z.input` is one configuration layer. */\nexport const switchboardConfigSchema = z.object({\n logLevel: z.enum(SWITCHBOARD_LOG_LEVELS).default(\"info\"),\n server: serverSchema.prefault({}),\n storage: storageSchema.prefault({}),\n protocol: protocolSchema.prefault({}),\n telemetry: telemetrySchema.prefault({}),\n auth: authSchema.prefault({}),\n inspection: inspectionSchema.prefault({}),\n workers: workersSchema.prefault({}),\n packages: packagesSchema.prefault({}),\n features: featuresSchema.prefault({}),\n attachments: attachmentsSchema.prefault({}),\n identity: identitySchema.optional(),\n drive: driveSchema.optional(),\n remoteDrives: z.array(z.string()).default([]),\n configFile: z.string().optional(),\n processorConfig: z.map(z.string(), z.unknown()).optional(),\n});\n\n/**\n * One layer's own schema: every key optional, no defaults (they would\n * override the layers below), unknown keys refused. `omit` drops dotted\n * paths the caller sets elsewhere.\n */\nexport function switchboardConfigLayerSchema(\n omit: readonly string[] = [],\n): z.ZodType<SwitchboardConfigInput, SwitchboardConfigInput> {\n return layerOf(switchboardConfigSchema, \"\", new Set(omit)) as z.ZodType<\n SwitchboardConfigInput,\n SwitchboardConfigInput\n >;\n}\n\nfunction layerOf(\n schema: z.ZodType,\n path: string,\n omit: Set<string>,\n): z.ZodType {\n const def = schema.def as { type: string; innerType?: z.ZodType };\n if (\n (def.type === \"default\" ||\n def.type === \"prefault\" ||\n def.type === \"optional\") &&\n def.innerType\n ) {\n return layerOf(def.innerType, path, omit);\n }\n if (!(schema instanceof z.ZodObject)) return schema;\n const shape: Record<string, z.ZodType> = {};\n for (const [key, field] of Object.entries(\n schema.shape as Record<string, z.ZodType>,\n )) {\n const at = path ? `${path}.${key}` : key;\n if (omit.has(at)) continue;\n shape[key] = layerOf(field, at, omit).optional();\n }\n const catchall = schema.def.catchall as z.ZodType | undefined;\n return catchall && catchall.def.type !== \"never\"\n ? z.looseObject(shape)\n : z.strictObject(shape);\n}\n\nexport type SwitchboardConfig = z.output<typeof switchboardConfigSchema>;\n\n/** One configuration layer: any subset of {@link SwitchboardConfig}. */\nexport type SwitchboardConfigInput = z.input<typeof switchboardConfigSchema>;\n\n// The sections reactor-api reads are ReactorApiConfig's, under its names.\ntype Section<T> = NonNullable<T>;\ntype MissingKeys<Api, Ours> = Exclude<keyof Section<Api>, keyof Ours>;\ntype Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;\ntype Assert<T extends true> = T;\nexport type ReactorApiSectionsMatch = [\n Assert<\n Same<\n MissingKeys<ReactorApiConfig[\"server\"], SwitchboardConfig[\"server\"]>,\n never\n >\n >,\n Assert<\n Same<\n MissingKeys<ReactorApiConfig[\"auth\"], SwitchboardConfig[\"auth\"]>,\n never\n >\n >,\n Assert<\n Same<\n MissingKeys<\n Section<ReactorApiConfig[\"auth\"]>[\"documentPermissions\"],\n SwitchboardConfig[\"auth\"][\"documentPermissions\"]\n >,\n never\n >\n >,\n Assert<\n Same<\n MissingKeys<\n Section<ReactorApiConfig[\"auth\"]>[\"access\"],\n SwitchboardConfig[\"auth\"][\"access\"]\n >,\n never\n >\n >,\n Assert<\n Same<\n MissingKeys<\n ReactorApiConfig[\"inspection\"],\n SwitchboardConfig[\"inspection\"]\n >,\n never\n >\n >,\n Assert<\n Same<\n MissingKeys<\n ReactorApiConfig[\"attachments\"],\n SwitchboardConfig[\"attachments\"]\n >,\n never\n >\n >,\n Assert<ReactorApiConfig extends SwitchboardConfigInput ? true : false>,\n Assert<\n Pick<\n SwitchboardConfig,\n \"server\" | \"auth\" | \"inspection\" | \"attachments\"\n > extends ReactorApiConfig\n ? true\n : false\n >,\n Assert<\n Same<\n SwitchboardConfig[\"server\"][\"gatewayAdapter\"],\n NonNullable<Section<ReactorApiConfig[\"server\"]>[\"gatewayAdapter\"]>\n >\n >,\n Assert<\n Same<SwitchboardConfig[\"attachments\"][\"storage\"], AttachmentStorageConfig>\n >,\n];\n\nexport { callerOverEnv, mergeSwitchboardConfig } from \"./merge.js\";\n"],"names":[],"mappings":";;;;AAMA,MAAM,iCAAiB,IAAI,IAAI,CAAC,uBAAuB,mBAAmB,CAAC;AAG3E,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,cAAc,OAAkC;CACvD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAO,eAAe,KAAK,MAAM,OAAO;AAE5C;AAEA,SAAS,aAAa,MAAe,MAAe,MAAuB;CACzE,MAAM,SAAkB,EAAE,GAAG,KAAK;CAClC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAAG;EAC/C,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,KAAK,OAAO,GAAG,KAAK,GAAG,QAAQ;EACrC,MAAM,UAAU,OAAO;EACvB,OAAO,OACL,cAAc,KAAK,KAAK,cAAc,OAAO,KAAK,CAAC,eAAe,IAAI,EAAE,IACpE,aAAa,SAAS,OAAO,EAAE,IAC/B;CACR;CACA,OAAO;AACT;;AAGA,SAAgB,uBAAuB,GAAG,QAAwB;CAChE,IAAI,SAAkB,CAAC;CACvB,KAAK,MAAM,SAAS,QAAQ,SAAS,aAAa,QAAQ,OAAO,EAAE;CACnE,OAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBlC,EAAA,KAAA;;;;;;iBAOc,6BACd,2BACC,EAAE,QAAQ,wBAAwB;KAoCzB,oBAAoB,EAAE,cAAc;;KAGpC,yBAAyB,EAAE,aAAa;KAG/C,QAAQ,KAAK,YAAY;KACzB,YAAY,KAAK,QAAQ,cAAc,QAAQ,YAAY;KAC3D,KAAK,GAAG,MAAM,YAAY,OAAO,YAAY;KAC7C,OAAO,kBAAkB;KAClB,2BACV,OACE,KACE,YAAY,4BAA4B,uCAI5C,OACE,KACE,YAAY,0BAA0B,qCAI1C,OACE,KACE,YACE,QAAQ,kDACR,4DAKN,OACE,KACE,YACE,QAAQ,qCACR,+CAKN,OACE,KACE,YACE,gCACA,2CAKN,OACE,KACE,YACE,iCACA,4CAKN,OAAO,yBAAyB,wCAChC,OACE,KACE,6EAEQ,kCAIZ,OACE,KACE,+CACA,YAAY,QAAQ,kDAGxB,OACE,KAAK,6CAA6C"}