opencode/packages/client
Kit Langton 8aea935131 feat: serve stored media as refs to clients that opt into experimental-media-uri
Clients that send X-OpenCode-Capabilities: experimental-media-uri get user
files and tool results stored in blob as media:<hash> refs with their size
and dimensions instead of inline base64, from session.messages,
session.message and session.inbox.list, when experimental.media_blob is on
in the session's own location (the config its media was written under).
Refs whose blob is gone become the same unavailable placeholder inline
readers get. Every other reader, the runner and export stay inline.

GET /api/experimental/media/:hash serves one blob that a stored message or
inbox item still references, with an immutable ETag, 304 support, nosniff
and a sandbox CSP; anything but a raster image is sent as an
application/octet-stream attachment. session.prompt accepts a referenced
media:<hash> ref as an attachment URI and re-admits its stored bytes as is.
2026-10-25 16:37:38 -07:00
..
script feat(core): read OpenCode Console usage limits and classify budget refusals (#58694) 2026-10-24 11:13:12 -05:00
src feat: serve stored media as refs to clients that opt into experimental-media-uri 2026-10-25 16:37:38 -07:00
test feat: serve stored media as refs to clients that opt into experimental-media-uri 2026-10-25 16:37:38 -07:00
package.json sync release versions for v2.1.4 [skip ci] 2026-10-23 10:15:01 +00:00
README.md refactor(packages): migrate to the opencode npm scope (#47852) 2026-09-07 17:19:33 -04:00
sst-env.d.ts zen: new inference 2026-06-25 12:15:34 -04:00
tsconfig.build.json feat(plugin): align hooks with client APIs 2026-07-03 18:12:22 -04:00
tsconfig.json chore: upgrade typecheck to TypeScript 7.0.2 (#56300) 2026-10-17 13:26:46 -07: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" }) })