tokensafe 1.3.3 → 1.3.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokensafe",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Autonomous Zero-Loss Token Economy & Context Optimizer for AI Coding Agents",
5
5
  "main": "bin/tokensafe.js",
6
6
  "bin": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agy-token-optimizer",
3
3
  "displayName": "TokenSafe",
4
- "version": "1.3.3",
4
+ "version": "1.3.4",
5
5
  "description": "Zero-Loss Token Economy & Context Optimizer for AI Agents. Compresses prompts, slices AST/tool outputs, and prevents stuck loops.",
6
6
  "logo": "assets/logo.svg",
7
7
  "author": {
package/src/__init__.py CHANGED
@@ -2,5 +2,5 @@
2
2
  TokenSafe: Autonomous Zero-Loss Token Economy & Context Optimizer for AI Coding Agents.
3
3
  """
4
4
 
5
- __version__ = "1.3.3"
5
+ __version__ = "1.3.4"
6
6
  __author__ = "TokenSafe Team"
package/src/distiller.py CHANGED
@@ -54,7 +54,7 @@ Rules:
54
54
  "name": "Google Gemini",
55
55
  "env_key": "GEMINI_API_KEY",
56
56
  "config_key": "gemini_api_key",
57
- "default_model": "gemini-2.0-flash-lite",
57
+ "default_model": "gemini-flash-lite-latest",
58
58
  "endpoint": "https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}"
59
59
  }
60
60
  }
@@ -115,9 +115,20 @@ Rules:
115
115
  return None
116
116
 
117
117
  # Determine order
118
+ pref = preferred_provider
119
+ if not pref:
120
+ base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
121
+ config_path = os.path.join(base_dir, "data", "config.json")
122
+ if os.path.exists(config_path):
123
+ try:
124
+ with open(config_path, "r", encoding="utf-8") as f:
125
+ pref = json.load(f).get("preferred_provider")
126
+ except Exception:
127
+ pass
128
+
118
129
  order = []
119
- if preferred_provider and preferred_provider in providers:
120
- order.append(preferred_provider)
130
+ if pref and pref in providers:
131
+ order.append(pref)
121
132
  # Add remaining in priority order
122
133
  for p in ["gemini", "openai", "deepseek"]:
123
134
  if p in providers and p not in order:
package/src/mcp_server.py CHANGED
@@ -28,7 +28,7 @@ from src.diff_slicer import DiffSlicer
28
28
 
29
29
  SERVER_INFO = {
30
30
  "name": "tokensafe-mcp",
31
- "version": "1.3.3"
31
+ "version": "1.3.4"
32
32
  }
33
33
 
34
34
  TOOLS = [
package/src/proxy.py CHANGED
@@ -232,8 +232,12 @@ class TokenSafeProxyHandler(BaseHTTPRequestHandler):
232
232
  generic_upstream_key = os.environ.get("TOKENSAFE_UPSTREAM_KEY", "")
233
233
 
234
234
  # Infer upstream URL if not provided
235
+ pref = conf_keys.get("preferred_provider", "").lower()
235
236
  if not custom_url:
236
- if openai_key and not deepseek_key:
237
+ if (pref == "gemini" and gemini_key) or (gemini_key and not deepseek_key and not openai_key):
238
+ upstream_url = "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions"
239
+ resolved_key = gemini_key
240
+ elif openai_key and not deepseek_key:
237
241
  upstream_url = "https://api.openai.com/v1/chat/completions"
238
242
  resolved_key = openai_key
239
243
  elif anthropic_key and not deepseek_key:
@@ -14,7 +14,7 @@ import urllib.request
14
14
  import urllib.error
15
15
  from typing import Dict, Any, Optional, Tuple
16
16
 
17
- CURRENT_VERSION = "1.3.3"
17
+ CURRENT_VERSION = "1.3.4"
18
18
  CACHE_TTL = 86400 # 24 hours
19
19
 
20
20
  PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))