import { TraceSpanEvent, HostedClient } from '../hosted/index.js';
import '../types-D9tuReDv.js';
import '../run-record-CP2ObebC.js';
import '@tangle-network/agent-interface';
import '../errors-CzMUYo7b.js';
import '../schema-m0gsnbt3.js';
import '../insight-report-BnRjTibG.js';
import '../summary-report-CInXwsza.js';
import '../failure-cluster-DH9Flgcf.js';
import '../store-BcFXE6LG.js';
import '../judge-calibration-0p2QcWNE.js';

/**
 * # `@tangle-network/agent-eval/adapters/otel` — OTel→hosted bridge.
 *
 * Forwards OpenTelemetry-shaped spans into the hosted-tier ingest endpoint
 * via `createHostedClient`. Works with anything that emits OTel
 * `ReadableSpan`s — `@opentelemetry/sdk-trace-base` directly, OpenLLMetry,
 * Phoenix's OTel exporter, TraceAI from future-agi, any OTel collector
 * pipeline.
 *
 * **Pattern:**
 *
 *   ```ts
 *   import { createHostedClient } from '@tangle-network/agent-eval/hosted'
 *   import { createOtelBridge } from '@tangle-network/agent-eval/adapters/otel'
 *
 *   const client = createHostedClient({ endpoint, apiKey, tenantId })
 *   const bridge = createOtelBridge({ client, defaultRunId: substrateRunId })
 *
 *   // Wherever your OTel SpanProcessor hands you a finished span:
 *   processor.onEnd = (span) => { void bridge.ingest([span]) }
 *   // …or in a SpanProcessor.onShutdown / batch flush:
 *   await bridge.ingest(batchedSpans)
 *   ```
 *
 * No `@opentelemetry/*` dependency is declared here — the adapter accepts
 * a structurally-typed `OtelLikeSpan`. This keeps the substrate dep graph
 * lean while remaining compatible with any OTel SDK that produces
 * `ReadableSpan`-shaped instances. If a consumer's span shape exposes
 * `parentSpanId` as a top-level field rather than via `parentSpanContext()`,
 * the adapter accepts both forms.
 */

/**
 * `[seconds, nanoseconds]` — the OTel SDK's `HrTime` shape. Spans emitted
 * by the OTel SDK carry timestamps in this representation; we convert to
 * a single unix-nano number for the wire format.
 */
type HrTime = [number, number];
/** Standard OTel `SpanStatusCode` numeric values: 0 = UNSET, 1 = OK, 2 = ERROR. */
declare const OTEL_STATUS_UNSET = 0;
declare const OTEL_STATUS_OK = 1;
declare const OTEL_STATUS_ERROR = 2;
type OtelAttributeValue = string | number | boolean | null | undefined | Array<string> | Array<number> | Array<boolean>;
/**
 * Structural surface compatible with `@opentelemetry/sdk-trace-base`'s
 * `ReadableSpan`. Consumers pass instances they get from their OTel SDK.
 */
interface OtelLikeSpan {
    spanContext: () => {
        traceId: string;
        spanId: string;
        traceFlags?: number;
    };
    /** Set on the span itself by some SDKs (OTLP-shape). Other SDKs expose
     *  the parent via `parentSpanContext()` instead — the adapter checks both. */
    parentSpanId?: string;
    parentSpanContext?: () => {
        spanId: string;
    } | undefined;
    name: string;
    startTime: HrTime;
    endTime: HrTime;
    attributes: Record<string, OtelAttributeValue>;
    events?: Array<{
        name: string;
        time: HrTime;
        attributes?: Record<string, OtelAttributeValue>;
    }>;
    status?: {
        code: number;
        message?: string;
    };
}
/** `[seconds, nanoseconds]` → unix-nano number. */
declare function hrTimeToUnixNano(hr: HrTime): number;
interface OtelBridgeOptions {
    /** Hosted client to forward spans to. */
    client: HostedClient;
    /** When set, spans missing a `tangle.runId` attribute receive this value
     *  on the way out. Useful when the OTel emitter doesn't know which
     *  substrate run it's serving. */
    defaultRunId?: string;
    /** Max spans per ingest call. Default 200. The hosted ingest endpoint
     *  caps at 5000 per call; we batch smaller by default to keep individual
     *  retries cheap. */
    batchSize?: number;
    /** Called when a batch fails to ingest. Defaults to a console.warn. Hook
     *  this when you need backpressure or to spill to a fallback. */
    onError?: (err: unknown, batch: TraceSpanEvent[]) => void | Promise<void>;
}
interface OtelBridge {
    /** Convert + ingest a batch of OTel-shape spans. */
    ingest(spans: OtelLikeSpan[]): Promise<void>;
    /** Convert one OTel span to the wire-format event. Useful for tests or
     *  custom batching pipelines. */
    spanToEvent(span: OtelLikeSpan): TraceSpanEvent;
}
declare function createOtelBridge(opts: OtelBridgeOptions): OtelBridge;

export { type HrTime, OTEL_STATUS_ERROR, OTEL_STATUS_OK, OTEL_STATUS_UNSET, type OtelAttributeValue, type OtelBridge, type OtelBridgeOptions, type OtelLikeSpan, createOtelBridge, hrTimeToUnixNano };
