@powerhousedao/switchboard 6.3.0-dev.9 → 6.4.0-next.0
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.
- package/.tsbuild/test/boot-helpers.d.ts +2 -1
- package/.tsbuild/test/boot-helpers.d.ts.map +1 -1
- package/.tsbuild/test/boot-identity-files.test.d.ts +2 -0
- package/.tsbuild/test/boot-identity-files.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +48 -0
- package/README.md +11 -9
- package/dist/boot.d.mts +1 -1
- package/dist/boot.mjs +1 -1
- package/dist/config/from-env.d.mts +1 -1
- package/dist/config/from-env.d.mts.map +1 -1
- package/dist/config/from-env.mjs +3 -3
- package/dist/config/schema.d.mts +1 -1
- package/dist/config/schema.mjs +3 -3
- package/dist/{from-env-DKK_wPrO.mjs → from-env-CLImR6qa.mjs} +4 -28
- package/dist/from-env-CLImR6qa.mjs.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/migrate.mjs +9 -4
- package/dist/migrate.mjs.map +1 -1
- package/dist/{plugin-host-tTjDTNz0.d.mts → plugin-host-Z-4Ruypj.d.mts} +19 -2
- package/dist/plugin-host-Z-4Ruypj.d.mts.map +1 -0
- package/dist/plugins/ai.d.mts +1 -1
- package/dist/plugins/attachments.d.mts +1 -1
- package/dist/plugins/attachments.mjs +3 -3
- package/dist/plugins/mcp.d.mts +1 -1
- package/dist/plugins/privacy.d.mts +1 -1
- package/dist/plugins/workflows.d.mts +2 -2
- package/dist/plugins/workflows.mjs +3 -3
- package/dist/{schema-BJ-OFAox.mjs → schema-BbwISVSO.mjs} +15 -13
- package/dist/schema-BbwISVSO.mjs.map +1 -0
- package/dist/{schema-w1lShimw.d.mts → schema-CZsLzAZg.d.mts} +9 -4
- package/dist/schema-CZsLzAZg.d.mts.map +1 -0
- package/dist/{server-BS-PFzoK.mjs → server-BMRdMNvC.mjs} +172 -244
- package/dist/server-BMRdMNvC.mjs.map +1 -0
- package/dist/server.d.mts +2 -2
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +4 -4
- package/dist/{types-Bk4T4D9F.d.mts → types-D-QK3xhO.d.mts} +12 -7
- package/dist/types-D-QK3xhO.d.mts.map +1 -0
- package/dist/{utils-Cm0TE6dP.mjs → utils-D8yHRVjT.mjs} +4 -18
- package/dist/{utils-Cm0TE6dP.mjs.map → utils-D8yHRVjT.mjs.map} +1 -1
- package/dist/utils.d.mts +1 -6
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +4 -4
- package/dist/{workflows-mdYUh3Us.mjs → workflows-D2r6IKou.mjs} +4 -4
- package/dist/{workflows-mdYUh3Us.mjs.map → workflows-D2r6IKou.mjs.map} +1 -1
- package/package.json +17 -17
- package/test/ai-gateway.test.ts +0 -2
- package/test/boot-auth-config.test.ts +1 -1
- package/test/boot-helpers.ts +3 -1
- package/test/boot-identity-files.test.ts +68 -0
- package/test/boot-mcp-auth.test.ts +0 -1
- package/test/boot-mcp-enabled.test.ts +0 -2
- package/test/boot-port-zero.test.ts +1 -2
- package/test/boot-ready-drives.test.ts +1 -2
- package/test/config-from-env.test.ts +0 -9
- package/test/config-merge.test.ts +47 -47
- package/test/config-schema.test.ts +16 -4
- package/test/default-composition.test.ts +61 -65
- package/test/default-drive-protocol-versions.test.ts +13 -6
- package/test/default-drive-slug.test.ts +6 -11
- package/test/plugin-presence.test.ts +15 -16
- package/dist/from-env-DKK_wPrO.mjs.map +0 -1
- package/dist/plugin-host-tTjDTNz0.d.mts.map +0 -1
- package/dist/schema-BJ-OFAox.mjs.map +0 -1
- package/dist/schema-w1lShimw.d.mts.map +0 -1
- package/dist/server-BS-PFzoK.mjs.map +0 -1
- package/dist/types-Bk4T4D9F.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-BbwISVSO.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/**\n * A caller's layer over the env's, keeping each key's pre-config precedence.\n * `declaredComposition`: the caller boots a declared plugin composition.\n */\nexport function callerOverEnv(\n env: Layer,\n caller: Layer,\n options: { declaredComposition?: boolean } = {},\n): 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.\n if (options.declaredComposition === 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.\n */\nconst accessModeSchema = z.string().superRefine((mode, ctx) => {\n if (mode === \"open\" || mode === \"licensed\") return;\n ctx.addIssue({\n code: \"custom\",\n message: `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: off unless a plugin composition lists it. */\n workflows: z.boolean().optional(),\n documentModelSubgraphs: z.boolean().default(true),\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 /** The Renown user file (`.renown.json`); unset: in the `.ph` of\n * `storage.userDataDir` when that is set, else `<cwd>/.ph/.renown.json`. */\n storagePath: 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,UAA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ACrC,IAAI,KAAK,IAAI,EAAE,GAAG;EAClB,MAAM,OAAO,QAAQ,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS;CACjD;CACA,MAAM,WAAW,OAAO,IAAI;CAC5B,OAAO,YAAY,SAAS,IAAI,SAAS,UACrC,EAAE,YAAY,KAAK,IACnB,EAAE,aAAa,KAAK;AAC1B","debug_id":"ba5ddb27-014a-5a1c-8c0a-5e2fdec7c2b5"}
|
|
@@ -5,8 +5,13 @@ import { AttachmentStorageConfig } from "@powerhousedao/reactor-attachments";
|
|
|
5
5
|
type Layer = SwitchboardConfigInput;
|
|
6
6
|
/** Later layers win per key; arrays, maps and unions are replaced whole. */
|
|
7
7
|
declare function mergeSwitchboardConfig(...layers: Layer[]): Layer;
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A caller's layer over the env's, keeping each key's pre-config precedence.
|
|
10
|
+
* `declaredComposition`: the caller boots a declared plugin composition.
|
|
11
|
+
*/
|
|
12
|
+
declare function callerOverEnv(env: Layer, caller: Layer, options?: {
|
|
13
|
+
declaredComposition?: boolean;
|
|
14
|
+
}): Layer;
|
|
10
15
|
//#endregion
|
|
11
16
|
//#region src/config/schema.d.ts
|
|
12
17
|
declare const SWITCHBOARD_LOG_LEVELS: readonly ["verbose", "debug", "info", "warn", "error"];
|
|
@@ -190,7 +195,6 @@ declare const switchboardConfigSchema: z.ZodObject<{
|
|
|
190
195
|
mcp: z.ZodOptional<z.ZodBoolean>;
|
|
191
196
|
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
192
197
|
documentModelSubgraphs: z.ZodDefault<z.ZodBoolean>;
|
|
193
|
-
pluginHost: z.ZodOptional<z.ZodBoolean>;
|
|
194
198
|
privacy: z.ZodPrefault<z.ZodObject<{
|
|
195
199
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
196
200
|
deploymentSecret: z.ZodOptional<z.ZodString>;
|
|
@@ -223,6 +227,7 @@ declare const switchboardConfigSchema: z.ZodObject<{
|
|
|
223
227
|
}, z.core.$strip>>;
|
|
224
228
|
identity: z.ZodOptional<z.ZodObject<{
|
|
225
229
|
keypairPath: z.ZodOptional<z.ZodString>;
|
|
230
|
+
storagePath: z.ZodOptional<z.ZodString>;
|
|
226
231
|
requireExisting: z.ZodOptional<z.ZodBoolean>;
|
|
227
232
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
228
233
|
}, z.core.$strip>>;
|
|
@@ -255,4 +260,4 @@ type ReactorApiSectionsMatch = [Assert<Same<MissingKeys<ReactorApiConfig["server
|
|
|
255
260
|
//#endregion
|
|
256
261
|
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 };
|
|
257
262
|
export {};
|
|
258
|
-
//# sourceMappingURL=schema-
|
|
263
|
+
//# sourceMappingURL=schema-CZsLzAZg.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-CZsLzAZg.d.mts","names":[],"sources":["../src/config/merge.ts","../src/config/schema.ts"],"mappings":";;;;KAEK,QAAQ;;iBAuCG,0BAA0B,QAAQ,UAAU;;;;;iBAU5C,cACd,KAAK,OACL,QAAQ,OACR;EAAW;IACV;;;cCjDU;cAQA;;cAoRA,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,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"}
|
|
@@ -1,15 +1,14 @@
|
|
|
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]="
|
|
3
|
-
import { a as loadNodeFsClass, c as openForVerify, d as ATTACHMENT_URL_SIGNING_SECRET_ENV, f as resolveAttachmentUrlSigning, i as isSupportedMajor, l as pgliteModuleSpec, n as StoredDocumentsRefusedError, o as loadPGliteModule, r as resolveUnsupportedStoredDocuments, s as loadPgDump, t as switchboardConfigFromEnv, u as readPgVersionFile } from "./from-env-
|
|
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]="1dd131ea-419f-5a75-bde7-33a456b885fd")}catch(e){}}();
|
|
3
|
+
import { a as loadNodeFsClass, c as openForVerify, d as ATTACHMENT_URL_SIGNING_SECRET_ENV, f as resolveAttachmentUrlSigning, i as isSupportedMajor, l as pgliteModuleSpec, n as StoredDocumentsRefusedError, o as loadPGliteModule, r as resolveUnsupportedStoredDocuments, s as loadPgDump, t as switchboardConfigFromEnv, u as readPgVersionFile } from "./from-env-CLImR6qa.mjs";
|
|
4
4
|
import { a as resolveWorkerModelSources, l as resolveProjectionWorkerOptions, n as keepImportableSources, o as resolveWorkerPoolOptions, p as workerPoolIssues, s as assertProjectionWorkerSupported, t as buildWorkerDbConfig } from "./worker-pool-gyxJnCxA.mjs";
|
|
5
5
|
import { t as isPostgresUrl } from "./postgres-url-DTDhBjXX.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { _ as triggerFatalShutdown, a as workflowsPlugin, c as WORKFLOW_TELEMETRY_SCOPE, d as isWorkflowSingletonConflict, f as modelManifestSource, g as raiseSigterm, h as installFatalErrorShutdown, l as assertWorkflowPackageLoadable, m as workflowSingletonLossHandler, p as retryWorkflowSingleton, s as WORKFLOW_PACKAGE_NAME, u as composeWorkflowRuntime } from "./workflows-mdYUh3Us.mjs";
|
|
6
|
+
import { i as switchboardConfigSchema, o as mergeSwitchboardConfig } from "./schema-BbwISVSO.mjs";
|
|
7
|
+
import { a as workflowsPlugin, c as WORKFLOW_TELEMETRY_SCOPE, d as modelManifestSource, f as workflowSingletonLossHandler, h as triggerFatalShutdown, l as assertWorkflowPackageLoadable, m as raiseSigterm, p as installFatalErrorShutdown, s as WORKFLOW_PACKAGE_NAME, u as composeWorkflowRuntime } from "./workflows-D2r6IKou.mjs";
|
|
9
8
|
import { t as privacyPlugin } from "./privacy-UodgY0i_.mjs";
|
|
10
9
|
import { t as mcpPlugin } from "./mcp-VW52B8KD.mjs";
|
|
11
10
|
import { n as reactorFeatureFlagsOf, t as renownLayers } from "./renown-layers-DmbWLt46.mjs";
|
|
12
|
-
import {
|
|
11
|
+
import { t as ensureDrive } from "./utils-D8yHRVjT.mjs";
|
|
13
12
|
import { createRequire, register } from "node:module";
|
|
14
13
|
import { metrics, trace } from "@opentelemetry/api";
|
|
15
14
|
import { ReactorInstrumentation } from "@powerhousedao/opentelemetry-instrumentation-reactor";
|
|
@@ -23,7 +22,6 @@ import fs, { promises } from "node:fs";
|
|
|
23
22
|
import path, { join, resolve } from "node:path";
|
|
24
23
|
import { z } from "zod";
|
|
25
24
|
import { httpsHooksPath } from "@powerhousedao/reactor-api/https-hooks";
|
|
26
|
-
import { AttachmentAlreadyExists, AttachmentNotFound, AttachmentPending, AttachmentReferenceReadModel, AttachmentSchemaCompiler, HashMismatch, InvalidAttachmentMetadata, InvalidAttachmentRef, ReservationNotFound, SizeMismatch, UploadTooLarge, createRef, createRemoteAttachmentService, parseAttachmentDownloadTarget, validateReserveMetadata } from "@powerhousedao/reactor-attachments";
|
|
27
25
|
import { createAttachmentClient } from "@powerhousedao/reactor-attachments/client";
|
|
28
26
|
import { DriveNodeView, NodeProcessor, REACTOR_DRIVE_DOCUMENT_TYPE, ReactorDriveClient, createReactorDriveWriteStrategy } from "@powerhousedao/reactor-drive";
|
|
29
27
|
import { REACTOR_DRIVE_SUBGRAPH_NAME, createReactorDriveResolvers, reactorDriveSubgraphTypeDefs } from "@powerhousedao/reactor-drive/subgraph";
|
|
@@ -33,6 +31,7 @@ import { Kysely, PostgresDialect, sql } from "kysely";
|
|
|
33
31
|
import net from "node:net";
|
|
34
32
|
import path$1 from "path";
|
|
35
33
|
import { Pool } from "pg";
|
|
34
|
+
import { AttachmentAlreadyExists, AttachmentNotFound, AttachmentPending, AttachmentReferenceReadModel, AttachmentSchemaCompiler, HashMismatch, InvalidAttachmentMetadata, InvalidAttachmentRef, ReservationNotFound, SizeMismatch, UploadTooLarge, createRef, createRemoteAttachmentService, parseAttachmentDownloadTarget, validateReserveMetadata } from "@powerhousedao/reactor-attachments";
|
|
36
35
|
import { Readable } from "node:stream";
|
|
37
36
|
import { mergeContributions, resolveOrder, runObserveHook, runObserveHookSequential, runTransformHook } from "@powerhousedao/host-core";
|
|
38
37
|
import { defaultStoreDirs, resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
|
|
@@ -223,6 +222,115 @@ async function renameLegacyTables(db, tables) {
|
|
|
223
222
|
});
|
|
224
223
|
}
|
|
225
224
|
//#endregion
|
|
225
|
+
//#region src/workflow/oauth-apps-config.ts
|
|
226
|
+
/**
|
|
227
|
+
* The config file's `workflows.oauthApps`, client file paths made absolute
|
|
228
|
+
* from `dir`, the config file's folder. A malformed entry is left out; a
|
|
229
|
+
* relay that is not an object is dropped and reported, the app kept without
|
|
230
|
+
* it. The relay's fields are checked by the runtime, as for apps a host
|
|
231
|
+
* passes itself.
|
|
232
|
+
*/
|
|
233
|
+
function parseOAuthApps(raw, dir, onDroppedRelay) {
|
|
234
|
+
if (!Array.isArray(raw)) return [];
|
|
235
|
+
const at = (p) => typeof p === "string" && p ? path.resolve(dir, p) : void 0;
|
|
236
|
+
return raw.flatMap((entry) => {
|
|
237
|
+
const app = entry ?? {};
|
|
238
|
+
if (typeof app.id !== "string" || !app.id) return [];
|
|
239
|
+
const desktop = at(app.clients?.desktop);
|
|
240
|
+
const web = at(app.clients?.web);
|
|
241
|
+
let relay;
|
|
242
|
+
if (app.relay !== void 0) {
|
|
243
|
+
if (typeof app.relay === "object" && app.relay !== null && !Array.isArray(app.relay)) relay = app.relay;
|
|
244
|
+
else onDroppedRelay?.(app.id, app.relay);
|
|
245
|
+
}
|
|
246
|
+
return [{
|
|
247
|
+
id: app.id,
|
|
248
|
+
clients: {
|
|
249
|
+
...desktop ? { desktop } : {},
|
|
250
|
+
...web ? { web } : {}
|
|
251
|
+
},
|
|
252
|
+
...relay ? { relay } : {}
|
|
253
|
+
}];
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/attachment-reference-read-model.mts
|
|
258
|
+
const attachmentSchemaCompiler = new AttachmentSchemaCompiler();
|
|
259
|
+
function createAttachmentReferenceReadModel(baseKysely, dependencies, attachmentReferenceWriter) {
|
|
260
|
+
return new AttachmentReferenceReadModel(baseKysely.withSchema(REACTOR_SCHEMA), dependencies.operationIndex, dependencies.writeCache, dependencies.processorManagerConsistencyTracker, dependencies.documentModelRegistry, attachmentSchemaCompiler, attachmentReferenceWriter);
|
|
261
|
+
}
|
|
262
|
+
function registerAttachmentReferenceReadModel(reactorBuilder, registration) {
|
|
263
|
+
reactorBuilder.withReadModelFactory(async ({ documentModelRegistry, operationIndex, writeCache, processorManagerConsistencyTracker }) => {
|
|
264
|
+
const readModel = createAttachmentReferenceReadModel(registration.baseKysely, {
|
|
265
|
+
operationIndex,
|
|
266
|
+
writeCache,
|
|
267
|
+
processorManagerConsistencyTracker,
|
|
268
|
+
documentModelRegistry
|
|
269
|
+
}, registration.attachmentReferenceWriter);
|
|
270
|
+
await readModel.init();
|
|
271
|
+
return readModel;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
async function registerAttachmentReferenceReadModelOnModule(clientModule, attachmentReferenceWriter) {
|
|
275
|
+
const reactorModule = clientModule.reactorModule;
|
|
276
|
+
if (!reactorModule) return {
|
|
277
|
+
status: "unavailable",
|
|
278
|
+
reason: "in-process-reactor-module-unavailable"
|
|
279
|
+
};
|
|
280
|
+
const coordinator = reactorModule.readModelCoordinator;
|
|
281
|
+
if (!supportsLiveReadModelRegistration(coordinator)) return {
|
|
282
|
+
status: "unavailable",
|
|
283
|
+
reason: "live-read-model-registration-unsupported"
|
|
284
|
+
};
|
|
285
|
+
const readModel = createAttachmentReferenceReadModel(reactorModule.database, {
|
|
286
|
+
operationIndex: reactorModule.operationIndex,
|
|
287
|
+
writeCache: reactorModule.writeCache,
|
|
288
|
+
processorManagerConsistencyTracker: reactorModule.processorManagerConsistencyTracker,
|
|
289
|
+
documentModelRegistry: reactorModule.documentModelRegistry
|
|
290
|
+
}, attachmentReferenceWriter);
|
|
291
|
+
await readModel.init();
|
|
292
|
+
coordinator.addReadModel(readModel, "pre_ready");
|
|
293
|
+
await readModel.init();
|
|
294
|
+
return { status: "available" };
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/builder-defaults.mts
|
|
298
|
+
/**
|
|
299
|
+
* Apply switchboard's standard configuration to a reactor + client builder
|
|
300
|
+
* pair. Each piece is opt-out via the options object; defaults mirror what
|
|
301
|
+
* `startSwitchboard` does when building a reactor itself. Mutates both
|
|
302
|
+
* builders in place.
|
|
303
|
+
*
|
|
304
|
+
* Does NOT touch kysely or read models — callers wire those themselves
|
|
305
|
+
* (see `withKysely` / `withReadModelFactory` on the reactor builder).
|
|
306
|
+
*/
|
|
307
|
+
/** The models switchboard always registers alongside package models. */
|
|
308
|
+
function switchboardBaseDocumentModels() {
|
|
309
|
+
return baseDocumentModels.map(([, model]) => model);
|
|
310
|
+
}
|
|
311
|
+
function applySwitchboardReactorDefaults(reactorBuilder, clientBuilder, options = {}) {
|
|
312
|
+
const baseModels = options.includeBaseModels !== false ? switchboardBaseDocumentModels() : [];
|
|
313
|
+
const extra = options.documentModels ?? [];
|
|
314
|
+
if (baseModels.length || extra.length) reactorBuilder.withDocumentModelSources(getUniqueDocumentModels(baseModels, extra));
|
|
315
|
+
if (options.upgradeManifests?.length) reactorBuilder.withUpgradeManifests(options.upgradeManifests);
|
|
316
|
+
const scheme = options.channelScheme === void 0 ? ChannelScheme.SWITCHBOARD : options.channelScheme;
|
|
317
|
+
if (scheme !== false) reactorBuilder.withChannelScheme(scheme);
|
|
318
|
+
if (options.signalHandlers !== false) reactorBuilder.withSignalHandlers();
|
|
319
|
+
if (options.executorConfig?.maxSkipThreshold !== void 0 || options.executorConfig?.featureFlags !== void 0) reactorBuilder.withExecutorConfig({
|
|
320
|
+
...options.executorConfig.maxSkipThreshold !== void 0 ? { maxSkipThreshold: options.executorConfig.maxSkipThreshold } : {},
|
|
321
|
+
...options.executorConfig.featureFlags !== void 0 ? { featureFlags: options.executorConfig.featureFlags } : {}
|
|
322
|
+
});
|
|
323
|
+
if (options.documentModelLoader) reactorBuilder.withDocumentModelLoader(options.documentModelLoader);
|
|
324
|
+
if (options.logger) reactorBuilder.withLogger(options.logger);
|
|
325
|
+
if (options.signer) {
|
|
326
|
+
clientBuilder.withSigner(options.signer);
|
|
327
|
+
reactorBuilder.withSigner(options.signer.signer, options.signer.workerSigner);
|
|
328
|
+
}
|
|
329
|
+
if (options.createSignaturePolicy) clientBuilder.withCreateSignaturePolicy(options.createSignaturePolicy);
|
|
330
|
+
const trust = options.trustPolicy ?? options.signer;
|
|
331
|
+
if (trust?.trustPolicy) reactorBuilder.withTrustPolicy(trust.trustPolicy, trust.workerTrustPolicy);
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
226
334
|
//#region src/attachments/auth.ts
|
|
227
335
|
const ANONYMOUS_ACTOR = {
|
|
228
336
|
user: void 0,
|
|
@@ -863,115 +971,6 @@ function signerFromEnvironment(backend, env) {
|
|
|
863
971
|
return signing.signer;
|
|
864
972
|
}
|
|
865
973
|
//#endregion
|
|
866
|
-
//#region src/workflow/oauth-apps-config.ts
|
|
867
|
-
/**
|
|
868
|
-
* The config file's `workflows.oauthApps`, client file paths made absolute
|
|
869
|
-
* from `dir`, the config file's folder. A malformed entry is left out; a
|
|
870
|
-
* relay that is not an object is dropped and reported, the app kept without
|
|
871
|
-
* it. The relay's fields are checked by the runtime, as for apps a host
|
|
872
|
-
* passes itself.
|
|
873
|
-
*/
|
|
874
|
-
function parseOAuthApps(raw, dir, onDroppedRelay) {
|
|
875
|
-
if (!Array.isArray(raw)) return [];
|
|
876
|
-
const at = (p) => typeof p === "string" && p ? path.resolve(dir, p) : void 0;
|
|
877
|
-
return raw.flatMap((entry) => {
|
|
878
|
-
const app = entry ?? {};
|
|
879
|
-
if (typeof app.id !== "string" || !app.id) return [];
|
|
880
|
-
const desktop = at(app.clients?.desktop);
|
|
881
|
-
const web = at(app.clients?.web);
|
|
882
|
-
let relay;
|
|
883
|
-
if (app.relay !== void 0) {
|
|
884
|
-
if (typeof app.relay === "object" && app.relay !== null && !Array.isArray(app.relay)) relay = app.relay;
|
|
885
|
-
else onDroppedRelay?.(app.id, app.relay);
|
|
886
|
-
}
|
|
887
|
-
return [{
|
|
888
|
-
id: app.id,
|
|
889
|
-
clients: {
|
|
890
|
-
...desktop ? { desktop } : {},
|
|
891
|
-
...web ? { web } : {}
|
|
892
|
-
},
|
|
893
|
-
...relay ? { relay } : {}
|
|
894
|
-
}];
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
//#endregion
|
|
898
|
-
//#region src/attachment-reference-read-model.mts
|
|
899
|
-
const attachmentSchemaCompiler = new AttachmentSchemaCompiler();
|
|
900
|
-
function createAttachmentReferenceReadModel(baseKysely, dependencies, attachmentReferenceWriter) {
|
|
901
|
-
return new AttachmentReferenceReadModel(baseKysely.withSchema(REACTOR_SCHEMA), dependencies.operationIndex, dependencies.writeCache, dependencies.processorManagerConsistencyTracker, dependencies.documentModelRegistry, attachmentSchemaCompiler, attachmentReferenceWriter);
|
|
902
|
-
}
|
|
903
|
-
function registerAttachmentReferenceReadModel(reactorBuilder, registration) {
|
|
904
|
-
reactorBuilder.withReadModelFactory(async ({ documentModelRegistry, operationIndex, writeCache, processorManagerConsistencyTracker }) => {
|
|
905
|
-
const readModel = createAttachmentReferenceReadModel(registration.baseKysely, {
|
|
906
|
-
operationIndex,
|
|
907
|
-
writeCache,
|
|
908
|
-
processorManagerConsistencyTracker,
|
|
909
|
-
documentModelRegistry
|
|
910
|
-
}, registration.attachmentReferenceWriter);
|
|
911
|
-
await readModel.init();
|
|
912
|
-
return readModel;
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
async function registerAttachmentReferenceReadModelOnModule(clientModule, attachmentReferenceWriter) {
|
|
916
|
-
const reactorModule = clientModule.reactorModule;
|
|
917
|
-
if (!reactorModule) return {
|
|
918
|
-
status: "unavailable",
|
|
919
|
-
reason: "in-process-reactor-module-unavailable"
|
|
920
|
-
};
|
|
921
|
-
const coordinator = reactorModule.readModelCoordinator;
|
|
922
|
-
if (!supportsLiveReadModelRegistration(coordinator)) return {
|
|
923
|
-
status: "unavailable",
|
|
924
|
-
reason: "live-read-model-registration-unsupported"
|
|
925
|
-
};
|
|
926
|
-
const readModel = createAttachmentReferenceReadModel(reactorModule.database, {
|
|
927
|
-
operationIndex: reactorModule.operationIndex,
|
|
928
|
-
writeCache: reactorModule.writeCache,
|
|
929
|
-
processorManagerConsistencyTracker: reactorModule.processorManagerConsistencyTracker,
|
|
930
|
-
documentModelRegistry: reactorModule.documentModelRegistry
|
|
931
|
-
}, attachmentReferenceWriter);
|
|
932
|
-
await readModel.init();
|
|
933
|
-
coordinator.addReadModel(readModel, "pre_ready");
|
|
934
|
-
await readModel.init();
|
|
935
|
-
return { status: "available" };
|
|
936
|
-
}
|
|
937
|
-
//#endregion
|
|
938
|
-
//#region src/builder-defaults.mts
|
|
939
|
-
/**
|
|
940
|
-
* Apply switchboard's standard configuration to a reactor + client builder
|
|
941
|
-
* pair. Each piece is opt-out via the options object; defaults mirror what
|
|
942
|
-
* `startSwitchboard` does when building a reactor itself. Mutates both
|
|
943
|
-
* builders in place.
|
|
944
|
-
*
|
|
945
|
-
* Does NOT touch kysely or read models — callers wire those themselves
|
|
946
|
-
* (see `withKysely` / `withReadModelFactory` on the reactor builder).
|
|
947
|
-
*/
|
|
948
|
-
/** The models switchboard always registers alongside package models. */
|
|
949
|
-
function switchboardBaseDocumentModels() {
|
|
950
|
-
return baseDocumentModels.map(([, model]) => model);
|
|
951
|
-
}
|
|
952
|
-
function applySwitchboardReactorDefaults(reactorBuilder, clientBuilder, options = {}) {
|
|
953
|
-
const baseModels = options.includeBaseModels !== false ? switchboardBaseDocumentModels() : [];
|
|
954
|
-
const extra = options.documentModels ?? [];
|
|
955
|
-
if (baseModels.length || extra.length) reactorBuilder.withDocumentModelSources(getUniqueDocumentModels(baseModels, extra));
|
|
956
|
-
if (options.upgradeManifests?.length) reactorBuilder.withUpgradeManifests(options.upgradeManifests);
|
|
957
|
-
const scheme = options.channelScheme === void 0 ? ChannelScheme.SWITCHBOARD : options.channelScheme;
|
|
958
|
-
if (scheme !== false) reactorBuilder.withChannelScheme(scheme);
|
|
959
|
-
if (options.signalHandlers !== false) reactorBuilder.withSignalHandlers();
|
|
960
|
-
if (options.executorConfig?.maxSkipThreshold !== void 0 || options.executorConfig?.featureFlags !== void 0) reactorBuilder.withExecutorConfig({
|
|
961
|
-
...options.executorConfig.maxSkipThreshold !== void 0 ? { maxSkipThreshold: options.executorConfig.maxSkipThreshold } : {},
|
|
962
|
-
...options.executorConfig.featureFlags !== void 0 ? { featureFlags: options.executorConfig.featureFlags } : {}
|
|
963
|
-
});
|
|
964
|
-
if (options.documentModelLoader) reactorBuilder.withDocumentModelLoader(options.documentModelLoader);
|
|
965
|
-
if (options.logger) reactorBuilder.withLogger(options.logger);
|
|
966
|
-
if (options.signer) {
|
|
967
|
-
clientBuilder.withSigner(options.signer);
|
|
968
|
-
reactorBuilder.withSigner(options.signer.signer, options.signer.workerSigner);
|
|
969
|
-
}
|
|
970
|
-
if (options.createSignaturePolicy) clientBuilder.withCreateSignaturePolicy(options.createSignaturePolicy);
|
|
971
|
-
const trust = options.trustPolicy ?? options.signer;
|
|
972
|
-
if (trust?.trustPolicy) reactorBuilder.withTrustPolicy(trust.trustPolicy, trust.workerTrustPolicy);
|
|
973
|
-
}
|
|
974
|
-
//#endregion
|
|
975
974
|
//#region src/plugins/attachments.mts
|
|
976
975
|
/** No entry config: presence is the whole activation. A typo'd config key
|
|
977
976
|
* fails at resolution instead of being silently ignored. */
|
|
@@ -1055,6 +1054,15 @@ function defaultSwitchboardPlugins(switches) {
|
|
|
1055
1054
|
return true;
|
|
1056
1055
|
});
|
|
1057
1056
|
}
|
|
1057
|
+
/**
|
|
1058
|
+
* The notice for a boot that `workflows.enabled` in powerhouse.config.json
|
|
1059
|
+
* switched workflows on before 6.4: no declared composition, and neither
|
|
1060
|
+
* PH_WORKFLOWS_ENABLED nor the caller says anything. The key no longer does.
|
|
1061
|
+
*/
|
|
1062
|
+
function configFileWorkflowsNotice(boot) {
|
|
1063
|
+
if (boot.declaredComposition || boot.workflows !== void 0 || boot.configFileEnabled !== true) return;
|
|
1064
|
+
return "powerhouse.config.json workflows.enabled no longer switches workflows on in Switchboard since 6.4, so they stay off. Set PH_WORKFLOWS_ENABLED=1, or list \"@powerhousedao/switchboard/plugins/workflows\" under runner.plugins in hosts/switchboard/host.js.";
|
|
1065
|
+
}
|
|
1058
1066
|
function createSwitchboardPluginHost(ctx, resolved) {
|
|
1059
1067
|
resolved ??= builtinSwitchboardPlugins();
|
|
1060
1068
|
const ordered = resolveOrder(resolved.map((r) => r.plugin));
|
|
@@ -1757,13 +1765,6 @@ function resolveKeyframes(configured, fromFile, configPath) {
|
|
|
1757
1765
|
if (configured) return configured;
|
|
1758
1766
|
return fromFile === void 0 ? void 0 : parseKeyframeSettings(fromFile, `${configPath} reactor.keyframes`);
|
|
1759
1767
|
}
|
|
1760
|
-
function readConfigWorkflowsEnabled(configPath) {
|
|
1761
|
-
try {
|
|
1762
|
-
return getConfig(configPath).workflows?.enabled ?? false;
|
|
1763
|
-
} catch {
|
|
1764
|
-
return false;
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
1768
|
async function resolveServerPort(requested, strictPort, logger) {
|
|
1768
1769
|
if (requested === 0 || strictPort) return requested;
|
|
1769
1770
|
for (let i = 0; i < PORT_FALLBACK_ATTEMPTS; i++) {
|
|
@@ -1855,23 +1856,21 @@ async function captureInSentry(error) {
|
|
|
1855
1856
|
}
|
|
1856
1857
|
async function initServer(requestedPort, options, config, renown, renownConfig, reportError, opening) {
|
|
1857
1858
|
const { dev, packages = [], remoteDrives = [], logger = defaultLogger } = options;
|
|
1858
|
-
const pluginHost =
|
|
1859
|
+
const pluginHost = createSwitchboardPluginHost({
|
|
1859
1860
|
logger,
|
|
1860
1861
|
options,
|
|
1861
1862
|
config,
|
|
1862
1863
|
renown
|
|
1863
|
-
},
|
|
1864
|
+
}, options.pluginComposition ?? defaultSwitchboardPlugins({
|
|
1864
1865
|
mcp: options.mcp !== false,
|
|
1865
1866
|
workflows: options.workflows?.enabled === true
|
|
1866
1867
|
}));
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
options.workflows
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
};
|
|
1874
|
-
}
|
|
1868
|
+
options = await pluginHost.transformOptions(options);
|
|
1869
|
+
options.mcp ??= false;
|
|
1870
|
+
options.workflows = {
|
|
1871
|
+
...options.workflows,
|
|
1872
|
+
enabled: options.workflows?.enabled === true
|
|
1873
|
+
};
|
|
1875
1874
|
logger.level = config.logLevel;
|
|
1876
1875
|
const dbPath = config.storage.readModel.url;
|
|
1877
1876
|
const reactorDbUrl = config.storage.reactor.url;
|
|
@@ -1960,7 +1959,6 @@ async function initServer(requestedPort, options, config, renown, renownConfig,
|
|
|
1960
1959
|
raiseSigterm();
|
|
1961
1960
|
};
|
|
1962
1961
|
const workflowsEnabled = options.workflows?.enabled === true;
|
|
1963
|
-
const privacyConfig = pluginHost ? { enabled: false } : resolvePrivacy(options.privacy, {});
|
|
1964
1962
|
if (workflowsEnabled) {
|
|
1965
1963
|
await assertWorkflowPackageLoadable();
|
|
1966
1964
|
if (!packages.includes("@powerhousedao/workflow")) packages.push(WORKFLOW_PACKAGE_NAME);
|
|
@@ -2279,30 +2277,20 @@ async function initServer(requestedPort, options, config, renown, renownConfig,
|
|
|
2279
2277
|
localCredentialCheck = createLocalCredentialVerifier(localRenownRequest, { onError: (error) => logger.error("Renown read model query failed: @error", error) });
|
|
2280
2278
|
logger.info("Renown credentials will be verified against this switchboard's own renown read model");
|
|
2281
2279
|
}
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
await pluginHost.observe("onHttpMounting");
|
|
2287
|
-
attachmentService = pluginHost.ctx.attachmentService;
|
|
2288
|
-
} else {
|
|
2289
|
-
registerAttachmentRoutes(api, { config: config.attachments });
|
|
2290
|
-
attachmentService = createRemoteAttachmentService(deriveAttachmentServiceConfig(options, serverPort, renown));
|
|
2291
|
-
}
|
|
2280
|
+
pluginHost.ctx.api = api;
|
|
2281
|
+
pluginHost.ctx.serverPort = serverPort;
|
|
2282
|
+
await pluginHost.observe("onHttpMounting");
|
|
2283
|
+
const attachmentService = pluginHost.ctx.attachmentService;
|
|
2292
2284
|
if (process.env.SENTRY_DSN) api.httpAdapter.setupSentryErrorHandler(await import("@sentry/node"));
|
|
2293
2285
|
const { client, read, write, graphqlManager, documentModelRegistry } = api;
|
|
2294
2286
|
const lateSubgraphs = [];
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
await pluginHost.observe("onReactorReady");
|
|
2303
|
-
}
|
|
2304
|
-
let workflows;
|
|
2305
|
-
let workflowsRetry;
|
|
2287
|
+
pluginHost.ctx.client = client;
|
|
2288
|
+
pluginHost.ctx.read = read;
|
|
2289
|
+
pluginHost.ctx.write = write;
|
|
2290
|
+
pluginHost.ctx.graphqlManager = graphqlManager;
|
|
2291
|
+
pluginHost.ctx.lateSubgraphs = lateSubgraphs;
|
|
2292
|
+
pluginHost.ctx.reactorClientModule = options.reactor ?? ownedReactorModule;
|
|
2293
|
+
await pluginHost.observe("onReactorReady");
|
|
2306
2294
|
const composeWorkflows = () => composeWorkflowRuntime({
|
|
2307
2295
|
reactorClient: client,
|
|
2308
2296
|
clientModule: options.reactor ?? ownedReactorModule,
|
|
@@ -2345,85 +2333,22 @@ async function initServer(requestedPort, options, config, renown, renownConfig,
|
|
|
2345
2333
|
reportFailure(reporting, error, "Failed to register workflow-runtime subgraph: @error");
|
|
2346
2334
|
});
|
|
2347
2335
|
};
|
|
2348
|
-
|
|
2349
|
-
workflows
|
|
2336
|
+
pluginHost.ctx.workflowsOrchestration = {
|
|
2337
|
+
enabled: options.workflows?.enabled === true,
|
|
2338
|
+
composeWorkflows,
|
|
2339
|
+
registerWorkflowSubgraph,
|
|
2340
|
+
updateRouter: () => graphqlManager.updateRouter(true),
|
|
2341
|
+
reportMountFailure: (error) => reportFailure(reporting, error, "Mounting the late workflow-runtime subgraph failed: @error"),
|
|
2342
|
+
setWorkflowsFact: () => api.inspection?.facts.setWorkflows(true)
|
|
2343
|
+
};
|
|
2344
|
+
try {
|
|
2345
|
+
await pluginHost.observe("onSubgraphsRegistering");
|
|
2350
2346
|
} catch (error) {
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
try {
|
|
2357
|
-
await composed.start();
|
|
2358
|
-
} catch (error) {
|
|
2359
|
-
try {
|
|
2360
|
-
await composed.stop();
|
|
2361
|
-
} catch (stopError) {
|
|
2362
|
-
logger.error("Stopping the late workflow runtime failed: @error", stopError);
|
|
2363
|
-
}
|
|
2364
|
-
throw error;
|
|
2365
|
-
}
|
|
2366
|
-
logger.info("Workflow runtime started");
|
|
2367
|
-
workflows = composed;
|
|
2368
|
-
await registerWorkflowSubgraph(composed);
|
|
2369
|
-
try {
|
|
2370
|
-
await graphqlManager.updateRouter(true);
|
|
2371
|
-
} catch (error) {
|
|
2372
|
-
reportFailure(reporting, error, "Mounting the late workflow-runtime subgraph failed: @error");
|
|
2373
|
-
}
|
|
2374
|
-
},
|
|
2375
|
-
logger
|
|
2376
|
-
});
|
|
2377
|
-
}
|
|
2378
|
-
if (workflows) {
|
|
2379
|
-
lateSubgraphs.push(registerWorkflowSubgraph(workflows));
|
|
2380
|
-
const runtime = workflows;
|
|
2381
|
-
await withProgressHeartbeat({
|
|
2382
|
-
logger,
|
|
2383
|
-
label: "Starting the workflow runtime"
|
|
2384
|
-
}, () => runtime.start());
|
|
2385
|
-
logger.info("Workflow runtime started");
|
|
2386
|
-
api.inspection?.facts.setWorkflows(true);
|
|
2387
|
-
}
|
|
2388
|
-
if (pluginHost) {
|
|
2389
|
-
pluginHost.ctx.workflowsOrchestration = {
|
|
2390
|
-
enabled: options.workflows?.enabled === true,
|
|
2391
|
-
composeWorkflows,
|
|
2392
|
-
registerWorkflowSubgraph,
|
|
2393
|
-
updateRouter: () => graphqlManager.updateRouter(true),
|
|
2394
|
-
reportMountFailure: (error) => reportFailure(reporting, error, "Mounting the late workflow-runtime subgraph failed: @error"),
|
|
2395
|
-
setWorkflowsFact: () => api.inspection?.facts.setWorkflows(true)
|
|
2396
|
-
};
|
|
2397
|
-
try {
|
|
2398
|
-
await pluginHost.observe("onSubgraphsRegistering");
|
|
2399
|
-
} catch (error) {
|
|
2400
|
-
await pluginHost.ctx.workflowsRetry?.stop();
|
|
2401
|
-
await pluginHost.ctx.workflows?.stop();
|
|
2402
|
-
await pluginHost.ctx.privacy?.stop();
|
|
2403
|
-
await abortBoot(api);
|
|
2404
|
-
throw error;
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
let privacy;
|
|
2408
|
-
if (!pluginHost && privacyConfig.enabled) {
|
|
2409
|
-
const signer = options.reactor ? options.privacy?.signer : options.privacy?.signer ?? renown?.signer;
|
|
2410
|
-
try {
|
|
2411
|
-
privacy = await startPrivacy({
|
|
2412
|
-
config: privacyConfig,
|
|
2413
|
-
reactorModule: (options.reactor ?? ownedReactorModule)?.reactorModule,
|
|
2414
|
-
signer,
|
|
2415
|
-
authorizationService: api.authorizationService,
|
|
2416
|
-
documentPermissionService: api.documentPermissionService,
|
|
2417
|
-
graphqlManager,
|
|
2418
|
-
readClient: read,
|
|
2419
|
-
logger: logger.child(["privacy"])
|
|
2420
|
-
});
|
|
2421
|
-
} catch (error) {
|
|
2422
|
-
await workflowsRetry?.stop();
|
|
2423
|
-
await workflows?.stop();
|
|
2424
|
-
await abortBoot(api);
|
|
2425
|
-
throw error;
|
|
2426
|
-
}
|
|
2347
|
+
await pluginHost.ctx.workflowsRetry?.stop();
|
|
2348
|
+
await pluginHost.ctx.workflows?.stop();
|
|
2349
|
+
await pluginHost.ctx.privacy?.stop();
|
|
2350
|
+
await abortBoot(api);
|
|
2351
|
+
throw error;
|
|
2427
2352
|
}
|
|
2428
2353
|
const stopCatchUpLoad = ownedReactorModule ? feedCatchUpPriority(catchUpPriority, api.httpServer) : () => {};
|
|
2429
2354
|
const stopTimingLog = startOwnedTimingLog(ownedReactorModule?.reactorModule, processorTiming, config.protocol.processorTimingLogMs, reactorLogger);
|
|
@@ -2433,10 +2358,7 @@ async function initServer(requestedPort, options, config, renown, renownConfig,
|
|
|
2433
2358
|
stopCatchUpLoad();
|
|
2434
2359
|
stopTimingLog();
|
|
2435
2360
|
memoryTelemetry.stop();
|
|
2436
|
-
|
|
2437
|
-
await privacy?.stop();
|
|
2438
|
-
await workflowsRetry?.stop();
|
|
2439
|
-
await workflows?.stop();
|
|
2361
|
+
await pluginHost.observe("onShutdown");
|
|
2440
2362
|
await api.dispose();
|
|
2441
2363
|
})();
|
|
2442
2364
|
apiRef.current = { dispose: drainApi };
|
|
@@ -2530,7 +2452,7 @@ async function initServer(requestedPort, options, config, renown, renownConfig,
|
|
|
2530
2452
|
if (!defaultDriveUrl && driveId) defaultDriveUrl = `${options.https ? "https" : "http"}://localhost:${serverPort}/d/${driveId}`;
|
|
2531
2453
|
}
|
|
2532
2454
|
}
|
|
2533
|
-
|
|
2455
|
+
await pluginHost.observe("onDrivesReady");
|
|
2534
2456
|
return {
|
|
2535
2457
|
defaultDriveUrl,
|
|
2536
2458
|
api,
|
|
@@ -2538,12 +2460,12 @@ async function initServer(requestedPort, options, config, renown, renownConfig,
|
|
|
2538
2460
|
attachmentService,
|
|
2539
2461
|
attachmentReferenceProjection: api.attachmentReferenceProjection,
|
|
2540
2462
|
get workflowTriggers() {
|
|
2541
|
-
return
|
|
2463
|
+
return pluginHost.ctx.workflows?.triggers;
|
|
2542
2464
|
},
|
|
2543
2465
|
workflowsEnabled,
|
|
2544
2466
|
modelManifest: () => workerModels?.modelManifest() ?? [],
|
|
2545
2467
|
privacy: (() => {
|
|
2546
|
-
const running =
|
|
2468
|
+
const running = pluginHost.ctx.privacy;
|
|
2547
2469
|
return running ? { erasure: running.erasure } : void 0;
|
|
2548
2470
|
})(),
|
|
2549
2471
|
mcpEnabled: options.mcp !== false,
|
|
@@ -2585,10 +2507,16 @@ const startSwitchboard = async (input = {}, deps = {}) => {
|
|
|
2585
2507
|
if (process.env.PYROSCOPE_SERVER_ADDRESS) await initProfilerFromEnv(process.env).catch((error) => logger.error("Error starting profiler: @error", error));
|
|
2586
2508
|
const serverPort = await resolveServerPort(config.server.port, config.server.strictPort, logger);
|
|
2587
2509
|
const options = serverOptionsOf(config, deps);
|
|
2588
|
-
if (
|
|
2510
|
+
if (options.pluginComposition === void 0) {
|
|
2589
2511
|
options.mcp = config.features.mcp ?? true;
|
|
2590
|
-
options.workflows = { enabled: config.features.workflows ??
|
|
2512
|
+
options.workflows = { enabled: config.features.workflows ?? false };
|
|
2591
2513
|
}
|
|
2514
|
+
const workflowsNotice = configFileWorkflowsNotice({
|
|
2515
|
+
declaredComposition: options.pluginComposition !== void 0,
|
|
2516
|
+
workflows: config.features.workflows,
|
|
2517
|
+
configFileEnabled: fileConfig.workflows?.enabled
|
|
2518
|
+
});
|
|
2519
|
+
if (workflowsNotice) logger.warn(workflowsNotice);
|
|
2592
2520
|
const renownConfig = resolveRenownConfig(renownLayers(fileConfig.auth?.renown, config.auth.renown), {}, logger);
|
|
2593
2521
|
const userDataDir = config.storage.userDataDir;
|
|
2594
2522
|
options.identity = {
|
|
@@ -2748,5 +2676,5 @@ function feedCatchUpPriority(priority, server) {
|
|
|
2748
2676
|
//#endregion
|
|
2749
2677
|
export { resolveKeyframes as a, attachmentsPlugin as c, initProfilerFromEnv as d, isPortAvailable as i, attachmentsPluginConfigSchema as l, deriveAttachmentServiceConfig as n, resolvePgliteStorageDirs as o, initSwitchboardProcess as r, startSwitchboard as s, createReactorKysely as t, applySwitchboardReactorDefaults as u };
|
|
2750
2678
|
|
|
2751
|
-
//# sourceMappingURL=server-
|
|
2752
|
-
//# debugId=
|
|
2679
|
+
//# sourceMappingURL=server-BMRdMNvC.mjs.map
|
|
2680
|
+
//# debugId=1dd131ea-419f-5a75-bde7-33a456b885fd
|