Files
Aiden Cline 4c949b0356 fix(core): map v1 setCacheKey to compatibility
V1 provider.options.setCacheKey was passed through as an inert provider setting, so the prompt cache key was never sent for providers that opt in (and could not be disabled for providers that default it on). Lower it to compatibility.supportsPromptCacheKey on the provider, add provider-level compatibility to the config schema, and apply it to every model of the provider with model-level compatibility taking precedence.
2026-09-28 17:58:56 -05:00
..
2026-09-25 23:57:39 +00:00
2026-06-25 12:15:34 -04:00

@opencode/client

Private generation target for clients derived directly from OpenCode's authoritative Effect HttpApi.

Entrypoints

  • @opencode/client: zero-Effect Promise client using fetch.
  • @opencode/client/effect: rich Effect network client using an environment-provided HttpClient.

The generated surface includes every standard HTTP group from Server's concrete API. The build compiler reads @opencode/server/api; the generated Effect runtime imports a client-local projection built from Protocol, with a generation-equivalence test preventing transport drift. Custom transports such as the PTY WebSocket connection remain outside the generic HTTP client. Run bun run generate after changing the contract and bun run check:generated to detect committed-output drift.

The Effect entrypoint uses canonical decoded values such as Session.ID, Location.Ref, and Prompt. These datatypes come from the lightweight @opencode/schema package and are re-exported so callers depend only on the client surface. Protocol owns endpoint construction and middleware placement; Server supplies the concrete middleware keys used by the build-time API.

The Promise root remains structural and has no Core or Effect runtime dependency. /effect depends only on Effect, Schema, and Protocol and is browser-bundle safe. Bundle-boundary tests enforce both import graphs.

Effect consumers construct canonical decoded inputs:

import { AbsolutePath, Location, OpenCode, Prompt } from "@opencode/client/effect"

const client = yield * OpenCode.make({ baseUrl: "https://opencode.example" })
yield *
  client.sessions.create({
    location: Location.Ref.make({ directory: AbsolutePath.make("/workspace") }),
  })
yield * client.sessions.prompt({ sessionID, prompt: Prompt.make({ text: "Hello" }) })