code60-transmission-server 0.0.0-stage → 0.1.0-staging.12

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 (98) hide show
  1. package/LICENSE +180 -0
  2. package/README.engine.md +463 -0
  3. package/README.md +376 -2
  4. package/dist/src/broker/filesystem.js +385 -0
  5. package/dist/src/broker/index.js +734 -0
  6. package/dist/src/broker/native/README.md +207 -0
  7. package/dist/src/broker/native/build.js +46 -0
  8. package/dist/src/broker/native/command-helper.c +93 -0
  9. package/dist/src/broker/native/fs-helper.c +529 -0
  10. package/dist/src/broker/native/git-helper.c +205 -0
  11. package/dist/src/broker/policy.js +149 -0
  12. package/dist/src/broker/startup-lock.js +14 -0
  13. package/dist/src/broker/types.js +11 -0
  14. package/dist/src/cli/configure.js +208 -0
  15. package/dist/src/cli/daemon.js +369 -0
  16. package/dist/src/cli/helpers.js +112 -0
  17. package/dist/src/cli/main.js +189 -0
  18. package/dist/src/cli/runtime-build.js +38 -0
  19. package/dist/src/config/coding-policy.js +4 -0
  20. package/dist/src/config/deployment.js +183 -0
  21. package/dist/src/config/documents.js +29 -0
  22. package/dist/src/config/profile-validation.js +129 -0
  23. package/dist/src/config/schema-graph.js +237 -0
  24. package/dist/src/config/schema-loader.js +185 -0
  25. package/dist/src/config/validation-pool.js +105 -0
  26. package/dist/src/config/validation-protocol.js +1 -0
  27. package/dist/src/config/validation-worker.js +106 -0
  28. package/dist/src/config/workflow-language.js +9 -0
  29. package/dist/src/config/workflow-schema.json +545 -0
  30. package/dist/src/config/workflow-types.js +1 -0
  31. package/dist/src/config/workflow-validation.js +95 -0
  32. package/dist/src/engine/budgets.js +50 -0
  33. package/dist/src/engine/clocks.js +27 -0
  34. package/dist/src/engine/commands.js +477 -0
  35. package/dist/src/engine/contracts.js +11 -0
  36. package/dist/src/engine/drain-state.js +31 -0
  37. package/dist/src/engine/effective-permissions.js +120 -0
  38. package/dist/src/engine/instruction-pins.js +205 -0
  39. package/dist/src/engine/retries.js +50 -0
  40. package/dist/src/engine/state.js +1 -0
  41. package/dist/src/engine/timing.js +23 -0
  42. package/dist/src/engine/tool-observations.js +87 -0
  43. package/dist/src/engine/workflow-engine.js +1862 -0
  44. package/dist/src/main.js +28 -0
  45. package/dist/src/mcp/catalog.js +71 -0
  46. package/dist/src/mcp/main.js +26 -0
  47. package/dist/src/mcp/server.js +177 -0
  48. package/dist/src/runtime/codex-app-server.js +91 -0
  49. package/dist/src/runtime/codex-executable.js +50 -0
  50. package/dist/src/runtime/containment.js +82 -0
  51. package/dist/src/runtime/engine-driver.js +221 -0
  52. package/dist/src/runtime/json-line-writer.js +192 -0
  53. package/dist/src/runtime/pinned-instruction-sources.js +24 -0
  54. package/dist/src/runtime/protocol-client.js +264 -0
  55. package/dist/src/runtime/protocol-pool.js +183 -0
  56. package/dist/src/runtime/protocol-projection.js +393 -0
  57. package/dist/src/runtime/protocol-types.js +1 -0
  58. package/dist/src/runtime/protocol-worker.js +18 -0
  59. package/dist/src/runtime/provider-bridge.js +290 -0
  60. package/dist/src/runtime/provider-credentials.js +41 -0
  61. package/dist/src/runtime/provider-transport.js +406 -0
  62. package/dist/src/runtime/runtime-broker.js +213 -0
  63. package/dist/src/runtime/workspace-instructions.js +120 -0
  64. package/dist/src/runtime/workspace-view.js +74 -0
  65. package/dist/src/server/api-contract.json +11629 -0
  66. package/dist/src/server/api-types.js +1 -0
  67. package/dist/src/server/application.js +44 -0
  68. package/dist/src/server/auth.js +67 -0
  69. package/dist/src/server/broker-handlers.js +242 -0
  70. package/dist/src/server/coding.js +281 -0
  71. package/dist/src/server/control-plane.js +50 -0
  72. package/dist/src/server/deployment.js +249 -0
  73. package/dist/src/server/errors.js +22 -0
  74. package/dist/src/server/history-handlers.js +127 -0
  75. package/dist/src/server/http.js +124 -0
  76. package/dist/src/server/paging.js +56 -0
  77. package/dist/src/server/publication.js +119 -0
  78. package/dist/src/server/tool-event-handler.js +77 -0
  79. package/dist/src/server/workspace-handlers.js +34 -0
  80. package/dist/src/storage/coordinator.js +224 -0
  81. package/dist/src/storage/startup-lock.js +71 -0
  82. package/dist/src/storage/store.js +167 -0
  83. package/dist/src/tools/check-worker.js +81 -0
  84. package/dist/src/tools/checks.js +117 -0
  85. package/dist/src/tools/command-check.js +34 -0
  86. package/dist/src/tools/commands.js +312 -0
  87. package/dist/src/tools/developer.js +353 -0
  88. package/dist/src/tools/dns.js +248 -0
  89. package/dist/src/tools/http-contract.js +38 -0
  90. package/dist/src/tools/http.js +358 -0
  91. package/dist/src/tools/index.js +194 -0
  92. package/dist/src/tools/worker-check.js +73 -0
  93. package/dist/src/workspaces/git.js +227 -0
  94. package/dist/src/workspaces/index.js +937 -0
  95. package/dist/src/workspaces/source.js +295 -0
  96. package/examples/deployment.local.json +22 -0
  97. package/package.json +71 -4
  98. package/scripts/postinstall.mjs +26 -0
@@ -0,0 +1,545 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Agentic Workflow YAML",
4
+ "$comment": "Structural workflow validation. Embedded schemas require companion validation; no defaults are inserted.",
5
+ "type": "object",
6
+ "properties": {
7
+ "kind": {
8
+ "const": "Workflow"
9
+ },
10
+ "version": {
11
+ "const": "1"
12
+ },
13
+ "metadata": {
14
+ "type": "object",
15
+ "properties": {
16
+ "name": {
17
+ "type": "string",
18
+ "minLength": 1
19
+ },
20
+ "description": {
21
+ "type": "string"
22
+ }
23
+ },
24
+ "required": [
25
+ "name"
26
+ ],
27
+ "additionalProperties": false
28
+ },
29
+ "types": {
30
+ "type": "object",
31
+ "propertyNames": {
32
+ "type": "string",
33
+ "pattern": "^[A-Za-z_][A-Za-z0-9_-]*$"
34
+ },
35
+ "additionalProperties": {
36
+ "type": [
37
+ "object",
38
+ "boolean"
39
+ ]
40
+ }
41
+ },
42
+ "config": {
43
+ "type": "object",
44
+ "properties": {
45
+ "timeout": {
46
+ "$ref": "#/$defs/timeout"
47
+ },
48
+ "schema-fetch": {
49
+ "$ref": "#/$defs/schemaFetch"
50
+ },
51
+ "infrastructure-retries": {
52
+ "type": "integer",
53
+ "minimum": 0,
54
+ "default": 3,
55
+ "description": "Retries after an initial infrastructure failure before charging an attempt."
56
+ },
57
+ "verification-retries": {
58
+ "type": "integer",
59
+ "minimum": 0,
60
+ "default": 3,
61
+ "description": "Engine retries after an initial unsuccessful verification operation; not retries of semantic rejection."
62
+ },
63
+ "pause-grace-period": {
64
+ "type": "string",
65
+ "pattern": "^[1-9][0-9]*(ms|s|m|h|d)$",
66
+ "default": "60s",
67
+ "description": "Global graceful-pause wait before operator attention; server default 30s. Expiry does not force-stop tools or mark the run paused."
68
+ },
69
+ "agent-profiles": {
70
+ "$ref": "#/$defs/AgentProfileBindings"
71
+ },
72
+ "approval-timeout": {
73
+ "type": "string",
74
+ "pattern": "^[1-9][0-9]*(ms|s|m|h|d)$",
75
+ "default": "24h",
76
+ "description": "Wall-clock approval/unused-grant expiry; continues through all pauses, bounded by applicable deadlines."
77
+ }
78
+ },
79
+ "required": [],
80
+ "additionalProperties": false
81
+ },
82
+ "steps": {
83
+ "type": "array",
84
+ "minItems": 1,
85
+ "items": {
86
+ "$ref": "#/$defs/step"
87
+ }
88
+ },
89
+ "instruction-resources": {
90
+ "type": "array",
91
+ "items": {
92
+ "$ref": "#/$defs/InstructionResource"
93
+ }
94
+ },
95
+ "inputs": {
96
+ "description": "Optional JSON Schema for immutable run inputs",
97
+ "oneOf": [
98
+ {
99
+ "type": "object"
100
+ },
101
+ {
102
+ "type": "boolean"
103
+ }
104
+ ]
105
+ }
106
+ },
107
+ "required": [
108
+ "kind",
109
+ "version",
110
+ "metadata",
111
+ "steps"
112
+ ],
113
+ "additionalProperties": false,
114
+ "$defs": {
115
+ "schemaFetch": {
116
+ "$comment": "Workflow-wide fetch timing settings. Defaults describe runtime behavior; validation does not insert them.",
117
+ "type": "object",
118
+ "properties": {
119
+ "timeout": {
120
+ "type": "string",
121
+ "pattern": "^[1-9][0-9]*(ms|s|m|h|d)$",
122
+ "default": "30s",
123
+ "description": "Total elapsed-time limit per schema fetch attempt, including connection and complete download."
124
+ },
125
+ "retry-delays": {
126
+ "type": "array",
127
+ "items": {
128
+ "type": "string",
129
+ "pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
130
+ },
131
+ "minItems": 2,
132
+ "maxItems": 2,
133
+ "default": [
134
+ "1s",
135
+ "2s"
136
+ ],
137
+ "description": "Delays before attempts two and three, respectively."
138
+ }
139
+ },
140
+ "additionalProperties": false
141
+ },
142
+ "artifact": {
143
+ "oneOf": [
144
+ {
145
+ "type": "object",
146
+ "properties": {
147
+ "$ref": {
148
+ "type": "string",
149
+ "pattern": "^(?:#/types/[A-Za-z_][A-Za-z0-9_-]*|[^/#?:\\\\\\r\\n][^#?:\\\\\\r\\n]*(?:#[^#\\r\\n]*)?)$"
150
+ }
151
+ },
152
+ "required": [
153
+ "$ref"
154
+ ],
155
+ "additionalProperties": false
156
+ },
157
+ {
158
+ "type": "object",
159
+ "not": {
160
+ "required": [
161
+ "$ref"
162
+ ]
163
+ }
164
+ },
165
+ {
166
+ "type": "boolean"
167
+ }
168
+ ]
169
+ },
170
+ "timeout": {
171
+ "type": "object",
172
+ "properties": {
173
+ "duration": {
174
+ "type": "string",
175
+ "pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
176
+ },
177
+ "on-timeout": {
178
+ "enum": [
179
+ "fail",
180
+ "block"
181
+ ]
182
+ }
183
+ },
184
+ "required": [
185
+ "duration",
186
+ "on-timeout"
187
+ ],
188
+ "additionalProperties": false
189
+ },
190
+ "workerTimeout": {
191
+ "type": "object",
192
+ "properties": {
193
+ "duration": {
194
+ "type": "string",
195
+ "pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
196
+ },
197
+ "on-timeout": {
198
+ "const": "reset-session",
199
+ "description": "Exhaustion prepares required handoff and resets if possible; otherwise blocks for decision."
200
+ }
201
+ },
202
+ "required": [
203
+ "duration",
204
+ "on-timeout"
205
+ ],
206
+ "additionalProperties": false
207
+ },
208
+ "step": {
209
+ "type": "object",
210
+ "properties": {
211
+ "id": {
212
+ "type": "string",
213
+ "pattern": "^[A-Za-z_][A-Za-z0-9_-]*$"
214
+ },
215
+ "name": {
216
+ "type": "string"
217
+ },
218
+ "execution": {
219
+ "type": "object",
220
+ "properties": {
221
+ "max-session-resets": {
222
+ "type": "integer",
223
+ "minimum": 0
224
+ },
225
+ "max-attempts-per-session": {
226
+ "type": "integer",
227
+ "minimum": 1
228
+ },
229
+ "git-reset-on-session-reset": {
230
+ "type": "boolean",
231
+ "default": false
232
+ },
233
+ "session": {
234
+ "type": "object",
235
+ "properties": {
236
+ "timeout": {
237
+ "$ref": "#/$defs/workerTimeout"
238
+ }
239
+ },
240
+ "required": [],
241
+ "additionalProperties": false
242
+ },
243
+ "submission-interval": {
244
+ "type": "object",
245
+ "properties": {
246
+ "duration": {
247
+ "type": "string",
248
+ "pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
249
+ },
250
+ "on-timeout": {
251
+ "const": "block",
252
+ "default": "block"
253
+ }
254
+ },
255
+ "required": [
256
+ "duration"
257
+ ],
258
+ "additionalProperties": false,
259
+ "description": "Time until first/next submission, excluding verification. Restarts after every submission; expiry blocks for a decision."
260
+ }
261
+ },
262
+ "required": [
263
+ "max-session-resets"
264
+ ],
265
+ "additionalProperties": false,
266
+ "anyOf": [
267
+ {
268
+ "required": [
269
+ "max-attempts-per-session"
270
+ ]
271
+ },
272
+ {
273
+ "required": [
274
+ "session"
275
+ ],
276
+ "properties": {
277
+ "session": {
278
+ "required": [
279
+ "timeout"
280
+ ]
281
+ }
282
+ }
283
+ }
284
+ ]
285
+ },
286
+ "exitArtifact": {
287
+ "type": "object",
288
+ "properties": {
289
+ "schema": {
290
+ "$ref": "#/$defs/artifact"
291
+ }
292
+ },
293
+ "required": [
294
+ "schema"
295
+ ],
296
+ "additionalProperties": false
297
+ },
298
+ "exitCriteria": {
299
+ "type": "object",
300
+ "properties": {
301
+ "deterministic": {
302
+ "type": "object",
303
+ "properties": {
304
+ "checks": {
305
+ "type": "array",
306
+ "items": {
307
+ "type": "string",
308
+ "minLength": 1
309
+ }
310
+ }
311
+ },
312
+ "required": [],
313
+ "additionalProperties": false
314
+ },
315
+ "semantic": {
316
+ "type": "object",
317
+ "properties": {
318
+ "criteria": {
319
+ "type": "array",
320
+ "items": {
321
+ "type": "string",
322
+ "minLength": 1
323
+ },
324
+ "minItems": 1
325
+ },
326
+ "verifier": {
327
+ "type": "object",
328
+ "properties": {
329
+ "session": {
330
+ "const": "ephemeral"
331
+ },
332
+ "max-attempts": {
333
+ "type": "integer",
334
+ "minimum": 1
335
+ },
336
+ "timeout": {
337
+ "$ref": "#/$defs/timeout"
338
+ }
339
+ },
340
+ "required": [
341
+ "session"
342
+ ],
343
+ "additionalProperties": false,
344
+ "anyOf": [
345
+ {
346
+ "required": [
347
+ "max-attempts"
348
+ ]
349
+ },
350
+ {
351
+ "required": [
352
+ "timeout"
353
+ ]
354
+ }
355
+ ]
356
+ }
357
+ },
358
+ "required": [
359
+ "criteria",
360
+ "verifier"
361
+ ],
362
+ "additionalProperties": false
363
+ }
364
+ },
365
+ "required": [],
366
+ "additionalProperties": false
367
+ },
368
+ "handoffArtifact": {
369
+ "type": "object",
370
+ "properties": {
371
+ "schema": {
372
+ "$ref": "#/$defs/artifact"
373
+ },
374
+ "historyLimit": {
375
+ "type": "integer",
376
+ "minimum": 0
377
+ },
378
+ "independent-handoff": {
379
+ "type": "boolean"
380
+ },
381
+ "max-attempts": {
382
+ "type": "integer",
383
+ "minimum": 1
384
+ },
385
+ "timeout": {
386
+ "$ref": "#/$defs/timeout"
387
+ }
388
+ },
389
+ "required": [
390
+ "schema",
391
+ "historyLimit",
392
+ "independent-handoff"
393
+ ],
394
+ "additionalProperties": false,
395
+ "allOf": [
396
+ {
397
+ "if": {
398
+ "properties": {
399
+ "independent-handoff": {
400
+ "const": true
401
+ }
402
+ },
403
+ "required": [
404
+ "independent-handoff"
405
+ ]
406
+ },
407
+ "then": {
408
+ "anyOf": [
409
+ {
410
+ "required": [
411
+ "max-attempts"
412
+ ]
413
+ },
414
+ {
415
+ "required": [
416
+ "timeout"
417
+ ]
418
+ }
419
+ ]
420
+ },
421
+ "else": {
422
+ "not": {
423
+ "required": [
424
+ "timeout"
425
+ ]
426
+ }
427
+ }
428
+ }
429
+ ]
430
+ },
431
+ "timeout": {
432
+ "$ref": "#/$defs/timeout"
433
+ },
434
+ "agent-profiles": {
435
+ "$ref": "#/$defs/AgentProfileBindings"
436
+ },
437
+ "instructions": {
438
+ "type": "array",
439
+ "items": {
440
+ "$ref": "#/$defs/InstructionSource"
441
+ }
442
+ }
443
+ },
444
+ "required": [
445
+ "id",
446
+ "execution",
447
+ "exitArtifact",
448
+ "exitCriteria"
449
+ ],
450
+ "additionalProperties": false
451
+ },
452
+ "AgentProfileBindings": {
453
+ "type": "object",
454
+ "properties": {
455
+ "worker": {
456
+ "$ref": "#/$defs/Id"
457
+ },
458
+ "verifier": {
459
+ "$ref": "#/$defs/Id"
460
+ },
461
+ "handoff": {
462
+ "$ref": "#/$defs/Id"
463
+ }
464
+ },
465
+ "required": [],
466
+ "additionalProperties": false,
467
+ "description": "Complete profile-version IDs, never mutable profile IDs or field overrides. Workflow defaults < run defaults < step bindings; overlay references by role, never merge profile contents. Required roles are checked after resolving the workflow.",
468
+ "minProperties": 1
469
+ },
470
+ "InstructionSource": {
471
+ "oneOf": [
472
+ {
473
+ "type": "object",
474
+ "properties": {
475
+ "kind": {
476
+ "const": "inline"
477
+ },
478
+ "text": {
479
+ "type": "string",
480
+ "minLength": 1
481
+ }
482
+ },
483
+ "required": [
484
+ "kind",
485
+ "text"
486
+ ],
487
+ "additionalProperties": false
488
+ },
489
+ {
490
+ "type": "object",
491
+ "properties": {
492
+ "kind": {
493
+ "const": "file"
494
+ },
495
+ "location": {
496
+ "type": "string",
497
+ "enum": [
498
+ "package",
499
+ "workspace"
500
+ ]
501
+ },
502
+ "path": {
503
+ "$ref": "#/$defs/RelativePath"
504
+ }
505
+ },
506
+ "required": [
507
+ "kind",
508
+ "location",
509
+ "path"
510
+ ],
511
+ "additionalProperties": false
512
+ }
513
+ ],
514
+ "description": "Ordered UTF-8 user/project instruction source. No URL, automatic discovery or templating. Workspace paths are relative to the managed root; package paths are relative to the owning profile/workflow package."
515
+ },
516
+ "InstructionResource": {
517
+ "type": "object",
518
+ "properties": {
519
+ "path": {
520
+ "$ref": "#/$defs/RelativePath"
521
+ },
522
+ "content": {
523
+ "type": "string"
524
+ }
525
+ },
526
+ "required": [
527
+ "path",
528
+ "content"
529
+ ],
530
+ "additionalProperties": false,
531
+ "description": "UTF-8 instruction file embedded in the immutable source package. Paths must be unique. Not an artifact JSON/YAML schema."
532
+ },
533
+ "RelativePath": {
534
+ "type": "string",
535
+ "minLength": 1,
536
+ "pattern": "^(?!/)(?![A-Za-z][A-Za-z0-9+.-]*:)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))[^\\\\\\r\\n]+(?<!/)$"
537
+ },
538
+ "Id": {
539
+ "type": "string",
540
+ "minLength": 1,
541
+ "maxLength": 128,
542
+ "pattern": "^[A-Za-z0-9_-]+$"
543
+ }
544
+ }
545
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ import { workflowLanguageSchema } from './workflow-language.js';
2
+ import { decodeDocument } from './documents.js';
3
+ import { buildSchemaGraph } from './schema-graph.js';
4
+ /** Trusted pure work: invoke ONLY inside a bounded validation worker. */
5
+ export function validateWorkflow(input, checks, ajv, remote = []) {
6
+ const report = { valid: false, issues: [], unresolvedReferences: [], validationLevel: 'structural' };
7
+ const add = (path, code, message) => report.issues.push({ severity: 'error', path, code, message });
8
+ let parsed;
9
+ try {
10
+ parsed = decodeDocument(input.source.content, input.source.format);
11
+ }
12
+ catch {
13
+ add('/source/content', 'invalid_document', 'Workflow must be acyclic JSON-compatible data with unique string keys.');
14
+ return { report };
15
+ }
16
+ const validate = ajv.compile(workflowLanguageSchema());
17
+ if (!validate(parsed)) {
18
+ for (const error of validate.errors ?? [])
19
+ add(error.instancePath, error.keyword, error.message ?? 'Workflow structure is invalid.');
20
+ return { report };
21
+ }
22
+ const definition = parsed;
23
+ const ids = new Set();
24
+ const instructions = new Map();
25
+ for (const [index, resource] of (definition['instruction-resources'] ?? []).entries()) {
26
+ if (instructions.has(resource.path))
27
+ add(`/instruction-resources/${index}/path`, 'duplicate_path', 'Instruction resource paths must be unique.');
28
+ instructions.set(resource.path, resource.content);
29
+ }
30
+ for (const [index, step] of definition.steps.entries()) {
31
+ if (ids.has(step.id))
32
+ add(`/steps/${index}/id`, 'duplicate_step_id', 'Step IDs must be unique.');
33
+ ids.add(step.id);
34
+ for (const name of step.exitCriteria.deterministic?.checks ?? [])
35
+ if (!checks.includes(name))
36
+ add(`/steps/${index}/exitCriteria/deterministic/checks`, 'unknown_check', 'A required named check is not installed.');
37
+ for (const [position, source] of (step.instructions ?? []).entries())
38
+ if (source.kind === 'file') {
39
+ if (source.location === 'package' && !instructions.has(source.path))
40
+ add(`/steps/${index}/instructions/${position}`, 'missing_package_source', 'Packaged step instruction source is missing.');
41
+ if (source.location === 'workspace')
42
+ report.unresolvedReferences.push(`workspace:${source.path}`);
43
+ }
44
+ const bindings = { ...definition.config?.['agent-profiles'], ...step['agent-profiles'] };
45
+ const roles = ['worker'];
46
+ if (step.exitCriteria.semantic?.criteria.length)
47
+ roles.push('verifier');
48
+ if (step.handoffArtifact?.['independent-handoff'])
49
+ roles.push('handoff');
50
+ for (const role of roles)
51
+ if (!bindings[role])
52
+ report.unresolvedReferences.push(`profile:${step.id}:${role}`);
53
+ }
54
+ let graph;
55
+ try {
56
+ graph = buildSchemaGraph(definition, input, remote);
57
+ }
58
+ catch {
59
+ add('/schemas', 'invalid_schema_graph', 'Schema identities or references are invalid.');
60
+ return { report, definition };
61
+ }
62
+ for (const issue of graph.errors)
63
+ add(issue.path, issue.code, issue.message);
64
+ report.unresolvedReferences.push(...graph.unresolvedRemote);
65
+ for (const resource of graph.resources) {
66
+ const schema = resource.schema;
67
+ if (typeof schema !== 'boolean' && (schema === null || typeof schema !== 'object' || Array.isArray(schema)))
68
+ continue;
69
+ try {
70
+ if (!ajv.validateSchema(schema))
71
+ for (const error of ajv.errors ?? [])
72
+ add('/schemas', error.keyword, error.message ?? 'Schema syntax is invalid.');
73
+ }
74
+ catch {
75
+ add('/schemas', 'invalid_schema', 'Schema syntax or dialect is unsupported.');
76
+ }
77
+ }
78
+ if (!graph.errors.length && !graph.unresolvedRemote.length) {
79
+ try {
80
+ for (const resource of graph.resources) {
81
+ if (typeof resource.schema === 'boolean' || (resource.schema !== null && typeof resource.schema === 'object' && !Array.isArray(resource.schema)))
82
+ ajv.addSchema(resource.schema, resource.uri);
83
+ }
84
+ for (const root of graph.roots)
85
+ ajv.compile({ $ref: root.uri });
86
+ }
87
+ catch {
88
+ add('/schemas', 'invalid_schema_graph', 'The complete schema graph cannot be compiled.');
89
+ }
90
+ }
91
+ report.valid = !report.issues.some(issue => issue.severity === 'error');
92
+ report.unresolvedReferences = [...new Set(report.unresolvedReferences)];
93
+ report.validationLevel = 'local_references';
94
+ return { report, definition, graph };
95
+ }