> ## Documentation Index
> Fetch the complete documentation index at: https://shinydapps-bd9fa40b.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# VERITY

> 自主 AI 代理，提供 10 项 L402 保护服务。赚取 sats，以 sats 支付。

# VERITY

VERITY 是一个基于 l402-kit 构建的自主 AI 代理。她通过 L402 协议销售 10 项服务，积累 Bitcoin 资金库，并根据需求自动调整价格——无需人工干预。

**发现端点：** `GET https://l402kit.com/api/verity`

***

## 10 项服务

| 服务          | 端点                         | 价格          | 要求 |
| ----------- | -------------------------- | ----------- | -- |
| 网页搜索        | `/api/verity/search`       | 100 sats    | —  |
| 网页抓取        | `/api/verity/scrape`       | 200 sats    | —  |
| BTC 价格      | `/api/verity/btc-price`    | 10 sats     | —  |
| 文本摘要        | `/api/verity/summarize`    | 50 sats     | —  |
| 情感分析        | `/api/verity/sentiment`    | 30 sats     | —  |
| 域名情报        | `/api/verity/domain-intel` | 500 sats    | —  |
| l402-kit 集成 | `/api/verity/integration`  | 10,000 sats | —  |
| 世界状态        | `/api/verity/worldstate`   | 80 sats     | —  |
| 翻译          | `/api/verity/translate`    | 50 sats     | —  |
| 深度研究        | `/api/verity/research`     | 300 sats    | —  |

价格为动态价格——VERITY 每 30 分钟根据需求调整一次。

***

## 如何支付

每项服务均遵循标准 L402 流程：

```bash theme={null}
# 第一步 — 请求服务（获取发票）
curl -i https://l402kit.com/api/verity/btc-price

# HTTP/1.1 402 Payment Required
# WWW-Authenticate: L402 macaroon="...", invoice="lnbc..."

# 第二步 — 使用任意 Lightning 钱包支付发票
# 第三步 — 携带证明重试请求
curl -H "Authorization: L402 <macaroon>:<preimage>" \
  https://l402kit.com/api/verity/btc-price
```

***

## 使用 L402Client 自动支付

```typescript theme={null}
import { L402Client } from "l402-kit/agent";
import { BlinkWallet } from "l402-kit/wallets";

const client = new L402Client({
  wallet: new BlinkWallet(process.env.BLINK_API_KEY!),
  budget: { maxSats: 500 },
});

// BTC 价格 — 10 sats
const price = await client.fetch("https://l402kit.com/api/verity/btc-price");
const data = await price.json();
console.log(data.bitcoin.usd);

// 世界状态 — 80 sats
const world = await client.fetch("https://l402kit.com/api/verity/worldstate");
const state = await world.json();
console.log(state.time.utc, state.location.city, state.weather.temperature_c);
```

***

## 服务参考

### 网页搜索 — 100 sats

网页搜索，返回前 10 条自然搜索结果。

```bash theme={null}
# GET
curl -H "Authorization: L402 <token>" \
  "https://l402kit.com/api/verity/search?q=bitcoin+lightning"

# POST
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"q":"bitcoin lightning"}' \
  https://l402kit.com/api/verity/search
```

**响应：**

```json theme={null}
{
  "agent": "VERITY",
  "service": "search",
  "query": "bitcoin lightning",
  "results": [
    { "title": "...", "link": "...", "snippet": "..." }
  ],
  "paid_with": "⚡ Lightning L402"
}
```

***

### 网页抓取 — 200 sats

以 markdown 格式返回完整页面内容。

```bash theme={null}
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com"}' \
  https://l402kit.com/api/verity/scrape
```

***

### BTC 价格 — 10 sats

实时 Bitcoin 价格，以 USD、EUR 和 BRL 计价。

```bash theme={null}
curl -H "Authorization: L402 <token>" \
  https://l402kit.com/api/verity/btc-price
```

**响应：**

```json theme={null}
{
  "bitcoin": { "usd": 98000, "eur": 90000, "brl": 550000 },
  "timestamp": "2026-05-10T12:00:00.000Z"
}
```

***

### 文本摘要 — 50 sats

AI 文本摘要，最多支持 50,000 个字符。

```bash theme={null}
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"text":"...long text...", "language":"portuguese"}' \
  https://l402kit.com/api/verity/summarize
```

***

### 情感分析 — 30 sats

情感分析，返回得分、置信度和关键词。

```bash theme={null}
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"text":"Bitcoin is the future of money"}' \
  https://l402kit.com/api/verity/sentiment
```

**响应：**

```json theme={null}
{
  "analysis": {
    "sentiment": "positive",
    "score": 0.92,
    "confidence": 0.88,
    "keywords": ["bitcoin", "future", "money"]
  }
}
```

***

### 域名情报 — 500 sats

WHOIS、DNS 记录和 SSL 证书。无需 API 密钥——使用公开的 RDAP 和 crt.sh。

```bash theme={null}
curl -H "Authorization: L402 <token>" \
  "https://l402kit.com/api/verity/domain-intel?domain=example.com"
```

**响应：**

```json theme={null}
{
  "domain": "example.com",
  "whois": { "registrar": "...", "registered": "...", "expires": "..." },
  "dns": { "a_records": ["93.184.216.34"] },
  "certificates": [{ "issued": "...", "expires": "...", "issuer": "..." }]
}
```

***

### l402-kit 集成 — 10,000 sats

提交一个公开的 GitHub 仓库 URL。VERITY 分析代码库后，返回完整的 l402-kit 集成代码。

```bash theme={null}
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"repoUrl":"https://github.com/owner/repo"}' \
  https://l402kit.com/api/verity/integration
```

**响应：**

````json theme={null}
{
  "repo": "owner/repo",
  "integration": "## Detected: Express.js\n\n```typescript\nimport { l402 } from 'l402-kit';\n...",
  "next_steps": ["Apply integration code", "Set env vars", "Deploy and test"]
}
````

***

### 世界状态 — 80 sats

单次调用返回 UTC 时间 + 调用方地理位置 + 当地天气。零外部 API 成本。

```bash theme={null}
curl -H "Authorization: L402 <token>" \
  https://l402kit.com/api/verity/worldstate
```

**响应：**

```json theme={null}
{
  "time": {
    "utc": "2026-05-10T14:32:00.000Z",
    "unix": 1778421120,
    "hour": 14, "minute": 32, "weekday": "Sun"
  },
  "location": {
    "city": "São Paulo", "country": "BR", "timezone": "America/Sao_Paulo"
  },
  "weather": {
    "temperature_c": 23.4,
    "feels_like_c": 22.1,
    "humidity_pct": 68,
    "condition": "partly cloudy"
  }
}
```

***

### 深度研究 — 300 sats

深度研究套餐：单次调用包含搜索 + 抓取 + AI 摘要。节省 3 次独立支付和 3 倍往返延迟。

```bash theme={null}
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"query": "bitcoin lightning network adoption 2026"}' \
  https://l402kit.com/api/verity/research
```

**响应：**

```json theme={null}
{
  "agent": "VERITY",
  "service": "research",
  "query": "bitcoin lightning network adoption 2026",
  "summary": "Lightning Network adoption has accelerated significantly in 2026...",
  "scraped_url": "https://example.com/article",
  "sources": [
    { "title": "...", "link": "...", "snippet": "..." }
  ],
  "provider": "serper",
  "paid_with": "⚡ Lightning L402"
}
```

**与单独调用各服务相比：** 搜索（100 sats）+ 抓取（200 sats）+ 摘要（50 sats）= 共 350 sats。深度研究仅需 300 sats——更便宜，且只需一次支付。

***

### 翻译 — 50 sats

将文本或 MDX 文档翻译为 11 种支持语言之一。当 `format` 为 `mdx` 时，代码块、MDX 组件、URL 和技术术语将被完整保留——仅翻译正文内容。

**支持的语言区域：** `pt`, `es`, `zh`, `ar`, `hi`, `fr`, `de`, `ru`, `ja`, `it`, `en`

```bash theme={null}
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"text": "Pay once, access forever.", "locale": "pt", "format": "plain"}' \
  https://l402kit.com/api/verity/translate
```

**MDX 格式**（保留代码块和组件）：

```bash theme={null}
curl -X POST -H "Authorization: L402 <token>" \
  -H "Content-Type: application/json" \
  -d '{"text": "---\ntitle: Quickstart\n---\n\nPay with Lightning.", "locale": "ja", "format": "mdx"}' \
  https://l402kit.com/api/verity/translate
```

**响应：**

```json theme={null}
{
  "agent": "VERITY",
  "service": "translate",
  "locale": "pt",
  "language": "Brazilian Portuguese",
  "format": "plain",
  "translated": "Pague uma vez, acesse para sempre.",
  "source_length": 26,
  "paid_with": "⚡ Lightning L402"
}
```

每次调用最大输入量：100,000 个字符。

***

## 动态定价

VERITY 每 30 分钟调整一次价格：

```
高需求（每小时调用量 > 阈值）→ 价格 × 1.1
零需求（连续 2 小时无调用）  → 价格 × 0.9
价格底线保护                  → 价格永不低于最低值
```

随时查看当前价格：

```bash theme={null}
curl https://l402kit.com/api/verity | jq '.services[].priceSats'
```

***

***

## 公共发现端点

这两个端点无需 L402 支付——它们公开 VERITY 的服务目录和财务数据，用于审计和发现。

### GET /api/verity/services

包含实时定价、底价和激增阈值的所有活跃服务的机器可读目录。

```bash theme={null}
curl https://l402kit.com/api/verity/services
```

```json theme={null}
{
  "services": [
    {
      "id": "search",
      "endpoint": "https://l402kit.com/api/verity/search",
      "price_sats": 500,
      "floor_sats": 500,
      "cogs_sats": 50,
      "surge_threshold": 50
    }
  ],
  "count": 10,
  "updated": "2026-05-12T14:32:00.000Z"
}
```

### GET /api/verity/fiscal

VERITY 的每日财务报告——收入、成本、利润率及按服务分类的明细。每天 00:00 UTC 生成。

```bash theme={null}
curl https://l402kit.com/api/verity/fiscal
```

```json theme={null}
{
  "date": "2026-05-12",
  "agent": "VERITY",
  "revenue_sats": 8450,
  "consumer_spent_sats": 340,
  "net_sats": 8110,
  "margin_pct": "95.98",
  "usd_equivalent": "10.00",
  "btc_usd_rate": 95000,
  "breakdown": {
    "search": { "calls": 21, "price": 500, "revenue": 10500, "success_rate": 98 }
  },
  "generated_at": "2026-05-12T00:00:01.000Z"
}
```

报告保存 7 天。如果当天报告對未生成，则返回 404。

## 运营者 API

如果你 fork VERITY 来运行自己的代理，这些端点允许你在运行时修改定价和预算——无需重新部署。

所有管理路由均需要 `DASHBOARD_SECRET` 请求头：

```
Authorization: Bearer <DASHBOARD_SECRET>
```

### GET /api/verity/admin/config

返回当前定价配置及所有服务的消费者支出情况。

```bash theme={null}
curl -H "Authorization: Bearer <secret>" \
  https://l402kit.com/api/verity/admin/config
```

**响应：**

```json theme={null}
{
  "configs": {
    "search":  { "base": 100, "floor": 50, "surgeThreshold": 50, "cogs": 2 },
    "translate": { "base": 50, "floor": 50, "surgeThreshold": 30, "cogs": 1 }
  },
  "prices": { "search": 100, "translate": 50 },
  "consumer": { "spent_today": 340, "budget": 10000 }
}
```

### POST /api/verity/admin/config

更新指定服务的定价参数。仅修改所提供的字段。

```bash theme={null}
curl -X POST -H "Authorization: Bearer <secret>" \
  -H "Content-Type: application/json" \
  -d '{"service": "search", "base": 150, "floor": 80}' \
  https://l402kit.com/api/verity/admin/config
```

| 字段               | 说明                    |
| ---------------- | --------------------- |
| `service`        | 服务名称（必填）              |
| `base`           | 基础价格，单位 sats          |
| `floor`          | 最低价格（动态定价永不低于此值）      |
| `surgeThreshold` | 触发 +10% 溢价的每小时调用次数    |
| `cogs`           | 商品成本，单位 sats（供财务代理使用） |

### POST /api/verity/admin/budget

设置消费者每日支出限额。

```bash theme={null}
curl -X POST -H "Authorization: Bearer <secret>" \
  -H "Content-Type: application/json" \
  -d '{"sats": 5000}' \
  https://l402kit.com/api/verity/admin/budget
```

最低值：100 sats。修改立即生效。

***

## 架构

```
VERITY (agent:shinydapps.verity)
  ├── 10 L402-protected services
  ├── Treasury: shinydapps@blink.sv
  ├── Heartbeat: every 30min (price adjustment + Satring market scan)
  ├── Query cache: KV-backed, per-service TTL (5min–24h)
  ├── Fiscal Agent: daily report at 00:00 UTC → GET /api/verity/fiscal
  ├── Service catalog: machine-readable → GET /api/verity/services
  ├── Agent contract: GET /.well-known/agent.json → verity block
  └── LAW-N: behavioral events emitted per transaction
```

VERITY 是开源的——相同的架构可以被 fork 用于创建你自己的自主代理。
