ClaudeAgentSDK.Mock.Process (claude_agent_sdk v0.18.0)

Copy Markdown View Source

Package-local mock process fixture for Claude SDK tests.

This module is only reachable when package-local test fixture mocking is enabled. Instead of spawning actual Claude CLI processes, it retrieves predefined responses from the ClaudeAgentSDK.Mock server and converts them into a stream of Message structs.

It is intentionally not a PRELIM service-mode simulation selector. Cross-stack simulation must enter through ASM and the shared cli_subprocess_core provider runtime profiles so normal provider parsers and execution-surface controls still run.

Behavior

  • Prompt extraction: Intelligently extracts the relevant prompt from CLI arguments
  • Response retrieval: Fetches appropriate mock responses from the Mock server
  • Stream conversion: Converts raw mock data into proper Message structs
  • Type preservation: Maintains the same message types and structure as real CLI output

Message Types Supported

  • :system - System initialization and status messages
  • :assistant - AI assistant responses with content
  • :user - User input messages (for conversation context)
  • :result - Final results with cost and performance metrics

Integration

This module is automatically used only when the test-environment runtime mock fixture gate is enabled.

Mock Response Format

Raw mock responses are converted to structured Message structs following the same patterns as the real CLI output, ensuring compatibility across mock and live modes.

Summary

Functions

Streams mock messages instead of running the actual CLI.

Functions

stream(args, options, stdin_input \\ nil)

@spec stream([String.t()], ClaudeAgentSDK.Options.t(), String.t() | nil) ::
  Enumerable.t()

Streams mock messages instead of running the actual CLI.