-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgrok_copilot_launcher.py
More file actions
308 lines (269 loc) Β· 12.3 KB
/
grok_copilot_launcher.py
File metadata and controls
308 lines (269 loc) Β· 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/usr/bin/env python3
"""
Grok Copilot Launcher (wrapper)
--------------------------------
Lightweight wrapper so you can run: python grok_copilot_launcher.py
Safely defers heavy imports (ipfs, exiftool, biconomy, MCP) until actually needed.
Use as a friendlier entrypoint around existing tooling in:
- grok_copilot_image_launcher.py
- agents/iem_syndicate.py
Commands:
(no args) Show status
install Install all required dependencies (Python, Node, Solana/Rust)
deploy-all Deploy complete Dream-Mind-Lucid ecosystem (all components)
deploy <Contract> Deploy contract via iem_syndicate (IEMDreams | OneiroSphere)
audit <Contract> Audit deployed contract
test Run dream recording test
Environment (optional):
DEPLOYER_KEY, SKALE_RPC, SKALE_CHAIN_ID, FORWARDER_ADDRESS, INFURA_PROJECT_ID
"""
import sys
import importlib
import shutil
import os
REPO_ROOT = os.path.dirname(os.path.abspath(__file__))
def status():
print("π Grok Copilot Launcher Ready")
print(" - Python:", sys.version.split()[0])
print(" - Working Dir:", REPO_ROOT)
# Lightweight dependency presence checks
mods = ["web3", "solcx", "ipfshttpclient", "PyExifTool", "mcp"]
available = []
for m in mods:
try:
importlib.import_module(m if m != "PyExifTool" else "exiftool")
available.append((m, True))
except Exception:
available.append((m, False))
print(" - Modules:")
for name, ok in available:
print(f" {name:14} {'β
' if ok else 'β οΈ missing'}")
if not any(ok for _, ok in available):
print(" Tip: pip install -r requirements.txt")
print(" - Launcher bridging to iem_syndicate & grok_copilot_image_launcher")
print(" - π OneiroBot integration available: try #oneirobot or #summon_oneirobot")
def run_syndicate(args):
try:
synd = importlib.import_module("agents.iem_syndicate")
except ModuleNotFoundError as e:
print(f"β Could not import iem_syndicate: {e}")
return 1
if not args:
print("Usage: deploy|audit|test ... (see file header)")
return 1
# Re-dispatch to the underlying functions without re-parsing argv globally
cmd = args[0].lower().lstrip('#') # allow hashtag style commands
if cmd == 'deploy_contract':
cmd = 'deploy'
if cmd == 'record_dream':
cmd = 'record'
try:
if cmd == "deploy":
if len(args) < 2:
print("β Specify contract (IEMDreams|OneiroSphere)")
return 1
synd.deploy_contract(args[1])
elif cmd == "audit":
target = args[1] if len(args) > 1 else "OneiroSphere"
synd.audit_contract(target)
elif cmd == "test":
synd.test_dream_recording()
else:
print(f"β Unknown command: {cmd}")
return 1
except Exception as exc:
print(f"β Error executing syndicate command: {exc}")
return 1
return 0
def run_install():
"""Install all required dependencies."""
print("π¦ Installing Dream-Mind-Lucid dependencies...")
try:
import subprocess
# 1. Install Python dependencies
print("π Installing Python dependencies...")
subprocess.run(["pip", "install", "web3", "py-solc-x", "mcp", "ipfshttpclient", "PyExifTool"], check=True)
# Install Solidity compiler
try:
from solcx import install_solc
install_solc("0.8.20")
except ImportError:
print("β οΈ Solidity compiler installation skipped - py-solc-x not available yet")
# Install from requirements.txt if available
if os.path.exists("requirements.txt"):
print("π Installing from requirements.txt...")
subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True)
print("β
Python dependencies installed!")
# 2. Install Node.js dependencies
print("π¦ Installing Node.js dependencies...")
subprocess.run(["npm", "install"], check=True, cwd=".")
if os.path.exists("evm"):
subprocess.run(["npm", "install"], check=True, cwd="evm")
print("β
Node.js dependencies installed!")
# 3. Install dashboard dependencies
if os.path.exists("dashboard/requirements.txt"):
print("π Installing dashboard dependencies...")
subprocess.run(["pip", "install", "-r", "dashboard/requirements.txt"], check=True)
print("β
Dashboard dependencies installed!")
# 4. Check Rust/Cargo availability
try:
result = subprocess.run(["cargo", "--version"], capture_output=True, text=True)
if result.returncode == 0:
print("π¦ Rust/Cargo detected:", result.stdout.strip())
# Test Solana program compilation
if os.path.exists("solana/programs"):
print("π Testing Solana program compilation...")
result = subprocess.run(["cargo", "check"], cwd="solana/programs", capture_output=True, text=True)
if result.returncode == 0:
print("β
Solana program compilation successful!")
else:
print("β οΈ Solana program compilation warnings (but successful)")
else:
print("β οΈ Rust/Cargo not available - Solana development disabled")
except FileNotFoundError:
print("β οΈ Rust/Cargo not found - Solana development disabled")
print("\nπ All dependencies installed successfully!")
print("π‘ Run 'python grok_copilot_launcher.py deploy-all' to deploy everything")
return 0
except subprocess.CalledProcessError as e:
print(f"β Installation failed: {e}")
print("π‘ Try running manually: pip install -r requirements.txt")
return 1
except Exception as e:
print(f"β Installation failed: {e}")
print("π‘ Try running manually: pip install -r requirements.txt")
return 1
def run_deploy_all():
"""Deploy all components of the Dream-Mind-Lucid ecosystem."""
print("π Starting complete Dream-Mind-Lucid deployment...")
try:
import subprocess
# 1. Run migration tests first to ensure everything is ready
print("π§ͺ Running pre-deployment tests...")
result = subprocess.run([sys.executable, "test_solana_migration.py"], capture_output=True, text=True)
if result.returncode == 0:
print("β
Pre-deployment tests passed!")
else:
print("β οΈ Some tests failed, but continuing with deployment")
print("Test output:", result.stdout[-500:]) # Show last 500 chars
# 2. Deploy Solana tokens (primary blockchain)
print("\nπ Deploying Solana tokens and programs...")
try:
result = subprocess.run([sys.executable, "agents/solana_dream_agent.py", "deploy_tokens"],
capture_output=True, text=True, timeout=120)
if result.returncode == 0:
print("β
Solana deployment successful!")
print("Output:", result.stdout[-300:]) # Show output summary
else:
print("β οΈ Solana deployment completed with warnings")
print("Output:", result.stdout[-300:])
except subprocess.TimeoutExpired:
print("β οΈ Solana deployment timed out but may still be running")
except Exception as e:
print(f"β οΈ Solana deployment issue: {e}")
# 3. Deploy SKALE contracts (legacy support)
print("\nβ‘ Deploying SKALE contracts...")
try:
# Deploy IEMDreams contract
synd = importlib.import_module("agents.iem_syndicate")
print("Deploying IEMDreams...")
synd.deploy_contract("IEMDreams")
print("Deploying OneiroSphere...")
synd.deploy_contract("OneiroSphere")
print("β
SKALE deployment successful!")
except Exception as e:
print(f"β οΈ SKALE deployment issue: {e}")
# 4. Deploy EVM contracts if Hardhat is available
print("\nπ Deploying EVM contracts...")
try:
if os.path.exists("evm/hardhat.config.js"):
result = subprocess.run(["npx", "hardhat", "compile"], cwd="evm", capture_output=True, text=True)
if result.returncode == 0:
print("β
EVM contracts compiled successfully!")
else:
print("β οΈ EVM compilation warnings:", result.stderr[-200:])
else:
print("β οΈ Hardhat config not found, skipping EVM deployment")
except Exception as e:
print(f"β οΈ EVM deployment issue: {e}")
# 5. Test the deployed system
print("\nπ§ͺ Running post-deployment tests...")
try:
result = subprocess.run([sys.executable, "test_deployment.py"], capture_output=True, text=True)
if result.returncode == 0:
print("β
Post-deployment tests passed!")
print("System status:", result.stdout[-400:])
else:
print("β οΈ Some post-deployment tests failed")
except Exception as e:
print(f"β οΈ Post-deployment test issue: {e}")
print("\nπ Deployment complete! The Dream-Mind-Lucid ecosystem is ready!")
print("π Next steps:")
print(" β’ Set environment variables for mainnet deployment")
print(" β’ Run 'python grok_copilot_launcher.py test' to verify functionality")
print(" β’ Start the dashboard: cd dashboard && streamlit run dream_dashboard.py")
print(" β’ Record your first dream via the agents or dashboard")
return 0
except Exception as e:
print(f"β Deployment failed: {e}")
return 1
def run_oneirobot(args):
"""Run OneiroBot commands via Copilot integration"""
try:
copilot_instruction = importlib.import_module("copilot-instruction")
except ModuleNotFoundError as e:
print(f"β Could not import copilot-instruction: {e}")
return 1
if not args:
print("Usage: oneirobot summon|status|scan|optimize|fix|help")
return 1
# Map command shortcuts to full commands
command_map = {
'summon': 'summon_oneirobot',
'status': 'oneirobot_status',
'scan': 'oneirobot_scan',
'optimize': 'oneirobot_optimize',
'fix': 'oneirobot_fix',
'help': 'oneirobot_help'
}
cmd = args[0].lower().lstrip('#')
full_command = command_map.get(cmd, cmd)
try:
# Use the handle_copilot_command function directly
result = copilot_instruction.handle_copilot_command(full_command, args[1:])
print(f"β
OneiroBot command '{cmd}' executed successfully")
return 0
except Exception as exc:
print(f"β Error executing OneiroBot command: {exc}")
return 1
def main():
if len(sys.argv) == 1:
status()
return 0
# Provide a minimal subcommand layer
sub = sys.argv[1].lower()
sub = sub.lstrip('#')
if sub in {"deploy", "audit", "test", "record", "deploy_contract", "record_dream"}:
return run_syndicate(sys.argv[1:])
elif sub in {"oneirobot", "oneiro", "summon_oneirobot", "oneirobot_status", "oneirobot_scan",
"oneirobot_optimize", "oneirobot_fix", "oneirobot_help"}:
return run_oneirobot(sys.argv[1:])
elif sub == "install":
return run_install()
elif sub in {"deploy-all", "deploy_all", "all"}:
return run_deploy_all()
elif sub == "image":
# Lazy run of the heavier image launcher
try:
mod = importlib.import_module("grok_copilot_image_launcher")
print("πΈ Image launcher module imported. (No auto-run main provided)")
except Exception as e:
print(f"β Failed to import image launcher: {e}")
return 1
return 0
else:
print(f"β Unknown subcommand: {sub}")
print("π‘ Available commands: install, deploy-all, deploy, audit, test, oneirobot, image")
return 1
if __name__ == "__main__":
raise SystemExit(main())