/*! * Jodit Editor PRO (https://xdsoft.net/jodit/) * See LICENSE.md in the project root for license information. * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/ */ import type { IDictionary, IJodit } from "jodit/esm/types/index"; import type { ToolCallStatus, ToolParameterType, ToolPermissionScope } from "./types"; /** * Result from a tool execution */ export interface IToolResult { /** ID of the tool call this result corresponds to */ toolCallId: string; /** Result data from tool execution */ result: any; /** Optional error message if execution failed */ error?: string; } /** * Represents a request to execute a tool */ export interface IToolCall { /** Unique identifier for this tool call */ readonly id: string; /** Name of the tool to execute */ readonly name: string; /** Arguments to pass to the tool */ readonly arguments: IDictionary; /** Current execution status */ readonly status: ToolCallStatus; /** Optional error message if status is 'error' */ readonly error?: string; /** Optional result from tool execution */ readonly result?: { readonly result?: any; readonly error?: string; }; } /** * Tool permission record */ export interface IToolPermission { /** Name of the tool */ toolName: string; /** Whether permission is granted */ granted: boolean; /** Timestamp when permission was granted */ grantedAt: number; /** Scope of the permission */ scope: ToolPermissionScope; } /** * Parameter definition for a tool */ export interface IToolParameter { /** Parameter name */ name: string; /** Parameter type */ type: ToolParameterType; /** Human-readable description */ description: string; /** Whether parameter is required */ required: boolean; /** Optional enum values for validation */ enum?: any[]; /** Optional default value */ default?: any; } /** * Tool definition */ export interface IToolDefinition { /** Unique tool name */ name: string; /** Human-readable description of what the tool does */ description: string; /** Array of parameters the tool accepts */ parameters: IToolParameter[]; /** Whether this tool requires user permission before execution */ requiresPermission: boolean; /** * Function to execute the tool * @param jodit - Editor instance * @param args - Arguments passed to the tool * @param signal - AbortSignal for cancellation * @returns Promise resolving to tool result */ execute: (jodit: IJodit, args: IDictionary, signal: AbortSignal) => Promise; }