@luma-ai/react 2.0.0 → 2.0.2
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/CHANGELOG.md +17 -0
- package/dist/chunks/{src-CI0MDOrd.js → src-BuzOHEps.js} +524 -519
- package/dist/chunks/src-BuzOHEps.js.map +1 -0
- package/dist/chunks/{support-cursor-pCpYa13-.js → support-cursor-CzNzBpxv.js} +2 -2
- package/dist/chunks/{support-cursor-pCpYa13-.js.map → support-cursor-CzNzBpxv.js.map} +1 -1
- package/dist/chunks/{visitor-call-CDpkyeoR.js → visitor-call-DY8tUjuJ.js} +3 -3
- package/dist/chunks/{visitor-call-CDpkyeoR.js.map → visitor-call-DY8tUjuJ.js.map} +1 -1
- package/dist/chunks/{visitor-cobrowse-BIyfnFu3.js → visitor-cobrowse-ctLeCxdW.js} +67 -4
- package/dist/chunks/visitor-cobrowse-ctLeCxdW.js.map +1 -0
- package/dist/config-BAC3xPNG.d.ts +97 -0
- package/dist/index-ByvZMuLw.d.ts +415 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/next.d.ts +5 -0
- package/dist/next.js +1 -1
- package/dist/react-router.d.ts +8 -0
- package/dist/react-router.js +1 -1
- package/dist/server.d.ts +31 -0
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/tanstack.d.ts +5 -0
- package/dist/tanstack.js +1 -1
- package/docs/troubleshooting.md +2 -2
- package/package.json +2 -2
- package/dist/chunks/src-CI0MDOrd.js.map +0 -1
- package/dist/chunks/visitor-cobrowse-BIyfnFu3.js.map +0 -1
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { a as SiteContext, n as LumaServer, o as SiteProduct, r as LumaActionDefinition, t as LumaAppearance } from "./config-BAC3xPNG.js";
|
|
2
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
/** Where the assistant may look and which URLs it may open on this website. */
|
|
5
|
+
type SitePolicy = {
|
|
6
|
+
/** Pages with no inspection, guides or navigation (for example an admin area). */
|
|
7
|
+
restrictedPaths: RegExp[];
|
|
8
|
+
/** State-changing URLs the assistant must never open, such as logout. */
|
|
9
|
+
blockedPaths: RegExp[];
|
|
10
|
+
/** Query parameters that make a URL state-changing or secret-bearing. */
|
|
11
|
+
blockedParams: string[];
|
|
12
|
+
/** Regions whose text and controls are never read. */
|
|
13
|
+
privateSelector: string;
|
|
14
|
+
};
|
|
15
|
+
/** A page the assistant may suggest. Relative URLs resolve against this site. */
|
|
16
|
+
type LumaLink = {
|
|
17
|
+
title: string;
|
|
18
|
+
url: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
/** Stable ID; derived from the URL when omitted. */
|
|
21
|
+
id?: string;
|
|
22
|
+
};
|
|
23
|
+
type LumaSiteInfo = {
|
|
24
|
+
name?: string;
|
|
25
|
+
language?: string;
|
|
26
|
+
currency?: string;
|
|
27
|
+
menus?: LumaLink[];
|
|
28
|
+
/** Public page directory. Also used for searchSite when no search function is given. */
|
|
29
|
+
pages?: LumaLink[];
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
type LumaProduct = Omit<SiteProduct, "id" | "image" | "currency" | "type" | "attributes" | "price"> & {
|
|
33
|
+
id?: string;
|
|
34
|
+
image?: string | null;
|
|
35
|
+
price: string | number;
|
|
36
|
+
currency?: string;
|
|
37
|
+
type?: string;
|
|
38
|
+
attributes?: Record<string, string[]>;
|
|
39
|
+
};
|
|
40
|
+
/** Extra fields (e.g. a price note) are passed to the assistant as-is. */
|
|
41
|
+
type LumaSearchResult<T> = {
|
|
42
|
+
items: T[];
|
|
43
|
+
hasMore?: boolean;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
};
|
|
46
|
+
type LumaDataSourceContext = {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
signal: AbortSignal;
|
|
49
|
+
};
|
|
50
|
+
type LumaProductQuery = {
|
|
51
|
+
query: string;
|
|
52
|
+
minPrice?: number | null;
|
|
53
|
+
maxPrice?: number | null;
|
|
54
|
+
category?: string | null;
|
|
55
|
+
inStock: boolean;
|
|
56
|
+
page: number;
|
|
57
|
+
};
|
|
58
|
+
/** Live data the assistant reads from your app. Every function runs in the visitor's browser. */
|
|
59
|
+
type LumaDataSources = {
|
|
60
|
+
site?: LumaSiteInfo | ((context: LumaDataSourceContext) => LumaSiteInfo | Promise<LumaSiteInfo>);
|
|
61
|
+
searchSite?: (input: {
|
|
62
|
+
query: string;
|
|
63
|
+
page: number;
|
|
64
|
+
}, context: LumaDataSourceContext) => Promise<LumaSearchResult<LumaLink>>;
|
|
65
|
+
searchProducts?: (input: LumaProductQuery, context: LumaDataSourceContext) => Promise<LumaSearchResult<LumaProduct>>;
|
|
66
|
+
getProduct?: (input: {
|
|
67
|
+
productId: number | string;
|
|
68
|
+
}, context: LumaDataSourceContext) => Promise<LumaProduct | null>;
|
|
69
|
+
};
|
|
70
|
+
/** How the assistant opens pages on this website. */
|
|
71
|
+
type LumaNavigation = {
|
|
72
|
+
/** Open a same-origin URL that already passed the site policy. */
|
|
73
|
+
navigate: (url: string) => void;
|
|
74
|
+
/** True when navigate keeps this document (client-side routing). */
|
|
75
|
+
client?: boolean;
|
|
76
|
+
};
|
|
77
|
+
type Landmark = {
|
|
78
|
+
path: string;
|
|
79
|
+
selector: string;
|
|
80
|
+
label: string;
|
|
81
|
+
fingerprint: string;
|
|
82
|
+
};
|
|
83
|
+
declare const formFieldSchema: z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
type: z.ZodEnum<{
|
|
86
|
+
consent: "consent";
|
|
87
|
+
date: "date";
|
|
88
|
+
email: "email";
|
|
89
|
+
long_text: "long_text";
|
|
90
|
+
multiple_choice: "multiple_choice";
|
|
91
|
+
number: "number";
|
|
92
|
+
phone: "phone";
|
|
93
|
+
short_text: "short_text";
|
|
94
|
+
single_choice: "single_choice";
|
|
95
|
+
}>;
|
|
96
|
+
label: z.ZodString;
|
|
97
|
+
help: z.ZodDefault<z.ZodString>;
|
|
98
|
+
placeholder: z.ZodDefault<z.ZodString>;
|
|
99
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
100
|
+
options: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
101
|
+
min: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
102
|
+
max: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
103
|
+
mapTo: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
104
|
+
email: "email";
|
|
105
|
+
name: "name";
|
|
106
|
+
phone: "phone";
|
|
107
|
+
}>>>;
|
|
108
|
+
hideFromAssistant: z.ZodDefault<z.ZodBoolean>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
type FormField = z.output<typeof formFieldSchema>;
|
|
111
|
+
/** A form as the visitor's widget receives it: no mapping, nothing private. */
|
|
112
|
+
type PublicFormField = Pick<FormField, "id" | "type" | "label" | "help" | "placeholder" | "required" | "options"> & {
|
|
113
|
+
min: number | null;
|
|
114
|
+
max: number | null;
|
|
115
|
+
};
|
|
116
|
+
type PublicForm = {
|
|
117
|
+
id: string;
|
|
118
|
+
title: string;
|
|
119
|
+
intro: string;
|
|
120
|
+
submitLabel: string;
|
|
121
|
+
fields: PublicFormField[];
|
|
122
|
+
};
|
|
123
|
+
declare const WIDGET_RADII: readonly ["none", "small", "medium", "large"];
|
|
124
|
+
declare const WIDGET_FONT_SIZES: readonly ["small", "medium", "large"];
|
|
125
|
+
/**
|
|
126
|
+
* Typefaces the owner can pick: `default` (the widget's own stack, nothing to
|
|
127
|
+
* download) or one of the Office font registry's families (the server's
|
|
128
|
+
* `services/office/fonts/registry.ts`), under the registry's IDs. The API
|
|
129
|
+
* serves each family's faces (`widgetFontFaces`) and the widget registers
|
|
130
|
+
* them only when the theme names one; a browser downloads a face only once
|
|
131
|
+
* text uses it. Left out: Kenar (`font.kenar`), whose only face is a 900
|
|
132
|
+
* weight, too heavy for message text.
|
|
133
|
+
*/
|
|
134
|
+
declare const WIDGET_FONT_CATALOG: readonly [{
|
|
135
|
+
readonly id: "font.iranyekanx";
|
|
136
|
+
readonly name: "IRANYekanX";
|
|
137
|
+
readonly weights: readonly [400, 700];
|
|
138
|
+
}, {
|
|
139
|
+
readonly id: "font.yekanbakh";
|
|
140
|
+
readonly name: "Yekan Bakh";
|
|
141
|
+
readonly weights: readonly [400, 700];
|
|
142
|
+
}, {
|
|
143
|
+
readonly id: "font.dana";
|
|
144
|
+
readonly name: "Dana";
|
|
145
|
+
readonly weights: readonly [400, 700];
|
|
146
|
+
}, {
|
|
147
|
+
readonly id: "font.iransansx";
|
|
148
|
+
readonly name: "IRANSansX";
|
|
149
|
+
readonly weights: readonly [400, 700];
|
|
150
|
+
}, {
|
|
151
|
+
readonly id: "font.peyda";
|
|
152
|
+
readonly name: "Peyda";
|
|
153
|
+
readonly weights: readonly [400, 700];
|
|
154
|
+
}, {
|
|
155
|
+
readonly id: "font.farhang";
|
|
156
|
+
readonly name: "Farhang";
|
|
157
|
+
readonly weights: readonly [400, 700];
|
|
158
|
+
}, {
|
|
159
|
+
readonly id: "font.kalameh";
|
|
160
|
+
readonly name: "Kalameh";
|
|
161
|
+
readonly weights: readonly [400, 700];
|
|
162
|
+
}, {
|
|
163
|
+
readonly id: "font.lahzeh-pro";
|
|
164
|
+
readonly name: "Lahzeh";
|
|
165
|
+
readonly weights: readonly [400, 700];
|
|
166
|
+
}, {
|
|
167
|
+
readonly id: "font.on";
|
|
168
|
+
readonly name: "On";
|
|
169
|
+
readonly weights: readonly [400, 700];
|
|
170
|
+
}, {
|
|
171
|
+
readonly id: "font.rokh-pro";
|
|
172
|
+
readonly name: "Rokh";
|
|
173
|
+
readonly weights: readonly [400, 700];
|
|
174
|
+
}, {
|
|
175
|
+
readonly id: "font.anjoman";
|
|
176
|
+
readonly name: "Anjoman";
|
|
177
|
+
readonly weights: readonly [400, 700];
|
|
178
|
+
}, {
|
|
179
|
+
readonly id: "font.kahroba-pro";
|
|
180
|
+
readonly name: "Kahroba";
|
|
181
|
+
readonly weights: readonly [400, 700];
|
|
182
|
+
}, {
|
|
183
|
+
readonly id: "font.doran";
|
|
184
|
+
readonly name: "Doran";
|
|
185
|
+
readonly weights: readonly [400, 700];
|
|
186
|
+
}, {
|
|
187
|
+
readonly id: "font.aria";
|
|
188
|
+
readonly name: "Aria";
|
|
189
|
+
readonly weights: readonly [400, 700];
|
|
190
|
+
}, {
|
|
191
|
+
readonly id: "font.alibaba";
|
|
192
|
+
readonly name: "Alibaba";
|
|
193
|
+
readonly weights: readonly [400, 700];
|
|
194
|
+
}, {
|
|
195
|
+
readonly id: "font.bidad";
|
|
196
|
+
readonly name: "Bidad";
|
|
197
|
+
readonly weights: readonly [400, 700];
|
|
198
|
+
}, {
|
|
199
|
+
readonly id: "font.modam";
|
|
200
|
+
readonly name: "Modam";
|
|
201
|
+
readonly weights: readonly [400, 700];
|
|
202
|
+
}, {
|
|
203
|
+
readonly id: "font.morabba-pro";
|
|
204
|
+
readonly name: "Morabba";
|
|
205
|
+
readonly weights: readonly [400, 700];
|
|
206
|
+
}, {
|
|
207
|
+
readonly id: "font.mahoor";
|
|
208
|
+
readonly name: "Mahoor";
|
|
209
|
+
readonly weights: readonly [400, 700];
|
|
210
|
+
}, {
|
|
211
|
+
readonly id: "font.abi";
|
|
212
|
+
readonly name: "Abi";
|
|
213
|
+
readonly weights: readonly [400, 700];
|
|
214
|
+
}, {
|
|
215
|
+
readonly id: "font.ravi";
|
|
216
|
+
readonly name: "Ravi";
|
|
217
|
+
readonly weights: readonly [400, 700];
|
|
218
|
+
}, {
|
|
219
|
+
readonly id: "font.b-nazanin";
|
|
220
|
+
readonly name: "B Nazanin";
|
|
221
|
+
readonly weights: readonly [400];
|
|
222
|
+
}, {
|
|
223
|
+
readonly id: "font.onvan";
|
|
224
|
+
readonly name: "Onvan";
|
|
225
|
+
readonly weights: readonly [400];
|
|
226
|
+
}, {
|
|
227
|
+
readonly id: "font.dabir";
|
|
228
|
+
readonly name: "Dabir";
|
|
229
|
+
readonly weights: readonly [400];
|
|
230
|
+
}];
|
|
231
|
+
type WidgetCatalogFont = (typeof WIDGET_FONT_CATALOG)[number];
|
|
232
|
+
declare const WIDGET_FONTS: readonly ["default", ...WidgetCatalogFont["id"][]];
|
|
233
|
+
type WidgetFont = (typeof WIDGET_FONTS)[number];
|
|
234
|
+
declare const WIDGET_DENSITIES: readonly ["compact", "normal", "comfortable"];
|
|
235
|
+
declare const WIDGET_SCHEMES: readonly ["auto", "light", "dark"];
|
|
236
|
+
declare const WIDGET_POSITIONS: readonly ["bottom-right", "bottom-left"];
|
|
237
|
+
declare const WIDGET_SIZES: readonly ["sm", "md", "lg", "xl"];
|
|
238
|
+
declare const WIDGET_LAUNCHER_ICONS: readonly ["avatar", "chat", "sparkles"];
|
|
239
|
+
declare const WIDGET_LAUNCHER_SIZES: readonly ["sm", "md", "lg", "xl"];
|
|
240
|
+
/** On phones the window can also fill the screen. */
|
|
241
|
+
declare const WIDGET_MOBILE_SIZES: readonly ["sm", "md", "lg", "xl", "full"];
|
|
242
|
+
type WidgetTheme = {
|
|
243
|
+
color: string;
|
|
244
|
+
scheme: (typeof WIDGET_SCHEMES)[number];
|
|
245
|
+
radius: (typeof WIDGET_RADII)[number];
|
|
246
|
+
/** Absent from older servers' configs: the widget then shows the default. */
|
|
247
|
+
font: WidgetFont;
|
|
248
|
+
fontSize: (typeof WIDGET_FONT_SIZES)[number];
|
|
249
|
+
density: (typeof WIDGET_DENSITIES)[number];
|
|
250
|
+
position: (typeof WIDGET_POSITIONS)[number];
|
|
251
|
+
size: (typeof WIDGET_SIZES)[number];
|
|
252
|
+
launcherIcon: (typeof WIDGET_LAUNCHER_ICONS)[number];
|
|
253
|
+
launcherLabel: string;
|
|
254
|
+
launcherSize: (typeof WIDGET_LAUNCHER_SIZES)[number];
|
|
255
|
+
offsetBottom: number;
|
|
256
|
+
offsetSide: number;
|
|
257
|
+
mobileEnabled: boolean;
|
|
258
|
+
mobileSize: (typeof WIDGET_MOBILE_SIZES)[number];
|
|
259
|
+
mobileLauncherSize: (typeof WIDGET_LAUNCHER_SIZES)[number];
|
|
260
|
+
mobileOffsetBottom: number;
|
|
261
|
+
mobileOffsetSide: number;
|
|
262
|
+
greeting: string;
|
|
263
|
+
subtitle: string;
|
|
264
|
+
placeholder: string;
|
|
265
|
+
disclaimer: string;
|
|
266
|
+
starters: string[];
|
|
267
|
+
rating: {
|
|
268
|
+
enabled: boolean;
|
|
269
|
+
afterMessages: number;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
type WidgetVoiceUnavailable = "off" | "cap" | "credits";
|
|
273
|
+
type WidgetVoiceState = {
|
|
274
|
+
available: true;
|
|
275
|
+
} | {
|
|
276
|
+
available: false;
|
|
277
|
+
reason: WidgetVoiceUnavailable;
|
|
278
|
+
};
|
|
279
|
+
/** Public, cacheable configuration a widget loads with its assistant. */
|
|
280
|
+
type WidgetConfig = {
|
|
281
|
+
assistantId: string;
|
|
282
|
+
name: string;
|
|
283
|
+
/** The logo's storage address (older widgets use it). */
|
|
284
|
+
avatar: string | null;
|
|
285
|
+
/**
|
|
286
|
+
* The logo through the API, relative to the API base the widget loaded
|
|
287
|
+
* this from (`/assistant/<id>/avatar/<name>?v=…`); older servers omit it.
|
|
288
|
+
*/
|
|
289
|
+
avatarPath?: string | null;
|
|
290
|
+
theme: WidgetTheme;
|
|
291
|
+
/** The theme fields the owner set in the designer; the rest are defaults. */
|
|
292
|
+
themeFields: string[];
|
|
293
|
+
voice: WidgetVoiceState;
|
|
294
|
+
/** The form shown before the first message (phase 11); older servers omit it. */
|
|
295
|
+
prechatForm?: PublicForm | null;
|
|
296
|
+
/**
|
|
297
|
+
* The assistant may send what the visitor tells it to the business's own
|
|
298
|
+
* services (an enabled action or MCP tool): the widget's notice says so.
|
|
299
|
+
*/
|
|
300
|
+
outsideServices?: boolean;
|
|
301
|
+
};
|
|
302
|
+
/** Light, dark, or the visitor's system (`auto`, followed as it changes). */
|
|
303
|
+
type LumaColorScheme = "auto" | "light" | "dark";
|
|
304
|
+
type LumaProviderProps = LumaAppearance & {
|
|
305
|
+
children?: ReactNode;
|
|
306
|
+
/**
|
|
307
|
+
* Your backend route made with createLumaSessionHandler. Recommended: the API key stays on
|
|
308
|
+
* your server.
|
|
309
|
+
*/
|
|
310
|
+
sessionEndpoint?: string;
|
|
311
|
+
/**
|
|
312
|
+
* Assistant ID for client-only apps without a backend. Requires keyless access and this
|
|
313
|
+
* site's domain in the Luma dashboard. Ignored when sessionEndpoint is set.
|
|
314
|
+
*/
|
|
315
|
+
assistantId?: string;
|
|
316
|
+
/** Luma API host: "internal" (ir.lumai.ir, default) or "direct" (dash.lumai.ir). */
|
|
317
|
+
server?: LumaServer;
|
|
318
|
+
/** Overrides the Luma API base URL, e.g. for local development. */
|
|
319
|
+
apiBaseUrl?: string;
|
|
320
|
+
/** Live data the assistant reads from your app. */
|
|
321
|
+
dataSources?: LumaDataSources;
|
|
322
|
+
/** Actions this page tree can run. Required in client-only mode to declare them. */
|
|
323
|
+
actions?: LumaActionDefinition[];
|
|
324
|
+
/** Disable navigation suggestions or on-page guides. Both are on by default. */
|
|
325
|
+
features?: {
|
|
326
|
+
navigation?: boolean;
|
|
327
|
+
guides?: boolean;
|
|
328
|
+
};
|
|
329
|
+
/** Paths where the assistant cannot look, guide or navigate, e.g. "/admin". */
|
|
330
|
+
restrictedPaths?: Array<string | RegExp>;
|
|
331
|
+
/** Extra state-changing paths and query parameters the assistant must never open. */
|
|
332
|
+
blockedPaths?: Array<string | RegExp>;
|
|
333
|
+
blockedParams?: string[];
|
|
334
|
+
/** CSS selectors of regions whose content is never read, in addition to data-luma-private. */
|
|
335
|
+
privateSelectors?: string[];
|
|
336
|
+
/** Hide the widget (for example on some routes) while keeping hooks working. */
|
|
337
|
+
disabled?: boolean;
|
|
338
|
+
/** Client-side router integration. Set by the next, react-router and tanstack entries. */
|
|
339
|
+
navigator?: LumaNavigation;
|
|
340
|
+
/**
|
|
341
|
+
* Light or dark for the widget: "light", "dark", or "auto" to follow the
|
|
342
|
+
* visitor's system (and its changes). Wins over the scheme set in the Luma
|
|
343
|
+
* dashboard's designer; change it at runtime to follow your site's own
|
|
344
|
+
* theme switch. Unset: the designer's choice.
|
|
345
|
+
*/
|
|
346
|
+
colorScheme?: LumaColorScheme;
|
|
347
|
+
/** "page": the chat fills the page instead of a floating launcher. */
|
|
348
|
+
layout?: "floating" | "page";
|
|
349
|
+
/** @internal Host-provided values used by the WordPress plugin. */
|
|
350
|
+
host?: {
|
|
351
|
+
chatEndpoint?: string;
|
|
352
|
+
siteContext?: SiteContext;
|
|
353
|
+
landmarks?: Landmark[];
|
|
354
|
+
restricted?: boolean;
|
|
355
|
+
policy?: SitePolicy;
|
|
356
|
+
storageScope?: string;
|
|
357
|
+
/** The widget configuration, when the host loaded it already. */
|
|
358
|
+
config?: WidgetConfig | null;
|
|
359
|
+
/**
|
|
360
|
+
* A host's old appearance settings, by theme field name (an older
|
|
361
|
+
* WordPress plugin's saved values): used only for fields the dashboard's
|
|
362
|
+
* designer has not set.
|
|
363
|
+
*/
|
|
364
|
+
themeFallbacks?: Record<string, unknown>;
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Adds the Luma assistant to every page below it and enables useLuma, useLumaContext and
|
|
369
|
+
* useLumaAction. Place it once, near the root of your app.
|
|
370
|
+
*/
|
|
371
|
+
declare function LumaProvider(props: LumaProviderProps): import("react").JSX.Element;
|
|
372
|
+
type LumaStatus = "connecting" | "ready" | "busy" | "error" | "disabled";
|
|
373
|
+
type LumaState = {
|
|
374
|
+
isOpen: boolean;
|
|
375
|
+
status: LumaStatus;
|
|
376
|
+
};
|
|
377
|
+
type LumaActionHandler<Input = unknown> = (input: Input) => unknown | Promise<unknown>;
|
|
378
|
+
/** Control the assistant from your own UI, e.g. an "Ask about this product" button. */
|
|
379
|
+
declare function useLuma(): {
|
|
380
|
+
isOpen: boolean;
|
|
381
|
+
status: LumaStatus;
|
|
382
|
+
open: () => void;
|
|
383
|
+
close: () => void;
|
|
384
|
+
toggle: () => void;
|
|
385
|
+
/**
|
|
386
|
+
* Opens the chat and sends text (queued until the session is ready).
|
|
387
|
+
* Returns false, sending nothing, for empty or too long text, while a
|
|
388
|
+
* reply is in progress or a message waits to be sent again, when the
|
|
389
|
+
* session expired, and while the pre-chat form must be filled first.
|
|
390
|
+
*/
|
|
391
|
+
ask: (text: string) => boolean;
|
|
392
|
+
newChat: () => void | undefined;
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Share structured state of the current page with the assistant (included when it inspects
|
|
396
|
+
* the page). Keep it small and free of secrets; it leaves the browser.
|
|
397
|
+
*/
|
|
398
|
+
declare function useLumaContext(name: string, value: unknown): void;
|
|
399
|
+
/**
|
|
400
|
+
* Let the assistant run an action on this page. The handler receives validated input; its
|
|
401
|
+
* JSON-serializable return value is reported to the assistant. Define the action at module
|
|
402
|
+
* level with defineAction so its identity is stable.
|
|
403
|
+
*/
|
|
404
|
+
declare function useLumaAction<Input>(definition: LumaActionDefinition<Input>, handler: LumaActionHandler<Input>): void;
|
|
405
|
+
/** Content inside is invisible to the assistant: never read, never targeted by guides. */
|
|
406
|
+
declare function LumaPrivate(props: HTMLAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
407
|
+
/** Name an unlabeled section so the assistant can find it and guide visitors to it. */
|
|
408
|
+
declare const lumaLabel: (label: string) => {
|
|
409
|
+
"data-luma-label": string;
|
|
410
|
+
};
|
|
411
|
+
/** Spread on an element whose content the assistant must never read. */
|
|
412
|
+
declare const lumaPrivate: () => {
|
|
413
|
+
"data-luma-private": string;
|
|
414
|
+
};
|
|
415
|
+
export { LumaProduct as _, useLumaAction as a, LumaSiteInfo as b, LumaState as c, LumaProviderProps as d, LumaColorScheme as f, LumaLink as g, LumaDataSources as h, useLuma as i, LumaStatus as l, LumaDataSourceContext as m, lumaPrivate as n, useLumaContext as o, LumaNavigation as p, LumaPrivate as r, LumaActionHandler as s, lumaLabel as t, LumaProvider as u, LumaProductQuery as v, LumaSearchResult as y };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, t as LumaAppearance } from "./config-BAC3xPNG.js";
|
|
2
|
+
import { _ as LumaProduct, a as useLumaAction, b as LumaSiteInfo, c as LumaState, d as LumaProviderProps, f as LumaColorScheme, g as LumaLink, h as LumaDataSources, i as useLuma, l as LumaStatus, m as LumaDataSourceContext, n as lumaPrivate, o as useLumaContext, p as LumaNavigation, r as LumaPrivate, s as LumaActionHandler, t as lumaLabel, u as LumaProvider, v as LumaProductQuery, y as LumaSearchResult } from "./index-ByvZMuLw.js";
|
|
3
|
+
export { type LumaActionDefinition, type LumaActionHandler, type LumaAppearance, type LumaColorScheme, type LumaDataSourceContext, type LumaDataSources, type LumaLink, type LumaNavigation, LumaPrivate, type LumaProduct, type LumaProductQuery, LumaProvider, type LumaProviderProps, type LumaSearchResult, type LumaServer, type LumaSiteInfo, type LumaState, type LumaStatus, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { r as LumaPrivate, s as LumaProvider,
|
|
2
|
+
export { r as LumaPrivate, s as LumaProvider, h as defineAction, t as lumaLabel, n as lumaPrivate, i as useLuma, a as useLumaAction, o as useLumaContext } from "./chunks/src-BuzOHEps.js";
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, t as LumaAppearance } from "./config-BAC3xPNG.js";
|
|
2
|
+
import { _ as LumaProduct, a as useLumaAction, b as LumaSiteInfo, c as LumaState, d as LumaProviderProps, f as LumaColorScheme, g as LumaLink, h as LumaDataSources, i as useLuma, l as LumaStatus, m as LumaDataSourceContext, n as lumaPrivate, o as useLumaContext, p as LumaNavigation, r as LumaPrivate, s as LumaActionHandler, t as lumaLabel, v as LumaProductQuery, y as LumaSearchResult } from "./index-ByvZMuLw.js";
|
|
3
|
+
/** LumaProvider for the Next.js App Router: navigation and guides use client-side routing. */
|
|
4
|
+
export declare function LumaProvider(props: Omit<LumaProviderProps, "navigator">): import("react").JSX.Element;
|
|
5
|
+
export { type LumaActionDefinition, type LumaActionHandler, type LumaAppearance, type LumaColorScheme, type LumaDataSourceContext, type LumaDataSources, type LumaLink, type LumaNavigation, LumaPrivate, type LumaProduct, type LumaProductQuery, type LumaProviderProps, type LumaSearchResult, type LumaServer, type LumaSiteInfo, type LumaState, type LumaStatus, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
package/dist/next.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as useLumaAction,
|
|
2
|
+
import { a as useLumaAction, h as defineAction, i as useLuma, m as routerPath, n as lumaPrivate, o as useLumaContext, r as LumaPrivate, s as LumaProvider$1, t as lumaLabel } from "./chunks/src-BuzOHEps.js";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useRouter } from "next/navigation";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, t as LumaAppearance } from "./config-BAC3xPNG.js";
|
|
2
|
+
import { _ as LumaProduct, a as useLumaAction, b as LumaSiteInfo, c as LumaState, d as LumaProviderProps, f as LumaColorScheme, g as LumaLink, h as LumaDataSources, i as useLuma, l as LumaStatus, m as LumaDataSourceContext, n as lumaPrivate, o as useLumaContext, p as LumaNavigation, r as LumaPrivate, s as LumaActionHandler, t as lumaLabel, v as LumaProductQuery, y as LumaSearchResult } from "./index-ByvZMuLw.js";
|
|
3
|
+
/**
|
|
4
|
+
* LumaProvider for React Router 7/8 (framework, data or declarative mode). Render it inside
|
|
5
|
+
* the router, e.g. in the root route component.
|
|
6
|
+
*/
|
|
7
|
+
export declare function LumaProvider(props: Omit<LumaProviderProps, "navigator">): import("react").JSX.Element;
|
|
8
|
+
export { type LumaActionDefinition, type LumaActionHandler, type LumaAppearance, type LumaColorScheme, type LumaDataSourceContext, type LumaDataSources, type LumaLink, type LumaNavigation, LumaPrivate, type LumaProduct, type LumaProductQuery, type LumaProviderProps, type LumaSearchResult, type LumaServer, type LumaSiteInfo, type LumaState, type LumaStatus, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
package/dist/react-router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as useLumaAction,
|
|
2
|
+
import { a as useLumaAction, h as defineAction, i as useLuma, m as routerPath, n as lumaPrivate, o as useLumaContext, r as LumaPrivate, s as LumaProvider$1, t as lumaLabel } from "./chunks/src-BuzOHEps.js";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useHref, useNavigate } from "react-router";
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, s as SiteToolName } from "./config-BAC3xPNG.js";
|
|
2
|
+
export type LumaSessionHandlerOptions = {
|
|
3
|
+
/** Luma API key. Keep it in a server-only environment variable. */
|
|
4
|
+
apiKey: string;
|
|
5
|
+
assistantId: string;
|
|
6
|
+
/** Luma API host: "internal" (ir.lumai.ir, default) or "direct" (dash.lumai.ir). */
|
|
7
|
+
server?: LumaServer;
|
|
8
|
+
/** Overrides the API base URL this server calls, e.g. for local development. */
|
|
9
|
+
apiBaseUrl?: string;
|
|
10
|
+
/** API base URL visitors' browsers use for chat, when it differs from apiBaseUrl. */
|
|
11
|
+
browserApiBaseUrl?: string;
|
|
12
|
+
/** Public site URL. Defaults to the request's host; set it behind proxies that rewrite Host. */
|
|
13
|
+
siteUrl?: string;
|
|
14
|
+
/** Owner allowlist of assistant tools. Defaults to all; the page requests what it can run. */
|
|
15
|
+
capabilities?: SiteToolName[];
|
|
16
|
+
/** Actions the assistant may propose; pages run them with useLumaAction. */
|
|
17
|
+
actions?: LumaActionDefinition[];
|
|
18
|
+
/**
|
|
19
|
+
* Your own visitor check or rate limit. Return false (403) or a Response to reject.
|
|
20
|
+
* Sessions spend this assistant's credits, so limit them per visitor in production.
|
|
21
|
+
*/
|
|
22
|
+
authorize?: (request: Request) => boolean | Response | Promise<boolean | Response>;
|
|
23
|
+
fetch?: typeof fetch;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Creates the POST handler that starts visitor sessions for LumaProvider's sessionEndpoint.
|
|
27
|
+
* It uses the Fetch API, so it works as a Next.js route handler, a TanStack Start server
|
|
28
|
+
* route, a React Router action, or in any runtime with Request/Response.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createLumaSessionHandler(options: LumaSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
31
|
+
export { type LumaActionDefinition, defineAction };
|
package/dist/server.js
CHANGED
|
@@ -246,7 +246,9 @@ function createLumaSessionHandler(options) {
|
|
|
246
246
|
}
|
|
247
247
|
if (!response.ok) {
|
|
248
248
|
log("LUMA_UPSTREAM_REJECTED", `Luma returned HTTP ${response.status}. ${upstreamHints[response.status] ?? ""}`.trim());
|
|
249
|
-
|
|
249
|
+
const refused = response.status >= 400 && response.status < 500;
|
|
250
|
+
const retryAfter = response.headers.get("retry-after");
|
|
251
|
+
return fail(refused ? response.status : 502, "LUMA_UPSTREAM_REJECTED", "Unable to create session", response.status === 429 && retryAfter && /^\d{1,5}$/.test(retryAfter) ? { "Retry-After": retryAfter } : void 0);
|
|
250
252
|
}
|
|
251
253
|
const payload = await response.json().catch(() => null);
|
|
252
254
|
const data = payload?.data;
|