Entry points
flue-guard is ESM-only, requires Node >= 22.19, and declares peer dependencies @flue/runtime ^2.0.8 and valibot ^1.0.0.
Six import paths. The root has what most apps need: govern, the types, and the adapter interfaces. Implementations live on subpaths so the root stays small.
| Import | Contents |
|---|---|
flue-guard | govern, createGovernedToolkit, caller, trusted, always, never, ContextStore, the errors, core types, adapter interfaces |
flue-guard/audit | HashChainAuditLog, InMemoryAuditLog, hashEntry, verifyChain, GENESIS_HASH |
flue-guard/adapters | Built-in adapter implementations and helpers: defaultRbac, autoApprove, redactors, InMemoryIdempotencyStore, scope matchers, toFlueTool, hostContextResolver |
flue-guard/jev | Optional createJevGuard, JevGuardOptions, JevHazard, JevThreshold; requires optional peer @typesafe-ai/sdk 0.6 or 0.7. Guide |
flue-guard/replay | replay, ReplayOptions, ReplayReport, ReplayChange, ReplayToolSpec. Also the flue-guard replay command. Guide |
flue-guard/testing | InMemoryAuditLog, InMemoryIdempotencyStore (re-exported test doubles) |
flue-guard (root)
Functions & classes
| Export | Description |
|---|---|
govern(options) | Create a toolkit with Flue's defineTool wired in; the way in. Reference |
createGovernedToolkit(options) | The explicit form: same toolkit, you inject defineTool. Reference |
caller(check) | Authorization anchored to the authenticated caller; same as passing check itself. Reference |
trusted(source, check) | Authorization anchored to a registered trusted source. Reference |
always(reason?) / never() | Shortcuts for "always ask" and "never ask" approval policies. Reference |
ContextStore | AsyncLocalStorage-backed trusted-context holder. Reference |
| Error classes & guards | GovernanceError and subclasses, isGovernanceError, isGovernanceDenial, isApprovalPending. Reference |
Types
| Export | Description |
|---|---|
GovernOptions, GovernedToolkitOptions | Options for govern / createGovernedToolkit |
GovernedToolkit | The toolkit: tool, defineGovernedTool, withContext, withSignal, run, current, peek |
GovernedToolSpec, GovernedFlueToolSpec | The tool spec (explicit-generic and schema-inferred forms) |
ToolGuard, GuardRequest, GuardAssessment | Provider-neutral semantic guard interfaces |
AuthorizeSpec, CallerCheck, TrustedSource | Authorization gate shapes |
SignalDelivery | The part of Flue's useDelivery() result that withSignal reads |
PendingApprovalOutput | What the model sees when a call waits for approval under Flue |
ToolCallInfo | The host's call id, passed to a governed tool's execute |
TrustedContext, ExecutionContext | The context your app binds / the one handlers receive |
ContextResolver | (hostContext?) => TrustedContext | Promise<TrustedContext> |
Decision, Outcome | Audit vocabulary: allow|deny|defer, executing|success|error|denied|replayed|pending |
ArgValidator, ParseValidator, FnValidator, StandardSchemaV1, InferArgs | Parameter-schema typing |
FlueCompatibleTool, FlueToolDefinition, FlueDefineTool | The governed tool before and after it becomes a Flue tool |
GovernanceErrorCode | Union of every machine-readable error code |
| Adapter interfaces | AuditLog, AuditEntry, AuditEntryBody, AuditInput, IdempotencyStore, IdempotencyRecord, IdempotencyStatus, BeginResult, RbacAdapter, RbacRequest, ApprovalAdapter, ApprovalPolicy, ApprovalRequest, ApprovalDecision, Redactor. Reference |
flue-guard/audit
| Export | Description |
|---|---|
HashChainAuditLog | Append-only hash-chained JSONL file log (single-writer) |
InMemoryAuditLog | Full hash-chained in-memory log |
hashEntry(body, hmacKey?) | Compute an entry's chain hash (Web Crypto) |
verifyChain(entries, hmacKey?) | Walk a chain; report the first inconsistency |
GENESIS_HASH | The 64-zero hash the first entry chains from |
Details: Audit log reference.
flue-guard/adapters
| Export | Description |
|---|---|
defaultRbac | Any-of role match against ctx.actor.roles |
autoApprove | Approval adapter that approves everything (local dev) |
defaultRedactor | Masks common sensitive field names + PII-like strings |
redactFields(fields?, options?) | Build a structural field-masking redactor |
textRedactor(transform, options?) | Adapt a string-based PII library into a Redactor |
composeRedactors(...redactors) | Run redactors left to right |
identityRedactor | Changes nothing |
InMemoryIdempotencyStore | Process-local idempotency store (the default) |
scopeAllowed(requested, allowed) | Does any allowed pattern match this scope? |
normalizeScopes(scopes) | Scope declaration -> string[] |
deniedScopes(requested, allowed) | The requested scopes not covered by allowed |
toFlueTool(governed) | Governed tool -> Flue ToolDefinition (manual wiring path) |
hostContextResolver(extract) | Context resolver for non-Flue hosts that pass a context object |
Details: Adapters reference.
flue-guard/replay
| Export | Description |
|---|---|
replay(options) | Run recorded calls against tool specs; resolves to a ReplayReport. Verifies the chain first and throws GovernanceConfigError when it does not hold |
ReplayOptions | entries, tools, and optional authorize (default false), hmacKey, rbac, trustedSources |
ReplayReport | total, unchanged, newlyDenied, newlyAllowed, notReplayed, noSpec |
ReplayChange | One changed call: seq, tool, actorId, was, now, checked |
ReplayCheck | "roles" | "scope" | "authorize" |
ReplayToolSpec | Any tool spec, whatever its argument and result types |
notReplayed reasons: recorded before replay support, no caller was recorded, arguments were invalid, a check crashed when recorded, inputs not fully recorded.
The package also installs the command flue-guard replay <audit.jsonl> --tools <module> [--authorize]. It reads the key of a keyed log from FLUE_GUARD_AUDIT_HMAC_KEY. Exit codes: 0 no call is newly denied, 1 at least one is, 2 the replay could not run.
How to use it: Replay a rule change.
flue-guard/testing
| Export | Description |
|---|---|
InMemoryAuditLog | Same class as flue-guard/audit exports; here for discoverability in tests |
InMemoryIdempotencyStore | Same class as flue-guard/adapters exports |