/** * `/proc/bare_os/protomux_extensions.json` — policy-gated operator view of Protomux * channel hints for kernel extensions (no wire secrets). */ /** * @param {Record} env */ function protomuxExtensionsRegistryExposed(env) { const v = String(env?.BARE_OS_PROC_PROTOMUX_EXTENSIONS_REGISTRY ?? '') .trim() .toLowerCase() return v === '1' || v === 'true' || v === 'yes' } /** * @param {{ * env?: Record | null, * registrySnapshot?: Record | null, * ctxApiVersion?: string * }} opts */ export function buildBareOsProtomuxExtensionsProcJson(opts = {}) { const env = opts.env && typeof opts.env === 'object' ? opts.env : {} const now = Date.now() if (!protomuxExtensionsRegistryExposed(env)) { return { schema: 1, exposed: false, note: 'Set BARE_OS_PROC_PROTOMUX_EXTENSIONS_REGISTRY=1 to expose extension mux hints (alias registry snapshot + stable logical channel names).', atMs: now } } const snap = opts.registrySnapshot && typeof opts.registrySnapshot === 'object' ? opts.registrySnapshot : {} return { schemaVersion: 2, exposed: true, ctxApiVersion: String(opts.ctxApiVersion || ''), registry: snap, muxWirePackage: 'protomux', muxWireMajor: 3, extensionLogicalChannels: [ { name: 'bare-os-kernel-ext-handshake', note: 'Reserved logical label for extension pairing over Protomux-framed streams (P2P).' }, { name: 'bare-os-extension-telemetry', note: 'Optional NDJSON-shaped diagnostic channel; host must open explicitly.' } ], wireReference: '/proc/bare_os/protomux.json', atMs: now } }