@luma-ai/react 0.1.0 → 2.0.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 (40) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +18 -12
  3. package/dist/chunks/src-CI0MDOrd.js +7643 -0
  4. package/dist/chunks/src-CI0MDOrd.js.map +1 -0
  5. package/dist/chunks/support-cursor-pCpYa13-.js +131 -0
  6. package/dist/chunks/support-cursor-pCpYa13-.js.map +1 -0
  7. package/dist/chunks/visitor-call-CDpkyeoR.js +1129 -0
  8. package/dist/chunks/visitor-call-CDpkyeoR.js.map +1 -0
  9. package/dist/chunks/visitor-cobrowse-BIyfnFu3.js +1352 -0
  10. package/dist/chunks/visitor-cobrowse-BIyfnFu3.js.map +1 -0
  11. package/dist/index.js +1 -2
  12. package/dist/next.js +2 -3
  13. package/dist/next.js.map +1 -1
  14. package/dist/react-router.js +2 -3
  15. package/dist/react-router.js.map +1 -1
  16. package/dist/server.js +8 -11
  17. package/dist/server.js.map +1 -1
  18. package/dist/tanstack.js +2 -3
  19. package/dist/tanstack.js.map +1 -1
  20. package/docs/ai-agents.md +5 -5
  21. package/docs/appearance.md +92 -0
  22. package/docs/data-sources.md +18 -18
  23. package/docs/features.md +62 -0
  24. package/docs/hooks.md +22 -8
  25. package/docs/index.md +17 -7
  26. package/docs/options.md +58 -51
  27. package/docs/privacy.md +29 -6
  28. package/docs/server.md +11 -7
  29. package/docs/troubleshooting.md +14 -6
  30. package/package.json +27 -20
  31. package/skills/luma-ai-react/SKILL.md +32 -13
  32. package/dist/chunks/src-dnp1waFV.js +0 -3100
  33. package/dist/chunks/src-dnp1waFV.js.map +0 -1
  34. package/dist/config-CCT7m9eE.d.ts +0 -102
  35. package/dist/index-BdkoFDyP.d.ts +0 -189
  36. package/dist/index.d.ts +0 -3
  37. package/dist/next.d.ts +0 -7
  38. package/dist/react-router.d.ts +0 -10
  39. package/dist/server.d.ts +0 -33
  40. package/dist/tanstack.d.ts +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma-ai/react",
3
- "version": "0.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Luma AI site assistant for React, Next.js, TanStack Start and React Router",
5
5
  "keywords": [
6
6
  "luma",
@@ -22,7 +22,8 @@
22
22
  "dist",
23
23
  "docs",
24
24
  "skills",
25
- "README.md"
25
+ "README.md",
26
+ "CHANGELOG.md"
26
27
  ],
27
28
  "exports": {
28
29
  ".": {
@@ -51,13 +52,13 @@
51
52
  "access": "public"
52
53
  },
53
54
  "dependencies": {
54
- "@ai-sdk/react": "4.0.130",
55
- "@radix-ui/react-avatar": "^1.2.6",
56
- "@radix-ui/react-slot": "^1.3.3",
57
- "ai": "^7.0.127",
55
+ "@ai-sdk/react": "4.0.163",
56
+ "@radix-ui/react-avatar": "^1.3.1",
57
+ "@radix-ui/react-slot": "^1.5.0",
58
+ "ai": "^7.0.159",
58
59
  "class-variance-authority": "^0.7.1",
59
60
  "clsx": "^2.1.1",
60
- "lucide-react": "^1.51.0",
61
+ "lucide-react": "^1.66.0",
61
62
  "react-markdown": "^10.1.0",
62
63
  "remark-gfm": "^4.0.1",
63
64
  "tailwind-merge": "^3.7.0",
@@ -84,27 +85,31 @@
84
85
  },
85
86
  "devDependencies": {
86
87
  "@luma/assistant-contract": "0.0.0",
88
+ "@luma/assistant-mock": "0.0.0",
87
89
  "@luma/tsconfig": "0.0.0",
88
- "@playwright/test": "^1.63.0",
90
+ "@playwright/test": "^1.64.1",
89
91
  "@tailwindcss/typography": "^0.5.20",
90
92
  "@tailwindcss/vite": "^4.3.3",
91
- "@tanstack/react-router": "^1.170.41",
92
- "@types/node": "^26.6.4",
93
+ "@tanstack/react-router": "^1.170.46",
94
+ "@types/jsdom": "30.0.0",
95
+ "@types/node": "^26.6.6",
93
96
  "@types/react": "^19.3.0",
94
97
  "@types/react-dom": "^19.3.0",
95
- "@vitejs/plugin-react": "^6.1.1",
96
- "next": "^16.3.8",
97
- "oxlint": "^1.86.0",
98
- "react": "^19.3.0",
99
- "react-dom": "^19.3.0",
100
- "react-router": "^8.4.0",
98
+ "@vitejs/plugin-react": "^6.1.2",
99
+ "jsdom": "30.1.3",
100
+ "next": "^16.4.3",
101
+ "oxfmt": "^0.75.0",
102
+ "oxlint": "^1.90.0",
103
+ "react": "^19.3.1",
104
+ "react-dom": "^19.3.1",
105
+ "react-router": "^8.5.1",
101
106
  "tailwindcss": "^4.3.3",
102
- "tsdown": "^0.23.0",
107
+ "tsdown": "^0.23.4",
103
108
  "tsx": "^4.23.15",
104
109
  "tw-animate-css": "^1.4.0",
105
110
  "typescript": "^7.0.2",
106
- "vite": "^8.3.2",
107
- "zod": "^4.6.5"
111
+ "vite": "^8.3.5",
112
+ "zod": "^4.6.7"
108
113
  },
109
114
  "engines": {
110
115
  "node": ">=20"
@@ -115,6 +120,8 @@
115
120
  "lint": "oxlint",
116
121
  "test": "tsx --test tests/*.test.ts",
117
122
  "dev": "vite --config playground/vite.config.ts",
118
- "test:e2e": "playwright test"
123
+ "test:e2e": "playwright test",
124
+ "format": "oxfmt",
125
+ "format:check": "oxfmt --check"
119
126
  }
120
127
  }
@@ -34,12 +34,12 @@ React Router framework mode: `export const action = ({ request }) => handler(req
34
34
 
35
35
  Provider, once, near the root. Import from the framework entry so navigation is client-side:
36
36
 
37
- | Framework | Import |
38
- | --- | --- |
39
- | Next.js App Router | `@luma-ai/react/next` (works directly in `app/layout.tsx`) |
40
- | TanStack Router/Start | `@luma-ai/react/tanstack` (root route) |
41
- | React Router 7/8 | `@luma-ai/react/react-router` (root route, inside the router) |
42
- | No router | `@luma-ai/react` |
37
+ | Framework | Import |
38
+ | --------------------- | ------------------------------------------------------------- |
39
+ | Next.js App Router | `@luma-ai/react/next` (works directly in `app/layout.tsx`) |
40
+ | TanStack Router/Start | `@luma-ai/react/tanstack` (root route) |
41
+ | React Router 7/8 | `@luma-ai/react/react-router` (root route, inside the router) |
42
+ | No router | `@luma-ai/react` |
43
43
 
44
44
  ```tsx
45
45
  <LumaProvider sessionEndpoint="/api/luma/session">{children}</LumaProvider>
@@ -49,7 +49,9 @@ Provider, once, near the root. Import from the framework entry so navigation is
49
49
 
50
50
  ```tsx
51
51
  import { LumaProvider } from "@luma-ai/react"; // or /react-router, /tanstack
52
- <LumaProvider assistantId="<uuid>" actions={[addToCart]}>{children}</LumaProvider>
52
+ <LumaProvider assistantId="<uuid>" actions={[addToCart]}>
53
+ {children}
54
+ </LumaProvider>;
53
55
  ```
54
56
 
55
57
  ## 4. Live data
@@ -58,10 +60,19 @@ import { LumaProvider } from "@luma-ai/react"; // or /react-router, /tanstack
58
60
  <LumaProvider
59
61
  sessionEndpoint="/api/luma/session"
60
62
  dataSources={{
61
- site: { name: "My shop", currency: "تومان", menus: [{ title: "Shipping", url: "/shipping" }] },
63
+ site: {
64
+ name: "My shop",
65
+ currency: "تومان",
66
+ menus: [{ title: "Shipping", url: "/shipping" }],
67
+ },
62
68
  // Resolves to { items: LumaProduct[], hasMore?: boolean }
63
69
  searchProducts: async ({ query, maxPrice, inStock, page }, { signal }) =>
64
- (await fetch(`/api/products?q=${encodeURIComponent(query)}&page=${page}`, { signal })).json(),
70
+ (
71
+ await fetch(
72
+ `/api/products?q=${encodeURIComponent(query)}&page=${page}`,
73
+ { signal },
74
+ )
75
+ ).json(),
65
76
  // Resolves to LumaProduct | null
66
77
  getProduct: async ({ productId }, { signal }) =>
67
78
  (await fetch(`/api/products/${productId}`, { signal })).json(),
@@ -78,10 +89,13 @@ import { LumaProvider } from "@luma-ai/react"; // or /react-router, /tanstack
78
89
  import { z } from "zod";
79
90
  import { defineAction } from "@luma-ai/react/server";
80
91
  export const addToCart = defineAction({
81
- name: "addToCart", // /^[A-Za-z][\w-]{0,63}$/
82
- title: "افزودن به سبد خرید", // Persian label on the approval card
92
+ name: "addToCart", // /^[A-Za-z][\w-]{0,63}$/
93
+ title: "افزودن به سبد خرید", // Persian label on the approval card
83
94
  description: "Add the product the visitor is viewing to their cart.",
84
- input: z.object({ productId: z.string(), quantity: z.number().int().min(1).max(5) }),
95
+ input: z.object({
96
+ productId: z.string(),
97
+ quantity: z.number().int().min(1).max(5),
98
+ }),
85
99
  });
86
100
  ```
87
101
 
@@ -89,7 +103,7 @@ export const addToCart = defineAction({
89
103
  // in the component that owns the state
90
104
  useLumaAction(addToCart, async ({ productId, quantity }) => {
91
105
  await cart.add(productId, quantity);
92
- return { cartItems: cart.count }; // JSON result reported to the assistant
106
+ return { cartItems: cart.count }; // JSON result reported to the assistant
93
107
  });
94
108
  ```
95
109
 
@@ -99,6 +113,9 @@ Declare the action in `createLumaSessionHandler({ actions })` (server) or `<Luma
99
113
 
100
114
  - `useLuma()` returns `{ isOpen, status, open, close, toggle, ask(text), newChat }`.
101
115
  - `useLumaContext("product", { id, selectedSize })` shares small JSON page state (8 KB total). No secrets.
116
+ - Light/dark: the dashboard's designer sets the look. To follow the site's own theme switch pass `colorScheme` (`"auto" | "light" | "dark"`, wins over the designer, can change at runtime). With next-themes: `colorScheme={resolvedTheme === "dark" ? "dark" : resolvedTheme === "light" ? "light" : "auto"}`. The widget does not read `class="dark"` on `<html>`.
117
+ - `layout="page"` fills its parent (give it a height) instead of a floating launcher.
118
+ - Live support, rating, voice, forms, product cards, quick calls, on-page pointing and co-browsing with support's cursor need no code; the owner switches them on in the dashboard or asks in the inbox. Calls need https and `Permissions-Policy: microphone=(self)` (screen sharing in a call also `display-capture=(self)`); the call engine and the co-browsing recorder are separate chunks loaded by `import()` only when a call rings or the visitor allows co-browsing. `LumaPrivate` regions and `privateSelectors` are never copied. A strict CSP must allow the Luma API host in `connect-src`, `img-src` and `media-src` (plus `blob:`); `data:` in `img-src` is optional (it lets the logo show at once on later pages).
102
119
  - Use `<LumaPrivate>`, `{...lumaPrivate()}` or `privateSelectors` for regions the assistant must never read. Use `restrictedPaths={["/admin"]}` for pages it must not inspect or open. Use `{...lumaLabel("…")}` to name unlabeled sections for guides.
103
120
 
104
121
  ## Common mistakes
@@ -107,11 +124,13 @@ Declare the action in `createLumaSessionHandler({ actions })` (server) or `<Luma
107
124
  - Wrong: importing `LumaProvider` from `@luma-ai/react` in a Next.js app. Pages then reload on navigation. Use `@luma-ai/react/next`.
108
125
  - Wrong: defining `defineAction(...)` inside a component. Define it at module level.
109
126
  - Wrong: registering `useLumaAction` without declaring the action. The console warns `LUMA_ACTION_NOT_DECLARED`.
127
+ - Wrong: rewriting or filtering the session handler's response (it carries the routed logo `avatar`/`avatarPath`) or the chat request body (`clientMessageId` lets the server recognise a resend after a dropped connection). Return and forward them unchanged.
110
128
  - Wrong: an auth middleware that redirects `/api/luma/session`. The console reports `LUMA_INVALID_SESSION_RESPONSE`. Exclude the route.
111
129
 
112
130
  ## Steps only the owner can do
113
131
 
114
132
  Ask the user. Do not invent values:
133
+
115
134
  - the assistant ID (UUID);
116
135
  - creating an API key at https://dash.lumai.ir/developers/api/keys;
117
136
  - for keyless mode, enabling keyless access and adding the exact origin in the dashboard (assistant → overview).