UNPKG

@mastra/core

Version:
45 lines • 2.45 kB
/** * Shared helpers for the workspace computer (desktop) tools. * * The computer tools delegate to the sandbox's optional `computer` capability * (see SandboxComputer). These helpers extract the capability from the tool * execution context and format screenshot results as media parts. */ import type { ToolExecutionContext } from '../../tools/types.js'; import type { WORKSPACE_TOOLS } from '../constants/index.js'; import type { ComputerScreenshot, SandboxComputer, WorkspaceSandbox } from '../sandbox/index.js'; import type { Workspace } from '../workspace.js'; import type { MediaToolResult } from './media.js'; import type { ComputerToolConfig } from './types.js'; /** Default for ComputerToolConfig.screenshotAfterAction. */ export declare const DEFAULT_SCREENSHOT_AFTER_ACTION = true; /** Default for ComputerToolConfig.screenshotDelayMs. */ export declare const DEFAULT_SCREENSHOT_DELAY_MS = 500; type ComputerToolName = (typeof WORKSPACE_TOOLS.COMPUTER)[keyof typeof WORKSPACE_TOOLS.COMPUTER]; /** * Extract the computer capability from the workspace sandbox in the tool * execution context. Throws if the workspace has no sandbox or the sandbox * doesn't support the computer capability. */ export declare function requireComputer(context: ToolExecutionContext): { workspace: Workspace; sandbox: WorkspaceSandbox; computer: SandboxComputer; }; /** Resolve the per-tool ComputerToolConfig from the workspace tools config. */ export declare function getComputerToolConfig(workspace: Workspace, toolName: ComputerToolName): ComputerToolConfig | undefined; /** * Format a screenshot as a MediaToolResult, falling back to text-only output * when the image exceeds the configured size cap (so huge base64 payloads * don't blow up the model context or storage). */ export declare function screenshotToResult(screenshot: ComputerScreenshot, text: string, maxMediaBytes: number): MediaToolResult | string; /** * Finish a computer action tool: when `screenshotAfterAction` is enabled * (default), wait briefly for the UI to react and attach a fresh screenshot * to the result so computer-use loops see the resulting desktop state. * Screenshot failures never fail the action itself. */ export declare function finishComputerAction(workspace: Workspace, computer: SandboxComputer, toolName: ComputerToolName, text: string): Promise<MediaToolResult | string>; export {}; //# sourceMappingURL=computer-helpers.d.ts.map