gitarsenal-cli 1.9.21 → 1.9.24

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.
Files changed (34) hide show
  1. package/.venv_status.json +1 -1
  2. package/package.json +1 -1
  3. package/python/__pycache__/auth_manager.cpython-313.pyc +0 -0
  4. package/python/__pycache__/command_manager.cpython-313.pyc +0 -0
  5. package/python/__pycache__/fetch_modal_tokens.cpython-313.pyc +0 -0
  6. package/python/__pycache__/llm_debugging.cpython-313.pyc +0 -0
  7. package/python/__pycache__/modal_container.cpython-313.pyc +0 -0
  8. package/python/__pycache__/shell.cpython-313.pyc +0 -0
  9. package/python/api_integration.py +0 -0
  10. package/python/command_manager.py +613 -0
  11. package/python/credentials_manager.py +0 -0
  12. package/python/fetch_modal_tokens.py +0 -0
  13. package/python/fix_modal_token.py +0 -0
  14. package/python/fix_modal_token_advanced.py +0 -0
  15. package/python/gitarsenal.py +0 -0
  16. package/python/gitarsenal_proxy_client.py +0 -0
  17. package/python/llm_debugging.py +1369 -0
  18. package/python/modal_container.py +626 -0
  19. package/python/setup.py +15 -0
  20. package/python/setup_modal_token.py +0 -39
  21. package/python/shell.py +627 -0
  22. package/python/test_modalSandboxScript.py +75 -2639
  23. package/scripts/postinstall.js +22 -23
  24. package/python/__pycache__/credentials_manager.cpython-313.pyc +0 -0
  25. package/python/__pycache__/test_modalSandboxScript.cpython-313.pyc +0 -0
  26. package/python/__pycache__/test_modalSandboxScript_stable.cpython-313.pyc +0 -0
  27. package/python/debug_delete.py +0 -167
  28. package/python/documentation.py +0 -76
  29. package/python/fix_setup_commands.py +0 -116
  30. package/python/modal_auth_patch.py +0 -178
  31. package/python/modal_proxy_service.py +0 -665
  32. package/python/modal_token_solution.py +0 -293
  33. package/python/test_dynamic_commands.py +0 -147
  34. package/test_modalSandboxScript.py +0 -5004
@@ -1,293 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Modal Token Solution
4
-
5
- This is a comprehensive solution that combines all our approaches to fix the Modal token issue.
6
- It should be imported before any Modal code is used.
7
-
8
- Usage:
9
- import modal_token_solution
10
- import modal
11
- # Now Modal will use our token
12
- """
13
-
14
- import os
15
- import sys
16
- import json
17
- import subprocess
18
- import importlib
19
- import inspect
20
- import types
21
- from pathlib import Path
22
- import time
23
-
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
- # print(f"⚠️ Using default tokens")
33
-
34
- print("🔧 Modal Token Solution - Comprehensive Fix")
35
-
36
- # =====================================================================
37
- # Approach 1: Set environment variables
38
- # =====================================================================
39
- print("\n📋 Approach 1: Setting environment variables")
40
- os.environ["MODAL_TOKEN_ID"] = TOKEN_ID
41
- os.environ["MODAL_TOKEN_SECRET"] = TOKEN_SECRET
42
- print(f"✅ Set MODAL_TOKEN_ID = [HIDDEN]")
43
- print(f"✅ Set MODAL_TOKEN_SECRET = [HIDDEN]")
44
-
45
- # =====================================================================
46
- # Approach 2: Create token files in various formats
47
- # =====================================================================
48
- print("\n📋 Approach 2: Creating token files in various formats")
49
- modal_dir = Path.home() / ".modal"
50
- modal_dir.mkdir(exist_ok=True)
51
-
52
- # Format 1: Standard token.json
53
- token_file = modal_dir / "token.json"
54
- with open(token_file, 'w') as f:
55
- token_data = {
56
- "token_id": TOKEN_ID,
57
- "token_secret": TOKEN_SECRET
58
- }
59
- json.dump(token_data, f)
60
- print(f"✅ Created token file at {token_file}")
61
-
62
- # Format 2: Alternative token.json format
63
- token_file_alt = modal_dir / "token_alt.json"
64
- with open(token_file_alt, 'w') as f:
65
- token_data_alt = {
66
- "id": TOKEN_ID,
67
- "secret": TOKEN_SECRET
68
- }
69
- json.dump(token_data_alt, f)
70
- print(f"✅ Created alternative token file at {token_file_alt}")
71
-
72
- # Format 3: Create .modalconfig file
73
- modalconfig_file = Path.home() / ".modalconfig"
74
- with open(modalconfig_file, 'w') as f:
75
- f.write(f"token_id = {TOKEN_ID}\n")
76
- f.write(f"token_secret = {TOKEN_SECRET}\n")
77
- print(f"✅ Created .modalconfig file at {modalconfig_file}")
78
-
79
- # Format 4: Create config.json file
80
- config_file = modal_dir / "config.json"
81
- with open(config_file, 'w') as f:
82
- config_data = {
83
- "token_id": TOKEN_ID,
84
- "token_secret": TOKEN_SECRET
85
- }
86
- json.dump(config_data, f)
87
- print(f"✅ Created config.json file at {config_file}")
88
-
89
- # =====================================================================
90
- # Approach 3: Use Modal CLI to set token
91
- # =====================================================================
92
- print("\n📋 Approach 3: Using Modal CLI")
93
- try:
94
- # Use the CLI to set the token directly
95
- result = subprocess.run(
96
- ["modal", "token", "set", "--token-id", TOKEN_ID, "--token-secret", TOKEN_SECRET, "--no-verify"],
97
- capture_output=True, text=True
98
- )
99
-
100
- if result.returncode == 0:
101
- print(f"✅ Successfully set token via Modal CLI")
102
- else:
103
- print(f"❌ Failed to set token via Modal CLI: {result.stderr}")
104
- except Exception as e:
105
- print(f"❌ Error using Modal CLI: {e}")
106
-
107
- # =====================================================================
108
- # Approach 4: Define functions that will always return our tokens
109
- # =====================================================================
110
- def get_token_id(*args, **kwargs):
111
- return TOKEN_ID
112
-
113
- def get_token_secret(*args, **kwargs):
114
- return TOKEN_SECRET
115
-
116
- # =====================================================================
117
- # Approach 5: Patch Modal's authentication system
118
- # =====================================================================
119
- print("\n📋 Approach 5: Patching Modal's authentication system")
120
- try:
121
- # Try to import modal.config
122
- import modal.config
123
-
124
- # Create a fake auth config object
125
- class FakeAuthConfig:
126
- token_id = TOKEN_ID
127
- token_secret = TOKEN_SECRET
128
-
129
- def get_token_id(self, *args, **kwargs):
130
- return TOKEN_ID
131
-
132
- def get_token_secret(self, *args, **kwargs):
133
- return TOKEN_SECRET
134
-
135
- # Replace Modal's auth config with our fake one
136
- try:
137
- modal.config._auth_config = FakeAuthConfig()
138
- print("✅ Replaced Modal's auth config with fake one")
139
- except Exception as e:
140
- print(f"❌ Error replacing auth config: {e}")
141
-
142
- # Also patch any token-related functions
143
- for name in dir(modal.config):
144
- if "token_id" in name.lower():
145
- try:
146
- attr = getattr(modal.config, name)
147
- if callable(attr):
148
- setattr(modal.config, name, get_token_id)
149
- print(f"✅ Patched modal.config.{name}")
150
- except:
151
- pass
152
- elif "token_secret" in name.lower() or "token" in name.lower():
153
- try:
154
- attr = getattr(modal.config, name)
155
- if callable(attr):
156
- setattr(modal.config, name, get_token_secret)
157
- print(f"✅ Patched modal.config.{name}")
158
- except:
159
- pass
160
-
161
- print("✅ Modal authentication patched successfully")
162
- except ImportError:
163
- # Modal not installed yet, we'll monkey-patch it when it's imported
164
- print("⚠️ Modal not installed yet, setting up import hook")
165
-
166
- # Original import function
167
- original_import = __import__
168
-
169
- # Our custom import function
170
- def custom_import(name, globals=None, locals=None, fromlist=(), level=0):
171
- # Call the original import function
172
- module = original_import(name, globals, locals, fromlist, level)
173
-
174
- # Check if this is modal or a submodule
175
- if name == "modal" or name.startswith("modal."):
176
- try:
177
- # Try to patch modal.config
178
- if hasattr(module, "config"):
179
- config = module.config
180
-
181
- # Create a fake auth config object if needed
182
- if not hasattr(config, "_auth_config"):
183
- class FakeAuthConfig:
184
- token_id = TOKEN_ID
185
- token_secret = TOKEN_SECRET
186
-
187
- def get_token_id(self, *args, **kwargs):
188
- return TOKEN_ID
189
-
190
- def get_token_secret(self, *args, **kwargs):
191
- return TOKEN_SECRET
192
-
193
- config._auth_config = FakeAuthConfig()
194
- else:
195
- # Patch existing auth config
196
- config._auth_config.token_id = TOKEN_ID
197
- config._auth_config.token_secret = TOKEN_SECRET
198
-
199
- # Patch methods
200
- if hasattr(config._auth_config, "get_token_id"):
201
- config._auth_config.get_token_id = get_token_id
202
- if hasattr(config._auth_config, "get_token_secret"):
203
- config._auth_config.get_token_secret = get_token_secret
204
-
205
- # Also patch any token-related functions
206
- for name in dir(config):
207
- if "token_id" in name.lower():
208
- try:
209
- attr = getattr(config, name)
210
- if callable(attr):
211
- setattr(config, name, get_token_id)
212
- except:
213
- pass
214
- elif "token_secret" in name.lower() or "token" in name.lower():
215
- try:
216
- attr = getattr(config, name)
217
- if callable(attr):
218
- setattr(config, name, get_token_secret)
219
- except:
220
- pass
221
-
222
- print("✅ Modal authentication patched during import")
223
- except Exception as e:
224
- print(f"⚠️ Error patching Modal: {e}")
225
-
226
- return module
227
-
228
- # Replace the built-in import function
229
- sys.modules["builtins"].__import__ = custom_import
230
-
231
- # =====================================================================
232
- # Approach 6: Monkey-patch Modal's authentication system
233
- # =====================================================================
234
- print("\n📋 Approach 6: Monkey-patching Modal's authentication system")
235
- try:
236
- import modal
237
-
238
- # Find all authentication-related classes and functions
239
- auth_related = []
240
- for module_name in dir(modal):
241
- if "auth" in module_name.lower() or "token" in module_name.lower() or "config" in module_name.lower():
242
- try:
243
- module = getattr(modal, module_name)
244
- auth_related.append((module_name, module))
245
- print(f"Found potential auth-related module: {module_name}")
246
- except Exception:
247
- pass
248
-
249
- # Try to monkey-patch auth functions to always return valid credentials
250
- for name, module in auth_related:
251
- if inspect.ismodule(module):
252
- for func_name in dir(module):
253
- if "get" in func_name.lower():
254
- if "token_id" in func_name.lower():
255
- try:
256
- original_func = getattr(module, func_name)
257
- if callable(original_func):
258
- print(f" - Patching {name}.{func_name}")
259
- setattr(module, func_name, get_token_id)
260
- except Exception as e:
261
- print(f" - Error patching {name}.{func_name}: {e}")
262
- elif "token_secret" in func_name.lower() or "token" in func_name.lower():
263
- try:
264
- original_func = getattr(module, func_name)
265
- if callable(original_func):
266
- print(f" - Patching {name}.{func_name}")
267
- setattr(module, func_name, get_token_secret)
268
- except Exception as e:
269
- print(f" - Error patching {name}.{func_name}: {e}")
270
- except Exception as e:
271
- print(f"❌ Error monkey-patching Modal: {e}")
272
-
273
- # =====================================================================
274
- # Approach 7: Create a test Modal app to verify token
275
- # =====================================================================
276
- print("\n📋 Approach 7: Testing Modal authentication")
277
- try:
278
- import modal
279
-
280
- print("Creating a test Modal app...")
281
- app = modal.App("test-auth")
282
-
283
- @app.function()
284
- def hello():
285
- return "Hello, world!"
286
-
287
- print("✅ Modal app created successfully")
288
- except ImportError:
289
- print("⚠️ Modal not installed, patch will be applied when it's imported")
290
- except Exception as e:
291
- print(f"❌ Error testing Modal patch: {e}")
292
-
293
- print("\n✅ Modal token solution applied successfully. Please try your command again.")
@@ -1,147 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Test script for the dynamic command list functionality.
4
- This demonstrates how the CommandListManager works with setup commands.
5
- """
6
-
7
- import sys
8
- import os
9
- import time
10
-
11
- # Add the current directory to the path so we can import from test_modalSandboxScript
12
- sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
13
-
14
- from test_modalSandboxScript import CommandListManager
15
-
16
- def simulate_command_execution(command, success_rate=0.8):
17
- """Simulate command execution with a given success rate."""
18
- import random
19
- time.sleep(0.1) # Simulate execution time
20
-
21
- success = random.random() < success_rate
22
- stdout = f"Simulated output for: {command}"
23
- stderr = "" if success else f"Simulated error for: {command}"
24
-
25
- return success, stdout, stderr
26
-
27
- def test_dynamic_command_list():
28
- """Test the dynamic command list functionality."""
29
- print("🧪 Testing Dynamic Command List Manager")
30
- print("=" * 60)
31
-
32
- # Initialize with some setup commands
33
- initial_commands = [
34
- "echo 'Starting setup...'",
35
- "pwd",
36
- "ls -la",
37
- "which python",
38
- "python --version"
39
- ]
40
-
41
- print(f"📋 Initial commands: {len(initial_commands)}")
42
- for i, cmd in enumerate(initial_commands, 1):
43
- print(f" {i}. {cmd}")
44
-
45
- # Create command list manager
46
- cmd_manager = CommandListManager(initial_commands)
47
-
48
- print(f"\n🔄 Starting command execution simulation...")
49
-
50
- # Simulate command execution
51
- while cmd_manager.has_pending_commands():
52
- next_cmd, cmd_type = cmd_manager.get_next_command()
53
-
54
- if not next_cmd:
55
- break
56
-
57
- # Print current status
58
- cmd_manager.print_status()
59
-
60
- if cmd_type == 'main':
61
- cmd_text = next_cmd['command']
62
- cmd_index = next_cmd['index']
63
-
64
- print(f"\n📋 Executing: {cmd_text}")
65
-
66
- # Simulate execution
67
- start_time = time.time()
68
- success, stdout, stderr = simulate_command_execution(cmd_text, success_rate=0.7)
69
- execution_time = time.time() - start_time
70
-
71
- # Mark as executed
72
- cmd_manager.mark_command_executed(
73
- cmd_index, 'main', success, stdout, stderr, execution_time
74
- )
75
-
76
- # If command failed, simulate adding a fix
77
- if not success:
78
- print(f"⚠️ Command failed, adding simulated fix...")
79
-
80
- # Simulate LLM suggesting a fix
81
- fix_command = f"echo 'Fix for: {cmd_text}'"
82
- fix_index = cmd_manager.add_suggested_fix(cmd_text, fix_command, "Simulated LLM fix")
83
-
84
- print(f"🔧 Added fix: {fix_command}")
85
-
86
- elif cmd_type == 'fix':
87
- cmd_text = next_cmd['fix_command']
88
- cmd_index = next_cmd['index']
89
-
90
- print(f"\n🔧 Executing fix: {cmd_text}")
91
-
92
- # Simulate execution
93
- start_time = time.time()
94
- success, stdout, stderr = simulate_command_execution(cmd_text, success_rate=0.9)
95
- execution_time = time.time() - start_time
96
-
97
- # Mark as executed
98
- cmd_manager.mark_command_executed(
99
- cmd_index, 'fix', success, stdout, stderr, execution_time
100
- )
101
-
102
- # Demonstrate dynamic command addition
103
- print(f"\n📋 Adding dynamic commands...")
104
- cmd_manager.add_command_dynamically("echo 'Dynamic command 1'", priority='normal')
105
- cmd_manager.add_command_dynamically("echo 'High priority command'", priority='high')
106
- cmd_manager.add_command_dynamically("echo 'Dynamic command 2'", priority='normal')
107
-
108
- # Execute the new commands
109
- print(f"\n🔄 Executing dynamic commands...")
110
- while cmd_manager.has_pending_commands():
111
- next_cmd, cmd_type = cmd_manager.get_next_command()
112
-
113
- if not next_cmd:
114
- break
115
-
116
- cmd_text = next_cmd['command']
117
- cmd_index = next_cmd['index']
118
-
119
- print(f"📋 Executing dynamic command: {cmd_text}")
120
-
121
- # Simulate execution
122
- start_time = time.time()
123
- success, stdout, stderr = simulate_command_execution(cmd_text, success_rate=0.9)
124
- execution_time = time.time() - start_time
125
-
126
- # Mark as executed
127
- cmd_manager.mark_command_executed(
128
- cmd_index, 'main', success, stdout, stderr, execution_time
129
- )
130
-
131
- # Print final status
132
- print(f"\n" + "=" * 60)
133
- print("🎉 FINAL STATUS")
134
- print("=" * 60)
135
- cmd_manager.print_status()
136
-
137
- # Show all commands with their status
138
- print(f"\n📋 All Commands Summary:")
139
- all_commands = cmd_manager.get_all_commands()
140
- for i, cmd in enumerate(all_commands, 1):
141
- status_icon = "✅" if cmd['status'] == 'success' else "❌" if cmd['status'] == 'failed' else "⏳"
142
- cmd_type = cmd.get('type', 'main')
143
- cmd_text = cmd.get('command', cmd.get('fix_command', 'Unknown command'))
144
- print(f" {i}. {status_icon} [{cmd_type}] {cmd_text}")
145
-
146
- if __name__ == "__main__":
147
- test_dynamic_command_list()