@oxvo/ai-live-assist 7.3.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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/cjs/AiLiveAssist.d.ts +108 -0
  4. package/cjs/AiLiveAssist.js +1774 -0
  5. package/cjs/client.d.ts +53 -0
  6. package/cjs/client.js +193 -0
  7. package/cjs/context.d.ts +58 -0
  8. package/cjs/context.js +979 -0
  9. package/cjs/control.d.ts +31 -0
  10. package/cjs/control.js +190 -0
  11. package/cjs/experienceState.d.ts +18 -0
  12. package/cjs/experienceState.js +82 -0
  13. package/cjs/index.d.ts +13 -0
  14. package/cjs/index.js +32 -0
  15. package/cjs/media.d.ts +34 -0
  16. package/cjs/media.js +207 -0
  17. package/cjs/messages.d.ts +2 -0
  18. package/cjs/messages.js +95 -0
  19. package/cjs/package.json +1 -0
  20. package/cjs/placement.d.ts +52 -0
  21. package/cjs/placement.js +293 -0
  22. package/cjs/presentation.d.ts +41 -0
  23. package/cjs/presentation.js +483 -0
  24. package/cjs/recordingPolicy.d.ts +2 -0
  25. package/cjs/recordingPolicy.js +12 -0
  26. package/cjs/safeSvg.d.ts +1 -0
  27. package/cjs/safeSvg.js +157 -0
  28. package/cjs/tabLock.d.ts +31 -0
  29. package/cjs/tabLock.js +260 -0
  30. package/cjs/types.d.ts +299 -0
  31. package/cjs/types.js +2 -0
  32. package/cjs/ui.d.ts +184 -0
  33. package/cjs/ui.js +2353 -0
  34. package/cjs/version.d.ts +1 -0
  35. package/cjs/version.js +4 -0
  36. package/cjs/visualContext.d.ts +21 -0
  37. package/cjs/visualContext.js +72 -0
  38. package/cjs/voicePresenceUi.d.ts +148 -0
  39. package/cjs/voicePresenceUi.js +2182 -0
  40. package/lib/AiLiveAssist.d.ts +108 -0
  41. package/lib/AiLiveAssist.js +1769 -0
  42. package/lib/client.d.ts +53 -0
  43. package/lib/client.js +187 -0
  44. package/lib/context.d.ts +58 -0
  45. package/lib/context.js +975 -0
  46. package/lib/control.d.ts +31 -0
  47. package/lib/control.js +186 -0
  48. package/lib/experienceState.d.ts +18 -0
  49. package/lib/experienceState.js +78 -0
  50. package/lib/index.d.ts +13 -0
  51. package/lib/index.js +26 -0
  52. package/lib/media.d.ts +34 -0
  53. package/lib/media.js +203 -0
  54. package/lib/messages.d.ts +2 -0
  55. package/lib/messages.js +92 -0
  56. package/lib/placement.d.ts +52 -0
  57. package/lib/placement.js +286 -0
  58. package/lib/presentation.d.ts +41 -0
  59. package/lib/presentation.js +478 -0
  60. package/lib/recordingPolicy.d.ts +2 -0
  61. package/lib/recordingPolicy.js +8 -0
  62. package/lib/safeSvg.d.ts +1 -0
  63. package/lib/safeSvg.js +153 -0
  64. package/lib/tabLock.d.ts +31 -0
  65. package/lib/tabLock.js +256 -0
  66. package/lib/types.d.ts +299 -0
  67. package/lib/types.js +1 -0
  68. package/lib/ui.d.ts +184 -0
  69. package/lib/ui.js +2349 -0
  70. package/lib/version.d.ts +1 -0
  71. package/lib/version.js +1 -0
  72. package/lib/visualContext.d.ts +21 -0
  73. package/lib/visualContext.js +68 -0
  74. package/lib/voicePresenceUi.d.ts +148 -0
  75. package/lib/voicePresenceUi.js +2178 -0
  76. package/package.json +58 -0
