gentiq 0.8.3 → 0.9.0

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 (44) hide show
  1. package/dist/{checkbox-hWwU3a5K.js → checkbox-DyzncQpE.js} +1680 -1712
  2. package/dist/gentiq-admin.es.js +4089 -3259
  3. package/dist/gentiq-index.es.js +1973 -1380
  4. package/dist/gentiq.css +1 -1
  5. package/dist/src/App.d.ts +1 -1
  6. package/dist/src/ComponentsContext.d.ts +1 -1
  7. package/dist/src/Part.d.ts +2 -1
  8. package/dist/src/admin/components/ErrorBanner.d.ts +7 -0
  9. package/dist/src/admin/components/I18nPreview.d.ts +6 -0
  10. package/dist/src/admin/components/ModalCloseButton.d.ts +7 -0
  11. package/dist/src/admin/components/SectionHeader.d.ts +8 -0
  12. package/dist/src/admin/lib/api.d.ts +109 -16
  13. package/dist/src/admin/pages/settings/ChatSection.d.ts +12 -0
  14. package/dist/src/admin/pages/settings/FieldModeGrid.d.ts +14 -0
  15. package/dist/src/admin/pages/settings/GeneralSection.d.ts +11 -0
  16. package/dist/src/admin/pages/settings/SettingsToggleCard.d.ts +10 -0
  17. package/dist/src/admin/pages/settings/TranslationEditor.d.ts +9 -0
  18. package/dist/src/admin/pages/settings/types.d.ts +12 -0
  19. package/dist/src/admin/pages/users/UserBulkBalanceModal.d.ts +11 -0
  20. package/dist/src/admin/pages/users/UserFormModal.d.ts +13 -0
  21. package/dist/src/admin/pages/users/UserRechargeModal.d.ts +10 -0
  22. package/dist/src/admin/pages/users/UserUsageDialog.d.ts +9 -0
  23. package/dist/src/admin/pages/users/UsersTable.d.ts +21 -0
  24. package/dist/src/components/PromptInputArea.d.ts +1 -1
  25. package/dist/src/components/ai-elements/Conversation.d.ts +10 -0
  26. package/dist/src/hooks/useGentiqAdmin.d.ts +9 -9
  27. package/dist/src/hooks/useGentiqChat.d.ts +3 -2
  28. package/dist/src/index.d.ts +4 -3
  29. package/dist/src/lib/GentiqApiContext.d.ts +12 -0
  30. package/dist/src/lib/api.d.ts +37 -17
  31. package/dist/src/lib/errors.d.ts +6 -5
  32. package/dist/src/lib/messageParts.d.ts +40 -0
  33. package/dist/src/locales/en.json.d.ts +456 -456
  34. package/dist/src/locales/fa.json.d.ts +455 -455
  35. package/dist/src/parts/FilePart.d.ts +1 -1
  36. package/dist/src/parts/ToolPart.d.ts +1 -1
  37. package/dist/src/types.d.ts +188 -14
  38. package/package.json +5 -5
  39. package/dist/src/components/ai-elements/Branch.d.ts +0 -20
  40. package/dist/src/components/ai-elements/Image.d.ts +0 -6
  41. package/dist/src/components/ai-elements/InlineCitation.d.ts +0 -38
  42. package/dist/src/components/ai-elements/Task.d.ts +0 -14
  43. package/dist/src/components/ai-elements/WebPreview.d.ts +0 -34
  44. package/dist/src/components/ui/carousel.d.ts +0 -19
package/dist/src/App.d.ts CHANGED
@@ -12,4 +12,4 @@ export interface ChatUIProps {
12
12
  disclaimer?: ChatProps['disclaimer'];
13
13
  welcome?: import('./types').WelcomeScreenConfig;
14
14
  }
