State type. setState merges, which is
what you want for the common case — update two fields without re-writing the rest.
State value. Reads return
that value in full, and setState re-persists it inside a storage transaction, so keep
it small and fixed-shape: status flags, cursors, the instance’s working memory. It
follows the storage layer’s codec rules and per-value size cap (see the
storage reference). For
data that accumulates or needs querying — rows you’d filter, aggregate, or join —
use the agent’s embedded SQL database instead; it lives in the
same instance and scales to 1 GB per agent.
initialState()
getState()
setState()
The merge is recursive, andnull deletes:
status and job.id were never rewritten.
replaceState()
onStateChanged()
One override fans state out to connected clients —broadcastSnapshot pushes to every
socket subscribed to state, and the hook covers setState and replaceState alike:
setState
override instead, where the patch object is in hand; the example on
AgentSocketServer shows that
variant.