@@ -0,0 +1 @@
1
+ export declare const VERSION = "7.3.0";
package/lib/version.js ADDED
@@ -0,0 +1 @@
1
+ export const VERSION = '7.3.0';
@@ -0,0 +1,21 @@
1
+ import type { VisualContextCapture } from './types.js';
2
+ export type SanitizedLayoutRegion = {
3
+ kind: 'target' | 'mask';
4
+ role: string;
5
+ label: string;
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ };
11
+ type SanitizedLayout = {
12
+ pageId: string;
13
+ revision: number;
14
+ viewport: {
15
+ width: number;
16
+ height: number;
17
+ };
18
+ regions: SanitizedLayoutRegion[];
19
+ };
20
+ export declare const renderSanitizedLayout: (layout: SanitizedLayout) => VisualContextCapture | null;
21
+ export {};
@@ -0,0 +1,68 @@
1
+ const MAX_WIDTH = 640;
2
+ const MAX_HEIGHT = 360;
3
+ const MAX_DATA_URL_LENGTH = 110000;
4
+ const boundedLabel = (value) => value.replace(/[\u0000-\u001f\u007f]/g, '').replace(/\s+/g, ' ').trim().slice(0, 80);
5
+ export const renderSanitizedLayout = (layout) => {
6
+ const scale = Math.min(1, MAX_WIDTH / layout.viewport.width, MAX_HEIGHT / layout.viewport.height);
7
+ const width = Math.max(1, Math.round(layout.viewport.width * scale));
8
+ const height = Math.max(1, Math.round(layout.viewport.height * scale));
9
+ const canvas = document.createElement('canvas');
10
+ canvas.width = width;
11
+ canvas.height = height;
12
+ const context = canvas.getContext('2d', { alpha: false });
13
+ if (!context)
14
+ return null;
15
+ context.fillStyle = '#f4f6f8';
16
+ context.fillRect(0, 0, width, height);
17
+ context.fillStyle = '#dfe5ea';
18
+ context.fillRect(0, 0, width, Math.min(height, 22));
19
+ context.fillStyle = '#33404c';
20
+ context.font = 'bold 9px sans-serif';
21
+ context.fillText('UNTRUSTED PRIVACY-FILTERED PAGE LAYOUT', 8, 14, Math.max(1, width - 16));
22
+ for (const region of layout.regions) {
23
+ const x = Math.max(0, Math.round(region.x * scale));
24
+ const y = Math.max(0, Math.round(region.y * scale));
25
+ const regionWidth = Math.max(1, Math.round(region.width * scale));
26
+ const regionHeight = Math.max(1, Math.round(region.height * scale));
27
+ if (region.kind === 'mask') {
28
+ context.fillStyle = '#202830';
29
+ context.fillRect(x, y, regionWidth, regionHeight);
30
+ context.strokeStyle = '#f0f3f5';
31
+ context.lineWidth = 1;
32
+ for (let offset = -regionHeight; offset < regionWidth; offset += 8) {
33
+ context.beginPath();
34
+ context.moveTo(x + offset, y + regionHeight);
35
+ context.lineTo(x + offset + regionHeight, y);
36
+ context.stroke();
37
+ }
38
+ continue;
39
+ }
40
+ context.fillStyle = '#ffffff';
41
+ context.fillRect(x, y, regionWidth, regionHeight);
42
+ context.strokeStyle = '#55758c';
43
+ context.lineWidth = 1;
44
+ context.strokeRect(x + 0.5, y + 0.5, Math.max(0, regionWidth - 1), Math.max(0, regionHeight - 1));
45
+ if (regionHeight >= 12 && regionWidth >= 24) {
46
+ const label = boundedLabel(`${region.role}: ${region.label}`);
47
+ context.fillStyle = '#253642';
48
+ context.font = '9px sans-serif';
49
+ context.fillText(label, x + 3, y + Math.min(11, regionHeight - 2), Math.max(1, regionWidth - 6));
50
+ }
51
+ }
52
+ for (const quality of [0.72, 0.56, 0.4]) {
53
+ const dataUrl = canvas.toDataURL('image/jpeg', quality);
54
+ if (dataUrl.startsWith('data:image/jpeg;base64,') &&
55
+ dataUrl.length <= MAX_DATA_URL_LENGTH) {
56
+ return {
57
+ source: 'sanitized_layout',
58
+ mimeType: 'image/jpeg',
59
+ dataUrl,
60
+ width,
61
+ height,
62
+ pageId: layout.pageId,
63
+ revision: layout.revision,
64
+ };
65
+ }
66
+ }
67
+ return null;
68
+ };
@@ -0,0 +1,148 @@
1
+ import type { AssistMode, BootstrapConfig, CapabilityTier, VisualContextRequest, WidgetMessageKey } from "./types.js";
2
+ import type { WidgetCallbacks } from "./ui.js";
3
+ type Confirmation = {
4
+ actionId: string;
5
+ proposalChecksum: string;
6
+ action: string;
7
+ targetLabel: string;
8
+ reason: string;
9
+ expectedEffect: string;
10
+ expiresAt: string;
11
+ };
12
+ type CaptionRole = "assistant" | "user";
13
+ type ServerPresenceState = "ready" | "listening" | "thinking" | "speaking" | "acting" | "awaiting_confirmation" | "reconnecting" | "ending";
14
+ export declare class VoicePresenceView {
15
+ private readonly callbacks;
16
+ private readonly onFallback;
17
+ private readonly config;
18
+ private readonly voiceConfig;
19
+ private readonly messages;
20
+ private readonly host;
21
+ private readonly shadow;
22
+ private readonly orb;
23
+ private readonly modalLayer;
24
+ private readonly agreement;
25
+ private readonly captionStage;
26
+ private readonly subtitleTrack;
27
+ private readonly statusBubble;
28
+ private readonly attributionBubble;
29
+ private readonly safetyCard;
30
+ private readonly recoveryCard;
31
+ private readonly liveRegion;
32
+ private readonly audio;
33
+ private readonly highlight;
34
+ private readonly stateMachine;
35
+ private readonly placement;
36
+ private readonly captionTimers;
37
+ private captionResizeObserver;
38
+ private captionLayoutFrame;
39
+ private highlightTarget;
40
+ private highlightResizeObserver;
41
+ private highlightFrame;
42
+ private highlightScrollTargets;
43
+ private currentConfirmation;
44
+ private currentVisualRequest;
45
+ private restoreFocus;
46
+ private active;
47
+ private activeElsewhere;
48
+ private destroyed;
49
+ private introPlayed;
50
+ private wakeTimer;
51
+ private statusTimer;
52
+ private attributionTimer;
53
+ private audioContext;
54
+ private playbackResumePending;
55
+ private outputSource;
56
+ private outputAnalyser;
57
+ private inputSource;
58
+ private inputAnalyser;
59
+ private levelFrame;
60
+ private levelBuffer;
61
+ private lastLevelAt;
62
+ private serverPresenceState;
63
+ private playbackState;
64
+ private capabilityTier;
65
+ constructor(config: BootstrapConfig, overrides: Partial<Record<WidgetMessageKey, string>>, callbacks: WidgetCallbacks, tabId: string, onFallback?: (fallback: "standard_assist" | "human_handoff") => void, visualTestMode?: boolean);
66
+ setRemoteStream(stream: MediaStream): void;
67
+ setCapabilityTier(tier: CapabilityTier): void;
68
+ setOrbTheme(theme: "light" | "dark"): void;
69
+ launcherRect(): DOMRectReadOnly | null;
70
+ presentationObstacles(): DOMRectReadOnly[];
71
+ setLocalStream(stream: MediaStream | null): void;
72
+ setStatus(value: string): void;
73
+ message(key: WidgetMessageKey): string;
74
+ setAssistantState(state: "listening" | "thinking" | "speaking" | "ready"): void;
75
+ applyPresenceState(state: ServerPresenceState, sequence: number, sessionId: string, pageId: string | null, fencingToken: number): void;
76
+ showPreflight(): void;
77
+ showRequestingMicrophone(): void;
78
+ showConnecting(resume?: boolean, _mode?: AssistMode): void;
79
+ showActive(welcomeMessage?: string | null): void;
80
+ addCaption(role: CaptionRole, text: string, final: boolean): void;
81
+ showConfirmation(value: Confirmation): void;
82
+ showActionState(status: "running" | "verified" | "failed"): void;
83
+ dismissActionState(): void;
84
+ showVisualRequest(value: VisualContextRequest): void;
85
+ showVisualResult(shared: boolean): void;
86
+ setVisualAvailable(_available: boolean, _paused?: boolean): void;
87
+ setVisualPaused(_paused: boolean): void;
88
+ setPaused(value: boolean): void;
89
+ setMuted(_value: boolean): void;
90
+ configureVoiceControls(_voice: boolean, _manual: boolean, _canUseAutomatic: boolean): void;
91
+ setManualTurn(_value: boolean): void;
92
+ setPushActive(_value: boolean): void;
93
+ interruptPlayback(): void;
94
+ showError(message?: string, retryable?: boolean, sessionActive?: boolean): void;
95
+ showEnded(message?: string): void;
96
+ showLimit(message?: string): void;
97
+ showActiveElsewhere(active: boolean): void;
98
+ showLaunchUnavailable(message: string): void;
99
+ updateHighlight(element: Element | null, status: "focus" | "success" | "failure"): void;
100
+ safetySurfaceVisible(): boolean;
101
+ cancelPendingConfirmation(): boolean;
102
+ resolvePendingConfirmation(approved: boolean): boolean;
103
+ destroy(): void;
104
+ private build;
105
+ private bind;
106
+ private bindPlaybackState;
107
+ private resumeRemotePlayback;
108
+ private effectivePresenceState;
109
+ private syncPresenceFromPlayback;
110
+ private syncLevelLoop;
111
+ private emitPlaybackState;
112
+ private applyConfig;
113
+ private openActivation;
114
+ private closeActivation;
115
+ private showAttribution;
116
+ private hideAttribution;
117
+ private onModalKeyDown;
118
+ private renderSafetyCard;
119
+ private hideSafetyCard;
120
+ private resolveConfirmation;
121
+ private resolveVisualRequest;
122
+ private renderRecoveryCard;
123
+ private syncSubtitleOcclusion;
124
+ private configuredFallback;
125
+ private showTransientStatus;
126
+ private hideStatus;
127
+ private layoutCaptions;
128
+ private scheduleCaptionLayout;
129
+ private discardCaption;
130
+ private removeCaption;
131
+ private clearCaptions;
132
+ private scheduleHighlightLayout;
133
+ private bindHighlightScrollTargets;
134
+ private unbindHighlightScrollTargets;
135
+ private renderHighlight;
136
+ private announce;
137
+ private ensureAudioContext;
138
+ private connectOutputAnalyser;
139
+ private startLevelLoop;
140
+ private stopLevelLoop;
141
+ private stopAudio;
142
+ private onVisibilityChange;
143
+ private activeAnalyser;
144
+ private legalLink;
145
+ private launcherLabel;
146
+ private require;
147
+ }
148
+ export {};