@oxvo/ai-live-assist 7.5.21 → 7.5.22

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.
@@ -34,7 +34,7 @@ export declare const normalizeAiGuideOpenInput: (input?: AiGuideOpenInput) => Re
34
34
  export declare const resolveAiGuideProtocolVersion: (bootstrap: Pick<BootstrapConfig, "experienceMode" | "minimumProtocolVersion" | "protocol">) => 1 | 2;
35
35
  export default class AiLiveAssist {
36
36
  private readonly options;
37
- readonly version = "7.5.21";
37
+ readonly version = "7.5.22";
38
38
  private readonly host;
39
39
  private readonly guideAdmission;
40
40
  private readonly standaloneAdmissionPending;
@@ -186,6 +186,9 @@ class RealtimeCommerce {
186
186
  const event = (0, contracts_js_1.parseRealtimeCommerceCatalog)(message.payload, this.bootstrap, this.context.current, undefined, Date.now(), { cartNegotiated: this.options.channel()?.commerceCartNegotiated === true });
187
187
  if (!event || (this.providerGenerationDigest !== null && event.providerGenerationDigest !== this.providerGenerationDigest))
188
188
  return;
189
+ // Initial launches have no separate provider-generation event. The first
190
+ // fenced, current-context catalog supplies its authenticated generation.
191
+ this.providerGenerationDigest ?? (this.providerGenerationDigest = event.providerGenerationDigest);
189
192
  if (this.currentCatalog?.catalog.resultSetId === event.catalog.resultSetId &&
190
193
  this.currentCatalog.executionId === event.executionId && this.currentCatalog.functionCallId === event.functionCallId &&
191
194
  this.currentCatalog.providerGenerationDigest === event.providerGenerationDigest)
package/cjs/context.js CHANGED
@@ -668,14 +668,26 @@ const safeOptionLabel = (option) => {
668
668
  return sensitivityFor(option, label) === 'none' ? label : '';
669
669
  };
670
670
  const isActionTarget = (element) => element.matches('a[href],button,input,select,textarea,summary,form,[contenteditable="true"],[role="button"],[role="link"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"],[tabindex]');
671
- const belongsToInteractiveControl = (element) => {
671
+ const belongsToInteractiveControl = (element, text) => {
672
+ const linkedText = element.closest('a[href],[role="link"]') !== null;
672
673
  for (let current = element; current; current = current.parentElement) {
673
- // Form copy can carry useful public instructions. Only controls and links
674
- // already represented in targets are omitted from visible page text.
674
+ // Public link text belongs in reading order beside surrounding page copy.
675
+ // Inspect the link's descriptors before sanitized names can erase them;
676
+ // neither those attributes nor the destination become semantic text.
677
+ if (current.matches('a[href],[role="link"]')) {
678
+ if (sensitivityFor(current, text) !== 'none' ||
679
+ sensitivityFor(current, normalize(`${current.getAttribute('aria-label') ?? ''} ${current.getAttribute('title') ?? ''}`, 500)) !== 'none' ||
680
+ accessibleNameSourceSensitivity(current) !== 'none')
681
+ return true;
682
+ }
683
+ if (linkedText && current.matches('[role="switch"],[role="option"],[role="slider"],[role="spinbutton"],[role="searchbox"],[role="listbox"],[role="treeitem"],[role="tab"],[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]'))
684
+ return true;
685
+ // Form copy can carry useful public instructions. Actual control text
686
+ // stays in targets, including links nested inside controls.
675
687
  if (current.matches('form'))
676
688
  continue;
677
689
  // A bare tabindex is often a focusable Framer content card, not an action.
678
- if (current.matches('a[href],button,input,select,textarea,summary,[contenteditable="true"],[role="button"],[role="link"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"]'))
690
+ if (current.matches('button,input,select,textarea,summary,[contenteditable="true"],[role="button"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"]'))
679
691
  return true;
680
692
  }
681
693
  return false;
@@ -1254,7 +1266,7 @@ class PageContextCollector {
1254
1266
  !parent.closest('script,style,noscript,template,svg') &&
1255
1267
  !parent.closest('input,select,textarea,option') &&
1256
1268
  (!semanticTextElement || !capturedSemanticText.has(semanticTextElement)) &&
1257
- !belongsToInteractiveControl(textElement) &&
1269
+ !belongsToInteractiveControl(textElement, text) &&
1258
1270
  isRendered(textElement) &&
1259
1271
  sensitivityFor(textElement, nameFor(textElement)) === 'none') {
1260
1272
  const textId = this.textIds.get(node) ?? id('text');
@@ -14,7 +14,7 @@ export declare class GuideAdmission {
14
14
  readonly identity: GuideIdentity;
15
15
  readonly store: GuideSubjectStore;
16
16
  private readonly runtime;
17
- private readonly guideMeasurementBridge?;
17
+ private guideMeasurementBridge?;
18
18
  private initialBootstrap;
19
19
  private currentBootstrap;
20
20
  private activeAdmission;
@@ -35,6 +35,7 @@ export declare class GuideAdmission {
35
35
  pendingIntent(): GuideLaunchIntent | null;
36
36
  measurementIntent(clientVersion: string): GuideMeasurementIntent | undefined;
37
37
  measurementBridge(intent: GuideLaunchIntent): GuideMeasurementBridge | undefined;
38
+ prepareMeasurement(clientVersion: string, signal: AbortSignal): GuideMeasurementBridge | undefined | Promise<GuideMeasurementBridge | undefined>;
38
39
  connectionScope(): GuideConnectionScope;
39
40
  bootstrap(path: string, locale: string, signal: AbortSignal): Promise<BootstrapConfig>;
40
41
  launch(input: GuideLaunchInput, signal: AbortSignal): Promise<LaunchResult>;
@@ -109,6 +109,23 @@ class GuideAdmission {
109
109
  return intent.guideMeasurement?.assignment === this.guideMeasurementBridge?.assignment
110
110
  ? this.guideMeasurementBridge : undefined;
111
111
  }
112
+ prepareMeasurement(clientVersion, signal) {
113
+ if (clientVersion !== guideMeasurement_js_1.GUIDE_MEASUREMENT_CLIENT_VERSION ||
114
+ this.currentBootstrap.capabilities?.guideMeasurementV1 !== true)
115
+ return undefined;
116
+ const existing = this.guideMeasurementBridge;
117
+ const renew = existing?.renew;
118
+ // Keep current and unmeasured admissions on their existing synchronous path.
119
+ if ((0, guideMeasurement_js_1.currentGuideMeasurementBridge)(existing))
120
+ return existing;
121
+ if (typeof renew !== 'function')
122
+ return undefined;
123
+ return (0, guideMeasurement_js_1.prepareGuideMeasurementBridge)(existing, signal).then(bridge => {
124
+ if (bridge)
125
+ this.guideMeasurementBridge = bridge;
126
+ return bridge;
127
+ });
128
+ }
112
129
  connectionScope() {
113
130
  let subjectId = this.subjectId();
114
131
  return {
@@ -173,10 +190,11 @@ class GuideAdmission {
173
190
  if (!this.currentBootstrap.available ||
174
191
  this.currentBootstrap.configRevision !== input.configRevision)
175
192
  throw invalid();
193
+ const measurement = this.prepareMeasurement(intent.clientVersion, signal);
194
+ const measurementBridge = measurement instanceof Promise ? await measurement : measurement;
176
195
  const subject = this.store.readSubject();
177
- const measurement = this.measurementIntent(intent.clientVersion);
178
- if (measurement)
179
- intent.guideMeasurement = measurement;
196
+ if (measurementBridge)
197
+ intent.guideMeasurement = { schemaVersion: 1, assignment: measurementBridge.assignment };
180
198
  this.admissionRequestId = intent.launchRequestId;
181
199
  const admission = this.runtime.admitGuide(intent, subject?.credential, signal);
182
200
  this.activeAdmission = admission;
@@ -220,7 +238,7 @@ class GuideAdmission {
220
238
  }
221
239
  if (signal.aborted)
222
240
  throw new DOMException("The operation was aborted.", "AbortError");
223
- const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal, ...(intent.guideMeasurement ? [this.measurementBridge(intent)] : []));
241
+ const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal, ...(intent.guideMeasurement ? [measurementBridge] : []));
224
242
  this.validateLaunch(launched, intent.launchRequestId, result.subjectId);
225
243
  return launched;
226
244
  }
@@ -1,5 +1,7 @@
1
1
  import type { GuideMeasurementBridge, GuideMeasurementIntent } from './guideTypes.js';
2
- export declare const GUIDE_MEASUREMENT_CLIENT_VERSION = "7.5.21";
2
+ export declare const GUIDE_MEASUREMENT_CLIENT_VERSION = "7.5.22";
3
3
  export declare function isGuideMeasurementIntent(value: unknown): value is GuideMeasurementIntent;
4
4
  /** The managed analytics owner supplies possession; this check grants no authority. */
5
5
  export declare function currentGuideMeasurementBridge(value: unknown): value is GuideMeasurementBridge;
6
+ /** Only new conversations renew. An admitted launch keeps its original intent. */
7
+ export declare function prepareGuideMeasurementBridge(bridge: GuideMeasurementBridge | undefined, signal: AbortSignal): Promise<GuideMeasurementBridge | undefined>;
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GUIDE_MEASUREMENT_CLIENT_VERSION = void 0;
4
4
  exports.isGuideMeasurementIntent = isGuideMeasurementIntent;
5
5
  exports.currentGuideMeasurementBridge = currentGuideMeasurementBridge;
6
- exports.GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.21';
6
+ exports.prepareGuideMeasurementBridge = prepareGuideMeasurementBridge;
7
+ exports.GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.22';
7
8
  function isGuideMeasurementIntent(value) {
8
9
  if (!value || typeof value !== 'object' || Array.isArray(value))
9
10
  return false;
@@ -27,3 +28,32 @@ function currentGuideMeasurementBridge(value) {
27
28
  return false;
28
29
  }
29
30
  }
31
+ /** Only new conversations renew. An admitted launch keeps its original intent. */
32
+ async function prepareGuideMeasurementBridge(bridge, signal) {
33
+ const aborted = () => new DOMException('The operation was aborted.', 'AbortError');
34
+ if (signal.aborted)
35
+ throw aborted();
36
+ const renew = bridge?.renew;
37
+ if (currentGuideMeasurementBridge(bridge))
38
+ return bridge;
39
+ if (typeof renew !== 'function')
40
+ return undefined;
41
+ const controller = new AbortController();
42
+ const abort = () => controller.abort();
43
+ signal.addEventListener('abort', abort, { once: true });
44
+ const timer = setTimeout(abort, 10000);
45
+ try {
46
+ const renewed = await new Promise(resolve => {
47
+ controller.signal.addEventListener('abort', () => resolve(undefined), { once: true });
48
+ Promise.resolve().then(() => controller.signal.aborted ? undefined : renew.call(bridge, controller.signal))
49
+ .then(resolve, () => resolve(undefined));
50
+ });
51
+ if (signal.aborted)
52
+ throw aborted();
53
+ return currentGuideMeasurementBridge(renewed) ? renewed : undefined;
54
+ }
55
+ finally {
56
+ clearTimeout(timer);
57
+ signal.removeEventListener('abort', abort);
58
+ }
59
+ }
@@ -49,6 +49,7 @@ export type GuideMeasurementBridge = {
49
49
  assignment: string;
50
50
  expiresAt: number;
51
51
  current(): boolean;
52
+ renew?(signal?: AbortSignal): Promise<GuideMeasurementBridge | undefined>;
52
53
  authorizeLaunch(url: string, rawBody: string, signal?: AbortSignal): Promise<{
53
54
  headers: Record<string, string>;
54
55
  current(): boolean;
@@ -1,6 +1,6 @@
1
1
  import { type LiveDuplexMediaOptions, type LiveDuplexMediaDependencies } from './liveDuplexMedia.js';
2
2
  import { type CommerceBootstrap, type CommerceContext, type CommerceCartSelection, type CommerceProduct, type CommerceContextClear, type LiveCommerceCatalog, type LiveCommerceDisplayed } from './commerce/contracts.js';
3
- export declare const LIVE_CONTROL_CLIENT_VERSION = "7.5.21";
3
+ export declare const LIVE_CONTROL_CLIENT_VERSION = "7.5.22";
4
4
  export declare const LIVE_CONTROL_CLIENT_CAPABILITIES: readonly ["live_duplex_v1", "live_local_wake_v1", "live_fragment_captions_v1"];
5
5
  declare const phases: readonly ["voice_off", "local_listening", "wake_buffering", "starting", "active", "tentative_idle", "closing", "uncertain", "muted", "suspended", "budget_blocked", "ended"];
6
6
  export type LiveControlState = {
@@ -14,7 +14,7 @@ export declare class LiveGuideAdmission {
14
14
  private readonly runtime;
15
15
  private readonly legacy?;
16
16
  private pendingAdmission;
17
- constructor(identity: GuideIdentity, store: GuideSubjectStore, runtime: RuntimeClient, legacy?: (Pick<GuideAdmission, "endLaunch" | "complete"> & Partial<Pick<GuideAdmission, "measurementIntent" | "measurementBridge">>) | undefined);
17
+ constructor(identity: GuideIdentity, store: GuideSubjectStore, runtime: RuntimeClient, legacy?: (Pick<GuideAdmission, "endLaunch" | "complete"> & Partial<Pick<GuideAdmission, "measurementIntent" | "measurementBridge" | "prepareMeasurement">>) | undefined);
18
18
  hasPendingLaunch(): boolean;
19
19
  pendingLaunchId(): string | null;
20
20
  launch(intent: LiveGuideLaunchIntent, signal: AbortSignal): Promise<LiveControlAuthorization>;
@@ -19,7 +19,11 @@ class LiveGuideAdmission {
19
19
  async launch(intent, signal) {
20
20
  if (intent.installKey !== this.identity.installKey || this.store.readLaunch())
21
21
  throw unavailable();
22
- const measurement = this.legacy?.measurementIntent?.(intent.clientVersion);
22
+ const preparation = this.legacy?.prepareMeasurement?.(intent.clientVersion, signal);
23
+ const bridge = preparation instanceof Promise ? await preparation : preparation;
24
+ const measurement = this.legacy?.prepareMeasurement
25
+ ? (bridge ? { schemaVersion: 1, assignment: bridge.assignment } : undefined)
26
+ : this.legacy?.measurementIntent?.(intent.clientVersion);
23
27
  if (measurement)
24
28
  intent = { ...intent, guideMeasurement: measurement };
25
29
  const subject = this.store.readSubject();
@@ -56,7 +60,7 @@ class LiveGuideAdmission {
56
60
  }
57
61
  if (signal.aborted)
58
62
  throw unavailable();
59
- const launch = await this.runtime.launchLiveGuide(intent, grant, signal, ...(intent.guideMeasurement ? [this.legacy?.measurementBridge?.(intent)] : []));
63
+ const launch = await this.runtime.launchLiveGuide(intent, grant, signal, ...(intent.guideMeasurement ? [bridge ?? this.legacy?.measurementBridge?.(intent)] : []));
60
64
  if (launch.projectId !== this.identity.projectId || launch.guideId !== this.identity.guideId ||
61
65
  launch.subjectId !== subjectId || launch.launchRequestId !== intent.launchRequestId)
62
66
  throw unavailable();
package/cjs/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "7.5.21";
1
+ export declare const VERSION = "7.5.22";
package/cjs/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '7.5.21';
4
+ exports.VERSION = '7.5.22';
@@ -34,7 +34,7 @@ export declare const normalizeAiGuideOpenInput: (input?: AiGuideOpenInput) => Re
34
34
  export declare const resolveAiGuideProtocolVersion: (bootstrap: Pick<BootstrapConfig, "experienceMode" | "minimumProtocolVersion" | "protocol">) => 1 | 2;
35
35
  export default class AiLiveAssist {
36
36
  private readonly options;
37
- readonly version = "7.5.21";
37
+ readonly version = "7.5.22";
38
38
  private readonly host;
39
39
  private readonly guideAdmission;
40
40
  private readonly standaloneAdmissionPending;
@@ -182,6 +182,9 @@ export class RealtimeCommerce {
182
182
  const event = parseRealtimeCommerceCatalog(message.payload, this.bootstrap, this.context.current, undefined, Date.now(), { cartNegotiated: this.options.channel()?.commerceCartNegotiated === true });
183
183
  if (!event || (this.providerGenerationDigest !== null && event.providerGenerationDigest !== this.providerGenerationDigest))
184
184
  return;
185
+ // Initial launches have no separate provider-generation event. The first
186
+ // fenced, current-context catalog supplies its authenticated generation.
187
+ this.providerGenerationDigest ?? (this.providerGenerationDigest = event.providerGenerationDigest);
185
188
  if (this.currentCatalog?.catalog.resultSetId === event.catalog.resultSetId &&
186
189
  this.currentCatalog.executionId === event.executionId && this.currentCatalog.functionCallId === event.functionCallId &&
187
190
  this.currentCatalog.providerGenerationDigest === event.providerGenerationDigest)
package/lib/context.js CHANGED
@@ -664,14 +664,26 @@ const safeOptionLabel = (option) => {
664
664
  return sensitivityFor(option, label) === 'none' ? label : '';
665
665
  };
666
666
  const isActionTarget = (element) => element.matches('a[href],button,input,select,textarea,summary,form,[contenteditable="true"],[role="button"],[role="link"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"],[tabindex]');
667
- const belongsToInteractiveControl = (element) => {
667
+ const belongsToInteractiveControl = (element, text) => {
668
+ const linkedText = element.closest('a[href],[role="link"]') !== null;
668
669
  for (let current = element; current; current = current.parentElement) {
669
- // Form copy can carry useful public instructions. Only controls and links
670
- // already represented in targets are omitted from visible page text.
670
+ // Public link text belongs in reading order beside surrounding page copy.
671
+ // Inspect the link's descriptors before sanitized names can erase them;
672
+ // neither those attributes nor the destination become semantic text.
673
+ if (current.matches('a[href],[role="link"]')) {
674
+ if (sensitivityFor(current, text) !== 'none' ||
675
+ sensitivityFor(current, normalize(`${current.getAttribute('aria-label') ?? ''} ${current.getAttribute('title') ?? ''}`, 500)) !== 'none' ||
676
+ accessibleNameSourceSensitivity(current) !== 'none')
677
+ return true;
678
+ }
679
+ if (linkedText && current.matches('[role="switch"],[role="option"],[role="slider"],[role="spinbutton"],[role="searchbox"],[role="listbox"],[role="treeitem"],[role="tab"],[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]'))
680
+ return true;
681
+ // Form copy can carry useful public instructions. Actual control text
682
+ // stays in targets, including links nested inside controls.
671
683
  if (current.matches('form'))
672
684
  continue;
673
685
  // A bare tabindex is often a focusable Framer content card, not an action.
674
- if (current.matches('a[href],button,input,select,textarea,summary,[contenteditable="true"],[role="button"],[role="link"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"]'))
686
+ if (current.matches('button,input,select,textarea,summary,[contenteditable="true"],[role="button"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"]'))
675
687
  return true;
676
688
  }
677
689
  return false;
@@ -1250,7 +1262,7 @@ export class PageContextCollector {
1250
1262
  !parent.closest('script,style,noscript,template,svg') &&
1251
1263
  !parent.closest('input,select,textarea,option') &&
1252
1264
  (!semanticTextElement || !capturedSemanticText.has(semanticTextElement)) &&
1253
- !belongsToInteractiveControl(textElement) &&
1265
+ !belongsToInteractiveControl(textElement, text) &&
1254
1266
  isRendered(textElement) &&
1255
1267
  sensitivityFor(textElement, nameFor(textElement)) === 'none') {
1256
1268
  const textId = this.textIds.get(node) ?? id('text');
@@ -14,7 +14,7 @@ export declare class GuideAdmission {
14
14
  readonly identity: GuideIdentity;
15
15
  readonly store: GuideSubjectStore;
16
16
  private readonly runtime;
17
- private readonly guideMeasurementBridge?;
17
+ private guideMeasurementBridge?;
18
18
  private initialBootstrap;
19
19
  private currentBootstrap;
20
20
  private activeAdmission;
@@ -35,6 +35,7 @@ export declare class GuideAdmission {
35
35
  pendingIntent(): GuideLaunchIntent | null;
36
36
  measurementIntent(clientVersion: string): GuideMeasurementIntent | undefined;
37
37
  measurementBridge(intent: GuideLaunchIntent): GuideMeasurementBridge | undefined;
38
+ prepareMeasurement(clientVersion: string, signal: AbortSignal): GuideMeasurementBridge | undefined | Promise<GuideMeasurementBridge | undefined>;
38
39
  connectionScope(): GuideConnectionScope;
39
40
  bootstrap(path: string, locale: string, signal: AbortSignal): Promise<BootstrapConfig>;
40
41
  launch(input: GuideLaunchInput, signal: AbortSignal): Promise<LaunchResult>;
@@ -1,6 +1,6 @@
1
1
  import { RuntimeClientError, } from "./client.js";
2
2
  import { GUIDE_SUBJECT_CREDENTIAL_PATTERN, GUIDE_UUID_PATTERN, guideLaunchRequestId, } from "./guideTypes.js";
3
- import { currentGuideMeasurementBridge, GUIDE_MEASUREMENT_CLIENT_VERSION } from './guideMeasurement.js';
3
+ import { currentGuideMeasurementBridge, prepareGuideMeasurementBridge, GUIDE_MEASUREMENT_CLIENT_VERSION } from './guideMeasurement.js';
4
4
  import { VERSION } from "./version.js";
5
5
  import { GuideRecordingSession, } from "./guideRecordingSession.js";
6
6
  const invalid = () => new RuntimeClientError("PROTOCOL_INVALID", "The AI Guide runtime returned an invalid session identity.", false, null, 502);
@@ -105,6 +105,23 @@ export class GuideAdmission {
105
105
  return intent.guideMeasurement?.assignment === this.guideMeasurementBridge?.assignment
106
106
  ? this.guideMeasurementBridge : undefined;
107
107
  }
108
+ prepareMeasurement(clientVersion, signal) {
109
+ if (clientVersion !== GUIDE_MEASUREMENT_CLIENT_VERSION ||
110
+ this.currentBootstrap.capabilities?.guideMeasurementV1 !== true)
111
+ return undefined;
112
+ const existing = this.guideMeasurementBridge;
113
+ const renew = existing?.renew;
114
+ // Keep current and unmeasured admissions on their existing synchronous path.
115
+ if (currentGuideMeasurementBridge(existing))
116
+ return existing;
117
+ if (typeof renew !== 'function')
118
+ return undefined;
119
+ return prepareGuideMeasurementBridge(existing, signal).then(bridge => {
120
+ if (bridge)
121
+ this.guideMeasurementBridge = bridge;
122
+ return bridge;
123
+ });
124
+ }
108
125
  connectionScope() {
109
126
  let subjectId = this.subjectId();
110
127
  return {
@@ -169,10 +186,11 @@ export class GuideAdmission {
169
186
  if (!this.currentBootstrap.available ||
170
187
  this.currentBootstrap.configRevision !== input.configRevision)
171
188
  throw invalid();
189
+ const measurement = this.prepareMeasurement(intent.clientVersion, signal);
190
+ const measurementBridge = measurement instanceof Promise ? await measurement : measurement;
172
191
  const subject = this.store.readSubject();
173
- const measurement = this.measurementIntent(intent.clientVersion);
174
- if (measurement)
175
- intent.guideMeasurement = measurement;
192
+ if (measurementBridge)
193
+ intent.guideMeasurement = { schemaVersion: 1, assignment: measurementBridge.assignment };
176
194
  this.admissionRequestId = intent.launchRequestId;
177
195
  const admission = this.runtime.admitGuide(intent, subject?.credential, signal);
178
196
  this.activeAdmission = admission;
@@ -216,7 +234,7 @@ export class GuideAdmission {
216
234
  }
217
235
  if (signal.aborted)
218
236
  throw new DOMException("The operation was aborted.", "AbortError");
219
- const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal, ...(intent.guideMeasurement ? [this.measurementBridge(intent)] : []));
237
+ const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal, ...(intent.guideMeasurement ? [measurementBridge] : []));
220
238
  this.validateLaunch(launched, intent.launchRequestId, result.subjectId);
221
239
  return launched;
222
240
  }
@@ -1,5 +1,7 @@
1
1
  import type { GuideMeasurementBridge, GuideMeasurementIntent } from './guideTypes.js';
2
- export declare const GUIDE_MEASUREMENT_CLIENT_VERSION = "7.5.21";
2
+ export declare const GUIDE_MEASUREMENT_CLIENT_VERSION = "7.5.22";
3
3
  export declare function isGuideMeasurementIntent(value: unknown): value is GuideMeasurementIntent;
4
4
  /** The managed analytics owner supplies possession; this check grants no authority. */
5
5
  export declare function currentGuideMeasurementBridge(value: unknown): value is GuideMeasurementBridge;
6
+ /** Only new conversations renew. An admitted launch keeps its original intent. */
7
+ export declare function prepareGuideMeasurementBridge(bridge: GuideMeasurementBridge | undefined, signal: AbortSignal): Promise<GuideMeasurementBridge | undefined>;
@@ -1,4 +1,4 @@
1
- export const GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.21';
1
+ export const GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.22';
2
2
  export function isGuideMeasurementIntent(value) {
3
3
  if (!value || typeof value !== 'object' || Array.isArray(value))
4
4
  return false;
@@ -22,3 +22,32 @@ export function currentGuideMeasurementBridge(value) {
22
22
  return false;
23
23
  }
24
24
  }
25
+ /** Only new conversations renew. An admitted launch keeps its original intent. */
26
+ export async function prepareGuideMeasurementBridge(bridge, signal) {
27
+ const aborted = () => new DOMException('The operation was aborted.', 'AbortError');
28
+ if (signal.aborted)
29
+ throw aborted();
30
+ const renew = bridge?.renew;
31
+ if (currentGuideMeasurementBridge(bridge))
32
+ return bridge;
33
+ if (typeof renew !== 'function')
34
+ return undefined;
35
+ const controller = new AbortController();
36
+ const abort = () => controller.abort();
37
+ signal.addEventListener('abort', abort, { once: true });
38
+ const timer = setTimeout(abort, 10000);
39
+ try {
40
+ const renewed = await new Promise(resolve => {
41
+ controller.signal.addEventListener('abort', () => resolve(undefined), { once: true });
42
+ Promise.resolve().then(() => controller.signal.aborted ? undefined : renew.call(bridge, controller.signal))
43
+ .then(resolve, () => resolve(undefined));
44
+ });
45
+ if (signal.aborted)
46
+ throw aborted();
47
+ return currentGuideMeasurementBridge(renewed) ? renewed : undefined;
48
+ }
49
+ finally {
50
+ clearTimeout(timer);
51
+ signal.removeEventListener('abort', abort);
52
+ }
53
+ }
@@ -49,6 +49,7 @@ export type GuideMeasurementBridge = {
49
49
  assignment: string;
50
50
  expiresAt: number;
51
51
  current(): boolean;
52
+ renew?(signal?: AbortSignal): Promise<GuideMeasurementBridge | undefined>;
52
53
  authorizeLaunch(url: string, rawBody: string, signal?: AbortSignal): Promise<{
53
54
  headers: Record<string, string>;
54
55
  current(): boolean;
@@ -1,6 +1,6 @@
1
1
  import { type LiveDuplexMediaOptions, type LiveDuplexMediaDependencies } from './liveDuplexMedia.js';
2
2
  import { type CommerceBootstrap, type CommerceContext, type CommerceCartSelection, type CommerceProduct, type CommerceContextClear, type LiveCommerceCatalog, type LiveCommerceDisplayed } from './commerce/contracts.js';
3
- export declare const LIVE_CONTROL_CLIENT_VERSION = "7.5.21";
3
+ export declare const LIVE_CONTROL_CLIENT_VERSION = "7.5.22";
4
4
  export declare const LIVE_CONTROL_CLIENT_CAPABILITIES: readonly ["live_duplex_v1", "live_local_wake_v1", "live_fragment_captions_v1"];
5
5
  declare const phases: readonly ["voice_off", "local_listening", "wake_buffering", "starting", "active", "tentative_idle", "closing", "uncertain", "muted", "suspended", "budget_blocked", "ended"];
6
6
  export type LiveControlState = {
@@ -14,7 +14,7 @@ export declare class LiveGuideAdmission {
14
14
  private readonly runtime;
15
15
  private readonly legacy?;
16
16
  private pendingAdmission;
17
- constructor(identity: GuideIdentity, store: GuideSubjectStore, runtime: RuntimeClient, legacy?: (Pick<GuideAdmission, "endLaunch" | "complete"> & Partial<Pick<GuideAdmission, "measurementIntent" | "measurementBridge">>) | undefined);
17
+ constructor(identity: GuideIdentity, store: GuideSubjectStore, runtime: RuntimeClient, legacy?: (Pick<GuideAdmission, "endLaunch" | "complete"> & Partial<Pick<GuideAdmission, "measurementIntent" | "measurementBridge" | "prepareMeasurement">>) | undefined);
18
18
  hasPendingLaunch(): boolean;
19
19
  pendingLaunchId(): string | null;
20
20
  launch(intent: LiveGuideLaunchIntent, signal: AbortSignal): Promise<LiveControlAuthorization>;
@@ -16,7 +16,11 @@ export class LiveGuideAdmission {
16
16
  async launch(intent, signal) {
17
17
  if (intent.installKey !== this.identity.installKey || this.store.readLaunch())
18
18
  throw unavailable();
19
- const measurement = this.legacy?.measurementIntent?.(intent.clientVersion);
19
+ const preparation = this.legacy?.prepareMeasurement?.(intent.clientVersion, signal);
20
+ const bridge = preparation instanceof Promise ? await preparation : preparation;
21
+ const measurement = this.legacy?.prepareMeasurement
22
+ ? (bridge ? { schemaVersion: 1, assignment: bridge.assignment } : undefined)
23
+ : this.legacy?.measurementIntent?.(intent.clientVersion);
20
24
  if (measurement)
21
25
  intent = { ...intent, guideMeasurement: measurement };
22
26
  const subject = this.store.readSubject();
@@ -53,7 +57,7 @@ export class LiveGuideAdmission {
53
57
  }
54
58
  if (signal.aborted)
55
59
  throw unavailable();
56
- const launch = await this.runtime.launchLiveGuide(intent, grant, signal, ...(intent.guideMeasurement ? [this.legacy?.measurementBridge?.(intent)] : []));
60
+ const launch = await this.runtime.launchLiveGuide(intent, grant, signal, ...(intent.guideMeasurement ? [bridge ?? this.legacy?.measurementBridge?.(intent)] : []));
57
61
  if (launch.projectId !== this.identity.projectId || launch.guideId !== this.identity.guideId ||
58
62
  launch.subjectId !== subjectId || launch.launchRequestId !== intent.launchRequestId)
59
63
  throw unavailable();
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "7.5.21";
1
+ export declare const VERSION = "7.5.22";
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '7.5.21';
1
+ export const VERSION = '7.5.22';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oxvo/ai-live-assist",
3
3
  "description": "Secure AI Guide browser plugin for OXVO Sessions.",
4
- "version": "7.5.21",
4
+ "version": "7.5.22",
5
5
  "keywords": [
6
6
  "ai-live-assist",
7
7
  "webrtc",