agent-manager

Adding Connectors

Overview

Connectors route events between the manager and external messaging platforms. Each connector implements a standard interface for connecting, disconnecting, and handling events.

Steps

1

Create the adapter file

Create a new adapter in src/connectors/adapters/ implementing ConnectorInterface.

2

Implement the interface

Implement: connect(), disconnect(), requestPermission(), postToolResult(), postNotification().

3

Add config schema

Add your connector's config schema in src/config/config.ts.

4

Wire it up

Wire it into src/connectors/connector-manager.ts.

Connector Interface

interface ConnectorInterface {
  readonly name: string;

  // Lifecycle
  connect(): Promise<void>;
  disconnect(): Promise<void>;

  // Permission flow
  requestPermission(request: {
    sessionId: string;
    tool: string;
    input: unknown;
  }): Promise<{ allowed: boolean }>;

  // Event forwarding
  postToolResult(result: {
    sessionId: string;
    tool: string;
    output: string;
  }): Promise<void>;

  postNotification(notification: {
    sessionId: string;
    message: string;
    type: "info" | "warning" | "error";
  }): Promise<void>;
}
TypeScript

Example

src/connectors/adapters/my-connector.ts
import type { ConnectorInterface } from "../connector-interface.js";

export class MyConnector implements ConnectorInterface {
  readonly name = "my-connector";

  async connect() {
    // Initialize your messaging client
  }

  async disconnect() {
    // Clean up resources
  }

  async requestPermission(request) {
    // Send the permission request to your platform
    // Wait for user response
    // Return { allowed: true/false }
    return { allowed: true };
  }

  async postToolResult(result) {
    // Forward tool output to your platform
  }

  async postNotification(notification) {
    // Forward notification to your platform
  }
}

Then add your config schema and wire it into the connector manager:

src/config/config.ts
const MyConnectorSchema = z.object({
  enabled: z.boolean().default(false),
  apiKey: z.string().optional(),
  // ... your config fields
});