// 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 { 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 Endpoint0_0 = (raw: RawClient["server.health"]) => () =>
  raw["health.get"]({}).pipe(Effect.mapError(mapClientError))

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

type Endpoint1_0Request = Parameters<RawClient["server.location"]["location.get"]>[0]
type Endpoint1_0Input = { readonly location?: Endpoint1_0Request["query"]["location"] }
const Endpoint1_0 = (raw: RawClient["server.location"]) => (input?: Endpoint1_0Input) =>
  raw["location.get"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

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

type Endpoint2_0Request = Parameters<RawClient["server.agent"]["agent.list"]>[0]
type Endpoint2_0Input = { readonly location?: Endpoint2_0Request["query"]["location"] }
const Endpoint2_0 = (raw: RawClient["server.agent"]) => (input?: Endpoint2_0Input) =>
  raw["agent.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

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

type Endpoint3_0Request = Parameters<RawClient["server.session"]["session.list"]>[0]
type Endpoint3_0Input = {
  readonly workspace?: Endpoint3_0Request["query"]["workspace"]
  readonly limit?: Endpoint3_0Request["query"]["limit"]
  readonly order?: Endpoint3_0Request["query"]["order"]
  readonly search?: Endpoint3_0Request["query"]["search"]
  readonly directory?: Endpoint3_0Request["query"]["directory"]
  readonly project?: Endpoint3_0Request["query"]["project"]
  readonly subpath?: Endpoint3_0Request["query"]["subpath"]
  readonly cursor?: Endpoint3_0Request["query"]["cursor"]
}
const Endpoint3_0 = (raw: RawClient["server.session"]) => (input?: Endpoint3_0Input) =>
  raw["session.list"]({
    query: {
      workspace: input?.["workspace"],
      limit: input?.["limit"],
      order: input?.["order"],
      search: input?.["search"],
      directory: input?.["directory"],
      project: input?.["project"],
      subpath: input?.["subpath"],
      cursor: input?.["cursor"],
    },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint3_1Request = Parameters<RawClient["server.session"]["session.create"]>[0]
type Endpoint3_1Input = {
  readonly id?: Endpoint3_1Request["payload"]["id"]
  readonly agent?: Endpoint3_1Request["payload"]["agent"]
  readonly model?: Endpoint3_1Request["payload"]["model"]
  readonly location?: Endpoint3_1Request["payload"]["location"]
}
const Endpoint3_1 = (raw: RawClient["server.session"]) => (input?: Endpoint3_1Input) =>
  raw["session.create"]({
    payload: { id: input?.["id"], agent: input?.["agent"], model: input?.["model"], location: input?.["location"] },
  }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

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

type Endpoint3_3Request = Parameters<RawClient["server.session"]["session.get"]>[0]
type Endpoint3_3Input = { readonly sessionID: Endpoint3_3Request["params"]["sessionID"] }
const Endpoint3_3 = (raw: RawClient["server.session"]) => (input: Endpoint3_3Input) =>
  raw["session.get"]({ params: { sessionID: input["sessionID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint3_4Request = Parameters<RawClient["server.session"]["session.switchAgent"]>[0]
type Endpoint3_4Input = {
  readonly sessionID: Endpoint3_4Request["params"]["sessionID"]
  readonly agent: Endpoint3_4Request["payload"]["agent"]
}
const Endpoint3_4 = (raw: RawClient["server.session"]) => (input: Endpoint3_4Input) =>
  raw["session.switchAgent"]({ params: { sessionID: input["sessionID"] }, payload: { agent: input["agent"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint3_5Request = Parameters<RawClient["server.session"]["session.switchModel"]>[0]
type Endpoint3_5Input = {
  readonly sessionID: Endpoint3_5Request["params"]["sessionID"]
  readonly model: Endpoint3_5Request["payload"]["model"]
}
const Endpoint3_5 = (raw: RawClient["server.session"]) => (input: Endpoint3_5Input) =>
  raw["session.switchModel"]({ params: { sessionID: input["sessionID"] }, payload: { model: input["model"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint3_6Request = Parameters<RawClient["server.session"]["session.prompt"]>[0]
type Endpoint3_6Input = {
  readonly sessionID: Endpoint3_6Request["params"]["sessionID"]
  readonly id?: Endpoint3_6Request["payload"]["id"]
  readonly prompt: Endpoint3_6Request["payload"]["prompt"]
  readonly delivery?: Endpoint3_6Request["payload"]["delivery"]
  readonly resume?: Endpoint3_6Request["payload"]["resume"]
}
const Endpoint3_6 = (raw: RawClient["server.session"]) => (input: Endpoint3_6Input) =>
  raw["session.prompt"]({
    params: { sessionID: input["sessionID"] },
    payload: { id: input["id"], prompt: input["prompt"], delivery: input["delivery"], resume: input["resume"] },
  }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint3_7Request = Parameters<RawClient["server.session"]["session.compact"]>[0]
type Endpoint3_7Input = { readonly sessionID: Endpoint3_7Request["params"]["sessionID"] }
const Endpoint3_7 = (raw: RawClient["server.session"]) => (input: Endpoint3_7Input) =>
  raw["session.compact"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint3_8Request = Parameters<RawClient["server.session"]["session.wait"]>[0]
type Endpoint3_8Input = { readonly sessionID: Endpoint3_8Request["params"]["sessionID"] }
const Endpoint3_8 = (raw: RawClient["server.session"]) => (input: Endpoint3_8Input) =>
  raw["session.wait"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint3_9Request = Parameters<RawClient["server.session"]["session.revert.stage"]>[0]
type Endpoint3_9Input = {
  readonly sessionID: Endpoint3_9Request["params"]["sessionID"]
  readonly messageID: Endpoint3_9Request["payload"]["messageID"]
  readonly files?: Endpoint3_9Request["payload"]["files"]
}
const Endpoint3_9 = (raw: RawClient["server.session"]) => (input: Endpoint3_9Input) =>
  raw["session.revert.stage"]({
    params: { sessionID: input["sessionID"] },
    payload: { messageID: input["messageID"], files: input["files"] },
  }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint3_10Request = Parameters<RawClient["server.session"]["session.revert.clear"]>[0]
type Endpoint3_10Input = { readonly sessionID: Endpoint3_10Request["params"]["sessionID"] }
const Endpoint3_10 = (raw: RawClient["server.session"]) => (input: Endpoint3_10Input) =>
  raw["session.revert.clear"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint3_11Request = Parameters<RawClient["server.session"]["session.revert.commit"]>[0]
type Endpoint3_11Input = { readonly sessionID: Endpoint3_11Request["params"]["sessionID"] }
const Endpoint3_11 = (raw: RawClient["server.session"]) => (input: Endpoint3_11Input) =>
  raw["session.revert.commit"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint3_12Request = Parameters<RawClient["server.session"]["session.context"]>[0]
type Endpoint3_12Input = { readonly sessionID: Endpoint3_12Request["params"]["sessionID"] }
const Endpoint3_12 = (raw: RawClient["server.session"]) => (input: Endpoint3_12Input) =>
  raw["session.context"]({ params: { sessionID: input["sessionID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint3_13Request = Parameters<RawClient["server.session"]["session.history"]>[0]
type Endpoint3_13Input = {
  readonly sessionID: Endpoint3_13Request["params"]["sessionID"]
  readonly limit?: Endpoint3_13Request["query"]["limit"]
  readonly after?: Endpoint3_13Request["query"]["after"]
}
const Endpoint3_13 = (raw: RawClient["server.session"]) => (input: Endpoint3_13Input) =>
  raw["session.history"]({
    params: { sessionID: input["sessionID"] },
    query: { limit: input["limit"], after: input["after"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint3_14Request = Parameters<RawClient["server.session"]["session.events"]>[0]
type Endpoint3_14Input = {
  readonly sessionID: Endpoint3_14Request["params"]["sessionID"]
  readonly after?: Endpoint3_14Request["query"]["after"]
}
const Endpoint3_14 = (raw: RawClient["server.session"]) => (input: Endpoint3_14Input) =>
  Stream.unwrap(
    raw["session.events"]({ params: { sessionID: input["sessionID"] }, query: { after: input["after"] } }).pipe(
      Effect.mapError(mapClientError),
      Effect.map((stream) => stream.pipe(Stream.mapError(mapClientError))),
    ),
  )

type Endpoint3_15Request = Parameters<RawClient["server.session"]["session.interrupt"]>[0]
type Endpoint3_15Input = { readonly sessionID: Endpoint3_15Request["params"]["sessionID"] }
const Endpoint3_15 = (raw: RawClient["server.session"]) => (input: Endpoint3_15Input) =>
  raw["session.interrupt"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint3_16Request = Parameters<RawClient["server.session"]["session.message"]>[0]
type Endpoint3_16Input = {
  readonly sessionID: Endpoint3_16Request["params"]["sessionID"]
  readonly messageID: Endpoint3_16Request["params"]["messageID"]
}
const Endpoint3_16 = (raw: RawClient["server.session"]) => (input: Endpoint3_16Input) =>
  raw["session.message"]({ params: { sessionID: input["sessionID"], messageID: input["messageID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

const adaptGroup3 = (raw: RawClient["server.session"]) => ({
  list: Endpoint3_0(raw),
  create: Endpoint3_1(raw),
  active: Endpoint3_2(raw),
  get: Endpoint3_3(raw),
  switchAgent: Endpoint3_4(raw),
  switchModel: Endpoint3_5(raw),
  prompt: Endpoint3_6(raw),
  compact: Endpoint3_7(raw),
  wait: Endpoint3_8(raw),
  stage: Endpoint3_9(raw),
  clear: Endpoint3_10(raw),
  commit: Endpoint3_11(raw),
  context: Endpoint3_12(raw),
  history: Endpoint3_13(raw),
  events: Endpoint3_14(raw),
  interrupt: Endpoint3_15(raw),
  message: Endpoint3_16(raw),
})

type Endpoint4_0Request = Parameters<RawClient["server.message"]["session.messages"]>[0]
type Endpoint4_0Input = {
  readonly sessionID: Endpoint4_0Request["params"]["sessionID"]
  readonly limit?: Endpoint4_0Request["query"]["limit"]
  readonly order?: Endpoint4_0Request["query"]["order"]
  readonly cursor?: Endpoint4_0Request["query"]["cursor"]
}
const Endpoint4_0 = (raw: RawClient["server.message"]) => (input: Endpoint4_0Input) =>
  raw["session.messages"]({
    params: { sessionID: input["sessionID"] },
    query: { limit: input["limit"], order: input["order"], cursor: input["cursor"] },
  }).pipe(Effect.mapError(mapClientError))

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

type Endpoint5_0Request = Parameters<RawClient["server.model"]["model.list"]>[0]
type Endpoint5_0Input = { readonly location?: Endpoint5_0Request["query"]["location"] }
const Endpoint5_0 = (raw: RawClient["server.model"]) => (input?: Endpoint5_0Input) =>
  raw["model.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

const adaptGroup5 = (raw: RawClient["server.model"]) => ({ list: Endpoint5_0(raw) })

type Endpoint6_0Request = Parameters<RawClient["server.provider"]["provider.list"]>[0]
type Endpoint6_0Input = { readonly location?: Endpoint6_0Request["query"]["location"] }
const Endpoint6_0 = (raw: RawClient["server.provider"]) => (input?: Endpoint6_0Input) =>
  raw["provider.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint6_1Request = Parameters<RawClient["server.provider"]["provider.get"]>[0]
type Endpoint6_1Input = {
  readonly providerID: Endpoint6_1Request["params"]["providerID"]
  readonly location?: Endpoint6_1Request["query"]["location"]
}
const Endpoint6_1 = (raw: RawClient["server.provider"]) => (input: Endpoint6_1Input) =>
  raw["provider.get"]({ params: { providerID: input["providerID"] }, query: { location: input["location"] } }).pipe(
    Effect.mapError(mapClientError),
  )

const adaptGroup6 = (raw: RawClient["server.provider"]) => ({ list: Endpoint6_0(raw), get: Endpoint6_1(raw) })

type Endpoint7_0Request = Parameters<RawClient["server.integration"]["integration.list"]>[0]
type Endpoint7_0Input = { readonly location?: Endpoint7_0Request["query"]["location"] }
const Endpoint7_0 = (raw: RawClient["server.integration"]) => (input?: Endpoint7_0Input) =>
  raw["integration.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint7_1Request = Parameters<RawClient["server.integration"]["integration.get"]>[0]
type Endpoint7_1Input = {
  readonly integrationID: Endpoint7_1Request["params"]["integrationID"]
  readonly location?: Endpoint7_1Request["query"]["location"]
}
const Endpoint7_1 = (raw: RawClient["server.integration"]) => (input: Endpoint7_1Input) =>
  raw["integration.get"]({
    params: { integrationID: input["integrationID"] },
    query: { location: input["location"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint7_2Request = Parameters<RawClient["server.integration"]["integration.connect.key"]>[0]
type Endpoint7_2Input = {
  readonly integrationID: Endpoint7_2Request["params"]["integrationID"]
  readonly location?: Endpoint7_2Request["query"]["location"]
  readonly key: Endpoint7_2Request["payload"]["key"]
  readonly label?: Endpoint7_2Request["payload"]["label"]
}
const Endpoint7_2 = (raw: RawClient["server.integration"]) => (input: Endpoint7_2Input) =>
  raw["integration.connect.key"]({
    params: { integrationID: input["integrationID"] },
    query: { location: input["location"] },
    payload: { key: input["key"], label: input["label"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint7_3Request = Parameters<RawClient["server.integration"]["integration.connect.oauth"]>[0]
type Endpoint7_3Input = {
  readonly integrationID: Endpoint7_3Request["params"]["integrationID"]
  readonly location?: Endpoint7_3Request["query"]["location"]
  readonly methodID: Endpoint7_3Request["payload"]["methodID"]
  readonly inputs: Endpoint7_3Request["payload"]["inputs"]
  readonly label?: Endpoint7_3Request["payload"]["label"]
}
const Endpoint7_3 = (raw: RawClient["server.integration"]) => (input: Endpoint7_3Input) =>
  raw["integration.connect.oauth"]({
    params: { integrationID: input["integrationID"] },
    query: { location: input["location"] },
    payload: { methodID: input["methodID"], inputs: input["inputs"], label: input["label"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint7_4Request = Parameters<RawClient["server.integration"]["integration.attempt.status"]>[0]
type Endpoint7_4Input = {
  readonly attemptID: Endpoint7_4Request["params"]["attemptID"]
  readonly location?: Endpoint7_4Request["query"]["location"]
}
const Endpoint7_4 = (raw: RawClient["server.integration"]) => (input: Endpoint7_4Input) =>
  raw["integration.attempt.status"]({
    params: { attemptID: input["attemptID"] },
    query: { location: input["location"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint7_5Request = Parameters<RawClient["server.integration"]["integration.attempt.complete"]>[0]
type Endpoint7_5Input = {
  readonly attemptID: Endpoint7_5Request["params"]["attemptID"]
  readonly location?: Endpoint7_5Request["query"]["location"]
  readonly code?: Endpoint7_5Request["payload"]["code"]
}
const Endpoint7_5 = (raw: RawClient["server.integration"]) => (input: Endpoint7_5Input) =>
  raw["integration.attempt.complete"]({
    params: { attemptID: input["attemptID"] },
    query: { location: input["location"] },
    payload: { code: input["code"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint7_6Request = Parameters<RawClient["server.integration"]["integration.attempt.cancel"]>[0]
type Endpoint7_6Input = {
  readonly attemptID: Endpoint7_6Request["params"]["attemptID"]
  readonly location?: Endpoint7_6Request["query"]["location"]
}
const Endpoint7_6 = (raw: RawClient["server.integration"]) => (input: Endpoint7_6Input) =>
  raw["integration.attempt.cancel"]({
    params: { attemptID: input["attemptID"] },
    query: { location: input["location"] },
  }).pipe(Effect.mapError(mapClientError))

const adaptGroup7 = (raw: RawClient["server.integration"]) => ({
  list: Endpoint7_0(raw),
  get: Endpoint7_1(raw),
  connectKey: Endpoint7_2(raw),
  connectOauth: Endpoint7_3(raw),
  attemptStatus: Endpoint7_4(raw),
  attemptComplete: Endpoint7_5(raw),
  attemptCancel: Endpoint7_6(raw),
})

type Endpoint8_0Request = Parameters<RawClient["server.credential"]["credential.update"]>[0]
type Endpoint8_0Input = {
  readonly credentialID: Endpoint8_0Request["params"]["credentialID"]
  readonly location?: Endpoint8_0Request["query"]["location"]
  readonly label: Endpoint8_0Request["payload"]["label"]
}
const Endpoint8_0 = (raw: RawClient["server.credential"]) => (input: Endpoint8_0Input) =>
  raw["credential.update"]({
    params: { credentialID: input["credentialID"] },
    query: { location: input["location"] },
    payload: { label: input["label"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint8_1Request = Parameters<RawClient["server.credential"]["credential.remove"]>[0]
type Endpoint8_1Input = {
  readonly credentialID: Endpoint8_1Request["params"]["credentialID"]
  readonly location?: Endpoint8_1Request["query"]["location"]
}
const Endpoint8_1 = (raw: RawClient["server.credential"]) => (input: Endpoint8_1Input) =>
  raw["credential.remove"]({
    params: { credentialID: input["credentialID"] },
    query: { location: input["location"] },
  }).pipe(Effect.mapError(mapClientError))

const adaptGroup8 = (raw: RawClient["server.credential"]) => ({ update: Endpoint8_0(raw), remove: Endpoint8_1(raw) })

type Endpoint9_0Request = Parameters<RawClient["server.permission"]["permission.request.list"]>[0]
type Endpoint9_0Input = { readonly location?: Endpoint9_0Request["query"]["location"] }
const Endpoint9_0 = (raw: RawClient["server.permission"]) => (input?: Endpoint9_0Input) =>
  raw["permission.request.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint9_1Request = Parameters<RawClient["server.permission"]["permission.saved.list"]>[0]
type Endpoint9_1Input = { readonly projectID?: Endpoint9_1Request["query"]["projectID"] }
const Endpoint9_1 = (raw: RawClient["server.permission"]) => (input?: Endpoint9_1Input) =>
  raw["permission.saved.list"]({ query: { projectID: input?.["projectID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint9_2Request = Parameters<RawClient["server.permission"]["permission.saved.remove"]>[0]
type Endpoint9_2Input = { readonly id: Endpoint9_2Request["params"]["id"] }
const Endpoint9_2 = (raw: RawClient["server.permission"]) => (input: Endpoint9_2Input) =>
  raw["permission.saved.remove"]({ params: { id: input["id"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint9_3Request = Parameters<RawClient["server.permission"]["session.permission.create"]>[0]
type Endpoint9_3Input = {
  readonly sessionID: Endpoint9_3Request["params"]["sessionID"]
  readonly id?: Endpoint9_3Request["payload"]["id"]
  readonly action: Endpoint9_3Request["payload"]["action"]
  readonly resources: Endpoint9_3Request["payload"]["resources"]
  readonly save?: Endpoint9_3Request["payload"]["save"]
  readonly metadata?: Endpoint9_3Request["payload"]["metadata"]
  readonly source?: Endpoint9_3Request["payload"]["source"]
  readonly agent?: Endpoint9_3Request["payload"]["agent"]
}
const Endpoint9_3 = (raw: RawClient["server.permission"]) => (input: Endpoint9_3Input) =>
  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),
  )

type Endpoint9_4Request = Parameters<RawClient["server.permission"]["session.permission.list"]>[0]
type Endpoint9_4Input = { readonly sessionID: Endpoint9_4Request["params"]["sessionID"] }
const Endpoint9_4 = (raw: RawClient["server.permission"]) => (input: Endpoint9_4Input) =>
  raw["session.permission.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint9_5Request = Parameters<RawClient["server.permission"]["session.permission.get"]>[0]
type Endpoint9_5Input = {
  readonly sessionID: Endpoint9_5Request["params"]["sessionID"]
  readonly requestID: Endpoint9_5Request["params"]["requestID"]
}
const Endpoint9_5 = (raw: RawClient["server.permission"]) => (input: Endpoint9_5Input) =>
  raw["session.permission.get"]({ params: { sessionID: input["sessionID"], requestID: input["requestID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint9_6Request = Parameters<RawClient["server.permission"]["session.permission.reply"]>[0]
type Endpoint9_6Input = {
  readonly sessionID: Endpoint9_6Request["params"]["sessionID"]
  readonly requestID: Endpoint9_6Request["params"]["requestID"]
  readonly reply: Endpoint9_6Request["payload"]["reply"]
  readonly message?: Endpoint9_6Request["payload"]["message"]
}
const Endpoint9_6 = (raw: RawClient["server.permission"]) => (input: Endpoint9_6Input) =>
  raw["session.permission.reply"]({
    params: { sessionID: input["sessionID"], requestID: input["requestID"] },
    payload: { reply: input["reply"], message: input["message"] },
  }).pipe(Effect.mapError(mapClientError))

const adaptGroup9 = (raw: RawClient["server.permission"]) => ({
  listRequests: Endpoint9_0(raw),
  listSaved: Endpoint9_1(raw),
  removeSaved: Endpoint9_2(raw),
  create: Endpoint9_3(raw),
  list: Endpoint9_4(raw),
  get: Endpoint9_5(raw),
  reply: Endpoint9_6(raw),
})

type Endpoint10_0Request = Parameters<RawClient["server.fs"]["fs.list"]>[0]
type Endpoint10_0Input = {
  readonly location?: Endpoint10_0Request["query"]["location"]
  readonly path?: Endpoint10_0Request["query"]["path"]
}
const Endpoint10_0 = (raw: RawClient["server.fs"]) => (input?: Endpoint10_0Input) =>
  raw["fs.list"]({ query: { location: input?.["location"], path: input?.["path"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint10_1Request = Parameters<RawClient["server.fs"]["fs.find"]>[0]
type Endpoint10_1Input = {
  readonly location?: Endpoint10_1Request["query"]["location"]
  readonly query: Endpoint10_1Request["query"]["query"]
  readonly type?: Endpoint10_1Request["query"]["type"]
  readonly limit?: Endpoint10_1Request["query"]["limit"]
}
const Endpoint10_1 = (raw: RawClient["server.fs"]) => (input: Endpoint10_1Input) =>
  raw["fs.find"]({
    query: { location: input["location"], query: input["query"], type: input["type"], limit: input["limit"] },
  }).pipe(Effect.mapError(mapClientError))

const adaptGroup10 = (raw: RawClient["server.fs"]) => ({ list: Endpoint10_0(raw), find: Endpoint10_1(raw) })

type Endpoint11_0Request = Parameters<RawClient["server.command"]["command.list"]>[0]
type Endpoint11_0Input = { readonly location?: Endpoint11_0Request["query"]["location"] }
const Endpoint11_0 = (raw: RawClient["server.command"]) => (input?: Endpoint11_0Input) =>
  raw["command.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

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

type Endpoint12_0Request = Parameters<RawClient["server.skill"]["skill.list"]>[0]
type Endpoint12_0Input = { readonly location?: Endpoint12_0Request["query"]["location"] }
const Endpoint12_0 = (raw: RawClient["server.skill"]) => (input?: Endpoint12_0Input) =>
  raw["skill.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

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

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

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

type Endpoint14_0Request = Parameters<RawClient["server.pty"]["pty.list"]>[0]
type Endpoint14_0Input = { readonly location?: Endpoint14_0Request["query"]["location"] }
const Endpoint14_0 = (raw: RawClient["server.pty"]) => (input?: Endpoint14_0Input) =>
  raw["pty.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint14_1Request = Parameters<RawClient["server.pty"]["pty.create"]>[0]
type Endpoint14_1Input = {
  readonly location?: Endpoint14_1Request["query"]["location"]
  readonly command?: Endpoint14_1Request["payload"]["command"]
  readonly args?: Endpoint14_1Request["payload"]["args"]
  readonly cwd?: Endpoint14_1Request["payload"]["cwd"]
  readonly title?: Endpoint14_1Request["payload"]["title"]
  readonly env?: Endpoint14_1Request["payload"]["env"]
}
const Endpoint14_1 = (raw: RawClient["server.pty"]) => (input?: Endpoint14_1Input) =>
  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))

type Endpoint14_2Request = Parameters<RawClient["server.pty"]["pty.get"]>[0]
type Endpoint14_2Input = {
  readonly ptyID: Endpoint14_2Request["params"]["ptyID"]
  readonly location?: Endpoint14_2Request["query"]["location"]
}
const Endpoint14_2 = (raw: RawClient["server.pty"]) => (input: Endpoint14_2Input) =>
  raw["pty.get"]({ params: { ptyID: input["ptyID"] }, query: { location: input["location"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint14_3Request = Parameters<RawClient["server.pty"]["pty.update"]>[0]
type Endpoint14_3Input = {
  readonly ptyID: Endpoint14_3Request["params"]["ptyID"]
  readonly location?: Endpoint14_3Request["query"]["location"]
  readonly title?: Endpoint14_3Request["payload"]["title"]
  readonly size?: Endpoint14_3Request["payload"]["size"]
}
const Endpoint14_3 = (raw: RawClient["server.pty"]) => (input: Endpoint14_3Input) =>
  raw["pty.update"]({
    params: { ptyID: input["ptyID"] },
    query: { location: input["location"] },
    payload: { title: input["title"], size: input["size"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint14_4Request = Parameters<RawClient["server.pty"]["pty.remove"]>[0]
type Endpoint14_4Input = {
  readonly ptyID: Endpoint14_4Request["params"]["ptyID"]
  readonly location?: Endpoint14_4Request["query"]["location"]
}
const Endpoint14_4 = (raw: RawClient["server.pty"]) => (input: Endpoint14_4Input) =>
  raw["pty.remove"]({ params: { ptyID: input["ptyID"] }, query: { location: input["location"] } }).pipe(
    Effect.mapError(mapClientError),
  )

const adaptGroup14 = (raw: RawClient["server.pty"]) => ({
  list: Endpoint14_0(raw),
  create: Endpoint14_1(raw),
  get: Endpoint14_2(raw),
  update: Endpoint14_3(raw),
  remove: Endpoint14_4(raw),
})

type Endpoint15_0Request = Parameters<RawClient["server.question"]["question.request.list"]>[0]
type Endpoint15_0Input = { readonly location?: Endpoint15_0Request["query"]["location"] }
const Endpoint15_0 = (raw: RawClient["server.question"]) => (input?: Endpoint15_0Input) =>
  raw["question.request.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint15_1Request = Parameters<RawClient["server.question"]["session.question.list"]>[0]
type Endpoint15_1Input = { readonly sessionID: Endpoint15_1Request["params"]["sessionID"] }
const Endpoint15_1 = (raw: RawClient["server.question"]) => (input: Endpoint15_1Input) =>
  raw["session.question.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint15_2Request = Parameters<RawClient["server.question"]["session.question.reply"]>[0]
type Endpoint15_2Input = {
  readonly sessionID: Endpoint15_2Request["params"]["sessionID"]
  readonly requestID: Endpoint15_2Request["params"]["requestID"]
  readonly answers: Endpoint15_2Request["payload"]["answers"]
}
const Endpoint15_2 = (raw: RawClient["server.question"]) => (input: Endpoint15_2Input) =>
  raw["session.question.reply"]({
    params: { sessionID: input["sessionID"], requestID: input["requestID"] },
    payload: { answers: input["answers"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint15_3Request = Parameters<RawClient["server.question"]["session.question.reject"]>[0]
type Endpoint15_3Input = {
  readonly sessionID: Endpoint15_3Request["params"]["sessionID"]
  readonly requestID: Endpoint15_3Request["params"]["requestID"]
}
const Endpoint15_3 = (raw: RawClient["server.question"]) => (input: Endpoint15_3Input) =>
  raw["session.question.reject"]({ params: { sessionID: input["sessionID"], requestID: input["requestID"] } }).pipe(
    Effect.mapError(mapClientError),
  )

const adaptGroup15 = (raw: RawClient["server.question"]) => ({
  listRequests: Endpoint15_0(raw),
  list: Endpoint15_1(raw),
  reply: Endpoint15_2(raw),
  reject: Endpoint15_3(raw),
})

type Endpoint16_0Request = Parameters<RawClient["server.reference"]["reference.list"]>[0]
type Endpoint16_0Input = { readonly location?: Endpoint16_0Request["query"]["location"] }
const Endpoint16_0 = (raw: RawClient["server.reference"]) => (input?: Endpoint16_0Input) =>
  raw["reference.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))

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

type Endpoint17_0Request = Parameters<RawClient["server.projectCopy"]["projectCopy.create"]>[0]
type Endpoint17_0Input = {
  readonly projectID: Endpoint17_0Request["params"]["projectID"]
  readonly location?: Endpoint17_0Request["query"]["location"]
  readonly strategy: Endpoint17_0Request["payload"]["strategy"]
  readonly directory: Endpoint17_0Request["payload"]["directory"]
  readonly name?: Endpoint17_0Request["payload"]["name"]
}
const Endpoint17_0 = (raw: RawClient["server.projectCopy"]) => (input: Endpoint17_0Input) =>
  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))

type Endpoint17_1Request = Parameters<RawClient["server.projectCopy"]["projectCopy.remove"]>[0]
type Endpoint17_1Input = {
  readonly projectID: Endpoint17_1Request["params"]["projectID"]
  readonly location?: Endpoint17_1Request["query"]["location"]
  readonly directory: Endpoint17_1Request["payload"]["directory"]
  readonly force: Endpoint17_1Request["payload"]["force"]
}
const Endpoint17_1 = (raw: RawClient["server.projectCopy"]) => (input: Endpoint17_1Input) =>
  raw["projectCopy.remove"]({
    params: { projectID: input["projectID"] },
    query: { location: input["location"] },
    payload: { directory: input["directory"], force: input["force"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint17_2Request = Parameters<RawClient["server.projectCopy"]["projectCopy.refresh"]>[0]
type Endpoint17_2Input = {
  readonly projectID: Endpoint17_2Request["params"]["projectID"]
  readonly location?: Endpoint17_2Request["query"]["location"]
}
const Endpoint17_2 = (raw: RawClient["server.projectCopy"]) => (input: Endpoint17_2Input) =>
  raw["projectCopy.refresh"]({
    params: { projectID: input["projectID"] },
    query: { location: input["location"] },
  }).pipe(Effect.mapError(mapClientError))

const adaptGroup17 = (raw: RawClient["server.projectCopy"]) => ({
  create: Endpoint17_0(raw),
  remove: Endpoint17_1(raw),
  refresh: Endpoint17_2(raw),
})

const adaptClient = (raw: RawClient) => ({
  health: adaptGroup0(raw["server.health"]),
  location: adaptGroup1(raw["server.location"]),
  agents: adaptGroup2(raw["server.agent"]),
  sessions: adaptGroup3(raw["server.session"]),
  messages: adaptGroup4(raw["server.message"]),
  models: adaptGroup5(raw["server.model"]),
  providers: adaptGroup6(raw["server.provider"]),
  integrations: adaptGroup7(raw["server.integration"]),
  credentials: adaptGroup8(raw["server.credential"]),
  permissions: adaptGroup9(raw["server.permission"]),
  files: adaptGroup10(raw["server.fs"]),
  commands: adaptGroup11(raw["server.command"]),
  skills: adaptGroup12(raw["server.skill"]),
  events: adaptGroup13(raw["server.event"]),
  ptys: adaptGroup14(raw["server.pty"]),
  questions: adaptGroup15(raw["server.question"]),
  references: adaptGroup16(raw["server.reference"]),
  projectCopies: adaptGroup17(raw["server.projectCopy"]),
})

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