export type ApiAiAgentThreadStreamRequest = {toolHints?: Array | undefined, autoApproveSql?: boolean | undefined, enableSqlMode?: boolean | undefined}; export type CreateApiApiV1ProjectsProjectUuidAiAgentsAgentUuidThreadsThreadUuidStreamArgs = {projectUuid: string, agentUuid: string, threadUuid: string, body: ApiAiAgentThreadStreamRequest}; export type CreateApiApiV1ProjectsProjectUuidAiAgentsAgentUuidThreadsThreadUuidStreamOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/stream */ export const createApiApiV1ProjectsProjectUuidAiAgentsAgentUuidThreadsThreadUuidStream = async (args: CreateApiApiV1ProjectsProjectUuidAiAgentsAgentUuidThreadsThreadUuidStreamArgs, options: CreateApiApiV1ProjectsProjectUuidAiAgentsAgentUuidThreadsThreadUuidStreamOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/projects/${encodeURIComponent(String(args.projectUuid))}/aiAgents/${encodeURIComponent(String(args.agentUuid))}/threads/${encodeURIComponent(String(args.threadUuid))}/stream${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };