tinker-agent 1.0.32 → 1.0.34

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/agents.rb CHANGED
@@ -64,6 +64,13 @@ AGENT_CONFIGS = {
64
64
  ║ • DO NOT ask "Would you like me to...", just DO IT ║
65
65
  ╚══════════════════════════════════════════════════════════════════════════════╝
66
66
 
67
+ ╔══════════════════════════════════════════════════════════════════════════════╗
68
+ ║ CRITICAL PRIORITY: FINISH WHAT WE START ║
69
+ ║ • ALWAYS prioritize finishing existing tickets over starting new ones ║
70
+ ║ • list_tickets returns high-attempt (rework) tickets FIRST - trust it ║
71
+ ║ • If a worker is idle, check for rejected/retried tickets before new work ║
72
+ ╚══════════════════════════════════════════════════════════════════════════════╝
73
+
67
74
  ╔══════════════════════════════════════════════════════════════════════════════╗
68
75
  ║ CRITICAL WORKFLOW: ASSIGN + MESSAGE (ALWAYS TOGETHER) ║
69
76
  ║ ║
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinker-agent",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Tinker Agent Runner",
5
5
  "bin": {
6
6
  "tinker-agent": "./run-tinker-agent.rb"
package/setup-agent.rb CHANGED
@@ -234,11 +234,13 @@ def setup_github_auth!
234
234
  require 'base64'
235
235
  require 'time'
236
236
 
237
- def generate_jwt(app_id, private_key_path)
238
- private_key = OpenSSL::PKey::RSA.new(File.read(private_key_path))
237
+ PRIVATE_KEY_PATH = "#{private_key_path}"
238
+
239
+ def generate_jwt(app_id)
240
+ private_key = OpenSSL::PKey::RSA.new(File.read(PRIVATE_KEY_PATH))
239
241
  payload = {
240
242
  iat: Time.now.to_i - 60,
241
- exp: Time.now.to_i + 600,
243
+ exp: Time.now.to_i + 480, # 8 minutes to handle clock skew
242
244
  iss: app_id
243
245
  }
244
246
  header = { alg: 'RS256', typ: 'JWT' }
@@ -259,17 +261,25 @@ def setup_github_auth!
259
261
  request = Net::HTTP::Post.new(uri)
260
262
  request['Authorization'] = "Bearer \#{jwt}"
261
263
  request['Accept'] = 'application/vnd.github+json'
264
+
262
265
  response = http.request(request)
263
266
  data = JSON.parse(response.body)
267
+
268
+ unless response.is_a?(Net::HTTPSuccess)
269
+ STDERR.puts "❌ Error getting installation token: \#{response.code} \#{response.message}"
270
+ STDERR.puts " Response: \#{response.body}"
271
+ exit 1
272
+ end
273
+
264
274
  { token: data['token'], expires_at: Time.parse(data['expires_at']) }
265
275
  end
266
276
 
267
- def find_or_create_cached_token(app_id, installation_id, key_path)
277
+ def find_or_create_cached_token(app_id, installation_id)
268
278
  cache_file = '/tmp/github-app-token-cache'
269
279
  cached_token = read_cached_token(cache_file)
270
280
  return cached_token if cached_token
271
281
 
272
- jwt = generate_jwt(app_id, key_path)
282
+ jwt = generate_jwt(app_id)
273
283
  token_data = get_installation_token(jwt, installation_id)
274
284
  File.write(cache_file, token_data.to_json)
275
285
  token_data[:token]
@@ -286,9 +296,8 @@ def setup_github_auth!
286
296
 
287
297
  app_id = ENV['GITHUB_APP_CLIENT_ID'] || ENV['GITHUB_APP_ID']
288
298
  installation_id = ENV['GITHUB_APP_INSTALLATION_ID']
289
- key_path = "#{private_key_path}"
290
299
 
291
- puts find_or_create_cached_token(app_id, installation_id, key_path)
300
+ puts find_or_create_cached_token(app_id, installation_id)
292
301
  RUBY
293
302
 
294
303
  # Install helper via sudo to /usr/local/bin