export type SessionType = 'agent' | 'team' | 'workflow'; export type DeleteSessionRequest = {session_ids: Array, session_types: Array}; export type DeleteApiSessionsArgs = {user_id?: (string | null) | undefined, db_id?: (string | null) | undefined, table?: (string | null) | undefined, body: DeleteSessionRequest}; export type DeleteApiSessionsOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete Multiple Sessions * * DELETE /sessions */ export const deleteApiSessions = async (args: DeleteApiSessionsArgs, options: DeleteApiSessionsOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.db_id != null) query.append("db_id", String(args.db_id)) if (args.table != null) query.append("table", String(args.table)) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/sessions${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", 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 };