Skip to content

feat(llm): add guarded OpenCode SDK and free-model support - #57

Merged
cskwork merged 8 commits into
devfrom
feat/gh-49-opencode-sdk
Oct 28, 2026
Merged

cskwork merged 8 commits into
devfrom
feat/gh-49-opencode-sdk

Conversation

@cskwork

@cskwork cskwork commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Adds an opt-in opencode-sdk provider for native OpenCode CLI/client/SDK 2.1.4 and the separately tested legacy CLI / @opencode-ai/sdk/v2 1.19.4 pair. ScopeWeaver keeps conversation state, tool execution, approvals, scope checks and usage accounting; the isolated loopback bridge streams one model step and captures tool requests.

Refs #49.

Behavior

  • Uses the genuine pinned native CLI and public client APIs; native tools remain registered but are denied before execution. Host tools run only through ScopeWeaver.
  • Adds explicit model discovery, a separate scoped bridge token, streaming/usage, cancellation/process cleanup, typed quota/context/free-tier errors, and six-language UI/backend/setup guidance.
  • Keeps existing API/OpenCode Go provider paths. SDK profiles reject local-only mode, non-loopback bridge URLs, redirects, proxy settings and unsupported runtime combinations.
  • Preserves raw native tool JSON, including 64-bit integers; legacy accepts safe structural JSON and rejects unsafe integers or opaque reasoning history explicitly.
  • Honors an SDK profile's positive output limit during connection tests. Preserves the original redirect failure across legacy retry gates without allowing another network request.
  • Adds opencode-sdk to the profile-format database CHECK constraint. Existing profile values remain; downgrade preparation is documented. Only disposable databases were migrated during verification.

Release packaging — 2026-10-26

7982c2a fixes a concrete archive omission: the SDK setup documentation referenced adapters/opencode-sdk, but release ZIPs only copied the agent adapter. The release builder now includes SDK package.json, bun.lock, all six README editions, src and test. It excludes local node_modules, .env/provider configuration and runtime state.

The existing real packaging-path fixture was extended first: RED exit 1 (missing SDK README), then GREEN exit 0 for six languages × five targets = 30 fixture ZIPs. Required SDK payload, notices, unchanged fixture executables, document content, exclusion sentinels and checksums all pass. Shell syntax and parent diff review pass. These fixture executables are packaging proof, not platform runtime proof. Go/web/SDK runtime source and dependency pins are unchanged by this commit.

Dependency remediation — 2026-10-26

Candidate 11def12 preserves the existing SDK implementation and runtime pins. It merges current dev d5ce498 with the previous PR head b9781b2 (the only tree difference is HANDOFF.md), then changes only the SDK package manifest and Bun lockfile:

  • Override provider-utils 4.0.21/4.0.23 to the patched 4.0.33. Existing public exports are retained; all direct runtime pins stay unchanged.
  • Deduplicate the plugin's unused Effect beta dependency onto the already installed stable 4.0.1. This removes the beta-only toml subtree. Plugin runtime JS has no Effect imports.
  • Preserve both native/legacy CLI versions, all six CLI/wrapper/PTY file hashes, protocol, process cleanup, guards and test assertions.

Fresh offline verification on Bun 1.3.14: frozen install PASS; syntax check PASS; actual-runtime loopback fixtures 62 tests / 324 assertions / 0 failures; independent diff review PASS. The initial sandbox run was 59/3 because ps was blocked (EPERM); the same baseline and patched tests both pass 62/0 with process visibility. No real provider request or historical diagnostic rerun was performed.

Audit moved from three reported packages to zod only, still exit 1. Current-head hosted checks and the maintainer's final human check remain required. This update is not risk acceptance or release approval.

Prior candidate verification (before dependency remediation)

  • Actual signed-out hosted-free E2E with opencode/deepseek-v4.1-flash-free: UI connection/save/activation, pending host Bash approval before file effect, one reviewed approval, exact FREE_OK file and visible final reply. Three real inference requests, each captured with max_tokens: 1024, retries disabled, no paid fallback, imported accounts, model fixtures or identity spoofing.
  • Combined actual-runtime SDK fixtures: 62 tests, 0 failures, 324 assertions. Redirect regression has deterministic RED/GREEN proof.
  • Go: 2,343 passing tests/subtests across 23 packages, three opt-in skips. Subsequent connection-cap change: 161 affected tests/subtests passed, including 16 direct/HTTP scenarios. These counts overlap. Vet and embedded build passed.
  • Frontend: 78 tests, static build and zero-vulnerability npm audit passed. Six-locale SDK copy and documentation links/examples checked; served Traditional Chinese/Japanese/Spanish help inspected.
  • Independent code/documentation review passed. Exact-head hosted CI remains required before merging.

Limits and release risks

  • Hosted-free access was verified for native mode only on macOS arm64. Availability and eligibility can change; no unlimited/permanent-free claim. Legacy hosted-free access is unverified. Both SDK runtimes are unsupported on Windows; Linux actual-runtime coverage is exercised by CI.
  • One earlier native multi-turn HTTP 502 was not reproduced in repeated/fresh runs; its cause remains unknown. The separately reproduced legacy redirect classification bug is fixed.
  • The regenerated Bun lockfile differs from the lost original. All 12 direct pins and the native CLI binary matched saved evidence, and the regenerated dependency tree was freshly tested; exact historical transitive equality is not claimed.
  • SDK dependency audit remains exit 1: zod 3.25.76 / 4.1.8 retain high advisory GHSA-mrhx-c7xc-m3w5. The current upstream core 2.1.4 pins 4.1.8, and even the latest GitLab provider 6.23.1 still requires zod 3. No global zod major override or advisory suppression was introduced. Verified compatible fixes or an explicit release-owner risk disposition are still required. Package audit does not inspect compiled vendor binaries; their unchanged hashes are identity evidence only.

Final combined dev E2E, main promotion and the minor release are coordinated separately after all agent-owned work is integrated.

@cskwork
cskwork merged commit 3d5bbec into dev Oct 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants