@oxvo/ai-live-assist 7.5.20 → 7.5.21

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 (99) hide show
  1. package/cjs/AiLiveAssist.d.ts +8 -1
  2. package/cjs/AiLiveAssist.js +113 -8
  3. package/cjs/client.d.ts +5 -3
  4. package/cjs/client.js +44 -5
  5. package/cjs/commerce/cartContracts.d.ts +158 -0
  6. package/cjs/commerce/cartContracts.js +228 -0
  7. package/cjs/commerce/cartSession.d.ts +86 -0
  8. package/cjs/commerce/cartSession.js +475 -0
  9. package/cjs/commerce/contracts.d.ts +152 -0
  10. package/cjs/commerce/contracts.js +322 -0
  11. package/cjs/commerce/pageContext.d.ts +50 -0
  12. package/cjs/commerce/pageContext.js +173 -0
  13. package/cjs/commerce/productPanel.d.ts +65 -0
  14. package/cjs/commerce/productPanel.js +662 -0
  15. package/cjs/commerce/realtimeCommerce.d.ts +73 -0
  16. package/cjs/commerce/realtimeCommerce.js +342 -0
  17. package/cjs/commerce/shopifyCart.d.ts +130 -0
  18. package/cjs/commerce/shopifyCart.js +1135 -0
  19. package/cjs/commerce/shopifyCartPresentation.d.ts +12 -0
  20. package/cjs/commerce/shopifyCartPresentation.js +379 -0
  21. package/cjs/commerce/shoppingNotes.d.ts +61 -0
  22. package/cjs/commerce/shoppingNotes.js +313 -0
  23. package/cjs/commerce/shoppingNotesView.d.ts +46 -0
  24. package/cjs/commerce/shoppingNotesView.js +269 -0
  25. package/cjs/control.d.ts +9 -1
  26. package/cjs/control.js +51 -1
  27. package/cjs/guideAdmission.d.ts +5 -2
  28. package/cjs/guideAdmission.js +21 -2
  29. package/cjs/guideInstaller.js +1 -1
  30. package/cjs/guideMeasurement.d.ts +5 -0
  31. package/cjs/guideMeasurement.js +29 -0
  32. package/cjs/guideSubjectStore.js +2 -0
  33. package/cjs/guideTypes.d.ts +18 -0
  34. package/cjs/liveControlChannel.d.ts +43 -1
  35. package/cjs/liveControlChannel.js +166 -14
  36. package/cjs/liveGuideAdmission.d.ts +3 -2
  37. package/cjs/liveGuideAdmission.js +10 -2
  38. package/cjs/liveGuideWidget.d.ts +18 -0
  39. package/cjs/liveGuideWidget.js +228 -23
  40. package/cjs/locales/resources.js +2240 -0
  41. package/cjs/messages.js +56 -0
  42. package/cjs/tabLock.d.ts +2 -0
  43. package/cjs/tabLock.js +11 -1
  44. package/cjs/types.d.ts +6 -2
  45. package/cjs/types.js +56 -0
  46. package/cjs/ui.d.ts +37 -0
  47. package/cjs/ui.js +259 -9
  48. package/cjs/version.d.ts +1 -1
  49. package/cjs/version.js +1 -1
  50. package/lib/AiLiveAssist.d.ts +8 -1
  51. package/lib/AiLiveAssist.js +113 -8
  52. package/lib/client.d.ts +5 -3
  53. package/lib/client.js +44 -5
  54. package/lib/commerce/cartContracts.d.ts +158 -0
  55. package/lib/commerce/cartContracts.js +221 -0
  56. package/lib/commerce/cartSession.d.ts +86 -0
  57. package/lib/commerce/cartSession.js +471 -0
  58. package/lib/commerce/contracts.d.ts +152 -0
  59. package/lib/commerce/contracts.js +300 -0
  60. package/lib/commerce/pageContext.d.ts +50 -0
  61. package/lib/commerce/pageContext.js +168 -0
  62. package/lib/commerce/productPanel.d.ts +65 -0
  63. package/lib/commerce/productPanel.js +657 -0
  64. package/lib/commerce/realtimeCommerce.d.ts +73 -0
  65. package/lib/commerce/realtimeCommerce.js +337 -0
  66. package/lib/commerce/shopifyCart.d.ts +130 -0
  67. package/lib/commerce/shopifyCart.js +1130 -0
  68. package/lib/commerce/shopifyCartPresentation.d.ts +12 -0
  69. package/lib/commerce/shopifyCartPresentation.js +376 -0
  70. package/lib/commerce/shoppingNotes.d.ts +61 -0
  71. package/lib/commerce/shoppingNotes.js +307 -0
  72. package/lib/commerce/shoppingNotesView.d.ts +46 -0
  73. package/lib/commerce/shoppingNotesView.js +265 -0
  74. package/lib/control.d.ts +9 -1
  75. package/lib/control.js +51 -1
  76. package/lib/guideAdmission.d.ts +5 -2
  77. package/lib/guideAdmission.js +21 -2
  78. package/lib/guideInstaller.js +1 -1
  79. package/lib/guideMeasurement.d.ts +5 -0
  80. package/lib/guideMeasurement.js +24 -0
  81. package/lib/guideSubjectStore.js +2 -0
  82. package/lib/guideTypes.d.ts +18 -0
  83. package/lib/liveControlChannel.d.ts +43 -1
  84. package/lib/liveControlChannel.js +166 -14
  85. package/lib/liveGuideAdmission.d.ts +3 -2
  86. package/lib/liveGuideAdmission.js +10 -2
  87. package/lib/liveGuideWidget.d.ts +18 -0
  88. package/lib/liveGuideWidget.js +228 -23
  89. package/lib/locales/resources.js +2240 -0
  90. package/lib/messages.js +56 -0
  91. package/lib/tabLock.d.ts +2 -0
  92. package/lib/tabLock.js +11 -1
  93. package/lib/types.d.ts +6 -2
  94. package/lib/types.js +56 -0
  95. package/lib/ui.d.ts +37 -0
  96. package/lib/ui.js +259 -9
  97. package/lib/version.d.ts +1 -1
  98. package/lib/version.js +1 -1
  99. package/package.json +1 -1
package/cjs/control.js CHANGED
@@ -13,6 +13,13 @@ const MAX_SETTLED_OPERATION_HISTORY = 100;
13
13
  const CLIENT_MESSAGE_ID_PATTERN = /^[A-Za-z0-9_.:-]{8,128}$/;
14
14
  const STATEFUL_CONTROL_TYPES = new Set([
15
15
  "cta.result",
16
+ "commerce.context",
17
+ "commerce.context.clear",
18
+ "commerce.catalog.displayed",
19
+ "commerce.cart.request",
20
+ "commerce.cart.confirmation.result",
21
+ "commerce.cart.execution.begin",
22
+ "commerce.cart.execution.result",
16
23
  "text.message",
17
24
  "confirmation.result",
18
25
  "consent.update",
@@ -39,7 +46,7 @@ const STATEFUL_CONTROL_TYPES = new Set([
39
46
  ]);
40
47
  const outcomeKey = (messageId, sequence) => `${messageId}\u0000${sequence}`;
41
48
  class ControlChannel {
42
- constructor(result, tabId, clientVersion, onDisconnect, initialClientSequence = 0, onClientSequence = () => undefined, onUnsafeDisconnect = () => undefined, transportRecovery) {
49
+ constructor(result, tabId, clientVersion, onDisconnect, initialClientSequence = 0, onClientSequence = () => undefined, onUnsafeDisconnect = () => undefined, transportRecovery, commerceVersion, commerceCartEnabled = false) {
43
50
  this.result = result;
44
51
  this.tabId = tabId;
45
52
  this.clientVersion = clientVersion;
@@ -47,6 +54,8 @@ class ControlChannel {
47
54
  this.onClientSequence = onClientSequence;
48
55
  this.onUnsafeDisconnect = onUnsafeDisconnect;
49
56
  this.transportRecovery = transportRecovery;
57
+ this.commerceVersion = commerceVersion;
58
+ this.commerceCartEnabled = commerceCartEnabled;
50
59
  this.socket = null;
51
60
  this.serverSequence = 0;
52
61
  this.serverBaselineEstablished = false;
@@ -69,6 +78,8 @@ class ControlChannel {
69
78
  this.pendingConnection = null;
70
79
  this.helloOperation = null;
71
80
  this.fencedAuthorityConfirmed = false;
81
+ this.commerceNegotiated = false;
82
+ this.cartNegotiated = false;
72
83
  this.transportRecoveryAttempted = false;
73
84
  this.recoveringTransport = false;
74
85
  this.clientSequence =
@@ -79,6 +90,15 @@ class ControlChannel {
79
90
  get leaseToken() {
80
91
  return this.fencingToken;
81
92
  }
93
+ get sessionId() {
94
+ return this.result.sessionId;
95
+ }
96
+ get negotiatedCommerceVersion() {
97
+ return this.commerceNegotiated ? 1 : undefined;
98
+ }
99
+ get commerceCartNegotiated() {
100
+ return this.commerceNegotiated && this.cartNegotiated;
101
+ }
82
102
  get lastClientSequence() {
83
103
  return this.clientSequence;
84
104
  }
@@ -126,6 +146,8 @@ class ControlChannel {
126
146
  this.sequenceGapDetected = false;
127
147
  this.recoveryDisconnectNotified = false;
128
148
  this.helloOperation = null;
149
+ this.commerceNegotiated = false;
150
+ this.cartNegotiated = false;
129
151
  this.fencedAuthorityConfirmed = false;
130
152
  this.handlerTail = null;
131
153
  this.pendingHandlerMessages = 0;
@@ -157,6 +179,8 @@ class ControlChannel {
157
179
  protocolMax: this.result.protocolVersion,
158
180
  clientVersion: this.clientVersion,
159
181
  ctaOffer: true,
182
+ ...(this.commerceVersion === 1 ? { commerceVersion: 1 } : {}),
183
+ ...(this.commerceVersion === 1 && this.commerceCartEnabled ? { commerceCartVersion: 1 } : {}),
160
184
  resume,
161
185
  });
162
186
  this.helloOperation = {
@@ -205,6 +229,8 @@ class ControlChannel {
205
229
  this.outboundOperations.clear();
206
230
  this.latestOutboundSequence.clear();
207
231
  this.helloOperation = null;
232
+ this.commerceNegotiated = false;
233
+ this.cartNegotiated = false;
208
234
  this.fencedAuthorityConfirmed = false;
209
235
  this.handlerTail = null;
210
236
  this.pendingHandlerMessages = 0;
@@ -225,6 +251,7 @@ class ControlChannel {
225
251
  });
226
252
  }
227
253
  send(type, payload, stableMessageId) {
254
+ this.requireCommerceCartNegotiation(type);
228
255
  if (this.recoveringTransport && type !== "hello" && type !== "heartbeat") {
229
256
  throw new Error("The AI Guide control channel is reconnecting.");
230
257
  }
@@ -250,6 +277,7 @@ class ControlChannel {
250
277
  return messageId;
251
278
  }
252
279
  reserveOperationIdentity(type, stableMessageId) {
280
+ this.requireCommerceCartNegotiation(type);
253
281
  const messageId = stableMessageId ?? `msg_${crypto.randomUUID()}`;
254
282
  if (!CLIENT_MESSAGE_ID_PATTERN.test(messageId)) {
255
283
  throw new Error("Invalid AI Guide control message ID.");
@@ -266,6 +294,7 @@ class ControlChannel {
266
294
  };
267
295
  }
268
296
  sendReserved(operation, payload) {
297
+ this.requireCommerceCartNegotiation(operation.type);
269
298
  const socket = this.socket;
270
299
  const socketGeneration = this.socketGeneration;
271
300
  if (!socket || socket.readyState !== WebSocket.OPEN) {
@@ -443,6 +472,8 @@ class ControlChannel {
443
472
  this.outboundOperations.clear();
444
473
  this.latestOutboundSequence.clear();
445
474
  this.helloOperation = null;
475
+ this.commerceNegotiated = false;
476
+ this.cartNegotiated = false;
446
477
  this.fencedAuthorityConfirmed = false;
447
478
  this.unsettledStatefulOperations.clear();
448
479
  }
@@ -517,10 +548,25 @@ class ControlChannel {
517
548
  : null,
518
549
  });
519
550
  }
551
+ if (message.type === "control.ready" &&
552
+ message.payload.helloMessageId === this.helloOperation?.messageId &&
553
+ this.helloOperation !== null) {
554
+ this.commerceNegotiated =
555
+ this.commerceVersion === 1 && message.payload.commerceVersion === 1;
556
+ this.cartNegotiated = this.commerceNegotiated && this.commerceCartEnabled &&
557
+ message.payload.commerceCartVersion === 1;
558
+ }
559
+ if (message.type.startsWith("commerce.cart.") && !this.commerceCartNegotiated)
560
+ return;
520
561
  if (!this.dispatchIngressHandlers(message, socket, generation))
521
562
  return;
522
563
  return this.enqueueHandlers(message, socket, generation);
523
564
  }
565
+ requireCommerceCartNegotiation(type) {
566
+ if (type.startsWith("commerce.cart.") && !this.commerceCartNegotiated) {
567
+ throw new Error("Shopping cart actions were not negotiated for this connection.");
568
+ }
569
+ }
524
570
  recoverFromSequenceGap(socket, generation) {
525
571
  if (this.sequenceGapDetected)
526
572
  return;
@@ -690,6 +736,8 @@ class ControlChannel {
690
736
  this.outboundOperations.clear();
691
737
  this.latestOutboundSequence.clear();
692
738
  this.helloOperation = null;
739
+ this.commerceNegotiated = false;
740
+ this.cartNegotiated = false;
693
741
  this.fencedAuthorityConfirmed = false;
694
742
  this.handlerTail = null;
695
743
  this.pendingHandlerMessages = 0;
@@ -727,6 +775,8 @@ class ControlChannel {
727
775
  this.outboundOperations.clear();
728
776
  this.latestOutboundSequence.clear();
729
777
  this.helloOperation = null;
778
+ this.commerceNegotiated = false;
779
+ this.cartNegotiated = false;
730
780
  this.fencedAuthorityConfirmed = false;
731
781
  socket.close(1000, reason.slice(0, 120));
732
782
  }
@@ -1,6 +1,6 @@
1
1
  import { RuntimeClient, type LaunchInput } from "./client.js";
2
2
  import { GuideSubjectStore } from "./guideSubjectStore.js";
3
- import { type GuideBootstrapConfig, type GuideIdentity, type GuideLaunchIntent } from "./guideTypes.js";
3
+ import { type GuideBootstrapConfig, type GuideIdentity, type GuideLaunchIntent, type GuideMeasurementBridge, type GuideMeasurementIntent } from "./guideTypes.js";
4
4
  import type { BootstrapConfig, LaunchResult, ConsentScope } from "./types.js";
5
5
  import { type GuideRecordingAdapter } from "./guideRecordingSession.js";
6
6
  export type GuideConnectionScope = {
@@ -14,6 +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
18
  private initialBootstrap;
18
19
  private currentBootstrap;
19
20
  private activeAdmission;
@@ -23,7 +24,7 @@ export declare class GuideAdmission {
23
24
  private readonly recording;
24
25
  private recordingChoice;
25
26
  private recordingChoiceRevision;
26
- constructor(identity: GuideIdentity, store: GuideSubjectStore, runtime: RuntimeClient, bootstrap: BootstrapConfig, recordingAdapter?: GuideRecordingAdapter | null);
27
+ constructor(identity: GuideIdentity, store: GuideSubjectStore, runtime: RuntimeClient, bootstrap: BootstrapConfig, recordingAdapter?: GuideRecordingAdapter | null, guideMeasurementBridge?: GuideMeasurementBridge | undefined);
27
28
  subjectId(): string | null;
28
29
  get recordingConfigured(): boolean;
29
30
  get recordingAllowed(): boolean;
@@ -32,6 +33,8 @@ export declare class GuideAdmission {
32
33
  updateRecordingConsent(scopes: ConsentScope[]): void;
33
34
  destroy(): void;
34
35
  pendingIntent(): GuideLaunchIntent | null;
36
+ measurementIntent(clientVersion: string): GuideMeasurementIntent | undefined;
37
+ measurementBridge(intent: GuideLaunchIntent): GuideMeasurementBridge | undefined;
35
38
  connectionScope(): GuideConnectionScope;
36
39
  bootstrap(path: string, locale: string, signal: AbortSignal): Promise<BootstrapConfig>;
37
40
  launch(input: GuideLaunchInput, signal: AbortSignal): Promise<LaunchResult>;
@@ -4,6 +4,7 @@ exports.GuideAdmission = void 0;
4
4
  exports.validateGuideBootstrap = validateGuideBootstrap;
5
5
  const client_js_1 = require("./client.js");
6
6
  const guideTypes_js_1 = require("./guideTypes.js");
7
+ const guideMeasurement_js_1 = require("./guideMeasurement.js");
7
8
  const version_js_1 = require("./version.js");
8
9
  const guideRecordingSession_js_1 = require("./guideRecordingSession.js");
9
10
  const invalid = () => new client_js_1.RuntimeClientError("PROTOCOL_INVALID", "The AI Guide runtime returned an invalid session identity.", false, null, 502);
@@ -29,10 +30,11 @@ function validateGuideBootstrap(value, installKey) {
29
30
  }
30
31
  /** Server admission and local cancellation fences; no recorder or crypto substitute. */
31
32
  class GuideAdmission {
32
- constructor(identity, store, runtime, bootstrap, recordingAdapter = null) {
33
+ constructor(identity, store, runtime, bootstrap, recordingAdapter = null, guideMeasurementBridge) {
33
34
  this.identity = identity;
34
35
  this.store = store;
35
36
  this.runtime = runtime;
37
+ this.guideMeasurementBridge = guideMeasurementBridge;
36
38
  this.activeAdmission = null;
37
39
  this.admissionRequestId = null;
38
40
  this.activeLaunchRequestId = null;
@@ -96,6 +98,17 @@ class GuideAdmission {
96
98
  pendingIntent() {
97
99
  return (this.store.readLaunch() ?? this.activeLaunchRecord)?.intent ?? null;
98
100
  }
101
+ measurementIntent(clientVersion) {
102
+ if (clientVersion !== guideMeasurement_js_1.GUIDE_MEASUREMENT_CLIENT_VERSION ||
103
+ this.currentBootstrap.capabilities?.guideMeasurementV1 !== true ||
104
+ !(0, guideMeasurement_js_1.currentGuideMeasurementBridge)(this.guideMeasurementBridge))
105
+ return undefined;
106
+ return { schemaVersion: 1, assignment: this.guideMeasurementBridge.assignment };
107
+ }
108
+ measurementBridge(intent) {
109
+ return intent.guideMeasurement?.assignment === this.guideMeasurementBridge?.assignment
110
+ ? this.guideMeasurementBridge : undefined;
111
+ }
99
112
  connectionScope() {
100
113
  let subjectId = this.subjectId();
101
114
  return {
@@ -144,6 +157,9 @@ class GuideAdmission {
144
157
  throw new client_js_1.RuntimeClientError("GUIDE_LAUNCH_PENDING", "Finish the previous AI Guide session before starting another.", true, null, 409);
145
158
  }
146
159
  const prior = previous.intent;
160
+ // Recovery keeps the original assignment even after consent/bridge expiry.
161
+ if (prior.guideMeasurement)
162
+ intent.guideMeasurement = { ...prior.guideMeasurement };
147
163
  // The original semantic intent stays immutable. Navigation is authorized
148
164
  // separately by resume2, not by mutating an already-issued grant.
149
165
  if (JSON.stringify({ ...prior, path: intent.path }) !==
@@ -158,6 +174,9 @@ class GuideAdmission {
158
174
  this.currentBootstrap.configRevision !== input.configRevision)
159
175
  throw invalid();
160
176
  const subject = this.store.readSubject();
177
+ const measurement = this.measurementIntent(intent.clientVersion);
178
+ if (measurement)
179
+ intent.guideMeasurement = measurement;
161
180
  this.admissionRequestId = intent.launchRequestId;
162
181
  const admission = this.runtime.admitGuide(intent, subject?.credential, signal);
163
182
  this.activeAdmission = admission;
@@ -201,7 +220,7 @@ class GuideAdmission {
201
220
  }
202
221
  if (signal.aborted)
203
222
  throw new DOMException("The operation was aborted.", "AbortError");
204
- const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal);
223
+ const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal, ...(intent.guideMeasurement ? [this.measurementBridge(intent)] : []));
205
224
  this.validateLaunch(launched, intent.launchRequestId, result.subjectId);
206
225
  return launched;
207
226
  }
@@ -79,7 +79,7 @@ function installGuide(options, recordingFactory) {
79
79
  resolved?.replayRecordingEnabled === true &&
80
80
  recordingFactory
81
81
  ? recordingFactory(identity, runtime.baseUrl)
82
- : null);
82
+ : null, options.guideMeasurementBridge);
83
83
  if (insideFrame &&
84
84
  resolved?.replayRecordingEnabled === true &&
85
85
  recordingFactory)
@@ -0,0 +1,5 @@
1
+ import type { GuideMeasurementBridge, GuideMeasurementIntent } from './guideTypes.js';
2
+ export declare const GUIDE_MEASUREMENT_CLIENT_VERSION = "7.5.21";
3
+ export declare function isGuideMeasurementIntent(value: unknown): value is GuideMeasurementIntent;
4
+ /** The managed analytics owner supplies possession; this check grants no authority. */
5
+ export declare function currentGuideMeasurementBridge(value: unknown): value is GuideMeasurementBridge;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GUIDE_MEASUREMENT_CLIENT_VERSION = void 0;
4
+ exports.isGuideMeasurementIntent = isGuideMeasurementIntent;
5
+ exports.currentGuideMeasurementBridge = currentGuideMeasurementBridge;
6
+ exports.GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.21';
7
+ function isGuideMeasurementIntent(value) {
8
+ if (!value || typeof value !== 'object' || Array.isArray(value))
9
+ return false;
10
+ const candidate = value;
11
+ return Object.keys(candidate).length === 2 && candidate.schemaVersion === 1 &&
12
+ typeof candidate.assignment === 'string' && candidate.assignment.length >= 100 && candidate.assignment.length <= 8192 &&
13
+ /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(candidate.assignment);
14
+ }
15
+ /** The managed analytics owner supplies possession; this check grants no authority. */
16
+ function currentGuideMeasurementBridge(value) {
17
+ try {
18
+ if (!value || typeof value !== 'object')
19
+ return false;
20
+ const bridge = value;
21
+ return bridge.status === 'assigned' && (bridge.arm === 'control' || bridge.arm === 'treatment') &&
22
+ isGuideMeasurementIntent({ schemaVersion: 1, assignment: bridge.assignment }) &&
23
+ Number.isFinite(bridge.expiresAt) && bridge.expiresAt > Date.now() &&
24
+ typeof bridge.current === 'function' && typeof bridge.authorizeLaunch === 'function' && bridge.current() === true;
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GuideSubjectStore = void 0;
4
4
  const guideTypes_js_1 = require("./guideTypes.js");
5
+ const guideMeasurement_js_1 = require("./guideMeasurement.js");
5
6
  class GuideSubjectStore {
6
7
  constructor(identity, origin, namespace, storage = localStorage) {
7
8
  this.identity = identity;
@@ -61,6 +62,7 @@ class GuideSubjectStore {
61
62
  intent.experienceMode !== "standard" ||
62
63
  !intent.consent ||
63
64
  !intent.capabilitySummary ||
65
+ (intent.guideMeasurement !== undefined && !(0, guideMeasurement_js_1.isGuideMeasurementIntent)(intent.guideMeasurement)) ||
64
66
  (record.recordingConsent !== undefined &&
65
67
  typeof record.recordingConsent !== "boolean"))
66
68
  throw new Error("The saved AI Guide launch is invalid.");
@@ -20,6 +20,7 @@ export type GuideLaunchIntent = {
20
20
  tabId: string;
21
21
  mode: "text" | "voice";
22
22
  experienceMode: "standard";
23
+ guideMeasurement?: GuideMeasurementIntent;
23
24
  consent: {
24
25
  disclosureChecksum: string;
25
26
  scopes: ConsentScope[];
@@ -37,6 +38,22 @@ export type GuideLaunchIntent = {
37
38
  lowPower: boolean;
38
39
  };
39
40
  };
41
+ export type GuideMeasurementIntent = {
42
+ schemaVersion: 1;
43
+ assignment: string;
44
+ };
45
+ /** In-memory possession bridge from the managed analytics loader. Never persist it. */
46
+ export type GuideMeasurementBridge = {
47
+ status: 'assigned';
48
+ arm: 'control' | 'treatment';
49
+ assignment: string;
50
+ expiresAt: number;
51
+ current(): boolean;
52
+ authorizeLaunch(url: string, rawBody: string, signal?: AbortSignal): Promise<{
53
+ headers: Record<string, string>;
54
+ current(): boolean;
55
+ }>;
56
+ };
40
57
  export type GuideAdmissionResult = {
41
58
  schemaVersion: 3;
42
59
  protocolVersion: 2;
@@ -105,6 +122,7 @@ export type AiGuideController = {
105
122
  export type StandaloneGuideOptions = Omit<PluginOptions, "siteKey" | "recordReplay"> & {
106
123
  installKey: string;
107
124
  runtimeUrl: string;
125
+ guideMeasurementBridge?: GuideMeasurementBridge;
108
126
  /** Opt in to this frame's own document and server-approved origin only.
109
127
  * Session recording is unavailable in frames; the Guide remains usable.
110
128
  * The embedding site must delegate microphone permission for voice.
@@ -1,5 +1,6 @@
1
1
  import { type LiveDuplexMediaOptions, type LiveDuplexMediaDependencies } from './liveDuplexMedia.js';
2
- export declare const LIVE_CONTROL_CLIENT_VERSION = "7.5.20";
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
4
  export declare const LIVE_CONTROL_CLIENT_CAPABILITIES: readonly ["live_duplex_v1", "live_local_wake_v1", "live_fragment_captions_v1"];
4
5
  declare const phases: readonly ["voice_off", "local_listening", "wake_buffering", "starting", "active", "tentative_idle", "closing", "uncertain", "muted", "suspended", "budget_blocked", "ended"];
5
6
  export type LiveControlState = {
@@ -63,6 +64,13 @@ export interface LiveControlChannelOptions {
63
64
  inputEpoch: number;
64
65
  status: 'working' | 'waiting' | 'blocked' | 'cancelled' | 'failed' | 'fresh_task_required';
65
66
  }): void;
67
+ commerce?: {
68
+ bootstrap: CommerceBootstrap;
69
+ currentContext(): CommerceContext | null;
70
+ cartVersion?: 1;
71
+ };
72
+ onCommerceCatalog?(value: LiveCommerceCatalog): void;
73
+ onCommerceCartEvent?(type: string, payload: unknown): void;
66
74
  }
67
75
  export type LiveControlReady = Readonly<{
68
76
  fencingToken: number;
@@ -70,7 +78,16 @@ export type LiveControlReady = Readonly<{
70
78
  commandEpoch: number;
71
79
  credentialExpiresAt: string;
72
80
  logicalDeadlineAt: string;
81
+ commerceVersion?: 1;
82
+ commerceCartVersion?: 1;
73
83
  }>;
84
+ export type DisplayedLiveCommerceSelection = {
85
+ selection: CommerceCartSelection;
86
+ displayReceipt: LiveCommerceDisplayed;
87
+ product: CommerceProduct;
88
+ expiresAt: string;
89
+ };
90
+ export type LiveCommerceCartCommand = 'commerce.cart.request' | 'commerce.cart.confirmation.result' | 'commerce.cart.execution.begin' | 'commerce.cart.execution.result';
74
91
  /** Dedicated Live voice bridge. It performs no HTTP/provider/financial calls,
75
92
  * reconnect, session reconstruction, feature enablement or speech inference.
76
93
  * Caller-provided capture reports must come from actual current detector/media
@@ -112,6 +129,13 @@ export declare class LiveControlChannel {
112
129
  private deadline;
113
130
  private connectionTimer;
114
131
  private expiryTimer;
132
+ private commerceTask;
133
+ private commerceTaskStatus;
134
+ private commerceCatalog;
135
+ private commerceDisplayedCatalog;
136
+ private commerceDisplayedProducts;
137
+ private readonly commerceAcknowledgements;
138
+ private minimumInputEpoch;
115
139
  constructor(options: LiveControlChannelOptions);
116
140
  connect(signal: AbortSignal): Promise<LiveControlReady>;
117
141
  /** Call directly in the visitor's gesture; no microphone is acquired by connect. */
@@ -139,6 +163,24 @@ export declare class LiveControlChannel {
139
163
  inputEpoch: number;
140
164
  text: string;
141
165
  }): void;
166
+ get commerceNegotiated(): boolean;
167
+ get commerceCartNegotiated(): boolean;
168
+ get sessionId(): string;
169
+ setCommerceContext(context: CommerceContext | CommerceContextClear): boolean;
170
+ acknowledgeCommerceCatalog(value: LiveCommerceDisplayed): boolean;
171
+ /** Display evidence only. A cart request still needs the runtime's fresh
172
+ * quote, consent checks and single-use execution admission. */
173
+ currentCartSelection(productRef: string, variantRef: string): DisplayedLiveCommerceSelection | null;
174
+ currentCartAuthority(): {
175
+ sessionId: string;
176
+ fencingToken: number;
177
+ taskId: string;
178
+ inputEpoch: number;
179
+ } | null;
180
+ sendCommerceCart(type: LiveCommerceCartCommand, payload: Record<string, unknown>): {
181
+ messageId: string;
182
+ accepted: Promise<boolean>;
183
+ };
142
184
  stop(): void;
143
185
  fence(reason: LiveControlPrivacyFence): void;
144
186
  end(): void;