@mastra/core
Version:
31 lines • 1.35 kB
TypeScript
/**
* Code Mode — tool factory
*
* `createCodeMode(config)` returns the `execute_typescript` tool plus the
* generated `instructions`. The tool transpiles the model's TypeScript to JS,
* runs it in a WorkspaceSandbox via the transport, and bridges each
* `external_*` call back to the real Mastra tool on the host.
*/
import type { Tool } from '../tool.js';
import type { CodeModeConfig, CodeModeTransport } from './types.js';
/** Result of {@link createCodeMode}: the tool plus its generated instructions. */
export interface CodeModeResult {
tool: Tool<any, any>;
instructions: string;
}
/**
* Create only the `execute_typescript` tool. Most callers want
* {@link createCodeMode}, which also returns the matching instructions.
*/
export declare function createCodeModeTool(config: CodeModeConfig, transport?: CodeModeTransport): Tool<any, any>;
/**
* Create Code Mode: the `execute_typescript` tool plus generated instructions.
*
* @example
* ```ts
* const { tool, instructions } = createCodeMode({ tools: { getTopProducts, getProductRatings } });
* const agent = new Agent({ instructions: ['You are helpful.', instructions], tools: { [tool.id]: tool } });
* ```
*/
export declare function createCodeMode(config: CodeModeConfig, transport?: CodeModeTransport): CodeModeResult;
//# sourceMappingURL=code-mode.d.ts.map