Registry / devops / vite-plugin-agent-tail

vite-plugin-agent-tail

JSON →
library0.4.0jsnpmunverified

A Vite plugin that captures browser console.log, console.warn, console.error, unhandled errors, and unhandled promise rejections during development and writes them to timestamped log files on disk. Current stable version is 0.4.0. Published as part of the agent-tail ecosystem, it injects a script via HTML transformation that intercepts console methods, batches output, and sends it to the dev server via sendBeacon. Key differentiators: provides tail -f friendly logs, latest symlink, and integrates with the agent-tail CLI for combined browser+server log viewing. Requires Vite >=5.0.0 and ships TypeScript types.

npm install vite-plugin-agent-tail
INSTALL
IMPORT
SIG · VITE-PLUGIN-AGENT-
V
vite-plugin-agent-tail
devopsjavascriptv0.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

agentTail
import { agentTail } from 'agent-tail/vite'
import agentTail from 'agent-tail/vite'
Named export from 'agent-tail/vite' subpath. Default import will fail.
agentTail()
export default defineConfig({ plugins: [agentTail()] })
export default defineConfig({ plugins: [agentTail] })
agentTail is a factory function, must be called. Omitting parentheses is a common mistake.
agent-tail (CLI)
import { agentTail } from 'agent-tail/vite'; import { defineConfig } from 'vite'
import { agentTail } from 'agent-tail'
The main 'agent-tail' package does not export the Vite plugin directly; use 'agent-tail/vite' subpath.

Install agent-tail, add the Vite plugin to vite.config.ts, and tail the browser log file.

// install: npm install -D agent-tail // vite.config.ts import { defineConfig } from 'vite'; import { agentTail } from 'agent-tail/vite'; export default defineConfig({ plugins: [agentTail()], }); // Terminal 2: view logs // tail -f tmp/logs/latest/browser.log // or use CLI: agent-tail tail browser -f
agent-tail --version
Debug
Known issues
breakingAs of v0.4.0, the import path changed from 'vite-plugin-agent-tail' to 'agent-tail/vite'. Old path no longer works.
fix
Update import from 'vite-plugin-agent-tail' to 'agent-tail/vite'.
affects: <0.4.0
gotchaThe plugin only captures logs during development (vite dev server). It does not work in production builds.
fix
Use a production logging solution like Sentry or LogRocket for production builds.
affects: >=0.0.0
gotchaThe plugin injects a script into HTML via transformIndexHtml. If your Vite config uses custom HTML or SSR, injection may not work correctly.
fix
Ensure your HTML entry point (index.html) is present and not served externally.
affects: >=0.0.0
gotchaLogs are written to a 'tmp/logs/' directory relative to the project root. Ensure this directory is writable and not excluded by .gitignore if you want to track logs.
fix
Add 'tmp/logs/' to .gitignore to avoid committing logs, or use a custom log directory.
affects: >=0.0.0
Errors
Common errors & fixes
ERR_PNPM_NO_MATCHING_VERSION_INSIDE_WORKSPACE  For agent-tail@0.4.0, the dependency vite@>=5.0.0 not satisfied in workspace
Vite version in project is below 5.0.0.
fix
Update Vite to >=5.0.0: npm install vite@^5.0.0
Error: agentTail is not a function
Calling agentTail as a plain plugin without invoking the factory function.
fix
Use plugins: [agentTail()] instead of plugins: [agentTail].
Cannot find module 'agent-tail/vite' or its corresponding type declarations.
Importing from 'agent-tail/vite' but package is not installed or not using the umbrella package.
fix
Install agent-tail: npm install -D agent-tail
TypeError: Failed to execute 'sendBeacon' on 'Navigator': The body of the beacon is not a valid type.
The injected script uses sendBeacon; if the browser or environment blocks it (e.g., HTTP vs HTTPS mismatch), logs may fail silently.
fix
Ensure the dev server runs on HTTPS or same-origin. agent-tail attempts to send to the current origin.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
viterequiredpeer dependency, version >=5.0.0 required for plugin compatibility
Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
vite-plugin-agent-tail — npm install vite-plugin-agent-tail · libregistry