Skip to content
Français

HarnessHookOptions

import type { HarnessHookOptions } from "@elie-laloum/outpost/harness";

The fields below cover all variants; the signature specifies their allowed combinations.

  • onRequired
    Phase
    Loop point where the hook runs.
  • nameOptional
    string | undefined
    Name for diagnostics, default the phase name.
  • timeoutMsOptional
    number | undefined
    Positive callback or command deadline in milliseconds; defaults to 30000. Callbacks must honor signal for host work.
  • commandVariant-dependent
    undefined | HookCommand
    Sandbox program receiving the serializable hook context as JSON on stdin. Return a phase-specific JSON decision or empty stdout. Nonzero exit, invalid output or stdout over 1 MiB fails the turn. Mutually exclusive with run.
  • runVariant-dependent
    (input: HarnessHookInput<Phase>) => HarnessHookResult<Phase> | Promise<HarnessHookResult<Phase>> | undefined
    Control function for this phase. Hooks of a phase run in declaration order; an exception fails the turn, and an invalid decision fails it with code configuration.
export type HarnessHookOptions<Phase extends HarnessHookPhase> = {
  readonly on: Phase;
  readonly name?: string;
  readonly timeoutMs?: number;
} & (
  | {
      readonly command?: never;
      run(
        input: HarnessHookInput<Phase>,
      ): HarnessHookResult<Phase> | Promise<HarnessHookResult<Phase>>;
    }
  | {
      readonly command: HookCommand;
      readonly run?: never;
    }
);