@xpert-ai/plugin-sdk 3.35.0 → 3.36.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/agent-results.cjs.js +5 -3
  2. package/agent-results.esm.js +2 -2
  3. package/analytics-result.cjs.js +64 -27
  4. package/analytics-result.esm.js +62 -28
  5. package/analytics.cjs.js +157 -15
  6. package/analytics.esm.js +154 -17
  7. package/artifact-document.cjs.js +9 -3
  8. package/artifact-document.esm.js +9 -3
  9. package/collaboration-client.cjs.js +274 -140
  10. package/collaboration-client.esm.js +273 -141
  11. package/docs/README.md +23 -0
  12. package/index.cjs.js +211 -10
  13. package/index.esm.js +191 -13
  14. package/package.json +8 -2
  15. package/remote-component.cjs.default.js +1 -0
  16. package/remote-component.cjs.js +143 -0
  17. package/remote-component.cjs.mjs +2 -0
  18. package/remote-component.d.ts +1 -0
  19. package/remote-component.esm.js +139 -0
  20. package/results.cjs.js +2 -14
  21. package/results.esm.js +2 -12
  22. package/src/analytics.d.ts +2 -0
  23. package/src/collaboration-client.d.ts +1 -0
  24. package/src/index.d.ts +1 -0
  25. package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +24 -24
  26. package/src/lib/agent/middleware/strategy.interface.d.ts +2 -0
  27. package/src/lib/agent/runtime/capability.d.ts +2 -0
  28. package/src/lib/agent/runtime/cli-model-profile.d.ts +14 -1
  29. package/src/lib/agent/runtime/dispatch.d.ts +79 -79
  30. package/src/lib/agent/runtime/execution-runner.d.ts +19 -10
  31. package/src/lib/agent/runtime/pipeline-scope.d.ts +4 -4
  32. package/src/lib/agent/runtime/results.d.ts +14 -234
  33. package/src/lib/agent/runtime/types.d.ts +19 -0
  34. package/src/lib/agent-event/index.d.ts +55 -0
  35. package/src/lib/agent-event/journal.d.ts +30 -0
  36. package/src/lib/artifact-document/dependencies.d.ts +3 -3
  37. package/src/lib/artifact-document/protocol.d.ts +2 -2
  38. package/src/lib/artifact-document/scheduler.d.ts +3 -0
  39. package/src/lib/assistant-capability/middleware.d.ts +2 -1
  40. package/src/lib/collaboration/client.d.ts +6 -59
  41. package/src/lib/collaboration/index.d.ts +1 -0
  42. package/src/lib/collaboration/operations-client.d.ts +23 -0
  43. package/src/lib/collaboration/presence.d.ts +36 -0
  44. package/src/lib/collaboration/provider.registry.d.ts +2 -2
  45. package/src/lib/collaboration/transport.d.ts +24 -0
  46. package/src/lib/collaboration/types.d.ts +57 -5
  47. package/src/lib/content-resource/catalog.d.ts +23 -1
  48. package/src/lib/content-resource/editor.d.ts +36 -1
  49. package/src/lib/data/analytics/analysis-evidence.d.ts +757 -0
  50. package/src/lib/data/analytics/analytics-certification.d.ts +64 -0
  51. package/src/lib/data/analytics/analytics-provider.d.ts +9 -0
  52. package/src/lib/data/analytics/analytics-value.d.ts +5 -0
  53. package/src/lib/data/analytics/index.d.ts +1 -0
  54. package/src/lib/evolution/runtime-capability.d.ts +1 -0
  55. package/src/lib/project-pipeline/adapters.d.ts +9 -2
  56. package/src/lib/project-pipeline/registry.d.ts +53 -50
  57. package/src/lib/project-task/acceptance.d.ts +13 -1
  58. package/src/lib/project-task/index.d.ts +4 -2
  59. package/src/lib/runtime/capabilities/project-configuration.d.ts +2 -0
  60. package/src/lib/view-extension/provider.interface.d.ts +51 -0
  61. package/src/remote-component.d.ts +13 -0
@@ -1,46 +1,6 @@
1
1
  import { _ as _extends } from './_extends.esm.js';
2
2
 
3
- function createSocketIoTransportAdapter(socket) {
4
- return {
5
- get connected () {
6
- return socket.connected;
7
- },
8
- get clientId () {
9
- var _socket_id;
10
- return (_socket_id = socket.id) != null ? _socket_id : null;
11
- },
12
- connect: ()=>{
13
- socket.connect();
14
- },
15
- disconnect: ()=>{
16
- socket.disconnect();
17
- },
18
- emit: (event, payload = {})=>{
19
- socket.emit(event, payload);
20
- },
21
- on: (event, handler)=>{
22
- socket.on(event, handler);
23
- return ()=>{
24
- socket.off(event, handler);
25
- };
26
- }
27
- };
28
- }
29
- /** Wrap a caller-owned `Y.Doc` without passing it across the runtime capability boundary. */ function createYjsDocumentAdapter(document, yjs) {
30
- return {
31
- applyUpdate: (update, origin)=>yjs.applyUpdate(document, update, origin),
32
- encodeStateVector: ()=>yjs.encodeStateVector(document),
33
- mergeUpdates: (updates)=>yjs.mergeUpdates(updates),
34
- onUpdate: (handler)=>{
35
- document.on('update', handler);
36
- return ()=>document.off('update', handler);
37
- }
38
- };
39
- }
40
- /**
41
- * Keep per-client sessions for cursors while exposing one collaborator per stable actor identity.
42
- * This prevents a second tab owned by the same user from either duplicating or hiding that user.
43
- */ function createCollaborationPresenceStore(options = {}) {
3
+ function createCollaborationPresenceStore(options = {}) {
44
4
  let selfClientId = null;
45
5
  let sessions = new Map();
46
6
  const readSnapshot = ()=>{
@@ -97,10 +57,179 @@ function createSocketIoTransportAdapter(socket) {
97
57
  snapshot: readSnapshot
98
58
  };
99
59
  }
60
+ function actorPresence(actor, clientId) {
61
+ return _extends({}, actor, {
62
+ clientId: clientId != null ? clientId : `self:${actor.presenceId}`,
63
+ pageId: null,
64
+ pointer: null,
65
+ focus: null,
66
+ selection: null,
67
+ viewport: null,
68
+ mode: null,
69
+ status: null,
70
+ toolName: null,
71
+ operationLabel: null,
72
+ updatedAt: Date.now()
73
+ });
74
+ }
75
+ /** Parse untrusted presence payloads shared by both engines; document content is ignored. */ function parseCollaborationPresence(value) {
76
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
77
+ const item = value;
78
+ const clientId = stringValue$1('clientId' in item ? item.clientId : undefined);
79
+ const presenceId = stringValue$1('presenceId' in item ? item.presenceId : undefined);
80
+ const displayName = stringValue$1('displayName' in item ? item.displayName : undefined);
81
+ const color = stringValue$1('color' in item ? item.color : undefined);
82
+ const actorType = 'actorType' in item ? item.actorType : undefined;
83
+ if (!clientId || !presenceId || !displayName || !color || actorType !== 'user' && actorType !== 'agent' && actorType !== 'system') return null;
84
+ return {
85
+ clientId,
86
+ presenceId,
87
+ displayName,
88
+ color,
89
+ actorType,
90
+ avatarUrl: nullableString('avatarUrl' in item ? item.avatarUrl : undefined),
91
+ pageId: nullableString('pageId' in item ? item.pageId : undefined),
92
+ pointer: parsePointer('pointer' in item ? item.pointer : undefined),
93
+ focus: parseFocus('focus' in item ? item.focus : undefined),
94
+ selection: parseSelection('selection' in item ? item.selection : undefined),
95
+ viewport: parseViewport('viewport' in item ? item.viewport : undefined),
96
+ mode: nullableString('mode' in item ? item.mode : undefined),
97
+ status: actorStatus('status' in item ? item.status : undefined),
98
+ toolName: nullableString('toolName' in item ? item.toolName : undefined),
99
+ operationLabel: nullableString('operationLabel' in item ? item.operationLabel : undefined),
100
+ updatedAt: 'updatedAt' in item && typeof item.updatedAt === 'number' ? item.updatedAt : Date.now()
101
+ };
102
+ }
103
+ function parsePointer(value) {
104
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
105
+ const item = value;
106
+ if (!('x' in item) || typeof item.x !== 'number' || !('y' in item) || typeof item.y !== 'number') return null;
107
+ return {
108
+ pageId: nullableString('pageId' in item ? item.pageId : undefined),
109
+ x: item.x,
110
+ y: item.y,
111
+ visible: ('visible' in item ? item.visible : undefined) !== false
112
+ };
113
+ }
114
+ function parseFocus(value) {
115
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
116
+ const item = value;
117
+ const kind = stringValue$1('kind' in item ? item.kind : undefined);
118
+ if (!kind) return null;
119
+ return {
120
+ kind,
121
+ key: nullableString('key' in item ? item.key : undefined),
122
+ pageId: nullableString('pageId' in item ? item.pageId : undefined),
123
+ elementId: nullableString('elementId' in item ? item.elementId : undefined),
124
+ fieldKey: nullableString('fieldKey' in item ? item.fieldKey : undefined)
125
+ };
126
+ }
127
+ function parseSelection(value) {
128
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
129
+ const item = value;
130
+ const kind = 'kind' in item ? item.kind : undefined;
131
+ if (kind === 'cells') {
132
+ const cells = 'cells' in item ? item.cells : undefined;
133
+ if (!cells || typeof cells !== 'object' || !('sheetId' in cells) || typeof cells.sheetId !== 'string' || !cells.sheetId || cells.sheetId.length > 256 || !('startRow' in cells) || !('endRow' in cells) || !('startColumn' in cells) || !('endColumn' in cells)) return null;
134
+ const { sheetId, startRow, endRow, startColumn, endColumn } = cells;
135
+ if (typeof startRow !== 'number' || typeof endRow !== 'number' || typeof startColumn !== 'number' || typeof endColumn !== 'number' || ![
136
+ startRow,
137
+ endRow,
138
+ startColumn,
139
+ endColumn
140
+ ].every(Number.isSafeInteger) || startRow < 0 || startColumn < 0 || endRow < startRow || endColumn < startColumn || endRow > 1048575 || endColumn > 16383) return null;
141
+ const baseRevision = 'baseRevision' in cells ? cells.baseRevision : undefined;
142
+ if (baseRevision !== undefined && (typeof baseRevision !== 'number' || !Number.isSafeInteger(baseRevision) || baseRevision < 1)) return null;
143
+ return {
144
+ kind,
145
+ cells: _extends({
146
+ sheetId,
147
+ startRow,
148
+ endRow,
149
+ startColumn,
150
+ endColumn
151
+ }, typeof baseRevision === 'number' ? {
152
+ baseRevision
153
+ } : {})
154
+ };
155
+ }
156
+ if (kind !== 'text' && kind !== 'elements') return null;
157
+ const elementIds = 'elementIds' in item ? item.elementIds : undefined;
158
+ return {
159
+ kind,
160
+ fieldKey: nullableString('fieldKey' in item ? item.fieldKey : undefined),
161
+ elementIds: Array.isArray(elementIds) ? elementIds.filter((entry)=>typeof entry === 'string') : null,
162
+ anchorRelativeBase64: nullableString('anchorRelativeBase64' in item ? item.anchorRelativeBase64 : undefined),
163
+ headRelativeBase64: nullableString('headRelativeBase64' in item ? item.headRelativeBase64 : undefined)
164
+ };
165
+ }
166
+ function parseViewport(value) {
167
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
168
+ const item = value;
169
+ if (!('zoom' in item) || typeof item.zoom !== 'number' || !('width' in item) || typeof item.width !== 'number' || !('height' in item) || typeof item.height !== 'number') return null;
170
+ return {
171
+ zoom: item.zoom,
172
+ width: item.width,
173
+ height: item.height
174
+ };
175
+ }
176
+ function stringValue$1(value) {
177
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
178
+ }
179
+ function nullableString(value) {
180
+ var _stringValue;
181
+ return (_stringValue = stringValue$1(value)) != null ? _stringValue : null;
182
+ }
183
+ function actorStatus(value) {
184
+ return value === 'thinking' || value === 'editing' || value === 'done' || value === 'failed' ? value : null;
185
+ }
186
+
187
+ /** Adapt a caller-owned Socket.IO client to the SDK's framework-neutral transport. */ function createSocketIoTransportAdapter(socket) {
188
+ return {
189
+ get connected () {
190
+ return socket.connected;
191
+ },
192
+ get clientId () {
193
+ var _socket_id;
194
+ return (_socket_id = socket.id) != null ? _socket_id : null;
195
+ },
196
+ connect: ()=>{
197
+ socket.connect();
198
+ },
199
+ disconnect: ()=>{
200
+ socket.disconnect();
201
+ },
202
+ emit: (event, payload = {})=>{
203
+ socket.emit(event, payload);
204
+ },
205
+ on: (event, handler)=>{
206
+ socket.on(event, handler);
207
+ return ()=>{
208
+ socket.off(event, handler);
209
+ };
210
+ }
211
+ };
212
+ }
213
+
214
+ /** Wrap a caller-owned `Y.Doc` without passing it across the runtime capability boundary. */ function createYjsDocumentAdapter(document, yjs) {
215
+ return {
216
+ applyUpdate: (update, origin)=>yjs.applyUpdate(document, update, origin),
217
+ encodeStateVector: ()=>yjs.encodeStateVector(document),
218
+ mergeUpdates: (updates)=>yjs.mergeUpdates(updates),
219
+ onUpdate: (handler)=>{
220
+ document.on('update', handler);
221
+ return ()=>document.off('update', handler);
222
+ }
223
+ };
224
+ }
100
225
  /**
101
- * Create a collaboration client with update batching, state-vector repair, presence heartbeat,
226
+ * Create a Yjs collaboration client with update batching, state-vector repair, presence heartbeat,
102
227
  * and reconnect synchronization. The caller retains ownership of the document and transport.
103
228
  */ function createCollaborationClient(options) {
229
+ // Legacy sessions omit engine and use Yjs; operations must use its notification client.
230
+ if (options.session.engine && options.session.engine !== 'yjs') {
231
+ throw new Error('Yjs collaboration protocol required');
232
+ }
104
233
  const remoteOrigin = Object.freeze({
105
234
  kind: 'platform.collaboration.remote'
106
235
  });
@@ -202,7 +331,7 @@ function createSocketIoTransportAdapter(socket) {
202
331
  }
203
332
  }));
