@mastra/core
Version:
72 lines • 3.54 kB
TypeScript
import type { MessageList, MastraDBMessage } from '../agent/message-list/index.js';
import type { ProcessInputStepArgs, Processor } from './index.js';
export interface ToolResultReminderOptions {
reminderText?: string;
maxTokens?: number;
pathExists?: (path: string) => boolean | Promise<boolean>;
isDirectory?: (path: string) => boolean | Promise<boolean>;
readFile?: (path: string) => string | Promise<string>;
getIgnoredInstructionPaths?: (args: ProcessInputStepArgs) => string[] | Promise<string[]>;
/**
* When provided and returning false for a request, no instruction-file
* reminders are injected at all. Lets hosts suppress ingestion of
* instruction files from untrusted checkouts (e.g. a PR branch under
* review), where AGENTS.md content is attacker-controlled.
*/
isEnabled?: (args: ProcessInputStepArgs) => boolean;
/**
* Per-request override for how instruction files are located and read.
* When it returns a reader, that reader replaces the instance-level
* pathExists/isDirectory/readFile for this request — e.g. serving content
* from a trusted git ref instead of an untrusted working tree. Returning
* undefined keeps the instance defaults.
*/
getReader?: (args: ProcessInputStepArgs) => ReminderFileReader | Promise<ReminderFileReader | undefined> | undefined;
/**
* Per-request project root. When it returns a path, relative tool paths are
* resolved against it instead of `process.cwd()`, and instruction files are
* only discovered inside it — paths outside the root and ancestor
* directories above it are never searched. Returning undefined keeps the
* default `process.cwd()` resolution with no boundary.
*/
getBasePath?: (args: ProcessInputStepArgs) => string | undefined;
}
/** Filesystem-shaped read access used to locate and read instruction files. */
export interface ReminderFileReader {
pathExists: (path: string) => boolean | Promise<boolean>;
isDirectory: (path: string) => boolean | Promise<boolean>;
readFile: (path: string) => string | Promise<string>;
/**
* Stable identity used only to deduplicate instruction paths. Read addresses
* and emitted paths remain unchanged. Omit to use lexical absolute paths;
* virtual readers must not resolve identities through the host filesystem.
*/
getPathIdentity?: (path: string) => string | Promise<string>;
}
/**
* Injects a persisted UI-visible reminder when the agent just interacted with
* a path whose directory ancestry contains an instruction file such as AGENTS.md.
*/
export declare class AgentsMDInjector implements Processor<'agents-md-injector'> {
static readonly supportsAsyncInstructionReaders = true;
id: 'agents-md-injector';
name: string;
description: string;
processorIndex: number;
private readonly reminderText?;
private readonly maxTokens;
private readonly pathExists;
private readonly isDirectory;
private readonly readFile;
private readonly getPathIdentity?;
private readonly getIgnoredInstructionPaths?;
private readonly isEnabled?;
private readonly getReader?;
private readonly getBasePath?;
constructor(options: ToolResultReminderOptions);
processInputStep(args: ProcessInputStepArgs): Promise<MessageList | MastraDBMessage[]>;
private getReminderText;
private findInstructionPathsInInvocation;
private hasReminderAlready;
}
//# sourceMappingURL=tool-result-reminder.d.ts.map