Adding Drivers
Overview
Agent Manager uses a driver abstraction for agent support. Each driver knows how to spawn, resume, and detect the status of a specific AI CLI agent.
Steps
1
Create the driver file
Create a new driver in src/agents/drivers/ extending BaseDriver.
2
Implement required methods
Implement: spawn(), resume(), continue(), detectStatus().
3
Register the driver
Register it in src/agents/agent-registry.ts.
Driver Interface
Your driver must extend BaseDriver and implement these methods:
abstract class BaseDriver {
abstract readonly name: string;
abstract readonly displayName: string;
abstract readonly command: string;
// Spawn a new agent session in the given directory
abstract spawn(cwd: string): string[];
// Resume an existing session by ID
abstract resume(sessionId: string, cwd: string): string[];
// Continue the last session in the given directory
abstract continue(cwd: string): string[];
// Detect agent status from terminal output
abstract detectStatus(output: string): "idle" | "running" | "waiting" | "unknown";
} TypeScript Example
Here's a simplified example of what a new driver looks like:
src/agents/drivers/my-agent-driver.ts
import { BaseDriver } from "./base-driver.js";
export class MyAgentDriver extends BaseDriver {
readonly name = "my-agent";
readonly displayName = "My Agent";
readonly command = "my-agent";
spawn(cwd: string): string[] {
return [this.command, "--cwd", cwd];
}
resume(sessionId: string, cwd: string): string[] {
return [this.command, "--resume", sessionId, "--cwd", cwd];
}
continue(cwd: string): string[] {
return [this.command, "--continue", "--cwd", cwd];
}
detectStatus(output: string) {
if (output.includes("waiting for input")) return "waiting" as const;
if (output.includes("running")) return "running" as const;
return "idle" as const;
}
} Then register it in the agent registry:
src/agents/agent-registry.ts
import { MyAgentDriver } from "./drivers/my-agent-driver.js";
// Add to the drivers array
const drivers = [
new ClaudeDriver(),
new GeminiDriver(),
new MyAgentDriver(), // ← Add here
];