@powerhousedao/switchboard 6.2.3-dev.84 → 6.2.3-dev.86

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 (72) 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/keyframe-reclaim-store.test.d.ts +2 -0
  4. package/.tsbuild/test/keyframe-reclaim-store.test.d.ts.map +1 -0
  5. package/.tsbuild/test/processor-timing-log.test.d.ts +2 -0
  6. package/.tsbuild/test/processor-timing-log.test.d.ts.map +1 -0
  7. package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts +2 -0
  8. package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts.map +1 -0
  9. package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts +2 -0
  10. package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts.map +1 -0
  11. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  12. package/CHANGELOG.md +33 -0
  13. package/README.md +33 -0
  14. package/dist/boot.d.mts +1 -1
  15. package/dist/boot.mjs +1 -1
  16. package/dist/config/from-env.d.mts +1 -1
  17. package/dist/config/from-env.d.mts.map +1 -1
  18. package/dist/config/from-env.mjs +3 -3
  19. package/dist/config/schema.d.mts +1 -1
  20. package/dist/config/schema.mjs +3 -3
  21. package/dist/{from-env-BO0n9R02.mjs → from-env-BgyZQAxw.mjs} +79 -7
  22. package/dist/from-env-BgyZQAxw.mjs.map +1 -0
  23. package/dist/index.mjs +13 -10
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/{plugin-host-C1sYEm8g.d.mts → plugin-host-C0bSz1Oe.d.mts} +2 -2
  26. package/dist/{plugin-host-C1sYEm8g.d.mts.map → plugin-host-C0bSz1Oe.d.mts.map} +1 -1
  27. package/dist/plugins/ai.d.mts +37 -0
  28. package/dist/plugins/ai.d.mts.map +1 -0
  29. package/dist/plugins/ai.mjs +352 -0
  30. package/dist/plugins/ai.mjs.map +1 -0
  31. package/dist/plugins/attachments.d.mts +1 -1
  32. package/dist/plugins/attachments.mjs +3 -3
  33. package/dist/plugins/mcp.d.mts +1 -1
  34. package/dist/plugins/privacy.d.mts +1 -1
  35. package/dist/plugins/workflows.d.mts +2 -2
  36. package/dist/plugins/workflows.mjs +3 -3
  37. package/dist/{schema-ivUWPQOn.d.mts → schema-DhempFjb.d.mts} +41 -1
  38. package/dist/schema-DhempFjb.d.mts.map +1 -0
  39. package/dist/{schema-0g_QdOWn.mjs → schema-XEZrdmag.mjs} +55 -6
  40. package/dist/schema-XEZrdmag.mjs.map +1 -0
  41. package/dist/{server-B3qhPKNn.mjs → server-BRVMofWD.mjs} +102 -14
  42. package/dist/server-BRVMofWD.mjs.map +1 -0
  43. package/dist/server.d.mts +7 -3
  44. package/dist/server.d.mts.map +1 -1
  45. package/dist/server.mjs +5 -5
  46. package/dist/{workflow-runtime-7GaJ13c9.d.mts → workflow-runtime-CF5pc8mt.d.mts} +5 -2
  47. package/dist/workflow-runtime-CF5pc8mt.d.mts.map +1 -0
  48. package/dist/{workflows-B1VsL5Lo.mjs → workflows-C_pWcP2u.mjs} +446 -9
  49. package/dist/workflows-C_pWcP2u.mjs.map +1 -0
  50. package/package.json +22 -16
  51. package/test/ai-gateway.test.ts +555 -0
  52. package/test/config-from-env.test.ts +184 -0
  53. package/test/config-schema.test.ts +28 -0
  54. package/test/goldens/packages.graphql +1 -1
  55. package/test/goldens/privacy.graphql +1 -1
  56. package/test/goldens/reactor-drive-nodes.graphql +1 -1
  57. package/test/goldens/resolvers.json +4 -0
  58. package/test/goldens/supergraph.graphql +217 -1
  59. package/test/goldens/workflow-runtime.graphql +95 -1
  60. package/test/keyframe-reclaim-store.test.ts +156 -0
  61. package/test/processor-timing-log.test.ts +109 -0
  62. package/test/redact-webhook-path.test.ts +9 -0
  63. package/test/workflow/resolvers.test.ts +106 -0
  64. package/test/workflow/waitpoint-routes.test.ts +284 -0
  65. package/test/workflow/waitpoint-runtime.test.ts +204 -0
  66. package/tsdown.config.ts +1 -0
  67. package/dist/from-env-BO0n9R02.mjs.map +0 -1
  68. package/dist/schema-0g_QdOWn.mjs.map +0 -1
  69. package/dist/schema-ivUWPQOn.d.mts.map +0 -1
  70. package/dist/server-B3qhPKNn.mjs.map +0 -1
  71. package/dist/workflow-runtime-7GaJ13c9.d.mts.map +0 -1
  72. package/dist/workflows-B1VsL5Lo.mjs.map +0 -1
