@oxvo/ai-live-assist 7.4.50 → 7.5.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/cjs/AiLiveAssist.d.ts +76 -11
- package/cjs/AiLiveAssist.js +1771 -298
- package/cjs/client.d.ts +19 -0
- package/cjs/client.js +51 -0
- package/cjs/context.d.ts +23 -1
- package/cjs/context.js +713 -126
- package/cjs/control.d.ts +2 -0
- package/cjs/control.js +42 -3
- package/cjs/ctaOffer.d.ts +11 -0
- package/cjs/ctaOffer.js +185 -0
- package/cjs/dialogFocusScope.js +1 -1
- package/cjs/guideAdmission.d.ts +46 -0
- package/cjs/guideAdmission.js +397 -0
- package/cjs/guideHost.d.ts +47 -0
- package/cjs/guideHost.js +48 -0
- package/cjs/guideInstallation.d.ts +12 -0
- package/cjs/guideInstallation.js +60 -0
- package/cjs/guideInstaller.d.ts +4 -0
- package/cjs/guideInstaller.js +116 -0
- package/cjs/guideMount.d.ts +22 -0
- package/cjs/guideMount.js +84 -0
- package/cjs/guideRecording.d.ts +64 -0
- package/cjs/guideRecording.js +176 -0
- package/cjs/guideRecordingSession.d.ts +35 -0
- package/cjs/guideRecordingSession.js +167 -0
- package/cjs/guideSubjectStore.d.ts +32 -0
- package/cjs/guideSubjectStore.js +105 -0
- package/cjs/guideTypes.d.ts +117 -0
- package/cjs/guideTypes.js +15 -0
- package/cjs/index.d.ts +6 -0
- package/cjs/index.js +25 -11
- package/cjs/liveAudioProcessor.d.ts +92 -0
- package/cjs/liveAudioProcessor.js +269 -0
- package/cjs/liveAudioQueue.d.ts +40 -0
- package/cjs/liveAudioQueue.js +130 -0
- package/cjs/liveAudioWorklet.d.ts +1 -0
- package/cjs/liveAudioWorklet.js +63 -0
- package/cjs/liveBrowserDetector.d.ts +16 -0
- package/cjs/liveBrowserDetector.js +75 -0
- package/cjs/liveBrowserDetectorWorker.d.ts +1 -0
- package/cjs/liveBrowserDetectorWorker.js +72 -0
- package/cjs/liveControlChannel.d.ts +176 -0
- package/cjs/liveControlChannel.js +829 -0
- package/cjs/liveDuplexMedia.d.ts +204 -0
- package/cjs/liveDuplexMedia.js +740 -0
- package/cjs/liveGuideAdmission.d.ts +21 -0
- package/cjs/liveGuideAdmission.js +94 -0
- package/cjs/liveGuideWidget.d.ts +68 -0
- package/cjs/liveGuideWidget.js +451 -0
- package/cjs/liveSpeechAssets.d.ts +36 -0
- package/cjs/liveSpeechAssets.js +39 -0
- package/cjs/liveSpeechCaptureBridge.d.ts +32 -0
- package/cjs/liveSpeechCaptureBridge.js +140 -0
- package/cjs/liveSpeechDetector.d.ts +62 -0
- package/cjs/liveSpeechDetector.js +206 -0
- package/cjs/liveSpeechModel.d.ts +46 -0
- package/cjs/liveSpeechModel.js +105 -0
- package/cjs/liveSpeechResampler.d.ts +22 -0
- package/cjs/liveSpeechResampler.js +93 -0
- package/cjs/liveSpeechWorker.d.ts +56 -0
- package/cjs/liveSpeechWorker.js +143 -0
- package/cjs/locales/resources.js +568 -8
- package/cjs/media.d.ts +11 -0
- package/cjs/media.js +78 -9
- package/cjs/messages.js +22 -8
- package/cjs/pageAssistancePreference.d.ts +15 -3
- package/cjs/pageAssistancePreference.js +46 -7
- package/cjs/preview.d.ts +4 -1
- package/cjs/preview.js +42 -1
- package/cjs/recording.d.ts +12 -0
- package/cjs/recording.js +150 -0
- package/cjs/standalone.d.ts +6 -0
- package/cjs/standalone.js +12 -0
- package/cjs/types.d.ts +31 -5
- package/cjs/types.js +14 -0
- package/cjs/ui.d.ts +128 -4
- package/cjs/ui.js +1918 -276
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/cjs/voicePresenceUi.d.ts +52 -4
- package/cjs/voicePresenceUi.js +659 -57
- package/lib/AiLiveAssist.d.ts +76 -11
- package/lib/AiLiveAssist.js +1772 -299
- package/lib/client.d.ts +19 -0
- package/lib/client.js +51 -0
- package/lib/context.d.ts +23 -1
- package/lib/context.js +713 -126
- package/lib/control.d.ts +2 -0
- package/lib/control.js +42 -3
- package/lib/ctaOffer.d.ts +11 -0
- package/lib/ctaOffer.js +179 -0
- package/lib/dialogFocusScope.js +1 -1
- package/lib/guideAdmission.d.ts +46 -0
- package/lib/guideAdmission.js +392 -0
- package/lib/guideHost.d.ts +47 -0
- package/lib/guideHost.js +42 -0
- package/lib/guideInstallation.d.ts +12 -0
- package/lib/guideInstallation.js +56 -0
- package/lib/guideInstaller.d.ts +4 -0
- package/lib/guideInstaller.js +113 -0
- package/lib/guideMount.d.ts +22 -0
- package/lib/guideMount.js +77 -0
- package/lib/guideRecording.d.ts +64 -0
- package/lib/guideRecording.js +172 -0
- package/lib/guideRecordingSession.d.ts +35 -0
- package/lib/guideRecordingSession.js +163 -0
- package/lib/guideSubjectStore.d.ts +32 -0
- package/lib/guideSubjectStore.js +101 -0
- package/lib/guideTypes.d.ts +117 -0
- package/lib/guideTypes.js +11 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +21 -10
- package/lib/liveAudioProcessor.d.ts +92 -0
- package/lib/liveAudioProcessor.js +265 -0
- package/lib/liveAudioQueue.d.ts +40 -0
- package/lib/liveAudioQueue.js +126 -0
- package/lib/liveAudioWorklet.d.ts +1 -0
- package/lib/liveAudioWorklet.js +61 -0
- package/lib/liveBrowserDetector.d.ts +16 -0
- package/lib/liveBrowserDetector.js +71 -0
- package/lib/liveBrowserDetectorWorker.d.ts +1 -0
- package/lib/liveBrowserDetectorWorker.js +70 -0
- package/lib/liveControlChannel.d.ts +176 -0
- package/lib/liveControlChannel.js +825 -0
- package/lib/liveDuplexMedia.d.ts +204 -0
- package/lib/liveDuplexMedia.js +736 -0
- package/lib/liveGuideAdmission.d.ts +21 -0
- package/lib/liveGuideAdmission.js +90 -0
- package/lib/liveGuideWidget.d.ts +68 -0
- package/lib/liveGuideWidget.js +447 -0
- package/lib/liveSpeechAssets.d.ts +36 -0
- package/lib/liveSpeechAssets.js +35 -0
- package/lib/liveSpeechCaptureBridge.d.ts +32 -0
- package/lib/liveSpeechCaptureBridge.js +136 -0
- package/lib/liveSpeechDetector.d.ts +62 -0
- package/lib/liveSpeechDetector.js +202 -0
- package/lib/liveSpeechModel.d.ts +46 -0
- package/lib/liveSpeechModel.js +101 -0
- package/lib/liveSpeechResampler.d.ts +22 -0
- package/lib/liveSpeechResampler.js +89 -0
- package/lib/liveSpeechWorker.d.ts +56 -0
- package/lib/liveSpeechWorker.js +137 -0
- package/lib/locales/resources.js +568 -8
- package/lib/media.d.ts +11 -0
- package/lib/media.js +77 -8
- package/lib/messages.js +22 -8
- package/lib/pageAssistancePreference.d.ts +15 -3
- package/lib/pageAssistancePreference.js +46 -7
- package/lib/preview.d.ts +4 -1
- package/lib/preview.js +42 -1
- package/lib/recording.d.ts +12 -0
- package/lib/recording.js +146 -0
- package/lib/standalone.d.ts +6 -0
- package/lib/standalone.js +6 -0
- package/lib/types.d.ts +31 -5
- package/lib/types.js +14 -0
- package/lib/ui.d.ts +128 -4
- package/lib/ui.js +1919 -277
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/voicePresenceUi.d.ts +52 -4
- package/lib/voicePresenceUi.js +659 -57
- package/package.json +16 -1
package/lib/media.d.ts
CHANGED
|
@@ -7,28 +7,36 @@ type MediaCallbacks = {
|
|
|
7
7
|
onMicrophoneUnavailable: () => void;
|
|
8
8
|
};
|
|
9
9
|
type MediaLifecycleCheck = () => boolean;
|
|
10
|
+
export declare const AUTOMATIC_PLAYBACK_ECHO_TAIL_MS = 400;
|
|
10
11
|
export declare class RealtimeMedia {
|
|
11
12
|
private readonly client;
|
|
12
13
|
private readonly callbacks;
|
|
13
14
|
private readonly isCurrent;
|
|
14
15
|
private connection;
|
|
15
16
|
private localStream;
|
|
17
|
+
private pendingReplacementStream;
|
|
16
18
|
private streamlessRemoteStream;
|
|
17
19
|
private dataChannel;
|
|
18
20
|
private manualTurn;
|
|
19
21
|
private pushActive;
|
|
20
22
|
private muted;
|
|
23
|
+
private assistantPlaybackAudible;
|
|
24
|
+
private automaticPlaybackSuppressed;
|
|
25
|
+
private playbackTailTimer;
|
|
26
|
+
private playbackGateGeneration;
|
|
21
27
|
private replacingDevice;
|
|
22
28
|
private closed;
|
|
23
29
|
private generation;
|
|
24
30
|
private deviceGeneration;
|
|
25
31
|
private signal;
|
|
26
32
|
private readonly lifetimeAbort;
|
|
33
|
+
private readonly stoppedStreams;
|
|
27
34
|
constructor(client: RuntimeClient, callbacks: MediaCallbacks, isCurrent?: MediaLifecycleCheck);
|
|
28
35
|
prepare(mode: AssistMode, signal: AbortSignal): Promise<void>;
|
|
29
36
|
connect(result: LaunchResult, mode: AssistMode, signal: AbortSignal, offerIdempotencyKey?: string, expectedSessionState?: "active_text" | "active_voice"): Promise<number>;
|
|
30
37
|
setMuted(muted: boolean): void;
|
|
31
38
|
get isMuted(): boolean;
|
|
39
|
+
setAssistantPlaybackAudible(audible: boolean): void;
|
|
32
40
|
setManualTurn(manual: boolean): void;
|
|
33
41
|
beginPushToTalk(): void;
|
|
34
42
|
endPushToTalk(): void;
|
|
@@ -37,6 +45,9 @@ export declare class RealtimeMedia {
|
|
|
37
45
|
close(): void;
|
|
38
46
|
private remoteStreamFor;
|
|
39
47
|
private applyTrackState;
|
|
48
|
+
private stopStream;
|
|
49
|
+
private cancelPlaybackTail;
|
|
50
|
+
private resetPlaybackGate;
|
|
40
51
|
private bindTrackEnd;
|
|
41
52
|
private onDeviceChange;
|
|
42
53
|
private replaceUnavailableDevice;
|
package/lib/media.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const AUTOMATIC_PLAYBACK_ECHO_TAIL_MS = 400;
|
|
1
2
|
const abortError = () => new DOMException("The operation was aborted.", "AbortError");
|
|
2
3
|
const stopStream = (stream) => {
|
|
3
4
|
for (const track of stream?.getTracks() ?? [])
|
|
@@ -10,17 +11,23 @@ export class RealtimeMedia {
|
|
|
10
11
|
this.isCurrent = isCurrent;
|
|
11
12
|
this.connection = null;
|
|
12
13
|
this.localStream = null;
|
|
14
|
+
this.pendingReplacementStream = null;
|
|
13
15
|
this.streamlessRemoteStream = null;
|
|
14
16
|
this.dataChannel = null;
|
|
15
17
|
this.manualTurn = false;
|
|
16
18
|
this.pushActive = false;
|
|
17
19
|
this.muted = false;
|
|
20
|
+
this.assistantPlaybackAudible = false;
|
|
21
|
+
this.automaticPlaybackSuppressed = false;
|
|
22
|
+
this.playbackTailTimer = null;
|
|
23
|
+
this.playbackGateGeneration = 0;
|
|
18
24
|
this.replacingDevice = false;
|
|
19
25
|
this.closed = false;
|
|
20
26
|
this.generation = 0;
|
|
21
27
|
this.deviceGeneration = 0;
|
|
22
28
|
this.signal = null;
|
|
23
29
|
this.lifetimeAbort = new AbortController();
|
|
30
|
+
this.stoppedStreams = new WeakSet();
|
|
24
31
|
this.onDeviceChange = () => {
|
|
25
32
|
if (!this.connection && this.localStream) {
|
|
26
33
|
const track = this.localStream.getAudioTracks()[0];
|
|
@@ -53,7 +60,7 @@ export class RealtimeMedia {
|
|
|
53
60
|
this.assertActive(signal, generation);
|
|
54
61
|
}
|
|
55
62
|
catch (error) {
|
|
56
|
-
stopStream(stream);
|
|
63
|
+
this.stopStream(stream);
|
|
57
64
|
throw error;
|
|
58
65
|
}
|
|
59
66
|
this.localStream = stream;
|
|
@@ -127,6 +134,35 @@ export class RealtimeMedia {
|
|
|
127
134
|
get isMuted() {
|
|
128
135
|
return this.muted;
|
|
129
136
|
}
|
|
137
|
+
setAssistantPlaybackAudible(audible) {
|
|
138
|
+
if (this.closed)
|
|
139
|
+
return;
|
|
140
|
+
this.assistantPlaybackAudible = audible;
|
|
141
|
+
if (audible) {
|
|
142
|
+
this.cancelPlaybackTail();
|
|
143
|
+
this.automaticPlaybackSuppressed = true;
|
|
144
|
+
this.applyTrackState();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!this.automaticPlaybackSuppressed || this.playbackTailTimer !== null) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const generation = this.generation;
|
|
151
|
+
const playbackGateGeneration = this.playbackGateGeneration;
|
|
152
|
+
this.playbackTailTimer = setTimeout(() => {
|
|
153
|
+
if (playbackGateGeneration !== this.playbackGateGeneration)
|
|
154
|
+
return;
|
|
155
|
+
this.playbackTailTimer = null;
|
|
156
|
+
const signal = this.signal;
|
|
157
|
+
if (this.assistantPlaybackAudible ||
|
|
158
|
+
!signal ||
|
|
159
|
+
!this.active(signal, generation)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.automaticPlaybackSuppressed = false;
|
|
163
|
+
this.applyTrackState();
|
|
164
|
+
}, AUTOMATIC_PLAYBACK_ECHO_TAIL_MS);
|
|
165
|
+
}
|
|
130
166
|
setManualTurn(manual) {
|
|
131
167
|
this.manualTurn = manual;
|
|
132
168
|
this.pushActive = false;
|
|
@@ -144,9 +180,12 @@ export class RealtimeMedia {
|
|
|
144
180
|
}
|
|
145
181
|
revokeLocalAudioCapture() {
|
|
146
182
|
this.deviceGeneration += 1;
|
|
183
|
+
this.resetPlaybackGate();
|
|
184
|
+
this.stopStream(this.pendingReplacementStream);
|
|
185
|
+
this.pendingReplacementStream = null;
|
|
147
186
|
if (!this.localStream)
|
|
148
187
|
return;
|
|
149
|
-
stopStream(this.localStream);
|
|
188
|
+
this.stopStream(this.localStream);
|
|
150
189
|
this.localStream = null;
|
|
151
190
|
this.callbacks.onLocalStream(null);
|
|
152
191
|
navigator.mediaDevices?.removeEventListener?.("devicechange", this.onDeviceChange);
|
|
@@ -166,9 +205,12 @@ export class RealtimeMedia {
|
|
|
166
205
|
this.deviceGeneration += 1;
|
|
167
206
|
this.lifetimeAbort.abort();
|
|
168
207
|
}
|
|
208
|
+
this.resetPlaybackGate();
|
|
169
209
|
this.dataChannel?.close();
|
|
170
210
|
this.dataChannel = null;
|
|
171
|
-
stopStream(this.
|
|
211
|
+
this.stopStream(this.pendingReplacementStream);
|
|
212
|
+
this.pendingReplacementStream = null;
|
|
213
|
+
this.stopStream(this.localStream);
|
|
172
214
|
this.localStream = null;
|
|
173
215
|
this.callbacks.onLocalStream(null);
|
|
174
216
|
navigator.mediaDevices?.removeEventListener?.("devicechange", this.onDeviceChange);
|
|
@@ -185,10 +227,31 @@ export class RealtimeMedia {
|
|
|
185
227
|
return stream;
|
|
186
228
|
}
|
|
187
229
|
applyTrackState() {
|
|
188
|
-
const enabled = !this.muted &&
|
|
189
|
-
|
|
190
|
-
|
|
230
|
+
const enabled = !this.muted &&
|
|
231
|
+
(this.manualTurn ? this.pushActive : !this.automaticPlaybackSuppressed);
|
|
232
|
+
for (const stream of [this.localStream, this.pendingReplacementStream]) {
|
|
233
|
+
for (const track of stream?.getAudioTracks() ?? []) {
|
|
234
|
+
track.enabled = enabled;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
stopStream(stream) {
|
|
239
|
+
if (!stream || this.stoppedStreams.has(stream))
|
|
240
|
+
return;
|
|
241
|
+
this.stoppedStreams.add(stream);
|
|
242
|
+
stopStream(stream);
|
|
243
|
+
}
|
|
244
|
+
cancelPlaybackTail() {
|
|
245
|
+
if (this.playbackTailTimer !== null) {
|
|
246
|
+
clearTimeout(this.playbackTailTimer);
|
|
247
|
+
this.playbackTailTimer = null;
|
|
191
248
|
}
|
|
249
|
+
this.playbackGateGeneration += 1;
|
|
250
|
+
}
|
|
251
|
+
resetPlaybackGate() {
|
|
252
|
+
this.cancelPlaybackTail();
|
|
253
|
+
this.assistantPlaybackAudible = false;
|
|
254
|
+
this.automaticPlaybackSuppressed = false;
|
|
192
255
|
}
|
|
193
256
|
bindTrackEnd() {
|
|
194
257
|
for (const track of this.localStream?.getAudioTracks() ?? []) {
|
|
@@ -245,21 +308,27 @@ export class RealtimeMedia {
|
|
|
245
308
|
.find((candidate) => candidate.track?.kind === "audio");
|
|
246
309
|
if (!track || !sender)
|
|
247
310
|
throw new Error("No replacement microphone track.");
|
|
311
|
+
this.pendingReplacementStream = replacement;
|
|
312
|
+
this.applyTrackState();
|
|
248
313
|
await sender.replaceTrack(track);
|
|
249
314
|
this.assertReplacementActive(signal, generation, deviceGeneration);
|
|
250
315
|
if (this.connection !== connection || this.localStream !== priorStream) {
|
|
251
316
|
throw abortError();
|
|
252
317
|
}
|
|
253
|
-
stopStream(priorStream);
|
|
318
|
+
this.stopStream(priorStream);
|
|
254
319
|
const activeReplacement = replacement;
|
|
255
320
|
this.localStream = activeReplacement;
|
|
321
|
+
this.pendingReplacementStream = null;
|
|
256
322
|
replacement = null;
|
|
257
323
|
this.bindTrackEnd();
|
|
258
324
|
this.applyTrackState();
|
|
259
325
|
this.callbacks.onLocalStream(activeReplacement);
|
|
260
326
|
}
|
|
261
327
|
catch (error) {
|
|
262
|
-
|
|
328
|
+
if (this.pendingReplacementStream === replacement) {
|
|
329
|
+
this.pendingReplacementStream = null;
|
|
330
|
+
}
|
|
331
|
+
this.stopStream(replacement);
|
|
263
332
|
if (!(error instanceof DOMException && error.name === "AbortError") &&
|
|
264
333
|
this.active(signal, generation)) {
|
|
265
334
|
this.callbacks.onMicrophoneUnavailable();
|
package/lib/messages.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export const defaultMessages = {
|
|
2
|
+
ctaDismiss: "Dismiss suggestion",
|
|
3
|
+
ctaNewTab: "Opens in a new tab",
|
|
4
|
+
ctaAvailable: "An optional next step is available.",
|
|
5
|
+
ctaPreviewMessage: "Here is an optional next step when you are ready.",
|
|
2
6
|
launcher: "Ask AI",
|
|
3
7
|
introTitle: "AI Guide",
|
|
4
8
|
conversationStarters: "Conversation starters",
|
|
5
9
|
disclosure: "You are interacting with an AI assistant.",
|
|
6
10
|
requiredConsent: "I understand that I am interacting with an AI assistant.",
|
|
7
11
|
consentAgreement: "I agree to use AI Guide.",
|
|
8
|
-
pageAssistanceTitle: "Allow AI
|
|
12
|
+
pageAssistanceTitle: "Allow AI assistance?",
|
|
9
13
|
pageAssistanceAlways: "Remember this choice for this site",
|
|
10
14
|
pageAssistanceAgreement: "By allowing, you agree to: ",
|
|
11
15
|
pageAssistanceAgreementConnector: " and ",
|
|
@@ -13,7 +17,7 @@ export const defaultMessages = {
|
|
|
13
17
|
pageAssistanceAppliesTo: "Applies to {target}.",
|
|
14
18
|
pageAssistanceAllow: "Allow",
|
|
15
19
|
pageAssistanceNotNow: "Not now",
|
|
16
|
-
pageAssistanceRevoke: "
|
|
20
|
+
pageAssistanceRevoke: "Forget saved page access",
|
|
17
21
|
legalDetails: "Terms and privacy",
|
|
18
22
|
legalTitle: "AI Guide terms and privacy",
|
|
19
23
|
legalClose: "Close details",
|
|
@@ -33,6 +37,8 @@ export const defaultMessages = {
|
|
|
33
37
|
handoffContextShare: "Share with support",
|
|
34
38
|
handoffContextNotNow: "Not now",
|
|
35
39
|
retentionConsent: "Retain a transcript with sensitive details removed under this site’s policy.",
|
|
40
|
+
recordingConsent: "Allow session recording (optional)",
|
|
41
|
+
recordingConsentDescription: "Record your browsing activity on this site to improve support. You can use AI Guide without recording.",
|
|
36
42
|
startText: "Start with text",
|
|
37
43
|
startVoice: "Start with voice",
|
|
38
44
|
connecting: "Connecting securely",
|
|
@@ -60,12 +66,20 @@ export const defaultMessages = {
|
|
|
60
66
|
muted: "Muted",
|
|
61
67
|
unmute: "Unmute",
|
|
62
68
|
interrupt: "Stop AI response",
|
|
63
|
-
usePushToTalk: "
|
|
69
|
+
usePushToTalk: "Push to talk",
|
|
64
70
|
useAutomaticTurns: "Return to automatic listening",
|
|
65
71
|
automaticTurnsUnavailable: "Automatic listening unavailable",
|
|
66
72
|
startSpeaking: "Start speaking",
|
|
67
73
|
sendVoiceTurn: "Send voice turn",
|
|
68
|
-
|
|
74
|
+
preparingMicrophone: "Preparing microphone…",
|
|
75
|
+
cancelVoiceStart: "Cancel microphone start",
|
|
76
|
+
microphoneUnavailable: "The microphone is unavailable. Allow microphone access and try Voice again.",
|
|
77
|
+
voiceUnavailable: "Voice is unavailable. Select the microphone to try again.",
|
|
78
|
+
voiceConsentRequired: "End this conversation, then start voice to allow microphone access.",
|
|
79
|
+
startVoiceHint: "Select the microphone to start speaking.",
|
|
80
|
+
repeatWhenMicrophoneReady: "Please repeat that when the microphone is ready.",
|
|
81
|
+
audioMonitoringPaused: "Audio monitoring paused. Select the microphone to try again.",
|
|
82
|
+
taskContextLimit: "This task has reached its context limit. Start a new conversation to continue.",
|
|
69
83
|
pauseActions: "Pause page actions",
|
|
70
84
|
resumeActions: "Resume page actions",
|
|
71
85
|
captionsOn: "Hide live captions",
|
|
@@ -85,10 +99,10 @@ export const defaultMessages = {
|
|
|
85
99
|
requestHumanFallback: "Request human support",
|
|
86
100
|
approve: "Approve",
|
|
87
101
|
decline: "Decline",
|
|
88
|
-
actionRequest: "Review
|
|
89
|
-
actionRunning: "Applying
|
|
90
|
-
actionVerified: "Action completed
|
|
91
|
-
actionFailed: "
|
|
102
|
+
actionRequest: "Review action",
|
|
103
|
+
actionRunning: "Applying action",
|
|
104
|
+
actionVerified: "Action completed",
|
|
105
|
+
actionFailed: "Action not confirmed",
|
|
92
106
|
actionVerificationExpired: "I couldn’t confirm whether the action completed after reconnecting. Please ask me to try again.",
|
|
93
107
|
limitReached: "This session reached its configured limit.",
|
|
94
108
|
ended: "This AI Guide session has ended.",
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
export declare const MAX_PAGE_ASSISTANCE_PREFERENCE_TTL_MS: number;
|
|
2
2
|
export declare const MAX_PAGE_ASSISTANCE_RECOVERY_TTL_MS: number;
|
|
3
|
+
export type PageAssistanceGuideScope = Readonly<{
|
|
4
|
+
projectId: number;
|
|
5
|
+
guideId: string;
|
|
6
|
+
}>;
|
|
7
|
+
type PageAssistanceScope = {
|
|
8
|
+
siteKey: string;
|
|
9
|
+
projectId?: never;
|
|
10
|
+
guideId?: never;
|
|
11
|
+
} | (PageAssistanceGuideScope & {
|
|
12
|
+
siteKey?: never;
|
|
13
|
+
});
|
|
3
14
|
export type PageAssistancePreferenceBinding = Readonly<{
|
|
4
15
|
origin: string;
|
|
5
|
-
siteKey: string;
|
|
6
16
|
visitorDigest: string;
|
|
7
17
|
schemaVersion: number;
|
|
8
18
|
configRevision: number;
|
|
9
19
|
policyVersion: number;
|
|
10
20
|
capability: "browser_control";
|
|
11
|
-
}
|
|
21
|
+
}> & PageAssistanceScope;
|
|
12
22
|
export type PageAssistanceReceipt = Readonly<{
|
|
13
23
|
receipt: string;
|
|
14
24
|
expiresAt: string;
|
|
15
25
|
}>;
|
|
16
26
|
export type PageAssistancePreferenceOptions = Readonly<{
|
|
27
|
+
storageNamespace?: string;
|
|
17
28
|
storage?: Storage | null;
|
|
18
29
|
eventTarget?: Window | null;
|
|
19
30
|
now?: () => number;
|
|
@@ -36,6 +47,7 @@ export type PageAssistanceRecoveryReceipt = PageAssistanceRecoveryInput & Readon
|
|
|
36
47
|
submissionDigest: string;
|
|
37
48
|
}>;
|
|
38
49
|
export type PageAssistanceRecoveryOptions = Readonly<{
|
|
50
|
+
storageNamespace?: string;
|
|
39
51
|
storage?: Storage | null;
|
|
40
52
|
now?: () => number;
|
|
41
53
|
subtle?: DigestProvider;
|
|
@@ -48,7 +60,7 @@ export declare class PageAssistanceRecoveryStore {
|
|
|
48
60
|
private readonly storage;
|
|
49
61
|
private readonly now;
|
|
50
62
|
private readonly subtle;
|
|
51
|
-
constructor(
|
|
63
|
+
constructor(scope: string | PageAssistanceGuideScope, options?: PageAssistanceRecoveryOptions);
|
|
52
64
|
remember(value: PageAssistanceRecoveryInput, isCurrent: () => boolean): Promise<PageAssistanceRecoveryReceipt | null>;
|
|
53
65
|
storedRecordPresent(): boolean | null;
|
|
54
66
|
read(): Promise<PageAssistanceRecoveryReceipt | null>;
|
|
@@ -34,6 +34,24 @@ const validOrigin = (value) => {
|
|
|
34
34
|
};
|
|
35
35
|
const validSiteKey = (value) => validBoundedString(value, MAX_SITE_KEY_LENGTH) &&
|
|
36
36
|
/^[A-Za-z0-9_.:-]+$/.test(value);
|
|
37
|
+
const validGuideScope = (value) => Boolean(value) &&
|
|
38
|
+
typeof value === "object" &&
|
|
39
|
+
validPositiveInteger(value.projectId) &&
|
|
40
|
+
typeof value.guideId === "string" &&
|
|
41
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value.guideId);
|
|
42
|
+
const scopeNamespace = (scope) => typeof scope === "string"
|
|
43
|
+
? validSiteKey(scope)
|
|
44
|
+
? scope
|
|
45
|
+
: null
|
|
46
|
+
: validGuideScope(scope)
|
|
47
|
+
? `guide:${scope.projectId}:${scope.guideId}`
|
|
48
|
+
: null;
|
|
49
|
+
// Storage scoping is independent of the authenticated project key in receipts.
|
|
50
|
+
const storageNamespace = (siteKey, namespace) => {
|
|
51
|
+
if (namespace === undefined)
|
|
52
|
+
return siteKey;
|
|
53
|
+
return validBoundedString(namespace, 4096) ? namespace : null;
|
|
54
|
+
};
|
|
37
55
|
const validVisitorDigest = (value) => typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value);
|
|
38
56
|
const validReceipt = (value) => typeof value === "string" &&
|
|
39
57
|
value.length >= MIN_RECEIPT_LENGTH &&
|
|
@@ -51,8 +69,17 @@ const parseBinding = (value) => {
|
|
|
51
69
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
52
70
|
return null;
|
|
53
71
|
const candidate = value;
|
|
72
|
+
const scope = candidate.siteKey !== undefined
|
|
73
|
+
? validSiteKey(candidate.siteKey) &&
|
|
74
|
+
candidate.projectId === undefined &&
|
|
75
|
+
candidate.guideId === undefined
|
|
76
|
+
? { siteKey: candidate.siteKey }
|
|
77
|
+
: null
|
|
78
|
+
: validGuideScope(candidate)
|
|
79
|
+
? { projectId: candidate.projectId, guideId: candidate.guideId }
|
|
80
|
+
: null;
|
|
54
81
|
if (!validOrigin(candidate.origin) ||
|
|
55
|
-
!
|
|
82
|
+
!scope ||
|
|
56
83
|
!validVisitorDigest(candidate.visitorDigest) ||
|
|
57
84
|
!validPositiveInteger(candidate.schemaVersion) ||
|
|
58
85
|
!validPositiveInteger(candidate.configRevision) ||
|
|
@@ -62,7 +89,7 @@ const parseBinding = (value) => {
|
|
|
62
89
|
}
|
|
63
90
|
return {
|
|
64
91
|
origin: candidate.origin,
|
|
65
|
-
|
|
92
|
+
...scope,
|
|
66
93
|
visitorDigest: candidate.visitorDigest,
|
|
67
94
|
schemaVersion: candidate.schemaVersion,
|
|
68
95
|
configRevision: candidate.configRevision,
|
|
@@ -72,6 +99,8 @@ const parseBinding = (value) => {
|
|
|
72
99
|
};
|
|
73
100
|
const sameBinding = (left, right) => left.origin === right.origin &&
|
|
74
101
|
left.siteKey === right.siteKey &&
|
|
102
|
+
left.projectId === right.projectId &&
|
|
103
|
+
left.guideId === right.guideId &&
|
|
75
104
|
left.visitorDigest === right.visitorDigest &&
|
|
76
105
|
left.schemaVersion === right.schemaVersion &&
|
|
77
106
|
left.configRevision === right.configRevision &&
|
|
@@ -162,9 +191,13 @@ export const digestPageAssistanceVisitor = async (visitorId, subtle = globalThis
|
|
|
162
191
|
}
|
|
163
192
|
};
|
|
164
193
|
export class PageAssistanceRecoveryStore {
|
|
165
|
-
constructor(
|
|
166
|
-
|
|
167
|
-
|
|
194
|
+
constructor(scope, options = {}) {
|
|
195
|
+
const identityNamespace = scopeNamespace(scope);
|
|
196
|
+
const namespace = identityNamespace
|
|
197
|
+
? storageNamespace(identityNamespace, options.storageNamespace)
|
|
198
|
+
: null;
|
|
199
|
+
this.key = namespace
|
|
200
|
+
? `${RECOVERY_STORAGE_PREFIX}${encodeURIComponent(namespace)}`
|
|
168
201
|
: null;
|
|
169
202
|
this.storage =
|
|
170
203
|
options.storage === undefined ? defaultSessionStorage() : options.storage;
|
|
@@ -357,8 +390,14 @@ export class PageAssistancePreferenceStore {
|
|
|
357
390
|
this.notify(value, previous);
|
|
358
391
|
};
|
|
359
392
|
this.binding = parseBinding(binding);
|
|
360
|
-
|
|
361
|
-
?
|
|
393
|
+
const identityNamespace = this.binding
|
|
394
|
+
? scopeNamespace(this.binding.siteKey ?? this.binding)
|
|
395
|
+
: null;
|
|
396
|
+
const namespace = identityNamespace
|
|
397
|
+
? storageNamespace(identityNamespace, options.storageNamespace)
|
|
398
|
+
: null;
|
|
399
|
+
this.key = namespace
|
|
400
|
+
? `${STORAGE_PREFIX}${encodeURIComponent(namespace)}`
|
|
362
401
|
: null;
|
|
363
402
|
this.storage =
|
|
364
403
|
options.storage === undefined ? defaultStorage() : options.storage;
|
package/lib/preview.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import type { AiGuidePreviewBridge, AiGuidePreviewController, AiGuidePreviewCont
|
|
|
2
2
|
export declare const AI_GUIDE_PREVIEW_PARENT_SOURCE = "oxvo-ai-guide-settings-preview";
|
|
3
3
|
export declare const AI_GUIDE_PREVIEW_WIDGET_SOURCE = "oxvo-ai-guide-widget-preview";
|
|
4
4
|
export declare const AI_GUIDE_PREVIEW_PROTOCOL_VERSION = 1;
|
|
5
|
-
export declare const AI_GUIDE_PREVIEW_RENDERER_VERSION = "1.0.
|
|
5
|
+
export declare const AI_GUIDE_PREVIEW_RENDERER_VERSION = "1.0.62";
|
|
6
6
|
export declare const buildAiGuidePreviewBootstrap: (draft: unknown, assetOrigin?: string | null) => BootstrapConfig;
|
|
7
7
|
export declare class AiGuidePreviewControllerImpl implements AiGuidePreviewController {
|
|
8
8
|
private readonly port;
|
|
9
9
|
private readonly nonce;
|
|
10
10
|
private readonly assetOrigin;
|
|
11
|
+
private ctaPreview;
|
|
12
|
+
private ctaPreviewAnnounced;
|
|
11
13
|
private view;
|
|
12
14
|
private config;
|
|
13
15
|
private display;
|
|
@@ -24,6 +26,7 @@ export declare class AiGuidePreviewControllerImpl implements AiGuidePreviewContr
|
|
|
24
26
|
private scheduleRender;
|
|
25
27
|
private callbacks;
|
|
26
28
|
private render;
|
|
29
|
+
private renderCtaPreview;
|
|
27
30
|
private blockNavigation;
|
|
28
31
|
private onMessage;
|
|
29
32
|
private post;
|
package/lib/preview.js
CHANGED
|
@@ -3,10 +3,11 @@ import { resolveSupportedWidgetLocale, resolveWidgetMessages, } from "./locales/
|
|
|
3
3
|
import { widgetLocaleResources } from "./locales/resources.js";
|
|
4
4
|
import { WidgetView } from "./ui.js";
|
|
5
5
|
import { VoicePresenceView } from "./voicePresenceUi.js";
|
|
6
|
+
import { parseCtaOffer } from "./ctaOffer.js";
|
|
6
7
|
export const AI_GUIDE_PREVIEW_PARENT_SOURCE = "oxvo-ai-guide-settings-preview";
|
|
7
8
|
export const AI_GUIDE_PREVIEW_WIDGET_SOURCE = "oxvo-ai-guide-widget-preview";
|
|
8
9
|
export const AI_GUIDE_PREVIEW_PROTOCOL_VERSION = 1;
|
|
9
|
-
export const AI_GUIDE_PREVIEW_RENDERER_VERSION = "1.0.
|
|
10
|
+
export const AI_GUIDE_PREVIEW_RENDERER_VERSION = "1.0.62";
|
|
10
11
|
const DEFAULT_COMPANION = {
|
|
11
12
|
enabled: true,
|
|
12
13
|
title: "AI Guide",
|
|
@@ -364,6 +365,8 @@ export class AiGuidePreviewControllerImpl {
|
|
|
364
365
|
this.port = port;
|
|
365
366
|
this.nonce = nonce;
|
|
366
367
|
this.assetOrigin = assetOrigin;
|
|
368
|
+
this.ctaPreview = null;
|
|
369
|
+
this.ctaPreviewAnnounced = false;
|
|
367
370
|
this.view = null;
|
|
368
371
|
this.display = "expanded";
|
|
369
372
|
this.mode = "text";
|
|
@@ -404,6 +407,19 @@ export class AiGuidePreviewControllerImpl {
|
|
|
404
407
|
return;
|
|
405
408
|
}
|
|
406
409
|
const nextConfig = buildAiGuidePreviewBootstrap(input.config, this.assetOrigin);
|
|
410
|
+
const cta = asRecord(asRecord(asRecord(input.config).appearance).ctaGoal);
|
|
411
|
+
this.ctaPreview =
|
|
412
|
+
cta.enabled === true
|
|
413
|
+
? parseCtaOffer({
|
|
414
|
+
offerId: "preview_cta_offer",
|
|
415
|
+
sourceTurnId: "preview_cta_assistant",
|
|
416
|
+
label: cta.label,
|
|
417
|
+
url: cta.url,
|
|
418
|
+
openBehavior: cta.openBehavior,
|
|
419
|
+
configRevision: 1,
|
|
420
|
+
expiresAt: new Date(Date.now() + 300000).toISOString(),
|
|
421
|
+
})
|
|
422
|
+
: null;
|
|
407
423
|
const nextDisplay = enumValue(input.display, ["launcher", "expanded"], this.display);
|
|
408
424
|
const nextMode = this.resolveModeForConfig(nextConfig, enumValue(input.mode, ["text", "voice"], this.mode));
|
|
409
425
|
const canUpdateWidgetInPlace = this.view instanceof WidgetView &&
|
|
@@ -412,6 +428,7 @@ export class AiGuidePreviewControllerImpl {
|
|
|
412
428
|
this.config.available === nextConfig.available &&
|
|
413
429
|
this.display === nextDisplay &&
|
|
414
430
|
this.mode === nextMode &&
|
|
431
|
+
this.config.voice?.turnMode === nextConfig.voice?.turnMode &&
|
|
415
432
|
this.config.locale?.default === nextConfig.locale?.default &&
|
|
416
433
|
this.hasInteractiveMode(this.config) ===
|
|
417
434
|
this.hasInteractiveMode(nextConfig);
|
|
@@ -435,6 +452,8 @@ export class AiGuidePreviewControllerImpl {
|
|
|
435
452
|
}
|
|
436
453
|
else
|
|
437
454
|
this.render();
|
|
455
|
+
if (canUpdateWidgetInPlace || canUpdateVoiceInPlace)
|
|
456
|
+
this.renderCtaPreview();
|
|
438
457
|
this.post("state");
|
|
439
458
|
}
|
|
440
459
|
getState() {
|
|
@@ -500,6 +519,9 @@ export class AiGuidePreviewControllerImpl {
|
|
|
500
519
|
onTextOnly: () => this.scheduleRender({ mode: "text" }),
|
|
501
520
|
onModeChange: (mode) => this.scheduleRender({ mode }),
|
|
502
521
|
onText: () => false,
|
|
522
|
+
// Closed shadow roots hide the anchor from the host capture listener.
|
|
523
|
+
// Deny activation here as well so even same-tab preview links stay inert.
|
|
524
|
+
onCtaResult: () => false,
|
|
503
525
|
onHuman: noOperation,
|
|
504
526
|
onConfirmation: noOperation,
|
|
505
527
|
onVisualContext: noOperation,
|
|
@@ -528,12 +550,14 @@ export class AiGuidePreviewControllerImpl {
|
|
|
528
550
|
? new VoicePresenceView(this.config, {}, this.callbacks(), "preview-only", () => undefined, false, { previewMode: true })
|
|
529
551
|
: new WidgetView(this.config, {}, this.callbacks(), {
|
|
530
552
|
persistentState: false,
|
|
553
|
+
manualTurnsSupported: this.config.voice?.turnMode === "manual",
|
|
531
554
|
initialPanelView: compactVoicePreview ? "compact" : "expanded",
|
|
532
555
|
});
|
|
533
556
|
next.setCapabilityTier("static");
|
|
534
557
|
const host = next.rootElement();
|
|
535
558
|
host.dataset.oxvoAiGuidePreview = "true";
|
|
536
559
|
host.addEventListener("click", this.blockNavigation, true);
|
|
560
|
+
host.addEventListener("auxclick", this.blockNavigation, true);
|
|
537
561
|
if (!this.config.available) {
|
|
538
562
|
next.showLaunchUnavailable("AI Guide is disabled.");
|
|
539
563
|
}
|
|
@@ -546,13 +570,30 @@ export class AiGuidePreviewControllerImpl {
|
|
|
546
570
|
next.open("voice");
|
|
547
571
|
else {
|
|
548
572
|
next.showConnecting(false, this.mode);
|
|
573
|
+
next.configureVoiceControls(this.mode === "voice", this.config.voice?.turnMode === "manual", this.config.voice?.turnMode !== "manual");
|
|
549
574
|
next.showActive(this.config.appearance?.welcomeMessage ?? null);
|
|
550
575
|
}
|
|
551
576
|
}
|
|
552
577
|
this.view = next;
|
|
553
578
|
previous?.destroy();
|
|
579
|
+
this.renderCtaPreview();
|
|
554
580
|
this.rendering = false;
|
|
555
581
|
}
|
|
582
|
+
renderCtaPreview() {
|
|
583
|
+
const view = this.view;
|
|
584
|
+
if (!view)
|
|
585
|
+
return;
|
|
586
|
+
view.clearCtaOffer();
|
|
587
|
+
if (!this.ctaPreview ||
|
|
588
|
+
!this.config.available ||
|
|
589
|
+
(this.display !== "expanded" && this.mode !== "voice"))
|
|
590
|
+
return;
|
|
591
|
+
view.addCaption("assistant", view.message("ctaPreviewMessage"), true, {
|
|
592
|
+
sourceTurnId: this.ctaPreview.sourceTurnId,
|
|
593
|
+
});
|
|
594
|
+
view.showCtaOffer(this.ctaPreview, { announce: !this.ctaPreviewAnnounced });
|
|
595
|
+
this.ctaPreviewAnnounced = true;
|
|
596
|
+
}
|
|
556
597
|
post(type, code) {
|
|
557
598
|
this.port.postMessage({
|
|
558
599
|
source: AI_GUIDE_PREVIEW_WIDGET_SOURCE,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GuideRecordingAdapter, GuideRecordingStatus } from "./guideRecordingSession.js";
|
|
2
|
+
import type { AiGuideController, GuideIdentity, StandaloneGuideOptions } from "./guideTypes.js";
|
|
3
|
+
export type RecordingGuideOptions = StandaloneGuideOptions & {
|
|
4
|
+
recording: {
|
|
5
|
+
projectKey: string;
|
|
6
|
+
ingestUrl: string;
|
|
7
|
+
};
|
|
8
|
+
onRecordingStatus?: (status: GuideRecordingStatus) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function createGuideOwnedRecording(options: RecordingGuideOptions, identity: GuideIdentity, runtimeUrl: string): GuideRecordingAdapter;
|
|
11
|
+
/** Recording starts only after explicit visitor session_recording consent. */
|
|
12
|
+
export declare function installAiGuideWithRecording(options: RecordingGuideOptions): Promise<AiGuideController | undefined>;
|