ikoncomponents 1.6.4 → 1.6.6

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.
Files changed (40) hide show
  1. package/README.md +36 -36
  2. package/dist/ikoncomponents/assistant-ui/Assistant.d.ts +16 -2
  3. package/dist/ikoncomponents/assistant-ui/Assistant.js +297 -11
  4. package/dist/ikoncomponents/assistant-ui/agent-dropdown.d.ts +24 -0
  5. package/dist/ikoncomponents/assistant-ui/agent-dropdown.js +16 -0
  6. package/dist/ikoncomponents/assistant-ui/agentTextChatTransport.d.ts +2 -0
  7. package/dist/ikoncomponents/assistant-ui/agentTextChatTransport.js +12 -2
  8. package/dist/ikoncomponents/assistant-ui/thread.d.ts +5 -0
  9. package/dist/ikoncomponents/assistant-ui/thread.js +12 -6
  10. package/dist/ikoncomponents/main-layout/RefreshContext.js +1 -0
  11. package/dist/ikoncomponents/main-layout/footer.js +1 -0
  12. package/dist/ikoncomponents/main-layout/header.js +1 -0
  13. package/dist/ikoncomponents/main-layout/index.js +1 -0
  14. package/dist/ikoncomponents/reload-component/index.d.ts +6 -0
  15. package/dist/ikoncomponents/reload-component/index.js +8 -0
  16. package/dist/ikoncomponents/table/DataTable/index.d.ts +2 -0
  17. package/dist/ikoncomponents/table/DataTable/index.js +9 -0
  18. package/dist/ikoncomponents/table/DataTablePageSize/index.d.ts +1 -0
  19. package/dist/ikoncomponents/table/DataTablePageSize/index.js +16 -0
  20. package/dist/ikoncomponents/table/DataTablePagination/index.d.ts +6 -0
  21. package/dist/ikoncomponents/table/DataTablePagination/index.js +14 -0
  22. package/dist/ikoncomponents/table/DataTableSearch/index.d.ts +1 -0
  23. package/dist/ikoncomponents/table/DataTableSearch/index.js +27 -0
  24. package/dist/ikoncomponents/table/component/DataTable.d.ts +14 -0
  25. package/dist/ikoncomponents/table/component/DataTable.js +10 -0
  26. package/dist/ikoncomponents/table/component/DataTablePageSize.d.ts +1 -0
  27. package/dist/ikoncomponents/table/component/DataTablePageSize.js +16 -0
  28. package/dist/ikoncomponents/table/component/DataTablePagination.d.ts +6 -0
  29. package/dist/ikoncomponents/table/component/DataTablePagination.js +14 -0
  30. package/dist/ikoncomponents/table/component/DataTableSearch.d.ts +1 -0
  31. package/dist/ikoncomponents/table/component/DataTableSearch.js +27 -0
  32. package/dist/ikoncomponents/table/index.d.ts +2 -0
  33. package/dist/ikoncomponents/table/index.js +12 -0
  34. package/dist/ikoncomponents/table/type.d.ts +24 -0
  35. package/dist/ikoncomponents/table/type.js +1 -0
  36. package/dist/index.d.ts +4 -2
  37. package/dist/index.js +3 -1
  38. package/dist/styles.css +162 -1
  39. package/dist/utils/api/loginService/index.js +2 -1
  40. package/package.json +23 -14
