tokensafe 4.3.0 → 4.3.2
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/.codex-plugin/plugin.json +1 -1
- package/kimi.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +3 -3
- package/src/cli.py +2 -1
- package/src/installer.py +37 -14
- package/src/mcp_server.py +1 -1
- package/src/telemetry_sync.py +16 -3
- package/src/version_checker.py +1 -1
package/kimi.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
|
|
5
5
|
"homepage": "https://tokensafe.dev",
|
|
6
6
|
"license": "MIT",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"mcpName": "dev.tokensafe/tokensafe",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.2",
|
|
5
5
|
"description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
|
|
6
6
|
"main": "bin/tokensafe.js",
|
|
7
7
|
"bin": {
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"displayName": "TokenSafe",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.2",
|
|
5
5
|
"description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
|
|
6
6
|
"logo": "assets/logo.png",
|
|
7
7
|
"developerName": "TokenSafe",
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "dev.tokensafe/tokensafe",
|
|
4
4
|
"title": "TokenSafe",
|
|
5
5
|
"description": "Your AI agent is smart enough to code all day. Local firewall & zero-loss runtime.",
|
|
6
|
-
"version": "4.3.
|
|
6
|
+
"version": "4.3.2",
|
|
7
7
|
"websiteUrl": "https://tokensafe.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/tokensafe-dev/tokensafe",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"registryType": "npm",
|
|
24
24
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
25
25
|
"identifier": "tokensafe",
|
|
26
|
-
"version": "4.3.
|
|
26
|
+
"version": "4.3.2",
|
|
27
27
|
"runtimeHint": "npx",
|
|
28
28
|
"transport": {
|
|
29
29
|
"type": "stdio"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"registryType": "pypi",
|
|
40
40
|
"registryBaseUrl": "https://pypi.org",
|
|
41
41
|
"identifier": "tokensafe",
|
|
42
|
-
"version": "4.3.
|
|
42
|
+
"version": "4.3.2",
|
|
43
43
|
"runtimeHint": "uvx",
|
|
44
44
|
"transport": {
|
|
45
45
|
"type": "stdio"
|
package/src/cli.py
CHANGED
|
@@ -405,7 +405,8 @@ def main(argv: Optional[List[str]] = None):
|
|
|
405
405
|
status = "\033[32m✔\033[0m" if r["success"] else "\033[31m✖\033[0m"
|
|
406
406
|
print(f" {status} \033[1m{r['name']:<28}\033[0m: {r['message']}")
|
|
407
407
|
print(f"\n\033[32m✔ Universal project rules injected into: {', '.join(res['project_rules'])}\033[0m\n")
|
|
408
|
-
|
|
408
|
+
# Proxy default-on is asserted INSIDE install_all (_ensure_proxy_default);
|
|
409
|
+
# the retired interactive prompt must never be referenced here again.
|
|
409
410
|
elif "--project" in args:
|
|
410
411
|
agents_plugin = None
|
|
411
412
|
if "--agents-plugin" in args:
|
package/src/installer.py
CHANGED
|
@@ -306,16 +306,23 @@ class AgentInstaller:
|
|
|
306
306
|
if not isinstance(entries, list):
|
|
307
307
|
hooks[event_name] = [default_entry]
|
|
308
308
|
return True
|
|
309
|
+
default_matcher = str(default_entry.get("matcher") or "")
|
|
309
310
|
seen = False
|
|
310
311
|
dirty = False
|
|
311
312
|
for entry in entries:
|
|
312
313
|
if isinstance(entry, dict) and isinstance(entry.get("hooks"), list):
|
|
313
314
|
for h in entry["hooks"]:
|
|
314
315
|
if isinstance(h, dict) and "claude_code_hook.py" in str(h.get("command", "")):
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
316
|
+
# Matcher-aware sync: a legacy entry with a
|
|
317
|
+
# DIFFERENT matcher covers only its own tool
|
|
318
|
+
# set (e.g. PostToolUse "Write|Edit|MultiEdit"
|
|
319
|
+
# never fires for Read), so the canonical
|
|
320
|
+
# default entry must still be appended.
|
|
321
|
+
if str(entry.get("matcher") or "") == default_matcher:
|
|
322
|
+
seen = True
|
|
323
|
+
if h.get("command") != claude_cmd:
|
|
324
|
+
h["command"] = claude_cmd
|
|
325
|
+
dirty = True
|
|
319
326
|
if not seen:
|
|
320
327
|
entries.append(default_entry)
|
|
321
328
|
dirty = True
|
|
@@ -1845,16 +1852,32 @@ WantedBy=default.target
|
|
|
1845
1852
|
cursor_mcp = os.path.join(project_dir, ".cursor", "mcp.json")
|
|
1846
1853
|
try:
|
|
1847
1854
|
os.makedirs(os.path.dirname(cursor_mcp), exist_ok=True)
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1855
|
+
# Idempotency exception: when the project ALREADY carries a
|
|
1856
|
+
# tokensafe entry (committed by the repo authors or injected
|
|
1857
|
+
# earlier), leave it verbatim — rewriting the machine-specific
|
|
1858
|
+
# PYTHON_BIN command churns tracked project files on every
|
|
1859
|
+
# `install --all` run (the tokensafe repo itself shipped exactly
|
|
1860
|
+
# this dirt: a .cursor/mcp.json diff + .backup after each run).
|
|
1861
|
+
already_present = False
|
|
1862
|
+
try:
|
|
1863
|
+
with open(cursor_mcp, "r", encoding="utf-8") as f:
|
|
1864
|
+
loaded = json.load(f)
|
|
1865
|
+
if isinstance(loaded, dict):
|
|
1866
|
+
existing = (loaded.get("mcpServers") or {}).get("tokensafe")
|
|
1867
|
+
already_present = isinstance(existing, dict) and bool(existing.get("command"))
|
|
1868
|
+
except Exception:
|
|
1869
|
+
already_present = False
|
|
1870
|
+
if not already_present:
|
|
1871
|
+
data, err = cls._load_json_with_backup(cursor_mcp)
|
|
1872
|
+
if not err and data is not None:
|
|
1873
|
+
if "mcpServers" not in data or not isinstance(data["mcpServers"], dict):
|
|
1874
|
+
data["mcpServers"] = {}
|
|
1875
|
+
data["mcpServers"]["tokensafe"] = {
|
|
1876
|
+
"command": PYTHON_BIN,
|
|
1877
|
+
"args": [MCP_SERVER_PATH]
|
|
1878
|
+
}
|
|
1879
|
+
cls._atomic_write_json(cursor_mcp, data)
|
|
1880
|
+
created.append(".cursor/mcp.json")
|
|
1858
1881
|
except Exception:
|
|
1859
1882
|
pass
|
|
1860
1883
|
|
package/src/mcp_server.py
CHANGED
package/src/telemetry_sync.py
CHANGED
|
@@ -241,7 +241,7 @@ class TelemetrySync:
|
|
|
241
241
|
current_last_id = last_id
|
|
242
242
|
headers = {
|
|
243
243
|
"Content-Type": "application/json",
|
|
244
|
-
"User-Agent": "TokenSafe-Sync/4.3.
|
|
244
|
+
"User-Agent": "TokenSafe-Sync/4.3.2"
|
|
245
245
|
}
|
|
246
246
|
if active_key:
|
|
247
247
|
headers["Authorization"] = f"Bearer {active_key}"
|
|
@@ -294,13 +294,13 @@ class TelemetrySync:
|
|
|
294
294
|
# event-type map so sync never blocks on schema drift.
|
|
295
295
|
try:
|
|
296
296
|
rows = cur.execute(
|
|
297
|
-
"SELECT id, timestamp, event_type, original_tokens, saved_tokens, est_usd_saved, details, measurement "
|
|
297
|
+
"SELECT id, timestamp, event_type, original_tokens, saved_tokens, est_usd_saved, session_id, details, measurement "
|
|
298
298
|
"FROM events WHERE id > ? ORDER BY id ASC LIMIT ?",
|
|
299
299
|
(current_last_id, page_limit)
|
|
300
300
|
).fetchall()
|
|
301
301
|
except sqlite3.OperationalError:
|
|
302
302
|
rows = cur.execute(
|
|
303
|
-
"SELECT id, timestamp, event_type, original_tokens, saved_tokens, est_usd_saved, details, "
|
|
303
|
+
"SELECT id, timestamp, event_type, original_tokens, saved_tokens, est_usd_saved, session_id, details, "
|
|
304
304
|
"NULL as measurement "
|
|
305
305
|
"FROM events WHERE id > ? ORDER BY id ASC LIMIT ?",
|
|
306
306
|
(current_last_id, page_limit)
|
|
@@ -368,6 +368,19 @@ class TelemetrySync:
|
|
|
368
368
|
agent_name = str(det.get("agent") or "")
|
|
369
369
|
except Exception:
|
|
370
370
|
pass
|
|
371
|
+
# MCP-server events carry no details.agent: the stdio process
|
|
372
|
+
# never learns the host agent directly, but the MCP initialize
|
|
373
|
+
# handshake already encodes it in the session id (mcp:<client>,
|
|
374
|
+
# e.g. mcp:zcode). Mirror MetricsTracker._infer_agent so those
|
|
375
|
+
# events land on the feed attributed instead of rendering "—".
|
|
376
|
+
if not agent_name:
|
|
377
|
+
sid = str(r["session_id"] or "")
|
|
378
|
+
if sid.startswith("mcp:"):
|
|
379
|
+
agent_name = sid[4:]
|
|
380
|
+
elif sid == "mcp_session":
|
|
381
|
+
agent_name = "mcp"
|
|
382
|
+
elif sid == "proxy_session":
|
|
383
|
+
agent_name = "proxy"
|
|
371
384
|
|
|
372
385
|
formatted_items.append((ev_id, {
|
|
373
386
|
"event_type": str(r["event_type"] or "PROMPT"),
|
package/src/version_checker.py
CHANGED
|
@@ -17,7 +17,7 @@ import urllib.request
|
|
|
17
17
|
import urllib.error
|
|
18
18
|
from typing import Dict, Any, Optional, Tuple
|
|
19
19
|
|
|
20
|
-
CURRENT_VERSION = "4.3.
|
|
20
|
+
CURRENT_VERSION = "4.3.2"
|
|
21
21
|
CACHE_TTL = 86400 # 24 hours
|
|
22
22
|
# When the cloud is unreachable we must NOT cache the synthesized "up to date"
|
|
23
23
|
# answer for a full day — otherwise an update released right after an outage
|