diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f788f3..9d97509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,7 +79,12 @@ ### Changed -1. **A `-D` override value is resolved with the same `${ENV_VAR:default}` substitution as a file value - the engines' +1. **`web.crawl` accepts a relative `include`.** A prefix that does not start with `/` now matches anywhere in a link's path, + since a model names a section as `guides/` as often as `/guides/`: the live drive of the Playground's `site-notes` graph + showed a crawl returning the start page alone because the model's `include` was relative. The README's Event-over-HTTP + example lists one route per entry - the engines' map takes no comma-separated list. + +2. **A `-D` override value is resolved with the same `${ENV_VAR:default}` substitution as a file value - the engines' change of the same day.** `AppConfig.get` returned an override as written, so a key moved from `application.yml` to a `-D` flag silently lost its substitution and a credential had to travel on the command line in clear. Now the value of a `-D` override (and of `AppConfig.set`) - an environment variable with a default, or a reference to another diff --git a/extensions/agent-tools/README.md b/extensions/agent-tools/README.md index e03c043..8244e47 100644 --- a/extensions/agent-tools/README.md +++ b/extensions/agent-tools/README.md @@ -87,7 +87,7 @@ identifies itself as `Mercury-Composable-AgentTools/`. | Route | Row | Arguments | Result | | --- | --- | --- | --- | | `web.fetch` | `web_fetch` | `url` (required); `as`: `text` (default), `markdown`, `raw` | `{url, status, content_type, title, text, bytes, truncated}`; HTML is reduced to its readable text (scripts, styles, `nav`, `header` and `footer` dropped; headings, lists, code and links kept as text or as Markdown); a text resource (`text/*`, JSON, XML) is returned as is; `raw` returns the body as received; a binary response is a 400; the page's own status (a 404, a 500) is a result, not an error | -| `web.crawl` | `web_crawl` | `url` (the start page); `max_pages` (default 10, cap `tools.web.crawl.max.pages`, 50); `max_depth` (default 2, cap 5); `include` (a path prefix the followed links must start with) | `{pages: [{url, title, text, bytes}], visited, truncated}`; same host only, links followed breadth-first, `robots.txt` honoured, `tools.web.crawl.delay.ms` (500) between requests, each page's text cut to `tools.web.page.max.chars` (20 000), the whole result to 60 000 characters | +| `web.crawl` | `web_crawl` | `url` (the start page); `max_pages` (default 10, cap `tools.web.crawl.max.pages`, 50); `max_depth` (default 2, cap 5); `include` (a path prefix the followed links must start with when it starts with `/`, else a part of the path - `guides/` and `/docs/guides/` both work) | `{pages: [{url, title, text, bytes}], visited, truncated}`; same host only, links followed breadth-first, `robots.txt` honoured, `tools.web.crawl.delay.ms` (500) between requests, each page's text cut to `tools.web.page.max.chars` (20 000), the whole result to 60 000 characters | The crawl is a bounded reader of a documentation section or a small site, not a spider: the page cap, the depth, the include prefix and the delay are all limits, and a model that needs more asks again with a narrower start. HTML is read @@ -180,10 +180,11 @@ graph's catalog row names the route: ```yaml event: http: - - route: 'file.read, file.write, file.list, file.search, file.extract, web.fetch, web.crawl' + - route: 'file.read' target: 'http://127.0.0.1:8089/api/event' - - route: 'graph.schema, graph.query, graph.write, graph.ingest, time.now' + - route: 'web.fetch' target: 'http://127.0.0.1:8089/api/event' + # ... one entry per route the graph names - the engines' map takes no comma-separated list ``` **Logs.** A tool logs its route, the status, the byte, entry or page count and the host of a URL - never a path's diff --git a/extensions/agent-tools/agent_tools.py b/extensions/agent-tools/agent_tools.py index f8e253c..a484acf 100644 --- a/extensions/agent-tools/agent_tools.py +++ b/extensions/agent-tools/agent_tools.py @@ -1676,6 +1676,12 @@ def _host_header(parts: SplitResult) -> str: return host if parts.port in (None, default) else f"{host}:{parts.port}" +def _under(path: str, include: str) -> bool: + """Whether a link's path is inside the crawl's include: a prefix when the include starts with a + slash, else anywhere in the path - a model names a section as `guides/` as often as `/guides/`.""" + return path.startswith(include) if include.startswith("/") else include in path + + class WebTools: """The two web tools over one allowlist, sharing one HTTP client without a cookie jar.""" @@ -1819,8 +1825,6 @@ async def web_crawl(self, _headers: dict[str, str], body: Body) -> Any: include = args.get("include") if include is not None and not isinstance(include, str): raise AppException(400, "include must be a string") - if include and not include.startswith("/"): - include = "/" + include start = self.sandbox.check_url(url) site = (start.scheme, (start.hostname or "").lower(), start.port) robots = await self._robots(start) @@ -1871,7 +1875,7 @@ async def web_crawl(self, _headers: dict[str, str], body: Body) -> Any: candidate.port, ) != site: continue - if include and not candidate.path.startswith(include): + if include and not _under(candidate.path, include): continue normalized = urlunsplit( ( diff --git a/memory/open-threads/thread-bp-agent-tools-python.md b/memory/open-threads/thread-bp-agent-tools-python.md index c8e9dc6..67c7c2c 100644 --- a/memory/open-threads/thread-bp-agent-tools-python.md +++ b/memory/open-threads/thread-bp-agent-tools-python.md @@ -11,7 +11,10 @@ MERGED 2026-11-17 - the pack's version 1 of the tools is complete): the four graph tools over the Bolt driver (`graph` extra; a `Transaction` seam, a fake for the tests, Neo4j and Memgraph schema procedures), `file.extract` behind the `documents` extra, `dev/graph-up.sh` / `graph-down.sh`, 161 tests and a live round trip on the development Neo4j; eight defaults set without a ruling in - the session log. Next: the engines' page and spec for step 2, then the Node twin. The plan as settled - step 1: `extensions/agent-tools/agent_tools.py` (the layout of `extensions/mcp-binding`: a module docstring, a + the session log. The Node twin landed as mercury-nodejs #130; the Playground's three graphs as + mercury-composable #647 (step 4), driven live through both packs 2026-11-17 - the drive taught a relative `include` + (PR #65, with the README's Event-over-HTTP snippet corrected to one route per entry). Next: nothing + here until the recipes page (step 5, the engine's). The plan as settled - step 1: `extensions/agent-tools/agent_tools.py` (the layout of `extensions/mcp-binding`: a module docstring, a `README.md`, `resources/application.yml`, a `describe` command printing every catalog row, `platform.on_startup` for the gated registration) with the file tools inside `tools.file.root` (`file.read`, `file.write` marked `write: true` with `create` the default, `file.list`, `file.search`; paths resolved with symlinks followed and refused outside the root; diff --git a/memory/sessions/2026-11-17-115327.md b/memory/sessions/2026-11-17-115327.md new file mode 100644 index 0000000..aaedd72 --- /dev/null +++ b/memory/sessions/2026-11-17-115327.md @@ -0,0 +1,24 @@ +# Session (2026-11-17T11:53:27.000Z) + +**Agent:** Claude Code +**Title:** The live drive of the Playground's agent-tools graphs taught two things here - a relative include, one route per map entry + +## What We Did + +- The three Playground graphs (mercury-composable #647) were driven live through this pack's `extensions/agent-tools` and + the LLM helper on Haiku 4.5: the four corpus documents ingested, two queries answered with sources, `site-notes` crawling + this project's published documentation and writing its notes after approval. The tools behaved; two lessons landed here: + - **`web.crawl`'s `include`**: the model passed `knowledge-graph/` and the crawl returned the start page alone, because the + tool prepended `/` and no link path began with `/knowledge-graph/`. A relative include now matches anywhere in the path; + an absolute one stays a prefix. Pinned by a test; the Node twin changed the same way. + - **The README's Event-over-HTTP example** listed the routes comma-separated in one entry; the Java engine refuses that + (`Invalid Event over HTTP config entry`). One route per entry now. +- Thread [[bp-agent-tools-python]] carries the lockstep state: steps 1-4 done, step 5 is the engine's. + +Opened as PR #65. + +## Memory References + +- Referenced: bp-agent-tools-python (edited: the drive's lessons, the state after step 4) +- Created: (none) +- Superseded: (none) diff --git a/tests/test_agent_tools.py b/tests/test_agent_tools.py index cf24414..46b7410 100644 --- a/tests/test_agent_tools.py +++ b/tests/test_agent_tools.py @@ -848,6 +848,13 @@ async def test_crawl_follows_links_breadth_first_inside_the_include( assert [p["title"] for p in reply["pages"]] == ["Home", "Section A", "Section B", "Section C"] assert reply["pages"][1]["text"] == "A\n\nText of A, see C." assert (reply["visited"], reply["truncated"]) == (4, False) + relative = await web_tools.web_crawl({}, {"url": f"{site}/", "include": "ocs/"}) + assert [p["url"] for p in relative["pages"]] == [ + f"{site}/", + f"{site}/docs/a", + f"{site}/docs/b", + f"{site}/docs/c", + ], "a relative include matches anywhere in the path" shallow = await web_tools.web_crawl({}, {"url": f"{site}/", "include": "docs/", "max_depth": 1}) assert [p["url"] for p in shallow["pages"]] == [f"{site}/", f"{site}/docs/a", f"{site}/docs/b"] assert shallow["truncated"] is False