feat(latex): add LaTeX integration with PDF compilation tool, block, and docs (#4972)

* feat(latex): add LaTeX integration with PDF compilation tool, block, and docs

* fix(latex): surface extracted TeX errors on all failed compile responses

* improvement(latex): add compile timeout, cap upstream error code, reject empty resource payloads

* feat(latex): add package search/lookup and font listing tools

* improvement(latex): address review findings — path traversal guard, http(s)-only resource urls, timeout abort handling, typed pdf output, NaN-safe maxResults, empty-query rejection, third-party disclosure

* fix(latex): fail compile/package lookups that return no payload

* improvement(latex): guard lookup tool responses against upstream errors

* improvement(latex): reject whitespace-only package names at the block boundary

* improvement(latex): make relatedPackages fallback explicit
This commit is contained in:
Waleed
2026-06-11 13:53:11 -07:00
committed by GitHub
parent 5028ef3b16
commit 493c64fe08
19 changed files with 1534 additions and 0 deletions
+27
View File
@@ -2589,6 +2589,33 @@ export function LangsmithIcon(props: SVGProps<SVGSVGElement>) {
)
}
export function LatexIcon(props: SVGProps<SVGSVGElement>) {
return (
<svg {...props} xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 500' fill='#000000'>
<path
d='m5.46 4.23h-.25c-.1 1.02-.24 2.26-2 2.26h-.81c-.47 0-.49-.07-.49-.4v-5.31c0-.34 0-.48.94-.48h.33v-.3c-.36.03-1.26.03-1.67.03-.39 0-1.17 0-1.51-.03v.3h.23c.77 0 .79.11.79.47v5.25c0 .36-.02.47-.79.47h-.23v.31h5.19z'
transform='matrix(45 0 0 45 40 47.65)'
/>
<path
d='m2.81.16c-.04-.12-.06-.16-.19-.16s-.16.04-.2.16l-1.61 4.08c-.07.17-.19.48-.81.48v.25h1.55v-.25c-.31 0-.5-.14-.5-.34 0-.05.01-.07.03-.14 0 0 .34-.86.34-.86h1.98l.4 1.02c.02.04.04.09.04.12 0 .2-.38.2-.57.2v.25h1.97v-.25h-.14c-.47 0-.52-.07-.59-.27 0 0-1.7-4.29-1.7-4.29zm-.4.71.89 2.26h-1.78z'
transform='matrix(45 0 0 45 151.6 40)'
/>
<path
d='m6.27 0h-6.09s-.18 2.24-.18 2.24h.24c.14-1.61.29-1.94 1.8-1.94.18 0 .44 0 .54.02.21.04.21.15.21.38v5.25c0 .34 0 .48-1.05.48h-.4v.31c.41-.03 1.42-.03 1.88-.03s1.49 0 1.9.03v-.31h-.4c-1.05 0-1.05-.14-1.05-.48v-5.25c0-.2 0-.34.18-.38.11-.02.38-.02.57-.02 1.5 0 1.65.33 1.79 1.94h.25s-.19-2.24-.19-2.24z'
transform='matrix(45 0 0 45 356.35 50.35)'
/>
<path
d='m6.16 4.2h-.25c-.25 1.53-.48 2.26-2.19 2.26h-1.32c-.47 0-.49-.07-.49-.4v-2.66h.89c.97 0 1.08.32 1.08 1.17h.25v-2.64h-.25c0 .85-.11 1.16-1.08 1.16h-.89v-2.39c0-.33.02-.4.49-.4h1.28c1.53 0 1.79.55 1.95 1.94h.25l-.28-2.24h-5.6v.3h.23c.77 0 .79.11.79.47v5.22c0 .36-.02.47-.79.47h-.23v.31h5.74z'
transform='matrix(45 0 0 45 602.5 150.25)'
/>
<path
d='m3.76 2.95 1.37-2c.21-.32.55-.64 1.44-.65v-.3h-2.38v.3c.4.01.62.23.62.46 0 .1-.02.12-.09.23 0 0-1.14 1.68-1.14 1.68l-1.28-1.92c-.02-.03-.07-.11-.07-.15 0-.12.22-.29.64-.3v-.3c-.34.03-1.07.03-1.45.03-.31 0-.93-.01-1.3-.03v.3h.19c.55 0 .74.07.93.35 0 0 1.83 2.77 1.83 2.77l-1.63 2.41c-.14.2-.44.66-1.44.66v.31h2.38v-.31c-.46-.01-.63-.28-.63-.46 0-.09.03-.13.1-.24l1.41-2.09 1.58 2.38c.02.04.05.08.05.11 0 .12-.22.29-.65.3v.31c.35-.03 1.08-.03 1.45-.03.42 0 .88.01 1.3.03v-.31h-.19c-.52 0-.73-.05-.94-.36 0 0-2.1-3.18-2.1-3.18z'
transform='matrix(45 0 0 45 845.95 47.65)'
/>
</svg>
)
}
export function LaunchDarklyIcon(props: SVGProps<SVGSVGElement>) {
return (
<svg {...props} viewBox='0 0 216 214.94' fill='none' xmlns='http://www.w3.org/2000/svg'>
+2
View File
@@ -108,6 +108,7 @@ import {
KalshiIcon,
KetchIcon,
LangsmithIcon,
LatexIcon,
LaunchDarklyIcon,
LemlistIcon,
LinearIcon,
@@ -341,6 +342,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
ketch: KetchIcon,
knowledge: PackageSearchIcon,
langsmith: LangsmithIcon,
latex: LatexIcon,
launchdarkly: LaunchDarklyIcon,
lemlist: LemlistIcon,
linear: LinearIcon,
@@ -0,0 +1,129 @@
---
title: LaTeX
description: Compile LaTeX documents into PDFs
---
import { BlockInfoCard } from "@/components/ui/block-info-card"
<BlockInfoCard
type="latex"
color="#FFFFFF"
/>
{/* MANUAL-CONTENT-START:intro */}
[LaTeX](https://www.latex-project.org/) is a typesetting system that is the de facto standard for producing high-quality scientific and technical documents. Unlike word processors, LaTeX uses plain-text markup to describe a document's structure and lets the compiler handle layout, which makes it ideal for documents with mathematical notation, citations, cross-references, and consistent professional formatting.
With LaTeX, you can:
- **Compile documents to PDF**: Turn LaTeX source into a polished, print-ready PDF
- **Typeset mathematics**: Render equations, theorems, and scientific notation with precision
- **Choose your compiler**: Build with pdfLaTeX, XeLaTeX, LuaLaTeX, pLaTeX, upLaTeX, or ConTeXt
- **Include supporting files**: Add images, included `.tex` files, bibliographies, and custom classes or styles to the build
- **Automate document production**: Generate reports, invoices, certificates, and papers from templates
In Sim, the LaTeX integration enables your agents to compile LaTeX source into PDF files as part of any workflow — no OAuth or API key required. Agents can draft documents in LaTeX, attach supporting resources such as images or BibTeX bibliographies, and produce a finished PDF that downstream blocks can email, upload, or store. Agents can also search the available TeX Live packages and system fonts to pick the right tools for a document. This makes it easy to build agents that generate reports, typeset research digests, or produce templated documents like invoices and certificates.
Note: compilation runs on the public [LaTeX-on-HTTP](https://github.com/YtoTech/latex-on-http) service at latex.ytotech.com, so the document source and any attached resources are sent to that third-party service. Avoid compiling documents whose contents must not leave your environment.
{/* MANUAL-CONTENT-END */}
## Usage Instructions
Integrates LaTeX into the workflow. Compiles LaTeX source into a PDF file with pdflatex, xelatex, lualatex, platex, uplatex, or context, and supports additional resources such as images, included .tex files, and bibliographies. Can also look up the TeX Live packages and system fonts available to the compiler. Does not require OAuth or an API key. Compilation runs on the public LaTeX-on-HTTP service (latex.ytotech.com), so document source and resources are sent to that third-party service.
## Actions
### `latex_compile`
Compile a LaTeX document into a PDF via the public LaTeX-on-HTTP service (latex.ytotech.com). Supports pdflatex, xelatex, lualatex, platex, uplatex, and context, plus supporting resources such as images, included .tex files, and bibliographies.
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `content` | string | Yes | LaTeX source of the main document, from \\documentclass to \\end\{document\} |
| `compiler` | string | No | LaTeX compiler: pdflatex \(default\), xelatex, lualatex, platex, uplatex, or context |
| `fileName` | string | No | Name for the generated PDF file \(default: document.pdf\) |
| `resources` | array | No | Supporting files for the compilation. Each entry has a "path" plus exactly one of "content" \(plain text\), "file" \(base64\), or "url" \(remote file\), e.g. \[\{"path": "refs.bib", "content": "..."\}, \{"path": "logo.png", "url": "https://..."\}\] |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `pdf` | file | Compiled PDF file |
| `pdfUrl` | string | URL of the compiled PDF |
| `fileName` | string | Name of the compiled PDF file |
| `compiler` | string | LaTeX compiler used for the build |
### `latex_search_packages`
Search the TeX Live packages available to the LaTeX compiler by name or description, e.g. to check which packages can be used in a document.
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `query` | string | Yes | Search terms matched against package names and descriptions |
| `maxResults` | number | No | Maximum number of packages to return \(default: 25, max: 100\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `packages` | array | TeX Live packages matching the query |
| ↳ `name` | string | Package name |
| ↳ `shortDescription` | string | One-line package description |
| ↳ `installed` | boolean | Whether the package is installed |
| ↳ `ctanUrl` | string | CTAN page for the package |
| `totalMatches` | number | Total number of packages matching the query, before truncation |
### `latex_get_package`
Get details about a specific TeX Live package available to the LaTeX compiler, including whether it is installed, its description, license, and related packages.
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `name` | string | Yes | Exact package name, e.g. amsmath, tikz, or biblatex |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `package` | json | TeX Live package details |
| ↳ `name` | string | Package name |
| ↳ `installed` | boolean | Whether the package is installed |
| ↳ `shortDescription` | string | One-line package description |
| ↳ `longDescription` | string | Full package description |
| ↳ `category` | string | Package category |
| ↳ `license` | string | Package license identifier |
| ↳ `topics` | array | CTAN topic tags |
| ↳ `relatedPackages` | array | Names of related packages |
| ↳ `homepage` | string | Package homepage URL |
| ↳ `ctanUrl` | string | CTAN page for the package |
### `latex_list_fonts`
List the system fonts available to the LaTeX compiler, optionally filtered by name, e.g. to pick a font for xelatex or lualatex documents using fontspec.
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `query` | string | No | Filter matched against font family and full font name, e.g. "Noto Serif" |
| `maxResults` | number | No | Maximum number of fonts to return \(default: 50, max: 200\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `fonts` | array | Fonts available to the LaTeX compiler |
| ↳ `family` | string | Font family name |
| ↳ `name` | string | Full font name |
| ↳ `styles` | array | Available styles, e.g. Bold or Italic |
| `totalMatches` | number | Total number of fonts matching the filter, before truncation |
@@ -108,6 +108,7 @@
"ketch",
"knowledge",
"langsmith",
"latex",
"launchdarkly",
"lemlist",
"linear",