@atlisp/mcp 1.0.12 → 1.0.13
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/package.json +1 -1
- package/src/cad-worker.js +24 -9
- package/src/constants.js +1 -1
package/package.json
CHANGED
package/src/cad-worker.js
CHANGED
|
@@ -79,16 +79,31 @@ const cadSendWithResult = edge.func(function() {/*
|
|
|
79
79
|
string progId = platform + ".Application";
|
|
80
80
|
string tempDir = System.IO.Path.GetTempPath();
|
|
81
81
|
tempFile = System.IO.Path.Combine(tempDir, "atlisp_result_" + System.Guid.NewGuid().ToString("N") + ".txt");
|
|
82
|
-
string lispCode = "(progn(setq f(open \"" + tempFile.Replace("\\", "\\\\") + "\" \"w\"))(print " + code + " f)(close f))";
|
|
82
|
+
string lispCode = "(progn(setq f(open \"" + tempFile.Replace("\\", "\\\\") + "\" \"w\"))(print " + code + " f)(close f)(princ))";
|
|
83
83
|
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
84
84
|
if (cad != null) {
|
|
85
85
|
dynamic doc = cad.ActiveDocument;
|
|
86
86
|
if (doc != null) {
|
|
87
87
|
doc.SendCommand(lispCode + "\n");
|
|
88
|
-
|
|
88
|
+
int retries = 10;
|
|
89
|
+
string result = "";
|
|
90
|
+
while (retries > 0 && !System.IO.File.Exists(tempFile)) {
|
|
91
|
+
System.Threading.Thread.Sleep(200);
|
|
92
|
+
retries--;
|
|
93
|
+
}
|
|
89
94
|
if (System.IO.File.Exists(tempFile)) {
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
retries = 5;
|
|
96
|
+
while (retries > 0) {
|
|
97
|
+
try {
|
|
98
|
+
byte[] bytes = System.IO.File.ReadAllBytes(tempFile);
|
|
99
|
+
result = System.Text.Encoding.GetEncoding("GBK").GetString(bytes).Trim();
|
|
100
|
+
try { System.IO.File.Delete(tempFile); } catch {}
|
|
101
|
+
break;
|
|
102
|
+
} catch (System.IO.IOException) {
|
|
103
|
+
System.Threading.Thread.Sleep(200);
|
|
104
|
+
retries--;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
92
107
|
if (!string.IsNullOrEmpty(result)) {
|
|
93
108
|
return new { success = true, result = result };
|
|
94
109
|
}
|
|
@@ -99,17 +114,17 @@ const cadSendWithResult = edge.func(function() {/*
|
|
|
99
114
|
}
|
|
100
115
|
} catch (Exception ex) {
|
|
101
116
|
System.Diagnostics.Debug.WriteLine("cadSendWithResult error: " + ex.Message);
|
|
102
|
-
if (tempFile != null
|
|
103
|
-
try { System.IO.File.Delete(tempFile); } catch {}
|
|
117
|
+
if (tempFile != null) {
|
|
118
|
+
try { if (System.IO.File.Exists(tempFile)) System.IO.File.Delete(tempFile); } catch {}
|
|
104
119
|
}
|
|
105
120
|
return new { success = false, error = ex.Message };
|
|
106
121
|
}
|
|
107
|
-
if (tempFile != null
|
|
108
|
-
try { System.IO.File.Delete(tempFile); } catch {}
|
|
122
|
+
if (tempFile != null) {
|
|
123
|
+
try { if (System.IO.File.Exists(tempFile)) System.IO.File.Delete(tempFile); } catch {}
|
|
109
124
|
}
|
|
110
125
|
return new { success = false };
|
|
111
126
|
}
|
|
112
|
-
|
|
127
|
+
*/});
|
|
113
128
|
|
|
114
129
|
process.stdin.setEncoding('utf8');
|
|
115
130
|
|
package/src/constants.js
CHANGED
|
@@ -7,7 +7,7 @@ export const FILE_EXTENSIONS = {
|
|
|
7
7
|
|
|
8
8
|
export const PROTOCOL_VERSION = '2024-11-05';
|
|
9
9
|
export const SERVER_NAME = 'atlisp-mcp-server';
|
|
10
|
-
export const SERVER_VERSION = '1.0.
|
|
10
|
+
export const SERVER_VERSION = '1.0.13';
|
|
11
11
|
|
|
12
12
|
export const MOCK_PACKAGES = [
|
|
13
13
|
{ name: 'base', description: '基础函数库', version: '1.0.0' },
|