Skip to content
Français

HarnessHookEvents

import type { HarnessHookEvents } from "@elie-laloum/outpost/harness";
  • session-startRequired
    { readonly prompt: string; readonly source?: "start" | "resume" | "repair"; }
    Event for session-start hooks: the rendered prompt.
  • before-promptRequired
    { readonly prompt: string; readonly source: "initial" | "steering"; }
    Context supplied at before-prompt; values are copied and frozen before callback delivery.
  • before-modelRequired
    { readonly messages: readonly ModelMessage[]; readonly system?: string; }
    Event for before-model hooks: the messages about to be sent.
  • after-modelRequired
    { readonly result: ModelResult; }
    Event for after-model hooks: the model result.
  • model-errorRequired
    { readonly error: unknown; }
    Context supplied at model-error; values are copied and frozen before callback delivery.
  • before-compactionRequired
    { readonly messages: readonly ModelMessage[]; readonly strategy: string; }
    Context supplied at before-compaction; values are copied and frozen before callback delivery.
  • after-compactionRequired
    { readonly messages: readonly ModelMessage[]; readonly strategy: string; }
    Context supplied at after-compaction; values are copied and frozen before callback delivery.
  • before-subagentRequired
    { readonly id: string; readonly name: string; readonly callId: string; readonly prompt: string; }
    Context supplied at before-subagent; values are copied and frozen before callback delivery.
  • after-subagentRequired
    { readonly id: string; readonly name: string; readonly callId: string; readonly text?: string; readonly error?: unknown; readonly conversation?: string; }
    Context supplied at after-subagent; values are copied and frozen before callback delivery.
  • run-endRequired
    { readonly reason: "success" | "error" | "aborted" | "timeout" | "limit"; readonly text?: string; readonly error?: unknown; }
    Context supplied at run-end; values are copied and frozen before callback delivery.
  • before-toolRequired
    { readonly call: ModelToolCallBlock; }
    Event for before-tool hooks: the validated call.
  • after-toolRequired
    { readonly call: ModelToolCallBlock; readonly result: HarnessToolResultView; readonly status?: "success" | "denied" | "error"; }
    Event for after-tool hooks: the call and its outcome.
  • stopRequired
    { readonly text: string; }
    Event for stop hooks: the final answer text.
export interface HarnessHookEvents {
  readonly "session-start": {
    readonly prompt: string;
    readonly source?: "start" | "resume" | "repair";
  };
  readonly "before-prompt": {
    readonly prompt: string;
    readonly source: "initial" | "steering";
  };
  readonly "before-model": {
    readonly messages: readonly ModelMessage[];
    readonly system?: string;
  };
  readonly "after-model": {
    readonly result: ModelResult;
  };
  readonly "model-error": {
    readonly error: unknown;
  };
  readonly "before-compaction": {
    readonly messages: readonly ModelMessage[];
    readonly strategy: string;
  };
  readonly "after-compaction": {
    readonly messages: readonly ModelMessage[];
    readonly strategy: string;
  };
  readonly "before-subagent": {
    readonly id: string;
    readonly name: string;
    readonly callId: string;
    readonly prompt: string;
  };
  readonly "after-subagent": {
    readonly id: string;
    readonly name: string;
    readonly callId: string;
    readonly text?: string;
    readonly error?: unknown;
    readonly conversation?: string;
  };
  readonly "run-end": {
    readonly reason: "success" | "error" | "aborted" | "timeout" | "limit";
    readonly text?: string;
    readonly error?: unknown;
  };
  readonly "before-tool": {
    readonly call: ModelToolCallBlock;
  };
  readonly "after-tool": {
    readonly call: ModelToolCallBlock;
    readonly result: HarnessToolResultView;
    readonly status?: "success" | "denied" | "error";
  };
  readonly stop: {
    readonly text: string;
  };
}