Agent / foldkit-agent
Why the API looks like this
Why bind and a host, rather than a runtime option. Foldkit 0.163.0
accepts no agent option on makeApplication, and its runtime handle exposes
neither the current Model nor a dispatch function, so an agent seam cannot be
installed from outside Foldkit. Agent.bind({ definition, host }) is that seam,
with the application supplying model and dispatch. Sync.mount returns a
host of the right shape; examples/todo writes one
by hand. If Foldkit later grows the option, it can construct the same seam.
Why forApplication and forModel, rather than plain make. TypeScript
cannot infer Model from an available callback alone, so available: model =>
… would leave model as any. Agent.forApplication(App) infers it from a
Surface.application, with App.model typed; Agent.forModel<Model>() fixes
it when there is no application. Agent.make is still there when the Model does
not matter.
Effect 4, not 3. Foldkit 0.168.0 peer-depends on effect@4.0.0, so
snippets written against Effect 3 need translating: Schema.OptionFromSelf is
Schema.Option here.
Why capabilities expose Messages, never setters. An agent changes the
application exactly the way a person does: by causing a Message the
application already handles, which update (normally via modifyFields) reduces.
There is no agent-side Model write, so nothing the agent does can bypass
transition semantics or diverge from what replay shows.