@@ -0,0 +1,352 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fa62fedb-9c48-5690-86e4-5f4f6da838b2")}catch(e){}}();
3
+ import { AuthorizationPolicy } from "@powerhousedao/reactor-api";
4
+ import { z } from "zod";
5
+ //#region src/ai/key-store.mts
6
+ /**
7
+ * The gateway's settings, held as host secrets (`ownerId: null`) in the
8
+ * workflow runtime's encrypted store and addressed by a fixed label. Host
9
+ * secrets resolve for no document and never appear in the
10
+ * `workflowRuntime.secrets` listing, and no API here returns a value.
11
+ */
12
+ const AI_KEY_LABEL = "ai-gateway/openrouter/api-key";
13
+ /** The model is not secret; it lives here so the gateway needs no table. */
14
+ const AI_MODEL_LABEL = "ai-gateway/openrouter/model";
15
+ function findActive(stats, label) {
16
+ return stats.filter((stat) => stat.label === label && stat.ownerId === null && stat.status === "ACTIVE");
17
+ }
18
+ async function readSetting(store, label) {
19
+ const newest = findActive(await store.list(), label).at(0);
20
+ if (!newest) return void 0;
21
+ return {
22
+ value: await store.get(newest.ref, null),
23
+ setBy: newest.createdBy,
24
+ setAt: newest.updatedAt
25
+ };
26
+ }
27
+ async function writeSetting(store, label, value, actor) {
28
+ const newest = findActive(await store.list(), label).at(0);
29
+ if (newest) {
30
+ await store.rotate(newest.ref, value);
31
+ return;
32
+ }
33
+ await store.create({
34
+ value,
35
+ label,
36
+ ownerId: null,
37
+ createdBy: actor ?? null
38
+ });
39
+ }
40
+ const readKey = (store) => readSetting(store, AI_KEY_LABEL);
41
+ const writeKey = (store, value, actor) => writeSetting(store, AI_KEY_LABEL, value, actor);
42
+ /** Tombstones the key: the value becomes unrecoverable. */
43
+ async function deleteKey(store) {
44
+ const active = findActive(await store.list(), AI_KEY_LABEL);
45
+ for (const stat of active) await store.delete(stat.ref);
46
+ }
47
+ const readModel = async (store) => (await readSetting(store, AI_MODEL_LABEL))?.value;
48
+ const writeModel = (store, model, actor) => writeSetting(store, AI_MODEL_LABEL, model, actor);
49
+ /** `sk-or-v1-…abcd`: the provider prefix and the last four, nothing between. */
50
+ function maskKey(value) {
51
+ const prefix = /^sk-(?:[a-z]+-)*(?:v\d+-)?/i.exec(value)?.[0] ?? "";
52
+ if (value.length - prefix.length < 16) return `${prefix}…`;
53
+ return `${prefix}…${value.slice(-4)}`;
54
+ }
55
+ //#endregion
56
+ //#region src/ai/routes.mts
57
+ /** Requests carry the conversation and base64 images, so more than the default. */
58
+ const MAX_CHAT_BODY_BYTES = 33554432;
59
+ const UPSTREAM_CHECK_TIMEOUT_MS = 15e3;
60
+ const MAX_KEY_CHARS = 512;
61
+ /** What of a chat request reaches the provider; routing overrides do not. */
62
+ const FORWARDED_CHAT_FIELDS = [
63
+ "messages",
64
+ "tools",
65
+ "tool_choice",
66
+ "parallel_tool_calls",
67
+ "temperature",
68
+ "top_p",
69
+ "frequency_penalty",
70
+ "presence_penalty",
71
+ "stop",
72
+ "seed",
73
+ "response_format",
74
+ "stream",
75
+ "stream_options"
76
+ ];
77
+ function errorResponse(status, message, code) {
78
+ return Response.json({ error: {
79
+ message,
80
+ code
81
+ } }, { status });
82
+ }
83
+ /** Removes the stored key, and anything shaped like a credential, from text. */
84
+ function redactSecrets(text, key) {
85
+ return (key ? text.split(key).join("[redacted]") : text).replace(/Bearer\s+\S+/gi, "Bearer [redacted]").replace(/sk-[a-z0-9_-]{8,}/gi, "[redacted]");
86
+ }
87
+ function errorText(error) {
88
+ return error instanceof Error ? error.message : String(error);
89
+ }
90
+ /** Never the request body or the parser's message: V8 quotes the input there. */
91
+ async function readJsonObject(request) {
92
+ try {
93
+ const value = JSON.parse(await request.text());
94
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
95
+ } catch {
96
+ return;
97
+ }
98
+ }
99
+ /**
100
+ * Serves the gateway: the OpenAI-compatible chat and model endpoints, and the
101
+ * key and model administration. Every route is for admins, and the key never
102
+ * leaves this module except as the upstream's bearer.
103
+ */
104
+ function registerAiRoutes(http, deps) {
105
+ const { logger } = deps;
106
+ const fetchImpl = deps.fetchImpl ?? fetch;
107
+ const upstreamHeaders = (key) => ({
108
+ authorization: `Bearer ${key}`,
109
+ "http-referer": deps.appUrl,
110
+ "x-title": deps.appTitle
111
+ });
112
+ const gate = async (ctx) => {
113
+ if (!deps.isAdmin(ctx.user?.address)) return { refused: errorResponse(403, "The assistant is for this host's admins.", "forbidden") };
114
+ let store;
115
+ try {
116
+ store = await deps.secrets();
117
+ } catch (error) {
118
+ logger.error("The AI gateway could not open the secret store: @message", redactSecrets(errorText(error), void 0));
119
+ }
120
+ if (!store) return { refused: errorResponse(503, "The assistant needs the workflow runtime, which is not running on this host.", "unavailable") };
121
+ return { store };
122
+ };
123
+ const currentModel = async (store) => await readModel(store) ?? deps.defaultModel;
124
+ const status = async (store) => {
125
+ const stored = await readKey(store);
126
+ return Response.json({
127
+ configured: stored !== void 0,
128
+ keyHint: stored ? maskKey(stored.value) : null,
129
+ keySetBy: stored?.setBy ?? null,
130
+ keySetAt: stored?.setAt ?? null,
131
+ model: await currentModel(store)
132
+ });
133
+ };
134
+ /** Keeps the provider's status; the body is rebuilt from its error message. */
135
+ const upstreamFailure = async (upstream, key) => {
136
+ let message = `The AI provider answered HTTP ${upstream.status}.`;
137
+ try {
138
+ const body = await upstream.json();
139
+ if (typeof body.error?.message === "string") message = redactSecrets(body.error.message, key);
140
+ } catch {}
141
+ return errorResponse(upstream.status, message, "upstream_error");
142
+ };
143
+ const unreachable = (error, key) => {
144
+ logger.warn("The AI gateway could not reach the provider: @message", redactSecrets(errorText(error), key));
145
+ return errorResponse(502, "The AI provider could not be reached.", "upstream_unreachable");
146
+ };
147
+ http.route({
148
+ method: "GET",
149
+ path: "ai/status",
150
+ auth: "renown",
151
+ handler: async (_request, ctx) => {
152
+ const gated = await gate(ctx);
153
+ return "refused" in gated ? gated.refused : status(gated.store);
154
+ }
155
+ });
156
+ http.route({
157
+ method: "PUT",
158
+ path: "ai/key",
159
+ auth: "renown",
160
+ maxBodyBytes: 4096,
161
+ handler: async (request, ctx) => {
162
+ const gated = await gate(ctx);
163
+ if ("refused" in gated) return gated.refused;
164
+ const body = await readJsonObject(request);
165
+ const value = typeof body?.value === "string" ? body.value.trim() : "";
166
+ if (!value || value.length > MAX_KEY_CHARS || /\s/.test(value)) return errorResponse(400, "Enter an OpenRouter key.", "invalid_key");
167
+ let check;
168
+ try {
169
+ check = await fetchImpl(`${deps.upstreamUrl}/key`, {
170
+ headers: upstreamHeaders(value),
171
+ signal: AbortSignal.timeout(UPSTREAM_CHECK_TIMEOUT_MS)
172
+ });
173
+ } catch (error) {
174
+ return unreachable(error, value);
175
+ }
176
+ if (!check.ok) {
177
+ await check.body?.cancel();
178
+ return errorResponse(400, `OpenRouter did not accept this key (HTTP ${check.status}).`, "invalid_key");
179
+ }
180
+ await check.body?.cancel();
181
+ await writeKey(gated.store, value, ctx.user?.address);
182
+ logger.info("The AI gateway key was set by @actor", ctx.user?.address);
183
+ return status(gated.store);
184
+ }
185
+ });
186
+ http.route({
187
+ method: "DELETE",
188
+ path: "ai/key",
189
+ auth: "renown",
190
+ handler: async (_request, ctx) => {
191
+ const gated = await gate(ctx);
192
+ if ("refused" in gated) return gated.refused;
193
+ await deleteKey(gated.store);
194
+ logger.info("The AI gateway key was reset by @actor", ctx.user?.address);
195
+ return status(gated.store);
196
+ }
197
+ });
198
+ http.route({
199
+ method: "PUT",
200
+ path: "ai/model",
201
+ auth: "renown",
202
+ maxBodyBytes: 4096,
203
+ handler: async (request, ctx) => {
204
+ const gated = await gate(ctx);
205
+ if ("refused" in gated) return gated.refused;
206
+ const body = await readJsonObject(request);
207
+ const model = typeof body?.model === "string" ? body.model.trim() : "";
208
+ if (!model) return errorResponse(400, "Name a model.", "invalid_model");
209
+ let listed;
210
+ try {
211
+ const answer = await fetchImpl(`${deps.upstreamUrl}/models`, { signal: AbortSignal.timeout(UPSTREAM_CHECK_TIMEOUT_MS) });
212
+ if (!answer.ok) throw new Error(`HTTP ${answer.status}`);
213
+ listed = await answer.json();
214
+ } catch (error) {
215
+ return unreachable(error, void 0);
216
+ }
217
+ if (!listed.data?.some((entry) => entry.id === model)) return errorResponse(400, `OpenRouter has no model "${model}".`, "invalid_model");
218
+ await writeModel(gated.store, model, ctx.user?.address);
219
+ return status(gated.store);
220
+ }
221
+ });
222
+ http.route({
223
+ method: "GET",
224
+ path: "ai/v1/models",
225
+ auth: "renown",
226
+ handler: async (_request, ctx) => {
227
+ const gated = await gate(ctx);
228
+ if ("refused" in gated) return gated.refused;
229
+ const stored = await readKey(gated.store);
230
+ if (!stored) return notConfigured();
231
+ let upstream;
232
+ try {
233
+ upstream = await fetchImpl(`${deps.upstreamUrl}/models`, {
234
+ headers: upstreamHeaders(stored.value),
235
+ signal: ctx.signal
236
+ });
237
+ } catch (error) {
238
+ return unreachable(error, stored.value);
239
+ }
240
+ if (!upstream.ok) return upstreamFailure(upstream, stored.value);
241
+ return new Response(upstream.body, {
242
+ status: upstream.status,
243
+ headers: { "content-type": "application/json" }
244
+ });
245
+ }
246
+ });
247
+ http.route({
248
+ method: "POST",
249
+ path: "ai/v1/chat/completions",
250
+ auth: "renown",
251
+ maxBodyBytes: MAX_CHAT_BODY_BYTES,
252
+ handler: async (request, ctx) => {
253
+ const gated = await gate(ctx);
254
+ if ("refused" in gated) return gated.refused;
255
+ const stored = await readKey(gated.store);
256
+ if (!stored) return notConfigured();
257
+ const body = await readJsonObject(request);
258
+ if (!Array.isArray(body?.messages)) return errorResponse(400, "A chat request needs messages.", "invalid_request");
259
+ const forwarded = {};
260
+ for (const field of FORWARDED_CHAT_FIELDS) if (body[field] !== void 0) forwarded[field] = body[field];
261
+ forwarded.model = await currentModel(gated.store);
262
+ const asked = body.max_tokens;
263
+ forwarded.max_tokens = typeof asked === "number" && asked > 0 ? Math.min(asked, deps.maxOutputTokens) : deps.maxOutputTokens;
264
+ let upstream;
265
+ try {
266
+ upstream = await fetchImpl(`${deps.upstreamUrl}/chat/completions`, {
267
+ method: "POST",
268
+ headers: {
269
+ ...upstreamHeaders(stored.value),
270
+ "content-type": "application/json"
271
+ },
272
+ body: JSON.stringify(forwarded),
273
+ signal: ctx.signal
274
+ });
275
+ } catch (error) {
276
+ return unreachable(error, stored.value);
277
+ }
278
+ if (!upstream.ok) return upstreamFailure(upstream, stored.value);
279
+ return new Response(upstream.body, {
280
+ status: upstream.status,
281
+ headers: {
282
+ "content-type": upstream.headers.get("content-type") ?? "text/event-stream",
283
+ "cache-control": "no-cache",
284
+ "x-accel-buffering": "no"
285
+ }
286
+ });
287
+ }
288
+ });
289
+ }
290
+ function notConfigured() {
291
+ return errorResponse(503, "The assistant has no OpenRouter key yet.", "not_configured");
292
+ }
293
+ //#endregion
294
+ //#region src/plugins/ai.mts
295
+ const DEFAULT_AI_UPSTREAM_URL = "https://openrouter.ai/api/v1";
296
+ const aiPluginConfigSchema = z.strictObject({
297
+ /** The model the gateway answers with until an admin picks another. */
298
+ defaultModel: z.string().min(1),
299
+ /** Upper bound on `max_tokens` per request. */
300
+ maxOutputTokens: z.number().int().positive().default(4096),
301
+ /** The OpenAI-compatible provider. Tests point this at a stub. */
302
+ upstreamUrl: z.url().default(DEFAULT_AI_UPSTREAM_URL),
303
+ /** How the host names itself to the provider (OpenRouter's app attribution). */
304
+ appTitle: z.string().min(1).default("Powerhouse"),
305
+ appUrl: z.url().default("https://powerhouse.inc"),
306
+ /**
307
+ * Local development only. Under the OPEN policy everyone is an admin,
308
+ * anonymous callers included, so the gateway does not mount there unless
309
+ * this says so.
310
+ */
311
+ allowWithoutAuth: z.boolean().default(false)
312
+ });
313
+ /**
314
+ * The AI gateway: an OpenAI-compatible endpoint for this host's admins that
315
+ * holds the provider key server side, so the browser's agent runs without
316
+ * one. The key is a host secret in the workflow runtime's encrypted store,
317
+ * reached per request through `ctx.workflows`: the runtime can arrive after
318
+ * boot, and a second opener of the store could race the first over the key
319
+ * file. Without the runtime the routes answer 503.
320
+ */
321
+ function createAiPlugin(rawConfig) {
322
+ const config = aiPluginConfigSchema.parse(rawConfig ?? {});
323
+ return {
324
+ name: "switchboard-ai",
325
+ appliesTo: "switchboard",
326
+ configSchema: aiPluginConfigSchema,
327
+ hooks: { onHttpMounting: (ctx) => {
328
+ const api = ctx.api;
329
+ const logger = ctx.logger;
330
+ const { authorizationService } = api;
331
+ if (authorizationService.config.policy === AuthorizationPolicy.OPEN && !config.allowWithoutAuth) {
332
+ logger.warn("The AI gateway is not mounted: this host has no sign-in, so every caller would be an admin. Enable authentication (AUTH_ENABLED=true with ADMINS), or set allowWithoutAuth for local development.");
333
+ return;
334
+ }
335
+ registerAiRoutes(api.httpRoutes.scopeFor("@powerhousedao/switchboard"), {
336
+ isAdmin: (address) => authorizationService.isSupremeAdmin(address),
337
+ secrets: async () => ctx.workflows?.secrets(),
338
+ upstreamUrl: config.upstreamUrl.replace(/\/+$/, ""),
339
+ defaultModel: config.defaultModel,
340
+ maxOutputTokens: config.maxOutputTokens,
341
+ appTitle: config.appTitle,
342
+ appUrl: config.appUrl,
343
+ logger
344
+ });
345
+ } }
346
+ };
347
+ }
348
+ //#endregion
349
+ export { DEFAULT_AI_UPSTREAM_URL, aiPluginConfigSchema, createAiPlugin, createAiPlugin as default };
350
+
351
+ //# sourceMappingURL=ai.mjs.map
352
+ //# debugId=fa62fedb-9c48-5690-86e4-5f4f6da838b2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.mjs","sources":["../../src/ai/key-store.mts","../../src/ai/routes.mts","../../src/plugins/ai.mts"],"sourcesContent":["import type { ComposedWorkflowRuntime } from \"../workflow-runtime.mjs\";\n\ntype SecretStore = Awaited<ReturnType<ComposedWorkflowRuntime[\"secrets\"]>>;\n\n/**\n * The gateway's settings, held as host secrets (`ownerId: null`) in the\n * workflow runtime's encrypted store and addressed by a fixed label. Host\n * secrets resolve for no document and never appear in the\n * `workflowRuntime.secrets` listing, and no API here returns a value.\n */\nexport const AI_KEY_LABEL = \"ai-gateway/openrouter/api-key\";\n/** The model is not secret; it lives here so the gateway needs no table. */\nexport const AI_MODEL_LABEL = \"ai-gateway/openrouter/model\";\n\nexport type AiSecretStore = Pick<\n SecretStore,\n \"get\" | \"create\" | \"rotate\" | \"list\" | \"delete\"\n>;\n\nexport interface StoredKey {\n value: string;\n setBy: string | null;\n setAt: string;\n}\n\nfunction findActive(\n stats: Awaited<ReturnType<SecretStore[\"list\"]>>,\n label: string,\n) {\n return stats.filter(\n (stat) =>\n stat.label === label && stat.ownerId === null && stat.status === \"ACTIVE\",\n );\n}\n\nasync function readSetting(\n store: AiSecretStore,\n label: string,\n): Promise<StoredKey | undefined> {\n const newest = findActive(await store.list(), label).at(0);\n if (!newest) return undefined;\n return {\n value: await store.get(newest.ref, null),\n setBy: newest.createdBy,\n setAt: newest.updatedAt,\n };\n}\n\nasync function writeSetting(\n store: AiSecretStore,\n label: string,\n value: string,\n actor: string | undefined,\n): Promise<void> {\n const newest = findActive(await store.list(), label).at(0);\n if (newest) {\n await store.rotate(newest.ref, value);\n return;\n }\n await store.create({ value, label, ownerId: null, createdBy: actor ?? null });\n}\n\nexport const readKey = (store: AiSecretStore) =>\n readSetting(store, AI_KEY_LABEL);\n\nexport const writeKey = (\n store: AiSecretStore,\n value: string,\n actor: string | undefined,\n) => writeSetting(store, AI_KEY_LABEL, value, actor);\n\n/** Tombstones the key: the value becomes unrecoverable. */\nexport async function deleteKey(store: AiSecretStore): Promise<void> {\n const active = findActive(await store.list(), AI_KEY_LABEL);\n for (const stat of active) await store.delete(stat.ref);\n}\n\nexport const readModel = async (store: AiSecretStore) =>\n (await readSetting(store, AI_MODEL_LABEL))?.value;\n\nexport const writeModel = (\n store: AiSecretStore,\n model: string,\n actor: string | undefined,\n) => writeSetting(store, AI_MODEL_LABEL, model, actor);\n\n/** `sk-or-v1-…abcd`: the provider prefix and the last four, nothing between. */\nexport function maskKey(value: string): string {\n const prefix = /^sk-(?:[a-z]+-)*(?:v\\d+-)?/i.exec(value)?.[0] ?? \"\";\n // A value this short would be mostly shown by its tail.\n if (value.length - prefix.length < 16) return `${prefix}…`;\n return `${prefix}…${value.slice(-4)}`;\n}\n","import type {\n IHttpScope,\n RouteContext,\n} from \"@powerhousedao/shared/processors\";\nimport type { ILogger } from \"document-model\";\nimport {\n deleteKey,\n maskKey,\n readKey,\n readModel,\n writeKey,\n writeModel,\n type AiSecretStore,\n} from \"./key-store.mjs\";\n\n/** Requests carry the conversation and base64 images, so more than the default. */\nconst MAX_CHAT_BODY_BYTES = 32 * 1024 * 1024;\nconst UPSTREAM_CHECK_TIMEOUT_MS = 15_000;\nconst MAX_KEY_CHARS = 512;\n\n/** What of a chat request reaches the provider; routing overrides do not. */\nconst FORWARDED_CHAT_FIELDS = [\n \"messages\",\n \"tools\",\n \"tool_choice\",\n \"parallel_tool_calls\",\n \"temperature\",\n \"top_p\",\n \"frequency_penalty\",\n \"presence_penalty\",\n \"stop\",\n \"seed\",\n \"response_format\",\n \"stream\",\n \"stream_options\",\n] as const;\n\nexport interface AiRoutesDeps {\n /** Whether this caller may use and manage the gateway. */\n isAdmin(address: string | undefined): boolean;\n /** Undefined while the workflow runtime is absent. */\n secrets(): Promise<AiSecretStore | undefined>;\n /** OpenAI-compatible base, without a trailing slash. */\n upstreamUrl: string;\n defaultModel: string;\n maxOutputTokens: number;\n appTitle: string;\n appUrl: string;\n logger: ILogger;\n fetchImpl?: typeof fetch;\n}\n\nfunction errorResponse(status: number, message: string, code: string) {\n // OpenAI's error shape, which OpenAI-compatible clients surface as is.\n return Response.json({ error: { message, code } }, { status });\n}\n\n/** Removes the stored key, and anything shaped like a credential, from text. */\nexport function redactSecrets(text: string, key: string | undefined): string {\n const named = key ? text.split(key).join(\"[redacted]\") : text;\n return named\n .replace(/Bearer\\s+\\S+/gi, \"Bearer [redacted]\")\n .replace(/sk-[a-z0-9_-]{8,}/gi, \"[redacted]\");\n}\n\nfunction errorText(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** Never the request body or the parser's message: V8 quotes the input there. */\nasync function readJsonObject(\n request: Request,\n): Promise<Record<string, unknown> | undefined> {\n try {\n const value: unknown = JSON.parse(await request.text());\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Serves the gateway: the OpenAI-compatible chat and model endpoints, and the\n * key and model administration. Every route is for admins, and the key never\n * leaves this module except as the upstream's bearer.\n */\nexport function registerAiRoutes(http: IHttpScope, deps: AiRoutesDeps): void {\n const { logger } = deps;\n const fetchImpl = deps.fetchImpl ?? fetch;\n\n const upstreamHeaders = (key: string) => ({\n authorization: `Bearer ${key}`,\n \"http-referer\": deps.appUrl,\n \"x-title\": deps.appTitle,\n });\n\n type Gate = { store: AiSecretStore } | { refused: Response };\n\n const gate = async (ctx: RouteContext): Promise<Gate> => {\n if (!deps.isAdmin(ctx.user?.address)) {\n return {\n refused: errorResponse(\n 403,\n \"The assistant is for this host's admins.\",\n \"forbidden\",\n ),\n };\n }\n let store: AiSecretStore | undefined;\n try {\n store = await deps.secrets();\n } catch (error) {\n logger.error(\n \"The AI gateway could not open the secret store: @message\",\n redactSecrets(errorText(error), undefined),\n );\n }\n if (!store) {\n return {\n refused: errorResponse(\n 503,\n \"The assistant needs the workflow runtime, which is not running on this host.\",\n \"unavailable\",\n ),\n };\n }\n return { store };\n };\n\n const currentModel = async (store: AiSecretStore) =>\n (await readModel(store)) ?? deps.defaultModel;\n\n const status = async (store: AiSecretStore) => {\n const stored = await readKey(store);\n return Response.json({\n configured: stored !== undefined,\n keyHint: stored ? maskKey(stored.value) : null,\n keySetBy: stored?.setBy ?? null,\n keySetAt: stored?.setAt ?? null,\n model: await currentModel(store),\n });\n };\n\n /** Keeps the provider's status; the body is rebuilt from its error message. */\n const upstreamFailure = async (upstream: Response, key: string) => {\n let message = `The AI provider answered HTTP ${upstream.status}.`;\n try {\n const body = (await upstream.json()) as {\n error?: { message?: unknown };\n };\n if (typeof body.error?.message === \"string\") {\n message = redactSecrets(body.error.message, key);\n }\n } catch {\n // Not JSON: the status line above says as much as we can repeat.\n }\n return errorResponse(upstream.status, message, \"upstream_error\");\n };\n\n const unreachable = (error: unknown, key: string | undefined) => {\n logger.warn(\n \"The AI gateway could not reach the provider: @message\",\n redactSecrets(errorText(error), key),\n );\n return errorResponse(\n 502,\n \"The AI provider could not be reached.\",\n \"upstream_unreachable\",\n );\n };\n\n http.route({\n method: \"GET\",\n path: \"ai/status\",\n auth: \"renown\",\n handler: async (_request, ctx) => {\n const gated = await gate(ctx);\n return \"refused\" in gated ? gated.refused : status(gated.store);\n },\n });\n\n // Tested before it is stored, so a typo cannot replace a working key.\n http.route({\n method: \"PUT\",\n path: \"ai/key\",\n auth: \"renown\",\n maxBodyBytes: 4096,\n handler: async (request, ctx) => {\n const gated = await gate(ctx);\n if (\"refused\" in gated) return gated.refused;\n const body = await readJsonObject(request);\n const value = typeof body?.value === \"string\" ? body.value.trim() : \"\";\n if (!value || value.length > MAX_KEY_CHARS || /\\s/.test(value)) {\n return errorResponse(400, \"Enter an OpenRouter key.\", \"invalid_key\");\n }\n let check: Response;\n try {\n check = await fetchImpl(`${deps.upstreamUrl}/key`, {\n headers: upstreamHeaders(value),\n signal: AbortSignal.timeout(UPSTREAM_CHECK_TIMEOUT_MS),\n });\n } catch (error) {\n return unreachable(error, value);\n }\n if (!check.ok) {\n await check.body?.cancel();\n return errorResponse(\n 400,\n `OpenRouter did not accept this key (HTTP ${check.status}).`,\n \"invalid_key\",\n );\n }\n await check.body?.cancel();\n await writeKey(gated.store, value, ctx.user?.address);\n logger.info(\"The AI gateway key was set by @actor\", ctx.user?.address);\n return status(gated.store);\n },\n });\n\n http.route({\n method: \"DELETE\",\n path: \"ai/key\",\n auth: \"renown\",\n handler: async (_request, ctx) => {\n const gated = await gate(ctx);\n if (\"refused\" in gated) return gated.refused;\n await deleteKey(gated.store);\n logger.info(\"The AI gateway key was reset by @actor\", ctx.user?.address);\n return status(gated.store);\n },\n });\n\n http.route({\n method: \"PUT\",\n path: \"ai/model\",\n auth: \"renown\",\n maxBodyBytes: 4096,\n handler: async (request, ctx) => {\n const gated = await gate(ctx);\n if (\"refused\" in gated) return gated.refused;\n const body = await readJsonObject(request);\n const model = typeof body?.model === \"string\" ? body.model.trim() : \"\";\n if (!model) {\n return errorResponse(400, \"Name a model.\", \"invalid_model\");\n }\n let listed: { data?: { id?: unknown }[] };\n try {\n const answer = await fetchImpl(`${deps.upstreamUrl}/models`, {\n signal: AbortSignal.timeout(UPSTREAM_CHECK_TIMEOUT_MS),\n });\n if (!answer.ok) throw new Error(`HTTP ${answer.status}`);\n listed = (await answer.json()) as typeof listed;\n } catch (error) {\n return unreachable(error, undefined);\n }\n if (!listed.data?.some((entry) => entry.id === model)) {\n return errorResponse(\n 400,\n `OpenRouter has no model \"${model}\".`,\n \"invalid_model\",\n );\n }\n await writeModel(gated.store, model, ctx.user?.address);\n return status(gated.store);\n },\n });\n\n http.route({\n method: \"GET\",\n path: \"ai/v1/models\",\n auth: \"renown\",\n handler: async (_request, ctx) => {\n const gated = await gate(ctx);\n if (\"refused\" in gated) return gated.refused;\n const stored = await readKey(gated.store);\n if (!stored) return notConfigured();\n let upstream: Response;\n try {\n upstream = await fetchImpl(`${deps.upstreamUrl}/models`, {\n headers: upstreamHeaders(stored.value),\n signal: ctx.signal,\n });\n } catch (error) {\n return unreachable(error, stored.value);\n }\n if (!upstream.ok) return upstreamFailure(upstream, stored.value);\n return new Response(upstream.body, {\n status: upstream.status,\n headers: { \"content-type\": \"application/json\" },\n });\n },\n });\n\n http.route({\n method: \"POST\",\n path: \"ai/v1/chat/completions\",\n auth: \"renown\",\n maxBodyBytes: MAX_CHAT_BODY_BYTES,\n handler: async (request, ctx) => {\n const gated = await gate(ctx);\n if (\"refused\" in gated) return gated.refused;\n const stored = await readKey(gated.store);\n if (!stored) return notConfigured();\n const body = await readJsonObject(request);\n if (!Array.isArray(body?.messages)) {\n return errorResponse(\n 400,\n \"A chat request needs messages.\",\n \"invalid_request\",\n );\n }\n\n const forwarded: Record<string, unknown> = {};\n for (const field of FORWARDED_CHAT_FIELDS) {\n if (body[field] !== undefined) forwarded[field] = body[field];\n }\n // The host's model, whatever the client named: cost is the host's call.\n forwarded.model = await currentModel(gated.store);\n const asked = body.max_tokens;\n forwarded.max_tokens =\n typeof asked === \"number\" && asked > 0\n ? Math.min(asked, deps.maxOutputTokens)\n : deps.maxOutputTokens;\n\n let upstream: Response;\n try {\n upstream = await fetchImpl(`${deps.upstreamUrl}/chat/completions`, {\n method: \"POST\",\n headers: {\n ...upstreamHeaders(stored.value),\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(forwarded),\n // A closed tab stops spending.\n signal: ctx.signal,\n });\n } catch (error) {\n return unreachable(error, stored.value);\n }\n if (!upstream.ok) return upstreamFailure(upstream, stored.value);\n return new Response(upstream.body, {\n status: upstream.status,\n headers: {\n \"content-type\":\n upstream.headers.get(\"content-type\") ?? \"text/event-stream\",\n \"cache-control\": \"no-cache\",\n \"x-accel-buffering\": \"no\",\n },\n });\n },\n });\n}\n\nfunction notConfigured() {\n return errorResponse(\n 503,\n \"The assistant has no OpenRouter key yet.\",\n \"not_configured\",\n );\n}\n","import type { HostPlugin } from \"@powerhousedao/host-core\";\nimport { AuthorizationPolicy, type API } from \"@powerhousedao/reactor-api\";\nimport type { ILogger } from \"document-model\";\nimport { z } from \"zod\";\nimport { registerAiRoutes } from \"../ai/routes.mjs\";\nimport type { SwitchboardHostContext } from \"../plugin-host.mjs\";\nimport type { ComposedWorkflowRuntime } from \"../workflow-runtime.mjs\";\n\nexport const DEFAULT_AI_UPSTREAM_URL = \"https://openrouter.ai/api/v1\";\n\nexport const aiPluginConfigSchema = z.strictObject({\n /** The model the gateway answers with until an admin picks another. */\n defaultModel: z.string().min(1),\n /** Upper bound on `max_tokens` per request. */\n maxOutputTokens: z.number().int().positive().default(4096),\n /** The OpenAI-compatible provider. Tests point this at a stub. */\n upstreamUrl: z.url().default(DEFAULT_AI_UPSTREAM_URL),\n /** How the host names itself to the provider (OpenRouter's app attribution). */\n appTitle: z.string().min(1).default(\"Powerhouse\"),\n appUrl: z.url().default(\"https://powerhouse.inc\"),\n /**\n * Local development only. Under the OPEN policy everyone is an admin,\n * anonymous callers included, so the gateway does not mount there unless\n * this says so.\n */\n allowWithoutAuth: z.boolean().default(false),\n});\n\nexport type AiPluginConfig = z.infer<typeof aiPluginConfigSchema>;\n\n/** What a host.js entry writes (typed-host-configs 1.4). */\nexport type AiPluginConfigInput = z.input<typeof aiPluginConfigSchema>;\n\ndeclare global {\n interface PHPluginConfigs {\n \"@powerhousedao/switchboard/plugins/ai\": AiPluginConfigInput;\n }\n}\n\nexport type AiPlugin = HostPlugin<\n { onHttpMounting: (ctx: SwitchboardHostContext) => void },\n AiPluginConfig\n>;\n\n/**\n * The AI gateway: an OpenAI-compatible endpoint for this host's admins that\n * holds the provider key server side, so the browser's agent runs without\n * one. The key is a host secret in the workflow runtime's encrypted store,\n * reached per request through `ctx.workflows`: the runtime can arrive after\n * boot, and a second opener of the store could race the first over the key\n * file. Without the runtime the routes answer 503.\n */\nexport function createAiPlugin(rawConfig: unknown): AiPlugin {\n const config = aiPluginConfigSchema.parse(rawConfig ?? {});\n return {\n name: \"switchboard-ai\",\n appliesTo: \"switchboard\",\n configSchema: aiPluginConfigSchema,\n hooks: {\n onHttpMounting: (ctx) => {\n const api = ctx.api as API;\n const logger = ctx.logger as ILogger;\n const { authorizationService } = api;\n // A warning, not a refused boot: a host composition is shared by\n // stacks that run with and without sign-in (desktop has none).\n if (\n authorizationService.config.policy === AuthorizationPolicy.OPEN &&\n !config.allowWithoutAuth\n ) {\n logger.warn(\n \"The AI gateway is not mounted: this host has no sign-in, so every caller would be an admin. Enable authentication (AUTH_ENABLED=true with ADMINS), or set allowWithoutAuth for local development.\",\n );\n return;\n }\n registerAiRoutes(\n api.httpRoutes.scopeFor(\"@powerhousedao/switchboard\"),\n {\n isAdmin: (address) => authorizationService.isSupremeAdmin(address),\n secrets: async () =>\n (ctx.workflows as ComposedWorkflowRuntime | undefined)?.secrets(),\n upstreamUrl: config.upstreamUrl.replace(/\\/+$/, \"\"),\n defaultModel: config.defaultModel,\n maxOutputTokens: config.maxOutputTokens,\n appTitle: config.appTitle,\n appUrl: config.appUrl,\n logger,\n },\n );\n },\n },\n };\n}\n\n// resolveHostPlugins consumes the DEFAULT export (plugin object or factory).\nexport default createAiPlugin;\n"],"names":[],"mappings":";;;;;;;;;;;AAUA,MAAa,eAAe;;AAE5B,MAAa,iBAAiB;AAa9B,SAAS,WACP,OACA,OACA;CACA,OAAO,MAAM,QACV,SACC,KAAK,UAAU,SAAS,KAAK,YAAY,QAAQ,KAAK,WAAW,QACrE;AACF;AAEA,eAAe,YACb,OACA,OACgC;CAChC,MAAM,SAAS,WAAW,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC;CACzD,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,OAAO;EACL,OAAO,MAAM,MAAM,IAAI,OAAO,KAAK,IAAI;EACvC,OAAO,OAAO;EACd,OAAO,OAAO;CAChB;AACF;AAEA,eAAe,aACb,OACA,OACA,OACA,OACe;CACf,MAAM,SAAS,WAAW,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC;CACzD,IAAI,QAAQ;EACV,MAAM,MAAM,OAAO,OAAO,KAAK,KAAK;EACpC;CACF;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AAqB,OAAO,WAAW,oBAAoB,QAC3D,CAAC,OAAO,kBACR;IACA,OAAO,KACL,mMACF;IACA;GACF;GACA,iBACE,IAAI,WAAW,SAAS,4BAA4B,GACpD;IACE,UAAU,YAAY,qBAAqB,eAAe,OAAO;IACjE,SAAS,YACN,IAAI,WAAmD,QAAQ;IAClE,aAAa,OAAO,YAAY,QAAQ,QAAQ,EAAE;IAClD,cAAc,OAAO;IACrB,iBAAiB,OAAO;IACxB,UAAU,OAAO;IACjB,QAAQ,OAAO;IACf;GACF,CACF;EACF,EACF;CACF;AACF","debug_id":"fa62fedb-9c48-5690-86e4-5f4f6da838b2"}
@@ -1,4 +1,4 @@
1
- import { t as SwitchboardHostContext } from "../plugin-host-C1sYEm8g.mjs";
1
+ import { t as SwitchboardHostContext } from "../plugin-host-C0bSz1Oe.mjs";
2
2
  import { z } from "zod";
