import { AmplitudeLike } from "./types.js";
import { AsyncLocalStorage } from "node:async_hooks";

//#region src/context.d.ts
interface SessionContextOptions {
  sessionId: string;
  traceId?: string | null;
  userId?: string | null;
  agentId?: string | null;
  parentAgentId?: string | null;
  env?: string | null;
  customerOrgId?: string | null;
  agentVersion?: string | null;
  description?: string | null;
  context?: Record<string, unknown> | null;
  groups?: Record<string, unknown> | null;
  tags?: string[] | null;
  idleTimeoutMinutes?: number | null;
  deviceId?: string | null;
  browserSessionId?: string | null;
  nextTurnIdFn?: (() => number) | null;
  amplitude?: AmplitudeLike | null;
  trackerManaged?: boolean;
  skipAutoUserTracking?: boolean;
}
declare class SessionContext {
  readonly sessionId: string;
  traceId: string | null;
  readonly userId: string | null;
  readonly agentId: string | null;
  readonly parentAgentId: string | null;
  readonly env: string | null;
  readonly customerOrgId: string | null;
  readonly agentVersion: string | null;
  readonly description: string | null;
  readonly context: Record<string, unknown> | null;
  readonly groups: Record<string, unknown> | null;
  readonly tags: string[] | null;
  readonly idleTimeoutMinutes: number | null;
  readonly deviceId: string | null;
  readonly browserSessionId: string | null;
  readonly amplitude: AmplitudeLike | null;
  readonly trackerManaged: boolean;
  readonly skipAutoUserTracking: boolean;
  private readonly _nextTurnIdFn;
  constructor(options: SessionContextOptions);
  nextTurnId(): number | null;
}
declare const _sessionStorage: AsyncLocalStorage<SessionContext | null>;
declare function getActiveContext(): SessionContext | null;
/**
 * Return `true` when a higher-level tracker (e.g. `AgentAnalyticsTracker`)
 * owns event emission for this context.
 *
 * `patch()` provider wrappers check this to avoid duplicate events.
 */
declare function isTrackerManaged(): boolean;
declare function runWithContext<T>(ctx: SessionContext, fn: () => T): T;
declare function runWithContextAsync<T>(ctx: SessionContext, fn: () => Promise<T>): Promise<T>;
/**
 * Set the active SessionContext for the current async scope.
 *
 * Returns a cleanup function that restores the previous context.
 * Use this in middleware or interceptors where the context must outlive
 * the call frame that created it.
 *
 * For scoped usage, prefer `agent.session()` (callback-based) or
 * `runWithContext()`.
 */
declare function pushContext(ctx: SessionContext | null): () => void;
//#endregion
export { SessionContext, SessionContextOptions, _sessionStorage, getActiveContext, isTrackerManaged, pushContext, runWithContext, runWithContextAsync };
//# sourceMappingURL=context.d.ts.map