Skip to content
Français

defineHarnessHook

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

Declare a callback or sandbox command for one of the 13 Outpost loop phases. Hooks run in declaration order; invalid decisions and callback failures fail the turn. Model transformations preserve original usage, refusal and output limits. Rewritten tool calls still pass schema and permission checks.

Complete example and detailed rules.

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

  • optionsRequired
    HarnessHookOptions<Phase>
    Loop phase, optional name and control function of the hook.
  • options.onRequired
    Phase
    Loop point where the hook runs.
  • options.nameOptional
    string | undefined
    Name for diagnostics, default the phase name.
  • options.timeoutMsOptional
    number | undefined
    Positive callback or command deadline in milliseconds; defaults to 30000. Callbacks must honor signal for host work.
  • options.commandVariant-dependent
    HookCommand | undefined
    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.
  • options.runVariant-dependent
    undefined | (input: HarnessHookInput<Phase>) => HarnessHookResult<Phase> | Promise<HarnessHookResult<Phase>>
    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.

HarnessHook<Phase>

export declare function defineHarnessHook<Phase extends HarnessHookPhase>(
  options: HarnessHookOptions<Phase>,
): HarnessHook<Phase>;