utim-cli 2.6.2__tar.gz → 2.6.4__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 (243) hide show
  1. {utim_cli-2.6.2 → utim_cli-2.6.4}/CHANGELOG.md +10 -0
  2. {utim_cli-2.6.2/utim_cli.egg-info → utim_cli-2.6.4}/PKG-INFO +1 -1
  3. {utim_cli-2.6.2 → utim_cli-2.6.4}/pyproject.toml +1 -1
  4. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim/__init__.py +1 -1
  5. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/__init__.py +1 -1
  6. utim_cli-2.6.4/utim_cli/_verify_spinner_ignore.py +89 -0
  7. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/_version.py +1 -1
  8. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/adaptation_engine.py +14 -11
  9. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/bootstrap.py +9 -3
  10. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/config.py +60 -0
  11. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/context_pruner.py +265 -6
  12. utim_cli-2.6.4/utim_cli/design_studio.py +2155 -0
  13. utim_cli-2.6.4/utim_cli/motion_audio.py +973 -0
  14. utim_cli-2.6.4/utim_cli/motion_bridge.py +872 -0
  15. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/motion_graphics.py +3706 -3106
  16. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/orchestrator.py +109 -132
  17. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/orchestrator_helpers.py +83 -15
  18. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/orchestrator_llm_transport.py +72 -143
  19. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/orchestrator_tool_exec.py +11 -0
  20. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/orchestrator_turn_history.py +70 -2
  21. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/reflection.py +107 -14
  22. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/auth.py +164 -21
  23. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/db.py +377 -99
  24. utim_cli-2.6.4/utim_cli/server/discord_verification.py +126 -0
  25. utim_cli-2.6.4/utim_cli/server/field_crypto.py +134 -0
  26. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/firewall.py +97 -3
  27. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/history.py +2 -1
  28. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/models.py +98 -35
  29. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/plan_integrity.py +8 -7
  30. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/platform_billing.py +21 -3
  31. utim_cli-2.6.4/utim_cli/server/quota_bank.py +461 -0
  32. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/router.py +6 -3
  33. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/__init__.py +5 -4
  34. utim_cli-2.6.4/utim_cli/server/routes/account_verification_routes.py +152 -0
  35. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/admin_bonus_routes.py +13 -16
  36. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/api_models_admin_routes.py +17 -1
  37. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/api_models_public_routes.py +668 -123
  38. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/auth_routes.py +2 -46
  39. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/completion_routes.py +85 -96
  40. utim_cli-2.6.4/utim_cli/server/routes/design_routes.py +407 -0
  41. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/marketplace_routes.py +42 -6
  42. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/quota_routes.py +111 -96
  43. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/wallet_routes.py +81 -4
  44. utim_cli-2.6.4/utim_cli/server/scripts/__init__.py +0 -0
  45. utim_cli-2.6.4/utim_cli/server/scripts/vault_ops.py +189 -0
  46. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/tier_tables.py +10 -1
  47. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/uptime_monitor.py +199 -193
  48. utim_cli-2.6.4/utim_cli/server/vault.py +392 -0
  49. utim_cli-2.6.4/utim_cli/skill_router.py +316 -0
  50. utim_cli-2.6.4/utim_cli/tests_quota_bank_scratch.py +71 -0
  51. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tools.py +306 -33
  52. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/model_dialog.py +584 -33
  53. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/utim.py +420 -293
  54. {utim_cli-2.6.2 → utim_cli-2.6.4/utim_cli.egg-info}/PKG-INFO +1 -1
  55. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli.egg-info/SOURCES.txt +13 -4
  56. utim_cli-2.6.2/utim_cli/design_systems.py +0 -971
  57. utim_cli-2.6.2/utim_cli/motion_bridge.py +0 -361
  58. utim_cli-2.6.2/utim_cli/open_design.py +0 -692
  59. utim_cli-2.6.2/utim_cli/server/routes/discord_routes.py +0 -474
  60. utim_cli-2.6.2/utim_cli/server/verification_gate.py +0 -328
  61. {utim_cli-2.6.2 → utim_cli-2.6.4}/LICENSE +0 -0
  62. {utim_cli-2.6.2 → utim_cli-2.6.4}/MANIFEST.in +0 -0
  63. {utim_cli-2.6.2 → utim_cli-2.6.4}/README.md +0 -0
  64. {utim_cli-2.6.2 → utim_cli-2.6.4}/setup.cfg +0 -0
  65. {utim_cli-2.6.2 → utim_cli-2.6.4}/setup.py +0 -0
  66. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/_chip_test.py +0 -0
  67. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/_verify_repro.py +0 -0
  68. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/_verify_syntax.py +0 -0
  69. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/_wizard_smoke_test.py +0 -0
  70. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/agent.py +0 -0
  71. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/architecture_indexer.py +0 -0
  72. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/ask_helper.py +0 -0
  73. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/auth.py +0 -0
  74. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/background_models.py +0 -0
  75. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/backup.py +0 -0
  76. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/behavior_telemetry.py +0 -0
  77. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/billing.py +0 -0
  78. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/blender_agent.py +0 -0
  79. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/brain.py +0 -0
  80. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/builtin/skills/utim-guide/SKILL.md +0 -0
  81. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/client_utils.py +0 -0
  82. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/constants.py +0 -0
  83. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/context_inspector.py +0 -0
  84. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/crawler/__init__.py +0 -0
  85. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/crawler/engine.py +0 -0
  86. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/crawler/markdown_distiller.py +0 -0
  87. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/dependency_manager.py +0 -0
  88. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/doctor.py +0 -0
  89. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/evidence_registry.py +0 -0
  90. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/harbor.py +0 -0
  91. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/knowledge_graph.py +0 -0
  92. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/local_db.py +0 -0
  93. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/logger.py +0 -0
  94. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/mcp_clean_wrapper.py +0 -0
  95. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/mcp_client.py +0 -0
  96. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/mcp_registry.json +0 -0
  97. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/models.txt +0 -0
  98. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/personalities.py +0 -0
  99. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/platform_installer.py +0 -0
  100. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/__init__.py +0 -0
  101. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/hooks.py +0 -0
  102. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/loader.py +0 -0
  103. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/manager.py +0 -0
  104. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/registry.py +0 -0
  105. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/runtime.py +0 -0
  106. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/schema.py +0 -0
  107. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/plugins/tool_loader.py +0 -0
  108. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/report.py +0 -0
  109. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/scrapy_search.py +0 -0
  110. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/sdk/__init__.py +0 -0
  111. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/sdk/config.py +0 -0
  112. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/sdk/context.py +0 -0
  113. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/sdk/events.py +0 -0
  114. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/sdk/handlers.py +0 -0
  115. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/sdk/session.py +0 -0
  116. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/sdk/sidecar.py +0 -0
  117. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/__init__.py +0 -0
  118. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/admin_auth.py +0 -0
  119. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/api_models_db.py +0 -0
  120. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/api_request_logs.py +0 -0
  121. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/attribution.py +0 -0
  122. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/audit_log.py +0 -0
  123. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/batch_processor.py +0 -0
  124. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/bonus_ledger.py +0 -0
  125. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/bot_detection.py +0 -0
  126. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/captcha.py +0 -0
  127. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/cli_auth.py +0 -0
  128. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/concurrency.py +0 -0
  129. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/crypto_utils.py +0 -0
  130. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/disposable_email_guard.py +0 -0
  131. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/SECRET_PROVISIONING.md +0 -0
  132. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/about.md +0 -0
  133. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/changelog.md +0 -0
  134. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/docs.md +0 -0
  135. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/features.md +0 -0
  136. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/license.md +0 -0
  137. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/pricing.md +0 -0
  138. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/privacy.md +0 -0
  139. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/refund.md +0 -0
  140. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/support.md +0 -0
  141. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/docs_md/terms.md +0 -0
  142. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/email_utils.py +0 -0
  143. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/exchange_rate.py +0 -0
  144. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/firebase.py +0 -0
  145. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/fix_duplicate_users.py +0 -0
  146. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/hobby_throttler.py +0 -0
  147. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/key_rotator.py +0 -0
  148. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/local_llm.py +0 -0
  149. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/logging_config.py +0 -0
  150. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/maintenance.py +0 -0
  151. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/model_agent.py +0 -0
  152. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/pricing_updater.py +0 -0
  153. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/provider_balance.py +0 -0
  154. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/provider_batcher.py +0 -0
  155. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/provider_discovery.py +0 -0
  156. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/provider_router.py +0 -0
  157. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/provision_build.py +0 -0
  158. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/purge_disposable_users.py +0 -0
  159. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/rate_limit.py +0 -0
  160. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/request_batcher.py +0 -0
  161. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/request_queue.py +0 -0
  162. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/rewards_engine.py +0 -0
  163. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/activity_routes.py +0 -0
  164. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/admin_db_routes.py +0 -0
  165. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/admin_providers_routes.py +0 -0
  166. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/admin_separated_models_routes.py +0 -0
  167. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/api_gateway_extensions_routes.py +0 -0
  168. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/api_key_routes.py +0 -0
  169. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/billing_routes.py +0 -0
  170. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/compression_routes.py +0 -0
  171. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/credit_routes.py +0 -0
  172. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/feedback_routes.py +0 -0
  173. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/provider_compat_routes.py +0 -0
  174. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/quota_share_routes.py +0 -0
  175. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/referral_routes.py +0 -0
  176. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/rewards_routes.py +0 -0
  177. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/security_routes.py +0 -0
  178. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/session_routes.py +0 -0
  179. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/share_routes.py +0 -0
  180. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/routes/webhook_routes.py +0 -0
  181. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/security_alerts.py +0 -0
  182. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/server.py +0 -0
  183. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/signup_guard.py +0 -0
  184. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/storage_nodes.py +0 -0
  185. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/server/utils.py +0 -0
  186. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/share.py +0 -0
  187. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/share_tui.py +0 -0
  188. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/situational_scoring.py +0 -0
  189. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/state.py +0 -0
  190. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/subagent_manager.py +0 -0
  191. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/syntax_fix.py +0 -0
  192. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/task_dispatcher.py +0 -0
  193. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/task_logger.py +0 -0
  194. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tools_grep.py +0 -0
  195. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/__init__.py +0 -0
  196. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/compression_dialog.py +0 -0
  197. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/feedback_dialog.py +0 -0
  198. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/history_dialog.py +0 -0
  199. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/marketplace_app_state.py +0 -0
  200. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/marketplace_dialog.py +0 -0
  201. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/marketplace_layout_engine.py +0 -0
  202. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/mcp_dialog.py +0 -0
  203. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/miniagents_dialog.py +0 -0
  204. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/personality_dialog.py +0 -0
  205. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/plugins_dialog.py +0 -0
  206. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/publish_dialog.py +0 -0
  207. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/quota_dialog.py +0 -0
  208. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/quota_redeem_dialog.py +0 -0
  209. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/quota_share_dialog.py +0 -0
  210. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/resume_dialog.py +0 -0
  211. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/rewards_tui.py +0 -0
  212. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/skills_dialog.py +0 -0
  213. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/spinner.py +0 -0
  214. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/stream_diagnostics.py +0 -0
  215. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/subagents_dialog.py +0 -0
  216. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/tasks_dialog.py +0 -0
  217. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/thinking_display.py +0 -0
  218. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/thinking_phrases.py +0 -0
  219. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/token_meter.py +0 -0
  220. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/tool_theme_preview.py +0 -0
  221. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/tool_themes.py +0 -0
  222. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/tools_dialog.py +0 -0
  223. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/update_dialog.py +0 -0
  224. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/tui/verbosity_dialog.py +0 -0
  225. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/update_checker.py +0 -0
  226. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/utilities.py +0 -0
  227. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/utimmodel.txt +0 -0
  228. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/vector_memory.py +0 -0
  229. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice.py +0 -0
  230. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_coding.py +0 -0
  231. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_events.py +0 -0
  232. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_handler.py +0 -0
  233. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_instant.py +0 -0
  234. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_orchestrator.py +0 -0
  235. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_session.py +0 -0
  236. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_stt.py +0 -0
  237. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/voice_tts.py +0 -0
  238. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/wheel.py +0 -0
  239. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli/workspace.py +0 -0
  240. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli.egg-info/dependency_links.txt +0 -0
  241. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli.egg-info/entry_points.txt +0 -0
  242. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli.egg-info/requires.txt +0 -0
  243. {utim_cli-2.6.2 → utim_cli-2.6.4}/utim_cli.egg-info/top_level.txt +0 -0
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.6.4] - 2026-11-10
4
+
5
+ ### 🐛 Minor Bug Fixes
6
+ - Assorted minor bug fixes and stability improvements across the CLI, server, and web surfaces.
7
+
8
+ ## [2.6.3] - 2026-11-06
9
+
10
+ ### 🐛 Minor Bug Fixes
11
+ - Assorted minor bug fixes and stability improvements across the CLI and server surfaces.
12
+
3
13
  ## [2.6.2] - 2026-11-04
