@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
package/dist/index.d.ts CHANGED
@@ -1,16 +1,20 @@
1
+ import { S as SemanticNode, a as SemanticState, b as SemanticSnapshot, c as SemanticRole, R as Rect, P as ProbeAnnotations, d as ProbeFrame, e as ProbeInfo, E as EvidenceProviderRegistration } from './contract-CH9gmj2Y.js';
2
+ export { A as AuthoritativeObservationEvidence, C as CellPoint, f as ContractProvider, g as CoordinateSpace, h as CursorInfo, i as EffectiveSessionContract, j as EvidenceProvenance, L as LocatorGeometry, k as LocatorVisibility, N as NodeGeometryObservations, O as Observation, l as ObservationAbsentReason, m as ObservationEvidence, n as ObservationStamp, o as ObservationUnknownReason, p as ObservationUnsupportedReason, q as PHYSICAL_INPUT_RECIPE_ACTIONS, r as PROBE_DEGRADED_CAPABILITIES, s as PROBE_INJECTION_TIERS, t as PROBE_SEMANTIC_CLASSES, u as PROBE_UNOBSERVABLE_FIELDS, v as PROVENANCE_SOURCES, w as PhysicalInputRecipe, x as PhysicalInputRecipeAction, y as PhysicalInputRecipeStep, z as PointerHitGrid, B as PointerHitRegion, D as PointerHitTest, F as ProbeAccessibilityHints, G as ProbeDegradedCapabilityId, H as ProbeExtent, I as ProbeGeometry, J as ProbeIdentity, K as ProbeIdentityKind, M as ProbeInjectionTier, Q as ProbeInstrumentation, T as ProbeObject, U as ProbeObservedState, V as ProbeOperation, W as ProbeRect, X as ProbeScroll, Y as ProbeSemanticClass, Z as ProbeUnobservableField, _ as ProvenanceSource, $ as ProviderActionRecipes, a0 as ProviderFocusState, a1 as ProviderPaintedRegion, a2 as ProviderPointerRegion, a3 as ProviderRevisionEvidence, a4 as ProviderScrollState, a5 as ProviderTerminalInputModes, a6 as SEMANTIC_ACTIONS, a7 as SEMANTIC_ROLES, a8 as SemanticAction, a9 as SemanticExtendedArray, aa as SemanticExtendedObject, ab as SemanticExtendedState, ac as SemanticExtendedValue, ad as SemanticPaintedRegion, ae as SemanticScrollState, af as SemanticTextRange, ag as SemanticValueAbsentReason, ah as SemanticValueObservation, ai as SemanticValueWithheldReason, aj as SessionCapabilityAvailability, ak as SpatialRelation, al as ViewportIntersection, am as evidence, an as intersectRects, ao as rectArea, ap as spatialRelation, aq as viewportIntersection } from './contract-CH9gmj2Y.js';
3
+ import { AdapterCapability } from './capability-graph.js';
4
+ export { ADAPTER_CAPABILITIES, CAPABILITY_CONFORMANCE_CLAIMS, CAPABILITY_EDGE_KINDS, CAPABILITY_GRAPH, CAPABILITY_GRAPH_VERSION, CAPABILITY_NODE_CATEGORIES, CAPABILITY_NODE_LAYERS, CONDITION_KINDS, CapabilityConformanceClaimId, CapabilityEdgeKind, CapabilityGraphEdge, CapabilityGraphNode, CapabilityGraphValidationResult, CapabilityNodeCategory, CapabilityNodeId, CapabilityNodeLayer, CapabilityRemediation, CapabilityResolution, ConditionKind, EVIDENCE_PROVIDER_CAPABILITIES, EVIDENCE_PROVIDER_TYPES, EvidenceProviderCapability, EvidenceProviderType, PROBE_CAPABILITIES, PUBLIC_CAPABILITY_CONSUMERS, ProbeCapability, PublicCapabilityConsumer, RUNTIME_PREREQUISITES, RuntimePrerequisiteId, SESSION_CAPABILITIES, SessionCapabilityId, capabilityNode, capabilityRemediation, resolveCapability, sessionCapabilitiesFromProducers, validateCapabilityGraph } from './capability-graph.js';
5
+ export { A as ARTIFACT_VALUE_POLICIES, a as ActionIntent, b as ActionKind, c as ActionPlan, d as ActionReceipt, e as ActionabilityExplanation, f as ArtifactValuePolicy, C as Condition, g as ConditionResult, h as ConditionTextMatcher, D as DEFAULT_ARTIFACT_VALUE_POLICY, E as ExecutableActionPlan, i as ExecutableDeviceOperation, j as ExecutableValue, L as LocatorDomain, k as LocatorRef, P as PhysicalRegion, l as PublicValue, R as RecordedDeviceOperation, m as RecordedValue, S as ScreenCondition, n as ScreenLeafCondition, o as ScreenLocatorRef, p as SemanticLocatorRef, q as SensitiveValue, V as ValueSensitivity, r as executableText, s as projectActionReceiptForArtifact, t as projectSemanticSnapshotForArtifact, u as publicValue, v as recordActionPlan, w as recordDeviceOperation, x as recordValue, y as sensitive, z as valueSensitivity } from './action-model-BP9Znu6L.js';
6
+ export { ActionId, AttemptId, CreateRunEventInput, DEFAULT_RUN_EVENT_LIMITS, ExecutionId, InvocationId, ProduceRunEventInput, ProjectId, RUN_EVENT_CLASSES, RUN_EVENT_VERSION, RUN_ID_KINDS, RunEvent, RunEventClass, RunEventId, RunEventIdentity, RunEventJson, RunEventLimits, RunEventProducer, RunEventProducerId, RunEventStreamValidator, RunEventValidationResult, RunEventViolationCode, RunId, RunIdByKind, RunIdFactory, RunIdKind, RunnerTaskId, SessionId, ShardId, SpecId, StepId, createRunEvent, createRunId, parseRunId, validateRunEvent } from './run-events.js';
7
+ export { DEFAULT_RUN_EVENT_JOURNAL_LIMITS, RunEventFlushBarrier, RunEventJournal, RunEventJournalAppendResult, RunEventJournalLimits, RunEventJournalViolationCode } from './run-journal.js';
8
+ export { RUN_STATES, RUN_STATE_TRANSITIONS, RunState, RunStateTransitionResult, TERMINAL_RUN_STATES, TerminalRunState, canTransitionRunState, isRunState, isTerminalRunState, validateRunStateTransition } from './run-state.js';
1
9
  import { z } from 'zod';
2
10
 
3
11
  /** Environment variable names injected by the driver before spawning the child. */
4
12
  declare const ENV_ENDPOINT = "TERMWRIGHT_ENDPOINT";
5
13
  declare const ENV_TOKEN = "TERMWRIGHT_TOKEN";
6
- declare const ENV_PROTOCOL = "TERMWRIGHT_PROTOCOL";
7
- /** Current protocol major version. */
8
- declare const PROTOCOL_VERSION: 1;
9
- declare const PROTOCOL_ID: "termwright/1";
10
- /** Qualified observation protocol. V1 remains exported for existing adapters. */
11
- declare const PROTOCOL_V2_ID: "termwright/2";
12
- type ProtocolId = typeof PROTOCOL_ID | typeof PROTOCOL_V2_ID;
13
- declare const SUPPORTED_PROTOCOL_IDS: readonly ProtocolId[];
14
+ /** Current and only supported protocol major version. */
15
+ declare const PROTOCOL_VERSION: 2;
16
+ declare const PROTOCOL_ID: "termwright/2";
17
+ type ProtocolId = typeof PROTOCOL_ID;
14
18
  /** Entropy behind a session token, in bytes (256 bits). */
15
19
  declare const TOKEN_BYTES = 32;
16
20
  /**
@@ -78,16 +82,6 @@ declare class ProtocolViolation extends Error {
78
82
  constructor(code: ProtocolViolationCode, message: string);
79
83
  }
80
84
 
81
- /**
82
- * v1 semantic roles. ARIA-aligned; closed set. Unknown roles must be rejected
83
- * during validation — they never silently acquire behavior.
84
- */
85
- declare const SEMANTIC_ROLES: readonly ["application", "region", "dialog", "alert", "status", "list", "listitem", "menu", "menuitem", "button", "checkbox", "radio", "tab", "textbox", "heading", "text", "progressbar", "separator", "scrollbar", "table", "row", "cell", "generic"];
86
- type SemanticRole = (typeof SEMANTIC_ROLES)[number];
87
- /** Descriptive action capabilities. Diagnostic/strategy hints, never callback endpoints. */
88
- declare const SEMANTIC_ACTIONS: readonly ["focus", "activate", "toggle", "setValue", "scroll", "select", "expand"];
89
- type SemanticAction = (typeof SEMANTIC_ACTIONS)[number];
90
-
91
85
  /**
92
86
  * Conservative defaults and absolute maxima. Callers may tighten defaults but
93
87
  * can never widen the absolute maxima.
@@ -116,622 +110,8 @@ interface ProtocolLimits {
116
110
  }
117
111
  declare const DEFAULT_LIMITS: ProtocolLimits;
118
112
  declare const ABSOLUTE_LIMITS: ProtocolLimits;
119
- /** Default semantic negotiation window (ms) before a session settles as generic. */
120
- declare const DEFAULT_NEGOTIATION_MS = 250;
121
-
122
- /**
123
- * Probe IR — what an instrumented process **observed**, not what it means.
124
- *
125
- * A probe reports facts; a recognizer turns them into the semantic tree. The
126
- * split exists because the six frameworks disagree about what is even knowable,
127
- * and collapsing that disagreement early is how a tree ends up asserting things
128
- * no framework ever said.
129
- *
130
- * Three rules shape every type here, each forced by the Phase 0 audits:
131
- *
132
- * 1. **Never fabricate identity.** Immediate-mode frameworks have none, and a
133
- * synthesised ordinal presented as a handle is worse than no handle: a test
134
- * written against it fails later and looks flaky rather than wrong. Identity
135
- * is therefore a typed capability with `frame-local` as a first-class value.
136
- * 2. **Intent is not ownership.** The rectangle a widget was drawn *into* is not
137
- * the cells it ended up owning; later writes win and no framework records
138
- * who painted what. The two are separate fields, and only one framework
139
- * computes the second.
140
- * 3. **Absent and unobservable are different facts.** A state a framework does
141
- * not expose is not a state that is off. The IR says which is which, rather
142
- * than letting `undefined` mean both.
143
- *
144
- * Naming note: the words `region` and `area` are avoided throughout. Each
145
- * carries at least three conflicting meanings across the audited frameworks,
146
- * and an IR that reuses them inherits every one of those ambiguities.
147
- */
148
- /**
149
- * How an object's identity behaves across frames.
150
- *
151
- * `frame-local` is a legitimate answer, not a degraded one: in immediate mode
152
- * the widget is consumed by the render and nothing upstream survives to be
153
- * named again. A consumer must not correlate `frame-local` values between
154
- * frames.
155
- */
156
- type ProbeIdentityKind = 'stable' | 'frame-local';
157
- /** An object's identity, tagged with what it is worth. */
158
- interface ProbeIdentity {
159
- readonly kind: ProbeIdentityKind;
160
- /** Unique within its frame; unique across the session only when `stable`. */
161
- readonly value: string;
162
- }
163
- /**
164
- * A rectangle in terminal cells.
165
- *
166
- * Deliberately not called a region or an area: `row`/`column` are absolute
167
- * cell coordinates, and negative origins are legal because a widget may be
168
- * partly scrolled off.
169
- */
170
- interface ProbeRect {
171
- readonly row: number;
172
- readonly column: number;
173
- readonly width: number;
174
- readonly height: number;
175
- }
176
- /**
177
- * Where an object was drawn.
178
- *
179
- * `intendedRect` is where it *asked* to draw. It is a statement of intent, not
180
- * a claim on cells: frameworks do not clip it, do not validate it against the
181
- * viewport, and a later write silently wins. For overlapping UIs — popups,
182
- * modals, shadows — it is not where the object ended up.
183
- *
184
- * `visibleRect` is the intersection with the clip imposed by ancestors, which
185
- * is the closest any framework gets to "what the user can see". Only one of
186
- * the six computes it; everywhere else it is absent, and inferring it from
187
- * `intendedRect` would be inventing a fact.
188
- */
189
- interface ProbeGeometry {
190
- readonly intendedRect?: ProbeRect;
191
- readonly visibleRect?: ProbeRect;
192
- }
193
- /** Scroll position, in cells, of a scrollable object's viewport. */
194
- interface ProbeScroll {
195
- readonly row: number;
196
- readonly column: number;
197
- }
198
- /** Total scrollable extent, in cells. Absent where a framework cannot report it. */
199
- interface ProbeExtent {
200
- readonly rows: number;
201
- readonly columns: number;
202
- }
203
- /**
204
- * State a probe read directly from the framework.
205
- *
206
- * Every field is optional, and absence means "not reported by this probe".
207
- * A field the framework is *known* not to expose belongs in
208
- * {@link ProbeObject.unobservable} instead, so a consumer can tell "off" from
209
- * "unknowable".
210
- *
211
- * The three selection facts have separate names on purpose. An accessibility
212
- * `selected` flag, a highlighted collection index and a selected text range
213
- * are not interchangeable, even though frameworks often call all three
214
- * "selection".
215
- */
216
- interface ProbeObservedState {
217
- readonly focused?: boolean;
218
- readonly disabled?: boolean;
219
- readonly checked?: boolean | 'mixed';
220
- readonly expanded?: boolean;
221
- readonly readonly?: boolean;
222
- readonly selected?: boolean;
223
- readonly busy?: boolean;
224
- readonly multiline?: boolean;
225
- /**
226
- * Whether the framework's own display flag is on. Distinct from being
227
- * scrolled out of view, which shows up as an empty `visibleRect`.
228
- */
229
- readonly displayed?: boolean;
230
- /** Contents of a value-bearing widget. `''` means empty, not absent. */
231
- readonly value?: string;
232
- /** Highlighted item in a collection, by index. Not a text selection. */
233
- readonly selectedIndex?: number;
234
- /** Selected text range within this object. Not an item selection. */
235
- readonly textSelection?: {
236
- readonly start: number;
237
- readonly end: number;
238
- };
239
- readonly scroll?: ProbeScroll;
240
- readonly scrollExtent?: ProbeExtent;
241
- }
242
- /** Field names a probe can declare unobservable. */
243
- declare const PROBE_UNOBSERVABLE_FIELDS: readonly ["focused", "disabled", "checked", "expanded", "readonly", "selected", "busy", "multiline", "displayed", "value", "selectedIndex", "textSelection", "scroll", "scrollExtent", "intendedRect", "visibleRect", "paintOrder", "text", "parent"];
244
- type ProbeUnobservableField = (typeof PROBE_UNOBSERVABLE_FIELDS)[number];
245
- /**
246
- * Author-supplied annotations carried verbatim.
247
- *
248
- * The probe does not interpret these — a recognizer does, at the top of the
249
- * merge precedence. `role` is deliberately a free string here: it is whatever
250
- * the author wrote, and validating it against the closed role set is the
251
- * recognizer's job, which can then report a bad annotation instead of silently
252
- * dropping it.
253
- */
254
- interface ProbeAccessibilityHints {
255
- /** Framework-native accessibility role, in the framework's vocabulary. */
256
- readonly role?: string;
257
- readonly name?: string;
258
- readonly description?: string;
259
- }
260
- interface ProbeAnnotations {
261
- readonly role?: string;
262
- readonly name?: string;
263
- readonly testId?: string;
264
- readonly description?: string;
265
- /** Application-domain JSON state, kept outside the portable state flags. */
266
- readonly extended?: SemanticExtendedState;
267
- /** Descriptive action intent; never callbacks or a second input channel. */
268
- readonly actions?: readonly SemanticAction[];
269
- /** Probe identity values of author-declared labelling relationships. */
270
- readonly labelledBy?: readonly string[];
271
- /** Probe identity values of author-declared description relationships. */
272
- readonly describedBy?: readonly string[];
273
- }
274
- /**
275
- * One object a probe observed in a frame.
276
- *
277
- * `frameworkType` is required. It is the framework's own name for the thing —
278
- * a class name, a constructor name, a widget type — and it is what keeps an
279
- * unrecognised widget alive as a `generic` node instead of being dropped. Its
280
- * quality varies enormously (Textual gives a full class ancestry; Ink gives one
281
- * of four host-element names), so a recognizer must treat it as a hint, not a
282
- * classification.
283
- */
284
- interface ProbeObject {
285
- readonly identity: ProbeIdentity;
286
- readonly frameworkType: string;
287
- /** Parent's identity value; absent for a root. */
288
- readonly parent?: string;
289
- readonly geometry?: ProbeGeometry;
290
- readonly state?: ProbeObservedState;
291
- /** Text the object itself carries, not its descendants'. */
292
- readonly text?: string;
293
- /** Accessibility metadata retained by the framework itself, not author SDK data. */
294
- readonly accessibility?: ProbeAccessibilityHints;
295
- readonly annotations?: ProbeAnnotations;
296
- /**
297
- * Where this object sits in paint order: higher was painted later, and
298
- * therefore on top.
299
- *
300
- * Available in three of the six frameworks (a compositor hit-test, a z-order
301
- * child list, a paint-order key) and absent in the rest. It is the only fact
302
- * that makes "is my target actually the thing at this cell" answerable
303
- * without inventing cell ownership, which no framework records.
304
- */
305
- readonly paintOrder?: number;
306
- /**
307
- * Facts this framework cannot report for this object. Distinct from a field
308
- * simply being absent, which means the probe did not report it this time.
309
- */
310
- readonly unobservable?: readonly ProbeUnobservableField[];
311
- }
312
- /**
313
- * A render or layout call the probe intercepted.
314
- *
315
- * Only some frameworks expose a call stream, and in immediate mode it is the
316
- * *only* structure that exists — there is no tree to walk, just an ordered list
317
- * of "this type was drawn into this rectangle". `ordinal` is the position in
318
- * that stream and is meaningful only within its frame.
319
- */
320
- interface ProbeOperation {
321
- readonly kind: 'render' | 'layout';
322
- readonly ordinal: number;
323
- /** Identity of the object this call concerned, when the probe can attribute it. */
324
- readonly target?: ProbeIdentity;
325
- readonly frameworkType?: string;
326
- readonly intendedRect?: ProbeRect;
327
- }
328
- /**
329
- * One observed frame.
330
- *
331
- * `objects` may be empty and `operations` may carry everything: that is what an
332
- * immediate-mode frame looks like, and a flat op list is a legal degenerate
333
- * tree rather than an error.
334
- */
335
- interface ProbeFrame {
336
- /** Monotonic within the session. Every framework has exactly one of these. */
337
- readonly frame: number;
338
- readonly objects: readonly ProbeObject[];
339
- readonly operations?: readonly ProbeOperation[];
340
- }
341
- /** Optional abilities a probe declares at handshake time. */
342
- declare const PROBE_CAPABILITIES: readonly ["stable-identity", "visible-rect", "operations", "annotations", "frame-begin", "paint-order"];
343
- type ProbeCapability = (typeof PROBE_CAPABILITIES)[number];
344
- /**
345
- * What a probe says about itself when it attaches.
346
- *
347
- * @remarks
348
- * `frame-begin` is optional for a reason that is easy to get wrong. No audited
349
- * framework offers a hook guaranteed to fire before every frame: one lets a
350
- * pre-draw hook veto the frame entirely (so the post-draw hook never runs), one
351
- * exposes only a post-frame hook, and one decouples submission from the flush
352
- * with a ticker. A consumer must therefore never read "no frame-begin" as "no
353
- * frame in progress" — doing so turns four of the six frameworks into a hang
354
- * rather than an error.
355
- */
356
- interface ProbeInfo {
357
- /** Framework name, e.g. `ink`, `textual`, `ratatui`. */
358
- readonly framework: string;
359
- readonly frameworkVersion?: string;
360
- /** Version of the probe itself, so a mismatch is diagnosable. */
361
- readonly probeVersion: string;
362
- /** The best identity this probe can offer for any object. */
363
- readonly identityKind: ProbeIdentityKind;
364
- readonly capabilities: readonly ProbeCapability[];
365
- }
366
- /**
367
- * Where a semantic fact came from.
368
- *
369
- * Ranked: an annotation is what the author said, a recognizer is what our rules
370
- * concluded, `framework` is what the framework itself reported, `correlation`
371
- * is what matching across sources implied, and `heuristic` is a guess that
372
- * happened to be useful. The merge precedence follows this order, except that
373
- * physical facts — bounds, focus, visibility, cells — are never casually
374
- * overridden by an annotation: an author may name a thing, but may not declare
375
- * where it is on screen.
376
- */
377
- declare const PROVENANCE_SOURCES: readonly ["annotation", "recognizer", "framework", "correlation", "heuristic"];
378
- type ProvenanceSource = (typeof PROVENANCE_SOURCES)[number];
379
-
380
- /**
381
- * Resolving IR geometry into the single rectangle a semantic node publishes.
382
- *
383
- * The IR keeps `intendedRect` and `visibleRect` apart because they are
384
- * different facts. `SemanticNode.bounds` is one rectangle, so somewhere the two
385
- * have to collapse — and that collapse is a decision, not a formatting step.
386
- *
387
- * The decision: **`bounds` is always the best known *visible* geometry.** A
388
- * consumer never has to ask which of the two it is holding, because the answer
389
- * is always the same one. Publishing both rectangles instead would push "which
390
- * of these did you mean" onto every consumer of the tree — the same one-field-
391
- * two-jobs problem, moved rather than solved.
392
- *
393
- * What a consumer still cannot know from `bounds` alone is whether something
394
- * else was painted on top. That is what {@link ResolvedBounds.occlusion}
395
- * carries, and it is why the two are resolved together here rather than in five
396
- * independent implementations.
397
- */
398
-
399
- /** Whether occlusion is knowable for this node. */
400
- type OcclusionKnowledge = 'known' | 'unknown';
401
- /** Which of the IR rectangles the published bounds came from. */
402
- type BoundsSource = 'visible' | 'clipped' | 'intended';
403
- /** The rectangle a node publishes, plus what is known about it. */
404
- interface ResolvedBounds {
405
- readonly rect: Rect;
406
- /**
407
- * `known` only when the probe reports paint order. Without it, a rectangle
408
- * says where a widget is, not whether a pointer aimed there reaches it.
409
- */
410
- readonly occlusion: OcclusionKnowledge;
411
- readonly source: BoundsSource;
412
- /**
413
- * True when the clip removed the rectangle entirely — the node exists and is
414
- * scrolled out of view.
415
- *
416
- * A normalizer maps this to **`state.hidden: true` plus
417
- * `state.offscreen: true`**. Both are needed and they say different things:
418
- * `hidden` because a zero-area rectangle cannot intersect the viewport and
419
- * validation refuses it otherwise, and `offscreen` because scrolled-away is
420
- * not the same state as never-displayed, and a consumer reading the tree has
421
- * no other way to tell them apart.
422
- */
423
- readonly clippedAway: boolean;
424
- }
425
- /** Settings for {@link resolveNodeBounds}. */
426
- interface ResolveBoundsOptions {
427
- /**
428
- * The clip imposed by ancestors, where the framework exposes one and has not
429
- * already applied it to `visibleRect`.
430
- */
431
- readonly clip?: ProbeRect;
432
- /** Whether the probe reports paint order for this object. */
433
- readonly paintOrderKnown?: boolean;
434
- }
435
- /**
436
- * Collapse IR geometry into the rectangle a semantic node publishes.
437
- *
438
- * Three tiers, best first:
439
- * 1. `visibleRect`, where the framework computed the clip intersection itself;
440
- * 2. `intendedRect ∩ clip`, where a clip is known but not pre-applied;
441
- * 3. `intendedRect` alone, as a last resort — it is where the widget *asked* to
442
- * draw, which is the only thing left when nothing knows about clipping.
443
- *
444
- * @param geometry - IR geometry for the object, if it reported any.
445
- * @param options - Clip and paint-order knowledge.
446
- * @returns The resolved bounds, or `undefined` when the object reported no
447
- * geometry at all. A bounds-free node is a legal, expected state — one audited
448
- * framework hands over a rendered string with no coordinates anywhere — and
449
- * inventing a rectangle for it would be worse than having none.
450
- */
451
- declare function resolveNodeBounds(geometry: ProbeGeometry | undefined, options?: ResolveBoundsOptions): ResolvedBounds | undefined;
452
-
453
- /** Why a fact could not be observed. Unknown is retryable; unsupported is not. */
454
- type ObservationUnknownReason = 'not-reported' | 'temporary' | 'clip-unobservable' | 'legacy-unqualified';
455
- type ObservationAbsentReason = 'detached' | 'not-displayed' | 'not-laid-out';
456
- type ObservationUnsupportedReason = 'capability' | 'framework-unobservable' | 'not-negotiated';
457
- type ObservationEvidence = 'adapter' | 'probe' | 'terminal-grid' | 'viewport-clip' | 'paint-order' | 'hit-grid' | 'legacy-v1';
458
- /**
459
- * A fact with its epistemic state preserved.
460
- *
461
- * Consumers must never coerce `unknown`/`unsupported` to false, nor absence to
462
- * an empty value. That rule prevents assertions from passing because a probe
463
- * simply could not observe the requested property.
464
- */
465
- type Observation<T> = {
466
- readonly status: 'known';
467
- readonly value: T;
468
- readonly evidence: ObservationEvidence;
469
- } | {
470
- readonly status: 'absent';
471
- readonly reason: ObservationAbsentReason;
472
- } | {
473
- readonly status: 'unknown';
474
- readonly reason: ObservationUnknownReason;
475
- } | {
476
- readonly status: 'unsupported';
477
- readonly capability: string;
478
- readonly reason: ObservationUnsupportedReason;
479
- };
480
- /** Atomic identity of the screen/tree pair used for an observation. */
481
- interface ObservationStamp {
482
- readonly sessionId: string;
483
- readonly screenRevision: number;
484
- readonly semanticRevision: number | null;
485
- }
486
- type CoordinateSpace = 'viewport-cells' | 'framework-local-cells';
487
- interface LocatorGeometry {
488
- readonly stamp: ObservationStamp;
489
- readonly coordinateSpace: Observation<CoordinateSpace>;
490
- readonly intendedRect: Observation<Rect>;
491
- readonly visibleRect: Observation<Rect>;
492
- }
493
- interface ViewportIntersection {
494
- /** Half-open intersection in viewport cell coordinates. */
495
- readonly rect: Rect;
496
- /** Intersection area / intended area. Zero-area intended rect has ratio 0. */
497
- readonly ratio: number;
498
- readonly fullyInside: boolean;
499
- }
500
- interface LocatorVisibility {
501
- readonly stamp: ObservationStamp;
502
- readonly attached: Observation<boolean>;
503
- readonly displayed: Observation<boolean>;
504
- readonly viewport: Observation<ViewportIntersection>;
505
- readonly offscreen: Observation<boolean>;
506
- }
507
- interface CellPoint {
508
- readonly row: number;
509
- readonly column: number;
510
- }
511
- interface PointerHitTest {
512
- readonly stamp: ObservationStamp;
513
- readonly point: Observation<CellPoint>;
514
- readonly receivesEvents: Observation<boolean>;
515
- /** Ref of the actual recipient, when the producer can identify it. */
516
- readonly recipient: Observation<string>;
517
- }
518
- type SpatialRelation = 'contains' | 'inside' | 'overlaps' | 'left-of' | 'right-of' | 'above' | 'below' | 'aligned-left' | 'aligned-right' | 'aligned-top' | 'aligned-bottom' | 'adjacent-horizontal' | 'adjacent-vertical';
519
- /** Correct half-open rectangle intersection. Touching edges do not overlap. */
520
- declare function intersectRects(a: Rect, b: Rect): Rect;
521
- declare function rectArea(rect: Rect): number;
522
- declare function viewportIntersection(rect: Rect, columns: number, rows: number): ViewportIntersection;
523
- declare function spatialRelation(a: Rect, relation: SpatialRelation, b: Rect): boolean;
524
-
525
- /** Zero-based viewport cell coordinates. */
526
- interface Rect {
527
- readonly row: number;
528
- readonly column: number;
529
- readonly width: number;
530
- readonly height: number;
531
- }
532
- /** Closed state set. No arbitrary records. */
533
- interface SemanticState {
534
- readonly disabled?: boolean;
535
- readonly focused?: boolean;
536
- readonly selected?: boolean;
537
- readonly checked?: boolean | 'mixed';
538
- readonly expanded?: boolean;
539
- readonly modal?: boolean;
540
- readonly busy?: boolean;
541
- readonly hidden?: boolean;
542
- /**
543
- * The node exists in the layout, but every one of its cells falls outside the
544
- * visible area — it is scrolled out, and scrolling can bring it back.
545
- *
546
- * Named for the claim a test author makes ("this row is off screen"), not for
547
- * the mechanism that produced it. Clipping is how it happens; being off
548
- * screen is what it means.
549
- *
550
- * **Absent means "not claiming"**, not "on screen". A producer that cannot
551
- * observe clipping simply omits it, which is why this is a positive
552
- * assertion rather than a tri-state.
553
- *
554
- * It exists so that `bounds: undefined` keeps its single meaning — "this
555
- * producer does not know the geometry". Before this field, an adapter had to
556
- * choose between saying "no geometry" and saying "scrolled away", and those
557
- * are different facts that a consumer reading a tree generically could not
558
- * tell apart.
559
- *
560
- * Implies {@link SemanticState.hidden}: if every cell is outside the visible
561
- * area then the node is not visible, and validation refuses the pair
562
- * `offscreen: true` without `hidden: true`.
563
- */
564
- readonly offscreen?: boolean;
565
- readonly readonly?: boolean;
566
- readonly multiline?: boolean;
567
- readonly orientation?: 'horizontal' | 'vertical';
568
- readonly level?: number;
569
- readonly positionInSet?: number;
570
- readonly setSize?: number;
571
- readonly scrollOffset?: number;
572
- readonly scrollExtent?: number;
573
- }
574
- /** Maps grapheme offsets of a node's text to cell coordinates (optional capability). */
575
- interface SemanticTextRange {
576
- readonly startOffset: number;
577
- readonly endOffset: number;
578
- readonly rect: Rect;
579
- }
580
- /**
581
- * Deterministic JSON data owned by the application domain, not by the portable
582
- * semantic vocabulary. Containers are allowed, but runtime objects/functions
583
- * are not; validation applies the protocol's normal depth, byte and collection
584
- * ceilings recursively.
585
- */
586
- interface SemanticExtendedArray extends ReadonlyArray<SemanticExtendedValue> {
587
- }
588
- interface SemanticExtendedObject {
589
- readonly [key: string]: SemanticExtendedValue;
590
- }
591
- type SemanticExtendedValue = null | boolean | number | string | SemanticExtendedArray | SemanticExtendedObject;
592
- /** Application-defined state, deliberately separate from {@link SemanticState}. */
593
- type SemanticExtendedState = SemanticExtendedObject;
594
- interface SemanticNode {
595
- readonly id: string;
596
- readonly parentId?: string;
597
- readonly role: SemanticRole;
598
- readonly name: string;
599
- readonly description?: string;
600
- readonly value?: string;
601
- /**
602
- * The node's **visible** geometry, guaranteed.
603
- *
604
- * Normalizers resolve this to the best known visible rectangle — the clip
605
- * intersection where a framework computes one, `intendedRect ∩ clip` where a
606
- * clip is known, and the intended rectangle only as a last resort. A consumer
607
- * therefore never has to ask which rectangle it is holding.
608
- *
609
- * Still optional: class-B/C frameworks publish nodes without trustworthy
610
- * coordinates, and one framework hands over a rendered string with no
611
- * geometry anywhere. Absent bounds is a normal state, not a degraded one.
612
- */
613
- readonly bounds?: Rect;
614
- /**
615
- * Whether it is knowable that something else was painted over this node.
616
- *
617
- * `bounds` says where the node is; it does not say whether a pointer aimed
618
- * there reaches it. Only some frameworks expose paint order, so this is
619
- * `'known'` only when the probe reported it. **Absent means `'unknown'`** —
620
- * the conservative value is the default, so a producer has to claim
621
- * knowledge rather than have it assumed.
622
- *
623
- * A consumer performing pointer actions should refuse on `'unknown'` rather
624
- * than click and hope: the input lands somewhere real, and if it lands on
625
- * another widget the result is attributed to this one. That is a silent
626
- * false green, which is a worse failure than a refusal.
627
- */
628
- readonly occlusion?: OcclusionKnowledge;
629
- readonly state?: SemanticState;
630
- /** Application-specific, serializable state; never promoted to portable flags. */
631
- readonly extended?: SemanticExtendedState;
632
- readonly actions?: readonly SemanticAction[];
633
- readonly labelledBy?: readonly string[];
634
- readonly describedBy?: readonly string[];
635
- readonly textRanges?: readonly SemanticTextRange[];
636
- /** Author-supplied test id (getByTestId). */
637
- readonly testId?: string;
638
- /**
639
- * The framework's own name for this widget — a class name, a constructor
640
- * name, a widget type.
641
- *
642
- * **Required when `role` is `generic`.** An unrecognised widget must survive
643
- * as a generic node keeping its bounds, text and children, instead of being
644
- * dropped with its children reparented. `frameworkType` is what makes such a
645
- * node identifiable: without it a generic node says only "something was
646
- * here", which is barely better than the drop it replaced.
647
- */
648
- readonly frameworkType?: string;
649
- /**
650
- * Provenance: where this node's facts came from.
651
- *
652
- * One source for the whole node, because node facts overwhelmingly share
653
- * one. Exceptions go in {@link SemanticNode.px}, so a mixed node pays only
654
- * for the fields that actually differ. Descriptive per-property strings were
655
- * ruled out by arithmetic — they cost about +91 % against a budget that is
656
- * already tight.
657
- */
658
- readonly p?: ProvenanceSource;
659
- /** Per-field provenance, for fields whose source differs from `p`. */
660
- readonly px?: Readonly<Record<string, ProvenanceSource>>;
661
- /**
662
- * Protocol v2 qualified layout facts. V1 snapshots MUST omit this field;
663
- * their legacy `bounds` projection deliberately remains unchanged.
664
- */
665
- readonly geometry?: NodeGeometryObservations;
666
- }
667
- /** Layout facts reported independently so absence never masquerades as false. */
668
- interface NodeGeometryObservations {
669
- readonly displayed: Observation<boolean>;
670
- readonly intendedRect: Observation<Rect>;
671
- readonly visibleRect: Observation<Rect>;
672
- }
673
- /** One half-open run of cells with an exact pointer recipient. */
674
- interface PointerHitRegion {
675
- /** Canonical non-empty row run: `height` is always 1. */
676
- readonly rect: Rect;
677
- readonly recipientId: string;
678
- }
679
- /** A complete point-ownership map for a committed frame. */
680
- interface PointerHitGrid {
681
- readonly regions: readonly PointerHitRegion[];
682
- }
683
- interface CursorInfo {
684
- readonly row: number;
685
- readonly column: number;
686
- readonly visible: boolean;
687
- readonly shape?: 'block' | 'underline' | 'bar';
688
- }
689
- interface SemanticSnapshot {
690
- readonly v: 1 | 2;
691
- readonly sessionId: string;
692
- /** Positive, strictly increasing within a semantic session. */
693
- readonly revision: number;
694
- readonly columns: number;
695
- readonly rows: number;
696
- readonly cursor?: CursorInfo;
697
- readonly rootIds: readonly string[];
698
- readonly nodes: readonly SemanticNode[];
699
- /** Required by v2, forbidden by strict v1 validation. */
700
- readonly coordinateSpace?: Observation<CoordinateSpace>;
701
- /**
702
- * Required by v2. `known` means a complete map, not a sample or paint-order
703
- * approximation. Cells absent from a known map have no semantic recipient.
704
- */
705
- readonly hitGrid?: Observation<PointerHitGrid>;
706
- }
707
-
708
- /** Machine-readable source of truth for geometry/visibility support. */
709
- interface FrameworkObservationCapabilities {
710
- readonly framework: 'generic' | 'textual' | 'opentui' | 'ink' | 'tview' | 'ratatui' | 'charm';
711
- readonly identity: 'stable' | 'frame-local' | 'none';
712
- readonly attached: 'supported';
713
- readonly displayed: 'supported' | 'conditional' | 'unsupported';
714
- readonly intendedRect: 'supported' | 'conditional' | 'unsupported';
715
- readonly visibleRect: 'supported' | 'conditional' | 'unsupported';
716
- readonly hitTest: 'supported' | 'conditional' | 'unsupported';
717
- readonly reason: string;
718
- }
719
- type CapabilityAvailability = 'supported' | 'conditional' | 'unsupported';
720
- type GeometryOperation = 'keyboard-actions' | 'pointer-actions' | 'toBeAttached' | 'toBeDetached' | 'toBeDisplayed' | 'toBeHidden' | 'toBeVisible' | 'toBeOffscreen' | 'toBeInViewport' | 'toReceivePointerEvents' | 'toHaveBounds' | 'toHaveSpatialRelation' | 'cellSnapshot';
721
- interface FrameworkOperationCapability {
722
- readonly framework: FrameworkObservationCapabilities['framework'];
723
- readonly operation: GeometryOperation;
724
- readonly availability: CapabilityAvailability;
725
- readonly reason: string;
726
- }
727
- declare const FRAMEWORK_OBSERVATION_CAPABILITIES: readonly FrameworkObservationCapabilities[];
728
- declare function frameworkObservationCapabilities(framework: string): FrameworkObservationCapabilities | undefined;
729
- /**
730
- * Normative operation matrix, derived from the fact registry. Documentation
731
- * validates against this export; adapters cannot gain an assertion merely by
732
- * changing prose.
733
- */
734
- declare const FRAMEWORK_OPERATION_CAPABILITIES: readonly FrameworkOperationCapability[];
113
+ /** Default adapter-discovery window (ms) before an auto-detected session closes admission. */
114
+ declare const DEFAULT_NEGOTIATION_MS = 2000;
735
115
 
736
116
  /**
737
117
  * The field names of a semantic node and of its state, as data.
@@ -755,7 +135,7 @@ declare const FRAMEWORK_OPERATION_CAPABILITIES: readonly FrameworkOperationCapab
755
135
  * schema but missing from the interface fails to compile here, which is the
756
136
  * half of the drift a runtime test cannot catch early.
757
137
  */
758
- declare const SEMANTIC_NODE_KEYS: readonly (Exclude<keyof SemanticNode, 'geometry'>)[];
138
+ declare const SEMANTIC_NODE_KEYS: readonly Exclude<keyof SemanticNode, 'geometry'>[];
759
139
  /** Every field name on `SemanticState`. */
760
140
  declare const SEMANTIC_STATE_KEYS: readonly (keyof SemanticState)[];
761
141
 
@@ -768,7 +148,7 @@ type ValidationResult = {
768
148
  readonly code: ValidationErrorCode;
769
149
  readonly detail: string;
770
150
  };
771
- type ValidationErrorCode = 'schema' | 'unknown-role' | 'duplicate-id' | 'missing-parent' | 'cycle' | 'depth' | 'count' | 'string-bytes' | 'bad-rect' | 'revision' | 'bytes';
151
+ type ValidationErrorCode = 'schema' | 'unknown-role' | 'duplicate-id' | 'missing-parent' | 'cycle' | 'depth' | 'count' | 'string-bytes' | 'bad-rect' | 'provider' | 'revision' | 'bytes';
772
152
  /**
773
153
  * Full snapshot validation per spec §8.2: unique ids, existing+acyclic parent
774
154
  * relations, dense bounded arrays, Unicode scalar strings within byte bounds,
@@ -881,120 +261,6 @@ type LogValidationResult = {
881
261
  */
882
262
  declare function validateLogRecord(value: unknown, limits: ProtocolLimits): LogValidationResult;
883
263
 
884
- /**
885
- * Tree deltas: incremental semantic updates bound to an exact base revision.
886
- *
887
- * A delta is only ever applied to the revision it names. There is no
888
- * speculative patching and no fuzzy rebasing: if the receiver does not hold
889
- * exactly `baseRevision`, it asks for a full snapshot with `get-tree` and
890
- * throws the delta away (origin spec §8.3). A wrong tree is far more expensive
891
- * than a redundant snapshot, because every assertion downstream inherits the
892
- * error silently.
893
- *
894
- * ## Composition semantics
895
- *
896
- * The semantic tree is a flat node list joined by `parentId`, so a delta is a
897
- * set of upserts plus a set of removals:
898
- *
899
- * - **`changed`** upserts by id: a node absent from the base is inserted, and
900
- * a node already present is **replaced wholesale**, never field-merged.
901
- * Merging would need a third state meaning "unset this optional field",
902
- * which the wire has no way to express.
903
- * - **`removed`** removes each id **together with its whole subtree**. Cascade
904
- * is what keeps a delta small — dropping a dialog is one id, not one id per
905
- * descendant — and it is the only rule that cannot leave orphans behind.
906
- * - **`rootIds`**, when present, replaces the root list outright. When absent
907
- * the base roots carry over, minus anything the removals took.
908
- * - **`cursor`**, when present, replaces the cursor. When absent it is
909
- * unchanged. Everything else about the viewport — columns, rows, session id
910
- * — is inherited and cannot be changed by a delta.
911
- *
912
- * Order matters: removals are applied first, then upserts. That lets one delta
913
- * move a node out of a removed subtree by re-adding it in `changed`.
914
- */
915
-
916
- /**
917
- * An incremental update to a semantic tree.
918
- *
919
- * Carries no viewport or session id: those belong to the snapshot the delta is
920
- * composed onto, and a change to them requires a full snapshot. The cursor is
921
- * the exception — it moves far too often to be worth a snapshot each time.
922
- */
923
- interface TreeDelta {
924
- /** The revision this delta is composed onto. Must match exactly. */
925
- readonly baseRevision: number;
926
- /** The revision produced by applying it. Strictly greater than the base. */
927
- readonly revision: number;
928
- /** Nodes to insert or replace, keyed by `id`. */
929
- readonly changed: readonly SemanticNode[];
930
- /** Node ids to remove, each together with its subtree. */
931
- readonly removed: readonly string[];
932
- /** Replacement root list; absent means the base roots carry over. */
933
- readonly rootIds?: readonly string[];
934
- /**
935
- * Replacement cursor; **absent means unchanged**.
936
- *
937
- * Without this a diffs-only session could never move the cursor, which in a
938
- * TUI moves on nearly every keystroke — the mode would be useless for
939
- * exactly the interactive applications it exists to make cheap.
940
- *
941
- * A delta can set the cursor but **cannot clear it**, and the two are not
942
- * the same thing: `{ visible: false }` says there is a cursor and it is
943
- * hidden, while an absent `SemanticSnapshot.cursor` says there is no cursor
944
- * information at all. `cursor` is the only optional field on a snapshot, so
945
- * it is the only one with this asymmetry.
946
- *
947
- * **Producer obligation:** a producer whose tree transitions from having a
948
- * cursor to having none MUST send a full snapshot rather than a delta.
949
- * Emitting a delta there would leave the receiver holding a cursor the
950
- * application has stopped reporting — stale state that looks live. The same
951
- * rule already applies to `columns`/`rows`, which a delta also cannot change.
952
- */
953
- readonly cursor?: CursorInfo;
954
- }
955
- /** Structured result: never throws hostile data onward. */
956
- type DeltaValidationResult = {
957
- readonly ok: true;
958
- readonly delta: TreeDelta;
959
- } | {
960
- readonly ok: false;
961
- readonly code: ValidationErrorCode;
962
- readonly detail: string;
963
- };
964
- /**
965
- * Validate the **shape** of an untrusted delta.
966
- *
967
- * This checks everything that can be known without the base tree: bounded
968
- * sizes, well-formed nodes, unique ids, and a base/revision pair that moves
969
- * forward. It deliberately cannot check parent existence, acyclicity, depth or
970
- * whether bounds fall inside the viewport — all of those are properties of the
971
- * *composed* tree, and {@link applyTreeDelta} checks them there.
972
- *
973
- * @param value - Untrusted candidate delta (without the message `type` field).
974
- * @param limits - Active limits.
975
- * @returns `{ ok: true, delta }` with a deep-frozen delta, or a typed failure.
976
- * Never throws.
977
- */
978
- declare function validateTreeDelta(value: unknown, limits: ProtocolLimits): DeltaValidationResult;
979
- /**
980
- * Compose a delta onto the snapshot it names, then validate the result.
981
- *
982
- * The base revision must match **exactly**; a mismatch is reported rather than
983
- * patched around, so the caller can fall back to `get-tree` per origin §8.3.
984
- *
985
- * All the invariants a delta cannot check on its own — parents exist, the tree
986
- * is acyclic, depth and counts are within limits, bounds intersect the viewport
987
- * — are checked here against the composed tree, by running the composed result
988
- * through {@link validateSnapshot}. A delta is therefore never trusted to
989
- * produce a valid tree; it is only trusted to describe one.
990
- *
991
- * @param base - The snapshot the delta is composed onto.
992
- * @param delta - A delta that already passed {@link validateTreeDelta}.
993
- * @param limits - Active limits.
994
- * @returns The composed, deep-frozen snapshot, or a typed failure. Never throws.
995
- */
996
- declare function applyTreeDelta(base: SemanticSnapshot, delta: TreeDelta, limits: ProtocolLimits): ValidationResult;
997
-
998
264
  /**
999
265
  * AccessKit export: `SemanticSnapshot` → an AccessKit `TreeUpdate`.
1000
266
  *
@@ -1064,6 +330,8 @@ interface AccessKitNode {
1064
330
  readonly modal?: boolean;
1065
331
  readonly hidden?: boolean;
1066
332
  readonly readOnly?: boolean;
333
+ readonly required?: boolean;
334
+ readonly multiselectable?: boolean;
1067
335
  readonly toggled?: AccessKitToggled;
1068
336
  }
1069
337
  /** AccessKit's `Tree`. */
