@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
43 lines • 2.27 kB
TypeScript
/**
* Workspace Tools — Factory
*
* Creates the built-in workspace tools for agents. Individual tools are
* defined in their own files; this module applies WorkspaceToolsConfig
* (enabled, requireApproval, requireReadBeforeWrite) and injects workspace
* into the tool execution context.
*/
import type { WorkspaceToolName } from '../constants/index.js';
import type { Workspace } from '../workspace.js';
import type { WorkspaceToolsConfig, DynamicToolConfigValue, ToolConfigContext, ToolConfigWithArgsContext } from './types.js';
export type { WorkspaceToolConfig, WorkspaceToolsConfig, ExecuteCommandToolConfig, BackgroundProcessConfig, BackgroundProcessMeta, BackgroundProcessExitMeta, ToolConfigContext, ToolConfigWithArgsContext, DynamicToolConfigValue, } from './types.js';
/** Resolved tool config with `enabled` as a boolean and execution-time values as raw config. */
export interface ResolvedToolConfig {
enabled: boolean;
requireApproval: DynamicToolConfigValue<ToolConfigWithArgsContext>;
requireReadBeforeWrite?: DynamicToolConfigValue<ToolConfigWithArgsContext>;
maxOutputTokens?: number;
name?: string;
}
/**
* Resolves the effective configuration for a specific tool.
*
* Resolution order (later overrides earlier):
* 1. Built-in defaults (enabled: true, requireApproval: false)
* 2. Top-level config (tools.enabled, tools.requireApproval)
* 3. Per-tool config (tools[toolName].enabled, tools[toolName].requireApproval)
*
* `enabled` is resolved to a boolean immediately (requires context if dynamic).
* `requireApproval` and `requireReadBeforeWrite` are passed through as-is
* for execution-time evaluation (they may need args).
*/
export declare function resolveToolConfig(toolsConfig: WorkspaceToolsConfig | undefined, toolName: WorkspaceToolName, context?: ToolConfigContext): Promise<ResolvedToolConfig>;
/**
* Creates workspace tools that will be auto-injected into agents.
*
* @param workspace - The workspace instance to bind tools to
* @returns Record of workspace tools
*/
export declare function createWorkspaceTools(workspace: Workspace, configContext?: Omit<ToolConfigContext, 'requestContext'> & {
requestContext?: unknown;
}): Promise<Record<string, any>>;
//# sourceMappingURL=tools.d.ts.map