@myun/gimi-chat 0.9.65 → 0.9.67

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 (54) hide show
  1. package/dist/apis/useApi.d.ts +6 -0
  2. package/dist/apis/useApi.js +45 -1
  3. package/dist/components/ai-chat-dialogue/index copy.js +1 -1
  4. package/dist/components/ai-chat-dialogue/index.js +4 -2
  5. package/dist/components/answer-item/component/artifacts/index.d.ts +13 -0
  6. package/dist/components/answer-item/component/artifacts/index.js +52 -0
  7. package/dist/components/answer-item/component/artifacts/index.module.css +24 -0
  8. package/dist/components/answer-item/component/tool-list/index.d.ts +7 -0
  9. package/dist/components/answer-item/component/tool-list/index.js +117 -0
  10. package/dist/components/answer-item/component/tool-list/index.module.css +97 -0
  11. package/dist/components/answer-item/index.d.ts +2 -1
  12. package/dist/components/answer-item/index.js +179 -8
  13. package/dist/components/answer-item/index.module.css +35 -0
  14. package/dist/components/ask-card/index.d.ts +1 -1
  15. package/dist/components/chat-input/extension/index.d.ts +1 -0
  16. package/dist/components/chat-input/extension/index.js +2 -1
  17. package/dist/components/chat-input/extension/skill/MentionList.d.ts +32 -0
  18. package/dist/components/chat-input/extension/skill/MentionList.js +206 -0
  19. package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +3 -0
  20. package/dist/components/chat-input/extension/skill/ReferSlot.js +100 -0
  21. package/dist/components/chat-input/extension/skill/data.d.ts +10 -0
  22. package/dist/components/chat-input/extension/skill/data.js +49 -0
  23. package/dist/components/chat-input/extension/skill/index.d.ts +7 -0
  24. package/dist/components/chat-input/extension/skill/index.js +5 -0
  25. package/dist/components/chat-input/extension/skill/index.less +117 -0
  26. package/dist/components/chat-input/extension/skill/suggestion.d.ts +16 -0
  27. package/dist/components/chat-input/extension/skill/suggestion.js +228 -0
  28. package/dist/components/chat-input/index.js +145 -24
  29. package/dist/components/chat-input/index.module.css +6 -0
  30. package/dist/components/file-card/index.js +2 -1
  31. package/dist/components/file-card/index.module.css +1 -0
  32. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +6 -1
  33. package/dist/components/knowledge-trace/tryWatch.js +2 -2
  34. package/dist/components/message-list/index.js +15 -3
  35. package/dist/components/message-list/index.module.css +3 -0
  36. package/dist/components/message-list/skill-tag/index.d.ts +5 -0
  37. package/dist/components/message-list/skill-tag/index.js +23 -0
  38. package/dist/components/message-list/skill-tag/index.module.css +22 -0
  39. package/dist/components/templates/CommonChat.js +3 -1
  40. package/dist/hooks/useChatActions.d.ts +2 -1
  41. package/dist/hooks/useChatActions.js +52 -12
  42. package/dist/hooks/useChatStream.d.ts +6 -1
  43. package/dist/hooks/useChatStream.js +97 -5
  44. package/dist/hooks/useCommonChatAPI.d.ts +1 -1
  45. package/dist/hooks/useCommonChatAPI.js +212 -58
  46. package/dist/i18n/locales/en-US.d.ts +7 -0
  47. package/dist/i18n/locales/en-US.js +8 -1
  48. package/dist/i18n/locales/zh-CN.d.ts +7 -0
  49. package/dist/i18n/locales/zh-CN.js +8 -1
  50. package/dist/interfaces/chatMessage.d.ts +40 -0
  51. package/dist/umd/index.min.js +1 -1
  52. package/dist/utils/tools.d.ts +7 -0
  53. package/dist/utils/tools.js +38 -1
  54. package/package.json +4 -2
@@ -1,20 +1,24 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
3
7
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
8
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7
9
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
10
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
11
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
13
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
14
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- import React, { useContext } from "react";
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
20
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
+ import React, { useContext, useEffect, useMemo } from "react";
18
22
  import { useTranslation } from 'react-i18next';
19
23
  import { AIChatInput, Divider, Popover } from '@douyinfe/semi-ui';
20
24
  import { transformToInputSlots } from "../../utils/chatInputUtil";
@@ -33,20 +37,33 @@ import UploadList from "../upload-list";
33
37
  import { FileStatus } from "../../interfaces/fileInterface";
34
38
  import LottieImg from "../lottie-img";
35
39
  import AIChatDialogue from "../ai-chat-dialogue";
36
- import { Keydown, TitleSlot } from "./extension";
40
+ import { Keydown, TitleSlot, ReferSlot, SkillMention, setSkillContext } from "./extension";
37
41
  import QuotedContent from "../quoted-content";
38
42
  import { ReferencesEdit } from "../reference-content";
39
43
  import IconFontCom from "../iconfont-com";
40
44
  import VoiceBars from "../voice-bars";
41
45
  import classNames from 'classnames';
46
+ import { maxInputLength } from "../../utils/tools";
42
47
  var extractText = function extractText() {
43
48
  var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
49
+ var skipSkill = arguments.length > 1 ? arguments[1] : undefined;
44
50
  return content.map(function (item) {
45
51
  if (item.type === 'text' && typeof item.text === 'string') {
46
52
  return item.text;
47
53
  }
54
+ // skill 节点序列化为 <skilltool> 标记发送,取值来自 content 中 transformer 展开后的 item
55
+
56
+ if (item.type === 'skill' && !skipSkill) {
57
+ var _skill$toolId, _skill$toolType, _skill$toolName;
58
+ var skill = item;
59
+ return "<skilltool>".concat(JSON.stringify({
60
+ toolId: (_skill$toolId = skill.toolId) !== null && _skill$toolId !== void 0 ? _skill$toolId : '',
61
+ toolType: (_skill$toolType = skill.toolType) !== null && _skill$toolType !== void 0 ? _skill$toolType : '',
62
+ toolName: (_skill$toolName = skill.toolName) !== null && _skill$toolName !== void 0 ? _skill$toolName : ''
63
+ }), "</skilltool>");
64
+ }
48
65
  if (item.content && Array.isArray(item.content)) {
49
- return extractText(item.content);
66
+ return extractText(item.content, skipSkill);
50
67
  }
51
68
  return '';
52
69
  }).join('');
@@ -84,12 +101,32 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
84
101
  var inputWrapRef = React.useRef(null);
85
102
  var preInputValueRef = React.useRef('');
86
103
  var inputRef = React.useRef(null);
104
+ var isTruncatingRef = React.useRef(false);
87
105
  var uploadFileRef = React.useRef(null);
88
106
  var conversationIdRef = React.useRef(conversationId);
89
107
  conversationIdRef.current = conversationId;
90
108
  var agentObjRef = React.useRef(agentObj);
91
109
  agentObjRef.current = agentObj;
92
-
110
+ var transformer = useMemo(function () {
111
+ return new Map([['referSlot', function (obj) {
112
+ var _obj$attrs = obj.attrs,
113
+ attrs = _obj$attrs === void 0 ? {} : _obj$attrs;
114
+ var value = attrs.value,
115
+ info = attrs.info,
116
+ _attrs$type = attrs.type,
117
+ type = _attrs$type === void 0 ? 'text' : _attrs$type,
118
+ uniqueKey = attrs.uniqueKey;
119
+ return _objectSpread({
120
+ type: type,
121
+ value: value,
122
+ uniqueKey: uniqueKey
123
+ }, JSON.parse(info || '{}'));
124
+ }]]);
125
+ }, []);
126
+ var extensions = useMemo(function () {
127
+ // 使用 / 触发 skill 下拉面板,选中后插入 referSlot
128
+ return [ReferSlot, SkillMention];
129
+ }, []);
93
130
  // 语音聊天相关
94
131
  var _React$useState = React.useState(false),
95
132
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -105,6 +142,26 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
105
142
  apiService = _useContext.apiService;
106
143
  var _ref = apiService,
107
144
  createRoomId = _ref.createRoomId;
145
+
146
+ // skill 面板由 tiptap ReactRenderer 渲染、脱离 Context 树,注入 agentId 与 apiService 供其拉取接口
147
+ useEffect(function () {
148
+ setSkillContext({
149
+ getAgentId: function getAgentId() {
150
+ var _agentObjRef$current;
151
+ return (_agentObjRef$current = agentObjRef.current) === null || _agentObjRef$current === void 0 ? void 0 : _agentObjRef$current.agentId;
152
+ },
153
+ getApiService: function getApiService() {
154
+ return apiService !== null && apiService !== void 0 ? apiService : null;
155
+ },
156
+ getSkillDisplay: function getSkillDisplay() {
157
+ var _agentObjRef$current2;
158
+ return (_agentObjRef$current2 = agentObjRef.current) === null || _agentObjRef$current2 === void 0 ? void 0 : _agentObjRef$current2.skillDisplay;
159
+ },
160
+ getCurrentTextLength: function getCurrentTextLength() {
161
+ return preInputValueRef.current.length;
162
+ }
163
+ });
164
+ }, [apiService]);
108
165
  React.useEffect(function () {
109
166
  if (!props.defaultPrompt) {
110
167
  setHasContent(false);
@@ -136,12 +193,49 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
136
193
  });
137
194
  var onContentChange = React.useCallback(function (content) {
138
195
  var _props$onValueChange;
196
+ // 长度按 extractText 的完整值计算(含 skill 序列化后的 <skilltool> 字符串)
139
197
  var value = extractText(content);
140
- if (value.length > 10000) {
141
- var _inputRef$current4;
142
- Toast.warning(t('chatInput.maxLength'));
143
- value = value.slice(0, 10000);
144
- (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || _inputRef$current4.setContent(value);
198
+ var overflow = value.length - maxInputLength;
199
+ // 超限时从文档末尾倒着删掉多余的文本字符,只动文本节点,
200
+ // skill / refer-slot / titleSlot 等节点结构原样保留(不能用 setContent,会把富文本拍平成纯文本)
201
+ if (overflow > 0 && !isTruncatingRef.current) {
202
+ var _inputRef$current4, _inputRef$current4$ge;
203
+ var editor = (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || (_inputRef$current4$ge = _inputRef$current4.getEditor) === null || _inputRef$current4$ge === void 0 ? void 0 : _inputRef$current4$ge.call(_inputRef$current4);
204
+ var ranges = [];
205
+ editor === null || editor === void 0 || editor.state.doc.descendants(function (node, pos) {
206
+ if (node.isText && node.text) {
207
+ ranges.push({
208
+ from: pos,
209
+ to: pos + node.text.length
210
+ });
211
+ }
212
+ return true;
213
+ });
214
+ var textTotal = ranges.reduce(function (sum, r) {
215
+ return sum + (r.to - r.from);
216
+ }, 0);
217
+ // 文本字符不足以抵掉超出量(超出来自 skill 节点本身),删也没用,避免死循环
218
+ if (editor && textTotal >= overflow) {
219
+ Toast.warning(t('chatInput.maxLength'));
220
+ var tr = editor.state.tr;
221
+ var remaining = overflow;
222
+ for (var i = ranges.length - 1; i >= 0 && remaining > 0; i--) {
223
+ var _ranges$i = ranges[i],
224
+ from = _ranges$i.from,
225
+ to = _ranges$i.to;
226
+ var take = Math.min(remaining, to - from);
227
+ tr.delete(tr.mapping.map(to - take), tr.mapping.map(to));
228
+ remaining -= take;
229
+ }
230
+ if (tr.docChanged) {
231
+ // 防止删除本身再次触发截断逻辑;删除后长度正好等于上限,
232
+ // 由它触发的这次回调会走下面的正常分支去同步 state
233
+ isTruncatingRef.current = true;
234
+ editor.view.dispatch(tr);
235
+ isTruncatingRef.current = false;
236
+ return;
237
+ }
238
+ }
145
239
  }
146
240
  setHasContent(value.trim().length > 0);
147
241
  preInputValueRef.current = value;
@@ -187,11 +281,37 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
187
281
  var el = inputWrapRef.current;
188
282
  if (!el) return;
189
283
  var handlePaste = function handlePaste(e) {
190
- var _e$clipboardData, _agentObjRef$current, _fileList$length, _uploadFileRef$curren;
191
- var items = Array.from(((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.items) || []);
284
+ var _e$clipboardData, _e$clipboardData2, _e$clipboardData3, _agentObjRef$current3, _fileList$length, _uploadFileRef$curren;
285
+ var pasteHtml = ((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.getData('text/html')) || '';
286
+ var pasteText = ((_e$clipboardData2 = e.clipboardData) === null || _e$clipboardData2 === void 0 ? void 0 : _e$clipboardData2.getData('text/plain')) || '';
287
+ var items = Array.from(((_e$clipboardData3 = e.clipboardData) === null || _e$clipboardData3 === void 0 ? void 0 : _e$clipboardData3.items) || []);
192
288
  var imageItem = items.find(function (item) {
193
289
  return item.kind === 'file' && item.type.startsWith('image/');
194
290
  });
291
+
292
+ // 含技能节点时,降级为纯文本插入(剥离 refer-slot 标签)
293
+ if (!imageItem && pasteHtml.includes('<refer-slot')) {
294
+ e.preventDefault();
295
+ e.stopPropagation();
296
+ if (pasteText) {
297
+ var _inputRef$current7;
298
+ if (preInputValueRef.current.length + pasteText.length > maxInputLength) {
299
+ Toast.warning(t('chatInput.maxLength'));
300
+ return;
301
+ }
302
+ (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 || (_inputRef$current7 = _inputRef$current7.getEditor()) === null || _inputRef$current7 === void 0 || (_inputRef$current7 = _inputRef$current7.commands) === null || _inputRef$current7 === void 0 || _inputRef$current7.insertContent(pasteText);
303
+ }
304
+ return;
305
+ }
306
+ if (!imageItem && pasteText) {
307
+ if (preInputValueRef.current.length + pasteText.length > maxInputLength) {
308
+ e.preventDefault();
309
+ e.stopPropagation();
310
+ Toast.warning(t('chatInput.maxLength'));
311
+ return;
312
+ }
313
+ return;
314
+ }
195
315
  if (!imageItem) return;
196
316
 
197
317
  // 有图片时阻止 tiptap 默认行为(避免图片被插入编辑器)
@@ -199,7 +319,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
199
319
  e.preventDefault();
200
320
 
201
321
  // 前置校验:上传功能是否开启
202
- if (!props.enableFileUpload || ((_agentObjRef$current = agentObjRef.current) === null || _agentObjRef$current === void 0 ? void 0 : _agentObjRef$current.openUploadFile) === 0) return;
322
+ if (!props.enableFileUpload || ((_agentObjRef$current3 = agentObjRef.current) === null || _agentObjRef$current3 === void 0 ? void 0 : _agentObjRef$current3.openUploadFile) === 0) return;
203
323
  if (props.disabled || isAskProcess) return;
204
324
  if (((_fileList$length = fileList === null || fileList === void 0 ? void 0 : fileList.length) !== null && _fileList$length !== void 0 ? _fileList$length : 0) >= 10) {
205
325
  Toast.info(t('chatInput.uploadLimitTen'));
@@ -489,7 +609,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
489
609
  return file.status === FileStatus.UPLOADING || file.status === FileStatus.PADDING || file.status === FileStatus.RETRING;
490
610
  });
491
611
  if (uploadingFile) {
492
- var _inputRef$current7;
612
+ var _inputRef$current8;
493
613
  // 文件处理中,恢复输入内容,不发送
494
614
  var message = '';
495
615
  if (uploadingFile.status === FileStatus.UPLOADING || uploadingFile.status === FileStatus.RETRING) {
@@ -498,7 +618,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
498
618
  message = t('fileValidation.parsing');
499
619
  }
500
620
  Toast.info(message);
501
- (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 || _inputRef$current7.setContent(text);
621
+ (_inputRef$current8 = inputRef.current) === null || _inputRef$current8 === void 0 || _inputRef$current8.setContent(text);
502
622
  return;
503
623
  }
504
624
  (_props$onSend = props.onSend) === null || _props$onSend === void 0 || _props$onSend.call(props, text);
@@ -601,11 +721,11 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
601
721
  };
602
722
  var handleInterrupt = function handleInterrupt() {
603
723
  var _props$onInterrupt;
604
- var latestMessage = messageList[messageList.length - 1];
724
+ // const latestMessage = messageList[messageList.length - 1];
605
725
  // 如果模型没有返回或正处于工作流调用阶段,不允许打断
606
- if (latestMessage.role === 1 && (!latestMessage.content && !latestMessage.reasoningContent || latestMessage.mcp)) {
607
- return;
608
- }
726
+ // if (latestMessage.role === 1 && (!latestMessage.content && !latestMessage.reasoningContent || latestMessage.mcp)) {
727
+ // return;
728
+ // }
609
729
  (_props$onInterrupt = props.onInterrupt) === null || _props$onInterrupt === void 0 || _props$onInterrupt.call(props);
610
730
  };
611
731
  var defaultContent = transformToInputSlots(props.defaultPrompt || '', props.titleSlot || '');
@@ -665,7 +785,8 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
665
785
  canSend: !props.disabled && hasContent,
666
786
  onMessageSend: onMessageSend,
667
787
  generating: isMsgRecieving,
668
- extensions: [TitleSlot, Keydown]
788
+ extensions: [TitleSlot, Keydown].concat(_toConsumableArray(extensions)),
789
+ transformer: transformer
669
790
  }, props)), showChatCommunication && /*#__PURE__*/React.createElement(AIChatDialogue, {
670
791
  paper: {
671
792
  enableCaptions: false,
@@ -141,7 +141,13 @@
141
141
  :global .semi-aiChatInput-footer-action-send-disabled {
142
142
  background-color: rgba(46, 50, 56, 0.1294117647);
143
143
  }
144
+ :global .semi-aiChatInput-editor-content {
145
+ display: flex;
146
+ flex-direction: column;
147
+ }
144
148
  :global .semi-aiChatInput-editor-content .tiptap {
149
+ flex: 1;
150
+ min-height: 0;
145
151
  font-size: 16px;
146
152
  color: var(--theme-mediumNeutral, #9AA7B7);
147
153
  }
@@ -8,6 +8,7 @@ import { setFilePreviewState, openSidebar } from "../../store/slices/gimiMenuSli
8
8
  import classNames from 'classnames';
9
9
  import { IconChevronRightStroked } from '@douyinfe/semi-icons';
10
10
  import IconFontCom from "../iconfont-com";
11
+ import { documentConstants } from "../../constants";
11
12
  export var FileCard = function FileCard(_ref) {
12
13
  var fileName = _ref.fileName,
13
14
  downloadUrl = _ref.downloadUrl,
@@ -50,7 +51,7 @@ export var FileCard = function FileCard(_ref) {
50
51
  }, /*#__PURE__*/React.createElement("div", {
51
52
  className: styles.icon
52
53
  }, /*#__PURE__*/React.createElement("img", {
53
- src: fileImgMap[fileType] || fileImgMap['xlsx'],
54
+ src: documentConstants[fileType] || documentConstants.default,
54
55
  alt: ""
55
56
  })), /*#__PURE__*/React.createElement("div", {
56
57
  className: styles.left
@@ -43,6 +43,7 @@
43
43
  align-items: center;
44
44
  gap: 10px;
45
45
  padding: 16px;
46
+ box-sizing: border-box;
46
47
  }
47
48
  .file_main:hover {
48
49
  cursor: pointer;
@@ -92,9 +92,14 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
92
92
  curPlayer === null || curPlayer === void 0 || curPlayer.pause();
93
93
  }
94
94
  setShowPanel(false);
95
+ // 资讯溯源:有权益直接跳转资讯详情,无权益则弹试看弹框
96
+ if (type === 'information' && trace.hasEntitlement) {
97
+ window.open("/news-list/new-information/".concat(trace.informationId, "?packageId=").concat(trace.packageId));
98
+ return;
99
+ }
95
100
  setCurTrace(trace);
96
101
  setTryWatchVisible(true);
97
- }, [setCurTrace]);
102
+ }, [type, curPlayer, setCurTrace]);
98
103
  var hoverPanelContent = useMemo(function () {
99
104
  if (isLoading) return /*#__PURE__*/React.createElement("div", {
100
105
  style: {
@@ -256,7 +256,7 @@ var TryWatch = function TryWatch(_ref7) {
256
256
  var _useTranslation4 = useTranslation(),
257
257
  t = _useTranslation4.t;
258
258
  var handleFull = function handleFull() {
259
- if (item.isDelete === 1 || item.isDeleted === 1) return;
259
+ if (item.isDelete === 1) return;
260
260
  if (platform !== 'myun') return Toast.warning(t('trace.jumpUnsupported'));
261
261
  if (type === 'information') {
262
262
  handleInformation();
@@ -337,7 +337,7 @@ var TryWatch = function TryWatch(_ref7) {
337
337
  className: styles.tryFullBtnContainer
338
338
  }, /*#__PURE__*/React.createElement("div", {
339
339
  className: styles.tips
340
- }, t('trace.tryFullTips')), /*#__PURE__*/React.createElement(Button, {
340
+ }, t(type === 'information' ? 'trace.tryFullTipsNoEntitlement' : 'trace.tryFullTips')), type !== 'information' && /*#__PURE__*/React.createElement(Button, {
341
341
  className: styles.tryFullBtn,
342
342
  onClick: handleFull
343
343
  }, t('trace.tryFull')))));
@@ -24,6 +24,8 @@ import { FileStatus } from "../../interfaces/fileInterface";
24
24
  import useChatActions from "../../hooks/useChatActions";
25
25
  import CopyButton from "../message-actions/CopyButton";
26
26
  import { Virtuoso } from 'react-virtuoso';
27
+ import { MMarkdown } from '@myun/gimi-design';
28
+ import SkillTag from "./skill-tag";
27
29
  var MessageItem = /*#__PURE__*/React.memo(function (props) {
28
30
  var _v$quoteTeachModelLis, _v$quoteProductList, _v$messageFilesList;
29
31
  var v = props.v,
@@ -41,6 +43,7 @@ var MessageItem = /*#__PURE__*/React.memo(function (props) {
41
43
  handleClickPromptWord = props.handleClickPromptWord,
42
44
  handleShowCourse = props.handleShowCourse,
43
45
  handleClickAskList = props.handleClickAskList,
46
+ handleClickConfirm = props.handleClickConfirm,
44
47
  playTTSByText = props.playTTSByText,
45
48
  stopTTSByText = props.stopTTSByText,
46
49
  isPlaying = props.isPlaying,
@@ -73,7 +76,13 @@ var MessageItem = /*#__PURE__*/React.memo(function (props) {
73
76
  quoteTeachModelList: v.quoteTeachModelList
74
77
  }), v.content && /*#__PURE__*/React.createElement("div", {
75
78
  className: styles.title
76
- }, replaceBraces(v.content)), v.messageFiles && /*#__PURE__*/React.createElement("div", {
79
+ }, /*#__PURE__*/React.createElement(MMarkdown, {
80
+ content: replaceBraces(v.content) || '',
81
+ customRender: [{
82
+ type: 'skilltool',
83
+ component: SkillTag
84
+ }]
85
+ })), v.messageFiles && /*#__PURE__*/React.createElement("div", {
77
86
  className: styles.listBox
78
87
  }, /*#__PURE__*/React.createElement(UploadList, {
79
88
  isMessage: true,
@@ -102,6 +111,7 @@ var MessageItem = /*#__PURE__*/React.memo(function (props) {
102
111
  handleClickPromptWord: handleClickPromptWord,
103
112
  handleShowCourse: handleShowCourse,
104
113
  handleClickAskList: handleClickAskList,
114
+ handleClickConfirm: handleClickConfirm,
105
115
  playTTSByText: playTTSByText,
106
116
  stopTTSByText: stopTTSByText,
107
117
  isVoicePlaying: isPlaying,
@@ -170,7 +180,8 @@ var MessageList = function MessageList(_ref) {
170
180
  // 使用 chatActions hook 提供的函数
171
181
  var showOpera = chatActions.showOpera,
172
182
  showCommend = chatActions.showCommend,
173
- handleClickAskList = chatActions.handleClickAskList;
183
+ handleClickAskList = chatActions.handleClickAskList,
184
+ handleClickConfirm = chatActions.handleClickConfirm;
174
185
  var handleClickPromptWord = React.useCallback(function (prompt) {
175
186
  handleSend(prompt);
176
187
  }, [handleSend]);
@@ -279,6 +290,7 @@ var MessageList = function MessageList(_ref) {
279
290
  handleClickPromptWord: handleClickPromptWord,
280
291
  handleShowCourse: handleShowCourse,
281
292
  handleClickAskList: handleClickAskList,
293
+ handleClickConfirm: handleClickConfirm,
282
294
  playTTSByText: playTTSByText,
283
295
  stopTTSByText: stopTTSByText,
284
296
  isPlaying: isPlaying,
@@ -294,7 +306,7 @@ var MessageList = function MessageList(_ref) {
294
306
  onCurrentTraceVideoClick: onCurrentTraceVideoClick,
295
307
  curPlayer: curPlayer
296
308
  });
297
- }, [chatUI, hideUserMessage, showOpera, onCopyCallback, onSucessExcel, onFailureExcel, onRetryExcel, showCommend, handleClickPromptWord, handleShowCourse, handleClickAskList, playTTSByText, stopTTSByText, isPlaying, onRegenerateClick, enableCopy, enableLike, enableUnLike, enableRegenerate, enableVoicePlay, onDownloadCallback, reasoningTitle, model, handleReTry, onLikeCallback, onUnLikeCallback]);
309
+ }, [chatUI, hideUserMessage, showOpera, onCopyCallback, onSucessExcel, onFailureExcel, onRetryExcel, showCommend, handleClickPromptWord, handleShowCourse, handleClickAskList, handleClickConfirm, playTTSByText, stopTTSByText, isPlaying, onRegenerateClick, enableCopy, enableLike, enableUnLike, enableRegenerate, enableVoicePlay, onDownloadCallback, reasoningTitle, model, handleReTry, onLikeCallback, onUnLikeCallback]);
298
310
  return /*#__PURE__*/React.createElement("div", {
299
311
  className: classNames(styles.main),
300
312
  style: buildStyle()
@@ -54,6 +54,9 @@
54
54
  align-self: flex-end;
55
55
  overflow-x: auto;
56
56
  }
57
+ .main .textWrap .textItem.question .title p {
58
+ margin: 0 !important;
59
+ }
57
60
  .main .textWrap .textItem.question .listBox {
58
61
  display: flex;
59
62
  flex-direction: row-reverse;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const SkillTag: ({ value }: {
3
+ value: string;
4
+ }) => React.JSX.Element;
5
+ export default SkillTag;
@@ -0,0 +1,23 @@
1
+ import React, { useMemo } from 'react';
2
+ import styles from "./index.module.css";
3
+ var SkillTag = function SkillTag(_ref) {
4
+ var value = _ref.value;
5
+ var item = useMemo(function () {
6
+ try {
7
+ return JSON.parse(value);
8
+ } catch (e) {
9
+ console.error('[skill-tag] parse value error:', e);
10
+ return {};
11
+ }
12
+ }, [value]);
13
+ return /*#__PURE__*/React.createElement("div", {
14
+ className: styles.skillItem
15
+ }, /*#__PURE__*/React.createElement("img", {
16
+ src: "https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202608/27/50553_20260827090545.png",
17
+ className: styles.icon,
18
+ alt: ""
19
+ }), /*#__PURE__*/React.createElement("span", {
20
+ className: styles.name
21
+ }, item.toolName || ''));
22
+ };
23
+ export default SkillTag;
@@ -0,0 +1,22 @@
1
+ .skillItem {
2
+ display: inline-block;
3
+ padding: 0px 8px 2px;
4
+ border-radius: 10px;
5
+ margin-right: 6px;
6
+ background-color: #E3E3E1;
7
+ line-height: 20px;
8
+ margin-bottom: 4px;
9
+ }
10
+ .skillItem .icon {
11
+ width: 14px;
12
+ height: 14px;
13
+ margin-right: 4px;
14
+ vertical-align: middle;
15
+ border-radius: unset;
16
+ }
17
+ .skillItem .name {
18
+ font-size: 14px;
19
+ color: var(--theme-deepNeutral, #221813);
20
+ font-weight: 500;
21
+ vertical-align: middle;
22
+ }
@@ -261,7 +261,9 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
261
261
  width: '100%'
262
262
  }
263
263
  }, /*#__PURE__*/React.createElement(AiLoading, null)), /*#__PURE__*/React.createElement(MessageList, _extends({
264
- chatList: messageList || defaultMessages,
264
+ chatList: messageList || defaultMessages
265
+ // chatList={defaultMessages}
266
+ ,
265
267
  handleSend: handleSend,
266
268
  platform: platform,
267
269
  inputModelRef: inputModelRef,
@@ -7,6 +7,7 @@ export declare const usePureChatActions: () => {
7
7
  declare const useChatActions: (showCopyId: number | null, inputModelRef: React.MutableRefObject<any>, handleSend: (val: string, agent?: any, isSystemAuto?: boolean) => void) => {
8
8
  showOpera: (id: number) => boolean;
9
9
  showCommend: (id: number) => boolean;
10
- handleClickAskList: (item: any, operation: string, key: string, value?: string | undefined) => void;
10
+ handleClickAskList: (item: any, operation: string, key: string, value?: string | undefined, inputModel?: any) => void;
11
+ handleClickConfirm: (item: any, confirmed: boolean) => void;
11
12
  };
12
13
  export default useChatActions;
@@ -79,22 +79,24 @@ export var usePureChatActions = function usePureChatActions() {
79
79
  replaceTags.forEach(function (tag) {
80
80
  text = text.replace(new RegExp("<".concat(tag, ">(.*?)</").concat(tag, ">"), 'g'), '');
81
81
  });
82
- _context.prev = 4;
83
- _context.next = 7;
82
+ // 过滤 <skilltool>...</skilltool> 标签及内容(含多行)
83
+ text = text.replace(/<skilltool>[\s\S]*?<\/skilltool>/gi, '');
84
+ _context.prev = 5;
85
+ _context.next = 8;
84
86
  return navigator.clipboard.writeText(text);
85
- case 7:
87
+ case 8:
86
88
  Toast.success(t('action.copySuccess'));
87
- _context.next = 13;
89
+ _context.next = 14;
88
90
  break;
89
- case 10:
90
- _context.prev = 10;
91
- _context.t0 = _context["catch"](4);
91
+ case 11:
92
+ _context.prev = 11;
93
+ _context.t0 = _context["catch"](5);
92
94
  Toast.error(t('action.copyFailed'));
93
- case 13:
95
+ case 14:
94
96
  case "end":
95
97
  return _context.stop();
96
98
  }
97
- }, _callee, null, [[4, 10]]);
99
+ }, _callee, null, [[5, 11]]);
98
100
  }));
99
101
  return function (_x) {
100
102
  return _ref2.apply(this, arguments);
@@ -187,13 +189,13 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
187
189
  * 点击问询列表
188
190
  */
189
191
  var handleClickAskList = React.useMemo(function () {
190
- return debounce(function (item, operation, key, value) {
192
+ return debounce(function (item, operation, key, value, inputModel) {
191
193
  var _messageList8;
192
194
  var messageList = messageListRef.current;
193
195
  if ((_messageList8 = messageList[messageList.length - 1]) !== null && _messageList8 !== void 0 && _messageList8.selectValue) {
194
196
  return;
195
197
  }
196
- var _inputModel = _defineProperty({}, "".concat(item.id, ".").concat(operation), key);
198
+ var _inputModel = inputModel || _defineProperty({}, "".concat(item.id, ".").concat(operation), key);
197
199
  inputModelRef.current = _inputModel;
198
200
  var newMessageList = updateLastMessage(messageList, function (lastMessage) {
199
201
  return _objectSpread(_objectSpread({}, lastMessage), {}, {
@@ -206,10 +208,48 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
206
208
  handleSend(value || '');
207
209
  }, 100);
208
210
  }, [handleSend, inputModelRef, dispatch]);
211
+
212
+ /**
213
+ * 确认/拒绝工具调用
214
+ * 绕开 ask 的 selectValue 防重逻辑,直接组装 user_confirm inputModel 发送
215
+ */
216
+ var handleClickConfirm = React.useCallback(function (item, confirmed) {
217
+ var _lastMessage$toolList, _item$data, _item$data2;
218
+ // 1. 更新最后一条消息的 toolList,把这条 user_confirm 改成已确认/已拒绝
219
+ var currentMessageList = messageListRef.current;
220
+ var lastMessage = currentMessageList[currentMessageList.length - 1];
221
+ var updatedToolList = (_lastMessage$toolList = lastMessage.toolList) === null || _lastMessage$toolList === void 0 ? void 0 : _lastMessage$toolList.map(function (tool) {
222
+ return tool.id === item.id ? _objectSpread(_objectSpread({}, tool), {}, {
223
+ moduleType: "user_confirm",
224
+ status: 'COMPLETED',
225
+ confirmStatus: confirmed ? "CONFIRMED" : "REJECTED"
226
+ }) : tool;
227
+ });
228
+ var updatedMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
229
+ toolList: updatedToolList
230
+ })]);
231
+ dispatch(setMessageList({
232
+ messageList: updatedMessageList
233
+ }));
234
+
235
+ // 2. 组装 inputModel 并发送
236
+ var inputModel = {
237
+ user_confirm: {
238
+ askingEventId: (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.askingEventId,
239
+ confirmResults: [{
240
+ toolCallId: ((_item$data2 = item.data) === null || _item$data2 === void 0 || (_item$data2 = _item$data2.toolCalls) === null || _item$data2 === void 0 || (_item$data2 = _item$data2[0]) === null || _item$data2 === void 0 ? void 0 : _item$data2.id) || '',
241
+ confirmed: confirmed
242
+ }]
243
+ }
244
+ };
245
+ inputModelRef.current = inputModel;
246
+ handleSend('', undefined, true, undefined, true); // skipCreateNewMessage: true 复用当前消息
247
+ }, [handleSend, inputModelRef, dispatch]);
209
248
  return {
210
249
  showOpera: showOpera,
211
250
  showCommend: showCommend,
212
- handleClickAskList: handleClickAskList
251
+ handleClickAskList: handleClickAskList,
252
+ handleClickConfirm: handleClickConfirm
213
253
  };
214
254
  };
215
255
  export default useChatActions;