Corsair Documentation

repository·main·Indexed 26 days ago

https://github.com/corsairdev/corsair

A unified integration layer for AI agents that provides secure connections to third-party applications like Slack, GitHub, and Gmail. Corsair manages credentials, enforces granular permission modes, and provides multi-tenant isolation. The ecosystem includes specialized SDKs such as @corsair/gmail-sdk and @corsair/hubspot-sdk, featuring TypeScript support, automatic webhook routing, and data synchronization.

Tokens
342.4K
Snippets
934
Records
1.9K
Agent score
92%

What's inside Corsair

  1. Overview of HeyGen plugin capabilities

    main

    The @corsair-dev/heygen plugin provides coverage for over 70 operations across several domains:

    • Videos: generate, template generate, WebM, translate, status, list/delete (v1 + v3).
    • Avatars: list (v3), groups, photo avatars, looks, talking photos, motion, upscale.
    • Voices / TTS: Starfish TTS, previews, list v1/v2/v3, design, clone.
    • Streaming: session lifecycle, ICE, tasks, list avatars/history.
    • Knowledge bases: create, list, update, delete.
    • Assets & templates: list/get templates, upload (legacy raw + v3 multipart), folders.
    • Webhooks & quota: endpoint CRUD, event types, remaining quota, users/me.
    • v3 expansions: video agents, brand kits/glossaries, avatar realtime, lipsync, hyperframes, AI clipping, proofread, video translations.

    Warning: Paths marked [B] in the source code are best-effort implementations where HeyGen's public documentation is incomplete. Verify these against a live account before production use.

  2. Compare Corsair deployment modes

    main

    Choose the correct setup based on where you want the Corsair logic and data to reside:

    Requirement
    Self-hosted SDK + Hub: Corsair runs in your app, credentials in your database, Hub handles public-URL surfaces (OAuth/Approvals).
    Corsair App (Hosted): A fully hosted setup where Corsair runs everything via @corsair-dev/app.
    Fully Self-hosted: No Hub relay used; you host all OAuth and approval URLs yourself.

    Note: The /api/corsair route requires a server-side environment. Pure client-side SPAs (Angular/Vue/Svelte) must wire this route into a backend (SSR server, Express, etc.).

  3. Security and Credential Management

    main

    Corsair is designed to prevent agents from accessing sensitive credentials:

    • Credential Isolation: Agents only see method names and results. Credentials are resolved internally by Corsair at call time. The agent cannot read, log, or exfiltrate them.
    • Storage: Credentials are stored in an encrypted database using envelope encryption. A Key Encryption Key (KEK) that you control encrypts per-tenant data keys, which in turn encrypt the actual secrets.
    • Manual Key Management: If you prefer to manage your own keys instead of using the built-in key manager, you can pass them directly to Corsair.
  4. Explore the Corsair Minimal Demo

    main
    The demo/minimal project is a lightweight demonstration of the Corsair integration layer. It showcases how to initialize Corsair with multiple integrations, handle incoming webhooks via a single Express endpoint, and interact with the API using full TypeScript support. This demo is specifically designed to highlight Corsair's core strengths: easy setup, automatic webhook routing, multi-tenancy, and automatic data synchronization.
  5. Key Corsair concepts for setup

    main

    When setting up Corsair, understand the following terminology:

    • Tenant: Represents one of your users.
    • Plugin: Represents a single service integration (e.g., Slack, GitHub).
    • Hub: The hosted component that manages public-facing surfaces like OAuth connect pages, callbacks, and approvals. It relays data but does not store your credentials.
    • Delivery URL: The endpoint where Hub sends results. This URL self-registers upon the first request.
    • Multi-tenant: The standard mode where the integration connects to your end users' accounts rather than just your own app's tools.
    • Permission Modes: You can choose between using Corsair Hub (preferred) or a manual, self-hosted mode.
  6. Store Reddit credentials

    main

    After installing the plugin, you must store your credentials using the Corsair CLI. Use the specific key names required by Reddit (e.g., api_key=, bot_token=, or OAuth client fields).

    For Solo Mode:

    pnpm corsair setup --plugin=reddit

    For Multi-Tenant Mode: Store secrets per-tenant after creating the tenant record:

    pnpm corsair setup --plugin=reddit --tenant=<tenantId>
  7. Configure Corsair with plugins

    main

    Initialize Corsair by calling createCorsair and providing an array of plugins for the integrations you wish to use (e.g., slack(), github(), gmail(), linear(), googlecalendar()).

    // corsair.ts
    export const corsair = createCorsair({
      plugins: [slack(), github(), gmail(), linear(), googlecalendar()],
    });
  8. Extend OpenWeatherMap with Hooks and Webhooks

    main

    You can add logging, approvals, or side effects to OpenWeatherMap interactions using Corsair's hook system:

    • Hooks: Use these on API calls to intercept or modify requests/responses.
    • WebhookHooks: Use these on incoming events to handle asynchronous data or notifications.

    Refer to the general Corsair Hooks and Webhooks documentation for routing and payload patterns.

  9. Run tests for @corsair-dev/gemini

    main

    Use pnpm to run tests for the Gemini package.

    • Offline unit tests: Always run and do not require an API key.
    • Live API tests: Only run if GEMINI_API_KEY is set. Image/Veo live tests will soft-skip on 429/404 errors to prevent CI failures due to free-tier quotas.
    pnpm --filter @corsair-dev/gemini test
  10. Install and configure the Jira plugin

    main

    To use Jira with Corsair, install the @corsair-dev/jira package and add it to your createCorsair configuration. You can use the plugin in either Solo or Multi-Tenant mode depending on your multiTenancy setting.

    Installation

    pnpm install @corsair-dev/jira

    Configuration

    Solo Mode:

    import { createCorsair } from 'corsair';
    import { jira } from '@corsair-dev/jira';
    
    export const corsair = createCorsair({
    	// ... other config options,
    	multiTenancy: false,
        plugins: [jira()],
    });

    Multi-Tenant Mode:

    import { createCorsair } from 'corsair';
    import { jira } from '@corsair-dev/jira';
    
    export const corsair = createCorsair({
    	// ... other config options,
        multiTenancy: true,
        plugins: [jira()],
    });
  11. Set up an HTTP handler for Razorpay webhooks

    main

    To handle incoming Razorpay webhooks, point your provider's subscription URL to a Corsair HTTP handler. You must use the processWebhook function from corsair, passing your corsair instance, the request headers, and the request body.

    import { processWebhook } from "corsair";
    import { corsair } from "@/server/corsair";
    
    export async function POST(request: Request) {
        const headers = Object.fromEntries(request.headers);
        const body = await request.json();
        const result = await processWebhook(corsair, headers, body);
        return result.response;
    }