Install
Scope-Enforced Functions
Create OpenAI function-calling tool definitions with built-in Grantex scope checks:Function Registry
UseGrantexFunctionRegistry to manage multiple functions and dispatch tool calls by name:
Audit Logging
Wrap any function withwithAuditLogging:
API Reference
createGrantexFunction(options)
| Option | Type | Description |
|---|---|---|
name | string | Function name (matches ^[a-zA-Z0-9_-]+$) |
description | string | Description shown to the LLM |
parameters | JsonSchema | JSON Schema for function arguments |
grantToken | string | Grantex JWT from token exchange |
requiredScope | string | Scope required to invoke this function |
func | (args: T) => Promise<unknown> | Function implementation |
{ definition, execute }.
GrantexFunctionRegistry
| Method | Description |
|---|---|
register(fn) | Register a function (chainable) |
definitions | All registered OpenAI tool definitions |
execute(name, args) | Execute a function by name |
withAuditLogging(fn, client, options)
| Option | Type | Description |
|---|---|---|
agentId | string | Agent ID for audit attribution |
grantId | string | Grant ID for the session |
Requirements
- Node.js 18+
@grantex/sdk>= 0.1.0