How it works
Five layers. One module. Your site stays exactly as it is.
The English views are produced by an output filter on the real response, so static sites, PHP, WordPress and proxied apps all work. A server may implement any subset of the layers; mod_ai_agent implements all five.
- Layer 1
Exact
The page exactly as a human's browser receives it.
any URL, ?ai=exact
- Layer 2
Read
The page explained in English (JSON) or as Markdown.
?ai=guide, ?ai=text
- Layer 3
Discover
The site described in English; what exists.
/.well-known/ai, sitemap.json, /llms.txt
- Layer 4
Ask
Plain-English questions, plain-English answers.
/.well-known/ai/ask
- Layer 5
Act / Chat
Doing what a person does by clicking, as a conversation.
/actions, /act, Accept: application/vnd.ai-chat+json
Apache + Webserver For AI
- • learns public pages (never anything behind a login)
- • reads your code to find login-only pages
- • optional: your AI provider for open questions
Your site, unchanged
PHP, WordPress, Node, Laravel, static…
The learning gate
“I don't know this site well enough yet.”
Once you configure an AI provider, the module learns your public pages from anonymous visitor traffic. It only starts answering after a learning period (7 days by default) and a minimum number of pages (20). Until then it says so, instead of guessing. You can skip the wait with immediate activation or by priming the site once.
See a conversation in the live demo →{
"type": "answer",
"mode": "learning",
"answer": "I don't know Bluewhite well enough yet to answer questions about it. I started learning about this site 2 days ago and have read 7 pages so far. I will start answering once I have been learning for another 5 days and have read at least 20 pages.",
"learning": { "pages_learned": 7, "ready_after": "2026-11-26T09:00:00Z" }
}Login detection
It reads your code. It never runs it.
From PHP guards, Laravel middleware, Express routers, React and Vue route guards, Next.js middleware and .htaccess rules, the module builds an access map. Pages that need a login are never learned, never quoted and are flagged to agents.
Which pages require logging in (code scan)
The module reads the site's source code. It never runs it. From the code it builds an access map: which URLs require a login, which are public, and which are login pages. This is how it uses the map:
- Learning: pages that require login are never learned, even if they return HTTP 200 with a "please log in" message. Stale copies are deleted.
- Page guides: each guide gets an
accessobject:{"requires_login": true, "enforced": "on the server", "explanation": "This page requires logging in: ..."}. Links to such pages are flagged too. - Sitemap: every entry has
requires_login. Routes that only exist in code are added, such as Express and Laravel routes and React/Vue screens, so a Node or Laravel app gets a real sitemap. Login-only pages are listed without content. Admin-like areas (/admin,/backoffice, ...) are never listed. - The AI: it is told which pages need login, so it can answer "you need to log in to see your invoices".
What it recognises
| Code | Detected as requiring login |
|---|---|
| PHP | if (!isset($_SESSION[...])) { header('Location: ...'); exit; } and similar (empty($_SESSION…), !is_user_logged_in(), !Auth::check(), !isLoggedIn() …, followed by redirect/exit/die/401/403) |
| PHP | Guard calls: require_login(), auth_redirect(), check_login(), denyAccessUnlessGranted() … |
| PHP | Your own guard functions, including wrappers of wrappers. Class methods are ignored. |
| PHP | Guards pulled in through include/require (followed through several levels), and HTTP basic auth (PHP_AUTH_USER + WWW-Authenticate) |
| Laravel | Route::get(...)->middleware('auth'), and routes inside Route::middleware(['auth'])->prefix('x')->group(...) or Route::group(['middleware' => 'auth'], ...) |
| Express-style JS | Route middleware (app.get('/x', ensureLoggedIn(), h)); router.use(auth) before routes; routers mounted with auth (app.use('/account', requireLogin, accountRouter)) followed through require/import; handlers that check req.session/req.user and redirect or return 401/403 |
| Next.js | middleware.ts matchers when the middleware checks a token/session |
| React Router | <Route element={<RequireAuth/>}> layout routes and their children, elements wrapped in ProtectedRoute/PrivateRoute…, <PrivateRoute path=…> |
| Vue / Angular route tables | meta: { requiresAuth: true } (inherited by children), canActivate, beforeEnter guards |
| Apache | .htaccess with AuthType + Require valid-user/user/group |
Browser-side guards are reported as "enforced": "in the browser", because the server may still send the app shell to anyone.
Where the code is. By default the scanner reads DocumentRoot. For apps whose code lives elsewhere (a Node app behind a reverse proxy, or a Laravel project above public/), list each folder and the URL it serves:
AIAgentSourceDir /var/www/html /
AIAgentSourceDir /srv/node-app /app # Express app proxied at /app
AIAgentSourceDir /srv/laravel /node_modules, vendor, .git, dist and build are skipped, and minified files are ignored. The scan is redone every AIAgentCodeScanInterval seconds (default 300), so code changes are picked up. In testing, 2,800 files took about 0.15 s.
The admin report. <KnowledgeDir>/access.txt lists every finding with its evidence, file and line, for example:
LOGIN-REQUIRED /orders.php [php] orders.php:2: calls login guard must_login() [lib/functions.php:5: function must_login() calls require_admin()]
LOGIN-REQUIRED /app/account/* [express] server.js:8: router mounted at '/account' uses middleware requireLogin
LOGIN-REQUIRED /spa/profile [react, browser] src/App.jsx:8: nested inside a guarded layout route
PUBLIC /app/pricing [express] routes/public.js:3: router.get('/pricing') has no auth middlewareFile names and code details appear only in this private report. Agents only ever see the English explanation.
Limits. This is pattern-based static analysis, not execution:
- Checks done in unusual ways (a custom framework, permissions loaded from a database, guards behind several layers of classes) can be missed. Such pages show
requires_login: nullorfalse. - Use
AIAgentExcludefor anything sensitive. The scanner adds protection; it doesn't replace that. - Ruby, Python and Java aren't scanned yet.