@memberjunction/realtime-widget 6.2.0-edge.5 → 6.2.0-edge.7
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 +11 -2
- package/dist/embed/chunks/UserViewEngine-H2CVAVG5.js +7 -0
- package/dist/embed/chunks/chunk-46L5OHPT.js +163629 -0
- package/dist/embed/chunks/chunk-4IZZL4GA.js +2513 -0
- package/dist/embed/chunks/chunk-FOFOZNZC.js +6165 -0
- package/dist/embed/chunks/chunk-MQPAK26D.js +39413 -0
- package/dist/embed/chunks/chunk-S3LX5KYE.js +46 -0
- package/dist/embed/chunks/chunk-VXA62VEQ.js +17259 -0
- package/dist/embed/chunks/dist-S5YIFSWR.js +66 -0
- package/dist/embed/chunks/guest-tool-relay-2MP5GU67.js +30 -0
- package/dist/embed/chunks/guest-voice-mint-MNMKTI3E.js +94 -0
- package/dist/embed/chunks/realtime-voice-controller-D2GLGIK2.js +30589 -0
- package/dist/embed/chunks/runtime-widget-transport-V7B2B3TL.js +162 -0
- package/dist/embed/mj-widget.js +1056 -0
- package/dist/embed.js +3 -2
- package/dist/embed.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +9 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +56 -7
- package/dist/loader.js.map +1 -1
- package/dist/session/widget-session-client.d.ts +46 -5
- package/dist/session/widget-session-client.d.ts.map +1 -1
- package/dist/session/widget-session-client.js +118 -17
- package/dist/session/widget-session-client.js.map +1 -1
- package/dist/transport/runtime-widget-transport.d.ts +0 -6
- package/dist/transport/runtime-widget-transport.d.ts.map +1 -1
- package/dist/transport/runtime-widget-transport.js +3 -31
- package/dist/transport/runtime-widget-transport.js.map +1 -1
- package/package.json +10 -10
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// dist/voice/voice-abuse-guard.js
|
|
2
|
+
var DEFAULT_VOICE_LIMITS = {
|
|
3
|
+
maxSessionMinutes: 10,
|
|
4
|
+
maxOutputTokens: 5e4
|
|
5
|
+
};
|
|
6
|
+
var VoiceAbuseGuard = class {
|
|
7
|
+
constructor(limits = DEFAULT_VOICE_LIMITS) {
|
|
8
|
+
this.limits = limits;
|
|
9
|
+
this.startedAtMs = null;
|
|
10
|
+
this.outputTokens = 0;
|
|
11
|
+
}
|
|
12
|
+
/** Marks the session start. */
|
|
13
|
+
Start(nowMs) {
|
|
14
|
+
this.startedAtMs = nowMs;
|
|
15
|
+
this.outputTokens = 0;
|
|
16
|
+
}
|
|
17
|
+
/** Accumulates reported output-token usage. */
|
|
18
|
+
AddUsage(outputTokens) {
|
|
19
|
+
if (outputTokens && outputTokens > 0) {
|
|
20
|
+
this.outputTokens += outputTokens;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Returns an abort reason if a ceiling has been crossed, else null. */
|
|
24
|
+
ShouldAbort(nowMs) {
|
|
25
|
+
if (this.startedAtMs === null) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const elapsedMin = (nowMs - this.startedAtMs) / 6e4;
|
|
29
|
+
if (elapsedMin >= this.limits.maxSessionMinutes) {
|
|
30
|
+
return "max-minutes";
|
|
31
|
+
}
|
|
32
|
+
if (this.limits.maxOutputTokens != null && this.outputTokens >= this.limits.maxOutputTokens) {
|
|
33
|
+
return "max-cost";
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
/** A user-facing message for an abort reason. */
|
|
38
|
+
static MessageFor(reason) {
|
|
39
|
+
return reason === "max-minutes" ? "Voice session time limit reached. Please start a new session or continue by text." : "Voice session usage limit reached. Please continue by text.";
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
DEFAULT_VOICE_LIMITS,
|
|
45
|
+
VoiceAbuseGuard
|
|
46
|
+
};
|