@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/atlisp-mcp.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/atlisp-mcp.js
|
|
4
4
|
import path10 from "path";
|
|
5
|
+
import fs8 from "fs";
|
|
5
6
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
6
7
|
import { createRequire } from "module";
|
|
7
8
|
import express2 from "express";
|
|
@@ -22,7 +23,7 @@ var FILE_EXTENSIONS = {
|
|
|
22
23
|
"BricsCAD": [".des"]
|
|
23
24
|
};
|
|
24
25
|
var SERVER_NAME = "atlisp-mcp-server";
|
|
25
|
-
var SERVER_VERSION = "1.6.
|
|
26
|
+
var SERVER_VERSION = "1.6.7";
|
|
26
27
|
var MOCK_PACKAGES = [
|
|
27
28
|
{ name: "base", description: "\u57FA\u7840\u51FD\u6570\u5E93", version: "1.0.0" },
|
|
28
29
|
{ name: "at-pm", description: "\u5DE5\u7A0B\u9879\u76EE\u7BA1\u7406", version: "2.1.0" },
|
|
@@ -115,7 +116,8 @@ function parseArgs() {
|
|
|
115
116
|
return result;
|
|
116
117
|
}
|
|
117
118
|
function loadConfigFile(filePath) {
|
|
118
|
-
if (!filePath || !fs.existsSync(filePath))
|
|
119
|
+
if (!filePath || !fs.existsSync(filePath))
|
|
120
|
+
return null;
|
|
119
121
|
try {
|
|
120
122
|
const raw = fs.readFileSync(filePath, "utf-8");
|
|
121
123
|
const parsed = JSON.parse(raw);
|
|
@@ -136,7 +138,7 @@ if (!envResult.success) {
|
|
|
136
138
|
process.exit(1);
|
|
137
139
|
}
|
|
138
140
|
var env = envResult.data;
|
|
139
|
-
var configFilePath = env.CONFIG_FILE || cliArgs.configFile || path.join(os.homedir(), "
|
|
141
|
+
var configFilePath = env.CONFIG_FILE || cliArgs.configFile || path.join(os.homedir(), ".atlisp", "atlisp.config.json");
|
|
140
142
|
var fileConfig = loadConfigFile(configFilePath);
|
|
141
143
|
var config = {
|
|
142
144
|
port: fileConfig?.port || parseInt(env.PORT || cliArgs.port, 10),
|
|
@@ -253,7 +255,8 @@ function setupStdoutHandler(w) {
|
|
|
253
255
|
const lines = buffer.split("\n");
|
|
254
256
|
buffer = lines.pop() || "";
|
|
255
257
|
for (const line of lines) {
|
|
256
|
-
if (!line.trim())
|
|
258
|
+
if (!line.trim())
|
|
259
|
+
continue;
|
|
257
260
|
try {
|
|
258
261
|
const result = JSON.parse(line);
|
|
259
262
|
const rid = result.requestId;
|
|
@@ -279,7 +282,8 @@ function setupStdoutHandler(w) {
|
|
|
279
282
|
}
|
|
280
283
|
function getWorker(force = false) {
|
|
281
284
|
if (!worker || !worker.connected || force) {
|
|
282
|
-
if (worker)
|
|
285
|
+
if (worker)
|
|
286
|
+
worker.kill();
|
|
283
287
|
worker = spawn("node", [workerPath], {
|
|
284
288
|
stdio: ["pipe", "pipe", "pipe"]
|
|
285
289
|
});
|
|
@@ -287,7 +291,8 @@ function getWorker(force = false) {
|
|
|
287
291
|
const w = worker;
|
|
288
292
|
w.on("exit", (code) => {
|
|
289
293
|
console.error("worker exited with code:", code);
|
|
290
|
-
if (w !== worker)
|
|
294
|
+
if (w !== worker)
|
|
295
|
+
return;
|
|
291
296
|
w.connected = false;
|
|
292
297
|
for (const [id, { reject, timeout }] of pendingRequests) {
|
|
293
298
|
clearTimeout(timeout);
|
|
@@ -308,7 +313,8 @@ function getWorker(force = false) {
|
|
|
308
313
|
return worker;
|
|
309
314
|
}
|
|
310
315
|
function startHeartbeat() {
|
|
311
|
-
if (heartbeatTimer)
|
|
316
|
+
if (heartbeatTimer)
|
|
317
|
+
clearInterval(heartbeatTimer);
|
|
312
318
|
heartbeatTimer = setInterval(async () => {
|
|
313
319
|
try {
|
|
314
320
|
const result = await sendMessage({ type: "ping" });
|
|
@@ -353,7 +359,8 @@ var CadConnection = class {
|
|
|
353
359
|
return process.platform === "win32";
|
|
354
360
|
}
|
|
355
361
|
async connect(platform = null) {
|
|
356
|
-
if (!this.isAvailable())
|
|
362
|
+
if (!this.isAvailable())
|
|
363
|
+
return false;
|
|
357
364
|
try {
|
|
358
365
|
const msg = platform ? { type: "connect", platform } : { type: "connect" };
|
|
359
366
|
const result = await sendMessage(msg);
|
|
@@ -370,13 +377,16 @@ var CadConnection = class {
|
|
|
370
377
|
return false;
|
|
371
378
|
}
|
|
372
379
|
async sendCommand(code) {
|
|
373
|
-
if (!this.connected)
|
|
380
|
+
if (!this.connected)
|
|
381
|
+
throw new Error("\u672A\u8FDE\u63A5 CAD");
|
|
374
382
|
const result = await sendMessage({ type: "send", code, platform: _platform });
|
|
375
|
-
if (result.success)
|
|
383
|
+
if (result.success)
|
|
384
|
+
return true;
|
|
376
385
|
throw new Error(result.error || "\u53D1\u9001\u5931\u8D25");
|
|
377
386
|
}
|
|
378
387
|
async sendCommandWithResult(code, encoding = null) {
|
|
379
|
-
if (!this.connected)
|
|
388
|
+
if (!this.connected)
|
|
389
|
+
throw new Error("\u672A\u8FDE\u63A5 CAD");
|
|
380
390
|
const result = await sendMessage({ type: "sendResult", code, platform: _platform, encoding: encoding || "" });
|
|
381
391
|
if (result.success) {
|
|
382
392
|
return result.result || "";
|
|
@@ -390,7 +400,8 @@ var CadConnection = class {
|
|
|
390
400
|
return this.product;
|
|
391
401
|
}
|
|
392
402
|
async isBusy() {
|
|
393
|
-
if (!this.connected)
|
|
403
|
+
if (!this.connected)
|
|
404
|
+
return false;
|
|
394
405
|
try {
|
|
395
406
|
const result = await sendMessage({ type: "isBusy", platform: _platform });
|
|
396
407
|
return result && result.isBusy;
|
|
@@ -399,7 +410,8 @@ var CadConnection = class {
|
|
|
399
410
|
}
|
|
400
411
|
}
|
|
401
412
|
async hasDoc() {
|
|
402
|
-
if (!this.connected)
|
|
413
|
+
if (!this.connected)
|
|
414
|
+
return { hasDoc: false, docCount: 0 };
|
|
403
415
|
try {
|
|
404
416
|
const result = await sendMessage({ type: "hasdoc", platform: _platform });
|
|
405
417
|
return result || { hasDoc: false, docCount: 0 };
|
|
@@ -408,7 +420,8 @@ var CadConnection = class {
|
|
|
408
420
|
}
|
|
409
421
|
}
|
|
410
422
|
async newDoc() {
|
|
411
|
-
if (!this.connected)
|
|
423
|
+
if (!this.connected)
|
|
424
|
+
throw new Error("\u672A\u8FDE\u63A5 CAD");
|
|
412
425
|
try {
|
|
413
426
|
const result = await sendMessage({ type: "newdoc", platform: _platform });
|
|
414
427
|
return result && result.success;
|
|
@@ -417,7 +430,8 @@ var CadConnection = class {
|
|
|
417
430
|
}
|
|
418
431
|
}
|
|
419
432
|
async bringToFront() {
|
|
420
|
-
if (!this.connected)
|
|
433
|
+
if (!this.connected)
|
|
434
|
+
throw new Error("\u672A\u8FDE\u63A5 CAD");
|
|
421
435
|
try {
|
|
422
436
|
const result = await sendMessage({ type: "bringToFront", platform: _platform });
|
|
423
437
|
return result && result.success;
|
|
@@ -426,7 +440,8 @@ var CadConnection = class {
|
|
|
426
440
|
}
|
|
427
441
|
}
|
|
428
442
|
async getInfo() {
|
|
429
|
-
if (!this.connected)
|
|
443
|
+
if (!this.connected)
|
|
444
|
+
return "CAD \u672A\u8FDE\u63A5";
|
|
430
445
|
return `Platform: ${this.product}, Version: ${this.version}, Status: Connected`;
|
|
431
446
|
}
|
|
432
447
|
async disconnect() {
|
|
@@ -463,9 +478,11 @@ var MAX_LOG_SIZE = 10 * 1024 * 1024;
|
|
|
463
478
|
var MAX_LOG_FILES = 5;
|
|
464
479
|
var stream = null;
|
|
465
480
|
function rotateLog() {
|
|
466
|
-
if (!fs2.existsSync(DEBUG_FILE))
|
|
481
|
+
if (!fs2.existsSync(DEBUG_FILE))
|
|
482
|
+
return;
|
|
467
483
|
const stat = fs2.statSync(DEBUG_FILE);
|
|
468
|
-
if (stat.size < MAX_LOG_SIZE)
|
|
484
|
+
if (stat.size < MAX_LOG_SIZE)
|
|
485
|
+
return;
|
|
469
486
|
if (stream) {
|
|
470
487
|
stream.end();
|
|
471
488
|
stream = null;
|
|
@@ -529,9 +546,11 @@ function ensureRequestLogDir() {
|
|
|
529
546
|
}
|
|
530
547
|
}
|
|
531
548
|
function rotateRequestLog() {
|
|
532
|
-
if (!fs2.existsSync(REQUEST_LOG_FILE))
|
|
549
|
+
if (!fs2.existsSync(REQUEST_LOG_FILE))
|
|
550
|
+
return;
|
|
533
551
|
const stat = fs2.statSync(REQUEST_LOG_FILE);
|
|
534
|
-
if (stat.size < 10 * 1024 * 1024)
|
|
552
|
+
if (stat.size < 10 * 1024 * 1024)
|
|
553
|
+
return;
|
|
535
554
|
const dir = path3.dirname(REQUEST_LOG_FILE);
|
|
536
555
|
for (let i = 5; i > 0; i--) {
|
|
537
556
|
const oldPath = `${REQUEST_LOG_FILE}.${i}`;
|
|
@@ -549,7 +568,8 @@ function rotateRequestLog() {
|
|
|
549
568
|
}
|
|
550
569
|
}
|
|
551
570
|
function logRequest(req) {
|
|
552
|
-
if (!config_default.requestLogEnabled)
|
|
571
|
+
if (!config_default.requestLogEnabled)
|
|
572
|
+
return;
|
|
553
573
|
try {
|
|
554
574
|
ensureRequestLogDir();
|
|
555
575
|
rotateRequestLog();
|
|
@@ -566,7 +586,8 @@ function logRequest(req) {
|
|
|
566
586
|
}
|
|
567
587
|
}
|
|
568
588
|
function logResponse(req, res, duration) {
|
|
569
|
-
if (!config_default.requestLogEnabled)
|
|
589
|
+
if (!config_default.requestLogEnabled)
|
|
590
|
+
return;
|
|
570
591
|
try {
|
|
571
592
|
ensureRequestLogDir();
|
|
572
593
|
const entry = {
|
|
@@ -664,11 +685,14 @@ function clearCache(uri) {
|
|
|
664
685
|
}
|
|
665
686
|
}
|
|
666
687
|
function parseLispList(str) {
|
|
667
|
-
if (!str || typeof str !== "string")
|
|
688
|
+
if (!str || typeof str !== "string")
|
|
689
|
+
return null;
|
|
668
690
|
const trimmed = str.trim();
|
|
669
|
-
if (!trimmed.startsWith("(") || !trimmed.endsWith(")"))
|
|
691
|
+
if (!trimmed.startsWith("(") || !trimmed.endsWith(")"))
|
|
692
|
+
return null;
|
|
670
693
|
const content = trimmed.slice(1, -1).trim();
|
|
671
|
-
if (!content)
|
|
694
|
+
if (!content)
|
|
695
|
+
return [];
|
|
672
696
|
const result = [];
|
|
673
697
|
let depth = 0;
|
|
674
698
|
let current = "";
|
|
@@ -710,32 +734,44 @@ function parseLispList(str) {
|
|
|
710
734
|
}
|
|
711
735
|
current += ch;
|
|
712
736
|
}
|
|
713
|
-
if (current.trim())
|
|
737
|
+
if (current.trim())
|
|
738
|
+
result.push(current.trim());
|
|
714
739
|
return result.map((item) => {
|
|
715
740
|
const t = item.trim();
|
|
716
|
-
if (t === "nil")
|
|
717
|
-
|
|
718
|
-
if (t === "
|
|
741
|
+
if (t === "nil")
|
|
742
|
+
return null;
|
|
743
|
+
if (t === "t")
|
|
744
|
+
return true;
|
|
745
|
+
if (t === "T")
|
|
746
|
+
return true;
|
|
719
747
|
const num = Number(t);
|
|
720
|
-
if (!isNaN(num) && t !== "")
|
|
721
|
-
|
|
748
|
+
if (!isNaN(num) && t !== "")
|
|
749
|
+
return num;
|
|
750
|
+
if (t.startsWith('"') && t.endsWith('"'))
|
|
751
|
+
return t.slice(1, -1);
|
|
722
752
|
return t;
|
|
723
753
|
});
|
|
724
754
|
}
|
|
725
755
|
function parseLispRecursive(str) {
|
|
726
|
-
if (!str || typeof str !== "string")
|
|
756
|
+
if (!str || typeof str !== "string")
|
|
757
|
+
return null;
|
|
727
758
|
str = str.trim();
|
|
728
|
-
if (!str)
|
|
759
|
+
if (!str)
|
|
760
|
+
return null;
|
|
729
761
|
let pos = 0;
|
|
730
762
|
function skipWs() {
|
|
731
|
-
while (pos < str.length && /\s/.test(str[pos]))
|
|
763
|
+
while (pos < str.length && /\s/.test(str[pos]))
|
|
764
|
+
pos++;
|
|
732
765
|
}
|
|
733
766
|
function parseValue() {
|
|
734
767
|
skipWs();
|
|
735
|
-
if (pos >= str.length)
|
|
768
|
+
if (pos >= str.length)
|
|
769
|
+
return null;
|
|
736
770
|
const ch = str[pos];
|
|
737
|
-
if (ch === "(")
|
|
738
|
-
|
|
771
|
+
if (ch === "(")
|
|
772
|
+
return parseList();
|
|
773
|
+
if (ch === '"')
|
|
774
|
+
return parseString();
|
|
739
775
|
if (ch === "'") {
|
|
740
776
|
pos++;
|
|
741
777
|
return parseValue();
|
|
@@ -748,11 +784,16 @@ function parseLispRecursive(str) {
|
|
|
748
784
|
while (pos < str.length && str[pos] !== '"') {
|
|
749
785
|
if (str[pos] === "\\" && pos + 1 < str.length) {
|
|
750
786
|
pos++;
|
|
751
|
-
if (str[pos] === '"')
|
|
752
|
-
|
|
753
|
-
else if (str[pos] === "
|
|
754
|
-
|
|
755
|
-
else
|
|
787
|
+
if (str[pos] === '"')
|
|
788
|
+
r += '"';
|
|
789
|
+
else if (str[pos] === "n")
|
|
790
|
+
r += "\n";
|
|
791
|
+
else if (str[pos] === "t")
|
|
792
|
+
r += " ";
|
|
793
|
+
else if (str[pos] === "\\")
|
|
794
|
+
r += "\\";
|
|
795
|
+
else
|
|
796
|
+
r += str[pos];
|
|
756
797
|
} else {
|
|
757
798
|
r += str[pos];
|
|
758
799
|
}
|
|
@@ -763,12 +804,16 @@ function parseLispRecursive(str) {
|
|
|
763
804
|
}
|
|
764
805
|
function parseAtom() {
|
|
765
806
|
const start = pos;
|
|
766
|
-
while (pos < str.length && !/\s/.test(str[pos]) && str[pos] !== ")" && str[pos] !== "(")
|
|
807
|
+
while (pos < str.length && !/\s/.test(str[pos]) && str[pos] !== ")" && str[pos] !== "(")
|
|
808
|
+
pos++;
|
|
767
809
|
const atom = str.slice(start, pos);
|
|
768
|
-
if (atom === "nil" || atom === "NIL")
|
|
769
|
-
|
|
810
|
+
if (atom === "nil" || atom === "NIL")
|
|
811
|
+
return null;
|
|
812
|
+
if (atom === "t" || atom === "T")
|
|
813
|
+
return true;
|
|
770
814
|
const num = Number(atom);
|
|
771
|
-
if (!isNaN(num) && atom !== "")
|
|
815
|
+
if (!isNaN(num) && atom !== "")
|
|
816
|
+
return num;
|
|
772
817
|
return atom;
|
|
773
818
|
}
|
|
774
819
|
function parseList() {
|
|
@@ -776,13 +821,15 @@ function parseLispRecursive(str) {
|
|
|
776
821
|
const items = [];
|
|
777
822
|
while (pos < str.length) {
|
|
778
823
|
skipWs();
|
|
779
|
-
if (pos >= str.length)
|
|
824
|
+
if (pos >= str.length)
|
|
825
|
+
break;
|
|
780
826
|
if (str[pos] === ")") {
|
|
781
827
|
pos++;
|
|
782
828
|
return items;
|
|
783
829
|
}
|
|
784
830
|
const left = parseValue();
|
|
785
|
-
if (left === void 0)
|
|
831
|
+
if (left === void 0)
|
|
832
|
+
break;
|
|
786
833
|
skipWs();
|
|
787
834
|
if (str[pos] === "." && (pos + 1 >= str.length || /\s/.test(str[pos + 1]) || str[pos + 1] === ")")) {
|
|
788
835
|
pos++;
|
|
@@ -805,7 +852,8 @@ function parseLispRecursive(str) {
|
|
|
805
852
|
return parseValue();
|
|
806
853
|
}
|
|
807
854
|
function lispPairsToObject(pairs) {
|
|
808
|
-
if (!Array.isArray(pairs))
|
|
855
|
+
if (!Array.isArray(pairs))
|
|
856
|
+
return pairs;
|
|
809
857
|
const obj = {};
|
|
810
858
|
for (let i = 0; i < pairs.length - 1; i += 2) {
|
|
811
859
|
const key = pairs[i];
|
|
@@ -817,7 +865,8 @@ function lispPairsToObject(pairs) {
|
|
|
817
865
|
return obj;
|
|
818
866
|
}
|
|
819
867
|
function propertyPairsToObject(pairs) {
|
|
820
|
-
if (!Array.isArray(pairs))
|
|
868
|
+
if (!Array.isArray(pairs))
|
|
869
|
+
return null;
|
|
821
870
|
const obj = {};
|
|
822
871
|
for (const pair of pairs) {
|
|
823
872
|
if (Array.isArray(pair) && pair.length >= 2) {
|
|
@@ -828,8 +877,10 @@ function propertyPairsToObject(pairs) {
|
|
|
828
877
|
}
|
|
829
878
|
function buildEntityPropertiesCode({ type, layer, bbox }) {
|
|
830
879
|
const items = [];
|
|
831
|
-
if (type)
|
|
832
|
-
|
|
880
|
+
if (type)
|
|
881
|
+
items.push(`(cons 0 "${type.replace(/"/g, '\\"')}")`);
|
|
882
|
+
if (layer)
|
|
883
|
+
items.push(`(cons 8 "${layer.replace(/"/g, '\\"')}")`);
|
|
833
884
|
if (bbox) {
|
|
834
885
|
const parts = bbox.split(",").map((s) => parseFloat(s.trim()));
|
|
835
886
|
if (parts.length === 4) {
|
|
@@ -860,8 +911,8 @@ var RESOURCES = [
|
|
|
860
911
|
{ uri: "atlisp://dwg/text-content", name: "Text Content", description: "\u6587\u672C\u5185\u5BB9\u53CA\u4F4D\u7F6E\uFF0C\u7528\u4E8E\u8BED\u4E49\u5206\u6790\u3002\u652F\u6301 ?layer=0&bbox=0,0,100,100&limit=5000&offset=0", mimeType: "application/json", subscribable: true },
|
|
861
912
|
{ uri: "atlisp://dwg/name", name: "DWG Name", description: "\u5F53\u524D DWG \u6587\u4EF6\u540D", mimeType: "application/json", subscribable: true },
|
|
862
913
|
{ uri: "atlisp://dwg/path", name: "DWG Path", description: "\u6587\u4EF6\u5B8C\u6574\u8DEF\u5F84", mimeType: "application/json", subscribable: true },
|
|
863
|
-
{ uri: "atlisp://dwg/block-refs", name: "Block References", description: "\u5757\u53C2\u7167\u5217\u8868\u53CA\u5C5E\u6027\u503C\u3001\u52A8\u6001\u5757\u7279\u6027\uFF0C\u652F\u6301
|
|
864
|
-
{ uri: "atlisp://dwg/tbl", name: "Tables", description: "CAD \u8868\u6570\u636E (layer, block, textstyle, dimstyle, linetype, ucs, view, viewport, regapp)\uFF0C\u652F\u6301
|
|
914
|
+
{ uri: "atlisp://dwg/block-refs", name: "Block References", description: "\u5757\u53C2\u7167\u5217\u8868\u53CA\u5C5E\u6027\u503C\u3001\u52A8\u6001\u5757\u7279\u6027\uFF0C\u652F\u6301\u8DEF\u5F84\u65B9\u5F0F atlisp://dwg/block-refs/{blockName}", mimeType: "application/json", subscribable: true },
|
|
915
|
+
{ uri: "atlisp://dwg/tbl", name: "Tables", description: "CAD \u8868\u6570\u636E (layer, block, textstyle, dimstyle, linetype, ucs, view, viewport, regapp)\uFF0C\u652F\u6301\u8DEF\u5F84\u65B9\u5F0F atlisp://dwg/tbl/layer", mimeType: "application/json", subscribable: true },
|
|
865
916
|
{ uri: "atlisp://cad/dwgs", name: "DWG List", description: "\u6240\u6709\u6253\u5F00\u7684 DWG \u6587\u4EF6\u5217\u8868", mimeType: "application/json", subscribable: true },
|
|
866
917
|
{ uri: "atlisp://packages", name: "Packages", description: "\u5DF2\u5B89\u88C5\u5305\u5217\u8868", mimeType: "application/json", subscribable: true },
|
|
867
918
|
{ uri: "atlisp://platforms", name: "Platforms", description: "\u652F\u6301\u7684\u5E73\u53F0\u4FE1\u606F", mimeType: "application/json", subscribable: false },
|
|
@@ -870,20 +921,29 @@ var RESOURCES = [
|
|
|
870
921
|
];
|
|
871
922
|
function parseQuery(uri) {
|
|
872
923
|
const qIdx = uri.indexOf("?");
|
|
873
|
-
if (qIdx === -1)
|
|
924
|
+
if (qIdx === -1)
|
|
925
|
+
return { base: uri, params: {} };
|
|
874
926
|
const base = uri.substring(0, qIdx);
|
|
875
927
|
const params = {};
|
|
876
928
|
uri.substring(qIdx + 1).split("&").forEach((p) => {
|
|
877
929
|
const eqIdx = p.indexOf("=");
|
|
878
930
|
const k = eqIdx === -1 ? p : p.substring(0, eqIdx);
|
|
879
931
|
const v = eqIdx === -1 ? "" : p.substring(eqIdx + 1);
|
|
880
|
-
if (k)
|
|
932
|
+
if (k)
|
|
933
|
+
params[k] = decodeURIComponent(v);
|
|
881
934
|
});
|
|
882
935
|
return { base, params };
|
|
883
936
|
}
|
|
884
937
|
function parseTemplateUri(uri) {
|
|
885
|
-
const
|
|
886
|
-
if (
|
|
938
|
+
const entityMatch = uri.match(/^atlisp:\/\/dwg\/entity\/([^?]+)$/);
|
|
939
|
+
if (entityMatch)
|
|
940
|
+
return { type: "entity", handle: entityMatch[1] };
|
|
941
|
+
const tblMatch = uri.match(/^atlisp:\/\/dwg\/tbl\/([^?]+)$/);
|
|
942
|
+
if (tblMatch)
|
|
943
|
+
return { type: "tbl", tblName: tblMatch[1] };
|
|
944
|
+
const blockRefMatch = uri.match(/^atlisp:\/\/dwg\/block-refs\/([^?]+)$/);
|
|
945
|
+
if (blockRefMatch)
|
|
946
|
+
return { type: "block-refs", blockName: blockRefMatch[1] };
|
|
887
947
|
return null;
|
|
888
948
|
}
|
|
889
949
|
async function listResources(subscribedUris = []) {
|
|
@@ -897,8 +957,16 @@ async function listResources(subscribedUris = []) {
|
|
|
897
957
|
}
|
|
898
958
|
async function readResource(uri) {
|
|
899
959
|
const templateMatch = parseTemplateUri(uri);
|
|
900
|
-
if (templateMatch
|
|
901
|
-
|
|
960
|
+
if (templateMatch) {
|
|
961
|
+
if (templateMatch.type === "entity") {
|
|
962
|
+
return await getEntityByHandle(templateMatch.handle);
|
|
963
|
+
}
|
|
964
|
+
if (templateMatch.type === "tbl") {
|
|
965
|
+
return await getTables({ tbl: templateMatch.tblName });
|
|
966
|
+
}
|
|
967
|
+
if (templateMatch.type === "block-refs") {
|
|
968
|
+
return await getBlockRefs({ blockName: templateMatch.blockName });
|
|
969
|
+
}
|
|
902
970
|
}
|
|
903
971
|
const { base, params } = parseQuery(uri);
|
|
904
972
|
switch (base) {
|
|
@@ -931,8 +999,10 @@ async function readResource(uri) {
|
|
|
931
999
|
}
|
|
932
1000
|
}
|
|
933
1001
|
async function getEntityByHandle(handle) {
|
|
934
|
-
if (!cad.connected)
|
|
935
|
-
|
|
1002
|
+
if (!cad.connected)
|
|
1003
|
+
await cad.connect();
|
|
1004
|
+
if (!cad.connected)
|
|
1005
|
+
return { error: "CAD \u672A\u8FDE\u63A5" };
|
|
936
1006
|
const code = `(progn
|
|
937
1007
|
(vl-load-com)
|
|
938
1008
|
(if (setq ent (handent "${handle}"))
|
|
@@ -952,7 +1022,8 @@ async function getEntityByHandle(handle) {
|
|
|
952
1022
|
)`;
|
|
953
1023
|
try {
|
|
954
1024
|
const result = await cad.sendCommandWithResult(code);
|
|
955
|
-
if (!result || result === "nil")
|
|
1025
|
+
if (!result || result === "nil")
|
|
1026
|
+
return { error: `\u672A\u627E\u5230\u5B9E\u4F53: ${handle}` };
|
|
956
1027
|
try {
|
|
957
1028
|
return JSON.parse(result);
|
|
958
1029
|
} catch {
|
|
@@ -964,7 +1035,8 @@ async function getEntityByHandle(handle) {
|
|
|
964
1035
|
}
|
|
965
1036
|
async function getCadInfo() {
|
|
966
1037
|
const cached = getCached("cad:info");
|
|
967
|
-
if (cached)
|
|
1038
|
+
if (cached)
|
|
1039
|
+
return cached;
|
|
968
1040
|
if (!cad.connected) {
|
|
969
1041
|
await cad.connect();
|
|
970
1042
|
}
|
|
@@ -991,8 +1063,10 @@ async function getCadInfo() {
|
|
|
991
1063
|
async function getEntities(params = {}) {
|
|
992
1064
|
const cacheKey = `dwg:entities:${JSON.stringify(params)}`;
|
|
993
1065
|
const cached = getCached(cacheKey);
|
|
994
|
-
if (cached)
|
|
995
|
-
|
|
1066
|
+
if (cached)
|
|
1067
|
+
return cached;
|
|
1068
|
+
if (!cad.connected)
|
|
1069
|
+
await cad.connect();
|
|
996
1070
|
if (!cad.connected) {
|
|
997
1071
|
const result = { total: 0, entities: [] };
|
|
998
1072
|
setCache(cacheKey, result);
|
|
@@ -1093,7 +1167,8 @@ async function getEntitiesSummary(cacheKey) {
|
|
|
1093
1167
|
}
|
|
1094
1168
|
function buildTextContentCode({ layer, bbox, offset, limit }) {
|
|
1095
1169
|
const items = [`'(0 . "TEXT,MTEXT,ATTRIB,TCH_TEXT")`];
|
|
1096
|
-
if (layer)
|
|
1170
|
+
if (layer)
|
|
1171
|
+
items.push(`(cons 8 "${layer.replace(/"/g, '\\"')}")`);
|
|
1097
1172
|
if (bbox) {
|
|
1098
1173
|
const parts = bbox.split(",").map((s) => parseFloat(s.trim()));
|
|
1099
1174
|
if (parts.length === 4) {
|
|
@@ -1122,8 +1197,10 @@ function buildTextContentCode({ layer, bbox, offset, limit }) {
|
|
|
1122
1197
|
async function getTextContent(params = {}) {
|
|
1123
1198
|
const cacheKey = `dwg:text-content:${JSON.stringify(params)}`;
|
|
1124
1199
|
const cached = getCached(cacheKey);
|
|
1125
|
-
if (cached)
|
|
1126
|
-
|
|
1200
|
+
if (cached)
|
|
1201
|
+
return cached;
|
|
1202
|
+
if (!cad.connected)
|
|
1203
|
+
await cad.connect();
|
|
1127
1204
|
if (!cad.connected) {
|
|
1128
1205
|
const result = { total: 0, offset: 0, limit: 5e3, texts: [] };
|
|
1129
1206
|
setCache(cacheKey, result);
|
|
@@ -1148,11 +1225,13 @@ async function getTextContent(params = {}) {
|
|
|
1148
1225
|
const data = lispPairsToObject(parsed);
|
|
1149
1226
|
const rawTexts = Array.isArray(data.texts) ? data.texts : [];
|
|
1150
1227
|
data.texts = rawTexts.map((item) => {
|
|
1151
|
-
if (!Array.isArray(item))
|
|
1228
|
+
if (!Array.isArray(item))
|
|
1229
|
+
return null;
|
|
1152
1230
|
const obj = {};
|
|
1153
1231
|
item.forEach((pair) => {
|
|
1154
1232
|
if (Array.isArray(pair) && pair.length >= 2) {
|
|
1155
|
-
if (pair[0] === "text")
|
|
1233
|
+
if (pair[0] === "text")
|
|
1234
|
+
obj.text = String(pair[1] || "");
|
|
1156
1235
|
else if (pair[0] === "position" && Array.isArray(pair[1])) {
|
|
1157
1236
|
obj.position = pair[1].map((v) => typeof v === "number" ? v : 0);
|
|
1158
1237
|
}
|
|
@@ -1170,8 +1249,10 @@ async function getTextContent(params = {}) {
|
|
|
1170
1249
|
}
|
|
1171
1250
|
}
|
|
1172
1251
|
async function getDwgName() {
|
|
1173
|
-
if (!cad.connected)
|
|
1174
|
-
|
|
1252
|
+
if (!cad.connected)
|
|
1253
|
+
await cad.connect();
|
|
1254
|
+
if (!cad.connected)
|
|
1255
|
+
return { name: null };
|
|
1175
1256
|
try {
|
|
1176
1257
|
const code = `(vl-princ-to-string (getvar "dwgname"))`;
|
|
1177
1258
|
const name = await cad.sendCommandWithResult(code);
|
|
@@ -1181,8 +1262,10 @@ async function getDwgName() {
|
|
|
1181
1262
|
}
|
|
1182
1263
|
}
|
|
1183
1264
|
async function getDwgPath() {
|
|
1184
|
-
if (!cad.connected)
|
|
1185
|
-
|
|
1265
|
+
if (!cad.connected)
|
|
1266
|
+
await cad.connect();
|
|
1267
|
+
if (!cad.connected)
|
|
1268
|
+
return { path: null, name: null };
|
|
1186
1269
|
try {
|
|
1187
1270
|
const code = `(progn
|
|
1188
1271
|
(setq prefix (vl-princ-to-string (getvar "dwgprefix")))
|
|
@@ -1200,7 +1283,8 @@ async function getDwgPath() {
|
|
|
1200
1283
|
}
|
|
1201
1284
|
if (!parsed) {
|
|
1202
1285
|
const listResult = parseLispList(result);
|
|
1203
|
-
if (listResult && listResult.length >= 2)
|
|
1286
|
+
if (listResult && listResult.length >= 2)
|
|
1287
|
+
parsed = listResult;
|
|
1204
1288
|
}
|
|
1205
1289
|
if (parsed && Array.isArray(parsed) && parsed.length >= 2) {
|
|
1206
1290
|
return { path: String(parsed[0]), name: String(parsed[1]) };
|
|
@@ -1287,8 +1371,10 @@ function buildBlockRefsCode(filterBlockName) {
|
|
|
1287
1371
|
async function getBlockRefs(params = {}) {
|
|
1288
1372
|
const cacheKey = `dwg:block-refs:${params.blockName || "all"}`;
|
|
1289
1373
|
const cached = getCached(cacheKey);
|
|
1290
|
-
if (cached)
|
|
1291
|
-
|
|
1374
|
+
if (cached)
|
|
1375
|
+
return cached;
|
|
1376
|
+
if (!cad.connected)
|
|
1377
|
+
await cad.connect();
|
|
1292
1378
|
if (!cad.connected) {
|
|
1293
1379
|
const result = { total: 0, blockRefs: [] };
|
|
1294
1380
|
setCache(cacheKey, result);
|
|
@@ -1342,76 +1428,93 @@ async function getBlockRefs(params = {}) {
|
|
|
1342
1428
|
return result;
|
|
1343
1429
|
}
|
|
1344
1430
|
}
|
|
1345
|
-
var
|
|
1346
|
-
layer: { name: "
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1431
|
+
var TBL_QUERIES = {
|
|
1432
|
+
layer: { name: "layer", lisp: `(progn
|
|
1433
|
+
(setq @d nil)
|
|
1434
|
+
(vlax-for e (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
|
|
1435
|
+
(setq @d (cons (list
|
|
1436
|
+
(cons 2 (vla-get-name e))
|
|
1437
|
+
(cons 62 (vla-get-color e))
|
|
1438
|
+
(cons 6 (vla-get-linetype e))
|
|
1439
|
+
(cons 70 (logior (if (vla-get-freeze e) 1 0) (if (vla-get-lock e) 4 0)))
|
|
1440
|
+
(cons 60 (if (vla-get-layeron e) 0 1))
|
|
1441
|
+
) @d)))
|
|
1442
|
+
(list (cons 'table 'layer) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` },
|
|
1443
|
+
block: { name: "block", lisp: `(progn
|
|
1444
|
+
(setq @d nil)
|
|
1445
|
+
(vlax-for e (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
|
|
1446
|
+
(if (not (and (vlax-property-available-p e 'isfoundation) (vlax-get e 'isfoundation)))
|
|
1447
|
+
(setq @d (cons (list (cons 2 (vla-get-name e)) (cons 70 (if (and (vlax-property-available-p e 'isxref) (vlax-get e 'isxref)) 1 0))) @d))))
|
|
1448
|
+
(list (cons 'table 'block) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` },
|
|
1449
|
+
style: { name: "style", lisp: `(progn
|
|
1450
|
+
(setq @d nil)
|
|
1451
|
+
(vlax-for e (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object)))
|
|
1452
|
+
(setq @d (cons (list (cons 2 (vla-get-name e)) (cons 70 0)) @d)))
|
|
1453
|
+
(list (cons 'table 'style) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` },
|
|
1454
|
+
dimstyle: { name: "dimstyle", lisp: `(progn
|
|
1455
|
+
(setq @d nil)
|
|
1456
|
+
(vlax-for e (vla-get-dimstyles (vla-get-activedocument (vlax-get-acad-object)))
|
|
1457
|
+
(setq @d (cons (list (cons 2 (vla-get-name e)) (cons 70 0)) @d)))
|
|
1458
|
+
(list (cons 'table 'dimstyle) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` },
|
|
1459
|
+
ltype: { name: "linetype", lisp: `(progn
|
|
1460
|
+
(setq @d nil)
|
|
1461
|
+
(vlax-for e (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))
|
|
1462
|
+
(setq @d (cons (list (cons 2 (vla-get-name e)) (cons 70 0)) @d)))
|
|
1463
|
+
(list (cons 'table 'linetype) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` }
|
|
1357
1464
|
};
|
|
1358
1465
|
function buildTablesCode(tblName) {
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1361
|
-
(
|
|
1362
|
-
(
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
(reverse res))
|
|
1367
|
-
(defun @tbl:get-all nil
|
|
1368
|
-
(list
|
|
1369
|
-
(cons "layer" (@tbl:get "LAYER"))
|
|
1370
|
-
(cons "block" (@tbl:get "BLOCK"))
|
|
1371
|
-
(cons "textstyle" (@tbl:get "STYLE"))
|
|
1372
|
-
(cons "dimstyle" (@tbl:get "DIMSTYLE"))
|
|
1373
|
-
(cons "linetype" (@tbl:get "LTYPE"))
|
|
1374
|
-
(cons "ucs" (@tbl:get "UCS"))
|
|
1375
|
-
(cons "view" (@tbl:get "VIEW"))
|
|
1376
|
-
(cons "regapp" (@tbl:get "REGAPP"))
|
|
1377
|
-
))
|
|
1378
|
-
(if (member (strcase "${tblName}") (list "${validTbls}"))
|
|
1379
|
-
(list (cons "table" (strcase "${tblName}")) (cons "data" (@tbl:get (strcase "${tblName}"))))
|
|
1380
|
-
(@tbl:get-all)))
|
|
1381
|
-
`;
|
|
1466
|
+
const key = tblName.toLowerCase();
|
|
1467
|
+
const query = TBL_QUERIES[key];
|
|
1468
|
+
if (query) {
|
|
1469
|
+
return `(progn (vl-load-com) ${query.lisp})`;
|
|
1470
|
+
}
|
|
1471
|
+
const parts = Object.values(TBL_QUERIES).map((q) => q.lisp);
|
|
1472
|
+
return `(progn (vl-load-com) (list ${parts.join(" ")}))`;
|
|
1382
1473
|
}
|
|
1383
1474
|
function parseTableRecord(rec) {
|
|
1384
|
-
if (!Array.isArray(rec)
|
|
1385
|
-
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
const obj = { name: String(name) };
|
|
1389
|
-
data.forEach((pair) => {
|
|
1475
|
+
if (!rec || !Array.isArray(rec))
|
|
1476
|
+
return null;
|
|
1477
|
+
const obj = {};
|
|
1478
|
+
for (const pair of rec) {
|
|
1390
1479
|
if (Array.isArray(pair) && pair.length >= 2) {
|
|
1391
|
-
const key = pair[0];
|
|
1392
|
-
|
|
1393
|
-
if (key ===
|
|
1394
|
-
|
|
1395
|
-
else if (key ===
|
|
1396
|
-
|
|
1397
|
-
else if (key ===
|
|
1398
|
-
|
|
1399
|
-
else if (key ===
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
else if (key ===
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1480
|
+
const key = String(pair[0]);
|
|
1481
|
+
const val = pair[1];
|
|
1482
|
+
if (key === "2")
|
|
1483
|
+
obj.name = String(val);
|
|
1484
|
+
else if (key === "62")
|
|
1485
|
+
obj.color = typeof val === "number" ? val : 7;
|
|
1486
|
+
else if (key === "6")
|
|
1487
|
+
obj.linetype = String(val);
|
|
1488
|
+
else if (key === "70") {
|
|
1489
|
+
obj.flags = typeof val === "number" ? val : 0;
|
|
1490
|
+
obj.frozen = (val & 1) !== 0;
|
|
1491
|
+
obj.locked = (val & 4) !== 0;
|
|
1492
|
+
} else if (key === "60")
|
|
1493
|
+
obj.on = val === 0;
|
|
1494
|
+
else if (key === "1")
|
|
1495
|
+
obj.font = String(val);
|
|
1496
|
+
else if (key === "40")
|
|
1497
|
+
obj.height = typeof val === "number" ? val : 0;
|
|
1498
|
+
else if (key === "41")
|
|
1499
|
+
obj.width = typeof val === "number" ? val : 1;
|
|
1500
|
+
else if (key === "42")
|
|
1501
|
+
obj.oblique = typeof val === "number" ? val : 0;
|
|
1502
|
+
else if (key === "3")
|
|
1503
|
+
obj.description = String(val);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
return obj.name ? obj : null;
|
|
1407
1507
|
}
|
|
1408
1508
|
async function getTables(params = {}) {
|
|
1409
|
-
const tblName = params.tbl || "all";
|
|
1509
|
+
const tblName = params.tbl || params.type || "all";
|
|
1410
1510
|
const cacheKey = `dwg:tbl:${tblName}`;
|
|
1411
1511
|
const cached = getCached(cacheKey);
|
|
1412
|
-
if (cached)
|
|
1413
|
-
|
|
1414
|
-
if (!cad.connected)
|
|
1512
|
+
if (cached)
|
|
1513
|
+
return cached;
|
|
1514
|
+
if (!cad.connected)
|
|
1515
|
+
await cad.connect();
|
|
1516
|
+
if (!cad.connected)
|
|
1517
|
+
return { table: tblName, data: [] };
|
|
1415
1518
|
try {
|
|
1416
1519
|
const code = buildTablesCode(tblName);
|
|
1417
1520
|
const resultStr = await cad.sendCommandWithResult(code);
|
|
@@ -1422,27 +1525,73 @@ async function getTables(params = {}) {
|
|
|
1422
1525
|
}
|
|
1423
1526
|
const parsed = parseLispRecursive(resultStr);
|
|
1424
1527
|
if (!parsed || !Array.isArray(parsed)) {
|
|
1425
|
-
const result2 = { table: tblName, data: [] };
|
|
1528
|
+
const result2 = { table: tblName, total: 0, data: [] };
|
|
1426
1529
|
setCache(cacheKey, result2);
|
|
1427
1530
|
return result2;
|
|
1428
1531
|
}
|
|
1429
|
-
const isSingleTable = parsed.length >= 2 && parsed[0] === "table";
|
|
1430
1532
|
let result;
|
|
1431
|
-
if (
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1533
|
+
if (parsed.length >= 3 && parsed[0] && String(parsed[0][0]).toUpperCase() === "TABLE") {
|
|
1534
|
+
const tableName = String(parsed[0][1]).toLowerCase();
|
|
1535
|
+
let total = 0;
|
|
1536
|
+
let tblData = [];
|
|
1537
|
+
for (const item of parsed) {
|
|
1538
|
+
if (Array.isArray(item) && item.length >= 2) {
|
|
1539
|
+
const key = String(item[0]).toUpperCase();
|
|
1540
|
+
if (key === "TOTAL")
|
|
1541
|
+
total = typeof item[1] === "number" ? item[1] : 0;
|
|
1542
|
+
else if (key === "DATA") {
|
|
1543
|
+
if (Array.isArray(item[1]) && item[1].length > 0 && item[1][0].length > 0 && !isNaN(parseInt(item[1][0][0]))) {
|
|
1544
|
+
tblData = item[1];
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
if (tblData.length === 0 && parsed.length > 2) {
|
|
1550
|
+
tblData = parsed.slice(2);
|
|
1551
|
+
}
|
|
1434
1552
|
result = {
|
|
1435
|
-
table:
|
|
1553
|
+
table: tableName,
|
|
1554
|
+
total,
|
|
1436
1555
|
data: tblData.map(parseTableRecord).filter(Boolean)
|
|
1437
1556
|
};
|
|
1438
1557
|
} else {
|
|
1439
1558
|
const allData = {};
|
|
1440
1559
|
parsed.forEach((item) => {
|
|
1441
|
-
if (Array.isArray(item)
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1560
|
+
if (!Array.isArray(item) || item.length < 2)
|
|
1561
|
+
return;
|
|
1562
|
+
let tableKey = null;
|
|
1563
|
+
const entry = { total: 0, data: [] };
|
|
1564
|
+
if (Array.isArray(item[0]) && item[0].length >= 2 && String(item[0][0]).toLowerCase() === "table") {
|
|
1565
|
+
tableKey = String(item[0][1]).toLowerCase();
|
|
1566
|
+
for (let i = 1; i < item.length; i++) {
|
|
1567
|
+
const sub = item[i];
|
|
1568
|
+
if (!Array.isArray(sub) || sub.length < 2)
|
|
1569
|
+
continue;
|
|
1570
|
+
const subKey = String(sub[0]).toUpperCase();
|
|
1571
|
+
if (subKey === "TOTAL")
|
|
1572
|
+
entry.total = typeof sub[1] === "number" ? sub[1] : 0;
|
|
1573
|
+
else if (subKey === "DATA") {
|
|
1574
|
+
const raw = Array.isArray(sub[1]) ? sub[1] : sub.slice(1);
|
|
1575
|
+
entry.data = raw.map(parseTableRecord).filter(Boolean);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
} else {
|
|
1579
|
+
tableKey = String(item[0]).toLowerCase();
|
|
1580
|
+
for (let i = 1; i < item.length; i++) {
|
|
1581
|
+
const sub = item[i];
|
|
1582
|
+
if (!Array.isArray(sub) || sub.length < 2)
|
|
1583
|
+
continue;
|
|
1584
|
+
const subKey = String(sub[0]).toUpperCase();
|
|
1585
|
+
if (subKey === "TOTAL") {
|
|
1586
|
+
entry.total = typeof sub[1] === "number" ? sub[1] : 0;
|
|
1587
|
+
} else if (subKey === "DATA") {
|
|
1588
|
+
const raw = Array.isArray(sub[1]) ? sub[1] : sub.slice(1);
|
|
1589
|
+
entry.data = raw.map(parseTableRecord).filter(Boolean);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1445
1592
|
}
|
|
1593
|
+
if (tableKey)
|
|
1594
|
+
allData[tableKey] = entry;
|
|
1446
1595
|
});
|
|
1447
1596
|
result = allData;
|
|
1448
1597
|
}
|
|
@@ -1458,9 +1607,12 @@ async function getTables(params = {}) {
|
|
|
1458
1607
|
async function getPackages(filterName = null) {
|
|
1459
1608
|
const cacheKey = filterName ? `packages:${filterName}` : "packages:all";
|
|
1460
1609
|
const cached = getCached(cacheKey);
|
|
1461
|
-
if (cached)
|
|
1462
|
-
|
|
1463
|
-
if (!cad.connected)
|
|
1610
|
+
if (cached)
|
|
1611
|
+
return cached;
|
|
1612
|
+
if (!cad.connected)
|
|
1613
|
+
await cad.connect();
|
|
1614
|
+
if (!cad.connected)
|
|
1615
|
+
return [];
|
|
1464
1616
|
try {
|
|
1465
1617
|
const code = `(mapcar 'cdr @::*local-pkgs*)`;
|
|
1466
1618
|
const result = await cad.sendCommandWithResult(code);
|
|
@@ -1474,7 +1626,8 @@ async function getPackages(filterName = null) {
|
|
|
1474
1626
|
} catch {
|
|
1475
1627
|
raw = parseLispList(result) || [];
|
|
1476
1628
|
}
|
|
1477
|
-
if (!Array.isArray(raw))
|
|
1629
|
+
if (!Array.isArray(raw))
|
|
1630
|
+
raw = [];
|
|
1478
1631
|
const packages = raw.map((item) => {
|
|
1479
1632
|
if (Array.isArray(item)) {
|
|
1480
1633
|
const pkg = { name: "", version: "0.0.0", description: "", loaded: true };
|
|
@@ -1483,13 +1636,20 @@ async function getPackages(filterName = null) {
|
|
|
1483
1636
|
const [[key, val]] = Object.entries(entry);
|
|
1484
1637
|
const k = String(key);
|
|
1485
1638
|
const v = String(val);
|
|
1486
|
-
if (k === ":NAME")
|
|
1487
|
-
|
|
1488
|
-
else if (k === ":
|
|
1489
|
-
|
|
1490
|
-
else if (k === ":
|
|
1491
|
-
|
|
1492
|
-
else if (k === ":
|
|
1639
|
+
if (k === ":NAME")
|
|
1640
|
+
pkg.name = v;
|
|
1641
|
+
else if (k === ":VERSION")
|
|
1642
|
+
pkg.version = v;
|
|
1643
|
+
else if (k === ":DESCRIPTION")
|
|
1644
|
+
pkg.description = v;
|
|
1645
|
+
else if (k === ":FULL-NAME")
|
|
1646
|
+
pkg.fullName = v;
|
|
1647
|
+
else if (k === ":AUTHOR")
|
|
1648
|
+
pkg.author = v;
|
|
1649
|
+
else if (k === ":CATEGORY")
|
|
1650
|
+
pkg.category = v;
|
|
1651
|
+
else if (k === ":URL")
|
|
1652
|
+
pkg.url = v;
|
|
1493
1653
|
}
|
|
1494
1654
|
}
|
|
1495
1655
|
return pkg;
|
|
@@ -1500,15 +1660,22 @@ async function getPackages(filterName = null) {
|
|
|
1500
1660
|
if (item && typeof item === "object") {
|
|
1501
1661
|
const pkg = { name: "", version: "0.0.0", description: "", loaded: true };
|
|
1502
1662
|
const nameVal = item.name || item.Name || item.NAME || item[":NAME"];
|
|
1503
|
-
if (nameVal)
|
|
1663
|
+
if (nameVal)
|
|
1664
|
+
pkg.name = String(nameVal);
|
|
1504
1665
|
const verVal = item.version || item.Version || item.VERSION || item[":VERSION"];
|
|
1505
|
-
if (verVal)
|
|
1666
|
+
if (verVal)
|
|
1667
|
+
pkg.version = String(verVal);
|
|
1506
1668
|
const descVal = item.description || item.Description || item.DESCRIPTION || item[":DESCRIPTION"];
|
|
1507
|
-
if (descVal)
|
|
1508
|
-
|
|
1509
|
-
if (item.
|
|
1510
|
-
|
|
1511
|
-
if (item.
|
|
1669
|
+
if (descVal)
|
|
1670
|
+
pkg.description = String(descVal);
|
|
1671
|
+
if (item.fullName || item.full_name)
|
|
1672
|
+
pkg.fullName = String(item.fullName || item.full_name);
|
|
1673
|
+
if (item.author || item.Author)
|
|
1674
|
+
pkg.author = String(item.author || item.Author);
|
|
1675
|
+
if (item.category || item.Category)
|
|
1676
|
+
pkg.category = String(item.category || item.Category);
|
|
1677
|
+
if (item.url || item.Url || item.URL)
|
|
1678
|
+
pkg.url = String(item.url || item.Url || item.URL);
|
|
1512
1679
|
return pkg;
|
|
1513
1680
|
}
|
|
1514
1681
|
return null;
|
|
@@ -1534,9 +1701,12 @@ function getPlatforms() {
|
|
|
1534
1701
|
async function getDwgList() {
|
|
1535
1702
|
const cacheKey = "cad:dwgs";
|
|
1536
1703
|
const cached = getCached(cacheKey);
|
|
1537
|
-
if (cached)
|
|
1538
|
-
|
|
1539
|
-
if (!cad.connected)
|
|
1704
|
+
if (cached)
|
|
1705
|
+
return cached;
|
|
1706
|
+
if (!cad.connected)
|
|
1707
|
+
await cad.connect();
|
|
1708
|
+
if (!cad.connected)
|
|
1709
|
+
return [];
|
|
1540
1710
|
try {
|
|
1541
1711
|
const code = `(progn
|
|
1542
1712
|
(vl-load-com)
|
|
@@ -1560,7 +1730,8 @@ async function getDwgList() {
|
|
|
1560
1730
|
parsed = listResult;
|
|
1561
1731
|
}
|
|
1562
1732
|
}
|
|
1563
|
-
if (!Array.isArray(parsed))
|
|
1733
|
+
if (!Array.isArray(parsed))
|
|
1734
|
+
parsed = [];
|
|
1564
1735
|
const dwgList = parsed.map((item) => {
|
|
1565
1736
|
if (Array.isArray(item) && item.length >= 2) {
|
|
1566
1737
|
return { name: String(item[0]), path: String(item[1]) };
|
|
@@ -1587,7 +1758,8 @@ function loadStandardsFile(filename) {
|
|
|
1587
1758
|
var standardsCache = /* @__PURE__ */ new Map();
|
|
1588
1759
|
function getCachedStandards(key) {
|
|
1589
1760
|
const entry = standardsCache.get(key);
|
|
1590
|
-
if (entry && Date.now() - entry.timestamp < 3e4)
|
|
1761
|
+
if (entry && Date.now() - entry.timestamp < 3e4)
|
|
1762
|
+
return entry.data;
|
|
1591
1763
|
standardsCache.delete(key);
|
|
1592
1764
|
return null;
|
|
1593
1765
|
}
|
|
@@ -1596,16 +1768,20 @@ function setCachedStandards(key, data) {
|
|
|
1596
1768
|
}
|
|
1597
1769
|
function getDraftingStandards() {
|
|
1598
1770
|
const cached = getCachedStandards("drafting");
|
|
1599
|
-
if (cached)
|
|
1771
|
+
if (cached)
|
|
1772
|
+
return cached;
|
|
1600
1773
|
const data = loadStandardsFile("drafting.json");
|
|
1601
|
-
if (data)
|
|
1774
|
+
if (data)
|
|
1775
|
+
setCachedStandards("drafting", data);
|
|
1602
1776
|
return data || { error: "\u5236\u56FE\u89C4\u8303\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25" };
|
|
1603
1777
|
}
|
|
1604
1778
|
function getCodingStandards() {
|
|
1605
1779
|
const cached = getCachedStandards("coding");
|
|
1606
|
-
if (cached)
|
|
1780
|
+
if (cached)
|
|
1781
|
+
return cached;
|
|
1607
1782
|
const data = loadStandardsFile("coding.json");
|
|
1608
|
-
if (data)
|
|
1783
|
+
if (data)
|
|
1784
|
+
setCachedStandards("coding", data);
|
|
1609
1785
|
return data || { error: "\u7F16\u7801\u89C4\u8303\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25" };
|
|
1610
1786
|
}
|
|
1611
1787
|
|
|
@@ -1820,9 +1996,11 @@ var SseSession = class {
|
|
|
1820
1996
|
return lines.join("\n") + "\n\n";
|
|
1821
1997
|
}
|
|
1822
1998
|
_setupDrain() {
|
|
1823
|
-
if (typeof this.#res.on !== "function")
|
|
1999
|
+
if (typeof this.#res.on !== "function")
|
|
2000
|
+
return;
|
|
1824
2001
|
this.#drainHandler = () => {
|
|
1825
|
-
if (!this.#active)
|
|
2002
|
+
if (!this.#active)
|
|
2003
|
+
return;
|
|
1826
2004
|
if (this.#backpressureBuffer.length > 0) {
|
|
1827
2005
|
this._drainBuffer();
|
|
1828
2006
|
}
|
|
@@ -1844,7 +2022,8 @@ var SseSession = class {
|
|
|
1844
2022
|
}
|
|
1845
2023
|
}
|
|
1846
2024
|
_write(content) {
|
|
1847
|
-
if (!this.#active)
|
|
2025
|
+
if (!this.#active)
|
|
2026
|
+
return false;
|
|
1848
2027
|
try {
|
|
1849
2028
|
if (this.#backpressureBuffer.length > 0) {
|
|
1850
2029
|
this.#backpressureBuffer.push(content);
|
|
@@ -1972,7 +2151,8 @@ function persistSessionData(clientId, sessionData) {
|
|
|
1972
2151
|
function loadPersistedSessionData(clientId) {
|
|
1973
2152
|
try {
|
|
1974
2153
|
const filePath = getSessionStorePath(clientId);
|
|
1975
|
-
if (!fs4.existsSync(filePath))
|
|
2154
|
+
if (!fs4.existsSync(filePath))
|
|
2155
|
+
return null;
|
|
1976
2156
|
const raw = fs4.readFileSync(filePath, "utf-8");
|
|
1977
2157
|
const store = JSON.parse(raw);
|
|
1978
2158
|
if (Date.now() - store.savedAt > SESSION_STORE_TTL) {
|
|
@@ -2132,7 +2312,8 @@ var SessionTransport = class {
|
|
|
2132
2312
|
this._started = true;
|
|
2133
2313
|
}
|
|
2134
2314
|
async send(message) {
|
|
2135
|
-
if (this._closed)
|
|
2315
|
+
if (this._closed)
|
|
2316
|
+
return;
|
|
2136
2317
|
if (this._pendingRequest) {
|
|
2137
2318
|
const { resolve, reject, timeout } = this._pendingRequest;
|
|
2138
2319
|
clearTimeout(timeout);
|
|
@@ -2141,7 +2322,8 @@ var SessionTransport = class {
|
|
|
2141
2322
|
}
|
|
2142
2323
|
}
|
|
2143
2324
|
async close() {
|
|
2144
|
-
if (this._closed)
|
|
2325
|
+
if (this._closed)
|
|
2326
|
+
return;
|
|
2145
2327
|
this._closed = true;
|
|
2146
2328
|
if (this._pendingRequest) {
|
|
2147
2329
|
const { reject, timeout } = this._pendingRequest;
|
|
@@ -2453,10 +2635,14 @@ ${generateSuggestions(entities, layers)}`
|
|
|
2453
2635
|
}
|
|
2454
2636
|
function generateSuggestions(entities, layers) {
|
|
2455
2637
|
const suggestions = [];
|
|
2456
|
-
if (entities.total > 1e3)
|
|
2457
|
-
|
|
2458
|
-
if (
|
|
2459
|
-
|
|
2638
|
+
if (entities.total > 1e3)
|
|
2639
|
+
suggestions.push("- \u56FE\u7EB8\u5B9E\u4F53\u8F83\u591A\uFF0C\u5EFA\u8BAE\u4F7F\u7528\u56FE\u5C42\u5206\u7C7B\u7BA1\u7406");
|
|
2640
|
+
if (layers.length > 20)
|
|
2641
|
+
suggestions.push("- \u56FE\u5C42\u8F83\u591A\uFF0C\u5EFA\u8BAE\u6E05\u7406\u672A\u4F7F\u7528\u7684\u56FE\u5C42");
|
|
2642
|
+
if (entities.byType.LINE && entities.byType.LINE > 500)
|
|
2643
|
+
suggestions.push("- \u7EBF\u6761\u8F83\u591A\uFF0C\u53EF\u8003\u8651\u4F7F\u7528 BLOCK \u51CF\u5C11\u5B9E\u4F53\u6570\u91CF");
|
|
2644
|
+
if (!entities.byType.DIMENSION)
|
|
2645
|
+
suggestions.push("- \u672A\u53D1\u73B0\u5C3A\u5BF8\u6807\u6CE8\uFF0C\u5EFA\u8BAE\u6DFB\u52A0\u6807\u6CE8");
|
|
2460
2646
|
return suggestions.length ? suggestions.join("\n") : "- \u56FE\u7EB8\u7ED3\u6784\u826F\u597D";
|
|
2461
2647
|
}
|
|
2462
2648
|
async function generateBatchLinesPrompt(args) {
|
|
@@ -3001,7 +3187,8 @@ var Metrics = class {
|
|
|
3001
3187
|
bucket.sum += value;
|
|
3002
3188
|
bucket.min = Math.min(bucket.min, value);
|
|
3003
3189
|
bucket.max = Math.max(bucket.max, value);
|
|
3004
|
-
if (!bucket.values)
|
|
3190
|
+
if (!bucket.values)
|
|
3191
|
+
bucket.values = [];
|
|
3005
3192
|
bucket.values.push(value);
|
|
3006
3193
|
this.histograms.set(key, bucket);
|
|
3007
3194
|
}
|
|
@@ -3092,9 +3279,15 @@ var RESOURCE_TEMPLATES = [
|
|
|
3092
3279
|
mimeType: "application/json"
|
|
3093
3280
|
},
|
|
3094
3281
|
{
|
|
3095
|
-
uriTemplate: "atlisp://dwg/entities
|
|
3096
|
-
name: "Entities
|
|
3097
|
-
description: "\u6309\u7C7B\u578B\
|
|
3282
|
+
uriTemplate: "atlisp://dwg/entities",
|
|
3283
|
+
name: "Entities Summary",
|
|
3284
|
+
description: "\u8FD4\u56DE\u56FE\u5143\u603B\u6570\u548C\u6309\u7C7B\u578B\u7EDF\u8BA1\u5217\u8868",
|
|
3285
|
+
mimeType: "application/json"
|
|
3286
|
+
},
|
|
3287
|
+
{
|
|
3288
|
+
uriTemplate: "atlisp://dwg/entities?type={type}&layer={layer}&bbox={bbox}",
|
|
3289
|
+
name: "Filtered Entities",
|
|
3290
|
+
description: "\u6309 type/layer/bbox \u8FC7\u6EE4\u56FE\u5143\uFF0C\u8FD4\u56DE entity:properties \u5168\u5C5E\u6027 JSON\uFF08ObjectName, Handle, Layer, Color, Center, Radius \u7B49\uFF09",
|
|
3098
3291
|
mimeType: "application/json"
|
|
3099
3292
|
},
|
|
3100
3293
|
{
|
|
@@ -3104,13 +3297,13 @@ var RESOURCE_TEMPLATES = [
|
|
|
3104
3297
|
mimeType: "application/json"
|
|
3105
3298
|
},
|
|
3106
3299
|
{
|
|
3107
|
-
uriTemplate: "atlisp://dwg/block-refs
|
|
3300
|
+
uriTemplate: "atlisp://dwg/block-refs/{blockName}",
|
|
3108
3301
|
name: "Block References",
|
|
3109
3302
|
description: "\u83B7\u53D6\u5757\u53C2\u7167\u5217\u8868\uFF0C\u652F\u6301\u6309\u5757\u540D\u8FC7\u6EE4",
|
|
3110
3303
|
mimeType: "application/json"
|
|
3111
3304
|
},
|
|
3112
3305
|
{
|
|
3113
|
-
uriTemplate: "atlisp://dwg/tbl
|
|
3306
|
+
uriTemplate: "atlisp://dwg/tbl/{tbl}",
|
|
3114
3307
|
name: "CAD Tables",
|
|
3115
3308
|
description: "\u83B7\u53D6 CAD \u8868\u6570\u636E (layer, block, textstyle, dimstyle, linetype, ucs, view, regapp)",
|
|
3116
3309
|
mimeType: "application/json"
|
|
@@ -3240,7 +3433,8 @@ async function evalLisp(code, withResult = false, encoding = null) {
|
|
|
3240
3433
|
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3241
3434
|
}
|
|
3242
3435
|
const trimmed = (code || "").trim();
|
|
3243
|
-
if (!trimmed)
|
|
3436
|
+
if (!trimmed)
|
|
3437
|
+
return { content: [{ type: "text", text: "\u547D\u4EE4\u4E3A\u7A7A\uFF0C\u672A\u53D1\u9001" }] };
|
|
3244
3438
|
try {
|
|
3245
3439
|
if (withResult) {
|
|
3246
3440
|
const result = await cad.sendCommandWithResult(trimmed, encoding);
|
|
@@ -3260,14 +3454,17 @@ async function getCadInfo2() {
|
|
|
3260
3454
|
if (!cad.connected) {
|
|
3261
3455
|
await cad.connect();
|
|
3262
3456
|
}
|
|
3263
|
-
if (!cad.connected)
|
|
3457
|
+
if (!cad.connected)
|
|
3458
|
+
return { content: [{ type: "text", text: "CAD \u672A\u8FDE\u63A5" }] };
|
|
3264
3459
|
const info = await cad.getInfo();
|
|
3265
3460
|
return { content: [{ type: "text", text: info }] };
|
|
3266
3461
|
}
|
|
3267
3462
|
async function atCommand(command) {
|
|
3268
|
-
if (!cad.connected)
|
|
3463
|
+
if (!cad.connected)
|
|
3464
|
+
return { content: [{ type: "text", text: "\u8BF7\u5148\u8FDE\u63A5 CAD" }], isError: true };
|
|
3269
3465
|
const trimmed = (command || "").trim();
|
|
3270
|
-
if (!trimmed)
|
|
3466
|
+
if (!trimmed)
|
|
3467
|
+
return { content: [{ type: "text", text: "\u547D\u4EE4\u4E3A\u7A7A\uFF0C\u672A\u53D1\u9001" }] };
|
|
3271
3468
|
await cad.sendCommand(trimmed + "\n");
|
|
3272
3469
|
return { content: [{ type: "text", text: "\u5DF2\u53D1\u9001\u547D\u4EE4" }] };
|
|
3273
3470
|
}
|
|
@@ -3275,7 +3472,8 @@ async function newDocument() {
|
|
|
3275
3472
|
if (!cad.connected) {
|
|
3276
3473
|
await cad.connect();
|
|
3277
3474
|
}
|
|
3278
|
-
if (!cad.connected)
|
|
3475
|
+
if (!cad.connected)
|
|
3476
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3279
3477
|
const result = await cad.newDoc();
|
|
3280
3478
|
if (result) {
|
|
3281
3479
|
return { content: [{ type: "text", text: "\u5DF2\u5728 CAD \u4E2D\u65B0\u5EFA\u7A7A\u767D\u6587\u6863" }] };
|
|
@@ -3286,7 +3484,8 @@ async function bringToFront() {
|
|
|
3286
3484
|
if (!cad.connected) {
|
|
3287
3485
|
await cad.connect();
|
|
3288
3486
|
}
|
|
3289
|
-
if (!cad.connected)
|
|
3487
|
+
if (!cad.connected)
|
|
3488
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3290
3489
|
const result = await cad.bringToFront();
|
|
3291
3490
|
if (result) {
|
|
3292
3491
|
return { content: [{ type: "text", text: "\u5DF2\u5C06 CAD \u7A97\u53E3\u5207\u6362\u5230\u524D\u53F0" }] };
|
|
@@ -3297,7 +3496,8 @@ async function installAtlisp() {
|
|
|
3297
3496
|
if (!cad.connected) {
|
|
3298
3497
|
await cad.connect();
|
|
3299
3498
|
}
|
|
3300
|
-
if (!cad.connected)
|
|
3499
|
+
if (!cad.connected)
|
|
3500
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3301
3501
|
const installCode = `(progn(vl-load-com)(setq s strcat h "http" o(vlax-create-object (s"win"h".win"h"request.5.1"))v vlax-invoke e eval r read)(v o'open "get" (s h"://atlisp.""cn/@"):vlax-true)(v o'send)(v o'WaitforResponse 1000)(e(r(vlax-get-property o'ResponseText))))`;
|
|
3302
3502
|
await cad.sendCommand(installCode + "\n");
|
|
3303
3503
|
return { content: [{ type: "text", text: "\u5DF2\u53D1\u9001 @lisp \u5B89\u88C5\u4EE3\u7801\u5230 CAD" }] };
|
|
@@ -3306,10 +3506,12 @@ async function listFunctionsInCad() {
|
|
|
3306
3506
|
if (!cad.connected) {
|
|
3307
3507
|
await cad.connect();
|
|
3308
3508
|
}
|
|
3309
|
-
if (!cad.connected)
|
|
3509
|
+
if (!cad.connected)
|
|
3510
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3310
3511
|
try {
|
|
3311
3512
|
const result = await cad.sendCommandWithResult("(atoms-family 0)", null);
|
|
3312
|
-
if (result)
|
|
3513
|
+
if (result)
|
|
3514
|
+
return { content: [{ type: "text", text: result }] };
|
|
3313
3515
|
return { content: [{ type: "text", text: "CAD \u51FD\u6570\u5217\u8868\u4E3A\u7A7A" }] };
|
|
3314
3516
|
} catch (e) {
|
|
3315
3517
|
return { content: [{ type: "text", text: `\u9519\u8BEF: ${e.message}` }], isError: true };
|
|
@@ -3364,7 +3566,8 @@ async function initAtlisp() {
|
|
|
3364
3566
|
if (!cad.connected) {
|
|
3365
3567
|
await cad.connect();
|
|
3366
3568
|
}
|
|
3367
|
-
if (!cad.connected)
|
|
3569
|
+
if (!cad.connected)
|
|
3570
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3368
3571
|
const code = `(if (null @::load-module)
|
|
3369
3572
|
(progn
|
|
3370
3573
|
(vl-load-com)
|
|
@@ -3404,12 +3607,15 @@ async function fetchPackages() {
|
|
|
3404
3607
|
return cachedPackages || MOCK_PACKAGES;
|
|
3405
3608
|
}
|
|
3406
3609
|
function flattenPackages(data) {
|
|
3407
|
-
if (Array.isArray(data))
|
|
3408
|
-
|
|
3610
|
+
if (Array.isArray(data))
|
|
3611
|
+
return data;
|
|
3612
|
+
if (data && Array.isArray(data.packages))
|
|
3613
|
+
return data.packages;
|
|
3409
3614
|
return [];
|
|
3410
3615
|
}
|
|
3411
3616
|
async function listPackages() {
|
|
3412
|
-
if (!cad.connected)
|
|
3617
|
+
if (!cad.connected)
|
|
3618
|
+
await cad.connect();
|
|
3413
3619
|
if (!cad.connected) {
|
|
3414
3620
|
const data2 = await fetchPackages();
|
|
3415
3621
|
const items2 = flattenPackages(data2);
|
|
@@ -3417,7 +3623,8 @@ async function listPackages() {
|
|
|
3417
3623
|
return { content: [{ type: "text", text: text2 }] };
|
|
3418
3624
|
}
|
|
3419
3625
|
const result = await cad.sendCommandWithResult("(@::package-list-in-local)");
|
|
3420
|
-
if (result && result !== "nil")
|
|
3626
|
+
if (result && result !== "nil")
|
|
3627
|
+
return { content: [{ type: "text", text: result }] };
|
|
3421
3628
|
const data = await fetchPackages();
|
|
3422
3629
|
const items = flattenPackages(data);
|
|
3423
3630
|
const text = items.length ? `\u4ECE\u6CE8\u518C\u8868\u83B7\u53D6\u7684 @lisp \u5305:
|
|
@@ -3437,10 +3644,12 @@ async function searchPackages(query) {
|
|
|
3437
3644
|
for (const p of items) {
|
|
3438
3645
|
const name = (p.name || "").toLowerCase();
|
|
3439
3646
|
const desc = (p.description || "").toLowerCase();
|
|
3440
|
-
if (name.includes(q) || desc.includes(q))
|
|
3647
|
+
if (name.includes(q) || desc.includes(q))
|
|
3648
|
+
results.push(p);
|
|
3441
3649
|
}
|
|
3442
3650
|
} else {
|
|
3443
|
-
for (const p of items)
|
|
3651
|
+
for (const p of items)
|
|
3652
|
+
results.push(p);
|
|
3444
3653
|
}
|
|
3445
3654
|
if (results.length === 0) {
|
|
3446
3655
|
return { content: [{ type: "text", text: `\u672A\u627E\u5230\u5305\u542B "${query}" \u7684\u5305` }] };
|
|
@@ -3492,7 +3701,8 @@ function writeCacheToDisk(data) {
|
|
|
3492
3701
|
}
|
|
3493
3702
|
async function fetchFunctions() {
|
|
3494
3703
|
const diskCache = readCacheFromDisk();
|
|
3495
|
-
if (diskCache)
|
|
3704
|
+
if (diskCache)
|
|
3705
|
+
return diskCache;
|
|
3496
3706
|
try {
|
|
3497
3707
|
const response = await fetch(FUNCTIONS_URL, { headers: { "User-Agent": "atlisp-mcp" } });
|
|
3498
3708
|
if (response.ok) {
|
|
@@ -3512,7 +3722,8 @@ async function getFunctionUsage(funcName, packageName) {
|
|
|
3512
3722
|
if (data) {
|
|
3513
3723
|
const funcs = Object.values(data.all_functions || {});
|
|
3514
3724
|
const func = funcs.find((f2) => f2.name === funcName || f2.name === `${packageName}:${funcName}`);
|
|
3515
|
-
if (func)
|
|
3725
|
+
if (func)
|
|
3726
|
+
results.push(func);
|
|
3516
3727
|
}
|
|
3517
3728
|
if (results.length === 0 && FUNCTIONS_DIR) {
|
|
3518
3729
|
try {
|
|
@@ -3521,7 +3732,8 @@ async function getFunctionUsage(funcName, packageName) {
|
|
|
3521
3732
|
const raw = fs6.readFileSync(path8.join(FUNCTIONS_DIR, file), "utf-8");
|
|
3522
3733
|
const data2 = JSON.parse(raw);
|
|
3523
3734
|
const func = data2.functions?.find((f2) => f2.name === funcName);
|
|
3524
|
-
if (func)
|
|
3735
|
+
if (func)
|
|
3736
|
+
results.push(func);
|
|
3525
3737
|
}
|
|
3526
3738
|
} catch {
|
|
3527
3739
|
}
|
|
@@ -3589,7 +3801,8 @@ async function getEntity(handle) {
|
|
|
3589
3801
|
if (!cad.connected) {
|
|
3590
3802
|
await cad.connect();
|
|
3591
3803
|
}
|
|
3592
|
-
if (!cad.connected)
|
|
3804
|
+
if (!cad.connected)
|
|
3805
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3593
3806
|
const code = `(progn
|
|
3594
3807
|
(vl-load-com)
|
|
3595
3808
|
(if (setq ent (handent "${handle}"))
|
|
@@ -3621,7 +3834,8 @@ async function setEntityProperty(handle, property, value) {
|
|
|
3621
3834
|
if (!cad.connected) {
|
|
3622
3835
|
await cad.connect();
|
|
3623
3836
|
}
|
|
3624
|
-
if (!cad.connected)
|
|
3837
|
+
if (!cad.connected)
|
|
3838
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3625
3839
|
let propCode = "";
|
|
3626
3840
|
switch (property) {
|
|
3627
3841
|
case "layer":
|
|
@@ -3664,7 +3878,8 @@ async function deleteEntity(handle) {
|
|
|
3664
3878
|
if (!cad.connected) {
|
|
3665
3879
|
await cad.connect();
|
|
3666
3880
|
}
|
|
3667
|
-
if (!cad.connected)
|
|
3881
|
+
if (!cad.connected)
|
|
3882
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3668
3883
|
const code = `(progn
|
|
3669
3884
|
(vl-load-com)
|
|
3670
3885
|
(if (setq ent (handent "${handle}"))
|
|
@@ -3689,12 +3904,15 @@ async function selectEntities(filter) {
|
|
|
3689
3904
|
if (!cad.connected) {
|
|
3690
3905
|
await cad.connect();
|
|
3691
3906
|
}
|
|
3692
|
-
if (!cad.connected)
|
|
3907
|
+
if (!cad.connected)
|
|
3908
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3693
3909
|
let filterCode = "nil";
|
|
3694
3910
|
if (filter && (filter.type || filter.layer)) {
|
|
3695
3911
|
const items = [];
|
|
3696
|
-
if (filter.type)
|
|
3697
|
-
|
|
3912
|
+
if (filter.type)
|
|
3913
|
+
items.push(`'(0 . "${filter.type}")`);
|
|
3914
|
+
if (filter.layer)
|
|
3915
|
+
items.push(`'(8 . "${filter.layer}")`);
|
|
3698
3916
|
filterCode = `(list ${items.join(" ")})`;
|
|
3699
3917
|
}
|
|
3700
3918
|
const code = `(progn
|
|
@@ -3726,7 +3944,8 @@ async function createLayer(name, color = 7, linetype = "Continuous") {
|
|
|
3726
3944
|
if (!cad.connected) {
|
|
3727
3945
|
await cad.connect();
|
|
3728
3946
|
}
|
|
3729
|
-
if (!cad.connected)
|
|
3947
|
+
if (!cad.connected)
|
|
3948
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3730
3949
|
const code = `(progn
|
|
3731
3950
|
(vl-load-com)
|
|
3732
3951
|
(if (not (tblsearch "LAYER" "${name}"))
|
|
@@ -3762,7 +3981,8 @@ async function deleteLayer(name) {
|
|
|
3762
3981
|
if (!cad.connected) {
|
|
3763
3982
|
await cad.connect();
|
|
3764
3983
|
}
|
|
3765
|
-
if (!cad.connected)
|
|
3984
|
+
if (!cad.connected)
|
|
3985
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3766
3986
|
const code = `(progn
|
|
3767
3987
|
(vl-load-com)
|
|
3768
3988
|
(cond
|
|
@@ -3796,7 +4016,8 @@ async function setLayerProperty(name, property, value) {
|
|
|
3796
4016
|
if (!cad.connected) {
|
|
3797
4017
|
await cad.connect();
|
|
3798
4018
|
}
|
|
3799
|
-
if (!cad.connected)
|
|
4019
|
+
if (!cad.connected)
|
|
4020
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3800
4021
|
let propCode = "";
|
|
3801
4022
|
switch (property) {
|
|
3802
4023
|
case "color":
|
|
@@ -3844,7 +4065,8 @@ async function setCurrentLayer(name) {
|
|
|
3844
4065
|
if (!cad.connected) {
|
|
3845
4066
|
await cad.connect();
|
|
3846
4067
|
}
|
|
3847
|
-
if (!cad.connected)
|
|
4068
|
+
if (!cad.connected)
|
|
4069
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3848
4070
|
const code = `(progn
|
|
3849
4071
|
(vl-load-com)
|
|
3850
4072
|
(if (tblsearch "LAYER" "${name}")
|
|
@@ -3871,7 +4093,8 @@ async function createBlock(name, entities) {
|
|
|
3871
4093
|
if (!cad.connected) {
|
|
3872
4094
|
await cad.connect();
|
|
3873
4095
|
}
|
|
3874
|
-
if (!cad.connected)
|
|
4096
|
+
if (!cad.connected)
|
|
4097
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3875
4098
|
const code = `(progn
|
|
3876
4099
|
(vl-load-com)
|
|
3877
4100
|
(if (not (tblsearch "BLOCK" "${name}"))
|
|
@@ -3908,7 +4131,8 @@ async function insertBlock(blockName, point, scale = 1, rotation = 0) {
|
|
|
3908
4131
|
if (!cad.connected) {
|
|
3909
4132
|
await cad.connect();
|
|
3910
4133
|
}
|
|
3911
|
-
if (!cad.connected)
|
|
4134
|
+
if (!cad.connected)
|
|
4135
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3912
4136
|
const coords = Array.isArray(point) ? point : point.split(",").map((s) => parseFloat(s.trim()));
|
|
3913
4137
|
if (coords.length < 2) {
|
|
3914
4138
|
return { content: [{ type: "text", text: "\u63D2\u5165\u70B9\u683C\u5F0F\u9519\u8BEF\uFF0C\u9700\u8981 x,y \u6216 [x,y,z]" }], isError: true };
|
|
@@ -3938,7 +4162,8 @@ async function getBlocks() {
|
|
|
3938
4162
|
if (!cad.connected) {
|
|
3939
4163
|
await cad.connect();
|
|
3940
4164
|
}
|
|
3941
|
-
if (!cad.connected)
|
|
4165
|
+
if (!cad.connected)
|
|
4166
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3942
4167
|
const code = `(progn
|
|
3943
4168
|
(vl-load-com)
|
|
3944
4169
|
(setq blocks nil)
|
|
@@ -3961,7 +4186,8 @@ async function explodeBlock(handle) {
|
|
|
3961
4186
|
if (!cad.connected) {
|
|
3962
4187
|
await cad.connect();
|
|
3963
4188
|
}
|
|
3964
|
-
if (!cad.connected)
|
|
4189
|
+
if (!cad.connected)
|
|
4190
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3965
4191
|
const code = `(progn
|
|
3966
4192
|
(vl-load-com)
|
|
3967
4193
|
(if (setq ent (handent "${handle}"))
|
|
@@ -3988,7 +4214,8 @@ async function openDwg(filePath) {
|
|
|
3988
4214
|
if (!cad.connected) {
|
|
3989
4215
|
await cad.connect();
|
|
3990
4216
|
}
|
|
3991
|
-
if (!cad.connected)
|
|
4217
|
+
if (!cad.connected)
|
|
4218
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
3992
4219
|
const normalizedPath = filePath.replace(/\\/g, "\\\\");
|
|
3993
4220
|
const code = `(progn
|
|
3994
4221
|
(vl-load-com)
|
|
@@ -4025,7 +4252,8 @@ async function saveDwg(filePath = null) {
|
|
|
4025
4252
|
if (!cad.connected) {
|
|
4026
4253
|
await cad.connect();
|
|
4027
4254
|
}
|
|
4028
|
-
if (!cad.connected)
|
|
4255
|
+
if (!cad.connected)
|
|
4256
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4029
4257
|
const code = filePath ? `(progn
|
|
4030
4258
|
(vl-load-com)
|
|
4031
4259
|
(command "._SAVEAS" "${filePath.replace(/\\/g, "\\\\")}")
|
|
@@ -4049,7 +4277,8 @@ async function exportPdf(outputPath, layout = "Model") {
|
|
|
4049
4277
|
if (!cad.connected) {
|
|
4050
4278
|
await cad.connect();
|
|
4051
4279
|
}
|
|
4052
|
-
if (!cad.connected)
|
|
4280
|
+
if (!cad.connected)
|
|
4281
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4053
4282
|
const normalizedPath = outputPath.replace(/\\/g, "\\\\");
|
|
4054
4283
|
const code = `(progn
|
|
4055
4284
|
(vl-load-com)
|
|
@@ -4077,7 +4306,8 @@ async function closeDwg(save = false) {
|
|
|
4077
4306
|
if (!cad.connected) {
|
|
4078
4307
|
await cad.connect();
|
|
4079
4308
|
}
|
|
4080
|
-
if (!cad.connected)
|
|
4309
|
+
if (!cad.connected)
|
|
4310
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4081
4311
|
const code = `(progn
|
|
4082
4312
|
(vl-load-com)
|
|
4083
4313
|
(if ${save ? "T" : "nil"}
|
|
@@ -4099,7 +4329,8 @@ async function createDimension(type, points, style = {}) {
|
|
|
4099
4329
|
if (!cad.connected) {
|
|
4100
4330
|
await cad.connect();
|
|
4101
4331
|
}
|
|
4102
|
-
if (!cad.connected)
|
|
4332
|
+
if (!cad.connected)
|
|
4333
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4103
4334
|
let dimCode = "";
|
|
4104
4335
|
const validTypes = ["ALIGNED", "LINEAR", "ORDINATE", "RADIAL", "DIAMETER", "ANGULAR"];
|
|
4105
4336
|
const dimType = (type || "ALIGNED").toUpperCase();
|
|
@@ -4141,7 +4372,8 @@ async function getDimensionValue(handle) {
|
|
|
4141
4372
|
if (!cad.connected) {
|
|
4142
4373
|
await cad.connect();
|
|
4143
4374
|
}
|
|
4144
|
-
if (!cad.connected)
|
|
4375
|
+
if (!cad.connected)
|
|
4376
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4145
4377
|
const code = `(progn
|
|
4146
4378
|
(vl-load-com)
|
|
4147
4379
|
(if (setq ent (handent "${handle}"))
|
|
@@ -4172,7 +4404,8 @@ async function createHatch(patternName, boundary, scale = 1, angle = 0) {
|
|
|
4172
4404
|
if (!cad.connected) {
|
|
4173
4405
|
await cad.connect();
|
|
4174
4406
|
}
|
|
4175
|
-
if (!cad.connected)
|
|
4407
|
+
if (!cad.connected)
|
|
4408
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4176
4409
|
const code = `(progn
|
|
4177
4410
|
(vl-load-com)
|
|
4178
4411
|
(command "._BHATCH" "p" "${patternName}" "s" "s" "sc" ${scale} "an" ${angle} "")
|
|
@@ -4192,12 +4425,17 @@ async function setHatchProperties(handle, props) {
|
|
|
4192
4425
|
if (!cad.connected) {
|
|
4193
4426
|
await cad.connect();
|
|
4194
4427
|
}
|
|
4195
|
-
if (!cad.connected)
|
|
4428
|
+
if (!cad.connected)
|
|
4429
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4196
4430
|
let propCode = "";
|
|
4197
|
-
if (props.pattern)
|
|
4198
|
-
|
|
4199
|
-
if (props.
|
|
4200
|
-
|
|
4431
|
+
if (props.pattern)
|
|
4432
|
+
propCode += `(command "._HATCHEDIT" "${handle}" "p" "${props.pattern}")`;
|
|
4433
|
+
if (props.scale)
|
|
4434
|
+
propCode += `(command "._HATCHEDIT" "${handle}" "s" ${props.scale})`;
|
|
4435
|
+
if (props.angle)
|
|
4436
|
+
propCode += `(command "._HATCHEDIT" "${handle}" "an" ${props.angle})`;
|
|
4437
|
+
if (props.color)
|
|
4438
|
+
propCode += `(command "._HATCHEDIT" "${handle}" "c" ${props.color})`;
|
|
4201
4439
|
const code = `(progn
|
|
4202
4440
|
(vl-load-com)
|
|
4203
4441
|
${propCode}
|
|
@@ -4214,7 +4452,8 @@ async function getBlockAttributes(blockHandle) {
|
|
|
4214
4452
|
if (!cad.connected) {
|
|
4215
4453
|
await cad.connect();
|
|
4216
4454
|
}
|
|
4217
|
-
if (!cad.connected)
|
|
4455
|
+
if (!cad.connected)
|
|
4456
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4218
4457
|
const code = `(progn
|
|
4219
4458
|
(vl-load-com)
|
|
4220
4459
|
(if (setq ent (handent "${blockHandle}"))
|
|
@@ -4243,7 +4482,8 @@ async function setBlockAttribute(blockHandle, tag, value) {
|
|
|
4243
4482
|
if (!cad.connected) {
|
|
4244
4483
|
await cad.connect();
|
|
4245
4484
|
}
|
|
4246
|
-
if (!cad.connected)
|
|
4485
|
+
if (!cad.connected)
|
|
4486
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4247
4487
|
const code = `(progn
|
|
4248
4488
|
(vl-load-com)
|
|
4249
4489
|
(if (setq ent (handent "${blockHandle}"))
|
|
@@ -4279,7 +4519,8 @@ async function zoomToExtents() {
|
|
|
4279
4519
|
if (!cad.connected) {
|
|
4280
4520
|
await cad.connect();
|
|
4281
4521
|
}
|
|
4282
|
-
if (!cad.connected)
|
|
4522
|
+
if (!cad.connected)
|
|
4523
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4283
4524
|
const code = `(progn
|
|
4284
4525
|
(vl-load-com)
|
|
4285
4526
|
(command "._ZOOM" "E")
|
|
@@ -4296,7 +4537,8 @@ async function zoomToWindow(p1, p2) {
|
|
|
4296
4537
|
if (!cad.connected) {
|
|
4297
4538
|
await cad.connect();
|
|
4298
4539
|
}
|
|
4299
|
-
if (!cad.connected)
|
|
4540
|
+
if (!cad.connected)
|
|
4541
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4300
4542
|
const code = `(command "._ZOOM" "W" (list ${p1}) (list ${p2}))`;
|
|
4301
4543
|
try {
|
|
4302
4544
|
await cad.sendCommand(code + "\n");
|
|
@@ -4309,7 +4551,8 @@ async function createNamedView(viewName, center = null) {
|
|
|
4309
4551
|
if (!cad.connected) {
|
|
4310
4552
|
await cad.connect();
|
|
4311
4553
|
}
|
|
4312
|
-
if (!cad.connected)
|
|
4554
|
+
if (!cad.connected)
|
|
4555
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4313
4556
|
const code = center ? `(command ".-VIEW" "S" "${viewName}" "C" (list ${center}))` : `(command ".-VIEW" "S" "${viewName}")`;
|
|
4314
4557
|
try {
|
|
4315
4558
|
await cad.sendCommand(code + "\n");
|
|
@@ -4322,7 +4565,8 @@ async function restoreNamedView(viewName) {
|
|
|
4322
4565
|
if (!cad.connected) {
|
|
4323
4566
|
await cad.connect();
|
|
4324
4567
|
}
|
|
4325
|
-
if (!cad.connected)
|
|
4568
|
+
if (!cad.connected)
|
|
4569
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4326
4570
|
const code = `(command ".-VIEW" "R" "${viewName}")`;
|
|
4327
4571
|
try {
|
|
4328
4572
|
await cad.sendCommand(code + "\n");
|
|
@@ -4335,7 +4579,8 @@ async function listNamedViews() {
|
|
|
4335
4579
|
if (!cad.connected) {
|
|
4336
4580
|
await cad.connect();
|
|
4337
4581
|
}
|
|
4338
|
-
if (!cad.connected)
|
|
4582
|
+
if (!cad.connected)
|
|
4583
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4339
4584
|
const code = `(progn
|
|
4340
4585
|
(vl-load-com)
|
|
4341
4586
|
(setq views nil)
|
|
@@ -4355,7 +4600,8 @@ async function exportDxf(outputPath, version2 = "R2018") {
|
|
|
4355
4600
|
if (!cad.connected) {
|
|
4356
4601
|
await cad.connect();
|
|
4357
4602
|
}
|
|
4358
|
-
if (!cad.connected)
|
|
4603
|
+
if (!cad.connected)
|
|
4604
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4359
4605
|
const normalizedPath = outputPath.replace(/\\/g, "\\\\");
|
|
4360
4606
|
const versionMap = {
|
|
4361
4607
|
"R2018": "AC1027",
|
|
@@ -4386,7 +4632,8 @@ async function exportDwf(outputPath) {
|
|
|
4386
4632
|
if (!cad.connected) {
|
|
4387
4633
|
await cad.connect();
|
|
4388
4634
|
}
|
|
4389
|
-
if (!cad.connected)
|
|
4635
|
+
if (!cad.connected)
|
|
4636
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4390
4637
|
const normalizedPath = outputPath.replace(/\\/g, "\\\\");
|
|
4391
4638
|
const code = `(progn
|
|
4392
4639
|
(vl-load-com)
|
|
@@ -4407,7 +4654,8 @@ async function batchSetLayer(handles, layerName) {
|
|
|
4407
4654
|
if (!cad.connected) {
|
|
4408
4655
|
await cad.connect();
|
|
4409
4656
|
}
|
|
4410
|
-
if (!cad.connected)
|
|
4657
|
+
if (!cad.connected)
|
|
4658
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4411
4659
|
if (!Array.isArray(handles) || handles.length === 0) {
|
|
4412
4660
|
return { content: [{ type: "text", text: "\u53E5\u67C4\u5217\u8868\u4E3A\u7A7A" }], isError: true };
|
|
4413
4661
|
}
|
|
@@ -4432,7 +4680,8 @@ async function createUcs(name, origin = "0,0,0", xAxis = "1,0,0", yAxis = "0,1,0
|
|
|
4432
4680
|
if (!cad.connected) {
|
|
4433
4681
|
await cad.connect();
|
|
4434
4682
|
}
|
|
4435
|
-
if (!cad.connected)
|
|
4683
|
+
if (!cad.connected)
|
|
4684
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4436
4685
|
const code = `(progn
|
|
4437
4686
|
(vl-load-com)
|
|
4438
4687
|
(if (not (tblsearch "UCS" "${name}"))
|
|
@@ -4463,7 +4712,8 @@ async function setUcs(name) {
|
|
|
4463
4712
|
if (!cad.connected) {
|
|
4464
4713
|
await cad.connect();
|
|
4465
4714
|
}
|
|
4466
|
-
if (!cad.connected)
|
|
4715
|
+
if (!cad.connected)
|
|
4716
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4467
4717
|
const code = `(progn
|
|
4468
4718
|
(vl-load-com)
|
|
4469
4719
|
(if (tblsearch "UCS" "${name}")
|
|
@@ -4488,7 +4738,8 @@ async function listUcs() {
|
|
|
4488
4738
|
if (!cad.connected) {
|
|
4489
4739
|
await cad.connect();
|
|
4490
4740
|
}
|
|
4491
|
-
if (!cad.connected)
|
|
4741
|
+
if (!cad.connected)
|
|
4742
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4492
4743
|
const code = `(progn
|
|
4493
4744
|
(vl-load-com)
|
|
4494
4745
|
(setq ucsList nil)
|
|
@@ -4511,7 +4762,8 @@ async function deleteUcs(name) {
|
|
|
4511
4762
|
if (!cad.connected) {
|
|
4512
4763
|
await cad.connect();
|
|
4513
4764
|
}
|
|
4514
|
-
if (!cad.connected)
|
|
4765
|
+
if (!cad.connected)
|
|
4766
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4515
4767
|
const code = `(progn
|
|
4516
4768
|
(vl-load-com)
|
|
4517
4769
|
(if (tblsearch "UCS" "${name}")
|
|
@@ -4536,7 +4788,8 @@ async function getCurrentUcs() {
|
|
|
4536
4788
|
if (!cad.connected) {
|
|
4537
4789
|
await cad.connect();
|
|
4538
4790
|
}
|
|
4539
|
-
if (!cad.connected)
|
|
4791
|
+
if (!cad.connected)
|
|
4792
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4540
4793
|
const code = `(progn
|
|
4541
4794
|
(vl-load-com)
|
|
4542
4795
|
(vla-get-activeutilities (vla-get-document (vla-get-application (vlax-get-acad-object))))
|
|
@@ -4553,7 +4806,8 @@ async function createLayout(name) {
|
|
|
4553
4806
|
if (!cad.connected) {
|
|
4554
4807
|
await cad.connect();
|
|
4555
4808
|
}
|
|
4556
|
-
if (!cad.connected)
|
|
4809
|
+
if (!cad.connected)
|
|
4810
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4557
4811
|
const code = `(progn
|
|
4558
4812
|
(vl-load-com)
|
|
4559
4813
|
(if (not (tblsearch "LAYOUT" "${name}"))
|
|
@@ -4581,7 +4835,8 @@ async function setLayout(name) {
|
|
|
4581
4835
|
if (!cad.connected) {
|
|
4582
4836
|
await cad.connect();
|
|
4583
4837
|
}
|
|
4584
|
-
if (!cad.connected)
|
|
4838
|
+
if (!cad.connected)
|
|
4839
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4585
4840
|
const code = `(progn
|
|
4586
4841
|
(vl-load-com)
|
|
4587
4842
|
(vlax-for layout (vla-get-layouts (vla-get-activedocument (vla-get-application (vlax-get-acad-object))))
|
|
@@ -4611,7 +4866,8 @@ async function listLayouts() {
|
|
|
4611
4866
|
if (!cad.connected) {
|
|
4612
4867
|
await cad.connect();
|
|
4613
4868
|
}
|
|
4614
|
-
if (!cad.connected)
|
|
4869
|
+
if (!cad.connected)
|
|
4870
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4615
4871
|
const code = `(progn
|
|
4616
4872
|
(vl-load-com)
|
|
4617
4873
|
(setq layouts nil)
|
|
@@ -4634,7 +4890,8 @@ async function deleteLayout(name) {
|
|
|
4634
4890
|
if (!cad.connected) {
|
|
4635
4891
|
await cad.connect();
|
|
4636
4892
|
}
|
|
4637
|
-
if (!cad.connected)
|
|
4893
|
+
if (!cad.connected)
|
|
4894
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4638
4895
|
if (name === "Model" || name === "\u6A21\u578B") {
|
|
4639
4896
|
return { content: [{ type: "text", text: "\u65E0\u6CD5\u5220\u9664\u6A21\u578B\u7A7A\u95F4" }], isError: true };
|
|
4640
4897
|
}
|
|
@@ -4662,7 +4919,8 @@ async function getCurrentLayout() {
|
|
|
4662
4919
|
if (!cad.connected) {
|
|
4663
4920
|
await cad.connect();
|
|
4664
4921
|
}
|
|
4665
|
-
if (!cad.connected)
|
|
4922
|
+
if (!cad.connected)
|
|
4923
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4666
4924
|
const code = `(vl-prin1-to-string (getvar "CTAB"))`;
|
|
4667
4925
|
try {
|
|
4668
4926
|
const result = await cad.sendCommandWithResult(code);
|
|
@@ -4675,7 +4933,8 @@ async function renameLayout(oldName, newName) {
|
|
|
4675
4933
|
if (!cad.connected) {
|
|
4676
4934
|
await cad.connect();
|
|
4677
4935
|
}
|
|
4678
|
-
if (!cad.connected)
|
|
4936
|
+
if (!cad.connected)
|
|
4937
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4679
4938
|
const code = `(progn
|
|
4680
4939
|
(vl-load-com)
|
|
4681
4940
|
(if (tblsearch "LAYOUT" "${oldName}")
|
|
@@ -4702,7 +4961,8 @@ async function plotToPdf(outputPath, layout = "Model", style = {}) {
|
|
|
4702
4961
|
if (!cad.connected) {
|
|
4703
4962
|
await cad.connect();
|
|
4704
4963
|
}
|
|
4705
|
-
if (!cad.connected)
|
|
4964
|
+
if (!cad.connected)
|
|
4965
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4706
4966
|
const normalizedPath = outputPath.replace(/\\/g, "\\\\");
|
|
4707
4967
|
const paperSize = style.paperSize || "A4";
|
|
4708
4968
|
const plotScale = style.plotScale || "1:1";
|
|
@@ -4735,7 +4995,8 @@ async function plotToPrinter(printerName, layout = "Model") {
|
|
|
4735
4995
|
if (!cad.connected) {
|
|
4736
4996
|
await cad.connect();
|
|
4737
4997
|
}
|
|
4738
|
-
if (!cad.connected)
|
|
4998
|
+
if (!cad.connected)
|
|
4999
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4739
5000
|
const code = `(progn
|
|
4740
5001
|
(vl-load-com)
|
|
4741
5002
|
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
|
|
@@ -4761,7 +5022,8 @@ async function createGroup(name, handles) {
|
|
|
4761
5022
|
if (!cad.connected) {
|
|
4762
5023
|
await cad.connect();
|
|
4763
5024
|
}
|
|
4764
|
-
if (!cad.connected)
|
|
5025
|
+
if (!cad.connected)
|
|
5026
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4765
5027
|
if (!Array.isArray(handles) || handles.length === 0) {
|
|
4766
5028
|
return { content: [{ type: "text", text: "\u53E5\u67C4\u5217\u8868\u4E3A\u7A7A" }], isError: true };
|
|
4767
5029
|
}
|
|
@@ -4787,7 +5049,8 @@ async function deleteGroup(name) {
|
|
|
4787
5049
|
if (!cad.connected) {
|
|
4788
5050
|
await cad.connect();
|
|
4789
5051
|
}
|
|
4790
|
-
if (!cad.connected)
|
|
5052
|
+
if (!cad.connected)
|
|
5053
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4791
5054
|
const code = `(progn
|
|
4792
5055
|
(vl-load-com)
|
|
4793
5056
|
(if (tblsearch "GROUP" "${name}")
|
|
@@ -4812,7 +5075,8 @@ async function listGroups() {
|
|
|
4812
5075
|
if (!cad.connected) {
|
|
4813
5076
|
await cad.connect();
|
|
4814
5077
|
}
|
|
4815
|
-
if (!cad.connected)
|
|
5078
|
+
if (!cad.connected)
|
|
5079
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4816
5080
|
const code = `(progn
|
|
4817
5081
|
(vl-load-com)
|
|
4818
5082
|
(setq groups nil)
|
|
@@ -4832,7 +5096,8 @@ async function getGroupEntities(groupName) {
|
|
|
4832
5096
|
if (!cad.connected) {
|
|
4833
5097
|
await cad.connect();
|
|
4834
5098
|
}
|
|
4835
|
-
if (!cad.connected)
|
|
5099
|
+
if (!cad.connected)
|
|
5100
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4836
5101
|
const code = `(progn
|
|
4837
5102
|
(vl-load-com)
|
|
4838
5103
|
(if (tblsearch "GROUP" "${groupName}")
|
|
@@ -4870,7 +5135,8 @@ async function measureDistance(p1, p2) {
|
|
|
4870
5135
|
if (!cad.connected) {
|
|
4871
5136
|
await cad.connect();
|
|
4872
5137
|
}
|
|
4873
|
-
if (!cad.connected)
|
|
5138
|
+
if (!cad.connected)
|
|
5139
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4874
5140
|
const code = `(progn
|
|
4875
5141
|
(vl-load-com)
|
|
4876
5142
|
(setq pt1 (list ${p1}) pt2 (list ${p2}))
|
|
@@ -4894,7 +5160,8 @@ async function measureArea(points) {
|
|
|
4894
5160
|
if (!cad.connected) {
|
|
4895
5161
|
await cad.connect();
|
|
4896
5162
|
}
|
|
4897
|
-
if (!cad.connected)
|
|
5163
|
+
if (!cad.connected)
|
|
5164
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4898
5165
|
const pts = Array.isArray(points) ? points : points.split(/[\s,]+/).filter(Boolean);
|
|
4899
5166
|
if (pts.length < 3) {
|
|
4900
5167
|
return { content: [{ type: "text", text: "\u81F3\u5C11\u9700\u8981 3 \u4E2A\u70B9" }], isError: true };
|
|
@@ -4931,7 +5198,8 @@ async function getEntityInfo(handle) {
|
|
|
4931
5198
|
if (!cad.connected) {
|
|
4932
5199
|
await cad.connect();
|
|
4933
5200
|
}
|
|
4934
|
-
if (!cad.connected)
|
|
5201
|
+
if (!cad.connected)
|
|
5202
|
+
return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
|
|
4935
5203
|
const code = `(progn
|
|
4936
5204
|
(vl-load-com)
|
|
4937
5205
|
(if (setq ent (handent "${handle}"))
|
|
@@ -4966,7 +5234,8 @@ async function ensureConnected() {
|
|
|
4966
5234
|
if (!cad.connected) {
|
|
4967
5235
|
await cad.connect();
|
|
4968
5236
|
}
|
|
4969
|
-
if (!cad.connected)
|
|
5237
|
+
if (!cad.connected)
|
|
5238
|
+
throw new Error("CAD \u672A\u8FDE\u63A5");
|
|
4970
5239
|
}
|
|
4971
5240
|
function parseHandleList(handles) {
|
|
4972
5241
|
if (typeof handles === "string") {
|
|
@@ -5207,7 +5476,8 @@ async function ensureConnected2() {
|
|
|
5207
5476
|
if (!cad.connected) {
|
|
5208
5477
|
await cad.connect();
|
|
5209
5478
|
}
|
|
5210
|
-
if (!cad.connected)
|
|
5479
|
+
if (!cad.connected)
|
|
5480
|
+
throw new Error("CAD \u672A\u8FDE\u63A5");
|
|
5211
5481
|
}
|
|
5212
5482
|
async function getXdata(handle, appName = "ACAD") {
|
|
5213
5483
|
await ensureConnected2();
|
|
@@ -5413,10 +5683,11 @@ async function searchByXdata(appName, key, value) {
|
|
|
5413
5683
|
async function exportXdataToFile(handle, filePath) {
|
|
5414
5684
|
await ensureConnected2();
|
|
5415
5685
|
const xdata = await getAllEntityXdata(handle);
|
|
5416
|
-
if (!xdata.success)
|
|
5686
|
+
if (!xdata.success)
|
|
5687
|
+
return xdata;
|
|
5417
5688
|
try {
|
|
5418
|
-
const
|
|
5419
|
-
|
|
5689
|
+
const fs9 = await import("fs");
|
|
5690
|
+
fs9.writeFileSync(filePath, JSON.stringify(xdata.xdata, null, 2));
|
|
5420
5691
|
return { handle, filePath, success: true };
|
|
5421
5692
|
} catch (e) {
|
|
5422
5693
|
return { error: e.message, success: false };
|
|
@@ -5425,8 +5696,8 @@ async function exportXdataToFile(handle, filePath) {
|
|
|
5425
5696
|
async function importXdataFromFile(handle, filePath, appName) {
|
|
5426
5697
|
await ensureConnected2();
|
|
5427
5698
|
try {
|
|
5428
|
-
const
|
|
5429
|
-
const data =
|
|
5699
|
+
const fs9 = await import("fs");
|
|
5700
|
+
const data = fs9.readFileSync(filePath, "utf8");
|
|
5430
5701
|
const xdata = JSON.parse(data);
|
|
5431
5702
|
if (appName && xdata[appName]) {
|
|
5432
5703
|
return await setXdata(handle, appName, xdata[appName]);
|
|
@@ -5446,7 +5717,8 @@ async function ensureConnected3() {
|
|
|
5446
5717
|
if (!cad.connected) {
|
|
5447
5718
|
await cad.connect();
|
|
5448
5719
|
}
|
|
5449
|
-
if (!cad.connected)
|
|
5720
|
+
if (!cad.connected)
|
|
5721
|
+
throw new Error("CAD \u672A\u8FDE\u63A5");
|
|
5450
5722
|
}
|
|
5451
5723
|
async function createSheetSet(name, description = "") {
|
|
5452
5724
|
await ensureConnected3();
|
|
@@ -5647,11 +5919,14 @@ async function ensureConnected4() {
|
|
|
5647
5919
|
if (!cad.connected) {
|
|
5648
5920
|
await cad.connect();
|
|
5649
5921
|
}
|
|
5650
|
-
if (!cad.connected)
|
|
5922
|
+
if (!cad.connected)
|
|
5923
|
+
throw new Error("CAD \u672A\u8FDE\u63A5");
|
|
5651
5924
|
}
|
|
5652
5925
|
function parsePoint(point) {
|
|
5653
|
-
if (Array.isArray(point))
|
|
5654
|
-
|
|
5926
|
+
if (Array.isArray(point))
|
|
5927
|
+
return point.join(" ");
|
|
5928
|
+
if (typeof point === "string")
|
|
5929
|
+
return point;
|
|
5655
5930
|
return "0,0,0";
|
|
5656
5931
|
}
|
|
5657
5932
|
async function createBox(center, length, width, height) {
|
|
@@ -5911,7 +6186,8 @@ async function ensureConnected5() {
|
|
|
5911
6186
|
if (!cad.connected) {
|
|
5912
6187
|
await cad.connect();
|
|
5913
6188
|
}
|
|
5914
|
-
if (!cad.connected)
|
|
6189
|
+
if (!cad.connected)
|
|
6190
|
+
throw new Error("CAD \u672A\u8FDE\u63A5");
|
|
5915
6191
|
}
|
|
5916
6192
|
async function createDimensionStyle(name, color = "bylayer", arrow = "ClosedFilled", textStyle = "") {
|
|
5917
6193
|
await ensureConnected5();
|
|
@@ -6137,7 +6413,8 @@ async function ensureConnected6() {
|
|
|
6137
6413
|
if (!cad.connected) {
|
|
6138
6414
|
await cad.connect();
|
|
6139
6415
|
}
|
|
6140
|
-
if (!cad.connected)
|
|
6416
|
+
if (!cad.connected)
|
|
6417
|
+
throw new Error("CAD \u672A\u8FDE\u63A5");
|
|
6141
6418
|
}
|
|
6142
6419
|
async function attachPdf(point, pdfPath, scale = 1, rotation = 0) {
|
|
6143
6420
|
await ensureConnected6();
|
|
@@ -6577,7 +6854,8 @@ function validateToolArgs(name, args) {
|
|
|
6577
6854
|
const baseType = type.replace("?", "");
|
|
6578
6855
|
const val = args[key];
|
|
6579
6856
|
if (val === void 0 || val === null) {
|
|
6580
|
-
if (isOptional)
|
|
6857
|
+
if (isOptional)
|
|
6858
|
+
continue;
|
|
6581
6859
|
throw new Error(`Missing required argument: ${key}`);
|
|
6582
6860
|
}
|
|
6583
6861
|
const actualType = typeof args[key];
|
|
@@ -6622,7 +6900,8 @@ ${CAD_PLATFORMS.join("\n")}
|
|
|
6622
6900
|
},
|
|
6623
6901
|
import_funlib: async (a) => {
|
|
6624
6902
|
const data = await loadAtlibFunctionLib();
|
|
6625
|
-
if (!data)
|
|
6903
|
+
if (!data)
|
|
6904
|
+
return { content: [{ type: "text", text: "\u52A0\u8F7D\u51FD\u6570\u5E93\u5931\u8D25" }], isError: true };
|
|
6626
6905
|
if (a.format === "list") {
|
|
6627
6906
|
const items = Object.values(data.all_functions || {}).map((f) => `${f.name}: ${f.description || ""}`);
|
|
6628
6907
|
return { content: [{ type: "text", text: items.join("\n") }] };
|
|
@@ -8447,7 +8726,8 @@ function notifyResourceChanges(toolName) {
|
|
|
8447
8726
|
}
|
|
8448
8727
|
async function handleToolCall(name, args) {
|
|
8449
8728
|
const handler = TOOL_HANDLERS[name];
|
|
8450
|
-
if (!handler)
|
|
8729
|
+
if (!handler)
|
|
8730
|
+
return { content: [{ type: "text", text: `\u672A\u77E5\u5DE5\u5177: ${name}` }], isError: true };
|
|
8451
8731
|
try {
|
|
8452
8732
|
validateToolArgs(name, args || {});
|
|
8453
8733
|
const result = await handler(args || {});
|
|
@@ -8507,10 +8787,12 @@ var RateLimiter = class {
|
|
|
8507
8787
|
this.keyLimits = /* @__PURE__ */ new Map();
|
|
8508
8788
|
}
|
|
8509
8789
|
getKeyLimit(apiKey2) {
|
|
8510
|
-
if (!apiKey2)
|
|
8790
|
+
if (!apiKey2)
|
|
8791
|
+
return this.defaultLimit;
|
|
8511
8792
|
if (config_default.apiKeys && config_default.apiKeys.length > 0) {
|
|
8512
8793
|
const found = config_default.apiKeys.find((k) => k.key === apiKey2);
|
|
8513
|
-
if (found)
|
|
8794
|
+
if (found)
|
|
8795
|
+
return found.limit;
|
|
8514
8796
|
}
|
|
8515
8797
|
if (config_default.apiKey && apiKey2 === config_default.apiKey) {
|
|
8516
8798
|
return config_default.apiKeyRateLimit || 1e3;
|
|
@@ -8518,10 +8800,12 @@ var RateLimiter = class {
|
|
|
8518
8800
|
return this.defaultLimit;
|
|
8519
8801
|
}
|
|
8520
8802
|
getKeyInfo(apiKey2) {
|
|
8521
|
-
if (!apiKey2)
|
|
8803
|
+
if (!apiKey2)
|
|
8804
|
+
return { name: "anonymous", limit: this.defaultLimit };
|
|
8522
8805
|
if (config_default.apiKeys && config_default.apiKeys.length > 0) {
|
|
8523
8806
|
const found = config_default.apiKeys.find((k) => k.key === apiKey2);
|
|
8524
|
-
if (found)
|
|
8807
|
+
if (found)
|
|
8808
|
+
return { name: found.name || apiKey2, limit: found.limit };
|
|
8525
8809
|
}
|
|
8526
8810
|
if (config_default.apiKey && apiKey2 === config_default.apiKey) {
|
|
8527
8811
|
return { name: "admin", limit: config_default.apiKeyRateLimit || 1e3 };
|
|
@@ -8617,7 +8901,8 @@ var JSON_CONTENT_TYPES = ["application/json", "application/json-rpc", "applicati
|
|
|
8617
8901
|
function createJsonBodyParser() {
|
|
8618
8902
|
return async (req, res, next) => {
|
|
8619
8903
|
const ct = (req.headers["content-type"] || "").toLowerCase();
|
|
8620
|
-
if (!JSON_CONTENT_TYPES.some((t) => ct.startsWith(t)))
|
|
8904
|
+
if (!JSON_CONTENT_TYPES.some((t) => ct.startsWith(t)))
|
|
8905
|
+
return next();
|
|
8621
8906
|
try {
|
|
8622
8907
|
const chunks = [];
|
|
8623
8908
|
for await (const chunk of req) {
|
|
@@ -8650,9 +8935,11 @@ function createAuthMiddleware() {
|
|
|
8650
8935
|
const PUBLIC_PATHS = ["/health"];
|
|
8651
8936
|
return (req, res, next) => {
|
|
8652
8937
|
if (apiKey) {
|
|
8653
|
-
if (PUBLIC_PATHS.includes(req.path))
|
|
8938
|
+
if (PUBLIC_PATHS.includes(req.path))
|
|
8939
|
+
return next();
|
|
8654
8940
|
const auth = req.get("Authorization");
|
|
8655
|
-
if (auth === `Bearer ${apiKey}`)
|
|
8941
|
+
if (auth === `Bearer ${apiKey}`)
|
|
8942
|
+
return next();
|
|
8656
8943
|
return res.status(401).json({ error: "Unauthorized" });
|
|
8657
8944
|
}
|
|
8658
8945
|
next();
|
|
@@ -8660,14 +8947,16 @@ function createAuthMiddleware() {
|
|
|
8660
8947
|
}
|
|
8661
8948
|
function createCorsMiddleware() {
|
|
8662
8949
|
return (req, res, next) => {
|
|
8663
|
-
if (!enableCors)
|
|
8950
|
+
if (!enableCors)
|
|
8951
|
+
return next();
|
|
8664
8952
|
res.setHeader("Access-Control-Allow-Origin", corsOrigin);
|
|
8665
8953
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS, CONNECT");
|
|
8666
8954
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept, mcp-session-id, last-event-id");
|
|
8667
8955
|
res.setHeader("Access-Control-Expose-Headers", "mcp-session-id, content-type, x-accel-buffering");
|
|
8668
8956
|
res.setHeader("Access-Control-Max-Age", "86400");
|
|
8669
8957
|
res.setHeader("Vary", "Accept");
|
|
8670
|
-
if (req.method === "OPTIONS")
|
|
8958
|
+
if (req.method === "OPTIONS")
|
|
8959
|
+
return res.status(204).end();
|
|
8671
8960
|
next();
|
|
8672
8961
|
};
|
|
8673
8962
|
}
|
|
@@ -9029,7 +9318,7 @@ Options:
|
|
|
9029
9318
|
--port <port> HTTP port (default: 8110)
|
|
9030
9319
|
--host <host> HTTP host (default: 0.0.0.0)
|
|
9031
9320
|
--stdio Shorthand for --transport stdio
|
|
9032
|
-
--config <path> Path to config file (default:
|
|
9321
|
+
--config <path> Path to config file (default: ~/.atlisp/atlisp.config.json)
|
|
9033
9322
|
--debug Enable debug mode
|
|
9034
9323
|
|
|
9035
9324
|
Environment Variables:
|
|
@@ -9079,7 +9368,8 @@ For more info: https://atlisp.cn
|
|
|
9079
9368
|
}
|
|
9080
9369
|
}
|
|
9081
9370
|
}
|
|
9082
|
-
if (config_default.apiKey)
|
|
9371
|
+
if (config_default.apiKey)
|
|
9372
|
+
log("API Key authentication enabled");
|
|
9083
9373
|
async function initCadConnection() {
|
|
9084
9374
|
log("Attempting to connect to CAD on startup...");
|
|
9085
9375
|
try {
|