{"version":3,"sources":["../../src/telemetry/session_context.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { Context } from '@opentelemetry/api';\nimport { getJobContext } from '../job.js';\nimport type { AgentSession } from '../voice/agent_session.js';\n\ntype SessionWithLoopTelemetry = AgentSession & {\n  _recordLoopStall?: (durationInS: number, timestamp: number, cause: string) => void;\n};\n\n/** The primary agent session in the active job, if one exists. @internal */\nexport function primarySession(): AgentSession | undefined {\n  return getJobContext(false)?._primaryAgentSession;\n}\n\n/** The primary session's root trace context, if the session is running. @internal */\nexport function sessionRootContext(): Context | undefined {\n  return primarySession()?.rootSpanContext;\n}\n\n/** Record a stall on the active session when a session integration is available. @internal */\nexport function recordLoopStall(durationInS: number, timestamp: number, cause: string): void {\n  const session = primarySession();\n  if (!session) return;\n  (session as SessionWithLoopTelemetry)._recordLoopStall?.(durationInS, timestamp, cause);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAA8B;AAQvB,SAAS,iBAA2C;AAZ3D;AAaE,UAAO,mCAAc,KAAK,MAAnB,mBAAsB;AAC/B;AAGO,SAAS,qBAA0C;AAjB1D;AAkBE,UAAO,oBAAe,MAAf,mBAAkB;AAC3B;AAGO,SAAS,gBAAgB,aAAqB,WAAmB,OAAqB;AAtB7F;AAuBE,QAAM,UAAU,eAAe;AAC/B,MAAI,CAAC,QAAS;AACd,GAAC,aAAqC,qBAArC,iCAAwD,aAAa,WAAW;AACnF;","names":[]}