AiInvestigationOptions<ResultSchema, ToolContext>
type AiInvestigationOptions<ResultSchema, ToolContext> = object;Options for investigating a failure with an AI provider.
Type Parameters
ResultSchema
ResultSchema extends Schema = Schema
ToolContext
ToolContext = unknown
Properties
resultSchema?
optional resultSchema?: ResultSchema;JSON Schema or Zod schema of the decorated method's return value. A recovered value (a direct result or a resultTools return value) is returned in place of the error, so it must match what the method returns.
investigationProvider
investigationProvider: InvestigationProviderConfig;External AI provider that runs the investigation.
investigationBehavior?
optional investigationBehavior?: InvestigationBehavior;Prompts, argument sanitization, and which built-in tools and outcomes the AI may use.
redactConfig?
optional redactConfig?: VaultOptions | false;flare-redact vault options. Investigation prompts and tool output are always redacted reversibly before they reach the provider (flare-redact's default detectors: API keys, tokens, emails, card numbers, …), and placeholders are restored in the response and in tool input. Use this to add terms or tune detectors, or set it to false to send everything unredacted.
toolContext?
optional toolContext?: ToolContext;Context passed to investigationTools and resultTools execute handlers.
investigationTools?
optional investigationTools?: InvestigationTool<ToolContext>[];Tools the AI may call while investigating. Strongly recommended to be read-only — no mutations or side effects; ignored by cursor.
mcpServers?
optional mcpServers?: McpServerConfig[];MCP servers whose tools the AI may call while investigating, alongside investigationTools. Connected once per investigation and closed afterwards. A server that can't be reached is logged as a warning and skipped.
Recommended: expose only read-only tools (narrow them with allowedTools), since the AI decides what to call.
resultTools?
optional resultTools?: ResultTool<ResultSchema, ToolContext>[];Tools the AI may pick as its outcome. trypatch calls the picked tool once the investigation completes, and its return value is returned from the decorated method in place of the error.
customErrors?
optional customErrors?: CustomErrorDefinition[];Custom error classes the AI can throw during investigation.
onAiInvestigationEnd?
optional onAiInvestigationEnd?: (ctx, outcome) => void | Promise<void>;Called with the AI's outcome before the decorated method returns or rejects, but not when the investigation fails before the AI picks an outcome. If it throws, the decorated method rejects with its original error.
Parameters
ctx
outcome
ResolvedOutcome<SchemaInfer<ResultSchema>>
Returns
void | Promise<void>