( args: Record<string, unknown>, ctx: ToolContext )
| 141 | }; |
| 142 | |
| 143 | export async function handle( |
| 144 | args: Record<string, unknown>, |
| 145 | ctx: ToolContext |
| 146 | ): Promise<ToolResponse> { |
| 147 | const { query, limit, filters, intent, includeSnippets, mode } = args as { |
| 148 | query?: unknown; |
| 149 | limit?: number; |
| 150 | filters?: Record<string, unknown>; |
| 151 | intent?: string; |
| 152 | includeSnippets?: boolean; |
| 153 | mode?: string; |
| 154 | }; |
| 155 | const queryStr = typeof query === 'string' ? query.trim() : ''; |
| 156 | |
| 157 | if (!queryStr) { |
| 158 | return { |
| 159 | content: [ |
| 160 | { |
| 161 | type: 'text', |
| 162 | text: JSON.stringify( |
| 163 | { |
| 164 | status: 'error', |
| 165 | errorCode: 'invalid_params', |
| 166 | message: "Invalid params: 'query' is required and must be a non-empty string.", |
| 167 | hint: "Provide a query like 'how are routes configured' or 'AlbumApiService'." |
| 168 | }, |
| 169 | null, |
| 170 | 2 |
| 171 | ) |
| 172 | } |
| 173 | ], |
| 174 | isError: true |
| 175 | }; |
| 176 | } |
| 177 | |
| 178 | if (ctx.indexState.status === 'indexing') { |
| 179 | return { |
| 180 | content: [ |
| 181 | { |
| 182 | type: 'text', |
| 183 | text: JSON.stringify( |
| 184 | { |
| 185 | status: 'indexing', |
| 186 | message: 'Index is still being built. Retry in a moment.', |
| 187 | progress: ctx.indexState.indexer?.getProgress() |
| 188 | }, |
| 189 | null, |
| 190 | 2 |
| 191 | ) |
| 192 | } |
| 193 | ] |
| 194 | }; |
| 195 | } |
| 196 | |
| 197 | if (ctx.indexState.status === 'error') { |
| 198 | return { |
| 199 | content: [ |
| 200 | { |
nothing calls this directly
no test coverage detected