@wix/legends-platform-sdk 1.23.0 → 1.25.0
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/README.md +21 -3
- package/dist/cjs/hooks/useClientContext/index.js +10 -0
- package/dist/cjs/hooks/useClientContext/index.js.map +1 -0
- package/dist/cjs/hooks/useClientContext/useClientContext.js +36 -0
- package/dist/cjs/hooks/useClientContext/useClientContext.js.map +1 -0
- package/dist/cjs/hooks/useConversation/livekit/constants.js +3 -1
- package/dist/cjs/hooks/useConversation/livekit/constants.js.map +1 -1
- package/dist/cjs/hooks/useConversation/livekit/types.js.map +1 -1
- package/dist/cjs/hooks/useConversation/livekit/useConversation.js +34 -6
- package/dist/cjs/hooks/useConversation/livekit/useConversation.js.map +1 -1
- package/dist/cjs/hooks/useConversation/livekit/utils/dataChannel.js +0 -4
- package/dist/cjs/hooks/useConversation/livekit/utils/dataChannel.js.map +1 -1
- package/dist/cjs/hooks/useConversation/livekit/utils/index.js +10 -4
- package/dist/cjs/hooks/useConversation/livekit/utils/index.js.map +1 -1
- package/dist/cjs/hooks/useConversation/livekit/utils/rpc.js +16 -0
- package/dist/cjs/hooks/useConversation/livekit/utils/rpc.js.map +1 -0
- package/dist/cjs/hooks/useConversation/livekit/utils/toolDefinitions.js +22 -0
- package/dist/cjs/hooks/useConversation/livekit/utils/toolDefinitions.js.map +1 -0
- package/dist/cjs/hooks/useTools/index.js.map +1 -1
- package/dist/cjs/hooks/useTools/model/types.js.map +1 -1
- package/dist/cjs/hooks/useTools/runtime/executeToolCall.js +2 -1
- package/dist/cjs/hooks/useTools/runtime/executeToolCall.js.map +1 -1
- package/dist/cjs/hooks/useTools/runtime/useToolCallingRuntime.js +10 -1
- package/dist/cjs/hooks/useTools/runtime/useToolCallingRuntime.js.map +1 -1
- package/dist/cjs/livekit/sdk.js +6 -0
- package/dist/cjs/livekit/sdk.js.map +1 -1
- package/dist/esm/hooks/useClientContext/index.js +2 -0
- package/dist/esm/hooks/useClientContext/index.js.map +1 -0
- package/dist/esm/hooks/useClientContext/useClientContext.js +38 -0
- package/dist/esm/hooks/useClientContext/useClientContext.js.map +1 -0
- package/dist/esm/hooks/useConversation/livekit/constants.js +2 -0
- package/dist/esm/hooks/useConversation/livekit/constants.js.map +1 -1
- package/dist/esm/hooks/useConversation/livekit/types.js.map +1 -1
- package/dist/esm/hooks/useConversation/livekit/useConversation.js +37 -8
- package/dist/esm/hooks/useConversation/livekit/useConversation.js.map +1 -1
- package/dist/esm/hooks/useConversation/livekit/utils/dataChannel.js +0 -3
- package/dist/esm/hooks/useConversation/livekit/utils/dataChannel.js.map +1 -1
- package/dist/esm/hooks/useConversation/livekit/utils/index.js +2 -1
- package/dist/esm/hooks/useConversation/livekit/utils/index.js.map +1 -1
- package/dist/esm/hooks/useConversation/livekit/utils/rpc.js +12 -0
- package/dist/esm/hooks/useConversation/livekit/utils/rpc.js.map +1 -0
- package/dist/esm/hooks/useConversation/livekit/utils/toolDefinitions.js +20 -0
- package/dist/esm/hooks/useConversation/livekit/utils/toolDefinitions.js.map +1 -0
- package/dist/esm/hooks/useTools/index.js.map +1 -1
- package/dist/esm/hooks/useTools/model/types.js.map +1 -1
- package/dist/esm/hooks/useTools/runtime/executeToolCall.js +2 -1
- package/dist/esm/hooks/useTools/runtime/executeToolCall.js.map +1 -1
- package/dist/esm/hooks/useTools/runtime/useToolCallingRuntime.js +10 -1
- package/dist/esm/hooks/useTools/runtime/useToolCallingRuntime.js.map +1 -1
- package/dist/esm/livekit/sdk.js +1 -0
- package/dist/esm/livekit/sdk.js.map +1 -1
- package/dist/types/hooks/useClientContext/index.d.ts +2 -0
- package/dist/types/hooks/useClientContext/index.d.ts.map +1 -0
- package/dist/types/hooks/useClientContext/useClientContext.d.ts +17 -0
- package/dist/types/hooks/useClientContext/useClientContext.d.ts.map +1 -0
- package/dist/types/hooks/useConversation/livekit/constants.d.ts +2 -0
- package/dist/types/hooks/useConversation/livekit/constants.d.ts.map +1 -1
- package/dist/types/hooks/useConversation/livekit/types.d.ts +4 -14
- package/dist/types/hooks/useConversation/livekit/types.d.ts.map +1 -1
- package/dist/types/hooks/useConversation/livekit/useConversation.d.ts.map +1 -1
- package/dist/types/hooks/useConversation/livekit/utils/dataChannel.d.ts +1 -2
- package/dist/types/hooks/useConversation/livekit/utils/dataChannel.d.ts.map +1 -1
- package/dist/types/hooks/useConversation/livekit/utils/index.d.ts +2 -1
- package/dist/types/hooks/useConversation/livekit/utils/index.d.ts.map +1 -1
- package/dist/types/hooks/useConversation/livekit/utils/rpc.d.ts +3 -0
- package/dist/types/hooks/useConversation/livekit/utils/rpc.d.ts.map +1 -0
- package/dist/types/hooks/useConversation/livekit/utils/toolDefinitions.d.ts +4 -0
- package/dist/types/hooks/useConversation/livekit/utils/toolDefinitions.d.ts.map +1 -0
- package/dist/types/hooks/useTools/index.d.ts +1 -1
- package/dist/types/hooks/useTools/index.d.ts.map +1 -1
- package/dist/types/hooks/useTools/model/types.d.ts +6 -1
- package/dist/types/hooks/useTools/model/types.d.ts.map +1 -1
- package/dist/types/hooks/useTools/runtime/executeToolCall.d.ts.map +1 -1
- package/dist/types/hooks/useTools/runtime/useToolCallingRuntime.d.ts +1 -0
- package/dist/types/hooks/useTools/runtime/useToolCallingRuntime.d.ts.map +1 -1
- package/dist/types/livekit/sdk.d.ts +1 -0
- package/dist/types/livekit/sdk.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/hooks/useConversation/livekit/utils/toolAdapter.js +0 -18
- package/dist/cjs/hooks/useConversation/livekit/utils/toolAdapter.js.map +0 -1
- package/dist/esm/hooks/useConversation/livekit/utils/toolAdapter.js +0 -14
- package/dist/esm/hooks/useConversation/livekit/utils/toolAdapter.js.map +0 -1
- package/dist/types/hooks/useConversation/livekit/utils/toolAdapter.d.ts +0 -4
- package/dist/types/hooks/useConversation/livekit/utils/toolAdapter.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -174,9 +174,21 @@ Observe client-side tool calls executed by the SDK. Register tool handlers by pa
|
|
|
174
174
|
import { LegendsPlatform, useTools, type ToolsRegistry } from '@wix/legends-platform-sdk/livekit/sdk';
|
|
175
175
|
|
|
176
176
|
const tools: ToolsRegistry = {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
fill_input: {
|
|
178
|
+
description:
|
|
179
|
+
'Fill a form field on the current page with a value the user provided. Use when the user asks to enter, type or set a value in a field. Returns a confirmation.',
|
|
180
|
+
parameters: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {
|
|
183
|
+
fieldId: { type: 'string', description: 'The id of the input to fill, e.g. "email"' },
|
|
184
|
+
value: { type: 'string', description: 'The exact value to enter' },
|
|
185
|
+
},
|
|
186
|
+
required: ['fieldId', 'value'],
|
|
187
|
+
},
|
|
188
|
+
handler: ({ fieldId, value }) => {
|
|
189
|
+
setFormValue(fieldId as string, value as string);
|
|
190
|
+
return `Filled ${fieldId} with ${value}`; // returned to the LLM as the tool result
|
|
191
|
+
},
|
|
180
192
|
},
|
|
181
193
|
};
|
|
182
194
|
|
|
@@ -195,6 +207,12 @@ function ToolLog() {
|
|
|
195
207
|
</LegendsPlatform>
|
|
196
208
|
```
|
|
197
209
|
|
|
210
|
+
Frontend-defined tools are currently offered to the agent in LiveKit voice and video calls only. The SDK does not yet send tool definitions in text-chat requests. Text chat can execute registered handlers for tools configured on the backend, but registering a tool here does not make it available to the text-chat LLM.
|
|
211
|
+
|
|
212
|
+
During a voice or video call the SDK registers two LiveKit RPC methods on the room: the agent calls `get_tools` when the user joins to receive the definitions, and `execute_tool` with `{ functionCallId, name, arguments }` for each call. The SDK runs the handler and replies with `{ functionCallId, result, error }`.
|
|
213
|
+
|
|
214
|
+
A bare function is still accepted as a registry value for backwards compatibility. It runs when the backend requests it by name, but it has no schema so it is not sent to the agent.
|
|
215
|
+
|
|
198
216
|
#### `useSpeechActivityDetector(options)`
|
|
199
217
|
|
|
200
218
|
Acoustic speech onset/offset detector driven by `AudioWorkletNode`. Useful for measuring end-to-end latency or building custom VAD UI.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var _useClientContext = require("./useClientContext");
|
|
5
|
+
Object.keys(_useClientContext).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _useClientContext[key]) return;
|
|
8
|
+
exports[key] = _useClientContext[key];
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_useClientContext","require","Object","keys","forEach","key","exports"],"sources":["../../../../src/hooks/useClientContext/index.ts"],"sourcesContent":["export * from './useClientContext';\n"],"mappings":";;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,iBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,iBAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,iBAAA,CAAAK,GAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useClientContext = useClientContext;
|
|
5
|
+
var _react = require("react");
|
|
6
|
+
var _livekitClient = require("livekit-client");
|
|
7
|
+
var _componentsReact = require("@livekit/components-react");
|
|
8
|
+
const LIVEKIT_INTERNAL_ATTR_PREFIX = 'lk.';
|
|
9
|
+
/**
|
|
10
|
+
* Reads and updates client context stored in LiveKit local participant attributes.
|
|
11
|
+
* Must be used within a LiveKit room context.
|
|
12
|
+
*/
|
|
13
|
+
function useClientContext() {
|
|
14
|
+
const room = (0, _componentsReact.useEnsureRoom)();
|
|
15
|
+
const [context, setContext] = (0, _react.useState)({});
|
|
16
|
+
(0, _react.useEffect)(() => {
|
|
17
|
+
const readAttributes = () => {
|
|
18
|
+
setContext(Object.fromEntries(Object.entries(room.localParticipant.attributes ?? {}).filter(([key, value]) => value && !key.startsWith(LIVEKIT_INTERNAL_ATTR_PREFIX))));
|
|
19
|
+
};
|
|
20
|
+
readAttributes();
|
|
21
|
+
room.localParticipant.on(_livekitClient.ParticipantEvent.AttributesChanged, readAttributes);
|
|
22
|
+
return () => {
|
|
23
|
+
room.localParticipant.off(_livekitClient.ParticipantEvent.AttributesChanged, readAttributes);
|
|
24
|
+
};
|
|
25
|
+
}, [room]);
|
|
26
|
+
const updateContext = (0, _react.useCallback)(async attributes => {
|
|
27
|
+
await room.localParticipant.setAttributes(attributes);
|
|
28
|
+
}, [room]);
|
|
29
|
+
const removeContext = (0, _react.useCallback)(keys => updateContext(Object.fromEntries(keys.map(key => [key, '']))), [updateContext]);
|
|
30
|
+
return {
|
|
31
|
+
context,
|
|
32
|
+
updateContext,
|
|
33
|
+
removeContext
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useClientContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_livekitClient","_componentsReact","LIVEKIT_INTERNAL_ATTR_PREFIX","useClientContext","room","useEnsureRoom","context","setContext","useState","useEffect","readAttributes","Object","fromEntries","entries","localParticipant","attributes","filter","key","value","startsWith","on","ParticipantEvent","AttributesChanged","off","updateContext","useCallback","setAttributes","removeContext","keys","map"],"sources":["../../../../src/hooks/useClientContext/useClientContext.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { ParticipantEvent } from 'livekit-client';\nimport { useEnsureRoom } from '@livekit/components-react';\n\nconst LIVEKIT_INTERNAL_ATTR_PREFIX = 'lk.';\n\nexport type UseClientContextResult = {\n /** Local participant attributes, excluding empty values and `lk.*` keys. */\n context: Record<string, string>;\n /**\n * Merges string values into the participant attributes; empty strings delete keys.\n * Requires `canUpdateOwnMetadata` permission. Update failures reject the promise.\n */\n updateContext(attributes: Record<string, string>): Promise<void>;\n /** Deletes keys. Requires `canUpdateOwnMetadata` permission and rejects on failure. */\n removeContext(keys: string[]): Promise<void>;\n};\n\n/**\n * Reads and updates client context stored in LiveKit local participant attributes.\n * Must be used within a LiveKit room context.\n */\nexport function useClientContext(): UseClientContextResult {\n const room = useEnsureRoom();\n const [context, setContext] = useState<Record<string, string>>({});\n\n useEffect(() => {\n const readAttributes = () => {\n setContext(\n Object.fromEntries(\n Object.entries(room.localParticipant.attributes ?? {}).filter(\n ([key, value]) =>\n value && !key.startsWith(LIVEKIT_INTERNAL_ATTR_PREFIX),\n ),\n ),\n );\n };\n\n readAttributes();\n\n room.localParticipant.on(\n ParticipantEvent.AttributesChanged,\n readAttributes,\n );\n return () => {\n room.localParticipant.off(\n ParticipantEvent.AttributesChanged,\n readAttributes,\n );\n };\n }, [room]);\n\n const updateContext = useCallback(\n async (attributes: Record<string, string>) => {\n await room.localParticipant.setAttributes(attributes);\n },\n [room],\n );\n\n const removeContext = useCallback(\n (keys: string[]) =>\n updateContext(Object.fromEntries(keys.map((key) => [key, '']))),\n [updateContext],\n );\n\n return {\n context,\n updateContext,\n removeContext,\n };\n}\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,MAAMG,4BAA4B,GAAG,KAAK;AAc1C;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAA,EAA2B;EACzD,MAAMC,IAAI,GAAG,IAAAC,8BAAa,EAAC,CAAC;EAC5B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAAyB,CAAC,CAAC,CAAC;EAElE,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,cAAc,GAAGA,CAAA,KAAM;MAC3BH,UAAU,CACRI,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACT,IAAI,CAACU,gBAAgB,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CAC3D,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KACXA,KAAK,IAAI,CAACD,GAAG,CAACE,UAAU,CAACjB,4BAA4B,CACzD,CACF,CACF,CAAC;IACH,CAAC;IAEDQ,cAAc,CAAC,CAAC;IAEhBN,IAAI,CAACU,gBAAgB,CAACM,EAAE,CACtBC,+BAAgB,CAACC,iBAAiB,EAClCZ,cACF,CAAC;IACD,OAAO,MAAM;MACXN,IAAI,CAACU,gBAAgB,CAACS,GAAG,CACvBF,+BAAgB,CAACC,iBAAiB,EAClCZ,cACF,CAAC;IACH,CAAC;EACH,CAAC,EAAE,CAACN,IAAI,CAAC,CAAC;EAEV,MAAMoB,aAAa,GAAG,IAAAC,kBAAW,EAC/B,MAAOV,UAAkC,IAAK;IAC5C,MAAMX,IAAI,CAACU,gBAAgB,CAACY,aAAa,CAACX,UAAU,CAAC;EACvD,CAAC,EACD,CAACX,IAAI,CACP,CAAC;EAED,MAAMuB,aAAa,GAAG,IAAAF,kBAAW,EAC9BG,IAAc,IACbJ,aAAa,CAACb,MAAM,CAACC,WAAW,CAACgB,IAAI,CAACC,GAAG,CAAEZ,GAAG,IAAK,CAACA,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACjE,CAACO,aAAa,CAChB,CAAC;EAED,OAAO;IACLlB,OAAO;IACPkB,aAAa;IACbG;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.SPEAKING_STATE_EVENT_MAP = exports.ACOUSTIC_USER_THRESHOLD_RMS = exports.ACOUSTIC_USER_HANGOVER_MS = exports.ACOUSTIC_AGENT_HANGOVER_MS = void 0;
|
|
4
|
+
exports.SPEAKING_STATE_EVENT_MAP = exports.GET_TOOLS_RPC_METHOD = exports.EXECUTE_TOOL_RPC_METHOD = exports.ACOUSTIC_USER_THRESHOLD_RMS = exports.ACOUSTIC_USER_HANGOVER_MS = exports.ACOUSTIC_AGENT_HANGOVER_MS = void 0;
|
|
5
5
|
const SPEAKING_STATE_EVENT_MAP = exports.SPEAKING_STATE_EVENT_MAP = {
|
|
6
6
|
STANDARD: {
|
|
7
7
|
speaking: 'userSpeakStart',
|
|
@@ -15,4 +15,6 @@ const SPEAKING_STATE_EVENT_MAP = exports.SPEAKING_STATE_EVENT_MAP = {
|
|
|
15
15
|
const ACOUSTIC_USER_THRESHOLD_RMS = exports.ACOUSTIC_USER_THRESHOLD_RMS = 0.025;
|
|
16
16
|
const ACOUSTIC_USER_HANGOVER_MS = exports.ACOUSTIC_USER_HANGOVER_MS = 400;
|
|
17
17
|
const ACOUSTIC_AGENT_HANGOVER_MS = exports.ACOUSTIC_AGENT_HANGOVER_MS = 900;
|
|
18
|
+
const GET_TOOLS_RPC_METHOD = exports.GET_TOOLS_RPC_METHOD = 'get_tools';
|
|
19
|
+
const EXECUTE_TOOL_RPC_METHOD = exports.EXECUTE_TOOL_RPC_METHOD = 'execute_tool';
|
|
18
20
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SPEAKING_STATE_EVENT_MAP","exports","STANDARD","speaking","listening","AGENT","ACOUSTIC_USER_THRESHOLD_RMS","ACOUSTIC_USER_HANGOVER_MS","ACOUSTIC_AGENT_HANGOVER_MS"],"sources":["../../../../../src/hooks/useConversation/livekit/constants.ts"],"sourcesContent":["import type { TurnDetectionData } from './types';\nimport type { ConversationEvent } from '../../useConversationEvents';\n\nexport const SPEAKING_STATE_EVENT_MAP: Record<\n TurnDetectionData['participantKind'],\n Record<TurnDetectionData['state'], ConversationEvent>\n> = {\n STANDARD: {\n speaking: 'userSpeakStart',\n listening: 'userSpeakStop',\n },\n AGENT: {\n speaking: 'agentSpeakStart',\n listening: 'agentSpeakStop',\n },\n};\n\nexport const ACOUSTIC_USER_THRESHOLD_RMS = 0.025;\nexport const ACOUSTIC_USER_HANGOVER_MS = 400;\nexport const ACOUSTIC_AGENT_HANGOVER_MS = 900;\n"],"mappings":";;;;AAGO,MAAMA,wBAGZ,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACFE,QAAQ,EAAE;IACRC,QAAQ,EAAE,gBAAgB;IAC1BC,SAAS,EAAE;EACb,CAAC;EACDC,KAAK,EAAE;IACLF,QAAQ,EAAE,iBAAiB;IAC3BC,SAAS,EAAE;EACb;AACF,CAAC;AAEM,MAAME,2BAA2B,GAAAL,OAAA,CAAAK,2BAAA,GAAG,KAAK;AACzC,MAAMC,yBAAyB,GAAAN,OAAA,CAAAM,yBAAA,GAAG,GAAG;AACrC,MAAMC,0BAA0B,GAAAP,OAAA,CAAAO,0BAAA,GAAG,GAAG","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["SPEAKING_STATE_EVENT_MAP","exports","STANDARD","speaking","listening","AGENT","ACOUSTIC_USER_THRESHOLD_RMS","ACOUSTIC_USER_HANGOVER_MS","ACOUSTIC_AGENT_HANGOVER_MS","GET_TOOLS_RPC_METHOD","EXECUTE_TOOL_RPC_METHOD"],"sources":["../../../../../src/hooks/useConversation/livekit/constants.ts"],"sourcesContent":["import type { TurnDetectionData } from './types';\nimport type { ConversationEvent } from '../../useConversationEvents';\n\nexport const SPEAKING_STATE_EVENT_MAP: Record<\n TurnDetectionData['participantKind'],\n Record<TurnDetectionData['state'], ConversationEvent>\n> = {\n STANDARD: {\n speaking: 'userSpeakStart',\n listening: 'userSpeakStop',\n },\n AGENT: {\n speaking: 'agentSpeakStart',\n listening: 'agentSpeakStop',\n },\n};\n\nexport const ACOUSTIC_USER_THRESHOLD_RMS = 0.025;\nexport const ACOUSTIC_USER_HANGOVER_MS = 400;\nexport const ACOUSTIC_AGENT_HANGOVER_MS = 900;\n\nexport const GET_TOOLS_RPC_METHOD = 'get_tools';\nexport const EXECUTE_TOOL_RPC_METHOD = 'execute_tool';\n"],"mappings":";;;;AAGO,MAAMA,wBAGZ,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACFE,QAAQ,EAAE;IACRC,QAAQ,EAAE,gBAAgB;IAC1BC,SAAS,EAAE;EACb,CAAC;EACDC,KAAK,EAAE;IACLF,QAAQ,EAAE,iBAAiB;IAC3BC,SAAS,EAAE;EACb;AACF,CAAC;AAEM,MAAME,2BAA2B,GAAAL,OAAA,CAAAK,2BAAA,GAAG,KAAK;AACzC,MAAMC,yBAAyB,GAAAN,OAAA,CAAAM,yBAAA,GAAG,GAAG;AACrC,MAAMC,0BAA0B,GAAAP,OAAA,CAAAO,0BAAA,GAAG,GAAG;AAEtC,MAAMC,oBAAoB,GAAAR,OAAA,CAAAQ,oBAAA,GAAG,WAAW;AACxC,MAAMC,uBAAuB,GAAAT,OAAA,CAAAS,uBAAA,GAAG,cAAc","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../../src/hooks/useConversation/livekit/types.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../../src/hooks/useConversation/livekit/types.ts"],"sourcesContent":["export type InactivityWarningData = {\n type: 'inactivity_warning';\n grace_period_sec: number;\n};\n\nexport type InactivityTimeoutData = {\n type: 'inactivity_timeout';\n};\n\nexport type TurnDetectionData = {\n createdAt: number;\n participantIdentity: string;\n sequence: number;\n source: string;\n state: 'listening' | 'speaking';\n turnDetectionStrategy: 'livekit_turn_detector' | 'silero_vad';\n type: string;\n version: number;\n participantKind: 'STANDARD' | 'AGENT';\n speechId?: string;\n};\n\nexport type ClientToolDefinition = {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -11,11 +11,13 @@ var _reactUse = require("react-use");
|
|
|
11
11
|
var _componentsReact = require("@livekit/components-react");
|
|
12
12
|
var _jotai = require("jotai");
|
|
13
13
|
var _conversation = require("../../../conversation");
|
|
14
|
+
var _sdkConsumer = require("../../../sdk-consumer");
|
|
14
15
|
var _useCreateConversation = require("../../useCreateConversation");
|
|
15
16
|
var _useSpeechActivityDetector = require("../../useSpeechActivityDetector");
|
|
16
17
|
var _useParticipantTrack = require("../../useParticipantTrack");
|
|
17
18
|
var _useEmitConversationEvent = require("../../useConversationEvents/useEmitConversationEvent");
|
|
18
19
|
var _useToolCallingRuntime = require("../../useTools/runtime/useToolCallingRuntime");
|
|
20
|
+
var _serialize = require("../../useTools/utils/serialize");
|
|
19
21
|
var _utils = require("./utils");
|
|
20
22
|
var _constants = require("./constants");
|
|
21
23
|
function useConversation({
|
|
@@ -39,8 +41,11 @@ function useConversation({
|
|
|
39
41
|
const speaker = (0, _jotai.useAtomValue)(_conversation.state.speaker);
|
|
40
42
|
const [microphone, setMicrophone] = (0, _jotai.useAtom)(_conversation.state.microphone);
|
|
41
43
|
const [camera, setCamera] = (0, _jotai.useAtom)(_conversation.state.camera);
|
|
44
|
+
const {
|
|
45
|
+
tools: toolsRegistry = {}
|
|
46
|
+
} = (0, _sdkConsumer.useSdkConsumer)();
|
|
42
47
|
const toolRuntime = (0, _useToolCallingRuntime.useToolCallingRuntime)();
|
|
43
|
-
const
|
|
48
|
+
const toolsRegistryRef = (0, _reactUse.useLatest)(toolsRegistry);
|
|
44
49
|
|
|
45
50
|
// for use in register/unregister room events
|
|
46
51
|
const conversationRef = (0, _reactUse.useLatest)(conversation.data);
|
|
@@ -301,13 +306,30 @@ function useConversation({
|
|
|
301
306
|
conversationId: (_conversationRef$curr5 = conversationRef.current) == null ? void 0 : _conversationRef$curr5.id
|
|
302
307
|
});
|
|
303
308
|
}
|
|
304
|
-
async function
|
|
305
|
-
|
|
309
|
+
async function handleGetToolsRpc() {
|
|
310
|
+
return JSON.stringify((0, _utils.buildToolDefinitions)(toolsRegistryRef.current));
|
|
311
|
+
}
|
|
312
|
+
async function handleExecuteToolRpc(data) {
|
|
313
|
+
const call = (0, _utils.parseFunctionCallPayload)(data.payload);
|
|
314
|
+
if (!call) {
|
|
315
|
+
return JSON.stringify({
|
|
316
|
+
functionCallId: '',
|
|
317
|
+
result: '',
|
|
318
|
+
error: 'Malformed function call payload.'
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const [result] = await toolRuntimeRef.current.executeToolCalls([call]);
|
|
323
|
+
return JSON.stringify(result);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
return JSON.stringify({
|
|
326
|
+
functionCallId: call.functionCallId,
|
|
327
|
+
result: '',
|
|
328
|
+
error: (0, _serialize.extractToolErrorMessage)(error)
|
|
329
|
+
});
|
|
330
|
+
}
|
|
306
331
|
}
|
|
307
332
|
const dataChannelHandlers = [{
|
|
308
|
-
guard: _utils.checkIsToolCallsData,
|
|
309
|
-
handle: handleToolCallsEvent
|
|
310
|
-
}, {
|
|
311
333
|
guard: _utils.checkIsTurnDetectionData,
|
|
312
334
|
handle: handleTurnDetectionEvent
|
|
313
335
|
}, {
|
|
@@ -450,8 +472,14 @@ function useConversation({
|
|
|
450
472
|
}
|
|
451
473
|
function registerRoomEvents() {
|
|
452
474
|
room.on('connected', handleConnectedEvent).on('encryptionError', handleEncryptionErrorEvent).on('disconnected', handleDisconnectedEvent).on('transcriptionReceived', handleTranscriptionReceivedEvent).on('participantConnected', handleParticipantConnectedEvent).on('participantDisconnected', handleParticipantDisconnectedEvent).on('dataReceived', handleDataReceivedEvent);
|
|
475
|
+
room.unregisterRpcMethod(_constants.GET_TOOLS_RPC_METHOD);
|
|
476
|
+
room.unregisterRpcMethod(_constants.EXECUTE_TOOL_RPC_METHOD);
|
|
477
|
+
room.registerRpcMethod(_constants.GET_TOOLS_RPC_METHOD, handleGetToolsRpc);
|
|
478
|
+
room.registerRpcMethod(_constants.EXECUTE_TOOL_RPC_METHOD, handleExecuteToolRpc);
|
|
453
479
|
}
|
|
454
480
|
function unregisterRoomEvents() {
|
|
481
|
+
room.unregisterRpcMethod(_constants.GET_TOOLS_RPC_METHOD);
|
|
482
|
+
room.unregisterRpcMethod(_constants.EXECUTE_TOOL_RPC_METHOD);
|
|
455
483
|
room.off('connected', handleConnectedEvent);
|
|
456
484
|
room.off('encryptionError', handleEncryptionErrorEvent);
|
|
457
485
|
room.off('disconnected', handleDisconnectedEvent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_livekitClient","_invariant","_interopRequireDefault","_reactTimerHook","_reactUse","_componentsReact","_jotai","_conversation","_useCreateConversation","_useSpeechActivityDetector","_useParticipantTrack","_useEmitConversationEvent","_useToolCallingRuntime","_utils","_constants","useConversation","autoJoin","type","config","startWithMicrophone","startWithCamera","firstConversation","lastConversationTopic","_conversation$data2","setLogLevel","LogLevel","silent","conversation","useCreateConversation","room","useEnsureRoom","speaker","useAtomValue","state","microphone","setMicrophone","useAtom","camera","setCamera","toolRuntime","useToolCallingRuntime","toolAdapter","createLivekitToolAdapter","conversationRef","useLatest","data","toolRuntimeRef","conversationStatus","setConversationStatus","userConnectionState","setUserConnectionState","joinedAt","setJoinedAt","setActiveMediaDevice","setMicrophoneDeviceId","useMediaDeviceSelect","kind","setSpeakerDeviceId","setCameraDeviceId","requestPermissions","enabled","setTranscriptions","useSetAtom","transcriptions","agentConnectionState","setAgentConnectionState","setAgentActivityState","agentActivityState","setUserActivityState","userActivityState","emitEvent","useEmitConversationEvent","inactivityTimeoutRef","useRef","acousticPhaseRef","acousticT0Ref","latestTurnMetadataRef","isConnectedRef","userCumulativeTrackStatsRef","undefined","agentCumulativeTrackStatsRef","userMicPublication","useParticipantTrack","source","Source","Microphone","agentMicPublication","timer","useTimer","autoStart","onExpire","handleExpire","expiryTimestamp","Date","useEffect","registerRoomEvents","unregisterRoomEvents","useUpdateEffect","deviceId","localParticipant","setMicrophoneEnabled","setCameraEnabled","resolution","width","height","join","_conversation$data","limit","restart","getTime","_conversation$data3","invariant","url","URL","accessToken","searchParams","get","connect","remoteParticipant","findJoinedAgentParticipant","handleAgentJoin","enableMediaDevices","error","console","handleTranscriptionReceivedEvent","segments","participant","map","s","id","message","text","ParticipantKind","AGENT","old","mergeTranscriptions","handleTurnDetectionEvent","_conversationRef$curr","conversationId","current","participantKind","eventState","turnDetectionStrategy","sequence","speechId","handleAcousticUserOnset","handleAcousticUserOffset","timestampMs","ACOUSTIC_USER_HANGOVER_MS","handleAcousticAgentOnset","_conversationRef$curr2","latencyMs","emitConversationTurnLatency","clientAcousticLatencyMs","_conversationRef$curr3","userReport","agentReport","Promise","all","getTrackStats","userStats","parseTrackStats","agentStats","cumulativeTrackStats","rttMs","roundTripTimeMs","jitterBufferDelayMs","userPacketsLost","packetsLost","agentPacketsLost","handleAcousticAgentOffset","useSpeechActivityDetector","onSpeechStart","onSpeechEnd","thresholdRms","ACOUSTIC_USER_THRESHOLD_RMS","hangoverMs","ACOUSTIC_AGENT_HANGOVER_MS","handleInactivityWarningEvent","_conversationRef$curr4","gracePeriodSec","grace_period_sec","handleInactivityTimeoutEvent","_data","_conversationRef$curr5","handleToolCallsEvent","resolveIncomingToolCalls","dataChannelHandlers","guard","checkIsToolCallsData","handle","checkIsTurnDetectionData","checkIsInactivityWarningData","checkIsInactivityTimeoutData","handleDataReceivedEvent","payload","decoded","decodeDataPayload","resolve","catch","handleConnectedEvent","_conversationRef$curr6","handleEncryptionErrorEvent","handleDisconnectedEvent","reason","DisconnectReason","CLIENT_INITIATED","ROOM_CLOSED","handleParticipantConnectedEvent","shouldHandleParticipantConnected","_conversationRef$curr7","handleParticipantDisconnectedEvent","_conversationRef$curr8","leave","_conversationRef$curr9","disconnect","_conversationRef$curr0","_conversationRef$curr1","interrupt","_conversationRef$curr10","publishConversationDataMessage","dismissInactivity","send","attachments","_conversationRef$curr11","sendText","topic","attributes","safeStringify","on","off","status"],"sources":["../../../../../src/hooks/useConversation/livekit/useConversation.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n DisconnectReason,\n Participant,\n setLogLevel,\n ParticipantKind,\n RemoteParticipant,\n TranscriptionSegment,\n LogLevel,\n} from 'livekit-client';\nimport invariant from 'invariant';\nimport { useTimer } from 'react-timer-hook';\nimport { useLatest, useUpdateEffect } from 'react-use';\nimport { useEnsureRoom, useMediaDeviceSelect } from '@livekit/components-react';\nimport { useAtom, useAtomValue, useSetAtom } from 'jotai';\nimport {\n Conversation,\n state,\n type ConversationTranscription,\n} from '../../../conversation';\nimport type {\n UseConversationResult,\n UseConversationOptions,\n Attachment,\n} from '../types';\nimport type {\n InactivityWarningData,\n InactivityTimeoutData,\n TurnDetectionData,\n ToolCallsData,\n} from './types';\nimport { useCreateConversation } from '../../useCreateConversation';\nimport { useSpeechActivityDetector } from '../../useSpeechActivityDetector';\nimport {\n useParticipantTrack,\n Source,\n getTrackStats,\n parseTrackStats,\n type CumulativeTrackStats,\n} from '../../useParticipantTrack';\n\nimport { useEmitConversationEvent } from '../../useConversationEvents/useEmitConversationEvent';\nimport { useToolCallingRuntime } from '../../useTools/runtime/useToolCallingRuntime';\nimport {\n checkIsTurnDetectionData,\n checkIsInactivityWarningData,\n checkIsInactivityTimeoutData,\n checkIsToolCallsData,\n createLivekitToolAdapter,\n decodeDataPayload,\n findJoinedAgentParticipant,\n mergeTranscriptions,\n publishConversationDataMessage,\n safeStringify,\n shouldHandleParticipantConnected,\n} from './utils';\nimport {\n ACOUSTIC_AGENT_HANGOVER_MS,\n ACOUSTIC_USER_HANGOVER_MS,\n ACOUSTIC_USER_THRESHOLD_RMS,\n} from './constants';\n\nexport function useConversation({\n autoJoin = true,\n type,\n config,\n startWithMicrophone = false,\n startWithCamera = false,\n firstConversation,\n lastConversationTopic,\n}: UseConversationOptions): UseConversationResult {\n setLogLevel(LogLevel.silent);\n\n const conversation = useCreateConversation({\n type,\n config,\n firstConversation,\n lastConversationTopic,\n });\n const room = useEnsureRoom();\n const speaker = useAtomValue(state.speaker);\n const [microphone, setMicrophone] = useAtom(state.microphone);\n const [camera, setCamera] = useAtom(state.camera);\n const toolRuntime = useToolCallingRuntime();\n const toolAdapter = createLivekitToolAdapter(room);\n\n // for use in register/unregister room events\n const conversationRef = useLatest<Conversation | undefined>(\n conversation.data,\n );\n const toolRuntimeRef = useLatest(toolRuntime);\n\n const [conversationStatus, setConversationStatus] = useAtom(\n state.conversationStatus,\n );\n\n const [userConnectionState, setUserConnectionState] = useAtom(\n state.userConnectionState,\n );\n\n const [joinedAt, setJoinedAt] = useAtom(state.joinedAt);\n\n const { setActiveMediaDevice: setMicrophoneDeviceId } = useMediaDeviceSelect({\n kind: 'audioinput',\n });\n const { setActiveMediaDevice: setSpeakerDeviceId } = useMediaDeviceSelect({\n kind: 'audiooutput',\n });\n const { setActiveMediaDevice: setCameraDeviceId } = useMediaDeviceSelect({\n kind: 'videoinput',\n requestPermissions: camera.enabled,\n });\n\n const setTranscriptions = useSetAtom(state.transcriptions);\n const [agentConnectionState, setAgentConnectionState] = useAtom(\n state.agentConnectionState,\n );\n const setAgentActivityState = useSetAtom(state.agentActivityState);\n const setUserActivityState = useSetAtom(state.userActivityState);\n const emitEvent = useEmitConversationEvent();\n\n const inactivityTimeoutRef = useRef(false);\n const acousticPhaseRef = useRef<'idle' | 'waitingForAgent' | 'busy'>('idle');\n const acousticT0Ref = useRef<number | null>(null);\n const latestTurnMetadataRef = useRef<{\n turnDetectionStrategy?: string;\n sequence?: number;\n speechId?: string;\n }>({});\n const isConnectedRef = useRef(false);\n const userCumulativeTrackStatsRef = useRef<CumulativeTrackStats | undefined>(\n undefined,\n );\n const agentCumulativeTrackStatsRef = useRef<CumulativeTrackStats | undefined>(\n undefined,\n );\n\n const userMicPublication = useParticipantTrack({\n type: 'user',\n source: Source.Microphone,\n });\n const agentMicPublication = useParticipantTrack({\n type: 'agent',\n source: Source.Microphone,\n });\n\n const timer = useTimer({\n autoStart: false,\n onExpire: handleExpire,\n expiryTimestamp: new Date(),\n });\n\n useEffect(() => {\n if (!room) {\n return;\n }\n registerRoomEvents();\n\n return () => {\n unregisterRoomEvents();\n };\n }, [room]);\n\n useUpdateEffect(() => {\n setMicrophoneDeviceId(microphone.deviceId);\n }, [microphone.deviceId]);\n\n useUpdateEffect(() => {\n setSpeakerDeviceId(speaker.deviceId);\n }, [speaker.deviceId]);\n\n useUpdateEffect(() => {\n setCameraDeviceId(camera.deviceId);\n }, [camera.deviceId]);\n\n useUpdateEffect(() => {\n if (agentConnectionState !== 'joined') {\n return;\n }\n room.localParticipant.setMicrophoneEnabled(microphone.enabled);\n }, [microphone.enabled, agentConnectionState]);\n\n useUpdateEffect(() => {\n if (agentConnectionState !== 'joined') {\n return;\n }\n room.localParticipant.setCameraEnabled(camera.enabled, {\n resolution: { width: 1920, height: 1080 },\n });\n }, [camera.enabled, agentConnectionState]);\n\n useEffect(() => {\n if (!autoJoin) {\n return;\n }\n\n if (conversationStatus === 'created') {\n void join();\n }\n }, [conversationStatus, autoJoin]);\n\n useEffect(() => {\n if (!joinedAt || conversation.data?.limit === undefined) {\n return;\n }\n\n timer.restart(new Date(joinedAt.getTime() + conversation.data!.limit!));\n }, [joinedAt, conversation.data?.limit]);\n\n async function join() {\n invariant(userConnectionState === 'idle', 'Already joined');\n invariant(conversation.data, 'Conversation is not ready');\n const url = new URL(conversation?.data?.url || '');\n const accessToken = url.searchParams.get('token');\n try {\n setUserConnectionState('joining');\n await room?.connect(conversation.data.url, accessToken!, {});\n\n // sometimes the agent is already joined before the user joins the conversation\n const remoteParticipant = findJoinedAgentParticipant(room, type);\n if (remoteParticipant && agentConnectionState !== 'joined') {\n handleAgentJoin(remoteParticipant);\n }\n\n enableMediaDevices();\n } catch (error) {\n console.error('Failed to join', error);\n setUserConnectionState('join-error');\n }\n }\n\n function enableMediaDevices() {\n if (startWithMicrophone) {\n setMicrophone({ ...microphone, enabled: true });\n }\n if (startWithCamera && type === 'video') {\n setCamera({ ...camera, enabled: true });\n }\n }\n\n function handleTranscriptionReceivedEvent(\n segments: TranscriptionSegment[],\n participant?: Participant,\n ) {\n const transcriptions: ConversationTranscription[] = segments.map((s) => ({\n id: s.id,\n message: s.text,\n source: participant?.kind === ParticipantKind.AGENT ? 'agent' : 'user',\n }));\n\n setTranscriptions((old) => mergeTranscriptions(transcriptions, old));\n }\n\n function handleTurnDetectionEvent(data: TurnDetectionData) {\n const conversationId = conversationRef.current?.id;\n const { participantKind, state: eventState } = data;\n switch (participantKind) {\n case 'STANDARD':\n if (eventState === 'listening') {\n latestTurnMetadataRef.current = {\n turnDetectionStrategy: data.turnDetectionStrategy,\n sequence: data.sequence,\n speechId: data.speechId,\n };\n }\n emitEvent(\n eventState === 'speaking' ? 'userSpeakStart' : 'userSpeakStop',\n { conversationId: conversationId! },\n );\n setUserActivityState(eventState);\n break;\n case 'AGENT':\n if (data.speechId) {\n latestTurnMetadataRef.current = {\n ...latestTurnMetadataRef.current,\n speechId: data.speechId,\n };\n }\n emitEvent(\n eventState === 'speaking' ? 'agentSpeakStart' : 'agentSpeakStop',\n { conversationId: conversationId! },\n );\n setAgentActivityState(eventState);\n break;\n }\n }\n\n function handleAcousticUserOnset() {\n if (!isConnectedRef.current) {\n return;\n }\n if (acousticPhaseRef.current === 'waitingForAgent') {\n acousticPhaseRef.current = 'idle';\n acousticT0Ref.current = null;\n }\n }\n\n function handleAcousticUserOffset(timestampMs: number) {\n if (!isConnectedRef.current || acousticPhaseRef.current !== 'idle') {\n return;\n }\n acousticT0Ref.current = timestampMs - ACOUSTIC_USER_HANGOVER_MS;\n acousticPhaseRef.current = 'waitingForAgent';\n }\n\n function handleAcousticAgentOnset(timestampMs: number) {\n if (\n !isConnectedRef.current ||\n acousticPhaseRef.current !== 'waitingForAgent' ||\n acousticT0Ref.current == null\n ) {\n return;\n }\n\n const latencyMs = timestampMs - acousticT0Ref.current;\n acousticT0Ref.current = null;\n acousticPhaseRef.current = 'busy';\n\n if (latencyMs < 0 || latencyMs > 15000) {\n return;\n }\n\n emitEvent('responseLatency', {\n conversationId: conversationRef.current?.id!,\n latencyMs,\n turnDetectionStrategy:\n latestTurnMetadataRef.current.turnDetectionStrategy!,\n sequence: latestTurnMetadataRef.current.sequence,\n speechId: latestTurnMetadataRef.current.speechId,\n });\n\n void emitConversationTurnLatency(latencyMs);\n }\n\n async function emitConversationTurnLatency(clientAcousticLatencyMs: number) {\n const [userReport, agentReport] = await Promise.all([\n getTrackStats(userMicPublication),\n getTrackStats(agentMicPublication),\n ]);\n const userStats = parseTrackStats(\n userReport,\n userCumulativeTrackStatsRef.current,\n );\n const agentStats = parseTrackStats(\n agentReport,\n agentCumulativeTrackStatsRef.current,\n );\n userCumulativeTrackStatsRef.current = userStats.cumulativeTrackStats;\n agentCumulativeTrackStatsRef.current = agentStats.cumulativeTrackStats;\n\n emitEvent('conversationTurnLatency', {\n conversationId: conversationRef.current?.id!,\n speechId: latestTurnMetadataRef.current.speechId,\n sequence: latestTurnMetadataRef.current.sequence,\n clientAcousticLatencyMs,\n rttMs: userStats.roundTripTimeMs,\n jitterBufferDelayMs: agentStats.jitterBufferDelayMs,\n userPacketsLost: userStats.packetsLost,\n agentPacketsLost: agentStats.packetsLost,\n });\n }\n\n function handleAcousticAgentOffset() {\n acousticPhaseRef.current = 'idle';\n }\n\n useSpeechActivityDetector({\n source: 'user',\n onSpeechStart: handleAcousticUserOnset,\n onSpeechEnd: handleAcousticUserOffset,\n thresholdRms: ACOUSTIC_USER_THRESHOLD_RMS,\n hangoverMs: ACOUSTIC_USER_HANGOVER_MS,\n });\n useSpeechActivityDetector({\n source: 'agent',\n onSpeechStart: handleAcousticAgentOnset,\n onSpeechEnd: handleAcousticAgentOffset,\n hangoverMs: ACOUSTIC_AGENT_HANGOVER_MS,\n });\n\n function handleInactivityWarningEvent(data: InactivityWarningData) {\n emitEvent('inactivityWarning', {\n conversationId: conversationRef.current?.id!,\n gracePeriodSec: data.grace_period_sec,\n });\n }\n\n function handleInactivityTimeoutEvent(_data: InactivityTimeoutData) {\n inactivityTimeoutRef.current = true;\n emitEvent('inactivityTimeout', {\n conversationId: conversationRef.current?.id!,\n });\n }\n\n async function handleToolCallsEvent(data: ToolCallsData) {\n await toolRuntimeRef.current.resolveIncomingToolCalls(data, toolAdapter);\n }\n\n const dataChannelHandlers: {\n guard: (data: unknown) => boolean;\n handle: (data: unknown) => void | Promise<void>;\n }[] = [\n {\n guard: checkIsToolCallsData,\n handle: handleToolCallsEvent as (data: unknown) => Promise<void>,\n },\n {\n guard: checkIsTurnDetectionData,\n handle: handleTurnDetectionEvent as (data: unknown) => void,\n },\n {\n guard: checkIsInactivityWarningData,\n handle: handleInactivityWarningEvent as (data: unknown) => void,\n },\n {\n guard: checkIsInactivityTimeoutData,\n handle: handleInactivityTimeoutEvent as (data: unknown) => void,\n },\n ];\n\n function handleDataReceivedEvent(payload: Uint8Array) {\n const decoded = decodeDataPayload(payload);\n if (decoded === null) {\n return;\n }\n for (const { guard, handle } of dataChannelHandlers) {\n if (guard(decoded)) {\n void Promise.resolve(handle(decoded)).catch((error) => {\n console.error('Failed to handle data channel payload', error);\n });\n return;\n }\n }\n }\n\n function handleConnectedEvent() {\n isConnectedRef.current = true;\n setUserConnectionState('joined');\n setAgentConnectionState('joining');\n emitEvent('callStarted', {\n conversationId: conversationRef.current?.id!,\n });\n }\n\n async function handleEncryptionErrorEvent(error: Error) {\n console.error('Encryption error', error);\n setConversationStatus('error');\n }\n\n function handleDisconnectedEvent(reason?: DisconnectReason) {\n isConnectedRef.current = false;\n acousticPhaseRef.current = 'idle';\n acousticT0Ref.current = null;\n latestTurnMetadataRef.current = {};\n userCumulativeTrackStatsRef.current = undefined;\n agentCumulativeTrackStatsRef.current = undefined;\n setAgentActivityState('idle');\n setAgentConnectionState('idle');\n setUserActivityState('idle');\n setUserConnectionState('idle');\n\n if (inactivityTimeoutRef.current) {\n inactivityTimeoutRef.current = false;\n setConversationStatus('inactivity-timeout');\n return;\n }\n\n switch (reason) {\n case DisconnectReason.CLIENT_INITIATED:\n break;\n case DisconnectReason.ROOM_CLOSED:\n setConversationStatus('destroyed');\n break;\n default:\n console.error('Conversation disconnected with reason', reason);\n setConversationStatus('error');\n break;\n }\n }\n\n function handleParticipantConnectedEvent(participant: RemoteParticipant) {\n if (shouldHandleParticipantConnected(participant, type)) {\n handleAgentJoin(participant);\n }\n }\n\n function handleAgentJoin(participant: RemoteParticipant) {\n setAgentConnectionState('joined');\n emitEvent('agentJoined', {\n conversationId: conversationRef.current?.id!,\n participant,\n });\n }\n\n function handleParticipantDisconnectedEvent(participant: RemoteParticipant) {\n setAgentConnectionState('left');\n emitEvent('agentLeft', {\n conversationId: conversationRef.current?.id!,\n participant,\n });\n }\n\n async function leave() {\n if (userConnectionState !== 'joined' && userConnectionState !== 'joining') {\n return;\n }\n\n try {\n setUserConnectionState('leaving');\n await room?.disconnect(true);\n setConversationStatus('destroyed');\n setJoinedAt(undefined);\n emitEvent('callEnded', {\n conversationId: conversationRef.current?.id!,\n });\n } catch (error) {\n console.error('Failed to leave', error);\n setConversationStatus('error');\n }\n }\n\n async function handleExpire() {\n emitEvent('timeExceeded', {\n conversationId: conversationRef.current?.id!,\n limit: conversationRef.current?.limit!,\n });\n await leave();\n setConversationStatus('exceeded');\n }\n\n async function interrupt() {\n emitEvent('interrupt', {\n conversationId: conversationRef.current?.id!,\n });\n\n await publishConversationDataMessage(room, {}, 'interrupt');\n }\n\n async function dismissInactivity() {\n await publishConversationDataMessage(\n room,\n { type: 'inactivity_dismiss' },\n 'inactivity_dismiss',\n );\n }\n\n async function send(message: string, attachments: Attachment[] = []) {\n await room?.localParticipant.sendText(message, {\n topic: 'lk.chat',\n attributes: {\n attachments: safeStringify(attachments),\n },\n });\n emitEvent('userSendMessage', {\n conversationId: conversationRef.current?.id!,\n message,\n });\n }\n\n function registerRoomEvents() {\n room\n .on('connected', handleConnectedEvent)\n .on('encryptionError', handleEncryptionErrorEvent)\n .on('disconnected', handleDisconnectedEvent)\n .on('transcriptionReceived', handleTranscriptionReceivedEvent)\n .on('participantConnected', handleParticipantConnectedEvent)\n .on('participantDisconnected', handleParticipantDisconnectedEvent)\n .on('dataReceived', handleDataReceivedEvent);\n }\n\n function unregisterRoomEvents() {\n room.off('connected', handleConnectedEvent);\n room.off('encryptionError', handleEncryptionErrorEvent);\n room.off('disconnected', handleDisconnectedEvent);\n room.off('transcriptionReceived', handleTranscriptionReceivedEvent);\n room.off('participantConnected', handleParticipantConnectedEvent);\n room.off('participantDisconnected', handleParticipantDisconnectedEvent);\n room.off('dataReceived', handleDataReceivedEvent);\n }\n\n return {\n status: conversationStatus,\n conversation: conversation.data,\n join,\n send,\n interrupt,\n dismissInactivity,\n leave,\n };\n}\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AASA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAgBA,IAAAS,sBAAA,GAAAT,OAAA;AACA,IAAAU,0BAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAX,OAAA;AAQA,IAAAY,yBAAA,GAAAZ,OAAA;AACA,IAAAa,sBAAA,GAAAb,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AAaA,IAAAe,UAAA,GAAAf,OAAA;AAMO,SAASgB,eAAeA,CAAC;EAC9BC,QAAQ,GAAG,IAAI;EACfC,IAAI;EACJC,MAAM;EACNC,mBAAmB,GAAG,KAAK;EAC3BC,eAAe,GAAG,KAAK;EACvBC,iBAAiB;EACjBC;AACsB,CAAC,EAAyB;EAAA,IAAAC,mBAAA;EAChD,IAAAC,0BAAW,EAACC,uBAAQ,CAACC,MAAM,CAAC;EAE5B,MAAMC,YAAY,GAAG,IAAAC,4CAAqB,EAAC;IACzCX,IAAI;IACJC,MAAM;IACNG,iBAAiB;IACjBC;EACF,CAAC,CAAC;EACF,MAAMO,IAAI,GAAG,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AACgG,OAAO,qBAAvBqF,uBAAA,CAAyB/F,EAAG;MAC5CC;IACF,CAAC,CAAC;EACJ;EAEA,SAASnC,kBAAkBA,CAAA,EAAG;IAC5BlE,IAAI,CACDwM,EAAE,CAAC,WAAW,EAAE7B,oBAAoB,CAAC,CACrC6B,EAAE,CAAC,iBAAiB,EAAE3B,0BAA0B,CAAC,CACjD2B,EAAE,CAAC,cAAc,EAAE1B,uBAAuB,CAAC,CAC3C0B,EAAE,CAAC,uBAAuB,EAAEzG,gCAAgC,CAAC,CAC7DyG,EAAE,CAAC,sBAAsB,EAAErB,+BAA+B,CAAC,CAC3DqB,EAAE,CAAC,yBAAyB,EAAElB,kCAAkC,CAAC,CACjEkB,EAAE,CAAC,cAAc,EAAEnC,uBAAuB,CAAC;EAChD;EAEA,SAASlG,oBAAoBA,CAAA,EAAG;IAC9BnE,IAAI,CAACyM,GAAG,CAAC,WAAW,EAAE9B,oBAAoB,CAAC;IAC3C3K,IAAI,CAACyM,GAAG,CAAC,iBAAiB,EAAE5B,0BAA0B,CAAC;IACvD7K,IAAI,CAACyM,GAAG,CAAC,cAAc,EAAE3B,uBAAuB,CAAC;IACjD9K,IAAI,CAACyM,GAAG,CAAC,uBAAuB,EAAE1G,gCAAgC,CAAC;IACnE/F,IAAI,CAACyM,GAAG,CAAC,sBAAsB,EAAEtB,+BAA+B,CAAC;IACjEnL,IAAI,CAACyM,GAAG,CAAC,yBAAyB,EAAEnB,kCAAkC,CAAC;IACvEtL,IAAI,CAACyM,GAAG,CAAC,cAAc,EAAEpC,uBAAuB,CAAC;EACnD;EAEA,OAAO;IACLqC,MAAM,EAAExL,kBAAkB;IAC1BpB,YAAY,EAAEA,YAAY,CAACkB,IAAI;IAC/B4D,IAAI;IACJqH,IAAI;IACJJ,SAAS;IACTG,iBAAiB;IACjBR;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","require","_livekitClient","_invariant","_interopRequireDefault","_reactTimerHook","_reactUse","_componentsReact","_jotai","_conversation","_sdkConsumer","_useCreateConversation","_useSpeechActivityDetector","_useParticipantTrack","_useEmitConversationEvent","_useToolCallingRuntime","_serialize","_utils","_constants","useConversation","autoJoin","type","config","startWithMicrophone","startWithCamera","firstConversation","lastConversationTopic","_conversation$data2","setLogLevel","LogLevel","silent","conversation","useCreateConversation","room","useEnsureRoom","speaker","useAtomValue","state","microphone","setMicrophone","useAtom","camera","setCamera","tools","toolsRegistry","useSdkConsumer","toolRuntime","useToolCallingRuntime","toolsRegistryRef","useLatest","conversationRef","data","toolRuntimeRef","conversationStatus","setConversationStatus","userConnectionState","setUserConnectionState","joinedAt","setJoinedAt","setActiveMediaDevice","setMicrophoneDeviceId","useMediaDeviceSelect","kind","setSpeakerDeviceId","setCameraDeviceId","requestPermissions","enabled","setTranscriptions","useSetAtom","transcriptions","agentConnectionState","setAgentConnectionState","setAgentActivityState","agentActivityState","setUserActivityState","userActivityState","emitEvent","useEmitConversationEvent","inactivityTimeoutRef","useRef","acousticPhaseRef","acousticT0Ref","latestTurnMetadataRef","isConnectedRef","userCumulativeTrackStatsRef","undefined","agentCumulativeTrackStatsRef","userMicPublication","useParticipantTrack","source","Source","Microphone","agentMicPublication","timer","useTimer","autoStart","onExpire","handleExpire","expiryTimestamp","Date","useEffect","registerRoomEvents","unregisterRoomEvents","useUpdateEffect","deviceId","localParticipant","setMicrophoneEnabled","setCameraEnabled","resolution","width","height","join","_conversation$data","limit","restart","getTime","_conversation$data3","invariant","url","URL","accessToken","searchParams","get","connect","remoteParticipant","findJoinedAgentParticipant","handleAgentJoin","enableMediaDevices","error","console","handleTranscriptionReceivedEvent","segments","participant","map","s","id","message","text","ParticipantKind","AGENT","old","mergeTranscriptions","handleTurnDetectionEvent","_conversationRef$curr","conversationId","current","participantKind","eventState","turnDetectionStrategy","sequence","speechId","handleAcousticUserOnset","handleAcousticUserOffset","timestampMs","ACOUSTIC_USER_HANGOVER_MS","handleAcousticAgentOnset","_conversationRef$curr2","latencyMs","emitConversationTurnLatency","clientAcousticLatencyMs","_conversationRef$curr3","userReport","agentReport","Promise","all","getTrackStats","userStats","parseTrackStats","agentStats","cumulativeTrackStats","rttMs","roundTripTimeMs","jitterBufferDelayMs","userPacketsLost","packetsLost","agentPacketsLost","handleAcousticAgentOffset","useSpeechActivityDetector","onSpeechStart","onSpeechEnd","thresholdRms","ACOUSTIC_USER_THRESHOLD_RMS","hangoverMs","ACOUSTIC_AGENT_HANGOVER_MS","handleInactivityWarningEvent","_conversationRef$curr4","gracePeriodSec","grace_period_sec","handleInactivityTimeoutEvent","_data","_conversationRef$curr5","handleGetToolsRpc","JSON","stringify","buildToolDefinitions","handleExecuteToolRpc","call","parseFunctionCallPayload","payload","functionCallId","result","executeToolCalls","extractToolErrorMessage","dataChannelHandlers","guard","checkIsTurnDetectionData","handle","checkIsInactivityWarningData","checkIsInactivityTimeoutData","handleDataReceivedEvent","decoded","decodeDataPayload","resolve","catch","handleConnectedEvent","_conversationRef$curr6","handleEncryptionErrorEvent","handleDisconnectedEvent","reason","DisconnectReason","CLIENT_INITIATED","ROOM_CLOSED","handleParticipantConnectedEvent","shouldHandleParticipantConnected","_conversationRef$curr7","handleParticipantDisconnectedEvent","_conversationRef$curr8","leave","_conversationRef$curr9","disconnect","_conversationRef$curr0","_conversationRef$curr1","interrupt","_conversationRef$curr10","publishConversationDataMessage","dismissInactivity","send","attachments","_conversationRef$curr11","sendText","topic","attributes","safeStringify","on","unregisterRpcMethod","GET_TOOLS_RPC_METHOD","EXECUTE_TOOL_RPC_METHOD","registerRpcMethod","off","status"],"sources":["../../../../../src/hooks/useConversation/livekit/useConversation.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n DisconnectReason,\n Participant,\n setLogLevel,\n ParticipantKind,\n RemoteParticipant,\n TranscriptionSegment,\n LogLevel,\n type RpcInvocationData,\n} from 'livekit-client';\nimport invariant from 'invariant';\nimport { useTimer } from 'react-timer-hook';\nimport { useLatest, useUpdateEffect } from 'react-use';\nimport { useEnsureRoom, useMediaDeviceSelect } from '@livekit/components-react';\nimport { useAtom, useAtomValue, useSetAtom } from 'jotai';\nimport {\n Conversation,\n state,\n type ConversationTranscription,\n} from '../../../conversation';\nimport type {\n UseConversationResult,\n UseConversationOptions,\n Attachment,\n} from '../types';\nimport type { FunctionCallResult } from '../../../types/service';\nimport { useSdkConsumer } from '../../../sdk-consumer';\nimport type {\n InactivityWarningData,\n InactivityTimeoutData,\n TurnDetectionData,\n} from './types';\nimport { useCreateConversation } from '../../useCreateConversation';\nimport { useSpeechActivityDetector } from '../../useSpeechActivityDetector';\nimport {\n useParticipantTrack,\n Source,\n getTrackStats,\n parseTrackStats,\n type CumulativeTrackStats,\n} from '../../useParticipantTrack';\n\nimport { useEmitConversationEvent } from '../../useConversationEvents/useEmitConversationEvent';\nimport { useToolCallingRuntime } from '../../useTools/runtime/useToolCallingRuntime';\nimport { extractToolErrorMessage } from '../../useTools/utils/serialize';\nimport {\n checkIsTurnDetectionData,\n checkIsInactivityWarningData,\n checkIsInactivityTimeoutData,\n buildToolDefinitions,\n decodeDataPayload,\n findJoinedAgentParticipant,\n mergeTranscriptions,\n parseFunctionCallPayload,\n publishConversationDataMessage,\n safeStringify,\n shouldHandleParticipantConnected,\n} from './utils';\nimport {\n ACOUSTIC_AGENT_HANGOVER_MS,\n ACOUSTIC_USER_HANGOVER_MS,\n ACOUSTIC_USER_THRESHOLD_RMS,\n EXECUTE_TOOL_RPC_METHOD,\n GET_TOOLS_RPC_METHOD,\n} from './constants';\n\nexport function useConversation({\n autoJoin = true,\n type,\n config,\n startWithMicrophone = false,\n startWithCamera = false,\n firstConversation,\n lastConversationTopic,\n}: UseConversationOptions): UseConversationResult {\n setLogLevel(LogLevel.silent);\n\n const conversation = useCreateConversation({\n type,\n config,\n firstConversation,\n lastConversationTopic,\n });\n const room = useEnsureRoom();\n const speaker = useAtomValue(state.speaker);\n const [microphone, setMicrophone] = useAtom(state.microphone);\n const [camera, setCamera] = useAtom(state.camera);\n const { tools: toolsRegistry = {} } = useSdkConsumer();\n const toolRuntime = useToolCallingRuntime();\n const toolsRegistryRef = useLatest(toolsRegistry);\n\n // for use in register/unregister room events\n const conversationRef = useLatest<Conversation | undefined>(\n conversation.data,\n );\n const toolRuntimeRef = useLatest(toolRuntime);\n\n const [conversationStatus, setConversationStatus] = useAtom(\n state.conversationStatus,\n );\n\n const [userConnectionState, setUserConnectionState] = useAtom(\n state.userConnectionState,\n );\n\n const [joinedAt, setJoinedAt] = useAtom(state.joinedAt);\n\n const { setActiveMediaDevice: setMicrophoneDeviceId } = useMediaDeviceSelect({\n kind: 'audioinput',\n });\n const { setActiveMediaDevice: setSpeakerDeviceId } = useMediaDeviceSelect({\n kind: 'audiooutput',\n });\n const { setActiveMediaDevice: setCameraDeviceId } = useMediaDeviceSelect({\n kind: 'videoinput',\n requestPermissions: camera.enabled,\n });\n\n const setTranscriptions = useSetAtom(state.transcriptions);\n const [agentConnectionState, setAgentConnectionState] = useAtom(\n state.agentConnectionState,\n );\n const setAgentActivityState = useSetAtom(state.agentActivityState);\n const setUserActivityState = useSetAtom(state.userActivityState);\n const emitEvent = useEmitConversationEvent();\n\n const inactivityTimeoutRef = useRef(false);\n const acousticPhaseRef = useRef<'idle' | 'waitingForAgent' | 'busy'>('idle');\n const acousticT0Ref = useRef<number | null>(null);\n const latestTurnMetadataRef = useRef<{\n turnDetectionStrategy?: string;\n sequence?: number;\n speechId?: string;\n }>({});\n const isConnectedRef = useRef(false);\n const userCumulativeTrackStatsRef = useRef<CumulativeTrackStats | undefined>(\n undefined,\n );\n const agentCumulativeTrackStatsRef = useRef<CumulativeTrackStats | undefined>(\n undefined,\n );\n\n const userMicPublication = useParticipantTrack({\n type: 'user',\n source: Source.Microphone,\n });\n const agentMicPublication = useParticipantTrack({\n type: 'agent',\n source: Source.Microphone,\n });\n\n const timer = useTimer({\n autoStart: false,\n onExpire: handleExpire,\n expiryTimestamp: new Date(),\n });\n\n useEffect(() => {\n if (!room) {\n return;\n }\n registerRoomEvents();\n\n return () => {\n unregisterRoomEvents();\n };\n }, [room]);\n\n useUpdateEffect(() => {\n setMicrophoneDeviceId(microphone.deviceId);\n }, [microphone.deviceId]);\n\n useUpdateEffect(() => {\n setSpeakerDeviceId(speaker.deviceId);\n }, [speaker.deviceId]);\n\n useUpdateEffect(() => {\n setCameraDeviceId(camera.deviceId);\n }, [camera.deviceId]);\n\n useUpdateEffect(() => {\n if (agentConnectionState !== 'joined') {\n return;\n }\n room.localParticipant.setMicrophoneEnabled(microphone.enabled);\n }, [microphone.enabled, agentConnectionState]);\n\n useUpdateEffect(() => {\n if (agentConnectionState !== 'joined') {\n return;\n }\n room.localParticipant.setCameraEnabled(camera.enabled, {\n resolution: { width: 1920, height: 1080 },\n });\n }, [camera.enabled, agentConnectionState]);\n\n useEffect(() => {\n if (!autoJoin) {\n return;\n }\n\n if (conversationStatus === 'created') {\n void join();\n }\n }, [conversationStatus, autoJoin]);\n\n useEffect(() => {\n if (!joinedAt || conversation.data?.limit === undefined) {\n return;\n }\n\n timer.restart(new Date(joinedAt.getTime() + conversation.data!.limit!));\n }, [joinedAt, conversation.data?.limit]);\n\n async function join() {\n invariant(userConnectionState === 'idle', 'Already joined');\n invariant(conversation.data, 'Conversation is not ready');\n const url = new URL(conversation?.data?.url || '');\n const accessToken = url.searchParams.get('token');\n try {\n setUserConnectionState('joining');\n await room?.connect(conversation.data.url, accessToken!, {});\n\n // sometimes the agent is already joined before the user joins the conversation\n const remoteParticipant = findJoinedAgentParticipant(room, type);\n if (remoteParticipant && agentConnectionState !== 'joined') {\n handleAgentJoin(remoteParticipant);\n }\n\n enableMediaDevices();\n } catch (error) {\n console.error('Failed to join', error);\n setUserConnectionState('join-error');\n }\n }\n\n function enableMediaDevices() {\n if (startWithMicrophone) {\n setMicrophone({ ...microphone, enabled: true });\n }\n if (startWithCamera && type === 'video') {\n setCamera({ ...camera, enabled: true });\n }\n }\n\n function handleTranscriptionReceivedEvent(\n segments: TranscriptionSegment[],\n participant?: Participant,\n ) {\n const transcriptions: ConversationTranscription[] = segments.map((s) => ({\n id: s.id,\n message: s.text,\n source: participant?.kind === ParticipantKind.AGENT ? 'agent' : 'user',\n }));\n\n setTranscriptions((old) => mergeTranscriptions(transcriptions, old));\n }\n\n function handleTurnDetectionEvent(data: TurnDetectionData) {\n const conversationId = conversationRef.current?.id;\n const { participantKind, state: eventState } = data;\n switch (participantKind) {\n case 'STANDARD':\n if (eventState === 'listening') {\n latestTurnMetadataRef.current = {\n turnDetectionStrategy: data.turnDetectionStrategy,\n sequence: data.sequence,\n speechId: data.speechId,\n };\n }\n emitEvent(\n eventState === 'speaking' ? 'userSpeakStart' : 'userSpeakStop',\n { conversationId: conversationId! },\n );\n setUserActivityState(eventState);\n break;\n case 'AGENT':\n if (data.speechId) {\n latestTurnMetadataRef.current = {\n ...latestTurnMetadataRef.current,\n speechId: data.speechId,\n };\n }\n emitEvent(\n eventState === 'speaking' ? 'agentSpeakStart' : 'agentSpeakStop',\n { conversationId: conversationId! },\n );\n setAgentActivityState(eventState);\n break;\n }\n }\n\n function handleAcousticUserOnset() {\n if (!isConnectedRef.current) {\n return;\n }\n if (acousticPhaseRef.current === 'waitingForAgent') {\n acousticPhaseRef.current = 'idle';\n acousticT0Ref.current = null;\n }\n }\n\n function handleAcousticUserOffset(timestampMs: number) {\n if (!isConnectedRef.current || acousticPhaseRef.current !== 'idle') {\n return;\n }\n acousticT0Ref.current = timestampMs - ACOUSTIC_USER_HANGOVER_MS;\n acousticPhaseRef.current = 'waitingForAgent';\n }\n\n function handleAcousticAgentOnset(timestampMs: number) {\n if (\n !isConnectedRef.current ||\n acousticPhaseRef.current !== 'waitingForAgent' ||\n acousticT0Ref.current == null\n ) {\n return;\n }\n\n const latencyMs = timestampMs - acousticT0Ref.current;\n acousticT0Ref.current = null;\n acousticPhaseRef.current = 'busy';\n\n if (latencyMs < 0 || latencyMs > 15000) {\n return;\n }\n\n emitEvent('responseLatency', {\n conversationId: conversationRef.current?.id!,\n latencyMs,\n turnDetectionStrategy:\n latestTurnMetadataRef.current.turnDetectionStrategy!,\n sequence: latestTurnMetadataRef.current.sequence,\n speechId: latestTurnMetadataRef.current.speechId,\n });\n\n void emitConversationTurnLatency(latencyMs);\n }\n\n async function emitConversationTurnLatency(clientAcousticLatencyMs: number) {\n const [userReport, agentReport] = await Promise.all([\n getTrackStats(userMicPublication),\n getTrackStats(agentMicPublication),\n ]);\n const userStats = parseTrackStats(\n userReport,\n userCumulativeTrackStatsRef.current,\n );\n const agentStats = parseTrackStats(\n agentReport,\n agentCumulativeTrackStatsRef.current,\n );\n userCumulativeTrackStatsRef.current = userStats.cumulativeTrackStats;\n agentCumulativeTrackStatsRef.current = agentStats.cumulativeTrackStats;\n\n emitEvent('conversationTurnLatency', {\n conversationId: conversationRef.current?.id!,\n speechId: latestTurnMetadataRef.current.speechId,\n sequence: latestTurnMetadataRef.current.sequence,\n clientAcousticLatencyMs,\n rttMs: userStats.roundTripTimeMs,\n jitterBufferDelayMs: agentStats.jitterBufferDelayMs,\n userPacketsLost: userStats.packetsLost,\n agentPacketsLost: agentStats.packetsLost,\n });\n }\n\n function handleAcousticAgentOffset() {\n acousticPhaseRef.current = 'idle';\n }\n\n useSpeechActivityDetector({\n source: 'user',\n onSpeechStart: handleAcousticUserOnset,\n onSpeechEnd: handleAcousticUserOffset,\n thresholdRms: ACOUSTIC_USER_THRESHOLD_RMS,\n hangoverMs: ACOUSTIC_USER_HANGOVER_MS,\n });\n useSpeechActivityDetector({\n source: 'agent',\n onSpeechStart: handleAcousticAgentOnset,\n onSpeechEnd: handleAcousticAgentOffset,\n hangoverMs: ACOUSTIC_AGENT_HANGOVER_MS,\n });\n\n function handleInactivityWarningEvent(data: InactivityWarningData) {\n emitEvent('inactivityWarning', {\n conversationId: conversationRef.current?.id!,\n gracePeriodSec: data.grace_period_sec,\n });\n }\n\n function handleInactivityTimeoutEvent(_data: InactivityTimeoutData) {\n inactivityTimeoutRef.current = true;\n emitEvent('inactivityTimeout', {\n conversationId: conversationRef.current?.id!,\n });\n }\n\n async function handleGetToolsRpc() {\n return JSON.stringify(buildToolDefinitions(toolsRegistryRef.current));\n }\n\n async function handleExecuteToolRpc(data: RpcInvocationData) {\n const call = parseFunctionCallPayload(data.payload);\n if (!call) {\n return JSON.stringify({\n functionCallId: '',\n result: '',\n error: 'Malformed function call payload.',\n } satisfies FunctionCallResult);\n }\n try {\n const [result] = await toolRuntimeRef.current.executeToolCalls([call]);\n return JSON.stringify(result);\n } catch (error) {\n return JSON.stringify({\n functionCallId: call.functionCallId,\n result: '',\n error: extractToolErrorMessage(error),\n } satisfies FunctionCallResult);\n }\n }\n\n const dataChannelHandlers: {\n guard: (data: unknown) => boolean;\n handle: (data: unknown) => void | Promise<void>;\n }[] = [\n {\n guard: checkIsTurnDetectionData,\n handle: handleTurnDetectionEvent as (data: unknown) => void,\n },\n {\n guard: checkIsInactivityWarningData,\n handle: handleInactivityWarningEvent as (data: unknown) => void,\n },\n {\n guard: checkIsInactivityTimeoutData,\n handle: handleInactivityTimeoutEvent as (data: unknown) => void,\n },\n ];\n\n function handleDataReceivedEvent(payload: Uint8Array) {\n const decoded = decodeDataPayload(payload);\n if (decoded === null) {\n return;\n }\n for (const { guard, handle } of dataChannelHandlers) {\n if (guard(decoded)) {\n void Promise.resolve(handle(decoded)).catch((error) => {\n console.error('Failed to handle data channel payload', error);\n });\n return;\n }\n }\n }\n\n function handleConnectedEvent() {\n isConnectedRef.current = true;\n setUserConnectionState('joined');\n setAgentConnectionState('joining');\n emitEvent('callStarted', {\n conversationId: conversationRef.current?.id!,\n });\n }\n\n async function handleEncryptionErrorEvent(error: Error) {\n console.error('Encryption error', error);\n setConversationStatus('error');\n }\n\n function handleDisconnectedEvent(reason?: DisconnectReason) {\n isConnectedRef.current = false;\n acousticPhaseRef.current = 'idle';\n acousticT0Ref.current = null;\n latestTurnMetadataRef.current = {};\n userCumulativeTrackStatsRef.current = undefined;\n agentCumulativeTrackStatsRef.current = undefined;\n setAgentActivityState('idle');\n setAgentConnectionState('idle');\n setUserActivityState('idle');\n setUserConnectionState('idle');\n\n if (inactivityTimeoutRef.current) {\n inactivityTimeoutRef.current = false;\n setConversationStatus('inactivity-timeout');\n return;\n }\n\n switch (reason) {\n case DisconnectReason.CLIENT_INITIATED:\n break;\n case DisconnectReason.ROOM_CLOSED:\n setConversationStatus('destroyed');\n break;\n default:\n console.error('Conversation disconnected with reason', reason);\n setConversationStatus('error');\n break;\n }\n }\n\n function handleParticipantConnectedEvent(participant: RemoteParticipant) {\n if (shouldHandleParticipantConnected(participant, type)) {\n handleAgentJoin(participant);\n }\n }\n\n function handleAgentJoin(participant: RemoteParticipant) {\n setAgentConnectionState('joined');\n emitEvent('agentJoined', {\n conversationId: conversationRef.current?.id!,\n participant,\n });\n }\n\n function handleParticipantDisconnectedEvent(participant: RemoteParticipant) {\n setAgentConnectionState('left');\n emitEvent('agentLeft', {\n conversationId: conversationRef.current?.id!,\n participant,\n });\n }\n\n async function leave() {\n if (userConnectionState !== 'joined' && userConnectionState !== 'joining') {\n return;\n }\n\n try {\n setUserConnectionState('leaving');\n await room?.disconnect(true);\n setConversationStatus('destroyed');\n setJoinedAt(undefined);\n emitEvent('callEnded', {\n conversationId: conversationRef.current?.id!,\n });\n } catch (error) {\n console.error('Failed to leave', error);\n setConversationStatus('error');\n }\n }\n\n async function handleExpire() {\n emitEvent('timeExceeded', {\n conversationId: conversationRef.current?.id!,\n limit: conversationRef.current?.limit!,\n });\n await leave();\n setConversationStatus('exceeded');\n }\n\n async function interrupt() {\n emitEvent('interrupt', {\n conversationId: conversationRef.current?.id!,\n });\n\n await publishConversationDataMessage(room, {}, 'interrupt');\n }\n\n async function dismissInactivity() {\n await publishConversationDataMessage(\n room,\n { type: 'inactivity_dismiss' },\n 'inactivity_dismiss',\n );\n }\n\n async function send(message: string, attachments: Attachment[] = []) {\n await room?.localParticipant.sendText(message, {\n topic: 'lk.chat',\n attributes: {\n attachments: safeStringify(attachments),\n },\n });\n emitEvent('userSendMessage', {\n conversationId: conversationRef.current?.id!,\n message,\n });\n }\n\n function registerRoomEvents() {\n room\n .on('connected', handleConnectedEvent)\n .on('encryptionError', handleEncryptionErrorEvent)\n .on('disconnected', handleDisconnectedEvent)\n .on('transcriptionReceived', handleTranscriptionReceivedEvent)\n .on('participantConnected', handleParticipantConnectedEvent)\n .on('participantDisconnected', handleParticipantDisconnectedEvent)\n .on('dataReceived', handleDataReceivedEvent);\n room.unregisterRpcMethod(GET_TOOLS_RPC_METHOD);\n room.unregisterRpcMethod(EXECUTE_TOOL_RPC_METHOD);\n room.registerRpcMethod(GET_TOOLS_RPC_METHOD, handleGetToolsRpc);\n room.registerRpcMethod(EXECUTE_TOOL_RPC_METHOD, handleExecuteToolRpc);\n }\n\n function unregisterRoomEvents() {\n room.unregisterRpcMethod(GET_TOOLS_RPC_METHOD);\n room.unregisterRpcMethod(EXECUTE_TOOL_RPC_METHOD);\n room.off('connected', handleConnectedEvent);\n room.off('encryptionError', handleEncryptionErrorEvent);\n room.off('disconnected', handleDisconnectedEvent);\n room.off('transcriptionReceived', handleTranscriptionReceivedEvent);\n room.off('participantConnected', handleParticipantConnectedEvent);\n room.off('participantDisconnected', handleParticipantDisconnectedEvent);\n room.off('dataReceived', handleDataReceivedEvent);\n }\n\n return {\n status: conversationStatus,\n conversation: conversation.data,\n join,\n send,\n interrupt,\n dismissInactivity,\n leave,\n };\n}\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAUA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAWA,IAAAS,YAAA,GAAAT,OAAA;AAMA,IAAAU,sBAAA,GAAAV,OAAA;AACA,IAAAW,0BA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AC,sBAAsB,EAAE1B,+BAA+B,CAAC;IACjE7L,IAAI,CAACuN,GAAG,CAAC,yBAAyB,EAAEvB,kCAAkC,CAAC;IACvEhM,IAAI,CAACuN,GAAG,CAAC,cAAc,EAAEvC,uBAAuB,CAAC;EACnD;EAEA,OAAO;IACLwC,MAAM,EAAEpM,kBAAkB;IAC1BtB,YAAY,EAAEA,YAAY,CAACoB,IAAI;IAC/B4D,IAAI;IACJ6H,IAAI;IACJJ,SAAS;IACTG,iBAAiB;IACjBR;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.checkIsInactivityTimeoutData = checkIsInactivityTimeoutData;
|
|
5
5
|
exports.checkIsInactivityWarningData = checkIsInactivityWarningData;
|
|
6
|
-
exports.checkIsToolCallsData = checkIsToolCallsData;
|
|
7
6
|
exports.checkIsTurnDetectionData = checkIsTurnDetectionData;
|
|
8
7
|
exports.decodeDataPayload = decodeDataPayload;
|
|
9
8
|
function decodeDataPayload(data) {
|
|
@@ -23,7 +22,4 @@ function checkIsInactivityWarningData(data) {
|
|
|
23
22
|
function checkIsInactivityTimeoutData(data) {
|
|
24
23
|
return typeof data === 'object' && data !== null && 'type' in data && data.type === 'inactivity_timeout';
|
|
25
24
|
}
|
|
26
|
-
function checkIsToolCallsData(data) {
|
|
27
|
-
return typeof data === 'object' && data !== null && 'type' in data && data.type === 'tool_calls' && 'requestId' in data && typeof data.requestId === 'string' && 'functionCalls' in data && Array.isArray(data.functionCalls);
|
|
28
|
-
}
|
|
29
25
|
//# sourceMappingURL=dataChannel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["decodeDataPayload","data","JSON","parse","TextDecoder","decode","error","console","checkIsTurnDetectionData","checkIsInactivityWarningData","type","grace_period_sec","checkIsInactivityTimeoutData"
|
|
1
|
+
{"version":3,"names":["decodeDataPayload","data","JSON","parse","TextDecoder","decode","error","console","checkIsTurnDetectionData","checkIsInactivityWarningData","type","grace_period_sec","checkIsInactivityTimeoutData"],"sources":["../../../../../../src/hooks/useConversation/livekit/utils/dataChannel.ts"],"sourcesContent":["import type {\n InactivityWarningData,\n InactivityTimeoutData,\n TurnDetectionData,\n} from '../types';\n\nexport function decodeDataPayload(data: Uint8Array): unknown {\n try {\n return JSON.parse(new TextDecoder().decode(data));\n } catch (error) {\n console.error('Failed to decode data received payload', error);\n return null;\n }\n}\n\nexport function checkIsTurnDetectionData(\n data: unknown,\n): data is TurnDetectionData {\n return (\n typeof data === 'object' &&\n data !== null &&\n 'participantKind' in data &&\n 'state' in data\n );\n}\n\nexport function checkIsInactivityWarningData(\n data: unknown,\n): data is InactivityWarningData {\n return (\n typeof data === 'object' &&\n data !== null &&\n 'type' in data &&\n (data as Record<string, unknown>).type === 'inactivity_warning' &&\n 'grace_period_sec' in data &&\n typeof (data as Record<string, unknown>).grace_period_sec === 'number'\n );\n}\n\nexport function checkIsInactivityTimeoutData(\n data: unknown,\n): data is InactivityTimeoutData {\n return (\n typeof data === 'object' &&\n data !== null &&\n 'type' in data &&\n (data as Record<string, unknown>).type === 'inactivity_timeout'\n );\n}\n"],"mappings":";;;;;;;AAMO,SAASA,iBAAiBA,CAACC,IAAgB,EAAW;EAC3D,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACJ,IAAI,CAAC,CAAC;EACnD,CAAC,CAAC,OAAOK,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,wCAAwC,EAAEA,KAAK,CAAC;IAC9D,OAAO,IAAI;EACb;AACF;AAEO,SAASE,wBAAwBA,CACtCP,IAAa,EACc;EAC3B,OACE,OAAOA,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,iBAAiB,IAAIA,IAAI,IACzB,OAAO,IAAIA,IAAI;AAEnB;AAEO,SAASQ,4BAA4BA,CAC1CR,IAAa,EACkB;EAC/B,OACE,OAAOA,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,MAAM,IAAIA,IAAI,IACbA,IAAI,CAA6BS,IAAI,KAAK,oBAAoB,IAC/D,kBAAkB,IAAIT,IAAI,IAC1B,OAAQA,IAAI,CAA6BU,gBAAgB,KAAK,QAAQ;AAE1E;AAEO,SAASC,4BAA4BA,CAC1CX,IAAa,EACkB;EAC/B,OACE,OAAOA,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,MAAM,IAAIA,IAAI,IACbA,IAAI,CAA6BS,IAAI,KAAK,oBAAoB;AAEnE","ignoreList":[]}
|
|
@@ -19,17 +19,23 @@ Object.keys(_participants).forEach(function (key) {
|
|
|
19
19
|
if (key in exports && exports[key] === _participants[key]) return;
|
|
20
20
|
exports[key] = _participants[key];
|
|
21
21
|
});
|
|
22
|
+
var _rpc = require("./rpc");
|
|
23
|
+
Object.keys(_rpc).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (key in exports && exports[key] === _rpc[key]) return;
|
|
26
|
+
exports[key] = _rpc[key];
|
|
27
|
+
});
|
|
22
28
|
var _serialization = require("./serialization");
|
|
23
29
|
Object.keys(_serialization).forEach(function (key) {
|
|
24
30
|
if (key === "default" || key === "__esModule") return;
|
|
25
31
|
if (key in exports && exports[key] === _serialization[key]) return;
|
|
26
32
|
exports[key] = _serialization[key];
|
|
27
33
|
});
|
|
28
|
-
var
|
|
29
|
-
Object.keys(
|
|
34
|
+
var _toolDefinitions = require("./toolDefinitions");
|
|
35
|
+
Object.keys(_toolDefinitions).forEach(function (key) {
|
|
30
36
|
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] ===
|
|
32
|
-
exports[key] =
|
|
37
|
+
if (key in exports && exports[key] === _toolDefinitions[key]) return;
|
|
38
|
+
exports[key] = _toolDefinitions[key];
|
|
33
39
|
});
|
|
34
40
|
var _transcriptions = require("./transcriptions");
|
|
35
41
|
Object.keys(_transcriptions).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dataChannel","require","Object","keys","forEach","key","exports","_messaging","_participants","_serialization","
|
|
1
|
+
{"version":3,"names":["_dataChannel","require","Object","keys","forEach","key","exports","_messaging","_participants","_rpc","_serialization","_toolDefinitions","_transcriptions"],"sources":["../../../../../../src/hooks/useConversation/livekit/utils/index.ts"],"sourcesContent":["export * from './dataChannel';\nexport * from './messaging';\nexport * from './participants';\nexport * from './rpc';\nexport * from './serialization';\nexport * from './toolDefinitions';\nexport * from './transcriptions';\n"],"mappings":";;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,YAAA,CAAAK,GAAA;AAAA;AACA,IAAAE,UAAA,GAAAN,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAI,UAAA,EAAAH,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAE,UAAA,CAAAF,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAE,UAAA,CAAAF,GAAA;AAAA;AACA,IAAAG,aAAA,GAAAP,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAK,aAAA,EAAAJ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAG,aAAA,CAAAH,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAG,aAAA,CAAAH,GAAA;AAAA;AACA,IAAAI,I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Payload;
|
|
5
|
+
function isFunctionCall(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && 'functionCallId' in value && typeof value.functionCallId === 'string' && 'name' in value && typeof value.name === 'string';
|
|
7
|
+
}
|
|
8
|
+
function parseFunctionCallPayload(payload) {
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(payload);
|
|
11
|
+
return isFunctionCall(parsed) ? parsed : undefined;
|
|
12
|
+
} catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isFunctionCall","value","functionCallId","name","parseFunctionCallPayload","payload","parsed","JSON","parse","undefined"],"sources":["../../../../../../src/hooks/useConversation/livekit/utils/rpc.ts"],"sourcesContent":["import type { FunctionCall } from '../../../../types/service';\n\nfunction isFunctionCall(value: unknown): value is FunctionCall {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'functionCallId' in value &&\n typeof value.functionCallId === 'string' &&\n 'name' in value &&\n typeof value.name === 'string'\n );\n}\n\nexport function parseFunctionCallPayload(\n payload: string,\n): FunctionCall | undefined {\n try {\n const parsed: unknown = JSON.parse(payload);\n return isFunctionCall(parsed) ? parsed : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;AAEA,SAASA,cAAcA,CAACC,KAAc,EAAyB;EAC7D,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,gBAAgB,IAAIA,KAAK,IACzB,OAAOA,KAAK,CAACC,cAAc,KAAK,QAAQ,IACxC,MAAM,IAAID,KAAK,IACf,OAAOA,KAAK,CAACE,IAAI,KAAK,QAAQ;AAElC;AAEO,SAASC,wBAAwBA,CACtCC,OAAe,EACW;EAC1B,IAAI;IACF,MAAMC,MAAe,GAAGC,IAAI,CAACC,KAAK,CAACH,OAAO,CAAC;IAC3C,OAAOL,cAAc,CAACM,MAAM,CAAC,GAAGA,MAAM,GAAGG,SAAS;EACpD,CAAC,CAAC,MAAM;IACN,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.buildToolDefinitions = buildToolDefinitions;
|
|
5
|
+
function buildToolDefinitions(registry) {
|
|
6
|
+
const tools = [];
|
|
7
|
+
for (const [name, entry] of Object.entries(registry)) {
|
|
8
|
+
if (typeof entry === 'function') {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
tools.push({
|
|
12
|
+
name,
|
|
13
|
+
description: entry.description ?? name,
|
|
14
|
+
parameters: entry.parameters ?? {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return tools;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=toolDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["buildToolDefinitions","registry","tools","name","entry","Object","entries","push","description","parameters","type","properties"],"sources":["../../../../../../src/hooks/useConversation/livekit/utils/toolDefinitions.ts"],"sourcesContent":["import type { ToolsRegistry } from '../../../useTools/model/types';\nimport type { ClientToolDefinition } from '../types';\n\nexport function buildToolDefinitions(\n registry: ToolsRegistry,\n): ClientToolDefinition[] {\n const tools: ClientToolDefinition[] = [];\n\n for (const [name, entry] of Object.entries(registry)) {\n if (typeof entry === 'function') {\n continue;\n }\n tools.push({\n name,\n description: entry.description ?? name,\n parameters: entry.parameters ?? { type: 'object', properties: {} },\n });\n }\n\n return tools;\n}\n"],"mappings":";;;;AAGO,SAASA,oBAAoBA,CAClCC,QAAuB,EACC;EACxB,MAAMC,KAA6B,GAAG,EAAE;EAExC,KAAK,MAAM,CAACC,IAAI,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,QAAQ,CAAC,EAAE;IACpD,IAAI,OAAOG,KAAK,KAAK,UAAU,EAAE;MAC/B;IACF;IACAF,KAAK,CAACK,IAAI,CAAC;MACTJ,IAAI;MACJK,WAAW,EAAEJ,KAAK,CAACI,WAAW,IAAIL,IAAI;MACtCM,UAAU,EAAEL,KAAK,CAACK,UAAU,IAAI;QAAEC,IAAI,EAAE,QAAQ;QAAEC,UAAU,EAAE,CAAC;MAAE;IACnE,CAAC,CAAC;EACJ;EAEA,OAAOT,KAAK;AACd","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_useTools","require","exports","useTools","_errors","ToolExecutionInProgressError"],"sources":["../../../../src/hooks/useTools/index.ts"],"sourcesContent":["export { useTools } from './public/useTools';\nexport { ToolExecutionInProgressError } from './model/errors';\nexport type {\n ToolArguments,\n ToolCallResult,\n ToolCallSnapshot,\n ToolCallStatus,\n ToolsRegistry,\n} from './model/types';\n"],"mappings":";;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAA6CC,OAAA,CAAAC,QAAA,GAAAH,SAAA,CAAAG,QAAA;AAC7C,IAAAC,OAAA,GAAAH,OAAA;AAA8DC,OAAA,CAAAG,4BAAA,GAAAD,OAAA,CAAAC,4BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_useTools","require","exports","useTools","_errors","ToolExecutionInProgressError"],"sources":["../../../../src/hooks/useTools/index.ts"],"sourcesContent":["export { useTools } from './public/useTools';\nexport { ToolExecutionInProgressError } from './model/errors';\nexport type {\n ToolArguments,\n ToolCallResult,\n ToolCallSnapshot,\n ToolCallStatus,\n ToolDefinition,\n ToolsRegistry,\n} from './model/types';\n"],"mappings":";;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAA6CC,OAAA,CAAAC,QAAA,GAAAH,SAAA,CAAAG,QAAA;AAC7C,IAAAC,OAAA,GAAAH,OAAA;AAA8DC,OAAA,CAAAG,4BAAA,GAAAD,OAAA,CAAAC,4BAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../../src/hooks/useTools/model/types.ts"],"sourcesContent":["import type { FunctionCall } from '../../../types/service';\n\nexport type ToolArguments = Record<string, unknown> | null;\n\nexport type ToolHandler = (\n arguments_?: ToolArguments,\n) => unknown | Promise<unknown>;\n\nexport type ToolsRegistry = Record<string, ToolHandler>;\n\nexport type ToolCallStatus = 'pending' | 'running' | 'completed';\n\nexport type ToolCallRequest = {\n id: string;\n name: string;\n arguments?: ToolArguments;\n};\n\nexport type ToolCallResult = {\n id: string;\n name: string;\n success: boolean;\n content: string;\n};\n\nexport type ToolCallSnapshot = {\n id: string;\n name: string;\n arguments: ToolArguments;\n status: ToolCallStatus;\n result: ToolCallResult | null;\n};\n\nexport type ToolCallSourceResponse = {\n functionCalls?: readonly FunctionCall[] | null;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../../src/hooks/useTools/model/types.ts"],"sourcesContent":["import type { FunctionCall } from '../../../types/service';\n\nexport type ToolArguments = Record<string, unknown> | null;\n\nexport type ToolHandler = (\n arguments_?: ToolArguments,\n) => unknown | Promise<unknown>;\n\nexport type ToolDefinition = {\n description?: string;\n parameters?: Record<string, unknown>;\n handler: ToolHandler;\n};\n\nexport type ToolsRegistry = Record<string, ToolHandler | ToolDefinition>;\n\nexport type ToolCallStatus = 'pending' | 'running' | 'completed';\n\nexport type ToolCallRequest = {\n id: string;\n name: string;\n arguments?: ToolArguments;\n};\n\nexport type ToolCallResult = {\n id: string;\n name: string;\n success: boolean;\n content: string;\n};\n\nexport type ToolCallSnapshot = {\n id: string;\n name: string;\n arguments: ToolArguments;\n status: ToolCallStatus;\n result: ToolCallResult | null;\n};\n\nexport type ToolCallSourceResponse = {\n functionCalls?: readonly FunctionCall[] | null;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -4,7 +4,8 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.executeToolCall = executeToolCall;
|
|
5
5
|
var _serialize = require("../utils/serialize");
|
|
6
6
|
async function executeToolCall(call, registry) {
|
|
7
|
-
const
|
|
7
|
+
const entry = registry[call.name];
|
|
8
|
+
const handler = typeof entry === 'function' ? entry : entry == null ? void 0 : entry.handler;
|
|
8
9
|
if (!handler) {
|
|
9
10
|
return {
|
|
10
11
|
id: call.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_serialize","require","executeToolCall","call","registry","
|
|
1
|
+
{"version":3,"names":["_serialize","require","executeToolCall","call","registry","entry","name","handler","id","success","content","output","arguments","serializeToolContent","error","extractToolErrorMessage"],"sources":["../../../../../src/hooks/useTools/runtime/executeToolCall.ts"],"sourcesContent":["import type {\n ToolCallRequest,\n ToolCallResult,\n ToolsRegistry,\n} from '../model/types';\nimport {\n extractToolErrorMessage,\n serializeToolContent,\n} from '../utils/serialize';\n\nexport async function executeToolCall(\n call: ToolCallRequest,\n registry: ToolsRegistry,\n): Promise<ToolCallResult> {\n const entry = registry[call.name];\n const handler = typeof entry === 'function' ? entry : entry?.handler;\n\n if (!handler) {\n return {\n id: call.id,\n name: call.name,\n success: false,\n content: `Tool \"${call.name}\" is not registered.`,\n };\n }\n\n try {\n const output = await handler(call.arguments ?? null);\n\n return {\n id: call.id,\n name: call.name,\n success: true,\n content: serializeToolContent(output),\n };\n } catch (error) {\n return {\n id: call.id,\n name: call.name,\n success: false,\n content: extractToolErrorMessage(error),\n };\n }\n}\n"],"mappings":";;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AAKO,eAAeC,eAAeA,CACnCC,IAAqB,EACrBC,QAAuB,EACE;EACzB,MAAMC,KAAK,GAAGD,QAAQ,CAACD,IAAI,CAACG,IAAI,CAAC;EACjC,MAAMC,OAAO,GAAG,OAAOF,KAAK,KAAK,UAAU,GAAGA,KAAK,GAAGA,KAAK,oBAALA,KAAK,CAAEE,OAAO;EAEpE,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO;MACLC,EAAE,EAAEL,IAAI,CAACK,EAAE;MACXF,IAAI,EAAEH,IAAI,CAACG,IAAI;MACfG,OAAO,EAAE,KAAK;MACdC,OAAO,EAAE,SAASP,IAAI,CAACG,IAAI;IAC7B,CAAC;EACH;EAEA,IAAI;IACF,MAAMK,MAAM,GAAG,MAAMJ,OAAO,CAACJ,IAAI,CAACS,SAAS,IAAI,IAAI,CAAC;IAEpD,OAAO;MACLJ,EAAE,EAAEL,IAAI,CAACK,EAAE;MACXF,IAAI,EAAEH,IAAI,CAACG,IAAI;MACfG,OAAO,EAAE,IAAI;MACbC,OAAO,EAAE,IAAAG,+BAAoB,EAACF,MAAM;IACtC,CAAC;EACH,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,OAAO;MACLN,EAAE,EAAEL,IAAI,CAACK,EAAE;MACXF,IAAI,EAAEH,IAAI,CAACG,IAAI;MACfG,OAAO,EAAE,KAAK;MACdC,OAAO,EAAE,IAAAK,kCAAuB,EAACD,KAAK;IACxC,CAAC;EACH;AACF","ignoreList":[]}
|