@voxevolv/client 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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/browser/index.js +40 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/index.js.sha384 +1 -0
- package/dist/browser/manifest.json +4 -0
- package/dist/generated/protocol-codecs.d.ts +19 -0
- package/dist/generated/protocol-codecs.d.ts.map +1 -0
- package/dist/generated/protocol-codecs.js +819 -0
- package/dist/generated/protocol-codecs.js.map +1 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +796 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +110 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +101 -0
- package/dist/protocol.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
// Generated by scripts/generate_sdk_codecs.py. Do not edit by hand.
|
|
2
|
+
const contracts = {
|
|
3
|
+
"AgentSnapshotPayload": {
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"ack_message_id": {
|
|
7
|
+
"title": "Ack Message Id",
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
"capabilities": {
|
|
11
|
+
"additionalProperties": true,
|
|
12
|
+
"title": "Capabilities",
|
|
13
|
+
"type": "object"
|
|
14
|
+
},
|
|
15
|
+
"connection_id": {
|
|
16
|
+
"title": "Connection Id",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"last_client_seq": {
|
|
20
|
+
"minimum": 1,
|
|
21
|
+
"title": "Last Client Seq",
|
|
22
|
+
"type": "integer"
|
|
23
|
+
},
|
|
24
|
+
"profile_revision": {
|
|
25
|
+
"title": "Profile Revision",
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"session_id": {
|
|
29
|
+
"title": "Session Id",
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"status": {
|
|
33
|
+
"enum": [
|
|
34
|
+
"connecting",
|
|
35
|
+
"ready",
|
|
36
|
+
"ended"
|
|
37
|
+
],
|
|
38
|
+
"title": "Status",
|
|
39
|
+
"type": "string"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"required": [
|
|
43
|
+
"session_id",
|
|
44
|
+
"profile_revision",
|
|
45
|
+
"capabilities",
|
|
46
|
+
"status",
|
|
47
|
+
"ack_message_id",
|
|
48
|
+
"connection_id",
|
|
49
|
+
"last_client_seq"
|
|
50
|
+
],
|
|
51
|
+
"title": "AgentSnapshotPayload",
|
|
52
|
+
"type": "object"
|
|
53
|
+
},
|
|
54
|
+
"ClientHelloPayload": {
|
|
55
|
+
"additionalProperties": false,
|
|
56
|
+
"properties": {
|
|
57
|
+
"last_server_seq": {
|
|
58
|
+
"default": 0,
|
|
59
|
+
"minimum": 0,
|
|
60
|
+
"title": "Last Server Seq",
|
|
61
|
+
"type": "integer"
|
|
62
|
+
},
|
|
63
|
+
"sdk": {
|
|
64
|
+
"maxLength": 80,
|
|
65
|
+
"minLength": 1,
|
|
66
|
+
"title": "Sdk",
|
|
67
|
+
"type": "string"
|
|
68
|
+
},
|
|
69
|
+
"tool_handlers": {
|
|
70
|
+
"items": {
|
|
71
|
+
"maxLength": 80,
|
|
72
|
+
"pattern": "^[a-z][a-z0-9_]{0,79}$",
|
|
73
|
+
"type": "string"
|
|
74
|
+
},
|
|
75
|
+
"maxItems": 128,
|
|
76
|
+
"title": "Tool Handlers",
|
|
77
|
+
"type": "array"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"required": [
|
|
81
|
+
"sdk"
|
|
82
|
+
],
|
|
83
|
+
"title": "ClientHelloPayload",
|
|
84
|
+
"type": "object"
|
|
85
|
+
},
|
|
86
|
+
"ClientMessage": {
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"properties": {
|
|
89
|
+
"client_seq": {
|
|
90
|
+
"minimum": 1,
|
|
91
|
+
"title": "Client Seq",
|
|
92
|
+
"type": "integer"
|
|
93
|
+
},
|
|
94
|
+
"connection_id": {
|
|
95
|
+
"maxLength": 120,
|
|
96
|
+
"minLength": 1,
|
|
97
|
+
"title": "Connection Id",
|
|
98
|
+
"type": "string"
|
|
99
|
+
},
|
|
100
|
+
"message_id": {
|
|
101
|
+
"maxLength": 120,
|
|
102
|
+
"minLength": 1,
|
|
103
|
+
"title": "Message Id",
|
|
104
|
+
"type": "string"
|
|
105
|
+
},
|
|
106
|
+
"payload": {
|
|
107
|
+
"additionalProperties": true,
|
|
108
|
+
"title": "Payload",
|
|
109
|
+
"type": "object"
|
|
110
|
+
},
|
|
111
|
+
"protocol_version": {
|
|
112
|
+
"const": 1,
|
|
113
|
+
"default": 1,
|
|
114
|
+
"title": "Protocol Version",
|
|
115
|
+
"type": "integer"
|
|
116
|
+
},
|
|
117
|
+
"type": {
|
|
118
|
+
"maxLength": 100,
|
|
119
|
+
"minLength": 1,
|
|
120
|
+
"title": "Type",
|
|
121
|
+
"type": "string"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"required": [
|
|
125
|
+
"message_id",
|
|
126
|
+
"connection_id",
|
|
127
|
+
"client_seq",
|
|
128
|
+
"type",
|
|
129
|
+
"payload"
|
|
130
|
+
],
|
|
131
|
+
"title": "ClientMessage",
|
|
132
|
+
"type": "object"
|
|
133
|
+
},
|
|
134
|
+
"CommandAckPayload": {
|
|
135
|
+
"additionalProperties": false,
|
|
136
|
+
"properties": {
|
|
137
|
+
"client_seq": {
|
|
138
|
+
"minimum": 1,
|
|
139
|
+
"title": "Client Seq",
|
|
140
|
+
"type": "integer"
|
|
141
|
+
},
|
|
142
|
+
"command_type": {
|
|
143
|
+
"maxLength": 100,
|
|
144
|
+
"minLength": 1,
|
|
145
|
+
"title": "Command Type",
|
|
146
|
+
"type": "string"
|
|
147
|
+
},
|
|
148
|
+
"connection_id": {
|
|
149
|
+
"title": "Connection Id",
|
|
150
|
+
"type": "string"
|
|
151
|
+
},
|
|
152
|
+
"message_id": {
|
|
153
|
+
"title": "Message Id",
|
|
154
|
+
"type": "string"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"required": [
|
|
158
|
+
"message_id",
|
|
159
|
+
"connection_id",
|
|
160
|
+
"client_seq",
|
|
161
|
+
"command_type"
|
|
162
|
+
],
|
|
163
|
+
"title": "CommandAckPayload",
|
|
164
|
+
"type": "object"
|
|
165
|
+
},
|
|
166
|
+
"CommandErrorPayload": {
|
|
167
|
+
"additionalProperties": false,
|
|
168
|
+
"properties": {
|
|
169
|
+
"client_seq": {
|
|
170
|
+
"minimum": 1,
|
|
171
|
+
"title": "Client Seq",
|
|
172
|
+
"type": "integer"
|
|
173
|
+
},
|
|
174
|
+
"code": {
|
|
175
|
+
"maxLength": 100,
|
|
176
|
+
"minLength": 1,
|
|
177
|
+
"title": "Code",
|
|
178
|
+
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
"command_type": {
|
|
181
|
+
"maxLength": 100,
|
|
182
|
+
"minLength": 1,
|
|
183
|
+
"title": "Command Type",
|
|
184
|
+
"type": "string"
|
|
185
|
+
},
|
|
186
|
+
"connection_id": {
|
|
187
|
+
"title": "Connection Id",
|
|
188
|
+
"type": "string"
|
|
189
|
+
},
|
|
190
|
+
"message": {
|
|
191
|
+
"maxLength": 500,
|
|
192
|
+
"minLength": 1,
|
|
193
|
+
"title": "Message",
|
|
194
|
+
"type": "string"
|
|
195
|
+
},
|
|
196
|
+
"message_id": {
|
|
197
|
+
"title": "Message Id",
|
|
198
|
+
"type": "string"
|
|
199
|
+
},
|
|
200
|
+
"retryable": {
|
|
201
|
+
"title": "Retryable",
|
|
202
|
+
"type": "boolean"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"required": [
|
|
206
|
+
"message_id",
|
|
207
|
+
"connection_id",
|
|
208
|
+
"client_seq",
|
|
209
|
+
"command_type",
|
|
210
|
+
"code",
|
|
211
|
+
"message",
|
|
212
|
+
"retryable"
|
|
213
|
+
],
|
|
214
|
+
"title": "CommandErrorPayload",
|
|
215
|
+
"type": "object"
|
|
216
|
+
},
|
|
217
|
+
"ContextRejectedPayload": {
|
|
218
|
+
"additionalProperties": false,
|
|
219
|
+
"properties": {
|
|
220
|
+
"client_seq": {
|
|
221
|
+
"minimum": 1,
|
|
222
|
+
"title": "Client Seq",
|
|
223
|
+
"type": "integer"
|
|
224
|
+
},
|
|
225
|
+
"code": {
|
|
226
|
+
"maxLength": 100,
|
|
227
|
+
"minLength": 1,
|
|
228
|
+
"title": "Code",
|
|
229
|
+
"type": "string"
|
|
230
|
+
},
|
|
231
|
+
"command_type": {
|
|
232
|
+
"maxLength": 100,
|
|
233
|
+
"minLength": 1,
|
|
234
|
+
"title": "Command Type",
|
|
235
|
+
"type": "string"
|
|
236
|
+
},
|
|
237
|
+
"connection_id": {
|
|
238
|
+
"title": "Connection Id",
|
|
239
|
+
"type": "string"
|
|
240
|
+
},
|
|
241
|
+
"message": {
|
|
242
|
+
"maxLength": 500,
|
|
243
|
+
"minLength": 1,
|
|
244
|
+
"title": "Message",
|
|
245
|
+
"type": "string"
|
|
246
|
+
},
|
|
247
|
+
"message_id": {
|
|
248
|
+
"title": "Message Id",
|
|
249
|
+
"type": "string"
|
|
250
|
+
},
|
|
251
|
+
"retryable": {
|
|
252
|
+
"title": "Retryable",
|
|
253
|
+
"type": "boolean"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"required": [
|
|
257
|
+
"message_id",
|
|
258
|
+
"connection_id",
|
|
259
|
+
"client_seq",
|
|
260
|
+
"command_type",
|
|
261
|
+
"code",
|
|
262
|
+
"message",
|
|
263
|
+
"retryable"
|
|
264
|
+
],
|
|
265
|
+
"title": "ContextRejectedPayload",
|
|
266
|
+
"type": "object"
|
|
267
|
+
},
|
|
268
|
+
"ContextUpdatePayload": {
|
|
269
|
+
"$defs": {
|
|
270
|
+
"ContextImageReference": {
|
|
271
|
+
"additionalProperties": false,
|
|
272
|
+
"properties": {
|
|
273
|
+
"bytes": {
|
|
274
|
+
"maximum": 5242880,
|
|
275
|
+
"minimum": 1,
|
|
276
|
+
"title": "Bytes",
|
|
277
|
+
"type": "integer"
|
|
278
|
+
},
|
|
279
|
+
"detail": {
|
|
280
|
+
"default": "low",
|
|
281
|
+
"enum": [
|
|
282
|
+
"auto",
|
|
283
|
+
"low",
|
|
284
|
+
"high"
|
|
285
|
+
],
|
|
286
|
+
"title": "Detail",
|
|
287
|
+
"type": "string"
|
|
288
|
+
},
|
|
289
|
+
"height": {
|
|
290
|
+
"anyOf": [
|
|
291
|
+
{
|
|
292
|
+
"maximum": 8192,
|
|
293
|
+
"minimum": 1,
|
|
294
|
+
"type": "integer"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"type": "null"
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
"default": null,
|
|
301
|
+
"title": "Height"
|
|
302
|
+
},
|
|
303
|
+
"mime": {
|
|
304
|
+
"enum": [
|
|
305
|
+
"image/jpeg",
|
|
306
|
+
"image/png",
|
|
307
|
+
"image/webp"
|
|
308
|
+
],
|
|
309
|
+
"title": "Mime",
|
|
310
|
+
"type": "string"
|
|
311
|
+
},
|
|
312
|
+
"sha256": {
|
|
313
|
+
"pattern": "^[a-f0-9]{64}$",
|
|
314
|
+
"title": "Sha256",
|
|
315
|
+
"type": "string"
|
|
316
|
+
},
|
|
317
|
+
"stream_id": {
|
|
318
|
+
"maxLength": 120,
|
|
319
|
+
"minLength": 1,
|
|
320
|
+
"title": "Stream Id",
|
|
321
|
+
"type": "string"
|
|
322
|
+
},
|
|
323
|
+
"width": {
|
|
324
|
+
"anyOf": [
|
|
325
|
+
{
|
|
326
|
+
"maximum": 8192,
|
|
327
|
+
"minimum": 1,
|
|
328
|
+
"type": "integer"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"type": "null"
|
|
332
|
+
}
|
|
333
|
+
],
|
|
334
|
+
"default": null,
|
|
335
|
+
"title": "Width"
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"required": [
|
|
339
|
+
"stream_id",
|
|
340
|
+
"mime",
|
|
341
|
+
"bytes",
|
|
342
|
+
"sha256"
|
|
343
|
+
],
|
|
344
|
+
"title": "ContextImageReference",
|
|
345
|
+
"type": "object"
|
|
346
|
+
},
|
|
347
|
+
"ContextTextStreamReference": {
|
|
348
|
+
"additionalProperties": false,
|
|
349
|
+
"properties": {
|
|
350
|
+
"bytes": {
|
|
351
|
+
"maximum": 262144,
|
|
352
|
+
"minimum": 1,
|
|
353
|
+
"title": "Bytes",
|
|
354
|
+
"type": "integer"
|
|
355
|
+
},
|
|
356
|
+
"sha256": {
|
|
357
|
+
"pattern": "^[a-f0-9]{64}$",
|
|
358
|
+
"title": "Sha256",
|
|
359
|
+
"type": "string"
|
|
360
|
+
},
|
|
361
|
+
"stream_id": {
|
|
362
|
+
"maxLength": 120,
|
|
363
|
+
"minLength": 1,
|
|
364
|
+
"title": "Stream Id",
|
|
365
|
+
"type": "string"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"required": [
|
|
369
|
+
"stream_id",
|
|
370
|
+
"bytes",
|
|
371
|
+
"sha256"
|
|
372
|
+
],
|
|
373
|
+
"title": "ContextTextStreamReference",
|
|
374
|
+
"type": "object"
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
"additionalProperties": false,
|
|
378
|
+
"oneOf": [
|
|
379
|
+
{
|
|
380
|
+
"properties": {
|
|
381
|
+
"image": {
|
|
382
|
+
"type": "null"
|
|
383
|
+
},
|
|
384
|
+
"text_stream": {
|
|
385
|
+
"type": "null"
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
"required": [
|
|
389
|
+
"text"
|
|
390
|
+
],
|
|
391
|
+
"type": "object"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"properties": {
|
|
395
|
+
"image": {
|
|
396
|
+
"type": "null"
|
|
397
|
+
},
|
|
398
|
+
"text": {
|
|
399
|
+
"type": "null"
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
"required": [
|
|
403
|
+
"text_stream"
|
|
404
|
+
],
|
|
405
|
+
"type": "object"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"properties": {
|
|
409
|
+
"mode": {
|
|
410
|
+
"const": "replace"
|
|
411
|
+
},
|
|
412
|
+
"text": {
|
|
413
|
+
"type": "null"
|
|
414
|
+
},
|
|
415
|
+
"text_stream": {
|
|
416
|
+
"type": "null"
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
"required": [
|
|
420
|
+
"image"
|
|
421
|
+
],
|
|
422
|
+
"type": "object"
|
|
423
|
+
}
|
|
424
|
+
],
|
|
425
|
+
"properties": {
|
|
426
|
+
"image": {
|
|
427
|
+
"anyOf": [
|
|
428
|
+
{
|
|
429
|
+
"$ref": "#/$defs/ContextImageReference"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"type": "null"
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
"default": null
|
|
436
|
+
},
|
|
437
|
+
"key": {
|
|
438
|
+
"maxLength": 120,
|
|
439
|
+
"minLength": 1,
|
|
440
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
|
|
441
|
+
"title": "Key",
|
|
442
|
+
"type": "string"
|
|
443
|
+
},
|
|
444
|
+
"label": {
|
|
445
|
+
"default": "",
|
|
446
|
+
"maxLength": 200,
|
|
447
|
+
"title": "Label",
|
|
448
|
+
"type": "string"
|
|
449
|
+
},
|
|
450
|
+
"mode": {
|
|
451
|
+
"enum": [
|
|
452
|
+
"append",
|
|
453
|
+
"replace"
|
|
454
|
+
],
|
|
455
|
+
"title": "Mode",
|
|
456
|
+
"type": "string"
|
|
457
|
+
},
|
|
458
|
+
"respond": {
|
|
459
|
+
"default": false,
|
|
460
|
+
"title": "Respond",
|
|
461
|
+
"type": "boolean"
|
|
462
|
+
},
|
|
463
|
+
"text": {
|
|
464
|
+
"anyOf": [
|
|
465
|
+
{
|
|
466
|
+
"maxLength": 32768,
|
|
467
|
+
"minLength": 1,
|
|
468
|
+
"type": "string"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"type": "null"
|
|
472
|
+
}
|
|
473
|
+
],
|
|
474
|
+
"default": null,
|
|
475
|
+
"title": "Text"
|
|
476
|
+
},
|
|
477
|
+
"text_stream": {
|
|
478
|
+
"anyOf": [
|
|
479
|
+
{
|
|
480
|
+
"$ref": "#/$defs/ContextTextStreamReference"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"type": "null"
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
"default": null
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
"required": [
|
|
490
|
+
"key",
|
|
491
|
+
"mode"
|
|
492
|
+
],
|
|
493
|
+
"title": "ContextUpdatePayload",
|
|
494
|
+
"type": "object"
|
|
495
|
+
},
|
|
496
|
+
"ContextUpdatedPayload": {
|
|
497
|
+
"additionalProperties": false,
|
|
498
|
+
"properties": {
|
|
499
|
+
"client_seq": {
|
|
500
|
+
"minimum": 1,
|
|
501
|
+
"title": "Client Seq",
|
|
502
|
+
"type": "integer"
|
|
503
|
+
},
|
|
504
|
+
"command_type": {
|
|
505
|
+
"maxLength": 100,
|
|
506
|
+
"minLength": 1,
|
|
507
|
+
"title": "Command Type",
|
|
508
|
+
"type": "string"
|
|
509
|
+
},
|
|
510
|
+
"connection_id": {
|
|
511
|
+
"title": "Connection Id",
|
|
512
|
+
"type": "string"
|
|
513
|
+
},
|
|
514
|
+
"context_sequence": {
|
|
515
|
+
"minimum": 1,
|
|
516
|
+
"title": "Context Sequence",
|
|
517
|
+
"type": "integer"
|
|
518
|
+
},
|
|
519
|
+
"key": {
|
|
520
|
+
"title": "Key",
|
|
521
|
+
"type": "string"
|
|
522
|
+
},
|
|
523
|
+
"message_id": {
|
|
524
|
+
"title": "Message Id",
|
|
525
|
+
"type": "string"
|
|
526
|
+
},
|
|
527
|
+
"mode": {
|
|
528
|
+
"enum": [
|
|
529
|
+
"append",
|
|
530
|
+
"replace"
|
|
531
|
+
],
|
|
532
|
+
"title": "Mode",
|
|
533
|
+
"type": "string"
|
|
534
|
+
},
|
|
535
|
+
"respond": {
|
|
536
|
+
"title": "Respond",
|
|
537
|
+
"type": "boolean"
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
"required": [
|
|
541
|
+
"message_id",
|
|
542
|
+
"connection_id",
|
|
543
|
+
"client_seq",
|
|
544
|
+
"command_type",
|
|
545
|
+
"key",
|
|
546
|
+
"mode",
|
|
547
|
+
"context_sequence",
|
|
548
|
+
"respond"
|
|
549
|
+
],
|
|
550
|
+
"title": "ContextUpdatedPayload",
|
|
551
|
+
"type": "object"
|
|
552
|
+
},
|
|
553
|
+
"RealtimeEvent": {
|
|
554
|
+
"additionalProperties": false,
|
|
555
|
+
"properties": {
|
|
556
|
+
"event_id": {
|
|
557
|
+
"title": "Event Id",
|
|
558
|
+
"type": "string"
|
|
559
|
+
},
|
|
560
|
+
"payload": {
|
|
561
|
+
"additionalProperties": true,
|
|
562
|
+
"title": "Payload",
|
|
563
|
+
"type": "object"
|
|
564
|
+
},
|
|
565
|
+
"protocol_version": {
|
|
566
|
+
"const": 1,
|
|
567
|
+
"default": 1,
|
|
568
|
+
"title": "Protocol Version",
|
|
569
|
+
"type": "integer"
|
|
570
|
+
},
|
|
571
|
+
"server_seq": {
|
|
572
|
+
"anyOf": [
|
|
573
|
+
{
|
|
574
|
+
"minimum": 1,
|
|
575
|
+
"type": "integer"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"type": "null"
|
|
579
|
+
}
|
|
580
|
+
],
|
|
581
|
+
"default": null,
|
|
582
|
+
"title": "Server Seq"
|
|
583
|
+
},
|
|
584
|
+
"stream_id": {
|
|
585
|
+
"title": "Stream Id",
|
|
586
|
+
"type": "string"
|
|
587
|
+
},
|
|
588
|
+
"stream_seq": {
|
|
589
|
+
"minimum": 1,
|
|
590
|
+
"title": "Stream Seq",
|
|
591
|
+
"type": "integer"
|
|
592
|
+
},
|
|
593
|
+
"ts": {
|
|
594
|
+
"format": "date-time",
|
|
595
|
+
"title": "Ts",
|
|
596
|
+
"type": "string"
|
|
597
|
+
},
|
|
598
|
+
"type": {
|
|
599
|
+
"maxLength": 100,
|
|
600
|
+
"minLength": 1,
|
|
601
|
+
"title": "Type",
|
|
602
|
+
"type": "string"
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
"required": [
|
|
606
|
+
"event_id",
|
|
607
|
+
"stream_id",
|
|
608
|
+
"stream_seq",
|
|
609
|
+
"ts",
|
|
610
|
+
"type",
|
|
611
|
+
"payload"
|
|
612
|
+
],
|
|
613
|
+
"title": "RealtimeEvent",
|
|
614
|
+
"type": "object"
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
function decode(schema, value, name) {
|
|
618
|
+
const error = validate(schema, value, name, schema);
|
|
619
|
+
if (error)
|
|
620
|
+
throw new TypeError(error);
|
|
621
|
+
return value;
|
|
622
|
+
}
|
|
623
|
+
function validate(schema, value, path, root) {
|
|
624
|
+
if (schema.$ref) {
|
|
625
|
+
const prefix = "#/$defs/";
|
|
626
|
+
if (!schema.$ref.startsWith(prefix))
|
|
627
|
+
return `${path} uses an unsupported schema reference`;
|
|
628
|
+
const resolved = root.$defs?.[schema.$ref.slice(prefix.length)];
|
|
629
|
+
if (!resolved)
|
|
630
|
+
return `${path} uses a missing schema reference`;
|
|
631
|
+
return validate(resolved, value, path, root);
|
|
632
|
+
}
|
|
633
|
+
if (schema.anyOf) {
|
|
634
|
+
if (!schema.anyOf.some((candidate) => validate(candidate, value, path, root) === null)) {
|
|
635
|
+
return `${path} does not match any allowed schema`;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (schema.oneOf) {
|
|
639
|
+
const matches = schema.oneOf.filter((candidate) => validate(candidate, value, path, root) === null);
|
|
640
|
+
if (matches.length !== 1)
|
|
641
|
+
return `${path} must match exactly one allowed schema`;
|
|
642
|
+
}
|
|
643
|
+
if (schema.allOf) {
|
|
644
|
+
for (const candidate of schema.allOf) {
|
|
645
|
+
const error = validate(candidate, value, path, root);
|
|
646
|
+
if (error)
|
|
647
|
+
return error;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (Object.prototype.hasOwnProperty.call(schema, "const") && value !== schema.const) {
|
|
651
|
+
return `${path} must equal ${String(schema.const)}`;
|
|
652
|
+
}
|
|
653
|
+
if (schema.enum && !schema.enum.includes(value))
|
|
654
|
+
return `${path} has an unsupported value`;
|
|
655
|
+
if (schema.type === "object") {
|
|
656
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
657
|
+
return `${path} must be an object`;
|
|
658
|
+
const object = value;
|
|
659
|
+
for (const required of schema.required ?? []) {
|
|
660
|
+
if (!Object.prototype.hasOwnProperty.call(object, required))
|
|
661
|
+
return `${path}.${required} is required`;
|
|
662
|
+
}
|
|
663
|
+
for (const [key, child] of Object.entries(schema.properties ?? {})) {
|
|
664
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
665
|
+
const error = validate(child, object[key], `${path}.${key}`, root);
|
|
666
|
+
if (error)
|
|
667
|
+
return error;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if (schema.additionalProperties === false) {
|
|
671
|
+
const allowed = new Set(Object.keys(schema.properties ?? {}));
|
|
672
|
+
const extra = Object.keys(object).find((key) => !allowed.has(key));
|
|
673
|
+
if (extra)
|
|
674
|
+
return `${path}.${extra} is not allowed`;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
else if (schema.type === "string") {
|
|
678
|
+
if (typeof value !== "string")
|
|
679
|
+
return `${path} must be a string`;
|
|
680
|
+
if (schema.minLength !== undefined && value.length < schema.minLength)
|
|
681
|
+
return `${path} is too short`;
|
|
682
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength)
|
|
683
|
+
return `${path} is too long`;
|
|
684
|
+
if (schema.pattern !== undefined && !new RegExp(schema.pattern).test(value))
|
|
685
|
+
return `${path} has an invalid format`;
|
|
686
|
+
if (schema.format === "date-time" && Number.isNaN(Date.parse(value)))
|
|
687
|
+
return `${path} must be a date-time`;
|
|
688
|
+
}
|
|
689
|
+
else if (schema.type === "integer") {
|
|
690
|
+
if (!Number.isInteger(value))
|
|
691
|
+
return `${path} must be an integer`;
|
|
692
|
+
}
|
|
693
|
+
else if (schema.type === "number") {
|
|
694
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
695
|
+
return `${path} must be a number`;
|
|
696
|
+
}
|
|
697
|
+
else if (schema.type === "boolean" && typeof value !== "boolean") {
|
|
698
|
+
return `${path} must be a boolean`;
|
|
699
|
+
}
|
|
700
|
+
else if (schema.type === "null" && value !== null) {
|
|
701
|
+
return `${path} must be null`;
|
|
702
|
+
}
|
|
703
|
+
if (typeof value === "number") {
|
|
704
|
+
if (schema.minimum !== undefined && value < schema.minimum)
|
|
705
|
+
return `${path} is below its minimum`;
|
|
706
|
+
if (schema.maximum !== undefined && value > schema.maximum)
|
|
707
|
+
return `${path} exceeds its maximum`;
|
|
708
|
+
}
|
|
709
|
+
return null;
|
|
710
|
+
}
|
|
711
|
+
export function decodeRealtimeEvent(value) {
|
|
712
|
+
return decode(contracts.RealtimeEvent, value, "RealtimeEvent");
|
|
713
|
+
}
|
|
714
|
+
export function isRealtimeEvent(value) {
|
|
715
|
+
try {
|
|
716
|
+
decodeRealtimeEvent(value);
|
|
717
|
+
return true;
|
|
718
|
+
}
|
|
719
|
+
catch {
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
export function decodeClientMessage(value) {
|
|
724
|
+
return decode(contracts.ClientMessage, value, "ClientMessage");
|
|
725
|
+
}
|
|
726
|
+
export function isClientMessage(value) {
|
|
727
|
+
try {
|
|
728
|
+
decodeClientMessage(value);
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
catch {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
export function decodeAgentSnapshotPayload(value) {
|
|
736
|
+
return decode(contracts.AgentSnapshotPayload, value, "AgentSnapshotPayload");
|
|
737
|
+
}
|
|
738
|
+
export function isAgentSnapshotPayload(value) {
|
|
739
|
+
try {
|
|
740
|
+
decodeAgentSnapshotPayload(value);
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
export function decodeClientHelloPayload(value) {
|
|
748
|
+
return decode(contracts.ClientHelloPayload, value, "ClientHelloPayload");
|
|
749
|
+
}
|
|
750
|
+
export function isClientHelloPayload(value) {
|
|
751
|
+
try {
|
|
752
|
+
decodeClientHelloPayload(value);
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
catch {
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
export function decodeCommandAckPayload(value) {
|
|
760
|
+
return decode(contracts.CommandAckPayload, value, "CommandAckPayload");
|
|
761
|
+
}
|
|
762
|
+
export function isCommandAckPayload(value) {
|
|
763
|
+
try {
|
|
764
|
+
decodeCommandAckPayload(value);
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
catch {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
export function decodeCommandErrorPayload(value) {
|
|
772
|
+
return decode(contracts.CommandErrorPayload, value, "CommandErrorPayload");
|
|
773
|
+
}
|
|
774
|
+
export function isCommandErrorPayload(value) {
|
|
775
|
+
try {
|
|
776
|
+
decodeCommandErrorPayload(value);
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
catch {
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
export function decodeContextUpdatePayload(value) {
|
|
784
|
+
return decode(contracts.ContextUpdatePayload, value, "ContextUpdatePayload");
|
|
785
|
+
}
|
|
786
|
+
export function isContextUpdatePayload(value) {
|
|
787
|
+
try {
|
|
788
|
+
decodeContextUpdatePayload(value);
|
|
789
|
+
return true;
|
|
790
|
+
}
|
|
791
|
+
catch {
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
export function decodeContextUpdatedPayload(value) {
|
|
796
|
+
return decode(contracts.ContextUpdatedPayload, value, "ContextUpdatedPayload");
|
|
797
|
+
}
|
|
798
|
+
export function isContextUpdatedPayload(value) {
|
|
799
|
+
try {
|
|
800
|
+
decodeContextUpdatedPayload(value);
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
catch {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
export function decodeContextRejectedPayload(value) {
|
|
808
|
+
return decode(contracts.ContextRejectedPayload, value, "ContextRejectedPayload");
|
|
809
|
+
}
|
|
810
|
+
export function isContextRejectedPayload(value) {
|
|
811
|
+
try {
|
|
812
|
+
decodeContextRejectedPayload(value);
|
|
813
|
+
return true;
|
|
814
|
+
}
|
|
815
|
+
catch {
|
|
816
|
+
return false;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
//# sourceMappingURL=protocol-codecs.js.map
|