@reticlehq/core 2.11.0 → 2.13.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 (58) hide show
  1. package/dist/constants.d.ts +40 -0
  2. package/dist/constants.js +41 -1
  3. package/dist/dev-server-registry.d.ts +85 -0
  4. package/dist/dev-server-registry.js +120 -0
  5. package/dist/document-identity.d.ts +39 -0
  6. package/dist/document-identity.js +53 -0
  7. package/dist/edit-epoch.d.ts +36 -0
  8. package/dist/edit-epoch.js +40 -0
  9. package/dist/event-payloads.d.ts +24 -4
  10. package/dist/event-payloads.js +13 -1
  11. package/dist/findings.d.ts +62 -0
  12. package/dist/findings.js +75 -0
  13. package/dist/flow-types.d.ts +88 -0
  14. package/dist/flow-types.js +22 -0
  15. package/dist/impact.d.ts +176 -0
  16. package/dist/impact.js +36 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.js +9 -0
  19. package/dist/instrumentation-gap.d.ts +59 -1
  20. package/dist/instrumentation-gap.js +0 -0
  21. package/dist/intent.d.ts +332 -0
  22. package/dist/intent.js +133 -0
  23. package/dist/journal.d.ts +33 -0
  24. package/dist/journal.js +20 -0
  25. package/dist/messages.d.ts +84 -10
  26. package/dist/messages.js +20 -0
  27. package/dist/net.d.ts +34 -0
  28. package/dist/net.js +86 -0
  29. package/dist/no-session-reason.d.ts +35 -0
  30. package/dist/no-session-reason.js +34 -0
  31. package/dist/notices.d.ts +79 -6
  32. package/dist/notices.js +83 -6
  33. package/dist/run-context.d.ts +122 -0
  34. package/dist/run-context.js +118 -0
  35. package/dist/schema/event-message.json +10 -0
  36. package/dist/schema/event-type.json +1 -0
  37. package/dist/schema/reticle-event.json +10 -0
  38. package/dist/schema/reticle-message.json +10 -0
  39. package/dist/security.d.ts +8 -2
  40. package/dist/security.js +37 -3
  41. package/dist/session-constants.d.ts +8 -0
  42. package/dist/session-constants.js +8 -0
  43. package/dist/source-constants.cjs +9 -0
  44. package/dist/source-constants.d.cts +4 -0
  45. package/dist/telemetry-license.d.ts +12 -0
  46. package/dist/telemetry-license.js +12 -0
  47. package/dist/telemetry-refusal.d.ts +94 -0
  48. package/dist/telemetry-refusal.js +61 -0
  49. package/dist/telemetry-session.d.ts +151 -2
  50. package/dist/telemetry-session.js +114 -0
  51. package/dist/telemetry.d.ts +167 -95
  52. package/dist/telemetry.js +46 -44
  53. package/dist/types.d.ts +9 -0
  54. package/dist/unreachable-notice.d.ts +19 -0
  55. package/dist/unreachable-notice.js +26 -0
  56. package/dist/verified-constants.d.ts +8 -0
  57. package/dist/verified-constants.js +10 -0
  58. package/package.json +6 -2
package/dist/notices.js CHANGED
@@ -34,10 +34,29 @@ export const BUFFER_EVICTION_WARNING = 'event buffer evicted older events (age/s
34
34
  * Thrown when a tool needs a live browser session and none is connected. Names the #1 real cause in a
35
35
  * multi-repo / multi-agent setup — a PORT MISMATCH between the app's SDK and the daemon — so the agent
36
36
  * checks the wiring instead of only the "is the SDK enabled?" dead end.
37
+ *
38
+ * It used to end by naming `reticle_wait_ready`, which is retired (see RETIRED_FROM_SURFACE) and
39
+ * answers `unknown tool`. This is the most-thrown error in the product — `resolve` raises it on
40
+ * every tool call while nothing is connected — so the one sentence carrying the ACTION sent the
41
+ * reader to a tool that does not exist, at the moment they had least idea what to do next.
42
+ *
43
+ * `reticle_sessions` is the live answer and a strictly better one: it returns the ranked diagnosis
44
+ * (which of the causes above this actually is, plus the port scan and a next action) rather than
45
+ * blocking and telling you nothing. It is the same tool `#unknownSessionError` already points at,
46
+ * so the two no-session paths now agree.
37
47
  */
38
- export const NO_SESSION_CONNECTED_ERROR = "no browser session connected. Two things to check: (1) your app is running with @reticlehq/browser enabled, and (2) it points at THIS daemon's port — a mismatch between the app's reticle({ port }) / VITE_RETICLE_WS_URL and the daemon's RETICLE_PORT is the usual cause. reticle_wait_ready blocks briefly for a session to appear.";
48
+ export const NO_SESSION_CONNECTED_ERROR = "no browser session connected. Two things to check: (1) your app is running with @reticlehq/browser enabled, and (2) it points at THIS daemon's port — a mismatch between the app's reticle({ port }) / VITE_RETICLE_WS_URL and the daemon's RETICLE_PORT is the usual cause. Call reticle_sessions for the diagnosis — it names which of these it is, and what to do next — rather than retrying this call.";
39
49
  /** Surfaced on act/assert results when the target tab is throttled. */
