@kite-copilot/chat-panel 0.2.29 → 0.2.33

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/README.md CHANGED
@@ -49,6 +49,10 @@ const chat = createKiteChat({
49
49
  userId: 'user-123',
50
50
  orgId: 'org-456',
51
51
  agentUrl: 'https://your-api.example.com',
52
+ // Optional: Pass user info for session tracking in control center
53
+ userName: 'John Doe',
54
+ userEmail: 'john@example.com',
55
+ userOrganization: 'Acme Inc',
52
56
  onNavigate: (page, subtab) => {
53
57
  router.push(`/${page}${subtab ? `?tab=${subtab}` : ''}`);
54
58
  },
@@ -197,8 +201,13 @@ function App() {
197
201
  <>
198
202
  <YourExistingApp />
199
203
  {/* Just add this - no layout changes needed */}
200
- <ChatPanelWithToggle
204
+ <ChatPanelWithToggle
201
205
  agentUrl="https://your-api.example.com"
206
+ userId="user-123"
207
+ orgId="org-456"
208
+ userName="John Doe"
209
+ userEmail="john@example.com"
210
+ userOrganization="Acme Inc"
202
211
  onNavigate={(page) => router.push(`/${page}`)}
203
212
  />
204
213
  </>
@@ -279,6 +288,29 @@ The endpoint should return:
279
288
  ]
280
289
  ```
281
290
 
291
+ ## User Info & Session Tracking
292
+
293
+ Pass user information to enable session tracking in the control center. This allows support agents to see who they're chatting with when conversations are escalated.
294
+
295
+ ```ts
296
+ const chat = createKiteChat({
297
+ userId: 'user-123',
298
+ orgId: 'org-456',
299
+ // Optional user info for control center display
300
+ userName: 'John Doe',
301
+ userEmail: 'john@example.com',
302
+ userOrganization: 'Acme Inc',
303
+ });
304
+ ```
305
+
306
+ | Field | Description |
307
+ |-------|-------------|
308
+ | `userName` | Displayed in conversations list and live chat |
309
+ | `userEmail` | Shown in user details panel |
310
+ | `userOrganization` | Helps support agents identify the customer's company |
311
+
312
+ **Note:** If user info is not provided, placeholder values ("Anonymous User", "Not provided", "Unknown") will be displayed in the control center.
313
+
282
314
  ## API Reference
283
315
 
284
316
  ### createKiteChat(config)
@@ -293,6 +325,9 @@ Creates a new chat instance with explicit lifecycle control.
293
325
  | `orgId` | `string` | Yes | Organization identifier |
294
326
  | `agentUrl` | `string` | No | Backend agent API URL |
295
327
  | `currentPage` | `string` | No | Current page context |
328
+ | `userName` | `string` | No | User's display name (for control center) |
329
+ | `userEmail` | `string` | No | User's email address (for control center) |
330
+ | `userOrganization` | `string` | No | User's organization name (for control center) |
296
331
  | `theme` | `'light' \| 'dark' \| 'system'` | No | Theme preference |
297
332
  | `startingQuestions` | `StartingQuestion[]` | No | Custom starting questions |
298
333
  | `startingQuestionsEndpoint` | `string` | No | URL to fetch per-user questions |
@@ -327,6 +362,11 @@ import { ChatPanelWithToggle } from '@kite-copilot/chat-panel';
327
362
  |------|------|---------|-------------|
328
363
  | `agentUrl` | `string` | `localhost:5002` | Backend agent URL |
329
364
  | `currentPage` | `string` | - | Current page for context |
365
+ | `userId` | `string` | - | Unique user identifier |
366
+ | `orgId` | `string` | - | Organization identifier |
367
+ | `userName` | `string` | - | User's display name (for control center) |
368
+ | `userEmail` | `string` | - | User's email address (for control center) |
369
+ | `userOrganization` | `string` | - | User's organization name (for control center) |
330
370
  | `defaultOpen` | `boolean` | `false` | Initial open state (uncontrolled) |
331
371
  | `isOpen` | `boolean` | - | Controlled open state |
332
372
  | `onOpenChange` | `(isOpen: boolean) => void` | - | Called when open state changes |
@@ -421,7 +461,10 @@ Main chat endpoint for streaming responses.
421
461
  "user_id": "user-123",
422
462
  "org_id": "org-456",
423
463
  "message": "user message",
424
- "current_page": "dashboard"
464
+ "current_page": "dashboard",
465
+ "user_name": "John Doe",
466
+ "user_email": "john@example.com",
467
+ "user_organization": "Acme Inc"
425
468
  }
426
469
  ```
427
470
 
package/dist/auto.cjs CHANGED
@@ -1313,7 +1313,12 @@ function ChatPanel({
1313
1313
  currentPage,
1314
1314
  agentUrl = DEFAULT_AGENT_URL,
1315
1315
  startingQuestions: startingQuestionsProp,
1316
- startingQuestionsEndpoint
1316
+ startingQuestionsEndpoint,
1317
+ userId,
1318
+ orgId,
1319
+ userName,
1320
+ userEmail,
1321
+ userOrganization
1317
1322
  } = {}) {
1318
1323
  const [messages, setMessages] = React4.useState(initialMessages);
1319
1324
  const [input, setInput] = React4.useState("");
@@ -1884,7 +1889,12 @@ function ChatPanel({
1884
1889
  body: JSON.stringify({
1885
1890
  session_id: sessionId,
1886
1891
  message: userText,
1887
- current_page: currentPage || "dashboard"
1892
+ current_page: currentPage || "dashboard",
1893
+ user_id: userId,
1894
+ user_name: userName,
1895
+ user_email: userEmail,
1896
+ user_organization: userOrganization,
1897
+ org_id: orgId
1888
1898
  }),
1889
1899
  signal: controller.signal
1890
1900
  });
@@ -2087,9 +2097,6 @@ function ChatPanel({
2087
2097
  };
2088
2098
  setMessages((prev) => [...prev, escalationMessage]);
2089
2099
  } else if (eventType === "token") {
2090
- if (process.env.NODE_ENV === "development") {
2091
- console.debug("[SSE] Token delta:", data.delta?.length || 0, "chars");
2092
- }
2093
2100
  }
2094
2101
  } catch (parseError) {
2095
2102
  console.error("Failed to parse SSE event:", parseError);
@@ -2147,6 +2154,7 @@ ${userText}`
2147
2154
  formData.append("message", userText);
2148
2155
  formData.append("session_id", sessionId);
2149
2156
  formData.append("current_page", currentPage || "dashboard");
2157
+ if (orgId) formData.append("org_id", orgId);
2150
2158
  const controller = new AbortController();
2151
2159
  const timeoutId = setTimeout(() => controller.abort(), 12e4);
2152
2160
  const response = await fetch(`${agentUrl}/chat/bulk/stream`, {
@@ -2958,10 +2966,7 @@ ${userText}`
2958
2966
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2959
2967
  }
2960
2968
  if (message.role === "agent") {
2961
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-50 border border-blue-200 px-3.5 py-2.5 text-sm text-gray-900 shadow-sm", children: [
2962
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-xs text-blue-600 font-medium mb-1", children: "Support Agent" }),
2963
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") })
2964
- ] }) }, message.id);
2969
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-500 px-3.5 py-2.5 text-sm text-white shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") }) }) }, message.id);
2965
2970
  }
