@opentiny/tiny-robot 0.4.0 → 0.4.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index6.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent as k, openBlock as _, createElementBlock as B, renderSlot as C, ref as L, computed as y, watch as H, unref as E, normalizeClass as K, createVNode as j, watchEffect as q, nextTick as ee, Fragment as w, createElementVNode as R, toDisplayString as z, withDirectives as Z, vShow as Q, createBlock as I, resolveDynamicComponent as Y, normalizeProps as D, guardReactiveProps as P, createCommentVNode as se, useCssModule as Ye, renderList as W, mergeProps as F, markRaw as O, inject as T, provide as $, toValue as S, reactive as Je, readonly as We, withCtx as M, onMounted as ve, onUnmounted as je } from "vue";
1
+ import { defineComponent as k, openBlock as b, createElementBlock as B, renderSlot as C, ref as L, computed as y, watch as H, unref as E, normalizeClass as K, createVNode as j, watchEffect as q, nextTick as ee, Fragment as w, createElementVNode as R, toDisplayString as z, withDirectives as Z, vShow as Q, createBlock as I, resolveDynamicComponent as Y, normalizeProps as D, guardReactiveProps as P, createCommentVNode as se, useCssModule as Ye, renderList as W, mergeProps as F, markRaw as O, inject as T, provide as $, toValue as S, reactive as Je, readonly as We, withCtx as M, onMounted as ve, onUnmounted as je } from "vue";
2
2
  import { _ as N } from "./_plugin-vue_export-helper.js";
3
3
  import { IconLoading as he, IconAtom as ze, IconArrowDown as ye, IconPlugin as fe, IconError as Ve, IconCancelled as Xe } from "@opentiny/tiny-robot-svgs";
4
4
  import { i as qe, w as Ze, g as Qe, a as et } from "./index4.js";
@@ -23,7 +23,7 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
23
23
  shape: {}
24
24
  },
