feat(latex): add LaTeX integration with PDF compilation tool, block, and docs#4972
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@greptile |
PR SummaryMedium Risk Overview Compile path: New Workflow UI: New LaTeX block with operations for compile (compiler choice, JSON resources), package search/detail, and font listing; wired through block/tool registries, Reviewed by Cursor Bugbot for commit 9c98876. Configure here. |
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 24fd735. Configure here.
|
@greptile |
Greptile SummaryThis PR adds a full LaTeX integration: a
Confidence Score: 5/5Safe to merge; the compile route is well-bounded and the lookup tools call an unauthenticated public read API with SSRF protection already in place. The new code adds a clearly scoped integration with no auth state, no database writes, and no mutations to existing paths. Previous review rounds caught and fixed the substantive issues. The two remaining observations are non-blocking style/performance notes. apps/sim/tools/latex/search_packages.ts — worth investigating whether the upstream /packages endpoint supports a query parameter to avoid downloading the full TeX Live list on every search call. Important Files Changed
Reviews (11): Last reviewed commit: "improvement(latex): make relatedPackages..." | Re-trigger Greptile |
Greptile SummaryThis PR adds a full LaTeX integration — a
Confidence Score: 4/5The new LaTeX integration is well-structured and follows the project's tool/block patterns. The main areas to revisit before merging are the missing fetch timeout on the upstream call and the lack of filtering on The integration adds no regressions to existing functionality. The two resource-field issues (unfiltered
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/tools/latex/route.ts | Core API route that proxies compilation to latex.ytotech.com and stores the PDF; missing an AbortSignal timeout on the upstream fetch call and resource paths/URLs are forwarded to the external service without sanitization |
| apps/sim/lib/api/contracts/tools/latex.ts | Zod contract for the LaTeX compile body; validates resource fields well (exactly-one-of enforcement via superRefine) but resource path has no guard against ../ traversal sequences |
| apps/sim/tools/latex/compile.ts | Tool config that calls the internal /api/tools/latex route; response transformation and output mapping look correct |
| apps/sim/tools/latex/types.ts | Type definitions for compile params, resources, and response; clean, minimal, and consistent with the rest of the tool layer |
| apps/sim/blocks/blocks/latex.ts | Block config with sub-blocks, templates, and skills; well-structured with correct params coercion in tools.config.params and comprehensive BlockMeta templates |
| apps/sim/lib/integrations/integrations.json | Integration metadata entry for LaTeX; correctly set as authType none with documents integrationType |
| apps/docs/content/docs/en/integrations/latex.mdx | Documentation page for the LaTeX integration; content and parameter tables are accurate |
Sequence Diagram
sequenceDiagram
participant Client as Sim Workflow Executor
participant Route as /api/tools/latex (Next.js)
participant Upstream as latex.ytotech.com
participant Storage as StorageService / uploadExecutionFile
Client->>Route: POST /api/tools/latex
Route->>Route: checkInternalAuth + Zod validation
Route->>Upstream: POST /builds/sync
Upstream-->>Route: 200 application/pdf OR 400 JSON
alt Compile success
Route->>Route: readResponseToBufferWithLimit
Route->>Storage: uploadExecutionFile or StorageService.uploadFile
Storage-->>Route: url + path
Route-->>Client: pdfFile, pdfUrl, fileName, compiler
else Compile error
Route->>Route: extractCompilationErrors(log_files)
Route-->>Client: 422 error with TeX error lines
else Upstream error
Route-->>Client: 502 service error
end
Reviews (2): Last reviewed commit: "fix(latex): surface extracted TeX errors..." | Re-trigger Greptile
Greptile SummaryThis PR adds a complete LaTeX integration — a
Confidence Score: 4/5Safe to merge as-is; the integration is fully wired and functional, with two non-blocking quality items worth addressing in a follow-up. The route, tool, block, and registry additions are well-structured and follow the project's existing patterns. The fetch to latex.ytotech.com lacks an AbortSignal timeout, so a slow or hung external service will hold a serverless slot for the full 60-second window rather than returning cleanly. User LaTeX source is forwarded to that public third-party service with no in-app disclosure, which is an architectural decision that should at minimum be surfaced in documentation. Neither issue causes incorrect behavior under normal conditions. apps/sim/app/api/tools/latex/route.ts (fetch timeout and third-party disclosure) and apps/sim/tools/latex/types.ts (pdf typed as unknown).
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/tools/latex/route.ts | Core API route; correctly validates input, stores PDFs, and surfaces TeX errors. Missing AbortSignal timeout on the upstream fetch and no in-app disclosure that user content is forwarded to latex.ytotech.com. |
| apps/sim/tools/latex/compile.ts | Tool definition follows existing patterns. Error-path returns pdf as '' (empty string), which pairs poorly with the unknown type in types.ts. |
| apps/sim/tools/latex/types.ts | Types are consistent with other tools, but pdf is typed as unknown — worth tightening to a concrete interface for downstream type safety. |
| apps/sim/lib/api/contracts/tools/latex.ts | Well-structured Zod contract with correct size limits (1 MB source, 25 resources), URL validation, and the superRefine exactly-one-of check for resource content type. |
| apps/sim/blocks/blocks/latex.ts | Block config, templates, and skills all look correct; resource JSON parsing and compiler defaulting are handled cleanly. |
| apps/sim/tools/registry.ts | latex_compile added correctly in alphabetical order alongside other tools. |
| apps/sim/blocks/registry.ts | LatexBlock and LatexBlockMeta registered correctly and in alphabetical order. |
| apps/docs/content/docs/en/integrations/latex.mdx | Documentation is clear and well-structured; does not mention that source is compiled via the external latex.ytotech.com service. |
Sequence Diagram
sequenceDiagram
participant Client as Sim Executor
participant Route as /api/tools/latex
participant Upstream as latex.ytotech.com
participant Storage as Storage (Execution / Copilot)
Client->>Route: "POST {content, compiler, resources, executionId?}"
Route->>Route: checkInternalAuth + Zod validate
Route->>Upstream: "POST /builds/sync {compiler, resources[{main:true, content}, ...]}"
alt success (200 + application/pdf)
Upstream-->>Route: PDF binary
Route->>Route: "readResponseToBufferWithLimit (<=25 MB)"
alt executionId present
Route->>Storage: uploadExecutionFile(pdfBuffer)
else fallback
Route->>Storage: StorageService.uploadFile(pdfBuffer, context:copilot)
end
Storage-->>Route: pdfFile / fileInfo
Route-->>Client: "{pdfFile, pdfUrl, fileName, compiler}"
else compile failure (4xx + error JSON)
Upstream-->>Route: "{error, log_files}"
Route->>Route: extractCompilationErrors(log_files)
Route-->>Client: "422 {error: LaTeX compilation failed}"
else service error (5xx / unexpected)
Upstream-->>Route: error response
Route-->>Client: "502 {error: LaTeX compile service error}"
end
Reviews (3): Last reviewed commit: "fix(latex): surface extracted TeX errors..." | Re-trigger Greptile
|
Addressed all three Greptile findings in 2ae901b:
|
|
@greptile |
|
@cursor review |
…ect empty resource payloads
2ae901b to
bd67bd7
Compare
|
Pushed two updates in bd67bd7 (and rebased the branch onto
|
|
@greptile |
|
@cursor review |
…ttp(s)-only resource urls, timeout abort handling, typed pdf output, NaN-safe maxResults, empty-query rejection, third-party disclosure
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@greptile review |
|
@greptile review |
|
@cursor review |
|
@greptile review |
|
@cursor review |
|
@greptile review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9c98876. Configure here.
Summary
latex_compiletool that compiles LaTeX source into a PDF via the LaTeX-on-HTTP service (no OAuth or API key required)/api/tools/latexroute compiles upstream, stores the PDF as an execution file (uploadExecutionFile, withStorageServicefallback), and surfaces TeX errors (!lines) on failed buildslib/api/contracts/tools/latex.ts), BlockMeta templates + skills, LaTeX logo icon, and generated docs with manual introType of Change
Testing
Tested the compile service live (success, compile-error, and multi-resource payloads); typecheck, biome,
check:api-validation:strict, and block/registry test suites all passChecklist