3
3
  import { HostPlugin } from "@powerhousedao/host-core";
4
4
  //#region src/plugins/attachments.d.mts
@@ -1,4 +1,4 @@
1
- import { c as attachmentsPluginConfigSchema, s as attachmentsPlugin } from "../server-B3qhPKNn.mjs";
1
+ import { c as attachmentsPlugin, l as attachmentsPluginConfigSchema } from "../server-BRVMofWD.mjs";
2
2
  export { attachmentsPlugin, attachmentsPlugin as default, attachmentsPluginConfigSchema };
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c0455083-05a5-5ca2-9574-f2c6e26f8b79")}catch(e){}}();
4
- //# debugId=c0455083-05a5-5ca2-9574-f2c6e26f8b79
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="db3731d4-0bde-5807-b90f-77df8b8e1de0")}catch(e){}}();
4
+ //# debugId=db3731d4-0bde-5807-b90f-77df8b8e1de0
@@ -1,4 +1,4 @@
1
- import { t as SwitchboardHostContext } from "../plugin-host-C1sYEm8g.mjs";
1
+ import { t as SwitchboardHostContext } from "../plugin-host-C0bSz1Oe.mjs";
2
2
  import { z } from "zod";
3
3
  import { HostPlugin } from "@powerhousedao/host-core";
