flare-redact 1.5.0 → 1.6.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/help.js ADDED
@@ -0,0 +1,461 @@
1
+ /**
2
+ * The CLI's help system.
3
+ *
4
+ * `--help` prints the summary. `help <topic>` prints the part you actually
5
+ * needed, because a flag list tells you a flag exists and nothing about when to
6
+ * reach for it. Every topic here is written from the behaviour in this
7
+ * repository; if one disagrees with the code, the topic is the bug.
8
+ */
9
+ import { DETECTORS } from './index.js';
10
+ export const HELP = `flare-redact — hide secrets & PII before they hit a log
11
+
12
+ USAGE
13
+ flare-redact [options] [files...] stdin if no files
14
+ flare-redact gateway [options] run the redaction sidecar proxy
15
+ flare-redact help [topic] explain a topic in depth
16
+
17
+ OPTIONS
18
+ --scan list what would be redacted, and why (input unchanged)
19
+ --format <f> scan output: pretty | json | sarif (default: pretty)
20
+ --sarif shorthand for --scan --format sarif
21
+ --summary print a count of findings per detector
22
+ --json parse input as JSON and redact recursively
23
+ --csv parse input as CSV and redact every cell
24
+ --mode <m> mask | label | hash | pseudonym | surrogate
25
+ (fpe is a deprecated alias for pseudonym)
26
+ --secret-env <n> read the transform key from env var <n>
27
+ (default: FLARE_REDACT_SECRET)
28
+ --hash-salt <s> deprecated; prefer --secret-env
29
+ --min-confidence <n>
30
+ drop findings below this confidence (0-1)
31
+ --refine-confidence
32
+ use the learned classifier to refine confidence for
33
+ generic detectors (fewer false positives on UUIDs,
34
+ hashes, and slugs); pairs with --min-confidence
35
+ --include-values include raw matched values in --scan output
36
+ (unsafe for logs and reports)
37
+ --only <ids> use only these detectors (comma-separated)
38
+ --enable <ids> turn on extra detectors (e.g. ipv4,high_entropy)
39
+ --disable <ids> turn off detectors (e.g. email)
40
+ --mask <str> replace every secret with this string
41
+ --allow <vals> never redact these exact values (comma-separated)
42
+ --exclude <glob> skip matching paths during directory scans (repeatable)
43
+ --max-file-size <size>
44
+ largest directory-discovered file to scan (default: 1mb)
45
+ accepts bytes or kb/mb/gb suffixes
46
+ --no-default-excludes
47
+ also walk .git, .hg, .svn, node_modules, and vendor
48
+ --term <word> also catch this exact word/phrase (repeatable)
49
+ --terms <file> also catch every word/phrase in this file (one per line)
50
+ --vault <file> reversible: write an AES-GCM encrypted map to <file>
51
+ --restore <file> restore using an encrypted map written by --vault
52
+ --vault-password-env <n>
53
+ vault password env var (default: FLARE_REDACT_VAULT_PASSWORD)
54
+ --allow-plaintext-vault
55
+ explicitly allow reading a legacy plaintext vault
56
+ --list show all detectors and exit
57
+ -h, --help show this help
58
+ -v, --version show version
59
+
60
+ SUBCOMMANDS
61
+ gateway run a reverse proxy that redacts request bodies and
62
+ restores the originals in the reply — no code changes
63
+ in the calling application. See: flare-redact gateway help
64
+ help explain a topic. Run 'flare-redact help topics' for the
65
+ index, or 'flare-redact help <detector>' for one detector.
66
+
67
+ EXAMPLES
68
+ tail -f app.log | flare-redact
69
+ flare-redact --scan config.env
70
+ flare-redact --scan .
71
+ flare-redact --scan . --exclude 'fixtures/**' --max-file-size 2mb
72
+ flare-redact --scan --format json .env app.log
73
+ flare-redact --sarif .env > flare-redact.sarif
74
+ flare-redact --json --mode hash < event.json
75
+ flare-redact --enable high_entropy,ipv4 < app.log
76
+ flare-redact --scan --enable high_entropy --refine-confidence --min-confidence 0.5 app.log
77
+
78
+ Stuck? 'flare-redact help topics' lists everything this help can explain.
79
+ `;
80
+ const TOPIC_LIST = [
81
+ {
82
+ name: 'detectors',
83
+ summary: 'choosing what gets redacted, by id or tag',
84
+ body: `DETECTORS — choosing what gets redacted
85
+
86
+ 'flare-redact --list' prints every detector: a filled circle is on by default, a
87
+ hollow one is off until you ask for it.
88
+
89
+ Three flags select, and they are applied in that order:
90
+
91
+ --only <ids> ignore the defaults; run exactly these
92
+ --enable <ids> add to the defaults
93
+ --disable <ids> remove from the result
94
+
95
+ Each accepts detector ids and tags interchangeably, comma-separated. Tags let you
96
+ say what you mean without listing thirty ids:
97
+
98
+ secret, pii, finance, network, crypto, email, vehicle, contextual, obfuscated
99
+ and country tags: us, gb, de, fr, es, it, nl, pl, tr, ca, au, br, in, cn, jp, id
100
+
101
+ flare-redact --enable pii app.log every PII detector
102
+ flare-redact --only secret .env secrets only, nothing else
103
+ flare-redact --disable email,ipv4 app.log defaults minus two
104
+
105
+ Contextual detectors (names, addresses, dates of birth) are off by default and
106
+ tagged 'contextual'. They read surrounding words to decide, so they are the ones
107
+ most worth reviewing with --scan before you turn them on in production.
108
+
109
+ 'flare-redact help <detector-id>' explains a single detector.
110
+
111
+ Custom values that no detector knows about:
112
+
113
+ --term <word> catch this exact word or phrase, repeatable
114
+ --terms <file> catch every line of a file
115
+ --allow <vals> never redact these exact values`,
116
+ },
117
+ {
118
+ name: 'modes',
119
+ summary: 'mask, label, hash, pseudonym, surrogate — and which to pick',
120
+ body: `MODES — what replaces a matched value
121
+
122
+ --mode mask the default. Partial, shape-preserving: a***@***, sk-***
123
+ --mode label the detector's name: [EMAIL], [OPENAI_KEY]
124
+ --mode hash keyed HMAC-SHA-256. Same input, same output, so you can
125
+ still count and join on it. Requires a key.
126
+ --mode pseudonym a fake value of the same shape. Requires a key.
127
+ --mode surrogate a typed synthetic value — a card number that still passes
128
+ Luhn, a date that is still a date. Requires a key.
129
+
130
+ --mask <str> ignore all of the above and write a fixed string
131
+
132
+ hash, pseudonym and surrogate are keyed, and the key never goes on the command
133
+ line. Put it in an environment variable:
134
+
135
+ export FLARE_REDACT_SECRET='…'
136
+ flare-redact --mode hash app.log
137
+
138
+ Use --secret-env <NAME> to read a different variable. --hash-salt still works and
139
+ is deprecated; it names the same thing badly.
140
+
141
+ 'fpe' is accepted as an alias for 'pseudonym' and warns. It was the wrong word:
142
+ none of this is format-preserving encryption, and nothing here is reversible
143
+ without a vault — see 'flare-redact help vault'.`,
144
+ },
145
+ {
146
+ name: 'vault',
147
+ summary: 'reversible redaction: get the originals back',
148
+ body: `VAULT — redaction you can undo
149
+
150
+ A mode replaces a value and forgets it. A vault replaces it with a stable
151
+ placeholder and remembers the mapping, so the same secret is always the same
152
+ placeholder and the text can be turned back into the original later.
153
+
154
+ export FLARE_REDACT_VAULT_PASSWORD='…'
155
+ flare-redact --vault map.json < app.log > safe.log # redact, save the map
156
+ flare-redact --restore map.json < safe.log # put the originals back
157
+
158
+ The map on disk is not plaintext: PBKDF2-SHA-256 derives a key from the password
159
+ and the file is an authenticated AES-256-GCM envelope. Lose the password and the
160
+ map is gone. The password comes from an environment variable, never a flag —
161
+ use --vault-password-env <NAME> to point at a different one.
162
+
163
+ Placeholders are opaque 96-bit random tokens by default, so a placeholder leaks
164
+ nothing about the value behind it.
165
+
166
+ A vault written by an older version in plaintext still loads, but only if you say
167
+ so explicitly with --allow-plaintext-vault.
168
+
169
+ In code this is createVault() / restore(), and the gateway uses one per request
170
+ so placeholders never cross between callers.`,
171
+ },
172
+ {
173
+ name: 'scan',
174
+ summary: 'find secrets without changing anything, and fail CI on them',
175
+ body: `SCAN — report, do not rewrite
176
+
177
+ flare-redact --scan config.env what would be redacted, and why
178
+ flare-redact --scan . walk a whole project
179
+ flare-redact --summary app.log just the counts, per detector
180
+
181
+ --scan never prints the matched value unless you pass --include-values, which is
182
+ unsafe for anything you keep. The report carries the detector, the reason, the
183
+ file and the position.
184
+
185
+ Output formats:
186
+
187
+ --format pretty human reading, the default
188
+ --format json machine reading
189
+ --format sarif GitHub code scanning and anything else that speaks SARIF
190
+ --sarif shorthand for --scan --format sarif
191
+
192
+ Exit codes make it a CI gate:
193
+
194
+ 0 nothing found
195
+ 1 findings (scan mode only)
196
+ 2 the command itself failed — bad flag, unreadable file, invalid JSON
197
+
198
+ # fail the build if a secret is committed
199
+ npx --yes flare-redact --scan . --exclude package-lock.json
200
+
201
+ Too noisy? Generic detectors like high_entropy match anything that looks random.
202
+ --refine-confidence runs the learned classifier over them and --min-confidence
203
+ drops the weak ones:
204
+
205
+ flare-redact --scan --enable high_entropy --refine-confidence --min-confidence 0.5 .`,
206
+ },
207
+ {
208
+ name: 'files',
209
+ summary: 'scanning directories: what is walked, what is skipped',
210
+ body: `FILES — what a directory scan actually reads
211
+
212
+ Give --scan a directory and it walks it. Three things are skipped without being
213
+ asked, because scanning them is noise or a hazard:
214
+
215
+ - .git, .hg, .svn, node_modules and vendor. Pass --no-default-excludes to walk
216
+ them anyway.
217
+ - files that look binary
218
+ - files larger than --max-file-size (default 1mb; accepts 512kb, 2mb, 1gb)
219
+ - symlinks are not followed
220
+
221
+ --exclude <glob> skip more paths, repeatable:
222
+
223
+ flare-redact --scan . --exclude 'fixtures/**' --exclude '*.min.js'
224
+
225
+ The json report counts what was skipped and why, so a scan that finds nothing
226
+ cannot quietly mean a scan that read nothing.`,
227
+ },
228
+ {
229
+ name: 'gateway',
230
+ summary: 'the sidecar proxy: redact without touching application code',
231
+ body: `GATEWAY — redaction without a code change
232
+
233
+ The library needs you to call it. The gateway does not: it is a reverse proxy
234
+ that redacts request bodies on the way out and restores the originals in the
235
+ reply, so an application integrates by changing one base URL.
236
+
237
+ flare-redact gateway --upstream https://api.openai.com --enable pii
238
+
239
+ # then, in the application — nothing else changes
240
+ export OPENAI_BASE_URL=http://127.0.0.1:8787/v1
241
+
242
+ Streamed responses are restored incrementally, so a placeholder split across two
243
+ SSE frames still comes back whole.
244
+
245
+ It is also a redaction service for languages without a native engine:
246
+ POST /v1/redact, POST /v1/scan, GET /v1/detectors and server-side /v1/sessions,
247
+ plus /healthz, /readyz and Prometheus /metrics. Those are the only paths the
248
+ gateway answers itself — everything else under /v1 is proxied to your upstream.
249
+
250
+ A container image ships in the repository under docker/.
251
+
252
+ Full flag list: flare-redact gateway help`,
253
+ },
254
+ {
255
+ name: 'agent-flow',
256
+ summary: 'FlareFlow: source-to-sink capabilities for AI tools',
257
+ body: `AGENT FLOW — control where protected values may be restored
258
+
259
+ FlareFlow is a library and gateway API for model-produced tool calls. It binds
260
+ each protected value to a runtime-owned source and detector, then restores it
261
+ only when a capability also matches the resolved sink, exact JSON Pointer path,
262
+ and remaining cumulative budget.
263
+
264
+ import { createAgentFlow } from 'flare-redact/agent';
265
+
266
+ const flow = createAgentFlow({
267
+ sinks: {
268
+ 'postgres.execute': {
269
+ capabilities: [{
270
+ id: 'credential', sources: ['config'],
271
+ detectors: ['url_credentials'],
272
+ paths: ['/args/connectionString'], maxUses: 1
273
+ }]
274
+ }
275
+ }
276
+ });
277
+
278
+ const safe = flow.protectForModel('config', sourceData);
279
+ const local = flow.authorizeForSink(runtimeTool.id, modelCall);
280
+
281
+ Do not take source ids, sink ids, or policy from model output. A forged,
282
+ cross-flow, expired, wrong-path, key-position, or over-budget token blocks the
283
+ whole call without partial restoration.
284
+
285
+ This controls exact placeholder declassification. It is not a general prompt-
286
+ injection defense and cannot protect data the model already saw.
287
+
288
+ Specification: spec/FLAREFLOW.md
289
+ Benchmark: npm run benchmark:agent -- --json`,
290
+ },
291
+ {
292
+ name: 'library',
293
+ summary: 'using it from JavaScript and TypeScript',
294
+ body: `LIBRARY — the JavaScript and TypeScript API
295
+
296
+ import { redact, scan, compilePolicy, createVault } from 'flare-redact';
297
+
298
+ redact('mail ada@example.com') // 'mail a***@***'
299
+ scan(value) // findings, no rewriting
300
+ compilePolicy(options) // resolve options once, reuse everywhere
301
+
302
+ redact() takes any value, not just strings: objects, arrays and nested
303
+ structures are walked and only the leaves are rewritten.
304
+
305
+ Adapters live behind subpath imports, so you pay for what you import:
306
+
307
+ flare-redact/pino flare-redact/winston log transports
308
+ flare-redact/http flare-redact/fetch HTTP layers
309
+ flare-redact/llm flare-redact/session prompts and conversations
310
+ flare-redact/tool MCP and multi-tool agent boundaries
311
+ flare-redact/agent provenance, path and budget enforcement for agents
312
+ flare-redact/stream flare-redact/csv streams and tabular data
313
+ flare-redact/middleware framework middleware
314
+ flare-redact/ml the learned confidence classifier
315
+ flare-redact/pack load an FRS-1 detector pack as ordinary detectors
316
+ flare-redact/gateway embed the sidecar in your own process
317
+
318
+ The package has no runtime dependencies. Node 20 or newer; Bun and Deno are
319
+ covered by CI.`,
320
+ },
321
+ {
322
+ name: 'sdks',
323
+ summary: 'the Python, Go and Rust engines — installed separately',
324
+ body: `SDKS — the same redactor in four languages
325
+
326
+ Python, Go and Rust have their own native engines. They are separate packages:
327
+ installing flare-redact from npm gives you the JavaScript engine and nothing
328
+ else, and it pulls no dependencies of any kind.
329
+
330
+ Node npm install flare-redact
331
+
332
+ Go go get github.com/flare-collection/flare-redact/sdk/go
333
+
334
+ Python pip install "flare-redact @ \\
335
+ git+https://github.com/flare-collection/flare-redact@v1.6.0#subdirectory=sdk/python"
336
+
337
+ Rust flare-redact = { git = "https://github.com/flare-collection/flare-redact", \\
338
+ tag = "v1.6.0" }
339
+
340
+ The Python and Rust engines are not on PyPI or crates.io yet, so they install
341
+ from the repository. The commands above are the ones that work today.
342
+
343
+ They are not ports that drift. All four implement FRS-1, the specification in
344
+ spec/SPEC.md, and all four run the same conformance corpus in spec/conformance/
345
+ in their own test suites — so the same input and the same options produce the
346
+ same output whichever engine you use.
347
+
348
+ If you cannot add a dependency at all, the gateway gives every language an HTTP
349
+ endpoint instead: flare-redact help gateway`,
350
+ },
351
+ {
352
+ name: 'env',
353
+ summary: 'every environment variable this tool reads',
354
+ body: `ENVIRONMENT
355
+
356
+ CLI:
357
+ FLARE_REDACT_SECRET key for hash, pseudonym and surrogate modes
358
+ (override the name with --secret-env)
359
+ FLARE_REDACT_VAULT_PASSWORD password for an encrypted vault file
360
+ (override the name with --vault-password-env)
361
+
362
+ Gateway:
363
+ FLARE_UPSTREAM origin to forward to
364
+ FLARE_GATEWAY_HOST bind address (default 127.0.0.1)
365
+ FLARE_GATEWAY_PORT bind port (default 8787)
366
+ FLARE_GATEWAY_TOKEN bearer token required by the /v1 API
367
+ FLARE_GATEWAY_MAX_BODY_BYTES request body cap
368
+ FLARE_GATEWAY_TIMEOUT_MS upstream timeout
369
+ FLARE_GATEWAY_SESSION_TTL_MS how long a server-side vault lives
370
+ FLARE_GATEWAY_LOG silent | info | debug
371
+ FLARE_REDACT_ONLY / _ENABLE / _DISABLE / _MODE / _SECRET
372
+ the policy, for containers
373
+
374
+ Secrets are read from the environment and never from flags, because a flag ends
375
+ up in shell history and in the process list.`,
376
+ },
377
+ {
378
+ name: 'exit-codes',
379
+ summary: 'what the process returns, and when',
380
+ body: `EXIT CODES
381
+
382
+ 0 success. In --scan, it also means nothing was found.
383
+ 1 --scan found at least one thing. This is what fails a CI job.
384
+ 2 the command failed: an unknown flag, a file that could not be read,
385
+ input that was not valid JSON, a bad vault password.
386
+
387
+ Redaction that finds nothing still exits 0 and prints the input unchanged, so
388
+ flare-redact is safe to leave in a pipeline permanently.`,
389
+ },
390
+ ];
391
+ export const TOPICS = TOPIC_LIST;
392
+ /** The topic index, as printed by `help topics`. */
393
+ export function topicIndex() {
394
+ const width = Math.max(...TOPICS.map((topic) => topic.name.length));
395
+ const lines = TOPICS.map((topic) => ` ${topic.name.padEnd(width)} ${topic.summary}`);
396
+ return `HELP TOPICS
397
+
398
+ ${lines.join('\n')}
399
+
400
+ flare-redact help <topic> read one of these
401
+ flare-redact help <detector> explain a single detector, e.g. 'help email'
402
+ flare-redact --list every detector, with defaults marked
403
+ `;
404
+ }
405
+ /** One detector, rendered as its own help page. */
406
+ function detectorHelp(id) {
407
+ const detector = DETECTORS.find((candidate) => candidate.id === id);
408
+ if (!detector)
409
+ return undefined;
410
+ const tags = detector.tags?.length ? detector.tags.join(', ') : 'none';
411
+ const state = detector.default
412
+ ? 'on by default'
413
+ : `off by default — turn it on with --enable ${detector.id}`;
414
+ return `DETECTOR ${detector.id}
415
+
416
+ ${detector.label}
417
+
418
+ ${detector.why}
419
+
420
+ State ${state}
421
+ Tags ${tags}
422
+
423
+ flare-redact --only ${detector.id} <file> run just this one
424
+ flare-redact --disable ${detector.id} <file> run everything except this one
425
+ `;
426
+ }
427
+ /**
428
+ * Suggest the nearest topic or detector for something we do not recognise.
429
+ * Prefix and substring matching only — a typo table would be more machinery
430
+ * than the problem deserves.
431
+ */
432
+ function nearest(query) {
433
+ const needle = query.toLowerCase();
434
+ const names = [...TOPICS.map((topic) => topic.name), ...DETECTORS.map((detector) => detector.id)];
435
+ // Either direction: "vaults" should find "vault", and "vau" should too.
436
+ return names.filter((name) => name.includes(needle) || needle.includes(name)).slice(0, 5);
437
+ }
438
+ /**
439
+ * Resolve `help [topic]`. Returns the text and the exit code rather than
440
+ * writing, so the caller decides between stdout and stderr and the tests can
441
+ * read it back.
442
+ */
443
+ export function renderHelp(topic) {
444
+ if (!topic)
445
+ return { text: HELP, code: 0 };
446
+ const name = topic.toLowerCase();
447
+ if (name === 'topics' || name === 'help')
448
+ return { text: topicIndex(), code: 0 };
449
+ const found = TOPICS.find((candidate) => candidate.name === name);
450
+ if (found)
451
+ return { text: `${found.body}\n`, code: 0 };
452
+ const detector = detectorHelp(topic);
453
+ if (detector)
454
+ return { text: detector, code: 0 };
455
+ const suggestions = nearest(name);
456
+ const hint = suggestions.length
457
+ ? `Did you mean: ${suggestions.join(', ')}?\n\n`
458
+ : '';
459
+ return { text: `No help for "${topic}".\n\n${hint}${topicIndex()}`, code: 2 };
460
+ }
461
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWvC,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEnB,CAAC;AAEF,MAAM,UAAU,GAAyB;IACvC;QACE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,2CAA2C;QACpD,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDA+B0C;KACjD;IACD;QACE,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,6DAA6D;QACtE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;iDAuBu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;IACP,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,SAAS,IAAI,GAAG,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAChF,CAAC"}
package/docker/README.md CHANGED
@@ -32,6 +32,7 @@ Without Docker: `npx flare-redact gateway --upstream https://api.openai.com`.
32
32
  - [Which parts of the body](#which-parts-of-the-body)
33
33
  - [Restoring the answer](#restoring-the-answer)
34
34
  - [The redaction API](#the-redaction-api)
35
+ - [FlareFlow for agent tools](#flareflow-for-agent-tools)
35
36
  - [Configuration](#configuration)
36
37
  - [Operating it](#operating-it)
37
38
  - [Security model](#security-model)
@@ -126,6 +127,13 @@ not what you want:
126
127
  | `POST /v1/sessions/:id/redact` | mask, remembering the mapping |
127
128
  | `POST /v1/sessions/:id/restore` | put the originals back |
128
129
  | `DELETE /v1/sessions/:id` | discard the mapping |
130
+ | `POST /v1/flows` | open an operator-policy-controlled FlareFlow |
131
+ | `POST /v1/flows/:id/protect` | protect `{source,input}` before model context |
132
+ | `POST /v1/flows/:id/inspect` | preflight `{sink,input}` without restoration |
133
+ | `POST /v1/flows/:id/authorize` | atomically restore or return a value-free 403 decision |
134
+ | `POST /v1/flows/:id/restore` | trusted final-application restoration |
135
+ | `GET /v1/flows/:id/snapshot` | value-free provenance, budget and audit state |
136
+ | `DELETE /v1/flows/:id` | discard mappings and counters |
129
137
  | `GET /healthz`, `GET /readyz` | liveness |
130
138
  | `GET /metrics` | Prometheus text |
131
139
 
@@ -133,8 +141,8 @@ Set `FLARE_GATEWAY_TOKEN` and every `/v1` call needs
133
141
  `Authorization: Bearer <token>`. Health and metrics stay open so a probe does not
134
142
  need a credential.
135
143
 
136
- Those eight paths are the only ones the gateway answers itself, and they are the
137
- only ones that shadow your upstream. Everything else under `/v1` — `/v1/chat/
144
+ Those listed control paths are the only ones the gateway answers itself, and
145
+ they are the only ones that shadow your upstream. Everything else under `/v1` — `/v1/chat/
138
146
  completions`, `/v1/models`, `/v1/messages` — is proxied like any other path, which
139
147
  is the whole point of putting the sidecar in front of a vendor that owns that
140
148
  namespace.
@@ -144,6 +152,52 @@ Sessions are held in memory, expire after `sessions.ttlMs` and are capped at
144
152
  attached. Because they are per-process, a replicated gateway needs sticky routing
145
153
  for session traffic — the stateless `/v1/redact` path does not.
146
154
 
155
+ ## FlareFlow for agent tools
156
+
157
+ Ordinary sessions remember placeholder mappings. FlareFlow additionally decides
158
+ where each protected value may be restored, using runtime-owned source,
159
+ detector, sink, JSON Pointer path, and cumulative-budget constraints. It is a
160
+ declassification boundary around model-produced tool calls, not a model prompt.
161
+
162
+ Enable it only with an operator policy in the gateway configuration:
163
+
164
+ ```json
165
+ {
166
+ "agentFlow": {
167
+ "enabled": true,
168
+ "sinks": {
169
+ "postgres.execute": {
170
+ "capabilities": [{
171
+ "id": "database-credential",
172
+ "sources": ["config"],
173
+ "detectors": ["url_credentials"],
174
+ "paths": ["/args/connectionString"],
175
+ "maxUses": 1
176
+ }]
177
+ },
178
+ "http.fetch": { "capabilities": [] }
179
+ }
180
+ }
181
+ }
182
+ ```
183
+
184
+ Clients open a flow with an empty `POST /v1/flows` body. They cannot submit or
185
+ widen its policy. A complete round trip is:
186
+
187
+ ```text
188
+ POST /v1/flows
189
+ POST /v1/flows/<id>/protect {"source":"config","input":...}
190
+ POST /v1/flows/<id>/authorize {"sink":"postgres.execute","input":...}
191
+ DELETE /v1/flows/<id>
192
+ ```
193
+
194
+ Denials are HTTP 403 with `ERR_AGENT_FLOW_BLOCKED` and a decision containing
195
+ only paths, labels, counts, and limit names. A denial restores nothing and does
196
+ not consume budget. Flow records are memory-only, idle-TTL-bound, capped by
197
+ `agentFlow.max`, and exported as the `flare_gateway_agent_flows` gauge. See the
198
+ [FlareFlow specification](../spec/FLAREFLOW.md) for the threat model and exact
199
+ invariant.
200
+
147
201
  ## Configuration
148
202
 
149
203
  Three layers, later winning: a config file, the environment, the command line.
@@ -166,7 +220,7 @@ flare-redact gateway --config docker/flare-gateway.example.json --print-config
166
220
  | `FLARE_GATEWAY_LOG` | `silent`, `info`, `debug` |
167
221
 
168
222
  See [`flare-gateway.example.json`](./flare-gateway.example.json) for the full
169
- shape, including per-route policies.
223
+ shape, including per-route policies and an operator-owned FlareFlow policy.
170
224
 
171
225
  ## Operating it
172
226
 
@@ -196,6 +250,8 @@ which makes "is the proxy actually in the path?" answerable from a single curl.
196
250
  - **The gateway's policy wins.** A client may pass options, but the configured
197
251
  policy is layered over them, so no caller can send `{"disable":["email"]}` and
198
252
  opt out. `transformSecret` from a client is rejected outright.
253
+ - **Agent clients cannot define declassification policy.** `/v1/flows` accepts
254
+ only an empty body; `agentFlow.sinks` comes from operator configuration.
199
255
  - **It binds to loopback by default.** In a container that has to be `0.0.0.0`;
200
256
  publish it as `127.0.0.1:8787:8787` or keep it on an internal network. A
201
257
  redaction proxy reachable from the internet is a proxy anyone can send data
@@ -41,6 +41,27 @@
41
41
  ],
42
42
 
43
43
  "sessions": { "ttlMs": 1800000, "max": 10000 },
44
+ "agentFlow": {
45
+ "enabled": true,
46
+ "ttlMs": 1800000,
47
+ "max": 10000,
48
+ "limits": { "tokenTtlMs": 3600000, "maxMappings": 10000, "maxEvents": 1000 },
49
+ "sinks": {
50
+ "postgres.execute": {
51
+ "capabilities": [
52
+ {
53
+ "id": "database-credential",
54
+ "sources": ["config", "postgres.result"],
55
+ "detectors": ["url_credentials"],
56
+ "paths": ["/args/connectionString"],
57
+ "maxUses": 2
58
+ }
59
+ ],
60
+ "budget": { "maxUses": 4, "maxUniqueValues": 2, "maxBytes": 1024 }
61
+ },
62
+ "http.fetch": { "capabilities": [] }
63
+ }
64
+ },
44
65
  "limits": { "maxBodyBytes": 8388608, "requestTimeoutMs": 120000 },
45
66
  "auditFindings": true,
46
67
  "metrics": true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flare-redact",
3
- "version": "1.5.0",
4
- "description": "Zero-dependency secret and PII redaction for any SDK, logs, HTTP, LLM prompts, and MCP tools — with a Docker sidecar gateway and Python, Go and Rust SDKs.",
3
+ "version": "1.6.0",
4
+ "description": "Zero-dependency secret and PII redaction for logs, prompts, and agent tools — with FlareFlow information-flow control and a polyglot sidecar.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -55,6 +55,10 @@
55
55
  "types": "./dist/middleware.d.ts",
56
56
  "default": "./dist/middleware.js"
57
57
  },
58
+ "./agent": {
59
+ "types": "./dist/agent.d.ts",
60
+ "default": "./dist/agent.js"
61
+ },
58
62
  "./pack": {
59
63
  "types": "./dist/pack.d.ts",
60
64
  "default": "./dist/pack.js"
@@ -74,6 +78,7 @@
74
78
  "dist",
75
79
  "bin",
76
80
  "spec/SPEC.md",
81
+ "spec/FLAREFLOW.md",
77
82
  "spec/detectors.json",
78
83
  "spec/detectors.schema.json",
79
84
  "spec/conformance",
@@ -83,6 +88,8 @@
83
88
  "bench/performance.mjs",
84
89
  "bench/adversarial-runtime.mjs",
85
90
  "bench/graph-vault.mjs",
91
+ "bench/agent-flow.mjs",
92
+ "bench/agent-flow-cases.json",
86
93
  "README.md",
87
94
  "CHANGELOG.md",
88
95
  "MIGRATION.md",
@@ -98,6 +105,7 @@
98
105
  "spec:conformance": "npm run build && node scripts/build-conformance.mjs",
99
106
  "gateway": "npm run build && node bin/flare-gateway.mjs",
100
107
  "benchmark": "npm run build && node bench/performance.mjs",
108
+ "benchmark:agent": "npm run build && node bench/agent-flow.mjs",
101
109
  "benchmark:adversarial": "npm run build && node bench/adversarial-runtime.mjs",
102
110
  "prepublishOnly": "npm run build",
103
111
  "benchmark:graph": "npm run build && node bench/graph-vault.mjs",
@@ -170,7 +178,10 @@
170
178
  "mcp",
171
179
  "ai-agents",
172
180
  "data-loss-prevention",
173
- "sdk"
181
+ "sdk",
182
+ "information-flow-control",
183
+ "agent-security",
184
+ "prompt-injection"
174
185
  ],
175
186
  "author": "Umud Hasanli (https://github.com/umudhasanli)",
176
187
  "license": "MIT",
@@ -196,8 +207,5 @@
196
207
  "doc": "docs",
197
208
  "example": "examples",
198
209
  "test": "test"
199
- },
200
- "dependencies": {
201
- "undici-types": "^6.21.0"
202
210
  }
203
211
  }