25
25
  setup(t) {
26
- return (e, n) => (_(), B("div", tt, [
26
+ return (e, n) => (b(), B("div", tt, [
27
27
  C(e.$slots, "default", {}, void 0, !0)
28
28
  ]));
29
29
  }
@@ -43,9 +43,9 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
43
43
  }, r = () => {
44
44
  s.value = !0, n.value = !0;
45
45
  };
46
- return (u, b) => {
46
+ return (u, _) => {
47
47
  var v;
48
- return _(), B("img", {
48
+ return b(), B("img", {
49
49
  class: K(["tr-bubble__image", { loading: !n.value }]),
50
50
  src: i.value,
51
51
  alt: (v = E(a)) == null ? void 0 : v.text,
@@ -66,7 +66,7 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
66
66
  contentIndex: {}
67
67
  },
68
68
  setup(t) {
69
- return (e, n) => (_(), B("div", rt, [
69
+ return (e, n) => (b(), B("div", rt, [
70
70
  j(E(he))
71
71
  ]));
72
72
  }
@@ -80,10 +80,10 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
80
80
  contentIndex: {}
81
81
  },
82
82
  setup(t) {
83
- const e = t, { restMessage: n, restProps: s } = Ke(e, ["reasoning_content"]), a = le(n, e.contentIndex), i = L(!1);
83
+ const e = t, { restMessage: n, restProps: s } = Ke(e, ["reasoning_content"]), a = le(n, e.contentIndex), i = L(!0);
84
84
  q(() => {
85
- var b;
86
- i.value = ((b = e.message.state) == null ? void 0 : b.open) ?? !1;
85
+ var _;
86
+ i.value = ((_ = e.message.state) == null ? void 0 : _.open) ?? !0;
87
87
  });
88
88
  const o = He(), r = () => {
89
89
  i.value = !i.value, o("open", i.value);
@@ -98,9 +98,9 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
98
98
  });
99
99
  });
100
100
  }
101
- ), (b, v) => {
101
+ ), (_, v) => {
102
102
  var p, m;
103
- return _(), B(w, null, [
103
+ return b(), B(w, null, [
104
104
  R("div", lt, [
105
105
  R("div", {
106
106
  class: "header",
@@ -132,11 +132,11 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
132
132
  [Q, i.value]
133
133
  ])
134
134
  ]),
135
- (_(), I(Y(E(a)), D(P(E(s))), null, 16))
135
+ (b(), I(Y(E(a)), D(P(E(s))), null, 16))
136
136
  ], 64);
137
137
  };
138
138
  }
139
- }), $e = /* @__PURE__ */ N(it, [["__scopeId", "data-v-a8e2bce1"]]), dt = {
139
+ }), $e = /* @__PURE__ */ N(it, [["__scopeId", "data-v-eacd6c58"]]), dt = {
140
140
  key: 0,
141
141
  class: "tr-bubble__text",
142
142
  "data-type": "text"
@@ -148,7 +148,7 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
148
148
  },
149
149
  setup(t) {
150
150
  const e = t, { contentText: n } = ie(e);
151
- return (s, a) => E(n) ? (_(), B("p", dt, z(E(n)), 1)) : se("", !0);
151
+ return (s, a) => E(n) ? (b(), B("p", dt, z(E(n)), 1)) : se("", !0);
152
152
  }
153
153
  }), ae = /* @__PURE__ */ N(ft, [["__scopeId", "data-v-93592ecb"]]), Ae = /* @__PURE__ */ k({
154
154
  __name: "ToolRole",
@@ -165,7 +165,7 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
165
165
  }), pt = {
166
166
  class: "tr-bubble__tool-call",
167
167
  "data-type": "tool-call"
168
- }, bt = { class: "header" }, _t = { class: "header-left" }, mt = { class: "title" }, gt = { class: "header-right" }, vt = { class: "divider" }, ht = ["innerHTML"], yt = /* @__PURE__ */ k({
168
+ }, _t = { class: "header" }, bt = { class: "header-left" }, mt = { class: "title" }, gt = { class: "header-right" }, vt = { class: "divider" }, ht = ["innerHTML"], yt = /* @__PURE__ */ k({
169
169
  __name: "Tool",
170
170
  props: {
171
171
  message: {},
@@ -188,10 +188,10 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
188
188
  } catch {
189
189
  }
190
190
  return x;
191
- }, u = Ye(), b = (d) => d.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), v = (d) => {
191
+ }, u = Ye(), _ = (d) => d.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), v = (d) => {
192
192
  if (!d)
193
193
  return "";
194
- let g = b(d);
194
+ let g = _(d);
195
195
  return g = g.replace(
196
196
  /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,
197
197
  (x) => {
@@ -223,10 +223,10 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
223
223
  };
224
224
  return (d, g) => {
225
225
  var x;
226
- return _(), B("div", pt, [
227
- R("div", bt, [
228
- R("div", _t, [
229
- (_(), I(Y(o.value.icon), {
226
+ return b(), B("div", pt, [
227
+ R("div", _t, [
228
+ R("div", bt, [
229
+ (b(), I(Y(o.value.icon), {
230
230
  class: K(["header-icon", `icon-${E(a).status}`])
231
231
  }, null, 8, ["class"])),
232
232
  R("span", null, [
@@ -271,9 +271,9 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
271
271
  },
272
272
  setup(t) {
273
273
  const e = t, { restMessage: n, restProps: s } = Ke(e, ["tool_calls"]), a = le(n, e.contentIndex);
274
- return (i, o) => (_(), B(w, null, [
275
- (_(), I(Y(E(a)), D(P(E(s))), null, 16)),
276
- (_(!0), B(w, null, W(e.message.tool_calls, (r, u) => (_(), I(Ne, F({
274
+ return (i, o) => (b(), B(w, null, [
275
+ (b(), I(Y(E(a)), D(P(E(s))), null, 16)),
276
+ (b(!0), B(w, null, W(e.message.tool_calls, (r, u) => (b(), I(Ne, F({
277
277
  key: r.id
278
278
  }, { ref_for: !0 }, e, { "tool-call-index": u }), null, 16, ["tool-call-index"]))), 128))
279
279
  ], 64));
@@ -340,7 +340,7 @@ function Tt(t, e) {
340
340
  };
341
341
  };
342
342
  return y(() => {
343
- const r = S(t), { content: u, index: b } = o(r), v = S(n).find((p) => p.find(r, u, b));
343
+ const r = S(t), { content: u, index: _ } = o(r), v = S(n).find((p) => p.find(r, u, _));
344
344
  return v ? {
345
345
  renderer: v.renderer,
346
346
  attributes: v.attributes
@@ -360,8 +360,8 @@ function Mt(t) {
360
360
  function le(t, e) {
361
361
  const n = T(Ee, De), s = T(ke, void 0), a = T(Se, void 0), i = te();
362
362
  return y(() => {
363
- const o = S(t), r = i(o), u = Array.isArray(r) ? r.at(e ?? 0) : { type: "text", text: r || "" }, b = S(n).find((v) => v.find(o, u, e));
364
- return b ? b.renderer : S(a) || S(s) || Pe;
363
+ const o = S(t), r = i(o), u = Array.isArray(r) ? r.at(e ?? 0) : { type: "text", text: r || "" }, _ = S(n).find((v) => v.find(o, u, e));
364
+ return _ ? _.renderer : S(a) || S(s) || Pe;
365
365
  });
366
366
  }
367
367
  function $t(t) {
@@ -442,25 +442,25 @@ const wt = async () => {
442
442
  } catch {
443
443
  return console.warn("[BubbleMarkdownRenderer] install markdown-it and dompurify to use markdown renderer"), J = null, null;
444
444
  }
445
- }, be = ["running", "success", "failed", "cancelled"], Dt = (t) => {
445
+ }, _e = ["running", "success", "failed", "cancelled"], Dt = (t) => {
446
446
  const e = y(() => {
447
447
  var o, r;
448
448
  return (r = (o = t.message) == null ? void 0 : o.tool_calls) == null ? void 0 : r[t.toolCallIndex];
449
449
  }), n = ue(), s = y(() => {
450
450
  var v, p, m;
451
451
  let o = n.toolCallDefaultStatus;
452
- o && !be.includes(o) && (o = void 0);
452
+ o && !_e.includes(o) && (o = void 0);
453
453
  const r = n.toolCallDefaultOpen;
454
454
  let u = {
455
455
  status: o,
456
456
  open: r
457
457
  };
458
- const b = (v = e.value) == null ? void 0 : v.id;
459
- if (b) {
460
- const l = (m = (p = t.message.state) == null ? void 0 : p.toolCall) == null ? void 0 : m[b];
458
+ const _ = (v = e.value) == null ? void 0 : v.id;
459
+ if (_) {
460
+ const l = (m = (p = t.message.state) == null ? void 0 : p.toolCall) == null ? void 0 : m[_];
461
461
  if (l) {
462
462
  const { status: f, open: h, ...c } = l;
463
- f && be.includes(f) && (u.status = f), h !== void 0 && (u.open = h), u = { ...u, ...c };
463
+ f && _e.includes(f) && (u.status = f), h !== void 0 && (u.open = h), u = { ...u, ...c };
464
464
  }
465
465
  }
466
466
  return u;
@@ -473,21 +473,21 @@ const wt = async () => {
473
473
  return q(() => {
474
474
  var u;
475
475
  const o = (u = e.value) == null ? void 0 : u.function.arguments, r = a.value;
476
- Ot().then(({ jsonrepair: b }) => {
477
- const v = b(typeof o == "string" ? o || "{}" : JSON.stringify(o));
476
+ Ot().then(({ jsonrepair: _ }) => {
477
+ const v = _(typeof o == "string" ? o || "{}" : JSON.stringify(o));
478
478
  i.value = {
479
479
  arguments: JSON.parse(v),
480
- result: r ? JSON.parse(b(r || "{}")) : void 0
480
+ result: r ? JSON.parse(_(r || "{}")) : void 0
481
481
  };
482
- }).catch((b) => {
483
- console.warn(b);
482
+ }).catch((_) => {
483
+ console.warn(_);
484
484
  });
485
485
  }), {
486
486
  toolCall: e,
487
487
  toolCallWithResult: We(i),
488
488
  state: s
489
489
  };
490
- }, _e = /* @__PURE__ */ k({
490
+ }, be = /* @__PURE__ */ k({
491
491
  __name: "BubbleBoxWrapper",
492
492
  props: {
493
493
  role: {},
@@ -498,7 +498,7 @@ const wt = async () => {
498
498
  },
499
499
  setup(t) {
500
500
  const e = t, n = Tt(() => e.messages, e.contentIndex);
501
- return (s, a) => (_(), I(Y(E(n).renderer), F({
501
+ return (s, a) => (b(), I(Y(E(n).renderer), F({
502
502
  "data-role": e.role,
503
503
  "data-placement": e.placement,
504
504
  "data-shape": e.shape
@@ -524,7 +524,7 @@ const wt = async () => {
524
524
  value: r,
525
525
  contentIndex: n.contentIndex
526
526
  });
527
- }), (o, r) => (_(), I(Y(E(s)), D(P(n)), null, 16));
527
+ }), (o, r) => (b(), I(Y(E(s)), D(P(n)), null, 16));
528
528
  }
529
529
  }), Ft = ["data-role", "data-placement"], Pt = { class: "tr-bubble__body" }, Ht = { class: "tr-bubble__content" }, Gt = { class: "tr-bubble__after" }, Kt = /* @__PURE__ */ k({
530
530
  __name: "Bubble",
@@ -562,7 +562,7 @@ const wt = async () => {
562
562
  return Array.isArray(f) ? f : [{ type: "text", text: f || "" }];
563
563
  };
564
564
  It({ fallbackBoxRenderer: () => n.fallbackBoxRenderer }), Mt({ fallbackContentRenderer: () => n.fallbackContentRenderer });
565
- const b = y(() => r.value.length === 0 ? !0 : n.hidden), v = y(() => {
565
+ const _ = y(() => r.value.length === 0 ? !0 : n.hidden), v = y(() => {
566
566
  if (n.contentRenderMode === "split" && r.value.length === 1) {
567
567
  const l = s(r.value.at(0));
568
568
  if (Array.isArray(l))
@@ -570,7 +570,7 @@ const wt = async () => {
570
570
  }
571
571
  return null;
572
572
  }), p = T(Te, !1), m = L(null);
573
- return p || Ge(m), (l, f) => Z((_(), B("div", {
573
+ return p || Ge(m), (l, f) => Z((b(), B("div", {
574
574
  class: "tr-bubble",
575
575
  ref_key: "bubbleRef",
576
576
  ref: m,
@@ -582,12 +582,12 @@ const wt = async () => {
582
582
  role: t.role
583
583
  }, void 0, !0),
584
584
  R("div", Pt, [
585
- n.avatar ? (_(), I(Y(n.avatar), {
585
+ n.avatar ? (b(), I(Y(n.avatar), {
586
586
  key: 0,
587
587
  class: K(["tr-bubble__avatar", l.$style["tr-bubble__avatar"]])
588
588
  }, null, 8, ["class"])) : se("", !0),
589
589
  R("div", Ht, [
590
- v.value ? (_(!0), B(w, { key: 0 }, W(v.value, (h, c) => (_(), I(_e, {
590
+ v.value ? (b(!0), B(w, { key: 0 }, W(v.value, (h, c) => (b(), I(be, {
591
591
  key: c,
592
592
  class: "tr-bubble__box",
593
593
  role: n.role,
@@ -609,7 +609,7 @@ const wt = async () => {
609
609
  }, void 0, !0)
610
610
  ]),
611
611
  _: 2
612
- }, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (_(), I(_e, {
612
+ }, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (b(), I(be, {
613
613
  key: 1,
614
614
  role: n.role,
615
615
  placement: n.placement,
@@ -617,10 +617,10 @@ const wt = async () => {
617
617
  messages: r.value
618
618
  }, {
619
619
  default: M(() => [
620
- (_(!0), B(w, null, W(r.value, (h, c) => (_(), B(w, {
620
+ (b(!0), B(w, null, W(r.value, (h, c) => (b(), B(w, {
621
621
  key: `message-${c}`
622
622
  }, [
623
- (_(!0), B(w, null, W(u(h), (d, g) => (_(), I(me, {
623
+ (b(!0), B(w, null, W(u(h), (d, g) => (b(), I(me, {
624
624
  key: `content-${g}`,
625
625
  message: h,
626
626
  "content-index": g,
@@ -647,7 +647,7 @@ const wt = async () => {
647
647
  role: t.role
648
648
  }, void 0, !0)
649
649
  ], 8, Ft)), [
650
- [Q, !b.value]
650
+ [Q, !_.value]
651
651
  ]);
652
652
  }
653
653
  }), Ut = {
@@ -664,8 +664,8 @@ function ge(t, e) {
664
664
  function Jt(t, e, n) {
665
665
  const { scrollOnMount: s = !0, bottomThreshold: a = 20, scrollThrottle: i = 0 } = n ?? {}, o = L(!0);
666
666
  let r = !1;
667
- const u = /* @__PURE__ */ new Set(), b = () => et(t), { y: v, isScrolling: p, arrivedState: m } = qe(b, { throttle: i }), l = (c) => c.scrollHeight - c.scrollTop - c.clientHeight <= a, f = async (c = "auto") => {
668
- const d = S(b);
667
+ const u = /* @__PURE__ */ new Set(), _ = () => et(t), { y: v, isScrolling: p, arrivedState: m } = qe(_, { throttle: i }), l = (c) => c.scrollHeight - c.scrollTop - c.clientHeight <= a, f = async (c = "auto") => {
668
+ const d = S(_);
669
669
  if (d && (await ee(), d.scrollTo({ top: d.scrollHeight, behavior: c }), c === "smooth" && !l(d))) {
670
670
  const g = ge(p, () => {
671
671
  d.scrollTo({ top: d.scrollHeight, behavior: "auto" }), u.delete(g);
@@ -680,7 +680,7 @@ function Jt(t, e, n) {
680
680
  return H(
681
681
  v,
682
682
  () => {
683
- const c = S(b);
683
+ const c = S(_);
684
684
  c && (o.value = l(c));
685
685
  },
686
686
  { flush: "post" }
@@ -719,7 +719,7 @@ const Wt = /* @__PURE__ */ k({
719
719
  emits: ["state-change"],
720
720
  setup(t, { emit: e }) {
721
721
  const n = t, s = e;
722
- return At(() => n.messageGroup), (a, i) => (_(), I(U, F(t.roleConfig, {
722
+ return At(() => n.messageGroup), (a, i) => (b(), I(U, F(t.roleConfig, {
723
723
  role: t.messageGroup.role,
724
724
  "content-render-mode": t.contentRenderMode,
725
725
  "content-resolver": t.contentResolver,
@@ -795,7 +795,7 @@ const Wt = /* @__PURE__ */ k({
795
795
  }), l = g;
796
796
  }
797
797
  return m;
798
- }, b = (p, m) => {
798
+ }, _ = (p, m) => {
799
799
  const l = [];
800
800
  let f = !1;
801
801
  for (const [h, c] of p.entries()) {
@@ -811,17 +811,17 @@ const Wt = /* @__PURE__ */ k({
811
811
  }), f = A;
812
812
  }
813
813
  return l;
814
- }, v = y(() => s.messages.length === 0 ? [] : typeof s.groupStrategy == "function" ? s.groupStrategy(s.messages, s.dividerRole) : s.groupStrategy === "consecutive" ? u(s.messages) : b(s.messages, s.dividerRole));
814
+ }, v = y(() => s.messages.length === 0 ? [] : typeof s.groupStrategy == "function" ? s.groupStrategy(s.messages, s.dividerRole) : s.groupStrategy === "consecutive" ? u(s.messages) : _(s.messages, s.dividerRole));
815
815
  return e({
816
816
  scrollToBottom: r
817
- }), (p, m) => (_(), B("div", {
817
+ }), (p, m) => (b(), B("div", {
818
818
  class: "tr-bubble-list",
819
819
  ref_key: "listRef",
820
820
  ref: o
821
821
  }, [
822
- (_(!0), B(w, null, W(v.value, (l, f) => {
822
+ (b(!0), B(w, null, W(v.value, (l, f) => {
823
823
  var h;
824
- return _(), I(Wt, {
824
+ return b(), I(Wt, {
825
825
  key: f,
826
826
  role: l.role || s.fallbackRole,
827
827
  "role-config": (h = s.roleConfigs) == null ? void 0 : h[l.role || s.fallbackRole],
@@ -884,15 +884,15 @@ const Wt = /* @__PURE__ */ k({
884
884
  const { mdConfig: a, dompurifyConfig: i } = ue(), o = L("");
885
885
  return q(() => {
886
886
  if (s.value) {
887
- const { markdown: r, dompurify: u } = s.value, b = r(a || {}).render(n.value);
888
- o.value = u.sanitize(b, i);
887
+ const { markdown: r, dompurify: u } = s.value, _ = r(a || {}).render(n.value);
888
+ o.value = u.sanitize(_, i);
889
889
  }
890
- }), (r, u) => o.value ? (_(), B("div", {
890
+ }), (r, u) => o.value ? (b(), B("div", {
891
891
  key: 0,
892
892
  class: "tr-bubble__markdown markdown-body",
893
893
  "data-type": "markdown",
894
894
  innerHTML: o.value
895
- }, null, 8, zt)) : (_(), I(ae, D(F({ key: 1 }, e)), null, 16));
895
+ }, null, 8, zt)) : (b(), I(ae, D(F({ key: 1 }, e)), null, 16));
896
896
  }
897
897
  }), Xt = /* @__PURE__ */ N(Vt, [["__scopeId", "data-v-eb1c196f"]]), sn = {
898
898
  Box: re,