@orello/react 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # <img src="https://www.orello.space/_next/image?url=%2Ficons%2Forello.png&w=48&q=75" width="32" height="32" valign="middle" /> @orello/react
2
+
3
+ React wrapper for embedding the **[Orello AI](https://orello.space)** widget. Supports real-time voice transcription, synthesis, and autonomous site navigation.
4
+
5
+ > [!IMPORTANT]
6
+ > **Orello AI** requires an active API key to connect to the assistant service. Sign up or log in at **[orello.space](https://orello.space)** to create your keys!
7
+
8
+ ### 🔑 Step-by-Step API Key Setup
9
+ 1. **Visit the Dashboard:** Go to **[orello.space](https://orello.space)** and log in.
10
+ 2. **Generate Key:** Navigate to **Developer Settings** > **API Keys** and click **Generate New Key**.
11
+ 3. **Save & Embed:** Copy the key and pass it as the `widgetKey` prop to the `<OrelloWidget>` component.
12
+
13
+ ## ✨ Features
14
+
15
+ - **Voice-First**: Deepgram & ElevenLabs integration with browser fallbacks.
16
+ - **Multimodal**: Visual page capture for AI awareness.
17
+ - **Type-Safe**: Full TypeScript support.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install @orello/react
23
+ ```
24
+
25
+ ## Basic Usage
26
+
27
+ ```tsx
28
+ import { OrelloWidget } from "@orello/react";
29
+
30
+ function App() {
31
+ return (
32
+ <>
33
+ <YourApp />
34
+ <OrelloWidget widgetKey="YOUR_WIDGET_KEY" />
35
+ </>
36
+ );
37
+ }
38
+
39
+ export default App;
40
+ ```
41
+
42
+ ## Recommended Usage (Explicit Assistant)
43
+
44
+ ```tsx
45
+ <OrelloWidget
46
+ widgetKey="YOUR_WIDGET_KEY"
47
+ assistantId="ASSISTANT_UID"
48
+ />
49
+ ```
50
+
51
+ ## Props
52
+
53
+ - `widgetKey` (required): Widget API key sent as `X-Api-Key`.
54
+ - `assistantId` (optional): Assistant UID for `/api/v1/assistants/public/{agentId}`.
55
+ - `scriptSrc` (optional): Embed script URL. Default: `https://cdn.orello.ai/orello.js`.
56
+ - `apiBase` (optional): API base URL.
57
+ - `agentEndpoint` (optional): Assistant endpoint template with `{agentId}`.
58
+ - `widgetUrl` (optional): Widget iframe URL.
59
+ - `wakeWord` (optional): Enables wake-word listener. Default: `true`.
60
+ - `onReady` (optional): Called when `orello:ready` is emitted.
61
+ - `onError` (optional): Called when `orello:error` is emitted.
62
+ - `cleanupOnUnmount` (optional): Removes script + widget on unmount. Default: `false`.
63
+
64
+ ## Runtime API
65
+
66
+ After init, runtime is exposed at `window.OrelloWidget`.
67
+
68
+ ```ts
69
+ window.OrelloWidget?.open();
70
+ window.OrelloWidget?.close();
71
+ window.OrelloWidget?.toggle();
72
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ OrelloWidget: () => OrelloWidget
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/OrelloWidget.tsx
28
+ var import_react = require("react");
29
+ var DEFAULT_SCRIPT_SRC = "https://cdn.orello.ai/orello.js";
30
+ function setOptionalAttribute(el, name, value) {
31
+ if (!value) return;
32
+ el.setAttribute(name, value);
33
+ }
34
+ function getExistingScript(scriptSrc) {
35
+ var _a;
36
+ const scripts = Array.from(document.querySelectorAll("script[src]"));
37
+ return (_a = scripts.find(
38
+ (item) => item.getAttribute("data-orello-react") === "true" && item.getAttribute("src") === scriptSrc
39
+ )) != null ? _a : null;
40
+ }
41
+ function OrelloWidget({
42
+ widgetKey,
43
+ assistantId,
44
+ scriptSrc = DEFAULT_SCRIPT_SRC,
45
+ apiBase,
46
+ agentEndpoint,
47
+ widgetUrl,
48
+ wakeWord = true,
49
+ onReady,
50
+ onError,
51
+ cleanupOnUnmount = false
52
+ }) {
53
+ (0, import_react.useEffect)(() => {
54
+ if (typeof window === "undefined" || typeof document === "undefined") {
55
+ return;
56
+ }
57
+ if (!widgetKey || !widgetKey.trim()) {
58
+ console.error("[Orello React] Missing required prop: widgetKey");
59
+ return;
60
+ }
61
+ const handleReady = (event) => {
62
+ onReady == null ? void 0 : onReady(event);
63
+ };
64
+ const handleError = (event) => {
65
+ onError == null ? void 0 : onError(event);
66
+ };
67
+ window.addEventListener("orello:ready", handleReady);
68
+ window.addEventListener("orello:error", handleError);
69
+ const resolvedScriptSrc = scriptSrc.trim() || DEFAULT_SCRIPT_SRC;
70
+ const existingScript = getExistingScript(resolvedScriptSrc);
71
+ if (!existingScript) {
72
+ const script = document.createElement("script");
73
+ script.src = resolvedScriptSrc;
74
+ script.async = true;
75
+ script.setAttribute("data-orello-react", "true");
76
+ script.setAttribute("data-api-key", widgetKey);
77
+ script.setAttribute("data-key", widgetKey);
78
+ script.setAttribute("data-wake-word", wakeWord ? "true" : "false");
79
+ setOptionalAttribute(script, "data-agent-id", assistantId);
80
+ setOptionalAttribute(script, "data-api-base", apiBase);
81
+ setOptionalAttribute(script, "data-agent-endpoint", agentEndpoint);
82
+ setOptionalAttribute(script, "data-widget-url", widgetUrl);
83
+ document.head.appendChild(script);
84
+ return () => {
85
+ window.removeEventListener("orello:ready", handleReady);
86
+ window.removeEventListener("orello:error", handleError);
87
+ if (cleanupOnUnmount) {
88
+ const root = document.getElementById("orello-widget-root");
89
+ if (root) root.remove();
90
+ script.remove();
91
+ delete window.OrelloWidget;
92
+ }
93
+ };
94
+ }
95
+ existingScript.setAttribute("data-api-key", widgetKey);
96
+ existingScript.setAttribute("data-key", widgetKey);
97
+ existingScript.setAttribute("data-wake-word", wakeWord ? "true" : "false");
98
+ if (assistantId) {
99
+ existingScript.setAttribute("data-agent-id", assistantId);
100
+ }
101
+ if (apiBase) {
102
+ existingScript.setAttribute("data-api-base", apiBase);
103
+ }
104
+ if (agentEndpoint) {
105
+ existingScript.setAttribute("data-agent-endpoint", agentEndpoint);
106
+ }
107
+ if (widgetUrl) {
108
+ existingScript.setAttribute("data-widget-url", widgetUrl);
109
+ }
110
+ return () => {
111
+ window.removeEventListener("orello:ready", handleReady);
112
+ window.removeEventListener("orello:error", handleError);
113
+ if (cleanupOnUnmount) {
114
+ const root = document.getElementById("orello-widget-root");
115
+ if (root) root.remove();
116
+ existingScript.remove();
117
+ delete window.OrelloWidget;
118
+ }
119
+ };
120
+ }, [
121
+ widgetKey,
122
+ assistantId,
123
+ scriptSrc,
124
+ apiBase,
125
+ agentEndpoint,
126
+ widgetUrl,
127
+ wakeWord,
128
+ onReady,
129
+ onError,
130
+ cleanupOnUnmount
131
+ ]);
132
+ return null;
133
+ }
134
+ // Annotate the CommonJS export names for ESM import in node:
135
+ 0 && (module.exports = {
136
+ OrelloWidget
137
+ });
@@ -0,0 +1,70 @@
1
+ type OrelloAgent = {
2
+ uid?: string;
3
+ name?: string;
4
+ description?: string;
5
+ firstMessage?: string;
6
+ voiceId?: string;
7
+ status?: string;
8
+ metadata?: Record<string, unknown>;
9
+ };
10
+ type OrelloWidgetConfig = {
11
+ agentId?: string;
12
+ apiBase?: string;
13
+ widgetUrl?: string;
14
+ };
15
+ type OrelloPointer = {
16
+ x: number;
17
+ y: number;
18
+ };
19
+ type OrelloWidgetActions = {
20
+ click: (selectorOrElement: string | Element) => boolean;
21
+ buttonClick: (selectorOrElement: string | Element) => boolean;
22
+ doubleClick: (selectorOrElement: string | Element) => boolean;
23
+ clickHold: (selectorOrElement: string | Element, durationMs?: number) => boolean;
24
+ scroll: (deltaX: number, deltaY: number, behavior?: ScrollBehavior) => void;
25
+ scrollBy: (deltaX: number, deltaY: number, behavior?: ScrollBehavior) => void;
26
+ touchScroll: (deltaY: number) => void;
27
+ mouseMove: (x: number, y: number) => OrelloPointer;
28
+ zoomIn: (step?: number) => number;
29
+ zoomOut: (step?: number) => number;
30
+ highlight: (selectorOrElement: string | Element, durationMs?: number) => boolean;
31
+ getPointer: () => OrelloPointer;
32
+ getZoom: () => number;
33
+ };
34
+ type OrelloRuntimeApi = {
35
+ version: string;
36
+ config: OrelloWidgetConfig;
37
+ agent?: OrelloAgent;
38
+ open: () => void;
39
+ close: () => void;
40
+ toggle: () => void;
41
+ actions: OrelloWidgetActions;
42
+ getDom: (path?: string) => unknown;
43
+ };
44
+ type OrelloReadyEvent = CustomEvent<{
45
+ agent?: OrelloAgent;
46
+ }>;
47
+ type OrelloErrorEvent = CustomEvent<{
48
+ message?: string;
49
+ }>;
50
+ declare global {
51
+ interface Window {
52
+ OrelloWidget?: OrelloRuntimeApi;
53
+ }
54
+ }
55
+
56
+ type OrelloWidgetProps = {
57
+ widgetKey: string;
58
+ assistantId?: string;
59
+ scriptSrc?: string;
60
+ apiBase?: string;
61
+ agentEndpoint?: string;
62
+ widgetUrl?: string;
63
+ wakeWord?: boolean;
64
+ onReady?: (event: OrelloReadyEvent) => void;
65
+ onError?: (event: OrelloErrorEvent) => void;
66
+ cleanupOnUnmount?: boolean;
67
+ };
68
+ declare function OrelloWidget({ widgetKey, assistantId, scriptSrc, apiBase, agentEndpoint, widgetUrl, wakeWord, onReady, onError, cleanupOnUnmount, }: OrelloWidgetProps): null;
69
+
70
+ export { type OrelloAgent, type OrelloErrorEvent, type OrelloReadyEvent, type OrelloRuntimeApi, OrelloWidget, type OrelloWidgetActions, type OrelloWidgetConfig, type OrelloWidgetProps };
@@ -0,0 +1,70 @@
1
+ type OrelloAgent = {
2
+ uid?: string;
3
+ name?: string;
4
+ description?: string;
5
+ firstMessage?: string;
6
+ voiceId?: string;
7
+ status?: string;
8
+ metadata?: Record<string, unknown>;
9
+ };
10
+ type OrelloWidgetConfig = {
11
+ agentId?: string;
12
+ apiBase?: string;
13
+ widgetUrl?: string;
14
+ };
15
+ type OrelloPointer = {
16
+ x: number;
17
+ y: number;
18
+ };
19
+ type OrelloWidgetActions = {
20
+ click: (selectorOrElement: string | Element) => boolean;
21
+ buttonClick: (selectorOrElement: string | Element) => boolean;
22
+ doubleClick: (selectorOrElement: string | Element) => boolean;
23
+ clickHold: (selectorOrElement: string | Element, durationMs?: number) => boolean;
24
+ scroll: (deltaX: number, deltaY: number, behavior?: ScrollBehavior) => void;
25
+ scrollBy: (deltaX: number, deltaY: number, behavior?: ScrollBehavior) => void;
26
+ touchScroll: (deltaY: number) => void;
27
+ mouseMove: (x: number, y: number) => OrelloPointer;
28
+ zoomIn: (step?: number) => number;
29
+ zoomOut: (step?: number) => number;
30
+ highlight: (selectorOrElement: string | Element, durationMs?: number) => boolean;
31
+ getPointer: () => OrelloPointer;
32
+ getZoom: () => number;
33
+ };
34
+ type OrelloRuntimeApi = {
35
+ version: string;
36
+ config: OrelloWidgetConfig;
37
+ agent?: OrelloAgent;
38
+ open: () => void;
39
+ close: () => void;
40
+ toggle: () => void;
41
+ actions: OrelloWidgetActions;
42
+ getDom: (path?: string) => unknown;
43
+ };
44
+ type OrelloReadyEvent = CustomEvent<{
45
+ agent?: OrelloAgent;
46
+ }>;
47
+ type OrelloErrorEvent = CustomEvent<{
48
+ message?: string;
49
+ }>;
50
+ declare global {
51
+ interface Window {
52
+ OrelloWidget?: OrelloRuntimeApi;
53
+ }
54
+ }
55
+
56
+ type OrelloWidgetProps = {
57
+ widgetKey: string;
58
+ assistantId?: string;
59
+ scriptSrc?: string;
60
+ apiBase?: string;
61
+ agentEndpoint?: string;
62
+ widgetUrl?: string;
63
+ wakeWord?: boolean;
64
+ onReady?: (event: OrelloReadyEvent) => void;
65
+ onError?: (event: OrelloErrorEvent) => void;
66
+ cleanupOnUnmount?: boolean;
67
+ };
68
+ declare function OrelloWidget({ widgetKey, assistantId, scriptSrc, apiBase, agentEndpoint, widgetUrl, wakeWord, onReady, onError, cleanupOnUnmount, }: OrelloWidgetProps): null;
69
+
70
+ export { type OrelloAgent, type OrelloErrorEvent, type OrelloReadyEvent, type OrelloRuntimeApi, OrelloWidget, type OrelloWidgetActions, type OrelloWidgetConfig, type OrelloWidgetProps };
package/dist/index.js ADDED
@@ -0,0 +1,110 @@
1
+ // src/OrelloWidget.tsx
2
+ import { useEffect } from "react";
3
+ var DEFAULT_SCRIPT_SRC = "https://cdn.orello.ai/orello.js";
4
+ function setOptionalAttribute(el, name, value) {
5
+ if (!value) return;
6
+ el.setAttribute(name, value);
7
+ }
8
+ function getExistingScript(scriptSrc) {
9
+ var _a;
10
+ const scripts = Array.from(document.querySelectorAll("script[src]"));
11
+ return (_a = scripts.find(
12
+ (item) => item.getAttribute("data-orello-react") === "true" && item.getAttribute("src") === scriptSrc
13
+ )) != null ? _a : null;
14
+ }
15
+ function OrelloWidget({
16
+ widgetKey,
17
+ assistantId,
18
+ scriptSrc = DEFAULT_SCRIPT_SRC,
19
+ apiBase,
20
+ agentEndpoint,
21
+ widgetUrl,
22
+ wakeWord = true,
23
+ onReady,
24
+ onError,
25
+ cleanupOnUnmount = false
26
+ }) {
27
+ useEffect(() => {
28
+ if (typeof window === "undefined" || typeof document === "undefined") {
29
+ return;
30
+ }
31
+ if (!widgetKey || !widgetKey.trim()) {
32
+ console.error("[Orello React] Missing required prop: widgetKey");
33
+ return;
34
+ }
35
+ const handleReady = (event) => {
36
+ onReady == null ? void 0 : onReady(event);
37
+ };
38
+ const handleError = (event) => {
39
+ onError == null ? void 0 : onError(event);
40
+ };
41
+ window.addEventListener("orello:ready", handleReady);
42
+ window.addEventListener("orello:error", handleError);
43
+ const resolvedScriptSrc = scriptSrc.trim() || DEFAULT_SCRIPT_SRC;
44
+ const existingScript = getExistingScript(resolvedScriptSrc);
45
+ if (!existingScript) {
46
+ const script = document.createElement("script");
47
+ script.src = resolvedScriptSrc;
48
+ script.async = true;
49
+ script.setAttribute("data-orello-react", "true");
50
+ script.setAttribute("data-api-key", widgetKey);
51
+ script.setAttribute("data-key", widgetKey);
52
+ script.setAttribute("data-wake-word", wakeWord ? "true" : "false");
53
+ setOptionalAttribute(script, "data-agent-id", assistantId);
54
+ setOptionalAttribute(script, "data-api-base", apiBase);
55
+ setOptionalAttribute(script, "data-agent-endpoint", agentEndpoint);
56
+ setOptionalAttribute(script, "data-widget-url", widgetUrl);
57
+ document.head.appendChild(script);
58
+ return () => {
59
+ window.removeEventListener("orello:ready", handleReady);
60
+ window.removeEventListener("orello:error", handleError);
61
+ if (cleanupOnUnmount) {
62
+ const root = document.getElementById("orello-widget-root");
63
+ if (root) root.remove();
64
+ script.remove();
65
+ delete window.OrelloWidget;
66
+ }
67
+ };
68
+ }
69
+ existingScript.setAttribute("data-api-key", widgetKey);
70
+ existingScript.setAttribute("data-key", widgetKey);
71
+ existingScript.setAttribute("data-wake-word", wakeWord ? "true" : "false");
72
+ if (assistantId) {
73
+ existingScript.setAttribute("data-agent-id", assistantId);
74
+ }
75
+ if (apiBase) {
76
+ existingScript.setAttribute("data-api-base", apiBase);
77
+ }
78
+ if (agentEndpoint) {
79
+ existingScript.setAttribute("data-agent-endpoint", agentEndpoint);
80
+ }
81
+ if (widgetUrl) {
82
+ existingScript.setAttribute("data-widget-url", widgetUrl);
83
+ }
84
+ return () => {
85
+ window.removeEventListener("orello:ready", handleReady);
86
+ window.removeEventListener("orello:error", handleError);
87
+ if (cleanupOnUnmount) {
88
+ const root = document.getElementById("orello-widget-root");
89
+ if (root) root.remove();
90
+ existingScript.remove();
91
+ delete window.OrelloWidget;
92
+ }
93
+ };
94
+ }, [
95
+ widgetKey,
96
+ assistantId,
97
+ scriptSrc,
98
+ apiBase,
99
+ agentEndpoint,
100
+ widgetUrl,
101
+ wakeWord,
102
+ onReady,
103
+ onError,
104
+ cleanupOnUnmount
105
+ ]);
106
+ return null;
107
+ }
108
+ export {
109
+ OrelloWidget
110
+ };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@orello/react",
3
+ "version": "0.1.3",
4
+ "description": "React wrapper for the Orello AI widget — embed intelligent conversational assistants into any React application.",
5
+ "author": "Orello Team <hello@orello.space>",
6
+ "license": "MIT",
7
+ "private": false,
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/orello.space/orello.git",
14
+ "directory": "libs/react"
15
+ },
16
+ "keywords": [
17
+ "ai",
18
+ "react",
19
+ "chat-widget",
20
+ "conversational-ai",
21
+ "customer-support",
22
+ "agent",
23
+ "orello"
24
+ ],
25
+ "bugs": {
26
+ "url": "https://github.com/orello.space/orello/issues"
27
+ },
28
+ "homepage": "https://orello.space",
29
+ "type": "module",
30
+ "main": "./dist/index.cjs",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js",
37
+ "require": "./dist/index.cjs"
38
+ }
39
+ },
40
+ "engines": {
41
+ "node": ">=20.0.0"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "README.md"
46
+ ],
47
+ "scripts": {
48
+ "build": "tsup src/index.ts --format esm,cjs --dts --minify",
49
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
50
+ "clean": "rm -rf dist",
51
+ "deploy": "npm run build && npm publish"
52
+ },
53
+ "peerDependencies": {
54
+ "react": ">=18.0.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/react": "^18.3.12",
58
+ "tsup": "^8.3.5",
59
+ "typescript": "^5.6.3"
60
+ }
61
+ }