@termwright/protocol 0.2.0 → 0.3.1

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 (40) hide show
  1. package/README.md +213 -605
  2. package/dist/action-model-BP9Znu6L.d.ts +219 -0
  3. package/dist/action-model.d.ts +3 -0
  4. package/dist/action-model.js +15 -0
  5. package/dist/action-model.js.map +1 -0
  6. package/dist/capability-graph.d.ts +90 -0
  7. package/dist/capability-graph.js +43 -0
  8. package/dist/capability-graph.js.map +1 -0
  9. package/dist/chunk-B4VUTTUE.js +59 -0
  10. package/dist/chunk-B4VUTTUE.js.map +1 -0
  11. package/dist/chunk-CZK6NNP3.js +389 -0
  12. package/dist/chunk-CZK6NNP3.js.map +1 -0
  13. package/dist/chunk-ODOJRXL6.js +84 -0
  14. package/dist/chunk-ODOJRXL6.js.map +1 -0
  15. package/dist/chunk-PUXRCPGY.js +112 -0
  16. package/dist/chunk-PUXRCPGY.js.map +1 -0
  17. package/dist/chunk-VBLS6E6U.js +1109 -0
  18. package/dist/chunk-VBLS6E6U.js.map +1 -0
  19. package/dist/chunk-ZZIYHDJ4.js +202 -0
  20. package/dist/chunk-ZZIYHDJ4.js.map +1 -0
  21. package/dist/contract-CH9gmj2Y.d.ts +746 -0
  22. package/dist/contract.d.ts +2 -0
  23. package/dist/contract.js +21 -0
  24. package/dist/contract.js.map +1 -0
  25. package/dist/index.d.ts +82 -798
  26. package/dist/index.js +1087 -766
  27. package/dist/index.js.map +1 -1
  28. package/dist/run-events.d.ts +158 -0
  29. package/dist/run-events.js +27 -0
  30. package/dist/run-events.js.map +1 -0
  31. package/dist/run-journal.d.ts +55 -0
  32. package/dist/run-journal.js +10 -0
  33. package/dist/run-journal.js.map +1 -0
  34. package/dist/run-state.d.ts +38 -0
  35. package/dist/run-state.js +19 -0
  36. package/dist/run-state.js.map +1 -0
  37. package/dist/test-provider.d.ts +22 -0
  38. package/dist/test-provider.js +32 -0
  39. package/dist/test-provider.js.map +1 -0
  40. package/package.json +33 -5
@@ -0,0 +1,1109 @@
1
+ // src/capability-graph.ts
2
+ var CAPABILITY_GRAPH_VERSION = 5;
3
+ var CAPABILITY_NODE_CATEGORIES = Object.freeze([
4
+ "evidence",
5
+ "input",
6
+ "planning",
7
+ "synchronization",
8
+ "diagnostic"
9
+ ]);
10
+ var CAPABILITY_NODE_LAYERS = Object.freeze([
11
+ "producer",
12
+ "session",
13
+ "runtime",
14
+ "strategy",
15
+ "public"
16
+ ]);
17
+ var CAPABILITY_EDGE_KINDS = Object.freeze([
18
+ "produces",
19
+ "requires",
20
+ "requires-any",
21
+ "runtime-requires",
22
+ "diagnoses"
23
+ ]);
24
+ var ADAPTER_CAPABILITIES = Object.freeze([
25
+ "tree",
26
+ "intended-geometry",
27
+ "clipped-geometry",
28
+ "states",
29
+ "focus-state",
30
+ "actions",
31
+ "action-recipes",
32
+ "text-ranges",
33
+ "render-revisions",
34
+ "logs",
35
+ "pointer-hit-grid"
36
+ ]);
37
+ var PROBE_CAPABILITIES = Object.freeze([
38
+ "stable-identity",
39
+ "intended-rect",
40
+ "visible-rect",
41
+ "operations",
42
+ "annotations",
43
+ "frame-begin",
44
+ "paint-order"
45
+ ]);
46
+ var EVIDENCE_PROVIDER_CAPABILITIES = Object.freeze([
47
+ "pointer-regions",
48
+ "hit-test",
49
+ "focus-state",
50
+ "action-recipes",
51
+ "scroll-state",
52
+ "painted-regions",
53
+ "terminal-input-modes"
54
+ ]);
55
+ var EVIDENCE_PROVIDER_TYPES = Object.freeze([
56
+ "pointer-evidence",
57
+ "focus-evidence",
58
+ "action-strategy",
59
+ "scroll-evidence",
60
+ "paint-evidence",
61
+ "input-mode-evidence"
62
+ ]);
63
+ var SESSION_CAPABILITIES = Object.freeze([
64
+ "semantic-tree",
65
+ "stable-identity",
66
+ "intended-geometry",
67
+ "clipped-geometry",
68
+ "painted-region",
69
+ "pointer-geometry",
70
+ "pointer-hit-testing",
71
+ "focus",
72
+ "scroll",
73
+ "render-order",
74
+ "action-strategies",
75
+ "keyboard-input",
76
+ "pointer-input",
77
+ "focus-input",
78
+ "paired-revisions"
79
+ ]);
80
+ var RUNTIME_PREREQUISITES = Object.freeze([
81
+ "writable-pty",
82
+ "terminal-input-modes-authoritative",
83
+ "mouse-reporting-enabled",
84
+ "mouse-motion-enabled",
85
+ "focus-reporting-enabled",
86
+ "committed-observation"
87
+ ]);
88
+ var PUBLIC_CAPABILITY_CONSUMERS = Object.freeze([
89
+ "locator.semantic-query",
90
+ "locator.semantic-scroll",
91
+ "locator.painted-region",
92
+ "condition.attached",
93
+ "condition.displayed",
94
+ "condition.visible",
95
+ "condition.in-viewport",
96
+ "condition.focused",
97
+ "condition.value",
98
+ "action.click",
99
+ "action.hover",
100
+ "action.drag",
101
+ "action.focus",
102
+ "action.activate",
103
+ "action.type",
104
+ "action.fill",
105
+ "action.check",
106
+ "action.uncheck",
107
+ "device.keyboard",
108
+ "device.mouse",
109
+ "device.window-focus",
110
+ "checkpoint",
111
+ "runner.inspector",
112
+ "trace.action",
113
+ "recorder.semantic-action",
114
+ "mcp.semantic-action",
115
+ "runner.diagnostics",
116
+ "trace.diagnostics"
117
+ ]);
118
+ var CAPABILITY_CONFORMANCE_CLAIMS = Object.freeze([
119
+ "claim.semantic-tree-authoritative",
120
+ "claim.stable-identity-authoritative",
121
+ "claim.intended-geometry-authoritative",
122
+ "claim.clipped-geometry-authoritative",
123
+ "claim.painted-region-authoritative",
124
+ "claim.pointer-region-authoritative",
125
+ "claim.pointer-hit-test-authoritative",
126
+ "claim.focus-authoritative",
127
+ "claim.scroll-authoritative",
128
+ "claim.render-order-authoritative",
129
+ "claim.action-strategy-authoritative",
130
+ "claim.keyboard-real-pty",
131
+ "claim.pointer-real-pty",
132
+ "claim.focus-report-real-pty",
133
+ "claim.paired-revisions",
134
+ "claim.logs-diagnostic"
135
+ ]);
136
+ var CONDITION_KINDS = Object.freeze([
137
+ "attached",
138
+ "detached",
139
+ "displayed",
140
+ "hidden",
141
+ "visible",
142
+ "in-viewport",
143
+ "offscreen",
144
+ "receives-pointer",
145
+ "pointer-region",
146
+ "pointer-input",
147
+ "mouse-input-enabled",
148
+ "enabled",
149
+ "disabled",
150
+ "focused",
151
+ "checked",
152
+ "selected",
153
+ "expanded",
154
+ "collapsed",
155
+ "value",
156
+ "not",
157
+ "all",
158
+ "any"
159
+ ]);
160
+ var certified = (message) => Object.freeze({
161
+ code: "select-certified-adapter",
162
+ message
163
+ });
164
+ var provider = (providerType, message) => Object.freeze({
165
+ code: "register-application-provider",
166
+ providerType,
167
+ message
168
+ });
169
+ var runtime = (runtimePrerequisite, message) => Object.freeze({
170
+ code: "enable-terminal-runtime",
171
+ runtimePrerequisite,
172
+ message
173
+ });
174
+ var settle = () => Object.freeze({
175
+ code: "wait-for-committed-observation",
176
+ message: "Wait for one paired committed observation before using this capability."
177
+ });
178
+ var producerNodes = [
179
+ ...ADAPTER_CAPABILITIES.map((id) => ({
180
+ id: `adapter.${id}`,
181
+ category: id === "render-revisions" ? "synchronization" : id === "logs" ? "diagnostic" : "evidence",
182
+ layer: "producer",
183
+ description: `Certified adapter handshake fact: ${id}.`,
184
+ remediation: certified(`Use an exact certified adapter which publishes ${id}.`)
185
+ })),
186
+ ...PROBE_CAPABILITIES.map((id) => ({
187
+ id: `probe.${id}`,
188
+ category: id === "frame-begin" ? "synchronization" : id === "operations" || id === "annotations" ? "diagnostic" : "evidence",
189
+ layer: "producer",
190
+ description: `Framework probe fact: ${id}.`,
191
+ remediation: certified(`Use exact certified instrumentation which publishes ${id}.`)
192
+ })),
193
+ ...EVIDENCE_PROVIDER_CAPABILITIES.map((id) => ({
194
+ id: `provider.${id}`,
195
+ category: "evidence",
196
+ layer: "producer",
197
+ description: `Authoritative application production-router fact: ${id}.`,
198
+ remediation: provider(
199
+ id === "action-recipes" ? "action-strategy" : id === "focus-state" ? "focus-evidence" : id === "scroll-state" ? "scroll-evidence" : id === "painted-regions" ? "paint-evidence" : id === "terminal-input-modes" ? "input-mode-evidence" : "pointer-evidence",
200
+ id === "action-recipes" ? "Register an action-strategy provider backed by the application's production keybindings." : id === "focus-state" ? "Register a focus-evidence provider backed by the application's production focus manager." : id === "scroll-state" ? "Register a scroll-evidence provider backed by the application's production viewport model." : id === "painted-regions" ? "Register a paint-evidence provider backed by the application's production painter." : id === "terminal-input-modes" ? "Register an input-mode-evidence provider backed by the application's production terminal parser configuration." : `Register a pointer-evidence provider backed by the application's production router (${id}).`
201
+ )
202
+ })),
203
+ {
204
+ id: "terminal.writable-pty",
205
+ category: "input",
206
+ layer: "producer",
207
+ description: "The native session owns a writable PTY input channel.",
208
+ remediation: runtime("writable-pty", "Launch the application in a writable real PTY.")
209
+ },
210
+ {
211
+ id: "terminal.input-modes-observable",
212
+ category: "input",
213
+ layer: "producer",
214
+ description: "The terminal backend authoritatively observes application mouse modes.",
215
+ remediation: runtime(
216
+ "terminal-input-modes-authoritative",
217
+ "Use a terminal backend that authoritatively observes terminal input modes."
218
+ )
219
+ }
220
+ ];
221
+ var sessionNode = (id, category, claim, remediation) => ({
222
+ id: `session.${id}`,
223
+ category,
224
+ layer: "session",
225
+ description: `Frozen session capability: ${id}.`,
226
+ conformanceClaims: [claim],
227
+ remediation
228
+ });
229
+ var sessionNodes = [
230
+ sessionNode(
231
+ "semantic-tree",
232
+ "evidence",
233
+ "claim.semantic-tree-authoritative",
234
+ certified("Use a certified semantic adapter.")
235
+ ),
236
+ sessionNode(
237
+ "stable-identity",
238
+ "evidence",
239
+ "claim.stable-identity-authoritative",
240
+ certified("Use a certified retained-identity adapter or explicit SemanticKey contract.")
241
+ ),
242
+ sessionNode(
243
+ "intended-geometry",
244
+ "evidence",
245
+ "claim.intended-geometry-authoritative",
246
+ certified("Use an adapter instrumented at the authoritative layout/render boundary.")
247
+ ),
248
+ sessionNode(
249
+ "clipped-geometry",
250
+ "evidence",
251
+ "claim.clipped-geometry-authoritative",
252
+ certified("Use an adapter that publishes authoritative clipping.")
253
+ ),
254
+ sessionNode(
255
+ "painted-region",
256
+ "evidence",
257
+ "claim.painted-region-authoritative",
258
+ provider(
259
+ "paint-evidence",
260
+ "Register a paint-evidence provider backed by the application's production painter."
261
+ )
262
+ ),
263
+ sessionNode(
264
+ "pointer-geometry",
265
+ "evidence",
266
+ "claim.pointer-region-authoritative",
267
+ provider(
268
+ "pointer-evidence",
269
+ "Register the application production pointer router as a pointer-evidence provider."
270
+ )
271
+ ),
272
+ sessionNode(
273
+ "pointer-hit-testing",
274
+ "evidence",
275
+ "claim.pointer-hit-test-authoritative",
276
+ provider(
277
+ "pointer-evidence",
278
+ "Register a pointer-evidence provider with authoritative hit testing."
279
+ )
280
+ ),
281
+ sessionNode(
282
+ "focus",
283
+ "evidence",
284
+ "claim.focus-authoritative",
285
+ provider(
286
+ "focus-evidence",
287
+ "Use a certified adapter with focus-state or register the application's production focus manager."
288
+ )
289
+ ),
290
+ sessionNode(
291
+ "scroll",
292
+ "evidence",
293
+ "claim.scroll-authoritative",
294
+ provider(
295
+ "scroll-evidence",
296
+ "Use a certified adapter with explicit scroll evidence or register the application's production viewport model."
297
+ )
298
+ ),
299
+ sessionNode(
300
+ "render-order",
301
+ "evidence",
302
+ "claim.render-order-authoritative",
303
+ certified(
304
+ "Use a certified adapter which guarantees render order for every applicable semantic node."
305
+ )
306
+ ),
307
+ sessionNode(
308
+ "action-strategies",
309
+ "planning",
310
+ "claim.action-strategy-authoritative",
311
+ provider(
312
+ "action-strategy",
313
+ "Register the application's production keybindings as authoritative physical input recipes."
314
+ )
315
+ ),
316
+ sessionNode(
317
+ "keyboard-input",
318
+ "input",
319
+ "claim.keyboard-real-pty",
320
+ runtime("writable-pty", "Launch in a writable real PTY.")
321
+ ),
322
+ sessionNode(
323
+ "pointer-input",
324
+ "input",
325
+ "claim.pointer-real-pty",
326
+ provider(
327
+ "input-mode-evidence",
328
+ "Use a backend that observes terminal modes or register the application's authoritative production parser configuration."
329
+ )
330
+ ),
331
+ sessionNode(
332
+ "focus-input",
333
+ "input",
334
+ "claim.focus-report-real-pty",
335
+ provider(
336
+ "input-mode-evidence",
337
+ "Use a backend that observes terminal modes or register the application's authoritative production parser configuration."
338
+ )
339
+ ),
340
+ sessionNode(
341
+ "paired-revisions",
342
+ "synchronization",
343
+ "claim.paired-revisions",
344
+ certified("Use an adapter with exact render revision markers.")
345
+ )
346
+ ];
347
+ var runtimeNodes = [
348
+ {
349
+ id: "runtime.writable-pty",
350
+ category: "input",
351
+ layer: "runtime",
352
+ description: "PTY input remains writable.",
353
+ remediation: runtime("writable-pty", "Launch or retain a writable PTY.")
354
+ },
355
+ {
356
+ id: "runtime.terminal-input-modes-authoritative",
357
+ category: "input",
358
+ layer: "runtime",
359
+ description: "Terminal mouse mode state is authoritative, either observed from VT output or supplied by the application's production parser.",
360
+ remediation: runtime(
361
+ "terminal-input-modes-authoritative",
362
+ "Use a backend with authoritative terminal mouse mode tracking or register input-mode evidence."
363
+ )
364
+ },
365
+ {
366
+ id: "runtime.mouse-reporting-enabled",
367
+ category: "input",
368
+ layer: "runtime",
369
+ description: "The application currently enables compatible mouse reporting.",
370
+ remediation: runtime(
371
+ "mouse-reporting-enabled",
372
+ "Enable terminal mouse reporting in the application."
373
+ )
374
+ },
375
+ {
376
+ id: "runtime.mouse-motion-enabled",
377
+ category: "input",
378
+ layer: "runtime",
379
+ description: "The application currently requests unpressed pointer motion.",
380
+ remediation: runtime(
381
+ "mouse-motion-enabled",
382
+ "Enable terminal any-event mouse motion reporting for hover."
383
+ )
384
+ },
385
+ {
386
+ id: "runtime.focus-reporting-enabled",
387
+ category: "input",
388
+ layer: "runtime",
389
+ description: "The application currently enables terminal focus reports.",
390
+ remediation: runtime(
391
+ "focus-reporting-enabled",
392
+ "Enable terminal focus reporting in the application."
393
+ )
394
+ },
395
+ {
396
+ id: "runtime.committed-observation",
397
+ category: "synchronization",
398
+ layer: "runtime",
399
+ description: "Semantic and VT evidence share one committed checkpoint.",
400
+ remediation: settle()
401
+ }
402
+ ];
403
+ var publicNode = (consumer, category, conditions = [], conformanceClaims) => ({
404
+ id: `public.${consumer}`,
405
+ category,
406
+ layer: "public",
407
+ publicConsumer: consumer,
408
+ description: `Public consumer ${consumer}.`,
409
+ conditions,
410
+ conformanceClaims,
411
+ remediation: settle()
412
+ });
413
+ var strategyNodes = [
414
+ {
415
+ id: "strategy.pointer-target",
416
+ category: "planning",
417
+ layer: "strategy",
418
+ description: "Resolve an authoritative safe physical pointer target.",
419
+ remediation: provider(
420
+ "pointer-evidence",
421
+ "Provide authoritative pointer regions, optionally with hit testing."
422
+ )
423
+ },
424
+ {
425
+ id: "strategy.keyboard-activate",
426
+ category: "planning",
427
+ layer: "strategy",
428
+ description: "Activate through a framework-declared keyboard convention and real PTY input.",
429
+ remediation: certified("Expose an authoritative semantic keyboard action convention.")
430
+ },
431
+ {
432
+ id: "strategy.pointer-activate",
433
+ category: "planning",
434
+ layer: "strategy",
435
+ description: "Activate through a planned real pointer click.",
436
+ remediation: provider("pointer-evidence", "Provide authoritative pointer evidence.")
437
+ },
438
+ {
439
+ id: "strategy.focus-by-pointer",
440
+ category: "planning",
441
+ layer: "strategy",
442
+ description: "Focus using a real planned pointer action.",
443
+ remediation: provider(
444
+ "pointer-evidence",
445
+ "Provide authoritative pointer evidence for the focus target."
446
+ )
447
+ },
448
+ {
449
+ id: "strategy.type-focused",
450
+ category: "planning",
451
+ layer: "strategy",
452
+ description: "Type only after authoritative element focus is known.",
453
+ remediation: certified("Use an adapter that guarantees focus state.")
454
+ }
455
+ ];
456
+ var publicNodes = [
457
+ publicNode("locator.semantic-query", "evidence", [], ["claim.semantic-tree-authoritative"]),
458
+ publicNode(
459
+ "locator.semantic-scroll",
460
+ "evidence",
461
+ [],
462
+ ["claim.scroll-authoritative", "claim.paired-revisions"]
463
+ ),
464
+ publicNode(
465
+ "locator.painted-region",
466
+ "evidence",
467
+ [],
468
+ ["claim.painted-region-authoritative", "claim.paired-revisions"]
469
+ ),
470
+ publicNode(
471
+ "condition.attached",
472
+ "evidence",
473
+ ["attached", "detached"],
474
+ ["claim.semantic-tree-authoritative"]
475
+ ),
476
+ publicNode(
477
+ "condition.displayed",
478
+ "evidence",
479
+ ["displayed", "hidden"],
480
+ ["claim.semantic-tree-authoritative"]
481
+ ),
482
+ publicNode(
483
+ "condition.visible",
484
+ "evidence",
485
+ ["visible"],
486
+ ["claim.clipped-geometry-authoritative"]
487
+ ),
488
+ publicNode(
489
+ "condition.in-viewport",
490
+ "evidence",
491
+ ["in-viewport", "offscreen"],
492
+ ["claim.clipped-geometry-authoritative"]
493
+ ),
494
+ publicNode("condition.focused", "evidence", ["focused"], ["claim.focus-authoritative"]),
495
+ publicNode("condition.value", "evidence", ["value"], ["claim.semantic-tree-authoritative"]),
496
+ publicNode(
497
+ "action.click",
498
+ "planning",
499
+ ["attached", "enabled", "visible", "pointer-region", "receives-pointer", "mouse-input-enabled"],
500
+ ["claim.pointer-region-authoritative", "claim.pointer-real-pty", "claim.paired-revisions"]
501
+ ),
502
+ publicNode(
503
+ "action.hover",
504
+ "planning",
505
+ ["attached", "visible", "pointer-region", "receives-pointer", "mouse-input-enabled"],
506
+ ["claim.pointer-region-authoritative", "claim.pointer-real-pty"]
507
+ ),
508
+ publicNode(
509
+ "action.drag",
510
+ "planning",
511
+ ["attached", "enabled", "visible", "pointer-region", "receives-pointer", "mouse-input-enabled"],
512
+ ["claim.pointer-region-authoritative", "claim.pointer-real-pty"]
513
+ ),
514
+ publicNode(
515
+ "action.focus",
516
+ "planning",
517
+ ["attached", "enabled", "displayed"],
518
+ ["claim.keyboard-real-pty", "claim.pointer-real-pty"]
519
+ ),
520
+ publicNode(
521
+ "action.activate",
522
+ "planning",
523
+ ["attached", "enabled", "displayed"],
524
+ ["claim.keyboard-real-pty", "claim.pointer-real-pty"]
525
+ ),
526
+ publicNode(
527
+ "action.type",
528
+ "planning",
529
+ ["attached", "enabled", "displayed", "focused"],
530
+ ["claim.focus-authoritative", "claim.keyboard-real-pty"]
531
+ ),
532
+ publicNode(
533
+ "action.fill",
534
+ "planning",
535
+ ["attached", "enabled", "displayed"],
536
+ ["claim.focus-authoritative", "claim.keyboard-real-pty"]
537
+ ),
538
+ publicNode(
539
+ "action.check",
540
+ "planning",
541
+ ["attached", "enabled", "displayed", "checked"],
542
+ ["claim.keyboard-real-pty", "claim.pointer-real-pty"]
543
+ ),
544
+ publicNode(
545
+ "action.uncheck",
546
+ "planning",
547
+ ["attached", "enabled", "displayed", "checked"],
548
+ ["claim.keyboard-real-pty", "claim.pointer-real-pty"]
549
+ ),
550
+ publicNode("device.keyboard", "input", [], ["claim.keyboard-real-pty"]),
551
+ publicNode("device.mouse", "input", [], ["claim.pointer-real-pty"]),
552
+ publicNode("device.window-focus", "input", [], ["claim.focus-report-real-pty"]),
553
+ publicNode("checkpoint", "synchronization", [], ["claim.paired-revisions"]),
554
+ publicNode("runner.inspector", "diagnostic", [], ["claim.semantic-tree-authoritative"]),
555
+ publicNode(
556
+ "trace.action",
557
+ "diagnostic",
558
+ [],
559
+ ["claim.pointer-real-pty", "claim.keyboard-real-pty"]
560
+ ),
561
+ publicNode("recorder.semantic-action", "planning", [], ["claim.pointer-hit-test-authoritative"]),
562
+ publicNode(
563
+ "mcp.semantic-action",
564
+ "planning",
565
+ [],
566
+ ["claim.pointer-real-pty", "claim.keyboard-real-pty"]
567
+ ),
568
+ publicNode("runner.diagnostics", "diagnostic", [], ["claim.semantic-tree-authoritative"]),
569
+ publicNode("trace.diagnostics", "diagnostic", [], ["claim.logs-diagnostic"])
570
+ ];
571
+ var diagnosticNodes = [
572
+ {
573
+ id: "diagnostic.semantic-tree",
574
+ category: "diagnostic",
575
+ layer: "session",
576
+ description: "Best-effort semantic tree for inspector diagnostics only.",
577
+ conformanceClaims: ["claim.semantic-tree-authoritative"],
578
+ remediation: certified("Use certified semantic evidence for public queries.")
579
+ },
580
+ {
581
+ id: "diagnostic.geometry",
582
+ category: "diagnostic",
583
+ layer: "session",
584
+ description: "Best-effort geometry that cannot unlock actions.",
585
+ conformanceClaims: ["claim.intended-geometry-authoritative"],
586
+ remediation: certified("Use certified geometry evidence for action planning.")
587
+ },
588
+ {
589
+ id: "diagnostic.render-order",
590
+ category: "diagnostic",
591
+ layer: "session",
592
+ description: "Best-effort paint order that cannot prove actionability.",
593
+ conformanceClaims: ["claim.render-order-authoritative"],
594
+ remediation: certified("Use a universally certified render-order producer.")
595
+ },
596
+ {
597
+ id: "diagnostic.logs",
598
+ category: "diagnostic",
599
+ layer: "session",
600
+ description: "Structured application logs.",
601
+ conformanceClaims: ["claim.logs-diagnostic"],
602
+ remediation: certified("Use an adapter that negotiates structured logs.")
603
+ }
604
+ ];
605
+ var edges = [
606
+ { from: "adapter.tree", to: "session.semantic-tree", kind: "produces" },
607
+ {
608
+ from: "probe.stable-identity",
609
+ to: "session.stable-identity",
610
+ kind: "produces"
611
+ },
612
+ {
613
+ from: "adapter.intended-geometry",
614
+ to: "session.intended-geometry",
615
+ kind: "produces"
616
+ },
617
+ {
618
+ from: "adapter.clipped-geometry",
619
+ to: "session.clipped-geometry",
620
+ kind: "produces"
621
+ },
622
+ { from: "adapter.focus-state", to: "session.focus", kind: "produces" },
623
+ { from: "provider.focus-state", to: "session.focus", kind: "produces" },
624
+ { from: "provider.scroll-state", to: "session.scroll", kind: "produces" },
625
+ {
626
+ from: "provider.painted-regions",
627
+ to: "session.painted-region",
628
+ kind: "produces"
629
+ },
630
+ {
631
+ from: "adapter.action-recipes",
632
+ to: "session.action-strategies",
633
+ kind: "produces"
634
+ },
635
+ {
636
+ from: "adapter.pointer-hit-grid",
637
+ to: "session.pointer-geometry",
638
+ kind: "produces"
639
+ },
640
+ {
641
+ from: "adapter.pointer-hit-grid",
642
+ to: "session.pointer-hit-testing",
643
+ kind: "produces"
644
+ },
645
+ {
646
+ from: "provider.pointer-regions",
647
+ to: "session.pointer-geometry",
648
+ kind: "produces"
649
+ },
650
+ {
651
+ from: "provider.hit-test",
652
+ to: "session.pointer-hit-testing",
653
+ kind: "produces"
654
+ },
655
+ {
656
+ from: "provider.action-recipes",
657
+ to: "session.action-strategies",
658
+ kind: "produces"
659
+ },
660
+ { from: "probe.paint-order", to: "session.render-order", kind: "produces" },
661
+ {
662
+ from: "probe.paint-order",
663
+ to: "diagnostic.render-order",
664
+ kind: "diagnoses"
665
+ },
666
+ { from: "adapter.logs", to: "diagnostic.logs", kind: "diagnoses" },
667
+ {
668
+ from: "terminal.writable-pty",
669
+ to: "session.keyboard-input",
670
+ kind: "produces"
671
+ },
672
+ {
673
+ from: "terminal.input-modes-observable",
674
+ to: "session.pointer-input",
675
+ kind: "produces"
676
+ },
677
+ {
678
+ from: "provider.terminal-input-modes",
679
+ to: "session.pointer-input",
680
+ kind: "produces"
681
+ },
682
+ {
683
+ from: "terminal.input-modes-observable",
684
+ to: "session.focus-input",
685
+ kind: "produces"
686
+ },
687
+ {
688
+ from: "provider.terminal-input-modes",
689
+ to: "session.focus-input",
690
+ kind: "produces"
691
+ },
692
+ {
693
+ from: "adapter.render-revisions",
694
+ to: "session.paired-revisions",
695
+ kind: "produces"
696
+ },
697
+ {
698
+ from: "terminal.writable-pty",
699
+ to: "runtime.writable-pty",
700
+ kind: "produces"
701
+ },
702
+ {
703
+ from: "terminal.input-modes-observable",
704
+ to: "runtime.terminal-input-modes-authoritative",
705
+ kind: "produces"
706
+ },
707
+ {
708
+ from: "provider.terminal-input-modes",
709
+ to: "runtime.terminal-input-modes-authoritative",
710
+ kind: "produces"
711
+ },
712
+ {
713
+ from: "session.pointer-geometry",
714
+ to: "strategy.pointer-target",
715
+ kind: "requires"
716
+ },
717
+ {
718
+ from: "runtime.committed-observation",
719
+ to: "strategy.pointer-target",
720
+ kind: "runtime-requires"
721
+ },
722
+ {
723
+ from: "strategy.pointer-target",
724
+ to: "strategy.pointer-activate",
725
+ kind: "requires"
726
+ },
727
+ {
728
+ from: "session.pointer-input",
729
+ to: "strategy.pointer-activate",
730
+ kind: "requires"
731
+ },
732
+ {
733
+ from: "runtime.terminal-input-modes-authoritative",
734
+ to: "strategy.pointer-activate",
735
+ kind: "runtime-requires"
736
+ },
737
+ {
738
+ from: "runtime.mouse-reporting-enabled",
739
+ to: "strategy.pointer-activate",
740
+ kind: "runtime-requires"
741
+ },
742
+ {
743
+ from: "session.keyboard-input",
744
+ to: "strategy.keyboard-activate",
745
+ kind: "requires"
746
+ },
747
+ {
748
+ from: "runtime.writable-pty",
749
+ to: "strategy.keyboard-activate",
750
+ kind: "runtime-requires"
751
+ },
752
+ {
753
+ from: "strategy.pointer-activate",
754
+ to: "strategy.focus-by-pointer",
755
+ kind: "requires"
756
+ },
757
+ { from: "session.focus", to: "strategy.type-focused", kind: "requires" },
758
+ {
759
+ from: "session.keyboard-input",
760
+ to: "strategy.type-focused",
761
+ kind: "requires"
762
+ },
763
+ {
764
+ from: "session.semantic-tree",
765
+ to: "public.locator.semantic-query",
766
+ kind: "requires"
767
+ },
768
+ {
769
+ from: "session.scroll",
770
+ to: "public.locator.semantic-scroll",
771
+ kind: "requires"
772
+ },
773
+ {
774
+ from: "runtime.committed-observation",
775
+ to: "public.locator.semantic-scroll",
776
+ kind: "runtime-requires"
777
+ },
778
+ {
779
+ from: "session.painted-region",
780
+ to: "public.locator.painted-region",
781
+ kind: "requires"
782
+ },
783
+ {
784
+ from: "runtime.committed-observation",
785
+ to: "public.locator.painted-region",
786
+ kind: "runtime-requires"
787
+ },
788
+ {
789
+ from: "session.semantic-tree",
790
+ to: "public.condition.attached",
791
+ kind: "requires"
792
+ },
793
+ {
794
+ from: "session.semantic-tree",
795
+ to: "public.condition.displayed",
796
+ kind: "requires"
797
+ },
798
+ {
799
+ from: "session.clipped-geometry",
800
+ to: "public.condition.visible",
801
+ kind: "requires"
802
+ },
803
+ {
804
+ from: "session.clipped-geometry",
805
+ to: "public.condition.in-viewport",
806
+ kind: "requires"
807
+ },
808
+ { from: "session.focus", to: "public.condition.focused", kind: "requires" },
809
+ {
810
+ from: "session.semantic-tree",
811
+ to: "public.condition.value",
812
+ kind: "requires"
813
+ },
814
+ {
815
+ from: "strategy.pointer-activate",
816
+ to: "public.action.click",
817
+ kind: "requires"
818
+ },
819
+ {
820
+ from: "strategy.pointer-target",
821
+ to: "public.action.hover",
822
+ kind: "requires"
823
+ },
824
+ {
825
+ from: "session.pointer-input",
826
+ to: "public.action.hover",
827
+ kind: "requires"
828
+ },
829
+ {
830
+ from: "runtime.terminal-input-modes-authoritative",
831
+ to: "public.action.hover",
832
+ kind: "runtime-requires"
833
+ },
834
+ {
835
+ from: "runtime.mouse-motion-enabled",
836
+ to: "public.action.hover",
837
+ kind: "runtime-requires"
838
+ },
839
+ {
840
+ from: "strategy.pointer-activate",
841
+ to: "public.action.drag",
842
+ kind: "requires"
843
+ },
844
+ {
845
+ from: "strategy.focus-by-pointer",
846
+ to: "public.action.focus",
847
+ kind: "requires-any"
848
+ },
849
+ {
850
+ from: "strategy.keyboard-activate",
851
+ to: "public.action.focus",
852
+ kind: "requires-any"
853
+ },
854
+ {
855
+ from: "strategy.pointer-activate",
856
+ to: "public.action.activate",
857
+ kind: "requires-any"
858
+ },
859
+ {
860
+ from: "strategy.keyboard-activate",
861
+ to: "public.action.activate",
862
+ kind: "requires-any"
863
+ },
864
+ { from: "strategy.type-focused", to: "public.action.type", kind: "requires" },
865
+ { from: "public.action.focus", to: "public.action.fill", kind: "requires" },
866
+ {
867
+ from: "session.keyboard-input",
868
+ to: "public.action.fill",
869
+ kind: "requires"
870
+ },
871
+ {
872
+ from: "public.action.activate",
873
+ to: "public.action.check",
874
+ kind: "requires"
875
+ },
876
+ {
877
+ from: "public.action.activate",
878
+ to: "public.action.uncheck",
879
+ kind: "requires"
880
+ },
881
+ {
882
+ from: "session.keyboard-input",
883
+ to: "public.device.keyboard",
884
+ kind: "requires"
885
+ },
886
+ {
887
+ from: "session.pointer-input",
888
+ to: "public.device.mouse",
889
+ kind: "requires"
890
+ },
891
+ {
892
+ from: "runtime.terminal-input-modes-authoritative",
893
+ to: "public.device.mouse",
894
+ kind: "runtime-requires"
895
+ },
896
+ {
897
+ from: "runtime.mouse-reporting-enabled",
898
+ to: "public.device.mouse",
899
+ kind: "runtime-requires"
900
+ },
901
+ {
902
+ from: "session.focus-input",
903
+ to: "public.device.window-focus",
904
+ kind: "requires"
905
+ },
906
+ {
907
+ from: "runtime.focus-reporting-enabled",
908
+ to: "public.device.window-focus",
909
+ kind: "runtime-requires"
910
+ },
911
+ {
912
+ from: "runtime.terminal-input-modes-authoritative",
913
+ to: "public.device.window-focus",
914
+ kind: "runtime-requires"
915
+ },
916
+ {
917
+ from: "session.paired-revisions",
918
+ to: "public.checkpoint",
919
+ kind: "requires"
920
+ },
921
+ {
922
+ from: "public.action.click",
923
+ to: "public.recorder.semantic-action",
924
+ kind: "requires"
925
+ },
926
+ {
927
+ from: "public.action.click",
928
+ to: "public.mcp.semantic-action",
929
+ kind: "requires"
930
+ },
931
+ {
932
+ from: "diagnostic.semantic-tree",
933
+ to: "public.runner.diagnostics",
934
+ kind: "diagnoses"
935
+ },
936
+ {
937
+ from: "diagnostic.geometry",
938
+ to: "public.runner.diagnostics",
939
+ kind: "diagnoses"
940
+ },
941
+ {
942
+ from: "diagnostic.logs",
943
+ to: "public.trace.diagnostics",
944
+ kind: "diagnoses"
945
+ },
946
+ {
947
+ from: "public.action.click",
948
+ to: "public.runner.inspector",
949
+ kind: "diagnoses"
950
+ },
951
+ { from: "public.action.click", to: "public.trace.action", kind: "diagnoses" }
952
+ ];
953
+ var CAPABILITY_GRAPH = deepFreeze({
954
+ version: CAPABILITY_GRAPH_VERSION,
955
+ nodes: [
956
+ ...producerNodes,
957
+ ...sessionNodes,
958
+ ...runtimeNodes,
959
+ ...strategyNodes,
960
+ ...publicNodes,
961
+ ...diagnosticNodes
962
+ ],
963
+ edges
964
+ });
965
+ function validateCapabilityGraph() {
966
+ const errors = [];
967
+ const nodes = /* @__PURE__ */ new Map();
968
+ for (const node of CAPABILITY_GRAPH.nodes) {
969
+ if (nodes.has(node.id)) errors.push(`duplicate capability node ${node.id}`);
970
+ nodes.set(node.id, node);
971
+ if (!CAPABILITY_NODE_CATEGORIES.includes(node.category))
972
+ errors.push(`invalid category on ${node.id}`);
973
+ if (!CAPABILITY_NODE_LAYERS.includes(node.layer)) errors.push(`invalid layer on ${node.id}`);
974
+ for (const claim of node.conformanceClaims ?? []) {
975
+ if (!CAPABILITY_CONFORMANCE_CLAIMS.includes(claim))
976
+ errors.push(`unknown claim ${claim} on ${node.id}`);
977
+ }
978
+ for (const condition of node.conditions ?? []) {
979
+ if (!CONDITION_KINDS.includes(condition))
980
+ errors.push(`unknown condition ${condition} on ${node.id}`);
981
+ }
982
+ }
983
+ const edgeKeys = /* @__PURE__ */ new Set();
984
+ for (const edge of CAPABILITY_GRAPH.edges) {
985
+ if (!nodes.has(edge.from)) errors.push(`edge source ${edge.from} is orphaned`);
986
+ if (!nodes.has(edge.to)) errors.push(`edge target ${edge.to} is orphaned`);
987
+ const key = `${edge.kind}:${edge.from}->${edge.to}`;
988
+ if (edgeKeys.has(key)) errors.push(`duplicate edge ${key}`);
989
+ edgeKeys.add(key);
990
+ }
991
+ for (const node of CAPABILITY_GRAPH.nodes) {
992
+ if ((node.layer === "session" || node.layer === "public") && (node.conformanceClaims?.length ?? 0) === 0) {
993
+ errors.push(`contract/public node ${node.id} has no mandatory conformance claim`);
994
+ }
995
+ if (node.remediation.code === "register-application-provider") {
996
+ const reachable = CAPABILITY_GRAPH.edges.some(
997
+ (edge) => edge.to === node.id && edge.from.startsWith("provider.") && edge.kind === "produces"
998
+ );
999
+ if (!reachable && node.layer === "session")
1000
+ errors.push(`impossible provider remediation on ${node.id}`);
1001
+ }
1002
+ if (node.remediation.code === "enable-terminal-runtime" && node.remediation.runtimePrerequisite === void 0) {
1003
+ errors.push(`runtime remediation on ${node.id} has no prerequisite id`);
1004
+ }
1005
+ }
1006
+ const usedClaims = new Set(
1007
+ CAPABILITY_GRAPH.nodes.flatMap((node) => node.conformanceClaims ?? [])
1008
+ );
1009
+ for (const claim of CAPABILITY_CONFORMANCE_CLAIMS) {
1010
+ if (!usedClaims.has(claim)) errors.push(`orphan conformance claim ${claim}`);
1011
+ }
1012
+ return Object.freeze({
1013
+ ok: errors.length === 0,
1014
+ errors: Object.freeze(errors)
1015
+ });
1016
+ }
1017
+ function capabilityNode(id) {
1018
+ const node = CAPABILITY_GRAPH.nodes.find((candidate) => candidate.id === id);
1019
+ if (node === void 0) throw new RangeError(`unknown capability graph node ${id}`);
1020
+ return node;
1021
+ }
1022
+ function capabilityRemediation(id) {
1023
+ return capabilityNode(id).remediation;
1024
+ }
1025
+ function sessionCapabilitiesFromProducers(producers) {
1026
+ const resolved = /* @__PURE__ */ new Map();
1027
+ for (const edge of CAPABILITY_GRAPH.edges) {
1028
+ if (edge.kind !== "produces" || !edge.to.startsWith("session.") || !producers.has(edge.from))
1029
+ continue;
1030
+ const capability = edge.to.slice("session.".length);
1031
+ const current = resolved.get(capability) ?? [];
1032
+ current.push(edge.from);
1033
+ resolved.set(capability, current);
1034
+ }
1035
+ return new Map(
1036
+ [...resolved].map(([capability, sources]) => [
1037
+ capability,
1038
+ Object.freeze([...new Set(sources)].sort())
1039
+ ])
1040
+ );
1041
+ }
1042
+ function resolveCapability(target, available) {
1043
+ const visiting = /* @__PURE__ */ new Set();
1044
+ const resolve = (id) => {
1045
+ if (available.has(id)) return [];
1046
+ const node = capabilityNode(id);
1047
+ if (node.layer === "producer" || node.layer === "session" || node.layer === "runtime")
1048
+ return [id];
1049
+ if (visiting.has(id)) throw new Error(`capability graph dependency cycle at ${id}`);
1050
+ visiting.add(id);
1051
+ const incoming = CAPABILITY_GRAPH.edges.filter(
1052
+ (edge) => edge.to === id && (edge.kind === "requires" || edge.kind === "requires-any" || edge.kind === "runtime-requires")
1053
+ );
1054
+ const mandatory = incoming.filter(({ kind }) => kind !== "requires-any").flatMap(({ from }) => resolve(from));
1055
+ const alternatives = incoming.filter(({ kind }) => kind === "requires-any").map(({ from }) => resolve(from));
1056
+ const bestAlternative = alternatives.length === 0 ? [] : alternatives.reduce(
1057
+ (best, candidate) => candidate.length < best.length ? candidate : best
1058
+ );
1059
+ visiting.delete(id);
1060
+ return unique([...mandatory, ...bestAlternative]);
1061
+ };
1062
+ const missing = resolve(target);
1063
+ const remediation = uniqueBy(
1064
+ missing.map((id) => capabilityRemediation(id)),
1065
+ (item) => `${item.code}:${item.providerType ?? ""}:${item.runtimePrerequisite ?? ""}:${item.message}`
1066
+ );
1067
+ return Object.freeze({
1068
+ available: missing.length === 0,
1069
+ target,
1070
+ missing: Object.freeze(missing),
1071
+ remediation: Object.freeze(remediation)
1072
+ });
1073
+ }
1074
+ function unique(values) {
1075
+ return [...new Set(values)];
1076
+ }
1077
+ function uniqueBy(values, key) {
1078
+ const found = /* @__PURE__ */ new Map();
1079
+ for (const value of values) found.set(key(value), value);
1080
+ return [...found.values()];
1081
+ }
1082
+ function deepFreeze(value) {
1083
+ if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
1084
+ for (const child of Object.values(value)) deepFreeze(child);
1085
+ return Object.freeze(value);
1086
+ }
1087
+
1088
+ export {
1089
+ CAPABILITY_GRAPH_VERSION,
1090
+ CAPABILITY_NODE_CATEGORIES,
1091
+ CAPABILITY_NODE_LAYERS,
1092
+ CAPABILITY_EDGE_KINDS,
1093
+ ADAPTER_CAPABILITIES,
1094
+ PROBE_CAPABILITIES,
1095
+ EVIDENCE_PROVIDER_CAPABILITIES,
1096
+ EVIDENCE_PROVIDER_TYPES,
1097
+ SESSION_CAPABILITIES,
1098
+ RUNTIME_PREREQUISITES,
1099
+ PUBLIC_CAPABILITY_CONSUMERS,
1100
+ CAPABILITY_CONFORMANCE_CLAIMS,
1101
+ CONDITION_KINDS,
1102
+ CAPABILITY_GRAPH,
1103
+ validateCapabilityGraph,
1104
+ capabilityNode,
1105
+ capabilityRemediation,
1106
+ sessionCapabilitiesFromProducers,
1107
+ resolveCapability
1108
+ };
1109
+ //# sourceMappingURL=chunk-VBLS6E6U.js.map