@inkeep/agents-ui 0.15.7 → 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 +90 -81
- 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,32 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useChat as
|
|
3
|
-
import { DefaultChatTransport as
|
|
4
|
-
import { useState as c, useMemo 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
|
|
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
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: y, aiChatSettings: a } =
|
|
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
21
|
filters: b
|
|
22
22
|
} = y, {
|
|
23
|
-
onInputMessageChange:
|
|
24
|
-
filters:
|
|
25
|
-
agentUrl:
|
|
26
|
-
context:
|
|
27
|
-
headers:
|
|
28
|
-
apiKey:
|
|
29
|
-
} = a,
|
|
23
|
+
onInputMessageChange: P,
|
|
24
|
+
filters: S,
|
|
25
|
+
agentUrl: w,
|
|
26
|
+
context: p,
|
|
27
|
+
headers: u,
|
|
28
|
+
apiKey: d
|
|
29
|
+
} = a, q = (e) => {
|
|
30
30
|
switch (e.code) {
|
|
31
31
|
case 400:
|
|
32
32
|
return e.message;
|
|
@@ -35,26 +35,30 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
35
35
|
default:
|
|
36
36
|
return ue;
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
39
|
-
()
|
|
40
|
-
|
|
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({
|
|
43
|
+
api: w,
|
|
41
44
|
headers: {
|
|
42
|
-
...
|
|
43
|
-
...
|
|
45
|
+
...d ? { Authorization: `Bearer ${d}` } : {},
|
|
46
|
+
...u
|
|
44
47
|
},
|
|
45
48
|
body: {
|
|
46
|
-
requestContext:
|
|
49
|
+
requestContext: p
|
|
47
50
|
}
|
|
48
51
|
}),
|
|
49
|
-
[
|
|
52
|
+
[w, d, u, p]
|
|
50
53
|
), {
|
|
51
54
|
messages: h,
|
|
52
|
-
sendMessage:
|
|
55
|
+
sendMessage: M,
|
|
56
|
+
addToolApprovalResponse: $,
|
|
53
57
|
status: _,
|
|
54
|
-
setMessages:
|
|
55
|
-
stop:
|
|
58
|
+
setMessages: k,
|
|
59
|
+
stop: B,
|
|
56
60
|
error: f
|
|
57
|
-
} =
|
|
61
|
+
} = ee({
|
|
58
62
|
transport: W,
|
|
59
63
|
onData(e) {
|
|
60
64
|
m(e.type, e.data);
|
|
@@ -79,107 +83,112 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
79
83
|
conversationId: t,
|
|
80
84
|
error: e.message
|
|
81
85
|
}
|
|
82
|
-
}),
|
|
86
|
+
}), k((i) => {
|
|
83
87
|
const n = [...i], s = n[n.length - 1];
|
|
84
88
|
if (s) {
|
|
85
|
-
const
|
|
89
|
+
const A = q(e);
|
|
86
90
|
s.role === "user" ? n.push({
|
|
87
|
-
id:
|
|
91
|
+
id: T(16),
|
|
88
92
|
role: "assistant",
|
|
89
|
-
parts: [{ type: "text", text:
|
|
90
|
-
}) : s.parts = [{ type: "text", text:
|
|
93
|
+
parts: [{ type: "text", text: A }]
|
|
94
|
+
}) : s.parts = [{ type: "text", text: A }];
|
|
91
95
|
}
|
|
92
96
|
return n;
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
f &&
|
|
99
|
+
}), D = _ === "submitted", L = _ === "streaming", G = h.length === 0, v = !r.trim() || D, J = ae("(max-width: 768px)"), [Q, I] = c(null);
|
|
100
|
+
R(() => {
|
|
101
|
+
f && I(f);
|
|
98
102
|
}, [f]);
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
const V = () => I(null), F = ne(null);
|
|
104
|
+
R(() => {
|
|
105
|
+
P?.(r);
|
|
102
106
|
}, [r]);
|
|
103
|
-
const
|
|
104
|
-
e.key === "Enter" && !e.shiftKey && !v && !e.nativeEvent.isComposing && (e.preventDefault(),
|
|
105
|
-
},
|
|
107
|
+
const Z = (e) => {
|
|
108
|
+
e.key === "Enter" && !e.shiftKey && !v && !e.nativeEvent.isComposing && (e.preventDefault(), C());
|
|
109
|
+
}, C = async (e = r) => {
|
|
106
110
|
if (v && (!e || e.trim().length === 0)) return;
|
|
107
|
-
|
|
111
|
+
g([]), l(""), await o({
|
|
108
112
|
eventName: "user_message_submitted",
|
|
109
113
|
properties: {
|
|
110
114
|
conversationId: t
|
|
111
115
|
}
|
|
112
116
|
});
|
|
113
|
-
const i = b ||
|
|
117
|
+
const i = b || S ? JSON.stringify({
|
|
114
118
|
...b,
|
|
115
|
-
...
|
|
119
|
+
...S
|
|
116
120
|
}) : void 0, n = {
|
|
117
|
-
...
|
|
121
|
+
...u
|
|
118
122
|
};
|
|
119
123
|
i && (n["inkeep-filters"] = i);
|
|
120
124
|
let s = t;
|
|
121
|
-
s || (s = `conv_${
|
|
125
|
+
s || (s = `conv_${T(16)}`, E(s)), H(s), M(
|
|
122
126
|
{
|
|
123
127
|
text: e
|
|
124
128
|
},
|
|
125
129
|
{
|
|
126
|
-
headers:
|
|
130
|
+
headers: {
|
|
131
|
+
...U(),
|
|
132
|
+
...n
|
|
133
|
+
},
|
|
127
134
|
body: {
|
|
128
135
|
conversationId: s,
|
|
129
|
-
requestContext:
|
|
136
|
+
requestContext: p
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
139
|
);
|
|
133
|
-
},
|
|
134
|
-
|
|
140
|
+
}, j = () => {
|
|
141
|
+
B().then(() => {
|
|
135
142
|
m("aborted", { conversationId: t });
|
|
136
143
|
});
|
|
137
|
-
},
|
|
138
|
-
|
|
144
|
+
}, N = () => {
|
|
145
|
+
V(), k([]), E(""), g([]), x(null), o({
|
|
139
146
|
eventName: "chat_clear_button_clicked",
|
|
140
147
|
properties: {
|
|
141
148
|
conversationId: t
|
|
142
149
|
}
|
|
143
150
|
});
|
|
144
|
-
}, { openForm:
|
|
145
|
-
return
|
|
146
|
-
submitMessage:
|
|
151
|
+
}, { openForm: X } = ce(), Y = me();
|
|
152
|
+
return oe(a.chatFunctionsRef, () => ({
|
|
153
|
+
submitMessage: C,
|
|
147
154
|
updateInputMessage(e) {
|
|
148
|
-
|
|
155
|
+
l(e);
|
|
149
156
|
},
|
|
150
|
-
clearChat:
|
|
157
|
+
clearChat: N,
|
|
151
158
|
openForm: (e) => {
|
|
152
|
-
|
|
159
|
+
Y?.setView("chat"), X(e, void 0);
|
|
153
160
|
},
|
|
154
161
|
focusInput: () => {
|
|
155
|
-
|
|
162
|
+
F.current?.focus();
|
|
156
163
|
}
|
|
157
164
|
})), {
|
|
158
165
|
messages: h,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
sendMessage: M,
|
|
167
|
+
addToolApprovalResponse: $,
|
|
168
|
+
isLoading: D,
|
|
169
|
+
isStreaming: L,
|
|
170
|
+
error: Q,
|
|
171
|
+
setError: I,
|
|
163
172
|
isSubmitDisabled: v,
|
|
164
173
|
input: r,
|
|
165
|
-
handleInputChange:
|
|
166
|
-
handleInputKeyDown:
|
|
167
|
-
handleSubmit:
|
|
168
|
-
stop:
|
|
169
|
-
clear:
|
|
174
|
+
handleInputChange: O,
|
|
175
|
+
handleInputKeyDown: Z,
|
|
176
|
+
handleSubmit: C,
|
|
177
|
+
stop: j,
|
|
178
|
+
clear: N,
|
|
170
179
|
isEmpty: h.length === 0,
|
|
171
|
-
inputRef:
|
|
172
|
-
isMobile:
|
|
180
|
+
inputRef: F,
|
|
181
|
+
isMobile: J,
|
|
173
182
|
// Additional state for attachments and workflow
|
|
174
|
-
messageAttachments:
|
|
175
|
-
setMessageAttachments:
|
|
176
|
-
selectedWorkflow:
|
|
177
|
-
setSelectedWorkflow:
|
|
178
|
-
isNewChat:
|
|
183
|
+
messageAttachments: z,
|
|
184
|
+
setMessageAttachments: g,
|
|
185
|
+
selectedWorkflow: K,
|
|
186
|
+
setSelectedWorkflow: x,
|
|
187
|
+
isNewChat: G,
|
|
179
188
|
conversationId: t
|
|
180
189
|
};
|
|
181
190
|
};
|
|
182
191
|
export {
|
|
183
192
|
ue as DEFAULT_ERROR_MESSAGE,
|
|
184
|
-
|
|
193
|
+
we as useInkeepChat
|
|
185
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",
|