MCPcopy
hub / github.com/simstudioai/sim / grepChatUpload

Function grepChatUpload

apps/sim/lib/copilot/tools/handlers/upload-file-reader.ts:173–192  ·  view source on GitHub ↗
(
  filename: string,
  chatId: string,
  pattern: string,
  options?: GrepOptions
)

Source from the content-addressed store, hash-verified

171 * message verbatim.
172 */
173export async function grepChatUpload(
174 filename: string,
175 chatId: string,
176 pattern: string,
177 options?: GrepOptions
178): Promise<GrepMatch[] | string[] | GrepCountEntry[]> {
179 const row = await findMothershipUploadRowByChatAndName(chatId, filename)
180 if (!row) {
181 throw new WorkspaceFileGrepError(
182 `Upload not found: "${filename}". Use glob("uploads/*") to list available uploads.`
183 )
184 }
185 const record = toWorkspaceFileRecord(row)
186 const result = await readFileRecord(record)
187 if (!result) {
188 throw new WorkspaceFileGrepError(`Upload content not found for "${filename}".`)
189 }
190 const uploadsPath = `uploads/${canonicalUploadKey(record.name)}`
191 return grepReadResult(uploadsPath, result, pattern, uploadsPath, options)
192}

Callers 1

executeVfsGrepFunction · 0.90

Calls 5

readFileRecordFunction · 0.90
grepReadResultFunction · 0.90
toWorkspaceFileRecordFunction · 0.85
canonicalUploadKeyFunction · 0.85

Tested by

no test coverage detected