@oryksa/sdk 0.1.3 → 0.1.5

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.es.md ADDED
@@ -0,0 +1,133 @@
1
+ <p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
2
+
3
+ # @oryksa/sdk
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 JavaScript y TypeScript de **ORYKSA AI Employees**: pon un empleado de IA que ya conoce el negocio dentro de tu app web, tu backend Node o tu app de escritorio Electron. El mismo cerebro de WhatsApp y del chat del sitio web, en texto y voz.
10
+
11
+ - Documentación: https://developer.oryksa.com
12
+ - API: `https://api.oryksa.com/v1`
13
+
14
+ ## Capturas de pantalla
15
+
16
+ <p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_en.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_en.png" width="420" alt="Chat with the README theme"></p>
17
+
18
+ Una página de tienda con `mountChat`, capturada por el CI en Chrome con una cuenta de prueba de ORYKSA (`test/shots.html`): colores por defecto a la izquierda y, a la derecha, el código de *Colores y tema*, más abajo.
19
+
20
+ ## Instalar
21
+
22
+ ```bash
23
+ npm install @oryksa/sdk
24
+ ```
25
+
26
+ ## Servidor (clave secreta)
27
+
28
+ ```js
29
+ import { Oryksa } from "@oryksa/sdk";
30
+ const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
31
+
32
+ const r = await oryksa.chat({ message: "Are you open on Saturday?" });
33
+ console.log(r.reply, r.conversation_id);
34
+
35
+ // Teach the AI employee about your app (e.g. on every release)
36
+ await oryksa.learnApp({
37
+ name: "FitTrack",
38
+ description: "Fitness app to log workouts and follow training plans.",
39
+ screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
40
+ faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
41
+ });
42
+ ```
43
+
44
+ ## En la app (token de sesión, nunca la clave secreta)
45
+
46
+ ```js
47
+ // your server
48
+ app.get("/oryksa-token", requireLogin, async (req, res) => {
49
+ const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
50
+ res.json({ token: s.client_token });
51
+ });
52
+
53
+ // your web app
54
+ import { OryksaClient, mountChat } from "@oryksa/sdk";
55
+ const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
56
+ mountChat({ client, lang: "en" }); // ready-made chat UI
57
+ ```
58
+
59
+ ## Enlaces con botón Abrir (0.1.5)
60
+
61
+ Los enlaces que da la IA se pueden pulsar 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). Pasa `onLink` para abrir tus propias páginas, por ejemplo la página del producto: devuelve true cuando tu app lo abrió, false para abrirlo en una pestaña nueva.
62
+
63
+ ```js
64
+ mountChat({
65
+ client, lang: "es",
66
+ onLink: (url) => {
67
+ const id = myProductIdOf(url); // tus rutas
68
+ if (!id) return false;
69
+ router.push("/product/" + id);
70
+ return true;
71
+ },
72
+ });
73
+ ```
74
+
75
+ `client.linkPreview(url)` da el título y la foto de un enlace (`null` cuando no se puede leer); `linksIn(text)` y `withoutLinks(text)` también se exportan.
76
+
77
+ ## Adjuntar una foto o un documento (0.1.5)
78
+
79
+ El chat de `mountChat` tiene un botón para adjuntar: foto de la galería, cámara (móviles y tabletas) o documento (PDF, Word, texto, CSV). Las fotos se reducen antes de enviarse (hasta 2 MB); documentos hasta 8 MB. La IA ve la foto o lee el documento. Se desactiva con `attachments: false`. Por código: `client.send(texto, { image: { base64, mime } })` o `{ file: { base64, name, mime } }`.
80
+
81
+ ## Tus funciones de IA: `ai` (0.1.5)
82
+
83
+ Haz que la IA haga lo que tu app o web 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 código; basta el token de sesión (nunca lleves la clave secreta). No crea una conversación en tu bandeja.
84
+
85
+ ```js
86
+ const r = await client.ai({
87
+ instructions: "Read the tyre on the photo: brand, model and size exactly as written on the sidewall. " +
88
+ "If the size is not legible, readable=false and size=null. Never invent.",
89
+ images: [{ base64: photoBase64, mime: "image/jpeg" }], // resized to 1600 px
90
+ schema: {
91
+ type: "object",
92
+ properties: { readable: { type: "boolean" }, brand: { type: ["string", "null"] }, size: { type: ["string", "null"] } },
93
+ required: ["readable", "brand", "size"],
94
+ },
95
+ });
96
+ if (r.json?.readable) showProducts(r.json.size);
97
+ ```
98
+
99
+ `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 falla con `OryksaError` status 402.
100
+
101
+ ## Colores y tema
102
+
103
+ `mountChat` acepta tres colores como texto CSS: `accent` (botones, burbujas del visitante, enlaces), `ink` (texto principal) y `soft` (burbujas de la IA). Los que falten mantienen el valor por defecto (`#5B57E0`, `#161B3D` y `#EEEBFB`). `position` (`"left"` o `"right"`) elige el lado de la pantalla.
104
+
105
+ ```js
106
+ mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
107
+ ```
108
+
109
+ ## Webhooks
110
+
111
+ ```js
112
+ import { verifyWebhook } from "@oryksa/sdk";
113
+ app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
114
+ const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
115
+ if (event.type === "booking.created") { /* save it */ }
116
+ res.sendStatus(200);
117
+ });
118
+ ```
119
+
120
+ ## Errores
121
+
122
+ Cada llamada que falla lanza `OryksaError` con `status`, `code` (por ejemplo `interaction_limit_reached`, `rate_limited`, `plan_required`) y `message`.
123
+
124
+ ## Sobre el autor
125
+
126
+ **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.
127
+
128
+ - LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
129
+ - ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
130
+
131
+ ---
132
+
133
+ MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
package/README.fr.md ADDED
@@ -0,0 +1,133 @@
1
+ <p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
2
+
3
+ # @oryksa/sdk
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-30363d?style=for-the-badge)](README.es.md) [![Français](https://img.shields.io/badge/Fran%C3%A7ais-0891b2?style=for-the-badge)](README.fr.md)
6
+
7
+ <p align="center"><a href="https://developer.oryksa.com/fr/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-fr.gif" width="760" alt="SDK ORYKSA : le chat et la voix de l'IA sur iOS, Android, Flutter, React Native et le web"></a></p>
8
+
9
+ SDK officiel JavaScript et TypeScript d'**ORYKSA AI Employees** : placez un employé IA qui connaît déjà l'entreprise dans votre app web, votre backend Node ou votre app de bureau Electron. Le même cerveau que WhatsApp et le chat du site web, en texte et en voix.
10
+
11
+ - Documentation : https://developer.oryksa.com
12
+ - API : `https://api.oryksa.com/v1`
13
+
14
+ ## Captures d'écran
15
+
16
+ <p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_en.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_en.png" width="420" alt="Chat with the README theme"></p>
17
+
18
+ Une page de boutique avec `mountChat`, capturée par la CI dans Chrome avec un compte de test ORYKSA (`test/shots.html`) : couleurs par défaut à gauche et, à droite, le code de *Couleurs et thème*, plus bas.
19
+
20
+ ## Installer
21
+
22
+ ```bash
23
+ npm install @oryksa/sdk
24
+ ```
25
+
26
+ ## Serveur (clé secrète)
27
+
28
+ ```js
29
+ import { Oryksa } from "@oryksa/sdk";
30
+ const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
31
+
32
+ const r = await oryksa.chat({ message: "Are you open on Saturday?" });
33
+ console.log(r.reply, r.conversation_id);
34
+
35
+ // Teach the AI employee about your app (e.g. on every release)
36
+ await oryksa.learnApp({
37
+ name: "FitTrack",
38
+ description: "Fitness app to log workouts and follow training plans.",
39
+ screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
40
+ faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
41
+ });
42
+ ```
43
+
44
+ ## Dans l'app (jeton de session, jamais la clé secrète)
45
+
46
+ ```js
47
+ // your server
48
+ app.get("/oryksa-token", requireLogin, async (req, res) => {
49
+ const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
50
+ res.json({ token: s.client_token });
51
+ });
52
+
53
+ // your web app
54
+ import { OryksaClient, mountChat } from "@oryksa/sdk";
55
+ const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
56
+ mountChat({ client, lang: "en" }); // ready-made chat UI
57
+ ```
58
+
59
+ ## Liens avec un bouton pour les ouvrir (0.1.5)
60
+
61
+ Les liens que donne l'IA se cliquent dans le chat (adresses web et e-mails), et chaque lien web a une carte sous sa réponse avec la photo et le titre de la page et un bouton pour l'ouvrir (les pages de votre propre site, les domaines de votre chat web ; les autres sites montrent l'adresse). Passez `onLink` pour ouvrir vos propres pages, par exemple la page du produit : renvoyez true quand votre app l'a ouvert, false pour l'ouvrir dans un nouvel onglet.
62
+
63
+ ```js
64
+ mountChat({
65
+ client, lang: "en",
66
+ onLink: (url) => {
67
+ const id = myProductIdOf(url); // vos routes
68
+ if (!id) return false;
69
+ router.push("/product/" + id);
70
+ return true;
71
+ },
72
+ });
73
+ ```
74
+
75
+ `client.linkPreview(url)` donne le titre et la photo d'un lien (`null` quand il ne peut pas être lu) ; `linksIn(text)` et `withoutLinks(text)` sont aussi exportés.
76
+
77
+ ## Joindre une photo ou un document (0.1.5)
78
+
79
+ Le chat de `mountChat` a un bouton pour joindre : photo de la galerie, appareil photo (téléphones et tablettes) ou document (PDF, Word, texte, CSV). Les photos sont réduites avant l'envoi (jusqu'à 2 Mo) ; documents jusqu'à 8 Mo. L'IA regarde la photo ou lit le document. À désactiver avec `attachments: false`. Par code : `client.send(texte, { image: { base64, mime } })` ou `{ file: { base64, name, mime } }`.
80
+
81
+ ## Vos propres fonctions d'IA : `ai` (0.1.5)
82
+
83
+ Faites faire à l'IA ce dont votre app ou site a besoin (lire une photo, extraire des données, classer, traduire, rédiger) et payez en interactions ORYKSA : 1 par réponse. Votre prompt et votre JSON Schema restent dans votre code ; le jeton de session suffit (n'embarquez jamais la clé secrète). Aucune conversation n'est créée dans votre boîte.
84
+
85
+ ```js
86
+ const r = await client.ai({
87
+ instructions: "Read the tyre on the photo: brand, model and size exactly as written on the sidewall. " +
88
+ "If the size is not legible, readable=false and size=null. Never invent.",
89
+ images: [{ base64: photoBase64, mime: "image/jpeg" }], // resized to 1600 px
90
+ schema: {
91
+ type: "object",
92
+ properties: { readable: { type: "boolean" }, brand: { type: ["string", "null"] }, size: { type: ["string", "null"] } },
93
+ required: ["readable", "brand", "size"],
94
+ },
95
+ });
96
+ if (r.json?.readable) showProducts(r.json.size);
97
+ ```
98
+
99
+ `r.text` contient la réponse en texte, `r.json` l'objet (avec un schema) et `r.interactionsSpent` les interactions utilisées. Quand les interactions du forfait sont épuisées, l'appel échoue avec `OryksaError` status 402.
100
+
101
+ ## Couleurs et thème
102
+
103
+ `mountChat` accepte trois couleurs en texte CSS : `accent` (boutons, bulles du visiteur, liens), `ink` (texte principal) et `soft` (bulles de l'IA). Celles qui manquent gardent la valeur par défaut (`#5B57E0`, `#161B3D` et `#EEEBFB`). `position` (`"left"` ou `"right"`) choisit le côté de l'écran.
104
+
105
+ ```js
106
+ mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
107
+ ```
108
+
109
+ ## Webhooks
110
+
111
+ ```js
112
+ import { verifyWebhook } from "@oryksa/sdk";
113
+ app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
114
+ const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
115
+ if (event.type === "booking.created") { /* save it */ }
116
+ res.sendStatus(200);
117
+ });
118
+ ```
119
+
120
+ ## Erreurs
121
+
122
+ Chaque appel qui échoue lève `OryksaError` avec `status`, `code` (par exemple `interaction_limit_reached`, `rate_limited`, `plan_required`) et `message`.
123
+
124
+ ## À propos de l'auteur
125
+
126
+ **Weslley Harakawa** - Fondateur d'ORYKSA AI. À Lisbonne, Portugal. Spécialités : intelligence artificielle, développement web et mobile, tokenisation blockchain. Formation : University of the People.
127
+
128
+ - LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
129
+ - ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
130
+
131
+ ---
132
+
133
+ MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
package/README.md CHANGED
@@ -1,75 +1,133 @@
1
- <p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
2
-
3
- # @oryksa/sdk
4
-
5
- Official JavaScript and TypeScript SDK for **ORYKSA AI Employees**: put an AI employee that already knows the business inside your web app, Node backend or Electron desktop app. Same brain as WhatsApp and the website chat, text and voice.
6
-
7
- - Docs: https://developer.oryksa.com
8
- - API: `https://api.oryksa.com/v1`
9
-
10
- ## Install
11
-
12
- ```bash
13
- npm install @oryksa/sdk
14
- ```
15
-
16
- ## Server (secret key)
17
-
18
- ```js
19
- import { Oryksa } from "@oryksa/sdk";
20
- const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
21
-
22
- const r = await oryksa.chat({ message: "Are you open on Saturday?" });
23
- console.log(r.reply, r.conversation_id);
24
-
25
- // Teach the AI employee about your app (e.g. on every release)
26
- await oryksa.learnApp({
27
- name: "FitTrack",
28
- description: "Fitness app to log workouts and follow training plans.",
29
- screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
30
- faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
31
- });
32
- ```
33
-
34
- ## In the app (session token, never the secret key)
35
-
36
- ```js
37
- // your server
38
- app.get("/oryksa-token", requireLogin, async (req, res) => {
39
- const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
40
- res.json({ token: s.client_token });
41
- });
42
-
43
- // your web app
44
- import { OryksaClient, mountChat } from "@oryksa/sdk";
45
- const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
46
- mountChat({ client, lang: "en" }); // ready-made chat UI
47
- ```
48
-
49
- ## Webhooks
50
-
51
- ```js
52
- import { verifyWebhook } from "@oryksa/sdk";
53
- app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
54
- const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
55
- if (event.type === "booking.created") { /* save it */ }
56
- res.sendStatus(200);
57
- });
58
- ```
59
-
60
- ## Errors
61
-
62
- Every failed call throws `OryksaError` with `status`, `code` (for example `interaction_limit_reached`, `rate_limited`, `plan_required`) and `message`.
63
-
64
- ## About the author
65
-
66
- **Weslley Harakawa** - Founder of ORYKSA AI. Based in Lisbon, Portugal. Specialties: artificial intelligence, web and mobile development, blockchain tokenization. Education: University of the People.
67
-
68
- - Website: https://harakawa.tech
69
- - LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
70
- - Instagram: https://www.instagram.com/weslley.harakawa
71
- - ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSAAI)
72
-
73
- ---
74
-
75
- 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/sdk
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 JavaScript and TypeScript SDK for **ORYKSA AI Employees**: put an AI employee that already knows the business inside your web app, Node backend or Electron desktop app. Same brain as WhatsApp and the website chat, text and voice.
10
+
11
+ - Docs: https://developer.oryksa.com
12
+ - API: `https://api.oryksa.com/v1`
13
+
14
+ ## Screenshots
15
+
16
+ <p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_en.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_en.png" width="420" alt="Chat with the README theme"></p>
17
+
18
+ A store page with `mountChat`, captured by CI in Chrome with an ORYKSA test account (`test/shots.html`): default colors on the left, the code of *Colours and theme* below on the right.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ npm install @oryksa/sdk
24
+ ```
25
+
26
+ ## Server (secret key)
27
+
28
+ ```js
29
+ import { Oryksa } from "@oryksa/sdk";
30
+ const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
31
+
32
+ const r = await oryksa.chat({ message: "Are you open on Saturday?" });
33
+ console.log(r.reply, r.conversation_id);
34
+
35
+ // Teach the AI employee about your app (e.g. on every release)
36
+ await oryksa.learnApp({
37
+ name: "FitTrack",
38
+ description: "Fitness app to log workouts and follow training plans.",
39
+ screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
40
+ faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
41
+ });
42
+ ```
43
+
44
+ ## In the app (session token, never the secret key)
45
+
46
+ ```js
47
+ // your server
48
+ app.get("/oryksa-token", requireLogin, async (req, res) => {
49
+ const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
50
+ res.json({ token: s.client_token });
51
+ });
52
+
53
+ // your web app
54
+ import { OryksaClient, mountChat } from "@oryksa/sdk";
55
+ const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
56
+ mountChat({ client, lang: "en" }); // ready-made chat UI
57
+ ```
58
+
59
+ ## Links with an Open button (0.1.5)
60
+
61
+ The links the AI gives can be clicked 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). Pass `onLink` to open your own pages, for example your product page: return true when your app opened it, false to open it in a new tab.
62
+
63
+ ```js
64
+ mountChat({
65
+ client, lang: "en",
66
+ onLink: (url) => {
67
+ const id = myProductIdOf(url); // your routes
68
+ if (!id) return false;
69
+ router.push("/product/" + id);
70
+ return true;
71
+ },
72
+ });
73
+ ```
74
+
75
+ `client.linkPreview(url)` gives the title and picture of a link (`null` when it cannot be read); `linksIn(text)` and `withoutLinks(text)` are exported too.
76
+
77
+ ## Attach a photo or a document (0.1.5)
78
+
79
+ The chat of `mountChat` has an attach button: a photo from the library, the camera (phones and tablets) or a document (PDF, Word, text, CSV). Photos are made smaller before they go (up to 2 MB); documents up to 8 MB. The AI looks at the photo or reads the document. Turn it off with `attachments: false`. From code: `client.send(text, { image: { base64, mime } })` or `{ file: { base64, name, mime } }`.
80
+
81
+ ## Your own AI features: `ai` (0.1.5)
82
+
83
+ Have the AI do what your app or site 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 code; the session token is enough (never ship the secret key). It does not create a conversation in your inbox.
84
+
85
+ ```js
86
+ const r = await client.ai({
87
+ instructions: "Read the tyre on the photo: brand, model and size exactly as written on the sidewall. " +
88
+ "If the size is not legible, readable=false and size=null. Never invent.",
89
+ images: [{ base64: photoBase64, mime: "image/jpeg" }], // resized to 1600 px
90
+ schema: {
91
+ type: "object",
92
+ properties: { readable: { type: "boolean" }, brand: { type: ["string", "null"] }, size: { type: ["string", "null"] } },
93
+ required: ["readable", "brand", "size"],
94
+ },
95
+ });
96
+ if (r.json?.readable) showProducts(r.json.size);
97
+ ```
98
+
99
+ `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 rejects with `OryksaError` status 402.
100
+
101
+ ## Colours and theme
102
+
103
+ `mountChat` accepts three colors as CSS strings: `accent` (buttons, visitor bubbles, links), `ink` (main text) and `soft` (AI bubbles). Missing ones keep the default (`#5B57E0`, `#161B3D` and `#EEEBFB`). `position` (`"left"` or `"right"`) picks the side of the screen.
104
+
105
+ ```js
106
+ mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
107
+ ```
108
+
109
+ ## Webhooks
110
+
111
+ ```js
112
+ import { verifyWebhook } from "@oryksa/sdk";
113
+ app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
114
+ const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
115
+ if (event.type === "booking.created") { /* save it */ }
116
+ res.sendStatus(200);
117
+ });
118
+ ```
119
+
120
+ ## Errors
121
+
122
+ Every failed call throws `OryksaError` with `status`, `code` (for example `interaction_limit_reached`, `rate_limited`, `plan_required`) and `message`.
123
+
124
+ ## About the author
125
+
126
+ **Weslley Harakawa** - Founder of ORYKSA AI. Based in Lisbon, Portugal. Specialties: artificial intelligence, web and mobile development, blockchain tokenization. Education: University of the People.
127
+
128
+ - LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
129
+ - ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
130
+
131
+ ---
132
+
133
+ MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
package/README.pt.md ADDED
@@ -0,0 +1,133 @@
1
+ <p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
2
+
3
+ # @oryksa/sdk
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-0891b2?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/pt/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-pt.gif" width="760" alt="SDKs ORYKSA: o chat e a voz da IA no iOS, Android, Flutter, React Native e na web"></a></p>
8
+
9
+ SDK oficial de JavaScript e TypeScript da **ORYKSA AI Employees**: põe um colaborador de IA que já conhece o negócio dentro da tua app web, do teu backend Node ou da tua app de secretária Electron. O mesmo cérebro do WhatsApp e do chat do site, em texto e voz.
10
+
11
+ - Documentação: https://developer.oryksa.com
12
+ - API: `https://api.oryksa.com/v1`
13
+
14
+ ## Capturas de ecrã
15
+
16
+ <p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_pt.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_pt.png" width="420" alt="Chat com o tema do README"></p>
17
+
18
+ Uma página de loja com `mountChat`, captada pelo CI no Chrome com uma conta de teste da ORYKSA (`test/shots.html`): cores de origem à esquerda e, à direita, o código de *Cores e tema*, mais abaixo.
19
+
20
+ ## Instalar
21
+
22
+ ```bash
23
+ npm install @oryksa/sdk
24
+ ```
25
+
26
+ ## Servidor (chave secreta)
27
+
28
+ ```js
29
+ import { Oryksa } from "@oryksa/sdk";
30
+ const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
31
+
32
+ const r = await oryksa.chat({ message: "Are you open on Saturday?" });
33
+ console.log(r.reply, r.conversation_id);
34
+
35
+ // Teach the AI employee about your app (e.g. on every release)
36
+ await oryksa.learnApp({
37
+ name: "FitTrack",
38
+ description: "Fitness app to log workouts and follow training plans.",
39
+ screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
40
+ faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
41
+ });
42
+ ```
43
+
44
+ ## Na app (token de sessão, nunca a chave secreta)
45
+
46
+ ```js
47
+ // your server
48
+ app.get("/oryksa-token", requireLogin, async (req, res) => {
49
+ const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
50
+ res.json({ token: s.client_token });
51
+ });
52
+
53
+ // your web app
54
+ import { OryksaClient, mountChat } from "@oryksa/sdk";
55
+ const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
56
+ mountChat({ client, lang: "en" }); // ready-made chat UI
57
+ ```
58
+
59
+ ## Links com botão Abrir (0.1.5)
60
+
61
+ Os links que a IA dá ficam clicáveis no chat (endereços web e e-mails), e cada link web ganha um cartão por baixo da resposta com a foto e o título da página e um botão **Abrir** (as páginas do teu próprio site, os domínios do teu chat do site; outros sites mostram o endereço). Passa `onLink` para abrir as tuas próprias páginas, por exemplo a página do produto: devolve true quando a tua app o abriu, false para o abrir num separador novo.
62
+
63
+ ```js
64
+ mountChat({
65
+ client, lang: "pt",
66
+ onLink: (url) => {
67
+ const id = myProductIdOf(url); // as tuas rotas
68
+ if (!id) return false;
69
+ router.push("/product/" + id);
70
+ return true;
71
+ },
72
+ });
73
+ ```
74
+
75
+ `client.linkPreview(url)` dá o título e a foto de um link (`null` quando não se consegue ler); `linksIn(text)` e `withoutLinks(text)` também são exportados.
76
+
77
+ ## Anexar uma foto ou um documento (0.1.5)
78
+
79
+ O chat do `mountChat` tem um botão de anexar: foto da galeria, câmara (telemóveis e tablets) ou documento (PDF, Word, texto, CSV). As fotos são reduzidas antes de seguir (até 2 MB); documentos até 8 MB. A IA vê a foto ou lê o documento. Desliga com `attachments: false`. Por código: `client.send(texto, { image: { base64, mime } })` ou `{ file: { base64, name, mime } }`.
80
+
81
+ ## As tuas funções de IA: `ai` (0.1.5)
82
+
83
+ Põe a IA a fazer o que a tua app ou site precisa (ler uma foto, extrair dados, classificar, traduzir, escrever) e paga com interações ORYKSA: 1 por resposta. O teu prompt e o teu JSON Schema ficam no teu código; basta o token de sessão (nunca leves a chave secreta). Não cria conversa na tua caixa.
84
+
85
+ ```js
86
+ const r = await client.ai({
87
+ instructions: "Read the tyre on the photo: brand, model and size exactly as written on the sidewall. " +
88
+ "If the size is not legible, readable=false and size=null. Never invent.",
89
+ images: [{ base64: photoBase64, mime: "image/jpeg" }], // resized to 1600 px
90
+ schema: {
91
+ type: "object",
92
+ properties: { readable: { type: "boolean" }, brand: { type: ["string", "null"] }, size: { type: ["string", "null"] } },
93
+ required: ["readable", "brand", "size"],
94
+ },
95
+ });
96
+ if (r.json?.readable) showProducts(r.json.size);
97
+ ```
98
+
99
+ `r.text` tem a resposta em texto, `r.json` o objeto (com schema) e `r.interactionsSpent` as interações gastas. Quando as interações do plano acabam, a chamada falha com `OryksaError` status 402.
100
+
101
+ ## Cores e tema
102
+
103
+ O `mountChat` aceita três cores como texto CSS: `accent` (botões, balões do visitante, ligações), `ink` (texto principal) e `soft` (balões da IA). As que faltarem mantêm o valor por omissão (`#5B57E0`, `#161B3D` e `#EEEBFB`). O `position` (`"left"` ou `"right"`) escolhe o lado do ecrã.
104
+
105
+ ```js
106
+ mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
107
+ ```
108
+
109
+ ## Webhooks
110
+
111
+ ```js
112
+ import { verifyWebhook } from "@oryksa/sdk";
113
+ app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
114
+ const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
115
+ if (event.type === "booking.created") { /* save it */ }
116
+ res.sendStatus(200);
117
+ });
118
+ ```
119
+
120
+ ## Erros
121
+
122
+ Cada chamada falhada lança `OryksaError` com `status`, `code` (por exemplo `interaction_limit_reached`, `rate_limited`, `plan_required`) e `message`.
123
+
124
+ ## Sobre o autor
125
+
126
+ **Weslley Harakawa** - Fundador da ORYKSA AI. Em Lisboa, Portugal. Especialidades: inteligência artificial, desenvolvimento web e mobile, tokenização em blockchain. Formação: University of the People.
127
+
128
+ - LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
129
+ - ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
130
+
131
+ ---
132
+
133
+ MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda