能力标签
CostHQ
⚙️
Agent工作流

CostHQ

基于 TypeScript · 无代码搭建完整 AI 自动化流程
⭐ 8 Stars 🍴 1 Forks 💻 TypeScript 📄 MIT 🏷 AI 7.5分
7.5AI 综合评分
aiclicost-tracking
✦ AI Skill Hub 推荐

经 AI Skill Hub 精选评估,CostHQ 获评「推荐使用」。这款Agent工作流在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 7.5 分,适合有一定技术背景的用户使用。

📚 深度解析

CostHQ 是一套完整的 AI Agent 自动化工作流方案。随着 AI 能力的不断提升,基于 Agent 的自动化工作流正在成为提升个人和团队效率的核心方式。区别于传统的 RPA 自动化(模拟鼠标键盘操作),AI Agent 工作流通过理解任务意图、动态规划执行路径,能够处理更复杂的非结构化任务。

CostHQ 工作流的设计遵循"最小配置,最大复用"原则:核心逻辑已经封装好,用户只需配置自己的 API Key 和业务参数即可快速上手。工作流内置错误处理和重试机制,在网络波动或 API 限速等情况下仍能稳定运行,适合作为生产环境的自动化基础设施。

在实际部署时,建议先在测试环境中运行 3-5 次,验证各个环节的输出结果符合预期,再部署到生产环境。AI Skill Hub 评分 7.5 分,是同类 Agent 工作流中的精选推荐。

📋 工具概览

CostHQ 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。

GitHub Stars
⭐ 8
开发语言
TypeScript
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
MIT
AI 综合评分
7.5 分
工具类型
Agent工作流
Forks
1

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

CostHQ 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。

📌 核心特色
  • 可视化 Agent 工作流编排,无需编写复杂代码
  • 支持多步骤自动化任务链,实现全流程无人值守
  • 与外部 API、数据库和第三方服务无缝集成
  • 内置错误处理与自动重试机制,保障稳定运行
  • 提供可复用的自动化模板,快速在同类场景部署
🎯 主要使用场景
  • 自动化日常重复性工作,将精力集中于创造性任务
  • 构建数据采集 → 处理 → 输出的完整自动化管线
  • 实现跨平台、跨系统的数据流转和业务协同
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:npm 全局安装
npm install -g costhq

# 方式二:npx 直接运行(无需安装)
npx costhq --help

# 方式三:项目依赖安装
npm install costhq

# 方式四:从源码运行
git clone https://github.com/brian-mwirigi/CostHQ
cd CostHQ
npm install
npm start
📋 安装步骤说明
  1. 访问 GitHub 仓库获取工作流文件
  2. 在对应平台(Dify / Flowise / Make 等)中找到「导入工作流」功能
  3. 上传工作流文件
  4. 按照提示配置必要的环境变量和 API Key
  5. 运行测试确认流程正常后投入使用
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
costhq --help

# 基本用法
costhq [options] <input>

# Node.js 代码中使用
const costhq = require('costhq');

const result = await costhq.run(options);
console.log(result);
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# costhq 配置说明
# 查看配置选项
costhq --config-example > config.yml

# 常见配置项
# output_dir: ./output
# log_level: info
# workers: 4

# 环境变量(覆盖配置文件)
export COSTHQ_CONFIG="/path/to/config.yml"
📑 README 深度解析 真实文档 完整度 82/100 含工作流图 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

CostHQ

Track what your AI agents actually cost

<p> <a href="https://www.npmjs.com/package/costhq"><img src="https://img.shields.io/npm/v/costhq?color=brightgreen" alt="npm version"></a> <a href="https://www.npmjs.com/package/costhq"><img src="https://img.shields.io/npm/dy/costhq?color=blue" alt="npm downloads"></a> <a href="https://www.npmjs.com/package/codesession-cli"><img src="https://img.shields.io/npm/dt/codesession-cli?label=legacy%20downloads&color=grey" alt="legacy npm downloads"></a> <a href="https://clawhub.ai/brian-mwirigi/costhq"><img src="https://img.shields.io/badge/OpenClaw-Skill-blue" alt="OpenClaw Skill"></a> <a href="https://github.com/brian-mwirigi/costhq"><img src="https://img.shields.io/github/stars/brian-mwirigi/costhq?style=social" alt="GitHub stars"></a> <a href="https://github.com/brian-mwirigi/costhq/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/costhq" alt="license"></a> </p>

<p><em>Track agent runs • Monitor files • Log commits • Enforce budgets</em></p>

