/** * Tool plugin interface definitions */ import { ChatCompletionFunctionTool } from "openai/resources.js"; import type { PermissionMode, PermissionCallback } from "../types/permissions.js"; import type { SubagentConfiguration } from "../utils/subagentParser.js"; import type { SkillMetadata } from "../types/skills.js"; export interface ToolPlugin { name: string; config: ChatCompletionFunctionTool; execute: (args: Record, context: ToolContext) => Promise; formatCompactParams?: (params: Record, context: ToolContext) => string; /** * Function to provide a prompt to be added to the tool description */ prompt?: (args?: { availableSubagents?: SubagentConfiguration[]; availableSkills?: SkillMetadata[]; workdir?: string; isSubagent?: boolean; }) => string; /** * Whether this tool is safe to run in parallel with other tools. * Default (undefined) = true (parallel). Set to false for tools that * perform read-modify-write on shared resources (e.g. Edit, Write). */ isConcurrencySafe?: boolean; } export interface ToolResult { success: boolean; content: string; error?: string; shortResult?: string; filePath?: string; startLineNumber?: number; images?: Array<{ data: string; mediaType?: string; }>; isManuallyBackgrounded?: boolean; metadata?: Record; } export interface ToolContext { abortSignal?: AbortSignal; backgroundTaskManager?: import("../managers/backgroundTaskManager.js").BackgroundTaskManager; workdir: string; /** Tool manager instance for tool discovery (used by ToolSearchTool) */ toolManager?: import("../managers/toolManager.js").ToolManager; /** Permission mode for this tool execution */ permissionMode?: PermissionMode; /** Custom permission callback */ canUseToolCallback?: PermissionCallback; /** Permission manager instance for permission checks */ permissionManager?: import("../managers/permissionManager.js").PermissionManager; /** MCP manager instance for calling MCP tools */ mcpManager?: import("../managers/mcpManager.js").McpManager; /** LSP manager instance for code intelligence */ lspManager?: import("../types/lsp.js").ILspManager; /** Reversion manager instance for file snapshots */ reversionManager?: import("../managers/reversionManager.js").ReversionManager; /** Current message ID for associating snapshots */ messageId?: string; /** Foreground task manager for backgrounding tasks */ foregroundTaskManager?: import("../types/processes.js").IForegroundTaskManager; /** Task manager instance for task management */ taskManager: import("../services/taskManager.js").TaskManager; /** Subagent manager instance for agent delegation */ subagentManager?: import("../managers/subagentManager.js").SubagentManager; /** Skill manager instance for skill invocation */ skillManager?: import("../managers/skillManager.js").SkillManager; /** Cron manager instance for scheduling tasks */ cronManager?: import("../managers/cronManager.js").CronManager; /** AI manager instance for AI operations */ aiManager?: import("../managers/aiManager.js").AIManager; /** AI service instance for AI operations */ aiService?: typeof import("../services/aiService.js"); /** Message manager instance for message operations */ messageManager?: import("../managers/messageManager.js").MessageManager; /** Current session ID */ sessionId?: string; /** The ID of the current tool call */ toolCallId?: string; /** Callback to update the short result of the current tool block */ onShortResultUpdate?: (shortResult: string) => void; /** Callback to update the full result of the current tool block */ onResultUpdate?: (result: string) => void; /** Limits for file reading operations */ fileReadingLimits?: { maxSizeBytes: number; maxTokens: number; }; /** State of files read in the current session for deduplication */ readFileState?: Map; /** Hook manager instance for executing hooks */ hookManager?: import("../managers/hookManager.js").HookManager; /** Callback to notify when the current working directory changes */ onCwdChange?: (newCwd: string) => void; /** Original working directory (before any cd changes) for CWD reset */ originalWorkdir?: string; /** Workflow manager instance for workflow orchestration */ workflowManager?: import("../managers/workflowManager.js").WorkflowManager; }