204
333
  cleanups.push(options.transport.on('presence', (payload)=>{
205
- const item = parsePresence(payload);
334
+ const item = parseCollaborationPresence(payload);
206
335
  if (item) {
207
336
  presenceSeenAt.set(item.clientId, Date.now());
208
337
  options.onPresence == null ? void 0 : options.onPresence.call(options, item);
@@ -210,7 +339,7 @@ function createSocketIoTransportAdapter(socket) {
210
339
  }));
211
340
  cleanups.push(options.transport.on('presence-snapshot', (payload)=>{
212
341
  const rawItems = payload['items'];
213
- const items = Array.isArray(rawItems) ? rawItems.map(parsePresence).filter(isPresence) : [];
342
+ const items = Array.isArray(rawItems) ? rawItems.map(parseCollaborationPresence).filter(isPresence) : [];
214
343
  var _stringValue, _ref;
215
344
  selfClientId = (_ref = (_stringValue = stringValue(payload['selfClientId'])) != null ? _stringValue : options.transport.clientId) != null ? _ref : selfClientId;
216
345
  presenceSeenAt.clear();
@@ -276,21 +405,6 @@ function createSocketIoTransportAdapter(socket) {
276
405
  }
277
406
  };
278
407
  }
279
- function actorPresence(actor, clientId) {
280
- return _extends({}, actor, {
281
- clientId: clientId != null ? clientId : `self:${actor.presenceId}`,
282
- pageId: null,
283
- pointer: null,
284
- focus: null,
285
- selection: null,
286
- viewport: null,
287
- mode: null,
288
- status: null,
289
- toolName: null,
290
- operationLabel: null,
291
- updatedAt: Date.now()
292
- });
293
- }
294
408
  /** Encode bytes in browsers without Node.js `Buffer`; chunks avoid argument-size limits. */ function bytesToBase64(bytes) {
295
409
  let binary = '';
296
410
  const chunkSize = 0x8000;
@@ -321,95 +435,113 @@ function parseAck(payload) {
321
435
  materializationStatus
322
436
  };
323
437
  }
324
- function parsePresence(value) {
325
- if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
326
- const item = value;
327
- const clientId = stringValue(item['clientId']);
328
- const presenceId = stringValue(item['presenceId']);
329
- const displayName = stringValue(item['displayName']);
330
- const color = stringValue(item['color']);
331
- const actorType = item['actorType'];
332
- if (!clientId || !presenceId || !displayName || !color || actorType !== 'user' && actorType !== 'agent' && actorType !== 'system') return null;
333
- return {
334
- clientId,
335
- presenceId,
336
- displayName,
337
- color,
338
- actorType,
339
- avatarUrl: nullableString(item['avatarUrl']),
340
- pageId: nullableString(item['pageId']),
341
- pointer: parsePointer(item['pointer']),
342
- focus: parseFocus(item['focus']),
343
- selection: parseSelection(item['selection']),
344
- viewport: parseViewport(item['viewport']),
345
- mode: nullableString(item['mode']),
346
- status: actorStatus(item['status']),
347
- toolName: nullableString(item['toolName']),
348
- operationLabel: nullableString(item['operationLabel']),
349
- updatedAt: typeof item['updatedAt'] === 'number' ? item['updatedAt'] : Date.now()
350
- };
351
- }
352
- function parsePointer(value) {
353
- const item = recordValue(value);
354
- if (!item || typeof item['x'] !== 'number' || typeof item['y'] !== 'number') return null;
355
- return {
356
- pageId: nullableString(item['pageId']),
357
- x: item['x'],
358
- y: item['y'],
359
- visible: item['visible'] !== false
360
- };
361
- }
362
- function parseFocus(value) {
363
- const item = recordValue(value);
364
- const kind = item && stringValue(item['kind']);
365
- if (!item || !kind) return null;
366
- return {
367
- kind,
368
- key: nullableString(item['key']),
369
- pageId: nullableString(item['pageId']),
370
- elementId: nullableString(item['elementId']),
371
- fieldKey: nullableString(item['fieldKey'])
372
- };
373
- }
374
- function parseSelection(value) {
375
- const item = recordValue(value);
376
- const kind = item == null ? void 0 : item['kind'];
377
- if (!item || kind !== 'text' && kind !== 'elements') return null;
378
- return {
379
- kind,
380
- fieldKey: nullableString(item['fieldKey']),
381
- elementIds: Array.isArray(item['elementIds']) ? item['elementIds'].filter((entry)=>typeof entry === 'string') : null,
382
- anchorRelativeBase64: nullableString(item['anchorRelativeBase64']),
383
- headRelativeBase64: nullableString(item['headRelativeBase64'])
384
- };
385
- }
386
- function parseViewport(value) {
387
- const item = recordValue(value);
388
- if (!item || typeof item['zoom'] !== 'number' || typeof item['width'] !== 'number' || typeof item['height'] !== 'number') return null;
389
- return {
390
- zoom: item['zoom'],
391
- width: item['width'],
392
- height: item['height']
393
- };
394
- }
395
- function recordValue(value) {
396
- return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
397
- }
398
438
  function isPresence(value) {
399
439
  return value !== null;
400
440
  }
401
441
  function stringValue(value) {
402
442
  return typeof value === 'string' && value.trim() ? value.trim() : undefined;
403
443
  }
404
- function nullableString(value) {
405
- var _stringValue;
406
- return (_stringValue = stringValue(value)) != null ? _stringValue : null;
407
- }
408
- function actorStatus(value) {
409
- return value === 'thinking' || value === 'editing' || value === 'done' || value === 'failed' ? value : null;
410
- }
411
444
  function positiveInteger(value, fallback) {
412
445
  return Number.isFinite(value) && Number(value) > 0 ? Math.trunc(Number(value)) : fallback;
413
446
  }
414
447
 
415
- export { base64ToBytes, bytesToBase64, createCollaborationClient, createCollaborationPresenceStore, createSocketIoTransportAdapter, createYjsDocumentAdapter };
448
+ /**
449
+ * Notification client for a domain-owned operation log, not an OT/CRDT implementation.
450
+ * The domain API owns writes, validation, conflict handling and persistence. This client
451
+ * only tracks committed revisions and ephemeral presence; it never submits business edits.
452
+ * Revisions coalesce to one high-water mark, so consumers must refetch authoritative state.
453
+ */ function createOperationCollaborationClient(options) {
454
+ if (options.session.engine !== 'operations') throw new Error('Operation collaboration protocol required');
455
+ const { transport, session } = options;
456
+ const presence = new Map();
457
+ let revision = -1, stopped = false, selfClientId = null;
458
+ let patch = {};
459
+ let presenceTimer;
460
+ const changed = ()=>options.onPresence([
461
+ ...presence.values()
462
+ ], selfClientId);
463
+ const addPresence = (value)=>{
464
+ const item = parseCollaborationPresence(value);
465
+ if (!item || presence.size >= 128 && !presence.has(item.clientId)) return;
466
+ presence.set(item.clientId, item);
467
+ };
468
+ // Repair missed invalidations on reconnect/periodic sync; no Yjs state vector is involved.
469
+ const sync = ()=>{
470
+ if (!stopped && transport.connected) transport.emit('sync-request', {});
471
+ };
472
+ const heartbeat = ()=>{
473
+ if (stopped) return;
474
+ if (Date.now() >= session.expiresAt) {
475
+ options.onError(new Error('Collaboration session expired'));
476
+ disconnect();
477
+ return;
478
+ }
479
+ if (transport.connected) transport.emit('presence', patch);
480
+ for (const [id, item] of presence)if (item.updatedAt < Date.now() - 15000) presence.delete(id);
481
+ changed();
482
+ };
483
+ const stops = [
484
+ transport.on('connect', ()=>{
485
+ var _transport_clientId;
486
+ selfClientId = (_transport_clientId = transport.clientId) != null ? _transport_clientId : null;
487
+ options.onConnection('connected');
488
+ sync();
489
+ heartbeat();
490
+ }),
491
+ transport.on('disconnect', ()=>{
492
+ presence.clear();
493
+ changed();
494
+ options.onConnection('disconnected');
495
+ }),
496
+ transport.on('revision', (value)=>{
497
+ if (value['documentId'] !== session.documentId || typeof value['revision'] !== 'number' || !Number.isSafeInteger(value['revision']) || value['revision'] < 0 || value['revision'] <= revision) return;
498
+ revision = value['revision'];
499
+ options.onRevision(revision);
500
+ }),
501
+ transport.on('presence-snapshot', (value)=>{
502
+ presence.clear();
503
+ var _transport_clientId;
504
+ selfClientId = typeof value['selfClientId'] === 'string' ? value['selfClientId'] : (_transport_clientId = transport.clientId) != null ? _transport_clientId : null;
505
+ if (Array.isArray(value['items'])) value['items'].slice(0, 128).forEach(addPresence);
506
+ changed();
507
+ }),
508
+ transport.on('presence', (value)=>{
509
+ addPresence(value);
510
+ changed();
511
+ }),
512
+ transport.on('presence-remove', (value)=>{
513
+ if (typeof value['clientId'] === 'string') presence.delete(value['clientId']);
514
+ changed();
515
+ }),
516
+ transport.on('error', (value)=>options.onError(new Error(typeof value['message'] === 'string' ? value['message'] : 'Collaboration disconnected')))
517
+ ];
518
+ const heartbeatTimer = setInterval(heartbeat, 5000), syncTimer = setInterval(sync, 15000);
519
+ function disconnect() {
520
+ if (stopped) return;
521
+ stopped = true;
522
+ clearInterval(heartbeatTimer);
523
+ clearInterval(syncTimer);
524
+ clearTimeout(presenceTimer);
525
+ stops.forEach((stop)=>stop());
526
+ transport.disconnect();
527
+ presence.clear();
528
+ changed();
529
+ options.onConnection('disconnected');
530
+ }
531
+ return {
532
+ connect () {
533
+ if (!stopped) transport.connect();
534
+ },
535
+ disconnect,
536
+ requestSync: sync,
537
+ setPresence (value) {
538
+ patch = value;
539
+ if (!stopped && !presenceTimer) presenceTimer = setTimeout(()=>{
540
+ presenceTimer = undefined;
541
+ if (transport.connected && !stopped) transport.emit('presence', patch);
542
+ }, 120);
543
+ }
544
+ };
545
+ }
546
+
547
+ export { base64ToBytes, bytesToBase64, createCollaborationClient, createCollaborationPresenceStore, createOperationCollaborationClient, createSocketIoTransportAdapter, createYjsDocumentAdapter, parseCollaborationPresence };
package/docs/README.md CHANGED
@@ -152,6 +152,29 @@ import {
152
152
 
153
153
  This entry point excludes the NestJS and Node.js dependencies used by the server SDK.
154
154
 
155
+ Choose the client using the server-issued session's `engine` (omitted means legacy Yjs):
156
+
157
+ | Engine | Browser client | Authoritative content and writes |
158
+ | ------------ | ---------------------------------------------- | ----------------------------------------------------------------------------------- |
159
+ | `yjs` | `createCollaborationClient` with a Yjs adapter | Platform CRDT state; plugin materializes business projections. |
160
+ | `operations` | `createOperationCollaborationClient` | Domain service and its operation log; platform carries revision notifications only. |
161
+
162
+ Both reuse the transport adapter and presence utilities. These live in protocol-neutral
163
+ modules; the operations client does not depend on the Yjs client. Existing public exports
164
+ remain available from the entry point above.
165
+
166
+ For `operations`, register an `ICollaborationOperationsProvider` with `authorize` and
167
+ `getRevision`. Submit edits through the domain API, which owns validation, idempotency,
168
+ conflict resolution, persistence and undo. After committing, call `notifyRevision`.
169
+ On `onRevision`, invalidate/refetch domain state while preserving local drafts under the
170
+ domain's conflict rules. Notifications may skip intermediate revisions; they are neither
171
+ operation payloads nor save acknowledgements. Reconnect and periodic sync read the latest
172
+ committed revision to repair missed notifications.
173
+
174
+ `getDocumentState`, `applyUpdate` and `migrateDocument` are Yjs-only APIs. An operations
175
+ session cannot use them to write content. Likewise, platform `sequenceNumber` and
176
+ materialization fields must not be treated as the current domain revision.
177
+
155
178
  ### Native MCP invocation defaults
156
179
 
157
180
  A decorated tool can declare `mcp.defaultApprovalMode: 'allow' | 'confirm' | 'deny'`.