opencode/packages/client
Sebastian 9c3f8311a6
Some checks are pending
bot-nix-hashes / compute (push) Blocked by required conditions
bot-nix-hashes / hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Waiting to run
bot-nix-hashes / hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Waiting to run
bot-nix-hashes / hash (blacksmith-6vcpu-macos-latest, aarch64-darwin) (push) Waiting to run
bot-nix-hashes / publish (push) Blocked by required conditions
check-nix / nix-eval (push) Waiting to run
check / typecheck (push) Waiting to run
deploy-files / files-build (push) Waiting to run
deploy-files / files-deploy (push) Blocked by required conditions
deploy-site / site-deploy (push) Blocked by required conditions
deploy-site / site-build (push) Waiting to run
deploy / legacy-build (push) Waiting to run
deploy / legacy-deploy (push) Blocked by required conditions
deploy / data-build (push) Waiting to run
deploy / data-deploy (push) Blocked by required conditions
feat(server): sync and write several experimental spaces in one request (#66694)
Co-authored-by: kommander <335157+kommander@users.noreply.github.com>
2026-11-27 00:26:13 +01:00
..
script feat(core): add push notifications for the mobile apps (#66130) 2026-11-24 23:52:07 -05:00
src feat(server): sync and write several experimental spaces in one request (#66694) 2026-11-27 00:26:13 +01:00
test feat(server): experimental spaces (#63998) 2026-11-26 16:45:28 +01:00
package.json release: v2.4.1 (#65848) 2026-11-23 11:33:25 -06:00
README.md refactor(packages): migrate to the opencode npm scope (#47852) 2026-09-07 17:19:33 -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" }) })