openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.7 kB
JavaScript
import{a as lstatIfExists}from"./path-existence-BR9MXlgL.mjs";import"./path-existence-runtime-BFjuPvea.mjs";import{n as MIGRATION_REASON_TARGET_EXISTS,o as createMigrationItem,v as summarizeMigrationItems}from"./migration-B8ObiJfa.mjs";import{a as resolvePlannedMigrationTargets}from"./migration-runtime-DCjCS5lg.mjs";import path from"node:path";
//!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}}}export{isMemoryOnlyMigration as n,buildHermesMemoryPlan as t};