@atlaskit/editor-plugin-autocomplete 4.1.0 → 4.1.2

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.
@@ -489,7 +489,8 @@ export const createLocalSlowLaneClient = (config = {}) => {
489
489
  onLoadError,
490
490
  onLoadSuccess,
491
491
  modelId = LOCAL_MLC_CAUSAL_MODEL_ID,
492
- customModelConfig
492
+ customModelConfig,
493
+ surface
493
494
  } = config;
494
495
 
495
496
  // ── State ──────────────────────────────────────────────────────────────
@@ -559,8 +560,8 @@ export const createLocalSlowLaneClient = (config = {}) => {
559
560
  let vendor;
560
561
  let architecture;
561
562
  try {
562
- var _adapter$info, _adapter$requestAdapt;
563
- const info = (_adapter$info = adapter.info) !== null && _adapter$info !== void 0 ? _adapter$info : await ((_adapter$requestAdapt = adapter.requestAdapterInfo) === null || _adapter$requestAdapt === void 0 ? void 0 : _adapter$requestAdapt.call(adapter));
563
+ var _info, _requestAdapterInfo, _ref;
564
+ const info = (_info = adapter.info) !== null && _info !== void 0 ? _info : await ((_requestAdapterInfo = (_ref = adapter).requestAdapterInfo) === null || _requestAdapterInfo === void 0 ? void 0 : _requestAdapterInfo.call(_ref));
564
565
  vendor = (info === null || info === void 0 ? void 0 : info.vendor) || undefined;
565
566
  architecture = (info === null || info === void 0 ? void 0 : info.architecture) || undefined;
566
567
  } catch {
@@ -786,7 +787,10 @@ export const createLocalSlowLaneClient = (config = {}) => {
786
787
  // terminates the experience, even on a synchronous throw.
787
788
  startExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
788
789
  textLength: text.length,
789
- isLocalLLM: true
790
+ isLocalLLM: true,
791
+ ...(surface ? {
792
+ surface
793
+ } : {})
790
794
  });
791
795
  const tStart = performance.now();
792
796
  let tLmDone = 0;
@@ -813,7 +817,10 @@ export const createLocalSlowLaneClient = (config = {}) => {
813
817
  // Discard stale results
814
818
  if (requestId < latestRequestId || destroyed) {
815
819
  abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', {
816
- isLocalLLM: true
820
+ isLocalLLM: true,
821
+ ...(surface ? {
822
+ surface
823
+ } : {})
817
824
  });
818
825
  return;
819
826
  }
@@ -861,7 +868,10 @@ export const createLocalSlowLaneClient = (config = {}) => {
861
868
  textLength: text.length,
862
869
  hasVector: storedContextVector !== null,
863
870
  hasLmLogits: storedLmLogits !== null,
864
- isLocalLLM: true
871
+ isLocalLLM: true,
872
+ ...(surface ? {
873
+ surface
874
+ } : {})
865
875
  });
866
876
  onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate({
867
877
  textLength: text.length,
@@ -872,7 +882,10 @@ export const createLocalSlowLaneClient = (config = {}) => {
872
882
  // Discard errors for stale requests or after teardown
873
883
  if (requestId < latestRequestId || destroyed) {
874
884
  abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', {
875
- isLocalLLM: true
885
+ isLocalLLM: true,
886
+ ...(surface ? {
887
+ surface
888
+ } : {})
876
889
  });
877
890
  return;
878
891
  }
@@ -880,7 +893,10 @@ export const createLocalSlowLaneClient = (config = {}) => {
880
893
  storedLmLogits = null;
881
894
  failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
882
895
  errorType: 'inference',
883
- isLocalLLM: true
896
+ isLocalLLM: true,
897
+ ...(surface ? {
898
+ surface
899
+ } : {})
884
900
  });
885
901
  onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate({
886
902
  textLength: text.length,
@@ -42,6 +42,7 @@ export const createSlowLaneClient = config => {
42
42
  baseUrl,
43
43
  sessionId: configSessionId,
44
44
  productKey = 'confluence',
45
+ surface,
45
46
  endpoint = '/gateway/api/v1/autocomplete/typeahead-encodings',
46
47
  debounceMs = DEFAULT_DEBOUNCE_MS,
47
48
  fetchFn = fetch,
@@ -70,7 +71,10 @@ export const createSlowLaneClient = config => {
70
71
  };
71
72
  startExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
72
73
  textLength: text.length,
73
- isLocalLLM: false
74
+ isLocalLLM: false,
75
+ ...(surface ? {
76
+ surface
77
+ } : {})
74
78
  });
75
79
  if (isAutocompleteDebugEnabled()) {
76
80
  // eslint-disable-next-line no-console
@@ -94,7 +98,10 @@ export const createSlowLaneClient = config => {
94
98
  failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
95
99
  status: res.status,
96
100
  errorType: 'http_error',
97
- isLocalLLM: false
101
+ isLocalLLM: false,
102
+ ...(surface ? {
103
+ surface
104
+ } : {})
98
105
  });
99
106
  if (isAutocompleteDebugEnabled()) {
100
107
  // eslint-disable-next-line no-console
@@ -127,7 +134,10 @@ export const createSlowLaneClient = config => {
127
134
  textLength: text.length,
128
135
  hasVector: storedContextVector !== null,
129
136
  hasLmLogits: storedLmLogits !== null,
130
- isLocalLLM: false
137
+ isLocalLLM: false,
138
+ ...(surface ? {
139
+ surface
140
+ } : {})
131
141
  });
132
142
  onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate({
133
143
  textLength: text.length,
@@ -140,7 +150,10 @@ export const createSlowLaneClient = config => {
140
150
  storedLmLogits = null;
141
151
  failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
142
152
  errorType: 'network',
143
- isLocalLLM: false
153
+ isLocalLLM: false,
154
+ ...(surface ? {
155
+ surface
156
+ } : {})
144
157
  });
145
158
  if (isAutocompleteDebugEnabled()) {
146
159
  // eslint-disable-next-line no-console
@@ -161,7 +174,10 @@ export const createSlowLaneClient = config => {
161
174
  debounceTimer = null;
162
175
  if (inflightRequestId !== null) {
163
176
  abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, inflightRequestId, 'superseded', {
164
- isLocalLLM: false
177
+ isLocalLLM: false,
178
+ ...(surface ? {
179
+ surface
180
+ } : {})
165
181
  });
166
182
  }
167
183
  const requestId = String(++requestSeq);
@@ -599,9 +599,13 @@ export const loadVectorsAsync = async options => {
599
599
  return;
600
600
  }
601
601
  const isLocalLLM = (_options$isLocalLLM = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM !== void 0 ? _options$isLocalLLM : false;
602
+ const surface = options === null || options === void 0 ? void 0 : options.surface;
602
603
  vectorsLoadStarted = true;
603
604
  startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
604
- isLocalLLM
605
+ isLocalLLM,
606
+ ...(surface ? {
607
+ surface
608
+ } : {})
605
609
  });
606
610
  let url;
607
611
  try {
@@ -610,7 +614,10 @@ export const loadVectorsAsync = async options => {
610
614
  vectorsLoadStarted = false;
611
615
  failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
612
616
  isLocalLLM,
613
- errorType: 'resolve_url'
617
+ errorType: 'resolve_url',
618
+ ...(surface ? {
619
+ surface
620
+ } : {})
614
621
  });
615
622
  // eslint-disable-next-line no-console
616
623
  console.warn('[text-predictor] Failed to resolve vectors URL:', e);
@@ -624,7 +631,10 @@ export const loadVectorsAsync = async options => {
624
631
  failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
625
632
  isLocalLLM,
626
633
  status: res.status,
627
- errorType: 'http_error'
634
+ errorType: 'http_error',
635
+ ...(surface ? {
636
+ surface
637
+ } : {})
628
638
  });
629
639
  // eslint-disable-next-line no-console
630
640
  console.warn(`[text-predictor] Failed to load vectors: ${res.status}`);
@@ -654,7 +664,10 @@ export const loadVectorsAsync = async options => {
654
664
  isLocalLLM,
655
665
  wordCount: nWords,
656
666
  dim,
657
- sizeBytes: float32.byteLength
667
+ sizeBytes: float32.byteLength,
668
+ ...(surface ? {
669
+ surface
670
+ } : {})
658
671
  });
659
672
  if (isAutocompleteDebugEnabled()) {
660
673
  // eslint-disable-next-line no-console
@@ -668,7 +681,10 @@ export const loadVectorsAsync = async options => {
668
681
  vectorsLoadStarted = false;
669
682
  failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
670
683
  isLocalLLM,
671
- errorType: 'network'
684
+ errorType: 'network',
685
+ ...(surface ? {
686
+ surface
687
+ } : {})
672
688
  });
673
689
  // eslint-disable-next-line no-console
674
690
  console.warn('[text-predictor] Failed to load vectors:', e);
@@ -687,9 +703,13 @@ export const loadDefaultVocabulary = options => {
687
703
  return vocabularyLoadPromise;
688
704
  }
689
705
  const isLocalLLM = (_options$isLocalLLM2 = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM2 !== void 0 ? _options$isLocalLLM2 : false;
706
+ const surface = options === null || options === void 0 ? void 0 : options.surface;
690
707
  vocabularyLoadPromise = (async () => {
691
708
  startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
692
- isLocalLLM
709
+ isLocalLLM,
710
+ ...(surface ? {
711
+ surface
712
+ } : {})
693
713
  });
694
714
  try {
695
715
  // The L2 vocabulary and L3 word list are code-split into their own async
@@ -717,12 +737,18 @@ export const loadDefaultVocabulary = options => {
717
737
  succeedExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
718
738
  isLocalLLM,
719
739
  l2WordCount: terms.length,
720
- l3WordCount: l3VocabularyData.length
740
+ l3WordCount: l3VocabularyData.length,
741
+ ...(surface ? {
742
+ surface
743
+ } : {})
721
744
  });
722
745
  } catch (e) {
723
746
  failExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
724
747
  isLocalLLM,
725
- errorType: 'parse_error'
748
+ errorType: 'parse_error',
749
+ ...(surface ? {
750
+ surface
751
+ } : {})
726
752
  });
727
753
  // Allow a later call to retry the load rather than caching the failure.
728
754
  vocabularyLoadPromise = undefined;
@@ -235,7 +235,8 @@ var isEnglishLocale = function isEnglishLocale(locale) {
235
235
  return locale.toLowerCase().startsWith('en');
236
236
  };
237
237
  export var createAutocompletePlugin = function createAutocompletePlugin(options, api) {
238
- var _options$locale;
238
+ var _options$surface, _options$locale;
239
+ var surface = (_options$surface = options === null || options === void 0 ? void 0 : options.surface) !== null && _options$surface !== void 0 ? _options$surface : 'editor';
239
240
  var locale = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : typeof navigator !== 'undefined' ? navigator.language : undefined;
240
241
  var isAutocompleteEnabled = isEnglishLocale(locale);
241
242
  var debounceTimer = null;
@@ -283,7 +284,8 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
283
284
  eventType: EVENT_TYPE.TRACK,
284
285
  attributes: {
285
286
  completionSource: getCompletionSource(),
286
- reason: reason
287
+ reason: reason,
288
+ surface: surface
287
289
  }
288
290
  });
289
291
  };
@@ -298,7 +300,8 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
298
300
  embeddingModelId: info.embeddingModelId,
299
301
  loadDurationMs: info.loadDurationMs,
300
302
  gpuVendor: info.capabilities.vendor,
301
- gpuArchitecture: info.capabilities.architecture
303
+ gpuArchitecture: info.capabilities.architecture,
304
+ surface: surface
302
305
  }
303
306
  });
304
307
  };
@@ -320,7 +323,8 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
320
323
  maxBufferSizeMB: capabilities.maxBufferSizeMB,
321
324
  maxStorageBufferBindingSizeMB: capabilities.maxStorageBufferBindingSizeMB,
322
325
  gpuVendor: capabilities.vendor,
323
- gpuArchitecture: capabilities.architecture
326
+ gpuArchitecture: capabilities.architecture,
327
+ surface: surface
324
328
  }
325
329
  });
326
330
  };
@@ -337,17 +341,20 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
337
341
  completionSource: getCompletionSource(),
338
342
  suggestionLength: suggestionLength,
339
343
  typedLength: typedLength,
340
- kssDelta: kssDelta
344
+ kssDelta: kssDelta,
345
+ surface: surface
341
346
  }
342
347
  });
343
348
  };
344
349
  var slowLaneClient = options !== null && options !== void 0 && options.useLocalModel ? createLocalSlowLaneClient({
345
350
  debounceMs: LOCAL_SLOW_LANE_DEBOUNCE_MS,
346
351
  onLoadSuccess: fireLocalModelLoadedAnalytics,
347
- onLoadError: fireLocalModelLoadFailedAnalytics
352
+ onLoadError: fireLocalModelLoadFailedAnalytics,
353
+ surface: surface
348
354
  }) : createSlowLaneClient({
349
355
  baseUrl: '',
350
- debounceMs: NETWORK_SLOW_LANE_DEBOUNCE_MS
356
+ debounceMs: NETWORK_SLOW_LANE_DEBOUNCE_MS,
357
+ surface: surface
351
358
  });
