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

Function compileDoc

apps/sim/lib/copilot/tools/server/files/doc-compile.ts:389–405  ·  view source on GitHub ↗
(
  args: CompileArgs
)

Source from the content-addressed store, hash-verified

387 * at most once per distinct source.
388 */
389export async function compileDoc(
390 args: CompileArgs
391): Promise<{ buffer: Buffer; contentType: string }> {
392 const { source, fileName, workspaceId } = args
393 const fmt = await getE2BDocFormat(fileName)
394 if (!fmt) throw new Error(`Unsupported document format: ${fileName}`)
395
396 const existing = await loadCompiledDoc(workspaceId, source, fmt.ext)
397 if (existing) return { buffer: existing, contentType: fmt.contentType }
398
399 const buffer =
400 fmt.engine === 'node'
401 ? await compileDocViaE2BNode({ source, fileName, workspaceId }, fmt.ext as 'pptx' | 'docx')
402 : await compileDocViaE2BPython({ source, fileName, workspaceId }, fmt)
403 await storeCompiledDoc(workspaceId, source, fmt.ext, fmt.contentType, buffer)
404 return { buffer, contentType: fmt.contentType }
405}
406
407/**
408 * Loads a compiled doc artifact by extension when present, without compiling.

Callers 4

compileDocForWriteFunction · 0.90
runE2BCompiledCheckFunction · 0.90
renderDocRecordResultMethod · 0.90
readFileContentMethod · 0.90

Calls 5

loadCompiledDocFunction · 0.90
storeCompiledDocFunction · 0.90
getE2BDocFormatFunction · 0.85
compileDocViaE2BNodeFunction · 0.85
compileDocViaE2BPythonFunction · 0.85

Tested by

no test coverage detected