Skip to main content

Client Adapters

Adapters translate between AI agent wire formats and SigmaShake's internal ToolCall type. They also handle hook installation and capability classification.

Adapter interface

interface ClientAdapter {
readonly name: string;
detect(): boolean;
parseInput(raw: string): ToolCall;
formatOutput(result: EvalResult): string;
toolCapability(toolName: string): Capability;
install(projectDir: string): Promise<void>;
uninstall(projectDir: string): Promise<void>;
healthCheck(): Promise<boolean>;
}

Built-in adapters

Claude Code Adapter

Name: claude-code

Detection: Looks for CLAUDE_CODE_VERSION, CLAUDE_CODE_API_KEY, or CLAUDE_CODE_ENTRYPOINT environment variables.

Tool capability mapping: Hardcoded map for 30+ Claude Code tools:

  • Bashexecute
  • Readread
  • Write, Edit, MultiEditwrite
  • Glob, Grepsearch
  • Agentagent
  • WebFetch, WebSearchnetwork

Hook installation: Creates .claude/hooks/ssg-check.sh as a PreToolUse hook. Includes circuit breaker protection (auto-allow after 5 consecutive denies to prevent lockout).

Generic Adapter

Name: generic

Detection: Always matches (fallback).

Wire format:

{"tool": "toolName", "input": {"key": "value"}}

Capability classification: Keyword-based prefix matching on tool name.

Adapter selection

Priority order:

  1. SSG_CLIENT environment variable (explicit override)
  2. Known client environment variables (e.g., CLAUDE_CODE_VERSION)
  3. Generic adapter (fallback)

Creating custom adapters

Implement the ClientAdapter interface and register it in the adapter registry. Key considerations:

  • detect() should be fast — it runs on every eval
  • parseInput() must handle malformed input gracefully
  • toolCapability() should cover all tools the client uses
  • install() should be idempotent (safe to run multiple times)