@mrtrinhvn/ag-kit 1.4.6 → 1.4.9
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/package.json
CHANGED
|
@@ -24,8 +24,10 @@ echo "════════════════════════
|
|
|
24
24
|
echo "[1/2] 🧪 Đang gắn kết Golden HUD Bridge... "
|
|
25
25
|
BRIDGE_PID_FILE=".agent/logs/.portal_bridge_${BRIDGE_PORT}.pid"
|
|
26
26
|
if [ -f "$BRIDGE_PID_FILE" ]; then
|
|
27
|
-
kill $(cat "$BRIDGE_PID_FILE") 2>/dev/null
|
|
27
|
+
kill $(cat "$BRIDGE_PID_FILE") 2>/dev/null || true
|
|
28
28
|
fi
|
|
29
|
+
# Surgical Port Kill (Garbage Collection)
|
|
30
|
+
lsof -ti tcp:${BRIDGE_PORT} | xargs kill -9 2>/dev/null || true
|
|
29
31
|
nohup node scripts/ag_portal_bridge.js > ".agent/logs/portal_bridge_${BRIDGE_PORT}.log" 2>&1 &
|
|
30
32
|
echo $! > "$BRIDGE_PID_FILE"
|
|
31
33
|
echo " ✅ Bridge đang chạy (PID: $(cat "$BRIDGE_PID_FILE") tại Cổng $BRIDGE_PORT)"
|
|
@@ -32,8 +32,14 @@ async function refreshTargets() {
|
|
|
32
32
|
try {
|
|
33
33
|
const targets = JSON.parse(data);
|
|
34
34
|
|
|
35
|
-
// Find
|
|
36
|
-
const
|
|
35
|
+
// Find workbench target for specific project
|
|
36
|
+
const projName = process.env.PROJECT_NAME || '';
|
|
37
|
+
const workbenchTargets = targets.filter(t =>
|
|
38
|
+
t.url &&
|
|
39
|
+
t.url.includes('workbench.html') &&
|
|
40
|
+
t.title &&
|
|
41
|
+
t.title.toLowerCase().includes(projName.toLowerCase())
|
|
42
|
+
);
|
|
37
43
|
|
|
38
44
|
workbenchTargets.forEach(target => {
|
|
39
45
|
if (!activeConnections.has(target.webSocketDebuggerUrl)) {
|
package/template/start.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# start.sh - Hệ thống Quản trị Khởi động (Agentic Port Fusion)
|
|
2
|
+
# start.sh - Hệ thống Quản trị Khởi động (Agentic Port Fusion & Dynamic Allocate)
|
|
3
3
|
|
|
4
4
|
# 1. Load config
|
|
5
5
|
if [ -f .env ]; then
|
|
@@ -10,8 +10,19 @@ else
|
|
|
10
10
|
fi
|
|
11
11
|
|
|
12
12
|
PORT=${IDE_PORT:-9555}
|
|
13
|
+
BRIDGE=${BRIDGE_PORT:-9656}
|
|
13
14
|
PROJ=${PROJECT_NAME:-"UnknownProject"}
|
|
14
15
|
|
|
16
|
+
update_env() {
|
|
17
|
+
local k=$1
|
|
18
|
+
local v=$2
|
|
19
|
+
if grep -q "^$k=" .env; then
|
|
20
|
+
sed -i.bak "s/^$k=.*/$k=$v/" .env && rm -f .env.bak
|
|
21
|
+
else
|
|
22
|
+
echo "$k=$v" >> .env
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
echo "🔍 Đang kiểm tra IDE cho [$PROJ] tại cổng $PORT..."
|
|
16
27
|
|
|
17
28
|
open_ide() {
|
|
@@ -45,6 +56,18 @@ else
|
|
|
45
56
|
sleep 4
|
|
46
57
|
fi
|
|
47
58
|
|
|
59
|
+
# Quét tìm cổng Bridge trống nếu bị trùng
|
|
60
|
+
ORIGINAL_BRIDGE=$BRIDGE
|
|
61
|
+
while nc -z 127.0.0.1 $BRIDGE &>/dev/null; do
|
|
62
|
+
BRIDGE=$((BRIDGE + 1))
|
|
63
|
+
done
|
|
64
|
+
|
|
65
|
+
if [ "$BRIDGE" != "$ORIGINAL_BRIDGE" ]; then
|
|
66
|
+
echo "🚀 Cổng Bridge $ORIGINAL_BRIDGE đã bị chiếm. Đã phân bổ cổng trống mới: BRIDGE=$BRIDGE"
|
|
67
|
+
update_env "BRIDGE_PORT" "$BRIDGE"
|
|
68
|
+
export BRIDGE_PORT=$BRIDGE
|
|
69
|
+
fi
|
|
70
|
+
|
|
48
71
|
# 3. Khởi động Giao diện & Agent (Receptionist)
|
|
49
72
|
echo "🚀 Đang đánh thức bộ não Agentic Gateway..."
|
|
50
73
|
bash .agent/scripts/receptionist_up.sh
|