@salesforce/agents
    Preparing search index...

    Class ConnectionManager

    Manages JWT and standard connections for agent operations.

    This class provides:

    • Automatic JWT creation and validation
    • Separation of JWT connection (for SFAP) and standard connection (for org operations)
    • Guard installation to prevent JWT token clobbering
    • JWT validation utilities for debugging
    const manager = await ConnectionManager.create(connection);

    // Get JWT connection for SFAP calls
    const jwtConn = manager.getJwtConnection();
    await jwtConn.request({ method: 'POST', url: '/authoring/scripts', ... });

    // Get standard connection for org queries
    const standardConn = manager.getStandardConnection();
    await standardConn.query('SELECT Id FROM User LIMIT 1');
    Index

    Methods

    • Gets the standard (non-JWT) connection for org-instance operations. Use this for SOQL queries, metadata operations, tooling API, etc.

      Returns Connection

      The standard connection

    • Refreshes the standard connection by clearing the access token and requesting a new one. This is useful after agent operations to ensure subsequent org operations work correctly.

      Returns Promise<void>

      If the refresh fails

    • Creates a new ConnectionManager instance.

      Builds two separate Connection objects derived from the username on the supplied connection: a standard connection for org-instance operations (SOQL, tooling, metadata) and a JWT-upgraded connection for SFAP API calls. The supplied connection is read-only — it is never mutated.

      Parameters

      • connection: Connection

        The connection whose username is used to derive the new connections

      Returns Promise<ConnectionManager>

      A new ConnectionManager instance

      If JWT creation or validation fails, or if the connection has no username