import path from "node:path"; import type { ZodIssue } from "zod"; import { CONFIG_PATH } from "../config/config.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { OpenClawSchema } from "../config/zod-schema.js"; import { note } from "../terminal/note.js"; import { isRecord } from "../utils.js";
function normalizeIssuePath(path: PropertyKey[]): Array<string | number> { return path.filter((part): part is string | number => typeof part !== "symbol");
}
function isUnrecognizedKeysIssue(issue: ZodIssue): issue is UnrecognizedKeysIssue { return issue.code === "unrecognized_keys";
}
export function formatConfigPath(parts: Array<string | number>): string { if (parts.length === 0) { return"<root>";
}
let out = ""; for (const part of parts) { if (typeof part === "number") {
out += `[${part}]`; continue;
}
out = out ? `${out}.${part}` : part;
} return out || "<root>";
}
export function resolveConfigPathTarget(root: unknown, path: Array<string | number>): unknown {
let current: unknown = root; for (const part of path) { if (typeof part === "number") { if (!Array.isArray(current)) { returnnull;
} if (part < 0 || part >= current.length) { returnnull;
}
current = current[part]; continue;
} if (!current || typeof current !== "object" || Array.isArray(current)) { returnnull;
} const record = current as Record<string, unknown>; if (!(part in record)) { returnnull;
}
current = record[part];
} return current;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.