Consumer Integration Manual
Use this manual when adding a character to an existing application. The SDK packages are private, so repository access is required.
1. Prerequisites
- A valid Character package source that implements
CharacterPackageReaderV1. - A product-defined stable semantic ID and role for each current Host target.
- A renderer for Character image/clip content and finite lifecycle terminals.
- A trusted application callback for any Host
activatecapability. - Explicit ownership for each Runtime, Autonomy, Host, Browser, and React resource.
Import from Public packages only. Never load package code. Core/Internal source is not a Consumer API.
2. Select the supported integration path
Choose the API that matches your application:
@charaweave/runtimeexposes the ordinary platform-neutral command/snapshot Runtime. It is not the autonomous Character WHAT API.@charaweave/coreexposescreateCoreSessionfor ordinary session lifecycle and Presentation Behavior/Recovery operations. It currently consumes the V10 projection. Pair it withcreateBrowserSessionfrom@charaweave/browserand, in React,CharaWeaveProvider/useCharaWeaveHostfrom@charaweave/react. See the complete Web tutorial and React guide.@charaweave/platformplus@charaweave/platform/browserprovide a higher-level Browser convenience composition that currently consumes Content V6.@charaweave/contentexposes current Content V11 and the V11 repertoire projection. There is no current one-call Public V11CharacterSessioncomposition wrapper. The public APIs can load V11 content and expose individual capabilities, but a complete external V11 execution path is not provided. Internal CharacterSession imports are not a supported consumer integration.
Choose a projection that includes the fields your application needs.
3. Load the package
Use Public Content to validate source package data:
import { loadCharacterContentV11 } from "@charaweave/content";
import type { CharacterPackageReaderV1 } from "@charaweave/content";
declare const reader: CharacterPackageReaderV1;
const result = await loadCharacterContentV11({
reader,
characterId: "example.simple-cat:cat",
});
if (!result.ok) {
throw new Error(`Invalid Character package: ${result.issues.length} issue(s)`);
}
const characterContent = result.character;
The reader owns file/archive/HTTP access and existence checks. Content validates package data and returns the requested type. The consumer renderer separately fetches/decodes visual resources using the validated asset references.
4. Create the existing V6 Platform Browser composition
When V6 Content is sufficient, the current Platform helper owns the ordinary Runtime, Autonomy Session, policy resolution, Browser coordinator, loop, Host registry, geometry, and action executor composition:
import { createConsumerSession } from "@charaweave/platform";
import { createBrowserEnvironment } from "@charaweave/platform/browser";
import { createCharacterViewportPlacement } from "@charaweave/browser-runtime";
import type { CharacterPackageReaderV1 } from "@charaweave/content";
import type { AutonomyTargetSessionPolicyV1 } from "@charaweave/autonomy";
import type { CharacterViewportPlacementV1 } from "@charaweave/browser-runtime";
declare const reader: CharacterPackageReaderV1;
declare const targetSessionPolicy: AutonomyTargetSessionPolicyV1;
declare const characterElement: HTMLElement;
declare function openPhoto(surfaceId: string): Promise<void>;
let placement: CharacterViewportPlacementV1 = createCharacterViewportPlacement(0, 0);
const session = await createConsumerSession({
character: { reader, characterId: "example.simple-cat:cat" },
targetSessionPolicy,
});
const browser = createBrowserEnvironment(session, {
character: {
getElement: () => characterElement,
getCurrentPlacement: () => placement,
applyPlacement: (next) => { placement = next; },
},
approachClearancePx: 16,
motionDurationMs: 280,
});
The CharacterPackageReaderV1 import is from @charaweave/content. The motion values above are Consumer configuration examples, not universal defaults. Keep characterElement mounted and the placement setter connected to the real renderer.
5. Register live semantic targets
const attachment = browser.attachHost({
element: photoCardElement,
id: "feed.photo.42",
role: "photo-card",
capabilities: ["activate"],
onActivate: async ({ surfaceId }) => openPhoto(surfaceId),
});
session.start();
id, role, and capabilities are application semantic data. The adapter registers the live element and geometry. activate requires a trusted application handler. visit selects and approaches a target but does not call the activation handler. inspect means the Character selected an inspect action; the Consumer decides what private product data an allowed inspector can expose.
6. Update, replace, or detach targets
On product identity replacement, detach the old attachment and attach the new entity with its semantic ID. On DOM element replacement for the same semantic target, let the framework adapter reconcile attachment lifetime where applicable. On unmount, detach exactly once. The registration generation distinguishes an old attachment from a new attachment with the same ID.
The React hooks useCharaWeaveHost, useConsumerHost and useCharaSurface each manage their own attachments. Do not call a second registration API for the same Element.
7. Render and report completion
The Consumer renderer owns asset loading, positioning, image decoding, frame advancement, and presentation completion observations. Presentation semantics come from validated bindings and Runtime lifecycle; a file name does not select a policy. Report completion for the active execution generation. A delayed result must not interrupt a new touch reaction or recovery.
Browser target geometry is viewport CSS-pixel DOMRect data. The Consumer should handle clipping/accessibility and keep its Host controls usable while the Character is visible.
8. Forward interaction and trusted actions
Forward user Touch through the supported Character/session command surface in the composition you selected. Activation callbacks remain product code. Do not let arbitrary Character package content execute URLs, scripts, or business mutations. A rejected/cancelled/failed operation is not a completed autonomous action.
9. Dispose cleanly
For the V6 convenience composition, remove bindings first, then dispose its owner:
attachment.detach();
session.stop();
session.dispose(); // also disposes its registered Browser environment and Runtime
Call stop before disposal if work is running. ConsumerSession.dispose() is idempotent and owns disposal of the registered environment and its Runtime/Autonomy resources. The Browser environment itself has no separate public dispose() method.
When composing lower-level public services, define an owner and dispose each owned service once, in reverse acquisition order. Maintain a clear map of subscriptions, loop, coordinator, motion, geometry, actions, registry, Autonomy Session, and Runtime.
10. Validate with a real host
Use a real application surface and identical layout when evaluating character placement. Verify mount/unmount, target replacement, Host activation, no stale action after detach, action lifecycle, Touch, Recovery, idle restoration, and cleanup. Test the same interactions in the actual product as well as in Studio.
The current workspace does not publish packages, provide arbitrary DOM discovery, provide a universal renderer, or persist Character history across sessions. See Host Integration, React Integration, and Runtime API.