Built-in sandbox SHIM: a bs4 (BeautifulSoup)-compatible module for the
model's Python sandbox, implemented in PURE Python on the stdlib
html.parser — NO host/JVM bridge, NOT a line of Clojure or babashka. bs4 is
a third-party wheel that does not ship in GraalPy, so agents that reach for
from bs4 import BeautifulSoup (the natural partner to the requests shim:
fetch then parse) would otherwise hit ModuleNotFoundError; this extension
contributes a :ext/sandbox-shims entry that env-python/build-agent-context
installs into every sandbox Context (main + every sub_loop fork).
It builds a Tag / NavigableString tree via html.parser, with
find/find_all plus the plural and directional finders
(find_next_siblings, find_all_previous, find_parents, and the camelCase
aliases), CSS .select / .select_one (type / #id / .class /
[attr]/[attr=v]/~=/^=/$=/*=, descendant / > / + / ~
combinators, comma groups, and the structural pseudo-classes :not, :is,
:nth-child, :nth-of-type, :first-child, :last-of-type, :empty,
:root, :contains), get_text, .string/.strings/.stripped_strings,
sibling/parent navigation, dynamic soup.tagname access, tree mutation, and
HTML serialization (str / encode / prettify). Entity handling, escaping
and attribute quoting follow bs4 4.12, as does the introspection surface:
PageElement/ResultSet/SoupStrainer, output_ready, sourceline,
is_empty_element, soup.builder + bs4.builder, formatter objects, and
encoding detection (original_encoding, bs4.dammit.UnicodeDammit).
Differentially tested against real beautifulsoup4 4.12.3 over 193 probes with
zero output mismatches. A deliberate subset of full bs4 (no lxml or html5lib
parsers — another features argument is honored leniently rather than raising
FeatureNotFound — and no soupsieve namespace or :has() selectors).
Like shim-requests there are NO :shim/bindings: the shim is a
self-contained Python preamble with zero host callables. It publishes bs4
(+ bs4.element, bs4.formatter, bs4.builder, bs4.dammit,
bs4.diagnose) into sys.modules (so from bs4 import BeautifulSoup works)
and staples BeautifulSoup onto builtins.
Built-in sandbox SHIM: a `bs4` (BeautifulSoup)-compatible module for the model's Python sandbox, implemented in PURE Python on the stdlib `html.parser` — NO host/JVM bridge, NOT a line of Clojure or babashka. bs4 is a third-party wheel that does not ship in GraalPy, so agents that reach for `from bs4 import BeautifulSoup` (the natural partner to the `requests` shim: fetch then parse) would otherwise hit ModuleNotFoundError; this extension contributes a `:ext/sandbox-shims` entry that `env-python/build-agent-context` installs into every sandbox Context (main + every `sub_loop` fork). It builds a `Tag` / `NavigableString` tree via `html.parser`, with `find`/`find_all` plus the plural and directional finders (`find_next_siblings`, `find_all_previous`, `find_parents`, and the camelCase aliases), CSS `.select` / `.select_one` (type / `#id` / `.class` / `[attr]`/`[attr=v]`/`~=`/`^=`/`$=`/`*=`, descendant / `>` / `+` / `~` combinators, comma groups, and the structural pseudo-classes `:not`, `:is`, `:nth-child`, `:nth-of-type`, `:first-child`, `:last-of-type`, `:empty`, `:root`, `:contains`), `get_text`, `.string`/`.strings`/`.stripped_strings`, sibling/parent navigation, dynamic `soup.tagname` access, tree mutation, and HTML serialization (`str` / `encode` / `prettify`). Entity handling, escaping and attribute quoting follow bs4 4.12, as does the introspection surface: `PageElement`/`ResultSet`/`SoupStrainer`, `output_ready`, `sourceline`, `is_empty_element`, `soup.builder` + `bs4.builder`, formatter objects, and encoding detection (`original_encoding`, `bs4.dammit.UnicodeDammit`). Differentially tested against real beautifulsoup4 4.12.3 over 193 probes with zero output mismatches. A deliberate subset of full bs4 (no lxml or html5lib parsers — another `features` argument is honored leniently rather than raising `FeatureNotFound` — and no soupsieve namespace or `:has()` selectors). Like `shim-requests` there are NO `:shim/bindings`: the shim is a self-contained Python preamble with zero host callables. It publishes `bs4` (+ `bs4.element`, `bs4.formatter`, `bs4.builder`, `bs4.dammit`, `bs4.diagnose`) into `sys.modules` (so `from bs4 import BeautifulSoup` works) and staples `BeautifulSoup` onto builtins.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |