openAgent
gitlabThe open source UNIVERSAL agent.
clone
https://gitlab.com/bitzzdev/openAgent.gitAIagentautomationopen-sourceuniversal-agent
# HTTP Route PatternsCurrent guidance for `packages/opencode/src/server/routes/instance/httpapi`.## Handler ShapeUse `HttpApiBuilder.group(...)` for normal JSON and streaming HTTP APIendpoints. Yield stable services once while building the handler layer,then close over those services in endpoint implementations.```tsexport const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "session", (handlers) =>Effect.gen(function* () {const session = yield* Session.Servicereturn handlers.handle("list", () => session.list())}),)```Use raw `HttpRouter` only for routes that do not fit the request/responseHttpApi model, such as WebSocket upgrades or catch-all fallback routes.Do not rebuild stable layers inside request handlers. Provide stableservices at the route/layer boundary and use request-level provisioningonly for request-derived context.## Error BoundariesExpected service errors should be mapped at the handler boundary toendpoint-declared public HTTP errors. Keep one-off mappings inline. Extractsmall helpers when the same mapping repeats.Generic middleware should not become a domain-error mapper. It shouldhandle cross-cutting concerns and final unknown-defect fallback.Public JSON errors should be explicit schema contracts declared on eachendpoint or group. Built-in `HttpApiError.*` is fine only when its generatedbody is intentionally the public wire shape.Preserve existing `{ name, data }` error bodies until a deliberate breakingAPI change.## OpenAPI Compatibility`public.ts` still owns SDK/OpenAPI compatibility transforms. Shrink thosetransforms by tightening source schemas one workaround at a time.When an OpenAPI-visible source schema changes:- verify the generated SDK diff is intentional- preserve legacy compatibility unless the PR explicitly changes it- prefer source-schema fixes over new post-processing rules## Checklist For Route PRs- [ ] Stable services are yielded at handler-layer construction.- [ ] Expected domain errors are translated at the route boundary.- [ ] Endpoint/group error schemas describe the public body and status.- [ ] Middleware does not gain new domain-specific name checks.- [ ] Raw routes are used only when HttpApi is the wrong abstraction.