MCPcopy Index your code
hub / github.com/simstudioai/sim / executeVfsGlob

Function executeVfsGlob

apps/sim/lib/copilot/tools/handlers/vfs.ts:164–199  ·  view source on GitHub ↗
(
  params: Record<string, unknown>,
  context: ExecutionContext
)

Source from the content-addressed store, hash-verified

162}
163
164export async function executeVfsGlob(
165 params: Record<string, unknown>,
166 context: ExecutionContext
167): Promise<ToolCallResult> {
168 const pattern = params.pattern as string | undefined
169 if (!pattern) {
170 return { success: false, error: "Missing required parameter 'pattern'" }
171 }
172
173 const workspaceId = context.workspaceId
174 if (!workspaceId) {
175 return { success: false, error: 'No workspace context available' }
176 }
177
178 try {
179 const vfs = await getOrMaterializeVFS(workspaceId, context.userId)
180 let files = vfs.glob(pattern)
181
182 if (context.chatId && (pattern === 'uploads/*' || pattern.startsWith('uploads/'))) {
183 const uploads = await listChatUploads(context.chatId)
184 // Encode per segment so uploads/ paths match the files/ convention; the
185 // upload resolver accepts both the encoded path and the raw display name.
186 const uploadPaths = uploads.map((f) => `uploads/${encodeUploadSegment(f.name)}`)
187 files = [...files, ...uploadPaths]
188 }
189
190 logger.debug('vfs_glob result', { pattern, fileCount: files.length })
191 return { success: true, output: { files } }
192 } catch (err) {
193 logger.error('vfs_glob failed', {
194 pattern,
195 error: toError(err).message,
196 })
197 return { success: false, error: getErrorMessage(err, 'vfs_glob failed') }
198 }
199}
200
201export async function executeVfsRead(
202 params: Record<string, unknown>,

Callers 1

vfs.test.tsFile · 0.90

Calls 8

getOrMaterializeVFSFunction · 0.90
listChatUploadsFunction · 0.90
toErrorFunction · 0.90
getErrorMessageFunction · 0.90
encodeUploadSegmentFunction · 0.85
globMethod · 0.80
debugMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected