@siact/sime-x-vue 0.0.8 → 0.0.9
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/sime-x-vue.mjs +42 -15
- package/dist/sime-x-vue.mjs.map +1 -1
- package/dist/sime-x-vue.umd.js +42 -15
- package/dist/sime-x-vue.umd.js.map +1 -1
- package/dist/style.css +60 -60
- package/package.json +1 -1
- package/types/composables/use-bubble.d.ts +3 -1
- package/types/composables/use-tts.d.ts +1 -0
package/dist/sime-x-vue.mjs
CHANGED
|
@@ -997,6 +997,7 @@ const simeX = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-91
|
|
|
997
997
|
|
|
998
998
|
function useTTS(getVoiceConfig) {
|
|
999
999
|
const isSpeaking = ref(false);
|
|
1000
|
+
const hasPendingAudio = ref(false);
|
|
1000
1001
|
let instance = null;
|
|
1001
1002
|
let initPromise = null;
|
|
1002
1003
|
let audioCtx = null;
|
|
@@ -1047,6 +1048,7 @@ function useTTS(getVoiceConfig) {
|
|
|
1047
1048
|
});
|
|
1048
1049
|
tts.onQueueEmpty(() => {
|
|
1049
1050
|
isSpeaking.value = false;
|
|
1051
|
+
hasPendingAudio.value = false;
|
|
1050
1052
|
onQueueEmptyCb?.();
|
|
1051
1053
|
});
|
|
1052
1054
|
tts.onError((err) => {
|
|
@@ -1072,6 +1074,7 @@ function useTTS(getVoiceConfig) {
|
|
|
1072
1074
|
const speak = async (text) => {
|
|
1073
1075
|
const clean = stripMarkdown(text);
|
|
1074
1076
|
if (!clean.trim()) return;
|
|
1077
|
+
hasPendingAudio.value = true;
|
|
1075
1078
|
const tts = await ensureInstance();
|
|
1076
1079
|
if (!tts) return;
|
|
1077
1080
|
try {
|
|
@@ -1098,6 +1101,7 @@ function useTTS(getVoiceConfig) {
|
|
|
1098
1101
|
const stop = () => {
|
|
1099
1102
|
sentenceBuffer = "";
|
|
1100
1103
|
isSpeaking.value = false;
|
|
1104
|
+
hasPendingAudio.value = false;
|
|
1101
1105
|
if (instance) {
|
|
1102
1106
|
try {
|
|
1103
1107
|
instance.stop();
|
|
@@ -1127,6 +1131,7 @@ function useTTS(getVoiceConfig) {
|
|
|
1127
1131
|
};
|
|
1128
1132
|
return {
|
|
1129
1133
|
isSpeaking,
|
|
1134
|
+
hasPendingAudio,
|
|
1130
1135
|
warmUpAudio,
|
|
1131
1136
|
speak,
|
|
1132
1137
|
feed,
|
|
@@ -1142,7 +1147,14 @@ function useBubble(options = {}) {
|
|
|
1142
1147
|
const fadingOut = ref(false);
|
|
1143
1148
|
const stackRef = ref(null);
|
|
1144
1149
|
let dismissTimer = null;
|
|
1145
|
-
const
|
|
1150
|
+
const hasOpened = ref(false);
|
|
1151
|
+
const isTTSActive = () => !!(options.isSpeaking?.value || options.hasPendingAudio?.value);
|
|
1152
|
+
const isBusy = () => !!(options.isInvoking?.value || isTTSActive());
|
|
1153
|
+
const show = computed(() => {
|
|
1154
|
+
if (!hasOpened.value) return false;
|
|
1155
|
+
if (isTTSActive()) return true;
|
|
1156
|
+
return visible.value && !fadingOut.value;
|
|
1157
|
+
});
|
|
1146
1158
|
const style = computed(() => ({
|
|
1147
1159
|
width: options.bubbleSize?.width || void 0,
|
|
1148
1160
|
maxHeight: options.bubbleSize?.maxHeight || void 0
|
|
@@ -1151,6 +1163,7 @@ function useBubble(options = {}) {
|
|
|
1151
1163
|
cancelDismiss();
|
|
1152
1164
|
fadingOut.value = false;
|
|
1153
1165
|
visible.value = true;
|
|
1166
|
+
hasOpened.value = true;
|
|
1154
1167
|
};
|
|
1155
1168
|
const cancelDismiss = () => {
|
|
1156
1169
|
if (dismissTimer) {
|
|
@@ -1160,21 +1173,39 @@ function useBubble(options = {}) {
|
|
|
1160
1173
|
};
|
|
1161
1174
|
const scheduleDismiss = () => {
|
|
1162
1175
|
cancelDismiss();
|
|
1163
|
-
if (
|
|
1164
|
-
if (options.isInvoking?.value) return;
|
|
1176
|
+
if (isBusy()) return;
|
|
1165
1177
|
const delay = options.dismissDelay ?? 4e3;
|
|
1166
1178
|
dismissTimer = setTimeout(() => {
|
|
1179
|
+
if (isBusy()) return;
|
|
1167
1180
|
fadingOut.value = true;
|
|
1168
1181
|
setTimeout(() => {
|
|
1182
|
+
if (isBusy()) {
|
|
1183
|
+
fadingOut.value = false;
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1169
1186
|
visible.value = false;
|
|
1170
1187
|
fadingOut.value = false;
|
|
1188
|
+
hasOpened.value = false;
|
|
1171
1189
|
}, 400);
|
|
1172
1190
|
}, delay);
|
|
1173
1191
|
};
|
|
1192
|
+
const watchTTSRef = (ttsRef) => {
|
|
1193
|
+
watch(ttsRef, (active) => {
|
|
1194
|
+
if (active && hasOpened.value) {
|
|
1195
|
+
cancelDismiss();
|
|
1196
|
+
if (fadingOut.value) fadingOut.value = false;
|
|
1197
|
+
} else if (!active && hasOpened.value && !isBusy()) {
|
|
1198
|
+
scheduleDismiss();
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
};
|
|
1202
|
+
if (options.isSpeaking) watchTTSRef(options.isSpeaking);
|
|
1203
|
+
if (options.hasPendingAudio) watchTTSRef(options.hasPendingAudio);
|
|
1174
1204
|
const hide = () => {
|
|
1175
1205
|
cancelDismiss();
|
|
1176
1206
|
fadingOut.value = false;
|
|
1177
1207
|
visible.value = false;
|
|
1208
|
+
hasOpened.value = false;
|
|
1178
1209
|
};
|
|
1179
1210
|
const scrollToBottom = () => {
|
|
1180
1211
|
nextTick(() => {
|
|
@@ -1804,7 +1835,7 @@ function useAgentInvoke(options) {
|
|
|
1804
1835
|
const processedToolResults = /* @__PURE__ */ new Set();
|
|
1805
1836
|
abortController = new AbortController();
|
|
1806
1837
|
const commands = await aiChatbotX.hostCommads();
|
|
1807
|
-
|
|
1838
|
+
conversationHistory.value.length > 0 ? [...conversationHistory.value] : void 0;
|
|
1808
1839
|
try {
|
|
1809
1840
|
const response = await fetch(options.endpoint.value, {
|
|
1810
1841
|
method: "POST",
|
|
@@ -1812,8 +1843,8 @@ function useAgentInvoke(options) {
|
|
|
1812
1843
|
body: JSON.stringify({
|
|
1813
1844
|
input: content,
|
|
1814
1845
|
projectId: options.projectId || "",
|
|
1815
|
-
commands: commands.length > 0 ? commands : void 0
|
|
1816
|
-
messages: historyToSend
|
|
1846
|
+
commands: commands.length > 0 ? commands : void 0
|
|
1847
|
+
// messages: historyToSend,
|
|
1817
1848
|
}),
|
|
1818
1849
|
signal: abortController.signal
|
|
1819
1850
|
});
|
|
@@ -1992,7 +2023,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1992
2023
|
const endpoint = computed(() => {
|
|
1993
2024
|
return props.invokeUrl || "http://localhost:3001/agent/zyy55sw40nrl801056m0o/stream-invoke";
|
|
1994
2025
|
});
|
|
1995
|
-
const wakeResponses = ["
|
|
2026
|
+
const wakeResponses = ["在呢"];
|
|
1996
2027
|
const tts = useTTS(getVoiceConfig);
|
|
1997
2028
|
const bubbleBridge = {
|
|
1998
2029
|
open: () => {
|
|
@@ -2021,6 +2052,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2021
2052
|
const bubble = useBubble({
|
|
2022
2053
|
dismissDelay: props.bubbleDismissDelay,
|
|
2023
2054
|
isSpeaking: tts.isSpeaking,
|
|
2055
|
+
hasPendingAudio: tts.hasPendingAudio,
|
|
2024
2056
|
isInvoking: agent.isInvoking,
|
|
2025
2057
|
bubbleSize: props.bubbleSize
|
|
2026
2058
|
});
|
|
@@ -2028,11 +2060,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2028
2060
|
bubbleBridge.scheduleDismiss = bubble.scheduleDismiss;
|
|
2029
2061
|
bubbleBridge.scrollToBottom = bubble.scrollToBottom;
|
|
2030
2062
|
const { show: showBubble, style: bubbleStyle, stackRef: bubbleStackRef } = bubble;
|
|
2031
|
-
tts.setOnQueueEmpty(() => {
|
|
2032
|
-
if (!agent.isInvoking.value) {
|
|
2033
|
-
bubble.scheduleDismiss();
|
|
2034
|
-
}
|
|
2035
|
-
});
|
|
2036
2063
|
const interruptCurrentResponse = () => {
|
|
2037
2064
|
agent.abort();
|
|
2038
2065
|
agent.resetState();
|
|
@@ -2057,7 +2084,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2057
2084
|
tts.warmUpAudio();
|
|
2058
2085
|
await voice.toggleVoiceMode(targetState);
|
|
2059
2086
|
};
|
|
2060
|
-
const { voiceStatus, transcriptionText, wakeAnimating } = voice;
|
|
2087
|
+
const { voiceStatus, transcriptionText, wakeAnimating, isTranscribing } = voice;
|
|
2061
2088
|
const { isInvoking, currentTextContent, currentToolParts, executingTools, hasAnyContent, toolDisplayName } = agent;
|
|
2062
2089
|
aiChatbotX?.registerVoiceMethods({
|
|
2063
2090
|
start: () => toggleVoiceMode(true),
|
|
@@ -2166,7 +2193,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2166
2193
|
default: withCtx(() => [
|
|
2167
2194
|
unref(voiceStatus) === "listening" ? (openBlock(), createElementBlock("div", {
|
|
2168
2195
|
key: 0,
|
|
2169
|
-
class: normalizeClass(["listening-badge", { "wake-active": unref(wakeAnimating) }])
|
|
2196
|
+
class: normalizeClass(["listening-badge", { "wake-active": unref(wakeAnimating) || unref(isTranscribing) || unref(isInvoking) }])
|
|
2170
2197
|
}, [..._cache[5] || (_cache[5] = [
|
|
2171
2198
|
createElementVNode("div", { class: "listening-waves" }, [
|
|
2172
2199
|
createElementVNode("div", { class: "wave wave-1" }),
|
|
@@ -2203,7 +2230,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2203
2230
|
}
|
|
2204
2231
|
});
|
|
2205
2232
|
|
|
2206
|
-
const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
2233
|
+
const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d81f42d8"]]);
|
|
2207
2234
|
|
|
2208
2235
|
export { _sfc_main$4 as AiChatbotProvider, voiceAssistant as AiChatbotVoiceAssistant, simeX as AiChatbotX, AiChatbotXKey, clientCommandKey, injectStrict };
|
|
2209
2236
|
//# sourceMappingURL=sime-x-vue.mjs.map
|