@inkeep/agents-ui 0.15.11 → 0.15.13
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/index.cjs +1 -1
- package/dist/index.js +171 -169
- package/dist/primitives/atoms/combobox.cjs +1 -0
- package/dist/primitives/atoms/combobox.js +275 -0
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +74 -87
- package/dist/primitives/components/embedded-chat.cjs +4 -4
- package/dist/primitives/components/embedded-chat.d.ts +22 -1
- package/dist/primitives/components/embedded-chat.js +1249 -1137
- package/dist/primitives/hooks/use-simple-scroll.cjs +1 -1
- package/dist/primitives/hooks/use-simple-scroll.d.ts +12 -1
- package/dist/primitives/hooks/use-simple-scroll.js +45 -12
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/primitives/utils/component-ids.cjs +1 -1
- package/dist/primitives/utils/component-ids.d.ts +24 -0
- package/dist/primitives/utils/component-ids.js +12 -0
- package/dist/primitives/utils/form.cjs +1 -1
- package/dist/primitives/utils/form.d.ts +1 -1
- package/dist/primitives/utils/form.js +3 -1
- package/dist/react/chat-button-modal.cjs +1 -0
- package/dist/react/chat-button-modal.d.ts +22 -0
- package/dist/react/chat-button-modal.js +41 -0
- package/dist/react/embedded-chat.cjs +1 -1
- package/dist/react/embedded-chat.js +210 -191
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +171 -169
- package/dist/styled/components/embedded-chat.cjs +1 -1
- package/dist/styled/components/embedded-chat.d.ts +16 -1
- package/dist/styled/components/embedded-chat.js +686 -568
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +191 -183
- package/dist/styled/components/ui/recipes/combobox.cjs +1 -0
- package/dist/styled/components/ui/recipes/combobox.d.ts +4 -0
- package/dist/styled/components/ui/recipes/combobox.js +57 -0
- package/dist/styled/components/ui/recipes/index.cjs +1 -1
- package/dist/styled/components/ui/recipes/index.d.ts +1 -0
- package/dist/styled/components/ui/recipes/index.js +29 -27
- package/dist/styled/components/ui/recipes/modal.d.ts +1 -1
- package/dist/styled/components/ui/recipes/scrollable.d.ts +1 -1
- package/dist/styled/components/ui/recipes/select.d.ts +1 -1
- package/dist/styled/inkeep.css.cjs +182 -2
- package/dist/styled/inkeep.css.js +182 -2
- package/dist/types/config/settings/form.d.ts +9 -1
- package/package.json +6 -5
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as c, Fragment as O, jsxs as M } from "react/jsx-runtime";
|
|
3
|
+
import * as f from "@zag-js/combobox";
|
|
4
|
+
import { useMachine as j, normalizeProps as B } from "@zag-js/react";
|
|
5
|
+
import * as r from "react";
|
|
6
|
+
import { useId as q } from "react";
|
|
7
|
+
import { BuiltInIconRenderer as I } from "./icons/built-in-icon-renderer.js";
|
|
8
|
+
import { useShadow as z } from "./shadow/context.js";
|
|
9
|
+
const A = r.forwardRef((o, a) => {
|
|
10
|
+
const {
|
|
11
|
+
children: t,
|
|
12
|
+
defaultValue: e = [],
|
|
13
|
+
items: n,
|
|
14
|
+
multiple: s = !1,
|
|
15
|
+
placeholder: l,
|
|
16
|
+
name: b,
|
|
17
|
+
disabled: P,
|
|
18
|
+
required: v,
|
|
19
|
+
id: w,
|
|
20
|
+
onValueChange: R
|
|
21
|
+
} = o, y = q(), N = w ?? y, T = z(), [p, h] = r.useState(n), L = r.useMemo(
|
|
22
|
+
() => f.collection({
|
|
23
|
+
items: p,
|
|
24
|
+
itemToValue: (i) => i.value,
|
|
25
|
+
itemToString: (i) => i.label
|
|
26
|
+
}),
|
|
27
|
+
[p]
|
|
28
|
+
), V = j(f.machine, {
|
|
29
|
+
id: N,
|
|
30
|
+
collection: L,
|
|
31
|
+
defaultValue: e,
|
|
32
|
+
multiple: s,
|
|
33
|
+
placeholder: l,
|
|
34
|
+
name: b,
|
|
35
|
+
disabled: P,
|
|
36
|
+
required: v,
|
|
37
|
+
openOnClick: !0,
|
|
38
|
+
getRootNode: () => T?.shadowHost?.shadowRoot ?? document,
|
|
39
|
+
selectionBehavior: s ? "clear" : "replace",
|
|
40
|
+
onOpenChange(i) {
|
|
41
|
+
i.open || h(n);
|
|
42
|
+
},
|
|
43
|
+
onInputValueChange(i) {
|
|
44
|
+
const g = i.inputValue.trim() === "" ? n : n.filter(
|
|
45
|
+
(E) => E.label.toLowerCase().includes(i.inputValue.toLowerCase())
|
|
46
|
+
);
|
|
47
|
+
h(g.length > 0 ? g : []);
|
|
48
|
+
},
|
|
49
|
+
onValueChange(i) {
|
|
50
|
+
R?.(i);
|
|
51
|
+
}
|
|
52
|
+
}), u = f.connect(
|
|
53
|
+
V,
|
|
54
|
+
B
|
|
55
|
+
), S = r.useMemo(() => ({ api: u, options: p }), [u, p]), k = u.getRootProps();
|
|
56
|
+
return /* @__PURE__ */ c("div", { "data-scope": "combobox", "data-part": "root", ...k, children: /* @__PURE__ */ c(C.Provider, { value: S, children: t }) });
|
|
57
|
+
});
|
|
58
|
+
A.displayName = "ComboboxRoot";
|
|
59
|
+
const D = r.forwardRef((o, a) => {
|
|
60
|
+
const { children: t, ...e } = o, n = d(), s = n.getControlProps();
|
|
61
|
+
return /* @__PURE__ */ c(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
"data-scope": "combobox",
|
|
65
|
+
"data-part": "control",
|
|
66
|
+
"data-state": n.open ? "open" : "closed",
|
|
67
|
+
"data-disabled": n.disabled ? "" : void 0,
|
|
68
|
+
"data-focus": n.focused ? "" : void 0,
|
|
69
|
+
...s,
|
|
70
|
+
ref: m(a, s.ref),
|
|
71
|
+
...e,
|
|
72
|
+
children: t
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
D.displayName = "ComboboxControl";
|
|
77
|
+
function m(...o) {
|
|
78
|
+
return (a) => {
|
|
79
|
+
o.forEach((t) => {
|
|
80
|
+
typeof t == "function" ? t(a) : t && (t.current = a);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const F = r.forwardRef((o, a) => {
|
|
85
|
+
const t = d(), e = t.getInputProps();
|
|
86
|
+
return /* @__PURE__ */ c(
|
|
87
|
+
"input",
|
|
88
|
+
{
|
|
89
|
+
"data-scope": "combobox",
|
|
90
|
+
"data-part": "input",
|
|
91
|
+
"data-state": t.open ? "open" : "closed",
|
|
92
|
+
...e,
|
|
93
|
+
...o,
|
|
94
|
+
ref: m(a, e.ref)
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
F.displayName = "ComboboxInput";
|
|
99
|
+
const H = r.forwardRef((o, a) => {
|
|
100
|
+
const t = d(), e = t.getTriggerProps();
|
|
101
|
+
return /* @__PURE__ */ c(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
type: "button",
|
|
105
|
+
"data-scope": "combobox",
|
|
106
|
+
"data-part": "trigger",
|
|
107
|
+
"data-state": t.open ? "open" : "closed",
|
|
108
|
+
"data-disabled": t.disabled ? "" : void 0,
|
|
109
|
+
...e,
|
|
110
|
+
ref: m(a, e.ref),
|
|
111
|
+
...o,
|
|
112
|
+
children: o.children ?? "▼"
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
H.displayName = "ComboboxTrigger";
|
|
117
|
+
const ao = r.forwardRef(
|
|
118
|
+
function(a, t) {
|
|
119
|
+
const e = d();
|
|
120
|
+
return /* @__PURE__ */ c("div", { ref: t, ...e.getPositionerProps(), ...a });
|
|
121
|
+
}
|
|
122
|
+
), _ = r.forwardRef((o, a) => {
|
|
123
|
+
const t = d(), e = t.getContentProps();
|
|
124
|
+
return /* @__PURE__ */ c(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
"data-scope": "combobox",
|
|
128
|
+
"data-part": "content",
|
|
129
|
+
"data-state": t.open ? "open" : "closed",
|
|
130
|
+
...e,
|
|
131
|
+
ref: m(a, e.ref),
|
|
132
|
+
...o,
|
|
133
|
+
children: o.children
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
_.displayName = "ComboboxContent";
|
|
138
|
+
const $ = r.forwardRef((o, a) => {
|
|
139
|
+
const e = d().getListProps();
|
|
140
|
+
return /* @__PURE__ */ c(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
ref: m(a, e.ref),
|
|
144
|
+
"data-scope": "combobox",
|
|
145
|
+
"data-part": "list",
|
|
146
|
+
...e,
|
|
147
|
+
...o,
|
|
148
|
+
children: o.children
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
$.displayName = "ComboboxList";
|
|
153
|
+
const G = ({ children: o }) => {
|
|
154
|
+
const a = W();
|
|
155
|
+
return /* @__PURE__ */ c(O, { children: o(a) });
|
|
156
|
+
};
|
|
157
|
+
G.displayName = "ComboboxListItems";
|
|
158
|
+
const J = r.forwardRef((o, a) => {
|
|
159
|
+
const { children: t = "No results found", ...e } = o;
|
|
160
|
+
return /* @__PURE__ */ c("div", { ref: a, "data-scope": "combobox", "data-part": "list-empty", ...e, children: t });
|
|
161
|
+
});
|
|
162
|
+
J.displayName = "ComboboxListEmpty";
|
|
163
|
+
const x = r.createContext(null), K = r.forwardRef((o, a) => {
|
|
164
|
+
const { item: t, ...e } = o, n = d(), s = n.getItemState({ item: t }), l = n.getItemProps({ item: t });
|
|
165
|
+
return /* @__PURE__ */ c(x.Provider, { value: t, children: /* @__PURE__ */ c(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
ref: m(a, l.ref),
|
|
169
|
+
"data-scope": "combobox",
|
|
170
|
+
"data-part": "item",
|
|
171
|
+
"data-value": t.value,
|
|
172
|
+
"data-highlighted": s.highlighted ? "" : void 0,
|
|
173
|
+
"data-state": s.selected ? "checked" : "unchecked",
|
|
174
|
+
"data-disabled": s.disabled ? "" : void 0,
|
|
175
|
+
...l,
|
|
176
|
+
...e,
|
|
177
|
+
children: o.children
|
|
178
|
+
}
|
|
179
|
+
) });
|
|
180
|
+
});
|
|
181
|
+
K.displayName = "ComboboxItem";
|
|
182
|
+
const Q = r.forwardRef((o, a) => {
|
|
183
|
+
const t = r.useContext(x), e = d(), n = t ? e.getItemTextProps({ item: t }) : {};
|
|
184
|
+
return /* @__PURE__ */ c(
|
|
185
|
+
"span",
|
|
186
|
+
{
|
|
187
|
+
ref: m(a, n.ref),
|
|
188
|
+
"data-scope": "combobox",
|
|
189
|
+
"data-part": "item-text",
|
|
190
|
+
...n,
|
|
191
|
+
...o
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
Q.displayName = "ComboboxItemText";
|
|
196
|
+
const U = r.forwardRef(
|
|
197
|
+
(o, a) => {
|
|
198
|
+
const { children: t, ...e } = o, n = r.useContext(x), s = d(), l = n ? s.getItemState({ item: n }) : { selected: !1 }, b = n ? s.getItemIndicatorProps({ item: n }) : {};
|
|
199
|
+
return l.selected ? /* @__PURE__ */ c(
|
|
200
|
+
"span",
|
|
201
|
+
{
|
|
202
|
+
ref: m(a, b.ref),
|
|
203
|
+
"data-scope": "combobox",
|
|
204
|
+
"data-part": "item-indicator",
|
|
205
|
+
"data-state": "checked",
|
|
206
|
+
"aria-hidden": !0,
|
|
207
|
+
...b,
|
|
208
|
+
...e,
|
|
209
|
+
children: t ?? /* @__PURE__ */ c(I, { iconSettings: { builtIn: "LuCheck" } })
|
|
210
|
+
}
|
|
211
|
+
) : null;
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
U.displayName = "ComboboxItemIndicator";
|
|
215
|
+
const C = r.createContext(
|
|
216
|
+
null
|
|
217
|
+
);
|
|
218
|
+
function d() {
|
|
219
|
+
const o = r.useContext(C);
|
|
220
|
+
if (!o) throw new Error("Combobox components must be used within ComboboxRoot");
|
|
221
|
+
return o.api;
|
|
222
|
+
}
|
|
223
|
+
function W() {
|
|
224
|
+
const o = r.useContext(C);
|
|
225
|
+
if (!o) throw new Error("Combobox components must be used within ComboboxRoot");
|
|
226
|
+
return o.options;
|
|
227
|
+
}
|
|
228
|
+
const X = r.forwardRef(
|
|
229
|
+
(o, a) => {
|
|
230
|
+
const t = d(), e = t.selectedItems ?? [], n = t.clearValue;
|
|
231
|
+
return e.length === 0 ? null : /* @__PURE__ */ c(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
ref: a,
|
|
235
|
+
"data-scope": "combobox",
|
|
236
|
+
"data-part": "selected-tags",
|
|
237
|
+
className: o.className,
|
|
238
|
+
style: o.style,
|
|
239
|
+
children: e.map((s) => /* @__PURE__ */ M("span", { "data-scope": "combobox", "data-part": "tag", children: [
|
|
240
|
+
o.renderTag ? o.renderTag(s) : s.label,
|
|
241
|
+
/* @__PURE__ */ c(
|
|
242
|
+
"button",
|
|
243
|
+
{
|
|
244
|
+
type: "button",
|
|
245
|
+
"data-part": "tag-clear",
|
|
246
|
+
"aria-label": `Remove ${s.label}`,
|
|
247
|
+
onClick: (l) => {
|
|
248
|
+
l.preventDefault(), l.stopPropagation(), n?.(s.value);
|
|
249
|
+
},
|
|
250
|
+
children: /* @__PURE__ */ c(I, { iconSettings: { builtIn: "IoCloseOutline" } })
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
] }, s.value))
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
X.displayName = "ComboboxSelectedTags";
|
|
259
|
+
export {
|
|
260
|
+
_ as ComboboxContent,
|
|
261
|
+
D as ComboboxControl,
|
|
262
|
+
F as ComboboxInput,
|
|
263
|
+
K as ComboboxItem,
|
|
264
|
+
U as ComboboxItemIndicator,
|
|
265
|
+
Q as ComboboxItemText,
|
|
266
|
+
$ as ComboboxList,
|
|
267
|
+
J as ComboboxListEmpty,
|
|
268
|
+
G as ComboboxListItems,
|
|
269
|
+
ao as ComboboxPositioner,
|
|
270
|
+
A as ComboboxRoot,
|
|
271
|
+
X as ComboboxSelectedTags,
|
|
272
|
+
H as ComboboxTrigger,
|
|
273
|
+
d as useComboboxApi,
|
|
274
|
+
W as useComboboxOptions
|
|
275
|
+
};
|
|
@@ -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 n=require("react"),A=require("./use-inkeep-chat.cjs");function E(m,u,S){const[T,d]=n.useState(!1),x=n.useRef(0),C=n.useRef(0),w=n.useRef(Date.now()),c=n.useRef(new Map),h=n.useRef(null),{processedParts:p,summaryTimings:b}=n.useMemo(()=>{const s=[];let e="",o=[],y=!1;m.length>x.current&&(w.current=Date.now(),x.current=m.length),C.current=0;const i=new Map,l=(r=!1)=>{if(o.length>0){const t=`group-${C.current++}`,a=c.current.get(t);a?i.set(t,{...a,isCompleted:r}):i.set(t,{isCompleted:r}),s.push({type:"summary-group",summaries:[...o],groupKey:t}),o=[]}};for(const r of m)if(r.type==="text")l(!0),e+=r.text||"";else if(r.type==="data-summary")e.trim()&&(s.push({type:"text",text:e}),e=""),o.push(r.data);else if(r.type==="data-operation"){e.trim()&&(s.push({type:"text",text:e}),e="");const t=r.data;if(t?.type){if((t.type==="tool_call"||t.type==="tool_result")&&t.details?.data?.inDelegatedAgent===!1)continue;switch(t.type){case"agent_initializing":break;case"completion":{const{type:f}=t;o.push({type:f,label:"Completed"}),l(!0);break}case"error":{const f=t.message||"Unknown error";if(console.warn("Data operation error:",f),!s.length)l(!0),h.current=f,y||(s.push({type:"text",text:A.DEFAULT_ERROR_MESSAGE}),y=!0);else{const{type:g,label:v}=t;o.push({type:g,label:v})}break}default:{const{type:f,label:g}=t;o.push({type:f,label:g});break}}}}else if(r.type==="data-artifact")if(r.data?.type?.toLowerCase()==="citation"){const t=r.data,a=t.artifactSummary||{title:t.name};e+=` ^${a?.title||t.name}^`}else e.trim()&&(s.push({type:"text",text:e}),e=""),s.push(r);else r.type==="data-component"?(e.trim()&&(s.push({type:"text",text:e}),e=""),l(!0),s.push(r)):(e.trim()&&(s.push({type:"text",text:e}),e=""),l(!0),s.push(r));if(l(!u),e.trim()&&s.push({type:"text",text:e}),!u)for(const[r,t]of i.entries())t.isCompleted||i.set(r,{...t,isCompleted:!0});const D=i.size!==c.current.size||Array.from(i.entries()).some(([r,t])=>{const a=c.current.get(r);return!a||a.isCompleted!==t.isCompleted})?i:c.current;return c.current=D,{processedParts:s,summaryTimings:D}},[m,u]);n.useEffect(()=>{h.current&&(S(new Error(h.current)),h.current=null)});const R=n.useCallback(()=>{const s=Date.now()-w.current,e=Array.from(c.current.values()).some(y=>!y.isCompleted),o=s>1e3&&!e;d(o)},[]);n.useEffect(()=>{if(!u){d(!1);return}if(!(p.length>0)){d(!1);return}const e=setInterval(R,200);return()=>clearInterval(e)},[u,R,p.length]);const k=n.useMemo(()=>!!(!(p.length>0)&&u),[p.length,u]);return{processedParts:p,summaryTimings:b,shouldShowInitialLoading:k,shouldShowStreamDelayLoading:T}}exports.useStreamProcessor=E;
|
|
@@ -1,122 +1,109 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { DEFAULT_ERROR_MESSAGE as
|
|
4
|
-
function
|
|
5
|
-
const [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
isCompleted:
|
|
17
|
-
})
|
|
18
|
-
isCompleted: n
|
|
19
|
-
}), t.push({
|
|
2
|
+
import { useState as L, useRef as f, useMemo as S, useEffect as k, useCallback as M } from "react";
|
|
3
|
+
import { DEFAULT_ERROR_MESSAGE as _ } from "./use-inkeep-chat.js";
|
|
4
|
+
function I(m, a, A) {
|
|
5
|
+
const [R, d] = L(!1), x = f(0), C = f(0), w = f(Date.now()), u = f(/* @__PURE__ */ new Map()), h = f(null), { processedParts: p, summaryTimings: b } = S(() => {
|
|
6
|
+
const n = [];
|
|
7
|
+
let e = "", s = [], y = !1;
|
|
8
|
+
m.length > x.current && (w.current = Date.now(), x.current = m.length), C.current = 0;
|
|
9
|
+
const i = /* @__PURE__ */ new Map(), l = (r = !1) => {
|
|
10
|
+
if (s.length > 0) {
|
|
11
|
+
const t = `group-${C.current++}`, o = u.current.get(t);
|
|
12
|
+
o ? i.set(t, {
|
|
13
|
+
...o,
|
|
14
|
+
isCompleted: r
|
|
15
|
+
}) : i.set(t, {
|
|
16
|
+
isCompleted: r
|
|
17
|
+
}), n.push({
|
|
20
18
|
type: "summary-group",
|
|
21
|
-
summaries: [...
|
|
22
|
-
groupKey:
|
|
23
|
-
}),
|
|
19
|
+
summaries: [...s],
|
|
20
|
+
groupKey: t
|
|
21
|
+
}), s = [];
|
|
24
22
|
}
|
|
25
23
|
};
|
|
26
|
-
for (const
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
else if (
|
|
30
|
-
e.trim() && (
|
|
31
|
-
else if (
|
|
32
|
-
e.trim() && (
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
if ((
|
|
24
|
+
for (const r of m)
|
|
25
|
+
if (r.type === "text")
|
|
26
|
+
l(!0), e += r.text || "";
|
|
27
|
+
else if (r.type === "data-summary")
|
|
28
|
+
e.trim() && (n.push({ type: "text", text: e }), e = ""), s.push(r.data);
|
|
29
|
+
else if (r.type === "data-operation") {
|
|
30
|
+
e.trim() && (n.push({ type: "text", text: e }), e = "");
|
|
31
|
+
const t = r.data;
|
|
32
|
+
if (t?.type) {
|
|
33
|
+
if ((t.type === "tool_call" || t.type === "tool_result") && t.details?.data?.inDelegatedAgent === !1)
|
|
36
34
|
continue;
|
|
37
|
-
switch (
|
|
35
|
+
switch (t.type) {
|
|
38
36
|
case "agent_initializing":
|
|
39
37
|
break;
|
|
40
38
|
case "completion": {
|
|
41
|
-
const { type:
|
|
42
|
-
|
|
39
|
+
const { type: c } = t;
|
|
40
|
+
s.push({ type: c, label: "Completed" }), l(!0);
|
|
43
41
|
break;
|
|
44
42
|
}
|
|
45
43
|
case "error": {
|
|
46
|
-
const
|
|
47
|
-
if (console.warn("Data operation error:",
|
|
48
|
-
|
|
44
|
+
const c = t.message || "Unknown error";
|
|
45
|
+
if (console.warn("Data operation error:", c), !n.length)
|
|
46
|
+
l(!0), h.current = c, y || (n.push({ type: "text", text: _ }), y = !0);
|
|
49
47
|
else {
|
|
50
|
-
const { type:
|
|
51
|
-
|
|
48
|
+
const { type: g, label: E } = t;
|
|
49
|
+
s.push({ type: g, label: E });
|
|
52
50
|
}
|
|
53
51
|
break;
|
|
54
52
|
}
|
|
55
53
|
default: {
|
|
56
|
-
const { type:
|
|
57
|
-
|
|
54
|
+
const { type: c, label: g } = t;
|
|
55
|
+
s.push({ type: c, label: g });
|
|
58
56
|
break;
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
|
-
} else if (
|
|
63
|
-
if (
|
|
64
|
-
const
|
|
65
|
-
title:
|
|
60
|
+
} else if (r.type === "data-artifact")
|
|
61
|
+
if (r.data?.type?.toLowerCase() === "citation") {
|
|
62
|
+
const t = r.data, o = t.artifactSummary || {
|
|
63
|
+
title: t.name
|
|
66
64
|
};
|
|
67
|
-
e += ` ^${
|
|
65
|
+
e += ` ^${o?.title || t.name}^`;
|
|
68
66
|
} else
|
|
69
|
-
e.trim() && (
|
|
70
|
-
else
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}), r = !0);
|
|
91
|
-
return r ? e : t;
|
|
92
|
-
});
|
|
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(() => {
|
|
67
|
+
e.trim() && (n.push({ type: "text", text: e }), e = ""), n.push(r);
|
|
68
|
+
else r.type === "data-component" ? (e.trim() && (n.push({ type: "text", text: e }), e = ""), l(!0), n.push(r)) : (e.trim() && (n.push({ type: "text", text: e }), e = ""), l(!0), n.push(r));
|
|
69
|
+
if (l(!a), e.trim() && n.push({ type: "text", text: e }), !a)
|
|
70
|
+
for (const [r, t] of i.entries())
|
|
71
|
+
t.isCompleted || i.set(r, { ...t, isCompleted: !0 });
|
|
72
|
+
const T = i.size !== u.current.size || Array.from(i.entries()).some(([r, t]) => {
|
|
73
|
+
const o = u.current.get(r);
|
|
74
|
+
return !o || o.isCompleted !== t.isCompleted;
|
|
75
|
+
}) ? i : u.current;
|
|
76
|
+
return u.current = T, { processedParts: n, summaryTimings: T };
|
|
77
|
+
}, [m, a]);
|
|
78
|
+
k(() => {
|
|
79
|
+
h.current && (A(new Error(h.current)), h.current = null);
|
|
80
|
+
});
|
|
81
|
+
const D = M(() => {
|
|
82
|
+
const n = Date.now() - w.current, e = Array.from(u.current.values()).some(
|
|
83
|
+
(y) => !y.isCompleted
|
|
84
|
+
), s = n > 1e3 && !e;
|
|
85
|
+
d(s);
|
|
86
|
+
}, []);
|
|
87
|
+
k(() => {
|
|
101
88
|
if (!a) {
|
|
102
|
-
|
|
89
|
+
d(!1);
|
|
103
90
|
return;
|
|
104
91
|
}
|
|
105
92
|
if (!(p.length > 0)) {
|
|
106
|
-
|
|
93
|
+
d(!1);
|
|
107
94
|
return;
|
|
108
95
|
}
|
|
109
|
-
const e = setInterval(
|
|
96
|
+
const e = setInterval(D, 200);
|
|
110
97
|
return () => clearInterval(e);
|
|
111
|
-
}, [a,
|
|
112
|
-
const
|
|
98
|
+
}, [a, D, p.length]);
|
|
99
|
+
const v = S(() => !!(!(p.length > 0) && a), [p.length, a]);
|
|
113
100
|
return {
|
|
114
101
|
processedParts: p,
|
|
115
|
-
summaryTimings:
|
|
116
|
-
shouldShowInitialLoading:
|
|
117
|
-
shouldShowStreamDelayLoading:
|
|
102
|
+
summaryTimings: b,
|
|
103
|
+
shouldShowInitialLoading: v,
|
|
104
|
+
shouldShowStreamDelayLoading: R
|
|
118
105
|
};
|
|
119
106
|
}
|
|
120
107
|
export {
|
|
121
|
-
|
|
108
|
+
I as useStreamProcessor
|
|
122
109
|
};
|