Skip to content
1 min read · 249 words

@nhtio/adk/batteries/llm/claude_code_cli/validation

Runtime validation schema and wrapper for Claude Code CLI adapter options.

Remarks

Schema and call-site wrapper for validating ClaudeCodeCliAdapterOptions. Used at construction time and at the start of every iteration against the merged options shape (stash > executor > constructor). Throws E_INVALID_CLAUDE_CODE_CLI_OPTIONS on failure — same hard-fail policy as every other ADK contract.

Three invariants enforced here that have no equivalent in the other LLM batteries:

  • apiKey/authToken are mutually exclusive AND at least one is required (.xor).
  • extraArgs entries are validated against a strict six-flag allowlist, with per-flag value arity, and every value string is rejected if it starts with - — the fix for the --betas variadic-value injection hazard (a value string spelling another flag would otherwise reach the CLI's own argv parser as a distinct token).
  • process.platform is checked at validation time: this battery is POSIX-only in v1 (reliable process-group control requires POSIX process groups), mirroring src/batteries/sandbox/node/srt_enforcer.ts's own platform-boundary precedent.

Variables

VariableDescription
claudeCodeCliOptionsSchemaValidator schema for ClaudeCodeCliAdapterOptions. Used by validateOptions at construction time and again at the start of every iteration after options have been merged (stash > executor > constructor). Rejects unknown top-level keys so typos fail loud.

Functions

FunctionDescription
validateOptionsValidates an arbitrary input against claudeCodeCliOptionsSchema and returns the resolved options shape. Throws E_INVALID_CLAUDE_CODE_CLI_OPTIONS (carrying the validator's error report on cause) on failure.