{"version":3,"file":"fetch.mjs","names":[],"sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { AgentDependencies } from '../agent/AgentDependencies'\n\nexport async function fetchWithTimeout(\n  fetch: AgentDependencies['fetch'],\n  url: string,\n  init?: Omit<RequestInit, 'signal'> & {\n    /**\n     * @default 5000\n     */\n    timeoutMs?: number\n  }\n) {\n  const abortController = new AbortController()\n  const timeoutMs = init?.timeoutMs ?? 5000\n\n  const timeout = setTimeout(() => abortController.abort(), timeoutMs)\n\n  try {\n    return await fetch(url, {\n      ...init,\n      signal: abortController.signal as NonNullable<RequestInit['signal']>,\n    })\n  } finally {\n    clearTimeout(timeout)\n  }\n}\n"],"mappings":";;;AAEA,eAAsB,iBACpB,OACA,KACA,MAMA;CACA,MAAM,kBAAkB,IAAI,iBAAiB;CAC7C,MAAM,YAAY,MAAM,aAAa;CAErC,MAAM,UAAU,iBAAiB,gBAAgB,OAAO,EAAE,UAAU;AAEpE,KAAI;AACF,SAAO,MAAM,MAAM,KAAK;GACtB,GAAG;GACH,QAAQ,gBAAgB;GACzB,CAAC;WACM;AACR,eAAa,QAAQ"}