lceda-connect 0.1.1 → 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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  本项目较重要的变更都记在这里。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号按 [语义化版本](https://semver.org/lang/zh-CN/) 走。
4
4
 
5
+ ## [0.2.0] - 2026-11-20
6
+
7
+ - 新增实验性的 `cdp input` 和 MCP `cdp_input`,可向指定 PCB 页面派发点击、有限按键和文本。请求需显式确认并通过页面、文档与焦点检查;工具不主动将窗口切到前台,也不调用系统键鼠。已通过模拟回归,真实客户端后台输入仍待验证。
8
+ - 兼容嘉立创 EDA 专业版 4.1.105:启动时不再传入该版本不识别的 `--remote-debugging-address` 参数。
9
+
5
10
  ## [0.1.1] - 2026-11-19
6
11
 
7
12
  - 更新 npm 安装说明和公开源码链接。此补丁不改运行时代码,用于验证 GitHub Actions 的 npm Trusted Publishing。
package/README.md CHANGED
@@ -208,12 +208,15 @@ lceda-bridge stop
208
208
 
209
209
  `start` 的行为细节:
210
210
 
211
- - 启动参数顺序固定为 `--remote-debugging-port` → `--remote-debugging-address` → `--proxy-server`。客户端「清理缓存」自重启只透传 `process.argv[1]`,端口必须待在第一位才能活过重启。
211
+ - `--remote-debugging-port` 放在首位,以兼容只透传首个参数的客户端自重启。为兼容不识别 `--remote-debugging-address` 的客户端(如嘉立创 EDA 4.1.105),CLI 不传该参数;显式指定的 `--proxy-server` 仍排在端口之后。
212
+ - CLI 通过 `127.0.0.1` 探测端点,客户端的实际监听地址由 Chromium 决定。端点能连通不代表它只监听回环;请用系统监听表检查该端口的全部监听地址。若有非回环监听,请停止本次调试会话,不要做端口转发。
212
213
  - 默认清掉继承来的 `http_proxy` / `https_proxy` / `all_proxy` / `ftp_proxy` / `no_proxy`,让客户端回到「按 Windows 系统代理走」这一条可解释路径(否则会去连某个终端专用的沙箱代理,表现为白屏 30~80 秒)。要保留就加 `--keep-proxy-env`。
213
214
  - 启动前先探 `pro.lceda.cn`:网络没通会警告,`--wait-online N` 可以等最多 N 秒。
214
215
  - 客户端是单实例的:已有实例时新启动的参数会被转交并丢弃,因此默认拒绝,确需并行要 `--force`(两个实例会争抢同一份数据)。
215
216
  - 启动后自动校准 pid:Electron 的启动器进程可能 fork 后退出,pid 文件会被改写成真正持有窗口的主进程。
216
217
 
218
+ 对已运行的指定 PCB 页面,可用 `cdp input` / MCP `cdp_input` 定向派发点击、按键或文本。它不会自动拉前台,也不回退到系统键鼠。见[使用条件与验收方法](docs/cdp-input.md)。
219
+
217
220
  ### `lceda-bridge <动作>` / `lceda-connect bridge <动作>`
218
221
 
219
222
  | 动作 | 说明 |
@@ -87,31 +87,25 @@ python scripts/check_environment.py --json
87
87
 
88
88
  ### 启动命令
89
89
 
90
- Windows(已实测):
90
+ Windows:
91
91
 
92
92
  ```powershell
93
- & "<安装目录>\lceda-pro.exe" --remote-debugging-port=9222 --remote-debugging-address=127.0.0.1
93
+ & "<安装目录>\lceda-pro.exe" --remote-debugging-port=9222
94
94
  ```
95
95
 
96
96
  macOS / Linux(同源机制,未实测):
97
97
 
98
98
  ```bash
99
- "<安装目录>/lceda-pro" --remote-debugging-port=9222 --remote-debugging-address=127.0.0.1
99
+ "<安装目录>/lceda-pro" --remote-debugging-port=9222
100
100
  ```
101
101
 
102
- - `--remote-debugging-address` 必须写 `127.0.0.1`。永远不要用 `0.0.0.0`,也不要做端口转发或内网穿透。
102
+ - 不要附加 `--remote-debugging-address`,部分客户端版本(如嘉立创 EDA 4.1.105)不识别它。实际监听地址由 Chromium 决定。不要做端口转发或内网穿透。
103
103
  - 端口被占用时换一个,或 `--remote-debugging-port=0` 让 Chromium 自选。
104
104
  - 不要设 `--user-data-dir`,客户端会用 `app.setPath` 覆盖它,白设。
105
105
 
106
106
  ### 成功的判据
107
107
 
108
- 启动后 stderr 出现这一行才算成功:
109
-
110
- ```text
111
- DevTools listening on ws://127.0.0.1:<port>/devtools/browser/<uuid>
112
- ```
113
-
114
- 没有这一行就是没开成,回「故障排查」。
108
+ 先在系统监听表确认调试端口属于刚启动的客户端,且全部监听地址都是回环(例如 `127.0.0.1` 或 `::1`)。发现 `0.0.0.0`、`::` 或其他非回环地址时,停止本次调试会话。再用 `lceda-connect cdp endpoint --port 9222` 确认端点可用;若改用了其他端口,请同时替换命令中的端口。
115
109
 
116
110
  ## 第二步:发现端点与看清结构
117
111
 
@@ -6,9 +6,11 @@
6
6
  - 提交:`9720f0802793d4e79aebd5374565419b8f1057e1`
7
7
  - 归属:自有内容在本项目中统一采用 GPL-3.0-only,不作为外部致谢,不另设源仓库旧许可约束。这里仅记录技术来源与移植映射。
8
8
 
9
- ## 原样收进 assets 的文件
9
+ ## 收进 assets 的文件
10
10
 
11
- 根目录 `SKILL.md` 与 `references/` 下全部 17 个文件(16 篇 Markdown 加 `menu-catalog.json`)从源仓库原样复制,没有改内容。源仓库的 `notes/`、`docs/`、`tests/`、`tools/`、`scripts/`、`out/` 不在本目录内。
11
+ 根目录 `SKILL.md` 与 `references/` 下全部 17 个文件(16 篇 Markdown 加 `menu-catalog.json`)最初从源仓库原样复制。源仓库的 `notes/`、`docs/`、`tests/`、`tools/`、`scripts/`、`out/` 不在本目录内。
12
+
13
+ 本地为兼容嘉立创 EDA 4.1.105 调整了 `SKILL.md`、`references/setup-guide.md` 和 `references/restart-and-relaunch.md` 中的 CDP 启动说明:移除地址参数,对齐本仓库的 CLI 传参,并区分端点探测与系统监听表核验。上方提交仍是原始来源。
12
14
 
13
15
  `references/api-contract.md` 的 §3.4(求值上下文)、§3.5(文档切换)、§6.9(编辑器状态与模态框句柄)是 `src/cdp/eval.ts`、`src/cdp/docs.ts`、`src/cdp/board.ts` 的语义依据,文档保留原文以便回溯。
14
16
 
@@ -51,9 +51,9 @@
51
51
 
52
52
  推论,直接决定启动脚本怎么排参数:
53
53
 
54
- - **`--remote-debugging-port` 必须排在第一个。** 排第一,清理缓存那条通道也能把端口带过去;排在后面就丢了。`assets/launcher/lceda-cdp.ps1.tmpl` 里参数数组的第一位就是它,**不要重排**。
55
- - `--remote-debugging-address` 在清理缓存通道里会丢。无害:Chromium 的默认绑地址就是 `127.0.0.1`,而且本 skill 只允许绑回环。
56
- - `-ProxyServer` 显式指定的代理在清理缓存通道里也会丢。重启后客户端回到「按系统代理走」,与脚本默认行为一致。
54
+ - **`--remote-debugging-port` 必须排在第一个。** 排第一,清理缓存那条通道也能把端口带过去;排在后面就丢了。`lceda-connect cdp start` 按这个顺序传参。
55
+ - 不要传 `--remote-debugging-address`:部分客户端版本不识别它。实际监听地址由 Chromium 决定,启动后要在系统监听表确认只监听回环。
56
+ - 用 `--proxy-server` 显式指定的代理参数在清理缓存通道里会丢。重启后客户端回到「按系统代理走」,与 CLI 默认行为一致。
57
57
  - **升级安装后参数全丢。** 升级完必须重新 `start`,`ensure` 也会如实报「进程在跑但没带端口」。
58
58
 
59
59
  关于「Electron 默认 `args = process.argv.slice(1)`」这一句:它是 Electron `app.relaunch()` 的文档语义,属于**静态依据**,本文没有在真机上逐条复跑。要自己验证,按第六节做一次改运行模式的重启,重启后看 `status` 里还有没有端口与 pid 变化。
@@ -77,7 +77,7 @@
77
77
  - 用途:真正承载调试能力的本地 HTTP + WebSocket 服务,由客户端启动时开启。
78
78
  - 下载地址:不需要——这不是要安装的东西,是客户端进程内建的服务。
79
79
  - 登录 / 凭据:不需要。
80
- - 权限:仅回环,`127.0.0.1`,禁止 `0.0.0.0`、端口转发、内网穿透。
80
+ - 安全要求:只接受回环监听(例如 `127.0.0.1` 或 `::1`)。禁止非回环监听、端口转发和内网穿透。
81
81
 
82
82
  ### 配置步骤
83
83
 
@@ -85,11 +85,11 @@
85
85
  2. 带参数启动:
86
86
 
87
87
  ```powershell
88
- & "<安装目录>\lceda-pro.exe" --remote-debugging-port=9222 --remote-debugging-address=127.0.0.1
88
+ & "<安装目录>\lceda-pro.exe" --remote-debugging-port=9222
89
89
  ```
90
90
 
91
- 3. 观察 stderr 是否出现 `DevTools listening on ws://127.0.0.1:<port>/devtools/browser/<uuid>`。
92
- 4. 运行 `python scripts/lceda_cdp.py discover` 确认端点与 uuid 归属。
91
+ 3. 不要附加部分客户端版本不识别的 `--remote-debugging-address`。用系统监听表(Windows 可用 `Get-NetTCPConnection -LocalPort 9222 -State Listen`)核对进程归属,并确认该端口没有非回环监听;有则停止该调试会话。
92
+ 4. 用 `lceda-connect cdp endpoint --port 9222` 检查端点是否可用。连通性检查不能替代第 3 步。
93
93
 
94
94
  不想每次手敲参数时,用 `python scripts/render_launcher.py --out-dir <目录>` 生成启停脚本,之后 `start` / `status` / `endpoint` / `stop` 四条命令搞定。脚本要由用户在自己的终端执行,详见 `launcher.md`。
95
95
 
@@ -105,11 +105,7 @@
105
105
 
106
106
  ### 验证方式
107
107
 
108
- ```bash
109
- python scripts/lceda_cdp.py discover --json
110
- ```
111
-
112
- `found` 为真即通过;判定依据是 `/json/version` 同时返回 `Browser` 与 `Protocol-Version`。
108
+ 系统监听表和 `cdp endpoint` 都通过,才算调试端口可用并满足回环要求。若使用动态端口,先从 `DevToolsActivePort` 确定端口,再核对监听进程。
113
109
 
114
110
  ### 撤销
115
111
 
@@ -1,6 +1,6 @@
1
1
  # easyeda-connect 编排层来源
2
2
 
3
- 本目录收录 `leonskill-easyeda-connect` 的知识文档与台账,文件内容原样保留:
3
+ 本目录收录 `leonskill-easyeda-connect` 的知识文档与台账,初次收录时原样保留:
4
4
 
5
5
  - 源仓库:<https://github.com/LeonhardtHUST/leonskill-easyeda-connect>
6
6
  - 提交:`9b2593061adef44c60c869b94666c19c59b52bd5`(`git -C <源仓库> rev-parse HEAD`)
@@ -8,6 +8,8 @@
8
8
  - 初次合并时源仓库存在未提交改动,涉及 bridge、窗口池和内部验收脚本;收录的文档与台账没有改动。2026-11-17 后续核查以本地工作树为准,相关源码已分组提交,当前源码 HEAD 为 `e025a54`。
9
9
  - `scripts/bridge_client.py` 的实时错误分类已同步到 `src/bridge/client.ts`:只有明确的 `ECONNREFUSED` 视为没有服务;连接重置、不可达、名称解析失败保留为未确认的协议/传输错误,超时单独报告。窗口池、身份绑定和 fixture 台账仍按下方边界保留在源仓库,不声称已移植。
10
10
 
11
+ 本地为兼容嘉立创 EDA 4.1.105 调整了 `references/setup-guide.md` 的 CDP 启动参数和回环监听核验说明。上方提交仍是原始来源。
12
+
11
13
  ## 收录文件
12
14
 
13
15
  | 文件 | 说明 |
@@ -64,9 +64,9 @@
64
64
  - 配置步骤:
65
65
  1. 安装专业版并完成激活,确认能进入编辑器。
66
66
  2. 走官方 API 通道:加载 bridge 扩展即可,无需重启。
67
- 3. 走视觉通道:彻底退出客户端(托盘退出不算),带 `--remote-debugging-port=9222 --remote-debugging-address=127.0.0.1` 启动;已运行的实例无法事后追加端口。
67
+ 3. 走视觉通道:彻底退出客户端(托盘退出不算),带 `--remote-debugging-port=9222` 启动;已运行的实例无法事后追加端口。
68
68
  - 验证方式:自检的 `client-session` 为 `ready`(至少一条通道能看到客户端)。
69
- - 安全:不改安装文件、不注入进程、不打补丁;调试端口只绑回环,用完正常启动一次即关闭。
69
+ - 安全:不改安装文件、不注入进程、不打补丁。不要附加部分客户端版本不识别的 `--remote-debugging-address`;启动后在系统监听表确认调试端口只监听回环,发现非回环监听时停止该调试会话。
70
70
  - 轮换与撤销:正常重启客户端即撤销调试端口;卸载扩展即撤销 API 通道。
71
71
  - 核验日期:2026-11-02。
72
72
 
@@ -1,12 +1,12 @@
1
1
  import { a as parseArgs, i as numberValue, n as boolValue, o as stringValue, r as formatOptions, t as CliUsageError } from "./cliArgs-BI3bJgCZ.mjs";
2
2
  import { _ as asCdpError, a as defaultPortFromEnv, b as hr, d as profileLabel, f as requireLoopbackHost, g as CdpError, h as versionWebSocketUrl, m as versionBrowser, o as discover, p as resolveEndpoint, r as attributionOf, s as endpointUrl, u as parsePortRange, x as paint } from "./discover-D4ouuCrn.mjs";
3
- import { a as activeDocument, c as Board, d as pickPage, i as screenshotToFile, n as firstSideEffectPattern, o as listDocuments, r as hasSideEffects, s as openDocument } from "./sideEffects-B34zsl2C.mjs";
4
- import { a as CdpSession, d as redact, i as listTargets, l as evaluateInContext, n as flattenFrameTree, o as EvalUsageError, r as formatFrameTree, t as fetchFrameTree, u as planEval } from "./targets-DiGwICXT.mjs";
3
+ import { a as cdpInputActionSchema, c as listDocuments, i as screenshotToFile, l as openDocument, n as firstSideEffectPattern, o as sendCdpInput, p as pickPage, r as hasSideEffects, s as activeDocument, u as Board } from "./sideEffects-D33hMchc.mjs";
4
+ import { a as CdpSession, f as redact, i as listTargets, l as evaluateInContext, n as flattenFrameTree, o as EvalUsageError, r as formatFrameTree, t as fetchFrameTree, u as planEval } from "./targets-DYfgkrq3.mjs";
5
5
  // src/cdp/cli.ts
6
6
  /**
7
7
  * `lceda-connect cdp-client <动作>` 的实现(源仓库 lceda_cdp.py 的 CLI 部分)。
8
8
  *
9
- * 动作:discover / targets / frames / eval / shot / docs。
9
+ * 动作:discover / targets / frames / eval / shot / docs / input。
10
10
  * 只连回环地址;`eval` 默认拒绝有副作用的表达式。退出码沿用源仓库口径:
11
11
  * 0 成功 / 1 未找到或用法 / 2 端点或选页失败 / 3 拒绝(副作用、非回环)/ 4 协议错误。
12
12
  */
@@ -140,8 +140,150 @@ const ACTIONS = [
140
140
  "frames",
141
141
  "eval",
142
142
  "shot",
143
- "docs"
143
+ "docs",
144
+ "input"
144
145
  ];
146
+ const INPUT_OPTIONS = [
147
+ {
148
+ name: "port",
149
+ type: "string",
150
+ placeholder: "PORT",
151
+ description: "本机调试端口(必填,不自动发现)"
152
+ },
153
+ {
154
+ name: "target",
155
+ type: "string",
156
+ placeholder: "ID",
157
+ description: "精确 page target ID(必填)"
158
+ },
159
+ {
160
+ name: "document",
161
+ type: "string",
162
+ placeholder: "UUID",
163
+ description: "当前 PCB 文档 UUID(必填)"
164
+ },
165
+ {
166
+ name: "confirm",
167
+ type: "boolean",
168
+ description: "确认派发到指定 PCB 页面,可能改动工程"
169
+ },
170
+ {
171
+ name: "x",
172
+ type: "string",
173
+ placeholder: "X",
174
+ description: "顶层页面视口 CSS 像素坐标"
175
+ },
176
+ {
177
+ name: "y",
178
+ type: "string",
179
+ placeholder: "Y",
180
+ description: "顶层页面视口 CSS 像素坐标"
181
+ },
182
+ {
183
+ name: "button",
184
+ type: "string",
185
+ placeholder: "left|right",
186
+ description: "鼠标键(默认 left)"
187
+ },
188
+ {
189
+ name: "click-count",
190
+ type: "string",
191
+ placeholder: "1|2",
192
+ description: "点击次数(默认 1)"
193
+ },
194
+ {
195
+ name: "key",
196
+ type: "string",
197
+ placeholder: "KEY",
198
+ description: "Escape / Enter / Tab / ArrowUp / ArrowDown / ArrowLeft / ArrowRight / Backspace"
199
+ },
200
+ {
201
+ name: "text",
202
+ type: "string",
203
+ placeholder: "TEXT",
204
+ description: "插入到当前获得焦点的可编辑控件"
205
+ },
206
+ {
207
+ name: "json",
208
+ type: "boolean",
209
+ description: "以 JSON 输出"
210
+ }
211
+ ];
212
+ const INPUT_ACTION_OPTIONS = {
213
+ click: [
214
+ "x",
215
+ "y",
216
+ "button",
217
+ "click-count"
218
+ ],
219
+ key: ["key"],
220
+ text: ["text"]
221
+ };
222
+ const INPUT_COMMON = /* @__PURE__ */ new Set([
223
+ "port",
224
+ "target",
225
+ "document",
226
+ "confirm",
227
+ "json"
228
+ ]);
229
+ function inputHelp(io) {
230
+ io.out("用法: lceda-connect cdp input <click|key|text> --port PORT --target ID --document UUID --confirm [选项]");
231
+ io.out("仅向指定 PCB 页面派发;不会启动客户端、拉前台或使用系统键鼠。响应只确认 CDP 收到事件。");
232
+ for (const line of formatOptions(INPUT_OPTIONS)) io.out(line);
233
+ }
234
+ async function cmdInput(argv, io) {
235
+ if (argv.length === 0 || argv[0] === "help" || argv[0] === "--help" || argv[0] === "-h") {
236
+ inputHelp(io);
237
+ return 0;
238
+ }
239
+ let json = false;
240
+ try {
241
+ const parsed = parseArgs(argv, INPUT_OPTIONS);
242
+ json = boolValue(parsed, "json");
243
+ const kind = parsed.positionals[0];
244
+ if (parsed.positionals.length !== 1 || kind !== "click" && kind !== "key" && kind !== "text") throw new CliUsageError("input 需要且只接受一个动作:click / key / text");
245
+ const allowed = INPUT_ACTION_OPTIONS[kind];
246
+ for (const flag of Object.keys(parsed.values)) if (!INPUT_COMMON.has(flag) && !allowed.includes(flag)) throw new CliUsageError(`input ${kind} 不接受 --${flag}`);
247
+ const port = stringValue(parsed, "port");
248
+ const target = stringValue(parsed, "target");
249
+ const documentUuid = stringValue(parsed, "document");
250
+ if (!port || !/^\d{1,5}$/.test(port) || !target || !documentUuid) throw new CliUsageError("input 必须显式提供 --port(整数)、--target 和 --document");
251
+ const decimal = (name) => {
252
+ const value = stringValue(parsed, name);
253
+ return value && /^\d+(?:\.\d+)?$/.test(value) ? Number(value) : NaN;
254
+ };
255
+ const count = stringValue(parsed, "click-count");
256
+ const action = cdpInputActionSchema.safeParse(kind === "click" ? {
257
+ kind,
258
+ x: decimal("x"),
259
+ y: decimal("y"),
260
+ button: stringValue(parsed, "button"),
261
+ clickCount: count === void 0 ? void 0 : count === "1" ? 1 : count === "2" ? 2 : NaN
262
+ } : kind === "key" ? {
263
+ kind,
264
+ key: stringValue(parsed, "key")
265
+ } : {
266
+ kind,
267
+ text: stringValue(parsed, "text")
268
+ });
269
+ if (!action.success) throw new CliUsageError("input 动作参数不合法;请查看 cdp input --help");
270
+ const result = await sendCdpInput({
271
+ port: Number(port),
272
+ target,
273
+ documentUuid,
274
+ confirm: boolValue(parsed, "confirm"),
275
+ action: action.data
276
+ });
277
+ if (json) emitJson(io, {
278
+ ok: true,
279
+ ...result
280
+ });
281
+ else io.out(`CDP 已确认 ${result.dispatched} 个事件;请另行回读编辑器操作结果。`);
282
+ return 0;
283
+ } catch (error) {
284
+ return reportError(io, error instanceof CliUsageError ? new CdpError("CDP_INPUT_INVALID", error.message, { exitCode: 1 }) : error, json);
285
+ }
286
+ }
145
287
  function cdpClientHelp() {
146
288
  return [
147
289
  "",
@@ -156,6 +298,7 @@ function cdpClientHelp() {
156
298
  " eval 在页面里执行 JS(默认只读)",
157
299
  " shot 截取当前页面可视区",
158
300
  " docs 文档列表 / 当前文档 / 打开文档",
301
+ " input 向指定 PCB 页面派发输入(input --help)",
159
302
  " help 这个帮助",
160
303
  "",
161
304
  paint.white(" 通用选项:"),
@@ -502,6 +645,7 @@ async function cmdDocs(rest, parsed, io, host, port, env, json) {
502
645
  }
503
646
  async function runCdpClientCommand(argv, io, env) {
504
647
  const first = argv[0]?.toLowerCase();
648
+ if (first === "input") return await cmdInput(argv.slice(1), io);
505
649
  if (argv.length === 0 || first === "help" || first === "-h" || first === "--help") {
506
650
  printHelp(io);
507
651
  return 0;
@@ -1,6 +1,6 @@
1
1
  import { a as parseArgs, i as numberValue, n as boolValue, o as stringValue, r as formatOptions, t as CliUsageError } from "./cliArgs-BI3bJgCZ.mjs";
2
2
  import { T as loadConfig, b as hr, x as paint } from "./discover-D4ouuCrn.mjs";
3
- import { a as routeNets, c as EdaVerbError, d as capabilitySummary, f as lookupCapability, i as readBoardState, l as createDefaultExecContext, n as docInfo, o as routeNetsPreview, r as evalApi, s as runDrc, t as boardDigestState, u as checkEnvironment } from "./verbs-CcrO8f9q.mjs";
3
+ import { a as routeNets, c as EdaVerbError, d as capabilitySummary, f as lookupCapability, i as readBoardState, l as createDefaultExecContext, n as docInfo, o as routeNetsPreview, r as evalApi, s as runDrc, t as boardDigestState, u as checkEnvironment } from "./verbs-CD4ZM9Es.mjs";
4
4
  import { readFileSync } from "node:fs";
5
5
  // src/eda/cli.ts
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as main } from "./main-D4XmxX8M.mjs";
2
+ import { t as main } from "./main-CzMqMptH.mjs";
3
3
  // src/cli-bridge.ts
4
4
  process.exitCode = await main({
5
5
  argv: process.argv.slice(2),
package/dist/cli-cdp.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as main } from "./main-D4XmxX8M.mjs";
2
+ import { t as main } from "./main-CzMqMptH.mjs";
3
3
  // src/cli-cdp.ts
4
4
  process.exitCode = await main({
5
5
  argv: process.argv.slice(2),
package/dist/cli-mcp.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as main } from "./main-D4XmxX8M.mjs";
2
+ import { t as main } from "./main-CzMqMptH.mjs";
3
3
  // src/cli-mcp.ts
4
4
  process.exitCode = await main({ argv: ["mcp", ...process.argv.slice(2)] });
5
5
  export {};
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as main } from "./main-D4XmxX8M.mjs";
2
+ import { t as main } from "./main-CzMqMptH.mjs";
3
3
  // src/cli.ts
4
4
  process.exitCode = await main({ argv: process.argv.slice(2) });
5
5
  export {};
package/dist/index.d.mts CHANGED
@@ -6,6 +6,7 @@ export declare const DEFAULT_CDP_PORT = 9222;
6
6
  interface CdpConfig {
7
7
  exePath: string;
8
8
  port: number;
9
+ /** CLI 探测端点的回环地址,不控制客户端的监听地址。 */
9
10
  bindHost: string;
10
11
  runtimeDir: string;
11
12
  pidFile: string;
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.mjs";
2
2
  import { C as DEFAULT_PRO_EXE, S as DEFAULT_CDP_PORT, T as loadConfig } from "./discover-D4ouuCrn.mjs";
3
- import { n as runCdpAction, r as runBridgeAction, t as main } from "./main-D4XmxX8M.mjs";
3
+ import { n as runCdpAction, r as runBridgeAction, t as main } from "./main-CzMqMptH.mjs";
4
4
  import { t as packageVersion } from "./version-B39-elun.mjs";
5
5
  import { $ as docsOf, A as buildGeometry, B as buildDevices, C as compare, D as summarize, E as stripVolatile, F as padNetKey, G as num, H as buildSymbols, I as padNetMap, J as transformPin, K as placementOf, L as pcbDocs, M as componentMeta, N as formatNetlistCsv, O as MIL_TO_MM, P as naturalKey, Q as docTitle, R as polyPoints, S as VOLATILE_KEYS, T as diffRecords, U as componentType, V as buildFootprints, W as deviceUuidOf, X as attrMap, Y as valueLike, Z as docElements, _ as pointKey, _t as decodeMemberName, a as findFloating, at as pythonJson, b as renderReport, c as runSingle, ct as Project, d as writeText, dt as ZipError, et as flatMap, f as TOL, ft as crc32, g as pinKey, gt as cp437TextToBytes, h as pageToIr, ht as readZip, i as duplicateDesignators, it as parseRecords, j as buildNetlist, k as asId, l as slug, lt as ProjectError, m as onSegment, mt as looksLikeZip, n as checkConsistency, nt as makeRecordKey, o as inspectProject, ot as splitRecordKey, p as buildNets, pt as extractEntry, q as text, r as collect, rt as normId, s as runDiff, st as scalarText, t as analyzeSummary, tt as isPlainRecord, u as writeJson, ut as openProject, v as splitPinKey, w as diffNetlist, x as NOISE_TYPES, y as validate, z as rotate } from "./analyze-DBkWgG82.mjs";
6
6
  import { n as runEpro2Command, t as epro2Help } from "./cli-DphIx1EQ.mjs";
7
- import { C as epro2Tools, D as reportTool, E as pcbNetlistTool, O as schematicNetsTool, S as diffTool, T as pcbGeometryTool, _ as eprj3NetlistTool, a as metricsTool, b as eprj3ValidateTool, c as runTool, d as stackupTool, f as touchstoneTool, g as eprj3InspectTool, h as eprj3GatesTool, l as sidecarTool, m as eprj3EditTool, o as netlistTool, p as eprj3BuildTool, s as probeTool, t as allTools, u as simTools, v as eprj3ReadRecordsTool, w as inspectTool, x as crosscheckTool, y as eprj3Tools } from "./registry-D6ReiPB6.mjs";
7
+ import { C as epro2Tools, D as reportTool, E as pcbNetlistTool, O as schematicNetsTool, S as diffTool, T as pcbGeometryTool, _ as eprj3NetlistTool, a as metricsTool, b as eprj3ValidateTool, c as runTool, d as stackupTool, f as touchstoneTool, g as eprj3InspectTool, h as eprj3GatesTool, l as sidecarTool, m as eprj3EditTool, o as netlistTool, p as eprj3BuildTool, s as probeTool, t as allTools, u as simTools, v as eprj3ReadRecordsTool, w as inspectTool, x as crosscheckTool, y as eprj3Tools } from "./registry-DaqVJuvF.mjs";
8
8
  import { n as runEprj3Command, t as eprj3HelpLines } from "./cli-ZuAl89m5.mjs";
9
9
  import { $ as stripBom, A as findIndexFile, B as formatRecord, C as round, D as documentFiles, E as describeDocumentFile, F as resolveProjectPath, G as readDocumentFile, H as metaOf, I as schematicDir, J as readTextBomSafe, K as readLines, L as sheetFile, M as loadEprj3Project, N as panelFile, O as ecfgFile, P as pcbFile, Q as splitDocumentLines, R as clientIdFrom, S as rotate$1, T as Eprj3ProjectError, U as normalizeRecordId, V as isDocHeadLine, W as parseRecord, X as reduceKey, Y as reduceDocSection, Z as reduceRecords, _ as parseSymbolEntry, a as EPRJ3_SCRIPTS, b as pointSegDist, c as eprj3ScriptsDir, d as isEprj3ScriptName, f as listEprj3Scripts, g as netlistProject, h as netKey, i as EPRJ3_GATE_NAMES, j as inspectEprj3Project, k as evarFile, l as eprj3SidecarDir, m as runEprj3Script, n as EPRJ3_EDIT_OPS, o as EPRJ3_SIDECAR_TIMEOUT_MS, p as resolveEprj3ScriptPath, q as readRecords, r as EPRJ3_GATES, s as eprj3GateArgs, t as validateEprj3Project, u as isEprj3EditOp, v as pcbNetlist, w as sheetNetlist, x as readSheet, y as pinTip, z as docTypeNumber } from "./validate-COx5r3o4.mjs";
10
10
  import { _ as loadSchema, a as validateOuter, b as applyRelaxations, c as validateSchema, d as hasSchema, f as isKnownDocType, g as loadRegistry, h as loadOuterSchema, i as validateLine, l as clearFormatCaches, m as knownDocTypes, n as parseRecordLine, o as describeValue, p as isRegisteredPair, r as validateFormat, s as typeOfValue, t as RecordParseError, u as formatAssetsRoot, v as resolveSchemaKey, x as relaxationRules, y as schemaRelativePath } from "./record-CHXWiMWA.mjs";
11
11
  import { a as getPrimitive, i as getFormatLog, n as getDocument, o as listTypes, r as getExample, s as schemaAssetPath, t as formatAssetsPresent } from "./knowledge-CX8Hrnoe.mjs";
12
12
  import { n as simHelp, t as runSimCommand } from "./cli-BegYbK44.mjs";
13
13
  import { $ as parseRawBuffer, $t as ROLE_VOCAB, A as listSimSidecarScripts, At as generateNetlist, B as fidelityLines, Bt as fmt, C as stackupSummaryLines, Cn as SimError, Ct as pinNetTableOf, D as viaParasitics, Dt as NetlistBuilder, E as traceSummaryLine, Et as validateIr, F as simSidecarDir, Ft as ParasiticError, G as DECK_DEFAULT_ARGS, Gt as resistor, H as manifestSummaryLines, Ht as formatSignificant, I as readNetlistFile, It as capacitor, J as cleanNetlist, Jt as transmissionLine, K as DeckError, Kt as seriesChain, L as runSimulation, Lt as capacitorModel, M as pythonCandidates, Mt as parseVoltage, N as resolveSimSidecarScript, Nt as sanitizeDes, O as viaSummaryLine, Ot as buildPinNetTable, P as runSimSidecar, Pt as NetCtx, Q as parseRawBinary, Qt as ModelResolver, R as LEVEL_NAMES, Rt as connectorModel, S as stackupFileExists, Sn as spiceNode, St as normalizeIr, T as traceParams, Tt as saveSimIr, U as ngspiceVersion, Ut as inductor, V as fileHash, Vt as fmtTime, W as writeManifest, Wt as parseEng, X as RawParseError, Xt as waveformText, Y as hasControlBlock, Yt as viaModel, Z as parseRawAscii, Zt as MappingError, _ as VIA_FIDELITY, _n as resolvePath, _t as cleanValue, a as loadTouchstoneOrNone, an as GroundMapError, at as metricSummaryLine, b as estimateVias, bn as simSkillDocsDir, bt as loadSimIr, c as touchstoneMetrics, cn as Namer, ct as NgspiceError, d as DEFAULT_ANTIPAD_CLEARANCE_MM, dn as deepMerge, dt as ngspiceCandidates, en as parseModelNames, et as parseRawFile, f as ExtractError, fn as displayNode, ft as ngspiceExists, g as TRACE_FIDELITY, gn as quotePath, gt as runNgspiceBatch, h as StackupError, hn as loadSimConfig, ht as resolveExecutable, i as impedance1Port, in as GroundMap, it as findVar, j as probePython, jt as loadModelLibrary, k as SIDECAR_TIMEOUT_MS, kt as designatorPrefix, l as COPPER_RESISTIVITY, ln as SKILL_VERSION, lt as findNgspiceSync, m as Stackup, mn as loadJsonFile, mt as probeNgspice, n as TouchstoneError, nn as provenanceText, nt as MetricError, o as parseTouchstone, on as isGroundLike, ot as NGSPICE_PROBE_TIMEOUT_MS, p as PLATING_THICKNESS_MM, pn as isVirtual, pt as parseNgspiceVersion, q as buildDeck, qt as tdFromLength, r as dbOf, rn as DEFAULT_ZERO_NETS, rt as computeMetrics, s as touchstoneLoss, sn as DEFAULTS, st as NGSPICE_RUN_TIMEOUT_MS, t as Touchstone, tn as parseSubcktPins, tt as plotsToCsv, u as C_PS_PER_MM, un as VIRTUAL_PREFIXES, ut as getNgspiceVersion, v as estimateGeometryTrace, vn as simModelsDir, vt as fromEpro2File, w as striplineZ0, wn as asText, wt as roundCoord, x as microstripZ0, xn as spiceIdent, xt as newSimIr, y as estimateNetTrace, yn as simScriptsDir, yt as fromSchematicIr, z as buildManifest, zt as ferriteModel } from "./touchstone-DOhfmSNh.mjs";
14
- import { i as serveStdio, n as createServer } from "./server-C7NJHDXj.mjs";
14
+ import { i as serveStdio, n as createServer } from "./server-qYlcXfzp.mjs";
15
15
  import { n as defineTool, t as ToolError } from "./types-D5d7ZRYF.mjs";
16
16
  // src/epro2/index.ts
17
17
  var epro2_exports = /* @__PURE__ */ __exportAll({
@@ -1453,13 +1453,11 @@ function clearProxyEnvironment(env) {
1453
1453
  return cleared;
1454
1454
  }
1455
1455
  /**
1456
- * 拼启动参数。**顺序不可重排**:客户端内部有两条自重启路径,其中「清理缓存」那条
1457
- * 只把 process.argv[1] 传给新进程(app.js: spawn(process.argv[0], [process.argv[1], ...]))。
1458
- * 端口放第一位,自重启后才还能带上调试端口;绑地址与代理参数会被丢掉——绑地址默认
1459
- * 就是 127.0.0.1,代理参数只在显式指定 --proxy-server 时有差异。
1456
+ * 调试端口放在第一位,兼容只透传 process.argv[1] 的客户端重启路径。
1457
+ * 为兼容不识别 --remote-debugging-address 的客户端,监听地址交由 Chromium 默认处理。
1460
1458
  */
1461
- function buildStartArgs(port, bindHost, proxyServer) {
1462
- const args = [`--remote-debugging-port=${port}`, `--remote-debugging-address=${bindHost}`];
1459
+ function buildStartArgs(port, proxyServer) {
1460
+ const args = [`--remote-debugging-port=${port}`];
1463
1461
  if (proxyServer) args.push(`--proxy-server=${proxyServer}`);
1464
1462
  return args;
1465
1463
  }
@@ -1669,7 +1667,7 @@ async function runStart(options, ctx, label = "start") {
1669
1667
  for (const item of cleared) reporter.say(` ${item}`);
1670
1668
  }
1671
1669
  }
1672
- const startArgs = buildStartArgs(cfg.cdp.port, cfg.cdp.bindHost, options.proxyServer);
1670
+ const startArgs = buildStartArgs(cfg.cdp.port, options.proxyServer);
1673
1671
  let ready = await probeNetReady();
1674
1672
  if (!ready && options.waitOnlineSec > 0) {
1675
1673
  reporter.say(`网络未就绪,最多等 ${options.waitOnlineSec} 秒(先让代理 / 校园网连上)…`, paint.yellow);
@@ -2127,6 +2125,7 @@ function cdpHelp() {
2127
2125
  " eval 在编辑器页面里求值(默认拒绝有副作用的表达式)",
2128
2126
  " shot 截图落盘",
2129
2127
  " docs 文档列表 / 当前文档 / 打开文档",
2128
+ " input 向指定 PCB 页面派发输入;见 input --help",
2130
2129
  paint.gray(" (lceda-cdp eval --help 查看这些动作的详细参数)"),
2131
2130
  "",
2132
2131
  paint.white(" 选项:"),
@@ -2198,7 +2197,7 @@ const DOMAIN_GROUPS = [
2198
2197
  {
2199
2198
  name: "eda",
2200
2199
  summary: "编辑器动词:双通道自检、读板、DRC、板指纹、自动布线、动词台账检索",
2201
- load: async () => (await import("./cli-DSk_viv1.mjs")).runEdaCommand
2200
+ load: async () => (await import("./cli-BekOvZjB.mjs")).runEdaCommand
2202
2201
  },
2203
2202
  {
2204
2203
  name: "sim",
@@ -2213,7 +2212,8 @@ const CDP_CLIENT_ACTIONS = [
2213
2212
  "frames",
2214
2213
  "eval",
2215
2214
  "shot",
2216
- "docs"
2215
+ "docs",
2216
+ "input"
2217
2217
  ];
2218
2218
  /** bridge 命令组里由 bridge 客户端(src/bridge)处理的动作,其余仍归服务管理。 */
2219
2219
  const BRIDGE_CLIENT_ACTIONS = [
@@ -2272,7 +2272,7 @@ async function runMcpGroup(argv, io, env) {
2272
2272
  }
2273
2273
  const selected = toolsets ?? env.LCEDA_TOOLSETS;
2274
2274
  if (action === "tools") {
2275
- const { toolsForEnv } = await import("./registry-Bs3kpMhy.mjs");
2275
+ const { toolsForEnv } = await import("./registry-5K1G1XmC.mjs");
2276
2276
  try {
2277
2277
  for (const tool of toolsForEnv(env, selected)) io.out(`${paint.cyan(tool.name.padEnd(28))} ${tool.description.split("。")[0] ?? ""}`);
2278
2278
  return 0;
@@ -2282,7 +2282,7 @@ async function runMcpGroup(argv, io, env) {
2282
2282
  }
2283
2283
  }
2284
2284
  if (action === "serve") {
2285
- const { serveStdio } = await import("./server-s5NZcVym.mjs");
2285
+ const { serveStdio } = await import("./server-DNMAlzZJ.mjs");
2286
2286
  try {
2287
2287
  await serveStdio(env, selected);
2288
2288
  return 0;
@@ -2333,7 +2333,7 @@ async function main(options) {
2333
2333
  }
2334
2334
  const clientAction = tail[0]?.trim().toLowerCase() ?? "";
2335
2335
  if (group === "cdp" && CDP_CLIENT_ACTIONS.includes(clientAction)) {
2336
- const { runCdpClientCommand } = await import("./cli-DhHRbgp_.mjs");
2336
+ const { runCdpClientCommand } = await import("./cli-B3GGyoP_.mjs");
2337
2337
  return await runCdpClientCommand(tail, io, env);
2338
2338
  }
2339
2339
  if (group === "bridge" && BRIDGE_CLIENT_ACTIONS.includes(clientAction)) {
@@ -0,0 +1 @@
1
+ export { r as toolsForEnv } from "./registry-DaqVJuvF.mjs";
@@ -3,17 +3,17 @@ import { a as search, i as getFormatDoc, n as apiDocsAvailable, r as getEntry }
3
3
  import { a as requireConnected, i as execute, n as bridgeErrorHint, o as selectWindow, r as discover, s as windows, t as BridgeClientError } from "./client-_LVz5Zg0.mjs";
4
4
  import { t as packageVersion } from "./version-B39-elun.mjs";
5
5
  import { c as BRIDGE_MAX_CODE_BYTES, h as BRIDGE_SERVICE_ID } from "./protocol-B4UcGrGa.mjs";
6
- import { a as activeDocument, c as Board, i as screenshotToFile, l as detectState, o as listDocuments, s as openDocument, t as classifyEval, u as normalizeState } from "./sideEffects-B34zsl2C.mjs";
6
+ import { a as cdpInputActionSchema, c as listDocuments, d as detectState, f as normalizeState, i as screenshotToFile, l as openDocument, o as sendCdpInput, s as activeDocument, t as classifyEval, u as Board } from "./sideEffects-D33hMchc.mjs";
7
7
  import { _ as asCdpError, h as versionWebSocketUrl, m as versionBrowser, o as discover$1, p as resolveEndpoint, r as attributionOf, s as endpointUrl, u as parsePortRange } from "./discover-D4ouuCrn.mjs";
8
- import { d as redact, i as listTargets, l as evaluateInContext, u as planEval } from "./targets-DiGwICXT.mjs";
9
- import { a as routeNets, c as EdaVerbError, d as capabilitySummary, f as lookupCapability, i as readBoardState, l as createDefaultExecContext, n as docInfo, o as routeNetsPreview, r as evalApi, s as runDrc, t as boardDigestState, u as checkEnvironment } from "./verbs-CcrO8f9q.mjs";
8
+ import { f as redact, i as listTargets, l as evaluateInContext, u as planEval } from "./targets-DYfgkrq3.mjs";
9
+ import { a as routeNets, c as EdaVerbError, d as capabilitySummary, f as lookupCapability, i as readBoardState, l as createDefaultExecContext, n as docInfo, o as routeNetsPreview, r as evalApi, s as runDrc, t as boardDigestState, u as checkEnvironment } from "./verbs-CD4ZM9Es.mjs";
10
10
  import { C as compare, Ct as safeWriteText, D as summarize, St as safeWriteJson, c as runSingle, lt as ProjectError, n as checkConsistency, o as inspectProject, r as collect, s as runDiff, t as analyzeSummary, yt as ensureSafeOutputDir } from "./analyze-DBkWgG82.mjs";
11
11
  import { D as documentFiles, F as resolveProjectPath, G as readDocumentFile, M as loadEprj3Project, Y as reduceDocSection, g as netlistProject, i as EPRJ3_GATE_NAMES, j as inspectEprj3Project, m as runEprj3Script, n as EPRJ3_EDIT_OPS, r as EPRJ3_GATES, s as eprj3GateArgs, t as validateEprj3Project, u as isEprj3EditOp } from "./validate-COx5r3o4.mjs";
12
12
  import { a as getPrimitive, i as getFormatLog, o as listTypes, r as getExample } from "./knowledge-CX8Hrnoe.mjs";
13
13
  import { i as validateLine, r as validateFormat } from "./record-CHXWiMWA.mjs";
14
14
  import { A as listSimSidecarScripts, At as generateNetlist, Cn as SimError, D as viaParasitics, Et as validateIr, F as simSidecarDir, I as readNetlistFile, L as runSimulation, Ot as buildPinNetTable, P as runSimSidecar, T as traceParams, bt as loadSimIr, c as touchstoneMetrics, et as parseRawFile, hn as loadSimConfig, j as probePython, m as Stackup, mt as probeNgspice, o as parseTouchstone, rt as computeMetrics, tt as plotsToCsv, vt as fromEpro2File } from "./touchstone-DOhfmSNh.mjs";
15
15
  import { i as listAssetFiles, r as assetsDir, s as readAssetText, t as assetExists } from "./assets-D48xh-kr.mjs";
16
- import "./main-D4XmxX8M.mjs";
16
+ import "./main-CzMqMptH.mjs";
17
17
  import path from "node:path";
18
18
  import { existsSync, readFileSync } from "node:fs";
19
19
  import { z } from "zod";
@@ -1617,6 +1617,30 @@ const cdpUiStateTool = defineTool({
1617
1617
  }
1618
1618
  }
1619
1619
  });
1620
+ const cdpInputTool = defineTool({
1621
+ name: "cdp_input",
1622
+ description: "向本机指定 PCB 页面派发一次鼠标点击、有限按键或文本,不启动客户端或拉前台。仅在编辑器 API 不适用时使用;必须确认并指定端口、精确 target 和当前 PCB UUID。结果仅代表 CDP 确认,须另行回读实际效果;结果不确定时不要自动重试。",
1623
+ input: {
1624
+ port: z.number().int().min(1).max(65535),
1625
+ target: z.string().min(1).max(128).describe("cdp_targets 返回的精确页面 target ID"),
1626
+ documentUuid: z.string().min(1).max(128).describe("预期的当前 PCB 文档 UUID"),
1627
+ action: cdpInputActionSchema,
1628
+ confirm: z.boolean().optional()
1629
+ },
1630
+ annotations: {
1631
+ readOnlyHint: false,
1632
+ destructiveHint: true,
1633
+ idempotentHint: false,
1634
+ openWorldHint: false
1635
+ },
1636
+ handler: async (args, ctx) => {
1637
+ try {
1638
+ return await sendCdpInput(args, { signal: ctx.signal });
1639
+ } catch (error) {
1640
+ fail$1(error);
1641
+ }
1642
+ }
1643
+ });
1620
1644
  function parseScan(value) {
1621
1645
  if (!value) return void 0;
1622
1646
  const range = parsePortRange(value);
@@ -1632,7 +1656,8 @@ const cdpTools = [
1632
1656
  cdpDocListTool,
1633
1657
  cdpDocActiveTool,
1634
1658
  cdpDocOpenTool,
1635
- cdpUiStateTool
1659
+ cdpUiStateTool,
1660
+ cdpInputTool
1636
1661
  ];
1637
1662
  // src/eda/mcpTools.ts
1638
1663
  /**
@@ -0,0 +1 @@
1
+ export { i as serveStdio } from "./server-qYlcXfzp.mjs";
@@ -2,8 +2,8 @@ import { i as listAssetFiles, s as readAssetText } from "./assets-D48xh-kr.mjs";
2
2
  import { T as loadConfig } from "./discover-D4ouuCrn.mjs";
3
3
  import { bt as resolveMcpWritePath } from "./analyze-DBkWgG82.mjs";
4
4
  import { t as packageVersion } from "./version-B39-elun.mjs";
5
- import "./main-D4XmxX8M.mjs";
6
- import { i as toolsetsForTools, r as toolsForEnv } from "./registry-D6ReiPB6.mjs";
5
+ import "./main-CzMqMptH.mjs";
6
+ import { i as toolsetsForTools, r as toolsForEnv } from "./registry-DaqVJuvF.mjs";
7
7
  import { r as normalizeToolContext, t as ToolError } from "./types-D5d7ZRYF.mjs";
8
8
  import os from "node:os";
9
9
  import path from "node:path";