opencode/packages/sdk-next
2026-07-03 17:30:25 -04:00
..
src fix(core): constrain location services (#35228) 2026-07-03 15:34:30 -04:00
test refactor(schema): session shell payloads and event prefix restore (#35229) 2026-07-03 17:30:25 -04:00
package.json refactor(plugin): move tool implementation to plugin (#34665) 2026-06-30 23:30:56 -04:00
README.md feat(plugin): support plugin-provided tools (#34619) 2026-06-30 13:18:56 -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/sdk-next

Effect-native scoped OpenCode host for in-process applications. This transitional package will replace the existing generated @opencode-ai/sdk after its consumers migrate.

The SDK executes Server's assembled HTTP router in memory. It opens no listener and performs no network I/O, while preserving the same routing, middleware, handlers, codecs, and errors as the network client.

import { OpenCode } from "@opencode-ai/sdk-next"

const opencode = yield * OpenCode.create()
const session = yield * opencode.sessions.get({ sessionID })

It also exports Tool for plugins that register tools with ctx.tool.register(...). Embedded plugins run through the ordinary discovery flow and register tools into each Location's ToolRegistry through the normal Tools.Service.register(...) path. Closing the owning Effect Scope releases router resources, location services, fibers, and scoped tool registrations.

sessions.events({ sessionID, after }) replays durable events after the optional aggregate sequence, then emits newly committed durable events. sessions.interrupt(...) targets execution owned by this host, and sessions.message(...) retrieves one projected Session message.

The same constructor is available as a service Layer:

const program = Effect.gen(function* () {
  const opencode = yield* OpenCode.Service
  return yield* opencode.sessions.get({ sessionID })
})

yield * program.pipe(Effect.provide(OpenCode.layer))

OpenCode.layer adapts OpenCode.create() for dependency injection; it does not define another host implementation.