@oryksa/react-native 1.0.0 → 1.1.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.
package/src/client.js CHANGED
@@ -1,114 +1,233 @@
1
- /*!
2
- * @oryksa/react-native - in-app client. Uses a short-lived session token (oryk_cs_...)
3
- * created by YOUR server with POST /v1/sessions. The secret API key never goes into the app.
4
- * Docs: https://developer.oryksa.com License: MIT
5
- */
6
- "use strict";
7
-
8
- const DEFAULT_BASE = "https://api.oryksa.com/v1";
9
- const VERSION = "1.0.0";
10
-
11
- class OryksaError extends Error {
12
- constructor(status, code, message, extra) {
13
- super(message);
14
- this.name = "OryksaError";
15
- this.status = status;
16
- this.code = code;
17
- Object.assign(this, extra || {});
18
- }
19
- }
20
-
21
- async function request(base, token, method, path, body, fetchImpl, timeoutMs) {
22
- const f = fetchImpl || globalThis.fetch;
23
- const ctrl = typeof AbortController !== "undefined" ? new AbortController() : null;
24
- const timer = ctrl ? setTimeout(() => ctrl.abort(), timeoutMs) : null;
25
- let res;
26
- try {
27
- res = await f(base + path, {
28
- method,
29
- headers: Object.assign(
30
- { Authorization: "Bearer " + token, Accept: "application/json", "X-ORYKSA-SDK": "react-native/" + VERSION },
31
- body !== undefined ? { "Content-Type": "application/json" } : {}
32
- ),
33
- body: body !== undefined ? JSON.stringify(body) : undefined,
34
- signal: ctrl ? ctrl.signal : undefined,
35
- });
36
- } catch (e) {
37
- throw new OryksaError(0, "network_error", "Could not reach ORYKSA: " + (e && e.message));
38
- } finally {
39
- if (timer) clearTimeout(timer);
40
- }
41
- let data = null;
42
- try { data = await res.json(); } catch (_) { data = null; }
43
- if (!res.ok && res.status !== 202) {
44
- const e = (data && data.error) || {};
45
- const extra = Object.assign({}, e);
46
- delete extra.code; delete extra.message;
47
- throw new OryksaError(res.status, e.code || "http_" + res.status, e.message || "Request failed with HTTP " + res.status, extra);
48
- }
49
- return data || {};
50
- }
51
-
52
- class OryksaClient {
53
- /**
54
- * @param {{token?: string, getToken?: () => Promise<string>, baseUrl?: string, fetch?: Function, timeoutMs?: number}} opts
55
- */
56
- constructor(opts) {
57
- const o = opts || {};
58
- if (!o.token && !o.getToken) throw new Error("OryksaClient needs { token } or { getToken }.");
59
- if (o.token && String(o.token).startsWith("oryk_live_")) throw new Error("Never use the secret API key in an app. Use a session token (oryk_cs_...).");
60
- this._token = o.token || null;
61
- this._getToken = o.getToken || null;
62
- this._base = String(o.baseUrl || DEFAULT_BASE).replace(/\/$/, "");
63
- this._fetch = o.fetch;
64
- this._timeout = o.timeoutMs || 60000;
65
- }
66
-
67
- async _tok(force) {
68
- if ((!this._token || force) && this._getToken) this._token = await this._getToken();
69
- if (!this._token) throw new OryksaError(401, "no_token", "No session token.");
70
- return this._token;
71
- }
72
-
73
- async _req(method, path, body) {
74
- try {
75
- return await request(this._base, await this._tok(false), method, path, body, this._fetch, this._timeout);
76
- } catch (e) {
77
- if (e instanceof OryksaError && (e.code === "session_expired" || e.status === 401) && this._getToken) {
78
- return request(this._base, await this._tok(true), method, path, body, this._fetch, this._timeout);
79
- }
80
- throw e;
81
- }
82
- }
83
-
84
- /** Name, photo, greeting and suggestions of the AI employee. */
85
- agent() { return this._req("GET", "/client/agent"); }
86
-
87
- /** Sends a message. status is "pending" when the AI needs a few more seconds: use sendAndWait. */
88
- send(message) { return this._req("POST", "/client/chat", { message }); }
89
-
90
- /** Messages of this conversation: { messages: [{ role, content }] }. */
91
- messages() { return this._req("GET", "/client/messages"); }
92
-
93
- /** Sends a message and waits for the reply text. */
94
- async sendAndWait(message, maxWaitMs) {
95
- const r = await this.send(message);
96
- if (!r || r.status !== "pending") return (r && r.reply) || null;
97
- const end = Date.now() + (maxWaitMs || 40000);
98
- while (Date.now() < end) {
99
- await new Promise((ok) => setTimeout(ok, 1500));
100
- const h = await this.messages();
101
- const last = ((h && h.messages) || []).slice(-1)[0];
102
- if (last && last.role === "assistant") return last.content;
103
- }
104
- return null;
105
- }
106
- }
107
-
108
- /** Picks the text for a language with fallbacks (br uses pt, then en). */
109
- function pick(map, lang) {
110
- if (!map || typeof map !== "object") return undefined;
111
- return map[lang] || (lang === "br" ? map.pt : undefined) || map.en || Object.values(map)[0];
112
- }
113
-
114
- module.exports = { OryksaClient, OryksaError, pick, VERSION, DEFAULT_BASE };
1
+ /*!
2
+ * @oryksa/react-native - in-app client. Uses a short-lived session token (oryk_cs_...)
3
+ * created by YOUR server with POST /v1/sessions. The secret API key never goes into the app.
4
+ * Docs: https://developer.oryksa.com License: MIT
5
+ */
6
+ "use strict";
7
+
8
+ const DEFAULT_BASE = "https://api.oryksa.com/v1";
9
+ const VERSION = "1.1.0";
10
+
11
+ class OryksaError extends Error {
12
+ constructor(status, code, message, extra) {
13
+ super(message);
14
+ this.name = "OryksaError";
15
+ this.status = status;
16
+ this.code = code;
17
+ Object.assign(this, extra || {});
18
+ }
19
+ }
20
+
21
+ async function request(base, token, method, path, body, fetchImpl, timeoutMs) {
22
+ const f = fetchImpl || globalThis.fetch;
23
+ const ctrl = typeof AbortController !== "undefined" ? new AbortController() : null;
24
+ const timer = ctrl ? setTimeout(() => ctrl.abort(), timeoutMs) : null;
25
+ let res;
26
+ try {
27
+ res = await f(base + path, {
28
+ method,
29
+ headers: Object.assign(
30
+ { Authorization: "Bearer " + token, Accept: "application/json", "X-ORYKSA-SDK": "react-native/" + VERSION },
31
+ body !== undefined ? { "Content-Type": "application/json" } : {}
32
+ ),
33
+ body: body !== undefined ? JSON.stringify(body) : undefined,
34
+ signal: ctrl ? ctrl.signal : undefined,
35
+ });
36
+ } catch (e) {
37
+ throw new OryksaError(0, "network_error", "Could not reach ORYKSA: " + (e && e.message));
38
+ } finally {
39
+ if (timer) clearTimeout(timer);
40
+ }
41
+ let data = null;
42
+ try { data = await res.json(); } catch (_) { data = null; }
43
+ if (!res.ok && res.status !== 202) {
44
+ const e = (data && data.error) || {};
45
+ const extra = Object.assign({}, e);
46
+ delete extra.code; delete extra.message;
47
+ throw new OryksaError(res.status, e.code || "http_" + res.status, e.message || "Request failed with HTTP " + res.status, extra);
48
+ }
49
+ return data || {};
50
+ }
51
+
52
+ /** One raw exchange (used for the voice: MP3 back, WAV up). Returns the Response. */
53
+ async function rawFetch(base, token, path, init, fetchImpl, timeoutMs) {
54
+ const f = fetchImpl || globalThis.fetch;
55
+ const ctrl = typeof AbortController !== "undefined" ? new AbortController() : null;
56
+ const timer = ctrl ? setTimeout(() => ctrl.abort(), timeoutMs) : null;
57
+ let res;
58
+ try {
59
+ res = await f(base + path, Object.assign({}, init, {
60
+ headers: Object.assign({ Authorization: "Bearer " + token, "X-ORYKSA-SDK": "react-native/" + VERSION }, init.headers || {}),
61
+ signal: ctrl ? ctrl.signal : undefined,
62
+ }));
63
+ } catch (e) {
64
+ throw new OryksaError(0, "network_error", "Could not reach ORYKSA: " + (e && e.message));
65
+ } finally {
66
+ if (timer) clearTimeout(timer);
67
+ }
68
+ if (!res.ok) {
69
+ let data = null;
70
+ try { data = await res.json(); } catch (_) { data = null; }
71
+ const e = (data && data.error) || {};
72
+ throw new OryksaError(res.status, e.code || "http_" + res.status, e.message || "Request failed with HTTP " + res.status);
73
+ }
74
+ return res;
75
+ }
76
+
77
+ function utf8(str) {
78
+ if (typeof TextEncoder !== "undefined") return new TextEncoder().encode(str);
79
+ const out = [];
80
+ for (let i = 0; i < str.length; i++) out.push(str.charCodeAt(i) & 0xff); // ASCII only (multipart headers)
81
+ return new Uint8Array(out);
82
+ }
83
+
84
+ /** multipart/form-data body with one file field `file` (built by hand: works in React Native and Node). */
85
+ function multipart(bytes, filename, type) {
86
+ const boundary = "oryksa-" + Date.now().toString(36) + Math.random().toString(36).slice(2);
87
+ const head = utf8("--" + boundary + '\r\nContent-Disposition: form-data; name="file"; filename="' + filename + '"\r\nContent-Type: ' + type + "\r\n\r\n");
88
+ const tail = utf8("\r\n--" + boundary + "--\r\n");
89
+ const body = new Uint8Array(head.length + bytes.length + tail.length);
90
+ body.set(head, 0);
91
+ body.set(bytes, head.length);
92
+ body.set(tail, head.length + bytes.length);
93
+ return { body, contentType: "multipart/form-data; boundary=" + boundary };
94
+ }
95
+
96
+ class OryksaClient {
97
+ /**
98
+ * @param {{token?: string, getToken?: () => Promise<string>, baseUrl?: string, fetch?: Function, timeoutMs?: number}} opts
99
+ */
100
+ constructor(opts) {
101
+ const o = opts || {};
102
+ if (!o.token && !o.getToken) throw new Error("OryksaClient needs { token } or { getToken }.");
103
+ if (o.token && String(o.token).startsWith("oryk_live_")) throw new Error("Never use the secret API key in an app. Use a session token (oryk_cs_...).");
104
+ this._token = o.token || null;
105
+ this._getToken = o.getToken || null;
106
+ this._base = String(o.baseUrl || DEFAULT_BASE).replace(/\/$/, "");
107
+ this._fetch = o.fetch;
108
+ this._timeout = o.timeoutMs || 60000;
109
+ }
110
+
111
+ async _tok(force) {
112
+ if ((!this._token || force) && this._getToken) this._token = await this._getToken();
113
+ if (!this._token) throw new OryksaError(401, "no_token", "No session token.");
114
+ return this._token;
115
+ }
116
+
117
+ async _req(method, path, body) {
118
+ try {
119
+ return await request(this._base, await this._tok(false), method, path, body, this._fetch, this._timeout);
120
+ } catch (e) {
121
+ if (e instanceof OryksaError && (e.code === "session_expired" || e.status === 401) && this._getToken) {
122
+ return request(this._base, await this._tok(true), method, path, body, this._fetch, this._timeout);
123
+ }
124
+ throw e;
125
+ }
126
+ }
127
+
128
+ /** Name, photo, greeting and suggestions of the AI employee. */
129
+ agent() { return this._req("GET", "/client/agent"); }
130
+
131
+ /**
132
+ * Sends a message. status is "pending" when the AI needs a few more seconds: use sendAndWait.
133
+ * @param {string} message
134
+ * @param {{appContext?: {screen?: string, title?: string, items?: string[]}, voice?: boolean, whisper?: boolean, voiceStats?: object}} [opts]
135
+ * appContext: the screen the customer is on inside your app, so the AI answers about it.
136
+ * voice: the reply will be heard (it also carries a short `speech`). whisper: the customer whispered.
137
+ */
138
+ send(message, opts) {
139
+ const o = opts || {};
140
+ const body = { message };
141
+ if (o.appContext) body.app_context = appContextJson(o.appContext);
142
+ if (o.voice) body.voice = true;
143
+ if (o.whisper) body.whisper = true;
144
+ if (o.voiceStats) { body.platform = "rn"; body.voice_stats = o.voiceStats; }
145
+ return this._req("POST", "/client/chat", body);
146
+ }
147
+
148
+ /** Like sendAndWait, but returns the whole reply object ({ status, reply, speech, whisper }). */
149
+ async sendAndWaitReply(message, opts) {
150
+ const o = opts || {};
151
+ const r = await this.send(message, o);
152
+ if (!r || r.status !== "pending") return r || {};
153
+ const end = Date.now() + (o.maxWaitMs || 40000);
154
+ while (Date.now() < end) {
155
+ await new Promise((ok) => setTimeout(ok, 1500));
156
+ const h = await this.messages();
157
+ const last = ((h && h.messages) || []).slice(-1)[0];
158
+ if (last && last.role === "assistant") return { status: "replied", reply: last.content, whisper: !!o.whisper };
159
+ }
160
+ return r;
161
+ }
162
+
163
+ async _raw(path, init) {
164
+ try {
165
+ return await rawFetch(this._base, await this._tok(false), path, init, this._fetch, this._timeout);
166
+ } catch (e) {
167
+ if (e instanceof OryksaError && (e.code === "session_expired" || e.status === 401) && this._getToken) {
168
+ return rawFetch(this._base, await this._tok(true), path, init, this._fetch, this._timeout);
169
+ }
170
+ throw e;
171
+ }
172
+ }
173
+
174
+ /**
175
+ * The AI's voice (ElevenLabs, the voice chosen in ORYKSA) for one reply of this conversation, as MP3
176
+ * bytes (Uint8Array). Resolves null when the voice is not available: then show the text only.
177
+ */
178
+ async tts(text, opts) {
179
+ try {
180
+ const body = { text };
181
+ if (opts && opts.whisper) body.whisper = true;
182
+ const res = await this._raw("/client/tts", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
183
+ const buf = new Uint8Array(await res.arrayBuffer());
184
+ return buf.length ? buf : null;
185
+ } catch (_) {
186
+ return null;
187
+ }
188
+ }
189
+
190
+ /** Customer voice to text. wav: Uint8Array, 16 kHz mono PCM16 WAV, up to 15 s. "" = nothing said, null = failed. */
191
+ async transcribe(wav) {
192
+ try {
193
+ const mp = multipart(wav, "voice.wav", "audio/wav");
194
+ const res = await this._raw("/client/transcribe", { method: "POST", headers: { "Content-Type": mp.contentType, Accept: "application/json" }, body: mp.body });
195
+ const d = await res.json();
196
+ return String((d && d.text) || "").trim();
197
+ } catch (_) {
198
+ return null;
199
+ }
200
+ }
201
+
202
+ /** Reports a voice turn that produced no message (nothing heard, a cut with nothing said). */
203
+ async voiceStats(stats) {
204
+ try { await this._req("POST", "/client/voice-stats", { platform: "rn", voice_stats: stats }); } catch (_) { /* telemetry only */ }
205
+ }
206
+
207
+ /** Messages of this conversation: { messages: [{ role, content }] }. */
208
+ messages() { return this._req("GET", "/client/messages"); }
209
+
210
+ /** Sends a message and waits for the reply text. opts: { appContext } (or a number = maxWaitMs, as in 1.0). */
211
+ async sendAndWait(message, opts) {
212
+ const o = typeof opts === "number" ? { maxWaitMs: opts } : (opts || {});
213
+ const r = await this.sendAndWaitReply(message, o);
214
+ return (r && r.reply) || null;
215
+ }
216
+ }
217
+
218
+ /** JSON of an app context: { screen, title, items (up to 20) }. */
219
+ function appContextJson(c) {
220
+ const o = {};
221
+ if (c.screen) o.screen = String(c.screen);
222
+ if (c.title) o.title = String(c.title);
223
+ if (Array.isArray(c.items) && c.items.length) o.items = c.items.slice(0, 20).map(String);
224
+ return o;
225
+ }
226
+
227
+ /** Picks the text for a language with fallbacks (br uses pt, then en). */
228
+ function pick(map, lang) {
229
+ if (!map || typeof map !== "object") return undefined;
230
+ return map[lang] || (lang === "br" ? map.pt : undefined) || map.en || Object.values(map)[0];
231
+ }
232
+
233
+ module.exports = { OryksaClient, OryksaError, pick, appContextJson, multipart, VERSION, DEFAULT_BASE };
package/src/index.d.ts CHANGED
@@ -1,53 +1,151 @@
1
- import * as React from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
3
-
4
- export declare const VERSION: string;
5
-
6
- export declare class OryksaError extends Error {
7
- status: number;
8
- code: string;
9
- [key: string]: unknown;
10
- }
11
-
12
- export interface OryksaAgent {
13
- name: string;
14
- avatar: string;
15
- business?: string | null;
16
- gender?: "female" | "male";
17
- greeting?: Record<string, string>;
18
- subtitle?: Record<string, string>;
19
- suggestions?: Record<string, string[]>;
20
- voice_replies?: boolean;
21
- conversation_id?: string;
22
- }
23
-
24
- export interface OryksaReply {
25
- object: "chat_reply";
26
- conversation_id: string;
27
- status: "replied" | "pending";
28
- reply: string | null;
29
- }
30
-
31
- export declare class OryksaClient {
32
- constructor(opts: { token?: string; getToken?: () => Promise<string>; baseUrl?: string; fetch?: typeof fetch; timeoutMs?: number });
33
- agent(): Promise<OryksaAgent>;
34
- send(message: string): Promise<OryksaReply>;
35
- sendAndWait(message: string, maxWaitMs?: number): Promise<string | null>;
36
- messages(): Promise<{ messages: { role: "user" | "assistant"; content: string }[] }>;
37
- }
38
-
39
- export type OryksaLang = "en" | "pt" | "br" | "es";
40
-
41
- export interface OryksaTheme {
42
- accent?: string;
43
- ink?: string;
44
- soft?: string;
45
- background?: string;
46
- muted?: string;
47
- }
48
-
49
- export declare const DEFAULT_THEME: Required<OryksaTheme>;
50
-
51
- export declare function OryksaChat(props: { client: OryksaClient; lang?: OryksaLang; theme?: OryksaTheme; onClose?: () => void }): React.ReactElement;
52
- export declare function OryksaChatModal(props: { client: OryksaClient; lang?: OryksaLang; theme?: OryksaTheme; visible: boolean; onClose: () => void }): React.ReactElement;
53
- export declare function OryksaChatButton(props: { client: OryksaClient; lang?: OryksaLang; theme?: OryksaTheme; position?: "left" | "right"; style?: StyleProp<ViewStyle> }): React.ReactElement;
1
+ import * as React from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+
4
+ export declare const VERSION: string;
5
+
6
+ export declare class OryksaError extends Error {
7
+ status: number;
8
+ code: string;
9
+ [key: string]: unknown;
10
+ }
11
+
12
+ export interface OryksaAgent {
13
+ name: string;
14
+ avatar: string;
15
+ business?: string | null;
16
+ gender?: "female" | "male";
17
+ greeting?: Record<string, string>;
18
+ subtitle?: Record<string, string>;
19
+ suggestions?: Record<string, string[]>;
20
+ voice_replies?: boolean;
21
+ conversation_id?: string;
22
+ /** The AI photo from "Your AI" in ORYKSA (never the owner's photo). Same as avatar. */
23
+ photo?: string;
24
+ /** ElevenLabs voice chosen for the AI in ORYKSA. */
25
+ voice?: string | null;
26
+ /** Main language of the AI, from ORYKSA. */
27
+ language?: string | null;
28
+ }
29
+
30
+ /** Where the customer is inside your app (sent with each message so the AI answers about it). */
31
+ export interface OryksaAppContext {
32
+ screen?: string;
33
+ title?: string;
34
+ /** What is listed on the screen. Up to 20. */
35
+ items?: string[];
36
+ }
37
+
38
+ export interface OryksaSendOptions {
39
+ appContext?: OryksaAppContext;
40
+ /** The reply will be heard: it also carries a short `speech`. */
41
+ voice?: boolean;
42
+ /** The customer whispered: shorter, whispered answer. */
43
+ whisper?: boolean;
44
+ voiceStats?: Record<string, unknown>;
45
+ maxWaitMs?: number;
46
+ }
47
+
48
+ export interface OryksaReply {
49
+ object: "chat_reply";
50
+ conversation_id: string;
51
+ status: "replied" | "pending";
52
+ reply: string | null;
53
+ /** With voice: the short spoken version of reply (1-2 sentences, no markdown). */
54
+ speech?: string;
55
+ whisper?: boolean;
56
+ }
57
+
58
+ export declare class OryksaClient {
59
+ constructor(opts: { token?: string; getToken?: () => Promise<string>; baseUrl?: string; fetch?: typeof fetch; timeoutMs?: number });
60
+ agent(): Promise<OryksaAgent>;
61
+ send(message: string, opts?: OryksaSendOptions): Promise<OryksaReply>;
62
+ sendAndWait(message: string, opts?: OryksaSendOptions | number): Promise<string | null>;
63
+ sendAndWaitReply(message: string, opts?: OryksaSendOptions): Promise<OryksaReply>;
64
+ messages(): Promise<{ messages: { role: "user" | "assistant"; content: string }[] }>;
65
+ /** The AI's voice (MP3 bytes) for one reply of this conversation; null when not available (show the text only). */
66
+ tts(text: string, opts?: { whisper?: boolean }): Promise<Uint8Array | null>;
67
+ /** 16 kHz mono PCM16 WAV to text. "" = nothing said, null = failed. */
68
+ transcribe(wav: Uint8Array): Promise<string | null>;
69
+ voiceStats(stats: Record<string, unknown>): Promise<void>;
70
+ }
71
+
72
+ /** Audio adapter used by the voice conversation (bring your own for Expo or another audio stack). */
73
+ export interface OryksaAudio {
74
+ /** onChunk receives PCM16 little-endian mono 16 kHz. Resolves false when the mic is not available. */
75
+ startMic(onChunk: (pcm: Uint8Array) => void): Promise<boolean>;
76
+ stopMic(): Promise<void>;
77
+ /** Plays MP3 bytes; resolves when it finished or was stopped. */
78
+ play(mp3: Uint8Array): Promise<void>;
79
+ stopPlayback(): Promise<void>;
80
+ }
81
+
82
+ /** The default adapter: react-native-live-audio-stream + react-native-sound + react-native-fs (null if not installed). */
83
+ export declare function createDefaultAudio(): OryksaAudio | null;
84
+
85
+ export type OryksaVoicePhase = "starting" | "listening" | "hearing" | "thinking" | "speaking" | "muted" | "micError" | "noisy" | "notUnderstood";
86
+
87
+ /** The ORYKSA voice conversation: the same behaviour as the ORYKSA app (only a human voice cuts her off). */
88
+ export declare class OryksaVoiceController {
89
+ constructor(opts: {
90
+ client: OryksaClient;
91
+ audio?: OryksaAudio | null;
92
+ appContext?: () => OryksaAppContext | undefined;
93
+ onUserText?: (text: string) => void;
94
+ onReply?: (text: string) => void;
95
+ onPhase?: (phase: OryksaVoicePhase, controller: OryksaVoiceController) => void;
96
+ });
97
+ phase: OryksaVoicePhase;
98
+ lastReply: string;
99
+ lastHeard: string;
100
+ start(): Promise<void>;
101
+ sendNow(): void;
102
+ say(text: string): Promise<void>;
103
+ toggleMute(): Promise<void>;
104
+ close(): Promise<void>;
105
+ }
106
+
107
+ /** The ORYKSA voice engine (line by line port of the ORYKSA app engine). */
108
+ export declare class Vad {
109
+ constructor(sampleRate?: number);
110
+ static bargeFloor: number;
111
+ static tetoOuvir: number;
112
+ static bargeVozMin: number;
113
+ static quietToCloseMs: number;
114
+ static maxSpeechMs: number;
115
+ static periodicidade(chunk: Uint8Array): number;
116
+ static rmsOf(chunk: Uint8Array): number;
117
+ readonly foiSussurro: boolean;
118
+ capturing: boolean;
119
+ reset(): void;
120
+ newTurn(): void;
121
+ feed(chunk: Uint8Array, speaking?: boolean): { isCapturing: boolean; isDone: boolean; isBargeIn: boolean; spokeMs: number; enough: boolean; isNoise: boolean; level: number };
122
+ }
123
+
124
+ export type OryksaLang = "en" | "pt" | "br" | "es";
125
+
126
+ export interface OryksaTheme {
127
+ accent?: string;
128
+ ink?: string;
129
+ soft?: string;
130
+ background?: string;
131
+ muted?: string;
132
+ }
133
+
134
+ export declare const DEFAULT_THEME: Required<OryksaTheme>;
135
+
136
+ interface OryksaChatVoiceProps {
137
+ /** Where the customer is in your app right now (sent with each message). */
138
+ appContext?: () => OryksaAppContext | undefined;
139
+ /** Shows the microphone when the plan has voice (default true). */
140
+ voice?: boolean;
141
+ /** Audio adapter (default: createDefaultAudio()). */
142
+ audio?: OryksaAudio | null;
143
+ }
144
+
145
+ export declare function OryksaChat(props: { client: OryksaClient; lang?: OryksaLang; theme?: OryksaTheme; onClose?: () => void } & OryksaChatVoiceProps): React.ReactElement;
146
+ export declare function OryksaChatModal(props: { client: OryksaClient; lang?: OryksaLang; theme?: OryksaTheme; visible: boolean; onClose: () => void } & OryksaChatVoiceProps): React.ReactElement;
147
+ export declare function OryksaChatButton(props: { client: OryksaClient; lang?: OryksaLang; theme?: OryksaTheme; position?: "left" | "right"; style?: StyleProp<ViewStyle> } & OryksaChatVoiceProps): React.ReactElement;
148
+ export declare function OryksaVoiceScreen(props: {
149
+ client: OryksaClient; agent: OryksaAgent; visible: boolean; onClose: () => void; lang?: OryksaLang; theme?: OryksaTheme;
150
+ appContext?: () => OryksaAppContext | undefined; onUserText?: (text: string) => void; onReply?: (text: string) => void; audio?: OryksaAudio | null;
151
+ }): React.ReactElement;
package/src/index.js CHANGED
@@ -1,18 +1,28 @@
1
- /*!
2
- * @oryksa/react-native - Official React Native SDK for ORYKSA AI Employees.
3
- * Docs: https://developer.oryksa.com License: MIT
4
- */
5
- "use strict";
6
-
7
- const client = require("./client");
8
- const chat = require("./chat");
9
-
10
- module.exports = {
11
- OryksaClient: client.OryksaClient,
12
- OryksaError: client.OryksaError,
13
- VERSION: client.VERSION,
14
- OryksaChat: chat.OryksaChat,
15
- OryksaChatModal: chat.OryksaChatModal,
16
- OryksaChatButton: chat.OryksaChatButton,
17
- DEFAULT_THEME: chat.DEFAULT_THEME,
18
- };
1
+ /*!
2
+ * @oryksa/react-native - Official React Native SDK for ORYKSA AI Employees.
3
+ * Docs: https://developer.oryksa.com License: MIT
4
+ */
5
+ "use strict";
6
+
7
+ const client = require("./client");
8
+ const chat = require("./chat");
9
+ const voice = require("./voice");
10
+ const voiceScreen = require("./voice-screen");
11
+ const vad = require("./vad");
12
+ const profanity = require("./profanity");
13
+
14
+ module.exports = {
15
+ OryksaClient: client.OryksaClient,
16
+ OryksaError: client.OryksaError,
17
+ VERSION: client.VERSION,
18
+ OryksaChat: chat.OryksaChat,
19
+ OryksaChatModal: chat.OryksaChatModal,
20
+ OryksaChatButton: chat.OryksaChatButton,
21
+ DEFAULT_THEME: chat.DEFAULT_THEME,
22
+ OryksaVoiceController: voice.OryksaVoiceController,
23
+ OryksaVoiceScreen: voiceScreen.OryksaVoiceScreen,
24
+ createDefaultAudio: voice.createDefaultAudio,
25
+ Vad: vad.Vad,
26
+ maskProfanity: profanity.mask,
27
+ loadProfanity: profanity.load,
28
+ };