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