@mastra/core
Version:
70 lines • 3.41 kB
TypeScript
import { Agent } from '../agent/index.js';
import type { AgentConfig } from '../agent/types.js';
export { buildBasePrompt, type PromptContext } from './prompt.js';
/**
* Configuration for {@link createCodingAgent}.
*
* Most fields are passed straight through to the underlying `Agent`. The
* factory fills portable defaults for the pieces a coding agent always needs —
* a local workspace, the task-list signal provider, stream-retry error
* processors, and the goal judge prompt — so a caller can get a working coding
* agent by supplying only `model`, `instructions`, and `tools`.
*/
export interface CreateCodingAgentConfig extends AgentConfig {
/**
* Base path for the default workspace built when `workspace` is omitted.
* @default process.cwd()
*/
basePath?: string;
}
/**
* Creates a coding agent as a Mastra {@link Agent}, applying portable defaults
* for the workspace, task-list signal, stream-retry error processors, and goal
* judge prompt.
*
* Caller-provided values always win:
* - `workspace` is used verbatim when provided; otherwise a {@link Workspace}
* backed by {@link LocalFilesystem}/{@link LocalSandbox} rooted at
* `basePath` (default `process.cwd()`) is built.
* - `signals` are merged with a {@link TaskSignalProvider} when `memory` is
* configured; otherwise the caller-provided signals are used verbatim (or
* an empty array when none are provided). This avoids wiring
* {@link TaskSignalProvider} — which requires a memory-backed thread — into
* agents that have no memory.
* - `outputProcessors` is used verbatim when provided; otherwise it defaults to
* {@link CyberRefusalHandler}, which retries once after an Anthropic cyber
* classifier stop.
* - `errorProcessors` is passed through when provided; otherwise it defaults to
* a {@link CyberRefusalHandler} followed by
* {@link defaultStabilityErrorProcessors} — provider-history compatibility,
* then prefill-error recovery, then unsupported-file recovery, then catch-all
* stream retries with specialized
* ECONNRESET/bad-request policies. The repairs run before the retry because
* error processors short-circuit on the first `retry: true`, and the retry's
* bad-request matcher claims the same `400`s they repair. Unlike a bare
* agent's defaults, this stack also retries unmatched errors, which is the
* portable coding agent's long-standing behavior. A provided list is merged
* with the shared defaults by the agent, like any `errorProcessors` list;
* `errorProcessorDefaults: false` runs only the provided list, or none.
* - `maxProcessorRetries` defaults to {@link DEFAULT_MAX_PROCESSOR_RETRIES} so
* the default output-lane cyber-refusal retry has a budget. Output-step
* retries only read this option, so the implicit error-lane cap does not
* cover them.
* - `goal.prompt` defaults to {@link DEFAULT_GOAL_JUDGE_PROMPT} when a goal is
* configured without one.
*
* @example
* ```typescript
* import { createCodingAgent } from '@mastra/core/coding-agent';
*
* const agent = createCodingAgent({
* id: 'my-coding-agent',
* name: 'My Coding Agent',
* model: 'openai/gpt-5',
* instructions: 'You are a helpful coding assistant.',
* tools: {},
* });
* ```
*/
export declare function createCodingAgent(config: CreateCodingAgentConfig): Agent;
//# sourceMappingURL=index.d.ts.map