/** * [WHO]: AgentDefinition interface, AgentDefinitionSource, AgentPermissionMode, built-in agent definitions * [FROM]: Depends on @catui/agent-core for AgentMessage, @catui/ai for Model * [TO]: Consumed by ./agent-tool, ./agent-registry, ./index.ts, extensions/builtin/subagent/* * [HERE]: core/sub-agent/agent-definition.ts - Agent type definitions per CC Agent architecture (cc-agent-design §IV, §V) * [COVENANT]: Add/remove fields → update P2 AGENT.md member list */ /** Where an agent definition comes from (CC: source field). */ export type AgentDefinitionSource = "built-in" | "plugin" | "flagSettings" | "userSettings" | "projectSettings"; /** Permission mode for spawned agents (CC: permissionMode field). */ export type AgentPermissionMode = "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan"; /** Isolation mode. Currently only "worktree" is supported. */ export type AgentIsolationMode = "worktree"; /** Memory scope for agent definitions. */ export type AgentMemoryScope = "user" | "project" | "local"; /** Effort level for reasoning. */ export type AgentEffort = "low" | "medium" | "high" | number; /** Fork context inheritance mode (CC: forksParentContext). */ export type ForksParentContext = true | "turn" | undefined; /** Maximum result size in characters (CC: maxResultSizeChars = 1e5). */ export declare const MAX_RESULT_SIZE_CHARS = 100000; /** Auto-background threshold in milliseconds (CC: 120000 = 2 minutes). */ export declare const AUTO_BACKGROUND_THRESHOLD_MS = 120000; /** Default timeout for MCP server availability checks (CC: 30 seconds). */ export declare const MCP_AVAILABILITY_CHECK_TIMEOUT_MS = 30000; /** * Full agent definition matching CC's AgentDefinition interface. * Controls everything about a spawned sub-agent: tools, model, prompt, isolation, etc. */ export interface AgentDefinition { /** Unique identifier for this agent type, e.g. "general-purpose", "Explore" */ agentType: string; /** One-line description shown to the parent agent when choosing which sub-agent to use */ description: string; /** * When-to-use guidance for the parent agent. * ⚠️ Can be a function reference (like CC's Explore agent) — runs at runtime to * dynamically generate guidance based on context. */ whenToUse: string | (() => string); /** * System prompt builder. * Receives a context object and returns the full system prompt string. * Fork mode uses the parent's renderedSystemPrompt directly instead. */ getSystemPrompt: (ctx: AgentSystemPromptContext) => string; /** * Tool whitelist. ["*"] = inherit all parent tools. * If undefined, falls through to disallowedTools (blacklist approach). */ tools?: string[]; /** * Tool blacklist. Listed tools are removed from the parent's tool set. * E.g. Explore: ["Agent", "Edit", "Write"] prevents spawning + editing. */ disallowedTools?: string[]; /** Model override: "sonnet" | "opus" | "haiku" | "inherit" | a specific model ID. "inherit" = use parent model. */ model?: string; /** Reasoning effort level. */ effort?: AgentEffort; /** Permission mode for the spawned agent. Inherits from parent if undefined. */ permissionMode?: AgentPermissionMode; /** Isolation mode. "worktree" creates a git worktree so the agent works on an isolated copy. */ isolation?: AgentIsolationMode; /** * Agent definition-level background flag. * ⚠️ Different from the run_in_background parameter — this controls whether * the agent type itself defaults to background execution. */ background?: boolean; /** * Controls which parent messages the fork inherits. * true = inherit all parent messages * "turn" = only inherit current turn's messages * undefined = no inheritance (fresh start) */ forksParentContext?: ForksParentContext; /** MCP servers that must be available for this agent to function. Agent will error if missing. */ requiredMcpServers?: string[]; /** MCP servers associated with this agent. */ mcpServers?: string[]; /** Where this definition came from. */ source: AgentDefinitionSource; /** Base directory for resolving relative paths in the definition. */ baseDir: string; /** UI color identifier for status rendering. */ color?: string; /** Maximum number of agent turns before forced completion. */ maxTurns?: number; /** Skills associated with this agent definition. */ skills?: string[]; /** Initial prompt injected before the user's task prompt. */ initialPrompt?: string; /** Memory scope: determines which memory context to load. */ memory?: AgentMemoryScope; /** Whether to skip loading CLAUDE.md / AGENTS.md / .CATUI.md context files. */ omitContextFiles?: boolean; /** Whether to append (rather than replace) the system prompt. */ appendSystemPrompt?: boolean; /** Hook configuration for lifecycle events. */ hooks?: Record; /** Filename (for custom agents loaded from .md / .json files). */ filename?: string; } /** * Context passed to AgentDefinition.getSystemPrompt(). * Mirrors CC's toolUseContext shape (simplified for Catui). */ export interface AgentSystemPromptContext { /** The cwd for this agent run (may differ from parent if worktree/cwd override is used). */ cwd: string; /** Whether the agent is running in fork mode (inherits parent prompt). */ isFork?: boolean; /** Additional working directories (worktree paths, etc.) for Notes injection. */ additionalWorkingDirs?: string[]; /** Model name being used by this agent. */ model?: string; /** Tool use context from parent (for permission checks, tool resolution). */ toolUseContext?: unknown; } /** * general-purpose agent (CC §5.1) * - tools: ["*"] — inherits all parent tools * - System prompt: inherits parent agent's system prompt */ export declare const GENERAL_PURPOSE_AGENT: AgentDefinition; /** * Explore agent (CC §5.2) * - disallowedTools: ["Agent", "Edit", "Write"] — read-only, no recursion * - model: "haiku" — fast and cheap * - omitContextFiles: true — skip CLAUDE.md / AGENTS.md */ export declare const EXPLORE_AGENT: AgentDefinition; /** * Plan agent (CC §5.3) * - disallowedTools: ["Agent", "Edit", "Write"] — read-only, no recursion * - model: "inherit" — uses parent model * - omitContextFiles: true */ export declare const PLAN_AGENT: AgentDefinition; /** * statusline-setup agent (CC §5.4) * - tools: ["Read", "Edit"] — only read and edit, no Bash/Write * - model: "sonnet" * - color: "orange" */ export declare const STATUSLINE_SETUP_AGENT: AgentDefinition; /** * Catui-guide agent (CC §5.5) * - Conditional tools: Read, Grep, Glob, Agent (if web access), else Read, Grep, Glob * - model: "haiku" * - permissionMode: "dontAsk" */ export declare const CATUI_GUIDE_AGENT: AgentDefinition; /** All built-in agent definitions, keyed by agentType. */ export declare const BUILT_IN_AGENT_DEFINITIONS: ReadonlyMap; /** * The default "fork" agent definition used when subagent_type is not specified. * In CC, this creates an agent that inherits the parent's system prompt, messages, * and tool set — effectively creating a "fork" of the parent session. */ export declare const DEFAULT_FORK_AGENT: AgentDefinition;