🏋️ Challenges — Module 05 (Integration)¶
- API: run
opencode api get /api/info, create a session with--dataand retrieve it. - JS client: create a session, send a prompt and subscribe to
client.event.subscribe(). - SDK: embed OpenCode with
OpenCode.create(), register a plugin and useawait using. - ACP/Web: connect an editor via ACP and generate a pairing link with
opencode pair.
💡 Solution (challenge 2)
import { OpenCode } from "@opencode/client"
const client = OpenCode.make({ baseUrl: "http://localhost:4096" })
const s = await client.session.create({ location: { directory: process.cwd() } })
await client.session.prompt({ sessionID: s.id, text: "Hello" })
for await (const e of client.event.subscribe()) { console.log(e.type); break }
💡 Solution (challenge 3)
import { OpenCode } from "@opencode/sdk"
await using opencode = await OpenCode.create()
const s = await opencode.sessions.create({ location: { directory: process.cwd() } })
await opencode.sessions.prompt({ sessionID: s.id, text: "Summarize the project" })
➡️ Module 06