Creating Plot Twists
    Preparing search index...

    Class IntegrationsAbstract

    Built-in tool for managing OAuth authentication and syncable resources.

    The redesigned Integrations tool:

    1. Declares providers/scopes in build options with lifecycle callbacks
    2. Manages syncable resources (calendars, projects, etc.) per actor
    3. Returns tokens for the user who enabled sync on a syncable
    4. Supports per-actor auth via actAs() for write-back operations

    Auth and syncable management is handled in the twist edit modal in Flutter, removing the need for tools to create auth activities or selection UIs.

    class CalendarTool extends Tool<CalendarTool> {
    static readonly PROVIDER = AuthProvider.Google;
    static readonly SCOPES = ["https://www.googleapis.com/auth/calendar"];

    build(build: ToolBuilder) {
    return {
    integrations: build(Integrations, {
    providers: [{
    provider: AuthProvider.Google,
    scopes: CalendarTool.SCOPES,
    getSyncables: this.getSyncables,
    onSyncEnabled: this.onSyncEnabled,
    onSyncDisabled: this.onSyncDisabled,
    }]
    }),
    };
    }

    async getSyncables(auth: Authorization, token: AuthToken): Promise<Syncable[]> {
    const calendars = await this.listCalendars(token);
    return calendars.map(c => ({ id: c.id, title: c.name }));
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Merge scopes from multiple tools, deduplicating.

      Parameters

      • ...scopeArrays: string[][]

        Arrays of scopes to merge

      Returns string[]

      Deduplicated array of scopes

    • Retrieves an access token for a syncable resource.

      Returns the token of the user who enabled sync on the given syncable. If the syncable is not enabled or the token is expired/invalid, returns null.

      Parameters

      • provider: AuthProvider

        The OAuth provider

      • syncableId: string

        The syncable resource ID (e.g., calendar ID)

      Returns Promise<AuthToken | null>

      Promise resolving to the access token or null

    • Execute a callback as a specific actor, requesting auth if needed.

      If the actor has a valid token, calls the callback immediately with it. If the actor has no token, creates a private auth note in the specified activity prompting them to connect. Once they authorize, this callback fires.

      Type Parameters

      Parameters

      • provider: AuthProvider

        The OAuth provider

      • actorId: ActorId

        The actor to act as

      • activityId: Uuid

        The activity to create an auth note in (if needed)

      • callback: TCallback

        Function to call with the token

      • ...extraArgs: TArgs

        Additional arguments to pass to the callback

      Returns Promise<void>