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

Function buildWorkspaceMdData

apps/sim/lib/copilot/chat/workspace-context.ts:324–524  ·  view source on GitHub ↗
(
  workspaceId: string,
  userId: string
)

Source from the content-addressed store, hash-verified

322// the typed VFS snapshot are built from this single fetch. Returns null when the
323// workspace is unavailable or a fetch fails.
324async function buildWorkspaceMdData(
325 workspaceId: string,
326 userId: string
327): Promise<WorkspaceMdData | null> {
328 try {
329 await assertActiveWorkspaceAccess(workspaceId, userId)
330 const wsRow = await getWorkspaceWithOwner(workspaceId)
331 if (!wsRow) {
332 return null
333 }
334
335 const [
336 members,
337 workflows,
338 folderRows,
339 kbs,
340 tables,
341 files,
342 credentials,
343 customTools,
344 mcpServerRows,
345 skillRows,
346 jobRows,
347 ] = await Promise.all([
348 getUsersWithPermissions(workspaceId),
349
350 db
351 .select({
352 id: workflow.id,
353 name: workflow.name,
354 description: workflow.description,
355 isDeployed: workflow.isDeployed,
356 lastRunAt: workflow.lastRunAt,
357 folderId: workflow.folderId,
358 })
359 .from(workflow)
360 .where(and(eq(workflow.workspaceId, workspaceId), isNull(workflow.archivedAt))),
361
362 db
363 .select({
364 id: workflowFolder.id,
365 name: workflowFolder.name,
366 parentId: workflowFolder.parentId,
367 })
368 .from(workflowFolder)
369 .where(and(eq(workflowFolder.workspaceId, workspaceId), isNull(workflowFolder.archivedAt))),
370
371 db
372 .select({
373 id: knowledgeBase.id,
374 name: knowledgeBase.name,
375 description: knowledgeBase.description,
376 })
377 .from(knowledgeBase)
378 .where(and(eq(knowledgeBase.workspaceId, workspaceId), isNull(knowledgeBase.deletedAt))),
379
380 db
381 .select({

Callers 2

generateWorkspaceContextFunction · 0.85

Calls 14

getWorkspaceWithOwnerFunction · 0.90
getUsersWithPermissionsFunction · 0.90
listWorkspaceFilesFunction · 0.90
listCustomToolsFunction · 0.90
listSkillsFunction · 0.90
toErrorFunction · 0.90
errorMethod · 0.80
resolveFolderPathFunction · 0.70
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected