llmswap-cli 1.0.0__tar.gz → 1.0.2__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.
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/PKG-INFO +1 -1
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/warm-up.md +1 -1
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/pyproject.toml +1 -1
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/__init__.py +1 -1
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/providers/claude.py +5 -3
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/warm/plan.py +7 -3
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_claude_provider.py +10 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_warm_plan.py +9 -5
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/uv.lock +1 -1
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.github/FUNDING.yml +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.github/pull_request_template.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.github/workflows/ci.yml +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.github/workflows/publish.yml +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.gitignore +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.python-version +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/.vscode/launch.json +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/AGENTS.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/CONTRIBUTING.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/LICENSE +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/README.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/assets/banner.png +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/assets/cswap-list.png +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/assets/tui-watch.png +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/architecture.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/auto-switch.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/claude-code.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/feature-map.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/img/dashboard.svg +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/img/list.svg +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/json-output.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/menubar.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/providers.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/docs/session-mode.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/__init__.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/__main__.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/app_bundle.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/appearance.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/autoswitch.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/cache.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/claude_locks.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/cli.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/credentials.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/exceptions.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/fsutil.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/json_output.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/launch_agent.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/lines.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/list_view.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/locking.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/logging_config.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/macos_keychain.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/mappings.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/menubar.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/migrations.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/models.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/oauth.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/pace.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/paths.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/poll_policy.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/printer.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/process_detection.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/session.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/settings.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/signin.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/snapshot_source.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/spawn.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/subscription.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/switcher.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/transfer.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/__init__.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/app.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/autoview.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/cswap.tcss +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/dashboard.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/data.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/modals.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/theme.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/tui/widgets.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/update_check.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/usage_bars.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/usage_rows.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/claude_swap/usage_store.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/AGENTS.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/__main__.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/cli.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/config.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/httpjson.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/jwt.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/menubar.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/model.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/paths.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/providers/AGENTS.md +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/providers/base.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/providers/codex.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/providers/gemini.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/providers/registry.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/render.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/rotate.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/store.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/tui.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/usage_cache.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/warm/runner.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/src/llmswap/warm/schedule.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/__init__.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/conftest.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/fixtures/sample_config.json +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/__init__.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/conftest.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_codex_provider.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_credential_safety.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_gemini_provider.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_rotate.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_schedule.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_tui_and_cli.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/llmswap/test_warm_runner.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_account_policy_cli.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_account_policy_store.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_account_policy_stray_standby_key.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_account_policy_values.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_add_account_identity.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_api_key_accounts.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_app_bundle.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_appearance.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_autoswitch.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_autoswitch_account_threshold.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_autoswitch_landing_room.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_backup_read_pacing.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_cache.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_claude_locks.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_cli.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_colour_cache_isolation.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_config_cli.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_credentials.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_fsutil.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_home_isolation.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_json_output.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_launch_agent.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_lines.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_list_view.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_locking.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_logging_config.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_login_account.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_login_expiry.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_macos_keychain.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_macos_keychain_contract.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_mappings.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_menubar.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_migrations.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_move_accounts.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_network_guard.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_oauth.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_oauth_weekly_only.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_pace.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_paths.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_poll_policy.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_printer.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_priority_strategy.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_process_detection.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_real_store_guard.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_session.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_settings.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_signin.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_spawn.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_subscription.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_swap_accounts.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_switcher.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_theme.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_transfer.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_tui.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_tui_policy_display.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_update_check.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_usage_bars.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_usage_store.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_weekly_only_strategies.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tests/test_worker_gc_freeze.py +0 -0
- {llmswap_cli-1.0.0 → llmswap_cli-1.0.2}/tools/screenshots.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: llmswap-cli
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: One account switcher for Claude Code, Codex and Gemini CLI: usage, rotation before limits, and warm-up pings
|
|
5
5
|
Project-URL: Homepage, https://github.com/richard7ao/llmswap
|
|
6
6
|
Project-URL: Repository, https://github.com/richard7ao/llmswap
|
|
@@ -14,7 +14,7 @@ A 5-hour window starts at an account's first request and resets exactly five hou
|
|
|
14
14
|
2. It is an OAuth login (API keys have no window) and the provider reports a 5-hour window.
|
|
15
15
|
3. Its weekly window is not full.
|
|
16
16
|
4. Its 5-hour window is cold, confirmed by a fresh usage read just before the ping.
|
|
17
|
-
5. The usage reading is at most 15 minutes old and has no error, and a cold window is confirmed with a fresh read just before the ping. (
|
|
17
|
+
5. The usage reading is at most 15 minutes old and has no error, and a cold window is confirmed with a fresh read just before the ping. (A Claude account whose response omits the 5-hour window, or a Codex window reported at 0% with a reset a full window away, counts as cold. A Codex plan that reports only a weekly window has no 5-hour window to warm and is skipped; a Codex Business plan did exactly that on 5 Dec 2026.)
|
|
18
18
|
6. It is outside quiet hours, and past the account's `--earliest` time if one is set.
|
|
19
19
|
7. It was not pinged within the last 20 minutes, and the reading is not older than our own last ping (an old reading cannot show the window that ping started).
|
|
20
20
|
8. It is not waiting out a failure: after a failed ping the account is retried after 5, 10, 20 ... minutes, at most 2 hours.
|
|
@@ -6,8 +6,10 @@ mode). This adapter only maps it onto the provider interface. Claude accounts
|
|
|
6
6
|
live in claude-swap's backup root, so an existing claude-swap install's
|
|
7
7
|
accounts show up here unchanged.
|
|
8
8
|
|
|
9
|
-
Usage windows are
|
|
10
|
-
|
|
9
|
+
Usage windows are the ``five_hour`` and ``seven_day`` entries of a stored
|
|
10
|
+
``UsageEntry.last_good``: ``pct`` 0-100 and an ISO ``resets_at`` (seen in claude-swap
|
|
11
|
+
1.4.0 on a live account). ``utilization`` is accepted too, the key of Anthropic's raw
|
|
12
|
+
usage response.
|
|
11
13
|
"""
|
|
12
14
|
|
|
13
15
|
from __future__ import annotations
|
|
@@ -41,7 +43,7 @@ def windows_from_usage(usage: dict | None) -> tuple[Window, ...]:
|
|
|
41
43
|
w = usage.get(key)
|
|
42
44
|
if not isinstance(w, dict):
|
|
43
45
|
continue
|
|
44
|
-
util = w.get("utilization")
|
|
46
|
+
util = w.get("pct", w.get("utilization"))
|
|
45
47
|
out.append(
|
|
46
48
|
Window(
|
|
47
49
|
key=short,
|
|
@@ -79,11 +79,15 @@ def decide(
|
|
|
79
79
|
window = view.usage.window("5h")
|
|
80
80
|
weekly = view.usage.window("7d")
|
|
81
81
|
if window is None:
|
|
82
|
-
# An idle account's response may omit the 5-hour window entirely. With a
|
|
83
|
-
# weekly window present the reading itself is sound, so a missing 5-hour
|
|
84
|
-
# window means none is running; with nothing at all there is no reading.
|
|
85
82
|
if weekly is None:
|
|
86
83
|
return Decision(False, "no usage windows reported for this account")
|
|
84
|
+
if view.provider != "claude":
|
|
85
|
+
# Codex reports a window it has not started as 0% used, so an absent
|
|
86
|
+
# 5-hour window is a plan without one (measured 5 Dec 2026: a Codex
|
|
87
|
+
# business plan returned a single 604800 s window and no other).
|
|
88
|
+
return Decision(False, "this plan has no 5-hour window to warm")
|
|
89
|
+
# Claude omits the 5-hour window while none is running. With a weekly
|
|
90
|
+
# window present the reading itself is sound, so none is running.
|
|
87
91
|
window = Window("5h", 0.0, None, FIVE_HOUR_S)
|
|
88
92
|
if weekly is not None and weekly.running(t) and (weekly.used_pct or 0) >= WEEKLY_FULL_PCT:
|
|
89
93
|
return Decision(False, "weekly limit reached", weekly.resets_at)
|
|
@@ -23,6 +23,16 @@ def test_usage_dict_becomes_five_hour_and_weekly_windows():
|
|
|
23
23
|
assert claude_mod.windows_from_usage(None) == ()
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
def test_stored_last_good_shape_uses_pct():
|
|
27
|
+
"""The shape claude-swap 1.4.0 stores on a live account: ``pct``, plus scoped windows we ignore."""
|
|
28
|
+
usage = {
|
|
29
|
+
"seven_day": {"pct": 87.0, "resets_at": iso(3600), "countdown": "1h", "clock": "x"},
|
|
30
|
+
"scoped": [{"name": "Fable", "pct": 8.0, "resets_at": iso(3600)}],
|
|
31
|
+
}
|
|
32
|
+
(week,) = claude_mod.windows_from_usage(usage)
|
|
33
|
+
assert (week.key, week.used_pct) == ("7d", 87.0)
|
|
34
|
+
|
|
35
|
+
|
|
26
36
|
def test_saved_account_shows_up_through_the_provider(temp_home, mock_claude_config, mock_credentials_file):
|
|
27
37
|
p = ClaudeProvider()
|
|
28
38
|
view = p.add()
|
|
@@ -49,11 +49,6 @@ def test_no_windows_at_all_means_no_reading_so_no_ping():
|
|
|
49
49
|
assert not plan.decide(view(five=False), ON, CFG, NOW).ping
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def test_an_idle_account_whose_response_omits_the_five_hour_window_is_cold():
|
|
53
|
-
d = plan.decide(view(five=False, week=Window("7d", 4.0, T + 86400, 604800)), ON, CFG, NOW)
|
|
54
|
-
assert d.ping
|
|
55
|
-
|
|
56
|
-
|
|
57
52
|
def test_full_weekly_window_is_skipped():
|
|
58
53
|
d = plan.decide(view(week=Window("7d", 100.0, T + 86400, 604800)), ON, CFG, NOW)
|
|
59
54
|
assert not d.ping and d.reason == "weekly limit reached"
|
|
@@ -94,3 +89,12 @@ def test_failures_back_off_with_growing_delay():
|
|
|
94
89
|
d = plan.decide(view(), ON, CFG, NOW, fail_count=2, last_attempt=T - 100)
|
|
95
90
|
assert not d.ping and d.look_again_at == T - 100 + 600
|
|
96
91
|
assert plan.decide(view(), ON, CFG, NOW, fail_count=2, last_attempt=T - 700).ping
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_missing_five_hour_window_is_cold_for_claude_but_a_planless_window_for_codex():
|
|
95
|
+
week = Window("7d", 4.0, T + 86400, 604800)
|
|
96
|
+
claude = view(five=False, week=week)
|
|
97
|
+
claude = AccountView("claude", "1", "a@x.io", usage=claude.usage)
|
|
98
|
+
assert plan.decide(claude, ON, CFG, NOW).ping
|
|
99
|
+
d = plan.decide(view(five=False, week=week), ON, CFG, NOW)
|
|
100
|
+
assert not d.ping and "no 5-hour window" in d.reason
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|