gitarsenal-cli 1.1.19 → 1.1.21

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.
@@ -18,27 +18,40 @@ import types
18
18
  import json
19
19
  from pathlib import Path
20
20
 
21
- # The token to use
22
- TOKEN = "ak-eNMIXRdfbvpxIXcSHKPFQW"
21
+ # Try to get tokens from the proxy server
22
+ try:
23
+ # First, try to import the fetch_modal_tokens module
24
+ from fetch_modal_tokens import get_tokens
25
+ TOKEN_ID, TOKEN_SECRET = get_tokens()
26
+ print(f"✅ Using tokens from proxy server or defaults")
27
+ except ImportError:
28
+ # If the module is not available, use hardcoded tokens
29
+ TOKEN_ID = "ak-sLhYqCjkvixiYcb9LAuCHp"
30
+ TOKEN_SECRET = "as-fPzD0Zm0dl6IFAEkhaH9pq" # Real token secret from fr8mafia profile
31
+ print(f"⚠️ Using hardcoded tokens")
23
32
 
24
33
  # Set environment variables
25
- os.environ["MODAL_TOKEN_ID"] = TOKEN
26
- os.environ["MODAL_TOKEN"] = TOKEN
34
+ os.environ["MODAL_TOKEN_ID"] = TOKEN_ID
35
+ os.environ["MODAL_TOKEN_SECRET"] = TOKEN_SECRET
27
36
 
28
37
  # Create token files
29
38
  modal_dir = Path.home() / ".modal"
30
39
  modal_dir.mkdir(exist_ok=True)
31
40
  token_file = modal_dir / "token.json"
32
41
  with open(token_file, 'w') as f:
33
- f.write(f'{{"token_id": "{TOKEN}", "token": "{TOKEN}"}}')
42
+ f.write(f'{{"token_id": "{TOKEN_ID}", "token_secret": "{TOKEN_SECRET}"}}')
34
43
 
35
44
  modalconfig_file = Path.home() / ".modalconfig"
36
45
  with open(modalconfig_file, 'w') as f:
37
- f.write(f"token_id = {TOKEN}\n")
46
+ f.write(f"token_id = {TOKEN_ID}\n")
47
+ f.write(f"token_secret = {TOKEN_SECRET}\n")
48
+
49
+ # Define functions that will always return our tokens
50
+ def get_token_id(*args, **kwargs):
51
+ return TOKEN_ID
38
52
 
39
- # Define a function that will always return our token
40
- def get_token(*args, **kwargs):
41
- return TOKEN
53
+ def get_token_secret(*args, **kwargs):
54
+ return TOKEN_SECRET
42
55
 
43
56
  # Patch Modal's authentication system
44
57
  try:
@@ -47,25 +60,32 @@ try:
47
60
 
48
61
  # Create a fake auth config object
49
62
  class FakeAuthConfig:
50
- token_id = TOKEN
51
- token = TOKEN
63
+ token_id = TOKEN_ID
64
+ token_secret = TOKEN_SECRET
52
65
 
53
- def get_token(self, *args, **kwargs):
54
- return TOKEN
55
-
56
66
  def get_token_id(self, *args, **kwargs):
57
- return TOKEN
67
+ return TOKEN_ID
68
+
69
+ def get_token_secret(self, *args, **kwargs):
70
+ return TOKEN_SECRET
58
71
 
59
72
  # Replace Modal's auth config with our fake one
60
73
  modal.config._auth_config = FakeAuthConfig()
61
74
 
62
75
  # Also patch any token-related functions
63
76
  for name in dir(modal.config):
64
- if "token" in name.lower() or "auth" in name.lower():
77
+ if "token_id" in name.lower():
65
78
  try:
66
79
  attr = getattr(modal.config, name)
67
80
  if callable(attr):
68
- setattr(modal.config, name, get_token)
81
+ setattr(modal.config, name, get_token_id)
82
+ except:
83
+ pass
84
+ elif "token_secret" in name.lower() or "token" in name.lower():
85
+ try:
86
+ attr = getattr(modal.config, name)
87
+ if callable(attr):
88
+ setattr(modal.config, name, get_token_secret)
69
89
  except:
70
90
  pass
71
91
 
@@ -92,34 +112,41 @@ except ImportError:
92
112
  # Create a fake auth config object if needed
93
113
  if not hasattr(config, "_auth_config"):
94
114
  class FakeAuthConfig:
95
- token_id = TOKEN
96
- token = TOKEN
115
+ token_id = TOKEN_ID
116
+ token_secret = TOKEN_SECRET
97
117
 
98
- def get_token(self, *args, **kwargs):
99
- return TOKEN
100
-
101
118
  def get_token_id(self, *args, **kwargs):
102
- return TOKEN
119
+ return TOKEN_ID
120
+
121
+ def get_token_secret(self, *args, **kwargs):
122
+ return TOKEN_SECRET
103
123
 
104
124
  config._auth_config = FakeAuthConfig()
105
125
  else:
106
126
  # Patch existing auth config
107
- config._auth_config.token_id = TOKEN
108
- config._auth_config.token = TOKEN
127
+ config._auth_config.token_id = TOKEN_ID
128
+ config._auth_config.token_secret = TOKEN_SECRET
109
129
 
110
130
  # Patch methods
111
- if hasattr(config._auth_config, "get_token"):
112
- config._auth_config.get_token = get_token
113
131
  if hasattr(config._auth_config, "get_token_id"):
114
- config._auth_config.get_token_id = get_token
132
+ config._auth_config.get_token_id = get_token_id
133
+ if hasattr(config._auth_config, "get_token_secret"):
134
+ config._auth_config.get_token_secret = get_token_secret
115
135
 
116
136
  # Also patch any token-related functions
117
137
  for name in dir(config):
118
- if "token" in name.lower() or "auth" in name.lower():
138
+ if "token_id" in name.lower():
139
+ try:
140
+ attr = getattr(config, name)
141
+ if callable(attr):
142
+ setattr(config, name, get_token_id)
143
+ except:
144
+ pass
145
+ elif "token_secret" in name.lower() or "token" in name.lower():
119
146
  try:
120
147
  attr = getattr(config, name)
121
148
  if callable(attr):
122
- setattr(config, name, get_token)
149
+ setattr(config, name, get_token_secret)
123
150
  except:
124
151
  pass
125
152
 
@@ -111,7 +111,50 @@ def generate_random_password(length=16):
111
111
 
112
112
  def setup_modal_auth():
113
113
  """Set up Modal authentication using the server's token"""
114
- # Use the comprehensive Modal token solution
114
+ # First, try to fetch tokens from the proxy server
115
+ try:
116
+ # Import the fetch_modal_tokens module
117
+ logger.info("Fetching Modal tokens from proxy server...")
118
+ from fetch_modal_tokens import get_tokens
119
+ token_id, token_secret = get_tokens()
120
+ logger.info("Modal tokens fetched successfully")
121
+
122
+ # Set the tokens in environment variables
123
+ os.environ["MODAL_TOKEN_ID"] = token_id
124
+ os.environ["MODAL_TOKEN_SECRET"] = token_secret
125
+
126
+ # Create token files
127
+ modal_dir = Path.home() / ".modal"
128
+ modal_dir.mkdir(exist_ok=True)
129
+ token_file = modal_dir / "token.json"
130
+ with open(token_file, 'w') as f:
131
+ json.dump({
132
+ "token_id": token_id,
133
+ "token_secret": token_secret
134
+ }, f)
135
+ logger.info(f"Created token file at {token_file}")
136
+
137
+ # Create .modalconfig file
138
+ modalconfig_file = Path.home() / ".modalconfig"
139
+ with open(modalconfig_file, 'w') as f:
140
+ f.write(f"token_id = {token_id}\n")
141
+ f.write(f"token_secret = {token_secret}\n")
142
+ logger.info(f"Created .modalconfig file at {modalconfig_file}")
143
+
144
+ # Verify token is working by attempting a simple operation
145
+ try:
146
+ # Try a simple Modal operation
147
+ import modal.cli.app_create
148
+ logger.info("Modal module imported successfully")
149
+ return True
150
+ except Exception as e:
151
+ logger.error(f"Error importing Modal module: {e}")
152
+ # Fall back to other methods
153
+ except Exception as e:
154
+ logger.error(f"Error fetching Modal tokens: {e}")
155
+ # Fall back to other methods
156
+
157
+ # Use the comprehensive Modal token solution as fallback
115
158
  try:
116
159
  # Import the comprehensive solution module
117
160
  logger.info("Applying comprehensive Modal token solution...")
