@inkeep/agents-ui 0.15.29 → 0.16.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.
Files changed (54) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +157 -158
  3. package/dist/primitives/atoms/markdown/index.cjs +1 -1
  4. package/dist/primitives/atoms/markdown/index.js +41 -39
  5. package/dist/primitives/components/embedded-chat.cjs +4 -4
  6. package/dist/primitives/components/embedded-chat.d.ts +5 -14
  7. package/dist/primitives/components/embedded-chat.js +800 -849
  8. package/dist/primitives/hooks/use-feedback-api.cjs +1 -0
  9. package/dist/primitives/hooks/use-feedback-api.d.ts +19 -0
  10. package/dist/primitives/hooks/use-feedback-api.js +37 -0
  11. package/dist/primitives/hooks/use-simple-scroll.cjs +1 -1
  12. package/dist/primitives/hooks/use-simple-scroll.d.ts +7 -0
  13. package/dist/primitives/hooks/use-simple-scroll.js +33 -30
  14. package/dist/primitives/index.cjs +1 -1
  15. package/dist/primitives/index.js +134 -136
  16. package/dist/primitives/providers/base-events-provider.cjs +1 -1
  17. package/dist/primitives/providers/base-events-provider.js +1 -1
  18. package/dist/primitives/providers/feedback-provider.cjs +1 -1
  19. package/dist/primitives/providers/feedback-provider.d.ts +1 -1
  20. package/dist/primitives/providers/feedback-provider.js +57 -64
  21. package/dist/primitives/providers/index.cjs +1 -1
  22. package/dist/primitives/providers/index.d.ts +0 -1
  23. package/dist/primitives/providers/index.js +42 -45
  24. package/dist/primitives/utils/component-ids.cjs +1 -1
  25. package/dist/primitives/utils/component-ids.d.ts +2 -6
  26. package/dist/primitives/utils/component-ids.js +1 -3
  27. package/dist/primitives/utils/default-settings.cjs +1 -1
  28. package/dist/primitives/utils/default-settings.d.ts +1 -0
  29. package/dist/primitives/utils/default-settings.js +6 -5
  30. package/dist/primitives/utils/misc.cjs +5 -1
  31. package/dist/primitives/utils/misc.d.ts +2 -1
  32. package/dist/primitives/utils/misc.js +45 -20
  33. package/dist/react/embedded-chat.cjs +1 -1
  34. package/dist/react/embedded-chat.js +249 -264
  35. package/dist/react/index.cjs +1 -1
  36. package/dist/react/index.js +157 -158
  37. package/dist/styled/components/embedded-chat.cjs +1 -1
  38. package/dist/styled/components/embedded-chat.d.ts +2 -4
  39. package/dist/styled/components/embedded-chat.js +381 -411
  40. package/dist/styled/components/index.cjs +1 -1
  41. package/dist/styled/components/index.js +12 -11
  42. package/dist/styled/components/message.cjs +1 -1
  43. package/dist/styled/components/message.d.ts +20 -0
  44. package/dist/styled/components/message.js +304 -230
  45. package/dist/styled/index.cjs +1 -1
  46. package/dist/styled/index.js +155 -156
  47. package/dist/styled/inkeep.css.cjs +79 -12
  48. package/dist/styled/inkeep.css.js +79 -12
  49. package/dist/types/config/ai.d.ts +7 -0
  50. package/dist/types/events.d.ts +3 -17
  51. package/package.json +1 -1
  52. package/dist/primitives/providers/feedback-item-provider.cjs +0 -1
  53. package/dist/primitives/providers/feedback-item-provider.d.ts +0 -10
  54. package/dist/primitives/providers/feedback-item-provider.js +0 -16
@@ -1,20 +1,21 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as i, Fragment as oe } from "react/jsx-runtime";
3
- import { useBaseEvents as se } from "../../primitives/providers/base-events-provider.js";
4
- import { useInkeepConfig as ie } from "../../primitives/providers/config-provider.js";
5
- import { useMessage as le } from "../../primitives/providers/message-provider.js";
6
- import { EmbeddedChatPrimitiveMarkdown as pe, PrimitiveMessagePart as S } from "../../primitives/components/embedded-chat.js";
7
- import { useChat as ce } from "../../primitives/components/embedded-chat/chat-provider.js";
8
- import { merge as de } from "merge-anything";
9
- import { cn as T } from "../utils.js";
10
- import { markdownStyles as ue } from "./ui/markdown-styles.js";
11
- import { useStreamProcessor as me } from "../../primitives/components/embedded-chat/use-stream-processor.js";
12
- import { DataSummaryGroup as he } from "./data-summary-group.js";
13
- import { useState as j, useRef as D, useEffect as $, useMemo as L, useCallback as P } from "react";
14
- import { DynamicComponent as R, MessageLoading as fe } from "./embedded-chat.js";
15
- import { Library as xe, ComponentIcon as ge, Hammer as ye, ChevronDown as we, Check as F, X as ve, XCircle as K, CheckCircle as W, Clock as be, Loader2 as Ce, Circle as ke } from "lucide-react";
16
- import { button as X } from "./ui/recipes/button.js";
17
- const Ne = {
2
+ import { jsx as e, jsxs as o, Fragment as ie } from "react/jsx-runtime";
3
+ import { useBaseEvents as le } from "../../primitives/providers/base-events-provider.js";
4
+ import { useInkeepConfig as de } from "../../primitives/providers/config-provider.js";
5
+ import { useMessage as pe } from "../../primitives/providers/message-provider.js";
6
+ import { EmbeddedChatPrimitiveMarkdown as ce, PrimitiveMessagePart as D } from "../../primitives/components/embedded-chat.js";
7
+ import { useChat as me } from "../../primitives/components/embedded-chat/chat-provider.js";
8
+ import { isCitationArtifact as ue } from "../../primitives/utils/misc.js";
9
+ import { merge as he } from "merge-anything";
10
+ import { cn as y } from "../utils.js";
11
+ import { markdownStyles as xe } from "./ui/markdown-styles.js";
12
+ import { useStreamProcessor as fe } from "../../primitives/components/embedded-chat/use-stream-processor.js";
13
+ import { DataSummaryGroup as ge } from "./data-summary-group.js";
14
+ import { useState as L, useRef as A, useEffect as $, useMemo as E, useCallback as P } from "react";
15
+ import { DynamicComponent as M, MessageLoading as ye } from "./embedded-chat.js";
16
+ import { Hammer as be, ChevronDown as X, Check as F, X as we, Library as ke, ComponentIcon as Ne, XCircle as ve, TriangleAlert as Ce, CheckCircle as K, Clock as Se, Loader2 as De, Circle as Te } from "lucide-react";
17
+ import { button as W } from "./ui/recipes/button.js";
18
+ const Ae = {
18
19
  "input-streaming": "Pending",
19
20
  "input-available": "Running",
20
21
  "approval-requested": "Awaiting Approval",
@@ -23,312 +24,385 @@ const Ne = {
23
24
  "output-error": "Error",
24
25
  "output-denied": "Denied"
25
26
  };
26
- function Se(a) {
27
- if (!a || typeof a != "object") return !1;
28
- const r = a;
29
- return typeof r.type == "string" && r.type.startsWith("tool-");
27
+ function Ee(t) {
28
+ if (!t || typeof t != "object") return !1;
29
+ const a = t;
30
+ return typeof a.type == "string" && a.type.startsWith("tool-");
30
31
  }
31
- const Te = (a) => {
32
- if (!a || typeof a != "object" || !("status" in a)) return;
33
- const r = a.status;
34
- return typeof r == "string" ? r : void 0;
35
- }, De = () => /* @__PURE__ */ e("div", { className: "flex space-x-1", children: [0, 1, 2].map((a) => /* @__PURE__ */ e(
32
+ const Pe = (t) => {
33
+ if (!t || typeof t != "object" || !("status" in t)) return;
34
+ const a = t.status;
35
+ return typeof a == "string" ? a : void 0;
36
+ }, Le = () => /* @__PURE__ */ e("div", { className: "flex space-x-1", children: [0, 1, 2].map((t) => /* @__PURE__ */ e(
36
37
  "span",
37
38
  {
38
39
  className: "animate-bounce-dot opacity-30",
39
40
  style: {
40
- animationDelay: `${a * 0.2}s`
41
+ animationDelay: `${t * 0.2}s`
41
42
  },
42
43
  children: "."
43
44
  },
44
- a
45
- )) }), G = ({ name: a, Icon: r, props: n, componentType: l }) => /* @__PURE__ */ i("div", { className: "border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3", children: [
46
- /* @__PURE__ */ i("div", { className: "flex justify-between px-4 py-2 text-xs", children: [
47
- /* @__PURE__ */ i("div", { className: "font-medium flex items-center gap-2", children: [
48
- /* @__PURE__ */ e(r, { className: "w-3 h-3 text-gray-600 dark:text-white-alpha-600" }),
49
- /* @__PURE__ */ e("span", { children: a })
45
+ t
46
+ )) }), G = ({ name: t, Icon: a, props: i, componentType: s }) => /* @__PURE__ */ o("div", { className: "border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3", children: [
47
+ /* @__PURE__ */ o("div", { className: "flex justify-between px-4 py-2 text-xs", children: [
48
+ /* @__PURE__ */ o("div", { className: "font-medium flex items-center gap-2", children: [
49
+ /* @__PURE__ */ e(a, { className: "w-3 h-3 text-gray-600 dark:text-white-alpha-600" }),
50
+ /* @__PURE__ */ e("span", { children: t })
50
51
  ] }),
51
- /* @__PURE__ */ e("div", { className: "flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono", children: l })
52
+ /* @__PURE__ */ e("div", { className: "flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono", children: s })
52
53
  ] }),
53
- /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2", children: JSON.stringify(n, null, 2) })
54
- ] }), Le = ({ name: a, props: r }) => /* @__PURE__ */ e(G, { name: a, Icon: ge, props: r, componentType: "component" }), Pe = ({ name: a, props: r }) => /* @__PURE__ */ e(G, { name: a, Icon: xe, props: r, componentType: "artifact" }), Ee = ({
55
- tool: a,
56
- componentDef: r,
57
- renderText: n,
58
- approvalId: l,
59
- messagePartsLength: h,
60
- setApprovalDelayPending: o,
61
- addToolApprovalResponse: s,
62
- sendMessage: c,
63
- conversationId: d
54
+ /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2", children: JSON.stringify(i, null, 2) })
55
+ ] }), je = ({ name: t, props: a }) => /* @__PURE__ */ e(G, { name: t, Icon: Ne, props: a, componentType: "component" }), Ie = ({ name: t, props: a }) => /* @__PURE__ */ e(G, { name: t, Icon: ke, props: a, componentType: "artifact" }), _e = ({
56
+ tool: t,
57
+ componentDef: a,
58
+ renderText: i,
59
+ approvalId: s,
60
+ messagePartsLength: u,
61
+ setApprovalDelayPending: n,
62
+ addToolApprovalResponse: c,
63
+ sendMessage: d,
64
+ conversationId: f
64
65
  }) => {
65
- const f = D(c);
66
- f.current = c;
67
- const x = D(s);
68
- x.current = s;
69
- const u = D(o);
70
- u.current = o;
71
- const v = P(
72
- async (A = !0) => {
73
- l && (u.current({ partCount: h }), x.current({ id: l, approved: A }), await f.current(void 0, { body: { conversationId: d } }));
66
+ const l = A(d);
67
+ l.current = d;
68
+ const m = A(c);
69
+ m.current = c;
70
+ const p = A(n);
71
+ p.current = n;
72
+ const h = P(
73
+ async (j = !0) => {
74
+ s && (p.current({ partCount: u }), m.current({ id: s, approved: j }), await l.current(void 0, { body: { conversationId: f } }));
74
75
  },
75
- [l, h, d]
76
- ), g = L(() => ({ tool: a, approve: v, renderMarkdown: n }), [a]);
77
- return /* @__PURE__ */ e(r ? R : Ae, { name: a.type, props: g, componentDef: r });
78
- }, Ae = ({ props: a, isDebug: r = !1 }) => {
79
- const { tool: n, approve: l } = a, h = n.type, o = h.startsWith("tool-") ? h.slice(5) : h, s = n.state, c = n.approval?.id, d = !!c, f = s === "approval-requested", x = Te(n.output), [u, v] = j(d || r), g = s ? Ne[s] ?? s : "tool";
76
+ [s, u, f]
77
+ ), v = E(() => ({ tool: t, approve: h, renderMarkdown: i }), [t]);
78
+ return /* @__PURE__ */ e(a ? M : Me, { name: t.type, props: v, componentDef: a });
79
+ };
80
+ function H(t) {
81
+ return t === null ? /* @__PURE__ */ e("span", { className: "text-gray-500 dark:text-white-alpha-500 font-mono font-medium text-1xs", children: "null" }) : t === void 0 ? /* @__PURE__ */ e("span", { className: "text-gray-400 dark:text-white-alpha-400 italic text-xs font-medium", children: "undefined" }) : typeof t == "boolean" ? /* @__PURE__ */ e(
82
+ "span",
83
+ {
84
+ className: y(
85
+ "inline-flex font-mono font-semibold items-center px-1 py-0.5 text-1xs rounded-md border",
86
+ t ? "bg-inkeep-expanded-primary-50 border-inkeep-expanded-primary-200 text-inkeep-expanded-primary-600 dark:bg-inkeep-expanded-primary-950 dark:border-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200" : "bg-gray-100 dark:bg-white-alpha-50 text-gray-700 dark:text-white-alpha-700"
87
+ ),
88
+ children: t ? "true" : "false"
89
+ }
90
+ ) : typeof t == "number" ? /* @__PURE__ */ e("span", { className: "tabular-nums font-medium text-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200", children: t.toLocaleString() }) : typeof t == "string" ? /* @__PURE__ */ e("span", { className: "text-gray-800 dark:text-white-alpha-800 break-words", children: t }) : /* @__PURE__ */ e("span", { children: String(t) });
91
+ }
92
+ const J = ({
93
+ name: t,
94
+ value: a,
95
+ isArrayIndex: i,
96
+ depth: s = 0
97
+ }) => {
98
+ const [u, n] = L(s < 1), c = a !== null && typeof a == "object" && !Array.isArray(a), d = Array.isArray(a);
99
+ if (!(c || d))
100
+ return /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2 py-1 text-xs", children: [
101
+ /* @__PURE__ */ e(
102
+ "span",
103
+ {
104
+ className: y(
105
+ "font-medium shrink-0",
106
+ i ? "text-gray-300 dark:text-white-alpha-300" : "text-gray-500 dark:text-white-alpha-500"
107
+ ),
108
+ children: i ? "—" : t
109
+ }
110
+ ),
111
+ /* @__PURE__ */ e("span", { className: "min-w-0", children: H(a) })
112
+ ] });
113
+ const l = d ? a.map((p, h) => [String(h), p]) : Object.entries(a);
114
+ return l.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2 py-1 text-xs", children: [
115
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-500 dark:text-white-alpha-500 shrink-0", children: t }),
116
+ /* @__PURE__ */ e("span", { className: "text-gray-400 dark:text-white-alpha-400 italic", children: d ? "empty list" : "empty" })
117
+ ] }) : /* @__PURE__ */ o("div", { children: [
118
+ /* @__PURE__ */ o(
119
+ "button",
120
+ {
121
+ type: "button",
122
+ onClick: (p) => {
123
+ p.stopPropagation(), n(!u);
124
+ },
125
+ className: "flex items-center gap-1.5 py-1 text-xs hover:bg-gray-50 dark:hover:bg-white-alpha-50 -mx-1.5 px-1.5 rounded transition-colors w-full text-left",
126
+ children: [
127
+ /* @__PURE__ */ e(
128
+ X,
129
+ {
130
+ className: y(
131
+ "h-3.5 w-3.5 text-gray-400 dark:text-white-alpha-400 shrink-0 transition-transform",
132
+ !u && "-rotate-90"
133
+ )
134
+ }
135
+ ),
136
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-500 dark:text-white-alpha-500", children: t }),
137
+ !u && /* @__PURE__ */ e("span", { className: "text-gray-400 dark:text-white-alpha-400 text-1xs ml-1", children: d ? `${l.length} item${l.length !== 1 ? "s" : ""}` : `${l.length} field${l.length !== 1 ? "s" : ""}` })
138
+ ]
139
+ }
140
+ ),
141
+ u && /* @__PURE__ */ e("div", { className: "border-l-2 border-gray-200 dark:border-white-alpha-200 ml-1.5 pl-3", children: l.map(([p, h]) => /* @__PURE__ */ e(J, { name: p, value: h, isArrayIndex: d, depth: s + 1 }, p)) })
142
+ ] });
143
+ }, $e = ({ value: t }) => {
144
+ if (t == null || typeof t != "object")
145
+ return /* @__PURE__ */ e("span", { className: "text-xs", children: H(t) });
146
+ const a = Array.isArray(t) ? t.map((i, s) => [String(s), i]) : Object.entries(t);
147
+ return a.length === 0 ? /* @__PURE__ */ e("div", { className: "text-xs text-gray-400 dark:text-white-alpha-400 italic", children: "No arguments" }) : /* @__PURE__ */ e("div", { className: "space-y-1", children: a.map(([i, s]) => /* @__PURE__ */ e(J, { name: i, value: s, isArrayIndex: Array.isArray(t) }, i)) });
148
+ }, Me = ({ props: t }) => {
149
+ const { tool: a, approve: i } = t, s = a.type, u = s.startsWith("tool-") ? s.slice(5) : s, n = a.state, c = a.approval?.id, d = !!c, f = n === "approval-requested", l = Pe(a.output), [m, p] = L(d), h = n ? Ae[n] ?? n : "tool";
80
150
  return $(() => {
81
- f && v(!0);
82
- }, [f]), /* @__PURE__ */ i("div", { className: "border rounded-lg mb-3 overflow-hidden", children: [
83
- (!d || r) && /* @__PURE__ */ i(
151
+ f && p(!0);
152
+ }, [f]), /* @__PURE__ */ o("div", { className: "border rounded-lg mb-3 overflow-hidden", children: [
153
+ /* @__PURE__ */ o(
84
154
  "button",
85
155
  {
86
156
  type: "button",
87
- className: "inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2",
88
- onClick: () => v(!u),
89
- "data-expanded": u,
157
+ className: "inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2 data-[expanded=true]:border-b",
158
+ onClick: () => p(!m),
159
+ "aria-expanded": m,
160
+ "data-expanded": m,
90
161
  children: [
91
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ i("div", { className: "font-medium flex items-center gap-2", children: [
92
- /* @__PURE__ */ e(ye, { className: "w-3 h-3 text-gray-600 dark:text-white-alpha-600" }),
93
- /* @__PURE__ */ e("span", { children: o })
162
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ o("div", { className: "font-medium flex items-center gap-2", children: [
163
+ /* @__PURE__ */ e(be, { className: "w-3 h-3 text-gray-600 dark:text-white-alpha-600" }),
164
+ /* @__PURE__ */ e("span", { children: u })
94
165
  ] }) }),
95
- /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
96
- /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono", children: [
166
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
167
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono", children: [
97
168
  (() => {
98
- switch (s) {
169
+ switch (n) {
99
170
  case "input-streaming":
100
- return /* @__PURE__ */ e(ke, { className: "w-3 h-3" });
171
+ return /* @__PURE__ */ e(Te, { className: "w-3 h-3" });
101
172
  case "input-available":
102
- return /* @__PURE__ */ e(Ce, { className: "w-3 h-3 animate-spin" });
173
+ return /* @__PURE__ */ e(De, { className: "w-3 h-3 animate-spin" });
103
174
  case "approval-requested":
104
- return /* @__PURE__ */ e(be, { className: "w-3 h-3" });
175
+ return /* @__PURE__ */ e(Se, { className: "w-3 h-3" });
105
176
  case "approval-responded":
106
- return /* @__PURE__ */ e(W, { className: "w-3 h-3" });
177
+ return /* @__PURE__ */ e(K, { className: "w-3 h-3" });
107
178
  case "output-available":
108
- return /* @__PURE__ */ e(W, { className: "w-3 h-3" });
109
- case "output-error":
110
179
  return /* @__PURE__ */ e(K, { className: "w-3 h-3" });
180
+ case "output-error":
181
+ return /* @__PURE__ */ e(Ce, { className: "w-3 h-3" });
111
182
  case "output-denied":
112
- return /* @__PURE__ */ e(K, { className: "w-3 h-3" });
183
+ return /* @__PURE__ */ e(ve, { className: "w-3 h-3" });
113
184
  default:
114
185
  return null;
115
186
  }
116
187
  })(),
117
- g
188
+ h
118
189
  ] }),
119
- /* @__PURE__ */ e(we, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180" })
190
+ /* @__PURE__ */ e(X, { className: "w-3.5 h-3.5 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180" })
120
191
  ] })
121
192
  ]
122
193
  }
123
194
  ),
124
- /* @__PURE__ */ e(
195
+ /* @__PURE__ */ o(
125
196
  "div",
126
197
  {
127
- "data-expanded": u,
128
- className: T(
129
- "relative",
130
- 'before:content-[""] before:absolute before:inset-x-0 before:-top-px before:h-3 before:pointer-events-none before:z-10',
131
- 'after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',
132
- "before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]",
133
- "dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]",
134
- "data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"
198
+ "data-expanded": m,
199
+ className: y(
200
+ "overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full"
135
201
  ),
136
- children: /* @__PURE__ */ i(
137
- "div",
138
- {
139
- "data-expanded": u,
140
- className: T(
141
- "px-4 data-[expanded=true]:pb-3 [scrollbar-width:thin] overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full",
142
- d ? "" : "data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"
202
+ children: [
203
+ /* @__PURE__ */ e(
204
+ "div",
205
+ {
206
+ "data-expanded": m,
207
+ className: y(
208
+ "relative",
209
+ 'before:content-[""] before:absolute before:inset-x-0 before:top-0 before:h-3 before:pointer-events-none before:z-10',
210
+ 'after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',
211
+ "before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]",
212
+ "dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]",
213
+ "data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"
214
+ ),
215
+ children: /* @__PURE__ */ e(
216
+ "div",
217
+ {
218
+ "data-expanded": m,
219
+ className: y(
220
+ "[scrollbar-width:thin] px-4",
221
+ "data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"
222
+ ),
223
+ children: a.input != null && /* @__PURE__ */ e("div", { className: "text-xs py-2", children: /* @__PURE__ */ e($e, { value: a.input }) })
224
+ }
225
+ )
226
+ }
227
+ ),
228
+ f && c && /* @__PURE__ */ o("div", { className: "flex justify-end gap-2 pt-1 pb-3 px-4", children: [
229
+ /* @__PURE__ */ e(
230
+ "button",
231
+ {
232
+ type: "button",
233
+ className: y(
234
+ W({ size: "xs", variant: "outline" }),
235
+ "px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"
236
+ ),
237
+ onClick: () => i(!1),
238
+ children: "Deny"
239
+ }
143
240
  ),
144
- children: [
145
- n.input != null && /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2", children: JSON.stringify(n.input, null, 2) }),
146
- !r && d && /* @__PURE__ */ i("div", { className: "whitespace-pre-wrap text-sm text-gray-700 dark:text-white-alpha-700 py-2", children: [
147
- "Approval is needed to run ",
148
- /* @__PURE__ */ e("strong", { children: o }),
149
- "."
150
- ] }),
151
- f && c && /* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-1", children: [
152
- /* @__PURE__ */ e(
153
- "button",
154
- {
155
- type: "button",
156
- className: T(
157
- X({ size: "xs", variant: "outline" }),
158
- "px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"
159
- ),
160
- onClick: () => l(!1),
161
- children: "Deny"
162
- }
241
+ /* @__PURE__ */ o(
242
+ "button",
243
+ {
244
+ type: "button",
245
+ className: y(
246
+ W({ size: "xs", variant: "primaryFilled" }),
247
+ "px-2 py-1 rounded-md text-xs gap-1"
163
248
  ),
164
- /* @__PURE__ */ i(
165
- "button",
166
- {
167
- type: "button",
168
- className: T(
169
- X({ size: "xs", variant: "primaryFilled" }),
170
- "px-2 py-1 rounded-md text-xs gap-1"
171
- ),
172
- onClick: () => l(!0),
173
- children: [
174
- /* @__PURE__ */ e(F, { className: "w-3 h-3" }),
175
- "Approve"
176
- ]
177
- }
178
- )
179
- ] }),
180
- s === "output-available" && n.output != null && !r && /* @__PURE__ */ i("div", { className: "flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize", children: [
181
- x === "approved" && /* @__PURE__ */ e(F, { className: "w-3 h-3" }),
182
- x
183
- ] }),
184
- s === "output-denied" && !r && /* @__PURE__ */ i("div", { className: "flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize", children: [
185
- /* @__PURE__ */ e(ve, { className: "w-3 h-3" }),
186
- g
187
- ] }),
188
- s === "output-available" && n.output != null && r && /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2", children: typeof n.output == "string" ? n.output : JSON.stringify(n.output, null, 2) })
189
- ]
190
- }
191
- )
249
+ onClick: () => i(!0),
250
+ children: [
251
+ /* @__PURE__ */ e(F, { className: "w-3 h-3" }),
252
+ "Approve"
253
+ ]
254
+ }
255
+ )
256
+ ] }),
257
+ n === "output-available" && l && a.output != null && /* @__PURE__ */ o("div", { className: "flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4", children: [
258
+ l === "approved" && /* @__PURE__ */ e(F, { className: "w-3 h-3" }),
259
+ l
260
+ ] }),
261
+ n === "output-denied" && /* @__PURE__ */ o("div", { className: "flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4", children: [
262
+ /* @__PURE__ */ e(we, { className: "w-3 h-3" }),
263
+ h
264
+ ] })
265
+ ]
192
266
  }
193
267
  )
194
268
  ] });
195
- }, Xe = ({
196
- className: a,
197
- componentStyles: r,
198
- children: n,
199
- isLast: l,
200
- ...h
269
+ }, Ze = ({
270
+ className: t,
271
+ componentStyles: a,
272
+ children: i,
273
+ isLast: s,
274
+ ...u
201
275
  }) => {
202
- const { message: o } = le(), { logEvent: s } = se(), { conversationId: c, isStreaming: d, isLoading: f, setError: x, addToolApprovalResponse: u, sendMessage: v } = ce(), {
203
- aiChatSettings: { components: g, artifacts: E, headers: A }
204
- } = ie(), H = A?.["x-emit-operations"] === "true", O = o.role === "user", V = (d || f) && l && o.role === "assistant", { processedParts: Q, summaryTimings: Y, shouldShowInitialLoading: Z, shouldShowStreamDelayLoading: ee } = me(o.parts, V, x), [k, z] = j(null), [te, _] = j(!1), m = D(null);
276
+ const { message: n } = pe(), { logEvent: c } = le(), { conversationId: d, isStreaming: f, isLoading: l, setError: m, addToolApprovalResponse: p, sendMessage: h } = me(), {
277
+ aiChatSettings: { components: v, artifacts: R, headers: j }
278
+ } = de(), Q = j?.["x-emit-operations"] === "true", O = n.role === "user", Y = (f || l) && s && n.role === "assistant", { processedParts: Z, summaryTimings: ee, shouldShowInitialLoading: te, shouldShowStreamDelayLoading: ae } = fe(n.parts, Y, m), [C, z] = L(null), [re, I] = L(!1), g = A(null);
205
279
  $(() => {
206
- if (!k) {
207
- _(!1), m.current && (clearTimeout(m.current), m.current = null);
280
+ if (!C) {
281
+ I(!1), g.current && (clearTimeout(g.current), g.current = null);
208
282
  return;
209
283
  }
210
- return _(!1), m.current && clearTimeout(m.current), m.current = window.setTimeout(() => {
211
- _(!0);
284
+ return I(!1), g.current && clearTimeout(g.current), g.current = window.setTimeout(() => {
285
+ I(!0);
212
286
  }, 1e3), () => {
213
- m.current && (clearTimeout(m.current), m.current = null);
287
+ g.current && (clearTimeout(g.current), g.current = null);
214
288
  };
215
- }, [k]), $(() => {
216
- k && (!l || o.parts.length > k.partCount) && z(null);
217
- }, [k, l, o.parts.length]);
218
- const q = L(
219
- () => o.parts.filter(
220
- (t) => t.type === "data-artifact" && t.data?.type?.toLowerCase() === "citation"
221
- ),
222
- [o.parts]
223
- ), J = L(
224
- () => de(ue, r ?? {}),
225
- [r]
226
- ), U = P(
227
- (t, p) => {
228
- s({
289
+ }, [C]), $(() => {
290
+ C && (!s || n.parts.length > C.partCount) && z(null);
291
+ }, [C, s, n.parts.length]);
292
+ const q = E(() => n.parts.filter(ue), [n.parts]), U = E(
293
+ () => he(xe, a ?? {}),
294
+ [a]
295
+ ), V = P(
296
+ (r, x) => {
297
+ c({
229
298
  eventName: "assistant_message_inline_link_opened",
230
299
  properties: {
231
- title: p?.toString(),
232
- url: t
300
+ title: x?.toString(),
301
+ url: r
233
302
  }
234
303
  });
235
304
  },
236
- [s]
305
+ [c]
237
306
  ), B = P(
238
- (t, p) => {
239
- s({
307
+ (r, x) => {
308
+ c({
240
309
  eventName: "assistant_code_block_copied",
241
310
  properties: {
242
- conversationId: c,
243
- language: t,
244
- code: p
311
+ conversationId: d,
312
+ language: r,
313
+ code: x
245
314
  }
246
315
  });
247
316
  },
248
- [s, c]
249
- ), I = P(
250
- (t) => /* @__PURE__ */ e(
251
- pe,
317
+ [c, d]
318
+ ), _ = P(
319
+ (r) => /* @__PURE__ */ e(
320
+ ce,
252
321
  {
253
- text: t,
254
- componentStyles: J,
255
- onLinkClick: U,
322
+ text: r,
323
+ componentStyles: U,
324
+ onLinkClick: V,
256
325
  onCodeCopy: B,
257
326
  artifacts: q
258
327
  }
259
328
  ),
260
- [J, U, B, q]
261
- ), ae = L(
262
- () => T(
329
+ [U, V, B, q]
330
+ ), ne = E(
331
+ () => y(
263
332
  "data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",
264
- a
333
+ t
265
334
  ),
266
- [a]
267
- ), re = !O || o.parts.some((t) => t.type === "text" && t.text?.trim());
268
- return /* @__PURE__ */ i(oe, { children: [
269
- !re && /* @__PURE__ */ e("span", { className: "text-gray-500 dark:text-white-alpha-500", children: "No message content" }),
270
- Q.map((t, p) => {
271
- const b = {
272
- "data-role": o.role,
273
- "data-type": t?.type === "data-component" ? t.data.type : t?.type,
274
- ...h,
275
- className: ae
335
+ [t]
336
+ ), se = !O || n.parts.some(
337
+ (r) => r.type === "text" && r.text?.trim()
338
+ );
339
+ return /* @__PURE__ */ o(ie, { children: [
340
+ !se && /* @__PURE__ */ e("span", { className: "text-gray-500 dark:text-white-alpha-500", children: "No message content" }),
341
+ Z.map((r, x) => {
342
+ const k = {
343
+ "data-role": n.role,
344
+ "data-type": r?.type === "data-component" ? r.data.type : r?.type,
345
+ ...u,
346
+ className: ne
276
347
  };
277
- switch (t?.type) {
348
+ switch (r?.type) {
278
349
  case "text":
279
- return /* @__PURE__ */ e(S, { ...b, children: O ? t.text : I(t.text || "") }, p);
350
+ return /* @__PURE__ */ e(D, { ...k, children: O ? r.text : _(r.text || "") }, x);
280
351
  case "data-component": {
281
- const { type: y } = t.data;
282
- switch (y) {
352
+ const { type: w } = r.data;
353
+ switch (w) {
283
354
  case "text":
284
- return /* @__PURE__ */ e("div", { ...b, children: I(t.data.text || "") }, p);
355
+ return /* @__PURE__ */ e("div", { ...k, children: _(r.data.text || "") }, x);
285
356
  default: {
286
- const C = t.data, { name: w, props: M } = C, N = g?.[w];
287
- return /* @__PURE__ */ e(S, { ...b, children: /* @__PURE__ */ e(N ? R : Le, { name: w, props: M, componentDef: N }) }, `${w}-${p}`);
357
+ const N = r.data, { name: b, props: T } = N, S = v?.[b];
358
+ return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(S ? M : je, { name: b, props: T, componentDef: S }) }, `${b}-${x}`);
288
359
  }
289
360
  }
290
361
  }
291
362
  case "data-artifact": {
292
- const y = t.data, { name: C, type: w, artifactSummary: M } = y, N = E?.[w];
293
- return /* @__PURE__ */ e(S, { ...b, children: /* @__PURE__ */ e(N ? R : Pe, { name: w, props: M, componentDef: N }) }, `${C}-${p}`);
363
+ const w = r.data, { name: N, type: b, artifactSummary: T } = w;
364
+ if (b === "citation" && !T?.url) return null;
365
+ const S = R?.[b];
366
+ return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(S ? M : Ie, { name: b, props: T, componentDef: S }) }, `${N}-${x}`);
294
367
  }
295
368
  case "summary-group": {
296
- const y = Y.get(t.groupKey) || {
369
+ const w = ee.get(r.groupKey) || {
297
370
  isCompleted: !1
298
371
  };
299
- return /* @__PURE__ */ e(S, { ...b, children: /* @__PURE__ */ e(
300
- he,
372
+ return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(
373
+ ge,
301
374
  {
302
- summaries: t.summaries || [],
303
- isCompleted: y.isCompleted
375
+ summaries: r.summaries || [],
376
+ isCompleted: w.isCompleted
304
377
  }
305
- ) }, `${t.groupKey}-${p}`);
378
+ ) }, `${r.groupKey}-${x}`);
306
379
  }
307
380
  default: {
308
- if (!Se(t))
381
+ if (!Ee(r))
309
382
  return null;
310
- const y = t, C = t.approval?.id;
311
- return H || C ? /* @__PURE__ */ e(S, { ...b, children: /* @__PURE__ */ e(
312
- Ee,
383
+ const w = r, N = r.approval?.id;
384
+ return Q || N ? /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(
385
+ _e,
313
386
  {
314
- tool: y,
315
- componentDef: g?.IkpTool,
316
- renderText: I,
317
- approvalId: C,
318
- messagePartsLength: o.parts.length,
387
+ tool: w,
388
+ componentDef: v?.IkpTool,
389
+ renderText: _,
390
+ approvalId: N,
391
+ messagePartsLength: n.parts.length,
319
392
  setApprovalDelayPending: z,
320
- addToolApprovalResponse: u,
321
- sendMessage: v,
322
- conversationId: c
393
+ addToolApprovalResponse: p,
394
+ sendMessage: h,
395
+ conversationId: d
323
396
  }
324
- ) }, t.toolCallId ?? `${t.type}-${p}`) : null;
397
+ ) }, r.toolCallId ?? `${r.type}-${x}`) : null;
325
398
  }
326
399
  }
327
400
  }),
328
- Z && /* @__PURE__ */ e(fe, {}),
329
- (ee || te) && /* @__PURE__ */ e(De, {})
401
+ te && /* @__PURE__ */ e(ye, {}),
402
+ (ae || re) && /* @__PURE__ */ e(Le, {})
330
403
  ] });
331
404
  };
332
405
  export {
333
- Xe as EmbeddedChatMessagePart
406
+ Me as DefaultToolComponent,
407
+ Ze as EmbeddedChatMessagePart
334
408
  };