@inkeep/agents-ui 0.14.9 → 0.14.11

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.
@@ -22,7 +22,7 @@ import { SourceItemProvider as We, useSourceItem as H } from "../providers/sourc
22
22
  import { useInkeepConfig as p } from "../providers/config-provider.js";
23
23
  import { useMessageFeedback as oe } from "../providers/feedback-provider.js";
24
24
  import { MessageAttachmentsProvider as Re, useMessageAttachments as U } from "../providers/message-attachments-provider.js";
25
- import { useMessage as f, MessageProvider as Ne } from "../providers/message-provider.js";
25
+ import { useMessage as M, MessageProvider as Ne } from "../providers/message-provider.js";
26
26
  import { CheckboxIcon as pe } from "../atoms/icons/checkbox-icon.js";
27
27
  import { useCopyToClipboard as J } from "../hooks/use-copy-to-clipboard.js";
28
28
  import { FeedbackItemProvider as Ve, useFeedbackItem as se } from "../providers/feedback-item-provider.js";
@@ -262,7 +262,7 @@ const ot = "__intro__", st = a("div", {
262
262
  ), kt = a("div", {
263
263
  _id: "aiChatMessageHeader"
264
264
  }), Hn = (t) => {
265
- const { message: e } = f();
265
+ const { message: e } = M();
266
266
  return /* @__PURE__ */ n(kt, { "data-role": e.role, ...t });
267
267
  }, Bt = a("div", {
268
268
  _id: "aiChatMessageLoading",
@@ -270,12 +270,12 @@ const ot = "__intro__", st = a("div", {
270
270
  }), Ln = (t) => /* @__PURE__ */ n(Bt, { ...t }), yt = a("div", {
271
271
  _id: "aiChatMessageAvatar"
272
272
  }), xn = (t) => {
273
- const { message: e } = f();
273
+ const { message: e } = M();
274
274
  return /* @__PURE__ */ n(yt, { "data-role": e.role, ...t });
275
275
  }, Tt = a(ee.Root, {
276
276
  _id: "aiChatMessageAvatarContent"
277
277
  }), Dn = (t) => {
278
- const { message: e } = f(), { baseSettings: i } = p();
278
+ const { message: e } = M(), { baseSettings: i } = p();
279
279
  return /* @__PURE__ */ n(
280
280
  Tt,
281
281
  {
@@ -288,7 +288,7 @@ const ot = "__intro__", st = a("div", {
288
288
  _id: "aiChatMessageAvatarFallback"
289
289
  }), On = E(
290
290
  (t) => {
291
- const { baseSettings: e } = p(), { message: i } = f();
291
+ const { baseSettings: e } = p(), { message: i } = M();
292
292
  return e.userProperties.name ? /* @__PURE__ */ n(
293
293
  wt,
294
294
  {
@@ -305,7 +305,7 @@ const ot = "__intro__", st = a("div", {
305
305
  const { onLoadingStatusChange: e, ...i } = t, {
306
306
  aiChatSettings: r,
307
307
  baseSettings: { userProperties: o }
308
- } = p(), { message: s } = f(), { aiAssistantAvatar: c } = r ?? {}, d = typeof c == "string" ? c : c?.light, m = (typeof c == "string" ? c : c?.dark) ?? d, l = Ze(d, m), [C, v] = W(l);
308
+ } = p(), { message: s } = M(), { aiAssistantAvatar: c } = r ?? {}, d = typeof c == "string" ? c : c?.light, m = (typeof c == "string" ? c : c?.dark) ?? d, l = Ze(d, m), [C, v] = W(l);
309
309
  Y(() => {
310
310
  v(l);
311
311
  }, [l]);
@@ -353,7 +353,7 @@ const ot = "__intro__", st = a("div", {
353
353
  ), Ht = a("span", {
354
354
  _id: "aiChatMessageName"
355
355
  }), Rn = (t) => {
356
- const { message: e } = f();
356
+ const { message: e } = M();
357
357
  return /* @__PURE__ */ n(
358
358
  Ht,
359
359
  {
@@ -365,7 +365,7 @@ const ot = "__intro__", st = a("div", {
365
365
  }, Lt = a("div", {
366
366
  _id: "aiChatMessageContentWrapper"
367
367
  }), Nn = (t) => {
368
- const { message: e } = f(), { messageButtons: i } = b(), r = i[e.id] || [];
368
+ const { message: e } = M(), { messageButtons: i } = b(), r = i[e.id] || [];
369
369
  return /* @__PURE__ */ n(
370
370
  Lt,
371
371
  {
@@ -377,12 +377,12 @@ const ot = "__intro__", st = a("div", {
377
377
  }, xt = a("div", {
378
378
  _id: "aiChatMessageContent"
379
379
  }), Vn = (t) => {
380
- const { message: e } = f();
380
+ const { message: e } = M();
381
381
  return /* @__PURE__ */ n(xt, { "data-role": e.role, ...t });
382
382
  }, Dt = a("div", {
383
383
  _id: "aiChatMessageAttachments"
384
384
  }), $n = (t) => {
385
- const { message: e } = f(), i = [];
385
+ const { message: e } = M(), i = [];
386
386
  return e.role !== "user" || !i?.length ? null : /* @__PURE__ */ n(Re, { children: /* @__PURE__ */ n(Dt, { ...t }) });
387
387
  }, Ot = a("div", {
388
388
  _id: "aiChatMessageAttachments__List"
@@ -472,25 +472,25 @@ const ot = "__intro__", st = a("div", {
472
472
  }, [t]), Fe(() => {
473
473
  if (!i || !o || !l || !s.current)
474
474
  return;
475
- const _ = s.current, M = document.createElement("div");
476
- return M.setAttribute("data-component", t), M.setAttribute("slot", _), c.current = M, m.current = !1, o.appendChild(M), u(!0), () => {
475
+ const _ = s.current, F = document.createElement("div");
476
+ return F.setAttribute("data-ikp-component", ""), F.setAttribute("data-component", t), F.setAttribute("slot", _), c.current = F, m.current = !1, o.appendChild(F), u(!0), () => {
477
477
  m.current = !0, u(!1), queueMicrotask(() => {
478
478
  try {
479
479
  d.current && (d.current.unmount(), d.current = null);
480
480
  } catch (A) {
481
481
  console.debug("Ignoring unmount error:", A);
482
482
  }
483
- M.parentNode === o && M.remove(), c.current = null;
483
+ F.parentNode === o && F.remove(), c.current = null;
484
484
  });
485
485
  };
486
486
  }, [i, o, l, t]), Y(() => {
487
487
  const _ = c.current;
488
488
  if (!_ || m.current) return;
489
- const M = (F) => {
490
- if (typeof F != "function" || F.length > 1) return !1;
489
+ const F = (f) => {
490
+ if (typeof f != "function" || f.length > 1) return !1;
491
491
  try {
492
- if (typeof F == "function" && F.constructor === Function) {
493
- const w = F({});
492
+ if (typeof f == "function" && f.constructor === Function) {
493
+ const w = f({});
494
494
  return G.isValidElement(w);
495
495
  }
496
496
  return !1;
@@ -499,12 +499,12 @@ const ot = "__intro__", st = a("div", {
499
499
  }
500
500
  };
501
501
  let A;
502
- if (M(i))
502
+ if (F(i))
503
503
  try {
504
- const F = i;
505
- A = G.createElement(F, e || {});
506
- } catch (F) {
507
- console.error("Error creating React element from component:", F);
504
+ const f = i;
505
+ A = G.createElement(f, e || {});
506
+ } catch (f) {
507
+ console.error("Error creating React element from component:", f);
508
508
  return;
509
509
  }
510
510
  else if (typeof i == "function")
@@ -525,12 +525,12 @@ const ot = "__intro__", st = a("div", {
525
525
  }), Ut = a("div", {
526
526
  _id: "aiChatMessageToolbar"
527
527
  }), ir = (t) => {
528
- const { isLoading: e, messages: i } = b(), { message: r } = f();
528
+ const { isLoading: e, messages: i } = b(), { message: r } = M();
529
529
  return i.at(-1)?.id === r?.id && e || r.role === "user" ? null : /* @__PURE__ */ n(Ut, { ...t });
530
530
  }, Kt = a("div", {
531
531
  _id: "aiChatMessageAnnotationActions"
532
532
  }), ar = (t) => {
533
- const { children: e, ...i } = t, { message: r } = f(), { messageButtons: o } = b(), s = o[r.id] || [];
533
+ const { children: e, ...i } = t, { message: r } = M(), { messageButtons: o } = b(), s = o[r.id] || [];
534
534
  return /* @__PURE__ */ n(Kt, { children: k(e, s), ...i });
535
535
  }, qt = a("a", {
536
536
  _id: "aiChatMessageAnnotationAction"
@@ -574,11 +574,11 @@ const ot = "__intro__", st = a("div", {
574
574
  }), rr = (t) => {
575
575
  const { action: e, onClick: i, className: r, ...o } = t, { conversationId: s } = b(), {
576
576
  baseSettings: { onFeedback: c }
577
- } = p(), { message: d } = f(), { isStreaming: m, messages: l } = b(), [C, v] = J(), { feedback: u, submitPositiveFeedback: _, setCurrentFeedback: M, currentFeedback: A } = oe(), { logEvent: F } = me(), [w, le] = Ue(), K = l.at(-1)?.id === d?.id, q = d.role === "assistant";
577
+ } = p(), { message: d } = M(), { isStreaming: m, messages: l } = b(), [C, v] = J(), { feedback: u, submitPositiveFeedback: _, setCurrentFeedback: F, currentFeedback: A } = oe(), { logEvent: f } = me(), [w, le] = Ue(), K = l.at(-1)?.id === d?.id, q = d.role === "assistant";
578
578
  if (K && m || !q) return null;
579
579
  const D = {
580
580
  copy() {
581
- v(ve(d)), F({
581
+ v(ve(d)), f({
582
582
  eventName: "assistant_message_copied",
583
583
  properties: {
584
584
  conversationId: s
@@ -591,7 +591,7 @@ const ot = "__intro__", st = a("div", {
591
591
  });
592
592
  },
593
593
  downvote() {
594
- M(d.id);
594
+ F(d.id);
595
595
  }
596
596
  }, j = {
597
597
  copy: "Copy Message",
@@ -630,7 +630,7 @@ const ot = "__intro__", st = a("div", {
630
630
  }, Gt = a("div", {
631
631
  _id: "aiChatMessageSources"
632
632
  }), or = (t) => {
633
- const { message: e } = f();
633
+ const { message: e } = M();
634
634
  return e.role !== "assistant" || !e.parts.filter(
635
635
  (r) => r.type === "data-artifact" && r.data?.type?.toLowerCase() === be
636
636
  )?.length ? null : /* @__PURE__ */ n(Gt, { ...t });
@@ -639,7 +639,7 @@ const ot = "__intro__", st = a("div", {
639
639
  }), sr = (t) => /* @__PURE__ */ n(Yt, { children: "Sources", ...t }), Jt = a("div", {
640
640
  _id: "aiChatMessageSources__List"
641
641
  }), cr = (t) => {
642
- const { message: e } = f(), { children: i, ...r } = t, {
642
+ const { message: e } = M(), { children: i, ...r } = t, {
643
643
  baseSettings: { transformSource: o, organizationDisplayName: s },
644
644
  aiChatSettings: { shouldOpenLinksInNewTab: c },
645
645
  searchSettings: { tabs: d }
@@ -669,8 +669,8 @@ const ot = "__intro__", st = a("div", {
669
669
  })))(_, "chatSourceItem", {
670
670
  organizationDisplayName: s,
671
671
  tabs: d
672
- }), F = A.shouldOpenInNewTab !== void 0 ? A.shouldOpenInNewTab : c;
673
- return { ...A, isExternal: F };
672
+ }), f = A.shouldOpenInNewTab !== void 0 ? A.shouldOpenInNewTab : c;
673
+ return { ...A, isExternal: f };
674
674
  });
675
675
  return /* @__PURE__ */ n(Jt, { children: k(i, C), ...r });
676
676
  }, Xt = a(De, {
@@ -1050,7 +1050,7 @@ const ot = "__intro__", st = a("div", {
1050
1050
  }), ki = a(y.Trigger, {
1051
1051
  _id: "aiChat__ChatAction"
1052
1052
  }), _e = (t) => {
1053
- const { action: e, onClick: i, className: r, ...o } = t, s = {}, { clear: c, stop: d, isLoading: m, isStreaming: l, messages: C } = b(), { conversationId: v } = b(), { aiChatSettings: u } = p(), [_, M] = J(), [
1053
+ const { action: e, onClick: i, className: r, ...o } = t, s = {}, { clear: c, stop: d, isLoading: m, isStreaming: l, messages: C } = b(), { conversationId: v } = b(), { aiChatSettings: u } = p(), [_, F] = J(), [
1054
1054
  A
1055
1055
  /* copyShareUri */
1056
1056
  ] = J();
@@ -1076,7 +1076,7 @@ ${z}`;
1076
1076
  ---
1077
1077
 
1078
1078
  `);
1079
- M(he);
1079
+ F(he);
1080
1080
  },
1081
1081
  share: async () => {
1082
1082
  },
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),p=require("../atoms/shadow/context.cjs");function x(){const c=p.useShadow()?.shadowHost,r=s.useRef(""),t=s.useCallback(e=>{if(!c){console.warn("useStreamingEvents: No host element available for event emission");return}const n={...e,conversationId:r.current,timestamp:Date.now()},a=new CustomEvent("streaming-event",{detail:n,bubbles:!0,composed:!0});c.dispatchEvent(a)},[c]),d=s.useCallback(e=>{r.current=e},[]),u=s.useCallback(e=>{t({kind:"text:delta",data:{text:e}})},[t]),m=s.useCallback((e,n,a)=>{t({kind:"stream:error",data:{message:e,agent:n,severity:"error",code:a}})},[t]),k=s.useCallback((e,n)=>{t({kind:"agent:reasoning",data:{agentId:e,parts:n}})},[t]),g=s.useCallback((e,n,a)=>{t({kind:"agent:generate",data:{agentId:e,parts:n,generationType:a}})},[t]),b=s.useCallback((e,n,a,o,i,l)=>{t({kind:"tool:execution",data:{agentId:e,toolName:n,args:a,result:o,toolId:i,duration:l}})},[t]),v=s.useCallback((e,n,a,o)=>{t({kind:"agent:transfer",data:{fromAgent:e,targetAgent:n,reason:a,context:o}})},[t]),C=s.useCallback((e,n,a,o,i)=>{t({kind:"delegation:sent",data:{delegationId:e,fromAgent:n,targetAgent:a,taskDescription:o,context:i}})},[t]),f=s.useCallback((e,n,a,o)=>{t({kind:"delegation:returned",data:{delegationId:e,fromAgent:n,targetAgent:a,result:o}})},[t]),E=s.useCallback((e,n,a,o,i,l,w)=>{t({kind:"artifact:saved",data:{artifactId:e,taskId:n,toolCallId:a,artifactType:o,summaryData:i,fullData:l,metadata:w}})},[t]),S=s.useCallback((e,n)=>{t({kind:"completion",data:{agent:e,iteration:n}})},[t]),h=s.useCallback((e,n)=>{t({kind:"agent:initializing",data:{sessionId:e,graphId:n}})},[t]);return{emitEvent:t,setConversationId:d,emitTextDelta:u,emitStreamError:m,emitAgentReasoning:k,emitAgentGenerate:g,emitToolExecution:b,emitAgentTransfer:v,emitDelegationSent:C,emitDelegationReturned:f,emitArtifactSaved:E,emitCompletion:S,emitAgentInitializing:h}}exports.useStreamingEvents=x;
@@ -0,0 +1,140 @@
1
+ "use client";
2
+ import { useRef as x, useCallback as o } from "react";
3
+ import { useShadow as A } from "../atoms/shadow/context.js";
4
+ function R() {
5
+ const r = A()?.shadowHost, c = x(""), e = o(
6
+ (t) => {
7
+ if (!r) {
8
+ console.warn("useStreamingEvents: No host element available for event emission");
9
+ return;
10
+ }
11
+ const n = {
12
+ ...t,
13
+ conversationId: c.current,
14
+ timestamp: Date.now()
15
+ }, a = new CustomEvent("streaming-event", {
16
+ detail: n,
17
+ bubbles: !0,
18
+ // Allow event to bubble up
19
+ composed: !0
20
+ // Allow event to escape Shadow DOM boundary
21
+ });
22
+ r.dispatchEvent(a);
23
+ },
24
+ [r]
25
+ ), m = o((t) => {
26
+ c.current = t;
27
+ }, []), l = o(
28
+ (t) => {
29
+ e({
30
+ kind: "text:delta",
31
+ data: { text: t }
32
+ });
33
+ },
34
+ [e]
35
+ ), u = o(
36
+ (t, n, a) => {
37
+ e({
38
+ kind: "stream:error",
39
+ data: {
40
+ message: t,
41
+ agent: n,
42
+ severity: "error",
43
+ code: a
44
+ }
45
+ });
46
+ },
47
+ [e]
48
+ ), g = o(
49
+ (t, n) => {
50
+ e({
51
+ kind: "agent:reasoning",
52
+ data: { agentId: t, parts: n }
53
+ });
54
+ },
55
+ [e]
56
+ ), v = o(
57
+ (t, n, a) => {
58
+ e({
59
+ kind: "agent:generate",
60
+ data: { agentId: t, parts: n, generationType: a }
61
+ });
62
+ },
63
+ [e]
64
+ ), f = o(
65
+ (t, n, a, i, s, d) => {
66
+ e({
67
+ kind: "tool:execution",
68
+ data: { agentId: t, toolName: n, args: a, result: i, toolId: s, duration: d }
69
+ });
70
+ },
71
+ [e]
72
+ ), k = o(
73
+ (t, n, a, i) => {
74
+ e({
75
+ kind: "agent:transfer",
76
+ data: { fromAgent: t, targetAgent: n, reason: a, context: i }
77
+ });
78
+ },
79
+ [e]
80
+ ), E = o(
81
+ (t, n, a, i, s) => {
82
+ e({
83
+ kind: "delegation:sent",
84
+ data: { delegationId: t, fromAgent: n, targetAgent: a, taskDescription: i, context: s }
85
+ });
86
+ },
87
+ [e]
88
+ ), p = o(
89
+ (t, n, a, i) => {
90
+ e({
91
+ kind: "delegation:returned",
92
+ data: { delegationId: t, fromAgent: n, targetAgent: a, result: i }
93
+ });
94
+ },
95
+ [e]
96
+ ), h = o(
97
+ (t, n, a, i, s, d, b) => {
98
+ e({
99
+ kind: "artifact:saved",
100
+ data: { artifactId: t, taskId: n, toolCallId: a, artifactType: i, summaryData: s, fullData: d, metadata: b }
101
+ });
102
+ },
103
+ [e]
104
+ ), w = o(
105
+ (t, n) => {
106
+ e({
107
+ kind: "completion",
108
+ data: { agent: t, iteration: n }
109
+ });
110
+ },
111
+ [e]
112
+ ), S = o(
113
+ (t, n) => {
114
+ e({
115
+ kind: "agent:initializing",
116
+ data: { sessionId: t, graphId: n }
117
+ });
118
+ },
119
+ [e]
120
+ );
121
+ return {
122
+ emitEvent: e,
123
+ setConversationId: m,
124
+ // Convenience methods
125
+ emitTextDelta: l,
126
+ emitStreamError: u,
127
+ emitAgentReasoning: g,
128
+ emitAgentGenerate: v,
129
+ emitToolExecution: f,
130
+ emitAgentTransfer: k,
131
+ emitDelegationSent: E,
132
+ emitDelegationReturned: p,
133
+ emitArtifactSaved: h,
134
+ emitCompletion: w,
135
+ emitAgentInitializing: S
136
+ };
137
+ }
138
+ export {
139
+ R as useStreamingEvents
140
+ };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.14.8",componentType:n,tags:o}),[n,o]),u={logEvent:t.useCallback(async c=>{const v={...i,...c.properties,...r},d={eventName:c.eventName,properties:v};return s.onEvent?.(d)},[s,i,r])};return E.jsx(a.Provider,{value:u,children:e})},g=()=>{const e=t.useContext(a);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=p;exports.useBaseEvents=g;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.14.10",componentType:n,tags:o}),[n,o]),u={logEvent:t.useCallback(async c=>{const v={...i,...c.properties,...r},d={eventName:c.eventName,properties:v};return s.onEvent?.(d)},[s,i,r])};return E.jsx(a.Provider,{value:u,children:e})},g=()=>{const e=t.useContext(a);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=p;exports.useBaseEvents=g;
@@ -5,7 +5,7 @@ import { useInkeepConfig as g } from "./config-provider.js";
5
5
  const a = d(void 0), P = ({ children: e }) => {
6
6
  const { baseSettings: t, componentType: o } = g(), { tags: s, analyticsProperties: n } = t, r = u(
7
7
  () => ({
8
- widgetLibraryVersion: "0.14.8",
8
+ widgetLibraryVersion: "0.14.10",
9
9
  componentType: o,
10
10
  tags: s
11
11
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.14.9",
3
+ "version": "0.14.11",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {