@agentxv2/gateway 0.1.1

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 (175) hide show
  1. package/.env.example +53 -0
  2. package/db/migrations/001_init.sql +117 -0
  3. package/db/migrations/002_agents.sql +20 -0
  4. package/db/migrations/003_a2a_results.sql +23 -0
  5. package/deploy/.env.deploy.example +23 -0
  6. package/deploy/add_swap_build.py +45 -0
  7. package/deploy/build_and_deploy.py +110 -0
  8. package/deploy/build_deploy_a2a.py +190 -0
  9. package/deploy/build_no_lint.py +52 -0
  10. package/deploy/build_on_fe.py +86 -0
  11. package/deploy/build_on_gw.py +98 -0
  12. package/deploy/build_prod.py +54 -0
  13. package/deploy/check_bal.py +31 -0
  14. package/deploy/check_code.py +47 -0
  15. package/deploy/check_deploy.sh +20 -0
  16. package/deploy/check_docs.py +16 -0
  17. package/deploy/check_frontend.py +42 -0
  18. package/deploy/check_frontend2.py +35 -0
  19. package/deploy/check_pks.py +34 -0
  20. package/deploy/check_status.py +32 -0
  21. package/deploy/check_v2.py +8 -0
  22. package/deploy/clean_install.py +28 -0
  23. package/deploy/deploy_a2a.py +58 -0
  24. package/deploy/deploy_a2a.sh +33 -0
  25. package/deploy/deploy_a2a_bg.sh +40 -0
  26. package/deploy/deploy_a2a_v2.py +151 -0
  27. package/deploy/deploy_a2a_v2.sh +36 -0
  28. package/deploy/deploy_bin.py +64 -0
  29. package/deploy/deploy_config.py +34 -0
  30. package/deploy/deploy_final.py +42 -0
  31. package/deploy/deploy_frontend.py +108 -0
  32. package/deploy/deploy_mcp.py +108 -0
  33. package/deploy/deploy_now.py +49 -0
  34. package/deploy/deploy_push_all.py +128 -0
  35. package/deploy/deploy_script.py +64 -0
  36. package/deploy/deploy_sep_a2a.sh +18 -0
  37. package/deploy/dev_mode.py +51 -0
  38. package/deploy/diag.py +12 -0
  39. package/deploy/diff_test.py +22 -0
  40. package/deploy/final_check.py +33 -0
  41. package/deploy/final_deploy.py +50 -0
  42. package/deploy/final_fix.py +54 -0
  43. package/deploy/final_push.py +114 -0
  44. package/deploy/find_frontend.py +38 -0
  45. package/deploy/fix_a2a.py +43 -0
  46. package/deploy/fix_and_build.py +77 -0
  47. package/deploy/fix_and_verify.py +56 -0
  48. package/deploy/fix_build.py +51 -0
  49. package/deploy/forge_deploy.py +67 -0
  50. package/deploy/full_push.py +101 -0
  51. package/deploy/full_push2.py +106 -0
  52. package/deploy/go_prod.py +59 -0
  53. package/deploy/gw_deploy.py +133 -0
  54. package/deploy/gw_final.py +206 -0
  55. package/deploy/gw_restart.py +28 -0
  56. package/deploy/gw_status.py +18 -0
  57. package/deploy/inline_build.py +99 -0
  58. package/deploy/one_shot.py +84 -0
  59. package/deploy/ox_deploy.py +32 -0
  60. package/deploy/pg_setup.py +36 -0
  61. package/deploy/prod_deploy.py +126 -0
  62. package/deploy/prod_final.py +140 -0
  63. package/deploy/prod_go.py +61 -0
  64. package/deploy/prod_one_shot.py +139 -0
  65. package/deploy/prod_setup.sh +62 -0
  66. package/deploy/prod_v2.py +91 -0
  67. package/deploy/prod_v3.py +103 -0
  68. package/deploy/push_docs.py +93 -0
  69. package/deploy/push_mcp.py +66 -0
  70. package/deploy/push_mcp_doc.py +28 -0
  71. package/deploy/push_v063.py +80 -0
  72. package/deploy/push_v2.py +71 -0
  73. package/deploy/qcheck.py +13 -0
  74. package/deploy/qcheck2.py +18 -0
  75. package/deploy/quick_check.py +8 -0
  76. package/deploy/rebuild.py +47 -0
  77. package/deploy/rebuild_frontend.py +44 -0
  78. package/deploy/restart.py +28 -0
  79. package/deploy/restore_frontend.py +42 -0
  80. package/deploy/restore_frontend2.py +41 -0
  81. package/deploy/restore_gateway.py +34 -0
  82. package/deploy/restore_quick.py +33 -0
  83. package/deploy/run_bash.py +19 -0
  84. package/deploy/run_sep.py +20 -0
  85. package/deploy/sdk_upgrade.py +50 -0
  86. package/deploy/server_prepare.py +41 -0
  87. package/deploy/server_setup.py +41 -0
  88. package/deploy/ssh_check.py +14 -0
  89. package/deploy/ssh_push.py +24 -0
  90. package/deploy/start_deploy.py +35 -0
  91. package/deploy/start_frontend.py +12 -0
  92. package/deploy/start_v2.py +29 -0
  93. package/deploy/stat.py +18 -0
  94. package/deploy/tail_log.py +11 -0
  95. package/deploy/update_env.py +32 -0
  96. package/deploy/upload_and_start.py +107 -0
  97. package/deploy/verify_a2a.py +13 -0
  98. package/deploy/verify_mcp.py +37 -0
  99. package/deploy/verify_sdk.py +21 -0
  100. package/dist/config.d.ts +26 -0
  101. package/dist/config.js +41 -0
  102. package/dist/config.js.map +1 -0
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +149 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/lib/crypto.d.ts +2 -0
  107. package/dist/lib/crypto.js +43 -0
  108. package/dist/lib/crypto.js.map +1 -0
  109. package/dist/lib/db.d.ts +3 -0
  110. package/dist/lib/db.js +26 -0
  111. package/dist/lib/db.js.map +1 -0
  112. package/dist/lib/ethers-utils.d.ts +60 -0
  113. package/dist/lib/ethers-utils.js +186 -0
  114. package/dist/lib/ethers-utils.js.map +1 -0
  115. package/dist/middleware/adminAuth.d.ts +2 -0
  116. package/dist/middleware/adminAuth.js +31 -0
  117. package/dist/middleware/adminAuth.js.map +1 -0
  118. package/dist/middleware/auth.d.ts +22 -0
  119. package/dist/middleware/auth.js +192 -0
  120. package/dist/middleware/auth.js.map +1 -0
  121. package/dist/middleware/error-handler.d.ts +36 -0
  122. package/dist/middleware/error-handler.js +100 -0
  123. package/dist/middleware/error-handler.js.map +1 -0
  124. package/dist/middleware/rate-limiter.d.ts +5 -0
  125. package/dist/middleware/rate-limiter.js +107 -0
  126. package/dist/middleware/rate-limiter.js.map +1 -0
  127. package/dist/routes/a2a.d.ts +2 -0
  128. package/dist/routes/a2a.js +84 -0
  129. package/dist/routes/a2a.js.map +1 -0
  130. package/dist/routes/admin.d.ts +2 -0
  131. package/dist/routes/admin.js +180 -0
  132. package/dist/routes/admin.js.map +1 -0
  133. package/dist/routes/agents.d.ts +2 -0
  134. package/dist/routes/agents.js +43 -0
  135. package/dist/routes/agents.js.map +1 -0
  136. package/dist/routes/chat.d.ts +2 -0
  137. package/dist/routes/chat.js +183 -0
  138. package/dist/routes/chat.js.map +1 -0
  139. package/dist/routes/history.d.ts +2 -0
  140. package/dist/routes/history.js +92 -0
  141. package/dist/routes/history.js.map +1 -0
  142. package/dist/routes/mcp.d.ts +13 -0
  143. package/dist/routes/mcp.js +513 -0
  144. package/dist/routes/mcp.js.map +1 -0
  145. package/dist/routes/tenant.d.ts +2 -0
  146. package/dist/routes/tenant.js +154 -0
  147. package/dist/routes/tenant.js.map +1 -0
  148. package/dist/services/a2a-worker.d.ts +7 -0
  149. package/dist/services/a2a-worker.js +406 -0
  150. package/dist/services/a2a-worker.js.map +1 -0
  151. package/dist/services/agent-indexer.d.ts +4 -0
  152. package/dist/services/agent-indexer.js +124 -0
  153. package/dist/services/agent-indexer.js.map +1 -0
  154. package/e2e_wallet.js +175 -0
  155. package/ecosystem.config.js +17 -0
  156. package/package.json +33 -0
  157. package/src/config.ts +47 -0
  158. package/src/index.ts +143 -0
  159. package/src/lib/crypto.ts +44 -0
  160. package/src/lib/db.ts +25 -0
  161. package/src/lib/ethers-utils.ts +229 -0
  162. package/src/middleware/adminAuth.ts +34 -0
  163. package/src/middleware/auth.ts +244 -0
  164. package/src/middleware/error-handler.ts +109 -0
  165. package/src/middleware/rate-limiter.ts +115 -0
  166. package/src/routes/a2a.ts +97 -0
  167. package/src/routes/admin.ts +219 -0
  168. package/src/routes/agents.ts +52 -0
  169. package/src/routes/chat.ts +219 -0
  170. package/src/routes/history.ts +114 -0
  171. package/src/routes/mcp.ts +567 -0
  172. package/src/routes/tenant.ts +196 -0
  173. package/src/services/a2a-worker.ts +486 -0
  174. package/src/services/agent-indexer.ts +127 -0
  175. package/tsconfig.json +18 -0
