@declarion/react 0.185.0 → 0.186.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.
@@ -229,6 +229,7 @@ function oe({ open: n, onClose: i, context: d, title: p = "", askOnOpen: m, dock
229
229
  l(_.messages, _.invocations).map((e) => e.kind === "message" ? /* @__PURE__ */ w(he, {
230
230
  message: e.message,
231
231
  delivered: e.delivered,
232
+ showsPlace: e.showsPlace,
232
233
  turns: _.turns
233
234
  }, e.message.id) : /* @__PURE__ */ w(de, { run: e }, e.id)),
234
235
  Q.map((e) => /* @__PURE__ */ w(ce, { agentTurn: e }, e.id)),
@@ -715,13 +716,13 @@ function P(e, t) {
715
716
  let n = t.indexOf(".");
716
717
  if (!(n < 0)) return e?.entities?.[t.slice(0, n)]?.actions?.[t.slice(n + 1)]?.display?.name;
717
718
  }
718
- function he({ message: e, delivered: t, turns: n }) {
719
- let r = ne(e, n) ? e.attachments : void 0;
719
+ function he({ message: e, delivered: t, showsPlace: n, turns: r }) {
720
+ let i = ne(e, r) ? e.attachments : void 0;
720
721
  if (e.role === "user") {
721
722
  let t = K(e.content);
722
723
  return e.content.some((e) => e.type !== "text" && e.type !== "location") ? /* @__PURE__ */ w(B, {
723
724
  message: e,
724
- files: r
725
+ files: i
725
726
  }) : /* @__PURE__ */ T("div", {
726
727
  style: {
727
728
  alignSelf: "flex-end",
@@ -736,27 +737,39 @@ function he({ message: e, delivered: t, turns: n }) {
736
737
  children: [
737
738
  t && /* @__PURE__ */ w(F, { text: t }),
738
739
  /* @__PURE__ */ w(b, {
739
- files: r,
740
+ files: i,
740
741
  align: "end"
741
742
  }),
742
- /* @__PURE__ */ w(R, { message: e })
743
+ /* @__PURE__ */ w(R, {
744
+ message: e,
745
+ showsPlace: n
746
+ })
743
747
  ]
744
748
  });
745
749
  }
746
- return e.role === "tool" ? /* @__PURE__ */ w(B, { message: e }) : e.role === "system" ? e.content.some((e) => e.type === "decision") ? /* @__PURE__ */ w(B, { message: e }) : I(e) ? /* @__PURE__ */ w(L, { message: e }) : /* @__PURE__ */ T(D, {
750
+ return e.role === "tool" ? /* @__PURE__ */ w(B, { message: e }) : e.role === "system" ? e.content.some((e) => e.type === "decision") ? /* @__PURE__ */ w(B, { message: e }) : I(e) ? /* @__PURE__ */ w(L, {
751
+ message: e,
752
+ showsPlace: n
753
+ }) : /* @__PURE__ */ T(D, {
747
754
  dataMessageId: e.id,
748
- children: [e.content.map((e, t) => /* @__PURE__ */ w(W, { block: e }, t)), /* @__PURE__ */ w(R, { message: e })]
749
- }) : e.content.length === 0 && !r?.length ? null : /* @__PURE__ */ T(D, {
755
+ children: [e.content.map((e, t) => /* @__PURE__ */ w(W, { block: e }, t)), /* @__PURE__ */ w(R, {
756
+ message: e,
757
+ showsPlace: n
758
+ })]
759
+ }) : e.content.length === 0 && !i?.length ? null : /* @__PURE__ */ T(D, {
750
760
  dataMessageId: e.id,
751
761
  dataStreaming: e.streaming,
752
762
  children: [
753
763
  e.content.map((e, t) => /* @__PURE__ */ w(W, { block: e }, t)),
754
764
  e.streaming && /* @__PURE__ */ w(se, {}),
755
765
  /* @__PURE__ */ w(b, {
756
- files: r,
766
+ files: i,
757
767
  align: "start"
758
768
  }),
759
- t && /* @__PURE__ */ w(R, { message: t })
769
+ t && /* @__PURE__ */ w(R, {
770
+ message: t,
771
+ showsPlace: n
772
+ })
760
773
  ]
761
774
  });
762
775
  }
@@ -783,11 +796,11 @@ function F({ text: e, dim: t }) {
783
796
  function I(e) {
784
797
  return !e.bot_id || e.delivery_key ? !1 : e.content.some((e) => e.type === "reaction" || e.type === "text" && (!!e.callback_data || e.heard === !0));
785
798
  }
786
- function L({ message: e }) {
787
- let t = f(), n = e.content.some((e) => e.type === "text" && e.heard === !0), r = e.content.some((e) => e.type === "text" && !!e.callback_data), i = K(e.content), a = e.content.find((e) => e.type === "reaction"), o = a?.type === "reaction" ? a.emoji ?? "" : i, s = n ? t("agent.panel.heard_started_nothing", "Heard, started nothing") : r ? t("agent.panel.pressed_button", "Pressed a button") : "";
799
+ function L({ message: e, showsPlace: t }) {
800
+ let n = f(), r = e.content.some((e) => e.type === "text" && e.heard === !0), i = e.content.some((e) => e.type === "text" && !!e.callback_data), a = K(e.content), o = e.content.find((e) => e.type === "reaction"), s = o?.type === "reaction" ? o.emoji ?? "" : a, c = r ? n("agent.panel.heard_started_nothing", "Heard, started nothing") : i ? n("agent.panel.pressed_button", "Pressed a button") : "";
788
801
  return /* @__PURE__ */ T("div", {
789
802
  "data-message-id": e.id,
790
- "data-person-on-messenger": n ? "heard" : r ? "pressed" : "reacted",
803
+ "data-person-on-messenger": r ? "heard" : i ? "pressed" : "reacted",
791
804
  style: {
792
805
  alignSelf: "flex-end",
793
806
  maxWidth: "80%",
@@ -797,28 +810,31 @@ function L({ message: e }) {
797
810
  alignItems: "flex-end"
798
811
  },
799
812
  children: [
800
- o && /* @__PURE__ */ w(F, {
801
- text: o,
802
- dim: n
813
+ s && /* @__PURE__ */ w(F, {
814
+ text: s,
815
+ dim: r
803
816
  }),
804
- s && /* @__PURE__ */ w("div", {
817
+ c && /* @__PURE__ */ w("div", {
805
818
  "data-messenger-mark": !0,
806
819
  style: {
807
820
  fontSize: 10.5,
808
821
  color: "var(--text-3)",
809
822
  marginTop: 2
810
823
  },
811
- children: s
824
+ children: c
812
825
  }),
813
- /* @__PURE__ */ w(R, { message: e })
826
+ /* @__PURE__ */ w(R, {
827
+ message: e,
828
+ showsPlace: t
829
+ })
814
830
  ]
815
831
  });
816
832
  }
817
- function R({ message: e }) {
818
- let t = f(), n = m("agent_message")?.fields.get("delivery_status");
833
+ function R({ message: e, showsPlace: t }) {
834
+ let n = f(), r = m("agent_message")?.fields.get("delivery_status");
819
835
  if (!e.bot_id) return null;
820
- let r = [];
821
- return e.bot && r.push(e.bot), e.chat_id && r.push(t("agent.panel.messenger_chat", "chat {chat}", { chat: z(e.chat_id) })), e.topic_id && r.push(t("agent.panel.messenger_topic", "topic {topic}", { topic: e.topic_id })), !e.delivery_key && e.sender_external_id && (e.sender_user || z(e.sender_external_id) !== z(e.chat_id ?? "")) && r.push(t("agent.panel.messenger_from", "from {sender}", { sender: e.sender_user || z(e.sender_external_id) })), e.delivery_status && r.push(t(n?.values?.find((t) => t.code === e.delivery_status)?.name) || e.delivery_status), /* @__PURE__ */ w("div", {
836
+ let i = [];
837
+ return t && e.bot && i.push(e.bot), t && e.chat_id && i.push(n("agent.panel.messenger_chat", "chat {chat}", { chat: z(e.chat_id) })), t && e.topic_id && i.push(n("agent.panel.messenger_topic", "topic {topic}", { topic: e.topic_id })), !e.delivery_key && e.sender_external_id && (e.sender_user || z(e.sender_external_id) !== z(e.chat_id ?? "")) && i.push(n("agent.panel.messenger_from", "from {sender}", { sender: e.sender_user || z(e.sender_external_id) })), e.delivery_status && i.push(n(r?.values?.find((t) => t.code === e.delivery_status)?.name) || e.delivery_status), i.length === 0 ? null : /* @__PURE__ */ w("div", {
822
838
  "data-messenger-facts": !0,
823
839
  "data-delivery-status": e.delivery_status ?? void 0,
824
840
  style: {
@@ -827,7 +843,7 @@ function R({ message: e }) {
827
843
  marginTop: 2,
828
844
  overflowWrap: "anywhere"
829
845
  },
830
- children: r.join(" · ")
846
+ children: i.join(" · ")
831
847
  });
832
848
  }
833
849
  function z(e) {
@@ -1,41 +1,55 @@
1
1
  // src/components/agents/transcript-runs.ts
2
2
  var e = /* @__PURE__ */ new Set(["operation.search"]);
3
- function t(t, i = []) {
4
- let s = [], c = /* @__PURE__ */ new Map();
5
- for (let e of i) e.assistant_message_id && e.provider_call_id && c.set(r(e.assistant_message_id, e.provider_call_id), e);
6
- let l = /* @__PURE__ */ new Map(), u = new Set(t.filter((e) => e.role === "assistant").map((e) => e.id));
3
+ function t(t, a = []) {
4
+ let c = [], l = /* @__PURE__ */ new Map();
5
+ for (let e of a) e.assistant_message_id && e.provider_call_id && l.set(i(e.assistant_message_id, e.provider_call_id), e);
6
+ let u = /* @__PURE__ */ new Map(), d = new Set(t.filter((e) => e.role === "assistant").map((e) => e.id));
7
7
  for (let e of t) {
8
8
  let t = e.delivery_key?.startsWith("reply:") ? e.delivery_key.slice(6) : "";
9
- u.has(t) && l.set(t, e);
9
+ d.has(t) && u.set(t, e);
10
10
  }
11
- let d = new Set(l.values());
12
- for (let r of t) {
13
- if (d.has(r)) continue;
14
- let t = n(r, c);
15
- if (o(r)) {
16
- let e = l.get(r.id);
17
- s.push({
11
+ let f = new Set(u.values());
12
+ for (let n of t) {
13
+ if (f.has(n)) continue;
14
+ let t = r(n, l);
15
+ if (s(n)) {
16
+ let e = u.get(n.id);
17
+ c.push({
18
18
  kind: "message",
19
- message: a(r),
19
+ message: o(n),
20
20
  ...e ? { delivered: e } : {}
21
21
  });
22
22
  }
23
23
  if (t.length === 0) continue;
24
- let i = s[s.length - 1], u = i?.kind === "run" ? i : (s.push({
24
+ let i = c[c.length - 1], a = i?.kind === "run" ? i : (c.push({
25
25
  kind: "run",
26
- id: r.id,
26
+ id: n.id,
27
27
  calls: []
28
- }), s[s.length - 1]);
29
- for (let n of t) e.has(n.name) || u.calls.push(n);
30
- u.calls.length === 0 && s.pop();
28
+ }), c[c.length - 1]);
29
+ for (let n of t) e.has(n.name) || a.calls.push(n);
30
+ a.calls.length === 0 && c.pop();
31
31
  }
32
- return s;
32
+ return n(c), c;
33
33
  }
34
- function n(e, t) {
34
+ function n(e) {
35
+ let t = "";
36
+ for (let n of e) {
37
+ if (n.kind !== "message") continue;
38
+ let e = n.delivered ?? n.message;
39
+ if (!e.bot_id) continue;
40
+ let r = [
41
+ e.bot_id,
42
+ e.chat_id ?? "",
43
+ e.topic_id ?? ""
44
+ ].join("\0");
45
+ r !== t && (n.showsPlace = !0), t = r;
46
+ }
47
+ }
48
+ function r(e, t) {
35
49
  let n = [];
36
- for (let i of e.content ?? []) {
37
- if (i.type !== "tool_use") continue;
38
- let a = i, o = a.id ?? "", s = t.get(r(e.id, o)), c = s?.status;
50
+ for (let r of e.content ?? []) {
51
+ if (r.type !== "tool_use") continue;
52
+ let a = r, o = a.id ?? "", s = t.get(i(e.id, o)), c = s?.status;
39
53
  n.push({
40
54
  id: s?.id ?? `${e.id}:${o || n.length}`,
41
55
  name: a.name ?? "",
@@ -48,22 +62,22 @@ function n(e, t) {
48
62
  }
49
63
  return n;
50
64
  }
51
- function r(e, t) {
65
+ function i(e, t) {
52
66
  return `${e}\u0000${t}`;
53
67
  }
54
- var i = /* @__PURE__ */ new Set([
68
+ var a = /* @__PURE__ */ new Set([
55
69
  "tool_use",
56
70
  "tool_result",
57
71
  "thinking",
58
72
  "redacted_thinking"
59
73
  ]);
60
- function a(e) {
74
+ function o(e) {
61
75
  return {
62
76
  ...e,
63
- content: (e.content ?? []).filter((e) => !i.has(e.type))
77
+ content: (e.content ?? []).filter((e) => !a.has(e.type))
64
78
  };
65
79
  }
66
- function o(e) {
67
- return (e.attachments?.length ?? 0) > 0 || (e.content ?? []).some((e) => !i.has(e.type));
80
+ function s(e) {
81
+ return (e.attachments?.length ?? 0) > 0 || (e.content ?? []).some((e) => !a.has(e.type));
68
82
  }
69
83
  export { t as fold };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.185.0",
3
+ "version": "0.186.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",