/**
 * SDKObserver — first-class observability hooks for the GoodVibes SDK.
 *
 * Consumers can implement any subset of `SDKObserver` and pass the instance
 * via the `observer` option on supported client factories. All methods are
 * optional; the SDK works identically whether an observer is present or not.
 *
 * Observer call sites are wrapped through `invokeObserver`: an observer that
 * throws will not propagate into SDK logic. Failures are reported and returned
 * so observer isolation does not hide broken callbacks.
 *
 * @example
 * const sdk = createGoodVibesSdk({
 *   baseUrl: 'https://daemon.example.com',
 *   tokenStore: createMemoryTokenStore(),
 *   observer: createConsoleObserver({ level: 'debug' }),
 * });
 */
/** OpenTelemetry SpanStatusCode.ERROR. Use in custom observer implementations with `span.setStatus({ code: SPAN_STATUS_ERROR })`. */
export declare const SPAN_STATUS_ERROR: 2;
import type { GoodVibesSdkError } from '@pellux/goodvibes-errors';
import type { AnyRuntimeEvent } from '../events/domain-map.js';
import type { TransportObserver, TransportActivityInfo } from '@pellux/goodvibes-transport-core';
export type { AnyRuntimeEvent };
/**
 * The auth state kind used in transition notifications.
 * - `'anonymous'` — no credentials present
 * - `'session'` — session-cookie or short-lived token
 * - `'token'` — long-lived bearer token
 */
export type AuthStateKind = 'anonymous' | 'session' | 'token';
/**
 * The reason an auth transition occurred.
 */
export type AuthTransitionReason = 'login' | 'logout' | 'refresh' | 'expire' | 'revoke';
/**
 * Re-export TransportActivityInfo from transport-core so SDK consumers
 * don't need to import from an internal package.
 */
export type { TransportActivityInfo } from '@pellux/goodvibes-transport-core';
/**
 * Auth transition metadata surfaced to the observer.
 */
export interface AuthTransitionInfo {
    readonly from: AuthStateKind;
    readonly to: AuthStateKind;
    readonly reason: AuthTransitionReason;
}
/**
 * Optional observer interface. Implement any subset of methods and pass the
 * instance to a supported client factory. All methods are optional.
 *
 * Every call site should go through `invokeObserver` so observer errors are
 * isolated from SDK control flow while remaining observable.
 */
export interface SDKObserver extends TransportObserver {
    /**
     * Called for every event dispatched through the realtime transport
     * (SSE or WebSocket). Receives the fully-typed runtime event payload.
     *
     * Wired as of 0.19.7 — fires on every envelope dispatched through
     * `createEventSourceConnector` and `createWebSocketConnector`.
     */
    onEvent?(event: AnyRuntimeEvent): void;
    /**
     * Called when the SDK catches and is about to rethrow a GoodVibesSdkError.
     * The error is still rethrown; this is notification only.
     *
     * Wired as of 0.19.7 — fires at every `GoodVibesSdkError` throw site in
     * the transport and auth layers before the error propagates to the caller.
     */
    onError?(err: GoodVibesSdkError): void;
    /**
     * Called at HTTP/SSE/WebSocket transport boundaries.
     * - `'send'` fires before the request is dispatched.
     * - `'recv'` fires after a response is received (with status + duration).
     *
     * Wired as of 0.19.7 — fires in `transport-http` request/response boundary
     * and in realtime connect/message boundaries.
     */
    onTransportActivity?(activity: TransportActivityInfo): void;
    /**
     * Called when the SDK's auth state transitions (login, logout, token
     * refresh, expiry, or revocation).
     */
    onAuthTransition?(transition: AuthTransitionInfo): void;
}
/**
 * Result returned from a protected observer callback invocation.
 */
export type ObserverInvocationResult = {
    readonly ok: true;
} | {
    readonly ok: false;
    readonly error: unknown;
};
export interface InvokeObserverOptions {
    /**
     * Optional callback label included in failure logs.
     */
    readonly label?: string | undefined;
    /**
     * Set to false when a caller handles a failed result itself and does not want
     * the default warning.
     */
    readonly report?: boolean | undefined;
}
/**
 * Safely invoke an observer method. Observer errors are isolated so they
 * never disrupt SDK control flow, but failures are returned and logged by
 * default. This is the canonical call pattern for all observer call sites
 * throughout the SDK.
 *
 * @param fn - Zero-argument thunk wrapping the observer call.
 */
export declare function invokeObserver(fn: () => void, options?: InvokeObserverOptions): ObserverInvocationResult;
export interface ConsoleObserverOptions {
    /** Minimum log level. Defaults to `'info'`. */
    readonly level?: 'debug' | 'info' | undefined;
}
/**
 * Create a development-friendly observer that logs SDK activity to the console.
 *
 * Use `level: 'debug'` to also log transport activity and every runtime event.
 *
 * @example
 * const sdk = createGoodVibesSdk({
 *   baseUrl: '...',
 *   observer: createConsoleObserver({ level: 'debug' }),
 * });
 */
export declare function createConsoleObserver(options?: ConsoleObserverOptions): SDKObserver;
/**
 * Accept-only OpenTelemetry types so we don't add a hard dependency on
 * `@opentelemetry/*`. Consumers bring their own tracer and meter.
 */
export interface OtelTracer {
    startActiveSpan<F extends (span: OtelSpan) => unknown>(name: string, fn: F): ReturnType<F>;
    startSpan(name: string, options?: unknown): OtelSpan;
}
export interface OtelSpan {
    setAttribute(key: string, value: string | number | boolean): this;
    setStatus(status: {
        code: number;
        message?: string;
    }): this;
    recordException(error: Error | unknown): this;
    end(): void;
}
export interface OtelMeter {
    createCounter(name: string, options?: {
        description?: string;
    }): OtelCounter;
    createHistogram(name: string, options?: {
        description?: string;
        unit?: string;
    }): OtelHistogram;
}
export interface OtelCounter {
    add(value: number, attributes?: Record<string, string | number | boolean>): void;
}
export interface OtelHistogram {
    record(value: number, attributes?: Record<string, string | number | boolean>): void;
}
/**
 * Create an observer that emits OpenTelemetry spans and metrics.
 *
 * Pass a pre-configured `Tracer` and `Meter` from your OpenTelemetry SDK setup.
 * This adapter has no hard dependency on `@opentelemetry/*` — it accepts the
 * abstractions defined above, which match the subset of the real
 * OpenTelemetry API.
 *
 * @example
 * import { trace, metrics } from '@opentelemetry/api';
 *
 * const observer = createOpenTelemetryObserver(
 *   trace.getTracer('goodvibes-sdk'),
 *   metrics.getMeter('goodvibes-sdk'),
 * );
 * const sdk = createGoodVibesSdk({ baseUrl: '...', observer });
 */
export declare function createOpenTelemetryObserver(tracer: OtelTracer, meter: OtelMeter): SDKObserver;
//# sourceMappingURL=index.d.ts.map