VoiceAgent
Defined in: packages/react/src/agent.ts:71
The store contract. subscribe + getSnapshot are useSyncExternalStore-
compatible: getSnapshot MUST return a stable reference until something changes
(return a cached object, mutate-then-replace), or React will loop.
Methods
subscribe()
subscribe(onStoreChange): () => void;Defined in: packages/react/src/agent.ts:73
Register a change listener; returns an unsubscribe fn.
Parameters
| Parameter | Type |
|---|---|
onStoreChange | () => void |
Returns
() => void
getSnapshot()
getSnapshot(): VoiceSnapshot;Defined in: packages/react/src/agent.ts:75
Current immutable snapshot (stable ref until a change).
Returns
mute()
mute(muted): void;Defined in: packages/react/src/agent.ts:78
Set the local mic muted flag.
Parameters
| Parameter | Type |
|---|---|
muted | boolean |
Returns
void
sendText()
sendText(text): void;Defined in: packages/react/src/agent.ts:80
Inject user text → agent reply.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
void
interrupt()
interrupt(): void;Defined in: packages/react/src/agent.ts:82
Cancel the current turn, return to idle.
Returns
void
reset()?
optional reset(): void;Defined in: packages/react/src/agent.ts:84
Clear the transcript + abandon any in-flight turn (chat reset). Optional.
Returns
void
speak()?
optional speak(text): void | Promise<void>;Defined in: packages/react/src/agent.ts:91
Make the agent speak arbitrary text now, outside a turn (e.g. a spoken welcome on call start). May return a promise that resolves when playback ends — callers should not assume completion if the implementation returns void. No-op if the agent can't speak.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
void | Promise<void>
start()?
optional start(): void | Promise<void>;Defined in: packages/react/src/agent.ts:94
Begin the session (optional; called by VoiceRoom on mount).
Returns
void | Promise<void>
stop()?
optional stop(): void | Promise<void>;Defined in: packages/react/src/agent.ts:96
End the session (optional; called by VoiceRoom on unmount).
Returns
void | Promise<void>
unlock()?
optional unlock(): void;Defined in: packages/react/src/agent.ts:98
Resume the Web Audio context after a user gesture (autoplay policy).
Returns
void