This `brownstone-middleware` package, currently at version 0.1.4, integrates with Express.js applications to manage and monetize AI agent access. It operates by detecting known AI crawlers and bots based on their user-agents. The middleware offers capabilities for logging AI hits (metering), enforcing access policies by blocking unauthorized agents with a 403 status, and injecting licensing metadata into HTML responses via a `<meta name="ai-usage">` tag. This allows AI systems to directly read usage terms. A key differentiator is its reliance on an external Brownstone API for comprehensive analytics, centralized licensing configuration, and robust bot detection, providing developers with granular control over how their content is accessed and used by AI models. The project is actively maintained, with ongoing updates to agent detection and API features.
npm install brownstone-middlewareVerified import paths — ran on the pinned version, not inferred.
Initializes an Express application with Brownstone middleware, enabling AI bot detection, logging, and optional enforcement of licensing rules, along with injecting license metadata into HTML responses.
Obtain an API key from `brownstoneai.dev` and pass it as the `apiKey` option to the middleware configuration object.
Ensure your application serves HTML responses for paths where AI meta-tag injection is desired.
Monitor the package's GitHub repository and npm release notes for changes before upgrading, especially in production environments.
Regularly update the `brownstone-middleware` package to benefit from the latest AI agent detection rules. Consider supplementing with other bot detection strategies if maximum coverage is critical.
Ensure you are using `const brownstone = require('brownstone-middleware');` if your project is CommonJS. If using ESM, a bundler might be needed to handle the CJS package, or await official ESM support in future versions.Provide a valid `apiKey` string, obtained from `brownstoneai.dev`, to the middleware options object: `brownstone({ apiKey: 'your_valid_key', metering: true })`.