( agentType: string, scope: AgentMemoryScope, )
| 54 | } |
| 55 | |
| 56 | async function copySnapshotToLocal( |
| 57 | agentType: string, |
| 58 | scope: AgentMemoryScope, |
| 59 | ): Promise<void> { |
| 60 | const snapshotMemDir = getSnapshotDirForAgent(agentType) |
| 61 | const localMemDir = getAgentMemoryDir(agentType, scope) |
| 62 | |
| 63 | await mkdir(localMemDir, { recursive: true }) |
| 64 | |
| 65 | try { |
| 66 | const files = await readdir(snapshotMemDir, { withFileTypes: true }) |
| 67 | for (const dirent of files) { |
| 68 | if (!dirent.isFile() || dirent.name === SNAPSHOT_JSON) continue |
| 69 | const content = await readFile(join(snapshotMemDir, dirent.name), { |
| 70 | encoding: 'utf-8', |
| 71 | }) |
| 72 | await writeFile(join(localMemDir, dirent.name), content) |
| 73 | } |
| 74 | } catch (e) { |
| 75 | logForDebugging(`Failed to copy snapshot to local agent memory: ${e}`) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | async function saveSyncedMeta( |
| 80 | agentType: string, |
no test coverage detected