@chainlit/react-client 0.2.1 → 0.2.3

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
@@ -59,8 +59,7 @@ const ChatComponent = () => {
59
59
  connect({
60
60
  userEnv: {
61
61
  /* user environment variables */
62
- },
63
- accessToken: 'Bearer YOUR_ACCESS_TOKEN' // Optional Chainlit auth token
62
+ }
64
63
  });
65
64
 
66
65
  return () => {
@@ -93,7 +92,7 @@ const MessagesComponent = () => {
93
92
  return (
94
93
  <div>
95
94
  {messages.map((message) => (
96
- <p key={message.id}>{message.content}</p>
95
+ <p key={message.id}>{message.output}</p>
97
96
  ))}
98
97
  </div>
99
98
  );
@@ -159,12 +158,12 @@ const InteractionComponent = () => {
159
158
  const { sendMessage, replyMessage } = useChatInteract();
160
159
 
161
160
  const handleSendMessage = () => {
162
- const message = { content: 'Hello, World!', id: 'message-id' };
161
+ const message = { output: 'Hello, World!', id: 'message-id' };
163
162
  sendMessage(message);
164
163
  };
165
164
 
166
165
  const handleReplyMessage = () => {
167
- const message = { content: 'Replying to your message', id: 'reply-id' };
166
+ const message = { output: 'Replying to your message', id: 'reply-id' };
168
167
  replyMessage(message);
169
168
  };
170
169
 
package/dist/index.d.mts CHANGED
@@ -7,14 +7,14 @@ import * as swr__internal from 'swr/_internal';
7
7
  import { SWRConfiguration } from 'swr';
8
8
 
9
9
  interface IAction {
10
- description?: string;
10
+ label: string;
11
11
  forId: string;
12
12
  id: string;
13
- label?: string;
13
+ payload: Record<string, unknown>;
14
14
  name: string;
15
15
  onClick: () => void;
16
- value: string;
17
- collapsed: boolean;
16
+ tooltip: string;
17
+ icon?: string;
18
18
  }
19
19
  interface ICallFn {
20
20
  callback: (payload: Record<string, any>) => void;
@@ -22,8 +22,8 @@ interface ICallFn {
22
22
  args: Record<string, any>;
23
23
  }
24
24
 
25
- type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
26
- type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
25
+ type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement | ICustomElement;
26
+ type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement | ICustomElement;
27
27
  type ElementType = IElement['type'];
28
28
  type IElementSize = 'small' | 'medium' | 'large';
29
29
  interface TElement<T> {
@@ -61,6 +61,15 @@ interface IFileElement extends TMessageElement<'file'> {
61
61
  type IPlotlyElement = TMessageElement<'plotly'>;
62
62
  type ITasklistElement = TElement<'tasklist'>;
63
63
  type IDataframeElement = TMessageElement<'dataframe'>;
64
+ interface ICustomElement extends TMessageElement<'custom'> {
65
+ props: Record<string, unknown>;
66
+ }
67
+
68
+ interface ICommand {
69
+ id: string;
70
+ icon: string;
71
+ description: string;
72
+ }
64
73
 
65
74
  interface IFeedback {
66
75
  id?: string;
@@ -78,6 +87,7 @@ interface IStep {
78
87
  threadId?: string;
79
88
  parentId?: string;
80
89
  isError?: boolean;
90
+ command?: string;
81
91
  showInput?: boolean | string;
82
92
  waitForAnswer?: boolean;
83
93
  input?: string;
@@ -87,6 +97,7 @@ interface IStep {
87
97
  end?: number | string;
88
98
  feedback?: IFeedback;
89
99
  language?: string;
100
+ defaultOpen?: boolean;
90
101
  streaming?: boolean;
91
102
  steps?: IStep[];
92
103
  metadata?: Record<string, any>;
@@ -170,22 +181,28 @@ interface IAuthConfig {
170
181
  requireLogin: boolean;
171
182
  passwordAuth: boolean;
172
183
  headerAuth: boolean;
173
- cookieAuth: boolean;
174
184
  oauthProviders: string[];
185
+ default_theme?: 'light' | 'dark';
175
186
  }
176
187
  interface IChainlitConfig {
177
188
  markdown?: string;
178
189
  ui: {
179
190
  name: string;
180
191
  description?: string;
192
+ font_family?: string;
193
+ default_theme?: 'light' | 'dark';
194
+ layout?: 'default' | 'wide';
181
195
  cot: 'hidden' | 'tool_call' | 'full';
182
- default_collapse_content?: boolean;
183
196
  github?: string;
184
- theme: any;
185
197
  custom_css?: string;
186
198
  custom_js?: string;
187
199
  custom_font?: string;
188
200
  custom_meta_image_url?: string;
201
+ header_links?: {
202
+ name: string;
203
+ icon_url: string;
204
+ url: string;
205
+ }[];
189
206
  };
190
207
  features: {
191
208
  spontaneous_file_upload?: {
@@ -237,11 +254,6 @@ declare const useChatInteract: () => {
237
254
  id: string;
238
255
  }>;
239
256
  };
240
- callAction: (action: IAction) => Promise<{
241
- id: string;
242
- status: boolean;
243
- response?: string | undefined;
244
- }> | undefined;
245
257
  clear: () => void;
246
258
  replyMessage: (message: IStep) => void;
247
259
  sendMessage: (message: PartialBy<IStep, 'createdAt' | 'id'>, fileReferences?: IFileRef[]) => void;
@@ -266,11 +278,13 @@ interface ISession {
266
278
  error?: boolean;
267
279
  }
268
280
  declare const threadIdToResumeState: recoil.RecoilState<string | undefined>;
281
+ declare const resumeThreadErrorState: recoil.RecoilState<string | undefined>;
269
282
  declare const chatProfileState: recoil.RecoilState<string | undefined>;
270
283
  declare const sessionIdState: recoil.RecoilState<string>;
271
284
  declare const sessionState: recoil.RecoilState<ISession | undefined>;
272
285
  declare const actionState: recoil.RecoilState<IAction[]>;
273
286
  declare const messagesState: recoil.RecoilState<IStep[]>;
287
+ declare const commandsState: recoil.RecoilState<ICommand[]>;
274
288
  declare const tokenCountState: recoil.RecoilState<number>;
275
289
  declare const loadingState: recoil.RecoilState<boolean>;
276
290
  declare const askUserState: recoil.RecoilState<IAsk | undefined>;
@@ -285,19 +299,20 @@ declare const chatSettingsValueState: recoil.RecoilState<any>;
285
299
  declare const elementState: recoil.RecoilState<IMessageElement[]>;
286
300
  declare const tasklistState: recoil.RecoilState<ITasklistElement[]>;
287
301
  declare const firstUserInteraction: recoil.RecoilState<string | undefined>;
288
- declare const accessTokenState: recoil.RecoilState<string | undefined>;
289
- declare const userState: recoil.RecoilState<IUser | null>;
302
+ declare const userState: recoil.RecoilState<IUser | null | undefined>;
290
303
  declare const configState: recoil.RecoilState<IChainlitConfig | undefined>;
291
304
  declare const authState: recoil.RecoilState<IAuthConfig | undefined>;
292
305
  declare const threadHistoryState: recoil.RecoilState<ThreadHistory | undefined>;
293
- declare const sideViewState: recoil.RecoilState<IMessageElement | undefined>;
306
+ declare const sideViewState: recoil.RecoilState<{
307
+ title: string;
308
+ elements: IMessageElement[];
309
+ } | undefined>;
294
310
  declare const currentThreadIdState: recoil.RecoilState<string | undefined>;
295
311
 
296
312
  declare const useChatSession: () => {
297
- connect: lodash.DebouncedFunc<({ transports, userEnv, accessToken }: {
313
+ connect: lodash.DebouncedFunc<({ transports, userEnv }: {
298
314
  transports?: string[] | undefined;
299
315
  userEnv: Record<string, string>;
300
- accessToken?: string | undefined;
301
316
  }) => void>;
302
317
  disconnect: () => void;
303
318
  session: ISession | undefined;
@@ -316,7 +331,7 @@ declare const useAudio: () => {
316
331
  wavStreamPlayer: any;
317
332
  };
318
333
 
319
- declare const useConfig: (accessToken?: string) => {
334
+ declare const useConfig: () => {
320
335
  config: IChainlitConfig | undefined;
321
336
  error: Error | undefined;
322
337
  isLoading: boolean;
@@ -328,27 +343,19 @@ declare const useAuth: () => {
328
343
  user: null;
329
344
  isReady: boolean;
330
345
  isAuthenticated: boolean;
331
- accessToken: string;
332
346
  logout: () => Promise<void>;
333
- setAccessToken: () => void;
334
347
  setUserFromAPI: () => Promise<void>;
335
- cookieAuth: boolean | undefined;
336
348
  } | {
337
349
  data: IAuthConfig | undefined;
338
- user: IUser | null;
350
+ user: IUser | null | undefined;
339
351
  isReady: boolean;
340
352
  isAuthenticated: boolean;
341
- accessToken: string | undefined;
342
353
  logout: (reload?: boolean) => Promise<void>;
343
- setAccessToken: (token: string) => void;
344
354
  setUserFromAPI: swr__internal.KeyedMutator<IUser>;
345
- cookieAuth: boolean | undefined;
346
355
  };
347
356
 
348
- declare const fetcher: (client: ChainlitAPI, endpoint: string, token?: string) => Promise<any>;
349
- declare function useApi<T>(path?: string | null, { token, ...swrConfig }?: SWRConfiguration & {
350
- token?: string;
351
- }): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
357
+ declare const fetcher: (client: ChainlitAPI, endpoint: string) => Promise<any>;
358
+ declare function useApi<T>(path?: string | null, { ...swrConfig }?: SWRConfiguration): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
352
359
 
353
360
  interface IThreadFilters {
354
361
  search?: string;
@@ -378,36 +385,44 @@ declare class APIBase {
378
385
  buildEndpoint(path: string): string;
379
386
  private getDetailFromErrorResponse;
380
387
  private handleRequestError;
381
- fetch(method: string, path: string, token?: string, data?: Payload, signal?: AbortSignal): Promise<Response>;
382
- get(endpoint: string, token?: string): Promise<Response>;
383
- post(endpoint: string, data: Payload, token?: string, signal?: AbortSignal): Promise<Response>;
384
- put(endpoint: string, data: Payload, token?: string): Promise<Response>;
385
- patch(endpoint: string, data: Payload, token?: string): Promise<Response>;
386
- delete(endpoint: string, data: Payload, token?: string): Promise<Response>;
388
+ fetch(method: string, path: string, data?: Payload, signal?: AbortSignal, headers?: {
389
+ Authorization?: string;
390
+ 'Content-Type'?: string;
391
+ }): Promise<Response>;
392
+ get(endpoint: string): Promise<Response>;
393
+ post(endpoint: string, data: Payload, signal?: AbortSignal): Promise<Response>;
394
+ put(endpoint: string, data: Payload): Promise<Response>;
395
+ patch(endpoint: string, data: Payload): Promise<Response>;
396
+ delete(endpoint: string, data: Payload): Promise<Response>;
387
397
  }
388
398
  declare class ChainlitAPI extends APIBase {
389
399
  headerAuth(): Promise<any>;
400
+ jwtAuth(token: string): Promise<any>;
390
401
  passwordAuth(data: FormData): Promise<any>;
391
- getUser(accessToken?: string): Promise<IUser>;
402
+ getUser(): Promise<IUser>;
392
403
  logout(): Promise<any>;
393
- setFeedback(feedback: IFeedback, accessToken?: string): Promise<{
404
+ setFeedback(feedback: IFeedback): Promise<{
394
405
  success: boolean;
395
406
  feedbackId: string;
396
407
  }>;
397
- deleteFeedback(feedbackId: string, accessToken?: string): Promise<{
408
+ deleteFeedback(feedbackId: string): Promise<{
398
409
  success: boolean;
399
410
  }>;
400
- listThreads(pagination: IPagination, filter: IThreadFilters, accessToken?: string): Promise<{
411
+ listThreads(pagination: IPagination, filter: IThreadFilters): Promise<{
401
412
  pageInfo: IPageInfo;
402
413
  data: IThread[];
403
414
  }>;
404
- deleteThread(threadId: string, accessToken?: string): Promise<any>;
405
- uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string, token?: string): {
415
+ renameThread(threadId: string, name: string): Promise<any>;
416
+ deleteThread(threadId: string): Promise<any>;
417
+ uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string): {
406
418
  xhr: XMLHttpRequest;
407
419
  promise: Promise<{
408
420
  id: string;
409
421
  }>;
410
422
  };
423
+ callAction(action: IAction, sessionId: string): Promise<any>;
424
+ updateElement(element: IElement, sessionId: string): Promise<any>;
425
+ deleteElement(element: IElement, sessionId: string): Promise<any>;
411
426
  getElementUrl(id: string, sessionId: string): string;
412
427
  getLogoEndpoint(theme: string): string;
413
428
  getOAuthEndpoint(provider: string): string;
@@ -429,4 +444,4 @@ declare const WavRenderer: {
429
444
  drawBars: (ctx: CanvasRenderingContext2D, data: Float32Array, cssWidth: number, cssHeight: number, color: string, pointCount?: number, barWidth?: number, barSpacing?: number, center?: boolean) => void;
430
445
  };
431
446
 
432
- export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, IDataframeElement, IElement, IElementSize, IFeedback, IFileElement, IFileRef, IImageElement, IMessageElement, IPageInfo, IPagination, IPdfElement, IPlotlyElement, ISession, IStarter, IStep, ITasklistElement, ITextElement, IThread, IThreadFilters, IToken, IUser, IUserMetadata, IVideoElement, ThreadHistory, UserInput, WavRenderer, accessTokenState, actionState, addMessage, addMessageToParent, askUserState, audioConnectionState, authState, callFnState, chatProfileState, chatSettingsDefaultValueSelector, chatSettingsInputsState, chatSettingsValueState, configState, currentThreadIdState, defaultChainlitContext, deleteMessageById, elementState, fetcher, firstUserInteraction, hasMessageById, isAiSpeakingState, isLastMessage, loadingState, messagesState, nestMessages, sessionIdState, sessionState, sideViewState, tasklistState, threadHistoryState, threadIdToResumeState, tokenCountState, updateMessageById, updateMessageContentById, useApi, useAudio, useAuth, useChatData, useChatInteract, useChatMessages, useChatSession, useConfig, userState, wavRecorderState, wavStreamPlayerState };
447
+ export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, ICommand, ICustomElement, IDataframeElement, IElement, IElementSize, IFeedback, IFileElement, IFileRef, IImageElement, IMessageElement, IPageInfo, IPagination, IPdfElement, IPlotlyElement, ISession, IStarter, IStep, ITasklistElement, ITextElement, IThread, IThreadFilters, IToken, IUser, IUserMetadata, IVideoElement, ThreadHistory, UserInput, WavRenderer, actionState, addMessage, addMessageToParent, askUserState, audioConnectionState, authState, callFnState, chatProfileState, chatSettingsDefaultValueSelector, chatSettingsInputsState, chatSettingsValueState, commandsState, configState, currentThreadIdState, defaultChainlitContext, deleteMessageById, elementState, fetcher, firstUserInteraction, hasMessageById, isAiSpeakingState, isLastMessage, loadingState, messagesState, nestMessages, resumeThreadErrorState, sessionIdState, sessionState, sideViewState, tasklistState, threadHistoryState, threadIdToResumeState, tokenCountState, updateMessageById, updateMessageContentById, useApi, useAudio, useAuth, useChatData, useChatInteract, useChatMessages, useChatSession, useConfig, userState, wavRecorderState, wavStreamPlayerState };
package/dist/index.d.ts CHANGED
@@ -7,14 +7,14 @@ import * as swr__internal from 'swr/_internal';
7
7
  import { SWRConfiguration } from 'swr';
8
8
 
9
9
  interface IAction {
10
- description?: string;
10
+ label: string;
11
11
  forId: string;
12
12
  id: string;
13
- label?: string;
13
+ payload: Record<string, unknown>;
14
14
  name: string;
15
15
  onClick: () => void;
16
- value: string;
17
- collapsed: boolean;
16
+ tooltip: string;
17
+ icon?: string;
18
18
  }
19
19
  interface ICallFn {
20
20
  callback: (payload: Record<string, any>) => void;
@@ -22,8 +22,8 @@ interface ICallFn {
22
22
  args: Record<string, any>;
23
23
  }
24
24
 
25
- type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
26
- type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
25
+ type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement | ICustomElement;
26
+ type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement | ICustomElement;
27
27
  type ElementType = IElement['type'];
28
28
  type IElementSize = 'small' | 'medium' | 'large';
29
29
  interface TElement<T> {
@@ -61,6 +61,15 @@ interface IFileElement extends TMessageElement<'file'> {
61
61
  type IPlotlyElement = TMessageElement<'plotly'>;
62
62
  type ITasklistElement = TElement<'tasklist'>;
63
63
  type IDataframeElement = TMessageElement<'dataframe'>;
64
+ interface ICustomElement extends TMessageElement<'custom'> {
65
+ props: Record<string, unknown>;
66
+ }
67
+
68
+ interface ICommand {
69
+ id: string;
70
+ icon: string;
71
+ description: string;
72
+ }
64
73
 
65
74
  interface IFeedback {
66
75
  id?: string;
@@ -78,6 +87,7 @@ interface IStep {
78
87
  threadId?: string;
79
88
  parentId?: string;
80
89
  isError?: boolean;
90
+ command?: string;
81
91
  showInput?: boolean | string;
82
92
  waitForAnswer?: boolean;
83
93
  input?: string;
@@ -87,6 +97,7 @@ interface IStep {
87
97
  end?: number | string;
88
98
  feedback?: IFeedback;
89
99
  language?: string;
100
+ defaultOpen?: boolean;
90
101
  streaming?: boolean;
91
102
  steps?: IStep[];
92
103
  metadata?: Record<string, any>;
@@ -170,22 +181,28 @@ interface IAuthConfig {
170
181
  requireLogin: boolean;
171
182
  passwordAuth: boolean;
172
183
  headerAuth: boolean;
173
- cookieAuth: boolean;
174
184
  oauthProviders: string[];
185
+ default_theme?: 'light' | 'dark';
175
186
  }
176
187
  interface IChainlitConfig {
177
188
  markdown?: string;
178
189
  ui: {
179
190
  name: string;
180
191
  description?: string;
192
+ font_family?: string;
193
+ default_theme?: 'light' | 'dark';
194
+ layout?: 'default' | 'wide';
181
195
  cot: 'hidden' | 'tool_call' | 'full';
182
- default_collapse_content?: boolean;
183
196
  github?: string;
184
- theme: any;
185
197
  custom_css?: string;
186
198
  custom_js?: string;
187
199
  custom_font?: string;
188
200
  custom_meta_image_url?: string;
201
+ header_links?: {
202
+ name: string;
203
+ icon_url: string;
204
+ url: string;
205
+ }[];
189
206
  };
190
207
  features: {
191
208
  spontaneous_file_upload?: {
@@ -237,11 +254,6 @@ declare const useChatInteract: () => {
237
254
  id: string;
238
255
  }>;
239
256
  };
240
- callAction: (action: IAction) => Promise<{
241
- id: string;
242
- status: boolean;
243
- response?: string | undefined;
244
- }> | undefined;
245
257
  clear: () => void;
246
258
  replyMessage: (message: IStep) => void;
247
259
  sendMessage: (message: PartialBy<IStep, 'createdAt' | 'id'>, fileReferences?: IFileRef[]) => void;
@@ -266,11 +278,13 @@ interface ISession {
266
278
  error?: boolean;
267
279
  }
268
280
  declare const threadIdToResumeState: recoil.RecoilState<string | undefined>;
281
+ declare const resumeThreadErrorState: recoil.RecoilState<string | undefined>;
269
282
  declare const chatProfileState: recoil.RecoilState<string | undefined>;
270
283
  declare const sessionIdState: recoil.RecoilState<string>;
271
284
  declare const sessionState: recoil.RecoilState<ISession | undefined>;
272
285
  declare const actionState: recoil.RecoilState<IAction[]>;
273
286
  declare const messagesState: recoil.RecoilState<IStep[]>;
287
+ declare const commandsState: recoil.RecoilState<ICommand[]>;
274
288
  declare const tokenCountState: recoil.RecoilState<number>;
275
289
  declare const loadingState: recoil.RecoilState<boolean>;
276
290
  declare const askUserState: recoil.RecoilState<IAsk | undefined>;
@@ -285,19 +299,20 @@ declare const chatSettingsValueState: recoil.RecoilState<any>;
285
299
  declare const elementState: recoil.RecoilState<IMessageElement[]>;
286
300
  declare const tasklistState: recoil.RecoilState<ITasklistElement[]>;
287
301
  declare const firstUserInteraction: recoil.RecoilState<string | undefined>;
288
- declare const accessTokenState: recoil.RecoilState<string | undefined>;
289
- declare const userState: recoil.RecoilState<IUser | null>;
302
+ declare const userState: recoil.RecoilState<IUser | null | undefined>;
290
303
  declare const configState: recoil.RecoilState<IChainlitConfig | undefined>;
291
304
  declare const authState: recoil.RecoilState<IAuthConfig | undefined>;
292
305
  declare const threadHistoryState: recoil.RecoilState<ThreadHistory | undefined>;
293
- declare const sideViewState: recoil.RecoilState<IMessageElement | undefined>;
306
+ declare const sideViewState: recoil.RecoilState<{
307
+ title: string;
308
+ elements: IMessageElement[];
309
+ } | undefined>;
294
310
  declare const currentThreadIdState: recoil.RecoilState<string | undefined>;
295
311
 
296
312
  declare const useChatSession: () => {
297
- connect: lodash.DebouncedFunc<({ transports, userEnv, accessToken }: {
313
+ connect: lodash.DebouncedFunc<({ transports, userEnv }: {
298
314
  transports?: string[] | undefined;
299
315
  userEnv: Record<string, string>;
300
- accessToken?: string | undefined;
301
316
  }) => void>;
302
317
  disconnect: () => void;
303
318
  session: ISession | undefined;
@@ -316,7 +331,7 @@ declare const useAudio: () => {
316
331
  wavStreamPlayer: any;
317
332
  };
318
333
 
319
- declare const useConfig: (accessToken?: string) => {
334
+ declare const useConfig: () => {
320
335
  config: IChainlitConfig | undefined;
321
336
  error: Error | undefined;
322
337
  isLoading: boolean;
@@ -328,27 +343,19 @@ declare const useAuth: () => {
328
343
  user: null;
329
344
  isReady: boolean;
330
345
  isAuthenticated: boolean;
331
- accessToken: string;
332
346
  logout: () => Promise<void>;
333
- setAccessToken: () => void;
334
347
  setUserFromAPI: () => Promise<void>;
335
- cookieAuth: boolean | undefined;
336
348
  } | {
337
349
  data: IAuthConfig | undefined;
338
- user: IUser | null;
350
+ user: IUser | null | undefined;
339
351
  isReady: boolean;
340
352
  isAuthenticated: boolean;
341
- accessToken: string | undefined;
342
353
  logout: (reload?: boolean) => Promise<void>;
343
- setAccessToken: (token: string) => void;
344
354
  setUserFromAPI: swr__internal.KeyedMutator<IUser>;
345
- cookieAuth: boolean | undefined;
346
355
  };
347
356
 
348
- declare const fetcher: (client: ChainlitAPI, endpoint: string, token?: string) => Promise<any>;
349
- declare function useApi<T>(path?: string | null, { token, ...swrConfig }?: SWRConfiguration & {
350
- token?: string;
351
- }): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
357
+ declare const fetcher: (client: ChainlitAPI, endpoint: string) => Promise<any>;
358
+ declare function useApi<T>(path?: string | null, { ...swrConfig }?: SWRConfiguration): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
352
359
 
353
360
  interface IThreadFilters {
354
361
  search?: string;
@@ -378,36 +385,44 @@ declare class APIBase {
378
385
  buildEndpoint(path: string): string;
379
386
  private getDetailFromErrorResponse;
380
387
  private handleRequestError;
381
- fetch(method: string, path: string, token?: string, data?: Payload, signal?: AbortSignal): Promise<Response>;
382
- get(endpoint: string, token?: string): Promise<Response>;
383
- post(endpoint: string, data: Payload, token?: string, signal?: AbortSignal): Promise<Response>;
384
- put(endpoint: string, data: Payload, token?: string): Promise<Response>;
385
- patch(endpoint: string, data: Payload, token?: string): Promise<Response>;
386
- delete(endpoint: string, data: Payload, token?: string): Promise<Response>;
388
+ fetch(method: string, path: string, data?: Payload, signal?: AbortSignal, headers?: {
389
+ Authorization?: string;
390
+ 'Content-Type'?: string;
391
+ }): Promise<Response>;
392
+ get(endpoint: string): Promise<Response>;
393
+ post(endpoint: string, data: Payload, signal?: AbortSignal): Promise<Response>;
394
+ put(endpoint: string, data: Payload): Promise<Response>;
395
+ patch(endpoint: string, data: Payload): Promise<Response>;
396
+ delete(endpoint: string, data: Payload): Promise<Response>;
387
397
  }
388
398
  declare class ChainlitAPI extends APIBase {
389
399
  headerAuth(): Promise<any>;
400
+ jwtAuth(token: string): Promise<any>;
390
401
  passwordAuth(data: FormData): Promise<any>;
391
- getUser(accessToken?: string): Promise<IUser>;
402
+ getUser(): Promise<IUser>;
392
403
  logout(): Promise<any>;
393
- setFeedback(feedback: IFeedback, accessToken?: string): Promise<{
404
+ setFeedback(feedback: IFeedback): Promise<{
394
405
  success: boolean;
395
406
  feedbackId: string;
396
407
  }>;
397
- deleteFeedback(feedbackId: string, accessToken?: string): Promise<{
408
+ deleteFeedback(feedbackId: string): Promise<{
398
409
  success: boolean;
399
410
  }>;
400
- listThreads(pagination: IPagination, filter: IThreadFilters, accessToken?: string): Promise<{
411
+ listThreads(pagination: IPagination, filter: IThreadFilters): Promise<{
401
412
  pageInfo: IPageInfo;
402
413
  data: IThread[];
403
414
  }>;
404
- deleteThread(threadId: string, accessToken?: string): Promise<any>;
405
- uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string, token?: string): {
415
+ renameThread(threadId: string, name: string): Promise<any>;
416
+ deleteThread(threadId: string): Promise<any>;
417
+ uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string): {
406
418
  xhr: XMLHttpRequest;
407
419
  promise: Promise<{
408
420
  id: string;
409
421
  }>;
410
422
  };
423
+ callAction(action: IAction, sessionId: string): Promise<any>;
424
+ updateElement(element: IElement, sessionId: string): Promise<any>;
425
+ deleteElement(element: IElement, sessionId: string): Promise<any>;
411
426
  getElementUrl(id: string, sessionId: string): string;
412
427
  getLogoEndpoint(theme: string): string;
413
428
  getOAuthEndpoint(provider: string): string;
@@ -429,4 +444,4 @@ declare const WavRenderer: {
429
444
  drawBars: (ctx: CanvasRenderingContext2D, data: Float32Array, cssWidth: number, cssHeight: number, color: string, pointCount?: number, barWidth?: number, barSpacing?: number, center?: boolean) => void;
430
445
  };
431
446
 
432
- export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, IDataframeElement, IElement, IElementSize, IFeedback, IFileElement, IFileRef, IImageElement, IMessageElement, IPageInfo, IPagination, IPdfElement, IPlotlyElement, ISession, IStarter, IStep, ITasklistElement, ITextElement, IThread, IThreadFilters, IToken, IUser, IUserMetadata, IVideoElement, ThreadHistory, UserInput, WavRenderer, accessTokenState, actionState, addMessage, addMessageToParent, askUserState, audioConnectionState, authState, callFnState, chatProfileState, chatSettingsDefaultValueSelector, chatSettingsInputsState, chatSettingsValueState, configState, currentThreadIdState, defaultChainlitContext, deleteMessageById, elementState, fetcher, firstUserInteraction, hasMessageById, isAiSpeakingState, isLastMessage, loadingState, messagesState, nestMessages, sessionIdState, sessionState, sideViewState, tasklistState, threadHistoryState, threadIdToResumeState, tokenCountState, updateMessageById, updateMessageContentById, useApi, useAudio, useAuth, useChatData, useChatInteract, useChatMessages, useChatSession, useConfig, userState, wavRecorderState, wavStreamPlayerState };
447
+ export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, ICommand, ICustomElement, IDataframeElement, IElement, IElementSize, IFeedback, IFileElement, IFileRef, IImageElement, IMessageElement, IPageInfo, IPagination, IPdfElement, IPlotlyElement, ISession, IStarter, IStep, ITasklistElement, ITextElement, IThread, IThreadFilters, IToken, IUser, IUserMetadata, IVideoElement, ThreadHistory, UserInput, WavRenderer, actionState, addMessage, addMessageToParent, askUserState, audioConnectionState, authState, callFnState, chatProfileState, chatSettingsDefaultValueSelector, chatSettingsInputsState, chatSettingsValueState, commandsState, configState, currentThreadIdState, defaultChainlitContext, deleteMessageById, elementState, fetcher, firstUserInteraction, hasMessageById, isAiSpeakingState, isLastMessage, loadingState, messagesState, nestMessages, resumeThreadErrorState, sessionIdState, sessionState, sideViewState, tasklistState, threadHistoryState, threadIdToResumeState, tokenCountState, updateMessageById, updateMessageContentById, useApi, useAudio, useAuth, useChatData, useChatInteract, useChatMessages, useChatSession, useConfig, userState, wavRecorderState, wavStreamPlayerState };