Files
puaros/packages/ipuaro/src/domain/services/ITool.ts
imfozilbek 130a8c4f24 feat(ipuaro): implement v0.1.0 foundation
- Project setup with tsup, vitest, ESM support
- Domain entities: Session, Project
- Value objects: FileData, FileAST, FileMeta, ChatMessage, ToolCall, ToolResult, UndoEntry
- Service interfaces: IStorage, ILLMClient, ITool, IIndexer, IToolRegistry
- Shared: Config (zod), IpuaroError, utils (hash, tokens), Result type
- CLI with placeholder commands (start, init, index)
- 91 unit tests with 100% coverage
- Fix package scope @puaros -> @samiyev in CLAUDE.md
2025-11-29 23:08:38 +05:00

69 lines
1.7 KiB
TypeScript

import type { ToolResult } from "../value-objects/ToolResult.js"
import type { IStorage } from "./IStorage.js"
/**
* Tool parameter schema.
*/
export interface ToolParameterSchema {
name: string
type: "string" | "number" | "boolean" | "array" | "object"
description: string
required: boolean
default?: unknown
}
/**
* Context provided to tools during execution.
*/
export interface ToolContext {
/** Project root path */
projectRoot: string
/** Storage service */
storage: IStorage
/** Request user confirmation callback */
requestConfirmation: (message: string, diff?: DiffInfo) => Promise<boolean>
/** Report progress callback */
onProgress?: (message: string) => void
}
/**
* Diff information for confirmation dialogs.
*/
export interface DiffInfo {
filePath: string
oldLines: string[]
newLines: string[]
startLine: number
}
/**
* Tool interface (port).
* All tools must implement this interface.
*/
export interface ITool {
/** Tool name (used in tool calls) */
readonly name: string
/** Human-readable description */
readonly description: string
/** Tool parameters schema */
readonly parameters: ToolParameterSchema[]
/** Whether tool requires user confirmation before execution */
readonly requiresConfirmation: boolean
/** Tool category */
readonly category: "read" | "edit" | "search" | "analysis" | "git" | "run"
/**
* Execute the tool with given parameters.
*/
execute(params: Record<string, unknown>, ctx: ToolContext): Promise<ToolResult>
/**
* Validate parameters before execution.
*/
validateParams(params: Record<string, unknown>): string | null
}