Repository navigation
feat(mcp): add a wait-for agent tool - #413
Merged
Merged
Conversation
Agents that click or navigate no longer have to poll other tools in a loop. pangular:wait-for blocks, up to timeoutMs, until a component appears or goes, a navigation settles, an HttpClient call finishes or a new error arrives. It only reads what the collectors already pushed. Refs #372.
Contributor
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
|
View your CI Pipeline Execution ↗ for commit 9e55908
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
7 tasks done
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 and why
The "general wait-for tool" item from #372.
After a click or a navigation, an agent had to call other tools in a loop until the page caught up.
pangular:wait-forblocks until a condition holds, up totimeoutMs(default 5000, kept between 100 and 30000), then answers with what it saw. It is areadtool: it only reads what the collectors already pushed to the server and sends nothing to the page.conditioncomponentselectoris renderedselectorcomponent-goneselectorselectornavigationurlwhen givenurl(optional)http-callurl, or any, finished after the wait startedurl(optional)errorcodewhen givencode(optional)updatedevents of the component tree, router and HTTP states, and also re-reads every 200ms (the errors state has no change event). It renews the activity lease every 2s so pages keep pushing during a long wait. Every timer and listener is removed before it answers.Timed out after Nms waiting for …. Last state: …, not an error.condition, a blankselector, an unknownpage, no page reporting that data) get a markdown answer, like the selector guard oninspect-component.page/pageIdwork like the other page tools.Inspector gating
Each condition needs its own inspector, so the entry lists
components,router,httpanderrors. A newanyInspectorfield onAgentEntrykeeps the tool while any of them is on for agents (otherwisecomponentsalone would hide it). Theconditionenum lists only the conditions whose inspector is on, and the tool is not registered when none is.Left out
navigationwithouturlcan hold before a navigation that was just triggered reaches the page. The docs say so and recommend passingurl.Docs: a
wait-forsection inagents/tools.md(tool count, conditions and arguments), the structured-output table inagents/mcp-server.md, the page-text row insecurity.md, theanyInspectorrow in the contributing guide, and a line in the shippedpangular-inspectorskill.Refs #372.
How it was verified
pnpm commit:checkpnpm format:checkpnpm typecheckpnpm test:devtools(3133). Newwait-for.test.ts(17 tests): each condition through the real devframe withpush-component-tree,push-router,push-httpandpush-errors; the timeout answer; argument checks; inspector gating; cleanup with fake timers (vi.getTimerCount()back to zero on success, timeout and a throwing check); timeout clamping.agent-metadataandtool-metadatafixtures updated.pnpm skills:checkapps/docsupdated andpnpm docs:buildpassesapp, so noextension:buildSummary by CodeRabbit
wait-fortool that waits for components to appear or disappear, navigation to finish, HTTP calls to complete, or new errors to occur. It returns the matching or latest state when the wait ends, including on timeout.wait-for.