Xpersona
C

CostLens

CLAWHUB · Unverified

Calculate OpenClaw usage cost from offline event logs, apply budget thresholds, and export operator-facing reports. Skill: CostLens Owner: mike007jd Summary: Calculate OpenClaw usage cost from offline event logs, apply budget thresholds, and export operator-facing reports. Tags: budget:1.0.1, cost:1.0.1, latest:1.0.1, llm:1.0.1, monitoring:1.0.1, openclaw:1.0.1 Version history: v1.0.1 | 2026-03-27T04:27:51.654Z | user README and SKILL.md compliance update for OpenClaw / ClawHub alignment. v1.0.0 | 2026-02-26T10:42:03.499Z | user I

62
Rank
84
Safety
1.2k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.2K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17445vjamxwgyr2d1q1jysg1d83qskv:costlens
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-mike007jd-costlens/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

15,286 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: costlens
description: Calculate OpenClaw usage cost from offline event logs, apply budget thresholds, and export operator-facing reports.
homepage: https://github.com/mike007jd/openclaw-skills/tree/main/costlens
metadata: {"openclaw":{"emoji":"💸","requires":{"bins":["node"]}}}
---

# CostLens

Turn JSON usage events into cost summaries, budget checks, and offline reports.

## When to use

- You already have token usage events and need a quick spend summary.
- You want a simple budget gate in local automation or CI.
- You need an exportable JSON report without relying on a hosted billing dashboard.

## Commands

```bash
node {baseDir}/bin/costlens.js monitor --events ./events.json --budget 10.00 --threshold 80
node {baseDir}/bin/costlens.js budget check --events ./events.json --budget 5.00 --format json
node {baseDir}/bin/costlens.js report --events ./events.json --out ./reports/cost-report.json
```

## Built-in default rates

| Model | Input/1k | Output/1k |
| --- | --- | --- |
| gpt-4.1 | $0.01 | $0.03 |
| gpt-4o-mini | $0.00015 | $0.0006 |
| claude-3-5-sonnet | $0.003 | $0.015 |
| default | $0.002 | $0.008 |

Events can override the defaults with `inputCostPer1k` and `outputCostPer1k`.

## Event shape

```json
[
  {
    "model": "gpt-4.1",
    "promptTokens": 1500,
    "completionTokens": 800,
    "timestamp": "2026-02-26T10:00:00Z"
  }
]
```

## Output

- Total calls, total tokens, and total cost
- Per-model breakdowns for calls, tokens, and cost
- Per-day spend trends
- Budget usage percentage and alert level (`ok`, `warning`, or `critical`)

## Boundaries

- Pricing is based on built-in defaults plus per-event overrides. It is not a live pricing feed.
- CostLens is optimized for offline JSON analysis, not streaming metering or invoice reconciliation.

README.md

# CostLens

[English](./README.md) | [简体中文](./README.zh-CN.md) | [한국어](./README.ko-KR.md)

> A token cost monitoring CLI for OpenClaw workflows that turns raw usage events into budget-aware summaries.

| Item | Value |
| --- | --- |
| Package | `@mike007jd/openclaw-costlens` |
| Runtime | Node.js 18+ |
| Interface | CLI + JavaScript module |
| Main commands | `monitor`, `report`, `budget check` |

## Why this exists

Token usage problems are usually discovered too late, after a workflow has already scaled. CostLens makes spend visible earlier by aggregating model usage, calculating cost, checking budget thresholds, and turning event streams into simple operator-facing output.

## What it does

- Reads JSON event arrays containing prompt and completion token counts
- Applies built-in model rates, with optional per-event overrides
- Summarizes cost by model and by day
- Skips invalid events safely and reports what was ignored
- Checks budget usage and raises warning or critical states
- Exports structured reports for handoff or audit

## Primary workflow

1. Export token events from your workflow logs.
2. Run `costlens monitor` for a quick operational view.
3. Add `--budget` and `--threshold` to enforce spend guardrails.
4. Write a report artifact with `costlens report`.

## Quick start

```bash
git clone https://github.com/mike007jd/openclaw-skills.git
cd openclaw-skills/costlens
npm install
node ./bin/costlens.js monitor --events ./fixtures/events.json --budget 0.1 --threshold 75
```

## Commands

| Command | Purpose |
| --- | --- |
| `costlens monitor --events <path>` | Print a live summary table or JSON payload |
| `costlens report --events <path> --out <path>` | Save a full JSON report |
| `costlens budget check --events <path> --budget <amount>` | Return budget status, including critical exits |

## Event shape

```json
{
  "model": "gpt-4.1",
  "promptTokens": 1200,
  "completionTokens": 300,
  "timestamp": "2026-03-10T10:00:00Z"
}
```

## Output behavior

- `monitor` returns exit code `0` for normal or warning states and `2` for critical budget overruns
- `report` writes a JSON artifact with totals, per-model breakdown, per-day breakdown, and budget summary
- Invalid events are skipped instead of crashing the run

## Project layout

```text
costlens/
├── bin/
├── fixtures/
├── src/
├── test.js
└── SKILL.md
```

## Status

The current implementation is built for offline event analysis with built-in model pricing and budget enforcement. It is a practical reporting layer rather than a streaming billing service.

_meta.json

{
  "ownerId": "kn715nrc07zv6hdsrmj6dnm0gs81wam4",
  "slug": "costlens",
  "version": "1.0.1",
  "publishedAt": 1774585671654
}

README.ko-KR.md

# CostLens

[English](./README.md) | [简体中文](./README.zh-CN.md) | [한국어](./README.ko-KR.md)

> OpenClaw 워크플로의 토큰 사용 이벤트를 비용과 예산 상태로 바꿔주는 비용 모니터링 CLI입니다.

