agentcap-cli 0.5.1__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/PKG-INFO +7 -7
  2. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/README.md +6 -6
  3. agentcap_cli-0.5.3/plugin/README.md +90 -0
  4. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/pyproject.toml +1 -1
  5. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/__init__.py +1 -1
  6. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/quota.py +7 -3
  7. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_cc_plugin.py +63 -1
  8. agentcap_cli-0.5.3/tests/test_prompt_block.py +219 -0
  9. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/.gitignore +0 -0
  10. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/LICENSE +0 -0
  11. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/codex-plugin/LICENSE +0 -0
  12. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/landing/v2/README.md +0 -0
  13. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/plugin/LICENSE +0 -0
  14. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/_lifeline_exec.py +0 -0
  15. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/_lifeline_watch.py +0 -0
  16. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/adapters.py +0 -0
  17. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/alerts.py +0 -0
  18. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/analytics.py +0 -0
  19. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/budget.py +0 -0
  20. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/clamp.py +0 -0
  21. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/cli.py +0 -0
  22. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/cli_history.py +0 -0
  23. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/data/pricing.json +0 -0
  24. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/demo.py +0 -0
  25. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/devtools/__init__.py +0 -0
  26. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/devtools/fake_upstream.py +0 -0
  27. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/estimate.py +0 -0
  28. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/eta.py +0 -0
  29. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/failsafe.py +0 -0
  30. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/harness.py +0 -0
  31. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/history.py +0 -0
  32. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/ledger.py +0 -0
  33. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/license.py +0 -0
  34. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/lifeline.py +0 -0
  35. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/live_quota.py +0 -0
  36. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/logschema.py +0 -0
  37. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/loop.py +0 -0
  38. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/plans.py +0 -0
  39. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/pricing.py +0 -0
  40. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/private.py +0 -0
  41. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/procstop.py +0 -0
  42. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/proxy.py +0 -0
  43. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/report.py +0 -0
  44. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/runner.py +0 -0
  45. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/upstreams.py +0 -0
  46. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/usage.py +0 -0
  47. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/src/agentcap/waste.py +0 -0
  48. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/conftest.py +0 -0
  49. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-a1b2c3.jsonl +0 -0
  50. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-d4e5f6.jsonl +0 -0
  51. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p.jsonl +0 -0
  52. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-00-thr-parent.jsonl +0 -0
  53. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-50-thr-child.jsonl +0 -0
  54. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-01-20-thr-fork.jsonl +0 -0
  55. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/harness_logs/agy-1.4.11-2026-10-30.jsonl +0 -0
  56. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/harness_logs/claude-2.1.316-pretooluse.json +0 -0
  57. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/harness_logs/claude-2.1.316-statusline.json +0 -0
  58. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/harness_logs/codex-rollout-2026-10-29.jsonl +0 -0
  59. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/harness_logs/opencode-2026-10-30.jsonl +0 -0
  60. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/history/claude/.credentials.json +0 -0
  61. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/history/claude/projects/-home-dev-shop/1f0c-sess-a.jsonl +0 -0
  62. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/history/codex/auth.json +0 -0
  63. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/history/codex/sessions/2026/10/29/rollout-2026-10-29T10-00-00-0199aaaa-bbbb-cccc-dddd-eeeeeeeeeeee.jsonl +0 -0
  64. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/upstream/README.md +0 -0
  65. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/upstream/anthropic_403_permission_error.json +0 -0
  66. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/upstream/openai_403_region_blocked.json +0 -0
  67. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/upstream/openrouter_401_user_not_found.json +0 -0
  68. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/upstream/openrouter_403_moderation.json +0 -0
  69. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/fixtures/upstream/openrouter_429_rate_limited.json +0 -0
  70. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/license_support.py +0 -0
  71. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/proxy_support.py +0 -0
  72. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_adapters.py +0 -0
  73. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_agent_set.py +0 -0
  74. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_agents.py +0 -0
  75. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_alerts.py +0 -0
  76. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_analytics.py +0 -0
  77. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_anthropic_proxy.py +0 -0
  78. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_anthropic_units.py +0 -0
  79. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_budget.py +0 -0
  80. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_child_status.py +0 -0
  81. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_clamp.py +0 -0
  82. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_claude_adapter_and_tiers.py +0 -0
  83. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_cli.py +0 -0
  84. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_codex_plugin.py +0 -0
  85. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_concurrent_forgive.py +0 -0
  86. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_e2e_claude.py +0 -0
  87. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_estimate.py +0 -0
  88. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_exit_codes.py +0 -0
  89. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_failsafe.py +0 -0
  90. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_harness.py +0 -0
  91. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_history.py +0 -0
  92. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_ledger.py +0 -0
  93. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_license.py +0 -0
  94. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_lifeline.py +0 -0
  95. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_live_quota.py +0 -0
  96. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_log_contract.py +0 -0
  97. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_log_contract_live.py +0 -0
  98. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_loop.py +0 -0
  99. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_plugin_package.py +0 -0
  100. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_pricing.py +0 -0
  101. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_private_dirs.py +0 -0
  102. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_procstop.py +0 -0
  103. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_proxy_auth.py +0 -0
  104. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_proxy_cancel.py +0 -0
  105. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_proxy_core.py +0 -0
  106. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_proxy_extras.py +0 -0
  107. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_proxy_streaming.py +0 -0
  108. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_quota.py +0 -0
  109. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_release.py +0 -0
  110. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_report_cli.py +0 -0
  111. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_runaway.py +0 -0
  112. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_runner.py +0 -0
  113. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_self_approve.py +0 -0
  114. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_stop_matrix.py +0 -0
  115. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_upstream_refusals.py +0 -0
  116. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_upstreams.py +0 -0
  117. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_usage.py +0 -0
  118. {agentcap_cli-0.5.1 → agentcap_cli-0.5.3}/tests/test_zombie_collector.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agentcap-cli
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: Local-first quota and cost guard for coding agents: per-job share of Claude Code/Codex/Gemini subscription quota, loop breaker, evidence receipt.
5
5
  Project-URL: Homepage, https://agentcap.launchbench.studio
6
6
  Project-URL: Repository, https://github.com/Blitz00X/agentcap
@@ -846,7 +846,7 @@ steps are noisy. No team aggregation: everything stays on your machine.
846
846
 
847
847
  ## Free vs Pro (0.2)
848
848
 
849
- **Free (MIT License, forever):** the per-run spend cap.
849
+ **Free (MIT License):** the per-run spend cap.
850
850
  - Per-run `--cap` (`--hour-cap` / `--day-cap` exit 2 on Free with a clear message)
851
851
  - Output clamping, fail-closed metering, terminal alerts
852
852
  - Claude Code, Codex, any SDK script (and Gemini CLI)
@@ -855,7 +855,7 @@ steps are noisy. No team aggregation: everything stays on your machine.
855
855
  When the Pro detectors below would have fired on a Free run, AgentCap does not stop it.
856
856
  It prints one line: `Pro's loop breaker would have stopped this at $X.XX`.
857
857
 
858
- **Pro, $12 one-time (launch week; $19 after): stop runs that loop or eat your quota.**
858
+ **Pro, $7 one-time during the beta ($12 after): stop runs that loop or eat your quota.**
859
859
 
860
860
  **Get Pro:** buy at https://agentcap.launchbench.studio/#pricing (Polar checkout). Polar then
861
861
  emails you an **Access purchase** link; the key is in the Polar customer portal (not in the
@@ -880,11 +880,11 @@ The VS Code/Cursor extension and the Claude Code plugin use the same CLI licence
880
880
  `AGENTCAP_RECEIPT_DIR`) with requests, spend, caps, the stop reason and the exit code. It contains
881
881
  numbers only, never prompts. The same one-line receipt is sent to Telegram and the webhook.
882
882
 
883
- [Buy AgentCap Pro — $12 launch week](https://buy.polar.sh/polar_cl_qagsvUdwQ0dRvaW7X5ynEJg5md27pEctIRAr40MBeLi)
883
+ [Buy AgentCap Pro — $7 beta price](https://buy.polar.sh/polar_cl_qagsvUdwQ0dRvaW7X5ynEJg5md27pEctIRAr40MBeLi)
884
884
 
885
885
  ### Purchase terms
886
886
 
887
- - Pro is $12 one-time (launch week; $19 after), no subscription. The current launch-week end date is on the pricing page.
887
+ - Pro is $7 one-time during the beta ($12 after), no subscription.
888
888
  - 14-day no-questions refund — email
889
889
  [kutaykarahan6@gmail.com](mailto:kutaykarahan6@gmail.com).
890
890
  - One licence key activates on up to 3 machines.
@@ -912,7 +912,7 @@ Polar customer portal.
912
912
  | LoopGuard | [tryloopguard.com](https://tryloopguard.com): free MIT CLI that integrates with Claude Code, Codex CLI and Cursor (no proxy, works with subscriptions) with per-session/daily caps and a no-progress loop killer; paid tier ($9/month) adds phone/Slack alerts and remote pause. A good fit if you use subscriptions or Claude Code. |
913
913
  | LiteLLM budgets | Budgets per key, user or team in the LiteLLM proxy; budgets need its database. A good fit if you already run a LiteLLM gateway; it is a server you deploy and configure. |
914
914
  | OpenRouter credit limits / provider spend caps | Account- or key-level and typically monthly (OpenRouter credit limits, OpenAI and Google spend caps). Provider caps are evaluated with a delay — Google has described about 10 minutes for the Gemini API cap — so a fast loop can overshoot. |
915
- | AgentCap | Local proxy for API-key traffic from Claude Code, Codex CLI, Gemini CLI or your own script: run cap (Free) with conservative reservation and output clamping, kills the process group at the cap and prints why. Pro (unattended pack): hour/day caps, loop/burn breaker, Telegram/webhook alerts, spend receipt, $19 one-time. |
915
+ | AgentCap | Local proxy for API-key traffic from Claude Code, Codex CLI, Gemini CLI or your own script: run cap (Free) with conservative reservation and output clamping, kills the process group at the cap and prints why. Pro (unattended pack): hour/day caps, loop/burn breaker, Telegram/webhook alerts, spend receipt, $7 one-time during the beta ($12 after). |
916
916
 
917
917
  The comparison above is from public pages; see the RelayPlane detail below.
918
918
 
@@ -953,7 +953,7 @@ prices and reported usage; when usage is missing it charges the full reservation
953
953
  **Is the day cap shared across machines?** No. Hour/day caps are per machine
954
954
  (local SQLite ledger). A license covers 3 machines, each with its own budget.
955
955
 
956
- **What does one-time purchase include?** $12 once in launch week ($19 after), all 0.x updates; not a
956
+ **What does one-time purchase include?** $7 once during the beta ($12 after), all 0.x updates; not a
957
957
  promise of future major versions. 14-day refund window per purchase terms.
958
958
 
959
959
  ## License
@@ -816,7 +816,7 @@ steps are noisy. No team aggregation: everything stays on your machine.
816
816
 
817
817
  ## Free vs Pro (0.2)
818
818
 
819
- **Free (MIT License, forever):** the per-run spend cap.
819
+ **Free (MIT License):** the per-run spend cap.
820
820
  - Per-run `--cap` (`--hour-cap` / `--day-cap` exit 2 on Free with a clear message)
821
821
  - Output clamping, fail-closed metering, terminal alerts
822
822
  - Claude Code, Codex, any SDK script (and Gemini CLI)
@@ -825,7 +825,7 @@ steps are noisy. No team aggregation: everything stays on your machine.
825
825
  When the Pro detectors below would have fired on a Free run, AgentCap does not stop it.
826
826
  It prints one line: `Pro's loop breaker would have stopped this at $X.XX`.
827
827
 
828
- **Pro, $12 one-time (launch week; $19 after): stop runs that loop or eat your quota.**
828
+ **Pro, $7 one-time during the beta ($12 after): stop runs that loop or eat your quota.**
829
829
 
830
830
  **Get Pro:** buy at https://agentcap.launchbench.studio/#pricing (Polar checkout). Polar then
831
831
  emails you an **Access purchase** link; the key is in the Polar customer portal (not in the
@@ -850,11 +850,11 @@ The VS Code/Cursor extension and the Claude Code plugin use the same CLI licence
850
850
  `AGENTCAP_RECEIPT_DIR`) with requests, spend, caps, the stop reason and the exit code. It contains
851
851
  numbers only, never prompts. The same one-line receipt is sent to Telegram and the webhook.
852
852
 
853
- [Buy AgentCap Pro — $12 launch week](https://buy.polar.sh/polar_cl_qagsvUdwQ0dRvaW7X5ynEJg5md27pEctIRAr40MBeLi)
853
+ [Buy AgentCap Pro — $7 beta price](https://buy.polar.sh/polar_cl_qagsvUdwQ0dRvaW7X5ynEJg5md27pEctIRAr40MBeLi)
854
854
 
855
855
  ### Purchase terms
856
856
 
857
- - Pro is $12 one-time (launch week; $19 after), no subscription. The current launch-week end date is on the pricing page.
857
+ - Pro is $7 one-time during the beta ($12 after), no subscription.
858
858
  - 14-day no-questions refund — email
859
859
  [kutaykarahan6@gmail.com](mailto:kutaykarahan6@gmail.com).
860
860
  - One licence key activates on up to 3 machines.
@@ -882,7 +882,7 @@ Polar customer portal.
882
882
  | LoopGuard | [tryloopguard.com](https://tryloopguard.com): free MIT CLI that integrates with Claude Code, Codex CLI and Cursor (no proxy, works with subscriptions) with per-session/daily caps and a no-progress loop killer; paid tier ($9/month) adds phone/Slack alerts and remote pause. A good fit if you use subscriptions or Claude Code. |
883
883
  | LiteLLM budgets | Budgets per key, user or team in the LiteLLM proxy; budgets need its database. A good fit if you already run a LiteLLM gateway; it is a server you deploy and configure. |
884
884
  | OpenRouter credit limits / provider spend caps | Account- or key-level and typically monthly (OpenRouter credit limits, OpenAI and Google spend caps). Provider caps are evaluated with a delay — Google has described about 10 minutes for the Gemini API cap — so a fast loop can overshoot. |
885
- | AgentCap | Local proxy for API-key traffic from Claude Code, Codex CLI, Gemini CLI or your own script: run cap (Free) with conservative reservation and output clamping, kills the process group at the cap and prints why. Pro (unattended pack): hour/day caps, loop/burn breaker, Telegram/webhook alerts, spend receipt, $19 one-time. |
885
+ | AgentCap | Local proxy for API-key traffic from Claude Code, Codex CLI, Gemini CLI or your own script: run cap (Free) with conservative reservation and output clamping, kills the process group at the cap and prints why. Pro (unattended pack): hour/day caps, loop/burn breaker, Telegram/webhook alerts, spend receipt, $7 one-time during the beta ($12 after). |
886
886
 
887
887
  The comparison above is from public pages; see the RelayPlane detail below.
888
888
 
@@ -923,7 +923,7 @@ prices and reported usage; when usage is missing it charges the full reservation
923
923
  **Is the day cap shared across machines?** No. Hour/day caps are per machine
924
924
  (local SQLite ledger). A license covers 3 machines, each with its own budget.
925
925
 
926
- **What does one-time purchase include?** $12 once in launch week ($19 after), all 0.x updates; not a
926
+ **What does one-time purchase include?** $7 once during the beta ($12 after), all 0.x updates; not a
927
927
  promise of future major versions. 14-day refund window per purchase terms.
928
928
 
929
929
  ## License
@@ -0,0 +1,90 @@
1
+ # AgentCap for Claude Code
2
+
3
+ Stop a Claude Code session before it loops or eats your Max/Pro quota.
4
+
5
+ AgentCap watches every tool call through Claude Code hooks. It warns, and on Pro ends the turn,
6
+ when a session reaches its share of your weekly or 5-hour quota, repeats the same tool call 4 times
7
+ in a row, or fails 8 tool calls in a row. Every stop says why, in plain numbers.
8
+
9
+ ## Install
10
+
11
+ ```
12
+ /plugin marketplace add Blitz00X/agentcap
13
+ /plugin install agentcap@agentcap
14
+ /agentcap:setup # once: adds AgentCap's read-only statusLine (your own line keeps showing)
15
+ ```
16
+
17
+ Needs `python3` on PATH. No pip install, no account, no network access.
18
+
19
+ ## Use
20
+
21
+ ```
22
+ /agentcap:quota 5% # this session may use 5 more points of the weekly quota
23
+ /agentcap:quota 2% 5h # or 2 more points of the 5-hour window
24
+ /agentcap:quota until 70% 5h # or stop when the 5-hour window reaches 70%
25
+ /agentcap:status # where this session stands and where it stops
26
+ /agentcap:default 10% 5h # give every new session (also claude -p) a limit; `off` removes it
27
+ /agentcap:approve # Pro, after a stop: raise the limit by 50% (at most twice)
28
+ /agentcap:off # clear this session's limit
29
+ /agentcap:unsetup # restore your previous statusLine and delete AgentCap's settings backup
30
+ ```
31
+
32
+ You can also ask in plain words. Claude Code shows a permission prompt with the stop point, and
33
+ the limit is set only after you approve:
34
+
35
+ - "Use at most 10% of the weekly quota in this session."
36
+ - "Stop when the 5-hour limit reaches 70%."
37
+ - "Why did AgentCap stop my last turn?"
38
+
39
+ The agent may only set or tighten a limit. Raising it, clearing it and approving a stop stay
40
+ yours: AgentCap denies any tool call by the agent that would run its script or edit its state.
41
+
42
+ ## Free and Pro
43
+
44
+ - **Free (MIT):** the live quota meter, a warning at 80% of the limit, and one notice when a limit,
45
+ a loop or an error streak is reached ("AgentCap Pro would stop the agent here"). Nothing is
46
+ blocked.
47
+ - **Pro ($7 one-time during the beta, $12 after):** the same detectors end the turn
48
+ (`PreToolUse` deny with `continue: false`), block new prompts while the session is over its
49
+ limit, and write a receipt. Pro is unlocked by a licence key that you activate with the separate
50
+ `agentcap` CLI (`pipx install agentcap-cli`, then `agentcap license activate`). Buy at
51
+ https://agentcap.launchbench.studio/#pricing. 14-day refund.
52
+
53
+ ## What the plugin runs, changes, stores and sends
54
+
55
+ - **Runs:** `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/agentcap_cc.py` on SessionStart,
56
+ UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure and Stop, and for the slash
57
+ commands above. Standard library only. While a limit is set it may start
58
+ `claude -p /usage` in the background, at most every 30 seconds, to read the current quota
59
+ (a local Claude Code command; no model call). Its statusLine command also runs your previous
60
+ user-level statusLine command, unchanged, so your own line keeps showing.
61
+ - **Changes:** `/agentcap:setup` sets only the `statusLine` key in `~/.claude/settings.json` and
62
+ keeps an owner-only backup of that file (`settings.json.agentcap-backup`).
63
+ `/agentcap:unsetup` restores your previous statusLine and deletes the backup.
64
+ - **Stores, on your machine only** (`~/.local/state/agentcap/quota/`): session ids, quota
65
+ percentages and reset times, counters, the tool name and a 16-character hash of each tool call,
66
+ and receipts (numbers and the last tool name). Never prompts, tool inputs, tool output, tokens or
67
+ credentials. Loop counters are deleted after 7 days, session files after 30 days, receipts after
68
+ 90 days.
69
+ - **Reads:** the `rate_limits` values Claude Code passes to the statusLine, Claude Code's own
70
+ `/usage` output, and the licence file `~/.config/agentcap/license.json` if it exists.
71
+ - **Sends:** nothing. The plugin makes no network requests. The separate `agentcap` CLI checks a
72
+ Pro key with Polar's licence API about once a week; Free users make no licence requests at all.
73
+
74
+ Privacy policy: https://agentcap.launchbench.studio/privacy
75
+
76
+ ## Limits
77
+
78
+ - The quota % is account-level: other sessions, devices and claude.ai use in the same window count
79
+ against this session's limit.
80
+ - A stop can be one response (or one 30-second `/usage` check) late, so a session can pass its
81
+ limit by a few points.
82
+ - macOS and Windows are not tested yet; Windows needs WSL.
83
+
84
+ ## Support
85
+
86
+ - Issues: https://github.com/Blitz00X/agentcap/issues
87
+ - Security reports: https://github.com/Blitz00X/agentcap/security/policy
88
+ - Source and the full CLI documentation: https://github.com/Blitz00X/agentcap
89
+
90
+ MIT License. Copyright (c) 2026 Kutay Karahan.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "agentcap-cli"
7
- version = "0.5.1"
7
+ version = "0.5.3"
8
8
  description = "Local-first quota and cost guard for coding agents: per-job share of Claude Code/Codex/Gemini subscription quota, loop breaker, evidence receipt."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -2,6 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __version__ = "0.5.1"
5
+ __version__ = "0.5.3"
6
6
 
7
7
  __all__ = ["__version__"]
@@ -290,7 +290,11 @@ def codex_home() -> Path:
290
290
 
291
291
 
292
292
  def parse_quota(raw: str) -> float:
293
- text = str(raw).strip().rstrip("%").strip()
293
+ # Turkish users write the sign first: `%1` means the same as `1%`.
294
+ text = str(raw).strip()
295
+ if text.startswith("%"):
296
+ text = text[1:].strip()
297
+ text = text.rstrip("%").strip()
294
298
  try:
295
299
  value = float(text)
296
300
  except ValueError:
@@ -1960,7 +1964,7 @@ class QuotaRunner:
1960
1964
  code = EXIT_GUARD_FAILED
1961
1965
  if loop_detail and not self.enforce:
1962
1966
  self._say(f"agentcap: Pro's loop breaker would have stopped this job at {LOOP_REPEATS} repeats"
1963
- f" ({loop_detail}). https://agentcap.launchbench.studio/#pricing")
1967
+ f" ({loop_detail}). See the Pro section of the AgentCap README.")
1964
1968
  self.summary = QuotaSummary(
1965
1969
  self.agent, self.window, self.quota, share, code, reason,
1966
1970
  tracker.baseline_exact, tracker.resets_seen, parallel, observed,
@@ -2127,7 +2131,7 @@ class QuotaRunner:
2127
2131
  if not self.enforce and s.observed and s.share >= s.quota:
2128
2132
  self._say(
2129
2133
  f"agentcap: Pro's quota mode would have stopped this job at {s.quota:g}%. "
2130
- "https://agentcap.launchbench.studio/#pricing"
2134
+ "See the Pro section of the AgentCap README."
2131
2135
  )
2132
2136
  if self.enforce:
2133
2137
  self._event("quota_receipt", s.share, reason=s.reason, exit_code=s.exit_code)
@@ -163,7 +163,8 @@ def test_manifests_valid_json():
163
163
  market = json.loads((ROOT / ".claude-plugin" / "marketplace.json").read_text())
164
164
  assert plugin["name"] == market["plugins"][0]["name"] == "agentcap"
165
165
  hooks = json.loads((ROOT / "hooks" / "hooks.json").read_text())["hooks"]
166
- assert set(hooks) == {"SessionStart", "PreToolUse", "PostToolUse", "PostToolUseFailure", "Stop"}
166
+ assert set(hooks) == {"SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse",
167
+ "PostToolUseFailure", "Stop"}
167
168
 
168
169
 
169
170
  # ------------------------------------------------------------- loop breaker
@@ -617,6 +618,67 @@ def test_setup_backup_is_private(env, monkeypatch):
617
618
  assert stat.S_IMODE(backup.stat().st_mode) == 0o600
618
619
 
619
620
 
621
+ def test_unsetup_restores_statusline_and_deletes_backup(env):
622
+ """0.5.3: the full-settings backup (may hold env keys) does not outlive /agentcap:unsetup."""
623
+
624
+ settings = cc.claude_settings_path()
625
+ settings.parent.mkdir(parents=True, exist_ok=True)
626
+ settings.write_text(json.dumps({
627
+ "statusLine": {"type": "command", "command": "echo old"},
628
+ "env": {"ANTHROPIC_API_KEY": "synthetic-not-a-real-key"},
629
+ }))
630
+ cc.cmd_setup(now=1.0)
631
+ backup = settings.with_name(settings.name + ".agentcap-backup")
632
+ assert backup.exists()
633
+ out = cc.cmd_unsetup()
634
+ assert "restored" in out and backup.name in out
635
+ assert not backup.exists()
636
+ data = json.loads(settings.read_text())
637
+ assert data["statusLine"] == {"type": "command", "command": "echo old"}
638
+ assert data["env"] == {"ANTHROPIC_API_KEY": "synthetic-not-a-real-key"}
639
+
640
+
641
+ def test_unsetup_of_a_foreign_statusline_keeps_the_backup(env):
642
+ settings = cc.claude_settings_path()
643
+ settings.parent.mkdir(parents=True, exist_ok=True)
644
+ settings.write_text(json.dumps({"statusLine": {"type": "command", "command": "echo mine"}}))
645
+ backup = settings.with_name(settings.name + ".agentcap-backup")
646
+ backup.write_text("{}")
647
+ assert "left unchanged" in cc.cmd_unsetup()
648
+ assert backup.exists()
649
+
650
+
651
+ def test_session_start_prunes_old_session_files_and_receipts(env):
652
+ import os as _os
653
+ import time as _t
654
+
655
+ now = _t.time()
656
+ month = 31 * 86400
657
+ files = {}
658
+ for sub in ("sessions", "usage", "by_cwd"):
659
+ d = cc.cc_dir() / sub
660
+ d.mkdir(parents=True, exist_ok=True)
661
+ files[sub] = (d / "old.json", d / "fresh.json")
662
+ for f in files[sub]:
663
+ f.write_text("{}")
664
+ _os.utime(files[sub][0], (now - month, now - month))
665
+ keep_txt = cc.cc_dir() / "sessions" / "notes.txt"
666
+ keep_txt.write_text("x")
667
+ _os.utime(keep_txt, (now - month, now - month))
668
+ receipts = cc.cc_dir() / "receipts.jsonl"
669
+ receipts.write_text(
670
+ json.dumps({"ts": now - 100 * 86400, "reason": "old"}) + "\n"
671
+ + json.dumps({"ts": now - 86400, "reason": "recent"}) + "\n"
672
+ + "not json\n")
673
+ hook("start", {"session_id": SID, "cwd": "/w", "hook_event_name": "SessionStart"})
674
+ for old, fresh in files.values():
675
+ assert not old.exists() and fresh.exists()
676
+ assert keep_txt.exists()
677
+ lines = receipts.read_text().splitlines()
678
+ assert [json.loads(line)["reason"] for line in lines[:1]] == ["recent"]
679
+ assert lines[1:] == ["not json"]
680
+
681
+
620
682
  def test_git_output_is_not_treated_as_a_plain_read(env):
621
683
  """L-3: --output writes state/plugin files even though git looks read-only."""
622
684
 
@@ -0,0 +1,219 @@
1
+ """A reached quota stops the conversation, not only the tool calls (0.5.2).
2
+
3
+ ``PreToolUse`` denies tool calls and ends the turn, but the user could type another
4
+ prompt and the model would answer in text, spending quota. Both plugins now check
5
+ ``UserPromptSubmit`` against the same reading ``PreToolUse`` uses; ``/agentcap:``
6
+ commands (Claude Code) and typed ``agentcap ...`` commands (Codex) always pass,
7
+ because they are how the user raises or clears the limit.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import importlib.util
13
+ import io
14
+ import json
15
+ from pathlib import Path
16
+
17
+ import pytest
18
+
19
+ from agentcap.quota import Reading, parse_agent_set, parse_limit_words, parse_quota
20
+
21
+ ROOT = Path(__file__).resolve().parent.parent
22
+
23
+
24
+ def _load(name):
25
+ spec = importlib.util.spec_from_file_location(name, ROOT / "scripts" / f"{name}.py")
26
+ mod = importlib.util.module_from_spec(spec)
27
+ spec.loader.exec_module(mod)
28
+ return mod
29
+
30
+
31
+ cc = _load("agentcap_cc")
32
+ cx = _load("agentcap_codex")
33
+
34
+ CC_SID = "4c2b1a00-1111-2222-3333-444455556666"
35
+ CX_SID = "01a1da0b-e835-7cf0-9dcd-5365269e5129"
36
+ RESETS = 2_000_000_000.0
37
+ R5 = 2_000_000_000.0
38
+ RW = 2_000_500_000.0
39
+
40
+
41
+ @pytest.fixture(autouse=True)
42
+ def env(tmp_path, monkeypatch):
43
+ monkeypatch.setenv("AGENTCAP_QUOTA_DIR", str(tmp_path / "state"))
44
+ monkeypatch.setenv("CLAUDE_CONFIG_DIR", str(tmp_path / "claude"))
45
+ monkeypatch.setenv("AGENTCAP_LICENSE_FILE", str(tmp_path / "license.json"))
46
+ monkeypatch.setattr(cx, "LIVE_READER", lambda: {"5h": Reading(10.0, R5), "week": Reading(40.0, RW)})
47
+ monkeypatch.setattr(cx, "SPAWN", lambda argv, **kw: None)
48
+ return tmp_path
49
+
50
+
51
+ def pro(tmp_path):
52
+ (tmp_path / "license.json").write_text(json.dumps(
53
+ {"source": "polar", "valid": True, "tier": "pro", "key": "X", "checked_at": 1, "reason": "ok"}))
54
+
55
+
56
+ # ------------------------------------------------------------------ Claude Code
57
+ def cc_hook(event, payload):
58
+ out = io.StringIO()
59
+ cc.main(["hook", event], stdin=io.StringIO(json.dumps(payload)), stdout=out)
60
+ text = out.getvalue().strip()
61
+ return json.loads(text) if text else None
62
+
63
+
64
+ def cc_prompt(text):
65
+ return cc_hook("prompt", {"session_id": CC_SID, "cwd": "/w", "hook_event_name": "UserPromptSubmit",
66
+ "prompt": text})
67
+
68
+
69
+ def cc_statusline(week, five=10.0):
70
+ payload = {"hook_event_name": "Status", "session_id": CC_SID, "cwd": "/w",
71
+ "rate_limits": {"five_hour": {"used_percentage": five, "resets_at": RESETS - 3600},
72
+ "seven_day": {"used_percentage": week, "resets_at": RESETS}}}
73
+ cc.main(["statusline"], stdin=io.StringIO(json.dumps(payload)), stdout=io.StringIO())
74
+
75
+
76
+ def cc_cmd(*args):
77
+ out = io.StringIO()
78
+ cc.main(list(args) + ["--session", CC_SID], stdout=out)
79
+ return out.getvalue()
80
+
81
+
82
+ def cc_at_limit(tmp_path):
83
+ """Pro, weekly quota 5 points from 40%, now at 45%: exactly at the stop point."""
84
+
85
+ pro(tmp_path)
86
+ cc_statusline(40.0)
87
+ cc_cmd("quota", "5%")
88
+ cc_statusline(45.0)
89
+
90
+
91
+ def test_claude_blocks_a_new_prompt_at_the_limit(env):
92
+ cc_at_limit(env)
93
+ out = cc_prompt("carry on with the task")
94
+ assert out["decision"] == "block"
95
+ assert out["reason"].startswith("agentcap: limit reached — weekly quota at 45%, stop point 45%.")
96
+ assert "/agentcap:approve (+50%)" in out["reason"]
97
+ assert "/agentcap:quota <N%> 5h" in out["reason"] and "/agentcap:off" in out["reason"]
98
+
99
+
100
+ def test_claude_slash_commands_pass_a_reached_limit(env):
101
+ cc_at_limit(env)
102
+ for command in ("/agentcap:off", "/agentcap:approve", "/agentcap:quota 5%", "/agentcap:status"):
103
+ assert cc_prompt(command) is None
104
+
105
+
106
+ def test_claude_under_the_limit_passes(env):
107
+ pro(env)
108
+ cc_statusline(40.0)
109
+ cc_cmd("quota", "10%")
110
+ cc_statusline(44.0)
111
+ assert cc_prompt("carry on") is None
112
+
113
+
114
+ def test_claude_free_tier_never_blocks_a_prompt(env):
115
+ cc_statusline(40.0) # no licence file: Free
116
+ cc_cmd("quota", "2%")
117
+ cc_statusline(45.0)
118
+ assert cc_prompt("carry on") is None
119
+
120
+
121
+ def test_claude_without_a_quota_passes(env):
122
+ pro(env)
123
+ cc_statusline(45.0)
124
+ assert cc_prompt("carry on") is None
125
+
126
+
127
+ # ------------------------------------------------------------------ Codex
128
+ def cx_hook(event, payload):
129
+ out = io.StringIO()
130
+ cx.main(["hook", event], stdin=io.StringIO(json.dumps(payload)), stdout=out)
131
+ text = out.getvalue().strip()
132
+ return json.loads(text) if text else None
133
+
134
+
135
+ def cx_prompt(text):
136
+ return cx_hook("UserPromptSubmit", {"session_id": CX_SID, "turn_id": "t", "cwd": "/w", "transcript_path": None,
137
+ "hook_event_name": "UserPromptSubmit", "model": "gpt-6-astra",
138
+ "permission_mode": "default", "prompt": text})
139
+
140
+
141
+ def cx_at_limit(tmp_path):
142
+ """Pro, 2 points of the 5-hour quota from 10%, the server now reports 13%."""
143
+
144
+ pro(tmp_path)
145
+ assert cx_prompt("agentcap 2% 5h")["decision"] == "block"
146
+ cx._atomic_write(cx.live_path(CX_SID), {"ts": 9e12, "readings": {"5h": {"used": 13.0, "resets_at": R5}}})
147
+
148
+
149
+ def test_codex_blocks_a_new_prompt_at_the_limit(env):
150
+ cx_at_limit(env)
151
+ out = cx_prompt("carry on with the task")
152
+ assert out["decision"] == "block"
153
+ assert "agentcap: limit reached — 5-hour quota at 13%, stop point 12%" in out["reason"]
154
+ assert "`agentcap approve` (+50%)" in out["reason"]
155
+ assert "`agentcap <N%> 5h`" in out["reason"] and "`agentcap off`" in out["reason"]
156
+
157
+
158
+ def test_codex_typed_commands_still_work_over_the_limit(env):
159
+ cx_at_limit(env)
160
+ assert "agentcap commands" in cx_prompt("agentcap help")["reason"]
161
+ assert "stops at 12%" in cx_prompt("agentcap status")["reason"]
162
+ cleared = cx_prompt("agentcap off")
163
+ assert cleared["decision"] == "block" and "cleared" in cleared["reason"]
164
+ assert cx_prompt("carry on") is None # the limit is gone
165
+
166
+
167
+ def test_codex_under_the_limit_passes(env):
168
+ pro(env)
169
+ cx_prompt("agentcap 5% 5h")
170
+ cx._atomic_write(cx.live_path(CX_SID), {"ts": 9e12, "readings": {"5h": {"used": 13.0, "resets_at": R5}}})
171
+ assert cx_prompt("carry on") is None
172
+
173
+
174
+ def test_codex_free_tier_never_blocks_a_prompt(env):
175
+ cx_prompt("agentcap 2% 5h")
176
+ cx._atomic_write(cx.live_path(CX_SID), {"ts": 9e12, "readings": {"5h": {"used": 13.0, "resets_at": R5}}})
177
+ assert cx_prompt("carry on") is None
178
+
179
+
180
+ def test_codex_without_a_quota_passes(env):
181
+ pro(env)
182
+ assert cx_prompt("carry on") is None
183
+
184
+
185
+ # ------------------------------------------------------------------ %1 / until %70
186
+ def test_a_leading_percent_is_the_same_limit():
187
+ assert parse_quota("%1") == parse_quota("1%") == 1.0
188
+ assert parse_quota(" %50 ") == 50.0
189
+ assert parse_limit_words(["%1", "5h"]) == parse_limit_words(["1%", "5h"]) == (1.0, "5h", False)
190
+ assert parse_limit_words(["until", "%70", "week"]) == \
191
+ parse_limit_words(["until", "70%", "week"]) == (70.0, "week", True)
192
+ assert parse_limit_words(["%50", "week"]) == parse_limit_words(["50%", "week"]) == (50.0, "week", False)
193
+ assert parse_agent_set("echo agentcap set %50 5h") == parse_agent_set("echo agentcap set 50% 5h")
194
+
195
+
196
+ def test_leading_percent_works_in_the_commands(env):
197
+ pro(env)
198
+ cc_statusline(40.0)
199
+ assert "5-hour" in cc_cmd("quota", "%2", "5h")
200
+ assert json.loads(cc.session_path(CC_SID).read_text())["quota"] == 2.0
201
+ assert "stops at 70% of the weekly quota" in cc_cmd("quota", "until", "%70", "week")
202
+
203
+ assert "2 more points of the 5-hour quota" in cx_prompt("agentcap %2 5h")["reason"]
204
+ assert "stops at 70% of the weekly quota" in cx_prompt("agentcap until %70 week")["reason"]
205
+
206
+
207
+ def test_a_bad_limit_message_is_whole(env):
208
+ with pytest.raises(ValueError) as excinfo:
209
+ parse_limit_words(["lots", "5h"])
210
+ assert str(excinfo.value) == "a limit looks like 50% or until 70% (got 'lots')"
211
+ assert "a limit looks like 50% or until 70% (got 'lots')" in cc_cmd("quota", "lots")
212
+ assert "a limit looks like 50% or until 70% (got 'lots')" in cx_prompt("agentcap lots")["reason"]
213
+
214
+
215
+ # ------------------------------------------------------------------ wiring
216
+ def test_claude_hooks_json_registers_the_prompt_hook():
217
+ hooks = json.loads((ROOT / "hooks" / "hooks.json").read_text())["hooks"]
218
+ command = hooks["UserPromptSubmit"][0]["hooks"][0]["command"]
219
+ assert command.endswith('agentcap_cc.py" hook prompt')
File without changes
File without changes