@doubleagent-so/agent-detector

中文文档
0.4.1发布于 2026/10/06MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 3.4万

Double Agent detection engine: classifies a browser session as human, bot or AI agent, entirely client-side.

原始使用文档
文档目录6 节
  1. Install
  2. Quick start
  3. How it works
  4. Try it
  5. Contributing
  6. Support

Double Agent

Agent Detector

@doubleagent-so/agent-detector

Classify a browser session as human, bot or AI agent, entirely inside the page.

Website · Docs · npm · Changelog · Report an issue · MIT license

npm CI License: MIT Types Dependencies Size Catalog

The detection engine behind Double Agent. It classifies a browser session as human, bot or AI agent (Claude in Chrome, ChatGPT Atlas, Comet, Browser Use, Playwright, headless Chrome…) entirely inside the page. No dependencies, no network requests: you decide what to do with the verdict.

Docs · Getting started · How it works · API · Extending · Signals · Catalog · Contributing

Use it directly when you want the raw engine. For a drop-in script with analytics and ads integrations and plugins, use @doubleagent-so/js.

Install

npm install @doubleagent-so/agent-detector

Quick start

import { createEngine } from '@doubleagent-so/agent-detector';

const engine = createEngine(window, {
  profile: 'ecommerce',                 // optional; detected from the page when omitted
  onVerdict: (v) => console.log(v.class, v.probability),
});

const v = await engine.ready;           // after the async probes (WebGL, workers, client hints)
v.class;           // 'human' | 'bot' | 'agent'
v.probability;     // { human: 0.03, bot: 0.05, agent: 0.92 }
v.agent;           // { family: 'claude', id: 'anthropic.claude-in-chrome', verified: false, method: 'marker.claude_active' }
v.recommendation;  // 'allow' | 'tag' | 'challenge' | 'step_up' | 'rate_limit' | 'deny'
v.reasons;         // [{ code: 'marker.claude_active', weight: 6.2 }, …]

engine.score('checkout');   // re-score for a specific action
engine.stop();              // remove listeners and timers

The engine keeps observing input (pointer, keys, scroll, timing) and re-scores every 2 s. onVerdict fires only when the class, recommendation, agent, stage or probability band changes.

Server-side helpers work without a DOM:

import { matchUserAgent, CATALOG } from '@doubleagent-so/agent-detector';

matchUserAgent('Mozilla/5.0 … ChatGPT-User/1.0; +https://openai.com/bot')?.entry.id; // 'openai.chatgpt-user'

How it works

Probes and input events become signals, each a log-likelihood ratio in a capped group. Fusion adds them to per-profile priors and softmaxes over human, bot and agent. A policy maps the result and the action to a recommendation. Every weight lives in one versioned object, DEFAULT_SIGNATURES. Details: How it works.

engine.payload() is a compact JSON summary you can send to your own backend. Re-score it there with evidence the client cannot forge: examples/server.ts.

Try it

git clone https://github.com/doubleagent-so/agent-detector && cd agent-detector && npm ci
npm run example     # live verdict at http://127.0.0.1:8123 — try a real browser, a headless one and an agent
npm run bench       # confusion matrix on labelled synthetic sessions

Contributing

Detection gets better with more eyes. Good places to start:

Read CONTRIBUTING.md first: tests first, false positives are the worst bug, weights need evidence. Report evasions privately (SECURITY.md), not in a public issue.


Support

  • Questions and bugs: open an issue.
  • Private account or billing questions: [email protected]. Never post secret keys or session tokens in a public issue.
  • Security problems: report them privately as described in SECURITY.md.

Maintained by Double Agent · Contributing · Code of conduct · Security · MIT license

版本与发布记录

@doubleagent-so/agent-detector 共发布 3 个版本,首次发布于 2026/10/02;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.1latest2026/10/061 个月前
0.4.02026/10/041 个月前
0.3.02026/10/021 个月前

关于 @doubleagent-so/agent-detector 的常见问题

@doubleagent-so/agent-detector 是什么?

Double Agent detection engine: classifies a browser session as human, bot or AI agent, entirely client-side.

如何安装 @doubleagent-so/agent-detector?

在项目目录运行 npm install @doubleagent-so/agent-detector,或使用 pnpm add / yarn add / bun add。

@doubleagent-so/agent-detector 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@doubleagent-so/agent-detector 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@doubleagent-so/agent-detector 可以商用吗?

@doubleagent-so/agent-detector 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@doubleagent-so/agent-detector 的下载量有多少?

根据 npm 官方下载统计,@doubleagent-so/agent-detector 在 2026/10/13 – 2026/11/11 这 30 天内被下载 33,683 次,日均约 1,123 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@doubleagent-so/agent-detector 还在维护吗?

最新版本 0.4.1 发布于 2026/10/06(1 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。