40
50
  export const THROTTLED_WARNING = 'tab throttled; timer/rAF/pointer gestures may silently no-op; refocus before driving';
51
+ /**
52
+ * Prefixed onto a wait/assert miss when the session is throttled. A background tab is starved by
53
+ * the browser, so a timeout there is not evidence the UI is absent — it may never have rendered.
54
+ * `inconclusive` on the verdict (this string) is what stops that miss being graded as a product
55
+ * failure. The CLI escape hatch is named second; an MCP-only agent has no shell.
56
+ */
57
+ export const THROTTLED_STARVED_NOTE = 'this tab is throttled and has not rendered; a miss here is not evidence the UI is absent. ' +
58
+ 'acquire a scriptable context with reticle_run { tool: "reticle_lease", action: "acquire", url } ' +
59
+ '(the human can run `reticle drive <url>` if they have a shell)';
41
60
  /**
42
61
  * Pushed to the panel when the last agent's MCP connection drops — the agent (any of
43
62
  * Codex/OpenCode/Claude/Hermes) has stopped or is waiting on you. Tells the human, who is
@@ -68,9 +87,67 @@ export const AGENT_ASK_NOTICE = 'Agent needs your input — answer in your termi
68
87
  export const YIELD_WITHOUT_SESSION_NOTE = 'No browser session was connected, so there was no panel to update. The turn end was still ' +
69
88
  'recorded. If you expected an app to be attached, that is the thing to look into.';
70
89
  /**
71
- * Actionable companion to THROTTLED_WARNING. Surfaced on act/assert results and
72
- * reticle_sessions rows when a tab is hidden/throttled and may be un-focusable/un-recoverable from
73
- * the in-page SDK + CDP path. Points at the `reticle drive` escape hatch (a guaranteed scriptable
74
- * context). Reticle cannot bring such a tab to front or recover it, so it names the limit instead.
90
+ * What leasing COSTS, said once and appended to every recommendation that offers it.
91
+ *
92
+ * A lease is a separate pooled context. It is the highest-value path in the product for autonomous
93
+ * work — and it is invisible to the person sitting in front of the app, because the HUD lives in
94
+ * THEIR tab. Recommending it without saying so produced exactly the failure it invites: an agent
95
+ * took the advice, drove fifteen calls into a context nobody could see, and the developer watching
96
+ * an empty HUD asked why nothing was running. The product looked broken while working correctly.
97
+ *
98
+ * The tradeoff is the whole content of the hint. An agent that knows a human is watching should
99
+ * spend a slower tab to stay visible; one working alone should lease and not think about it.
100
+ */
101
+ export const LEASE_IS_INVISIBLE_NOTE = 'note that a lease is a SEPARATE context: the human watching this tab sees nothing of what you do there, so prefer this tab while someone is following along';
102
+ /**
103
+ * A tab that is HIDDEN — backgrounded, or in another window.
104
+ *
105
+ * The genuinely risky case, and the one this recommendation was written for. A background tab has
106
+ * its timers and rAF clamped hard, so synthetic events can land on a page that never advances, and
107
+ * Reticle cannot bring it to the front. Naming the limit is the honest move.
108
+ *
109
+ * Names the escape hatch the AGENT can take first (`reticle_lease` through `reticle_run`, since
110
+ * lease is not on the default surface) and leaves `reticle drive` as the human-side equivalent: an
111
+ * MCP-only agent has no shell, so a CLI sentence is advice it cannot follow.
112
+ */
113
+ /**
114
+ * A DESKTOP window that has gone to the background, which is a different problem with a different fix.
115
+ *
116
+ * The web answer — acquire a lease, or run `reticle drive <url>` — is unavailable here and saying it
117
+ * is worse than saying nothing. A lease opens a headless BROWSER context; an Electron or Tauri app's
118
+ * window IS the client, and a browser pointed at the same dev-server URL is a different program with
119
+ * no main process, no preload and no Rust commands. Driven on MarkText, a shipped Electron editor:
120
+ * its window went behind, the session reported hidden+throttled, and the only advice offered was the
121
+ * one thing that could not be done — while the thing that works, bringing the window forward, went
122
+ * unsaid.
123
+ *
124
+ * No `reticle_lease` and no `reticle drive` in this sentence, deliberately. Both are checked by test.
125
+ */
126
+ export const DESKTOP_WINDOW_BACKGROUNDED = "this app window is in the background, and a backgrounded webview clamps its timers and rAF — a synthetic action can land on a page that never advances. Bring the app window to the front and retry. A lease is NOT the answer for a desktop app: it opens a browser context, which has none of this app's IPC or commands.";
127
+ export const HIDDEN_TAB_RECOMMENDATION = 'tab hidden and may be un-focusable from here; timers and rAF are clamped in a background tab, so an action can land on a page that never advances. Refocus it, or acquire a guaranteed scriptable context yourself with `reticle_run { tool: "reticle_lease", action: "acquire", url }` (a human can equivalently run `reticle drive <url>`) — ' +
128
+ LEASE_IS_INVISIBLE_NOTE;
129
+ /**
130
+ * A tab that is NOT hidden but has gone quiet — the `throttled` flag without `hidden`.
131
+ *
132
+ * Worth being exact, because the flag's name oversells it: `throttled` is `hidden || stale`, and
133
+ * stale only means no health heartbeat arrived inside the window. For a tab that is not hidden that
134
+ * usually means nothing worse than a quiet page, and such a tab is very often driveable.
135
+ *
136
+ * Split out because the old single message treated this as equivalent to hidden and it is not.
137
+ * Measured in the field: a session flagged throttled took a sign-in and two clean net-grade verdicts
138
+ * with no retries, while the recommendation had already sent the agent into a lease the watching
139
+ * human could not see. One flag produced advice that cost the product's main trust surface and
140
+ * bought nothing.
141
+ *
142
+ * So this reports the uncertainty honestly — it MAY be slow, timing-sensitive work is what suffers —
143
+ * and offers the precise instrument for that (`refuseWhenThrottled`) rather than a different
144
+ * browser.
145
+ */
146
+ export const THROTTLED_TAB_RECOMMENDATION = 'tab is not hidden but has not reported health recently — usually a quiet page rather than a stuck one, and very often still driveable. This is also the tab a human can see, so try it first. Timing-sensitive work (animations, debounces, gestures) is what degrades: pass `refuseWhenThrottled: true` to refuse rather than act over events that may not land. Lease a separate context only if a drive here actually fails; ' +
147
+ LEASE_IS_INVISIBLE_NOTE;
148
+ /**
149
+ * @deprecated Use {@link HIDDEN_TAB_RECOMMENDATION} or {@link THROTTLED_TAB_RECOMMENDATION}.
150
+ * Retained so an older consumer pinned to this name still compiles; it is the hidden-tab wording,
151
+ * which is the case the single message was actually correct for.
75
152
  */
76
- export const UNSCRIPTABLE_TAB_RECOMMENDATION = 'tab hidden/throttled and may be un-focusable from here; refocus it, or run `reticle drive <url>` for a guaranteed scriptable context';
153
+ export const UNSCRIPTABLE_TAB_RECOMMENDATION = HIDDEN_TAB_RECOMMENDATION;
@@ -0,0 +1,122 @@
1
+ /**
2
+ * What a run has established, held so the agent can ASK for it back.
3
+ *
4
+ * Verification is multi-step, and the only thing holding the thread together is the agent's own
5
+ * context window. When that compacts, or the turn ends, or a sub-agent takes over, the thread is
6
+ * gone and the work restarts. The shape of that shows in the field without needing the theory: long
7
+ * runs of the same read-only call, an agent searching by exhaustion because it no longer remembers
8
+ * what it already saw.
9
+ *
10
+ * ## Pulled, never pushed
11
+ *
12
+ * An earlier version of this rode along on every tool response. It cost +136% on a verdict and was
13
+ * cut, because the agent still had most of that context most of the time: we paid on every call to
14
+ * duplicate what it already knew. The asymmetry that makes the feature work is not that Reticle
15
+ * remembers MORE, it is that Reticle's copy does not degrade at the moment the agent's does. So the
16
+ * agent asks, at the moment it knows its own memory is gone, and pays once.
17
+ *
18
+ * That inversion is why nothing here returns `undefined` for an empty run. A push had to stay silent
19
+ * when it had nothing to say; a pull was asked a question, and "nothing established yet" is the
20
+ * answer the asker needs.
21
+ *
22
+ * ## Two rules stop it becoming the thing it prevents
23
+ *
24
+ * **It must shrink, not grow.** Superseding facts REPLACE rather than append, and both blocks are
25
+ * capped. A context object that accumulates is a token bomb, and read-only payloads are already the
26
+ * largest thing this product emits.
27
+ *
28
+ * **Memory that can be wrong is worse than no memory.** A stale established fact is precisely the
29
+ * false-green mechanism this product exists to prevent, and stale refs are already the most common
30
+ * error an agent sees from us. So every fact carries the document AND the edit epoch it was observed
31
+ * under, and is dropped the moment either moves: no grace period, no probably-fine. The comparison
32
+ * is `isSameDocument`/`isSameEditEpoch` rather than a third rule written beside them.
33
+ *
34
+ * ## What may never go in
35
+ *
36
+ * Only what Reticle OBSERVED. Never what the agent intends, plans, or believes: that is not ours to
37
+ * hold, it is unbounded, and a verification tool that remembers what an agent was thinking is
38
+ * inventing evidence. `remaining` is the one forward-looking field and it is derived mechanically
39
+ * from declared bindings, so it remains a report of a fact — which bindings are undischarged — and
40
+ * not a prediction.
41
+ */
42
+ import { type Intent } from './intent.js';
43
+ import type { Verified } from './verified-constants.js';
44
+ /**
45
+ * How many rows either block may carry.
46
+ *
47
+ * A decision written down in one place, because the whole feature is a bet that this answer costs
48
+ * fewer tokens than the re-derivation it prevents, and a cap that drifts makes that bet
49
+ * unmeasurable. Twelve is enough to hold the refs, routes and verdicts a single verification thread
50
+ * works with, and small enough that the answer stays a briefing rather than a second payload.
51
+ *
52
+ * One number for both blocks on purpose: two caps is two things to keep in step, and nothing has
53
+ * ever suggested proofs and observations deserve different budgets.
54
+ */
55
+ export declare const RUN_ESTABLISHED_CAP = 12;
56
+ /**
57
+ * Evidence scoped to the page and the source revision it was taken under.
58
+ *
59
+ * Both fields are optional and absence means "current", exactly as `isSameDocument` and
60
+ * `isSameEditEpoch` already rule: an SDK predating either stamps nothing, and a page with no
61
+ * hot-update channel never stamps an epoch at all.
62
+ */
63
+ interface ScopedEvidence {
64
+ /** The document this was seen under. Absent only from evidence predating document identity. */
65
+ readonly doc?: string | undefined;
66
+ /** The edit epoch this was seen under. Absent where no hot update could ever be observed. */
67
+ readonly epoch?: number | undefined;
68
+ }
69
+ /**
70
+ * One thing this run established, with the page state it was true under.
71
+ *
72
+ * `key` is the SUBJECT — re-establishing the same subject supersedes rather than appends. `fact` is
73
+ * the conclusion in prose, never the transcript it came from: "e12 is the Submit button", not the
74
+ * snapshot that revealed it.
75
+ */
76
+ export interface EstablishedFact extends ScopedEvidence {
77
+ readonly key: string;
78
+ readonly fact: string;
79
+ /** Where in the source this was about, `file:line`, when the run observed one. */
80
+ readonly source?: string | undefined;
81
+ }
82
+ /**
83
+ * One claim a verdict already settled.
84
+ *
85
+ * The claim IS the subject: proving the same thing twice is one row, the newer one. An agent that
86
+ * has forgotten it proved something either re-proves it, which is slow, or assumes it, which is a
87
+ * false green — and both are the failure this block exists to stop, so `verified` travels with the
88
+ * claim rather than being flattened to a boolean.
89
+ */
90
+ export interface ProvenClaim extends ScopedEvidence {
91
+ readonly claim: string;
92
+ readonly verified: Verified;
93
+ readonly source?: string | undefined;
94
+ }
95
+ /** What this run has established, what it has proved, and what nothing has discharged. */
96
+ export interface RunContext {
97
+ readonly step: number;
98
+ readonly established: readonly EstablishedFact[];
99
+ readonly proven: readonly ProvenClaim[];
100
+ readonly remaining: readonly string[];
101
+ }
102
+ /** Fold new observations into the established set. See `foldScoped`. */
103
+ export declare function foldEstablished(existing: readonly EstablishedFact[], incoming: readonly EstablishedFact[], currentDocumentId: string | undefined, currentEditEpoch: number | undefined): EstablishedFact[];
104
+ /** Fold new verdicts into the proven set, keyed on the claim. See `foldScoped`. */
105
+ export declare function foldProven(existing: readonly ProvenClaim[], incoming: readonly ProvenClaim[], currentDocumentId: string | undefined, currentEditEpoch: number | undefined): ProvenClaim[];
106
+ /**
107
+ * The declared intents no verdict has discharged yet.
108
+ *
109
+ * Derived, never inferred. This reports a property of the ledger — which bindings remain unproved —
110
+ * and says nothing about what the agent means to do next.
111
+ */
112
+ export declare function remainingFor(intents: readonly Intent[]): string[];
113
+ /** Assemble the answer. Always answers: an empty run has an empty context, and that is the truth. */
114
+ export declare function buildRunContext(input: {
115
+ step: number;
116
+ intents: readonly Intent[];
117
+ established: readonly EstablishedFact[];
118
+ proven: readonly ProvenClaim[];
119
+ currentDocumentId: string | undefined;
120
+ currentEditEpoch: number | undefined;
121
+ }): RunContext;
122
+ export {};
@@ -0,0 +1,118 @@
1
+ /**
2
+ * What a run has established, held so the agent can ASK for it back.
3
+ *
4
+ * Verification is multi-step, and the only thing holding the thread together is the agent's own
5
+ * context window. When that compacts, or the turn ends, or a sub-agent takes over, the thread is
6
+ * gone and the work restarts. The shape of that shows in the field without needing the theory: long
7
+ * runs of the same read-only call, an agent searching by exhaustion because it no longer remembers
8
+ * what it already saw.
9
+ *
10
+ * ## Pulled, never pushed
11
+ *
12
+ * An earlier version of this rode along on every tool response. It cost +136% on a verdict and was
13
+ * cut, because the agent still had most of that context most of the time: we paid on every call to
14
+ * duplicate what it already knew. The asymmetry that makes the feature work is not that Reticle
15
+ * remembers MORE, it is that Reticle's copy does not degrade at the moment the agent's does. So the
16
+ * agent asks, at the moment it knows its own memory is gone, and pays once.
17
+ *
18
+ * That inversion is why nothing here returns `undefined` for an empty run. A push had to stay silent
19
+ * when it had nothing to say; a pull was asked a question, and "nothing established yet" is the
20
+ * answer the asker needs.
21
+ *
22
+ * ## Two rules stop it becoming the thing it prevents
23
+ *
24
+ * **It must shrink, not grow.** Superseding facts REPLACE rather than append, and both blocks are
25
+ * capped. A context object that accumulates is a token bomb, and read-only payloads are already the
26
+ * largest thing this product emits.
27
+ *
28
+ * **Memory that can be wrong is worse than no memory.** A stale established fact is precisely the
29
+ * false-green mechanism this product exists to prevent, and stale refs are already the most common
30
+ * error an agent sees from us. So every fact carries the document AND the edit epoch it was observed
31
+ * under, and is dropped the moment either moves: no grace period, no probably-fine. The comparison
32
+ * is `isSameDocument`/`isSameEditEpoch` rather than a third rule written beside them.
33
+ *
34
+ * ## What may never go in
35
+ *
36
+ * Only what Reticle OBSERVED. Never what the agent intends, plans, or believes: that is not ours to
37
+ * hold, it is unbounded, and a verification tool that remembers what an agent was thinking is
38
+ * inventing evidence. `remaining` is the one forward-looking field and it is derived mechanically
39
+ * from declared bindings, so it remains a report of a fact — which bindings are undischarged — and
40
+ * not a prediction.
41
+ */
42
+ import { isSameDocument } from './document-identity.js';
43
+ import { isSameEditEpoch } from './edit-epoch.js';
44
+ import { IntentState } from './intent.js';
45
+ /**
46
+ * How many rows either block may carry.
47
+ *
48
+ * A decision written down in one place, because the whole feature is a bet that this answer costs
49
+ * fewer tokens than the re-derivation it prevents, and a cap that drifts makes that bet
50
+ * unmeasurable. Twelve is enough to hold the refs, routes and verdicts a single verification thread
51
+ * works with, and small enough that the answer stays a briefing rather than a second payload.
52
+ *
53
+ * One number for both blocks on purpose: two caps is two things to keep in step, and nothing has
54
+ * ever suggested proofs and observations deserve different budgets.
55
+ */
56
+ export const RUN_ESTABLISHED_CAP = 12;
57
+ /** Is this evidence still describing the page and the source revision in force? */
58
+ function isCurrent(evidence, currentDocumentId, currentEditEpoch) {
59
+ return (isSameDocument(evidence.doc, currentDocumentId) &&
60
+ isSameEditEpoch(evidence.epoch, currentEditEpoch));
61
+ }
62
+ /**
63
+ * Drop what a navigation or an edit invalidated, supersede what was re-observed, keep the most
64
+ * recent within the cap.
65
+ *
66
+ * One fold with a key function rather than two, because `established` and `proven` obey the same
67
+ * three rules and a second copy is a second place for them to drift apart.
68
+ */
69
+ function foldScoped(existing, incoming, keyOf, currentDocumentId, currentEditEpoch) {
70
+ const current = (row) => isCurrent(row, currentDocumentId, currentEditEpoch);
71
+ // Supersede WITHIN the batch as well as against the prior set. `buildRunContext` folds against an
72
+ // empty prior set, so a rule that only ever applied to `existing` never applied at all there — and
73
+ // the envelope's whole contract is that `key` is the subject and re-observing it replaces rather
74
+ // than appends. A driven session showed the same ref twice and the same claim three times:
75
+ // duplicates in the one payload whose entire purpose is a cheap context restore.
76
+ //
77
+ // Last wins, because the newest reading is the true one. Insertion order is preserved from the
78
+ // LAST occurrence, so a re-observed subject moves to the recent end where the cap protects it.
79
+ const fresh = new Map();
80
+ for (const row of incoming) {
81
+ if (!current(row))
82
+ continue;
83
+ const key = keyOf(row);
84
+ fresh.delete(key);
85
+ fresh.set(key, row);
86
+ }
87
+ const superseded = new Set(fresh.keys());
88
+ const kept = existing.filter((row) => current(row) && !superseded.has(keyOf(row)));
89
+ // Oldest first, so trimming from the front drops the least recent. `slice` on the tail keeps the
90
+ // newest, which is the half a next step is most likely to need.
91
+ return [...kept, ...fresh.values()].slice(-RUN_ESTABLISHED_CAP);
92
+ }
93
+ /** Fold new observations into the established set. See `foldScoped`. */
94
+ export function foldEstablished(existing, incoming, currentDocumentId, currentEditEpoch) {
95
+ return foldScoped(existing, incoming, (f) => f.key, currentDocumentId, currentEditEpoch);
96
+ }
97
+ /** Fold new verdicts into the proven set, keyed on the claim. See `foldScoped`. */
98
+ export function foldProven(existing, incoming, currentDocumentId, currentEditEpoch) {
99
+ return foldScoped(existing, incoming, (p) => p.claim, currentDocumentId, currentEditEpoch);
100
+ }
101
+ /**
102
+ * The declared intents no verdict has discharged yet.
103
+ *
104
+ * Derived, never inferred. This reports a property of the ledger — which bindings remain unproved —
105
+ * and says nothing about what the agent means to do next.
106
+ */
107
+ export function remainingFor(intents) {
108
+ return intents.filter((i) => IntentState.PROVED !== i.state).map((i) => i.statement);
109
+ }
110
+ /** Assemble the answer. Always answers: an empty run has an empty context, and that is the truth. */
111
+ export function buildRunContext(input) {
112
+ return {
113
+ step: input.step,
114
+ established: foldEstablished([], input.established, input.currentDocumentId, input.currentEditEpoch),
115
+ proven: foldProven([], input.proven, input.currentDocumentId, input.currentEditEpoch),
116
+ remaining: remainingFor(input.intents),
117
+ };
118
+ }
@@ -41,6 +41,7 @@
41
41
  "state.change",
42
42
  "storage.change",
43
43
  "page.health",
44
+ "context.opened",
44
45
  "render.commit",
45
46
  "focus.change",
46
47
  "flow.recorded",
@@ -76,6 +77,15 @@
76
77
  "window"
77
78
  ]
78
79
  },
80
+ "documentId": {
81
+ "type": "string",
82
+ "minLength": 1,
83
+ "maxLength": 8
84
+ },
85
+ "editEpoch": {
86
+ "type": "integer",
87
+ "minimum": 0
88
+ },
79
89
  "data": {
80
90
  "type": "object",
81
91
  "additionalProperties": {},
@@ -28,6 +28,7 @@
28
28
  "state.change",
29
29
  "storage.change",
30
30
  "page.health",
31
+ "context.opened",
31
32
  "render.commit",
32
33
  "focus.change",
33
34
  "flow.recorded",
@@ -34,6 +34,7 @@
34
34
  "state.change",
35
35
  "storage.change",
36
36
  "page.health",
37
+ "context.opened",
37
38
  "render.commit",
38
39
  "focus.change",
39
40
  "flow.recorded",
@@ -69,6 +70,15 @@
69
70
  "window"
70
71
  ]
71
72
  },
73
+ "documentId": {
74
+ "type": "string",
75
+ "minLength": 1,
76
+ "maxLength": 8
77
+ },
78
+ "editEpoch": {
79
+ "type": "integer",
80
+ "minimum": 0
81
+ },
72
82
  "data": {
73
83
  "type": "object",
74
84
  "additionalProperties": {},
@@ -174,6 +174,7 @@
174
174
  "state.change",
175
175
  "storage.change",
176
176
  "page.health",
177
+ "context.opened",
177
178
  "render.commit",
178
179
  "focus.change",
179
180
  "flow.recorded",
@@ -207,6 +208,15 @@
207
208
  "window"
208
209
  ]
