effect: Effect bridge package (LanguageModel over gateway + agent, schema interop, scoped sandbox layers)
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 0
- Avg merge
- 29m
- Merged PRs (30d)
- 127
Description
Tracking issue for an [Effect](https://effect.website) bridge to the Coder AI SDK — a new `packages/effect` package (`@coder/ai-sdk-effect`) exposing the three existing packages through Effect-native abstractions.
## Architecture
The bridge adapts our imperative SDK surfaces to Effect's service/Layer/Stream model without changing the underlying packages:
- **`LanguageModel` service over AI Gateway** (`@coder/ai-sdk-provider`): implement Effect's `LanguageModel` interface on top of the gateway endpoints, mapping Effect `Prompt`/`Response` to the provider's chat-completions/messages calls and HTTP failures to typed `AiError`s (auth, quota, provider-unavailable, malformed-response), preserving the centralized vs BYOK auth modes.
- **Schema interop**: helpers bridging Standard Schema / Effect Schema to the SDK's tool-definition and structured-output surfaces, so Effect users define tools and output schemas in Effect Schema and get correct wire types both directions.
- **Scoped resource management for sandboxes** (`@coder/ai-sdk-sandbox`): `ensureCoderWorkspace` + session lifecycle as `Effect.acquireRelease` / scoped `Layer`s, so workspace acquisition, agent-readiness waits, and teardown compose with Effect scopes and interruption.
- **`LanguageModel` over CoderAgent/chatd** (`@coder/ai-sdk-agent`): server-side agent loop as an Effect service — `TurnTranslator` output mapped onto `Effect Stream`, fiber interruption wired to `agent.interrupt()`, and the SDK's retryable/terminal error taxonomy (`CoderStreamError.isRetryable`, timeout vs cancellation) surfaced as tagged errors usable with Effect retry policies.
## Roadmap
### Phase 1 — Spike (in flight)
- [ ] `packages/effect` scaffold (private, excluded from release-please until graduation)
- [ ] Effect `LanguageModel` implementation over `@coder/ai-sdk-provider` (AI Gateway): Prompt/Response mapping + typed `AiError` hierarchy for HTTP errors
- [ ] Standard Schema / Effect Schema interop helpers for tool definitions and structured outputs
- [ ] Scoped `Layer`s for workspace sandbox lifecycle (`ensureCoderWorkspace` + session as `Effect.acquireRelease`)
- [ ] Unit tests + live validation against dev.coder.com
### Phase 2
- [ ] `LanguageModel` implementation over `CoderAgent`/chatd: `TurnTranslator` → `Effect Stream` mapping
- [ ] Fiber interruption → `agent.interrupt()`
- [ ] Retryable error tagging aligned with Effect retry policies
- [ ] Publishing decision: versioning, peerDependency policy on `effect`/`@effect/ai`, release-please wiring
## Notes
- Spike ships as a private package: no npm publish and no release-please manifest entry until Phase 1 review concludes the API shape is right.
- Effect / @effect/ai are fast-moving; the spike should pin exact versions and record the pinned API surface in the package README.
---
_Generated with [`mux`](https://github.com/coder/mux) • Model: `anthropic:claude-fable-5` • Thinking: `xhigh`_
Contributor guide
Research direction
Start by reviewing the existing @coder/ai-sdk-provider, @coder/ai-sdk-sandbox, and @coder/ai-sdk-agent package entry points, then scaffold the private packages/effect package. Track the Phase 1 roadmap: implement the provider mapping, schema helpers, and scoped sandbox layers, add unit tests and live validation against dev.coder.com, and document pinned Effect APIs in the package README.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100