Skip to content
2 min read · 312 words

@nhtio/adk/batteries/llm/claude_code_cli/exceptions

Battery-scoped exception constructors for the Claude Code CLI adapter.

Remarks

Battery-scoped exception classes minted via createException from @nhtio/adk/factories. Malformed NDJSON frames (either the wrapper's own inbound-command reader, or its translation of Claude's stream-json) are explicitly NOT a distinct exception — they are swallowed and surfaced via helpers.log.trace, matching the Ollama battery's malformed-line policy.

Variables

VariableDescription
E_CLAUDE_CODE_CLI_BINARY_NOT_FOUNDThrown when the claude binary cannot be located/spawned.
E_CLAUDE_CODE_CLI_MCP_BRIDGE_STARTUP_FAILEDThrown when the wrapper's own MCP bridge server fails to start, OR Claude's system/init reports an mcp_server_errors entry naming the bridge, OR the @modelcontextprotocol/sdk optional peer is missing at wrapper startup.
E_CLAUDE_CODE_CLI_PROCESS_EXITED_NONZEROThrown when the wrapper process exits with no terminal result/error event observed.
E_CLAUDE_CODE_CLI_STARTUP_TIMEOUTThrown when the wrapper does not signal ready and Claude's system/init within startupTimeoutMs.
E_CLAUDE_CODE_CLI_STREAM_ERRORThrown on a transport-level stream failure between the adapter and the wrapper.
E_CLAUDE_CODE_CLI_STREAM_STALLEDThrown when the wrapper's stdout goes idle for longer than streamIdleTimeoutMs.
E_CLAUDE_CODE_CLI_TURN_FAILEDThrown when Claude's terminal result reports isError: true — includes --max-budget-usd/ --max-turns exhaustion, the CLI-native substitutes for a client-side contextWindow guard.
E_CLAUDE_CODE_CLI_UNSUPPORTED_MEDIA_MODALITYThrown when a @nhtio/adk!Media whose modality cannot be represented reaches either direction of this battery under the corresponding unsupportedMediaPolicy/ unsupportedResultMediaPolicy: 'throw' — bidirectional: inbound prompt media (a -p string has no native image channel) and outbound tool-result media (only text/image MCP content blocks are supported).
E_CLAUDE_CODE_CLI_WRAPPER_CRASHEDThrown when the wrapper process crashes or exits abnormally mid-dispatch.
E_CLAUDE_CODE_CLI_WRAPPER_SPAWN_ERRORThrown when the wrapper process itself fails to spawn.
E_INVALID_CLAUDE_CODE_CLI_OPTIONSThrown when the resolved adapter options (constructor, executor overrides, or per-dispatch stash.claudeCodeCli) fail validation — including extraArgs security-flag rejection, the apiKey/authToken XOR violation, and the POSIX-only platform guard.