@absolutejs/policy

中文文档
0.4.1发布于 2026/08/23MITTypeScriptES Module近 30 天下载 2808

Versioned provider-neutral policy lifecycle, simulation, and AuthZEN adapter for AI agent actions.

原始使用文档
文档目录3 节
  1. Provider-neutral evaluation
  2. AuthZEN, AARP, and COAZ
  3. Drizzle persistence

@absolutejs/policy

Immutable, provider-neutral policy lifecycle for agent actions. Drafts are validated and content-digested, versions only increase, activation atomically retires the previous version, evaluations record the exact version and digest, and simulation evaluates an unpersisted candidate without changing live policy.

Provider-neutral evaluation

createAuthzenAdapter() speaks the OpenID AuthZEN evaluation API while custom adapters can target Cedar, OPA, cloud IAM, or an embedded rules engine. PostgreSQL enforces one active version per policy with a partial unique index.

AuthZEN, AARP, and COAZ

Version 0.2 adds direct support for the OpenID AuthZEN AARP and COAZ Working Group Drafts. AARP helpers extract requestable denials, preserve their binding, submit idempotent access requests, persist portable task handles, and only produce approval context for a fresh PDP evaluation. COAZ validates MCP coaz / x-coaz-mapping declarations and constructs single or aligned bulk SARC requests through an injected CEL evaluator. Any mapping, PDP, or decision failure denies tool execution.

Drizzle persistence

Version 0.3 adds @absolutejs/policy/drizzle, a typed Postgres store for production deployments including Neon:

import {
    createDrizzlePolicyStore,
    policyDrizzleSchema
} from '@absolutejs/policy/drizzle';

const policyStore = createDrizzlePolicyStore({ db });

Include policyDrizzleSchema in the host's normal Drizzle migrations; the store never mutates schema at runtime. Activation locks a policy's versions, retires the prior active row, and moves the active pointer transactionally, backed by the one-active partial unique index. PolicyVersionInsertSchema and PolicyVersionSelectSchema are generated from the table with Drizzle-TypeBox. The structural SQL adapter remains available for compatibility, while new Drizzle applications can stay fully typed end to end.

版本与发布记录

@absolutejs/policy 共发布 6 个版本,首次发布于 2026/07/16;过去 12 个月发布了 6 个版本。

版本发布日期距今
0.4.1latest2026/08/232 个月前
0.4.02026/08/232 个月前
0.3.12026/07/273 个月前
0.3.02026/07/233 个月前
0.2.02026/07/163 个月前
0.1.02026/07/163 个月前

关于 @absolutejs/policy 的常见问题

@absolutejs/policy 是什么?

Versioned provider-neutral policy lifecycle, simulation, and AuthZEN adapter for AI agent actions.

如何安装 @absolutejs/policy?

在项目目录运行 npm install @absolutejs/policy,或使用 pnpm add / yarn add / bun add。

@absolutejs/policy 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@absolutejs/policy 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@absolutejs/policy 可以商用吗?

@absolutejs/policy 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@absolutejs/policy 的下载量有多少?

根据 npm 官方下载统计,@absolutejs/policy 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,808 次,日均约 94 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@absolutejs/policy 还在维护吗?

最新版本 0.4.1 发布于 2026/08/23(2 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/07/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。