MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / toolResultSearchText

Function toolResultSearchText

source code/utils/transcriptSearch.ts:173–204  ·  view source on GitHub ↗
(r: unknown)

Source from the content-addressed store, hash-verified

171 * all top-level string fields — crude but better than indexing model-chatter.
172 * Empty for unknown shapes: under-count > phantom. */
173export function toolResultSearchText(r: unknown): string {
174 if (!r || typeof r !== 'object') return typeof r === 'string' ? r : ''
175 const o = r as Record<string, unknown>
176 // Known shapes first (common tools).
177 if (typeof o.stdout === 'string') {
178 const err = typeof o.stderr === 'string' ? o.stderr : ''
179 return o.stdout + (err ? '\n' + err : '')
180 }
181 if (
182 o.file &&
183 typeof o.file === 'object' &&
184 typeof (o.file as { content?: unknown }).content === 'string'
185 ) {
186 return (o.file as { content: string }).content
187 }
188 // Known output-field names only. A blind walk would index metadata
189 // the UI doesn't show (rawOutputPath, backgroundTaskId, filePath,
190 // durationMs-as-string). Allowlist the fields tools actually render.
191 // Tools not matching any shape index empty — add them here as found.
192 const parts: string[] = []
193 for (const k of ['content', 'output', 'result', 'text', 'message']) {
194 const v = o[k]
195 if (typeof v === 'string') parts.push(v)
196 }
197 for (const k of ['filenames', 'lines', 'results']) {
198 const v = o[k]
199 if (Array.isArray(v) && v.every(x => typeof x === 'string')) {
200 parts.push((v as string[]).join('\n'))
201 }
202 }
203 return parts.join('\n')
204}

Callers 1

computeSearchTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected