Recursive Proxy
wrap() intercepts every method call no matter how deeply nested, preserving your original TypeScript types completely.
Approval Gates
Pass requiresApproval to wrap() to pause execution until a human reviewer approves from the dashboard.
Automatic Rollback
If a reviewer rejects or any action fails, AgentRein reverses every previous action in LIFO order automatically.
The Recursive Proxy
The core of AgentRein SDK’s power comes from thewrap() method. Rather
than forcing you to learn a new syntax, wrap() uses a Recursive JavaScript
Proxy to intercept your existing client’s actions.
When you call agentrein.wrap(client, session, { connector }), it intercepts
every method call, no matter how deeply nested (e.g., octokit.rest.issues.create).
It tracks the action, logs it to the backend, executes the original function,
and registers it for potential rollback — while completely preserving your
original TypeScript types.
Approval Gates
For high-risk methods that need human sign-off, passrequiresApproval
directly to wrap():
Methods not listed in requiresApproval execute immediately without interruption. Only listed paths trigger the approval gate.
ApprovalRejectedError is thrown and
the session is automatically rolled back.