mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
feat(ai): OpenCode provider via HTTP + SSE (#379)
* feat(ai): add OpenCode provider via HTTP + SSE Bundle @opencode-ai/sdk to spawn `opencode serve` and communicate via HTTP REST + SSE. Richest provider: fork, resume, streaming, tools, and runtime permission approvals all work natively. - OpenCodeProvider: lazy server spawn, shared HTTP client, dynamic model discovery via GET /provider - OpenCodeSession: SSE event drain loop, system prompt via API field, permission reply (once/reject), abort via HTTP - mapOpenCodeEvent: SSE → AIMessage mapping (text deltas, tool lifecycle, permissions, session status, errors) - 11 new event mapping tests (78 total, 157 expect calls) For provenance purposes, this commit was AI assisted. * docs(ai): add OpenCode to AI features guide and code review docs For provenance purposes, this commit was AI assisted. * fix(ai): prevent double server spawn in OpenCode ensureServer() Use a promise-mutex pattern so concurrent callers (e.g. fetchModels + createSession) share a single server spawn instead of racing to create two. Also remove empty finally block from SSE drain loop. For provenance purposes, this commit was AI assisted. * fix(ai): await SSE subscribe in OpenCode provider The SDK's event.subscribe() is async — must be awaited before destructuring the stream. For provenance purposes, this commit was AI assisted. * fix(ui): scrollable model dropdown with search filter Cap dropdown height at min(320px, 50vh) so it doesn't overflow the viewport when providers expose many models (e.g. OpenCode with 20+). Add a search/filter input when there are more than 8 models. For provenance purposes, this commit was AI assisted. * fix(ai): close SSE stream, rename to opencode-sdk, move dep to root - Close SSE stream in finally block to prevent connection leak on abort/early return - Rename provider from opencode to opencode-sdk for consistency with claude-agent-sdk, codex-sdk, pi-sdk - Move @opencode-ai/sdk dependency to root package.json alongside the other SDK dependencies For provenance purposes, this commit was AI assisted. * feat(ui): add first-run AI setup dialog for provider selection Show a one-time modal on first review when AI providers are available. Users pick a default provider and model from a 2-column grid, with a brief feature intro and auth disclaimer. Persists via cookie, can be changed later in Settings. For provenance purposes, this commit was AI assisted. * fix(ai): clear startPromise on failure so OpenCode provider can retry If doStart() fails (port conflict, timeout, binary crash), the cached rejected promise prevented all future ensureServer() calls from retrying. Now cleared on failure and on dispose(). Also updates stale "future" comment in types.ts. For provenance purposes, this commit was AI assisted.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
"dependencies": {
|
||||
"@anthropic-ai/claude-agent-sdk": "^0.2.81",
|
||||
"@openai/codex-sdk": "^0.116.0",
|
||||
"@opencode-ai/sdk": "^1.3.0",
|
||||
"@pierre/diffs": "^1.1.0-beta.19",
|
||||
"diff": "^8.0.3",
|
||||
"dompurify": "^3.3.3",
|
||||
|
||||
Reference in New Issue
Block a user