""" adapters/runtime/claude_code.py Claude Code agent runtime adapter — Phase 2 stub. TODO (Phase 2): - Implement spawn() to launch a Claude Code sub-agent via the Agent SDK. - Implement get_result() to await agent completion and parse the output. - Implement kill() to terminate the sub-agent process or session. - Map task brief context (files, constraints, artifacts) into the agent's system prompt and tool context. - Handle Claude Code tool-use responses and extract structured output. """ from __future__ import annotations from adapters.base.runtime import RuntimeAdapter class ClaudeCodeRuntimeAdapter(RuntimeAdapter): """ Runtime adapter that spawns Claude Code sub-agents for coding tasks. Used when a TaskBrief has preferred_runtime == "coding_agent". Expects the Claude Code CLI / Agent SDK to be available in the environment. Credentials are inherited from the environment (ANTHROPIC_API_KEY). """ def __init__(self, config: dict) -> None: # TODO (Phase 2): Accept loaded team.yaml config dict. # Validate that Claude Code CLI or SDK is accessible. # Initialise any agent session management state. raise NotImplementedError("ClaudeCodeRuntimeAdapter.__init__ is not yet implemented.") def spawn(self, task: str, capability: str, context: dict) -> str: # TODO (Phase 2): Launch a Claude Code sub-agent. # Compose a structured system prompt from task + context. # Inject relevant files and constraints as tool context. # Return an agent_id that maps to a running agent session. raise NotImplementedError("ClaudeCodeRuntimeAdapter.spawn is not yet implemented.") def get_result(self, agent_id: str, timeout_s: int) -> dict: # TODO (Phase 2): Await the Claude Code agent session to complete. # Parse the agent's final message for structured JSON output. # Return dict with: {"status": ..., "output": ..., "artifacts": [...]}. # Raise TimeoutError if timeout_s elapses. raise NotImplementedError("ClaudeCodeRuntimeAdapter.get_result is not yet implemented.") def kill(self, agent_id: str) -> None: # TODO (Phase 2): Terminate the Claude Code agent session. # Clean up any temporary files or session state. raise NotImplementedError("ClaudeCodeRuntimeAdapter.kill is not yet implemented.")