Skip to content

Référence API

L’API Commander a deux couches. La plupart des apps n’ont besoin que de la Layer 1.

Layer 1 — Intégration publique (commencez ici)

SurfacePackage / entréeUsage
CLIcommander · packages/core/src/cliEntry.tsTerminal, scripts, CI
SDK TypeScript@commander/sdkCommanderClientApps Node
HTTP APIServeur :4000Clients polyglottes, Console
SDK Pythoncommander-ai (HTTP)Python contre l’API

SDK TypeScript

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();
MéthodeRôle
connect / disconnectCycle de vie
run(task)Exécution complète → ExecutionResult
plan(task)Délibération seule
onEvent(handler)Stream d’événements

npm : monorepo d’abord. Publish public en cours. Agent SDK.

HTTP

bash
curl http://localhost:4000/health
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"}'

V2 : POST /v1/runsMigration V2.

Python

python
from commander import CommanderClient

SDK Python.


Layer 2 — Composants d’orchestration runtime

Modules internes @commander/core. Pour étendre le runtime uniquement.

ComposantRôle
Task Complexity AnalyzerScore → topologie
Adaptive OrchestratorPlan multi-agents
Token Budget AllocatorBudget
Three-Layer MemoryMémoire 3 couches
Reflection EngineÉval post-run
Consensus CheckerVotes multi-modèles
Inspector AgentSanté / problèmes

Quand utiliser Layer 2

Topologie custom, recherche mémoire/consensus, tests d’un sous-système.

Quand ne pas

« Lancer une tâche » → CommanderClient. Clients distants → HTTP.

Exemple minimal

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,
);

Préférez CommanderClient aux singletons getGlobal… sauf état partagé voulu.

Voir aussi

MIT — Conçu pour l’orchestration multi-agents.