Skip to content
Français

ObservationClient

import type { ObservationClient } from "@elie-laloum/outpost/core";
  • flushRequired
    () => Promise<void>
    Flush in-memory delivery and active tracking sessions without closing them. Delivery remains bounded; failures and dropped events remain observable.
  • closeRequired
    () => Promise<void>
    Prevent new sessions, wait for active sessions owned by this client or its children, then flush and close in-memory delivery. Idempotent. Does not cancel execution or close borrowed sinks, transport or telemetry SDKs. Readers remain usable.
  • readRunRequired
    (id: string, options?: ObservationReadOptions) => Promise<RunSnapshot | undefined>
    Read the snapshot for id with optional signal and maxBytes; returns undefined when absent. Requires the configured transport. Expired running snapshots are reported abandoned without modifying storage.
  • watchRunRequired
    (id: string, options?: ObservationWatchOptions) => AsyncIterable<RunEvent>
    Follow persisted events for id after options.from (default 0), polling until settled or expired. Supports signal, pollMs and maxBytes. Cancellation stops reading only. The record must exist; missing events and invalid cursors fail explicitly.
  • [Symbol.asyncDispose]Required
    () => Promise<void>
    Await close(): stop accepting new executions, wait for active tracking sessions and flush delivery. Does not cancel executions or close borrowed sinks and transport.
  • redactingRequired
    boolean
    True when this scope has any redaction rules, including inherited ones. Conversation capture uses it to refuse unsupported binary filtering only when enabled.
  • scopeRequired
    ObservationScope
    Immutable correlation fields inherited by emissions from this hub.
  • errorsRequired
    readonly unknown[]
    Shared bounded collection of sink, serialization, overflow and timeout errors; retains the first 100 failures independently of execution.
  • droppedRequired
    number
    Shared count of delivery losses across sinks, including overflow and disabled receivers.
  • verboseRequired
    boolean
    Whether producers may emit full model request and response payloads; journal retention is configured separately.
  • redactRequired
    <T>(value: T) => T
    Copy a structured value and apply this scope’s masking rules without mutating the original. Used by transcript storage before serializing records.
  • emitRequired
    (source: ObservationSource, event: ObservationEvent) => void
    Stamps an event with seq, timestamp, source and this hub’s scope, then delivers a copy to inherited and local sinks. Does nothing after close(); sink failures go to errors, never thrown.
  • childRequired
    (scope: ObservationScope, sinks?: readonly ObservationSink[], redact?: readonly RegExp[]) => ObservationHub
    Create a child scope inheriting sinks and redaction rules; optional additional sinks and regular expressions apply before all inherited and local receivers. Closing the child flushes its deliveries without closing the parent.
export interface ObservationClient extends ObservationHub {
  flush(): Promise<void>;
  close(): Promise<void>;
  readRun(
    id: string,
    options?: ObservationReadOptions,
  ): Promise<RunSnapshot | undefined>;
  watchRun(
    id: string,
    options?: ObservationWatchOptions,
  ): AsyncIterable<RunEvent>;
  [Symbol.asyncDispose](): Promise<void>;
}