# @doubleagent-so/agent-detector 中文文档

规范地址：https://npmcn.com/package/%40doubleagent-so/agent-detector/

版本：0\.4\.1
npm 元数据更新时间：2026-10-06T12:34:43.706Z
中文译文更新时间：2026-11-12T17:42:57.548Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40doubleagent-so/agent-detector
原文对照：https://npmcn.com/package/%40doubleagent-so/agent-detector/?lang=original
项目主页：https://doubleagent.so/docs/
源码仓库：https://github.com/doubleagent-so/agent-detector

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：210 kB，61 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2026-10-02T15:28:37.739Z
- 最新版本发布：2026-10-06T12:34:43.363Z
- 近 30 天下载量：33683（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 3 个）

## 中文简介

双代理检测引擎:将浏览器会话分类为人,bot或AI代理,完全为客户端.

## 安装

```sh
npm install @doubleagent-so/agent-detector
```

也可以使用：`pnpm add @doubleagent-so/agent-detector`、`yarn add @doubleagent-so/agent-detector`、`bun add @doubleagent-so/agent-detector`

## README

![Double Agent](https://raw.githubusercontent.com/doubleagent-so/agent-detector/main/assets/doubleagent.svg)

# 特工探测器

`@doubleagent-so/agent-detector`

将浏览器会话分类为人,bot或AI代理,完全在页面内.

**[网站](https://doubleagent.so/)** • 妇女 [文档](https://doubleagent.so/docs/agent-detector/) • 妇女 [无](https://www.npmjs.com/package/@doubleagent-so/agent-detector) • 妇女 [更改日志](https://github.com/doubleagent-so/agent-detector/blob/main/CHANGELOG.md) • 妇女 [报告问题](https://github.com/doubleagent-so/agent-detector/issues) • 妇女 [麻省理工学院许可证](https://github.com/doubleagent-so/agent-detector/blob/main/LICENSE)

[![npm](https://img.shields.io/npm/v/@doubleagent-so/agent-detector.svg)](https://www.npmjs.com/package/@doubleagent-so/agent-detector) [![CI](https://github.com/doubleagent-so/agent-detector/actions/workflows/ci.yml/badge.svg)](https://github.com/doubleagent-so/agent-detector/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/doubleagent-so/agent-detector/blob/main/LICENSE) [![Types](https://img.shields.io/badge/types-included-3178c6.svg)](https://github.com/doubleagent-so/agent-detector/blob/main/src/types.ts) [![Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](https://github.com/doubleagent-so/agent-detector/blob/main/package.json) [![Size](https://img.shields.io/badge/engine-%E2%89%A416%20KB%20gzip-brightgreen.svg)](https://github.com/doubleagent-so/agent-detector/blob/main/scripts/size.mjs) [![Catalog](https://img.shields.io/badge/catalog-226%20bots%20%26%20agents-8a2be2.svg)](https://github.com/doubleagent-so/agent-detector/blob/main/docs/catalog.md)

后面的探测引擎 **[双面代理](https://doubleagent.so/)**。它将浏览器会话分类为 **人类**, (中文(简体) ), **机器人** 或者说 **AI 代理人** (Claude in Chrome, ChatGPT Atlas, 彗星, 浏览器使用, Playwright, 无头 Chrome...) 完全 在页面中。 没有依赖性,没有网络请求: 您决定如何处理判决.

**[文档](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/README.md)** • 妇女 **[开始](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/getting-started.md)** • 妇女 **[如何运作](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/how-it-works.md)** • 妇女 **[API 密码](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/api.md)** • 妇女 **[扩展](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/extending.md)** • 妇女 **[信号](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/signals.md)** • 妇女 **[目录](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/catalog.md)** • 妇女 **[捐款](https://npmcn.com/package/%40doubleagent-so/agent-detector/CONTRIBUTING.md)**

需要原始引擎时直接使用. 对于一个有分析与广告集成和插件的即用脚本, 使用情况 [`@doubleagent-so/js`](https://doubleagent.so/docs/script-tag/)。 。 。 .

## 安装

```sh
npm install @doubleagent-so/agent-detector
```

## 快开始

```ts
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
```

引擎持续观察输入(指针,密钥,卷轴,计时)并每2 s重分. `onVerdict` 只有在 类别、推荐、代理、舞台或概率波段变化.

服务器侧助手没有 DOM 操作 :

```ts
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'
```

## 如何运作

探测和输入事件 **信号**,在封顶中,每个记录相比 **组**。 。 。 . **组合** 加入他们 每张相片的前科和软马克思 超过人类,机器人和代理。 A 类 **政策** 将结果和动作映射到 a 建议。 每一个重量都生活在一个版本的物体中, `DEFAULT_SIGNATURES`细节 : [如何运作](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/how-it-works.md)。 。 。 .

`engine.payload()` 是一个压缩 JSON 摘要,您可以发送到自己的后端。 以证据重新计分 客户端不能伪造 : [实例/服务器.ts](https://npmcn.com/package/%40doubleagent-so/agent-detector/examples/server.ts)。 。 。 .

## 试试看

```sh
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
```

## 捐款

发现更多眼睛会更好 开始的好地方:

-   **报告误读会话**:一个真正的被标记为自动化的浏览器,或者一个作为人经过的代理. [打开错误的分类](https://github.com/doubleagent-so/agent-detector/issues/new?template=misclassification.yml)。 。 。 .
-   **添加代理或机器人** 及其操作员的文档. [请求一](https://github.com/doubleagent-so/agent-detector/issues/new?template=new-agent.yml) 或者说 [自己加进去](https://npmcn.com/package/%40doubleagent-so/agent-detector/docs/extending.md#add-an-agent-or-bot-to-the-catalog)。 。 。 .
-   **更难测试.** 合成的痕迹 `test/traces.ts` 今天很容易,现实的 `npm run bench` 有意义的.
-   标有标签的问题 [不错的第一期](https://github.com/doubleagent-so/agent-detector/labels/good%20first%20issue) 财务报告和审定财务报表 [需要帮助](https://github.com/doubleagent-so/agent-detector/labels/help%20wanted)。 。 。 .

读取 [捐款额](https://npmcn.com/package/%40doubleagent-so/agent-detector/CONTRIBUTING.md) 一:先是测试,假阳性是最差的bug,重量需要证据. 私下举报([警卫](https://npmcn.com/package/%40doubleagent-so/agent-detector/SECURITY.md)),不是在公共问题上.

* * *

## 支助

-   问题和错误 : [打开一个问题](https://github.com/doubleagent-so/agent-detector/issues/new/choose)。 。 。 .
-   私人账户或账单问题: [支持@ doubleagent.so](mailto:support@doubleagent.so)。从不在公共问题中贴出密钥或会话符号.
-   安全问题:按 [警卫](https://github.com/doubleagent-so/agent-detector/blob/main/SECURITY.md)。 。 。 .

维护者 [双面代理](https://doubleagent.so/) • 妇女 [捐款](https://github.com/doubleagent-so/agent-detector/blob/main/CONTRIBUTING.md) • 妇女 [行为守则](https://github.com/doubleagent-so/agent-detector/blob/main/CODE_OF_CONDUCT.md) • 妇女 [警卫](https://github.com/doubleagent-so/agent-detector/blob/main/SECURITY.md) • 妇女 [麻省理工学院许可证](https://github.com/doubleagent-so/agent-detector/blob/main/LICENSE)

## 常见问题

### @doubleagent-so/agent-detector 是什么？

双代理检测引擎:将浏览器会话分类为人,bot或AI代理,完全为客户端\.

### 如何安装 @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 和提交记录判断。