| 항목 | 내용 |
| --- | --- |
| 패키지 | `@mike007jd/openclaw-costlens` |
| 런타임 | Node.js 18+ |
| 인터페이스 | CLI + JavaScript 모듈 |
| 주요 명령 | `monitor`, `report`, `budget check` |

## 왜 필요한가

토큰 비용 문제는 대개 워크플로가 커진 뒤에야 드러납니다. CostLens는 모델별 사용량, 비용, 예산 임계값을 조기에 보여 줘서 운영자가 더 빨리 대응할 수 있게 합니다.

## 제공 기능

- prompt/completion 토큰 수가 포함된 JSON 이벤트 배열 로드
- 내장 모델 요율 적용 및 이벤트별 요율 오버라이드 지원
- 모델별, 일자별 비용 집계
- 잘못된 이벤트를 안전하게 건너뛰고 그 사실을 명시
- 예산 사용률을 계산해 warning/critical 상태 반환
- 인수인계와 감사에 사용할 구조화된 보고서 생성

## 대표 워크플로

1. 워크플로 로그에서 토큰 이벤트를 추출합니다.
2. `costlens monitor` 로 빠른 운영 요약을 확인합니다.
3. `--budget`, `--threshold` 로 지출 가드레일을 적용합니다.
4. `costlens report` 로 보고서 파일을 저장합니다.

## 빠른 시작

```bash
git clone https://github.com/mike007jd/openclaw-skills.git
cd openclaw-skills/costlens
npm install
node ./bin/costlens.js monitor --events ./fixtures/events.json --budget 0.1 --threshold 75
```

## 명령어

| 명령 | 설명 |
| --- | --- |
| `costlens monitor --events <path>` | 요약 테이블 또는 JSON 출력 |
| `costlens report --events <path> --out <path>` | 전체 JSON 보고서 저장 |
| `costlens budget check --events <path> --budget <amount>` | 예산 상태 확인 및 임계 초과 시 차단 코드 반환 |

## 이벤트 형식

```json
{
  "model": "gpt-4.1",
  "promptTokens": 1200,
  "completionTokens": 300,
  "timestamp": "2026-03-10T10:00:00Z"
}
```

## 출력 동작

- `monitor` 는 정상/경고 상태에서 `0`, 심각한 예산 초과 시 `2` 를 반환합니다
- `report` 는 총합, 모델별 집계, 날짜별 집계, 예산 상태를 담은 JSON 파일을 생성합니다
- 잘못된 이벤트는 실행을 중단시키지 않고 건너뜁니다

## 프로젝트 구조

```text
costlens/
├── bin/
├── fixtures/
├── src/
├── test.js
└── SKILL.md
```

## 현재 상태

현재 구현은 오프라인 이벤트 분석과 예산 관리에 초점을 둡니다. 실시간 과금 시스템이라기보다 실용적인 비용 리포팅 레이어에 가깝습니다.

README.zh-CN.md

# CostLens

[English](./README.md) | [简体中文](./README.zh-CN.md) | [한국어](./README.ko-KR.md)

> 一个面向 OpenClaw 工作流的 token 成本监控 CLI,把原始使用事件转成带预算感知的成本摘要。

| 项目 | 内容 |
| --- | --- |
| 包名 | `@mike007jd/openclaw-costlens` |
| 运行环境 | Node.js 18+ |
| 接口形态 | CLI + JavaScript 模块 |
| 主要命令 | `monitor`、`report`、`budget check` |

## 为什么需要它

Token 成本问题往往在工作流已经放大之后才暴露出来。CostLens 的作用就是更早把花费显性化:它会汇总模型使用量、计算成本、检查预算阈值,并把事件流整理成运维可读的输出。

## 它能做什么

- 读取包含 prompt / completion token 数的 JSON 事件数组
- 使用内置模型费率,也支持按事件覆盖费率
- 按模型、按日期汇总成本
- 安全跳过非法事件,并明确说明跳过了什么
- 检查预算使用率并给出 warning / critical 状态
- 导出结构化报告,便于交接或审计

## 典型工作流

1. 从工作流日志导出 token 事件。
2. 使用 `costlens monitor` 查看快速运行摘要。
3. 加上 `--budget` 和 `--threshold` 做预算守护。
4. 用 `costlens report` 输出正式报告文件。

## 快速开始

```bash
git clone https://github.com/mike007jd/openclaw-skills.git
cd openclaw-skills/costlens
npm install
node ./bin/costlens.js monitor --events ./fixtures/events.json --budget 0.1 --threshold 75
```

## 命令说明

| 命令 | 作用 |
| --- | --- |
| `costlens monitor --events <path>` | 输出快速摘要表格或 JSON |
| `costlens report --events <path> --out <path>` | 保存完整 JSON 报告 |
| `costlens budget check --events <path> --budget <amount>` | 返回预算状态,并在严重超支时给出关键退出码 |

## 事件格式

```json
{
  "model": "gpt-4.1",
  "promptTokens": 1200,
  "completionTokens": 300,
  "timestamp": "2026-03-10T10:00:00Z"
}
```

## 输出行为

- `monitor` 在正常或 warning 状态下返回 `0`,在严重超预算时返回 `2`
- `report` 会写出包含总量、按模型拆分、按日期拆分和预算状态的 JSON 文件
- 非法事件会被跳过,而不是直接让整次执行失败

## 项目结构

```text
costlens/
├── bin/
├── fixtures/
├── src/
├── test.js
└── SKILL.md
```

## 当前状态

当前实现适合离线事件分析,内置了常见模型费率和预算判断能力。它是一个实用的成本报告层,而不是实时计费系统。

Sponsored

Ads related to CostLens and adjacent AI workflows.