@inkeep/agents-ui 0.15.4 → 0.15.5
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/atoms/markdown/index.cjs +1 -1
- package/dist/primitives/atoms/markdown/index.js +49 -44
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +13 -11
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react"),f=require("react-markdown"),M=require("rehype-raw"),y=require("remark-gfm"),g=require("remark-supersub"),b=require("../../providers/markdown-provider.cjs"),S=require("../codeblock/index.cjs"),n=require("./components.cjs"),q=require("./rehype-inline-code-property.cjs");const C=({children:c,componentStyles:h,shouldOpenLinksInNewTab:d,onLinkClick:l,onCodeCopy:m,artifacts:x,...j})=>{if(!c)return null;const p={h1:({children:r})=>e.jsx(n.MarkdownH1,{children:r}),h2:({children:r})=>e.jsx(n.MarkdownH2,{children:r}),p:({children:r})=>e.jsx(n.MarkdownP,{children:r}),li:({children:r})=>e.jsx(n.MarkdownLi,{children:r}),ul:({children:r})=>e.jsx(n.MarkdownUl,{children:r}),hr:()=>e.jsx(n.MarkdownHr,{}),input:({type:r,checked:s,disabled:t,readOnly:o,required:i,value:a})=>e.jsx(n.MarkdownInput,{type:r,checked:s,disabled:t,readOnly:o,required:i,value:a}),ol:({children:r,node:s})=>{const t=s?.properties?.start,o=typeof t=="number"?t:void 0;return e.jsx(n.MarkdownOl,{style:{"--start":t?.toString()??"0"},start:o,children:r})},a:({children:r,href:s})=>{const t=w.Children.toArray(r),o=t[0],i=typeof o=="string"&&/^\(\d+\)$/.test(o)&&t.length===1,a=i?o.match(/\d+/):r,u=e.jsx(n.MarkdownLink,{isExternal:d,href:s,onClick:()=>{l?.(s,a?.toString())},children:a});return i?e.jsx(n.MarkdownSourceLink,{children:u}):u},img:({src:r,alt:s})=>e.jsx(n.MarkdownImg,{src:r,alt:s}),table:({children:r})=>e.jsx(n.MarkdownTable,{children:r}),th:({children:r,isHeader:s})=>s?e.jsx(n.MarkdownTh,{children:r}):e.jsx(n.MarkdownTd,{children:r}),pre:({children:r})=>e.jsx("pre",{children:r}),code:({children:r,inline:s,className:t})=>s?e.jsx(n.MarkdownCode,{children:r}):e.jsx(S.CodeBlock,{className:t,onCopy:m,children:r}),sub:({children:r})=>typeof r=="string"&&(r.startsWith(" ")||r.endsWith(" "))?e.jsxs(e.Fragment,{children:["~",r,"~"]}):e.jsx("sub",{children:r}),sup:({children:r})=>{if(r&&typeof r=="string"){const s=x?.find(t=>(t.data?.artifactSummary?.title||t.data?.name)===r);if(s){const t=s.data,o=t?.artifactSummary?.url,i=t?.artifactSummary?.title||t?.name||r;return o?e.jsx(n.MarkdownSup,{children:e.jsx(n.MarkdownLink,{href:o,isExternal:d,onClick:()=>l?.(o,i),children:e.jsx("span",{children:i})})}):e.jsx(n.MarkdownSup,{children:e.jsx("span",{children:i})})}}return e.jsx("sup",{children:r})}},k=e.jsx(f,{remarkPlugins:[[y,{singleTilde:!1}],g],rehypePlugins:[M,q.rehypeInlineCodeProperty],components:p,disallowedElements:P,children:c.toString(),...j});return e.jsx(b.ChatMarkdownProvider,{componentStyles:h,children:k})},P=["script","iframe","frame","embed","meta","base","form","style","object"];exports.Markdown=C;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { ChatMarkdownProvider as
|
|
8
|
-
import { CodeBlock as
|
|
9
|
-
import { MarkdownSup as
|
|
1
|
+
import { jsx as t, jsxs as y, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import b from "react";
|
|
3
|
+
import S from "react-markdown";
|
|
4
|
+
import C from "rehype-raw";
|
|
5
|
+
import x from "remark-gfm";
|
|
6
|
+
import P from "remark-supersub";
|
|
7
|
+
import { ChatMarkdownProvider as j } from "../../providers/markdown-provider.js";
|
|
8
|
+
import { CodeBlock as E } from "../codeblock/index.js";
|
|
9
|
+
import { MarkdownSup as m, MarkdownLink as h, MarkdownCode as H, MarkdownTh as R, MarkdownTd as T, MarkdownTable as v, MarkdownImg as A, MarkdownSourceLink as I, MarkdownOl as W, MarkdownInput as _, MarkdownHr as B, MarkdownUl as D, MarkdownLi as F, MarkdownP as G, MarkdownH2 as L, MarkdownH1 as U } from "./components.js";
|
|
10
10
|
import { rehypeInlineCodeProperty as V } from "./rehype-inline-code-property.js";
|
|
11
|
-
const
|
|
11
|
+
const rr = ({
|
|
12
12
|
children: d,
|
|
13
|
-
componentStyles:
|
|
13
|
+
componentStyles: u,
|
|
14
14
|
shouldOpenLinksInNewTab: c,
|
|
15
15
|
onLinkClick: l,
|
|
16
|
-
onCodeCopy:
|
|
16
|
+
onCodeCopy: p,
|
|
17
17
|
artifacts: f,
|
|
18
18
|
...k
|
|
19
19
|
}) => {
|
|
20
20
|
if (!d) return null;
|
|
21
21
|
const w = {
|
|
22
|
-
h1: ({ children: r }) => /* @__PURE__ */
|
|
23
|
-
h2: ({ children: r }) => /* @__PURE__ */
|
|
24
|
-
p: ({ children: r }) => /* @__PURE__ */
|
|
25
|
-
li: ({ children: r }) => /* @__PURE__ */
|
|
26
|
-
ul: ({ children: r }) => /* @__PURE__ */
|
|
27
|
-
hr: () => /* @__PURE__ */
|
|
28
|
-
input: ({ type: r, checked: e, disabled:
|
|
29
|
-
|
|
22
|
+
h1: ({ children: r }) => /* @__PURE__ */ t(U, { children: r }),
|
|
23
|
+
h2: ({ children: r }) => /* @__PURE__ */ t(L, { children: r }),
|
|
24
|
+
p: ({ children: r }) => /* @__PURE__ */ t(G, { children: r }),
|
|
25
|
+
li: ({ children: r }) => /* @__PURE__ */ t(F, { children: r }),
|
|
26
|
+
ul: ({ children: r }) => /* @__PURE__ */ t(D, { children: r }),
|
|
27
|
+
hr: () => /* @__PURE__ */ t(B, {}),
|
|
28
|
+
input: ({ type: r, checked: e, disabled: n, readOnly: o, required: i, value: a }) => /* @__PURE__ */ t(
|
|
29
|
+
_,
|
|
30
30
|
{
|
|
31
31
|
type: r,
|
|
32
32
|
checked: e,
|
|
33
|
-
disabled:
|
|
33
|
+
disabled: n,
|
|
34
34
|
readOnly: o,
|
|
35
35
|
required: i,
|
|
36
36
|
value: a
|
|
37
37
|
}
|
|
38
38
|
),
|
|
39
39
|
ol: ({ children: r, node: e }) => {
|
|
40
|
-
const
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
|
|
40
|
+
const n = e?.properties?.start, o = typeof n == "number" ? n : void 0;
|
|
41
|
+
return /* @__PURE__ */ t(
|
|
42
|
+
W,
|
|
43
43
|
{
|
|
44
44
|
style: {
|
|
45
|
-
"--start":
|
|
45
|
+
"--start": n?.toString() ?? "0"
|
|
46
46
|
},
|
|
47
47
|
start: o,
|
|
48
48
|
children: r
|
|
@@ -50,7 +50,7 @@ const Z = ({
|
|
|
50
50
|
);
|
|
51
51
|
},
|
|
52
52
|
a: ({ children: r, href: e }) => {
|
|
53
|
-
const
|
|
53
|
+
const n = b.Children.toArray(r), o = n[0], i = typeof o == "string" && /^\(\d+\)$/.test(o) && n.length === 1, a = i ? o.match(/\d+/) : r, s = /* @__PURE__ */ t(
|
|
54
54
|
h,
|
|
55
55
|
{
|
|
56
56
|
isExternal: c,
|
|
@@ -61,45 +61,50 @@ const Z = ({
|
|
|
61
61
|
children: a
|
|
62
62
|
}
|
|
63
63
|
);
|
|
64
|
-
return i ? /* @__PURE__ */
|
|
64
|
+
return i ? /* @__PURE__ */ t(I, { children: s }) : s;
|
|
65
65
|
},
|
|
66
|
-
img: ({ src: r, alt: e }) => /* @__PURE__ */
|
|
67
|
-
table: ({ children: r }) => /* @__PURE__ */
|
|
68
|
-
th: ({ children: r, isHeader: e }) => e ? /* @__PURE__ */
|
|
69
|
-
pre: ({ children: r }) => /* @__PURE__ */
|
|
70
|
-
code: ({ children: r, inline: e, className:
|
|
66
|
+
img: ({ src: r, alt: e }) => /* @__PURE__ */ t(A, { src: r, alt: e }),
|
|
67
|
+
table: ({ children: r }) => /* @__PURE__ */ t(v, { children: r }),
|
|
68
|
+
th: ({ children: r, isHeader: e }) => e ? /* @__PURE__ */ t(R, { children: r }) : /* @__PURE__ */ t(T, { children: r }),
|
|
69
|
+
pre: ({ children: r }) => /* @__PURE__ */ t("pre", { children: r }),
|
|
70
|
+
code: ({ children: r, inline: e, className: n }) => e ? /* @__PURE__ */ t(H, { children: r }) : /* @__PURE__ */ t(E, { className: n, onCopy: p, children: r }),
|
|
71
|
+
sub: ({ children: r }) => typeof r == "string" && (r.startsWith(" ") || r.endsWith(" ")) ? /* @__PURE__ */ y(g, { children: [
|
|
72
|
+
"~",
|
|
73
|
+
r,
|
|
74
|
+
"~"
|
|
75
|
+
] }) : /* @__PURE__ */ t("sub", { children: r }),
|
|
71
76
|
sup: ({ children: r }) => {
|
|
72
77
|
if (r && typeof r == "string") {
|
|
73
78
|
const e = f?.find(
|
|
74
|
-
(
|
|
79
|
+
(n) => (n.data?.artifactSummary?.title || n.data?.name) === r
|
|
75
80
|
);
|
|
76
81
|
if (e) {
|
|
77
|
-
const
|
|
78
|
-
return o ? /* @__PURE__ */
|
|
82
|
+
const n = e.data, o = n?.artifactSummary?.url, i = n?.artifactSummary?.title || n?.name || r;
|
|
83
|
+
return o ? /* @__PURE__ */ t(m, { children: /* @__PURE__ */ t(
|
|
79
84
|
h,
|
|
80
85
|
{
|
|
81
86
|
href: o,
|
|
82
87
|
isExternal: c,
|
|
83
88
|
onClick: () => l?.(o, i),
|
|
84
|
-
children: /* @__PURE__ */
|
|
89
|
+
children: /* @__PURE__ */ t("span", { children: i })
|
|
85
90
|
}
|
|
86
|
-
) }) : /* @__PURE__ */
|
|
91
|
+
) }) : /* @__PURE__ */ t(m, { children: /* @__PURE__ */ t("span", { children: i }) });
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ t("sup", { children: r });
|
|
90
95
|
}
|
|
91
|
-
}, M = /* @__PURE__ */
|
|
92
|
-
|
|
96
|
+
}, M = /* @__PURE__ */ t(
|
|
97
|
+
S,
|
|
93
98
|
{
|
|
94
|
-
remarkPlugins: [
|
|
95
|
-
rehypePlugins: [
|
|
99
|
+
remarkPlugins: [[x, { singleTilde: !1 }], P],
|
|
100
|
+
rehypePlugins: [C, V],
|
|
96
101
|
components: w,
|
|
97
102
|
disallowedElements: $,
|
|
98
103
|
children: d.toString(),
|
|
99
104
|
...k
|
|
100
105
|
}
|
|
101
106
|
);
|
|
102
|
-
return /* @__PURE__ */
|
|
107
|
+
return /* @__PURE__ */ t(j, { componentStyles: u, children: M });
|
|
103
108
|
}, $ = [
|
|
104
109
|
"script",
|
|
105
110
|
"iframe",
|
|
@@ -112,5 +117,5 @@ const Z = ({
|
|
|
112
117
|
"object"
|
|
113
118
|
];
|
|
114
119
|
export {
|
|
115
|
-
|
|
120
|
+
rr as Markdown
|
|
116
121
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),E=require("./use-inkeep-chat.cjs");function L(f,u,d){const[p,D]=n.useState([]),[h,w]=n.useState(new Map),[
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),E=require("./use-inkeep-chat.cjs");function L(f,u,d){const[p,D]=n.useState([]),[h,w]=n.useState(new Map),[C,T]=n.useState(Date.now()),[A,y]=n.useState(!1),x=n.useRef(0),S=n.useRef(0),R=n.useRef([]),m=n.useRef(h);m.current=h;const b=n.useCallback(()=>{const t=[];let e="",a=[],i=!1;f.length>x.current&&(T(Date.now()),x.current=f.length),S.current=0;const c=new Map,l=(s=!1)=>{if(a.length>0){const r=`group-${S.current++}`,o=m.current.get(r);o?c.set(r,{...o,isCompleted:s}):c.set(r,{isCompleted:s}),t.push({type:"summary-group",summaries:[...a],groupKey:r}),a=[]}};for(const s of f)if(s.type==="text")l(!0),e+=s.text||"";else if(s.type==="data-summary")e.trim()&&(t.push({type:"text",text:e}),e=""),a.push(s.data);else if(s.type==="data-operation"){e.trim()&&(t.push({type:"text",text:e}),e="");const r=s.data;if(r?.type)switch(r.type){case"agent_initializing":break;case"completion":{const{type:o}=r;a.push({type:o,label:"Completed"}),l(!0);break}case"error":{const o=r.message||"Unknown error";if(console.warn("Data operation error:",o),!t.length)l(!0),d(new Error(o)),i||(t.push({type:"text",text:E.DEFAULT_ERROR_MESSAGE}),i=!0);else{const{type:g,label:v}=r;a.push({type:g,label:v})}break}default:{const{type:o,label:g}=r;a.push({type:o,label:g});break}}}else if(s.type==="data-artifact")if(s.data?.type?.toLowerCase()==="citation"){const r=s.data,o=r.artifactSummary||{title:r.name};e+=` ^${o?.title||r.name}^`}else e.trim()&&(t.push({type:"text",text:e}),e=""),t.push(s);else s.type==="data-component"&&(e.trim()&&(t.push({type:"text",text:e}),e=""),l(!0),t.push(s));return l(!u),e.trim()&&t.push({type:"text",text:e}),{processed:t,newTimings:c}},[f,u,d]);n.useEffect(()=>{if(R.current===f)return;R.current=f;const{processed:t,newTimings:e}=b();D(t),(e.size!==m.current.size||Array.from(e.entries()).some(([i,c])=>{const l=m.current.get(i);return!l||l.isCompleted!==c.isCompleted}))&&w(e)},[b,f]),n.useEffect(()=>{u||w(t=>{const e=new Map(t);let a=!1;for(const[i,c]of e.entries())c.isCompleted||(e.set(i,{...c,isCompleted:!0}),a=!0);return a?e:t})},[u]);const k=n.useCallback(()=>{const t=Date.now()-C,e=Array.from(m.current.values()).some(i=>!i.isCompleted),a=t>1e3&&!e;y(a)},[C]);n.useEffect(()=>{if(!u){y(!1);return}if(!(p.length>0)){y(!1);return}const e=setInterval(k,200);return()=>clearInterval(e)},[u,k,p.length]);const P=n.useMemo(()=>!!(!(p.length>0)&&u),[p.length,u]);return{processedParts:p,summaryTimings:h,shouldShowInitialLoading:P,shouldShowStreamDelayLoading:A}}exports.useStreamProcessor=L;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as m, useRef as h, useCallback as
|
|
2
|
+
import { useState as m, useRef as h, useCallback as L, useEffect as w, useMemo as z } from "react";
|
|
3
3
|
import { DEFAULT_ERROR_MESSAGE as G } from "./use-inkeep-chat.js";
|
|
4
4
|
function F(l, a, x) {
|
|
5
|
-
const [f,
|
|
5
|
+
const [f, R] = m([]), [y, C] = m(/* @__PURE__ */ new Map()), [D, v] = m(Date.now()), [M, g] = m(!1), S = h(0), A = h(0), T = h([]), p = h(y);
|
|
6
6
|
p.current = y;
|
|
7
|
-
const
|
|
7
|
+
const b = L(() => {
|
|
8
8
|
const e = [];
|
|
9
9
|
let t = "", n = [], i = !1;
|
|
10
10
|
l.length > S.current && (v(Date.now()), S.current = l.length), A.current = 0;
|
|
@@ -35,9 +35,11 @@ function F(l, a, x) {
|
|
|
35
35
|
switch (r.type) {
|
|
36
36
|
case "agent_initializing":
|
|
37
37
|
break;
|
|
38
|
-
case "completion":
|
|
39
|
-
|
|
38
|
+
case "completion": {
|
|
39
|
+
const { type: o } = r;
|
|
40
|
+
n.push({ type: o, label: "Completed" }), u(!0);
|
|
40
41
|
break;
|
|
42
|
+
}
|
|
41
43
|
case "error": {
|
|
42
44
|
const o = r.message || "Unknown error";
|
|
43
45
|
if (console.warn("Data operation error:", o), !e.length)
|
|
@@ -69,12 +71,12 @@ function F(l, a, x) {
|
|
|
69
71
|
if (T.current === l)
|
|
70
72
|
return;
|
|
71
73
|
T.current = l;
|
|
72
|
-
const { processed: e, newTimings: t } =
|
|
73
|
-
|
|
74
|
+
const { processed: e, newTimings: t } = b();
|
|
75
|
+
R(e), (t.size !== p.current.size || Array.from(t.entries()).some(([i, c]) => {
|
|
74
76
|
const u = p.current.get(i);
|
|
75
77
|
return !u || u.isCompleted !== c.isCompleted;
|
|
76
78
|
})) && C(t);
|
|
77
|
-
}, [
|
|
79
|
+
}, [b, l]), w(() => {
|
|
78
80
|
a || C((e) => {
|
|
79
81
|
const t = new Map(e);
|
|
80
82
|
let n = !1;
|
|
@@ -86,7 +88,7 @@ function F(l, a, x) {
|
|
|
86
88
|
return n ? t : e;
|
|
87
89
|
});
|
|
88
90
|
}, [a]);
|
|
89
|
-
const
|
|
91
|
+
const k = L(() => {
|
|
90
92
|
const e = Date.now() - D, t = Array.from(p.current.values()).some(
|
|
91
93
|
(i) => !i.isCompleted
|
|
92
94
|
), n = e > 1e3 && !t;
|
|
@@ -101,9 +103,9 @@ function F(l, a, x) {
|
|
|
101
103
|
g(!1);
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
|
-
const t = setInterval(
|
|
106
|
+
const t = setInterval(k, 200);
|
|
105
107
|
return () => clearInterval(t);
|
|
106
|
-
}, [a,
|
|
108
|
+
}, [a, k, f.length]);
|
|
107
109
|
const P = z(() => !!(!(f.length > 0) && a), [f.length, a]);
|
|
108
110
|
return {
|
|
109
111
|
processedParts: f,
|
|
@@ -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.4",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.4",
|
|
9
9
|
componentType: o,
|
|
10
10
|
tags: s
|
|
11
11
|
}),
|