@powerhousedao/switchboard 6.2.3-dev.70 → 6.2.3-dev.72
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/default-drive-slug.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/port-probe.test.d.ts +2 -0
- package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
- package/.tsbuild/test/shutdown.test.d.ts +2 -0
- package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
- package/.tsbuild/test/store-lock.test.d.ts +2 -0
- package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +44 -0
- package/dist/index.mjs +1 -1
- package/dist/{mcp-cNWW82NH.mjs → mcp-SsBK14Jm.mjs} +10 -5
- package/dist/mcp-SsBK14Jm.mjs.map +1 -0
- package/dist/plugins/attachments.d.mts +10 -0
- package/dist/plugins/attachments.d.mts.map +1 -1
- package/dist/plugins/attachments.mjs +4 -4
- package/dist/plugins/mcp.d.mts +10 -0
- package/dist/plugins/mcp.d.mts.map +1 -1
- package/dist/plugins/mcp.mjs +4 -4
- package/dist/plugins/privacy.d.mts +10 -0
- package/dist/plugins/privacy.d.mts.map +1 -1
- package/dist/plugins/privacy.mjs +4 -4
- package/dist/plugins/workflows.d.mts +46 -3
- package/dist/plugins/workflows.d.mts.map +1 -1
- package/dist/plugins/workflows.mjs +4 -4
- package/dist/{privacy-C8KVimKF.mjs → privacy-BsFl7GzK.mjs} +9 -4
- package/dist/{privacy-C8KVimKF.mjs.map → privacy-BsFl7GzK.mjs.map} +1 -1
- package/dist/{server-CF_mjyJi.mjs → server-CrWPtMG6.mjs} +114 -29
- package/dist/server-CrWPtMG6.mjs.map +1 -0
- package/dist/server.d.mts +18 -15
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +3 -3
- package/dist/{utils-uaBlzyjS.mjs → utils-Dh845exv.mjs} +42 -9
- package/dist/utils-Dh845exv.mjs.map +1 -0
- package/dist/utils.d.mts +8 -2
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +3 -3
- package/dist/{workflows-qKtqZhn3.mjs → workflows-fsBcElEi.mjs} +111 -67
- package/dist/{workflows-qKtqZhn3.mjs.map → workflows-fsBcElEi.mjs.map} +1 -1
- package/package.json +18 -17
- package/test/attachments/routes.test.ts +26 -11
- package/test/default-drive-slug.test.ts +97 -0
- package/test/plugin-config-schemas.test.ts +83 -0
- package/test/port-probe.test.ts +45 -0
- package/test/shutdown.test.ts +278 -0
- package/test/store-lock.test.ts +65 -0
- package/test/workflows-plugin-config.test.ts +77 -0
- package/dist/mcp-cNWW82NH.mjs.map +0 -1
- package/dist/server-CF_mjyJi.mjs.map +0 -1
- package/dist/utils-uaBlzyjS.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
## 6.2.3-dev.72 (2026-10-23)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **shared,connect,codegen:** ph init and ph migrate give a project the router as a peer at connect's version, and the host stylesheet shows light and dark tokens ([0829546eaf](https://github.com/powerhouse-inc/powerhouse/commit/0829546eaf))
|
|
6
|
+
|
|
7
|
+
### 🩹 Fixes
|
|
8
|
+
|
|
9
|
+
- **switchboard:** one process per PGlite store ([a2283f4a52](https://github.com/powerhouse-inc/powerhouse/commit/a2283f4a52))
|
|
10
|
+
- **reactor-attachments,switchboard:** an empty file is a valid attachment ([223d231756](https://github.com/powerhouse-inc/powerhouse/commit/223d231756))
|
|
11
|
+
|
|
12
|
+
### ❤️ Thank You
|
|
13
|
+
|
|
14
|
+
- acaldas
|
|
15
|
+
- Claude Opus 5.5
|
|
16
|
+
- Wouter Kampmann
|
|
17
|
+
|
|
18
|
+
## 6.2.3-dev.71 (2026-10-22)
|
|
19
|
+
|
|
20
|
+
### 🚀 Features
|
|
21
|
+
|
|
22
|
+
- **shared,design-system,workflow,vetra,powerhouse-vetra-packages,connect:** bundled packages leave their dependencies to Connect's build, which includes each once ([74bf2d8b37](https://github.com/powerhouse-inc/powerhouse/commit/74bf2d8b37))
|
|
23
|
+
- **desktop:** vendor local package tarballs into the stack (PH_DESKTOP_LOCAL_PACKAGES) ([000bc39d10](https://github.com/powerhouse-inc/powerhouse/commit/000bc39d10))
|
|
24
|
+
- **ph-cli:** runners export declared + resolved host schemas; compound members leave Ctrl-C to the compound ([4dc7c40322](https://github.com/powerhouse-inc/powerhouse/commit/4dc7c40322))
|
|
25
|
+
- **codegen:** pure builders for generated outputs.js/.d.ts and the hosts typing files ([be3c35122f](https://github.com/powerhouse-inc/powerhouse/commit/be3c35122f))
|
|
26
|
+
- **switchboard:** shutdown() stops the owned reactor, idempotently ([26b46c1a36](https://github.com/powerhouse-inc/powerhouse/commit/26b46c1a36))
|
|
27
|
+
- **switchboard:** typed configSchema and PHPluginConfigs entry for every built-in plugin ([ed25110339](https://github.com/powerhouse-inc/powerhouse/commit/ed25110339))
|
|
28
|
+
- **connect,desktop:** layered backgrounds for the home screen and the loading page ([9ffe4915b4](https://github.com/powerhouse-inc/powerhouse/commit/9ffe4915b4))
|
|
29
|
+
- **host-core,ph-cli,switchboard,connect,codegen:** workflow plugins declare the drive and the link ([ab37f30600](https://github.com/powerhouse-inc/powerhouse/commit/ab37f30600))
|
|
30
|
+
|
|
31
|
+
### 🩹 Fixes
|
|
32
|
+
|
|
33
|
+
- **switchboard:** the port probe falls back to ipv4 on a host without ipv6, and names the port when it fails ([a18c187faa](https://github.com/powerhouse-inc/powerhouse/commit/a18c187faa))
|
|
34
|
+
- **switchboard,reactor-api,ph-cli:** a slug another document holds is never moved: a default drive reuses a drive that holds it or is logged and skipped, and graphql creates refuse it ([245cc68e6c](https://github.com/powerhouse-inc/powerhouse/commit/245cc68e6c))
|
|
35
|
+
- **switchboard:** an aborted boot stops the owned reactor through its shutdown ([ac4d0b05bf](https://github.com/powerhouse-inc/powerhouse/commit/ac4d0b05bf))
|
|
36
|
+
|
|
37
|
+
### ❤️ Thank You
|
|
38
|
+
|
|
39
|
+
- acaldas
|
|
40
|
+
- Benjamin Jordan
|
|
41
|
+
- Claude Fable 5.1
|
|
42
|
+
- Claude Opus 5.5
|
|
43
|
+
- Wouter Kampmann
|
|
44
|
+
|
|
1
45
|
## 6.2.3-dev.70 (2026-10-22)
|
|
2
46
|
|
|
3
47
|
### 🚀 Features
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
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]="c9eef974-47b1-5e45-aad6-5ebb1885b76a")}catch(e){}}();
|
|
4
|
-
import { a as startSwitchboard, d as
|
|
4
|
+
import { a as startSwitchboard, d as initProfilerFromEnv, f as parseForcePgVersion, o as StoredDocumentsRefusedError } from "./server-CrWPtMG6.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
7
7
|
import { ExpressInstrumentation } from "@opentelemetry/instrumentation-express";
|
|
@@ -1,4 +1,10 @@
|
|
|
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]="54d61ec8-8bfa-5067-b1a5-2ae8c4b8fd6d")}catch(e){}}();
|
|
3
|
+
import { z } from "zod";
|
|
1
4
|
//#region src/plugins/mcp.mts
|
|
5
|
+
/** No entry config: presence is the whole activation. A typo'd config key
|
|
6
|
+
* fails at resolution instead of being silently ignored. */
|
|
7
|
+
const mcpPluginConfigSchema = z.strictObject({});
|
|
2
8
|
/**
|
|
3
9
|
* R2.2 — the MCP subsystem as a built-in plugin. Flag-on semantics: PRESENCE
|
|
4
10
|
* IS ACTIVATION — listed (built-in default) means the /mcp endpoint mounts;
|
|
@@ -10,18 +16,17 @@
|
|
|
10
16
|
* map: reactor-api server.ts:1282-1294) and is driven by options.mcp — the
|
|
11
17
|
* plugin's whole job is owning that option.
|
|
12
18
|
*/
|
|
13
|
-
|
|
14
|
-
!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]="d0d8adf1-591a-51b6-9fdb-e71751e66fca")}catch(e){}}();
|
|
15
19
|
const mcpPlugin = {
|
|
16
20
|
name: "switchboard-mcp",
|
|
17
21
|
appliesTo: "switchboard",
|
|
22
|
+
configSchema: mcpPluginConfigSchema,
|
|
18
23
|
hooks: { transformServerOptions: (options) => options.mcp === false ? options : {
|
|
19
24
|
...options,
|
|
20
25
|
mcp: true
|
|
21
26
|
} }
|
|
22
27
|
};
|
|
23
28
|
//#endregion
|
|
24
|
-
export { mcpPlugin as t };
|
|
29
|
+
export { mcpPluginConfigSchema as n, mcpPlugin as t };
|
|
25
30
|
|
|
26
|
-
//# sourceMappingURL=mcp-
|
|
27
|
-
//# debugId=
|
|
31
|
+
//# sourceMappingURL=mcp-SsBK14Jm.mjs.map
|
|
32
|
+
//# debugId=54d61ec8-8bfa-5067-b1a5-2ae8c4b8fd6d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-SsBK14Jm.mjs","sources":["../src/plugins/mcp.mts"],"sourcesContent":["import type { HostPlugin } from \"@powerhousedao/host-core\";\nimport type { SwitchboardHostContext } from \"../plugin-host.mjs\";\nimport { z } from \"zod\";\n\n/** No entry config: presence is the whole activation. A typo'd config key\n * fails at resolution instead of being silently ignored. */\nexport const mcpPluginConfigSchema = z.strictObject({});\n\nexport type McpPluginConfig = z.input<typeof mcpPluginConfigSchema>;\n\ndeclare global {\n interface PHPluginConfigs {\n \"@powerhousedao/switchboard/plugins/mcp\": McpPluginConfig;\n }\n}\n\n/**\n * R2.2 — the MCP subsystem as a built-in plugin. Flag-on semantics: PRESENCE\n * IS ACTIVATION — listed (built-in default) means the /mcp endpoint mounts;\n * removed from the composition means it does not exist. The MCP_ENABLED env\n * flag governs the classic/flag-off path only (resolveMcpEnabled, which\n * still runs and whose result this transform overrides flag-on).\n *\n * The mount itself lives inside reactor-api's initializeAndStartAPI (carve\n * map: reactor-api server.ts:1282-1294) and is driven by options.mcp — the\n * plugin's whole job is owning that option.\n */\nexport const mcpPlugin: HostPlugin<{\n transformServerOptions: (\n options: Record<string, unknown>,\n ctx: SwitchboardHostContext,\n ) => Record<string, unknown>;\n}> = {\n name: \"switchboard-mcp\",\n appliesTo: \"switchboard\",\n configSchema: mcpPluginConfigSchema,\n hooks: {\n // An explicit caller/host `mcp: false` option keeps winning (the same\n // short-circuit resolveMcpEnabled has); only the ENV flag loses its\n // meaning flag-on — presence in the composition is the switch.\n transformServerOptions: (options) =>\n options.mcp === false ? options : { ...options, mcp: true },\n },\n};\n\n// resolveHostPlugins consumes the DEFAULT export (plugin object or factory).\nexport default mcpPlugin;\n"],"names":[],"mappings":";;;;;;AAMA,MAAa,wBAAwB,EAAE,aAAa,CAAC,CAAC;;;;;;;;;;;;AAqBtD,MAAa,YAKR;CACH,MAAM;CACN,WAAW;CACX,cAAc;CACd,OAAO,EAIL,yBAAyB,YACvB,QAAQ,QAAQ,QAAQ,UAAU;EAAE,GAAG;EAAS,KAAK;CAAK,EAC9D;AACF","debug_id":"54d61ec8-8bfa-5067-b1a5-2ae8c4b8fd6d"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { t as SwitchboardHostContext } from "../plugin-host-CGO4XZzK.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { HostPlugin } from "@powerhousedao/host-core";
|
|
3
4
|
//#region src/plugins/attachments.d.mts
|
|
5
|
+
/** No entry config: presence is the whole activation. A typo'd config key
|
|
6
|
+
* fails at resolution instead of being silently ignored. */
|
|
7
|
+
export declare const attachmentsPluginConfigSchema: z.ZodObject<{}, z.core.$strict>;
|
|
8
|
+
export type AttachmentsPluginConfig = z.input<typeof attachmentsPluginConfigSchema>;
|
|
9
|
+
declare global {
|
|
10
|
+
interface PHPluginConfigs {
|
|
11
|
+
"@powerhousedao/switchboard/plugins/attachments": AttachmentsPluginConfig;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* R2.3 — the attachments subsystem as a built-in plugin: the six /attachments
|
|
6
16
|
* routes mount at onHttpMounting and the remote attachment service is created
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.d.mts","names":[],"sources":["../../src/plugins/attachments.mts"],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"attachments.d.mts","names":[],"sources":["../../src/plugins/attachments.mts"],"mappings":";;;;;;qBAUa,+BAA6B,EAAA,cAAA,EAAA,KAAA;YAE9B,0BAA0B,EAAE,aAC/B;QAGD;YACI;IACR,kDAAkD;;;;;;;;;;;;;;;;qBAiBzC,mBAAmB;EAC9B,iBAAiB,KAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as attachmentsPlugin } from "../server-
|
|
2
|
-
export { attachmentsPlugin, attachmentsPlugin as default };
|
|
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]="
|
|
4
|
-
//# debugId=
|
|
1
|
+
import { c as attachmentsPlugin, l as attachmentsPluginConfigSchema } from "../server-CrWPtMG6.mjs";
|
|
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]="383f9b00-d2f6-5824-a01a-6361cbd9470a")}catch(e){}}();
|
|
4
|
+
//# debugId=383f9b00-d2f6-5824-a01a-6361cbd9470a
|
package/dist/plugins/mcp.d.mts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { t as SwitchboardHostContext } from "../plugin-host-CGO4XZzK.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { HostPlugin } from "@powerhousedao/host-core";
|
|
3
4
|
//#region src/plugins/mcp.d.mts
|
|
5
|
+
/** No entry config: presence is the whole activation. A typo'd config key
|
|
6
|
+
* fails at resolution instead of being silently ignored. */
|
|
7
|
+
export declare const mcpPluginConfigSchema: z.ZodObject<{}, z.core.$strict>;
|
|
8
|
+
export type McpPluginConfig = z.input<typeof mcpPluginConfigSchema>;
|
|
9
|
+
declare global {
|
|
10
|
+
interface PHPluginConfigs {
|
|
11
|
+
"@powerhousedao/switchboard/plugins/mcp": McpPluginConfig;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* R2.2 — the MCP subsystem as a built-in plugin. Flag-on semantics: PRESENCE
|
|
6
16
|
* IS ACTIVATION — listed (built-in default) means the /mcp endpoint mounts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../../src/plugins/mcp.mts"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../../src/plugins/mcp.mts"],"mappings":";;;;;;qBAMa,uBAAqB,EAAA,cAAA,EAAA,KAAA;YAEtB,kBAAkB,EAAE,aAAa;QAErC;YACI;IACR,0CAA0C;;;;;;;;;;;;;;qBAejC,WAAW;EACtB,yBACE,SAAS,yBACT,KAAK,2BACF"}
|
package/dist/plugins/mcp.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as mcpPlugin } from "../mcp-
|
|
2
|
-
export { mcpPlugin as default, mcpPlugin };
|
|
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]="
|
|
4
|
-
//# debugId=
|
|
1
|
+
import { n as mcpPluginConfigSchema, t as mcpPlugin } from "../mcp-SsBK14Jm.mjs";
|
|
2
|
+
export { mcpPlugin as default, mcpPlugin, mcpPluginConfigSchema };
|
|
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]="dba18a22-a12c-5f1b-8475-f41ceb845bef")}catch(e){}}();
|
|
4
|
+
//# debugId=dba18a22-a12c-5f1b-8475-f41ceb845bef
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { t as SwitchboardHostContext } from "../plugin-host-CGO4XZzK.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { HostPlugin } from "@powerhousedao/host-core";
|
|
3
4
|
//#region src/plugins/privacy.d.mts
|
|
5
|
+
/** No entry config: presence is the whole activation. A typo'd config key
|
|
6
|
+
* fails at resolution instead of being silently ignored. */
|
|
7
|
+
export declare const privacyPluginConfigSchema: z.ZodObject<{}, z.core.$strict>;
|
|
8
|
+
export type PrivacyPluginConfig = z.input<typeof privacyPluginConfigSchema>;
|
|
9
|
+
declare global {
|
|
10
|
+
interface PHPluginConfigs {
|
|
11
|
+
"@powerhousedao/switchboard/plugins/privacy": PrivacyPluginConfig;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
4
14
|
export declare const privacyPlugin: HostPlugin<{
|
|
5
15
|
transformServerOptions: (options: Record<string, unknown>, ctx: SwitchboardHostContext) => Record<string, unknown>;
|
|
6
16
|
onSubgraphsRegistering: (ctx: SwitchboardHostContext) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy.d.mts","names":[],"sources":["../../src/plugins/privacy.mts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"privacy.d.mts","names":[],"sources":["../../src/plugins/privacy.mts"],"mappings":";;;;;;qBAea,2BAAyB,EAAA,cAAA,EAAA,KAAA;YAE1B,sBAAsB,EAAE,aAAa;QAEzC;YACI;IACR,8CAA8C;;;qBAuBrC,eAAe;EAC1B,yBACE,SAAS,yBACT,KAAK,2BACF;EACL,yBAAyB,KAAK,2BAA2B;EACzD,aAAa,KAAK,2BAA2B"}
|
package/dist/plugins/privacy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as privacyPlugin } from "../privacy-
|
|
2
|
-
export { privacyPlugin as default, privacyPlugin };
|
|
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]="
|
|
4
|
-
//# debugId=
|
|
1
|
+
import { n as privacyPluginConfigSchema, t as privacyPlugin } from "../privacy-BsFl7GzK.mjs";
|
|
2
|
+
export { privacyPlugin as default, privacyPlugin, privacyPluginConfigSchema };
|
|
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]="592a4fa2-4449-54b4-834e-9e201f049024")}catch(e){}}();
|
|
4
|
+
//# debugId=592a4fa2-4449-54b4-834e-9e201f049024
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as SwitchboardHostContext } from "../plugin-host-CGO4XZzK.mjs";
|
|
2
2
|
import { t as ComposedWorkflowRuntime } from "../workflow-runtime-7GaJ13c9.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import { HostPlugin } from "@powerhousedao/host-core";
|
|
4
5
|
//#region src/plugins/workflows.d.mts
|
|
5
6
|
/**
|
|
@@ -8,6 +9,15 @@ import { HostPlugin } from "@powerhousedao/host-core";
|
|
|
8
9
|
* mcp carve); the PH_WORKFLOWS_ENABLED env/config resolution governs the
|
|
9
10
|
* classic path only.
|
|
10
11
|
*
|
|
12
|
+
* The plugin also DECLARES the drive the runtime serves — the Workflows drive
|
|
13
|
+
* that opens in Workflow Studio — as a drive contribution (workflow-plugins
|
|
14
|
+
* plan). The switchboard runner merges it into the host's drive plan (a host
|
|
15
|
+
* declaration with the same slug wins), seeds it, reports it on the handle so
|
|
16
|
+
* a compound can hand it to its connect member, and `--explain drives` lists
|
|
17
|
+
* it with this plugin as provenance. Before, the runner seeded that drive as
|
|
18
|
+
* an implicit side effect of the workflows flag; now the entry's `config.drive`
|
|
19
|
+
* names it (`drive: false` serves the runtime without seeding a drive).
|
|
20
|
+
*
|
|
11
21
|
* The orchestration (compose, singleton-conflict retry, subgraph
|
|
12
22
|
* registration, start, inspection fact) moves here VERBATIM from the inline
|
|
13
23
|
* block; the dependency-heavy wiring closures (composeWorkflows,
|
|
@@ -25,12 +35,45 @@ export interface WorkflowsOrchestration {
|
|
|
25
35
|
reportMountFailure: (error: unknown) => void;
|
|
26
36
|
setWorkflowsFact: () => void;
|
|
27
37
|
}
|
|
28
|
-
|
|
38
|
+
/** The drive app Workflow Studio registers under (packages/workflow). */
|
|
39
|
+
export declare const WORKFLOW_STUDIO_EDITOR_ID = "workflow-studio";
|
|
40
|
+
/** The drive the plugin seeds unless the entry says otherwise. */
|
|
41
|
+
export declare const DEFAULT_WORKFLOWS_DRIVE: {
|
|
42
|
+
readonly slug: "workflows";
|
|
43
|
+
readonly name: "Workflows";
|
|
44
|
+
};
|
|
45
|
+
export declare const workflowsPluginConfigSchema: z.ZodObject<{
|
|
46
|
+
drive: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
47
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
48
|
+
name: z.ZodOptional<z.ZodString>;
|
|
49
|
+
id: z.ZodOptional<z.ZodString>;
|
|
50
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
51
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strict>, z.ZodLiteral<false>]>>;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
export type WorkflowsPluginConfig = z.infer<typeof workflowsPluginConfigSchema>;
|
|
55
|
+
/** What a host.js entry writes (typed-host-configs 1.4). Kept a type alias,
|
|
56
|
+
* not an interface, so it stays assignable to the runtime `PluginEntryData`
|
|
57
|
+
* config record. */
|
|
58
|
+
export type WorkflowsPluginConfigInput = z.input<typeof workflowsPluginConfigSchema>;
|
|
59
|
+
declare global {
|
|
60
|
+
interface PHPluginConfigs {
|
|
61
|
+
"@powerhousedao/switchboard/plugins/workflows": WorkflowsPluginConfigInput;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export type WorkflowsPlugin = HostPlugin<{
|
|
29
65
|
transformServerOptions: (options: Record<string, unknown>, ctx: SwitchboardHostContext) => Record<string, unknown>;
|
|
30
66
|
onSubgraphsRegistering: (ctx: SwitchboardHostContext) => Promise<void>;
|
|
31
67
|
onShutdown: (ctx: SwitchboardHostContext) => Promise<void>;
|
|
32
|
-
}>;
|
|
68
|
+
}, WorkflowsPluginConfig>;
|
|
69
|
+
/** The drive declaration the entry config amounts to (host-core's
|
|
70
|
+
* DriveDeclaration shape; kept structural here to avoid the import cycle the
|
|
71
|
+
* Contributions type documents). `undefined` when `drive: false`. */
|
|
72
|
+
export declare function workflowsDriveDeclaration(config: WorkflowsPluginConfig): Record<string, unknown> | undefined;
|
|
73
|
+
export declare function createWorkflowsPlugin(rawConfig?: unknown): WorkflowsPlugin;
|
|
74
|
+
/** The default-config instance: the built-in composition's entry. */
|
|
75
|
+
export declare const workflowsPlugin: WorkflowsPlugin;
|
|
33
76
|
//#endregion
|
|
34
|
-
export {
|
|
77
|
+
export { createWorkflowsPlugin as default };
|
|
35
78
|
export {};
|
|
36
79
|
//# sourceMappingURL=workflows.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.mts","names":[],"sources":["../../src/plugins/workflows.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflows.d.mts","names":[],"sources":["../../src/plugins/workflows.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCiB;EACf;EACA,wBAAwB,QAAQ;EAChC,2BACE,UAAU,4BACP;EACL,oBAAoB;EACpB,qBAAqB;EACrB;;;qBAQW;;qBAGA;WACX;WACA;;qBAgBW,6BAA2B,EAAA;;;;;;;;GAGtC,EAAA,KAAA;YAEU,wBAAwB,EAAE,aAAa;;;;YAKvC,6BAA6B,EAAE,aAClC;QAGD;YACI;IACR,gDAAgD;;;YAIxC,kBAAkB;EAE1B,yBACE,SAAS,yBACT,KAAK,2BACF;EACL,yBAAyB,KAAK,2BAA2B;EACzD,aAAa,KAAK,2BAA2B;GAE/C;;;;wBAMc,0BACd,QAAQ,wBACP;wBAca,sBACd,sBACC;;qBA2FU,iBAAiB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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]="
|
|
4
|
-
//# debugId=
|
|
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-fsBcElEi.mjs";
|
|
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]="2bbe9f5e-cbe6-5936-abf9-a29134af73d1")}catch(e){}}();
|
|
4
|
+
//# debugId=2bbe9f5e-cbe6-5936-abf9-a29134af73d1
|
|
@@ -1,7 +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]="
|
|
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]="04a759c0-bfa6-5b01-a2ad-e0e248168e96")}catch(e){}}();
|
|
3
3
|
import { AuthorizationPolicy, PrivacyPermissionAdapter } from "@powerhousedao/reactor-api";
|
|
4
4
|
import { DisclosureService, MIN_DEPLOYMENT_SECRET_BYTES, createModuleErasure, createPrivacySubgraph, registerSubjectDocumentsReadModel } from "@powerhousedao/reactor-privacy";
|
|
5
|
+
import { z } from "zod";
|
|
5
6
|
//#region src/privacy.mts
|
|
6
7
|
const DAY_MS = 864e5;
|
|
7
8
|
/** Enabling privacy on a switchboard that cannot run it safely. */
|
|
@@ -76,9 +77,13 @@ async function startPrivacy(deps) {
|
|
|
76
77
|
}
|
|
77
78
|
//#endregion
|
|
78
79
|
//#region src/plugins/privacy.mts
|
|
80
|
+
/** No entry config: presence is the whole activation. A typo'd config key
|
|
81
|
+
* fails at resolution instead of being silently ignored. */
|
|
82
|
+
const privacyPluginConfigSchema = z.strictObject({});
|
|
79
83
|
const privacyPlugin = {
|
|
80
84
|
name: "switchboard-privacy",
|
|
81
85
|
appliesTo: "switchboard",
|
|
86
|
+
configSchema: privacyPluginConfigSchema,
|
|
82
87
|
hooks: {
|
|
83
88
|
transformServerOptions: (options, ctx) => {
|
|
84
89
|
ctx.privacyConfig = resolvePrivacy(options.privacy, process.env);
|
|
@@ -107,7 +112,7 @@ const privacyPlugin = {
|
|
|
107
112
|
}
|
|
108
113
|
};
|
|
109
114
|
//#endregion
|
|
110
|
-
export {
|
|
115
|
+
export { startPrivacy as i, privacyPluginConfigSchema as n, resolvePrivacy as r, privacyPlugin as t };
|
|
111
116
|
|
|
112
|
-
//# sourceMappingURL=privacy-
|
|
113
|
-
//# debugId=
|
|
117
|
+
//# sourceMappingURL=privacy-BsFl7GzK.mjs.map
|
|
118
|
+
//# debugId=04a759c0-bfa6-5b01-a2ad-e0e248168e96
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy-C8KVimKF.mjs","sources":["../src/privacy.mts","../src/plugins/privacy.mts"],"sourcesContent":["import type {\n InProcessReactorModule,\n IReactorClient,\n} from \"@powerhousedao/reactor\";\nimport {\n AuthorizationPolicy,\n PrivacyPermissionAdapter,\n type DocumentPermissionService,\n type GraphQLManager,\n type IAuthorizationService,\n} from \"@powerhousedao/reactor-api\";\nimport {\n createModuleErasure,\n createPrivacySubgraph,\n DisclosureService,\n MIN_DEPLOYMENT_SECRET_BYTES,\n registerSubjectDocumentsReadModel,\n type ErasureScheduler,\n type IErasureService,\n} from \"@powerhousedao/reactor-privacy\";\nimport type { ISigner } from \"@powerhousedao/shared/document-model\";\nimport type { ILogger } from \"document-model\";\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\nexport type PrivacyOptions = {\n /** Wins over PH_PRIVACY_ENABLED. */\n enabled?: boolean;\n /** Wins over PH_PRIVACY_DEPLOYMENT_SECRET. */\n deploymentSecret?: string;\n /** The reactor's signer, for a caller-provided reactor. */\n signer?: ISigner;\n};\n\nexport type ResolvedPrivacy =\n | { enabled: false }\n | {\n enabled: true;\n deploymentSecret: string;\n intervalMs?: number;\n deadlineMs?: number;\n markerGraceMs?: number;\n purgeTimeoutMs?: number;\n };\n\n/** Enabling privacy on a switchboard that cannot run it safely. */\nexport class PrivacyBootError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"PrivacyBootError\";\n }\n}\n\nfunction positive(\n env: NodeJS.ProcessEnv,\n name: string,\n unitMs: number,\n): number | undefined {\n const raw = env[name];\n if (raw === undefined || raw.trim() === \"\") return undefined;\n const value = Number(raw);\n if (!Number.isFinite(value) || value <= 0) {\n throw new PrivacyBootError(\n `${name} must be a positive number, got \"${raw}\"`,\n );\n }\n return value * unitMs;\n}\n\nexport function resolvePrivacy(\n options: PrivacyOptions | undefined,\n env: NodeJS.ProcessEnv,\n): ResolvedPrivacy {\n const enabled = options?.enabled ?? env.PH_PRIVACY_ENABLED === \"true\";\n if (!enabled) return { enabled: false };\n const deploymentSecret =\n options?.deploymentSecret ?? env.PH_PRIVACY_DEPLOYMENT_SECRET;\n if (\n !deploymentSecret ||\n Buffer.byteLength(deploymentSecret, \"utf8\") < MIN_DEPLOYMENT_SECRET_BYTES\n ) {\n throw new PrivacyBootError(\n `PH_PRIVACY_ENABLED needs PH_PRIVACY_DEPLOYMENT_SECRET of at least ${MIN_DEPLOYMENT_SECRET_BYTES} bytes`,\n );\n }\n return {\n enabled: true,\n deploymentSecret,\n intervalMs: positive(env, \"PH_PRIVACY_INTERVAL_MS\", 1),\n deadlineMs: positive(env, \"PH_PRIVACY_DEADLINE_DAYS\", DAY_MS),\n markerGraceMs: positive(env, \"PH_PRIVACY_MARKER_GRACE_DAYS\", DAY_MS),\n purgeTimeoutMs: positive(env, \"PH_PRIVACY_PURGE_TIMEOUT_MINUTES\", 60_000),\n };\n}\n\nexport type RunningPrivacy = {\n erasure: IErasureService;\n scheduler: ErasureScheduler;\n stop(): Promise<void>;\n};\n\n/** Subject index, erasure scheduler and admin subgraph on a built reactor. */\nexport async function startPrivacy(deps: {\n config: Extract<ResolvedPrivacy, { enabled: true }>;\n reactorModule: InProcessReactorModule | undefined;\n signer: ISigner | undefined;\n authorizationService: IAuthorizationService;\n documentPermissionService: DocumentPermissionService | undefined;\n graphqlManager: GraphQLManager;\n reactorClient: IReactorClient;\n logger: ILogger;\n}): Promise<RunningPrivacy> {\n const { config, reactorModule, authorizationService } = deps;\n if (authorizationService.config.policy === AuthorizationPolicy.OPEN) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED is refused under the OPEN authorization policy: every caller, anonymous included, would administer erasure. Enable authentication (AUTH_ENABLED=true with ADMINS) first.\",\n );\n }\n if (!reactorModule) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED needs an in-process reactor module\",\n );\n }\n if (!deps.signer?.app?.key) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED needs a reactor signer (a Renown identity): every receiver refuses an unsigned purge marker\",\n );\n }\n\n const permissions = deps.documentPermissionService\n ? new PrivacyPermissionAdapter(deps.documentPermissionService)\n : undefined;\n const { service, scheduler } = createModuleErasure(reactorModule, {\n deploymentSecret: config.deploymentSecret,\n signer: deps.signer,\n permissions,\n intervalMs: config.intervalMs,\n deadlineMs: config.deadlineMs,\n markerGraceMs: config.markerGraceMs,\n purgeTimeoutMs: config.purgeTimeoutMs,\n logger: deps.logger,\n });\n\n const disclosure = new DisclosureService(\n reactorModule.database,\n config.deploymentSecret,\n permissions,\n );\n let subgraph;\n try {\n subgraph = createPrivacySubgraph({\n authorizationService,\n erasure: service,\n disclosure,\n });\n } catch (error) {\n throw new PrivacyBootError(\n error instanceof Error ? error.message : String(error),\n );\n }\n\n await registerSubjectDocumentsReadModel(reactorModule, {\n deploymentSecret: config.deploymentSecret,\n });\n await deps.graphqlManager.registerSubgraphInstance(\n {\n ...subgraph,\n path: deps.graphqlManager.getBasePath(),\n reactorClient: deps.reactorClient,\n relationalDb: undefined as never,\n },\n \"graphql\",\n false,\n );\n\n scheduler.start();\n deps.logger.info(\"Privacy add-on started: subject index, erasure scheduler\");\n return {\n erasure: service,\n scheduler,\n stop: () => scheduler.stop(),\n };\n}\n","import type { IRenown } from \"@renown/sdk\";\nimport type { HostPlugin } from \"@powerhousedao/host-core\";\nimport type { ILogger } from \"document-model\";\nimport {\n resolvePrivacy,\n startPrivacy,\n type PrivacyOptions,\n type ResolvedPrivacy,\n type RunningPrivacy,\n} from \"../privacy.mjs\";\nimport type { SwitchboardHostContext } from \"../plugin-host.mjs\";\n\n/**\n * R2.4 — the privacy subsystem as a built-in plugin. Presence is activation\n * of the SUBSYSTEM; whether privacy enforcement runs still requires its\n * config (enabled + deploymentSecret — A SECRET, env-only:\n * PH_PRIVACY_DEPLOYMENT_SECRET never enters host files).\n *\n * Timing preserved from the inline path (carve map): config resolves EARLY at\n * transformServerOptions (a bad secret fails the boot before any resource\n * opens — same fail-fast property as the inline line-571 resolve); the mount\n * runs at onSubgraphsRegistering, whose server-side call site carries the\n * inline failure semantics (stop workflows, abortBoot, rethrow); teardown is\n * first in shutdown via onShutdown.\n */\n\ntype PrivacyCapableOptions = Record<string, unknown> & {\n privacy?: PrivacyOptions & { signer?: unknown };\n reactor?: unknown;\n};\n\nexport const privacyPlugin: HostPlugin<{\n transformServerOptions: (\n options: Record<string, unknown>,\n ctx: SwitchboardHostContext,\n ) => Record<string, unknown>;\n onSubgraphsRegistering: (ctx: SwitchboardHostContext) => Promise<void>;\n onShutdown: (ctx: SwitchboardHostContext) => Promise<void>;\n}> = {\n name: \"switchboard-privacy\",\n appliesTo: \"switchboard\",\n hooks: {\n transformServerOptions: (options, ctx) => {\n // Fail-fast resolve, before the reactor is built.\n ctx.privacyConfig = resolvePrivacy(\n (options as PrivacyCapableOptions).privacy,\n process.env,\n );\n return options;\n },\n onSubgraphsRegistering: async (ctx) => {\n const config = ctx.privacyConfig as ResolvedPrivacy;\n if (!config.enabled) return;\n const options = ctx.options as PrivacyCapableOptions;\n // The caller's reactor signs with a signer only the caller knows.\n const signer = options.reactor\n ? options.privacy?.signer\n : (options.privacy?.signer ?? (ctx.renown as IRenown | null)?.signer);\n const api = ctx.api as {\n authorizationService: never;\n documentPermissionService: never;\n };\n ctx.privacy = await startPrivacy({\n config,\n reactorModule: (\n ctx.reactorClientModule as { reactorModule?: never } | undefined\n )?.reactorModule,\n signer: signer as never,\n authorizationService: api.authorizationService,\n documentPermissionService: api.documentPermissionService,\n graphqlManager: ctx.graphqlManager as never,\n reactorClient: ctx.client as never,\n logger: (ctx.logger as ILogger).child([\"privacy\"]),\n });\n },\n onShutdown: async (ctx) => {\n await (ctx.privacy as RunningPrivacy | undefined)?.stop();\n },\n },\n};\n\n// resolveHostPlugins consumes the DEFAULT export (plugin object or factory).\nexport default privacyPlugin;\n"],"names":[],"mappings":";;;;;AAuBA,MAAM,SAAS;;AAuBf,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,SAAS,SACP,KACA,MACA,QACoB;CACpB,MAAM,MAAM,IAAI;CAChB,IAAI,QAAQ,KAAA,KAAa,IAAI,KAAK,MAAM,IAAI,OAAO,KAAA;CACnD,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S;GACT;EACF,CAAC;CACH,SAAS,OAAO;EACd,MAAM,IAAI,iBACR,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;CACF;CAEA,MAAM,kCAAkC,eAAe,EACrD,kBAAkB,OAAO,iBAC3B,CAAC;CACD,MAAM,KAAK,eAAe,yBACxB;EACE,GAAG;EACH,MAAM,KAAK,eAAe,YAAY;EACtC,eAAe,KAAK;EACpB,cAAc,KAAA;CAChB,GACA,WACA,KACF;CAEA,UAAU,MAAM;CAChB,KAAK,OAAO,KAAK,0DAA0D;CAC3E,OAAO;EACL,SAAS;EACT;EACA,YAAY,UAAU,KAAK;CAC7B;AACF;;;ACvJA,MAAa,gBAOR;CACH,MAAM;CACN,WAAW;CACX,OAAO;EACL,yBAAyB,SAAS,QAAQ;GAExC,IAAI,gBAAgB,eACjB,QAAkC,SACnC,QAAQ,GACV;GACA,OAAO;EACT;EACA,wBAAwB,OAAO,QAAQ;GACrC,MAAM,SAAS,IAAI;GACnB,IAAI,CAAC,OAAO,SAAS;GACrB,MAAM,UAAU,IAAI;GAEpB,MAAM,SAAS,QAAQ,UACnB,QAAQ,SAAS,SAChB,QAAQ,SAAS,UAAW,IAAI,QAA2B;GAChE,MAAM,MAAM,IAAI;GAIhB,IAAI,UAAU,MAAM,aAAa;IAC/B;IACA,eACE,IAAI,qBACH;IACK;IACR,sBAAsB,IAAI;IAC1B,2BAA2B,IAAI;IAC/B,gBAAgB,IAAI;IACpB,eAAe,IAAI;IACnB,QAAS,IAAI,OAAmB,MAAM,CAAC,SAAS,CAAC;GACnD,CAAC;EACH;EACA,YAAY,OAAO,QAAQ;GACzB,MAAO,IAAI,SAAwC,KAAK;EAC1D;CACF;AACF","debug_id":"ff8496aa-7c16-5960-8a4d-9f5b6fd3e74d"}
|
|
1
|
+
{"version":3,"file":"privacy-BsFl7GzK.mjs","sources":["../src/privacy.mts","../src/plugins/privacy.mts"],"sourcesContent":["import type {\n InProcessReactorModule,\n IReactorClient,\n} from \"@powerhousedao/reactor\";\nimport {\n AuthorizationPolicy,\n PrivacyPermissionAdapter,\n type DocumentPermissionService,\n type GraphQLManager,\n type IAuthorizationService,\n} from \"@powerhousedao/reactor-api\";\nimport {\n createModuleErasure,\n createPrivacySubgraph,\n DisclosureService,\n MIN_DEPLOYMENT_SECRET_BYTES,\n registerSubjectDocumentsReadModel,\n type ErasureScheduler,\n type IErasureService,\n} from \"@powerhousedao/reactor-privacy\";\nimport type { ISigner } from \"@powerhousedao/shared/document-model\";\nimport type { ILogger } from \"document-model\";\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\nexport type PrivacyOptions = {\n /** Wins over PH_PRIVACY_ENABLED. */\n enabled?: boolean;\n /** Wins over PH_PRIVACY_DEPLOYMENT_SECRET. */\n deploymentSecret?: string;\n /** The reactor's signer, for a caller-provided reactor. */\n signer?: ISigner;\n};\n\nexport type ResolvedPrivacy =\n | { enabled: false }\n | {\n enabled: true;\n deploymentSecret: string;\n intervalMs?: number;\n deadlineMs?: number;\n markerGraceMs?: number;\n purgeTimeoutMs?: number;\n };\n\n/** Enabling privacy on a switchboard that cannot run it safely. */\nexport class PrivacyBootError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"PrivacyBootError\";\n }\n}\n\nfunction positive(\n env: NodeJS.ProcessEnv,\n name: string,\n unitMs: number,\n): number | undefined {\n const raw = env[name];\n if (raw === undefined || raw.trim() === \"\") return undefined;\n const value = Number(raw);\n if (!Number.isFinite(value) || value <= 0) {\n throw new PrivacyBootError(\n `${name} must be a positive number, got \"${raw}\"`,\n );\n }\n return value * unitMs;\n}\n\nexport function resolvePrivacy(\n options: PrivacyOptions | undefined,\n env: NodeJS.ProcessEnv,\n): ResolvedPrivacy {\n const enabled = options?.enabled ?? env.PH_PRIVACY_ENABLED === \"true\";\n if (!enabled) return { enabled: false };\n const deploymentSecret =\n options?.deploymentSecret ?? env.PH_PRIVACY_DEPLOYMENT_SECRET;\n if (\n !deploymentSecret ||\n Buffer.byteLength(deploymentSecret, \"utf8\") < MIN_DEPLOYMENT_SECRET_BYTES\n ) {\n throw new PrivacyBootError(\n `PH_PRIVACY_ENABLED needs PH_PRIVACY_DEPLOYMENT_SECRET of at least ${MIN_DEPLOYMENT_SECRET_BYTES} bytes`,\n );\n }\n return {\n enabled: true,\n deploymentSecret,\n intervalMs: positive(env, \"PH_PRIVACY_INTERVAL_MS\", 1),\n deadlineMs: positive(env, \"PH_PRIVACY_DEADLINE_DAYS\", DAY_MS),\n markerGraceMs: positive(env, \"PH_PRIVACY_MARKER_GRACE_DAYS\", DAY_MS),\n purgeTimeoutMs: positive(env, \"PH_PRIVACY_PURGE_TIMEOUT_MINUTES\", 60_000),\n };\n}\n\nexport type RunningPrivacy = {\n erasure: IErasureService;\n scheduler: ErasureScheduler;\n stop(): Promise<void>;\n};\n\n/** Subject index, erasure scheduler and admin subgraph on a built reactor. */\nexport async function startPrivacy(deps: {\n config: Extract<ResolvedPrivacy, { enabled: true }>;\n reactorModule: InProcessReactorModule | undefined;\n signer: ISigner | undefined;\n authorizationService: IAuthorizationService;\n documentPermissionService: DocumentPermissionService | undefined;\n graphqlManager: GraphQLManager;\n reactorClient: IReactorClient;\n logger: ILogger;\n}): Promise<RunningPrivacy> {\n const { config, reactorModule, authorizationService } = deps;\n if (authorizationService.config.policy === AuthorizationPolicy.OPEN) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED is refused under the OPEN authorization policy: every caller, anonymous included, would administer erasure. Enable authentication (AUTH_ENABLED=true with ADMINS) first.\",\n );\n }\n if (!reactorModule) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED needs an in-process reactor module\",\n );\n }\n if (!deps.signer?.app?.key) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED needs a reactor signer (a Renown identity): every receiver refuses an unsigned purge marker\",\n );\n }\n\n const permissions = deps.documentPermissionService\n ? new PrivacyPermissionAdapter(deps.documentPermissionService)\n : undefined;\n const { service, scheduler } = createModuleErasure(reactorModule, {\n deploymentSecret: config.deploymentSecret,\n signer: deps.signer,\n permissions,\n intervalMs: config.intervalMs,\n deadlineMs: config.deadlineMs,\n markerGraceMs: config.markerGraceMs,\n purgeTimeoutMs: config.purgeTimeoutMs,\n logger: deps.logger,\n });\n\n const disclosure = new DisclosureService(\n reactorModule.database,\n config.deploymentSecret,\n permissions,\n );\n let subgraph;\n try {\n subgraph = createPrivacySubgraph({\n authorizationService,\n erasure: service,\n disclosure,\n });\n } catch (error) {\n throw new PrivacyBootError(\n error instanceof Error ? error.message : String(error),\n );\n }\n\n await registerSubjectDocumentsReadModel(reactorModule, {\n deploymentSecret: config.deploymentSecret,\n });\n await deps.graphqlManager.registerSubgraphInstance(\n {\n ...subgraph,\n path: deps.graphqlManager.getBasePath(),\n reactorClient: deps.reactorClient,\n relationalDb: undefined as never,\n },\n \"graphql\",\n false,\n );\n\n scheduler.start();\n deps.logger.info(\"Privacy add-on started: subject index, erasure scheduler\");\n return {\n erasure: service,\n scheduler,\n stop: () => scheduler.stop(),\n };\n}\n","import type { IRenown } from \"@renown/sdk\";\nimport type { HostPlugin } from \"@powerhousedao/host-core\";\nimport type { ILogger } from \"document-model\";\nimport {\n resolvePrivacy,\n startPrivacy,\n type PrivacyOptions,\n type ResolvedPrivacy,\n type RunningPrivacy,\n} from \"../privacy.mjs\";\nimport type { SwitchboardHostContext } from \"../plugin-host.mjs\";\nimport { z } from \"zod\";\n\n/** No entry config: presence is the whole activation. A typo'd config key\n * fails at resolution instead of being silently ignored. */\nexport const privacyPluginConfigSchema = z.strictObject({});\n\nexport type PrivacyPluginConfig = z.input<typeof privacyPluginConfigSchema>;\n\ndeclare global {\n interface PHPluginConfigs {\n \"@powerhousedao/switchboard/plugins/privacy\": PrivacyPluginConfig;\n }\n}\n\n/**\n * R2.4 — the privacy subsystem as a built-in plugin. Presence is activation\n * of the SUBSYSTEM; whether privacy enforcement runs still requires its\n * config (enabled + deploymentSecret — A SECRET, env-only:\n * PH_PRIVACY_DEPLOYMENT_SECRET never enters host files).\n *\n * Timing preserved from the inline path (carve map): config resolves EARLY at\n * transformServerOptions (a bad secret fails the boot before any resource\n * opens — same fail-fast property as the inline line-571 resolve); the mount\n * runs at onSubgraphsRegistering, whose server-side call site carries the\n * inline failure semantics (stop workflows, abortBoot, rethrow); teardown is\n * first in shutdown via onShutdown.\n */\n\ntype PrivacyCapableOptions = Record<string, unknown> & {\n privacy?: PrivacyOptions & { signer?: unknown };\n reactor?: unknown;\n};\n\nexport const privacyPlugin: HostPlugin<{\n transformServerOptions: (\n options: Record<string, unknown>,\n ctx: SwitchboardHostContext,\n ) => Record<string, unknown>;\n onSubgraphsRegistering: (ctx: SwitchboardHostContext) => Promise<void>;\n onShutdown: (ctx: SwitchboardHostContext) => Promise<void>;\n}> = {\n name: \"switchboard-privacy\",\n appliesTo: \"switchboard\",\n configSchema: privacyPluginConfigSchema,\n hooks: {\n transformServerOptions: (options, ctx) => {\n // Fail-fast resolve, before the reactor is built.\n ctx.privacyConfig = resolvePrivacy(\n (options as PrivacyCapableOptions).privacy,\n process.env,\n );\n return options;\n },\n onSubgraphsRegistering: async (ctx) => {\n const config = ctx.privacyConfig as ResolvedPrivacy;\n if (!config.enabled) return;\n const options = ctx.options as PrivacyCapableOptions;\n // The caller's reactor signs with a signer only the caller knows.\n const signer = options.reactor\n ? options.privacy?.signer\n : (options.privacy?.signer ?? (ctx.renown as IRenown | null)?.signer);\n const api = ctx.api as {\n authorizationService: never;\n documentPermissionService: never;\n };\n ctx.privacy = await startPrivacy({\n config,\n reactorModule: (\n ctx.reactorClientModule as { reactorModule?: never } | undefined\n )?.reactorModule,\n signer: signer as never,\n authorizationService: api.authorizationService,\n documentPermissionService: api.documentPermissionService,\n graphqlManager: ctx.graphqlManager as never,\n reactorClient: ctx.client as never,\n logger: (ctx.logger as ILogger).child([\"privacy\"]),\n });\n },\n onShutdown: async (ctx) => {\n await (ctx.privacy as RunningPrivacy | undefined)?.stop();\n },\n },\n};\n\n// resolveHostPlugins consumes the DE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