UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

52 lines (51 loc) • 1.99 kB
import { a as lstatIfExists } from "./path-existence-Co7-GyVr.mjs"; import "./path-existence-runtime-LOpU--Vt.mjs"; import { n as MIGRATION_REASON_TARGET_EXISTS, o as createMigrationItem, v as summarizeMigrationItems } from "./migration-C73lp9ea.mjs"; import { a as resolvePlannedMigrationTargets } from "./migration-runtime-2xeVeXDu.mjs"; import path from "node:path"; //#region extensions/migrate-hermes/memory.ts const MIGRATION_REASON_TARGET_NOT_REGULAR = "target is not a regular file"; function isMemoryOnlyMigration(e) { return Boolean(e.itemKinds && e.itemKinds.length > 0 && e.itemKinds.every((e) => e === "memory")); } async function buildHermesMemoryPlan(e, t) { const n = resolvePlannedMigrationTargets(e); const r = path.join(n.workspaceDir, "memory", "imports", "hermes"); const i = []; for (const [n, a] of [["MEMORY.md", t.memoryPath], ["USER.md", t.userPath]]) { if (!a) continue; const t = path.join(r, n); const o = await lstatIfExists(t); const s = o !== void 0 && !o.isFile(); const c = s || o !== void 0 && !e.overwrite; i.push(createMigrationItem({ id: `memory:${n}`, kind: "memory", action: "copy", source: a, target: t, status: c ? "conflict" : "planned", reason: s ? MIGRATION_REASON_TARGET_NOT_REGULAR : c ? MIGRATION_REASON_TARGET_EXISTS : void 0, message: "Copy Hermes memory into the OpenClaw memory index.", details: { sourceType: "hermes-memory", sourceLabel: `Hermes ${n}`, collectionId: "hermes", collectionLabel: "Hermes", relativePath: n } })); } return { providerId: "hermes", source: t.root, target: n.workspaceDir, summary: summarizeMigrationItems(i), items: i, warnings: i.some((e) => e.status === "conflict") ? ["Conflicts were found. Re-run with --overwrite to replace conflicting targets after item-level backups."] : [], nextSteps: [], metadata: { agentDir: n.agentDir } }; } //#endregion export { isMemoryOnlyMigration as n, buildHermesMemoryPlan as t };