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 +1 -1
- package/plugin.json +1 -1
- package/src/__init__.py +1 -1
- package/src/distiller.py +14 -3
- package/src/mcp_server.py +1 -1
- package/src/proxy.py +5 -1
- package/src/version_checker.py +1 -1
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-token-optimizer",
|
|
3
3
|
"displayName": "TokenSafe",
|
|
4
|
-
"version": "1.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
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-
|
|
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
|
|
120
|
-
order.append(
|
|
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
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
|
|
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:
|
package/src/version_checker.py
CHANGED
|
@@ -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.
|
|
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__)))
|