import type { HttpClient } from "../core/http.js"; import type { OneclawResponse } from "../types.js"; export type OtelNodeKind = "agent" | "vault" | "policy" | "connector" | "chain"; export type OtelAgentStatus = "compromised" | "warn" | "suspended" | "ok"; export interface OtelTopologyNode { id: string; kind: OtelNodeKind; label: string; /** Agents only. */ status?: OtelAgentStatus; /** Agents only; absent until the trust engine has scored them. */ trust?: number; } export interface OtelTopologyEdge { from: string; to: string; /** `holds` | `grants` | `signs` | `calls` */ kind: string; } export interface OtelTopology { nodes: OtelTopologyNode[]; edges: OtelTopologyEdge[]; /** True when the 500-node cap applied; `total_nodes` is the pre-cap count. */ truncated: boolean; total_nodes: number; fixture?: boolean; } export interface OtelBlastRadius { vaults: number; connectors: number; chains: number; } export interface OtelThreat { id: string; agent_id: string; class: string; severity: "critical" | "warn"; detected_by: string; status: "open" | "acknowledged" | "resolved"; /** Produced while the trust engine was in recommend-only mode. */ shadow: boolean; evidence: unknown; blast_radius: OtelBlastRadius; blast_radius_size: number; resolved_by: string | null; created_at: string; updated_at: string; } export interface OtelSummary { posture_score: number; open_threats: number; open_critical: number; pending_approvals: number; agent_count: number; top_threats: OtelThreat[]; } export interface OtelMetricBucket { t: string; executions: number; denials: number; transactions: number; llm_calls: number; } export interface OtelMetrics { window: { window_secs: number; step_secs: number; }; buckets: OtelMetricBucket[]; } export interface OtelFlowEdge { agent_id: string; agent_name: string; vault_id: string; vault_name: string; reads: number; distinct_paths: number; } export interface OtelFlows { window: { window_secs: number; step_secs: number; }; edges: OtelFlowEdge[]; total_reads: number; } export interface OtelTrustComponents { denial_rate: number | null; threat_hits: number | null; egress_blocks: number | null; spend_velocity: number | null; off_hours: number | null; consensus_bypass: number | null; } export interface OtelAgentTrust { agent_id: string; /** Null until the engine's first cycle reaches this agent. */ score: number | null; shadow: boolean; updated_at: string | null; /** Null per component means "not measured in this deployment", not zero. */ components: OtelTrustComponents; history: { at: string; score: number; }[]; recent: { at: string; action: string; resource_type: string | null; }[]; } /** One frame from the SSE stream: a signal, or a gap the client must react to. */ export type OtelStreamEvent = { type: "signal"; id: number; signal: OtelSignal; } | { type: "gap"; skipped?: number; missed?: boolean; reconnect_topology?: boolean; }; export interface OtelSignal { event_id: number; resource: { org_id: string; agent_id?: string; agent_name?: string; runtime_id?: string; }; kind?: string; name: string; [key: string]: unknown; } export interface OtelStreamOptions { /** Resume after this event id (sent as `Last-Event-ID`). */ lastEventId?: number; signal?: AbortSignal; } /** * Split accumulated SSE text into complete frames. Returns the parsed frames * and whatever trailing partial frame must be kept for the next chunk. * Comment lines (`:ping`) are dropped. */ export declare function parseSseFrames(buffer: string): { frames: { event: string; id?: string; data: string; }[]; rest: string; }; /** Turn a parsed frame into a stream event, or null for frames the client ignores. */ export declare function frameToEvent(frame: { event: string; id?: string; data: string; }): OtelStreamEvent | null; /** * Consume an SSE response body as stream events. Shared by the org-wide and * the platform-connection streams; the caller opens the request so the * auth and path stay with the resource that owns them. */ export declare function readSseEvents(res: Response): AsyncGenerator; /** Open an SSE request with the client's auth. Throws on a non-2xx status. */ export declare function openSse(http: HttpClient, path: string, opts?: OtelStreamOptions): Promise; export declare class OtelResource { private readonly http; constructor(http: HttpClient); /** Agent, vault, policy, connector and chain graph for the org. */ topology(): Promise>; /** Durable threat register, highest blast radius first. */ threats(state?: "open" | "all"): Promise>; /** Posture score and the counts behind it. */ summary(): Promise>; /** Time-bucketed counts. `window` like `1h`, `24h`, `7d` (max 30d). */ metrics(window?: string, step?: string): Promise>; /** Who actually read from which vault, counted from audit events. */ flows(window?: string): Promise>; /** The components, 24h history and recent actions behind one agent's trust score. */ agentTrust(agentId: string): Promise>; /** * Live signals as an async iterator. Yields `{type: "gap"}` when the * server could not resume from `lastEventId` or the subscriber lagged — * refetch `topology()` when `reconnect_topology` is set. * * ```ts * for await (const ev of client.otel.stream({ signal: ac.signal })) { * if (ev.type === "signal") console.log(ev.signal.name); * } * ``` */ stream(opts?: OtelStreamOptions): AsyncGenerator; } //# sourceMappingURL=otel.d.ts.map