@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/CHANGELOG.md CHANGED
@@ -1,37 +1,44 @@
1
- # Changelog
2
-
3
- ## 1.1.3
4
-
5
- - **Links you can tap, with an Open button.** The links of her replies were plain text. They can now be tapped in the chat (web and e-mail, underlined, in the accent colour on her bubbles and white on the customer's), and each web link (3 at most) gets a card under the reply with the picture and the title of the page and an **Open** button. Titles and pictures come from `client.linkPreview(url)` (new `GET /v1/client/link-preview`, kept in memory, never throws), only for the pages of the business's own site (its website chat domains); other links show the address.
6
- - `onLink: (url) => boolean` on `OryksaChatButton`, `OryksaChat`, `OryksaChatModal` and `OryksaVoiceScreen` lets your app open its own screens (return true) instead of the system (`Linking.openURL`).
7
- - **The voice screen shows what she says**, the short spoken version, without the addresses (7 lines at most), with the same cards under it; tapping Open closes the voice screen, then opens the link. `OryksaVoiceController.lastSpoken`; `say()` now also sets `lastReply` and `lastSpoken`.
8
- - New exports: `OryksaLinkCard`, `linksIn`, `withoutLinks`, `openLink` (and the types `OryksaLinkHandler`, `OryksaLinkPreview`). Tests: `test/links.test.js`; the README links code is type-checked by CI (`test/readme/readme-links.tsx`).
9
- - **Attach a photo, take one or send a document.** The chat input has an attach button (on by default, `attachments={false}` hides it on `OryksaChat`, `OryksaChatModal` and `OryksaChatButton`): the photo library, the camera (not on the web) or a document (PDF, Word, text, CSV and pictures, up to 8 MB). Photos come made smaller to 1600 pixels, JPEG 80%, up to 2 MB, and go as `image_base64` / `image_mime`; documents go as `file_base64` / `file_name` / `file_mime` on `POST /v1/client/chat`. The customer's bubble shows the photo, or the document icon and its name; a file that is too large or cannot be read shows a short note. The pickers come from two new optional peer dependencies your app installs, `react-native-image-picker` (library and camera) and `@react-native-documents/picker` (documents); each choice shows only when its library is installed, and `picker` takes your own adapter (Expo). `send(message, { image, file })`, `createDefaultPicker`, `photoAttachment`, `documentAttachment`, `MAX_PHOTO_BYTES`, `MAX_FILE_BYTES`. Tests: `test/attach.test.js`; the README attach code is type-checked (`test/readme/readme-attach.tsx`).
10
-
11
- ## 1.1.2
12
-
13
- - Documentation only, no change in the SDK behaviour: README in English, Portuguese, Spanish and French, with real screenshots of the SDK components (CI, React Native for Web, ORYKSA test account), an animated overview of the ORYKSA SDKs and a *Colours and theme* section. The README theme code is type-checked by CI (`test/readme`).
14
- - The YouTube link of the author section is now https://www.youtube.com/@ORYKSA.
15
-
16
- ## 1.1.1
17
-
18
- - Voice screen: the words the person says are never shown on screen. While the AI thinks it shows "I'm listening" / "One moment..." in the interface language; the AI's answer still shows as text. Same behaviour as the ORYKSA apps, web and extensions.
19
-
20
- ## 1.1.0
21
-
22
- * Copy button under each reply of the AI (copies the text, shows a check for a moment), as in the ORYKSA apps and extension. Uses `@react-native-clipboard/clipboard` when installed (optional peer dependency).
23
- * Voice: a voice screen with the photo of the AI ("I'm listening" / her answer, Mute, Close) opened from the microphone in the chat. The same behaviour as the ORYKSA app: the microphone stays open while she speaks and only a human voice cuts her off (typing, TV, birds and her own echo do not); she stops on the word and the text stays in the chat; the second before the cut is kept; 700 ms of silence closes a sentence (15 s at most); a whisper gets a whispered, shorter answer; her voice is the one chosen in ORYKSA and, if it fails, the text is shown without a robot voice.
24
- * The voice engine is the ORYKSA app engine (`Vad`), with the same audio tests on real recordings.
25
- * `appContext`: tell the AI which screen of your app the customer is on (product, cart, booking) so it answers about it.
26
- * The client gets `tts`, `transcribe` and `voiceStats`; `send` accepts `voice`, `whisper`, `appContext` and returns `speech` (the short spoken version).
27
- * The agent includes `photo` (the AI photo from Your AI), `voice` and `language`.
28
- * Bold text (`**`) in the chat bubbles.
29
- * The SDK serves the customers of the business only: it is never an interface for the owner.
30
- * Voice uses an audio adapter: by default `react-native-live-audio-stream`, `react-native-sound` and `react-native-fs` (optional peer dependencies); Expo or other stacks can pass their own. Without them the chat works and the microphone is hidden.
31
-
32
- ## 1.0.0
33
-
34
- * First release.
35
- * `OryksaClient`: in-app client with short-lived session tokens (agent, send, sendAndWait, messages), refreshes the token when it expires.
36
- * `OryksaChatButton`, `OryksaChatModal` and `OryksaChat`: ready chat with the look of the ORYKSA website chat, name and photo of the AI from the ORYKSA account, in English, Portuguese (Portugal and Brazil) and Spanish.
37
- * No native code, works in Expo Go. TypeScript types included.
1
+ # Changelog
2
+
3
+ ## 1.1.4
4
+
5
+ * **The AI doing what you want in your app: `client.ai({...})`.** An AI task of your own feature, from the app, with
6
+ the session token (never the secret key): instructions, text, up to 4 photos and an optional JSON Schema; the answer
7
+ comes back as text and, with a schema, as an object in `json`. Each answer counts as 1 ORYKSA interaction. It does
8
+ not create a conversation in the business's inbox and never acts on the account. Server route: `POST /v1/client/ai`.
9
+
10
+ ## 1.1.3
11
+
12
+ - **Links you can tap, with an Open button.** The links of her replies were plain text. They can now be tapped in the chat (web and e-mail, underlined, in the accent colour on her bubbles and white on the customer's), and each web link (3 at most) gets a card under the reply with the picture and the title of the page and an **Open** button. Titles and pictures come from `client.linkPreview(url)` (new `GET /v1/client/link-preview`, kept in memory, never throws), only for the pages of the business's own site (its website chat domains); other links show the address.
13
+ - `onLink: (url) => boolean` on `OryksaChatButton`, `OryksaChat`, `OryksaChatModal` and `OryksaVoiceScreen` lets your app open its own screens (return true) instead of the system (`Linking.openURL`).
14
+ - **The voice screen shows what she says**, the short spoken version, without the addresses (7 lines at most), with the same cards under it; tapping Open closes the voice screen, then opens the link. `OryksaVoiceController.lastSpoken`; `say()` now also sets `lastReply` and `lastSpoken`.
15
+ - New exports: `OryksaLinkCard`, `linksIn`, `withoutLinks`, `openLink` (and the types `OryksaLinkHandler`, `OryksaLinkPreview`). Tests: `test/links.test.js`; the README links code is type-checked by CI (`test/readme/readme-links.tsx`).
16
+ - **Attach a photo, take one or send a document.** The chat input has an attach button (on by default, `attachments={false}` hides it on `OryksaChat`, `OryksaChatModal` and `OryksaChatButton`): the photo library, the camera (not on the web) or a document (PDF, Word, text, CSV and pictures, up to 8 MB). Photos come made smaller to 1600 pixels, JPEG 80%, up to 2 MB, and go as `image_base64` / `image_mime`; documents go as `file_base64` / `file_name` / `file_mime` on `POST /v1/client/chat`. The customer's bubble shows the photo, or the document icon and its name; a file that is too large or cannot be read shows a short note. The pickers come from two new optional peer dependencies your app installs, `react-native-image-picker` (library and camera) and `@react-native-documents/picker` (documents); each choice shows only when its library is installed, and `picker` takes your own adapter (Expo). `send(message, { image, file })`, `createDefaultPicker`, `photoAttachment`, `documentAttachment`, `MAX_PHOTO_BYTES`, `MAX_FILE_BYTES`. Tests: `test/attach.test.js`; the README attach code is type-checked (`test/readme/readme-attach.tsx`).
17
+
18
+ ## 1.1.2
19
+
20
+ - Documentation only, no change in the SDK behaviour: README in English, Portuguese, Spanish and French, with real screenshots of the SDK components (CI, React Native for Web, ORYKSA test account), an animated overview of the ORYKSA SDKs and a *Colours and theme* section. The README theme code is type-checked by CI (`test/readme`).
21
+ - The YouTube link of the author section is now https://www.youtube.com/@ORYKSA.
22
+
23
+ ## 1.1.1
24
+
25
+ - Voice screen: the words the person says are never shown on screen. While the AI thinks it shows "I'm listening" / "One moment..." in the interface language; the AI's answer still shows as text. Same behaviour as the ORYKSA apps, web and extensions.
26
+
27
+ ## 1.1.0
28
+
29
+ * Copy button under each reply of the AI (copies the text, shows a check for a moment), as in the ORYKSA apps and extension. Uses `@react-native-clipboard/clipboard` when installed (optional peer dependency).
30
+ * Voice: a voice screen with the photo of the AI ("I'm listening" / her answer, Mute, Close) opened from the microphone in the chat. The same behaviour as the ORYKSA app: the microphone stays open while she speaks and only a human voice cuts her off (typing, TV, birds and her own echo do not); she stops on the word and the text stays in the chat; the second before the cut is kept; 700 ms of silence closes a sentence (15 s at most); a whisper gets a whispered, shorter answer; her voice is the one chosen in ORYKSA and, if it fails, the text is shown without a robot voice.
31
+ * The voice engine is the ORYKSA app engine (`Vad`), with the same audio tests on real recordings.
32
+ * `appContext`: tell the AI which screen of your app the customer is on (product, cart, booking) so it answers about it.
33
+ * The client gets `tts`, `transcribe` and `voiceStats`; `send` accepts `voice`, `whisper`, `appContext` and returns `speech` (the short spoken version).
34
+ * The agent includes `photo` (the AI photo from Your AI), `voice` and `language`.
35
+ * Bold text (`**`) in the chat bubbles.
36
+ * The SDK serves the customers of the business only: it is never an interface for the owner.
37
+ * Voice uses an audio adapter: by default `react-native-live-audio-stream`, `react-native-sound` and `react-native-fs` (optional peer dependencies); Expo or other stacks can pass their own. Without them the chat works and the microphone is hidden.
38
+
39
+ ## 1.0.0
40
+
41
+ * First release.
42
+ * `OryksaClient`: in-app client with short-lived session tokens (agent, send, sendAndWait, messages), refreshes the token when it expires.
43
+ * `OryksaChatButton`, `OryksaChatModal` and `OryksaChat`: ready chat with the look of the ORYKSA website chat, name and photo of the AI from the ORYKSA account, in English, Portuguese (Portugal and Brazil) and Spanish.
44
+ * No native code, works in Expo Go. TypeScript types included.
package/README.es.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-30363d?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-0891b2?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/es/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-es.gif" width="760" alt="SDKs de ORYKSA: el chat y la voz de la IA en iOS, Android, Flutter, React Native y la web"></a></p>
8
-
9
- SDK oficial de React Native de **ORYKSA AI Employees**. Pon dentro de tu app iOS y Android (React Native o Expo) un empleado de IA que ya conoce tu negocio: un chat listo con el mismo aspecto que el chat de la web de ORYKSA, el nombre y la foto de tu IA desde tu cuenta ORYKSA, en inglés, portugués y español.
10
-
11
- * Documentación: https://developer.oryksa.com/es/sdks
12
- * API: `https://api.oryksa.com/v1`
13
- * Sin código nativo: funciona en Expo Go.
14
-
15
- ## Capturas de pantalla
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
- Los propios componentes del SDK, dibujados por el CI en Chrome a tamaño de móvil con React Native for Web y una cuenta de prueba de ORYKSA (`test/web/`). En el móvil el chat muestra también el micrófono, que necesita las bibliotecas de audio nativas. El chat verde usa el código de *Colores y tema*, más abajo.
20
-
21
- ## Instalar
22
-
23
- ```bash
24
- npm install @oryksa/react-native
25
- ```
26
-
27
- ## Para qué sirve
28
-
29
- El SDK pone el chat y la voz de ORYKSA dentro de tu app para atender a los **clientes de tu negocio**: preguntan, compran y reservan. La IA responde con tu Brain, tus productos y tus servicios, con el nombre, la foto y la voz que elegiste en *Tu IA*, y guarda leads, reservas y ventas en las Actividades de tu cuenta ORYKSA. **No** es una interfaz para el dueño: a través del SDK nadie cambia ajustes, lee las Actividades ni da órdenes a ORYKSA. Más información: https://help.oryksa.com/es/a/sdks-what-they-do
30
-
31
- Las palabrotas que escribe el cliente aparecen con asteriscos en el chat (la misma lista de todos los chats de ORYKSA, cargada desde `https://app.oryksa.com/widget/profanity.json` y guardada 24 horas). Las respuestas de la IA ya vienen filtradas desde el servidor.
32
-
33
- ## Voz y contexto de la app (1.1)
34
-
35
- El chat muestra un micrófono cuando tu plan incluye voz. Abre la pantalla de voz con el mismo comportamiento que la app de ORYKSA: el micrófono sigue abierto mientras ella habla y solo una voz humana la interrumpe (el tecleo, la televisión y su propio eco no); se detiene en la palabra y el texto queda en el chat; a un susurro responde con un susurro; si su voz falla, se muestra el texto (nunca una voz robótica).
36
-
37
- La voz necesita tres bibliotecas nativas (dependencias peer opcionales) y el permiso de micrófono (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
- Sin ellas, el chat funciona y el micrófono queda oculto. Con Expo u otra pila de audio: pasa tu propio adaptador `audio` (`startMic`, `stopMic`, `play`, `stopPlayback`).
44
-
45
- Cada respuesta de la IA tiene un botón de copiar debajo. Usa `@react-native-clipboard/clipboard` cuando está instalado (dependencia peer opcional: `npm install @react-native-clipboard/clipboard`); las versiones antiguas de React Native usan el `Clipboard` integrado.
46
-
47
- ```jsx
48
- <OryksaChatButton client={client} lang="pt"
49
- appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
50
- ```
51
-
52
- ## Enlaces con botón Abrir (1.1.3)
53
-
54
- Los enlaces que da la IA se pueden tocar en el chat (direcciones web y e-mails), y cada enlace web tiene una tarjeta debajo de su respuesta con la foto y el título de la página y un botón **Abrir** (las páginas de tu propio sitio, los dominios de tu chat web; otros sitios muestran la dirección). La pantalla de voz muestra lo que ella dice sin las direcciones, con las mismas tarjetas; tocar Abrir cierra la pantalla de voz. Pasa `onLink` para abrir tus propias pantallas, por ejemplo la página del producto: devuelve true cuando tu app lo abrió, false para que lo abra el sistema (`Linking.openURL`).
55
-
56
- ```jsx
57
- <OryksaChatButton client={client} lang="es"
58
- onLink={(url) => {
59
- const id = myProductIdOf(url); // tus rutas
60
- if (!id) return false;
61
- navigation.navigate("Product", { id });
62
- return true;
63
- }} />
64
- ```
65
-
66
- `onLink` también está en `OryksaChat`, `OryksaChatModal` y `OryksaVoiceScreen`.
67
-
68
- ## Adjuntar una foto o un documento (1.1.3)
69
-
70
- El chat tiene un botón de adjuntar (un clip, activado por defecto): una foto de la galería, una foto de la cámara o un documento (PDF, Word, texto, CSV, hasta 8 MB). La IA mira la foto (reducida a 1600 píxeles, JPEG 80%, hasta 2 MB) y lee el documento; la burbuja del cliente muestra la foto, o el icono del documento y su nombre. `attachments={false}` oculta el botón.
71
-
72
- React Native no tiene selector propio, así que el SDK usa dos bibliotecas opcionales que tu app instala (dependencias peer opcionales, como las de la voz). Cada opción solo aparece cuando su biblioteca está; sin las dos, el botón se oculta:
73
-
74
- ```sh
75
- npm install react-native-image-picker @react-native-documents/picker
76
- ```
77
-
78
- * `react-native-image-picker`: galería y cámara. Info.plist de iOS: `NSPhotoLibraryUsageDescription` y `NSCameraUsageDescription`. Android: ningún permiso para la galería; para la cámara, `CAMERA` solo hace falta si tu app lo declara en su propio manifest (entonces concédelo antes de abrir la cámara).
79
- * `@react-native-documents/picker`: documentos, en el selector de documentos del sistema (sin permiso). Los documentos se leen con `react-native-fs` cuando está instalado, si no con `fetch`.
80
-
81
- ```jsx
82
- <OryksaChatButton client={client} lang="es" attachments={false} /> {/* sin botón de adjuntar */}
83
-
84
- // Expo u otra stack: tus propios selectores (si falta uno, se oculta esa opción)
85
- const picker = {
86
- pickPhoto: () => myPhotoPicker(), // { base64, mime } reducida (1600 px, JPEG 80%), o null
87
- pickDocument: () => myDocumentPicker(), // { base64, name, mime }, o null
88
- };
89
- <OryksaChat client={client} picker={picker} />
90
- ```
91
-
92
- Sin la interfaz: `client.send("Aquí está el presupuesto", { file: { base64, name: "presupuesto.pdf", mime: "application/pdf" } })` (fotos: `{ image: { base64, mime } }`).
93
-
94
- ## Cómo funciona (y por qué la clave está segura)
95
-
96
- 1. Tu **servidor** guarda la clave secreta de la API (`oryk_live_...`, creada en developer.oryksa.com) y crea un **token de sesión** de corta duración para cada usuario que ha iniciado sesión, con `POST /v1/sessions` (con `@oryksa/sdk` en Node: `oryksa.createSession(...)`).
97
- 2. Tu **app** recibe solo ese token de sesión (`oryk_cs_...`). La clave secreta nunca entra en la app.
98
- 3. Cada respuesta de la IA cuenta como una interacción de tu plan ORYKSA, igual que en WhatsApp.
99
-
100
- ## En la 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
- Otras piezas:
120
-
121
- * `<OryksaChatModal client={client} visible={open} onClose={() => setOpen(false)} />`: abre el chat desde tu propio botón.
122
- * `<OryksaChat client={client} />`: el panel dentro de cualquier pantalla.
123
- * `theme={{ accent: "#5B57E0" }}`: colores.
124
- * Sin la interfaz: `await client.agent()`, `await client.sendAndWait("Are you open on Saturday?")`, `await client.messages()`.
125
-
126
- ## Mantén la IA sincronizada con tu app
127
-
128
- En tu servidor, con `@oryksa/sdk`:
129
-
130
- ```js
131
- await oryksa.learnApp({ name: "FitTrack", description: "...", screens: [...], faq: [...] });
132
- ```
133
-
134
- ## Errores
135
-
136
- Las llamadas que fallan lanzan `OryksaError` con `status`, `code` (por ejemplo `interaction_limit_reached`, `rate_limited`, `plan_required`) y `message`.
137
-
138
- ## Colores y tema
139
-
140
- La prop `theme` recibe un objeto con hasta cinco colores en texto hexadecimal: `accent` (botones, burbujas del visitante, enlaces), `ink` (texto principal), `soft` (burbujas de la IA), `background` (panel) y `muted` (texto secundario). Las claves que faltan mantienen el valor por defecto, así que `{ accent: "#0E8A6B" }` basta. Funciona en `OryksaChatButton`, `OryksaChatModal` y `OryksaChat`, y los valores por defecto se exportan como `DEFAULT_THEME`.
141
-
142
- ```jsx
143
- const theme = { accent: "#0E8A6B" };
144
-
145
- <OryksaChatButton client={client} lang="en" theme={theme} />
146
- ```
147
-
148
- No hay tema oscuro automático: para el modo oscuro, pasa tus propios colores oscuros.
149
-
150
- ---
151
-
152
- ## Sobre el autor
153
-
154
- **Weslley Harakawa** - Fundador de ORYKSA AI. En Lisboa, Portugal. Especialidades: inteligencia artificial, desarrollo web y móvil, tokenización en blockchain. Formación: 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-30363d?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-0891b2?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/es/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-es.gif" width="760" alt="SDKs de ORYKSA: el chat y la voz de la IA en iOS, Android, Flutter, React Native y la web"></a></p>
8
+
9
+ SDK oficial de React Native de **ORYKSA AI Employees**. Pon dentro de tu app iOS y Android (React Native o Expo) un empleado de IA que ya conoce tu negocio: un chat listo con el mismo aspecto que el chat de la web de ORYKSA, el nombre y la foto de tu IA desde tu cuenta ORYKSA, en inglés, portugués y español.
10
+
11
+ * Documentación: https://developer.oryksa.com/es/sdks
12
+ * API: `https://api.oryksa.com/v1`
13
+ * Sin código nativo: funciona en Expo Go.
14
+
15
+ ## Capturas de pantalla
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
+ Los propios componentes del SDK, dibujados por el CI en Chrome a tamaño de móvil con React Native for Web y una cuenta de prueba de ORYKSA (`test/web/`). En el móvil el chat muestra también el micrófono, que necesita las bibliotecas de audio nativas. El chat verde usa el código de *Colores y tema*, más abajo.
20
+
21
+ ## Instalar
22
+
23
+ ```bash
24
+ npm install @oryksa/react-native
25
+ ```
26
+
27
+ ## Para qué sirve
28
+
29
+ El SDK pone el chat y la voz de ORYKSA dentro de tu app para atender a los **clientes de tu negocio**: preguntan, compran y reservan. La IA responde con tu Brain, tus productos y tus servicios, con el nombre, la foto y la voz que elegiste en *Tu IA*, y guarda leads, reservas y ventas en las Actividades de tu cuenta ORYKSA. **No** es una interfaz para el dueño: a través del SDK nadie cambia ajustes, lee las Actividades ni da órdenes a ORYKSA. Más información: https://help.oryksa.com/es/a/sdks-what-they-do
30
+
31
+ Las palabrotas que escribe el cliente aparecen con asteriscos en el chat (la misma lista de todos los chats de ORYKSA, cargada desde `https://app.oryksa.com/widget/profanity.json` y guardada 24 horas). Las respuestas de la IA ya vienen filtradas desde el servidor.
32
+
33
+ ## Voz y contexto de la app (1.1)
34
+
35
+ El chat muestra un micrófono cuando tu plan incluye voz. Abre la pantalla de voz con el mismo comportamiento que la app de ORYKSA: el micrófono sigue abierto mientras ella habla y solo una voz humana la interrumpe (el tecleo, la televisión y su propio eco no); se detiene en la palabra y el texto queda en el chat; a un susurro responde con un susurro; si su voz falla, se muestra el texto (nunca una voz robótica).
36
+
37
+ La voz necesita tres bibliotecas nativas (dependencias peer opcionales) y el permiso de micrófono (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
+ Sin ellas, el chat funciona y el micrófono queda oculto. Con Expo u otra pila de audio: pasa tu propio adaptador `audio` (`startMic`, `stopMic`, `play`, `stopPlayback`).
44
+
45
+ Cada respuesta de la IA tiene un botón de copiar debajo. Usa `@react-native-clipboard/clipboard` cuando está instalado (dependencia peer opcional: `npm install @react-native-clipboard/clipboard`); las versiones antiguas de React Native usan el `Clipboard` integrado.
46
+
47
+ ```jsx
48
+ <OryksaChatButton client={client} lang="pt"
49
+ appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
50
+ ```
51
+
52
+ ## Enlaces con botón Abrir (1.1.3)
53
+
54
+ Los enlaces que da la IA se pueden tocar en el chat (direcciones web y e-mails), y cada enlace web tiene una tarjeta debajo de su respuesta con la foto y el título de la página y un botón **Abrir** (las páginas de tu propio sitio, los dominios de tu chat web; otros sitios muestran la dirección). La pantalla de voz muestra lo que ella dice sin las direcciones, con las mismas tarjetas; tocar Abrir cierra la pantalla de voz. Pasa `onLink` para abrir tus propias pantallas, por ejemplo la página del producto: devuelve true cuando tu app lo abrió, false para que lo abra el sistema (`Linking.openURL`).
55
+
56
+ ```jsx
57
+ <OryksaChatButton client={client} lang="es"
58
+ onLink={(url) => {
59
+ const id = myProductIdOf(url); // tus rutas
60
+ if (!id) return false;
61
+ navigation.navigate("Product", { id });
62
+ return true;
63
+ }} />
64
+ ```
65
+
66
+ `onLink` también está en `OryksaChat`, `OryksaChatModal` y `OryksaVoiceScreen`.
67
+
68
+ ## Adjuntar una foto o un documento (1.1.3)
69
+
70
+ El chat tiene un botón de adjuntar (un clip, activado por defecto): una foto de la galería, una foto de la cámara o un documento (PDF, Word, texto, CSV, hasta 8 MB). La IA mira la foto (reducida a 1600 píxeles, JPEG 80%, hasta 2 MB) y lee el documento; la burbuja del cliente muestra la foto, o el icono del documento y su nombre. `attachments={false}` oculta el botón.
71
+
72
+ React Native no tiene selector propio, así que el SDK usa dos bibliotecas opcionales que tu app instala (dependencias peer opcionales, como las de la voz). Cada opción solo aparece cuando su biblioteca está; sin las dos, el botón se oculta:
73
+
74
+ ```sh
75
+ npm install react-native-image-picker @react-native-documents/picker
76
+ ```
77
+
78
+ * `react-native-image-picker`: galería y cámara. Info.plist de iOS: `NSPhotoLibraryUsageDescription` y `NSCameraUsageDescription`. Android: ningún permiso para la galería; para la cámara, `CAMERA` solo hace falta si tu app lo declara en su propio manifest (entonces concédelo antes de abrir la cámara).
79
+ * `@react-native-documents/picker`: documentos, en el selector de documentos del sistema (sin permiso). Los documentos se leen con `react-native-fs` cuando está instalado, si no con `fetch`.
80
+
81
+ ```jsx
82
+ <OryksaChatButton client={client} lang="es" attachments={false} /> {/* sin botón de adjuntar */}
83
+
84
+ // Expo u otra stack: tus propios selectores (si falta uno, se oculta esa opción)
85
+ const picker = {
86
+ pickPhoto: () => myPhotoPicker(), // { base64, mime } reducida (1600 px, JPEG 80%), o null
87
+ pickDocument: () => myDocumentPicker(), // { base64, name, mime }, o null
88
+ };
89
+ <OryksaChat client={client} picker={picker} />
90
+ ```
91
+
92
+ Sin la interfaz: `client.send("Aquí está el presupuesto", { file: { base64, name: "presupuesto.pdf", mime: "application/pdf" } })` (fotos: `{ image: { base64, mime } }`).
93
+
94
+ ## Tus funciones de IA: `ai` (1.1.4)
95
+
96
+ Haz que la IA haga lo que tu app necesita (leer una foto, extraer datos, clasificar, traducir, escribir) y paga con interacciones ORYKSA: 1 por respuesta. Tu prompt y tu JSON Schema viven en tu app; basta el token de sesión (nunca lleves la clave secreta). No crea una conversación en tu bandeja.
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` trae la respuesta en texto, `r.json` el objeto (con schema) y `r.interactionsSpent` las interacciones usadas. Cuando se agotan las interacciones del plan, la llamada lanza `OryksaError` con el status 402.
113
+
114
+ ## Cómo funciona (y por qué la clave está segura)
115
+
116
+ 1. Tu **servidor** guarda la clave secreta de la API (`oryk_live_...`, creada en developer.oryksa.com) y crea un **token de sesión** de corta duración para cada usuario que ha iniciado sesión, con `POST /v1/sessions` (con `@oryksa/sdk` en Node: `oryksa.createSession(...)`).
117
+ 2. Tu **app** recibe solo ese token de sesión (`oryk_cs_...`). La clave secreta nunca entra en la app.
118
+ 3. Cada respuesta de la IA cuenta como una interacción de tu plan ORYKSA, igual que en WhatsApp.
119
+
120
+ ## En la 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
+ Otras piezas:
140
+
141
+ * `<OryksaChatModal client={client} visible={open} onClose={() => setOpen(false)} />`: abre el chat desde tu propio botón.
142
+ * `<OryksaChat client={client} />`: el panel dentro de cualquier pantalla.
143
+ * `theme={{ accent: "#5B57E0" }}`: colores.
144
+ * Sin la interfaz: `await client.agent()`, `await client.sendAndWait("Are you open on Saturday?")`, `await client.messages()`.
145
+
146
+ ## Mantén la IA sincronizada con tu app
147
+
148
+ En tu servidor, con `@oryksa/sdk`:
149
+
150
+ ```js
151
+ await oryksa.learnApp({ name: "FitTrack", description: "...", screens: [...], faq: [...] });
152
+ ```
153
+
154
+ ## Errores
155
+
156
+ Las llamadas que fallan lanzan `OryksaError` con `status`, `code` (por ejemplo `interaction_limit_reached`, `rate_limited`, `plan_required`) y `message`.
157
+
158
+ ## Colores y tema
159
+
160
+ La prop `theme` recibe un objeto con hasta cinco colores en texto hexadecimal: `accent` (botones, burbujas del visitante, enlaces), `ink` (texto principal), `soft` (burbujas de la IA), `background` (panel) y `muted` (texto secundario). Las claves que faltan mantienen el valor por defecto, así que `{ accent: "#0E8A6B" }` basta. Funciona en `OryksaChatButton`, `OryksaChatModal` y `OryksaChat`, y los valores por defecto se exportan como `DEFAULT_THEME`.
161
+
162
+ ```jsx
163
+ const theme = { accent: "#0E8A6B" };
164
+
165
+ <OryksaChatButton client={client} lang="en" theme={theme} />
166
+ ```
167
+
168
+ No hay tema oscuro automático: para el modo oscuro, pasa tus propios colores oscuros.
169
+
170
+ ---
171
+
172
+ ## Sobre el autor
173
+
174
+ **Weslley Harakawa** - Fundador de ORYKSA AI. En Lisboa, Portugal. Especialidades: inteligencia artificial, desarrollo web y móvil, tokenización en blockchain. Formación: 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