Repository navigation
0.8.0-preview.2
Pre-releaseThe second preview of the unofficial OpenCode .NET SDK, built against upstream release tag v2.0.2 (@opencode/cli@2.0.2).
dotnet add package OpenCodeAI.Sdk --prerelease
dotnet add package OpenCodeAI.Sdk.Extensions --prerelease # dependency injection, optionalThe package id is not the namespace. You install
OpenCodeAI.Sdkand you writeusing OpenCode.Sdk;— nuget.org reserves theOpenCode.id prefix for an unrelated owner, so the artifact carries a different name than the code inside it.
What changed since 0.8.0-preview.1
- The pin moved to upstream release tag
v2.0.2. The SDK now targets the OpenCode 2.x server as published on the@opencode/clirelease channel; install it withnpm install -g @opencode/cli@2.0.2. OpenCode 1.x servers are not supported. The old@opencode-ai/cliscope is frozen and no longer reaches a server this SDK can drive. - Coverage is 138 of 143 operations across 29 client families. New:
OpenCodeClient.Config(preferences read and patch, host shell catalog) andSessionClient.PutPermissionRulesAsync; sessions carry their permission ruleset and the durablesession.permissions.updatedevent. Removed upstream:v2.session.messageUpdate. - Request properties that the server accepts as absent, null, or a value are now
Optional<T>.defaultleaves the member out,= nullorOptional<T>.Nullwrites an explicit null, a value writes the value. This is what makes clearing a preference ({"shell":null}) expressible; object initializers such asTitle = "x"are unchanged. 39 properties across 21 operations changed type, one of them the sharedToolFileContent.Name, which is read through.Valueon the response side. See the new Requests guide. - The launcher defaults to
opencode serveand resolves the command the way a shell does,PATHEXTincluded, so an npm-installed CLI's.cmdshim starts on Windows. A 1.x install onPATHfails fast with its usage text. - Cursor lists generalize. Every cursor-carrying list derives from
ListRequest;EnumerateSessionsAsyncjoinsEnumerateMessagesAsync, both returningCursorSequence<TPage, TItem>(anIAsyncEnumerable<TItem>with.Pages), and continuation carries the first page's filters. - Union interfaces carry what every member shares. A member every arm of a union declares in the same shape is hoisted onto the union interface (nullable there, because the unknown carrier holds none), and records promoted for one identical shape share a carrier interface such as
IDurableEnvelope. SubmitAsync(string)on both terminal families sends a line plus the carriage return a terminal's Enter key sends.- A 401 on a client built without a password says why: an
opencode serveprocess always runs with a password. The docs no longer claim an anonymous server exists. - Durable replay is documented honestly: the distributed CLI starts its server without event persistence and exposes no switch for it, so a replay from such a server is the
log.syncedmarker alone; a live test is the reversal trigger.
Targets netstandard2.0, net472, net8.0, net9.0, net10.0; both packages declare IsAotCompatible on net10.0.
Verification
5,612 tests green on Windows (the fullest leg, with net472), Linux and macOS; the Windows consumer leg ran against the npm-distributed @opencode/cli@2.0.2 build with isolated roots (1,184 of 1,185 live tests, the one failure being a proof that needs the owned pinned server).
Full details in CHANGELOG.md.