// Generated by @novaclaw/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 roots?: Endpoint3_0Request["query"]["roots"]
  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 under?: Endpoint3_0Request["query"]["under"]
  readonly cursor?: Endpoint3_0Request["query"]["cursor"]
}
const Endpoint3_0 = (raw: RawClient["server.session"]) => (input?: Endpoint3_0Input) =>
  raw["session.list"]({
    query: {
      workspace: input?.["workspace"],
      roots: input?.["roots"],
      limit: input?.["limit"],
      order: input?.["order"],
      search: input?.["search"],
      directory: input?.["directory"],
      under: input?.["under"],
      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 parentID?: Endpoint3_1Request["payload"]["parentID"]
  readonly agent?: Endpoint3_1Request["payload"]["agent"]
  readonly model?: Endpoint3_1Request["payload"]["model"]
  readonly systemPromptOverride?: Endpoint3_1Request["payload"]["systemPromptOverride"]
  readonly type?: Endpoint3_1Request["payload"]["type"]
  readonly priority?: Endpoint3_1Request["payload"]["priority"]
  readonly permissionMode?: Endpoint3_1Request["payload"]["permissionMode"]
  readonly location?: Endpoint3_1Request["payload"]["location"]
  readonly title?: Endpoint3_1Request["payload"]["title"]
  readonly permission?: Endpoint3_1Request["payload"]["permission"]
  readonly strict?: Endpoint3_1Request["payload"]["strict"]
  readonly introspection?: Endpoint3_1Request["payload"]["introspection"]
  readonly quality?: Endpoint3_1Request["payload"]["quality"]
  readonly affective?: Endpoint3_1Request["payload"]["affective"]
}
const Endpoint3_1 = (raw: RawClient["server.session"]) => (input?: Endpoint3_1Input) =>
  raw["session.create"]({
    payload: {
      id: input?.["id"],
      parentID: input?.["parentID"],
      agent: input?.["agent"],
      model: input?.["model"],
      systemPromptOverride: input?.["systemPromptOverride"],
      type: input?.["type"],
      priority: input?.["priority"],
      permissionMode: input?.["permissionMode"],
      location: input?.["location"],
      title: input?.["title"],
      permission: input?.["permission"],
      strict: input?.["strict"],
      introspection: input?.["introspection"],
      quality: input?.["quality"],
      affective: input?.["affective"],
    },
  }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

type Endpoint3_2Request = Parameters<RawClient["server.session"]["session.tags.set"]>[0]
type Endpoint3_2Input = {
  readonly sessionID: Endpoint3_2Request["params"]["sessionID"]
  readonly tags: Endpoint3_2Request["payload"]["tags"]
}
const Endpoint3_2 = (raw: RawClient["server.session"]) => (input: Endpoint3_2Input) =>
  raw["session.tags.set"]({ params: { sessionID: input["sessionID"] }, payload: { tags: input["tags"] } }).pipe(
    Effect.mapError(mapClientError),
  )

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

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

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

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

type Endpoint3_7Request = Parameters<RawClient["server.session"]["session.update"]>[0]
type Endpoint3_7Input = {
  readonly sessionID: Endpoint3_7Request["params"]["sessionID"]
  readonly title?: Endpoint3_7Request["payload"]["title"]
  readonly metadata?: Endpoint3_7Request["payload"]["metadata"]
  readonly archived?: Endpoint3_7Request["payload"]["archived"]
}
const Endpoint3_7 = (raw: RawClient["server.session"]) => (input: Endpoint3_7Input) =>
  raw["session.update"]({
    params: { sessionID: input["sessionID"] },
    payload: { title: input["title"], metadata: input["metadata"], archived: input["archived"] },
  }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

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

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

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

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

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

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

type Endpoint3_14Request = Parameters<RawClient["server.session"]["session.switchMode"]>[0]
type Endpoint3_14Input = {
  readonly sessionID: Endpoint3_14Request["params"]["sessionID"]
  readonly permissionMode: Endpoint3_14Request["payload"]["permissionMode"]
}
const Endpoint3_14 = (raw: RawClient["server.session"]) => (input: Endpoint3_14Input) =>
  raw["session.switchMode"]({
    params: { sessionID: input["sessionID"] },
    payload: { permissionMode: input["permissionMode"] },
  }).pipe(Effect.mapError(mapClientError))

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

type Endpoint3_16Request = Parameters<RawClient["server.session"]["session.switchFeature"]>[0]
type Endpoint3_16Input = {
  readonly sessionID: Endpoint3_16Request["params"]["sessionID"]
  readonly feature: Endpoint3_16Request["payload"]["feature"]
  readonly enabled: Endpoint3_16Request["payload"]["enabled"]
}
const Endpoint3_16 = (raw: RawClient["server.session"]) => (input: Endpoint3_16Input) =>
  raw["session.switchFeature"]({
    params: { sessionID: input["sessionID"] },
    payload: { feature: input["feature"], enabled: input["enabled"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint3_17Request = Parameters<RawClient["server.session"]["session.switchType"]>[0]
type Endpoint3_17Input = {
  readonly sessionID: Endpoint3_17Request["params"]["sessionID"]
  readonly type: Endpoint3_17Request["payload"]["type"]
}
const Endpoint3_17 = (raw: RawClient["server.session"]) => (input: Endpoint3_17Input) =>
  raw["session.switchType"]({ params: { sessionID: input["sessionID"] }, payload: { type: input["type"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint3_18Request = Parameters<RawClient["server.session"]["session.switchPromptOverride"]>[0]
type Endpoint3_18Input = {
  readonly sessionID: Endpoint3_18Request["params"]["sessionID"]
  readonly override: Endpoint3_18Request["payload"]["override"]
}
const Endpoint3_18 = (raw: RawClient["server.session"]) => (input: Endpoint3_18Input) =>
  raw["session.switchPromptOverride"]({
    params: { sessionID: input["sessionID"] },
    payload: { override: input["override"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint3_19Request = Parameters<RawClient["server.session"]["session.shell"]>[0]
type Endpoint3_19Input = {
  readonly sessionID: Endpoint3_19Request["params"]["sessionID"]
  readonly command: Endpoint3_19Request["payload"]["command"]
}
const Endpoint3_19 = (raw: RawClient["server.session"]) => (input: Endpoint3_19Input) =>
  raw["session.shell"]({ params: { sessionID: input["sessionID"] }, payload: { command: input["command"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint3_20Request = Parameters<RawClient["server.session"]["session.command"]>[0]
type Endpoint3_20Input = {
  readonly sessionID: Endpoint3_20Request["params"]["sessionID"]
  readonly command: Endpoint3_20Request["payload"]["command"]
  readonly arguments: Endpoint3_20Request["payload"]["arguments"]
  readonly agent?: Endpoint3_20Request["payload"]["agent"]
  readonly model?: Endpoint3_20Request["payload"]["model"]
  readonly variant?: Endpoint3_20Request["payload"]["variant"]
  readonly messageID?: Endpoint3_20Request["payload"]["messageID"]
}
const Endpoint3_20 = (raw: RawClient["server.session"]) => (input: Endpoint3_20Input) =>
  raw["session.command"]({
    params: { sessionID: input["sessionID"] },
    payload: {
      command: input["command"],
      arguments: input["arguments"],
      agent: input["agent"],
      model: input["model"],
      variant: input["variant"],
      messageID: input["messageID"],
    },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint3_21Request = Parameters<RawClient["server.session"]["session.prompt"]>[0]
type Endpoint3_21Input = {
  readonly sessionID: Endpoint3_21Request["params"]["sessionID"]
  readonly id?: Endpoint3_21Request["payload"]["id"]
  readonly prompt: Endpoint3_21Request["payload"]["prompt"]
  readonly delivery?: Endpoint3_21Request["payload"]["delivery"]
  readonly resume?: Endpoint3_21Request["payload"]["resume"]
}
const Endpoint3_21 = (raw: RawClient["server.session"]) => (input: Endpoint3_21Input) =>
  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_22Request = Parameters<RawClient["server.session"]["session.compact"]>[0]
type Endpoint3_22Input = { readonly sessionID: Endpoint3_22Request["params"]["sessionID"] }
const Endpoint3_22 = (raw: RawClient["server.session"]) => (input: Endpoint3_22Input) =>
  raw["session.compact"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

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

type Endpoint3_24Request = Parameters<RawClient["server.session"]["session.revert.stage"]>[0]
type Endpoint3_24Input = {
  readonly sessionID: Endpoint3_24Request["params"]["sessionID"]
  readonly messageID: Endpoint3_24Request["payload"]["messageID"]
  readonly files?: Endpoint3_24Request["payload"]["files"]
}
const Endpoint3_24 = (raw: RawClient["server.session"]) => (input: Endpoint3_24Input) =>
  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_25Request = Parameters<RawClient["server.session"]["session.revert.clear"]>[0]
type Endpoint3_25Input = { readonly sessionID: Endpoint3_25Request["params"]["sessionID"] }
const Endpoint3_25 = (raw: RawClient["server.session"]) => (input: Endpoint3_25Input) =>
  raw["session.revert.clear"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

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

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

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

type Endpoint3_29Request = Parameters<RawClient["server.session"]["session.events"]>[0]
type Endpoint3_29Input = {
  readonly sessionID: Endpoint3_29Request["params"]["sessionID"]
  readonly after?: Endpoint3_29Request["query"]["after"]
}
const Endpoint3_29 = (raw: RawClient["server.session"]) => (input: Endpoint3_29Input) =>
  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_30Request = Parameters<RawClient["server.session"]["session.interrupt"]>[0]
type Endpoint3_30Input = { readonly sessionID: Endpoint3_30Request["params"]["sessionID"] }
const Endpoint3_30 = (raw: RawClient["server.session"]) => (input: Endpoint3_30Input) =>
  raw["session.interrupt"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint3_31Request = Parameters<RawClient["server.session"]["session.message"]>[0]
type Endpoint3_31Input = {
  readonly sessionID: Endpoint3_31Request["params"]["sessionID"]
  readonly messageID: Endpoint3_31Request["params"]["messageID"]
}
const Endpoint3_31 = (raw: RawClient["server.session"]) => (input: Endpoint3_31Input) =>
  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),
  set: Endpoint3_2(raw),
  all: Endpoint3_3(raw),
  active: Endpoint3_4(raw),
  get: Endpoint3_5(raw),
  children: Endpoint3_6(raw),
  update: Endpoint3_7(raw),
  remove: Endpoint3_8(raw),
  fork: Endpoint3_9(raw),
  todo: Endpoint3_10(raw),
  switchAgent: Endpoint3_11(raw),
  switchModel: Endpoint3_12(raw),
  switchResponder: Endpoint3_13(raw),
  switchMode: Endpoint3_14(raw),
  switchStrict: Endpoint3_15(raw),
  switchFeature: Endpoint3_16(raw),
  switchType: Endpoint3_17(raw),
  switchPromptOverride: Endpoint3_18(raw),
  shell: Endpoint3_19(raw),
  command: Endpoint3_20(raw),
  prompt: Endpoint3_21(raw),
  compact: Endpoint3_22(raw),
  wait: Endpoint3_23(raw),
  stage: Endpoint3_24(raw),
  clear: Endpoint3_25(raw),
  commit: Endpoint3_26(raw),
  context: Endpoint3_27(raw),
  history: Endpoint3_28(raw),
  events: Endpoint3_29(raw),
  interrupt: Endpoint3_30(raw),
  message: Endpoint3_31(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),
  )

type Endpoint6_2Request = Parameters<RawClient["server.provider"]["provider.remove"]>[0]
type Endpoint6_2Input = {
  readonly providerID: Endpoint6_2Request["params"]["providerID"]
  readonly location?: Endpoint6_2Request["query"]["location"]
}
const Endpoint6_2 = (raw: RawClient["server.provider"]) => (input: Endpoint6_2Input) =>
  raw["provider.remove"]({ 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),
  remove: Endpoint6_2(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) })

const Endpoint9_0 = (raw: RawClient["server.messenger"]) => () =>
  raw["messenger.driver.list"]({}).pipe(Effect.mapError(mapClientError))

const Endpoint9_1 = (raw: RawClient["server.messenger"]) => () =>
  raw["messenger.account.list"]({}).pipe(Effect.mapError(mapClientError))

type Endpoint9_2Request = Parameters<RawClient["server.messenger"]["messenger.account.create"]>[0]
type Endpoint9_2Input = {
  readonly driverID: Endpoint9_2Request["payload"]["driverID"]
  readonly label: Endpoint9_2Request["payload"]["label"]
  readonly enabled: Endpoint9_2Request["payload"]["enabled"]
  readonly settings: Endpoint9_2Request["payload"]["settings"]
  readonly secret?: Endpoint9_2Request["payload"]["secret"]
}
const Endpoint9_2 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_2Input) =>
  raw["messenger.account.create"]({
    payload: {
      driverID: input["driverID"],
      label: input["label"],
      enabled: input["enabled"],
      settings: input["settings"],
      secret: input["secret"],
    },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint9_3Request = Parameters<RawClient["server.messenger"]["messenger.account.update"]>[0]
type Endpoint9_3Input = {
  readonly accountID: Endpoint9_3Request["params"]["accountID"]
  readonly label?: Endpoint9_3Request["payload"]["label"]
  readonly enabled?: Endpoint9_3Request["payload"]["enabled"]
  readonly settings?: Endpoint9_3Request["payload"]["settings"]
  readonly secret?: Endpoint9_3Request["payload"]["secret"]
}
const Endpoint9_3 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_3Input) =>
  raw["messenger.account.update"]({
    params: { accountID: input["accountID"] },
    payload: { label: input["label"], enabled: input["enabled"], settings: input["settings"], secret: input["secret"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint9_4Request = Parameters<RawClient["server.messenger"]["messenger.account.remove"]>[0]
type Endpoint9_4Input = { readonly accountID: Endpoint9_4Request["params"]["accountID"] }
const Endpoint9_4 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_4Input) =>
  raw["messenger.account.remove"]({ params: { accountID: input["accountID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint9_5Request = Parameters<RawClient["server.messenger"]["messenger.account.pair"]>[0]
type Endpoint9_5Input = {
  readonly accountID: Endpoint9_5Request["params"]["accountID"]
  readonly trust: Endpoint9_5Request["payload"]["trust"]
}
const Endpoint9_5 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_5Input) =>
  raw["messenger.account.pair"]({ params: { accountID: input["accountID"] }, payload: { trust: input["trust"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint9_6Request = Parameters<RawClient["server.messenger"]["messenger.account.chats"]>[0]
type Endpoint9_6Input = { readonly accountID: Endpoint9_6Request["params"]["accountID"] }
const Endpoint9_6 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_6Input) =>
  raw["messenger.account.chats"]({ params: { accountID: input["accountID"] } }).pipe(Effect.mapError(mapClientError))

const Endpoint9_7 = (raw: RawClient["server.messenger"]) => () =>
  raw["messenger.binding.list"]({}).pipe(Effect.mapError(mapClientError))

type Endpoint9_8Request = Parameters<RawClient["server.messenger"]["messenger.binding.create"]>[0]
type Endpoint9_8Input = {
  readonly accountID: Endpoint9_8Request["payload"]["accountID"]
  readonly chatID: Endpoint9_8Request["payload"]["chatID"]
  readonly sessionID: Endpoint9_8Request["payload"]["sessionID"]
  readonly trust: Endpoint9_8Request["payload"]["trust"]
  readonly steal?: Endpoint9_8Request["payload"]["steal"]
}
const Endpoint9_8 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_8Input) =>
  raw["messenger.binding.create"]({
    payload: {
      accountID: input["accountID"],
      chatID: input["chatID"],
      sessionID: input["sessionID"],
      trust: input["trust"],
      steal: input["steal"],
    },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint9_9Request = Parameters<RawClient["server.messenger"]["messenger.binding.remove"]>[0]
type Endpoint9_9Input = { readonly bindingID: Endpoint9_9Request["params"]["bindingID"] }
const Endpoint9_9 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_9Input) =>
  raw["messenger.binding.remove"]({ params: { bindingID: input["bindingID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint9_10Request = Parameters<RawClient["server.messenger"]["messenger.login.begin"]>[0]
type Endpoint9_10Input = {
  readonly accountID: Endpoint9_10Request["params"]["accountID"]
  readonly inputs: Endpoint9_10Request["payload"]["inputs"]
}
const Endpoint9_10 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_10Input) =>
  raw["messenger.login.begin"]({
    params: { accountID: input["accountID"] },
    payload: { inputs: input["inputs"] },
  }).pipe(Effect.mapError(mapClientError))

type Endpoint9_11Request = Parameters<RawClient["server.messenger"]["messenger.login.status"]>[0]
type Endpoint9_11Input = { readonly attemptID: Endpoint9_11Request["params"]["attemptID"] }
const Endpoint9_11 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_11Input) =>
  raw["messenger.login.status"]({ params: { attemptID: input["attemptID"] } }).pipe(Effect.mapError(mapClientError))

type Endpoint9_12Request = Parameters<RawClient["server.messenger"]["messenger.login.complete"]>[0]
type Endpoint9_12Input = {
  readonly attemptID: Endpoint9_12Request["params"]["attemptID"]
  readonly code: Endpoint9_12Request["payload"]["code"]
}
const Endpoint9_12 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_12Input) =>
  raw["messenger.login.complete"]({ params: { attemptID: input["attemptID"] }, payload: { code: input["code"] } }).pipe(
    Effect.mapError(mapClientError),
  )

type Endpoint9_13Request = Parameters<RawClient["server.messenger"]["messenger.login.cancel"]>[0]
type Endpoint9_13Input = { readonly attemptID: Endpoint9_13Request["params"]["attemptID"] }
const Endpoint9_13 = (raw: RawClient["server.messenger"]) => (input: Endpoint9_13Input) =>
  raw["messenger.login.cancel"]({ params: { attemptID: input["attemptID"] } }).pipe(Effect.mapError(mapClientError))

const adaptGroup9 = (raw: RawClient["server.messenger"]) => ({
  listDrivers: Endpoint9_0(raw),
  listAccounts: Endpoint9_1(raw),
  createAccount: Endpoint9_2(raw),
  updateAccount: Endpoint9_3(raw),
  removeAccount: Endpoint9_4(raw),
  mintPairing: Endpoint9_5(raw),
  listAccountChats: Endpoint9_6(raw),
  listBindings: Endpoint9_7(raw),
  createBinding: Endpoint9_8(raw),
  removeBinding: Endpoint9_9(raw),
  loginBegin: Endpoint9_10(raw),
  loginStatus: Endpoint9_11(raw),
  loginComplete: Endpoint9_12(raw),
  loginCancel: Endpoint9_13(raw),
})

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

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

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

type Endpoint10_3Request = Parameters<RawClient["server.permission"]["session.permission.create"]>[0]
type Endpoint10_3Input = {
  readonly sessionID: Endpoint10_3Request["params"]["sessionID"]
  readonly id?: Endpoint10_3Request["payload"]["id"]
  readonly action: Endpoint10_3Request["payload"]["action"]
  readonly resources: Endpoint10_3Request["payload"]["resources"]
  readonly save?: Endpoint10_3Request["payload"]["save"]
  readonly metadata?: Endpoint10_3Request["payload"]["metadata"]
  readonly source?: Endpoint10_3Request["payload"]["source"]
  readonly agent?: Endpoint10_3Request["payload"]["agent"]
}
const Endpoint10_3 = (raw: RawClient["server.permission"]) => (input: Endpoint10_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 Endpoint10_4Request = Parameters<RawClient["server.permission"]["session.permission.list"]>[0]
type Endpoint10_4Input = { readonly sessionID: Endpoint10_4Request["params"]["sessionID"] }
const Endpoint10_4 = (raw: RawClient["server.permission"]) => (input: Endpoint10_4Input) =>
  raw["session.permission.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
    Effect.mapError(mapClientError),
    Effect.map((value) => value.data),
  )

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

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

const adaptGroup10 = (raw: RawClient["server.permission"]) => ({
  listRequests: Endpoint10_0(raw),
  listSaved: Endpoint10_1(raw),
  removeSaved: Endpoint10_2(raw),
  create: Endpoint10_3(raw),
  list: Endpoint10_4(raw),
  get: Endpoint10_5(raw),
  reply: Endpoint10_6(raw),
})

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

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

const adaptGroup11 = (raw: RawClient["server.fs"]) => ({ list: Endpoint11_0(raw), find: Endpoint11_1(raw) })

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

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

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

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

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

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

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

type Endpoint15_1Request = Parameters<RawClient["server.pty"]["pty.create"]>[0]
type Endpoint15_1Input = {
  readonly location?: Endpoint15_1Request["query"]["location"]
  readonly command?: Endpoint15_1Request["payload"]["command"]
  readonly args?: Endpoint15_1Request["payload"]["args"]
  readonly cwd?: Endpoint15_1Request["payload"]["cwd"]
  readonly title?: Endpoint15_1Request["payload"]["title"]
  readonly env?: Endpoint15_1Request["payload"]["env"]
}
const Endpoint15_1 = (raw: RawClient["server.pty"]) => (input?: Endpoint15_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 Endpoint15_2Request = Parameters<RawClient["server.pty"]["pty.get"]>[0]
type Endpoint15_2Input = {
  readonly ptyID: Endpoint15_2Request["params"]["ptyID"]
  readonly location?: Endpoint15_2Request["query"]["location"]
}
const Endpoint15_2 = (raw: RawClient["server.pty"]) => (input: Endpoint15_2Input) =>
  raw["pty.get"]({ params: { ptyID: input["ptyID"] }, query: { location: input["location"] } }).pipe(
    Effect.mapError(mapClientError),
  )

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

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

const adaptGroup15 = (raw: RawClient["server.pty"]) => ({
  list: Endpoint15_0(raw),
  create: Endpoint15_1(raw),
  get: Endpoint15_2(raw),
  update: Endpoint15_3(raw),
  remove: Endpoint15_4(raw),
})

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

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

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

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

const adaptGroup16 = (raw: RawClient["server.question"]) => ({
  listRequests: Endpoint16_0(raw),
  list: Endpoint16_1(raw),
  reply: Endpoint16_2(raw),
  reject: Endpoint16_3(raw),
})

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

const adaptGroup17 = (raw: RawClient["server.reference"]) => ({ list: Endpoint17_0(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"]),
  messenger: adaptGroup9(raw["server.messenger"]),
  permissions: adaptGroup10(raw["server.permission"]),
  files: adaptGroup11(raw["server.fs"]),
  commands: adaptGroup12(raw["server.command"]),
  skills: adaptGroup13(raw["server.skill"]),
  events: adaptGroup14(raw["server.event"]),
  ptys: adaptGroup15(raw["server.pty"]),
  questions: adaptGroup16(raw["server.question"]),
  references: adaptGroup17(raw["server.reference"]),
})

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