@reticlehq/core 2.14.0 → 3.2.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.
Files changed (148) hide show
  1. package/dist/{artifacts-entry.d.ts → artifacts/artifacts-entry.d.ts} +7 -7
  2. package/dist/{artifacts-entry.js → artifacts/artifacts-entry.js} +7 -7
  3. package/dist/artifacts/flow-composition.d.ts +30 -0
  4. package/dist/artifacts/flow-composition.js +19 -0
  5. package/dist/{flow-constants.d.ts → artifacts/flow-constants.d.ts} +99 -3
  6. package/dist/{flow-constants.js → artifacts/flow-constants.js} +108 -4
  7. package/dist/artifacts/flow-mutation-target.d.ts +39 -0
  8. package/dist/artifacts/flow-mutation-target.js +89 -0
  9. package/dist/artifacts/flow-order.d.ts +30 -0
  10. package/dist/artifacts/flow-order.js +49 -0
  11. package/dist/artifacts/flow-select.d.ts +56 -0
  12. package/dist/artifacts/flow-select.js +56 -0
  13. package/dist/artifacts/flow-step-tool.d.ts +31 -0
  14. package/dist/artifacts/flow-step-tool.js +31 -0
  15. package/dist/artifacts/flow-types.d.ts +3736 -0
  16. package/dist/artifacts/flow-types.js +463 -0
  17. package/dist/artifacts/flow-unreached.d.ts +12 -0
  18. package/dist/artifacts/flow-unreached.js +24 -0
  19. package/dist/{impact.d.ts → artifacts/impact.d.ts} +271 -103
  20. package/dist/{impact.js → artifacts/impact.js} +75 -5
  21. package/dist/artifacts/journal.d.ts +218 -0
  22. package/dist/artifacts/journal.js +130 -0
  23. package/dist/artifacts/step-effect.d.ts +29 -0
  24. package/dist/artifacts/step-effect.js +28 -0
  25. package/dist/hooks/hook-events.d.ts +311 -0
  26. package/dist/hooks/hook-events.js +127 -0
  27. package/dist/hooks/hooks-entry.d.ts +9 -0
  28. package/dist/hooks/hooks-entry.js +9 -0
  29. package/dist/identity/brand.d.ts +102 -0
  30. package/dist/{brand.js → identity/brand.js} +7 -0
  31. package/dist/{contract-fingerprint.d.ts → identity/contract-fingerprint.d.ts} +21 -3
  32. package/dist/{contract-fingerprint.js → identity/contract-fingerprint.js} +22 -4
  33. package/dist/{document-identity.d.ts → identity/document-identity.d.ts} +4 -5
  34. package/dist/{document-identity.js → identity/document-identity.js} +4 -5
  35. package/dist/{source-constants.d.ts → identity/source-constants.d.ts} +4 -4
  36. package/dist/{source-constants.js → identity/source-constants.js} +4 -4
  37. package/dist/index.d.ts +57 -43
  38. package/dist/index.js +66 -45
  39. package/dist/onboarding.d.ts +114 -0
  40. package/dist/onboarding.js +141 -0
  41. package/dist/realm/registry.d.ts +212 -0
  42. package/dist/realm/registry.js +302 -0
  43. package/dist/{dev-server-registry.d.ts → registry/dev-server-registry.d.ts} +6 -7
  44. package/dist/{dev-server-registry.js → registry/dev-server-registry.js} +28 -19
  45. package/dist/{project-registry.d.ts → registry/project-registry.d.ts} +5 -5
  46. package/dist/{project-registry.js → registry/project-registry.js} +5 -5
  47. package/dist/schema/command-name.json +31 -0
  48. package/dist/schema/event-payloads.json +795 -0
  49. package/dist/schema/hello-message.json +70 -2
  50. package/dist/schema/reticle-message.json +70 -2
  51. package/dist/telemetry-entry.d.ts +1 -1
  52. package/dist/telemetry-entry.js +1 -1
  53. package/dist/telemetry-feedback.d.ts +15 -16
  54. package/dist/telemetry-feedback.js +11 -12
  55. package/dist/telemetry-license.d.ts +1 -1
  56. package/dist/telemetry-license.js +1 -1
  57. package/dist/telemetry-refusal.d.ts +11 -11
  58. package/dist/telemetry-refusal.js +7 -8
  59. package/dist/telemetry-session.d.ts +51 -59
  60. package/dist/telemetry-session.js +47 -55
  61. package/dist/telemetry.d.ts +306 -222
  62. package/dist/telemetry.js +112 -99
  63. package/dist/tour-entry.d.ts +10 -0
  64. package/dist/tour-entry.js +10 -0
  65. package/dist/tour.d.ts +125 -0
  66. package/dist/tour.js +165 -0
  67. package/dist/{consequence.d.ts → verdict/consequence.d.ts} +32 -15
  68. package/dist/{consequence.js → verdict/consequence.js} +9 -31
  69. package/dist/{finding-fingerprint.js → verdict/finding-fingerprint.js} +1 -1
  70. package/dist/{findings.d.ts → verdict/findings.d.ts} +86 -39
  71. package/dist/{findings.js → verdict/findings.js} +103 -49
  72. package/dist/{instrumentation-gap.d.ts → verdict/instrumentation-gap.d.ts} +7 -14
  73. package/dist/{instrumentation-gap.js → verdict/instrumentation-gap.js} +7 -15
  74. package/dist/{intent.d.ts → verdict/intent.d.ts} +35 -46
  75. package/dist/{intent.js → verdict/intent.js} +11 -22
  76. package/dist/verdict/revision.d.ts +44 -0
  77. package/dist/verdict/revision.js +53 -0
  78. package/dist/{run-context.d.ts → verdict/run-context.d.ts} +13 -34
  79. package/dist/{run-context.js → verdict/run-context.js} +15 -36
  80. package/dist/{security.js → verdict/security.js} +12 -21
  81. package/dist/{verification-run.d.ts → verdict/verification-run.d.ts} +381 -105
  82. package/dist/{verification-run.js → verdict/verification-run.js} +157 -21
  83. package/dist/{verified-constants.d.ts → verdict/verified-constants.d.ts} +34 -13
  84. package/dist/{verified-constants.js → verdict/verified-constants.js} +34 -13
  85. package/dist/{verify-progress.d.ts → verdict/verify-progress.d.ts} +18 -22
  86. package/dist/{verify-progress.js → verdict/verify-progress.js} +6 -10
  87. package/dist/wire/channel.d.ts +46 -0
  88. package/dist/wire/channel.js +95 -0
  89. package/dist/{constants.d.ts → wire/constants/constants.d.ts} +179 -28
  90. package/dist/{constants.js → wire/constants/constants.js} +199 -28
  91. package/dist/{session-constants.d.ts → wire/constants/session-constants.d.ts} +23 -2
  92. package/dist/{session-constants.js → wire/constants/session-constants.js} +23 -2
  93. package/dist/{desktop-contract.js → wire/desktop-contract.js} +1 -1
  94. package/dist/{event-classification.js → wire/event-classification.js} +1 -1
  95. package/dist/{event-payloads.d.ts → wire/event-payloads.d.ts} +72 -13
  96. package/dist/{event-payloads.js → wire/event-payloads.js} +23 -3
  97. package/dist/{event-priority.d.ts → wire/event-priority.d.ts} +1 -4
  98. package/dist/{event-priority.js → wire/event-priority.js} +2 -5
  99. package/dist/{global-press.js → wire/global-press.js} +1 -1
  100. package/dist/{messages.d.ts → wire/messages.d.ts} +240 -48
  101. package/dist/{messages.js → wire/messages.js} +68 -5
  102. package/dist/wire/narrow.d.ts +39 -0
  103. package/dist/wire/narrow.js +45 -0
  104. package/dist/{net.d.ts → wire/net.d.ts} +36 -13
  105. package/dist/{net.js → wire/net.js} +36 -13
  106. package/dist/wire/platform.d.ts +37 -0
  107. package/dist/wire/platform.js +36 -0
  108. package/dist/{redaction.js → wire/redaction.js} +12 -12
  109. package/dist/wire/snapshot-tree.d.ts +33 -0
  110. package/dist/wire/snapshot-tree.js +43 -0
  111. package/dist/wire/tool-names.d.ts +133 -0
  112. package/dist/wire/tool-names.js +142 -0
  113. package/dist/{toon.js → wire/toon.js} +1 -1
  114. package/dist/{types.d.ts → wire/types.d.ts} +77 -76
  115. package/dist/{types.js → wire/types.js} +4 -3
  116. package/dist/{no-session-reason.d.ts → words/no-session-reason.d.ts} +7 -3
  117. package/dist/{no-session-reason.js → words/no-session-reason.js} +7 -3
  118. package/dist/{notices.d.ts → words/notices.d.ts} +8 -12
  119. package/dist/{notices.js → words/notices.js} +8 -12
  120. package/package.json +16 -7
  121. package/dist/brand.d.ts +0 -49
  122. package/dist/flow-types.d.ts +0 -1711
  123. package/dist/flow-types.js +0 -247
  124. package/dist/journal.d.ts +0 -122
  125. package/dist/journal.js +0 -57
  126. package/dist/{impact-savings.d.ts → artifacts/impact-savings.d.ts} +0 -0
  127. package/dist/{impact-savings.js → artifacts/impact-savings.js} +0 -0
  128. package/dist/{edit-epoch.d.ts → identity/edit-epoch.d.ts} +0 -0
  129. package/dist/{edit-epoch.js → identity/edit-epoch.js} +0 -0
  130. package/dist/{project-id.d.ts → identity/project-id.d.ts} +0 -0
  131. package/dist/{project-id.js → identity/project-id.js} +0 -0
  132. package/dist/{daemon-registry.d.ts → registry/daemon-registry.d.ts} +0 -0
  133. package/dist/{daemon-registry.js → registry/daemon-registry.js} +0 -0
  134. package/dist/{finding-fingerprint.d.ts → verdict/finding-fingerprint.d.ts} +0 -0
  135. package/dist/{security.d.ts → verdict/security.d.ts} +0 -0
  136. package/dist/{desktop-contract.d.ts → wire/desktop-contract.d.ts} +0 -0
  137. package/dist/{event-classification.d.ts → wire/event-classification.d.ts} +0 -0
  138. package/dist/{global-press.d.ts → wire/global-press.d.ts} +0 -0
  139. package/dist/{redaction.d.ts → wire/redaction.d.ts} +0 -0
  140. package/dist/{state-select.d.ts → wire/state-select.d.ts} +0 -0
  141. package/dist/{state-select.js → wire/state-select.js} +0 -0
  142. package/dist/{toon.d.ts → wire/toon.d.ts} +0 -0
  143. package/dist/{browser-misdirect.d.ts → words/browser-misdirect.d.ts} +0 -0
  144. package/dist/{browser-misdirect.js → words/browser-misdirect.js} +0 -0
  145. package/dist/{unreachable-notice.d.ts → words/unreachable-notice.d.ts} +0 -0
  146. package/dist/{unreachable-notice.js → words/unreachable-notice.js} +0 -0
  147. package/dist/{upgrade.d.ts → words/upgrade.d.ts} +2 -2
  148. /package/dist/{upgrade.js → words/upgrade.js} +0 -0
@@ -1,9 +1,11 @@
1
1
  import { z } from 'zod';
2
- import { EventAttribution, EventType, RETICLE_PROTOCOL_VERSION, MessageKind, TRANSPORT_LIMITS, } from './constants.js';
3
- import { HumanControlKind, MarkAnchorStrategy } from './session-constants.js';
2
+ import { EventAttribution, EventType, RETICLE_MIN_PROTOCOL_VERSION, RETICLE_PROTOCOL_VERSION, MessageKind, TRANSPORT_LIMITS, } from './constants/constants.js';
3
+ import { HumanControlKind, MarkAnchorStrategy } from './constants/session-constants.js';
4
4
  import { MAX_WIRE_REDACT_KEYS, MAX_WIRE_REDACT_KEY_LENGTH } from './redaction.js';
5
- import { DOCUMENT_ID_LENGTH } from './document-identity.js';
6
- import { NO_EDITS_OBSERVED } from './edit-epoch.js';
5
+ import { DOCUMENT_ID_LENGTH } from '../identity/document-identity.js';
6
+ import { NO_EDITS_OBSERVED } from '../identity/edit-epoch.js';
7
+ import { PlatformProfile } from './platform.js';
8
+ import { ChannelId } from './channel.js';
7
9
  const sessionIdSchema = z.string().min(1).max(TRANSPORT_LIMITS.MAX_SESSION_ID_LENGTH);