4
14
 
5
15
  ### 🐛 Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: utim-cli
3
- Version: 2.6.2
3
+ Version: 2.6.4
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.2"
7
+ version = "2.6.4"
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.2"
17
+ __version__ = "2.6.4"
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.2"
8
+ __version__ = "2.6.4"
9
9
 
10
10
 
11
11
  import builtins, os, pathlib, urllib.parse, re
@@ -0,0 +1,89 @@
1
+ """Verify /modelsettings resolves the model row from the chosen identifier."""
2
+ import sys
3
+ import os
4
+
5
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6
+
7
+ from utim_cli.config import config
8
+
9
+
10
+ def _norm_id(v):
11
+ s = str(v or "").strip().lower()
12
+ if ":" in s:
13
+ s = s.split(":")[0]
14
+ if "/" in s:
15
+ s = s.split("/")[-1]
16
+ return s
17
+
18
+
19
+ def resolve(identifier, plan_tier="hobby"):
20
+ target = str(identifier or "").strip()
21
+ if not target:
22
+ return None, None
23
+ bare = _norm_id(target)
24
+ from utim_cli.server.db import SessionLocal as _SL
25
+ from utim_cli.server import tier_tables as _tt
26
+
27
+ order = list(dict.fromkeys(([plan_tier] if plan_tier else []) + ["free", "hobby", "pro", "max", "ultimate"]))
28
+ _sess = _SL()
29
+ try:
30
+ for t in order:
31
+ try:
32
+ cls = _tt._class_for_table(_tt.TIER_TEXT_TABLE[t])
33
+ except Exception:
34
+ cls = None
35
+ if cls is None:
36
+ continue
37
+ try:
38
+ r = _sess.query(cls).filter(cls.model_id == target).first()
39
+ except Exception:
40
+ r = None
41
+ if r is not None:
42
+ return r, t
43
+ if bare:
44
+ for t in order:
45
+ try:
46
+ cls = _tt._class_for_table(_tt.TIER_TEXT_TABLE[t])
47
+ except Exception:
48
+ cls = None
49
+ if cls is None:
50
+ continue
51
+ try:
52
+ r = _sess.query(cls).filter(cls.model_id.ilike(f"%{bare}")).first()
53
+ except Exception:
54
+ r = None
55
+ if r is not None:
56
+ return r, t
57
+ finally:
58
+ _sess.close()
59
+ return None, None
60
+
61
+
62
+ def main():
63
+ out = []
64
+ ok = True
65
+ cases = [
66
+ "wf/deepseek-v4.1-flash",
67
+ "hobby/deepseek-v4.1-flash",
68
+ "deepseek-v4.1-flash",
69
+ "wf/glm-5.3-flash",
70
+ "deepseek-v4.1-flash:free",
71
+ ]
72
+ for c in cases:
73
+ row, tier = resolve(c)
74
+ if row is None:
75
+ out.append(f"FAIL {c:<34} -> NO ROW")
76
+ ok = False
77
+ continue
78
+ mo = getattr(row, "max_output_tokens", None)
79
+ cw = getattr(row, "context_window", None)
80
+ real_id = getattr(row, "model_id", None)
81
+ out.append(f"PASS {c:<34} -> {tier}_models id={real_id!r} max_out={mo} ctx={cw}")
82
+ out.append("")
83
+ out.append("ALL OK" if ok else "FAILURES")
84
+ sys.stderr.write("\n".join(out) + "\n")
85
+ return 0 if ok else 1
86
+
87
+
88
+ if __name__ == "__main__":
89
+ raise SystemExit(main())
@@ -11,6 +11,6 @@
11
11
  # from here so every surface stays in sync automatically.
