@oxvo/ai-live-assist 7.3.4 → 7.4.23

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 (67) hide show
  1. package/cjs/AiLiveAssist.d.ts +588 -6
  2. package/cjs/AiLiveAssist.js +14892 -1240
  3. package/cjs/client.d.ts +71 -10
  4. package/cjs/client.js +316 -58
  5. package/cjs/context.d.ts +15 -5
  6. package/cjs/context.js +568 -73
  7. package/cjs/control.d.ts +72 -7
  8. package/cjs/control.js +594 -71
  9. package/cjs/dialogFocusScope.d.ts +37 -0
  10. package/cjs/dialogFocusScope.js +227 -0
  11. package/cjs/experienceState.js +1 -1
  12. package/cjs/index.d.ts +1 -1
  13. package/cjs/index.js +2 -2
  14. package/cjs/media.d.ts +14 -3
  15. package/cjs/media.js +128 -19
  16. package/cjs/messages.js +26 -3
  17. package/cjs/messengerLoader.d.ts +3 -0
  18. package/cjs/messengerLoader.js +156 -0
  19. package/cjs/pageAssistancePreference.d.ts +78 -0
  20. package/cjs/pageAssistancePreference.js +488 -0
  21. package/cjs/preview.d.ts +33 -0
  22. package/cjs/preview.js +567 -0
  23. package/cjs/tabLock.d.ts +54 -3
  24. package/cjs/tabLock.js +752 -72
  25. package/cjs/types.d.ts +152 -4
  26. package/cjs/ui.d.ts +200 -10
  27. package/cjs/ui.js +6946 -523
  28. package/cjs/version.d.ts +1 -1
  29. package/cjs/version.js +1 -1
  30. package/cjs/voicePresenceUi.d.ts +48 -9
  31. package/cjs/voicePresenceUi.js +863 -125
  32. package/lib/AiLiveAssist.d.ts +588 -6
  33. package/lib/AiLiveAssist.js +14897 -1248
  34. package/lib/client.d.ts +71 -10
  35. package/lib/client.js +313 -57
  36. package/lib/context.d.ts +15 -5
  37. package/lib/context.js +566 -72
  38. package/lib/control.d.ts +72 -7
  39. package/lib/control.js +594 -71
  40. package/lib/dialogFocusScope.d.ts +37 -0
  41. package/lib/dialogFocusScope.js +223 -0
  42. package/lib/experienceState.js +1 -1
  43. package/lib/index.d.ts +1 -1
  44. package/lib/index.js +2 -2
  45. package/lib/media.d.ts +14 -3
  46. package/lib/media.js +128 -19
  47. package/lib/messages.js +26 -3
  48. package/lib/messengerLoader.d.ts +3 -0
  49. package/lib/messengerLoader.js +151 -0
  50. package/lib/pageAssistancePreference.d.ts +78 -0
  51. package/lib/pageAssistancePreference.js +482 -0
  52. package/lib/preview.d.ts +33 -0
  53. package/lib/preview.js +561 -0
  54. package/lib/tabLock.d.ts +54 -3
  55. package/lib/tabLock.js +752 -72
  56. package/lib/types.d.ts +152 -4
  57. package/lib/ui.d.ts +200 -10
  58. package/lib/ui.js +6947 -524
  59. package/lib/version.d.ts +1 -1
  60. package/lib/version.js +1 -1
  61. package/lib/voicePresenceUi.d.ts +48 -9
  62. package/lib/voicePresenceUi.js +863 -125
  63. package/package.json +8 -3
  64. package/cjs/recordingPolicy.d.ts +0 -2
  65. package/cjs/recordingPolicy.js +0 -12
  66. package/lib/recordingPolicy.d.ts +0 -2
  67. package/lib/recordingPolicy.js +0 -8
package/cjs/messages.js CHANGED
@@ -7,10 +7,19 @@ exports.defaultMessages = {
7
7
  disclosure: "You are interacting with an AI assistant.",
8
8
  requiredConsent: "I understand that I am interacting with an AI assistant.",
9
9
  consentAgreement: "I agree to use AI Guide.",
10
+ pageAssistanceTitle: "Allow AI Guide to help on this page?",
11
+ pageAssistanceAlways: "Remember this choice for this site",
12
+ pageAssistanceAgreement: "By allowing, you agree to the ",
13
+ pageAssistanceAgreementConnector: " and ",
14
+ pageAssistanceAgreementTerminator: ".",
15
+ pageAssistanceAppliesTo: "Applies to {target}.",
16
+ pageAssistanceAllow: "Allow",
17
+ pageAssistanceNotNow: "Not now",
18
+ pageAssistanceRevoke: "Revoke always allow",
10
19
  legalDetails: "Terms and privacy",
11
20
  legalTitle: "AI Guide terms and privacy",
12
21
  legalClose: "Close details",
13
- termsOfService: "Terms of service",
22
+ termsOfService: "Terms of Service",
14
23
  microphoneConsent: "Send microphone audio to the AI provider for this session.",
15
24
  pageConsent: "Share a limited, sanitized description of this page.",
16
25
  controlConsent: "Allow approved low-risk page actions within this site.",
@@ -23,6 +32,8 @@ exports.defaultMessages = {
23
32
  pauseVisual: "Pause visual sharing",
24
33
  resumeVisual: "Resume visual sharing",
25
34
  handoffConsent: "Share a short conversation summary if I request a human.",
35
+ handoffContextShare: "Share with support",
36
+ handoffContextNotNow: "Not now",
26
37
  retentionConsent: "Retain a redacted transcript under this site’s policy.",
27
38
  startText: "Start with text",
28
39
  startVoice: "Start with voice",
@@ -33,14 +44,18 @@ exports.defaultMessages = {
33
44
  ready: "Ready",
34
45
  paused: "AI actions are paused. You remain in control.",
35
46
  reconnecting: "Reconnecting securely",
47
+ ending: "Ending session…",
48
+ handoffEnding: "Finishing the support connection…",
49
+ endRetry: "The session could not finish ending. Select End session to try again.",
36
50
  end: "End session",
37
51
  restart: "Start a new session",
38
52
  close: "Close",
39
53
  minimize: "Minimize",
40
- maximize: "Expand conversation",
54
+ maximize: "Chat",
41
55
  activeCall: "AI Guide is still active",
42
56
  movePanel: "Move AI Guide",
43
57
  mute: "Mute",
58
+ muted: "Muted",
44
59
  unmute: "Unmute",
45
60
  interrupt: "Stop AI response",
46
61
  usePushToTalk: "Use push to talk",
@@ -54,9 +69,16 @@ exports.defaultMessages = {
54
69
  captionsOn: "Hide live captions",
55
70
  captionsOff: "Show live captions",
56
71
  textOnly: "Switch to text only",
72
+ modeSwitch: "Conversation mode",
73
+ chatMode: "Chat",
74
+ voiceMode: "Voice",
75
+ stopVoice: "Stop voice",
57
76
  send: "Send",
58
77
  messagePlaceholder: "Type a message",
59
78
  requestHuman: "Request human support",
79
+ support: "Support",
80
+ supportReply: "New reply from Support",
81
+ viewSupport: "View reply",
60
82
  continueWithFullAssist: "Continue with Full Assist",
61
83
  requestHumanFallback: "Request human support",
62
84
  approve: "Approve",
@@ -65,6 +87,7 @@ exports.defaultMessages = {
65
87
  actionRunning: "Applying the approved action",
66
88
  actionVerified: "Action completed and verified",
67
89
  actionFailed: "The action could not be verified",
90
+ actionVerificationExpired: "I couldn’t confirm whether the action completed after reconnecting. Please ask me to try again.",
68
91
  limitReached: "This session reached its configured limit.",
69
92
  ended: "This AI Guide session has ended.",
70
93
  idleEnded: "This session ended after no visitor activity.",
@@ -80,7 +103,7 @@ exports.defaultMessages = {
80
103
  visitorCooldown: "Please wait before starting another AI Guide session.",
81
104
  visitorAlreadyActive: "An AI Guide session is already active for this visitor.",
82
105
  safetyBoundary: "Payment details, passwords, and verification codes are always handled by you. You can pause actions or end this session at any time.",
83
- privacyPolicy: "Privacy policy",
106
+ privacyPolicy: "Privacy Policy",
84
107
  moreControls: "More controls",
85
108
  emptyConversation: "Messages and live captions appear here.",
86
109
  audioPaused: "Audio playback is paused. Select the panel to continue.",
@@ -0,0 +1,3 @@
1
+ import type { MessengerWebWidgetDescriptor } from "./types.js";
2
+ export declare const normalizeMessengerWebWidgetDescriptor: (value: MessengerWebWidgetDescriptor | undefined) => MessengerWebWidgetDescriptor | null;
3
+ export declare const loadMessengerWebWidget: (descriptorInput: MessengerWebWidgetDescriptor, timeoutMs: number) => Promise<void>;
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadMessengerWebWidget = exports.normalizeMessengerWebWidgetDescriptor = void 0;
4
+ const MESSENGER_SCRIPT_MARKER = "data-oxvo-ai-messenger-companion";
5
+ const MESSENGER_SCRIPT_STATE = "data-oxvo-ai-messenger-state";
6
+ const MAX_URL_LENGTH = 2048;
7
+ const MAX_WEBSITE_TOKEN_LENGTH = 512;
8
+ const MAX_BIGINT_STRING = "9223372036854775807";
9
+ const positiveBigintString = (value) => {
10
+ if (typeof value !== "string" || !/^[1-9]\d{0,18}$/.test(value)) {
11
+ return null;
12
+ }
13
+ return value.length < MAX_BIGINT_STRING.length || value <= MAX_BIGINT_STRING
14
+ ? value
15
+ : null;
16
+ };
17
+ const httpUrl = (value, stripTrailingSlash = false) => {
18
+ if (typeof value !== "string" || value.length === 0 || value.length > MAX_URL_LENGTH) {
19
+ return null;
20
+ }
21
+ try {
22
+ const url = new URL(value, window.location.href);
23
+ if (!["http:", "https:"].includes(url.protocol) ||
24
+ url.username.length > 0 ||
25
+ url.password.length > 0) {
26
+ return null;
27
+ }
28
+ return stripTrailingSlash ? url.href.replace(/\/$/, "") : url.href;
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ };
34
+ const normalizeMessengerWebWidgetDescriptor = (value) => {
35
+ if (!value || typeof value !== "object")
36
+ return null;
37
+ const inboxId = positiveBigintString(value.inboxId);
38
+ const baseUrl = httpUrl(value.baseUrl, true);
39
+ const sdkUrl = httpUrl(value.sdkUrl);
40
+ const websiteToken = typeof value.websiteToken === "string" ? value.websiteToken.trim() : "";
41
+ if (!inboxId ||
42
+ !baseUrl ||
43
+ !sdkUrl ||
44
+ websiteToken.length === 0 ||
45
+ websiteToken.length > MAX_WEBSITE_TOKEN_LENGTH ||
46
+ /[\s\u0000-\u001f\u007f]/.test(websiteToken)) {
47
+ return null;
48
+ }
49
+ return { inboxId, baseUrl, sdkUrl, websiteToken };
50
+ };
51
+ exports.normalizeMessengerWebWidgetDescriptor = normalizeMessengerWebWidgetDescriptor;
52
+ const scriptMatches = (script, descriptor) => script.src === descriptor.sdkUrl &&
53
+ script.dataset.oxvoInboxId === descriptor.inboxId &&
54
+ script.dataset.oxvoBaseUrl === descriptor.baseUrl &&
55
+ script.dataset.oxvoWebsiteToken === descriptor.websiteToken;
56
+ const restoreSettingsAfterLoad = (settingsWindow, hiddenSettings, previousSettings) => {
57
+ if (settingsWindow.oxvoSettings !== hiddenSettings)
58
+ return;
59
+ if (previousSettings)
60
+ settingsWindow.oxvoSettings = previousSettings;
61
+ else
62
+ Reflect.deleteProperty(settingsWindow, "oxvoSettings");
63
+ };
64
+ const loadMessengerWebWidget = (descriptorInput, timeoutMs) => {
65
+ const descriptor = (0, exports.normalizeMessengerWebWidgetDescriptor)(descriptorInput);
66
+ if (!descriptor)
67
+ return Promise.reject(new Error("Invalid Messenger descriptor."));
68
+ const settingsWindow = window;
69
+ if (settingsWindow.oxvo)
70
+ return Promise.resolve();
71
+ const existing = document.querySelector(`script[${MESSENGER_SCRIPT_MARKER}="true"]`);
72
+ if (existing && !scriptMatches(existing, descriptor)) {
73
+ return Promise.reject(new Error("A different Messenger companion is already loading."));
74
+ }
75
+ if (existing?.getAttribute(MESSENGER_SCRIPT_STATE) === "error") {
76
+ return Promise.reject(new Error("Messenger failed to load."));
77
+ }
78
+ const script = existing ?? document.createElement("script");
79
+ const ownsScript = !existing;
80
+ if (!existing) {
81
+ script.async = true;
82
+ script.src = descriptor.sdkUrl;
83
+ script.setAttribute(MESSENGER_SCRIPT_MARKER, "true");
84
+ script.setAttribute(MESSENGER_SCRIPT_STATE, "loading");
85
+ script.dataset.oxvoInboxId = descriptor.inboxId;
86
+ script.dataset.oxvoBaseUrl = descriptor.baseUrl;
87
+ script.dataset.oxvoWebsiteToken = descriptor.websiteToken;
88
+ }
89
+ return new Promise((resolve, reject) => {
90
+ let settled = false;
91
+ const previousSettings = settingsWindow.oxvoSettings;
92
+ const hiddenSettings = {
93
+ ...(previousSettings ?? {}),
94
+ launcherVisible: false,
95
+ };
96
+ settingsWindow.oxvoSettings = hiddenSettings;
97
+ const finish = (error, preserveLateLoadGuard = false) => {
98
+ if (settled)
99
+ return;
100
+ settled = true;
101
+ window.clearTimeout(timeout);
102
+ if (!preserveLateLoadGuard) {
103
+ script.removeEventListener("load", loaded);
104
+ script.removeEventListener("error", failed);
105
+ }
106
+ if (error)
107
+ reject(error);
108
+ else
109
+ resolve();
110
+ };
111
+ const loaded = () => {
112
+ const messenger = settingsWindow.oxvo;
113
+ try {
114
+ messenger?.close?.();
115
+ messenger?.hideLauncher?.();
116
+ }
117
+ finally {
118
+ restoreSettingsAfterLoad(settingsWindow, hiddenSettings, previousSettings);
119
+ }
120
+ if (settled)
121
+ return;
122
+ if (!messenger) {
123
+ script.setAttribute(MESSENGER_SCRIPT_STATE, "error");
124
+ if (ownsScript)
125
+ script.remove();
126
+ finish(new Error("Messenger SDK did not initialize."));
127
+ return;
128
+ }
129
+ script.setAttribute(MESSENGER_SCRIPT_STATE, "loaded");
130
+ finish();
131
+ };
132
+ const failed = () => {
133
+ if (settled)
134
+ return;
135
+ script.setAttribute(MESSENGER_SCRIPT_STATE, "error");
136
+ if (ownsScript)
137
+ script.remove();
138
+ restoreSettingsAfterLoad(settingsWindow, hiddenSettings, previousSettings);
139
+ finish(new Error("Messenger failed to load."));
140
+ };
141
+ script.addEventListener("load", loaded, { once: true });
142
+ script.addEventListener("error", failed, { once: true });
143
+ const timeout = window.setTimeout(() => {
144
+ script.setAttribute(MESSENGER_SCRIPT_STATE, "error");
145
+ if (ownsScript)
146
+ script.remove();
147
+ restoreSettingsAfterLoad(settingsWindow, hiddenSettings, previousSettings);
148
+ finish(new Error("Messenger did not become available in time."), true);
149
+ }, Math.max(1, timeoutMs));
150
+ if (!existing)
151
+ document.head.append(script);
152
+ else if (script.getAttribute(MESSENGER_SCRIPT_STATE) === "loaded")
153
+ loaded();
154
+ });
155
+ };
156
+ exports.loadMessengerWebWidget = loadMessengerWebWidget;
@@ -0,0 +1,78 @@
1
+ export declare const MAX_PAGE_ASSISTANCE_PREFERENCE_TTL_MS: number;
2
+ export declare const MAX_PAGE_ASSISTANCE_RECOVERY_TTL_MS: number;
3
+ export type PageAssistancePreferenceBinding = Readonly<{
4
+ origin: string;
5
+ siteKey: string;
6
+ visitorDigest: string;
7
+ schemaVersion: number;
8
+ configRevision: number;
9
+ policyVersion: number;
10
+ capability: "browser_control";
11
+ }>;
12
+ export type PageAssistanceReceipt = Readonly<{
13
+ receipt: string;
14
+ expiresAt: string;
15
+ }>;
16
+ export type PageAssistancePreferenceOptions = Readonly<{
17
+ storage?: Storage | null;
18
+ eventTarget?: Window | null;
19
+ now?: () => number;
20
+ }>;
21
+ export type PageAssistanceRecoveryDecision = "allow_session" | "allow_persistent";
22
+ export type PageAssistanceRecoveryInput = Readonly<{
23
+ sessionId: string;
24
+ tabId: string;
25
+ bindingGeneration: string;
26
+ requestId: string;
27
+ proposalChecksum: string;
28
+ authorityEpoch: number;
29
+ decision: PageAssistanceRecoveryDecision;
30
+ persistentReceipt: string | null;
31
+ configRevision: number;
32
+ policyVersion: number;
33
+ expiresAt: number;
34
+ }>;
35
+ export type PageAssistanceRecoveryReceipt = PageAssistanceRecoveryInput & Readonly<{
36
+ submissionDigest: string;
37
+ }>;
38
+ export type PageAssistanceRecoveryOptions = Readonly<{
39
+ storage?: Storage | null;
40
+ now?: () => number;
41
+ subtle?: DigestProvider;
42
+ }>;
43
+ type PreferenceListener = (value: PageAssistanceReceipt | null, previous: PageAssistanceReceipt | null) => void;
44
+ type DigestProvider = Pick<SubtleCrypto, "digest">;
45
+ export declare const digestPageAssistanceVisitor: (visitorId: string, subtle?: DigestProvider | undefined) => Promise<string | null>;
46
+ export declare class PageAssistanceRecoveryStore {
47
+ private readonly key;
48
+ private readonly storage;
49
+ private readonly now;
50
+ private readonly subtle;
51
+ constructor(siteKey: string, options?: PageAssistanceRecoveryOptions);
52
+ remember(value: PageAssistanceRecoveryInput, isCurrent: () => boolean): Promise<PageAssistanceRecoveryReceipt | null>;
53
+ storedRecordPresent(): boolean | null;
54
+ read(): Promise<PageAssistanceRecoveryReceipt | null>;
55
+ consume(submissionDigest: string): boolean;
56
+ private clearIfUnchanged;
57
+ clear(): void;
58
+ }
59
+ export declare class PageAssistancePreferenceStore {
60
+ private readonly binding;
61
+ private readonly key;
62
+ private readonly storage;
63
+ private readonly eventTarget;
64
+ private readonly now;
65
+ private readonly listeners;
66
+ private lastKnownReceipt;
67
+ private destroyed;
68
+ constructor(binding: PageAssistancePreferenceBinding, options?: PageAssistancePreferenceOptions);
69
+ read(): PageAssistanceReceipt | null;
70
+ remember(value: PageAssistanceReceipt): boolean;
71
+ clear(): void;
72
+ subscribe(listener: PreferenceListener): () => void;
73
+ destroy(): void;
74
+ private parse;
75
+ private notify;
76
+ private onStorage;
77
+ }
78
+ export {};