AI-SDLC
AI-SDLC
API Reference

Agent Runner

Agent Runners

The orchestrator invokes AI coding agents through the AgentRunner interface. Runners are auto-discovered from environment variables via the RunnerRegistry.

AgentRunner Interface

Every runner implements:

interface AgentRunner {
  run(ctx: AgentContext): Promise<AgentResult>;
}

The orchestrator provides context (issue details, codebase profile, constraints) and the runner spawns the agent, collects output, and commits changes.

Available Runners

ClaudeCodeRunner

Invokes Claude Code CLI in --print mode.

PropertyValue
CLI commandclaude -p --model <model> --allowedTools <tools>
stdinPrompt sent via stdin
AuthANTHROPIC_API_KEY (inherited from environment)
Model overrideAI_SDLC_MODEL env var (default: claude-sonnet-4-5-20250929)
RegistrationAlways available (built-in)
import { ClaudeCodeRunner } from '@ai-sdlc/orchestrator';

CopilotRunner

Invokes GitHub Copilot CLI in --yolo autonomous mode.

PropertyValue
CLI commandcopilot -p <prompt> --yolo [--model <model>]
stdinNone (prompt is a CLI argument)
AuthGH_TOKEN or GITHUB_TOKEN (passed through environment)
Model overrideAI_SDLC_COPILOT_MODEL env var
RegistrationAvailable when GH_TOKEN or GITHUB_TOKEN is set
import { CopilotRunner } from '@ai-sdlc/orchestrator';

CursorRunner

Invokes Cursor CLI agent with NDJSON stream output.

PropertyValue
CLI commandcursor-agent --print <prompt> --force --output-format=stream-json [-m <model>]
stdinNone (prompt is a CLI argument)
AuthCURSOR_API_KEY
Model overrideAI_SDLC_CURSOR_MODEL env var
RegistrationAvailable when CURSOR_API_KEY is set

The runner parses NDJSON output to extract the final assistant message for use as the PR summary.

import { CursorRunner, parseStreamJson } from '@ai-sdlc/orchestrator';

CodexRunner

Invokes OpenAI Codex CLI in --full-auto --json mode.

PropertyValue
CLI commandcodex exec - --full-auto --json [-m <model>]
stdinPrompt written to stdin (Codex reads from -)
AuthCODEX_API_KEY
Model overrideAI_SDLC_CODEX_MODEL env var
RegistrationAvailable when CODEX_API_KEY is set

The runner includes an enhanced token usage parser that first tries NDJSON usage/token_usage events from stderr (accumulating across multiple events), then falls back to regex.

import { CodexRunner, parseTokenUsage } from '@ai-sdlc/orchestrator';

GenericLLMRunner

Invokes any OpenAI-compatible chat completions API over HTTP.

PropertyValue
TransportHTTP POST to /v1/chat/completions endpoint
AuthAPI key via Authorization: Bearer header
RegistrationAvailable when OPENAI_API_KEY or LLM_API_KEY + LLM_API_URL is set
import { GenericLLMRunner } from '@ai-sdlc/orchestrator';

Runner Registry

The RunnerRegistry manages discovery and selection of runners:

import { createRunnerRegistry } from '@ai-sdlc/orchestrator';

const registry = createRunnerRegistry();

// List all available runners
const available = registry.listAvailable();
console.log(available.map(r => r.name));
// ['claude-code', 'copilot', 'cursor', ...]

// Get a specific runner
const runner = registry.get('copilot');

// Get the default runner (first available)
const defaultRunner = registry.getDefault();

Auto-Discovery

discoverFromEnv() registers runners based on environment variables:

RunnerRequired Env Var(s)Source
claude-code(always available)built-in
copilotGH_TOKEN or GITHUB_TOKENenv
cursorCURSOR_API_KEYenv
codexCODEX_API_KEYenv
openaiOPENAI_API_KEYenv
anthropicANTHROPIC_API_KEYenv
generic-llmLLM_API_URL + LLM_API_KEYenv

Manual Registration

You can register custom runners:

import { RunnerRegistry } from '@ai-sdlc/orchestrator';

class MyCustomRunner implements AgentRunner {
  async run(ctx: AgentContext): Promise<AgentResult> {
    // Custom agent invocation logic
  }
}

const registry = new RunnerRegistry();
registry.register('my-agent', new MyCustomRunner());

Common Pattern

All CLI-based runners (Claude Code, Copilot, Cursor, Codex) follow the same subprocess pattern:

  1. Build promptbuildPrompt(ctx) constructs a prompt from issue details, constraints, codebase context, and episodic memory
  2. Spawn CLI — Run the agent CLI as a child process with appropriate flags
  3. Collect output — Buffer stdout and stderr
  4. Parse token usage — Extract input/output token counts from stderr for cost tracking
  5. Git diff — Run git diff --name-only and git ls-files --others to find changed files
  6. Commitgit add -A and git commit with the configured message template and co-author

Environment Variables

VariableDefaultDescription
AI_SDLC_MODELclaude-sonnet-4-5-20250929Model for ClaudeCodeRunner
AI_SDLC_COPILOT_MODEL(CLI default)Model override for CopilotRunner
AI_SDLC_CURSOR_MODEL(CLI default)Model override for CursorRunner
AI_SDLC_CODEX_MODEL(CLI default)Model override for CodexRunner
AI_SDLC_RUNNER_TIMEOUT900000 (15 min)Runner timeout in ms (supports duration strings)
AI_SDLC_LINT_COMMAND(none)Lint command injected into agent prompts
AI_SDLC_FORMAT_COMMAND(none)Format command injected into agent prompts
AI_SDLC_COMMIT_MESSAGE_TEMPLATEfix: resolve issue #{issueNumber}\n\n{issueTitle}Commit message template
AI_SDLC_COMMIT_CO_AUTHORClaude <noreply@anthropic.com>Co-author for commits