Skip to main content

ability-sdk

This library was generated with Nx.

Building

Run nx build ability-sdk to build the library.

Usage

Vincent Policy & Ability SDK

This library provides a type-safe lifecycle system for defining and composing policies and abilities, with strong TypeScript inference support throughout.

Core Concepts

  • Policies encapsulate decision logic (precheck, evaluate, commit) and define their input/output schemas.
  • Abilities orchestrate multiple policies and expose precheck and execute lifecycle methods.
  • Context injection provides allow() / deny() and succeed() / fail() methods, with schema-safe return typing.
  • All inference is preserved automatically using createVincentPolicy, createVincentAbilityPolicy, and createVincentAbility.

Calling commit() on a Policy from within a Ability

Policies can define a commit() lifecycle method to finalize changes once an ability executes successfully. These commit() functions are injected automatically into the allowedPolicies object of the AbilityContext.

Example Policy (max daily spend)


Example Ability - Uniswap

Tip

Ability and policy authors should export the result of createVincentPolicy() / createVincentAbility()