UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

53 lines (52 loc) • 1.96 kB
import { B as timestampMsToIsoFileStamp } from "./number-coercion-D6u-4YD8.mjs"; import { r as resolveStateDir } from "./state-dir-DiG0gXzD.mjs"; import "./paths-DAcAg5aV.mjs"; import { n as normalizeAgentId, t as isValidAgentId } from "./agent-id-CQjtp2ft.mjs"; import { h as resolveConfiguredAgentId } from "./agent-scope-config-DmXgFGKP.mjs"; import { r as loadConfig } from "./io.runtime-DsJ2dLCQ.mjs"; import "./config-CMA-J084.mjs"; import path from "node:path"; //#region src/commands/migrate/context.ts /** Builds a migration logger that keeps JSON stdout machine-readable. */ function createMigrationLogger(e, t = {}) { const n = t.json ? e.error : e.log; return { debug: (e) => { if (process.env.OPENCLAW_VERBOSE === "1") n(e); }, info: (e) => n(e), warn: (t) => e.error(t), error: (t) => e.error(t) }; } function buildMigrationReportDir(e, t, n = Date.now()) { const r = timestampMsToIsoFileStamp(n); return path.join(t, "migration", e, r); } /** Resolves an explicit migration owner without allowing typo-created agent stores. */ function resolveMigrationTargetAgentId(e, t) { const n = t?.trim(); if (t !== void 0 && !n) throw new Error("--agent must not be blank"); if (!n) return; if (!isValidAgentId(n)) throw new Error(`Invalid agent id "${n}".`); const r = normalizeAgentId(n); return resolveConfiguredAgentId(e, r); } function buildMigrationContext(e) { const t = e.configOverride ?? loadConfig(); return { config: t, stateDir: resolveStateDir(), targetAgentId: resolveMigrationTargetAgentId(t, e.targetAgentId), itemKinds: e.itemKinds, source: e.source, includeSecrets: Boolean(e.includeSecrets), overwrite: Boolean(e.overwrite), providerOptions: e.providerOptions, backupPath: e.backupPath, reportDir: e.reportDir, logger: createMigrationLogger(e.runtime, { json: e.json }) }; } //#endregion export { buildMigrationReportDir as n, createMigrationLogger as r, buildMigrationContext as t };