solidworks-mcp-server 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/LICENSE +21 -0
- package/README.md +333 -0
- package/dist/cache/manager.d.ts +50 -0
- package/dist/cache/manager.d.ts.map +1 -0
- package/dist/cache/manager.js +127 -0
- package/dist/cache/manager.js.map +1 -0
- package/dist/db/connection.d.ts +48 -0
- package/dist/db/connection.d.ts.map +1 -0
- package/dist/db/connection.js +132 -0
- package/dist/db/connection.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +402 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/chromadb.d.ts +16 -0
- package/dist/knowledge/chromadb.d.ts.map +1 -0
- package/dist/knowledge/chromadb.js +80 -0
- package/dist/knowledge/chromadb.js.map +1 -0
- package/dist/macro/index.d.ts +6 -0
- package/dist/macro/index.d.ts.map +1 -0
- package/dist/macro/index.js +6 -0
- package/dist/macro/index.js.map +1 -0
- package/dist/macro/recorder.d.ts +72 -0
- package/dist/macro/recorder.d.ts.map +1 -0
- package/dist/macro/recorder.js +228 -0
- package/dist/macro/recorder.js.map +1 -0
- package/dist/macro/types.d.ts +77 -0
- package/dist/macro/types.d.ts.map +1 -0
- package/dist/macro/types.js +5 -0
- package/dist/macro/types.js.map +1 -0
- package/dist/resources/base.d.ts +116 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/base.js +161 -0
- package/dist/resources/base.js.map +1 -0
- package/dist/resources/design-table.d.ts +384 -0
- package/dist/resources/design-table.d.ts.map +1 -0
- package/dist/resources/design-table.js +337 -0
- package/dist/resources/design-table.js.map +1 -0
- package/dist/resources/pdm.d.ts +1277 -0
- package/dist/resources/pdm.d.ts.map +1 -0
- package/dist/resources/pdm.js +358 -0
- package/dist/resources/pdm.js.map +1 -0
- package/dist/resources/registry.d.ts +59 -0
- package/dist/resources/registry.d.ts.map +1 -0
- package/dist/resources/registry.js +88 -0
- package/dist/resources/registry.js.map +1 -0
- package/dist/solidworks/api.d.ts +24 -0
- package/dist/solidworks/api.d.ts.map +1 -0
- package/dist/solidworks/api.js +226 -0
- package/dist/solidworks/api.js.map +1 -0
- package/dist/solidworks/types.d.ts +55 -0
- package/dist/solidworks/types.d.ts.map +1 -0
- package/dist/solidworks/types.js +2 -0
- package/dist/solidworks/types.js.map +1 -0
- package/dist/state/store.d.ts +101 -0
- package/dist/state/store.d.ts.map +1 -0
- package/dist/state/store.js +262 -0
- package/dist/state/store.js.map +1 -0
- package/dist/tools/analysis.d.ts +37 -0
- package/dist/tools/analysis.d.ts.map +1 -0
- package/dist/tools/analysis.js +169 -0
- package/dist/tools/analysis.js.map +1 -0
- package/dist/tools/drawing.d.ts +151 -0
- package/dist/tools/drawing.d.ts.map +1 -0
- package/dist/tools/drawing.js +171 -0
- package/dist/tools/drawing.js.map +1 -0
- package/dist/tools/export.d.ts +97 -0
- package/dist/tools/export.d.ts.map +1 -0
- package/dist/tools/export.js +128 -0
- package/dist/tools/export.js.map +1 -0
- package/dist/tools/modeling.d.ts +9 -0
- package/dist/tools/modeling.d.ts.map +1 -0
- package/dist/tools/modeling.js +120 -0
- package/dist/tools/modeling.js.map +1 -0
- package/dist/tools/vba.d.ts +123 -0
- package/dist/tools/vba.d.ts.map +1 -0
- package/dist/tools/vba.js +158 -0
- package/dist/tools/vba.js.map +1 -0
- package/dist/utils/config.d.ts +18 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +26 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +84 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ChromaClient } from 'chromadb';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
|
+
import { config } from '../utils/config.js';
|
|
4
|
+
export class SolidWorksKnowledgeBase {
|
|
5
|
+
client;
|
|
6
|
+
collection;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.client = new ChromaClient({
|
|
9
|
+
path: `http://${config.chromadb.host}:${config.chromadb.port}`,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async initialize() {
|
|
13
|
+
try {
|
|
14
|
+
// Create or get collection for SolidWorks operations
|
|
15
|
+
this.collection = await this.client.getOrCreateCollection({
|
|
16
|
+
name: 'solidworks_operations',
|
|
17
|
+
metadata: { description: 'SolidWorks operation history and patterns' },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
logger.warn('ChromaDB not available, running without knowledge base');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async recordOperation(operation) {
|
|
25
|
+
if (!this.collection)
|
|
26
|
+
return;
|
|
27
|
+
try {
|
|
28
|
+
await this.collection.add({
|
|
29
|
+
ids: [`op_${Date.now()}`],
|
|
30
|
+
documents: [JSON.stringify(operation)],
|
|
31
|
+
metadatas: [{
|
|
32
|
+
tool: operation.tool,
|
|
33
|
+
success: operation.success.toString(),
|
|
34
|
+
timestamp: operation.timestamp.toISOString(),
|
|
35
|
+
}],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger.error('Failed to record operation', error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async findSimilarOperations(query, limit = 5) {
|
|
43
|
+
if (!this.collection)
|
|
44
|
+
return [];
|
|
45
|
+
try {
|
|
46
|
+
const results = await this.collection.query({
|
|
47
|
+
queryTexts: [query],
|
|
48
|
+
nResults: limit,
|
|
49
|
+
});
|
|
50
|
+
return results.documents[0].map((doc, i) => ({
|
|
51
|
+
document: JSON.parse(doc),
|
|
52
|
+
metadata: results.metadatas[0][i],
|
|
53
|
+
distance: results.distances[0][i],
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
logger.error('Failed to query operations', error);
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async getSuccessRate(tool) {
|
|
62
|
+
if (!this.collection)
|
|
63
|
+
return 0;
|
|
64
|
+
try {
|
|
65
|
+
const results = await this.collection.query({
|
|
66
|
+
queryTexts: [''],
|
|
67
|
+
where: { tool },
|
|
68
|
+
nResults: 1000,
|
|
69
|
+
});
|
|
70
|
+
const total = results.metadatas[0].length;
|
|
71
|
+
const successful = results.metadatas[0].filter((m) => m.success === 'true').length;
|
|
72
|
+
return total > 0 ? (successful / total) * 100 : 0;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
logger.error('Failed to calculate success rate', error);
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=chromadb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chromadb.js","sourceRoot":"","sources":["../../src/knowledge/chromadb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,OAAO,uBAAuB;IAC1B,MAAM,CAAe;IACrB,UAAU,CAAM;IAExB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,CAAC;YAC7B,IAAI,EAAE,UAAU,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;SAC/D,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,qDAAqD;YACrD,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC;gBACxD,IAAI,EAAE,uBAAuB;gBAC7B,QA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/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/macro/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Macro Recorder for SolidWorks MCP
|
|
3
|
+
* Records and manages macro operations
|
|
4
|
+
*/
|
|
5
|
+
import { MacroAction, MacroRecording, MacroExecution } from './types.js';
|
|
6
|
+
export declare class MacroRecorder {
|
|
7
|
+
private currentRecording;
|
|
8
|
+
private recordings;
|
|
9
|
+
private executions;
|
|
10
|
+
private actionHandlers;
|
|
11
|
+
/**
|
|
12
|
+
* Start a new macro recording
|
|
13
|
+
*/
|
|
14
|
+
startRecording(name: string, description?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Stop the current recording
|
|
17
|
+
*/
|
|
18
|
+
stopRecording(): MacroRecording | null;
|
|
19
|
+
/**
|
|
20
|
+
* Record an action
|
|
21
|
+
*/
|
|
22
|
+
recordAction(type: string, name: string, parameters: Record<string, any>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get a recording by ID
|
|
25
|
+
*/
|
|
26
|
+
getRecording(id: string): MacroRecording | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get all recordings
|
|
29
|
+
*/
|
|
30
|
+
getAllRecordings(): MacroRecording[];
|
|
31
|
+
/**
|
|
32
|
+
* Delete a recording
|
|
33
|
+
*/
|
|
34
|
+
deleteRecording(id: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Register an action handler
|
|
37
|
+
*/
|
|
38
|
+
registerActionHandler(type: string, handler: (action: MacroAction) => Promise<any>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Execute a macro recording
|
|
41
|
+
*/
|
|
42
|
+
executeMacro(macroId: string, parameters?: Record<string, any>): Promise<MacroExecution>;
|
|
43
|
+
/**
|
|
44
|
+
* Get execution by ID
|
|
45
|
+
*/
|
|
46
|
+
getExecution(id: string): MacroExecution | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Get all executions for a macro
|
|
49
|
+
*/
|
|
50
|
+
getMacroExecutions(macroId: string): MacroExecution[];
|
|
51
|
+
/**
|
|
52
|
+
* Add a log entry to an execution
|
|
53
|
+
*/
|
|
54
|
+
private addLog;
|
|
55
|
+
/**
|
|
56
|
+
* Export recording to VBA code
|
|
57
|
+
*/
|
|
58
|
+
exportToVBA(macroId: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Convert action to VBA code
|
|
61
|
+
*/
|
|
62
|
+
private actionToVBA;
|
|
63
|
+
/**
|
|
64
|
+
* Sanitize name for VBA
|
|
65
|
+
*/
|
|
66
|
+
private sanitizeName;
|
|
67
|
+
/**
|
|
68
|
+
* Clear all recordings and executions
|
|
69
|
+
*/
|
|
70
|
+
clear(): void;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../src/macro/recorder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAY,MAAM,YAAY,CAAC;AAGnF,qBAAa,aAAa;IACxB,OAAO,CAAC,gBAAgB,CAA+B;IACvD,OAAO,CAAC,UAAU,CAA0C;IAC5D,OAAO,CAAC,UAAU,CAA0C;IAC5D,OAAO,CAAC,cAAc,CAAiE;IAEvF;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAE,MAAW,GAAG,MAAM;IAsB9D;;OAEG;IACH,aAAa,IAAI,cAAc,GAAG,IAAI;IAatC;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAgB/E;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIpD;;OAEG;IACH,gBAAgB,IAAI,cAAc,EAAE;IAIpC;;OAEG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIpC;;OAEG;IACH,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI;IAIzF;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAqD9F;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIpD;;OAEG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE;IAIrD;;OAEG;IACH,OAAO,CAAC,MAAM;IASd;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAyCpC;;OAEG;IACH,OAAO,CAAC,WAAW;IAcnB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACH,KAAK,IAAI,IAAI;CAKd"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Macro Recorder for SolidWorks MCP
|
|
3
|
+
* Records and manages macro operations
|
|
4
|
+
*/
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
export class MacroRecorder {
|
|
7
|
+
currentRecording = null;
|
|
8
|
+
recordings = new Map();
|
|
9
|
+
executions = new Map();
|
|
10
|
+
actionHandlers = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Start a new macro recording
|
|
13
|
+
*/
|
|
14
|
+
startRecording(name, description = '') {
|
|
15
|
+
if (this.currentRecording) {
|
|
16
|
+
throw new Error('A recording is already in progress');
|
|
17
|
+
}
|
|
18
|
+
const id = uuidv4();
|
|
19
|
+
this.currentRecording = {
|
|
20
|
+
id,
|
|
21
|
+
name,
|
|
22
|
+
description,
|
|
23
|
+
startTime: new Date().toISOString(),
|
|
24
|
+
actions: [],
|
|
25
|
+
metadata: {
|
|
26
|
+
createdBy: 'solidworks-mcp',
|
|
27
|
+
version: '1.0.0',
|
|
28
|
+
tags: []
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return id;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Stop the current recording
|
|
35
|
+
*/
|
|
36
|
+
stopRecording() {
|
|
37
|
+
if (!this.currentRecording) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
this.currentRecording.endTime = new Date().toISOString();
|
|
41
|
+
const recording = this.currentRecording;
|
|
42
|
+
this.recordings.set(recording.id, recording);
|
|
43
|
+
this.currentRecording = null;
|
|
44
|
+
return recording;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Record an action
|
|
48
|
+
*/
|
|
49
|
+
recordAction(type, name, parameters) {
|
|
50
|
+
if (!this.currentRecording) {
|
|
51
|
+
throw new Error('No recording in progress');
|
|
52
|
+
}
|
|
53
|
+
const action = {
|
|
54
|
+
id: uuidv4(),
|
|
55
|
+
type,
|
|
56
|
+
name,
|
|
57
|
+
timestamp: new Date().toISOString(),
|
|
58
|
+
parameters
|
|
59
|
+
};
|
|
60
|
+
this.currentRecording.actions.push(action);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get a recording by ID
|
|
64
|
+
*/
|
|
65
|
+
getRecording(id) {
|
|
66
|
+
return this.recordings.get(id);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get all recordings
|
|
70
|
+
*/
|
|
71
|
+
getAllRecordings() {
|
|
72
|
+
return Array.from(this.recordings.values());
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Delete a recording
|
|
76
|
+
*/
|
|
77
|
+
deleteRecording(id) {
|
|
78
|
+
return this.recordings.delete(id);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Register an action handler
|
|
82
|
+
*/
|
|
83
|
+
registerActionHandler(type, handler) {
|
|
84
|
+
this.actionHandlers.set(type, handler);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Execute a macro recording
|
|
88
|
+
*/
|
|
89
|
+
async executeMacro(macroId, parameters) {
|
|
90
|
+
const recording = this.recordings.get(macroId);
|
|
91
|
+
if (!recording) {
|
|
92
|
+
throw new Error(`Macro '${macroId}' not found`);
|
|
93
|
+
}
|
|
94
|
+
const executionId = uuidv4();
|
|
95
|
+
const execution = {
|
|
96
|
+
id: executionId,
|
|
97
|
+
macroId,
|
|
98
|
+
startTime: new Date().toISOString(),
|
|
99
|
+
status: 'running',
|
|
100
|
+
logs: []
|
|
101
|
+
};
|
|
102
|
+
this.executions.set(executionId, execution);
|
|
103
|
+
try {
|
|
104
|
+
const results = [];
|
|
105
|
+
for (const action of recording.actions) {
|
|
106
|
+
const handler = this.actionHandlers.get(action.type);
|
|
107
|
+
if (!handler) {
|
|
108
|
+
throw new Error(`No handler registered for action type '${action.type}'`);
|
|
109
|
+
}
|
|
110
|
+
this.addLog(execution, 'info', `Executing action: ${action.name}`);
|
|
111
|
+
try {
|
|
112
|
+
const result = await handler({
|
|
113
|
+
...action,
|
|
114
|
+
parameters: { ...action.parameters, ...parameters }
|
|
115
|
+
});
|
|
116
|
+
results.push(result);
|
|
117
|
+
this.addLog(execution, 'debug', `Action completed: ${action.name}`, result);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
this.addLog(execution, 'error', `Action failed: ${action.name}`, error);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
execution.status = 'completed';
|
|
125
|
+
execution.endTime = new Date().toISOString();
|
|
126
|
+
execution.result = results;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
execution.status = 'failed';
|
|
130
|
+
execution.endTime = new Date().toISOString();
|
|
131
|
+
execution.error = error instanceof Error ? error.message : String(error);
|
|
132
|
+
this.addLog(execution, 'error', 'Macro execution failed', error);
|
|
133
|
+
}
|
|
134
|
+
return execution;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get execution by ID
|
|
138
|
+
*/
|
|
139
|
+
getExecution(id) {
|
|
140
|
+
return this.executions.get(id);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get all executions for a macro
|
|
144
|
+
*/
|
|
145
|
+
getMacroExecutions(macroId) {
|
|
146
|
+
return Array.from(this.executions.values()).filter(e => e.macroId === macroId);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Add a log entry to an execution
|
|
150
|
+
*/
|
|
151
|
+
addLog(execution, level, message, data) {
|
|
152
|
+
execution.logs.push({
|
|
153
|
+
timestamp: new Date().toISOString(),
|
|
154
|
+
level,
|
|
155
|
+
message,
|
|
156
|
+
data
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Export recording to VBA code
|
|
161
|
+
*/
|
|
162
|
+
exportToVBA(macroId) {
|
|
163
|
+
const recording = this.recordings.get(macroId);
|
|
164
|
+
if (!recording) {
|
|
165
|
+
throw new Error(`Macro '${macroId}' not found`);
|
|
166
|
+
}
|
|
167
|
+
const vbaLines = [
|
|
168
|
+
`' Macro: ${recording.name}`,
|
|
169
|
+
`' Description: ${recording.description}`,
|
|
170
|
+
`' Generated: ${new Date().toISOString()}`,
|
|
171
|
+
`' By: SolidWorks MCP Server`,
|
|
172
|
+
'',
|
|
173
|
+
`Sub ${this.sanitizeName(recording.name)}()`,
|
|
174
|
+
' Dim swApp As SldWorks.SldWorks',
|
|
175
|
+
' Dim swModel As SldWorks.ModelDoc2',
|
|
176
|
+
' ',
|
|
177
|
+
' Set swApp = Application.SldWorks',
|
|
178
|
+
' Set swModel = swApp.ActiveDoc',
|
|
179
|
+
' ',
|
|
180
|
+
' If swModel Is Nothing Then',
|
|
181
|
+
' MsgBox "No active document found"',
|
|
182
|
+
' Exit Sub',
|
|
183
|
+
' End If',
|
|
184
|
+
' '
|
|
185
|
+
];
|
|
186
|
+
// Convert actions to VBA code
|
|
187
|
+
for (const action of recording.actions) {
|
|
188
|
+
const vbaCode = this.actionToVBA(action);
|
|
189
|
+
if (vbaCode) {
|
|
190
|
+
vbaLines.push(` ' ${action.name}`);
|
|
191
|
+
vbaLines.push(...vbaCode.split('\n').map(line => ` ${line}`));
|
|
192
|
+
vbaLines.push('');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
vbaLines.push('End Sub');
|
|
196
|
+
return vbaLines.join('\n');
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Convert action to VBA code
|
|
200
|
+
*/
|
|
201
|
+
actionToVBA(action) {
|
|
202
|
+
// This would be expanded with specific action type conversions
|
|
203
|
+
const vbaGenerators = {
|
|
204
|
+
'create-sketch': (params) => `swModel.CreateSketch "${params.plane}"`,
|
|
205
|
+
'add-line': (params) => `swModel.CreateLine2 ${params.x1}, ${params.y1}, ${params.z1}, ${params.x2}, ${params.y2}, ${params.z2}`,
|
|
206
|
+
'add-circle': (params) => `swModel.CreateCircle2 ${params.centerX}, ${params.centerY}, ${params.centerZ}, ${params.radius}`,
|
|
207
|
+
'extrude': (params) => `swModel.FeatureManager.FeatureExtrusion3 True, False, False, 0, 0, ${params.depth}, 0, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False`,
|
|
208
|
+
// Add more action types as needed
|
|
209
|
+
};
|
|
210
|
+
const generator = vbaGenerators[action.type];
|
|
211
|
+
return generator ? generator(action.parameters) : `' Unsupported action: ${action.type}`;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Sanitize name for VBA
|
|
215
|
+
*/
|
|
216
|
+
sanitizeName(name) {
|
|
217
|
+
return name.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Clear all recordings and executions
|
|
221
|
+
*/
|
|
222
|
+
clear() {
|
|
223
|
+
this.currentRecording = null;
|
|
224
|
+
this.recordings.clear();
|
|
225
|
+
this.executions.clear();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorder.js","sourceRoot":"","sources":["../../src/macro/recorder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,OAAO,aAAa;IAChB,gBAAgB,GAA0B,IAAI,CAAC;IAC/C,UAAU,GAAgC,IAAI,GAAG,EAAE,CAAC;IACpD,UAAU,GAAgC,IAAI,GAAG,EAAE,CAAC;IACpD,cAAc,GAAuD,IAAI,GAAG,EAAE,CAAC;IAEvF;;OAEG;IACH,cAAc,CAAC,IAAY,EAAE,cAAsB,EAAE;QACnD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG;YACtB,EAAE;YACF,IAAI;YACJ,WAAW;YACX,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE;gBACR,SAAS,EAAE,gBAAgB;gBAC3B,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE,EAAE;aACT;SACF,CAAC;QAEF,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;OAE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,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Macro Types for SolidWorks MCP
|
|
3
|
+
*/
|
|
4
|
+
export interface MacroAction {
|
|
5
|
+
id: string;
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
parameters: Record<string, any>;
|
|
10
|
+
result?: any;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface MacroRecording {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
startTime: string;
|
|
18
|
+
endTime?: string;
|
|
19
|
+
actions: MacroAction[];
|
|
20
|
+
metadata: {
|
|
21
|
+
createdBy: string;
|
|
22
|
+
version: string;
|
|
23
|
+
solidworksVersion?: string;
|
|
24
|
+
tags: string[];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface MacroTemplate {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
category: string;
|
|
32
|
+
parameters: MacroParameter[];
|
|
33
|
+
code: string;
|
|
34
|
+
language: 'VBA' | 'VSTA' | 'C#' | 'VB.NET';
|
|
35
|
+
examples?: MacroExample[];
|
|
36
|
+
}
|
|
37
|
+
export interface MacroParameter {
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
required: boolean;
|
|
42
|
+
defaultValue?: any;
|
|
43
|
+
validation?: {
|
|
44
|
+
min?: number;
|
|
45
|
+
max?: number;
|
|
46
|
+
pattern?: string;
|
|
47
|
+
enum?: any[];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface MacroExample {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
parameters: Record<string, any>;
|
|
54
|
+
expectedResult?: any;
|
|
55
|
+
}
|
|
56
|
+
export interface MacroExecution {
|
|
57
|
+
id: string;
|
|
58
|
+
macroId: string;
|
|
59
|
+
startTime: string;
|
|
60
|
+
endTime?: string;
|
|
61
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
62
|
+
result?: any;
|
|
63
|
+
error?: string;
|
|
64
|
+
logs: MacroLog[];
|
|
65
|
+
}
|
|
66
|
+
export interface MacroLog {
|
|
67
|
+
timestamp: string;
|
|
68
|
+
level: 'debug' | 'info' | 'warning' | 'error';
|
|
69
|
+
message: string;
|
|
70
|
+
data?: any;
|
|
71
|
+
}
|
|
72
|
+
export interface MacroStorageOptions {
|
|
73
|
+
type: 'file' | 'database' | 'memory';
|
|
74
|
+
path?: string;
|
|
75
|
+
connectionString?: string;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/macro/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,QAAQ,EAAE;QACR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QAAQ,CAAC;IACvD,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/macro/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Resource Class for SolidWorks MCP Implementation
|
|
3
|
+
* Provides foundation for all SolidWorks resources with state management
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export interface ValidationResult {
|
|
7
|
+
valid: boolean;
|
|
8
|
+
errors?: Array<{
|
|
9
|
+
path: string;
|
|
10
|
+
message: string;
|
|
11
|
+
}>;
|
|
12
|
+
warnings?: Array<{
|
|
13
|
+
path: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export interface ResourceState {
|
|
18
|
+
id: string;
|
|
19
|
+
type: string;
|
|
20
|
+
name: string;
|
|
21
|
+
properties: Record<string, any>;
|
|
22
|
+
outputs: Record<string, any>;
|
|
23
|
+
metadata: ResourceMetadata;
|
|
24
|
+
status: ResourceStatus;
|
|
25
|
+
}
|
|
26
|
+
export interface ResourceMetadata {
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
createdBy: string;
|
|
30
|
+
version: number;
|
|
31
|
+
tags: Record<string, string>;
|
|
32
|
+
annotations: Record<string, string>;
|
|
33
|
+
solidworksVersion?: string;
|
|
34
|
+
fileReference?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare enum ResourceStatus {
|
|
37
|
+
PENDING = "pending",
|
|
38
|
+
CREATING = "creating",
|
|
39
|
+
CREATED = "created",
|
|
40
|
+
UPDATING = "updating",
|
|
41
|
+
DELETING = "deleting",
|
|
42
|
+
DELETED = "deleted",
|
|
43
|
+
FAILED = "failed",
|
|
44
|
+
EXECUTING = "executing",
|
|
45
|
+
COMPLETED = "completed",
|
|
46
|
+
UNKNOWN = "unknown"
|
|
47
|
+
}
|
|
48
|
+
export interface ResourceDependency {
|
|
49
|
+
resourceId: string;
|
|
50
|
+
type: 'hard' | 'soft';
|
|
51
|
+
outputRef?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare abstract class SolidWorksResource {
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly name: string;
|
|
56
|
+
protected _properties: Record<string, any>;
|
|
57
|
+
protected _outputs: Record<string, any>;
|
|
58
|
+
protected _dependencies: ResourceDependency[];
|
|
59
|
+
protected _status: ResourceStatus;
|
|
60
|
+
protected _metadata: ResourceMetadata;
|
|
61
|
+
abstract readonly type: string;
|
|
62
|
+
abstract readonly schema: z.ZodSchema<any>;
|
|
63
|
+
constructor(id: string, name: string, properties: Record<string, any>);
|
|
64
|
+
/**
|
|
65
|
+
* Validate the resource properties against schema
|
|
66
|
+
*/
|
|
67
|
+
validate(): ValidationResult;
|
|
68
|
+
/**
|
|
69
|
+
* Convert resource to state representation
|
|
70
|
+
*/
|
|
71
|
+
toState(): ResourceState;
|
|
72
|
+
/**
|
|
73
|
+
* Restore resource from state
|
|
74
|
+
*/
|
|
75
|
+
fromState(state: ResourceState): void;
|
|
76
|
+
/**
|
|
77
|
+
* Get resource dependencies
|
|
78
|
+
*/
|
|
79
|
+
getDependencies(): ResourceDependency[];
|
|
80
|
+
/**
|
|
81
|
+
* Add a dependency to this resource
|
|
82
|
+
*/
|
|
83
|
+
addDependency(dependency: ResourceDependency): void;
|
|
84
|
+
/**
|
|
85
|
+
* Get resource outputs
|
|
86
|
+
*/
|
|
87
|
+
getOutputs(): Record<string, any>;
|
|
88
|
+
/**
|
|
89
|
+
* Set resource outputs
|
|
90
|
+
*/
|
|
91
|
+
setOutputs(outputs: Record<string, any>): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get resource status
|
|
94
|
+
*/
|
|
95
|
+
getStatus(): ResourceStatus;
|
|
96
|
+
/**
|
|
97
|
+
* Update resource status
|
|
98
|
+
*/
|
|
99
|
+
setStatus(status: ResourceStatus): void;
|
|
100
|
+
/**
|
|
101
|
+
* Get resource properties
|
|
102
|
+
*/
|
|
103
|
+
getProperties(): Record<string, any>;
|
|
104
|
+
/**
|
|
105
|
+
* Update resource properties
|
|
106
|
+
*/
|
|
107
|
+
updateProperties(properties: Partial<Record<string, any>>): ValidationResult;
|
|
108
|
+
/**
|
|
109
|
+
* Abstract methods that must be implemented by concrete resources
|
|
110
|
+
*/
|
|
111
|
+
abstract execute(api: any): Promise<any>;
|
|
112
|
+
abstract toVBACode(): string;
|
|
113
|
+
abstract toMacroCode(): string;
|
|
114
|
+
abstract getRequiredCapabilities(): string[];
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/resources/base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,QAAQ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