Skip to content

Système de plugins

Système de plugins. Cette page décrit un composant d’architecture Commander. Le texte ci-dessous reprend la structure du monorepo en français opérationnel ; les blocs de code restent en anglais.

Hooks principaux

HookQuand
beforeLLMCall / afterLLMCallChaque requête LLM
beforeToolCall / afterToolCallChaque tool
onAgentStart / onAgentCompleteCycle de vie agent
beforeVerification / afterVerificationPortes de qualité
beforeRun / afterRunRun global
onError / onRetryErreurs / retries
onStreamEventSSE
onHandoffHandoff inter-agents

Créer un plugin

typescript
import { CommanderPlugin, getHookManager } from '@commander/core';

class LoggingPlugin implements CommanderPlugin {
  name = 'logging';
  hooks = {
    beforeLLMCall: async (params) => {
      console.log(`[LLM] ${params.provider}`);
      return params; // throw pour bloquer
    },
    afterToolCall: async (result) => {
      console.log(`[Tool] ${result.tool} ${result.durationMs}ms`);
      return result;
    },
  };
}

getHookManager().register(new LoggingPlugin());

Sécurité

Les plugins tiers reçoivent un contexte sandboxed : leurs permissions ne dépassent jamais le système principal.

bash
npx tsx packages/core/src/cliEntry.ts plugin enable rag
npx tsx packages/core/src/cliEntry.ts plugin disable rag

Lié

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