@siact/sime-x-vue 0.0.18 → 0.0.19

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.
@@ -106,7 +106,7 @@ const _hoisted_9$2 = ["onClick"];
106
106
  const _hoisted_10$2 = { class: "ai-chat__messages-inner" };
107
107
  const _hoisted_11$2 = { class: "ai-chat__message-content" };
108
108
  const _hoisted_12$2 = ["innerHTML"];
109
- const _hoisted_13$2 = {
109
+ const _hoisted_13$1 = {
110
110
  key: 1,
111
111
  class: "ai-chat__reasoning"
112
112
  };
@@ -469,7 +469,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
469
469
  innerHTML: renderMarkdown(part.text)
470
470
  }, null, 8, _hoisted_12$2)
471
471
  ])
472
- ], 2)) : part.type === "reasoning" ? (openBlock(), createElementBlock("div", _hoisted_13$2, [
472
+ ], 2)) : part.type === "reasoning" ? (openBlock(), createElementBlock("div", _hoisted_13$1, [
473
473
  createElementVNode("button", {
474
474
  class: "ai-chat__reasoning-trigger",
475
475
  onClick: ($event) => toggleReasoning(message.id)
@@ -1464,7 +1464,7 @@ const _hoisted_10$1 = {
1464
1464
  };
1465
1465
  const _hoisted_11$1 = { class: "input-bar" };
1466
1466
  const _hoisted_12$1 = ["disabled"];
1467
- const _hoisted_13$1 = ["disabled"];
1467
+ const _hoisted_13 = ["disabled"];
1468
1468
  const _hoisted_14 = {
1469
1469
  key: 0,
1470
1470
  class: "btn-spinner",
@@ -1511,6 +1511,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1511
1511
  scrollToBottom: () => {
1512
1512
  }
1513
1513
  };
1514
+ const test = () => {
1515
+ aiChatbotX.invokeText("你好");
1516
+ };
1517
+ const test1 = () => {
1518
+ aiChatbotX.abortInvoke();
1519
+ };
1514
1520
  const endpoint = `/sime/proxy/organizations/${aiChatbotX.organizationId()}/agents/${props.agentId}/stream-invoke`;
1515
1521
  const agent = useAgentInvoke({
1516
1522
  endpoint,
@@ -1549,6 +1555,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1549
1555
  class: "command-test",
1550
1556
  "data-theme": currentTheme$1
1551
1557
  }, [
1558
+ createElementVNode("button", { onClick: test }, "测试"),
1559
+ createElementVNode("button", { onClick: test1 }, "测试1"),
1552
1560
  createVNode(Transition, { name: "bubble-fade" }, {
1553
1561
  default: withCtx(() => [
1554
1562
  unref(showBubble) ? (openBlock(), createElementBlock("div", {
@@ -1663,14 +1671,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1663
1671
  "stroke-linejoin": "round"
1664
1672
  }, null, -1)
1665
1673
  ])]))
1666
- ], 8, _hoisted_13$1)
1674
+ ], 8, _hoisted_13)
1667
1675
  ])
1668
1676
  ]);
1669
1677
  };
1670
1678
  }
1671
1679
  });
1672
1680
 
1673
- const commandTest = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-5c7468c4"]]);
1681
+ const commandTest = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-93ed98f5"]]);
1674
1682
 
1675
1683
  class CommandManager {
1676
1684
  commands = /* @__PURE__ */ new Map();
@@ -1731,7 +1739,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1731
1739
  __name: "sime-provider",
1732
1740
  props: {
1733
1741
  appToken: {},
1734
- organizationId: {}
1742
+ organizationId: {},
1743
+ projectId: {}
1735
1744
  },
1736
1745
  setup(__props) {
1737
1746
  const props = __props;
@@ -1742,6 +1751,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1742
1751
  });
1743
1752
  const stopBroadcastRef = shallowRef(async () => {
1744
1753
  });
1754
+ const voiceAssistantRef = shallowRef(
1755
+ null
1756
+ );
1745
1757
  provide(AiChatbotXKey, {
1746
1758
  appToken: () => props.appToken,
1747
1759
  organizationId: () => props.organizationId,
@@ -1753,6 +1765,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1753
1765
  if (methods.start) startListeningRef.value = methods.start;
1754
1766
  if (methods.stop) stopListeningRef.value = methods.stop;
1755
1767
  },
1768
+ registerVoiceAssistant: (methods) => {
1769
+ voiceAssistantRef.value = methods;
1770
+ },
1756
1771
  getCommads: async () => commandManager.value.getCommands(),
1757
1772
  registerCommand: (cmd) => {
1758
1773
  commandManager.value.registerCommand(cmd);
@@ -1762,6 +1777,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1762
1777
  },
1763
1778
  async executeCommand(commandName, args = []) {
1764
1779
  return await commandManager.value.executeCommand(commandName, args);
1780
+ },
1781
+ invokeText: async (text) => {
1782
+ voiceAssistantRef.value?.agentInvoke(text);
1783
+ },
1784
+ abortInvoke: () => {
1785
+ voiceAssistantRef.value?.agentAbort();
1765
1786
  }
1766
1787
  });
1767
1788
  return (_ctx, _cache) => {
@@ -1789,7 +1810,27 @@ function useTTS(getVoiceConfig) {
1789
1810
  }
1790
1811
  return -1;
1791
1812
  };
