22 lines
893 B
TypeScript
22 lines
893 B
TypeScript
import { makeDefaultApi } from "@opencode-ai/protocol/api"
|
|
import { InvalidRequestError, SessionNotFoundError } from "@opencode-ai/protocol/errors"
|
|
import { HttpApi, HttpApiMiddleware } from "effect/unstable/httpapi"
|
|
|
|
class LocationMiddleware extends HttpApiMiddleware.Service<LocationMiddleware>()(
|
|
"@opencode-ai/client/LocationMiddleware",
|
|
) {}
|
|
|
|
class SessionLocationMiddleware extends HttpApiMiddleware.Service<SessionLocationMiddleware>()(
|
|
"@opencode-ai/client/SessionLocationMiddleware",
|
|
{ error: [InvalidRequestError, SessionNotFoundError] },
|
|
) {}
|
|
|
|
const Api = makeDefaultApi({
|
|
locationMiddleware: LocationMiddleware,
|
|
sessionLocationMiddleware: SessionLocationMiddleware,
|
|
})
|
|
|
|
export const SessionGroup = Api.groups["server.session"]
|
|
export const EventGroup = Api.groups["server.event"]
|
|
export const ClientApi = HttpApi.make("opencode-client").add(SessionGroup).add(EventGroup)
|