Files
puaros/packages/ipuaro/src/domain/services/ILLMClient.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

82 lines
1.7 KiB
TypeScript

import type { ChatMessage } from "../value-objects/ChatMessage.js"
import type { ToolCall } from "../value-objects/ToolCall.js"
/**
* Tool parameter definition for LLM.
*/
export interface ToolParameter {
name: string
type: "string" | "number" | "boolean" | "array" | "object"
description: string
required: boolean
enum?: string[]
}
/**
* Tool definition for LLM function calling.
*/
export interface ToolDef {
name: string
description: string
parameters: ToolParameter[]
}
/**
* Response from LLM.
*/
export interface LLMResponse {
/** Text content of the response */
content: string
/** Tool calls parsed from response */
toolCalls: ToolCall[]
/** Token count for this response */
tokens: number
/** Generation time in milliseconds */
timeMs: number
/** Whether response was truncated */
truncated: boolean
/** Stop reason */
stopReason: "end" | "length" | "tool_use"
}
/**
* LLM client service interface (port).
* Abstracts the LLM provider.
*/
export interface ILLMClient {
/**
* Send messages to LLM and get response.
*/
chat(messages: ChatMessage[], tools?: ToolDef[]): Promise<LLMResponse>
/**
* Count tokens in text.
*/
countTokens(text: string): Promise<number>
/**
* Check if LLM service is available.
*/
isAvailable(): Promise<boolean>
/**
* Get current model name.
*/
getModelName(): string
/**
* Get context window size.
*/
getContextWindowSize(): number
/**
* Pull/download model if not available locally.
*/
pullModel(model: string): Promise<void>
/**
* Abort current generation.
*/
abort(): void
}