@mastra/core
Version:
44 lines • 2.1 kB
TypeScript
import type { IMastraLogger } from '../../logger/index.js';
import type { ToolPayloadTransformPolicy } from '../../tools/types.js';
type ToolsRecord = Record<string, unknown>;
export interface ApplyToolPayloadTransformOptions {
/** Run-level transform policy (in-process only — it carries a closure that cannot serialize). */
policy?: ToolPayloadTransformPolicy;
/** Pre-resolved tool-level transform. Takes precedence over lookup via `tools`. */
toolTransform?: unknown;
/**
* Tool source(s) searched in order for the tool-level transform. Each source is
* searched with the full resolution ladder (direct name → provider-tool name →
* `id` property); the first source that yields the tool ends the search.
*/
tools?: ToolsRecord | Array<ToolsRecord | undefined>;
logger?: IMastraLogger;
/**
* Overrides for the *transform input* (what the transform function sees),
* independent of the emitted chunk payload. Key presence wins over the payload
* value — e.g. llm-mapping merges `mastra.modelOutput` into the emitted
* payload's providerMetadata but transforms against the original tool-call
* providerMetadata.
*/
transformInput?: {
args?: unknown;
providerMetadata?: Record<string, unknown>;
};
}
/**
* Apply the tool payload transform policy (run-level and/or tool-level) to a
* tool-shaped chunk before it is emitted. Shared by the main loop's
* tool-call/llm-mapping steps and the durable loop's tool-call/llm-execution
* steps — the phase is derived from the chunk type, and every phase pairs with
* an `input-available` transform so display targets always see redacted args.
*
* When no transform is configured, or the chunk is not tool-shaped, the chunk
* is returned unchanged.
*/
export declare function applyToolPayloadTransformToChunk<TChunk extends {
type: string;
payload?: any;
metadata?: Record<string, any>;
}>(chunk: TChunk, opts: ApplyToolPayloadTransformOptions): Promise<TChunk>;
export {};
//# sourceMappingURL=tool-payload-transform.d.ts.map