跳到正文
Skillpedia
其他81k · #1601

cost-federation

它能做什么

这项技能按一小时、一天和一周三个时间段,统计每个已连接节点的支出。适合与多个已连接系统共享 AI 工作的人。

适用场景

  • ✓当你把 AI 工作开放给一个新的已连接节点,并希望先有一个基准时。
  • ✓当你想通过定期检查监视每个节点的支出时。
  • ✓当你想确认开支上限能否捕捉到超出限度的节点时。

技能链接

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-federation/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-federation/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“各个已连接节点在过去一天里为我的任务花了多少钱?”

每周 5 个新技能,1 分钟读完。

工作原理

这项技能从共享存储中读取支出事件,在三个时间段内按节点汇总。然后它将每个节点与一个美元阈值进行比较,并报告超过阈值的节点。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Cost Federation

ADR-097 Phase 3 specifies a federation_spend event bus that publishes one event per federation_send completion: {peerId, taskId, tokensUsed, usdSpent, ts}. Cost-tracker is the declared consumer — it aggregates per-peer rolling windows (1h / 24h / 7d) and the federation breaker queries that aggregate to suspend peers exceeding the configured threshold.

Phase 3 isn't landed upstream yet. This skill is the consumer-side wiring; it activates the moment upstream publishes events to the federation-spend namespace. Until then it reports cleanly with a "no events found" notice.

When to use

  • Before opening federation traffic to a new peer — establish baseline.
  • Periodically (e.g. /loop 5m) to monitor per-peer spend across windows.
  • After ADR-097 Phase 2/3 lands — to verify breaker suspension reasoning.

Steps

  1. Run the script:

    node plugins/ruflo-cost-tracker/scripts/federation.mjs
    

    Optional env:

    • FED_FORMAT=json — JSON instead of markdown
    • FED_NAMESPACE=federation-spend — override target namespace
    • FED_SUSPEND_THRESHOLD_USD=5.0 — breaker threshold (ADR-097 default)
  2. Inspect — per-peer 1h/24h/7d windows of count + USD spent, plus a "Suspension threshold check" block flagging peers over the breaker line.

Storage contract (consumer side)

When Phase 3 lands, events should be persisted to namespace federation-spend with key prefix fed-spend- and JSON value matching:

{
  "peerId": "<peer-uuid>",
  "taskId": "<task-uuid>",
  "tokensUsed": 12345,
  "usdSpent": 0.0287,
  "ts": "2026-05-05T..."
}

The script reads any record matching that prefix, regardless of how upstream produces them. Multiple events per peer accumulate cleanly into the rolling-window sums.

Cross-references

  • ADR-097: Federation budget circuit breaker — the complete spec
  • cost-report — same data, different lens (cost-report focuses on local agent spend; this skill on per-peer federated spend)
  • ruflo-federation plugin — the producer side (when Phase 3 lands)
常见问题

它现在就能运行吗?

只有在上游系统开始发布事件之后才可以。在此之前,它会报告未找到任何事件。

默认阈值是多少?

来源设定的默认值为 5 美元,你可以通过设置进行更改。

节点超过上限时会怎样?

该节点会在报告中被标记。暂停节点是由读取这些数据的另一个熔断器完成的,而不是由这项技能完成。

详情

作者的原始描述

Consumer-side wiring for ADR-097 Phase 3 federation_spend events — per-peer rolling windows + suspension-threshold check

repo: ruvnet/ruflo

热度

GitHub 星标
81k
排名
#1601
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能