AbsoluteJS

Agency

@absolutejs/agencyv0.7.4betaAI

Provider-agnostic AI agent authorization with policy, approvals, rejections, durable delegation, execution leases, receipts, kill switches, and signed handoffs.

#Installation

BASH
bun add @absolutejs/agency

#Capabilities

Overview

Provider-neutral action authorization for AI agents.

Authentication says which agent is acting and on whose behalf. Agency decides whether that exact action may happen now, coordinates prerequisites such as human approval or terminal human rejection, issues a short-lived single-use execution lease, and records a receipt after execution.

The core contract is deliberately provider-neutral. @absolutejs/agency/authzen contains adapters for the OpenID AuthZEN Authorization API, its Access Request and Approval Profile (AARP), and MCP tool mappings compatible with the COAZ profile direction.

Agentic control plane

createAgentControlPlane() inventories an agent's registrations, delegations, tasks, credential grants, allowances, mandates, leases, and other capabilities through small AgentControlSource adapters. Revocation activates a durable kill switch first, then fans out cleanup to every source. Pass the control plane to createAgency({ control, ... }); action requests, lease issuance, and execution then fail closed while the agent is disabled.

Handoffs, simulation, and telemetry

createAgentDelegationAuthority() issues durable, revocable delegation grants inside Agency. Every child must attenuate its parent's user, audience, expiry, action scopes, effects, resource boundaries, and spend ceiling; delegation depth is bounded and revocation cascades to descendants. Pass the authority as createAgency({ delegations: authority, ... }) to re-check the complete active chain when an action is requested, when its execution lease is issued, and immediately before that lease is consumed.

signAgentHandoff() / verifyAgentHandoff() create audience-bound,

expiring, replay-protected agent-to-agent capability envelopes. Use attenuateAgentHandoff() for additional hops so scopes, spend, expiry, and user identity cannot escalate.

Show 10 more

signAgentHandoffWith() / verifyAgentHandoffWith() accept independent

signer and verifier providers over canonical bytes. Cloud KMS/HSM adapters can keep private keys non-exportable, rotate by keyId, and reject algorithms without changing the handoff wire contract. HS256 remains available for compatibility and local development.

simulateAction() evaluates policy and produces the same canonical binding

without storing an action, issuing a lease, or running an effect.

createAgencyTelemetryEmitter() maps every Agency event to stable

agent. event names and attributes that can feed OpenTelemetry or any audit sink without coupling the core package to a telemetry vendor.

Memory stores are development defaults. Production deployments should supply durable, transactional stores for Agency state, kill switches, and handoff nonces.

PostgreSQL production state

agencyPostgresSchemaSql() creates indexed tables for actions, approvals, rejections, leases, receipts, kill switches, and replay nonces. The adapters accept a small structural AgencySqlClient, so Bun SQL, Neon, pg, and transaction-aware host clients can be used without coupling the core package to a database driver.

Lease consumption is one conditional UPDATE, making concurrent execution attempts safe across processes. Handoff nonces are persisted as SHA-256 digests, not bearer values. Apply agencyPostgresSchemaSql() during deployment before starting workers.

Outcomes

What you can build

Action-level authorization

Authorize the exact action an authenticated agent wants to perform, including actor, delegation, effects, resource, input digest, spend, and expiry.

Human and policy control

Coordinate approvals, terminal rejections, revocation, simulation, short-lived leases, execution, and receipts through one provider-neutral control plane.

Hardening checklist

Production guidance

Use durable Agency stateReplace memory stores with transactional durable stores for actions, decisions, leases, receipts, kill switches, delegation state, and replay nonces before production.

Follow in order

Troubleshooting path

1
An action was not executed
Trace the canonical action binding, policy decision, approval or rejection, lease issuance, lease consumption, and execution receipt. A mismatch at any boundary should fail closed.

#@absolutejs/agency quick start

Partial snippet

# @absolutejs/agency

TS
import { createAgency, createMemoryAgencyStore } from "@absolutejs/agency";

const agency = createAgency({
  policy: yourPolicyDecisionPoint,
  store: createMemoryAgencyStore(),
});

const { action, decision } = await agency.request({
  action: "send_email",
  actor: {
    agentId: "sales-agent",
    delegationId: "delegation-123",
    scopes: ["email:send"],
    userId: "user-123",
  },
  effects: ["send", "external-network"],
  input: { subject: "Hello", to: "buyer@example.com" },
  resource: { id: "buyer@example.com", type: "email_recipient" },
});

if (decision.kind === "allow") {
  const lease = await agency.issueLease(action.actionId);
  const { receipt } = await agency.execute({
    executor: "email-provider",
    leaseId: lease.leaseId,
    run: () => email.send(action.input),
  });
}

if (decision.kind === "deny" && decision.requestable) {
  await agency.reject({
    actionId: action.actionId,
    reason: "The recipient is outside the approved customer account.",
    rejectedBy: "operator-123",
  });
}

#PostgreSQL production state

Partial snippet

agencyPostgresSchemaSql() creates indexed tables for actions, approvals, rejections, leases, receipts, kill switches, and replay nonces. The adapters accept a small structural AgencySqlClient, so Bun SQL, Neon, pg, and transaction-aware host clients can be used without coupling the core package to a database driver.

TS
const store = createPostgresAgencyStore({ client: sqlClient });
const controlStore = createPostgresAgentControlStore({ client: sqlClient });
const replayStore = createPostgresHandoffReplayStore({ client: sqlClient });

#Handoffs, simulation, and telemetry

Partial snippet

createAgentDelegationAuthority() issues durable, revocable delegation grants inside Agency. Every child must attenuate its parent's user, audience, expiry, action scopes, effects, resource boundaries, and spend ceiling; delegation depth is bounded and revocation cascades to descendants. Pass the authority as createAgency({ delegations: authority, ... }) to re-check the complete active chain when an action is requested, when its execution lease is issued, and immediately before that lease is consumed.

TS
const delegations = createAgentDelegationAuthority({
  audience: "https://app.example",
  store: createMemoryAgentDelegationStore(), // use PostgreSQL in production
});

const grant = await delegations.issue({
  audience: "https://app.example",
  issuerAgentId: "user-agent",
  subjectAgentId: "calendar-agent",
  userId: "user-1",
  scopes: ["calendar.create"],
  effects: ["write", "external-network"],
  resourceTypes: ["calendar"],
  expiresAt: Date.now() + 3_600_000,
});

#Public entry points

Supported entry points declared by this project’s package manifest. Internal dist paths are not part of the package contract.

Public package entry point declared in package.json.

@absolutejs/agency@absolutejs/agency/authzen@absolutejs/agency/manifest@absolutejs/agency/manifest.json

#Package commands

Scripts declared by this project’s package manifest.

bun run buildrm -rf dist && bun build src/index.ts src/authzen.ts src/manifest.ts --outdir dist --root src --sourcemap --target=bun --external drizzle-orm --external 'drizzle-orm/*' && tsc --project tsconfig.build.json && absolute-manifest emit
bun run check:packagebun run typecheck && bun run test && bun run verify-package && bun run build && bun run verify-package --artifacts
bun run formatprettier --write "./**/*.{ts,json,md}"
bun run testbun test tests/
bun run typechecktsc --noEmit

#API reference

Search the declarations exported by the current package type files. Expand a symbol to inspect its source-backed signature.

66 symbols
actionBindingexportPermalink
TS
actionBinding
Exported from @absolutejs/agency
Use this API in an outcome:Govern an AI agent

Continue toward an outcome

These playbooks show where this package fits, how to verify the combined system, and what changes before production.