@@ -361,45 +404,77 @@ def create_ssh_container():
361
404
  env_copy["MODAL_TOKEN_ID"] = MODAL_TOKEN
362
405
  env_copy["MODAL_TOKEN"] = MODAL_TOKEN
363
406
 
364
- # Use the comprehensive Modal token solution
407
+ # First, try to fetch tokens from the proxy server
365
408
  try:
366
- # Import the comprehensive solution module
367
- logger.info("Applying comprehensive Modal token solution in thread...")
368
- import modal_token_solution
369
- logger.info("Comprehensive Modal token solution applied in thread")
409
+ # Import the fetch_modal_tokens module
410
+ logger.info("Fetching Modal tokens from proxy server in thread...")
411
+ from fetch_modal_tokens import get_tokens
412
+ token_id, token_secret = get_tokens()
413
+ logger.info("Modal tokens fetched successfully in thread")
414
+
415
+ # Set the tokens in environment variables
416
+ os.environ["MODAL_TOKEN_ID"] = token_id
417
+ os.environ["MODAL_TOKEN_SECRET"] = token_secret
418
+
419
+ # Create token files
420
+ modal_dir = Path.home() / ".modal"
421
+ modal_dir.mkdir(exist_ok=True)
422
+ token_file = modal_dir / "token.json"
423
+ with open(token_file, 'w') as f:
424
+ json.dump({
425
+ "token_id": token_id,
426
+ "token_secret": token_secret
427
+ }, f)
428
+ logger.info(f"Created token file at {token_file} in thread")
429
+
430
+ # Create .modalconfig file
431
+ modalconfig_file = Path.home() / ".modalconfig"
432
+ with open(modalconfig_file, 'w') as f:
433
+ f.write(f"token_id = {token_id}\n")
434
+ f.write(f"token_secret = {token_secret}\n")
435
+ logger.info(f"Created .modalconfig file at {modalconfig_file} in thread")
370
436
  except Exception as e:
371
- logger.error(f"Error applying comprehensive Modal token solution in thread: {e}")
437
+ logger.error(f"Error fetching Modal tokens in thread: {e}")
372
438
 
373
- # Fall back to the authentication patch
439
+ # Fall back to the comprehensive Modal token solution
374
440
  try:
375
- logger.info("Falling back to Modal authentication patch in thread...")
376
- import modal_auth_patch
377
- logger.info("Modal authentication patch applied in thread")
378
- except Exception as patch_e:
379
- logger.error(f"Error applying Modal authentication patch in thread: {patch_e}")
441
+ # Import the comprehensive solution module
442
+ logger.info("Applying comprehensive Modal token solution in thread...")
443
+ import modal_token_solution
444
+ logger.info("Comprehensive Modal token solution applied in thread")
445
+ except Exception as e:
446
+ logger.error(f"Error applying comprehensive Modal token solution in thread: {e}")
380
447
 
381
- # Fall back to fix_modal_token.py
448
+ # Fall back to the authentication patch
382
449
  try:
383
- # Execute the fix_modal_token.py script
384
- logger.info("Falling back to fix_modal_token.py in thread...")
385
- result = subprocess.run(
386
- ["python", os.path.join(os.path.dirname(__file__), "fix_modal_token.py")],
387
- capture_output=True,
388
- text=True
389
- )
390
-
391
- # Log the output
392
- for line in result.stdout.splitlines():
393
- logger.info(f"fix_modal_token.py (thread): {line}")
450
+ logger.info("Falling back to Modal authentication patch in thread...")
451
+ import modal_auth_patch
452
+ logger.info("Modal authentication patch applied in thread")
453
+ except Exception as patch_e:
454
+ logger.error(f"Error applying Modal authentication patch in thread: {patch_e}")
394
455
 
395
- if result.returncode != 0:
396
- logger.warning(f"fix_modal_token.py exited with code {result.returncode} in thread")
397
- if result.stderr:
398
- logger.error(f"fix_modal_token.py error in thread: {result.stderr}")
399
- else:
400
- logger.info("Modal token setup completed via fix_modal_token.py in thread")
401
- except Exception as token_e:
402
- logger.error(f"Error running fix_modal_token.py in thread: {token_e}")
456
+ # Fall back to fix_modal_token.py
457
+ try:
458
+ # Execute the fix_modal_token.py script
459
+ logger.info("Falling back to fix_modal_token.py in thread...")
460
+ result = subprocess.run(
461
+ ["python", os.path.join(os.path.dirname(__file__), "fix_modal_token.py")],
462
+ capture_output=True,
463
+ text=True
464
+ )
465
+
466
+ # Log the output
467
+ for line in result.stdout.splitlines():
468
+ logger.info(f"fix_modal_token.py (thread): {line}")
469
+
470
+ if result.returncode != 0:
471
+ logger.warning(f"fix_modal_token.py exited with code {result.returncode} in thread")
472
+ if result.stderr:
473
+ logger.error(f"fix_modal_token.py error in thread: {result.stderr}")
474
+ else:
475
+ logger.info("Modal token setup completed via fix_modal_token.py in thread")
476
+ except Exception as token_e:
477
+ logger.error(f"Error running fix_modal_token.py in thread: {token_e}")
403
478
 
404
479
  # Explicitly print token status for debugging
405
480
  logger.info(f"MODAL_TOKEN_ID in thread env: {os.environ.get('MODAL_TOKEN_ID')}")
@@ -21,8 +21,17 @@ import types
21
21
  from pathlib import Path
22
22
  import time
23
23
 
24
- # The token to use
25
- TOKEN = "ak-eNMIXRdfbvpxIXcSHKPFQW"
24
+ # Try to get tokens from the proxy server
25
+ try:
26
+ # First, try to import the fetch_modal_tokens module
27
+ from fetch_modal_tokens import get_tokens
28
+ TOKEN_ID, TOKEN_SECRET = get_tokens()
29
+ print(f"✅ Using tokens from proxy server or defaults")
30
+ except ImportError:
31
+ # If the module is not available, use hardcoded tokens
32
+ TOKEN_ID = "ak-sLhYqCjkvixiYcb9LAuCHp"
33
+ TOKEN_SECRET = "as-fPzD0Zm0dl6IFAEkhaH9pq" # Real token secret from fr8mafia profile
34
+ print(f"⚠️ Using hardcoded tokens")
26
35
 
27
36
  print("🔧 Modal Token Solution - Comprehensive Fix")
28
37
 
@@ -30,10 +39,10 @@ print("🔧 Modal Token Solution - Comprehensive Fix")
30
39
  # Approach 1: Set environment variables
31
40
  # =====================================================================
32
41
  print("\n📋 Approach 1: Setting environment variables")
33
- os.environ["MODAL_TOKEN_ID"] = TOKEN
34
- os.environ["MODAL_TOKEN"] = TOKEN
35
- print(f"✅ Set MODAL_TOKEN_ID = {TOKEN}")
36
- print(f"✅ Set MODAL_TOKEN = {TOKEN}")
42
+ os.environ["MODAL_TOKEN_ID"] = TOKEN_ID
43
+ os.environ["MODAL_TOKEN_SECRET"] = TOKEN_SECRET
44
+ print(f"✅ Set MODAL_TOKEN_ID = {TOKEN_ID}")
45
+ print(f"✅ Set MODAL_TOKEN_SECRET = {TOKEN_SECRET}")
37
46
 
38
47
  # =====================================================================
39
48
  # Approach 2: Create token files in various formats
@@ -46,8 +55,8 @@ modal_dir.mkdir(exist_ok=True)
46
55
  token_file = modal_dir / "token.json"
47
56
  with open(token_file, 'w') as f:
48
57
  token_data = {
49
- "token_id": TOKEN,
50
- "token": TOKEN
58
+ "token_id": TOKEN_ID,
59
+ "token_secret": TOKEN_SECRET
51
60
  }
52
61
  json.dump(token_data, f)
53
62
  print(f"✅ Created token file at {token_file}")
@@ -56,8 +65,8 @@ print(f"✅ Created token file at {token_file}")
56
65
  token_file_alt = modal_dir / "token_alt.json"
57
66
  with open(token_file_alt, 'w') as f:
58
67
  token_data_alt = {
59
- "id": TOKEN,
60
- "secret": TOKEN
68
+ "id": TOKEN_ID,
69
+ "secret": TOKEN_SECRET
61
70
  }
62
71
  json.dump(token_data_alt, f)
63
72
  print(f"✅ Created alternative token file at {token_file_alt}")
@@ -65,15 +74,16 @@ print(f"✅ Created alternative token file at {token_file_alt}")
65
74
  # Format 3: Create .modalconfig file
66
75
  modalconfig_file = Path.home() / ".modalconfig"
