Host Integration
The host is the application that displays the character. Register the elements it can interact with and supply the callbacks it may invoke.
Responsibility split
| Responsibility | CharaWeave | Consumer / Host |
|---|---|---|
| WHAT selection | Yes | No |
| Character identity, authored preferences, repertoire | Package data | Supplies and validates package input |
| Current target existence | No | Yes |
| Target semantic registration | Defines contract | Adapter/application maps product objects to IDs, roles, capabilities |
| Target geometry | Browser Adapter measures bound elements | Provides the live Element and placement inputs |
| Presentation policy/lifecycle | Runtime selects semantic state and lifecycle | Renderer consumes the selected clip and reports finite terminal observation |
| DOM rendering and asset loading | No universal renderer | Yes |
| Business action execution | No arbitrary package code | Consumer executes trusted, application-owned callbacks |
| Mount/unmount and disposal | Exposes lifecycle operations | Owns service/session lifetime |
Current public composition
@charaweave/platform provides createConsumerSession; @charaweave/platform/browser provides createBrowserEnvironment. This convenience composition loads Content V6 and has a V6 consumer projection. It is not a complete high-level wrapper for V11 repertoire evaluation. Use the V11 Content loader when you need its additional fields. The public execution APIs do not currently provide a complete V11 CharacterSession. Do not import internal packages to bypass that limit.
For the ordinary V10 Core projection, the standard createCoreSession + createBrowserSession path is also available, with @charaweave/react for React. The Generic Web Integration tutorial uses this path. The APIs are divided into packages by function. @charaweave/runtime handles the ordinary platform-neutral character command/snapshot runtime; the autonomy/browser path composes Content, Autonomy, Host, Browser Runtime, and rendering responsibilities. See Runtime API Reference and Public API ledger.
Integration sequence
- Load a package through Public Content and handle validation issues.
- Create the Character/Runtime session using an existing Public entrypoint suitable for the schema projection.
- Create application-owned Host and Browser services, or use the existing Platform Browser composition where its V6 projection meets the use case.
- Bind a live Host Element to a stable semantic surface ID, role, and declared capabilities.
- Provide the character Element and placement projection to Browser motion/rendering.
- Start scheduling only after required target and renderer services are ready.
- Execute only application-owned Host callbacks.
activateis trusted consumer behavior; package data is never executable. - Observe finite Presentation completion, cancellation, failure, touch, and context invalidation on their supported semantic paths.
- On route removal, stop the loop, detach bindings, dispose services/session in their ownership order.
Host identity and capability validation
Both Host Surface ID and role must match the current lexical format (lowercase letters/digits separated by dots or hyphens: ^[a-z0-9]+(?:[.-][a-z0-9]+)*$). For example, feed.photo.42 and photo-card are valid; feed:photo:42 is not. Character package resource IDs use a different colon-separated format. Map arbitrary external IDs to stable, collision-free valid Host IDs rather than blindly inserting them into the descriptor.
Host capabilities currently contain only the optional activate capability (no duplicates); an empty list is valid. A visit is a Character action, not a Host capability named visit. The current registry validates exact descriptor fields: schemaVersion 1, id, role, capabilities. The registry checks these values when a surface is registered.
Host surface example
The current Browser convenience API accepts a real Element and semantic descriptor:
const attachment = browser.attachHost({
element: photoCardElement,
id: "feed.photo.42",
role: "photo-card",
capabilities: ["activate"],
onActivate: async ({ surfaceId }) => {
await openPhoto(surfaceId);
},
});
// On unmount or when this target ceases to represent the same object:
attachment.detach();
This matches BrowserHostAttachmentInputV1. Your application maps surfaceId to a photo. The handler must remain application-owned and must not be loaded from the Character package.
Lifecycle
Keep the host services alive until every attachment has been removed. A registry, geometry adapter, and executor are application services; a React callback ref owns only its attachment. On target replacement, detach the old surface and register a new semantic generation. When leaving a route, stop execution, detach its targets and dispose the session it owns. Reject late execution results for detached targets.
Geometry and accessibility
Browser Host geometry is measured from bound elements in viewport CSS pixels through getBoundingClientRect(). DPR is not multiplied into CSS positions. Current transform coverage is bounded to axis-aligned rendered rectangles. Preserve the product UI's focus, keyboard, and accessible names; a character overlay must not intercept interactions unless the Consumer deliberately implements that behavior.
See React Integration, Generic Web Integration, Targets, and Consumer Integration Manual.