export interface ToolContext { workspaceRoot: string; runId?: string; recordTouchedFile?: (path: string) => void; allowOutsideWorkspace?: boolean; allowedReadPaths?: string[]; allowedWritePaths?: string[]; allowShell?: boolean; allowDestructiveOperations?: boolean; shellAllowlist?: string[]; } export type ToolSchemaPrimitiveType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null"; export interface ToolSchemaDefinition extends Record { type?: ToolSchemaPrimitiveType | ToolSchemaPrimitiveType[]; properties?: Record; required?: string[]; items?: ToolSchemaDefinition; additionalProperties?: boolean; enum?: unknown[]; minimum?: number; maximum?: number; minLength?: number; maxLength?: number; } export interface ToolInputSchema extends ToolSchemaDefinition { type: "object"; properties?: Record; required?: string[]; } export type ToolErrorCode = "tool_unknown" | "tool_schema_invalid" | "tool_invalid_args" | "tool_permission_denied" | "tool_timeout" | "tool_execution_failed" | "missing_credentials" | "repo_access_denied" | "scope_denied" | "encrypted_operation_disabled" | "docdex_context_missing" | "docdex_api_key_missing" | "docdex_operation_not_allowed" | "docdex_auth_failed" | "docdex_repo_access_denied" | "docdex_unavailable"; export type ToolErrorCategory = "lookup" | "schema" | "validation" | "permission" | "timeout" | "execution"; export interface ToolError { code: ToolErrorCode; category: ToolErrorCategory; message: string; retryable: boolean; details?: Record; } export declare class ToolExecutionError extends Error { readonly code: ToolErrorCode; readonly category: ToolErrorCategory; readonly retryable: boolean; readonly details?: Record; constructor(code: ToolErrorCode, message: string, options?: { retryable?: boolean; details?: Record; }); toToolError(): ToolError; } export declare const toolErrorCategoryForCode: (code: ToolErrorCode) => ToolErrorCategory; export interface ToolHandlerResult { output: string; data?: unknown; } export interface ToolExecutionResult extends ToolHandlerResult { ok: boolean; error?: ToolError; } export type ToolHandler = (args: unknown, context: ToolContext) => Promise; /** * Capability group a tool belongs to. The orchestrator selects capabilities * first and only then sees the full schemas of the tools inside them, so this * value is what keeps the planner prompt bounded as the registry grows. */ export type ToolCapability = string; export interface ToolDefinition { name: string; description: string; inputSchema?: ToolInputSchema; /** Shape of `ToolHandlerResult.data`, when the tool returns structured data. */ outputSchema?: ToolSchemaDefinition; /** * Whether the tool can mutate anything. Decided by Codali policy, never by a * connector's self-description: an MCP server advertising `readOnlyHint` is a * hint, not a security boundary. */ readOnly?: boolean; capability?: ToolCapability; handler: ToolHandler; } /** * The model-facing view of a tool. Derived from {@link ToolDefinition} on * demand — never stored separately, so the planner and the executor cannot * drift onto different schemas. */ export interface ToolDescriptor { name: string; description: string; inputSchema?: ToolInputSchema; outputSchema?: ToolSchemaDefinition; readOnly: boolean; capability: ToolCapability; } export declare const DEFAULT_TOOL_CAPABILITY = "general"; /** * Capability inferred from a tool name when the definition does not declare * one. Names are conventionally `_` (`docdex_search`) or * `::` for connector-backed tools. */ export declare const toolCapabilityForName: (name: string) => ToolCapability; //# sourceMappingURL=ToolTypes.d.ts.map