Skip to main content

Overview

This example demonstrates how to use the OpenCode CLI integration to execute simple prompts. The AgentCtrl facade provides a clean API for invoking the opencode run command with full event observability. Key concepts:
  • AgentCtrl::openCode(): Factory for OpenCode agent builder
  • AgentCtrlConsoleLogger: Shows execution lifecycle with color-coded labels
  • AgentResponse: Structured response with text, session info, usage stats, and cost

Example

Expected Output

Key Points

  • Simple execution: One method call handles the entire interaction
  • Full observability: Console logger shows request building, sandbox, and response parsing
  • Cost tracking: OpenCode exposes cost information in the response