@personaai/react 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -325,6 +325,16 @@ interface UseVoiceOptions {
|
|
|
325
325
|
* leave undefined) to start a fresh conversation.
|
|
326
326
|
*/
|
|
327
327
|
threadId?: string;
|
|
328
|
+
/**
|
|
329
|
+
* Caller-supplied context appended to the Agent's system instruction for
|
|
330
|
+
* this call — same field/cap/contract as `useChat`'s `sendMessage(text, {
|
|
331
|
+
* contextOverride })`. Unlike text chat, this is a **one-time append at
|
|
332
|
+
* connect**, not re-applied per turn: Gemini Live's system instruction is
|
|
333
|
+
* fixed for the whole call, so changing it means ending this call and
|
|
334
|
+
* starting a new `start()`. Capped at 4000 characters server-side
|
|
335
|
+
* (rejected with a 400, not truncated).
|
|
336
|
+
*/
|
|
337
|
+
contextOverride?: string;
|
|
328
338
|
}
|
|
329
339
|
interface UseVoiceResult {
|
|
330
340
|
state: PersonaVoiceState;
|
package/dist/index.d.ts
CHANGED
|
@@ -325,6 +325,16 @@ interface UseVoiceOptions {
|
|
|
325
325
|
* leave undefined) to start a fresh conversation.
|
|
326
326
|
*/
|
|
327
327
|
threadId?: string;
|
|
328
|
+
/**
|
|
329
|
+
* Caller-supplied context appended to the Agent's system instruction for
|
|
330
|
+
* this call — same field/cap/contract as `useChat`'s `sendMessage(text, {
|
|
331
|
+
* contextOverride })`. Unlike text chat, this is a **one-time append at
|
|
332
|
+
* connect**, not re-applied per turn: Gemini Live's system instruction is
|
|
333
|
+
* fixed for the whole call, so changing it means ending this call and
|
|
334
|
+
* starting a new `start()`. Capped at 4000 characters server-side
|
|
335
|
+
* (rejected with a 400, not truncated).
|
|
336
|
+
*/
|
|
337
|
+
contextOverride?: string;
|
|
328
338
|
}
|
|
329
339
|
interface UseVoiceResult {
|
|
330
340
|
state: PersonaVoiceState;
|
package/dist/index.js
CHANGED
|
@@ -1392,6 +1392,7 @@ function useVoice(options = {}) {
|
|
|
1392
1392
|
const voiceLogger = useMemo3(() => logger.child("voice"), [logger]);
|
|
1393
1393
|
const agentId = options.agentId || defaultAgentId;
|
|
1394
1394
|
const threadId = options.threadId;
|
|
1395
|
+
const contextOverride = options.contextOverride;
|
|
1395
1396
|
const [state, setState] = useState4("idle");
|
|
1396
1397
|
const [isMuted, setIsMuted] = useState4(false);
|
|
1397
1398
|
const [transcript, setTranscript] = useState4(
|
|
@@ -1661,14 +1662,19 @@ function useVoice(options = {}) {
|
|
|
1661
1662
|
setToolCalls([]);
|
|
1662
1663
|
acceptedTurnSeqRef.current = 0;
|
|
1663
1664
|
setState("connecting");
|
|
1664
|
-
voiceLogger.debug("start() called", {
|
|
1665
|
+
voiceLogger.debug("start() called", {
|
|
1666
|
+
agentId,
|
|
1667
|
+
threadId,
|
|
1668
|
+
hasContextOverride: !!contextOverride
|
|
1669
|
+
});
|
|
1665
1670
|
try {
|
|
1666
1671
|
const res = await fetchWithAuth("/voice/sessions", {
|
|
1667
1672
|
method: "POST",
|
|
1668
1673
|
headers: { "Content-Type": "application/json" },
|
|
1669
1674
|
body: JSON.stringify({
|
|
1670
1675
|
agentId,
|
|
1671
|
-
...threadId ? { threadId } : {}
|
|
1676
|
+
...threadId ? { threadId } : {},
|
|
1677
|
+
...contextOverride ? { contextOverride } : {}
|
|
1672
1678
|
})
|
|
1673
1679
|
});
|
|
1674
1680
|
if (!res.ok) {
|
|
@@ -1704,7 +1710,7 @@ function useVoice(options = {}) {
|
|
|
1704
1710
|
}
|
|
1705
1711
|
teardownAudio();
|
|
1706
1712
|
}
|
|
1707
|
-
}, [agentId, threadId, fetchWithAuth, handleMessage, teardownAudio, voiceLogger]);
|
|
1713
|
+
}, [agentId, threadId, contextOverride, fetchWithAuth, handleMessage, teardownAudio, voiceLogger]);
|
|
1708
1714
|
const mute = useCallback4((muted) => {
|
|
1709
1715
|
setIsMuted(muted);
|
|
1710
1716
|
streamRef.current?.getAudioTracks().forEach((track) => {
|