12
12
  # ─────────────────────────────────────────────────────────────────────────────
13
13
 
14
- VERSION = "2.6.2"
14
+ VERSION = "2.6.4"
15
15
 
16
16
 
@@ -51,8 +51,8 @@ HEALTH_COOLDOWN_S = 120 # circuit-open cooldown before half-open pr
51
51
  HEALTH_CIRCUIT_THRESHOLD = 0.25 # below this health → circuit open
52
52
  HEALTH_PERSIST_INTERVAL_S = 30.0 # throttle disk writes
53
53
  MAX_TOKENS_GROWTH_CAP = 2.0 # never exceed 2× base output budget
54
- THINK_OPEN_RE = re.compile(r"<think(?:\s[^>]*)?>", re.IGNORECASE)
55
- THINK_CLOSE_RE = re.compile(r"</think>", re.IGNORECASE)
54
+ THINK_OPEN_RE = re.compile(r"<(?:think|2)(?:\s[^>]*)?>", re.IGNORECASE)
55
+ THINK_CLOSE_RE = re.compile(r"<(?:/think|think)>|</think>", re.IGNORECASE)
56
56
 
57
57
  # Canonical finish reasons — everything maps into this tiny set.
58
58
  CANONICAL_STOP = "stop"
@@ -436,11 +436,11 @@ class AdaptationEngine:
436
436
  if not signal.truncated:
437
437
  return False
438
438
  if has_tool_calls:
439
- # If the model already emitted real tool calls, the ReAct loop will
440
- # handle them; don't inject a spurious CONTINUE that would confuse it.
441
- # Except for incomplete_tool_call — there the args are broken so we must continue.
442
- if signal.kind != "incomplete_tool_call":
443
- return False
439
+ # If the model emitted tool_calls (valid OR truncated mid-JSON), let
440
+ # orchestrator.py's pre-execution arg validation gate handle them so every
441
+ # tool_call_id receives a proper role='tool' response and part-by-part
442
+ # recovery instructions (never ask the model to re-emit a giant tool call).
443
+ return False
444
444
  if self.continue_rounds >= self.max_continue_rounds:
445
445
  logger.warning(f"[AdaptationEngine] max continues ({self.max_continue_rounds}) reached — stopping")
446
446
  return False
@@ -459,7 +459,7 @@ class AdaptationEngine:
459
459
  # just spams the user and can ping-pong the model. Hard-evidence
460
460
  # kinds (token_limit, tool-call JSON, think tags) keep the full
461
461
  # max_continue_rounds budget because genuine long output needs them.
462
- _AMBIGUOUS_KINDS = ("incomplete_fence", "mid_sentence_stop")
462
+ _AMBIGUOUS_KINDS = ("incomplete_fence", "mid_sentence_stop", "incomplete_think")
463
463
  if signal.kind in _AMBIGUOUS_KINDS and self.continue_rounds > 0:
464
464
  logger.info(
465
465
  f"[AdaptationEngine] kind={signal.kind!r} already fired once this task "
@@ -491,9 +491,12 @@ class AdaptationEngine:
491
491
  # Tailored nudge per kind — keeps model from repeating itself
492
492
  if signal.kind == "incomplete_tool_call":
493
493
  nudge = (
494
- "Your previous tool-call arguments were cut off mid-JSON (truncated). "
495
- "Please re-emit the COMPLETE tool call(s) with full JSON arguments. "
496
- "Do not repeat any already-executed calls — just provide the corrected tool calls now."
494
+ "Your previous tool-call arguments were cut off mid-JSON at the output token limit. "
495
+ "Do NOT re-emit a single giant file payload! Write or edit the file PART BY PART "
496
+ "(~100-150 lines max per call): for new/overwritten files, write Part 1 with "
497
+ "write_file(..., is_partial=True) / remotion_write_file(..., append=False) (or split "
498
+ "into modular files), then append subsequent chunks with append=True; for existing "
499
+ "files, make small section-by-section edit_file / remotion_edit_file calls."
497
500
  )
498
501
  elif signal.kind == "incomplete_fence":
499
502
  nudge = (
@@ -287,6 +287,7 @@ When users ask how to use, configure, or control UTIM CLI, or ask you to switch
287
287
 
288
288
  _SKILLS_CACHE = {}
289
289
  _SKILLS_CACHE_TS = 0.0
290
+ _SKILLS_CACHE_SIG = None
290
291
  _SKILLS_CACHE_TTL = 300.0 # seconds
291
292
 
292
293
  def scan_available_skills(force_reload: bool = False):
@@ -296,11 +297,16 @@ def scan_available_skills(force_reload: bool = False):
296
297
  Returns:
297
298
  dict: A dictionary mapping skill_name to dict containing path, name, description, and keywords.
298
299
  """
299
- global _SKILLS_CACHE, _SKILLS_CACHE_TS
300
- import time
300
+ global _SKILLS_CACHE, _SKILLS_CACHE_TS, _SKILLS_CACHE_SIG
301
+ import time, os
301
302
  now = time.time()
302
- if not force_reload and _SKILLS_CACHE and (now - _SKILLS_CACHE_TS) < _SKILLS_CACHE_TTL:
303
+ cur_sig = tuple(
304
+ len(os.listdir(p)) if os.path.isdir(p) else -1
305
+ for p in (".agents/skills", ".utim/skills")
306
+ )
307
+ if not force_reload and _SKILLS_CACHE and cur_sig == _SKILLS_CACHE_SIG and (now - _SKILLS_CACHE_TS) < _SKILLS_CACHE_TTL:
303
308
  return _SKILLS_CACHE
309
+ _SKILLS_CACHE_SIG = cur_sig
304
310
 
305
311
  import os, re
306
312
  from pathlib import Path
@@ -741,6 +741,66 @@ config = Config()
741
741
  BLENDER_PATH = config.blender_path
742
742
 
743
743
 
744
+ def _migrate_stale_max_tokens() -> None:
745
+ """One-time heal for frozen ``model_settings_*['max_tokens']`` values.
746
+
747
+ Builds before this fix seeded ``max_tokens`` with a flat 4096 default and
748
+ then never refreshed it. Because a value below the DB ceiling looks exactly
749
+ like a deliberate user downgrade, ``_get_model_max_output`` cannot tell the
750
+ two apart — so an affected user stayed pinned at 4096 forever while the
751
+ ``/modelsettings`` dialog displayed the true 128k ceiling. That mismatch
752
+ truncated long responses (most visibly on ``@design``, whose renders need a
753
+ large completion budget).
754
+
755
+ The legacy seed signature is exact: ``max_tokens == 4096`` paired with the
756
+ untouched default ``temperature`` and no explicit ``max_tokens_source``
757
+ marker. Only that precise fingerprint is migrated; anything the user
758
+ actually chose is left alone. A ``max_tokens_source`` marker is written
759
+ afterwards so the migration is idempotent.
760
+ """
761
+ try:
762
+ if config.get("_migrated_max_tokens_v2"):
763
+ return
764
+ legacy_seed = 4096
765
+ healed = 0
766
+ for key in list(getattr(config, "_global_data", {}) or {}) + list(
767
+ getattr(config, "_local_data", {}) or {}
768
+ ):
769
+ if not key.startswith("model_settings_"):
770
+ continue
771
+ settings = config.get(key)
772
+ if not isinstance(settings, dict):
773
+ continue
774
+ # Already marked as an explicit user choice -> never touch it.
775
+ if settings.get("max_tokens_source") == "user":
776
+ continue
777
+ if settings.get("max_tokens") != legacy_seed:
778
+ continue
779
+ model_id = key[len("model_settings_"):]
780
+ try:
781
+ from utim_cli.server.models import get_max_output_tokens
782
+
783
+ db_max = int(get_max_output_tokens(model_id, fallback=legacy_seed))
784
+ except Exception:
785
+ db_max = legacy_seed
786
+ if db_max > legacy_seed:
787
+ settings["max_tokens"] = db_max
788
+ settings["max_tokens_source"] = "db"
789
+ config.set(key, settings)
790
+ healed += 1
791
+ config.set("_migrated_max_tokens_v2", True)
792
+ if healed:
793
+ logger.info(
794
+ f"Migrated {healed} stale model_settings max_tokens value(s) "
795
+ f"from the legacy 4096 seed to the DB ceiling."
796
+ )
797
+ except Exception as e:
798
+ logger.warning(f"max_tokens migration skipped: {e}")
799
+
800
+
801
+ _migrate_stale_max_tokens()
802
+
803
+
744
804
  # ── Tool-call theme preference ────────────────────────────────────────────────
745
805
  # Stored under the ``ui`` key as ``{"tool_theme": "<name>"}`` so future UI
746
806
  # preferences can share the namespace without colliding with agent settings.
@@ -1334,6 +1334,14 @@ def soft_prune_messages(
1334
1334
  if not messages or len(messages) <= 2:
1335
1335
  return messages
1336
1336
 
1337
+ # @design mode: stop all intra-turn soft-pruning completely until the turn ends
1338
+ try:
1339
+ from utim_cli.design_studio import active_design_mode
1340
+ if active_design_mode():
1341
+ return list(messages)
1342
+ except Exception:
1343
+ pass
1344
+
1337
1345
  # 1. First pass: distill old thinking blocks from non-current assistant turns
1338
1346
  cleaned_messages = _strip_thinking_blocks(messages, keep_last=1)
1339
1347
 
@@ -2822,6 +2830,50 @@ def _is_valid_custom_entry(entry: Any) -> bool:
2822
2830
  return low.startswith("http://") or low.startswith("https://")
2823
2831
 
2824
2832
 
2833
+ def _catalog_serves_model(model_id: str, routing: str) -> bool:
2834
+ """Can `routing` actually serve `model_id`?
2835
+
2836
+ Guards the cross-routing retry. A custom/BYOK id such as
2837
+ ``oao/minimax-m3.1-flash`` only exists on the user's own base_url; asking
2838
+ the utim or openrouter gateway for it returns 404/invalid-model, so the
2839
+ retry burns a round trip and then reports the ORIGINAL error -- which made
2840
+ a harmless "extra bytes after JSON" quirk look fatal.
2841
+
2842
+ Deliberately permissive: when we cannot determine the catalogue, answer
2843
+ True so a genuinely recoverable case is never blocked. It only returns
2844
+ False on a positive "this id is custom-only" signal.
2845
+ """
2846
+ try:
2847
+ mid = str(model_id or "").strip()
2848
+ if not mid:
2849
+ return False
2850
+ low = mid.lower()
2851
+ rot = str(routing or "").strip().lower()
2852
+
2853
+ # Explicit custom/BYOK prefixes never exist on the public catalogues.
2854
+ if low.startswith(("byok/", "custom/", "custom-", "local/", "ollama/",
2855
+ "lmstudio/", "vllm/", "oao/")):
2856
+ return False
2857
+
2858
+ if rot in ("utim", "openrouter"):
2859
+ # Try the live catalogue when one is available.
2860
+ try:
2861
+ from utim_cli.client_utils import get_model_catalog
2862
+ cat = get_model_catalog()
2863
+ ids = getattr(cat, "by_id", None) or {}
2864
+ if ids:
2865
+ return mid in ids or low in {str(k).lower() for k in ids}
2866
+ except Exception:
2867
+ pass
2868
+ # A provider-prefixed id (vendor/model) is normally an aggregator
2869
+ # route, so allow it -- only bare custom ids were already excluded
2870
+ # by the prefix check above.
2871
+ return "/" in low
2872
+ return True
2873
+ except Exception:
2874
+ return True
2875
+
2876
+
2825
2877
  def _resolve_compression_routing(model_id: str) -> str:
2826
2878
  """Mirror LLMTransportMixin routing so compression hits the same endpoint as the main agent.
2827
2879
 
@@ -2839,6 +2891,41 @@ def _resolve_compression_routing(model_id: str) -> str:
2839
2891
  try:
2840
2892
  from utim_cli.config import config as _cfg
2841
2893
  from utim_cli.client_utils import is_byok_or_custom_model as _is_byok
2894
+
2895
+ # ── PRIMARY-SOURCE SHORTCUT (stale-BYOK collision fix) ──────────────
2896
+ # A BARE id such as "deepseek-v4.1-flash" collides with any leftover
2897
+ # custom/BYOK entry carrying that model_id, even when the user no
2898
+ # longer uses it (observed: provider XEMARUX, ai.xemarux.com, revoked
2899
+ # key). is_byok_or_custom_model() then answers True and routing snaps
2900
+ # to "custom" -- so compression posts to the dead endpoint and comes
2901
+ # back 401 {"error":{"message":"User not found."}} before the 401
2902
+ # handler re-routes it. Two log lines per compression, forever.
2903
+ #
2904
+ # The user's ACTUAL model is tiered ("hobby/deepseek-v4.1-flash") and
2905
+ # its recorded source is "utim". A credential-less/stale custom entry
2906
+ # must never outrank an explicit per-model source. So: if the user's
2907
+ # configured source says utim/openrouter, honor it for bare ids that
2908
+ # are not presented as custom/BYOK.
2909
+ _mid_s = str(model_id or "")
2910
+ _mid_low = _mid_s.lower()
2911
+ _explicit_bare = _mid_low.startswith(("byok/", "custom/", "custom-", "local/", "ollama/", "lmstudio/", "vllm/"))
2912
+ _pref_chk = _mid_low.split("/")[0] if "/" in _mid_low else _mid_low
2913
+ _is_dedicated = _pref_chk in ("vyceai", "apinex", "atria") or _mid_low.startswith(("vyceai", "apinex", "atria"))
2914
+ if not _explicit_bare and not _is_dedicated and "/" not in _mid_s:
2915
+ try:
2916
+ _src_hint = _cfg.get("main_model_source")
2917
+ _main_m = _cfg.get("main_model")
2918
+ # Only trust the hint when it describes THIS model family --
2919
+ # compare on the bare tail so "hobby/x" matches "x".
2920
+ if (
2921
+ _src_hint in ("utim", "openrouter")
2922
+ and _main_m
2923
+ and str(_main_m).split("/")[-1].lower() == _mid_low
2924
+ ):
2925
+ return _src_hint
2926
+ except Exception:
2927
+ pass
2928
+
2842
2929
  # 1. Custom / BYOK — must have valid base_url, otherwise fall through
2843
2930
  _is_byok_flag = False
2844
2931
  try:
@@ -2986,9 +3073,68 @@ def _call_compression_model_with_fallback(messages: List[Dict], llm_key: str, ma
2986
3073
  pass
2987
3074
  last_error = f"server route: {_srv_msg[:200]}"
2988
3075
 
3076
+ _auth_reroute_done = False
2989
3077
  for i, model in enumerate(models_to_try):
2990
3078
  _routing = _resolve_compression_routing(model)
3079
+ # ── STALE-CUSTOM-ENTRY GUARD ────────────────────────────────────────
3080
+ # A bare model id (e.g. "deepseek-v4.1-flash") can collide with a
3081
+ # leftover custom/BYOK entry from a previous provider (observed:
3082
+ # provider_name=XEMARUX, base_url=https://ai.xemarux.com/v1, with a
3083
+ # revoked API key). is_byok_or_custom_model() then reports True and
3084
+ # _resolve_compression_routing() returns "custom", so the request is
3085
+ # forced to that dead endpoint and comes back
3086
+ # 401 {"error":{"message":"User not found.","code":401}}
3087
+ # even though the *tiered* id the user actually runs
3088
+ # ("hobby/deepseek-v4.1-flash") routes cleanly to "utim".
3089
+ #
3090
+ # Guard: if "custom" was chosen but the resolved entry has no usable
3091
+ # base_url or no API key, do not force it. Fall back to the routing
3092
+ # for the user's currently configured main model (normally "utim").
3093
+ if _routing == "custom":
3094
+ _custom_ok = False
3095
+ try:
3096
+ from utim_cli.config import config as _cfg_g
3097
+ _ce = _cfg_g.get_custom_model(model)
3098
+ if _is_valid_custom_entry(_ce):
3099
+ _ck = str(_ce.get("api_key") or "").strip()
3100
+ _custom_ok = bool(_ck)
3101
+ except Exception:
3102
+ _custom_ok = False
3103
+ if not _custom_ok:
3104
+ _fallback_routing = "utim"
3105
+ try:
3106
+ _mm = None
3107
+ from utim_cli.config import config as _cfg_g2
3108
+ _mm = _cfg_g2.get("main_model")
3109
+ if _mm and _mm != model:
3110
+ _fr = _resolve_compression_routing(_mm)
3111
+ if _fr in ("utim", "openrouter", "custom") and _fr != "custom":
3112
+ _fallback_routing = _fr
3113
+ except Exception:
3114
+ pass
3115
+ _routing = _fallback_routing
3116
+ try:
3117
+ # Same policy as the AUTH RE-ROUTE notice below: the guard
3118
+ # already FIXED the routing, so this is informational only.
3119
+ # Gated behind UTIM_DEBUG_ROUTING instead of always printed.
3120
+ import os as _os_g
3121
+ if str(_os_g.environ.get("UTIM_DEBUG_ROUTING", "")).strip().lower() in ("1", "true", "yes", "on"):
3122
+ import sys as _sys_g
3123
+ print(
3124
+ f"[COMPRESSION ROUTING GUARD] model={model} had a stale/credential-less "
3125
+ f"custom entry — re-routed to '{_routing}' instead of 'custom'",
3126
+ file=_sys_g.stderr,
3127
+ )
3128
+ except Exception:
3129
+ pass
3130
+ _diag_routing = _routing
2991
3131
  _empty_hits_for_model = 0
3132
+ _auth_reroute_done = False
3133
+ # One-shot in-place recovery for a 200 with an undecodable body
3134
+ # (double-emit / SSE-ish / trailing-bytes framing quirk). Reset per
3135
+ # model so each candidate gets its own retry budget.
3136
+ _nonjson_retried = False
3137
+ _nonjson_retry_pending = False
2992
3138
  model_retries = 1 if model == primary_model else 2
2993
3139
  for attempt in range(model_retries + 1):
2994
3140
  try:
@@ -3008,14 +3154,90 @@ def _call_compression_model_with_fallback(messages: List[Dict], llm_key: str, ma
3008
3154
  if resp.status_code == 429:
3009
3155
  last_error = f"Model {model} rate limited (429)"
3010
3156
  break
3157
+ # ── 401 RE-ROUTE ────────────────────────────────────────────
3158
+ # A revoked/stale custom (BYOK) or OpenRouter credential must
3159
+ # never kill compression. Observed failure:
3160
+ # 401 {"error":{"message":"User not found.","code":401}}
3161
+ # caused by a leftover custom entry for the bare model id whose
3162
+ # provider key had been revoked. If we were forced onto
3163
+ # custom/openrouter and hit 401, transparently retry once via
3164
+ # the UTIM server routing (the user's valid UTIM key), then
3165
+ # continue the normal loop if that is unavailable.
3166
+ if resp.status_code == 401 and _routing in ("custom", "openrouter") and not _auth_reroute_done:
3167
+ _auth_reroute_done = True
3168
+ try:
3169
+ _body_txt = (resp.text or "")[:200].replace("\n", " ")
3170
+ except Exception:
3171
+ _body_txt = ""
3172
+ # Silent by default: this is a SUCCESSFUL recovery, not an
3173
+ # error the user must act on. The first attempt used a
3174
+ # stale/revoked custom credential, the retry via the valid
3175
+ # UTIM key succeeds, and compression completes normally --
3176
+ # so printing two lines per compression turn was pure
3177
+ # noise. Set UTIM_DEBUG_ROUTING=1 to surface it while
3178
+ # debugging provider routing.
3179
+ try:
3180
+ import os as _os_401
3181
+ if str(_os_401.environ.get("UTIM_DEBUG_ROUTING", "")).strip().lower() in ("1", "true", "yes", "on"):
3182
+ import sys as _sys_401
3183
+ print(
3184
+ f"[COMPRESSION AUTH RE-ROUTE] {_routing} returned 401 "
3185
+ f"({_body_txt}) for model={model} — retrying via 'utim'",
3186
+ file=_sys_401.stderr,
3187
+ )
3188
+ except Exception:
3189
+ pass
3190
+ last_error = (
3191
+ f"Model {model} {_routing} auth failed 401: {_body_txt} "
3192
+ f"(re-routed to utim)"
3193
+ )
3194
+ _routing = "utim"
3195
+ _diag_routing = _routing
3196
+ continue
3011
3197
  resp.raise_for_status()
3012
3198
 
3013
3199
  if resp.status_code == 200:
3200
+ # Some OpenAI-compatible upstreams (e.g. proxy-gateway models
3201
+ # like oao/*) answer 200 with a JSON payload FOLLOWED by extra
3202
+ # bytes, or with SSE-ish text that resp.json() rejects with
3203
+ # "Extra data: line 1 column N (char N-1)". Treating that as a
3204
+ # hard failure killed compression entirely and fell back to a
3205
+ # deterministic summary. Decode the first complete JSON value
3206
+ # instead, and only then give up.
3207
+ body = None
3014
3208
  try:
3015
3209
  body = resp.json()
3016
3210
  except Exception as je:
3017
- last_error = f"Model {model} returned non-JSON 200: {je}"
3018
- break
3211
+ _first = None
3212
+ try:
3213
+ _raw_txt = resp.text if hasattr(resp, "text") else ""
3214
+ except Exception:
3215
+ _raw_txt = ""
3216
+ try:
3217
+ from utim_cli.reflection import _extract_first_json as _efj
3218
+ if _raw_txt:
3219
+ _first = _efj(_raw_txt)
3220
+ except Exception:
3221
+ _first = None
3222
+ if isinstance(_first, dict):
3223
+ body = _first
3224
+ else:
3225
+ last_error = f"Model {model} returned non-JSON 200: {je}"
3226
+ # A 200 whose body is not decodable JSON is almost
3227
+ # always a transport/proxy framing quirk (double
3228
+ # emit, SSE-ish text, trailing bytes) rather than a
3229
+ # model failure. Retry the SAME model on the SAME
3230
+ # routing once before abandoning it -- the original
3231
+ # code broke straight out to the deterministic
3232
+ # summary, which is why one bad frame killed the
3233
+ # whole compression turn.
3234
+ if attempt < model_retries and not _nonjson_retried:
3235
+ _nonjson_retried = True
3236
+ _nonjson_retry_pending = True
3237
+ import time as _t_nj
3238
+ _t_nj.sleep(0.4)
3239
+ continue
3240
+ break
3019
3241
  try:
3020
3242
  result = body["choices"][0]["message"]["content"]
3021
3243
  except Exception as ke:
@@ -3082,7 +3304,14 @@ def _call_compression_model_with_fallback(messages: List[Dict], llm_key: str, ma
3082
3304
  # ── Cross-routing retry for custom primary that returned empty twice ─────
3083
3305
  # If primary was custom and emptied, retry same model via openrouter once
3084
3306
  # before giving up — covers broken/empty custom base_url case.
3085
- if empty_hits >= 2 and last_error and "empty content" in last_error.lower():
3307
+ # ALSO covers "non-JSON 200" (Extra data / trailing bytes from a flaky
3308
+ # proxy-gateway upstream): try the same model through the valid UTIM /
3309
+ # OpenRouter routing once instead of dropping straight to the deterministic
3310
+ # summary.
3311
+ _recoverable = bool(last_error) and (
3312
+ "empty content" in last_error.lower() or "non-json 200" in last_error.lower()
3313
+ )
3314
+ if empty_hits >= 2 or _recoverable:
3086
3315
  try:
3087
3316
  _primary_routing = _resolve_compression_routing(primary_model)
3088
3317
  except Exception:
@@ -3097,8 +3326,21 @@ def _call_compression_model_with_fallback(messages: List[Dict], llm_key: str, ma
3097
3326
  _alt_routing = "utim"
3098
3327
  except Exception:
3099
3328
  pass
3329
+ # FIX: a custom-routed model id (e.g. "oao/minimax-m3.1-flash") is
3330
+ # meaningless on the utim/openrouter catalogue. The old code retried
3331
+ # the SAME model id on the alt gateway, which cannot serve it, so the
3332
+ # retry always failed and compression fell back to a deterministic
3333
+ # summary -- while the reported error stayed the original
3334
+ # "non-JSON 200". That made a 1-line JSON quirk look fatal.
3335
+ # A cross-routing retry is only meaningful when the model id is
3336
+ # actually served by the alt catalogue.
3337
+ _alt_can_serve = False
3338
+ try:
3339
+ _alt_can_serve = bool(_catalog_serves_model(primary_model, _alt_routing))
3340
+ except Exception:
3341
+ _alt_can_serve = False
3100
3342
  # Only retry if we haven't already tried this alt routing via fallback models
3101
- if _alt_routing not in [_resolve_compression_routing(m) for m in models_to_try[1:]]:
3343
+ if _alt_can_serve and _alt_routing not in [_resolve_compression_routing(m) for m in models_to_try[1:]]:
3102
3344
  try:
3103
3345
  from utim_cli.client_utils import proxy_openrouter_request as _proxy2
3104
3346
  _alt_resp = _proxy2(
@@ -3107,7 +3349,20 @@ def _call_compression_model_with_fallback(messages: List[Dict], llm_key: str, ma
3107
3349
  )
3108
3350
  if _alt_resp.status_code == 200:
3109
3351
  try:
3110
- _alt_body = _alt_resp.json()
3352
+ try:
3353
+ _alt_body = _alt_resp.json()
3354
+ except Exception:
3355
+ # Same "Extra data" tolerance as the primary call.
3356
+ _alt_body = None
3357
+ try:
3358
+ from utim_cli.reflection import _extract_first_json as _efj2
3359
+ _maybe = _efj2(getattr(_alt_resp, "text", "") or "")
3360
+ if isinstance(_maybe, dict):
3361
+ _alt_body = _maybe
3362
+ except Exception:
3363
+ _alt_body = None
3364
+ if _alt_body is None:
3365
+ raise
3111
3366
  _alt_result = _alt_body["choices"][0]["message"]["content"]
3112
3367
  _alt_result = re.sub(r"<think(?:ing)?>.*?</think(?:ing)?>", "", str(_alt_result or ""), flags=re.DOTALL).strip()
3113
3368
  if _alt_result:
@@ -3140,7 +3395,11 @@ def _call_compression_model_with_fallback(messages: List[Dict], llm_key: str, ma
3140
3395
  _local = _local[:_cap] + "… [truncated]"
3141
3396
  _local = "[LOCAL FALLBACK SUMMARY] " + _local
3142
3397
  import sys as _sys2
3143
- diag2 = f"model={primary_model} routing={_diag_routing if '_diag_routing' in locals() else 'unknown'} empty_hits={empty_hits}"
3398
+ diag2 = (
3399
+ f"model={primary_model} routing={_diag_routing if '_diag_routing' in locals() else 'unknown'} "
3400
+ f"empty_hits={empty_hits} nonjson_retried={bool(locals().get('_nonjson_retried'))} "
3401
+ f"alt_retry={'skipped-no-catalogue' if not locals().get('_alt_can_serve', True) else locals().get('_alt_routing', 'n/a')}"
3402
+ )
3144
3403
  print(f"[COMPRESSION LOCAL FALLBACK] LLM fallback failed ({last_error} | {diag2}) — using deterministic summary.", file=_sys2.stderr)
3145
3404
  return _local
3146
3405
  except Exception: