@atlaskit/editor-plugin-autocomplete 6.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/compass.yml +2 -2
  3. package/dist/cjs/analytics/ufo.js +3 -2
  4. package/dist/cjs/pm-plugins/artifacts-manifest.js +210 -0
  5. package/dist/cjs/pm-plugins/autocomplete-plugin.js +10 -2
  6. package/dist/cjs/pm-plugins/local-slow-lane-client.js +68 -153
  7. package/dist/cjs/pm-plugins/scoring-pipeline.js +130 -28
  8. package/dist/cjs/pm-plugins/text-predictor.js +45 -106
  9. package/dist/es2019/analytics/ufo.js +4 -2
  10. package/dist/es2019/pm-plugins/artifacts-manifest.js +126 -0
  11. package/dist/es2019/pm-plugins/autocomplete-plugin.js +10 -2
  12. package/dist/es2019/pm-plugins/local-slow-lane-client.js +8 -78
  13. package/dist/es2019/pm-plugins/scoring-pipeline.js +97 -21
  14. package/dist/es2019/pm-plugins/text-predictor.js +17 -59
  15. package/dist/esm/analytics/ufo.js +3 -2
  16. package/dist/esm/pm-plugins/artifacts-manifest.js +204 -0
  17. package/dist/esm/pm-plugins/autocomplete-plugin.js +10 -2
  18. package/dist/esm/pm-plugins/local-slow-lane-client.js +67 -148
  19. package/dist/esm/pm-plugins/scoring-pipeline.js +128 -26
  20. package/dist/esm/pm-plugins/text-predictor.js +45 -98
  21. package/dist/types/analytics/ufo.d.ts +1 -0
  22. package/dist/types/pm-plugins/artifacts-manifest.d.ts +55 -0
  23. package/dist/types/pm-plugins/autocomplete-plugin.d.ts +5 -11
  24. package/dist/types/pm-plugins/scoring-pipeline.d.ts +14 -0
  25. package/dist/types/pm-plugins/text-predictor.d.ts +0 -1
  26. package/package.json +3 -6
  27. package/src/analytics/ufo.ts +5 -0
  28. package/src/pm-plugins/artifacts-manifest.ts +151 -0
  29. package/src/pm-plugins/autocomplete-plugin.ts +14 -12
  30. package/src/pm-plugins/local-slow-lane-client.ts +10 -92
  31. package/src/pm-plugins/scoring-pipeline.ts +115 -23
  32. package/src/pm-plugins/text-predictor.ts +28 -76
  33. package/dist/cjs/pm-plugins/data/combined_l2_l3_pos_tags.json +0 -73571
  34. package/dist/cjs/pm-plugins/data/first_token_to_words.json +0 -1
  35. package/dist/cjs/pm-plugins/data/ghost_pos_tags.json +0 -43
  36. package/dist/cjs/pm-plugins/data/grammar_transitions_10k.json +0 -46
  37. package/dist/cjs/pm-plugins/data/l3_vocabulary.json +0 -20002
  38. package/dist/cjs/pm-plugins/data/vocabulary_10k.json +0 -38794
  39. package/dist/cjs/pm-plugins/data/word_index_10k.json +0 -7762
  40. package/dist/es2019/pm-plugins/data/combined_l2_l3_pos_tags.json +0 -73571
  41. package/dist/es2019/pm-plugins/data/first_token_to_words.json +0 -1
  42. package/dist/es2019/pm-plugins/data/ghost_pos_tags.json +0 -43
  43. package/dist/es2019/pm-plugins/data/grammar_transitions_10k.json +0 -46
  44. package/dist/es2019/pm-plugins/data/l3_vocabulary.json +0 -20002
  45. package/dist/es2019/pm-plugins/data/vocabulary_10k.json +0 -38794
  46. package/dist/es2019/pm-plugins/data/word_index_10k.json +0 -7762
  47. package/dist/esm/pm-plugins/data/combined_l2_l3_pos_tags.json +0 -73571
  48. package/dist/esm/pm-plugins/data/first_token_to_words.json +0 -1
  49. package/dist/esm/pm-plugins/data/ghost_pos_tags.json +0 -43
  50. package/dist/esm/pm-plugins/data/grammar_transitions_10k.json +0 -46
  51. package/dist/esm/pm-plugins/data/l3_vocabulary.json +0 -20002
  52. package/dist/esm/pm-plugins/data/vocabulary_10k.json +0 -38794
  53. package/dist/esm/pm-plugins/data/word_index_10k.json +0 -7762
  54. package/src/pm-plugins/data/combined_l2_l3_pos_tags.json +0 -73571
  55. package/src/pm-plugins/data/first_token_to_words.json +0 -1
  56. package/src/pm-plugins/data/ghost_pos_tags.json +0 -43
  57. package/src/pm-plugins/data/grammar_transitions_10k.json +0 -46
  58. package/src/pm-plugins/data/l3_vocabulary.json +0 -20002
  59. package/src/pm-plugins/data/vocabulary_10k.json +0 -38794
  60. package/src/pm-plugins/data/word-vectors_10k.bin +0 -3
  61. package/src/pm-plugins/data/word_index_10k.json +0 -7762
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-autocomplete
2
2
 
3
+ ## 8.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 7.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [`7a16264359631`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7a16264359631) -
14
+ Load autocomplete model artifacts from the CDN instead of bundling them. The vocabulary,
15
+ POS/grammar, word-index and word-vectors payloads are now resolved from GET
16
+ /gateway/api/v1/autocomplete/artifacts, so this endpoint must be reachable for autocomplete to
17
+ produce suggestions. BREAKING: the `getVectorsBinaryUrl` plugin option has been removed — the word
18
+ vectors binary URL now always comes from the artifacts manifest, so hosts must stop serving it
19
+ themselves.
20
+
21
+ Rovo chat autocomplete now runs on-device via WebGPU instead of the network slow-lane backend.
22
+
3
23
  ## 6.0.0
4
24
 
5
25
  ### Patch Changes
package/compass.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  configVersion: 1
2
2
  id: ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:component/c5751cc6-3513-4070-9deb-af31e86aed34/45ef6a6c-98b8-4615-940d-e9013db36999
3
3
  name: '@atlaskit/editor-plugin-autocomplete'
4
- ownerId: ari:cloud:identity::team/0250ee69-f755-47fd-a468-bf8a9d10a3c5 # Editor AI
4
+ ownerId: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb # Editor Developers
5
5
  labels:
6
6
  - platform-code
7
7
  - platform-afm
@@ -23,7 +23,7 @@ links:
23
23
  customFields:
24
24
  - name: Department
25
25
  type: text
26
- value: Eng - Editor AI
26
+ value: Editor Developers
27
27
  - name: Trusted Reviewer Teams
28
28
  type: text
29
29
  value: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb
@@ -38,7 +38,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
38
38
  var EXPERIENCE_NAME = exports.EXPERIENCE_NAME = {
39
39
  SLOW_LANE_FETCH: 'slow-lane-fetch',
40
40
  LOAD_VOCABULARY: 'load-vocabulary',
41
- LOAD_VECTORS: 'load-vectors'
41
+ LOAD_VECTORS: 'load-vectors',
42
+ LOAD_GRAMMAR: 'load-grammar'
42
43
  };
43
44
  var isUfoEnabled = function isUfoEnabled() {
44
45
  var _process;
@@ -56,7 +57,7 @@ var operationConfig = {
56
57
  })
57
58
  }
58
59
  };
59
- var experiences = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, EXPERIENCE_NAME.SLOW_LANE_FETCH, new _ufo.ConcurrentExperience(EXPERIENCE_NAME.SLOW_LANE_FETCH, operationConfig)), EXPERIENCE_NAME.LOAD_VOCABULARY, new _ufo.ConcurrentExperience(EXPERIENCE_NAME.LOAD_VOCABULARY, operationConfig)), EXPERIENCE_NAME.LOAD_VECTORS, new _ufo.ConcurrentExperience(EXPERIENCE_NAME.LOAD_VECTORS, operationConfig));
60
+ var experiences = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, EXPERIENCE_NAME.SLOW_LANE_FETCH, new _ufo.ConcurrentExperience(EXPERIENCE_NAME.SLOW_LANE_FETCH, operationConfig)), EXPERIENCE_NAME.LOAD_VOCABULARY, new _ufo.ConcurrentExperience(EXPERIENCE_NAME.LOAD_VOCABULARY, operationConfig)), EXPERIENCE_NAME.LOAD_VECTORS, new _ufo.ConcurrentExperience(EXPERIENCE_NAME.LOAD_VECTORS, operationConfig)), EXPERIENCE_NAME.LOAD_GRAMMAR, new _ufo.ConcurrentExperience(EXPERIENCE_NAME.LOAD_GRAMMAR, operationConfig));
60
61
  var startExp = exports.startExp = function startExp(name, id, metadata) {
61
62
  if (!isUfoEnabled()) {
62
63
  return;
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.resetArtifactsManifestCache = exports.getArtifactUrl = exports.fetchArtifactJson = exports.ARTIFACT_NAME = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _debugMode = require("./debug-mode");
11
+ /**
12
+ * Artifacts Manifest Client: resolves the autocomplete model artifacts hosted on
13
+ * the CDN.
14
+ *
15
+ * `GET /gateway/api/v1/autocomplete/artifacts` returns one presigned CDN URL per
16
+ * artifact for the tenant's active model version:
17
+ *
18
+ * { activeVersion, artifacts: [{ name, url, contentType, sizeBytes, checksum }] }
19
+ *
20
+ * Every loader in the plugin resolves its payload through here, so no model data
21
+ * is bundled with the package.
22
+ */
23
+
24
+ // ─── Types ───────────────────────────────────────────────────────────────────
25
+
26
+ /**
27
+ * Manifest artifact names. These are the manifest's lookup keys and are
28
+ * hyphenated, unlike the underscored filenames the artifacts are generated from.
29
+ */
30
+ var ARTIFACT_NAME = exports.ARTIFACT_NAME = {
31
+ FIRST_TOKEN_TO_WORDS: 'first-token-to-words.json',
32
+ GHOST_POS_TAGS: 'ghost-pos-tags.json',
33
+ GRAMMAR_TRANSITIONS: 'grammar-transitions-10k.json',
34
+ L3_VOCABULARY: 'l3-vocabulary.json',
35
+ POS_TAGS: 'combined-l2-l3-pos-tags.json',
36
+ VOCABULARY: 'vocabulary-10k.json',
37
+ WORD_INDEX: 'word-index-10k.json',
38
+ WORD_VECTORS: 'word-vectors-10k.bin'
39
+ };
40
+
41
+ /** A single entry in the artifacts manifest. */
42
+
43
+ /** Response body of the artifacts endpoint. */
44
+
45
+ // ─── Constants ───────────────────────────────────────────────────────────────
46
+
47
+ var MANIFEST_ENDPOINT = '/gateway/api/v1/autocomplete/artifacts';
48
+
49
+ /**
50
+ * Presigned artifact URLs expire ~10 minutes after the manifest is issued, so
51
+ * the manifest is re-requested well inside that window instead of being cached
52
+ * for the session and handing out dead URLs to a late loader.
53
+ */
54
+ var MANIFEST_TTL_MS = 5 * 60 * 1000;
55
+
56
+ // ─── Manifest ────────────────────────────────────────────────────────────────
57
+
58
+ var manifestPromise;
59
+ var manifestRequestedAt = 0;
60
+
61
+ /** Test-only: drops the memoised manifest so the next lookup re-requests it. */
62
+ var resetArtifactsManifestCache = exports.resetArtifactsManifestCache = function resetArtifactsManifestCache() {
63
+ manifestPromise = undefined;
64
+ manifestRequestedAt = 0;
65
+ };
66
+ var requestManifest = /*#__PURE__*/function () {
67
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
68
+ var res, body;
69
+ return _regenerator.default.wrap(function (_context) {
70
+ while (1) switch (_context.prev = _context.next) {
71
+ case 0:
72
+ _context.next = 1;
73
+ return fetch(MANIFEST_ENDPOINT, {
74
+ method: 'GET',
75
+ headers: {
76
+ 'x-experience-id': 'confluence-smart-typeahead-artifacts',
77
+ 'x-product': 'confluence'
78
+ }
79
+ });
80
+ case 1:
81
+ res = _context.sent;
82
+ if (res.ok) {
83
+ _context.next = 2;
84
+ break;
85
+ }
86
+ throw new Error("[autocomplete-artifacts] Manifest request failed: ".concat(res.status));
87
+ case 2:
88
+ _context.next = 3;
89
+ return res.json();
90
+ case 3:
91
+ body = _context.sent;
92
+ if (!(!Array.isArray(body === null || body === void 0 ? void 0 : body.artifacts) || body.artifacts.length === 0)) {
93
+ _context.next = 4;
94
+ break;
95
+ }
96
+ throw new Error('[autocomplete-artifacts] Manifest response contained no artifacts');
97
+ case 4:
98
+ if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
99
+ // eslint-disable-next-line no-console
100
+ console.log('[autocomplete-artifacts] Manifest loaded:', {
101
+ activeVersion: body.activeVersion,
102
+ names: body.artifacts.map(function (artifact) {
103
+ return artifact.name;
104
+ })
105
+ });
106
+ }
107
+ return _context.abrupt("return", new Map(body.artifacts.map(function (artifact) {
108
+ return [artifact.name, artifact];
109
+ })));
110
+ case 5:
111
+ case "end":
112
+ return _context.stop();
113
+ }
114
+ }, _callee);
115
+ }));
116
+ return function requestManifest() {
117
+ return _ref.apply(this, arguments);
118
+ };
119
+ }();
120
+ var getManifest = function getManifest() {
121
+ if (manifestPromise && Date.now() - manifestRequestedAt < MANIFEST_TTL_MS) {
122
+ return manifestPromise;
123
+ }
124
+ manifestRequestedAt = Date.now();
125
+ manifestPromise = requestManifest().catch(function (e) {
126
+ // Never cache a rejection — a transient failure would otherwise stop every
127
+ // later loader in the session from retrying.
128
+ resetArtifactsManifestCache();
129
+ throw e;
130
+ });
131
+ return manifestPromise;
132
+ };
133
+
134
+ // ─── Public API ──────────────────────────────────────────────────────────────
135
+
136
+ /**
137
+ * Resolve the CDN URL for an artifact.
138
+ *
139
+ * :raises Error: when the manifest cannot be fetched or omits the artifact.
140
+ */
141
+ var getArtifactUrl = exports.getArtifactUrl = /*#__PURE__*/function () {
142
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name) {
143
+ var _manifest$get;
144
+ var manifest, url;
145
+ return _regenerator.default.wrap(function (_context2) {
146
+ while (1) switch (_context2.prev = _context2.next) {
147
+ case 0:
148
+ _context2.next = 1;
149
+ return getManifest();
150
+ case 1:
151
+ manifest = _context2.sent;
152
+ url = (_manifest$get = manifest.get(name)) === null || _manifest$get === void 0 ? void 0 : _manifest$get.url;
153
+ if (url) {
154
+ _context2.next = 2;
155
+ break;
156
+ }
157
+ throw new Error("[autocomplete-artifacts] Manifest has no URL for \"".concat(name, "\""));
158
+ case 2:
159
+ return _context2.abrupt("return", url);
160
+ case 3:
161
+ case "end":
162
+ return _context2.stop();
163
+ }
164
+ }, _callee2);
165
+ }));
166
+ return function getArtifactUrl(_x) {
167
+ return _ref2.apply(this, arguments);
168
+ };
169
+ }();
170
+
171
+ /**
172
+ * Download and parse a JSON artifact. The presigned URL carries its own auth
173
+ * token, so the request is sent without Atlassian headers or credentials.
174
+ *
175
+ * :raises Error: when the manifest lookup or the download fails.
176
+ */
177
+ var fetchArtifactJson = exports.fetchArtifactJson = /*#__PURE__*/function () {
178
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name) {
179
+ var url, res;
180
+ return _regenerator.default.wrap(function (_context3) {
181
+ while (1) switch (_context3.prev = _context3.next) {
182
+ case 0:
183
+ _context3.next = 1;
184
+ return getArtifactUrl(name);
185
+ case 1:
186
+ url = _context3.sent;
187
+ _context3.next = 2;
188
+ return fetch(url);
189
+ case 2:
190
+ res = _context3.sent;
191
+ if (res.ok) {
192
+ _context3.next = 3;
193
+ break;
194
+ }
195
+ throw new Error("[autocomplete-artifacts] Failed to download \"".concat(name, "\": ").concat(res.status));
196
+ case 3:
197
+ _context3.next = 4;
198
+ return res.json();
199
+ case 4:
200
+ return _context3.abrupt("return", _context3.sent);
201
+ case 5:
202
+ case "end":
203
+ return _context3.stop();
204
+ }
205
+ }, _callee3);
206
+ }));
207
+ return function fetchArtifactJson(_x2) {
208
+ return _ref3.apply(this, arguments);
209
+ };
210
+ }();
@@ -16,6 +16,7 @@ var _view = require("@atlaskit/editor-prosemirror/view");
16
16
  var _debugMode = require("./debug-mode");
17
17
  var _ghostTextDecoration = require("./ghost-text-decoration");
18
18
  var _localSlowLaneClient = require("./local-slow-lane-client");
19
+ var _scoringPipeline = require("./scoring-pipeline");
19
20
  var _slowLaneClient = require("./slow-lane-client");
20
21
  var _textPredictor = require("./text-predictor");
21
22
  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; } } }; }
@@ -678,7 +679,7 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
678
679
  return accepted;
679
680
  },
680
681
  focus: function focus() {
681
- var _options$useLocalMode, _options$useLocalMode2;
682
+ var _options$useLocalMode, _options$useLocalMode2, _options$useLocalMode3;
682
683
  if (!isAutocompleteEnabled) {
683
684
  return false;
684
685
  }
@@ -691,7 +692,6 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
691
692
  });
692
693
  });
693
694
  (0, _textPredictor.loadVectorsAsync)({
694
- getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl,
695
695
  isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false,
696
696
  surface: surface
697
697
  }).catch(function (error) {
@@ -699,6 +699,14 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
699
699
  location: 'editor-plugin-autocomplete/loadVectorsAsync'
700
700
  });
701
701
  });
702
+ (0, _scoringPipeline.loadGrammarDataAsync)({
703
+ isLocalLLM: (_options$useLocalMode3 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode3 !== void 0 ? _options$useLocalMode3 : false,
704
+ surface: surface
705
+ }).catch(function (error) {
706
+ (0, _monitoring.logException)(error, {
707
+ location: 'editor-plugin-autocomplete/loadGrammarDataAsync'
708
+ });
709
+ });
702
710
  if (!hasIngestedPage) {
703
711
  hasIngestedPage = true;
704
712
  refreshContext({