@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.
- package/cjs/AiLiveAssist.d.ts +8 -1
- package/cjs/AiLiveAssist.js +113 -8
- package/cjs/client.d.ts +5 -3
- package/cjs/client.js +44 -5
- package/cjs/commerce/cartContracts.d.ts +158 -0
- package/cjs/commerce/cartContracts.js +228 -0
- package/cjs/commerce/cartSession.d.ts +86 -0
- package/cjs/commerce/cartSession.js +475 -0
- package/cjs/commerce/contracts.d.ts +152 -0
- package/cjs/commerce/contracts.js +322 -0
- package/cjs/commerce/pageContext.d.ts +50 -0
- package/cjs/commerce/pageContext.js +173 -0
- package/cjs/commerce/productPanel.d.ts +65 -0
- package/cjs/commerce/productPanel.js +662 -0
- package/cjs/commerce/realtimeCommerce.d.ts +73 -0
- package/cjs/commerce/realtimeCommerce.js +342 -0
- package/cjs/commerce/shopifyCart.d.ts +130 -0
- package/cjs/commerce/shopifyCart.js +1135 -0
- package/cjs/commerce/shopifyCartPresentation.d.ts +12 -0
- package/cjs/commerce/shopifyCartPresentation.js +379 -0
- package/cjs/commerce/shoppingNotes.d.ts +61 -0
- package/cjs/commerce/shoppingNotes.js +313 -0
- package/cjs/commerce/shoppingNotesView.d.ts +46 -0
- package/cjs/commerce/shoppingNotesView.js +269 -0
- package/cjs/control.d.ts +9 -1
- package/cjs/control.js +51 -1
- package/cjs/guideAdmission.d.ts +5 -2
- package/cjs/guideAdmission.js +21 -2
- package/cjs/guideInstaller.js +1 -1
- package/cjs/guideMeasurement.d.ts +5 -0
- package/cjs/guideMeasurement.js +29 -0
- package/cjs/guideSubjectStore.js +2 -0
- package/cjs/guideTypes.d.ts +18 -0
- package/cjs/liveControlChannel.d.ts +43 -1
- package/cjs/liveControlChannel.js +166 -14
- package/cjs/liveGuideAdmission.d.ts +3 -2
- package/cjs/liveGuideAdmission.js +10 -2
- package/cjs/liveGuideWidget.d.ts +18 -0
- package/cjs/liveGuideWidget.js +228 -23
- package/cjs/locales/resources.js +2240 -0
- package/cjs/messages.js +56 -0
- package/cjs/tabLock.d.ts +2 -0
- package/cjs/tabLock.js +11 -1
- package/cjs/types.d.ts +6 -2
- package/cjs/types.js +56 -0
- package/cjs/ui.d.ts +37 -0
- package/cjs/ui.js +259 -9
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/lib/AiLiveAssist.d.ts +8 -1
- package/lib/AiLiveAssist.js +113 -8
- package/lib/client.d.ts +5 -3
- package/lib/client.js +44 -5
- package/lib/commerce/cartContracts.d.ts +158 -0
- package/lib/commerce/cartContracts.js +221 -0
- package/lib/commerce/cartSession.d.ts +86 -0
- package/lib/commerce/cartSession.js +471 -0
- package/lib/commerce/contracts.d.ts +152 -0
- package/lib/commerce/contracts.js +300 -0
- package/lib/commerce/pageContext.d.ts +50 -0
- package/lib/commerce/pageContext.js +168 -0
- package/lib/commerce/productPanel.d.ts +65 -0
- package/lib/commerce/productPanel.js +657 -0
- package/lib/commerce/realtimeCommerce.d.ts +73 -0
- package/lib/commerce/realtimeCommerce.js +337 -0
- package/lib/commerce/shopifyCart.d.ts +130 -0
- package/lib/commerce/shopifyCart.js +1130 -0
- package/lib/commerce/shopifyCartPresentation.d.ts +12 -0
- package/lib/commerce/shopifyCartPresentation.js +376 -0
- package/lib/commerce/shoppingNotes.d.ts +61 -0
- package/lib/commerce/shoppingNotes.js +307 -0
- package/lib/commerce/shoppingNotesView.d.ts +46 -0
- package/lib/commerce/shoppingNotesView.js +265 -0
- package/lib/control.d.ts +9 -1
- package/lib/control.js +51 -1
- package/lib/guideAdmission.d.ts +5 -2
- package/lib/guideAdmission.js +21 -2
- package/lib/guideInstaller.js +1 -1
- package/lib/guideMeasurement.d.ts +5 -0
- package/lib/guideMeasurement.js +24 -0
- package/lib/guideSubjectStore.js +2 -0
- package/lib/guideTypes.d.ts +18 -0
- package/lib/liveControlChannel.d.ts +43 -1
- package/lib/liveControlChannel.js +166 -14
- package/lib/liveGuideAdmission.d.ts +3 -2
- package/lib/liveGuideAdmission.js +10 -2
- package/lib/liveGuideWidget.d.ts +18 -0
- package/lib/liveGuideWidget.js +228 -23
- package/lib/locales/resources.js +2240 -0
- package/lib/messages.js +56 -0
- package/lib/tabLock.d.ts +2 -0
- package/lib/tabLock.js +11 -1
- package/lib/types.d.ts +6 -2
- package/lib/types.js +56 -0
- package/lib/ui.d.ts +37 -0
- package/lib/ui.js +259 -9
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/control.js
CHANGED
|
@@ -10,6 +10,13 @@ const MAX_SETTLED_OPERATION_HISTORY = 100;
|
|
|
10
10
|
const CLIENT_MESSAGE_ID_PATTERN = /^[A-Za-z0-9_.:-]{8,128}$/;
|
|
11
11
|
const STATEFUL_CONTROL_TYPES = new Set([
|
|
12
12
|
"cta.result",
|
|
13
|
+
"commerce.context",
|
|
14
|
+
"commerce.context.clear",
|
|
15
|
+
"commerce.catalog.displayed",
|
|
16
|
+
"commerce.cart.request",
|
|
17
|
+
"commerce.cart.confirmation.result",
|
|
18
|
+
"commerce.cart.execution.begin",
|
|
19
|
+
"commerce.cart.execution.result",
|
|
13
20
|
"text.message",
|
|
14
21
|
"confirmation.result",
|
|
15
22
|
"consent.update",
|
|
@@ -36,7 +43,7 @@ const STATEFUL_CONTROL_TYPES = new Set([
|
|
|
36
43
|
]);
|
|
37
44
|
const outcomeKey = (messageId, sequence) => `${messageId}\u0000${sequence}`;
|
|
38
45
|
export class ControlChannel {
|
|
39
|
-
constructor(result, tabId, clientVersion, onDisconnect, initialClientSequence = 0, onClientSequence = () => undefined, onUnsafeDisconnect = () => undefined, transportRecovery) {
|
|
46
|
+
constructor(result, tabId, clientVersion, onDisconnect, initialClientSequence = 0, onClientSequence = () => undefined, onUnsafeDisconnect = () => undefined, transportRecovery, commerceVersion, commerceCartEnabled = false) {
|
|
40
47
|
this.result = result;
|
|
41
48
|
this.tabId = tabId;
|
|
42
49
|
this.clientVersion = clientVersion;
|
|
@@ -44,6 +51,8 @@ export class ControlChannel {
|
|
|
44
51
|
this.onClientSequence = onClientSequence;
|
|
45
52
|
this.onUnsafeDisconnect = onUnsafeDisconnect;
|
|
46
53
|
this.transportRecovery = transportRecovery;
|
|
54
|
+
this.commerceVersion = commerceVersion;
|
|
55
|
+
this.commerceCartEnabled = commerceCartEnabled;
|
|
47
56
|
this.socket = null;
|
|
48
57
|
this.serverSequence = 0;
|
|
49
58
|
this.serverBaselineEstablished = false;
|
|
@@ -66,6 +75,8 @@ export class ControlChannel {
|
|
|
66
75
|
this.pendingConnection = null;
|
|
67
76
|
this.helloOperation = null;
|
|
68
77
|
this.fencedAuthorityConfirmed = false;
|
|
78
|
+
this.commerceNegotiated = false;
|
|
79
|
+
this.cartNegotiated = false;
|
|
69
80
|
this.transportRecoveryAttempted = false;
|
|
70
81
|
this.recoveringTransport = false;
|
|
71
82
|
this.clientSequence =
|
|
@@ -76,6 +87,15 @@ export class ControlChannel {
|
|
|
76
87
|
get leaseToken() {
|
|
77
88
|
return this.fencingToken;
|
|
78
89
|
}
|
|
90
|
+
get sessionId() {
|
|
91
|
+
return this.result.sessionId;
|
|
92
|
+
}
|
|
93
|
+
get negotiatedCommerceVersion() {
|
|
94
|
+
return this.commerceNegotiated ? 1 : undefined;
|
|
95
|
+
}
|
|
96
|
+
get commerceCartNegotiated() {
|
|
97
|
+
return this.commerceNegotiated && this.cartNegotiated;
|
|
98
|
+
}
|
|
79
99
|
get lastClientSequence() {
|
|
80
100
|
return this.clientSequence;
|
|
81
101
|
}
|
|
@@ -123,6 +143,8 @@ export class ControlChannel {
|
|
|
123
143
|
this.sequenceGapDetected = false;
|
|
124
144
|
this.recoveryDisconnectNotified = false;
|
|
125
145
|
this.helloOperation = null;
|
|
146
|
+
this.commerceNegotiated = false;
|
|
147
|
+
this.cartNegotiated = false;
|
|
126
148
|
this.fencedAuthorityConfirmed = false;
|
|
127
149
|
this.handlerTail = null;
|
|
128
150
|
this.pendingHandlerMessages = 0;
|
|
@@ -154,6 +176,8 @@ export class ControlChannel {
|
|
|
154
176
|
protocolMax: this.result.protocolVersion,
|
|
155
177
|
clientVersion: this.clientVersion,
|
|
156
178
|
ctaOffer: true,
|
|
179
|
+
...(this.commerceVersion === 1 ? { commerceVersion: 1 } : {}),
|
|
180
|
+
...(this.commerceVersion === 1 && this.commerceCartEnabled ? { commerceCartVersion: 1 } : {}),
|
|
157
181
|
resume,
|
|
158
182
|
});
|
|
159
183
|
this.helloOperation = {
|
|
@@ -202,6 +226,8 @@ export class ControlChannel {
|
|
|
202
226
|
this.outboundOperations.clear();
|
|
203
227
|
this.latestOutboundSequence.clear();
|
|
204
228
|
this.helloOperation = null;
|
|
229
|
+
this.commerceNegotiated = false;
|
|
230
|
+
this.cartNegotiated = false;
|
|
205
231
|
this.fencedAuthorityConfirmed = false;
|
|
206
232
|
this.handlerTail = null;
|
|
207
233
|
this.pendingHandlerMessages = 0;
|
|
@@ -222,6 +248,7 @@ export class ControlChannel {
|
|
|
222
248
|
});
|
|
223
249
|
}
|
|
224
250
|
send(type, payload, stableMessageId) {
|
|
251
|
+
this.requireCommerceCartNegotiation(type);
|
|
225
252
|
if (this.recoveringTransport && type !== "hello" && type !== "heartbeat") {
|
|
226
253
|
throw new Error("The AI Guide control channel is reconnecting.");
|
|
227
254
|
}
|
|
@@ -247,6 +274,7 @@ export class ControlChannel {
|
|
|
247
274
|
return messageId;
|
|
248
275
|
}
|
|
249
276
|
reserveOperationIdentity(type, stableMessageId) {
|
|
277
|
+
this.requireCommerceCartNegotiation(type);
|
|
250
278
|
const messageId = stableMessageId ?? `msg_${crypto.randomUUID()}`;
|
|
251
279
|
if (!CLIENT_MESSAGE_ID_PATTERN.test(messageId)) {
|
|
252
280
|
throw new Error("Invalid AI Guide control message ID.");
|
|
@@ -263,6 +291,7 @@ export class ControlChannel {
|
|
|
263
291
|
};
|
|
264
292
|
}
|
|
265
293
|
sendReserved(operation, payload) {
|
|
294
|
+
this.requireCommerceCartNegotiation(operation.type);
|
|
266
295
|
const socket = this.socket;
|
|
267
296
|
const socketGeneration = this.socketGeneration;
|
|
268
297
|
if (!socket || socket.readyState !== WebSocket.OPEN) {
|
|
@@ -440,6 +469,8 @@ export class ControlChannel {
|
|
|
440
469
|
this.outboundOperations.clear();
|
|
441
470
|
this.latestOutboundSequence.clear();
|
|
442
471
|
this.helloOperation = null;
|
|
472
|
+
this.commerceNegotiated = false;
|
|
473
|
+
this.cartNegotiated = false;
|
|
443
474
|
this.fencedAuthorityConfirmed = false;
|
|
444
475
|
this.unsettledStatefulOperations.clear();
|
|
445
476
|
}
|
|
@@ -514,10 +545,25 @@ export class ControlChannel {
|
|
|
514
545
|
: null,
|
|
515
546
|
});
|
|
516
547
|
}
|
|
548
|
+
if (message.type === "control.ready" &&
|
|
549
|
+
message.payload.helloMessageId === this.helloOperation?.messageId &&
|
|
550
|
+
this.helloOperation !== null) {
|
|
551
|
+
this.commerceNegotiated =
|
|
552
|
+
this.commerceVersion === 1 && message.payload.commerceVersion === 1;
|
|
553
|
+
this.cartNegotiated = this.commerceNegotiated && this.commerceCartEnabled &&
|
|
554
|
+
message.payload.commerceCartVersion === 1;
|
|
555
|
+
}
|
|
556
|
+
if (message.type.startsWith("commerce.cart.") && !this.commerceCartNegotiated)
|
|
557
|
+
return;
|
|
517
558
|
if (!this.dispatchIngressHandlers(message, socket, generation))
|
|
518
559
|
return;
|
|
519
560
|
return this.enqueueHandlers(message, socket, generation);
|
|
520
561
|
}
|
|
562
|
+
requireCommerceCartNegotiation(type) {
|
|
563
|
+
if (type.startsWith("commerce.cart.") && !this.commerceCartNegotiated) {
|
|
564
|
+
throw new Error("Shopping cart actions were not negotiated for this connection.");
|
|
565
|
+
}
|
|
566
|
+
}
|
|
521
567
|
recoverFromSequenceGap(socket, generation) {
|
|
522
568
|
if (this.sequenceGapDetected)
|
|
523
569
|
return;
|
|
@@ -687,6 +733,8 @@ export class ControlChannel {
|
|
|
687
733
|
this.outboundOperations.clear();
|
|
688
734
|
this.latestOutboundSequence.clear();
|
|
689
735
|
this.helloOperation = null;
|
|
736
|
+
this.commerceNegotiated = false;
|
|
737
|
+
this.cartNegotiated = false;
|
|
690
738
|
this.fencedAuthorityConfirmed = false;
|
|
691
739
|
this.handlerTail = null;
|
|
692
740
|
this.pendingHandlerMessages = 0;
|
|
@@ -724,6 +772,8 @@ export class ControlChannel {
|
|
|
724
772
|
this.outboundOperations.clear();
|
|
725
773
|
this.latestOutboundSequence.clear();
|
|
726
774
|
this.helloOperation = null;
|
|
775
|
+
this.commerceNegotiated = false;
|
|
776
|
+
this.cartNegotiated = false;
|
|
727
777
|
this.fencedAuthorityConfirmed = false;
|
|
728
778
|
socket.close(1000, reason.slice(0, 120));
|
|
729
779
|
}
|
package/lib/guideAdmission.d.ts
CHANGED
|
@@ -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>;
|
package/lib/guideAdmission.js
CHANGED
|
@@ -1,5 +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
4
|
import { VERSION } from "./version.js";
|
|
4
5
|
import { GuideRecordingSession, } from "./guideRecordingSession.js";
|
|
5
6
|
const invalid = () => new RuntimeClientError("PROTOCOL_INVALID", "The AI Guide runtime returned an invalid session identity.", false, null, 502);
|
|
@@ -25,10 +26,11 @@ export function validateGuideBootstrap(value, installKey) {
|
|
|
25
26
|
}
|
|
26
27
|
/** Server admission and local cancellation fences; no recorder or crypto substitute. */
|
|
27
28
|
export class GuideAdmission {
|
|
28
|
-
constructor(identity, store, runtime, bootstrap, recordingAdapter = null) {
|
|
29
|
+
constructor(identity, store, runtime, bootstrap, recordingAdapter = null, guideMeasurementBridge) {
|
|
29
30
|
this.identity = identity;
|
|
30
31
|
this.store = store;
|
|
31
32
|
this.runtime = runtime;
|
|
33
|
+
this.guideMeasurementBridge = guideMeasurementBridge;
|
|
32
34
|
this.activeAdmission = null;
|
|
33
35
|
this.admissionRequestId = null;
|
|
34
36
|
this.activeLaunchRequestId = null;
|
|
@@ -92,6 +94,17 @@ export class GuideAdmission {
|
|
|
92
94
|
pendingIntent() {
|
|
93
95
|
return (this.store.readLaunch() ?? this.activeLaunchRecord)?.intent ?? null;
|
|
94
96
|
}
|
|
97
|
+
measurementIntent(clientVersion) {
|
|
98
|
+
if (clientVersion !== GUIDE_MEASUREMENT_CLIENT_VERSION ||
|
|
99
|
+
this.currentBootstrap.capabilities?.guideMeasurementV1 !== true ||
|
|
100
|
+
!currentGuideMeasurementBridge(this.guideMeasurementBridge))
|
|
101
|
+
return undefined;
|
|
102
|
+
return { schemaVersion: 1, assignment: this.guideMeasurementBridge.assignment };
|
|
103
|
+
}
|
|
104
|
+
measurementBridge(intent) {
|
|
105
|
+
return intent.guideMeasurement?.assignment === this.guideMeasurementBridge?.assignment
|
|
106
|
+
? this.guideMeasurementBridge : undefined;
|
|
107
|
+
}
|
|
95
108
|
connectionScope() {
|
|
96
109
|
let subjectId = this.subjectId();
|
|
97
110
|
return {
|
|
@@ -140,6 +153,9 @@ export class GuideAdmission {
|
|
|
140
153
|
throw new RuntimeClientError("GUIDE_LAUNCH_PENDING", "Finish the previous AI Guide session before starting another.", true, null, 409);
|
|
141
154
|
}
|
|
142
155
|
const prior = previous.intent;
|
|
156
|
+
// Recovery keeps the original assignment even after consent/bridge expiry.
|
|
157
|
+
if (prior.guideMeasurement)
|
|
158
|
+
intent.guideMeasurement = { ...prior.guideMeasurement };
|
|
143
159
|
// The original semantic intent stays immutable. Navigation is authorized
|
|
144
160
|
// separately by resume2, not by mutating an already-issued grant.
|
|
145
161
|
if (JSON.stringify({ ...prior, path: intent.path }) !==
|
|
@@ -154,6 +170,9 @@ export class GuideAdmission {
|
|
|
154
170
|
this.currentBootstrap.configRevision !== input.configRevision)
|
|
155
171
|
throw invalid();
|
|
156
172
|
const subject = this.store.readSubject();
|
|
173
|
+
const measurement = this.measurementIntent(intent.clientVersion);
|
|
174
|
+
if (measurement)
|
|
175
|
+
intent.guideMeasurement = measurement;
|
|
157
176
|
this.admissionRequestId = intent.launchRequestId;
|
|
158
177
|
const admission = this.runtime.admitGuide(intent, subject?.credential, signal);
|
|
159
178
|
this.activeAdmission = admission;
|
|
@@ -197,7 +216,7 @@ export class GuideAdmission {
|
|
|
197
216
|
}
|
|
198
217
|
if (signal.aborted)
|
|
199
218
|
throw new DOMException("The operation was aborted.", "AbortError");
|
|
200
|
-
const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal);
|
|
219
|
+
const launched = await this.runtime.launchGuide(intent, result.admissionGrant, signal, ...(intent.guideMeasurement ? [this.measurementBridge(intent)] : []));
|
|
201
220
|
this.validateLaunch(launched, intent.launchRequestId, result.subjectId);
|
|
202
221
|
return launched;
|
|
203
222
|
}
|
package/lib/guideInstaller.js
CHANGED
|
@@ -76,7 +76,7 @@ export function installGuide(options, recordingFactory) {
|
|
|
76
76
|
resolved?.replayRecordingEnabled === true &&
|
|
77
77
|
recordingFactory
|
|
78
78
|
? recordingFactory(identity, runtime.baseUrl)
|
|
79
|
-
: null);
|
|
79
|
+
: null, options.guideMeasurementBridge);
|
|
80
80
|
if (insideFrame &&
|
|
81
81
|
resolved?.replayRecordingEnabled === true &&
|
|
82
82
|
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,24 @@
|
|
|
1
|
+
export const GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.21';
|
|
2
|
+
export function isGuideMeasurementIntent(value) {
|
|
3
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
4
|
+
return false;
|
|
5
|
+
const candidate = value;
|
|
6
|
+
return Object.keys(candidate).length === 2 && candidate.schemaVersion === 1 &&
|
|
7
|
+
typeof candidate.assignment === 'string' && candidate.assignment.length >= 100 && candidate.assignment.length <= 8192 &&
|
|
8
|
+
/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(candidate.assignment);
|
|
9
|
+
}
|
|
10
|
+
/** The managed analytics owner supplies possession; this check grants no authority. */
|
|
11
|
+
export function currentGuideMeasurementBridge(value) {
|
|
12
|
+
try {
|
|
13
|
+
if (!value || typeof value !== 'object')
|
|
14
|
+
return false;
|
|
15
|
+
const bridge = value;
|
|
16
|
+
return bridge.status === 'assigned' && (bridge.arm === 'control' || bridge.arm === 'treatment') &&
|
|
17
|
+
isGuideMeasurementIntent({ schemaVersion: 1, assignment: bridge.assignment }) &&
|
|
18
|
+
Number.isFinite(bridge.expiresAt) && bridge.expiresAt > Date.now() &&
|
|
19
|
+
typeof bridge.current === 'function' && typeof bridge.authorizeLaunch === 'function' && bridge.current() === true;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
package/lib/guideSubjectStore.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GUIDE_SUBJECT_CREDENTIAL_PATTERN, GUIDE_UUID_PATTERN, } from "./guideTypes.js";
|
|
2
|
+
import { isGuideMeasurementIntent } from './guideMeasurement.js';
|
|
2
3
|
export class GuideSubjectStore {
|
|
3
4
|
constructor(identity, origin, namespace, storage = localStorage) {
|
|
4
5
|
this.identity = identity;
|
|
@@ -58,6 +59,7 @@ export class GuideSubjectStore {
|
|
|
58
59
|
intent.experienceMode !== "standard" ||
|
|
59
60
|
!intent.consent ||
|
|
60
61
|
!intent.capabilitySummary ||
|
|
62
|
+
(intent.guideMeasurement !== undefined && !isGuideMeasurementIntent(intent.guideMeasurement)) ||
|
|
61
63
|
(record.recordingConsent !== undefined &&
|
|
62
64
|
typeof record.recordingConsent !== "boolean"))
|
|
63
65
|
throw new Error("The saved AI Guide launch is invalid.");
|
package/lib/guideTypes.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|