feat(miner-ui): add discover and attempt HTTP action routes - #6574
Conversation
Add POST /api/discover and POST /api/attempt in apps/loopover-miner-ui, each a thin non-bypassing bridge to the real runDiscover/runAttempt CLI entry points, inheriting vite-auth.ts's /api/* cookie gate (and, for attempt, runAttempt's Governor chokepoint). Add a structured onResult hook to runDiscover mirroring runAttempt's convention so the route can read the result; it fires only at the two success points, never on a reportCliFailure branch, and is additive to the unchanged exit-code return. Credentials are never read from the request body. Includes route, CLI-hook, and client-fetcher tests. Closes JSONbored#6522
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6574 +/- ##
=======================================
Coverage 93.62% 93.62%
=======================================
Files 678 678
Lines 67889 67891 +2
Branches 18657 18657
=======================================
+ Hits 63558 63560 +2
Misses 3360 3360
Partials 971 971
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-16 14:55:19 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|



Summary
Adds the first HTTP surface for the AMS miner's own action-taking commands (#6522):
POST /api/discoverand
POST /api/attemptinapps/loopover-miner-ui, each a thin, non-bypassing bridge to the real,unmodified
runDiscover/runAttemptCLI entry points. Both live under/api/*, so they inheritvite-auth.ts's existing same-origin cookie gate for free;/api/attemptadditionally inherits theGovernor chokepoint that
runAttemptalready routes every write through — no new or parallel executionpath is introduced.
The route handler's only job is marshaling a POST body into the CLI-style
argsarray each command'sparseDiscoverArgs/parseAttemptArgsalready accepts, and marshaling the structured result back out.To make
discover's result visible to a non-CLI caller,runDiscovergains a structuredonResulthookthat mirrors
runAttempt's existing convention exactly — it fires only at the two real success points(dry-run and full-run), never at a
reportCliFailurebranch, and is purely additive to the unchangedexit-code return. When a command exits non-zero without ever emitting a structured result (the
parse-error / paused / unexpected-error branches that intentionally don't call
onResult), the routereturns a structured error rather than assuming a result is present.
Credentials are never accepted from the request body — a
githubToken/token/apiKey-shaped fieldis dropped, not threaded through; the miner resolves its own local credentials server-side exactly as the
CLI does.
/api/attemptcan run for minutes (a full worktree + coding-agent iteration), so the routeimposes no timeout of its own.
The final chat dispatch-layer registration is intentionally out of scope — the issue states the routes,
the
onResulthook, and the client fetchers ship on their own, with only that last wiring step blocked onthe separate scaffolding issue.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
Ran the full local gate (
npm run test:ci) plusnpm audit, all green:git diff --checknpm run actionlintnpm run typechecknpm run test:coverage—packages/loopover-miner/lib/discover-cli.js(the only Codecov-gated change)at 100% lines / 99% branch; both sides of the new
options.onResult?.(...)optional-chaining at bothcall sites are covered.
apps/loopover-miner-uiis Codecov-excluded; its own vitest floor(85/85/75/85) stays green at 88.8/88.5/82.8/90.6.
npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderate(correct method+path and null for every sibling combination), well-formed dispatch, malformed/
missing-required-field bodies (400, never reaching the CLI fake), the exit-code-only-without-result
branch, the slow-resolving no-route-timeout case, credential-field dropping, the 500 catch, the
client fetchers' success / non-2xx / bad-shape / rejection paths, and the
runDiscoveronResulthook firing at both success points and never on the parse-error branch.
Safety
rankings, or private maintainer evidence are exposed. The routes explicitly never read a credential
field from the body (tested), and resolve credentials server-side exactly as the CLI does.
vite-auth.ts's existing same-origin/api/*cookie gate unchanged (registered before them invite.config.ts). Their own negative-pathcases (malformed body → 400 without invoking the CLI; non-discover/attempt method+path → fall
through) are covered.
/api/*routes, not part ofthe worker's OpenAPI spec, so no OpenAPI/MCP surface changed (
ui:openapi:checkis clean).typed client fetchers.
UI Evidence
N/A — this PR adds HTTP routes (
vite-discover-api.ts,vite-attempt-api.ts), their client fetchers, anda CLI
onResulthook. There is no visible UI, frontend page, or component change to screenshot.Notes
discoverhas no Governor chokepoint today (it only fans out + ranks + enqueues, none of the gated writeactions), so — matching the CLI exactly — this route adds none either. Only
/api/attemptinherits thechokepoint, via the unmodified
runAttempt.onResultaddition is backward-compatible:runDiscoverstill returns the same plain exit codebin/loopover-miner.js'sprocess.exit(exitCode)relies on; a regression test pins that the parse-errorbranch keeps its non-zero exit and never fires the hook.