@@ -1183,12 +451,44 @@ declare const probeInfoSchema: z.ZodObject<{
1183
451
  }>;
1184
452
  capabilities: z.ZodArray<z.ZodEnum<{
1185
453
  "stable-identity": "stable-identity";
454
+ "intended-rect": "intended-rect";
1186
455
  "visible-rect": "visible-rect";
1187
456
  operations: "operations";
1188
457
  annotations: "annotations";
1189
458
  "frame-begin": "frame-begin";
1190
459
  "paint-order": "paint-order";
1191
460
  }>>;
461
+ instrumentation: z.ZodOptional<z.ZodObject<{
462
+ highestTier: z.ZodEnum<{
463
+ T0: "T0";
464
+ T1: "T1";
465
+ T2: "T2";
466
+ T3: "T3";
467
+ }>;
468
+ semanticClass: z.ZodEnum<{
469
+ A: "A";
470
+ B: "B";
471
+ }>;
472
+ degradedCapabilities: z.ZodArray<z.ZodEnum<{
473
+ "intended-geometry": "intended-geometry";
474
+ "clipped-geometry": "clipped-geometry";
475
+ "stable-identity": "stable-identity";
476
+ "semantic-tree": "semantic-tree";
477
+ "painted-region": "painted-region";
478
+ "pointer-geometry": "pointer-geometry";
479
+ "pointer-hit-testing": "pointer-hit-testing";
480
+ focus: "focus";
481
+ scroll: "scroll";
482
+ "render-order": "render-order";
483
+ "action-strategies": "action-strategies";
484
+ "keyboard-input": "keyboard-input";
485
+ "pointer-input": "pointer-input";
486
+ "focus-input": "focus-input";
487
+ "paired-revisions": "paired-revisions";
488
+ "inactive-screen-tree": "inactive-screen-tree";
489
+ "custom-container-enumeration": "custom-container-enumeration";
490
+ }>>;
491
+ }, z.core.$strict>>;
1192
492
  }, z.core.$strict>;
