@inupedia/spotlight-vue 0.9.0 → 0.9.2

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.
Files changed (32) hide show
  1. package/dist/assets/spotlight-vue.css +1 -1
  2. package/dist/avatar/speech/spotlightSpeech.d.ts.map +1 -1
  3. package/dist/avatar/speech/spotlightSpeech.js +20 -31
  4. package/dist/avatar/voice/micAccess.d.ts +4 -0
  5. package/dist/avatar/voice/micAccess.d.ts.map +1 -0
  6. package/dist/avatar/voice/micAccess.js +26 -0
  7. package/dist/avatar/voice/phonePairing.d.ts +14 -0
  8. package/dist/avatar/voice/phonePairing.d.ts.map +1 -0
  9. package/dist/avatar/voice/phonePairing.js +30 -0
  10. package/dist/avatar/voice/usePhoneVoicePairing.d.ts +17 -0
  11. package/dist/avatar/voice/usePhoneVoicePairing.d.ts.map +1 -0
  12. package/dist/avatar/voice/usePhoneVoicePairing.js +88 -0
  13. package/dist/components/Live2dPanel.vue.d.ts +20 -0
  14. package/dist/components/Live2dPanel.vue.d.ts.map +1 -1
  15. package/dist/components/Live2dPanel.vue.js +1 -1
  16. package/dist/components/Live2dPanel2.vue.js +167 -62
  17. package/dist/components/SpotlightCommandPanel.vue.d.ts.map +1 -1
  18. package/dist/components/SpotlightCommandPanel.vue.js +1 -1
  19. package/dist/components/SpotlightCommandPanel2.vue.js +337 -191
  20. package/dist/components/SpotlightShell.vue.d.ts.map +1 -1
  21. package/dist/components/SpotlightShell.vue.js +2 -2
  22. package/dist/components/SpotlightShell2.vue.js +268 -255
  23. package/dist/node_modules/.pnpm/uqr@0.1.3/node_modules/uqr/dist/index.js +504 -0
  24. package/dist/remote/runPipeline.d.ts.map +1 -1
  25. package/dist/remote/runPipeline.js +103 -97
  26. package/dist/store/index.d.ts +1 -0
  27. package/dist/store/index.d.ts.map +1 -1
  28. package/dist/store/index.js +15 -13
  29. package/dist/store/modelStore.d.ts +16 -0
  30. package/dist/store/modelStore.d.ts.map +1 -0
  31. package/dist/store/modelStore.js +63 -0
  32. package/package.json +5 -3
