tokensafe 1.3.2 → 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.2",
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.2",
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.2"
5
+ __version__ = "1.3.4"
6
6
  __author__ = "TokenSafe Team"
package/src/dashboard.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """
2
- Terminal & Interactive HTML Dashboard for Antigravity Token Optimizer.
2
+ Terminal & Interactive HTML Dashboard for TokenSafe Context & Token Optimizer.
3
3
  Provides colorful CLI reports, Markdown exports, and rich modern HTML widgets.
4
4
  """
5
5
 
@@ -68,7 +68,7 @@ class Dashboard:
68
68
 
69
69
  out = []
70
70
  out.append(f"\n{BOLD}{CYAN}╔════════════════════════════════════════════════════════════════════╗{RESET}")
71
- out.append(f"{BOLD}{CYAN}║ ⚡ ANTIGRAVITY TOKEN OPTIMIZER DASHBOARD ⚡ ║{RESET}")
71
+ out.append(f"{BOLD}{CYAN}║ ⚡ TOKENSAFE CONTEXT OPTIMIZER DASHBOARD ⚡ ║{RESET}")
72
72
  out.append(f"{BOLD}{CYAN}╚════════════════════════════════════════════════════════════════════╝{RESET}\n")
73
73
 
74
74
  # Top summary cards
@@ -105,8 +105,8 @@ class Dashboard:
105
105
 
106
106
  out.append(f" [{DIM}{t_str}{RESET}] {CYAN}{ev_type:<15}{RESET} {detail_desc:<20} ➔ {GREEN}+{saved:,} saved{RESET} ({pct_ev:.1f}%)")
107
107
 
108
- out.append(f"\n{DIM}Run `agy-tokens test \"<prompt>\"` to test compression on custom input.{RESET}")
109
- out.append(f"{DIM}Run `agy-tokens html` to view interactive browser dashboard.{RESET}")
108
+ out.append(f"\n{DIM}Run `tokensafe test \"<prompt>\"` (or `agy-tokens`) to test compression on custom input.{RESET}")
109
+ out.append(f"{DIM}Run `tokensafe html` (or `agy-tokens html`) to view interactive browser dashboard.{RESET}")
110
110
 
111
111
  if VersionChecker:
112
112
  banner = VersionChecker.get_banner()
@@ -129,7 +129,7 @@ class Dashboard:
129
129
  opt = summary["total_optimized_tokens"]
130
130
 
131
131
  md = []
132
- md.append("# ⚡ Antigravity Token Optimizer Report\n")
132
+ md.append("# ⚡ TokenSafe Context & Token Optimizer Report\n")
133
133
  md.append(f"> **Cumulative Resource Efficiency:** **{pct:.1f}% Reduction** across {summary['total_events']} events.\n")
134
134
  md.append("| Metric | Value |")
135
135
  md.append("| :--- | :--- |")
@@ -208,7 +208,7 @@ class Dashboard:
208
208
  <head>
209
209
  <meta charset="UTF-8">
210
210
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
211
- <title>⚡ Antigravity Token Optimizer Dashboard</title>
211
+ <title>⚡ TokenSafe Context Optimizer Dashboard</title>
212
212
  <style>
213
213
  :root {{
214
214
  --bg: #090a0f;
@@ -259,8 +259,8 @@ class Dashboard:
259
259
  <div class="container">
260
260
  <div class="header">
261
261
  <div>
262
- <h1 class="title">⚡ Antigravity Token Optimizer</h1>
263
- <p class="subtitle">Next-gen Autonomous Token Economy & Context Preservation</p>
262
+ <h1 class="title">⚡ TokenSafe</h1>
263
+ <p class="subtitle">Autonomous Zero-Loss Token Economy & Context Preservation</p>
264
264
  </div>
265
265
  <div id="live-pill" class="subtitle" style="display: flex; align-items: center; gap: 6px;">
266
266
  <span style="color: #10b981;">●</span> Live SQLite Tracking
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.2"
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.2"
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__)))