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}});
  • setHostData replaces the whole map; updateHostData merges the top level.
  • Changing host data rebuilds rendered surfaces, so a progress block bound to /host/cart/progress moves 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 own data as a fallback (so the model can ship a default). All other paths resolve against the surface data only.

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).

Last updated 2026-09-28 · Report an issue with this page