2966
2971
  if (message.kind === "searchSummary") {
2967
2972
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -4154,7 +4159,12 @@ function ChatPanelWithToggle({
4154
4159
  startingQuestionsEndpoint,
4155
4160
  defaultOpen = false,
4156
4161
  isOpen: controlledIsOpen,
4157
- onOpenChange
4162
+ onOpenChange,
4163
+ userId,
4164
+ orgId,
4165
+ userName,
4166
+ userEmail,
4167
+ userOrganization
4158
4168
  }) {
4159
4169
  const [internalIsOpen, setInternalIsOpen] = React4.useState(defaultOpen);
4160
4170
  const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
@@ -4185,7 +4195,12 @@ function ChatPanelWithToggle({
4185
4195
  currentPage,
4186
4196
  agentUrl,
4187
4197
  startingQuestions,
4188
- startingQuestionsEndpoint
4198
+ startingQuestionsEndpoint,
4199
+ userId,
4200
+ orgId,
4201
+ userName,
4202
+ userEmail,
4203
+ userOrganization
4189
4204
  }
4190
4205
  );
4191
4206
  }
@@ -4238,7 +4253,12 @@ function KiteChatWrapper({
4238
4253
  onNavigate: (page, subtab) => config.onNavigate?.(page, subtab),
4239
4254
  onActionComplete: config.onActionComplete,
4240
4255
  startingQuestions: config.startingQuestions,
4241
- startingQuestionsEndpoint: config.startingQuestionsEndpoint
4256
+ startingQuestionsEndpoint: config.startingQuestionsEndpoint,
4257
+ userId: config.userId,
4258
+ orgId: config.orgId,
4259
+ userName: config.userName,
4260
+ userEmail: config.userEmail,
4261
+ userOrganization: config.userOrganization
4242
4262
  }
4243
4263
  );
4244
4264
  }
package/dist/auto.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-CyoN-YV4.cjs';
1
+ import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-DPFkdPqV.cjs';
2
2
  import 'react/jsx-runtime';
3
3
 
4
4
  /**
package/dist/auto.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-CyoN-YV4.js';
1
+ import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-DPFkdPqV.js';
2
2
  import 'react/jsx-runtime';
3
3
 
4
4
  /**
package/dist/auto.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createKiteChat
3
- } from "./chunk-DGU3KTFD.js";
3
+ } from "./chunk-5BWUHEPW.js";
4
4
 
5
5
  // src/auto.ts
6
6
  function mountKiteChat(config) {
@@ -1312,7 +1312,12 @@ function ChatPanel({
1312
1312
  currentPage,
1313
1313
  agentUrl = DEFAULT_AGENT_URL,
1314
1314
  startingQuestions: startingQuestionsProp,
1315
- startingQuestionsEndpoint
1315
+ startingQuestionsEndpoint,
1316
+ userId,
1317
+ orgId,
1318
+ userName,
1319
+ userEmail,
1320
+ userOrganization
1316
1321
  } = {}) {
1317
1322
  const [messages, setMessages] = React4.useState(initialMessages);
1318
1323
  const [input, setInput] = React4.useState("");
@@ -1883,7 +1888,12 @@ function ChatPanel({
1883
1888
  body: JSON.stringify({
1884
1889
  session_id: sessionId,
1885
1890
  message: userText,
1886
- current_page: currentPage || "dashboard"
1891
+ current_page: currentPage || "dashboard",
1892
+ user_id: userId,
1893
+ user_name: userName,
1894
+ user_email: userEmail,
1895
+ user_organization: userOrganization,
1896
+ org_id: orgId
1887
1897
  }),
1888
1898
  signal: controller.signal
1889
1899
  });
@@ -2086,9 +2096,6 @@ function ChatPanel({
2086
2096
  };
2087
2097
  setMessages((prev) => [...prev, escalationMessage]);
2088
2098
  } else if (eventType === "token") {
2089
- if (process.env.NODE_ENV === "development") {
2090
- console.debug("[SSE] Token delta:", data.delta?.length || 0, "chars");
2091
- }
2092
2099
  }
2093
2100
  } catch (parseError) {
2094
2101
  console.error("Failed to parse SSE event:", parseError);
@@ -2146,6 +2153,7 @@ ${userText}`
2146
2153
  formData.append("message", userText);
2147
2154
  formData.append("session_id", sessionId);
2148
2155
  formData.append("current_page", currentPage || "dashboard");
2156
+ if (orgId) formData.append("org_id", orgId);
2149
2157
  const controller = new AbortController();
2150
2158
  const timeoutId = setTimeout(() => controller.abort(), 12e4);
2151
2159
  const response = await fetch(`${agentUrl}/chat/bulk/stream`, {
@@ -2957,10 +2965,7 @@ ${userText}`
2957
2965
  return /* @__PURE__ */ jsx9("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2958
2966
  }
2959
2967
  if (message.role === "agent") {
2960
- return /* @__PURE__ */ jsx9("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-50 border border-blue-200 px-3.5 py-2.5 text-sm text-gray-900 shadow-sm", children: [
2961
- /* @__PURE__ */ jsx9("div", { className: "text-xs text-blue-600 font-medium mb-1", children: "Support Agent" }),
2962
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") })
2963
- ] }) }, message.id);
2968
+ return /* @__PURE__ */ jsx9("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-500 px-3.5 py-2.5 text-sm text-white shadow-sm", children: /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") }) }) }, message.id);
2964
2969
  }
2965
2970
  if (message.kind === "searchSummary") {
2966
2971
  return /* @__PURE__ */ jsx9(
@@ -4173,7 +4178,12 @@ function ChatPanelWithToggle({
4173
4178
  startingQuestionsEndpoint,
4174
4179
  defaultOpen = false,
4175
4180
  isOpen: controlledIsOpen,
4176
- onOpenChange
4181
+ onOpenChange,
4182
+ userId,
4183
+ orgId,
4184
+ userName,
4185
+ userEmail,
4186
+ userOrganization
4177
4187
  }) {
4178
4188
  const [internalIsOpen, setInternalIsOpen] = React4.useState(defaultOpen);
4179
4189
  const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
@@ -4204,7 +4214,12 @@ function ChatPanelWithToggle({
4204
4214
  currentPage,
4205
4215
  agentUrl,
4206
4216
  startingQuestions,
4207
- startingQuestionsEndpoint
4217
+ startingQuestionsEndpoint,
4218
+ userId,
4219
+ orgId,
4220
+ userName,
4221
+ userEmail,
4222
+ userOrganization
4208
4223
  }
4209
4224
  );
4210
4225
  }
@@ -4271,7 +4286,12 @@ function KiteChatWrapper({
4271
4286
  onNavigate: (page, subtab) => config.onNavigate?.(page, subtab),
4272
4287
  onActionComplete: config.onActionComplete,
4273
4288
  startingQuestions: config.startingQuestions,
4274
- startingQuestionsEndpoint: config.startingQuestionsEndpoint
4289
+ startingQuestionsEndpoint: config.startingQuestionsEndpoint,
4290
+ userId: config.userId,
4291
+ orgId: config.orgId,
4292
+ userName: config.userName,
4293
+ userEmail: config.userEmail,
4294
+ userOrganization: config.userOrganization
4275
4295
  }
4276
4296
  );
4277
4297
  }
@@ -98,8 +98,18 @@ interface ChatPanelProps {
98
98
  startingQuestions?: StartingQuestion[];
99
99
  /** API endpoint to fetch starting questions */
100
100
  startingQuestionsEndpoint?: string;
101
+ /** Unique identifier for the current user */
102
+ userId?: string;
103
+ /** Organization identifier */
104
+ orgId?: string;
105
+ /** User's display name (for personalization and support) */
106
+ userName?: string;
107
+ /** User's email address (for support agent context) */
108
+ userEmail?: string;
109
+ /** User's organization/company name (for support agent context) */
110
+ userOrganization?: string;
101
111
  }
102
- declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
112
+ declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, userId, orgId, userName, userEmail, userOrganization, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
103
113
  /**
104
114
  * PanelToggle - An arrow button on the right edge that toggles the side panel
105
115
  * Shows left arrow when closed (click to open), right arrow when open (click to close)
@@ -144,8 +154,18 @@ interface ChatPanelWithToggleProps {
144
154
  isOpen?: boolean;
145
155
  /** Callback when panel open state changes */
146
156
  onOpenChange?: (isOpen: boolean) => void;
157
+ /** Unique identifier for the current user */
158
+ userId?: string;
159
+ /** Organization identifier */
160
+ orgId?: string;
161
+ /** User's display name (for personalization and support) */
162
+ userName?: string;
163
+ /** User's email address (for support agent context) */
164
+ userEmail?: string;
165
+ /** User's organization/company name (for support agent context) */
166
+ userOrganization?: string;
147
167
  }
