@atlisp/mcp 1.6.9 → 1.6.10
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/dist/atlisp-mcp.js +584 -294
- package/dist/cad-worker.js +24 -14
- package/package.json +1 -1
package/dist/cad-worker.js
CHANGED
|
@@ -46,7 +46,7 @@ const cadConnect = edge.func(function() {/*
|
|
|
46
46
|
System.Diagnostics.Debug.WriteLine("GStarCAD connect error: " + ex.Message);
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
|
-
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject("
|
|
49
|
+
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject("BricscadApp.AcadApplication");
|
|
50
50
|
if (cad != null) {
|
|
51
51
|
string ver = cad.Version.ToString();
|
|
52
52
|
return new { success = true, platform = "BricsCAD", version = ver };
|
|
@@ -61,7 +61,7 @@ const cadConnect = edge.func(function() {/*
|
|
|
61
61
|
const cadLaunch = edge.func(function() {/*
|
|
62
62
|
async (input) => {
|
|
63
63
|
string[] platforms = { "AutoCAD", "ZWCAD", "GStarCAD", "BricsCAD" };
|
|
64
|
-
string[] progIds = { "AutoCAD.Application", "ZWCAD.Application", "GStarCAD.Application", "
|
|
64
|
+
string[] progIds = { "AutoCAD.Application", "ZWCAD.Application", "GStarCAD.Application", "BricscadApp.AcadApplication" };
|
|
65
65
|
|
|
66
66
|
for (int i = 0; i < platforms.Length; i++) {
|
|
67
67
|
try {
|
|
@@ -103,7 +103,7 @@ const cadSend = edge.func(function() {/*
|
|
|
103
103
|
dynamic d = input;
|
|
104
104
|
string code = d.code.ToString();
|
|
105
105
|
string platform = d.platform.ToString();
|
|
106
|
-
string progId = platform == "BricsCAD" ? "
|
|
106
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
107
107
|
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
108
108
|
if (cad != null) {
|
|
109
109
|
dynamic doc = cad.ActiveDocument;
|
|
@@ -124,29 +124,32 @@ const cadSendWithResult = edge.func(function() {/*
|
|
|
124
124
|
async (input) => {
|
|
125
125
|
string tempFile = null;
|
|
126
126
|
string lispFile = null;
|
|
127
|
+
string userCodeFile = null;
|
|
127
128
|
try {
|
|
128
129
|
dynamic d = input;
|
|
129
130
|
string code = d.code.ToString();
|
|
130
131
|
string platform = d.platform.ToString();
|
|
131
132
|
string encoding = d.encoding != null ? d.encoding.ToString() : "";
|
|
132
|
-
string progId = platform == "BricsCAD" ? "
|
|
133
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
133
134
|
string tempDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "@lisp", "tmp");
|
|
134
135
|
System.IO.Directory.CreateDirectory(tempDir);
|
|
135
136
|
|
|
136
137
|
tempFile = System.IO.Path.Combine(tempDir, "atlisp_result_" + System.Guid.NewGuid().ToString("N") + ".txt");
|
|
137
138
|
lispFile = System.IO.Path.Combine(tempDir, "atlisp_code_" + System.Guid.NewGuid().ToString("N") + ".lsp");
|
|
139
|
+
userCodeFile = System.IO.Path.Combine(tempDir, "atlisp_user_" + System.Guid.NewGuid().ToString("N") + ".lsp");
|
|
140
|
+
|
|
141
|
+
// 用户代码单独写入文件,避免拼接注入风险
|
|
142
|
+
System.IO.File.WriteAllText(userCodeFile, code, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage));
|
|
138
143
|
|
|
139
|
-
// 生成 LISP 代码:使用 vl-catch-all-apply 捕获结果和错误
|
|
140
|
-
// 返回 (success . result) 或 (nil . error-msg)
|
|
141
144
|
string lispCode = "(progn"
|
|
142
145
|
+ "(setq f(open \"" + tempFile.Replace("\\", "\\\\") + "\" \"w\"))"
|
|
143
|
-
+ "(setq r(vl-catch-all-apply '(lambda ()(
|
|
146
|
+
+ "(setq r(vl-catch-all-apply '(lambda ()(load \"" + userCodeFile.Replace("\\", "\\\\") + "\"))))"
|
|
144
147
|
+ "(if (vl-catch-all-error-p r)"
|
|
145
148
|
+ "(princ(strcat \"ERROR:\"(vl-catch-all-error-message r)) f)"
|
|
146
149
|
+ "(princ r f))"
|
|
147
150
|
+ "(close f)"
|
|
148
151
|
+ "(princ))";
|
|
149
|
-
|
|
152
|
+
|
|
150
153
|
// 使用系统 ANSI 编码以兼容 GstarCAD / ZWCAD
|
|
151
154
|
System.IO.File.WriteAllText(lispFile, lispCode, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage));
|
|
152
155
|
|
|
@@ -201,6 +204,7 @@ string encoding = d.encoding != null ? d.encoding.ToString() : "";
|
|
|
201
204
|
|
|
202
205
|
try { System.IO.File.Delete(tempFile); } catch {}
|
|
203
206
|
try { System.IO.File.Delete(lispFile); } catch {}
|
|
207
|
+
try { System.IO.File.Delete(userCodeFile); } catch {}
|
|
204
208
|
break;
|
|
205
209
|
} catch (System.IO.IOException) {
|
|
206
210
|
System.Threading.Thread.Sleep(200);
|
|
@@ -223,6 +227,9 @@ string encoding = d.encoding != null ? d.encoding.ToString() : "";
|
|
|
223
227
|
if (lispFile != null) {
|
|
224
228
|
try { if (System.IO.File.Exists(lispFile)) System.IO.File.Delete(lispFile); } catch {}
|
|
225
229
|
}
|
|
230
|
+
if (userCodeFile != null) {
|
|
231
|
+
try { if (System.IO.File.Exists(userCodeFile)) System.IO.File.Delete(userCodeFile); } catch {}
|
|
232
|
+
}
|
|
226
233
|
return new { success = false, error = ex.Message };
|
|
227
234
|
}
|
|
228
235
|
if (tempFile != null) {
|
|
@@ -231,6 +238,9 @@ string encoding = d.encoding != null ? d.encoding.ToString() : "";
|
|
|
231
238
|
if (lispFile != null) {
|
|
232
239
|
try { if (System.IO.File.Exists(lispFile)) System.IO.File.Delete(lispFile); } catch {}
|
|
233
240
|
}
|
|
241
|
+
if (userCodeFile != null) {
|
|
242
|
+
try { if (System.IO.File.Exists(userCodeFile)) System.IO.File.Delete(userCodeFile); } catch {}
|
|
243
|
+
}
|
|
234
244
|
return new { success = false };
|
|
235
245
|
}
|
|
236
246
|
*/});
|
|
@@ -262,7 +272,7 @@ const cadIsBusy = edge.func(function() {/*
|
|
|
262
272
|
async (input) => {
|
|
263
273
|
try {
|
|
264
274
|
string platform = input.ToString();
|
|
265
|
-
string progId = platform == "BricsCAD" ? "
|
|
275
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
266
276
|
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
267
277
|
if (cad != null) {
|
|
268
278
|
bool isBusy = false;
|
|
@@ -284,7 +294,7 @@ const cadHasDoc = edge.func(function() {/*
|
|
|
284
294
|
async (input) => {
|
|
285
295
|
try {
|
|
286
296
|
string platform = input.ToString();
|
|
287
|
-
string progId = platform == "BricsCAD" ? "
|
|
297
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
288
298
|
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
289
299
|
if (cad != null) {
|
|
290
300
|
int docCount = cad.Documents.Count;
|
|
@@ -301,7 +311,7 @@ const cadNewDoc = edge.func(function() {/*
|
|
|
301
311
|
async (input) => {
|
|
302
312
|
try {
|
|
303
313
|
string platform = input.ToString();
|
|
304
|
-
string progId = platform == "BricsCAD" ? "
|
|
314
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
305
315
|
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
306
316
|
if (cad != null) {
|
|
307
317
|
cad.Documents.Add();
|
|
@@ -319,7 +329,7 @@ const cadBringToFront = edge.func(function() {/*
|
|
|
319
329
|
async (input) => {
|
|
320
330
|
try {
|
|
321
331
|
string platform = input.ToString();
|
|
322
|
-
string progId = platform == "BricsCAD" ? "
|
|
332
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
323
333
|
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
324
334
|
if (cad != null) {
|
|
325
335
|
cad.Visible = true;
|
|
@@ -337,7 +347,7 @@ const cadConnectByName = edge.func(function() {/*
|
|
|
337
347
|
async (input) => {
|
|
338
348
|
try {
|
|
339
349
|
string platform = input.ToString();
|
|
340
|
-
string progId = platform == "BricsCAD" ? "
|
|
350
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
341
351
|
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
342
352
|
if (cad != null) {
|
|
343
353
|
string ver = cad.Version.ToString();
|
|
@@ -348,7 +358,7 @@ const cadConnectByName = edge.func(function() {/*
|
|
|
348
358
|
}
|
|
349
359
|
try {
|
|
350
360
|
string platform = input.ToString();
|
|
351
|
-
string progId = platform == "BricsCAD" ? "
|
|
361
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
352
362
|
var type = System.Type.GetTypeFromProgID(progId);
|
|
353
363
|
if (type != null) {
|
|
354
364
|
dynamic cad = System.Activator.CreateInstance(type);
|