A session's workspace placement could only be set through the internal Effect SDK. This opens it to agents, plugins and the HTTP API behind the new `workspaces` flag: - `Session.create` accepts `parentID` together with an explicit `location`, so a child can run on a different placement; a plain `parentID` child still copies its parent. - The `subagent` tool gains optional `workspaceID` and `directory`; reusing an existing child with a different placement fails instead of changing it. - New `opencode` tools `workspace_providers`, `workspace_create` (create and provision) and `workspace_destroy`, permission-gated. - `session_move` accepts `workspaceID` and passes the session's current one when omitted, so moving between directories no longer silently drops a workspace placement. Core move skips the host directory stat and host project resolution for workspace destinations; the Location layer resolves the project. - Plugin `session.create` accepts `location.workspace`. - HTTP: `experimental.workspaceID` on `session.create` and `session.move`, and a new experimental group `/api/experimental/workspace/*` (providers, create, provision, destroy). Generated clients regenerated. Verified: `bun typecheck` in schema, core, plugin, protocol, server, client and sdk; `bun run check` at the root; protocol experimental-identifiers test; core session-create, session-move, tool-opencode, tool-subagent and plugin tests; server session handler tests; sdk embedded test (child placed on a workspace while a plain child inherits). |
||
|---|---|---|
| .. | ||
| script | ||
| src | ||
| test | ||
| package.json | ||
| README.md | ||
| sst-env.d.ts | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
@opencode/client
Private generation target for clients derived directly from OpenCode's authoritative Effect HttpApi.
Entrypoints
@opencode/client: zero-Effect Promise client usingfetch.@opencode/client/effect: rich Effect network client using an environment-providedHttpClient.
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" }) })