@plurnk/plurnk-contracts 6.0.1 → 7.0.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 (97) hide show
  1. package/.env.defaults +5 -5
  2. package/README.md +4 -4
  3. package/SPEC.md +158 -2054
  4. package/dist/schema/{AguiDiscovery.json → AcpDiscovery.json} +4 -4
  5. package/dist/schema/ApplicationOperationEvent.json +2 -2
  6. package/dist/schema/CapabilityDescriptor.json +3 -3
  7. package/dist/schema/CapabilityPolicy.json +5 -1
  8. package/dist/schema/CapabilitySelector.json +3 -3
  9. package/dist/schema/ClientInteractionProjection.json +2 -2
  10. package/dist/schema/ClientInteractionRequest.json +26 -10
  11. package/dist/schema/ClientInteractionResolution.json +14 -6
  12. package/dist/schema/FunctionalityDefinitionState.json +3 -3
  13. package/dist/schema/FunctionalityDiscoverQuery.json +2 -1
  14. package/dist/schema/FunctionalityMutationResult.json +1 -1
  15. package/dist/schema/MatcherBody.json +2 -2
  16. package/dist/schema/McpServerDefinition.json +35 -9
  17. package/dist/schema/ModelCatalogPage.json +1 -1
  18. package/dist/schema/ModelRoute.json +2 -2
  19. package/dist/schema/Notice.json +1 -1
  20. package/dist/schema/PlurnkStatement.json +8 -8
  21. package/dist/schema/ProposalDisposition.json +1 -1
  22. package/dist/schema/ProposalPolicy.json +1 -1
  23. package/dist/schema/ProposalProjection.json +57 -6
  24. package/dist/schema/ResourceSelection.json +1 -1
  25. package/dist/schema/RollbackReport.json +1 -1
  26. package/dist/schema/{WorkerOwner.json → SessionOwner.json} +2 -2
  27. package/dist/schema/SkillDefinition.json +8 -7
  28. package/dist/src/Application.d.ts +97 -66
  29. package/dist/src/Application.d.ts.map +1 -1
  30. package/dist/src/Application.js +198 -1
  31. package/dist/src/Application.js.map +1 -1
  32. package/dist/src/ApplicationNotifications.d.ts +52 -0
  33. package/dist/src/ApplicationNotifications.d.ts.map +1 -0
  34. package/dist/src/ApplicationNotifications.js +2 -0
  35. package/dist/src/ApplicationNotifications.js.map +1 -0
  36. package/dist/src/ApplicationPort.d.ts +84 -75
  37. package/dist/src/ApplicationPort.d.ts.map +1 -1
  38. package/dist/src/ApplicationStream.d.ts +4 -4
  39. package/dist/src/ApplicationStream.d.ts.map +1 -1
  40. package/dist/src/CapabilityAdmission.d.ts +2 -0
  41. package/dist/src/CapabilityAdmission.d.ts.map +1 -1
  42. package/dist/src/CapabilityAdmission.js +14 -2
  43. package/dist/src/CapabilityAdmission.js.map +1 -1
  44. package/dist/src/Excerpt.js +1 -1
  45. package/dist/src/Excerpt.js.map +1 -1
  46. package/dist/src/Functionality.d.ts +3 -6
  47. package/dist/src/Functionality.d.ts.map +1 -1
  48. package/dist/src/HttpOrigin.d.ts +3 -3
  49. package/dist/src/HttpOrigin.js +1 -1
  50. package/dist/src/JsonDocument.js +1 -1
  51. package/dist/src/JsonDocument.js.map +1 -1
  52. package/dist/src/JsonResult.js +1 -1
  53. package/dist/src/JsonResult.js.map +1 -1
  54. package/dist/src/LogRow.d.ts +31 -0
  55. package/dist/src/LogRow.d.ts.map +1 -0
  56. package/dist/src/LogRow.js +46 -0
  57. package/dist/src/LogRow.js.map +1 -0
  58. package/dist/src/LoopLifecycle.d.ts +1 -1
  59. package/dist/src/LoopLifecycle.d.ts.map +1 -1
  60. package/dist/src/LoopLifecycle.js +2 -2
  61. package/dist/src/LoopLifecycle.js.map +1 -1
  62. package/dist/src/MessageResource.d.ts +4 -4
  63. package/dist/src/MessageResource.d.ts.map +1 -1
  64. package/dist/src/PathSyntax.js +2 -2
  65. package/dist/src/PathSyntax.js.map +1 -1
  66. package/dist/src/PlurnkParseError.js +1 -1
  67. package/dist/src/PlurnkParseError.js.map +1 -1
  68. package/dist/src/Problems.js +1 -1
  69. package/dist/src/Problems.js.map +1 -1
  70. package/dist/src/TurnDisposition.js +1 -1
  71. package/dist/src/TurnDisposition.js.map +1 -1
  72. package/dist/src/Validator.d.ts +5 -108
  73. package/dist/src/Validator.d.ts.map +1 -1
  74. package/dist/src/Validator.js +97 -518
  75. package/dist/src/Validator.js.map +1 -1
  76. package/dist/src/guards.js +1 -1
  77. package/dist/src/guards.js.map +1 -1
  78. package/dist/src/index.d.ts +6 -5
  79. package/dist/src/index.d.ts.map +1 -1
  80. package/dist/src/index.js +7 -5
  81. package/dist/src/index.js.map +1 -1
  82. package/dist/src/types.d.ts +1 -1
  83. package/dist/src/types.d.ts.map +1 -1
  84. package/dist/src/types.generated.d.ts +91 -187
  85. package/dist/src/types.generated.d.ts.map +1 -1
  86. package/dist/src/types.js +7 -7
  87. package/dist/src/types.js.map +1 -1
  88. package/package.json +5 -9
  89. package/plurnk.md +16 -16
  90. package/dist/conformance/agui-v1.json +0 -716
  91. package/dist/schema/A2aAgentDefinition.json +0 -76
  92. package/dist/schema/AguiClientConformance.json +0 -74
  93. package/dist/schema/AguiConformanceKit.json +0 -111
  94. package/dist/src/AguiConformance.d.ts +0 -11
  95. package/dist/src/AguiConformance.d.ts.map +0 -1
  96. package/dist/src/AguiConformance.js +0 -16
  97. package/dist/src/AguiConformance.js.map +0 -1
@@ -21,11 +21,10 @@ import capabilityDescriptorSchema from "../schema/CapabilityDescriptor.json" wit
21
21
  import capabilityPolicySchema from "../schema/CapabilityPolicy.json" with { type: "json" };
22
22
  import capabilityProjectionSchema from "../schema/CapabilityProjection.json" with { type: "json" };
23
23
  import capabilitySelectorSchema from "../schema/CapabilitySelector.json" with { type: "json" };
24
- import workerOwnerSchema from "../schema/WorkerOwner.json" with { type: "json" };
24
+ import sessionOwnerSchema from "../schema/SessionOwner.json" with { type: "json" };
25
25
  import clientDisplayCapabilitiesSchema from "../schema/ClientDisplayCapabilities.json" with { type: "json" };
26
26
  import mcpServerDefinitionSchema from "../schema/McpServerDefinition.json" with { type: "json" };
27
27
  import skillDefinitionSchema from "../schema/SkillDefinition.json" with { type: "json" };
28
- import a2aAgentDefinitionSchema from "../schema/A2aAgentDefinition.json" with { type: "json" };
29
28
  import mcpOAuthSchema from "../schema/McpOAuth.json" with { type: "json" };
30
29
  import clientInteractionRequestSchema from "../schema/ClientInteractionRequest.json" with { type: "json" };
31
30
  import clientInteractionProjectionSchema from "../schema/ClientInteractionProjection.json" with { type: "json" };
@@ -46,129 +45,16 @@ import mcpOAuthBeginResultSchema from "../schema/McpOAuthBeginResult.json" with
46
45
  import functionalityPreparationActivitySchema from "../schema/FunctionalityPreparationActivity.json" with { type: "json" };
47
46
  import modelReadinessSchema from "../schema/ModelReadiness.json" with { type: "json" };
48
47
  import modelRouteSchema from "../schema/ModelRoute.json" with { type: "json" };
49
- import aguiDiscoverySchema from "../schema/AguiDiscovery.json" with { type: "json" };
50
- import aguiClientConformanceSchema from "../schema/AguiClientConformance.json" with { type: "json" };
51
- import aguiConformanceKitSchema from "../schema/AguiConformanceKit.json" with { type: "json" };
48
+ import acpDiscoverySchema from "../schema/AcpDiscovery.json" with { type: "json" };
52
49
  import providerAccountingSchema from "../schema/ProviderAccounting.json" with { type: "json" };
53
50
  import providerRequestAccountingSchema from "../schema/ProviderRequestAccounting.json" with { type: "json" };
54
51
  import providerUsageSchema from "../schema/ProviderUsage.json" with { type: "json" };
55
52
  import providerCostSchema from "../schema/ProviderCost.json" with { type: "json" };
56
- export class InvalidNoticeError extends TypeError {
57
- }
58
53
  export class InvalidProblemDetailsError extends TypeError {
59
54
  }
60
- export class InvalidProblemProjectionError extends TypeError {
61
- }
62
55
  export class InvalidOperationResultError extends TypeError {
63
56
  }
64
- export class InvalidEntryReadResultError extends TypeError {
65
- }
66
- export class InvalidTextRegionError extends TypeError {
67
- }
68
- export class InvalidRangeExtentError extends TypeError {
69
- }
70
- export class InvalidCapabilityDescriptorError extends TypeError {
71
- }
72
- export class InvalidCapabilityPolicyError extends TypeError {
73
- }
74
- export class InvalidWorkerOwnerError extends TypeError {
75
- }
76
- export class InvalidProposalProjectionError extends TypeError {
77
- }
78
- export class InvalidClientDisplayCapabilitiesError extends TypeError {
79
- }
80
- export class InvalidMcpServerDefinitionError extends TypeError {
81
- }
82
- export class InvalidSkillDefinitionError extends TypeError {
83
- }
84
- export class InvalidA2aAgentDefinitionError extends TypeError {
85
- }
86
- export class InvalidMcpOAuthError extends TypeError {
87
- }
88
- export class InvalidClientInteractionRequestError extends TypeError {
89
- }
90
- export class InvalidClientInteractionProjectionError extends TypeError {
91
- }
92
- export class InvalidClientInteractionResolutionError extends TypeError {
93
- }
94
- export class InvalidEffortError extends TypeError {
95
- }
96
- export class InvalidModelCatalogPageError extends TypeError {
97
- }
98
- export class InvalidModelCatalogQueryError extends TypeError {
99
- }
100
- export class InvalidFunctionalityListResultError extends TypeError {
101
- }
102
- export class InvalidFunctionalityDiscoverResultError extends TypeError {
103
- }
104
- export class InvalidFunctionalityMutationResultError extends TypeError {
105
- }
106
- export class InvalidRollbackReportError extends TypeError {
107
- }
108
- export class InvalidModelReadinessError extends TypeError {
109
- }
110
- export class InvalidModelRouteError extends TypeError {
111
- }
112
- export class InvalidAguiDiscoveryError extends TypeError {
113
- }
114
- export class InvalidAguiClientConformanceError extends TypeError {
115
- }
116
- export class InvalidAguiConformanceKitError extends TypeError {
117
- }
118
- export class InvalidJsonSchemaInstanceError extends TypeError {
119
- }
120
- export class InvalidParsedPathError extends TypeError {
121
- }
122
- export class InvalidPlurnkStatementError extends TypeError {
123
- }
124
57
  export default class Validator {
125
- static #position = Validator.#compile(positionSchema);
126
- static #lineMarker = Validator.#compile(lineMarkerSchema);
127
- static #textLineMarker = Validator.#compile(textLineMarkerSchema);
128
- static #parsedPath = Validator.#compile(parsedPathSchema);
129
- static #matcherBody = Validator.#compile(matcherBodySchema);
130
- static #sendBody = Validator.#compile(sendBodySchema);
131
- static #plurnkStatement = Validator.#withRefs(plurnkStatementSchema, [
132
- positionSchema,
133
- lineMarkerSchema,
134
- textLineMarkerSchema,
135
- parsedPathSchema,
136
- matcherBodySchema,
137
- sendBodySchema,
138
- resourceSelectionSchema,
139
- ]);
140
- static #notice = Validator.#compile(noticeSchema);
141
- static #problemDetails = Validator.#compile(problemDetailsSchema);
142
- static #problemProjection = Validator.#compile(problemProjectionSchema);
143
- static #operationResult = Validator.#withRefs(operationResultSchema, [problemDetailsSchema, rangeExtentSchema]);
144
- static #entryReadResult = Validator.#withRefs(entryReadResultSchema, [problemDetailsSchema]);
145
- static #textRegion = Validator.#compile(textRegionSchema);
146
- static #rangeExtent = Validator.#compile(rangeExtentSchema);
147
- static #capabilityDescriptor = Validator.#withRefs(capabilityDescriptorSchema, [capabilitySelectorSchema]);
148
- static #capabilityPolicy = Validator.#withRefs(capabilityPolicySchema, [capabilitySelectorSchema]);
149
- static #workerOwner = Validator.#compile(workerOwnerSchema);
150
- static #proposalProjection = Validator.#withRefs(proposalProjectionSchema, [proposalDispositionSchema, capabilityPolicySchema, capabilitySelectorSchema]);
151
- static #clientDisplayCapabilities = Validator.#compile(clientDisplayCapabilitiesSchema);
152
- static #mcpServerDefinition = Validator.#withRefs(mcpServerDefinitionSchema, [mcpOAuthSchema]);
153
- static #a2aAgentDefinition = Validator.#compile(a2aAgentDefinitionSchema);
154
- static #skillDefinition = Validator.#compile(skillDefinitionSchema);
155
- static #mcpOAuth = Validator.#compile(mcpOAuthSchema);
156
- static #clientInteractionRequest = Validator.#compile(clientInteractionRequestSchema);
157
- static #clientInteractionProjection = Validator.#withRefs(clientInteractionProjectionSchema, [clientInteractionRequestSchema]);
158
- static #clientInteractionResolution = Validator.#compile(clientInteractionResolutionSchema);
159
- static #effort = Validator.#compile(effortSchema);
160
- static #providerRequestAccounting = Validator.#withRefs(providerRequestAccountingSchema, [providerUsageSchema, providerCostSchema]);
161
- static #modelReadiness = Validator.#compile(modelReadinessSchema);
162
- static #modelCatalogPage = Validator.#withRefs(modelCatalogPageSchema, [modelReadinessSchema, effortSchema]);
163
- static #functionalityListResult = Validator.#withRefs(functionalityListResultSchema, [functionalityDefinitionStateSchema, functionalityProvenanceSchema, problemDetailsSchema]);
164
- static #functionalityDiscoverResult = Validator.#withRefs(functionalityDiscoverResultSchema, [functionalityCandidateSchema, functionalityProvenanceSchema]);
165
- static #functionalityMutationResult = Validator.#withRefs(functionalityMutationResultSchema, [functionalityDefinitionStateSchema, functionalityProvenanceSchema, problemDetailsSchema]);
166
- static #rollbackReport = Validator.#compile(rollbackReportSchema);
167
- static #modelCatalogQuery = Validator.#compile(modelCatalogQuerySchema);
168
- static #modelRoute = Validator.#withRefs(modelRouteSchema, [effortSchema]);
169
- static #aguiDiscovery = Validator.#withRefs(aguiDiscoverySchema, [clientDisplayCapabilitiesSchema]);
170
- static #aguiClientConformance = Validator.#compile(aguiClientConformanceSchema);
171
- static #aguiConformanceKit = Validator.#compile(aguiConformanceKitSchema);
172
58
  static #jsonSchemaValidators = new WeakMap();
173
59
  static #publicSchemas = [
174
60
  applicationOperationEventSchema,
@@ -180,9 +66,7 @@ export default class Validator {
180
66
  matcherBodySchema,
181
67
  sendBodySchema,
182
68
  resourceSelectionSchema,
183
- aguiDiscoverySchema,
184
- aguiClientConformanceSchema,
185
- aguiConformanceKitSchema,
69
+ acpDiscoverySchema,
186
70
  clientDisplayCapabilitiesSchema,
187
71
  clientInteractionProjectionSchema,
188
72
  clientInteractionRequestSchema,
@@ -202,11 +86,11 @@ export default class Validator {
202
86
  mcpOAuthSchema,
203
87
  mcpServerDefinitionSchema,
204
88
  skillDefinitionSchema,
205
- a2aAgentDefinitionSchema,
206
89
  capabilityDescriptorSchema,
207
90
  capabilityPolicySchema,
208
91
  capabilityProjectionSchema,
209
92
  capabilitySelectorSchema,
93
+ sessionOwnerSchema,
210
94
  modelCatalogPageSchema,
211
95
  modelCatalogQuerySchema,
212
96
  modelReadinessSchema,
@@ -222,6 +106,7 @@ export default class Validator {
222
106
  providerUsageSchema,
223
107
  providerCostSchema,
224
108
  rangeExtentSchema,
109
+ textRegionSchema,
225
110
  effortSchema,
226
111
  ];
227
112
  // The exact schema behind a `$ref` a Functionality family declares as its definition
@@ -230,7 +115,7 @@ export default class Validator {
230
115
  const schema = Validator.#publicSchemas.find((candidate) => Validator.#schemaId(candidate) === ref);
231
116
  return schema === undefined ? null : schema;
232
117
  }
233
- // {§wire-entrypoint} A schema document is an object, naming its dialect in `$schema` or taking the validator's
118
+ // {§text-region} A schema document is an object, naming its dialect in `$schema` or taking the validator's
234
119
  // default; every validator compiles one, the checked-in documents and the dynamic ones callers own alike. What
235
120
  // the document then means is the validator's to read, its declared dialect included.
236
121
  static #schemaDocument(value) {
@@ -262,178 +147,21 @@ export default class Validator {
262
147
  }
263
148
  return validator;
264
149
  }
265
- // {§wire-entrypoint} The schema's acceptance is the proof a value has its wire type: a guard over the result of
150
+ // {§text-region} The schema's acceptance is the proof a value has its wire type: a guard over the result of
266
151
  // validating that value, the one place a validated `unknown` takes its type. The caller names the type the
267
152
  // schema it validated against generates; the predicate is where it appears.
268
153
  // oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- a type predicate's parameter appears once by nature
269
154
  static #accepted(value, result) {
270
155
  return result.valid;
271
156
  }
