@dolusoft/claude-collab 1.8.2 → 1.8.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/dist/cli.js +68 -49
- package/dist/cli.js.map +1 -1
- package/dist/mcp-main.js +68 -49
- package/dist/mcp-main.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp-main.js
CHANGED
|
@@ -701,10 +701,17 @@ var HubManager = class {
|
|
|
701
701
|
server.start(port);
|
|
702
702
|
this.hubServer = server;
|
|
703
703
|
this.currentPort = port;
|
|
704
|
-
await addFirewallRule(port);
|
|
705
704
|
const advertiser = new MdnsAdvertiser();
|
|
706
705
|
advertiser.start(port);
|
|
707
706
|
this.advertiser = advertiser;
|
|
707
|
+
let firewallAdded = false;
|
|
708
|
+
try {
|
|
709
|
+
await addFirewallRule(port);
|
|
710
|
+
firewallAdded = true;
|
|
711
|
+
} catch (err) {
|
|
712
|
+
console.error("[hub-manager] firewall rule failed:", err);
|
|
713
|
+
}
|
|
714
|
+
return { firewallAdded };
|
|
708
715
|
}
|
|
709
716
|
async stop() {
|
|
710
717
|
if (!this.isRunning) throw new Error("Hub is not running");
|
|
@@ -716,34 +723,51 @@ var HubManager = class {
|
|
|
716
723
|
this.hubServer.stop();
|
|
717
724
|
this.hubServer = null;
|
|
718
725
|
this.currentPort = null;
|
|
719
|
-
|
|
726
|
+
let firewallRemoved = false;
|
|
727
|
+
try {
|
|
728
|
+
await removeFirewallRule(port);
|
|
729
|
+
firewallRemoved = true;
|
|
730
|
+
} catch (err) {
|
|
731
|
+
console.error("[hub-manager] firewall rule removal failed:", err);
|
|
732
|
+
}
|
|
733
|
+
return { firewallRemoved };
|
|
720
734
|
}
|
|
721
735
|
};
|
|
722
|
-
function runElevated(
|
|
736
|
+
function runElevated(argArray) {
|
|
737
|
+
const argList = argArray.map((a) => `"${a}"`).join(",");
|
|
738
|
+
const psCommand = `Start-Process -FilePath "netsh" -ArgumentList @(${argList}) -Verb RunAs -Wait`;
|
|
723
739
|
return new Promise((resolve, reject) => {
|
|
724
|
-
const ps = spawn("powershell", [
|
|
725
|
-
"-NoProfile",
|
|
726
|
-
"-Command",
|
|
727
|
-
`Start-Process -FilePath "netsh" -ArgumentList "${netshArgs}" -Verb RunAs -Wait`
|
|
728
|
-
]);
|
|
740
|
+
const ps = spawn("powershell", ["-NoProfile", "-Command", psCommand]);
|
|
729
741
|
ps.on("close", (code) => {
|
|
730
742
|
if (code === 0) resolve();
|
|
731
|
-
else reject(new Error(`Firewall
|
|
743
|
+
else reject(new Error(`Firewall UAC prompt was cancelled or denied (exit code ${code}).`));
|
|
732
744
|
});
|
|
733
745
|
ps.on("error", (err) => {
|
|
734
|
-
reject(new Error(`Failed to launch PowerShell
|
|
746
|
+
reject(new Error(`Failed to launch PowerShell: ${err.message}`));
|
|
735
747
|
});
|
|
736
748
|
});
|
|
737
749
|
}
|
|
738
750
|
async function addFirewallRule(port) {
|
|
739
|
-
await runElevated(
|
|
740
|
-
|
|
741
|
-
|
|
751
|
+
await runElevated([
|
|
752
|
+
"advfirewall",
|
|
753
|
+
"firewall",
|
|
754
|
+
"add",
|
|
755
|
+
"rule",
|
|
756
|
+
`name=claude-collab-${port}`,
|
|
757
|
+
"protocol=TCP",
|
|
758
|
+
"dir=in",
|
|
759
|
+
`localport=${port}`,
|
|
760
|
+
"action=allow"
|
|
761
|
+
]);
|
|
742
762
|
}
|
|
743
763
|
async function removeFirewallRule(port) {
|
|
744
|
-
await runElevated(
|
|
745
|
-
|
|
746
|
-
|
|
764
|
+
await runElevated([
|
|
765
|
+
"advfirewall",
|
|
766
|
+
"firewall",
|
|
767
|
+
"delete",
|
|
768
|
+
"rule",
|
|
769
|
+
`name=claude-collab-${port}`
|
|
770
|
+
]);
|
|
747
771
|
}
|
|
748
772
|
var askSchema = {
|
|
749
773
|
peer: z.string().describe('Name of the peer to ask (e.g., "alice", "backend")'),
|
|
@@ -920,15 +944,14 @@ function registerStartHubTool(server, client, hubManager) {
|
|
|
920
944
|
}]
|
|
921
945
|
};
|
|
922
946
|
}
|
|
947
|
+
let firewallAdded = false;
|
|
923
948
|
try {
|
|
924
|
-
await hubManager.start(port);
|
|
949
|
+
const result = await hubManager.start(port);
|
|
950
|
+
firewallAdded = result.firewallAdded;
|
|
925
951
|
} catch (err) {
|
|
926
952
|
const msg = err instanceof Error ? err.message : String(err);
|
|
927
953
|
return {
|
|
928
|
-
content: [{
|
|
929
|
-
type: "text",
|
|
930
|
-
text: `Failed to start hub: ${msg}`
|
|
931
|
-
}]
|
|
954
|
+
content: [{ type: "text", text: `Failed to start hub: ${msg}` }]
|
|
932
955
|
};
|
|
933
956
|
}
|
|
934
957
|
try {
|
|
@@ -936,22 +959,17 @@ function registerStartHubTool(server, client, hubManager) {
|
|
|
936
959
|
} catch (err) {
|
|
937
960
|
const msg = err instanceof Error ? err.message : String(err);
|
|
938
961
|
return {
|
|
939
|
-
content: [{
|
|
940
|
-
type: "text",
|
|
941
|
-
text: `Hub started on port ${port}, but failed to self-connect: ${msg}`
|
|
942
|
-
}]
|
|
962
|
+
content: [{ type: "text", text: `Hub started on port ${port}, but failed to self-connect: ${msg}` }]
|
|
943
963
|
};
|
|
944
964
|
}
|
|
965
|
+
const lines = [
|
|
966
|
+
`Hub started on port ${port}.`,
|
|
967
|
+
firewallAdded ? `Firewall rule added (claude-collab-${port}) \u2014 LAN peers can connect.` : `WARNING: Firewall rule could not be added (UAC was cancelled or denied). Peers on other machines may be blocked by Windows Firewall. Run start_hub again and accept the UAC prompt to fix this.`,
|
|
968
|
+
`Others on the LAN will auto-discover and connect via mDNS.`,
|
|
969
|
+
`Use stop_hub when you are done.`
|
|
970
|
+
];
|
|
945
971
|
return {
|
|
946
|
-
content: [{
|
|
947
|
-
type: "text",
|
|
948
|
-
text: [
|
|
949
|
-
`Hub started on port ${port}.`,
|
|
950
|
-
`Firewall rule added (claude-collab-${port}).`,
|
|
951
|
-
`Others on the LAN will auto-discover and connect \u2014 no IP sharing needed.`,
|
|
952
|
-
`Use stop_hub when you are done to close the hub and remove the firewall rule.`
|
|
953
|
-
].join("\n")
|
|
954
|
-
}]
|
|
972
|
+
content: [{ type: "text", text: lines.join("\n") }]
|
|
955
973
|
};
|
|
956
974
|
}
|
|
957
975
|
);
|
|
@@ -973,26 +991,23 @@ function registerStopHubTool(server, hubManager) {
|
|
|
973
991
|
};
|
|
974
992
|
}
|
|
975
993
|
const port = hubManager.port;
|
|
994
|
+
let firewallRemoved = false;
|
|
976
995
|
try {
|
|
977
|
-
await hubManager.stop();
|
|
996
|
+
const result = await hubManager.stop();
|
|
997
|
+
firewallRemoved = result.firewallRemoved;
|
|
978
998
|
} catch (err) {
|
|
979
999
|
const msg = err instanceof Error ? err.message : String(err);
|
|
980
1000
|
return {
|
|
981
|
-
content: [{
|
|
982
|
-
type: "text",
|
|
983
|
-
text: `Failed to stop hub: ${msg}`
|
|
984
|
-
}]
|
|
1001
|
+
content: [{ type: "text", text: `Failed to stop hub: ${msg}` }]
|
|
985
1002
|
};
|
|
986
1003
|
}
|
|
1004
|
+
const lines = [
|
|
1005
|
+
`Hub stopped (was on port ${port}).`,
|
|
1006
|
+
firewallRemoved ? `Firewall rule removed (claude-collab-${port}).` : `WARNING: Firewall rule could not be removed (UAC was cancelled). Remove it manually: netsh advfirewall firewall delete rule name="claude-collab-${port}"`,
|
|
1007
|
+
`All peers have been disconnected.`
|
|
1008
|
+
];
|
|
987
1009
|
return {
|
|
988
|
-
content: [{
|
|
989
|
-
type: "text",
|
|
990
|
-
text: [
|
|
991
|
-
`Hub stopped (was on port ${port}).`,
|
|
992
|
-
`Firewall rule removed (claude-collab-${port}).`,
|
|
993
|
-
`All peers have been disconnected.`
|
|
994
|
-
].join("\n")
|
|
995
|
-
}]
|
|
1010
|
+
content: [{ type: "text", text: lines.join("\n") }]
|
|
996
1011
|
};
|
|
997
1012
|
}
|
|
998
1013
|
);
|
|
@@ -1019,6 +1034,10 @@ async function startMcpServer(options) {
|
|
|
1019
1034
|
await server.connect(transport);
|
|
1020
1035
|
}
|
|
1021
1036
|
var SERVICE_TYPE2 = "claude-collab";
|
|
1037
|
+
function resolveHost(svc) {
|
|
1038
|
+
const ipv4 = svc.addresses?.find((a) => /^\d+\.\d+\.\d+\.\d+$/.test(a));
|
|
1039
|
+
return ipv4 ?? svc.host;
|
|
1040
|
+
}
|
|
1022
1041
|
function discoverHub(timeoutMs = 5e3) {
|
|
1023
1042
|
return new Promise((resolve) => {
|
|
1024
1043
|
const bonjour = new Bonjour();
|
|
@@ -1034,7 +1053,7 @@ function discoverHub(timeoutMs = 5e3) {
|
|
|
1034
1053
|
};
|
|
1035
1054
|
const timer = setTimeout(() => finish(null), timeoutMs);
|
|
1036
1055
|
browser.on("up", (svc) => {
|
|
1037
|
-
finish({ host: svc
|
|
1056
|
+
finish({ host: resolveHost(svc), port: svc.port });
|
|
1038
1057
|
});
|
|
1039
1058
|
});
|
|
1040
1059
|
}
|
|
@@ -1042,7 +1061,7 @@ function watchForHub(onFound) {
|
|
|
1042
1061
|
const bonjour = new Bonjour();
|
|
1043
1062
|
const browser = bonjour.find({ type: SERVICE_TYPE2 });
|
|
1044
1063
|
browser.on("up", (svc) => {
|
|
1045
|
-
onFound({ host: svc
|
|
1064
|
+
onFound({ host: resolveHost(svc), port: svc.port });
|
|
1046
1065
|
});
|
|
1047
1066
|
return () => {
|
|
1048
1067
|
browser.stop();
|