Skip to content
Français

createCustomReporter

import { createCustomReporter } from "@elie-laloum/outpost/observation";

Create an observe callback that routes each agent observation to the handler for its kind. Handlers run one at a time on a bounded queue without blocking the dispatch; flush() waits for them and rejects with the first handler failure. The caller owns any files or loggers the handlers use. The returned callable also implements ObservationSink for direct composition through createObservation({ sinks }).

Complete example and detailed rules.

  • handlersRequired
    ReporterHandlers
    Handlers keyed by agent event kind, run one at a time in arrival order; kinds without a handler are ignored.
  • optionsOptional
    CustomReporterOptions | undefined
    Error diagnostics for the custom reporter; no terminal output or resource ownership is added.
  • options.capacityOptional
    number | undefined
    Maximum waiting events in the reporter queue, default 1024; overflow drops newest deliveries and makes flush reject.
  • options.deliveryTimeoutMsOptional
    number | undefined
    Maximum asynchronous handler wait in milliseconds, default 5000; timeout disables further deliveries and makes flush reject.
  • options.onErrorOptional
    ((error: unknown, event: AgentObservation) => void | Promise<void>) | undefined
    Called for each failed handler with its error and event; diagnostic failures are isolated and the first handler failure remains observable through flush().

CustomReporter

export declare function createCustomReporter(
  handlers: ReporterHandlers,
  options?: CustomReporterOptions,
): CustomReporter;