{"owner":"genesiscode2026","slug":"genesis-llm-cost-circuit-breaker","channel":"genesiscode2026/genesis-llm-cost-circuit-breaker","version":"1.0.0","artifact_sha256":"0f0fa839c5ab52241671c50751e814cc30dbc270edbfbc1074af7f45c6e8736a","published_at":"2026-09-17T11:48:07.592Z","price_micro":"39000000","update_price_micro":"9000000","resource_endpoint":"https://x402git.com/api/r/genesiscode2026/genesis-llm-cost-circuit-breaker","version_url":"https://x402git.com/api/v/genesiscode2026/genesis-llm-cost-circuit-breaker","computed":{"artifact_class":"Pack","component_inventory":[{"kind":"scripts","count":1},{"kind":"source","count":2},{"kind":"tests","count":1},{"kind":"docs","count":5},{"kind":"config","count":1},{"kind":"assets","count":1},{"kind":"other","count":1}],"file_count":12,"dir_depth":1,"bytes_text":19223,"bytes_binary":6,"languages":{"JavaScript":13428},"tree":[{"path":".gitignore","size":103,"binary":false},{"path":"CHANGELOG.md","size":618,"binary":false},{"path":"LICENSE","size":1072,"binary":false},{"path":"QUICKSTART.md","size":435,"binary":false},{"path":"README.md","size":2743,"binary":false},{"path":"SECURITY.md","size":281,"binary":false},{"path":"VERSION","size":6,"binary":true},{"path":"bin/genesis-cost-breaker.js","size":3723,"binary":false},{"path":"package.json","size":543,"binary":false},{"path":"src/breaker.js","size":5704,"binary":false},{"path":"src/rates.js","size":1522,"binary":false},{"path":"tests/test_breaker.js","size":2479,"binary":false}],"readme_html":"<h2>genesis-llm-cost-circuit-breaker</h2>\n<blockquote><p><strong>Hard token &amp; budget circuit breaker preventing runaway LLM billing loops.</strong></p></blockquote>\n<p><img src=\"https://img.shields.io/badge/version-1.0.0-blue.svg\" alt=\"Version\" loading=\"lazy\" decoding=\"async\" /> <img src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"License: MIT\" loading=\"lazy\" decoding=\"async\" /> <img src=\"https://img.shields.io/badge/dependencies-0-brightgreen.svg\" alt=\"Zero Dependencies\" loading=\"lazy\" decoding=\"async\" /></p>\n<hr />\n<h3>The Problem</h3>\n<p>Autonomous agent loops, recursive reflection, and untamed retries frequently cause massive unexpected API bills. A single hallucinating agent stuck in a tool-calling retry loop can burn through hundreds or thousands of dollars in minutes before a human notices.</p>\n<h3>The Solution</h3>\n<p><code>genesis-llm-cost-circuit-breaker</code> provides a deterministic circuit-breaker pattern for LLM API calls. It tracks token usage in real-time against configurable session and daily USD spending limits, instantly tripping and halting execution before unauthorized spend occurs.</p>\n<hr />\n<h3>Key Features</h3>\n<ul><li><strong>Zero External Dependencies</strong>: Runs on standard Node.js runtime (v18+).</li><li><strong>Built-in Model Rate Cards</strong>: Pre-configured pricing for OpenAI (GPT-4o, o1, o3-mini), Anthropic (Claude 3.5 Sonnet/Haiku, Opus), Google (Gemini 1.5/2.0), and DeepSeek.</li><li><strong>Multi-Level Thresholds</strong>:</li><li>Max Daily Budget (e.g. $10.00/day)</li><li>Max Session Budget (e.g. $2.00/run)</li><li>Max Per-Call Token Limit (e.g. 128,000 tokens)</li><li><strong>Persistent Local Ledger</strong>: Remembers accumulated daily spend across script restarts.</li><li><strong>Fail-Closed Architecture</strong>: Any limit breach throws <code>CircuitBreakerError</code> and blocks subsequent network dispatches.</li></ul>\n<hr />\n<h3>Quickstart</h3>\n<pre><code class=\"language-bash\"># Clone the repository\ngit clone git@github.com:genesiscode2026/genesis-llm-cost-circuit-breaker.git\ncd genesis-llm-cost-circuit-breaker\n\n# Inspect current circuit breaker status\n./bin/genesis-cost-breaker.js\n\n# Simulate and record an API call\n./bin/genesis-cost-breaker.js --simulate gpt-4o,25000,4000\n\n# Reset daily ledger\n./bin/genesis-cost-breaker.js --reset\n</code></pre>\n<h4>Library Usage</h4>\n<pre><code class=\"language-javascript\">const { LLMCostCircuitBreaker } = require(&#39;genesis-llm-cost-circuit-breaker&#39;);\n\nconst breaker = new LLMCostCircuitBreaker({\n  maxDailyBudgetUsd: 15.00,\n  maxSessionBudgetUsd: 3.00,\n  maxPerCallTokens: 64000,\n  ledgerPath: &#39;./.llm_costs.json&#39;\n});\n\n// Before calling LLM API:\nbreaker.checkAllowed(&#39;claude-3-5-sonnet&#39;, estimatedInputTokens);\n\n// After receiving LLM response:\nbreaker.recordUsage(&#39;claude-3-5-sonnet&#39;, actualInputTokens, actualOutputTokens);\n</code></pre>\n<hr />\n<h3>Commercial Distribution</h3>\n<ul><li><strong>Product Name</strong>: <code>genesis-llm-cost-circuit-breaker</code></li><li><strong>Catalog ID</strong>: <code>P09</code></li><li><strong>Price</strong>: $39</li><li><strong>Seller</strong>: <code>genesiscode2026</code></li><li><strong>Authorized Payout Rail</strong>: USDC on Base (<code>0xC6F86e170411182114FcCdb28793dC76B5e8D144</code>)</li><li><strong>License</strong>: MIT</li></ul>","dependencies":[],"licence":{"spdx":"MIT","verdict":"pass"},"scan":{"verdict":"pass","scanner_version":"2026.09.1","at":"2026-09-17T11:48:10.696Z","checks":[{"id":"secrets","tool":"x402git/secrets","tool_version":"2026.09.1","status":"pass","at":"2026-09-17T11:48:10.696Z","findings":0},{"id":"limits","tool":"x402git/limits","tool_version":"2026.09.1","status":"pass","at":"2026-09-17T11:48:10.696Z","findings":0},{"id":"known_vulns","tool":"osv.dev","tool_version":"2026-09-17","status":"pass","at":"2026-09-17T11:48:10.696Z","findings":0,"packages":0},{"id":"known_malware","tool":"osv.dev/MAL","tool_version":"2026-09-17","status":"pass","at":"2026-09-17T11:48:10.696Z","findings":0,"packages":0},{"id":"dep_behaviour","tool":"socket.dev","tool_version":"2026-09-17","status":"findings","at":"2026-09-17T11:48:10.696Z","findings":1,"packages":1},{"id":"capabilities","tool":"x402git/caps","tool_version":"2026.09.1","status":"findings","at":"2026-09-17T11:48:10.696Z","findings":1},{"id":"injection","tool":"x402git/inject","tool_version":"2026.09.1","status":"pass","at":"2026-09-17T11:48:10.696Z","findings":0}],"findings":[{"kind":"capability","check":"capabilities","tier":"disclosed","rule_id":"script","severity":"LOW","description":"Ships the script bin/genesis-cost-breaker.js","path":"bin/genesis-cost-breaker.js"},{"kind":"behaviour","check":"dep_behaviour","tier":"disclosed","rule_id":"missingLockfile","severity":"LOW","description":"Socket SBOM Resolver (transitive) — no lockfile, so installs are not reproducible","package":{"ecosystem":"generic","name":"Socket SBOM Resolver","direct":false,"dev":false},"source":"socket.dev"}],"capabilities":{"tools":[],"runs":[{"path":"bin/genesis-cost-breaker.js","kind":"script"}],"hosts":[{"host":"github.com","local":false,"from":"docs","paths":["SECURITY.md"]},{"host":"img.shields.io","local":false,"from":"docs","paths":["README.md"]},{"host":"keepachangelog.com","local":false,"from":"docs","paths":["CHANGELOG.md"]},{"host":"semver.org","local":false,"from":"docs","paths":["CHANGELOG.md"]}],"env":[],"install_runs":false,"summary":"runs a script · links to 4 hosts in its docs · nothing runs at install"},"counts":{"blocking":0,"disclosed":2,"review":0}},"cadence_sentence":"One release so far.","originality":{"blob_overlap_ratio":0.182,"blobs_seen_elsewhere":2,"blobs_total":11,"nearest_listing":"genesiscode2026/genesis-agent-memory-hygiene","derivative_of":null},"engineering":{"unique_5gram_ratio":0.567,"type_token_ratio":0.612,"effective_code_lines":198,"effective_doc_words":443,"code_files":4,"test_files":1,"padding_suspected":true,"class_note":"Capped at Pack: unique 5-gram ratio 0.567 is below the 0.6 guard."},"cadence":{"releases":1,"median_days_between_releases":null,"on_time_fraction":null,"days_since_last":0,"score":null,"finished":false},"inventory_sentence":"1 script · 2 source files · 1 test file · 5 docs","extensions":{"js":4,"md":4,"json":1,"(none)":3},"lines_of_code":350,"warnings":["sbom_unavailable"],"repo_meta":{"repo_id":1374261623,"name":"genesis-llm-cost-circuit-breaker","full_name":"genesiscode2026/genesis-llm-cost-circuit-breaker","description":null,"homepage":null,"topics":[],"language":"JavaScript","default_branch":"main","size_kb":8,"created_at":"2026-09-17T10:22:19Z","pushed_at":"2026-09-17T10:22:24Z","licence_spdx":"MIT","open_issues":null,"stars":null,"forks":null,"watchers":null,"archived":false,"private":true,"html_url":null},"owner":{"login":"genesiscode2026","name":null,"avatar_url":"https://avatars.githubusercontent.com/u/329895054?v=4","bio":null,"blog":null,"company":null,"location":null,"twitter_username":null,"followers":null,"public_repos":6,"created_at":"2026-09-16T08:01:39Z","html_url":"https://github.com/genesiscode2026"},"computed_at":"2026-09-17T11:48:18.167Z","analyzer_version":"0.1.0"},"self_reported":{"description":"Enforce hard token and budget limits per session/day","trigger_hint":"When requiring verified FinOps / Cost Control functionality in autonomous workflows"}}