Skip to content

Commit bd67bd7

Browse files
committed
feat(latex): add package search/lookup and font listing tools
1 parent c908687 commit bd67bd7

9 files changed

Lines changed: 576 additions & 12 deletions

File tree

apps/docs/content/docs/en/integrations/latex.mdx

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ In Sim, the LaTeX integration enables your agents to compile LaTeX source into P
2727

2828
## Usage Instructions
2929

30-
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. Does not require OAuth or an API key.
30+
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.
3131

3232

3333

@@ -55,4 +55,73 @@ Compile a LaTeX document into a PDF. Supports pdflatex, xelatex, lualatex, plate
5555
| `fileName` | string | Name of the compiled PDF file |
5656
| `compiler` | string | LaTeX compiler used for the build |
5757

58+
### `latex_search_packages`
59+
60+
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.
61+
62+
#### Input
63+
64+
| Parameter | Type | Required | Description |
65+
| --------- | ---- | -------- | ----------- |
66+
| `query` | string | Yes | Search terms matched against package names and descriptions |
67+
| `maxResults` | number | No | Maximum number of packages to return \(default: $\{DEFAULT_MAX_RESULTS\}, max: $\{MAX_RESULTS_LIMIT\}\) |
68+
69+
#### Output
70+
71+
| Parameter | Type | Description |
72+
| --------- | ---- | ----------- |
73+
| `packages` | array | TeX Live packages matching the query |
74+
|`name` | string | Package name |
75+
|`shortDescription` | string | One-line package description |
76+
|`installed` | boolean | Whether the package is installed |
77+
|`ctanUrl` | string | CTAN page for the package |
78+
| `totalMatches` | number | Total number of packages matching the query, before truncation |
79+
80+
### `latex_get_package`
81+
82+
Get details about a specific TeX Live package available to the LaTeX compiler, including whether it is installed, its description, license, and related packages.
83+
84+
#### Input
85+
86+
| Parameter | Type | Required | Description |
87+
| --------- | ---- | -------- | ----------- |
88+
| `name` | string | Yes | Exact package name, e.g. amsmath, tikz, or biblatex |
89+
90+
#### Output
91+
92+
| Parameter | Type | Description |
93+
| --------- | ---- | ----------- |
94+
| `package` | json | TeX Live package details |
95+
|`name` | string | Package name |
96+
|`installed` | boolean | Whether the package is installed |
97+
|`shortDescription` | string | One-line package description |
98+
|`longDescription` | string | Full package description |
99+
|`category` | string | Package category |
100+
|`license` | string | Package license identifier |
101+
|`topics` | array | CTAN topic tags |
102+
|`relatedPackages` | array | Names of related packages |
103+
|`homepage` | string | Package homepage URL |
104+
|`ctanUrl` | string | CTAN page for the package |
105+
106+
### `latex_list_fonts`
107+
108+
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.
109+
110+
#### Input
111+
112+
| Parameter | Type | Required | Description |
113+
| --------- | ---- | -------- | ----------- |
114+
| `query` | string | No | Filter matched against font family and full font name, e.g. "Noto Serif" |
115+
| `maxResults` | number | No | Maximum number of fonts to return \(default: $\{DEFAULT_MAX_RESULTS\}, max: $\{MAX_RESULTS_LIMIT\}\) |
116+
117+
#### Output
118+
119+
| Parameter | Type | Description |
120+
| --------- | ---- | ----------- |
121+
| `fonts` | array | Fonts available to the LaTeX compiler |
122+
|`family` | string | Font family name |
123+
|`name` | string | Full font name |
124+
|`styles` | array | Available styles, e.g. Bold or Italic |
125+
| `totalMatches` | number | Total number of fonts matching the filter, before truncation |
126+
58127

apps/sim/blocks/blocks/latex.ts

Lines changed: 125 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
import { LatexIcon } from '@/components/icons'
22
import type { BlockConfig, BlockMeta } from '@/blocks/types'
33
import { IntegrationType } from '@/blocks/types'
4-
import type { LatexCompileResponse } from '@/tools/latex/types'
4+
import type { LatexResponse } from '@/tools/latex/types'
55

6-
export const LatexBlock: BlockConfig<LatexCompileResponse> = {
6+
export const LatexBlock: BlockConfig<LatexResponse> = {
77
type: 'latex',
88
name: 'LaTeX',
99
description: 'Compile LaTeX documents into PDFs',
1010
longDescription:
11-
'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. Does not require OAuth or an API key.',
11+
'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.',
1212
docsLink: 'https://docs.sim.ai/integrations/latex',
1313
category: 'tools',
1414
integrationType: IntegrationType.Documents,
1515
bgColor: '#FFFFFF',
1616
icon: LatexIcon,
1717
subBlocks: [
18+
{
19+
id: 'operation',
20+
title: 'Operation',
21+
type: 'dropdown',
22+
options: [
23+
{ label: 'Compile Document', id: 'latex_compile' },
24+
{ label: 'Search Packages', id: 'latex_search_packages' },
25+
{ label: 'Get Package Details', id: 'latex_get_package' },
26+
{ label: 'List Fonts', id: 'latex_list_fonts' },
27+
],
28+
value: () => 'latex_compile',
29+
},
30+
// Compile Document operation inputs
1831
{
1932
id: 'content',
2033
title: 'LaTeX Source',
2134
type: 'long-input',
2235
placeholder:
2336
'\\documentclass{article}\n\\begin{document}\nHello, world! $E = mc^2$\n\\end{document}',
2437
rows: 10,
38+
condition: { field: 'operation', value: 'latex_compile' },
2539
required: true,
2640
},
2741
{
@@ -37,6 +51,7 @@ export const LatexBlock: BlockConfig<LatexCompileResponse> = {
3751
{ label: 'ConTeXt', id: 'context' },
3852
],
3953
value: () => 'pdflatex',
54+
condition: { field: 'operation', value: 'latex_compile' },
4055
},
4156
{
4257
id: 'resources',
@@ -45,6 +60,7 @@ export const LatexBlock: BlockConfig<LatexCompileResponse> = {
4560
language: 'json',
4661
mode: 'advanced',
4762
placeholder: '[{"path": "refs.bib", "content": "..."}]',
63+
condition: { field: 'operation', value: 'latex_compile' },
4864
wandConfig: {
4965
enabled: true,
5066
prompt: `Generate a JSON array of supporting files for a LaTeX compilation based on the user's description. Each entry must have a "path" (relative file path the LaTeX source references) plus exactly one of:
@@ -66,14 +82,91 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`,
6682
type: 'short-input',
6783
mode: 'advanced',
6884
placeholder: 'document.pdf',
85+
condition: { field: 'operation', value: 'latex_compile' },
86+
},
87+
// Search Packages operation inputs
88+
{
89+
id: 'packageQuery',
90+
title: 'Search Query',
91+
type: 'short-input',
92+
placeholder: 'Search package names and descriptions (e.g. "chemistry", "tikz")...',
93+
condition: { field: 'operation', value: 'latex_search_packages' },
94+
required: true,
95+
},
96+
// Get Package Details operation inputs
97+
{
98+
id: 'packageName',
99+
title: 'Package Name',
100+
type: 'short-input',
101+
placeholder: 'Exact package name (e.g. amsmath, tikz, biblatex)',
102+
condition: { field: 'operation', value: 'latex_get_package' },
103+
required: true,
104+
},
105+
// List Fonts operation inputs
106+
{
107+
id: 'fontQuery',
108+
title: 'Font Filter',
109+
type: 'short-input',
110+
placeholder: 'Filter by font family or name (e.g. "Noto Serif")...',
111+
condition: { field: 'operation', value: 'latex_list_fonts' },
112+
},
113+
{
114+
id: 'maxResults',
115+
title: 'Max Results',
116+
type: 'short-input',
117+
mode: 'advanced',
118+
placeholder: '25',
119+
condition: {
120+
field: 'operation',
121+
value: ['latex_search_packages', 'latex_list_fonts'],
122+
},
69123
},
70124
],
71125
tools: {
72-
access: ['latex_compile'],
126+
access: ['latex_compile', 'latex_search_packages', 'latex_get_package', 'latex_list_fonts'],
73127
config: {
74-
tool: () => 'latex_compile',
128+
tool: (params) => {
129+
switch (params.operation) {
130+
case 'latex_search_packages':
131+
return 'latex_search_packages'
132+
case 'latex_get_package':
133+
return 'latex_get_package'
134+
case 'latex_list_fonts':
135+
return 'latex_list_fonts'
136+
default:
137+
return 'latex_compile'
138+
}
139+
},
75140
params: (params) => {
76-
const { compiler, fileName, resources, ...rest } = params
141+
const {
142+
operation,
143+
compiler,
144+
fileName,
145+
resources,
146+
packageQuery,
147+
packageName,
148+
fontQuery,
149+
maxResults,
150+
...rest
151+
} = params
152+
153+
if (operation === 'latex_search_packages') {
154+
return {
155+
query: packageQuery,
156+
...(maxResults ? { maxResults: Number(maxResults) } : {}),
157+
}
158+
}
159+
160+
if (operation === 'latex_get_package') {
161+
return { name: packageName }
162+
}
163+
164+
if (operation === 'latex_list_fonts') {
165+
return {
166+
...(typeof fontQuery === 'string' && fontQuery.trim() ? { query: fontQuery } : {}),
167+
...(maxResults ? { maxResults: Number(maxResults) } : {}),
168+
}
169+
}
77170

78171
let parsedResources: unknown
79172
if (typeof resources === 'string' && resources.trim()) {
@@ -96,16 +189,41 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`,
96189
},
97190
},
98191
inputs: {
192+
operation: { type: 'string', description: 'Operation to perform' },
193+
// Compile Document operation
99194
content: { type: 'string', description: 'LaTeX source of the main document' },
100195
compiler: { type: 'string', description: 'LaTeX compiler to use' },
101196
resources: { type: 'json', description: 'Supporting files for the compilation' },
102197
fileName: { type: 'string', description: 'Name for the generated PDF file' },
198+
// Search Packages operation
199+
packageQuery: { type: 'string', description: 'Package search terms' },
200+
// Get Package Details operation
201+
packageName: { type: 'string', description: 'Exact TeX Live package name' },
202+
// List Fonts operation
203+
fontQuery: { type: 'string', description: 'Font family or name filter' },
204+
maxResults: { type: 'number', description: 'Maximum results to return' },
103205
},
104206
outputs: {
207+
// Compile Document output
105208
pdf: { type: 'file', description: 'Compiled PDF file' },
106209
pdfUrl: { type: 'string', description: 'URL of the compiled PDF' },
107210
fileName: { type: 'string', description: 'Name of the compiled PDF file' },
108211
compiler: { type: 'string', description: 'LaTeX compiler used for the build' },
212+
// Search Packages output
213+
packages: {
214+
type: 'json',
215+
description: 'Matching TeX Live packages [{name, shortDescription, installed, ctanUrl}]',
216+
},
217+
// Get Package Details output
218+
package: {
219+
type: 'json',
220+
description:
221+
'Package details (name, installed, shortDescription, longDescription, category, license, topics, relatedPackages, homepage, ctanUrl)',
222+
},
223+
// List Fonts output
224+
fonts: { type: 'json', description: 'Available fonts [{family, name, styles}]' },
225+
// Shared search/list output
226+
totalMatches: { type: 'number', description: 'Total matches found before truncation' },
109227
},
110228
}
111229

@@ -225,7 +343,7 @@ export const LatexBlockMeta = {
225343
description:
226344
'Diagnose failed LaTeX builds from the compiler error output and iterate until the document compiles. Use when a compilation returns errors instead of a PDF.',
227345
content:
228-
'# Fix Compilation Errors\n\nGet a failing LaTeX document to build.\n\n## Steps\n1. Read the TeX error lines from the failed compile (lines starting with !), which name the problem and its location.\n2. Apply the targeted fix: missing packages, unescaped special characters, unmatched braces or environments, or commands needing a different compiler (e.g. fontspec requires xelatex or lualatex).\n3. Recompile and repeat until the build succeeds.\n4. Keep edits minimal — fix the errors without rewriting the document.\n\n## Output\nThe compiled PDF and a short list of the fixes that were applied.',
346+
'# Fix Compilation Errors\n\nGet a failing LaTeX document to build.\n\n## Steps\n1. Read the TeX error lines from the failed compile (lines starting with !), which name the problem and its location.\n2. Apply the targeted fix: missing packages (verify availability with Get Package Details or Search Packages), unescaped special characters, unmatched braces or environments, or commands needing a different compiler (e.g. fontspec requires xelatex or lualatex — confirm the font exists with List Fonts).\n3. Recompile and repeat until the build succeeds.\n4. Keep edits minimal — fix the errors without rewriting the document.\n\n## Output\nThe compiled PDF and a short list of the fixes that were applied.',
229347
},
230348
],
231349
} as const satisfies BlockMeta

apps/sim/lib/integrations/integrations.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8244,12 +8244,29 @@
82448244
"slug": "latex",
82458245
"name": "LaTeX",
82468246
"description": "Compile LaTeX documents into PDFs",
8247-
"longDescription": "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. Does not require OAuth or an API key.",
8247+
"longDescription": "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.",
82488248
"bgColor": "#FFFFFF",
82498249
"iconName": "LatexIcon",
82508250
"docsUrl": "https://docs.sim.ai/integrations/latex",
8251-
"operations": [],
8252-
"operationCount": 0,
8251+
"operations": [
8252+
{
8253+
"name": "Compile Document",
8254+
"description": "Compile a LaTeX document into a PDF. Supports pdflatex, xelatex, lualatex, platex, uplatex, and context, plus supporting resources such as images, included .tex files, and bibliographies."
8255+
},
8256+
{
8257+
"name": "Search Packages",
8258+
"description": "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."
8259+
},
8260+
{
8261+
"name": "Get Package Details",
8262+
"description": "Get details about a specific TeX Live package available to the LaTeX compiler, including whether it is installed, its description, license, and related packages."
8263+
},
8264+
{
8265+
"name": "List Fonts",
8266+
"description": "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."
8267+
}
8268+
],
8269+
"operationCount": 4,
82538270
"triggers": [],
82548271
"triggerCount": 0,
82558272
"authType": "none",

0 commit comments

Comments
 (0)