export type CreateApiApiAgentSchedulesIdCallbackArgs = {id: string, body: {session_id: string, attempt_id: string, status: 'success' | 'failure' | 'unknown', executed_at?: string | undefined, error_message?: (string | null) | undefined}}; export type CreateApiApiAgentSchedulesIdCallbackOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * callback * * POST /api/agent_schedules/{id}/callback */ export const createApiApiAgentSchedulesIdCallback = async (args: CreateApiApiAgentSchedulesIdCallbackArgs, options?: CreateApiApiAgentSchedulesIdCallbackOptions) => { const {baseUrl = "https://llm-api.treasuredata.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") if (ApiKeyAuth !== undefined) headers.set('authorization', `TD1 ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/agent_schedules/${encodeURIComponent(String(args.id))}/callback${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };