@powerhousedao/host-core 6.3.0-dev.8 → 6.4.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{compound-CBqPgk38.d.mts → compound-D2dh2VUh.d.mts} +332 -22
- package/dist/compound-D2dh2VUh.d.mts.map +1 -0
- package/dist/{compound-DKi56SSx.mjs → compound-n-bO0qKh.mjs} +1616 -487
- package/dist/compound-n-bO0qKh.mjs.map +1 -0
- package/dist/{env-substitution-C_fVirPh.d.mts → env-substitution-Ct39KFvA.d.mts} +7 -3
- package/dist/env-substitution-Ct39KFvA.d.mts.map +1 -0
- package/dist/{env-substitution-BXGohOGN.mjs → env-substitution-FJ5Nua4M.mjs} +29 -10
- package/dist/env-substitution-FJ5Nua4M.mjs.map +1 -0
- package/dist/{host-schemas-BM7F21lf.d.mts → host-schemas-B6_-P11_.d.mts} +52 -19
- package/dist/host-schemas-B6_-P11_.d.mts.map +1 -0
- package/dist/index.d.mts +194 -129
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +51 -355
- package/dist/index.mjs.map +1 -1
- package/dist/kill-tree.d.mts +8 -0
- package/dist/kill-tree.d.mts.map +1 -0
- package/dist/kill-tree.mjs +73 -0
- package/dist/kill-tree.mjs.map +1 -0
- package/dist/plugins-DP3YlIWx.mjs +309 -0
- package/dist/plugins-DP3YlIWx.mjs.map +1 -0
- package/dist/{plugins-Uk84BRay.d.mts → plugins-Dsmfhbn7.d.mts} +53 -3
- package/dist/plugins-Dsmfhbn7.d.mts.map +1 -0
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +2 -174
- package/dist/projection.d.mts +12 -18
- package/dist/projection.d.mts.map +1 -1
- package/dist/projection.mjs +17 -10
- package/dist/projection.mjs.map +1 -1
- package/dist/runners/compound.d.mts +9 -3
- package/dist/runners/compound.d.mts.map +1 -1
- package/dist/runners/compound.mjs +1 -1
- package/dist/schema.d.mts +6 -4
- package/dist/schema.d.mts.map +1 -1
- package/dist/schema.mjs +5 -4
- package/dist/schema.mjs.map +1 -1
- package/package.json +9 -3
- package/dist/compound-CBqPgk38.d.mts.map +0 -1
- package/dist/compound-DKi56SSx.mjs.map +0 -1
- package/dist/env-substitution-BXGohOGN.mjs.map +0 -1
- package/dist/env-substitution-C_fVirPh.d.mts.map +0 -1
- package/dist/host-schemas-BM7F21lf.d.mts.map +0 -1
- package/dist/plugins-Uk84BRay.d.mts.map +0 -1
- package/dist/plugins.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-substitution-BXGohOGN.mjs","names":[],"sources":["../src/drive-schema.ts","../src/host-schemas.ts","../src/env-substitution.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { tokenable, type TokenableSchema } from \"./tokens.js\";\n\n/**\n * The schema half of drives.ts, zod only so `./schema` stays neutral.\n * - slug: the SEEDING KEY (idempotence); id optional (stable identity).\n * - preferredEditor: stored at header.meta.preferredEditor; Connect config's\n * `app` is the legacy alias.\n * - remote.url: a drive served elsewhere; local fields are ignored for it.\n * Token-able (`$output` on a producer's `drives.<slug>.url`).\n */\nexport function buildDriveDeclarationSchema(\n urlField: (schema: z.ZodString) => TokenableSchema<z.ZodString>,\n) {\n return z.strictObject({\n slug: z.string().min(1),\n id: z.string().min(1).optional(),\n /** Derive the id from the project path, like generateProjectDriveId — the\n * same ids classic `ph vetra` produces. `true` serves the drive under the\n * hashed slug too (the vetra drive's slug IS its hashed id); `\"id\"` hashes\n * only the id and keeps the declared slug (the classic Workflows drive:\n * `/d/workflows`, id `workflows-<hash>`). */\n projectHash: z.union([z.boolean(), z.literal(\"id\")]).optional(),\n /** What a missing drive is created as. Default powerhouse/document-drive. */\n documentType: z\n .enum([\"powerhouse/document-drive\", \"powerhouse/reactor-drive\"])\n .optional(),\n name: z.string().min(1).optional(),\n icon: z.string().optional(),\n preferredEditor: z.string().optional(),\n sharingType: z.enum([\"public\", \"private\", \"shared\"]).optional(),\n availableOffline: z.boolean().optional(),\n remote: z.strictObject({ url: urlField(z.string().min(1)) }).optional(),\n });\n}\n\nexport const driveDeclarationSchema = buildDriveDeclarationSchema(tokenable);\n\nexport type DriveDeclaration = z.infer<typeof driveDeclarationSchema>;\n\nexport const drivesSchema = z.array(driveDeclarationSchema);\n\n/** The project-hashed drive id (`${slug}-${sha256(projectRoot)[0..8]}`) with\n * the hash function injected, so neutral consumers (a browser monitor) can\n * pass `crypto.subtle`-derived or precomputed hex. drives.ts binds it to\n * node:crypto as `projectDriveId`. */\nexport function projectDriveIdWith(\n sha256Hex: (input: string) => string,\n projectRoot: string,\n slug: string,\n): string {\n return `${slug}-${sha256Hex(projectRoot).substring(0, 8)}`;\n}\n","import { switchboardOfDrive } from \"@powerhousedao/shared/host-tokens\";\nimport { isOriginPlaceholderUrl } from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport { z } from \"zod\";\nimport { buildDriveDeclarationSchema } from \"./drive-schema.js\";\nimport { pluginEntrySchema } from \"./plugins.js\";\nimport {\n envTokenable,\n tokenable,\n type EnvToken,\n type TokenableSchema,\n type TokenMode,\n} from \"./tokens.js\";\n\n/**\n * The zod single source for host.js blocks (typed-host-configs G1). Every\n * host type is z.input/z.output of these schemas; nothing is hand-mirrored.\n * Top-level host objects and the `reactor` block are STRICT (a typo fails);\n * `runner` stays loose until each runner declares its options (T2), and\n * `config` is runner-defined.\n *\n * Token-able fields (typed-host-configs 3.5): `reactor.backends.*.remote.url`\n * (required, a switchboard drive address), `reactor.drives` (whole list, e.g. `$map`),\n * `reactor.drives[].remote.url` and `storage.dataDir` (`$env` only). Their z.input admits tokens, their z.output is the resolved type.\n */\n\n/** A host's `name` keys its run record, `.ph/run/<name>.json`, so it must be\n * one safe path segment. */\nexport const HOST_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nexport const HOST_NAME_MAX_LENGTH = 128;\nexport const HOST_NAME_MESSAGE =\n \"A host name is used as a file name, so use only letters, digits, '.', '_' and '-', start with a letter or digit, and keep it to 128 characters.\";\nexport const hostNameSchema = z\n .string()\n .min(1)\n .max(HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE)\n .regex(HOST_NAME_PATTERN, HOST_NAME_MESSAGE);\n\n/**\n * A URL, or one written against the page origin (`${origin}/graphql`): the\n * browser resolves the placeholder when it loads Connect's config, for a\n * member whose own server proxies the switchboard's paths.\n */\nexport const originOrUrlSchema = z.union([\n z.url(),\n z.string().refine(isOriginPlaceholderUrl, {\n message: \"a URL, or ${origin}/<path> for a proxied sibling\",\n }),\n]);\n\nexport const profileSchema = z.strictObject({\n appId: z.string().min(1).optional(),\n name: z.string().min(1).optional(),\n description: z.string().optional(),\n icon: z.string().optional(),\n});\n\nexport const reactorProtocolSchema = z.strictObject({\n featureFlags: z\n .strictObject({\n documentDecisions: z.boolean().optional(),\n authEnforcement: z.boolean().optional(),\n authGroups: z.boolean().optional(),\n authConditions: z.boolean().optional(),\n undoV3: z.boolean().optional(),\n })\n .optional(),\n createSignaturePolicy: z.enum([\"legacy\", \"v2-required\"]).optional(),\n unsupportedStoredDocuments: z.enum([\"refuse\", \"read-only\"]).optional(),\n});\n\nexport const runnerKindSchema = z.enum([\"reactor\", \"compound\"]);\nexport type RunnerKind = z.infer<typeof runnerKindSchema>;\n\nexport const reactorBackendKindSchema = z.enum([\n \"in-process\",\n \"worker\",\n \"remote\",\n]);\n\n// Path-equality for the one-dir guard: pure string normalisation (the host\n// core stays Node-free); the server repeats the check with path.resolve.\nconst samePath = (a: string, b: string): boolean => {\n const norm = (p: string) =>\n p.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\").replace(/^\\.\\//, \"\");\n return norm(a) === norm(b);\n};\n\n/** Compound wiring: the generic compound runner's `config` block.\n * (`projectDrivesIntoConnect` and `drivesPublicBase` were removed in T3: a\n * member consumes another member's drives through `$output` tokens.) */\nexport const compoundWiringSchema = z.strictObject({\n /** Member start order; must name declared children and agree with the\n * output-token dependencies (resolve/plan.ts). Optional: without it the\n * order is derived from the tokens. Unnamed members start after the named\n * ones, in declaration order. */\n startOrder: z.array(z.string().min(1)).optional(),\n /** Write .ph/run/<host>.json (default true). */\n runtimeRecord: z.boolean().optional(),\n /** Patch the baked CSP for the runtime registry on a served Connect\n * member (forwarded as `runner.cspRegistrySync` to every member whose\n * runner is `@powerhousedao/ph-cli/runners/connect`). */\n cspRegistrySync: z.boolean().optional(),\n});\n\n/** `config.startOrder ⊆ keys(children)`, checked where both are visible.\n * Apply it LAST (`.superRefine(refineStartOrder)`) to a runner's final host\n * schema: zod refuses to `.extend()` a refined object. */\nexport function refineStartOrder(\n host: { children: Record<string, unknown>; config?: Record<string, unknown> },\n ctx: z.RefinementCtx,\n): void {\n const startOrder = host.config?.startOrder;\n if (!Array.isArray(startOrder)) return;\n const members = Object.keys(host.children);\n startOrder.forEach((name: unknown, index) => {\n if (startOrder.indexOf(name) !== index) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"config\", \"startOrder\", index],\n message: `startOrder names \"${String(name)}\" twice; each member starts once.`,\n });\n return;\n }\n if (typeof name === \"string\" && members.includes(name)) return;\n ctx.addIssue({\n code: \"custom\",\n path: [\"config\", \"startOrder\", index],\n message: `startOrder names \"${String(name)}\", which is not a member. Members: ${members.join(\", \") || \"(none)\"}.`,\n });\n });\n}\n\n/** How a schema set wraps its token-able fields. Both modes share one static\n * type (declared input, resolved output); they differ at runtime only. */\ninterface FieldWrappers {\n any: <S extends z.ZodType>(schema: S) => TokenableSchema<S>;\n env: <S extends z.ZodType>(schema: S) => TokenableSchema<S, EnvToken>;\n}\n\nconst ALLOW_TOKENS: FieldWrappers = { any: tokenable, env: envTokenable };\n// A one-option union: the same validation as `schema`, typed like the\n// \"allow\" wrappers so both modes share HostSchemas.\nconst FORBID_TOKENS: FieldWrappers = {\n any: (schema) => z.union([schema]),\n env: (schema) => z.union([schema]),\n};\n\n/** The replacement a non-drive `remote.url` message names. */\nfunction useDriveUrl(host = \"switchboard\", member?: string): string {\n const memberPart = member ? `, member: \"${member}\"` : \"\";\n return (\n `remote: { url: ${host}.drives.<slug>.url } with ${host} from ../${host}/outputs.js, ` +\n `or remote: { url: { $output: { host: \"${host}\"${memberPart}, path: [\"drives\", \"<slug>\", \"url\"] } } }`\n );\n}\n\n/** The `$output` of a declared `remote.url` that reads `endpoints.graphql`. */\nfunction endpointsGraphqlRef(\n url: unknown,\n): { host: string; member?: string } | undefined {\n if (typeof url !== \"object\" || url === null || !(\"$output\" in url)) {\n return undefined;\n }\n const ref = (url as { $output: unknown }).$output;\n if (typeof ref !== \"object\" || ref === null) return undefined;\n const { host, member, path } = ref as Record<string, unknown>;\n if (typeof host !== \"string\" || !Array.isArray(path)) return undefined;\n if (path.join(\".\") !== \"endpoints.graphql\") return undefined;\n return { host, ...(typeof member === \"string\" ? { member } : {}) };\n}\n\n/** The slug a drive link names: a `drives.<slug>.url` token's slug or a\n * literal address's served slug; undefined when only runtime knows it. */\nfunction linkedSlug(url: unknown): string | undefined {\n if (typeof url === \"string\") return switchboardOfDrive(url)?.slug;\n const ref =\n typeof url === \"object\" && url !== null && \"$output\" in url\n ? (url as { $output: { path?: unknown } }).$output\n : undefined;\n const path = Array.isArray(ref?.path) ? (ref.path as unknown[]) : [];\n return path.length === 3 &&\n path[0] === \"drives\" &&\n typeof path[1] === \"string\" &&\n path[2] === \"url\"\n ? path[1]\n : undefined;\n}\n\ninterface DeclaredReactorHost {\n runner?: { plugins?: unknown };\n config?: unknown;\n reactor?: {\n backends?: Record<string, { kind: string; remote?: { url: unknown } }>;\n placement?: {\n primary?: string;\n drives?: Record<string, string>;\n newDrives?: string;\n };\n drives?: unknown;\n };\n}\n\n/** The drives a declared host names (home drives, `reactor.drives`, plugin\n * `config.drive` links), or undefined when one is known only at runtime. */\nfunction knownDriveSlugs(host: DeclaredReactorHost): string[] | undefined {\n const reactor = host.reactor ?? {};\n const slugs: string[] = [];\n for (const backend of Object.values(reactor.backends ?? {})) {\n if (backend.kind !== \"remote\") continue;\n const slug = linkedSlug(backend.remote?.url);\n if (slug === undefined) return undefined;\n slugs.push(slug);\n }\n if (reactor.drives !== undefined) {\n if (!Array.isArray(reactor.drives)) return undefined;\n for (const drive of reactor.drives as { slug?: unknown }[]) {\n if (typeof drive.slug === \"string\") slugs.push(drive.slug);\n }\n }\n const plugins = Array.isArray(host.runner?.plugins)\n ? (host.runner.plugins as unknown[])\n : [];\n for (const entry of plugins) {\n const config =\n typeof entry === \"object\" && entry !== null && \"config\" in entry\n ? (entry as { config: unknown }).config\n : undefined;\n if (typeof config !== \"object\" || config === null) continue;\n if (!(\"drive\" in config) || config.drive === undefined) continue;\n const slug = linkedSlug(config.drive);\n if (slug === undefined) return undefined;\n slugs.push(slug);\n }\n for (const drive of connectDefaultDrives(host.config)) {\n if (typeof drive !== \"object\" || drive === null || !(\"url\" in drive)) {\n continue;\n }\n const slug = linkedSlug(drive.url);\n if (slug === undefined) return undefined;\n slugs.push(slug);\n }\n return slugs;\n}\n\n/** A Connect host's `config.drives.defaultDrives`, unchecked. */\nfunction connectDefaultDrives(config: unknown): unknown[] {\n const drives =\n typeof config === \"object\" && config !== null && \"drives\" in config\n ? (config as { drives: unknown }).drives\n : undefined;\n const list =\n typeof drives === \"object\" && drives !== null && \"defaultDrives\" in drives\n ? (drives as { defaultDrives: unknown }).defaultDrives\n : undefined;\n return Array.isArray(list) ? list : [];\n}\n\n/** Declared form, at host level so plugin drives are seen: a placement key\n * must name a drive the host names, when every drive is knowable. A host\n * with no remote backend is not checked: its plugins may contribute drives\n * (a switchboard's workflows drive) that no field names. */\nfunction refineDeclaredPlacementKeys(\n host: DeclaredReactorHost,\n ctx: z.RefinementCtx,\n): void {\n const placed = Object.keys(host.reactor?.placement?.drives ?? {});\n if (placed.length === 0) return;\n const remote = Object.values(host.reactor?.backends ?? {}).some(\n (b) => b.kind === \"remote\",\n );\n if (!remote) return;\n const known = knownDriveSlugs(host);\n if (!known) return;\n // A literal address may carry the hashed slug of a `projectHash` drive.\n const names = (slug: string, served: string) =>\n served === slug ||\n (served.startsWith(`${slug}-`) &&\n /^[0-9a-f]{8}$/.test(served.slice(slug.length + 1)));\n for (const slug of placed) {\n if (known.some((served) => names(slug, served))) continue;\n ctx.addIssue({\n code: \"custom\",\n path: [\"reactor\", \"placement\", \"drives\", slug],\n message: `placement.drives.${slug} names no drive this host links to or declares (${[...new Set(known)].join(\", \") || \"none\"}).`,\n });\n }\n}\n\ninterface ResolvedReactorBlock {\n backends?: Record<string, { kind: string; remote?: { url: unknown } }>;\n placement?: { drives?: Record<string, string> };\n drives?: unknown;\n}\n\n/** Resolved-form checks across backends, drives and placement: one base is\n * one remote backend, and a drive placed on a remote is on its switchboard. */\nfunction refineResolvedReactor(\n reactor: ResolvedReactorBlock,\n ctx: z.RefinementCtx,\n): void {\n const backends = reactor.backends ?? {};\n const baseOf = new Map<string, string>();\n const byBase = new Map<string, string>();\n // Every switchboard a slug is linked on: one slug on two is ambiguous.\n const linked = new Map<string, Set<string>>();\n const link = (slug: string, base: string) =>\n linked.set(slug, (linked.get(slug) ?? new Set()).add(base));\n for (const [name, backend] of Object.entries(backends)) {\n const url = backend.remote?.url;\n if (backend.kind !== \"remote\" || typeof url !== \"string\") continue;\n const home = switchboardOfDrive(url);\n if (!home) continue;\n baseOf.set(name, home.base);\n link(home.slug, home.base);\n const first = byBase.get(home.base);\n if (first === undefined) {\n byBase.set(home.base, name);\n continue;\n }\n ctx.addIssue({\n code: \"custom\",\n path: [\"backends\", name, \"remote\", \"url\"],\n message: `backends \"${first}\" and \"${name}\" both open drives on the same switchboard (${home.base}). Keep \"${first}\", and list the second drive under reactor.drives with its remote.url instead.`,\n });\n }\n\n const kept = new Set<string>();\n const declared = Array.isArray(reactor.drives)\n ? (reactor.drives as { slug: string; remote?: { url: string } }[])\n : [];\n declared.forEach((drive, index) => {\n if (!drive.remote) {\n kept.add(drive.slug);\n return;\n }\n const at = switchboardOfDrive(drive.remote.url);\n // An empty url already fails the field's own check.\n if (at || drive.remote.url === \"\") {\n if (at) link(drive.slug, at.base);\n return;\n }\n ctx.addIssue({\n code: \"custom\",\n path: [\"drives\", index, \"remote\", \"url\"],\n message: `remote.url must be a switchboard drive address (<switchboard>/d/<slug>), not ${drive.remote.url}: sync needs the drive. Use url: switchboard.drives.<slug>.url, or url: { $output: { host: \"switchboard\", path: [\"drives\", \"<slug>\", \"url\"] } }.`,\n });\n });\n\n const nameOf = (base: string) => byBase.get(base) ?? base;\n for (const [slug, name] of Object.entries(reactor.placement?.drives ?? {})) {\n const at = [\"placement\", \"drives\", slug];\n const on = [...(linked.get(slug) ?? [])];\n // Two drives answer to the key, whichever backend it names.\n if (on.length > 0 && kept.has(slug)) {\n ctx.addIssue({\n code: \"custom\",\n path: at,\n message: `Drive \"${slug}\" is both this reactor's own drive and on ${on.map(nameOf).join(\" and \")}. Rename one, or link only one.`,\n });\n continue;\n }\n if (on.length > 1) {\n ctx.addIssue({\n code: \"custom\",\n path: at,\n message: `Drive \"${slug}\" is on both ${on.map(nameOf).join(\" and \")}. Rename one, or link only one.`,\n });\n continue;\n }\n const base = baseOf.get(name);\n if (base === undefined) continue;\n if (on.length === 0) {\n // A key that names no drive here (a hashed home drive) is not checked.\n if (!kept.has(slug)) continue;\n ctx.addIssue({\n code: \"custom\",\n path: at,\n message: `placement.drives.${slug} opens drive \"${slug}\" on \"${name}\", but this reactor keeps that drive itself. Only a drive on a switchboard can open there without a copy.`,\n });\n continue;\n }\n if (on[0] === base) continue;\n ctx.addIssue({\n code: \"custom\",\n path: at,\n message: `placement.drives.${slug} opens drive \"${slug}\" on \"${name}\" (${base}), but the drive is on ${on[0]}. Place it on the backend for that switchboard.`,\n });\n }\n}\n\n/** `remote` keys that tune a connection, so only a remote backend has them. */\nconst REMOTE_ONLY_KEYS = [\"requestTimeoutMs\", \"breaker\", \"realtime\"] as const;\n\n/**\n * Builds the host schema set. \"allow\" (declared form) accepts `T | Token` in\n * every token-able field; \"forbid\" (resolved form) accepts `T` only.\n */\nfunction buildHostSchemas(tokenField: FieldWrappers) {\n const resolved = tokenField === FORBID_TOKENS;\n const reactorBackendSchema = z\n .strictObject({\n kind: reactorBackendKindSchema,\n storage: z\n .strictObject({\n kind: z.enum([\"idb\", \"memory\", \"path\", \"postgres\"]),\n /** `\"${userData}/…\"` sugar or `{ $env: \"NAME\" }`. */\n dataDir: tokenField.env(z.string()).optional(),\n url: z.string().optional(),\n })\n .optional(),\n readModel: z.strictObject({ url: z.string().optional() }).optional(),\n packages: z\n .strictObject({\n cdnUrl: z.string().optional(),\n specs: z.array(z.string()).optional(),\n /** on-demand model resolution (was DYNAMIC_MODEL_LOADING). */\n dynamic: z.boolean().optional(),\n })\n .optional(),\n // A switchboard drive address, `<base>/d/<slug>`: typically a\n // producer's `drives.<slug>.url` output token. The backend is the\n // switchboard at `<base>`. `${origin}/d/<slug>` when the member's own\n // server proxies the switchboard (the browser then calls its page\n // origin; see `runner.proxy` on the connect runner).\n remote: z\n .strictObject({\n url: tokenField.any(originOrUrlSchema),\n /** Give up on one request to this switchboard after this long. Default 30_000. */\n requestTimeoutMs: z.number().int().positive().optional(),\n /** After `failures` failed requests in a row, send nothing for\n * `openMs`. Default { failures: 3, openMs: 30_000 }. `false`:\n * never stop trying. */\n breaker: z\n .union([\n z.literal(false),\n z.strictObject({\n failures: z.number().int().min(1).optional(),\n openMs: z.number().int().nonnegative().optional(),\n }),\n ])\n .optional(),\n /** Live updates over a socket (the router's GraphQL\n * subscriptions, not drive sync). Default true. */\n realtime: z.boolean().optional(),\n })\n .optional(),\n })\n // Two PGlite instances on one data dir corrupt it: the reactor store\n // (storage.dataDir) and the read-model store (readModel.url) must differ.\n // Postgres is exempt: one database legitimately serves both stores.\n .superRefine((backend, ctx) => {\n // 2.1 \"a remote backend needs url\": `remote` is optional for the\n // in-process/worker kinds, but a remote backend attaches by URL only.\n if (backend.kind === \"remote\" && !backend.remote) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"remote\", \"url\"],\n message: `a \"remote\" backend needs remote.url, a switchboard drive address: ${useDriveUrl()}.`,\n });\n }\n if (backend.kind !== \"remote\" && backend.remote) {\n for (const key of REMOTE_ONLY_KEYS) {\n if (backend.remote[key] === undefined) continue;\n ctx.addIssue({\n code: \"custom\",\n path: [\"remote\", key],\n message: `remote.${key} applies only to a \"remote\" backend; this one is \"${backend.kind}\".`,\n });\n }\n }\n const url: unknown = backend.remote?.url;\n const graphqlRef = resolved ? undefined : endpointsGraphqlRef(url);\n if (graphqlRef) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"remote\", \"url\"],\n message: `remote.url reads ${graphqlRef.host}'s endpoints.graphql; it must be a switchboard drive address (<switchboard>/d/<slug>): sync needs the drive. Use ${useDriveUrl(graphqlRef.host, graphqlRef.member)}.`,\n });\n }\n if (resolved && typeof url === \"string\" && !switchboardOfDrive(url)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"remote\", \"url\"],\n message: `remote.url must be a switchboard drive address (<switchboard>/d/<slug>), not ${url}: sync needs the drive. Use ${useDriveUrl()}.`,\n });\n }\n const store = backend.storage;\n const storeDir = store?.kind === \"path\" ? store.dataDir : undefined;\n const readModel = backend.readModel?.url;\n // In the declared form dataDir may still be a `$env` token: compare\n // only resolved strings (resolved validation re-runs this check).\n if (\n typeof storeDir === \"string\" &&\n readModel &&\n samePath(storeDir, readModel)\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"readModel\", \"url\"],\n message:\n `readModel.url must not be the reactor's storage dir (${readModel}): ` +\n \"two PGlite instances on one data dir corrupt it. Omit readModel.url \" +\n \"to get the classic <root>/.ph/read-storage next to the reactor store.\",\n });\n }\n });\n\n const reactorSchema = z\n .strictObject({\n backends: z.record(z.string(), reactorBackendSchema).optional(),\n placement: z\n .strictObject({\n primary: z.string().optional(),\n /** Declared drive slug → backend name. A local backend keeps a\n * synced copy; the drive's own remote backend opens it there with\n * no copy. An unlisted drive keeps a synced copy. */\n drives: z.record(z.string().min(1), z.string().min(1)).optional(),\n /** The backend new drives (and documents outside a drive) are\n * created on. A switchboard keeps no copy in this browser.\n * Default: the browser reactor, else the only switchboard. */\n newDrives: z.string().min(1).optional(),\n })\n .optional(),\n router: z\n .strictObject({\n /** Wait this long for a reactor to say whether it holds a\n * document. 0: no bound. Default 3_000. */\n probeTimeoutMs: z.number().int().nonnegative().optional(),\n /** Look again after this long for a document found on a later\n * backend. Default 30_000. */\n provisionalRouteMs: z.number().int().nonnegative().optional(),\n })\n .optional(),\n protocol: reactorProtocolSchema.optional(),\n /** DEPRECATED (dies in R2): workflows become a listed plugin. */\n workflows: z.boolean().optional(),\n // R1 core keys: identity/signing and storage namespace.\n renown: z\n .strictObject({\n url: z.string().optional(),\n networkId: z.string().optional(),\n chainId: z.number().int().optional(),\n })\n .optional(),\n namespace: z.string().min(1).optional(),\n // Core-declared, seeded by the host runtime. Token-able as a whole\n // (3.3): a `$map` over a producer's `drives` output (or an `$output` of\n // an array of declarations) renders the list at resolve time.\n drives: tokenField\n .any(z.array(buildDriveDeclarationSchema(tokenField.any)))\n .optional(),\n })\n .superRefine((reactor, ctx) => {\n const backends = reactor.backends ?? {};\n for (const [slug, name] of Object.entries(\n reactor.placement?.drives ?? {},\n )) {\n if (Object.hasOwn(backends, name)) continue;\n ctx.addIssue({\n code: \"custom\",\n path: [\"placement\", \"drives\", slug],\n message: `placement.drives.${slug} names backend \"${name}\", which is not in backends (${Object.keys(backends).join(\", \") || \"none\"}).`,\n });\n }\n const newDrives = reactor.placement?.newDrives;\n if (newDrives !== undefined && !Object.hasOwn(backends, newDrives)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"placement\", \"newDrives\"],\n message: `placement.newDrives names backend \"${newDrives}\", which is not in backends (${Object.keys(backends).join(\", \") || \"none\"}).`,\n });\n }\n if (resolved) refineResolvedReactor(reactor, ctx);\n });\n\n /** Common runner options; runner modules extend it with their own. */\n const runnerBaseSchema = z.looseObject({\n module: z.string().min(1),\n defaultVerb: z.string().min(1).optional(),\n port: z.number().int().positive().optional(),\n /** Bind address; each runner documents its default. */\n host: z.string().min(1).optional(),\n /** THE COMPOSITION: plugin entries; presence is activation. */\n plugins: z.array(pluginEntrySchema).optional(),\n });\n\n /** A compound member wrapper. Sections are FULL STATEMENTS except `runner`,\n * which key-merges over the member's own. Plugins live in `runner.plugins`\n * (as on a standalone host); there is no wrapper-level `plugins`. */\n const childWrapperSchema = z.strictObject({\n host: z.string().min(1),\n // 0 passes here; the member runner's own schema decides whether it may.\n runner: runnerBaseSchema\n .partial()\n .extend({ port: z.number().int().min(0).max(65535).optional() })\n .optional(),\n config: z.looseObject({}).optional(),\n reactor: reactorSchema.optional(),\n });\n\n const childrenSchema = z.record(z.string(), childWrapperSchema);\n\n const reactorHostSchema = z.strictObject({\n name: hostNameSchema,\n runner: runnerBaseSchema,\n config: z.looseObject({}).optional(),\n profile: profileSchema.optional(),\n reactor: reactorSchema.optional(),\n });\n\n const compoundHostSchema = z.strictObject({\n name: hostNameSchema,\n runner: runnerBaseSchema,\n children: childrenSchema,\n config: z.looseObject({}).optional(),\n profile: profileSchema.optional(),\n });\n\n return {\n reactorBackendSchema,\n reactorSchema,\n runnerBaseSchema,\n childWrapperSchema,\n childrenSchema,\n reactorHostSchema,\n compoundHostSchema,\n /** This set's field wrapper, for a runner's OWN token-able fields inside\n * `defineHostSchemas`: declared, `T | Token` in and `T` out; resolved,\n * `T` only. Both modes share one static type. */\n tokenable: tokenField.any,\n /** As `tokenable`, but the only token accepted is `$env`. */\n envTokenable: tokenField.env,\n };\n}\n\nexport type HostSchemas = ReturnType<typeof buildHostSchemas>;\n\n/** The host schema set in declared (\"allow\": token-able fields take tokens)\n * or resolved (\"forbid\") form. */\nexport function makeHostSchemas(options: { tokens: TokenMode }): HostSchemas {\n return buildHostSchemas(\n options.tokens === \"allow\" ? ALLOW_TOKENS : FORBID_TOKENS,\n );\n}\n\nexport type PlacementKeyIssue = {\n path: (string | number)[];\n message: string;\n};\n\n/** The issues a host-level refinement raises, outside a zod parse. */\nfunction collectIssues(\n host: unknown,\n refine: (host: DeclaredReactorHost, ctx: z.RefinementCtx) => void,\n): PlacementKeyIssue[] {\n if (typeof host !== \"object\" || host === null || !(\"reactor\" in host)) {\n return [];\n }\n const issues: PlacementKeyIssue[] = [];\n const ctx = {\n addIssue: (issue: { path?: PropertyKey[]; message?: string }) => {\n issues.push({\n path: (issue.path ?? []).filter(\n (part): part is string | number => typeof part !== \"symbol\",\n ),\n message: issue.message ?? \"\",\n });\n },\n } as unknown as z.RefinementCtx;\n refine(host as DeclaredReactorHost, ctx);\n return issues;\n}\n\n/** withPlacementKeys' check, for a merged declared host parsed some other way. */\nexport function placementKeyIssues(host: unknown): PlacementKeyIssue[] {\n return collectIssues(host, refineDeclaredPlacementKeys);\n}\n\nexport const CONNECT_PRIMARY_MESSAGE =\n \"Connect doesn't use placement.primary. To choose where new drives go, use placement.newDrives.\";\n\n/**\n * A Connect host's placement rules, in either form. The router's primary is\n * the browser reactor, else the `newDrives` switchboard, else the only one,\n * so `placement.primary` means nothing here, and a Connect with several\n * switchboards and no browser reactor must say where new drives go. Apply it\n * last to the Connect runner's schema: `.superRefine(refineConnectReactor)`.\n */\nexport function refineConnectReactor(\n host: { reactor?: unknown },\n ctx: z.RefinementCtx,\n): void {\n const reactor = (host as DeclaredReactorHost).reactor;\n if (!reactor) return;\n if (reactor.placement?.primary !== undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"reactor\", \"placement\", \"primary\"],\n message: CONNECT_PRIMARY_MESSAGE,\n });\n }\n const backends = Object.entries(reactor.backends ?? {});\n const remotes = backends\n .filter(([, backend]) => backend.kind === \"remote\")\n .map(([name]) => name);\n if (\n remotes.length > 1 &&\n remotes.length === backends.length &&\n reactor.placement?.newDrives === undefined\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"reactor\", \"placement\", \"newDrives\"],\n message: `This Connect keeps no reactor in the browser and links ${remotes.length} switchboards (${remotes.join(\", \")}). Set placement.newDrives to the one new drives are created on.`,\n });\n }\n}\n\n/** refineConnectReactor's check, for a Connect host parsed some other way. */\nexport function connectReactorIssues(host: unknown): PlacementKeyIssue[] {\n return collectIssues(host, refineConnectReactor);\n}\n\n/** Adds the host-level placement key check to a runner's declared schema. */\nfunction withPlacementKeys<T>(schema: T): T {\n if (!(schema instanceof z.ZodType)) return schema;\n return schema.superRefine((host, ctx) => {\n if (typeof host === \"object\" && host !== null && \"reactor\" in host) {\n refineDeclaredPlacementKeys(host as DeclaredReactorHost, ctx);\n }\n }) as T;\n}\n\n/**\n * One runner definition, two schemas (3.5): `build` runs over the DECLARED\n * set (tokens allowed; its z.input types host files) and the RESOLVED set\n * (no tokens; `validateHost` checks it before the verb). Export both, type\n * the host as `z.input<typeof declaredHostSchema>`, refine last inside the\n * builder (zod can't extend a refined object), and wrap the runner's own\n * token-able fields with `s.tokenable` / `s.envTokenable`.\n */\nexport function defineHostSchemas<T>(build: (schemas: HostSchemas) => T): {\n declaredHostSchema: T;\n hostSchema: T;\n} {\n return {\n declaredHostSchema: withPlacementKeys(build(declaredSchemas)),\n hostSchema: build(resolvedSchemas),\n };\n}\n\nconst declaredSchemas = makeHostSchemas({ tokens: \"allow\" });\nconst resolvedSchemas = makeHostSchemas({ tokens: \"forbid\" });\n\n/* The exported base blocks are the RESOLVED form (what verbs receive). The\n * declared forms are `declaredHostSchemas` / `defineHostSchemas`. */\nexport const declaredHostSchemas: HostSchemas = declaredSchemas;\nexport const reactorBackendSchema = resolvedSchemas.reactorBackendSchema;\nexport const reactorSchema = resolvedSchemas.reactorSchema;\nexport const runnerBaseSchema = resolvedSchemas.runnerBaseSchema;\nexport const childWrapperSchema = resolvedSchemas.childWrapperSchema;\nexport const childrenSchema = resolvedSchemas.childrenSchema;\nexport const reactorHostSchema = resolvedSchemas.reactorHostSchema;\nexport const compoundHostSchema = resolvedSchemas.compoundHostSchema;\n\n/** The generic compound runner's host: the base with its wiring config. */\nconst genericCompound = defineHostSchemas((s) =>\n s.compoundHostSchema\n .extend({ config: compoundWiringSchema.optional() })\n .superRefine(refineStartOrder),\n);\nexport const genericCompoundHostSchema = genericCompound.hostSchema;\nexport const declaredGenericCompoundHostSchema =\n genericCompound.declaredHostSchema;\n\n/* -------------------------------------------------------------------- types */\n\nexport type Profile = z.infer<typeof profileSchema>;\nexport type ReactorProtocol = z.infer<typeof reactorProtocolSchema>;\nexport type ReactorBackend = z.infer<typeof reactorBackendSchema>;\nexport type ReactorBackendKind = ReactorBackend[\"kind\"];\nexport type ReactorStorageConfig = NonNullable<ReactorBackend[\"storage\"]>;\nexport type ReactorPackageConfig = NonNullable<ReactorBackend[\"packages\"]>;\nexport type ReactorRemoteConfig = NonNullable<ReactorBackend[\"remote\"]>;\nexport type ReactorConfig = z.infer<typeof reactorSchema>;\nexport type RunnerBase = z.infer<typeof runnerBaseSchema>;\nexport type ChildWrapper = z.infer<typeof childWrapperSchema>;\nexport type CompoundWiring = z.infer<typeof compoundWiringSchema>;\n\n/** What a host.js author writes (z.input), per runner kind. The `never`\n * sides make reactor XOR children a type error. */\nexport type ReactorHostInput = z.input<\n typeof declaredSchemas.reactorHostSchema\n> & {\n children?: never;\n};\nexport type CompoundHostInput = z.input<\n typeof declaredSchemas.compoundHostSchema\n> & {\n reactor?: never;\n};\nexport type HostDefinition = ReactorHostInput | CompoundHostInput;\n\n/** What a verb receives (z.output) from the base schemas. */\nexport type ReactorHost = z.output<typeof reactorHostSchema>;\nexport type CompoundHost = z.output<typeof compoundHostSchema>;\n\n/* --------------------------------------------------------------- JSON Schema */\n\nconst SCHEMA_BASE = \"https://powerhouse.inc/schemas\";\n\n/** One host schema as an editor JSON Schema with a stable `$id` — the\n * per-runner emission helper (runner packages emit their own hostSchema). */\nexport function emitHostJsonSchema(\n name: string,\n schema: z.ZodType,\n): Record<string, unknown> {\n return {\n $id: `${SCHEMA_BASE}/${name}.schema.json`,\n ...z.toJSONSchema(schema, { io: \"input\" }),\n };\n}\n\n/** The emitted-schema set, keyed by published filename. Pure — the\n * emit-schemas script writes these and the drift test re-derives them. */\nexport function emittedHostSchemas(): Record<string, unknown> {\n return {\n // Editor schemas describe what authors write: the declared form.\n \"host-reactor.schema.json\": emitHostJsonSchema(\n \"host-reactor\",\n declaredSchemas.reactorHostSchema,\n ),\n \"host-compound.schema.json\": emitHostJsonSchema(\n \"host-compound\",\n declaredSchemas.compoundHostSchema,\n ),\n };\n}\n","/**\n * Pure built-in `$env` substitution: the `\"${userData}\"` / `\"${projectRoot}\"`\n * string sugar, deep-applied to a JSON-shaped value. No node imports, so it\n * ships in `./schema`; the node default for userData is placeholders.ts.\n */\n\nexport interface BuiltinEnv {\n userData?: string;\n projectRoot?: string;\n}\n\n/** The always-resolvable `$env` names (also the `\"${name}\"` sugar). */\nexport const BUILTIN_ENV_NAMES: readonly (keyof BuiltinEnv)[] = [\n \"userData\",\n \"projectRoot\",\n];\n\nexport function isBuiltinEnvName(name: string): name is keyof BuiltinEnv {\n return (BUILTIN_ENV_NAMES as readonly string[]).includes(name);\n}\n\nconst BUILTIN = new RegExp(`\\\\$\\\\{(${BUILTIN_ENV_NAMES.join(\"|\")})\\\\}`, \"g\");\n\nfunction substitute(text: string, env: BuiltinEnv): string {\n return text.replace(\n BUILTIN,\n (match, name: keyof BuiltinEnv) => env[name] ?? match,\n );\n}\n\n/** Deep-substitute the built-ins that `env` provides in every string; an\n * absent built-in is left as written. The input is never mutated. */\nexport function substituteBuiltinEnv<T>(value: T, env: BuiltinEnv): T {\n return substituteValue(value, env) as T;\n}\n\nfunction substituteValue(value: unknown, env: BuiltinEnv): unknown {\n if (typeof value === \"string\") return substitute(value, env);\n if (Array.isArray(value)) return value.map((v) => substituteValue(v, env));\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n out[k] = substituteValue(v, env);\n }\n return out;\n }\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,4BACd,UACA;CACA,OAAO,EAAE,aAAa;EACpB,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EACtB,IAAI,EAA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4BAA4B,mBAC1B,gBACA,gBAAgB,iBAClB;EACA,6BAA6B,mBAC3B,iBACA,gBAAgB,kBAClB;CACF;AACF;;;;ACzzBA,MAAa,oBAAmD,CAC9D,YACA,aACF;AAEA,SAAgB,iBAAiB,MAAwC;CACvE,OAAQ,kBAAwC,SAAS,IAAI;AAC/D;AAEA,MAAM,UAAU,IAAI,OAAO,UAAU,kBAAkB,KAAK,GAAG,EAAE,OAAO,GAAG;AAE3E,SAAS,WAAW,MAAc,KAAyB;CACzD,OAAO,KAAK,QACV,UACC,OAAO,SAA2B,IAAI,SAAS,KAClD;AACF;;;AAIA,SAAgB,qBAAwB,OAAU,KAAoB;CACpE,OAAO,gBAAgB,OAAO,GAAG;AACnC;AAEA,SAAS,gBAAgB,OAAgB,KAA0B;CACjE,IAAI,OAAO,UAAU,UAAU,OAAO,WAAW,OAAO,GAAG;CAC3D,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,MAAM,gBAAgB,GAAG,GAAG,CAAC;CACzE,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAC/C,MAAM,MAA+B,CAAC;EACtC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,KAAK,GACvC,IAAI,KAAK,gBAAgB,GAAG,GAAG;EAEjC,OAAO;CACT;CACA,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-substitution-C_fVirPh.d.mts","names":[],"sources":["../src/env-substitution.ts"],"mappings":";;;;;;UAMiB;EACf;EACA;;;;iBAwBc,qBAAqB,GAAG,OAAO,GAAG,KAAK,aAAa"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-schemas-BM7F21lf.d.mts","names":[],"sources":["../src/host-schemas.ts"],"mappings":";;;;;;;;;;;;;;;;cA2Ba,mBAAiB;cACjB;cACA;cAEA,gBAAc,EAAA;cAkBd,eAAa,EAAA;;;;;GAKxB,EAAA,KAAA;cAEW,uBA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A,EAAA;;;;;GAG5B,EAAA,KAAA;;;KAIU,kBAAkB,EAAE,aAAa;UAG5B;EACf;EACA;EACA;EACA,QAAQ;;iBAGM,qBACd,OAAO,kBACN;;;iBAca,uBACd,kBAAkB,mBAClB,gBACC;iBAea,mBACd,OAAO,uBACP;iBAsBc,iBAAiB,YAAY;iBAS7B,kBACd,kBACA;;;KAcU,QAAQ,GAAG,MAAM,KAAK,MAAM,IAAI,QAAQ;KACxC,UAAU,GAAG,MAAM,OAAO,GAAG,KAAK,MAAM,IAAI,QAAQ;KACpD,QAAQ,MAAM,KAAK,aAAa;;;;;;;UAQ3B;EACf;EACA;EACA;IAAuB;IAAc;IAAe;;GACnD;;UAGc,WACf,SAAS,yBACT;;EAGA;;;EAGA;;EAEA;;;EAGA;;;EAGA,eAAe,EAAE,QAAQ;EACzB,QAAQ,QAAQ;EAChB,gBAAgB;;;;KAKN,iBACV,SAAS,yBACT,qBAEE,WAAW,QAAQ,aACjB,QAAQ,YAAY,WAAW,QAAQ;UAE5B,eAAe,SAAS;EACvC,OAAO;EACP,QAAQ,WAAW;;EAEnB;;;;iBAOc,aAAa,QAC3B,kBAAkB,WAAW,YAC5B,WAAW;iBA6CQ,eAAe,GAAG,GACtC,cACA,kBAAkB,cAClB,KAAK,IACJ,QAAQ;iBAWW,iBAAiB,GAAG,GACxC,cACA,kBAAkB,cAClB,KAAK,GACL,MAAM,IACL,QAAQ;;;;iBAYW,yBAAyB,GAC7C,cACA,kBAAkB,cAClB,KAAK,IACJ;iBAOmB,eAAe,GACnC,cACA,kBAAkB,cAClB,KAAK,IACJ;UAWc;EACf;EACA;;UAGe,mBAAmB;EAClC,OAAO;EACP,QAAQ;;;;iBAKM,mBACd;EACE,QAAQ;EACR,YAAY;MAEb,eAAe"}
|
package/dist/plugins.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":[],"sources":["../src/plugins.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * R1 — the host plugin framework (bridge-runners-to-plugins plan,\n * customization-references/host-core as the blueprint).\n *\n * A plugin is hooks + contributions; hooks are boot wiring (main realm only),\n * contributions are declarative, serializable surface. Host RUNTIMES define\n * the hook vocabulary and interleave their own wiring between stages — they\n * are never plugins themselves.\n *\n * host.js carries the COMPOSITION as `runner.plugins` entries:\n * string | { module, enabled?, verbs?, config? }\n * Presence is activation (enabled defaults true); `verbs` scopes an entry to\n * matching run verbs; `config` is validated against the plugin's declared\n * zod schema. Entries resolve from the PROJECT's dependency tree exactly\n * like runner modules.\n */\n\nexport class PluginError extends Error {\n constructor(message: string, hint?: string) {\n super(hint ? `${message}\\n Hint: ${hint}` : message);\n this.name = \"PluginError\";\n }\n}\n\n/* ------------------------------------------------------------------ entries */\n\nexport const pluginEntryObjectSchema = z.strictObject({\n module: z.string().min(1),\n /** Presence is activation BY DEFAULT; false is the explicit off-switch. */\n enabled: z.boolean().optional(),\n /** \"*\" (default) or the run verbs this entry is active for. */\n verbs: z\n .union([z.literal(\"*\"), z.array(z.string().min(1)).min(1)])\n .optional(),\n /** Validated against the plugin's declared configSchema at resolution. */\n config: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const pluginEntrySchema = z.union([\n z.string().min(1),\n pluginEntryObjectSchema,\n]);\n\n/** The validated (runtime) entry shape. Authors write `PluginEntry`\n * (host-types.ts), which types known plugins' configs. */\nexport type PluginEntryData = z.infer<typeof pluginEntrySchema>;\nexport type { PluginEntry } from \"./host-types.js\";\n\nexport interface NormalizedPluginEntry {\n module: string;\n enabled: boolean;\n verbs: \"*\" | string[];\n config: Record<string, unknown>;\n}\n\nexport function normalizePluginEntry(\n entry: PluginEntryData,\n): NormalizedPluginEntry {\n if (typeof entry === \"string\") {\n return { module: entry, enabled: true, verbs: \"*\", config: {} };\n }\n return {\n module: entry.module,\n enabled: entry.enabled ?? true,\n verbs: entry.verbs ?? \"*\",\n config: entry.config ?? {},\n };\n}\n\n/** Module is the identity key: a duplicate makes override targeting and\n * ordering ambiguous, so it fails loudly. */\nexport function normalizePluginEntries(\n entries: readonly PluginEntryData[],\n where: string,\n): NormalizedPluginEntry[] {\n const normalized = entries.map(normalizePluginEntry);\n const seen = new Set<string>();\n for (const entry of normalized) {\n if (seen.has(entry.module)) {\n throw new PluginError(\n `${where}: plugin \"${entry.module}\" is listed twice.`,\n \"Module specifiers are the identity key of a composition; a plugin meant to run twice needs distinct subpath specifiers.\",\n );\n }\n seen.add(entry.module);\n }\n return normalized;\n}\n\nexport function entryActiveForVerb(\n entry: NormalizedPluginEntry,\n verb: string,\n): boolean {\n if (!entry.enabled) return false;\n return entry.verbs === \"*\" || entry.verbs.includes(verb);\n}\n\n/* ---------------------------------------------------------------- hierarchy */\n\n/**\n * The appliesTo hierarchy. \"reactor\" is the base every reactor host extends;\n * \"compound\" is its own branch (plugins over the member set — e.g. the clint\n * proxy). Host runtimes register their id with a parent; compatibility walks\n * the parent chain.\n */\nconst HOST_TYPE_PARENTS: Record<string, string | null> = {\n reactor: null,\n compound: null,\n connect: \"reactor\",\n switchboard: \"reactor\",\n mastra: \"reactor\",\n};\n\nexport function registerHostType(id: string, parent: string | null): void {\n if (id in HOST_TYPE_PARENTS && HOST_TYPE_PARENTS[id] !== parent) {\n throw new PluginError(\n `Host type \"${id}\" is already registered with parent \"${String(HOST_TYPE_PARENTS[id])}\".`,\n );\n }\n HOST_TYPE_PARENTS[id] = parent;\n}\n\nexport function hostTypeSatisfies(\n hostType: string,\n appliesTo: string,\n): boolean {\n let current: string | null = hostType;\n while (current !== null) {\n if (current === appliesTo) return true;\n current = current in HOST_TYPE_PARENTS ? HOST_TYPE_PARENTS[current] : null;\n }\n return false;\n}\n\n/* ------------------------------------------------------------------- plugin */\n\n/** Hook kinds (v1 §2.2). The hook VOCABULARY is defined by host runtimes;\n * plugins implement subsets of it. */\nexport type Provide<T, C> = (ctx: C) => T | Promise<T>;\nexport type Transform<T, C> = (value: T, ctx: C) => T | Promise<T>;\nexport type Observe<C> = (ctx: C) => void | Promise<void>;\n\n/**\n * Core contributions — declarative, serializable, realm-crossing. Host\n * runtimes extend this with their own kinds (UI slots live in connect-host,\n * never here). `drives` entries use the drive declaration shape from\n * drives.ts; kept as unknown here to avoid a cycle — the merge is shape-blind.\n */\nexport interface Contributions {\n drives?: unknown[];\n packages?: string[];\n configDeclarations?: { name: string; type?: string; description?: string }[];\n [kind: string]: unknown[] | undefined;\n}\n\nexport interface HostPlugin<\n THooks = Record<string, unknown>,\n TConfig = unknown,\n> {\n /** Stable id; used in ordering, dependsOn, and every diagnostic. */\n name: string;\n /** Host-type requirement; the entry is rejected on a host outside the\n * hierarchy branch. Default: \"reactor\". */\n appliesTo?: string;\n /** Coarse ordering bucket (Vite-style). Default: \"normal\". */\n enforce?: \"pre\" | \"post\";\n /** Hard dependencies on OTHER PLUGINS — the host runtime is implied and\n * never named. Missing dependency or cycle fails boot naming both sides. */\n dependsOn?: string[];\n /** Declared config shape; entry config is validated against it. A plugin\n * without a schema accepts no config (passing one is a boot error). */\n configSchema?: z.ZodType<TConfig>;\n hooks?: Partial<THooks>;\n contributions?: Contributions;\n}\n\n/** A plugin module default-exports either a HostPlugin object (no config\n * accepted) or a factory `(config) => HostPlugin`. */\nexport type HostPluginModule<\n THooks = Record<string, unknown>,\n TConfig = unknown,\n> =\n | HostPlugin<THooks, TConfig>\n | ((config: TConfig) => HostPlugin<THooks, TConfig>);\n\nexport interface ResolvedPlugin<THooks = Record<string, unknown>> {\n entry: NormalizedPluginEntry;\n plugin: HostPlugin<THooks>;\n /** Provenance for contribution merge ordering. */\n provenance: \"built-in\" | \"local\" | \"dependency\";\n}\n\n/* ----------------------------------------------------------------- ordering */\n\n/** Registration order, bucketed pre → normal → post (stable within buckets),\n * then dependsOn topo-sorted within the bucketed order. */\nexport function resolveOrder<THooks>(\n plugins: readonly HostPlugin<THooks>[],\n): HostPlugin<THooks>[] {\n const buckets: Record<\"pre\" | \"normal\" | \"post\", HostPlugin<THooks>[]> = {\n pre: [],\n normal: [],\n post: [],\n };\n for (const plugin of plugins)\n buckets[plugin.enforce ?? \"normal\"].push(plugin);\n const bucketed = [...buckets.pre, ...buckets.normal, ...buckets.post];\n\n const byName = new Map(bucketed.map((p) => [p.name, p]));\n for (const plugin of bucketed) {\n for (const dep of plugin.dependsOn ?? []) {\n if (!byName.has(dep)) {\n throw new PluginError(\n `Plugin \"${plugin.name}\" depends on missing plugin \"${dep}\".`,\n \"dependsOn names PLUGINS only — the host runtime is implied and never named.\",\n );\n }\n }\n }\n\n const ordered: HostPlugin<THooks>[] = [];\n const state = new Map<string, \"visiting\" | \"done\">();\n const visit = (plugin: HostPlugin<THooks>, chain: string[]): void => {\n const mark = state.get(plugin.name);\n if (mark === \"done\") return;\n if (mark === \"visiting\") {\n throw new PluginError(\n `Plugin dependency cycle: ${[...chain, plugin.name].join(\" -> \")}.`,\n );\n }\n state.set(plugin.name, \"visiting\");\n for (const dep of plugin.dependsOn ?? []) {\n visit(byName.get(dep)!, [...chain, plugin.name]);\n }\n state.set(plugin.name, \"done\");\n ordered.push(plugin);\n };\n for (const plugin of bucketed) visit(plugin, []);\n return ordered;\n}\n\n/* -------------------------------------------------------------------- hooks */\n\nexport async function runProvideHook<T, C>(\n name: string,\n plugins: readonly HostPlugin[],\n ctx: C,\n): Promise<T | undefined> {\n const impls = plugins.filter((p) => typeof p.hooks?.[name] === \"function\");\n if (impls.length > 1) {\n throw new PluginError(\n `Hook \"${name}\" is provided by ${impls.map((p) => `\"${p.name}\"`).join(\" and \")} — provide hooks have one winner.`,\n );\n }\n const impl = impls[0]?.hooks?.[name] as Provide<T, C> | undefined;\n return impl ? await impl(ctx) : undefined;\n}\n\nexport async function runTransformHook<T, C>(\n name: string,\n plugins: readonly HostPlugin[],\n ctx: C,\n seed: T,\n): Promise<T> {\n let value = seed;\n for (const plugin of plugins) {\n const impl = plugin.hooks?.[name] as Transform<T, C> | undefined;\n if (typeof impl === \"function\") value = await impl(value, ctx);\n }\n return value;\n}\n\n/** Sequential observe, in plugin order — for lifecycle moments whose order\n * is load-bearing (teardown: the switchboard stops privacy before workflows\n * before the api, per the carve map). */\nexport async function runObserveHookSequential<C>(\n name: string,\n plugins: readonly HostPlugin[],\n ctx: C,\n): Promise<void> {\n for (const plugin of plugins) {\n const impl = plugin.hooks?.[name] as Observe<C> | undefined;\n if (typeof impl === \"function\") await impl(ctx);\n }\n}\n\nexport async function runObserveHook<C>(\n name: string,\n plugins: readonly HostPlugin[],\n ctx: C,\n): Promise<void> {\n await Promise.all(\n plugins.map(async (plugin) => {\n const impl = plugin.hooks?.[name] as Observe<C> | undefined;\n if (typeof impl === \"function\") await impl(ctx);\n }),\n );\n}\n\n/* ------------------------------------------------------------ contributions */\n\nexport interface ContributionSource {\n pluginName: string;\n provenance: \"built-in\" | \"local\" | \"dependency\";\n}\n\nexport interface MergedContribution<T = unknown> {\n value: T;\n source: ContributionSource;\n}\n\n/** Array kinds concatenate in provenance-then-order sequence (built-in first,\n * so later sources read as overrides where consumers want last-wins). */\nexport function mergeContributions(\n resolved: readonly {\n plugin: HostPlugin;\n provenance: ContributionSource[\"provenance\"];\n }[],\n): Record<string, MergedContribution[]> {\n const rank: Record<ContributionSource[\"provenance\"], number> = {\n \"built-in\": 0,\n local: 1,\n dependency: 2,\n };\n const sorted = [...resolved].sort(\n (a, b) => rank[a.provenance] - rank[b.provenance],\n );\n const merged: Record<string, MergedContribution[]> = {};\n for (const { plugin, provenance } of sorted) {\n for (const [kind, values] of Object.entries(plugin.contributions ?? {})) {\n if (!values) continue;\n const bucket = (merged[kind] ??= []);\n for (const value of values) {\n bucket.push({ value, source: { pluginName: plugin.name, provenance } });\n }\n }\n }\n return merged;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAY,SAAiB,MAAe;EAC1C,MAAM,OAAO,GAAG,QAAQ,YAAY,SAAS,OAAO;EACpD,KAAK,OAAO;CACd;AACF;AAIA,MAAa,0BAA0B,EAAE,aAAa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