tinker-agent 1.0.14 → 1.0.16

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.
@@ -4,7 +4,7 @@
4
4
  set -e
5
5
 
6
6
  AGENT_TYPE="${AGENT_TYPE:-worker}"
7
- STATUS_FILE="/tmp/agent-bridge-status-$AGENT_TYPE"
7
+ STATUS_FILE="/tmp/agent-bridge-status"
8
8
 
9
9
  # Check if we're already inside tmux
10
10
  if [ -n "$TMUX" ]; then
@@ -41,14 +41,14 @@ tmux set-option -g status-right-length 300
41
41
  tmux set-option -t "$SESSION" status-left-length 30
42
42
  tmux set-option -t "$SESSION" status-right-length 300
43
43
  tmux set-option -t "$SESSION" status-left "#[fg=cyan,bold]🤖 $AGENT_TYPE #[fg=cyan]│ "
44
- tmux set-option -t "$SESSION" status-right "#[fg=green]#(cat $STATUS_FILE 2>/dev/null || echo '❓') #[fg=cyan]│ #[fg=white]%H:%M:%S"
44
+ tmux set-option -t "$SESSION" status-right "#[fg=yellow]#(cat ${STATUS_FILE}.cmd 2>/dev/null) #[fg=cyan]│ #[fg=green]#(cat $STATUS_FILE 2>/dev/null || echo '❓') #[fg=cyan]│ #[fg=white]%H:%M:%S"
45
45
  tmux set-option -t "$SESSION" window-status-format ""
46
46
  tmux set-option -t "$SESSION" window-status-current-format ""
47
47
  tmux set-option -t "$SESSION" remain-on-exit off
48
48
  tmux set-option -t "$SESSION" mouse on
49
49
 
50
50
  # Run agent-bridge in tmux session
51
- tmux send-keys -t "$SESSION" "export STATUS_FILE='$STATUS_FILE' AGENT_TYPE='$AGENT_TYPE' && export INSIDE_TMUX=1 && agent-bridge" C-m
51
+ tmux send-keys -t "$SESSION" "export AGENT_TYPE='$AGENT_TYPE' && export INSIDE_TMUX=1 && agent-bridge" C-m
52
52
 
53
53
  # Attach or wait
54
54
  if [ -t 0 ]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinker-agent",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Tinker Agent Runner",
5
5
  "bin": {
6
6
  "tinker-agent": "./run-tinker-agent.rb"
package/setup-agent.rb CHANGED
@@ -246,9 +246,6 @@ def setup_github_auth!
246
246
  puts "🔐 Configuring GitHub App authentication..."
247
247
 
248
248
  # Create helper script
249
- helper_path = "/usr/local/bin/git-auth-helper"
250
-
251
- # We embed the helper script content here
252
249
  helper_content = <<~RUBY
253
250
  #!/usr/bin/env ruby
254
251
  require 'openssl'
@@ -308,27 +305,32 @@ def setup_github_auth!
308
305
  puts cached_token(app_id, installation_id, key_path)
309
306
  RUBY
310
307
 
311
- # Only write if we have permission (we should as root or if /usr/local/bin is writable)
312
- # If not, write to /tmp and use that
313
- if File.writable?("/usr/local/bin")
314
- File.write(helper_path, helper_content)
315
- File.chmod(0755, helper_path)
316
- else
317
- helper_path = "/tmp/git-auth-helper"
318
- File.write(helper_path, helper_content)
319
- File.chmod(0755, helper_path)
320
- end
308
+ # Install helper via sudo to /usr/local/bin
309
+ helper_path = "/usr/local/bin/git-auth-helper"
310
+ File.write("/tmp/git-auth-helper", helper_content)
311
+ system("sudo mv /tmp/git-auth-helper #{helper_path}")
312
+ system("sudo chmod +x #{helper_path}")
321
313
 
322
314
  # Configure git
323
315
  system("git config --global credential.helper '!f() { test \"$1\" = get && echo \"protocol=https\" && echo \"host=github.com\" && echo \"username=x-access-token\" && echo \"password=$(#{helper_path})\"; }; f'")
324
316
 
325
- # Configure gh CLI
326
- token = `#{helper_path}`.strip
327
- if token.empty?
328
- puts "❌ Failed to generate GitHub App token"
317
+ # Configure gh CLI wrapper for auto-refresh
318
+ real_gh_path = "/usr/bin/gh"
319
+ if File.exist?(real_gh_path)
320
+ wrapper_path = "/usr/local/bin/gh"
321
+ wrapper_content = <<~BASH
322
+ #!/bin/bash
323
+ # Auto-refresh GitHub token using git-auth-helper
324
+ export GH_TOKEN=$(#{helper_path})
325
+ exec #{real_gh_path} "$@"
326
+ BASH
327
+
328
+ File.write("/tmp/gh-wrapper", wrapper_content)
329
+ system("sudo mv /tmp/gh-wrapper #{wrapper_path}")
330
+ system("sudo chmod +x #{wrapper_path}")
331
+ puts "✅ GitHub App authentication configured (with auto-refresh)"
329
332
  else
330
- IO.popen("gh auth login --with-token 2>/dev/null", "w") { |io| io.puts token }
331
- puts "✅ GitHub App authentication configured"
333
+ puts "⚠️ Could not find 'gh' at #{real_gh_path}, skipping wrapper"
332
334
  end
333
335
 
334
336
  elsif ENV["GH_TOKEN"] && !ENV["GH_TOKEN"].empty?