Local and Global State (upcoming)
// @zw-run-locally
// Local per-run state β cleared automatically when the run ends
const runState = zw.state.access();
runState.runStartedAt = Date.now();
// Shared Desktop Agent global state β persists across runs on this device
const globalState = zw.globalState.access();
globalState.totalRuns = (globalState.totalRuns ?? 0) + 1;// In the browser β work with a JSON-safe snapshot of local or global state
const runStateCopy = await zw.state.browser.getCopy();
runStateCopy.lastSeenAt = Date.now();
await zw.state.browser.commit({ state: runStateCopy });1. Local Per-Run State β zw.state.*
zw.state.*At a Glance
Examples
2. Global State β zw.globalState.*
zw.globalState.*At a Glance
Example
Notes
3. Use State in the Browser β zw.state.browser.* and zw.globalState.browser.*
zw.state.browser.* and zw.globalState.browser.*At a Glance
Examples
Notes
Last updated