@inkeep/agents-ui 0.15.8 → 0.15.9
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-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +21 -0
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +83 -80
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +30 -30
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +158 -84
- package/dist/styled/components/ui/recipes/button.cjs +1 -1
- package/dist/styled/components/ui/recipes/button.d.ts +1 -1
- package/dist/styled/components/ui/recipes/button.js +6 -0
- package/dist/styled/inkeep.css.cjs +11 -0
- package/dist/styled/inkeep.css.js +11 -0
- package/package.json +4 -5
|
@@ -1,3 +1,3 @@
|
|
|
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 ee=require("@ai-sdk/react"),te=require("ai"),n=require("react"),se=require("../../providers/config-provider.cjs"),ne=require("../../hooks/use-media-query.cjs"),A=require("../../utils/generate-uid.cjs"),re=require("../../providers/base-events-provider.cjs"),oe=require("../../providers/chat-form-provider.cjs"),ae=require("../../providers/widget-provider.cjs"),ie=require("@radix-ui/react-use-controllable-state"),ce=require("../../hooks/use-streaming-events.cjs"),P=`Hmm..
|
|
2
2
|
|
|
3
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`,
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`,ue=()=>{const{baseSettings:C,aiChatSettings:i}=se.useInkeepConfig(),[t="",I]=ie.useControllableState({prop:i.conversationId,defaultProp:i.conversationId??""}),{logEvent:o}=re.useBaseEvents(),{setConversationId:N,emitToParent:u}=ce.useStreamingEvents(),[a,l]=n.useState(""),T=e=>l(e.target.value),{filters:b}=C,{onInputMessageChange:U,filters:y,agentUrl:w,context:d,headers:p,apiKey:g}=i,O=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${C.organizationDisplayName??"Administrator"}`;default:return P}},[H,m]=n.useState([]),[z,M]=n.useState(null),K=()=>({"x-inkeep-client-timezone":Intl.DateTimeFormat().resolvedOptions().timeZone,"x-inkeep-client-timestamp":new Date().toISOString()}),L=n.useMemo(()=>new te.DefaultChatTransport({api:w,headers:{...g?{Authorization:`Bearer ${g}`}:{},...p},body:{requestContext:d}}),[w,g,p,d]),{messages:h,sendMessage:_,addToolApprovalResponse:W,status:q,setMessages:x,stop:$,error:f}=ee.useChat({transport:L,onData(e){u(e.type,e.data)},async onFinish(){u("completion",{conversationId:t}),await o({eventName:"assistant_message_received",properties:{conversationId:t}}),o({eventName:"assistant_answer_displayed",properties:{conversationId:t}})},onError(e){console.log("onError",e.message),o({eventName:"chat_error",properties:{conversationId:t,error:e.message}}),x(c=>{const r=[...c],s=r[r.length-1];if(s){const D=O(e);s.role==="user"?r.push({id:A.generateUid(16),role:"assistant",parts:[{type:"text",text:D}]}):s.parts=[{type:"text",text:D}]}return r})}}),F=q==="submitted",B=q==="streaming",G=h.length===0,v=!a.trim()||F,Q=ne.useMediaQuery("(max-width: 768px)"),[j,S]=n.useState(null);n.useEffect(()=>{f&&S(f)},[f]);const J=()=>S(null),R=n.useRef(null);n.useEffect(()=>{U?.(a)},[a]);const V=e=>{e.key==="Enter"&&!e.shiftKey&&!v&&!e.nativeEvent.isComposing&&(e.preventDefault(),E())},E=async(e=a)=>{if(v&&(!e||e.trim().length===0))return;m([]),l(""),await o({eventName:"user_message_submitted",properties:{conversationId:t}});const c=b||y?JSON.stringify({...b,...y}):void 0,r={...p};c&&(r["inkeep-filters"]=c);let s=t;s||(s=`conv_${A.generateUid(16)}`,I(s)),N(s),_({text:e},{headers:{...K(),...r},body:{conversationId:s,requestContext:d}})},Z=()=>{$().then(()=>{u("aborted",{conversationId:t})})},k=()=>{J(),x([]),I(""),m([]),M(null),o({eventName:"chat_clear_button_clicked",properties:{conversationId:t}})},{openForm:X}=oe.useChatForm(),Y=ae.useWidget();return n.useImperativeHandle(i.chatFunctionsRef,()=>({submitMessage:E,updateInputMessage(e){l(e)},clearChat:k,openForm:e=>{Y?.setView("chat"),X(e,void 0)},focusInput:()=>{R.current?.focus()}})),{messages:h,sendMessage:_,addToolApprovalResponse:W,isLoading:F,isStreaming:B,error:j,setError:S,isSubmitDisabled:v,input:a,handleInputChange:T,handleInputKeyDown:V,handleSubmit:E,stop:Z,clear:k,isEmpty:h.length===0,inputRef:R,isMobile:Q,messageAttachments:H,setMessageAttachments:m,selectedWorkflow:z,setSelectedWorkflow:M,isNewChat:G,conversationId:t}};exports.DEFAULT_ERROR_MESSAGE=P;exports.useInkeepChat=ue;
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import { KeyboardEvent, Dispatch, SetStateAction, RefObject } from 'react';
|
|
2
2
|
import { Message, MessageAttachment, Workflow } from '../../../types/index.ts';
|
|
3
|
+
import { FileUIPart, ChatRequestOptions, ChatAddToolApproveResponseFunction } from 'ai';
|
|
3
4
|
export declare const DEFAULT_ERROR_MESSAGE = "Hmm.. \n\nIt seems I might be having some issues right now. Please clear the chat and try again.";
|
|
4
5
|
export declare const useInkeepChat: () => {
|
|
5
6
|
messages: Message[];
|
|
7
|
+
sendMessage: (message?: (Omit<Message, "id" | "role"> & {
|
|
8
|
+
id?: string | undefined;
|
|
9
|
+
role?: "system" | "user" | "assistant" | undefined;
|
|
10
|
+
} & {
|
|
11
|
+
text?: never;
|
|
12
|
+
files?: never;
|
|
13
|
+
messageId?: string;
|
|
14
|
+
}) | {
|
|
15
|
+
text: string;
|
|
16
|
+
files?: FileList | FileUIPart[];
|
|
17
|
+
metadata?: unknown;
|
|
18
|
+
parts?: never;
|
|
19
|
+
messageId?: string;
|
|
20
|
+
} | {
|
|
21
|
+
files: FileList | FileUIPart[];
|
|
22
|
+
metadata?: unknown;
|
|
23
|
+
parts?: never;
|
|
24
|
+
messageId?: string;
|
|
25
|
+
} | undefined, options?: ChatRequestOptions) => Promise<void>;
|
|
26
|
+
addToolApprovalResponse: ChatAddToolApproveResponseFunction;
|
|
6
27
|
isLoading: boolean;
|
|
7
28
|
isStreaming: boolean;
|
|
8
29
|
error: Error | null;
|
|
@@ -1,68 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useChat as
|
|
3
|
-
import { DefaultChatTransport as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { useMediaQuery as
|
|
7
|
-
import { generateUid as
|
|
8
|
-
import { useBaseEvents as
|
|
9
|
-
import { useChatForm as
|
|
10
|
-
import { useWidget as
|
|
11
|
-
import { useControllableState as
|
|
12
|
-
import { useStreamingEvents as
|
|
13
|
-
const
|
|
2
|
+
import { useChat as ee } from "@ai-sdk/react";
|
|
3
|
+
import { DefaultChatTransport as te } from "ai";
|
|
4
|
+
import { useState as c, useMemo as se, useEffect as R, useRef as ne, useImperativeHandle as oe } from "react";
|
|
5
|
+
import { useInkeepConfig as re } from "../../providers/config-provider.js";
|
|
6
|
+
import { useMediaQuery as ae } from "../../hooks/use-media-query.js";
|
|
7
|
+
import { generateUid as T } from "../../utils/generate-uid.js";
|
|
8
|
+
import { useBaseEvents as ie } from "../../providers/base-events-provider.js";
|
|
9
|
+
import { useChatForm as ce } from "../../providers/chat-form-provider.js";
|
|
10
|
+
import { useWidget as me } from "../../providers/widget-provider.js";
|
|
11
|
+
import { useControllableState as le } from "@radix-ui/react-use-controllable-state";
|
|
12
|
+
import { useStreamingEvents as pe } from "../../hooks/use-streaming-events.js";
|
|
13
|
+
const ue = `Hmm..
|
|
14
14
|
|
|
15
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`,
|
|
16
|
-
const { baseSettings:
|
|
15
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`, we = () => {
|
|
16
|
+
const { baseSettings: y, aiChatSettings: a } = re(), [t = "", E] = le({
|
|
17
17
|
prop: a.conversationId,
|
|
18
18
|
defaultProp: a.conversationId ?? ""
|
|
19
|
-
}), { logEvent: o } =
|
|
19
|
+
}), { logEvent: o } = ie(), { setConversationId: H, emitToParent: m } = pe(), [r, l] = c(""), O = (e) => l(e.target.value), {
|
|
20
20
|
/* shouldBypassCaptcha, */
|
|
21
|
-
filters:
|
|
22
|
-
} =
|
|
23
|
-
onInputMessageChange:
|
|
24
|
-
filters:
|
|
21
|
+
filters: b
|
|
22
|
+
} = y, {
|
|
23
|
+
onInputMessageChange: P,
|
|
24
|
+
filters: S,
|
|
25
25
|
agentUrl: w,
|
|
26
26
|
context: p,
|
|
27
27
|
headers: u,
|
|
28
|
-
apiKey:
|
|
29
|
-
} = a,
|
|
28
|
+
apiKey: d
|
|
29
|
+
} = a, q = (e) => {
|
|
30
30
|
switch (e.code) {
|
|
31
31
|
case 400:
|
|
32
32
|
return e.message;
|
|
33
33
|
case 403:
|
|
34
|
-
return `There seems to be a configuration error. Please contact ${
|
|
34
|
+
return `There seems to be a configuration error. Please contact ${y.organizationDisplayName ?? "Administrator"}`;
|
|
35
35
|
default:
|
|
36
|
-
return
|
|
36
|
+
return ue;
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
39
|
-
()
|
|
38
|
+
}, [z, g] = c([]), [K, x] = c(null), U = () => ({
|
|
39
|
+
"x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
40
|
+
"x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
41
|
+
}), W = se(
|
|
42
|
+
() => new te({
|
|
40
43
|
api: w,
|
|
41
44
|
headers: {
|
|
42
|
-
...
|
|
43
|
-
"x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
44
|
-
"x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
45
|
+
...d ? { Authorization: `Bearer ${d}` } : {},
|
|
45
46
|
...u
|
|
46
47
|
},
|
|
47
48
|
body: {
|
|
48
49
|
requestContext: p
|
|
49
50
|
}
|
|
50
51
|
}),
|
|
51
|
-
[w,
|
|
52
|
+
[w, d, u, p]
|
|
52
53
|
), {
|
|
53
54
|
messages: h,
|
|
54
|
-
sendMessage:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
sendMessage: M,
|
|
56
|
+
addToolApprovalResponse: $,
|
|
57
|
+
status: _,
|
|
58
|
+
setMessages: k,
|
|
59
|
+
stop: B,
|
|
58
60
|
error: f
|
|
59
|
-
} =
|
|
60
|
-
transport:
|
|
61
|
+
} = ee({
|
|
62
|
+
transport: W,
|
|
61
63
|
onData(e) {
|
|
62
|
-
|
|
64
|
+
m(e.type, e.data);
|
|
63
65
|
},
|
|
64
66
|
async onFinish() {
|
|
65
|
-
|
|
67
|
+
m("completion", { conversationId: t }), await o({
|
|
66
68
|
eventName: "assistant_message_received",
|
|
67
69
|
properties: {
|
|
68
70
|
conversationId: t
|
|
@@ -81,53 +83,52 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
81
83
|
conversationId: t,
|
|
82
84
|
error: e.message
|
|
83
85
|
}
|
|
84
|
-
}),
|
|
86
|
+
}), k((i) => {
|
|
85
87
|
const n = [...i], s = n[n.length - 1];
|
|
86
88
|
if (s) {
|
|
87
|
-
const
|
|
89
|
+
const A = q(e);
|
|
88
90
|
s.role === "user" ? n.push({
|
|
89
|
-
id:
|
|
91
|
+
id: T(16),
|
|
90
92
|
role: "assistant",
|
|
91
|
-
parts: [{ type: "text", text:
|
|
92
|
-
}) : s.parts = [{ type: "text", text:
|
|
93
|
+
parts: [{ type: "text", text: A }]
|
|
94
|
+
}) : s.parts = [{ type: "text", text: A }];
|
|
93
95
|
}
|
|
94
96
|
return n;
|
|
95
97
|
});
|
|
96
98
|
}
|
|
97
|
-
}),
|
|
98
|
-
|
|
99
|
+
}), D = _ === "submitted", L = _ === "streaming", G = h.length === 0, v = !r.trim() || D, J = ae("(max-width: 768px)"), [Q, I] = c(null);
|
|
100
|
+
R(() => {
|
|
99
101
|
f && I(f);
|
|
100
102
|
}, [f]);
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
const V = () => I(null), F = ne(null);
|
|
104
|
+
R(() => {
|
|
105
|
+
P?.(r);
|
|
104
106
|
}, [r]);
|
|
105
|
-
const
|
|
107
|
+
const Z = (e) => {
|
|
106
108
|
e.key === "Enter" && !e.shiftKey && !v && !e.nativeEvent.isComposing && (e.preventDefault(), C());
|
|
107
109
|
}, C = async (e = r) => {
|
|
108
110
|
if (v && (!e || e.trim().length === 0)) return;
|
|
109
|
-
|
|
111
|
+
g([]), l(""), await o({
|
|
110
112
|
eventName: "user_message_submitted",
|
|
111
113
|
properties: {
|
|
112
114
|
conversationId: t
|
|
113
115
|
}
|
|
114
116
|
});
|
|
115
|
-
const i =
|
|
116
|
-
...
|
|
117
|
-
...
|
|
117
|
+
const i = b || S ? JSON.stringify({
|
|
118
|
+
...b,
|
|
119
|
+
...S
|
|
118
120
|
}) : void 0, n = {
|
|
119
121
|
...u
|
|
120
122
|
};
|
|
121
123
|
i && (n["inkeep-filters"] = i);
|
|
122
124
|
let s = t;
|
|
123
|
-
s || (s = `conv_${
|
|
125
|
+
s || (s = `conv_${T(16)}`, E(s)), H(s), M(
|
|
124
126
|
{
|
|
125
127
|
text: e
|
|
126
128
|
},
|
|
127
129
|
{
|
|
128
130
|
headers: {
|
|
129
|
-
|
|
130
|
-
"x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
131
|
+
...U(),
|
|
131
132
|
...n
|
|
132
133
|
},
|
|
133
134
|
body: {
|
|
@@ -136,56 +137,58 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
);
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
}, j = () => {
|
|
141
|
+
B().then(() => {
|
|
142
|
+
m("aborted", { conversationId: t });
|
|
142
143
|
});
|
|
143
|
-
},
|
|
144
|
-
|
|
144
|
+
}, N = () => {
|
|
145
|
+
V(), k([]), E(""), g([]), x(null), o({
|
|
145
146
|
eventName: "chat_clear_button_clicked",
|
|
146
147
|
properties: {
|
|
147
148
|
conversationId: t
|
|
148
149
|
}
|
|
149
150
|
});
|
|
150
|
-
}, { openForm:
|
|
151
|
-
return
|
|
151
|
+
}, { openForm: X } = ce(), Y = me();
|
|
152
|
+
return oe(a.chatFunctionsRef, () => ({
|
|
152
153
|
submitMessage: C,
|
|
153
154
|
updateInputMessage(e) {
|
|
154
155
|
l(e);
|
|
155
156
|
},
|
|
156
|
-
clearChat:
|
|
157
|
+
clearChat: N,
|
|
157
158
|
openForm: (e) => {
|
|
158
|
-
|
|
159
|
+
Y?.setView("chat"), X(e, void 0);
|
|
159
160
|
},
|
|
160
161
|
focusInput: () => {
|
|
161
|
-
|
|
162
|
+
F.current?.focus();
|
|
162
163
|
}
|
|
163
164
|
})), {
|
|
164
165
|
messages: h,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
sendMessage: M,
|
|
167
|
+
addToolApprovalResponse: $,
|
|
168
|
+
isLoading: D,
|
|
169
|
+
isStreaming: L,
|
|
170
|
+
error: Q,
|
|
168
171
|
setError: I,
|
|
169
172
|
isSubmitDisabled: v,
|
|
170
173
|
input: r,
|
|
171
|
-
handleInputChange:
|
|
172
|
-
handleInputKeyDown:
|
|
174
|
+
handleInputChange: O,
|
|
175
|
+
handleInputKeyDown: Z,
|
|
173
176
|
handleSubmit: C,
|
|
174
|
-
stop:
|
|
175
|
-
clear:
|
|
177
|
+
stop: j,
|
|
178
|
+
clear: N,
|
|
176
179
|
isEmpty: h.length === 0,
|
|
177
|
-
inputRef:
|
|
178
|
-
isMobile:
|
|
180
|
+
inputRef: F,
|
|
181
|
+
isMobile: J,
|
|
179
182
|
// Additional state for attachments and workflow
|
|
180
|
-
messageAttachments:
|
|
181
|
-
setMessageAttachments:
|
|
182
|
-
selectedWorkflow:
|
|
183
|
+
messageAttachments: z,
|
|
184
|
+
setMessageAttachments: g,
|
|
185
|
+
selectedWorkflow: K,
|
|
183
186
|
setSelectedWorkflow: x,
|
|
184
|
-
isNewChat:
|
|
187
|
+
isNewChat: G,
|
|
185
188
|
conversationId: t
|
|
186
189
|
};
|
|
187
190
|
};
|
|
188
191
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
ue as DEFAULT_ERROR_MESSAGE,
|
|
193
|
+
we as useInkeepChat
|
|
191
194
|
};
|
|
@@ -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,
|
|
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,i,d){const[p,D]=n.useState([]),[h,x]=n.useState(new Map),[w,T]=n.useState(Date.now()),[A,y]=n.useState(!1),C=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=[],c=!1;f.length>C.current&&(T(Date.now()),C.current=f.length),S.current=0;const l=new Map,u=(s=!1)=>{if(a.length>0){const r=`group-${S.current++}`,o=m.current.get(r);o?l.set(r,{...o,isCompleted:s}):l.set(r,{isCompleted:s}),t.push({type:"summary-group",summaries:[...a],groupKey:r}),a=[]}};for(const s of f)if(s.type==="text")u(!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"}),u(!0);break}case"error":{const o=r.message||"Unknown error";if(console.warn("Data operation error:",o),!t.length)u(!0),d(new Error(o)),c||(t.push({type:"text",text:E.DEFAULT_ERROR_MESSAGE}),c=!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=""),u(!0),t.push(s)):(e.trim()&&(t.push({type:"text",text:e}),e=""),u(!0),t.push(s));return u(!i),e.trim()&&t.push({type:"text",text:e}),{processed:t,newTimings:l}},[f,i,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(([c,l])=>{const u=m.current.get(c);return!u||u.isCompleted!==l.isCompleted}))&&x(e)},[b,f]),n.useEffect(()=>{i||x(t=>{const e=new Map(t);let a=!1;for(const[c,l]of e.entries())l.isCompleted||(e.set(c,{...l,isCompleted:!0}),a=!0);return a?e:t})},[i]);const k=n.useCallback(()=>{const t=Date.now()-w,e=Array.from(m.current.values()).some(c=>!c.isCompleted),a=t>1e3&&!e;y(a)},[w]);n.useEffect(()=>{if(!i){y(!1);return}if(!(p.length>0)){y(!1);return}const e=setInterval(k,200);return()=>clearInterval(e)},[i,k,p.length]);const P=n.useMemo(()=>!!(!(p.length>0)&&i),[p.length,i]);return{processedParts:p,summaryTimings:h,shouldShowInitialLoading:P,shouldShowStreamDelayLoading:A}}exports.useStreamProcessor=L;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as m, useRef as h, useCallback as L, useEffect as
|
|
2
|
+
import { useState as m, useRef as h, useCallback as L, useEffect as x, useMemo as z } from "react";
|
|
3
3
|
import { DEFAULT_ERROR_MESSAGE as G } from "./use-inkeep-chat.js";
|
|
4
|
-
function F(l,
|
|
5
|
-
const [
|
|
6
|
-
|
|
4
|
+
function F(l, i, w) {
|
|
5
|
+
const [p, 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([]), f = h(y);
|
|
6
|
+
f.current = y;
|
|
7
7
|
const b = L(() => {
|
|
8
8
|
const e = [];
|
|
9
|
-
let t = "", n = [],
|
|
9
|
+
let t = "", n = [], u = !1;
|
|
10
10
|
l.length > S.current && (v(Date.now()), S.current = l.length), A.current = 0;
|
|
11
|
-
const c = /* @__PURE__ */ new Map(),
|
|
11
|
+
const c = /* @__PURE__ */ new Map(), a = (s = !1) => {
|
|
12
12
|
if (n.length > 0) {
|
|
13
|
-
const r = `group-${A.current++}`, o =
|
|
13
|
+
const r = `group-${A.current++}`, o = f.current.get(r);
|
|
14
14
|
o ? c.set(r, {
|
|
15
15
|
...o,
|
|
16
16
|
isCompleted: s
|
|
@@ -25,7 +25,7 @@ function F(l, a, x) {
|
|
|
25
25
|
};
|
|
26
26
|
for (const s of l)
|
|
27
27
|
if (s.type === "text")
|
|
28
|
-
|
|
28
|
+
a(!0), t += s.text || "";
|
|
29
29
|
else if (s.type === "data-summary")
|
|
30
30
|
t.trim() && (e.push({ type: "text", text: t }), t = ""), n.push(s.data);
|
|
31
31
|
else if (s.type === "data-operation") {
|
|
@@ -37,13 +37,13 @@ function F(l, a, x) {
|
|
|
37
37
|
break;
|
|
38
38
|
case "completion": {
|
|
39
39
|
const { type: o } = r;
|
|
40
|
-
n.push({ type: o, label: "Completed" }),
|
|
40
|
+
n.push({ type: o, label: "Completed" }), a(!0);
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
case "error": {
|
|
44
44
|
const o = r.message || "Unknown error";
|
|
45
45
|
if (console.warn("Data operation error:", o), !e.length)
|
|
46
|
-
|
|
46
|
+
a(!0), w(new Error(o)), u || (e.push({ type: "text", text: G }), u = !0);
|
|
47
47
|
else {
|
|
48
48
|
const { type: d, label: E } = r;
|
|
49
49
|
n.push({ type: d, label: E });
|
|
@@ -64,51 +64,51 @@ function F(l, a, x) {
|
|
|
64
64
|
t += ` ^${o?.title || r.name}^`;
|
|
65
65
|
} else
|
|
66
66
|
t.trim() && (e.push({ type: "text", text: t }), t = ""), e.push(s);
|
|
67
|
-
else s.type === "data-component" && (t.trim() && (e.push({ type: "text", text: t }), t = ""),
|
|
68
|
-
return
|
|
69
|
-
}, [l,
|
|
70
|
-
|
|
67
|
+
else s.type === "data-component" ? (t.trim() && (e.push({ type: "text", text: t }), t = ""), a(!0), e.push(s)) : (t.trim() && (e.push({ type: "text", text: t }), t = ""), a(!0), e.push(s));
|
|
68
|
+
return a(!i), t.trim() && e.push({ type: "text", text: t }), { processed: e, newTimings: c };
|
|
69
|
+
}, [l, i, w]);
|
|
70
|
+
x(() => {
|
|
71
71
|
if (T.current === l)
|
|
72
72
|
return;
|
|
73
73
|
T.current = l;
|
|
74
74
|
const { processed: e, newTimings: t } = b();
|
|
75
|
-
R(e), (t.size !==
|
|
76
|
-
const
|
|
77
|
-
return !
|
|
75
|
+
R(e), (t.size !== f.current.size || Array.from(t.entries()).some(([u, c]) => {
|
|
76
|
+
const a = f.current.get(u);
|
|
77
|
+
return !a || a.isCompleted !== c.isCompleted;
|
|
78
78
|
})) && C(t);
|
|
79
|
-
}, [b, l]),
|
|
80
|
-
|
|
79
|
+
}, [b, l]), x(() => {
|
|
80
|
+
i || C((e) => {
|
|
81
81
|
const t = new Map(e);
|
|
82
82
|
let n = !1;
|
|
83
|
-
for (const [
|
|
84
|
-
c.isCompleted || (t.set(
|
|
83
|
+
for (const [u, c] of t.entries())
|
|
84
|
+
c.isCompleted || (t.set(u, {
|
|
85
85
|
...c,
|
|
86
86
|
isCompleted: !0
|
|
87
87
|
}), n = !0);
|
|
88
88
|
return n ? t : e;
|
|
89
89
|
});
|
|
90
|
-
}, [
|
|
90
|
+
}, [i]);
|
|
91
91
|
const k = L(() => {
|
|
92
|
-
const e = Date.now() - D, t = Array.from(
|
|
93
|
-
(
|
|
92
|
+
const e = Date.now() - D, t = Array.from(f.current.values()).some(
|
|
93
|
+
(u) => !u.isCompleted
|
|
94
94
|
), n = e > 1e3 && !t;
|
|
95
95
|
g(n);
|
|
96
96
|
}, [D]);
|
|
97
|
-
|
|
98
|
-
if (!
|
|
97
|
+
x(() => {
|
|
98
|
+
if (!i) {
|
|
99
99
|
g(!1);
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
if (!(
|
|
102
|
+
if (!(p.length > 0)) {
|
|
103
103
|
g(!1);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
const t = setInterval(k, 200);
|
|
107
107
|
return () => clearInterval(t);
|
|
108
|
-
}, [
|
|
109
|
-
const P = z(() => !!(!(
|
|
108
|
+
}, [i, k, p.length]);
|
|
109
|
+
const P = z(() => !!(!(p.length > 0) && i), [p.length, i]);
|
|
110
110
|
return {
|
|
111
|
-
processedParts:
|
|
111
|
+
processedParts: p,
|
|
112
112
|
summaryTimings: y,
|
|
113
113
|
shouldShowInitialLoading: P,
|
|
114
114
|
shouldShowStreamDelayLoading: M
|
|
@@ -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.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;
|
|
@@ -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.8",
|
|
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"),G=require("../../primitives/providers/base-events-provider.cjs"),K=require("../../primitives/providers/config-provider.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),G=require("../../primitives/providers/base-events-provider.cjs"),K=require("../../primitives/providers/config-provider.cjs"),U=require("../../primitives/providers/message-provider.cjs"),c=require("../../primitives/components/embedded-chat.cjs"),W=require("../../primitives/components/embedded-chat/chat-provider.cjs"),B=require("merge-anything"),j=require("../utils.cjs"),H=require("./ui/markdown-styles.cjs"),Q=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),V=require("./data-summary-group.cjs"),p=require("react"),X=require("./embedded-chat.cjs"),y=require("lucide-react"),S=require("./ui/recipes/button.cjs");function Y(s){if(!s||typeof s!="object")return!1;const a=s;return typeof a.type=="string"&&a.type.startsWith("tool-")}const Z=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(s=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${s*.2}s`},children:"."},s))}),D=({name:s,Icon:a,props:x,componentType:d})=>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(a,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:s})]}),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:d})]}),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(x,null,2)})]}),ee=({name:s,props:a})=>e.jsx(D,{name:s,Icon:y.ComponentIcon,props:a,componentType:"component"}),te=({name:s,props:a})=>e.jsx(D,{name:s,Icon:y.Library,props:a,componentType:"artifact"}),se=({part:s,onApprove:a,onDeny:x})=>{const d=s.type,g=d.startsWith("tool-")?d.slice(5):d,n=s.state;return e.jsxs("div",{className:"border rounded-lg 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(y.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:g})]}),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:n??"tool"})]}),e.jsxs("div",{className:"px-4 pb-3",children:[s.input!=null&&e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2",children:JSON.stringify(s.input,null,2)}),n==="approval-requested"&&s.approval?.id&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs("button",{type:"button",className:j.cn(S.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:a,children:[e.jsx(y.Check,{className:"w-3 h-3"}),"Approve"]}),e.jsx("button",{type:"button",className:j.cn(S.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:x,children:"Deny"})]}),n==="output-available"&&s.output!=null&&e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2",children:typeof s.output=="string"?s.output:JSON.stringify(s.output,null,2)})]})]})},ae=({className:s,componentStyles:a,children:x,isLast:d,...g})=>{const{message:n}=U.useMessage(),{logEvent:h}=G.useBaseEvents(),{conversationId:f,isStreaming:M,isLoading:q,setError:$,addToolApprovalResponse:E,sendMessage:I}=W.useChat(),{aiChatSettings:{components:L,artifacts:T}}=K.useInkeepConfig(),_=n.role==="user",A=(M||q)&&d&&n.role==="assistant",{processedParts:O,summaryTimings:R,shouldShowInitialLoading:J,shouldShowStreamDelayLoading:z}=Q.useStreamProcessor(n.parts,A,$),C=p.useMemo(()=>n.parts.filter(t=>t.type==="data-artifact"&&t.data?.type?.toLowerCase()==="citation"),[n.parts]),w=p.useMemo(()=>B.merge(H.markdownStyles,a??{}),[a]),k=p.useCallback((t,o)=>{h({eventName:"assistant_message_inline_link_opened",properties:{title:o?.toString(),url:t}})},[h]),N=p.useCallback((t,o)=>{h({eventName:"assistant_code_block_copied",properties:{conversationId:f,language:t,code:o}})},[h,f]),P=p.useCallback(t=>e.jsx(c.EmbeddedChatPrimitiveMarkdown,{text:t,componentStyles:w,onLinkClick:k,onCodeCopy:N,artifacts:C}),[w,k,N,C]),F=p.useMemo(()=>j.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",s),[s]);return e.jsxs(e.Fragment,{children:[O.map((t,o)=>{const l={"data-role":n.role,"data-type":t?.type==="data-component"?t.data.type:t?.type,...g,className:F};switch(t?.type){case"text":return e.jsx(c.PrimitiveMessagePart,{...l,children:_?t.text:P(t.text||"")},o);case"data-component":{const{type:r}=t.data;switch(r){case"text":return e.jsx("div",{...l,children:P(t.data.text||"")},o);default:{const m=t.data,{name:i,props:v}=m,u=L?.[i],b=u?c.EmbeddedChatPrimitiveDynamicComponent:ee;return e.jsx(c.PrimitiveMessagePart,{...l,children:e.jsx(b,{name:i,props:v,componentDef:u})},`${i}-${o}`)}}}case"data-artifact":{const r=t.data,{name:m,type:i,artifactSummary:v}=r,u=T?.[i],b=u?c.EmbeddedChatPrimitiveDynamicComponent:te;return e.jsx(c.PrimitiveMessagePart,{...l,children:e.jsx(b,{name:i,props:v,componentDef:u})},`${m}-${o}`)}case"summary-group":{const r=R.get(t.groupKey)||{isCompleted:!1};return e.jsx(c.PrimitiveMessagePart,{...l,children:e.jsx(V.DataSummaryGroup,{summaries:t.summaries||[],isCompleted:r.isCompleted})},`${t.groupKey}-${o}`)}default:if(Y(t)){const r=t.approval?.id,m=async i=>{r&&(E({id:r,approved:i}),await I(void 0,{body:{conversationId:f}}))};return e.jsx(c.PrimitiveMessagePart,{...l,children:e.jsx(se,{part:t,onApprove:r?()=>void m(!0):void 0,onDeny:r?()=>void m(!1):void 0})},t.toolCallId??`${t.type}-${o}`)}return null}}),J&&e.jsx(X.MessageLoading,{}),z&&e.jsx(Z,{})]})};exports.EmbeddedChatMessagePart=ae;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useBaseEvents as
|
|
4
|
-
import { useInkeepConfig as
|
|
5
|
-
import { useMessage as
|
|
6
|
-
import { EmbeddedChatPrimitiveMarkdown as
|
|
7
|
-
import { useChat as
|
|
8
|
-
import { merge as
|
|
9
|
-
import { cn as
|
|
10
|
-
import { markdownStyles as
|
|
11
|
-
import { useStreamProcessor as
|
|
12
|
-
import { DataSummaryGroup as
|
|
13
|
-
import { useMemo as
|
|
14
|
-
import { MessageLoading as
|
|
15
|
-
import { Library as
|
|
16
|
-
|
|
2
|
+
import { jsx as e, jsxs as i, Fragment as B } from "react/jsx-runtime";
|
|
3
|
+
import { useBaseEvents as G } from "../../primitives/providers/base-events-provider.js";
|
|
4
|
+
import { useInkeepConfig as H } from "../../primitives/providers/config-provider.js";
|
|
5
|
+
import { useMessage as R } from "../../primitives/providers/message-provider.js";
|
|
6
|
+
import { EmbeddedChatPrimitiveMarkdown as Q, PrimitiveMessagePart as u, EmbeddedChatPrimitiveDynamicComponent as L } from "../../primitives/components/embedded-chat.js";
|
|
7
|
+
import { useChat as V } from "../../primitives/components/embedded-chat/chat-provider.js";
|
|
8
|
+
import { merge as X } from "merge-anything";
|
|
9
|
+
import { cn as C } from "../utils.js";
|
|
10
|
+
import { markdownStyles as Y } from "./ui/markdown-styles.js";
|
|
11
|
+
import { useStreamProcessor as Z } from "../../primitives/components/embedded-chat/use-stream-processor.js";
|
|
12
|
+
import { DataSummaryGroup as ee } from "./data-summary-group.js";
|
|
13
|
+
import { useMemo as v, useCallback as w } from "react";
|
|
14
|
+
import { MessageLoading as te } from "./embedded-chat.js";
|
|
15
|
+
import { Hammer as ae, Check as oe, Library as ne, ComponentIcon as se } from "lucide-react";
|
|
16
|
+
import { button as M } from "./ui/recipes/button.js";
|
|
17
|
+
function re(a) {
|
|
18
|
+
if (!a || typeof a != "object") return !1;
|
|
19
|
+
const o = a;
|
|
20
|
+
return typeof o.type == "string" && o.type.startsWith("tool-");
|
|
21
|
+
}
|
|
22
|
+
const ie = () => /* @__PURE__ */ e("div", { className: "flex space-x-1", children: [0, 1, 2].map((a) => /* @__PURE__ */ e(
|
|
17
23
|
"span",
|
|
18
24
|
{
|
|
19
25
|
className: "animate-bounce-dot opacity-30",
|
|
@@ -23,120 +29,188 @@ const te = () => /* @__PURE__ */ t("div", { className: "flex space-x-1", childre
|
|
|
23
29
|
children: "."
|
|
24
30
|
},
|
|
25
31
|
a
|
|
26
|
-
)) }),
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
-
/* @__PURE__ */
|
|
32
|
+
)) }), P = ({ name: a, Icon: o, props: h, componentType: m }) => /* @__PURE__ */ i("div", { className: "border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3", children: [
|
|
33
|
+
/* @__PURE__ */ i("div", { className: "flex justify-between px-4 py-2 text-xs", children: [
|
|
34
|
+
/* @__PURE__ */ i("div", { className: "font-medium flex items-center gap-2", children: [
|
|
35
|
+
/* @__PURE__ */ e(o, { className: "w-3 h-3 text-gray-600 dark:text-white-alpha-600" }),
|
|
36
|
+
/* @__PURE__ */ e("span", { children: a })
|
|
31
37
|
] }),
|
|
32
|
-
/* @__PURE__ */
|
|
38
|
+
/* @__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: m })
|
|
33
39
|
] }),
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
] }),
|
|
40
|
+
/* @__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(h, null, 2) })
|
|
41
|
+
] }), le = ({ name: a, props: o }) => /* @__PURE__ */ e(P, { name: a, Icon: se, props: o, componentType: "component" }), me = ({ name: a, props: o }) => /* @__PURE__ */ e(P, { name: a, Icon: ne, props: o, componentType: "artifact" }), ce = ({ part: a, onApprove: o, onDeny: h }) => {
|
|
42
|
+
const m = a.type, f = m.startsWith("tool-") ? m.slice(5) : m, n = a.state;
|
|
43
|
+
return /* @__PURE__ */ i("div", { className: "border rounded-lg mb-3", children: [
|
|
44
|
+
/* @__PURE__ */ i("div", { className: "flex justify-between px-4 py-2 text-xs", children: [
|
|
45
|
+
/* @__PURE__ */ i("div", { className: "font-medium flex items-center gap-2", children: [
|
|
46
|
+
/* @__PURE__ */ e(ae, { className: "w-3 h-3 text-gray-600 dark:text-white-alpha-600" }),
|
|
47
|
+
/* @__PURE__ */ e("span", { children: f })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__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: n ?? "tool" })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ i("div", { className: "px-4 pb-3", children: [
|
|
52
|
+
a.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(a.input, null, 2) }),
|
|
53
|
+
n === "approval-requested" && a.approval?.id && /* @__PURE__ */ i("div", { className: "flex gap-2 pt-1", children: [
|
|
54
|
+
/* @__PURE__ */ i(
|
|
55
|
+
"button",
|
|
56
|
+
{
|
|
57
|
+
type: "button",
|
|
58
|
+
className: C(
|
|
59
|
+
M({ size: "xs", variant: "primaryFilled" }),
|
|
60
|
+
"px-2 py-1 rounded-md text-xs gap-1"
|
|
61
|
+
),
|
|
62
|
+
onClick: o,
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ e(oe, { className: "w-3 h-3" }),
|
|
65
|
+
"Approve"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ e(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
type: "button",
|
|
73
|
+
className: C(
|
|
74
|
+
M({ size: "xs", variant: "outline" }),
|
|
75
|
+
"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"
|
|
76
|
+
),
|
|
77
|
+
onClick: h,
|
|
78
|
+
children: "Deny"
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] }),
|
|
82
|
+
n === "output-available" && a.output != null && /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2", children: typeof a.output == "string" ? a.output : JSON.stringify(a.output, null, 2) })
|
|
83
|
+
] })
|
|
84
|
+
] });
|
|
85
|
+
}, Se = ({
|
|
36
86
|
className: a,
|
|
37
|
-
componentStyles:
|
|
38
|
-
children:
|
|
39
|
-
isLast:
|
|
40
|
-
...
|
|
87
|
+
componentStyles: o,
|
|
88
|
+
children: h,
|
|
89
|
+
isLast: m,
|
|
90
|
+
...f
|
|
41
91
|
}) => {
|
|
42
|
-
const { message:
|
|
43
|
-
aiChatSettings: { components:
|
|
44
|
-
} =
|
|
45
|
-
() =>
|
|
46
|
-
(
|
|
92
|
+
const { message: n } = R(), { logEvent: y } = G(), { conversationId: g, isStreaming: I, isLoading: $, setError: T, addToolApprovalResponse: E, sendMessage: _ } = V(), {
|
|
93
|
+
aiChatSettings: { components: j, artifacts: A }
|
|
94
|
+
} = H(), J = n.role === "user", O = (I || $) && m && n.role === "assistant", { processedParts: z, summaryTimings: F, shouldShowInitialLoading: K, shouldShowStreamDelayLoading: U } = Z(n.parts, O, T), b = v(
|
|
95
|
+
() => n.parts.filter(
|
|
96
|
+
(t) => t.type === "data-artifact" && t.data?.type?.toLowerCase() === "citation"
|
|
47
97
|
),
|
|
48
|
-
[
|
|
49
|
-
),
|
|
50
|
-
() =>
|
|
51
|
-
[
|
|
52
|
-
),
|
|
53
|
-
(
|
|
54
|
-
|
|
98
|
+
[n.parts]
|
|
99
|
+
), k = v(
|
|
100
|
+
() => X(Y, o ?? {}),
|
|
101
|
+
[o]
|
|
102
|
+
), N = w(
|
|
103
|
+
(t, s) => {
|
|
104
|
+
y({
|
|
55
105
|
eventName: "assistant_message_inline_link_opened",
|
|
56
106
|
properties: {
|
|
57
|
-
title:
|
|
58
|
-
url:
|
|
107
|
+
title: s?.toString(),
|
|
108
|
+
url: t
|
|
59
109
|
}
|
|
60
110
|
});
|
|
61
111
|
},
|
|
62
|
-
[
|
|
63
|
-
), D =
|
|
64
|
-
(
|
|
65
|
-
|
|
112
|
+
[y]
|
|
113
|
+
), D = w(
|
|
114
|
+
(t, s) => {
|
|
115
|
+
y({
|
|
66
116
|
eventName: "assistant_code_block_copied",
|
|
67
117
|
properties: {
|
|
68
|
-
conversationId:
|
|
69
|
-
language:
|
|
70
|
-
code:
|
|
118
|
+
conversationId: g,
|
|
119
|
+
language: t,
|
|
120
|
+
code: s
|
|
71
121
|
}
|
|
72
122
|
});
|
|
73
123
|
},
|
|
74
|
-
[
|
|
75
|
-
),
|
|
76
|
-
(
|
|
77
|
-
|
|
124
|
+
[y, g]
|
|
125
|
+
), S = w(
|
|
126
|
+
(t) => /* @__PURE__ */ e(
|
|
127
|
+
Q,
|
|
78
128
|
{
|
|
79
|
-
text:
|
|
80
|
-
componentStyles:
|
|
81
|
-
onLinkClick:
|
|
129
|
+
text: t,
|
|
130
|
+
componentStyles: k,
|
|
131
|
+
onLinkClick: N,
|
|
82
132
|
onCodeCopy: D,
|
|
83
|
-
artifacts:
|
|
133
|
+
artifacts: b
|
|
84
134
|
}
|
|
85
135
|
),
|
|
86
|
-
[
|
|
87
|
-
),
|
|
88
|
-
() =>
|
|
136
|
+
[k, N, D, b]
|
|
137
|
+
), W = v(
|
|
138
|
+
() => C(
|
|
89
139
|
"data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",
|
|
90
140
|
a
|
|
91
141
|
),
|
|
92
142
|
[a]
|
|
93
143
|
);
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
"data-role":
|
|
98
|
-
"data-type":
|
|
99
|
-
...
|
|
100
|
-
className:
|
|
144
|
+
return /* @__PURE__ */ i(B, { children: [
|
|
145
|
+
z.map((t, s) => {
|
|
146
|
+
const c = {
|
|
147
|
+
"data-role": n.role,
|
|
148
|
+
"data-type": t?.type === "data-component" ? t.data.type : t?.type,
|
|
149
|
+
...f,
|
|
150
|
+
className: W
|
|
101
151
|
};
|
|
102
|
-
switch (
|
|
152
|
+
switch (t?.type) {
|
|
103
153
|
case "text":
|
|
104
|
-
return /* @__PURE__ */
|
|
154
|
+
return /* @__PURE__ */ e(u, { ...c, children: J ? t.text : S(t.text || "") }, s);
|
|
105
155
|
case "data-component": {
|
|
106
|
-
const { type:
|
|
107
|
-
switch (
|
|
156
|
+
const { type: r } = t.data;
|
|
157
|
+
switch (r) {
|
|
108
158
|
case "text":
|
|
109
|
-
return /* @__PURE__ */
|
|
159
|
+
return /* @__PURE__ */ e("div", { ...c, children: S(t.data.text || "") }, s);
|
|
110
160
|
default: {
|
|
111
|
-
const
|
|
112
|
-
return /* @__PURE__ */
|
|
161
|
+
const d = t.data, { name: l, props: x } = d, p = j?.[l];
|
|
162
|
+
return /* @__PURE__ */ e(u, { ...c, children: /* @__PURE__ */ e(p ? L : le, { name: l, props: x, componentDef: p }) }, `${l}-${s}`);
|
|
113
163
|
}
|
|
114
164
|
}
|
|
115
165
|
}
|
|
116
166
|
case "data-artifact": {
|
|
117
|
-
const
|
|
118
|
-
return /* @__PURE__ */
|
|
167
|
+
const r = t.data, { name: d, type: l, artifactSummary: x } = r, p = A?.[l];
|
|
168
|
+
return /* @__PURE__ */ e(u, { ...c, children: /* @__PURE__ */ e(p ? L : me, { name: l, props: x, componentDef: p }) }, `${d}-${s}`);
|
|
119
169
|
}
|
|
120
170
|
case "summary-group": {
|
|
121
|
-
const
|
|
171
|
+
const r = F.get(t.groupKey) || {
|
|
122
172
|
isCompleted: !1
|
|
123
173
|
};
|
|
124
|
-
return /* @__PURE__ */
|
|
125
|
-
|
|
174
|
+
return /* @__PURE__ */ e(u, { ...c, children: /* @__PURE__ */ e(
|
|
175
|
+
ee,
|
|
126
176
|
{
|
|
127
|
-
summaries:
|
|
128
|
-
isCompleted:
|
|
177
|
+
summaries: t.summaries || [],
|
|
178
|
+
isCompleted: r.isCompleted
|
|
129
179
|
}
|
|
130
|
-
) }, `${
|
|
180
|
+
) }, `${t.groupKey}-${s}`);
|
|
131
181
|
}
|
|
132
182
|
default:
|
|
183
|
+
if (re(t)) {
|
|
184
|
+
const r = t.approval?.id, d = async (l) => {
|
|
185
|
+
r && (E({ id: r, approved: l }), await _(void 0, {
|
|
186
|
+
body: {
|
|
187
|
+
conversationId: g
|
|
188
|
+
}
|
|
189
|
+
}));
|
|
190
|
+
};
|
|
191
|
+
return /* @__PURE__ */ e(
|
|
192
|
+
u,
|
|
193
|
+
{
|
|
194
|
+
...c,
|
|
195
|
+
children: /* @__PURE__ */ e(
|
|
196
|
+
ce,
|
|
197
|
+
{
|
|
198
|
+
part: t,
|
|
199
|
+
onApprove: r ? () => void d(!0) : void 0,
|
|
200
|
+
onDeny: r ? () => void d(!1) : void 0
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
},
|
|
204
|
+
t.toolCallId ?? `${t.type}-${s}`
|
|
205
|
+
);
|
|
206
|
+
}
|
|
133
207
|
return null;
|
|
134
208
|
}
|
|
135
209
|
}),
|
|
136
|
-
|
|
137
|
-
|
|
210
|
+
K && /* @__PURE__ */ e(te, {}),
|
|
211
|
+
U && /* @__PURE__ */ e(ie, {})
|
|
138
212
|
] });
|
|
139
213
|
};
|
|
140
214
|
export {
|
|
141
|
-
|
|
215
|
+
Se as EmbeddedChatMessagePart
|
|
142
216
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("class-variance-authority"),a=e.cva(["inline-flex","items-center","justify-center","align-middle","select-none","relative","whitespace-nowrap","appearance-none","rounded-md","leading-[1.2]","transition-all","duration-300","cursor-pointer","font-semibold","focus:outline-none","focus:z-base","focus-visible:ring","focus-visible:ring-gray-500","dark:focus-visible:ring-white-alpha-900","focus-visible:ring-2","disabled:opacity-40","disabled:cursor-not-allowed","disabled:shadow-none"],{variants:{variant:{solid:["bg-gray-100 dark:bg-white-alpha-100","text-gray-800 dark:text-white-alpha-950","hover:bg-gray-200 dark:hover:bg-white-alpha-200","hover:disabled:bg-gray-100 dark:hover:disabled:bg-white-alpha-100","active:bg-gray-300 dark:active:bg-white-alpha-400"],iconButton:["px-1 text-gray-500 text-md","hover:text-inkeep-primary-strong","dark:text-gray-dark-200","dark:hover:text-inkeep-expanded-primary-300"],ghost:["text-gray-800 dark:text-white-alpha-950","hover:bg-gray-100 dark:hover:bg-white-alpha-100","active:bg-gray-200 dark:active:bg-white-alpha-200"],outline:["border dark:border-white-alpha-200","text-gray-600 dark:text-gray-200","hover:bg-gray-50 dark:hover:bg-white-alpha-100","active:bg-gray-50 dark:active:bg-white-alpha-100"]},size:{sm:"h-8 min-w-8 text-sm px-3",md:"h-9 min-w-9 text-sm px-4",xs:"h-6 min-w-6 text-xs px-2"},preset:{neutralFilled:["bg-gray-1000 text-white hover:bg-gray-900 active:bg-gray-900","dark:bg-inkeep-expanded-primary-300 dark:text-gray-dark-950","dark:hover:bg-inkeep-expanded-primary-200","dark:active:bg-inkeep-expanded-primary-200"]}},defaultVariants:{size:"md"}});exports.button=a;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("class-variance-authority"),a=e.cva(["inline-flex","items-center","justify-center","align-middle","select-none","relative","whitespace-nowrap","appearance-none","rounded-md","leading-[1.2]","transition-all","duration-300","cursor-pointer","font-semibold","focus:outline-none","focus:z-base","focus-visible:ring","focus-visible:ring-gray-500","dark:focus-visible:ring-white-alpha-900","focus-visible:ring-2","disabled:opacity-40","disabled:cursor-not-allowed","disabled:shadow-none"],{variants:{variant:{solid:["bg-gray-100 dark:bg-white-alpha-100","text-gray-800 dark:text-white-alpha-950","hover:bg-gray-200 dark:hover:bg-white-alpha-200","hover:disabled:bg-gray-100 dark:hover:disabled:bg-white-alpha-100","active:bg-gray-300 dark:active:bg-white-alpha-400"],iconButton:["px-1 text-gray-500 text-md","hover:text-inkeep-primary-strong","dark:text-gray-dark-200","dark:hover:text-inkeep-expanded-primary-300"],ghost:["text-gray-800 dark:text-white-alpha-950","hover:bg-gray-100 dark:hover:bg-white-alpha-100","active:bg-gray-200 dark:active:bg-white-alpha-200"],outline:["border dark:border-white-alpha-200","text-gray-600 dark:text-gray-200","hover:bg-gray-50 dark:hover:bg-white-alpha-100","active:bg-gray-50 dark:active:bg-white-alpha-100"],primaryFilled:["bg-inkeep-expanded-primary-500 text-inkeep-primary-text-color-on-primary hover:bg-inkeep-expanded-primary-700 active:bg-inkeep-expanded-primary-700","dark:bg-inkeep-expanded-primary-300 dark:text-gray-dark-950","dark:hover:bg-inkeep-expanded-primary-200","dark:active:bg-inkeep-expanded-primary-200"]},size:{sm:"h-8 min-w-8 text-sm px-3",md:"h-9 min-w-9 text-sm px-4",xs:"h-6 min-w-6 text-xs px-2"},preset:{neutralFilled:["bg-gray-1000 text-white hover:bg-gray-900 active:bg-gray-900","dark:bg-inkeep-expanded-primary-300 dark:text-gray-dark-950","dark:hover:bg-inkeep-expanded-primary-200","dark:active:bg-inkeep-expanded-primary-200"]}},defaultVariants:{size:"md"}});exports.button=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassProp } from 'class-variance-authority/types';
|
|
2
2
|
export declare const button: (props?: ({
|
|
3
|
-
variant?: "solid" | "iconButton" | "ghost" | "outline" | null | undefined;
|
|
3
|
+
variant?: "solid" | "iconButton" | "ghost" | "outline" | "primaryFilled" | null | undefined;
|
|
4
4
|
size?: "sm" | "md" | "xs" | null | undefined;
|
|
5
5
|
preset?: "neutralFilled" | null | undefined;
|
|
6
6
|
} & ClassProp) | undefined) => string;
|
|
@@ -55,6 +55,12 @@ const r = e(
|
|
|
55
55
|
"text-gray-600 dark:text-gray-200",
|
|
56
56
|
"hover:bg-gray-50 dark:hover:bg-white-alpha-100",
|
|
57
57
|
"active:bg-gray-50 dark:active:bg-white-alpha-100"
|
|
58
|
+
],
|
|
59
|
+
primaryFilled: [
|
|
60
|
+
"bg-inkeep-expanded-primary-500 text-inkeep-primary-text-color-on-primary hover:bg-inkeep-expanded-primary-700 active:bg-inkeep-expanded-primary-700",
|
|
61
|
+
"dark:bg-inkeep-expanded-primary-300 dark:text-gray-dark-950",
|
|
62
|
+
"dark:hover:bg-inkeep-expanded-primary-200",
|
|
63
|
+
"dark:active:bg-inkeep-expanded-primary-200"
|
|
58
64
|
]
|
|
59
65
|
},
|
|
60
66
|
size: {
|
|
@@ -1456,6 +1456,9 @@ video {
|
|
|
1456
1456
|
.bg-inherit {
|
|
1457
1457
|
background-color: inherit;
|
|
1458
1458
|
}
|
|
1459
|
+
.bg-inkeep-expanded-primary-500 {
|
|
1460
|
+
background-color: var(--ikp-color-inkeep-expanded-primary-500);
|
|
1461
|
+
}
|
|
1459
1462
|
.bg-inkeep-primary-medium {
|
|
1460
1463
|
background-color: var(--ikp-color-inkeep-primary-medium);
|
|
1461
1464
|
}
|
|
@@ -2448,6 +2451,10 @@ slot {
|
|
|
2448
2451
|
background-color: var(--ikp-color-gray-900);
|
|
2449
2452
|
}
|
|
2450
2453
|
|
|
2454
|
+
.active\\:bg-inkeep-expanded-primary-700:active {
|
|
2455
|
+
background-color: var(--ikp-color-inkeep-expanded-primary-700);
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2451
2458
|
.active\\:transition-transform:active {
|
|
2452
2459
|
transition-property: transform;
|
|
2453
2460
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -3107,6 +3114,10 @@ slot {
|
|
|
3107
3114
|
background-color: var(--ikp-color-gray-900);
|
|
3108
3115
|
}
|
|
3109
3116
|
|
|
3117
|
+
.hover\\:bg-inkeep-expanded-primary-700:hover:not(:disabled) {
|
|
3118
|
+
background-color: var(--ikp-color-inkeep-expanded-primary-700);
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3110
3121
|
.hover\\:bg-inkeep-primary-light-subtle:hover:not(:disabled) {
|
|
3111
3122
|
background-color: var(--ikp-color-inkeep-primary-light-subtle);
|
|
3112
3123
|
}
|
|
@@ -1457,6 +1457,9 @@ video {
|
|
|
1457
1457
|
.bg-inherit {
|
|
1458
1458
|
background-color: inherit;
|
|
1459
1459
|
}
|
|
1460
|
+
.bg-inkeep-expanded-primary-500 {
|
|
1461
|
+
background-color: var(--ikp-color-inkeep-expanded-primary-500);
|
|
1462
|
+
}
|
|
1460
1463
|
.bg-inkeep-primary-medium {
|
|
1461
1464
|
background-color: var(--ikp-color-inkeep-primary-medium);
|
|
1462
1465
|
}
|
|
@@ -2449,6 +2452,10 @@ slot {
|
|
|
2449
2452
|
background-color: var(--ikp-color-gray-900);
|
|
2450
2453
|
}
|
|
2451
2454
|
|
|
2455
|
+
.active\\:bg-inkeep-expanded-primary-700:active {
|
|
2456
|
+
background-color: var(--ikp-color-inkeep-expanded-primary-700);
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2452
2459
|
.active\\:transition-transform:active {
|
|
2453
2460
|
transition-property: transform;
|
|
2454
2461
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -3108,6 +3115,10 @@ slot {
|
|
|
3108
3115
|
background-color: var(--ikp-color-gray-900);
|
|
3109
3116
|
}
|
|
3110
3117
|
|
|
3118
|
+
.hover\\:bg-inkeep-expanded-primary-700:hover:not(:disabled) {
|
|
3119
|
+
background-color: var(--ikp-color-inkeep-expanded-primary-700);
|
|
3120
|
+
}
|
|
3121
|
+
|
|
3111
3122
|
.hover\\:bg-inkeep-primary-light-subtle:hover:not(:disabled) {
|
|
3112
3123
|
background-color: var(--ikp-color-inkeep-primary-light-subtle);
|
|
3113
3124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-ui",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"sideEffects": false,
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@ai-sdk/openai": "
|
|
42
|
-
"@ai-sdk/react": "
|
|
43
|
-
"@ai-sdk/ui-utils": "^1.2.11",
|
|
41
|
+
"@ai-sdk/openai": "3.0.14",
|
|
42
|
+
"@ai-sdk/react": "3.0.46",
|
|
44
43
|
"@radix-ui/number": "^1.1.1",
|
|
45
44
|
"@radix-ui/primitive": "^1.1.1",
|
|
46
45
|
"@radix-ui/react-avatar": "1.1.2",
|
|
@@ -70,7 +69,7 @@
|
|
|
70
69
|
"@zag-js/presence": "^1.13.1",
|
|
71
70
|
"@zag-js/react": "^1.13.1",
|
|
72
71
|
"@zag-js/remove-scroll": "^1.26.2",
|
|
73
|
-
"ai": "
|
|
72
|
+
"ai": "6.0.44",
|
|
74
73
|
"altcha-lib": "^1.2.0",
|
|
75
74
|
"aria-hidden": "^1.2.4",
|
|
76
75
|
"class-variance-authority": "0.7.1",
|