obi-sdk 0.1.1

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/LICENSE.txt ADDED
@@ -0,0 +1,35 @@
1
+ **Obi SDK License Agreement**
2
+
3
+ **Effective Date:** 28th April 2025
4
+ **Last Updated:** 28th April 2025
5
+
6
+ ### 1. Grant of License
7
+ Subject to the terms of this Agreement and payment of applicable fees, **Cor** grants you a non-exclusive, non-transferable, non-sublicensable license to use the **Obi SDK** (the "SDK") solely to integrate voice assistant functionality into your applications.
8
+
9
+ ### 2. Restrictions
10
+ You may **not**:
11
+ - Use the SDK without a valid paid license or subscription.
12
+ - Copy, modify, reverse-engineer, or create derivative works of the SDK.
13
+ - Distribute, sublicense, or make the SDK available to third parties.
14
+ - Remove or alter any proprietary notices.
15
+
16
+ ### 3. Ownership
17
+ The SDK is licensed, not sold. **Cor** retains all rights, title, and interest in and to the SDK, including all intellectual property rights.
18
+
19
+ ### 4. Fees and Activation
20
+ Use of the SDK requires a valid license key issued by **Cor**. Access to features or voice processing may be metered, and continued usage is subject to payment of applicable fees as described on our pricing page: [www.iamobi.ai](https://www.iamobi.ai).
21
+
22
+ ### 5. Updates & Support
23
+ **Cor** may provide updates or patches at its discretion. Support is only provided to licensed users with active subscriptions.
24
+
25
+ ### 6. Termination
26
+ This Agreement is effective until terminated. It will terminate automatically without notice if you fail to comply with any terms. Upon termination, you must destroy all copies of the SDK.
27
+
28
+ ### 7. Disclaimer of Warranties
29
+ The SDK is provided "as is" without warranties of any kind. You assume all risks related to use.
30
+
31
+ ### 8. Limitation of Liability
32
+ In no event will **Cor** be liable for indirect, incidental, or consequential damages arising from use of the SDK.
33
+
34
+ ### 9. Governing Law
35
+ This Agreement shall be governed by the laws of Australia.
package/README.md ADDED
@@ -0,0 +1,274 @@
1
+ # Obi SDK
2
+
3
+ A JavaScript SDK with dynamic content capabilities for integrating Obi into your web applications.
4
+
5
+ ## Features
6
+
7
+ - ASssistant interacts through voice and screen share
8
+ - DOM analysis allows the assistant to improve context
9
+ - Framework-agnostic UI components using Web Components
10
+ - Event-based API
11
+ - TypeScript support
12
+
13
+ ## Installation
14
+
15
+ Currently, the recommended way to use Obi SDK is through the inline loader script approach.
16
+
17
+ ## Configuration Options
18
+
19
+ The loader accepts the following configuration options:
20
+
21
+ | Option | Type | Default | Description |
22
+ | ------------ | ------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------- |
23
+ | `position` | string | `'bottom-right'` | Position of the widget on the page. Options: `'bottom-right'`, `'bottom-left'`, `'top-right'`, `'top-left'` |
24
+ | `apiKey` | string | - | Your Obi API key (required for production) |
25
+ | `sdkVersion` | string | `'latest'` | Version of the SDK to load |
26
+ | `noCacheSDK` | boolean | `false` | Force fresh load of SDK without caching |
27
+ | `apiBaseUrl` | string | `'https://www.iamobi.ai/api/'` | Base URL for API calls |
28
+
29
+ ## Quick Start
30
+
31
+ The simplest way to add Obi to your website is by using the inline loader script:
32
+
33
+ 1. Copy the full inline loader script from above
34
+ 2. Add it to your HTML page
35
+ 3. Configure the widget using `window.obiWidgetConfig`
36
+
37
+ ```html
38
+ <!DOCTYPE html>
39
+ <html>
40
+ <head>
41
+ <title>My Website with Obi</title>
42
+ <script>
43
+ // Configure Obi
44
+ window.obiWidgetConfig = {
45
+ position: "bottom-right",
46
+ apiKey: "YOUR_API_KEY",
47
+ apiBaseUrl: "https://www.iamobi.ai/api/",
48
+ }
49
+ </script>
50
+ </head>
51
+ <body>
52
+ <!-- Your website content -->
53
+
54
+ <!-- Add Obi widget loader script at the end of body -->
55
+ <script>
56
+ ;(function (w, d) {
57
+ "use strict"
58
+ var c = {
59
+ position: "bottom-right",
60
+ apiBaseUrl: "https://www.iamobi.ai/api/",
61
+ sdkVersion: "latest",
62
+ noCacheSDK: !1,
63
+ }
64
+ w.__obiSDKLoading = w.__obiSDKLoading || !1
65
+ function i() {
66
+ var f = w.obiWidgetConfig || {}
67
+ for (var k in c) !(k in f) && (f[k] = c[k])
68
+ if (typeof w.ObiSDK === "function" || typeof w.ObiSDK === "object") g(f)
69
+ else {
70
+ if (w.__obiSDKLoading) {
71
+ e(function () {
72
+ g(f)
73
+ })
74
+ return
75
+ }
76
+ if (f.sdkVersion === "latest" && !f.noCacheSDK) {
77
+ m(function (v) {
78
+ v && (f.sdkVersion = v)
79
+ j(f, function () {
80
+ w.__obiSDKLoading = !1
81
+ g(f)
82
+ })
83
+ })
84
+ } else {
85
+ j(f, function () {
86
+ w.__obiSDKLoading = !1
87
+ g(f)
88
+ })
89
+ }
90
+ }
91
+ }
92
+ function e(f) {
93
+ var t = w.setInterval(function () {
94
+ if (typeof w.ObiSDK === "function" || typeof w.ObiSDK === "object") {
95
+ w.clearInterval(t)
96
+ f()
97
+ }
98
+ }, 100)
99
+ }
100
+ function m(cb) {
101
+ try {
102
+ var x = new (w.XMLHttpRequest || w.ActiveXObject)("Microsoft.XMLHTTP")
103
+ x.open("GET", "https://registry.npmjs.org/obi-sdk/latest")
104
+ x.onload = function () {
105
+ if (x.status === 200) {
106
+ try {
107
+ var r = JSON.parse(x.responseText)
108
+ cb(r.version)
109
+ } catch (e) {
110
+ cb(null)
111
+ }
112
+ } else {
113
+ cb(null)
114
+ }
115
+ }
116
+ x.onerror = function () {
117
+ cb(null)
118
+ }
119
+ x.send()
120
+ } catch (e) {
121
+ cb(null)
122
+ }
123
+ }
124
+ function j(f, cb) {
125
+ w.__obiSDKLoading = !0
126
+ var s = d.createElement("script")
127
+ s.type = "text/javascript"
128
+ s.async = !0
129
+ var b = "https://cdn.iamobi.ai/obi-sdk"
130
+ s.src = f.noCacheSDK
131
+ ? b + "-" + f.sdkVersion + ".js?t=" + Date.now()
132
+ : b + "-" + f.sdkVersion + ".js"
133
+ s.onload = cb
134
+ s.onerror = function () {
135
+ w.__obiSDKLoading = !1
136
+ w.console && w.console.error && w.console.error("Failed to load Obi SDK")
137
+ if (f.sdkVersion !== "latest" && !f.noCacheSDK) {
138
+ w.console && w.console.warn && w.console.warn("Falling back to latest version")
139
+ f.sdkVersion = "latest"
140
+ j(f, cb)
141
+ }
142
+ }
143
+ var fs = d.getElementsByTagName("script")[0]
144
+ fs.parentNode.insertBefore(s, fs)
145
+ }
146
+ function g(f) {
147
+ if (d.querySelector("obi-widget")) {
148
+ w.console && w.console.log && w.console.log("Obi Widget already exists on the page")
149
+ return
150
+ }
151
+ if (!w.customElements || !w.customElements.get("obi-widget")) {
152
+ w.console &&
153
+ w.console.warn &&
154
+ w.console.warn(
155
+ "Obi Widget component not registered - SDK may not have loaded properly"
156
+ )
157
+ return
158
+ }
159
+ var t = d.createElement("obi-widget")
160
+ f.theme && t.setAttribute("theme", f.theme)
161
+ f.apiKey && t.setAttribute("api-key", f.apiKey)
162
+ f.endpoint && t.setAttribute("endpoint", f.endpoint)
163
+ f.apiBaseUrl && t.setAttribute("api-base-url", f.apiBaseUrl)
164
+ t.style.position = "fixed"
165
+ t.style.zIndex = "9999"
166
+ switch (f.position) {
167
+ case "bottom-right":
168
+ t.style.bottom = "20px"
169
+ t.style.right = "20px"
170
+ break
171
+ case "bottom-left":
172
+ t.style.bottom = "20px"
173
+ t.style.left = "20px"
174
+ break
175
+ case "top-right":
176
+ t.style.top = "20px"
177
+ t.style.right = "20px"
178
+ break
179
+ case "top-left":
180
+ t.style.top = "20px"
181
+ t.style.left = "20px"
182
+ break
183
+ }
184
+ d.body.appendChild(t)
185
+ w.console && w.console.log && w.console.log("Obi Widget added to page")
186
+ }
187
+ d.readyState === "complete"
188
+ ? i()
189
+ : w.attachEvent
190
+ ? w.attachEvent("onload", i)
191
+ : w.addEventListener("load", i, !1)
192
+ })(window, document)
193
+ </script>
194
+ </body>
195
+ </html>
196
+ ```
197
+
198
+ The widget will automatically appear in the specified position on your page.
199
+
200
+ ## Coming Soon
201
+
202
+ The following features are under development and will be available in future releases:
203
+
204
+ - React integration components
205
+ - Import-based usage
206
+ - Advanced SDK methods for voice and screen capture
207
+
208
+ ## Documentation
209
+
210
+ ### Inline Loader Script
211
+
212
+ The inline loader script provides a self-contained way to add the Obi Widget to any webpage:
213
+
214
+ 1. It checks if there's a global configuration object (`window.obiWidgetConfig`)
215
+ 2. It merges this with default configuration values
216
+ 3. It queries the npm registry to get the latest version of the SDK
217
+ 4. It loads the SDK from your CDN with the appropriate version
218
+ 5. It creates the `<obi-widget>` element and positions it on the page
219
+ 6. It configures the widget with the provided options
220
+
221
+ Before using in production, you should update the CDN URL to point to where you host the SDK files:
222
+
223
+ ```js
224
+ // In the loader script, change this line:
225
+ var b = "https://cdn.iamobi.ai/obi-sdk"
226
+
227
+ // To point to your CDN:
228
+ var b = "https://your-cdn.iamobi.ai/path/to/obi-sdk"
229
+ ```
230
+
231
+ ### Widget Positioning
232
+
233
+ The widget can be positioned in one of four corners of the page:
234
+
235
+ ```js
236
+ window.obiWidgetConfig = {
237
+ position: "bottom-right", // Options: "bottom-right", "bottom-left", "top-right", "top-left"
238
+ apiKey: "YOUR_API_KEY",
239
+ apiBaseUrl: "https://www.iamobi.ai/api/",
240
+ }
241
+ ```
242
+
243
+ ### Theming
244
+
245
+ The widget supports light and dark themes:
246
+
247
+ ```js
248
+ window.obiWidgetConfig = {
249
+ theme: "light", // Options: "light", "dark"
250
+ apiKey: "YOUR_API_KEY",
251
+ apiBaseUrl: "https://www.iamobi.ai/api/",
252
+ }
253
+ ```
254
+
255
+ ### SDK Version Control
256
+
257
+ You can specify which version of the SDK to load:
258
+
259
+ ```js
260
+ window.obiWidgetConfig = {
261
+ sdkVersion: "latest", // Use "latest" or a specific version number
262
+ noCacheSDK: false, // Set to true to bypass cache
263
+ apiKey: "YOUR_API_KEY",
264
+ apiBaseUrl: "https://www.iamobi.ai/api/",
265
+ }
266
+ ```
267
+
268
+ ## Contributing
269
+
270
+ Contributions are welcome! Please feel free to submit a Pull Request.
271
+
272
+ ## License
273
+
274
+ SEE LICENSE IN LICENSE.txt