n2n-nexus 0.12.2 → 0.12.3
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 +17 -0
- package/build/client/discovery.js +12 -2
- package/build/client/nexus-client.js +7 -1
- package/build/server/instance-id.js +3 -1
- package/docs/CHANGELOG_zh.md +17 -0
- package/docs/INSTALL.md +1 -1
- package/docs/INSTALL_zh.md +1 -1
- package/docs/TOOLS_REFERENCE.md +1 -1
- package/docs/TOOLS_REFERENCE_zh.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
|
|
7
|
+
## [0.12.3] - 2026-10-29
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- A session whose Stop event was lost (the host was down or restarting when its turn ended) goes stale after 30 minutes like any other: the background wait no longer counts as its activity while it is working, so it stops being reported as working and messages sent to it stop waiting for a wake that never comes.
|
|
12
|
+
- A host bound to a name (`--host mybox`) accepts requests addressed by that name: its own health probes, the tray and `service install` no longer get 403 and report that nothing answers.
|
|
13
|
+
- Profile texts (`set_profile` title, note and label), the title a client reports, the host name, the WSL distribution and the working directory are stored on one line: line breaks and Unicode line separators in them can no longer forge a message's framing lines in another session's notification.
|
|
14
|
+
- A member that joins a meeting again after `leave_meeting` starts from the newest message, as documented, instead of being refused its first post for the messages it missed.
|
|
15
|
+
- A database written by an older host whose migrations fail now says to delete `nexus.db` when the CHANGELOG of the release says to reset the data directory, instead of a bare SQL error.
|
|
16
|
+
- The client survives an endpoint that is not an n2n-nexus host: an error status with a non-object body no longer crashes the hook or the MCP adapter, a tool list that is not a list leaves the adapter unconnected (it retries) instead of half-connected, and a tool call answered with a non-object body fails as a transport error. The discovery cache is written through a temporary file and renamed into place, so a concurrent hook never reads a partial URL.
|
|
17
|
+
- On Windows, upgrading through `install` restarts the background service with its data directory intact when that directory ends in a backslash and contains a space.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- The Windows firewall rules added by **Allow LAN access** apply to private and domain networks only, not to public ones. Rules added by an earlier version are not changed until LAN access is turned off and on again.
|
|
22
|
+
- On WSL, the MCP adapter's instance ID includes the distribution, since distributions on one Windows machine share its host name; two distributions on the same workspace no longer share chat and meeting read cursors. The ID changes once for WSL users, which resets those cursors (not the hooks' per-conversation ones).
|
|
23
|
+
|
|
7
24
|
## [0.12.2] - 2026-10-29
|
|
8
25
|
|
|
9
26
|
### Changed
|
|
@@ -120,8 +120,18 @@ export async function resolveEndpoint(configured, options = {}) {
|
|
|
120
120
|
return cached.endpoint;
|
|
121
121
|
const endpoint = await discoverEndpoint() ?? LOCAL_ENDPOINT;
|
|
122
122
|
try {
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
// Written next to the file and renamed over it: a hook reading it at the same time never sees a partial URL.
|
|
124
|
+
const target = cacheFile();
|
|
125
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
126
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
127
|
+
fs.writeFileSync(tmp, endpoint + "\n");
|
|
128
|
+
try {
|
|
129
|
+
fs.renameSync(tmp, target);
|
|
130
|
+
}
|
|
131
|
+
catch (e) {
|
|
132
|
+
fs.rmSync(tmp, { force: true });
|
|
133
|
+
throw e;
|
|
134
|
+
}
|
|
125
135
|
}
|
|
126
136
|
catch { /* caching is best effort */ }
|
|
127
137
|
return endpoint;
|
|
@@ -68,7 +68,9 @@ export class NexusClient {
|
|
|
68
68
|
}
|
|
69
69
|
const status = res.statusCode ?? 0;
|
|
70
70
|
if (status >= 400) {
|
|
71
|
-
|
|
71
|
+
// The body may be any JSON value (null, a number, ...): only an object carries an error text.
|
|
72
|
+
const error = typeof parsed === "object" && parsed !== null ? parsed.error : undefined;
|
|
73
|
+
reject(new NexusToolError(typeof error === "string" && error ? error : `HTTP ${status}`, status));
|
|
72
74
|
}
|
|
73
75
|
else {
|
|
74
76
|
resolve(parsed);
|
|
@@ -88,6 +90,8 @@ export class NexusClient {
|
|
|
88
90
|
}
|
|
89
91
|
async fetchTools() {
|
|
90
92
|
const res = await this.request("GET", "/api/tools");
|
|
93
|
+
if (typeof res !== "object" || res === null || !Array.isArray(res.tools))
|
|
94
|
+
throw new NexusTransportError("Invalid tools response from n2n-nexus-host");
|
|
91
95
|
return res.tools;
|
|
92
96
|
}
|
|
93
97
|
/** Forward a client hook event; `timeoutMs` overrides the client timeout (a listening Stop waits long). */
|
|
@@ -96,6 +100,8 @@ export class NexusClient {
|
|
|
96
100
|
}
|
|
97
101
|
async callTool(name, args, instanceId, caller) {
|
|
98
102
|
const res = await this.request("POST", "/api/tools/call", { tool: name, args: args || {}, ...(instanceId ? { instanceId } : {}), ...(caller ? { caller } : {}) });
|
|
103
|
+
if (!res || typeof res !== "object")
|
|
104
|
+
throw new NexusTransportError("Invalid tool call response from n2n-nexus-host");
|
|
99
105
|
if (!res.ok)
|
|
100
106
|
throw new NexusToolError(res.error || "Tool call failed", 200);
|
|
101
107
|
return res.result;
|
|
@@ -6,6 +6,8 @@ import os from "node:os";
|
|
|
6
6
|
* survive an IDE restart: derive it from the machine, the workspace the IDE
|
|
7
7
|
* launched the adapter in and the IDE itself (two IDEs open on the same
|
|
8
8
|
* workspace must not share cursors), unless the user pins one explicitly.
|
|
9
|
+
* WSL distributions on one Windows machine share its host name, so the
|
|
10
|
+
* distribution goes into the workspace hash.
|
|
9
11
|
*/
|
|
10
12
|
export function resolveInstanceId(env = process.env, argv = process.argv, cwd = process.cwd(), clientName) {
|
|
11
13
|
if (env.NEXUS_INSTANCE_ID)
|
|
@@ -13,7 +15,7 @@ export function resolveInstanceId(env = process.env, argv = process.argv, cwd =
|
|
|
13
15
|
const idx = argv.indexOf("--id");
|
|
14
16
|
if (idx !== -1 && argv[idx + 1])
|
|
15
17
|
return argv[idx + 1];
|
|
16
|
-
const digest = createHash("sha1").update(cwd).digest("hex").slice(0, 8);
|
|
18
|
+
const digest = createHash("sha1").update(env.WSL_DISTRO_NAME ? `${env.WSL_DISTRO_NAME}\n${cwd}` : cwd).digest("hex").slice(0, 8);
|
|
17
19
|
const client = clientName ? `-${clientName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 24)}` : "";
|
|
18
20
|
return `mcp-${os.hostname()}-${digest}${client}`;
|
|
19
21
|
}
|
package/docs/CHANGELOG_zh.md
CHANGED
|
@@ -4,6 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
本项目的所有重大变更都将记录在此文件中。
|
|
6
6
|
|
|
7
|
+
## [0.12.3] - 2026-10-29
|
|
8
|
+
|
|
9
|
+
### 修复
|
|
10
|
+
|
|
11
|
+
- Stop 事件丢失的会话(回合结束时 host 正好关闭或重启)像其他会话一样 30 分钟后过期:后台等待在会话处于 working 时不再算作它的活动,于是它不再被报告为 working,发给它的消息也不再等待一个永远不会到来的唤醒。
|
|
12
|
+
- 绑定到名字的 host(`--host mybox`)接受以该名字寻址的请求:它自己的健康探测、托盘和 `service install` 不再得到 403、不再报告没有应答。
|
|
13
|
+
- 资料文本(`set_profile` 的 title、note、label)、客户端报告的标题、主机名、WSL 发行版名和工作目录都按单行存储:其中的换行和 Unicode 行分隔符不能再在其他会话的通知里伪造消息的框架行。
|
|
14
|
+
- `leave_meeting` 之后重新加入会议的成员按文档所说从最新消息开始,而不是因错过的消息被拒绝第一次发言。
|
|
15
|
+
- 旧版本 host 写的数据库迁移失败时,提示在该版本的 CHANGELOG 要求重置数据目录时删除 `nexus.db`,而不是只给一条 SQL 错误。
|
|
16
|
+
- 客户端能承受端点上不是 n2n-nexus host 的情况:错误状态加非对象响应体不再让 hook 或 MCP 适配器崩溃;工具列表不是列表时适配器保持未连接(继续重试)而不是半连接;工具调用得到非对象响应体时作为传输错误失败。发现缓存先写临时文件再改名到位,并发的 hook 不会读到半截 URL。
|
|
17
|
+
- Windows 上通过 `install` 升级时,数据目录以反斜杠结尾且含空格也能带着原数据目录重启后台服务。
|
|
18
|
+
|
|
19
|
+
### 变更
|
|
20
|
+
|
|
21
|
+
- **允许局域网访问**添加的 Windows 防火墙规则只对专用和域网络生效,不含公用网络。早先版本添加的规则在关闭再开启局域网访问之前不会改变。
|
|
22
|
+
- WSL 上 MCP 适配器的实例 ID 包含发行版名,因为同一台 Windows 上的发行版共用主机名;同一工作区的两个发行版不再共用聊天和会议的已读游标。WSL 用户的 ID 会变一次,这些游标随之重置(hooks 按对话记录的游标不受影响)。
|
|
23
|
+
|
|
7
24
|
## [0.12.2] - 2026-10-29
|
|
8
25
|
|
|
9
26
|
### 变更
|
package/docs/INSTALL.md
CHANGED
|
@@ -114,7 +114,7 @@ The adapter can start before the host. It loads the host's tool list once the ho
|
|
|
114
114
|
By default the host listens on `127.0.0.1` only. To make it the host for other machines on a trusted network:
|
|
115
115
|
|
|
116
116
|
1. On the host machine, turn LAN access on:
|
|
117
|
-
- Tray: check **Allow LAN access**. The tray writes `"host": "0.0.0.0"` to `settings.json` and restarts the host. On Windows it adds inbound firewall rules for the TCP port and the UDP discovery port (5688 and 5688 by default) after a UAC prompt; on macOS and Linux it tells you which ports to allow in your firewall.
|
|
117
|
+
- Tray: check **Allow LAN access**. The tray writes `"host": "0.0.0.0"` to `settings.json` and restarts the host. On Windows it adds inbound firewall rules for the TCP port and the UDP discovery port (5688 and 5688 by default) on private and domain networks, not public ones, after a UAC prompt; on macOS and Linux it tells you which ports to allow in your firewall.
|
|
118
118
|
- Service: `n2n-nexus-host service install --host 0.0.0.0` writes the address to `settings.json`; allow TCP 5688 and UDP 5688 in the firewall yourself.
|
|
119
119
|
2. On the other machines, install the client with `--endpoint discover` (for example `n2n-nexus install claude --endpoint discover`), or with the host's address.
|
|
120
120
|
|
package/docs/INSTALL_zh.md
CHANGED
|
@@ -114,7 +114,7 @@ Claude Code 不需要这一步:`install claude` 写入 `settings.json` 后,h
|
|
|
114
114
|
host 默认只监听 `127.0.0.1`。要让它成为可信网络里其他机器的 host:
|
|
115
115
|
|
|
116
116
|
1. 在 host 所在的机器上打开局域网访问:
|
|
117
|
-
- 托盘:勾选 **允许局域网访问**。托盘把 `"host": "0.0.0.0"` 写进 `settings.json` 并重启 host。Windows 上会在 UAC 确认后添加 TCP 端口和 UDP 发现端口(默认都是 5688
|
|
117
|
+
- 托盘:勾选 **允许局域网访问**。托盘把 `"host": "0.0.0.0"` 写进 `settings.json` 并重启 host。Windows 上会在 UAC 确认后添加 TCP 端口和 UDP 发现端口(默认都是 5688)的入站防火墙规则,只对专用和域网络生效,不含公用网络;macOS 和 Linux 上会提示需要在防火墙放行的端口。
|
|
118
118
|
- 服务:`n2n-nexus-host service install --host 0.0.0.0` 把地址写进 `settings.json`;防火墙里的 TCP 5688 和 UDP 5688 需要自己放行。
|
|
119
119
|
2. 在其他机器上用 `--endpoint discover` 安装客户端(例如 `n2n-nexus install claude --endpoint discover`),或者直接写 host 的地址。
|
|
120
120
|
|
package/docs/TOOLS_REFERENCE.md
CHANGED
|
@@ -12,7 +12,7 @@ Parameter tables below are derived from `contract/tools.json`, the JSON Schema t
|
|
|
12
12
|
- Calls are rate limited per conversation, per instance without the hooks (default 20 per second, burst 60; `rateLimit` and `rateBurst` in the host's `settings.json`). Over the limit a call fails with "Rate limit exceeded ... retry after Ns"; retry after that delay.
|
|
13
13
|
- Every tool has a display `title` (for example "Delete Project") for client UIs.
|
|
14
14
|
- Every tool carries MCP annotations: `readOnlyHint`, `destructiveHint`, `idempotentHint` and `openWorldHint: false` (all tools act only on the host). Per the MCP definition a tool is non-destructive only when its updates are purely additive. Read tools are marked read-only. `start_meeting`, `join_meeting`, `create_task`, `send_message`, `send` and `reply` only add data and are non-destructive (`join_meeting` is also idempotent); `update_task` is marked non-destructive and idempotent too. `listen`, `set_profile`, `sync_project_assets`, `update_project`, `upload_project_asset`, `rename_project`, `sync_global_doc`, `update_global_strategy`, `end_meeting`, `archive_meeting`, `reopen_meeting`, `leave_meeting`, `stance`, `cancel_task`, `host_maintenance` and `host_delete_project` rewrite or remove existing state and are marked destructive, so clients can ask for confirmation. `read_messages` and `read` are not read-only because they advance the caller's own unread state, but they are non-destructive since no shared data changes.
|
|
15
|
-
- Every adapter has an instance ID (`NEXUS_INSTANCE_ID`, `--id`, or `mcp-<hostname>-<hash of the working directory>-<IDE name>` by default, where the IDE name is the MCP client name from the request's `io.modelcontextprotocol/clientInfo` or, for 2025-era clients, from `initialize`). It stays the same across restarts of the same IDE in the same workspace while two IDEs on one workspace stay distinct. The adapter sends it as `instanceId` with every call. Several conversations of one IDE in one workspace share it, so chat and meeting tools identify the conversation instead when the n2n-nexus hooks are installed (see the next item); a client without the hooks is identified by its instance, and `read_messages` then fails without `instanceId`.
|
|
15
|
+
- Every adapter has an instance ID (`NEXUS_INSTANCE_ID`, `--id`, or `mcp-<hostname>-<hash of the working directory>-<IDE name>` by default, where the hash also covers the WSL distribution, since distributions on one Windows machine share its host name, and the IDE name is the MCP client name from the request's `io.modelcontextprotocol/clientInfo` or, for 2025-era clients, from `initialize`). It stays the same across restarts of the same IDE in the same workspace while two IDEs on one workspace stay distinct. The adapter sends it as `instanceId` with every call. Several conversations of one IDE in one workspace share it, so chat and meeting tools identify the conversation instead when the n2n-nexus hooks are installed (see the next item); a client without the hooks is identified by its instance, and `read_messages` then fails without `instanceId`.
|
|
16
16
|
- Two kinds of id appear in results: conversation session ids, `claude:<id>` or `codex:<id>`, and adapter instance ids (`mcp-…`). The direct-message tools (`peers`, `send`, `read`, `reply`) use session ids. Chat and meetings use the calling conversation's session id when the hooks are installed, else its instance id: the sender and `from` of `send_message` / `read_messages`, the unread cursor, a meeting's `initiator` and `participants` and the `actor` of `meeting.*` events; results say which with `identity` (`session` or `instance`). A session id there can be used with `send`; an instance id cannot. If an instance has had a conversation identified within the last 30 minutes and one of its calls cannot be identified, the call fails with a retry message instead of using the instance's shared cursor. Other events and `updatedBy` of global docs keep the instance id.
|
|
17
17
|
- Project IDs follow `[prefix]_[name]`; the prefixes are listed in the [Assistant guide](ASSISTANT_GUIDE.md#2-project-ids).
|
|
18
18
|
- All project write tools run synchronously and return their result directly. The task tools (`create_task`, `get_task`, `list_tasks`, `update_task`, `cancel_task`) track work that assistants manage themselves.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- 调用按对话限流,没装 hooks 时按实例(默认每秒 20 次,突发 60 次;对应 host `settings.json` 中的 `rateLimit` 和 `rateBurst`)。超出限制的调用会失败并返回 "Rate limit exceeded ... retry after Ns";等待该时长后重试。
|
|
13
13
|
- 每个工具都有供客户端界面显示的 `title`(例如 "Delete Project")。
|
|
14
14
|
- 每个工具都带有 MCP annotations:`readOnlyHint`、`destructiveHint`、`idempotentHint` 和 `openWorldHint: false`(所有工具都只作用于 host)。按照 MCP 的定义,只有更新完全是追加时,工具才算非破坏性。读取类工具标为只读。`start_meeting`、`join_meeting`、`create_task`、`send_message`、`send` 和 `reply` 只追加数据,是非破坏性的(`join_meeting` 也是幂等的);`update_task` 也标为非破坏性且幂等。`listen`、`set_profile`、`sync_project_assets`、`update_project`、`upload_project_asset`、`rename_project`、`sync_global_doc`、`update_global_strategy`、`end_meeting`、`archive_meeting`、`reopen_meeting`、`leave_meeting`、`stance`、`cancel_task`、`host_maintenance` 和 `host_delete_project` 会改写或删除已有状态,标为破坏性,以便客户端请求确认。`read_messages` 和 `read` 不是只读的,因为它们会推进调用方自己的未读状态;但它们是非破坏性的,因为不改变任何共享数据。
|
|
15
|
-
- 每个适配器都有一个实例 ID(`NEXUS_INSTANCE_ID`、`--id`,默认是 `mcp-<hostname>-<工作目录的哈希>-<IDE
|
|
15
|
+
- 每个适配器都有一个实例 ID(`NEXUS_INSTANCE_ID`、`--id`,默认是 `mcp-<hostname>-<工作目录的哈希>-<IDE 名>`,其中哈希也包含 WSL 发行版名,因为同一台 Windows 上的发行版共用它的主机名;IDE 名是 MCP 客户端名,取自请求的 `io.modelcontextprotocol/clientInfo`,2025 代的客户端则取自 `initialize`)。同一个 IDE 在同一个工作区里重启后它保持不变,而同一个工作区里的两个 IDE 仍然互相区分。适配器在每次调用中都以 `instanceId` 带上它。同一个 IDE 在同一个工作区里的多个对话共用它,所以装了 n2n-nexus hooks 时,聊天和会议工具改为识别对话本身(见下一条);没装 hooks 的客户端按实例识别,这时没有 `instanceId` 的 `read_messages` 会失败。
|
|
16
16
|
- 结果里会出现两种 ID:对话的会话 ID(`claude:<id>` 或 `codex:<id>`)和适配器实例 ID(`mcp-…`)。直接消息工具(`peers`、`send`、`read`、`reply`)使用会话 ID。聊天和会议在装了 hooks 时使用调用方对话的会话 ID,否则使用实例 ID:`send_message` / `read_messages` 的发送方和 `from`、未读游标、会议的 `initiator` 和 `participants`、`meeting.*` 事件的 `actor`;结果里的 `identity`(`session` 或 `instance`)说明是哪一种。这里的会话 ID 可以用于 `send`,实例 ID 不能。某个实例在最近 30 分钟内识别出过对话、而这次调用识别不出时,调用会失败并提示重试,而不会改用该实例共用的游标。其他事件和全局文档的 `updatedBy` 仍是实例 ID。
|
|
17
17
|
- 项目 ID 采用 `[prefix]_[name]` 格式;前缀列在[助手指南](ASSISTANT_GUIDE_zh.md#2-项目-id)中。
|
|
18
18
|
- 所有项目写入工具都同步执行并直接返回结果。任务工具(`create_task`、`get_task`、`list_tasks`、`update_task`、`cancel_task`)用于跟踪由助手自己管理的工作。
|