Skip to content

feat(runner): add pandoc and WeasyPrint for offline PDF rendering - #2

Merged
TomasPalsson merged 1 commit into
fix/nsjail-no-cgroup-clonefrom
feat/runner-pdf-tools
Sep 23, 2026
Merged

TomasPalsson merged 1 commit into
fix/nsjail-no-cgroup-clonefrom
feat/runner-pdf-tools

Conversation

@TomasPalsson

Copy link
Copy Markdown

@busla, this is a small add-on to your branch for #769.

Why

We want the apro-pdf skill (aproorg/apro-skills#23) to run in the code interpreter, so a branded PDF comes back as a chat attachment. The sandbox has no Chrome and no network, so the skill got an offline path: pandoc → WeasyPrint, with Mermaid pre-drawn by mermaidx (real mermaid.js v11 in embedded QuickJS). This PR puts those tools in the runner image. The nsjail/seccomp policy doesn't change.

What

  • api/Dockerfile
    • new pandoc-fetch stage: official static pandoc 3.11, sha256-pinned per TARGETARCH, copied to /usr/local/bin/pandoc (/usr is mounted in the jail; bookworm apt only has 2.17, and apt is deleted later anyway).
    • sandbox-build: WeasyPrint runtime libs libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz-subset0.
  • docker/package-init.sh: weasyprint==70.0, mermaidx==0.9.5 (pinned). Their deps resolve for Python 3.14 on aarch64 (quickjs-ng abi3 wheel).

Verified (local arm64 build, --target lambda-microvm-runner)

  • pandoc --version → 3.11.
  • /pkgs/python/3.14.4 imports weasyprint 70.0 and mermaidx, and renders a PDF with Icelandic text.
  • Full skill run inside the image: --network none --memory 512m, /etc/fonts hidden like in the jail, and the skill mounted read-only at /mnt/data/skills/apro-pdf. A 615-line SOW with 3 Mermaid diagrams → CHECKS: OK, 25 pages, brand fonts embedded, 8.7 s.
  • Not yet run through the real nsjail /execute path. No seccomp change is expected: no browser, no sockets, no memfd_create.

Size

About +190 MB on a ~5.2 GB image. Almost all of it is the static pandoc binary (168 MB). WeasyPrint + mermaidx add ~17 MB, and the Pango libs a few MB.

Rollout (after merge into your branch)

Rebuild the runner through the workflow, register a new MicroVM image version with tools/code-interpreter/create-microvm-image.sh, and bump code_interpreter_runner_image_version for apro-sandbox in #769.

Static pandoc 3.11 (sha256-pinned), WeasyPrint's Pango/HarfBuzz runtime libs,
and weasyprint + mermaidx in /pkgs, so the apro-pdf skill can render branded
PDFs inside the jail without Chrome or network.
@busla

busla commented Sep 23, 2026

Copy link
Copy Markdown

nice! go ahead and merge

@TomasPalsson
TomasPalsson merged commit d4fd61d into fix/nsjail-no-cgroup-clone Sep 23, 2026
@TomasPalsson
TomasPalsson deleted the feat/runner-pdf-tools branch September 23, 2026 13:30
busla pushed a commit that referenced this pull request Nov 20, 2026
Static pandoc 3.11 (sha256-pinned), WeasyPrint's Pango/HarfBuzz runtime libs,
and weasyprint + mermaidx in /pkgs, so the apro-pdf skill can render branded
PDFs inside the jail without Chrome or network.

(cherry picked from commit d4fd61d)

Also carries: feat(runner): render office documents and OCR text in the sandbox (#6, 380589e), folded in when replaying onto v1.11.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants