d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
138 lines
4.1 KiB
TypeScript
138 lines
4.1 KiB
TypeScript
import type { UserFile } from '@/executor/types'
|
|
import type { LatexCompileParams, LatexCompileResponse } from '@/tools/latex/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const latexCompileTool: ToolConfig<LatexCompileParams, LatexCompileResponse> = {
|
|
id: 'latex_compile',
|
|
name: 'LaTeX Compile',
|
|
description:
|
|
'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.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
content: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'LaTeX source of the main document, from \\documentclass to \\end{document}',
|
|
},
|
|
compiler: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'LaTeX compiler: pdflatex (default), xelatex, lualatex, platex, uplatex, or context',
|
|
},
|
|
fileName: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Name for the generated PDF file (default: document.pdf)',
|
|
},
|
|
resources: {
|
|
type: 'array',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'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://..."}]',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
path: { type: 'string', description: 'Relative path the file is available at' },
|
|
content: { type: 'string', description: 'Plain-text file content' },
|
|
file: { type: 'string', description: 'Base64-encoded file content' },
|
|
url: { type: 'string', description: 'URL the file is downloaded from' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: '/api/tools/latex',
|
|
method: 'POST',
|
|
headers: () => ({
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (
|
|
params: LatexCompileParams & {
|
|
_context?: { workspaceId?: string; workflowId?: string; executionId?: string }
|
|
}
|
|
) => ({
|
|
content: params.content,
|
|
compiler: params.compiler,
|
|
fileName: params.fileName,
|
|
resources: params.resources,
|
|
workspaceId: params._context?.workspaceId,
|
|
workflowId: params._context?.workflowId,
|
|
executionId: params._context?.executionId,
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = (await response.json()) as {
|
|
error?: string
|
|
pdfFile?: UserFile
|
|
pdfUrl?: string
|
|
fileName?: string
|
|
compiler?: string
|
|
}
|
|
|
|
if (!response.ok || data.error) {
|
|
return {
|
|
success: false,
|
|
error: data.error || 'LaTeX compilation failed',
|
|
output: {
|
|
pdf: '',
|
|
pdfUrl: '',
|
|
fileName: '',
|
|
compiler: data.compiler || '',
|
|
},
|
|
}
|
|
}
|
|
|
|
const pdf =
|
|
data.pdfFile ||
|
|
(data.pdfUrl
|
|
? {
|
|
name: data.fileName || 'document.pdf',
|
|
url: data.pdfUrl,
|
|
mimeType: 'application/pdf',
|
|
}
|
|
: '')
|
|
|
|
if (!pdf) {
|
|
return {
|
|
success: false,
|
|
error: 'LaTeX compile response did not include a PDF',
|
|
output: {
|
|
pdf: '',
|
|
pdfUrl: '',
|
|
fileName: '',
|
|
compiler: data.compiler || '',
|
|
},
|
|
}
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
pdf,
|
|
pdfUrl: data.pdfUrl || '',
|
|
fileName: data.fileName || '',
|
|
compiler: data.compiler || '',
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
pdf: {
|
|
type: 'file',
|
|
description: 'Compiled PDF file',
|
|
fileConfig: { mimeType: 'application/pdf', extension: 'pdf' },
|
|
},
|
|
pdfUrl: { type: 'string', description: 'URL of the compiled PDF' },
|
|
fileName: { type: 'string', description: 'Name of the compiled PDF file' },
|
|
compiler: { type: 'string', description: 'LaTeX compiler used for the build' },
|
|
},
|
|
}
|