iubcli 5.0.0 → 5.0.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/README.md +8 -0
- package/dist/index.js +92 -19
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/Ifaz2611/iubcli/main/icon/icon.svg" alt="IUB CLI icon" width="88" height="88" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# IUB CLI
|
|
2
6
|
|
|
3
7
|
> Autonomous BYOK terminal coding agent for English workflows, with BUILD and PLAN modes, local-first configuration, and resilient free-model failover.
|
|
@@ -6,6 +10,7 @@
|
|
|
6
10
|
[](https://nodejs.org/)
|
|
7
11
|
[](license)
|
|
8
12
|
[](#bring-your-own-key-byok)
|
|
13
|
+
[](https://github.com/Ifaz2611/iubcli)
|
|
9
14
|
|
|
10
15
|
```
|
|
11
16
|
██╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗
|
|
@@ -319,10 +324,13 @@ iubcli/
|
|
|
319
324
|
│ ├── detector.ts # project stack detection
|
|
320
325
|
│ ├── image.ts # clipboard/file image payload loading
|
|
321
326
|
│ └── mesh.ts # cross-instance peer networking
|
|
327
|
+
├── icon/
|
|
328
|
+
│ └── icon.svg # project logo and favicon source
|
|
322
329
|
├── scripts/
|
|
323
330
|
│ ├── test-tools.ts
|
|
324
331
|
│ ├── test-image.ts
|
|
325
332
|
│ ├── test-box.ts
|
|
333
|
+
│ ├── test-mesh.ts
|
|
326
334
|
│ └── test-gemini-tools.ts
|
|
327
335
|
├── package.json
|
|
328
336
|
├── tsconfig.json
|
package/dist/index.js
CHANGED
|
@@ -7828,6 +7828,25 @@ import crypto from "crypto";
|
|
|
7828
7828
|
import { EventEmitter } from "events";
|
|
7829
7829
|
import { WebSocketServer, WebSocket } from "ws";
|
|
7830
7830
|
var DEFAULT_MESH_PORT = 49152;
|
|
7831
|
+
function mergePeerUpdate(current, incoming) {
|
|
7832
|
+
if (!incoming || typeof incoming !== "object") return null;
|
|
7833
|
+
const update = incoming;
|
|
7834
|
+
if (typeof update.nodeId !== "string" || update.nodeId !== current.nodeId) {
|
|
7835
|
+
return null;
|
|
7836
|
+
}
|
|
7837
|
+
if (update.role !== void 0 && update.role !== current.role) {
|
|
7838
|
+
return null;
|
|
7839
|
+
}
|
|
7840
|
+
const mode = update.mode === "build" || update.mode === "plan" ? update.mode : current.mode;
|
|
7841
|
+
const model = typeof update.model === "string" && update.model.trim().length > 0 ? update.model : current.model;
|
|
7842
|
+
const provider = typeof update.provider === "string" && update.provider.trim().length > 0 ? update.provider : current.provider;
|
|
7843
|
+
return {
|
|
7844
|
+
...current,
|
|
7845
|
+
mode,
|
|
7846
|
+
model,
|
|
7847
|
+
provider
|
|
7848
|
+
};
|
|
7849
|
+
}
|
|
7831
7850
|
function getOrCreateMeshToken(customToken) {
|
|
7832
7851
|
if (customToken && customToken.trim().length > 0) {
|
|
7833
7852
|
return customToken.trim();
|
|
@@ -7993,27 +8012,54 @@ var MeshNode = class extends EventEmitter {
|
|
|
7993
8012
|
ws.close(4001, "Unauthorized");
|
|
7994
8013
|
return;
|
|
7995
8014
|
}
|
|
8015
|
+
if (!msg.peer || typeof msg.peer !== "object" || typeof msg.peer.nodeId !== "string" || msg.peer.nodeId.trim().length === 0) {
|
|
8016
|
+
ws.send(JSON.stringify({ type: "AUTH_FAIL", reason: "Invalid peer identity" }));
|
|
8017
|
+
ws.close(4001, "Invalid Identity");
|
|
8018
|
+
return;
|
|
8019
|
+
}
|
|
7996
8020
|
clearTimeout(authTimeout);
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8021
|
+
const previousPeer = authedPeer;
|
|
8022
|
+
if (previousPeer && msg.peer.nodeId !== previousPeer.nodeId) {
|
|
8023
|
+
ws.send(
|
|
8024
|
+
JSON.stringify({
|
|
8025
|
+
type: "AUTH_FAIL",
|
|
8026
|
+
reason: "Node identity cannot change after authentication"
|
|
8027
|
+
})
|
|
8028
|
+
);
|
|
8029
|
+
ws.close(4003, "Identity Change Rejected");
|
|
8030
|
+
return;
|
|
8031
|
+
}
|
|
8032
|
+
const authed = previousPeer ? {
|
|
8033
|
+
...previousPeer,
|
|
8034
|
+
role: typeof msg.peer.role === "string" && msg.peer.role.trim().length > 0 ? msg.peer.role : previousPeer.role,
|
|
8035
|
+
mode: msg.peer.mode === "build" || msg.peer.mode === "plan" ? msg.peer.mode : previousPeer.mode,
|
|
8036
|
+
model: typeof msg.peer.model === "string" && msg.peer.model.trim().length > 0 ? msg.peer.model : previousPeer.model,
|
|
8037
|
+
provider: typeof msg.peer.provider === "string" && msg.peer.provider.trim().length > 0 ? msg.peer.provider : previousPeer.provider
|
|
8038
|
+
} : msg.peer;
|
|
8039
|
+
authedPeer = authed;
|
|
8040
|
+
this.connectedClients.set(ws, authed);
|
|
8041
|
+
this.peers.set(authed.nodeId, authed);
|
|
8000
8042
|
const peerList = this.listPeers();
|
|
8001
8043
|
ws.send(
|
|
8002
8044
|
JSON.stringify({
|
|
8003
8045
|
type: "AUTH_OK",
|
|
8004
|
-
assignedNodeId:
|
|
8046
|
+
assignedNodeId: authed.nodeId,
|
|
8005
8047
|
peers: peerList
|
|
8006
8048
|
})
|
|
8007
8049
|
);
|
|
8008
8050
|
this.broadcast(
|
|
8009
8051
|
{
|
|
8010
8052
|
type: "PEER_JOINED",
|
|
8011
|
-
peer:
|
|
8053
|
+
peer: authed
|
|
8012
8054
|
},
|
|
8013
8055
|
ws
|
|
8014
8056
|
);
|
|
8015
|
-
|
|
8016
|
-
|
|
8057
|
+
if (previousPeer) {
|
|
8058
|
+
this.emit("peer_updated", authed);
|
|
8059
|
+
} else {
|
|
8060
|
+
this.emit("peer_connected", authed);
|
|
8061
|
+
this.onPeerConnectCallback?.(authed);
|
|
8062
|
+
}
|
|
8017
8063
|
return;
|
|
8018
8064
|
}
|
|
8019
8065
|
if (!authedPeer) {
|
|
@@ -8029,11 +8075,15 @@ var MeshNode = class extends EventEmitter {
|
|
|
8029
8075
|
return;
|
|
8030
8076
|
}
|
|
8031
8077
|
if (msg.type === "PEER_UPDATE") {
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8078
|
+
const updated = mergePeerUpdate(authedPeer, msg.peer);
|
|
8079
|
+
if (!updated) {
|
|
8080
|
+
return;
|
|
8081
|
+
}
|
|
8082
|
+
authedPeer = updated;
|
|
8083
|
+
this.connectedClients.set(ws, updated);
|
|
8084
|
+
this.peers.set(updated.nodeId, updated);
|
|
8085
|
+
this.broadcast({ type: "PEER_UPDATE", peer: updated }, ws);
|
|
8086
|
+
this.emit("peer_updated", updated);
|
|
8037
8087
|
return;
|
|
8038
8088
|
}
|
|
8039
8089
|
} catch {
|
|
@@ -8044,7 +8094,9 @@ var MeshNode = class extends EventEmitter {
|
|
|
8044
8094
|
if (authedPeer) {
|
|
8045
8095
|
const departing = authedPeer;
|
|
8046
8096
|
this.connectedClients.delete(ws);
|
|
8047
|
-
this.peers.
|
|
8097
|
+
if (this.peers.get(departing.nodeId) === departing) {
|
|
8098
|
+
this.peers.delete(departing.nodeId);
|
|
8099
|
+
}
|
|
8048
8100
|
this.broadcast({ type: "PEER_LEFT", nodeId: departing.nodeId });
|
|
8049
8101
|
this.emit("peer_disconnected", departing);
|
|
8050
8102
|
this.onPeerDisconnectCallback?.(departing);
|
|
@@ -8107,9 +8159,14 @@ var MeshNode = class extends EventEmitter {
|
|
|
8107
8159
|
}
|
|
8108
8160
|
if (msg.type === "PEER_JOINED") {
|
|
8109
8161
|
if (msg.peer.nodeId !== this.nodeId) {
|
|
8162
|
+
const existing = this.peers.get(msg.peer.nodeId);
|
|
8110
8163
|
this.peers.set(msg.peer.nodeId, msg.peer);
|
|
8111
|
-
|
|
8112
|
-
|
|
8164
|
+
if (existing) {
|
|
8165
|
+
this.emit("peer_updated", msg.peer);
|
|
8166
|
+
} else {
|
|
8167
|
+
this.emit("peer_connected", msg.peer);
|
|
8168
|
+
this.onPeerConnectCallback?.(msg.peer);
|
|
8169
|
+
}
|
|
8113
8170
|
}
|
|
8114
8171
|
return;
|
|
8115
8172
|
}
|
|
@@ -8123,10 +8180,12 @@ var MeshNode = class extends EventEmitter {
|
|
|
8123
8180
|
return;
|
|
8124
8181
|
}
|
|
8125
8182
|
if (msg.type === "PEER_UPDATE") {
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8183
|
+
const current = this.peers.get(msg.peer.nodeId);
|
|
8184
|
+
if (!current) return;
|
|
8185
|
+
const updated = mergePeerUpdate(current, msg.peer);
|
|
8186
|
+
if (!updated) return;
|
|
8187
|
+
this.peers.set(updated.nodeId, updated);
|
|
8188
|
+
this.emit("peer_updated", updated);
|
|
8130
8189
|
return;
|
|
8131
8190
|
}
|
|
8132
8191
|
if (msg.type === "RPC_REQUEST") {
|
|
@@ -8462,10 +8521,24 @@ ${out}`;
|
|
|
8462
8521
|
* Broadcast state update (e.g. mode change or model change).
|
|
8463
8522
|
*/
|
|
8464
8523
|
updateState(updates) {
|
|
8524
|
+
const roleChanged = updates.role !== void 0 && updates.role !== this.role;
|
|
8465
8525
|
if (updates.mode) this.mode = updates.mode;
|
|
8466
8526
|
if (updates.model) this.model = updates.model;
|
|
8467
8527
|
if (updates.role) this.role = updates.role;
|
|
8468
8528
|
const myInfo = this.getMyPeerInfo();
|
|
8529
|
+
if (roleChanged) {
|
|
8530
|
+
if (this.isHost) {
|
|
8531
|
+
this.broadcast({ type: "PEER_JOINED", peer: myInfo });
|
|
8532
|
+
} else if (this.clientWs && this.clientWs.readyState === WebSocket.OPEN) {
|
|
8533
|
+
const authMsg = {
|
|
8534
|
+
type: "AUTH",
|
|
8535
|
+
token: this.token,
|
|
8536
|
+
peer: myInfo
|
|
8537
|
+
};
|
|
8538
|
+
this.clientWs.send(JSON.stringify(authMsg));
|
|
8539
|
+
}
|
|
8540
|
+
return;
|
|
8541
|
+
}
|
|
8469
8542
|
const updateMsg = {
|
|
8470
8543
|
type: "PEER_UPDATE",
|
|
8471
8544
|
peer: myInfo
|