d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
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
103 lines
2.9 KiB
TypeScript
103 lines
2.9 KiB
TypeScript
import type { LatexFont, LatexListFontsParams, LatexListFontsResponse } from '@/tools/latex/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
const DEFAULT_MAX_RESULTS = 50
|
|
const MAX_RESULTS_LIMIT = 200
|
|
|
|
export const latexListFontsTool: ToolConfig<LatexListFontsParams, LatexListFontsResponse> = {
|
|
id: 'latex_list_fonts',
|
|
name: 'LaTeX List Fonts',
|
|
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.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
query: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Filter matched against font family and full font name, e.g. "Noto Serif"',
|
|
},
|
|
maxResults: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Maximum number of fonts to return (default: 50, max: 200)',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: 'https://latex.ytotech.com/fonts',
|
|
method: 'GET',
|
|
headers: () => ({
|
|
Accept: 'application/json',
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response, params?: LatexListFontsParams) => {
|
|
const data = (await response.json()) as {
|
|
error?: string
|
|
fonts?: Array<{
|
|
family?: string
|
|
name?: string
|
|
styles?: string[]
|
|
}>
|
|
}
|
|
|
|
if (!response.ok || data.error) {
|
|
return {
|
|
success: false,
|
|
error: data.error || `LaTeX font listing failed (${response.status})`,
|
|
output: { fonts: [], totalMatches: 0 },
|
|
}
|
|
}
|
|
|
|
const query = (params?.query ?? '').trim().toLowerCase()
|
|
const matches = (data.fonts ?? []).filter((font) => {
|
|
if (!query) return true
|
|
return (
|
|
(font.family ?? '').toLowerCase().includes(query) ||
|
|
(font.name ?? '').toLowerCase().includes(query)
|
|
)
|
|
})
|
|
|
|
const requested = Math.trunc(Number(params?.maxResults))
|
|
const maxResults =
|
|
Number.isFinite(requested) && requested > 0
|
|
? Math.min(requested, MAX_RESULTS_LIMIT)
|
|
: DEFAULT_MAX_RESULTS
|
|
const fonts: LatexFont[] = matches.slice(0, maxResults).map((font) => ({
|
|
family: font.family ?? '',
|
|
name: font.name ?? '',
|
|
styles: font.styles ?? [],
|
|
}))
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
fonts,
|
|
totalMatches: matches.length,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
fonts: {
|
|
type: 'array',
|
|
description: 'Fonts available to the LaTeX compiler',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
family: { type: 'string', description: 'Font family name' },
|
|
name: { type: 'string', description: 'Full font name' },
|
|
styles: { type: 'array', description: 'Available styles, e.g. Bold or Italic' },
|
|
},
|
|
},
|
|
},
|
|
totalMatches: {
|
|
type: 'number',
|
|
description: 'Total number of fonts matching the filter, before truncation',
|
|
},
|
|
},
|
|
}
|