4
4
  //#region src/plugins/mcp.d.mts
@@ -1,4 +1,4 @@
1
- import { t as SwitchboardHostContext } from "../plugin-host-C1sYEm8g.mjs";
1
+ import { t as SwitchboardHostContext } from "../plugin-host-C0bSz1Oe.mjs";
2
2
  import { z } from "zod";
3
3
  import { HostPlugin } from "@powerhousedao/host-core";
4
4
  //#region src/plugins/privacy.d.mts
@@ -1,5 +1,5 @@
1
- import { t as SwitchboardHostContext } from "../plugin-host-C1sYEm8g.mjs";
2
- import { t as ComposedWorkflowRuntime } from "../workflow-runtime-7GaJ13c9.mjs";
1
+ import { t as SwitchboardHostContext } from "../plugin-host-C0bSz1Oe.mjs";
2
+ import { t as ComposedWorkflowRuntime } from "../workflow-runtime-CF5pc8mt.mjs";
3
3
  import { z } from "zod";
4
4
  import { HostPlugin } from "@powerhousedao/host-core";
5
5
  //#region src/plugins/workflows.d.mts
@@ -1,4 +1,4 @@
1
- import { a as workflowsPlugin, i as workflowsDriveDeclaration, n as WORKFLOW_STUDIO_EDITOR_ID, o as workflowsPluginConfigSchema, r as createWorkflowsPlugin, t as DEFAULT_WORKFLOWS_DRIVE } from "../workflows-B1VsL5Lo.mjs";
1
+ import { a as workflowsPlugin, i as workflowsDriveDeclaration, n as WORKFLOW_STUDIO_EDITOR_ID, o as workflowsPluginConfigSchema, r as createWorkflowsPlugin, t as DEFAULT_WORKFLOWS_DRIVE } from "../workflows-C_pWcP2u.mjs";
2
2
  export { DEFAULT_WORKFLOWS_DRIVE, WORKFLOW_STUDIO_EDITOR_ID, createWorkflowsPlugin, createWorkflowsPlugin as default, workflowsDriveDeclaration, workflowsPlugin, workflowsPluginConfigSchema };
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="01552745-f61c-52e0-8f12-91424a3a9481")}catch(e){}}();
4
- //# debugId=01552745-f61c-52e0-8f12-91424a3a9481
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6958d494-8b5b-5ec2-be74-534a171b2acb")}catch(e){}}();
4
+ //# debugId=6958d494-8b5b-5ec2-be74-534a171b2acb
@@ -62,6 +62,16 @@ declare const switchboardConfigSchema: z.ZodObject<{
62
62
  }, z.core.$strip>>;
63
63
  migratePglite: z.ZodDefault<z.ZodBoolean>;
64
64
  forcePgVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<16>, z.ZodLiteral<17>]>>;
65
+ keyframes: z.ZodOptional<z.ZodObject<{
66
+ default: z.ZodOptional<z.ZodObject<{
67
+ interval: z.ZodOptional<z.ZodNumber>;
68
+ keep: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
69
+ }, z.core.$strict>>;
70
+ types: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
71
+ interval: z.ZodOptional<z.ZodNumber>;
72
+ keep: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
73
+ }, z.core.$strict>>>;
74
+ }, z.core.$strict>>;
65
75
  }, z.core.$strip>>;
66
76
  protocol: z.ZodPrefault<z.ZodObject<{
67
77
  featureFlags: z.ZodPrefault<z.ZodObject<{
@@ -81,6 +91,36 @@ declare const switchboardConfigSchema: z.ZodObject<{
81
91
  legacyProcessorIds: z.ZodDefault<z.ZodBoolean>;
82
92
  maxSkipThreshold: z.ZodOptional<z.ZodNumber>;
83
93
  catchUpPriority: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"dynamic">, z.ZodNumber]>>;
94
+ processorTiming: z.ZodDefault<z.ZodEnum<{
95
+ basic: "basic";
96
+ detailed: "detailed";
97
+ off: "off";
98
+ }>>;
99
+ processorTimingWindowMs: z.ZodDefault<z.ZodNumber>;
100
+ processorSlowBatchMs: z.ZodDefault<z.ZodNumber>;
101
+ processorTimingLogMs: z.ZodDefault<z.ZodNumber>;
102
+ }, z.core.$strip>>;
103
+ telemetry: z.ZodPrefault<z.ZodObject<{
104
+ memory: z.ZodPrefault<z.ZodObject<{
105
+ enabled: z.ZodDefault<z.ZodBoolean>;
106
+ intervalMs: z.ZodDefault<z.ZodNumber>;
107
+ outputs: z.ZodDefault<z.ZodArray<z.ZodEnum<{
108
+ console: "console";
109
+ file: "file";
110
+ memory: "memory";
111
+ }>>>;
112
+ file: z.ZodPrefault<z.ZodObject<{
113
+ path: z.ZodOptional<z.ZodString>;
114
+ maxMb: z.ZodDefault<z.ZodNumber>;
115
+ keep: z.ZodDefault<z.ZodNumber>;
116
+ }, z.core.$strip>>;
117
+ ringSize: z.ZodDefault<z.ZodNumber>;
118
+ consoleIntervalMs: z.ZodDefault<z.ZodNumber>;
119
+ workers: z.ZodDefault<z.ZodBoolean>;
120
+ windowMin: z.ZodDefault<z.ZodNumber>;
121
+ }, z.core.$strip>>;
122
+ dir: z.ZodOptional<z.ZodString>;
123
+ heapSnapshotDir: z.ZodOptional<z.ZodString>;
84
124
  }, z.core.$strip>>;
85
125
  auth: z.ZodPrefault<z.ZodObject<{
86
126
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -199,4 +239,4 @@ type ReactorApiSectionsMatch = [Assert<Same<MissingKeys<ReactorApiConfig["server
199
239
  //#endregion
200
240
  export { SwitchboardConfigInput as a, callerOverEnv as c, SwitchboardConfig as i, mergeSwitchboardConfig as l, SWITCHBOARD_DRIVE_DOCUMENT_TYPES as n, switchboardConfigLayerSchema as o, SWITCHBOARD_LOG_LEVELS as r, switchboardConfigSchema as s, ReactorApiSectionsMatch as t };
201
241
  export {};
202
- //# sourceMappingURL=schema-ivUWPQOn.d.mts.map
242
+ //# sourceMappingURL=schema-DhempFjb.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-DhempFjb.d.mts","names":[],"sources":["../src/config/merge.ts","../src/config/schema.ts"],"mappings":";;;;KAEK,QAAQ;;iBAuCG,0BAA0B,QAAQ,UAAU;;iBAO5C,cAAc,KAAK,OAAO,QAAQ,QAAQ;;;cC1C7C;cAQA;;cAkPA,yBAAuB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,gCACA,2CAKN,OACE,KACE,YACE,iCACA,4CAKN,OAAO,yBAAyB,wCAChC,OACE,KACE,6EAEQ,kCAIZ,OACE,KACE,+CACA,YAAY,QAAQ,kDAGxB,OACE,KAAK,6CAA6C"}
@@ -1,8 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8d779fcc-b20d-513a-b972-c22f71f4667a")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4cfd484a-11e3-5f7d-a891-5b7293484d62")}catch(e){}}();
3
3
  import { z } from "zod";
4
4
  //#region src/config/merge.ts
5
- const REPLACED_WHOLE = /* @__PURE__ */ new Set(["attachments.storage"]);
5
+ const REPLACED_WHOLE = /* @__PURE__ */ new Set(["attachments.storage", "storage.keyframes"]);
6
6
  const ENV_WINS_AUTH = [
7
7
  "enabled",
8
8
  "admins",
@@ -94,6 +94,16 @@ const vacuumFullSchema = z.object({
94
94
  quietMs: nonNegative.optional(),
95
95
  maxDeferMs: nonNegative.optional()
96
96
  });
97
+ const keyframeRuleSchema = z.strictObject({
98
+ interval: positiveInt.optional(),
99
+ /** Null keeps every keyframe. */
100
+ keep: positiveInt.nullable().optional()
101
+ });
102
+ /** See `KeyframeSettings` in the reactor. */
103
+ const keyframesSchema = z.strictObject({
104
+ default: keyframeRuleSchema.optional(),
105
+ types: z.record(z.string(), keyframeRuleSchema).optional()
106
+ });
97
107
  const storageSchema = z.object({
98
108
  /** Postgres URL or PGlite data dir; unset uses the default dir. */
99
109
  reactor: z.object({ url: z.string().min(1).optional() }).prefault({}),
@@ -109,7 +119,9 @@ const storageSchema = z.object({
109
119
  vacuumFull: vacuumFullSchema.prefault({})
110
120
  }).prefault({}),
111
121
  migratePglite: z.boolean().default(false),
112
- forcePgVersion: z.union([z.literal(16), z.literal(17)]).optional()
122
+ forcePgVersion: z.union([z.literal(16), z.literal(17)]).optional(),
123
+ /** Unset: `reactor.keyframes` of the project config, then the built-in rule. */
124
+ keyframes: keyframesSchema.optional()
113
125
  });
114
126
  const protocolSchema = z.object({
115
127
  featureFlags: z.object({
@@ -123,7 +135,43 @@ const protocolSchema = z.object({
123
135
  unsupportedStoredDocuments: z.enum(["refuse", "read-only"]).default("refuse"),
124
136
  legacyProcessorIds: z.boolean().default(true),
125
137
  maxSkipThreshold: positiveInt.optional(),
126
- catchUpPriority: z.union([z.literal("dynamic"), z.number().int().min(0).max(7)]).default("dynamic")
138
+ catchUpPriority: z.union([z.literal("dynamic"), z.number().int().min(0).max(7)]).default("dynamic"),
139
+ /** What processors record about their time. */
140
+ processorTiming: z.enum([
141
+ "off",
142
+ "basic",
143
+ "detailed"
144
+ ]).default("basic"),
145
+ processorTimingWindowMs: positiveInt.default(6e4),
146
+ /** At `detailed`: an `onOperations` call over this logs a warning. */
147
+ processorSlowBatchMs: positiveInt.default(1e3),
148
+ /** Above 0: logs the slowest processors this often while catching up. */
149
+ processorTimingLogMs: nonNegativeInt.default(0)
150
+ });
151
+ const memoryTelemetrySchema = z.object({
152
+ enabled: z.boolean().default(false),
153
+ intervalMs: z.number().int().min(1e3).default(3e4),
154
+ /** `memory`, the ring, is always on while telemetry runs. */
155
+ outputs: z.array(z.enum([
156
+ "memory",
157
+ "file",
158
+ "console"
159
+ ])).default(["memory", "file"]),
160
+ file: z.object({
161
+ path: z.string().min(1).optional(),
162
+ maxMb: positiveInt.default(10),
163
+ keep: positiveInt.default(5)
164
+ }).prefault({}),
165
+ ringSize: positiveInt.default(720),
166
+ consoleIntervalMs: positiveInt.default(3e5),
167
+ workers: z.boolean().default(true),
168
+ windowMin: positiveInt.default(30)
169
+ });
170
+ const telemetrySchema = z.object({
171
+ memory: memoryTelemetrySchema.prefault({}),
172
+ /** Under it go the JSONL files and heap snapshots; unset: `<phDir>/telemetry`. */
173
+ dir: z.string().min(1).optional(),
174
+ heapSnapshotDir: z.string().min(1).optional()
127
175
  });
128
176
  const authSchema = z.object({
129
177
  enabled: z.boolean().default(false),
@@ -227,6 +275,7 @@ const switchboardConfigSchema = z.object({
227
275
  server: serverSchema.prefault({}),
228
276
  storage: storageSchema.prefault({}),
229
277
  protocol: protocolSchema.prefault({}),
278
+ telemetry: telemetrySchema.prefault({}),
230
279
  auth: authSchema.prefault({}),
231
280
  inspection: inspectionSchema.prefault({}),
232
281
  workers: workersSchema.prefault({}),
@@ -263,5 +312,5 @@ function layerOf(schema, path, omit) {
263
312
  //#endregion
264
313
  export { callerOverEnv as a, switchboardConfigSchema as i, SWITCHBOARD_LOG_LEVELS as n, mergeSwitchboardConfig as o, switchboardConfigLayerSchema as r, SWITCHBOARD_DRIVE_DOCUMENT_TYPES as t };
265
314
 
266
- //# sourceMappingURL=schema-0g_QdOWn.mjs.map
267
- //# debugId=8d779fcc-b20d-513a-b972-c22f71f4667a
315
+ //# sourceMappingURL=schema-XEZrdmag.mjs.map
316
+ //# debugId=4cfd484a-11e3-5f7d-a891-5b7293484d62