package/README.md CHANGED
@@ -1,36 +1,36 @@
1
- This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2
-
3
- ## Getting Started
4
-
5
- First, run the development server:
6
-
7
- ```bash
8
- npm run dev
9
- # or
10
- yarn dev
11
- # or
12
- pnpm dev
13
- # or
14
- bun dev
15
- ```
16
-
17
- Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
-
19
- You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
-
21
- This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
-
23
- ## Learn More
24
-
25
- To learn more about Next.js, take a look at the following resources:
26
-
27
- - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
- - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
-
30
- You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
-
32
- ## Deploy on Vercel
33
-
34
- The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
-
36
- Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
1
+ This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
+
21
+ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
+
23
+ ## Learn More
24
+
25
+ To learn more about Next.js, take a look at the following resources:
26
+
27
+ - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
+ - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
+
30
+ You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
+
32
+ ## Deploy on Vercel
33
+
34
+ The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
+
36
+ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
@@ -1,4 +1,16 @@
1
- import { UserData } from "../../utils/userType";
1
+ interface UserData {
2
+ userId: string;
3
+ userName: string;
4
+ userLogin: string;
5
+ password: string;
6
+ userPhone?: string;
7
+ userEmail: string;
8
+ userThumbnail?: string | null;
9
+ userType?: string;
10
+ active?: boolean;
11
+ accountId?: string;
12
+ userDeleted?: boolean;
13
+ }
2
14
  interface AssistantComponentProps {
3
15
  provider?: string;
4
16
  model?: string;
@@ -8,7 +20,9 @@ interface AssistantComponentProps {
8
20
  maxTokens?: number;
9
21
  className?: string;
10
22
  baseUrl?: string;
23
+ additionalReferenceInfo?: object;
24
+ appId: string;
11
25
  currentUserDetails: UserData;
12
26
  }
13
- export declare const AssistantComponent: ({ provider, model, agentId, agentName, temperature, maxTokens, className, baseUrl, currentUserDetails }: AssistantComponentProps) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const AssistantComponent: ({ provider, model, agentId, agentName, temperature, maxTokens, className, baseUrl, additionalReferenceInfo, appId, currentUserDetails, }: AssistantComponentProps) => import("react/jsx-runtime").JSX.Element;
14
28
  export {};
@@ -1,20 +1,306 @@
1
+ // "use client";
2
+ // import { Thread } from "./thread";
3
+ // import { AssistantRuntimeProvider } from "@assistant-ui/react";
4
+ // import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
5
+ // import { AgentTextChatTransport } from "./agentTextChatTransport";
6
+ // import { useEffect, useState } from "react";
7
+ // import { getValidAccessToken } from "@/utils/token-management";
8
+ // import { Agent } from "./agent-dropdown";
9
+ // interface UserData {
10
+ // userId: string;
11
+ // userName: string;
12
+ // userLogin: string;
13
+ // password: string;
14
+ // userPhone?: string;
15
+ // userEmail: string;
16
+ // userThumbnail?: string | null;
17
+ // userType?: string;
18
+ // active?: boolean;
19
+ // accountId?: string;
20
+ // userDeleted?: boolean;
21
+ // }
22
+ // interface AssistantComponentProps {
23
+ // provider?: string;
24
+ // model?: string;
25
+ // agentId?: string;
26
+ // agentName?: string;
27
+ // temperature?: number;
28
+ // maxTokens?: number;
29
+ // className?: string;
30
+ // baseUrl?: string;
31
+ // additionalReferenceInfo?: object;
32
+ // appId: string;
33
+ // currentUserDetails: UserData;
34
+ // }
35
+ // export const AssistantComponent = ({
36
+ // provider = "openai",
37
+ // model = "gpt-4o-mini",
38
+ // agentId = "default-agent",
39
+ // agentName = "Default Agent",
40
+ // temperature = 0.7,
41
+ // maxTokens = 2048,
42
+ // className,
43
+ // baseUrl = "http://localhost:3000",
44
+ // additionalReferenceInfo = {},
45
+ // appId = "",
46
+ // currentUserDetails,
47
+ // }: AssistantComponentProps) => {
48
+ // const runtime = useChatRuntime({
49
+ // transport: new AgentTextChatTransport({
50
+ // provider,
51
+ // model,
52
+ // agentId,
53
+ // agentName,
54
+ // temperature,
55
+ // maxTokens,
56
+ // baseUrl,
57
+ // additionalReferenceInfo,
58
+ // }),
59
+ // });
60
+ // const [agentList, setAgentList] = useState([]);
61
+ // const [selectedAgent, setSelectedAgent] = useState<Agent>();
62
+ // const getAgentsByAppId = async () => {
63
+ // try {
64
+ // const accessToken = await getValidAccessToken(
65
+ // "https://ikoncloud-dev.keross.com/ikon-api",
66
+ // );
67
+ // const response = await fetch(`${baseUrl}/api/agent/${appId}`, {
68
+ // method: "GET",
69
+ // headers: {
70
+ // "Content-Type": "application/json",
71
+ // Authorization: `Bearer ${accessToken}`,
72
+ // },
73
+ // });
74
+ // // 1. Check if the response is actually okay
75
+ // if (!response.ok) {
76
+ // throw new Error(`HTTP error! status: ${response.status}`);
77
+ // }
78
+ // // 2. Parse the body as JSON
79
+ // const data = await response.json();
80
+ // // 3. Now you can use it!
81
+ // console.log("Agent Data:", data);
82
+ // setAgentList(data);
83
+ // // setAgentList(response)
84
+ // } catch (error) {
85
+ // console.error(
86
+ // "Error while fetching agents with the specific appId",
87
+ // error,
88
+ // );
89
+ // }
90
+ // };
91
+ // useEffect(() => {
92
+ // getAgentsByAppId();
93
+ // }, [appId, baseUrl]);
94
+ // useEffect(() => {
95
+ // },[selectedAgent])
96
+ // return (
97
+ // <AssistantRuntimeProvider runtime={runtime}>
98
+ // <div className={className}>
99
+ // <div
100
+ // className={`flex flex-col h-full border rounded-lg overflow-hidden ${className}`}
101
+ // >
102
+ // <Thread
103
+ // currentUserDetails={currentUserDetails}
104
+ // agents={agentList}
105
+ // initialAgentId={agentId}
106
+ // initialAgentName={agentName}
107
+ // onAgentChange={(agent) => {
108
+ // // Handle agent change here
109
+ // console.log("Agent changed:", agent);
110
+ // setSelectedAgent(agent);
111
+ // }}
112
+ // />
113
+ // </div>
114
+ // </div>
115
+ // </AssistantRuntimeProvider>
116
+ // );
117
+ // };
118
+ //2nd imperfect change
119
+ // "use client";
120
+ // import { Thread } from "./thread";
121
+ // import { AssistantRuntimeProvider } from "@assistant-ui/react";
122
+ // import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
123
+ // import { AgentTextChatTransport } from "./agentTextChatTransport";
124
+ // import { useEffect, useRef, useState } from "react";
125
+ // import { getValidAccessToken } from "@/utils/token-management";
126
+ // import { Agent } from "./agent-dropdown";
127
+ // interface UserData {
128
+ // userId: string;
129
+ // userName: string;
130
+ // userLogin: string;
131
+ // password: string;
132
+ // userPhone?: string;
133
+ // userEmail: string;
134
+ // userThumbnail?: string | null;
135
+ // userType?: string;
136
+ // active?: boolean;
137
+ // accountId?: string;
138
+ // userDeleted?: boolean;
139
+ // }
140
+ // interface AssistantComponentProps {
141
+ // provider?: string;
142
+ // model?: string;
143
+ // agentId?: string;
144
+ // agentName?: string;
145
+ // temperature?: number;
146
+ // maxTokens?: number;
147
+ // className?: string;
148
+ // baseUrl?: string;
149
+ // additionalReferenceInfo?: object;
150
+ // appId: string;
151
+ // currentUserDetails: UserData;
152
+ // }
153
+ // export const AssistantComponent = ({
154
+ // provider = "openai",
155
+ // model = "gpt-4o-mini",
156
+ // agentId = "default-agent",
157
+ // agentName = "Default Agent",
158
+ // temperature = 0.7,
159
+ // maxTokens = 2048,
160
+ // className,
161
+ // baseUrl = "http://localhost:3000",
162
+ // additionalReferenceInfo = {},
163
+ // appId = "",
164
+ // currentUserDetails,
165
+ // }: AssistantComponentProps) => {
166
+ // const transportRef = useRef<AgentTextChatTransport | null>(null);
167
+ // const transport = new AgentTextChatTransport({
168
+ // provider,
169
+ // model,
170
+ // agentId,
171
+ // agentName,
172
+ // temperature,
173
+ // maxTokens,
174
+ // baseUrl,
175
+ // additionalReferenceInfo,
176
+ // });
177
+ // transportRef.current = transport;
178
+ // const runtime = useChatRuntime({
179
+ // transport,
180
+ // });
181
+ // const [agentList, setAgentList] = useState<Agent[]>([]);
182
+ // const [selectedAgent, setSelectedAgent] = useState<Agent>();
183
+ // const getAgentsByAppId = async () => {
184
+ // try {
185
+ // const accessToken = await getValidAccessToken(
186
+ // "https://ikoncloud-dev.keross.com/ikon-api",
187
+ // );
188
+ // const response = await fetch(`${baseUrl}/api/agent/${appId}`, {
189
+ // method: "GET",
190
+ // headers: {
191
+ // "Content-Type": "application/json",
192
+ // Authorization: `Bearer ${accessToken}`,
193
+ // },
194
+ // });
195
+ // if (!response.ok) {
196
+ // throw new Error(`HTTP error! status: ${response.status}`);
197
+ // }
198
+ // const data = await response.json();
199
+ // console.log("Agent Data:", data);
200
+ // setAgentList(data);
201
+ // } catch (error) {
202
+ // console.error(
203
+ // "Error while fetching agents with the specific appId",
204
+ // error,
205
+ // );
206
+ // }
207
+ // };
208
+ // useEffect(() => {
209
+ // getAgentsByAppId();
210
+ // }, [appId, baseUrl]);
211
+ // const handleAgentChange = (agent: Agent) => {
212
+ // setSelectedAgent(agent);
213
+ // // Update the transport with the new agent configuration
214
+ // if (transportRef.current) {
215
+ // transportRef.current.updateAgentConfig({
216
+ // agentId: agent.agentID,
217
+ // agentName: agent.agentName,
218
+ // });
219
+ // }
220
+ // console.log("Agent changed to:", agent.agentName);
221
+ // };
222
+ // return (
223
+ // <AssistantRuntimeProvider runtime={runtime}>
224
+ // <div className={className}>
225
+ // <div
226
+ // className={`flex flex-col h-full border rounded-lg overflow-hidden ${className}`}
227
+ // >
228
+ // <Thread
229
+ // currentUserDetails={currentUserDetails}
230
+ // agents={agentList}
231
+ // initialAgentId={agentId}
232
+ // initialAgentName={agentName}
233
+ // onAgentChange={handleAgentChange}
234
+ // />
235
+ // </div>
236
+ // </div>
237
+ // </AssistantRuntimeProvider>
238
+ // );
239
+ // };
240
+ //3rd change
1
241
  "use client";
2
242
  import { jsx as _jsx } from "react/jsx-runtime";
3
243
  import { Thread } from "./thread";
4
244
  import { AssistantRuntimeProvider } from "@assistant-ui/react";
5
245
  import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
6
246
  import { AgentTextChatTransport } from "./agentTextChatTransport";
7
- export const AssistantComponent = ({ provider = "openai", model = "gpt-4o-mini", agentId = "default-agent", agentName = "Default Agent", temperature = 0.7, maxTokens = 2048, className, baseUrl = "http://localhost:3000", currentUserDetails }) => {
247
+ import { useEffect, useMemo, useState } from "react";
248
+ import { getValidAccessToken } from "../../utils/token-management";
249
+ export const AssistantComponent = ({ provider = "openai", model = "gpt-4o-mini", agentId = "default-agent", agentName = "Default Agent", temperature = 0.7, maxTokens = 2048, className, baseUrl = "http://localhost:3000", additionalReferenceInfo = {}, appId = "", currentUserDetails, }) => {
250
+ const [agentList, setAgentList] = useState([]);
251
+ const [selectedAgent, setSelectedAgent] = useState();
252
+ // Create transport with current agent config - memoized to avoid recreating on every render
253
+ const transport = useMemo(() => new AgentTextChatTransport({
254
+ provider,
255
+ model,
256
+ agentId: selectedAgent ? selectedAgent.agentID : agentId,
257
+ agentName: selectedAgent ? selectedAgent.agentName : agentName,
258
+ temperature,
259
+ maxTokens,
260
+ baseUrl,
261
+ additionalReferenceInfo,
262
+ }), [
263
+ provider,
264
+ model,
265
+ selectedAgent,
266
+ agentId,
267
+ agentName,
268
+ temperature,
269
+ maxTokens,
270
+ baseUrl,
271
+ additionalReferenceInfo,
272
+ ]);
273
+ // Create runtime with the transport - will recreate when transport changes
8
274
  const runtime = useChatRuntime({
9
- transport: new AgentTextChatTransport({
10
- provider,
11
- model,
12
- agentId,
13
- agentName,
14
- temperature,
15
- maxTokens,
16
- baseUrl
17
- }),
275
+ transport,
18
276
  });
19
- return _jsx(AssistantRuntimeProvider, { runtime: runtime, children: _jsx("div", { className: className, children: _jsx("div", { className: `flex flex-col h-full border rounded-lg overflow-hidden ${className}`, children: _jsx(Thread, { currentUserDetails: currentUserDetails }) }) }) });
277
+ const getAgentsByAppId = async () => {
278
+ try {
279
+ const accessToken = await getValidAccessToken("https://ikoncloud-dev.keross.com/ikon-api");
280
+ const response = await fetch(`${baseUrl}/api/agent/${appId}`, {
281
+ method: "GET",
282
+ headers: {
283
+ "Content-Type": "application/json",
284
+ Authorization: `Bearer ${accessToken}`,
285
+ },
286
+ });
287
+ if (!response.ok) {
288
+ throw new Error(`HTTP error! status: ${response.status}`);
289
+ }
290
+ const data = await response.json();
291
+ console.log("Agent Data:", data);
292
+ setAgentList(data);
293
+ }
294
+ catch (error) {
295
+ console.error("Error while fetching agents with the specific appId", error);
296
+ }
297
+ };
298
+ useEffect(() => {
299
+ getAgentsByAppId();
300
+ }, [appId, baseUrl]);
301
+ const handleAgentChange = (agent) => {
302
+ setSelectedAgent(agent);
303
+ console.log("Agent changed to:", agent.agentName);
304
+ };
305
+ return (_jsx(AssistantRuntimeProvider, { runtime: runtime, children: _jsx("div", { className: className, children: _jsx("div", { className: `flex flex-col h-full border rounded-lg overflow-hidden ${className}`, children: _jsx(Thread, { currentUserDetails: currentUserDetails, agents: agentList, initialAgentId: agentId, initialAgentName: agentName, onAgentChange: handleAgentChange }) }) }) }));
20
306
  };
@@ -0,0 +1,24 @@
1
+ export interface Agent {
2
+ agentDescription?: string;
3
+ agentID: string;
4
+ agentName: string;
5
+ agentRoles?: string[];
6
+ agentTasks?: object[];
7
+ appId: string;
8
+ createdAt: string;
9
+ createdBy: string;
10
+ mcpServerIds?: string[];
11
+ systemPrompt: string;
12
+ updatedAt: string;
13
+ updatedBy: string;
14
+ userName?: null | string;
15
+ [key: string]: any;
16
+ }
17
+ export interface AgentDropdownProps {
18
+ agents: Agent[];
19
+ selectedAgent?: Agent;
20
+ onSelectAgent: (agent: Agent) => void;
21
+ className?: string;
22
+ triggerClassName?: string;
23
+ }
24
+ export declare const AgentDropdown: ({ agents, selectedAgent, onSelectAgent, className, triggerClassName, }: AgentDropdownProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { ChevronDownIcon } from "lucide-react";
5
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "../../shadcn/dropdown-menu";
6
+ import { Button } from "../../shadcn/button";
7
+ import { cn } from "../../utils/cn";
8
+ export const AgentDropdown = ({ agents, selectedAgent, onSelectAgent, className, triggerClassName, }) => {
9
+ const [open, setOpen] = useState(false);
10
+ // const displayAgent = selectedAgent || (agents.length > 0 ? agents[0] : null);
11
+ const displayAgent = selectedAgent || null;
12
+ return (_jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", className: cn("gap-2 px-3 py-2 text-sm font-medium rounded-2xl", triggerClassName), children: [_jsx("span", { className: "truncate", children: (displayAgent === null || displayAgent === void 0 ? void 0 : displayAgent.agentName) || "Select Agent" }), _jsx(ChevronDownIcon, { className: "size-4 shrink-0 opacity-50" })] }) }), _jsx(DropdownMenuContent, { align: "end", className: cn("min-w-[200px]", className), children: agents.length > 0 ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuLabel, { className: "px-2 py-1.5 text-xs font-semibold text-muted-foreground", children: "Agents" }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuGroup, { children: agents.map((agent) => (_jsxs(DropdownMenuItem, { onClick: () => {
13
+ onSelectAgent(agent);
14
+ setOpen(false);
15
+ }, className: cn("cursor-pointer flex flex-col gap-1", (displayAgent === null || displayAgent === void 0 ? void 0 : displayAgent.agentID) === agent.agentID && "bg-accent"), children: [_jsx("div", { className: "font-medium text-sm", children: agent.agentName }), agent.agentDescription && (_jsx("div", { className: "text-xs text-muted-foreground truncate", children: agent.agentDescription }))] }, agent.agentID))) })] })) : (_jsx("div", { className: "px-2 py-1.5 text-sm text-muted-foreground text-center", children: "No agents available" })) })] }));
16
+ };
@@ -7,12 +7,14 @@ export interface AgentTextChatTransportOptions {
7
7
  temperature?: number;
8
8
  maxTokens?: number;
9
9
  baseUrl?: string;
10
+ additionalReferenceInfo?: object;
10
11
  }
11
12
  export declare class AgentTextChatTransport<UI_MESSAGE extends UIMessage = UIMessage> implements ChatTransport<UI_MESSAGE> {
12
13
  private agentConfig;
13
14
  private baseUrl;
14
15
  private chatIdMap;
15
16
  constructor(options: AgentTextChatTransportOptions);
17
+ updateAgentConfig(options: Partial<AgentTextChatTransportOptions>): void;
16
18
  private getChatId;
17
19
  sendMessages(options: {
18
20
  trigger: "submit-message" | "regenerate-message";
@@ -1,3 +1,4 @@
1
+ import { getValidAccessToken } from "../../utils/token-management";
1
2
  import { v4 as uuidv4 } from "uuid";
2
3
  export class AgentTextChatTransport {
3
4
  constructor(options) {
@@ -5,6 +6,9 @@ export class AgentTextChatTransport {
5
6
  this.agentConfig = options;
6
7
  this.baseUrl = options.baseUrl || "";
7
8
  }
9
+ updateAgentConfig(options) {
10
+ this.agentConfig = Object.assign(Object.assign({}, this.agentConfig), options);
11
+ }
8
12
  getChatId(chatId) {
9
13
  if (this.chatIdMap.has(chatId)) {
10
14
  return this.chatIdMap.get(chatId);
@@ -25,11 +29,17 @@ export class AgentTextChatTransport {
25
29
  .join("");
26
30
  return {
27
31
  role: msg.role,
28
- content: content,
32
+ content: msg.role === "user" &&
33
+ this.agentConfig.additionalReferenceInfo &&
34
+ Object.keys(this.agentConfig.additionalReferenceInfo).length > 0
35
+ ? content + JSON.stringify(this.agentConfig.additionalReferenceInfo)
36
+ : content,
29
37
  };
30
38
  });
31
39
  const requestBody = Object.assign({ messages: convertedMessages, provider: this.agentConfig.provider, model: this.agentConfig.model, agentId: this.agentConfig.agentId, agentName: this.agentConfig.agentName, temperature: (_a = this.agentConfig.temperature) !== null && _a !== void 0 ? _a : 0.7, maxTokens: (_b = this.agentConfig.maxTokens) !== null && _b !== void 0 ? _b : 2048, stream: true, useVoice: false }, body);
32
- const mergedHeaders = Object.assign({ "Content-Type": "application/json" }, (headers instanceof Headers
40
+ //adding code to fetch the token and pass it
41
+ const accessToken = await getValidAccessToken(this.baseUrl);
42
+ const mergedHeaders = Object.assign({ "Content-Type": "application/json", "Authorization": `Bearer ${accessToken}` }, (headers instanceof Headers
33
43
  ? Object.fromEntries(headers.entries())
34
44
  : headers || {}));
35
45
  try {
@@ -1,5 +1,10 @@
1
1
  import { type FC } from "react";
2
2
  import { UserData } from "../../utils/userType";
3
+ import { Agent } from "./agent-dropdown";
3
4
  export declare const Thread: FC<{
4
5
  currentUserDetails: UserData;
6
+ agents?: Agent[];
7
+ initialAgentId?: string;
8
+ initialAgentName?: string;
9
+ onAgentChange?: (agent: Agent) => void;
5
10
  }>;
@@ -13,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { ArrowDownIcon, ArrowUpIcon, CheckIcon, ChevronLeftIcon, ChevronRightIcon, CopyIcon, PencilIcon, RefreshCwIcon, Square, } from "lucide-react";
15
15
  import { ActionBarPrimitive, BranchPickerPrimitive, ComposerPrimitive, ErrorPrimitive, MessagePrimitive, ThreadPrimitive, } from "@assistant-ui/react";
16
+ import { useState } from "react";
16
17
  import { LazyMotion, MotionConfig, domAnimation } from "motion/react";
17
18
  import * as m from "motion/react-m";
18
19
  import { Button } from "../../shadcn/button";
@@ -21,14 +22,19 @@ import { ToolFallback } from "../assistant-ui/tool-fallback";
21
22
  import { TooltipIconButton } from "../assistant-ui/tooltip-icon-button";
22
23
  import { ComposerAddAttachment, ComposerAttachments, UserMessageAttachments, } from "../assistant-ui/attachment";
23
24
  import { cn } from "../../utils/cn";
24
- export const Thread = ({ currentUserDetails, }) => {
25
+ import { AgentDropdown } from "./agent-dropdown";
26
+ export const Thread = ({ currentUserDetails, agents = [], initialAgentId = "default-agent", initialAgentName = "Default Agent", onAgentChange, }) => {
27
+ const [selectedAgent, setSelectedAgent] = useState(agents.find((a) => a.agentID === initialAgentId));
25
28
  return (_jsx(LazyMotion, { features: domAnimation, children: _jsx(MotionConfig, { reducedMotion: "user", children: _jsx(ThreadPrimitive.Root, { className: "aui-root aui-thread-root @container flex h-full flex-col bg-background", style: {
26
29
  ["--thread-max-width"]: "44rem",
27
30
  }, children: _jsxs(ThreadPrimitive.Viewport, { turnAnchor: "top", className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4", children: [_jsx(ThreadPrimitive.If, { empty: true, children: _jsx(ThreadWelcome, { currentUserDetails: currentUserDetails }) }), _jsx(ThreadPrimitive.Messages, { components: {
28
31
  UserMessage,
29
32
  EditComposer,
30
33
  AssistantMessage,
31
- } }), _jsxs(ThreadPrimitive.ViewportFooter, { className: "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-4 flex w-full max-w-[var(--thread-max-width)] flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6", children: [_jsx(ThreadScrollToBottom, {}), _jsx(Composer, {})] })] }) }) }) }));
34
+ } }), _jsxs(ThreadPrimitive.ViewportFooter, { className: "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-4 flex w-full max-w-[var(--thread-max-width)] flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6", children: [_jsx(ThreadScrollToBottom, {}), _jsx(Composer, { agents: agents, selectedAgent: selectedAgent, onSelectAgent: (agent) => {
35
+ setSelectedAgent(agent);
36
+ onAgentChange === null || onAgentChange === void 0 ? void 0 : onAgentChange(agent);
37
+ } })] })] }) }) }) }));
32
38
  };
33
39
  const ThreadScrollToBottom = () => {
34
40
  return (_jsx(ThreadPrimitive.ScrollToBottom, { asChild: true, children: _jsx(TooltipIconButton, { tooltip: "Scroll to bottom", variant: "outline", className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible dark:bg-background dark:hover:bg-accent", children: _jsx(ArrowDownIcon, {}) }) }));
@@ -76,11 +82,11 @@ const ThreadSuggestions = () => {
76
82
  },
77
83
  ].map((suggestedAction, index) => (_jsx(m.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: 20 }, transition: { delay: 0.05 * index }, className: "aui-thread-welcome-suggestion-display [&:nth-child(n+3)]:hidden @md:[&:nth-child(n+3)]:block", children: _jsx(ThreadPrimitive.Suggestion, { prompt: suggestedAction.action, send: true, asChild: true, children: _jsxs(Button, { variant: "ghost", className: "aui-thread-welcome-suggestion h-auto w-full flex-1 flex-wrap items-start justify-start gap-1 rounded-3xl border px-5 py-4 text-left text-sm @md:flex-col dark:hover:bg-accent/60", "aria-label": suggestedAction.action, children: [_jsx("span", { className: "aui-thread-welcome-suggestion-text-1 font-medium", children: suggestedAction.title }), _jsx("span", { className: "aui-thread-welcome-suggestion-text-2 text-muted-foreground", children: suggestedAction.label })] }) }) }, `suggested-action-${suggestedAction.title}-${index}`))) }));
78
84
  };
79
- const Composer = () => {
80
- return (_jsx(ComposerPrimitive.Root, { className: "aui-composer-root relative flex w-full flex-col", children: _jsxs(ComposerPrimitive.AttachmentDropzone, { className: "aui-composer-attachment-dropzone group/input-group flex w-full flex-col rounded-3xl border border-input bg-background px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-[3px] has-[textarea:focus-visible]:ring-ring/50 data-[dragging=true]:border-dashed data-[dragging=true]:border-ring data-[dragging=true]:bg-accent/50 dark:bg-background", children: [_jsx(ComposerAttachments, {}), _jsx(ComposerPrimitive.Input, { placeholder: "Send a message...", className: "aui-composer-input mb-1 max-h-32 min-h-16 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 text-base outline-none placeholder:text-muted-foreground focus-visible:ring-0", rows: 1, autoFocus: true, "aria-label": "Message input" }), _jsx(ComposerAction, {})] }) }));
85
+ const Composer = ({ agents = [], selectedAgent, onSelectAgent }) => {
86
+ return (_jsx(ComposerPrimitive.Root, { className: "aui-composer-root relative flex w-full flex-col", children: _jsxs(ComposerPrimitive.AttachmentDropzone, { className: "aui-composer-attachment-dropzone group/input-group flex w-full flex-col rounded-3xl border border-input bg-background px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-[3px] has-[textarea:focus-visible]:ring-ring/50 data-[dragging=true]:border-dashed data-[dragging=true]:border-ring data-[dragging=true]:bg-accent/50 dark:bg-background", children: [_jsx(ComposerAttachments, {}), _jsx(ComposerPrimitive.Input, { placeholder: "Send a message...", className: "aui-composer-input mb-1 max-h-32 min-h-16 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 text-base outline-none placeholder:text-muted-foreground focus-visible:ring-0", rows: 1, autoFocus: true, "aria-label": "Message input" }), _jsx(ComposerAction, { agents: agents, selectedAgent: selectedAgent, onSelectAgent: onSelectAgent })] }) }));
81
87
  };
82
- const ComposerAction = () => {
83
- return (_jsxs("div", { className: "aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between", children: [_jsx(ComposerAddAttachment, {}), _jsx(ThreadPrimitive.If, { running: false, children: _jsx(ComposerPrimitive.Send, { asChild: true, children: _jsx(TooltipIconButton, { tooltip: "Send message", side: "bottom", type: "submit", variant: "default", size: "icon", className: "aui-composer-send size-[34px] rounded-full p-1", "aria-label": "Send message", children: _jsx(ArrowUpIcon, { className: "aui-composer-send-icon size-5" }) }) }) }), _jsx(ThreadPrimitive.If, { running: true, children: _jsx(ComposerPrimitive.Cancel, { asChild: true, children: _jsx(Button, { type: "button", variant: "default", size: "icon", className: "aui-composer-cancel size-[34px] rounded-full border border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90", "aria-label": "Stop generating", children: _jsx(Square, { className: "aui-composer-cancel-icon size-3.5 fill-white dark:fill-black" }) }) }) })] }));
88
+ const ComposerAction = ({ agents = [], selectedAgent, onSelectAgent }) => {
89
+ return (_jsxs("div", { className: "aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between", children: [_jsx(ComposerAddAttachment, {}), _jsxs("div", { className: "flex gap-3", children: [agents.length > 0 && (_jsx(AgentDropdown, { agents: agents, selectedAgent: selectedAgent, onSelectAgent: onSelectAgent !== null && onSelectAgent !== void 0 ? onSelectAgent : (() => { }), triggerClassName: "h-9 text-xs" })), _jsx(ThreadPrimitive.If, { running: false, children: _jsx(ComposerPrimitive.Send, { asChild: true, children: _jsx(TooltipIconButton, { tooltip: "Send message", side: "bottom", type: "submit", variant: "default", size: "icon", className: "aui-composer-send size-[34px] rounded-full p-1", "aria-label": "Send message", children: _jsx(ArrowUpIcon, { className: "aui-composer-send-icon size-5" }) }) }) }), _jsx(ThreadPrimitive.If, { running: true, children: _jsx(ComposerPrimitive.Cancel, { asChild: true, children: _jsx(Button, { type: "button", variant: "default", size: "icon", className: "aui-composer-cancel size-[34px] rounded-full border border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90", "aria-label": "Stop generating", children: _jsx(Square, { className: "aui-composer-cancel-icon size-3.5 fill-white dark:fill-black" }) }) }) })] })] }));
84
90
  };
85
91
  const MessageError = () => {
86
92
  return (_jsx(MessagePrimitive.Error, { children: _jsx(ErrorPrimitive.Root, { className: "aui-message-error-root mt-2 rounded-md border border-destructive bg-destructive/10 p-3 text-sm text-destructive dark:bg-destructive/5 dark:text-red-200", children: _jsx(ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) }));
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import { createContext, useContext, useState, useCallback } from 'react';
3
4
  const RefreshContext = createContext(undefined);
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { Copyright } from "lucide-react";
3
4
  export function Footer() {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { AppBreadcrumb } from "../app-breadcrumb";
3
4
  import { ThemeToggleBtn } from "../theme-toggle-btn";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
3
  import { MainSidebar } from './main-sidebar';
3
4
  import { SidebarInset, SidebarProvider } from '../../shadcn/sidebar';
@@ -0,0 +1,6 @@
1
+ export interface ReloadProps {
2
+ isLoading: boolean;
3
+ onReload?: () => void;
4
+ errorMessage?: string;
5
+ }
6
+ export declare function Reload({ isLoading, onReload, errorMessage, }: ReloadProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Loader2, RotateCcw } from "lucide-react";
3
+ export function Reload({ isLoading, onReload, errorMessage, }) {
4
+ if (!isLoading && !errorMessage)
5
+ return null;
6
+ return (_jsx("div", { className: "absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-md rounded-lg transition-all duration-300", children: _jsx("div", { className: "flex flex-col items-center gap-4", children: isLoading ? (_jsx("div", { className: "bg-background/80 p-6 rounded-2xl shadow-xl border border-border/50 backdrop-blur-xl animate-in fade-in zoom-in duration-300", children: _jsx(Loader2, { size: 48, className: "text-primary animate-spin" }) })) : (_jsx("div", { className: "bg-background/80 p-4 rounded-full shadow-lg border border-border/50 backdrop-blur-xl animate-in fade-in zoom-in duration-300", children: _jsx("button", { onClick: onReload, className: "p-3 rounded-full bg-primary/10 hover:bg-primary/20 transition-all text-primary hover:scale-110 active:scale-95", title: errorMessage || "Reload Data", children: _jsx(RotateCcw, { className: "w-6 h-6" }) }) })) }) }));
7
+ }
8
+ ;
@@ -0,0 +1,2 @@
1
+ import { DataTableProps } from "../type";
2
+ export declare function DataTable<T>({ data, columns, keyExtractor, onRowClick }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from "../../../shadcn/table";
3
+ export function DataTable({ data, columns, keyExtractor, onRowClick }) {
4
+ return (_jsx("div", { className: "rounded-md border bg-background shadow-sm overflow-hidden", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsx(TableRow, { className: "bg-muted border-b border-border", children: columns.map((col, index) => (_jsx(TableHead, { className: "font-semibold text-muted-foreground", children: typeof col.header === "function" ? col.header() : col.header }, index))) }) }), _jsx(TableBody, { children: data && data.length > 0 ? (data.map((row) => (_jsx(TableRow, { onClick: () => onRowClick && onRowClick(row), className: `hover:bg-muted/50 transition-colors border-b border-border ${onRowClick ? "cursor-pointer" : ""}`, children: columns.map((col, colIndex) => (_jsx(TableCell, { className: colIndex === 0 ? "font-medium" : "", children: col.cell
5
+ ? col.cell(row)
6
+ : col.accessorKey
7
+ ? String(row[col.accessorKey] || "N/A")
8
+ : null }, colIndex))) }, keyExtractor(onRowClick ? row : row))))) : (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length, className: "h-24 text-center text-muted-foreground", children: "No records found." }) })) })] }) }));
9
+ }
@@ -0,0 +1 @@
1
+ export declare function DataTablePageSize(): import("react/jsx-runtime").JSX.Element;