209
210
  },
211
+ "documentId": {
212
+ "type": "string",
213
+ "minLength": 1,
214
+ "maxLength": 8
215
+ },
216
+ "editEpoch": {
217
+ "type": "integer",
218
+ "minimum": 0
219
+ },
210
220
  "data": {
211
221
  "type": "object",
212
222
  "additionalProperties": {},
@@ -20,5 +20,11 @@ export declare const OPAQUE_ORIGIN = "null";
20
20
  * pairing token, exactly as they do for a request that omits `Origin` entirely.
21
21
  */
22
22
  export declare function isOpaqueOrigin(origin: string): boolean;
23
- /** Best-effort classifier for labels and tool names that can trigger irreversible effects. */
24
- export declare function isDangerousActionText(text: string): boolean;
23
+ /**
24
+ * Best-effort classifier for labels and tool names that can trigger irreversible effects.
25
+ *
26
+ * `role` is the resolved ARIA role of the control. An `option` is a value picker: its text names
27
+ * the value, not an action, so "Payment" as a select choice is not a payment. Callers that have no
28
+ * role (a tool name, a click with no role on the descriptor) omit it and the text decides.
29
+ */
30
+ export declare function isDangerousActionText(text: string, role?: string): boolean;
package/dist/security.js CHANGED
@@ -11,11 +11,37 @@
11
11
  * `payment` catches "Send payment" and "Confirm payment" (which the bare-verb list missed entirely,
12
12
  * because `\bpay\b` does not match "payment"), and `send money`/`send funds` catch the rest.
13
13
  *
14
+ * `logout` / `log out` / `sign out` were here and are not. Signing out is reversible, and the
15
+ * words fire on almost every authenticated drive — a `Log out` menuitem was blocked on every
16
+ * session. Same cost as `send`: a guard that fires on routine controls trains agents to pass
17
+ * `confirmDangerous` reflexively.
18
+ *
14
19
  * The guard stays deliberately asymmetric — a false block costs one round-trip, a missed block can
15
20
  * charge somebody's card — so this narrows the trigger without lowering money coverage. Both
16
21
  * directions are pinned in security.test.ts.
17
22
  */
18
- const DANGEROUS_ACTION = /\b(delete|remove|destroy|erase|drop|terminate|revoke|reset|logout|log out|sign out|close account|cancel subscription|purchase|buy|pay|payment|place order|confirm order|deploy|publish|send money|send funds|transfer|withdraw|refund)\b/i;
23
+ /**
24
+ * Labels that read as irreversible: something is destroyed, or money moves.
25
+ *
26
+ * `deploy` and `publish` were here and are not. The guard's contract — written at the top of
27
+ * act-danger.ts — is "a money-moving or destructive control", and a deploy is neither: nothing is
28
+ * destroyed, nothing is paid, and the thing it produces did not exist before. Consequential is a
29
+ * wider net than this list is allowed to be, or half the buttons in a dev tool sit behind a
30
+ * permission flag.
31
+ *
32
+ * Removed on measurement, not taste. Three benchmark runs against an app with a "New deploy" button
33
+ * lost their ENTIRE turn budget to the refusal. Improving its wording did not rescue the last one:
34
+ * the agent spent its remaining turns weighing a bug report about the block and looking for a
35
+ * webmcp workaround. A guard that costs a whole run on a control it was never written to catch is
36
+ * not protecting anybody — it is training agents to route around it, which is worse than not having
37
+ * it, because the routing-around generalises to the buttons that DO matter.
38
+ */
39
+ const DANGEROUS_ACTION = /\b(delete|remove|destroy|erase|drop|terminate|revoke|reset|close account|cancel subscription|purchase|buy|pay|payment|place order|confirm order|send money|send funds|transfer|withdraw|refund)\b/i;
40
+ /**
41
+ * Roles that pick a value from a list, not perform an action. Selecting "Payment" as a document
42
+ * type is not a payment. `menuitem` is deliberately not here: a menu item labelled Delete still is.
43
+ */
44
+ const VALUE_PICKER_ROLE = 'option';
19
45
  /** The hostnames that ARE loopback outright, with no parsing: the name, and IPv6 ::1 both ways. */
20
46
  const LOOPBACK_HOSTNAMES = ['localhost', '::1', '0:0:0:0:0:0:0:1'];
21
47
  /** IPv4 loopback is the whole 127.0.0.0/8 block, so the first octet is the entire test. */
@@ -82,7 +108,15 @@ export function isOpaqueOrigin(origin) {
82
108
  return true;
83
109
  }
84
110
  }
