Skip to content

Commit 493c64f

Browse files
authored
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
1 parent 5028ef3 commit 493c64f

19 files changed

Lines changed: 1534 additions & 0 deletions

File tree

apps/docs/components/icons.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,33 @@ export function LangsmithIcon(props: SVGProps<SVGSVGElement>) {
25892589
)
25902590
}
25912591

2592+
export function LatexIcon(props: SVGProps<SVGSVGElement>) {
2593+
return (
2594+
<svg {...props} xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 500' fill='#000000'>
2595+
<path
2596+
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'
2597+
transform='matrix(45 0 0 45 40 47.65)'
2598+
/>
2599+
<path
2600+
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'
2601+
transform='matrix(45 0 0 45 151.6 40)'
2602+
/>
2603+
<path
2604+
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'
2605+
transform='matrix(45 0 0 45 356.35 50.35)'
2606+
/>
2607+
<path
2608+
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'
2609+
transform='matrix(45 0 0 45 602.5 150.25)'
2610+
/>
2611+
<path
2612+
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'
2613+
transform='matrix(45 0 0 45 845.95 47.65)'
2614+
/>
2615+
</svg>
2616+
)
2617+
}
2618+
25922619
export function LaunchDarklyIcon(props: SVGProps<SVGSVGElement>) {
25932620
return (
25942621
<svg {...props} viewBox='0 0 216 214.94' fill='none' xmlns='http://www.w3.org/2000/svg'>

apps/docs/components/ui/icon-mapping.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ import {
108108
KalshiIcon,
109109
KetchIcon,
110110
LangsmithIcon,
111+
LatexIcon,
111112
LaunchDarklyIcon,
112113
LemlistIcon,
113114
LinearIcon,
@@ -341,6 +342,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
341342
ketch: KetchIcon,
342343
knowledge: PackageSearchIcon,
343344
langsmith: LangsmithIcon,
345+
latex: LatexIcon,
344346
launchdarkly: LaunchDarklyIcon,
345347
lemlist: LemlistIcon,
346348
linear: LinearIcon,
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
title: LaTeX
3+
description: Compile LaTeX documents into PDFs
4+
---
5+
6+
import { BlockInfoCard } from "@/components/ui/block-info-card"
7+
8+
<BlockInfoCard
9+
type="latex"
10+
color="#FFFFFF"
11+
/>
12+
13+
{/* MANUAL-CONTENT-START:intro */}
14+
[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.
15+
16+
With LaTeX, you can:
17+
18+
- **Compile documents to PDF**: Turn LaTeX source into a polished, print-ready PDF
19+
- **Typeset mathematics**: Render equations, theorems, and scientific notation with precision
20+
- **Choose your compiler**: Build with pdfLaTeX, XeLaTeX, LuaLaTeX, pLaTeX, upLaTeX, or ConTeXt
21+
- **Include supporting files**: Add images, included `.tex` files, bibliographies, and custom classes or styles to the build
22+
- **Automate document production**: Generate reports, invoices, certificates, and papers from templates
23+
24+
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.
25+
26+
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.
27+
{/* MANUAL-CONTENT-END */}
28+
29+
30+
## Usage Instructions
31+
32+
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.
33+
34+
35+
36+
## Actions
37+
38+
### `latex_compile`
39+
40+
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.
41+
42+
#### Input
43+
44+
| Parameter | Type | Required | Description |
45+
| --------- | ---- | -------- | ----------- |
46+
| `content` | string | Yes | LaTeX source of the main document, from \\documentclass to \\end\{document\} |
47+
| `compiler` | string | No | LaTeX compiler: pdflatex \(default\), xelatex, lualatex, platex, uplatex, or context |
48+
| `fileName` | string | No | Name for the generated PDF file \(default: document.pdf\) |
49+
| `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://..."\}\] |
50+
51+
#### Output
52+
53+
| Parameter | Type | Description |
54+
| --------- | ---- | ----------- |
55+
| `pdf` | file | Compiled PDF file |
56+
| `pdfUrl` | string | URL of the compiled PDF |
57+
| `fileName` | string | Name of the compiled PDF file |
58+
| `compiler` | string | LaTeX compiler used for the build |
59+
60+
### `latex_search_packages`
61+
62+
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.
63+
64+
#### Input
65+
66+
| Parameter | Type | Required | Description |
67+
| --------- | ---- | -------- | ----------- |
68+
| `query` | string | Yes | Search terms matched against package names and descriptions |
69+
| `maxResults` | number | No | Maximum number of packages to return \(default: 25, max: 100\) |
70+
71+
#### Output
72+
73+
| Parameter | Type | Description |
74+
| --------- | ---- | ----------- |
75+
| `packages` | array | TeX Live packages matching the query |
76+
|`name` | string | Package name |
77+
|`shortDescription` | string | One-line package description |
78+
|`installed` | boolean | Whether the package is installed |
79+
|`ctanUrl` | string | CTAN page for the package |
80+
| `totalMatches` | number | Total number of packages matching the query, before truncation |
81+
82+
### `latex_get_package`
83+
84+
Get details about a specific TeX Live package available to the LaTeX compiler, including whether it is installed, its description, license, and related packages.
85+
86+
#### Input
87+
88+
| Parameter | Type | Required | Description |
89+
| --------- | ---- | -------- | ----------- |
90+
| `name` | string | Yes | Exact package name, e.g. amsmath, tikz, or biblatex |
91+
92+
#### Output
93+
94+
| Parameter | Type | Description |
95+
| --------- | ---- | ----------- |
96+
| `package` | json | TeX Live package details |
97+
|`name` | string | Package name |
98+
|`installed` | boolean | Whether the package is installed |
99+
|`shortDescription` | string | One-line package description |
100+
|`longDescription` | string | Full package description |
101+
|`category` | string | Package category |
102+
|`license` | string | Package license identifier |
103+
|`topics` | array | CTAN topic tags |
104+
|`relatedPackages` | array | Names of related packages |
105+
|`homepage` | string | Package homepage URL |
106+
|`ctanUrl` | string | CTAN page for the package |
107+
108+
### `latex_list_fonts`
109+
110+
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.
111+
112+
#### Input
113+
114+
| Parameter | Type | Required | Description |
115+
| --------- | ---- | -------- | ----------- |
116+
| `query` | string | No | Filter matched against font family and full font name, e.g. "Noto Serif" |
117+
| `maxResults` | number | No | Maximum number of fonts to return \(default: 50, max: 200\) |
118+
119+
#### Output
120+
121+
| Parameter | Type | Description |
122+
| --------- | ---- | ----------- |
123+
| `fonts` | array | Fonts available to the LaTeX compiler |
124+
|`family` | string | Font family name |
125+
|`name` | string | Full font name |
126+
|`styles` | array | Available styles, e.g. Bold or Italic |
127+
| `totalMatches` | number | Total number of fonts matching the filter, before truncation |
128+
129+

apps/docs/content/docs/en/integrations/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"ketch",
109109
"knowledge",
110110
"langsmith",
111+
"latex",
111112
"launchdarkly",
112113
"lemlist",
113114
"linear",

0 commit comments

Comments
 (0)