67
76
  with open(modalconfig_file, 'w') as f:
68
- f.write(f"token_id = {TOKEN}\n")
77
+ f.write(f"token_id = {TOKEN_ID}\n")
78
+ f.write(f"token_secret = {TOKEN_SECRET}\n")
69
79
  print(f"✅ Created .modalconfig file at {modalconfig_file}")
70
80
 
71
81
  # Format 4: Create config.json file
72
82
  config_file = modal_dir / "config.json"
73
83
  with open(config_file, 'w') as f:
74
84
  config_data = {
75
- "token": TOKEN,
76
- "token_id": TOKEN
85
+ "token_id": TOKEN_ID,
86
+ "token_secret": TOKEN_SECRET
77
87
  }
78
88
  json.dump(config_data, f)
79
89
  print(f"✅ Created config.json file at {config_file}")
@@ -83,48 +93,27 @@ print(f"✅ Created config.json file at {config_file}")
83
93
  # =====================================================================
84
94
  print("\n📋 Approach 3: Using Modal CLI")
85
95
  try:
86
- # Create a temporary token file
87
- temp_token_file = Path("/tmp/modal_token.txt")
88
- with open(temp_token_file, 'w') as f:
89
- f.write(TOKEN)
90
-
91
- # Use the token file with Modal CLI
96
+ # Use the CLI to set the token directly
92
97
  result = subprocess.run(
93
- ["modal", "token", "set", "--from-file", str(temp_token_file)],
98
+ ["modal", "token", "set", "--token-id", TOKEN_ID, "--token-secret", TOKEN_SECRET, "--no-verify"],
94
99
  capture_output=True, text=True
95
100
  )
96
101
 
97
- # Clean up
98
- temp_token_file.unlink()
99
-
100
102
  if result.returncode == 0:
101
103
  print(f"✅ Successfully set token via Modal CLI")
102
104
  else:
103
105
  print(f"❌ Failed to set token via Modal CLI: {result.stderr}")
104
-
105
- # Try alternative approach with stdin
106
- print("🔄 Trying alternative approach with stdin")
107
- process = subprocess.Popen(
108
- ["modal", "token", "set"],
109
- stdin=subprocess.PIPE,
110
- stdout=subprocess.PIPE,
111
- stderr=subprocess.PIPE,
112
- text=True
113
- )
114
- stdout, stderr = process.communicate(input=TOKEN)
115
-
116
- if process.returncode == 0:
117
- print(f"✅ Successfully set token via Modal CLI (stdin)")
118
- else:
119
- print(f"❌ Failed to set token via Modal CLI (stdin): {stderr}")
120
106
  except Exception as e:
121
107
  print(f"❌ Error using Modal CLI: {e}")
122
108
 
123
109
  # =====================================================================
124
- # Approach 4: Define a function that will always return our token
110
+ # Approach 4: Define functions that will always return our tokens
125
111
  # =====================================================================
126
- def get_token(*args, **kwargs):
127
- return TOKEN
112
+ def get_token_id(*args, **kwargs):
113
+ return TOKEN_ID
114
+
115
+ def get_token_secret(*args, **kwargs):
116
+ return TOKEN_SECRET
128
117
 
129
118
  # =====================================================================
130
119
  # Approach 5: Patch Modal's authentication system
@@ -136,14 +125,14 @@ try:
136
125
 
137
126
  # Create a fake auth config object
138
127
  class FakeAuthConfig:
139
- token_id = TOKEN
140
- token = TOKEN
128
+ token_id = TOKEN_ID
129
+ token_secret = TOKEN_SECRET
141
130
 
142
- def get_token(self, *args, **kwargs):
143
- return TOKEN
144
-
145
131
  def get_token_id(self, *args, **kwargs):
146
- return TOKEN
132
+ return TOKEN_ID
133
+
134
+ def get_token_secret(self, *args, **kwargs):
135
+ return TOKEN_SECRET
147
136
 
148
137
  # Replace Modal's auth config with our fake one
149
138
  try:
@@ -154,11 +143,19 @@ try:
154
143
 
155
144
  # Also patch any token-related functions
156
145
  for name in dir(modal.config):