8
10
  const refSchema = z.string().max(TRANSPORT_LIMITS.MAX_REF_LENGTH);
9
11
  const documentIdSchema = z.string().min(1).max(DOCUMENT_ID_LENGTH);
@@ -88,7 +90,16 @@ export const ReticleEventSchema = z.object({
88
90
  /** Browser announces itself to the bridge on connect. */
89
91
  export const HelloMessageSchema = z.object({
90
92
  kind: z.literal(MessageKind.HELLO),
91
- protocolVersion: z.literal(RETICLE_PROTOCOL_VERSION),
93
+ /**
94
+ * The wire protocol this peer speaks.
95
+ *
96
+ * A RANGE, not a fixed number. An exact match is right while both halves ship together and wrong
97
+ * as soon as anything else implements this: a peer one version behind is not incompatible, it is
98
+ * behind. The bridge accepts anything from the oldest version it still talks to up to its own.
99
+ *
100
+ * Out of range is still a hard door, with the diagnostics that already name which side is stale.
101
+ */
102
+ protocolVersion: z.number().int().min(RETICLE_MIN_PROTOCOL_VERSION).max(RETICLE_PROTOCOL_VERSION),
92
103
  sessionId: sessionIdSchema,
93
104
  url: z.string().max(TRANSPORT_LIMITS.MAX_URL_LENGTH),
94
105
  title: z.string().max(TRANSPORT_LIMITS.MAX_TITLE_LENGTH),
@@ -104,6 +115,58 @@ export const HelloMessageSchema = z.object({
104
115
  .max(TRANSPORT_LIMITS.MAX_ADAPTERS),
105
116
  /** Optional browser/bridge pairing token. Required when the bridge configures one. */
106
117
  token: z.string().max(TRANSPORT_LIMITS.MAX_TOKEN_LENGTH).optional(),
118
+ /**
119
+ * What kind of surface this is: a browser document, a web page in somebody else's window, a
120
+ * native view tree, or no rendering surface at all. See platform.ts.
121
+ *
122
+ * ABSENT MEANS `web`, never "unknown". Everything that connected before this field existed was a
123
+ * browser document, so absence is not a gap -- it is the answer those connections would have
124
+ * given. This is the same convention five other fields on this message already use.
125
+ *
126
+ * It is deliberately not the shell name. Electron and Tauri are two shells and one surface, and
127
+ * verification wants the surface: the question being asked is what can be demanded of you, not
128
+ * which product you are.
129
+ */
130
+ platform: z.nativeEnum(PlatformProfile).optional(),
131
+ /**
132
+ * The channels this build can actually observe. See channel.ts.
133
+ *
134
+ * ABSENT MEANS "everything", not "nothing" -- an SDK built before this field existed watched
135
+ * whatever it watched, and reading its silence as "observes nothing" would refuse every claim it
136
+ * makes. Same convention as every other optional field on this message.
137
+ *
138
+ * A closed list rather than free strings, because the rule that refuses a claim reading an
139
+ * undeclared channel has to switch on these. Commands below are free strings for the opposite
140
+ * reason: nothing switches on them, and command names are already opaque on this wire.
141
+ */
142
+ channels: z.array(z.nativeEnum(ChannelId)).max(TRANSPORT_LIMITS.MAX_ADAPTERS).optional(),
143
+ /**
144
+ * The commands this build can serve.
145
+ *
146
+ * Absent means "assume the usual set". Present and missing a name means asking for it is a
147
+ * mistake somebody can be told about before they spend an action on it, rather than after.
148
+ */
149
+ commands: z
150
+ .array(z.string().max(TRANSPORT_LIMITS.MAX_TOKEN_LENGTH))
151
+ .max(TRANSPORT_LIMITS.MAX_ADAPTERS)
152
+ .optional(),
153
+ /**
154
+ * The wire names this peer actually speaks, so compatibility can be judged name by name.
155
+ *
156
+ * The fingerprint beside it is a hash over the whole vocabulary: it can say "same" or "different"
157
+ * and nothing else. An implementation that speaks part of the contract -- which is the right thing
158
+ * for anything that is not a browser to do -- can never produce a matching hash, and was therefore
159
+ * reported as skewed on every call forever.
160
+ *
161
+ * Absent means "compare the fingerprint", which is what a build predating this field does.
162
+ */
163
+ contractParts: z
164
+ .object({
165
+ commands: z.array(z.string()).max(TRANSPORT_LIMITS.MAX_CONTRACT_NAMES),
166
+ events: z.array(z.string()).max(TRANSPORT_LIMITS.MAX_CONTRACT_NAMES),
167
+ actions: z.array(z.string()).max(TRANSPORT_LIMITS.MAX_CONTRACT_NAMES),
168
+ })
169
+ .optional(),
107
170
  /** Whether the app has advertised a capability registry (reticle.describe). */
108
171
  hasCapabilities: z.boolean().optional(),
109
172
  /**
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Reading a value off the wire without trusting it.
3
+ *
4
+ * Everything that arrives from a page, a config file or an agent's arguments is `unknown` until
5
+ * something checks it. These are that check, in the smallest form: give me the string if it is a
6
+ * string, and nothing if it is not.
7
+ *
8
+ * They lived under `tools/` in the server package, because a tool handler was the first thing that
9
+ * needed them. Nothing about them is a tool: the rules that decide a verdict use them, the session
10
+ * uses them, the command line uses them. A helper filed under where it was first needed rather than
11
+ * what it does is a helper that drags its old neighbourhood along behind it, and this one was
12
+ * dragging the whole tool surface into the verdict engine.
13
+ *
14
+ * `undefined` for a value of the wrong type, never a default. A number that arrives as the string
15
+ * "12" is not a number, and quietly making it one is how a wire mistake becomes a wrong answer that
16
+ * nothing reports.
17
+ */
18
+ /** The value if it is a string, otherwise nothing. */
19
+ export declare function asString(value: unknown): string | undefined;
20
+ /**
21
+ * The value if it is a number, otherwise nothing.
22
+ *
23
+ * `NaN` and `Infinity` pass, because `typeof NaN` is `'number'`. That is worth knowing rather than
24
+ * quietly fixing here: this moved out of the server unchanged, and tightening it in the same commit
25
+ * would be a behaviour change wearing a refactor's message. If a caller needs a finite number it
26
+ * should say so where it reads the value.
27
+ */
28
+ export declare function asNumber(value: unknown): number | undefined;
29
+ /**
30
+ * The value if it is an object, otherwise an empty one.
31
+ *
32
+ * The odd one out: it answers with `{}` rather than `undefined`, because every caller is about to
33
+ * read a key off it and an empty object gives them `undefined` for free.
34
+ *
35
+ * An ARRAY passes, because an array is an object to JavaScript. Almost certainly not what a caller
36
+ * reaching for a named key meant, and left exactly as it was for the same reason as above: this is a
37
+ * move, and a move that also changes behaviour is two changes wearing one message.
38
+ */
39
+ export declare function asRecord(value: unknown): Record<string, unknown>;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Reading a value off the wire without trusting it.
3
+ *
4
+ * Everything that arrives from a page, a config file or an agent's arguments is `unknown` until
5
+ * something checks it. These are that check, in the smallest form: give me the string if it is a
6
+ * string, and nothing if it is not.
7
+ *
8
+ * They lived under `tools/` in the server package, because a tool handler was the first thing that
9
+ * needed them. Nothing about them is a tool: the rules that decide a verdict use them, the session
10
+ * uses them, the command line uses them. A helper filed under where it was first needed rather than
11
+ * what it does is a helper that drags its old neighbourhood along behind it, and this one was
12
+ * dragging the whole tool surface into the verdict engine.
13
+ *
14
+ * `undefined` for a value of the wrong type, never a default. A number that arrives as the string
15
+ * "12" is not a number, and quietly making it one is how a wire mistake becomes a wrong answer that
16
+ * nothing reports.
17
+ */
18
+ /** The value if it is a string, otherwise nothing. */
19
+ export function asString(value) {
20
+ return 'string' === typeof value ? value : undefined;
21
+ }
22
+ /**
23
+ * The value if it is a number, otherwise nothing.
24
+ *
25
+ * `NaN` and `Infinity` pass, because `typeof NaN` is `'number'`. That is worth knowing rather than
26
+ * quietly fixing here: this moved out of the server unchanged, and tightening it in the same commit
27
+ * would be a behaviour change wearing a refactor's message. If a caller needs a finite number it
28
+ * should say so where it reads the value.
29
+ */
30
+ export function asNumber(value) {
31
+ return 'number' === typeof value ? value : undefined;
32
+ }
33
+ /**
34
+ * The value if it is an object, otherwise an empty one.
35
+ *
36
+ * The odd one out: it answers with `{}` rather than `undefined`, because every caller is about to
37
+ * read a key off it and an empty object gives them `undefined` for free.
38
+ *
39
+ * An ARRAY passes, because an array is an object to JavaScript. Almost certainly not what a caller
40
+ * reaching for a named key meant, and left exactly as it was for the same reason as above: this is a
41
+ * move, and a move that also changes behaviour is two changes wearing one message.
42
+ */
43
+ export function asRecord(value) {
44
+ return 'object' === typeof value && value !== null ? value : {};
45
+ }
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Network-call vocabulary shared by the browser SDK and the server. Split out of constants.ts to
3
- * keep that file under the size cap.
2
+ * Network-call vocabulary shared by the browser SDK and the server.
4
3
  */
5
4
  /**
6
5
  * What issued a network-shaped call. Desktop apps (Electron, Tauri) reach their backend over IPC
@@ -17,9 +16,9 @@ export declare const NetInitiator: {
17
16
  *
18
17
  * A server-rendered app answers a click with a full document load: the old document is torn down
19
18
  * with the SDK inside it, and the SDK comes back up in a page whose defining request happened
20
- * before it existed. No patched transport could have seen it, so the net channel had no record of
21
- * it at all — a Django MPA click was verified on route and heading while the `net` clause naming
22
- * the destination MISSED, and the verdict came back `unknown`.
19
+ * before it existed. No patched transport could have seen it, so without this initiator the net
20
+ * channel has no record of it at all: a `net` clause naming the destination MISSES and the verdict
21
+ * comes back `unknown` even though route and heading verified.
23
22
  *
24
23
  * DISTINCT FROM the document-INITIATED subresource initiators (`link`, `css`, `img`, `script`,
25
24
  * `manifest`, `other`) that the resource-timing observer stamps. Those prove that observer is
@@ -74,19 +73,19 @@ export declare const IpcStatus: {
74
73
  * `202 Accepted` — the server took the request and has NOT finished processing it.
75
74
  *
76
75
  * The only status in HTTP whose meaning is "no outcome yet". Folding it into the 2xx success band is
77
- * how an asynchronous workflow gets verified at exactly the moment nothing has been decided:
78
- * measured on a logistics console, a dispatch answered 202, the UI rendered success, the page
79
- * settled, and the server reverted the shipment 1.2s later.
76
+ * how an asynchronous workflow gets verified at exactly the moment nothing has been decided: a
77
+ * dispatch answers 202, the UI renders success, the page settles, and the server reverts the write
78
+ * a second later.
80
79
  */
81
80
  export declare const HTTP_ACCEPTED = 202;
82
81
  /**
83
82
  * Traffic the DEV TOOLCHAIN makes about itself — never the app under test.
84
83
  *
85
- * A CLOSED list, deliberately. Reported from a real drive: a correct Next.js navigation graded
86
- * `verified: "no"` because the dev overlay was fetching a source map for an unrelated React key
87
- * warning (`POST /__nextjs_original-stack-frames`), and that in-flight request counted as "the UI
88
- * advanced over a request that never settled". Every app that logs one dev warning got a false
89
- * negative on every action — the worst defect class after a false green.
84
+ * A CLOSED list, deliberately. Without it a correct navigation grades `verified: "no"` because the
85
+ * dev overlay is fetching a source map for an unrelated React warning (`POST
86
+ * /__nextjs_original-stack-frames`) and that in-flight request counts as "the UI advanced over a
87
+ * request that never settled" — a false negative on every action in any app that logs one dev
88
+ * warning.
90
89
  *
91
90
  * The rule for adding an entry: it must be a channel the FRAMEWORK owns, that no application route
92
91
  * can occupy, and that fires as a consequence of running in dev rather than of anything the user
@@ -153,3 +152,27 @@ export declare const URL_RAW = "urlRaw";
153
152
  * otherwise the displayed (possibly redacted) `url`.
154
153
  */
155
154
  export declare function urlForMatch(data: Record<string, unknown>): string;
155
+ /**
156
+ * The NET_REQUEST field carrying a DISCRIMINATOR for the request body.
157
+ *
158
+ * `duplicate-request` asks whether two writes in one action's window were the same write. Method
159
+ * plus URL cannot answer that — a command-bus API posts every mutation to one endpoint, and a
160
+ * submit that intentionally saves and then advances sends two different payloads to the same URL —
161
+ * and the body that could answer it is not on the record: capturing bodies by default would put
162
+ * passwords, tokens and customer data on the wire for every request an app makes.
163
+ *
164
+ * So the page sends a fingerprint of the body's SHAPE instead: key names, value types and the total
165
+ * length, hashed. It is equal for two identical payloads and different for two payloads that differ
166
+ * in structure or size, which is all the rule needs, and it is not a projection of the payload —
167
+ * no character of any value is ever read into it, so there is nothing in it to recover.
168
+ */
169
+ export declare const REQUEST_SHAPE_FIELD = "requestShape";
170
+ /**
171
+ * The fingerprint of a request that carried NO body.
172
+ *
173
+ * A KNOWN discriminator, not a missing one: two bodyless POSTs to one URL are indistinguishable to
174
+ * the server too, so they are allowed to be a duplicate. A body the page cannot read as text
175
+ * (FormData, Blob, a stream) omits the field ALTOGETHER, which is the same statement an older SDK
176
+ * makes by not sending it: a body may have existed and nothing about it is on the record.
177
+ */
178
+ export declare const REQUEST_SHAPE_NONE = "none";
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Network-call vocabulary shared by the browser SDK and the server. Split out of constants.ts to
3
- * keep that file under the size cap.
2
+ * Network-call vocabulary shared by the browser SDK and the server.
4
3
  */
5
4
  /**
6
5
  * What issued a network-shaped call. Desktop apps (Electron, Tauri) reach their backend over IPC
@@ -17,9 +16,9 @@ export const NetInitiator = {
17
16
  *
18
17
  * A server-rendered app answers a click with a full document load: the old document is torn down
19
18
  * with the SDK inside it, and the SDK comes back up in a page whose defining request happened
20
- * before it existed. No patched transport could have seen it, so the net channel had no record of
21
- * it at all — a Django MPA click was verified on route and heading while the `net` clause naming
22
- * the destination MISSED, and the verdict came back `unknown`.
19
+ * before it existed. No patched transport could have seen it, so without this initiator the net
20
+ * channel has no record of it at all: a `net` clause naming the destination MISSES and the verdict
21
+ * comes back `unknown` even though route and heading verified.
23
22
  *
24
23
  * DISTINCT FROM the document-INITIATED subresource initiators (`link`, `css`, `img`, `script`,
25
24
  * `manifest`, `other`) that the resource-timing observer stamps. Those prove that observer is
@@ -73,19 +72,19 @@ export const IpcStatus = {
73
72
  * `202 Accepted` — the server took the request and has NOT finished processing it.
74
73
  *
75
74
  * The only status in HTTP whose meaning is "no outcome yet". Folding it into the 2xx success band is
76
- * how an asynchronous workflow gets verified at exactly the moment nothing has been decided:
77
- * measured on a logistics console, a dispatch answered 202, the UI rendered success, the page
78
- * settled, and the server reverted the shipment 1.2s later.
75
+ * how an asynchronous workflow gets verified at exactly the moment nothing has been decided: a
76
+ * dispatch answers 202, the UI renders success, the page settles, and the server reverts the write
77
+ * a second later.
79
78
  */
80
79
  export const HTTP_ACCEPTED = 202;
81
80
  /**
82
81
  * Traffic the DEV TOOLCHAIN makes about itself — never the app under test.
83
82
  *
84
- * A CLOSED list, deliberately. Reported from a real drive: a correct Next.js navigation graded
85
- * `verified: "no"` because the dev overlay was fetching a source map for an unrelated React key
86
- * warning (`POST /__nextjs_original-stack-frames`), and that in-flight request counted as "the UI
87
- * advanced over a request that never settled". Every app that logs one dev warning got a false
88
- * negative on every action — the worst defect class after a false green.
83
+ * A CLOSED list, deliberately. Without it a correct navigation grades `verified: "no"` because the
84
+ * dev overlay is fetching a source map for an unrelated React warning (`POST
85
+ * /__nextjs_original-stack-frames`) and that in-flight request counts as "the UI advanced over a
86
+ * request that never settled" — a false negative on every action in any app that logs one dev
87
+ * warning.
89
88
  *
90
89
  * The rule for adding an entry: it must be a channel the FRAMEWORK owns, that no application route
91
90
  * can occupy, and that fires as a consequence of running in dev rather than of anything the user
@@ -208,3 +207,27 @@ export function urlForMatch(data) {
208
207
  const url = data['url'];
209
208
  return 'string' === typeof url ? url : '';
210
209
  }
210
+ /**
211
+ * The NET_REQUEST field carrying a DISCRIMINATOR for the request body.
212
+ *
213
+ * `duplicate-request` asks whether two writes in one action's window were the same write. Method
214
+ * plus URL cannot answer that — a command-bus API posts every mutation to one endpoint, and a
215
+ * submit that intentionally saves and then advances sends two different payloads to the same URL —
216
+ * and the body that could answer it is not on the record: capturing bodies by default would put
217
+ * passwords, tokens and customer data on the wire for every request an app makes.
218
+ *
219
+ * So the page sends a fingerprint of the body's SHAPE instead: key names, value types and the total
220
+ * length, hashed. It is equal for two identical payloads and different for two payloads that differ
221
+ * in structure or size, which is all the rule needs, and it is not a projection of the payload —
222
+ * no character of any value is ever read into it, so there is nothing in it to recover.
223
+ */
224
+ export const REQUEST_SHAPE_FIELD = 'requestShape';
225
+ /**
226
+ * The fingerprint of a request that carried NO body.
227
+ *
228
+ * A KNOWN discriminator, not a missing one: two bodyless POSTs to one URL are indistinguishable to
229
+ * the server too, so they are allowed to be a duplicate. A body the page cannot read as text
230
+ * (FormData, Blob, a stream) omits the field ALTOGETHER, which is the same statement an older SDK
231
+ * makes by not sending it: a body may have existed and nothing about it is on the record.
232
+ */
233
+ export const REQUEST_SHAPE_NONE = 'none';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * What kind of surface an app presents, which decides what can be demanded of it.
3
+ *
4
+ * This is deliberately NOT the list of shells. "Which shell is this" -- a browser, Electron, Tauri --
5
+ * is a question about what somebody is using, and it belongs to the usage contract. "What kind of
6
+ * surface is this" is a question about what can be observed, and it is the one verification needs.
7
+ *
8
+ * Electron and Tauri are two different products and one kind of surface: a web page inside a native
9
+ * window. Code that branched on the shell had to name both, and would have to name a third that
10
+ * behaved identically. Code that branches on the surface names `webview` once.
11
+ *
12
+ * There are no dependencies here on purpose. A third-party implementation says which of these it is
13
+ * and needs nothing from this package to say it.
14
+ *
15
+ * Absent on the wire means `web`. That is the back-compat convention used throughout the handshake:
16
+ * a field nobody sent means what everything meant before the field existed.
17
+ */
18
+ export declare const PlatformProfile: {
19
+ /** A browser document. The page owns the window. */
20
+ readonly WEB: "web";
21
+ /**
22
+ * A web page inside something else's window: Electron's renderer, Tauri, Capacitor, a React
23
+ * Native WebView. It renders like the web and the window around it is not ours.
24
+ */
25
+ readonly WEBVIEW: "webview";
26
+ /**
27
+ * A native view tree -- iOS, Android, Flutter. There are elements and they are not DOM nodes, so
28
+ * anything that assumes a document is wrong here.
29
+ */
30
+ readonly NATIVE: "native";
31
+ /**
32
+ * No rendering surface at all: a job, a worker, an API. It can still be observed and it can still
33
+ * be asserted about; it just cannot be looked at or photographed.
34
+ */
35
+ readonly SERVICE: "service";
36
+ };
37
+ export type PlatformProfile = (typeof PlatformProfile)[keyof typeof PlatformProfile];
@@ -0,0 +1,36 @@
1
+ /**
2
+ * What kind of surface an app presents, which decides what can be demanded of it.
3
+ *
4
+ * This is deliberately NOT the list of shells. "Which shell is this" -- a browser, Electron, Tauri --
5
+ * is a question about what somebody is using, and it belongs to the usage contract. "What kind of
6
+ * surface is this" is a question about what can be observed, and it is the one verification needs.
7
+ *
8
+ * Electron and Tauri are two different products and one kind of surface: a web page inside a native
9
+ * window. Code that branched on the shell had to name both, and would have to name a third that
10
+ * behaved identically. Code that branches on the surface names `webview` once.
11
+ *
12
+ * There are no dependencies here on purpose. A third-party implementation says which of these it is
13
+ * and needs nothing from this package to say it.
14
+ *
15
+ * Absent on the wire means `web`. That is the back-compat convention used throughout the handshake:
16
+ * a field nobody sent means what everything meant before the field existed.
17
+ */
18
+ export const PlatformProfile = {
19
+ /** A browser document. The page owns the window. */
20
+ WEB: 'web',
21
+ /**
22
+ * A web page inside something else's window: Electron's renderer, Tauri, Capacitor, a React
23
+ * Native WebView. It renders like the web and the window around it is not ours.
24
+ */
25
+ WEBVIEW: 'webview',
26
+ /**
27
+ * A native view tree -- iOS, Android, Flutter. There are elements and they are not DOM nodes, so
28
+ * anything that assumes a document is wrong here.
29
+ */
30
+ NATIVE: 'native',
31
+ /**
32
+ * No rendering surface at all: a job, a worker, an API. It can still be observed and it can still
33
+ * be asserted about; it just cannot be looked at or photographed.
34
+ */
35
+ SERVICE: 'service',
36
+ };
@@ -1,13 +1,12 @@
1
- import { REDACTED_VALUE } from './constants.js';
1
+ import { REDACTED_VALUE } from './constants/constants.js';
2
2
  import { URL_RAW } from './net.js';
3
3
  /**
4
4
  * Wire redaction rules — which field names carry credentials, and which VALUE shapes are secrets
5
5
  * regardless of the field they sit in.
6
6
  *
7
- * These live in core because they are a property of the wire, not of one side of it. They were
8
- * implemented in the browser SDK, which was the only consumer until the driven path began capturing
9
- * request bodies straight from the network stack — those are raw and unscrubbed, and duplicating a
10
- * security regex to redact them would be the worst possible place to have two copies drift.
7
+ * These live in core because they are a property of the wire, not of one side of it: the browser
8
+ * SDK and the driven path (which captures request bodies raw off the network stack) both redact
9
+ * with them, and a security regex is the worst possible place to have two copies drift.
11
10
  */
12
11
  // `pass[-_]?phrase` is the fourth spelling of the first three. There is no benign field called
13
12
  // `passphrase`: it is what an SSH key, a keystore, an encrypted backup and a wallet all call their
@@ -17,21 +16,22 @@ import { URL_RAW } from './net.js';
17
16
  // away, but the window in which one is useful is the window in which a drive is running, and the
18
17
  // journal is written to disk and read back later. `(otp|totp|mfa|recovery|backup)[-_]?codes?`
19
18
  // carries the camelCase spellings too, since `[-_]?` is optional and the rule is case-insensitive.
20
- // Bare `otp`/`totp` are boundary-anchored: unanchored they would fire inside ordinary words, and
21
- // this file's own history is a list of false positives that had to be walked back.
19
+ // Bare `otp`/`totp` are boundary-anchored: unanchored they fire inside ordinary words.
22
20
  // `code` on its own is deliberately NOT here — `statusCode`, `postcode`, `couponCode` and
23
21
  // `countryCode` are ordinary app data an agent needs in order to reach a verdict.
24
22
  //
25
23
  // `token` must match auth CREDENTIALS, not compound design fields. Bare/separated `token(s)` and
26
24
  // auth-prefixed tokens (accessToken, auth_token, sessionToken, …) are redacted; `colorToken`,
27
- // `backgroundToken`, `tokenCount`, `designToken` are NOT — they were false-positives that redacted
28
- // legitimate reticle_inspect/reticle_state output.
29
- // `token` must match auth CREDENTIALS, not compound design fields (see note above). `cookie` is
30
- // boundary-anchored the same way: it targets the `Cookie` / `Set-Cookie` HTTP HEADER names (which
25
+ // `backgroundToken`, `tokenCount`, `designToken` are NOT — redacting those blinds
26
+ // reticle_inspect/reticle_state to legitimate app data. `cookie` is boundary-anchored the same way: it targets the `Cookie` / `Set-Cookie` HTTP HEADER names (which
31
27
  // bundle the session credential and were the one wire payload reaching the journal + the agent
32
28
  // unredacted), NOT any key that merely contains the substring — `scopecookie`, `cookieConsent`,
33
29
  // `cookiePolicy` are legitimate app values an agent may need to read, and stay visible.
34
- const SENSITIVE_KEY = /password|passwd|passcode|pass[-_]?phrase|(?:otp|totp|mfa|recovery|backup)[-_]?codes?|(?:^|[-_])(?:otp|totp)(?=$|[-_])|secret|(?:(?:access|refresh|auth|bearer|api|id|session|csrf|client)[-_]?tokens?|(?:^|[-_])tokens?(?=$|[-_]))|session[-_]?id|(?:^|[-_])(?:sid|pwd|jwt)(?=$|[-_])|authorization|(?:^|[-_])(?:set[-_])?cookie(?=$|[-_])|api[-_]?key|access[-_]?key|private[-_]?key|client[-_]?secret|credit[-_]?card|card[-_]?number|cvv|cvc|ssn|(?:^|[-_])(?:signature|sig)$|(?:^|[-_])credential$|x-(?:amz|goog)-(?:signature|credential|security-token)$/i;
30
+ // Bare `card` and `pan` are boundary-anchored for the same reason. Without them a checkout POST
31
+ // reaches the agent as `{"planId":"team","card":"4111111111111111"}` — `credit_card` and
32
+ // `card_number` are not the only spellings, and `card` is what Stripe's own object calls it. The
33
+ // anchors keep `discard`, `cardinality` and `panel` visible.
34
+ const SENSITIVE_KEY = /password|passwd|passcode|pass[-_]?phrase|(?:otp|totp|mfa|recovery|backup)[-_]?codes?|(?:^|[-_])(?:otp|totp)(?=$|[-_])|secret|(?:(?:access|refresh|auth|bearer|api|id|session|csrf|client)[-_]?tokens?|(?:^|[-_])tokens?(?=$|[-_]))|session[-_]?id|(?:^|[-_])(?:sid|pwd|jwt)(?=$|[-_])|authorization|(?:^|[-_])(?:set[-_])?cookie(?=$|[-_])|api[-_]?key|access[-_]?key|private[-_]?key|client[-_]?secret|credit[-_]?card|card[-_]?(?:number|num|no|pan)(?=$|[-_])|(?:^|[-_])(?:card|pan)(?=$|[-_])|cvv|cvc|ssn|(?:^|[-_])(?:signature|sig)$|(?:^|[-_])credential$|x-(?:amz|goog)-(?:signature|credential|security-token)$/i;
35
35
  /**
36
36
  * The built-in rule, always available and never configurable.
37
37
  *
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Reading the snapshot tree — the one line-per-element text format the browser emits.
3
+ *
4
+ * It lives in core because it is a WIRE format: the browser writes it, and several things on the
5
+ * Node side read it back. It was previously a helper beside the MCP tool handlers, which made every
6
+ * other reader import from the tool surface to parse a string the tool surface does not own — and a
7
+ * directory guard caught exactly that the moment a second layer needed it.
8
+ *
9
+ * A line looks like:
10
+ *
11
+ * - button "Pay $42.00" (ref=e4) [disabled]
12
+ *
13
+ * Only elements carrying a `ref` can be acted on, so only those are returned.
14
+ */
15
+ /** One interactive element: its ref, and the line it came from with the ref taken out. */
16
+ export interface InteractiveItem {
17
+ ref: string;
18
+ desc: string;
19
+ }
20
+ /**
21
+ * Parse interactive elements (those with refs) out of a snapshot tree.
22
+ *
23
+ * The description used to be built with a SECOND regex, `/\s*\(ref=e\d+\)/`, whose leading `\s*`
24
+ * made it quadratic: on a line with a long run of whitespace the engine retries the unbounded
25
+ * prefix at every position before failing the literal that follows. The tree is page-derived, so
26
+ * that run is app-controlled, and CodeQL flagged it as a polynomial ReDoS on the release branch.
27
+ *
28
+ * `REF` has already located the token, so the description is the line with that exact span cut
29
+ * out. The `\s*` was NOT redundant -- it ate the gap left behind when a ref sits mid-line, and two
30
+ * pinned tests failed when it was dropped outright -- so the prefix is trimmed instead. `trimEnd`
31
+ * is a string method: same result, linear, and one fewer regex to keep in step with the first.
32
+ */
33
+ export declare function parseInteractive(tree: string): InteractiveItem[];
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Reading the snapshot tree — the one line-per-element text format the browser emits.
3
+ *
4
+ * It lives in core because it is a WIRE format: the browser writes it, and several things on the
5
+ * Node side read it back. It was previously a helper beside the MCP tool handlers, which made every
6
+ * other reader import from the tool surface to parse a string the tool surface does not own — and a
7
+ * directory guard caught exactly that the moment a second layer needed it.
8
+ *
9
+ * A line looks like:
10
+ *
11
+ * - button "Pay $42.00" (ref=e4) [disabled]
12
+ *
13
+ * Only elements carrying a `ref` can be acted on, so only those are returned.
14
+ */
15
+ const REF = /\(ref=(e\d+)\)/;
16
+ /**
17
+ * Parse interactive elements (those with refs) out of a snapshot tree.
18
+ *
19
+ * The description used to be built with a SECOND regex, `/\s*\(ref=e\d+\)/`, whose leading `\s*`
20
+ * made it quadratic: on a line with a long run of whitespace the engine retries the unbounded
21
+ * prefix at every position before failing the literal that follows. The tree is page-derived, so
22
+ * that run is app-controlled, and CodeQL flagged it as a polynomial ReDoS on the release branch.
23
+ *
24
+ * `REF` has already located the token, so the description is the line with that exact span cut
25
+ * out. The `\s*` was NOT redundant -- it ate the gap left behind when a ref sits mid-line, and two
26
+ * pinned tests failed when it was dropped outright -- so the prefix is trimmed instead. `trimEnd`
27
+ * is a string method: same result, linear, and one fewer regex to keep in step with the first.
28
+ */
29
+ export function parseInteractive(tree) {
30
+ const items = [];
31
+ for (const line of tree.split('\n')) {
32
+ const match = REF.exec(line);
33
+ if (match !== null) {
34
+ const token = match[0];
35
+ const at = line.indexOf(token);
36
+ items.push({
37
+ ref: match[1] ?? '',
38
+ desc: `${line.slice(0, at).trimEnd()}${line.slice(at + token.length)}`.trim(),
39
+ });
40
+ }
41
+ }
42
+ return items;
43
+ }