remnote-bridge 0.1.7 → 0.1.8
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 +30 -6
- package/dist/cli/commands/connect.js +31 -2
- package/dist/cli/commands/health.js +111 -1
- package/dist/cli/commands/setup.js +112 -0
- package/dist/cli/daemon/daemon.js +101 -20
- package/dist/cli/daemon/headless-browser.js +291 -0
- package/dist/cli/daemon/static-server.js +84 -0
- package/dist/cli/main.js +22 -6
- package/dist/cli/server/ws-server.js +62 -1
- package/dist/mcp/daemon-client.js +4 -1
- package/dist/mcp/instructions.js +52 -5
- package/dist/mcp/tools/infra-tools.js +39 -9
- package/package.json +5 -1
- package/remnote-plugin/dist/bridge-icon.svg +8 -0
- package/remnote-plugin/dist/bridge_widget-sandbox.js +65 -0
- package/remnote-plugin/dist/bridge_widget.js +65 -0
- package/remnote-plugin/dist/index-sandbox.css +591 -0
- package/remnote-plugin/dist/index-sandbox.js +64 -0
- package/remnote-plugin/dist/index.css +591 -0
- package/remnote-plugin/dist/index.html +9 -0
- package/remnote-plugin/dist/index.js +64 -0
- package/remnote-plugin/dist/manifest.json +22 -0
- package/skills/remnote-bridge/SKILL.md +48 -4
- package/skills/remnote-bridge/instructions/connect.md +40 -10
- package/skills/remnote-bridge/instructions/disconnect.md +1 -1
- package/skills/remnote-bridge/instructions/health.md +67 -1
- package/skills/remnote-bridge/instructions/overall.md +1 -1
- package/skills/remnote-bridge/instructions/setup.md +130 -0
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 基础设施工具:connect、disconnect、health
|
|
2
|
+
* 基础设施工具:setup、connect、disconnect、health
|
|
3
3
|
*/
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { callCli } from '../daemon-client.js';
|
|
6
6
|
export function registerInfraTools(server) {
|
|
7
7
|
// -------------------------------------------------------------------------
|
|
8
|
-
//
|
|
8
|
+
// setup
|
|
9
9
|
// -------------------------------------------------------------------------
|
|
10
10
|
server.addTool({
|
|
11
|
-
name: '
|
|
12
|
-
description: '
|
|
11
|
+
name: 'setup',
|
|
12
|
+
description: '启动 Chrome 浏览器让用户登录 RemNote,保存登录凭证到本地 profile。这是使用 headless 模式(connect --headless)的前置步骤。\n\n调用后 Chrome 窗口会弹出,你需要立即告知用户:"已打开 Chrome,请在浏览器中登录 RemNote,并在 RemNote 中配置 dev plugin URL(http://localhost:8080),完成后用 Cmd+Q(macOS)或关闭窗口彻底退出 Chrome"。此工具会阻塞等待用户关闭 Chrome 后返回结果。\n\n幂等:已完成 setup 后重复调用返回 alreadyDone: true。\n超时:600 秒(用户可能需要较长时间完成登录、2FA 验证等)。\n前置条件:需要桌面环境(GUI),无 GUI 环境会报错。\n关联工具:connect(启动会话,传 headless 参数实现无人值守连接)',
|
|
13
13
|
parameters: z.object({}),
|
|
14
14
|
execute: async () => {
|
|
15
|
-
const response = await callCli('
|
|
15
|
+
const response = await callCli('setup', undefined, { timeoutMs: 600_000 });
|
|
16
|
+
return JSON.stringify(response, null, 2);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// -------------------------------------------------------------------------
|
|
20
|
+
// connect
|
|
21
|
+
// -------------------------------------------------------------------------
|
|
22
|
+
server.addTool({
|
|
23
|
+
name: 'connect',
|
|
24
|
+
description: '启动守护进程(daemon),建立 CLI 与 RemNote Plugin 之间的通信通道。这是所有业务命令(read_rem、edit_rem、search 等)的前置步骤。\n\n适用场景:\n- 开始一次 RemNote 操作会话前,必须先调用此工具\n- 不确定 daemon 是否在运行时,也可安全调用(幂等)\n\n两种模式:\n- 标准模式(默认):启动 daemon 后需要用户在 RemNote 中手动加载 Plugin\n- Headless 模式(headless=true):自动启动 headless Chrome 加载 Plugin,无需用户操作。需先完成 setup(保存登录凭证)\n\n输出:返回 JSON,关键字段 ok、alreadyRunning(是否已运行)、pid、wsPort、headless。\n幂等:重复调用不会启动多个 daemon。daemon 默认 30 分钟无活动自动关闭。\n关联工具:setup(headless 前置)、disconnect(结束会话)、health(检查状态)',
|
|
25
|
+
parameters: z.object({
|
|
26
|
+
headless: z.boolean().optional().describe('启用 headless 模式:自动启动 Chrome 加载 Plugin(需先 setup)'),
|
|
27
|
+
}),
|
|
28
|
+
execute: async (args) => {
|
|
29
|
+
const flags = [];
|
|
30
|
+
if (args.headless)
|
|
31
|
+
flags.push('--headless');
|
|
32
|
+
const response = await callCli('connect', undefined, {
|
|
33
|
+
timeoutMs: 90_000,
|
|
34
|
+
flags: flags.length > 0 ? flags : undefined,
|
|
35
|
+
});
|
|
16
36
|
return JSON.stringify(response, null, 2);
|
|
17
37
|
},
|
|
18
38
|
});
|
|
@@ -33,10 +53,20 @@ export function registerInfraTools(server) {
|
|
|
33
53
|
// -------------------------------------------------------------------------
|
|
34
54
|
server.addTool({
|
|
35
55
|
name: 'health',
|
|
36
|
-
description: '检查系统三层状态(daemon 守护进程 / Plugin 连接 / SDK 就绪),用于诊断连接问题。\n\n适用场景:\n- 业务命令失败时,首先调用 health 定位故障层级\n- 执行 connect 后确认通道是否完全就绪\n- 长时间未操作后,检查 daemon 是否仍在运行\n\n输出:返回 JSON,关键字段 ok(三层是否全部健康)、daemon.running、plugin.connected、sdk.ready、timeoutRemaining
|
|
37
|
-
parameters: z.object({
|
|
38
|
-
|
|
39
|
-
|
|
56
|
+
description: '检查系统三层状态(daemon 守护进程 / Plugin 连接 / SDK 就绪),用于诊断连接问题。\n\n适用场景:\n- 业务命令失败时,首先调用 health 定位故障层级\n- 执行 connect 后确认通道是否完全就绪\n- 长时间未操作后,检查 daemon 是否仍在运行\n\n输出:返回 JSON,关键字段 ok(三层是否全部健康)、daemon.running、plugin.connected、sdk.ready、timeoutRemaining。headless 模式下额外包含 headless 对象。\n三层有严格依赖:daemon 运行 → Plugin 连接 → SDK 就绪。\nok 为 false 时:daemon 未运行则 connect;Plugin 未连接则确认 RemNote 已打开(或使用 headless 模式);SDK 未就绪则等待重试。\n\n--diagnose 模式(headless 专用):截图 + 详细状态 + console 错误 + 排查建议。\n--reload 模式(headless 专用):重载 headless Chrome 页面。\n\n只读不写,不改变任何状态(--reload 除外)。\n关联工具:connect(启动)、disconnect(结束)',
|
|
57
|
+
parameters: z.object({
|
|
58
|
+
diagnose: z.boolean().optional().describe('诊断 headless Chrome(截图 + 状态 + console 错误)'),
|
|
59
|
+
reload: z.boolean().optional().describe('重载 headless Chrome 页面'),
|
|
60
|
+
}),
|
|
61
|
+
execute: async (args) => {
|
|
62
|
+
const flags = [];
|
|
63
|
+
if (args.diagnose)
|
|
64
|
+
flags.push('--diagnose');
|
|
65
|
+
if (args.reload)
|
|
66
|
+
flags.push('--reload');
|
|
67
|
+
const response = await callCli('health', undefined, {
|
|
68
|
+
flags: flags.length > 0 ? flags : undefined,
|
|
69
|
+
});
|
|
40
70
|
return JSON.stringify(response, null, 2);
|
|
41
71
|
},
|
|
42
72
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remnote-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "RemNote 自动化桥接工具集:CLI + MCP Server + Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/**/*.js",
|
|
12
|
+
"remnote-plugin/dist/",
|
|
12
13
|
"remnote-plugin/src/bridge/",
|
|
13
14
|
"remnote-plugin/src/services/",
|
|
14
15
|
"remnote-plugin/src/utils/",
|
|
@@ -27,12 +28,15 @@
|
|
|
27
28
|
],
|
|
28
29
|
"scripts": {
|
|
29
30
|
"build": "tsc",
|
|
31
|
+
"build:plugin": "cd remnote-plugin && npm install && npm run build",
|
|
32
|
+
"prepublishOnly": "npm run build && npm run build:plugin",
|
|
30
33
|
"dev": "tsx src/cli/main.ts",
|
|
31
34
|
"test": "vitest run",
|
|
32
35
|
"lint:deps": "node scripts/check-layer-deps.cjs"
|
|
33
36
|
},
|
|
34
37
|
"dependencies": {
|
|
35
38
|
"commander": "^12.1.0",
|
|
39
|
+
"puppeteer-core": "^24.0.0",
|
|
36
40
|
"ws": "^8.16.0",
|
|
37
41
|
"fastmcp": "latest",
|
|
38
42
|
"zod": "^3.23.0"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<!-- Bidirectional arrows -->
|
|
3
|
+
<path d="M3 8 L9 8 M7 6 L9 8 L7 10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
4
|
+
<path d="M21 8 L15 8 M17 6 L15 8 L17 10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
5
|
+
|
|
6
|
+
<!-- MCP text -->
|
|
7
|
+
<text x="12" y="19" text-anchor="middle" font-size="7" fill="currentColor" font-weight="700" font-family="system-ui, -apple-system, sans-serif">MCP</text>
|
|
8
|
+
</svg>
|