tokensafe 2.0.0 → 2.0.1
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/server.json +3 -3
- package/src/mcp_server.py +1 -1
- package/src/telemetry_sync.py +1 -1
- package/src/version_checker.py +38 -9
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": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
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/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "dev.tokensafe/tokensafe",
|
|
4
4
|
"title": "TokenSafe",
|
|
5
5
|
"description": "Cut AI coding agent token usage up to 90% via AST slicing, dependency graphs & security guards.",
|
|
6
|
-
"version": "2.0.
|
|
6
|
+
"version": "2.0.1",
|
|
7
7
|
"websiteUrl": "https://tokensafe.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/NekoSin4eG/tokensafe",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"registryType": "npm",
|
|
31
31
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
32
32
|
"identifier": "tokensafe",
|
|
33
|
-
"version": "2.0.
|
|
33
|
+
"version": "2.0.1",
|
|
34
34
|
"runtimeHint": "npx",
|
|
35
35
|
"transport": {
|
|
36
36
|
"type": "stdio"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"registryType": "pypi",
|
|
47
47
|
"registryBaseUrl": "https://pypi.org",
|
|
48
48
|
"identifier": "tokensafe",
|
|
49
|
-
"version": "2.0.
|
|
49
|
+
"version": "2.0.1",
|
|
50
50
|
"runtimeHint": "uvx",
|
|
51
51
|
"transport": {
|
|
52
52
|
"type": "stdio"
|
package/src/mcp_server.py
CHANGED
package/src/telemetry_sync.py
CHANGED
|
@@ -264,7 +264,7 @@ class TelemetrySync:
|
|
|
264
264
|
rollup_synced = bool(state.get("lifetime_rollup_synced", False))
|
|
265
265
|
headers = {
|
|
266
266
|
"Content-Type": "application/json",
|
|
267
|
-
"User-Agent": "TokenSafe-Sync/2.0.
|
|
267
|
+
"User-Agent": "TokenSafe-Sync/2.0.1"
|
|
268
268
|
}
|
|
269
269
|
if active_key:
|
|
270
270
|
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 = "2.0.
|
|
19
|
+
CURRENT_VERSION = "2.0.1"
|
|
20
20
|
CACHE_TTL = 86400 # 24 hours
|
|
21
21
|
# When the cloud is unreachable we must NOT cache the synthesized "up to date"
|
|
22
22
|
# answer for a full day — otherwise an update released right after an outage
|
|
@@ -331,15 +331,44 @@ class VersionChecker:
|
|
|
331
331
|
if not force and last_notified_ver == latest and (now - last_notified_at) < CACHE_TTL:
|
|
332
332
|
return False
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
# Cross-process claim: several agent hook processes can pass the 24h
|
|
335
|
+
# cache check simultaneously (Antigravity + ZCode + adapters), which
|
|
336
|
+
# rendered the update dialog TWICE. Only the process that wins the
|
|
337
|
+
# O_EXCL claim shows the dialog; the claim self-expires.
|
|
338
|
+
claim_path = os.path.join(DATA_DIR, ".update_dialog.claim")
|
|
339
|
+
try:
|
|
340
|
+
if os.path.exists(claim_path):
|
|
341
|
+
if (now - os.path.getmtime(claim_path)) < 60:
|
|
342
|
+
return False
|
|
343
|
+
os.remove(claim_path) # stale claim: safe to reclaim (O_EXCL guards the race)
|
|
344
|
+
fd = os.open(claim_path, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
|
|
345
|
+
os.write(fd, str(os.getpid()).encode("utf-8"))
|
|
346
|
+
os.close(fd)
|
|
347
|
+
except FileExistsError:
|
|
348
|
+
return False
|
|
349
|
+
except OSError:
|
|
350
|
+
pass # claim is best-effort; never block the dialog entirely on fs errors
|
|
351
|
+
|
|
352
|
+
try:
|
|
353
|
+
cached["last_os_notify_version"] = latest
|
|
354
|
+
cached["last_os_notify_at"] = now
|
|
355
|
+
cls.save_cache(cached)
|
|
356
|
+
except Exception:
|
|
357
|
+
pass
|
|
337
358
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
359
|
+
try:
|
|
360
|
+
dispatched = cls.show_os_dialog(
|
|
361
|
+
current_version=current_version,
|
|
362
|
+
latest_version=latest,
|
|
363
|
+
update_command=cmd
|
|
364
|
+
)
|
|
365
|
+
return dispatched
|
|
366
|
+
finally:
|
|
367
|
+
# Release the dialog claim so a future version can notify again.
|
|
368
|
+
try:
|
|
369
|
+
os.remove(claim_path)
|
|
370
|
+
except OSError:
|
|
371
|
+
pass
|
|
343
372
|
|
|
344
373
|
@classmethod
|
|
345
374
|
def notify_os_update_background(
|