Skip to content
Français

ReporterHandlers

import type { ReporterHandlers } from "@elie-laloum/outpost";
  • stderrOptional
    ((event: { readonly kind: "stderr"; readonly text: string; readonly truncated?: boolean; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives agent stderr line by line, each at most 8192 characters; truncated marks a cut line.
  • model-routeOptional
    ((event: ModelRouteEvent & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Handle the effective model selection for a routed harness step, including its fallback reason and optional confidence.
  • subagentOptional
    ((event: { readonly kind: "subagent"; readonly id: string; readonly callId: string; readonly name: string; readonly status: "started" | "finished" | "failed"; readonly conversation?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a built-in harness subagent start, finish or failure, with the delegating call and the transcript identifier when stored.
  • finishedOptional
    ((event: { readonly kind: "finished"; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the agent’s successful end of turn, before Outpost collects commits and cleans up.
  • message-usageOptional
    ((event: { readonly kind: "message-usage"; readonly tokens: Usage; readonly messageId?: string; readonly parentCallId?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the usage Claude Code reports for each message, with its message and parent call identifiers. It is informational: dispatch usage counts turn totals instead.
  • stoppedOptional
    ((event: { readonly kind: "stopped"; readonly reason: "completion" | "idle-timeout" | "deadline" | "aborted" | "oversized-event" | "steered"; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives why Outpost stopped the agent process: completion, idle-timeout, deadline, aborted, oversized-event or steered.
  • steerOptional
    ((event: { readonly kind: "steer"; readonly text: string; readonly mode: SteeringMode; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a delivered steering instruction and whether it was injected or resumed.
  • reasoningOptional
    ((event: { readonly kind: "reasoning"; readonly text: string; readonly parentCallId?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives readable reasoning text exposed by the agent or model.
  • file-changeOptional
    ((event: { readonly kind: "file-change"; readonly changes: unknown; readonly callId?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives file changes reported by Codex, unmodified.
  • model-requestOptional
    ((event: { readonly kind: "model-request"; readonly request: unknown; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives each built-in harness model request when the hub is verbose; it may contain private instructions.
  • model-responseOptional
    ((event: { readonly kind: "model-response"; readonly response: unknown; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives each built-in harness model response when the hub is verbose.
  • model-retryOptional
    ((event: { readonly kind: "model-retry"; readonly attempt: number; readonly message?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a retry reported by the model provider, with its attempt number and message.
  • model-errorOptional
    ((event: { readonly kind: "model-error"; readonly message: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the message of a failed built-in harness model request.
  • hookOptional
    ((event: { readonly kind: "hook"; readonly phase: string; readonly changed: boolean; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a completed built-in harness hook with its phase and whether it changed anything.
  • instructions-loadedOptional
    ((event: { readonly kind: "instructions-loaded"; readonly count: number; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the number of nonempty instruction sources resolved for a built-in harness turn.
  • skills-loadedOptional
    ((event: { readonly kind: "skills-loaded"; readonly names: readonly string[]; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the skills newly loaded into a built-in harness conversation.
  • tool-outputOptional
    ((event: { readonly kind: "tool-output"; readonly callId: string; readonly channel: "stdout" | "stderr"; readonly text: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives built-in harness tool command output in chunks of at most 8192 characters, correlated by callId.
  • phaseOptional
    ((event: { readonly kind: "phase"; readonly name: string; readonly agent?: string; readonly branch?: string; readonly directory?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a dispatch phase (preparing prompt, running, preparation failed) with the agent name, branch and workspace directory when known.
  • summaryOptional
    ((event: { readonly kind: "summary"; readonly durationMs: number; readonly status: number; readonly tokens: Usage; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the end of a pass: its duration, exit status and total token usage.
  • warningOptional
    ((event: { readonly kind: "warning"; readonly message: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a nonfatal warning, such as incomplete usage or a replay divergence in warn mode.
  • textOptional
    ((event: { readonly kind: "text"; readonly text: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a block of agent text.
  • text-deltaOptional
    ((event: { readonly kind: "text-delta"; readonly text: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a streamed text fragment from Claude Code with partialMessages or from the built-in harness.
  • resultOptional
    ((event: { readonly kind: "result"; readonly text: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the agent’s final answer text for the turn.
  • promptOptional
    ((event: { readonly kind: "prompt"; readonly text: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the rendered prompt sent at the start of each pass.
  • toolOptional
    ((event: { readonly kind: "tool"; readonly name: string; readonly input: unknown; readonly callId?: string; readonly parentCallId?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a tool call with its name, raw input and, when the protocol supplies them, its call and parent call identifiers.
  • tool-resultOptional
    ((event: { readonly kind: "tool-result"; readonly callId: string; readonly name: string; readonly isError: boolean; readonly preview: string; readonly characters: number; readonly parentCallId?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a tool result with its call identifier, error flag, first 2000 characters and full length.
  • stepOptional
    ((event: { readonly kind: "step"; readonly index: number; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the start of a built-in harness step, before its model request.
  • tool-deniedOptional
    ((event: { readonly kind: "tool-denied"; readonly callId: string; readonly name: string; readonly reason: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a built-in harness tool call refused by permissions or a hook, with the reason.
  • stop-preventedOptional
    ((event: { readonly kind: "stop-prevented"; readonly message: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a final answer refused by a built-in harness stop hook, with the message sent back to the model.
  • compactionOptional
    ((event: { readonly kind: "compaction"; readonly strategy: string; readonly messages: number; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a built-in harness history compaction, with the strategy name and resulting message count.
  • conversationOptional
    ((event: { readonly kind: "conversation"; readonly id: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives the native conversation identifier once the agent reports it.
  • usageOptional
    ((event: { readonly kind: "usage"; readonly tokens: Usage; readonly cumulative?: boolean; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives each token increment counted toward the dispatch usage; session totals arrive already converted to increments.
  • failureOptional
    ((event: { readonly kind: "failure"; readonly message: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a failure reported by the agent protocol. Rejections without one, such as timeouts, produce no failure event.
  • quotaOptional
    ((event: { readonly kind: "quota"; readonly message: string; readonly resetAt?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a usage-limit or rate-limit signal, with its reset time when reported. The signal alone does not fail the turn.
  • fallbackOptional
    ((event: { readonly kind: "fallback"; readonly from: FallbackCandidate; readonly to: FallbackCandidate; readonly failure: FallbackTrigger; readonly message: string; readonly resetAt?: string; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives a fallback agent handing the dispatch to its next candidate, with both candidates, the failure category and its message.
  • rawOptional
    ((event: { readonly kind: "raw"; readonly value: unknown; readonly bytes?: number; readonly truncated?: boolean; } & { readonly subagentId?: string; } & { readonly pass: number; readonly at: string; readonly seq?: number; readonly source?: ObservationSource; readonly scope?: ObservationScope; }) => void | Promise<void>) | undefined
    Receives each raw protocol line, which may contain prompts, file contents or secrets.
export type ReporterHandlers = {
  readonly [Kind in AgentObservation["kind"]]?: (
    event: Extract<
      AgentObservation,
      {
        kind: Kind;
      }
    >,
  ) => void | Promise<void>;
};