@atlaskit/collab-provider 24.1.9 → 24.1.10

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,14 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 24.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`80b19d6c0649f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/80b19d6c0649f) -
8
+ Preserve agent type metadata in collaboration presence participants behind
9
+ `platform_move_presence_agents`.
10
+ - Updated dependencies
11
+
3
12
  ## 24.1.9
4
13
 
5
14
  ### Patch Changes
@@ -16,6 +16,7 @@ var _transform = require("@atlaskit/editor-prosemirror/transform");
16
16
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
17
17
  var _state = require("@atlaskit/editor-prosemirror/state");
18
18
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
19
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
19
20
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
21
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
21
22
  var _const = require("../helpers/const");
@@ -968,7 +969,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
968
969
  }
969
970
  try {
970
971
  var _this$analyticsHelper34;
971
- var providerIds = new Set();
972
+ var agentTypeByProviderId = new Map();
972
973
  var agentIds = new Set();
973
974
  var agentTypes = new Set();
974
975
  var agentStepCount = 0;
@@ -981,12 +982,12 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
981
982
  if (!providerId) {
982
983
  continue;
983
984
  }
984
- providerIds.add(providerId);
985
985
  agentStepCount++;
986
986
  var _ref10 = step,
987
987
  agentId = _ref10.agentId,
988
988
  agentType = _ref10.agentType;
989
989
  if (agentType) {
990
+ agentTypeByProviderId.set(providerId, agentType);
990
991
  agentTypes.add(agentType);
991
992
  }
992
993
  if (agentId) {
@@ -999,7 +1000,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
999
1000
  } finally {
1000
1001
  _iterator.f();
1001
1002
  }
1002
- if (providerIds.size === 0) {
1003
+ if (agentTypeByProviderId.size === 0) {
1003
1004
  return;
1004
1005
  }
1005
1006
  // Anchor signal that the agent-presence logic kicked off for a received transaction. Fires
@@ -1007,13 +1008,13 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
1007
1008
  // non-PII: agent kinds, actor ids, and counts — never document content.
1008
1009
  (_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 || _this$analyticsHelper34.sendActionEvent(_const.EVENT_ACTION.AGENT_EDIT_RECEIVED, _const.EVENT_STATUS.SUCCESS, {
1009
1010
  agentIds: (0, _toConsumableArray2.default)(agentIds),
1010
- agentCount: providerIds.size,
1011
+ agentCount: agentTypeByProviderId.size,
1011
1012
  agentTypes: (0, _toConsumableArray2.default)(agentTypes),
1012
1013
  agentStepCount: agentStepCount,
1013
1014
  totalStepCount: steps.length
1014
1015
  });
1015
- providerIds.forEach(function (providerId) {
1016
- return _this3.participantsService.upsertAIProviderParticipantLocally(providerId);
1016
+ agentTypeByProviderId.forEach(function (agentType, providerId) {
1017
+ return _this3.participantsService.upsertAIProviderParticipantLocally(providerId, (0, _fg.fg)('platform_move_presence_agents') ? agentType : undefined);
1017
1018
  });
1018
1019
  } catch (error) {
1019
1020
  var _this$analyticsHelper35;
@@ -15,11 +15,11 @@ var PARTICIPANT_UPDATE_INTERVAL = exports.PARTICIPANT_UPDATE_INTERVAL = 300 * 10
15
15
  var DEFAULT_BATCH_FETCH_SIZE = 25;
16
16
  var createParticipantFromPayload = exports.createParticipantFromPayload = /*#__PURE__*/function () {
17
17
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(payload, getUser) {
18
- var actingUserId, sessionId, timestamp, clientId, userId, permit, presenceId, presenceActivity, user, participant;
18
+ var actingUserId, agentType, sessionId, timestamp, clientId, userId, permit, presenceId, presenceActivity, user, participant;
19
19
  return _regenerator.default.wrap(function (_context) {
20
20
  while (1) switch (_context.prev = _context.next) {
21
21
  case 0:
22
- actingUserId = payload.actingUserId, sessionId = payload.sessionId, timestamp = payload.timestamp, clientId = payload.clientId, userId = payload.userId, permit = payload.permit, presenceId = payload.presenceId, presenceActivity = payload.presenceActivity;
22
+ actingUserId = payload.actingUserId, agentType = payload.agentType, sessionId = payload.sessionId, timestamp = payload.timestamp, clientId = payload.clientId, userId = payload.userId, permit = payload.permit, presenceId = payload.presenceId, presenceActivity = payload.presenceActivity;
23
23
  _context.next = 1;
24
24
  return getUser === null || getUser === void 0 ? void 0 : getUser(userId);
25
25
  case 1:
@@ -34,6 +34,7 @@ var createParticipantFromPayload = exports.createParticipantFromPayload = /*#__P
34
34
  clientId: clientId,
35
35
  permit: permit,
36
36
  actingUserId: actingUserId,
37
+ agentType: agentType,
37
38
  isGuest: user === null || user === void 0 ? void 0 : user.isGuest,
38
39
  presenceId: presenceId,
39
40
  presenceActivity: presenceActivity,
@@ -106,6 +107,7 @@ var fetchParticipants = exports.fetchParticipants = /*#__PURE__*/function () {
106
107
  clientId: participant.clientId,
107
108
  permit: participant.permit,
108
109
  actingUserId: participant.actingUserId,
110
+ agentType: participant.agentType,
109
111
  presenceId: participant.presenceId,
110
112
  presenceActivity: participant.presenceActivity,
111
113
  isHydrated: true
@@ -88,12 +88,13 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
88
88
  }
89
89
  }
90
90
  });
91
- (0, _defineProperty2.default)(this, "buildAIProviderPresencePayload", function (providerId) {
91
+ (0, _defineProperty2.default)(this, "buildAIProviderPresencePayload", function (providerId, agentType) {
92
92
  var defaultPresenceData = _this.getPresenceData();
93
93
  var presencePayload = {
94
94
  sessionId: "".concat(providerId, "::").concat(defaultPresenceData.sessionId),
95
95
  userId: providerId,
96
96
  clientId: "".concat(providerId, "::").concat(defaultPresenceData.clientId),
97
+ agentType: agentType,
97
98
  permit: {
98
99
  isPermittedToComment: false,
99
100
  isPermittedToEdit: false,
@@ -136,11 +137,13 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
136
137
  * presence consumer on each streamed step.
137
138
  *
138
139
  * @param providerId `agent:<aaid|type>` id of the agent
140
+ * @param agentType kind of the agent that authored the step
139
141
  */
140
- (0, _defineProperty2.default)(this, "upsertAIProviderParticipantLocally", function (providerId) {
141
- var payload = _this.buildAIProviderPresencePayload(providerId);
142
+ (0, _defineProperty2.default)(this, "upsertAIProviderParticipantLocally", function (providerId, agentType) {
143
+ var payload = _this.buildAIProviderPresencePayload(providerId, agentType);
142
144
  var sessionId = payload.sessionId;
143
145
  var existing = _this.participantsState.getBySessionId(sessionId);
146
+ var hasAgentTypeChanged = (existing === null || existing === void 0 ? void 0 : existing.agentType) !== agentType;
144
147
  var wasInactive = existing ? Date.now() - existing.lastActive >= AGENT_PRESENCE_INACTIVE_MS : false;
145
148
  var participant = _objectSpread(_objectSpread(_objectSpread({}, payload), (0, _fg.fg)('platform_move_presence_agents') ? {
146
149
  presenceActivity: 'editor'
@@ -160,7 +163,7 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
160
163
 
161
164
  // Active refreshes stay silent. Re-emit when an inactive agent becomes active so consumers
162
165
  // can update its presentation immediately.
163
- if (!existing || (0, _fg.fg)('platform_move_presence_agents') && wasInactive) {
166
+ if (!existing || hasAgentTypeChanged || (0, _fg.fg)('platform_move_presence_agents') && wasInactive) {
164
167
  _this.emitPresence({
165
168
  joined: [participant]
166
169
  }, 'adding agent participant from remote step');
@@ -230,6 +233,9 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
230
233
  (0, _defineProperty2.default)(this, "hasActingUserChanged", function (previous, current) {
231
234
  return previous.actingUserId !== current.actingUserId;
232
235
  });
236
+ (0, _defineProperty2.default)(this, "hasAgentTypeChanged", function (previous, current) {
237
+ return previous.agentType !== current.agentType;
238
+ });
233
239
  (0, _defineProperty2.default)(this, "handleAnonymousUser", /*#__PURE__*/function () {
234
240
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(payload) {
235
241
  var _previousParticipant$, _ref2, _previousParticipant$2, _asset2;
@@ -330,7 +336,7 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
330
336
  _context2.next = 7;
331
337
  break;
332
338
  }
333
- if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
339
+ if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentTypeChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
334
340
  _this.emitPresence({
335
341
  joined: [participant]
336
342
  }, 'handling participant acting user changed event');
@@ -428,12 +434,13 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
428
434
  // would handle activity and lastActive changes
429
435
  participant = _objectSpread(_objectSpread({}, previousParticipant), {}, {
430
436
  actingUserId: payload.actingUserId,
437
+ agentType: payload.agentType,
431
438
  presenceActivity: payload.presenceActivity,
432
439
  lastActive: payload.timestamp
433
440
  });
434
441
  _this.participantsState.setBySessionId(sessionId, participant);
435
442
  _this.scheduleRemoteAgentExpiry(participant);
436
- if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
443
+ if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentTypeChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
437
444
  _this.emitPresence({
438
445
  joined: [participant]
439
446
  }, 'handling participant acting user changed event');
@@ -457,19 +464,23 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
457
464
  }());
458
465
  (0, _defineProperty2.default)(this, "onParticipantUpdated", /*#__PURE__*/function () {
459
466
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(payload) {
467
+ var gatedPayload;
460
468
  return _regenerator.default.wrap(function (_context4) {
461
469
  while (1) switch (_context4.prev = _context4.next) {
462
470
  case 0:
471
+ gatedPayload = _objectSpread(_objectSpread({}, payload), {}, {
472
+ agentType: (0, _fg.fg)('platform_move_presence_agents') ? payload.agentType : undefined
473
+ });
463
474
  if (!_this.batchProps) {
464
475
  _context4.next = 1;
465
476
  break;
466
477
  }
467
- _this.updateParticipantLazy(payload);
478
+ _this.updateParticipantLazy(gatedPayload);
468
479
  _context4.next = 2;
469
480
  break;
470
481
  case 1:
471
482
  _context4.next = 2;
472
- return _this.updateParticipantEager(payload);
483
+ return _this.updateParticipantEager(gatedPayload);
473
484
  case 2:
474
485
  case "end":
475
486
  return _context4.stop();
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "24.1.8";
8
+ var version = exports.version = "24.1.9";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -4,6 +4,7 @@ import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform'
4
4
  import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
5
5
  import { Transaction } from '@atlaskit/editor-prosemirror/state';
6
6
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
7
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
7
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
10
  import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
@@ -843,7 +844,7 @@ export class DocumentService {
843
844
  }
844
845
  try {
845
846
  var _this$analyticsHelper34;
846
- const providerIds = new Set();
847
+ const agentTypeByProviderId = new Map();
847
848
  const agentIds = new Set();
848
849
  const agentTypes = new Set();
849
850
  let agentStepCount = 0;
@@ -852,13 +853,13 @@ export class DocumentService {
852
853
  if (!providerId) {
853
854
  continue;
854
855
  }
855
- providerIds.add(providerId);
856
856
  agentStepCount++;
857
857
  const {
858
858
  agentId,
859
859
  agentType
860
860
  } = step;
861
861
  if (agentType) {
862
+ agentTypeByProviderId.set(providerId, agentType);
862
863
  agentTypes.add(agentType);
863
864
  }
864
865
  if (agentId) {
@@ -866,7 +867,7 @@ export class DocumentService {
866
867
  }
867
868
  }
868
869
  // No agent-authored steps in this batch — nothing to register or report.
869
- if (providerIds.size === 0) {
870
+ if (agentTypeByProviderId.size === 0) {
870
871
  return;
871
872
  }
872
873
  // Anchor signal that the agent-presence logic kicked off for a received transaction. Fires
@@ -874,12 +875,12 @@ export class DocumentService {
874
875
  // non-PII: agent kinds, actor ids, and counts — never document content.
875
876
  (_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 ? void 0 : _this$analyticsHelper34.sendActionEvent(EVENT_ACTION.AGENT_EDIT_RECEIVED, EVENT_STATUS.SUCCESS, {
876
877
  agentIds: [...agentIds],
877
- agentCount: providerIds.size,
878
+ agentCount: agentTypeByProviderId.size,
878
879
  agentTypes: [...agentTypes],
879
880
  agentStepCount,
880
881
  totalStepCount: steps.length
881
882
  });
882
- providerIds.forEach(providerId => this.participantsService.upsertAIProviderParticipantLocally(providerId));
883
+ agentTypeByProviderId.forEach((agentType, providerId) => this.participantsService.upsertAIProviderParticipantLocally(providerId, fg('platform_move_presence_agents') ? agentType : undefined));
883
884
  } catch (error) {
884
885
  var _this$analyticsHelper35;
885
886
  (_this$analyticsHelper35 = this.analyticsHelper) === null || _this$analyticsHelper35 === void 0 ? void 0 : _this$analyticsHelper35.sendErrorEvent(error, 'Error while adding agent presence from steps');
@@ -6,6 +6,7 @@ const DEFAULT_BATCH_FETCH_SIZE = 25;
6
6
  export const createParticipantFromPayload = async (payload, getUser) => {
7
7
  const {
8
8
  actingUserId,
9
+ agentType,
9
10
  sessionId,
10
11
  timestamp,
11
12
  clientId,
@@ -25,6 +26,7 @@ export const createParticipantFromPayload = async (payload, getUser) => {
25
26
  clientId,
26
27
  permit,
27
28
  actingUserId,
29
+ agentType,
28
30
  isGuest: user === null || user === void 0 ? void 0 : user.isGuest,
29
31
  presenceId: presenceId,
30
32
  presenceActivity: presenceActivity,
@@ -80,6 +82,7 @@ export const fetchParticipants = async (participantsState, batchProps) => {
80
82
  clientId: participant.clientId,
81
83
  permit: participant.permit,
82
84
  actingUserId: participant.actingUserId,
85
+ agentType: participant.agentType,
83
86
  presenceId: participant.presenceId,
84
87
  presenceActivity: participant.presenceActivity,
85
88
  isHydrated: true
@@ -72,12 +72,13 @@ export class ParticipantsService {
72
72
  }
73
73
  }
74
74
  });
75
- _defineProperty(this, "buildAIProviderPresencePayload", providerId => {
75
+ _defineProperty(this, "buildAIProviderPresencePayload", (providerId, agentType) => {
76
76
  const defaultPresenceData = this.getPresenceData();
77
77
  const presencePayload = {
78
78
  sessionId: `${providerId}::${defaultPresenceData.sessionId}`,
79
79
  userId: providerId,
80
80
  clientId: `${providerId}::${defaultPresenceData.clientId}`,
81
+ agentType,
81
82
  permit: {
82
83
  isPermittedToComment: false,
83
84
  isPermittedToEdit: false,
@@ -120,13 +121,15 @@ export class ParticipantsService {
120
121
  * presence consumer on each streamed step.
121
122
  *
122
123
  * @param providerId `agent:<aaid|type>` id of the agent
124
+ * @param agentType kind of the agent that authored the step
123
125
  */
124
- _defineProperty(this, "upsertAIProviderParticipantLocally", providerId => {
125
- const payload = this.buildAIProviderPresencePayload(providerId);
126
+ _defineProperty(this, "upsertAIProviderParticipantLocally", (providerId, agentType) => {
127
+ const payload = this.buildAIProviderPresencePayload(providerId, agentType);
126
128
  const {
127
129
  sessionId
128
130
  } = payload;
129
131
  const existing = this.participantsState.getBySessionId(sessionId);
132
+ const hasAgentTypeChanged = (existing === null || existing === void 0 ? void 0 : existing.agentType) !== agentType;
130
133
  const wasInactive = existing ? Date.now() - existing.lastActive >= AGENT_PRESENCE_INACTIVE_MS : false;
131
134
  const participant = {
132
135
  ...payload,
@@ -148,7 +151,7 @@ export class ParticipantsService {
148
151
 
149
152
  // Active refreshes stay silent. Re-emit when an inactive agent becomes active so consumers
150
153
  // can update its presentation immediately.
151
- if (!existing || fg('platform_move_presence_agents') && wasInactive) {
154
+ if (!existing || hasAgentTypeChanged || fg('platform_move_presence_agents') && wasInactive) {
152
155
  this.emitPresence({
153
156
  joined: [participant]
154
157
  }, 'adding agent participant from remote step');
@@ -214,6 +217,9 @@ export class ParticipantsService {
214
217
  _defineProperty(this, "hasActingUserChanged", (previous, current) => {
215
218
  return previous.actingUserId !== current.actingUserId;
216
219
  });
220
+ _defineProperty(this, "hasAgentTypeChanged", (previous, current) => {
221
+ return previous.agentType !== current.agentType;
222
+ });
217
223
  _defineProperty(this, "handleAnonymousUser", async payload => {
218
224
  var _previousParticipant$, _ref, _previousParticipant$2, _asset2;
219
225
  const {
@@ -280,7 +286,7 @@ export class ParticipantsService {
280
286
  this.participantsState.setBySessionId(participant.sessionId, participant);
281
287
  this.scheduleRemoteAgentExpiry(participant);
282
288
  if (previousParticipant) {
283
- if (this.hasActingUserChanged(previousParticipant, participant) || this.hasAgentBecomeActive(previousParticipant, participant)) {
289
+ if (this.hasActingUserChanged(previousParticipant, participant) || this.hasAgentTypeChanged(previousParticipant, participant) || this.hasAgentBecomeActive(previousParticipant, participant)) {
284
290
  this.emitPresence({
285
291
  joined: [participant]
286
292
  }, 'handling participant acting user changed event');
@@ -364,12 +370,13 @@ export class ParticipantsService {
364
370
  const participant = {
365
371
  ...previousParticipant,
366
372
  actingUserId: payload.actingUserId,
373
+ agentType: payload.agentType,
367
374
  presenceActivity: payload.presenceActivity,
368
375
  lastActive: payload.timestamp
369
376
  };
370
377
  this.participantsState.setBySessionId(sessionId, participant);
371
378
  this.scheduleRemoteAgentExpiry(participant);
372
- if (this.hasActingUserChanged(previousParticipant, participant) || this.hasAgentBecomeActive(previousParticipant, participant)) {
379
+ if (this.hasActingUserChanged(previousParticipant, participant) || this.hasAgentTypeChanged(previousParticipant, participant) || this.hasAgentBecomeActive(previousParticipant, participant)) {
373
380
  this.emitPresence({
374
381
  joined: [participant]
375
382
  }, 'handling participant acting user changed event');
@@ -383,10 +390,14 @@ export class ParticipantsService {
383
390
  return;
384
391
  });
385
392
  _defineProperty(this, "onParticipantUpdated", async payload => {
393
+ const gatedPayload = {
394
+ ...payload,
395
+ agentType: fg('platform_move_presence_agents') ? payload.agentType : undefined
396
+ };
386
397
  if (this.batchProps) {
387
- this.updateParticipantLazy(payload);
398
+ this.updateParticipantLazy(gatedPayload);
388
399
  } else {
389
- await this.updateParticipantEager(payload);
400
+ await this.updateParticipantEager(gatedPayload);
390
401
  }
391
402
  });
392
403
  /**
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "24.1.8";
2
+ export const version = "24.1.9";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -14,6 +14,7 @@ import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform'
14
14
  import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
15
15
  import { Transaction } from '@atlaskit/editor-prosemirror/state';
16
16
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
17
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
17
18
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
18
19
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
20
  import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
@@ -962,7 +963,7 @@ export var DocumentService = /*#__PURE__*/function () {
962
963
  }
963
964
  try {
964
965
  var _this$analyticsHelper34;
965
- var providerIds = new Set();
966
+ var agentTypeByProviderId = new Map();
966
967
  var agentIds = new Set();
967
968
  var agentTypes = new Set();
968
969
  var agentStepCount = 0;
@@ -975,12 +976,12 @@ export var DocumentService = /*#__PURE__*/function () {
975
976
  if (!providerId) {
976
977
  continue;
977
978
  }
978
- providerIds.add(providerId);
979
979
  agentStepCount++;
980
980
  var _ref10 = step,
981
981
  agentId = _ref10.agentId,
982
982
  agentType = _ref10.agentType;
983
983
  if (agentType) {
984
+ agentTypeByProviderId.set(providerId, agentType);
984
985
  agentTypes.add(agentType);
985
986
  }
986
987
  if (agentId) {
@@ -993,7 +994,7 @@ export var DocumentService = /*#__PURE__*/function () {
993
994
  } finally {
994
995
  _iterator.f();
995
996
  }
996
- if (providerIds.size === 0) {
997
+ if (agentTypeByProviderId.size === 0) {
997
998
  return;
998
999
  }
999
1000
  // Anchor signal that the agent-presence logic kicked off for a received transaction. Fires
@@ -1001,13 +1002,13 @@ export var DocumentService = /*#__PURE__*/function () {
1001
1002
  // non-PII: agent kinds, actor ids, and counts — never document content.
1002
1003
  (_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 || _this$analyticsHelper34.sendActionEvent(EVENT_ACTION.AGENT_EDIT_RECEIVED, EVENT_STATUS.SUCCESS, {
1003
1004
  agentIds: _toConsumableArray(agentIds),
1004
- agentCount: providerIds.size,
1005
+ agentCount: agentTypeByProviderId.size,
1005
1006
  agentTypes: _toConsumableArray(agentTypes),
1006
1007
  agentStepCount: agentStepCount,
1007
1008
  totalStepCount: steps.length
1008
1009
  });
1009
- providerIds.forEach(function (providerId) {
1010
- return _this3.participantsService.upsertAIProviderParticipantLocally(providerId);
1010
+ agentTypeByProviderId.forEach(function (agentType, providerId) {
1011
+ return _this3.participantsService.upsertAIProviderParticipantLocally(providerId, fg('platform_move_presence_agents') ? agentType : undefined);
1011
1012
  });
1012
1013
  } catch (error) {
1013
1014
  var _this$analyticsHelper35;
@@ -8,11 +8,11 @@ export var PARTICIPANT_UPDATE_INTERVAL = 300 * 1000; // 300 seconds
8
8
  var DEFAULT_BATCH_FETCH_SIZE = 25;
9
9
  export var createParticipantFromPayload = /*#__PURE__*/function () {
10
10
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload, getUser) {
11
- var actingUserId, sessionId, timestamp, clientId, userId, permit, presenceId, presenceActivity, user, participant;
11
+ var actingUserId, agentType, sessionId, timestamp, clientId, userId, permit, presenceId, presenceActivity, user, participant;
12
12
  return _regeneratorRuntime.wrap(function (_context) {
13
13
  while (1) switch (_context.prev = _context.next) {
14
14
  case 0:
15
- actingUserId = payload.actingUserId, sessionId = payload.sessionId, timestamp = payload.timestamp, clientId = payload.clientId, userId = payload.userId, permit = payload.permit, presenceId = payload.presenceId, presenceActivity = payload.presenceActivity;
15
+ actingUserId = payload.actingUserId, agentType = payload.agentType, sessionId = payload.sessionId, timestamp = payload.timestamp, clientId = payload.clientId, userId = payload.userId, permit = payload.permit, presenceId = payload.presenceId, presenceActivity = payload.presenceActivity;
16
16
  _context.next = 1;
17
17
  return getUser === null || getUser === void 0 ? void 0 : getUser(userId);
18
18
  case 1:
@@ -27,6 +27,7 @@ export var createParticipantFromPayload = /*#__PURE__*/function () {
27
27
  clientId: clientId,
28
28
  permit: permit,
29
29
  actingUserId: actingUserId,
30
+ agentType: agentType,
30
31
  isGuest: user === null || user === void 0 ? void 0 : user.isGuest,
31
32
  presenceId: presenceId,
32
33
  presenceActivity: presenceActivity,
@@ -99,6 +100,7 @@ export var fetchParticipants = /*#__PURE__*/function () {
99
100
  clientId: participant.clientId,
100
101
  permit: participant.permit,
101
102
  actingUserId: participant.actingUserId,
103
+ agentType: participant.agentType,
102
104
  presenceId: participant.presenceId,
103
105
  presenceActivity: participant.presenceActivity,
104
106
  isHydrated: true
@@ -81,12 +81,13 @@ export var ParticipantsService = /*#__PURE__*/function () {
81
81
  }
82
82
  }
83
83
  });
84
- _defineProperty(this, "buildAIProviderPresencePayload", function (providerId) {
84
+ _defineProperty(this, "buildAIProviderPresencePayload", function (providerId, agentType) {
85
85
  var defaultPresenceData = _this.getPresenceData();
86
86
  var presencePayload = {
87
87
  sessionId: "".concat(providerId, "::").concat(defaultPresenceData.sessionId),
88
88
  userId: providerId,
89
89
  clientId: "".concat(providerId, "::").concat(defaultPresenceData.clientId),
90
+ agentType: agentType,
90
91
  permit: {
91
92
  isPermittedToComment: false,
92
93
  isPermittedToEdit: false,
@@ -129,11 +130,13 @@ export var ParticipantsService = /*#__PURE__*/function () {
129
130
  * presence consumer on each streamed step.
130
131
  *
131
132
  * @param providerId `agent:<aaid|type>` id of the agent
133
+ * @param agentType kind of the agent that authored the step
132
134
  */
133
- _defineProperty(this, "upsertAIProviderParticipantLocally", function (providerId) {
134
- var payload = _this.buildAIProviderPresencePayload(providerId);
135
+ _defineProperty(this, "upsertAIProviderParticipantLocally", function (providerId, agentType) {
136
+ var payload = _this.buildAIProviderPresencePayload(providerId, agentType);
135
137
  var sessionId = payload.sessionId;
136
138
  var existing = _this.participantsState.getBySessionId(sessionId);
139
+ var hasAgentTypeChanged = (existing === null || existing === void 0 ? void 0 : existing.agentType) !== agentType;
137
140
  var wasInactive = existing ? Date.now() - existing.lastActive >= AGENT_PRESENCE_INACTIVE_MS : false;
138
141
  var participant = _objectSpread(_objectSpread(_objectSpread({}, payload), fg('platform_move_presence_agents') ? {
139
142
  presenceActivity: 'editor'
@@ -153,7 +156,7 @@ export var ParticipantsService = /*#__PURE__*/function () {
153
156
 
154
157
  // Active refreshes stay silent. Re-emit when an inactive agent becomes active so consumers
155
158
  // can update its presentation immediately.
156
- if (!existing || fg('platform_move_presence_agents') && wasInactive) {
159
+ if (!existing || hasAgentTypeChanged || fg('platform_move_presence_agents') && wasInactive) {
157
160
  _this.emitPresence({
158
161
  joined: [participant]
159
162
  }, 'adding agent participant from remote step');
@@ -223,6 +226,9 @@ export var ParticipantsService = /*#__PURE__*/function () {
223
226
  _defineProperty(this, "hasActingUserChanged", function (previous, current) {
224
227
  return previous.actingUserId !== current.actingUserId;
225
228
  });
229
+ _defineProperty(this, "hasAgentTypeChanged", function (previous, current) {
230
+ return previous.agentType !== current.agentType;
231
+ });
226
232
  _defineProperty(this, "handleAnonymousUser", /*#__PURE__*/function () {
227
233
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
228
234
  var _previousParticipant$, _ref2, _previousParticipant$2, _asset2;
@@ -323,7 +329,7 @@ export var ParticipantsService = /*#__PURE__*/function () {
323
329
  _context2.next = 7;
324
330
  break;
325
331
  }
326
- if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
332
+ if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentTypeChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
327
333
  _this.emitPresence({
328
334
  joined: [participant]
329
335
  }, 'handling participant acting user changed event');
@@ -421,12 +427,13 @@ export var ParticipantsService = /*#__PURE__*/function () {
421
427
  // would handle activity and lastActive changes
422
428
  participant = _objectSpread(_objectSpread({}, previousParticipant), {}, {
423
429
  actingUserId: payload.actingUserId,
430
+ agentType: payload.agentType,
424
431
  presenceActivity: payload.presenceActivity,
425
432
  lastActive: payload.timestamp
426
433
  });
427
434
  _this.participantsState.setBySessionId(sessionId, participant);
428
435
  _this.scheduleRemoteAgentExpiry(participant);
429
- if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
436
+ if (_this.hasActingUserChanged(previousParticipant, participant) || _this.hasAgentTypeChanged(previousParticipant, participant) || _this.hasAgentBecomeActive(previousParticipant, participant)) {
430
437
  _this.emitPresence({
431
438
  joined: [participant]
432
439
  }, 'handling participant acting user changed event');
@@ -450,19 +457,23 @@ export var ParticipantsService = /*#__PURE__*/function () {
450
457
  }());
451
458
  _defineProperty(this, "onParticipantUpdated", /*#__PURE__*/function () {
452
459
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(payload) {
460
+ var gatedPayload;
453
461
  return _regeneratorRuntime.wrap(function (_context4) {
454
462
  while (1) switch (_context4.prev = _context4.next) {
455
463
  case 0:
464
+ gatedPayload = _objectSpread(_objectSpread({}, payload), {}, {
465
+ agentType: fg('platform_move_presence_agents') ? payload.agentType : undefined
466
+ });
456
467
  if (!_this.batchProps) {
457
468
  _context4.next = 1;
458
469
  break;
459
470
  }
460
- _this.updateParticipantLazy(payload);
471
+ _this.updateParticipantLazy(gatedPayload);
461
472
  _context4.next = 2;
462
473
  break;
463
474
  case 1:
464
475
  _context4.next = 2;
465
- return _this.updateParticipantEager(payload);
476
+ return _this.updateParticipantEager(gatedPayload);
466
477
  case 2:
467
478
  case "end":
468
479
  return _context4.stop();
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "24.1.8";
2
+ export var version = "24.1.9";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -83,8 +83,9 @@ export declare class ParticipantsService {
83
83
  * presence consumer on each streamed step.
84
84
  *
85
85
  * @param providerId `agent:<aaid|type>` id of the agent
86
+ * @param agentType kind of the agent that authored the step
86
87
  */
87
- upsertAIProviderParticipantLocally: (providerId: string) => void;
88
+ upsertAIProviderParticipantLocally: (providerId: string, agentType?: string) => void;
88
89
  /**
89
90
  * (Re)starts the sliding expiry timer for an agent participant. The enriched lifecycle retains
90
91
  * agents for five minutes, while the legacy lifecycle keeps its 30-second removal behavior.
@@ -105,6 +106,7 @@ export declare class ParticipantsService {
105
106
  private clearAgentPresenceTimers;
106
107
  private hasPresenceActivityChanged;
107
108
  private hasActingUserChanged;
109
+ private hasAgentTypeChanged;
108
110
  private handleAnonymousUser;
109
111
  /**
110
112
  * Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
@@ -155,6 +155,8 @@ export type BroadcastIncomingPayload = {
155
155
  export type PresenceData = {
156
156
  /** User identity an agent participant is acting on behalf of, when delegated by a user. */
157
157
  actingUserId?: string;
158
+ /** Agent kind supplied by NCS, such as `convo-ai`, `mcp`, or `twg`. */
159
+ agentType?: string;
158
160
  clientId: number | string;
159
161
  /** Permission level the participant holds on the document (view / comment / edit). */
160
162
  permit?: UserPermitType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "24.1.9",
3
+ "version": "24.1.10",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -23,14 +23,14 @@
23
23
  "@atlaskit/analytics-listeners": "^11.1.0",
24
24
  "@atlaskit/anonymous-assets": "^2.8.0",
25
25
  "@atlaskit/atlassian-context": "^1.1.0",
26
- "@atlaskit/editor-json-transformer": "^9.4.0",
26
+ "@atlaskit/editor-json-transformer": "^9.5.0",
27
27
  "@atlaskit/editor-prosemirror": "^8.0.0",
28
28
  "@atlaskit/feature-gate-js-client": "^6.0.0",
29
29
  "@atlaskit/platform-feature-experiments": "^0.3.0",
30
30
  "@atlaskit/platform-feature-flags": "^2.1.0",
31
31
  "@atlaskit/prosemirror-collab": "^1.0.0",
32
32
  "@atlaskit/react-ufo": "^7.6.0",
33
- "@atlaskit/tmp-editor-statsig": "^155.0.0",
33
+ "@atlaskit/tmp-editor-statsig": "^156.0.0",
34
34
  "@atlaskit/ufo": "^1.0.0",
35
35
  "@atlaskit/util-service-support": "^7.2.0",
36
36
  "@babel/runtime": "^7.0.0",
@@ -77,6 +77,6 @@
77
77
  }
78
78
  },
79
79
  "peerDependencies": {
80
- "@atlaskit/editor-common": "^119.10.0"
80
+ "@atlaskit/editor-common": "^119.12.0"
81
81
  }
82
82
  }