{"version":3,"sources":["/Users/shyun/comcom/ain-enterprise/ain-adk/dist/cjs/chunk-3R5V2PEO.cjs","../../src/utils/request-context.ts"],"names":[],"mappings":"AAAA;ACAA,0CAAkC;AAclC,IAAM,QAAA,EAAU,IAAI,mCAAA,CAAkC,CAAA;AAM/C,IAAM,sBAAA,EAAwB,CACpC,OAAA,EACA,EAAA,EAAA,GACO,OAAA,CAAQ,GAAA,CAAI,OAAA,EAAS,EAAE,CAAA;AAGxB,IAAM,kBAAA,EAAoB,CAAA,EAAA,GAChC,OAAA,CAAQ,QAAA,CAAS,CAAA;AAMX,IAAM,qBAAA,EAAuB,CACnC,KAAA,EAAA,GACU;AACV,EAAA,MAAM,MAAA,EAAQ,OAAA,CAAQ,QAAA,CAAS,CAAA;AAC/B,EAAA,GAAA,CAAI,KAAA,EAAO,MAAA,CAAO,MAAA,CAAO,KAAA,EAAO,KAAK,CAAA;AACtC,CAAA;AD7BA;AACA;AACE;AACA;AACA;AACF,0JAAC","file":"/Users/shyun/comcom/ain-enterprise/ain-adk/dist/cjs/chunk-3R5V2PEO.cjs","sourcesContent":[null,"import { AsyncLocalStorage } from \"node:async_hooks\";\n\n/**\n * Ambient per-request context carried across async boundaries via\n * AsyncLocalStorage. Loggers read from it so every log line can be\n * correlated to a request without threading IDs through parameters.\n */\nexport interface RequestContext {\n\t/** Correlation ID: one per HTTP request (or per scheduled run). */\n\trequestId: string;\n\tuserId?: string;\n\tthreadId?: string;\n}\n\nconst storage = new AsyncLocalStorage<RequestContext>();\n\n/**\n * Runs `fn` with `context` as the ambient request context. Everything in\n * the async call tree of `fn` (awaits, promises, timers) sees the context.\n */\nexport const runWithRequestContext = <T>(\n\tcontext: RequestContext,\n\tfn: () => T,\n): T => storage.run(context, fn);\n\n/** Returns the ambient context, or undefined outside of one. */\nexport const getRequestContext = (): RequestContext | undefined =>\n\tstorage.getStore();\n\n/**\n * Merges fields into the current context (e.g. userId after auth,\n * threadId once resolved). No-op when called outside of a context.\n */\nexport const updateRequestContext = (\n\tpatch: Partial<Omit<RequestContext, \"requestId\">>,\n): void => {\n\tconst store = storage.getStore();\n\tif (store) Object.assign(store, patch);\n};\n"]}