@reticlehq/core 2.13.1 → 3.1.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/artifacts/artifacts-entry.d.ts +20 -0
- package/dist/artifacts/artifacts-entry.js +20 -0
- package/dist/artifacts/flow-composition.d.ts +30 -0
- package/dist/artifacts/flow-composition.js +19 -0
- package/dist/{flow-constants.d.ts → artifacts/flow-constants.d.ts} +97 -3
- package/dist/{flow-constants.js → artifacts/flow-constants.js} +103 -4
- package/dist/artifacts/flow-mutation-target.d.ts +39 -0
- package/dist/artifacts/flow-mutation-target.js +89 -0
- package/dist/artifacts/flow-order.d.ts +30 -0
- package/dist/artifacts/flow-order.js +49 -0
- package/dist/artifacts/flow-select.d.ts +56 -0
- package/dist/artifacts/flow-select.js +56 -0
- package/dist/artifacts/flow-step-tool.d.ts +31 -0
- package/dist/artifacts/flow-step-tool.js +31 -0
- package/dist/artifacts/flow-types.d.ts +3736 -0
- package/dist/artifacts/flow-types.js +463 -0
- package/dist/artifacts/flow-unreached.d.ts +12 -0
- package/dist/artifacts/flow-unreached.js +24 -0
- package/dist/{impact-savings.d.ts → artifacts/impact-savings.d.ts} +7 -3
- package/dist/{impact-savings.js → artifacts/impact-savings.js} +27 -4
- package/dist/{impact.d.ts → artifacts/impact.d.ts} +122 -54
- package/dist/{impact.js → artifacts/impact.js} +30 -0
- package/dist/{journal.d.ts → artifacts/journal.d.ts} +50 -6
- package/dist/{journal.js → artifacts/journal.js} +38 -2
- package/dist/artifacts/step-effect.d.ts +29 -0
- package/dist/artifacts/step-effect.js +28 -0
- package/dist/hooks/hook-events.d.ts +311 -0
- package/dist/hooks/hook-events.js +127 -0
- package/dist/hooks/hooks-entry.d.ts +9 -0
- package/dist/hooks/hooks-entry.js +9 -0
- package/dist/{brand.d.ts → identity/brand.d.ts} +7 -0
- package/dist/{contract-fingerprint.d.ts → identity/contract-fingerprint.d.ts} +21 -3
- package/dist/{contract-fingerprint.js → identity/contract-fingerprint.js} +22 -4
- package/dist/{document-identity.d.ts → identity/document-identity.d.ts} +4 -5
- package/dist/{document-identity.js → identity/document-identity.js} +4 -5
- package/dist/{source-constants.d.ts → identity/source-constants.d.ts} +4 -4
- package/dist/{source-constants.js → identity/source-constants.js} +4 -4
- package/dist/index.d.ts +69 -42
- package/dist/index.js +78 -44
- package/dist/onboarding.d.ts +114 -0
- package/dist/onboarding.js +141 -0
- package/dist/realm/registry.d.ts +212 -0
- package/dist/realm/registry.js +302 -0
- package/dist/{dev-server-registry.d.ts → registry/dev-server-registry.d.ts} +4 -5
- package/dist/{dev-server-registry.js → registry/dev-server-registry.js} +28 -19
- package/dist/{project-registry.d.ts → registry/project-registry.d.ts} +5 -5
- package/dist/{project-registry.js → registry/project-registry.js} +5 -5
- package/dist/schema/command-name.json +31 -0
- package/dist/schema/event-message.json +1 -0
- package/dist/schema/event-payloads.json +791 -0
- package/dist/schema/event-type.json +1 -0
- package/dist/schema/hello-message.json +76 -2
- package/dist/schema/reticle-event.json +1 -0
- package/dist/schema/reticle-message.json +77 -2
- package/dist/telemetry-entry.d.ts +15 -0
- package/dist/telemetry-entry.js +15 -0
- package/dist/telemetry-feedback.d.ts +13 -14
- package/dist/telemetry-feedback.js +11 -12
- package/dist/telemetry-license.d.ts +1 -1
- package/dist/telemetry-license.js +1 -1
- package/dist/telemetry-refusal.d.ts +11 -11
- package/dist/telemetry-refusal.js +7 -8
- package/dist/telemetry-session.d.ts +49 -57
- package/dist/telemetry-session.js +47 -55
- package/dist/telemetry.d.ts +229 -198
- package/dist/telemetry.js +83 -98
- package/dist/tour-entry.d.ts +10 -0
- package/dist/tour-entry.js +10 -0
- package/dist/tour.d.ts +125 -0
- package/dist/tour.js +165 -0
- package/dist/{consequence.d.ts → verdict/consequence.d.ts} +35 -11
- package/dist/{consequence.js → verdict/consequence.js} +9 -22
- package/dist/{finding-fingerprint.js → verdict/finding-fingerprint.js} +1 -1
- package/dist/{findings.d.ts → verdict/findings.d.ts} +149 -41
- package/dist/{findings.js → verdict/findings.js} +169 -48
- package/dist/{instrumentation-gap.d.ts → verdict/instrumentation-gap.d.ts} +22 -14
- package/dist/{instrumentation-gap.js → verdict/instrumentation-gap.js} +23 -15
- package/dist/{intent.d.ts → verdict/intent.d.ts} +41 -52
- package/dist/{intent.js → verdict/intent.js} +11 -22
- package/dist/verdict/revision.d.ts +44 -0
- package/dist/verdict/revision.js +53 -0
- package/dist/{run-context.d.ts → verdict/run-context.d.ts} +13 -34
- package/dist/{run-context.js → verdict/run-context.js} +15 -36
- package/dist/{security.js → verdict/security.js} +12 -21
- package/dist/{verification-run.d.ts → verdict/verification-run.d.ts} +369 -93
- package/dist/{verification-run.js → verdict/verification-run.js} +157 -21
- package/dist/{verified-constants.d.ts → verdict/verified-constants.d.ts} +36 -13
- package/dist/{verified-constants.js → verdict/verified-constants.js} +36 -13
- package/dist/verdict/verify-progress.d.ts +129 -0
- package/dist/verdict/verify-progress.js +74 -0
- package/dist/wire/channel.d.ts +46 -0
- package/dist/wire/channel.js +95 -0
- package/dist/{constants.d.ts → wire/constants/constants.d.ts} +124 -28
- package/dist/{constants.js → wire/constants/constants.js} +137 -28
- package/dist/{session-constants.d.ts → wire/constants/session-constants.d.ts} +9 -2
- package/dist/{session-constants.js → wire/constants/session-constants.js} +9 -2
- package/dist/{desktop-contract.js → wire/desktop-contract.js} +1 -1
- package/dist/{event-classification.js → wire/event-classification.js} +1 -1
- package/dist/{event-payloads.d.ts → wire/event-payloads.d.ts} +229 -17
- package/dist/{event-payloads.js → wire/event-payloads.js} +61 -3
- package/dist/{event-priority.d.ts → wire/event-priority.d.ts} +1 -4
- package/dist/{event-priority.js → wire/event-priority.js} +2 -5
- package/dist/wire/global-press.d.ts +30 -0
- package/dist/wire/global-press.js +54 -0
- package/dist/{messages.d.ts → wire/messages.d.ts} +290 -38
- package/dist/{messages.js → wire/messages.js} +93 -5
- package/dist/wire/narrow.d.ts +39 -0
- package/dist/wire/narrow.js +45 -0
- package/dist/{net.d.ts → wire/net.d.ts} +49 -10
- package/dist/{net.js → wire/net.js} +49 -10
- package/dist/wire/platform.d.ts +37 -0
- package/dist/wire/platform.js +36 -0
- package/dist/{redaction.d.ts → wire/redaction.d.ts} +30 -0
- package/dist/wire/redaction.js +274 -0
- package/dist/wire/tool-names.d.ts +133 -0
- package/dist/wire/tool-names.js +142 -0
- package/dist/{toon.js → wire/toon.js} +1 -1
- package/dist/{types.d.ts → wire/types.d.ts} +106 -66
- package/dist/{types.js → wire/types.js} +24 -4
- package/dist/{no-session-reason.d.ts → words/no-session-reason.d.ts} +7 -3
- package/dist/{no-session-reason.js → words/no-session-reason.js} +7 -3
- package/dist/{notices.d.ts → words/notices.d.ts} +24 -12
- package/dist/{notices.js → words/notices.js} +27 -12
- package/package.json +22 -5
- package/dist/flow-types.d.ts +0 -1473
- package/dist/flow-types.js +0 -195
- package/dist/redaction.js +0 -149
- /package/dist/{brand.js → identity/brand.js} +0 -0
- /package/dist/{edit-epoch.d.ts → identity/edit-epoch.d.ts} +0 -0
- /package/dist/{edit-epoch.js → identity/edit-epoch.js} +0 -0
- /package/dist/{project-id.d.ts → identity/project-id.d.ts} +0 -0
- /package/dist/{project-id.js → identity/project-id.js} +0 -0
- /package/dist/{daemon-registry.d.ts → registry/daemon-registry.d.ts} +0 -0
- /package/dist/{daemon-registry.js → registry/daemon-registry.js} +0 -0
- /package/dist/{finding-fingerprint.d.ts → verdict/finding-fingerprint.d.ts} +0 -0
- /package/dist/{security.d.ts → verdict/security.d.ts} +0 -0
- /package/dist/{desktop-contract.d.ts → wire/desktop-contract.d.ts} +0 -0
- /package/dist/{event-classification.d.ts → wire/event-classification.d.ts} +0 -0
- /package/dist/{state-select.d.ts → wire/state-select.d.ts} +0 -0
- /package/dist/{state-select.js → wire/state-select.js} +0 -0
- /package/dist/{toon.d.ts → wire/toon.d.ts} +0 -0
- /package/dist/{browser-misdirect.d.ts → words/browser-misdirect.d.ts} +0 -0
- /package/dist/{browser-misdirect.js → words/browser-misdirect.js} +0 -0
- /package/dist/{unreachable-notice.d.ts → words/unreachable-notice.d.ts} +0 -0
- /package/dist/{unreachable-notice.js → words/unreachable-notice.js} +0 -0
- /package/dist/{upgrade.d.ts → words/upgrade.d.ts} +0 -0
- /package/dist/{upgrade.js → words/upgrade.js} +0 -0
package/dist/flow-types.js
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ActionType, AnchorKind, FLOW_FILE_VERSION, } from './constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* The MCP tool names that can appear as a recorded flow step's `tool`. These are the ONLY tool names
|
|
5
|
-
* that cross the wire into a persisted flow file — the browser recorder stamps them, the server replays
|
|
6
|
-
* them, and FlowStep types them — so they live in core, the wire contract. The full agent-facing tool
|
|
7
|
-
* surface stays server-side (ReticleTool); ReticleTool references THESE for the flow-persisted three, so
|
|
8
|
-
* there is one source of truth and a rename cannot silently desync the recorder from the replayer (a
|
|
9
|
-
* tool rename once killed four e2e specs — this closes the browser/server half of that drift).
|
|
10
|
-
*/
|
|
11
|
-
export const FlowStepTool = {
|
|
12
|
-
ACT: 'reticle_act',
|
|
13
|
-
ACT_SEQUENCE: 'reticle_act_sequence',
|
|
14
|
-
ACT_AND_WAIT: 'reticle_act_and_wait',
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* A semantic anchor: how a step re-finds its element/event at replay
|
|
18
|
-
* time. Never a volatile eXX ref. testid/role+name bind a DOM element; signal binds an event.
|
|
19
|
-
*/
|
|
20
|
-
export const FlowAnchorSchema = z.discriminatedUnion('kind', [
|
|
21
|
-
// `source` is provenance, not part of how the step re-finds its element — the testid does that.
|
|
22
|
-
// It rides along so a failure can say which file to open; optional, so existing flow files parse
|
|
23
|
-
// unchanged and FLOW_FILE_VERSION does not move.
|
|
24
|
-
z.object({
|
|
25
|
-
kind: z.literal(AnchorKind.TESTID),
|
|
26
|
-
value: z.string().min(1),
|
|
27
|
-
source: z
|
|
28
|
-
.object({ file: z.string(), line: z.number(), column: z.number().optional() })
|
|
29
|
-
.optional(),
|
|
30
|
-
}),
|
|
31
|
-
z.object({
|
|
32
|
-
kind: z.literal(AnchorKind.ROLE),
|
|
33
|
-
role: z.string().min(1),
|
|
34
|
-
name: z.string().optional(),
|
|
35
|
-
}),
|
|
36
|
-
z.object({ kind: z.literal(AnchorKind.SIGNAL), name: z.string().min(1) }),
|
|
37
|
-
// Auto-anchor: re-find an element by component identity / source location when it has no testid.
|
|
38
|
-
// component or source carries the durable signal; role/name are disambiguating extras.
|
|
39
|
-
z.object({
|
|
40
|
-
kind: z.literal(AnchorKind.COMPONENT),
|
|
41
|
-
component: z.string().optional(),
|
|
42
|
-
source: z
|
|
43
|
-
.object({ file: z.string(), line: z.number(), column: z.number().optional() })
|
|
44
|
-
.optional(),
|
|
45
|
-
role: z.string().optional(),
|
|
46
|
-
name: z.string().optional(),
|
|
47
|
-
}),
|
|
48
|
-
]);
|
|
49
|
-
/** A post-condition a step asserts (compiled from a structured annotation; optional). */
|
|
50
|
-
export const FlowExpectSchema = z.object({
|
|
51
|
-
signal: z.string().optional(),
|
|
52
|
-
/**
|
|
53
|
-
* Optional payload shape an `assert-signal` annotation requires the signal
|
|
54
|
-
* to match (the predicate DSL's signal.dataMatches). Additive/optional — a flow file with a
|
|
55
|
-
* bare `signal` still parses, and the on-disk version stays FLOW_FILE_VERSION 1.
|
|
56
|
-
*/
|
|
57
|
-
signalData: z.record(z.unknown()).optional(),
|
|
58
|
-
/**
|
|
59
|
-
* Exact number of times the signal must have fired — the signal-side twin of `net.count`, and the
|
|
60
|
-
* only way a saved flow can keep a cardinality the agent actually asserted. Without it a
|
|
61
|
-
* `count: 1` drive would be recorded as bare presence, which is a strictly WEAKER claim than the
|
|
62
|
-
* one made: the replayed flow then goes green on the double-fire it was recorded to catch.
|
|
63
|
-
* Additive/optional — a flow file with a bare `signal` still parses, and FLOW_FILE_VERSION stays 1.
|
|
64
|
-
*/
|
|
65
|
-
signalCount: z.number().int().nonnegative().optional(),
|
|
66
|
-
net: z
|
|
67
|
-
.object({
|
|
68
|
-
method: z.string().optional(),
|
|
69
|
-
urlContains: z.string().optional(),
|
|
70
|
-
status: z.number().optional(),
|
|
71
|
-
/**
|
|
72
|
-
* Exact number of matching requests since the action — turns presence into a cardinality
|
|
73
|
-
* assertion. Catches the double-submit / useEffect-double-fire / retry-storm regression class:
|
|
74
|
-
* the request fired (presence passes) but fired the WRONG number of times. Omit = presence (≥1).
|
|
75
|
-
*/
|
|
76
|
-
count: z.number().int().nonnegative().optional(),
|
|
77
|
-
})
|
|
78
|
-
.optional(),
|
|
79
|
-
/**
|
|
80
|
-
* Console golden end-condition: assert the action logged (or, with absent:true, did NOT log) a
|
|
81
|
-
* console message at `level` (default 'error'). `absent:true` is the common case — "the action
|
|
82
|
-
* completed with a clean console" — catching the regression where an action throws a caught error
|
|
83
|
-
* / logs an uncaught rejection while the UI still renders fine (a presence check passes it).
|
|
84
|
-
*/
|
|
85
|
-
console: z
|
|
86
|
-
.object({
|
|
87
|
-
level: z.string().optional(),
|
|
88
|
-
absent: z.boolean().optional(),
|
|
89
|
-
})
|
|
90
|
-
.optional(),
|
|
91
|
-
element: z
|
|
92
|
-
.object({
|
|
93
|
-
testid: z.string().optional(),
|
|
94
|
-
role: z.string().optional(),
|
|
95
|
-
name: z.string().optional(),
|
|
96
|
-
})
|
|
97
|
-
.optional(),
|
|
98
|
-
/**
|
|
99
|
-
* Assert a registered store's value — the source of truth no DOM/network read can reach. Compiles
|
|
100
|
-
* to the predicate engine's `state` predicate. Additive/optional — a flow without it still parses
|
|
101
|
-
* and the on-disk version stays FLOW_FILE_VERSION 1. `equals` accepts a literal, omitted = presence,
|
|
102
|
-
* or a `{ $gte | $contains | $length }` operator pattern.
|
|
103
|
-
*/
|
|
104
|
-
state: z
|
|
105
|
-
.object({
|
|
106
|
-
store: z.string().optional(),
|
|
107
|
-
path: z.string(),
|
|
108
|
-
equals: z.unknown().optional(),
|
|
109
|
-
/**
|
|
110
|
-
* Treat this as an INVARIANT that must still hold AFTER the action settles, rather than a
|
|
111
|
-
* condition to wait for. Set it for a blast-radius check ("this unrelated path must NOT have
|
|
112
|
-
* moved") — without it a wait-until-true read passes before an over-reaching side-effect lands.
|
|
113
|
-
*/
|
|
114
|
-
hold: z.boolean().optional(),
|
|
115
|
-
})
|
|
116
|
-
.optional(),
|
|
117
|
-
});
|
|
118
|
-
const baseFlowStep = z.object({
|
|
119
|
-
tool: z.string(),
|
|
120
|
-
anchor: FlowAnchorSchema,
|
|
121
|
-
action: z.nativeEnum(ActionType).optional(),
|
|
122
|
-
args: z.record(z.unknown()).optional(),
|
|
123
|
-
expect: FlowExpectSchema.optional(),
|
|
124
|
-
degraded: z.boolean().optional(),
|
|
125
|
-
});
|
|
126
|
-
export const FlowStepSchema = baseFlowStep.extend({
|
|
127
|
-
steps: z.lazy(() => z.array(FlowStepSchema).optional()),
|
|
128
|
-
});
|
|
129
|
-
/**
|
|
130
|
-
* The on-disk flow file: diffable, git-tracked, anchor-resolved.
|
|
131
|
-
* The optional `dynamic` field (both `dynamic` + `success` are optional, so a
|
|
132
|
-
* file with neither still parses — back-compat is locked by a test).
|
|
133
|
-
*/
|
|
134
|
-
export const FlowFileSchema = z.object({
|
|
135
|
-
version: z.literal(FLOW_FILE_VERSION),
|
|
136
|
-
name: z.string(),
|
|
137
|
-
/**
|
|
138
|
-
* The business goal this flow exists to verify, one line (e.g. "ship a deploy to production").
|
|
139
|
-
* Optional + back-compat (a flow without it still parses). Set via an `intent` annotation. The
|
|
140
|
-
* point of "intent + outcome oracle": a flow that declares an intent should also assert an
|
|
141
|
-
* observable business OUTCOME (a consequence success-state), or it claims to verify a goal it
|
|
142
|
-
* cannot actually check — flow-classify flags that gap.
|
|
143
|
-
*/
|
|
144
|
-
intent: z.string().optional(),
|
|
145
|
-
/**
|
|
146
|
-
* The intent-ledger row this flow discharges — the id in `.reticle/intent.json`.
|
|
147
|
-
*
|
|
148
|
-
* `intent` above is the prose a recorder captured; this is the LINK to the ledger that already
|
|
149
|
-
* models declared → bound → proved and records which verdict discharged what. Without it there
|
|
150
|
-
* would be two ways to say what a change is for, which is the defect this codebase keeps paying
|
|
151
|
-
* for: a flow's goal and an intent's statement would drift apart with nothing to reconcile them.
|
|
152
|
-
*
|
|
153
|
-
* Set at save time from the flow's own prose, or written by hand to point a flow at an intent
|
|
154
|
-
* declared earlier via `reticle_intent` — a flow can prove something somebody else declared.
|
|
155
|
-
* Optional + back-compat: a flow without it replays exactly as before, and the on-disk version
|
|
156
|
-
* stays FLOW_FILE_VERSION 1.
|
|
157
|
-
*/
|
|
158
|
-
intentId: z.string().optional(),
|
|
159
|
-
/**
|
|
160
|
-
* The project the flow was recorded against (the connecting session's HELLO `projectId`), stamped at
|
|
161
|
-
* save time. Scopes a flow to its app so a shared daemon's HUD lists only the current project's flows
|
|
162
|
-
* instead of every project that ever saved to that daemon. Optional + back-compat: a flow with no
|
|
163
|
-
* projectId is treated as global (visible everywhere), so pre-existing files parse and still show.
|
|
164
|
-
*/
|
|
165
|
-
projectId: z.string().optional(),
|
|
166
|
-
/**
|
|
167
|
-
* The route (pathname) the journey started on, captured at record time. Replay navigates here
|
|
168
|
-
* before step 1 so a flow whose first anchor lives on another page doesn't drift on step 1 ("a
|
|
169
|
-
* step no longer matches") just because replay began on the wrong page. Optional + back-compat: a
|
|
170
|
-
* flow without it (or recorded before this shipped) replays from the current page as before, and
|
|
171
|
-
* the on-disk version stays FLOW_FILE_VERSION 1.
|
|
172
|
-
*/
|
|
173
|
-
startPath: z.string().optional(),
|
|
174
|
-
// FUTURE: fixtures/preconditions — schema slot reserved, unpopulated this cut. The recorder
|
|
175
|
-
// never writes it and no fixture runner exists.
|
|
176
|
-
fixture: z.string().optional(),
|
|
177
|
-
/** From the injected clock (ms) — deterministic in tests, byte-stable on disk. */
|
|
178
|
-
createdAt: z.number(),
|
|
179
|
-
steps: z.array(FlowStepSchema),
|
|
180
|
-
success: FlowExpectSchema.optional(),
|
|
181
|
-
/**
|
|
182
|
-
* Anchors whose CONTENT must not be asserted (e.g. LLM output). Replay asserts
|
|
183
|
-
* presence, not words. Compiled from a `mark-dynamic` annotation.
|
|
184
|
-
*/
|
|
185
|
-
dynamic: z.array(FlowAnchorSchema).optional(),
|
|
186
|
-
});
|
|
187
|
-
/**
|
|
188
|
-
* The in-page → wire payload for a finished human recording. The browser
|
|
189
|
-
* compiles captured interactions into a FlowFile-shaped object (resolving semantic anchors at
|
|
190
|
-
* capture time) and emits it as ONE EventType.FLOW_RECORDED event; the server persists it.
|
|
191
|
-
*/
|
|
192
|
-
export const RecordedFlowSchema = z.object({
|
|
193
|
-
name: z.string(),
|
|
194
|
-
flow: FlowFileSchema,
|
|
195
|
-
});
|
package/dist/redaction.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { REDACTED_VALUE } from './constants.js';
|
|
2
|
-
/**
|
|
3
|
-
* Wire redaction rules — which field names carry credentials, and which VALUE shapes are secrets
|
|
4
|
-
* regardless of the field they sit in.
|
|
5
|
-
*
|
|
6
|
-
* These live in core because they are a property of the wire, not of one side of it. They were
|
|
7
|
-
* implemented in the browser SDK, which was the only consumer until the driven path began capturing
|
|
8
|
-
* request bodies straight from the network stack — those are raw and unscrubbed, and duplicating a
|
|
9
|
-
* security regex to redact them would be the worst possible place to have two copies drift.
|
|
10
|
-
*/
|
|
11
|
-
// `token` must match auth CREDENTIALS, not compound design fields. Bare/separated `token(s)` and
|
|
12
|
-
// auth-prefixed tokens (accessToken, auth_token, sessionToken, …) are redacted; `colorToken`,
|
|
13
|
-
// `backgroundToken`, `tokenCount`, `designToken` are NOT — they were false-positives that redacted
|
|
14
|
-
// legitimate reticle_inspect/reticle_state output.
|
|
15
|
-
// `token` must match auth CREDENTIALS, not compound design fields (see note above). `cookie` is
|
|
16
|
-
// boundary-anchored the same way: it targets the `Cookie` / `Set-Cookie` HTTP HEADER names (which
|
|
17
|
-
// bundle the session credential and were the one wire payload reaching the journal + the agent
|
|
18
|
-
// unredacted), NOT any key that merely contains the substring — `scopecookie`, `cookieConsent`,
|
|
19
|
-
// `cookiePolicy` are legitimate app values an agent may need to read, and stay visible.
|
|
20
|
-
const SENSITIVE_KEY = /password|passwd|passcode|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;
|
|
21
|
-
/**
|
|
22
|
-
* The built-in rule, always available and never configurable.
|
|
23
|
-
*
|
|
24
|
-
* Separate from `isSensitiveKey` on purpose: the driven path needs a floor that no page-supplied
|
|
25
|
-
* config can lower, and the conformance test needs something to compare an unconfigured policy
|
|
26
|
-
* against. Every existing caller wants `isSensitiveKey`.
|
|
27
|
-
*/
|
|
28
|
-
export function defaultIsSensitiveKey(key) {
|
|
29
|
-
return SENSITIVE_KEY.test(key);
|
|
30
|
-
}
|
|
31
|
-
function normalizeNames(values) {
|
|
32
|
-
const out = new Set();
|
|
33
|
-
for (const value of values ?? []) {
|
|
34
|
-
const trimmed = value.trim().toLowerCase();
|
|
35
|
-
if (trimmed.length > 0)
|
|
36
|
-
out.add(trimmed);
|
|
37
|
-
}
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Resolve a config into a rule.
|
|
42
|
-
*
|
|
43
|
-
* `onWarn` fires ONCE here, at build time, rather than per key: the check runs on every serialized
|
|
44
|
-
* key of every event, so a per-key warning would flood the console of the app it is trying to help.
|
|
45
|
-
*/
|
|
46
|
-
export function buildRedactionPolicy(config, onWarn) {
|
|
47
|
-
const literalKeys = normalizeNames(config?.keys?.filter((k) => 'string' === typeof k));
|
|
48
|
-
const patterns = (config?.keys ?? []).filter((k) => k instanceof RegExp);
|
|
49
|
-
const allowed = normalizeNames(config?.allow);
|
|
50
|
-
// Exempting a key the default rule calls a credential is a deliberate choice with a real blast
|
|
51
|
-
// radius: that value now reaches the agent transcript and the on-disk journal. Say it once, name
|
|
52
|
-
// the keys, and say nothing about the ordinary case — an exemption for a key the rule never
|
|
53
|
-
// matched is the false-positive fix this option exists for, and warning about it would train
|
|
54
|
-
// people to ignore the warning that matters.
|
|
55
|
-
const exemptedCredentials = [...allowed].filter((key) => defaultIsSensitiveKey(key) && !literalKeys.has(key));
|
|
56
|
-
if (exemptedCredentials.length > 0 && onWarn !== undefined) {
|
|
57
|
-
onWarn(`[reticle] redact.allow is exempting ${exemptedCredentials.join(', ')} from redaction. The ` +
|
|
58
|
-
`default rule treats ${1 === exemptedCredentials.length ? 'that key' : 'those keys'} as a ` +
|
|
59
|
-
`credential, so ${1 === exemptedCredentials.length ? 'its value' : 'their values'} will now ` +
|
|
60
|
-
`reach the agent transcript and the on-disk journal in cleartext.`);
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
isSensitiveKey: (key) => {
|
|
64
|
-
const normalized = key.toLowerCase();
|
|
65
|
-
if (literalKeys.has(normalized))
|
|
66
|
-
return true;
|
|
67
|
-
for (const pattern of patterns) {
|
|
68
|
-
// `test` on a /g regex advances lastIndex between calls, so the same key alternates
|
|
69
|
-
// true/false. Reset it rather than trusting every caller to omit the flag.
|
|
70
|
-
pattern.lastIndex = 0;
|
|
71
|
-
if (pattern.test(key))
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
if (allowed.has(normalized))
|
|
75
|
-
return false;
|
|
76
|
-
return defaultIsSensitiveKey(key);
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The rule in force for THIS process.
|
|
82
|
-
*
|
|
83
|
-
* Ambient rather than threaded through the ~10 call sites that redact, so configuring it changes
|
|
84
|
-
* every one of them at once and adding a new one cannot accidentally opt out. Set by `connect()` in
|
|
85
|
-
* the browser, where one page means one config.
|
|
86
|
-
*
|
|
87
|
-
* The server deliberately does NOT set this. A daemon serves many sessions in one process, so an
|
|
88
|
-
* ambient policy there would let one app's config decide another app's redaction; the driven path
|
|
89
|
-
* holds its own policy per daemon instead, built only from what sessions declared as EXTRA keys.
|
|
90
|
-
*/
|
|
91
|
-
let activePolicy;
|
|
92
|
-
export function setActiveRedactionPolicy(policy) {
|
|
93
|
-
activePolicy = policy;
|
|
94
|
-
}
|
|
95
|
-
export function resetActiveRedactionPolicy() {
|
|
96
|
-
activePolicy = undefined;
|
|
97
|
-
}
|
|
98
|
-
/** Whether a key carries a credential, under the policy in force. */
|
|
99
|
-
export function isSensitiveKey(key) {
|
|
100
|
-
return activePolicy === undefined ? defaultIsSensitiveKey(key) : activePolicy.isSensitiveKey(key);
|
|
101
|
-
}
|
|
102
|
-
/** Cap on how many declared keys travel in a hello — a bound, not a limit anyone should reach. */
|
|
103
|
-
export const MAX_WIRE_REDACT_KEYS = 64;
|
|
104
|
-
/** Cap on one declared key's length, so a hello cannot be inflated by a pathological name. */
|
|
105
|
-
export const MAX_WIRE_REDACT_KEY_LENGTH = 128;
|
|
106
|
-
/**
|
|
107
|
-
* The part of a config that may cross the bridge, so the server redacts an app's own credentials on
|
|
108
|
-
* the driven path too — where request bodies are captured raw from the network stack and never pass
|
|
109
|
-
* through the SDK at all.
|
|
110
|
-
*
|
|
111
|
-
* Two deliberate exclusions, and both are the safe direction of the asymmetry:
|
|
112
|
-
*
|
|
113
|
-
* - **RegExp entries do not travel.** Compiling a pattern that arrived over a socket and running it
|
|
114
|
-
* against every key of every request body is a ReDoS surface handed to whatever is on the page.
|
|
115
|
-
* A dropped pattern means the driven path over-redacts relative to the config, never under.
|
|
116
|
-
* - **`allow` never travels.** It is the only part of the config that REMOVES redaction, so a page
|
|
117
|
-
* able to send it could quietly un-redact `password` in the daemon's journal for every session.
|
|
118
|
-
* The driven path keeps the default floor.
|
|
119
|
-
*
|
|
120
|
-
* Both limitations are documented for users in docs/usage.md ("Extending the redaction rules").
|
|
121
|
-
*/
|
|
122
|
-
export function wireRedactionKeys(config) {
|
|
123
|
-
const seen = new Set();
|
|
124
|
-
const out = [];
|
|
125
|
-
for (const key of config?.keys ?? []) {
|
|
126
|
-
if (typeof key !== 'string')
|
|
127
|
-
continue;
|
|
128
|
-
const trimmed = key.trim();
|
|
129
|
-
if (0 === trimmed.length || trimmed.length > MAX_WIRE_REDACT_KEY_LENGTH)
|
|
130
|
-
continue;
|
|
131
|
-
const normalized = trimmed.toLowerCase();
|
|
132
|
-
if (seen.has(normalized))
|
|
133
|
-
continue;
|
|
134
|
-
seen.add(normalized);
|
|
135
|
-
out.push(trimmed);
|
|
136
|
-
if (out.length >= MAX_WIRE_REDACT_KEYS)
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
return out;
|
|
140
|
-
}
|
|
141
|
-
// High-confidence credential SHAPES, redacted regardless of key name — for scanning body/value text where
|
|
142
|
-
// a secret can sit under a benign key (`{"note":"<jwt>"}`, `<meta content="sk_live_…">`). Deliberately
|
|
143
|
-
// narrow (JWT, known provider prefixes) so it never corrupts legitimate prose the way a broad
|
|
144
|
-
// entropy/length heuristic would.
|
|
145
|
-
const KNOWN_SECRET = /eyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}|(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|ya29\.[A-Za-z0-9._-]{20,}/g;
|
|
146
|
-
/** Redact high-confidence secret shapes anywhere in a text/value, independent of any surrounding key. */
|
|
147
|
-
export function scrubKnownSecrets(text) {
|
|
148
|
-
return text.replace(KNOWN_SECRET, REDACTED_VALUE);
|
|
149
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|