easyeda-mcp-pro 0.2.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/README.md +304 -0
- package/dist/bridge/client.d.ts +16 -0
- package/dist/bridge/client.js +48 -0
- package/dist/bridge/client.js.map +1 -0
- package/dist/bridge/extension.d.ts +26 -0
- package/dist/bridge/extension.js +556 -0
- package/dist/bridge/extension.js.map +1 -0
- package/dist/bridge/manager.d.ts +37 -0
- package/dist/bridge/manager.js +225 -0
- package/dist/bridge/manager.js.map +1 -0
- package/dist/bridge/protocol.d.ts +68 -0
- package/dist/bridge/protocol.js +56 -0
- package/dist/bridge/protocol.js.map +1 -0
- package/dist/bridge/types.d.ts +52 -0
- package/dist/bridge/types.js +19 -0
- package/dist/bridge/types.js.map +1 -0
- package/dist/config/env.d.ts +98 -0
- package/dist/config/env.js +103 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/feature-flags.d.ts +16 -0
- package/dist/config/feature-flags.js +17 -0
- package/dist/config/feature-flags.js.map +1 -0
- package/dist/config/profiles.d.ts +10 -0
- package/dist/config/profiles.js +45 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/common.d.ts +123 -0
- package/dist/schemas/common.js +79 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/server/errors.d.ts +3 -0
- package/dist/server/errors.js +59 -0
- package/dist/server/errors.js.map +1 -0
- package/dist/server/factory.d.ts +17 -0
- package/dist/server/factory.js +60 -0
- package/dist/server/factory.js.map +1 -0
- package/dist/server/transports/http.d.ts +10 -0
- package/dist/server/transports/http.js +54 -0
- package/dist/server/transports/http.js.map +1 -0
- package/dist/storage/database.d.ts +19 -0
- package/dist/storage/database.js +136 -0
- package/dist/storage/database.js.map +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/types.d.ts +26 -0
- package/dist/storage/types.js +9 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/tools/L0_diagnostics.d.ts +6 -0
- package/dist/tools/L0_diagnostics.js +297 -0
- package/dist/tools/L0_diagnostics.js.map +1 -0
- package/dist/tools/L1_board.d.ts +6 -0
- package/dist/tools/L1_board.js +182 -0
- package/dist/tools/L1_board.js.map +1 -0
- package/dist/tools/L1_bom.d.ts +6 -0
- package/dist/tools/L1_bom.js +267 -0
- package/dist/tools/L1_bom.js.map +1 -0
- package/dist/tools/L1_drc_erc.d.ts +6 -0
- package/dist/tools/L1_drc_erc.js +235 -0
- package/dist/tools/L1_drc_erc.js.map +1 -0
- package/dist/tools/L1_export.d.ts +6 -0
- package/dist/tools/L1_export.js +214 -0
- package/dist/tools/L1_export.js.map +1 -0
- package/dist/tools/L1_schematic.d.ts +6 -0
- package/dist/tools/L1_schematic.js +182 -0
- package/dist/tools/L1_schematic.js.map +1 -0
- package/dist/tools/registry.d.ts +21 -0
- package/dist/tools/registry.js +55 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/types.d.ts +53 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.js +54 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/redaction.d.ts +2 -0
- package/dist/utils/redaction.js +56 -0
- package/dist/utils/redaction.js.map +1 -0
- package/dist/vendors/digikey/client.d.ts +49 -0
- package/dist/vendors/digikey/client.js +200 -0
- package/dist/vendors/digikey/client.js.map +1 -0
- package/dist/vendors/jlcpcb/client.d.ts +79 -0
- package/dist/vendors/jlcpcb/client.js +156 -0
- package/dist/vendors/jlcpcb/client.js.map +1 -0
- package/dist/vendors/lcsc/client.d.ts +57 -0
- package/dist/vendors/lcsc/client.js +140 -0
- package/dist/vendors/lcsc/client.js.map +1 -0
- package/dist/vendors/mouser/client.d.ts +46 -0
- package/dist/vendors/mouser/client.js +141 -0
- package/dist/vendors/mouser/client.js.map +1 -0
- package/package.json +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# easyeda-mcp-pro
|
|
2
|
+
|
|
3
|
+
**Production-grade MCP server for EasyEDA Pro: safe PCB design inspection, BOM sourcing, manufacturing export, and AI-assisted hardware review.**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/oaslananka/easyeda-mcp-pro/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/easyeda-mcp-pro)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://deepwiki.com/oaslananka/easyeda-mcp-pro)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx easyeda-mcp-pro
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Point your MCP client (Claude, Cursor, etc.) to the stdio transport. Create a `.env` file to configure suppliers and AI providers (see [Configuration](#configuration)).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
easyeda-mcp-pro is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that bridges AI assistants with hardware design workflows in EasyEDA Pro. It exposes 25 MCP tools for schematic inspection, BOM management, design rule checks, PCB board analysis, fabrication exports, and supplier integration.
|
|
25
|
+
|
|
26
|
+
The server connects to EasyEDA Pro via a WebSocket bridge extension, enabling real-time access to open project data. It integrates with JLCPCB, LCSC, Mouser, and DigiKey for BOM sourcing and pricing.
|
|
27
|
+
|
|
28
|
+
### Key Capabilities
|
|
29
|
+
|
|
30
|
+
| Area | What you can do |
|
|
31
|
+
| --------------- | -------------------------------------------------------- |
|
|
32
|
+
| **Schematic** | List nets and components, get net details |
|
|
33
|
+
| **BOM** | Generate, validate, export, and source bill of materials |
|
|
34
|
+
| **DRC/ERC** | Run design rule and electrical rule checks |
|
|
35
|
+
| **Board** | Inspect layers, stackup, dimensions, features |
|
|
36
|
+
| **Export** | Export Gerbers, pick-and-place, PDF, netlist |
|
|
37
|
+
| **Diagnostics** | Health check, bridge status, capabilities, self-test |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Prerequisites
|
|
42
|
+
|
|
43
|
+
- **Node.js** >=24 <27 (required for the latest JavaScript features)
|
|
44
|
+
- **pnpm** >=11 (for local development; the npm package is self-contained)
|
|
45
|
+
- **EasyEDA Pro** with the [bridge extension](https://github.com/oaslananka/easyeda-bridge) installed and running
|
|
46
|
+
- For supplier integration: API credentials from JLCPCB, LCSC, Mouser, or DigiKey
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
### Via npm (recommended)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g easyeda-mcp-pro
|
|
56
|
+
easyeda-mcp-pro
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Via npx
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npx easyeda-mcp-pro
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### From source
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git clone https://github.com/oaslananka/easyeda-mcp-pro.git
|
|
69
|
+
cd easyeda-mcp-pro
|
|
70
|
+
cp .env.example .env
|
|
71
|
+
pnpm install
|
|
72
|
+
pnpm build
|
|
73
|
+
pnpm start
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Configuration
|
|
79
|
+
|
|
80
|
+
Copy `.env.example` to `.env` and edit. All variables have safe defaults — only configure what you need.
|
|
81
|
+
|
|
82
|
+
### Essential
|
|
83
|
+
|
|
84
|
+
| Variable | Default | Description |
|
|
85
|
+
| -------------- | ------------- | ---------------------------------------------------------------------------- |
|
|
86
|
+
| `NODE_ENV` | `development` | Set to `production` in production |
|
|
87
|
+
| `LOG_LEVEL` | `info` | Pino log level: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `silent` |
|
|
88
|
+
| `TOOL_PROFILE` | `core` | Tool set: `core`, `pro`, `full`, `dev`, `experimental` |
|
|
89
|
+
| `TRANSPORT` | `stdio` | Server transport: `stdio` (default) or `http` |
|
|
90
|
+
|
|
91
|
+
### Bridge (EasyEDA Pro connection)
|
|
92
|
+
|
|
93
|
+
| Variable | Default | Description |
|
|
94
|
+
| ------------------- | ----------- | ------------------------ |
|
|
95
|
+
| `BRIDGE_HOST` | `127.0.0.1` | Bridge WebSocket host |
|
|
96
|
+
| `BRIDGE_PORT` | `18601` | Bridge port |
|
|
97
|
+
| `BRIDGE_TIMEOUT_MS` | `15000` | Bridge call timeout (ms) |
|
|
98
|
+
|
|
99
|
+
### Storage
|
|
100
|
+
|
|
101
|
+
| Variable | Default | Description |
|
|
102
|
+
| ---------- | ------------------ | ------------------------------------------- |
|
|
103
|
+
| `DATA_DIR` | `.easyeda-mcp-pro` | Data directory (cache, database, artifacts) |
|
|
104
|
+
|
|
105
|
+
### Supplier integration
|
|
106
|
+
|
|
107
|
+
Enable suppliers by setting their credentials. All suppliers are disabled by default.
|
|
108
|
+
|
|
109
|
+
- **JLCPCB**: `JLCPCB_MODE=approved_api` + client ID/secret
|
|
110
|
+
- **LCSC**: `JLCSEARCH_ENABLED=true` (default, no key required for basic search)
|
|
111
|
+
- **Mouser**: `MOUSER_ENABLED=true` + API key
|
|
112
|
+
- **DigiKey**: `DIGIKEY_ENABLED=true` + OAuth2 client ID/secret
|
|
113
|
+
|
|
114
|
+
### AI Assistance (experimental)
|
|
115
|
+
|
|
116
|
+
Configure an AI provider for LLM-assisted design review:
|
|
117
|
+
|
|
118
|
+
| Variable | Default | Description |
|
|
119
|
+
| ------------- | ------- | ----------------------------------------------- |
|
|
120
|
+
| `AI_PROVIDER` | `none` | `anthropic`, `openai`, `openrouter`, or `local` |
|
|
121
|
+
| `AI_MODEL` | `''` | Model name |
|
|
122
|
+
|
|
123
|
+
### HTTP transport
|
|
124
|
+
|
|
125
|
+
When using `TRANSPORT=http`:
|
|
126
|
+
|
|
127
|
+
| Variable | Default | Description |
|
|
128
|
+
| ------------- | ----------- | ----------------------------------------- |
|
|
129
|
+
| `HTTP_HOST` | `127.0.0.1` | Bind address (use `0.0.0.0` with caution) |
|
|
130
|
+
| `HTTP_PORT` | `3000` | Port |
|
|
131
|
+
| `CORS_ORIGIN` | `''` | Allowed CORS origin |
|
|
132
|
+
|
|
133
|
+
For production HTTP deployments, configure OAuth (`OAUTH_ENABLED=true` + issuer/JWKS).
|
|
134
|
+
|
|
135
|
+
See `.env.example` for the complete list of 42 configuration variables.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## MCP Tools
|
|
140
|
+
|
|
141
|
+
All 25 tools are available via the MCP server. Tools are filtered by the active `TOOL_PROFILE`.
|
|
142
|
+
|
|
143
|
+
### L0 — Diagnostics (core)
|
|
144
|
+
|
|
145
|
+
| Tool | Description |
|
|
146
|
+
| --------------------------- | ----------------------------------------------------- |
|
|
147
|
+
| `easyeda_health_check` | Server health, runtime version, profile, bridge state |
|
|
148
|
+
| `easyeda_bridge_status` | Bridge connection status, version, capabilities |
|
|
149
|
+
| `easyeda_get_capabilities` | Available profiles, features, supported operations |
|
|
150
|
+
| `easyeda_get_server_config` | Safe/redacted server configuration |
|
|
151
|
+
| `easyeda_get_tool_profiles` | Available tool profiles |
|
|
152
|
+
| `easyeda_get_feature_flags` | Current feature flags |
|
|
153
|
+
| `easyeda_run_self_test` | Internal self-test |
|
|
154
|
+
|
|
155
|
+
### L1 — Schematic (core)
|
|
156
|
+
|
|
157
|
+
| Tool | Description |
|
|
158
|
+
| ------------------------------ | ----------------------------------------------------------- |
|
|
159
|
+
| `easyeda_schematic_nets` | List all nets with node connections |
|
|
160
|
+
| `easyeda_schematic_components` | List components with ref, value, footprint, LCSC, datasheet |
|
|
161
|
+
| `easyeda_schematic_net_detail` | Full detail for a specific net |
|
|
162
|
+
|
|
163
|
+
### L1 — BOM (core)
|
|
164
|
+
|
|
165
|
+
| Tool | Description |
|
|
166
|
+
| ---------------------- | --------------------------------------- |
|
|
167
|
+
| `easyeda_bom_generate` | Generate bill of materials |
|
|
168
|
+
| `easyeda_bom_validate` | Validate BOM against LCSC inventory |
|
|
169
|
+
| `easyeda_bom_export` | Export BOM to file |
|
|
170
|
+
| `easyeda_bom_sourcing` | Pricing and availability from suppliers |
|
|
171
|
+
|
|
172
|
+
### L1 — DRC/ERC (core)
|
|
173
|
+
|
|
174
|
+
| Tool | Description |
|
|
175
|
+
| ---------------------------- | ----------------------------------- |
|
|
176
|
+
| `easyeda_drc_run` | Design rule check for PCB |
|
|
177
|
+
| `easyeda_erc_run` | Electrical rule check for schematic |
|
|
178
|
+
| `easyeda_rule_check_summary` | Combined DRC + ERC summary |
|
|
179
|
+
|
|
180
|
+
### L1 — Board (core)
|
|
181
|
+
|
|
182
|
+
| Tool | Description |
|
|
183
|
+
| -------------------------- | ----------------------------------------------- |
|
|
184
|
+
| `easyeda_board_layers` | List PCB layers with type, color, visibility |
|
|
185
|
+
| `easyeda_board_stackup` | Layer stackup with thickness, material |
|
|
186
|
+
| `easyeda_board_dimensions` | Board outline, shape, mounting holes |
|
|
187
|
+
| `easyeda_board_features` | Counts of vias, tracks, zones, pads, components |
|
|
188
|
+
|
|
189
|
+
### L1 — Export (core/pro)
|
|
190
|
+
|
|
191
|
+
| Tool | Profile | Description |
|
|
192
|
+
| --------------------------- | ------- | ----------------------------------- |
|
|
193
|
+
| `easyeda_export_gerbers` | core | Export Gerber files for fabrication |
|
|
194
|
+
| `easyeda_export_pick_place` | pro | Export pick-and-place centroid file |
|
|
195
|
+
| `easyeda_export_pdf` | pro | Export schematic/board to PDF |
|
|
196
|
+
| `easyeda_export_netlist` | pro | Export netlist |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Architecture
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
┌─────────────────┐ WebSocket ┌─────────────────────┐
|
|
204
|
+
│ AI Assistant │ ◄──── MCP ──────► │ easyeda-mcp-pro │
|
|
205
|
+
│ (Claude, etc.) │ Protocol │ (MCP Server) │
|
|
206
|
+
└─────────────────┘ │ │
|
|
207
|
+
│ ┌───────────────┐ │
|
|
208
|
+
┌─────────────────┐ WebSocket │ │ BridgeManager │──┼──► EasyEDA Pro
|
|
209
|
+
│ EasyEDA Pro │ ◄── Bridge ──────►│ │ (WS Client) │ │ (Plugin)
|
|
210
|
+
│ (via Plugin) │ Protocol │ └───────────────┘ │
|
|
211
|
+
└─────────────────┘ │ ┌───────────────┐ │
|
|
212
|
+
│ │ ToolRegistry │ │
|
|
213
|
+
│ │ (25 tools) │ │
|
|
214
|
+
│ └───────────────┘ │
|
|
215
|
+
│ ┌───────────────┐ │
|
|
216
|
+
│ │ Storage │──┼──► SQLite
|
|
217
|
+
│ │ (Cache/DB) │ │
|
|
218
|
+
│ └───────────────┘ │
|
|
219
|
+
│ ┌───────────────┐ │
|
|
220
|
+
│ │ Vendors │──┼──► JLCPCB/LCSC/
|
|
221
|
+
│ │ (API Clients) │ │ Mouser/DigiKey
|
|
222
|
+
│ └───────────────┘ │
|
|
223
|
+
└─────────────────────┘
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Transports
|
|
227
|
+
|
|
228
|
+
- **stdio** (default): Standard MCP transport — works with Claude Desktop, Cursor, and most MCP clients
|
|
229
|
+
- **HTTP**: Streamable HTTP transport with `/healthz`, `/readyz`, `/mcp` endpoints, CORS, and optional OAuth — suitable for remote deployments
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Development
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Setup
|
|
237
|
+
pnpm install
|
|
238
|
+
cp .env.example .env
|
|
239
|
+
|
|
240
|
+
# Code quality
|
|
241
|
+
pnpm format:check # Prettier
|
|
242
|
+
pnpm typecheck # TypeScript
|
|
243
|
+
pnpm lint # ESLint
|
|
244
|
+
|
|
245
|
+
# Test
|
|
246
|
+
pnpm test # Vitest (73 tests across 12 files)
|
|
247
|
+
pnpm test:coverage # With coverage report
|
|
248
|
+
|
|
249
|
+
# Build & run
|
|
250
|
+
pnpm build # tsc -> dist/
|
|
251
|
+
pnpm dev # Hot-reload dev mode
|
|
252
|
+
pnpm start # Run compiled build
|
|
253
|
+
|
|
254
|
+
# MCP Inspector (debug UI)
|
|
255
|
+
pnpm inspector
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Project structure
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
src/
|
|
262
|
+
├── index.ts # Entry point
|
|
263
|
+
├── bridge/ # EasyEDA Pro WebSocket bridge protocol
|
|
264
|
+
│ ├── manager.ts, client.ts, extension.ts, protocol.ts, types.ts
|
|
265
|
+
├── config/ # Environment configuration
|
|
266
|
+
│ ├── env.ts, profiles.ts, feature-flags.ts
|
|
267
|
+
├── schemas/ # Shared Zod schemas
|
|
268
|
+
├── server/ # MCP server core
|
|
269
|
+
│ ├── factory.ts, errors.ts
|
|
270
|
+
│ └── transports/
|
|
271
|
+
│ └── http.ts # HTTP/Streamable HTTP transport
|
|
272
|
+
├── storage/ # SQLite storage (cache, artifacts)
|
|
273
|
+
├── tools/ # 25 MCP tool definitions (6 groups)
|
|
274
|
+
│ ├── registry.ts, types.ts
|
|
275
|
+
│ ├── L0_diagnostics.ts, L1_schematic.ts, L1_bom.ts
|
|
276
|
+
│ ├── L1_drc_erc.ts, L1_board.ts, L1_export.ts
|
|
277
|
+
└── vendors/ # Supplier API clients
|
|
278
|
+
├── lcsc/, jlcpcb/, mouser/, digikey/
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Security
|
|
284
|
+
|
|
285
|
+
- **Production safety**: Validates config at startup — rejects non-loopback HTTP without OAuth, blocks dangerous features in production
|
|
286
|
+
- **Secret redaction**: API keys, tokens, passwords are redacted from logs and diagnostic output
|
|
287
|
+
- **Branch protection**: `main` branch requires review and up-to-date status checks
|
|
288
|
+
- **Code scanning**: CodeQL analysis runs on every push and PR (security-extended + security-and-quality queries)
|
|
289
|
+
- **Dependency management**: Renovate automatically updates dependencies with security patches
|
|
290
|
+
- **Reporting**: See [SECURITY.md](SECURITY.md) for vulnerability disclosure
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## License
|
|
295
|
+
|
|
296
|
+
[MIT](LICENSE)
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Related
|
|
301
|
+
|
|
302
|
+
- [easyeda-bridge](https://github.com/oaslananka/easyeda-bridge) — EasyEDA Pro plugin that exposes the bridge WebSocket API
|
|
303
|
+
- [Model Context Protocol](https://modelcontextprotocol.io) — Standard protocol for AI tool integration
|
|
304
|
+
- [EasyEDA Pro](https://pro.easyeda.com) — Professional PCB design tool
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type BridgeManager } from './manager.js';
|
|
2
|
+
import { type EasyedaApiMethod, type BridgeCallOptions, type BridgeCallResult } from './types.js';
|
|
3
|
+
export declare class EasyedaClient {
|
|
4
|
+
private bridge;
|
|
5
|
+
constructor(bridge: BridgeManager);
|
|
6
|
+
call<T = unknown>(method: EasyedaApiMethod, params?: Record<string, unknown>, opts?: BridgeCallOptions): Promise<BridgeCallResult<T>>;
|
|
7
|
+
openProject(projectId: string): Promise<BridgeCallResult>;
|
|
8
|
+
listNets(projectId: string): Promise<BridgeCallResult>;
|
|
9
|
+
listComponents(projectId: string): Promise<BridgeCallResult>;
|
|
10
|
+
generateBom(projectId: string): Promise<BridgeCallResult>;
|
|
11
|
+
runDrc(projectId: string): Promise<BridgeCallResult>;
|
|
12
|
+
runErc(projectId: string): Promise<BridgeCallResult>;
|
|
13
|
+
exportGerbers(projectId: string, options?: Record<string, unknown>): Promise<BridgeCallResult>;
|
|
14
|
+
searchInventory(query: string): Promise<BridgeCallResult>;
|
|
15
|
+
getPrice(lcsc: string): Promise<BridgeCallResult>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getLogger } from '../utils/logger.js';
|
|
2
|
+
const logger = getLogger();
|
|
3
|
+
export class EasyedaClient {
|
|
4
|
+
bridge;
|
|
5
|
+
constructor(bridge) {
|
|
6
|
+
this.bridge = bridge;
|
|
7
|
+
}
|
|
8
|
+
async call(method, params, opts) {
|
|
9
|
+
try {
|
|
10
|
+
logger.debug({ method }, 'bridge call');
|
|
11
|
+
const result = await this.bridge.call(method, params, opts);
|
|
12
|
+
return { success: true, data: result };
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
16
|
+
logger.warn({ method, err: message }, 'bridge call failed');
|
|
17
|
+
return { success: false, error: { code: 'BRIDGE_ERROR', message } };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async openProject(projectId) {
|
|
21
|
+
return this.call('project.open', { projectId });
|
|
22
|
+
}
|
|
23
|
+
async listNets(projectId) {
|
|
24
|
+
return this.call('schematic.listNets', { projectId });
|
|
25
|
+
}
|
|
26
|
+
async listComponents(projectId) {
|
|
27
|
+
return this.call('schematic.listComponents', { projectId });
|
|
28
|
+
}
|
|
29
|
+
async generateBom(projectId) {
|
|
30
|
+
return this.call('bom.generate', { projectId });
|
|
31
|
+
}
|
|
32
|
+
async runDrc(projectId) {
|
|
33
|
+
return this.call('design.drc', { projectId });
|
|
34
|
+
}
|
|
35
|
+
async runErc(projectId) {
|
|
36
|
+
return this.call('design.erc', { projectId });
|
|
37
|
+
}
|
|
38
|
+
async exportGerbers(projectId, options) {
|
|
39
|
+
return this.call('board.exportGerbers', { projectId, ...options });
|
|
40
|
+
}
|
|
41
|
+
async searchInventory(query) {
|
|
42
|
+
return this.call('inventory.search', { query });
|
|
43
|
+
}
|
|
44
|
+
async getPrice(lcsc) {
|
|
45
|
+
return this.call('inventory.getPrice', { lcsc });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/bridge/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;AAE3B,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE7C,KAAK,CAAC,IAAI,CACR,MAAwB,EACxB,MAAgC,EAChC,IAAwB;QAExB,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC;YACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAA6B,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACzC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,oBAAoB,CAAC,CAAC;YAC5D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,CAAC;QACtE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAiB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,SAAiB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,SAAiB;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAiB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,SAAiB,EACjB,OAAiC;QAEjC,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,KAAa;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { type EnvConfig } from '../config/env.js';
|
|
3
|
+
export type ExtensionState = 'idle' | 'listening' | 'connected' | 'error';
|
|
4
|
+
export interface ExtensionEvents {
|
|
5
|
+
stateChanged: (state: ExtensionState, previous: ExtensionState) => void;
|
|
6
|
+
clientConnected: () => void;
|
|
7
|
+
clientDisconnected: (reason: string) => void;
|
|
8
|
+
error: (error: Error) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class BridgeExtension extends EventEmitter {
|
|
11
|
+
state: ExtensionState;
|
|
12
|
+
private config;
|
|
13
|
+
private wss;
|
|
14
|
+
private client;
|
|
15
|
+
private heartbeatTimer;
|
|
16
|
+
constructor(config: EnvConfig);
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
private handleHandshake;
|
|
19
|
+
private handleHeartbeat;
|
|
20
|
+
private handleRequest;
|
|
21
|
+
private executeMethod;
|
|
22
|
+
private executeDevMock;
|
|
23
|
+
private startHeartbeat;
|
|
24
|
+
private stopHeartbeat;
|
|
25
|
+
stop(): void;
|
|
26
|
+
}
|