@mgamadeus/ddd-agents 0.6.1 → 0.6.3
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 +28 -9
- package/dist/styles.css +6 -1
- package/dist/types/entries/voice.d.ts +2 -2
- package/dist/types/voice/AgentVoiceCallBand/AgentVoiceCallBand.d.ts +16 -0
- package/dist/types/voice/AgentVoiceCallCaptions/AgentVoiceCallCaptions.d.ts +6 -0
- package/dist/types/voice/AgentVoiceChatStartButton/AgentVoiceChatStartButton.d.ts +8 -0
- package/dist/types/voice/AgentVoiceIncomingCall/AgentVoiceIncomingCall.d.ts +11 -0
- package/dist/types/voice/AgentVoiceInputGlow/AgentVoiceInputGlow.d.ts +2 -0
- package/dist/types/voice/agent-voice-api.d.ts +16 -4
- package/dist/types/voice/agent-voice-part-test-id.d.ts +5 -0
- package/dist/voice.js +132 -55
- package/dist/voice.js.map +1 -1
- package/package.json +1 -1
- package/public-api.json +2 -0
package/dist/voice.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useSyncExternalStore, useState, useEffect, useMemo, useRef, useCallback
|
|
|
3
3
|
import { t as textKey } from "./chunks/text-key-DnoZ4lAk.js";
|
|
4
4
|
import { f as formatAgentVoiceCallDuration } from "./chunks/format-agent-voice-call-duration-C-3hRc9p.js";
|
|
5
5
|
import { a as useOptionalAgentsConversationClient } from "./chunks/AgentsConversationClientContext-C4T7g_Qk.js";
|
|
6
|
-
import { c as DEFAULT_AGENTS_TEXTS, ab as useAgentsTexts, K as getAgentDisplayName } from "./chunks/link-navigation-BUcy5qWW.js";
|
|
6
|
+
import { c as DEFAULT_AGENTS_TEXTS, ab as useAgentsTexts, K as getAgentDisplayName, a4 as useAgentsComponents, D as DEFAULT_AGENTS_COMPONENTS } from "./chunks/link-navigation-BUcy5qWW.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { V as VoiceBarsIcon, C as ConversationMessageWidgets, a as ConversationMessageUser } from "./chunks/VoiceBarsIcon-BIcURsBF.js";
|
|
9
9
|
import { a as useOptionalAgentsChatStore, u as useAgentsChatSelector } from "./chunks/use-agents-chat-store-CuIkCz9v.js";
|
|
@@ -24,7 +24,7 @@ const readAgentVoiceErrorCode = (failure) => {
|
|
|
24
24
|
};
|
|
25
25
|
const trimApiPrefix = (apiPrefix) => apiPrefix.replace(/\/+$/, "");
|
|
26
26
|
const callPath = (callId) => `/${encodeURIComponent(String(callId))}`;
|
|
27
|
-
const buildAgentVoiceRequests = (apiPrefix) => {
|
|
27
|
+
const buildAgentVoiceRequests = (apiPrefix, buildOpenPath) => {
|
|
28
28
|
const prefix = trimApiPrefix(apiPrefix);
|
|
29
29
|
return {
|
|
30
30
|
openSession: ({
|
|
@@ -33,7 +33,7 @@ const buildAgentVoiceRequests = (apiPrefix) => {
|
|
|
33
33
|
conversationId,
|
|
34
34
|
callId
|
|
35
35
|
}) => ({
|
|
36
|
-
url: `${prefix}/open
|
|
36
|
+
url: buildOpenPath === void 0 ? `${prefix}/open` : buildOpenPath(agentSpaceId),
|
|
37
37
|
method: "POST",
|
|
38
38
|
body: { agentSpaceId, sdpOffer, conversationId, callId }
|
|
39
39
|
}),
|
|
@@ -70,8 +70,8 @@ const buildAgentVoiceRequests = (apiPrefix) => {
|
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
const AGENT_VOICE_ERROR_CODE_INVALID_OPEN_ANSWER = "invalid_open_answer";
|
|
73
|
-
const createAgentVoiceApi = ({ baseApi, apiPrefix }) => {
|
|
74
|
-
const requests = buildAgentVoiceRequests(apiPrefix);
|
|
73
|
+
const createAgentVoiceApi = ({ baseApi, apiPrefix, buildOpenPath }) => {
|
|
74
|
+
const requests = buildAgentVoiceRequests(apiPrefix, buildOpenPath);
|
|
75
75
|
return {
|
|
76
76
|
openSession: async (args) => {
|
|
77
77
|
const openAnswer = await baseApi.request(requests.openSession(args));
|
|
@@ -632,6 +632,21 @@ const useAgentVoiceCallServerEnd = (subscribeToConversationChanges) => {
|
|
|
632
632
|
};
|
|
633
633
|
}, [isCallActive, callConversationId, callId, subscribeToConversationChanges, conversationClient]);
|
|
634
634
|
};
|
|
635
|
+
const useFollowAgentVoiceCallConversation = (onConversationOfCallChanged) => {
|
|
636
|
+
const callPhase = useAgentVoiceCallValue((call) => call.phase);
|
|
637
|
+
const callId = useAgentVoiceCallValue((call) => call.callId);
|
|
638
|
+
const callConversationId = useAgentVoiceCallValue((call) => call.conversationId);
|
|
639
|
+
const callAgentSpaceId = useAgentVoiceCallValue((call) => call.agentSpaceId);
|
|
640
|
+
const reportedCallAndConversationRef = useRef(void 0);
|
|
641
|
+
useEffect(() => {
|
|
642
|
+
if (onConversationOfCallChanged === void 0) return;
|
|
643
|
+
if (!isAgentVoiceCallActive(callPhase) || callId === void 0 || callConversationId === void 0) return;
|
|
644
|
+
const callAndConversation = `${callId}:${callConversationId}`;
|
|
645
|
+
if (reportedCallAndConversationRef.current === callAndConversation) return;
|
|
646
|
+
reportedCallAndConversationRef.current = callAndConversation;
|
|
647
|
+
onConversationOfCallChanged(callConversationId, callAgentSpaceId);
|
|
648
|
+
}, [callPhase, callId, callConversationId, callAgentSpaceId, onConversationOfCallChanged]);
|
|
649
|
+
};
|
|
635
650
|
const SENTENCE_PATTERN = /[^.!?…]+[.!?…]*\s*/g;
|
|
636
651
|
const normalizeForMatching = (text) => text.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "");
|
|
637
652
|
const buildUnsavedAgentVoiceCallLines = (lines, savedMessages) => {
|
|
@@ -899,21 +914,6 @@ const useAgentVoiceRingTone = (isRinging) => {
|
|
|
899
914
|
};
|
|
900
915
|
}, [isRinging]);
|
|
901
916
|
};
|
|
902
|
-
const useFollowAgentVoiceCallConversation = (onConversationOfCallChanged) => {
|
|
903
|
-
const callPhase = useAgentVoiceCallValue((call) => call.phase);
|
|
904
|
-
const callId = useAgentVoiceCallValue((call) => call.callId);
|
|
905
|
-
const callConversationId = useAgentVoiceCallValue((call) => call.conversationId);
|
|
906
|
-
const callAgentSpaceId = useAgentVoiceCallValue((call) => call.agentSpaceId);
|
|
907
|
-
const reportedCallAndConversationRef = useRef(void 0);
|
|
908
|
-
useEffect(() => {
|
|
909
|
-
if (onConversationOfCallChanged === void 0) return;
|
|
910
|
-
if (!isAgentVoiceCallActive(callPhase) || callId === void 0 || callConversationId === void 0) return;
|
|
911
|
-
const callAndConversation = `${callId}:${callConversationId}`;
|
|
912
|
-
if (reportedCallAndConversationRef.current === callAndConversation) return;
|
|
913
|
-
reportedCallAndConversationRef.current = callAndConversation;
|
|
914
|
-
onConversationOfCallChanged(callConversationId, callAgentSpaceId);
|
|
915
|
-
}, [callPhase, callId, callConversationId, callAgentSpaceId, onConversationOfCallChanged]);
|
|
916
|
-
};
|
|
917
917
|
const AgentVoiceCallContext = createContext({ ringSource: void 0 });
|
|
918
918
|
const useAgentVoiceRingSource = () => useContext(AgentVoiceCallContext).ringSource;
|
|
919
919
|
const useAgentVoiceTranslateText = () => {
|
|
@@ -937,24 +937,32 @@ const startButton = "agents_startButton_DMqIXK";
|
|
|
937
937
|
const styles$5 = {
|
|
938
938
|
startButton
|
|
939
939
|
};
|
|
940
|
+
const LABEL_TEXT_KEY = textKey("Talk to %agentName%");
|
|
940
941
|
const AgentVoiceChatStartButton = (props) => {
|
|
941
|
-
const { agentSpaceId, conversationId, disabled = false, testId = "agent-voice-chat-start" } = props;
|
|
942
|
+
const { agentSpaceId, conversationId, disabled = false, onStart, testId = "agent-voice-chat-start" } = props;
|
|
942
943
|
const translateText = useAgentVoiceTranslateText();
|
|
943
944
|
const isCallActive = useIsAgentVoiceCallActive();
|
|
944
|
-
const
|
|
945
|
-
|
|
945
|
+
const { Tooltip } = useAgentsComponents();
|
|
946
|
+
const hasEnvironmentTooltip = Tooltip !== DEFAULT_AGENTS_COMPONENTS.Tooltip;
|
|
947
|
+
const label2 = translateText(LABEL_TEXT_KEY);
|
|
948
|
+
const startButton2 = /* @__PURE__ */ jsx(
|
|
946
949
|
"button",
|
|
947
950
|
{
|
|
948
951
|
type: "button",
|
|
949
952
|
className: styles$5.startButton,
|
|
950
|
-
onClick: () =>
|
|
953
|
+
onClick: () => {
|
|
954
|
+
onStart?.();
|
|
955
|
+
void startAgentVoiceCall({ agentSpaceId, conversationId });
|
|
956
|
+
},
|
|
951
957
|
disabled: disabled || isCallActive,
|
|
952
958
|
"aria-label": label2,
|
|
953
|
-
title: label2,
|
|
959
|
+
title: hasEnvironmentTooltip ? void 0 : label2,
|
|
954
960
|
"data-testid": testId,
|
|
955
961
|
children: /* @__PURE__ */ jsx(VoiceBarsIcon, { size: 18 })
|
|
956
962
|
}
|
|
957
963
|
);
|
|
964
|
+
if (!hasEnvironmentTooltip) return startButton2;
|
|
965
|
+
return /* @__PURE__ */ jsx(Tooltip, { text: LABEL_TEXT_KEY, replacements: { agentName: getAgentDisplayName() }, placement: "top", wrapsChild: true, children: startButton2 });
|
|
958
966
|
};
|
|
959
967
|
const icon = "agents_icon_VX-p0I";
|
|
960
968
|
const styles$4 = {
|
|
@@ -970,6 +978,7 @@ const AgentVoiceHangUpIcon = (props) => renderLineIcon(
|
|
|
970
978
|
/* @__PURE__ */ jsx("path", { d: "M3.5 14.5c4.7-4.7 12.3-4.7 17 0l-2.2 2.2-3.1-1.4v-2.4a9.6 9.6 0 0 0-6.4 0v2.4l-3.1 1.4-2.2-2.2Z" })
|
|
971
979
|
);
|
|
972
980
|
const AgentVoiceCloseIcon = (props) => renderLineIcon(props.size ?? 16, /* @__PURE__ */ jsx("path", { d: "M6 6l12 12M18 6 6 18" }));
|
|
981
|
+
const agentVoicePartTestId = (testId, part, defaultTestId) => testId === void 0 ? defaultTestId : `${testId}-${part}`;
|
|
973
982
|
const endedAgentVoiceCallTitleTextKey = (call) => {
|
|
974
983
|
if (call.endReason === AGENT_VOICE_CALL_END_REASON_ENDED_BY_AGENT) return textKey("%agentName% ended the voice chat");
|
|
975
984
|
if (call.endReason === AGENT_VOICE_CALL_END_REASON_LIMIT_REACHED) return textKey("Voice chat limit reached");
|
|
@@ -987,6 +996,7 @@ const status = "agents_status_saTxLl";
|
|
|
987
996
|
const title = "agents_title_PBN6ka";
|
|
988
997
|
const time = "agents_time_aaWlsN";
|
|
989
998
|
const actions$1 = "agents_actions_uyJzPl";
|
|
999
|
+
const applicationActions = "agents_applicationActions_b5QBp8";
|
|
990
1000
|
const action$1 = "agents_action_z96Tb1";
|
|
991
1001
|
const actionLabel = "agents_actionLabel_ItbQmp";
|
|
992
1002
|
const styles$3 = {
|
|
@@ -998,6 +1008,7 @@ const styles$3 = {
|
|
|
998
1008
|
title,
|
|
999
1009
|
time,
|
|
1000
1010
|
actions: actions$1,
|
|
1011
|
+
applicationActions,
|
|
1001
1012
|
action: action$1,
|
|
1002
1013
|
actionLabel
|
|
1003
1014
|
};
|
|
@@ -1010,6 +1021,13 @@ const TURN_STATUS_TEXT_KEYS = {
|
|
|
1010
1021
|
thinking: textKey("%agentName% is thinking"),
|
|
1011
1022
|
listening: textKey("%agentName% is listening")
|
|
1012
1023
|
};
|
|
1024
|
+
const DEFAULT_TEST_ID = "agent-voice-call-band";
|
|
1025
|
+
const hasApplicationActions = (actions2) => actions2 !== void 0 && actions2 !== null && actions2 !== false;
|
|
1026
|
+
const AgentVoiceBandApplicationActions = (props) => {
|
|
1027
|
+
const { actions: actions2, testId } = props;
|
|
1028
|
+
if (!hasApplicationActions(actions2)) return null;
|
|
1029
|
+
return /* @__PURE__ */ jsx("div", { className: styles$3.applicationActions, "data-testid": testId, children: actions2 });
|
|
1030
|
+
};
|
|
1013
1031
|
const AgentVoiceBandAction = (props) => {
|
|
1014
1032
|
const { label: label2, icon: icon2, onClick, testId, iconOnly = false, pressed, variant, disabled = false } = props;
|
|
1015
1033
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1031,20 +1049,29 @@ const AgentVoiceBandAction = (props) => {
|
|
|
1031
1049
|
);
|
|
1032
1050
|
};
|
|
1033
1051
|
const AgentVoiceCallBandView = (props) => {
|
|
1034
|
-
const { call, elapsedSeconds, onStartVoiceChat, incoming, agentSpot } = props;
|
|
1052
|
+
const { call, elapsedSeconds, onStartVoiceChat, incoming, agentSpot, actions: actions2, testId } = props;
|
|
1035
1053
|
const translateText = useAgentVoiceTranslateText();
|
|
1036
1054
|
const duration = formatAgentVoiceCallDuration(elapsedSeconds);
|
|
1037
1055
|
const agentName = getAgentDisplayName();
|
|
1056
|
+
const bandTestId = testId ?? DEFAULT_TEST_ID;
|
|
1057
|
+
const applicationActions2 = /* @__PURE__ */ jsx(
|
|
1058
|
+
AgentVoiceBandApplicationActions,
|
|
1059
|
+
{
|
|
1060
|
+
actions: actions2,
|
|
1061
|
+
testId: agentVoicePartTestId(testId, "actions", "agent-voice-call-band-actions")
|
|
1062
|
+
}
|
|
1063
|
+
);
|
|
1038
1064
|
const spot2 = agentSpot === void 0 || agentSpot === null ? null : /* @__PURE__ */ jsx("div", { className: styles$3.spot, children: agentSpot });
|
|
1039
1065
|
if (isAgentVoiceCallActive(call.phase)) {
|
|
1040
|
-
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid":
|
|
1066
|
+
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid": bandTestId, "data-phase": call.phase, children: /* @__PURE__ */ jsxs("div", { className: styles$3.content, children: [
|
|
1041
1067
|
spot2,
|
|
1042
1068
|
/* @__PURE__ */ jsxs("div", { className: styles$3.who, "aria-live": "polite", children: [
|
|
1043
1069
|
/* @__PURE__ */ jsx("span", { className: styles$3.title, children: agentName }),
|
|
1044
1070
|
call.phase === "live" && /* @__PURE__ */ jsx("span", { className: styles$3.time, children: duration }),
|
|
1045
|
-
/* @__PURE__ */ jsx("span", { className: styles$3.status, "data-testid": "agent-voice-call-status", children: translateText(TURN_STATUS_TEXT_KEYS[turnOfAgentVoiceCall(call)]) })
|
|
1071
|
+
/* @__PURE__ */ jsx("span", { className: styles$3.status, "data-testid": agentVoicePartTestId(testId, "status", "agent-voice-call-status"), children: translateText(TURN_STATUS_TEXT_KEYS[turnOfAgentVoiceCall(call)]) })
|
|
1046
1072
|
] }),
|
|
1047
1073
|
/* @__PURE__ */ jsxs("div", { className: styles$3.actions, children: [
|
|
1074
|
+
applicationActions2,
|
|
1048
1075
|
/* @__PURE__ */ jsx(
|
|
1049
1076
|
AgentVoiceBandAction,
|
|
1050
1077
|
{
|
|
@@ -1053,7 +1080,7 @@ const AgentVoiceCallBandView = (props) => {
|
|
|
1053
1080
|
onClick: toggleAgentVoiceCallMute,
|
|
1054
1081
|
pressed: call.isMuted,
|
|
1055
1082
|
disabled: call.phase !== "live",
|
|
1056
|
-
testId: "agent-voice-call-mute"
|
|
1083
|
+
testId: agentVoicePartTestId(testId, "mute", "agent-voice-call-mute")
|
|
1057
1084
|
}
|
|
1058
1085
|
),
|
|
1059
1086
|
/* @__PURE__ */ jsx(
|
|
@@ -1063,7 +1090,7 @@ const AgentVoiceCallBandView = (props) => {
|
|
|
1063
1090
|
icon: /* @__PURE__ */ jsx(AgentVoiceHangUpIcon, {}),
|
|
1064
1091
|
onClick: () => hangUpAgentVoiceCall(),
|
|
1065
1092
|
variant: "end",
|
|
1066
|
-
testId: "agent-voice-call-end"
|
|
1093
|
+
testId: agentVoicePartTestId(testId, "end", "agent-voice-call-end")
|
|
1067
1094
|
}
|
|
1068
1095
|
)
|
|
1069
1096
|
] })
|
|
@@ -1071,13 +1098,14 @@ const AgentVoiceCallBandView = (props) => {
|
|
|
1071
1098
|
}
|
|
1072
1099
|
if (incoming?.ring) {
|
|
1073
1100
|
const callerLabel = incoming.callerLabel ?? buildAgentVoiceCallerLabel(incoming.ring, translateText, agentName);
|
|
1074
|
-
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid":
|
|
1101
|
+
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid": bandTestId, "data-phase": "incoming", children: /* @__PURE__ */ jsxs("div", { className: styles$3.content, children: [
|
|
1075
1102
|
spot2,
|
|
1076
1103
|
/* @__PURE__ */ jsxs("div", { className: styles$3.who, role: "alert", children: [
|
|
1077
1104
|
/* @__PURE__ */ jsx("span", { className: styles$3.title, children: callerLabel.text }),
|
|
1078
1105
|
callerLabel.detail ? /* @__PURE__ */ jsx("span", { className: styles$3.status, children: callerLabel.detail }) : null
|
|
1079
1106
|
] }),
|
|
1080
1107
|
/* @__PURE__ */ jsxs("div", { className: styles$3.actions, children: [
|
|
1108
|
+
applicationActions2,
|
|
1081
1109
|
/* @__PURE__ */ jsx(
|
|
1082
1110
|
AgentVoiceBandAction,
|
|
1083
1111
|
{
|
|
@@ -1086,7 +1114,7 @@ const AgentVoiceCallBandView = (props) => {
|
|
|
1086
1114
|
onClick: incoming.onDecline,
|
|
1087
1115
|
variant: "end",
|
|
1088
1116
|
disabled: incoming.isAnswering,
|
|
1089
|
-
testId: "agent-voice-call-incoming-decline"
|
|
1117
|
+
testId: agentVoicePartTestId(testId, "incoming-decline", "agent-voice-call-incoming-decline")
|
|
1090
1118
|
}
|
|
1091
1119
|
),
|
|
1092
1120
|
/* @__PURE__ */ jsx(
|
|
@@ -1097,32 +1125,43 @@ const AgentVoiceCallBandView = (props) => {
|
|
|
1097
1125
|
onClick: incoming.onAccept,
|
|
1098
1126
|
variant: "accept",
|
|
1099
1127
|
disabled: incoming.isAnswering,
|
|
1100
|
-
testId: "agent-voice-call-incoming-accept"
|
|
1128
|
+
testId: agentVoicePartTestId(testId, "incoming-accept", "agent-voice-call-incoming-accept")
|
|
1101
1129
|
}
|
|
1102
1130
|
)
|
|
1103
1131
|
] })
|
|
1104
1132
|
] }, "incoming") });
|
|
1105
1133
|
}
|
|
1106
1134
|
if (incoming?.refusal && call.phase === "idle") {
|
|
1107
|
-
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid":
|
|
1135
|
+
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid": bandTestId, "data-phase": "refused", children: /* @__PURE__ */ jsxs("div", { className: styles$3.content, children: [
|
|
1136
|
+
/* @__PURE__ */ jsx("div", { className: styles$3.who, role: "status", children: /* @__PURE__ */ jsx(
|
|
1137
|
+
"span",
|
|
1138
|
+
{
|
|
1139
|
+
className: styles$3.status,
|
|
1140
|
+
"data-testid": agentVoicePartTestId(testId, "incoming-refusal", "agent-voice-call-incoming-refusal"),
|
|
1141
|
+
children: translateText(AGENT_VOICE_ANSWER_REFUSAL_TEXT_KEYS[incoming.refusal])
|
|
1142
|
+
}
|
|
1143
|
+
) }),
|
|
1144
|
+
hasApplicationActions(actions2) ? /* @__PURE__ */ jsx("div", { className: styles$3.actions, children: applicationActions2 }) : null
|
|
1145
|
+
] }, "refused") });
|
|
1108
1146
|
}
|
|
1109
1147
|
if (call.phase !== "ended" && call.phase !== "failed") return null;
|
|
1110
1148
|
const wasConnected = call.connectedAtMs !== void 0;
|
|
1111
1149
|
const titleTextKey = agentVoiceCallOutcomeTitleTextKey(call);
|
|
1112
|
-
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid":
|
|
1150
|
+
return /* @__PURE__ */ jsx("div", { className: styles$3.band, "data-testid": bandTestId, "data-phase": call.phase, "data-end-reason": call.endReason, children: /* @__PURE__ */ jsxs("div", { className: styles$3.content, children: [
|
|
1113
1151
|
/* @__PURE__ */ jsxs("div", { className: styles$3.who, "aria-live": "polite", children: [
|
|
1114
1152
|
/* @__PURE__ */ jsx(
|
|
1115
1153
|
"span",
|
|
1116
1154
|
{
|
|
1117
1155
|
className: styles$3.title,
|
|
1118
|
-
"data-testid": call.phase === "ended" && wasConnected ? "agent-voice-call-ended-status" : void 0,
|
|
1156
|
+
"data-testid": call.phase === "ended" && wasConnected ? agentVoicePartTestId(testId, "ended-status", "agent-voice-call-ended-status") : void 0,
|
|
1119
1157
|
children: translateText(titleTextKey)
|
|
1120
1158
|
}
|
|
1121
1159
|
),
|
|
1122
1160
|
call.phase === "ended" && wasConnected && /* @__PURE__ */ jsx("span", { className: styles$3.time, children: duration }),
|
|
1123
|
-
call.phase === "failed" && call.failureTextKey && /* @__PURE__ */ jsx("span", { className: styles$3.status, "data-testid": "agent-voice-call-failure", children: translateText(call.failureTextKey) })
|
|
1161
|
+
call.phase === "failed" && call.failureTextKey && /* @__PURE__ */ jsx("span", { className: styles$3.status, "data-testid": agentVoicePartTestId(testId, "failure", "agent-voice-call-failure"), children: translateText(call.failureTextKey) })
|
|
1124
1162
|
] }),
|
|
1125
1163
|
/* @__PURE__ */ jsxs("div", { className: styles$3.actions, children: [
|
|
1164
|
+
applicationActions2,
|
|
1126
1165
|
/* @__PURE__ */ jsx(
|
|
1127
1166
|
AgentVoiceBandAction,
|
|
1128
1167
|
{
|
|
@@ -1130,7 +1169,7 @@ const AgentVoiceCallBandView = (props) => {
|
|
|
1130
1169
|
icon: /* @__PURE__ */ jsx(VoiceBarsIcon, { size: 16 }),
|
|
1131
1170
|
onClick: onStartVoiceChat,
|
|
1132
1171
|
variant: "accept",
|
|
1133
|
-
testId: "agent-voice-call-start-again"
|
|
1172
|
+
testId: agentVoicePartTestId(testId, "start-again", "agent-voice-call-start-again")
|
|
1134
1173
|
}
|
|
1135
1174
|
),
|
|
1136
1175
|
/* @__PURE__ */ jsx(
|
|
@@ -1140,14 +1179,14 @@ const AgentVoiceCallBandView = (props) => {
|
|
|
1140
1179
|
icon: /* @__PURE__ */ jsx(AgentVoiceCloseIcon, {}),
|
|
1141
1180
|
onClick: dismissAgentVoiceCallOutcome,
|
|
1142
1181
|
iconOnly: true,
|
|
1143
|
-
testId: "agent-voice-call-band-close"
|
|
1182
|
+
testId: agentVoicePartTestId(testId, "close", "agent-voice-call-band-close")
|
|
1144
1183
|
}
|
|
1145
1184
|
)
|
|
1146
1185
|
] })
|
|
1147
1186
|
] }, call.phase) });
|
|
1148
1187
|
};
|
|
1149
1188
|
const AgentVoiceCallBand = (props) => {
|
|
1150
|
-
const { renderAgentSpot, agentSpaceId, isPresented = true } = props;
|
|
1189
|
+
const { renderAgentSpot, agentSpaceId, isPresented = true, actions: actions2, testId } = props;
|
|
1151
1190
|
const liveCall = useAgentVoiceCallSnapshot();
|
|
1152
1191
|
const call = isAgentVoiceCallShownInAgentSpace(liveCall, agentSpaceId) ? liveCall : IDLE_AGENT_VOICE_CALL;
|
|
1153
1192
|
const elapsedSeconds = useAgentVoiceCallElapsedSeconds(call);
|
|
@@ -1159,6 +1198,8 @@ const AgentVoiceCallBand = (props) => {
|
|
|
1159
1198
|
call,
|
|
1160
1199
|
elapsedSeconds,
|
|
1161
1200
|
agentSpot: renderAgentSpot?.(call),
|
|
1201
|
+
actions: actions2,
|
|
1202
|
+
testId,
|
|
1162
1203
|
onStartVoiceChat: () => void startAgentVoiceCall({ agentSpaceId: call.agentSpaceId ?? agentSpaceId, conversationId: call.conversationId }),
|
|
1163
1204
|
incoming: {
|
|
1164
1205
|
ring,
|
|
@@ -1184,7 +1225,7 @@ const styles$2 = {
|
|
|
1184
1225
|
const NO_MESSAGES = [];
|
|
1185
1226
|
const selectMessages = (state) => state.messages;
|
|
1186
1227
|
const AgentVoiceCallCaptionLines = (props) => {
|
|
1187
|
-
const { call, ownerMessageTheme } = props;
|
|
1228
|
+
const { call, ownerMessageTheme, testId } = props;
|
|
1188
1229
|
const chatStore = useOptionalAgentsChatStore();
|
|
1189
1230
|
const messages = useAgentsChatSelector(chatStore, selectMessages, null) ?? NO_MESSAGES;
|
|
1190
1231
|
const [highestIndexBeforeVoiceChat, setHighestIndexBeforeVoiceChat] = useState(void 0);
|
|
@@ -1195,15 +1236,31 @@ const AgentVoiceCallCaptionLines = (props) => {
|
|
|
1195
1236
|
() => highestIndexBeforeVoiceChat === void 0 ? [] : buildUnsavedAgentVoiceCallLines(call.lines, savedMessagesOfTheVoiceChat(messages, highestIndexBeforeVoiceChat)),
|
|
1196
1237
|
[call.lines, messages, highestIndexBeforeVoiceChat]
|
|
1197
1238
|
);
|
|
1198
|
-
return /* @__PURE__ */ jsx("div", { className: styles$2.captions, "data-testid": "agent-voice-call-captions", children: unsavedLines.map(
|
|
1199
|
-
(line2) => line2.speaker === "agent" ? /* @__PURE__ */ jsx(
|
|
1239
|
+
return /* @__PURE__ */ jsx("div", { className: styles$2.captions, "data-testid": testId ?? "agent-voice-call-captions", children: unsavedLines.map(
|
|
1240
|
+
(line2) => line2.speaker === "agent" ? /* @__PURE__ */ jsx(
|
|
1241
|
+
"div",
|
|
1242
|
+
{
|
|
1243
|
+
className: styles$2.line,
|
|
1244
|
+
"data-testid": agentVoicePartTestId(testId, "caption-agent", "agent-voice-call-caption-agent"),
|
|
1245
|
+
children: /* @__PURE__ */ jsx(ConversationMessageWidgets, { message: line2.text, interactive: false, justDelivered: false, hideAssistantMeta: true })
|
|
1246
|
+
},
|
|
1247
|
+
line2.id
|
|
1248
|
+
) : /* @__PURE__ */ jsx(
|
|
1249
|
+
"div",
|
|
1250
|
+
{
|
|
1251
|
+
className: styles$2.line,
|
|
1252
|
+
"data-testid": agentVoicePartTestId(testId, "caption-owner", "agent-voice-call-caption-owner"),
|
|
1253
|
+
children: /* @__PURE__ */ jsx(ConversationMessageUser, { text: line2.text, theme: ownerMessageTheme })
|
|
1254
|
+
},
|
|
1255
|
+
line2.id
|
|
1256
|
+
)
|
|
1200
1257
|
) });
|
|
1201
1258
|
};
|
|
1202
1259
|
const AgentVoiceCallCaptions = (props) => {
|
|
1203
|
-
const { agentSpaceId, ownerMessageTheme } = props;
|
|
1260
|
+
const { agentSpaceId, ownerMessageTheme, testId } = props;
|
|
1204
1261
|
const call = useAgentVoiceCallSnapshot();
|
|
1205
1262
|
if (!isAgentVoiceCallActive(call.phase) || !isAgentVoiceCallShownInAgentSpace(call, agentSpaceId)) return null;
|
|
1206
|
-
return /* @__PURE__ */ jsx(AgentVoiceCallCaptionLines, { call, ownerMessageTheme });
|
|
1263
|
+
return /* @__PURE__ */ jsx(AgentVoiceCallCaptionLines, { call, ownerMessageTheme, testId });
|
|
1207
1264
|
};
|
|
1208
1265
|
const glowVoiceOfAgentVoiceCallTurn = (turn) => {
|
|
1209
1266
|
if (turn === "agent") return "agent";
|
|
@@ -1234,7 +1291,8 @@ const GLOW_COLOUR_PROPERTIES = [
|
|
|
1234
1291
|
["--agents-voice-glow-color-4", "#12ffff"],
|
|
1235
1292
|
["--agents-voice-glow-color-1", "#00495d"]
|
|
1236
1293
|
];
|
|
1237
|
-
const AgentVoiceInputGlowCanvases = () => {
|
|
1294
|
+
const AgentVoiceInputGlowCanvases = (props) => {
|
|
1295
|
+
const { testId } = props;
|
|
1238
1296
|
const voice = useAgentVoiceCallValue(
|
|
1239
1297
|
(call) => isAgentVoiceCallActive(call.phase) ? glowVoiceOfAgentVoiceCallTurn(turnOfAgentVoiceCall(call)) : "quiet"
|
|
1240
1298
|
);
|
|
@@ -1372,15 +1430,15 @@ const AgentVoiceInputGlowCanvases = () => {
|
|
|
1372
1430
|
field?.removeEventListener("focusin", startBurst);
|
|
1373
1431
|
};
|
|
1374
1432
|
}, []);
|
|
1375
|
-
return /* @__PURE__ */ jsxs("div", { ref: boxRef, className: styles$1.glow, "aria-hidden": true, "data-testid":
|
|
1433
|
+
return /* @__PURE__ */ jsxs("div", { ref: boxRef, className: styles$1.glow, "aria-hidden": true, "data-testid": testId, children: [
|
|
1376
1434
|
/* @__PURE__ */ jsx("canvas", { ref: haloCanvasRef, className: styles$1.halo }),
|
|
1377
1435
|
/* @__PURE__ */ jsx("canvas", { ref: edgeCanvasRef, className: styles$1.edge })
|
|
1378
1436
|
] });
|
|
1379
1437
|
};
|
|
1380
1438
|
const AgentVoiceInputGlow = (props) => {
|
|
1381
|
-
const { agentSpaceId } = props;
|
|
1439
|
+
const { agentSpaceId, testId = "agent-voice-input-glow" } = props;
|
|
1382
1440
|
const isCallActiveHere = useIsAgentVoiceCallActive(agentSpaceId);
|
|
1383
|
-
return isCallActiveHere ? /* @__PURE__ */ jsx(AgentVoiceInputGlowCanvases, {}) : null;
|
|
1441
|
+
return isCallActiveHere ? /* @__PURE__ */ jsx(AgentVoiceInputGlowCanvases, { testId }) : null;
|
|
1384
1442
|
};
|
|
1385
1443
|
const withAgentVoiceIncomingRing = (heldRings, ring) => [...heldRings.filter((heldRing) => heldRing.callId !== ring.callId), ring];
|
|
1386
1444
|
const withoutAgentVoiceIncomingRingOfCall = (heldRings, callId) => heldRings.filter((heldRing) => heldRing.callId !== callId);
|
|
@@ -1435,7 +1493,7 @@ const styles = {
|
|
|
1435
1493
|
action
|
|
1436
1494
|
};
|
|
1437
1495
|
const AgentVoiceIncomingCall = (props) => {
|
|
1438
|
-
const { resolveCallerLabel, renderAgentSpot } = props;
|
|
1496
|
+
const { resolveCallerLabel, renderAgentSpot, zIndex, testId } = props;
|
|
1439
1497
|
const translateText = useAgentVoiceTranslateText();
|
|
1440
1498
|
const ringSource = useAgentVoiceRingSource();
|
|
1441
1499
|
const isCallActive = useAgentVoiceCallValue((call) => isAgentVoiceCallActive(call.phase));
|
|
@@ -1455,10 +1513,20 @@ const AgentVoiceIncomingCall = (props) => {
|
|
|
1455
1513
|
useAgentVoiceRingTone(ring !== void 0 && !isAnswering);
|
|
1456
1514
|
const card = ringSource !== void 0 ? pickAgentVoiceIncomingCard({ ring, refusal, bandHostCount, ringCoverCount }) : void 0;
|
|
1457
1515
|
const callerLabelId = useId();
|
|
1516
|
+
const layerStyle = zIndex === void 0 ? void 0 : { zIndex };
|
|
1458
1517
|
if (card === void 0) return null;
|
|
1459
1518
|
if (ring === void 0) {
|
|
1460
1519
|
if (refusal === void 0) return null;
|
|
1461
|
-
return /* @__PURE__ */ jsx(
|
|
1520
|
+
return /* @__PURE__ */ jsx(
|
|
1521
|
+
"div",
|
|
1522
|
+
{
|
|
1523
|
+
className: styles.incomingCall,
|
|
1524
|
+
style: layerStyle,
|
|
1525
|
+
role: "status",
|
|
1526
|
+
"data-testid": agentVoicePartTestId(testId, "refusal", "agent-voice-incoming-call-refusal"),
|
|
1527
|
+
children: /* @__PURE__ */ jsx("span", { className: styles.detail, children: translateText(AGENT_VOICE_ANSWER_REFUSAL_TEXT_KEYS[refusal]) })
|
|
1528
|
+
}
|
|
1529
|
+
);
|
|
1462
1530
|
}
|
|
1463
1531
|
const shownCallerLabel = callerLabel ?? buildAgentVoiceCallerLabel(ring, translateText, getAgentDisplayName());
|
|
1464
1532
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1468,12 +1536,20 @@ const AgentVoiceIncomingCall = (props) => {
|
|
|
1468
1536
|
role: "alertdialog",
|
|
1469
1537
|
"aria-live": "assertive",
|
|
1470
1538
|
"aria-labelledby": callerLabelId,
|
|
1471
|
-
|
|
1539
|
+
style: layerStyle,
|
|
1540
|
+
"data-testid": testId ?? "agent-voice-incoming-call",
|
|
1472
1541
|
children: [
|
|
1473
1542
|
/* @__PURE__ */ jsx("div", { className: styles.spot, children: renderAgentSpot ? renderAgentSpot() : /* @__PURE__ */ jsx("span", { className: styles.mark, children: /* @__PURE__ */ jsx(VoiceBarsIcon, { size: 24 }) }) }),
|
|
1474
1543
|
/* @__PURE__ */ jsxs("div", { className: styles.caller, id: callerLabelId, children: [
|
|
1475
1544
|
/* @__PURE__ */ jsx("span", { className: styles.label, children: shownCallerLabel.text }),
|
|
1476
|
-
shownCallerLabel.detail ? /* @__PURE__ */ jsx(
|
|
1545
|
+
shownCallerLabel.detail ? /* @__PURE__ */ jsx(
|
|
1546
|
+
"span",
|
|
1547
|
+
{
|
|
1548
|
+
className: styles.detail,
|
|
1549
|
+
"data-testid": agentVoicePartTestId(testId, "detail", "agent-voice-incoming-call-detail"),
|
|
1550
|
+
children: shownCallerLabel.detail
|
|
1551
|
+
}
|
|
1552
|
+
) : null
|
|
1477
1553
|
] }),
|
|
1478
1554
|
/* @__PURE__ */ jsxs("div", { className: styles.actions, children: [
|
|
1479
1555
|
/* @__PURE__ */ jsxs(
|
|
@@ -1483,7 +1559,7 @@ const AgentVoiceIncomingCall = (props) => {
|
|
|
1483
1559
|
className: styles.action,
|
|
1484
1560
|
disabled: isAnswering,
|
|
1485
1561
|
onClick: declineAgentVoiceIncomingRing,
|
|
1486
|
-
"data-testid": "agent-voice-incoming-call-decline",
|
|
1562
|
+
"data-testid": agentVoicePartTestId(testId, "decline", "agent-voice-incoming-call-decline"),
|
|
1487
1563
|
children: [
|
|
1488
1564
|
/* @__PURE__ */ jsx(AgentVoiceCloseIcon, {}),
|
|
1489
1565
|
/* @__PURE__ */ jsx("span", { children: translateText("Decline") })
|
|
@@ -1498,7 +1574,7 @@ const AgentVoiceIncomingCall = (props) => {
|
|
|
1498
1574
|
"data-variant": "accept",
|
|
1499
1575
|
disabled: isAnswering,
|
|
1500
1576
|
onClick: () => void acceptAgentVoiceIncomingRing(),
|
|
1501
|
-
"data-testid": "agent-voice-incoming-call-accept",
|
|
1577
|
+
"data-testid": agentVoicePartTestId(testId, "accept", "agent-voice-incoming-call-accept"),
|
|
1502
1578
|
children: [
|
|
1503
1579
|
/* @__PURE__ */ jsx(AgentVoiceMicrophoneIcon, {}),
|
|
1504
1580
|
/* @__PURE__ */ jsx("span", { children: translateText("Accept") })
|
|
@@ -1563,6 +1639,7 @@ export {
|
|
|
1563
1639
|
useAgentVoiceRingCover,
|
|
1564
1640
|
useAgentVoiceRingTone,
|
|
1565
1641
|
useAgentVoiceTranslateText,
|
|
1642
|
+
useFollowAgentVoiceCallConversation,
|
|
1566
1643
|
useIsAgentVoiceCallActive
|
|
1567
1644
|
};
|
|
1568
1645
|
//# sourceMappingURL=voice.js.map
|