import { PrivacyConfig } from "./core/privacy.js";
import { AmplitudeLike } from "./types.js";

//#region src/decorators.d.ts

declare class ToolCallTracker {
  static _amplitude: AmplitudeLike | null;
  static _userId: string | null;
  static _sessionId: string | null;
  static _traceId: string | null;
  static _turnId: number;
  static _env: string | null;
  static _agentId: string | null;
  static _parentAgentId: string | null;
  static _customerOrgId: string | null;
  static _agentVersion: string | null;
  static _context: Record<string, unknown> | null;
  static _privacyConfig: PrivacyConfig | null;
  static _eventProperties: Record<string, unknown> | null;
  static _userProperties: Record<string, unknown> | null;
  static _groups: Record<string, unknown> | null;
  static setAmplitude(amplitude: AmplitudeLike, userId: string, opts?: {
    sessionId?: string | null;
    traceId?: string | null;
    turnId?: number;
    env?: string | null;
    agentId?: string | null;
    parentAgentId?: string | null;
    customerOrgId?: string | null;
    agentVersion?: string | null;
    context?: Record<string, unknown> | null;
    privacyConfig?: PrivacyConfig | null;
    eventProperties?: Record<string, unknown> | null;
    userProperties?: Record<string, unknown> | null;
    groups?: Record<string, unknown> | null;
  }): void;
  static clear(): void;
  static isConfigured(): boolean;
}
interface ToolOptions {
  name?: string;
  toolType?: string | null;
  toolOwner?: string | null;
  amplitude?: AmplitudeLike | null;
  userId?: string | null;
  sessionId?: string | null;
  traceId?: string | null;
  turnId?: number | null;
  env?: string | null;
  agentId?: string | null;
  parentAgentId?: string | null;
  customerOrgId?: string | null;
  agentVersion?: string | null;
  context?: Record<string, unknown> | null;
  privacyConfig?: PrivacyConfig | null;
  eventProperties?: Record<string, unknown> | null;
  userProperties?: Record<string, unknown> | null;
  groups?: Record<string, unknown> | null;
  inputSchema?: Record<string, unknown> | null;
  timeoutMs?: number | null;
  onError?: ((error: Error, toolName: string) => void) | null;
}
type AnyFn = (...args: any[]) => any;
/**
 * Converts a function's return type to Promise-wrapped if not already.
 * Reflects the fact that tool() always returns an async wrapper.
 */
type ToolWrapped<T extends AnyFn> = T extends ((...args: infer A) => infer R) ? R extends Promise<unknown> ? (...args: A) => R : (...args: A) => Promise<R> : T;
/**
 * Wraps a function and emits one `[Agent] Tool Call` event per invocation.
 *
 * Supports both forms:
 * - `tool(fn, opts?)`
 * - `tool(opts)(fn)`
 *
 * Resolution order for tracking context is:
 * runtime overrides > decorator opts > active session context > `ToolCallTracker`.
 * If tracking is not configured (`amplitude`/`userId` missing), the wrapped function
 * still executes and no tracking event is emitted.
 */
declare function tool<T extends AnyFn>(fn: T, opts?: ToolOptions): ToolWrapped<T>;
declare function tool(opts: ToolOptions): <T extends AnyFn>(fn: T) => ToolWrapped<T>;
type ObserveSpanType = 'span' | 'tool' | 'agent' | 'llm';
interface ObserveOptions {
  name?: string;
  type?: ObserveSpanType;
  amplitude?: AmplitudeLike | null;
  userId?: string | null;
  agentId?: string | null;
  env?: string | null;
  privacyConfig?: PrivacyConfig | null;
}
/**
 * Converts a function's return type to Promise-wrapped if not already.
 * Reflects the fact that observe() always returns an async wrapper.
 */
type ObserveWrapped<T extends AnyFn> = T extends ((...args: infer A) => infer R) ? R extends Promise<unknown> ? (...args: A) => R : (...args: A) => Promise<R> : T;
/**
 * Wraps a function and emits one `[Agent] Span` event per invocation.
 *
 * Supports both forms:
 * - `observe(fn, opts?)`
 * - `observe(opts)(fn)`
 *
 * If called inside an active session context, spans attach to that session.
 * If no context is active, observe creates a short-lived session boundary and
 * emits a session-end event when the wrapped function completes.
 */
declare function observe<T extends AnyFn>(fn: T, opts?: ObserveOptions): ObserveWrapped<T>;
declare function observe(opts: ObserveOptions): <T extends AnyFn>(fn: T) => ObserveWrapped<T>;
//#endregion
export { ObserveSpanType, ObserveWrapped, ToolCallTracker, ToolWrapped, observe, tool };
//# sourceMappingURL=decorators.d.ts.map