272
- static validatePosition(value) {
273
- return Validator.#validate(Validator.#position, value);
274
- }
275
- static validateLineMarker(value) {
276
- return Validator.#validate(Validator.#lineMarker, value);
277
- }
278
- static validateTextLineMarker(value) {
279
- return Validator.#validate(Validator.#textLineMarker, value);
280
- }
281
- static validateParsedPath(value) {
282
- return Validator.#validate(Validator.#parsedPath, value);
283
- }
284
- static validateMatcherBody(value) {
285
- return Validator.#validate(Validator.#matcherBody, value);
286
- }
287
- static validateSendBody(value) {
288
- return Validator.#validate(Validator.#sendBody, value);
289
- }
290
- static validatePlurnkStatement(value) {
291
- return Validator.#validate(Validator.#plurnkStatement, value);
292
- }
293
- static validateNotice(value) {
294
- return Validator.#validate(Validator.#notice, value);
295
- }
296
- static validateProblemDetails(value) {
297
- return Validator.#validate(Validator.#problemDetails, value);
298
- }
299
- static validateProblemProjection(value) {
300
- return Validator.#validate(Validator.#problemProjection, value);
301
- }
302
- static validateOperationResult(value) {
303
- return Validator.#validate(Validator.#operationResult, value);
304
- }
305
- static validateEntryReadResult(value) {
306
- const result = Validator.#validate(Validator.#entryReadResult, value);
307
- if (!Validator.#accepted(value, result))
308
- return result;
309
- const entry = value.entry;
310
- if (entry === null)
311
- return result;
312
- for (const [name, channel] of Object.entries(entry.channels)) {
313
- const returnedLength = Array.from(channel.content).length;
314
- if (channel.contentOffset + returnedLength !== channel.contentLength) {
315
- return {
316
- valid: false,
317
- errors: [{
318
- keyword: "entry-read-suffix",
319
- instanceLocation: `/entry/channels/${name}`,
320
- keywordLocation: "#/$defs/channel",
321
- error: "contentOffset plus the returned Unicode-code-point length must equal contentLength",
322
- }],
323
- };
324
- }
325
- }
326
- return result;
327
- }
328
- static validateTextRegion(value) {
329
- return Validator.#validate(Validator.#textRegion, value);
330
- }
331
- static validateRangeExtent(value) {
332
- return Validator.#validate(Validator.#rangeExtent, value);
333
- }
334
- static validateCapabilityDescriptor(value) {
335
- return Validator.#validate(Validator.#capabilityDescriptor, value);
336
- }
337
- static validateCapabilityPolicy(value) {
338
- return Validator.#validate(Validator.#capabilityPolicy, value);
339
- }
340
- static validateWorkerOwner(value) {
341
- return Validator.#validate(Validator.#workerOwner, value);
342
- }
343
- static assertWorkerOwner(value) {
344
- const result = Validator.validateWorkerOwner(value);
345
- if (!Validator.#accepted(value, result))
346
- throw new InvalidWorkerOwnerError(`invalid WorkerOwner: ${JSON.stringify(result.errors)}`);
347
- return value;
348
- }
349
- static validateProposalProjection(value) {
350
- return Validator.#validate(Validator.#proposalProjection, value);
351
- }
352
- static validateClientDisplayCapabilities(value) {
353
- return Validator.#validate(Validator.#clientDisplayCapabilities, value);
354
- }
355
- static validateMcpServerDefinition(value) {
356
- return Validator.#validate(Validator.#mcpServerDefinition, value);
357
- }
358
- static validateA2aAgentDefinition(value) {
359
- return Validator.#validate(Validator.#a2aAgentDefinition, value);
360
- }
361
- static validateSkillDefinition(value) {
362
- return Validator.#validate(Validator.#skillDefinition, value);
363
- }
364
- static validateMcpOAuth(value) {
365
- return Validator.#validate(Validator.#mcpOAuth, value);
366
- }
367
- static validateClientInteractionRequest(value) {
368
- return Validator.#validate(Validator.#clientInteractionRequest, value);
369
- }
370
- static validateClientInteractionProjection(value) {
371
- return Validator.#validate(Validator.#clientInteractionProjection, value);
372
- }
373
- static validateClientInteractionResolution(value) {
374
- return Validator.#validate(Validator.#clientInteractionResolution, value);
375
- }
376
- static validateEffort(value) {
377
- return Validator.#validate(Validator.#effort, value);
378
- }
379
- static validateProviderRequestAccounting(value) {
380
- return Validator.#validate(Validator.#providerRequestAccounting, value);
381
- }
382
- static validateModelCatalogPage(value) {
383
- return Validator.#validate(Validator.#modelCatalogPage, value);
384
- }
385
- static validateModelCatalogQuery(value) {
386
- return Validator.#validate(Validator.#modelCatalogQuery, value);
387
- }
388
- static validateFunctionalityListResult(value) {
389
- return Validator.#validate(Validator.#functionalityListResult, value);
390
- }
391
- static validateFunctionalityDiscoverResult(value) {
392
- return Validator.#validate(Validator.#functionalityDiscoverResult, value);
393
- }
394
- static validateFunctionalityMutationResult(value) {
395
- return Validator.#validate(Validator.#functionalityMutationResult, value);
396
- }
397
- static validateRollbackReport(value) {
398
- return Validator.#validate(Validator.#rollbackReport, value);
399
- }
400
- static assertRollbackReport(value) {
401
- const result = Validator.validateRollbackReport(value);
157
+ // oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- schema assertion returns the type the validated schema generates
158
+ static #assert(schema, label, value, ErrorClass = TypeError) {
159
+ const result = Validator.validateJsonSchemaInstance(schema, value);
402
160
  if (!Validator.#accepted(value, result)) {
403
- throw new InvalidRollbackReportError(`invalid RollbackReport: ${JSON.stringify(result.errors)}`);
161
+ throw new ErrorClass(`invalid ${label}: ${JSON.stringify(result.errors)}`);
404
162
  }
405
163
  return value;
406
164
  }
407
- static validateModelReadiness(value) {
408
- const result = Validator.#validate(Validator.#modelReadiness, value);
409
- if (!Validator.#accepted(value, result))
410
- return result;
411
- const readiness = value;
412
- if (readiness.ready !== (readiness.causes.length === 0)) {
413
- return {
414
- valid: false,
415
- errors: [{
416
- keyword: "model-readiness",
417
- instanceLocation: "",
418
- keywordLocation: "#",
419
- error: "ready must be true exactly when causes is empty",
420
- }],
421
- };
422
- }
423
- return result;
424
- }
425
- static validateModelRoute(value) {
426
- return Validator.#validate(Validator.#modelRoute, value);
427
- }
428
- static validateAguiDiscovery(value) {
429
- return Validator.#validate(Validator.#aguiDiscovery, value);
430
- }
431
- static validateAguiClientConformance(value) {
432
- return Validator.#validate(Validator.#aguiClientConformance, value);
433
- }
434
- static validateAguiConformanceKit(value) {
435
- return Validator.#validate(Validator.#aguiConformanceKit, value);
436
- }
437
165
  static validateJsonSchemaInstance(schema, value) {
438
166
  let validator = Validator.#jsonSchemaValidators.get(schema);
439
167
  if (validator === undefined) {
@@ -443,327 +171,178 @@ export default class Validator {
443
171
  validator = Validator.#withRefs(structuredClone(schema), Validator.#publicSchemas);
444
172
  Validator.#jsonSchemaValidators.set(schema, validator);
445
173
  }
446
- return Validator.#validate(validator, value);
174
+ const result = validator.validate(value);
175
+ return { valid: result.valid, errors: result.errors };
447
176
  }
448
- static assertNotice(value) {
449
- const result = Validator.validateNotice(value);
450
- if (!Validator.#accepted(value, result))
451
- throw new InvalidNoticeError(`invalid Notice: ${JSON.stringify(result.errors)}`);
177
+ static assertJsonSchemaInstance(label, schema, value) {
178
+ const result = Validator.validateJsonSchemaInstance(schema, value);
179
+ if (!result.valid) {
180
+ throw new TypeError(`${label} does not satisfy its JSON Schema: ${JSON.stringify(result.errors)}`);
181
+ }
452
182
  return value;
453
183
  }
184
+ static validateParsedPath(value) {
185
+ return Validator.validateJsonSchemaInstance(parsedPathSchema, value);
186
+ }
187
+ static validatePlurnkStatement(value) {
188
+ return Validator.validateJsonSchemaInstance(plurnkStatementSchema, value);
189
+ }
190
+ static validateEffort(value) {
191
+ return Validator.validateJsonSchemaInstance(effortSchema, value);
192
+ }
193
+ static assertSessionOwner(value) {
194
+ return Validator.#assert(sessionOwnerSchema, "SessionOwner", value);
195
+ }
196
+ static assertRollbackReport(value) {
197
+ return Validator.#assert(rollbackReportSchema, "RollbackReport", value);
198
+ }
199
+ static assertNotice(value) {
200
+ return Validator.#assert(noticeSchema, "Notice", value);
201
+ }
454
202
  static assertProblemDetails(value) {
455
- const result = Validator.validateProblemDetails(value);
456
- if (!Validator.#accepted(value, result)) {
457
- throw new InvalidProblemDetailsError(`invalid RFC 9457 Problem Details: ${JSON.stringify(result.errors)}`);
458
- }
459
- return value;
203
+ return Validator.#assert(problemDetailsSchema, "RFC 9457 Problem Details", value, InvalidProblemDetailsError);
460
204
  }
461
205
  static assertProblemProjection(value) {
462
- const result = Validator.validateProblemProjection(value);
463
- if (!Validator.#accepted(value, result)) {
464
- throw new InvalidProblemProjectionError(`invalid model Problem projection: ${JSON.stringify(result.errors)}`);
465
- }
466
- return value;
206
+ return Validator.#assert(problemProjectionSchema, "model Problem projection", value);
467
207
  }
468
208
  static assertOperationResult(value) {
469
- const result = Validator.validateOperationResult(value);
470
- if (!Validator.#accepted(value, result)) {
471
- throw new InvalidOperationResultError(`invalid operation result: ${JSON.stringify(result.errors)}`);
209
+ const exact = Validator.#assert(operationResultSchema, "operation result", value, InvalidOperationResultError);
210
+ if (exact.problem !== undefined && exact.problem.status !== exact.status) {
211
+ throw new InvalidOperationResultError(`operation result status ${exact.status} does not match problem status ${exact.problem.status}`);
472
212
  }
473
- if (value.problem !== undefined && value.problem.status !== value.status) {
474
- throw new InvalidOperationResultError(`operation result status ${value.status} does not match problem status ${value.problem.status}`);
475
- }
476
- if (value.range !== undefined) {
213
+ if (exact.range !== undefined) {
477
214
  try {
478
- Validator.assertRangeExtent(value.range);
215
+ Validator.assertRangeExtent(exact.range);
479
216
  }
480
217
  catch (cause) {
481
218
  throw new InvalidOperationResultError("operation result contains an invalid RangeExtent", { cause });
482
219
  }
483
220
  }
484
- return value;
221
+ return exact;
485
222
  }
486
223
  static assertEntryReadResult(value) {
487
- const result = Validator.validateEntryReadResult(value);
488
- if (!Validator.#accepted(value, result)) {
489
- throw new InvalidEntryReadResultError(`invalid EntryReadResult: ${JSON.stringify(result.errors)}`);
490
- }
491
- if ("problem" in value && value.problem.status !== value.status) {
492
- throw new InvalidEntryReadResultError(`EntryReadResult status ${value.status} does not match problem status ${value.problem.status}`);
224
+ const exact = Validator.#assert(entryReadResultSchema, "EntryReadResult", value);
225
+ if ("problem" in exact && exact.problem.status !== exact.status) {
226
+ throw new TypeError(`EntryReadResult status ${exact.status} does not match problem status ${exact.problem.status}`);
227
+ }
228
+ if (exact.entry !== null) {
229
+ for (const [name, channel] of Object.entries(exact.entry.channels)) {
230
+ const returnedLength = Array.from(channel.content).length;
231
+ if (channel.contentOffset + returnedLength !== channel.contentLength) {
232
+ throw new TypeError(`invalid EntryReadResult: /entry/channels/${name} contentOffset plus the returned Unicode-code-point length must equal contentLength`);
233
+ }
234
+ }
493
235
  }
494
- return value;
236
+ return exact;
495
237
  }
496
238
  static assertTextRegion(value) {
497
- const result = Validator.validateTextRegion(value);
498
- if (!Validator.#accepted(value, result)) {
499
- throw new InvalidTextRegionError(`invalid TextRegion: ${JSON.stringify(result.errors)}`);
500
- }
501
- if (value.endLine < value.startLine
502
- || (value.endLine === value.startLine && value.endColumn < value.startColumn)) {
503
- throw new InvalidTextRegionError("TextRegion ends before it starts");
239
+ const exact = Validator.#assert(textRegionSchema, "TextRegion", value);
240
+ if (exact.endLine < exact.startLine
241
+ || (exact.endLine === exact.startLine && exact.endColumn < exact.startColumn)) {
242
+ throw new TypeError("TextRegion ends before it starts");
504
243
  }
505
- return value;
244
+ return exact;
506
245
  }
507
246
  static assertRangeExtent(value) {
508
- const result = Validator.validateRangeExtent(value);
509
- if (!Validator.#accepted(value, result)) {
510
- throw new InvalidRangeExtentError(`invalid RangeExtent: ${JSON.stringify(result.errors)}`);
511
- }
512
- if (value.returned !== undefined) {
513
- const [first, last] = value.returned;
514
- if (first > last || last > value.total) {
515
- throw new InvalidRangeExtentError("RangeExtent returned positions must be ordered within total");
247
+ const exact = Validator.#assert(rangeExtentSchema, "RangeExtent", value);
248
+ if (exact.returned !== undefined) {
249
+ const [first, last] = exact.returned;
250
+ if (first > last || last > exact.total) {
251
+ throw new TypeError("RangeExtent returned positions must be ordered within total");
516
252
  }
517
253
  }
518
- return value;
254
+ return exact;
519
255
  }
520
256
  static assertCapabilityDescriptor(value) {
521
- const result = Validator.validateCapabilityDescriptor(value);
522
- if (!Validator.#accepted(value, result)) {
523
- throw new InvalidCapabilityDescriptorError(`invalid CapabilityDescriptor: ${JSON.stringify(result.errors)}`);
524
- }
525
- return value;
257
+ return Validator.#assert(capabilityDescriptorSchema, "CapabilityDescriptor", value);
526
258
  }
527
259
  static assertCapabilityPolicy(value) {
528
- const result = Validator.validateCapabilityPolicy(value);
529
- if (!Validator.#accepted(value, result)) {
530
- throw new InvalidCapabilityPolicyError(`invalid CapabilityPolicy: ${JSON.stringify(result.errors)}`);
531
- }
532
- return value;
260
+ return Validator.#assert(capabilityPolicySchema, "CapabilityPolicy", value);
533
261
  }
534
262
  static assertProposalProjection(value) {
535
- const result = Validator.validateProposalProjection(value);
536
- if (!Validator.#accepted(value, result)) {
537
- throw new InvalidProposalProjectionError(`invalid ProposalProjection: ${JSON.stringify(result.errors)}`);
538
- }
539
- return value;
263
+ return Validator.#assert(proposalProjectionSchema, "ProposalProjection", value);
540
264
  }
541
265
  static assertClientDisplayCapabilities(value) {
542
- const result = Validator.validateClientDisplayCapabilities(value);
543
- if (!Validator.#accepted(value, result)) {
544
- throw new InvalidClientDisplayCapabilitiesError(`invalid ClientDisplayCapabilities: ${JSON.stringify(result.errors)}`);
545
- }
546
- return value;
266
+ return Validator.#assert(clientDisplayCapabilitiesSchema, "ClientDisplayCapabilities", value);
547
267
  }
548
268
  static assertMcpServerDefinition(value) {
549
- const result = Validator.validateMcpServerDefinition(value);
550
- if (!Validator.#accepted(value, result)) {
551
- throw new InvalidMcpServerDefinitionError(`invalid MCP server definition: ${JSON.stringify(result.errors)}`);
552
- }
553
- return value;
554
- }
555
- static assertA2aAgentDefinition(value) {
556
- const result = Validator.validateA2aAgentDefinition(value);
557
- if (!Validator.#accepted(value, result)) {
558
- throw new InvalidA2aAgentDefinitionError(`invalid A2A agent definition: ${JSON.stringify(result.errors)}`);
559
- }
560
- return value;
269
+ return Validator.#assert(mcpServerDefinitionSchema, "MCP server definition", value);
561
270
  }
562
271
  static assertSkillDefinition(value) {
563
- const result = Validator.validateSkillDefinition(value);
564
- if (!Validator.#accepted(value, result)) {
565
- throw new InvalidSkillDefinitionError(`invalid Skill definition: ${JSON.stringify(result.errors)}`);
566
- }
567
- return value;
272
+ return Validator.#assert(skillDefinitionSchema, "Skill definition", value);
568
273
  }
569
274
  static assertMcpOAuth(value) {
570
- const result = Validator.validateMcpOAuth(value);
571
- if (!Validator.#accepted(value, result)) {
572
- throw new InvalidMcpOAuthError(`invalid MCP OAuth settings: ${JSON.stringify(result.errors)}`);
573
- }
574
- return value;
275
+ return Validator.#assert(mcpOAuthSchema, "MCP OAuth settings", value);
575
276
  }
576
277
  static assertClientInteractionRequest(value) {
577
- const result = Validator.validateClientInteractionRequest(value);
578
- if (!Validator.#accepted(value, result)) {
579
- throw new InvalidClientInteractionRequestError(`invalid ClientInteractionRequest: ${JSON.stringify(result.errors)}`);
580
- }
581
- return value;
278
+ return Validator.#assert(clientInteractionRequestSchema, "ClientInteractionRequest", value);
582
279
  }
583
280
  static assertClientInteractionProjection(value) {
584
- const result = Validator.validateClientInteractionProjection(value);
585
- if (!Validator.#accepted(value, result)) {
586
- throw new InvalidClientInteractionProjectionError(`invalid ClientInteractionProjection: ${JSON.stringify(result.errors)}`);
587
- }
588
- return value;
281
+ return Validator.#assert(clientInteractionProjectionSchema, "ClientInteractionProjection", value);
589
282
  }
590
283
  static assertClientInteractionResolution(value) {
591
- const result = Validator.validateClientInteractionResolution(value);
592
- if (!Validator.#accepted(value, result)) {
593
- throw new InvalidClientInteractionResolutionError(`invalid ClientInteractionResolution: ${JSON.stringify(result.errors)}`);
594
- }
595
- return value;
284
+ return Validator.#assert(clientInteractionResolutionSchema, "ClientInteractionResolution", value);
596
285
  }
597
286
  static assertParsedPath(value) {
598
- const result = Validator.validateParsedPath(value);
599
- if (!Validator.#accepted(value, result)) {
600
- throw new InvalidParsedPathError(`invalid ParsedPath: ${JSON.stringify(result.errors)}`);
601
- }
602
- return value;
287
+ return Validator.#assert(parsedPathSchema, "ParsedPath", value);
603
288
  }
604
289
  static assertPlurnkStatement(value) {
605
- const result = Validator.validatePlurnkStatement(value);
606
- if (!Validator.#accepted(value, result)) {
607
- throw new InvalidPlurnkStatementError(`invalid PlurnkStatement: ${JSON.stringify(result.errors)}`);
608
- }
609
- return value;
290
+ return Validator.#assert(plurnkStatementSchema, "PlurnkStatement", value);
610
291
  }
611
292
  static assertEffort(value) {
612
- const result = Validator.validateEffort(value);
613
- if (!Validator.#accepted(value, result)) {
614
- throw new InvalidEffortError(`invalid Effort: ${JSON.stringify(result.errors)}`);
615
- }
616
- return value;
293
+ return Validator.#assert(effortSchema, "Effort", value);
617
294
  }
618
295
  static assertModelCatalogPage(value) {
619
- const result = Validator.validateModelCatalogPage(value);
620
- if (!Validator.#accepted(value, result)) {
621
- throw new InvalidModelCatalogPageError(`invalid ModelCatalogPage: ${JSON.stringify(result.errors)}`);
622
- }
623
- const page = value;
296
+ const page = Validator.#assert(modelCatalogPageSchema, "ModelCatalogPage", value);
624
297
  const selectors = new Set();
625
298
  for (const item of page.items) {
626
299
  Validator.assertModelReadiness(item.readiness);
627
300
  if (item.selector !== `${item.provider}/${item.model}`) {
628
- throw new InvalidModelCatalogPageError("ModelCatalogPage item selector must equal provider/model");
301
+ throw new TypeError("ModelCatalogPage item selector must equal provider/model");
629
302
  }
630
303
  if (selectors.has(item.selector)) {
631
- throw new InvalidModelCatalogPageError("ModelCatalogPage item selectors must be unique");
304
+ throw new TypeError("ModelCatalogPage item selectors must be unique");
632
305
  }
633
306
  selectors.add(item.selector);
634
307
  }
635
308
  const pageEnd = page.offset + page.items.length;
636
309
  if (page.items.length > 0 && pageEnd > page.total) {
637
- throw new InvalidModelCatalogPageError("ModelCatalogPage items extend beyond total");
310
+ throw new TypeError("ModelCatalogPage items extend beyond total");
638
311
  }
639
312
  if (page.nextOffset !== undefined) {
640
313
  if (page.nextOffset !== pageEnd || page.nextOffset >= page.total) {
641
- throw new InvalidModelCatalogPageError("ModelCatalogPage nextOffset must equal the page end and leave remaining items");
314
+ throw new TypeError("ModelCatalogPage nextOffset must equal the page end and leave remaining items");
642
315
  }
643
316
  }
644
317
  else if (page.offset < page.total && pageEnd < page.total) {
645
- throw new InvalidModelCatalogPageError("ModelCatalogPage omits nextOffset before total");
318
+ throw new TypeError("ModelCatalogPage omits nextOffset before total");
646
319
  }
647
320
  return page;
648
321
  }
649
322
  static assertFunctionalityListResult(value) {
650
- const result = Validator.validateFunctionalityListResult(value);
651
- if (!Validator.#accepted(value, result)) {
652
- throw new InvalidFunctionalityListResultError(`invalid FunctionalityListResult: ${JSON.stringify(result.errors)}`);
653
- }
654
- return value;
323
+ return Validator.#assert(functionalityListResultSchema, "FunctionalityListResult", value);
655
324
  }
656
325
  static assertFunctionalityDiscoverResult(value) {
657
- const result = Validator.validateFunctionalityDiscoverResult(value);
658
- if (!Validator.#accepted(value, result)) {
659
- throw new InvalidFunctionalityDiscoverResultError(`invalid FunctionalityDiscoverResult: ${JSON.stringify(result.errors)}`);
660
- }
661
- return value;
326
+ return Validator.#assert(functionalityDiscoverResultSchema, "FunctionalityDiscoverResult", value);
662
327
  }
663
328
  static assertFunctionalityMutationResult(value) {
664
- const result = Validator.validateFunctionalityMutationResult(value);
665
- if (!Validator.#accepted(value, result)) {
666
- throw new InvalidFunctionalityMutationResultError(`invalid FunctionalityMutationResult: ${JSON.stringify(result.errors)}`);
667
- }
668
- return value;
329
+ return Validator.#assert(functionalityMutationResultSchema, "FunctionalityMutationResult", value);
669
330
  }
670
331
  static assertModelCatalogQuery(value) {
671
- const result = Validator.validateModelCatalogQuery(value);
672
- if (!Validator.#accepted(value, result)) {
673
- throw new InvalidModelCatalogQueryError(`invalid ModelCatalogQuery: ${JSON.stringify(result.errors)}`);
674
- }
675
- return value;
332
+ return Validator.#assert(modelCatalogQuerySchema, "ModelCatalogQuery", value);
676
333
  }
677
334
  static assertModelReadiness(value) {
678
- const result = Validator.validateModelReadiness(value);
679
- if (!Validator.#accepted(value, result)) {
680
- throw new InvalidModelReadinessError(`invalid ModelReadiness: ${JSON.stringify(result.errors)}`);
335
+ const readiness = Validator.#assert(modelReadinessSchema, "ModelReadiness", value);
336
+ if (readiness.ready !== (readiness.causes.length === 0)) {
337
+ throw new TypeError("invalid ModelReadiness: ready must be true exactly when causes is empty");
681
338
  }
682
- return value;
339
+ return readiness;
683
340
  }
684
341
  static assertModelRoute(value) {
685
- const result = Validator.validateModelRoute(value);
686
- if (!Validator.#accepted(value, result)) {
687
- throw new InvalidModelRouteError(`invalid ModelRoute: ${JSON.stringify(result.errors)}`);
688
- }
689
- return value;
690
- }
691
- static assertAguiDiscovery(value) {
692
- const result = Validator.validateAguiDiscovery(value);
693
- if (!Validator.#accepted(value, result)) {
694
- throw new InvalidAguiDiscoveryError(`invalid AG-UI discovery manifest: ${JSON.stringify(result.errors)}`);
695
- }
696
- return value;
697
- }
698
- static assertAguiClientConformance(discoveryValue, conformanceValue) {
699
- const discovery = Validator.assertAguiDiscovery(discoveryValue);
700
- const result = Validator.validateAguiClientConformance(conformanceValue);
701
- if (!Validator.#accepted(conformanceValue, result)) {
702
- throw new InvalidAguiClientConformanceError(`invalid AG-UI client conformance: ${JSON.stringify(result.errors)}`);
703
- }
704
- const conformance = conformanceValue;
705
- const mismatch = (kind) => {
706
- const installed = Object.keys(discovery[kind]).toSorted();
707
- const accounted = Object.keys(conformance[kind]).toSorted();
708
- return installed.length === accounted.length
709
- && installed.every((name, index) => name === accounted[index])
710
- ? []
711
- : [
712
- ...installed.filter((name) => !Object.hasOwn(conformance[kind], name)).map((name) => `missing ${kind.slice(0, -1)} '${name}'`),
713
- ...accounted.filter((name) => !Object.hasOwn(discovery[kind], name)).map((name) => `unknown ${kind.slice(0, -1)} '${name}'`),
714
- ];
715
- };
716
- const mismatches = [...mismatch("actions"), ...mismatch("notifications")];
717
- if (mismatches.length > 0) {
718
- throw new InvalidAguiClientConformanceError(`AG-UI client conformance does not account for the installed surface: ${mismatches.join(", ")}`);
719
- }
720
- const missingDimensions = [];
721
- for (const kind of ["actions", "notifications"]) {
722
- const baseline = kind === "actions"
723
- ? ["projection", "success", "failure"]
724
- : ["framing", "projection"];
725
- for (const [name, disposition] of Object.entries(conformance[kind])) {
726
- const required = disposition.posture === "native"
727
- ? [...baseline, "admission", "presentation"]
728
- : disposition.posture === "generic"
729
- ? baseline
730
- : ["failure"];
731
- for (const dimension of required) {
732
- if (!disposition.dimensions.some((declared) => declared === dimension)) {
733
- missingDimensions.push(`${kind.slice(0, -1)} '${name}' lacks ${dimension}`);
734
- }
735
- }
736
- }
737
- }
738
- if (missingDimensions.length > 0) {
739
- throw new InvalidAguiClientConformanceError(`AG-UI client conformance omits required dimensions: ${missingDimensions.join(", ")}`);
740
- }
741
- return conformance;
342
+ return Validator.#assert(modelRouteSchema, "ModelRoute", value);
742
343
  }
743
- static assertAguiConformanceKit(value) {
744
- const result = Validator.validateAguiConformanceKit(value);
745
- if (!Validator.#accepted(value, result)) {
746
- throw new InvalidAguiConformanceKitError(`invalid AG-UI conformance kit: ${JSON.stringify(result.errors)}`);
747
- }
748
- const kit = value;
749
- for (const specimens of [kit.transport, kit.lifecycles]) {
750
- const names = specimens.map(({ name }) => name);
751
- if (new Set(names).size !== names.length) {
752
- throw new InvalidAguiConformanceKitError("AG-UI conformance specimen names must be unique within their family");
753
- }
754
- }
755
- return kit;
756
- }
757
- static assertJsonSchemaInstance(label, schema, value) {
758
- const result = Validator.validateJsonSchemaInstance(schema, value);
759
- if (!result.valid) {
760
- throw new InvalidJsonSchemaInstanceError(`${label} does not satisfy its JSON Schema: ${JSON.stringify(result.errors)}`);
761
- }
762
- return value;
763
- }
764
- static #validate(validator, value) {
765
- const result = validator.validate(value);
766
- return { valid: result.valid, errors: result.errors };
344
+ static assertAcpDiscovery(value) {
345
+ return Validator.#assert(acpDiscoverySchema, "ACP discovery manifest", value);
767
346
  }
768
347
  }
769
348
  //# sourceMappingURL=Validator.js.map