<p>If this tool saves you money, consider <a href="https://github.com/sponsors/brian-mwirigi">sponsoring</a> or <a href="https://github.com/brian-mwirigi/codesession-cli">giving it a star</a></p>

<p> <a href="https://github.com/sponsors/brian-mwirigi"><img src="https://img.shields.io/badge/Sponsor-%E2%9D%A4-pink?logo=github" alt="Sponsor"></a> <a href="https://buymeacoffee.com/brianmwirigi"><img src="https://img.shields.io/badge/Buy%20Me%20a%20Coffee-%E2%98%95-yellow?logo=buymeacoffee&logoColor=black" alt="Buy Me a Coffee"></a> <a href="https://www.npmjs.com/package/costhq"> npm</a> • <a href="https://github.com/brian-mwirigi/costhq"> GitHub</a> • <a href="https://costhq.mintlify.app/"> Documentation</a> • <a href="https://github.com/brian-mwirigi/costhq/blob/main/CHANGELOG.md"> Changelog</a> • <a href="#openclaw-skill"> OpenClaw Skill</a> </p>

<p>Developed by <a href="https://brianmunene.me">Brian Munene Mwirigi</a></p> </div>

---

Overview

  • KPI cards: total sessions, cost, time, avg duration, avg cost, files changed, commits
  • Daily cost area chart (30 days) with spend projection (avg daily + projected monthly)
  • Daily token usage bar chart (prompt vs completion)
  • Sessions per day chart
  • Most expensive sessions table
  • Cost velocity chart ($/hr per session)

What's New in v3.0.0 (The Pro Unlock)

  • Command Center Console — Start sessions, inject tokens, and terminate sessions directly from the dashboard UI without touching the CLI! Watchers run automatically in the background. (Pro feature)
  • Shareable Stats Card — A beautiful, Spotify-Wrapped style component to export a PNG image of your coding and AI usage stats. (Pro feature)
  • In-App Feedback — Built-in feedback modal allowing you to report bugs or request features directly from the dashboard.
  • Onboarding Wizard — First-time user overlay walkthrough for CLI commands and dashboard capabilities.
  • Massive Performance Boosts — SQLite performance indexes added, simple-git instances are now cached, and puppeteer was removed from production dependencies making installs significantly faster.

What's New in v2.0.0

  • Alerts Dashboard — Set daily, total, and per-session cost limits with progress bars, alarm mode (sound + browser notifications), and status badges
  • Start Fresh — Reset all session data from the dashboard with a confirmation modal
  • Insights Page — File hotspots, activity heatmap, project breakdown, pricing table
  • Bug Fixes — Fixed alarm autoplay policy, null ref crash, active session cleanup on reset

Full Changelog →

---

Prerequisites

codesession-cli uses an embedded SQLite database (better-sqlite3) which requires C/C++ build tools to compile:

OSInstall build tools
**Ubuntu/Debian**sudo apt-get install -y build-essential python3
**macOS**xcode-select --install
**Windows**npm install -g windows-build-tools or install [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
**Alpine**apk add build-base python3
Note: If prebuilt binaries are available for your platform, compilation is skipped automatically.

Installation

Install

npm install -g codesession-cli

Failsafe: `cs` not installed

Agent skills should check which cs (or where cs on Windows) before attempting to track. If not available, degrade gracefully — don't block the agent's primary task.

AI Usage with Agent Tracking

<img src="https://raw.githubusercontent.com/brian-mwirigi/codesession-cli/main/docs/screenshots/agent-tracking.png" alt="Agent Tracking" width="800">

Quick Start: Node.js Library (New!)

With the merge of aitoken-cli, you can now use codesession as a drop-in Node.js library to track API spend in your own backend applications. Costs are automatically calculated and sent to your dashboard!

Quick Start: CLI (for Agents & Humans)

If you use OpenClaw, Claude Code, or any AI agent framework, this is for you. All commands support --json for machine-readable output:

```bash

CLI Usage (Manual / Interactive)

For human developers tracking their own sessions:

```bash

Log AI usage

cs log-ai -p anthropic -m claude-sonnet-4 --prompt-tokens 8000 --completion-tokens 2000

Example: Agent run tracked by codesession

You: Fix the payment processing bug and add retry logic

Agent: Starting session tracking...
  $ cs start "Fix payment processing + retry"
  Session started

  [Agent works: reads files, edits code, runs tests...]
  $ cs log-ai -p anthropic -m claude-opus-4-6 --prompt-tokens 8000 --completion-tokens 4000
  $ cs log-ai -p anthropic -m claude-opus-4-6 --prompt-tokens 12000 --completion-tokens 6000
  $ cs log-ai -p anthropic -m claude-opus-4-6 --prompt-tokens 5000 --completion-tokens 3000

  $ cs end -n "Fixed payment bug, added exponential backoff retry"
  Session ended

  Session: 12m • 6 files • 2 commits • $0.76 AI cost

After 50 agent runs:

$ cs stats
┌──────────────┬────────────────┐
│ Total Sessions│ 50            │
│ Total Time   │ 8h 34m        │
│ Files Changed│ 312           │
│ Commits      │ 87            │
│ Total AI Cost│ $47.23        │
└──────────────┴────────────────┘

---

Example Output

$ cs show

Session: Build user auth

┌──────────────┬────────────────────────────┐
│ Metric       │ Value                      │
├──────────────┼────────────────────────────┤
│ Status       │ Completed                  │
│ Started      │ Feb 09, 2026 14:30         │
│ Ended        │ Feb 09, 2026 16:45         │
│ Duration     │ 2h 15m                     │
│ Files Changed│ 12                         │
│ Commits      │ 5                          │
│ AI Tokens    │ 45,000                     │
│ AI Cost      │ $2.34                      │
│ Notes        │ Completed basic auth flow  │
└──────────────┴────────────────────────────┘

Example `cs show --json` output

{
  "id": 42,
  "name": "Fix payment processing + retry",
  "status": "completed",
  "startTime": "2026-02-09T14:30:00.000Z",
  "endTime": "2026-02-09T14:42:17.000Z",
  "duration": 737,
  "durationFormatted": "12m",
  "workingDirectory": "/home/user/project",
  "filesChanged": 6,
  "commits": 2,
  "aiTokens": 46000,
  "aiCost": 1.065,
  "notes": "Fixed payment bug, added exponential backoff retry",
  "files": [
    { "id": 1, "sessionId": 42, "filePath": "src/payments.ts", "changeType": "modified", "timestamp": "2026-02-09T14:32:11.000Z" },
    { "id": 2, "sessionId": 42, "filePath": "src/retry.ts", "changeType": "created", "timestamp": "2026-02-09T14:35:44.000Z" },
    { "id": 3, "sessionId": 42, "filePath": "tests/payments.test.ts", "changeType": "modified", "timestamp": "2026-02-09T14:38:20.000Z" }
  ],
  "commits": [
    { "id": 1, "sessionId": 42, "hash": "a1b2c3d", "message": "fix: payment processing null check", "timestamp": "2026-02-09T14:36:00.000Z" },
    { "id": 2, "sessionId": 42, "hash": "e4f5g6h", "message": "feat: add exponential backoff retry", "timestamp": "2026-02-09T14:41:00.000Z" }
  ],
  "aiUsage": [
    { "id": 1, "sessionId": 42, "provider": "anthropic", "model": "claude-opus-4-6", "tokens": 12000, "promptTokens": 8000, "completionTokens": 4000, "cost": 0.42, "timestamp": "2026-02-09T14:31:05.000Z" },
    { "id": 2, "sessionId": 42, "provider": "anthropic", "model": "claude-opus-4-6", "tokens": 18000, "promptTokens": 12000, "completionTokens": 6000, "cost": 0.63, "timestamp": "2026-02-09T14:34:22.000Z" },
    { "id": 3, "sessionId": 42, "provider": "anthropic", "model": "claude-sonnet-4", "tokens": 16000, "promptTokens": 14000, "completionTokens": 2000, "cost": 0.072, "timestamp": "2026-02-09T14:39:50.000Z" }
  ],
  "annotations": [
    { "id": 1, "sessionId": 42, "message": "Starting retry logic implementation", "timestamp": "2026-02-09T14:35:00.000Z" },
    { "id": 2, "sessionId": 42, "message": "Tests passing, cleaning up", "timestamp": "2026-02-09T14:40:30.000Z" }
  ]
}
All --json responses include schemaVersion (currently 1) and codesessionVersion (e.g. "2.0.0") at the top level.

log-ai options

FlagDescription
-p, --providerAI provider (required)
-m, --modelModel name (required)
-t, --tokensTotal tokens
--prompt-tokensPrompt/input tokens
--completion-tokensCompletion/output tokens
-c, --costCost in USD (auto-calculated if omitted for known models)
-s, --session <id>Target a specific session instead of the active one

Configurable pricing

codesession ships with built-in pricing for 17 models. Override or add models:

```bash

What's New in v2.1.0 (The API Tracking Pivot)

We merged the most loved features of aitoken-cli directly into codesession! You can now use codesession as a drop-in Node.js library to automatically track AI costs in your backend apps, completely headless.

  • Drop-in SDKs — Just import { TrackedOpenAI } from 'codesession-cli/extensions'
  • Background Sessions — API calls made via the library auto-create headless tracking sessions so you never lose a cent of data.
  • Extended Model Pricing — 42+ built-in models including DeepSeek, o1, o3, Azure, and Cohere.
  • Middleware HookscreateTrackedClient() and BatchTracker for advanced Node.js architectures.

---

1. Drop-in SDK Extensions

Simply replace new OpenAI() with new TrackedOpenAI():

import { TrackedOpenAI, TrackedAnthropic } from 'codesession-cli/extensions';

// Works exactly like the official OpenAI SDK, but logs tokens and costs automatically!
const openai = new TrackedOpenAI({ apiKey: process.env.OPENAI_API_KEY });
const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }]
});

Programmatic API (for agent frameworks)

Build codesession tracking directly into your agent:

import { AgentSession, BudgetExceededError } from 'codesession-cli/agents';

const session = new AgentSession('Refactor auth module', {
  budget: 5.00,        // Hard cap: stop at $5
  directory: './src',   // Watch this directory
  git: true,           // Track commits
});

session.start();

// After each AI call — with granular tokens (cost auto-calculated)
session.logAI('anthropic', 'claude-opus-4-6', 15000, 0.30, {
  promptTokens: 10000,
  completionTokens: 5000,
});

// Pre-flight check
if (!session.canAfford(2.00)) {
  console.log('Switching to cheaper model...');
}

// Budget enforcement is automatic
try {
  session.logAI('openai', 'gpt-4o', 50000, 4.80);
} catch (e) {
  if (e instanceof BudgetExceededError) {
    console.log(`Stopped at $${e.spent} (limit: $${e.budget})`);
  }
}

const summary = session.end();
// { duration: 847, filesChanged: 12, aiCost: 4.80, commits: 3, ... }

Agent Workflow

graph LR A[Start Session] --> B[Agent Works] B --> C[Log AI Calls] C --> D{More Work?} D -->|Yes| B D -->|No| E[End Session] E --> F[View Dashboard] B -.->|Auto-tracked| G[File Changes] B -.->|Auto-tracked| H[Git Commits] C -.->|Tracked| I[Tokens & Cost] style A fill:#4CAF50 style E fill:#2196F3 style F fill:#FF9800

Typical agent flow: 1. cs start "Task name" --json --close-stale - Creates session 2. Agent performs work (files, commits auto-tracked) 3. cs log-ai -p anthropic -m claude-sonnet-4 --agent "Agent Name" --json - Log each AI call 4. cs status --json - Check costs mid-session 5. cs end -n "Task complete" --json - Finalize and summarize 6. cs dashboard - Review analytics

Integration Contract (for agent frameworks)

If you're building an agent framework integration (OpenClaw, Claude Code, custom), here's the contract:

🇨🇳 中文文档镜像 AI 翻译 2026-06-01
英文原文章节由系统翻译为中文摘要,便于快速理解。完整原文见上方 "📑 README 深度解析"。
📌 简介

CostHQ 是一款专为开发者设计的 AI 成本追踪工具,旨在精准监控 AI Agent 的实际开销。通过直观的 Dashboard,您可以实时查看 Session 总数、累计成本、Token 使用量(Prompt 与 Completion)以及费用变化趋势。系统提供详细的费用分析图表与最昂贵的 Session 列表,帮助您全面掌控 AI 使用情况,实现成本的可视化与预测。

⚡ 功能介绍

v3.0.0 版本引入了强大的 Command Center Console,允许用户直接在 UI 界面启动或终止 Session,无需频繁操作 CLI。此外,全新的 Shareable Stats Card 支持将您的编程与 AI 使用统计导出为 Spotify-Wrapped 风格的精美图片。v2.0.0 版本则提供了完善的 Alerts Dashboard,支持设置每日及单次 Session 的成本限额,并通过声音和浏览器通知进行实时预警。

📋 环境依赖

在使用 codesession-cli 之前,请确保您的系统已安装必要的 C/C++ 构建工具。由于项目使用了嵌入式的 SQLite 数据库(better-sqlite3),在 Ubuntu/Debian 等 Linux 环境下,您可能需要通过 `sudo apt-get install` 安装相关的编译依赖,以确保数据库组件能够正常编译与运行。

🛠 安装步骤(Docker/pip/源码)

您可以通过 npm 全局安装 codesession-cli 来快速开始使用:执行 `npm install -g codesession-cli` 即可。对于集成 AI Agent 的开发者,建议在调用前通过 `which cs` 命令检查 CLI 是否已正确安装,以确保在工具缺失时能够实现平滑降级,不影响 Agent 的核心任务执行。

🚀 使用教程

CostHQ 提供两种灵活的使用模式:对于开发者,您可以将其作为 Node.js 库直接引入后端应用,实现无感知的 API 费用追踪;对于使用 OpenClaw、Claude Code 或其他 AI Agent 框架的用户,可以直接通过 CLI 进行交互。所有命令行指令均支持 `--json` 参数,方便进行机器可读的数据处理与自动化集成。

⚙️ 配置说明(含 MCP / env)

您可以高度自定义日志记录选项,通过 `--provider` 指定 AI 提供商,并使用 `--model`、`--prompt-tokens`、`--completion-tokens` 等参数精确记录 Token 使用情况。如果需要,您还可以通过 `--cost` 手动指定费用。CostHQ 内置了 17 种主流模型的定价策略,并支持用户根据实际需求覆盖或新增自定义模型定价。

🔌 API 说明

在 v2.1.0 版本中,codesession 完成了向 API 追踪能力的重大转型。通过提供 Drop-in SDK 扩展,开发者只需将官方 SDK(如 `new OpenAI()`)替换为 `new TrackedOpenAI()`,即可在保持原有开发体验的同时,实现对 Token 和成本的自动记录与 Headless(无头)模式下的后台追踪。

🔄 工作流/模块

CostHQ 构建了一套完整的 Agent 工作流闭环:从启动 Session 开始,Agent 在执行任务过程中,系统会自动追踪文件变更(File Changes)与 Git Commits。每当发生 AI 调用时,Tokens 与 Cost 会被实时记录。任务结束后,所有数据将汇总至 Dashboard,通过可视化的方式呈现完整的 AI 使用链路与成本报告。

🎯 aiskill88 AI 点评 A 级 2026-05-29

CostHQ是一个有用的开源AI工作流工具

📚 实用指南(长尾问题)
适合谁
  • 需要 CostHQ 解决具体问题的开发者与运营人员
最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
部署方案
  • CLI:直接 npm install -g / pip install,命令行调用
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
CostHQ 中文教程CostHQ 安装报错怎么办CostHQ 与同类工具对比CostHQ 最佳实践CostHQ 适合谁用

⚡ 核心功能

👥 适合谁
  • 需要 CostHQ 解决具体问题的开发者与运营人员
⭐ 最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)

👥 适合人群

自动化工程师和运维人员项目经理和业务分析师希望减少重复性工作的专业人士数字化转型团队

🎯 使用场景

  • 自动化日常重复性工作,将精力集中于创造性任务
  • 构建数据采集 → 处理 → 输出的完整自动化管线
  • 实现跨平台、跨系统的数据流转和业务协同

⚖️ 优点与不足

✅ 优点
  • +MIT 协议,可免费商用
  • +大幅减少重复性人工操作
  • +可视化流程,清晰直观
  • +可扩展性强,支持复杂场景
⚠️ 不足
  • 初始配置和调试需投入一定时间
  • 强依赖外部服务的稳定性
  • 复杂场景需具备一定技术基础
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐

📚 相关教程推荐
📰 相关 AI 新闻
🍿 AI 圈相关吃瓜
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

CostHQ 是一款TypeScript开发的AI辅助工具。开源AI工作流:Track what your AI agents cost including files, commits, tokens, budgets. CLI , 。⭐8 · TypeScript 主要应用场景包括:AI项目成本跟踪。
💡 AI Skill Hub 点评

AI Skill Hub 点评:CostHQ 的核心功能完整,质量良好。对于自动化工程师和运维人员来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。

⬇️ 获取与下载
⬇ 下载源码 ZIP

✅ MIT 协议 · 可免费商用 · 直接从 aiskill88 服务器下载,无需跳转 GitHub

📚 深入学习 CostHQ
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 CostHQ
原始描述 开源AI工作流:Track what your AI agents cost including files, commits, tokens, budgets. CLI , 。⭐8 · TypeScript
Topics aiclicost-tracking
GitHub https://github.com/brian-mwirigi/CostHQ
License MIT
语言 TypeScript
🔗 原始来源
🐙 GitHub 仓库  https://github.com/brian-mwirigi/CostHQ 🌐 官方网站  https://www.npmjs.com/package/costhq

收录时间:2026-05-29 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。