utim-cli 2.6.5__tar.gz → 2.6.6__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 (238) hide show
  1. {utim_cli-2.6.5 → utim_cli-2.6.6}/CHANGELOG.md +9 -0
  2. {utim_cli-2.6.5/utim_cli.egg-info → utim_cli-2.6.6}/PKG-INFO +1 -1
  3. {utim_cli-2.6.5 → utim_cli-2.6.6}/pyproject.toml +1 -1
  4. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim/__init__.py +1 -1
  5. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/__init__.py +1 -1
  6. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/_version.py +1 -1
  7. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/auth.py +79 -4
  8. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/quota_bank.py +4 -2
  9. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/completion_routes.py +228 -36
  10. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/quota_routes.py +96 -28
  11. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/utim.py +42 -5
  12. {utim_cli-2.6.5 → utim_cli-2.6.6/utim_cli.egg-info}/PKG-INFO +1 -1
  13. {utim_cli-2.6.5 → utim_cli-2.6.6}/LICENSE +0 -0
  14. {utim_cli-2.6.5 → utim_cli-2.6.6}/MANIFEST.in +0 -0
  15. {utim_cli-2.6.5 → utim_cli-2.6.6}/README.md +0 -0
  16. {utim_cli-2.6.5 → utim_cli-2.6.6}/setup.cfg +0 -0
  17. {utim_cli-2.6.5 → utim_cli-2.6.6}/setup.py +0 -0
  18. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/_chip_test.py +0 -0
  19. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/_verify_repro.py +0 -0
  20. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/_verify_spinner_ignore.py +0 -0
  21. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/_verify_syntax.py +0 -0
  22. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/_wizard_smoke_test.py +0 -0
  23. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/adaptation_engine.py +0 -0
  24. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/agent.py +0 -0
  25. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/architecture_indexer.py +0 -0
  26. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/ask_helper.py +0 -0
  27. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/auth.py +0 -0
  28. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/background_models.py +0 -0
  29. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/backup.py +0 -0
  30. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/behavior_telemetry.py +0 -0
  31. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/billing.py +0 -0
  32. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/blender_agent.py +0 -0
  33. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/bootstrap.py +0 -0
  34. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/brain.py +0 -0
  35. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/builtin/skills/utim-guide/SKILL.md +0 -0
  36. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/client_utils.py +0 -0
  37. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/config.py +0 -0
  38. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/constants.py +0 -0
  39. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/context_inspector.py +0 -0
  40. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/context_pruner.py +0 -0
  41. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/crawler/__init__.py +0 -0
  42. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/crawler/engine.py +0 -0
  43. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/crawler/markdown_distiller.py +0 -0
  44. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/dependency_manager.py +0 -0
  45. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/design_studio.py +0 -0
  46. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/doctor.py +0 -0
  47. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/evidence_registry.py +0 -0
  48. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/harbor.py +0 -0
  49. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/knowledge_graph.py +0 -0
  50. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/local_db.py +0 -0
  51. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/logger.py +0 -0
  52. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/mcp_clean_wrapper.py +0 -0
  53. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/mcp_client.py +0 -0
  54. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/mcp_registry.json +0 -0
  55. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/models.txt +0 -0
  56. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/motion_audio.py +0 -0
  57. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/motion_bridge.py +0 -0
  58. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/motion_graphics.py +0 -0
  59. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/orchestrator.py +0 -0
  60. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/orchestrator_helpers.py +0 -0
  61. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/orchestrator_llm_transport.py +0 -0
  62. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/orchestrator_tool_exec.py +0 -0
  63. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/orchestrator_turn_history.py +0 -0
  64. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/personalities.py +0 -0
  65. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/platform_installer.py +0 -0
  66. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/__init__.py +0 -0
  67. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/hooks.py +0 -0
  68. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/loader.py +0 -0
  69. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/manager.py +0 -0
  70. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/registry.py +0 -0
  71. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/runtime.py +0 -0
  72. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/schema.py +0 -0
  73. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/plugins/tool_loader.py +0 -0
  74. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/reflection.py +0 -0
  75. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/report.py +0 -0
  76. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/scrapy_search.py +0 -0
  77. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/sdk/__init__.py +0 -0
  78. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/sdk/config.py +0 -0
  79. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/sdk/context.py +0 -0
  80. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/sdk/events.py +0 -0
  81. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/sdk/handlers.py +0 -0
  82. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/sdk/session.py +0 -0
  83. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/sdk/sidecar.py +0 -0
  84. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/__init__.py +0 -0
  85. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/admin_auth.py +0 -0
  86. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/api_models_db.py +0 -0
  87. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/api_request_logs.py +0 -0
  88. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/attribution.py +0 -0
  89. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/audit_log.py +0 -0
  90. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/batch_processor.py +0 -0
  91. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/bonus_ledger.py +0 -0
  92. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/bot_detection.py +0 -0
  93. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/captcha.py +0 -0
  94. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/cli_auth.py +0 -0
  95. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/concurrency.py +0 -0
  96. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/crypto_utils.py +0 -0
  97. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/db.py +0 -0
  98. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/discord_verification.py +0 -0
  99. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/disposable_email_guard.py +0 -0
  100. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/SECRET_PROVISIONING.md +0 -0
  101. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/about.md +0 -0
  102. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/changelog.md +0 -0
  103. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/docs.md +0 -0
  104. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/features.md +0 -0
  105. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/license.md +0 -0
  106. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/pricing.md +0 -0
  107. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/privacy.md +0 -0
  108. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/refund.md +0 -0
  109. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/support.md +0 -0
  110. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/docs_md/terms.md +0 -0
  111. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/email_utils.py +0 -0
  112. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/exchange_rate.py +0 -0
  113. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/field_crypto.py +0 -0
  114. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/firebase.py +0 -0
  115. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/firewall.py +0 -0
  116. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/fix_duplicate_users.py +0 -0
  117. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/history.py +0 -0
  118. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/hobby_throttler.py +0 -0
  119. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/key_rotator.py +0 -0
  120. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/local_llm.py +0 -0
  121. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/logging_config.py +0 -0
  122. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/maintenance.py +0 -0
  123. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/model_agent.py +0 -0
  124. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/models.py +0 -0
  125. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/plan_integrity.py +0 -0
  126. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/platform_billing.py +0 -0
  127. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/pricing_updater.py +0 -0
  128. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/provider_balance.py +0 -0
  129. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/provider_batcher.py +0 -0
  130. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/provider_discovery.py +0 -0
  131. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/provider_router.py +0 -0
  132. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/provision_build.py +0 -0
  133. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/purge_disposable_users.py +0 -0
  134. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/rate_limit.py +0 -0
  135. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/request_batcher.py +0 -0
  136. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/request_queue.py +0 -0
  137. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/rewards_engine.py +0 -0
  138. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/router.py +0 -0
  139. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/__init__.py +0 -0
  140. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/account_verification_routes.py +0 -0
  141. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/activity_routes.py +0 -0
  142. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/admin_bonus_routes.py +0 -0
  143. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/admin_db_routes.py +0 -0
  144. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/admin_providers_routes.py +0 -0
  145. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/admin_separated_models_routes.py +0 -0
  146. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/api_gateway_extensions_routes.py +0 -0
  147. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/api_key_routes.py +0 -0
  148. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/api_models_admin_routes.py +0 -0
  149. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/api_models_public_routes.py +0 -0
  150. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/auth_routes.py +0 -0
  151. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/billing_routes.py +0 -0
  152. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/compression_routes.py +0 -0
  153. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/credit_routes.py +0 -0
  154. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/design_routes.py +0 -0
  155. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/feedback_routes.py +0 -0
  156. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/marketplace_routes.py +0 -0
  157. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/provider_compat_routes.py +0 -0
  158. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/quota_share_routes.py +0 -0
  159. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/referral_routes.py +0 -0
  160. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/rewards_routes.py +0 -0
  161. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/security_routes.py +0 -0
  162. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/session_routes.py +0 -0
  163. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/share_routes.py +0 -0
  164. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/wallet_routes.py +0 -0
  165. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/routes/webhook_routes.py +0 -0
  166. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/scripts/__init__.py +0 -0
  167. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/scripts/vault_ops.py +0 -0
  168. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/security_alerts.py +0 -0
  169. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/server.py +0 -0
  170. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/signup_guard.py +0 -0
  171. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/storage_nodes.py +0 -0
  172. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/tier_tables.py +0 -0
  173. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/uptime_monitor.py +0 -0
  174. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/utils.py +0 -0
  175. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/server/vault.py +0 -0
  176. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/share.py +0 -0
  177. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/share_tui.py +0 -0
  178. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/situational_scoring.py +0 -0
  179. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/skill_router.py +0 -0
  180. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/state.py +0 -0
  181. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/subagent_manager.py +0 -0
  182. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/syntax_fix.py +0 -0
  183. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/task_dispatcher.py +0 -0
  184. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/task_logger.py +0 -0
  185. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tests_quota_bank_scratch.py +0 -0
  186. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tools.py +0 -0
  187. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tools_grep.py +0 -0
  188. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/__init__.py +0 -0
  189. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/compression_dialog.py +0 -0
  190. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/feedback_dialog.py +0 -0
  191. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/history_dialog.py +0 -0
  192. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/marketplace_app_state.py +0 -0
  193. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/marketplace_dialog.py +0 -0
  194. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/marketplace_layout_engine.py +0 -0
  195. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/mcp_dialog.py +0 -0
  196. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/miniagents_dialog.py +0 -0
  197. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/model_dialog.py +0 -0
  198. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/personality_dialog.py +0 -0
  199. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/plugins_dialog.py +0 -0
  200. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/publish_dialog.py +0 -0
  201. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/quota_dialog.py +0 -0
  202. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/quota_redeem_dialog.py +0 -0
  203. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/quota_share_dialog.py +0 -0
  204. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/resume_dialog.py +0 -0
  205. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/rewards_tui.py +0 -0
  206. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/skills_dialog.py +0 -0
  207. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/spinner.py +0 -0
  208. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/stream_diagnostics.py +0 -0
  209. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/subagents_dialog.py +0 -0
  210. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/tasks_dialog.py +0 -0
  211. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/thinking_display.py +0 -0
  212. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/thinking_phrases.py +0 -0
  213. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/token_meter.py +0 -0
  214. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/tool_theme_preview.py +0 -0
  215. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/tool_themes.py +0 -0
  216. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/tools_dialog.py +0 -0
  217. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/update_dialog.py +0 -0
  218. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/tui/verbosity_dialog.py +0 -0
  219. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/update_checker.py +0 -0
  220. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/utilities.py +0 -0
  221. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/utimmodel.txt +0 -0
  222. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/vector_memory.py +0 -0
  223. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice.py +0 -0
  224. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_coding.py +0 -0
  225. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_events.py +0 -0
  226. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_handler.py +0 -0
  227. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_instant.py +0 -0
  228. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_orchestrator.py +0 -0
  229. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_session.py +0 -0
  230. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_stt.py +0 -0
  231. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/voice_tts.py +0 -0
  232. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/wheel.py +0 -0
  233. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli/workspace.py +0 -0
  234. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli.egg-info/SOURCES.txt +0 -0
  235. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli.egg-info/dependency_links.txt +0 -0
  236. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli.egg-info/entry_points.txt +0 -0
  237. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli.egg-info/requires.txt +0 -0
  238. {utim_cli-2.6.5 → utim_cli-2.6.6}/utim_cli.egg-info/top_level.txt +0 -0
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.6.6] - 2026-11-11
4
+
5
+ ### 🐛 Minor Bug Fixes
6
+ - **Fixed Some UI Bugs**: Corrected several display issues in the usage dialog and website surfaces.
7
+ - The free-tier usage dialog no longer reports `Exhausted` / `Monthly quota EXHAUSTED` for accounts that still hold their full 15,000-credit allowance. A free-plan account is now detected from `plan_id` as well as `plan_name`, so a stale or duplicate subscription row can no longer push a free user down the paid render branch.
8
+ - The `This Month` footer now derives its progress bar and remaining figure from the server's authoritative `free_monthly_used` / `free_monthly_remaining` values instead of subtracting raw local token counts from a credit-denominated cap, which had forced the bar to `0 tokens remaining of 15K` for every account.
9
+ - `/api/usage` now emits real free-pool figures for any free-plan account rather than zeroing them when `is_subscribed` was set, and floors the reported remaining balance at the stored credit balance so a live allowance can never display as drained.
10
+ - Removed the misleading `10x paid-tier discount` and fixed token-allowance copy from the pricing table, pricing notes, model registry, bento grid, and legal pages, aligning them with the credit-based metering model.
11
+
3
12
  ## [2.6.5] - 2026-11-11
4
13
 
5
14
  ### 🐛 Minor Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: utim-cli
3
- Version: 2.6.5
3
+ Version: 2.6.6
4
4
  Summary: UTIM – Universal Terminal Intelligence Manager. A powerful agentic AI coding assistant for your terminal.
5
5
  License: Emend AI Proprietary EULA
6
6
  Project-URL: Homepage, https://utim.dev
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "utim-cli"
7
- version = "2.6.5"
7
+ version = "2.6.6"
8
8
 
9
9
  description = "UTIM – Universal Terminal Intelligence Manager. A powerful agentic AI coding assistant for your terminal."
10
10
  readme = "README.md"
@@ -14,7 +14,7 @@ Quickstart:
14
14
  try:
15
15
  from utim_cli._version import VERSION as __version__
16
16
  except ImportError:
17
- __version__ = "2.6.5"
17
+ __version__ = "2.6.6"
18
18
 
19
19
  # Developer-friendly core classes (similar to `import genai` / `import openai`)
20
20
  from utim_cli.sdk.session import UtimSession as Session
@@ -5,7 +5,7 @@ try:
5
5
  from utim_cli._version import VERSION as __version__
6
6
  except ImportError:
7
7
  # Fallback during first-install / editable-install edge cases
8
- __version__ = "2.6.5"
8
+ __version__ = "2.6.6"
9
9
 
10
10
 
11
11
  import builtins, os, pathlib, urllib.parse, re
@@ -11,6 +11,6 @@
11
11
  # from here so every surface stays in sync automatically.
12
12
  # ─────────────────────────────────────────────────────────────────────────────
13
13
 
14
- VERSION = "2.6.5"
14
+ VERSION = "2.6.6"
15
15
 
16
16
 
@@ -254,9 +254,17 @@ def process_user_refills(db: Session, user_id: str, now: Optional[datetime.datet
254
254
  ).first()
255
255
  if not quota:
256
256
  quota = db.query(QuotaUsage).filter(QuotaUsage.user_id == user_id).order_by(QuotaUsage.period_end.desc()).first()
257
- if quota and quota.credits_limit != 15000:
258
- quota.credits_limit = 15000
259
- db.commit()
257
+ if quota:
258
+ if quota.credits_limit != 15000:
259
+ quota.credits_limit = 15000
260
+ db.commit()
261
+ # Sync quota.credits_used with free_monthly_used so the gate
262
+ # never fires a false "exhausted" when the authoritative counter
263
+ # says the user still has credits remaining.
264
+ free_used = float(getattr(credit_row, "free_monthly_used", 0.0) or 0.0) if credit_row else 0.0
265
+ if abs(float(quota.credits_used or 0.0) - free_used) > 1.0:
266
+ quota.credits_used = free_used
267
+ db.commit()
260
268
  return
261
269
 
262
270
 
@@ -389,12 +397,79 @@ async def get_current_user(
389
397
  # User.api_key is EncryptedString; Fernet is randomised so
390
398
  # ``User.api_key == token`` encrypts the bind value to a fresh token
391
399
  # that matches nothing and fails SILENTLY (returns no row, no error).
400
+ #
401
+ # ROTATION-SAFE LOOKUP: probe ALL candidate blind indexes (one per
402
+ # ever-configured master secret) so a key-rotation never 401s a valid
403
+ # CLI user whose api_key_bidx was sealed under the previous secret.
404
+ _bidx_candidates = [blind_index(token, "api_key")]
405
+ try:
406
+ from .vault import blind_index_exact_candidates as _bi_cands
407
+ _bidx_candidates.extend(_bi_cands(token))
408
+ except Exception:
409
+ pass
410
+ _bidx_candidates = [c for c in dict.fromkeys(_bidx_candidates) if c]
411
+
392
412
  user = db.query(User).filter(
393
- User.api_key_bidx == blind_index(token, "api_key"),
413
+ User.api_key_bidx.in_(_bidx_candidates),
394
414
  User.is_active == True,
395
415
  ).first()
396
416
  if user:
417
+ # Self-heal: rewrite bidx with the current secret on mismatch.
418
+ try:
419
+ _current_bidx = blind_index(token, "api_key")
420
+ if user.api_key_bidx != _current_bidx:
421
+ _conflict = (
422
+ db.query(User.id)
423
+ .filter(User.api_key_bidx == _current_bidx, User.id != user.id)
424
+ .first()
425
+ )
426
+ if not _conflict:
427
+ user.api_key_bidx = _current_bidx
428
+ db.commit()
429
+ logger.info(
430
+ "api_key_bidx re-sealed (get_current_user) for user %s", user.id
431
+ )
432
+ except Exception as _reseal_err:
433
+ db.rollback()
434
+ logger.debug("api_key_bidx re-seal skipped: %s", _reseal_err)
397
435
  return user
436
+
437
+ # ── Plaintext fallback: bidx may be NULL or stale for rows written
438
+ # before the current master secret existed. Compare directly against
439
+ # the decrypted api_key (or plaintext when encryption is off).
440
+ try:
441
+ _rows = (
442
+ db.query(User)
443
+ .filter(User.api_key.isnot(None), User.is_active == True)
444
+ .all()
445
+ )
446
+ for _row in _rows:
447
+ _stored = getattr(_row, "api_key", None)
448
+ if not _stored:
449
+ continue
450
+ if hmac.compare_digest(str(_stored), str(token)):
451
+ logger.warning(
452
+ "auth_plaintext_fallback hit for user %s — api_key_bidx "
453
+ "was unverifiable under every configured master secret",
454
+ _row.id,
455
+ )
456
+ # Self-heal: seal the bidx so the fast path works next time.
457
+ try:
458
+ _current_bidx = blind_index(token, "api_key")
459
+ _conflict = (
460
+ db.query(User.id)
461
+ .filter(User.api_key_bidx == _current_bidx, User.id != _row.id)
462
+ .first()
463
+ )
464
+ if not _conflict:
465
+ _row.api_key_bidx = _current_bidx
466
+ db.commit()
467
+ except Exception:
468
+ db.rollback()
469
+ return _row
470
+ except Exception as _pt_err:
471
+ logger.error("plaintext api_key fallback failed: %s", _pt_err)
472
+
398
473
  # Check user-created API keys
399
474
  from .db import UserApiKey
400
475
  api_key = db.query(UserApiKey).filter(
@@ -432,12 +432,14 @@ def spend_quota_bank(
432
432
  remaining -= from_bank
433
433
  credit.quota_bank_credits = banked_total(db, user_id)
434
434
 
435
- if from_bank > 0.0 or from_bonus > 0.0 or from_week > 0.0:
435
+ total_charged = from_week + from_bank + from_bonus
436
+ if total_charged > 0.0:
437
+ credit.total_spent = float(getattr(credit, "total_spent", 0.0) or 0.0) + total_charged
436
438
  db.add(Transaction(
437
439
  id=str(uuid.uuid4()),
438
440
  user_id=user_id,
439
441
  kind="deduction",
440
- amount=-cost,
442
+ amount=-total_charged,
441
443
  balance_after=float(credit.balance or 0.0),
442
444
  description=(
443
445
  f"Usage: {cost:.1f} credits "
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
 
6
6
  import asyncio
7
7
  import json
8
+ import math
8
9
  import logging
9
10
  import os
10
11
  import uuid
@@ -916,10 +917,12 @@ FREE_TIER_MONTHLY_TOKEN_POOL = 15_000.0
916
917
  #: this for new gating logic — reference FREE_TIER_MONTHLY_TOKEN_POOL instead.
917
918
  FREE_TIER_DAILY_TOKEN_ALLOWANCE = FREE_TIER_MONTHLY_TOKEN_POOL
918
919
 
919
- #: Fallback baseline (USD per 1M tokens) used when no free model has a price
920
- #: configured. With this baseline a model priced at $0.50/1M consumes half a
921
- #: pool token per token used.
922
- FREE_TIER_BASELINE_PRICE_PER_1M = 0.10
920
+ #: DEPRECATED — do not use. Prices must be read from the `free_models` table.
921
+ #: This constant (formerly 0.10 USD/1M) fabricated a baseline whenever the
922
+ #: table had no priced rows, which silently rescaled every free-tier
923
+ #: deduction. Retained only so stale imports do not raise ImportError; it is
924
+ #: never consulted by the pricing path. Use get_free_tier_baseline_price().
925
+ FREE_TIER_BASELINE_PRICE_PER_1M = 0.0
923
926
 
924
927
  # Cache of ``model_id -> (cost_input_per_1m, cost_output_per_1m)`` for free models.
925
928
  _FREE_TIER_PRICING_CACHE: Dict[str, Tuple[float, float]] = {}
@@ -955,9 +958,17 @@ def _read_free_tier_pricing_table(db: Optional[Session] = None) -> Dict[str, Tup
955
958
 
956
959
  try:
957
960
  try:
961
+ # NOTE: `is_active` is nullable and seeded rows frequently leave it
962
+ # NULL. The free-model gate (is_free_or_gateway_model) accepts
963
+ # NULL, so this reader MUST as well — otherwise a model that the
964
+ # gate recognises as free reads back as "unpriced" here, and its
965
+ # usage escapes deduction. Keep these two predicates in sync.
958
966
  rows = (
959
967
  session.query(FreeModelDB)
960
- .filter(FreeModelDB.is_active == True) # noqa: E712
968
+ .filter(
969
+ (FreeModelDB.is_active == True) # noqa: E712
970
+ | (FreeModelDB.is_active.is_(None))
971
+ )
961
972
  .all()
962
973
  )
963
974
  except Exception:
@@ -981,17 +992,58 @@ def _read_free_tier_pricing_table(db: Optional[Session] = None) -> Dict[str, Tup
981
992
  return out
982
993
 
983
994
 
995
+ def _resolve_free_model_key(model_id: str, table: Dict[str, Tuple[float, float]]) -> Optional[str]:
996
+ """Resolve a request model ID onto a key present in the ``free_models`` table.
997
+
998
+ The requested ID and the ID stored in ``free_models`` routinely differ:
999
+ callers send ``utim/minimax-m3.1-flash`` while the row may be keyed
1000
+ ``minimax-m3.1-flash``, and free slugs carry a ``:free`` suffix. Without
1001
+ this tolerance the lookup misses and the caller is charged a made-up
1002
+ price instead of the real one from the table.
1003
+ """
1004
+ if not model_id or not table:
1005
+ return None
1006
+
1007
+ candidate = model_id.strip()
1008
+ # 1. Exact hit.
1009
+ if candidate in table:
1010
+ return candidate
1011
+
1012
+ # 2. Strip a ``:free`` / ``:beta`` style flavour suffix.
1013
+ stripped = candidate.split(":", 1)[0]
1014
+ if stripped in table:
1015
+ return stripped
1016
+
1017
+ # 3. Drop a leading provider namespace (``utim/``, ``openrouter/``, ...).
1018
+ if "/" in stripped:
1019
+ tail = stripped.split("/", 1)[1]
1020
+ if tail in table:
1021
+ return tail
1022
+
1023
+ # 4. Case-insensitive / dot-vs-dash tolerant comparison.
1024
+ def _norm(s: str) -> str:
1025
+ return s.strip().lower().replace(".", "-").replace("_", "-")
1026
+
1027
+ want = _norm(stripped.split("/")[-1])
1028
+ for key in table:
1029
+ if _norm(key.split("/")[-1]) == want:
1030
+ return key
1031
+
1032
+ return None
1033
+
1034
+
984
1035
  def get_free_tier_model_pricing(
985
1036
  model_id: str,
986
1037
  db: Optional[Session] = None,
987
1038
  ) -> Tuple[float, float]:
988
1039
  """Return ``(cost_input_per_1m, cost_output_per_1m)`` for a free-tier model.
989
1040
 
990
- Looks the model up in the ``free_models`` DB table first. When the model is
991
- not registered there (e.g. a hardcoded ``:free`` slug such as
992
- ``nvidia/nemotron-3.5-lightning:free``) the generic API-model pricing table
993
- is consulted as a fallback. Unknown models resolve to ``(0.0, 0.0)``, which
994
- means "consume exactly the tokens you used".
1041
+ Pricing is read from the ``free_models`` DB table, which is the single
1042
+ source of truth for free-tier model cost. When the model is not registered
1043
+ there, the generic API-model pricing table is consulted as a fallback.
1044
+ Unknown models resolve to ``(0.0, 0.0)`` and the caller MUST treat that as
1045
+ "pricing unknown", never as "this model is free" — see the baseline
1046
+ fallback applied in the billing path.
995
1047
  """
996
1048
  global _FREE_TIER_PRICING_CACHE, _FREE_TIER_PRICING_CACHE_TS
997
1049
 
@@ -1008,10 +1060,20 @@ def get_free_tier_model_pricing(
1008
1060
  _FREE_TIER_PRICING_CACHE = {}
1009
1061
  _FREE_TIER_PRICING_CACHE_TS = now
1010
1062
 
1011
- cached = _FREE_TIER_PRICING_CACHE.get(model_id)
1012
- if cached is not None:
1013
- return cached
1014
-
1063
+ table = _FREE_TIER_PRICING_CACHE
1064
+ resolved_key = _resolve_free_model_key(model_id, table)
1065
+ if resolved_key is not None:
1066
+ cached = table.get(resolved_key)
1067
+ if cached is not None:
1068
+ return cached
1069
+
1070
+ # ── Do NOT consult `model_registry` here ─────────────────────────────
1071
+ # `model_registry` (ModelDB) holds the general model catalog, and
1072
+ # `utim_models` holds community-added models. Neither is the pricing
1073
+ # source for the free tier: free-tier prices live in `free_models`.
1074
+ # Reading another table would silently substitute an unrelated rate and
1075
+ # mask a row that was never seeded, so a miss is reported honestly.
1076
+ #
1015
1077
  # Check dedicated API model pricing (ApiModel)
1016
1078
  try:
1017
1079
  from ..api_models_db import ApiModel
@@ -1026,6 +1088,16 @@ def get_free_tier_model_pricing(
1026
1088
  .filter(ApiModel.model_id == model_id)
1027
1089
  .first()
1028
1090
  )
1091
+ # Same tolerance as the free_models lookup: the ApiModel row may be
1092
+ # keyed without the provider namespace or without a `:free` suffix.
1093
+ if row is None:
1094
+ _bare = model_id.split(":", 1)[0]
1095
+ _tail = _bare.split("/", 1)[-1]
1096
+ row = (
1097
+ session.query(ApiModel)
1098
+ .filter(ApiModel.model_id.in_([_bare, _tail]))
1099
+ .first()
1100
+ )
1029
1101
  if row is not None:
1030
1102
  return (
1031
1103
  float(getattr(row, "cost_input_per_1m", 0.0) or 0.0),
@@ -1067,10 +1139,31 @@ def get_free_tier_baseline_price(db: Optional[Session] = None) -> float:
1067
1139
  except Exception:
1068
1140
  prices = []
1069
1141
 
1070
- baseline = min(prices) if prices else FREE_TIER_BASELINE_PRICE_PER_1M
1071
- _FREE_TIER_BASELINE_CACHE = baseline
1072
- _FREE_TIER_BASELINE_CACHE_TS = now
1073
- return baseline
1142
+ # ── STRICT DB SOURCING ───────────────────────────────────────────────
1143
+ # The baseline is the cheapest positive price actually present in the
1144
+ # `free_models` table. It must never be a hardcoded constant: a fabricated
1145
+ # baseline silently rescales every deduction, so a model whose real price
1146
+ # is 10x the invented baseline would be billed 1/10th of what it costs.
1147
+ # If the table has no priced rows, the correct answer is 0.0 ("cannot
1148
+ # derive") and the caller is responsible for alerting — not inventing.
1149
+ if prices:
1150
+ baseline = min(prices)
1151
+ _FREE_TIER_BASELINE_CACHE = baseline
1152
+ _FREE_TIER_BASELINE_CACHE_TS = now
1153
+ return baseline
1154
+
1155
+ logger.error(
1156
+ "free_tier_baseline_unavailable",
1157
+ extra={
1158
+ "reason": "no_priced_rows_in_free_models",
1159
+ "detail": (
1160
+ "free_models has no row with a positive cost_input_per_1m or "
1161
+ "cost_output_per_1m. Free-tier deductions cannot be derived "
1162
+ "until at least one model is seeded with real pricing."
1163
+ ),
1164
+ },
1165
+ )
1166
+ return 0.0
1074
1167
 
1075
1168
 
1076
1169
  def compute_free_tier_token_deduction(
@@ -1098,11 +1191,16 @@ def compute_free_tier_token_deduction(
1098
1191
 
1099
1192
  p_in, p_out = get_free_tier_model_pricing(model_id, db)
1100
1193
  baseline = get_free_tier_baseline_price(db)
1101
- if not baseline or baseline <= 0:
1102
- baseline = FREE_TIER_BASELINE_PRICE_PER_1M
1103
1194
 
1104
- weight_in = (p_in / baseline) if (p_in and p_in > 0) else 1.0
1105
- weight_out = (p_out / baseline) if (p_out and p_out > 0) else 1.0
1195
+ # No priced rows in `free_models` -> no basis for weighting. Deduct the
1196
+ # raw token count (weight 1.0) rather than dividing by an invented
1197
+ # baseline, and let the caller surface the missing configuration.
1198
+ if baseline and baseline > 0:
1199
+ weight_in = (p_in / baseline) if (p_in and p_in > 0) else 1.0
1200
+ weight_out = (p_out / baseline) if (p_out and p_out > 0) else 1.0
1201
+ else:
1202
+ weight_in = 1.0
1203
+ weight_out = 1.0
1106
1204
 
1107
1205
  return float(in_tok * weight_in + out_tok * weight_out)
1108
1206
 
@@ -1509,13 +1607,25 @@ async def completions(
1509
1607
  # same 15,000-credit monthly pool, so the gate must NOT exempt
1510
1608
  # zero-cost models: a free model still consumes credits from the
1511
1609
  # monthly balance. Only bonus-funded usage bypasses the pool.
1610
+ #
1611
+ # AUTHORITATIVE SOURCE: for free plans, `Credit.free_monthly_used`
1612
+ # is the canonical spend counter — it is decremented in real time
1613
+ # as credits are consumed. `QuotaUsage.credits_used` is an audit
1614
+ # counter that may lag, stale, or fail to reset after a manual DB
1615
+ # fix, causing the gate to show "exhausted" even when the user has
1616
+ # a full 15,000-credit balance. For free plans, use free_monthly_used
1617
+ # only; fall back to credits_used only when free_monthly_used is absent.
1512
1618
  limit_to_check = FREE_TIER_MONTHLY_TOKEN_POOL if _plan_is_free else quota.credits_limit
1513
- free_monthly_used = getattr(_cr, "free_monthly_used", 0.0) if _cr else 0.0
1514
- used_to_check = max(float(getattr(quota, "credits_used", 0.0) or 0.0), float(free_monthly_used or 0.0))
1619
+ free_monthly_used = getattr(_cr, "free_monthly_used", None) if _cr else None
1620
+ if _plan_is_free:
1621
+ # Trust free_monthly_used as the sole authoritative counter.
1622
+ used_to_check = float(free_monthly_used or 0.0)
1623
+ else:
1624
+ used_to_check = float(getattr(quota, "credits_used", 0.0) or 0.0)
1515
1625
  if _plan_is_free and _bonus <= 0.0 and used_to_check >= limit_to_check:
1516
1626
  _reset_dt = (
1517
1627
  sub.current_period_end if (sub and sub.current_period_end)
1518
- else (quota.reset_at if quota else (now + datetime.timedelta(days=30)))
1628
+ else (quota.reset_at if quota else (datetime.datetime.utcnow() + datetime.timedelta(days=30)))
1519
1629
  )
1520
1630
  _reset_iso = _reset_dt.isoformat() + "Z"
1521
1631
  _used_pct = (used_to_check / limit_to_check * 100.0) if limit_to_check > 0 else 100.0
@@ -1748,9 +1858,14 @@ async def completions(
1748
1858
  req.model_id = sub
1749
1859
  else:
1750
1860
  req.model_id = "nvidia/nemotron-3.5-lightning:free"
1751
- elif req.model_id in APINEX_MODEL_IDS or req.model_id.startswith("free/"):
1861
+ elif req.model_id in APINEX_MODEL_IDS:
1862
+ # Only check the APINEX rotator for actual APINEX model IDs.
1863
+ # `free/` prefix models (e.g. free/glm-5.3-flash) are served from the
1864
+ # free_models DB table using their own endpoint_url + api_keys_enc —
1865
+ # they have no relation to the APINEX key rotator and must NOT be
1866
+ # blocked here.
1752
1867
  from ..key_rotator import global_apinex_key_rotator
1753
- if not global_apinex_key_rotator.has_available_keys():
1868
+ if not global_apinex_key_rotator.has_available_keys(for_free_tier=True):
1754
1869
  raise HTTPException(
1755
1870
  status_code=503,
1756
1871
  detail={"error": {"message": f"Provider APINEX for model '{req.model_id}' is currently unavailable (no active keys).", "type": "provider_unavailable"}}
@@ -3483,17 +3598,63 @@ async def completions(
3483
3598
  _free_pin, _free_pout = get_free_tier_model_pricing(
3484
3599
  _snap_orig_model_id or _snap_model_id or "", db=fresh_db
3485
3600
  )
3601
+ # ── Price source: `free_models` table ONLY ────────
3602
+ # The per-model price MUST come from `free_models`.
3603
+ # A hardcoded constant is not a price: it silently
3604
+ # rescales every free-tier deduction and hides
3605
+ # models that were never seeded with real values.
3606
+ #
3607
+ # Resolution order:
3608
+ # 1. `free_models` row for this model (real price)
3609
+ # 2. ApiModel pricing, for slugs not in the table
3610
+ # 3. cheapest priced row already in `free_models`
3611
+ # 4. unpriceable -> charge `credits_cost` if the
3612
+ # model is metered, else flag it. Never invent.
3613
+ _free_pin, _free_pout = get_free_tier_model_pricing(
3614
+ _snap_orig_model_id or _snap_model_id or "", db=fresh_db
3615
+ )
3616
+ _free_price_source = "free_models"
3617
+ if not (_free_pin and _free_pin > 0.0) and not (
3618
+ _free_pout and _free_pout > 0.0
3619
+ ):
3620
+ # Nothing priced for this slug. Use the cheapest
3621
+ # price that genuinely exists in `free_models`
3622
+ # so usage is still metered at the real floor.
3623
+ _floor = get_free_tier_baseline_price(db=fresh_db)
3624
+ if _floor and _floor > 0.0:
3625
+ _free_pin = _floor
3626
+ _free_pout = _floor
3627
+ _free_price_source = "free_models_floor"
3628
+ else:
3629
+ _free_price_source = "unpriced"
3630
+
3486
3631
  _free_usd = (
3487
- (float(final_input or 0) / 1_000_000.0) * _free_pin
3488
- + (float(final_output or 0) / 1_000_000.0) * _free_pout
3632
+ (float(final_input or 0) / 1_000_000.0) * float(_free_pin or 0.0)
3633
+ + (float(final_output or 0) / 1_000_000.0) * float(_free_pout or 0.0)
3489
3634
  )
3490
- # 1 USD == 3,000 credits. Fall back to credits_cost when
3491
- # pricing is unknown so a priced model is never free.
3635
+ # 1 USD == 3,000 credits. `credits_cost` is the
3636
+ # metered price for non-free slugs, so it is a
3637
+ # legitimate lower bound; it is 0.0 for free models.
3492
3638
  free_credit_cost = max(
3493
3639
  0.0,
3494
3640
  _free_usd * 3000.0,
3495
3641
  float(credits_cost or 0.0),
3496
3642
  )
3643
+ if _free_price_source == "unpriced" and free_credit_cost <= 0.0:
3644
+ logger.error(
3645
+ "free_tier_model_unpriced",
3646
+ extra={
3647
+ "model_id": _snap_orig_model_id or _snap_model_id,
3648
+ "input_tokens": final_input,
3649
+ "output_tokens": final_output,
3650
+ "detail": (
3651
+ "No price found in `free_models` or "
3652
+ "`api_models` and no priced floor row "
3653
+ "exists to fall back to. Usage was "
3654
+ "recorded but not charged."
3655
+ ),
3656
+ },
3657
+ )
3497
3658
 
3498
3659
  # `credit_row` already resolved above the branch.
3499
3660
  if credit_row:
@@ -3517,6 +3678,7 @@ async def completions(
3517
3678
  credit_charge = max(0.0, credit_charge - credits_to_pool)
3518
3679
 
3519
3680
  if credit_charge > 0.0:
3681
+ charged_from_balance = 0.0
3520
3682
  if pref_quota == "bonus" or bonus_bal > 0.0:
3521
3683
  if credit_charge <= bonus_bal:
3522
3684
  credit_row.bonus_balance = bonus_bal - credit_charge
@@ -3528,12 +3690,32 @@ async def completions(
3528
3690
  credit_charge -= bonus_bal
3529
3691
  if credit_charge > 0.0:
3530
3692
  if credit_charge <= credit_row.balance:
3693
+ charged_from_balance = credit_charge
3531
3694
  credit_row.balance = credit_row.balance - credit_charge
3532
3695
  credit_charge = 0.0
3533
3696
  else:
3697
+ charged_from_balance = float(credit_row.balance or 0.0)
3534
3698
  credit_row.balance = 0.0
3535
-
3536
- quota_row.credits_used += tokens_to_pool
3699
+ # Track total_spent for all charged sources
3700
+ _free_total_charged = charged_to_bonus + charged_from_balance
3701
+ if _free_total_charged > 0.0:
3702
+ credit_row.total_spent = float(getattr(credit_row, "total_spent", 0.0) or 0.0) + _free_total_charged
3703
+
3704
+ # Also count free monthly pool consumption in total_spent
3705
+ # (credits_to_pool is absorbed by the monthly allowance, not
3706
+ # subtracted from balance, so it must be added separately).
3707
+ if credits_to_pool > 0.0:
3708
+ credit_row.total_spent = float(getattr(credit_row, "total_spent", 0.0) or 0.0) + credits_to_pool
3709
+
3710
+ # Mirror the monthly-pool draw onto QuotaUsage.
3711
+ # NOTE: the pool is CREDIT-denominated, so this
3712
+ # must be `credits_to_pool` (bound above). The
3713
+ # former `tokens_to_pool` name no longer exists
3714
+ # and raised NameError, degrading the whole
3715
+ # ledger write to the error path.
3716
+ quota_row.credits_used = float(
3717
+ quota_row.credits_used or 0.0
3718
+ ) + float(credits_to_pool or 0.0)
3537
3719
 
3538
3720
  # ── Bonus usage accounting (per-grant FIFO drain) ──
3539
3721
  if charged_to_bonus > 0.0:
@@ -3625,7 +3807,7 @@ async def completions(
3625
3807
  try:
3626
3808
  from ..provider_balance import global_token_ledger
3627
3809
  global_token_ledger.record_usage(
3628
- provider_id=_snap_provider if "_snap_provider" in locals() else (_snap_model_id.split("/")[0] if "/" in _snap_model_id else "openrouter"),
3810
+ provider_id=str(_snap_provider_id or "openrouter"),
3629
3811
  key_id="active_key",
3630
3812
  input_tokens=final_input,
3631
3813
  output_tokens=final_output,
@@ -4006,6 +4188,11 @@ def deduct_credits_unallocated_first(db: Session, user: User, credits_cost: floa
4006
4188
  charged_to_regular = credits_cost - charged_to_bonus
4007
4189
  quota_row.credits_used += charged_to_monthly
4008
4190
 
4191
+ # Track total_spent for all charged amounts (free plan path)
4192
+ _unalloc_total_charged = charged_to_bonus + charged_to_monthly
4193
+ if _unalloc_total_charged > 0.0:
4194
+ credit_row.total_spent = float(getattr(credit_row, "total_spent", 0.0) or 0.0) + _unalloc_total_charged
4195
+
4009
4196
  # ── Bonus usage accounting (per-grant FIFO drain) ──
4010
4197
  if charged_to_bonus > 0.0:
4011
4198
  try:
@@ -4100,9 +4287,14 @@ async def generate_image_proxy(
4100
4287
  )
4101
4288
 
4102
4289
  # Free tier is bounded by the MONTHLY credit pool — never a daily figure.
4290
+ # Use free_monthly_used as the sole authoritative counter for free plans;
4291
+ # quota.credits_used may be stale and cause false "exhausted" blocks.
4103
4292
  limit_to_check = FREE_TIER_MONTHLY_TOKEN_POOL if (plan and _plan_is_free) else quota.credits_limit
4104
- free_monthly_used = getattr(credit_row, "free_monthly_used", 0.0) if credit_row else 0.0
4105
- used_to_check = max(float(getattr(quota, "credits_used", 0.0) or 0.0), float(free_monthly_used or 0.0))
4293
+ free_monthly_used = getattr(credit_row, "free_monthly_used", None) if credit_row else None
4294
+ if _plan_is_free:
4295
+ used_to_check = float(free_monthly_used or 0.0)
4296
+ else:
4297
+ used_to_check = float(getattr(quota, "credits_used", 0.0) or 0.0)
4106
4298
 
4107
4299
 
4108
4300
  if (plan and (plan.name or "").lower() not in ("hobby", "pro", "max", "ultimate", "ultra")) and bonus_balance <= 0.0 and used_to_check >= limit_to_check: