feat(agentic): add --base to devframe connect port probes - #405
zahidzorbaz wants to merge 2 commits into
Conversation
`probeDevframeOrigin` took any 2xx answer as a live devframe and fell back
to `{}` when the body did not parse. A host with an SPA fallback (Vite
serving `index.html` for unknown paths) therefore passed as a devframe
with no MCP route: `devframe connect --port` listed a phantom instance and
failed with DF0051 instead of DF0050, and registry liveness checks kept
stale records whose port now serves an unrelated app.
A candidate now counts only when it answers with a JSON object.
Refs devframes#403
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`--port` probes always looked for `__connection.json` at the root, so a devframe or hub mounted below it (Vite DevTools at `/__devtools/`) could not be reached, and the advertised MCP path was resolved against `/`. Add a `base` connector option and a `--base <path>` CLI flag (default `/`) for the explicit port probes, and resolve the MCP path against that base, the same way the instance shell does for registry records. `probePort` is exported for focused tests. Document the flag in the CLI help and the MCP adapter's Discovery section. Closes devframes#403 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
◈ PR Lens
Architecture 3 components touched across 3 lanes. Play the interactive walkthrough Inside the changed components — 2 viewsComponent view — CLI base path resolution How CLI connect passes the base path and resolves relative MCP tool endpoints. Component view — Origin probe and JSON validation How the instance registry validates JSON connection metadata and ignores HTML SPA fallbacks. Data flow
Follow each request, response and payload View
Tip Run 🪧 More tips
Thanks for using PR Lens! It's built by Coldtea, free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
@zahidzorbaz is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
Description
devframe connect --port <n>couldn't reach a devframe mounted below the root of its host, such as Vite DevTools at/__devtools/. When it failed, it reported the misleading DF0051 ("no MCP endpoint, restart with --mcp"). This PR fixes both parts of the problem.fix(devframe): only accept a JSON object as connection meta.probeDevframeOrigincounted any 2xx answer as a devframe and fell back to{}for an unparseable body. A host with an SPA fallback (Vite servingindex.html) therefore passed as a devframe with no MCP route. A candidate now counts only when it answers with a JSON object. With this change:--portprobe on the wrong path yields "no instance" (DF0050) instead of a phantommcp: nullinstance;feat(agentic):--base <path>fordevframe connectport probes. There is a newbaseoption inConnectServerOptions, exposed as the--baseCLI flag (default/). The explicit port probes look for__connection.jsonunder that base. The advertised MCP path is resolved against the same base, asinstance-shellalready does for registry records. No mount path is hardcoded. Registry records keep their ownbasePathand ignore--base. The CLI help, the "no instances" hint and the MCP adapter's Discovery section document the flag.probePortis exported for focused tests, following the precedent ofresolveAuthTokenandbuildInstanceRequestHeaders, and the tsnapi snapshot for@devframes/agentic/connectis updated to match.Verified against a live Vite 8.3 +
@vitejs/devtools0.7.5 dev server with an empty registry:--port 5174port-5174,mcp: null,call-tool→ DF0051call-tool→ DF0050--port 5174 --base /__devtools/mcp.url…/__devtools/__mcp, 11 tools, read-onlycall-toolsucceedsLinked Issues
Closes #403
Additional context
--portfallback and the probe itself.instance-registry.test.tscovers an HTML SPA fallback, a non-object JSON body, meta under a non-root base, and pruning a record whose port serves an SPA.connect.test.tscoversprobePortwith a base, base normalization, and a root that serves only the SPA fallback.cli/main.test.tschecks the help output.main. The newprobePorttests fail onmainonly becauseprobePortisn't exported there.pnpm lint,pnpm knip,pnpm typecheckandpnpm buildpass.pnpm testhas two failures unrelated to this change:tests/exports.test.ts > devframe > dts: ./internalalso fails on a cleanmaincheckout. It's an ordering difference in the snapshot (importAgenticMcpsorted differently). This PR doesn't touch that snapshot.src/utils/serve-static.test.tshits intermittentETIMEDOUTconnecting to its local server under full-suite load. A different test fails on each run, and the file passes on its own, both onmainand on this branch.🤖 Generated with Claude Code