# Code Deb AI Discovery SDK

**Target release:** `@codedeb/ai-discovery@0.1.0` passed isolated ESM installation and TypeScript consumer checks; public npm availability has not yet been independently verified.

AI search referrals and verified crawler evidence — intended for developers building reliable storefronts, search infrastructure and production applications. Unlike a hosted platform, the SDK does not require a Code Deb account for its pure functions.

## Build, test and stage

```bash
npm ci
npm run test:nepal-sdks
npm run sdk:pack:verify
node scripts/sdk/stage-npm-package.mjs sdk-ai-discovery
```

These commands prepare the candidate without publishing it. Review the generated `.sdk-artifacts/npm-stage/sdk-ai-discovery` contents and all licenses. After a successful, independently verified npm release, the installation command will be `npm install @codedeb/ai-discovery`. Do not advertise this command as publicly working before release verification.

## Quickstart using implemented exports

```ts
import {classifyAiVisit} from '@codedeb/ai-discovery';
const result=classifyAiVisit({timestamp:'2026-11-21',path:'/products',referrer:'https://chatgpt.com/'});
console.log(result.confidence,result.kind);
```

## Public API contract

| Entry point or function | Responsibility |
| --- | --- |
| `classifyAiVisit(visit)` | Categorize AI referrers, claimed crawler UAs and caller-verified bots |
| `summarizeAiDiscovery(visits)` | Aggregate source and evidence-confidence counts |

## Production integration

A User-Agent can be forged and a referral need not imply an LLM cited content. Verify crawlers using provider-published methods and avoid logging raw user queries or identifiers. Google-Extended is a robots control token, not a crawler.

The published SDK must have bounded resource use, correct authentication boundaries where applicable, and tests for malformed input. Caller-owned storage, OAuth, background jobs or hosted services must be configured explicitly rather than invented by the library.

## Compatibility and release history

- **0.1.0 candidate — 21 November 2026:** First implementation of the documented independent module, subject to the complete release gate.
- JavaScript ESM with generated TypeScript declarations; Node.js 20+ for Node execution.
- No npm publication, hosted API, SLA, vendor certification, ranking guarantee or customer data access is implied by this candidate.
- Code Deb-owned package code is intended for Apache-2.0 distribution. Third-party dependencies, data and trademarks retain their own terms.

## References and related SDKs

- [Developer SDK index](/docs/sdk)
- [Code Deb Developer resources](/docs/resources)
- [Reference standards and vendor documentation](https://platform.openai.com/docs/bots)




## Implementation workflow

1. Collect privacy-reviewed first-party referrer and request evidence.
2. Separate confirmed referrers from spoofable crawler User-Agent claims.
3. Verify bot identity independently before marking it authenticated.
4. Never equate a referral count with model citations or an answer-engine ranking.

## Registry verification and installation

```bash
npm view @codedeb/ai-discovery@0.1.0 version
# Install when the target release is listed and its tarball is retrievable:
npm install @codedeb/ai-discovery@0.1.0
```

A valid local package is not automatically a live npm release. A verified publication must expose version metadata, a current dist-tag and a public tarball. Keep installation versions pinned and check the included distribution license.

## Production acceptance criteria

- Verify normal, corrupted, missing and boundary inputs with the actual package exports.
- Keep any secrets, authorization and persistent state in application-owned server adapters.
- Record explicit classifications, retry outcomes or regression evidence without turning unknown into verified.
- Audit access limits, failure handling and operational monitoring independently of the SDK.

## Troubleshooting

**Registry 404:** Confirm the intended version on [npm](https://www.npmjs.com/package/@codedeb/ai-discovery), and do not assume publication from local test output. **Unexpected classification or diff:** Review the original evidence fields and source data. **External processing problem:** Inspect your event store, browser runner, authenticated client or queue; the SDK is a library, not a hosted processing service.

## Related SDKs

[search console](/docs/sdk/search-console) · [seo](/docs/sdk/seo) · [Developer SDKs](/docs/sdk) · [Technical resources](/docs/resources)
