@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
@@ -2,7 +2,7 @@ import { z } from 'zod/v3';
2
2
  import { type AgentOutputDelivery } from '@xpert-ai/contracts';
3
3
  /** Opt in to the host's authorized, on-demand result View from middleware metadata. */
4
4
  export declare const AGENT_TASK_RESULTS_FEATURE = "agent_task_results";
5
- export { agentResultPathSchema, agentOutputDeliverySchema, type AgentOutputDelivery } from '@xpert-ai/contracts';
5
+ export { agentResultPathSchema, agentOutputDeliverySchema, agentDeliveryRecoverySchema, type AgentDeliveryRecovery, type AgentOutputDelivery } from '@xpert-ai/contracts';
6
6
  /** Machine-readable result kind; file declarations are not committed artifacts or download grants. */
7
7
  export declare const agentResultItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
8
8
  type: z.ZodLiteral<"analysis">;
@@ -93,241 +93,21 @@ export declare const agentResultItemSchema: z.ZodDiscriminatedUnion<"type", [z.Z
93
93
  summary?: string;
94
94
  }>]>;
95
95
  export type AgentResultItem = z.output<typeof agentResultItemSchema>;
96
- /** Explicit final response envelope shared by adapters; ordinary prose is never classified heuristically. */
97
- export declare const agentTaskResultSchema: z.ZodEffects<z.ZodObject<{
98
- version: z.ZodLiteral<1>;
99
- summary: z.ZodString;
100
- items: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
101
- type: z.ZodLiteral<"analysis">;
102
- id: z.ZodString;
103
- title: z.ZodString;
104
- summary: z.ZodString;
105
- }, "strict", z.ZodTypeAny, {
106
- type?: "analysis";
107
- id?: string;
108
- title?: string;
109
- summary?: string;
110
- }, {
111
- type?: "analysis";
112
- id?: string;
113
- title?: string;
114
- summary?: string;
115
- }>, z.ZodObject<{
116
- type: z.ZodLiteral<"changes">;
117
- files: z.ZodArray<z.ZodObject<{
118
- path: z.ZodEffects<z.ZodString, string, string>;
119
- change: z.ZodEnum<["created", "modified", "deleted"]>;
120
- }, "strict", z.ZodTypeAny, {
121
- path?: string;
122
- change?: "created" | "modified" | "deleted";
123
- }, {
124
- path?: string;
125
- change?: "created" | "modified" | "deleted";
126
- }>, "many">;
127
- id: z.ZodString;
128
- title: z.ZodString;
129
- summary: z.ZodString;
130
- }, "strict", z.ZodTypeAny, {
131
- type?: "changes";
132
- id?: string;
133
- title?: string;
134
- summary?: string;
135
- files?: {
136
- path?: string;
137
- change?: "created" | "modified" | "deleted";
138
- }[];
139
- }, {
140
- type?: "changes";
141
- id?: string;
142
- title?: string;
143
- summary?: string;
144
- files?: {
145
- path?: string;
146
- change?: "created" | "modified" | "deleted";
147
- }[];
148
- }>, z.ZodObject<{
149
- type: z.ZodLiteral<"tests">;
150
- status: z.ZodEnum<["passed", "failed", "skipped"]>;
151
- command: z.ZodOptional<z.ZodString>;
152
- id: z.ZodString;
153
- title: z.ZodString;
154
- summary: z.ZodString;
155
- }, "strict", z.ZodTypeAny, {
156
- type?: "tests";
157
- status?: "passed" | "failed" | "skipped";
158
- id?: string;
159
- title?: string;
160
- summary?: string;
161
- command?: string;
162
- }, {
163
- type?: "tests";
164
- status?: "passed" | "failed" | "skipped";
165
- id?: string;
166
- title?: string;
167
- summary?: string;
168
- command?: string;
169
- }>, z.ZodObject<{
170
- type: z.ZodLiteral<"file">;
171
- path: z.ZodEffects<z.ZodString, string, string>;
172
- id: z.ZodString;
173
- title: z.ZodString;
174
- summary: z.ZodString;
175
- }, "strict", z.ZodTypeAny, {
176
- type?: "file";
177
- path?: string;
178
- id?: string;
179
- title?: string;
180
- summary?: string;
181
- }, {
182
- type?: "file";
183
- path?: string;
184
- id?: string;
185
- title?: string;
186
- summary?: string;
187
- }>]>, "many">;
188
- }, "strict", z.ZodTypeAny, {
189
- summary?: string;
190
- version?: 1;
191
- items?: ({
192
- type?: "analysis";
193
- id?: string;
194
- title?: string;
195
- summary?: string;
196
- } | {
197
- type?: "changes";
198
- id?: string;
199
- title?: string;
200
- summary?: string;
201
- files?: {
202
- path?: string;
203
- change?: "created" | "modified" | "deleted";
204
- }[];
205
- } | {
206
- type?: "tests";
207
- status?: "passed" | "failed" | "skipped";
208
- id?: string;
209
- title?: string;
210
- summary?: string;
211
- command?: string;
212
- } | {
213
- type?: "file";
214
- path?: string;
215
- id?: string;
216
- title?: string;
217
- summary?: string;
218
- })[];
219
- }, {
220
- summary?: string;
221
- version?: 1;
222
- items?: ({
223
- type?: "analysis";
224
- id?: string;
225
- title?: string;
226
- summary?: string;
227
- } | {
228
- type?: "changes";
229
- id?: string;
230
- title?: string;
231
- summary?: string;
232
- files?: {
233
- path?: string;
234
- change?: "created" | "modified" | "deleted";
235
- }[];
236
- } | {
237
- type?: "tests";
238
- status?: "passed" | "failed" | "skipped";
239
- id?: string;
240
- title?: string;
241
- summary?: string;
242
- command?: string;
243
- } | {
244
- type?: "file";
245
- path?: string;
246
- id?: string;
247
- title?: string;
248
- summary?: string;
249
- })[];
250
- }>, {
251
- summary?: string;
252
- version?: 1;
253
- items?: ({
254
- type?: "analysis";
255
- id?: string;
256
- title?: string;
257
- summary?: string;
258
- } | {
259
- type?: "changes";
260
- id?: string;
261
- title?: string;
262
- summary?: string;
263
- files?: {
264
- path?: string;
265
- change?: "created" | "modified" | "deleted";
266
- }[];
267
- } | {
268
- type?: "tests";
269
- status?: "passed" | "failed" | "skipped";
270
- id?: string;
271
- title?: string;
272
- summary?: string;
273
- command?: string;
274
- } | {
275
- type?: "file";
276
- path?: string;
277
- id?: string;
278
- title?: string;
279
- summary?: string;
280
- })[];
281
- }, {
282
- summary?: string;
283
- version?: 1;
284
- items?: ({
285
- type?: "analysis";
286
- id?: string;
287
- title?: string;
288
- summary?: string;
289
- } | {
290
- type?: "changes";
291
- id?: string;
292
- title?: string;
293
- summary?: string;
294
- files?: {
295
- path?: string;
296
- change?: "created" | "modified" | "deleted";
297
- }[];
298
- } | {
299
- type?: "tests";
300
- status?: "passed" | "failed" | "skipped";
301
- id?: string;
302
- title?: string;
303
- summary?: string;
304
- command?: string;
305
- } | {
306
- type?: "file";
307
- path?: string;
308
- id?: string;
309
- title?: string;
310
- summary?: string;
311
- })[];
312
- }>;
313
- export type AgentTaskResult = z.output<typeof agentTaskResultSchema>;
314
- /** Bound structured report transfer independently of the host's artifact-export quota. */
315
- export declare const AGENT_TASK_RESULT_FILE_MAX_BYTES: number;
316
- /** Explicit final submission of an envelope file. Its digest pins bytes, not a business verdict. */
317
- export declare const agentTaskResultFileSchema: z.ZodObject<{
318
- version: z.ZodLiteral<1>;
319
- path: z.ZodEffects<z.ZodString, string, string>;
320
- sha256: z.ZodString;
321
- }, "strict", z.ZodTypeAny, {
96
+ /** Report bytes are transported independently of artifact quotas and business acceptance. */
97
+ export declare const AGENT_TASK_REPORT_MAX_BYTES: number;
98
+ export type AgentTaskReport = {
99
+ text: string;
100
+ sha256: string;
101
+ };
102
+ export type AgentReportDelivery = {
103
+ status: 'completed';
104
+ sha256: string;
322
105
  path?: string;
323
- version?: 1;
324
- sha256?: string;
325
- }, {
106
+ } | {
107
+ status: 'failed';
108
+ code: 'report_unavailable' | 'report_empty' | 'report_too_large';
326
109
  path?: string;
327
- version?: 1;
328
- sha256?: string;
329
- }>;
330
- export type AgentTaskResultFile = z.output<typeof agentTaskResultFileSchema>;
110
+ };
331
111
  /** Persist only after the platform has committed the artifact; never accept an ID invented by a model. */
332
112
  export interface AgentResultArtifact {
333
113
  id: string;
@@ -90,7 +90,17 @@ export interface AgentInvocationInput {
90
90
  }
91
91
  /** Output or in-progress receipt. Check invocation status before treating it as final. */
92
92
  export interface AgentInvocationResult {
93
+ /** Optional reply content, preserved without imposing a report format; may be empty. */
93
94
  text: string;
95
+ /** The reply exceeded the transport limit; no partial text is presented as complete evidence. */
96
+ textTruncated?: boolean;
97
+ /** Present only when a report file was explicitly selected. */
98
+ report?: import('./results').AgentReportDelivery;
99
+ deliveryHistory?: Array<{
100
+ at: string;
101
+ report?: import('./results').AgentReportDelivery;
102
+ export?: AgentOutputExport;
103
+ }>;
94
104
  /** Explicit adapter-normalized findings; display kind is never inferred from prose or titles. */
95
105
  items?: AgentResultItem[];
96
106
  /** Separate delivery outcome; task success does not imply that files were exported. */
@@ -146,8 +156,15 @@ export interface AgentInvocationRequest {
146
156
  /** Optional host-owned asynchronous reply and project association; not supplied by the execution Agent. */
147
157
  dispatch?: AgentInvocationDispatchContext;
148
158
  }
159
+ /** Host supervisor causes; provider observations cannot replace a pending termination. */
160
+ export type AgentRunnerTerminationReason = 'authorization_revoked' | 'lease_expired' | 'runner_unavailable';
149
161
  /** Host-owned invocation snapshot; not an update DTO. */
150
162
  export interface AgentInvocation extends AgentRuntimeObservation {
163
+ /** Durable host stop intent. Only matching descendant-exit evidence can settle this execution. */
164
+ runnerTermination?: {
165
+ reason: AgentRunnerTerminationReason;
166
+ requestedAt: string;
167
+ };
151
168
  /** Persisted business outcome awaiting independent process completion evidence. */
152
169
  reportedOutcome?: 'succeeded' | 'failed' | 'cancelled';
153
170
  /** Pinned at admission; plugins cannot replace the original host or execution generation. */
@@ -184,6 +201,8 @@ export interface AgentInvocation extends AgentRuntimeObservation {
184
201
  /** Host timestamps in ISO 8601 format. */
185
202
  createdAt: string;
186
203
  updatedAt: string;
204
+ /** First host-confirmed terminal observation; delivery recovery does not extend runtime. Absent on old records. */
205
+ completedAt?: string;
187
206
  }
188
207
  /** Checks confirmed completion; unknown remains non-terminal. */
189
208
  export declare function isAgentInvocationTerminal(status: AgentInvocationStatus): boolean;
@@ -0,0 +1,55 @@
1
+ import type { AgentEventPresentation, AgentEventTypeDefinition, EventDecision, PluginAgentEvent } from '@xpert-ai/contracts';
2
+ export declare const AGENT_EVENT_SOURCE = "XPERT_AGENT_EVENT_SOURCE_V1";
3
+ export declare const AgentEventSourceStrategy: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
4
+ export { agentEventRefSchema, pluginAgentEventSchema, agentEventDecisionSchema, type AgentEventPresentation, type AgentEventTypeDefinition, type AgentEventTypeDisplay, type AgentEventRef, type PluginAgentEvent, type EventDecision } from '@xpert-ai/contracts';
5
+ export type EventPublishResult = {
6
+ status: 'accepted' | 'duplicate';
7
+ receiptId: string;
8
+ } | {
9
+ status: 'rejected';
10
+ code: 'binding_changed' | 'invalid_event' | 'unsupported_version' | 'identity_conflict';
11
+ };
12
+ export interface AgentEventPublisher {
13
+ publish(event: PluginAgentEvent): Promise<EventPublishResult>;
14
+ }
15
+ export interface AgentEventContext {
16
+ readonly bindingId: string;
17
+ readonly bindingRevision: number;
18
+ readonly sourceBindingRef: string;
19
+ readonly tenantId: string;
20
+ readonly organizationId: string;
21
+ readonly workspaceId: string;
22
+ readonly projectId?: string;
23
+ readonly xpertId: string;
24
+ readonly userId: string;
25
+ readonly signal: AbortSignal;
26
+ }
27
+ export interface AgentEventDelivery {
28
+ receiptId: string;
29
+ fence: string;
30
+ event: PluginAgentEvent;
31
+ }
32
+ export interface PluginAgentEventSource {
33
+ readonly key: string;
34
+ readonly protocolVersion: 1;
35
+ readonly eventTypes: readonly AgentEventTypeDefinition[];
36
+ /** Authorized title matches within this binding. The host intersects these with its visible receipts. */
37
+ searchTitles?(context: AgentEventContext, term: string): Promise<({
38
+ subject: string;
39
+ } | {
40
+ result: {
41
+ kind: string;
42
+ key: string;
43
+ };
44
+ })[]>;
45
+ describe?(context: AgentEventContext, event: PluginAgentEvent, decision: EventDecision | null, options?: {
46
+ includeConversation: boolean;
47
+ }): Promise<AgentEventPresentation | null>;
48
+ /** Changes the capture policy only for an authorized source and revision. */
49
+ configure(context: AgentEventContext, enabled: boolean): Promise<void>;
50
+ drain(context: AgentEventContext, publisher: AgentEventPublisher, limit: number): Promise<{
51
+ more: boolean;
52
+ }>;
53
+ handle(context: AgentEventContext, delivery: AgentEventDelivery): Promise<EventDecision>;
54
+ }
55
+ export * from './journal';
@@ -0,0 +1,30 @@
1
+ import type { AgentEventContext, AgentEventDelivery, AgentEventPublisher, EventDecision, PluginAgentEvent } from './index';
2
+ export interface AgentEventSql {
3
+ query<T = unknown>(sql: string, params?: unknown[]): Promise<T>;
4
+ }
5
+ export declare function agentEventDigest(value: unknown): string;
6
+ interface Route {
7
+ binding: string;
8
+ revision: number;
9
+ enabled: boolean;
10
+ }
11
+ export interface AgentEventOrigin {
12
+ tenantId: string;
13
+ organizationId: string;
14
+ ref: string;
15
+ }
16
+ /** PostgreSQL source journal scoped to one plugin's own route and fact tables. */
17
+ export declare class PluginEventJournal {
18
+ private readonly routes;
19
+ private readonly facts;
20
+ constructor(prefix: string);
21
+ private lock;
22
+ configure(tx: AgentEventSql, ctx: AgentEventContext, enabled: boolean): Promise<void>;
23
+ route(tx: AgentEventSql, origin: AgentEventOrigin): Promise<Route>;
24
+ capture(tx: AgentEventSql, route: Route, data: Omit<PluginAgentEvent, 'bindingRevision' | 'fact'>, snapshot: unknown, factKey: string, revision: string): Promise<boolean>;
25
+ drain(db: AgentEventSql, ctx: AgentEventContext, publisher: AgentEventPublisher, limit: number): Promise<{
26
+ more: boolean;
27
+ }>;
28
+ decide(tx: AgentEventSql, ctx: AgentEventContext, delivery: AgentEventDelivery, apply: (snapshot: unknown) => Promise<EventDecision>): Promise<EventDecision>;
29
+ }
30
+ export {};
@@ -75,23 +75,23 @@ export declare const artifactDocumentDependencyAssets: z.ZodArray<z.ZodEffects<z
75
75
  source: z.ZodString;
76
76
  }, "strict", z.ZodTypeAny, {
77
77
  id?: string;
78
+ source?: string;
78
79
  version?: string;
79
80
  sha256?: string;
80
- source?: string;
81
81
  format?: "classic-script";
82
82
  global?: string;
83
83
  }, {
84
84
  id?: string;
85
+ source?: string;
85
86
  version?: string;
86
87
  sha256?: string;
87
- source?: string;
88
88
  format?: "classic-script";
89
89
  global?: string;
90
90
  }>, ArtifactDocumentDependencyAsset, {
91
91
  id?: string;
92
+ source?: string;
92
93
  version?: string;
93
94
  sha256?: string;
94
- source?: string;
95
95
  format?: "classic-script";
96
96
  global?: string;
97
97
  }>, "many">;
@@ -16,14 +16,14 @@ export declare const artifactDocumentQuery: z.ZodObject<{
16
16
  }, "strict", z.ZodTypeAny, {
17
17
  type?: "query";
18
18
  controls?: Record<string, string | number | boolean>;
19
- requestId?: string;
20
19
  bindingId?: string;
20
+ requestId?: string;
21
21
  priority?: "interactive" | "initial" | "refresh";
22
22
  }, {
23
23
  type?: "query";
24
24
  controls?: Record<string, string | number | boolean>;
25
- requestId?: string;
26
25
  bindingId?: string;
26
+ requestId?: string;
27
27
  priority?: "interactive" | "initial" | "refresh";
28
28
  }>;
29
29
  /** Flat UI filter values keyed by declared control IDs; validated again by the backend Binding. */
@@ -1,8 +1,11 @@
1
1
  import type { ArtifactDocumentControls } from './protocol';
2
+ import type { AnalyticsQueryRequest } from '@xpert-ai/contracts';
2
3
  export type ArtifactQueryPriority = 'interactive' | 'initial' | 'refresh';
3
4
  export interface ArtifactQueryInput {
4
5
  bindingId: string;
5
6
  controls: ArtifactDocumentControls;
7
+ /** Forward to the runtime; a refresh must not coalesce with an earlier reuse request. */
8
+ cache?: AnalyticsQueryRequest['cache'];
6
9
  }
7
10
  export interface ArtifactQueryState {
8
11
  bindingId: string;
@@ -1,5 +1,5 @@
1
1
  import { type TXpertTeamDraft } from '@xpert-ai/contracts';
2
- export declare function hasAssistantMiddleware(draft: TXpertTeamDraft, provider: string): boolean;
2
+ export declare function hasAssistantMiddleware(draft: TXpertTeamDraft, provider: string, agentKey?: string): boolean;
3
3
  /** Compose only the draft graph. The platform records the contribution for safe removal.
4
4
  * No Project, permission, external resource or implicit replacement is created here. */
5
5
  export declare function applyAssistantMiddleware(draft: TXpertTeamDraft, input: {
@@ -7,4 +7,5 @@ export declare function applyAssistantMiddleware(draft: TXpertTeamDraft, input:
7
7
  key: string;
8
8
  title: string;
9
9
  instructions: string;
10
+ preserveToolConcurrency?: boolean;
10
11
  }): void;
@@ -1,28 +1,8 @@
1
- import type { ApplyCollaborationUpdateResult, CollaborationPresencePatch, CollaborationSessionDescriptor, ICollaborationActor, ICollaborationPresence } from './types';
2
- export type CollaborationTransportPayload = Record<string, unknown>;
3
- export type CollaborationTransportHandler = (payload: CollaborationTransportPayload) => void;
4
- /** Framework-neutral event transport used by the collaboration client. */
5
- export interface CollaborationTransport {
6
- readonly connected: boolean;
7
- /** Socket/session identifier for this exact browser client, when the transport exposes one. */
8
- readonly clientId?: string | null;
9
- connect(): void;
10
- disconnect(): void;
11
- emit(event: string, payload?: CollaborationTransportPayload): void;
12
- on(event: string, handler: CollaborationTransportHandler): () => void;
13
- }
14
- /** Minimal Socket.IO-compatible shape; keeps socket.io-client out of the SDK bundle. */
15
- export interface CollaborationSocketLike {
16
- readonly connected: boolean;
17
- readonly id?: string;
18
- connect(): unknown;
19
- disconnect(): unknown;
20
- emit(event: string, payload?: CollaborationTransportPayload): unknown;
21
- on(event: string, handler: CollaborationTransportHandler): unknown;
22
- off(event: string, handler: CollaborationTransportHandler): unknown;
23
- }
24
- /** Adapt a caller-owned Socket.IO client to the SDK's framework-neutral transport. */
25
- export declare function createSocketIoTransportAdapter(socket: CollaborationSocketLike): CollaborationTransport;
1
+ import type { CollaborationTransport } from './transport';
2
+ import { type CollaborationPresenceSnapshotMetadata } from './presence';
3
+ export * from './transport';
4
+ export * from './presence';
5
+ import type { ApplyCollaborationUpdateResult, CollaborationPresencePatch, CollaborationSessionDescriptor, ICollaborationPresence } from './types';
26
6
  export type CollaborationDocumentUpdateHandler = (update: Uint8Array, origin: unknown) => void;
27
7
  /** Binary CRDT operations required by the generic collaboration client. */
28
8
  export interface CollaborationBinaryDocumentAdapter {
@@ -74,41 +54,8 @@ export interface CollaborationClient {
74
54
  requestSync(): void;
75
55
  setPresence(patch: CollaborationPresencePatch): void;
76
56
  }
77
- /** Connection-specific metadata delivered with a presence snapshot. */
78
- export type CollaborationPresenceSnapshotMetadata = {
79
- selfClientId: string | null;
80
- };
81
- /** Stable, framework-neutral view of active collaboration sessions and deduplicated actors. */
82
- export type CollaborationPresenceStoreSnapshot = {
83
- selfClientId: string | null;
84
- /** Every active browser/Agent session keyed by `clientId`. */
85
- sessions: ICollaborationPresence[];
86
- /** Sessions excluding only this exact browser client. */
87
- remoteSessions: ICollaborationPresence[];
88
- /** One entry per actor identity, including the local actor when supplied. */
89
- collaborators: ICollaborationPresence[];
90
- };
91
- export type CollaborationPresenceStoreOptions = {
92
- selfActor?: ICollaborationActor | null;
93
- includeSelf?: boolean;
94
- onChange?: (snapshot: CollaborationPresenceStoreSnapshot) => void;
95
- };
96
- /** Mutable presence projection used by plugin UIs without coupling them to a framework. */
97
- export interface CollaborationPresenceStore {
98
- setSelfClientId(clientId: string | null): void;
99
- replace(items: ICollaborationPresence[], selfClientId?: string | null): void;
100
- upsert(item: ICollaborationPresence): void;
101
- remove(clientId: string): void;
102
- clear(): void;
103
- snapshot(): CollaborationPresenceStoreSnapshot;
104
- }
105
- /**
106
- * Keep per-client sessions for cursors while exposing one collaborator per stable actor identity.
107
- * This prevents a second tab owned by the same user from either duplicating or hiding that user.
108
- */
109
- export declare function createCollaborationPresenceStore(options?: CollaborationPresenceStoreOptions): CollaborationPresenceStore;
110
57
  /**
111
- * Create a collaboration client with update batching, state-vector repair, presence heartbeat,
58
+ * Create a Yjs collaboration client with update batching, state-vector repair, presence heartbeat,
112
59
  * and reconnect synchronization. The caller retains ownership of the document and transport.
113
60
  */
114
61
  export declare function createCollaborationClient(options: CollaborationClientOptions): CollaborationClient;
@@ -3,3 +3,4 @@ export * from './runtime-capability';
3
3
  export * from './provider.decorator';
4
4
  export * from './provider.registry';
5
5
  export * from './client';
6
+ export * from './operations-client';
@@ -0,0 +1,23 @@
1
+ import type { CollaborationTransport } from './transport';
2
+ import type { CollaborationPresencePatch, CollaborationSessionDescriptor, ICollaborationPresence } from './types';
3
+ export type OperationCollaborationOptions = {
4
+ session: CollaborationSessionDescriptor;
5
+ transport: CollaborationTransport;
6
+ /** Invalidate/refetch domain state; this is neither an operation payload nor a save acknowledgement. */
7
+ onRevision(revision: number): void;
8
+ onPresence(items: ICollaborationPresence[], selfClientId: string | null): void;
9
+ onConnection(state: 'connected' | 'disconnected'): void;
10
+ onError(error: Error): void;
11
+ };
12
+ /**
13
+ * Notification client for a domain-owned operation log, not an OT/CRDT implementation.
14
+ * The domain API owns writes, validation, conflict handling and persistence. This client
15
+ * only tracks committed revisions and ephemeral presence; it never submits business edits.
16
+ * Revisions coalesce to one high-water mark, so consumers must refetch authoritative state.
17
+ */
18
+ export declare function createOperationCollaborationClient(options: OperationCollaborationOptions): {
19
+ connect(): void;
20
+ disconnect: () => void;
21
+ requestSync: () => void;
22
+ setPresence(value: CollaborationPresencePatch): void;
23
+ };
@@ -0,0 +1,36 @@
1
+ import type { ICollaborationActor, ICollaborationPresence } from './types';
2
+ /** Connection-specific metadata delivered with a presence snapshot. */
3
+ export type CollaborationPresenceSnapshotMetadata = {
4
+ selfClientId: string | null;
5
+ };
6
+ /** Stable, framework-neutral view of active collaboration sessions and deduplicated actors. */
7
+ export type CollaborationPresenceStoreSnapshot = {
8
+ selfClientId: string | null;
9
+ /** Every active browser/Agent session keyed by `clientId`. */
10
+ sessions: ICollaborationPresence[];
11
+ /** Sessions excluding only this exact browser client. */
12
+ remoteSessions: ICollaborationPresence[];
13
+ /** One entry per actor identity, including the local actor when supplied. */
14
+ collaborators: ICollaborationPresence[];
15
+ };
16
+ export type CollaborationPresenceStoreOptions = {
17
+ selfActor?: ICollaborationActor | null;
18
+ includeSelf?: boolean;
19
+ onChange?: (snapshot: CollaborationPresenceStoreSnapshot) => void;
20
+ };
21
+ /** Mutable presence projection used by plugin UIs without coupling them to a framework. */
22
+ export interface CollaborationPresenceStore {
23
+ setSelfClientId(clientId: string | null): void;
24
+ replace(items: ICollaborationPresence[], selfClientId?: string | null): void;
25
+ upsert(item: ICollaborationPresence): void;
26
+ remove(clientId: string): void;
27
+ clear(): void;
28
+ snapshot(): CollaborationPresenceStoreSnapshot;
29
+ }
30
+ /**
31
+ * Keep per-client sessions for cursors while exposing one collaborator per stable actor identity.
32
+ * This prevents a second tab owned by the same user from either duplicating or hiding that user.
33
+ */
34
+ export declare function createCollaborationPresenceStore(options?: CollaborationPresenceStoreOptions): CollaborationPresenceStore;
35
+ /** Parse untrusted presence payloads shared by both engines; document content is ignored. */
36
+ export declare function parseCollaborationPresence(value: unknown): ICollaborationPresence | null;
@@ -1,7 +1,7 @@
1
1
  import { DiscoveryService, Reflector } from '@nestjs/core';
2
2
  import { BaseStrategyRegistry } from '../strategy';
3
- import type { ICollaborationDocumentProvider } from './types';
3
+ import type { CollaborationProvider } from './types';
4
4
  /** Discovers system and organization-scoped collaboration providers from loaded plugins. */
5
- export declare class CollaborationDocumentProviderRegistry extends BaseStrategyRegistry<ICollaborationDocumentProvider> {
5
+ export declare class CollaborationDocumentProviderRegistry extends BaseStrategyRegistry<CollaborationProvider> {
6
6
  constructor(discoveryService: DiscoveryService, reflector: Reflector);
7
7
  }
@@ -0,0 +1,24 @@
1
+ export type CollaborationTransportPayload = Record<string, unknown>;
2
+ export type CollaborationTransportHandler = (payload: CollaborationTransportPayload) => void;
3
+ /** Framework-neutral event transport used by the collaboration client. */
4
+ export interface CollaborationTransport {
5
+ readonly connected: boolean;
6
+ /** Socket/session identifier for this exact browser client, when the transport exposes one. */
7
+ readonly clientId?: string | null;
8
+ connect(): void;
9
+ disconnect(): void;
10
+ emit(event: string, payload?: CollaborationTransportPayload): void;
11
+ on(event: string, handler: CollaborationTransportHandler): () => void;
12
+ }
13
+ /** Minimal Socket.IO-compatible shape; keeps socket.io-client out of the SDK bundle. */
14
+ export interface CollaborationSocketLike {
15
+ readonly connected: boolean;
16
+ readonly id?: string;
17
+ connect(): unknown;
18
+ disconnect(): unknown;
19
+ emit(event: string, payload?: CollaborationTransportPayload): unknown;
20
+ on(event: string, handler: CollaborationTransportHandler): unknown;
21
+ off(event: string, handler: CollaborationTransportHandler): unknown;
22
+ }
23
+ /** Adapt a caller-owned Socket.IO client to the SDK's framework-neutral transport. */
24
+ export declare function createSocketIoTransportAdapter(socket: CollaborationSocketLike): CollaborationTransport;