Skip to content
Français

createObservation

import { createObservation } from "@elie-laloum/outpost/core";

Create a reusable observation client with optional persistence and borrowed sinks. Dispatch and workflow engines open independent tracking sessions and close them on settlement; the client exposes readRun and watchRun for the same transport. Construction performs no storage writes or execution. Sessions use separate event sequences, and checkpoint resumes preserve persistent cursors. close() waits for active sessions without cancelling execution. Low-level hubs and standalone readers remain compatible.

Complete example and detailed rules.

  • optionsOptional
    ObservationOptions | undefined
    Optional delivery, redaction, sink and persistence settings. With no transport, only in-memory observation is enabled. Sinks and transport are borrowed; no run is started by construction.
  • options.transporterOptional
    Transport | undefined
    Optional caller-owned transport for run snapshots and events under runs/<id>/. Execution engines register and close tracking sessions; constructing a client or reading never creates records. Without it, readRun and watchRun refuse.
  • options.heartbeatMsOptional
    number | undefined
    Tracking heartbeat interval in milliseconds, default 5000, a positive safe integer within the timer range. Applies only to recorded running executions.
  • options.abandonAfterMsOptional
    number | undefined
    Heartbeat expiry delay in milliseconds, default 30000; must exceed heartbeatMs. Expiry reports suspected abandonment on read, never recovery authorization.
  • options.redactOptional
    readonly RegExp[] | undefined
    Regular expressions applied recursively to event strings, keys and scope strings before delivery. Each rule replaces all matches; its lastIndex is preserved.
  • options.sinksOptional
    readonly ObservationSink[] | undefined
    Receivers attached to this root and inherited by every child.
  • options.scopeOptional
    ObservationScope | undefined
    Initial correlation fields; child scopes override only explicitly supplied fields.
  • options.capacityOptional
    number | undefined
    Maximum events waiting per asynchronous sink, default 1024; on overflow the newest are dropped and counted. A value that is not a positive integer throws.
  • options.deliveryTimeoutMsOptional
    number | undefined
    Maximum wait for one asynchronous delivery or sink flush, default 5000; a sink that exceeds it is disabled for the hub’s lifetime. A value that is not a positive integer throws.
  • options.verboseOptional
    boolean | undefined
    Explicitly allow full model request/response events. Does not enable verbose journal retention by itself.

ObservationClient

export declare function createObservation(
  options?: ObservationOptions,
): ObservationClient;