Skip to content

API Reference

Commander has two layers of API surface. Most apps only need Layer 1.

Layer 1 — Public integration (start here)

SurfacePackage / entryBest for
CLIcommander · packages/core/src/cliEntry.tsTerminal, scripts, CI
TypeScript SDK@commander/sdkCommanderClientEmbed in Node apps
HTTP APIServer :4000Polyglot clients, Web Console
Python SDKcommander-ai (HTTP client)Python against the API server

TypeScript SDK

typescript
import { CommanderClient, createClient } from '@commander/sdk';

const client = new CommanderClient({ provider: 'openai' });
await client.connect();
const result = await client.run('audit this repo');
console.log(result.status, result.summary);
await client.disconnect();

// or
const c = await createClient();
await c.run('explain the architecture');
await c.disconnect();
MethodRole
connect / disconnectLifecycle
run(task)Full execution → ExecutionResult
plan(task)Deliberation only
onEvent(handler)Stream agent/tool events
createAgent / memory helpersAdvanced session control

npm status: packages are monorepo-first; public publish is in progress. See Agent SDK.

HTTP (server)

bash
curl http://localhost:4000/health
curl http://localhost:4000/metrics

curl -X POST http://localhost:4000/execute \
  -H "Authorization: Bearer $COMMANDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"task":"analyze this repository","mode":"plan"}'

Architecture V2 durable API: POST /v1/runs — see V2 Migration.

Python

python
from commander import CommanderClient
# thin httpx client → API server

Python SDK.


Layer 2 — Runtime orchestration components

These modules power deliberation, budgeting, memory, and verification inside @commander/core. Use them when extending the runtime — not for normal app integration.

ComponentPurpose
Task Complexity AnalyzerScore task → recommend topology
Adaptive OrchestratorMulti-agent plan + coordination
Token Budget AllocatorBudget split across agents
Three-Layer MemoryWorking · episodic · long-term
Reflection EnginePost-run evaluation
Consensus CheckerMulti-model votes for high risk
Inspector AgentHealth / issue detection

When to use Layer 2

  • Building a custom topology or planner
  • Research / instrumentation of memory and consensus
  • Tests that isolate a single subsystem

When not to use Layer 2

  • Product features that only need “run this task” → use CommanderClient
  • Remote multi-language clients → use HTTP

Minimal Layer 2 example

typescript
import {
  TaskComplexityAnalyzer,
  AdaptiveOrchestrator,
  TokenBudgetAllocator,
} from '@commander/core';

const analyzer = new TaskComplexityAnalyzer();
const complexity = analyzer.analyze({
  id: 'task-1',
  description: 'Build distributed logging system',
  riskLevel: 'high',
});

const allocator = new TokenBudgetAllocator({ baseBudget: 100_000 });
const budget = allocator.allocate(
  complexity.recommendedTopology,
  complexity.score,
  3,
);

const orchestrator = new AdaptiveOrchestrator();
orchestrator.registerAgent({
  id: 'lead',
  name: 'Lead',
  role: 'architect',
  capabilities: [],
});

const plan = orchestrator.createPlan(
  [{ id: 'task-1', description: '...', complexity: complexity.score }],
  complexity.recommendedTopology,
);

Global accessors

Some components expose process singletons (used by the runtime/SDK helpers):

  • getGlobalTaskComplexityAnalyzer()
  • getGlobalAdaptiveOrchestrator()
  • getGlobalTokenBudgetAllocator()
  • getGlobalThreeLayerMemory()
  • getGlobalReflectionEngine()
  • getGlobalConsensusChecker()
  • getGlobalInspectorAgent()

Prefer CommanderClient unless you are sure you need process-wide shared state.


Architecture depth

Subsystem design (not method lists): Architecture overview, Agent runtime, Verification, Security.

MIT Licensed — Built for multi-agent orchestration.