Install
Scope-Enforced Tools
Create Vercel AI SDK tools with Grantex authorization. Scope is checked at construction time — if the token is missing the required scope,createGrantexTool throws immediately:
Inspect Grant Scopes
UsegetGrantScopes to check what scopes a token has before creating tools:
Audit Logging
Wrap tools withwithAuditLogging to log every invocation to the Grantex audit trail:
API Reference
createGrantexTool(options)
Throws
GrantexScopeError if scope is missing.
getGrantScopes(grantToken)
Returns unverified string[] scopes decoded from the token’s scp claim. Use this only for display or debugging; protected tool execution performs signature verification.
withAuditLogging(tool, client, options)
GrantexScopeError
Requirements
- Node.js 18+
@grantex/sdk>= 0.1.0ai>= 4.0.0 (Vercel AI SDK)zod>= 3.0.0