Host data bindings
Let surfaces show live app state, such as the cart total, without the value ever leaving the device.
A surface prop can be a binding { "path": "/host/cart/total" }. Paths under /host/ are resolved on the device against data your app publishes:
Kletso.instance.setHostData({
'cart': {'items': 2, 'total': 3198, 'label': '₹302 away from free shipping'},
});
Kletso.instance.updateHostData({'cart': {'items': 3, 'total': 3897}});
setHostDatareplaces the whole map;updateHostDatamerges the top level.- Changing host data rebuilds rendered surfaces, so a
progressblock bound to/host/cart/progressmoves as the user shops. - The values are never sent to the runtime or the model. If the model needs to know the cart value, put it in context instead.
- Resolution order for
/host/...paths: your host data first, then the surface’s owndataas a fallback (so the model can ship a default). All other paths resolve against the surfacedataonly.
Example surface node the agent might render:
"ship": { "type": "progress", "props": { "value": { "path": "/host/cart/progress" }, "label": { "path": "/host/cart/label" } } }
Renderers outside the chat can pass their own resolver: KletsoSurfaceView(surface: s, bindingResolver: myResolver).