CharaWeave Architecture
A character package defines the character's available actions and artwork. The runtime selects an action, the browser integration executes it, and the application renders the result. The repository is a private workspace. See the package exports and Public API surface.
Runtime flow
flowchart LR
P[Character Package] --> V[Package validation and Content projection]
V --> S[CharacterSession / Runtime composition]
H[Host application] --> A[Host Adapter]
A --> C[Context and semantic Targets]
C --> S
S --> B[Behavior selection]
B --> W[Selected WHAT]
W --> L[Execution lifecycle]
L --> PR[Presentation state and clip]
PR --> R[Consumer renderer]
R --> H
Package Runtime checks the manifest, character definition, resource paths and declared assets before Content returns typed data. A character package contains data, not executable code.
WHAT selection
flowchart LR
R[Authored repertoire] --> C[Capability gate]
C --> A[Current applicability]
A --> T[Temporal eligibility]
T --> M[Base preference and policy contributions]
M --> RP[Action repetition]
RP --> TH[Target history / affinity]
TH --> PS[Presentation and context suppression]
PS --> EM[Effective finite mass]
EM --> W[Weighted WHAT selection]
Capability, applicability and timing determine whether an action can be considered. The policy resolver adjusts the weights of eligible actions. An action whose effective weight falls to zero cannot be selected. Read Behavior Selection before interpreting an effective mass.
Lifecycle ownership
stateDiagram-v2
[*] --> Idle
Idle --> Action: opportunity selected and accepted
Action --> Idle: completed terminal
Action --> Idle: cancelled / failed / invalidated terminal
Idle --> Touch: user interaction
Action --> Touch: touch takes ownership
Action --> Recovery: owned interaction context invalidated
Touch --> Idle: finite reaction ends
Recovery --> Idle: recovery terminal
ActivityOwnership determines which activity controls the character's presentation. A touch reaction or recovery can interrupt an autonomous action. The host adapter supplies the interaction context.
Host and adapter boundary
flowchart TD
DOM[Host DOM / application UI] --> RH[React Host Adapter, when used]
RH --> BH[Browser Host Adapter]
BH --> HC[Public Host contract]
HC --> BR[Browser Runtime composition]
BR --> CS[CharacterSession and policy]
CS --> OBS[Semantic observations and commands]
OBS --> BR
BR --> RENDER[Application-owned renderer]
Use @charaweave/core with @charaweave/browser for the standard browser integration, and @charaweave/react for React. The lower-level browser and React host adapters are @charaweave/host-browser and @charaweave/react-host-browser. @charaweave/browser-runtime provides execution services. A Consumer supplies target meaning, DOM elements and lifecycle, renders assets and finite clips, and decides whether a Host activation performs a business operation. See Adapter Policy.
Package boundaries
packages/stable: long-lived contract candidates such as identifiers, commands, definitions, and package schema.packages/public: supported facades and production adapters.packages/internal: Runtime and policy implementation. Consumers should not import these packages directly.apps: Studio and playground composition. These applications assemble the runtime and its renderer.
For source-level dependency information, see the public API inventory and architecture baseline. The repository is private.
Current limitations
- No AI controller or cross-session long-term Character memory.
- No generic arbitrary behavior DSL or marketplace.
- The Consumer maps product objects to semantic targets and handles product-specific actions.
- Renderer code owns loading and drawing; the current package is not a universal rendering engine.
- The public API is divided into packages. There is no umbrella SDK.
- Current package manifests are private
0.0.0workspace packages; no npm install path is offered.