tokensafe 1.4.7 → 1.4.8
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/hooks/pre_invocation.py
CHANGED
|
@@ -99,7 +99,8 @@ def main():
|
|
|
99
99
|
"target_file": compaction["target_file"],
|
|
100
100
|
"symbol": compaction["symbol"],
|
|
101
101
|
"traits": compaction["traits"],
|
|
102
|
-
"tier": tier
|
|
102
|
+
"tier": tier,
|
|
103
|
+
"model": payload.get("model") or os.environ.get("AGY_MODEL") or os.environ.get("MODEL") or "gemini-3.8-flash"
|
|
103
104
|
}
|
|
104
105
|
)
|
|
105
106
|
|
|
@@ -149,7 +150,8 @@ def main():
|
|
|
149
150
|
"turns": invocation_num,
|
|
150
151
|
"total_accum_orig": orig_hist_tokens,
|
|
151
152
|
"read_files": stats.get("read_files_count", 0),
|
|
152
|
-
"edited_files": stats.get("edited_files_count", 0)
|
|
153
|
+
"edited_files": stats.get("edited_files_count", 0),
|
|
154
|
+
"model": payload.get("model") or os.environ.get("AGY_MODEL") or os.environ.get("MODEL") or "gemini-3.8-flash"
|
|
153
155
|
}
|
|
154
156
|
)
|
|
155
157
|
|
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.4.
|
|
4
|
+
"version": "1.4.8",
|
|
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/license_manager.py
CHANGED
|
@@ -16,6 +16,8 @@ from typing import Dict, Any, Tuple, Optional
|
|
|
16
16
|
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
17
17
|
DATA_DIR = os.path.join(PROJECT_ROOT, "data")
|
|
18
18
|
LICENSE_FILE = os.path.join(DATA_DIR, "license.json")
|
|
19
|
+
GLOBAL_DATA_DIR = os.path.expanduser("~/.tokensafe")
|
|
20
|
+
GLOBAL_LICENSE_FILE = os.path.join(GLOBAL_DATA_DIR, "license.json")
|
|
19
21
|
|
|
20
22
|
# Master Public Key for client-side offline verification (RFC 8032 Ed25519)
|
|
21
23
|
DEFAULT_ED25519_PUBLIC_KEY = os.environ.get("TOKENSAFE_PUBLIC_KEY", "3911e2ffe5ad07ee23be392b88f238af302f9d3a0bf51881de8b5e0e6af71430")
|
|
@@ -276,34 +278,45 @@ class LicenseManager:
|
|
|
276
278
|
|
|
277
279
|
@classmethod
|
|
278
280
|
def get_active_license_key(cls) -> str:
|
|
279
|
-
"""Retrieves active raw license key string from env or
|
|
281
|
+
"""Retrieves active raw license key string from env or persistent license.json files."""
|
|
280
282
|
key = os.environ.get("TOKENSAFE_LICENSE_KEY", "").strip()
|
|
281
|
-
if not key
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
if not key:
|
|
284
|
+
for p in (LICENSE_FILE, GLOBAL_LICENSE_FILE):
|
|
285
|
+
if os.path.exists(p):
|
|
286
|
+
try:
|
|
287
|
+
with open(p, "r", encoding="utf-8") as f:
|
|
288
|
+
data = json.load(f)
|
|
289
|
+
candidate = data.get("license_key", "").strip()
|
|
290
|
+
if candidate:
|
|
291
|
+
key = candidate
|
|
292
|
+
break
|
|
293
|
+
except Exception:
|
|
294
|
+
pass
|
|
288
295
|
return key
|
|
289
296
|
|
|
290
297
|
@classmethod
|
|
291
298
|
def save_license(cls, license_key: str) -> Tuple[bool, str]:
|
|
292
|
-
"""Saves a verified license key to local persistent storage."""
|
|
299
|
+
"""Saves a verified license key to local and user global persistent storage."""
|
|
293
300
|
valid, payload, msg = cls.validate_license(license_key)
|
|
294
301
|
if not valid:
|
|
295
302
|
return False, f"Cannot save invalid license: {msg}"
|
|
296
303
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
record = {
|
|
305
|
+
"license_key": license_key,
|
|
306
|
+
"tier": payload.get("tier"),
|
|
307
|
+
"email": payload.get("email"),
|
|
308
|
+
"expires_at": payload.get("expires_at"),
|
|
309
|
+
"trial": payload.get("trial", False),
|
|
310
|
+
"saved_at": int(time.time())
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
for target_dir, target_file in ((DATA_DIR, LICENSE_FILE), (GLOBAL_DATA_DIR, GLOBAL_LICENSE_FILE)):
|
|
314
|
+
try:
|
|
315
|
+
os.makedirs(target_dir, exist_ok=True)
|
|
316
|
+
with open(target_file, "w", encoding="utf-8") as f:
|
|
317
|
+
json.dump(record, f, indent=2)
|
|
318
|
+
except Exception:
|
|
319
|
+
pass
|
|
307
320
|
|
|
308
321
|
tier_name = payload.get("tier", "").upper()
|
|
309
322
|
trial_note = " (7-Day Trial)" if payload.get("trial") else ""
|
package/src/mcp_server.py
CHANGED
package/src/telemetry_sync.py
CHANGED
|
@@ -215,7 +215,7 @@ class TelemetrySync:
|
|
|
215
215
|
except Exception:
|
|
216
216
|
ts_int = int(time.time())
|
|
217
217
|
|
|
218
|
-
model_name = "
|
|
218
|
+
model_name = os.environ.get("AGY_MODEL") or os.environ.get("MODEL") or "gemini-3.8-flash"
|
|
219
219
|
if r["details"]:
|
|
220
220
|
try:
|
|
221
221
|
det = json.loads(r["details"]) if isinstance(r["details"], str) else r["details"]
|
|
@@ -236,7 +236,7 @@ class TelemetrySync:
|
|
|
236
236
|
total_sent = 0
|
|
237
237
|
headers = {
|
|
238
238
|
"Content-Type": "application/json",
|
|
239
|
-
"User-Agent": "TokenSafe-Sync/1.4.
|
|
239
|
+
"User-Agent": "TokenSafe-Sync/1.4.8"
|
|
240
240
|
}
|
|
241
241
|
if active_key:
|
|
242
242
|
headers["Authorization"] = f"Bearer {active_key}"
|
package/src/version_checker.py
CHANGED
|
@@ -16,7 +16,7 @@ import urllib.request
|
|
|
16
16
|
import urllib.error
|
|
17
17
|
from typing import Dict, Any, Optional, Tuple
|
|
18
18
|
|
|
19
|
-
CURRENT_VERSION = "1.4.
|
|
19
|
+
CURRENT_VERSION = "1.4.8"
|
|
20
20
|
CACHE_TTL = 86400 # 24 hours
|
|
21
21
|
|
|
22
22
|
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
Binary file
|