Package:
@hexos/react-coreHook that registers a context entry to be sent with every agent request.
Provides the agent with information about the current application state (e.g., current page, user preferences, selected items). The context is stored in frontendContextAtom and included in every TransportMessage.
When the component unmounts, the context entry is automatically removed unless
persistent is set to true (default). Persistent context survives component
unmounting and is only removed explicitly.
Related: ContextDefinition defines the entry structure, updateContextAtom and removeContextAtom manage the store, useAgent includes the context when sending messages.
Example
useAgentContext({
key: 'current_page',
description: 'The current page the user is viewing',
value: { route: '/dashboard', title: 'Dashboard' },
priority: 10,
});function useAgentContext(definition: ContextDefinition): voidParameters