deepseek-pp-shell-host 0.6.4 → 0.7.0
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/native/shell-mcp-host.mjs +23 -3
- package/package.json +1 -1
|
@@ -62,6 +62,7 @@ const MAX_PYTHON_TIMEOUT_MS = 30_000;
|
|
|
62
62
|
const MAX_PYTHON_CODE_BYTES = 60_000;
|
|
63
63
|
const MAX_PYTHON_OUTPUT_BYTES = 64_000;
|
|
64
64
|
const PYTHON_PACKAGE_CHECKS = ['numpy', 'pandas', 'sympy'];
|
|
65
|
+
const PYTHON_NOT_FOUND_MESSAGE = 'No local Python interpreter found. Tried environment variables, PATH entries, common paths, and python/python3/py --version.';
|
|
65
66
|
const DEFAULT_SHELL = platform() === 'win32' ? 'powershell.exe' : process.env.SHELL || '/bin/sh';
|
|
66
67
|
const WINDOWS_POWERSHELL_UTF8_PREAMBLE = [
|
|
67
68
|
'[Console]::InputEncoding = [System.Text.UTF8Encoding]::new($false)',
|
|
@@ -357,7 +358,7 @@ async function createPythonStatusResult() {
|
|
|
357
358
|
const status = await detectPythonStatus();
|
|
358
359
|
const text = status.available
|
|
359
360
|
? `Python ${status.version} ready at ${status.executable}`
|
|
360
|
-
:
|
|
361
|
+
: PYTHON_NOT_FOUND_MESSAGE;
|
|
361
362
|
|
|
362
363
|
return {
|
|
363
364
|
content: [{ type: 'text', text }],
|
|
@@ -393,7 +394,7 @@ async function executePythonTool(args) {
|
|
|
393
394
|
if (!status.available || !status.command) {
|
|
394
395
|
return {
|
|
395
396
|
isError: true,
|
|
396
|
-
content: [{ type: 'text', text:
|
|
397
|
+
content: [{ type: 'text', text: PYTHON_NOT_FOUND_MESSAGE }],
|
|
397
398
|
structuredContent: {
|
|
398
399
|
ok: false,
|
|
399
400
|
data: status,
|
|
@@ -552,12 +553,12 @@ function getPosixPythonPathCandidates() {
|
|
|
552
553
|
|
|
553
554
|
function getWindowsPythonPathCandidates() {
|
|
554
555
|
const candidates = [];
|
|
556
|
+
addWindowsPathPythonCandidates(candidates);
|
|
555
557
|
const dirs = [
|
|
556
558
|
resolve(localAppData, 'Programs', 'Python'),
|
|
557
559
|
process.env.ProgramFiles ? resolve(process.env.ProgramFiles) : '',
|
|
558
560
|
process.env['ProgramFiles(x86)'] ? resolve(process.env['ProgramFiles(x86)']) : '',
|
|
559
561
|
].filter(Boolean);
|
|
560
|
-
addPythonPathCandidate(candidates, resolve(localAppData, 'Microsoft', 'WindowsApps', 'python.exe'), 'path:file');
|
|
561
562
|
for (const dir of dirs) {
|
|
562
563
|
for (const entry of readDirectoryEntries(dir)) {
|
|
563
564
|
if (!/^Python\d+/i.test(entry.name)) continue;
|
|
@@ -567,6 +568,14 @@ function getWindowsPythonPathCandidates() {
|
|
|
567
568
|
return candidates;
|
|
568
569
|
}
|
|
569
570
|
|
|
571
|
+
function addWindowsPathPythonCandidates(candidates) {
|
|
572
|
+
for (const dir of splitPath(getEnvironmentPath(process.env))) {
|
|
573
|
+
for (const name of ['python.exe', 'python3.exe']) {
|
|
574
|
+
addPythonPathCandidate(candidates, resolve(dir, name), 'path:PATH');
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
570
579
|
function addPythonEnvDirCandidates(candidates, envsDir) {
|
|
571
580
|
for (const entry of readDirectoryEntries(envsDir)) {
|
|
572
581
|
if (!entry.isDirectory()) continue;
|
|
@@ -579,9 +588,20 @@ function addPythonEnvDirCandidates(candidates, envsDir) {
|
|
|
579
588
|
|
|
580
589
|
function addPythonPathCandidate(candidates, pythonPath, source) {
|
|
581
590
|
if (!existsSync(pythonPath)) return;
|
|
591
|
+
if (platform() === 'win32' && isWindowsAppExecutionAliasPath(pythonPath)) return;
|
|
582
592
|
candidates.push({ command: pythonPath, args: [], source });
|
|
583
593
|
}
|
|
584
594
|
|
|
595
|
+
function isWindowsAppExecutionAliasPath(filePath) {
|
|
596
|
+
const normalized = normalizeWindowsPathForCompare(filePath);
|
|
597
|
+
const aliasDir = normalizeWindowsPathForCompare(resolve(localAppData, 'Microsoft', 'WindowsApps'));
|
|
598
|
+
return normalized === aliasDir || normalized.startsWith(aliasDir + '/');
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function normalizeWindowsPathForCompare(filePath) {
|
|
602
|
+
return resolve(filePath).replace(/[\\/]+/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
603
|
+
}
|
|
604
|
+
|
|
585
605
|
function readDirectoryEntries(dir) {
|
|
586
606
|
try {
|
|
587
607
|
return readdirSync(dir, { withFileTypes: true });
|