@@ -1,407 +1,420 @@
1
- import { defineComponent as Ae, computed as _, ref as d, watch as Z, onMounted as Be, onUnmounted as xe, openBlock as U, createElementBlock as ee, Fragment as He, createVNode as _e, unref as M, createBlock as Ke, createElementVNode as te, createCommentVNode as Re, nextTick as ne } from "vue";
2
- import { VoiceTurnController as Fe, sanitizeSpokenText as Ie, drainSpokenClips as ie, packSpokenSentences as Me } from "@inupedia/spotlight-protocol";
3
- import { stopTtsBufferPlayback as Oe, decodeTtsAudioFromBlob as De, getTtsPlaybackContext as Ne, appendSilenceToAudioBuffer as Ue, playTtsAudioBuffer as qe, TTS_CLIP_SILENCE_MS as re } from "../avatar/speech/live2dTtsPlayback.js";
4
- import { SpotlightSpeechService as ze, hasSpotlightSpeechConfig as $e } from "../avatar/speech/spotlightSpeech.js";
5
- import { storeToRefs as Ge } from "pinia";
6
- import { useSpotlightStore as We } from "../store/spotlightStore.js";
7
- import { useSpotlightAvatarConfig as Ye } from "../avatar/config.js";
8
- import { unlockVoicePlayback as Qe } from "../avatar/voice/voiceSession.js";
9
- import { shouldAbortVoiceOnPanelHide as je } from "../avatar/voice/panelHidePolicy.js";
10
- import { directorPhaseFromTurn as Je } from "../avatar/voice/avatarDirector.js";
11
- import { useAgentSessionStore as Xe } from "../session/agentSession.js";
12
- import Ze from "./SpotlightRoot.vue.js";
13
- import et from "./Live2dPanel.vue.js";
14
- import { useLive2dOverlayStore as tt } from "../store/live2dOverlayStore.js";
15
- import { useLive2dSpeechStore as nt } from "../store/live2dSpeechStore.js";
16
- import { useLive2dVoiceChannelStore as it } from "../store/live2dVoiceChannelStore.js";
17
- import { devWarn as rt } from "../utils/devConsole.js";
18
- const oe = "Backquote", ot = "`", Tt = /* @__PURE__ */ Ae({
1
+ import { defineComponent as xe, computed as R, ref as h, watch as te, onMounted as He, onUnmounted as Ke, openBlock as N, createElementBlock as re, Fragment as _e, createVNode as Re, unref as l, createBlock as Fe, createElementVNode as ie, createCommentVNode as Ie, nextTick as oe } from "vue";
2
+ import { VoiceTurnController as Me, sanitizeSpokenText as De, drainSpokenClips as ae, packSpokenSentences as Oe } from "@inupedia/spotlight-protocol";
3
+ import { stopTtsBufferPlayback as Ue, decodeTtsAudioFromBlob as qe, getTtsPlaybackContext as Ne, appendSilenceToAudioBuffer as $e, playTtsAudioBuffer as ze, TTS_CLIP_SILENCE_MS as le } from "../avatar/speech/live2dTtsPlayback.js";
4
+ import { SpotlightSpeechService as Ge, hasSpotlightSpeechConfig as We } from "../avatar/speech/spotlightSpeech.js";
5
+ import { storeToRefs as Ye } from "pinia";
6
+ import { useSpotlightStore as Qe } from "../store/spotlightStore.js";
7
+ import { useSpotlightAvatarConfig as je } from "../avatar/config.js";
8
+ import { unlockVoicePlayback as Je } from "../avatar/voice/voiceSession.js";
9
+ import { shouldAbortVoiceOnPanelHide as Xe } from "../avatar/voice/panelHidePolicy.js";
10
+ import { directorPhaseFromTurn as Ze } from "../avatar/voice/avatarDirector.js";
11
+ import { microphoneAccessMessage as $ } from "../avatar/voice/micAccess.js";
12
+ import { usePhoneVoicePairing as en } from "../avatar/voice/usePhoneVoicePairing.js";
13
+ import { useAgentSessionStore as nn } from "../session/agentSession.js";
14
+ import tn from "./SpotlightRoot.vue.js";
15
+ import rn from "./Live2dPanel.vue.js";
16
+ import { useLive2dOverlayStore as on } from "../store/live2dOverlayStore.js";
17
+ import { useLive2dSpeechStore as an } from "../store/live2dSpeechStore.js";
18
+ import { useLive2dVoiceChannelStore as ln } from "../store/live2dVoiceChannelStore.js";
19
+ import { devWarn as sn } from "../utils/devConsole.js";
20
+ const se = "Backquote", cn = "`", An = /* @__PURE__ */ xe({
19
21
  __name: "SpotlightShell",
20
22
  props: {
21
23
  avatarEnabled: { type: Boolean, default: !1 }
22
24
  },
23
25
  setup(O) {
24
- const V = O, K = Ye(), ae = _(
25
- () => K.deckKicker?.trim() || "SPOTLIGHT"
26
- ), R = _(
27
- () => K.greetingText?.trim() || "您好,我是 Spotlight 助手"
28
- ), n = We(), E = tt(), { visible: h } = Ge(E), s = nt(), c = it(), b = new ze(), T = d(null), u = d(!1), y = d(!1), C = d(!1), A = d(null), p = d(null), g = d(0), S = d(!1), q = _(
26
+ const S = O, F = je(), ce = R(
27
+ () => F.deckKicker?.trim() || "SPOTLIGHT"
28
+ ), I = R(
29
+ () => F.greetingText?.trim() || "您好,我是 Spotlight 助手"
30
+ ), t = Qe(), B = on(), { visible: g } = Ye(B), c = an(), u = ln(), w = new Ge(), L = h(null), p = h(!1), k = h(!1), E = h(!1), x = h(null), m = h(null), b = h(0), P = h(!1), z = R(
29
31
  () => Math.max(
30
32
  0,
31
- K.briefingKeepLastMs ?? 0
33
+ F.briefingKeepLastMs ?? 0
32
34
  )
33
35
  );
34
- let k = null;
35
- const m = d(!1);
36
- let B = Promise.resolve(), F = 0;
37
- const l = new Fe(), x = d(!1);
38
- let D = 0, f = "", L = 0;
39
- l.onAbort(async () => {
40
- n.cancelPipeline(), x.value = !1, f = "", L = 0, w(), H(), s.reset(), import("../avatar/spine/live2dApp.js").then(
36
+ let T = null;
37
+ const y = h(!1);
38
+ let H = Promise.resolve(), M = 0;
39
+ const s = new Me(), K = h(!1);
40
+ let U = 0, f = "", V = 0;
41
+ s.onAbort(async () => {
42
+ t.cancelPipeline(), K.value = !1, f = "", V = 0, C(), _(), c.reset(), import("../avatar/spine/live2dApp.js").then(
41
43
  (e) => e.stopLive2dLipSync()
42
44
  );
43
45
  });
44
- const le = _(() => n.showThinkingBar ? !V.avatarEnabled || !h.value || n.pipelinePhase === "running" || S.value ? !0 : n.pipelinePhase === "done" : !1), se = _(() => {
45
- const e = n.agentSteps.length === 1 && n.agentSteps[0]?.label === "回答";
46
- return n.pipelinePhase === "running" || e || S.value;
46
+ const ue = R(() => t.showThinkingBar ? !S.avatarEnabled || !g.value || t.pipelinePhase === "running" || P.value ? !0 : t.pipelinePhase === "done" : !1), pe = R(() => {
47
+ const e = t.agentSteps.length === 1 && t.agentSteps[0]?.label === "回答";
48
+ return t.pipelinePhase === "running" || e || P.value;
47
49
  });
48
- function ce() {
49
- S.value = !1, h.value && (n.showThinkingBar = !1);
50
+ function fe() {
51
+ P.value = !1, g.value && (t.showThinkingBar = !1);
50
52
  }
51
- function z() {
52
- T.value != null && (window.clearTimeout(T.value), T.value = null);
53
+ function G() {
54
+ L.value != null && (window.clearTimeout(L.value), L.value = null);
53
55
  }
54
- function H() {
55
- z(), A.value && (A.value.abort(), A.value = null), y.value = !1, C.value = !1, u.value = !1, m.value = !1, c.reset(), b.cancel();
56
+ function _() {
57
+ G(), x.value && (x.value.abort(), x.value = null), k.value = !1, E.value = !1, p.value = !1, y.value = !1, u.reset(), w.cancel();
56
58
  }
57
- function w() {
58
- k && (k.abort(), k = null), p.value && (p.value.abort(), p.value = null), I(), s.reset(), import("../avatar/spine/live2dApp.js").then(
59
+ function C() {
60
+ T && (T.abort(), T = null), m.value && (m.value.abort(), m.value = null), D(), c.reset(), import("../avatar/spine/live2dApp.js").then(
59
61
  (e) => e.stopLive2dLipSync()
60
62
  );
61
63
  }
62
- function ue(e, t) {
63
- return e <= 0 ? Promise.resolve() : new Promise((i, r) => {
64
+ function ve(e, n) {
65
+ return e <= 0 ? Promise.resolve() : new Promise((r, i) => {
64
66
  const a = window.setTimeout(() => {
65
- t?.removeEventListener("abort", o), i();
67
+ n?.removeEventListener("abort", o), r();
66
68
  }, e), o = () => {
67
- window.clearTimeout(a), r(new DOMException("Aborted", "AbortError"));
69
+ window.clearTimeout(a), i(new DOMException("Aborted", "AbortError"));
68
70
  };
69
- if (t?.aborted) {
71
+ if (n?.aborted) {
70
72
  o();
71
73
  return;
72
74
  }
73
- t?.addEventListener("abort", o, { once: !0 });
75
+ n?.addEventListener("abort", o, { once: !0 });
74
76
  });
75
77
  }
76
- async function fe() {
77
- if (!h.value || n.pipelinePhase === "running") return;
78
- w(), g.value += 1;
79
- const e = g.value, t = new AbortController();
80
- if (k = t, !$e()) {
81
- k = null, await ne(), (await import("../avatar/spine/live2dApp.js")).playLive2dHello(), s.start(R.value, { instant: !0 }), s.reset();
78
+ async function de() {
79
+ if (!g.value || t.pipelinePhase === "running") return;
80
+ C(), b.value += 1;
81
+ const e = b.value, n = new AbortController();
82
+ if (T = n, !We()) {
83
+ T = null, await oe(), (await import("../avatar/spine/live2dApp.js")).playLive2dHello(), c.start(I.value, { instant: !0 }), c.reset();
82
84
  return;
83
85
  }
84
- const i = b.synthesize(
85
- R.value,
86
- t.signal
86
+ const r = w.synthesize(
87
+ I.value,
88
+ n.signal
87
89
  );
88
- if (await ne(), await new Promise((r) => {
89
- requestAnimationFrame(() => r());
90
- }), !!v(t, e))
90
+ if (await oe(), await new Promise((i) => {
91
+ requestAnimationFrame(() => i());
92
+ }), !!v(n, e))
91
93
  try {
92
- const { blob: r } = await i;
93
- if (!v(t, e)) return;
94
- await Q(
95
- R.value,
96
- r,
97
- t,
94
+ const { blob: i } = await r;
95
+ if (!v(n, e)) return;
96
+ await J(
97
+ I.value,
98
+ i,
99
+ n,
98
100
  e,
99
101
  { instantText: !0, playHelloWithSpeech: !0 }
100
102
  );
101
- } catch (r) {
102
- if (t.signal.aborted) return;
103
- const a = r instanceof Error ? r.message : "数字人招呼语音失败,请稍后重试。";
104
- rt("[live2d-greeting]", a), v(t, e) && ((await import("../avatar/spine/live2dApp.js")).playLive2dHello(), s.start(R.value, { instant: !0 }), s.reset());
103
+ } catch (i) {
104
+ if (n.signal.aborted) return;
105
+ const a = i instanceof Error ? i.message : "数字人招呼语音失败,请稍后重试。";
106
+ sn("[live2d-greeting]", a), v(n, e) && ((await import("../avatar/spine/live2dApp.js")).playLive2dHello(), c.start(I.value, { instant: !0 }), c.reset());
105
107
  } finally {
106
- k === t && (k = null);
108
+ T === n && (T = null);
107
109
  }
108
110
  }
109
- function I() {
110
- Oe();
111
+ function D() {
112
+ Ue();
111
113
  }
112
- function $() {
114
+ function W() {
113
115
  return globalThis.crypto?.randomUUID?.() ?? `turn-${Date.now()}-${Math.random()}`;
114
116
  }
115
- function ve() {
116
- const e = Xe();
117
- for (let t = e.conversationHistory.length - 1; t >= 0; t -= 1) {
118
- const i = e.conversationHistory[t];
119
- if (i?.role === "assistant" && i.content.trim())
120
- return i.content.trim();
117
+ function he() {
118
+ const e = nn();
119
+ for (let n = e.conversationHistory.length - 1; n >= 0; n -= 1) {
120
+ const r = e.conversationHistory[n];
121
+ if (r?.role === "assistant" && r.content.trim())
122
+ return r.content.trim();
121
123
  }
122
124
  return "";
123
125
  }
124
- function de(e) {
125
- const t = Me(e);
126
- t.length !== 0 && (l.setPhase("speaking"), t.forEach((i, r) => {
127
- Y({ text: i });
126
+ function me(e) {
127
+ const n = Oe(e);
128
+ n.length !== 0 && (s.setPhase("speaking"), n.forEach((r, i) => {
129
+ j({ text: r });
128
130
  }));
129
131
  }
130
- function pe() {
131
- w(), g.value += 1;
132
+ function ge() {
133
+ C(), b.value += 1;
132
134
  const e = new AbortController();
133
- p.value = e, B = Promise.resolve(), F = 0, f = "", L = 0, S.value = !0, x.value = !0, $(), D = 0;
135
+ m.value = e, H = Promise.resolve(), M = 0, f = "", V = 0, P.value = !0, K.value = !0, W(), U = 0;
134
136
  }
135
- function G(e) {
136
- const t = p.value;
137
- if (!t || t.signal.aborted || !e) return;
138
- const i = g.value, r = L;
139
- L += 1;
140
- const a = b.synthesize(e, t.signal).then(
137
+ function Y(e) {
138
+ const n = m.value;
139
+ if (!n || n.signal.aborted || !e) return;
140
+ const r = b.value, i = V;
141
+ V += 1;
142
+ const a = w.synthesize(e, n.signal).then(
141
143
  (o) => ({ blob: o.blob, error: null }),
142
144
  (o) => ({ blob: null, error: o })
143
145
  );
144
- F += 1, B = B.then(async () => {
146
+ M += 1, H = H.then(async () => {
145
147
  const o = await a;
146
148
  if (o.error) throw o.error;
147
- if (!o.blob || !v(t, i)) return;
148
- r === 0 && ce();
149
- const P = L > r + 1 || f.length > 0 || n.pipelinePhase === "running" || n.loading;
150
- await Q(
149
+ if (!o.blob || !v(n, r)) return;
150
+ i === 0 && fe();
151
+ const A = V > i + 1 || f.length > 0 || t.pipelinePhase === "running" || t.loading;
152
+ await J(
151
153
  e,
152
154
  o.blob,
153
- t,
154
- i,
155
+ n,
156
+ r,
155
157
  {
156
158
  instantText: !0,
157
- hasFollowingClip: P
159
+ hasFollowingClip: A
158
160
  }
159
161
  );
160
162
  }).catch((o) => {
161
- t.signal.aborted || (n.error = o instanceof Error ? o.message : "数字人语音播放失败,请稍后重试。");
163
+ n.signal.aborted || (t.error = o instanceof Error ? o.message : "数字人语音播放失败,请稍后重试。");
162
164
  });
163
165
  }
164
- function W() {
166
+ function Q() {
165
167
  if (!f) return;
166
- const e = ie(f, { force: !0 });
168
+ const e = ae(f, { force: !0 });
167
169
  f = "";
168
- for (const t of e.ready) G(t);
170
+ for (const n of e.ready) Y(n);
169
171
  }
170
- function Y(e) {
171
- e.generation != null && e.generation !== D && (D = e.generation, $(), B = Promise.resolve(), f = "", L = 0);
172
- const t = Ie(e.text);
173
- if (!t) return;
174
- f += t;
175
- const i = ie(f);
176
- f = i.rest;
177
- for (const r of i.ready) G(r);
172
+ function j(e) {
173
+ e.generation != null && e.generation !== U && (U = e.generation, W(), H = Promise.resolve(), f = "", V = 0);
174
+ const n = De(e.text);
175
+ if (!n) return;
176
+ f += n;
177
+ const r = ae(f);
178
+ f = r.rest;
179
+ for (const i of r.ready) Y(i);
178
180
  }
179
- async function he() {
180
- const e = p.value;
181
+ async function be() {
182
+ const e = m.value;
181
183
  if (!e) {
182
- x.value = !1;
184
+ K.value = !1;
183
185
  return;
184
186
  }
185
- const t = g.value;
186
- if (await B, S.value = !1, (await import("../avatar/spine/live2dApp.js")).stopLive2dLipSync(), v(e, t)) {
187
- if (q.value > 0 && F > 0)
187
+ const n = b.value;
188
+ if (await H, P.value = !1, (await import("../avatar/spine/live2dApp.js")).stopLive2dLipSync(), v(e, n)) {
189
+ if (z.value > 0 && M > 0)
188
190
  try {
189
- await ue(q.value, e.signal);
191
+ await ve(z.value, e.signal);
190
192
  } catch {
191
193
  }
192
- v(e, t) && s.reset();
194
+ v(e, n) && c.reset();
193
195
  }
194
- p.value === e && (p.value = null), x.value = !1;
196
+ m.value === e && (m.value = null), K.value = !1;
195
197
  }
196
- function v(e, t) {
197
- return !e.signal.aborted && g.value === t;
198
+ function v(e, n) {
199
+ return !e.signal.aborted && b.value === n;
198
200
  }
199
- async function Q(e, t, i, r, a) {
200
- if (!v(i, r)) return;
201
+ async function J(e, n, r, i, a) {
202
+ if (!v(r, i)) return;
201
203
  const o = a?.hasFollowingClip ?? !1;
202
- I();
203
- const P = await import("../avatar/spine/live2dApp.js"), { audioBuffer: Le, envelope: Pe } = await De(t);
204
- if (!v(i, r)) return;
205
- a?.playHelloWithSpeech && P.playLive2dHello(), s.start(e, { instant: a?.instantText ?? !0 });
206
- const Ve = Ne(), Ee = Ue(
207
- Ve,
208
- Le,
209
- o ? re : Math.round(re / 2)
204
+ D();
205
+ const A = await import("../avatar/spine/live2dApp.js"), { audioBuffer: Ee, envelope: Ve } = await qe(n);
206
+ if (!v(r, i)) return;
207
+ a?.playHelloWithSpeech && A.playLive2dHello(), c.start(e, { instant: a?.instantText ?? !0 });
208
+ const Ae = Ne(), Be = $e(
209
+ Ae,
210
+ Ee,
211
+ o ? le : Math.round(le / 2)
210
212
  );
211
213
  try {
212
- await qe(Ee, i.signal, {
213
- onStart: (N) => {
214
- P.bindLive2dLipSyncToClock(N, Pe);
214
+ await ze(Be, r.signal, {
215
+ onStart: (q) => {
216
+ A.bindLive2dLipSyncToClock(q, Ve);
215
217
  }
216
218
  });
217
- } catch (N) {
218
- throw P.stopLive2dLipSync(), I(), N;
219
+ } catch (q) {
220
+ throw A.stopLive2dLipSync(), D(), q;
219
221
  }
220
- o || P.stopLive2dLipSync(), I(), v(i, r) && (o || s.reset());
222
+ o || A.stopLive2dLipSync(), D(), v(r, i) && (o || c.reset());
221
223
  }
222
- function j() {
223
- return !V.avatarEnabled || !h.value ? !1 : !n.loading && !C.value && !y.value;
224
+ function X() {
225
+ return !S.avatarEnabled || !g.value ? !1 : !t.loading && !E.value && !k.value;
224
226
  }
225
- function J() {
226
- return j() && !n.visible;
227
+ function Z() {
228
+ return X() && !t.visible;
227
229
  }
228
- async function ge(e) {
229
- const t = e.trim();
230
- if (!t) return;
231
- n.prompt = t, l.setPhase("thinking"), pe();
232
- const i = p.value, r = g.value;
230
+ async function ee(e) {
231
+ const n = e.trim();
232
+ if (!n) return;
233
+ t.prompt = n, s.setPhase("thinking"), ge();
234
+ const r = m.value, i = b.value;
233
235
  try {
234
- await n.submit({
236
+ await t.submit({
235
237
  interactionMode: "voice",
236
- onVoiceSentence: Y
238
+ onVoiceSentence: j
237
239
  });
238
240
  } finally {
239
- const a = !!i && v(i, r);
240
- if (W(), a && F === 0) {
241
- const o = ve();
242
- o && de(o), W();
241
+ const a = !!r && v(r, i);
242
+ if (Q(), a && M === 0) {
243
+ const o = he();
244
+ o && me(o), Q();
243
245
  }
244
- await he(), a && (l.resetTo("idle"), c.reset());
246
+ await be(), a && (s.resetTo("idle"), u.reset());
245
247
  }
246
248
  }
247
- async function X() {
248
- if (y.value) return;
249
- const e = m.value;
250
- u.value = !1, e && c.setTranscribing(!0), y.value = !0;
251
- const t = new AbortController();
252
- A.value = t;
249
+ const d = en({
250
+ enabled: S.avatarEnabled,
251
+ onUtterance: ee
252
+ });
253
+ async function ne() {
254
+ if (k.value) return;
255
+ const e = y.value;
256
+ p.value = !1, e && u.setTranscribing(!0), k.value = !0;
257
+ const n = new AbortController();
258
+ x.value = n;
253
259
  try {
254
- const { text: i } = await b.stopAndTranscribe(t.signal), r = i.trim();
260
+ const { text: r } = await w.stopAndTranscribe(n.signal), i = r.trim();
255
261
  if (e) {
256
- if (m.value = !1, c.setTranscribing(!1), !r) {
257
- n.error = "没识别到内容,请靠近麦克风再说一次。";
262
+ if (y.value = !1, u.setTranscribing(!1), !i) {
263
+ t.error = "没识别到内容,请靠近麦克风再说一次。";
258
264
  return;
259
265
  }
260
- await ge(r);
266
+ await ee(i);
261
267
  return;
262
268
  }
263
- const a = n.prompt.trim();
264
- n.prompt = a ? `${a} ${i}` : i;
265
- } catch (i) {
266
- if (t.signal.aborted) return;
267
- const r = i instanceof Error ? i.message : "语音识别失败,请重试。";
268
- n.error = r;
269
+ const a = t.prompt.trim();
270
+ t.prompt = a ? `${a} ${r}` : r;
271
+ } catch (r) {
272
+ if (n.signal.aborted) return;
273
+ t.error = $(r) || "语音识别失败,请重试。";
269
274
  } finally {
270
- A.value = null, y.value = !1, u.value = !1, m.value = !1, c.reset();
275
+ x.value = null, k.value = !1, p.value = !1, y.value = !1, u.reset();
271
276
  }
272
277
  }
273
- function me(e) {
278
+ function ye(e) {
274
279
  if (e.repeat || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
275
- const t = J();
276
- !n.visible && !t || n.visible && n.loading || (e.preventDefault(), !(T.value != null || u.value) && (T.value = window.setTimeout(async () => {
277
- T.value = null;
278
- const i = J();
279
- if (!(!n.visible && !i) && !(n.visible && n.loading))
280
+ const n = Z();
281
+ !t.visible && !n || t.visible && t.loading || (e.preventDefault(), !(L.value != null || p.value) && (L.value = window.setTimeout(async () => {
282
+ L.value = null;
283
+ const r = Z();
284
+ if (!(!t.visible && !r) && !(t.visible && t.loading))
280
285
  try {
281
- await b.startRecording(), u.value = !0, m.value = i, i ? c.setRecording(!0) : c.reset(), n.error = "";
282
- } catch (r) {
283
- const a = r instanceof Error ? r.message : "无法启动语音录制。";
284
- n.error = a, u.value = !1, m.value = !1, c.reset();
286
+ await w.startRecording(), p.value = !0, y.value = r, r ? u.setRecording(!0) : u.reset(), t.error = "";
287
+ } catch (i) {
288
+ t.error = $(i), p.value = !1, y.value = !1, u.reset();
285
289
  }
286
290
  }, 450)));
287
291
  }
288
- async function be() {
289
- if (!(!j() || C.value)) {
290
- C.value = !0;
292
+ async function Se() {
293
+ if (!(!X() || E.value)) {
294
+ E.value = !0;
291
295
  try {
292
- if (w(), await b.startRecording(), !h.value) {
293
- b.cancel();
296
+ if (C(), await w.startRecording(), !g.value) {
297
+ w.cancel();
294
298
  return;
295
299
  }
296
- u.value = !0, m.value = !0, c.setRecording(!0), n.error = "";
300
+ p.value = !0, y.value = !0, u.setRecording(!0), t.error = "";
297
301
  } catch (e) {
298
- const t = e instanceof Error ? e.message : "无法启动语音录制。";
299
- n.error = t, u.value = !1, m.value = !1, c.reset();
302
+ t.error = $(e), p.value = !1, y.value = !1, u.reset();
300
303
  } finally {
301
- C.value = !1;
304
+ E.value = !1;
302
305
  }
303
306
  }
304
307
  }
305
- function ye() {
306
- u.value && X();
308
+ function we() {
309
+ p.value && ne();
307
310
  }
308
- function Se(e) {
309
- if (e.code !== oe || !n.visible && !u.value) return;
311
+ function ke(e) {
312
+ if (e.code !== se || !t.visible && !p.value) return;
310
313
  e.preventDefault();
311
- const t = u.value;
312
- z(), t && X();
314
+ const n = p.value;
315
+ G(), n && ne();
313
316
  }
314
- function ke(e) {
315
- if (e.code === oe) {
316
- me(e);
317
+ function Pe(e) {
318
+ if (e.code === se) {
319
+ ye(e);
317
320
  return;
318
321
  }
319
- const t = e.key.toLowerCase(), i = e.metaKey || e.ctrlKey;
320
- V.avatarEnabled && i && t === "l" && (e.preventDefault(), E.toggle());
321
- }
322
- function we() {
323
- E.show();
322
+ const n = e.key.toLowerCase(), r = e.metaKey || e.ctrlKey;
323
+ S.avatarEnabled && r && n === "l" && (e.preventDefault(), B.toggle());
324
324
  }
325
325
  function Te() {
326
- l.abort("escape").then(() => {
327
- S.value = !1, g.value += 1, w(), s.reset(), n.showThinkingBar ? n.closeThinking() : n.visible && n.close();
326
+ B.show();
327
+ }
328
+ function Ce() {
329
+ s.abort("escape").then(() => {
330
+ P.value = !1, b.value += 1, C(), c.reset(), t.showThinkingBar ? t.closeThinking() : t.visible && t.close();
328
331
  });
329
332
  }
330
- function Ce(e) {
333
+ function Le(e) {
331
334
  if (!e) {
332
- if (!je({
333
- loading: n.loading,
334
- pipelinePhase: n.pipelinePhase
335
+ if (!Xe({
336
+ loading: t.loading,
337
+ pipelinePhase: t.pipelinePhase
335
338
  })) {
336
- H();
339
+ _();
337
340
  return;
338
341
  }
339
- l.abort("panel_close"), H(), h.value && n.prepareLive2dVoiceChannel();
342
+ s.abort("panel_close"), _(), g.value && t.prepareLive2dVoiceChannel();
340
343
  }
341
344
  }
342
- return Z(h, (e) => {
343
- if (V.avatarEnabled) {
345
+ return te(g, (e) => {
346
+ if (S.avatarEnabled) {
344
347
  if (!e) {
345
- S.value = !1, l.abort("avatar_close"), H(), w(), s.reset(), c.reset();
348
+ P.value = !1, s.abort("avatar_close"), _(), C(), c.reset(), u.reset();
346
349
  return;
347
350
  }
348
- n.visible || n.prepareLive2dVoiceChannel(), Qe(), fe();
351
+ t.visible || t.prepareLive2dVoiceChannel(), Je(), de();
349
352
  }
350
- }), Z(
351
- () => Je({
352
- loading: n.loading,
353
- speaking: l.phase === "speaking" || x.value,
354
- toolRunning: n.agentSteps.some(
353
+ }), te(
354
+ () => Ze({
355
+ loading: t.loading,
356
+ speaking: s.phase === "speaking" || K.value,
357
+ toolRunning: t.agentSteps.some(
355
358
  (e) => e.toolCalls?.some(
356
- (t) => t.status === "running" || t.status === "pending"
359
+ (n) => n.status === "running" || n.status === "pending"
357
360
  )
358
361
  ),
359
- interrupted: l.phase === "interrupted"
362
+ interrupted: s.phase === "interrupted"
360
363
  }),
361
364
  (e) => {
362
- l.phase === "interrupted" || l.phase === "error" || l.setPhase(e);
365
+ s.phase === "interrupted" || s.phase === "error" || s.setPhase(e);
363
366
  }
364
- ), Be(() => {
365
- V.avatarEnabled && K.initiallyVisible && E.show();
366
- }), xe(() => {
367
- l.abort("session_end"), H(), w(), s.reset(), c.reset();
368
- }), (e, t) => (U(), ee(He, null, [
369
- _e(Ze, {
370
- "deck-kicker": ae.value,
371
- "voice-hold-active": u.value,
372
- "speech-pending": y.value,
373
- "voice-key-label": ot,
374
- "show-thinking": le.value,
375
- "thinking-centered": se.value,
376
- "on-escape": Te,
377
- "on-keydown": ke,
378
- "on-keyup": Se,
379
- onVisibleChange: Ce
367
+ ), He(() => {
368
+ S.avatarEnabled && F.initiallyVisible && B.show(), S.avatarEnabled && d.startPolling();
369
+ }), Ke(() => {
370
+ s.abort("session_end"), _(), C(), c.reset(), u.reset();
371
+ }), (e, n) => (N(), re(_e, null, [
372
+ Re(tn, {
373
+ "deck-kicker": ce.value,
374
+ "voice-hold-active": p.value,
375
+ "speech-pending": k.value,
376
+ "voice-key-label": cn,
377
+ "show-thinking": ue.value,
378
+ "thinking-centered": pe.value,
379
+ "on-escape": Ce,
380
+ "on-keydown": Pe,
381
+ "on-keyup": ke,
382
+ onVisibleChange: Le
380
383
  }, null, 8, ["deck-kicker", "voice-hold-active", "speech-pending", "show-thinking", "thinking-centered"]),
381
- O.avatarEnabled && M(h) ? (U(), Ke(et, {
384
+ O.avatarEnabled && l(g) ? (N(), Fe(rn, {
382
385
  key: 0,
383
- "voice-disabled": M(n).loading || y.value || C.value,
384
- "voice-error": M(n).error,
385
- onVoiceStart: be,
386
- onVoiceStop: ye,
387
- onClose: M(E).hide
388
- }, null, 8, ["voice-disabled", "voice-error", "onClose"])) : O.avatarEnabled ? (U(), ee("button", {
386
+ "voice-disabled": l(t).loading || k.value || E.value,
387
+ "voice-error": l(t).error,
388
+ "phone-pair-available": l(d).canShow.value,
389
+ "phone-pair-open": l(d).panelOpen.value,
390
+ "phone-pair-qr": l(d).qrSvg.value,
391
+ "phone-pair-url": l(d).pairUrl.value,
392
+ "phone-pair-error": l(d).pairError.value,
393
+ "phone-connected": l(d).phoneConnected.value,
394
+ onVoiceStart: Se,
395
+ onVoiceStop: we,
396
+ onPhonePair: l(d).openPanel,
397
+ onPhonePairClose: l(d).closePanel,
398
+ onDismissError: n[0] || (n[0] = (r) => l(t).error = ""),
399
+ onDismissPairError: l(d).clearPairError,
400
+ onClose: l(B).hide
401
+ }, null, 8, ["voice-disabled", "voice-error", "phone-pair-available", "phone-pair-open", "phone-pair-qr", "phone-pair-url", "phone-pair-error", "phone-connected", "onPhonePair", "onPhonePairClose", "onDismissPairError", "onClose"])) : O.avatarEnabled ? (N(), re("button", {
389
402
  key: 1,
390
403
  type: "button",
391
404
  class: "spotlight-avatar-reopen",
392
405
  "aria-label": "再次打开数字人小滴",
393
406
  title: "再次打开小滴(Ctrl/Command + L)",
394
- onClick: we
395
- }, [...t[0] || (t[0] = [
396
- te("span", {
407
+ onClick: Te
408
+ }, [...n[1] || (n[1] = [
409
+ ie("span", {
397
410
  class: "spotlight-avatar-reopen__drop",
398
411
  "aria-hidden": "true"
399
412
  }, null, -1),
400
- te("span", { class: "spotlight-avatar-reopen__label" }, "小滴", -1)
401
- ])])) : Re("", !0)
413
+ ie("span", { class: "spotlight-avatar-reopen__label" }, "小滴", -1)
414
+ ])])) : Ie("", !0)
402
415
  ], 64));
403
416
  }
404
417
  });
405
418
  export {
406
- Tt as default
419
+ An as default
407
420
  };