File size: 706 Bytes
4af09f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { exportFullWorkspace, importWorkspace, WorkspaceExport } from './db';

/**
 * Persistence Bridge
 * 
 * In a standard web environment, we can't directly write to the filesystem.
 * However, we can trigger a download or, in this agentic environment, 
 * provide a hook for the agent to sync the state.
 */

export async function syncToJSON(): Promise<WorkspaceExport> {
  const data = await exportFullWorkspace();
  console.log('SYNC_REQUIRED', JSON.stringify(data)); 
  // We log this so the agent/system can pick it up if watching logs, 
  // or the user can copy-paste.
  return data;
}

export async function loadFromJSON(data: WorkspaceExport): Promise<void> {
  await importWorkspace(data);
}