@qontinui/ui-bridge-native 0.6.16 → 0.7.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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The Observation envelope, vendored from `@qontinui/ui-bridge`.
3
+ *
4
+ * `./observation.ts` is a GENERATED copy of the canonical
5
+ * `packages/ui-bridge/src/observation/observation.ts` (see
6
+ * `scripts/sync-observation.mjs`); CI fails if the two drift. This package
7
+ * imports it by relative path so it takes no runtime dependency on
8
+ * `@qontinui/ui-bridge` (an optional peer here) and needs no package-`exports`
9
+ * support from Metro.
10
+ */
11
+ export { Observation, ObservationError, UNKNOWN_CODES, isUnknownCode, type UnknownCode, type ObservationStatus, type ObservationProducer, type ObservationCoverage, type UnmeasuredDimension, type ObservationCache, type ObservationProvenance, type ObservationProvenanceInit, type ObservationUnknown, type ObservationTime, type MeasuredObservation, type AbsentObservation, type UnknownObservation, } from './observation';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Observation envelope — the shape every UI Bridge observation surface answers
3
+ * in: WHAT was seen (`measured`), that nothing was there (`absent`), or that the
4
+ * producer could not look (`unknown`) — and, in every case, where the answer
5
+ * came from (`provenance`).
6
+ *
7
+ * Why it exists: an empty findings list used to mean either "the page has
8
+ * nothing there" or "the producer never looked", byte-identically, and only the
9
+ * first is a statement about the page. `page-health` rendered a missing
10
+ * `elements` key as a CRITICAL blank page; an agent reading that went looking
11
+ * for a bug no evidence pointed at.
12
+ *
13
+ * This is the TypeScript twin of the canonical Rust type
14
+ * `qontinui-schemas/rust-vision-core/src/observation.rs`. `@qontinui/ui-bridge`
15
+ * is a standalone package and takes no dependency on qontinui-schemas; it is
16
+ * held to the Rust canon by SDK-captured fixtures the schemas crate parses
17
+ * strictly (plan 2026-09-20-ui-bridge-observations-…, D2). The two MUST stay
18
+ * structurally identical on the wire:
19
+ *
20
+ * ```jsonc
21
+ * {
22
+ * "status": "measured" | "absent" | "unknown", // always present
23
+ * "value": <T>, // present iff measured
24
+ * "unknown": { "code": <UnknownCode>, "detail": "…" }, // present iff unknown
25
+ * "provenance": { // always present, EVERY key always present
26
+ * "producer": { "id": "…", "version": "…" },
27
+ * "observedAt": "<RFC3339>" | null,
28
+ * "evaluatedAt": "<RFC3339>",
29
+ * "coverage": { "considered": n, "measured": n,
30
+ * "unmeasured": [{ "dimension": "…", "count": n, "code": <UnknownCode> }] },
31
+ * "confidence": <0..1> | null,
32
+ * "cache": { "hit": bool, "storedAt": "<RFC3339>" | null, "keyInputs": ["…"] } | null,
33
+ * "source": { … } | null
34
+ * }
35
+ * }
36
+ * ```
37
+ *
38
+ * `null` in `provenance` is a STATEMENT, never an omission: `confidence: null`
39
+ * says "a deduction, not an estimate", `cache: null` says "this producer has no
40
+ * cache", `observedAt: null` says "no sample was taken". A key is therefore
41
+ * never left out, and the constructors below are the only way to build one.
42
+ *
43
+ * The envelope adds no score and no verdict — `healthy`/`unhealthy` never
44
+ * appears in it.
45
+ */
46
+ /**
47
+ * Why a producer could not answer. A CLOSED set: every `unknown` observation
48
+ * carries exactly one of these, so an agent branches on the code rather than
49
+ * parsing English out of `detail`.
50
+ */
51
+ export type UnknownCode =
52
+ /** The bridge/app could not be reached. */
53
+ 'app_unreachable'
54
+ /** The running build does not serve this capability (e.g. an SDK route that needs a runner). */
55
+ | 'capability_unavailable_in_build'
56
+ /** The producer ran and errored (transport, HTTP status, timeout, thrown exception). */
57
+ | 'producer_failed'
58
+ /** The producer did not run — e.g. zero registered components, nothing to look at yet. */
59
+ | 'producer_not_run'
60
+ /** A required input was absent (no `elements` key, no bbox, no frame). */
61
+ | 'input_missing'
62
+ /** Observations existed but all fell under the caller's confidence floor. */
63
+ | 'below_confidence_floor'
64
+ /** A model reply could not be parsed/validated. */
65
+ | 'model_reply_unparseable'
66
+ /** The question needs more than one frame (e.g. `animation_settled`). */
67
+ | 'needs_multi_frame_input'
68
+ /** The input is known to be stale. */
69
+ | 'stale_input';
70
+ /** Every {@link UnknownCode}, in the canonical (wire-contract) order. */
71
+ export declare const UNKNOWN_CODES: readonly UnknownCode[];
72
+ /** Type guard: is `value` one of the closed {@link UnknownCode} members? */
73
+ export declare function isUnknownCode(value: unknown): value is UnknownCode;
74
+ /** Which producer answered, and at what version. */
75
+ export interface ObservationProducer {
76
+ /** e.g. `sdk/page-health`, `runner/vision-extract`, `vision-core/layout`. */
77
+ id: string;
78
+ /** The producing package's or crate's version. */
79
+ version: string;
80
+ }
81
+ /** One dimension the producer could NOT measure, how many items it affected, and why. */
82
+ export interface UnmeasuredDimension {
83
+ /** What went unmeasured, e.g. `geometry`, `text`. */
84
+ dimension: string;
85
+ /** How many considered items lacked it. */
86
+ count: number;
87
+ code: UnknownCode;
88
+ }
89
+ /**
90
+ * How much of what the producer looked at it could actually measure. A
91
+ * non-empty `unmeasured` makes a `measured` observation DEGRADED (legal) and an
92
+ * `absent` one ILLEGAL; so does `considered === 0` for `absent`.
93
+ */
94
+ export interface ObservationCoverage {
95
+ /** Items the producer considered. */
96
+ considered: number;
97
+ /** Items it could measure in full. */
98
+ measured: number;
99
+ /** Named dimensions it could not measure. Always present — `[]` is the statement "full coverage". */
100
+ unmeasured: UnmeasuredDimension[];
101
+ }
102
+ /** Provenance of a cached answer. Every key always present. */
103
+ export interface ObservationCache {
104
+ /** Whether this answer was served from the cache. */
105
+ hit: boolean;
106
+ /** When the served entry was stored. `null` on a miss or when the cache keeps no timestamp. */
107
+ storedAt: string | null;
108
+ /** The inputs the cache key was derived from, so a reader can judge what a hit is keyed on. */
109
+ keyInputs: string[];
110
+ }
111
+ /** Where an {@link Observation} came from. EVERY key is always present. */
112
+ export interface ObservationProvenance {
113
+ producer: ObservationProducer;
114
+ /** When the underlying state was sampled (snapshot time / frame capture). `null` = no sample was taken. */
115
+ observedAt: string | null;
116
+ /** When the producer ran. Never null. */
117
+ evaluatedAt: string;
118
+ coverage: ObservationCoverage;
119
+ /** Finite, in `[0, 1]`, or `null` = "a deduction, not an estimate". */
120
+ confidence: number | null;
121
+ /** `null` = this producer has no cache. */
122
+ cache: ObservationCache | null;
123
+ /** Source attribution as a JSON object, or `null` = the producer has none to give. */
124
+ source: Record<string, unknown> | null;
125
+ }
126
+ /** Why a producer could not answer. */
127
+ export interface ObservationUnknown {
128
+ code: UnknownCode;
129
+ /** Human prose. Never the only carrier of the reason — `code` is. */
130
+ detail: string;
131
+ }
132
+ /** The three answers, as the `status` tag spells them on the wire. */
133
+ export type ObservationStatus = 'measured' | 'absent' | 'unknown';
134
+ /** The producer looked and saw `value`. */
135
+ export interface MeasuredObservation<T> {
136
+ status: 'measured';
137
+ value: T;
138
+ provenance: ObservationProvenance;
139
+ }
140
+ /** The producer looked with FULL coverage and found nothing. */
141
+ export interface AbsentObservation {
142
+ status: 'absent';
143
+ provenance: ObservationProvenance;
144
+ }
145
+ /** The producer could not look. Carries no `value`. */
146
+ export interface UnknownObservation {
147
+ status: 'unknown';
148
+ unknown: ObservationUnknown;
149
+ provenance: ObservationProvenance;
150
+ }
151
+ /**
152
+ * The envelope. A discriminated union on `status`, so there is no `measured`
153
+ * without a `value`, no `unknown` without a `code`, and no `value` beside an
154
+ * `absent` — at compile time. The one invariant spanning the state AND the
155
+ * provenance (`absent` only over full coverage of at least one considered
156
+ * item) is enforced by
157
+ * {@link Observation.absent}.
158
+ */
159
+ export type Observation<T> = MeasuredObservation<T> | AbsentObservation | UnknownObservation;
160
+ /** Thrown when a constructor is asked for an illegal envelope. */
161
+ export declare class ObservationError extends Error {
162
+ constructor(message: string);
163
+ }
164
+ /** A timestamp in any of the forms producers hold one in. */
165
+ export type ObservationTime = string | number | Date;
166
+ /** Inputs for {@link Observation.provenance}. Omitted optional keys become the explicit `null` statements. */
167
+ export interface ObservationProvenanceInit {
168
+ producer: ObservationProducer;
169
+ /** When the underlying state was sampled. Omitted / `null` = no sample was taken. */
170
+ observedAt?: ObservationTime | null;
171
+ /** When the producer ran. Defaults to now. */
172
+ evaluatedAt?: ObservationTime;
173
+ /** Defaults to `{ considered: 0, measured: 0, unmeasured: [] }`. */
174
+ coverage?: ObservationCoverage;
175
+ /** Omitted / `null` / non-finite = a deduction, not an estimate. */
176
+ confidence?: number | null;
177
+ /** Omitted / `null` = this producer has no cache. */
178
+ cache?: {
179
+ hit: boolean;
180
+ storedAt: ObservationTime | null;
181
+ keyInputs: string[];
182
+ } | null;
183
+ /** Omitted / `null` = no source attribution. */
184
+ source?: Record<string, unknown> | null;
185
+ }
186
+ /** Full coverage of `n` considered items. */
187
+ declare function fullCoverage(n: number): ObservationCoverage;
188
+ declare function provenance(init: ObservationProvenanceInit): ObservationProvenance;
189
+ /**
190
+ * The producer looked and saw `value`. THROWS {@link ObservationError} on
191
+ * `undefined`: a measured observation whose `value` key would vanish from
192
+ * the wire is exactly the missing-key shape the Rust canon refuses.
193
+ */
194
+ declare function measured<T>(value: T, prov: ObservationProvenance): Observation<T>;
195
+ /**
196
+ * The producer looked and found nothing. "absent" means the producer
197
+ * considered at least one item, measured every one of them, and found
198
+ * nothing. THROWS {@link ObservationError}, checked in the Rust canon's order:
199
+ *
200
+ * 1. `coverage.unmeasured` is non-empty — never asserted over a region the
201
+ * producer did not measure;
202
+ * 2. `coverage.considered` is 0 — never asserted over nothing looked at (a
203
+ * producer with nothing to consider answers `unknown`, e.g.
204
+ * `producer_not_run` / `input_missing`);
205
+ * 3. `coverage.measured !== coverage.considered` — a partial look is
206
+ * `measured` with its gaps in `coverage.unmeasured`, never `absent`.
207
+ */
208
+ declare function absent<T = never>(prov: ObservationProvenance): Observation<T>;
209
+ declare function unknown<T = never>(code: UnknownCode, detail: string, prov: ObservationProvenance): Observation<T>;
210
+ /**
211
+ * Constructors for the envelope. `Observation.measured` / `.absent` /
212
+ * `.unknown` are the ONLY way to build one; `.provenance` builds the block
213
+ * with every nullable key stated explicitly.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * // `Observation` is exported by the package that ships this module.
218
+ * const prov = Observation.provenance({
219
+ * producer: { id: 'sdk/page-health', version: '0.29.0' },
220
+ * observedAt: Date.now(),
221
+ * });
222
+ * const obs = Observation.unknown('input_missing', 'no elements key', prov);
223
+ * ```
224
+ */
225
+ export declare const Observation: {
226
+ readonly provenance: typeof provenance;
227
+ readonly fullCoverage: typeof fullCoverage;
228
+ readonly measured: typeof measured;
229
+ readonly absent: typeof absent;
230
+ readonly unknown: typeof unknown;
231
+ };
232
+ export {};
233
+ //# sourceMappingURL=observation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../../src/observation/observation.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAMH;;;;GAIG;AACH,MAAM,MAAM,WAAW;AACrB,2CAA2C;AACzC,iBAAiB;AACnB,gGAAgG;GAC9F,iCAAiC;AACnC,wFAAwF;GACtF,iBAAiB;AACnB,0FAA0F;GACxF,kBAAkB;AACpB,0EAA0E;GACxE,eAAe;AACjB,6EAA6E;GAC3E,wBAAwB;AAC1B,mDAAmD;GACjD,yBAAyB;AAC3B,yEAAyE;GACvE,yBAAyB;AAC3B,sCAAsC;GACpC,aAAa,CAAC;AAElB,yEAAyE;AACzE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