@@ -0,0 +1,128 @@
1
+ import paramiko, tarfile, os, base64, time
2
+
3
+ GW_HOST = '43.156.225.164'
4
+ GIT_HOST = '43.156.78.59'
5
+ PWD = 'Asdf1234!'
6
+
7
+ GW_LOCAL = r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\gateway'
8
+ TARPATH = r'c:\Users\apply\Downloads\code\agentx_gw_v2.tar.gz'
9
+ GW_APP = '/home/ubuntu/agentx-gateway'
10
+
11
+ # ── 1. Build tar ──────────────────────────────────────────────────────
12
+ print("=== Tar ===")
13
+ with tarfile.open(TARPATH, 'w:gz') as tar:
14
+ for root, dirs, files in os.walk(GW_LOCAL):
15
+ dirs[:] = [d for d in dirs if d not in ('node_modules','dist','.git')]
16
+ for f in files:
17
+ if f in ('.env',) or f.endswith('.tar.gz'): continue
18
+ full = os.path.join(root, f)
19
+ arc = os.path.relpath(full, GW_LOCAL).replace('\\','/')
20
+ tar.add(full, arcname=arc)
21
+ print(f"{os.path.getsize(TARPATH)//1024} KB")
22
+
23
+ # ── 2. Upload to production ──────────────────────────────────────────
24
+ print("\n=== Upload to 164 ===")
25
+ t = paramiko.Transport((GW_HOST, 22))
26
+ t.connect(username='ubuntu', password=PWD)
27
+ s = paramiko.SFTPClient.from_transport(t)
28
+ s.put(TARPATH, '/tmp/gw_v2.tar.gz')
29
+ s.close()
30
+ t.close()
31
+
32
+ # ── 3. Build + deploy Gateway ────────────────────────────────────────
33
+ c = paramiko.SSHClient()
34
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
35
+ c.connect(GW_HOST, username='ubuntu', password=PWD, timeout=30)
36
+
37
+ c.exec_command(f"cd {GW_APP} && tar xzf /tmp/gw_v2.tar.gz --overwrite && echo 'EXTRACTED' && ls src/routes/mcp.ts src/config.ts", timeout=10)
38
+
39
+ # Add RPC_URL_OXACHAIN to .env if missing
40
+ stdin, stdout, stderr = c.exec_command(f"grep RPC_URL_OXACHAIN {GW_APP}/.env || echo 'RPC_URL_OXACHAIN=http://43.156.99.215:18545' >> {GW_APP}/.env && echo 'ENV OK'")
41
+ print(stdout.read().decode().strip())
42
+
43
+ # Build
44
+ print("\n=== tsc ===")
45
+ stdin, stdout, stderr = c.exec_command(f"cd {GW_APP} && ./node_modules/.bin/tsc 2>&1 | tail -5; echo 'EXIT='$?", timeout=120)
46
+ out = stdout.read().decode()
47
+ print(out[-300:])
48
+
49
+ stdin, stdout, stderr = c.exec_command(f"ls {GW_APP}/dist/routes/mcp.js && echo BUILD_OK || echo BUILD_FAILED")
50
+ print(stdout.read().decode().strip())
51
+
52
+ # Restart
53
+ print("\n=== Restart Gateway ===")
54
+ c.exec_command("fuser -k 3090/tcp 2>/dev/null; sleep 2", timeout=10)
55
+ c.exec_command(f"cd {GW_APP} && nohup node dist/index.js > /tmp/gw.log 2>&1 & disown", timeout=5)
56
+ time.sleep(5)
57
+
58
+ # Verify
59
+ stdin, stdout, stderr = c.exec_command("ss -tlnp | grep 3090 && curl -s http://localhost:3090/api/v1/health")
60
+ print(stdout.read().decode())
61
+
62
+ import json
63
+ # Test dual-chain health
64
+ stdin, stdout, stderr = c.exec_command(
65
+ 'curl -s -X POST http://localhost:3090/mcp -H "Content-Type: application/json" -d \'{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"agentx_gateway_health","arguments":{}}}\''
66
+ )
67
+ data = json.loads(stdout.read().decode())
68
+ chains = data.get('result', {}).get('content', [{}])[0].get('text', '{}')
69
+ try:
70
+ h = json.loads(chains) if isinstance(chains, str) else chains
71
+ ox = h.get('chains', {}).get('oxachain', {})
72
+ print(f"\nMCP dual-chain: Sepolia={h.get('chains',{}).get('sepolia',{}).get('chainId')}, OxaChain={ox.get('chainId')}, A2A={ox.get('a2aProtocol','')[:10]}...")
73
+ except: pass
74
+
75
+ c.close()
76
+ print("\n✅ Gateway v0.2.0 deployed — dual-chain MCP on 164:3090")
77
+
78
+ # ── 4. Push to GitHub ─────────────────────────────────────────────────
79
+ print("\n=== Push to GitHub ===")
80
+
81
+ # Read final files
82
+ with open(GW_LOCAL + r'\src\routes\mcp.ts', 'r', encoding='utf-8') as f: mcp = f.read()
83
+ with open(GW_LOCAL + r'\src\config.ts', 'r', encoding='utf-8') as f: cfg = f.read()
84
+ with open(GW_LOCAL + r'\src\index.ts', 'r', encoding='utf-8') as f: idx = f.read()
85
+ with open(MCP_DOC := r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\MCP_SETUP.md', 'r', encoding='utf-8') as f: mcp_doc = f.read()
86
+
87
+ b_mcp = base64.b64encode(mcp.encode()).decode()
88
+ b_cfg = base64.b64encode(cfg.encode()).decode()
89
+ b_idx = base64.b64encode(idx.encode()).decode()
90
+ b_doc = base64.b64encode(mcp_doc.encode()).decode()
91
+
92
+ push = f'''#!/bin/bash
93
+ set -e
94
+ cd /tmp && rm -rf axpush && git clone git@github.com:sftgroup/Agentx.git axpush
95
+ cd axpush
96
+ echo '{b_mcp}' | base64 -d > gateway/src/routes/mcp.ts
97
+ echo '{b_cfg}' | base64 -d > gateway/src/config.ts
98
+ echo '{b_idx}' | base64 -d > gateway/src/index.ts
99
+ echo '{b_doc}' | base64 -d > MCP_SETUP.md
100
+ git add -A
101
+ git diff --cached --stat --stat=100
102
+ git commit -m "feat: MCP dual-chain support — Sepolia + OxaChain L1
103
+
104
+ Gateway /mcp now supports chain parameter:
105
+ - tools/call with {{\"chain\":\"sepolia\"}} (default) or {{\"chain\":\"oxachain\"}}
106
+ - All 6 contracts on both chains configured via .env
107
+ - Health endpoint returns both chain contract addresses
108
+ - MCP_SETUP.md updated with full dual-chain address table
109
+ " 2>&1
110
+ git push origin main 2>&1
111
+ git tag -f v0.6.4 2>/dev/null
112
+ git tag -f -a v0.6.4 -m "v0.6.4 — MCP dual-chain (Sepolia + OxaChain L1), 29 platform tools" 2>&1
113
+ git push origin v0.6.4 --force 2>&1
114
+ echo "PUSH_OK"
115
+ '''
116
+
117
+ pb = base64.b64encode(push.encode()).decode()
118
+ c2 = paramiko.SSHClient()
119
+ c2.set_missing_host_key_policy(paramiko.AutoAddPolicy())
120
+ c2.connect(GIT_HOST, username='ubuntu', password=PWD, timeout=30)
121
+ stdin, stdout, stderr = c2.exec_command(f"echo '{pb}' | base64 -d | bash 2>&1")
122
+ print(stdout.read().decode())
123
+ err = stderr.read().decode()
124
+ if err: print("E:", err[-300:])
125
+ c2.close()
126
+
127
+ print("\n✅ All done — production deployed + GitHub pushed")
128
+ print(" MCP: http://43.156.225.164:3090/mcp (Sepolia + OxaChain L1)")
@@ -0,0 +1,64 @@
1
+ import paramiko, os
2
+
3
+ c = paramiko.SSHClient()
4
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
5
+ c.connect('43.156.78.59', username='ubuntu', password='Asdf1234!', timeout=30)
6
+
7
+ def run(cmd):
8
+ print(f"> {cmd[:120]}")
9
+ stdin, stdout, stderr = c.exec_command(cmd, timeout=600)
10
+ out = stdout.read().decode()
11
+ err = stderr.read().decode()
12
+ ec = stdout.channel.recv_exit_status()
13
+ if out: print(out[-600:])
14
+ if err: print("E:", err[-400:])
15
+ return ec, out, err
16
+
17
+ # Ensure symlink
18
+ run("export PATH=$HOME/.foundry/bin:$PATH && cd /tmp/a2a_build/src && ln -sf erc8004-interfaces interfaces")
19
+
20
+ # Try forge script approach - pass IDENTITY_REGISTRY and PRIVATE_KEY as env
21
+ # Write .env file for the script
22
+ env_sep = """IDENTITY_REGISTRY=0xe94ad380d3F8d08a7590eda0C84f354a93F96e5F
23
+ PRIVATE_KEY=0x872c3190b82d17b29bb046c9c55a7f7390c7f74bd6d592ba8d211f20f896f28e
24
+ """
25
+ env_ox = """IDENTITY_REGISTRY=0xbf5F9db266c8c97E3334466C88597Eb758AfE212
26
+ PRIVATE_KEY=0x872c3190b82d17b29bb046c9c55a7f7390c7f74bd6d592ba8d211f20f896f28e
27
+ """
28
+ import base64
29
+ b64 = base64.b64encode(env_sep.encode()).decode()
30
+ run(f"echo '{b64}' | base64 -d > /tmp/a2a_build/.env && echo 'env written'")
31
+
32
+ # Sepolia deploy via forge script
33
+ print("\n=== SEPOLIA DEPLOY ===")
34
+ ec, out, err = run(
35
+ "export PATH=$HOME/.foundry/bin:$PATH && cd /tmp/a2a_build && "
36
+ "source .env && "
37
+ "forge script script/DeployA2A.s.sol:DeployA2A "
38
+ "--rpc-url https://ethereum-sepolia-rpc.publicnode.com "
39
+ "--broadcast --legacy 2>&1 | tail -30"
40
+ )
41
+
42
+ # Check for deployed address
43
+ for line in (out+err).split('\n'):
44
+ if 'Deployed at' in line or '0x' in line[:10]:
45
+ print(f" >> {line.strip()}")
46
+
47
+ # OxaChain deploy
48
+ print("\n=== OXACHAIN DEPLOY ===")
49
+ b64 = base64.b64encode(env_ox.encode()).decode()
50
+ run(f"echo '{b64}' | base64 -d > /tmp/a2a_build/.env && echo 'env written'")
51
+
52
+ ec, out, err = run(
53
+ "export PATH=$HOME/.foundry/bin:$PATH && cd /tmp/a2a_build && "
54
+ "source .env && "
55
+ "forge script script/DeployA2A.s.sol:DeployA2A "
56
+ "--rpc-url http://43.156.99.215:18545 "
57
+ "--broadcast --legacy 2>&1 | tail -30"
58
+ )
59
+
60
+ for line in (out+err).split('\n'):
61
+ if 'Deployed at' in line or '0x' in line[:10]:
62
+ print(f" >> {line.strip()}")
63
+
64
+ c.close()
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ export PATH=$HOME/.foundry/bin:$PATH
3
+ cd /tmp/a2a_build
4
+ ln -sf erc8004-interfaces src/interfaces
5
+
6
+ PK=0x9ff7f5511067c86fdd8c1dee11799e4778e4b1e86e5093d53eae8d4af356a424
7
+ SEP_IR=0xe94ad380d3F8d08a7590eda0C84f354a93F96e5F
8
+
9
+ echo "===== DEPLOYING SEPOLIA ====="
10
+ cat > .env << ENVEOF
11
+ IDENTITY_REGISTRY=$SEP_IR
12
+ PRIVATE_KEY=$PK
13
+ ENVEOF
14
+
15
+ forge script script/DeployA2A.s.sol:DeployA2A \
16
+ --rpc-url https://ethereum-sepolia-rpc.publicnode.com \
17
+ --broadcast --legacy \
18
+ 2>&1
@@ -0,0 +1,51 @@
1
+ import paramiko
2
+
3
+ host = '43.156.78.59'
4
+ user = 'ubuntu'
5
+ password = 'Asdf1234!'
6
+
7
+ client = paramiko.SSHClient()
8
+ client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
9
+ client.connect(host, username=user, password=password, timeout=15)
10
+
11
+ def run(cmd):
12
+ print(f"> {cmd}")
13
+ stdin, stdout, stderr = client.exec_command(cmd)
14
+ out = stdout.read().decode()
15
+ err = stderr.read().decode()
16
+ stdout.channel.recv_exit_status()
17
+ if out: print(out[-500:] if len(out) > 500 else out)
18
+ if err: print("ERR:", err[-300:] if len(err) > 300 else err)
19
+ return out
20
+
21
+ # Kill everything on port 8080 and pending npm/next
22
+ print("=== Killing old processes ===")
23
+ run("pkill -f 'next-server' 2>/dev/null; pkill -f 'next build' 2>/dev/null; pkill -f 'next dev' 2>/dev/null; sleep 2; echo done")
24
+ run("fuser -k 8080/tcp 2>/dev/null; echo done")
25
+
26
+ # Ensure node_modules are there (full install without --production)
27
+ print("\n=== Checking node_modules ===")
28
+ run("ls ~/agentx-platform/node_modules/tailwindcss/package.json 2>/dev/null && echo 'tailwind OK' || echo 'MISSING tailwind'")
29
+
30
+ # Start with next dev on port 8080 (auto-compiles TSX and has hot reload)
31
+ # Use NODE_OPTIONS to limit memory
32
+ print("\n=== Starting Next.js dev server ===")
33
+ run("cd ~/agentx-platform && NODE_OPTIONS='--max-old-space-size=512' nohup npx next dev -p 8080 -H 0.0.0.0 > /tmp/next-dev.log 2>&1 &")
34
+
35
+ import time
36
+ time.sleep(8)
37
+
38
+ # Check if it started
39
+ print("\n=== Checking if dev server started ===")
40
+ run("ss -tlnp | grep 8080 2>/dev/null")
41
+ run("tail -20 /tmp/next-dev.log 2>/dev/null")
42
+
43
+ time.sleep(3)
44
+ run("curl -s -o /dev/null -w 'HTTP %{http_code}\n' http://localhost:8080/ 2>&1")
45
+
46
+ # Check for compile errors
47
+ print("\n=== Recent logs ===")
48
+ run("tail -30 /tmp/next-dev.log 2>/dev/null")
49
+
50
+ client.close()
51
+ print("\n=== Done ===")
package/deploy/diag.py ADDED
@@ -0,0 +1,12 @@
1
+ import paramiko
2
+ c = paramiko.SSHClient()
3
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
4
+ c.connect('43.156.225.164', username='ubuntu', password='Asdf1234!', timeout=10)
5
+
6
+ stdin, stdout, stderr = c.exec_command(
7
+ "grep -B2 -A20 'Build error' /tmp/agentx-deploy.log 2>/dev/null | head -30; "
8
+ "echo '===FILES==='; ls /home/ubuntu/agentx-platform/app/ 2>/dev/null | head -5; "
9
+ "echo '===PKG==='; head -5 /home/ubuntu/agentx-platform/package.json 2>/dev/null"
10
+ )
11
+ print(stdout.read().decode())
12
+ c.close()
@@ -0,0 +1,22 @@
1
+ import paramiko
2
+
3
+ c = paramiko.SSHClient()
4
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
5
+ c.connect('43.156.78.59', username='ubuntu', password='Asdf1234!', timeout=10)
6
+
7
+ # Check what was modified on test server directly
8
+ cmds = [
9
+ "echo '=== A2A page ===' && grep 'A2A_REGISTRY\\|A2A_PROTOCOL' /home/ubuntu/agentx-platform/app/a2a/page.tsx 2>/dev/null | head -5",
10
+ "echo '=== next.config ===' && head -10 /home/ubuntu/agentx-platform/next.config.js 2>/dev/null",
11
+ "echo '=== SDK config (if exists) ===' && grep -r 'a2aProtocolRegistry' /home/ubuntu/agentx-platform/node_modules/@agentxv2/sdk/dist/ 2>/dev/null | head -5",
12
+ "echo '=== gateway src ===' && ls /tmp/a2a_build/src/erc8004-extensions/ 2>/dev/null",
13
+ ]
14
+
15
+ for cmd in cmds:
16
+ stdin, stdout, stderr = c.exec_command(cmd)
17
+ out = stdout.read().decode().strip()
18
+ if out: print(out)
19
+ err = stderr.read().decode().strip()
20
+ if err: print("E:", err[:200])
21
+
22
+ c.close()
@@ -0,0 +1,33 @@
1
+ import paramiko
2
+
3
+ host_f = '43.156.78.59'
4
+ c = paramiko.SSHClient()
5
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
6
+ c.connect(host_f, username='ubuntu', password='Asdf1234!', timeout=10)
7
+
8
+ def run(cmd):
9
+ stdin, stdout, stderr = c.exec_command(cmd)
10
+ out = stdout.read().decode()
11
+ err = stderr.read().decode()
12
+ stdout.channel.recv_exit_status()
13
+ if out: print(out)
14
+ if err and 'curl' not in cmd: print("ERR:", err[-200:])
15
+ return out
16
+
17
+ print("=== HTTP Test ===")
18
+ result = run("curl -I http://localhost:8080/ 2>&1 | head -5")
19
+ print(f"Result: {result}")
20
+
21
+ print("\n=== Full log ===")
22
+ run("tail -10 /tmp/n8080.log 2>/dev/null")
23
+
24
+ print("\n=== PM2 on gateway ===")
25
+ host_g = '101.33.109.117'
26
+ c2 = paramiko.SSHClient()
27
+ c2.set_missing_host_key_policy(paramiko.AutoAddPolicy())
28
+ c2.connect(host_g, username='ubuntu', password='Asdf1234!', timeout=10)
29
+ stdin, stdout, stderr = c2.exec_command("pm2 list && curl -s http://localhost:3090/api/v1/health")
30
+ print(stdout.read().decode())
31
+ c2.close()
32
+
33
+ c.close()
@@ -0,0 +1,50 @@
1
+ import paramiko
2
+ import base64
3
+
4
+ c = paramiko.SSHClient()
5
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
6
+ c.connect('43.156.78.59', username='ubuntu', password='Asdf1234!', timeout=30)
7
+
8
+ # Upload .env.production
9
+ with open(r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend\.env.production', 'r') as f:
10
+ env = f.read()
11
+ b64 = base64.b64encode(env.encode()).decode()
12
+ stdin, stdout, stderr = c.exec_command(
13
+ f"echo '{b64}' | base64 -d > /home/ubuntu/agentx-platform/.env.production && echo 'env ok' && grep A2A /home/ubuntu/agentx-platform/.env.production"
14
+ )
15
+ print(stdout.read().decode())
16
+
17
+ # Kill old + build + start
18
+ print("\n=== Building ===")
19
+ stdin, stdout, stderr = c.exec_command(
20
+ "fuser -k 8080/tcp 2>/dev/null; pkill -f 'next' 2>/dev/null; sleep 1; "
21
+ "cd /home/ubuntu/agentx-platform && NODE_OPTIONS='--max-old-space-size=1536' npx next build 2>&1 | tail -15",
22
+ timeout=600
23
+ )
24
+ out = stdout.read().decode()
25
+ err = stderr.read().decode()
26
+ ec = stdout.channel.recv_exit_status()
27
+ print(out)
28
+ if err: print("ERR:", err[-300:])
29
+ print(f"Build exit: {ec}")
30
+
31
+ if ec != 0:
32
+ print("BUILD FAILED")
33
+ c.close()
34
+ exit(1)
35
+
36
+ # Start
37
+ print("\n=== Starting ===")
38
+ stdin, stdout, stderr = c.exec_command(
39
+ "cd /home/ubuntu/agentx-platform && nohup npx next start -p 8080 > /tmp/fe-a2av2.log 2>&1 &",
40
+ timeout=5
41
+ )
42
+ import time; time.sleep(5)
43
+
44
+ stdin, stdout, stderr = c.exec_command("ss -tlnp | grep 8080")
45
+ print(stdout.read().decode())
46
+ stdin, stdout, stderr = c.exec_command("tail -2 /tmp/fe-a2av2.log")
47
+ print(stdout.read().decode())
48
+
49
+ c.close()
50
+ print("\n=== DONE ===")
@@ -0,0 +1,54 @@
1
+ import paramiko
2
+ import time
3
+
4
+ host_f = '43.156.78.59'
5
+ host_g = '101.33.109.117'
6
+ user = 'ubuntu'
7
+ password = 'Asdf1234!'
8
+
9
+ # First restart gateway PM2
10
+ print("=== Restarting Gateway ===")
11
+ c = paramiko.SSHClient()
12
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
13
+ c.connect(host_g, username=user, password=password, timeout=10)
14
+
15
+ def run(client, cmd, desc=""):
16
+ print(f"[{desc}] > {cmd[:80]}")
17
+ stdin, stdout, stderr = client.exec_command(cmd)
18
+ out = stdout.read().decode()
19
+ err = stderr.read().decode()
20
+ ec = stdout.channel.recv_exit_status()
21
+ if out: print(out[-400:])
22
+ return ec, out, err
23
+
24
+ run(c, "pm2 resurrect 2>/dev/null; pm2 restart all 2>/dev/null || (cd ~/agentx-gateway && pm2 start ecosystem.config.js)", "Gateway")
25
+ time.sleep(2)
26
+ run(c, "curl -s http://localhost:3090/api/v1/health", "Health check")
27
+ c.close()
28
+
29
+ # Now fix frontend - use next dev instead of build+start
30
+ print("\n=== Fixing Frontend ===")
31
+ c2 = paramiko.SSHClient()
32
+ c2.set_missing_host_key_policy(paramiko.AutoAddPolicy())
33
+ c2.connect(host_f, username=user, password=password, timeout=10)
34
+
35
+ # Kill anything on 8080
36
+ run(c2, "fuser -k 8080/tcp 2>/dev/null; sleep 1; echo done")
37
+
38
+ # Ensure packages are available (full install)
39
+ run(c2, "cd ~/agentx-platform && ls node_modules/.package-lock.json 2>/dev/null && echo 'modules OK' || npm install 2>&1 | tail -3", "Check deps")
40
+
41
+ # Start next dev with memory limits
42
+ run(c2, "cd ~/agentx-platform && NODE_OPTIONS='--max-old-space-size=512' nohup npx next dev -p 8080 -H 0.0.0.0 > /tmp/next-8080.log 2>&1 &", "Start dev")
43
+
44
+ time.sleep(10)
45
+ ec, out, err = run(c2, "ss -tlnp | grep 8080", "Check port")
46
+ if ec != 0:
47
+ run(c2, "tail -20 /tmp/next-8080.log 2>/dev/null", "Log")
48
+
49
+ time.sleep(5)
50
+ run(c2, "ss -tlnp | grep 8080", "Re-check")
51
+ run(c2, "tail -10 /tmp/next-8080.log 2>/dev/null", "Log")
52
+
53
+ c2.close()
54
+ print("\n=== Done ===")
@@ -0,0 +1,114 @@
1
+ import paramiko, tarfile, os, base64
2
+
3
+ GIT_HOST = '43.156.78.59'
4
+ PWD = 'Asdf1234!'
5
+ ROOT = r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx'
6
+ TARPATH = r'c:\Users\apply\Downloads\code\agentx_full_push.tar.gz'
7
+
8
+ EXCLUDE_DIRS = {'node_modules', '.next', '.git', 'dist', 'archive', '__pycache__', '.turbo'}
9
+ SECRET_FILES = {'git_push.py'}
10
+
11
+ print("=== Tar all files ===")
12
+ count = 0
13
+ with tarfile.open(TARPATH, 'w:gz') as tar:
14
+ for root, dirs, files in os.walk(ROOT):
15
+ dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS]
16
+ for f in files:
17
+ if f in SECRET_FILES or f.endswith(('.tsbuildinfo', 'pnpm-lock.yaml', '.tar.gz', '.tgz')):
18
+ continue
19
+ full = os.path.join(root, f)
20
+ arc = os.path.relpath(full, ROOT).replace('\\', '/')
21
+ tar.add(full, arcname=arc)
22
+ count += 1
23
+ print(f"{count} files, {os.path.getsize(TARPATH)//1024} KB")
24
+
25
+ # Upload
26
+ print("\n=== Upload ===")
27
+ t = paramiko.Transport((GIT_HOST, 22))
28
+ t.connect(username='ubuntu', password=PWD)
29
+ s = paramiko.SFTPClient.from_transport(t)
30
+ s.put(TARPATH, '/tmp/ax_full.tar.gz')
31
+ s.close()
32
+ t.close()
33
+
34
+ # Clone + overwrite + push + tag
35
+ push = '''#!/bin/bash
36
+ set -e
37
+ cd /tmp
38
+ rm -rf ax-final
39
+ git clone git@github.com:sftgroup/Agentx.git ax-final
40
+ cd ax-final
41
+ find . -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} \; 2>/dev/null || true
42
+ tar xzf /tmp/ax_full.tar.gz
43
+ echo "Files: $(find . -type f -not -path './.git/*' | wc -l)"
44
+
45
+ git add -A
46
+ echo "=== STATS ==="
47
+ git diff --cached --stat --stat=120 | tail -30
48
+ git commit -m "release: v0.6.4 — full-stack dual-chain, MCP server, platform tools, all docs
49
+
50
+ Smart Contracts (6 contracts, dual-chain):
51
+ - Sepolia (11155111) + OxaChain L1 (19505)
52
+ - A2AProtocolRegistry v2 with getUserTasks(address)
53
+
54
+ SDK @agentxv2/sdk@0.6.3:
55
+ - platform-tools.ts: 28 LLM tools exposing all 7 contract modules
56
+ - buildPlatformTools() / executePlatformTool() / wrapPlatformToolsAsSkills()
57
+
58
+ Gateway v0.2.0:
59
+ - POST /mcp — standard MCP JSON-RPC 2.0 server
60
+ - 29 tools, dual-chain support (chain: sepolia/oxachain)
61
+ - tools/list + tools/call + initialize + notifications/initialized
62
+
63
+ Docs (all updated with dual-chain):
64
+ - README.md: project overview, dual-chain architecture
65
+ - INTEGRATION.md: SDK/Gateway/Contract integration (v0.6.2+)
66
+ - DEPLOYMENT.md: production 164 full-stack + all 12 contract addresses
67
+ - MCP_SETUP.md: Claude Desktop/Cursor config, all 29 tools, dual-chain
68
+ - SDK README: v0.6.3 API reference
69
+ - AGENTX_PROGRESS.md: full development tracker
70
+
71
+ Production: 43.156.225.164 (Frontend :3000, Gateway :3090, PG :5432)
72
+ " 2>&1
73
+
74
+ git push origin main 2>&1
75
+ echo "PUSH_OK"
76
+
77
+ git tag -f v0.6.4 2>/dev/null
78
+ git push origin :refs/tags/v0.6.4 2>/dev/null
79
+ git tag -a v0.6.4 -m "v0.6.4 — Full-stack dual-chain release
80
+
81
+ Production: 43.156.225.164 (Frontend :3000, Gateway :3090, PG :5432)
82
+
83
+ Contracts (Dual-Chain):
84
+ Sepolia (11155111): IdentityRegistry 0xe94a...96e5F
85
+ OxaChain L1 (19505): IdentityRegistry 0xbf5F...E212
86
+ A2AProtocolRegistry v2 with getUserTasks on both chains
87
+
88
+ SDK @agentxv2/sdk@0.6.3:
89
+ platform-tools.ts: 28 LLM-callable tools (all 7 contract modules)
90
+ AgentLoop ReAct engine with open/mcp/a2a skill execution
91
+
92
+ Gateway:
93
+ POST /mcp — standard MCP JSON-RPC 2.0 server (29 tools)
94
+ Dual-chain read: Sepolia + OxaChain L1
95
+ Claude Desktop / Cursor compatible
96
+
97
+ Docs: README, INTEGRATION, DEPLOYMENT, MCP_SETUP, SDK README, PROGRESS
98
+ " 2>&1
99
+
100
+ git push origin v0.6.4 2>&1
101
+ echo "TAG_OK"
102
+ '''
103
+
104
+ pb = base64.b64encode(push.encode()).decode()
105
+ c = paramiko.SSHClient()
106
+ c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
107
+ c.connect(GIT_HOST, username='ubuntu', password=PWD, timeout=30)
108
+ stdin, stdout, stderr = c.exec_command(f"echo '{pb}' | base64 -d | bash 2>&1")
109
+ out = stdout.read().decode()
110
+ err = stderr.read().decode()
111
+ print("\n=== RESULT ===")
112
+ print(out)
113
+ if err: print("E:", err[-500:])
114
+ c.close()
@@ -0,0 +1,38 @@
1
+ import paramiko
2
+ import os
3
+
4
+ host = '101.33.109.117'
5
+ user = 'ubuntu'
6
+ password = 'Asdf1234!'
7
+
8
+ client = paramiko.SSHClient()
9
+ client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
10
+ client.connect(host, username=user, password=password)
11
+
12
+ sftp = client.open_sftp()
13
+
14
+ def run(cmd):
15
+ stdin, stdout, stderr = client.exec_command(cmd)
16
+ out = stdout.read().decode()
17
+ err = stderr.read().decode()
18
+ stdout.channel.recv_exit_status()
19
+ if out: print(out)
20
+ if err: print("ERR:", err[:200])
21
+ return out
22
+
23
+ # Find where the frontend is deployed
24
+ print("=== Finding frontend location ===")
25
+ run("ls -la ~/ 2>&1")
26
+ run("ls /home/ 2>&1")
27
+ run("find /home -name 'next.config.js' -maxdepth 4 2>/dev/null")
28
+ run("find /var -name 'next.config.js' -maxdepth 4 2>/dev/null")
29
+
30
+ # Check current processes
31
+ print("\n=== Checking existing processes ===")
32
+ run("ps aux | grep -E 'node|next|pm2' | grep -v grep | head -20")
33
+
34
+ # Check PM2 processes
35
+ print("\n=== PM2 list ===")
36
+ run("pm2 list 2>&1")
37
+
38
+ client.close()
@@ -0,0 +1,43 @@
1
+ import paramiko
2
+ import base64
3
+ import time
4
+
5
+ host_fe = '43.156.78.59'
6
+ password = 'Asdf1234!'
7
+
8
+ client = paramiko.SSHClient()
9
+ client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
10
+ client.connect(host_fe, username='ubuntu', password=password, timeout=30)
11
+
12
+ def run(cmd, desc=""):
13
+ print(f"[{desc}] > {cmd[:120]}")
14
+ stdin, stdout, stderr = client.exec_command(cmd, timeout=300)
15
+ out = stdout.read().decode()
16
+ err = stderr.read().decode()
17
+ ec = stdout.channel.recv_exit_status()
18
+ if out: print(out[-400:])
19
+ if err and 'deprecat' not in err.lower() and 'warn' not in err.lower(): print("ERR:", err[-200:])
20
+ return ec, out
21
+
22
+ # Upload fixed A2A page
23
+ print("=== Upload A2A page fix ===")
24
+ with open(r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend\app\a2a\page.tsx', 'r', encoding='utf-8') as f:
25
+ content = f.read()
26
+ b64 = base64.b64encode(content.encode()).decode()
27
+ run(f"echo '{b64}' | base64 -d > /home/ubuntu/agentx-platform/app/a2a/page.tsx && wc -c /home/ubuntu/agentx-platform/app/a2a/page.tsx", "upload")
28
+
29
+ # Incremental rebuild (should be fast since only a2a page changed and .next cache exists)
30
+ print("\n=== Incremental rebuild ===")
31
+ run("fuser -k 8080/tcp 2>/dev/null; pkill -f 'next' 2>/dev/null; sleep 1; echo done")
32
+ ec, out = run("cd /home/ubuntu/agentx-platform && NODE_OPTIONS='--max-old-space-size=1536' npx next build 2>&1 | tail -20", "build")
33
+ print(f"Build exit: {ec}")
34
+
35
+ # Start
36
+ print("\n=== Start ===")
37
+ run("cd /home/ubuntu/agentx-platform && nohup npx next start -p 8080 > /tmp/fe-a2afix.log 2>&1 &", "start")
38
+ time.sleep(5)
39
+ run("ss -tlnp | grep 8080", "port check")
40
+ run("tail -3 /tmp/fe-a2afix.log", "log")
41
+
42
+ client.close()
43
+ print("\n=== DONE ===")