agentleFS
bharath31bharath31/nominee/llms.txt

nominee

llms.txt2 starsChanged 4 months agoMITView on GitHub

Your agent got approval at 2:14. It executed at 2:31 with a dead token. Approval is the easy part: agent frameworks already provide useful approval, guardrail, and durable resume primitives — needsApproval and its equivalents can pause a tool call and ask a human. What they cannot tell you is what happens after: the token expired during the pause, the arguments drifted, the permission changed, or the approval got spent twice. nominee makes the moment after "approve" correct — token…

The file

Files
llms.txt
# nominee

Your agent got approval at 2:14. It executed at 2:31 with a dead token. Approval is the easy part: agent frameworks already provide useful approval, guardrail, and durable resume primitives — `needsApproval` and its equivalents can pause a tool call and ask a human. What they cannot tell you is what happens after: the token expired during the pause, the arguments drifted, the permission changed, or the approval got spent twice. nominee makes the moment after "approve" correct — token minted at execution · bound to the args a human saw · spendable once — and leaves a hash-chained receipt.

nominee is an open-source TypeScript library that checks every AI tool call before your tool code executes. Framework-neutral, zero dependencies in the core.

Beachhead ICP: TypeScript teams whose agent takes a write action on a third-party API on a user's behalf, where a human approves out of band (Slack / email / push), not inside the originating request. Self-selection test: does your approval come back in the same HTTP request that asked for it? Then you don't need nominee.

Lead proof: naive rotating refresh fails 7/8 under concurrency; nominee gets 8/8 with the same agent code. One command, no API keys, runs offline: `node examples/token-refresh-correctness/run.mjs`.

Agent frameworks already provide useful approval, guardrail, and durable resume primitives. nominee complements them when a tool decision must incorporate application user/resource authorization, exact-input binding, call-time credentials, narrowing delegation, or one evidence stream across runtimes.

nominee sits in-process between the model and tools. Every tool call is checked against declarative allow/deny/ask policy; official wrappers route through the decision-bound `run()` path; decisions are sealed into a hash-chained receipt log; and tools resolve fresh, scope-separated user credentials only after a single-use capability is consumed. Approvals are bound to a canonical hash of the exact input, so mutating arguments after approval throws `AuthorizationInputChangedError` instead of executing, and a capability executes once — an approved call cannot be replayed.

Layers: your agent/framework (AI SDK, Eve, OpenAI Agents, Mastra, LangChain, Cloudflare, MCP, standalone) → nominee (policy, approvals, receipts, tokens) → your vault/store (env, DB, OAuth2, Auth0 Token Vault, Supabase).

Key concepts:
- **Post-pause correctness**: credentials are resolved at execution time, inside the `run()` callback after the capability is consumed — a token is never older than the call it serves. When an action names a `resource`, the application authorizer is consulted while planning and again after capability consumption, so a permission revoked mid-approval fails closed. `resumeAction()` before consumption rotates the capability and invalidates the old value.
- **Observe mode**: `new Nominee({ mode: 'observe' })` + `nominee.observe(tools)` is report-only and needs no policy. Deny, ask, budget, and false-authorizer decisions are recorded but not enforced; runtime, integrity, authorizer, and persistence errors still fail closed. Policy verdicts remain unchanged on action records and hash-chained receipts, each marked `enforcement: 'observe'`. Schema-version-2 `nominee.observations()` reports callbacks that actually started, a bounded callable-tool inventory (including never-called tools), argument types/ranges, fingerprint-based bounded cardinalities, unbounded arguments, and policy verdicts; it does not retain raw string/boolean values or user IDs, while bounded numeric samples and aggregates may be sensitive. `formatObservations()` prints it. Safety rails: enforcement is the default, `production: true` refuses observe mode, startup prints an unmissable notice, and delegated sub-agents inherit the mode. It is a discovery tool, not a security control. `npx nominee-cli observe` demonstrates it on a sample agent.
- **Local console**: `npx nominee-cli console` starts an authenticated loopback-only UI with no account or cloud relay. It renders observe reports, generates a starter policy, live-tails receipt verdicts, explains verification limits, and settles `ask` calls once. A running process opts in with `createConsoleBridge()` from `nominee-cli/console`; no transport exists in core. The bridge denies or expires an approval when its console connection fails. Live state is process-local, not a production approval store.
- **Policy**: ordered `allow` / `deny` / `ask` rules over tool calls. Glob tool-name patterns (`github.*`), argument-level `when` predicates, call budgets (`maxCalls`), and a `fallback` effect (default `ask`). First match wins. The model cannot talk its way past a deny — `PolicyDeniedError` is thrown before the tool runs.
- **Decision-bound execution**: `nominee.run({ tool, input, user, resource, tenant, connection, scopes }, execute)` is the recommended path. Lifecycle: `planned → policy_checked → pending_approval → approved → capability_issued → executing → succeeded | failed`. A capability is single-use and bound to a canonical input hash — mutating arguments after approval throws `AuthorizationInputChangedError`. When an approval outlives the request, `ActionPendingError` carries a durable action id for `resumeAction()`. `prepareAction()`, `resolveActionApproval()`, and `executeCapability()` support durable workflows, and executors receive `{ action, input, token? }`.
- **guard()**: `nominee.guard(tools, { user })` wraps a whole tools object so every call routes through `run()` internally. Manual `authorize(...)` integrations call `await assertUnchanged(authorization, input)` before executing. `check(...)` is a side-effect-free dry run. Unbound `authorize()` and `token()` are disabled under `production: true`.
- **Approvals**: `ask` rules block until a human decides — via `onApprovalRequest` + `req.approve()/req.deny()`, a webhook calling `nominee.resolveApproval(id, 'approved')` or `resolveActionApproval()`, or natively via a strategy like Auth0 CIBA. Denials throw `ApprovalDeniedError`.
- **Receipts**: every decision, approval, and token grant appends to a hash chain (optional HMAC key) — tamper-evident against a downstream log editor, not non-repudiation (anyone who can verify could forge a consistent rewrite). New receipts include `v: 1` in the hashed content (receipt schema version, not `policyVersion`). `verifyReceipts` accepts unversioned legacy records and mixed chains; unknown `v` values fail closed. In-memory receipts retain the latest 1,000 entries by default (`retain: 'all'` keeps every entry; durable stores are the unbounded path). `formatReceipts()` prints a compact terminal summary. `delivery: 'strict'` waits for an async external sink before an allowed async operation returns; buffered sinks expose `flushReceipts()`. `verifyDurableReceipts()` verifies a durable stream + checkpoint. The instance methods are async — `await nominee.verifyReceipts()` / `await nominee.verifyDurableReceipts()` — while the standalone exported `verifyReceipts(receipts)` is synchronous. Durable agents can pass `resume: { seq, prev }` to continue a chain.
- **Delegation**: `nominee.delegate('sub-agent', { policy })` — the strictest outcome across the chain wins (deny > ask > allow); a sub-agent can only narrow authority, and its receipts carry the full chain `user → orchestrator → sub-agent`.
- **Tokens** (supporting act): under `run()`, strategies resolve credentials inside the execute callback after capability consumption — `getToken` receives `CredentialAuthorizationContext` (action, resource, capability, input hash, policyVersion). Standalone `nominee.token({ user, connection, scopes })` remains for dev; cache and single-flight keys include the canonical scope set. Strategies swap the backing store (plain function, OAuth2, Auth0 Token Vault, Supabase) without touching agent code.
- **Production mode**: `production: true` requires default-deny policy, durable action store, atomic durable receipt store with `delivery: 'strict'`, and durable provider approval state. `nominee-postgres` supplies the stores.
- **Adapters**: `nominee-ai` (Vercel AI SDK + Cloudflare Agents: `guardTools`, `nomineeTool`), `nominee-eve` (Vercel Eve: `nomineeTool`), `nominee-openai` (OpenAI Agents SDK), `nominee-mastra` (Mastra), `nominee-mcp` (MCP servers), `nominee-langchain` (LangChain JS). All adapters route through `run()` and surface `ActionPendingError` when an approval outlives the request. Core `guard()` covers anything with `{ execute }`.

Runnable proof, zero setup: `npx nominee-cli` runs a support-agent refund flow against the real package. A $25 refund runs, a $200 refund asks and executes once after approval, a $2,000 refund is blocked before the tool runs, and the receipt chain is verified. The proof makes no network calls after npm fetches the package, needs no API keys, and exits 1 if an invariant regresses. (Always invoke `npx nominee-cli`; `npx nominee` resolves the core library, which has no CLI.) `npx nominee-cli observe --out <file>` writes a report-only inventory; `npx nominee-cli console --report <file>` opens it locally and can receive explicit live hooks; `npx nominee-cli generate <file>` writes an evidence-commented, default-deny starter policy whose thresholds are observations rather than recommendations; `npx nominee-cli verify <receipts.json>` checks a receipt chain offline; `npx nominee-cli check <policy-file>` lints tool-name patterns, using the embedded observed inventory when present. Source: https://github.com/bharath31/nominee/tree/main/packages/cli

Lead proof: https://github.com/bharath31/nominee/tree/main/examples/token-refresh-correctness — naive rotating refresh fails 7/8 under concurrency; nominee gets 8/8 with the same agent code (no mocks that cheat). Supporting security proof: a prompt-injected agent tries to exfiltrate email and is blocked by policy before the tool runs, with the refusal hash-chained onto the receipt log — https://github.com/bharath31/nominee/tree/main/examples/prompt-injection-blocked (no API keys). This is blast-radius containment, not detection: the model can be hijacked and the denied tool still does not execute — and the denial is on the record. Live version: https://nominee.dev/agent. Governed MCP servers (OAuth is the connection; nominee is the action): https://nominee.dev/docs/mcp/ and `nominee-mcp`.

Production refund example: Vercel AI SDK tools, durable approval endpoints, and PostgreSQL action/receipt stores under `production: true` — https://github.com/bharath31/nominee/tree/main/examples/support-refund-agent

When you DON'T need nominee: your approval comes back in the same HTTP request that asked for it (no pause, no staleness); your agent only reads public or low-risk data; your framework already enforces every permission your application needs; or a few local if-statements cover the tools and you do not need durable approvals or shared limits.

## Quick Start
```typescript
import { Nominee, allow, deny, ask } from 'nominee'

const nominee = new Nominee({
  policy: {
    rules: [
      allow('orders.read'),
      allow('refund.issue', { when: ({ input }) => input.amount <= 50 }),
      ask('refund.issue', { when: ({ input }) => input.amount <= 500 }),
      deny('refund.issue'),
      deny('customers.export'),
    ],
    fallback: 'deny',
  },
  onApprovalRequest: (req) => req.approve(), // wire to Slack / push / your UI
})

const tools = nominee.guard(
  { 'orders.read': readOrder, 'refund.issue': issueRefund, 'customers.export': exportCustomers },
  { user: 'alice' },
)
// Denied calls throw PolicyDeniedError before the tool runs; every outcome is on nominee.receipts.
```

Docs: https://nominee.dev/docs/ · GitHub: https://github.com/bharath31/nominee · npm: https://www.npmjs.com/package/nominee

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.