// Generated by @opencode-ai/httpapi-codegen. Do not edit.
import { Effect, Stream, Schema } from "effect"
import { Sse } from "effect/unstable/encoding"
import { HttpClientError } from "effect/unstable/http"
import { HttpApiClient } from "effect/unstable/httpapi"
import { ClientApi } from "../../contract"
import type {
  Endpoint0_0Output,
  Endpoint0_1Input,
  Endpoint0_1Output,
  Endpoint1_0Output,
  Endpoint2_0Input,
  Endpoint2_0Output,
  Endpoint3_0Input,
  Endpoint3_0Output,
  Endpoint3_1Input,
  Endpoint3_1Output,
  Endpoint4_0Input,
  Endpoint4_0Output,
  Endpoint5_0Input,
  Endpoint5_0Output,
  Endpoint5_1Input,
  Endpoint5_1Output,
  Endpoint5_2Input,
  Endpoint5_2Output,
  Endpoint5_3Input,
  Endpoint5_3Output,
  Endpoint5_4Output,
  Endpoint5_5Input,
  Endpoint5_5Output,
  Endpoint5_6Input,
  Endpoint5_6Output,
  Endpoint5_7Input,
  Endpoint5_7Output,
  Endpoint5_8Input,
  Endpoint5_8Output,
  Endpoint5_9Input,
  Endpoint5_9Output,
  Endpoint5_10Input,
  Endpoint5_10Output,
  Endpoint5_11Input,
  Endpoint5_11Output,
  Endpoint5_12Input,
  Endpoint5_12Output,
  Endpoint5_13Input,
  Endpoint5_13Output,
  Endpoint5_14Input,
  Endpoint5_14Output,
  Endpoint5_15Input,
  Endpoint5_15Output,
  Endpoint5_16Input,
  Endpoint5_16Output,
  Endpoint5_17Input,
  Endpoint5_17Output,
  Endpoint5_18Input,
  Endpoint5_18Output,
  Endpoint5_19Input,
  Endpoint5_19Output,
  Endpoint5_20Input,
  Endpoint5_20Output,
  Endpoint5_21Input,
  Endpoint5_21Output,
  Endpoint5_22Input,
  Endpoint5_22Output,
  Endpoint5_23Input,
  Endpoint5_23Output,
  Endpoint5_24Input,
  Endpoint5_24Output,
  Endpoint5_25Input,
  Endpoint5_25Output,
  Endpoint5_26Input,
  Endpoint5_26Output,
  Endpoint5_27Input,
  Endpoint5_27Output,
  Endpoint5_28Input,
  Endpoint5_28Output,
  Endpoint5_29Input,
  Endpoint5_29Output,
  Endpoint5_30Input,
  Endpoint5_30Output,
  Endpoint5_31Input,
  Endpoint5_31Output,
  Endpoint6_0Input,
  Endpoint6_0Output,
  Endpoint7_0Input,
  Endpoint7_0Output,
  Endpoint7_1Input,
  Endpoint7_1Output,
  Endpoint8_0Input,
  Endpoint8_0Output,
  Endpoint9_0Input,
  Endpoint9_0Output,
  Endpoint9_1Input,
  Endpoint9_1Output,
  Endpoint10_0Input,
  Endpoint10_0Output,
  Endpoint10_1Input,
  Endpoint10_1Output,
  Endpoint10_2Input,
  Endpoint10_2Output,
  Endpoint10_3Input,
  Endpoint10_3Output,
  Endpoint10_4Input,
  Endpoint10_4Output,
  Endpoint10_5Input,
  Endpoint10_5Output,
  Endpoint10_6Input,
  Endpoint10_6Output,
  Endpoint10_7Input,
  Endpoint10_7Output,
  Endpoint10_8Input,
  Endpoint10_8Output,
  Endpoint10_9Input,
  Endpoint10_9Output,
  Endpoint10_10Input,
  Endpoint10_10Output,
  Endpoint11_0Input,
  Endpoint11_0Output,
  Endpoint11_1Input,
  Endpoint11_1Output,
  Endpoint11_2Input,
  Endpoint11_2Output,
  Endpoint11_3Input,
  Endpoint11_3Output,
  Endpoint11_4Input,
  Endpoint11_4Output,
  Endpoint11_5Input,
  Endpoint11_5Output,
  Endpoint12_0Input,
  Endpoint12_0Output,
  Endpoint12_1Input,
  Endpoint12_1Output,
  Endpoint13_0Output,
  Endpoint13_1Input,
  Endpoint13_1Output,
  Endpoint13_2Input,
  Endpoint13_2Output,
  Endpoint14_0Input,
  Endpoint14_0Output,
  Endpoint14_1Input,
  Endpoint14_1Output,
  Endpoint14_2Input,
  Endpoint14_2Output,
  Endpoint14_3Input,
  Endpoint14_3Output,
  Endpoint14_4Input,
  Endpoint14_4Output,
  Endpoint14_5Input,
  Endpoint14_5Output,
  Endpoint14_6Input,
  Endpoint14_6Output,
  Endpoint15_0Input,
  Endpoint15_0Output,
  Endpoint15_1Input,
  Endpoint15_1Output,
  Endpoint15_2Input,
  Endpoint15_2Output,
  Endpoint15_3Input,
  Endpoint15_3Output,
  Endpoint15_4Input,
  Endpoint15_4Output,
  Endpoint15_5Input,
  Endpoint15_5Output,
  Endpoint15_6Input,
  Endpoint15_6Output,
  Endpoint16_0Input,
  Endpoint16_0Output,
  Endpoint16_1Input,
  Endpoint16_1Output,
  Endpoint17_0Input,
  Endpoint17_0Output,
  Endpoint18_0Input,
  Endpoint18_0Output,
  Endpoint19_0Output,
  Endpoint20_0Input,
  Endpoint20_0Output,
  Endpoint20_1Input,
  Endpoint20_1Output,
  Endpoint20_2Input,
  Endpoint20_2Output,
  Endpoint20_3Input,
  Endpoint20_3Output,
  Endpoint20_4Input,
  Endpoint20_4Output,
  Endpoint21_0Input,
  Endpoint21_0Output,
  Endpoint21_1Input,
  Endpoint21_1Output,
  Endpoint21_2Input,
  Endpoint21_2Output,
  Endpoint21_3Input,
  Endpoint21_3Output,
  Endpoint21_4Input,
  Endpoint21_4Output,
  Endpoint21_5Input,
  Endpoint21_5Output,
  Endpoint22_0Input,
  Endpoint22_0Output,
  Endpoint22_1Input,
  Endpoint22_1Output,
  Endpoint22_2Input,
  Endpoint22_2Output,
  Endpoint22_3Input,
  Endpoint22_3Output,
  Endpoint23_0Input,
  Endpoint23_0Output,
  Endpoint24_0Input,
  Endpoint24_0Output,
  Endpoint24_1Input,
  Endpoint24_1Output,
  Endpoint24_2Input,
  Endpoint24_2Output,
  Endpoint25_0Input,
  Endpoint25_0Output,
  Endpoint25_1Input,
  Endpoint25_1Output,
  Endpoint25_2Input,
  Endpoint25_2Output,
  Endpoint26_0Output,
  Endpoint26_1Input,
  Endpoint26_1Output,
  Endpoint27_0Output,
  Endpoint28_0Input,
  Endpoint28_0Output,
  Endpoint28_1Input,
  Endpoint28_1Output,
  Endpoint29_0Input,
  Endpoint29_0Output,
} from "../api/api.js"
import { ClientError } from "./client-error"

type RawClient = HttpApiClient.ForApi<typeof ClientApi>

const mapClientError = <E>(error: E) =>
  HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error)
    ? new ClientError({ cause: error })
    : error

const preserveEffect =
  <A>() =>
  <E, R>(effect: Effect.Effect<A, E, R>) =>
    effect
const preserveStream =
  <A>() =>
  <E, R>(stream: Stream.Stream<A, E, R>) =>
    stream

const Endpoint0_0 = (raw: RawClient["server.health"]) => () =>
  preserveEffect<Endpoint0_0Output>()(raw["health.get"]({}).pipe(Effect.mapError(mapClientError)))

const Endpoint0_1 = (raw: RawClient["server.health"]) => (input: Endpoint0_1Input) =>
  preserveEffect<Endpoint0_1Output>()(
    raw["health.stop"]({ payload: { instanceID: input["instanceID"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup0 = (raw: RawClient["server.health"]) => ({ get: Endpoint0_0(raw), stop: Endpoint0_1(raw) })

const Endpoint1_0 = (raw: RawClient["server.server"]) => () =>
  preserveEffect<Endpoint1_0Output>()(raw["server.get"]({}).pipe(Effect.mapError(mapClientError)))

const adaptGroup1 = (raw: RawClient["server.server"]) => ({ get: Endpoint1_0(raw) })

const Endpoint2_0 = (raw: RawClient["server.location"]) => (input?: Endpoint2_0Input) =>
  preserveEffect<Endpoint2_0Output>()(
    raw["location.get"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup2 = (raw: RawClient["server.location"]) => ({ get: Endpoint2_0(raw) })

const Endpoint3_0 = (raw: RawClient["server.agent"]) => (input?: Endpoint3_0Input) =>
  preserveEffect<Endpoint3_0Output>()(
    raw["agent.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint3_1 = (raw: RawClient["server.agent"]) => (input: Endpoint3_1Input) =>
  preserveEffect<Endpoint3_1Output>()(
    raw["agent.get"]({ params: { agentID: input["agentID"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const adaptGroup3 = (raw: RawClient["server.agent"]) => ({ list: Endpoint3_0(raw), get: Endpoint3_1(raw) })

const Endpoint4_0 = (raw: RawClient["server.plugin"]) => (input?: Endpoint4_0Input) =>
  preserveEffect<Endpoint4_0Output>()(
    raw["plugin.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup4 = (raw: RawClient["server.plugin"]) => ({ list: Endpoint4_0(raw) })

const Endpoint5_0 = (raw: RawClient["server.session"]) => (input?: Endpoint5_0Input) =>
  preserveEffect<Endpoint5_0Output>()(
    raw["session.list"]({
      query: {
        workspace: input?.["workspace"],
        limit: input?.["limit"],
        order: input?.["order"],
        search: input?.["search"],
        parentID: input?.["parentID"],
        directory: input?.["directory"],
        project: input?.["project"],
        subpath: input?.["subpath"],
        cursor: input?.["cursor"],
      },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_1 = (raw: RawClient["server.session"]) => (input?: Endpoint5_1Input) =>
  preserveEffect<Endpoint5_1Output>()(
    raw["session.create"]({
      payload: {
        id: input?.["id"],
        title: input?.["title"],
        agent: input?.["agent"],
        model: input?.["model"],
        location: input?.["location"],
      },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_2 = (raw: RawClient["server.session"]) => (input: Endpoint5_2Input) =>
  preserveEffect<Endpoint5_2Output>()(
    raw["session.import"]({
      payload: { info: input["info"], messages: input["messages"], location: input["location"] },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_3 = (raw: RawClient["server.session"]) => (input: Endpoint5_3Input) =>
  preserveEffect<Endpoint5_3Output>()(
    raw["session.export"]({ params: { sessionID: input["sessionID"] }, query: { sanitize: input["sanitize"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_4 = (raw: RawClient["server.session"]) => () =>
  preserveEffect<Endpoint5_4Output>()(
    raw["session.active"]({}).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_5 = (raw: RawClient["server.session"]) => (input: Endpoint5_5Input) =>
  preserveEffect<Endpoint5_5Output>()(
    raw["session.get"]({ params: { sessionID: input["sessionID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_6 = (raw: RawClient["server.session"]) => (input: Endpoint5_6Input) =>
  preserveEffect<Endpoint5_6Output>()(
    raw["session.remove"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_7 = (raw: RawClient["server.session"]) => (input: Endpoint5_7Input) =>
  preserveEffect<Endpoint5_7Output>()(
    raw["session.fork"]({ params: { sessionID: input["sessionID"] }, payload: { boundary: input["boundary"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_8 = (raw: RawClient["server.session"]) => (input: Endpoint5_8Input) =>
  preserveEffect<Endpoint5_8Output>()(
    raw["session.switchAgent"]({ params: { sessionID: input["sessionID"] }, payload: { agent: input["agent"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint5_9 = (raw: RawClient["server.session"]) => (input: Endpoint5_9Input) =>
  preserveEffect<Endpoint5_9Output>()(
    raw["session.switchModel"]({ params: { sessionID: input["sessionID"] }, payload: { model: input["model"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint5_10 = (raw: RawClient["server.session"]) => (input: Endpoint5_10Input) =>
  preserveEffect<Endpoint5_10Output>()(
    raw["session.rename"]({ params: { sessionID: input["sessionID"] }, payload: { title: input["title"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint5_11 = (raw: RawClient["server.session"]) => (input: Endpoint5_11Input) =>
  preserveEffect<Endpoint5_11Output>()(
    raw["session.move"]({
      params: { sessionID: input["sessionID"] },
      payload: { directory: input["directory"], workspaceID: input["workspaceID"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_12 = (raw: RawClient["server.session"]) => (input: Endpoint5_12Input) =>
  preserveEffect<Endpoint5_12Output>()(
    raw["session.prompt"]({
      params: { sessionID: input["sessionID"] },
      payload: {
        id: input["id"],
        text: input["text"],
        files: input["files"],
        agents: input["agents"],
        metadata: input["metadata"],
        delivery: input["delivery"],
        resume: input["resume"],
      },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_13 = (raw: RawClient["server.session"]) => (input: Endpoint5_13Input) =>
  preserveEffect<Endpoint5_13Output>()(
    raw["session.command"]({
      params: { sessionID: input["sessionID"] },
      payload: {
        id: input["id"],
        command: input["command"],
        arguments: input["arguments"],
        agent: input["agent"],
        model: input["model"],
        files: input["files"],
        agents: input["agents"],
        delivery: input["delivery"],
        resume: input["resume"],
      },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_14 = (raw: RawClient["server.session"]) => (input: Endpoint5_14Input) =>
  preserveEffect<Endpoint5_14Output>()(
    raw["session.skill"]({
      params: { sessionID: input["sessionID"] },
      payload: { id: input["id"], skill: input["skill"], resume: input["resume"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_15 = (raw: RawClient["server.session"]) => (input: Endpoint5_15Input) =>
  preserveEffect<Endpoint5_15Output>()(
    raw["session.synthetic"]({
      params: { sessionID: input["sessionID"] },
      payload: {
        id: input["id"],
        text: input["text"],
        description: input["description"],
        metadata: input["metadata"],
        delivery: input["delivery"],
        resume: input["resume"],
      },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_16 = (raw: RawClient["server.session"]) => (input: Endpoint5_16Input) =>
  preserveEffect<Endpoint5_16Output>()(
    raw["session.shell"]({
      params: { sessionID: input["sessionID"] },
      payload: { id: input["id"], command: input["command"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_17 = (raw: RawClient["server.session"]) => (input: Endpoint5_17Input) =>
  preserveEffect<Endpoint5_17Output>()(
    raw["session.compact"]({ params: { sessionID: input["sessionID"] }, payload: { id: input["id"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_18 = (raw: RawClient["server.session"]) => (input: Endpoint5_18Input) =>
  preserveEffect<Endpoint5_18Output>()(
    raw["session.wait"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_19 = (raw: RawClient["server.session"]) => (input: Endpoint5_19Input) =>
  preserveEffect<Endpoint5_19Output>()(
    raw["session.revert.stage"]({
      params: { sessionID: input["sessionID"] },
      payload: { messageID: input["messageID"], files: input["files"] },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_20 = (raw: RawClient["server.session"]) => (input: Endpoint5_20Input) =>
  preserveEffect<Endpoint5_20Output>()(
    raw["session.revert.clear"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_21 = (raw: RawClient["server.session"]) => (input: Endpoint5_21Input) =>
  preserveEffect<Endpoint5_21Output>()(
    raw["session.revert.commit"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_22 = (raw: RawClient["server.session"]) => (input: Endpoint5_22Input) =>
  preserveEffect<Endpoint5_22Output>()(
    raw["session.context"]({ params: { sessionID: input["sessionID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_23 = (raw: RawClient["server.session"]) => (input: Endpoint5_23Input) =>
  preserveEffect<Endpoint5_23Output>()(
    raw["session.pending.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_24 = (raw: RawClient["server.session"]) => (input: Endpoint5_24Input) =>
  preserveEffect<Endpoint5_24Output>()(
    raw["session.instructions.entry.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_25 = (raw: RawClient["server.session"]) => (input: Endpoint5_25Input) =>
  preserveEffect<Endpoint5_25Output>()(
    raw["session.instructions.entry.put"]({
      params: { sessionID: input["sessionID"], key: input["key"] },
      payload: { value: input["value"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_26 = (raw: RawClient["server.session"]) => (input: Endpoint5_26Input) =>
  preserveEffect<Endpoint5_26Output>()(
    raw["session.instructions.entry.remove"]({ params: { sessionID: input["sessionID"], key: input["key"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint5_27 = (raw: RawClient["server.session"]) => (input: Endpoint5_27Input) =>
  preserveEffect<Endpoint5_27Output>()(
    raw["session.generate"]({ params: { sessionID: input["sessionID"] }, payload: { prompt: input["prompt"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint5_28 = (raw: RawClient["server.session"]) => (input: Endpoint5_28Input) =>
  preserveStream<Endpoint5_28Output>()(
    Stream.unwrap(
      raw["session.log"]({
        params: { sessionID: input["sessionID"] },
        query: { after: input["after"], follow: input["follow"] },
      }).pipe(
        Effect.mapError(mapClientError),
        Effect.map((stream) => stream.pipe(Stream.mapError(mapClientError))),
      ),
    ),
  )

const Endpoint5_29 = (raw: RawClient["server.session"]) => (input: Endpoint5_29Input) =>
  preserveEffect<Endpoint5_29Output>()(
    raw["session.interrupt"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_30 = (raw: RawClient["server.session"]) => (input: Endpoint5_30Input) =>
  preserveEffect<Endpoint5_30Output>()(
    raw["session.background"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint5_31 = (raw: RawClient["server.session"]) => (input: Endpoint5_31Input) =>
  preserveEffect<Endpoint5_31Output>()(
    raw["session.message"]({ params: { sessionID: input["sessionID"], messageID: input["messageID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const adaptGroup5 = (raw: RawClient["server.session"]) => ({
  list: Endpoint5_0(raw),
  create: Endpoint5_1(raw),
  import: Endpoint5_2(raw),
  export: Endpoint5_3(raw),
  active: Endpoint5_4(raw),
  get: Endpoint5_5(raw),
  remove: Endpoint5_6(raw),
  fork: Endpoint5_7(raw),
  switchAgent: Endpoint5_8(raw),
  switchModel: Endpoint5_9(raw),
  rename: Endpoint5_10(raw),
  move: Endpoint5_11(raw),
  prompt: Endpoint5_12(raw),
  command: Endpoint5_13(raw),
  skill: Endpoint5_14(raw),
  synthetic: Endpoint5_15(raw),
  shell: Endpoint5_16(raw),
  compact: Endpoint5_17(raw),
  wait: Endpoint5_18(raw),
  revert: { stage: Endpoint5_19(raw), clear: Endpoint5_20(raw), commit: Endpoint5_21(raw) },
  context: Endpoint5_22(raw),
  pending: { list: Endpoint5_23(raw) },
  instructions: { entry: { list: Endpoint5_24(raw), put: Endpoint5_25(raw), remove: Endpoint5_26(raw) } },
  generate: Endpoint5_27(raw),
  log: Endpoint5_28(raw),
  interrupt: Endpoint5_29(raw),
  background: Endpoint5_30(raw),
  message: Endpoint5_31(raw),
})

const Endpoint6_0 = (raw: RawClient["server.message"]) => (input: Endpoint6_0Input) =>
  preserveEffect<Endpoint6_0Output>()(
    raw["session.messages"]({
      params: { sessionID: input["sessionID"] },
      query: { limit: input["limit"], order: input["order"], cursor: input["cursor"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup6 = (raw: RawClient["server.message"]) => ({ list: Endpoint6_0(raw) })

const Endpoint7_0 = (raw: RawClient["server.model"]) => (input?: Endpoint7_0Input) =>
  preserveEffect<Endpoint7_0Output>()(
    raw["model.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint7_1 = (raw: RawClient["server.model"]) => (input?: Endpoint7_1Input) =>
  preserveEffect<Endpoint7_1Output>()(
    raw["model.default"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup7 = (raw: RawClient["server.model"]) => ({ list: Endpoint7_0(raw), default: Endpoint7_1(raw) })

const Endpoint8_0 = (raw: RawClient["server.generate"]) => (input: Endpoint8_0Input) =>
  preserveEffect<Endpoint8_0Output>()(
    raw["generate.text"]({
      query: { location: input["location"] },
      payload: { prompt: input["prompt"], model: input["model"] },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const adaptGroup8 = (raw: RawClient["server.generate"]) => ({ text: Endpoint8_0(raw) })

const Endpoint9_0 = (raw: RawClient["server.provider"]) => (input?: Endpoint9_0Input) =>
  preserveEffect<Endpoint9_0Output>()(
    raw["provider.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint9_1 = (raw: RawClient["server.provider"]) => (input: Endpoint9_1Input) =>
  preserveEffect<Endpoint9_1Output>()(
    raw["provider.get"]({ params: { providerID: input["providerID"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const adaptGroup9 = (raw: RawClient["server.provider"]) => ({ list: Endpoint9_0(raw), get: Endpoint9_1(raw) })

const Endpoint10_0 = (raw: RawClient["server.integration"]) => (input?: Endpoint10_0Input) =>
  preserveEffect<Endpoint10_0Output>()(
    raw["integration.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_1 = (raw: RawClient["server.integration"]) => (input: Endpoint10_1Input) =>
  preserveEffect<Endpoint10_1Output>()(
    raw["integration.get"]({
      params: { integrationID: input["integrationID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_2 = (raw: RawClient["server.integration"]) => (input: Endpoint10_2Input) =>
  preserveEffect<Endpoint10_2Output>()(
    raw["integration.wellknown.add"]({ query: { location: input["location"] }, payload: { url: input["url"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint10_3 = (raw: RawClient["server.integration"]) => (input: Endpoint10_3Input) =>
  preserveEffect<Endpoint10_3Output>()(
    raw["integration.connect.key"]({
      params: { integrationID: input["integrationID"] },
      query: { location: input["location"] },
      payload: { key: input["key"], label: input["label"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_4 = (raw: RawClient["server.integration"]) => (input: Endpoint10_4Input) =>
  preserveEffect<Endpoint10_4Output>()(
    raw["integration.oauth.connect"]({
      params: { integrationID: input["integrationID"] },
      query: { location: input["location"] },
      payload: { methodID: input["methodID"], inputs: input["inputs"], label: input["label"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_5 = (raw: RawClient["server.integration"]) => (input: Endpoint10_5Input) =>
  preserveEffect<Endpoint10_5Output>()(
    raw["integration.oauth.status"]({
      params: { integrationID: input["integrationID"], attemptID: input["attemptID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_6 = (raw: RawClient["server.integration"]) => (input: Endpoint10_6Input) =>
  preserveEffect<Endpoint10_6Output>()(
    raw["integration.oauth.complete"]({
      params: { integrationID: input["integrationID"], attemptID: input["attemptID"] },
      query: { location: input["location"] },
      payload: { code: input["code"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_7 = (raw: RawClient["server.integration"]) => (input: Endpoint10_7Input) =>
  preserveEffect<Endpoint10_7Output>()(
    raw["integration.oauth.cancel"]({
      params: { integrationID: input["integrationID"], attemptID: input["attemptID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_8 = (raw: RawClient["server.integration"]) => (input: Endpoint10_8Input) =>
  preserveEffect<Endpoint10_8Output>()(
    raw["integration.command.connect"]({
      params: { integrationID: input["integrationID"] },
      query: { location: input["location"] },
      payload: { methodID: input["methodID"], label: input["label"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_9 = (raw: RawClient["server.integration"]) => (input: Endpoint10_9Input) =>
  preserveEffect<Endpoint10_9Output>()(
    raw["integration.command.status"]({
      params: { integrationID: input["integrationID"], attemptID: input["attemptID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint10_10 = (raw: RawClient["server.integration"]) => (input: Endpoint10_10Input) =>
  preserveEffect<Endpoint10_10Output>()(
    raw["integration.command.cancel"]({
      params: { integrationID: input["integrationID"], attemptID: input["attemptID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup10 = (raw: RawClient["server.integration"]) => ({
  list: Endpoint10_0(raw),
  get: Endpoint10_1(raw),
  wellknown: { add: Endpoint10_2(raw) },
  connect: { key: Endpoint10_3(raw) },
  oauth: {
    connect: Endpoint10_4(raw),
    status: Endpoint10_5(raw),
    complete: Endpoint10_6(raw),
    cancel: Endpoint10_7(raw),
  },
  command: { connect: Endpoint10_8(raw), status: Endpoint10_9(raw), cancel: Endpoint10_10(raw) },
})

const Endpoint11_0 = (raw: RawClient["server.mcp"]) => (input?: Endpoint11_0Input) =>
  preserveEffect<Endpoint11_0Output>()(
    raw["mcp.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint11_1 = (raw: RawClient["server.mcp"]) => (input: Endpoint11_1Input) =>
  preserveEffect<Endpoint11_1Output>()(
    raw["mcp.add"]({
      params: { server: input["server"] },
      query: { location: input["location"] },
      payload: { config: input["config"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint11_2 = (raw: RawClient["server.mcp"]) => (input: Endpoint11_2Input) =>
  preserveEffect<Endpoint11_2Output>()(
    raw["mcp.remove"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint11_3 = (raw: RawClient["server.mcp"]) => (input: Endpoint11_3Input) =>
  preserveEffect<Endpoint11_3Output>()(
    raw["mcp.connect"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint11_4 = (raw: RawClient["server.mcp"]) => (input: Endpoint11_4Input) =>
  preserveEffect<Endpoint11_4Output>()(
    raw["mcp.disconnect"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint11_5 = (raw: RawClient["server.mcp"]) => (input?: Endpoint11_5Input) =>
  preserveEffect<Endpoint11_5Output>()(
    raw["mcp.resource.catalog"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup11 = (raw: RawClient["server.mcp"]) => ({
  list: Endpoint11_0(raw),
  add: Endpoint11_1(raw),
  remove: Endpoint11_2(raw),
  connect: Endpoint11_3(raw),
  disconnect: Endpoint11_4(raw),
  resource: { catalog: Endpoint11_5(raw) },
})

const Endpoint12_0 = (raw: RawClient["server.credential"]) => (input: Endpoint12_0Input) =>
  preserveEffect<Endpoint12_0Output>()(
    raw["credential.update"]({
      params: { credentialID: input["credentialID"] },
      query: { location: input["location"] },
      payload: { label: input["label"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint12_1 = (raw: RawClient["server.credential"]) => (input: Endpoint12_1Input) =>
  preserveEffect<Endpoint12_1Output>()(
    raw["credential.remove"]({
      params: { credentialID: input["credentialID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup12 = (raw: RawClient["server.credential"]) => ({ update: Endpoint12_0(raw), remove: Endpoint12_1(raw) })

const Endpoint13_0 = (raw: RawClient["server.project"]) => () =>
  preserveEffect<Endpoint13_0Output>()(raw["project.list"]({}).pipe(Effect.mapError(mapClientError)))

const Endpoint13_1 = (raw: RawClient["server.project"]) => (input?: Endpoint13_1Input) =>
  preserveEffect<Endpoint13_1Output>()(
    raw["project.current"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint13_2 = (raw: RawClient["server.project"]) => (input: Endpoint13_2Input) =>
  preserveEffect<Endpoint13_2Output>()(
    raw["project.directories"]({
      params: { projectID: input["projectID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup13 = (raw: RawClient["server.project"]) => ({
  list: Endpoint13_0(raw),
  current: Endpoint13_1(raw),
  directories: Endpoint13_2(raw),
})

const Endpoint14_0 = (raw: RawClient["server.form"]) => (input?: Endpoint14_0Input) =>
  preserveEffect<Endpoint14_0Output>()(
    raw["form.request.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint14_1 = (raw: RawClient["server.form"]) => (input: Endpoint14_1Input) =>
  preserveEffect<Endpoint14_1Output>()(
    raw["session.form.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint14_2 = (raw: RawClient["server.form"]) => (input: Endpoint14_2Input) =>
  preserveEffect<Endpoint14_2Output>()(
    raw["session.form.create"]({
      params: { sessionID: input["sessionID"] },
      payload: { id: input["id"], title: input["title"], metadata: input["metadata"], fields: input["fields"] },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint14_3 = (raw: RawClient["server.form"]) => (input: Endpoint14_3Input) =>
  preserveEffect<Endpoint14_3Output>()(
    raw["session.form.get"]({ params: { sessionID: input["sessionID"], formID: input["formID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint14_4 = (raw: RawClient["server.form"]) => (input: Endpoint14_4Input) =>
  preserveEffect<Endpoint14_4Output>()(
    raw["session.form.state"]({ params: { sessionID: input["sessionID"], formID: input["formID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint14_5 = (raw: RawClient["server.form"]) => (input: Endpoint14_5Input) =>
  preserveEffect<Endpoint14_5Output>()(
    raw["session.form.reply"]({
      params: { sessionID: input["sessionID"], formID: input["formID"] },
      payload: { answer: input["answer"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint14_6 = (raw: RawClient["server.form"]) => (input: Endpoint14_6Input) =>
  preserveEffect<Endpoint14_6Output>()(
    raw["session.form.cancel"]({ params: { sessionID: input["sessionID"], formID: input["formID"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const adaptGroup14 = (raw: RawClient["server.form"]) => ({
  request: { list: Endpoint14_0(raw) },
  list: Endpoint14_1(raw),
  create: Endpoint14_2(raw),
  get: Endpoint14_3(raw),
  state: Endpoint14_4(raw),
  reply: Endpoint14_5(raw),
  cancel: Endpoint14_6(raw),
})

const Endpoint15_0 = (raw: RawClient["server.permission"]) => (input?: Endpoint15_0Input) =>
  preserveEffect<Endpoint15_0Output>()(
    raw["permission.request.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint15_1 = (raw: RawClient["server.permission"]) => (input?: Endpoint15_1Input) =>
  preserveEffect<Endpoint15_1Output>()(
    raw["permission.saved.list"]({ query: { projectID: input?.["projectID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint15_2 = (raw: RawClient["server.permission"]) => (input: Endpoint15_2Input) =>
  preserveEffect<Endpoint15_2Output>()(
    raw["permission.saved.remove"]({ params: { id: input["id"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint15_3 = (raw: RawClient["server.permission"]) => (input: Endpoint15_3Input) =>
  preserveEffect<Endpoint15_3Output>()(
    raw["session.permission.create"]({
      params: { sessionID: input["sessionID"] },
      payload: {
        id: input["id"],
        action: input["action"],
        resources: input["resources"],
        save: input["save"],
        metadata: input["metadata"],
        source: input["source"],
        agent: input["agent"],
      },
    }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint15_4 = (raw: RawClient["server.permission"]) => (input: Endpoint15_4Input) =>
  preserveEffect<Endpoint15_4Output>()(
    raw["session.permission.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint15_5 = (raw: RawClient["server.permission"]) => (input: Endpoint15_5Input) =>
  preserveEffect<Endpoint15_5Output>()(
    raw["session.permission.get"]({ params: { sessionID: input["sessionID"], requestID: input["requestID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint15_6 = (raw: RawClient["server.permission"]) => (input: Endpoint15_6Input) =>
  preserveEffect<Endpoint15_6Output>()(
    raw["session.permission.reply"]({
      params: { sessionID: input["sessionID"], requestID: input["requestID"] },
      payload: { reply: input["reply"], message: input["message"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup15 = (raw: RawClient["server.permission"]) => ({
  request: { list: Endpoint15_0(raw) },
  saved: { list: Endpoint15_1(raw), remove: Endpoint15_2(raw) },
  create: Endpoint15_3(raw),
  list: Endpoint15_4(raw),
  get: Endpoint15_5(raw),
  reply: Endpoint15_6(raw),
})

const Endpoint16_0 = (raw: RawClient["server.fs"]) => (input?: Endpoint16_0Input) =>
  preserveEffect<Endpoint16_0Output>()(
    raw["fs.list"]({ query: { location: input?.["location"], path: input?.["path"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint16_1 = (raw: RawClient["server.fs"]) => (input: Endpoint16_1Input) =>
  preserveEffect<Endpoint16_1Output>()(
    raw["fs.find"]({
      query: { location: input["location"], query: input["query"], type: input["type"], limit: input["limit"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup16 = (raw: RawClient["server.fs"]) => ({ list: Endpoint16_0(raw), find: Endpoint16_1(raw) })

const Endpoint17_0 = (raw: RawClient["server.command"]) => (input?: Endpoint17_0Input) =>
  preserveEffect<Endpoint17_0Output>()(
    raw["command.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup17 = (raw: RawClient["server.command"]) => ({ list: Endpoint17_0(raw) })

const Endpoint18_0 = (raw: RawClient["server.skill"]) => (input?: Endpoint18_0Input) =>
  preserveEffect<Endpoint18_0Output>()(
    raw["skill.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup18 = (raw: RawClient["server.skill"]) => ({ list: Endpoint18_0(raw) })

const Endpoint19_0 = (raw: RawClient["server.event"]) => () =>
  preserveStream<Endpoint19_0Output>()(
    Stream.unwrap(
      raw["event.subscribe"]({}).pipe(
        Effect.mapError(mapClientError),
        Effect.map((stream) => stream.pipe(Stream.mapError(mapClientError))),
      ),
    ),
  )

const adaptGroup19 = (raw: RawClient["server.event"]) => ({ subscribe: Endpoint19_0(raw) })

const Endpoint20_0 = (raw: RawClient["server.pty"]) => (input?: Endpoint20_0Input) =>
  preserveEffect<Endpoint20_0Output>()(
    raw["pty.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint20_1 = (raw: RawClient["server.pty"]) => (input?: Endpoint20_1Input) =>
  preserveEffect<Endpoint20_1Output>()(
    raw["pty.create"]({
      query: { location: input?.["location"] },
      payload: {
        command: input?.["command"],
        args: input?.["args"],
        cwd: input?.["cwd"],
        title: input?.["title"],
        env: input?.["env"],
      },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint20_2 = (raw: RawClient["server.pty"]) => (input: Endpoint20_2Input) =>
  preserveEffect<Endpoint20_2Output>()(
    raw["pty.get"]({ params: { ptyID: input["ptyID"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint20_3 = (raw: RawClient["server.pty"]) => (input: Endpoint20_3Input) =>
  preserveEffect<Endpoint20_3Output>()(
    raw["pty.update"]({
      params: { ptyID: input["ptyID"] },
      query: { location: input["location"] },
      payload: { title: input["title"], size: input["size"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint20_4 = (raw: RawClient["server.pty"]) => (input: Endpoint20_4Input) =>
  preserveEffect<Endpoint20_4Output>()(
    raw["pty.remove"]({ params: { ptyID: input["ptyID"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const adaptGroup20 = (raw: RawClient["server.pty"]) => ({
  list: Endpoint20_0(raw),
  create: Endpoint20_1(raw),
  get: Endpoint20_2(raw),
  update: Endpoint20_3(raw),
  remove: Endpoint20_4(raw),
})

const Endpoint21_0 = (raw: RawClient["server.shell"]) => (input?: Endpoint21_0Input) =>
  preserveEffect<Endpoint21_0Output>()(
    raw["shell.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint21_1 = (raw: RawClient["server.shell"]) => (input: Endpoint21_1Input) =>
  preserveEffect<Endpoint21_1Output>()(
    raw["shell.create"]({
      query: { location: input["location"] },
      payload: { command: input["command"], cwd: input["cwd"], timeout: input["timeout"], metadata: input["metadata"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint21_2 = (raw: RawClient["server.shell"]) => (input: Endpoint21_2Input) =>
  preserveEffect<Endpoint21_2Output>()(
    raw["shell.get"]({ params: { id: input["id"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const Endpoint21_3 = (raw: RawClient["server.shell"]) => (input: Endpoint21_3Input) =>
  preserveEffect<Endpoint21_3Output>()(
    raw["shell.timeout"]({
      params: { id: input["id"] },
      query: { location: input["location"] },
      payload: { timeout: input["timeout"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint21_4 = (raw: RawClient["server.shell"]) => (input: Endpoint21_4Input) =>
  preserveEffect<Endpoint21_4Output>()(
    raw["shell.output"]({
      params: { id: input["id"] },
      query: { location: input["location"], cursor: input["cursor"], limit: input["limit"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint21_5 = (raw: RawClient["server.shell"]) => (input: Endpoint21_5Input) =>
  preserveEffect<Endpoint21_5Output>()(
    raw["shell.remove"]({ params: { id: input["id"] }, query: { location: input["location"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const adaptGroup21 = (raw: RawClient["server.shell"]) => ({
  list: Endpoint21_0(raw),
  create: Endpoint21_1(raw),
  get: Endpoint21_2(raw),
  timeout: Endpoint21_3(raw),
  output: Endpoint21_4(raw),
  remove: Endpoint21_5(raw),
})

const Endpoint22_0 = (raw: RawClient["server.question"]) => (input?: Endpoint22_0Input) =>
  preserveEffect<Endpoint22_0Output>()(
    raw["question.request.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint22_1 = (raw: RawClient["server.question"]) => (input: Endpoint22_1Input) =>
  preserveEffect<Endpoint22_1Output>()(
    raw["session.question.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((value) => value.data),
    ),
  )

const Endpoint22_2 = (raw: RawClient["server.question"]) => (input: Endpoint22_2Input) =>
  preserveEffect<Endpoint22_2Output>()(
    raw["session.question.reply"]({
      params: { sessionID: input["sessionID"], requestID: input["requestID"] },
      payload: { answers: input["answers"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint22_3 = (raw: RawClient["server.question"]) => (input: Endpoint22_3Input) =>
  preserveEffect<Endpoint22_3Output>()(
    raw["session.question.reject"]({ params: { sessionID: input["sessionID"], requestID: input["requestID"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const adaptGroup22 = (raw: RawClient["server.question"]) => ({
  request: { list: Endpoint22_0(raw) },
  list: Endpoint22_1(raw),
  reply: Endpoint22_2(raw),
  reject: Endpoint22_3(raw),
})

const Endpoint23_0 = (raw: RawClient["server.reference"]) => (input?: Endpoint23_0Input) =>
  preserveEffect<Endpoint23_0Output>()(
    raw["reference.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup23 = (raw: RawClient["server.reference"]) => ({ list: Endpoint23_0(raw) })

const Endpoint24_0 = (raw: RawClient["server.projectCopy"]) => (input: Endpoint24_0Input) =>
  preserveEffect<Endpoint24_0Output>()(
    raw["projectCopy.create"]({
      params: { projectID: input["projectID"] },
      query: { location: input["location"] },
      payload: { strategy: input["strategy"], directory: input["directory"], name: input["name"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint24_1 = (raw: RawClient["server.projectCopy"]) => (input: Endpoint24_1Input) =>
  preserveEffect<Endpoint24_1Output>()(
    raw["projectCopy.remove"]({
      params: { projectID: input["projectID"] },
      query: { location: input["location"] },
      payload: { directory: input["directory"], force: input["force"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint24_2 = (raw: RawClient["server.projectCopy"]) => (input: Endpoint24_2Input) =>
  preserveEffect<Endpoint24_2Output>()(
    raw["projectCopy.refresh"]({
      params: { projectID: input["projectID"] },
      query: { location: input["location"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup24 = (raw: RawClient["server.projectCopy"]) => ({
  create: Endpoint24_0(raw),
  remove: Endpoint24_1(raw),
  refresh: Endpoint24_2(raw),
})

const Endpoint25_0 = (raw: RawClient["server.vcs"]) => (input?: Endpoint25_0Input) =>
  preserveEffect<Endpoint25_0Output>()(
    raw["vcs.get"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint25_1 = (raw: RawClient["server.vcs"]) => (input?: Endpoint25_1Input) =>
  preserveEffect<Endpoint25_1Output>()(
    raw["vcs.status"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint25_2 = (raw: RawClient["server.vcs"]) => (input: Endpoint25_2Input) =>
  preserveEffect<Endpoint25_2Output>()(
    raw["vcs.diff"]({ query: { location: input["location"], mode: input["mode"], context: input["context"] } }).pipe(
      Effect.mapError(mapClientError),
    ),
  )

const adaptGroup25 = (raw: RawClient["server.vcs"]) => ({
  get: Endpoint25_0(raw),
  status: Endpoint25_1(raw),
  diff: Endpoint25_2(raw),
})

const Endpoint26_0 = (raw: RawClient["server.debug"]) => () =>
  preserveEffect<Endpoint26_0Output>()(raw["debug.location"]({}).pipe(Effect.mapError(mapClientError)))

const Endpoint26_1 = (raw: RawClient["server.debug"]) => (input?: Endpoint26_1Input) =>
  preserveEffect<Endpoint26_1Output>()(
    raw["debug.location.evict"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup26 = (raw: RawClient["server.debug"]) => ({
  location: { list: Endpoint26_0(raw), evict: Endpoint26_1(raw) },
})

const Endpoint27_0 = (raw: RawClient["server.migration"]) => () =>
  preserveEffect<Endpoint27_0Output>()(raw["migration.v1.status"]({}).pipe(Effect.mapError(mapClientError)))

const adaptGroup27 = (raw: RawClient["server.migration"]) => ({ v1: { status: Endpoint27_0(raw) } })

const Endpoint28_0 = (raw: RawClient["server.websearch"]) => (input?: Endpoint28_0Input) =>
  preserveEffect<Endpoint28_0Output>()(
    raw["websearch.providers"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const Endpoint28_1 = (raw: RawClient["server.websearch"]) => (input: Endpoint28_1Input) =>
  preserveEffect<Endpoint28_1Output>()(
    raw["websearch.query"]({
      query: { location: input["location"] },
      payload: { query: input["query"], providerID: input["providerID"] },
    }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup28 = (raw: RawClient["server.websearch"]) => ({
  providers: Endpoint28_0(raw),
  query: Endpoint28_1(raw),
})

const Endpoint29_0 = (raw: RawClient["server.config"]) => (input?: Endpoint29_0Input) =>
  preserveEffect<Endpoint29_0Output>()(
    raw["config.get"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
  )

const adaptGroup29 = (raw: RawClient["server.config"]) => ({ get: Endpoint29_0(raw) })

const adaptClient = (raw: RawClient) => ({
  health: adaptGroup0(raw["server.health"]),
  server: adaptGroup1(raw["server.server"]),
  location: adaptGroup2(raw["server.location"]),
  agent: adaptGroup3(raw["server.agent"]),
  plugin: adaptGroup4(raw["server.plugin"]),
  session: adaptGroup5(raw["server.session"]),
  message: adaptGroup6(raw["server.message"]),
  model: adaptGroup7(raw["server.model"]),
  generate: adaptGroup8(raw["server.generate"]),
  provider: adaptGroup9(raw["server.provider"]),
  integration: adaptGroup10(raw["server.integration"]),
  mcp: adaptGroup11(raw["server.mcp"]),
  credential: adaptGroup12(raw["server.credential"]),
  project: adaptGroup13(raw["server.project"]),
  form: adaptGroup14(raw["server.form"]),
  permission: adaptGroup15(raw["server.permission"]),
  file: adaptGroup16(raw["server.fs"]),
  command: adaptGroup17(raw["server.command"]),
  skill: adaptGroup18(raw["server.skill"]),
  event: adaptGroup19(raw["server.event"]),
  pty: adaptGroup20(raw["server.pty"]),
  shell: adaptGroup21(raw["server.shell"]),
  question: adaptGroup22(raw["server.question"]),
  reference: adaptGroup23(raw["server.reference"]),
  projectCopy: adaptGroup24(raw["server.projectCopy"]),
  vcs: adaptGroup25(raw["server.vcs"]),
  debug: adaptGroup26(raw["server.debug"]),
  migration: adaptGroup27(raw["server.migration"]),
  websearch: adaptGroup28(raw["server.websearch"]),
  config: adaptGroup29(raw["server.config"]),
})

export const make = (options?: { readonly baseUrl?: URL | string }) =>
  HttpApiClient.make(ClientApi, options).pipe(Effect.map(adaptClient))
