@agentscope-ai/chat 1.1.39 → 1.1.41-beta.1764749089549

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 (233) hide show
  1. package/bin/starter_webui.zip +0 -0
  2. package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.tsx +8 -4
  3. package/components/ImageGenerator/index.tsx +1 -1
  4. package/components/Markdown/Markdown.tsx +105 -0
  5. package/components/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.tsx +1 -1
  6. package/components/Markdown/core/components/Null.tsx +1 -0
  7. package/components/Markdown/core/components/Raw.tsx +18 -0
  8. package/components/Markdown/{Markdown → core}/hooks/useCitationsData.tsx +3 -7
  9. package/components/Markdown/core/hooks/useCursorContent.tsx +15 -0
  10. package/components/Markdown/{Markdown/hooks/useTyping.ts → core/hooks/useTyping.tsx} +4 -1
  11. package/components/Markdown/core/index.tsx +18 -0
  12. package/components/Markdown/{plugins → core/plugins}/citations/CitationComponent.tsx +5 -3
  13. package/components/Markdown/{plugins → core/plugins}/citations/index.tsx +3 -4
  14. package/components/Markdown/{plugins → core/plugins}/cursor/Underline.tsx +1 -1
  15. package/components/Markdown/{plugins → core/plugins}/cursor/index.tsx +8 -8
  16. package/components/Markdown/demo/cursor.tsx +2 -3
  17. package/components/Markdown/index.en-US.md +1 -2
  18. package/components/Markdown/index.tsx +6 -0
  19. package/components/Markdown/index.zh-CN.md +1 -2
  20. package/components/Markdown/{Markdown/style.ts → styles.ts} +12 -21
  21. package/components/Markdown/types.tsx +94 -0
  22. package/components/index.ts +1 -3
  23. package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.js +5 -3
  24. package/lib/ImageGenerator/index.js +1 -1
  25. package/lib/Markdown/Markdown.d.ts +4 -0
  26. package/lib/Markdown/Markdown.js +110 -0
  27. package/lib/Markdown/core/components/Null.d.ts +2 -0
  28. package/lib/Markdown/core/components/Null.js +3 -0
  29. package/lib/Markdown/core/components/Raw.d.ts +8 -0
  30. package/lib/Markdown/core/components/Raw.js +13 -0
  31. package/lib/Markdown/core/hooks/useCitationsData.d.ts +6 -0
  32. package/lib/Markdown/{Markdown → core}/hooks/useCitationsData.js +1 -1
  33. package/lib/Markdown/core/hooks/useCursorContent.d.ts +4 -0
  34. package/lib/Markdown/core/hooks/useCursorContent.js +14 -0
  35. package/lib/Markdown/core/hooks/useTyping.d.ts +5 -0
  36. package/lib/Markdown/{Markdown → core}/hooks/useTyping.js +3 -2
  37. package/lib/Markdown/core/index.d.ts +2 -0
  38. package/lib/Markdown/{Markdown/hooks/useAnimation.js → core/index.js} +23 -23
  39. package/lib/Markdown/{plugins → core/plugins}/citations/CitationComponent.js +5 -5
  40. package/lib/Markdown/{plugins → core/plugins}/citations/index.d.ts +1 -2
  41. package/lib/Markdown/{plugins → core/plugins}/citations/index.js +1 -1
  42. package/lib/Markdown/{plugins → core/plugins}/cursor/Dot.js +1 -1
  43. package/lib/Markdown/{plugins → core/plugins}/cursor/Underline.js +1 -1
  44. package/lib/Markdown/{plugins → core/plugins}/cursor/index.js +4 -4
  45. package/lib/Markdown/index.d.ts +2 -1
  46. package/lib/Markdown/styles.js +32 -0
  47. package/lib/Markdown/types.d.ts +78 -0
  48. package/lib/index.d.ts +0 -2
  49. package/lib/index.js +0 -2
  50. package/package.json +7 -31
  51. package/components/AGUI/components/HelpModal/icons.tsx +0 -68
  52. package/components/AGUI/components/HelpModal/index.tsx +0 -1
  53. package/components/AGUI/components/HelpModal/modal.tsx +0 -101
  54. package/components/AGUI/components/chat/Button.tsx +0 -18
  55. package/components/AGUI/components/chat/Chat.tsx +0 -780
  56. package/components/AGUI/components/chat/ChatContext.tsx +0 -248
  57. package/components/AGUI/components/chat/CodeBlock.tsx +0 -406
  58. package/components/AGUI/components/chat/Header.tsx +0 -22
  59. package/components/AGUI/components/chat/Icons.tsx +0 -237
  60. package/components/AGUI/components/chat/ImageUploadQueue.tsx +0 -77
  61. package/components/AGUI/components/chat/Input.tsx +0 -24
  62. package/components/AGUI/components/chat/Markdown.tsx +0 -134
  63. package/components/AGUI/components/chat/Messages.tsx +0 -259
  64. package/components/AGUI/components/chat/Modal.tsx +0 -133
  65. package/components/AGUI/components/chat/Popup.tsx +0 -57
  66. package/components/AGUI/components/chat/PoweredByTag.tsx +0 -29
  67. package/components/AGUI/components/chat/Sidebar.tsx +0 -74
  68. package/components/AGUI/components/chat/Suggestion.tsx +0 -132
  69. package/components/AGUI/components/chat/Suggestions.tsx +0 -20
  70. package/components/AGUI/components/chat/Textarea.tsx +0 -61
  71. package/components/AGUI/components/chat/Window.tsx +0 -152
  72. package/components/AGUI/components/chat/index.tsx +0 -11
  73. package/components/AGUI/components/chat/messages/AssistantMessage.tsx +0 -69
  74. package/components/AGUI/components/chat/messages/RenderActionExecutionMessage.tsx +0 -129
  75. package/components/AGUI/components/chat/messages/RenderAgentStateMessage.tsx +0 -116
  76. package/components/AGUI/components/chat/messages/RenderImageMessage.tsx +0 -64
  77. package/components/AGUI/components/chat/messages/RenderResultMessage.tsx +0 -26
  78. package/components/AGUI/components/chat/messages/RenderTextMessage.tsx +0 -51
  79. package/components/AGUI/components/chat/messages/UserMessage.tsx +0 -10
  80. package/components/AGUI/components/chat/props.ts +0 -186
  81. package/components/AGUI/components/index.ts +0 -1
  82. package/components/AGUI/context/index.ts +0 -1
  83. package/components/AGUI/hooks/index.ts +0 -1
  84. package/components/AGUI/hooks/use-copilot-chat-suggestions.tsx +0 -122
  85. package/components/AGUI/hooks/use-copy-to-clipboard.tsx +0 -29
  86. package/components/AGUI/hooks/use-dark-mode.ts +0 -10
  87. package/components/AGUI/hooks/use-push-to-talk.tsx +0 -166
  88. package/components/AGUI/index.tsx +0 -4
  89. package/components/AGUI/lib/utils.test.ts +0 -7
  90. package/components/AGUI/lib/utils.ts +0 -27
  91. package/components/AGUI/styles.css +0 -0
  92. package/components/AGUI/types/css.ts +0 -0
  93. package/components/AGUI/types/index.ts +0 -1
  94. package/components/AGUI/types/suggestions.ts +0 -6
  95. package/components/Markdown/Markdown/AnimationNode.tsx +0 -89
  96. package/components/Markdown/Markdown/Markdown.tsx +0 -61
  97. package/components/Markdown/Markdown/core/Parser.ts +0 -52
  98. package/components/Markdown/Markdown/core/Renderer.ts +0 -121
  99. package/components/Markdown/Markdown/core/index.ts +0 -4
  100. package/components/Markdown/Markdown/hooks/index.ts +0 -4
  101. package/components/Markdown/Markdown/hooks/useAnimation.tsx +0 -27
  102. package/components/Markdown/Markdown/hooks/useStreaming.ts +0 -503
  103. package/components/Markdown/Markdown/index.tsx +0 -198
  104. package/components/Markdown/Markdown/interface.ts +0 -217
  105. package/components/Markdown/demo/typing.tsx +0 -82
  106. package/components/Markdown/index.ts +0 -1
  107. package/components/Markdown/plugins/latex/index.ts +0 -109
  108. package/components/Markdown/plugins/type.ts +0 -71
  109. package/lib/AGUI/components/HelpModal/icons.d.ts +0 -5
  110. package/lib/AGUI/components/HelpModal/icons.js +0 -84
  111. package/lib/AGUI/components/HelpModal/index.d.ts +0 -1
  112. package/lib/AGUI/components/HelpModal/index.js +0 -1
  113. package/lib/AGUI/components/HelpModal/modal.d.ts +0 -1
  114. package/lib/AGUI/components/HelpModal/modal.js +0 -104
  115. package/lib/AGUI/components/chat/Button.d.ts +0 -2
  116. package/lib/AGUI/components/chat/Button.js +0 -27
  117. package/lib/AGUI/components/chat/Chat.d.ts +0 -242
  118. package/lib/AGUI/components/chat/Chat.js +0 -634
  119. package/lib/AGUI/components/chat/ChatContext.d.ts +0 -142
  120. package/lib/AGUI/components/chat/ChatContext.js +0 -75
  121. package/lib/AGUI/components/chat/CodeBlock.d.ts +0 -12
  122. package/lib/AGUI/components/chat/CodeBlock.js +0 -398
  123. package/lib/AGUI/components/chat/Header.d.ts +0 -2
  124. package/lib/AGUI/components/chat/Header.js +0 -28
  125. package/lib/AGUI/components/chat/Icons.d.ts +0 -16
  126. package/lib/AGUI/components/chat/Icons.js +0 -247
  127. package/lib/AGUI/components/chat/ImageUploadQueue.d.ts +0 -11
  128. package/lib/AGUI/components/chat/ImageUploadQueue.js +0 -65
  129. package/lib/AGUI/components/chat/Input.d.ts +0 -2
  130. package/lib/AGUI/components/chat/Input.js +0 -30
  131. package/lib/AGUI/components/chat/Markdown.d.ts +0 -7
  132. package/lib/AGUI/components/chat/Markdown.js +0 -187
  133. package/lib/AGUI/components/chat/Messages.d.ts +0 -7
  134. package/lib/AGUI/components/chat/Messages.js +0 -242
  135. package/lib/AGUI/components/chat/Modal.d.ts +0 -43
  136. package/lib/AGUI/components/chat/Modal.js +0 -113
  137. package/lib/AGUI/components/chat/Popup.d.ts +0 -49
  138. package/lib/AGUI/components/chat/Popup.js +0 -64
  139. package/lib/AGUI/components/chat/PoweredByTag.d.ts +0 -3
  140. package/lib/AGUI/components/chat/PoweredByTag.js +0 -27
  141. package/lib/AGUI/components/chat/Sidebar.d.ts +0 -2
  142. package/lib/AGUI/components/chat/Sidebar.js +0 -85
  143. package/lib/AGUI/components/chat/Suggestion.d.ts +0 -16
  144. package/lib/AGUI/components/chat/Suggestion.js +0 -146
  145. package/lib/AGUI/components/chat/Suggestions.d.ts +0 -2
  146. package/lib/AGUI/components/chat/Suggestions.js +0 -21
  147. package/lib/AGUI/components/chat/Textarea.d.ts +0 -11
  148. package/lib/AGUI/components/chat/Textarea.js +0 -60
  149. package/lib/AGUI/components/chat/Window.d.ts +0 -2
  150. package/lib/AGUI/components/chat/Window.js +0 -115
  151. package/lib/AGUI/components/chat/index.d.ts +0 -11
  152. package/lib/AGUI/components/chat/index.js +0 -11
  153. package/lib/AGUI/components/chat/messages/AssistantMessage.d.ts +0 -2
  154. package/lib/AGUI/components/chat/messages/AssistantMessage.js +0 -56
  155. package/lib/AGUI/components/chat/messages/RenderActionExecutionMessage.d.ts +0 -2
  156. package/lib/AGUI/components/chat/messages/RenderActionExecutionMessage.js +0 -114
  157. package/lib/AGUI/components/chat/messages/RenderAgentStateMessage.d.ts +0 -2
  158. package/lib/AGUI/components/chat/messages/RenderAgentStateMessage.js +0 -97
  159. package/lib/AGUI/components/chat/messages/RenderImageMessage.d.ts +0 -2
  160. package/lib/AGUI/components/chat/messages/RenderImageMessage.js +0 -61
  161. package/lib/AGUI/components/chat/messages/RenderResultMessage.d.ts +0 -2
  162. package/lib/AGUI/components/chat/messages/RenderResultMessage.js +0 -27
  163. package/lib/AGUI/components/chat/messages/RenderTextMessage.d.ts +0 -2
  164. package/lib/AGUI/components/chat/messages/RenderTextMessage.js +0 -47
  165. package/lib/AGUI/components/chat/messages/UserMessage.d.ts +0 -2
  166. package/lib/AGUI/components/chat/messages/UserMessage.js +0 -9
  167. package/lib/AGUI/components/chat/props.d.ts +0 -157
  168. package/lib/AGUI/components/index.d.ts +0 -1
  169. package/lib/AGUI/components/index.js +0 -1
  170. package/lib/AGUI/context/index.d.ts +0 -1
  171. package/lib/AGUI/context/index.js +0 -1
  172. package/lib/AGUI/hooks/index.d.ts +0 -1
  173. package/lib/AGUI/hooks/index.js +0 -1
  174. package/lib/AGUI/hooks/use-copilot-chat-suggestions.d.ts +0 -87
  175. package/lib/AGUI/hooks/use-copilot-chat-suggestions.js +0 -95
  176. package/lib/AGUI/hooks/use-copy-to-clipboard.d.ts +0 -7
  177. package/lib/AGUI/hooks/use-copy-to-clipboard.js +0 -34
  178. package/lib/AGUI/hooks/use-dark-mode.d.ts +0 -1
  179. package/lib/AGUI/hooks/use-dark-mode.js +0 -4
  180. package/lib/AGUI/hooks/use-push-to-talk.d.ts +0 -16
  181. package/lib/AGUI/hooks/use-push-to-talk.js +0 -260
  182. package/lib/AGUI/index.d.ts +0 -4
  183. package/lib/AGUI/index.js +0 -4
  184. package/lib/AGUI/lib/utils.d.ts +0 -2
  185. package/lib/AGUI/lib/utils.js +0 -52
  186. package/lib/AGUI/styles.css +0 -0
  187. package/lib/AGUI/types/css.d.ts +0 -0
  188. package/lib/AGUI/types/css.js +0 -0
  189. package/lib/AGUI/types/index.d.ts +0 -1
  190. package/lib/AGUI/types/index.js +0 -1
  191. package/lib/AGUI/types/suggestions.d.ts +0 -6
  192. package/lib/AGUI/types/suggestions.js +0 -1
  193. package/lib/Markdown/Markdown/AnimationNode.d.ts +0 -20
  194. package/lib/Markdown/Markdown/AnimationNode.js +0 -84
  195. package/lib/Markdown/Markdown/Markdown.d.ts +0 -4
  196. package/lib/Markdown/Markdown/Markdown.js +0 -58
  197. package/lib/Markdown/Markdown/core/Parser.d.ts +0 -16
  198. package/lib/Markdown/Markdown/core/Parser.js +0 -65
  199. package/lib/Markdown/Markdown/core/Renderer.d.ts +0 -24
  200. package/lib/Markdown/Markdown/core/Renderer.js +0 -137
  201. package/lib/Markdown/Markdown/core/index.d.ts +0 -3
  202. package/lib/Markdown/Markdown/core/index.js +0 -3
  203. package/lib/Markdown/Markdown/hooks/index.d.ts +0 -3
  204. package/lib/Markdown/Markdown/hooks/index.js +0 -3
  205. package/lib/Markdown/Markdown/hooks/useAnimation.d.ts +0 -4
  206. package/lib/Markdown/Markdown/hooks/useCitationsData.d.ts +0 -7
  207. package/lib/Markdown/Markdown/hooks/useStreaming.d.ts +0 -3
  208. package/lib/Markdown/Markdown/hooks/useStreaming.js +0 -521
  209. package/lib/Markdown/Markdown/hooks/useTyping.d.ts +0 -4
  210. package/lib/Markdown/Markdown/index.d.ts +0 -84
  211. package/lib/Markdown/Markdown/index.js +0 -161
  212. package/lib/Markdown/Markdown/interface.d.ts +0 -203
  213. package/lib/Markdown/Markdown/interface.js +0 -1
  214. package/lib/Markdown/Markdown/style.js +0 -32
  215. package/lib/Markdown/plugins/latex/index.d.ts +0 -9
  216. package/lib/Markdown/plugins/latex/index.js +0 -97
  217. package/lib/Markdown/plugins/type.d.ts +0 -60
  218. package/lib/Markdown/plugins/type.js +0 -1
  219. /package/components/Markdown/{Markdown/defaultComponents/DisabledImage.tsx → core/components/DisableImage.tsx} +0 -0
  220. /package/components/Markdown/{Markdown/defaultComponents → core/components}/Media.tsx +0 -0
  221. /package/components/Markdown/{plugins → core/plugins}/cursor/Dot.tsx +0 -0
  222. /package/lib/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.d.ts +0 -0
  223. /package/lib/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.js +0 -0
  224. /package/lib/Markdown/{Markdown/defaultComponents/DisabledImage.d.ts → core/components/DisableImage.d.ts} +0 -0
  225. /package/lib/Markdown/{Markdown/defaultComponents/DisabledImage.js → core/components/DisableImage.js} +0 -0
  226. /package/lib/Markdown/{Markdown/defaultComponents → core/components}/Media.d.ts +0 -0
  227. /package/lib/Markdown/{Markdown/defaultComponents → core/components}/Media.js +0 -0
  228. /package/lib/Markdown/{plugins → core/plugins}/citations/CitationComponent.d.ts +0 -0
  229. /package/lib/Markdown/{plugins → core/plugins}/cursor/Dot.d.ts +0 -0
  230. /package/lib/Markdown/{plugins → core/plugins}/cursor/Underline.d.ts +0 -0
  231. /package/lib/Markdown/{plugins → core/plugins}/cursor/index.d.ts +0 -0
  232. /package/lib/Markdown/{Markdown/style.d.ts → styles.d.ts} +0 -0
  233. /package/lib/{AGUI/components/chat/props.js → Markdown/types.js} +0 -0
@@ -1,146 +0,0 @@
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
- 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; }
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 _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); }
6
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
- 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; }
9
- 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); } }
10
- 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); }); }; }
11
- import { extract } from "@copilotkit/react-core";
12
- import { SmallSpinnerIcon } from "./Icons";
13
- import { actionParametersToJsonSchema } from "@copilotkit/shared";
14
- import { CopilotRequestType } from "@copilotkit/runtime-client-gql";
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- export function Suggestion(_ref) {
17
- var title = _ref.title,
18
- _onClick = _ref.onClick,
19
- partial = _ref.partial,
20
- className = _ref.className;
21
- return /*#__PURE__*/_jsx("button", {
22
- disabled: partial,
23
- onClick: function onClick(e) {
24
- e.preventDefault();
25
- _onClick();
26
- },
27
- className: className || (partial ? "suggestion loading" : "suggestion"),
28
- "data-test-id": "suggestion",
29
- children: partial ? SmallSpinnerIcon : /*#__PURE__*/_jsx("span", {
30
- children: title
31
- })
32
- });
33
- }
34
- export var reloadSuggestions = /*#__PURE__*/function () {
35
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(context, chatSuggestionConfiguration, setCurrentSuggestions, abortControllerRef) {
36
- var abortController, tools, allSuggestions, _loop, _i, _Object$values;
37
- return _regeneratorRuntime().wrap(function _callee$(_context2) {
38
- while (1) switch (_context2.prev = _context2.next) {
39
- case 0:
40
- abortController = abortControllerRef.current;
41
- tools = JSON.stringify(Object.values(context.actions).map(function (action) {
42
- return {
43
- name: action.name,
44
- description: action.description,
45
- jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters))
46
- };
47
- }));
48
- allSuggestions = [];
49
- _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
50
- var config, numOfSuggestionsInstructions, result;
51
- return _regeneratorRuntime().wrap(function _loop$(_context) {
52
- while (1) switch (_context.prev = _context.next) {
53
- case 0:
54
- config = _Object$values[_i];
55
- _context.prev = 1;
56
- numOfSuggestionsInstructions = config.minSuggestions === 0 ? "Produce up to ".concat(config.maxSuggestions, " suggestions. ") + "If there are no highly relevant suggestions you can think of, provide an empty array." : "Produce between ".concat(config.minSuggestions, " and ").concat(config.maxSuggestions, " suggestions.");
57
- _context.next = 5;
58
- return extract({
59
- context: context,
60
- instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
61
- data: config.instructions + "\n\n" + numOfSuggestionsInstructions + "\n\n" + "Available tools: " + tools + "\n\n",
62
- requestType: CopilotRequestType.Task,
63
- parameters: [{
64
- name: "suggestions",
65
- type: "object[]",
66
- attributes: [{
67
- name: "title",
68
- description: "The title of the suggestion. This is shown as a button and should be short.",
69
- type: "string"
70
- }, {
71
- name: "message",
72
- description: "The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.",
73
- type: "string"
74
- }]
75
- }],
76
- include: {
77
- messages: true,
78
- readable: true
79
- },
80
- abortSignal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
81
- stream: function stream(_ref3) {
82
- var status = _ref3.status,
83
- args = _ref3.args;
84
- var suggestions = args.suggestions || [];
85
- var newSuggestions = [];
86
- for (var i = 0; i < suggestions.length; i++) {
87
- // if GPT provides too many suggestions, limit the number of suggestions
88
- if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {
89
- break;
90
- }
91
- var _suggestions$i = suggestions[i],
92
- title = _suggestions$i.title,
93
- message = _suggestions$i.message;
94
-
95
- // If this is the last suggestion and the status is not complete, mark it as partial
96
- var partial = i == suggestions.length - 1 && status !== "complete";
97
- newSuggestions.push({
98
- title: title,
99
- message: message,
100
- partial: partial,
101
- className: config.className
102
- });
103
- }
104
- setCurrentSuggestions([].concat(allSuggestions, newSuggestions));
105
- }
106
- });
107
- case 5:
108
- result = _context.sent;
109
- allSuggestions.push.apply(allSuggestions, _toConsumableArray(result.suggestions));
110
- _context.next = 12;
111
- break;
112
- case 9:
113
- _context.prev = 9;
114
- _context.t0 = _context["catch"](1);
115
- console.error("Error loading suggestions", _context.t0);
116
- case 12:
117
- case "end":
118
- return _context.stop();
119
- }
120
- }, _loop, null, [[1, 9]]);
121
- });
122
- _i = 0, _Object$values = Object.values(chatSuggestionConfiguration);
123
- case 5:
124
- if (!(_i < _Object$values.length)) {
125
- _context2.next = 10;
126
- break;
127
- }
128
- return _context2.delegateYield(_loop(), "t0", 7);
129
- case 7:
130
- _i++;
131
- _context2.next = 5;
132
- break;
133
- case 10:
134
- if (abortControllerRef.current === abortController) {
135
- abortControllerRef.current = null;
136
- }
137
- case 11:
138
- case "end":
139
- return _context2.stop();
140
- }
141
- }, _callee);
142
- }));
143
- return function reloadSuggestions(_x, _x2, _x3, _x4) {
144
- return _ref2.apply(this, arguments);
145
- };
146
- }();
@@ -1,2 +0,0 @@
1
- import { RenderSuggestionsListProps } from "./props";
2
- export declare function Suggestions({ suggestions, onSuggestionClick }: RenderSuggestionsListProps): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +0,0 @@
1
- import { Suggestion } from "./Suggestion";
2
- import React from "react";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- export function Suggestions(_ref) {
5
- var suggestions = _ref.suggestions,
6
- onSuggestionClick = _ref.onSuggestionClick;
7
- return /*#__PURE__*/_jsx("div", {
8
- className: "suggestions",
9
- children: suggestions.map(function (suggestion, index) {
10
- return /*#__PURE__*/_jsx(Suggestion, {
11
- title: suggestion.title,
12
- message: suggestion.message,
13
- partial: suggestion.partial,
14
- className: suggestion.className,
15
- onClick: function onClick() {
16
- return onSuggestionClick(suggestion.message);
17
- }
18
- }, index);
19
- })
20
- });
21
- }
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- interface AutoResizingTextareaProps {
3
- maxRows?: number;
4
- placeholder?: string;
5
- value: string;
6
- onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
7
- onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
8
- autoFocus?: boolean;
9
- }
10
- declare const AutoResizingTextarea: React.ForwardRefExoticComponent<AutoResizingTextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
11
- export default AutoResizingTextarea;
@@ -1,60 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- 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."); }
3
- 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); }
4
- 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; }
5
- 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; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from "react";
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- var AutoResizingTextarea = /*#__PURE__*/forwardRef(function (_ref, ref) {
10
- var _ref$maxRows = _ref.maxRows,
11
- maxRows = _ref$maxRows === void 0 ? 1 : _ref$maxRows,
12
- placeholder = _ref.placeholder,
13
- value = _ref.value,
14
- onChange = _ref.onChange,
15
- onKeyDown = _ref.onKeyDown,
16
- autoFocus = _ref.autoFocus;
17
- var internalTextareaRef = useRef(null);
18
- var _useState = useState(0),
19
- _useState2 = _slicedToArray(_useState, 2),
20
- maxHeight = _useState2[0],
21
- setMaxHeight = _useState2[1];
22
- useImperativeHandle(ref, function () {
23
- return internalTextareaRef.current;
24
- });
25
- useEffect(function () {
26
- var calculateMaxHeight = function calculateMaxHeight() {
27
- var textarea = internalTextareaRef.current;
28
- if (textarea) {
29
- textarea.style.height = "auto";
30
- var singleRowHeight = textarea.scrollHeight;
31
- setMaxHeight(singleRowHeight * maxRows);
32
- if (autoFocus) {
33
- textarea.focus();
34
- }
35
- }
36
- };
37
- calculateMaxHeight();
38
- }, [maxRows]);
39
- useEffect(function () {
40
- var textarea = internalTextareaRef.current;
41
- if (textarea) {
42
- textarea.style.height = "auto";
43
- textarea.style.height = "".concat(Math.min(textarea.scrollHeight, maxHeight), "px");
44
- }
45
- }, [value, maxHeight]);
46
- return /*#__PURE__*/_jsx("textarea", {
47
- ref: internalTextareaRef,
48
- value: value,
49
- onChange: onChange,
50
- onKeyDown: onKeyDown,
51
- placeholder: placeholder,
52
- style: {
53
- overflow: "auto",
54
- resize: "none",
55
- maxHeight: "".concat(maxHeight, "px")
56
- },
57
- rows: 1
58
- });
59
- });
60
- export default AutoResizingTextarea;
@@ -1,2 +0,0 @@
1
- import { WindowProps } from "./props";
2
- export declare const Window: ({ children, clickOutsideToClose, shortcut, hitEscapeToClose, }: WindowProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,115 +0,0 @@
1
- import React, { useCallback, useEffect } from "react";
2
- import { useChatContext } from "./ChatContext";
3
- import { useCopilotContext } from "@copilotkit/react-core";
4
- import { isMacOS } from "@copilotkit/shared";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- export var Window = function Window(_ref) {
7
- var children = _ref.children,
8
- clickOutsideToClose = _ref.clickOutsideToClose,
9
- shortcut = _ref.shortcut,
10
- hitEscapeToClose = _ref.hitEscapeToClose;
11
- var windowRef = React.useRef(null);
12
- var context = useCopilotContext();
13
- var _useChatContext = useChatContext(),
14
- open = _useChatContext.open,
15
- setOpen = _useChatContext.setOpen;
16
- var handleClickOutside = useCallback(function (event) {
17
- var _windowRef$current;
18
- if (!clickOutsideToClose) {
19
- return;
20
- }
21
- var parentElement = (_windowRef$current = windowRef.current) === null || _windowRef$current === void 0 ? void 0 : _windowRef$current.parentElement;
22
- var className = "";
23
- if (event.target instanceof HTMLElement) {
24
- className = event.target.className;
25
- }
26
- if (open && parentElement && !parentElement.contains(event.target) &&
27
- // prevent closing the window when clicking on the debug menu
28
- !className.includes("copilotKitDebugMenu")) {
29
- setOpen(false);
30
- }
31
- }, [clickOutsideToClose, open, setOpen]);
32
- var handleKeyDown = useCallback(function (event) {
33
- var _windowRef$current2;
34
- var target = event.target;
35
- var isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
36
- var isDescendantOfWrapper = (_windowRef$current2 = windowRef.current) === null || _windowRef$current2 === void 0 ? void 0 : _windowRef$current2.contains(target);
37
- if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
38
- setOpen(false);
39
- } else if (event.key === shortcut && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
40
- setOpen(!open);
41
- }
42
- }, [hitEscapeToClose, shortcut, open, setOpen]);
43
- var adjustForMobile = useCallback(function () {
44
- var copilotKitWindow = windowRef.current;
45
- var vv = window.visualViewport;
46
- if (!copilotKitWindow || !vv) {
47
- return;
48
- }
49
- if (window.innerWidth < 640 && open) {
50
- copilotKitWindow.style.height = "".concat(vv.height, "px");
51
- copilotKitWindow.style.left = "".concat(vv.offsetLeft, "px");
52
- copilotKitWindow.style.top = "".concat(vv.offsetTop, "px");
53
- document.body.style.position = "fixed";
54
- document.body.style.width = "100%";
55
- document.body.style.height = "".concat(window.innerHeight, "px");
56
- document.body.style.overflow = "hidden";
57
- document.body.style.touchAction = "none";
58
-
59
- // Prevent scrolling on iOS
60
- document.body.addEventListener("touchmove", preventScroll, {
61
- passive: false
62
- });
63
- } else {
64
- copilotKitWindow.style.height = "";
65
- copilotKitWindow.style.left = "";
66
- copilotKitWindow.style.top = "";
67
- document.body.style.position = "";
68
- document.body.style.height = "";
69
- document.body.style.width = "";
70
- document.body.style.overflow = "";
71
- document.body.style.top = "";
72
- document.body.style.touchAction = "";
73
- document.body.removeEventListener("touchmove", preventScroll);
74
- }
75
- }, [open]);
76
- useEffect(function () {
77
- document.addEventListener("mousedown", handleClickOutside);
78
- document.addEventListener("keydown", handleKeyDown);
79
- if (window.visualViewport) {
80
- window.visualViewport.addEventListener("resize", adjustForMobile);
81
- adjustForMobile();
82
- }
83
- return function () {
84
- document.removeEventListener("mousedown", handleClickOutside);
85
- document.removeEventListener("keydown", handleKeyDown);
86
- if (window.visualViewport) {
87
- window.visualViewport.removeEventListener("resize", adjustForMobile);
88
- }
89
- };
90
- }, [adjustForMobile, handleClickOutside, handleKeyDown]);
91
- return /*#__PURE__*/_jsx("div", {
92
- className: "copilotKitWindow ".concat(open ? " open" : ""),
93
- ref: windowRef,
94
- children: children
95
- });
96
- };
97
- var preventScroll = function preventScroll(event) {
98
- var targetElement = event.target;
99
-
100
- // Function to check if the target has the parent with a given class
101
- var hasParentWithClass = function hasParentWithClass(element, className) {
102
- while (element && element !== document.body) {
103
- if (element.classList.contains(className)) {
104
- return true;
105
- }
106
- element = element.parentElement;
107
- }
108
- return false;
109
- };
110
-
111
- // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class
112
- if (!hasParentWithClass(targetElement, "copilotKitMessages")) {
113
- event.preventDefault();
114
- }
115
- };
@@ -1,11 +0,0 @@
1
- export * from "./props";
2
- export { CopilotPopup } from "./Popup";
3
- export { CopilotSidebar } from "./Sidebar";
4
- export { CopilotChat } from "./Chat";
5
- export { Markdown } from "./Markdown";
6
- export { AssistantMessage } from "./messages/AssistantMessage";
7
- export { UserMessage } from "./messages/UserMessage";
8
- export { useChatContext } from "./ChatContext";
9
- export { RenderImageMessage } from "./messages/RenderImageMessage";
10
- export { Suggestions as RenderSuggestionsList } from "./Suggestions";
11
- export { Suggestion as RenderSuggestion } from "./Suggestion";
@@ -1,11 +0,0 @@
1
- export * from "./props";
2
- export { CopilotPopup } from "./Popup";
3
- export { CopilotSidebar } from "./Sidebar";
4
- export { CopilotChat } from "./Chat";
5
- export { Markdown } from "./Markdown";
6
- export { AssistantMessage } from "./messages/AssistantMessage";
7
- export { UserMessage } from "./messages/UserMessage";
8
- export { useChatContext } from "./ChatContext";
9
- export { RenderImageMessage } from "./messages/RenderImageMessage";
10
- export { Suggestions as RenderSuggestionsList } from "./Suggestions";
11
- export { Suggestion as RenderSuggestion } from "./Suggestion";
@@ -1,2 +0,0 @@
1
- import { AssistantMessageProps } from "../props";
2
- export declare const AssistantMessage: (props: AssistantMessageProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,56 +0,0 @@
1
- import { Bubble } from "../../../..";
2
- import compact from 'lodash/compact';
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- export var AssistantMessage = function AssistantMessage(props) {
5
- var _props$rawData$conten;
6
- if (props.subComponent) return props.subComponent;
7
- var hasThink = (_props$rawData$conten = props.rawData.content) === null || _props$rawData$conten === void 0 ? void 0 : _props$rawData$conten.includes('<think>');
8
- var msgStatus = props.isCurrentMessage && props.isGenerating ? "generating" : void 0;
9
- if (!hasThink) return /*#__PURE__*/_jsx(Bubble, {
10
- role: "assistant",
11
- content: props.rawData.content,
12
- id: props.rawData.id,
13
- msgStatus: msgStatus
14
- });
15
- var hasThinkEnd = props.rawData.content.includes('</think>');
16
- var _parseThinkContentIf = parseThinkContentIf(props.rawData.content),
17
- content = _parseThinkContentIf.content,
18
- think = _parseThinkContentIf.think;
19
- return /*#__PURE__*/_jsx(Bubble, {
20
- role: "assistant",
21
- cards: compact([hasThink && {
22
- code: 'DeepThink',
23
- data: {
24
- title: 'AI思考',
25
- loading: !hasThinkEnd,
26
- content: think
27
- }
28
- }, {
29
- code: 'Text',
30
- data: {
31
- content: content,
32
- msgStatus: msgStatus
33
- }
34
- }]),
35
- id: props.rawData.id,
36
- msgStatus: msgStatus
37
- });
38
- };
39
- function parseThinkContentIf(content) {
40
- var reg0 = /<think>([\s\S]*?)<\/think>/g;
41
- var reg1 = /<think>([\s\S]*)/g;
42
- var reg0Result = content.match(reg0);
43
- if (reg0Result) return {
44
- think: reg0Result[0].replace(/<think>/, '').replace(/<\/think>/g, ''),
45
- content: content.replace(reg0Result[0], '')
46
- };
47
- var reg1Result = content.match(reg1);
48
- if (reg1Result) return {
49
- think: reg1Result[0].replace(/<think>/, ''),
50
- content: content.replace(reg1Result[0], '')
51
- };
52
- return {
53
- think: '',
54
- content: content
55
- };
56
- }
@@ -1,2 +0,0 @@
1
- import { RenderMessageProps } from "../props";
2
- export declare function RenderActionExecutionMessage({ AssistantMessage, ...props }: RenderMessageProps): import("react/jsx-runtime").JSX.Element;
@@ -1,114 +0,0 @@
1
- var _excluded = ["AssistantMessage"];
2
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
- import { MessageStatusCode } from "@copilotkit/runtime-client-gql";
5
- import { useCopilotContext } from "@copilotkit/react-core";
6
- import { AssistantMessage as DefaultAssistantMessage } from "./AssistantMessage";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
- export function RenderActionExecutionMessage(_ref) {
10
- var _ref$AssistantMessage = _ref.AssistantMessage,
11
- AssistantMessage = _ref$AssistantMessage === void 0 ? DefaultAssistantMessage : _ref$AssistantMessage,
12
- props = _objectWithoutProperties(_ref, _excluded);
13
- var _useCopilotContext = useCopilotContext(),
14
- chatComponentsCache = _useCopilotContext.chatComponentsCache;
15
- var message = props.message,
16
- inProgress = props.inProgress,
17
- index = props.index,
18
- isCurrentMessage = props.isCurrentMessage,
19
- actionResult = props.actionResult;
20
- if (message.isActionExecutionMessage()) {
21
- if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
22
- var render = chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"];
23
- // render a static string
24
- if (typeof render === "string") {
25
- // when render is static, we show it only when in progress
26
- if (isCurrentMessage && inProgress) {
27
- return /*#__PURE__*/_jsx(AssistantMessage, {
28
- rawData: message,
29
- "data-message-role": "assistant",
30
- isLoading: false,
31
- isGenerating: true,
32
- message: render
33
- }, index);
34
- }
35
- // Done - silent by default to avoid a series of "done" messages
36
- else {
37
- return null;
38
- }
39
- }
40
- // render is a function
41
- else {
42
- var args = message.arguments;
43
- var status = "inProgress";
44
- if (actionResult !== undefined) {
45
- status = "complete";
46
- } else if (message.status.code !== MessageStatusCode.Pending) {
47
- status = "executing";
48
- }
49
- try {
50
- var toRender = render({
51
- status: status,
52
- // Cast to any as RenderFunctionStatus is a union that can be complex to narrow here
53
- args: args,
54
- result: actionResult,
55
- name: message.name,
56
- messageId: message.id // Pass messageId for HITL action correlation
57
- });
58
-
59
- // No result and complete: stay silent
60
- if (!toRender && status === "complete") {
61
- return null;
62
- }
63
- if (typeof toRender === "string") {
64
- return /*#__PURE__*/_jsx(AssistantMessage, {
65
- rawData: message,
66
- "data-message-role": "assistant",
67
- isLoading: false,
68
- isGenerating: false,
69
- message: toRender
70
- }, index);
71
- } else {
72
- return /*#__PURE__*/_jsx(AssistantMessage, {
73
- rawData: message,
74
- "data-message-role": "action-render",
75
- isLoading: false,
76
- isGenerating: false,
77
- subComponent: toRender
78
- }, index);
79
- }
80
- } catch (e) {
81
- // It's useful to log this error for developers to debug their custom render functions
82
- console.error("Error executing render function for action ".concat(message.name, ": ").concat(e));
83
- return /*#__PURE__*/_jsx(AssistantMessage, {
84
- rawData: message,
85
- "data-message-role": "assistant",
86
- isLoading: false,
87
- isGenerating: false,
88
- subComponent: /*#__PURE__*/_jsxs("div", {
89
- className: "copilotKitMessage copilotKitAssistantMessage",
90
- children: [/*#__PURE__*/_jsxs("b", {
91
- children: ["\u274C Error executing render function for action ", message.name, ":"]
92
- }), /*#__PURE__*/_jsx("pre", {
93
- children: e instanceof Error ? e.message : String(e)
94
- })]
95
- })
96
- }, index);
97
- }
98
- }
99
- }
100
- // No render function found- show the default message
101
- else if (!inProgress || !isCurrentMessage) {
102
- // Done - silent by default to avoid a series of "done" messages
103
- return null;
104
- } else {
105
- // In progress
106
- return /*#__PURE__*/_jsx(AssistantMessage, {
107
- rawData: message,
108
- "data-message-role": "assistant",
109
- isLoading: true,
110
- isGenerating: true
111
- }, index);
112
- }
113
- }
114
- }
@@ -1,2 +0,0 @@
1
- import { RenderMessageProps } from "../props";
2
- export declare function RenderAgentStateMessage({ AssistantMessage, ...props }: RenderMessageProps): import("react/jsx-runtime").JSX.Element;