UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

54 lines 1.97 kB
/** * BrowserContextProcessor * * Input processor that injects browser context into agent prompts. * Similar to ChatChannelProcessor for channels. * * - `processInput`: Adds a system message with stable context (provider, sessionId, headless mode). * - `processInputStep`: At step 0, adds a new user message with browser context as a `<system-reminder>`. * This preserves prompt cache by not modifying existing messages in history. * * Reads from `requestContext.get('browser')`. * * @example * ```ts * const agent = new Agent({ * browser: new AgentBrowser({ ... }), * inputProcessors: [new BrowserContextProcessor()], * }); * ``` */ import type { ProcessInputArgs, ProcessInputResult, ProcessInputStepArgs } from '../processors/index.js'; /** * Browser context stored in RequestContext. * Set by the browser implementation or deployer. */ export interface BrowserContext { /** Browser provider name (e.g., "agent-browser", "stagehand") */ provider: string; /** Provider type: 'sdk' for direct API, 'cli' for command-line tools */ providerType?: 'sdk' | 'cli'; /** Session ID for tracking */ sessionId?: string; /** Whether browser is running in headless mode */ headless?: boolean; /** Current page URL (updated per-request) */ currentUrl?: string; /** Current page title (updated per-request) */ pageTitle?: string; /** * CDP WebSocket URL for CLI providers. * When present, the agent should pass this URL to CLI commands * to connect them to the browser managed by Mastra. */ cdpUrl?: string; } /** * Input processor that injects browser context into agent prompts. */ export declare class BrowserContextProcessor { readonly id = "browser-context"; processInput(args: ProcessInputArgs): ProcessInputResult; processInputStep(args: ProcessInputStepArgs): Promise<import("../agent").MessageList | undefined>; } //# sourceMappingURL=processor.d.ts.map