@ixo/topic-protocol 0.1.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.
- package/README.md +133 -0
- package/dist/schemas/action-receipt.schema.json +18 -0
- package/dist/schemas/agent-run.schema.json +18 -0
- package/dist/schemas/external-session-binding.schema.json +24 -0
- package/dist/schemas/room-policy.schema.json +15 -0
- package/dist/schemas/topic-capsule.schema.json +19 -0
- package/dist/schemas/topic-index-entry.schema.json +17 -0
- package/dist/schemas/topic-message.schema.json +18 -0
- package/dist/schemas/topic-operation.schema.json +19 -0
- package/dist/schemas/topic-preferences.schema.json +13 -0
- package/dist/schemas/topic-record.schema.json +18 -0
- package/dist/schemas/topic-relation.schema.json +16 -0
- package/dist/schemas/topic-root.schema.json +18 -0
- package/dist/schemas/topic-state.schema.json +19 -0
- package/dist/src/contracts/schemas.d.ts +569 -0
- package/dist/src/contracts/schemas.js +30 -0
- package/dist/src/contracts/schemas.js.map +1 -0
- package/dist/src/contracts/validator.d.ts +14 -0
- package/dist/src/contracts/validator.js +43 -0
- package/dist/src/contracts/validator.js.map +1 -0
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.js +11 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/matrix/anchors.d.ts +2 -0
- package/dist/src/matrix/anchors.js +55 -0
- package/dist/src/matrix/anchors.js.map +1 -0
- package/dist/src/matrix/content.d.ts +11 -0
- package/dist/src/matrix/content.js +64 -0
- package/dist/src/matrix/content.js.map +1 -0
- package/dist/src/matrix/events.d.ts +4 -0
- package/dist/src/matrix/events.js +94 -0
- package/dist/src/matrix/events.js.map +1 -0
- package/dist/src/matrix/pending.d.ts +22 -0
- package/dist/src/matrix/pending.js +83 -0
- package/dist/src/matrix/pending.js.map +1 -0
- package/dist/src/matrix/runtime.d.ts +18 -0
- package/dist/src/matrix/runtime.js +121 -0
- package/dist/src/matrix/runtime.js.map +1 -0
- package/dist/src/matrix/types.d.ts +84 -0
- package/dist/src/matrix/types.js +5 -0
- package/dist/src/matrix/types.js.map +1 -0
- package/dist/src/projector/payload.d.ts +27 -0
- package/dist/src/projector/payload.js +80 -0
- package/dist/src/projector/payload.js.map +1 -0
- package/dist/src/projector/prepare.d.ts +3 -0
- package/dist/src/projector/prepare.js +47 -0
- package/dist/src/projector/prepare.js.map +1 -0
- package/dist/src/projector/project.d.ts +2 -0
- package/dist/src/projector/project.js +89 -0
- package/dist/src/projector/project.js.map +1 -0
- package/dist/src/projector/state.d.ts +8 -0
- package/dist/src/projector/state.js +89 -0
- package/dist/src/projector/state.js.map +1 -0
- package/dist/src/projector/types.d.ts +76 -0
- package/dist/src/projector/types.js +19 -0
- package/dist/src/projector/types.js.map +1 -0
- package/dist/src/shared/compare.d.ts +2 -0
- package/dist/src/shared/compare.js +14 -0
- package/dist/src/shared/compare.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
export declare const SCHEMA_REGISTRY: Readonly<{
|
|
2
|
+
"action-receipt": {
|
|
3
|
+
$schema: string;
|
|
4
|
+
$id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
type: string;
|
|
7
|
+
required: string[];
|
|
8
|
+
properties: {
|
|
9
|
+
receiptId: {
|
|
10
|
+
type: string;
|
|
11
|
+
minLength: number;
|
|
12
|
+
};
|
|
13
|
+
topicId: {
|
|
14
|
+
type: string;
|
|
15
|
+
pattern: string;
|
|
16
|
+
};
|
|
17
|
+
action: {
|
|
18
|
+
type: string;
|
|
19
|
+
minLength: number;
|
|
20
|
+
};
|
|
21
|
+
actor: {
|
|
22
|
+
type: string;
|
|
23
|
+
minLength: number;
|
|
24
|
+
};
|
|
25
|
+
status: {
|
|
26
|
+
type: string;
|
|
27
|
+
enum: string[];
|
|
28
|
+
};
|
|
29
|
+
idempotencyKey: {
|
|
30
|
+
type: string;
|
|
31
|
+
minLength: number;
|
|
32
|
+
};
|
|
33
|
+
createdAt: {
|
|
34
|
+
type: string;
|
|
35
|
+
format: string;
|
|
36
|
+
};
|
|
37
|
+
capability: {
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
additionalProperties: boolean;
|
|
42
|
+
};
|
|
43
|
+
"agent-run": {
|
|
44
|
+
$schema: string;
|
|
45
|
+
$id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
type: string;
|
|
48
|
+
required: string[];
|
|
49
|
+
properties: {
|
|
50
|
+
runId: {
|
|
51
|
+
type: string;
|
|
52
|
+
minLength: number;
|
|
53
|
+
};
|
|
54
|
+
topicId: {
|
|
55
|
+
type: string;
|
|
56
|
+
pattern: string;
|
|
57
|
+
};
|
|
58
|
+
agentId: {
|
|
59
|
+
type: string;
|
|
60
|
+
minLength: number;
|
|
61
|
+
};
|
|
62
|
+
capsuleRevision: {
|
|
63
|
+
type: string;
|
|
64
|
+
minLength: number;
|
|
65
|
+
};
|
|
66
|
+
status: {
|
|
67
|
+
type: string;
|
|
68
|
+
enum: string[];
|
|
69
|
+
};
|
|
70
|
+
startedAt: {
|
|
71
|
+
type: string;
|
|
72
|
+
format: string;
|
|
73
|
+
};
|
|
74
|
+
finishedAt: {
|
|
75
|
+
type: string;
|
|
76
|
+
format: string;
|
|
77
|
+
};
|
|
78
|
+
outputs: {
|
|
79
|
+
type: string;
|
|
80
|
+
items: {
|
|
81
|
+
type: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
additionalProperties: boolean;
|
|
86
|
+
};
|
|
87
|
+
"external-session-binding": {
|
|
88
|
+
$schema: string;
|
|
89
|
+
$id: string;
|
|
90
|
+
title: string;
|
|
91
|
+
type: string;
|
|
92
|
+
required: string[];
|
|
93
|
+
properties: {
|
|
94
|
+
bindingId: {
|
|
95
|
+
type: string;
|
|
96
|
+
minLength: number;
|
|
97
|
+
};
|
|
98
|
+
topicId: {
|
|
99
|
+
type: string;
|
|
100
|
+
pattern: string;
|
|
101
|
+
};
|
|
102
|
+
provider: {
|
|
103
|
+
type: string;
|
|
104
|
+
minLength: number;
|
|
105
|
+
};
|
|
106
|
+
sessionReference: {
|
|
107
|
+
type: string;
|
|
108
|
+
minLength: number;
|
|
109
|
+
};
|
|
110
|
+
actor: {
|
|
111
|
+
type: string;
|
|
112
|
+
minLength: number;
|
|
113
|
+
};
|
|
114
|
+
createdAt: {
|
|
115
|
+
type: string;
|
|
116
|
+
format: string;
|
|
117
|
+
};
|
|
118
|
+
policy: {
|
|
119
|
+
type: string;
|
|
120
|
+
required: string[];
|
|
121
|
+
properties: {
|
|
122
|
+
privateByDefault: {
|
|
123
|
+
type: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
additionalProperties: boolean;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
additionalProperties: boolean;
|
|
130
|
+
};
|
|
131
|
+
"room-policy": {
|
|
132
|
+
$schema: string;
|
|
133
|
+
$id: string;
|
|
134
|
+
title: string;
|
|
135
|
+
type: string;
|
|
136
|
+
required: string[];
|
|
137
|
+
properties: {
|
|
138
|
+
version: {
|
|
139
|
+
const: number;
|
|
140
|
+
};
|
|
141
|
+
mode: {
|
|
142
|
+
type: string;
|
|
143
|
+
enum: string[];
|
|
144
|
+
};
|
|
145
|
+
generalEnabled: {
|
|
146
|
+
type: string;
|
|
147
|
+
};
|
|
148
|
+
allowTopicsInDirectRooms: {
|
|
149
|
+
type: string;
|
|
150
|
+
};
|
|
151
|
+
authorisedRoles: {
|
|
152
|
+
type: string;
|
|
153
|
+
items: {
|
|
154
|
+
type: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
additionalProperties: boolean;
|
|
159
|
+
};
|
|
160
|
+
"topic-capsule": {
|
|
161
|
+
$schema: string;
|
|
162
|
+
$id: string;
|
|
163
|
+
title: string;
|
|
164
|
+
type: string;
|
|
165
|
+
required: string[];
|
|
166
|
+
properties: {
|
|
167
|
+
topicId: {
|
|
168
|
+
type: string;
|
|
169
|
+
pattern: string;
|
|
170
|
+
};
|
|
171
|
+
anchor: {
|
|
172
|
+
type: string;
|
|
173
|
+
required: string[];
|
|
174
|
+
properties: {
|
|
175
|
+
roomId: {
|
|
176
|
+
type: string;
|
|
177
|
+
};
|
|
178
|
+
rootEventId: {
|
|
179
|
+
type: string;
|
|
180
|
+
pattern: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
stateRevision: {
|
|
185
|
+
type: string;
|
|
186
|
+
minLength: number;
|
|
187
|
+
};
|
|
188
|
+
participants: {
|
|
189
|
+
type: string;
|
|
190
|
+
items: {
|
|
191
|
+
type: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
linkedContext: {
|
|
195
|
+
type: string;
|
|
196
|
+
items: {
|
|
197
|
+
type: string;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
acceptedMemory: {
|
|
201
|
+
type: string;
|
|
202
|
+
items: {
|
|
203
|
+
type: string;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
relevantEvents: {
|
|
207
|
+
type: string;
|
|
208
|
+
items: {
|
|
209
|
+
type: string;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
capabilities: {
|
|
213
|
+
type: string;
|
|
214
|
+
items: {
|
|
215
|
+
type: string;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
runtimePolicy: {
|
|
219
|
+
type: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
additionalProperties: boolean;
|
|
223
|
+
};
|
|
224
|
+
"topic-index-entry": {
|
|
225
|
+
$schema: string;
|
|
226
|
+
$id: string;
|
|
227
|
+
title: string;
|
|
228
|
+
type: string;
|
|
229
|
+
required: string[];
|
|
230
|
+
properties: {
|
|
231
|
+
topicId: {
|
|
232
|
+
type: string;
|
|
233
|
+
pattern: string;
|
|
234
|
+
};
|
|
235
|
+
roomId: {
|
|
236
|
+
type: string;
|
|
237
|
+
minLength: number;
|
|
238
|
+
};
|
|
239
|
+
rootEventId: {
|
|
240
|
+
type: string;
|
|
241
|
+
pattern: string;
|
|
242
|
+
};
|
|
243
|
+
status: {
|
|
244
|
+
type: string;
|
|
245
|
+
};
|
|
246
|
+
latestActivityAt: {
|
|
247
|
+
type: string;
|
|
248
|
+
format: string;
|
|
249
|
+
};
|
|
250
|
+
notificationMode: {
|
|
251
|
+
type: string;
|
|
252
|
+
enum: string[];
|
|
253
|
+
};
|
|
254
|
+
completeness: {
|
|
255
|
+
type: string;
|
|
256
|
+
enum: string[];
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
additionalProperties: boolean;
|
|
260
|
+
};
|
|
261
|
+
"topic-message": {
|
|
262
|
+
$schema: string;
|
|
263
|
+
$id: string;
|
|
264
|
+
title: string;
|
|
265
|
+
type: string;
|
|
266
|
+
required: string[];
|
|
267
|
+
properties: {
|
|
268
|
+
topicId: {
|
|
269
|
+
type: string;
|
|
270
|
+
pattern: string;
|
|
271
|
+
};
|
|
272
|
+
roomId: {
|
|
273
|
+
type: string;
|
|
274
|
+
minLength: number;
|
|
275
|
+
};
|
|
276
|
+
rootEventId: {
|
|
277
|
+
type: string;
|
|
278
|
+
pattern: string;
|
|
279
|
+
};
|
|
280
|
+
eventId: {
|
|
281
|
+
type: string;
|
|
282
|
+
pattern: string;
|
|
283
|
+
};
|
|
284
|
+
sender: {
|
|
285
|
+
type: string;
|
|
286
|
+
minLength: number;
|
|
287
|
+
};
|
|
288
|
+
body: {
|
|
289
|
+
type: string;
|
|
290
|
+
};
|
|
291
|
+
createdAt: {
|
|
292
|
+
type: string;
|
|
293
|
+
format: string;
|
|
294
|
+
};
|
|
295
|
+
inReplyTo: {
|
|
296
|
+
type: string;
|
|
297
|
+
pattern: string;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
additionalProperties: boolean;
|
|
301
|
+
};
|
|
302
|
+
"topic-operation": {
|
|
303
|
+
$schema: string;
|
|
304
|
+
$id: string;
|
|
305
|
+
title: string;
|
|
306
|
+
type: string;
|
|
307
|
+
required: string[];
|
|
308
|
+
properties: {
|
|
309
|
+
version: {
|
|
310
|
+
const: number;
|
|
311
|
+
};
|
|
312
|
+
operationId: {
|
|
313
|
+
type: string;
|
|
314
|
+
minLength: number;
|
|
315
|
+
};
|
|
316
|
+
topicId: {
|
|
317
|
+
type: string;
|
|
318
|
+
pattern: string;
|
|
319
|
+
};
|
|
320
|
+
type: {
|
|
321
|
+
type: string;
|
|
322
|
+
enum: string[];
|
|
323
|
+
};
|
|
324
|
+
previousRevision: {
|
|
325
|
+
type: string;
|
|
326
|
+
minLength: number;
|
|
327
|
+
};
|
|
328
|
+
actor: {
|
|
329
|
+
type: string;
|
|
330
|
+
minLength: number;
|
|
331
|
+
};
|
|
332
|
+
createdAt: {
|
|
333
|
+
type: string;
|
|
334
|
+
format: string;
|
|
335
|
+
};
|
|
336
|
+
payload: {
|
|
337
|
+
type: string;
|
|
338
|
+
};
|
|
339
|
+
capability: {
|
|
340
|
+
type: string;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
additionalProperties: boolean;
|
|
344
|
+
};
|
|
345
|
+
"topic-preferences": {
|
|
346
|
+
$schema: string;
|
|
347
|
+
$id: string;
|
|
348
|
+
title: string;
|
|
349
|
+
type: string;
|
|
350
|
+
required: string[];
|
|
351
|
+
properties: {
|
|
352
|
+
version: {
|
|
353
|
+
const: number;
|
|
354
|
+
};
|
|
355
|
+
topics: {
|
|
356
|
+
type: string;
|
|
357
|
+
additionalProperties: {
|
|
358
|
+
type: string;
|
|
359
|
+
required: string[];
|
|
360
|
+
properties: {
|
|
361
|
+
notificationMode: {
|
|
362
|
+
type: string;
|
|
363
|
+
enum: string[];
|
|
364
|
+
};
|
|
365
|
+
pinned: {
|
|
366
|
+
type: string;
|
|
367
|
+
};
|
|
368
|
+
markedUnreadFrom: {
|
|
369
|
+
type: string[];
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
autoFollow: {
|
|
375
|
+
type: string;
|
|
376
|
+
enum: string[];
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
additionalProperties: boolean;
|
|
380
|
+
};
|
|
381
|
+
"topic-record": {
|
|
382
|
+
$schema: string;
|
|
383
|
+
$id: string;
|
|
384
|
+
title: string;
|
|
385
|
+
type: string;
|
|
386
|
+
required: string[];
|
|
387
|
+
properties: {
|
|
388
|
+
recordId: {
|
|
389
|
+
type: string;
|
|
390
|
+
minLength: number;
|
|
391
|
+
};
|
|
392
|
+
topicId: {
|
|
393
|
+
type: string;
|
|
394
|
+
pattern: string;
|
|
395
|
+
};
|
|
396
|
+
kind: {
|
|
397
|
+
type: string;
|
|
398
|
+
enum: string[];
|
|
399
|
+
};
|
|
400
|
+
createdBy: {
|
|
401
|
+
type: string;
|
|
402
|
+
minLength: number;
|
|
403
|
+
};
|
|
404
|
+
createdAt: {
|
|
405
|
+
type: string;
|
|
406
|
+
format: string;
|
|
407
|
+
};
|
|
408
|
+
sourceEventIds: {
|
|
409
|
+
type: string;
|
|
410
|
+
items: {
|
|
411
|
+
type: string;
|
|
412
|
+
pattern: string;
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
content: {
|
|
416
|
+
type: string;
|
|
417
|
+
};
|
|
418
|
+
accepted: {
|
|
419
|
+
type: string;
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
additionalProperties: boolean;
|
|
423
|
+
};
|
|
424
|
+
"topic-relation": {
|
|
425
|
+
$schema: string;
|
|
426
|
+
$id: string;
|
|
427
|
+
title: string;
|
|
428
|
+
type: string;
|
|
429
|
+
required: string[];
|
|
430
|
+
properties: {
|
|
431
|
+
relationId: {
|
|
432
|
+
type: string;
|
|
433
|
+
minLength: number;
|
|
434
|
+
};
|
|
435
|
+
fromTopicId: {
|
|
436
|
+
type: string;
|
|
437
|
+
pattern: string;
|
|
438
|
+
};
|
|
439
|
+
type: {
|
|
440
|
+
type: string;
|
|
441
|
+
enum: string[];
|
|
442
|
+
};
|
|
443
|
+
toTopicId: {
|
|
444
|
+
type: string;
|
|
445
|
+
pattern: string;
|
|
446
|
+
};
|
|
447
|
+
createdBy: {
|
|
448
|
+
type: string;
|
|
449
|
+
minLength: number;
|
|
450
|
+
};
|
|
451
|
+
createdAt: {
|
|
452
|
+
type: string;
|
|
453
|
+
format: string;
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
additionalProperties: boolean;
|
|
457
|
+
};
|
|
458
|
+
"topic-root": {
|
|
459
|
+
$schema: string;
|
|
460
|
+
$id: string;
|
|
461
|
+
title: string;
|
|
462
|
+
type: string;
|
|
463
|
+
required: string[];
|
|
464
|
+
properties: {
|
|
465
|
+
version: {
|
|
466
|
+
const: number;
|
|
467
|
+
};
|
|
468
|
+
id: {
|
|
469
|
+
type: string;
|
|
470
|
+
pattern: string;
|
|
471
|
+
};
|
|
472
|
+
title: {
|
|
473
|
+
type: string;
|
|
474
|
+
minLength: number;
|
|
475
|
+
maxLength: number;
|
|
476
|
+
};
|
|
477
|
+
kind: {
|
|
478
|
+
type: string;
|
|
479
|
+
enum: string[];
|
|
480
|
+
};
|
|
481
|
+
status: {
|
|
482
|
+
type: string;
|
|
483
|
+
enum: string[];
|
|
484
|
+
};
|
|
485
|
+
createdBy: {
|
|
486
|
+
type: string;
|
|
487
|
+
minLength: number;
|
|
488
|
+
};
|
|
489
|
+
createdAt: {
|
|
490
|
+
type: string;
|
|
491
|
+
format: string;
|
|
492
|
+
};
|
|
493
|
+
context: {
|
|
494
|
+
type: string;
|
|
495
|
+
items: {
|
|
496
|
+
type: string;
|
|
497
|
+
required: string[];
|
|
498
|
+
properties: {
|
|
499
|
+
type: {
|
|
500
|
+
type: string;
|
|
501
|
+
};
|
|
502
|
+
id: {
|
|
503
|
+
type: string;
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
additionalProperties: boolean;
|
|
510
|
+
};
|
|
511
|
+
"topic-state": {
|
|
512
|
+
$schema: string;
|
|
513
|
+
$id: string;
|
|
514
|
+
title: string;
|
|
515
|
+
type: string;
|
|
516
|
+
required: string[];
|
|
517
|
+
properties: {
|
|
518
|
+
topicId: {
|
|
519
|
+
type: string;
|
|
520
|
+
pattern: string;
|
|
521
|
+
};
|
|
522
|
+
revision: {
|
|
523
|
+
type: string;
|
|
524
|
+
minLength: number;
|
|
525
|
+
};
|
|
526
|
+
status: {
|
|
527
|
+
type: string;
|
|
528
|
+
enum: string[];
|
|
529
|
+
};
|
|
530
|
+
purpose: {
|
|
531
|
+
type: string;
|
|
532
|
+
};
|
|
533
|
+
acceptedFacts: {
|
|
534
|
+
type: string;
|
|
535
|
+
items: {
|
|
536
|
+
type: string;
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
decisions: {
|
|
540
|
+
type: string;
|
|
541
|
+
items: {
|
|
542
|
+
type: string;
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
unresolvedQuestions: {
|
|
546
|
+
type: string;
|
|
547
|
+
items: {
|
|
548
|
+
type: string;
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
basedOnEvents: {
|
|
552
|
+
type: string;
|
|
553
|
+
items: {
|
|
554
|
+
type: string;
|
|
555
|
+
pattern: string;
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
conflicts: {
|
|
559
|
+
type: string;
|
|
560
|
+
items: {
|
|
561
|
+
type: string;
|
|
562
|
+
};
|
|
563
|
+
};
|
|
564
|
+
};
|
|
565
|
+
additionalProperties: boolean;
|
|
566
|
+
};
|
|
567
|
+
}>;
|
|
568
|
+
export type ContractName = keyof typeof SCHEMA_REGISTRY;
|
|
569
|
+
export declare const CONTRACT_NAMES: readonly ("action-receipt" | "agent-run" | "external-session-binding" | "room-policy" | "topic-capsule" | "topic-index-entry" | "topic-message" | "topic-operation" | "topic-preferences" | "topic-record" | "topic-relation" | "topic-root" | "topic-state")[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import actionReceipt from "../../schemas/action-receipt.schema.json" with { type: "json" };
|
|
2
|
+
import agentRun from "../../schemas/agent-run.schema.json" with { type: "json" };
|
|
3
|
+
import externalSessionBinding from "../../schemas/external-session-binding.schema.json" with { type: "json" };
|
|
4
|
+
import roomPolicy from "../../schemas/room-policy.schema.json" with { type: "json" };
|
|
5
|
+
import topicCapsule from "../../schemas/topic-capsule.schema.json" with { type: "json" };
|
|
6
|
+
import topicIndexEntry from "../../schemas/topic-index-entry.schema.json" with { type: "json" };
|
|
7
|
+
import topicMessage from "../../schemas/topic-message.schema.json" with { type: "json" };
|
|
8
|
+
import topicOperation from "../../schemas/topic-operation.schema.json" with { type: "json" };
|
|
9
|
+
import topicPreferences from "../../schemas/topic-preferences.schema.json" with { type: "json" };
|
|
10
|
+
import topicRecord from "../../schemas/topic-record.schema.json" with { type: "json" };
|
|
11
|
+
import topicRelation from "../../schemas/topic-relation.schema.json" with { type: "json" };
|
|
12
|
+
import topicRoot from "../../schemas/topic-root.schema.json" with { type: "json" };
|
|
13
|
+
import topicState from "../../schemas/topic-state.schema.json" with { type: "json" };
|
|
14
|
+
export const SCHEMA_REGISTRY = Object.freeze({
|
|
15
|
+
"action-receipt": actionReceipt,
|
|
16
|
+
"agent-run": agentRun,
|
|
17
|
+
"external-session-binding": externalSessionBinding,
|
|
18
|
+
"room-policy": roomPolicy,
|
|
19
|
+
"topic-capsule": topicCapsule,
|
|
20
|
+
"topic-index-entry": topicIndexEntry,
|
|
21
|
+
"topic-message": topicMessage,
|
|
22
|
+
"topic-operation": topicOperation,
|
|
23
|
+
"topic-preferences": topicPreferences,
|
|
24
|
+
"topic-record": topicRecord,
|
|
25
|
+
"topic-relation": topicRelation,
|
|
26
|
+
"topic-root": topicRoot,
|
|
27
|
+
"topic-state": topicState,
|
|
28
|
+
});
|
|
29
|
+
export const CONTRACT_NAMES = Object.freeze(Object.keys(SCHEMA_REGISTRY).sort());
|
|
30
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/contracts/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3F,OAAO,QAAQ,MAAM,qCAAqC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACjF,OAAO,sBAAsB,MAAM,oDAAoD,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9G,OAAO,UAAU,MAAM,uCAAuC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrF,OAAO,YAAY,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACzF,OAAO,eAAe,MAAM,6CAA6C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChG,OAAO,YAAY,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACzF,OAAO,cAAc,MAAM,2CAA2C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7F,OAAO,gBAAgB,MAAM,6CAA6C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACjG,OAAO,WAAW,MAAM,wCAAwC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvF,OAAO,aAAa,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3F,OAAO,SAAS,MAAM,sCAAsC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnF,OAAO,UAAU,MAAM,uCAAuC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAErF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,gBAAgB,EAAE,aAAa;IAC/B,WAAW,EAAE,QAAQ;IACrB,0BAA0B,EAAE,sBAAsB;IAClD,aAAa,EAAE,UAAU;IACzB,eAAe,EAAE,YAAY;IAC7B,mBAAmB,EAAE,eAAe;IACpC,eAAe,EAAE,YAAY;IAC7B,iBAAiB,EAAE,cAAc;IACjC,mBAAmB,EAAE,gBAAgB;IACrC,cAAc,EAAE,WAAW;IAC3B,gBAAgB,EAAE,aAAa;IAC/B,YAAY,EAAE,SAAS;IACvB,aAAa,EAAE,UAAU;CAC1B,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CACzC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,EAAoB,CACtD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ContractName } from "./schemas.js";
|
|
2
|
+
export interface ContractValidationError {
|
|
3
|
+
readonly instancePath: string;
|
|
4
|
+
readonly keyword: string;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
}
|
|
7
|
+
export type ContractValidationResult = {
|
|
8
|
+
readonly ok: true;
|
|
9
|
+
} | {
|
|
10
|
+
readonly ok: false;
|
|
11
|
+
readonly errors: readonly ContractValidationError[];
|
|
12
|
+
};
|
|
13
|
+
export declare function validateContract(name: ContractName, value: unknown): ContractValidationResult;
|
|
14
|
+
export declare function assertContract(name: ContractName, value: unknown): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Ajv2020, } from "ajv/dist/2020.js";
|
|
2
|
+
import * as formatsModule from "ajv-formats";
|
|
3
|
+
import { TopicProtocolError } from "../errors.js";
|
|
4
|
+
import { SCHEMA_REGISTRY, } from "./schemas.js";
|
|
5
|
+
const ajv = new Ajv2020({ allErrors: true, strict: true });
|
|
6
|
+
const validators = new Map();
|
|
7
|
+
const addFormats = formatsModule.default;
|
|
8
|
+
addFormats(ajv);
|
|
9
|
+
function isContractName(value) {
|
|
10
|
+
return Object.hasOwn(SCHEMA_REGISTRY, value);
|
|
11
|
+
}
|
|
12
|
+
function validatorFor(name) {
|
|
13
|
+
const existing = validators.get(name);
|
|
14
|
+
if (existing !== undefined)
|
|
15
|
+
return existing;
|
|
16
|
+
const validator = ajv.compile(SCHEMA_REGISTRY[name]);
|
|
17
|
+
validators.set(name, validator);
|
|
18
|
+
return validator;
|
|
19
|
+
}
|
|
20
|
+
function normaliseError(error) {
|
|
21
|
+
const path = error.instancePath.length === 0 ? "/" : error.instancePath;
|
|
22
|
+
return {
|
|
23
|
+
instancePath: path,
|
|
24
|
+
keyword: error.keyword,
|
|
25
|
+
message: `${path} ${error.message ?? "is invalid"}`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function validateContract(name, value) {
|
|
29
|
+
if (!isContractName(name)) {
|
|
30
|
+
throw new TopicProtocolError("UNKNOWN_CONTRACT", `Unknown Topic Protocol contract: ${String(name)}`, { name });
|
|
31
|
+
}
|
|
32
|
+
const validator = validatorFor(name);
|
|
33
|
+
if (validator(value))
|
|
34
|
+
return { ok: true };
|
|
35
|
+
return { ok: false, errors: (validator.errors ?? []).map(normaliseError) };
|
|
36
|
+
}
|
|
37
|
+
export function assertContract(name, value) {
|
|
38
|
+
const result = validateContract(name, value);
|
|
39
|
+
if (result.ok)
|
|
40
|
+
return;
|
|
41
|
+
throw new TopicProtocolError("CONTRACT_VALIDATION_FAILED", `${name} failed contract validation`, { contract: name, errors: result.errors });
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/contracts/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,GAGR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,aAAa,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,eAAe,GAEhB,MAAM,cAAc,CAAC;AAYtB,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkC,CAAC;AAC7D,MAAM,UAAU,GAAG,aAAa,CAAC,OAAmC,CAAC;AACrE,UAAU,CAAC,GAAG,CAAC,CAAC;AAEhB,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,YAAY,CAAC,IAAkB;IACtC,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC5C,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,cAAc,CAAC,KAAkB;IACxC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;IACxE,OAAO;QACL,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO,EAAE,GAAG,IAAI,IAAI,KAAK,CAAC,OAAO,IAAI,YAAY,EAAE;KACpD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,IAAkB,EAClB,KAAc;IAEd,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,kBAAkB,CAC1B,kBAAkB,EAClB,oCAAoC,MAAM,CAAC,IAAI,CAAC,EAAE,EAClD,EAAE,IAAI,EAAE,CACT,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IAC1C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAkB,EAAE,KAAc;IAC/D,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7C,IAAI,MAAM,CAAC,EAAE;QAAE,OAAO;IACtB,MAAM,IAAI,kBAAkB,CAC1B,4BAA4B,EAC5B,GAAG,IAAI,6BAA6B,EACpC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type TopicProtocolErrorCode = "ANCHOR_CONFLICT" | "ANCHOR_CYCLE" | "AUTHORIZATION_FAILED" | "CONTRACT_VALIDATION_FAILED" | "DUPLICATE_OPERATION" | "FIRST_MESSAGE_FAILED" | "INVALID_ANCHOR" | "INVALID_MATRIX_EVENT" | "INVALID_OPERATION_PAYLOAD" | "INVALID_SERVER_EVENT_ID" | "NON_CANONICAL_CONFLICT_SELECTION" | "PENDING_ROOT_UNRESOLVED" | "ROOT_CREATION_FAILED" | "ROOT_DISCOVERY_FAILED" | "STORAGE_FAILED" | "TOPIC_ROOT_NOT_FOUND" | "TOPIC_MISMATCH" | "UNKNOWN_CONFLICT" | "UNKNOWN_CONTRACT";
|
|
2
|
+
export declare class TopicProtocolError extends Error {
|
|
3
|
+
readonly code: TopicProtocolErrorCode;
|
|
4
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
5
|
+
constructor(code: TopicProtocolErrorCode, message: string, details?: Readonly<Record<string, unknown>>, options?: ErrorOptions);
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class TopicProtocolError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
details;
|
|
4
|
+
constructor(code, message, details = {}, options) {
|
|
5
|
+
super(message, options);
|
|
6
|
+
this.name = "TopicProtocolError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.details = details;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAqBA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,CAAyB;IAC7B,OAAO,CAAoC;IAEpD,YACE,IAA4B,EAC5B,OAAe,EACf,UAA6C,EAAE,EAC/C,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|