@dolusoft/claude-collab 1.10.2 → 1.10.4
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 +51 -50
- package/dist/cli.js +5 -126
- package/dist/cli.js.map +1 -1
- package/dist/mcp-main.js +5 -126
- package/dist/mcp-main.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp-main.js
CHANGED
|
@@ -102,7 +102,7 @@ var MulticastDiscovery = class extends EventEmitter {
|
|
|
102
102
|
}
|
|
103
103
|
sendUnicast(toIp) {
|
|
104
104
|
if (!this.socket) return;
|
|
105
|
-
const buf = Buffer.from(JSON.stringify({ type: "ANNOUNCE", name: this.myName, wsPort: this.myWsPort }));
|
|
105
|
+
const buf = Buffer.from(JSON.stringify({ type: "ANNOUNCE", name: this.myName, wsPort: this.myWsPort, unicast: true }));
|
|
106
106
|
this.socket.send(buf, MULTICAST_PORT, toIp, (err) => {
|
|
107
107
|
if (err) console.error(`[multicast] unicast reply to ${toIp} error:`, err.message);
|
|
108
108
|
});
|
|
@@ -115,12 +115,14 @@ var MulticastDiscovery = class extends EventEmitter {
|
|
|
115
115
|
const peer = { name: msg.name, ip: fromIp, wsPort: msg.wsPort, lastSeen: Date.now() };
|
|
116
116
|
this.peers.set(msg.name, peer);
|
|
117
117
|
console.error(`[multicast] discovered peer: ${msg.name} @ ${fromIp}:${msg.wsPort}`);
|
|
118
|
-
this.sendUnicast(fromIp);
|
|
119
118
|
} else {
|
|
120
119
|
existing.lastSeen = Date.now();
|
|
121
120
|
existing.ip = fromIp;
|
|
122
121
|
existing.wsPort = msg.wsPort;
|
|
123
122
|
}
|
|
123
|
+
if (!msg.unicast) {
|
|
124
|
+
this.sendUnicast(fromIp);
|
|
125
|
+
}
|
|
124
126
|
this.emit("peer-found", { name: msg.name, ip: fromIp, wsPort: msg.wsPort });
|
|
125
127
|
} else if (msg.type === "LEAVE") {
|
|
126
128
|
if (this.peers.has(msg.name)) {
|
|
@@ -1041,128 +1043,7 @@ async function removeFirewallRule(port) {
|
|
|
1041
1043
|
}
|
|
1042
1044
|
}
|
|
1043
1045
|
|
|
1044
|
-
// src/presentation/mcp/tools/
|
|
1045
|
-
var FIREWALL_OPEN_DESCRIPTION = `Open a Windows Firewall inbound rule so peers on the LAN can connect directly to you.
|
|
1046
|
-
|
|
1047
|
-
WHEN YOU NEED THIS:
|
|
1048
|
-
- Other peers cannot see you in their peers() list even though you are on the same LAN
|
|
1049
|
-
- You just started and want to make sure all peers can reach you
|
|
1050
|
-
- A peer explicitly says they cannot connect to you
|
|
1051
|
-
|
|
1052
|
-
WHEN YOU DO NOT NEED THIS:
|
|
1053
|
-
- You can already see peers in peers() \u2014 the connection is working
|
|
1054
|
-
- You are connecting outbound to others (outbound connections do not require firewall rules)
|
|
1055
|
-
|
|
1056
|
-
WHAT HAPPENS:
|
|
1057
|
-
- On most systems: the rule is applied immediately (terminal is already elevated)
|
|
1058
|
-
- On standard Windows: a UAC popup appears \u2014 the user must click Yes
|
|
1059
|
-
- On VMs or headless setups: applied directly if running as Administrator
|
|
1060
|
-
|
|
1061
|
-
The rule is named "claude-collab-{port}" and allows inbound TCP on your current listen port.
|
|
1062
|
-
Call firewall_close() when you are done to clean up the rule.`;
|
|
1063
|
-
function registerFirewallOpenTool(server, client) {
|
|
1064
|
-
server.tool(
|
|
1065
|
-
"firewall_open",
|
|
1066
|
-
FIREWALL_OPEN_DESCRIPTION,
|
|
1067
|
-
{
|
|
1068
|
-
port: z.number().min(1024).max(65535).optional().describe(
|
|
1069
|
-
"Port to open. Defaults to your current listen port \u2014 omit this unless you have a specific reason to override."
|
|
1070
|
-
)
|
|
1071
|
-
},
|
|
1072
|
-
async ({ port }) => {
|
|
1073
|
-
const targetPort = port ?? client.getInfo().port;
|
|
1074
|
-
if (!targetPort) {
|
|
1075
|
-
return {
|
|
1076
|
-
content: [{ type: "text", text: "P2P node is not running yet \u2014 port unknown. Try again in a moment." }],
|
|
1077
|
-
isError: true
|
|
1078
|
-
};
|
|
1079
|
-
}
|
|
1080
|
-
try {
|
|
1081
|
-
await addFirewallRule(targetPort);
|
|
1082
|
-
return {
|
|
1083
|
-
content: [{
|
|
1084
|
-
type: "text",
|
|
1085
|
-
text: [
|
|
1086
|
-
`Firewall rule opened for port ${targetPort} (claude-collab-${targetPort}).`,
|
|
1087
|
-
`Peers on the LAN can now connect to you inbound.`,
|
|
1088
|
-
`Call firewall_close() when you are done with this session.`
|
|
1089
|
-
].join("\n")
|
|
1090
|
-
}]
|
|
1091
|
-
};
|
|
1092
|
-
} catch (err) {
|
|
1093
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1094
|
-
return {
|
|
1095
|
-
content: [{
|
|
1096
|
-
type: "text",
|
|
1097
|
-
text: [
|
|
1098
|
-
`Failed to open firewall: ${msg}`,
|
|
1099
|
-
``,
|
|
1100
|
-
`Try running your terminal as Administrator and call firewall_open() again.`
|
|
1101
|
-
].join("\n")
|
|
1102
|
-
}],
|
|
1103
|
-
isError: true
|
|
1104
|
-
};
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
);
|
|
1108
|
-
}
|
|
1109
|
-
var FIREWALL_CLOSE_DESCRIPTION = `Remove the Windows Firewall inbound rule that was opened by firewall_open().
|
|
1110
|
-
|
|
1111
|
-
WHEN TO USE:
|
|
1112
|
-
- At the end of a collaboration session to clean up
|
|
1113
|
-
- When you no longer want to accept inbound peer connections
|
|
1114
|
-
- As general hygiene \u2014 open firewall rules should not be left indefinitely
|
|
1115
|
-
|
|
1116
|
-
WHAT HAPPENS:
|
|
1117
|
-
- The inbound TCP rule "claude-collab-{port}" is deleted from Windows Firewall
|
|
1118
|
-
- Existing active connections are not dropped \u2014 only new inbound connections are blocked
|
|
1119
|
-
- On standard Windows: a UAC popup appears \u2014 the user must click Yes
|
|
1120
|
-
- On VMs or admin terminals: applied directly without a popup
|
|
1121
|
-
|
|
1122
|
-
NOTE: Because ports are random each session, each startup creates a new rule name.
|
|
1123
|
-
Old rules from previous sessions can be removed by passing the port explicitly.`;
|
|
1124
|
-
function registerFirewallCloseTool(server, client) {
|
|
1125
|
-
server.tool(
|
|
1126
|
-
"firewall_close",
|
|
1127
|
-
FIREWALL_CLOSE_DESCRIPTION,
|
|
1128
|
-
{
|
|
1129
|
-
port: z.number().min(1024).max(65535).optional().describe(
|
|
1130
|
-
"Port whose rule to remove. Defaults to your current listen port. Pass a specific port to clean up a rule from a previous session."
|
|
1131
|
-
)
|
|
1132
|
-
},
|
|
1133
|
-
async ({ port }) => {
|
|
1134
|
-
const targetPort = port ?? client.getInfo().port;
|
|
1135
|
-
if (!targetPort) {
|
|
1136
|
-
return {
|
|
1137
|
-
content: [{ type: "text", text: "P2P node is not running yet \u2014 port unknown. Try again in a moment." }],
|
|
1138
|
-
isError: true
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
try {
|
|
1142
|
-
await removeFirewallRule(targetPort);
|
|
1143
|
-
return {
|
|
1144
|
-
content: [{
|
|
1145
|
-
type: "text",
|
|
1146
|
-
text: `Firewall rule removed for port ${targetPort} (claude-collab-${targetPort}).`
|
|
1147
|
-
}]
|
|
1148
|
-
};
|
|
1149
|
-
} catch (err) {
|
|
1150
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1151
|
-
return {
|
|
1152
|
-
content: [{
|
|
1153
|
-
type: "text",
|
|
1154
|
-
text: [
|
|
1155
|
-
`Failed to remove firewall rule: ${msg}`,
|
|
1156
|
-
``,
|
|
1157
|
-
`The rule may not exist (if firewall_open was never called this session), or try running as Administrator.`
|
|
1158
|
-
].join("\n")
|
|
1159
|
-
}],
|
|
1160
|
-
isError: true
|
|
1161
|
-
};
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
);
|
|
1165
|
-
}
|
|
1046
|
+
// src/presentation/mcp/tools/peer-find.tool.ts
|
|
1166
1047
|
var PEER_FIND_DESCRIPTION = `Discover and connect to peers on the LAN automatically.
|
|
1167
1048
|
|
|
1168
1049
|
WHAT IT DOES:
|
|
@@ -1253,8 +1134,6 @@ function createMcpServer(options) {
|
|
|
1253
1134
|
registerReplyTool(server, client);
|
|
1254
1135
|
registerPeersTool(server, client);
|
|
1255
1136
|
registerHistoryTool(server, client);
|
|
1256
|
-
registerFirewallOpenTool(server, client);
|
|
1257
|
-
registerFirewallCloseTool(server, client);
|
|
1258
1137
|
registerPeerFindTool(server, client);
|
|
1259
1138
|
return server;
|
|
1260
1139
|
}
|