@powerhousedao/host-core 6.2.3-dev.55 → 6.2.3-dev.56

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.
@@ -492,7 +492,10 @@ const childrenSchema = z.record(z.string(), z.strictObject({
492
492
  config: z.looseObject({}).optional(),
493
493
  reactor: reactorSchema.optional()
494
494
  }));
495
- z.looseObject({
495
+ /** Composed generic host shapes — the basis for the emitted editor schemas
496
+ * (D2.a). Runner packages extend these with their own runner options; `config`
497
+ * stays loose by design. */
498
+ const reactorHostSchema = z.looseObject({
496
499
  name: z.string().min(1),
497
500
  runner: runnerBaseSchema,
498
501
  config: z.looseObject({}).optional(),
@@ -506,7 +509,21 @@ const compoundHostSchema = z.looseObject({
506
509
  config: z.looseObject({}).optional(),
507
510
  profile: profileSchema
508
511
  });
512
+ const SCHEMA_BASE = "https://powerhouse.inc/schemas";
513
+ /** The emitted-schema set, keyed by published filename. Pure — the
514
+ * emit-schemas script writes these to disk and the drift test re-derives
515
+ * them, per the runtime-config-schema pattern. */
516
+ function emittedHostSchemas() {
517
+ const emit = (name, schema) => ({
518
+ $id: `${SCHEMA_BASE}/${name}.schema.json`,
519
+ ...z.toJSONSchema(schema, { io: "input" })
520
+ });
521
+ return {
522
+ "host-reactor.schema.json": emit("host-reactor", reactorHostSchema),
523
+ "host-compound.schema.json": emit("host-compound", compoundHostSchema)
524
+ };
525
+ }
509
526
  //#endregion
510
- export { lintHostImports as C, projectDrivesIntoConnect as D, mergeDefaultDrives as E, rebaseDriveUrl as O, findNonStaticValue as S, probeHostsFolder as T, getVerb as _, reactorProtocolSchema as a, validateHost as b, runCompound as c, clearRunRecord as d, isPidAlive as f, RunnerError as g, writeRunRecord as h, reactorBackendSchema as i, defaultUserDataDir as l, readRunRecord as m, compoundHostSchema as n, reactorSchema as o, probeRun as p, profileSchema as r, runnerBaseSchema as s, childrenSchema as t, resolveUserDataPlaceholders as u, listVerbs as v, loadHost as w, HostLoadError as x, resolveRunnerModule as y };
527
+ export { rebaseDriveUrl as A, HostLoadError as C, probeHostsFolder as D, loadHost as E, mergeDefaultDrives as O, validateHost as S, lintHostImports as T, writeRunRecord as _, reactorBackendSchema as a, listVerbs as b, reactorSchema as c, defaultUserDataDir as d, resolveUserDataPlaceholders as f, readRunRecord as g, probeRun as h, profileSchema as i, projectDrivesIntoConnect as k, runnerBaseSchema as l, isPidAlive as m, compoundHostSchema as n, reactorHostSchema as o, clearRunRecord as p, emittedHostSchemas as r, reactorProtocolSchema as s, childrenSchema as t, runCompound as u, RunnerError as v, findNonStaticValue as w, resolveRunnerModule as x, getVerb as y };
511
528
 
512
- //# sourceMappingURL=host-schemas-B0-Vk8vP.mjs.map
529
+ //# sourceMappingURL=host-schemas-C_MLcYX6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-schemas-B0-Vk8vP.mjs","names":[],"sources":["../src/connect-projection.ts","../src/host-loader.ts","../src/runner-resolver.ts","../src/run-record.ts","../src/placeholders.ts","../src/compound.ts","../src/host-schemas.ts"],"sourcesContent":["import type {\n PHConnectDefaultDrive,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\n\n/**\n * Instance-fact projection for compound hosts: the drives a compound's\n * reactor member created, projected into the Connect member's runtime-config\n * override. Pure functions, moved from ph-cli's vetra service so the generic\n * compound and the classic path share one implementation.\n */\n\nfunction isLocalDrive(\n drive: PHConnectDefaultDrive,\n): drive is Extract<PHConnectDefaultDrive, { local: true }> {\n return \"local\" in drive;\n}\n\n// Identity key for de-duplication: remote entries are keyed by URL; local\n// entries are keyed by `local:<id>` so a local drive id can never collide\n// with a remote URL that happens to be the same string.\nconst driveKey = (drive: PHConnectDefaultDrive): string =>\n isLocalDrive(drive) ? `local:${drive.id}` : drive.url;\n\n/**\n * Concatenate groups of `connect.drives.defaultDrives` in the order given,\n * de-duplicating by drive identity (URL for remote entries, id for local\n * ones). The first occurrence of a drive wins, so earlier groups keep their\n * position and metadata — e.g. the Vetra drive `ph vetra` starts stays first\n * even when the project's `powerhouse.config.json` lists the same drive.\n */\nexport function mergeDefaultDrives(\n ...groups: PHConnectDefaultDrive[][]\n): PHConnectDefaultDrive[] {\n const seen = new Set<string>();\n const out: PHConnectDefaultDrive[] = [];\n for (const group of groups) {\n for (const drive of group) {\n const key = driveKey(drive);\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(drive);\n }\n }\n return out;\n}\n\n/**\n * Rebase a local drive URL onto a public base: keeps the /d/<slug> path,\n * swaps the loopback origin for the public base. Browser clients behind a\n * reverse proxy can't reach http://localhost:<port>. Non-loopback URLs\n * (e.g. a remote drive) are already public and pass through unchanged, as do\n * unparseable ones.\n */\nexport function rebaseDriveUrl(driveUrl: string, publicBase: string): string {\n let url: URL;\n try {\n url = new URL(driveUrl);\n } catch {\n return driveUrl;\n }\n if (![\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname)) {\n return driveUrl;\n }\n return `${publicBase.replace(/\\/+$/, \"\")}${url.pathname}`;\n}\n\nexport interface DriveProjectionInput {\n /** Drive URLs the compound's reactor member created, in display order\n * (e.g. vetra, preview, workflows). Null/undefined entries are skipped. */\n createdDriveUrls: (string | null | undefined)[];\n /** The project's configured `connect.drives.defaultDrives`. */\n configuredDefaultDrives?: PHConnectDefaultDrive[];\n /** `--drives-public-base`: advertise proxy-reachable URLs to the browser. */\n publicBase?: string | null;\n}\n\n/**\n * The compound's drives projection: created drives first (rebased onto the\n * public base when given), then the project's configured drives, de-duplicated\n * — and `preserve-all`, because compound-injected drive lists change per\n * launch context and must never detach drives the user added by hand.\n */\nexport function projectDrivesIntoConnect(\n input: DriveProjectionInput,\n): Pick<PHConnectRuntimeConfig, \"drives\"> {\n const created: PHConnectDefaultDrive[] = input.createdDriveUrls\n .filter((url): url is string => typeof url === \"string\" && url.length > 0)\n .map((url) => ({\n url: input.publicBase ? rebaseDriveUrl(url, input.publicBase) : url,\n name: null,\n icon: null,\n }));\n return {\n drives: {\n defaultDrives: mergeDefaultDrives(\n created,\n input.configuredDefaultDrives ?? [],\n ),\n preserveStrategy: \"preserve-all\",\n },\n };\n}\n","import { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Loads and pre-validates a `hosts/<name>/host.js` definition.\n *\n * A host file is a static PROJECTION of powerhouse.config.json: plain ESM,\n * default-exporting a data object. Three gates run before any runner sees it:\n * 1. import lint — the only legal import is the project's\n * powerhouse.config.json (host files are data, not programs);\n * 2. static check — the exported object must survive a JSON round trip\n * (functions, undefined, class instances, Dates etc. are rejected,\n * reporting the offending path);\n * 3. shape pre-check — `name`, `runner.module`, and the reactor XOR children\n * rule. Full validation is the runner's `hostSchema` (phase 2).\n *\n * This module never exits the process — callers own error presentation.\n */\n\nconst HOST_FILE = \"host.js\";\nconst CONFIG_IMPORT_SUFFIX = \"powerhouse.config.json\";\n\nexport class HostLoadError extends Error {\n constructor(message: string, hint?: string) {\n super(hint ? `${message}\\n Hint: ${hint}` : message);\n this.name = \"HostLoadError\";\n }\n}\n\nexport type HostsFolderStatus =\n | { kind: \"absent\" }\n | { kind: \"empty\"; dir: string }\n | { kind: \"present\"; dir: string; hosts: string[] };\n\n/** A `hosts/` folder with no `<name>/host.js` inside is \"empty\" — the guard\n * state: callers warn loudly and fall back to legacy rather than activating\n * the new architecture off a stray `mkdir hosts`. */\nexport function probeHostsFolder(projectRoot: string): HostsFolderStatus {\n const dir = path.join(projectRoot, \"hosts\");\n if (!existsSync(dir) || !statSync(dir).isDirectory()) {\n return { kind: \"absent\" };\n }\n const hosts = readdirSync(dir, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() &&\n existsSync(path.join(dir, entry.name, HOST_FILE)),\n )\n .map((entry) => entry.name)\n .sort();\n return hosts.length === 0\n ? { kind: \"empty\", dir }\n : { kind: \"present\", dir, hosts };\n}\n\n/** Rejects every import except the project's powerhouse.config.json, plus any\n * dynamic `import(...)` or `require(...)`. Source-level enforcement: the JSON\n * round trip below is the hard gate; this one produces the better error. */\nexport function lintHostImports(source: string, file: string): void {\n for (const match of source.matchAll(\n /^\\s*import\\b[^;'\"]*?from\\s+[\"']([^\"']+)[\"']/gm,\n )) {\n const specifier = match[1];\n if (!specifier.endsWith(CONFIG_IMPORT_SUFFIX)) {\n throw new HostLoadError(\n `${file} imports \"${specifier}\" — a host file may only import the project's powerhouse.config.json.`,\n \"Host files are static projections; code belongs in plugins.js or the runner.\",\n );\n }\n }\n if (/^\\s*import\\s+[\"']/m.test(source)) {\n throw new HostLoadError(\n `${file} contains a side-effect import — a host file may only import the project's powerhouse.config.json.`,\n );\n }\n if (/\\bimport\\s*\\(/.test(source) || /\\brequire\\s*\\(/.test(source)) {\n throw new HostLoadError(\n `${file} uses dynamic import()/require() — host files are static data.`,\n );\n }\n}\n\n/** Returns the path of the first value that would not survive a JSON round\n * trip, or undefined when the object is fully static. */\nexport function findNonStaticValue(\n value: unknown,\n trail = \"\",\n): string | undefined {\n if (value === null) return undefined;\n const kind = typeof value;\n if (kind === \"string\" || kind === \"number\" || kind === \"boolean\") {\n return undefined;\n }\n if (kind !== \"object\") {\n return `${trail || \"<root>\"} (${kind})`;\n }\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const hit = findNonStaticValue(value[i], `${trail}[${i}]`);\n if (hit) return hit;\n }\n return undefined;\n }\n const proto: unknown = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null) {\n return `${trail || \"<root>\"} (non-plain object)`;\n }\n for (const [key, child] of Object.entries(value as Record<string, unknown>)) {\n const hit = findNonStaticValue(child, trail ? `${trail}.${key}` : key);\n if (hit) return hit;\n }\n return undefined;\n}\n\nexport interface HostDefinition {\n name: string;\n runner: { module: string } & Record<string, unknown>;\n config?: Record<string, unknown>;\n profile?: Record<string, unknown>;\n reactor?: Record<string, unknown>;\n children?: Record<string, unknown>;\n}\n\nexport interface LoadedHost {\n name: string;\n dir: string;\n file: string;\n host: HostDefinition;\n}\n\nfunction assertHostShape(\n host: Record<string, unknown>,\n file: string,\n): asserts host is HostDefinition & Record<string, unknown> {\n if (typeof host.name !== \"string\" || host.name.length === 0) {\n throw new HostLoadError(`${file}: \\`name\\` must be a non-empty string.`);\n }\n const runner = host.runner;\n if (\n runner === null ||\n typeof runner !== \"object\" ||\n typeof (runner as Record<string, unknown>).module !== \"string\"\n ) {\n throw new HostLoadError(\n `${file}: \\`runner\\` must be an object with a \\`module\\` specifier string.`,\n );\n }\n if (host.reactor !== undefined && host.children !== undefined) {\n throw new HostLoadError(\n `${file}: \\`reactor\\` and \\`children\\` are mutually exclusive — a host is a reactor runner or a compound runner, never both.`,\n );\n }\n}\n\nexport async function loadHost(\n projectRoot: string,\n hostName: string,\n): Promise<LoadedHost> {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"absent\") {\n throw new HostLoadError(\n `No hosts/ folder found in ${projectRoot}.`,\n \"Scaffold one with `ph init --uniform-runners` (or create hosts/<name>/host.js).\",\n );\n }\n if (probe.kind === \"empty\") {\n throw new HostLoadError(\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js.`,\n \"An empty hosts/ folder does not activate the uniform-runners architecture; add a host definition or remove the folder.\",\n );\n }\n if (!probe.hosts.includes(hostName)) {\n throw new HostLoadError(\n `Unknown host \"${hostName}\". Available hosts: ${probe.hosts.join(\", \")}.`,\n );\n }\n\n const file = path.join(probe.dir, hostName, HOST_FILE);\n lintHostImports(readFileSync(file, \"utf8\"), file);\n\n const module = (await import(pathToFileURL(file).href)) as {\n default?: unknown;\n };\n const host = module.default;\n if (host === null || typeof host !== \"object\" || Array.isArray(host)) {\n throw new HostLoadError(\n `${file} must default-export the host object (\\`export default { name, runner, ... }\\`).`,\n );\n }\n\n const nonStatic = findNonStaticValue(host);\n if (nonStatic) {\n throw new HostLoadError(\n `${file} exports a non-static value at \\`${nonStatic}\\` — host files must survive a JSON round trip.`,\n \"Runtime behavior belongs in the runner; host files only carry data.\",\n );\n }\n\n assertHostShape(host as Record<string, unknown>, file);\n return {\n name: hostName,\n dir: path.dirname(file),\n file,\n host: host as HostDefinition,\n };\n}\n","import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { HostDefinition } from \"./host-loader.js\";\n\n/**\n * Resolves a host's `runner.module` specifier from the PROJECT's dependency\n * tree (not ph-cli's), imports it, and checks the runner-module contract:\n * `{ run, hostSchema, kind, ...optionalVerbs }`. Phase-0 home is ph-cli; the\n * uniform-runners plan moves this into @powerhousedao/host-core with the\n * generic compound (phase 1).\n */\n\nexport class RunnerError extends Error {\n constructor(message: string, hint?: string) {\n super(hint ? `${message}\\n Hint: ${hint}` : message);\n this.name = \"RunnerError\";\n }\n}\n\nexport interface RunnerContext {\n projectRoot: string;\n verb: string;\n env: Record<string, string | undefined>;\n}\n\nexport type RunnerVerb = (\n host: HostDefinition,\n ctx: RunnerContext,\n) => Promise<unknown>;\n\n/** zod-shaped structurally, so this module needs no zod dependency. */\nexport interface HostSchemaLike {\n safeParse(host: unknown): {\n success: boolean;\n error?: { issues?: { path: (string | number)[]; message: string }[] };\n };\n}\n\nexport interface RunnerModule {\n run: RunnerVerb;\n hostSchema: HostSchemaLike;\n kind: string;\n [key: string]: unknown;\n}\n\n/** Exports that are part of the contract but are not verbs. */\nconst NON_VERB_EXPORTS = new Set([\"hostSchema\", \"kind\", \"default\"]);\n\nexport async function resolveRunnerModule(\n projectRoot: string,\n specifier: string,\n): Promise<RunnerModule> {\n const projectRequire = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n let resolved: string;\n try {\n resolved = projectRequire.resolve(specifier);\n } catch {\n throw new RunnerError(\n `Cannot resolve runner module \"${specifier}\" from ${projectRoot}.`,\n \"The runner must be a dependency of the project (install it, then retry).\",\n );\n }\n\n const module = (await import(pathToFileURL(resolved).href)) as Record<\n string,\n unknown\n >;\n\n if (typeof module.run !== \"function\") {\n throw new RunnerError(\n `Runner \"${specifier}\" does not export a \\`run\\` function (required verb).`,\n );\n }\n const hostSchema = module.hostSchema as HostSchemaLike | undefined;\n if (!hostSchema || typeof hostSchema.safeParse !== \"function\") {\n throw new RunnerError(\n `Runner \"${specifier}\" does not export a \\`hostSchema\\` — runners validate their own host shape.`,\n );\n }\n if (typeof module.kind !== \"string\") {\n throw new RunnerError(\n `Runner \"${specifier}\" does not export \\`kind\\` (e.g. \"reactor\" | \"compound\").`,\n );\n }\n return module as unknown as RunnerModule;\n}\n\nexport function listVerbs(runner: RunnerModule): string[] {\n return Object.entries(runner)\n .filter(\n ([name, value]) =>\n typeof value === \"function\" && !NON_VERB_EXPORTS.has(name),\n )\n .map(([name]) => name)\n .sort();\n}\n\nexport function getVerb(\n runner: RunnerModule,\n specifier: string,\n verb: string,\n): RunnerVerb {\n const candidate = runner[verb];\n if (typeof candidate !== \"function\" || NON_VERB_EXPORTS.has(verb)) {\n throw new RunnerError(\n `Runner \"${specifier}\" does not support the verb \"${verb}\". Supported verbs: ${listVerbs(\n runner,\n ).join(\", \")}.`,\n );\n }\n return candidate as RunnerVerb;\n}\n\nexport function validateHost(\n runner: RunnerModule,\n specifier: string,\n host: HostDefinition,\n file: string,\n): void {\n const result = runner.hostSchema.safeParse(host);\n if (!result.success) {\n const issues = (result.error?.issues ?? [])\n .map(\n (issue) => ` - ${issue.path.join(\".\") || \"<root>\"}: ${issue.message}`,\n )\n .join(\"\\n\");\n throw new RunnerError(\n `${file} failed validation against the hostSchema of \"${specifier}\":\\n${issues || \" (no details reported)\"}`,\n );\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * A running host's `.ph/run/<host>.json` record: what is live for this\n * project, keyed by host name so N hosts (vetra, desktop, …) coexist. This is\n * the generic form of ph-cli's vetra-runtime record; the compound writes one\n * per supervised host and (for compatibility) keeps the legacy\n * vetra-runtime.json in step while agent tooling still reads it (D1.c).\n */\nexport interface RunRecordMember {\n port?: number;\n url?: string;\n}\n\nexport interface RunRecord {\n pid: number;\n hostName: string;\n projectName: string;\n startedAt: string;\n members: Record<string, RunRecordMember>;\n /** Host-specific extras (e.g. mcpUrl) a runner wants in the record. */\n extra?: Record<string, unknown>;\n}\n\nexport type RunProbe =\n | { status: \"none\" }\n | { status: \"stale\"; record: RunRecord }\n | { status: \"live\"; record: RunRecord }\n | { status: \"foreign\"; record: RunRecord };\n\nconst runDir = (projectDir: string) => path.join(projectDir, \".ph\", \"run\");\nconst recordPath = (projectDir: string, hostName: string) =>\n path.join(runDir(projectDir), `${hostName}.json`);\n\nexport function readRunRecord(\n projectDir: string,\n hostName: string,\n): RunRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(recordPath(projectDir, hostName), \"utf8\"),\n ) as RunRecord;\n } catch {\n return undefined;\n }\n}\n\nexport function writeRunRecord(projectDir: string, record: RunRecord): void {\n const target = recordPath(projectDir, record.hostName);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\nexport function clearRunRecord(projectDir: string, hostName: string): void {\n try {\n fs.rmSync(recordPath(projectDir, hostName));\n } catch {\n // already gone\n }\n}\n\nexport function isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM = the process exists but belongs to another user.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\n/**\n * Decide whether the recorded instance is this project's live host.\n *\n * pid liveness alone proves nothing (pids are reused), and the recorded\n * projectName is what separates \"my instance\" from \"a different project that\n * happens to hold this storage root\" — the confusion the vetra lock exists to\n * prevent. A stale record (dead pid) is reported so the caller can clear it; a\n * foreign one (live pid, different project) is left alone.\n */\nexport function probeRun(\n projectDir: string,\n hostName: string,\n projectName: string,\n): RunProbe {\n const record = readRunRecord(projectDir, hostName);\n if (!record) return { status: \"none\" };\n if (!isPidAlive(record.pid)) return { status: \"stale\", record };\n if (record.projectName !== projectName) return { status: \"foreign\", record };\n return { status: \"live\", record };\n}\n","import path from \"node:path\";\n\n/**\n * `${userData}` resolution for host files (desktop shape): storage paths in a\n * host must not derive from the instance name (renames must stay safe), so\n * the host file writes `${userData}/pglite` and the RUNNER resolves it at\n * start. In the CLI the default userData is `<projectRoot>/.ph/user-data`;\n * a shell (Tauri) overrides it via PH_USER_DATA_DIR to the OS profile dir.\n */\nexport function defaultUserDataDir(\n projectRoot: string,\n env: Record<string, string | undefined> = process.env,\n): string {\n return env.PH_USER_DATA_DIR ?? path.join(projectRoot, \".ph\", \"user-data\");\n}\n\nconst PLACEHOLDER = /\\$\\{userData\\}/g;\n\n/** Deep-substitute `${userData}` in every string of a JSON-shaped value.\n * Non-strings pass through; the input is never mutated. */\nexport function resolveUserDataPlaceholders<T>(value: T, userData: string): T {\n if (typeof value === \"string\") {\n return value.replace(PLACEHOLDER, userData) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((v) =>\n resolveUserDataPlaceholders<unknown>(v, userData),\n ) as T;\n }\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n out[k] = resolveUserDataPlaceholders(v, userData);\n }\n return out as T;\n }\n return value;\n}\n","import type { HostDefinition } from \"./host-loader.js\";\nimport { loadHost } from \"./host-loader.js\";\nimport { projectDrivesIntoConnect } from \"./connect-projection.js\";\nimport {\n defaultUserDataDir,\n resolveUserDataPlaceholders,\n} from \"./placeholders.js\";\nimport {\n clearRunRecord,\n probeRun,\n writeRunRecord,\n type RunRecordMember,\n} from \"./run-record.js\";\nimport {\n getVerb,\n resolveRunnerModule,\n validateHost,\n type RunnerContext,\n} from \"./runner-resolver.js\";\n\n/**\n * The generic compound runner: supervises the members a compound host\n * declares, each started via its OWN declared runner at the compound's member\n * verb. It projects a reactor member's created drives into a connect member's\n * config, writes a .ph/run/<host>.json record, holds a per-project lock, and\n * tears members down in reverse order on shutdown.\n *\n * Phase-1 model is ATTACHED and in-process: member runner verbs start their\n * servers (which hold the event loop) and return a handle of facts; the\n * compound stays alive as long as they do. Detached supervision is phase 5.\n */\n\n/** Facts a member runner verb returns so the compound can project and tear\n * down. All optional: a void-returning verb is treated as \"started, no facts,\n * self-sustaining\" (the phase-0 bridges). */\nexport interface RunnerHandle {\n /** Port the member bound. */\n port?: number;\n /** Drive URLs a reactor member created, in display order — projected into a\n * connect member's defaultDrives. */\n driveUrls?: (string | null | undefined)[];\n /** Named endpoints (graphql, mcp, …) for the run record / diagnostics. */\n endpoints?: Record<string, string>;\n /** Resolves when the member is serving; the compound awaits it before the\n * next member when ordering requires readiness. */\n ready?: Promise<void>;\n /** Reverse-order teardown. */\n shutdown?: () => void | Promise<void>;\n}\n\nexport interface CompoundMember {\n host: string;\n plugins?: string[];\n runner?: { port?: number } & Record<string, unknown>;\n config?: Record<string, unknown>;\n reactor?: Record<string, unknown>;\n}\n\nexport interface CompoundWiring {\n /** Project the reactor member's created drives into the connect member. */\n projectDrivesIntoConnect?: boolean;\n /** --drives-public-base equivalent. */\n drivesPublicBase?: string | null;\n /** Member start order; defaults to declaration order. */\n startOrder?: string[];\n /** Write .ph/run/<host>.json (default true). */\n runtimeRecord?: boolean;\n /** Patch the baked CSP for the runtime registry on a served connect member\n * (forwarded to the connect runner as a runner option). */\n cspRegistrySync?: boolean;\n}\n\ninterface StartedMember {\n name: string;\n handle: RunnerHandle;\n}\n\nfunction memberEntries(host: HostDefinition): [string, CompoundMember][] {\n const children = (host.children ?? {}) as Record<string, CompoundMember>;\n return Object.entries(children);\n}\n\nfunction orderedMembers(\n host: HostDefinition,\n wiring: CompoundWiring,\n): [string, CompoundMember][] {\n const entries = memberEntries(host);\n if (!wiring.startOrder) return entries;\n const byName = new Map(entries);\n const out: [string, CompoundMember][] = [];\n for (const name of wiring.startOrder) {\n const m = byName.get(name);\n if (m) {\n out.push([name, m]);\n byName.delete(name);\n }\n }\n // any not named in startOrder keep declaration order, after the named ones\n for (const [name, m] of entries) if (byName.has(name)) out.push([name, m]);\n return out;\n}\n\n/** Build the member host object the member runner sees: the member's own\n * host.js, with the wrapper's runner/config/reactor overrides applied\n * (wrapper wins), and any compound-computed config patch merged in. */\nasync function resolveMemberHost(\n projectRoot: string,\n member: CompoundMember,\n userData: string,\n configPatch?: Record<string, unknown>,\n): Promise<HostDefinition> {\n const loaded = await loadHost(projectRoot, member.host);\n const base = loaded.host;\n const merged: HostDefinition = {\n ...base,\n runner: { ...base.runner, ...(member.runner ?? {}) },\n config: {\n ...(base.config ?? {}),\n ...(member.config ?? {}),\n ...(configPatch ?? {}),\n },\n reactor: { ...(base.reactor ?? {}), ...(member.reactor ?? {}) } as\n | Record<string, unknown>\n | undefined,\n };\n // ${userData} in the merged host (storage dirs etc.) resolves here — at the\n // runner, never derived from the instance name, so renames stay safe.\n return resolveUserDataPlaceholders(merged, userData);\n}\n\nfunction isConnectMember(member: CompoundMember): boolean {\n return member.host === \"connect\";\n}\nfunction isReactorFactMember(member: CompoundMember): boolean {\n return member.host === \"switchboard\";\n}\n\nexport interface RunCompoundOptions {\n /** Project identity for the lock (defaults read from package.json by the CLI). */\n projectName: string;\n /** Extra record fields (e.g. mcpUrl). */\n recordExtra?: Record<string, unknown>;\n /** Registers signal handlers for teardown (default true; tests pass false). */\n installSignalHandlers?: boolean;\n}\n\nexport interface RunCompoundResult {\n started: StartedMember[];\n shutdown: () => Promise<void>;\n}\n\nexport async function runCompound(\n host: HostDefinition,\n ctx: RunnerContext,\n options: RunCompoundOptions,\n): Promise<RunCompoundResult> {\n const projectRoot = ctx.projectRoot;\n const wiring = (host.config ?? {}) as CompoundWiring;\n // The member verb is ctx.verb, resolved by the CALLING runner module (its\n // `run` maps to defaultVerb; its dev/build/serve forward themselves) — the\n // engine never consults defaultVerb, so an explicit verb always wins.\n const verb = ctx.verb;\n\n // Lock: one live instance per project per host (storage-root contention).\n const probe = probeRun(projectRoot, host.name, options.projectName);\n if (probe.status === \"live\") {\n throw new Error(\n `${host.name} is already running for this project (pid ${probe.record.pid}). ` +\n `Stop it before starting another.`,\n );\n }\n if (probe.status === \"foreign\") {\n throw new Error(\n `.ph/run/${host.name}.json describes a live \"${probe.record.projectName}\", ` +\n `but this project is \"${options.projectName}\". Refusing to start a second instance.`,\n );\n }\n // stale record: proceed (a dead pid does not hold the lock)\n\n const userData = defaultUserDataDir(projectRoot, ctx.env);\n const started: StartedMember[] = [];\n const reactorFacts: { driveUrls: (string | null | undefined)[] } = {\n driveUrls: [],\n };\n\n const shutdown = async () => {\n for (const m of [...started].reverse()) {\n try {\n await m.handle.shutdown?.();\n } catch {\n // best effort — keep tearing down the rest\n }\n }\n if (wiring.runtimeRecord !== false) {\n clearRunRecord(projectRoot, host.name);\n }\n };\n\n for (const [name, member] of orderedMembers(host, wiring)) {\n // Compute a config patch for the connect member from reactor facts.\n let configPatch: Record<string, unknown> | undefined;\n if (\n isConnectMember(member) &&\n wiring.projectDrivesIntoConnect &&\n reactorFacts.driveUrls.length > 0\n ) {\n const configuredDefaultDrives = (\n (member.config as { drives?: { defaultDrives?: unknown } } | undefined)\n ?.drives as { defaultDrives?: unknown } | undefined\n )?.defaultDrives as never;\n configPatch = projectDrivesIntoConnect({\n createdDriveUrls: reactorFacts.driveUrls,\n configuredDefaultDrives,\n publicBase: wiring.drivesPublicBase,\n });\n }\n\n const memberHost = await resolveMemberHost(\n projectRoot,\n member,\n userData,\n configPatch,\n );\n if (isConnectMember(member) && wiring.cspRegistrySync) {\n memberHost.runner = { ...memberHost.runner, cspRegistrySync: true };\n }\n const specifier = memberHost.runner.module;\n const runner = await resolveRunnerModule(projectRoot, specifier);\n validateHost(runner, specifier, memberHost, `hosts/${member.host}/host.js`);\n // At compound verb \"run\", each member runs its own (merged) defaultVerb —\n // \"each member's default mode\" — which is what lets a desktop compound\n // pair a switchboard at `run` with a connect at `serve`. An explicit\n // forwarded verb (dev/build/serve) stays uniform across members.\n const memberVerb =\n verb === \"run\"\n ? ((memberHost.runner.defaultVerb as string | undefined) ?? \"run\")\n : verb;\n const fn = getVerb(runner, specifier, memberVerb);\n const handle = ((await fn(memberHost, ctx)) ?? {}) as RunnerHandle;\n if (handle.ready) await handle.ready;\n started.push({ name, handle });\n\n if (isReactorFactMember(member) && handle.driveUrls) {\n reactorFacts.driveUrls.push(...handle.driveUrls);\n }\n }\n\n if (wiring.runtimeRecord !== false) {\n const members: Record<string, RunRecordMember> = {};\n for (const m of started) {\n members[m.name] = {\n port: m.handle.port,\n url: m.handle.endpoints?.graphql ?? m.handle.endpoints?.connect,\n };\n }\n writeRunRecord(projectRoot, {\n pid: process.pid,\n hostName: host.name,\n projectName: options.projectName,\n startedAt: new Date().toISOString(),\n members,\n extra: options.recordExtra,\n });\n }\n\n if (options.installSignalHandlers !== false) {\n const onSignal = (code: number) => {\n void shutdown().finally(() => process.exit(code));\n };\n process.on(\"exit\", () => {\n if (wiring.runtimeRecord !== false)\n clearRunRecord(projectRoot, host.name);\n });\n process.on(\"SIGINT\", () => onSignal(130));\n process.on(\"SIGTERM\", () => onSignal(143));\n }\n\n return { started, shutdown };\n}\n","import { z } from \"zod\";\n\n/**\n * The shared zod schemas for host.js blocks (D2.a). The `reactor` block\n * validates STRICTLY (D2.d — phase 0's tolerated-unknown-keys notice ends\n * here): a typo'd protocol key must fail, not silently not-apply, because\n * these are fleet-consensus settings. `config` stays loose — it is\n * runner-defined by design.\n */\n\nexport const profileSchema = z\n .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 .optional();\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 })\n .optional(),\n createSignaturePolicy: z.enum([\"legacy\", \"v2-required\"]).optional(),\n unsupportedStoredDocuments: z.enum([\"refuse\", \"read-only\"]).optional(),\n});\n\nexport const reactorBackendSchema = z.strictObject({\n kind: z.enum([\"in-process\", \"worker\", \"remote\"]).optional(),\n storage: z\n .strictObject({\n kind: z.enum([\"idb\", \"memory\", \"path\", \"postgres\"]),\n dataDir: 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 dynamic: z.boolean().optional(),\n })\n .optional(),\n remote: z\n .strictObject({\n host: z.string().optional(),\n url: z.string().optional(),\n })\n .optional(),\n});\n\nexport const reactorSchema = z.strictObject({\n backends: z.record(z.string(), reactorBackendSchema).optional(),\n placement: z\n .strictObject({\n primary: z.string().optional(),\n default: z.looseObject({}).optional(),\n })\n .optional(),\n workflows: z.boolean().optional(),\n protocol: reactorProtocolSchema.optional(),\n});\n\n/** Common runner options every host.runner carries; runner modules extend it\n * loosely with their own process options. */\nexport const runnerBaseSchema = z.looseObject({\n module: z.string().min(1),\n defaultVerb: z.string().optional(),\n port: z.number().int().positive().optional(),\n});\n\n/** A compound's children map (mutually exclusive with `reactor` — the XOR is\n * structural, enforced by the loader; schemas validate each side's shape). */\nexport const childrenSchema = z.record(\n z.string(),\n z.strictObject({\n host: z.string().min(1),\n plugins: z.array(z.string()).optional(),\n runner: z.looseObject({}).optional(),\n config: z.looseObject({}).optional(),\n reactor: reactorSchema.optional(),\n }),\n);\n\n/** Composed generic host shapes — the basis for the emitted editor schemas\n * (D2.a). Runner packages extend these with their own runner options; `config`\n * stays loose by design. */\nexport const reactorHostSchema = z.looseObject({\n name: z.string().min(1),\n runner: runnerBaseSchema,\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n reactor: reactorSchema.optional(),\n});\n\nexport const compoundHostSchema = z.looseObject({\n name: z.string().min(1),\n runner: runnerBaseSchema,\n children: childrenSchema,\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n});\n\nconst SCHEMA_BASE = \"https://powerhouse.inc/schemas\";\n\n/** The emitted-schema set, keyed by published filename. Pure — the\n * emit-schemas script writes these to disk and the drift test re-derives\n * them, per the runtime-config-schema pattern. */\nexport function emittedHostSchemas(): Record<string, unknown> {\n const emit = (name: string, schema: z.ZodType) => ({\n $id: `${SCHEMA_BASE}/${name}.schema.json`,\n ...z.toJSONSchema(schema, { io: \"input\" }),\n });\n return {\n \"host-reactor.schema.json\": emit(\"host-reactor\", reactorHostSchema),\n \"host-compound.schema.json\": emit(\"host-compound\", compoundHostSchema),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,aACP,OAC0D;CAC1D,OAAO,WAAW;AACpB;AAKA,MAAM,YAAY,UAChB,aAAa,KAAK,IAAI,SAAS,MAAM,OAAO,MAAM;;;;;;;;AASpD,SAAgB,mBACd,GAAG,QACsB;CACzB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,SAAS,OAAO;EACzB,MAAM,MAAM,SAAS,KAAK;EAC1B,IAAI,KAAK,IAAI,GAAG,GAAG;EACnB,KAAK,IAAI,GAAG;EACZ,IAAI,KAAK,KAAK;CAChB;CAEF,OAAO;AACT;;;;;;;;AASA,SAAgB,eAAe,UAAkB,YAA4B;CAC3E,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,QAAQ;CACxB,QAAQ;EACN,OAAO;CACT;CACA,IAAI,CAAC;EAAC;EAAa;EAAa;CAAO,CAAC,CAAC,SAAS,IAAI,QAAQ,GAC5D,OAAO;CAET,OAAO,GAAG,WAAW,QAAQ,QAAQ,EAAE,IAAI,IAAI;AACjD;;;;;;;AAkBA,SAAgB,yBACd,OACwC;CAQxC,OAAO,EACL,QAAQ;EACN,eAAe,mBATsB,MAAM,iBAC5C,QAAQ,QAAuB,OAAO,QAAQ,YAAY,IAAI,SAAS,CAAC,CAAC,CACzE,KAAK,SAAS;GACb,KAAK,MAAM,aAAa,eAAe,KAAK,MAAM,UAAU,IAAI;GAChE,MAAM;GACN,MAAM;EACR,EAIU,GACN,MAAM,2BAA2B,CAAC,CACpC;EACA,k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,CAAC,CAAC,CAAC,SAAS;CACtC,CAAC,CAAC,CACD,SAAS;CACZ,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,UAAU,sBAAsB,SAAS;AAC3C,CAAC;;;AAID,MAAa,mBAAmB,EAAE,YAAY;CAC5C,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACxB,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;CACjC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;AAC7C,CAAC;;;AAID,MAAa,iBAAiB,EAAE,OAC9B,EAAE,OAAO,GACT,EAAE,aAAa;CACb,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACtC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS,cAAc,SAAS;AAClC,CAAC,CACH;AAKiC,EAAE,YAAY;CAC7C,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,QAAQ;CACR,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS;CACT,SAAS,cAAc,SAAS;AAClC,CAAC;AAED,MAAa,qBAAqB,EAAE,YAAY;CAC9C,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,QAAQ;CACR,UAAU;CACV,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS;AACX,CAAC"}
1
+ {"version":3,"file":"host-schemas-C_MLcYX6.mjs","names":[],"sources":["../src/connect-projection.ts","../src/host-loader.ts","../src/runner-resolver.ts","../src/run-record.ts","../src/placeholders.ts","../src/compound.ts","../src/host-schemas.ts"],"sourcesContent":["import type {\n PHConnectDefaultDrive,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\n\n/**\n * Instance-fact projection for compound hosts: the drives a compound's\n * reactor member created, projected into the Connect member's runtime-config\n * override. Pure functions, moved from ph-cli's vetra service so the generic\n * compound and the classic path share one implementation.\n */\n\nfunction isLocalDrive(\n drive: PHConnectDefaultDrive,\n): drive is Extract<PHConnectDefaultDrive, { local: true }> {\n return \"local\" in drive;\n}\n\n// Identity key for de-duplication: remote entries are keyed by URL; local\n// entries are keyed by `local:<id>` so a local drive id can never collide\n// with a remote URL that happens to be the same string.\nconst driveKey = (drive: PHConnectDefaultDrive): string =>\n isLocalDrive(drive) ? `local:${drive.id}` : drive.url;\n\n/**\n * Concatenate groups of `connect.drives.defaultDrives` in the order given,\n * de-duplicating by drive identity (URL for remote entries, id for local\n * ones). The first occurrence of a drive wins, so earlier groups keep their\n * position and metadata — e.g. the Vetra drive `ph vetra` starts stays first\n * even when the project's `powerhouse.config.json` lists the same drive.\n */\nexport function mergeDefaultDrives(\n ...groups: PHConnectDefaultDrive[][]\n): PHConnectDefaultDrive[] {\n const seen = new Set<string>();\n const out: PHConnectDefaultDrive[] = [];\n for (const group of groups) {\n for (const drive of group) {\n const key = driveKey(drive);\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(drive);\n }\n }\n return out;\n}\n\n/**\n * Rebase a local drive URL onto a public base: keeps the /d/<slug> path,\n * swaps the loopback origin for the public base. Browser clients behind a\n * reverse proxy can't reach http://localhost:<port>. Non-loopback URLs\n * (e.g. a remote drive) are already public and pass through unchanged, as do\n * unparseable ones.\n */\nexport function rebaseDriveUrl(driveUrl: string, publicBase: string): string {\n let url: URL;\n try {\n url = new URL(driveUrl);\n } catch {\n return driveUrl;\n }\n if (![\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname)) {\n return driveUrl;\n }\n return `${publicBase.replace(/\\/+$/, \"\")}${url.pathname}`;\n}\n\nexport interface DriveProjectionInput {\n /** Drive URLs the compound's reactor member created, in display order\n * (e.g. vetra, preview, workflows). Null/undefined entries are skipped. */\n createdDriveUrls: (string | null | undefined)[];\n /** The project's configured `connect.drives.defaultDrives`. */\n configuredDefaultDrives?: PHConnectDefaultDrive[];\n /** `--drives-public-base`: advertise proxy-reachable URLs to the browser. */\n publicBase?: string | null;\n}\n\n/**\n * The compound's drives projection: created drives first (rebased onto the\n * public base when given), then the project's configured drives, de-duplicated\n * — and `preserve-all`, because compound-injected drive lists change per\n * launch context and must never detach drives the user added by hand.\n */\nexport function projectDrivesIntoConnect(\n input: DriveProjectionInput,\n): Pick<PHConnectRuntimeConfig, \"drives\"> {\n const created: PHConnectDefaultDrive[] = input.createdDriveUrls\n .filter((url): url is string => typeof url === \"string\" && url.length > 0)\n .map((url) => ({\n url: input.publicBase ? rebaseDriveUrl(url, input.publicBase) : url,\n name: null,\n icon: null,\n }));\n return {\n drives: {\n defaultDrives: mergeDefaultDrives(\n created,\n input.configuredDefaultDrives ?? [],\n ),\n preserveStrategy: \"preserve-all\",\n },\n };\n}\n","import { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Loads and pre-validates a `hosts/<name>/host.js` definition.\n *\n * A host file is a static PROJECTION of powerhouse.config.json: plain ESM,\n * default-exporting a data object. Three gates run before any runner sees it:\n * 1. import lint — the only legal import is the project's\n * powerhouse.config.json (host files are data, not programs);\n * 2. static check — the exported object must survive a JSON round trip\n * (functions, undefined, class instances, Dates etc. are rejected,\n * reporting the offending path);\n * 3. shape pre-check — `name`, `runner.module`, and the reactor XOR children\n * rule. Full validation is the runner's `hostSchema` (phase 2).\n *\n * This module never exits the process — callers own error presentation.\n */\n\nconst HOST_FILE = \"host.js\";\nconst CONFIG_IMPORT_SUFFIX = \"powerhouse.config.json\";\n\nexport class HostLoadError extends Error {\n constructor(message: string, hint?: string) {\n super(hint ? `${message}\\n Hint: ${hint}` : message);\n this.name = \"HostLoadError\";\n }\n}\n\nexport type HostsFolderStatus =\n | { kind: \"absent\" }\n | { kind: \"empty\"; dir: string }\n | { kind: \"present\"; dir: string; hosts: string[] };\n\n/** A `hosts/` folder with no `<name>/host.js` inside is \"empty\" — the guard\n * state: callers warn loudly and fall back to legacy rather than activating\n * the new architecture off a stray `mkdir hosts`. */\nexport function probeHostsFolder(projectRoot: string): HostsFolderStatus {\n const dir = path.join(projectRoot, \"hosts\");\n if (!existsSync(dir) || !statSync(dir).isDirectory()) {\n return { kind: \"absent\" };\n }\n const hosts = readdirSync(dir, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() &&\n existsSync(path.join(dir, entry.name, HOST_FILE)),\n )\n .map((entry) => entry.name)\n .sort();\n return hosts.length === 0\n ? { kind: \"empty\", dir }\n : { kind: \"present\", dir, hosts };\n}\n\n/** Rejects every import except the project's powerhouse.config.json, plus any\n * dynamic `import(...)` or `require(...)`. Source-level enforcement: the JSON\n * round trip below is the hard gate; this one produces the better error. */\nexport function lintHostImports(source: string, file: string): void {\n for (const match of source.matchAll(\n /^\\s*import\\b[^;'\"]*?from\\s+[\"']([^\"']+)[\"']/gm,\n )) {\n const specifier = match[1];\n if (!specifier.endsWith(CONFIG_IMPORT_SUFFIX)) {\n throw new HostLoadError(\n `${file} imports \"${specifier}\" — a host file may only import the project's powerhouse.config.json.`,\n \"Host files are static projections; code belongs in plugins.js or the runner.\",\n );\n }\n }\n if (/^\\s*import\\s+[\"']/m.test(source)) {\n throw new HostLoadError(\n `${file} contains a side-effect import — a host file may only import the project's powerhouse.config.json.`,\n );\n }\n if (/\\bimport\\s*\\(/.test(source) || /\\brequire\\s*\\(/.test(source)) {\n throw new HostLoadError(\n `${file} uses dynamic import()/require() — host files are static data.`,\n );\n }\n}\n\n/** Returns the path of the first value that would not survive a JSON round\n * trip, or undefined when the object is fully static. */\nexport function findNonStaticValue(\n value: unknown,\n trail = \"\",\n): string | undefined {\n if (value === null) return undefined;\n const kind = typeof value;\n if (kind === \"string\" || kind === \"number\" || kind === \"boolean\") {\n return undefined;\n }\n if (kind !== \"object\") {\n return `${trail || \"<root>\"} (${kind})`;\n }\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const hit = findNonStaticValue(value[i], `${trail}[${i}]`);\n if (hit) return hit;\n }\n return undefined;\n }\n const proto: unknown = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null) {\n return `${trail || \"<root>\"} (non-plain object)`;\n }\n for (const [key, child] of Object.entries(value as Record<string, unknown>)) {\n const hit = findNonStaticValue(child, trail ? `${trail}.${key}` : key);\n if (hit) return hit;\n }\n return undefined;\n}\n\nexport interface HostDefinition {\n name: string;\n runner: { module: string } & Record<string, unknown>;\n config?: Record<string, unknown>;\n profile?: Record<string, unknown>;\n reactor?: Record<string, unknown>;\n children?: Record<string, unknown>;\n}\n\nexport interface LoadedHost {\n name: string;\n dir: string;\n file: string;\n host: HostDefinition;\n}\n\nfunction assertHostShape(\n host: Record<string, unknown>,\n file: string,\n): asserts host is HostDefinition & Record<string, unknown> {\n if (typeof host.name !== \"string\" || host.name.length === 0) {\n throw new HostLoadError(`${file}: \\`name\\` must be a non-empty string.`);\n }\n const runner = host.runner;\n if (\n runner === null ||\n typeof runner !== \"object\" ||\n typeof (runner as Record<string, unknown>).module !== \"string\"\n ) {\n throw new HostLoadError(\n `${file}: \\`runner\\` must be an object with a \\`module\\` specifier string.`,\n );\n }\n if (host.reactor !== undefined && host.children !== undefined) {\n throw new HostLoadError(\n `${file}: \\`reactor\\` and \\`children\\` are mutually exclusive — a host is a reactor runner or a compound runner, never both.`,\n );\n }\n}\n\nexport async function loadHost(\n projectRoot: string,\n hostName: string,\n): Promise<LoadedHost> {\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"absent\") {\n throw new HostLoadError(\n `No hosts/ folder found in ${projectRoot}.`,\n \"Scaffold one with `ph init --uniform-runners` (or create hosts/<name>/host.js).\",\n );\n }\n if (probe.kind === \"empty\") {\n throw new HostLoadError(\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js.`,\n \"An empty hosts/ folder does not activate the uniform-runners architecture; add a host definition or remove the folder.\",\n );\n }\n if (!probe.hosts.includes(hostName)) {\n throw new HostLoadError(\n `Unknown host \"${hostName}\". Available hosts: ${probe.hosts.join(\", \")}.`,\n );\n }\n\n const file = path.join(probe.dir, hostName, HOST_FILE);\n lintHostImports(readFileSync(file, \"utf8\"), file);\n\n const module = (await import(pathToFileURL(file).href)) as {\n default?: unknown;\n };\n const host = module.default;\n if (host === null || typeof host !== \"object\" || Array.isArray(host)) {\n throw new HostLoadError(\n `${file} must default-export the host object (\\`export default { name, runner, ... }\\`).`,\n );\n }\n\n const nonStatic = findNonStaticValue(host);\n if (nonStatic) {\n throw new HostLoadError(\n `${file} exports a non-static value at \\`${nonStatic}\\` — host files must survive a JSON round trip.`,\n \"Runtime behavior belongs in the runner; host files only carry data.\",\n );\n }\n\n assertHostShape(host as Record<string, unknown>, file);\n return {\n name: hostName,\n dir: path.dirname(file),\n file,\n host: host as HostDefinition,\n };\n}\n","import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { HostDefinition } from \"./host-loader.js\";\n\n/**\n * Resolves a host's `runner.module` specifier from the PROJECT's dependency\n * tree (not ph-cli's), imports it, and checks the runner-module contract:\n * `{ run, hostSchema, kind, ...optionalVerbs }`. Phase-0 home is ph-cli; the\n * uniform-runners plan moves this into @powerhousedao/host-core with the\n * generic compound (phase 1).\n */\n\nexport class RunnerError extends Error {\n constructor(message: string, hint?: string) {\n super(hint ? `${message}\\n Hint: ${hint}` : message);\n this.name = \"RunnerError\";\n }\n}\n\nexport interface RunnerContext {\n projectRoot: string;\n verb: string;\n env: Record<string, string | undefined>;\n}\n\nexport type RunnerVerb = (\n host: HostDefinition,\n ctx: RunnerContext,\n) => Promise<unknown>;\n\n/** zod-shaped structurally, so this module needs no zod dependency. */\nexport interface HostSchemaLike {\n safeParse(host: unknown): {\n success: boolean;\n error?: { issues?: { path: (string | number)[]; message: string }[] };\n };\n}\n\nexport interface RunnerModule {\n run: RunnerVerb;\n hostSchema: HostSchemaLike;\n kind: string;\n [key: string]: unknown;\n}\n\n/** Exports that are part of the contract but are not verbs. */\nconst NON_VERB_EXPORTS = new Set([\"hostSchema\", \"kind\", \"default\"]);\n\nexport async function resolveRunnerModule(\n projectRoot: string,\n specifier: string,\n): Promise<RunnerModule> {\n const projectRequire = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n let resolved: string;\n try {\n resolved = projectRequire.resolve(specifier);\n } catch {\n throw new RunnerError(\n `Cannot resolve runner module \"${specifier}\" from ${projectRoot}.`,\n \"The runner must be a dependency of the project (install it, then retry).\",\n );\n }\n\n const module = (await import(pathToFileURL(resolved).href)) as Record<\n string,\n unknown\n >;\n\n if (typeof module.run !== \"function\") {\n throw new RunnerError(\n `Runner \"${specifier}\" does not export a \\`run\\` function (required verb).`,\n );\n }\n const hostSchema = module.hostSchema as HostSchemaLike | undefined;\n if (!hostSchema || typeof hostSchema.safeParse !== \"function\") {\n throw new RunnerError(\n `Runner \"${specifier}\" does not export a \\`hostSchema\\` — runners validate their own host shape.`,\n );\n }\n if (typeof module.kind !== \"string\") {\n throw new RunnerError(\n `Runner \"${specifier}\" does not export \\`kind\\` (e.g. \"reactor\" | \"compound\").`,\n );\n }\n return module as unknown as RunnerModule;\n}\n\nexport function listVerbs(runner: RunnerModule): string[] {\n return Object.entries(runner)\n .filter(\n ([name, value]) =>\n typeof value === \"function\" && !NON_VERB_EXPORTS.has(name),\n )\n .map(([name]) => name)\n .sort();\n}\n\nexport function getVerb(\n runner: RunnerModule,\n specifier: string,\n verb: string,\n): RunnerVerb {\n const candidate = runner[verb];\n if (typeof candidate !== \"function\" || NON_VERB_EXPORTS.has(verb)) {\n throw new RunnerError(\n `Runner \"${specifier}\" does not support the verb \"${verb}\". Supported verbs: ${listVerbs(\n runner,\n ).join(\", \")}.`,\n );\n }\n return candidate as RunnerVerb;\n}\n\nexport function validateHost(\n runner: RunnerModule,\n specifier: string,\n host: HostDefinition,\n file: string,\n): void {\n const result = runner.hostSchema.safeParse(host);\n if (!result.success) {\n const issues = (result.error?.issues ?? [])\n .map(\n (issue) => ` - ${issue.path.join(\".\") || \"<root>\"}: ${issue.message}`,\n )\n .join(\"\\n\");\n throw new RunnerError(\n `${file} failed validation against the hostSchema of \"${specifier}\":\\n${issues || \" (no details reported)\"}`,\n );\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * A running host's `.ph/run/<host>.json` record: what is live for this\n * project, keyed by host name so N hosts (vetra, desktop, …) coexist. This is\n * the generic form of ph-cli's vetra-runtime record; the compound writes one\n * per supervised host and (for compatibility) keeps the legacy\n * vetra-runtime.json in step while agent tooling still reads it (D1.c).\n */\nexport interface RunRecordMember {\n port?: number;\n url?: string;\n}\n\nexport interface RunRecord {\n pid: number;\n hostName: string;\n projectName: string;\n startedAt: string;\n members: Record<string, RunRecordMember>;\n /** Host-specific extras (e.g. mcpUrl) a runner wants in the record. */\n extra?: Record<string, unknown>;\n}\n\nexport type RunProbe =\n | { status: \"none\" }\n | { status: \"stale\"; record: RunRecord }\n | { status: \"live\"; record: RunRecord }\n | { status: \"foreign\"; record: RunRecord };\n\nconst runDir = (projectDir: string) => path.join(projectDir, \".ph\", \"run\");\nconst recordPath = (projectDir: string, hostName: string) =>\n path.join(runDir(projectDir), `${hostName}.json`);\n\nexport function readRunRecord(\n projectDir: string,\n hostName: string,\n): RunRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(recordPath(projectDir, hostName), \"utf8\"),\n ) as RunRecord;\n } catch {\n return undefined;\n }\n}\n\nexport function writeRunRecord(projectDir: string, record: RunRecord): void {\n const target = recordPath(projectDir, record.hostName);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\nexport function clearRunRecord(projectDir: string, hostName: string): void {\n try {\n fs.rmSync(recordPath(projectDir, hostName));\n } catch {\n // already gone\n }\n}\n\nexport function isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM = the process exists but belongs to another user.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\n/**\n * Decide whether the recorded instance is this project's live host.\n *\n * pid liveness alone proves nothing (pids are reused), and the recorded\n * projectName is what separates \"my instance\" from \"a different project that\n * happens to hold this storage root\" — the confusion the vetra lock exists to\n * prevent. A stale record (dead pid) is reported so the caller can clear it; a\n * foreign one (live pid, different project) is left alone.\n */\nexport function probeRun(\n projectDir: string,\n hostName: string,\n projectName: string,\n): RunProbe {\n const record = readRunRecord(projectDir, hostName);\n if (!record) return { status: \"none\" };\n if (!isPidAlive(record.pid)) return { status: \"stale\", record };\n if (record.projectName !== projectName) return { status: \"foreign\", record };\n return { status: \"live\", record };\n}\n","import path from \"node:path\";\n\n/**\n * `${userData}` resolution for host files (desktop shape): storage paths in a\n * host must not derive from the instance name (renames must stay safe), so\n * the host file writes `${userData}/pglite` and the RUNNER resolves it at\n * start. In the CLI the default userData is `<projectRoot>/.ph/user-data`;\n * a shell (Tauri) overrides it via PH_USER_DATA_DIR to the OS profile dir.\n */\nexport function defaultUserDataDir(\n projectRoot: string,\n env: Record<string, string | undefined> = process.env,\n): string {\n return env.PH_USER_DATA_DIR ?? path.join(projectRoot, \".ph\", \"user-data\");\n}\n\nconst PLACEHOLDER = /\\$\\{userData\\}/g;\n\n/** Deep-substitute `${userData}` in every string of a JSON-shaped value.\n * Non-strings pass through; the input is never mutated. */\nexport function resolveUserDataPlaceholders<T>(value: T, userData: string): T {\n if (typeof value === \"string\") {\n return value.replace(PLACEHOLDER, userData) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((v) =>\n resolveUserDataPlaceholders<unknown>(v, userData),\n ) as T;\n }\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n out[k] = resolveUserDataPlaceholders(v, userData);\n }\n return out as T;\n }\n return value;\n}\n","import type { HostDefinition } from \"./host-loader.js\";\nimport { loadHost } from \"./host-loader.js\";\nimport { projectDrivesIntoConnect } from \"./connect-projection.js\";\nimport {\n defaultUserDataDir,\n resolveUserDataPlaceholders,\n} from \"./placeholders.js\";\nimport {\n clearRunRecord,\n probeRun,\n writeRunRecord,\n type RunRecordMember,\n} from \"./run-record.js\";\nimport {\n getVerb,\n resolveRunnerModule,\n validateHost,\n type RunnerContext,\n} from \"./runner-resolver.js\";\n\n/**\n * The generic compound runner: supervises the members a compound host\n * declares, each started via its OWN declared runner at the compound's member\n * verb. It projects a reactor member's created drives into a connect member's\n * config, writes a .ph/run/<host>.json record, holds a per-project lock, and\n * tears members down in reverse order on shutdown.\n *\n * Phase-1 model is ATTACHED and in-process: member runner verbs start their\n * servers (which hold the event loop) and return a handle of facts; the\n * compound stays alive as long as they do. Detached supervision is phase 5.\n */\n\n/** Facts a member runner verb returns so the compound can project and tear\n * down. All optional: a void-returning verb is treated as \"started, no facts,\n * self-sustaining\" (the phase-0 bridges). */\nexport interface RunnerHandle {\n /** Port the member bound. */\n port?: number;\n /** Drive URLs a reactor member created, in display order — projected into a\n * connect member's defaultDrives. */\n driveUrls?: (string | null | undefined)[];\n /** Named endpoints (graphql, mcp, …) for the run record / diagnostics. */\n endpoints?: Record<string, string>;\n /** Resolves when the member is serving; the compound awaits it before the\n * next member when ordering requires readiness. */\n ready?: Promise<void>;\n /** Reverse-order teardown. */\n shutdown?: () => void | Promise<void>;\n}\n\nexport interface CompoundMember {\n host: string;\n plugins?: string[];\n runner?: { port?: number } & Record<string, unknown>;\n config?: Record<string, unknown>;\n reactor?: Record<string, unknown>;\n}\n\nexport interface CompoundWiring {\n /** Project the reactor member's created drives into the connect member. */\n projectDrivesIntoConnect?: boolean;\n /** --drives-public-base equivalent. */\n drivesPublicBase?: string | null;\n /** Member start order; defaults to declaration order. */\n startOrder?: string[];\n /** Write .ph/run/<host>.json (default true). */\n runtimeRecord?: boolean;\n /** Patch the baked CSP for the runtime registry on a served connect member\n * (forwarded to the connect runner as a runner option). */\n cspRegistrySync?: boolean;\n}\n\ninterface StartedMember {\n name: string;\n handle: RunnerHandle;\n}\n\nfunction memberEntries(host: HostDefinition): [string, CompoundMember][] {\n const children = (host.children ?? {}) as Record<string, CompoundMember>;\n return Object.entries(children);\n}\n\nfunction orderedMembers(\n host: HostDefinition,\n wiring: CompoundWiring,\n): [string, CompoundMember][] {\n const entries = memberEntries(host);\n if (!wiring.startOrder) return entries;\n const byName = new Map(entries);\n const out: [string, CompoundMember][] = [];\n for (const name of wiring.startOrder) {\n const m = byName.get(name);\n if (m) {\n out.push([name, m]);\n byName.delete(name);\n }\n }\n // any not named in startOrder keep declaration order, after the named ones\n for (const [name, m] of entries) if (byName.has(name)) out.push([name, m]);\n return out;\n}\n\n/** Build the member host object the member runner sees: the member's own\n * host.js, with the wrapper's runner/config/reactor overrides applied\n * (wrapper wins), and any compound-computed config patch merged in. */\nasync function resolveMemberHost(\n projectRoot: string,\n member: CompoundMember,\n userData: string,\n configPatch?: Record<string, unknown>,\n): Promise<HostDefinition> {\n const loaded = await loadHost(projectRoot, member.host);\n const base = loaded.host;\n const merged: HostDefinition = {\n ...base,\n runner: { ...base.runner, ...(member.runner ?? {}) },\n config: {\n ...(base.config ?? {}),\n ...(member.config ?? {}),\n ...(configPatch ?? {}),\n },\n reactor: { ...(base.reactor ?? {}), ...(member.reactor ?? {}) } as\n | Record<string, unknown>\n | undefined,\n };\n // ${userData} in the merged host (storage dirs etc.) resolves here — at the\n // runner, never derived from the instance name, so renames stay safe.\n return resolveUserDataPlaceholders(merged, userData);\n}\n\nfunction isConnectMember(member: CompoundMember): boolean {\n return member.host === \"connect\";\n}\nfunction isReactorFactMember(member: CompoundMember): boolean {\n return member.host === \"switchboard\";\n}\n\nexport interface RunCompoundOptions {\n /** Project identity for the lock (defaults read from package.json by the CLI). */\n projectName: string;\n /** Extra record fields (e.g. mcpUrl). */\n recordExtra?: Record<string, unknown>;\n /** Registers signal handlers for teardown (default true; tests pass false). */\n installSignalHandlers?: boolean;\n}\n\nexport interface RunCompoundResult {\n started: StartedMember[];\n shutdown: () => Promise<void>;\n}\n\nexport async function runCompound(\n host: HostDefinition,\n ctx: RunnerContext,\n options: RunCompoundOptions,\n): Promise<RunCompoundResult> {\n const projectRoot = ctx.projectRoot;\n const wiring = (host.config ?? {}) as CompoundWiring;\n // The member verb is ctx.verb, resolved by the CALLING runner module (its\n // `run` maps to defaultVerb; its dev/build/serve forward themselves) — the\n // engine never consults defaultVerb, so an explicit verb always wins.\n const verb = ctx.verb;\n\n // Lock: one live instance per project per host (storage-root contention).\n const probe = probeRun(projectRoot, host.name, options.projectName);\n if (probe.status === \"live\") {\n throw new Error(\n `${host.name} is already running for this project (pid ${probe.record.pid}). ` +\n `Stop it before starting another.`,\n );\n }\n if (probe.status === \"foreign\") {\n throw new Error(\n `.ph/run/${host.name}.json describes a live \"${probe.record.projectName}\", ` +\n `but this project is \"${options.projectName}\". Refusing to start a second instance.`,\n );\n }\n // stale record: proceed (a dead pid does not hold the lock)\n\n const userData = defaultUserDataDir(projectRoot, ctx.env);\n const started: StartedMember[] = [];\n const reactorFacts: { driveUrls: (string | null | undefined)[] } = {\n driveUrls: [],\n };\n\n const shutdown = async () => {\n for (const m of [...started].reverse()) {\n try {\n await m.handle.shutdown?.();\n } catch {\n // best effort — keep tearing down the rest\n }\n }\n if (wiring.runtimeRecord !== false) {\n clearRunRecord(projectRoot, host.name);\n }\n };\n\n for (const [name, member] of orderedMembers(host, wiring)) {\n // Compute a config patch for the connect member from reactor facts.\n let configPatch: Record<string, unknown> | undefined;\n if (\n isConnectMember(member) &&\n wiring.projectDrivesIntoConnect &&\n reactorFacts.driveUrls.length > 0\n ) {\n const configuredDefaultDrives = (\n (member.config as { drives?: { defaultDrives?: unknown } } | undefined)\n ?.drives as { defaultDrives?: unknown } | undefined\n )?.defaultDrives as never;\n configPatch = projectDrivesIntoConnect({\n createdDriveUrls: reactorFacts.driveUrls,\n configuredDefaultDrives,\n publicBase: wiring.drivesPublicBase,\n });\n }\n\n const memberHost = await resolveMemberHost(\n projectRoot,\n member,\n userData,\n configPatch,\n );\n if (isConnectMember(member) && wiring.cspRegistrySync) {\n memberHost.runner = { ...memberHost.runner, cspRegistrySync: true };\n }\n const specifier = memberHost.runner.module;\n const runner = await resolveRunnerModule(projectRoot, specifier);\n validateHost(runner, specifier, memberHost, `hosts/${member.host}/host.js`);\n // At compound verb \"run\", each member runs its own (merged) defaultVerb —\n // \"each member's default mode\" — which is what lets a desktop compound\n // pair a switchboard at `run` with a connect at `serve`. An explicit\n // forwarded verb (dev/build/serve) stays uniform across members.\n const memberVerb =\n verb === \"run\"\n ? ((memberHost.runner.defaultVerb as string | undefined) ?? \"run\")\n : verb;\n const fn = getVerb(runner, specifier, memberVerb);\n const handle = ((await fn(memberHost, ctx)) ?? {}) as RunnerHandle;\n if (handle.ready) await handle.ready;\n started.push({ name, handle });\n\n if (isReactorFactMember(member) && handle.driveUrls) {\n reactorFacts.driveUrls.push(...handle.driveUrls);\n }\n }\n\n if (wiring.runtimeRecord !== false) {\n const members: Record<string, RunRecordMember> = {};\n for (const m of started) {\n members[m.name] = {\n port: m.handle.port,\n url: m.handle.endpoints?.graphql ?? m.handle.endpoints?.connect,\n };\n }\n writeRunRecord(projectRoot, {\n pid: process.pid,\n hostName: host.name,\n projectName: options.projectName,\n startedAt: new Date().toISOString(),\n members,\n extra: options.recordExtra,\n });\n }\n\n if (options.installSignalHandlers !== false) {\n const onSignal = (code: number) => {\n void shutdown().finally(() => process.exit(code));\n };\n process.on(\"exit\", () => {\n if (wiring.runtimeRecord !== false)\n clearRunRecord(projectRoot, host.name);\n });\n process.on(\"SIGINT\", () => onSignal(130));\n process.on(\"SIGTERM\", () => onSignal(143));\n }\n\n return { started, shutdown };\n}\n","import { z } from \"zod\";\n\n/**\n * The shared zod schemas for host.js blocks (D2.a). The `reactor` block\n * validates STRICTLY (D2.d — phase 0's tolerated-unknown-keys notice ends\n * here): a typo'd protocol key must fail, not silently not-apply, because\n * these are fleet-consensus settings. `config` stays loose — it is\n * runner-defined by design.\n */\n\nexport const profileSchema = z\n .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 .optional();\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 })\n .optional(),\n createSignaturePolicy: z.enum([\"legacy\", \"v2-required\"]).optional(),\n unsupportedStoredDocuments: z.enum([\"refuse\", \"read-only\"]).optional(),\n});\n\nexport const reactorBackendSchema = z.strictObject({\n kind: z.enum([\"in-process\", \"worker\", \"remote\"]).optional(),\n storage: z\n .strictObject({\n kind: z.enum([\"idb\", \"memory\", \"path\", \"postgres\"]),\n dataDir: 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 dynamic: z.boolean().optional(),\n })\n .optional(),\n remote: z\n .strictObject({\n host: z.string().optional(),\n url: z.string().optional(),\n })\n .optional(),\n});\n\nexport const reactorSchema = z.strictObject({\n backends: z.record(z.string(), reactorBackendSchema).optional(),\n placement: z\n .strictObject({\n primary: z.string().optional(),\n default: z.looseObject({}).optional(),\n })\n .optional(),\n workflows: z.boolean().optional(),\n protocol: reactorProtocolSchema.optional(),\n});\n\n/** Common runner options every host.runner carries; runner modules extend it\n * loosely with their own process options. */\nexport const runnerBaseSchema = z.looseObject({\n module: z.string().min(1),\n defaultVerb: z.string().optional(),\n port: z.number().int().positive().optional(),\n});\n\n/** A compound's children map (mutually exclusive with `reactor` — the XOR is\n * structural, enforced by the loader; schemas validate each side's shape). */\nexport const childrenSchema = z.record(\n z.string(),\n z.strictObject({\n host: z.string().min(1),\n plugins: z.array(z.string()).optional(),\n runner: z.looseObject({}).optional(),\n config: z.looseObject({}).optional(),\n reactor: reactorSchema.optional(),\n }),\n);\n\n/** Composed generic host shapes — the basis for the emitted editor schemas\n * (D2.a). Runner packages extend these with their own runner options; `config`\n * stays loose by design. */\nexport const reactorHostSchema = z.looseObject({\n name: z.string().min(1),\n runner: runnerBaseSchema,\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n reactor: reactorSchema.optional(),\n});\n\nexport const compoundHostSchema = z.looseObject({\n name: z.string().min(1),\n runner: runnerBaseSchema,\n children: childrenSchema,\n config: z.looseObject({}).optional(),\n profile: profileSchema,\n});\n\nconst SCHEMA_BASE = \"https://powerhouse.inc/schemas\";\n\n/** The emitted-schema set, keyed by published filename. Pure — the\n * emit-schemas script writes these to disk and the drift test re-derives\n * them, per the runtime-config-schema pattern. */\nexport function emittedHostSchemas(): Record<string, unknown> {\n const emit = (name: string, schema: z.ZodType) => ({\n $id: `${SCHEMA_BASE}/${name}.schema.json`,\n ...z.toJSONSchema(schema, { io: \"input\" }),\n });\n return {\n \"host-reactor.schema.json\": emit(\"host-reactor\", reactorHostSchema),\n \"host-compound.schema.json\": emit(\"host-compound\", compoundHostSchema),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,aACP,OAC0D;CAC1D,OAAO,WAAW;AACpB;AAKA,MAAM,YAAY,UAChB,aAAa,KAAK,IAAI,SAAS,MAAM,OAAO,MAAM;;;;;;;;AASpD,SAAgB,mBACd,GAAG,QACsB;CACzB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,SAAS,OAAO;EACzB,MAAM,MAAM,SAAS,KAAK;EAC1B,IAAI,KAAK,IAAI,GAAG,GAAG;EACnB,KAAK,IAAI,GAAG;EACZ,IAAI,KAAK,KAAK;CAChB;CAEF,OAAO;AACT;;;;;;;;AASA,SAAg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MAAa,oBAAoB,EAAE,YAAY;CAC7C,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,QAAQ;CACR,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS;CACT,SAAS,cAAc,SAAS;AAClC,CAAC;AAED,MAAa,qBAAqB,EAAE,YAAY;CAC9C,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,QAAQ;CACR,UAAU;CACV,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;CACnC,SAAS;AACX,CAAC;AAED,MAAM,cAAc;;;;AAKpB,SAAgB,qBAA8C;CAC5D,MAAM,QAAQ,MAAc,YAAuB;EACjD,KAAK,GAAG,YAAY,GAAG,KAAK;EAC5B,GAAG,EAAE,aAAa,QAAQ,EAAE,IAAI,QAAQ,CAAC;CAC3C;CACA,OAAO;EACL,4BAA4B,KAAK,gBAAgB,iBAAiB;EAClE,6BAA6B,KAAK,iBAAiB,kBAAkB;CACvE;AACF"}
package/dist/index.d.mts CHANGED
@@ -425,6 +425,153 @@ export declare const childrenSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
425
425
  }, z.core.$strict>>;
426
426
  }, z.core.$strict>>;
427
427
  }, z.core.$strict>>;
428
+ /** Composed generic host shapes — the basis for the emitted editor schemas
429
+ * (D2.a). Runner packages extend these with their own runner options; `config`
430
+ * stays loose by design. */
431
+ export declare const reactorHostSchema: z.ZodObject<{
432
+ name: z.ZodString;
433
+ runner: z.ZodObject<{
434
+ module: z.ZodString;
435
+ defaultVerb: z.ZodOptional<z.ZodString>;
436
+ port: z.ZodOptional<z.ZodNumber>;
437
+ }, z.core.$loose>;
438
+ config: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
439
+ profile: z.ZodOptional<z.ZodObject<{
440
+ appId: z.ZodOptional<z.ZodString>;
441
+ name: z.ZodOptional<z.ZodString>;
442
+ description: z.ZodOptional<z.ZodString>;
443
+ icon: z.ZodOptional<z.ZodString>;
444
+ }, z.core.$strict>>;
445
+ reactor: z.ZodOptional<z.ZodObject<{
446
+ backends: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
447
+ kind: z.ZodOptional<z.ZodEnum<{
448
+ "in-process": "in-process";
449
+ remote: "remote";
450
+ worker: "worker";
451
+ }>>;
452
+ storage: z.ZodOptional<z.ZodObject<{
453
+ kind: z.ZodEnum<{
454
+ idb: "idb";
455
+ memory: "memory";
456
+ path: "path";
457
+ postgres: "postgres";
458
+ }>;
459
+ dataDir: z.ZodOptional<z.ZodString>;
460
+ url: z.ZodOptional<z.ZodString>;
461
+ }, z.core.$strict>>;
462
+ readModel: z.ZodOptional<z.ZodObject<{
463
+ url: z.ZodOptional<z.ZodString>;
464
+ }, z.core.$strict>>;
465
+ packages: z.ZodOptional<z.ZodObject<{
466
+ cdnUrl: z.ZodOptional<z.ZodString>;
467
+ specs: z.ZodOptional<z.ZodArray<z.ZodString>>;
468
+ dynamic: z.ZodOptional<z.ZodBoolean>;
469
+ }, z.core.$strict>>;
470
+ remote: z.ZodOptional<z.ZodObject<{
471
+ host: z.ZodOptional<z.ZodString>;
472
+ url: z.ZodOptional<z.ZodString>;
473
+ }, z.core.$strict>>;
474
+ }, z.core.$strict>>>;
475
+ placement: z.ZodOptional<z.ZodObject<{
476
+ primary: z.ZodOptional<z.ZodString>;
477
+ default: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
478
+ }, z.core.$strict>>;
479
+ workflows: z.ZodOptional<z.ZodBoolean>;
480
+ protocol: z.ZodOptional<z.ZodObject<{
481
+ featureFlags: z.ZodOptional<z.ZodObject<{
482
+ documentDecisions: z.ZodOptional<z.ZodBoolean>;
483
+ authEnforcement: z.ZodOptional<z.ZodBoolean>;
484
+ authGroups: z.ZodOptional<z.ZodBoolean>;
485
+ authConditions: z.ZodOptional<z.ZodBoolean>;
486
+ }, z.core.$strict>>;
487
+ createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
488
+ legacy: "legacy";
489
+ "v2-required": "v2-required";
490
+ }>>;
491
+ unsupportedStoredDocuments: z.ZodOptional<z.ZodEnum<{
492
+ "read-only": "read-only";
493
+ refuse: "refuse";
494
+ }>>;
495
+ }, z.core.$strict>>;
496
+ }, z.core.$strict>>;
497
+ }, z.core.$loose>;
498
+ export declare const compoundHostSchema: z.ZodObject<{
499
+ name: z.ZodString;
500
+ runner: z.ZodObject<{
501
+ module: z.ZodString;
502
+ defaultVerb: z.ZodOptional<z.ZodString>;
503
+ port: z.ZodOptional<z.ZodNumber>;
504
+ }, z.core.$loose>;
505
+ children: z.ZodRecord<z.ZodString, z.ZodObject<{
506
+ host: z.ZodString;
507
+ plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
508
+ runner: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
509
+ config: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
510
+ reactor: z.ZodOptional<z.ZodObject<{
511
+ backends: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
512
+ kind: z.ZodOptional<z.ZodEnum<{
513
+ "in-process": "in-process";
514
+ remote: "remote";
515
+ worker: "worker";
516
+ }>>;
517
+ storage: z.ZodOptional<z.ZodObject<{
518
+ kind: z.ZodEnum<{
519
+ idb: "idb";
520
+ memory: "memory";
521
+ path: "path";
522
+ postgres: "postgres";
523
+ }>;
524
+ dataDir: z.ZodOptional<z.ZodString>;
525
+ url: z.ZodOptional<z.ZodString>;
526
+ }, z.core.$strict>>;
527
+ readModel: z.ZodOptional<z.ZodObject<{
528
+ url: z.ZodOptional<z.ZodString>;
529
+ }, z.core.$strict>>;
530
+ packages: z.ZodOptional<z.ZodObject<{
531
+ cdnUrl: z.ZodOptional<z.ZodString>;
532
+ specs: z.ZodOptional<z.ZodArray<z.ZodString>>;
533
+ dynamic: z.ZodOptional<z.ZodBoolean>;
534
+ }, z.core.$strict>>;
535
+ remote: z.ZodOptional<z.ZodObject<{
536
+ host: z.ZodOptional<z.ZodString>;
537
+ url: z.ZodOptional<z.ZodString>;
538
+ }, z.core.$strict>>;
539
+ }, z.core.$strict>>>;
540
+ placement: z.ZodOptional<z.ZodObject<{
541
+ primary: z.ZodOptional<z.ZodString>;
542
+ default: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
543
+ }, z.core.$strict>>;
544
+ workflows: z.ZodOptional<z.ZodBoolean>;
545
+ protocol: z.ZodOptional<z.ZodObject<{
546
+ featureFlags: z.ZodOptional<z.ZodObject<{
547
+ documentDecisions: z.ZodOptional<z.ZodBoolean>;
548
+ authEnforcement: z.ZodOptional<z.ZodBoolean>;
549
+ authGroups: z.ZodOptional<z.ZodBoolean>;
550
+ authConditions: z.ZodOptional<z.ZodBoolean>;
551
+ }, z.core.$strict>>;
552
+ createSignaturePolicy: z.ZodOptional<z.ZodEnum<{
553
+ legacy: "legacy";
554
+ "v2-required": "v2-required";
555
+ }>>;
556
+ unsupportedStoredDocuments: z.ZodOptional<z.ZodEnum<{
557
+ "read-only": "read-only";
558
+ refuse: "refuse";
559
+ }>>;
560
+ }, z.core.$strict>>;
561
+ }, z.core.$strict>>;
562
+ }, z.core.$strict>>;
563
+ config: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
564
+ profile: z.ZodOptional<z.ZodObject<{
565
+ appId: z.ZodOptional<z.ZodString>;
566
+ name: z.ZodOptional<z.ZodString>;
567
+ description: z.ZodOptional<z.ZodString>;
568
+ icon: z.ZodOptional<z.ZodString>;
569
+ }, z.core.$strict>>;
570
+ }, z.core.$loose>;
571
+ /** The emitted-schema set, keyed by published filename. Pure — the
572
+ * emit-schemas script writes these to disk and the drift test re-derives
573
+ * them, per the runtime-config-schema pattern. */
574
+ export declare function emittedHostSchemas(): Record<string, unknown>;
428
575
  //#endregion
429
576
  export { type CompoundMember, type CompoundWiring, type ConnectReactorProjection, type DriveProjectionInput, type HostDefinition, HostLoadError, type HostSchemaLike, type HostsFolderStatus, type LoadedHost, type ProjectedDescriptor, type ReactorBackend, type ReactorConfig, type ReactorProtocol, type RunCompoundOptions, type RunCompoundResult, type RunProbe, type RunRecord, type RunRecordMember, type RunnerContext, RunnerError, type RunnerHandle, type RunnerModule, type RunnerVerb, type SwitchboardReactorProjection, findNonStaticValue, getVerb, lintHostImports, listVerbs, loadHost, probeHostsFolder, resolveRunnerModule, runCompound, validateHost };
430
577
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/connect-projection.ts","../src/run-record.ts","../src/placeholders.ts","../src/reactor-config.ts","../src/backend-projection.ts","../src/host-schemas.ts"],"mappings":";;;;;;;;;;;wBA+BgB,sBACX,QAAQ,4BACV;;;;;;;;wBAqBa,eAAe,kBAAkB;UAahC;;;EAGf;;EAEA,0BAA0B;;EAE1B;;;;;;;;wBASc,yBACd,OAAO,uBACN,KAAK;;;;;;;;;;UC3ES;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA,SAAS,eAAe;;EAExB,QAAQ;;KAGE;EACN;;EACA;EAAiB,QAAQ;;EACzB;EAAgB,QAAQ;;EACxB;EAAmB,QAAQ;;wBAMjB,cACd,oBACA,mBACC;wBAUa,eAAe,oBAAoB,QAAQ;wBAM3C,eAAe,oBAAoB;wBAQnC,WAAW;;;;;;;;;;wBAmBX,SACd,oBACA,kBACA,sBACC;;;;;;;;;;wBC5Ea,mBACd,qBACA,MAAK;;;wBASS,4BAA4B,GAAG,OAAO,GAAG,mBAAmB;;;;;;;;;;;KCXhE;UAEK;EACf;EACA;EACA;;UAGe;EACf;EACA;;EAEA;;UAGe;EACf;EACA;;UAGe;EACf,OAAO;EACP,UAAU;EACV;IAAc;;EACd,WAAW;EACX,SAAS;;;UAIM;EACf;IACE;IACA;IACA;IACA;;EAEF;EACA;;UAGe;EACf,WAAW,eAAe;EAC1B;IACE;IACA,UAAU;;EAEZ;EACA,WAAW;;;;wBAKG,eACd,SAAS,4BACR;;;wBA2Ba,YACd,UAAU,8BACT;UAiBc;;EAEf,KAAK;;EAEL;IAAW;;;;wBAIG,4BACd,SAAS,4BACR;UAkBc;;EAEf;IACE,UAAU;IACV;MAAa;;IACb;MAAQ;;;;;;;wBAOI,wBACd,SAAS,4BACR;;;;;;;;wBAoBa,0BACd,UAAU,6BACV,KAAK,oCACL;;;;;;;;;;;;;;KC5JU;EACN;;EACA;;EACA;EAAc;;UAEH;EACf;EACA;EACA,UAAU;EACV;IAAa;IAAiB;IAAkB;;EAChD;IACE;IACA;IACA;IACA;;EAEF;IAAW;;;;;;wBAgCG,oBACd,cACA,SAAS,gBACT,WAAW,kBACV;;;wBA2Ba,sBACd,SAAS,4BACR;;;;;;;wBAsBa,yBACd,SAAS;;wBAWK,kBACd,SAAS;;;;;;;;;;qBC5HE,eAAa,EAAA,YAAA,EAAA;;;;;GAOb,EAAA,KAAA;qBAEA,uBAAqB,EAAA;;;;;;;;;;;;;;;GAWhC,EAAA,KAAA;qBAEW,sBAAoB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuB/B,EAAA,KAAA;qBAEW,eAAa,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUxB,EAAA,KAAA;;;qBAIW,kBAAgB,EAAA;;;;GAI3B,EAAA,KAAA;;;qBAIW,gBAAc,EAAA,UAAA,EAAA,WAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS1B,EAAA,KAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/connect-projection.ts","../src/run-record.ts","../src/placeholders.ts","../src/reactor-config.ts","../src/backend-projection.ts","../src/host-schemas.ts"],"mappings":";;;;;;;;;;;wBA+BgB,sBACX,QAAQ,4BACV;;;;;;;;wBAqBa,eAAe,kBAAkB;UAahC;;;EAGf;;EAEA,0BAA0B;;EAE1B;;;;;;;;wBASc,yBACd,OAAO,uBACN,KAAK;;;;;;;;;;UC3ES;EACf;EACA;;UAGe;EACf;EACA;EACA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AoB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuB/B,EAAA,KAAA;qBAEW,eAAa,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUxB,EAAA,KAAA;;;qBAIW,kBAAgB,EAAA;;;;GAI3B,EAAA,KAAA;;;qBAIW,gBAAc,EAAA,UAAA,EAAA,WAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS1B,EAAA,KAAA;;;;qBAKY,mBAAiB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM5B,EAAA,KAAA;qBAEW,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM7B,EAAA,KAAA;;;;wBAOc,sBAAsB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as lintHostImports, D as projectDrivesIntoConnect, E as mergeDefaultDrives, O as rebaseDriveUrl, S as findNonStaticValue, T as probeHostsFolder, _ as getVerb, a as reactorProtocolSchema, b as validateHost, c as runCompound, d as clearRunRecord, f as isPidAlive, g as RunnerError, h as writeRunRecord, i as reactorBackendSchema, l as defaultUserDataDir, m as readRunRecord, o as reactorSchema, p as probeRun, r as profileSchema, s as runnerBaseSchema, t as childrenSchema, u as resolveUserDataPlaceholders, v as listVerbs, w as loadHost, x as HostLoadError, y as resolveRunnerModule } from "./host-schemas-B0-Vk8vP.mjs";
1
+ import { A as rebaseDriveUrl, C as HostLoadError, D as probeHostsFolder, E as loadHost, O as mergeDefaultDrives, S as validateHost, T as lintHostImports, _ as writeRunRecord, a as reactorBackendSchema, b as listVerbs, c as reactorSchema, d as defaultUserDataDir, f as resolveUserDataPlaceholders, g as readRunRecord, h as probeRun, i as profileSchema, k as projectDrivesIntoConnect, l as runnerBaseSchema, m as isPidAlive, n as compoundHostSchema, o as reactorHostSchema, p as clearRunRecord, r as emittedHostSchemas, s as reactorProtocolSchema, t as childrenSchema, u as runCompound, v as RunnerError, w as findNonStaticValue, x as resolveRunnerModule, y as getVerb } from "./host-schemas-C_MLcYX6.mjs";
2
2
  //#region src/backend-projection.ts
3
3
  function projectStorage(name, storage) {
4
4
  switch (storage.kind) {
@@ -137,6 +137,6 @@ function assertProtocolConsistency(protocol, env, hostFile = "the host file") {
137
137
  }
138
138
  }
139
139
  //#endregion
140
- export { HostLoadError, RunnerError, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, childrenSchema, clearRunRecord, defaultUserDataDir, findNonStaticValue, getVerb, isPidAlive, isStructuralMultiReactor, lintHostImports, listVerbs, loadHost, mergeDefaultDrives, primaryBackend, probeHostsFolder, probeRun, profileSchema, projectDrivesIntoConnect, projectReactorToConnect, projectReactorToSwitchboard, protocolEnv, reactorBackendSchema, reactorProtocolSchema, reactorSchema, readRunRecord, rebaseDriveUrl, remoteBackendUrls, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runnerBaseSchema, validateHost, writeRunRecord };
140
+ export { HostLoadError, RunnerError, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, childrenSchema, clearRunRecord, compoundHostSchema, defaultUserDataDir, emittedHostSchemas, findNonStaticValue, getVerb, isPidAlive, isStructuralMultiReactor, lintHostImports, listVerbs, loadHost, mergeDefaultDrives, primaryBackend, probeHostsFolder, probeRun, profileSchema, projectDrivesIntoConnect, projectReactorToConnect, projectReactorToSwitchboard, protocolEnv, reactorBackendSchema, reactorHostSchema, reactorProtocolSchema, reactorSchema, readRunRecord, rebaseDriveUrl, remoteBackendUrls, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runnerBaseSchema, validateHost, writeRunRecord };
141
141
 
142
142
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import { c as runCompound, n as compoundHostSchema } from "../host-schemas-B0-Vk8vP.mjs";
1
+ import { n as compoundHostSchema, u as runCompound } from "../host-schemas-C_MLcYX6.mjs";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  //#region src/runners/compound.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/host-core",
3
- "version": "6.2.3-dev.55",
3
+ "version": "6.2.3-dev.56",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -31,13 +31,13 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@powerhousedao/shared": "6.2.3-dev.55",
34
+ "@powerhousedao/shared": "6.2.3-dev.56",
35
35
  "zod": "4.3.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "tsdown": "0.23.0",
39
39
  "vitest": "5.0.3",
40
- "@powerhousedao/reactor-monitor": "6.2.3-dev.55"
40
+ "@powerhousedao/reactor-monitor": "6.2.3-dev.56"
41
41
  },
42
42
  "scripts": {
43
43
  "tsc": "tsc",