@atlaskit/editor-plugin-autocomplete 4.1.0 → 4.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-autocomplete
2
2
 
3
+ ## 4.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`18ab4e3c6ed23`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/18ab4e3c6ed23) -
8
+ Include asset files in the published package so they render correctly for consumers.
9
+ - [`96ceccb98c3b9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/96ceccb98c3b9) -
10
+ Add a `surface` attribute to editor autocomplete analytics and UFO experience metadata, and wire
11
+ it through the plugin lifecycle.
12
+
13
+ Host integrations now pass explicit surface values:
14
+ - Confluence comments uses `confluence-comments`
15
+ - Rovo chat uses `rovo-chat`
16
+
17
+ This improves cross-surface tracking clarity while keeping surface values consumer-defined.
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 4.1.0
4
22
 
5
23
  ### Minor Changes
@@ -242,7 +242,8 @@ var isEnglishLocale = function isEnglishLocale(locale) {
242
242
  return locale.toLowerCase().startsWith('en');
243
243
  };
244
244
  var createAutocompletePlugin = exports.createAutocompletePlugin = function createAutocompletePlugin(options, api) {
245
- var _options$locale;
245
+ var _options$surface, _options$locale;
246
+ var surface = (_options$surface = options === null || options === void 0 ? void 0 : options.surface) !== null && _options$surface !== void 0 ? _options$surface : 'editor';
246
247
  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;
247
248
  var isAutocompleteEnabled = isEnglishLocale(locale);
248
249
  var debounceTimer = null;
@@ -290,7 +291,8 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
290
291
  eventType: _analytics.EVENT_TYPE.TRACK,
291
292
  attributes: {
292
293
  completionSource: getCompletionSource(),
293
- reason: reason
294
+ reason: reason,
295
+ surface: surface
294
296
  }
295
297
  });
296
298
  };
@@ -305,7 +307,8 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
305
307
  embeddingModelId: info.embeddingModelId,
306
308
  loadDurationMs: info.loadDurationMs,
307
309
  gpuVendor: info.capabilities.vendor,
308
- gpuArchitecture: info.capabilities.architecture
310
+ gpuArchitecture: info.capabilities.architecture,
311
+ surface: surface
309
312
  }
310
313
  });
311
314
  };
@@ -327,7 +330,8 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
327
330
  maxBufferSizeMB: capabilities.maxBufferSizeMB,
328
331
  maxStorageBufferBindingSizeMB: capabilities.maxStorageBufferBindingSizeMB,
329
332
  gpuVendor: capabilities.vendor,
330
- gpuArchitecture: capabilities.architecture
333
+ gpuArchitecture: capabilities.architecture,
334
+ surface: surface
331
335
  }
332
336
  });
333
337
  };
@@ -344,17 +348,20 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
344
348
  completionSource: getCompletionSource(),
345
349
  suggestionLength: suggestionLength,
346
350
  typedLength: typedLength,
347
- kssDelta: kssDelta
351
+ kssDelta: kssDelta,
352
+ surface: surface
348
353
  }
349
354
  });
350
355
  };
351
356
  var slowLaneClient = options !== null && options !== void 0 && options.useLocalModel ? (0, _localSlowLaneClient.createLocalSlowLaneClient)({
352
357
  debounceMs: LOCAL_SLOW_LANE_DEBOUNCE_MS,
353
358
  onLoadSuccess: fireLocalModelLoadedAnalytics,
354
- onLoadError: fireLocalModelLoadFailedAnalytics
359
+ onLoadError: fireLocalModelLoadFailedAnalytics,
360
+ surface: surface
355
361
  }) : (0, _slowLaneClient.createSlowLaneClient)({
356
362
  baseUrl: '',
357
- debounceMs: NETWORK_SLOW_LANE_DEBOUNCE_MS
363
+ debounceMs: NETWORK_SLOW_LANE_DEBOUNCE_MS,
364
+ surface: surface
358
365
  });
359
366
  (0, _slowLaneClient.setDefaultSlowLaneClient)(slowLaneClient);
360
367
  var contextRequestInFlight = false;
@@ -525,7 +532,8 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
525
532
  actionSubject: _analytics.ACTION_SUBJECT.CONTEXTUAL_TYPEAHEAD,
526
533
  eventType: _analytics.EVENT_TYPE.TRACK,
527
534
  attributes: {
528
- completionSource: getCompletionSource()
535
+ completionSource: getCompletionSource(),
536
+ surface: surface
529
537
  }
530
538
  });
531
539
  }
@@ -649,7 +657,8 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
649
657
  return false;
650
658
  }
651
659
  (0, _textPredictor.loadDefaultVocabulary)({
652
- isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false
660
+ isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false,
661
+ surface: surface
653
662
  }).catch(function (error) {
654
663
  (0, _monitoring.logException)(error, {
655
664
  location: 'editor-plugin-autocomplete/loadDefaultVocabulary'
@@ -657,7 +666,8 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
657
666
  });
658
667
  (0, _textPredictor.loadVectorsAsync)({
659
668
  getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl,
660
- isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false
669
+ isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false,
670
+ surface: surface
661
671
  }).catch(function (error) {
662
672
  (0, _monitoring.logException)(error, {
663
673
  location: 'editor-plugin-autocomplete/loadVectorsAsync'
@@ -631,7 +631,8 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
631
631
  onLoadSuccess = config.onLoadSuccess,
632
632
  _config$modelId = config.modelId,
633
633
  modelId = _config$modelId === void 0 ? LOCAL_MLC_CAUSAL_MODEL_ID : _config$modelId,
634
- customModelConfig = config.customModelConfig;
634
+ customModelConfig = config.customModelConfig,
635
+ surface = config.surface;
635
636
 
636
637
  // ── State ──────────────────────────────────────────────────────────────
637
638
  var storedContextVector = null;
@@ -1002,10 +1003,12 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
1002
1003
  // the try — post engine-init (parity with the network fetch, which
1003
1004
  // excludes the one-time model load) and so the catch below always
1004
1005
  // terminates the experience, even on a synchronous throw.
1005
- (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
1006
+ (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, _objectSpread({
1006
1007
  textLength: text.length,
1007
1008
  isLocalLLM: true
1008
- });
1009
+ }, surface ? {
1010
+ surface: surface
1011
+ } : {}));
1009
1012
  tStart = performance.now();
1010
1013
  tLmDone = 0;
1011
1014
  tEmbDone = 0;
@@ -1038,9 +1041,11 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
1038
1041
  _context4.next = 4;
1039
1042
  break;
1040
1043
  }
1041
- (0, _ufo.abortExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', {
1044
+ (0, _ufo.abortExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', _objectSpread({
1042
1045
  isLocalLLM: true
1043
- });
1046
+ }, surface ? {
1047
+ surface: surface
1048
+ } : {}));
1044
1049
  return _context4.abrupt("return");
1045
1050
  case 4:
1046
1051
  // ── LM logits: whole-word BE-parity payload ──────────────────
@@ -1092,12 +1097,14 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
1092
1097
  // eslint-disable-next-line no-console
1093
1098
  console.groupEnd();
1094
1099
  }
1095
- (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
1100
+ (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, _objectSpread({
1096
1101
  textLength: text.length,
1097
1102
  hasVector: storedContextVector !== null,
1098
1103
  hasLmLogits: storedLmLogits !== null,
1099
1104
  isLocalLLM: true
1100
- });
1105
+ }, surface ? {
1106
+ surface: surface
1107
+ } : {}));
1101
1108
  onUpdate === null || onUpdate === void 0 || onUpdate({
1102
1109
  textLength: text.length,
1103
1110
  hasVector: storedContextVector !== null,
@@ -1112,17 +1119,21 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
1112
1119
  _context4.next = 6;
1113
1120
  break;
1114
1121
  }
1115
- (0, _ufo.abortExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', {
1122
+ (0, _ufo.abortExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, destroyed ? 'destroyed' : 'superseded', _objectSpread({
1116
1123
  isLocalLLM: true
1117
- });
1124
+ }, surface ? {
1125
+ surface: surface
1126
+ } : {}));
1118
1127
  return _context4.abrupt("return");
1119
1128
  case 6:
1120
1129
  storedContextVector = null;
1121
1130
  storedLmLogits = null;
1122
- (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, {
1131
+ (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, experienceId, _objectSpread({
1123
1132
  errorType: 'inference',
1124
1133
  isLocalLLM: true
1125
- });
1134
+ }, surface ? {
1135
+ surface: surface
1136
+ } : {}));
1126
1137
  onUpdate === null || onUpdate === void 0 || onUpdate({
1127
1138
  textLength: text.length,
1128
1139
  hasVector: false,
@@ -7,10 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.setDefaultSlowLaneClient = exports.isWordBoundary = exports.getStoredLmLogits = exports.getStoredContextVector = exports.createSlowLaneClient = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _ufo = require("../analytics/ufo");
12
13
  var _debugMode = require("./debug-mode");
13
- /**
14
+ 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; }
15
+ 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) { (0, _defineProperty2.default)(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; } /**
14
16
  * Slow Lane Client: Backend context encoding for autocomplete.
15
17
  *
16
18
  * Fires a BE request on word boundaries to encode document context.
@@ -18,7 +20,6 @@ var _debugMode = require("./debug-mode");
18
20
  * Request: { text, session_id }
19
21
  * Response: { semantic_vector: number[], lm_logits: Record<string, number> }
20
22
  */
21
-
22
23
  // ─── Types ───────────────────────────────────────────────────────────────────
23
24
 
24
25
  /** Request payload for typeahead-encodings endpoint. */
@@ -51,6 +52,7 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
51
52
  configSessionId = config.sessionId,
52
53
  _config$productKey = config.productKey,
53
54
  productKey = _config$productKey === void 0 ? 'confluence' : _config$productKey,
55
+ surface = config.surface,
54
56
  _config$endpoint = config.endpoint,
55
57
  endpoint = _config$endpoint === void 0 ? '/gateway/api/v1/autocomplete/typeahead-encodings' : _config$endpoint,
56
58
  _config$debounceMs = config.debounceMs,
@@ -87,10 +89,12 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
87
89
  text: text,
88
90
  session_id: sessionId
89
91
  };
90
- (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
92
+ (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
91
93
  textLength: text.length,
92
94
  isLocalLLM: false
93
- });
95
+ }, surface ? {
96
+ surface: surface
97
+ } : {}));
94
98
  if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
95
99
  // eslint-disable-next-line no-console
96
100
  console.groupCollapsed("%c[SlowLane] %c\uD83D\uDCE4 Sending context | ".concat(text.length, " chars"), 'color: #9c27b0; font-weight: bold;', 'color: inherit;');
@@ -116,11 +120,13 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
116
120
  }
117
121
  storedContextVector = null;
118
122
  storedLmLogits = null;
119
- (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
123
+ (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
120
124
  status: res.status,
121
125
  errorType: 'http_error',
122
126
  isLocalLLM: false
123
- });
127
+ }, surface ? {
128
+ surface: surface
129
+ } : {}));
124
130
  if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
125
131
  // eslint-disable-next-line no-console
126
132
  console.log("%c[SlowLane] %c\u274C Request failed (".concat(res.status, ")"), 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
@@ -151,12 +157,14 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
151
157
  // eslint-disable-next-line no-console
152
158
  console.groupEnd();
153
159
  }
154
- (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
160
+ (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
155
161
  textLength: text.length,
156
162
  hasVector: storedContextVector !== null,
157
163
  hasLmLogits: storedLmLogits !== null,
158
164
  isLocalLLM: false
159
- });
165
+ }, surface ? {
166
+ surface: surface
167
+ } : {}));
160
168
  onUpdate === null || onUpdate === void 0 || onUpdate({
161
169
  textLength: text.length,
162
170
  hasVector: storedContextVector !== null,
@@ -170,10 +178,12 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
170
178
  _t = _context["catch"](2);
171
179
  storedContextVector = null;
172
180
  storedLmLogits = null;
173
- (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
181
+ (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, _objectSpread({
174
182
  errorType: 'network',
175
183
  isLocalLLM: false
176
- });
184
+ }, surface ? {
185
+ surface: surface
186
+ } : {}));
177
187
  if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
178
188
  // eslint-disable-next-line no-console
179
189
  console.log('%c[SlowLane] %c❌ Network error — context cleared', 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
@@ -202,9 +212,11 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
202
212
  debounceTimer = setTimeout(function () {
203
213
  debounceTimer = null;
204
214
  if (inflightRequestId !== null) {
205
- (0, _ufo.abortExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, inflightRequestId, 'superseded', {
215
+ (0, _ufo.abortExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, inflightRequestId, 'superseded', _objectSpread({
206
216
  isLocalLLM: false
207
- });
217
+ }, surface ? {
218
+ surface: surface
219
+ } : {}));
208
220
  }
209
221
  var requestId = String(++requestSeq);
210
222
  inflightRequestId = requestId;
@@ -18,6 +18,8 @@ var _debugMode = require("./debug-mode");
18
18
  var _scoringPipeline = require("./scoring-pipeline");
19
19
  var _slowLaneClient = require("./slow-lane-client");
20
20
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t4 in e) "default" !== _t4 && {}.hasOwnProperty.call(e, _t4) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t4)) && (i.get || i.set) ? o(f, _t4, i) : f[_t4] = e[_t4]); return f; })(e, t); }
21
+ 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; }
22
+ 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) { (0, _defineProperty2.default)(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; }
21
23
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
22
24
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
23
25
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /**
@@ -736,7 +738,7 @@ function unwrapJsonModule(mod, shape) {
736
738
  var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
737
739
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
738
740
  var _options$isLocalLLM;
739
- var isLocalLLM, url, _wordIndexOuter$index, res, buffer, float32, wordIndexModule, wordIndexOuter, wordIndex, nWords, dim, _t, _t2;
741
+ var isLocalLLM, surface, url, _wordIndexOuter$index, res, buffer, float32, wordIndexModule, wordIndexOuter, wordIndex, nWords, dim, _t, _t2;
740
742
  return _regenerator.default.wrap(function (_context) {
741
743
  while (1) switch (_context.prev = _context.next) {
742
744
  case 0:
@@ -755,10 +757,13 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
755
757
  return _context.abrupt("return");
756
758
  case 2:
757
759
  isLocalLLM = (_options$isLocalLLM = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM !== void 0 ? _options$isLocalLLM : false;
760
+ surface = options === null || options === void 0 ? void 0 : options.surface;
758
761
  vectorsLoadStarted = true;
759
- (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
762
+ (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', _objectSpread({
760
763
  isLocalLLM: isLocalLLM
761
- });
764
+ }, surface ? {
765
+ surface: surface
766
+ } : {}));
762
767
  _context.prev = 3;
763
768
  _context.next = 4;
764
769
  return options.getBinaryUrl();
@@ -770,10 +775,12 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
770
775
  _context.prev = 5;
771
776
  _t = _context["catch"](3);
772
777
  vectorsLoadStarted = false;
773
- (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
778
+ (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', _objectSpread({
774
779
  isLocalLLM: isLocalLLM,
775
780
  errorType: 'resolve_url'
776
- });
781
+ }, surface ? {
782
+ surface: surface
783
+ } : {}));
777
784
  // eslint-disable-next-line no-console
778
785
  console.warn('[text-predictor] Failed to resolve vectors URL:', _t);
779
786
  return _context.abrupt("return");
@@ -788,11 +795,13 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
788
795
  break;
789
796
  }
790
797
  vectorsLoadStarted = false;
791
- (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
798
+ (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', _objectSpread({
792
799
  isLocalLLM: isLocalLLM,
793
800
  status: res.status,
794
801
  errorType: 'http_error'
795
- });
802
+ }, surface ? {
803
+ surface: surface
804
+ } : {}));
796
805
  // eslint-disable-next-line no-console
797
806
  console.warn("[text-predictor] Failed to load vectors: ".concat(res.status));
798
807
  return _context.abrupt("return");
@@ -823,12 +832,14 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
823
832
  wordIndex: wordIndex,
824
833
  dim: dim
825
834
  };
826
- (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
835
+ (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', _objectSpread({
827
836
  isLocalLLM: isLocalLLM,
828
837
  wordCount: nWords,
829
838
  dim: dim,
830
839
  sizeBytes: float32.byteLength
831
- });
840
+ }, surface ? {
841
+ surface: surface
842
+ } : {}));
832
843
  if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
833
844
  // eslint-disable-next-line no-console
834
845
  console.log('[text-predictor] Vectors loaded:', {
@@ -843,10 +854,12 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
843
854
  _context.prev = 11;
844
855
  _t2 = _context["catch"](6);
845
856
  vectorsLoadStarted = false;
846
- (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
857
+ (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', _objectSpread({
847
858
  isLocalLLM: isLocalLLM,
848
859
  errorType: 'network'
849
- });
860
+ }, surface ? {
861
+ surface: surface
862
+ } : {}));
850
863
  // eslint-disable-next-line no-console
851
864
  console.warn('[text-predictor] Failed to load vectors:', _t2);
852
865
  case 12:
@@ -872,14 +885,17 @@ var loadDefaultVocabulary = exports.loadDefaultVocabulary = function loadDefault
872
885
  return vocabularyLoadPromise;
873
886
  }
874
887
  var isLocalLLM = (_options$isLocalLLM2 = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM2 !== void 0 ? _options$isLocalLLM2 : false;
888
+ var surface = options === null || options === void 0 ? void 0 : options.surface;
875
889
  vocabularyLoadPromise = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
876
890
  var _yield$Promise$all, _yield$Promise$all2, vocabularyModule, l3VocabularyModule, vocabularyData, l3VocabularyData, terms, _t3;
877
891
  return _regenerator.default.wrap(function (_context2) {
878
892
  while (1) switch (_context2.prev = _context2.next) {
879
893
  case 0:
880
- (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
894
+ (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', _objectSpread({
881
895
  isLocalLLM: isLocalLLM
882
- });
896
+ }, surface ? {
897
+ surface: surface
898
+ } : {}));
883
899
  _context2.prev = 1;
884
900
  _context2.next = 2;
885
901
  return Promise.all([Promise.resolve().then(function () {
@@ -917,20 +933,24 @@ var loadDefaultVocabulary = exports.loadDefaultVocabulary = function loadDefault
917
933
  initVocabulary({
918
934
  terms: terms
919
935
  });
920
- (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
936
+ (0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', _objectSpread({
921
937
  isLocalLLM: isLocalLLM,
922
938
  l2WordCount: terms.length,
923
939
  l3WordCount: l3VocabularyData.length
924
- });
940
+ }, surface ? {
941
+ surface: surface
942
+ } : {}));
925
943
  _context2.next = 5;
926
944
  break;
927
945
  case 4:
928
946
  _context2.prev = 4;
929
947
  _t3 = _context2["catch"](1);
930
- (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
948
+ (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', _objectSpread({
931
949
  isLocalLLM: isLocalLLM,
932
950
  errorType: 'parse_error'
933
- });
951
+ }, surface ? {
952
+ surface: surface
953
+ } : {}));
934
954
  // Allow a later call to retry the load rather than caching the failure.
935
955
  vocabularyLoadPromise = undefined;
936
956
  throw _t3;
@@ -230,7 +230,8 @@ const isEnglishLocale = locale => {
230
230
  return locale.toLowerCase().startsWith('en');
231
231
  };
232
232
  export const createAutocompletePlugin = (options, api) => {
233
- var _options$locale;
233
+ var _options$surface, _options$locale;
234
+ const surface = (_options$surface = options === null || options === void 0 ? void 0 : options.surface) !== null && _options$surface !== void 0 ? _options$surface : 'editor';
234
235
  const 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;
235
236
  const isAutocompleteEnabled = isEnglishLocale(locale);
236
237
  let debounceTimer = null;
@@ -278,7 +279,8 @@ export const createAutocompletePlugin = (options, api) => {
278
279
  eventType: EVENT_TYPE.TRACK,
279
280
  attributes: {
280
281
  completionSource: getCompletionSource(),
281
- reason
282
+ reason,
283
+ surface
282
284
  }
283
285
  });
284
286
  };
@@ -293,7 +295,8 @@ export const createAutocompletePlugin = (options, api) => {
293
295
  embeddingModelId: info.embeddingModelId,
294
296
  loadDurationMs: info.loadDurationMs,
295
297
  gpuVendor: info.capabilities.vendor,
296
- gpuArchitecture: info.capabilities.architecture
298
+ gpuArchitecture: info.capabilities.architecture,
299
+ surface
297
300
  }
298
301
  });
299
302
  };
@@ -317,7 +320,8 @@ export const createAutocompletePlugin = (options, api) => {
317
320
  maxBufferSizeMB: capabilities.maxBufferSizeMB,
318
321
  maxStorageBufferBindingSizeMB: capabilities.maxStorageBufferBindingSizeMB,
319
322
  gpuVendor: capabilities.vendor,
320
- gpuArchitecture: capabilities.architecture
323
+ gpuArchitecture: capabilities.architecture,
324
+ surface
321
325
  }
322
326
  });
323
327
  };
@@ -334,17 +338,20 @@ export const createAutocompletePlugin = (options, api) => {
334
338
  completionSource: getCompletionSource(),
335
339
  suggestionLength,
336
340
  typedLength,
337
- kssDelta
341
+ kssDelta,
342
+ surface
338
343
  }
339
344
  });
340
345
  };
341
346
  const slowLaneClient = options !== null && options !== void 0 && options.useLocalModel ? createLocalSlowLaneClient({
342
347
  debounceMs: LOCAL_SLOW_LANE_DEBOUNCE_MS,
343
348
  onLoadSuccess: fireLocalModelLoadedAnalytics,
344
- onLoadError: fireLocalModelLoadFailedAnalytics
349
+ onLoadError: fireLocalModelLoadFailedAnalytics,
350
+ surface
345
351
  }) : createSlowLaneClient({
346
352
  baseUrl: '',
347
- debounceMs: NETWORK_SLOW_LANE_DEBOUNCE_MS
353
+ debounceMs: NETWORK_SLOW_LANE_DEBOUNCE_MS,
354
+ surface
348
355
  });
349
356
  setDefaultSlowLaneClient(slowLaneClient);
350
357
  let contextRequestInFlight = false;
@@ -509,7 +516,8 @@ export const createAutocompletePlugin = (options, api) => {
509
516
  actionSubject: ACTION_SUBJECT.CONTEXTUAL_TYPEAHEAD,
510
517
  eventType: EVENT_TYPE.TRACK,
511
518
  attributes: {
512
- completionSource: getCompletionSource()
519
+ completionSource: getCompletionSource(),
520
+ surface
513
521
  }
514
522
  });
515
523
  }
@@ -636,7 +644,8 @@ export const createAutocompletePlugin = (options, api) => {
636
644
  return false;
637
645
  }
638
646
  loadDefaultVocabulary({
639
- isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false
647
+ isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false,
648
+ surface
640
649
  }).catch(error => {
641
650
  logException(error, {
642
651
  location: 'editor-plugin-autocomplete/loadDefaultVocabulary'
@@ -644,7 +653,8 @@ export const createAutocompletePlugin = (options, api) => {
644
653
  });
645
654
  loadVectorsAsync({
646
655
  getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl,
647
- isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false
656
+ isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false,
657
+ surface
648
658
  }).catch(error => {
649
659
  logException(error, {
650
660
  location: 'editor-plugin-autocomplete/loadVectorsAsync'
@@ -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 ──────────────────────────────────────────────────────────────
@@ -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,