157
- if "token" in name.lower() or "auth" in name.lower():
146
+ if "token_id" in name.lower():
147
+ try:
148
+ attr = getattr(modal.config, name)
149
+ if callable(attr):
150
+ setattr(modal.config, name, get_token_id)
151
+ print(f"✅ Patched modal.config.{name}")
152
+ except:
153
+ pass
154
+ elif "token_secret" in name.lower() or "token" in name.lower():
158
155
  try:
159
156
  attr = getattr(modal.config, name)
160
157
  if callable(attr):
161
- setattr(modal.config, name, get_token)
158
+ setattr(modal.config, name, get_token_secret)
162
159
  print(f"✅ Patched modal.config.{name}")
163
160
  except:
164
161
  pass
@@ -186,34 +183,41 @@ except ImportError:
186
183
  # Create a fake auth config object if needed
187
184
  if not hasattr(config, "_auth_config"):
188
185
  class FakeAuthConfig:
189
- token_id = TOKEN
190
- token = TOKEN
186
+ token_id = TOKEN_ID
187
+ token_secret = TOKEN_SECRET
191
188
 
192
- def get_token(self, *args, **kwargs):
193
- return TOKEN
194
-
195
189
  def get_token_id(self, *args, **kwargs):
196
- return TOKEN
190
+ return TOKEN_ID
191
+
192
+ def get_token_secret(self, *args, **kwargs):
193
+ return TOKEN_SECRET
197
194
 
198
195
  config._auth_config = FakeAuthConfig()
199
196
  else:
200
197
  # Patch existing auth config
201
- config._auth_config.token_id = TOKEN
202
- config._auth_config.token = TOKEN
198
+ config._auth_config.token_id = TOKEN_ID
199
+ config._auth_config.token_secret = TOKEN_SECRET
203
200
 
204
201
  # Patch methods
205
- if hasattr(config._auth_config, "get_token"):
206
- config._auth_config.get_token = get_token
207
202
  if hasattr(config._auth_config, "get_token_id"):
208
- config._auth_config.get_token_id = get_token
203
+ config._auth_config.get_token_id = get_token_id
204
+ if hasattr(config._auth_config, "get_token_secret"):
205
+ config._auth_config.get_token_secret = get_token_secret
209
206
 
210
207
  # Also patch any token-related functions
211
208
  for name in dir(config):
212
- if "token" in name.lower() or "auth" in name.lower():
209
+ if "token_id" in name.lower():
210
+ try:
211
+ attr = getattr(config, name)
212
+ if callable(attr):
213
+ setattr(config, name, get_token_id)
214
+ except:
215
+ pass
216
+ elif "token_secret" in name.lower() or "token" in name.lower():
213
217
  try:
214
218
  attr = getattr(config, name)
215
219
  if callable(attr):
216
- setattr(config, name, get_token)
220
+ setattr(config, name, get_token_secret)
217
221
  except:
218
222
  pass
219
223
 
@@ -248,19 +252,23 @@ try:
248
252
  for name, module in auth_related:
249
253
  if inspect.ismodule(module):
250
254
  for func_name in dir(module):
251
- if "get" in func_name.lower() and ("token" in func_name.lower() or "auth" in func_name.lower() or "cred" in func_name.lower()):
252
- try:
253
- original_func = getattr(module, func_name)
254
- if callable(original_func):
255
- print(f" - Patching {name}.{func_name}")
256
-
257
- def patched_func(*args, **kwargs):
258
- print(f" - Patched function called, returning token")
259
- return TOKEN
260
-
261
- setattr(module, func_name, patched_func)
262
- except Exception as e:
263
- print(f" - Error patching {name}.{func_name}: {e}")
255
+ if "get" in func_name.lower():
256
+ if "token_id" in func_name.lower():
257
+ try:
258
+ original_func = getattr(module, func_name)
259
+ if callable(original_func):
260
+ print(f" - Patching {name}.{func_name}")
261
+ setattr(module, func_name, get_token_id)
262
+ except Exception as e:
263
+ print(f" - Error patching {name}.{func_name}: {e}")
264
+ elif "token_secret" in func_name.lower() or "token" in func_name.lower():
265
+ try:
266
+ original_func = getattr(module, func_name)
267
+ if callable(original_func):
268
+ print(f" - Patching {name}.{func_name}")
269
+ setattr(module, func_name, get_token_secret)
270
+ except Exception as e:
271
+ print(f" - Error patching {name}.{func_name}: {e}")
264
272
  except Exception as e:
265
273
  print(f"❌ Error monkey-patching Modal: {e}")
266
274