15
- export default function ChatUI({ sidebar, header, components, classNames, disclaimer, welcome }: ChatUIProps): import("react/jsx-runtime").JSX.Element;
15
+ export default function ChatUI({ sidebar, header, components, classNames, disclaimer, welcome, }: ChatUIProps): import("react/jsx-runtime").JSX.Element;
@@ -38,5 +38,5 @@ interface ComponentsProviderProps {
38
38
  * Merges caller-supplied overrides with the framework defaults and makes the
39
39
  * result available to all descendant components via `useComponents()`.
40
40
  */
41
- export declare function ComponentsProvider({ components, history, welcome, threadActions, composer, theme, disclaimer, app, i18n, settings, children }: ComponentsProviderProps): import("react/jsx-runtime").JSX.Element;
41
+ export declare function ComponentsProvider({ components, history, welcome, threadActions, composer, theme, disclaimer, app, i18n, settings, children, }: ComponentsProviderProps): import("react/jsx-runtime").JSX.Element;
42
42
  export {};
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { UIDataTypes, UIMessagePart, UITools, UIMessage } from 'ai';
3
+ import { MessagePart } from './lib/messageParts';
3
4
  export interface PartProps {
4
5
  part: UIMessagePart<UIDataTypes, UITools>;
5
6
  message: UIMessage;
@@ -11,7 +12,7 @@ export interface PartProps {
11
12
  isFinished?: boolean;
12
13
  readonly?: boolean;
13
14
  /** Escape-hatch: return a ReactNode to fully replace rendering for this part. */
14
- renderMessagePart?: (part: any, message: any) => ReactNode;
15
+ renderMessagePart?: (part: MessagePart, message: UIMessage) => ReactNode;
15
16
  chat?: any;
16
17
  }
17
18
  export declare function Part(props: PartProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ interface ErrorBannerProps {
2
+ message: string;
3
+ onDismiss: () => void;
4
+ }
5
+ /** Dismissible inline error banner shared across admin pages. */
6
+ export declare function ErrorBanner({ message, onDismiss }: ErrorBannerProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ interface I18nPreviewProps {
2
+ value: string;
3
+ }
4
+ /** Shows the resolved translation for a value that looks like an i18n key. */
5
+ export declare function I18nPreview({ value }: I18nPreviewProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ interface ModalCloseButtonProps {
2
+ onClick: () => void;
3
+ label?: string;
4
+ }
5
+ /** The "×" button used in the header of hand-rolled admin modals. */
6
+ export declare function ModalCloseButton({ onClick, label }: ModalCloseButtonProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import { LucideIcon } from 'lucide-react';
2
+ interface SectionHeaderProps {
3
+ title: string;
4
+ icon: LucideIcon;
5
+ }
6
+ /** Centered divider + label used to separate sections on the settings page. */
7
+ export declare function SectionHeader({ title, icon: Icon }: SectionHeaderProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -1,3 +1,4 @@
1
+ import { AppSettings } from '../../types';
1
2
  export interface AdminLoginResponse {
2
3
  token: string;
3
4
  admin_id: string;
@@ -50,8 +51,8 @@ export interface UserUsageSummary {
50
51
  export interface UserBulkBalanceFilters {
51
52
  query?: string;
52
53
  user_ids?: string[];
53
- metadata_equals?: Record<string, any>;
54
- metadata_in?: Record<string, any[]>;
54
+ metadata_equals?: Record<string, unknown>;
55
+ metadata_in?: Record<string, unknown[]>;
55
56
  }
56
57
  export interface UserBulkBalanceUpdate {
57
58
  operation: 'set' | 'add' | 'full_charge';
@@ -94,7 +95,7 @@ export interface ThreadItem {
94
95
  id: string;
95
96
  thread_id: string;
96
97
  role: string;
97
- content: any;
98
+ content: unknown;
98
99
  feedback?: string;
99
100
  created_at: string;
100
101
  }
@@ -105,12 +106,104 @@ export interface Job {
105
106
  user_id: string | null;
106
107
  created_at: string;
107
108
  updated_at: string;
108
- metadata: any;
109
+ metadata: unknown;
109
110
  progress: number;
110
111
  message: string | null;
111
- result: any;
112
+ result: unknown;
112
113
  error: string | null;
113
114
  }
115
+ /** Generic `{ status, message }` acknowledgement returned by mutating endpoints. */
116
+ export interface AdminStatusResponse {
117
+ status: string;
118
+ message: string;
119
+ }
120
+ /** Response from creating a user. */
121
+ export interface UserCreateResponse {
122
+ status: string;
123
+ user: {
124
+ id: string;
125
+ phone: string;
126
+ name: string;
127
+ surname: string;
128
+ token: string;
129
+ created_at: string;
130
+ recharge_policy?: RechargePolicy | null;
131
+ };
132
+ }
133
+ /** A user's balance as returned after a balance mutation. */
134
+ export interface AdminUserBalance {
135
+ tokens: number;
136
+ requests: number;
137
+ token_limit: number;
138
+ request_limit: number;
139
+ updated_at: string;
140
+ }
141
+ /** Response from updating a user's balance. */
142
+ export interface UserBalanceUpdateResponse {
143
+ status: string;
144
+ message: string;
145
+ balance: AdminUserBalance;
146
+ }
147
+ /** Response from refreshing a user's auth token. */
148
+ export interface UserTokenRefreshResponse {
149
+ status: string;
150
+ message: string;
151
+ user: {
152
+ id: string;
153
+ phone: string;
154
+ name: string;
155
+ surname: string;
156
+ token: string;
157
+ balance?: AdminUserBalance | null;
158
+ metadata: Record<string, any>;
159
+ };
160
+ }
161
+ export interface AnalyticsTrendItem {
162
+ date: string;
163
+ count: number;
164
+ }
165
+ export interface AnalyticsTokenTrendItem {
166
+ date: string;
167
+ input_tokens: number;
168
+ output_tokens: number;
169
+ requests: number;
170
+ cost_microunits: number;
171
+ unpriced_requests: number;
172
+ }
173
+ export interface AnalyticsFeedbackSentimentItem {
174
+ sentiment: string;
175
+ count: number;
176
+ }
177
+ export interface AnalyticsActiveUser {
178
+ user_id: string;
179
+ name: string;
180
+ thread_count: number;
181
+ }
182
+ /** Response from the analytics endpoint. */
183
+ export interface AdminAnalytics {
184
+ overview: {
185
+ total_users: number;
186
+ total_threads: number;
187
+ total_messages: number;
188
+ total_input_tokens: number;
189
+ total_output_tokens: number;
190
+ total_cost_microunits: number;
191
+ unpriced_requests: number;
192
+ currency: string;
193
+ };
194
+ trends: {
195
+ users: AnalyticsTrendItem[];
196
+ threads: AnalyticsTrendItem[];
197
+ messages: AnalyticsTrendItem[];
198
+ token_usage: AnalyticsTokenTrendItem[];
199
+ };
200
+ distributions: {
201
+ feedback_sentiment: AnalyticsFeedbackSentimentItem[];
202
+ };
203
+ active_users: AnalyticsActiveUser[];
204
+ }
205
+ /** Request body accepted by the settings update endpoint (all fields optional). */
206
+ export type AppSettingsUpdateInput = Partial<Omit<AppSettings, 'updated_at'>>;
114
207
  export declare class AdminAPI {
115
208
  private token;
116
209
  constructor();
@@ -130,8 +223,8 @@ export declare class AdminAPI {
130
223
  name?: string;
131
224
  password?: string;
132
225
  permissions?: string[];
133
- }): Promise<any>;
134
- deleteAdmin(adminId: string): Promise<any>;
226
+ }): Promise<AdminStatusResponse>;
227
+ deleteAdmin(adminId: string): Promise<AdminStatusResponse>;
135
228
  listPermissions(): Promise<{
136
229
  permissions: string[];
137
230
  }>;
@@ -153,7 +246,7 @@ export declare class AdminAPI {
153
246
  users: User[];
154
247
  count: number;
155
248
  }>;
156
- createUser(phone: string, name: string, surname: string, tokens?: number, requests?: number, token_limit?: number, request_limit?: number, metadata?: Record<string, any>, recharge_policy?: RechargePolicyInput): Promise<any>;
249
+ createUser(phone: string, name: string, surname: string, tokens?: number, requests?: number, token_limit?: number, request_limit?: number, metadata?: Record<string, any>, recharge_policy?: RechargePolicyInput): Promise<UserCreateResponse>;
157
250
  updateUser(userId: string, data: {
158
251
  phone?: string;
159
252
  name?: string;
@@ -164,8 +257,8 @@ export declare class AdminAPI {
164
257
  status: string;
165
258
  user: User;
166
259
  }>;
167
- deleteUser(userId: string): Promise<any>;
168
- updateUserBalance(userId: string, tokens: number, requests: number, token_limit?: number, request_limit?: number): Promise<any>;
260
+ deleteUser(userId: string): Promise<AdminStatusResponse>;
261
+ updateUserBalance(userId: string, tokens: number, requests: number, token_limit?: number, request_limit?: number): Promise<UserBalanceUpdateResponse>;
169
262
  bulkUpdateUserBalance(data: UserBulkBalanceUpdate): Promise<{
170
263
  status: string;
171
264
  matched: number;
@@ -176,17 +269,17 @@ export declare class AdminAPI {
176
269
  matched: number;
177
270
  updated: number;
178
271
  }>;
179
- refreshUserToken(userId: string): Promise<any>;
272
+ refreshUserToken(userId: string): Promise<UserTokenRefreshResponse>;
180
273
  getUserUsageSummary(userId: string): Promise<UserUsageSummary>;
181
- getAnalytics(days?: number): Promise<any>;
274
+ getAnalytics(days?: number): Promise<AdminAnalytics>;
182
275
  listJobs(limit?: number, type?: string): Promise<{
183
276
  jobs: Job[];
184
277
  count: number;
185
278
  }>;
186
- cancelJob(jobId: string): Promise<any>;
187
- getSettings(): Promise<any>;
188
- updateSettings(data: any): Promise<any>;
189
- resetSettings(): Promise<any>;
279
+ cancelJob(jobId: string): Promise<AdminStatusResponse>;
280
+ getSettings(): Promise<AppSettings>;
281
+ updateSettings(data: AppSettingsUpdateInput): Promise<AppSettings>;
282
+ resetSettings(): Promise<AdminStatusResponse>;
190
283
  getAttachmentBlob(objectName: string): Promise<Blob>;
191
284
  }
192
285
  export declare const adminAPI: AdminAPI;
@@ -0,0 +1,12 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { UserMetadataField } from '../../../types';
3
+ import { AdminSettingsState } from './types';
4
+ interface ChatSectionProps {
5
+ settings: AdminSettingsState;
6
+ setSettings: Dispatch<SetStateAction<AdminSettingsState>>;
7
+ userMetadataFields: UserMetadataField[];
8
+ isRtl: boolean;
9
+ }
10
+ /** Chat experience settings: greetings, feature toggles, and settings-tab field modes. */
11
+ export declare function ChatSection({ settings, setSettings, userMetadataFields, isRtl, }: ChatSectionProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,14 @@
1
+ import { SettingsFieldMode } from '../../../types';
2
+ interface FieldModeGridProps {
3
+ title: string;
4
+ fields: {
5
+ id: string;
6
+ label: string;
7
+ }[];
8
+ values: Record<string, SettingsFieldMode>;
9
+ onChange: (id: string, mode: SettingsFieldMode) => void;
10
+ columns?: 2 | 4;
11
+ }
12
+ /** A titled grid of per-field visibility/mode selects (editable / faded / hidden). */
13
+ export declare function FieldModeGrid({ title, fields, values, onChange, columns, }: FieldModeGridProps): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { AdminSettingsState } from './types';
3
+ interface GeneralSectionProps {
4
+ settings: AdminSettingsState;
5
+ setSettings: Dispatch<SetStateAction<AdminSettingsState>>;
6
+ accentValue: string;
7
+ accentIsValid: boolean;
8
+ }
9
+ /** App-name, language and appearance (theme + accent) settings. */
10
+ export declare function GeneralSection({ settings, setSettings, accentValue, accentIsValid, }: GeneralSectionProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,10 @@
1
+ interface SettingsToggleCardProps {
2
+ title: string;
3
+ help: string;
4
+ checked: boolean;
5
+ onCheckedChange: (checked: boolean) => void;
6
+ className?: string;
7
+ }
8
+ /** A bordered card pairing a labeled description with a toggle switch. */
9
+ export declare function SettingsToggleCard({ title, help, checked, onCheckedChange, className, }: SettingsToggleCardProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ /** Nested i18n bundle the translation editor reads/writes: lang → namespace → key → value. */
2
+ export type TranslationStore = Record<string, Record<string, Record<string, string>>>;
3
+ interface TranslationEditorProps {
4
+ translations: TranslationStore;
5
+ onChange: (next: TranslationStore) => void;
6
+ }
7
+ /** JSON editor for the per-language / per-namespace i18n bundles. */
8
+ export declare function TranslationEditor({ translations, onChange }: TranslationEditorProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ import { AppSettings, SettingsFieldMode } from '../../../types';
2
+ import { TranslationStore } from './TranslationEditor';
3
+ /**
4
+ * Local editor state — the backend {@link AppSettings} with the loosely-typed
5
+ * `translations` and per-section field maps narrowed to the shapes the settings page edits.
6
+ */
7
+ export type AdminSettingsState = Omit<AppSettings, 'translations' | 'settings_general_fields' | 'settings_profile_fields' | 'settings_account_fields'> & {
8
+ translations: TranslationStore;
9
+ settings_general_fields: Record<string, SettingsFieldMode>;
10
+ settings_profile_fields: Record<string, SettingsFieldMode>;
11
+ settings_account_fields: Record<string, SettingsFieldMode>;
12
+ };
@@ -0,0 +1,11 @@
1
+ import { UserMetadataField } from '../../../types';
2
+ interface UserBulkBalanceModalProps {
3
+ searchQuery: string;
4
+ userMetadataFields: UserMetadataField[];
5
+ onClose: () => void;
6
+ onApplied: () => void;
7
+ onError: (message: string) => void;
8
+ }
9
+ /** Modal to apply balance and/or renewal-policy changes to many users at once. */
10
+ export declare function UserBulkBalanceModal({ searchQuery, userMetadataFields, onClose, onApplied, onError, }: UserBulkBalanceModalProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,13 @@
1
+ import { User } from '../../lib/api';
2
+ import { AppSettings, UserMetadataField } from '../../../types';
3
+ interface UserFormModalProps {
4
+ editingUser: User | null;
5
+ appSettings: AppSettings | null;
6
+ userMetadataFields: UserMetadataField[];
7
+ onClose: () => void;
8
+ onSaved: () => void;
9
+ onError: (message: string) => void;
10
+ }
11
+ /** Add / edit a single user, including initial balance, auto-recharge and metadata. */
12
+ export declare function UserFormModal({ editingUser, appSettings, userMetadataFields, onClose, onSaved, onError, }: UserFormModalProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,10 @@
1
+ import { User } from '../../lib/api';
2
+ interface UserRechargeModalProps {
3
+ user: User;
4
+ onClose: () => void;
5
+ onSaved: () => void;
6
+ onError: (message: string) => void;
7
+ }
8
+ /** Modal to top up / set the token & request balance of a single user. */
9
+ export declare function UserRechargeModal({ user, onClose, onSaved, onError }: UserRechargeModalProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { User } from '../../lib/api';
2
+ interface UserUsageDialogProps {
3
+ user: User | null;
4
+ onClose: () => void;
5
+ onError: (message: string) => void;
6
+ }
7
+ /** Loads and displays a user's aggregate usage summary in a dialog. */
8
+ export declare function UserUsageDialog({ user, onClose, onError }: UserUsageDialogProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,21 @@
1
+ import { User } from '../../lib/api';
2
+ import { UserMetadataField } from '../../../types';
3
+ export type SortField = 'phone' | 'name' | 'surname';
4
+ export type SortOrder = 'asc' | 'desc';
5
+ interface UsersTableProps {
6
+ users: User[];
7
+ loading: boolean;
8
+ totalCount: number;
9
+ userMetadataFields: UserMetadataField[];
10
+ sortBy: SortField;
11
+ sortOrder: SortOrder;
12
+ onSort: (field: SortField) => void;
13
+ onLoadMore: () => void;
14
+ onUsage: (user: User) => void;
15
+ onEdit: (user: User) => void;
16
+ onRecharge: (user: User) => void;
17
+ onCopyToken: (user: User) => void;
18
+ onDelete: (userId: string) => void;
19
+ }
20
+ export declare function UsersTable({ users, loading, totalCount, userMetadataFields, sortBy, sortOrder, onSort, onLoadMore, onUsage, onEdit, onRecharge, onCopyToken, onDelete, }: UsersTableProps): import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -8,5 +8,5 @@ interface PromptInputAreaProps {
8
8
  conversationId?: string;
9
9
  className?: string;
10
10
  }
11
- export declare function PromptInputArea({ onSend, status, isLastMessageFinished, stop, isErrorVisible, conversationId, className }: PromptInputAreaProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function PromptInputArea({ onSend, status, isLastMessageFinished, stop, isErrorVisible, conversationId, className, }: PromptInputAreaProps): import("react/jsx-runtime").JSX.Element;
12
12
  export {};
@@ -5,5 +5,15 @@ export type ConversationProps = ComponentProps<typeof StickToBottom>;
5
5
  export declare const Conversation: ({ className, ...props }: ConversationProps) => import("react/jsx-runtime").JSX.Element;
6
6
  export type ConversationContentProps = ComponentProps<typeof StickToBottom.Content>;
7
7
  export declare const ConversationContent: ({ className, ...props }: ConversationContentProps) => import("react/jsx-runtime").JSX.Element;
8
+ /**
9
+ * Forces a scroll to the bottom the moment the user submits a message, even if
10
+ * they had scrolled up. Must render inside <Conversation> to read the
11
+ * stick-to-bottom context. `use-stick-to-bottom` only auto-sticks while the
12
+ * viewport is already at the bottom, so a fresh send from a scrolled-up
13
+ * position needs this nudge.
14
+ */
15
+ export declare const ConversationScrollOnSubmit: ({ status }: {
16
+ status: string;
17
+ }) => null;
8
18
  export type ConversationScrollButtonProps = ComponentProps<typeof Button>;
9
19
  export declare const ConversationScrollButton: ({ className, ...props }: ConversationScrollButtonProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,9 +1,9 @@
1
- export declare function useAdminUsers(skip?: number, limit?: number, query?: string): import('@tanstack/react-query').UseQueryResult<{
1
+ export declare function useAdminUsers(skip?: number, limit?: number, query?: string, sortBy?: 'phone' | 'name' | 'surname', sortOrder?: 'asc' | 'desc'): import('@tanstack/react-query').UseQueryResult<{
2
2
  users: import('../admin/lib/api').User[];
3
3
  count: number;
4
4
  }, Error>;
5
5
  export declare function useAdminUsersMutations(): {
6
- createUser: import('@tanstack/react-query').UseMutationResult<any, Error, {
6
+ createUser: import('@tanstack/react-query').UseMutationResult<import('../admin/lib/api').UserCreateResponse, Error, {
7
7
  phone: string;
8
8
  name: string;
9
9
  surname: string;
@@ -21,15 +21,15 @@ export declare function useAdminUsersMutations(): {
21
21
  surname?: string;
22
22
  };
23
23
  }, unknown>;
24
- deleteUser: import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
25
- updateBalance: import('@tanstack/react-query').UseMutationResult<any, Error, {
24
+ deleteUser: import('@tanstack/react-query').UseMutationResult<import('../admin/lib/api').AdminStatusResponse, Error, string, unknown>;
25
+ updateBalance: import('@tanstack/react-query').UseMutationResult<import('../admin/lib/api').UserBalanceUpdateResponse, Error, {
26
26
  userId: string;
27
27
  tokens: number;
28
28
  requests: number;
29
29
  }, unknown>;
30
- refreshToken: import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
30
+ refreshToken: import('@tanstack/react-query').UseMutationResult<import('../admin/lib/api').UserTokenRefreshResponse, Error, string, unknown>;
31
31
  };
32
- export declare function useAdminAnalytics(days?: number): import('@tanstack/react-query').UseQueryResult<any, Error>;
32
+ export declare function useAdminAnalytics(days?: number): import('@tanstack/react-query').UseQueryResult<import('../admin/lib/api').AdminAnalytics, Error>;
33
33
  export declare function useAdminAdmins(): import('@tanstack/react-query').UseQueryResult<{
34
34
  admins: import('../admin/lib/api').Admin[];
35
35
  }, Error>;
@@ -40,7 +40,7 @@ export declare function useAdminAdminsMutations(): {
40
40
  name: string;
41
41
  permissions: string[];
42
42
  }, unknown>;
43
- updateAdmin: import('@tanstack/react-query').UseMutationResult<any, Error, {
43
+ updateAdmin: import('@tanstack/react-query').UseMutationResult<import('../admin/lib/api').AdminStatusResponse, Error, {
44
44
  adminId: string;
45
45
  data: {
46
46
  name?: string;
@@ -48,7 +48,7 @@ export declare function useAdminAdminsMutations(): {
48
48
  permissions?: string[];
49
49
  };
50
50
  }, unknown>;
51
- deleteAdmin: import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
51
+ deleteAdmin: import('@tanstack/react-query').UseMutationResult<import('../admin/lib/api').AdminStatusResponse, Error, string, unknown>;
52
52
  };
53
53
  export declare function useAdminThreads(skip?: number, limit?: number, query?: string, feedback?: string): import('@tanstack/react-query').UseQueryResult<{
54
54
  threads: import('../admin/lib/api').Thread[];
@@ -64,7 +64,7 @@ export declare function useAdminJobs(limit?: number, type?: string): import('@ta
64
64
  count: number;
65
65
  }, Error>;
66
66
  export declare function useAdminJobsMutations(): {
67
- cancelJob: import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
67
+ cancelJob: import('@tanstack/react-query').UseMutationResult<import('../admin/lib/api').AdminStatusResponse, Error, string, unknown>;
68
68
  };
69
69
  export declare function useAdminAuth(): {
70
70
  login: (username: string, password: string) => Promise<import('../admin/lib/api').AdminLoginResponse>;
@@ -1,3 +1,4 @@
1
+ import { UIMessage } from 'ai';
1
2
  import { ChatReference } from '../types';
2
3
  export type ChatStatus = 'idle' | 'loading-history' | 'ready' | 'streaming' | 'error' | 'submitted';
3
4
  export interface UseGentiqChatOptions {
@@ -13,8 +14,8 @@ export declare function useGentiqChat({ onFinish }?: UseGentiqChatOptions): {
13
14
  isErrorHistory: boolean;
14
15
  conversationId: string;
15
16
  id: string;
16
- setMessages: (messages: import('ai').UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[] | ((messages: import('ai').UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[]) => import('ai').UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[])) => void;
17
- messages: import('ai').UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[];
17
+ setMessages: (messages: UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[] | ((messages: UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[]) => UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[])) => void;
18
+ messages: UIMessage<unknown, import('ai').UIDataTypes, import('ai').UITools>[];
18
19
  regenerate: ({ messageId, ...options }?: {
19
20
  messageId?: string;
20
21
  } & import('ai').ChatRequestOptions) => Promise<void>;
@@ -1,6 +1,7 @@
1
1
  export { GentiqProvider, type GentiqProviderProps } from './GentiqProvider';
2
2
  export * from './types';
3
- export { userAPI } from './lib/api';
3
+ export { createGentiqApi, type GentiqApi } from './lib/api';
4
+ export { useGentiqApi } from './lib/GentiqApiContext';
4
5
  export { default as ChatUI, type ChatUIProps } from './App';
5
6
  export { default as Chat, type ChatProps } from './Chat';
6
7
  export { Part, type PartProps } from './Part';
@@ -17,11 +18,11 @@ export { SettingsDialog } from './components/SettingsDialog';
17
18
  export { WelcomeScreen } from './components/WelcomeScreen';
18
19
  export { AppSidebar } from './components/AppSidebar';
19
20
  export { SidebarProvider } from './components/ui/sidebar';
20
- export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from './components/ui/select';
21
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, } from './components/ui/select';
21
22
  export { default as RequireAuth } from './components/RequireAuth';
22
23
  export { default as UserLoginPage } from './pages/UserLoginPage';
23
24
  export { default as SharedChatView } from './pages/SharedChatView';
24
25
  export { useGentiqChat } from './hooks/useGentiqChat';
25
- export { useGentiqUser, type UseGentiqUserOptions, } from './hooks/useGentiqUser';
26
+ export { useGentiqUser, type UseGentiqUserOptions } from './hooks/useGentiqUser';
26
27
  export { useComponents } from './ComponentsContext';
27
28
  export { useTranslation, withTranslation, Translation, Trans } from 'react-i18next';
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ import { GentiqApi } from './api';
3
+ /**
4
+ * Access the API client of the nearest {@link GentiqProvider}.
5
+ *
6
+ * @throws if called outside a `GentiqProvider`.
7
+ */
8
+ export declare function useGentiqApi(): GentiqApi;
9
+ export declare function GentiqApiProvider({ api, children }: {
10
+ api: GentiqApi;
11
+ children: ReactNode;
12
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,20 +1,39 @@
1
- import { GentiqConfig, GentiqEndpoints, GentiqUser } from '../types';
2
- export declare const userAPI: {
3
- init: (config: GentiqConfig) => void;
1
+ import { AppConfigResponse, AuthResponse, FeedbackResponse, GentiqConfig, GentiqEndpoints, GentiqUser, RegisterResponse, ShareThreadResponse, SharedThreadResponse, StatusResponse, ThreadHistoryResponse, ThreadMessagesResponse, UserBalance } from '../types';
2
+ /** Endpoint override functions take string path segments and return a path. */
3
+ type EndpointFn = (...args: string[]) => string;
4
+ /**
5
+ * The user-facing API client. One instance per {@link createGentiqApi} call,
6
+ * each owning its own config and auth adapter so multiple `GentiqProvider`s
7
+ * (multi-tenant / multi-backend) never clobber one another's state.
8
+ *
9
+ * Obtain the active instance with `useGentiqApi()` inside the provider tree;
10
+ * call `createGentiqApi()` directly only for tests or non-React usage.
11
+ */
12
+ export type GentiqApi = ReturnType<typeof createGentiqApi>;
13
+ /**
14
+ * Create an isolated Gentiq API client. The returned instance closes over its
15
+ * own `config`/`authAdapter`; reconfigure it later via {@link GentiqApi.configure}.
16
+ */
17
+ export declare function createGentiqApi(initialConfig?: GentiqConfig): {
18
+ /**
19
+ * Merge new config into this instance. Safe to call repeatedly (e.g. when
20
+ * the provider re-resolves config after fetching dynamic settings).
21
+ */
22
+ configure: (next: GentiqConfig) => void;
4
23
  getConfig: () => GentiqConfig;
5
24
  getToken: () => string | null;
6
25
  setToken: (token: string) => void;
7
26
  clearToken: () => void;
8
27
  getHeaders: () => Record<string, string>;
9
- getEndpoint: (key: keyof GentiqEndpoints, fallback: string | ((...args: any[]) => string), ...args: any[]) => string;
10
- handleResponse: (res: Response, fallbackMessage?: string) => Promise<any>;
11
- login: (phone: string, password: string) => Promise<any>;
12
- register: (phone: string, password: string, name: string, surname: string, metadata?: Record<string, any>) => Promise<any>;
13
- getBalance: () => Promise<any>;
14
- getHistory: (skip?: number, limit?: number) => Promise<any>;
15
- getThreadMessages: (threadId: string) => Promise<any>;
16
- deleteThread: (threadId: string) => Promise<any>;
17
- updateThreadTitle: (threadId: string, title: string) => Promise<any>;
28
+ getEndpoint: (key: keyof GentiqEndpoints, fallback: string | EndpointFn, ...args: string[]) => string;
29
+ handleResponse: <T = unknown>(res: Response, fallbackMessage?: string) => Promise<T>;
30
+ login: (phone: string, password: string) => Promise<AuthResponse>;
31
+ register: (phone: string, password: string, name: string, surname: string, metadata?: Record<string, any>) => Promise<RegisterResponse>;
32
+ getBalance: () => Promise<UserBalance>;
33
+ getHistory: (skip?: number, limit?: number) => Promise<ThreadHistoryResponse>;
34
+ getThreadMessages: (threadId: string) => Promise<ThreadMessagesResponse>;
35
+ deleteThread: (threadId: string) => Promise<StatusResponse>;
36
+ updateThreadTitle: (threadId: string, title: string) => Promise<StatusResponse>;
18
37
  /**
19
38
  * Fetch an attachment from the Minio-backed proxy endpoint and return
20
39
  * a local blob URL usable in <img src>. Caller should revoke via
@@ -26,7 +45,7 @@ export declare const userAPI: {
26
45
  * a local blob URL.
27
46
  */
28
47
  getPublicAttachmentBlobUrl(object_name: string): Promise<string>;
29
- saveFeedback: (threadId: string, messageId: string, sentiment: "like" | "dislike" | null) => Promise<any>;
48
+ saveFeedback: (threadId: string, messageId: string, sentiment: "like" | "dislike" | null) => Promise<FeedbackResponse>;
30
49
  getMe: () => Promise<GentiqUser>;
31
50
  updateMe: (data: {
32
51
  name?: string;
@@ -35,8 +54,9 @@ export declare const userAPI: {
35
54
  password?: string;
36
55
  metadata?: Record<string, any>;
37
56
  }) => Promise<GentiqUser>;
38
- pinThread: (threadId: string, pinned: boolean) => Promise<any>;
39
- shareThread: (threadId: string) => Promise<any>;
40
- getSharedThread: (shareId: string) => Promise<any>;
41
- getAppConfig: () => Promise<any>;
57
+ pinThread: (threadId: string, pinned: boolean) => Promise<StatusResponse>;
58
+ shareThread: (threadId: string) => Promise<ShareThreadResponse>;
59
+ getSharedThread: (shareId: string) => Promise<SharedThreadResponse>;
60
+ getAppConfig: () => Promise<AppConfigResponse>;
42
61
  };
62
+ export {};