Skip to content

Implement OpenCode inference client #11

Description

@Coldaine

Origin: docs/todo.md entry dated 2026-04-01
Plan: docs/plans/plan-inference-engine.md (OpenCode client), docs/architecture.md §How the Shadow Model Works

Description

Create shadow-agent/src/inference/opencode-client.ts by porting sidecar's opencode-client.js. Responsibilities: start the OpenCode server (or attach to an existing one), create a session, send prompts, poll completions, and surface provider-neutral responses. The OpenCode SDK is the primary inference harness because it gives free provider abstraction (Claude, GPT-4, Gemini, OpenRouter) and inherits credentials from the user's existing OpenCode config.

Acceptance criteria

  • Wraps @opencode-ai/sdk behind the shared InferenceClient seam at src/inference/inference-client.ts
  • Start-or-attach logic avoids duplicate servers when one is already running
  • Session creation, prompt send, completion polling all implemented
  • Surfaces structured errors (auth, transport, model) for the orchestrator
  • Honors model selection from config; defaults to a Claude model when unspecified
  • Fake-client contract tests pass without reaching a real OpenCode server

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions