tinker-agent 1.0.34 → 1.0.35
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/bin/install-agent.sh +10 -3
- package/package.json +1 -1
- package/run-tinker-agent.rb +21 -5
package/bin/install-agent.sh
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
4
|
# Install dependencies
|
|
5
|
+
# Handle potential clock skew in containers
|
|
6
|
+
echo 'Acquire::Check-Date "false";' > /etc/apt/apt.conf.d/99no-check-date
|
|
7
|
+
|
|
5
8
|
apt-get update && apt-get install -y \
|
|
6
9
|
git curl tmux sudo unzip wget
|
|
7
10
|
|
|
8
11
|
# Install Node.js (required for Claude CLI)
|
|
9
|
-
if ! command -v node &> /dev/null; then
|
|
12
|
+
if ! command -v node &> /dev/null || ! command -v npm &> /dev/null; then
|
|
10
13
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
11
14
|
apt-get install -y nodejs
|
|
12
15
|
fi
|
|
@@ -32,8 +35,12 @@ if getent group ${GROUP_ID} >/dev/null 2>&1; then
|
|
|
32
35
|
GROUP_NAME=$(getent group ${GROUP_ID} | cut -d: -f1)
|
|
33
36
|
else
|
|
34
37
|
# Create group
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
if getent group ${AGENT_USER} >/dev/null 2>&1; then
|
|
39
|
+
GROUP_NAME=${AGENT_USER}
|
|
40
|
+
else
|
|
41
|
+
groupadd -g ${GROUP_ID} ${AGENT_USER}
|
|
42
|
+
GROUP_NAME=${AGENT_USER}
|
|
43
|
+
fi
|
|
37
44
|
fi
|
|
38
45
|
|
|
39
46
|
# 2. Handle User
|
package/package.json
CHANGED
package/run-tinker-agent.rb
CHANGED
|
@@ -308,13 +308,29 @@ def attach_to_agent(agent_type, config)
|
|
|
308
308
|
puts "📎 Attaching to #{agent_type} agent..."
|
|
309
309
|
|
|
310
310
|
# Determine the user to attach as
|
|
311
|
-
#
|
|
312
|
-
user = `docker exec #{container_name}
|
|
311
|
+
# Robust method: find the user running the agent process (tmux or bridge)
|
|
312
|
+
user = `docker exec #{container_name} ps aux | grep "[a]gent-bridge-tmux" | awk '{print $1}' | head -n 1`.strip
|
|
313
313
|
|
|
314
314
|
if user.empty?
|
|
315
|
-
#
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
user = `docker exec #{container_name} ps aux | grep "[t]mux new-session" | awk '{print $1}' | head -n 1`.strip
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
if user.empty?
|
|
319
|
+
# Fallback to previous heuristic
|
|
320
|
+
detected_user = `docker exec #{container_name} whoami 2>/dev/null`.strip
|
|
321
|
+
if detected_user == "root" || detected_user.empty?
|
|
322
|
+
uid = Process.uid
|
|
323
|
+
mapped_user = `docker exec #{container_name} getent passwd #{uid} | cut -d: -f1`.strip
|
|
324
|
+
user = mapped_user unless mapped_user.empty?
|
|
325
|
+
else
|
|
326
|
+
user = detected_user
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
if user.empty?
|
|
331
|
+
# Final Fallback
|
|
332
|
+
user = "rails"
|
|
333
|
+
puts "⚠️ Could not detect agent user, defaulting to '#{user}'"
|
|
318
334
|
end
|
|
319
335
|
|
|
320
336
|
if user.empty?
|