/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { SDKCore } from "../core.js"; import { agentRunsStreamAgentRunEvents } from "../funcs/agentRunsStreamAgentRunEvents.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; export type AgentRunsStreamAgentRunEventsQueryData = string; export function prefetchAgentRunsStreamAgentRunEvents( queryClient: QueryClient, client$: SDKCore, request: operations.StreamAgentRunEventsRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildAgentRunsStreamAgentRunEventsQuery( client$, request, options, ), }); } export function buildAgentRunsStreamAgentRunEventsQuery( client$: SDKCore, request: operations.StreamAgentRunEventsRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: ( context: QueryFunctionContext, ) => Promise; } { return { queryKey: queryKeyAgentRunsStreamAgentRunEvents( request.agentId, request.runId, { xOnBehalfOf: request.xOnBehalfOf }, ), queryFn: async function agentRunsStreamAgentRunEventsQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(agentRunsStreamAgentRunEvents( client$, request, mergedOptions, )); }, }; } export function queryKeyAgentRunsStreamAgentRunEvents( agentId: string, runId: string, parameters: { xOnBehalfOf?: string | undefined }, ): QueryKey { return [ "@meetkai/mka1", "Agent Runs", "streamAgentRunEvents", agentId, runId, parameters, ]; }