Repository navigation
feat(cli): built-in web_search and web_fetch on nginjen-lite (#625 part 1b) - #672
Merged
Merged
Conversation
…art 1a) web::vetted_get performs a single GET through the existing vet-and-pin resolver: the host is checked up front (a private address is refused before any connection) and again in the connection's own resolver. No redirect is followed (a 3xx comes back with an unread body), a non-2xx status is a response rather than an error, the body is capped (error or truncate and flag) and the timeout covers the hop. vet_public_url and allow_private_from_env expose the check and the opt-out.
# Conflicts: # CHANGELOG.md
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
Part 1b of #625: built-in
web_search(keyless engines) andweb_fetch(HTML converters, robots.txt), on nginjen-lite 0.1.0 and tole's own HTTP client, behind the defaultweb-builtinfeature of tole-cli. The nginjen backend (NGINJEN_BASE_URL+NGINJEN_API_KEY) and thetole doctorlines follow in part 2.Depends on: #671 (part 1a,
web::vetted_get), which is merged. The latestdevelopis merged into this branch (a merge commit), and the PR now targetsdevelop.Why
Out of the box tole had no search, and its fetch returned plain text only. The owner wants nginjen's core built in, with tole's guards kept: one client, the SSRF check on every hop, and no secrets in URLs or queries.
Changes
crates/tole-cli/src/web_builtin.rs(new,web-builtinfeature):TolHttpimplements nginjen-lite'sHttpClientwith lite'sget_following_redirectsaroundweb::vetted_get, one hop at a time. On every hop:check_hoprefuses an https-to-http hop, and a hop whose URL carries a known secret;Pacerallows at most one request per second per host, remembering at most 64 hosts;BuiltinSearchTool(web_search):search_with_fallbacks; a non-2xx answer moves to the next engine;BuiltinFetchTool(web_fetch):RobotsChecker(64-origin cache, fail-open);formatismarkdown(default),compact,text,htmlorlinks. The tool description sayscompactdrops inline bold, italic, code and image alt text (nginjen verify_package edit-distance: cover boundary cases / simplify early-exit; scoped-vs-bare consistency #235);tole/<version> (+https://github.com/codecoradev/tole).tool_roster::build: a configuredTOLE_WEB_FETCH_URL/TOLE_WEB_SEARCH_URLbackend still wins. Otherwise the built-in tools are registered (web-builtin); without the feature, today's direct fetcher is used and search needs a backend.web-builtin = ["dep:nginjen-lite", "dep:url"], on by default;nginjen-lite = { version = "0.1.0", features = ["robots"] }(nopdf,readabilityorureq);url, already in the tree.tests/tool_specs.rs: the full-registry spec size now includes the built-in pair: 16,032 characters for 30 tools, under the unchanged 18,000 bound.docs/perf.mdwith the size and dependency table.Final numbers (re-measured on this head; also in
docs/perf.md):tolerelease bytes--no-default-features)web-builtinweb-builtin)sort -u, 30 distinct crates; 4 of them build-time proc-macros)Memory: per tool, a bounded robots cache (at most 64 origins) and a bounded per-host pacer (at most 64 hosts); no threads; every input and output is capped per call.
Testing
web_builtin_tests.rswent red against stubs (7 of 7 failed), then green.develop:cargo fmt --allcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspacecargo test -p tole-core --no-default-featuresweb-builtinweb_builtinunit tests,tool_specsand the crate counts.cora review --no-llm --base feat/web-vetted-hop: no issues.