@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
50 lines • 2.12 kB
TypeScript
import type { MastraLanguageModel } from '../llm/model/shared.types.js';
import type { ObservabilityContext } from '../observability/index.js';
import { MastraModelOutput } from '../stream/index.js';
import type { InnerAgentExecutionOptions } from './agent.types.js';
import type { MessageList } from './message-list/index.js';
/**
* Options for TripWire that control how the tripwire should be handled
*/
export interface TripWireOptions<TMetadata = unknown> {
/**
* If true, the agent should retry with the tripwire reason as feedback.
* The failed response will be added to message history along with the reason.
*/
retry?: boolean;
/**
* Strongly typed metadata from the processor.
* This allows processors to pass structured information about what triggered the tripwire.
*/
metadata?: TMetadata;
}
/**
* TripWire is a custom Error class for aborting processing with optional retry and metadata.
*
* When thrown from a processor, it signals that processing should stop.
* The `options` field controls how the tripwire should be handled:
* - `retry: true` - The agent will retry with the reason as feedback
* - `metadata` - Strongly typed data about what triggered the tripwire
*/
export declare class TripWire<TMetadata = unknown> extends Error {
readonly options: TripWireOptions<TMetadata>;
readonly processorId?: string;
constructor(reason: string, options?: TripWireOptions<TMetadata>, processorId?: string);
}
/**
* Tripwire data passed to getModelOutputForTripwire
*/
export interface TripwireData<TMetadata = unknown> {
reason: string;
retry?: boolean;
metadata?: TMetadata;
processorId?: string;
}
export declare const getModelOutputForTripwire: <OUTPUT = undefined, TMetadata = unknown>({ tripwire, runId, options, model, messageList, ...rest }: {
tripwire: TripwireData<TMetadata>;
runId: string;
options: InnerAgentExecutionOptions<OUTPUT>;
model: MastraLanguageModel;
messageList: MessageList;
} & ObservabilityContext) => Promise<MastraModelOutput<OUTPUT>>;
//# sourceMappingURL=trip-wire.d.ts.map