@powerhousedao/switchboard 6.2.3-dev.70 → 6.2.3-dev.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
  2. package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
  3. package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
  4. package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
  5. package/.tsbuild/test/port-probe.test.d.ts +2 -0
  6. package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
  7. package/.tsbuild/test/shutdown.test.d.ts +2 -0
  8. package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
  9. package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
  10. package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
  11. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  12. package/CHANGELOG.md +27 -0
  13. package/dist/index.mjs +1 -1
  14. package/dist/{mcp-cNWW82NH.mjs → mcp-SsBK14Jm.mjs} +10 -5
  15. package/dist/mcp-SsBK14Jm.mjs.map +1 -0
  16. package/dist/plugins/attachments.d.mts +10 -0
  17. package/dist/plugins/attachments.d.mts.map +1 -1
  18. package/dist/plugins/attachments.mjs +4 -4
  19. package/dist/plugins/mcp.d.mts +10 -0
  20. package/dist/plugins/mcp.d.mts.map +1 -1
  21. package/dist/plugins/mcp.mjs +4 -4
  22. package/dist/plugins/privacy.d.mts +10 -0
  23. package/dist/plugins/privacy.d.mts.map +1 -1
  24. package/dist/plugins/privacy.mjs +4 -4
  25. package/dist/plugins/workflows.d.mts +46 -3
  26. package/dist/plugins/workflows.d.mts.map +1 -1
  27. package/dist/plugins/workflows.mjs +4 -4
  28. package/dist/{privacy-C8KVimKF.mjs → privacy-BsFl7GzK.mjs} +9 -4
  29. package/dist/{privacy-C8KVimKF.mjs.map → privacy-BsFl7GzK.mjs.map} +1 -1
  30. package/dist/{server-CF_mjyJi.mjs → server-Be1vmpxu.mjs} +54 -27
  31. package/dist/server-Be1vmpxu.mjs.map +1 -0
  32. package/dist/server.d.mts +18 -15
  33. package/dist/server.d.mts.map +1 -1
  34. package/dist/server.mjs +3 -3
  35. package/dist/{utils-uaBlzyjS.mjs → utils-Dh845exv.mjs} +42 -9
  36. package/dist/utils-Dh845exv.mjs.map +1 -0
  37. package/dist/utils.d.mts +8 -2
  38. package/dist/utils.d.mts.map +1 -1
  39. package/dist/utils.mjs +3 -3
  40. package/dist/{workflows-qKtqZhn3.mjs → workflows-fsBcElEi.mjs} +111 -67
  41. package/dist/{workflows-qKtqZhn3.mjs.map → workflows-fsBcElEi.mjs.map} +1 -1
  42. package/package.json +18 -17
  43. package/test/default-drive-slug.test.ts +97 -0
  44. package/test/plugin-config-schemas.test.ts +83 -0
  45. package/test/port-probe.test.ts +45 -0
  46. package/test/shutdown.test.ts +278 -0
  47. package/test/workflows-plugin-config.test.ts +77 -0
  48. package/dist/mcp-cNWW82NH.mjs.map +0 -1
  49. package/dist/server-CF_mjyJi.mjs.map +0 -1
  50. package/dist/utils-uaBlzyjS.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ ## 6.2.3-dev.71 (2026-10-22)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **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))
6
+ - **desktop:** vendor local package tarballs into the stack (PH_DESKTOP_LOCAL_PACKAGES) ([000bc39d10](https://github.com/powerhouse-inc/powerhouse/commit/000bc39d10))
7
+ - **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))
8
+ - **codegen:** pure builders for generated outputs.js/.d.ts and the hosts typing files ([be3c35122f](https://github.com/powerhouse-inc/powerhouse/commit/be3c35122f))
9
+ - **switchboard:** shutdown() stops the owned reactor, idempotently ([26b46c1a36](https://github.com/powerhouse-inc/powerhouse/commit/26b46c1a36))
10
+ - **switchboard:** typed configSchema and PHPluginConfigs entry for every built-in plugin ([ed25110339](https://github.com/powerhouse-inc/powerhouse/commit/ed25110339))
11
+ - **connect,desktop:** layered backgrounds for the home screen and the loading page ([9ffe4915b4](https://github.com/powerhouse-inc/powerhouse/commit/9ffe4915b4))
12
+ - **host-core,ph-cli,switchboard,connect,codegen:** workflow plugins declare the drive and the link ([ab37f30600](https://github.com/powerhouse-inc/powerhouse/commit/ab37f30600))
13
+
14
+ ### 🩹 Fixes
15
+
16
+ - **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))
17
+ - **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))
18
+ - **switchboard:** an aborted boot stops the owned reactor through its shutdown ([ac4d0b05bf](https://github.com/powerhouse-inc/powerhouse/commit/ac4d0b05bf))
19
+
20
+ ### ❤️ Thank You
21
+
22
+ - acaldas
23
+ - Benjamin Jordan
24
+ - Claude Fable 5.1
25
+ - Claude Opus 5.5
26
+ - Wouter Kampmann
27
+
1
28
  ## 6.2.3-dev.70 (2026-10-22)
2
29
 
3
30
  ### 🚀 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 parseForcePgVersion, o as StoredDocumentsRefusedError, u as initProfilerFromEnv } from "./server-CF_mjyJi.mjs";
4
+ import { a as startSwitchboard, d as initProfilerFromEnv, f as parseForcePgVersion, o as StoredDocumentsRefusedError } from "./server-Be1vmpxu.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-cNWW82NH.mjs.map
27
- //# debugId=d0d8adf1-591a-51b6-9fdb-e71751e66fca
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":";;;;;;;;;;;;;;;;qBAoBa,mBAAmB;EAC9B,iBAAiB,KAAK"}
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-CF_mjyJi.mjs";
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]="b7befcd4-8ac4-5403-8cd0-8c54a1d4a288")}catch(e){}}();
4
- //# debugId=b7befcd4-8ac4-5403-8cd0-8c54a1d4a288
1
+ import { c as attachmentsPlugin, l as attachmentsPluginConfigSchema } from "../server-Be1vmpxu.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]="ed86abc7-35ba-5991-bb13-49c7632e4476")}catch(e){}}();
4
+ //# debugId=ed86abc7-35ba-5991-bb13-49c7632e4476
@@ -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":";;;;;;;;;;;;;;qBAca,WAAW;EACtB,yBACE,SAAS,yBACT,KAAK,2BACF"}
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"}
@@ -1,4 +1,4 @@
1
- import { t as mcpPlugin } from "../mcp-cNWW82NH.mjs";
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]="eae60854-3cb6-5759-8567-94ac5a34d60a")}catch(e){}}();
4
- //# debugId=eae60854-3cb6-5759-8567-94ac5a34d60a
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":";;;qBA+Ba,eAAe;EAC1B,yBACE,SAAS,yBACT,KAAK,2BACF;EACL,yBAAyB,KAAK,2BAA2B;EACzD,aAAa,KAAK,2BAA2B"}
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"}
@@ -1,4 +1,4 @@
1
- import { t as privacyPlugin } from "../privacy-C8KVimKF.mjs";
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]="942527ef-2aa7-59d7-a6fa-6766c92fb0b1")}catch(e){}}();
4
- //# debugId=942527ef-2aa7-59d7-a6fa-6766c92fb0b1
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
- export declare const workflowsPlugin: HostPlugin<{
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 { workflowsPlugin as default };
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":";;;;;;;;;;;;;;;;;;;iBA0BiB;EACf;EACA,wBAAwB,QAAQ;EAChC,2BACE,UAAU,4BACP;EACL,oBAAoB;EACpB,qBAAqB;EACrB;;qBAOW,iBAAiB;EAC5B,yBACE,SAAS,yBACT,KAAK,2BACF;EACL,yBAAyB,KAAK,2BAA2B;EACzD,aAAa,KAAK,2BAA2B"}
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 { t as workflowsPlugin } from "../workflows-qKtqZhn3.mjs";
2
- export { workflowsPlugin as default, workflowsPlugin };
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]="ec591584-f4a2-5205-ae5e-deecdc2af277")}catch(e){}}();
4
- //# debugId=ec591584-f4a2-5205-ae5e-deecdc2af277
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]="ff8496aa-7c16-5960-8a4d-9f5b6fd3e74d")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="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 { resolvePrivacy as n, startPrivacy as r, privacyPlugin as t };
115
+ export { startPrivacy as i, privacyPluginConfigSchema as n, resolvePrivacy as r, privacyPlugin as t };
111
116
 
112
- //# sourceMappingURL=privacy-C8KVimKF.mjs.map
113
- //# debugId=ff8496aa-7c16-5960-8a4d-9f5b6fd3e74d
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":"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","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 DEFAULT export (plugin object or factory).\nexport default privacyPlugin;\n"],"names":[],"mappings":"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","debug_id":"04a759c0-bfa6-5b01-a2ad-e0e248168e96"}
@@ -1,9 +1,9 @@
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]="c7a0fd97-c4f8-5b06-a939-44b23fae01c3")}catch(e){}}();
3
- import { a as composeWorkflowRuntime, c as resolveWorkflowsEnabled, d as installFatalErrorShutdown, f as triggerFatalShutdown, i as assertWorkflowPackageLoadable, l as retryWorkflowSingleton, n as WORKFLOW_PACKAGE_NAME, o as isWorkflowSingletonConflict, r as WORKFLOW_TELEMETRY_SCOPE, s as modelManifestSource, t as workflowsPlugin, u as workflowSingletonLossHandler } from "./workflows-qKtqZhn3.mjs";
4
- import { n as resolvePrivacy, r as startPrivacy, t as privacyPlugin } from "./privacy-C8KVimKF.mjs";
5
- import { t as mcpPlugin } from "./mcp-cNWW82NH.mjs";
6
- import { n as addDefaultReactorDrive, r as isPostgresUrl, t as addDefaultDrive } from "./utils-uaBlzyjS.mjs";
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]="eb9f9f91-b014-5be8-a29c-f37efe0c4ad0")}catch(e){}}();
3
+ import { _ as triggerFatalShutdown, a as workflowsPlugin, c as WORKFLOW_TELEMETRY_SCOPE, d as isWorkflowSingletonConflict, f as modelManifestSource, g as installFatalErrorShutdown, h as workflowSingletonLossHandler, l as assertWorkflowPackageLoadable, m as retryWorkflowSingleton, p as resolveWorkflowsEnabled, s as WORKFLOW_PACKAGE_NAME, u as composeWorkflowRuntime } from "./workflows-fsBcElEi.mjs";
4
+ import { i as startPrivacy, r as resolvePrivacy, t as privacyPlugin } from "./privacy-BsFl7GzK.mjs";
5
+ import { t as mcpPlugin } from "./mcp-SsBK14Jm.mjs";
6
+ import { n as addDefaultReactorDrive, r as isPostgresUrl, t as addDefaultDrive } from "./utils-Dh845exv.mjs";
7
7
  import { createRequire, register } from "node:module";
8
8
  import { metrics, trace } from "@opentelemetry/api";
9
9
  import { ReactorInstrumentation } from "@powerhousedao/opentelemetry-instrumentation-reactor";
@@ -28,6 +28,7 @@ import path$1 from "path";
28
28
  import { Pool } from "pg";
29
29
  import { Readable } from "node:stream";
30
30
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
31
+ import { z } from "zod";
31
32
  import { mergeContributions, resolveOrder, runObserveHook, runObserveHookSequential, runTransformHook } from "@powerhousedao/host-core";
32
33
  import { DEFAULT_SIGNATURE_POLICY, isSignaturePolicy } from "@powerhousedao/shared/document-model";
33
34
  import { readFile } from "node:fs/promises";
@@ -903,6 +904,9 @@ function applySwitchboardReactorDefaults(reactorBuilder, clientBuilder, options
903
904
  }
904
905
  //#endregion
905
906
  //#region src/plugins/attachments.mts
907
+ /** No entry config: presence is the whole activation. A typo'd config key
908
+ * fails at resolution instead of being silently ignored. */
909
+ const attachmentsPluginConfigSchema = z.strictObject({});
906
910
  /**
907
911
  * R2.3 — the attachments subsystem as a built-in plugin: the six /attachments
908
912
  * routes mount at onHttpMounting and the remote attachment service is created
@@ -919,6 +923,7 @@ function applySwitchboardReactorDefaults(reactorBuilder, clientBuilder, options
919
923
  const attachmentsPlugin = {
920
924
  name: "switchboard-attachments",
921
925
  appliesTo: "switchboard",
926
+ configSchema: attachmentsPluginConfigSchema,
922
927
  hooks: { onHttpMounting: (ctx) => {
923
928
  registerAttachmentRoutes(ctx.api);
924
929
  ctx.attachmentService = createRemoteAttachmentService(deriveAttachmentServiceConfig(ctx.options, ctx.serverPort, ctx.renown));
@@ -1753,7 +1758,21 @@ const PGLITE_IN_MEMORY = process.env.PH_PGLITE_IN_MEMORY === "1";
1753
1758
  * the port is free, false if the OS reports it in use. Any other error is
1754
1759
  * surfaced so we don't silently mask real issues (permissions, bad host, …).
1755
1760
  */
1756
- function isPortAvailable(port) {
1761
+ async function isPortAvailable(port) {
1762
+ try {
1763
+ return await probePort(port, "::");
1764
+ } catch (error) {
1765
+ if (!isNoIpv6Error(error)) throw portProbeError(port, error);
1766
+ try {
1767
+ return await probePort(port, "0.0.0.0");
1768
+ } catch (ipv4Error) {
1769
+ throw portProbeError(port, ipv4Error);
1770
+ }
1771
+ }
1772
+ }
1773
+ const isNoIpv6Error = (error) => ["EAFNOSUPPORT", "EADDRNOTAVAIL"].includes(error.code ?? "");
1774
+ const portProbeError = (port, error) => new Error(`Could not check whether port ${port} is free: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1775
+ function probePort(port, host) {
1757
1776
  return new Promise((resolve, reject) => {
1758
1777
  const tester = net.createServer();
1759
1778
  tester.once("error", (err) => {
@@ -1765,7 +1784,7 @@ function isPortAvailable(port) {
1765
1784
  });
1766
1785
  tester.listen({
1767
1786
  port,
1768
- host: "::"
1787
+ host
1769
1788
  });
1770
1789
  });
1771
1790
  }
@@ -1985,6 +2004,7 @@ async function initServer(serverPort, options, renown, renownConfig) {
1985
2004
  const clientBuilder = new ReactorClientBuilder().withReactorBuilder(reactorBuilder);
1986
2005
  const vetraDocumentModels = dev ? Object.values(await import("@powerhousedao/vetra/document-models")).filter((m) => typeof m === "object" && m !== null && "documentModel" in m && "reducer" in m) : [];
1987
2006
  applySwitchboardReactorDefaults(reactorBuilder, clientBuilder, {
2007
+ signalHandlers: options.signalHandlers,
1988
2008
  documentModels: [...documentModels, ...vetraDocumentModels],
1989
2009
  upgradeManifests,
1990
2010
  executorConfig: hasSkipThreshold || enabledFeatureFlags.length > 0 ? {
@@ -2080,22 +2100,25 @@ async function initServer(serverPort, options, renown, renownConfig) {
2080
2100
  };
2081
2101
  };
2082
2102
  const abortBoot = async (api) => {
2103
+ let disposed;
2104
+ const disposeApi = () => disposed ??= api.dispose();
2105
+ apiRef.current = { dispose: disposeApi };
2083
2106
  const owned = ownedReactorModule;
2084
- if (owned) try {
2107
+ if (owned?.reactorModule) try {
2108
+ await owned.reactorModule.shutdown();
2109
+ } catch (error) {
2110
+ logger.error("Aborting boot: reactor shutdown failed: @error", error);
2111
+ }
2112
+ else if (owned) try {
2085
2113
  await owned.reactor.kill().completed;
2086
2114
  } catch (error) {
2087
2115
  logger.error("Aborting boot: reactor shutdown failed: @error", error);
2088
2116
  }
2089
2117
  try {
2090
- await api.dispose();
2118
+ await disposeApi();
2091
2119
  } catch (error) {
2092
2120
  logger.error("Aborting boot: api dispose failed: @error", error);
2093
2121
  }
2094
- if (owned?.reactorModule) try {
2095
- await owned.reactorModule.database.destroy();
2096
- } catch (error) {
2097
- logger.error("Aborting boot: database destroy failed: @error", error);
2098
- }
2099
2122
  };
2100
2123
  let localCredentialCheck;
2101
2124
  const verifyCredential = renownConfig.source === "self" ? (params) => localCredentialCheck ? localCredentialCheck(params) : Promise.reject(/* @__PURE__ */ new Error("The local renown read model is not bound yet")) : void 0;
@@ -2306,14 +2329,17 @@ async function initServer(serverPort, options, renown, renownConfig) {
2306
2329
  throw error;
2307
2330
  }
2308
2331
  }
2309
- const shutdown = async () => {
2332
+ let apiDrained;
2333
+ const drainApi = () => apiDrained ??= (async () => {
2310
2334
  if (pluginHost) await pluginHost.observe("onShutdown");
2311
2335
  await privacy?.stop();
2312
2336
  await workflowsRetry?.stop();
2313
2337
  await workflows?.stop();
2314
2338
  await api.dispose();
2315
- };
2316
- apiRef.current = { dispose: shutdown };
2339
+ })();
2340
+ apiRef.current = { dispose: drainApi };
2341
+ const ownedReactor = ownedReactorModule?.reactorModule;
2342
+ const shutdown = ownedReactor ? () => ownedReactor.shutdown() : drainApi;
2317
2343
  if (httpLoader) {
2318
2344
  const packageManagementService = new PackageManagementService({
2319
2345
  defaultRegistryUrl: registryUrl,
@@ -2372,8 +2398,8 @@ async function initServer(serverPort, options, renown, renownConfig) {
2372
2398
  }, reporting);
2373
2399
  if (options.drive) {
2374
2400
  if (!renown) throw new Error("Cannot create default drive without Renown identity");
2375
- if ((options.drive.documentType ?? "powerhouse/document-drive") === "powerhouse/reactor-drive") defaultDriveUrl = await addDefaultReactorDrive(client, options.drive, serverPort);
2376
- else defaultDriveUrl = await addDefaultDrive(client, options.drive, serverPort);
2401
+ if ((options.drive.documentType ?? "powerhouse/document-drive") === "powerhouse/reactor-drive") defaultDriveUrl = await addDefaultReactorDrive(client, options.drive, serverPort, logger);
2402
+ else defaultDriveUrl = await addDefaultDrive(client, options.drive, serverPort, logger);
2377
2403
  }
2378
2404
  if (vite) api.httpAdapter.mountRawMiddleware(vite.middlewares);
2379
2405
  if (remoteDrives.length > 0) for (const remoteDriveUrl of remoteDrives) {
@@ -2431,11 +2457,12 @@ async function initServer(serverPort, options, renown, renownConfig) {
2431
2457
  * dangling until the process exits.
2432
2458
  *
2433
2459
  * When `options.reactor` is omitted, the switchboard builds and owns the
2434
- * reactor. `shutdown()` on the returned handle only drains the api (HTTP
2435
- * server, GraphQL, MCP, attachments); the reactor itself is torn down by
2436
- * its own signal handlers (`withSignalHandlers`), which call `kill()` and
2437
- * trigger the `withShutdownHook` chain that disposes the api. Programmatic
2438
- * full teardown isn't currently exposed — wire it via SIGINT/SIGTERM.
2460
+ * reactor. `shutdown()` on the returned handle then runs the reactor
2461
+ * module's `shutdown()`: `kill()`, the `withShutdownHook` chain that drains
2462
+ * the api (HTTP server, GraphQL, MCP, attachments, read-model db), then the
2463
+ * reactor database. It does not exit the process. It is the same memoized
2464
+ * teardown the SIGINT/SIGTERM handlers (`withSignalHandlers`) run, so calling
2465
+ * it twice, or receiving a signal around it, tears down once.
2439
2466
  */
2440
2467
  const startSwitchboard = async (options = {}) => {
2441
2468
  const requestedPort = options.port ?? DEFAULT_PORT;
@@ -2491,7 +2518,7 @@ const startSwitchboard = async (options = {}) => {
2491
2518
  };
2492
2519
  if (import.meta.main) await startSwitchboard({ fatalErrorShutdown: true });
2493
2520
  //#endregion
2494
- export { startSwitchboard as a, attachmentsPlugin as c, parseForcePgVersion as d, resolvePgliteStorageDirs as i, applySwitchboardReactorDefaults as l, deriveAttachmentServiceConfig as n, StoredDocumentsRefusedError as o, isPortAvailable as r, resolveUnsupportedStoredDocuments as s, createReactorKysely as t, initProfilerFromEnv as u };
2521
+ export { startSwitchboard as a, attachmentsPlugin as c, initProfilerFromEnv as d, parseForcePgVersion as f, resolvePgliteStorageDirs as i, attachmentsPluginConfigSchema as l, deriveAttachmentServiceConfig as n, StoredDocumentsRefusedError as o, isPortAvailable as r, resolveUnsupportedStoredDocuments as s, createReactorKysely as t, applySwitchboardReactorDefaults as u };
2495
2522
 
2496
- //# sourceMappingURL=server-CF_mjyJi.mjs.map
2497
- //# debugId=c7a0fd97-c4f8-5b06-a939-44b23fae01c3
2523
+ //# sourceMappingURL=server-Be1vmpxu.mjs.map
2524
+ //# debugId=eb9f9f91-b014-5be8-a29c-f37efe0c4ad0