@oryksa/react-native 1.1.3 → 1.1.4

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
@@ -1,161 +1,181 @@
1
- <p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
2
-
3
- # @oryksa/react-native
4
-
5
- [![English](https://img.shields.io/badge/English-0891b2?style=for-the-badge)](README.md) [![Português](https://img.shields.io/badge/Portugu%C3%AAs-30363d?style=for-the-badge)](README.pt.md) [![Español](https://img.shields.io/badge/Espa%C3%B1ol-30363d?style=for-the-badge)](README.es.md) [![Français](https://img.shields.io/badge/Fran%C3%A7ais-30363d?style=for-the-badge)](README.fr.md)
6
-
7
- <p align="center"><a href="https://developer.oryksa.com/en/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-en.gif" width="760" alt="ORYKSA SDKs: the AI chat and voice on iOS, Android, Flutter, React Native and the web"></a></p>
8
-
9
- Official React Native SDK for **ORYKSA AI Employees**. Put an AI employee that already knows your business inside your iOS and Android app (React Native or Expo): a ready chat with the same look as the ORYKSA website chat, the name and photo of your AI from your ORYKSA account, in English, Portuguese and Spanish.
10
-
11
- * Docs: https://developer.oryksa.com/en/sdks
12
- * API: `https://api.oryksa.com/v1`
13
- * No native code: works in Expo Go.
14
-
15
- ## Screenshots
16
-
17
- <p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_product_en.png" width="230" alt="Product page with the chat button"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_chat_en.png" width="230" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_theme_en.png" width="230" alt="Chat with the README theme"></p>
18
-
19
- The SDK components themselves, rendered by CI in Chrome at phone size with React Native for Web and an ORYKSA test account (`test/web/`). On a phone the chat also shows the microphone, which needs the native audio libraries. The green chat uses the code of *Colours and theme* below.
20
-
21
- ## Install
22
-
23
- ```bash
24
- npm install @oryksa/react-native
25
- ```
26
-
27
- ## What it is for
28
-
29
- The SDK puts the ORYKSA chat and voice inside your app to serve the **customers of your business**: they ask, buy and book. The AI answers with your Brain, products and services, with the name, photo and voice you chose in *Your AI*, and saves leads, bookings and sales in the Activities of your ORYKSA account. It is **not** an interface for the owner: nobody changes settings, reads Activities or gives orders to ORYKSA through the SDK. More: https://help.oryksa.com/en/a/sdks-what-they-do
30
-
31
- Swear words the customer types show as asterisks in the chat (the same list as every ORYKSA chat, loaded from `https://app.oryksa.com/widget/profanity.json`, kept 24 hours). The AI's replies already come filtered from the server.
32
-
33
- ## Voice and app context (1.1)
34
-
35
- The chat shows a microphone when your plan has voice. It opens the voice screen with the same behaviour as the ORYKSA app: the microphone stays open while she speaks and only a human voice cuts her off (typing, TV and her own echo do not); she stops on the word and the text stays in the chat; a whisper gets a whispered answer; if her voice fails, the text is shown (never a robot voice).
36
-
37
- Voice needs three native libraries (optional peer dependencies) and the microphone permission (Android `RECORD_AUDIO`, iOS `NSMicrophoneUsageDescription`):
38
-
39
- ```sh
40
- npm install react-native-live-audio-stream react-native-sound react-native-fs
41
- ```
42
-
43
- Without them the chat works and the microphone is hidden. Expo or another audio stack: pass your own `audio` adapter (`startMic`, `stopMic`, `play`, `stopPlayback`).
44
-
45
- Each reply of the AI has a copy button under it. It uses `@react-native-clipboard/clipboard` when installed (optional peer dependency: `npm install @react-native-clipboard/clipboard`); older React Native versions use the built-in `Clipboard`.
46
-
47
- ```jsx
48
- <OryksaChatButton client={client} lang="pt"
49
- appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
50
- ```
51
-
52
- ## Links with an Open button (1.1.3)
53
-
54
- The links the AI gives can be tapped in the chat (web addresses and e-mails), and each web link gets a card under her reply with the picture and title of the page and an **Open** button (the pages of your own site, the domains of your website chat; other sites show the address). The voice screen shows what she says without the addresses, with the same cards; tapping Open closes the voice screen. Pass `onLink` to open your own screens, for example your product page: return true when your app opened it, false to let the system open it (`Linking.openURL`).
55
-
56
- ```jsx
57
- <OryksaChatButton client={client} lang="en"
58
- onLink={(url) => {
59
- const id = myProductIdOf(url); // your routes
60
- if (!id) return false;
61
- navigation.navigate("Product", { id });
62
- return true;
63
- }} />
64
- ```
65
-
66
- `onLink` is also on `OryksaChat`, `OryksaChatModal` and `OryksaVoiceScreen`.
67
-
68
- ## Attach a photo or a document (1.1.3)
69
-
70
- The chat has an attach button (a paperclip, on by default): a photo from the library, a photo from the camera, or a document (PDF, Word, text, CSV, up to 8 MB). The AI looks at the photo (made smaller to 1600 pixels, JPEG 80%, up to 2 MB) and reads the document; the customer's bubble shows the photo, or the document icon and its name. `attachments={false}` hides the button.
71
-
72
- React Native has no picker of its own, so the SDK uses two optional libraries your app installs (optional peer dependencies, like the voice libraries). Each choice shows only when its library is there; without both, the button is hidden:
73
-
74
- ```sh
75
- npm install react-native-image-picker @react-native-documents/picker
76
- ```
77
-
78
- * `react-native-image-picker`: photo library and camera. iOS Info.plist: `NSPhotoLibraryUsageDescription` and `NSCameraUsageDescription`. Android: no permission for the photo library; for the camera, `CAMERA` is needed only if your app declares it in its own manifest (then grant it before the camera opens).
79
- * `@react-native-documents/picker`: documents, in the system document picker (no permission). Documents are read with `react-native-fs` when installed, else with `fetch`.
80
-
81
- ```jsx
82
- <OryksaChatButton client={client} lang="en" attachments={false} /> {/* no attach button */}
83
-
84
- // Expo or another stack: your own pickers (a missing one hides that choice)
85
- const picker = {
86
- pickPhoto: () => myPhotoPicker(), // { base64, mime } made smaller (1600 px, JPEG 80%), or null
87
- pickDocument: () => myDocumentPicker(), // { base64, name, mime }, or null
88
- };
89
- <OryksaChat client={client} picker={picker} />
90
- ```
91
-
92
- Without the UI: `client.send("Here is the quote", { file: { base64, name: "quote.pdf", mime: "application/pdf" } })` (photos: `{ image: { base64, mime } }`).
93
-
94
- ## How it works (and why the key stays safe)
95
-
96
- 1. Your **server** keeps the secret API key (`oryk_live_...`, created at developer.oryksa.com) and creates a short-lived **session token** for each signed-in user with `POST /v1/sessions` (with `@oryksa/sdk` on Node: `oryksa.createSession(...)`).
97
- 2. Your **app** receives only that session token (`oryk_cs_...`). The secret key never goes into the app.
98
- 3. Every AI reply counts as one interaction of your ORYKSA plan, the same as on WhatsApp.
99
-
100
- ## In the app
101
-
102
- ```jsx
103
- import { OryksaClient, OryksaChatButton } from "@oryksa/react-native";
104
-
105
- const client = new OryksaClient({
106
- getToken: async () => (await fetch("https://your-server.example/oryksa-token").then((r) => r.json())).token,
107
- });
108
-
109
- export default function App() {
110
- return (
111
- <View style={{ flex: 1 }}>
112
- <MyScreens />
113
- <OryksaChatButton client={client} lang="en" /> {/* en, pt, br, es */}
114
- </View>
115
- );
116
- }
117
- ```
118
-
119
- Other pieces:
120
-
121
- * `<OryksaChatModal client={client} visible={open} onClose={() => setOpen(false)} />`: open the chat from your own button.
122
- * `<OryksaChat client={client} />`: the panel inside any screen.
123
- * `theme={{ accent: "#5B57E0" }}`: colors.
124
- * Without the UI: `await client.agent()`, `await client.sendAndWait("Are you open on Saturday?")`, `await client.messages()`.
125
-
126
- ## Keep the AI in sync with your app
127
-
128
- On your server, with `@oryksa/sdk`:
129
-
130
- ```js
131
- await oryksa.learnApp({ name: "FitTrack", description: "...", screens: [...], faq: [...] });
132
- ```
133
-
134
- ## Errors
135
-
136
- Failed calls throw `OryksaError` with `status`, `code` (for example `interaction_limit_reached`, `rate_limited`, `plan_required`) and `message`.
137
-
138
- ## Colours and theme
139
-
140
- The `theme` prop takes an object with up to five colors as hex strings: `accent` (buttons, visitor bubbles, links), `ink` (main text), `soft` (AI bubbles), `background` (panel) and `muted` (secondary text). Missing keys keep the default, so `{ accent: "#0E8A6B" }` is enough. It works on `OryksaChatButton`, `OryksaChatModal` and `OryksaChat`, and the defaults are exported as `DEFAULT_THEME`.
141
-
142
- ```jsx
143
- const theme = { accent: "#0E8A6B" };
144
-
145
- <OryksaChatButton client={client} lang="en" theme={theme} />
146
- ```
147
-
148
- There is no automatic dark theme: for dark mode, pass your own dark colors.
149
-
150
- ---
151
-
152
- ## About the author
153
-
154
- **Weslley Harakawa** - Founder of ORYKSA AI. Based in Lisbon, Portugal. Specialties: artificial intelligence, web and mobile development, blockchain tokenization. Education: University of the People.
155
-
156
- - LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
157
- - ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
158
-
159
- ---
160
-
161
- MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
1
+ <p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
2
+
3
+ # @oryksa/react-native
4
+
5
+ [![English](https://img.shields.io/badge/English-0891b2?style=for-the-badge)](README.md) [![Português](https://img.shields.io/badge/Portugu%C3%AAs-30363d?style=for-the-badge)](README.pt.md) [![Español](https://img.shields.io/badge/Espa%C3%B1ol-30363d?style=for-the-badge)](README.es.md) [![Français](https://img.shields.io/badge/Fran%C3%A7ais-30363d?style=for-the-badge)](README.fr.md)
6
+
7
+ <p align="center"><a href="https://developer.oryksa.com/en/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-en.gif" width="760" alt="ORYKSA SDKs: the AI chat and voice on iOS, Android, Flutter, React Native and the web"></a></p>
8
+
9
+ Official React Native SDK for **ORYKSA AI Employees**. Put an AI employee that already knows your business inside your iOS and Android app (React Native or Expo): a ready chat with the same look as the ORYKSA website chat, the name and photo of your AI from your ORYKSA account, in English, Portuguese and Spanish.
10
+
11
+ * Docs: https://developer.oryksa.com/en/sdks
12
+ * API: `https://api.oryksa.com/v1`
13
+ * No native code: works in Expo Go.
14
+
15
+ ## Screenshots
16
+
17
+ <p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_product_en.png" width="230" alt="Product page with the chat button"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_chat_en.png" width="230" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_theme_en.png" width="230" alt="Chat with the README theme"></p>
18
+
19
+ The SDK components themselves, rendered by CI in Chrome at phone size with React Native for Web and an ORYKSA test account (`test/web/`). On a phone the chat also shows the microphone, which needs the native audio libraries. The green chat uses the code of *Colours and theme* below.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install @oryksa/react-native
25
+ ```
26
+
27
+ ## What it is for
28
+
29
+ The SDK puts the ORYKSA chat and voice inside your app to serve the **customers of your business**: they ask, buy and book. The AI answers with your Brain, products and services, with the name, photo and voice you chose in *Your AI*, and saves leads, bookings and sales in the Activities of your ORYKSA account. It is **not** an interface for the owner: nobody changes settings, reads Activities or gives orders to ORYKSA through the SDK. More: https://help.oryksa.com/en/a/sdks-what-they-do
30
+
31
+ Swear words the customer types show as asterisks in the chat (the same list as every ORYKSA chat, loaded from `https://app.oryksa.com/widget/profanity.json`, kept 24 hours). The AI's replies already come filtered from the server.
32
+
33
+ ## Voice and app context (1.1)
34
+
35
+ The chat shows a microphone when your plan has voice. It opens the voice screen with the same behaviour as the ORYKSA app: the microphone stays open while she speaks and only a human voice cuts her off (typing, TV and her own echo do not); she stops on the word and the text stays in the chat; a whisper gets a whispered answer; if her voice fails, the text is shown (never a robot voice).
36
+
37
+ Voice needs three native libraries (optional peer dependencies) and the microphone permission (Android `RECORD_AUDIO`, iOS `NSMicrophoneUsageDescription`):
38
+
39
+ ```sh
40
+ npm install react-native-live-audio-stream react-native-sound react-native-fs
41
+ ```
42
+
43
+ Without them the chat works and the microphone is hidden. Expo or another audio stack: pass your own `audio` adapter (`startMic`, `stopMic`, `play`, `stopPlayback`).
44
+
45
+ Each reply of the AI has a copy button under it. It uses `@react-native-clipboard/clipboard` when installed (optional peer dependency: `npm install @react-native-clipboard/clipboard`); older React Native versions use the built-in `Clipboard`.
46
+
47
+ ```jsx
48
+ <OryksaChatButton client={client} lang="pt"
49
+ appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
50
+ ```
51
+
52
+ ## Links with an Open button (1.1.3)
53
+
54
+ The links the AI gives can be tapped in the chat (web addresses and e-mails), and each web link gets a card under her reply with the picture and title of the page and an **Open** button (the pages of your own site, the domains of your website chat; other sites show the address). The voice screen shows what she says without the addresses, with the same cards; tapping Open closes the voice screen. Pass `onLink` to open your own screens, for example your product page: return true when your app opened it, false to let the system open it (`Linking.openURL`).
55
+
56
+ ```jsx
57
+ <OryksaChatButton client={client} lang="en"
58
+ onLink={(url) => {
59
+ const id = myProductIdOf(url); // your routes
60
+ if (!id) return false;
61
+ navigation.navigate("Product", { id });
62
+ return true;
63
+ }} />
64
+ ```
65
+
66
+ `onLink` is also on `OryksaChat`, `OryksaChatModal` and `OryksaVoiceScreen`.
67
+
68
+ ## Attach a photo or a document (1.1.3)
69
+
70
+ The chat has an attach button (a paperclip, on by default): a photo from the library, a photo from the camera, or a document (PDF, Word, text, CSV, up to 8 MB). The AI looks at the photo (made smaller to 1600 pixels, JPEG 80%, up to 2 MB) and reads the document; the customer's bubble shows the photo, or the document icon and its name. `attachments={false}` hides the button.
71
+
72
+ React Native has no picker of its own, so the SDK uses two optional libraries your app installs (optional peer dependencies, like the voice libraries). Each choice shows only when its library is there; without both, the button is hidden:
73
+
74
+ ```sh
75
+ npm install react-native-image-picker @react-native-documents/picker
76
+ ```
77
+
78
+ * `react-native-image-picker`: photo library and camera. iOS Info.plist: `NSPhotoLibraryUsageDescription` and `NSCameraUsageDescription`. Android: no permission for the photo library; for the camera, `CAMERA` is needed only if your app declares it in its own manifest (then grant it before the camera opens).
79
+ * `@react-native-documents/picker`: documents, in the system document picker (no permission). Documents are read with `react-native-fs` when installed, else with `fetch`.
80
+
81
+ ```jsx
82
+ <OryksaChatButton client={client} lang="en" attachments={false} /> {/* no attach button */}
83
+
84
+ // Expo or another stack: your own pickers (a missing one hides that choice)
85
+ const picker = {
86
+ pickPhoto: () => myPhotoPicker(), // { base64, mime } made smaller (1600 px, JPEG 80%), or null
87
+ pickDocument: () => myDocumentPicker(), // { base64, name, mime }, or null
88
+ };
89
+ <OryksaChat client={client} picker={picker} />
90
+ ```
91
+
92
+ Without the UI: `client.send("Here is the quote", { file: { base64, name: "quote.pdf", mime: "application/pdf" } })` (photos: `{ image: { base64, mime } }`).
93
+
94
+ ## Your own AI features: `ai` (1.1.4)
95
+
96
+ Have the AI do what your app needs (read a photo, extract data, classify, translate, write) and pay with ORYKSA interactions: 1 per answer. Your prompt and your JSON Schema live in your app; the session token is enough (never ship the secret key). It does not create a conversation in your inbox.
97
+
98
+ ```js
99
+ const r = await client.ai({
100
+ instructions: "Read the tyre on the photo: brand, model and size exactly as written on the sidewall. " +
101
+ "If the size is not legible, readable=false and size=null. Never invent.",
102
+ images: [{ base64: photoBase64, mime: "image/jpeg" }], // resized to 1600 px
103
+ schema: {
104
+ type: "object",
105
+ properties: { readable: { type: "boolean" }, brand: { type: ["string", "null"] }, size: { type: ["string", "null"] } },
106
+ required: ["readable", "brand", "size"],
107
+ },
108
+ });
109
+ if (r.json?.readable) showProducts(r.json.size);
110
+ ```
111
+
112
+ `r.text` has the answer as text, `r.json` the object (with a schema), `r.interactionsSpent` the interactions used. When the plan's interactions are used up the call throws `OryksaError` with status 402.
113
+
114
+ ## How it works (and why the key stays safe)
115
+
116
+ 1. Your **server** keeps the secret API key (`oryk_live_...`, created at developer.oryksa.com) and creates a short-lived **session token** for each signed-in user with `POST /v1/sessions` (with `@oryksa/sdk` on Node: `oryksa.createSession(...)`).
117
+ 2. Your **app** receives only that session token (`oryk_cs_...`). The secret key never goes into the app.
118
+ 3. Every AI reply counts as one interaction of your ORYKSA plan, the same as on WhatsApp.
119
+
120
+ ## In the app
121
+
122
+ ```jsx
123
+ import { OryksaClient, OryksaChatButton } from "@oryksa/react-native";
124
+
125
+ const client = new OryksaClient({
126
+ getToken: async () => (await fetch("https://your-server.example/oryksa-token").then((r) => r.json())).token,
127
+ });
128
+
129
+ export default function App() {
130
+ return (
131
+ <View style={{ flex: 1 }}>
132
+ <MyScreens />
133
+ <OryksaChatButton client={client} lang="en" /> {/* en, pt, br, es */}
134
+ </View>
135
+ );
136
+ }
137
+ ```
138
+
139
+ Other pieces:
140
+
141
+ * `<OryksaChatModal client={client} visible={open} onClose={() => setOpen(false)} />`: open the chat from your own button.
142
+ * `<OryksaChat client={client} />`: the panel inside any screen.
143
+ * `theme={{ accent: "#5B57E0" }}`: colors.
144
+ * Without the UI: `await client.agent()`, `await client.sendAndWait("Are you open on Saturday?")`, `await client.messages()`.
145
+
146
+ ## Keep the AI in sync with your app
147
+
148
+ On your server, with `@oryksa/sdk`:
149
+
150
+ ```js
151
+ await oryksa.learnApp({ name: "FitTrack", description: "...", screens: [...], faq: [...] });
152
+ ```
153
+
154
+ ## Errors
155
+
156
+ Failed calls throw `OryksaError` with `status`, `code` (for example `interaction_limit_reached`, `rate_limited`, `plan_required`) and `message`.
157
+
158
+ ## Colours and theme
159
+
160
+ The `theme` prop takes an object with up to five colors as hex strings: `accent` (buttons, visitor bubbles, links), `ink` (main text), `soft` (AI bubbles), `background` (panel) and `muted` (secondary text). Missing keys keep the default, so `{ accent: "#0E8A6B" }` is enough. It works on `OryksaChatButton`, `OryksaChatModal` and `OryksaChat`, and the defaults are exported as `DEFAULT_THEME`.
161
+
162
+ ```jsx
163
+ const theme = { accent: "#0E8A6B" };
164
+
165
+ <OryksaChatButton client={client} lang="en" theme={theme} />
166
+ ```
167
+
168
+ There is no automatic dark theme: for dark mode, pass your own dark colors.
169
+
170
+ ---
171
+
172
+ ## About the author
173
+
174
+ **Weslley Harakawa** - Founder of ORYKSA AI. Based in Lisbon, Portugal. Specialties: artificial intelligence, web and mobile development, blockchain tokenization. Education: University of the People.
175
+
176
+ - LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
177
+ - ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
178
+
179
+ ---
180
+
181
+ MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda