import { RunInstance, Middleware, RunContext, RunContextCallbacks } from '../context.js'; import { E as Emitter, C as Callback, I as InferCallbackValue, b as EventMeta } from '../emitter-kHxkUxco.js'; import { Logger } from '../logger/logger.js'; import { AnyConstructable } from '../internals/types.js'; import '../internals/serializable.js'; import '../internals/helpers/guards.js'; import '../internals/helpers/promise.js'; import '../errors.js'; import 'pino'; /** * Copyright 2025 © BeeAI a Series of LF Projects, LLC * SPDX-License-Identifier: Apache-2.0 */ /** * Information about how deep the given entity is in the execution tree. */ interface TraceLevel { /** Relative depth to the included (observed) elements */ relative: number; /** Absolute depth from the root */ absolute: number; } /** * Input for custom formatter function */ interface GlobalTrajectoryMiddlewareFormatterInput { prefix: string; className: string; eventName: string; instanceName: string | null; } interface GlobalTrajectoryMiddlewareCallbacks { start: Callback<{ message: string; level: TraceLevel; origin: [InferCallbackValue, EventMeta]; }>; success: Callback<{ message: string; level: TraceLevel; origin: [InferCallbackValue, EventMeta]; }>; error: Callback<{ message: string; level: TraceLevel; origin: [InferCallbackValue, EventMeta]; }>; finish: Callback<{ message: string; level: TraceLevel; origin: [InferCallbackValue, EventMeta]; }>; } type OutputTargetFn = (message: string) => void; type OutputTarget = Logger | OutputTargetFn; interface GlobalTrajectoryMiddlewareOptions { /** Specify output target: 'console', Logger instance, custom function, or null to disable */ target?: OutputTarget; /** List of classes to include in the trajectory */ included?: AnyConstructable[]; /** List of classes to exclude from the trajectory */ excluded?: AnyConstructable[]; /** Use pretty formatting for the trajectory */ pretty?: boolean; /** Customize how instances of individual classes should be printed */ prefixByType?: Map; /** Enable/Disable the logging */ enabled?: boolean; /** Whether to observe trajectories of nested run contexts */ matchNested?: boolean; /** Defines a priority for registered events */ emitterPriority?: number; /** Custom formatter function */ formatter?: (input: GlobalTrajectoryMiddlewareFormatterInput) => string; } /** * Middleware for capturing and logging execution flow of agents, tools, and models. * Provides hierarchical visualization with indentation to show the call stack. */ declare class GlobalTrajectoryMiddleware extends Middleware { protected enabled: boolean; protected included: AnyConstructable[]; protected excluded: AnyConstructable[]; protected cleanups: (() => void)[]; protected target: (message: string) => void; protected ctx: RunContext | null; protected pretty: boolean; protected traceLevel: Map; protected prefixByType: Map; protected matchNested: boolean; protected emitterPriority: number; protected formatter: (input: GlobalTrajectoryMiddlewareFormatterInput) => string; readonly emitter: Emitter; constructor(options?: GlobalTrajectoryMiddlewareOptions); /** * Bind the middleware to a run context */ bind(ctx: RunContext): void; private createTarget; private bindEmitter; private logTraceId; private isAllowed; private extractName; private formatPrefix; private getTraceLevel; private formatPayload; private onInternalStart; private onInternalSuccess; private onInternalError; private onInternalFinish; } export { GlobalTrajectoryMiddleware, type GlobalTrajectoryMiddlewareCallbacks, type GlobalTrajectoryMiddlewareFormatterInput, type GlobalTrajectoryMiddlewareOptions, type TraceLevel };