@inkeep/agents-ui 0.15.9 → 0.15.10
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/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +85 -82
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/styled/components/data-summary-group.cjs +1 -1
- package/dist/styled/components/data-summary-group.js +70 -63
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +253 -144
- package/dist/styled/inkeep.css.cjs +67 -0
- package/dist/styled/inkeep.css.js +67 -0
- package/dist/types/config/components.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),L=require("./use-inkeep-chat.cjs");function M(l,u,C){const[p,k]=r.useState([]),[y,x]=r.useState(new Map),[w,A]=r.useState(Date.now()),[P,d]=r.useState(!1),S=r.useRef(0),D=r.useRef(0),R=r.useRef([]),m=r.useRef(y);m.current=y;const T=r.useCallback(()=>{const t=[];let e="",o=[],i=!1;l.length>S.current&&(A(Date.now()),S.current=l.length),D.current=0;const c=new Map,a=(n=!1)=>{if(o.length>0){const s=`group-${D.current++}`,h=m.current.get(s);h?c.set(s,{...h,isCompleted:n}):c.set(s,{isCompleted:n}),t.push({type:"summary-group",summaries:[...o],groupKey:s}),o=[]}};for(const n of l)if(n.type==="text")a(!0),e+=n.text||"";else if(n.type==="data-summary")e.trim()&&(t.push({type:"text",text:e}),e=""),o.push(n.data);else if(n.type==="data-operation"){e.trim()&&(t.push({type:"text",text:e}),e="");const s=n.data;if(s?.type){if((s.type==="tool_call"||s.type==="tool_result")&&s.details?.data?.inDelegatedAgent===!1)continue;switch(s.type){case"agent_initializing":break;case"completion":{const{type:f}=s;o.push({type:f,label:"Completed"}),a(!0);break}case"error":{const f=s.message||"Unknown error";if(console.warn("Data operation error:",f),!t.length)a(!0),C(new Error(f)),i||(t.push({type:"text",text:L.DEFAULT_ERROR_MESSAGE}),i=!0);else{const{type:g,label:E}=s;o.push({type:g,label:E})}break}default:{const{type:f,label:g}=s;o.push({type:f,label:g});break}}}}else if(n.type==="data-artifact")if(n.data?.type?.toLowerCase()==="citation"){const s=n.data,h=s.artifactSummary||{title:s.name};e+=` ^${h?.title||s.name}^`}else e.trim()&&(t.push({type:"text",text:e}),e=""),t.push(n);else n.type==="data-component"?(e.trim()&&(t.push({type:"text",text:e}),e=""),a(!0),t.push(n)):(e.trim()&&(t.push({type:"text",text:e}),e=""),a(!0),t.push(n));return a(!u),e.trim()&&t.push({type:"text",text:e}),{processed:t,newTimings:c}},[l,u,C]);r.useEffect(()=>{if(R.current===l)return;R.current=l;const{processed:t,newTimings:e}=T();k(t),(e.size!==m.current.size||Array.from(e.entries()).some(([i,c])=>{const a=m.current.get(i);return!a||a.isCompleted!==c.isCompleted}))&&x(e)},[T,l]),r.useEffect(()=>{u||x(t=>{const e=new Map(t);let o=!1;for(const[i,c]of e.entries())c.isCompleted||(e.set(i,{...c,isCompleted:!0}),o=!0);return o?e:t})},[u]);const b=r.useCallback(()=>{const t=Date.now()-w,e=Array.from(m.current.values()).some(i=>!i.isCompleted),o=t>1e3&&!e;d(o)},[w]);r.useEffect(()=>{if(!u){d(!1);return}if(!(p.length>0)){d(!1);return}const e=setInterval(b,200);return()=>clearInterval(e)},[u,b,p.length]);const v=r.useMemo(()=>!!(!(p.length>0)&&u),[p.length,u]);return{processedParts:p,summaryTimings:y,shouldShowInitialLoading:v,shouldShowStreamDelayLoading:P}}exports.useStreamProcessor=M;
|
|
@@ -1,101 +1,104 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as h, useRef as y, useCallback as R, useEffect as w, useMemo as z } from "react";
|
|
3
3
|
import { DEFAULT_ERROR_MESSAGE as G } from "./use-inkeep-chat.js";
|
|
4
|
-
function
|
|
5
|
-
const [p,
|
|
6
|
-
f.current =
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
...
|
|
16
|
-
isCompleted:
|
|
17
|
-
}) :
|
|
18
|
-
isCompleted:
|
|
19
|
-
}),
|
|
4
|
+
function K(c, a, C) {
|
|
5
|
+
const [p, v] = h([]), [d, D] = h(/* @__PURE__ */ new Map()), [T, M] = h(Date.now()), [P, g] = h(!1), A = y(0), S = y(0), b = y([]), f = y(d);
|
|
6
|
+
f.current = d;
|
|
7
|
+
const k = R(() => {
|
|
8
|
+
const t = [];
|
|
9
|
+
let e = "", r = [], i = !1;
|
|
10
|
+
c.length > A.current && (M(Date.now()), A.current = c.length), S.current = 0;
|
|
11
|
+
const u = /* @__PURE__ */ new Map(), o = (n = !1) => {
|
|
12
|
+
if (r.length > 0) {
|
|
13
|
+
const s = `group-${S.current++}`, m = f.current.get(s);
|
|
14
|
+
m ? u.set(s, {
|
|
15
|
+
...m,
|
|
16
|
+
isCompleted: n
|
|
17
|
+
}) : u.set(s, {
|
|
18
|
+
isCompleted: n
|
|
19
|
+
}), t.push({
|
|
20
20
|
type: "summary-group",
|
|
21
|
-
summaries: [...
|
|
22
|
-
groupKey:
|
|
23
|
-
}),
|
|
21
|
+
summaries: [...r],
|
|
22
|
+
groupKey: s
|
|
23
|
+
}), r = [];
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
for (const
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
else if (
|
|
30
|
-
|
|
31
|
-
else if (
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
26
|
+
for (const n of c)
|
|
27
|
+
if (n.type === "text")
|
|
28
|
+
o(!0), e += n.text || "";
|
|
29
|
+
else if (n.type === "data-summary")
|
|
30
|
+
e.trim() && (t.push({ type: "text", text: e }), e = ""), r.push(n.data);
|
|
31
|
+
else if (n.type === "data-operation") {
|
|
32
|
+
e.trim() && (t.push({ type: "text", text: e }), e = "");
|
|
33
|
+
const s = n.data;
|
|
34
|
+
if (s?.type) {
|
|
35
|
+
if ((s.type === "tool_call" || s.type === "tool_result") && s.details?.data?.inDelegatedAgent === !1)
|
|
36
|
+
continue;
|
|
37
|
+
switch (s.type) {
|
|
36
38
|
case "agent_initializing":
|
|
37
39
|
break;
|
|
38
40
|
case "completion": {
|
|
39
|
-
const { type:
|
|
40
|
-
|
|
41
|
+
const { type: l } = s;
|
|
42
|
+
r.push({ type: l, label: "Completed" }), o(!0);
|
|
41
43
|
break;
|
|
42
44
|
}
|
|
43
45
|
case "error": {
|
|
44
|
-
const
|
|
45
|
-
if (console.warn("Data operation error:",
|
|
46
|
-
|
|
46
|
+
const l = s.message || "Unknown error";
|
|
47
|
+
if (console.warn("Data operation error:", l), !t.length)
|
|
48
|
+
o(!0), C(new Error(l)), i || (t.push({ type: "text", text: G }), i = !0);
|
|
47
49
|
else {
|
|
48
|
-
const { type:
|
|
49
|
-
|
|
50
|
+
const { type: x, label: _ } = s;
|
|
51
|
+
r.push({ type: x, label: _ });
|
|
50
52
|
}
|
|
51
53
|
break;
|
|
52
54
|
}
|
|
53
55
|
default: {
|
|
54
|
-
const { type:
|
|
55
|
-
|
|
56
|
+
const { type: l, label: x } = s;
|
|
57
|
+
r.push({ type: l, label: x });
|
|
56
58
|
break;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
}
|
|
62
|
+
} else if (n.type === "data-artifact")
|
|
63
|
+
if (n.data?.type?.toLowerCase() === "citation") {
|
|
64
|
+
const s = n.data, m = s.artifactSummary || {
|
|
65
|
+
title: s.name
|
|
63
66
|
};
|
|
64
|
-
|
|
67
|
+
e += ` ^${m?.title || s.name}^`;
|
|
65
68
|
} else
|
|
66
|
-
|
|
67
|
-
else
|
|
68
|
-
return
|
|
69
|
-
}, [
|
|
70
|
-
|
|
71
|
-
if (
|
|
69
|
+
e.trim() && (t.push({ type: "text", text: e }), e = ""), t.push(n);
|
|
70
|
+
else n.type === "data-component" ? (e.trim() && (t.push({ type: "text", text: e }), e = ""), o(!0), t.push(n)) : (e.trim() && (t.push({ type: "text", text: e }), e = ""), o(!0), t.push(n));
|
|
71
|
+
return o(!a), e.trim() && t.push({ type: "text", text: e }), { processed: t, newTimings: u };
|
|
72
|
+
}, [c, a, C]);
|
|
73
|
+
w(() => {
|
|
74
|
+
if (b.current === c)
|
|
72
75
|
return;
|
|
73
|
-
|
|
74
|
-
const { processed:
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
return !
|
|
78
|
-
})) &&
|
|
79
|
-
}, [
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
let
|
|
83
|
-
for (const [
|
|
84
|
-
|
|
85
|
-
...
|
|
76
|
+
b.current = c;
|
|
77
|
+
const { processed: t, newTimings: e } = k();
|
|
78
|
+
v(t), (e.size !== f.current.size || Array.from(e.entries()).some(([i, u]) => {
|
|
79
|
+
const o = f.current.get(i);
|
|
80
|
+
return !o || o.isCompleted !== u.isCompleted;
|
|
81
|
+
})) && D(e);
|
|
82
|
+
}, [k, c]), w(() => {
|
|
83
|
+
a || D((t) => {
|
|
84
|
+
const e = new Map(t);
|
|
85
|
+
let r = !1;
|
|
86
|
+
for (const [i, u] of e.entries())
|
|
87
|
+
u.isCompleted || (e.set(i, {
|
|
88
|
+
...u,
|
|
86
89
|
isCompleted: !0
|
|
87
|
-
}),
|
|
88
|
-
return
|
|
90
|
+
}), r = !0);
|
|
91
|
+
return r ? e : t;
|
|
89
92
|
});
|
|
90
|
-
}, [
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
(
|
|
94
|
-
),
|
|
95
|
-
g(
|
|
96
|
-
}, [
|
|
97
|
-
|
|
98
|
-
if (!
|
|
93
|
+
}, [a]);
|
|
94
|
+
const L = R(() => {
|
|
95
|
+
const t = Date.now() - T, e = Array.from(f.current.values()).some(
|
|
96
|
+
(i) => !i.isCompleted
|
|
97
|
+
), r = t > 1e3 && !e;
|
|
98
|
+
g(r);
|
|
99
|
+
}, [T]);
|
|
100
|
+
w(() => {
|
|
101
|
+
if (!a) {
|
|
99
102
|
g(!1);
|
|
100
103
|
return;
|
|
101
104
|
}
|
|
@@ -103,17 +106,17 @@ function F(l, i, w) {
|
|
|
103
106
|
g(!1);
|
|
104
107
|
return;
|
|
105
108
|
}
|
|
106
|
-
const
|
|
107
|
-
return () => clearInterval(
|
|
108
|
-
}, [
|
|
109
|
-
const
|
|
109
|
+
const e = setInterval(L, 200);
|
|
110
|
+
return () => clearInterval(e);
|
|
111
|
+
}, [a, L, p.length]);
|
|
112
|
+
const E = z(() => !!(!(p.length > 0) && a), [p.length, a]);
|
|
110
113
|
return {
|
|
111
114
|
processedParts: p,
|
|
112
|
-
summaryTimings:
|
|
113
|
-
shouldShowInitialLoading:
|
|
114
|
-
shouldShowStreamDelayLoading:
|
|
115
|
+
summaryTimings: d,
|
|
116
|
+
shouldShowInitialLoading: E,
|
|
117
|
+
shouldShowStreamDelayLoading: P
|
|
115
118
|
};
|
|
116
119
|
}
|
|
117
120
|
export {
|
|
118
|
-
|
|
121
|
+
K as useStreamProcessor
|
|
119
122
|
};
|
|
@@ -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.15.
|
|
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.15.9",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.15.
|
|
8
|
+
widgetLibraryVersion: "0.15.9",
|
|
9
9
|
componentType: o,
|
|
10
10
|
tags: s
|
|
11
11
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("lucide-react"),r=require("../../primitives/components/data-summaries.cjs"),p=t=>{const{type:n,label:s}=t;return s||n.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())},u={agent_generate:e.jsx(a.RefreshCw,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_reasoning:e.jsx(a.Brain,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_call:e.jsx(a.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_result:e.jsx(a.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),transfer:e.jsx(a.ArrowRight,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_sent:e.jsx(a.Forward,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_returned:e.jsx(a.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),artifact_saved:e.jsx(a.Download,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),error:e.jsx(a.TriangleAlert,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_initializing:e.jsx(a.CircleDot,{className:"w-3 h-3 animate-spin"}),completion:e.jsx(a.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),default:e.jsx(a.Dot,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"})},h={retrieve:e.jsx(a.Search,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),action:e.jsx(a.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),...u},m=o.memo(({summary:t,showConnector:n})=>{const s=o.useMemo(()=>t.details&&Object.keys(t.details).length>0?JSON.stringify(t.details,null,2):null,[t.details]),i=o.useMemo(()=>p(t),[t]),c=o.useMemo(()=>h[t.type]||h.default,[t.type]);return e.jsxs(r.DataSummaryItem,{className:"flex items-start gap-2 text-xs relative",children:[n&&e.jsx(r.DataSummaryConnector,{className:"absolute left-1.5 top-4 bottom-0 w-px bg-gray-200 dark:bg-white-alpha-200 -mb-3"}),e.jsx(r.DataSummaryIconContainer,{className:"flex items-center justify-center w-3 h-3 relative z-10 mt-0.5",children:c}),e.jsxs(r.DataSummaryContent,{className:"flex-1",children:[e.jsx(r.DataSummaryLabel,{className:"text-gray-700 dark:text-white-alpha-600",children:i}),s&&e.jsx(r.DataSummaryDetails,{className:"mt-2 text-xs whitespace-pre-wrap font-mono bg-gray-50 dark:bg-gray-dark-900 p-2 rounded-md px-3 py-2",children:s})]})]})}),g=o.memo(({summaries:t,isCompleted:n})=>{const s=t.length>1,[i,c]=o.useState(!n||!s);o.useEffect(()=>{let l;return n&&s?l=setTimeout(()=>{c(!1)},1e3):c(!0),()=>{l&&clearTimeout(l)}},[n,s]);const d=o.useCallback(()=>{s&&c(!i)},[s,i]);return s?e.jsxs(r.DataSummaryGroup,{className:"flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative",children:[e.jsx(r.DataSummaryToggle,{type:"button",onClick:d,"data-expanded":i,className:"inline-flex items-center group gap-2 text-xs text-gray-500 dark:text-white-alpha-600 hover:text-gray-700 dark:hover:text-white-alpha-700 transition-colors cursor-pointer",children:n?e.jsxs(e.Fragment,{children:[e.jsx(a.Check,{className:"check-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 absolute opacity-100 group-hover:opacity-0 group-data-[expanded=true]:opacity-0"}),e.jsx(a.ChevronRight,{className:"chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90"}),e.jsx(r.DataSummaryToggleText,{className:"font-medium",children:"Completed"})]}):e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"w-3 h-3 animate-spin"}),e.jsx(r.DataSummaryToggleText,{className:"font-medium",children:"Thinking..."})]})}),e.jsx(r.DataSummaryCollapsible,{"data-expanded":i,className:"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",children:e.jsx(r.DataSummaryList,{className:"pb-2 mt-1.5 space-y-3 relative",children:t.map((l,x)=>e.jsx(m,{summary:l,showConnector:t.length>1&&x<t.length-1},`op-${l.type}-${x}`))})})]}):e.jsx(r.DataSummaryGroup,{className:"flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative",children:e.jsx(r.DataSummaryList,{className:"pb-2 mt-1.5 space-y-3 relative",children:t.map((l,x)=>e.jsx(m,{summary:l,showConnector:!1},`op-${l.type}-${x}`))})})});exports.DataSummaryGroup=g;
|
|
@@ -1,89 +1,96 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { memo as
|
|
4
|
-
import { Check as
|
|
5
|
-
import { DataSummaryGroup as
|
|
6
|
-
const
|
|
7
|
-
const { type:
|
|
8
|
-
return e ||
|
|
9
|
-
},
|
|
10
|
-
agent_generate: /* @__PURE__ */ a(
|
|
11
|
-
agent_reasoning: /* @__PURE__ */ a(
|
|
2
|
+
import { jsx as a, jsxs as n, Fragment as h } from "react/jsx-runtime";
|
|
3
|
+
import { memo as w, useState as N, useEffect as k, useCallback as D, useMemo as m } from "react";
|
|
4
|
+
import { Check as S, ChevronRight as v, LoaderCircle as b, CheckCheck as c, Search as C, Dot as P, CircleDot as _, TriangleAlert as T, Download as I, Forward as A, ArrowRight as L, Hammer as d, Brain as O, RefreshCw as E } from "lucide-react";
|
|
5
|
+
import { DataSummaryGroup as p, DataSummaryList as x, DataSummaryToggle as M, DataSummaryToggleText as g, DataSummaryCollapsible as R, DataSummaryItem as j, DataSummaryConnector as $, DataSummaryIconContainer as G, DataSummaryContent as z, DataSummaryLabel as F, DataSummaryDetails as U } from "../../primitives/components/data-summaries.js";
|
|
6
|
+
const B = (t) => {
|
|
7
|
+
const { type: i, label: e } = t;
|
|
8
|
+
return e || i.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
|
|
9
|
+
}, H = {
|
|
10
|
+
agent_generate: /* @__PURE__ */ a(E, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
11
|
+
agent_reasoning: /* @__PURE__ */ a(O, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
12
12
|
tool_call: /* @__PURE__ */ a(d, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
13
13
|
tool_result: /* @__PURE__ */ a(d, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
14
|
-
transfer: /* @__PURE__ */ a(
|
|
15
|
-
delegation_sent: /* @__PURE__ */ a(
|
|
16
|
-
delegation_returned: /* @__PURE__ */ a(
|
|
17
|
-
artifact_saved: /* @__PURE__ */ a(
|
|
18
|
-
error: /* @__PURE__ */ a(
|
|
19
|
-
agent_initializing: /* @__PURE__ */ a(
|
|
20
|
-
completion: /* @__PURE__ */ a(
|
|
21
|
-
default: /* @__PURE__ */ a(
|
|
22
|
-
},
|
|
23
|
-
retrieve: /* @__PURE__ */ a(
|
|
24
|
-
action: /* @__PURE__ */ a(
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
const e =
|
|
28
|
-
() =>
|
|
14
|
+
transfer: /* @__PURE__ */ a(L, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
15
|
+
delegation_sent: /* @__PURE__ */ a(A, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
16
|
+
delegation_returned: /* @__PURE__ */ a(c, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
17
|
+
artifact_saved: /* @__PURE__ */ a(I, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
18
|
+
error: /* @__PURE__ */ a(T, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
19
|
+
agent_initializing: /* @__PURE__ */ a(_, { className: "w-3 h-3 animate-spin" }),
|
|
20
|
+
completion: /* @__PURE__ */ a(c, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
21
|
+
default: /* @__PURE__ */ a(P, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" })
|
|
22
|
+
}, u = {
|
|
23
|
+
retrieve: /* @__PURE__ */ a(C, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
24
|
+
action: /* @__PURE__ */ a(c, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
25
|
+
...H
|
|
26
|
+
}, y = w(({ summary: t, showConnector: i }) => {
|
|
27
|
+
const e = m(() => t.details && Object.keys(t.details).length > 0 ? JSON.stringify(t.details, null, 2) : null, [t.details]), l = m(() => B(t), [t]), s = m(
|
|
28
|
+
() => u[t.type] || u.default,
|
|
29
29
|
[t.type]
|
|
30
30
|
);
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
|
|
33
|
-
/* @__PURE__ */ a(
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */ a(
|
|
36
|
-
e && /* @__PURE__ */ a(
|
|
31
|
+
return /* @__PURE__ */ n(j, { className: "flex items-start gap-2 text-xs relative", children: [
|
|
32
|
+
i && /* @__PURE__ */ a($, { className: "absolute left-1.5 top-4 bottom-0 w-px bg-gray-200 dark:bg-white-alpha-200 -mb-3" }),
|
|
33
|
+
/* @__PURE__ */ a(G, { className: "flex items-center justify-center w-3 h-3 relative z-10 mt-0.5", children: s }),
|
|
34
|
+
/* @__PURE__ */ n(z, { className: "flex-1", children: [
|
|
35
|
+
/* @__PURE__ */ a(F, { className: "text-gray-700 dark:text-white-alpha-600", children: l }),
|
|
36
|
+
e && /* @__PURE__ */ a(U, { className: "mt-2 text-xs whitespace-pre-wrap font-mono bg-gray-50 dark:bg-gray-dark-900 p-2 rounded-md px-3 py-2", children: e })
|
|
37
37
|
] })
|
|
38
38
|
] });
|
|
39
|
-
}),
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
let
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
}, 1e3) :
|
|
46
|
-
|
|
39
|
+
}), Q = w(({ summaries: t, isCompleted: i }) => {
|
|
40
|
+
const e = t.length > 1, [l, s] = N(!i || !e);
|
|
41
|
+
k(() => {
|
|
42
|
+
let r;
|
|
43
|
+
return i && e ? r = setTimeout(() => {
|
|
44
|
+
s(!1);
|
|
45
|
+
}, 1e3) : s(!0), () => {
|
|
46
|
+
r && clearTimeout(r);
|
|
47
47
|
};
|
|
48
|
-
}, [
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
}, [e]);
|
|
52
|
-
return /* @__PURE__ */
|
|
48
|
+
}, [i, e]);
|
|
49
|
+
const f = D(() => {
|
|
50
|
+
e && s(!l);
|
|
51
|
+
}, [e, l]);
|
|
52
|
+
return e ? /* @__PURE__ */ n(p, { className: "flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative", children: [
|
|
53
53
|
/* @__PURE__ */ a(
|
|
54
|
-
|
|
54
|
+
M,
|
|
55
55
|
{
|
|
56
56
|
type: "button",
|
|
57
|
-
onClick:
|
|
58
|
-
"data-expanded":
|
|
57
|
+
onClick: f,
|
|
58
|
+
"data-expanded": l,
|
|
59
59
|
className: "inline-flex items-center group gap-2 text-xs text-gray-500 dark:text-white-alpha-600 hover:text-gray-700 dark:hover:text-white-alpha-700 transition-colors cursor-pointer",
|
|
60
|
-
children:
|
|
61
|
-
/* @__PURE__ */ a(
|
|
62
|
-
/* @__PURE__ */ a(
|
|
63
|
-
/* @__PURE__ */ a(
|
|
64
|
-
] }) : /* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */ a(
|
|
66
|
-
/* @__PURE__ */ a(
|
|
60
|
+
children: i ? /* @__PURE__ */ n(h, { children: [
|
|
61
|
+
/* @__PURE__ */ a(S, { className: "check-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 absolute opacity-100 group-hover:opacity-0 group-data-[expanded=true]:opacity-0" }),
|
|
62
|
+
/* @__PURE__ */ a(v, { className: "chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90" }),
|
|
63
|
+
/* @__PURE__ */ a(g, { className: "font-medium", children: "Completed" })
|
|
64
|
+
] }) : /* @__PURE__ */ n(h, { children: [
|
|
65
|
+
/* @__PURE__ */ a(b, { className: "w-3 h-3 animate-spin" }),
|
|
66
|
+
/* @__PURE__ */ a(g, { className: "font-medium", children: "Thinking..." })
|
|
67
67
|
] })
|
|
68
68
|
}
|
|
69
69
|
),
|
|
70
70
|
/* @__PURE__ */ a(
|
|
71
|
-
|
|
71
|
+
R,
|
|
72
72
|
{
|
|
73
|
-
"data-expanded":
|
|
73
|
+
"data-expanded": l,
|
|
74
74
|
className: "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",
|
|
75
|
-
children: /* @__PURE__ */ a(
|
|
76
|
-
|
|
75
|
+
children: /* @__PURE__ */ a(x, { className: "pb-2 mt-1.5 space-y-3 relative", children: t.map((r, o) => /* @__PURE__ */ a(
|
|
76
|
+
y,
|
|
77
77
|
{
|
|
78
|
-
summary:
|
|
79
|
-
showConnector: t.length > 1 &&
|
|
78
|
+
summary: r,
|
|
79
|
+
showConnector: t.length > 1 && o < t.length - 1
|
|
80
80
|
},
|
|
81
|
-
`op-${
|
|
81
|
+
`op-${r.type}-${o}`
|
|
82
82
|
)) })
|
|
83
83
|
}
|
|
84
84
|
)
|
|
85
|
-
] })
|
|
85
|
+
] }) : /* @__PURE__ */ a(p, { className: "flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative", children: /* @__PURE__ */ a(x, { className: "pb-2 mt-1.5 space-y-3 relative", children: t.map((r, o) => /* @__PURE__ */ a(
|
|
86
|
+
y,
|
|
87
|
+
{
|
|
88
|
+
summary: r,
|
|
89
|
+
showConnector: !1
|
|
90
|
+
},
|
|
91
|
+
`op-${r.type}-${o}`
|
|
92
|
+
)) }) });
|
|
86
93
|
});
|
|
87
94
|
export {
|
|
88
|
-
|
|
95
|
+
Q as DataSummaryGroup
|
|
89
96
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),Q=require("../../primitives/providers/base-events-provider.cjs"),Y=require("../../primitives/providers/config-provider.cjs"),Z=require("../../primitives/providers/message-provider.cjs"),m=require("../../primitives/components/embedded-chat.cjs"),ee=require("../../primitives/components/embedded-chat/chat-provider.cjs"),te=require("merge-anything"),C=require("../utils.cjs"),ae=require("./ui/markdown-styles.cjs"),se=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),re=require("./data-summary-group.cjs"),o=require("react"),O=require("./embedded-chat.cjs"),n=require("lucide-react"),R=require("./ui/recipes/button.cjs"),ne={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function oe(t){if(!t||typeof t!="object")return!1;const r=t;return typeof r.type=="string"&&r.type.startsWith("tool-")}const ie=t=>{if(!t||typeof t!="object"||!("status"in t))return;const r=t.status;return typeof r=="string"?r:void 0},le=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(t=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${t*.2}s`},children:"."},t))}),z=({name:t,Icon:r,props:i,componentType:c})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(r,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:t})]}),e.jsx("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:c})]}),e.jsx("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)})]}),ce=({name:t,props:r})=>e.jsx(z,{name:t,Icon:n.ComponentIcon,props:r,componentType:"component"}),de=({name:t,props:r})=>e.jsx(z,{name:t,Icon:n.Library,props:r,componentType:"artifact"}),pe=({part:t,approve:r,isDebug:i=!1})=>{const c=t.type,k=c.startsWith("tool-")?c.slice(5):c,s=t.state,x=!!t.approval?.id,y=s==="approval-requested",N=ie(t.output),[h,S]=o.useState(x||!i),P=s?ne[s]??s:"tool";o.useEffect(()=>{y&&S(!0)},[y]);const v=()=>{switch(s){case"input-streaming":return e.jsx(n.Circle,{className:"w-3 h-3"});case"input-available":return e.jsx(n.Loader2,{className:"w-3 h-3 animate-spin"});case"approval-requested":return e.jsx(n.Clock,{className:"w-3 h-3"});case"approval-responded":return e.jsx(n.CheckCircle,{className:"w-3 h-3"});case"output-available":return e.jsx(n.CheckCircle,{className:"w-3 h-3"});case"output-error":return e.jsx(n.XCircle,{className:"w-3 h-3"});case"output-denied":return e.jsx(n.XCircle,{className:"w-3 h-3"});default:return null}};return e.jsxs("div",{className:"border rounded-lg mb-3 overflow-hidden",children:[i&&e.jsxs("button",{type:"button",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",onClick:()=>S(!h),"data-expanded":h,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(n.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:k})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("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:[v(),P]}),e.jsx(n.ChevronDown,{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"})]})]}),e.jsx("div",{"data-expanded":h,className:C.cn("relative",'before:content-[""] before:absolute before:inset-x-0 before:-top-px before:h-3 before:pointer-events-none before:z-10','after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',"before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]","dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]","data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"),children:e.jsxs("div",{"data-expanded":h,className:C.cn("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",x?"":"data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"),children:[t.input!=null&&i&&e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2",children:JSON.stringify(t.input,null,2)}),!i&&e.jsxs("div",{className:"whitespace-pre-wrap text-sm text-gray-700 dark:text-white-alpha-700 py-2",children:["Approval is needed to run ",e.jsx("strong",{children:k}),"."]}),y&&t.approval?.id&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{type:"button",className:C.cn(R.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>r(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:C.cn(R.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>r(!0),children:[e.jsx(n.Check,{className:"w-3 h-3"}),"Approve"]})]}),s==="output-available"&&t.output!=null&&!i&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize",children:[N==="approved"&&e.jsx(n.Check,{className:"w-3 h-3"}),N]}),s==="output-denied"&&!i&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize",children:[e.jsx(n.X,{className:"w-3 h-3"}),P]}),s==="output-available"&&t.output!=null&&i&&e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2",children:typeof t.output=="string"?t.output:JSON.stringify(t.output,null,2)})]})})]})},ue=({className:t,componentStyles:r,children:i,isLast:c,...k})=>{const{message:s}=Z.useMessage(),{logEvent:g}=Q.useBaseEvents(),{conversationId:x,isStreaming:y,isLoading:N,setError:h,addToolApprovalResponse:S,sendMessage:P}=ee.useChat(),{aiChatSettings:{components:v,artifacts:J,headers:X}}=Y.useInkeepConfig(),M=X?.["x-emit-operations"]==="true",B=s.role==="user",F=(y||N)&&c&&s.role==="assistant",{processedParts:G,summaryTimings:K,shouldShowInitialLoading:U,shouldShowStreamDelayLoading:W}=se.useStreamProcessor(s.parts,F,h),[w,I]=o.useState(null),[H,D]=o.useState(!1),d=o.useRef(null);o.useEffect(()=>{if(!w){D(!1),d.current&&(clearTimeout(d.current),d.current=null);return}return D(!1),d.current&&clearTimeout(d.current),d.current=window.setTimeout(()=>{D(!0)},1e3),()=>{d.current&&(clearTimeout(d.current),d.current=null)}},[w]),o.useEffect(()=>{w&&(!c||s.parts.length>w.partCount)&&I(null)},[w,c,s.parts.length]);const A=o.useMemo(()=>s.parts.filter(a=>a.type==="data-artifact"&&a.data?.type?.toLowerCase()==="citation"),[s.parts]),L=o.useMemo(()=>te.merge(ae.markdownStyles,r??{}),[r]),_=o.useCallback((a,l)=>{g({eventName:"assistant_message_inline_link_opened",properties:{title:l?.toString(),url:a}})},[g]),$=o.useCallback((a,l)=>{g({eventName:"assistant_code_block_copied",properties:{conversationId:x,language:a,code:l}})},[g,x]),q=o.useCallback(a=>e.jsx(m.EmbeddedChatPrimitiveMarkdown,{text:a,componentStyles:L,onLinkClick:_,onCodeCopy:$,artifacts:A}),[L,_,$,A]),V=o.useMemo(()=>C.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",t),[t]);return e.jsxs(e.Fragment,{children:[G.map((a,l)=>{const f={"data-role":s.role,"data-type":a?.type==="data-component"?a.data.type:a?.type,...k,className:V};switch(a?.type){case"text":return e.jsx(m.PrimitiveMessagePart,{...f,children:B?a.text:q(a.text||"")},l);case"data-component":{const{type:p}=a.data;switch(p){case"text":return e.jsx("div",{...f,children:q(a.data.text||"")},l);default:{const T=a.data,{name:u,props:b}=T,j=v?.[u],E=j?m.EmbeddedChatPrimitiveDynamicComponent:ce;return e.jsx(m.PrimitiveMessagePart,{...f,children:e.jsx(E,{name:u,props:b,componentDef:j})},`${u}-${l}`)}}}case"data-artifact":{const p=a.data,{name:T,type:u,artifactSummary:b}=p,j=J?.[u],E=j?m.EmbeddedChatPrimitiveDynamicComponent:de;return e.jsx(m.PrimitiveMessagePart,{...f,children:e.jsx(E,{name:u,props:b,componentDef:j})},`${T}-${l}`)}case"summary-group":{const p=K.get(a.groupKey)||{isCompleted:!1};return e.jsx(m.PrimitiveMessagePart,{...f,children:e.jsx(re.DataSummaryGroup,{summaries:a.summaries||[],isCompleted:p.isCompleted})},`${a.groupKey}-${l}`)}default:if(oe(a)){const p=a.approval?.id;if(!(M||p))return null;const u=async(b=!0)=>{p&&(I({partCount:s.parts.length}),S({id:p,approved:b}),await P(void 0,{body:{conversationId:x}}))};return e.jsx(m.PrimitiveMessagePart,{...f,children:v?.IkpTool?e.jsx(O.DynamicComponent,{name:"IkpTool",props:{tool:a,approve:u,renderMarkdown:q},componentDef:v.IkpTool}):e.jsx(pe,{part:a,approve:u,isDebug:M})},a.toolCallId??`${a.type}-${l}`)}return null}}),U&&e.jsx(O.MessageLoading,{}),(W||H)&&e.jsx(le,{})]})};exports.EmbeddedChatMessagePart=ue;
|