(options: {
bookId?: string | null;
isVectorized: boolean;
enabledSkills: Skill[];
})
| 66 | |
| 67 | /** Get available tools based on current state */ |
| 68 | export function getAvailableTools(options: { |
| 69 | bookId?: string | null; |
| 70 | isVectorized: boolean; |
| 71 | enabledSkills: Skill[]; |
| 72 | }): ToolDefinition[] { |
| 73 | const tools: ToolDefinition[] = []; |
| 74 | |
| 75 | // General tools are always available (no bookId required) |
| 76 | tools.push(...getGeneralTools()); |
| 77 | |
| 78 | if (options.bookId) { |
| 79 | // Context tools (always available when book is loaded) |
| 80 | tools.push(...getContextTools(options.bookId)); |
| 81 | |
| 82 | // RAG tools (require vectorization) |
| 83 | if (options.isVectorized) { |
| 84 | tools.push( |
| 85 | createRagSearchTool(options.bookId), |
| 86 | createRagTocTool(options.bookId), |
| 87 | createRagContextTool(options.bookId), |
| 88 | ); |
| 89 | |
| 90 | // Content analysis tools (require chunks from vectorization) |
| 91 | tools.push( |
| 92 | createSummarizeTool(options.bookId), |
| 93 | createExtractEntitiesTool(options.bookId), |
| 94 | createAnalyzeArgumentsTool(options.bookId), |
| 95 | createFindQuotesTool(options.bookId), |
| 96 | createCompareSectionsTool(options.bookId), |
| 97 | ); |
| 98 | } else { |
| 99 | tools.push( |
| 100 | createFallbackTocTool(options.bookId), |
| 101 | createFallbackSearchTool(options.bookId), |
| 102 | createFallbackChapterContextTool(options.bookId), |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | // Citations are available for indexed chunks and for fallback sources that |
| 107 | // can be validated against concrete reader segments. |
| 108 | tools.push(createGetAnnotationsTool(options.bookId), createAddCitationTool(options.bookId)); |
| 109 | } |
| 110 | |
| 111 | // Add custom skills |
| 112 | for (const skill of options.enabledSkills) { |
| 113 | tools.push(skillToTool(skill)); |
| 114 | } |
| 115 | |
| 116 | return tools; |
| 117 | } |
no test coverage detected