@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
49 lines • 2.08 kB
TypeScript
/**
* Workspace Tool Helpers
*
* Runtime assertions for extracting workspace resources from tool execution context.
*/
import type { ToolExecutionContext } from '../../tools/types.js';
import type { WorkspaceFilesystem } from '../filesystem/index.js';
import type { WorkspaceSandbox } from '../sandbox/index.js';
import type { Workspace } from '../workspace.js';
/**
* Extract workspace from tool execution context.
* Throws if workspace is not available.
*/
export declare function requireWorkspace(context: ToolExecutionContext): Workspace;
/**
* Extract filesystem from workspace in tool execution context.
* Throws if workspace or filesystem is not available.
*/
export declare function requireFilesystem(context: ToolExecutionContext): {
workspace: Workspace;
filesystem: WorkspaceFilesystem;
};
/**
* Extract sandbox from workspace in tool execution context.
* Throws if workspace or sandbox is not available.
*/
export declare function requireSandbox(context: ToolExecutionContext): {
workspace: Workspace;
sandbox: WorkspaceSandbox;
};
/**
* Emit workspace metadata as a data chunk so the UI can render workspace info immediately.
* Should be called at the start of every workspace tool's execute function.
*/
export declare function emitWorkspaceMetadata(context: ToolExecutionContext, toolName: string): Promise<void>;
/**
* Get LSP diagnostics text to append to edit tool results.
* Non-blocking — returns empty string on any failure.
*
* LSP is a Workspace-level feature. This helper checks if the workspace
* has an LSP manager and uses it to get diagnostics for the edited file.
*
* @param workspace - The workspace (must have an LSP manager for diagnostics)
* @param filePath - Relative path within the filesystem (as used by the tool)
* @param content - The file content after the edit
* @returns Formatted diagnostics text, or empty string if unavailable
*/
export declare function getEditDiagnosticsText(workspace: Workspace, filePath: string, content: string): Promise<string>;
//# sourceMappingURL=helpers.d.ts.map