UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.2 kB
import{l as isRecord}from"./record-coerce-BTbqdJ3-.mjs";import"./utils-Dlk0IYAa.mjs";import{o as openRootFileSync,r as isRootFileMissingFailure}from"./boundary-file-read-bB9An35K.mjs";import{i as INCLUDE_KEY,s as isInternalIncludeWriteTarget}from"./includes-gwK90iIZ.mjs";import{r as resolveIncludeWriteBoundary}from"./include-write-boundary-D2kTsgAN.mjs";import fs from"node:fs";import path from"node:path"; //!src/commands/doctor/shared/include-migration-ownership.ts function containsAuthoredInclude(e){if(Array.isArray(e))return e.some(containsAuthoredInclude);if(!isRecord(e))return false;return Object.hasOwn(e,`$include`)||Object.values(e).some(containsAuthoredInclude)}function classifyConfigPathMigrationOwnership(e){const t=(e.snapshot.includeProvenance??[]).filter(t=>t.path.length<=e.configPath.length&&t.path.every((t,n)=>t===e.configPath[n]));if(t.length===0)return{kind:`direct`};const n=[...new Set(t.flatMap(e=>e.targetPaths??(e.targetPath?[e.targetPath]:[])))].toSorted();const r=resolveIncludeWriteBoundary({provenance:e.snapshot.includeProvenance,changed:{paths:[e.configPath],rootChanged:false}});if(r&&isInternalIncludeWriteTarget({configPath:e.snapshot.path,includePath:r.includePath}))return{kind:`single-include`,targetPath:r.includePath};return{kind:`manual`,targetPaths:n}}function readOtelProtocol(e){const t=isRecord(e)?e:null;const n=isRecord(t?.diagnostics)?t.diagnostics:null;return(isRecord(n?.otel)?n.otel:null)?.protocol}function classifyOtelGrpcMigrationOwnership(e){if(readOtelProtocol(e.resolvedConfig)!==`grpc`)return null;const t=classifyConfigPathMigrationOwnership({snapshot:e.snapshot,configPath:[`diagnostics`,`otel`,`protocol`]});if(t.kind!==`direct`)return t;return readOtelProtocol(e.authoredConfig)===`grpc`?t:{kind:`resolved-only`}}function readDoctorConfigBackup(e){const t=openRootFileSync({absolutePath:e,rootPath:path.dirname(e),boundaryLabel:`config backup directory`});if(!t.ok){if(isRootFileMissingFailure(t))return;throw new Error(`Config backup could not be read safely`)}try{return fs.readFileSync(t.fd,`utf8`)}finally{fs.closeSync(t.fd)}}export{containsAuthoredInclude as n,readDoctorConfigBackup as r,classifyOtelGrpcMigrationOwnership as t};