1792
- const stripMarkdown = (text) => text.replace(/```[\s\S]*?```/g, "").replace(/\|[^\n]*\|/g, "").replace(/#{1,6}\s*/g, "").replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/`([^`]*)`/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^[-*+]\s+/gm, "").replace(/^>\s+/gm, "").replace(/\s*\+\s*/g, "加").replace(/\s*-\s*/g, "减").replace(/\s*×\s*/g, "乘").replace(/\s*÷\s*/g, "除").replace(/\s*=\s*/g, "等于").replace(/(\d)\.(\d)/g, "$1点$2").replace(/\n{2,}/g, "。").replace(/\n/g, ",").trim();
1813
+ const normalizeNumbers = (text) => {
1814
+ return text.replace(/(-?\d[\d,]*\.?\d*)\s*%/g, (_, num) => {
1815
+ const cleanNum = num.replace(/,/g, "");
1816
+ const n = parseFloat(cleanNum);
1817
+ const spoken = cleanNum.replace(".", "点");
1818
+ if (n < 0) return `负百分之${spoken.replace("-", "")}`;
1819
+ return `百分之${spoken}`;
1820
+ }).replace(/(-?\d[\d,]*)\.(\d+)/g, (_, intPart, decPart) => {
1821
+ const cleanInt = intPart.replace(/,/g, "");
1822
+ if (cleanInt.startsWith("-")) {
1823
+ return `负${cleanInt.slice(1)}点${decPart}`;
1824
+ }
1825
+ return `${cleanInt}点${decPart}`;
1826
+ }).replace(/-(\d)/g, "负$1");
1827
+ };
1828
+ const stripMarkdown = (text) => {
1829
+ let result = text.replace(/```[\s\S]*?```/g, "").replace(/\|[^\n]*\|/g, "").replace(/#{1,6}\s*/g, "").replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/`([^`]*)`/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^[-*+]\s+/gm, "").replace(/^>\s+/gm, "");
1830
+ result = normalizeNumbers(result);
1831
+ result = result.replace(/\s*\+\s*(?=\d)/g, "加").replace(/\s*\+\s*/g, "加").replace(/\s*-\s*(?=\d)/g, "减").replace(/\s*-\s*/g, "减").replace(/\s*×\s*/g, "乘").replace(/\s*÷\s*/g, "除").replace(/\s*=\s*/g, "等于").replace(/\n{2,}/g, "。").replace(/\n/g, ",").trim();
1832
+ return result;
1833
+ };
1793
1834
  const normalizeSpeakText = (text, options) => {
1794
1835
  const clean = stripMarkdown(text).replace(LEADING_WEAK_PUNCTUATION, "").trim();
1795
1836
  if (!clean) return "";
@@ -2209,12 +2250,8 @@ const _hoisted_10 = {
2209
2250
  key: 2,
2210
2251
  class: "agent-text"
2211
2252
  };
2212
- const _hoisted_11 = {
2213
- key: 0,
2214
- class: "status-pill"
2215
- };
2216
- const _hoisted_12 = { class: "fab-avatar-wrapper" };
2217
- const _hoisted_13 = ["src"];
2253
+ const _hoisted_11 = { class: "fab-avatar-wrapper" };
2254
+ const _hoisted_12 = ["src"];
2218
2255
  const currentTheme = "dark";
2219
2256
  const _sfc_main = /* @__PURE__ */ defineComponent({
2220
2257
  __name: "voice-assistant",
@@ -2303,13 +2340,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2303
2340
  tts.warmUpAudio();
2304
2341
  await voice.toggleVoiceMode(targetState);
2305
2342
  };
2306
- const { voiceStatus, transcriptionText, wakeAnimating, isTranscribing } = voice;
2343
+ const { voiceStatus, wakeAnimating, isTranscribing } = voice;
2307
2344
  const { isInvoking, currentTextContent, currentToolParts, executingTools, hasAnyContent, toolDisplayName } = agent;
2308
2345
  aiChatbotX?.registerVoiceMethods({
2309
2346
  stopBroadcast: async () => interruptCurrentResponse(),
2310
2347
  start: () => toggleVoiceMode(true),
2311
2348
  stop: () => toggleVoiceMode(false)
2312
2349
  });
2350
+ aiChatbotX?.registerVoiceAssistant({
2351
+ agentInvoke: agent.invoke,
2352
+ agentAbort: agent.abort
2353
+ });
2313
2354
  onBeforeUnmount(async () => {
2314
2355
  bubble.destroy();
2315
2356
  agent.abort();
@@ -2397,15 +2438,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2397
2438
  class: "assistant-fab",
2398
2439
  onClick: _cache[0] || (_cache[0] = ($event) => toggleVoiceMode())
2399
2440
  }, [
2400
- unref(transcriptionText) || unref(isInvoking) ? (openBlock(), createElementBlock("div", _hoisted_11, toDisplayString(unref(isInvoking) ? "正在思考中..." : unref(transcriptionText)), 1)) : createCommentVNode("", true),
2401
- createElementVNode("div", _hoisted_12, [
2441
+ createElementVNode("div", _hoisted_11, [
2402
2442
  createElementVNode("img", {
2403
2443
  src: __props.xLogo ? __props.xLogo : "/x.png",
2404
2444
  alt: "voice assistant",
2405
2445
  style: normalizeStyle({
2406
2446
  width: `${__props.xSize?.width || 88}px`
2407
2447
  })
2408
- }, null, 12, _hoisted_13),
2448
+ }, null, 12, _hoisted_12),
2409
2449
  createVNode(Transition, { name: "indicator-fade" }, {
2410
2450
  default: withCtx(() => [
2411
2451
  unref(voiceStatus) === "listening" ? (openBlock(), createElementBlock("div", {
@@ -2447,7 +2487,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2447
2487
  }
2448
2488
  });
2449
2489
 
2450
- const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-59d72f34"]]);
2490
+ const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d1d9b351"]]);
2451
2491
 
2452
2492
  var clientCommandKey = /* @__PURE__ */ ((clientCommandKey2) => {
2453
2493
  clientCommandKey2["SET_THEME"] = "SiMeAgent_setTheme";