// This file is auto-generated by @hey-api/openapi-ts

import { type DefaultError, type InfiniteData, infiniteQueryOptions, type MutationOptions, queryOptions } from '@tanstack/solid-query';

import { client } from '../client.gen';
import { type Options, serenCloudApprovalInboxDecide, serenCloudApprovalInboxList, serenCloudCompleteDeploymentBundleUpload, serenCloudCreateDeploymentBundle, serenCloudCreateEnvironment, serenCloudCreateEvalSet, serenCloudDelete, serenCloudDeleteEnvironment, serenCloudDeploy, serenCloudDeploymentAudit, serenCloudDeploymentPendingApprovals, serenCloudDeploymentRun, serenCloudDeploymentRunArtifacts, serenCloudDeploymentRunCancel, serenCloudDeploymentRunEvals, serenCloudDeploymentRunEvents, serenCloudDeploymentRunPendingApprovals, serenCloudDeploymentRuns, serenCloudDeploymentRunStreamClose, serenCloudEvalCases, serenCloudEvalRunResults, serenCloudEvalRuns, serenCloudEvalSets, serenCloudGetAuditEntry, serenCloudGetDeployment, serenCloudGetDeploymentBundle, serenCloudGetDeploymentBundleDownload, serenCloudGetDeploymentEvalDrift, serenCloudGetDeploymentSpend, serenCloudGetEnvironment, serenCloudGetEvalCase, serenCloudGetEvalCaseResult, serenCloudGetEvalRun, serenCloudGetEvalSet, serenCloudListAuditEntries, serenCloudListDeployments, serenCloudListEnvironments, serenCloudPendingApprovals, serenCloudPromoteRunToEvalCase, serenCloudRun, serenCloudRunArtifacts, serenCloudRunAudit, serenCloudRunCancel, serenCloudRunCompare, serenCloudRunDetail, serenCloudRunEvals, serenCloudRunEvalSet, serenCloudRunEvents, serenCloudRunPendingApprovals, serenCloudRuns, serenCloudRunStreamClose, serenCloudStart, serenCloudStop, serenCloudUpdateConfig, serenCloudUpdateEnvironment, serenCloudUpdateEvalSet, serenCloudVerifyAudit } from '../sdk.gen';
import type { SerenCloudApprovalInboxDecideData, SerenCloudApprovalInboxDecideResponse, SerenCloudApprovalInboxListData, SerenCloudApprovalInboxListResponse, SerenCloudCompleteDeploymentBundleUploadData, SerenCloudCompleteDeploymentBundleUploadResponse, SerenCloudCreateDeploymentBundleData, SerenCloudCreateDeploymentBundleResponse, SerenCloudCreateEnvironmentData, SerenCloudCreateEnvironmentResponse, SerenCloudCreateEvalSetData, SerenCloudCreateEvalSetResponse, SerenCloudDeleteData, SerenCloudDeleteEnvironmentData, SerenCloudDeleteEnvironmentResponse, SerenCloudDeleteResponse, SerenCloudDeployData, SerenCloudDeploymentAuditData, SerenCloudDeploymentAuditResponse, SerenCloudDeploymentPendingApprovalsData, SerenCloudDeploymentPendingApprovalsResponse, SerenCloudDeploymentRunArtifactsData, SerenCloudDeploymentRunArtifactsResponse, SerenCloudDeploymentRunCancelData, SerenCloudDeploymentRunCancelResponse, SerenCloudDeploymentRunData, SerenCloudDeploymentRunEvalsData, SerenCloudDeploymentRunEvalsResponse, SerenCloudDeploymentRunEventsData, SerenCloudDeploymentRunEventsResponse, SerenCloudDeploymentRunPendingApprovalsData, SerenCloudDeploymentRunPendingApprovalsResponse, SerenCloudDeploymentRunResponse, SerenCloudDeploymentRunsData, SerenCloudDeploymentRunsResponse, SerenCloudDeploymentRunStreamCloseData, SerenCloudDeploymentRunStreamCloseResponse, SerenCloudDeployResponse, SerenCloudEvalCasesData, SerenCloudEvalCasesResponse, SerenCloudEvalRunResultsData, SerenCloudEvalRunResultsResponse, SerenCloudEvalRunsData, SerenCloudEvalRunsResponse, SerenCloudEvalSetsData, SerenCloudEvalSetsResponse, SerenCloudGetAuditEntryData, SerenCloudGetAuditEntryResponse, SerenCloudGetDeploymentBundleData, SerenCloudGetDeploymentBundleDownloadData, SerenCloudGetDeploymentBundleDownloadResponse, SerenCloudGetDeploymentBundleResponse, SerenCloudGetDeploymentData, SerenCloudGetDeploymentEvalDriftData, SerenCloudGetDeploymentEvalDriftResponse, SerenCloudGetDeploymentResponse, SerenCloudGetDeploymentSpendData, SerenCloudGetDeploymentSpendResponse, SerenCloudGetEnvironmentData, SerenCloudGetEnvironmentResponse, SerenCloudGetEvalCaseData, SerenCloudGetEvalCaseResponse, SerenCloudGetEvalCaseResultData, SerenCloudGetEvalCaseResultResponse, SerenCloudGetEvalRunData, SerenCloudGetEvalRunResponse, SerenCloudGetEvalSetData, SerenCloudGetEvalSetResponse, SerenCloudListAuditEntriesData, SerenCloudListAuditEntriesResponse, SerenCloudListDeploymentsData, SerenCloudListDeploymentsResponse, SerenCloudListEnvironmentsData, SerenCloudListEnvironmentsResponse, SerenCloudPendingApprovalsData, SerenCloudPendingApprovalsResponse, SerenCloudPromoteRunToEvalCaseData, SerenCloudPromoteRunToEvalCaseResponse, SerenCloudRunArtifactsData, SerenCloudRunArtifactsResponse, SerenCloudRunAuditData, SerenCloudRunAuditResponse, SerenCloudRunCancelData, SerenCloudRunCancelResponse, SerenCloudRunCompareData, SerenCloudRunCompareResponse, SerenCloudRunData, SerenCloudRunDetailData, SerenCloudRunDetailResponse, SerenCloudRunEvalsData, SerenCloudRunEvalSetData, SerenCloudRunEvalSetResponse, SerenCloudRunEvalsResponse, SerenCloudRunEventsData, SerenCloudRunEventsResponse, SerenCloudRunPendingApprovalsData, SerenCloudRunPendingApprovalsResponse, SerenCloudRunResponse, SerenCloudRunsData, SerenCloudRunsResponse, SerenCloudRunStreamCloseData, SerenCloudRunStreamCloseResponse, SerenCloudStartData, SerenCloudStartResponse, SerenCloudStopData, SerenCloudStopResponse, SerenCloudUpdateConfigData, SerenCloudUpdateConfigResponse, SerenCloudUpdateEnvironmentData, SerenCloudUpdateEnvironmentResponse, SerenCloudUpdateEvalSetData, SerenCloudUpdateEvalSetResponse, SerenCloudVerifyAuditData, SerenCloudVerifyAuditResponse } from '../types.gen';

export type QueryKey<TOptions extends Options> = [
    Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
        _id: string;
        _infinite?: boolean;
        tags?: ReadonlyArray<string>;
    }
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
    QueryKey<TOptions>[0]
] => {
    const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
    if (infinite) {
        params._infinite = infinite;
    }
    if (tags) {
        params.tags = tags;
    }
    if (options?.body) {
        params.body = options.body;
    }
    if (options?.headers) {
        params.headers = options.headers;
    }
    if (options?.path) {
        params.path = options.path;
    }
    if (options?.query) {
        params.query = options.query;
    }
    return [params];
};

export const serenCloudListAuditEntriesQueryKey = (options?: Options<SerenCloudListAuditEntriesData>) => createQueryKey('serenCloudListAuditEntries', options);

/**
 * List tamper-evident audit entries for seren-cloud.
 */
export const serenCloudListAuditEntriesOptions = (options?: Options<SerenCloudListAuditEntriesData>) => queryOptions<SerenCloudListAuditEntriesResponse, DefaultError, SerenCloudListAuditEntriesResponse, ReturnType<typeof serenCloudListAuditEntriesQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudListAuditEntries({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudListAuditEntriesQueryKey(options)
});

const createInfiniteParams = <K extends Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>>(queryKey: QueryKey<Options>, page: K) => {
    const params = { ...queryKey[0] };
    if (page.body) {
        params.body = {
            ...queryKey[0].body as any,
            ...page.body as any
        };
    }
    if (page.headers) {
        params.headers = {
            ...queryKey[0].headers,
            ...page.headers
        };
    }
    if (page.path) {
        params.path = {
            ...queryKey[0].path as any,
            ...page.path as any
        };
    }
    if (page.query) {
        params.query = {
            ...queryKey[0].query as any,
            ...page.query as any
        };
    }
    return params as unknown as typeof page;
};

export const serenCloudListAuditEntriesInfiniteQueryKey = (options?: Options<SerenCloudListAuditEntriesData>): QueryKey<Options<SerenCloudListAuditEntriesData>> => createQueryKey('serenCloudListAuditEntries', options, true);

/**
 * List tamper-evident audit entries for seren-cloud.
 */
export const serenCloudListAuditEntriesInfiniteOptions = (options?: Options<SerenCloudListAuditEntriesData>) => infiniteQueryOptions<SerenCloudListAuditEntriesResponse, DefaultError, InfiniteData<SerenCloudListAuditEntriesResponse>, QueryKey<Options<SerenCloudListAuditEntriesData>>, number | Pick<QueryKey<Options<SerenCloudListAuditEntriesData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudListAuditEntriesData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudListAuditEntries({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudListAuditEntriesInfiniteQueryKey(options)
});

export const serenCloudVerifyAuditQueryKey = (options?: Options<SerenCloudVerifyAuditData>) => createQueryKey('serenCloudVerifyAudit', options);

/**
 * Verify the tamper-evident audit chain.
 */
export const serenCloudVerifyAuditOptions = (options?: Options<SerenCloudVerifyAuditData>) => queryOptions<SerenCloudVerifyAuditResponse, DefaultError, SerenCloudVerifyAuditResponse, ReturnType<typeof serenCloudVerifyAuditQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudVerifyAudit({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudVerifyAuditQueryKey(options)
});

export const serenCloudGetAuditEntryQueryKey = (options: Options<SerenCloudGetAuditEntryData>) => createQueryKey('serenCloudGetAuditEntry', options);

/**
 * Get a single tamper-evident audit entry.
 */
export const serenCloudGetAuditEntryOptions = (options: Options<SerenCloudGetAuditEntryData>) => queryOptions<SerenCloudGetAuditEntryResponse, DefaultError, SerenCloudGetAuditEntryResponse, ReturnType<typeof serenCloudGetAuditEntryQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetAuditEntry({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetAuditEntryQueryKey(options)
});

/**
 * Deploy a skill to seren-cloud.
 */
export const serenCloudDeployMutation = (options?: Partial<Options<SerenCloudDeployData>>): MutationOptions<SerenCloudDeployResponse, DefaultError, Options<SerenCloudDeployData>> => {
    const mutationOptions: MutationOptions<SerenCloudDeployResponse, DefaultError, Options<SerenCloudDeployData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudDeploy({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Register a content-addressed deployment bundle before uploading raw bytes.
 */
export const serenCloudCreateDeploymentBundleMutation = (options?: Partial<Options<SerenCloudCreateDeploymentBundleData>>): MutationOptions<SerenCloudCreateDeploymentBundleResponse, DefaultError, Options<SerenCloudCreateDeploymentBundleData>> => {
    const mutationOptions: MutationOptions<SerenCloudCreateDeploymentBundleResponse, DefaultError, Options<SerenCloudCreateDeploymentBundleData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudCreateDeploymentBundle({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudGetDeploymentBundleQueryKey = (options: Options<SerenCloudGetDeploymentBundleData>) => createQueryKey('serenCloudGetDeploymentBundle', options);

/**
 * Get deployment bundle metadata without raw content.
 */
export const serenCloudGetDeploymentBundleOptions = (options: Options<SerenCloudGetDeploymentBundleData>) => queryOptions<SerenCloudGetDeploymentBundleResponse, DefaultError, SerenCloudGetDeploymentBundleResponse, ReturnType<typeof serenCloudGetDeploymentBundleQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetDeploymentBundle({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetDeploymentBundleQueryKey(options)
});

/**
 * Complete a direct-to-S3 upload for a registered deployment bundle.
 */
export const serenCloudCompleteDeploymentBundleUploadMutation = (options?: Partial<Options<SerenCloudCompleteDeploymentBundleUploadData>>): MutationOptions<SerenCloudCompleteDeploymentBundleUploadResponse, DefaultError, Options<SerenCloudCompleteDeploymentBundleUploadData>> => {
    const mutationOptions: MutationOptions<SerenCloudCompleteDeploymentBundleUploadResponse, DefaultError, Options<SerenCloudCompleteDeploymentBundleUploadData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudCompleteDeploymentBundleUpload({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudListDeploymentsQueryKey = (options?: Options<SerenCloudListDeploymentsData>) => createQueryKey('serenCloudListDeployments', options);

/**
 * List all deployments for the authenticated organization.
 */
export const serenCloudListDeploymentsOptions = (options?: Options<SerenCloudListDeploymentsData>) => queryOptions<SerenCloudListDeploymentsResponse, DefaultError, SerenCloudListDeploymentsResponse, ReturnType<typeof serenCloudListDeploymentsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudListDeployments({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudListDeploymentsQueryKey(options)
});

/**
 * Delete a deployment and clean up runtime resources.
 */
export const serenCloudDeleteMutation = (options?: Partial<Options<SerenCloudDeleteData>>): MutationOptions<SerenCloudDeleteResponse, DefaultError, Options<SerenCloudDeleteData>> => {
    const mutationOptions: MutationOptions<SerenCloudDeleteResponse, DefaultError, Options<SerenCloudDeleteData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudDelete({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudGetDeploymentQueryKey = (options: Options<SerenCloudGetDeploymentData>) => createQueryKey('serenCloudGetDeployment', options);

/**
 * Get details of a specific deployment.
 */
export const serenCloudGetDeploymentOptions = (options: Options<SerenCloudGetDeploymentData>) => queryOptions<SerenCloudGetDeploymentResponse, DefaultError, SerenCloudGetDeploymentResponse, ReturnType<typeof serenCloudGetDeploymentQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetDeployment({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetDeploymentQueryKey(options)
});

/**
 * Update config and/or secrets without redeploying code.
 */
export const serenCloudUpdateConfigMutation = (options?: Partial<Options<SerenCloudUpdateConfigData>>): MutationOptions<SerenCloudUpdateConfigResponse, DefaultError, Options<SerenCloudUpdateConfigData>> => {
    const mutationOptions: MutationOptions<SerenCloudUpdateConfigResponse, DefaultError, Options<SerenCloudUpdateConfigData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudUpdateConfig({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudDeploymentAuditQueryKey = (options: Options<SerenCloudDeploymentAuditData>) => createQueryKey('serenCloudDeploymentAudit', options);

/**
 * List tamper-evident audit entries scoped to a deployment.
 */
export const serenCloudDeploymentAuditOptions = (options: Options<SerenCloudDeploymentAuditData>) => queryOptions<SerenCloudDeploymentAuditResponse, DefaultError, SerenCloudDeploymentAuditResponse, ReturnType<typeof serenCloudDeploymentAuditQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentAudit({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentAuditQueryKey(options)
});

export const serenCloudDeploymentAuditInfiniteQueryKey = (options: Options<SerenCloudDeploymentAuditData>): QueryKey<Options<SerenCloudDeploymentAuditData>> => createQueryKey('serenCloudDeploymentAudit', options, true);

/**
 * List tamper-evident audit entries scoped to a deployment.
 */
export const serenCloudDeploymentAuditInfiniteOptions = (options: Options<SerenCloudDeploymentAuditData>) => infiniteQueryOptions<SerenCloudDeploymentAuditResponse, DefaultError, InfiniteData<SerenCloudDeploymentAuditResponse>, QueryKey<Options<SerenCloudDeploymentAuditData>>, number | Pick<QueryKey<Options<SerenCloudDeploymentAuditData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudDeploymentAuditData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudDeploymentAudit({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentAuditInfiniteQueryKey(options)
});

export const serenCloudGetDeploymentBundleDownloadQueryKey = (options: Options<SerenCloudGetDeploymentBundleDownloadData>) => createQueryKey('serenCloudGetDeploymentBundleDownload', options);

/**
 * Get a short-lived direct download URL for a deployment runtime bundle.
 */
export const serenCloudGetDeploymentBundleDownloadOptions = (options: Options<SerenCloudGetDeploymentBundleDownloadData>) => queryOptions<SerenCloudGetDeploymentBundleDownloadResponse, DefaultError, SerenCloudGetDeploymentBundleDownloadResponse, ReturnType<typeof serenCloudGetDeploymentBundleDownloadQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetDeploymentBundleDownload({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetDeploymentBundleDownloadQueryKey(options)
});

export const serenCloudGetDeploymentEvalDriftQueryKey = (options: Options<SerenCloudGetDeploymentEvalDriftData>) => createQueryKey('serenCloudGetDeploymentEvalDrift', options);

/**
 * Compare the deployment's current eval-set verdict against the baseline
 * captured at the last successful apply. Reports `passed`/`failed` deltas
 * plus an operator-safe summary message.
 */
export const serenCloudGetDeploymentEvalDriftOptions = (options: Options<SerenCloudGetDeploymentEvalDriftData>) => queryOptions<SerenCloudGetDeploymentEvalDriftResponse, DefaultError, SerenCloudGetDeploymentEvalDriftResponse, ReturnType<typeof serenCloudGetDeploymentEvalDriftQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetDeploymentEvalDrift({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetDeploymentEvalDriftQueryKey(options)
});

export const serenCloudDeploymentPendingApprovalsQueryKey = (options: Options<SerenCloudDeploymentPendingApprovalsData>) => createQueryKey('serenCloudDeploymentPendingApprovals', options);

/**
 * List awaiting-approval runs for a deployment.
 */
export const serenCloudDeploymentPendingApprovalsOptions = (options: Options<SerenCloudDeploymentPendingApprovalsData>) => queryOptions<SerenCloudDeploymentPendingApprovalsResponse, DefaultError, SerenCloudDeploymentPendingApprovalsResponse, ReturnType<typeof serenCloudDeploymentPendingApprovalsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentPendingApprovals({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentPendingApprovalsQueryKey(options)
});

export const serenCloudDeploymentPendingApprovalsInfiniteQueryKey = (options: Options<SerenCloudDeploymentPendingApprovalsData>): QueryKey<Options<SerenCloudDeploymentPendingApprovalsData>> => createQueryKey('serenCloudDeploymentPendingApprovals', options, true);

/**
 * List awaiting-approval runs for a deployment.
 */
export const serenCloudDeploymentPendingApprovalsInfiniteOptions = (options: Options<SerenCloudDeploymentPendingApprovalsData>) => infiniteQueryOptions<SerenCloudDeploymentPendingApprovalsResponse, DefaultError, InfiniteData<SerenCloudDeploymentPendingApprovalsResponse>, QueryKey<Options<SerenCloudDeploymentPendingApprovalsData>>, number | Pick<QueryKey<Options<SerenCloudDeploymentPendingApprovalsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudDeploymentPendingApprovalsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudDeploymentPendingApprovals({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentPendingApprovalsInfiniteQueryKey(options)
});

export const serenCloudDeploymentRunsQueryKey = (options: Options<SerenCloudDeploymentRunsData>) => createQueryKey('serenCloudDeploymentRuns', options);

/**
 * List run events (history) for a deployment.
 */
export const serenCloudDeploymentRunsOptions = (options: Options<SerenCloudDeploymentRunsData>) => queryOptions<SerenCloudDeploymentRunsResponse, DefaultError, SerenCloudDeploymentRunsResponse, ReturnType<typeof serenCloudDeploymentRunsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentRuns({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunsQueryKey(options)
});

export const serenCloudDeploymentRunsInfiniteQueryKey = (options: Options<SerenCloudDeploymentRunsData>): QueryKey<Options<SerenCloudDeploymentRunsData>> => createQueryKey('serenCloudDeploymentRuns', options, true);

/**
 * List run events (history) for a deployment.
 */
export const serenCloudDeploymentRunsInfiniteOptions = (options: Options<SerenCloudDeploymentRunsData>) => infiniteQueryOptions<SerenCloudDeploymentRunsResponse, DefaultError, InfiniteData<SerenCloudDeploymentRunsResponse>, QueryKey<Options<SerenCloudDeploymentRunsData>>, number | Pick<QueryKey<Options<SerenCloudDeploymentRunsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudDeploymentRunsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudDeploymentRuns({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunsInfiniteQueryKey(options)
});

export const serenCloudRunMutation = (options?: Partial<Options<SerenCloudRunData>>): MutationOptions<SerenCloudRunResponse, DefaultError, Options<SerenCloudRunData>> => {
    const mutationOptions: MutationOptions<SerenCloudRunResponse, DefaultError, Options<SerenCloudRunData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudRun({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudDeploymentRunQueryKey = (options: Options<SerenCloudDeploymentRunData>) => createQueryKey('serenCloudDeploymentRun', options);

/**
 * Get a single run event for a deployment.
 */
export const serenCloudDeploymentRunOptions = (options: Options<SerenCloudDeploymentRunData>) => queryOptions<SerenCloudDeploymentRunResponse, DefaultError, SerenCloudDeploymentRunResponse, ReturnType<typeof serenCloudDeploymentRunQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentRun({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunQueryKey(options)
});

export const serenCloudDeploymentRunArtifactsQueryKey = (options: Options<SerenCloudDeploymentRunArtifactsData>) => createQueryKey('serenCloudDeploymentRunArtifacts', options);

/**
 * List artifacts emitted by a specific deployment run.
 */
export const serenCloudDeploymentRunArtifactsOptions = (options: Options<SerenCloudDeploymentRunArtifactsData>) => queryOptions<SerenCloudDeploymentRunArtifactsResponse, DefaultError, SerenCloudDeploymentRunArtifactsResponse, ReturnType<typeof serenCloudDeploymentRunArtifactsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentRunArtifacts({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunArtifactsQueryKey(options)
});

export const serenCloudDeploymentRunArtifactsInfiniteQueryKey = (options: Options<SerenCloudDeploymentRunArtifactsData>): QueryKey<Options<SerenCloudDeploymentRunArtifactsData>> => createQueryKey('serenCloudDeploymentRunArtifacts', options, true);

/**
 * List artifacts emitted by a specific deployment run.
 */
export const serenCloudDeploymentRunArtifactsInfiniteOptions = (options: Options<SerenCloudDeploymentRunArtifactsData>) => infiniteQueryOptions<SerenCloudDeploymentRunArtifactsResponse, DefaultError, InfiniteData<SerenCloudDeploymentRunArtifactsResponse>, QueryKey<Options<SerenCloudDeploymentRunArtifactsData>>, number | Pick<QueryKey<Options<SerenCloudDeploymentRunArtifactsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudDeploymentRunArtifactsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudDeploymentRunArtifacts({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunArtifactsInfiniteQueryKey(options)
});

/**
 * Cancel a queued/running deployment run.
 */
export const serenCloudDeploymentRunCancelMutation = (options?: Partial<Options<SerenCloudDeploymentRunCancelData>>): MutationOptions<SerenCloudDeploymentRunCancelResponse, DefaultError, Options<SerenCloudDeploymentRunCancelData>> => {
    const mutationOptions: MutationOptions<SerenCloudDeploymentRunCancelResponse, DefaultError, Options<SerenCloudDeploymentRunCancelData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudDeploymentRunCancel({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudDeploymentRunEvalsQueryKey = (options: Options<SerenCloudDeploymentRunEvalsData>) => createQueryKey('serenCloudDeploymentRunEvals', options);

/**
 * List eval records linked to a specific deployment run.
 */
export const serenCloudDeploymentRunEvalsOptions = (options: Options<SerenCloudDeploymentRunEvalsData>) => queryOptions<SerenCloudDeploymentRunEvalsResponse, DefaultError, SerenCloudDeploymentRunEvalsResponse, ReturnType<typeof serenCloudDeploymentRunEvalsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentRunEvals({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunEvalsQueryKey(options)
});

export const serenCloudDeploymentRunEventsQueryKey = (options: Options<SerenCloudDeploymentRunEventsData>) => createQueryKey('serenCloudDeploymentRunEvents', options);

/**
 * List structured output events emitted by a specific deployment run.
 */
export const serenCloudDeploymentRunEventsOptions = (options: Options<SerenCloudDeploymentRunEventsData>) => queryOptions<SerenCloudDeploymentRunEventsResponse, DefaultError, SerenCloudDeploymentRunEventsResponse, ReturnType<typeof serenCloudDeploymentRunEventsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentRunEvents({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunEventsQueryKey(options)
});

export const serenCloudDeploymentRunEventsInfiniteQueryKey = (options: Options<SerenCloudDeploymentRunEventsData>): QueryKey<Options<SerenCloudDeploymentRunEventsData>> => createQueryKey('serenCloudDeploymentRunEvents', options, true);

/**
 * List structured output events emitted by a specific deployment run.
 */
export const serenCloudDeploymentRunEventsInfiniteOptions = (options: Options<SerenCloudDeploymentRunEventsData>) => infiniteQueryOptions<SerenCloudDeploymentRunEventsResponse, DefaultError, InfiniteData<SerenCloudDeploymentRunEventsResponse>, QueryKey<Options<SerenCloudDeploymentRunEventsData>>, number | Pick<QueryKey<Options<SerenCloudDeploymentRunEventsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudDeploymentRunEventsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudDeploymentRunEvents({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunEventsInfiniteQueryKey(options)
});

export const serenCloudDeploymentRunPendingApprovalsQueryKey = (options: Options<SerenCloudDeploymentRunPendingApprovalsData>) => createQueryKey('serenCloudDeploymentRunPendingApprovals', options);

/**
 * List current pending approvals for a specific deployment run.
 */
export const serenCloudDeploymentRunPendingApprovalsOptions = (options: Options<SerenCloudDeploymentRunPendingApprovalsData>) => queryOptions<SerenCloudDeploymentRunPendingApprovalsResponse, DefaultError, SerenCloudDeploymentRunPendingApprovalsResponse, ReturnType<typeof serenCloudDeploymentRunPendingApprovalsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudDeploymentRunPendingApprovals({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudDeploymentRunPendingApprovalsQueryKey(options)
});

/**
 * Close an active deployment-run stream session.
 */
export const serenCloudDeploymentRunStreamCloseMutation = (options?: Partial<Options<SerenCloudDeploymentRunStreamCloseData>>): MutationOptions<SerenCloudDeploymentRunStreamCloseResponse, DefaultError, Options<SerenCloudDeploymentRunStreamCloseData>> => {
    const mutationOptions: MutationOptions<SerenCloudDeploymentRunStreamCloseResponse, DefaultError, Options<SerenCloudDeploymentRunStreamCloseData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudDeploymentRunStreamClose({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudGetDeploymentSpendQueryKey = (options: Options<SerenCloudGetDeploymentSpendData>) => createQueryKey('serenCloudGetDeploymentSpend', options);

/**
 * Run a one-shot invocation of a deployment.
 */
export const serenCloudGetDeploymentSpendOptions = (options: Options<SerenCloudGetDeploymentSpendData>) => queryOptions<SerenCloudGetDeploymentSpendResponse, DefaultError, SerenCloudGetDeploymentSpendResponse, ReturnType<typeof serenCloudGetDeploymentSpendQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetDeploymentSpend({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetDeploymentSpendQueryKey(options)
});

/**
 * Start an always-on deployment (scale to 1 replica).
 */
export const serenCloudStartMutation = (options?: Partial<Options<SerenCloudStartData>>): MutationOptions<SerenCloudStartResponse, DefaultError, Options<SerenCloudStartData>> => {
    const mutationOptions: MutationOptions<SerenCloudStartResponse, DefaultError, Options<SerenCloudStartData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudStart({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Stop an always-on deployment (scale to 0 replicas).
 */
export const serenCloudStopMutation = (options?: Partial<Options<SerenCloudStopData>>): MutationOptions<SerenCloudStopResponse, DefaultError, Options<SerenCloudStopData>> => {
    const mutationOptions: MutationOptions<SerenCloudStopResponse, DefaultError, Options<SerenCloudStopData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudStop({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudListEnvironmentsQueryKey = (options?: Options<SerenCloudListEnvironmentsData>) => createQueryKey('serenCloudListEnvironments', options);

/**
 * List reusable execution environment profiles.
 */
export const serenCloudListEnvironmentsOptions = (options?: Options<SerenCloudListEnvironmentsData>) => queryOptions<SerenCloudListEnvironmentsResponse, DefaultError, SerenCloudListEnvironmentsResponse, ReturnType<typeof serenCloudListEnvironmentsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudListEnvironments({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudListEnvironmentsQueryKey(options)
});

/**
 * Create a reusable execution environment profile.
 */
export const serenCloudCreateEnvironmentMutation = (options?: Partial<Options<SerenCloudCreateEnvironmentData>>): MutationOptions<SerenCloudCreateEnvironmentResponse, DefaultError, Options<SerenCloudCreateEnvironmentData>> => {
    const mutationOptions: MutationOptions<SerenCloudCreateEnvironmentResponse, DefaultError, Options<SerenCloudCreateEnvironmentData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudCreateEnvironment({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Delete a reusable execution environment profile.
 */
export const serenCloudDeleteEnvironmentMutation = (options?: Partial<Options<SerenCloudDeleteEnvironmentData>>): MutationOptions<SerenCloudDeleteEnvironmentResponse, DefaultError, Options<SerenCloudDeleteEnvironmentData>> => {
    const mutationOptions: MutationOptions<SerenCloudDeleteEnvironmentResponse, DefaultError, Options<SerenCloudDeleteEnvironmentData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudDeleteEnvironment({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudGetEnvironmentQueryKey = (options: Options<SerenCloudGetEnvironmentData>) => createQueryKey('serenCloudGetEnvironment', options);

/**
 * Get a reusable execution environment profile.
 */
export const serenCloudGetEnvironmentOptions = (options: Options<SerenCloudGetEnvironmentData>) => queryOptions<SerenCloudGetEnvironmentResponse, DefaultError, SerenCloudGetEnvironmentResponse, ReturnType<typeof serenCloudGetEnvironmentQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetEnvironment({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetEnvironmentQueryKey(options)
});

/**
 * Update a reusable execution environment profile.
 */
export const serenCloudUpdateEnvironmentMutation = (options?: Partial<Options<SerenCloudUpdateEnvironmentData>>): MutationOptions<SerenCloudUpdateEnvironmentResponse, DefaultError, Options<SerenCloudUpdateEnvironmentData>> => {
    const mutationOptions: MutationOptions<SerenCloudUpdateEnvironmentResponse, DefaultError, Options<SerenCloudUpdateEnvironmentData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudUpdateEnvironment({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudEvalSetsQueryKey = (options?: Options<SerenCloudEvalSetsData>) => createQueryKey('serenCloudEvalSets', options);

/**
 * List eval sets for the authenticated organization.
 */
export const serenCloudEvalSetsOptions = (options?: Options<SerenCloudEvalSetsData>) => queryOptions<SerenCloudEvalSetsResponse, DefaultError, SerenCloudEvalSetsResponse, ReturnType<typeof serenCloudEvalSetsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudEvalSets({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalSetsQueryKey(options)
});

export const serenCloudEvalSetsInfiniteQueryKey = (options?: Options<SerenCloudEvalSetsData>): QueryKey<Options<SerenCloudEvalSetsData>> => createQueryKey('serenCloudEvalSets', options, true);

/**
 * List eval sets for the authenticated organization.
 */
export const serenCloudEvalSetsInfiniteOptions = (options?: Options<SerenCloudEvalSetsData>) => infiniteQueryOptions<SerenCloudEvalSetsResponse, DefaultError, InfiniteData<SerenCloudEvalSetsResponse>, QueryKey<Options<SerenCloudEvalSetsData>>, number | Pick<QueryKey<Options<SerenCloudEvalSetsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudEvalSetsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudEvalSets({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalSetsInfiniteQueryKey(options)
});

/**
 * Create a durable eval set for seren-cloud runs.
 */
export const serenCloudCreateEvalSetMutation = (options?: Partial<Options<SerenCloudCreateEvalSetData>>): MutationOptions<SerenCloudCreateEvalSetResponse, DefaultError, Options<SerenCloudCreateEvalSetData>> => {
    const mutationOptions: MutationOptions<SerenCloudCreateEvalSetResponse, DefaultError, Options<SerenCloudCreateEvalSetData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudCreateEvalSet({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudGetEvalSetQueryKey = (options: Options<SerenCloudGetEvalSetData>) => createQueryKey('serenCloudGetEvalSet', options);

/**
 * Get a single eval set.
 */
export const serenCloudGetEvalSetOptions = (options: Options<SerenCloudGetEvalSetData>) => queryOptions<SerenCloudGetEvalSetResponse, DefaultError, SerenCloudGetEvalSetResponse, ReturnType<typeof serenCloudGetEvalSetQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetEvalSet({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetEvalSetQueryKey(options)
});

/**
 * Replace an eval set definition, including schedule and criteria.
 */
export const serenCloudUpdateEvalSetMutation = (options?: Partial<Options<SerenCloudUpdateEvalSetData>>): MutationOptions<SerenCloudUpdateEvalSetResponse, DefaultError, Options<SerenCloudUpdateEvalSetData>> => {
    const mutationOptions: MutationOptions<SerenCloudUpdateEvalSetResponse, DefaultError, Options<SerenCloudUpdateEvalSetData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudUpdateEvalSet({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudEvalCasesQueryKey = (options: Options<SerenCloudEvalCasesData>) => createQueryKey('serenCloudEvalCases', options);

/**
 * List eval cases within a set.
 */
export const serenCloudEvalCasesOptions = (options: Options<SerenCloudEvalCasesData>) => queryOptions<SerenCloudEvalCasesResponse, DefaultError, SerenCloudEvalCasesResponse, ReturnType<typeof serenCloudEvalCasesQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudEvalCases({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalCasesQueryKey(options)
});

export const serenCloudEvalCasesInfiniteQueryKey = (options: Options<SerenCloudEvalCasesData>): QueryKey<Options<SerenCloudEvalCasesData>> => createQueryKey('serenCloudEvalCases', options, true);

/**
 * List eval cases within a set.
 */
export const serenCloudEvalCasesInfiniteOptions = (options: Options<SerenCloudEvalCasesData>) => infiniteQueryOptions<SerenCloudEvalCasesResponse, DefaultError, InfiniteData<SerenCloudEvalCasesResponse>, QueryKey<Options<SerenCloudEvalCasesData>>, number | Pick<QueryKey<Options<SerenCloudEvalCasesData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudEvalCasesData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudEvalCases({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalCasesInfiniteQueryKey(options)
});

/**
 * Promote a terminal run into a durable eval case.
 */
export const serenCloudPromoteRunToEvalCaseMutation = (options?: Partial<Options<SerenCloudPromoteRunToEvalCaseData>>): MutationOptions<SerenCloudPromoteRunToEvalCaseResponse, DefaultError, Options<SerenCloudPromoteRunToEvalCaseData>> => {
    const mutationOptions: MutationOptions<SerenCloudPromoteRunToEvalCaseResponse, DefaultError, Options<SerenCloudPromoteRunToEvalCaseData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudPromoteRunToEvalCase({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudGetEvalCaseQueryKey = (options: Options<SerenCloudGetEvalCaseData>) => createQueryKey('serenCloudGetEvalCase', options);

/**
 * Get a single eval case.
 */
export const serenCloudGetEvalCaseOptions = (options: Options<SerenCloudGetEvalCaseData>) => queryOptions<SerenCloudGetEvalCaseResponse, DefaultError, SerenCloudGetEvalCaseResponse, ReturnType<typeof serenCloudGetEvalCaseQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetEvalCase({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetEvalCaseQueryKey(options)
});

export const serenCloudEvalRunsQueryKey = (options: Options<SerenCloudEvalRunsData>) => createQueryKey('serenCloudEvalRuns', options);

/**
 * List eval runs within a set.
 */
export const serenCloudEvalRunsOptions = (options: Options<SerenCloudEvalRunsData>) => queryOptions<SerenCloudEvalRunsResponse, DefaultError, SerenCloudEvalRunsResponse, ReturnType<typeof serenCloudEvalRunsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudEvalRuns({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalRunsQueryKey(options)
});

export const serenCloudEvalRunsInfiniteQueryKey = (options: Options<SerenCloudEvalRunsData>): QueryKey<Options<SerenCloudEvalRunsData>> => createQueryKey('serenCloudEvalRuns', options, true);

/**
 * List eval runs within a set.
 */
export const serenCloudEvalRunsInfiniteOptions = (options: Options<SerenCloudEvalRunsData>) => infiniteQueryOptions<SerenCloudEvalRunsResponse, DefaultError, InfiniteData<SerenCloudEvalRunsResponse>, QueryKey<Options<SerenCloudEvalRunsData>>, number | Pick<QueryKey<Options<SerenCloudEvalRunsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudEvalRunsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudEvalRuns({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalRunsInfiniteQueryKey(options)
});

/**
 * Execute an eval set against a deployment.
 */
export const serenCloudRunEvalSetMutation = (options?: Partial<Options<SerenCloudRunEvalSetData>>): MutationOptions<SerenCloudRunEvalSetResponse, DefaultError, Options<SerenCloudRunEvalSetData>> => {
    const mutationOptions: MutationOptions<SerenCloudRunEvalSetResponse, DefaultError, Options<SerenCloudRunEvalSetData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudRunEvalSet({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudGetEvalRunQueryKey = (options: Options<SerenCloudGetEvalRunData>) => createQueryKey('serenCloudGetEvalRun', options);

/**
 * Get a single eval run.
 */
export const serenCloudGetEvalRunOptions = (options: Options<SerenCloudGetEvalRunData>) => queryOptions<SerenCloudGetEvalRunResponse, DefaultError, SerenCloudGetEvalRunResponse, ReturnType<typeof serenCloudGetEvalRunQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetEvalRun({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetEvalRunQueryKey(options)
});

export const serenCloudEvalRunResultsQueryKey = (options: Options<SerenCloudEvalRunResultsData>) => createQueryKey('serenCloudEvalRunResults', options);

/**
 * List case results for an eval run.
 */
export const serenCloudEvalRunResultsOptions = (options: Options<SerenCloudEvalRunResultsData>) => queryOptions<SerenCloudEvalRunResultsResponse, DefaultError, SerenCloudEvalRunResultsResponse, ReturnType<typeof serenCloudEvalRunResultsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudEvalRunResults({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalRunResultsQueryKey(options)
});

export const serenCloudEvalRunResultsInfiniteQueryKey = (options: Options<SerenCloudEvalRunResultsData>): QueryKey<Options<SerenCloudEvalRunResultsData>> => createQueryKey('serenCloudEvalRunResults', options, true);

/**
 * List case results for an eval run.
 */
export const serenCloudEvalRunResultsInfiniteOptions = (options: Options<SerenCloudEvalRunResultsData>) => infiniteQueryOptions<SerenCloudEvalRunResultsResponse, DefaultError, InfiniteData<SerenCloudEvalRunResultsResponse>, QueryKey<Options<SerenCloudEvalRunResultsData>>, number | Pick<QueryKey<Options<SerenCloudEvalRunResultsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudEvalRunResultsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudEvalRunResults({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudEvalRunResultsInfiniteQueryKey(options)
});

export const serenCloudGetEvalCaseResultQueryKey = (options: Options<SerenCloudGetEvalCaseResultData>) => createQueryKey('serenCloudGetEvalCaseResult', options);

/**
 * Get a single case result from an eval run.
 */
export const serenCloudGetEvalCaseResultOptions = (options: Options<SerenCloudGetEvalCaseResultData>) => queryOptions<SerenCloudGetEvalCaseResultResponse, DefaultError, SerenCloudGetEvalCaseResultResponse, ReturnType<typeof serenCloudGetEvalCaseResultQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudGetEvalCaseResult({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudGetEvalCaseResultQueryKey(options)
});

export const serenCloudApprovalInboxListQueryKey = (options?: Options<SerenCloudApprovalInboxListData>) => createQueryKey('serenCloudApprovalInboxList', options);

/**
 * List every awaiting approval the operator owns across all approval kinds.
 *
 * Returns `ToolCall` entries (derived from `awaiting_approval` runs) and
 * `BlockedEgress` entries (from `blocked_egress_inbox_entries`) merged into
 * a single timeline ordered by `created_at DESC`. Pagination is cursor-only:
 * the response includes `next_cursor` when more entries are available, and
 * the caller passes it back in `?cursor=`.
 */
export const serenCloudApprovalInboxListOptions = (options?: Options<SerenCloudApprovalInboxListData>) => queryOptions<SerenCloudApprovalInboxListResponse, DefaultError, SerenCloudApprovalInboxListResponse, ReturnType<typeof serenCloudApprovalInboxListQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudApprovalInboxList({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudApprovalInboxListQueryKey(options)
});

export const serenCloudApprovalInboxListInfiniteQueryKey = (options?: Options<SerenCloudApprovalInboxListData>): QueryKey<Options<SerenCloudApprovalInboxListData>> => createQueryKey('serenCloudApprovalInboxList', options, true);

/**
 * List every awaiting approval the operator owns across all approval kinds.
 *
 * Returns `ToolCall` entries (derived from `awaiting_approval` runs) and
 * `BlockedEgress` entries (from `blocked_egress_inbox_entries`) merged into
 * a single timeline ordered by `created_at DESC`. Pagination is cursor-only:
 * the response includes `next_cursor` when more entries are available, and
 * the caller passes it back in `?cursor=`.
 */
export const serenCloudApprovalInboxListInfiniteOptions = (options?: Options<SerenCloudApprovalInboxListData>) => infiniteQueryOptions<SerenCloudApprovalInboxListResponse, DefaultError, InfiniteData<SerenCloudApprovalInboxListResponse>, QueryKey<Options<SerenCloudApprovalInboxListData>>, string | Pick<QueryKey<Options<SerenCloudApprovalInboxListData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudApprovalInboxListData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                cursor: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudApprovalInboxList({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudApprovalInboxListInfiniteQueryKey(options)
});

/**
 * Record an operator approve/deny decision for a single inbox entry.
 *
 * Tool-call entries record an audit row and rely on the existing run-resume
 * flow to emit the `approval_decision` event. Blocked-egress entries flip
 * the row's `decision_state` so the runtime wait long-poll releases or
 * drops the corresponding request on its next tick. Re-deciding an
 * already-terminal blocked-egress row returns the current state instead of
 * 409 so the agent runtime's at-least-once retries are idempotent.
 */
export const serenCloudApprovalInboxDecideMutation = (options?: Partial<Options<SerenCloudApprovalInboxDecideData>>): MutationOptions<SerenCloudApprovalInboxDecideResponse, DefaultError, Options<SerenCloudApprovalInboxDecideData>> => {
    const mutationOptions: MutationOptions<SerenCloudApprovalInboxDecideResponse, DefaultError, Options<SerenCloudApprovalInboxDecideData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudApprovalInboxDecide({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudPendingApprovalsQueryKey = (options?: Options<SerenCloudPendingApprovalsData>) => createQueryKey('serenCloudPendingApprovals', options);

/**
 * List awaiting-approval runs across all deployments for the organization.
 */
export const serenCloudPendingApprovalsOptions = (options?: Options<SerenCloudPendingApprovalsData>) => queryOptions<SerenCloudPendingApprovalsResponse, DefaultError, SerenCloudPendingApprovalsResponse, ReturnType<typeof serenCloudPendingApprovalsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudPendingApprovals({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudPendingApprovalsQueryKey(options)
});

export const serenCloudPendingApprovalsInfiniteQueryKey = (options?: Options<SerenCloudPendingApprovalsData>): QueryKey<Options<SerenCloudPendingApprovalsData>> => createQueryKey('serenCloudPendingApprovals', options, true);

/**
 * List awaiting-approval runs across all deployments for the organization.
 */
export const serenCloudPendingApprovalsInfiniteOptions = (options?: Options<SerenCloudPendingApprovalsData>) => infiniteQueryOptions<SerenCloudPendingApprovalsResponse, DefaultError, InfiniteData<SerenCloudPendingApprovalsResponse>, QueryKey<Options<SerenCloudPendingApprovalsData>>, number | Pick<QueryKey<Options<SerenCloudPendingApprovalsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudPendingApprovalsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudPendingApprovals({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudPendingApprovalsInfiniteQueryKey(options)
});

export const serenCloudRunsQueryKey = (options?: Options<SerenCloudRunsData>) => createQueryKey('serenCloudRuns', options);

/**
 * List all runs across all deployments for the organization.
 */
export const serenCloudRunsOptions = (options?: Options<SerenCloudRunsData>) => queryOptions<SerenCloudRunsResponse, DefaultError, SerenCloudRunsResponse, ReturnType<typeof serenCloudRunsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRuns({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunsQueryKey(options)
});

export const serenCloudRunsInfiniteQueryKey = (options?: Options<SerenCloudRunsData>): QueryKey<Options<SerenCloudRunsData>> => createQueryKey('serenCloudRuns', options, true);

/**
 * List all runs across all deployments for the organization.
 */
export const serenCloudRunsInfiniteOptions = (options?: Options<SerenCloudRunsData>) => infiniteQueryOptions<SerenCloudRunsResponse, DefaultError, InfiniteData<SerenCloudRunsResponse>, QueryKey<Options<SerenCloudRunsData>>, number | Pick<QueryKey<Options<SerenCloudRunsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudRunsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudRuns({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunsInfiniteQueryKey(options)
});

export const serenCloudRunDetailQueryKey = (options: Options<SerenCloudRunDetailData>) => createQueryKey('serenCloudRunDetail', options);

/**
 * Get a single run event by ID (cross-agent).
 */
export const serenCloudRunDetailOptions = (options: Options<SerenCloudRunDetailData>) => queryOptions<SerenCloudRunDetailResponse, DefaultError, SerenCloudRunDetailResponse, ReturnType<typeof serenCloudRunDetailQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRunDetail({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunDetailQueryKey(options)
});

export const serenCloudRunArtifactsQueryKey = (options: Options<SerenCloudRunArtifactsData>) => createQueryKey('serenCloudRunArtifacts', options);

/**
 * List artifacts emitted by a run event.
 */
export const serenCloudRunArtifactsOptions = (options: Options<SerenCloudRunArtifactsData>) => queryOptions<SerenCloudRunArtifactsResponse, DefaultError, SerenCloudRunArtifactsResponse, ReturnType<typeof serenCloudRunArtifactsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRunArtifacts({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunArtifactsQueryKey(options)
});

export const serenCloudRunArtifactsInfiniteQueryKey = (options: Options<SerenCloudRunArtifactsData>): QueryKey<Options<SerenCloudRunArtifactsData>> => createQueryKey('serenCloudRunArtifacts', options, true);

/**
 * List artifacts emitted by a run event.
 */
export const serenCloudRunArtifactsInfiniteOptions = (options: Options<SerenCloudRunArtifactsData>) => infiniteQueryOptions<SerenCloudRunArtifactsResponse, DefaultError, InfiniteData<SerenCloudRunArtifactsResponse>, QueryKey<Options<SerenCloudRunArtifactsData>>, number | Pick<QueryKey<Options<SerenCloudRunArtifactsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudRunArtifactsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudRunArtifacts({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunArtifactsInfiniteQueryKey(options)
});

export const serenCloudRunAuditQueryKey = (options: Options<SerenCloudRunAuditData>) => createQueryKey('serenCloudRunAudit', options);

/**
 * List tamper-evident audit entries scoped to a run.
 */
export const serenCloudRunAuditOptions = (options: Options<SerenCloudRunAuditData>) => queryOptions<SerenCloudRunAuditResponse, DefaultError, SerenCloudRunAuditResponse, ReturnType<typeof serenCloudRunAuditQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRunAudit({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunAuditQueryKey(options)
});

export const serenCloudRunAuditInfiniteQueryKey = (options: Options<SerenCloudRunAuditData>): QueryKey<Options<SerenCloudRunAuditData>> => createQueryKey('serenCloudRunAudit', options, true);

/**
 * List tamper-evident audit entries scoped to a run.
 */
export const serenCloudRunAuditInfiniteOptions = (options: Options<SerenCloudRunAuditData>) => infiniteQueryOptions<SerenCloudRunAuditResponse, DefaultError, InfiniteData<SerenCloudRunAuditResponse>, QueryKey<Options<SerenCloudRunAuditData>>, number | Pick<QueryKey<Options<SerenCloudRunAuditData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudRunAuditData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudRunAudit({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunAuditInfiniteQueryKey(options)
});

/**
 * Cancel a queued/running run by ID.
 */
export const serenCloudRunCancelMutation = (options?: Partial<Options<SerenCloudRunCancelData>>): MutationOptions<SerenCloudRunCancelResponse, DefaultError, Options<SerenCloudRunCancelData>> => {
    const mutationOptions: MutationOptions<SerenCloudRunCancelResponse, DefaultError, Options<SerenCloudRunCancelData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudRunCancel({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenCloudRunCompareQueryKey = (options: Options<SerenCloudRunCompareData>) => createQueryKey('serenCloudRunCompare', options);

/**
 * Compare two run replay/eval captures by ID (cross-agent).
 */
export const serenCloudRunCompareOptions = (options: Options<SerenCloudRunCompareData>) => queryOptions<SerenCloudRunCompareResponse, DefaultError, SerenCloudRunCompareResponse, ReturnType<typeof serenCloudRunCompareQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRunCompare({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunCompareQueryKey(options)
});

export const serenCloudRunEvalsQueryKey = (options: Options<SerenCloudRunEvalsData>) => createQueryKey('serenCloudRunEvals', options);

/**
 * List eval records linked to a run event.
 */
export const serenCloudRunEvalsOptions = (options: Options<SerenCloudRunEvalsData>) => queryOptions<SerenCloudRunEvalsResponse, DefaultError, SerenCloudRunEvalsResponse, ReturnType<typeof serenCloudRunEvalsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRunEvals({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunEvalsQueryKey(options)
});

export const serenCloudRunEventsQueryKey = (options: Options<SerenCloudRunEventsData>) => createQueryKey('serenCloudRunEvents', options);

/**
 * List structured output events emitted by a run event.
 */
export const serenCloudRunEventsOptions = (options: Options<SerenCloudRunEventsData>) => queryOptions<SerenCloudRunEventsResponse, DefaultError, SerenCloudRunEventsResponse, ReturnType<typeof serenCloudRunEventsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRunEvents({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunEventsQueryKey(options)
});

export const serenCloudRunEventsInfiniteQueryKey = (options: Options<SerenCloudRunEventsData>): QueryKey<Options<SerenCloudRunEventsData>> => createQueryKey('serenCloudRunEvents', options, true);

/**
 * List structured output events emitted by a run event.
 */
export const serenCloudRunEventsInfiniteOptions = (options: Options<SerenCloudRunEventsData>) => infiniteQueryOptions<SerenCloudRunEventsResponse, DefaultError, InfiniteData<SerenCloudRunEventsResponse>, QueryKey<Options<SerenCloudRunEventsData>>, number | Pick<QueryKey<Options<SerenCloudRunEventsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
// @ts-ignore
{
    queryFn: async ({ pageParam, queryKey, signal }) => {
        // @ts-ignore
        const page: Pick<QueryKey<Options<SerenCloudRunEventsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
            query: {
                offset: pageParam
            }
        };
        const params = createInfiniteParams(queryKey, page);
        const { data } = await serenCloudRunEvents({
            ...options,
            ...params,
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunEventsInfiniteQueryKey(options)
});

export const serenCloudRunPendingApprovalsQueryKey = (options: Options<SerenCloudRunPendingApprovalsData>) => createQueryKey('serenCloudRunPendingApprovals', options);

/**
 * List current pending approvals for a run event.
 */
export const serenCloudRunPendingApprovalsOptions = (options: Options<SerenCloudRunPendingApprovalsData>) => queryOptions<SerenCloudRunPendingApprovalsResponse, DefaultError, SerenCloudRunPendingApprovalsResponse, ReturnType<typeof serenCloudRunPendingApprovalsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenCloudRunPendingApprovals({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenCloudRunPendingApprovalsQueryKey(options)
});

/**
 * Close an active run stream session (global run path).
 */
export const serenCloudRunStreamCloseMutation = (options?: Partial<Options<SerenCloudRunStreamCloseData>>): MutationOptions<SerenCloudRunStreamCloseResponse, DefaultError, Options<SerenCloudRunStreamCloseData>> => {
    const mutationOptions: MutationOptions<SerenCloudRunStreamCloseResponse, DefaultError, Options<SerenCloudRunStreamCloseData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenCloudRunStreamClose({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};
