import { InterventionHandler } from '../../interventions/handler.js'; import type { InterventionAction } from '../../interventions/actions.js'; import type { BeforeToolCallEvent } from '../../hooks/events.js'; import type { JSONValue } from '../../types/json.js'; /** * Configuration for the {@link HumanInTheLoop} intervention handler. */ export interface HumanInTheLoopConfig { /** * Tools that can execute WITHOUT human approval. All other tools require approval. * * - Use `'*'` to allow all tools. * - Prefix with `!` to exclude specific tools from `'*'` (they still require approval). * * @example * ```typescript * // Only readFile and listDir run freely; everything else needs approval * { allowedTools: ['readFile', 'listDir'] } * * // All tools run freely (HITL disabled) * { allowedTools: ['*'] } * * // All tools run freely EXCEPT deleteFile and sendEmail * { allowedTools: ['*', '!deleteFile', '!sendEmail'] } * ``` */ allowedTools?: string[]; /** * When true, trust responses approve the tool AND remember it * in `agent.appState` for the rest of the session (won't ask again). * Works in both interrupt/resume and inline `ask` modes. * * Negated tools (`!tool`) cannot be trusted. * * Defaults to `false`. */ enableTrust?: boolean; /** * Custom trust response validator. Defaults to accepting `'t'`/`'trust'` (case-insensitive). * When this returns true, the tool is approved AND trusted for the session. * * Only evaluated when `enableTrust` is true. */ evaluateTrust?: (response: JSONValue) => boolean; /** * Custom approval response validator. Defaults to accepting `true`, `'y'`/`'yes'` (case-insensitive). */ evaluate?: (response: JSONValue) => boolean; /** * Controls how the human's response is collected. * * - **Default** (omitted): uses interrupt/resume — agent pauses, caller resumes with response. * - **`'stdio'`**: prompts via CLI readline (Node.js only). Agent blocks inline until human responds. * - **Custom function**: your own async prompt logic (Slack, web UI, etc.). Agent blocks inline. */ ask?: ((prompt: string) => Promise) | 'stdio'; } /** * Human-in-the-loop intervention handler that pauses agent execution * before tool calls to request human approval. * * By default, ALL tools require approval and the agent pauses via interrupt/resume. * Use `allowedTools` to whitelist tools that run freely, and `ask` to provide * inline prompting (CLI, custom UI). * * @example * ```typescript * import { Agent } from '@strands-agents/sdk' * import { HumanInTheLoop } from '@strands-agents/sdk/vended-interventions/hitl' * * // All tools require approval, agent pauses via interrupt (default) * const agent = new Agent({ * interventions: [new HumanInTheLoop()], * }) * * // readFile runs freely, everything else pauses for approval * const agent = new Agent({ * interventions: [new HumanInTheLoop({ allowedTools: ['readFile'] })], * }) * * // CLI mode — prompts in terminal inline * const agent = new Agent({ * interventions: [new HumanInTheLoop({ ask: 'stdio' })], * }) * * // Custom UI — provide your own prompt function * const agent = new Agent({ * interventions: [new HumanInTheLoop({ * ask: async (prompt) => await slackDM(userId, prompt), * })], * }) * ``` */ export declare class HumanInTheLoop extends InterventionHandler { readonly name = "strands:human-in-the-loop"; private readonly _allowedTools; private readonly _enableTrust; private readonly _evaluateTrust; private readonly _evaluate; private readonly _ask; constructor(config?: HumanInTheLoopConfig); beforeToolCall(event: BeforeToolCallEvent): Promise; /** * Precedence (first match wins): * 1. Negated (`!tool`) → always requires approval (cannot be trusted) * 2. Trusted at runtime via 't' response (stored in agent.appState) → runs freely * 3. Wildcard (`*`) → runs freely * 4. Explicitly listed → runs freely * 5. Default → requires approval */ private _requiresApproval; private _trustTool; private _isTrustResponse; } //# sourceMappingURL=hitl.d.ts.map