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

Method materialize

apps/sim/lib/copilot/vfs/workspace-vfs.ts:513–627  ·  view source on GitHub ↗

* Materialize workspace data into the VFS. * Uses shared service functions for all data access, then generates * WORKSPACE.md from the summaries returned by each materializer.

(workspaceId: string, userId: string)

Source from the content-addressed store, hash-verified

511 * WORKSPACE.md from the summaries returned by each materializer.
512 */
513 async materialize(workspaceId: string, userId: string): Promise<void> {
514 const start = Date.now()
515 this.files = new Map()
516 this.lazy = new Map()
517 this.normalizedCache = new Map()
518 this.deploymentCache = new Map()
519 this._workspaceId = workspaceId
520 this._betaEnabled = await isFeatureEnabled('mothership-beta', { userId })
521
522 // Per-phase wall-clock, stamped on the span so a slow materialize in a
523 // trace names its bottleneck instead of showing up as unattributed dead
524 // time inside read/glob/grep (how the v0.7 lint.json regression hid).
525 const phaseMs: Record<string, number> = {}
526 const timed = <T>(phase: string, promise: Promise<T>): Promise<T> => {
527 const t0 = Date.now()
528 return promise.finally(() => {
529 phaseMs[phase] = Date.now() - t0
530 })
531 }
532
533 await trace
534 .getTracer('sim-copilot-vfs', '1.0.0')
535 .startActiveSpan(
536 TraceSpan.CopilotVfsMaterialize,
537 { attributes: { [TraceAttr.WorkspaceId]: workspaceId } },
538 async (span) => {
539 try {
540 const [
541 wfSummary,
542 kbSummary,
543 tblSummary,
544 fileSummary,
545 envSummary,
546 toolsSummary,
547 mcpServersSummary,
548 skillsSummary,
549 taskSummary,
550 jobsSummary,
551 wsRow,
552 members,
553 ] = await Promise.all([
554 timed('workflows', this.materializeWorkflows(workspaceId)),
555 timed('knowledge_bases', this.materializeKnowledgeBases(workspaceId, userId)),
556 timed('tables', this.materializeTables(workspaceId)),
557 timed('files', this.materializeFiles(workspaceId)),
558 timed('environment', this.materializeEnvironment(workspaceId, userId)),
559 timed('custom_tools', this.materializeCustomTools(workspaceId, userId)),
560 timed('mcp_servers', this.materializeMcpServers(workspaceId)),
561 timed('skills', this.materializeSkills(workspaceId)),
562 timed('tasks', this.materializeTasks(workspaceId, userId)),
563 timed('jobs', this.materializeJobs(workspaceId)),
564 timed('workspace_row', getWorkspaceWithOwner(workspaceId)),
565 timed('members', getUsersWithPermissions(workspaceId)),
566 ])
567
568 const workspaceMdData = {
569 workspace: wsRow,
570 members,

Callers 1

getOrMaterializeVFSFunction · 0.95

Calls 15

materializeWorkflowsMethod · 0.95
materializeTablesMethod · 0.95
materializeFilesMethod · 0.95
materializeMcpServersMethod · 0.95
materializeSkillsMethod · 0.95
materializeTasksMethod · 0.95
materializeJobsMethod · 0.95
isFeatureEnabledFunction · 0.90

Tested by

no test coverage detected