Corsair — Agent Integration Layer

2026-08-14 · page · source ↗ · source summary

Corsair is an open-source TypeScript library that acts as the integration-and-permission layer between an AI agent and ~120 SaaS APIs. Register typed plugins (GitHub, Slack, Gmail, Linear, …) and you get a compile-time-checked client — corsair.slack.api.messages.post(...) — where every call is gated by a permission matrix backed by a database the agent cannot reach, credentials are envelope-encrypted so the model never sees them, and destructive actions become expiring human-review links rather than "please don't" instructions in the prompt. It is the library-shaped answer to the credential-layer problem this wiki's Security and Sandboxing page argues is the real frontier.


Architecture

A pnpm-workspace + turborepo monorepo of ~128 packages. packages/corsair is the core (~24K lines); packages/<provider> holds one package per integration (~122 with an endpoints/ tree); www/ is the Next.js marketing/dashboard site; explorer/ is a CLI plugin catalog; docs/ carries the guides.

createCorsair({ plugins, database, kek, multiTenancy, permissions, manual, hub }) (in packages/corsair/core/index.ts) returns either a single-tenant client or a multi-tenant wrapper exposing withTenant(tenantId), plus keys (integration secrets) and permissions/manage namespaces.

The plugin contract (core/plugins/index.ts) is the whole design in one type: each plugin declares endpoints (a nested function tree), webhooks, a Zod schema (a synced entity store), keyBuilder (auth resolution), endpointMeta (per-endpoint risk level), endpointSchemas/webhookSchemas (Zod), hooks/webhookHooks (before/after), oauthConfig, errorHandlers, and webhook tenant-matchers.

The client surface is built at runtime by bindEndpointsRecursively (core/endpoints/bind.ts) — which wraps every function in the readonly guard → permission guard → retry → hooks → keyBuilder pipeline — but typed statically via UnionToIntersection over plugin namespaces (core/client/index.ts). So IntelliSense knows the full method tree even though the object is assembled by reflection.

Data model (db/index.ts): five tables — corsair_integrations, corsair_accounts, corsair_entities, corsair_events, corsair_permissions — over Kysely (Postgres in prod, SQLite in demo/tests). A hosted "Hub" (packages/corsair/hub/) adds OAuth connect + approval UI: dev delivers through the browser (?d=<token>), prod through an HMAC-signed envelope POSTed to a registered delivery URL.

Key techniques

Design decisions

Comparison notes


Sources: raw/corsair, Corsair: The Unified Integration Layer for Agents Last updated: 2026-08-14