@mrtrinhvn/ag-kit 1.4.9 → 1.4.11
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
|
@@ -8,6 +8,18 @@ cd "$PROJECT_DIR"
|
|
|
8
8
|
|
|
9
9
|
mkdir -p .agent/logs
|
|
10
10
|
|
|
11
|
+
# 0. NVM/Node PATH Resolution for GUI Execution
|
|
12
|
+
export PATH="/usr/local/bin:/usr/bin:/bin:$PATH"
|
|
13
|
+
if [ -f "$HOME/.bashrc" ]; then
|
|
14
|
+
source "$HOME/.bashrc" >/dev/null 2>&1 || true
|
|
15
|
+
fi
|
|
16
|
+
if [ -s "$HOME/.nvm/nvm.sh" ]; then
|
|
17
|
+
source "$HOME/.nvm/nvm.sh" >/dev/null 2>&1 || true
|
|
18
|
+
fi
|
|
19
|
+
if [ -s "$HOME/.bun/_bun" ]; then
|
|
20
|
+
export PATH="$HOME/.bun/bin:$PATH"
|
|
21
|
+
fi
|
|
22
|
+
|
|
11
23
|
# 1. Load Cấu hình Tĩnh từ .env
|
|
12
24
|
if [ -f .env ]; then
|
|
13
25
|
source .env
|
|
@@ -15,6 +27,7 @@ fi
|
|
|
15
27
|
|
|
16
28
|
export IDE_PORT=${IDE_PORT:-9555}
|
|
17
29
|
export BRIDGE_PORT=${BRIDGE_PORT:-9656}
|
|
30
|
+
export PROJECT_NAME=${PROJECT_NAME:-"UnknownProject"}
|
|
18
31
|
|
|
19
32
|
echo "════════════════════════════════════════════════════"
|
|
20
33
|
echo " 🏢 AG GATEWAY - CẦU NỐI NỘI BỘ [$BRIDGE_PORT]"
|
|
@@ -28,7 +41,7 @@ if [ -f "$BRIDGE_PID_FILE" ]; then
|
|
|
28
41
|
fi
|
|
29
42
|
# Surgical Port Kill (Garbage Collection)
|
|
30
43
|
lsof -ti tcp:${BRIDGE_PORT} | xargs kill -9 2>/dev/null || true
|
|
31
|
-
|
|
44
|
+
setsid node scripts/ag_portal_bridge.js > ".agent/logs/portal_bridge_${BRIDGE_PORT}.log" 2>&1 &
|
|
32
45
|
echo $! > "$BRIDGE_PID_FILE"
|
|
33
46
|
echo " ✅ Bridge đang chạy (PID: $(cat "$BRIDGE_PID_FILE") tại Cổng $BRIDGE_PORT)"
|
|
34
47
|
|
|
@@ -46,7 +59,7 @@ if [ -f "$BOT_PID_FILE" ]; then
|
|
|
46
59
|
fi
|
|
47
60
|
sleep 1
|
|
48
61
|
|
|
49
|
-
|
|
62
|
+
setsid bash -c "while true; do
|
|
50
63
|
echo \"\$(date): Khởi động Bot...\" >> .agent/logs/bot_interaction.log
|
|
51
64
|
npx tsx src/index.ts >> .agent/logs/bot_interaction.log 2>&1
|
|
52
65
|
EXIT_CODE=\$?
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
if (window.ag_popup_win && !window.ag_popup_win.closed) window.ag_popup_win.close();
|
|
4
4
|
|
|
5
5
|
const HUD_ID = 'antigravity-elite-statusbar-item';
|
|
6
|
-
if (document.getElementById(HUD_ID))
|
|
6
|
+
if (document.getElementById(HUD_ID)) return "ALREADY_EXISTS";
|
|
7
7
|
|
|
8
8
|
// 2. Locate Status Bar
|
|
9
9
|
const statusBar = document.querySelector('.part.statusbar');
|
|
@@ -93,21 +93,15 @@ function injectHUDIntoContext(ws, contextId) {
|
|
|
93
93
|
if (!fs.existsSync(hudPath)) return;
|
|
94
94
|
|
|
95
95
|
const script = fs.readFileSync(hudPath, 'utf8');
|
|
96
|
-
const b64Script = Buffer.from(script).toString('base64');
|
|
97
96
|
|
|
98
97
|
const message = {
|
|
99
98
|
id: 1000 + contextId,
|
|
100
99
|
method: "Runtime.evaluate",
|
|
101
100
|
params: {
|
|
102
|
-
expression:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
s.textContent = atob('${b64Script}');
|
|
107
|
-
document.head.appendChild(s);
|
|
108
|
-
return "INJECTED";
|
|
109
|
-
})();`,
|
|
110
|
-
contextId: contextId
|
|
101
|
+
expression: script,
|
|
102
|
+
contextId: contextId,
|
|
103
|
+
awaitPromise: true,
|
|
104
|
+
userGesture: true
|
|
111
105
|
}
|
|
112
106
|
};
|
|
113
107
|
ws.send(JSON.stringify(message));
|
package/template/start.sh
CHANGED
|
@@ -59,6 +59,20 @@ fi
|
|
|
59
59
|
# Quét tìm cổng Bridge trống nếu bị trùng
|
|
60
60
|
ORIGINAL_BRIDGE=$BRIDGE
|
|
61
61
|
while nc -z 127.0.0.1 $BRIDGE &>/dev/null; do
|
|
62
|
+
# Kiểm tra xem cổng này có phải do chính dự án mình đang giữ từ phiên trước không
|
|
63
|
+
PID_FILE=".agent/logs/.portal_bridge_${BRIDGE}.pid"
|
|
64
|
+
if [ -f "$PID_FILE" ]; then
|
|
65
|
+
PID_IN_FILE=$(cat "$PID_FILE" 2>/dev/null)
|
|
66
|
+
if [ -n "$PID_IN_FILE" ]; then
|
|
67
|
+
if kill -0 "$PID_IN_FILE" 2>/dev/null; then
|
|
68
|
+
echo "🗑️ Dọn dẹp tiến trình cũ của dự án tại cổng $BRIDGE..."
|
|
69
|
+
kill -9 "$PID_IN_FILE" 2>/dev/null || true
|
|
70
|
+
sleep 1
|
|
71
|
+
continue
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
fi
|
|
75
|
+
# Nếu không phải của mình, nhảy cổng tiếp
|
|
62
76
|
BRIDGE=$((BRIDGE + 1))
|
|
63
77
|
done
|
|
64
78
|
|