352
359
  setDefaultSlowLaneClient(slowLaneClient);
353
360
  var contextRequestInFlight = false;
@@ -518,7 +525,8 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
518
525
  actionSubject: ACTION_SUBJECT.CONTEXTUAL_TYPEAHEAD,
519
526
  eventType: EVENT_TYPE.TRACK,
520
527
  attributes: {
521
- completionSource: getCompletionSource()
528
+ completionSource: getCompletionSource(),
529
+ surface: surface
522
530
  }
523
531
  });
524
532
  }
@@ -642,7 +650,8 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
642
650
  return false;
643
651
  }
644
652
  loadDefaultVocabulary({
645
- isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false
653
+ isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false,
654
+ surface: surface
646
655
  }).catch(function (error) {
647
656
  logException(error, {
648
657
  location: 'editor-plugin-autocomplete/loadDefaultVocabulary'
@@ -650,7 +659,8 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
650
659
  });
651
660
  loadVectorsAsync({
652
661
  getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl,
653
- isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false
662
+ isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false,
663
+ surface: surface
654
664
  }).catch(function (error) {
655
665
  logException(error, {
656
666
  location: 'editor-plugin-autocomplete/loadVectorsAsync'
@@ -621,7 +621,8 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
621
621
  onLoadSuccess = config.onLoadSuccess,
622
622
  _config$modelId = config.modelId,
623
623
  modelId = _config$modelId === void 0 ? LOCAL_MLC_CAUSAL_MODEL_ID : _config$modelId,
624
- customModelConfig = config.customModelConfig;
624
+ customModelConfig = config.customModelConfig,
625
+ surface = config.surface;
625
626
 
626
627
  // ── State ──────────────────────────────────────────────────────────────
627
628
  var storedContextVector = null;
@@ -675,7 +676,7 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
675
676
  */
676
677
  var probeWebGpuCapabilities = /*#__PURE__*/function () {
677
678
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
678
- var gpu, _adapter$limits, _adapter$limits2, adapter, vendor, architecture, _adapter$info, _adapter$requestAdapt, info, _t, _t2, _t3;
679
+ var gpu, _adapter$limits, _adapter$limits2, adapter, vendor, architecture, _info, _requestAdapterInfo, _ref9, info, _t, _t2, _t3;
679
680
  return _regeneratorRuntime.wrap(function (_context2) {
680
681
  while (1) switch (_context2.prev = _context2.next) {
681
682
  case 0:
@@ -703,16 +704,16 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
703
704
  });
704
705
  case 3:
705
706
  _context2.prev = 3;
706
- if (!((_adapter$info = adapter.info) !== null && _adapter$info !== void 0)) {
707
+ if (!((_info = adapter.info) !== null && _info !== void 0)) {
707
708
  _context2.next = 4;
708
709
  break;
709
710
  }
710
- _t = _adapter$info;
711
+ _t = _info;
711
712
  _context2.next = 6;
712
713
  break;
713
714
  case 4:
714
715
  _context2.next = 5;
715
- return (_adapter$requestAdapt = adapter.requestAdapterInfo) === null || _adapter$requestAdapt === void 0 ? void 0 : _adapter$requestAdapt.call(adapter);
716
+ return (_requestAdapterInfo = (_ref9 = adapter).requestAdapterInfo) === null || _requestAdapterInfo === void 0 ? void 0 : _requestAdapterInfo.call(_ref9);
716
717
  case 5:
717
718
  _t = _context2.sent;
718
719
  case 6:
@@ -804,7 +805,7 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
804
805
  initFailed = true;
805
806
  };
806
807
  var initEngine = /*#__PURE__*/function () {
807
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
808
+ var _ref0 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
808
809
  var capabilities, startTime, _yield$Promise$all3, _yield$Promise$all4, _yield$Promise$all4$, MLCEngineCtor, prebuiltAppConfig, customModelRecord, appConfig, newEngine, loadDurationMs, errorMsg, _t4;
809
810
  return _regeneratorRuntime.wrap(function (_context3) {
810
811
  while (1) switch (_context3.prev = _context3.next) {
@@ -920,7 +921,7 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
920
921
  }, _callee3, null, [[5, 9]]);
921
922
  }));
922
923
  return function initEngine() {
923
- return _ref9.apply(this, arguments);
924
+ return _ref0.apply(this, arguments);
924
925
  };
925
926
  }();
926
927
  var ensureEngineInitialized = function ensureEngineInitialized() {
@@ -947,7 +948,7 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
947
948
  * 384-d semantic vector (passage-encoded; see `wrapForArctic`).
948
949
  */
949
950
  var runInference = /*#__PURE__*/function () {
950
- var _ref0 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(text, requestId) {
951
+ var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(text, requestId) {
951
952
  var experienceId, lmText, semanticText, arcticInput, captureCompletionTime, _data, tStart, tLmDone, tEmbDone, _yield$Promise$all5, _yield$Promise$all6, embeddingResponse, rawLogits, payload, embedding, sumSq, i, topTokens, errorMsg, _t5;
952
953
  return _regeneratorRuntime.wrap(function (_context4) {
953
954
  while (1) switch (_context4.prev = _context4.next) {
@@ -990,10 +991,12 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
990
991
  // the try — post engine-init (parity with the network fetch, which
991
992
  // excludes the one-time model load) and so the catch below always
992
993
  // terminates the experience, even on a synchronous throw.
993
- startExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
994
+ startExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, _objectSpread({
994
995
  textLength: text.length,
995
996
  isLocalLLM: true
996
- });
997
+ }, surface ? {
998
+ surface: surface
999
+ } : {}));
997
1000
  tStart = performance.now();
998
1001
  tLmDone = 0;
999
1002
  tEmbDone = 0;
@@ -1026,9 +1029,11 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
1026
1029
  _context4.next = 4;
1027
1030
  break;
1028
1031
  }
1029
- abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', {
1032
+ abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', _objectSpread({
1030
1033
  isLocalLLM: true
1031
- });
1034
+ }, surface ? {
1035
+ surface: surface
1036
+ } : {}));
1032
1037
  return _context4.abrupt("return");
1033
1038
  case 4:
1034
1039
  // ── LM logits: whole-word BE-parity payload ──────────────────
@@ -1063,29 +1068,31 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
1063
1068
  // eslint-disable-next-line no-console
1064
1069
  console.log(storedLmLogits ? "\u2705 lm_logits: ".concat(Object.keys(storedLmLogits).length, " words") : '❌ No lm_logits');
1065
1070
  if (storedLmLogits) {
1066
- topTokens = Object.entries(storedLmLogits).sort(function (_ref1, _ref10) {
1067
- var _ref11 = _slicedToArray(_ref1, 2),
1068
- a = _ref11[1];
1071
+ topTokens = Object.entries(storedLmLogits).sort(function (_ref10, _ref11) {
1069
1072
  var _ref12 = _slicedToArray(_ref10, 2),
1070
- b = _ref12[1];
1073
+ a = _ref12[1];
1074
+ var _ref13 = _slicedToArray(_ref11, 2),
1075
+ b = _ref13[1];
1071
1076
  return b - a;
1072
1077
  }).slice(0, 10); // eslint-disable-next-line no-console
1073
- console.log('Top 10 predictions:', topTokens.map(function (_ref13) {
1074
- var _ref14 = _slicedToArray(_ref13, 2),
1075
- t = _ref14[0],
1076
- p = _ref14[1];
1078
+ console.log('Top 10 predictions:', topTokens.map(function (_ref14) {
1079
+ var _ref15 = _slicedToArray(_ref14, 2),
1080
+ t = _ref15[0],
1081
+ p = _ref15[1];
1077
1082
  return "".concat(t, ": ").concat((p * 100).toFixed(1), "%");
1078
1083
  }).join(', '));
1079
1084
  }
1080
1085
  // eslint-disable-next-line no-console
1081
1086
  console.groupEnd();
1082
1087
  }
1083
- succeedExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
1088
+ succeedExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, _objectSpread({
1084
1089
  textLength: text.length,
1085
1090
  hasVector: storedContextVector !== null,
1086
1091
  hasLmLogits: storedLmLogits !== null,
1087
1092
  isLocalLLM: true
1088
- });
1093
+ }, surface ? {
1094
+ surface: surface
1095
+ } : {}));
1089
1096
  onUpdate === null || onUpdate === void 0 || onUpdate({
1090
1097
  textLength: text.length,
1091
1098
  hasVector: storedContextVector !== null,
@@ -1100,17 +1107,21 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
1100
1107
  _context4.next = 6;
1101
1108
  break;
1102
1109
  }
1103
- abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', {
1110
+ abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', _objectSpread({
1104
1111
  isLocalLLM: true
1105
- });
1112
+ }, surface ? {
1113
+ surface: surface
1114
+ } : {}));
1106
1115
  return _context4.abrupt("return");
1107
1116
  case 6:
1108
1117
  storedContextVector = null;
1109
1118
  storedLmLogits = null;
1110
- failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
1119
+ failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, _objectSpread({
1111
1120
  errorType: 'inference',
1112
1121
  isLocalLLM: true
1113
- });
1122
+ }, surface ? {
1123
+ surface: surface
1124
+ } : {}));
1114
1125
  onUpdate === null || onUpdate === void 0 || onUpdate({
1115
1126
  textLength: text.length,
1116
1127
  hasVector: false,
@@ -1128,7 +1139,7 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
1128
1139
  }, _callee4, null, [[2, 5]]);
1129
1140
  }));
1130
1141
  return function runInference(_x, _x2) {
1131
- return _ref0.apply(this, arguments);
1142
+ return _ref1.apply(this, arguments);
1132
1143
  };
1133
1144
  }();
1134
1145
 
@@ -1,6 +1,9 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
7
  /**
5
8
  * Slow Lane Client: Backend context encoding for autocomplete.
6
9
  *
@@ -45,6 +48,7 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
45
48
  configSessionId = config.sessionId,
46
49
  _config$productKey = config.productKey,
47
50
  productKey = _config$productKey === void 0 ? 'confluence' : _config$productKey,
51
+ surface = config.surface,
48
52
  _config$endpoint = config.endpoint,
49
53
  endpoint = _config$endpoint === void 0 ? '/gateway/api/v1/autocomplete/typeahead-encodings' : _config$endpoint,
50
54
  _config$debounceMs = config.debounceMs,
@@ -81,10 +85,12 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
81
85
  text: text,
82
86
  session_id: sessionId
83
87
  };
84
- startExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
88
+ startExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
85
89
  textLength: text.length,
86
90
  isLocalLLM: false
87
- });
91
+ }, surface ? {
92
+ surface: surface
93
+ } : {}));
88
94
  if (isAutocompleteDebugEnabled()) {
89
95
  // eslint-disable-next-line no-console
90
96
  console.groupCollapsed("%c[SlowLane] %c\uD83D\uDCE4 Sending context | ".concat(text.length, " chars"), 'color: #9c27b0; font-weight: bold;', 'color: inherit;');
@@ -110,11 +116,13 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
110
116
  }
111
117
  storedContextVector = null;
112
118
  storedLmLogits = null;
113
- failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
119
+ failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
114
120
  status: res.status,
115
121
  errorType: 'http_error',
116
122
  isLocalLLM: false
117
- });
123
+ }, surface ? {
124
+ surface: surface
125
+ } : {}));
118
126
  if (isAutocompleteDebugEnabled()) {
119
127
  // eslint-disable-next-line no-console
120
128
  console.log("%c[SlowLane] %c\u274C Request failed (".concat(res.status, ")"), 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
@@ -145,12 +153,14 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
145
153
  // eslint-disable-next-line no-console
146
154
  console.groupEnd();
147
155
  }
148
- succeedExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
156
+ succeedExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
149
157
  textLength: text.length,
150
158
  hasVector: storedContextVector !== null,
151
159
  hasLmLogits: storedLmLogits !== null,
152
160
  isLocalLLM: false
153
- });
161
+ }, surface ? {
162
+ surface: surface
163
+ } : {}));
154
164
  onUpdate === null || onUpdate === void 0 || onUpdate({
155
165
  textLength: text.length,
156
166
  hasVector: storedContextVector !== null,
@@ -164,10 +174,12 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
164
174
  _t = _context["catch"](2);
165
175
  storedContextVector = null;
166
176
  storedLmLogits = null;
167
- failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
177
+ failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
168
178
  errorType: 'network',
169
179
  isLocalLLM: false
170
- });
180
+ }, surface ? {
181
+ surface: surface
182
+ } : {}));
171
183
  if (isAutocompleteDebugEnabled()) {
172
184
  // eslint-disable-next-line no-console
173
185
  console.log('%c[SlowLane] %c❌ Network error — context cleared', 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
@@ -196,9 +208,11 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
196
208
  debounceTimer = setTimeout(function () {
197
209
  debounceTimer = null;
198
210
  if (inflightRequestId !== null) {
199
- abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, inflightRequestId, 'superseded', {
211
+ abortExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, inflightRequestId, 'superseded', _objectSpread({
200
212
  isLocalLLM: false
201
- });
213
+ }, surface ? {
214
+ surface: surface
215
+ } : {}));
202
216
  }
203
217
  var requestId = String(++requestSeq);
204
218
  inflightRequestId = requestId;