Repository navigation
feat(sandbox): bake the document skills' libraries into the runtime - #3787
Merged
Merged
Conversation
The builtin docx, pptx, xlsx and pdf skills install their libraries at run time (npm install -g docx / pptxgenjs, pip install markitdown[pptx] and Pillow) and import others the image lacked (pandas, pdfplumber, pdf2image, reportlab, lxml). On a deployment whose sandbox egress blocks the package registries those installs fail and the skills fall back to a degraded path, as they would on a locked-down on-prem deployment. The Python libraries join the existing hash-locked document-python-requirements.txt, resolved for Python 3.12 against the hermes-agent pins so the later Hermes install keeps every version, with a hash for every cp312 manylinux wheel on amd64 and arm64. The Node libraries (docx, pptxgenjs, and react, react-dom, react-icons and sharp for the icon recipe in pptxgenjs.md) come from a committed package-lock.json installed with npm ci --ignore-scripts into /opt/tale/document-node. The image's NODE_PATH names that prefix and the session entrypoint puts the per-session npm prefix in front of it, so a package an exec installs still wins. image-size, which pptxgenjs declares but never loads, is overridden to a release without its denial-of-service advisories so the Trivy gate stays green. The root .gitignore keeps that one npm lock. The pdf skill's OCR route stays unbaked, since the image has no tesseract binary. The offline document check now covers both locks (bytes, versions, installed hashes) and exercises the skills' own paths as both session users with no network: pandas over the XLSX fixture, reportlab into pdfplumber, pypdfium2 and pdf2image, and docx plus a pptxgenjs deck with a sharp-rasterized icon read back through pandoc and markitdown. The conformance test asserts runnerd's NODE_PATH layering. The check's memory ceiling and the image size budget grow with the libraries.
The sandbox image now carries the libraries of the built-in docx, pptx, xlsx and pdf skills, so an agent equipped with them produces Office and PDF files on a deployment whose sandbox egress blocks package registries. The harness page says so beside its outbound-access note, including that the skills' own install commands then fail harmlessly and that OCR for scanned PDFs is not included; the hardening page tells operators restricting SANDBOX_EGRESS_ALLOWLIST that the document skills need no registry. EN, DE and FR change together.
A live agent run is the half the image test cannot cover: TASK-F46 has an agent equipped with docx and pptx deliver a Word memo and an icon deck while SANDBOX_EGRESS_ALLOWLIST admits no registry. The automation register records what the offline image check already owns, and the suite and readme counts move to 85 and 922 boxes.
The first lock pinned the newest release of every library, several of them one to twenty days old, while the repository's Renovate policy holds a release back 30 to 90 days so a compromised or broken one is pulled before adoption. These libraries land in every org's sandbox. Re-resolve both locks with nothing published in the last 90 days. Two younger releases stay because they fix known advisories: soupsieve 2.9.2 (two ReDoS advisories in 2.8.4) and sharp 0.35.4 (libheif HIGH advisories below it); the image-size override stays for the same reason. The pre-existing pins and Hermes' own pins are unchanged. The Node lock is now written by npm 11, the major the image's Node 24 ships, which records libc on sharp's platform packages, so npm ci on glibc no longer installs the musl builds (~18 MB). The README records the release-age rule and the refresh recipe.
security.yml only triggers on bun.lock, package.json files one level under services/, Dockerfiles and the Trivy ignore file. The sandbox runtime's document-skill npm lock and Python hash lock match none of them, so a Renovate bump or manual refresh of either would merge without the HIGH/CRITICAL gate. Add both to the pull_request and push path filters.
The entrypoint spelled out the baked document-library directory a second time. Prepend the session prefix to the NODE_PATH the image sets instead, the way PYTHONPATH already does, so the Dockerfile is the only place that names the baked directory. The resolved value is unchanged.
The check runs under the default session profile's 128-pid cap, which counts threads, while OpenBLAS (numpy) and libvips (sharp) size their pools to the host's cores. On a host with many cores the check could fail for reasons unrelated to the image. Run both with one thread.
The hardening page said the built-in document skills need no package registry at all. They create and read Word, PowerPoint, Excel and PDF files without one, but the pdf skill's OCR route is not in the image. Qualify the sentence in English, German and French.
The new path-filter comment claimed the gate checks both document locks for advisories. Trivy scans the npm lock only; the Python hash lock's file name is not one it reads for vulnerabilities. Say so, so nobody relies on a gate that does not exist.
…-skill-packages # Conflicts: # services/platform/tests/manual/readme.md
The image check found typing-extensions 4.16.0 where the document lock said 4.15.0: the Hermes install that follows the document libraries pins pydantic 2.13.4, which pulls 4.16.0, so the lock no longer described the image. The lock now names 4.16.0 with its wheel hash, so the later Hermes install keeps every version the lock lists, as its header promises.
Code scanning flags 'RUN cd' in a Dockerfile; npm ci --prefix installs into the same directory from the committed lock without changing the working directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Customer feedback on document creation led us to check what the builtin
docx,pptx,xlsxandpdfskills need at run time. They install libraries on the fly (npm install -g docx,npm install -g pptxgenjs,pip install "markitdown[pptx]",pip install Pillow) and import others the sandbox image did not carry (pandas, pdfplumber, pdf2image, reportlab, lxml). When sandbox egress blocks the package registries, as on a locked-down on-prem deployment, those installs fail and the skills fall back to a weaker path. This PR bakes those libraries into the sandbox runtime image. It follows the existing hash-locked pattern. The skills themselves stay org-seeded, and theirSKILL.mdfiles are untouched.services/sandbox-runtime/document-python-requirements.txtgainsmarkitdown[pptx]0.1.6, pandas 3.0.3, pdfplumber 0.11.10, pdf2image 1.17.0, reportlab 5.0.0 and lxml 6.1.1, plus their full dependency closure (41 pins, up from 8; the existing 8 are byte-identical). Pillow 12.2.0 comes from Hermes' pin. The lock is resolved for Python 3.12 withuv pip compile --only-binary :all: --exclude-newer 2026-07-01against thehermes-agent==0.18.0resolution as constraints. Hermes installs into the same interpreter afterwards and pins Pillow, requests, certifi, cryptography, packaging and PyYAML itself, so building this way keeps it from swapping any locked version. Every pin carries the hash of each cp312 manylinux wheel for amd64 and arm64, and there are no sdists. The Dockerfile still installs it with--require-hashes --only-binary=:all:.services/sandbox-runtime/document-node/withpackage.jsonandpackage-lock.json: docx 9.7.1, pptxgenjs 4.0.1, and react/react-dom 19.2.7, react-icons 5.7.0 and sharp 0.35.4 for the icon recipe in the pptx skill'spptxgenjs.md. The lock is written by npm 11, the major the image's Node 24 ships. It recordslibcon sharp's platform packages, sonpm cion glibc skips the musl builds. Every lock entry has an integrity hash, and no package has an install script. The image installs it withnpm ci --ignore-scriptsinto/opt/tale/document-nodeand setsENV NODE_PATHto it.entrypoint.shprepends the session prefix to that value (NODE_PATH=/agent/.runtime/deps/node/lib/node_modules${NODE_PATH:+:$NODE_PATH}, the same pattern asPYTHONPATH), so a package a session installs still wins andrequire('docx')from/agent/workspaceresolves.package-lock.jsonis gitignored repo-wide (bun is the package manager), so.gitignorenow keeps this one lock.overridesliftsimage-size, which pptxgenjs declares but never loads, from 1.2.1 to 2.0.4. Without that, the Trivy fs gate would fail on two HIGH advisories;npm audit --package-lock-onlynow reports 0.security.ymlnow also triggers onservices/sandbox-runtime/document-node/**and the Python requirements file, so a Renovate bump or manual refresh of the npm lock alone still runs the Trivy gate.pytesseractneeds a tesseract binary the image lacks), theqpdf/pdftkCLIs, and the JS alternativespdf-lib/pdfjs-distthat the pdf reference mentions without an install step (pypdf covers those paths). I also kept the skills' ownnpm install -g/pip installlines as they are. With egress they refresh the session copy; without it they fail while the baked library keeps working.platform/agents/harnessesnow says the document skills work without registry access and that OCR is not included. EN/DE/FRself-hosted/operate/security/hardeningtells operators settingSANDBOX_EGRESS_ALLOWLISTthat these skills need no registry to create and read Word, PowerPoint, Excel and PDF files, and that OCR is not included. The sandbox-runtime README documents both locks, the release-age rule and how to regenerate them, and.agents/repo.mdnotes where the libraries live.tests/integration/lib/document-tools.tsruns offline on a read-only root as uid 65534 and uid 10001. It checks both locks: bytes, exact versions, installed file hashes, and each npm package's installed integrity against the lock. It then runs the skills' actual paths: pandas reads the XLSX fixture, reportlab writes a PDF that pdfplumber, pypdfium2 and pdf2image/poppler read back, and Node writes a.docxand a pptxgenjs deck with a sharp-rasterized react-icons icon, which pandoc andpython -m markitdownread back. The check now imports onnxruntime and pandas in one interpreter (about 300 MB resident when measured), so its memory cap goes from 256m to 1g. It keeps the default session profile's 128-pid cap and runs OpenBLAS and libvips with one thread each, so a many-core host does not exhaust the cap.container-sandbox-runtime-test.tschecks runnerd'sNODE_PATHin a booted session and that a session-installed package shadows the baked one. Thesandbox-runtimesize budget goes from 5400 to 5900 MB.TASK-F46(agent with docx/pptx delivers a memo and an icon deck whileSANDBOX_EGRESS_ALLOWLISTadmits no registry) and a matching row inreference/automation.md.Checklist
bun run check: not run in full locally, because the machine is shared and loaded. CI runs the full gate. For the touched workspaces I ran typecheck, oxlint, oxfmt, docs tests, the manual gate and the sandbox-runtime daemon tests (see Test plan).bun run lint:sastpasses on the final head (467 rules on 4060 files, 0 findings).;/:).docs/{en,de,fr}/(harnesses, hardening).README.md/README.de.md/README.fr.md: N/A, the root READMEs don't cover sandbox image contents.services/sandbox-runtime/README.mdis updated.Test plan
What I verified locally, without a docker build (the disk is full):
uv pip compilewith--exclude-newer 2026-07-01(plus per-package exceptions for the pre-existing pypdf/elementpath pins and the soupsieve fix) gives identical results forx86_64-manylinux_2_36andaarch64-manylinux_2_36. A script checked that every pin has at least one hashed cp312 manylinux wheel for each architecture; the same script regenerates the previous lock's hash lines byte for byte. An OSV query over all 41 pins flags only Hermes' Pillow and cryptography pins (see Follow-ups).npm audit --package-lock-onlyreports 0.npx npm@11 ci --ignore-scripts --omit=dev --os=linux --cpu=x64 --libc=glibcfrom the committed lock installs 37 packages, 127 MB: only the glibc sharp and libvips builds, no musl and no wasm32. With npm 10 the wasm32 fallback (about 9 MB) is still installed; the image's Node 24 ships npm 11. Publish dates of every lock entry were checked withnpm view … time.uv pip checkclean) and annpm ciof the committed lock, with the thread-pool variables set. Only the/opt/talepaths were swapped for temp paths, and pandoc was replaced by readingword/document.xml, because pandoc is not installed here. It passes: 41 Python distributions, 4856 RECORD hashes, 37 npm integrity entries, and the DOCX/PPTX/PNG/PDF/XLSX round-trips.bun run --filter @tale/platform typecheck, oxlint on the touched test files,oxfmt --check,bun run --filter @tale/docs test(171/171),sh -nonentrypoint.sh, commitlint on the new commits. Earlier in this PR:bun run lint:manual,check-guide.tsonsuites/tasks.md,bun run lint:sast.@tale/sandbox-runtime-daemonbun test(earlier in this PR): 174 pass, 2 fail. The same 2 fail on a cleanmaintree (thestageFilesstalled-URL deadline and the partial-exec-body timing test) because the machine is loaded; this change doesn't touch them.How this gets proven for real: this PR touches
services/sandbox-runtime/**, sobuild.ymlruns Build sandbox-runtime (the actual image build, amd64) and then Validate images. That job runscontainer-image-test.ts, which includes the extendedcheckDocumentToolsfor both uids and the size budget, andcontainer-sandbox-runtime-test.ts, which includes theNODE_PATHcheck (its expected value also proves the entrypoint composes with the image'sENV NODE_PATH).security.ymlruns the Trivy fs gate over the new lock. arm64 is proven only at release time:release.yml's native "Verify native document tools" step runs the samecheckDocumentToolsagainst each pushed amd64/arm64 digest, and nothing builds arm64 on a PR.Not verified:
TASK-F46: I have not run a live agent task with blocked egress.NODE_PATH. A CLI in/opt/agentsthat probes for an optional module it doesn't bundle (for examplesharp) will now find the baked copy. Its ownnode_modulesstill resolve first.Follow-ups: