tokensafe 1.4.6 → 1.4.7
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.
|
Binary file
|
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.7",
|
|
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/mcp_server.py
CHANGED
package/src/telemetry_sync.py
CHANGED
|
@@ -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.7"
|
|
240
240
|
}
|
|
241
241
|
if active_key:
|
|
242
242
|
headers["Authorization"] = f"Bearer {active_key}"
|
|
@@ -333,15 +333,7 @@ class TelemetrySync:
|
|
|
333
333
|
creationflags=flags
|
|
334
334
|
)
|
|
335
335
|
except Exception:
|
|
336
|
-
|
|
337
|
-
def _worker():
|
|
338
|
-
try:
|
|
339
|
-
cls.sync(timeout=2.0)
|
|
340
|
-
except Exception:
|
|
341
|
-
pass
|
|
342
|
-
|
|
343
|
-
t = threading.Thread(target=_worker, daemon=True)
|
|
344
|
-
t.start()
|
|
336
|
+
pass
|
|
345
337
|
|
|
346
338
|
|
|
347
339
|
if __name__ == "__main__":
|
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.7"
|
|
20
20
|
CACHE_TTL = 86400 # 24 hours
|
|
21
21
|
|
|
22
22
|
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
@@ -317,18 +317,51 @@ class VersionChecker:
|
|
|
317
317
|
force: bool = False
|
|
318
318
|
):
|
|
319
319
|
"""
|
|
320
|
-
Dispatches notify_os_update in a
|
|
320
|
+
Dispatches notify_os_update in a detached, non-blocking background OS process.
|
|
321
|
+
Avoids in-process daemon threads to prevent OpenSSL cleanup SIGSEGV races during fast CLI exit.
|
|
321
322
|
"""
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
323
|
+
now = int(time.time())
|
|
324
|
+
cached = cls.load_cache()
|
|
325
|
+
if not force and cached:
|
|
326
|
+
checked_at = cached.get("checked_at", 0)
|
|
327
|
+
update_available = cached.get("update_available", False)
|
|
328
|
+
latest = cached.get("latest_version", current_version)
|
|
329
|
+
last_notified_ver = cached.get("last_os_notify_version", "")
|
|
330
|
+
last_notified_at = cached.get("last_os_notify_at", 0)
|
|
331
|
+
|
|
332
|
+
# If cache is valid and no update is available, skip completely
|
|
333
|
+
if now - checked_at < CACHE_TTL and not update_available:
|
|
334
|
+
return
|
|
335
|
+
|
|
336
|
+
# If update is available but user was already notified within 24h, skip
|
|
337
|
+
if update_available and last_notified_ver == latest and (now - last_notified_at < CACHE_TTL):
|
|
338
|
+
return
|
|
332
339
|
|
|
333
|
-
|
|
334
|
-
|
|
340
|
+
try:
|
|
341
|
+
flags = 0
|
|
342
|
+
if os.name == "nt":
|
|
343
|
+
flags = subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.DETACHED_PROCESS
|
|
344
|
+
script_path = os.path.abspath(__file__)
|
|
345
|
+
cmd = [sys.executable, script_path, "--check-bg"]
|
|
346
|
+
if force:
|
|
347
|
+
cmd.append("--force")
|
|
348
|
+
subprocess.Popen(
|
|
349
|
+
cmd,
|
|
350
|
+
cwd=PROJECT_ROOT,
|
|
351
|
+
stdout=subprocess.DEVNULL,
|
|
352
|
+
stderr=subprocess.DEVNULL,
|
|
353
|
+
stdin=subprocess.DEVNULL,
|
|
354
|
+
start_new_session=(os.name != "nt"),
|
|
355
|
+
creationflags=flags
|
|
356
|
+
)
|
|
357
|
+
except Exception:
|
|
358
|
+
pass
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
if __name__ == "__main__":
|
|
362
|
+
if "--check-bg" in sys.argv:
|
|
363
|
+
try:
|
|
364
|
+
is_force = "--force" in sys.argv
|
|
365
|
+
VersionChecker.notify_os_update(force=is_force)
|
|
366
|
+
except Exception:
|
|
367
|
+
pass
|