opencode/packages/client
Dax Raad 93159bccbf feat(core): port v2 runtime fixes onto dev
Cherry-picks the packages/core changes from the v2 branch onto dev:
- combined ordered stdout/stderr in AppProcess + bash structured output
- edit/apply-patch return FileDiff info with status and line stats
- ignore no-op model switches; record reasoning timestamps
- return unexpected local tool defects to the model and continue
- keep OAuth account metadata out of request bodies
- nest OpenAI reasoning effort/summary options
- load OpenCode provider config asynchronously; batch plugin boot
- export latest public event manifest

Includes the supporting schema reasoning time field and regenerated
client/SDK types.
2026-06-27 00:07:25 -04:00
..
script feat(sdk): expose live event stream (#34098) 2026-06-26 21:16:33 +02:00
src feat(core): port v2 runtime fixes onto dev 2026-06-27 00:07:25 -04:00
test feat(sdk): expose live event stream (#34098) 2026-06-26 21:16:33 +02:00
package.json feat(sdk): add HttpApi clients and embedded host (#33445) 2026-06-24 23:08:54 -04:00
README.md feat(sdk): add HttpApi clients and embedded host (#33445) 2026-06-24 23:08:54 -04:00
sst-env.d.ts zen: new inference 2026-06-25 12:15:34 -04:00
tsconfig.json feat(sdk): add HttpApi clients and embedded host (#33445) 2026-06-24 23:08:54 -04:00

@opencode-ai/client

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

Entrypoints

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

The generated surface starts with the Session group from Server's concrete API. The build compiler reads @opencode-ai/server/api; the generated Effect runtime imports a client-local projection built from Protocol, with a generation-equivalence test preventing transport drift. 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-ai/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-ai/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" }) })