@oxvo/ai-live-assist 7.5.21 → 7.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/AiLiveAssist.d.ts +1 -1
- package/cjs/commerce/realtimeCommerce.js +6 -0
- package/cjs/context.js +62 -10
- package/cjs/guideAdmission.d.ts +2 -1
- package/cjs/guideAdmission.js +22 -4
- package/cjs/guideMeasurement.d.ts +3 -1
- package/cjs/guideMeasurement.js +31 -1
- package/cjs/guideTypes.d.ts +1 -0
- package/cjs/liveControlChannel.d.ts +1 -1
- package/cjs/liveControlChannel.js +4 -1
- package/cjs/liveGuideAdmission.d.ts +1 -1
- package/cjs/liveGuideAdmission.js +6 -2
- package/cjs/privacy/textRedaction.generated.d.ts +1 -0
- package/cjs/privacy/textRedaction.generated.js +29 -0
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/lib/AiLiveAssist.d.ts +1 -1
- package/lib/commerce/realtimeCommerce.js +6 -0
- package/lib/context.js +62 -10
- package/lib/guideAdmission.d.ts +2 -1
- package/lib/guideAdmission.js +23 -5
- package/lib/guideMeasurement.d.ts +3 -1
- package/lib/guideMeasurement.js +30 -1
- package/lib/guideTypes.d.ts +1 -0
- package/lib/liveControlChannel.d.ts +1 -1
- package/lib/liveControlChannel.js +4 -1
- package/lib/liveGuideAdmission.d.ts +1 -1
- package/lib/liveGuideAdmission.js +6 -2
- package/lib/privacy/textRedaction.generated.d.ts +1 -0
- package/lib/privacy/textRedaction.generated.js +25 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +6 -5
package/cjs/AiLiveAssist.d.ts
CHANGED
|
@@ -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.
|
|
37
|
+
readonly version = "7.5.23";
|
|
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)
|
|
@@ -239,6 +242,9 @@ class RealtimeCommerce {
|
|
|
239
242
|
}
|
|
240
243
|
},
|
|
241
244
|
onDisplayed: (resultSetId, products) => {
|
|
245
|
+
// The empty-state UI is visible, but the protocol acknowledges product cards only.
|
|
246
|
+
if (products.length === 0)
|
|
247
|
+
return;
|
|
242
248
|
this.context.refresh();
|
|
243
249
|
if (!isCurrent() || resultSetId !== event.catalog.resultSetId ||
|
|
244
250
|
!(0, contracts_js_1.isDisplayedCommerceProducts)(event.catalog, products))
|
package/cjs/context.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PageContextCollector = exports.actionTargetFingerprint = void 0;
|
|
4
|
+
const textRedaction_generated_js_1 = require("./privacy/textRedaction.generated.js");
|
|
4
5
|
const visualContext_js_1 = require("./visualContext.js");
|
|
5
6
|
const MAX_TARGETS = 256;
|
|
6
7
|
const MAX_TEXT_ITEMS = 256;
|
|
7
8
|
const MAX_TOTAL_TEXT = 24000;
|
|
9
|
+
const MAX_RAW_TEXT_NODE = 96000;
|
|
8
10
|
const MAX_OPTIONS = 100;
|
|
9
11
|
const MAX_SELECTED_TEXT = 2000;
|
|
10
12
|
const SELECTION_RETENTION_MS = 120000;
|
|
@@ -668,14 +670,26 @@ const safeOptionLabel = (option) => {
|
|
|
668
670
|
return sensitivityFor(option, label) === 'none' ? label : '';
|
|
669
671
|
};
|
|
670
672
|
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) => {
|
|
673
|
+
const belongsToInteractiveControl = (element, text) => {
|
|
674
|
+
const linkedText = element.closest('a[href],[role="link"]') !== null;
|
|
672
675
|
for (let current = element; current; current = current.parentElement) {
|
|
673
|
-
//
|
|
674
|
-
//
|
|
676
|
+
// Public link text belongs in reading order beside surrounding page copy.
|
|
677
|
+
// Inspect the link's descriptors before sanitized names can erase them;
|
|
678
|
+
// neither those attributes nor the destination become semantic text.
|
|
679
|
+
if (current.matches('a[href],[role="link"]')) {
|
|
680
|
+
if (sensitivityFor(current, text) !== 'none' ||
|
|
681
|
+
sensitivityFor(current, normalize(`${current.getAttribute('aria-label') ?? ''} ${current.getAttribute('title') ?? ''}`, 500)) !== 'none' ||
|
|
682
|
+
accessibleNameSourceSensitivity(current) !== 'none')
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
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"]'))
|
|
686
|
+
return true;
|
|
687
|
+
// Form copy can carry useful public instructions. Actual control text
|
|
688
|
+
// stays in targets, including links nested inside controls.
|
|
675
689
|
if (current.matches('form'))
|
|
676
690
|
continue;
|
|
677
691
|
// A bare tabindex is often a focusable Framer content card, not an action.
|
|
678
|
-
if (current.matches('
|
|
692
|
+
if (current.matches('button,input,select,textarea,summary,[contenteditable="true"],[role="button"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"]'))
|
|
679
693
|
return true;
|
|
680
694
|
}
|
|
681
695
|
return false;
|
|
@@ -1245,22 +1259,60 @@ class PageContextCollector {
|
|
|
1245
1259
|
const textElement = semanticTextElement && isRendered(semanticTextElement)
|
|
1246
1260
|
? semanticTextElement
|
|
1247
1261
|
: node.nodeType === Node.TEXT_NODE ? parent : null;
|
|
1248
|
-
const
|
|
1249
|
-
(node.nodeType === Node.TEXT_NODE ? node.textContent ?? '' : '')
|
|
1262
|
+
const rawText = semanticTextElement?.getAttribute('aria-label') ??
|
|
1263
|
+
(node.nodeType === Node.TEXT_NODE ? node.textContent ?? '' : '');
|
|
1264
|
+
const normalizedText = normalize(rawText.slice(0, MAX_RAW_TEXT_NODE), MAX_RAW_TEXT_NODE);
|
|
1265
|
+
const text = normalizedText.slice(0, 500);
|
|
1250
1266
|
if (parent &&
|
|
1251
1267
|
textElement &&
|
|
1252
|
-
text &&
|
|
1268
|
+
(text || rawText.length > MAX_RAW_TEXT_NODE) &&
|
|
1253
1269
|
!parent.closest(PRIVATE_SELECTOR) &&
|
|
1254
1270
|
!parent.closest('script,style,noscript,template,svg') &&
|
|
1255
1271
|
!parent.closest('input,select,textarea,option') &&
|
|
1256
1272
|
(!semanticTextElement || !capturedSemanticText.has(semanticTextElement)) &&
|
|
1257
|
-
!belongsToInteractiveControl(textElement) &&
|
|
1273
|
+
!belongsToInteractiveControl(textElement, normalizedText) &&
|
|
1258
1274
|
isRendered(textElement) &&
|
|
1259
1275
|
sensitivityFor(textElement, nameFor(textElement)) === 'none') {
|
|
1260
1276
|
const textId = this.textIds.get(node) ?? id('text');
|
|
1261
1277
|
this.textIds.set(node, textId);
|
|
1262
|
-
|
|
1263
|
-
|
|
1278
|
+
// Fail closed on unusually large nodes instead of redacting a partial
|
|
1279
|
+
// credential or adding an unbounded full-node redaction pass.
|
|
1280
|
+
if (rawText.length > MAX_RAW_TEXT_NODE) {
|
|
1281
|
+
truncated = true;
|
|
1282
|
+
node = walker.nextNode();
|
|
1283
|
+
continue;
|
|
1284
|
+
}
|
|
1285
|
+
// Normalize the whole bounded node before the native text policy so
|
|
1286
|
+
// whitespace-separated credentials cannot evade redaction at a cut.
|
|
1287
|
+
const safeText = (0, textRedaction_generated_js_1.redactText)(normalizedText, MAX_TOTAL_TEXT + 1);
|
|
1288
|
+
let offset = 0;
|
|
1289
|
+
let chunkIndex = 0;
|
|
1290
|
+
while (offset < safeText.length && visibleText.length < MAX_TEXT_ITEMS && totalText < MAX_TOTAL_TEXT) {
|
|
1291
|
+
let end = Math.min(offset + 500, offset + MAX_TOTAL_TEXT - totalText, safeText.length);
|
|
1292
|
+
// Prefer sentence/word boundaries without reserving more payload.
|
|
1293
|
+
if (end < safeText.length) {
|
|
1294
|
+
const window = safeText.slice(offset, end);
|
|
1295
|
+
const sentences = Array.from(window.matchAll(/[.!?] (?=\S)/g));
|
|
1296
|
+
const sentenceEnd = sentences[sentences.length - 1]?.index;
|
|
1297
|
+
const wordEnd = window.lastIndexOf(' ');
|
|
1298
|
+
if (sentenceEnd !== undefined && sentenceEnd >= 249)
|
|
1299
|
+
end = offset + sentenceEnd + 2;
|
|
1300
|
+
else if (wordEnd > 0)
|
|
1301
|
+
end = offset + wordEnd + 1;
|
|
1302
|
+
}
|
|
1303
|
+
// A hard token/budget boundary must not split a UTF-16 pair.
|
|
1304
|
+
if (end < safeText.length && /[\uD800-\uDBFF]/.test(safeText[end - 1]))
|
|
1305
|
+
end -= 1;
|
|
1306
|
+
if (end === offset)
|
|
1307
|
+
break;
|
|
1308
|
+
const chunk = safeText.slice(offset, end);
|
|
1309
|
+
visibleText.push({ id: chunkIndex === 0 ? textId : `${textId}.${chunkIndex}`, text: chunk, provenance: 'page' });
|
|
1310
|
+
totalText += chunk.length;
|
|
1311
|
+
offset = end;
|
|
1312
|
+
chunkIndex += 1;
|
|
1313
|
+
}
|
|
1314
|
+
if (offset < safeText.length)
|
|
1315
|
+
truncated = true;
|
|
1264
1316
|
if (semanticTextElement)
|
|
1265
1317
|
capturedSemanticText.add(semanticTextElement);
|
|
1266
1318
|
}
|
package/cjs/guideAdmission.d.ts
CHANGED
|
@@ -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
|
|
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>;
|
package/cjs/guideAdmission.js
CHANGED
|
@@ -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
|
-
|
|
178
|
-
|
|
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 ? [
|
|
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.
|
|
2
|
+
export declare const GUIDE_MEASUREMENT_CLIENT_VERSION = "7.5.23";
|
|
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>;
|
package/cjs/guideMeasurement.js
CHANGED
|
@@ -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.
|
|
6
|
+
exports.prepareGuideMeasurementBridge = prepareGuideMeasurementBridge;
|
|
7
|
+
exports.GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.23';
|
|
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
|
+
}
|
package/cjs/guideTypes.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
export declare const LIVE_CONTROL_CLIENT_VERSION = "7.5.23";
|
|
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 = {
|
|
@@ -221,6 +221,9 @@ class LiveControlChannel {
|
|
|
221
221
|
return true;
|
|
222
222
|
}
|
|
223
223
|
acknowledgeCommerceCatalog(value) {
|
|
224
|
+
// The empty-state UI is visible, but the protocol acknowledges product cards only.
|
|
225
|
+
if (value.products.length === 0)
|
|
226
|
+
return false;
|
|
224
227
|
const current = this.commerceCatalog;
|
|
225
228
|
const commerce = this.options.commerce;
|
|
226
229
|
if (!this.commerceNegotiated || !current || !commerce || !this.commerceTask || !(0, contracts_js_1.parseLiveCommerceCatalog)(current, commerce.bootstrap, commerce.currentContext(), this.commerceTask, this.clock.wallNow(), { cartNegotiated: this.commerceCartNegotiated }) ||
|
|
@@ -428,7 +431,7 @@ class LiveControlChannel {
|
|
|
428
431
|
stack.pop();
|
|
429
432
|
else if (data.slice((match.index ?? 0) + match[0].length).trimStart().startsWith(':')) {
|
|
430
433
|
const key = JSON.parse(match[0]);
|
|
431
|
-
const keys = stack.
|
|
434
|
+
const keys = stack[stack.length - 1];
|
|
432
435
|
if (!keys || keys.has(key))
|
|
433
436
|
throw unavailable();
|
|
434
437
|
keys.add(key);
|
|
@@ -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
|
|
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();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const redactText: (value: string, maximum?: number) => string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Generated from ai-live-assist/src/security/textRedaction.ts. Do not edit.
|
|
3
|
+
// Source SHA256: 23840bc803a386b537b4104c4e8d92c7faa7ec0643efff8284bc825d7731e257
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.redactText = void 0;
|
|
6
|
+
const secretValuePatterns = [
|
|
7
|
+
// Compact signed JWTs remain credentials even without a Bearer prefix or a
|
|
8
|
+
// secret-looking field name (for example guideMeasurement.assignment).
|
|
9
|
+
/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?![A-Za-z0-9_-])/g,
|
|
10
|
+
/\b(?:assignment[_ -]?credential|analytics[_ -]?(?:receipt|proof))["']?\s*[:=]\s*["']?[^\s,;"']{2,}["']?/gi,
|
|
11
|
+
/\b(?:password|passphrase|secret|token|api[_ -]?key|authorization|cookie|otp|one[- ]time(?: code)?|verification code|cvv|cvc|card number|routing number|iban|private[_ -]?key)\s*[:=]\s*["']?[^\s,;"']{2,}["']?/gi,
|
|
12
|
+
/\b(?:sk|rk|pk)-[A-Za-z0-9_-]{16,}\b/g,
|
|
13
|
+
/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*\b/gi,
|
|
14
|
+
/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
|
|
15
|
+
/\b(?:\d[ -]*?){13,19}\b/g,
|
|
16
|
+
];
|
|
17
|
+
const redactText = (value, maximum = 2000) => {
|
|
18
|
+
let redacted = value;
|
|
19
|
+
for (const pattern of secretValuePatterns)
|
|
20
|
+
redacted = redacted.replace(pattern, '[REDACTED]');
|
|
21
|
+
let safe = '';
|
|
22
|
+
for (let index = 0; index < redacted.length; index += 1) {
|
|
23
|
+
const character = redacted[index] ?? '';
|
|
24
|
+
const code = redacted.charCodeAt(index);
|
|
25
|
+
safe += code < 32 && ![9, 10, 13].includes(code) ? ' ' : character;
|
|
26
|
+
}
|
|
27
|
+
return safe.trim().slice(0, maximum);
|
|
28
|
+
};
|
|
29
|
+
exports.redactText = redactText;
|
package/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "7.5.
|
|
1
|
+
export declare const VERSION = "7.5.23";
|
package/cjs/version.js
CHANGED
package/lib/AiLiveAssist.d.ts
CHANGED
|
@@ -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.
|
|
37
|
+
readonly version = "7.5.23";
|
|
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)
|
|
@@ -235,6 +238,9 @@ export class RealtimeCommerce {
|
|
|
235
238
|
}
|
|
236
239
|
},
|
|
237
240
|
onDisplayed: (resultSetId, products) => {
|
|
241
|
+
// The empty-state UI is visible, but the protocol acknowledges product cards only.
|
|
242
|
+
if (products.length === 0)
|
|
243
|
+
return;
|
|
238
244
|
this.context.refresh();
|
|
239
245
|
if (!isCurrent() || resultSetId !== event.catalog.resultSetId ||
|
|
240
246
|
!isDisplayedCommerceProducts(event.catalog, products))
|
package/lib/context.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { redactText } from './privacy/textRedaction.generated.js';
|
|
1
2
|
import { renderSanitizedLayout } from './visualContext.js';
|
|
2
3
|
const MAX_TARGETS = 256;
|
|
3
4
|
const MAX_TEXT_ITEMS = 256;
|
|
4
5
|
const MAX_TOTAL_TEXT = 24000;
|
|
6
|
+
const MAX_RAW_TEXT_NODE = 96000;
|
|
5
7
|
const MAX_OPTIONS = 100;
|
|
6
8
|
const MAX_SELECTED_TEXT = 2000;
|
|
7
9
|
const SELECTION_RETENTION_MS = 120000;
|
|
@@ -664,14 +666,26 @@ const safeOptionLabel = (option) => {
|
|
|
664
666
|
return sensitivityFor(option, label) === 'none' ? label : '';
|
|
665
667
|
};
|
|
666
668
|
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) => {
|
|
669
|
+
const belongsToInteractiveControl = (element, text) => {
|
|
670
|
+
const linkedText = element.closest('a[href],[role="link"]') !== null;
|
|
668
671
|
for (let current = element; current; current = current.parentElement) {
|
|
669
|
-
//
|
|
670
|
-
//
|
|
672
|
+
// Public link text belongs in reading order beside surrounding page copy.
|
|
673
|
+
// Inspect the link's descriptors before sanitized names can erase them;
|
|
674
|
+
// neither those attributes nor the destination become semantic text.
|
|
675
|
+
if (current.matches('a[href],[role="link"]')) {
|
|
676
|
+
if (sensitivityFor(current, text) !== 'none' ||
|
|
677
|
+
sensitivityFor(current, normalize(`${current.getAttribute('aria-label') ?? ''} ${current.getAttribute('title') ?? ''}`, 500)) !== 'none' ||
|
|
678
|
+
accessibleNameSourceSensitivity(current) !== 'none')
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
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"]'))
|
|
682
|
+
return true;
|
|
683
|
+
// Form copy can carry useful public instructions. Actual control text
|
|
684
|
+
// stays in targets, including links nested inside controls.
|
|
671
685
|
if (current.matches('form'))
|
|
672
686
|
continue;
|
|
673
687
|
// A bare tabindex is often a focusable Framer content card, not an action.
|
|
674
|
-
if (current.matches('
|
|
688
|
+
if (current.matches('button,input,select,textarea,summary,[contenteditable="true"],[role="button"],[role="checkbox"],[role="radio"],[role="combobox"],[role="textbox"]'))
|
|
675
689
|
return true;
|
|
676
690
|
}
|
|
677
691
|
return false;
|
|
@@ -1241,22 +1255,60 @@ export class PageContextCollector {
|
|
|
1241
1255
|
const textElement = semanticTextElement && isRendered(semanticTextElement)
|
|
1242
1256
|
? semanticTextElement
|
|
1243
1257
|
: node.nodeType === Node.TEXT_NODE ? parent : null;
|
|
1244
|
-
const
|
|
1245
|
-
(node.nodeType === Node.TEXT_NODE ? node.textContent ?? '' : '')
|
|
1258
|
+
const rawText = semanticTextElement?.getAttribute('aria-label') ??
|
|
1259
|
+
(node.nodeType === Node.TEXT_NODE ? node.textContent ?? '' : '');
|
|
1260
|
+
const normalizedText = normalize(rawText.slice(0, MAX_RAW_TEXT_NODE), MAX_RAW_TEXT_NODE);
|
|
1261
|
+
const text = normalizedText.slice(0, 500);
|
|
1246
1262
|
if (parent &&
|
|
1247
1263
|
textElement &&
|
|
1248
|
-
text &&
|
|
1264
|
+
(text || rawText.length > MAX_RAW_TEXT_NODE) &&
|
|
1249
1265
|
!parent.closest(PRIVATE_SELECTOR) &&
|
|
1250
1266
|
!parent.closest('script,style,noscript,template,svg') &&
|
|
1251
1267
|
!parent.closest('input,select,textarea,option') &&
|
|
1252
1268
|
(!semanticTextElement || !capturedSemanticText.has(semanticTextElement)) &&
|
|
1253
|
-
!belongsToInteractiveControl(textElement) &&
|
|
1269
|
+
!belongsToInteractiveControl(textElement, normalizedText) &&
|
|
1254
1270
|
isRendered(textElement) &&
|
|
1255
1271
|
sensitivityFor(textElement, nameFor(textElement)) === 'none') {
|
|
1256
1272
|
const textId = this.textIds.get(node) ?? id('text');
|
|
1257
1273
|
this.textIds.set(node, textId);
|
|
1258
|
-
|
|
1259
|
-
|
|
1274
|
+
// Fail closed on unusually large nodes instead of redacting a partial
|
|
1275
|
+
// credential or adding an unbounded full-node redaction pass.
|
|
1276
|
+
if (rawText.length > MAX_RAW_TEXT_NODE) {
|
|
1277
|
+
truncated = true;
|
|
1278
|
+
node = walker.nextNode();
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
// Normalize the whole bounded node before the native text policy so
|
|
1282
|
+
// whitespace-separated credentials cannot evade redaction at a cut.
|
|
1283
|
+
const safeText = redactText(normalizedText, MAX_TOTAL_TEXT + 1);
|
|
1284
|
+
let offset = 0;
|
|
1285
|
+
let chunkIndex = 0;
|
|
1286
|
+
while (offset < safeText.length && visibleText.length < MAX_TEXT_ITEMS && totalText < MAX_TOTAL_TEXT) {
|
|
1287
|
+
let end = Math.min(offset + 500, offset + MAX_TOTAL_TEXT - totalText, safeText.length);
|
|
1288
|
+
// Prefer sentence/word boundaries without reserving more payload.
|
|
1289
|
+
if (end < safeText.length) {
|
|
1290
|
+
const window = safeText.slice(offset, end);
|
|
1291
|
+
const sentences = Array.from(window.matchAll(/[.!?] (?=\S)/g));
|
|
1292
|
+
const sentenceEnd = sentences[sentences.length - 1]?.index;
|
|
1293
|
+
const wordEnd = window.lastIndexOf(' ');
|
|
1294
|
+
if (sentenceEnd !== undefined && sentenceEnd >= 249)
|
|
1295
|
+
end = offset + sentenceEnd + 2;
|
|
1296
|
+
else if (wordEnd > 0)
|
|
1297
|
+
end = offset + wordEnd + 1;
|
|
1298
|
+
}
|
|
1299
|
+
// A hard token/budget boundary must not split a UTF-16 pair.
|
|
1300
|
+
if (end < safeText.length && /[\uD800-\uDBFF]/.test(safeText[end - 1]))
|
|
1301
|
+
end -= 1;
|
|
1302
|
+
if (end === offset)
|
|
1303
|
+
break;
|
|
1304
|
+
const chunk = safeText.slice(offset, end);
|
|
1305
|
+
visibleText.push({ id: chunkIndex === 0 ? textId : `${textId}.${chunkIndex}`, text: chunk, provenance: 'page' });
|
|
1306
|
+
totalText += chunk.length;
|
|
1307
|
+
offset = end;
|
|
1308
|
+
chunkIndex += 1;
|
|
1309
|
+
}
|
|
1310
|
+
if (offset < safeText.length)
|
|
1311
|
+
truncated = true;
|
|
1260
1312
|
if (semanticTextElement)
|
|
1261
1313
|
capturedSemanticText.add(semanticTextElement);
|
|
1262
1314
|
}
|
package/lib/guideAdmission.d.ts
CHANGED
|
@@ -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
|
|
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>;
|
package/lib/guideAdmission.js
CHANGED
|
@@ -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
|
-
|
|
174
|
-
|
|
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 ? [
|
|
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.
|
|
2
|
+
export declare const GUIDE_MEASUREMENT_CLIENT_VERSION = "7.5.23";
|
|
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>;
|
package/lib/guideMeasurement.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.
|
|
1
|
+
export const GUIDE_MEASUREMENT_CLIENT_VERSION = '7.5.23';
|
|
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
|
+
}
|
package/lib/guideTypes.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
export declare const LIVE_CONTROL_CLIENT_VERSION = "7.5.23";
|
|
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 = {
|
|
@@ -218,6 +218,9 @@ export class LiveControlChannel {
|
|
|
218
218
|
return true;
|
|
219
219
|
}
|
|
220
220
|
acknowledgeCommerceCatalog(value) {
|
|
221
|
+
// The empty-state UI is visible, but the protocol acknowledges product cards only.
|
|
222
|
+
if (value.products.length === 0)
|
|
223
|
+
return false;
|
|
221
224
|
const current = this.commerceCatalog;
|
|
222
225
|
const commerce = this.options.commerce;
|
|
223
226
|
if (!this.commerceNegotiated || !current || !commerce || !this.commerceTask || !parseLiveCommerceCatalog(current, commerce.bootstrap, commerce.currentContext(), this.commerceTask, this.clock.wallNow(), { cartNegotiated: this.commerceCartNegotiated }) ||
|
|
@@ -425,7 +428,7 @@ export class LiveControlChannel {
|
|
|
425
428
|
stack.pop();
|
|
426
429
|
else if (data.slice((match.index ?? 0) + match[0].length).trimStart().startsWith(':')) {
|
|
427
430
|
const key = JSON.parse(match[0]);
|
|
428
|
-
const keys = stack.
|
|
431
|
+
const keys = stack[stack.length - 1];
|
|
429
432
|
if (!keys || keys.has(key))
|
|
430
433
|
throw unavailable();
|
|
431
434
|
keys.add(key);
|
|
@@ -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
|
|
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();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const redactText: (value: string, maximum?: number) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Generated from ai-live-assist/src/security/textRedaction.ts. Do not edit.
|
|
2
|
+
// Source SHA256: 23840bc803a386b537b4104c4e8d92c7faa7ec0643efff8284bc825d7731e257
|
|
3
|
+
const secretValuePatterns = [
|
|
4
|
+
// Compact signed JWTs remain credentials even without a Bearer prefix or a
|
|
5
|
+
// secret-looking field name (for example guideMeasurement.assignment).
|
|
6
|
+
/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?![A-Za-z0-9_-])/g,
|
|
7
|
+
/\b(?:assignment[_ -]?credential|analytics[_ -]?(?:receipt|proof))["']?\s*[:=]\s*["']?[^\s,;"']{2,}["']?/gi,
|
|
8
|
+
/\b(?:password|passphrase|secret|token|api[_ -]?key|authorization|cookie|otp|one[- ]time(?: code)?|verification code|cvv|cvc|card number|routing number|iban|private[_ -]?key)\s*[:=]\s*["']?[^\s,;"']{2,}["']?/gi,
|
|
9
|
+
/\b(?:sk|rk|pk)-[A-Za-z0-9_-]{16,}\b/g,
|
|
10
|
+
/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*\b/gi,
|
|
11
|
+
/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
|
|
12
|
+
/\b(?:\d[ -]*?){13,19}\b/g,
|
|
13
|
+
];
|
|
14
|
+
export const redactText = (value, maximum = 2000) => {
|
|
15
|
+
let redacted = value;
|
|
16
|
+
for (const pattern of secretValuePatterns)
|
|
17
|
+
redacted = redacted.replace(pattern, '[REDACTED]');
|
|
18
|
+
let safe = '';
|
|
19
|
+
for (let index = 0; index < redacted.length; index += 1) {
|
|
20
|
+
const character = redacted[index] ?? '';
|
|
21
|
+
const code = redacted.charCodeAt(index);
|
|
22
|
+
safe += code < 32 && ![9, 10, 13].includes(code) ? ' ' : character;
|
|
23
|
+
}
|
|
24
|
+
return safe.trim().slice(0, maximum);
|
|
25
|
+
};
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "7.5.
|
|
1
|
+
export declare const VERSION = "7.5.23";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '7.5.
|
|
1
|
+
export const VERSION = '7.5.23';
|
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.
|
|
4
|
+
"version": "7.5.23",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-live-assist",
|
|
7
7
|
"webrtc",
|
|
@@ -44,12 +44,13 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "node scripts/generateLocales.mjs && rm -rf lib cjs && tsc --project tsconfig.json && tsc --project tsconfig-cjs.json && printf '{ \"type\": \"commonjs\" }\\n' > cjs/package.json",
|
|
47
|
+
"build": "node scripts/generateTextRedaction.mjs --check && node scripts/generateLocales.mjs && rm -rf lib cjs && tsc --project tsconfig.json && tsc --project tsconfig-cjs.json && printf '{ \"type\": \"commonjs\" }\\n' > cjs/package.json",
|
|
48
48
|
"locales:generate": "node scripts/generateLocales.mjs",
|
|
49
49
|
"lint": "eslint src --ext .ts --max-warnings=0",
|
|
50
|
-
"test": "jest --coverage=false --runInBand",
|
|
51
|
-
"test:ci": "jest --coverage=true --runInBand",
|
|
52
|
-
"prepublishOnly": "bun run test && bun run build"
|
|
50
|
+
"test": "node scripts/generateTextRedaction.mjs --check && jest --coverage=false --runInBand",
|
|
51
|
+
"test:ci": "node scripts/generateTextRedaction.mjs --check && jest --coverage=true --runInBand",
|
|
52
|
+
"prepublishOnly": "bun run test && bun run build",
|
|
53
|
+
"text-redaction:generate": "node scripts/generateTextRedaction.mjs"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"@oxvo/browser": ">=7.4.50"
|