tokensafe 4.7.9 → 4.7.12
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/bin/tokensafe.js +24 -1
- package/kimi.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +3 -3
- package/src/auto_inject.py +91 -52
- package/src/installer.py +17 -10
- package/src/mcp_server.py +133 -14
- package/src/oumv_gateway.py +376 -52
- package/src/retrofit.py +5 -12
- package/src/telemetry_sync.py +1 -1
- package/src/version_checker.py +1 -1
package/bin/tokensafe.js
CHANGED
|
@@ -244,7 +244,23 @@ function download(url, dest, expectedSize, redirects) {
|
|
|
244
244
|
|
|
245
245
|
function extractArchive(archive, destDir) {
|
|
246
246
|
fs.mkdirSync(destDir, { recursive: true });
|
|
247
|
-
|
|
247
|
+
// Windows: GNU tar (the one Git for Windows ships) reads `D:\...` as a remote
|
|
248
|
+
// host and fails with "Cannot connect to D:". Copying the archive next to the
|
|
249
|
+
// target and extracting it by relative name keeps the drive letter out of the
|
|
250
|
+
// argument list, which works for both GNU tar and bsdtar.
|
|
251
|
+
const localArchive = path.join(destDir, `.runtime${path.extname(archive) || '.tgz'}`);
|
|
252
|
+
fs.copyFileSync(archive, localArchive);
|
|
253
|
+
const res = spawnSync('tar', ['-xzf', path.basename(localArchive)], {
|
|
254
|
+
cwd: destDir,
|
|
255
|
+
encoding: 'utf-8',
|
|
256
|
+
stdio: 'pipe',
|
|
257
|
+
timeout: 600000,
|
|
258
|
+
});
|
|
259
|
+
try {
|
|
260
|
+
fs.rmSync(localArchive, { force: true });
|
|
261
|
+
} catch (_) {
|
|
262
|
+
/* the extraction verdict matters more than the leftover */
|
|
263
|
+
}
|
|
248
264
|
if (res.status !== 0) {
|
|
249
265
|
const detail = ((res.stderr || '') || (res.error && res.error.message) || '').trim();
|
|
250
266
|
throw new Error(`failed to extract the runtime archive${detail ? `: ${detail}` : ''}`);
|
|
@@ -366,6 +382,13 @@ async function findPython(options = {}) {
|
|
|
366
382
|
fail(`TOKENSAFE_PYTHON=${pinned} is not a usable CPython ${MIN_PYTHON[0]}.${MIN_PYTHON[1]}+ with 'cryptography'.`);
|
|
367
383
|
}
|
|
368
384
|
|
|
385
|
+
// CI and support repros need the managed path even when the machine happens to
|
|
386
|
+
// have a suitable CPython: without this the provisioner is never exercised on
|
|
387
|
+
// the runners, which is exactly how a broken Linux/Windows archive ships.
|
|
388
|
+
if ((process.env.TOKENSAFE_FORCE_MANAGED_RUNTIME || '').trim() === '1') {
|
|
389
|
+
return allowProvision ? await ensureManagedRuntime() : null;
|
|
390
|
+
}
|
|
391
|
+
|
|
369
392
|
const candidates = [];
|
|
370
393
|
const venvPy = venvPythonPath();
|
|
371
394
|
if (fs.existsSync(venvPy)) candidates.push(venvPy);
|
package/kimi.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.12",
|
|
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.7.
|
|
4
|
+
"version": "4.7.12",
|
|
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.7.
|
|
4
|
+
"version": "4.7.12",
|
|
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.7.
|
|
6
|
+
"version": "4.7.12",
|
|
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.7.
|
|
26
|
+
"version": "4.7.12",
|
|
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.7.
|
|
42
|
+
"version": "4.7.12",
|
|
43
43
|
"runtimeHint": "uvx",
|
|
44
44
|
"transport": {
|
|
45
45
|
"type": "stdio"
|
package/src/auto_inject.py
CHANGED
|
@@ -18,6 +18,7 @@ Two very different injection strategies live here, because the runtimes differ:
|
|
|
18
18
|
|
|
19
19
|
from __future__ import annotations
|
|
20
20
|
|
|
21
|
+
import glob
|
|
21
22
|
import hashlib
|
|
22
23
|
import json
|
|
23
24
|
import os
|
|
@@ -63,6 +64,51 @@ def _inject_dir(workspace: str) -> str:
|
|
|
63
64
|
return os.path.join(_tokensafe_home(), _INJECT_DIRNAME, _workspace_id(workspace))
|
|
64
65
|
|
|
65
66
|
|
|
67
|
+
def _manifest_path(workspace: str, kind: str) -> str:
|
|
68
|
+
"""One manifest per adapter kind: a monorepo can carry a Go patch and a .NET
|
|
69
|
+
patch at once, and a single shared file would lose the first one's backup."""
|
|
70
|
+
return os.path.join(_inject_dir(workspace), "manifests", f"{kind}.json")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _write_manifest(workspace: str, kind: str, payload: Dict[str, Any]) -> str:
|
|
74
|
+
path = _manifest_path(workspace, kind)
|
|
75
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
76
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
77
|
+
json.dump(payload, f, indent=2)
|
|
78
|
+
return path
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _read_manifest(workspace: str, kind: str, legacy_modes: tuple) -> Optional[Dict[str, Any]]:
|
|
82
|
+
"""Own manifest first; a legacy single manifest.json only when its mode belongs
|
|
83
|
+
to this adapter (the old file was shared by every kind)."""
|
|
84
|
+
own = _manifest_path(workspace, kind)
|
|
85
|
+
if os.path.isfile(own):
|
|
86
|
+
try:
|
|
87
|
+
with open(own, "r", encoding="utf-8") as f:
|
|
88
|
+
data = json.load(f)
|
|
89
|
+
data["_manifest"] = own
|
|
90
|
+
return data
|
|
91
|
+
except Exception:
|
|
92
|
+
return None
|
|
93
|
+
legacy = os.path.join(_inject_dir(workspace), "manifest.json")
|
|
94
|
+
if os.path.isfile(legacy):
|
|
95
|
+
try:
|
|
96
|
+
with open(legacy, "r", encoding="utf-8") as f:
|
|
97
|
+
data = json.load(f)
|
|
98
|
+
except Exception:
|
|
99
|
+
return None
|
|
100
|
+
if data.get("mode") in legacy_modes:
|
|
101
|
+
data["_manifest"] = legacy
|
|
102
|
+
return data
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _delete_manifest(manifest: Dict[str, Any]) -> None:
|
|
107
|
+
path = manifest.get("_manifest")
|
|
108
|
+
if path and os.path.isfile(path):
|
|
109
|
+
os.unlink(path)
|
|
110
|
+
|
|
111
|
+
|
|
66
112
|
def pyhooks_dir() -> str:
|
|
67
113
|
return os.path.join(_tokensafe_home(), _PYHOOKS_DIRNAME)
|
|
68
114
|
|
|
@@ -235,7 +281,7 @@ def go_patch_state(workspace: str) -> Dict[str, Any]:
|
|
|
235
281
|
_GO_MODULE = "github.com/tokensafe-dev/tokensafe-backend/go"
|
|
236
282
|
# Keep in step with the backend release tag (go/vX.Y.Z): injection must never
|
|
237
283
|
# downgrade an adapter that is already newer than this pin.
|
|
238
|
-
_GO_MODULE_VERSION = "v0.
|
|
284
|
+
_GO_MODULE_VERSION = "v0.9.2"
|
|
239
285
|
|
|
240
286
|
|
|
241
287
|
def _version_tuple(tag: str):
|
|
@@ -454,17 +500,12 @@ def apply_go_patch(workspace: str, dry_run: bool = False) -> Dict[str, Any]:
|
|
|
454
500
|
"build_output": build_output[-1200:],
|
|
455
501
|
}
|
|
456
502
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
"mode": "serve" if wrapped is not None else "mount",
|
|
464
|
-
},
|
|
465
|
-
f,
|
|
466
|
-
indent=2,
|
|
467
|
-
)
|
|
503
|
+
_write_manifest(workspace, "go", {
|
|
504
|
+
"entrypoint": path,
|
|
505
|
+
"backup": backup_path,
|
|
506
|
+
"framework": framework,
|
|
507
|
+
"mode": "serve" if wrapped is not None else "mount",
|
|
508
|
+
})
|
|
468
509
|
|
|
469
510
|
return {
|
|
470
511
|
"status": "patched",
|
|
@@ -494,17 +535,15 @@ def _go_build(workspace: str) -> Tuple[bool, str]:
|
|
|
494
535
|
|
|
495
536
|
|
|
496
537
|
def revert_go_patch(workspace: str) -> Dict[str, Any]:
|
|
497
|
-
|
|
498
|
-
if
|
|
538
|
+
manifest = _read_manifest(workspace, "go", ("serve", "mount", "go_patch"))
|
|
539
|
+
if manifest is None:
|
|
499
540
|
return {"status": "nothing-to-revert"}
|
|
500
|
-
with open(manifest_path, "r", encoding="utf-8") as f:
|
|
501
|
-
manifest = json.load(f)
|
|
502
541
|
target = manifest.get("entrypoint")
|
|
503
542
|
backup = manifest.get("backup")
|
|
504
543
|
if not target or not backup or not os.path.isfile(backup):
|
|
505
544
|
return {"status": "error", "reason": "backup missing"}
|
|
506
545
|
shutil.copy2(backup, target)
|
|
507
|
-
|
|
546
|
+
_delete_manifest(manifest)
|
|
508
547
|
return {"status": "reverted", "entrypoint": os.path.relpath(target, workspace)}
|
|
509
548
|
|
|
510
549
|
|
|
@@ -612,8 +651,7 @@ def apply_node_patch(workspace: str, dry_run: bool = False) -> Dict[str, Any]:
|
|
|
612
651
|
shutil.copy2(path, backup_path)
|
|
613
652
|
with open(path, "w", encoding="utf-8") as f:
|
|
614
653
|
f.write(patched)
|
|
615
|
-
|
|
616
|
-
json.dump({"entrypoint": path, "backup": backup_path, "framework": framework, "mode": "node_mount"}, f, indent=2)
|
|
654
|
+
_write_manifest(workspace, "node", {"entrypoint": path, "backup": backup_path, "framework": framework})
|
|
617
655
|
return {
|
|
618
656
|
"status": "patched",
|
|
619
657
|
"entrypoint": os.path.relpath(path, workspace),
|
|
@@ -625,22 +663,15 @@ def apply_node_patch(workspace: str, dry_run: bool = False) -> Dict[str, Any]:
|
|
|
625
663
|
|
|
626
664
|
|
|
627
665
|
def revert_node_patch(workspace: str) -> Dict[str, Any]:
|
|
628
|
-
|
|
629
|
-
if
|
|
666
|
+
manifest = _read_manifest(workspace, "node", ("node_mount",))
|
|
667
|
+
if manifest is None:
|
|
630
668
|
return {"status": "clean", "reason": "no Node patch manifest"}
|
|
631
|
-
try:
|
|
632
|
-
with open(manifest_path, "r", encoding="utf-8") as f:
|
|
633
|
-
manifest = json.load(f)
|
|
634
|
-
except Exception as exc:
|
|
635
|
-
return {"status": "error", "reason": f"cannot read manifest: {exc}"}
|
|
636
|
-
if manifest.get("mode") != "node_mount":
|
|
637
|
-
return {"status": "clean", "reason": "manifest is not a Node patch"}
|
|
638
669
|
entrypoint = manifest.get("entrypoint")
|
|
639
670
|
backup = manifest.get("backup")
|
|
640
671
|
if not (entrypoint and backup and os.path.isfile(backup)):
|
|
641
672
|
return {"status": "error", "reason": "backup missing; restore manually"}
|
|
642
673
|
shutil.copy2(backup, entrypoint)
|
|
643
|
-
|
|
674
|
+
_delete_manifest(manifest)
|
|
644
675
|
return {"status": "reverted", "entrypoint": os.path.relpath(entrypoint, workspace)}
|
|
645
676
|
|
|
646
677
|
|
|
@@ -658,8 +689,26 @@ def _sidecar_cache_dir() -> str:
|
|
|
658
689
|
_DOTNET_MARK_BEGIN = "// tokensafe:oumv:begin"
|
|
659
690
|
_DOTNET_MARK_END = "// tokensafe:oumv:end"
|
|
660
691
|
_DOTNET_PACKAGE = "TokenSafe.Oumv.AspNetCore"
|
|
661
|
-
_DOTNET_PACKAGE_VERSION = "0.1.
|
|
692
|
+
_DOTNET_PACKAGE_VERSION = "0.1.1"
|
|
693
|
+
|
|
694
|
+
|
|
662
695
|
|
|
696
|
+
def _dotnet_cli() -> str:
|
|
697
|
+
"""Resolves the dotnet executable: explicit override, then DOTNET_ROOT, then PATH.
|
|
698
|
+
|
|
699
|
+
A machine can carry an old SDK on PATH (this one had 7.0) while a current one
|
|
700
|
+
lives under DOTNET_ROOT; the build pre-flight must use the latter or a net10
|
|
701
|
+
project fails to compile for the wrong reason.
|
|
702
|
+
"""
|
|
703
|
+
override = os.environ.get("TOKENSAFE_DOTNET")
|
|
704
|
+
if override and os.path.isfile(override):
|
|
705
|
+
return override
|
|
706
|
+
root = os.environ.get("DOTNET_ROOT")
|
|
707
|
+
if root:
|
|
708
|
+
candidate = os.path.join(root, "dotnet.exe" if os.name == "nt" else "dotnet")
|
|
709
|
+
if os.path.isfile(candidate):
|
|
710
|
+
return candidate
|
|
711
|
+
return "dotnet"
|
|
663
712
|
|
|
664
713
|
def _dotnet_web_project(workspace: str) -> Optional[str]:
|
|
665
714
|
"""Finds a web csproj (Microsoft.NET.Sdk.Web or the ASP.NET Core framework reference)."""
|
|
@@ -710,7 +759,7 @@ def dotnet_patch_state(workspace: str) -> Dict[str, Any]:
|
|
|
710
759
|
def _dotnet_build(project: str) -> Tuple[bool, str]:
|
|
711
760
|
try:
|
|
712
761
|
result = subprocess.run(
|
|
713
|
-
[
|
|
762
|
+
[_dotnet_cli(), "build", project, "-c", "Release", "--nologo", "-v", "quiet"],
|
|
714
763
|
capture_output=True,
|
|
715
764
|
text=True,
|
|
716
765
|
timeout=600,
|
|
@@ -733,7 +782,7 @@ def _ensure_dotnet_dependency(project: str) -> Optional[str]:
|
|
|
733
782
|
return None
|
|
734
783
|
try:
|
|
735
784
|
result = subprocess.run(
|
|
736
|
-
[
|
|
785
|
+
[_dotnet_cli(), "add", project, "package", _DOTNET_PACKAGE, "--version", _DOTNET_PACKAGE_VERSION],
|
|
737
786
|
capture_output=True,
|
|
738
787
|
text=True,
|
|
739
788
|
timeout=300,
|
|
@@ -833,12 +882,8 @@ def apply_dotnet_patch(workspace: str, dry_run: bool = False) -> Dict[str, Any]:
|
|
|
833
882
|
"build": build_output[-800:],
|
|
834
883
|
}
|
|
835
884
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
{"entrypoint": entrypoint, "backup": backup_path, "framework": "aspnetcore", "mode": "dotnet_mount"},
|
|
839
|
-
handle,
|
|
840
|
-
indent=2,
|
|
841
|
-
)
|
|
885
|
+
_write_manifest(workspace, "dotnet",
|
|
886
|
+
{"entrypoint": entrypoint, "backup": backup_path, "framework": "aspnetcore"})
|
|
842
887
|
return {
|
|
843
888
|
"status": "patched",
|
|
844
889
|
"entrypoint": os.path.relpath(entrypoint, workspace),
|
|
@@ -851,39 +896,32 @@ def apply_dotnet_patch(workspace: str, dry_run: bool = False) -> Dict[str, Any]:
|
|
|
851
896
|
|
|
852
897
|
|
|
853
898
|
def revert_dotnet_patch(workspace: str) -> Dict[str, Any]:
|
|
854
|
-
|
|
855
|
-
if
|
|
899
|
+
manifest = _read_manifest(workspace, "dotnet", ("dotnet_mount",))
|
|
900
|
+
if manifest is None:
|
|
856
901
|
return {"status": "clean", "reason": "no .NET patch manifest"}
|
|
857
|
-
try:
|
|
858
|
-
with open(manifest_path, "r", encoding="utf-8") as handle:
|
|
859
|
-
manifest = json.load(handle)
|
|
860
|
-
except Exception as exc:
|
|
861
|
-
return {"status": "error", "reason": f"cannot read manifest: {exc}"}
|
|
862
|
-
if manifest.get("mode") != "dotnet_mount":
|
|
863
|
-
return {"status": "clean", "reason": "manifest is not a .NET patch"}
|
|
864
902
|
entrypoint = manifest.get("entrypoint")
|
|
865
903
|
backup = manifest.get("backup")
|
|
866
904
|
if not (entrypoint and backup and os.path.isfile(backup)):
|
|
867
905
|
return {"status": "error", "reason": "backup missing; restore manually"}
|
|
868
906
|
shutil.copy2(backup, entrypoint)
|
|
869
|
-
|
|
907
|
+
_delete_manifest(manifest)
|
|
870
908
|
return {"status": "reverted", "entrypoint": os.path.relpath(entrypoint, workspace)}
|
|
871
909
|
|
|
872
910
|
|
|
873
911
|
# Pinned to the backend release: the sidecars are single files, so the cache is
|
|
874
912
|
# content-addressed by SHA-256 and a clean machine downloads the exact bytes the
|
|
875
913
|
# release was certified from. Bump both the tag and the hashes together.
|
|
876
|
-
_SIDECAR_RELEASE_TAG = "v0.
|
|
914
|
+
_SIDECAR_RELEASE_TAG = "v0.9.2"
|
|
877
915
|
_SIDECARS = {
|
|
878
916
|
"spring": (
|
|
879
917
|
"java/src/dev/tokensafe/oumv/OumvSpring.java",
|
|
880
918
|
"OumvSpring.java",
|
|
881
|
-
"
|
|
919
|
+
"45aa63f2c71cf25065f591ebd589b21c7c7c58d218f3dce45880af0e1f1e7d81",
|
|
882
920
|
),
|
|
883
921
|
"php": (
|
|
884
922
|
"php/bin/oumv-php",
|
|
885
923
|
"oumv-php",
|
|
886
|
-
"
|
|
924
|
+
"660e7f53cc3799bd700cea2173f672594a5b8bc33e26cfa91ee559aec66f325a",
|
|
887
925
|
),
|
|
888
926
|
}
|
|
889
927
|
|
|
@@ -1085,7 +1123,8 @@ def plan(workspace: str) -> Dict[str, Any]:
|
|
|
1085
1123
|
"profiles": [p for p in ("frontend", "backend") if stack.get(p)],
|
|
1086
1124
|
"actions": actions,
|
|
1087
1125
|
"python_autoload_present": python_autoload_present(),
|
|
1088
|
-
"revertable":
|
|
1126
|
+
"revertable": bool(glob.glob(os.path.join(_inject_dir(workspace), "manifests", "*.json")))
|
|
1127
|
+
or os.path.isfile(os.path.join(_inject_dir(workspace), "manifest.json")),
|
|
1089
1128
|
}
|
|
1090
1129
|
|
|
1091
1130
|
|
package/src/installer.py
CHANGED
|
@@ -2345,7 +2345,7 @@ WantedBy=default.target
|
|
|
2345
2345
|
"message": "; ".join(msgs) if msgs else "Cleaned"
|
|
2346
2346
|
}
|
|
2347
2347
|
|
|
2348
|
-
cls.restart_mcp_daemons()
|
|
2348
|
+
cls.restart_mcp_daemons(kill_running=True)
|
|
2349
2349
|
proj_report = cls.uninstall_project(os.getcwd())
|
|
2350
2350
|
|
|
2351
2351
|
purged = False
|
|
@@ -2429,7 +2429,7 @@ WantedBy=default.target
|
|
|
2429
2429
|
else:
|
|
2430
2430
|
print(f" \033[33m–\033[0m \033[1m{name}\033[0m: Nothing to remove")
|
|
2431
2431
|
|
|
2432
|
-
cls.restart_mcp_daemons()
|
|
2432
|
+
cls.restart_mcp_daemons(kill_running=True)
|
|
2433
2433
|
proj_rep = cls.uninstall_project(os.getcwd())
|
|
2434
2434
|
if proj_rep.get("cleaned_rules"):
|
|
2435
2435
|
print(f"\n\033[32m✔ Cleaned project rules from: {', '.join(proj_rep['cleaned_rules'])}\033[0m")
|
|
@@ -2482,10 +2482,16 @@ WantedBy=default.target
|
|
|
2482
2482
|
return False
|
|
2483
2483
|
|
|
2484
2484
|
@classmethod
|
|
2485
|
-
def restart_mcp_daemons(cls) -> int:
|
|
2485
|
+
def restart_mcp_daemons(cls, kill_running: bool = False) -> int:
|
|
2486
2486
|
"""
|
|
2487
|
-
Touches the MCP reload marker
|
|
2488
|
-
|
|
2487
|
+
Touches the MCP reload marker so auto-reconnecting IDEs (Antigravity, Cursor,
|
|
2488
|
+
Claude Code) spawn the updated version.
|
|
2489
|
+
|
|
2490
|
+
By default nothing is killed: running TokenSafe MCP servers belong to live
|
|
2491
|
+
sessions of any host, and a machine-wide SIGTERM during an update kills
|
|
2492
|
+
concurrent sessions' gateways (session-scoped MCP hosts never respawn them).
|
|
2493
|
+
Uninstall flows pass kill_running=True because removing TokenSafe should
|
|
2494
|
+
stop it everywhere.
|
|
2489
2495
|
"""
|
|
2490
2496
|
try:
|
|
2491
2497
|
# Data-dir resolution is context-independent (canonical
|
|
@@ -2500,7 +2506,7 @@ WantedBy=default.target
|
|
|
2500
2506
|
except Exception:
|
|
2501
2507
|
pass
|
|
2502
2508
|
|
|
2503
|
-
if os.name == "nt":
|
|
2509
|
+
if not kill_running or os.name == "nt":
|
|
2504
2510
|
return 0
|
|
2505
2511
|
|
|
2506
2512
|
my_pid = os.getpid()
|
|
@@ -2906,11 +2912,12 @@ WantedBy=default.target
|
|
|
2906
2912
|
except Exception:
|
|
2907
2913
|
pass
|
|
2908
2914
|
|
|
2909
|
-
# 6.
|
|
2915
|
+
# 6. Flag the reload so auto-reconnecting IDEs pick the new version.
|
|
2916
|
+
# Running servers are NOT killed: they belong to live sessions of
|
|
2917
|
+
# other agents, and session-scoped MCP hosts never respawn them.
|
|
2910
2918
|
restarted_count = cls.restart_mcp_daemons()
|
|
2911
|
-
if restarted_count
|
|
2912
|
-
print(f" {
|
|
2913
|
-
print(f" {CYAN}ℹ{RESET} Antigravity/Cursor/Claude Code reconnect automatically; reload MCP in Claude Desktop/VS Code if disconnected.")
|
|
2919
|
+
if restarted_count == 0:
|
|
2920
|
+
print(f" {CYAN}ℹ{RESET} Reload marker written; running sessions keep their current engine until restarted (by design).")
|
|
2914
2921
|
|
|
2915
2922
|
# 7. Proxy re-assertion (ultimate, default-on): TokenSafe is the default LLM
|
|
2916
2923
|
# route for every wire-able agent. Agent/app updates are known to rewrite
|