obi-sdk 0.1.2 → 0.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/README.md +99 -65
- package/dist/index-e52b38be.js +5223 -0
- package/dist/modular/chunks/assistant-5a47c1b4.js +234 -0
- package/dist/modular/chunks/assistant-5a47c1b4.js.map +1 -0
- package/dist/modular/chunks/mitt-3c1f932d.js +20 -0
- package/dist/modular/chunks/mitt-3c1f932d.js.map +1 -0
- package/dist/modular/chunks/{index-634e0df5.js → obi-widget-0d63936f.js} +2258 -253
- package/dist/modular/chunks/obi-widget-0d63936f.js.map +1 -0
- package/dist/modular/chunks/{session-e208b5bb.js → session-88fd0dca.js} +18 -39
- package/dist/modular/chunks/session-88fd0dca.js.map +1 -0
- package/dist/modular/core.js +11 -207
- package/dist/modular/core.js.map +1 -1
- package/dist/modular/index.js +78 -400
- package/dist/modular/index.js.map +1 -1
- package/dist/modular/ui.js +29 -1992
- package/dist/modular/ui.js.map +1 -1
- package/dist/obi-loader.iife.js +1 -1
- package/dist/obi-loader.iife.js.map +1 -1
- package/dist/obi-loader.js +36 -33
- package/dist/obi-loader.js.map +1 -1
- package/dist/obi-loader.umd.cjs +1 -1
- package/dist/obi-loader.umd.cjs.map +1 -1
- package/dist/obi-sdk.es.js +8 -22713
- package/dist/obi-sdk.standalone.iife.js +72 -175
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/obi-sdk.umd.js +121 -262
- package/dist/session-33b71dff.js +15762 -0
- package/package.json +1 -1
- package/dist/modular/chunks/index-634e0df5.js.map +0 -1
- package/dist/modular/chunks/session-e208b5bb.js.map +0 -1
package/dist/modular/core.js
CHANGED
|
@@ -1,210 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { O } from "./chunks/
|
|
4
|
-
|
|
5
|
-
constructor(config = {}) {
|
|
6
|
-
this.state = SDKState.READY;
|
|
7
|
-
this.emitter = mitt();
|
|
8
|
-
this.voiceEnabled = false;
|
|
9
|
-
this.screenCaptureEnabled = false;
|
|
10
|
-
this.config = ObiSDKConfigSchema.parse(config);
|
|
11
|
-
if (this.config.debug) {
|
|
12
|
-
console.log("ObiSDK initialized with config:", this.config);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async init() {
|
|
16
|
-
try {
|
|
17
|
-
if (this.config.enableVoice) {
|
|
18
|
-
await this.initVoice();
|
|
19
|
-
}
|
|
20
|
-
if (this.config.enableScreenCapture) {
|
|
21
|
-
await this.initScreenCapture();
|
|
22
|
-
}
|
|
23
|
-
this.setState(SDKState.READY);
|
|
24
|
-
this.emitter.emit(EventType.READY);
|
|
25
|
-
if (this.config.debug) {
|
|
26
|
-
console.log("ObiSDK ready");
|
|
27
|
-
}
|
|
28
|
-
} catch (error) {
|
|
29
|
-
const sdkError = {
|
|
30
|
-
code: "init_failed",
|
|
31
|
-
message: "Failed to initialize SDK",
|
|
32
|
-
details: error
|
|
33
|
-
};
|
|
34
|
-
this.handleError(sdkError);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async initVoice() {
|
|
38
|
-
if (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia) {
|
|
39
|
-
throw new Error("Voice recording not supported in this browser");
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
await window.navigator.mediaDevices.getUserMedia({ audio: true });
|
|
43
|
-
this.voiceEnabled = true;
|
|
44
|
-
if (this.config.debug) {
|
|
45
|
-
console.log("Voice capabilities initialized");
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
throw new Error(`Microphone access denied: ${error}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async initScreenCapture() {
|
|
52
|
-
if (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getDisplayMedia) {
|
|
53
|
-
throw new Error("Screen capture not supported in this browser");
|
|
54
|
-
}
|
|
55
|
-
this.screenCaptureEnabled = true;
|
|
56
|
-
if (this.config.debug) {
|
|
57
|
-
console.log("Screen capture capabilities initialized");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Set the SDK state and emit state change event
|
|
62
|
-
*/
|
|
63
|
-
setState(newState) {
|
|
64
|
-
this.state = newState;
|
|
65
|
-
this.emitter.emit(EventType.STATE_CHANGE, newState);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Handle SDK errors
|
|
69
|
-
*/
|
|
70
|
-
handleError(error) {
|
|
71
|
-
this.setState(SDKState.ERROR);
|
|
72
|
-
this.emitter.emit(EventType.ERROR, error);
|
|
73
|
-
if (this.config.debug) {
|
|
74
|
-
console.error("ObiSDK error:", error);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Start voice recording
|
|
79
|
-
*/
|
|
80
|
-
async startVoiceRecording() {
|
|
81
|
-
if (!this.voiceEnabled) {
|
|
82
|
-
this.handleError({
|
|
83
|
-
code: "voice_disabled",
|
|
84
|
-
message: "Voice recording is not enabled or available"
|
|
85
|
-
});
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
this.setState(SDKState.AGENT_SPEAKING);
|
|
90
|
-
this.emitter.emit(EventType.VOICE_START);
|
|
91
|
-
if (this.config.debug) {
|
|
92
|
-
console.log("Voice recording started");
|
|
93
|
-
}
|
|
94
|
-
} catch (error) {
|
|
95
|
-
this.handleError({
|
|
96
|
-
code: "voice_start_failed",
|
|
97
|
-
message: "Failed to start voice recording",
|
|
98
|
-
details: error
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Stop voice recording
|
|
104
|
-
*/
|
|
105
|
-
async stopVoiceRecording() {
|
|
106
|
-
if (this.state === SDKState.READY) {
|
|
107
|
-
return { transcript: void 0 };
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
const result = { transcript: "Sample transcript" };
|
|
111
|
-
this.setState(SDKState.READY);
|
|
112
|
-
this.emitter.emit(EventType.VOICE_STOP, result);
|
|
113
|
-
if (this.config.debug) {
|
|
114
|
-
console.log("Voice recording stopped:", result);
|
|
115
|
-
}
|
|
116
|
-
return result;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
this.handleError({
|
|
119
|
-
code: "voice_stop_failed",
|
|
120
|
-
message: "Failed to stop voice recording",
|
|
121
|
-
details: error
|
|
122
|
-
});
|
|
123
|
-
return { transcript: void 0 };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Start screen capture
|
|
128
|
-
*/
|
|
129
|
-
async startScreenCapture() {
|
|
130
|
-
if (!this.screenCaptureEnabled) {
|
|
131
|
-
this.handleError({
|
|
132
|
-
code: "screen_capture_disabled",
|
|
133
|
-
message: "Screen capture is not enabled or available"
|
|
134
|
-
});
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
this.setState(SDKState.AGENT_SPEAKING);
|
|
139
|
-
this.emitter.emit(EventType.SCREEN_CAPTURE_START);
|
|
140
|
-
if (this.config.debug) {
|
|
141
|
-
console.log("Screen capture started");
|
|
142
|
-
}
|
|
143
|
-
} catch (error) {
|
|
144
|
-
this.handleError({
|
|
145
|
-
code: "screen_capture_start_failed",
|
|
146
|
-
message: "Failed to start screen capture",
|
|
147
|
-
details: error
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Stop screen capture
|
|
153
|
-
*/
|
|
154
|
-
async stopScreenCapture() {
|
|
155
|
-
if (this.state === SDKState.READY) {
|
|
156
|
-
return { screenshot: void 0 };
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
const result = { screenshot: "data:image/png;base64,..." };
|
|
160
|
-
this.setState(SDKState.READY);
|
|
161
|
-
this.emitter.emit(EventType.SCREEN_CAPTURE_STOP, result);
|
|
162
|
-
if (this.config.debug) {
|
|
163
|
-
console.log("Screen capture stopped");
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
} catch (error) {
|
|
167
|
-
this.handleError({
|
|
168
|
-
code: "screen_capture_stop_failed",
|
|
169
|
-
message: "Failed to stop screen capture",
|
|
170
|
-
details: error
|
|
171
|
-
});
|
|
172
|
-
return { screenshot: void 0 };
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Subscribe to SDK events
|
|
177
|
-
*/
|
|
178
|
-
on(event, handler) {
|
|
179
|
-
this.emitter.on(event, handler);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Unsubscribe from SDK events
|
|
183
|
-
*/
|
|
184
|
-
off(event, handler) {
|
|
185
|
-
this.emitter.off(event, handler);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Get current SDK state
|
|
189
|
-
*/
|
|
190
|
-
getState() {
|
|
191
|
-
return this.state;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Cleanup and dispose SDK resources
|
|
195
|
-
*/
|
|
196
|
-
dispose() {
|
|
197
|
-
this.emitter.all.clear();
|
|
198
|
-
if (this.config.debug) {
|
|
199
|
-
console.log("ObiSDK disposed");
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
1
|
+
import { A, E, O, S } from "./chunks/obi-widget-0d63936f.js";
|
|
2
|
+
import { ObiSession } from "./chunks/session-88fd0dca.js";
|
|
3
|
+
import { a, O as O2 } from "./chunks/assistant-5a47c1b4.js";
|
|
4
|
+
import "./chunks/mitt-3c1f932d.js";
|
|
203
5
|
export {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
6
|
+
A as API_BASE_URL,
|
|
7
|
+
E as EventType,
|
|
8
|
+
a as ObiAssistant,
|
|
9
|
+
O2 as ObiSDK,
|
|
10
|
+
O as ObiSDKConfigSchema,
|
|
11
|
+
ObiSession,
|
|
12
|
+
S as SDKState
|
|
209
13
|
};
|
|
210
14
|
//# sourceMappingURL=core.js.map
|
package/dist/modular/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":[
|
|
1
|
+
{"version":3,"file":"core.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|