forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseA2UI.ts
More file actions
34 lines (28 loc) · 892 Bytes
/
Copy pathuseA2UI.ts
File metadata and controls
34 lines (28 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { useA2UIActions, useA2UIState } from "../core/A2UIProvider";
/**
* Result returned by the useA2UI hook.
*/
export interface UseA2UIResult {
/** Process incoming v0.9 A2UI messages */
processMessages: (messages: Array<Record<string, unknown>>) => void;
/** Get a surface model by ID */
getSurface: (surfaceId: string) => any | undefined;
/** Clear all surfaces */
clearSurfaces: () => void;
/** The current version number (increments on state changes) */
version: number;
}
/**
* Main API hook for A2UI v0.9. Provides methods to process messages
* and access surface state.
*/
export function useA2UI(): UseA2UIResult {
const actions = useA2UIActions();
const state = useA2UIState();
return {
processMessages: actions.processMessages,
getSurface: actions.getSurface,
clearSurfaces: actions.clearSurfaces,
version: state.version,
};
}