85
- /** Best-effort classifier for labels and tool names that can trigger irreversible effects. */
86
- export function isDangerousActionText(text) {
111
+ /**
112
+ * Best-effort classifier for labels and tool names that can trigger irreversible effects.
113
+ *
114
+ * `role` is the resolved ARIA role of the control. An `option` is a value picker: its text names
115
+ * the value, not an action, so "Payment" as a select choice is not a payment. Callers that have no
116
+ * role (a tool name, a click with no role on the descriptor) omit it and the text decides.
117
+ */
118
+ export function isDangerousActionText(text, role) {
119
+ if (role !== undefined && role.trim().toLowerCase() === VALUE_PICKER_ROLE)
120
+ return false;
87
121
  return DANGEROUS_ACTION.test(text.replace(/[_-]+/g, ' '));
88
122
  }
@@ -129,5 +129,13 @@ export declare const NoSessionAction: {
129
129
  readonly OPEN_APP: "open_app";
130
130
  /** A session was here and went away: reopen the tab, or take a lease. */
131
131
  readonly REOPEN_APP: "reopen_app";
132
+ /**
133
+ * The app IS connected — to another daemon on this machine. Nothing to open, nothing to install.
134
+ *
135
+ * Its own kind because every other action here is wrong for it: the app is running, wired and
136
+ * live, so `open_app`, `run_init` and `start_dev_server` all send the agent to fix something that
137
+ * is not broken, and `reopen_app` points it at a tab that is already open.
138
+ */
139
+ readonly DAEMON_SPLIT: "daemon_split";
132
140
  };
133
141
  export type NoSessionAction = (typeof NoSessionAction)[keyof typeof NoSessionAction];
@@ -126,4 +126,12 @@ export const NoSessionAction = {
126
126
  OPEN_APP: 'open_app',
127
127
  /** A session was here and went away: reopen the tab, or take a lease. */
128
128
  REOPEN_APP: 'reopen_app',
129
+ /**
130
+ * The app IS connected — to another daemon on this machine. Nothing to open, nothing to install.
131
+ *
132
+ * Its own kind because every other action here is wrong for it: the app is running, wired and
133
+ * live, so `open_app`, `run_init` and `start_dev_server` all send the agent to fix something that
134
+ * is not broken, and `reopen_app` points it at a tab that is already open.
135
+ */
136
+ DAEMON_SPLIT: 'daemon_split',
129
137
  };
@@ -0,0 +1,9 @@
1
+ // GENERATED by scripts/gen-source-constants.mjs — do not edit.
2
+ //
3
+ // The CommonJS view of source-constants, for build tooling (@reticlehq/babel-plugin) that
4
+ // cannot import the ESM build. Edit src/source-constants.ts and rebuild @reticlehq/core.
5
+ 'use strict';
6
+ exports.DATA_RETICLE_SOURCE_ATTR = "data-reticle-source";
7
+ exports.RETICLE_ROOT_GLOBAL = "__RETICLE_ROOT__";
8
+ exports.RETICLE_SDK_VERSION_GLOBAL = "__RETICLE_SDK_VERSION__";
9
+ Object.freeze(exports);
@@ -0,0 +1,4 @@
1
+ // GENERATED by scripts/gen-source-constants.mjs — do not edit.
2
+ export declare const DATA_RETICLE_SOURCE_ATTR: "data-reticle-source";
3
+ export declare const RETICLE_ROOT_GLOBAL: "__RETICLE_ROOT__";
4
+ export declare const RETICLE_SDK_VERSION_GLOBAL: "__RETICLE_SDK_VERSION__";
@@ -15,6 +15,18 @@
15
15
  * This is a STATUS, never an identity. It says whether a key verified, not whose key it is; the
16
16
  * separate `licenseId` carries the opaque id, and the organisation NAME never goes on the wire at all.
17
17
  */
18
+ /**
19
+ * A licence key is present in the environment — whatever this build was able to conclude about it.
20
+ *
21
+ * Separate from `licenseStatus` because status can be ABSENT: `eval` reports nothing at all, by
22
+ * design, since it means no issuer key is baked and that is every OSS install. The consequence was
23
+ * that a customer who pastes a real enterprise key into a build which cannot verify it produced no
24
+ * licence signal whatsoever — indistinguishable from someone who has never held a key. The one
25
+ * population most worth seeing was the one that could not be seen.
26
+ *
27
+ * Never the key. This is a boolean; the key itself is a credential and never leaves the machine.
28
+ */
29
+ export declare const LICENSE_KEY_PRESENT = "licenseKeyPresent";
18
30
  export declare const LicenseActivation: {
19
31
  /** A valid, unexpired, correctly-signed key covering this build. */
20
32
  readonly ACTIVE: "active";
@@ -15,6 +15,18 @@
15
15
  * This is a STATUS, never an identity. It says whether a key verified, not whose key it is; the
16
16
  * separate `licenseId` carries the opaque id, and the organisation NAME never goes on the wire at all.
17
17
  */
18
+ /**
19
+ * A licence key is present in the environment — whatever this build was able to conclude about it.
20
+ *
21
+ * Separate from `licenseStatus` because status can be ABSENT: `eval` reports nothing at all, by
22
+ * design, since it means no issuer key is baked and that is every OSS install. The consequence was
23
+ * that a customer who pastes a real enterprise key into a build which cannot verify it produced no
24
+ * licence signal whatsoever — indistinguishable from someone who has never held a key. The one
25
+ * population most worth seeing was the one that could not be seen.
26
+ *
27
+ * Never the key. This is a boolean; the key itself is a credential and never leaves the machine.
28
+ */
29
+ export const LICENSE_KEY_PRESENT = 'licenseKeyPresent';
18
30
  export const LicenseActivation = {
19
31
  /** A valid, unexpired, correctly-signed key covering this build. */
20
32
  ACTIVE: 'active',