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)
| Surface | Package / entrée | Usage |
|---|---|---|
| CLI | commander · packages/core/src/cliEntry.ts | Terminal, scripts, CI |
| SDK TypeScript | @commander/sdk → CommanderClient | Apps Node |
| HTTP API | Serveur :4000 | Clients polyglottes, Console |
| SDK Python | commander-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éthode | Rôle |
|---|---|
connect / disconnect | Cycle 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/runs — Migration V2.
Python
python
from commander import CommanderClientLayer 2 — Composants d’orchestration runtime
Modules internes @commander/core. Pour étendre le runtime uniquement.
| Composant | Rôle |
|---|---|
| Task Complexity Analyzer | Score → topologie |
| Adaptive Orchestrator | Plan multi-agents |
| Token Budget Allocator | Budget |
| Three-Layer Memory | Mémoire 3 couches |
| Reflection Engine | Éval post-run |
| Consensus Checker | Votes multi-modèles |
| Inspector Agent | Santé / 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.