tokensafe 4.7.18 → 4.7.19
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 +40 -17
- package/kimi.plugin.json +1 -1
- 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 +1 -1
package/bin/tokensafe.js
CHANGED
|
@@ -71,19 +71,40 @@ function venvPythonPath() {
|
|
|
71
71
|
/**
|
|
72
72
|
* Returns the interpreter's own path when it is a usable CPython >= 3.10,
|
|
73
73
|
* optionally requiring importable runtime dependencies. null otherwise.
|
|
74
|
+
*
|
|
75
|
+
* `command` is a name, a path, or an argv prefix for the Windows `py` launcher.
|
|
74
76
|
*/
|
|
75
|
-
function probePython(
|
|
77
|
+
function probePython(command, requireDeps) {
|
|
78
|
+
const argv = Array.isArray(command) ? command : [command];
|
|
76
79
|
const imports = requireDeps ? 'import sys, cryptography' : 'import sys';
|
|
77
80
|
const probe = `${imports}; assert sys.version_info >= (${MIN_PYTHON[0]}, ${MIN_PYTHON[1]}); print(sys.executable)`;
|
|
78
81
|
try {
|
|
79
|
-
const res = spawnSync(
|
|
82
|
+
const res = spawnSync(argv[0], [...argv.slice(1), '-c', probe], { encoding: 'utf-8', stdio: 'pipe', timeout: 20000 });
|
|
80
83
|
if (res.status !== 0) return null;
|
|
81
|
-
return (res.stdout || '').trim() ||
|
|
84
|
+
return (res.stdout || '').trim() || argv[0];
|
|
82
85
|
} catch (_) {
|
|
83
86
|
return null;
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Interpreters to try, most specific first.
|
|
92
|
+
*
|
|
93
|
+
* The venv this launcher owns comes first, then the PATH names. On Windows the
|
|
94
|
+
* python.org installer can leave python.exe off PATH while `py` (the launcher)
|
|
95
|
+
* lands in C:\Windows regardless, so `py -3` is probed too: without it a
|
|
96
|
+
* perfectly good CPython is skipped and the 47 MB managed runtime downloads for
|
|
97
|
+
* nothing.
|
|
98
|
+
*/
|
|
99
|
+
function pythonCandidates() {
|
|
100
|
+
const candidates = [];
|
|
101
|
+
const venvPy = venvPythonPath();
|
|
102
|
+
if (fs.existsSync(venvPy)) candidates.push([venvPy]);
|
|
103
|
+
candidates.push(['python3'], ['python']);
|
|
104
|
+
if (process.platform === 'win32') candidates.push(['py', '-3']);
|
|
105
|
+
return candidates;
|
|
106
|
+
}
|
|
107
|
+
|
|
87
108
|
function moduleAvailable(cmd, name) {
|
|
88
109
|
try {
|
|
89
110
|
return spawnSync(cmd, ['-c', `import ${name}`], { stdio: 'pipe', timeout: 20000 }).status === 0;
|
|
@@ -373,12 +394,14 @@ async function findPython(options = {}) {
|
|
|
373
394
|
const { allowProvision = true, requireDeps = true } = options;
|
|
374
395
|
const pinned = (process.env.TOKENSAFE_PYTHON || '').trim();
|
|
375
396
|
if (pinned) {
|
|
376
|
-
|
|
377
|
-
if (
|
|
378
|
-
|
|
397
|
+
const withDeps = probePython(pinned, true);
|
|
398
|
+
if (withDeps) return withDeps;
|
|
399
|
+
const bare = probePython(pinned, false);
|
|
400
|
+
if (requireDeps && bare) {
|
|
401
|
+
const bootstrapped = bootstrapDependencies(bare);
|
|
379
402
|
if (bootstrapped) return bootstrapped;
|
|
380
403
|
}
|
|
381
|
-
if (!requireDeps &&
|
|
404
|
+
if (!requireDeps && bare) return bare;
|
|
382
405
|
fail(`TOKENSAFE_PYTHON=${pinned} is not a usable CPython ${MIN_PYTHON[0]}.${MIN_PYTHON[1]}+ with 'cryptography'.`);
|
|
383
406
|
}
|
|
384
407
|
|
|
@@ -389,28 +412,27 @@ async function findPython(options = {}) {
|
|
|
389
412
|
return allowProvision ? await ensureManagedRuntime() : null;
|
|
390
413
|
}
|
|
391
414
|
|
|
392
|
-
const candidates =
|
|
393
|
-
const venvPy = venvPythonPath();
|
|
394
|
-
if (fs.existsSync(venvPy)) candidates.push(venvPy);
|
|
395
|
-
candidates.push('python3', 'python');
|
|
415
|
+
const candidates = pythonCandidates();
|
|
396
416
|
|
|
397
417
|
if (!requireDeps) {
|
|
398
418
|
// `help` only prints: a bare interpreter is enough, and a dependency
|
|
399
419
|
// bootstrap there would turn a two-line reference into a pip install.
|
|
400
420
|
for (const cmd of candidates) {
|
|
401
|
-
|
|
421
|
+
const resolved = probePython(cmd, false);
|
|
422
|
+
if (resolved) return resolved;
|
|
402
423
|
}
|
|
403
424
|
return allowProvision ? await ensureManagedRuntime() : null;
|
|
404
425
|
}
|
|
405
426
|
|
|
406
427
|
for (const cmd of candidates) {
|
|
407
|
-
|
|
428
|
+
const resolved = probePython(cmd, true);
|
|
429
|
+
if (resolved) return resolved;
|
|
408
430
|
}
|
|
409
431
|
for (const cmd of candidates) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
432
|
+
const resolved = probePython(cmd, false);
|
|
433
|
+
if (!resolved) continue;
|
|
434
|
+
const bootstrapped = bootstrapDependencies(resolved);
|
|
435
|
+
if (bootstrapped) return bootstrapped;
|
|
414
436
|
}
|
|
415
437
|
|
|
416
438
|
return allowProvision ? await ensureManagedRuntime() : null;
|
|
@@ -503,6 +525,7 @@ if (require.main === module) {
|
|
|
503
525
|
loadManifest,
|
|
504
526
|
platformKey,
|
|
505
527
|
probePython,
|
|
528
|
+
pythonCandidates,
|
|
506
529
|
findRuntimePython,
|
|
507
530
|
sha256File,
|
|
508
531
|
installDeps,
|
package/kimi.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.19",
|
|
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.19",
|
|
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.19",
|
|
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.19",
|
|
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.19",
|
|
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.19",
|
|
43
43
|
"runtimeHint": "uvx",
|
|
44
44
|
"transport": {
|
|
45
45
|
"type": "stdio"
|
package/src/mcp_server.py
CHANGED
package/src/telemetry_sync.py
CHANGED
|
@@ -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.7.
|
|
314
|
+
"User-Agent": "TokenSafe-Sync/4.7.19"
|
|
315
315
|
}
|
|
316
316
|
if active_key:
|
|
317
317
|
headers["Authorization"] = f"Bearer {active_key}"
|
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.7.
|
|
20
|
+
CURRENT_VERSION = "4.7.19"
|
|
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
|