Created
September 4, 2025 17:33
-
-
Save K-Mistele/9beaf10c921866d2701538704999d299 to your computer and use it in GitHub Desktop.
Opencode Zod schema validation issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createOpencodeClient, createOpencodeServer } from "../packages/sdk/js/src" | |
| const server = await createOpencodeServer({ port: 9090 }) | |
| try { | |
| const client = await createOpencodeClient({ baseUrl: server.url }) | |
| const { data: session } = await client.session.create({ body: { title: "test session" } }) | |
| if (!session) throw new Error("Unable to create new session") | |
| const { data: result, error } = await client.session.prompt({ | |
| path: { id: session.id }, | |
| body: { | |
| parts: [{ type: "text", text: "What files are in the current directory?" }], | |
| model: { | |
| providerID: "anthropic", | |
| modelID: "claude-sonnet-4-20250514", | |
| }, | |
| }, | |
| }) | |
| if (result) console.log(result) | |
| else if (error) throw error | |
| } catch (error: any) { | |
| console.error("error" in error ? error.error : error) | |
| } finally { | |
| await server.close() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment