Variable hitlConst

hitl: {
    autoApprove(): HitlHandler;
    autoReject(reason?): HitlHandler;
    cli(): HitlHandler;
    webhook(url): HitlHandler;
    slack(opts): HitlHandler;
    llmJudge(config?): HitlHandler;
} = ...

A collection of factory functions that produce HitlHandler instances for common approval patterns.

All handlers are composable: you can wrap any factory result in your own function to add logging, fallback logic, or conditional routing.

Type declaration

  • autoApprove:function
    • Returns a handler that approves every request immediately without any human interaction.

      Intended for use in automated tests and CI pipelines where human review is not required.

      Returns HitlHandler

      A HitlHandler that always resolves { approved: true }.

      Example

      handler: hitl.autoApprove()
      
  • autoReject:function
    • Returns a handler that rejects every request immediately without any human interaction.

      Useful for dry-run or read-only execution modes where you want to confirm which actions would have been triggered without actually permitting any.

      Parameters

      • Optional reason: string

        Optional human-readable rejection reason appended to the decision. Defaults to "Auto-rejected".

      Returns HitlHandler

      A HitlHandler that always resolves { approved: false, reason }.

      Example

      handler: hitl.autoReject('dry-run mode — no side effects permitted')
      
  • cli:function
    • Returns a handler that pauses execution and prompts the user interactively via stdin/stdout.

      Displays the approval request summary (description, agent, action, type) and waits for the user to type y (approve) or n (reject).

      Important: This handler reads from process.stdin, so it must only be used in interactive terminal environments (not in CI/CD pipelines or serverless functions).

      Returns HitlHandler

      A HitlHandler that waits for interactive CLI input.

      Example

      handler: hitl.cli()
      
  • webhook:function
    • Returns a handler that POSTs the ApprovalRequest as JSON to the provided URL and expects the server to respond with an ApprovalDecision.

      The server must respond with Content-Type: application/json containing an object with at least an approved: boolean field. Non-2xx responses are treated as a rejection with the HTTP status code as the reason.

      Parameters

      • url: string

        The full URL to POST approval requests to.

      Returns HitlHandler

      A HitlHandler that delegates decisions to an HTTP endpoint.

      Example

      handler: hitl.webhook('https://my-approval-service.example.com/approve')
      
  • slack:function
    • Returns a handler that posts a notification to a Slack channel when an approval is requested.

      v1 behaviour: The message is sent to the configured Slack channel, then the handler immediately auto-approves. A future version will poll for emoji reactions (:white_check_mark: / :x:) on the posted message before resolving.

      Parameters

      • opts: {
            channel: string;
            token: string;
        }
        • channel: string

          Slack channel ID or name (e.g. "#approvals" or "C0123456789").

        • token: string

          Slack Bot OAuth token with chat:write scope.

      Returns HitlHandler

      A HitlHandler that posts to Slack and auto-approves for v1.

      Example

      handler: hitl.slack({ channel: '#approvals', token: process.env.SLACK_BOT_TOKEN! })
      
  • llmJudge:function
    • Creates an HITL handler that delegates approval decisions to an LLM judge.

      The LLM evaluates the approval request against configurable criteria and returns a structured approve/reject decision with reasoning. When the LLM's self-reported confidence falls below confidenceThreshold, the decision is delegated to a fallback handler (default: hitl.autoReject).

      Parameters

      • config: {
            model?: string;
            provider?: string;
            criteria?: string;
            confidenceThreshold?: number;
            fallback?: HitlHandler;
            apiKey?: string;
        } = {}

        LLM judge configuration.

        • Optional model?: string

          LLM model to use.

          Default

          'gpt-4o-mini'
          
        • Optional provider?: string

          LLM provider.

          Default

          'openai'
          
        • Optional criteria?: string

          Custom evaluation criteria/rubric.

          Default

          'Evaluate whether this action is safe, relevant, and appropriate.'
          
        • Optional confidenceThreshold?: number

          Confidence threshold — below this, escalate to fallback handler.

          Default

          0.7
          
        • Optional fallback?: HitlHandler

          Fallback handler when confidence is below threshold.

          Default

          hitl.autoReject('LLM judge confidence too low')
          
        • Optional apiKey?: string

          API key override.

      Returns HitlHandler

      A HitlHandler that auto-decides via LLM.

      Example

      import { agency, hitl } from '@framers/agentos';

      const guarded = agency({
      agents: { worker: { instructions: 'Execute tasks.' } },
      hitl: {
      approvals: { beforeTool: ['delete-file'] },
      handler: hitl.llmJudge({
      model: 'gpt-4o-mini',
      criteria: 'Is this action safe and non-destructive?',
      confidenceThreshold: 0.8,
      fallback: hitl.cli(), // escalate uncertain decisions to human
      }),
      },
      });