rem-notepad / src /lib /persistence.ts
algorembrant's picture
Upload 31 files
4af09f9 verified
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);
}