refactor(protocol): extract server contracts (#33708)

This commit is contained in:
Kit Langton
2026-06-24 22:15:31 -04:00
committed by GitHub
parent f9dac262ff
commit 56a37c3640
77 changed files with 1070 additions and 878 deletions
@@ -1,6 +1,8 @@
import { Effect } from "effect"
import { HttpApiMiddleware } from "effect/unstable/httpapi"
import { InvalidRequestError } from "../errors"
import { InvalidRequestError } from "@opencode-ai/protocol/errors"
import { SchemaErrorMiddleware } from "@opencode-ai/protocol/middleware/schema-error"
export { SchemaErrorMiddleware } from "@opencode-ai/protocol/middleware/schema-error"
const REASON_LIMIT = 1024
@@ -9,11 +11,6 @@ function truncateReason(reason: string) {
return reason.slice(0, REASON_LIMIT) + `... (${reason.length - REASON_LIMIT} more chars)`
}
export class SchemaErrorMiddleware extends HttpApiMiddleware.Service<SchemaErrorMiddleware>()(
"@opencode/HttpApiSchemaError",
{ error: InvalidRequestError },
) {}
export const schemaErrorLayer = HttpApiMiddleware.layerSchemaErrorTransform(SchemaErrorMiddleware, (error) => {
const reason = truncateReason(error.cause.message)
return Effect.logWarning("schema rejection").pipe(