import { Dt as TelemetryAttributes, Et as TelemetryArtifactAttachment, Ot as TelemetryMetricRecord, kt as TelemetrySpanEventRecord } from "./ItemsInputNormalizer-CFkfNMLt.js";

//#region src/domain/telemetry/TelemetryContracts.d.ts
type TelemetrySpanStatus = "running" | "completed" | "failed";
type TelemetrySpanKind = "internal" | "client";
interface TelemetryTraceContext {
  readonly runId: string;
  readonly workflowId: string;
  readonly traceId: string;
  readonly rootSpanId: string;
  readonly serviceName?: string;
  readonly createdAt: string;
  readonly expiresAt?: string;
}
interface TelemetrySpanRecord {
  readonly traceId: string;
  readonly spanId: string;
  readonly parentSpanId?: string;
  readonly runId: string;
  readonly workflowId: string;
  readonly nodeId?: string;
  readonly activationId?: string;
  readonly connectionInvocationId?: string;
  readonly name: string;
  readonly kind: TelemetrySpanKind;
  readonly status?: TelemetrySpanStatus;
  readonly statusMessage?: string;
  readonly startTime?: string;
  readonly endTime?: string;
  readonly workflowFolder?: string;
  readonly nodeType?: string;
  readonly nodeRole?: string;
  readonly modelName?: string;
  readonly attributes?: TelemetryAttributes;
  readonly events?: ReadonlyArray<TelemetrySpanEventRecord>;
  readonly retentionExpiresAt?: string;
  readonly iterationId?: string;
  readonly itemIndex?: number;
  readonly parentInvocationId?: string;
}
interface TelemetrySpanUpsert {
  readonly traceId: string;
  readonly spanId: string;
  readonly parentSpanId?: string;
  readonly runId: string;
  readonly workflowId: string;
  readonly nodeId?: string;
  readonly activationId?: string;
  readonly connectionInvocationId?: string;
  readonly name?: string;
  readonly kind?: TelemetrySpanKind;
  readonly status?: TelemetrySpanStatus;
  readonly statusMessage?: string;
  readonly startTime?: string;
  readonly endTime?: string;
  readonly workflowFolder?: string;
  readonly nodeType?: string;
  readonly nodeRole?: string;
  readonly modelName?: string;
  readonly attributes?: TelemetryAttributes;
  readonly events?: ReadonlyArray<TelemetrySpanEventRecord>;
  readonly retentionExpiresAt?: string;
  readonly iterationId?: string;
  readonly itemIndex?: number;
  readonly parentInvocationId?: string;
}
interface TelemetryArtifactRecord {
  readonly artifactId: string;
  readonly traceId: string;
  readonly spanId: string;
  readonly runId: string;
  readonly workflowId: string;
  readonly nodeId?: string;
  readonly activationId?: string;
  readonly kind: string;
  readonly contentType: string;
  readonly previewText?: string;
  readonly previewJson?: unknown;
  readonly payloadText?: string;
  readonly payloadJson?: unknown;
  /** Set when the payload was offloaded to BinaryStorage (byteLength > 64 KB). */
  readonly payloadStorageKey?: string;
  readonly bytes?: number;
  readonly truncated?: boolean;
  readonly createdAt: string;
  readonly expiresAt?: string;
  readonly retentionExpiresAt?: string;
}
interface TelemetryArtifactWrite extends TelemetryArtifactAttachment {
  readonly traceId: string;
  readonly spanId: string;
  readonly runId: string;
  readonly workflowId: string;
  readonly nodeId?: string;
  readonly activationId?: string;
  readonly retentionExpiresAt?: string;
}
interface TelemetryMetricPointRecord {
  readonly metricPointId: string;
  readonly traceId?: string;
  readonly spanId?: string;
  readonly runId?: string;
  readonly workflowId: string;
  readonly nodeId?: string;
  readonly activationId?: string;
  readonly metricName: string;
  readonly value: number;
  readonly unit?: string;
  readonly observedAt: string;
  readonly workflowFolder?: string;
  readonly nodeType?: string;
  readonly nodeRole?: string;
  readonly modelName?: string;
  readonly dimensions?: TelemetryAttributes;
  readonly retentionExpiresAt?: string;
  readonly iterationId?: string;
  readonly itemIndex?: number;
  readonly parentInvocationId?: string;
}
interface TelemetryMetricPointWrite extends TelemetryMetricRecord {
  readonly traceId?: string;
  readonly spanId?: string;
  readonly runId?: string;
  readonly workflowId: string;
  readonly nodeId?: string;
  readonly activationId?: string;
  readonly observedAt: string;
  readonly workflowFolder?: string;
  readonly nodeType?: string;
  readonly nodeRole?: string;
  readonly modelName?: string;
  readonly retentionExpiresAt?: string;
  readonly iterationId?: string;
  readonly itemIndex?: number;
  readonly parentInvocationId?: string;
}
interface TelemetrySpanListQuery {
  readonly traceId?: string;
  readonly runId?: string;
  readonly runIds?: ReadonlyArray<string>;
  readonly workflowId?: string;
  readonly workflowIds?: ReadonlyArray<string>;
  readonly statuses?: ReadonlyArray<TelemetrySpanStatus>;
  readonly names?: ReadonlyArray<string>;
  readonly modelNames?: ReadonlyArray<string>;
  readonly startTimeGte?: string;
  readonly endTimeLte?: string;
  readonly limit?: number;
}
interface TelemetryMetricPointListQuery {
  readonly traceId?: string;
  readonly runId?: string;
  readonly runIds?: ReadonlyArray<string>;
  readonly workflowId?: string;
  readonly workflowIds?: ReadonlyArray<string>;
  readonly nodeId?: string;
  readonly metricNames?: ReadonlyArray<string>;
  readonly modelNames?: ReadonlyArray<string>;
  readonly observedAtGte?: string;
  readonly observedAtLte?: string;
  readonly limit?: number;
}
interface TelemetryPruneArgs {
  readonly nowIso: string;
  readonly limit?: number;
}
interface RunTraceContextRepository {
  load(runId: string): Promise<TelemetryTraceContext | undefined>;
  getOrCreate(args: Readonly<{
    runId: string;
    workflowId: string;
    serviceName?: string;
  }>): Promise<TelemetryTraceContext>;
  upsertExpiry(args: Readonly<{
    runId: string;
    expiresAt?: string;
  }>): Promise<void>;
}
interface TelemetrySpanStore {
  upsert(record: TelemetrySpanUpsert): Promise<void>;
  list(args?: TelemetrySpanListQuery): Promise<ReadonlyArray<TelemetrySpanRecord>>;
  listByTraceId(traceId: string): Promise<ReadonlyArray<TelemetrySpanRecord>>;
  pruneExpired(args: TelemetryPruneArgs): Promise<number>;
}
interface TelemetryArtifactStore {
  save(record: TelemetryArtifactWrite): Promise<TelemetryArtifactRecord>;
  listByTraceId(traceId: string): Promise<ReadonlyArray<TelemetryArtifactRecord>>;
  /**
   * Deletes expired artifacts. Returns the count of deleted rows and any
   * `payloadStorageKey` references that callers must clean up from BinaryStorage.
   */
  pruneExpired(args: TelemetryPruneArgs): Promise<{
    count: number;
    storageKeys: ReadonlyArray<string>;
  }>;
}
interface TelemetryMetricPointStore {
  save(record: TelemetryMetricPointWrite): Promise<TelemetryMetricPointRecord>;
  list(args?: TelemetryMetricPointListQuery): Promise<ReadonlyArray<TelemetryMetricPointRecord>>;
  pruneExpired(args: TelemetryPruneArgs): Promise<number>;
}
interface TelemetryExporter {
  exportSpans(spans: ReadonlyArray<TelemetrySpanRecord>): Promise<void>;
}
//#endregion
export { TelemetrySpanStatus as a, TelemetryMetricPointStore as i, TelemetryArtifactStore as n, TelemetrySpanStore as o, TelemetryExporter as r, TelemetrySpanUpsert as s, RunTraceContextRepository as t };
//# sourceMappingURL=TelemetryContracts-DpZEODQM.d.ts.map