tokensafe 4.12.3 → 4.12.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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.12.3",
2
+ "version": "4.12.4",
3
3
  "name": "tokensafe",
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
  "author": {
package/kimi.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokensafe",
3
- "version": "4.12.3",
3
+ "version": "4.12.4",
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": "Apache-2.0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tokensafe",
3
3
  "mcpName": "dev.tokensafe/tokensafe",
4
- "version": "4.12.3",
4
+ "version": "4.12.4",
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.12.3",
4
+ "version": "4.12.4",
5
5
  "license": "Apache-2.0",
6
6
  "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.",
7
7
  "logo": "assets/logo.png",
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.12.3",
6
+ "version": "4.12.4",
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.12.3",
26
+ "version": "4.12.4",
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.12.3",
42
+ "version": "4.12.4",
43
43
  "runtimeHint": "uvx",
44
44
  "transport": {
45
45
  "type": "stdio"
package/src/mcp_server.py CHANGED
@@ -45,7 +45,7 @@ from src.session_context import current_root, current_session_id
45
45
 
46
46
  SERVER_INFO = {
47
47
  "name": "tokensafe-mcp",
48
- "version": "4.12.3"
48
+ "version": "4.12.4"
49
49
  }
50
50
 
51
51
  # MCP client attribution: the initialize handshake carries clientInfo, which
package/src/proxy.py CHANGED
@@ -1448,6 +1448,12 @@ class TokenSafeProxyHandler(BaseHTTPRequestHandler):
1448
1448
  if isinstance(_m, dict):
1449
1449
  _m.pop("_tokensafe_thinking", None)
1450
1450
 
1451
+ # Ask OpenAI-dialect providers to emit the trailing usage chunk; without
1452
+ # it a streaming session reports no input/cache numbers at all, and the
1453
+ # cold-cache detector stays blind. Must run BEFORE the body is
1454
+ # serialized below — this cost one live-test failure to notice.
1455
+ _ensure_stream_usage(payload, provider)
1456
+
1451
1457
  headers = {"Content-Type": "application/json", "Accept-Encoding": "identity"}
1452
1458
  if provider == "anthropic":
1453
1459
  x_api_key = self.headers.get("x-api-key", "") if hasattr(self.headers, "get") else ""
@@ -1467,11 +1473,6 @@ class TokenSafeProxyHandler(BaseHTTPRequestHandler):
1467
1473
  headers=headers
1468
1474
  )
1469
1475
 
1470
- # Ask OpenAI-dialect providers to emit the trailing usage chunk; without
1471
- # it a streaming session reports no input/cache numbers at all, and the
1472
- # cold-cache detector below stays blind.
1473
- _ensure_stream_usage(payload, provider)
1474
-
1475
1476
  is_stream = bool(payload.get("stream"))
1476
1477
  req_timeout = 120.0 if is_stream else 30.0
1477
1478
  try:
@@ -311,7 +311,7 @@ class TelemetrySync:
311
311
  current_last_id = last_id
312
312
  headers = {
313
313
  "Content-Type": "application/json",
314
- "User-Agent": "TokenSafe-Sync/4.12.3"
314
+ "User-Agent": "TokenSafe-Sync/4.12.4"
315
315
  }
316
316
  if active_key:
317
317
  headers["Authorization"] = f"Bearer {active_key}"
@@ -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.12.3"
20
+ CURRENT_VERSION = "4.12.4"
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