Skip to content

refactor(evi): dedupe git, gateway and capture wiring shared with lib - #761

Merged
HugoRCD merged 1 commit into
mainfrom
evi/dedupe-evi-tool-wiring
Oct 2, 2026
Merged

HugoRCD merged 1 commit into
mainfrom
evi/dedupe-evi-tool-wiring

Conversation

@evlogai

@evlogai evlogai Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Batch of dedupe findings from the repo-health-sweep at revision 7f4a26fa192faaf0a359140c97b9c1e294609344, all parent-verified against main.

Problem. Three pieces of Eve wiring under apps/evi/agent/tools/ duplicated logic that agent/lib/ already owns with colocated tests:

  • tools/git.ts defined its own canShip(auth) that was character-identical to canAccessAdminTools in lib/trust.ts, used at four call sites.
  • tools/ai-gateway.ts kept a private gatewayFetch plus BASE_URL/FETCH_TIMEOUT_MS constants while lib/gateway.ts owns the Gateway client (now the single owner, exported, with tests).
  • tools/capture.ts kept a private captureFrame, SCREENSHOT_DIR and FrameRequest type while lib/capture.ts owns the frame pipeline (now the single owner, exported, with tests).

Preserved behavior. Same git gating decision for every session type, same Gateway request shape (URL params, bearer token, 10s timeout, evi.AI_GATEWAY_REQUEST_FAILED on non-ok), same capture frame sequence (viewport, settle wait, target probe, scroll-into-view marker, screenshot). The moved comment ("Maintainer and schedule-app turns ship code...") stays on resolveGitTools where the gate is checked.

-import { isMaintainer, isScheduleAppAuth } from '../lib/trust'
+import { canAccessAdminTools } from '../lib/trust'
-/** Maintainer and schedule-app turns ship code; nothing else reaches git over the network. */
-function canShip(auth: SessionAuthContext | null): boolean {
-  return isMaintainer(auth) || isScheduleAppAuth(auth)
-}
 const resolveGitTools = (_event: unknown, ctx: DynamicResolveContext) => {
-  if (!canShip(ctx.session.auth.current)) return null
+  if (!canAccessAdminTools(ctx.session.auth.current)) return null

New coverage. lib/gateway.test.ts gains a gatewayFetch describe (params + bearer header + parsed body; non-ok response maps to the structured error with the response body in internal), and lib/capture.test.ts gains a captureFrame describe covering the unresolved-target error, the settle wait, and the scroll-into-view marker sequence.

Verification. pnpm run lint, pnpm run typecheck, pnpm run test all exit 0 on the branch; evi suite 289 passed (41 files), evlog suite 2008 passed. No changeset: the change is confined to apps/*.

ELI5

Evi's own agent code had three places where a tool file kept a second copy of logic that already lives in a shared library folder with tests next to it: who is allowed to run git commands, how AI Gateway requests are sent, and how a screenshot frame is captured. This deletes the copies and points at the shared one. How the agent behaves is unchanged, and the shared logic gained direct tests.

@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
evi Ready Ready Preview Oct 2, 2026 9:27am UTC
4 Skipped Deployments
Project Deployment Actions Updated
evlog-docs Skipped Skipped v0 Oct 2, 2026 9:27am UTC
evlog-render-lab Skipped Skipped Oct 2, 2026 9:27am UTC
evlog-telemetry Skipped Skipped Oct 2, 2026 9:27am UTC
just-use-evlog Skipped Skipped Oct 2, 2026 9:27am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 87e6b4fa-4aaf-4960-b8db-680be274a859

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions
github-actions Bot requested a review from HugoRCD October 2, 2026 09:26
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@evlog/cli@761
npm i https://pkg.pr.new/evlog@761
npm i https://pkg.pr.new/@evlog/nuxthub@761
npm i https://pkg.pr.new/@evlog/telemetry@761

commit: cd2dd04

@HugoRCD
HugoRCD merged commit 4f83950 into main Oct 2, 2026
20 checks passed
@HugoRCD
HugoRCD deleted the evi/dedupe-evi-tool-wiring branch October 2, 2026 16:09

This branch was successfully deployed

1 active and 4 inactive deployments
Preview – evi — cd2dd045 Deployed Oct 2, 2026 by vercel[bot]
Preview – evlog-docs — cd2dd045 Deployed Oct 2, 2026 by vercel[bot]
Preview – evlog-telemetry — cd2dd045 Deployed Oct 2, 2026 by vercel[bot]
Preview – just-use-evlog — cd2dd045 Deployed Oct 2, 2026 by vercel[bot]
Preview – evlog-render-lab — cd2dd045 Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant