Skip to content

fix(drive): discover current V2 services through @opencode/client - #89

Merged
kitlangton merged 1 commit into
mainfrom
status-discovery
Sep 16, 2026
Merged

kitlangton merged 1 commit into
mainfrom
status-discovery

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

Drive 2.1.0 cannot attach to a current OpenCode V2 server. The script server starts and logs server listening, then Drive fails with OpenCode service registration was not found and stops it before any TUI launches (#87). The pinned @opencode-ai/[email protected] probes /api/health, but current V2 answers service discovery on /api/status and returns 404 for the old route, so Service.discover treats a healthy server as absent.

What Changes

Drive now pins the renamed SDK, @opencode/[email protected], whose Service.discover probes /api/status.

Before After
Discovery probe GET /api/health → 404 → "registration not found" GET /api/status → { version, pid, urls } → attached
SDK package @opencode-ai/[email protected] @opencode/[email protected]

Manual probes follow the same SDK surface:

Old New
opencode.health.get() opencode.server.status()
opencode.form.list({ sessionID }) / form.state(...) opencode.session.form.list(...) / session.form.get(...).state
permission.reply({ ..., reply: "once" }) permission.reply({ ..., decision: "once" })
plugin.awaitActivation({ location }) poll model.default / agent.list until populated (endpoint removed upstream)
session.rename(...) session.update(...)

The fake OpenCode test fixture serves /api/status. It still rejects a wrong x-opencode-directory, but only when the header is present, because the discovery probe deliberately carries no directory.

Scope

Fixes #87. Provider package fixtures keep @opencode-ai/ai/...; current V2 rewrites that prefix to @opencode/ai/, so they are unaffected. No Drive protocol or CLI changes.

Verification

bun run check
bun run test
# real end-to-end against OpenCode origin/v2 (2cdd938152) with --dev:
OPENCODE_DRIVE_MEDIA_DIR=$PWD/.drive-output bun packages/drive/bin/opencode-drive run ./spinner-gap.ts
  • check: 0 errors (1 pre-existing lint warning in recording/marks.ts)
  • test: 38 files / 274 tests pass (vitest) and 40 pass (bun test CLI integration)
  • End-to-end: the same script that failed with OpenCode service registration was not found on 2.1.0 now attaches the SDK, launches the TUI, controls a simulated shell tool call, and captures frames against a current V2 checkout.

@kitlangton
kitlangton merged commit 7817d0f into main Sep 16, 2026
1 check passed
@kitlangton
kitlangton deleted the status-discovery branch September 16, 2026 18:38
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.

fix: support current V2 service discovery when starting scripts

1 participant