# Core

The detection engine inside the script is open source: [github.com/doubleagent-so/core](https://github.com/doubleagent-so/core) (MIT). Read how every verdict is made, run it yourself, or make it better.

- Runs in the page. No dependencies, no network requests.
- Returns `human`, `bot` or `agent`, with probabilities, the agent's identity, the reasons and a recommendation.
- 226 named bots and agents in the [catalog](https://github.com/doubleagent-so/core/blob/main/docs/catalog.md), 71 [signal codes](https://github.com/doubleagent-so/core/blob/main/docs/signals.md).

## Script or core

| | Script (`doubleagent.js`) | Core |
|---|---|---|
| Install | One tag | Code |
| Verdict in the page | Yes | Yes |
| Sessions across pages, consent | Yes | You build it |
| GA4, Meta, Shopify and 14 more | Yes | You build it |
| Your own tools and backend | [Plugins](/docs/plugins) | `engine.payload()` |
| Server re-scoring, HQ, tokens | With the cloud | No |

The script runs core. With `data-cloud="off"` it stays in the page, like core on its own.

## Use it

```sh
git clone https://github.com/doubleagent-so/core && cd core && npm ci
npm run example   # live verdict page
```

```ts
import { createEngine } from '@doubleagent-so/core';

const engine = createEngine(window, { onVerdict: (v) => console.log(v.class, v.reasons) });
const verdict = await engine.ready;
```

[Getting started](https://github.com/doubleagent-so/core/blob/main/docs/getting-started.md) covers the options, the verdict and sending `engine.payload()` to your backend.

## How it works

Probes and input events become signals. Each is a log-likelihood ratio in a capped group, so correlated tells can't pile up. Fusion adds them to your site profile's priors. A policy turns the result and the action into a recommendation. [How it works](https://github.com/doubleagent-so/core/blob/main/docs/how-it-works.md).

The cloud re-scores every session with evidence the browser can't forge (headers, IP ranges, Web Bot Auth). It never trusts the client's verdict.

## Improve it

- A real browser labelled automated, or an agent that passed: [report a misclassification](https://github.com/doubleagent-so/core/issues/new?template=misclassification.yml).
- A new agent or bot: [add it to the catalog](https://github.com/doubleagent-so/core/blob/main/docs/extending.md#add-an-agent-or-bot-to-the-catalog).
- A probe, better weights, fewer false positives: [Extending](https://github.com/doubleagent-so/core/blob/main/docs/extending.md) and [Contributing](https://github.com/doubleagent-so/core/blob/main/CONTRIBUTING.md).

Found a way past it? Report it privately ([Security](https://github.com/doubleagent-so/core/blob/main/SECURITY.md)).