148
- declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange, }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
168
+ declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange, userId, orgId, userName, userEmail, userOrganization, }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
149
169
  /**
150
170
  * @deprecated Use ChatPanelWithToggle instead for the new side panel UX
151
171
  */
@@ -206,6 +226,12 @@ interface KiteChatConfig {
206
226
  startingQuestions?: StartingQuestion[];
207
227
  /** API endpoint to fetch starting questions */
208
228
  startingQuestionsEndpoint?: string;
229
+ /** User's display name (optional - for personalization and support) */
230
+ userName?: string;
231
+ /** User's email address (optional - for support agent context) */
232
+ userEmail?: string;
233
+ /** User's organization/company name (optional - for support agent context) */
234
+ userOrganization?: string;
209
235
  }
210
236
  /**
211
237
  * Instance returned by createKiteChat with lifecycle control methods.
@@ -98,8 +98,18 @@ interface ChatPanelProps {
98
98
  startingQuestions?: StartingQuestion[];
99
99
  /** API endpoint to fetch starting questions */
100
100
  startingQuestionsEndpoint?: string;
101
+ /** Unique identifier for the current user */
102
+ userId?: string;
103
+ /** Organization identifier */
104
+ orgId?: string;
105
+ /** User's display name (for personalization and support) */
106
+ userName?: string;
107
+ /** User's email address (for support agent context) */
108
+ userEmail?: string;
109
+ /** User's organization/company name (for support agent context) */
110
+ userOrganization?: string;
101
111
  }
102
- declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
112
+ declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, userId, orgId, userName, userEmail, userOrganization, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
103
113
  /**
104
114
  * PanelToggle - An arrow button on the right edge that toggles the side panel
105
115
  * Shows left arrow when closed (click to open), right arrow when open (click to close)
@@ -144,8 +154,18 @@ interface ChatPanelWithToggleProps {
144
154
  isOpen?: boolean;
145
155
  /** Callback when panel open state changes */
146
156
  onOpenChange?: (isOpen: boolean) => void;
157
+ /** Unique identifier for the current user */
158
+ userId?: string;
159
+ /** Organization identifier */
160
+ orgId?: string;
161
+ /** User's display name (for personalization and support) */
162
+ userName?: string;
163
+ /** User's email address (for support agent context) */
164
+ userEmail?: string;
165
+ /** User's organization/company name (for support agent context) */
166
+ userOrganization?: string;
147
167
  }
148
- declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange, }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
168
+ declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange, userId, orgId, userName, userEmail, userOrganization, }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
149
169
  /**
150
170
  * @deprecated Use ChatPanelWithToggle instead for the new side panel UX
151
171
  */
@@ -206,6 +226,12 @@ interface KiteChatConfig {
206
226
  startingQuestions?: StartingQuestion[];
207
227
  /** API endpoint to fetch starting questions */
208
228
  startingQuestionsEndpoint?: string;
229
+ /** User's display name (optional - for personalization and support) */
230
+ userName?: string;
231
+ /** User's email address (optional - for support agent context) */
232
+ userEmail?: string;
233
+ /** User's organization/company name (optional - for support agent context) */
234
+ userOrganization?: string;
209
235
  }
210
236
  /**
211
237
  * Instance returned by createKiteChat with lifecycle control methods.