1193
493
  /**
1194
494
  * Validate a probe's self-description.
@@ -1234,13 +534,6 @@ declare function validateProbeFrame(value: unknown, limits: ProtocolLimits): Pro
1234
534
  */
1235
535
  declare function validateProbeAnnotations(value: unknown, limits: ProtocolLimits): ProbeAnnotationValidationResult;
1236
536
 
1237
- /**
1238
- * Wire messages. Transport: length-prefixed JSON frames (see framing.ts).
1239
- * CDP-like: adapter pushes commits; driver issues requests; either side may
1240
- * send errors. All messages are validated against limits BEFORE retention.
1241
- */
1242
- declare const ADAPTER_CAPABILITIES: readonly ["tree", "bounds", "absolute-bounds", "states", "actions", "text-ranges", "render-revisions", "tree-diffs", "logs", "qualified-observations", "pointer-hit-grid"];
1243
- type AdapterCapability = (typeof ADAPTER_CAPABILITIES)[number];
1244
537
  /** adapter → driver, exactly once, before any other message. */
1245
538
  interface HelloMessage {
1246
539
  readonly type: 'hello';
@@ -1259,6 +552,8 @@ interface HelloMessage {
1259
552
  * negotiates against measured capability rather than assuming a floor.
1260
553
  */
1261
554
  readonly probe?: ProbeInfo;
555
+ /** Application evidence providers frozen into this session contract. */
556
+ readonly providers?: readonly EvidenceProviderRegistration[];
1262
557
  }
1263
558
  /** driver → adapter, reply to hello. */
1264
559
  interface HelloAckMessage {
@@ -1266,15 +561,8 @@ interface HelloAckMessage {
1266
561
  readonly protocol: ProtocolId;
1267
562
  readonly sessionId: string;
1268
563
  readonly limits: ProtocolLimits;
1269
- /**
1270
- * Which traffic the driver wants pushed.
1271
- *
1272
- * `diffs` is only ever selected for an adapter that announced the
1273
- * `tree-diffs` capability, so an adapter that does not know the value never
1274
- * receives it — the closed set grew without breaking anyone, because the
1275
- * adapter opts in first.
1276
- */
1277
- readonly subscribe: 'snapshots' | 'revisions' | 'diffs';
564
+ /** Which semantic traffic the driver wants pushed. */
565
+ readonly subscribe: 'snapshots' | 'revisions';
1278
566
  /** Marker configuration: producer must emit the signed OSC 8487 commit marker. */
1279
567
  readonly marker: {
1280
568
  readonly enabled: boolean;
@@ -1307,19 +595,6 @@ interface SnapshotMessage {
1307
595
  readonly type: 'snapshot';
1308
596
  readonly snapshot: SemanticSnapshot;
1309
597
  }
1310
- /** driver → adapter, request full snapshot (latest, or a held revision). */
1311
- interface GetTreeRequest {
1312
- readonly type: 'get-tree';
1313
- readonly requestId: number;
1314
- readonly revision?: number;
1315
- }
1316
- /** adapter → driver, response to get-tree. */
1317
- interface GetTreeResponse {
1318
- readonly type: 'get-tree-result';
1319
- readonly requestId: number;
1320
- readonly snapshot?: SemanticSnapshot;
1321
- readonly error?: string;
1322
- }
1323
598
  /**
1324
599
  * adapter → driver, a frame has started (capability `frame-begin`).
1325
600
  *
@@ -1341,17 +616,6 @@ interface FrameBeginMessage {
1341
616
  readonly type: 'frame-begin';
1342
617
  readonly revision: number;
1343
618
  }
1344
- /**
1345
- * adapter → driver, an incremental tree update (capability `tree-diffs`,
1346
- * `subscribe: 'diffs'`).
1347
- *
1348
- * Bound to an exact base revision: see `delta.ts` for composition semantics.
1349
- * A receiver that does not hold `baseRevision` must request a full snapshot
1350
- * with `get-tree` rather than patch speculatively.
1351
- */
1352
- interface TreeDeltaMessage extends TreeDelta {
1353
- readonly type: 'tree-delta';
1354
- }
1355
619
  /**
1356
620
  * adapter → driver, one application log record (capability `logs`).
1357
621
  *
@@ -1366,18 +630,18 @@ interface LogMessage {
1366
630
  /** either direction: terminal protocol error; sender closes after emitting. */
1367
631
  interface ProtocolErrorMessage {
1368
632
  readonly type: 'error';
1369
- readonly code: 'bad-token' | 'bad-version' | 'malformed' | 'limit-exceeded' | 'internal';
633
+ readonly code: 'bad-token' | 'bad-version' | 'malformed' | 'limit-exceeded' | 'duplicate-semantic-key' | 'adapter-guarantee-violation' | 'capability-provider-violation' | 'internal';
1370
634
  readonly message: string;
1371
635
  }
1372
- type AdapterToDriverMessage = HelloMessage | RevisionCommitMessage | SnapshotMessage | GetTreeResponse | TreeDeltaMessage | FrameBeginMessage | LogMessage | ProtocolErrorMessage;
1373
- type DriverToAdapterMessage = HelloAckMessage | GetTreeRequest | ProtocolErrorMessage;
636
+ type AdapterToDriverMessage = HelloMessage | RevisionCommitMessage | SnapshotMessage | FrameBeginMessage | LogMessage | ProtocolErrorMessage;
637
+ type DriverToAdapterMessage = HelloAckMessage | ProtocolErrorMessage;
1374
638
  /** Outcome of parsing one wire message. Mirrors `ProtocolErrorMessage['code']`. */
1375
639
  type MessageParseResult<T> = {
1376
640
  readonly ok: true;
1377
641
  readonly message: T;
1378
642
  } | {
1379
643
  readonly ok: false;
1380
- readonly code: 'bad-version' | 'malformed' | 'limit-exceeded';
644
+ readonly code: 'bad-version' | 'malformed' | 'limit-exceeded' | 'capability-provider-violation';
1381
645
  readonly detail: string;
1382
646
  };
1383
647
  /**
@@ -1431,10 +695,12 @@ declare function parseDriverMessage(value: unknown, limits: ProtocolLimits): Mes
1431
695
  *
1432
696
  * ## Why OSC and not DCS
1433
697
  *
1434
- * ConPTY rewrites the stream it forwards. A passthrough probe run in CI across
1435
- * the three platforms showed it dropping DCS, APC and OSC 8, while passing
698
+ * The legacy, frame-based inbox ConPTY rewrote the stream it forwarded. A
699
+ * permeability probe showed it dropping DCS, APC and OSC 8 while passing
1436
700
  * private OSC with either terminator, and OSC 133. DCS therefore could not
1437
- * carry a marker on Windows at all.
701
+ * carry a marker on the original Windows backend. The pinned passthrough
702
+ * ConPTY now forwards those families, but OSC 8487 remains the single encoding
703
+ * certified across every supported platform.
1438
704
  *
1439
705
  * One encoding is used everywhere rather than negotiating per platform: two
1440
706
  * paths double the surface that has to stay correct, and the path used least
@@ -1509,6 +775,24 @@ declare function encodeMarker(token: string, sessionId: string, revision: number
1509
775
  */
1510
776
  declare function verifyMarkerPayload(payload: string, token: string, sessionId: string): RenderMarker | null;
1511
777
 
778
+ /** Private, request-addressed cursor synchronization used by Termwright's ConPTY host. */
779
+ declare const CONPTY_HOST_CURSOR_OSC_CODE = 8488;
780
+ /** Versioned payload prefix inside the host-reserved OSC 8488 namespace. */
781
+ declare const CONPTY_HOST_CURSOR_PREFIX = "twh-cpr-v1";
782
+ interface ConPtyHostCursorRequest {
783
+ readonly token: string;
784
+ }
785
+ interface ConPtyHostCursorResponse extends ConPtyHostCursorRequest {
786
+ readonly row: number;
787
+ readonly column: number;
788
+ }
789
+ /** Parses the payload delivered by an OSC 8488 handler, after `8488;`. */
790
+ declare function parseConPtyHostCursorRequest(payload: string): ConPtyHostCursorRequest | null;
791
+ /** Encodes the only reply the patched native host consumes. Coordinates are one-based. */
792
+ declare function encodeConPtyHostCursorResponse(request: ConPtyHostCursorRequest, row: number, column: number): string;
793
+ /** Strictly recognizes a complete host reply before the PTY chooses its input transport. */
794
+ declare function parseConPtyHostCursorResponse(value: Uint8Array | string): ConPtyHostCursorResponse | null;
795
+
1512
796
  /**
1513
797
  * Wire framing: 4-byte big-endian unsigned length prefix + UTF-8 JSON body.
1514
798
  * The length is checked against limits.maxFrameBytes BEFORE any decoding;
@@ -1562,4 +846,4 @@ declare function encodeFrame(message: unknown, maxFrameBytes: number): Uint8Arra
1562
846
  */
1563
847
  declare function projectDto<T>(value: unknown, maxDepth: number): T;
1564
848
 
1565
- export { ABSOLUTE_LIMITS, ACCESSKIT_ROLE_BY_SEMANTIC_ROLE, ACCESSKIT_ROOT_TREE_ID, ADAPTER_CAPABILITIES, type AccessKitExport, type AccessKitExportOptions, type AccessKitNode, type AccessKitRect, type AccessKitToggled, type AccessKitTree, type AccessKitTreeUpdate, type AdapterCapability, type AdapterToDriverMessage, type BoundsSource, type CapabilityAvailability, type CellPoint, type CoordinateSpace, type CursorInfo, DEFAULT_LIMITS, DEFAULT_NEGOTIATION_MS, type DeltaValidationResult, type DriverToAdapterMessage, ENV_ENDPOINT, ENV_PROTOCOL, ENV_TOKEN, FRAMEWORK_OBSERVATION_CAPABILITIES, FRAMEWORK_OPERATION_CAPABILITIES, FRAME_HEADER_BYTES, type FrameBeginMessage, type FrameDecoder, type FrameworkObservationCapabilities, type FrameworkOperationCapability, type GeometryOperation, type GetTreeRequest, type GetTreeResponse, type HelloAckMessage, type HelloMessage, LOG_LEVELS, LOG_LEVEL_SEVERITY, type LocatorGeometry, type LocatorVisibility, type LogAttrValue, type LogLevel, type LogMessage, type LogRecord, type LogValidationResult, MARKER_MAC_BYTES, MARKER_OSC_CODE, MARKER_OSC_PREFIX, MAX_LOG_ATTRS, type MessageParseResult, type NodeGeometryObservations, type Observation, type ObservationAbsentReason, type ObservationEvidence, type ObservationStamp, type ObservationUnknownReason, type ObservationUnsupportedReason, type OcclusionKnowledge, PROBE_CAPABILITIES, PROBE_UNOBSERVABLE_FIELDS, PROTOCOL_ID, PROTOCOL_V2_ID, PROTOCOL_VERSION, PROVENANCE_SOURCES, type PointerHitGrid, type PointerHitRegion, type PointerHitTest, type ProbeAccessibilityHints, type ProbeAnnotationValidationResult, type ProbeAnnotations, type ProbeCapability, type ProbeExtent, type ProbeFrame, type ProbeGeometry, type ProbeIdentity, type ProbeIdentityKind, type ProbeInfo, type ProbeObject, type ProbeObservedState, type ProbeOperation, type ProbeRect, type ProbeScroll, type ProbeUnobservableField, type ProbeValidationResult, type ProtocolErrorMessage, type ProtocolId, type ProtocolLimits, ProtocolViolation, type ProtocolViolationCode, type ProvenanceSource, type Rect, type RenderMarker, type ResolveBoundsOptions, type ResolvedBounds, type RevisionCommitMessage, SEMANTIC_ACTIONS, SEMANTIC_NODE_KEYS, SEMANTIC_ROLES, SEMANTIC_STATE_KEYS, SUPPORTED_PROTOCOL_IDS, type SemanticAction, type SemanticExtendedArray, type SemanticExtendedObject, type SemanticExtendedState, type SemanticExtendedValue, type SemanticNode, type SemanticRole, type SemanticSnapshot, type SemanticState, type SemanticTextRange, type SnapshotMessage, type SpatialRelation, TOKEN_BYTES, type TreeDelta, type TreeDeltaMessage, type ValidationErrorCode, type ValidationResult, type ViewportIntersection, accessKitNodeId, applyTreeDelta, createFrameDecoder, encodeFrame, encodeMarker, frameworkObservationCapabilities, generateToken, intersectRects, parseAdapterMessage, parseDriverMessage, probeInfoSchema, projectDto, rectArea, resolveNodeBounds, spatialRelation, toAccessKitTreeUpdate, validateLogRecord, validateProbeAnnotations, validateProbeFrame, validateProbeInfo, validateSnapshot, validateTreeDelta, verifyMarkerPayload, viewportIntersection };
849
+ export { ABSOLUTE_LIMITS, ACCESSKIT_ROLE_BY_SEMANTIC_ROLE, ACCESSKIT_ROOT_TREE_ID, type AccessKitExport, type AccessKitExportOptions, type AccessKitNode, type AccessKitRect, type AccessKitToggled, type AccessKitTree, type AccessKitTreeUpdate, AdapterCapability, type AdapterToDriverMessage, CONPTY_HOST_CURSOR_OSC_CODE, CONPTY_HOST_CURSOR_PREFIX, type ConPtyHostCursorRequest, type ConPtyHostCursorResponse, DEFAULT_LIMITS, DEFAULT_NEGOTIATION_MS, type DriverToAdapterMessage, ENV_ENDPOINT, ENV_TOKEN, EvidenceProviderRegistration, FRAME_HEADER_BYTES, type FrameBeginMessage, type FrameDecoder, type HelloAckMessage, type HelloMessage, LOG_LEVELS, LOG_LEVEL_SEVERITY, type LogAttrValue, type LogLevel, type LogMessage, type LogRecord, type LogValidationResult, MARKER_MAC_BYTES, MARKER_OSC_CODE, MARKER_OSC_PREFIX, MAX_LOG_ATTRS, type MessageParseResult, PROTOCOL_ID, PROTOCOL_VERSION, type ProbeAnnotationValidationResult, ProbeAnnotations, ProbeFrame, ProbeInfo, type ProbeValidationResult, type ProtocolErrorMessage, type ProtocolId, type ProtocolLimits, ProtocolViolation, type ProtocolViolationCode, Rect, type RenderMarker, type RevisionCommitMessage, SEMANTIC_NODE_KEYS, SEMANTIC_STATE_KEYS, SemanticNode, SemanticRole, SemanticSnapshot, SemanticState, type SnapshotMessage, TOKEN_BYTES, type ValidationErrorCode, type ValidationResult, accessKitNodeId, createFrameDecoder, encodeConPtyHostCursorResponse, encodeFrame, encodeMarker, generateToken, parseAdapterMessage, parseConPtyHostCursorRequest, parseConPtyHostCursorResponse, parseDriverMessage, probeInfoSchema, projectDto, toAccessKitTreeUpdate, validateLogRecord, validateProbeAnnotations, validateProbeFrame, validateProbeInfo, validateSnapshot, verifyMarkerPayload };