@reticlehq/core 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consequence.d.ts +27 -0
- package/dist/consequence.js +26 -0
- package/dist/constants.d.ts +52 -8
- package/dist/constants.js +49 -8
- package/dist/contract-fingerprint.d.ts +29 -0
- package/dist/contract-fingerprint.js +56 -0
- package/dist/daemon-registry.js +1 -1
- package/dist/event-payloads.d.ts +50 -2
- package/dist/event-payloads.js +12 -1
- package/dist/flow-constants.d.ts +8 -0
- package/dist/flow-constants.js +12 -0
- package/dist/flow-types.d.ts +40 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/journal.d.ts +2 -2
- package/dist/messages.d.ts +72 -0
- package/dist/messages.js +34 -0
- package/dist/net.d.ts +40 -0
- package/dist/net.js +44 -0
- package/dist/project-id.d.ts +28 -0
- package/dist/project-id.js +51 -0
- package/dist/redaction.d.ts +64 -0
- package/dist/redaction.js +118 -1
- package/dist/schema/hello-message.json +17 -0
- package/dist/schema/reticle-message.json +17 -0
- package/dist/security.js +10 -5
- package/dist/source-constants.d.ts +32 -0
- package/dist/source-constants.js +32 -0
- package/dist/state-select.d.ts +24 -2
- package/dist/state-select.js +102 -22
- package/dist/telemetry-feedback.d.ts +32 -10
- package/dist/telemetry-feedback.js +21 -0
- package/dist/telemetry-session.d.ts +30 -0
- package/dist/telemetry-session.js +24 -0
- package/dist/telemetry.d.ts +491 -81
- package/dist/telemetry.js +188 -2
- package/dist/toon.d.ts +2 -1
- package/dist/toon.js +37 -37
- package/dist/types.d.ts +54 -6
- package/dist/types.js +12 -0
- package/dist/upgrade.js +1 -1
- package/dist/verification-run.d.ts +38 -38
- package/dist/verified-constants.d.ts +37 -0
- package/dist/verified-constants.js +36 -0
- package/package.json +5 -3
package/dist/telemetry.js
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { z } from 'zod';
|
|
19
19
|
import { MachineSnapshotSchema, ProjectProfileSchema, SessionSummarySchema, } from './telemetry-session.js';
|
|
20
|
-
import { FeedbackSchema } from './telemetry-feedback.js';
|
|
20
|
+
import { BrowserBrand, FeedbackSchema } from './telemetry-feedback.js';
|
|
21
|
+
import { VerifiedReason } from './verified-constants.js';
|
|
21
22
|
import { IdentitySchema } from './telemetry-feedback.js';
|
|
22
23
|
/** Bump when the event shape changes so the analytics side can segment old senders. */
|
|
23
24
|
export const TELEMETRY_EVENT_VERSION = 3;
|
|
@@ -55,6 +56,20 @@ export const TelemetryEventKind = {
|
|
|
55
56
|
* errors, features touched). One event replaces the hundreds the old per-call `tool` event sent.
|
|
56
57
|
*/
|
|
57
58
|
DAEMON_STOPPED: 'daemon_stopped',
|
|
59
|
+
/**
|
|
60
|
+
* A PERIODIC roll-up from a daemon that is still running — same payload shape as DAEMON_STOPPED,
|
|
61
|
+
* `final: false`.
|
|
62
|
+
*
|
|
63
|
+
* It used to be emitted AS `daemon_stopped`, which made an event named for an exit fire while the
|
|
64
|
+
* process was alive. Measured over one day: 98 `daemon_stopped` events were 73 real exits plus 25
|
|
65
|
+
* flushes, so anything counting sessions over-stated by 34% — and worse, the two populations are
|
|
66
|
+
* opposites. Every one of the 25 flushes had tool calls; not one of the 73 exits did (a daemon that
|
|
67
|
+
* served a tool never idle-exits, so only the idle ones ever reach a clean shutdown). A funnel over
|
|
68
|
+
* the raw event therefore describes active sessions at one end and abandoned ones at the other.
|
|
69
|
+
*
|
|
70
|
+
* Count sessions with DAEMON_STOPPED. Sum work with both.
|
|
71
|
+
*/
|
|
72
|
+
SESSION_PROGRESS: 'session_progress',
|
|
58
73
|
/**
|
|
59
74
|
* A verification produced a verdict. The product's reason to exist, and the one metric an investor
|
|
60
75
|
* should be shown: not "tools were called" but "an app was actually verified, and here is how often
|
|
@@ -93,6 +108,23 @@ export const TelemetryEventKind = {
|
|
|
93
108
|
* identical to healthy usage in every other metric.
|
|
94
109
|
*/
|
|
95
110
|
MCP_CLIENT_CONNECTED: 'mcp_client_connected',
|
|
111
|
+
/**
|
|
112
|
+
* The agent LOST its Reticle tools — the worst thing this product does to anyone, and until now
|
|
113
|
+
* completely invisible in the field.
|
|
114
|
+
*
|
|
115
|
+
* `mcp_client_connected` shows reconnect churn only from the daemon's side, and the proxy's own
|
|
116
|
+
* account of an outage went to a local file nobody sends us. So "how often does a real user's MCP
|
|
117
|
+
* server go down, and does it come back" — the single question the transport has to answer — could
|
|
118
|
+
* not be asked of any dashboard.
|
|
119
|
+
*
|
|
120
|
+
* Deliberately capped at TWO per proxy process: once on the first outage of a session, and once if
|
|
121
|
+
* the retry budget is spent (the severe case, where it stopped retrying and went dormant). The
|
|
122
|
+
* per-call `tool` event was already removed here for cost, and one measured afternoon produced 547
|
|
123
|
+
* proxy reconnects — an event per reconnect would bill for the pathology instead of measuring it.
|
|
124
|
+
* The first-outage event answers "what share of sessions lose MCP at all", which is the number
|
|
125
|
+
* that decides whether this is fixed.
|
|
126
|
+
*/
|
|
127
|
+
MCP_CONNECTION_LOST: 'mcp_connection_lost',
|
|
96
128
|
/**
|
|
97
129
|
* `reticle init` finished. The onboarding funnel had no instrumentation at all, so a setup that
|
|
98
130
|
* failed on a missing dependency was indistinguishable from a user who never tried.
|
|
@@ -112,6 +144,32 @@ export const TelemetryEventKind = {
|
|
|
112
144
|
*/
|
|
113
145
|
BUG_FOUND: 'bug_found',
|
|
114
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Events that belong to a DAEMON RUN, and therefore carry `sessionId`.
|
|
149
|
+
*
|
|
150
|
+
* `sessionId` is minted per process, which is right for a daemon (a daemon run IS the session) and
|
|
151
|
+
* wrong for a one-shot CLI command, which invents one that joins to nothing. Measured over a real
|
|
152
|
+
* day: uniq(sessionId) was 704, of which 561 came from `cli_command_run` and NOT ONE was shared with
|
|
153
|
+
* a daemon. The real number of daemon runs was 121, so every tile counting sessions was ~6x high.
|
|
154
|
+
*
|
|
155
|
+
* Omitting the id on the one-shot events costs nothing — no join on those ids could ever have
|
|
156
|
+
* succeeded — and makes `uniq(sessionId)` mean the thing every dashboard already assumes it means.
|
|
157
|
+
*/
|
|
158
|
+
const SESSION_SCOPED = new Set([
|
|
159
|
+
TelemetryEventKind.DAEMON_STARTED,
|
|
160
|
+
TelemetryEventKind.DAEMON_STOPPED,
|
|
161
|
+
TelemetryEventKind.SESSION_PROGRESS,
|
|
162
|
+
TelemetryEventKind.MCP_CLIENT_CONNECTED,
|
|
163
|
+
TelemetryEventKind.PROJECT_PROFILED,
|
|
164
|
+
TelemetryEventKind.VERIFICATION_COMPLETED,
|
|
165
|
+
TelemetryEventKind.BUG_FOUND,
|
|
166
|
+
TelemetryEventKind.RUNTIME_CRASHED,
|
|
167
|
+
TelemetryEventKind.FEEDBACK_SUBMITTED,
|
|
168
|
+
]);
|
|
169
|
+
/** True when this event happened inside a daemon run, so a `sessionId` on it means something. */
|
|
170
|
+
export function isSessionScoped(kind) {
|
|
171
|
+
return SESSION_SCOPED.has(kind);
|
|
172
|
+
}
|
|
115
173
|
/**
|
|
116
174
|
* Who caused this. The only honest split available to us: a `reticle` command was TYPED by a person,
|
|
117
175
|
* while an MCP tool call came from the agent's own loop.
|
|
@@ -165,11 +223,54 @@ export const VerificationSchema = z.object({
|
|
|
165
223
|
*/
|
|
166
224
|
falseGreenCaught: z.boolean(),
|
|
167
225
|
durationMs: z.number().int().nonnegative().optional(),
|
|
226
|
+
/**
|
|
227
|
+
* `headless` | `headed` | `attached` — how the browser under verification got there.
|
|
228
|
+
*
|
|
229
|
+
* Without it, "verifications run" is one undifferentiated number covering three different
|
|
230
|
+
* products: unattended CI, a human watching an agent work, and the SDK in somebody's own dev
|
|
231
|
+
* server. They have different costs, different failure modes and different value, and only the
|
|
232
|
+
* last one is what most installs actually do.
|
|
233
|
+
*/
|
|
234
|
+
browser: z.string().min(1).max(16).optional(),
|
|
235
|
+
/**
|
|
236
|
+
* WHICH browser it was — `chrome` | `edge` | `arc` | `dia` | `brave` | `opera` | `firefox` |
|
|
237
|
+
* `safari` | `other`, from `BrowserBrand`.
|
|
238
|
+
*
|
|
239
|
+
* `browser` above says who drove it, and its most common value by far is `attached`: the SDK
|
|
240
|
+
* connected from a browser Reticle never launched. That leaves the actual browser unknown, and
|
|
241
|
+
* the engine cannot fill the gap — Chrome, Edge, Arc, Dia and Brave are one `blink`.
|
|
242
|
+
*
|
|
243
|
+
* OPTIONAL and absent rather than `"unknown"` when the page did not say: a desktop webview has no
|
|
244
|
+
* brand, and an older SDK does not report one. A guessed value would be indistinguishable from a
|
|
245
|
+
* measured one on a dashboard.
|
|
246
|
+
*/
|
|
247
|
+
brand: z.nativeEnum(BrowserBrand).optional(),
|
|
248
|
+
/**
|
|
249
|
+
* WHICH clause of the honesty rule decided this — see `VerifiedReason`.
|
|
250
|
+
*
|
|
251
|
+
* `verified` alone cannot answer the question the product is judged on. `unknown` + `passed:false`
|
|
252
|
+
* was measured covering "Reticle caught a real bug", "the agent wrote a bad predicate" and
|
|
253
|
+
* "Reticle itself could not see", which need opposite responses and arrive as one value; `no`
|
|
254
|
+
* collapses "channels disagree" into "the agent's predicate failed" the same way.
|
|
255
|
+
*
|
|
256
|
+
* OPTIONAL because not every verdict comes from `decideVerified` — a suite reports pass/fail with
|
|
257
|
+
* no clause behind it, and an older SDK reports none. Absent means unclassified, never guessed.
|
|
258
|
+
*/
|
|
259
|
+
reason: z.nativeEnum(VerifiedReason).optional(),
|
|
168
260
|
});
|
|
169
261
|
/** Which way the installed version moved, and between which versions. */
|
|
170
262
|
export const VersionChangeSchema = z.object({
|
|
171
263
|
from: z.string().min(1).max(64),
|
|
172
264
|
to: z.string().min(1).max(64),
|
|
265
|
+
/**
|
|
266
|
+
* True when an agent had been told about exactly this version recently — so the nudge plausibly
|
|
267
|
+
* caused the update.
|
|
268
|
+
*
|
|
269
|
+
* Without it, `version_changed` says a version moved and never why, which leaves "the nudge never
|
|
270
|
+
* fired" and "the nudge fired and nobody acted" indistinguishable. Those need opposite responses,
|
|
271
|
+
* and the whole adoption story rests on knowing which one is happening.
|
|
272
|
+
*/
|
|
273
|
+
nudged: z.boolean().optional(),
|
|
173
274
|
/** `update` (forward) or `rollback` (back) — a rollback is a release-quality alarm. */
|
|
174
275
|
direction: z.string().min(1).max(16),
|
|
175
276
|
});
|
|
@@ -241,6 +342,28 @@ export const BugSource = {
|
|
|
241
342
|
/** An assertion the agent declared did not hold. */
|
|
242
343
|
ASSERTION: 'assertion',
|
|
243
344
|
};
|
|
345
|
+
/**
|
|
346
|
+
* WHOSE fault the defect was.
|
|
347
|
+
*
|
|
348
|
+
* `bugsFound` is the number this product would most like to publish, and it is not publishable
|
|
349
|
+
* without this. Measured over one real session: 8 `bug_found` events, of which **one** was a defect
|
|
350
|
+
* in the app under test. The other seven were the agent's own bad predicates (a store path that
|
|
351
|
+
* never existed, an impossible selector) and one empty ref, all published as defects in the
|
|
352
|
+
* customer's product. A founder steering on that number is steering on noise.
|
|
353
|
+
*
|
|
354
|
+
* Deliberately OMITTED rather than guessed when the evidence does not say. A failed `element.present`
|
|
355
|
+
* covers "the button is missing", "the API is down" and "the agent mistyped a testid" identically,
|
|
356
|
+
* and inventing an owner for it would put a guess into the one number we intend to publish — the
|
|
357
|
+
* same mistake `brand` refuses to make by being absent rather than `"unknown"`.
|
|
358
|
+
*/
|
|
359
|
+
export const BugAttribution = {
|
|
360
|
+
/** A defect in the app under test — the only bucket that belongs in a published defect count. */
|
|
361
|
+
APP: 'app',
|
|
362
|
+
/** The agent's own call was wrong: a path, store or target that never existed. Teach the agent. */
|
|
363
|
+
REQUEST: 'request',
|
|
364
|
+
/** Reticle could not see or could not drive. Our bug, or our configuration. Ship a fix. */
|
|
365
|
+
RETICLE: 'reticle',
|
|
366
|
+
};
|
|
244
367
|
/**
|
|
245
368
|
* One defect Reticle found in the app under test.
|
|
246
369
|
*
|
|
@@ -283,6 +406,11 @@ export const BugFoundSchema = z.object({
|
|
|
283
406
|
* as one — and must not be, since that would need data this event refuses to collect.
|
|
284
407
|
*/
|
|
285
408
|
repeat: z.boolean(),
|
|
409
|
+
/**
|
|
410
|
+
* Whose fault it was — `app` | `request` | `reticle`. ABSENT when the evidence cannot say; see
|
|
411
|
+
* `BugAttribution`. Count `attribution: 'app'` for defects found in anybody's product.
|
|
412
|
+
*/
|
|
413
|
+
attribution: z.nativeEnum(BugAttribution).optional(),
|
|
286
414
|
});
|
|
287
415
|
/** An MCP client attaching. Separates "installed and running" from "someone is actually using it". */
|
|
288
416
|
export const McpConnectionSchema = z.object({
|
|
@@ -297,6 +425,49 @@ export const McpConnectionSchema = z.object({
|
|
|
297
425
|
/** Which client, from its own handshake (`claude-code`, `cursor`). */
|
|
298
426
|
client: z.string().min(1).max(64).optional(),
|
|
299
427
|
});
|
|
428
|
+
/**
|
|
429
|
+
* WHICH stage of an MCP outage this is. Reported at most twice per proxy process, and the two are
|
|
430
|
+
* different facts: `first` says the session lost its tools at all, `budget_spent` says the proxy
|
|
431
|
+
* stopped retrying and never came back on its own.
|
|
432
|
+
*/
|
|
433
|
+
export const OutageStage = {
|
|
434
|
+
FIRST: 'first',
|
|
435
|
+
BUDGET_SPENT: 'budget_spent',
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* WHY the stream went away, as far as the proxy can tell. A closed vocabulary because the proxy's
|
|
439
|
+
* own reason strings are free text feeding a log — `OTHER` is the bucket that lets a new one arrive
|
|
440
|
+
* without a raw string reaching the wire, per the classifier rule.
|
|
441
|
+
*/
|
|
442
|
+
export const OutageReason = {
|
|
443
|
+
/** The SSE stream ended cleanly — usually the daemon exiting. */
|
|
444
|
+
SSE_ENDED: 'sse_ended',
|
|
445
|
+
/** The stream errored. */
|
|
446
|
+
SSE_ERROR: 'sse_error',
|
|
447
|
+
/** The socket died under us with neither `end` nor `error` — daemon killed, network reset. */
|
|
448
|
+
SSE_ABORTED: 'sse_aborted',
|
|
449
|
+
/** The response closed. */
|
|
450
|
+
SSE_CLOSED: 'sse_closed',
|
|
451
|
+
/** A reconnect attempt could not reach the daemon at all. */
|
|
452
|
+
CONNECT_ERROR: 'connect_error',
|
|
453
|
+
/** Anything the proxy reported that this list does not name. A classifier must be able to say so. */
|
|
454
|
+
OTHER: 'other',
|
|
455
|
+
};
|
|
456
|
+
/**
|
|
457
|
+
* The agent LOST its Reticle tools.
|
|
458
|
+
*
|
|
459
|
+
* This block existed on the emitter's input type and never on the wire: `emit()` builds its event
|
|
460
|
+
* from an explicit allow-list of keys and `outage` was not in it, so two deliberately different
|
|
461
|
+
* outages — `first`/`sse_ended`/3 and `budget_spent`/`connect_error`/12 — produced byte-identical
|
|
462
|
+
* events. Against a standing "MCP must never go down" mandate, the metric that measures it reported
|
|
463
|
+
* a bare count with no cause and no recovery signal. This is the schema half of the fix.
|
|
464
|
+
*/
|
|
465
|
+
export const McpOutageSchema = z.object({
|
|
466
|
+
stage: z.nativeEnum(OutageStage),
|
|
467
|
+
reason: z.nativeEnum(OutageReason),
|
|
468
|
+
/** Consecutive reconnects tried when this was reported. `first` is near 1; a spent budget is high. */
|
|
469
|
+
attempts: z.number().int().nonnegative(),
|
|
470
|
+
});
|
|
300
471
|
/** How `reticle init` went. The onboarding funnel, which had no instrumentation whatsoever. */
|
|
301
472
|
export const InitOutcomeSchema = z.object({
|
|
302
473
|
ok: z.boolean(),
|
|
@@ -326,7 +497,12 @@ export const TelemetryEventSchema = z.object({
|
|
|
326
497
|
* explicitly supports) interleaved into one undifferentiated stream, and no per-session funnel could
|
|
327
498
|
* be built at all. It cannot be backfilled, which is why it is worth adding before the data matters.
|
|
328
499
|
*/
|
|
329
|
-
|
|
500
|
+
/**
|
|
501
|
+
* The daemon run this happened inside. ABSENT on one-shot CLI events — see isSessionScoped: a
|
|
502
|
+
* per-process id on `reticle status` is not a session, it is a number that inflates every session
|
|
503
|
+
* count and joins to nothing.
|
|
504
|
+
*/
|
|
505
|
+
sessionId: z.string().min(1).max(64).optional(),
|
|
330
506
|
event: z.nativeEnum(TelemetryEventKind),
|
|
331
507
|
/** Client epoch-ms when the event happened (the server also stamps its own receive time). */
|
|
332
508
|
ts: z.number().int().nonnegative(),
|
|
@@ -342,6 +518,14 @@ export const TelemetryEventSchema = z.object({
|
|
|
342
518
|
projectIdSource: z.nativeEnum(ProjectIdSource).optional(),
|
|
343
519
|
/** `process.platform` (darwin/linux/win32) — OS mix, low cardinality, non-identifying. */
|
|
344
520
|
os: z.string().min(1).max(32),
|
|
521
|
+
/**
|
|
522
|
+
* Minutes this machine's local time is offset from UTC.
|
|
523
|
+
*
|
|
524
|
+
* "When do they work" was answerable only through ingest-side GeoIP, which may be off and is a
|
|
525
|
+
* coarser thing than a working day. One integer, no location, identifies nobody — and it turns
|
|
526
|
+
* every time-of-day tile from "which continent" into "9am or 11pm".
|
|
527
|
+
*/
|
|
528
|
+
tzOffsetMin: z.number().int().min(-900).max(900).optional(),
|
|
345
529
|
/** Only on `feedback`: the author-submitted report + its environment context. Never sent otherwise. */
|
|
346
530
|
feedback: FeedbackSchema.optional(),
|
|
347
531
|
/** Human or agent. Absent on events that are neither (a crash, a version change). */
|
|
@@ -372,4 +556,6 @@ export const TelemetryEventSchema = z.object({
|
|
|
372
556
|
init: InitOutcomeSchema.optional(),
|
|
373
557
|
/** Only on `bug_found`. */
|
|
374
558
|
bug: BugFoundSchema.optional(),
|
|
559
|
+
/** Only on `mcp_connection_lost`: which stage of the outage, why, and after how many retries. */
|
|
560
|
+
outage: McpOutageSchema.optional(),
|
|
375
561
|
});
|
package/dist/toon.d.ts
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
*
|
|
18
18
|
* State flags (inside []):
|
|
19
19
|
* vis visible hid hidden en enabled dis disabled
|
|
20
|
-
* chk checked
|
|
20
|
+
* chk checked exp expanded focus focused
|
|
21
|
+
* (`present` is on every element, so it is never encoded — see STATE_FLAG.)
|
|
21
22
|
*
|
|
22
23
|
* Attributes (key=value, space-separated):
|
|
23
24
|
* val="..." current value of the element
|
package/dist/toon.js
CHANGED
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
*
|
|
18
18
|
* State flags (inside []):
|
|
19
19
|
* vis visible hid hidden en enabled dis disabled
|
|
20
|
-
* chk checked
|
|
20
|
+
* chk checked exp expanded focus focused
|
|
21
|
+
* (`present` is on every element, so it is never encoded — see STATE_FLAG.)
|
|
21
22
|
*
|
|
22
23
|
* Attributes (key=value, space-separated):
|
|
23
24
|
* val="..." current value of the element
|
|
24
25
|
* count=N child count (for containers, replaces expanding children)
|
|
25
26
|
* ph="..." placeholder text
|
|
26
27
|
*/
|
|
28
|
+
import { ElementState } from './constants.js';
|
|
27
29
|
const ROLE_MAP = {
|
|
28
30
|
button: 'btn',
|
|
29
31
|
textbox: 'inp',
|
|
@@ -65,51 +67,49 @@ const ROLE_MAP = {
|
|
|
65
67
|
function abbreviateRole(role) {
|
|
66
68
|
return ROLE_MAP[role] ?? 'el';
|
|
67
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Short flags for the states the SDK reports.
|
|
72
|
+
*
|
|
73
|
+
* `present` is deliberately absent: `getStates` seeds every element's array with it, so it is true
|
|
74
|
+
* of everything that could appear here and encodes nothing — while costing eight characters per
|
|
75
|
+
* element in the layer whose entire job is cutting the agent's token bill. `visible`/`hidden` are
|
|
76
|
+
* likewise absent because the `visible` field already carries them.
|
|
77
|
+
*
|
|
78
|
+
* An unlisted state falls through to its own name, so an SDK newer than this daemon still reaches
|
|
79
|
+
* the agent with something readable instead of losing the state.
|
|
80
|
+
*/
|
|
81
|
+
const STATE_FLAG = {
|
|
82
|
+
[ElementState.ENABLED]: 'en',
|
|
83
|
+
[ElementState.DISABLED]: 'dis',
|
|
84
|
+
[ElementState.CHECKED]: 'chk',
|
|
85
|
+
[ElementState.EXPANDED]: 'exp',
|
|
86
|
+
[ElementState.FOCUSED]: 'focus',
|
|
87
|
+
};
|
|
88
|
+
/** States the `visible` field already encodes, plus the one that is true of everything. */
|
|
89
|
+
const UNENCODED_STATES = new Set([
|
|
90
|
+
ElementState.PRESENT,
|
|
91
|
+
ElementState.VISIBLE,
|
|
92
|
+
ElementState.HIDDEN,
|
|
93
|
+
]);
|
|
68
94
|
function encodeStates(states, visible) {
|
|
69
95
|
const flags = [];
|
|
70
|
-
if (
|
|
96
|
+
if (true === visible)
|
|
71
97
|
flags.push('vis');
|
|
72
|
-
else if (
|
|
98
|
+
else if (false === visible)
|
|
73
99
|
flags.push('hid');
|
|
74
100
|
for (const s of states) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
case 'hidden':
|
|
79
|
-
break; // handled above
|
|
80
|
-
case 'enabled':
|
|
81
|
-
flags.push('en');
|
|
82
|
-
break;
|
|
83
|
-
case 'disabled':
|
|
84
|
-
flags.push('dis');
|
|
85
|
-
break;
|
|
86
|
-
case 'checked':
|
|
87
|
-
flags.push('chk');
|
|
88
|
-
break;
|
|
89
|
-
case 'unchecked':
|
|
90
|
-
flags.push('uch');
|
|
91
|
-
break;
|
|
92
|
-
case 'expanded':
|
|
93
|
-
flags.push('exp');
|
|
94
|
-
break;
|
|
95
|
-
case 'collapsed':
|
|
96
|
-
flags.push('col');
|
|
97
|
-
break;
|
|
98
|
-
case 'focused':
|
|
99
|
-
flags.push('focus');
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
flags.push(s);
|
|
103
|
-
}
|
|
101
|
+
if (UNENCODED_STATES.has(s))
|
|
102
|
+
continue;
|
|
103
|
+
flags.push(STATE_FLAG[s] ?? s);
|
|
104
104
|
}
|
|
105
105
|
return flags.length > 0 ? `[${flags.join(',')}]` : '';
|
|
106
106
|
}
|
|
107
107
|
/** Coerce a wire field to a string. resultToToon receives UNVALIDATED wire data cast to ToonElement,
|
|
108
108
|
* so a missing/numeric `name` must not make `.replace` throw and lose the whole encode. */
|
|
109
109
|
function toText(v) {
|
|
110
|
-
if (typeof v
|
|
110
|
+
if ('string' === typeof v)
|
|
111
111
|
return v;
|
|
112
|
-
if (
|
|
112
|
+
if ('number' === typeof v || 'boolean' === typeof v || 'bigint' === typeof v)
|
|
113
113
|
return String(v);
|
|
114
114
|
return ''; // undefined / null / object / symbol have no representable text on a wire field
|
|
115
115
|
}
|
|
@@ -125,7 +125,7 @@ function encodeLine(el, depth) {
|
|
|
125
125
|
const states = encodeStates(Array.isArray(el.states) ? el.states : [], el.visible);
|
|
126
126
|
const ref = toText(el.ref) || '?';
|
|
127
127
|
const parts = [indent + type, ref, encodeName(el.name), ...(states ? [states] : [])];
|
|
128
|
-
if (typeof el.value
|
|
128
|
+
if ('string' === typeof el.value && el.value.length > 0)
|
|
129
129
|
parts.push(`val=${encodeValue(el.value)}`);
|
|
130
130
|
if (el.childCount !== undefined)
|
|
131
131
|
parts.push(`count=${String(el.childCount)}`);
|
|
@@ -149,7 +149,7 @@ function encodeTree(elements, depth = 0) {
|
|
|
149
149
|
}
|
|
150
150
|
/** Encode an array of ElementDescriptor-shaped objects to TOON text. */
|
|
151
151
|
export function toToon(elements) {
|
|
152
|
-
if (elements.length
|
|
152
|
+
if (0 === elements.length)
|
|
153
153
|
return '# TOON v1 — empty';
|
|
154
154
|
return `# TOON v1\n${encodeTree(elements)}`;
|
|
155
155
|
}
|
|
@@ -162,7 +162,7 @@ export function resultToToon(result) {
|
|
|
162
162
|
}
|
|
163
163
|
/** Whether a tool result object should be encoded as TOON (has an elements array). */
|
|
164
164
|
export function isToonable(result) {
|
|
165
|
-
return (typeof result
|
|
165
|
+
return ('object' === typeof result &&
|
|
166
166
|
result !== null &&
|
|
167
167
|
!Array.isArray(result) &&
|
|
168
168
|
Array.isArray(result['elements']));
|
package/dist/types.d.ts
CHANGED
|
@@ -136,6 +136,12 @@ export interface MatchResult {
|
|
|
136
136
|
* confirmed absence (a false negative); both are the false-green shape this tool exists to prevent.
|
|
137
137
|
*/
|
|
138
138
|
scopeMissing?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Zero-match diagnosis, present only on a miss: what IS on the page. `reticle_query` has always
|
|
141
|
+
* returned this; MATCH (the command every PREDICATE uses) did not, so a failed assertion was a
|
|
142
|
+
* dead end while the same failure through query was one step from fixed.
|
|
143
|
+
*/
|
|
144
|
+
hint?: QueryEmptyHint;
|
|
139
145
|
}
|
|
140
146
|
/**
|
|
141
147
|
* A semantic cluster of interactive elements in the DOM — the replacement for the raw testid list
|
|
@@ -575,8 +581,8 @@ export declare const RunRecordSchema: z.ZodObject<{
|
|
|
575
581
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
576
582
|
}, "strip", z.ZodTypeAny, {
|
|
577
583
|
status: "pass" | "drift" | "error" | "fail";
|
|
578
|
-
kind: "flow_replay" | "manual";
|
|
579
584
|
at: number;
|
|
585
|
+
kind: "flow_replay" | "manual";
|
|
580
586
|
name: string;
|
|
581
587
|
durationMs?: number | undefined;
|
|
582
588
|
evidence?: {
|
|
@@ -587,8 +593,8 @@ export declare const RunRecordSchema: z.ZodObject<{
|
|
|
587
593
|
summary?: string | undefined;
|
|
588
594
|
}, {
|
|
589
595
|
status: "pass" | "drift" | "error" | "fail";
|
|
590
|
-
kind: "flow_replay" | "manual";
|
|
591
596
|
at: number;
|
|
597
|
+
kind: "flow_replay" | "manual";
|
|
592
598
|
name: string;
|
|
593
599
|
durationMs?: number | undefined;
|
|
594
600
|
evidence?: {
|
|
@@ -654,8 +660,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
654
660
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
655
661
|
}, "strip", z.ZodTypeAny, {
|
|
656
662
|
status: "pass" | "drift" | "error" | "fail";
|
|
657
|
-
kind: "flow_replay" | "manual";
|
|
658
663
|
at: number;
|
|
664
|
+
kind: "flow_replay" | "manual";
|
|
659
665
|
name: string;
|
|
660
666
|
durationMs?: number | undefined;
|
|
661
667
|
evidence?: {
|
|
@@ -666,8 +672,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
666
672
|
summary?: string | undefined;
|
|
667
673
|
}, {
|
|
668
674
|
status: "pass" | "drift" | "error" | "fail";
|
|
669
|
-
kind: "flow_replay" | "manual";
|
|
670
675
|
at: number;
|
|
676
|
+
kind: "flow_replay" | "manual";
|
|
671
677
|
name: string;
|
|
672
678
|
durationMs?: number | undefined;
|
|
673
679
|
evidence?: {
|
|
@@ -680,8 +686,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
680
686
|
}, "strip", z.ZodTypeAny, {
|
|
681
687
|
runs: {
|
|
682
688
|
status: "pass" | "drift" | "error" | "fail";
|
|
683
|
-
kind: "flow_replay" | "manual";
|
|
684
689
|
at: number;
|
|
690
|
+
kind: "flow_replay" | "manual";
|
|
685
691
|
name: string;
|
|
686
692
|
durationMs?: number | undefined;
|
|
687
693
|
evidence?: {
|
|
@@ -699,8 +705,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
699
705
|
}, {
|
|
700
706
|
runs: {
|
|
701
707
|
status: "pass" | "drift" | "error" | "fail";
|
|
702
|
-
kind: "flow_replay" | "manual";
|
|
703
708
|
at: number;
|
|
709
|
+
kind: "flow_replay" | "manual";
|
|
704
710
|
name: string;
|
|
705
711
|
durationMs?: number | undefined;
|
|
706
712
|
evidence?: {
|
|
@@ -764,6 +770,40 @@ export declare const AnnotationSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObj
|
|
|
764
770
|
statePath: string;
|
|
765
771
|
store?: string | undefined;
|
|
766
772
|
equals?: unknown;
|
|
773
|
+
}>, z.ZodObject<{
|
|
774
|
+
kind: z.ZodLiteral<"assert-net">;
|
|
775
|
+
net: z.ZodObject<{
|
|
776
|
+
method: z.ZodOptional<z.ZodString>;
|
|
777
|
+
urlContains: z.ZodOptional<z.ZodString>;
|
|
778
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
779
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
780
|
+
}, "strip", z.ZodTypeAny, {
|
|
781
|
+
status?: number | undefined;
|
|
782
|
+
method?: string | undefined;
|
|
783
|
+
count?: number | undefined;
|
|
784
|
+
urlContains?: string | undefined;
|
|
785
|
+
}, {
|
|
786
|
+
status?: number | undefined;
|
|
787
|
+
method?: string | undefined;
|
|
788
|
+
count?: number | undefined;
|
|
789
|
+
urlContains?: string | undefined;
|
|
790
|
+
}>;
|
|
791
|
+
}, "strip", z.ZodTypeAny, {
|
|
792
|
+
kind: "assert-net";
|
|
793
|
+
net: {
|
|
794
|
+
status?: number | undefined;
|
|
795
|
+
method?: string | undefined;
|
|
796
|
+
count?: number | undefined;
|
|
797
|
+
urlContains?: string | undefined;
|
|
798
|
+
};
|
|
799
|
+
}, {
|
|
800
|
+
kind: "assert-net";
|
|
801
|
+
net: {
|
|
802
|
+
status?: number | undefined;
|
|
803
|
+
method?: string | undefined;
|
|
804
|
+
count?: number | undefined;
|
|
805
|
+
urlContains?: string | undefined;
|
|
806
|
+
};
|
|
767
807
|
}>, z.ZodObject<{
|
|
768
808
|
kind: z.ZodLiteral<"mark-dynamic">;
|
|
769
809
|
testid: z.ZodString;
|
|
@@ -863,6 +903,14 @@ export type AnnotateResult = {
|
|
|
863
903
|
ok: true;
|
|
864
904
|
target: AnnotationTarget;
|
|
865
905
|
compiled: string;
|
|
906
|
+
/**
|
|
907
|
+
* Set when the compiled annotation is NOT something a replay evaluates, so `compiled` on its
|
|
908
|
+
* own would overstate it. `assert-signal` writes a STEP expect, and replay checks exactly two
|
|
909
|
+
* things per step — element presence and state — so a step signal is recorded and then never
|
|
910
|
+
* checked. Saying "will assert signal X" and passing regardless is a false green in the
|
|
911
|
+
* feature whose whole job is to catch them.
|
|
912
|
+
*/
|
|
913
|
+
note?: string;
|
|
866
914
|
}
|
|
867
915
|
/**
|
|
868
916
|
* A failure carries its own way out. `code` alone told the caller WHAT was wrong and never what to
|
package/dist/types.js
CHANGED
|
@@ -127,6 +127,18 @@ export const AnnotationSchema = z.discriminatedUnion('kind', [
|
|
|
127
127
|
store: z.string().min(1).optional(),
|
|
128
128
|
equals: z.unknown().optional(),
|
|
129
129
|
}),
|
|
130
|
+
z.object({
|
|
131
|
+
kind: z.literal(AnnotationKind.ASSERT_NET),
|
|
132
|
+
// Same shape SUCCESS_STATE already accepts, so one vocabulary describes a network consequence
|
|
133
|
+
// whether it gates a step or ends the flow. `count` is the point of it: presence says the
|
|
134
|
+
// request fired, cardinality catches the double-submit that fired it twice.
|
|
135
|
+
net: z.object({
|
|
136
|
+
method: z.string().min(1).optional(),
|
|
137
|
+
urlContains: z.string().min(1).optional(),
|
|
138
|
+
status: z.number().optional(),
|
|
139
|
+
count: z.number().int().nonnegative().optional(),
|
|
140
|
+
}),
|
|
141
|
+
}),
|
|
130
142
|
z.object({
|
|
131
143
|
kind: z.literal(AnnotationKind.MARK_DYNAMIC),
|
|
132
144
|
testid: z.string().min(1),
|
package/dist/upgrade.js
CHANGED
|
@@ -53,7 +53,7 @@ export const UpgradeHintSchema = z.object({
|
|
|
53
53
|
});
|
|
54
54
|
/** Narrow an unknown wire value to a CloudCapability. */
|
|
55
55
|
export function isCloudCapability(value) {
|
|
56
|
-
return typeof value
|
|
56
|
+
return 'string' === typeof value && Object.values(CloudCapability).includes(value);
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Canned, honest copy per capability. Kept here (not inlined at emit sites) so the tone is reviewed in
|