/** * Fail policy for `tool.batch`: when a child fails, optionally cancel * pending/in-flight siblings. * * Default is continue (never cancel on child failure). Models opt into * cancel_pending (fail-fast) or selective rules / per-call cancel_on_fail. */ export type BatchFailMatch = "any" | "all"; export interface BatchFailRule { readonly ifFailed: readonly string[]; readonly cancel: readonly string[]; readonly match: BatchFailMatch; } export type BatchFailMode = { readonly kind: "continue"; } | { readonly kind: "cancel_pending"; } | { readonly kind: "rules"; readonly rules: readonly BatchFailRule[]; }; export interface BatchCallFailMeta { readonly id: string; readonly name: string; /** 1-based index matching section headers (#1, #2, …). */ readonly index1: number; readonly cancelOnFail: readonly string[]; } /** * Parse top-level on_fail / aliases. Default: continue. * Does not compile per-call cancel_on_fail (see {@link compileBatchFailMode}). */ export declare function parseBatchFailPolicy(args: Record, knownIds: ReadonlySet): BatchFailMode; /** * Merge top-level policy with per-call cancel_on_fail into a final mode. * Per-call shorthand becomes rules: { if_failed: thisId, cancel: targets }. */ export declare function compileBatchFailMode(topLevel: BatchFailMode, calls: readonly BatchCallFailMeta[], knownIds: ReadonlySet): BatchFailMode; /** * Given the set of failed call ids so far, return ids that should be cancelled * under the given mode. Does not include ids already finished. */ export declare function evaluateCancelTargets(mode: BatchFailMode, failedIds: ReadonlySet, allIds: readonly string[]): Set; /** * Human-readable cancel reason listing which failed children triggered it. */ export declare function formatBatchCancelReason(triggerIds: readonly string[], metaById: ReadonlyMap): string; /** * Parse optional cancel_on_fail / cancelOnFail on a call entry. */ export declare function parseCancelOnFailField(entry: Record, callLabel: string): string[]; /** * Resolve call id: explicit non-empty string, else auto "1"/"2"/… (1-based). */ export declare function resolveBatchCallId(entry: Record, index0: number, seen: Set): string;