PermDock
Typed permissions for TypeScript apps, APIs, databases and AI agents: one definition and one decision object, checked in the UI, the API, SQL, Postgres RLS and agent tool approvals.

Docs · npm package · Changelog · Product brief · Roadmap · Agent guide · Contributing · Report issue
permdock is on npm (packages/permdock/package.json holds the version): one package with core, every adapter, the permdock CLI and permdock/testing. Releases follow semver; the roadmap says how versions are numbered.
pnpm add permdock
import { allow, getPermDock, definePolicy, principal, role } from "permdock";
const policy = definePolicy(
{ permissions, roles },
{
roles: [
role(roles.member, [
allow(permissions.post.read),
allow(permissions.post.update, { where: { authorId: principal.id } }),
allow(permissions.post.delete, { approval: "human" }),
]),
],
subject: (user: User | null) => user && { id: user.id, roles: user.roles },
},
);
const permdock = await getPermDock(policy, user);
permdock.decide(permissions.post.delete, post); // { outcome: 'approval-required', token, ... }
The npm README walks through every surface with code; the docs are the full reference.
Why PermDock
Permission logic in a typical TypeScript app lives in if (user.role === 'admin') checks in components, 'post:update' strings in middleware, a hand-written client copy of the server rules, RLS policies nobody diffs against the app, and AI agents that call tools with no way to say "ask first". PermDock replaces them with one typed definition and one Decision.
- Typed references.
permissions.post.update is a frozen object with a key, a scope and the resource's Standard Schema. A rename is a type error everywhere it is used, and the definition is the catalog.
- Policy as data. Roles are arrays of
allow / deny grants with a portable condition AST that evaluates in the browser, filters arrays, compiles to Drizzle, Prisma and Kysely where, and generates Postgres RLS.
- Three outcomes.
granted, denied or approval-required, with denial reasons, permitted alternatives and a replay-safe approval token. explain() names the grant or deny that decided it.
- Agents as actors. A subject carries the user and the agent acting for them. Policy delegations cap what an agent may do, and approvals take a quorum, stages and escalation.
- Changes reviewed in CI.
permdock diff fails a pull request that takes access away, and permdock rls verify checks the database against can().
- Adoption in steps. An app keeps its permission keys, SQL helpers, tokens and custom roles while it moves over (existing apps).
- Embedded. Every decision runs in-process. PermDock Cloud is optional and never on the decision path.
What ships