@pagelines/sdk 1.0.928 → 1.0.929
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BotProvider.js +109 -109
- package/dist/BotProvider.js.map +1 -1
- package/dist/BotWrap.js +1168 -1057
- package/dist/BotWrap.js.map +1 -1
- package/dist/bot/index.d.ts +5 -1
- package/dist/bot/ui/ChatComposer.vue.d.ts +63 -0
- package/dist/bot/ui/ChatDivider.vue.d.ts +13 -0
- package/dist/bot/ui/ChatTurn.vue.d.ts +36 -0
- package/dist/bot.js +48 -48
- package/dist/bot.js.map +1 -1
- package/dist/sdk.css +1 -1
- package/dist/widget.js +51 -51
- package/dist/widget.js.map +1 -1
- package/package.json +1 -1
package/dist/bot/index.d.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { default as BotChat } from './ui/BotChat.vue';
|
|
|
2
2
|
import { default as BotProvider } from './ui/BotProvider.vue';
|
|
3
3
|
import { default as BotWidget } from './ui/BotWidget.vue';
|
|
4
4
|
import { default as BotWrap } from './ui/BotWrap.vue';
|
|
5
|
+
import { default as ChatComposer } from './ui/ChatComposer.vue';
|
|
6
|
+
import { default as ChatDivider } from './ui/ChatDivider.vue';
|
|
5
7
|
import { default as ChatRichText } from './ui/ChatRichText.vue';
|
|
8
|
+
import { default as ChatScroller } from './ui/ChatScroller.vue';
|
|
9
|
+
import { default as ChatTurn } from './ui/ChatTurn.vue';
|
|
6
10
|
import { default as ElBotChat } from './ui/ElBotChat.vue';
|
|
7
11
|
import { default as ElBotChatPreview } from './ui/ElBotChatPreview.vue';
|
|
8
12
|
import { default as VoiceMode } from './ui/VoiceMode.vue';
|
|
@@ -12,4 +16,4 @@ export { VoiceSessionClient } from './voice/voice-session-client';
|
|
|
12
16
|
export type { VoiceClientHandlers, VoiceLevelEvent, VoiceMetric, VoiceMetricName, VoiceSessionClientState, VoiceSessionError, } from './voice/voice-session-client';
|
|
13
17
|
export type { WorkJournalModel, WorkJournalOutcome, WorkJournalRow, WorkJournalTone } from './work-journal';
|
|
14
18
|
export * from './schema';
|
|
15
|
-
export { BotChat, BotProvider, BotWidget, BotWrap, ChatRichText, ElBotChat, ElBotChatPreview, VoiceMode };
|
|
19
|
+
export { BotChat, BotProvider, BotWidget, BotWrap, ChatComposer, ChatDivider, ChatRichText, ChatScroller, ChatTurn, ElBotChat, ElBotChatPreview, VoiceMode };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composer card every conversation types into, bot or person: one card,
|
|
3
|
+
* two rows, text on top and controls beneath, Send in the bottom-right seat.
|
|
4
|
+
* Fixed 16px corners (Messages-style): the radius never grows with the
|
|
5
|
+
* draft, and the 16px inset keeps the buttons out of the curve.
|
|
6
|
+
*
|
|
7
|
+
* Enter submits, Shift+Enter breaks the line, an IME's Enter picks a word.
|
|
8
|
+
* The whole card is the field's hit area. `leading` holds what sits left of
|
|
9
|
+
* the controls row (attach), `actions` what sits before Send (voice, stop);
|
|
10
|
+
* `input` replaces the field (a recording in progress).
|
|
11
|
+
*/
|
|
12
|
+
type __VLS_Props = {
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
maxlength?: number;
|
|
16
|
+
/** On a dark canvas. */
|
|
17
|
+
inverted?: boolean;
|
|
18
|
+
/** Off when another control (voice start, a recording) owns the seat. */
|
|
19
|
+
showSend?: boolean;
|
|
20
|
+
sendEnabled: boolean;
|
|
21
|
+
sendLabel?: string;
|
|
22
|
+
/** A running bot turn turns Send into Stop; idle has nothing to send. */
|
|
23
|
+
action?: 'idle' | 'send' | 'stop';
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* After a send. Touch: blur so the software keyboard closes and the full UI
|
|
27
|
+
* returns. Desktop: keep focus for rapid follow-ups (a click on Send moved
|
|
28
|
+
* it to the button). Never both on one path: WebKit processes focus() then
|
|
29
|
+
* blur() in one task as "still focused" and the keyboard stays up.
|
|
30
|
+
*/
|
|
31
|
+
declare function settleAfterSend(): void;
|
|
32
|
+
type __VLS_ModelProps = {
|
|
33
|
+
modelValue: string;
|
|
34
|
+
};
|
|
35
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
36
|
+
declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {};
|
|
37
|
+
type __VLS_Slots = {} & {
|
|
38
|
+
input?: (props: typeof __VLS_1) => any;
|
|
39
|
+
} & {
|
|
40
|
+
leading?: (props: typeof __VLS_3) => any;
|
|
41
|
+
} & {
|
|
42
|
+
actions?: (props: typeof __VLS_5) => any;
|
|
43
|
+
};
|
|
44
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
45
|
+
focus: () => void | undefined;
|
|
46
|
+
settleAfterSend: typeof settleAfterSend;
|
|
47
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
48
|
+
submit: () => any;
|
|
49
|
+
action: () => any;
|
|
50
|
+
"update:modelValue": (value: string) => any;
|
|
51
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
52
|
+
onSubmit?: (() => any) | undefined;
|
|
53
|
+
onAction?: (() => any) | undefined;
|
|
54
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
55
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
56
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
57
|
+
declare const _default: typeof __VLS_export;
|
|
58
|
+
export default _default;
|
|
59
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
60
|
+
new (): {
|
|
61
|
+
$slots: S;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The date line between a transcript's days, bot chat and member threads
|
|
3
|
+
* alike. A flat hairline, not a gradient fade: the gradient read as
|
|
4
|
+
* decoration; a simple rule is the Swiss divider.
|
|
5
|
+
*/
|
|
6
|
+
type __VLS_Props = {
|
|
7
|
+
label: string;
|
|
8
|
+
/** On a dark canvas. */
|
|
9
|
+
inverted?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One message in a transcript, for bot chat and member threads alike: one
|
|
3
|
+
* look for every conversation. Your own words sit in a quiet light bubble on
|
|
4
|
+
* the right; the other side's (bot or person) on the open canvas, no bubble,
|
|
5
|
+
* no border, no face, so the prose reads like a document and whitespace alone
|
|
6
|
+
* separates turns. A solid or outlined bubble per reply was the heaviest ink
|
|
7
|
+
* on the page. Neither side wears a measure: a reply takes the column minus an
|
|
8
|
+
* inset on the right, your bubble grows to fit minus the same inset on the
|
|
9
|
+
* left. The inset says who is speaking. The inset reads the `chat` container.
|
|
10
|
+
*
|
|
11
|
+
* `before` and `after` hold what rides with the message outside the bubble
|
|
12
|
+
* (attachments, a shared post card, the reply's actions); the default slot is
|
|
13
|
+
* the message itself, and the bubble draws only when it is given.
|
|
14
|
+
*/
|
|
15
|
+
type __VLS_Props = {
|
|
16
|
+
own: boolean;
|
|
17
|
+
/** On a dark canvas. */
|
|
18
|
+
inverted?: boolean;
|
|
19
|
+
};
|
|
20
|
+
declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {};
|
|
21
|
+
type __VLS_Slots = {} & {
|
|
22
|
+
before?: (props: typeof __VLS_1) => any;
|
|
23
|
+
} & {
|
|
24
|
+
default?: (props: typeof __VLS_3) => any;
|
|
25
|
+
} & {
|
|
26
|
+
after?: (props: typeof __VLS_5) => any;
|
|
27
|
+
};
|
|
28
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
30
|
+
declare const _default: typeof __VLS_export;
|
|
31
|
+
export default _default;
|
|
32
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
33
|
+
new (): {
|
|
34
|
+
$slots: S;
|
|
35
|
+
};
|
|
36
|
+
};
|
package/dist/bot.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import "./rolldown-runtime.js";
|
|
2
2
|
import { c as e, l as t } from "./sdkClient.js";
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
import { n as
|
|
6
|
-
import { SettingsObject as
|
|
7
|
-
import { Fragment as
|
|
3
|
+
import { _ as n, a as r, c as i, l as a, n as o, o as s, r as c, s as l, t as u } from "./BotWrap.js";
|
|
4
|
+
import { i as d, n as f, r as p, t as m } from "./BotProvider.js";
|
|
5
|
+
import { n as h, t as g } from "./provider.js";
|
|
6
|
+
import { SettingsObject as _, detectBrowserTimezone as v, readChatEventStream as y, zVoiceSessionMint as b } from "@pagelines/core";
|
|
7
|
+
import { Fragment as x, createBlock as S, createCommentVNode as C, createElementBlock as w, createElementVNode as T, createVNode as E, defineComponent as D, nextTick as O, normalizeClass as k, normalizeStyle as A, openBlock as j, ref as M, renderList as N, watch as P, withCtx as F } from "vue";
|
|
8
8
|
// bot/ui/BotWidget.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
-
var
|
|
9
|
+
var I = {
|
|
10
10
|
key: 0,
|
|
11
11
|
class: "relative h-full w-full"
|
|
12
|
-
},
|
|
12
|
+
}, L = { class: "group relative h-full w-full rounded-3xl overflow-hidden shadow-lg transition-all duration-300 ease-[cubic-bezier(0.25,1,0.33,1)] hover:shadow-2xl hover:translate-y-[-1px] hover:brightness-110 active:scale-[1.06] active:-translate-y-0.5 active:duration-100" }, R = ["src", "alt"], z = {
|
|
13
13
|
key: 0,
|
|
14
14
|
class: "absolute top-0.5 right-0.5"
|
|
15
|
-
},
|
|
15
|
+
}, B = /* @__PURE__ */ D({
|
|
16
16
|
__name: "BotWidget",
|
|
17
17
|
props: {
|
|
18
18
|
sdk: {},
|
|
@@ -22,12 +22,12 @@ var M = {
|
|
|
22
22
|
position: {}
|
|
23
23
|
},
|
|
24
24
|
setup(e, { expose: t }) {
|
|
25
|
-
let n = e, r =
|
|
25
|
+
let n = e, r = M(!1), i = M(!1);
|
|
26
26
|
function toggle() {
|
|
27
27
|
r.value = !r.value;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
e ? (await
|
|
29
|
+
P(r, async (e) => {
|
|
30
|
+
e ? (await O(), setTimeout(() => {
|
|
31
31
|
i.value = !0;
|
|
32
32
|
}, 400)) : i.value = !1;
|
|
33
33
|
});
|
|
@@ -44,29 +44,29 @@ var M = {
|
|
|
44
44
|
toggle,
|
|
45
45
|
open,
|
|
46
46
|
close
|
|
47
|
-
}), (t, a) => (
|
|
47
|
+
}), (t, a) => (j(), S(u, {
|
|
48
48
|
sdk: e.sdk,
|
|
49
49
|
handle: e.handle,
|
|
50
50
|
context: e.context,
|
|
51
51
|
"first-message": e.firstMessage
|
|
52
52
|
}, {
|
|
53
|
-
default:
|
|
53
|
+
default: F(({ bot: t, sdk: o }) => [t ? (j(), w("div", {
|
|
54
54
|
key: 0,
|
|
55
|
-
class:
|
|
56
|
-
}, [
|
|
57
|
-
class:
|
|
58
|
-
style:
|
|
55
|
+
class: k(["fixed z-[999999] pointer-events-auto", [n.position === "bottom-left" ? "bottom-6 left-6" : n.position === "top-right" ? "top-6 right-6" : n.position === "top-left" ? "top-6 left-6" : "bottom-6 right-6"]])
|
|
56
|
+
}, [T("div", {
|
|
57
|
+
class: k(["transition-all duration-500 ease-[cubic-bezier(0.25,1,0.33,1)] transform-gpu", [r.value ? "widget-expanded w-96 h-[600px] max-w-[calc(100vw-48px)] max-h-[calc(100vh-48px)] rounded-3xl opacity-100 scale-100" : "widget-button w-[80px] h-[80px] opacity-100 scale-100 flex items-center justify-center cursor-pointer"]]),
|
|
58
|
+
style: A({ "transform-origin": n.position === "bottom-left" ? "bottom left" : n.position === "top-right" ? "top right" : n.position === "top-left" ? "top left" : "bottom right" }),
|
|
59
59
|
onClick: a[0] || (a[0] = (e) => r.value ? void 0 : toggle())
|
|
60
|
-
}, [r.value ?
|
|
60
|
+
}, [r.value ? C("", !0) : (j(), w("div", I, [T("div", L, [T("img", {
|
|
61
61
|
src: t.avatarUrl.value,
|
|
62
62
|
alt: `${t.displayName.value} assistant`,
|
|
63
63
|
class: "h-full w-full object-cover pointer-events-none",
|
|
64
64
|
width: "80",
|
|
65
65
|
height: "80"
|
|
66
|
-
}, null, 8,
|
|
66
|
+
}, null, 8, R), a[1] || (a[1] = T("div", { class: "absolute inset-0 pointer-events-none bg-gradient-to-br from-transparent via-black/10 to-black/40 opacity-60 transition-opacity duration-300 group-hover:opacity-40" }, null, -1))]), t.state.value.lifecycle === "running" ? (j(), w("div", z, [...a[2] || (a[2] = [T("div", {
|
|
67
67
|
class: "size-3 bg-green-500 rounded-full ring-2 ring-white absolute animate-ping",
|
|
68
68
|
style: { "animation-duration": "3s" }
|
|
69
|
-
}, null, -1),
|
|
69
|
+
}, null, -1), T("div", { class: "size-3 bg-green-500 rounded-full ring-2 ring-white" }, null, -1)])])) : C("", !0)])), r.value && t ? (j(), S(f, {
|
|
70
70
|
key: 1,
|
|
71
71
|
class: "rounded-3xl shadow-2xl border border-white/10",
|
|
72
72
|
sdk: o,
|
|
@@ -82,7 +82,7 @@ var M = {
|
|
|
82
82
|
"context",
|
|
83
83
|
"first-message",
|
|
84
84
|
"is-active"
|
|
85
|
-
])) :
|
|
85
|
+
])) : C("", !0)], 6)], 2)) : C("", !0)]),
|
|
86
86
|
_: 1
|
|
87
87
|
}, 8, [
|
|
88
88
|
"sdk",
|
|
@@ -91,25 +91,25 @@ var M = {
|
|
|
91
91
|
"first-message"
|
|
92
92
|
]));
|
|
93
93
|
}
|
|
94
|
-
}),
|
|
94
|
+
}), V = ["data-sender"], H = /* @__PURE__ */ D({
|
|
95
95
|
__name: "ElBotChatPreview",
|
|
96
96
|
props: {
|
|
97
97
|
messages: {},
|
|
98
98
|
variant: {}
|
|
99
99
|
},
|
|
100
100
|
setup(e) {
|
|
101
|
-
return (t,
|
|
102
|
-
class:
|
|
101
|
+
return (t, n) => (j(), w("div", {
|
|
102
|
+
class: k(["@container/chat-preview flex flex-col gap-3", e.variant === "dark" ? "text-white" : "text-slate-950"]),
|
|
103
103
|
"data-test": "bot-chat-preview"
|
|
104
|
-
}, [(
|
|
105
|
-
key: `${t.sender}-${
|
|
106
|
-
class:
|
|
104
|
+
}, [(j(!0), w(x, null, N(e.messages, (t, n) => (j(), w("div", {
|
|
105
|
+
key: `${t.sender}-${n}`,
|
|
106
|
+
class: k(["flex", t.sender === "user" ? "justify-end" : "justify-start"]),
|
|
107
107
|
"data-test": "bot-chat-preview-message",
|
|
108
108
|
"data-sender": t.sender
|
|
109
|
-
}, [
|
|
109
|
+
}, [T("div", { class: k(["max-w-[88%] rounded-2xl px-4 py-3 text-sm shadow-sm @sm/chat-preview:max-w-[78%]", t.sender === "user" ? "bg-slate-950 text-white" : e.variant === "dark" ? "border border-white/10 bg-white/10 text-white" : "border border-slate-200 bg-white text-slate-950"]) }, [E(a, {
|
|
110
110
|
text: t.text,
|
|
111
111
|
inverted: t.sender === "user" || e.variant === "dark"
|
|
112
|
-
}, null, 8, ["text", "inverted"])], 2)], 10,
|
|
112
|
+
}, null, 8, ["text", "inverted"])], 2)], 10, V))), 128))], 2));
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
// bot/voice/voice-work-state.ts
|
|
@@ -149,38 +149,38 @@ function reduceVoiceWorkEvent(e, t) {
|
|
|
149
149
|
} : e;
|
|
150
150
|
}
|
|
151
151
|
// bot/voice/voice-session-client.ts
|
|
152
|
-
var
|
|
152
|
+
var U = {
|
|
153
153
|
start: "/audio/start-call.mp3",
|
|
154
154
|
end: "/audio/end-call.mp3"
|
|
155
|
-
},
|
|
155
|
+
}, W = .7, G = 50, K = 15e3, q = 3e3;
|
|
156
156
|
function unlockAudio(e, t) {
|
|
157
157
|
for (let n of e) n.muted = !0, n.play().catch(() => {}), n.pause(), n.currentTime = 0, n.muted = !1, n.volume = t;
|
|
158
158
|
}
|
|
159
159
|
function createBrowserVoiceChimePlayer(e) {
|
|
160
|
-
let t = Object.fromEntries(Object.entries(
|
|
160
|
+
let t = Object.fromEntries(Object.entries(U).map(([t, n]) => {
|
|
161
161
|
let r = new Audio(`${e}${n}`);
|
|
162
|
-
return r.preload = "auto", r.volume =
|
|
162
|
+
return r.preload = "auto", r.volume = W, [t, r];
|
|
163
163
|
}));
|
|
164
164
|
return {
|
|
165
165
|
play: (e) => {
|
|
166
166
|
t[e].currentTime = 0, t[e].play().catch(() => {});
|
|
167
167
|
},
|
|
168
|
-
unlock: () => unlockAudio(Object.values(t),
|
|
168
|
+
unlock: () => unlockAudio(Object.values(t), W)
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
var
|
|
171
|
+
var J = .16;
|
|
172
172
|
function createBrowserVoiceWorkCue(e) {
|
|
173
173
|
let t = new Audio(`${e}/audio/thinking.mp3`);
|
|
174
|
-
return t.preload = "auto", t.loop = !0, t.volume =
|
|
174
|
+
return t.preload = "auto", t.loop = !0, t.volume = J, {
|
|
175
175
|
setActive: (e) => {
|
|
176
176
|
e ? t.play().catch(() => {}) : (t.pause(), t.currentTime = 0);
|
|
177
177
|
},
|
|
178
|
-
unlock: () => unlockAudio([t],
|
|
178
|
+
unlock: () => unlockAudio([t], J)
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
-
var VoiceSessionClient = class extends
|
|
181
|
+
var VoiceSessionClient = class extends _ {
|
|
182
182
|
constructor(t) {
|
|
183
|
-
super("VoiceSessionClient", t), e(this, "state",
|
|
183
|
+
super("VoiceSessionClient", t), e(this, "state", M("idle")), e(this, "isMuted", M(!1)), e(this, "provider", void 0), e(this, "teardownPromise", void 0), e(this, "providerName", void 0), e(this, "chime", void 0), e(this, "workCue", void 0), e(this, "generation", 0), e(this, "levelTimer", void 0), e(this, "startAtMs", 0), e(this, "liveAtMs", 0), e(this, "firstPlaybackEmitted", !1), e(this, "mutePending", !1), e(this, "conversationId", void 0), e(this, "workAbort", void 0), e(this, "workState", createVoiceWorkState()), e(this, "workCuePlaying", !1), e(this, "workCueWanted", !1), e(this, "workCuePending", void 0), e(this, "thinking", !1), e(this, "speaking", {
|
|
184
184
|
user: !1,
|
|
185
185
|
bot: !1
|
|
186
186
|
}), this.chime = t.playChime ? {
|
|
@@ -217,7 +217,7 @@ var VoiceSessionClient = class extends p {
|
|
|
217
217
|
async connect(e) {
|
|
218
218
|
let { mint: t, generation: n } = e;
|
|
219
219
|
this.providerName = t.provider;
|
|
220
|
-
let r = await (this.settings.createProvider ??
|
|
220
|
+
let r = await (this.settings.createProvider ?? g)(t);
|
|
221
221
|
if (n !== this.generation) {
|
|
222
222
|
await r.disconnect().catch(() => {});
|
|
223
223
|
return;
|
|
@@ -242,7 +242,7 @@ var VoiceSessionClient = class extends p {
|
|
|
242
242
|
}), a;
|
|
243
243
|
try {
|
|
244
244
|
await Promise.race([i, new Promise((e, t) => {
|
|
245
|
-
a = setTimeout(() => t(Object.assign(/* @__PURE__ */ Error("Voice connection timed out."), { code: "VOICE_CONNECT_TIMEOUT" })),
|
|
245
|
+
a = setTimeout(() => t(Object.assign(/* @__PURE__ */ Error("Voice connection timed out."), { code: "VOICE_CONNECT_TIMEOUT" })), K);
|
|
246
246
|
})]);
|
|
247
247
|
} catch (e) {
|
|
248
248
|
if (i.then(() => r.disconnect()).catch(() => {}), n !== this.generation || this.provider !== r) return;
|
|
@@ -313,8 +313,8 @@ var VoiceSessionClient = class extends p {
|
|
|
313
313
|
this.levelTimer === void 0 && (this.levelTimer = setInterval(() => {
|
|
314
314
|
if (t !== this.generation || this.provider !== e) return;
|
|
315
315
|
let n = e.sampleLevel(this.speaking.bot ? "playback" : this.speaking.user ? "mic" : void 0);
|
|
316
|
-
n && (this.settings.onLevel?.(n), !this.firstPlaybackEmitted && n.source === "playback" &&
|
|
317
|
-
},
|
|
316
|
+
n && (this.settings.onLevel?.(n), !this.firstPlaybackEmitted && n.source === "playback" && h(n.level) && this.liveAtMs > 0 && (this.firstPlaybackEmitted = !0, this.emitMetric("voice.first_playback", Date.now() - this.liveAtMs)));
|
|
317
|
+
}, G));
|
|
318
318
|
}
|
|
319
319
|
authHeaders() {
|
|
320
320
|
return this.settings.token ? { Authorization: `Bearer ${this.settings.token}` } : {};
|
|
@@ -345,7 +345,7 @@ var VoiceSessionClient = class extends p {
|
|
|
345
345
|
credentials: "include",
|
|
346
346
|
signal: r.signal
|
|
347
347
|
});
|
|
348
|
-
if (e.ok && e.body) for await (let t of
|
|
348
|
+
if (e.ok && e.body) for await (let t of y(e.body.getReader())) {
|
|
349
349
|
if (r.signal.aborted || n !== this.generation) return;
|
|
350
350
|
let e = this.workState, i = reduceVoiceWorkEvent(e, t);
|
|
351
351
|
i !== e && (this.workState = i, (i.activeTurnId !== e.activeTurnId || i.description !== e.description) && (this.settings.onWorkChange?.({
|
|
@@ -369,7 +369,7 @@ var VoiceSessionClient = class extends p {
|
|
|
369
369
|
let e = this.generation;
|
|
370
370
|
this.workCuePending = setTimeout(() => {
|
|
371
371
|
this.workCuePending = void 0, e === this.generation && this.workCueWanted && this.setWorkCue(!0);
|
|
372
|
-
}, this.settings.workCueDelayMs ??
|
|
372
|
+
}, this.settings.workCueDelayMs ?? q);
|
|
373
373
|
} else this.setWorkCue(!1);
|
|
374
374
|
}
|
|
375
375
|
}
|
|
@@ -414,7 +414,7 @@ var VoiceSessionClient = class extends p {
|
|
|
414
414
|
}]
|
|
415
415
|
}
|
|
416
416
|
})).conversationId, e !== this.generation)) return null;
|
|
417
|
-
let n =
|
|
417
|
+
let n = v(), r = await this.post({
|
|
418
418
|
path: "/api/voice/sessions",
|
|
419
419
|
body: {
|
|
420
420
|
conversationId: t,
|
|
@@ -422,7 +422,7 @@ var VoiceSessionClient = class extends p {
|
|
|
422
422
|
}
|
|
423
423
|
});
|
|
424
424
|
if (e !== this.generation) return null;
|
|
425
|
-
let i =
|
|
425
|
+
let i = b.safeParse(r);
|
|
426
426
|
if (!i.success) throw Object.assign(/* @__PURE__ */ Error("Voice session mint returned an unexpected shape."), { code: "VOICE_MINT_INVALID" });
|
|
427
427
|
return this.conversationId = t, i.data;
|
|
428
428
|
}
|
|
@@ -436,6 +436,6 @@ var VoiceSessionClient = class extends p {
|
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
438
|
};
|
|
439
|
-
export {
|
|
439
|
+
export { p as BOT_MODES, d as Bot, f as BotChat, n as BotChatController, m as BotProvider, B as BotWidget, u as BotWrap, i as ChatComposer, l as ChatDivider, a as ChatRichText, s as ChatScroller, r as ChatTurn, o as ElBotChat, H as ElBotChatPreview, c as VoiceMode, VoiceSessionClient };
|
|
440
440
|
|
|
441
441
|
//# sourceMappingURL=bot.js.map
|