@pipecat-ai/client-react 1.2.0 → 1.2.1
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.d.ts.map +1 -1
- package/dist/index.js +61 -11
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +61 -11
- package/dist/index.module.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAQA;;;;GAIG;AACH,mCAAmC,CACjC,YAAY,EAAE,gBAAgB,KAC3B,SAAS,CAAC;AAEf;;GAEG;AACH;IACE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH;IACE;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAClC;AAED;;;GAGG;AACH;IACE,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;CACjD;AAED;IACE;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,aAAa,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAClC;AAED;IACE,IA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AE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,iBAAe,CAAC;CAClC;AAED,OAAO,MAAM,iBAAiB,MAAM,EAAE,CAAC,OAAK,CAoR3C,CAAC;ACnRF;;GAEG;AACH;IACE;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC1D;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC1D;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACxD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,MAAM,yBAA0B,+EAKpC,OAAU;;;;;;CA0IZ,CAAC","sources":["client-react/src/src/conversation/types.ts","client-react/src/src/conversation/botOutput.ts","client-react/src/src/conversation/conversationAtoms.ts","client-react/src/src/conversation/utils.ts","client-react/src/src/conversation/conversationActions.ts","client-react/src/src/RTVIEventContext.ts","client-react/src/src/useRTVIClientEvent.ts","client-react/src/src/conversation/useConversationEventWiring.ts","client-react/src/src/conversation/PipecatConversationProvider.tsx","client-react/src/src/PipecatClientState.tsx","client-react/src/src/PipecatClientProvider.tsx","client-react/src/src/usePipecatClient.ts","client-react/src/src/usePipecatClientMediaTrack.ts","client-react/src/src/PipecatClientAudio.tsx","client-react/src/src/usePipecatClientCamControl.ts","client-react/src/src/PipecatClientCamToggle.tsx","client-react/src/src/usePipecatClientMicControl.ts","client-react/src/src/PipecatClientMicToggle.tsx","client-react/src/src/usePipecatClientScreenShareControl.ts","client-react/src/src/PipecatClientScreenShareToggle.tsx","client-react/src/src/useMergedRef.ts","client-react/src/src/PipecatClientVideo.tsx","client-react/src/src/usePipecatClientMediaDevices.ts","client-react/src/src/usePipecatClientTransportState.ts","client-react/src/src/VoiceVisualizer.tsx","client-react/src/src/usePipecatConversation.ts","client-react/src/src/index.ts","client-react/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/**\n * Copyright (c) 2024, Daily.\n *\n * SPDX-License-Identifier: BSD-2-Clause\n */\n\nimport { PipecatClientAudio } from \"./PipecatClientAudio\";\nimport { PipecatClientCamToggle } from \"./PipecatClientCamToggle\";\nimport { PipecatClientMicToggle } from \"./PipecatClientMicToggle\";\nimport { PipecatClientProvider } from \"./PipecatClientProvider\";\nimport { PipecatClientScreenShareToggle } from \"./PipecatClientScreenShareToggle\";\nimport { PipecatClientVideo } from \"./PipecatClientVideo\";\nimport { usePipecatClient } from \"./usePipecatClient\";\nimport { usePipecatClientCamControl } from \"./usePipecatClientCamControl\";\nimport { usePipecatClientMediaDevices } from \"./usePipecatClientMediaDevices\";\nimport { usePipecatClientMediaTrack } from \"./usePipecatClientMediaTrack\";\nimport { usePipecatClientMicControl } from \"./usePipecatClientMicControl\";\nimport { usePipecatClientScreenShareControl } from \"./usePipecatClientScreenShareControl\";\nimport { usePipecatClientTransportState } from \"./usePipecatClientTransportState\";\nimport { useRTVIClientEvent } from \"./useRTVIClientEvent\";\nimport { VoiceVisualizer } from \"./VoiceVisualizer\";\nimport {\n deduplicateFunctionCalls,\n filterEmptyMessages,\n isMessageEmpty,\n mergeMessages,\n sortByCreatedAt,\n} from \"./conversation/conversationActions\";\nimport { useConversationContext } from \"./conversation/PipecatConversationProvider\";\nimport { usePipecatConversation } from \"./usePipecatConversation\";\n\nexport {\n PipecatClientAudio,\n PipecatClientCamToggle,\n PipecatClientMicToggle,\n PipecatClientProvider,\n PipecatClientScreenShareToggle,\n PipecatClientVideo,\n usePipecatClient,\n usePipecatClientCamControl,\n usePipecatClientMediaDevices,\n usePipecatClientMediaTrack,\n usePipecatClientMicControl,\n usePipecatClientScreenShareControl,\n usePipecatClientTransportState,\n useRTVIClientEvent,\n VoiceVisualizer,\n // Conversation\n useConversationContext,\n usePipecatConversation,\n deduplicateFunctionCalls,\n filterEmptyMessages,\n isMessageEmpty,\n mergeMessages,\n sortByCreatedAt,\n};\n\n// Conversation types\nexport type {\n AggregationMetadata,\n BotOutputText,\n ConversationMessage,\n ConversationMessagePart,\n FunctionCallData,\n FunctionCallRenderer,\n} from \"./conversation/types\";\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ $parcel$export(module.exports, "sortByCreatedAt", () => $cbb62fb16c5d45ff$export
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
var $d1f89db81f967f39$exports = {};
|
|
65
|
-
$d1f89db81f967f39$exports = JSON.parse("{\"name\":\"@pipecat-ai/client-react\",\"version\":\"1.2.
|
|
65
|
+
$d1f89db81f967f39$exports = JSON.parse("{\"name\":\"@pipecat-ai/client-react\",\"version\":\"1.2.1\",\"license\":\"BSD-2-Clause\",\"main\":\"dist/index.js\",\"module\":\"dist/index.module.js\",\"types\":\"dist/index.d.ts\",\"source\":\"src/index.ts\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/pipecat-ai/pipecat-client-web.git\"},\"exports\":{\".\":{\"types\":\"./dist/index.d.ts\",\"import\":\"./dist/index.module.js\",\"require\":\"./dist/index.js\"}},\"files\":[\"dist\",\"package.json\",\"README.md\"],\"scripts\":{\"build\":\"parcel build --no-cache\",\"dev\":\"parcel watch\",\"lint\":\"eslint . --report-unused-disable-directives --max-warnings 0 --ignore-pattern 'dist/'\",\"test\":\"jest\"},\"jest\":{\"preset\":\"ts-jest\",\"testEnvironment\":\"jsdom\",\"moduleNameMapper\":{\"^@/(.*)$\":\"<rootDir>/src/$1\"},\"transform\":{\"^.+\\\\.tsx?$\":[\"ts-jest\",{\"tsconfig\":{\"jsx\":\"react-jsx\",\"module\":\"commonjs\",\"moduleResolution\":\"node\",\"esModuleInterop\":true,\"allowImportingTsExtensions\":false,\"noUnusedLocals\":false,\"noUnusedParameters\":false}}]}},\"devDependencies\":{\"@jest/globals\":\"^30.2.0\",\"@pipecat-ai/client-js\":\"*\",\"@types/jest\":\"^30.0.0\",\"@types/react\":\"^18.3.3\",\"@types/react-dom\":\"^18.3.0\",\"@typescript-eslint/eslint-plugin\":\"^8.32.0\",\"eslint\":\"^9.11.1\",\"eslint-config-prettier\":\"^9.1.0\",\"eslint-plugin-react-hooks\":\"^5.2.0\",\"eslint-plugin-simple-import-sort\":\"^12.1.1\",\"jest\":\"^30.2.0\",\"jest-environment-jsdom\":\"^30.2.0\",\"parcel\":\"^2.12.0\",\"react\":\"^18.3.1\",\"react-dom\":\"^18.3.1\",\"ts-jest\":\"^29.4.6\",\"typescript\":\"^5.2.2\"},\"peerDependencies\":{\"@pipecat-ai/client-js\":\"*\",\"react\":\">=18\",\"react-dom\":\">=18\"},\"dependencies\":{\"jotai\":\"^2.9.0\"}}");
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
@@ -77,8 +77,8 @@ $d1f89db81f967f39$exports = JSON.parse("{\"name\":\"@pipecat-ai/client-react\",\
|
|
|
77
77
|
* Copyright (c) 2024, Daily.
|
|
78
78
|
*
|
|
79
79
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
80
|
-
*/ const $ad0c8ea1ee293a79$
|
|
81
|
-
return text.toLowerCase().replace(/[^\
|
|
80
|
+
*/ const $ad0c8ea1ee293a79$export$7d7fdcf7579a70b2 = (text)=>{
|
|
81
|
+
return text.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, "");
|
|
82
82
|
};
|
|
83
83
|
const $ad0c8ea1ee293a79$var$skipWhitespace = (text, start)=>{
|
|
84
84
|
let i = start;
|
|
@@ -102,10 +102,10 @@ const $ad0c8ea1ee293a79$var$skipWhitespace = (text, start)=>{
|
|
|
102
102
|
const remainder = unspoken.slice(actualStart);
|
|
103
103
|
// Sentence-level: if spoken exactly matches the remainder (normalized), consume the whole part
|
|
104
104
|
// so we never leave a word unspoken due to word-matching edge cases.
|
|
105
|
-
if ($ad0c8ea1ee293a79$
|
|
106
|
-
const spokenWords = $ad0c8ea1ee293a79$
|
|
105
|
+
if ($ad0c8ea1ee293a79$export$7d7fdcf7579a70b2(spokenForMatching).trim() === $ad0c8ea1ee293a79$export$7d7fdcf7579a70b2(remainder).trim()) return unspoken.length;
|
|
106
|
+
const spokenWords = $ad0c8ea1ee293a79$export$7d7fdcf7579a70b2(spokenForMatching).split(/\s+/).filter(Boolean);
|
|
107
107
|
if (spokenWords.length === 0) return actualStart;
|
|
108
|
-
const unspokenWords = $ad0c8ea1ee293a79$
|
|
108
|
+
const unspokenWords = $ad0c8ea1ee293a79$export$7d7fdcf7579a70b2(unspoken.slice(actualStart)).split(/\s+/).filter(Boolean);
|
|
109
109
|
// Sequential match, allowing prefix match for contractions (e.g. "I" vs "I'm")
|
|
110
110
|
// and limited skipping of mismatched unspoken words (e.g. punctuation artifacts).
|
|
111
111
|
let matchedWords = 0;
|
|
@@ -125,7 +125,7 @@ const $ad0c8ea1ee293a79$var$skipWhitespace = (text, start)=>{
|
|
|
125
125
|
}
|
|
126
126
|
if (matchedWords < spokenWords.length) return actualStart;
|
|
127
127
|
// Convert word matches back into a character position in the original unspoken string.
|
|
128
|
-
const isWordChar = (char)=>/[
|
|
128
|
+
const isWordChar = (char)=>/[\p{L}\p{N}]/u.test(char);
|
|
129
129
|
let wordCount = 0;
|
|
130
130
|
let i = actualStart;
|
|
131
131
|
let inWord = false;
|
|
@@ -175,6 +175,10 @@ function $ad0c8ea1ee293a79$export$9b39fd8438081d6d(cursor, parts, spokenText) {
|
|
|
175
175
|
if (typeof currentPart.text !== "string") return false;
|
|
176
176
|
const partText = currentPart.text;
|
|
177
177
|
const startChar = cursor.currentCharIndex;
|
|
178
|
+
// If the spoken text is pure punctuation (e.g. an em dash "—"), normalization
|
|
179
|
+
// strips it to empty and word-matching would fail. Treat it as successfully
|
|
180
|
+
// consumed so the cursor stays put and subsequent words continue matching.
|
|
181
|
+
if ($ad0c8ea1ee293a79$export$7d7fdcf7579a70b2(spokenText).trim().length === 0) return true;
|
|
178
182
|
const newPosition = $ad0c8ea1ee293a79$var$findSpokenPositionInUnspoken(spokenText, partText, startChar);
|
|
179
183
|
const whitespaceEnd = $ad0c8ea1ee293a79$var$skipWhitespace(partText, startChar);
|
|
180
184
|
if (newPosition > whitespaceEnd) {
|
|
@@ -270,6 +274,27 @@ function $f4fa178c5adc67bb$export$296de88ccac4bedb(arr, predicate) {
|
|
|
270
274
|
|
|
271
275
|
|
|
272
276
|
/** Max time gap (ms) between consecutive same-role messages for merging. */ const $cbb62fb16c5d45ff$var$MERGE_WINDOW_MS = 30000;
|
|
277
|
+
/**
|
|
278
|
+
* Unicode characters used by `FilterIncompleteTurns` on the server to mark
|
|
279
|
+
* turn completion status. The LLM emits one of these as the very first
|
|
280
|
+
* character of every response:
|
|
281
|
+
*
|
|
282
|
+
* ✓ (U+2713) — complete turn
|
|
283
|
+
* ○ (U+25CB) — incomplete short
|
|
284
|
+
* ◐ (U+25D0) — incomplete long
|
|
285
|
+
*
|
|
286
|
+
* They must be stripped before the text reaches conversation state.
|
|
287
|
+
*/ const $cbb62fb16c5d45ff$var$TURN_COMPLETION_MARKERS = new Set([
|
|
288
|
+
"\u2713",
|
|
289
|
+
"\u25CB",
|
|
290
|
+
"\u25D0"
|
|
291
|
+
]);
|
|
292
|
+
function $cbb62fb16c5d45ff$export$146b18879fa8cfd7(text) {
|
|
293
|
+
if (text.length === 0) return text;
|
|
294
|
+
if ($cbb62fb16c5d45ff$var$TURN_COMPLETION_MARKERS.has(text[0])) // Remove marker and optional single trailing space
|
|
295
|
+
return text[1] === " " ? text.slice(2) : text.slice(1);
|
|
296
|
+
return text;
|
|
297
|
+
}
|
|
273
298
|
const $cbb62fb16c5d45ff$export$cbefc5865f8cbd89 = (a, b)=>{
|
|
274
299
|
return a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : 0;
|
|
275
300
|
};
|
|
@@ -450,16 +475,27 @@ function $cbb62fb16c5d45ff$export$cd74f809c89ea10c(get, set, role) {
|
|
|
450
475
|
}
|
|
451
476
|
function $cbb62fb16c5d45ff$export$c3a007efc2f315a0(get, set, messageData) {
|
|
452
477
|
const now = new Date();
|
|
478
|
+
const current = get((0, $28e6b30207a0392e$export$92a4076839a978d0));
|
|
479
|
+
// If the most recent message is an active (non-final) assistant message,
|
|
480
|
+
// backdate the injected message so it sorts before the assistant's createdAt.
|
|
481
|
+
// This prevents the injected message from splitting the bot's response across
|
|
482
|
+
// two bubbles and breaking the karaoke cursor.
|
|
483
|
+
const lastMessage = current[current.length - 1];
|
|
484
|
+
const lastAssistant = lastMessage?.role === "assistant" ? lastMessage : undefined;
|
|
485
|
+
let timestamp;
|
|
486
|
+
if (lastAssistant && lastAssistant.final === false && messageData.role === "system") {
|
|
487
|
+
const assistantTime = new Date(lastAssistant.createdAt);
|
|
488
|
+
timestamp = new Date(assistantTime.getTime() - 1).toISOString();
|
|
489
|
+
} else timestamp = now.toISOString();
|
|
453
490
|
const message = {
|
|
454
491
|
role: messageData.role,
|
|
455
492
|
final: true,
|
|
456
493
|
parts: [
|
|
457
494
|
...messageData.parts
|
|
458
495
|
],
|
|
459
|
-
createdAt:
|
|
496
|
+
createdAt: timestamp,
|
|
460
497
|
updatedAt: now.toISOString()
|
|
461
498
|
};
|
|
462
|
-
const current = get((0, $28e6b30207a0392e$export$92a4076839a978d0));
|
|
463
499
|
const updatedMessages = [
|
|
464
500
|
...current,
|
|
465
501
|
message
|
|
@@ -530,6 +566,10 @@ function $cbb62fb16c5d45ff$export$57de01211e3df548(get, set, text, final) {
|
|
|
530
566
|
set((0, $28e6b30207a0392e$export$92a4076839a978d0), processedMessages);
|
|
531
567
|
}
|
|
532
568
|
function $cbb62fb16c5d45ff$export$d78810e35f742a16(get, set, text, final, spoken, aggregatedBy) {
|
|
569
|
+
// Strip turn-completion markers emitted by FilterIncompleteTurns before
|
|
570
|
+
// the text enters conversation state.
|
|
571
|
+
text = $cbb62fb16c5d45ff$export$146b18879fa8cfd7(text);
|
|
572
|
+
if (text.length === 0) return;
|
|
533
573
|
const now = new Date();
|
|
534
574
|
const messages = [
|
|
535
575
|
...get((0, $28e6b30207a0392e$export$92a4076839a978d0))
|
|
@@ -653,11 +693,21 @@ function $cbb62fb16c5d45ff$export$e450805545c7dd86(get, set, data) {
|
|
|
653
693
|
if (existingIndex !== -1) return;
|
|
654
694
|
}
|
|
655
695
|
const now = new Date();
|
|
696
|
+
// If the most recent message is an active (non-final) assistant message,
|
|
697
|
+
// backdate the function call so it sorts before the assistant's createdAt.
|
|
698
|
+
// This prevents the function call from splitting the bot's response across
|
|
699
|
+
// two bubbles and breaking the karaoke cursor.
|
|
700
|
+
const lastMessage = messages[messages.length - 1];
|
|
701
|
+
let timestamp;
|
|
702
|
+
if (lastMessage?.role === "assistant" && lastMessage.final === false) {
|
|
703
|
+
const assistantTime = new Date(lastMessage.createdAt);
|
|
704
|
+
timestamp = new Date(assistantTime.getTime() - 1).toISOString();
|
|
705
|
+
} else timestamp = now.toISOString();
|
|
656
706
|
const message = {
|
|
657
707
|
role: "function_call",
|
|
658
708
|
final: false,
|
|
659
709
|
parts: [],
|
|
660
|
-
createdAt:
|
|
710
|
+
createdAt: timestamp,
|
|
661
711
|
updatedAt: now.toISOString(),
|
|
662
712
|
functionCall: {
|
|
663
713
|
function_name: data.function_name,
|
|
@@ -721,7 +771,7 @@ function $cbb62fb16c5d45ff$export$809efdca1a10761a(get, set, data) {
|
|
|
721
771
|
const messages = get((0, $28e6b30207a0392e$export$92a4076839a978d0));
|
|
722
772
|
const lastFc = (0, $f4fa178c5adc67bb$export$296de88ccac4bedb)(messages, (m)=>m.role === "function_call");
|
|
723
773
|
// Check if InProgress already created an entry (events arrived out of order).
|
|
724
|
-
if (lastFc?.functionCall && lastFc.functionCall.status !== "started" && Date.now() - new Date(lastFc.createdAt).getTime() < 2000) {
|
|
774
|
+
if (lastFc?.functionCall && lastFc.functionCall.status !== "started" && Date.now() - new Date(lastFc.updatedAt ?? lastFc.createdAt).getTime() < 2000) {
|
|
725
775
|
if (data.function_name && !lastFc.functionCall.function_name && lastFc.functionCall.tool_call_id) $cbb62fb16c5d45ff$export$1908264de3a8afe4(get, set, lastFc.functionCall.tool_call_id, {
|
|
726
776
|
function_name: data.function_name
|
|
727
777
|
});
|