MCPcopy Create free account
hub / github.com/Noumena-Network/code / copySnapshotToLocal

Function copySnapshotToLocal

src/tools/AgentTool/agentMemorySnapshot.ts:70–91  ·  view source on GitHub ↗
(
  agentType: string,
  scope: AgentMemoryScope,
)

Source from the content-addressed store, hash-verified

68}
69
70async function copySnapshotToLocal(
71 agentType: string,
72 scope: AgentMemoryScope,
73): Promise<void> {
74 const snapshotMemDir = getSnapshotDirForAgent(agentType)
75 const localMemDir = getAgentMemoryDir(agentType, scope)
76
77 await mkdir(localMemDir, { recursive: true })
78
79 try {
80 const files = await readdir(snapshotMemDir, { withFileTypes: true })
81 for (const dirent of files) {
82 if (!dirent.isFile() || dirent.name === SNAPSHOT_JSON) continue
83 const content = await readFile(join(snapshotMemDir, dirent.name), {
84 encoding: 'utf-8',
85 })
86 await writeFile(join(localMemDir, dirent.name), content)
87 }
88 } catch (e) {
89 logForDebugging(`Failed to copy snapshot to local agent memory: ${e}`)
90 }
91}
92
93async function saveSyncedMeta(
94 agentType: string,

Callers 2

initializeFromSnapshotFunction · 0.85
replaceFromSnapshotFunction · 0.85

Calls 6

getSnapshotDirForAgentFunction · 0.85
getAgentMemoryDirFunction · 0.85
mkdirFunction · 0.85
readdirFunction · 0.85
readFileFunction · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected