import type { ProcessorContext } from '@mastra/core/processors'; import type { RequestContext } from '@mastra/core/request-context'; import { z } from 'zod'; import type { Memory } from '../../index.js'; type ExtractorMode = 'inline' | 'structured'; export type ExtractorSource = 'observer' | 'reflector'; export interface ExtractorRuntimeContext { source: ExtractorSource; threadId?: string; resourceId?: string; mainAgent?: ProcessorContext['agent']; memory?: Memory; requestContext?: RequestContext; } export interface ExtractorOnExtractedContext extends ExtractorRuntimeContext { extractor: Extractor; threadId: string; previous?: T; current: T; sendSignal?: ProcessorContext['sendSignal']; } type MaybePromise = T | Promise; type ExtractorConfigValue = TValue | ((context: ExtractorRuntimeContext) => MaybePromise); export interface ExtractorConfig { /** Human-readable extractor name. Converted to a stable kebab-case slug for XML tags and metadata keys. */ name: string; /** Instructions describing what this extractor should return. */ instructions: ExtractorConfigValue; /** Zod schema used for structured extraction. Omit to extract an inline string value from the observer/reflector output. */ schema?: ExtractorConfigValue | undefined>; /** Whether the previous extraction should be shown to the extractor prompt. Defaults to true. */ includePreviousExtraction?: boolean; /** Dot-separated OM metadata path for persistence. Defaults to `extracted.`. Set false to skip OM metadata persistence. */ metadataKeyPath?: string | false; /** Optional lifecycle hook invoked after a value is parsed and before it is persisted. */ onExtracted?: (context: ExtractorOnExtractedContext) => Promise | T | void | undefined; } export declare const BUILT_IN_EXTRACTOR_SLUGS: readonly string[]; export type BuiltInExtractorSlug = (typeof BUILT_IN_EXTRACTOR_SLUGS)[number]; export declare function isBuiltInExtractorSlug(slug: string): slug is BuiltInExtractorSlug; export declare function slugifyExtractorName(name: string): string; export declare class Extractor { readonly name: string; readonly slug: string; readonly instructions: string; readonly schema: z.ZodType; readonly mode: ExtractorMode; readonly includePreviousExtraction: boolean; readonly metadataKeyPath: string | false; readonly onExtracted?: ExtractorConfig['onExtracted']; /** @internal */ readonly internal: boolean; private readonly instructionsConfig; private readonly schemaConfig?; constructor(config: ExtractorConfig, internal?: boolean); resolve(context: ExtractorRuntimeContext): Promise>; } export declare function resolveExtractors(extractors: readonly Extractor[], context: ExtractorRuntimeContext): Promise[]>; export declare function validateExtractorList(extractors: readonly Extractor[]): Extractor[]; export declare function parseExtractorValue(extractor: Extractor, raw: string): T; export interface ParsedExtractedValues { values: Record; failures: Array<{ slug: string; error: string; }>; } export declare function parseExtractedValues(output: string, extractors: readonly Extractor[]): ParsedExtractedValues; export declare function stripExtractorSections(output: string, extractors: readonly Extractor[]): string; export declare function buildExtractorOutputSections(extractors: readonly Extractor[]): string; export declare function buildExtractorPriorLines(extractors: readonly Extractor[], priorExtractedValues?: Record): string[]; export {}; //# sourceMappingURL=extractor.d.ts.map