@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.
- package/.env.example +53 -0
- package/db/migrations/001_init.sql +117 -0
- package/db/migrations/002_agents.sql +20 -0
- package/db/migrations/003_a2a_results.sql +23 -0
- package/deploy/.env.deploy.example +23 -0
- package/deploy/add_swap_build.py +45 -0
- package/deploy/build_and_deploy.py +110 -0
- package/deploy/build_deploy_a2a.py +190 -0
- package/deploy/build_no_lint.py +52 -0
- package/deploy/build_on_fe.py +86 -0
- package/deploy/build_on_gw.py +98 -0
- package/deploy/build_prod.py +54 -0
- package/deploy/check_bal.py +31 -0
- package/deploy/check_code.py +47 -0
- package/deploy/check_deploy.sh +20 -0
- package/deploy/check_docs.py +16 -0
- package/deploy/check_frontend.py +42 -0
- package/deploy/check_frontend2.py +35 -0
- package/deploy/check_pks.py +34 -0
- package/deploy/check_status.py +32 -0
- package/deploy/check_v2.py +8 -0
- package/deploy/clean_install.py +28 -0
- package/deploy/deploy_a2a.py +58 -0
- package/deploy/deploy_a2a.sh +33 -0
- package/deploy/deploy_a2a_bg.sh +40 -0
- package/deploy/deploy_a2a_v2.py +151 -0
- package/deploy/deploy_a2a_v2.sh +36 -0
- package/deploy/deploy_bin.py +64 -0
- package/deploy/deploy_config.py +34 -0
- package/deploy/deploy_final.py +42 -0
- package/deploy/deploy_frontend.py +108 -0
- package/deploy/deploy_mcp.py +108 -0
- package/deploy/deploy_now.py +49 -0
- package/deploy/deploy_push_all.py +128 -0
- package/deploy/deploy_script.py +64 -0
- package/deploy/deploy_sep_a2a.sh +18 -0
- package/deploy/dev_mode.py +51 -0
- package/deploy/diag.py +12 -0
- package/deploy/diff_test.py +22 -0
- package/deploy/final_check.py +33 -0
- package/deploy/final_deploy.py +50 -0
- package/deploy/final_fix.py +54 -0
- package/deploy/final_push.py +114 -0
- package/deploy/find_frontend.py +38 -0
- package/deploy/fix_a2a.py +43 -0
- package/deploy/fix_and_build.py +77 -0
- package/deploy/fix_and_verify.py +56 -0
- package/deploy/fix_build.py +51 -0
- package/deploy/forge_deploy.py +67 -0
- package/deploy/full_push.py +101 -0
- package/deploy/full_push2.py +106 -0
- package/deploy/go_prod.py +59 -0
- package/deploy/gw_deploy.py +133 -0
- package/deploy/gw_final.py +206 -0
- package/deploy/gw_restart.py +28 -0
- package/deploy/gw_status.py +18 -0
- package/deploy/inline_build.py +99 -0
- package/deploy/one_shot.py +84 -0
- package/deploy/ox_deploy.py +32 -0
- package/deploy/pg_setup.py +36 -0
- package/deploy/prod_deploy.py +126 -0
- package/deploy/prod_final.py +140 -0
- package/deploy/prod_go.py +61 -0
- package/deploy/prod_one_shot.py +139 -0
- package/deploy/prod_setup.sh +62 -0
- package/deploy/prod_v2.py +91 -0
- package/deploy/prod_v3.py +103 -0
- package/deploy/push_docs.py +93 -0
- package/deploy/push_mcp.py +66 -0
- package/deploy/push_mcp_doc.py +28 -0
- package/deploy/push_v063.py +80 -0
- package/deploy/push_v2.py +71 -0
- package/deploy/qcheck.py +13 -0
- package/deploy/qcheck2.py +18 -0
- package/deploy/quick_check.py +8 -0
- package/deploy/rebuild.py +47 -0
- package/deploy/rebuild_frontend.py +44 -0
- package/deploy/restart.py +28 -0
- package/deploy/restore_frontend.py +42 -0
- package/deploy/restore_frontend2.py +41 -0
- package/deploy/restore_gateway.py +34 -0
- package/deploy/restore_quick.py +33 -0
- package/deploy/run_bash.py +19 -0
- package/deploy/run_sep.py +20 -0
- package/deploy/sdk_upgrade.py +50 -0
- package/deploy/server_prepare.py +41 -0
- package/deploy/server_setup.py +41 -0
- package/deploy/ssh_check.py +14 -0
- package/deploy/ssh_push.py +24 -0
- package/deploy/start_deploy.py +35 -0
- package/deploy/start_frontend.py +12 -0
- package/deploy/start_v2.py +29 -0
- package/deploy/stat.py +18 -0
- package/deploy/tail_log.py +11 -0
- package/deploy/update_env.py +32 -0
- package/deploy/upload_and_start.py +107 -0
- package/deploy/verify_a2a.py +13 -0
- package/deploy/verify_mcp.py +37 -0
- package/deploy/verify_sdk.py +21 -0
- package/dist/config.d.ts +26 -0
- package/dist/config.js +41 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +149 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/crypto.d.ts +2 -0
- package/dist/lib/crypto.js +43 -0
- package/dist/lib/crypto.js.map +1 -0
- package/dist/lib/db.d.ts +3 -0
- package/dist/lib/db.js +26 -0
- package/dist/lib/db.js.map +1 -0
- package/dist/lib/ethers-utils.d.ts +60 -0
- package/dist/lib/ethers-utils.js +186 -0
- package/dist/lib/ethers-utils.js.map +1 -0
- package/dist/middleware/adminAuth.d.ts +2 -0
- package/dist/middleware/adminAuth.js +31 -0
- package/dist/middleware/adminAuth.js.map +1 -0
- package/dist/middleware/auth.d.ts +22 -0
- package/dist/middleware/auth.js +192 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +36 -0
- package/dist/middleware/error-handler.js +100 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/rate-limiter.d.ts +5 -0
- package/dist/middleware/rate-limiter.js +107 -0
- package/dist/middleware/rate-limiter.js.map +1 -0
- package/dist/routes/a2a.d.ts +2 -0
- package/dist/routes/a2a.js +84 -0
- package/dist/routes/a2a.js.map +1 -0
- package/dist/routes/admin.d.ts +2 -0
- package/dist/routes/admin.js +180 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/agents.d.ts +2 -0
- package/dist/routes/agents.js +43 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/chat.d.ts +2 -0
- package/dist/routes/chat.js +183 -0
- package/dist/routes/chat.js.map +1 -0
- package/dist/routes/history.d.ts +2 -0
- package/dist/routes/history.js +92 -0
- package/dist/routes/history.js.map +1 -0
- package/dist/routes/mcp.d.ts +13 -0
- package/dist/routes/mcp.js +513 -0
- package/dist/routes/mcp.js.map +1 -0
- package/dist/routes/tenant.d.ts +2 -0
- package/dist/routes/tenant.js +154 -0
- package/dist/routes/tenant.js.map +1 -0
- package/dist/services/a2a-worker.d.ts +7 -0
- package/dist/services/a2a-worker.js +406 -0
- package/dist/services/a2a-worker.js.map +1 -0
- package/dist/services/agent-indexer.d.ts +4 -0
- package/dist/services/agent-indexer.js +124 -0
- package/dist/services/agent-indexer.js.map +1 -0
- package/e2e_wallet.js +175 -0
- package/ecosystem.config.js +17 -0
- package/package.json +33 -0
- package/src/config.ts +47 -0
- package/src/index.ts +143 -0
- package/src/lib/crypto.ts +44 -0
- package/src/lib/db.ts +25 -0
- package/src/lib/ethers-utils.ts +229 -0
- package/src/middleware/adminAuth.ts +34 -0
- package/src/middleware/auth.ts +244 -0
- package/src/middleware/error-handler.ts +109 -0
- package/src/middleware/rate-limiter.ts +115 -0
- package/src/routes/a2a.ts +97 -0
- package/src/routes/admin.ts +219 -0
- package/src/routes/agents.ts +52 -0
- package/src/routes/chat.ts +219 -0
- package/src/routes/history.ts +114 -0
- package/src/routes/mcp.ts +567 -0
- package/src/routes/tenant.ts +196 -0
- package/src/services/a2a-worker.ts +486 -0
- package/src/services/agent-indexer.ts +127 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import paramiko
|
|
2
|
+
import tarfile, os, base64, time
|
|
3
|
+
|
|
4
|
+
HOST = '43.156.225.164'
|
|
5
|
+
PWD = 'Asdf1234!'
|
|
6
|
+
PORT = '3090'
|
|
7
|
+
APP = '/home/ubuntu/agentx-gateway'
|
|
8
|
+
|
|
9
|
+
local = r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\gateway'
|
|
10
|
+
tarpath = r'c:\Users\apply\Downloads\code\agentx_gw.tar.gz'
|
|
11
|
+
|
|
12
|
+
# 1. Tar
|
|
13
|
+
print("=== Tar ===")
|
|
14
|
+
with tarfile.open(tarpath, 'w:gz') as tar:
|
|
15
|
+
for root, dirs, files in os.walk(local):
|
|
16
|
+
dirs[:] = [d for d in dirs if d not in ('node_modules','dist','.git')]
|
|
17
|
+
for f in files:
|
|
18
|
+
if f.endswith('.tar.gz'): continue
|
|
19
|
+
full = os.path.join(root, f)
|
|
20
|
+
arc = os.path.relpath(full, local).replace('\\', '/')
|
|
21
|
+
tar.add(full, arcname=arc)
|
|
22
|
+
print(f"{os.path.getsize(tarpath)//1024} KB")
|
|
23
|
+
|
|
24
|
+
# 2. Upload
|
|
25
|
+
print("Uploading...")
|
|
26
|
+
t = paramiko.Transport((HOST, 22))
|
|
27
|
+
t.connect(username='ubuntu', password=PWD)
|
|
28
|
+
s = paramiko.SFTPClient.from_transport(t)
|
|
29
|
+
s.put(tarpath, '/tmp/agentx_gw.tar.gz')
|
|
30
|
+
s.close()
|
|
31
|
+
t.close()
|
|
32
|
+
|
|
33
|
+
# 3. Deploy
|
|
34
|
+
c = paramiko.SSHClient()
|
|
35
|
+
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
36
|
+
c.connect(HOST, username='ubuntu', password=PWD, timeout=30)
|
|
37
|
+
|
|
38
|
+
# Extract
|
|
39
|
+
stdin, stdout, stderr = c.exec_command(f"rm -rf {APP} && mkdir -p {APP} && cd {APP} && tar xzf /tmp/agentx_gw.tar.gz && ls src/index.ts package.json tsconfig.json")
|
|
40
|
+
print(stdout.read().decode().strip())
|
|
41
|
+
|
|
42
|
+
# Write .env
|
|
43
|
+
env = f'''PORT={PORT}
|
|
44
|
+
NODE_ENV=production
|
|
45
|
+
DATABASE_URL=postgresql://agentx:AgentX2024!Gateway@localhost:5432/agentx_gateway
|
|
46
|
+
JWT_SECRET=agentx-prod-jwt-secret-20260717-gateway-key
|
|
47
|
+
SESSION_TTL_SEC=86400
|
|
48
|
+
'''
|
|
49
|
+
b64 = base64.b64encode(env.encode()).decode()
|
|
50
|
+
c.exec_command(f"echo '{b64}' | base64 -d > {APP}/.env && echo 'env OK'")
|
|
51
|
+
|
|
52
|
+
# npm install
|
|
53
|
+
print("\n=== npm install ===")
|
|
54
|
+
stdin, stdout, stderr = c.exec_command(f"cd {APP} && npm install 2>&1 | tail -8", timeout=300)
|
|
55
|
+
out = stdout.read().decode()
|
|
56
|
+
print(out[-400:] if len(out) > 400 else out)
|
|
57
|
+
|
|
58
|
+
# tsc build
|
|
59
|
+
print("\n=== tsc ===")
|
|
60
|
+
stdin, stdout, stderr = c.exec_command(f"cd {APP} && ./node_modules/.bin/tsc 2>&1 | tail -10", timeout=120)
|
|
61
|
+
out = stdout.read().decode()
|
|
62
|
+
print(out[-400:] if len(out) > 400 else out)
|
|
63
|
+
|
|
64
|
+
stdin, stdout, stderr = c.exec_command(f"ls {APP}/dist/index.js 2>/dev/null && echo BUILD_OK || echo BUILD_FAILED")
|
|
65
|
+
check = stdout.read().decode().strip()
|
|
66
|
+
print(f"Build: {check}")
|
|
67
|
+
|
|
68
|
+
# Init DB tables
|
|
69
|
+
print("\n=== DB init ===")
|
|
70
|
+
# Check if we have a migration/schema file
|
|
71
|
+
schema_files = []
|
|
72
|
+
for fname in ['schema.sql', 'migrations', 'db.ts']:
|
|
73
|
+
stdin, stdout, stderr = c.exec_command(f"ls {APP}/src/lib/{fname} 2>/dev/null && echo 'HAS_{fname}' || true")
|
|
74
|
+
r = stdout.read().decode().strip()
|
|
75
|
+
if r: schema_files.append(r)
|
|
76
|
+
|
|
77
|
+
# Create tables manually
|
|
78
|
+
sql = """
|
|
79
|
+
CREATE TABLE IF NOT EXISTS plans (
|
|
80
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
81
|
+
name TEXT NOT NULL,
|
|
82
|
+
slug TEXT NOT NULL UNIQUE,
|
|
83
|
+
description TEXT,
|
|
84
|
+
quota_daily INTEGER NOT NULL DEFAULT 1000,
|
|
85
|
+
rpm_limit INTEGER NOT NULL DEFAULT 100,
|
|
86
|
+
price_monthly_cents INTEGER NOT NULL DEFAULT 0,
|
|
87
|
+
features JSONB DEFAULT '[]',
|
|
88
|
+
is_active BOOLEAN DEFAULT true,
|
|
89
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
CREATE TABLE IF NOT EXISTS tenants (
|
|
93
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
94
|
+
wallet_address TEXT NOT NULL UNIQUE,
|
|
95
|
+
plan_id UUID REFERENCES plans(id),
|
|
96
|
+
status TEXT DEFAULT 'active',
|
|
97
|
+
metadata JSONB DEFAULT '{}',
|
|
98
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
99
|
+
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
CREATE TABLE IF NOT EXISTS platform_api_keys (
|
|
103
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
104
|
+
name TEXT NOT NULL DEFAULT 'Default',
|
|
105
|
+
encrypted_key TEXT NOT NULL,
|
|
106
|
+
key_hash TEXT NOT NULL UNIQUE,
|
|
107
|
+
is_active BOOLEAN DEFAULT true,
|
|
108
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
CREATE TABLE IF NOT EXISTS tenant_api_keys (
|
|
112
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
113
|
+
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
114
|
+
name TEXT NOT NULL DEFAULT 'BYOK Key',
|
|
115
|
+
encrypted_key TEXT NOT NULL,
|
|
116
|
+
key_hash TEXT NOT NULL UNIQUE,
|
|
117
|
+
provider TEXT NOT NULL DEFAULT 'openai',
|
|
118
|
+
base_url TEXT DEFAULT 'https://api.openai.com/v1',
|
|
119
|
+
is_active BOOLEAN DEFAULT true,
|
|
120
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
CREATE TABLE IF NOT EXISTS usage_logs (
|
|
124
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
125
|
+
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
126
|
+
tokens_used INTEGER NOT NULL DEFAULT 0,
|
|
127
|
+
tool_calls INTEGER NOT NULL DEFAULT 0,
|
|
128
|
+
model TEXT,
|
|
129
|
+
source TEXT DEFAULT 'platform',
|
|
130
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
CREATE TABLE IF NOT EXISTS chat_messages (
|
|
134
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
135
|
+
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
136
|
+
agent_id TEXT,
|
|
137
|
+
role TEXT NOT NULL,
|
|
138
|
+
content TEXT,
|
|
139
|
+
metadata JSONB DEFAULT '{}',
|
|
140
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
INSERT INTO plans (name, slug, description, quota_daily, rpm_limit, price_monthly_cents)
|
|
144
|
+
VALUES ('Free', 'free', 'Free tier', 100, 10, 0) ON CONFLICT (slug) DO NOTHING;
|
|
145
|
+
|
|
146
|
+
INSERT INTO plans (name, slug, description, quota_daily, rpm_limit, price_monthly_cents)
|
|
147
|
+
VALUES ('Pro', 'pro', 'Pro tier', 10000, 100, 1000) ON CONFLICT (slug) DO NOTHING;
|
|
148
|
+
"""
|
|
149
|
+
b64 = base64.b64encode(sql.encode()).decode()
|
|
150
|
+
stdin, stdout, stderr = c.exec_command(
|
|
151
|
+
f"echo '{b64}' | base64 -d > /tmp/schema.sql && "
|
|
152
|
+
f"export PGPASSWORD='AgentX2024!Gateway' && "
|
|
153
|
+
f"psql -h localhost -U agentx -d agentx_gateway -f /tmp/schema.sql 2>&1 | tail -10"
|
|
154
|
+
)
|
|
155
|
+
out = stdout.read().decode()
|
|
156
|
+
print(out[-400:] if len(out) > 400 else out)
|
|
157
|
+
|
|
158
|
+
# Start
|
|
159
|
+
print(f"\n=== Start on {PORT} ===")
|
|
160
|
+
c.exec_command(f"fuser -k {PORT}/tcp 2>/dev/null; sleep 2", timeout=10)
|
|
161
|
+
c.exec_command(
|
|
162
|
+
f"cd {APP} && nohup node dist/index.js > /tmp/gw.log 2>&1 & disown",
|
|
163
|
+
timeout=5
|
|
164
|
+
)
|
|
165
|
+
time.sleep(4)
|
|
166
|
+
|
|
167
|
+
stdin, stdout, stderr = c.exec_command(f"ss -tlnp | grep {PORT} && echo '---' && curl -s http://localhost:{PORT}/api/v1/health 2>&1")
|
|
168
|
+
out = stdout.read().decode()
|
|
169
|
+
print(out)
|
|
170
|
+
|
|
171
|
+
if '200' in out or 'OK' in out or '/api/v1/health' in out:
|
|
172
|
+
print("\n✅ Gateway running on 164:3090!")
|
|
173
|
+
else:
|
|
174
|
+
stdin, stdout, stderr = c.exec_command("tail -20 /tmp/gw.log 2>/dev/null")
|
|
175
|
+
print("Log:", stdout.read().decode()[:500])
|
|
176
|
+
|
|
177
|
+
# Now update frontend env
|
|
178
|
+
print("\n=== Update frontend .env ===")
|
|
179
|
+
new_gw = 'NEXT_PUBLIC_AGENTX_GATEWAY_URL=http://43.156.225.164:3090'
|
|
180
|
+
# Read current .env.production from server
|
|
181
|
+
stdin, stdout, stderr = c.exec_command("cat /home/ubuntu/agentx-platform/.env.production | head -5")
|
|
182
|
+
current = stdout.read().decode()
|
|
183
|
+
print(current[:100])
|
|
184
|
+
|
|
185
|
+
# Replace GATEWAY_URL
|
|
186
|
+
stdin, stdout, stderr = c.exec_command(
|
|
187
|
+
f"sed -i 's|NEXT_PUBLIC_AGENTX_GATEWAY_URL=.*|{new_gw}|' /home/ubuntu/agentx-platform/.env.production && "
|
|
188
|
+
f"grep GATEWAY /home/ubuntu/agentx-platform/.env.production"
|
|
189
|
+
)
|
|
190
|
+
print(stdout.read().decode().strip())
|
|
191
|
+
|
|
192
|
+
# Restart frontend
|
|
193
|
+
print("\n=== Restart frontend ===")
|
|
194
|
+
c.exec_command("fuser -k 3000/tcp 2>/dev/null; sleep 2", timeout=10)
|
|
195
|
+
c.exec_command(
|
|
196
|
+
"cd /home/ubuntu/agentx-platform && nohup ./node_modules/.bin/next start -p 3000 > /tmp/agentx-run.log 2>&1 & disown",
|
|
197
|
+
timeout=5
|
|
198
|
+
)
|
|
199
|
+
time.sleep(6)
|
|
200
|
+
stdin, stdout, stderr = c.exec_command("ss -tlnp | grep 3000 && curl -sI http://localhost:3000/ 2>&1 | head -3")
|
|
201
|
+
print(stdout.read().decode())
|
|
202
|
+
|
|
203
|
+
c.close()
|
|
204
|
+
print("\n✅ DONE — All on 43.156.225.164!")
|
|
205
|
+
print(" Frontend: http://43.156.225.164:3000")
|
|
206
|
+
print(" Gateway: http://43.156.225.164:3090")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import paramiko, time
|
|
2
|
+
|
|
3
|
+
c = paramiko.SSHClient()
|
|
4
|
+
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
5
|
+
c.connect('43.156.225.164', username='ubuntu', password='Asdf1234!', timeout=10)
|
|
6
|
+
|
|
7
|
+
print("=== Restarting Gateway ===")
|
|
8
|
+
stdin, stdout, stderr = c.exec_command(
|
|
9
|
+
"cd /home/ubuntu/agentx-gateway && "
|
|
10
|
+
"nohup node dist/index.js > /tmp/gw.log 2>&1 & disown; "
|
|
11
|
+
"sleep 3; echo 'started'",
|
|
12
|
+
timeout=10
|
|
13
|
+
)
|
|
14
|
+
print(stdout.read().decode().strip())
|
|
15
|
+
|
|
16
|
+
time.sleep(2)
|
|
17
|
+
|
|
18
|
+
print("\n=== Port Status ===")
|
|
19
|
+
stdin, stdout, stderr = c.exec_command(
|
|
20
|
+
"ss -tlnp | awk '/3000|3090|5432/ && !/awk/'"
|
|
21
|
+
)
|
|
22
|
+
print(stdout.read().decode())
|
|
23
|
+
|
|
24
|
+
print("\n=== Gateway Health ===")
|
|
25
|
+
stdin, stdout, stderr = c.exec_command("curl -s http://localhost:3090/api/v1/health 2>&1")
|
|
26
|
+
print(stdout.read().decode())
|
|
27
|
+
|
|
28
|
+
c.close()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import paramiko
|
|
2
|
+
|
|
3
|
+
c = paramiko.SSHClient()
|
|
4
|
+
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
5
|
+
c.connect('43.156.225.164', username='ubuntu', password='Asdf1234!', timeout=10)
|
|
6
|
+
|
|
7
|
+
stdin, stdout, stderr = c.exec_command("tail -15 /tmp/gw.log 2>/dev/null || echo NO_GW_LOG")
|
|
8
|
+
print("GW LOG:", stdout.read().decode()[:500])
|
|
9
|
+
|
|
10
|
+
stdin, stdout, stderr = c.exec_command(
|
|
11
|
+
"ps aux 2>/dev/null | awk '/agentx-gateway/ || /node.*dist.index.js/ || /3000/ || /3090/' | awk '!/(awk|grep)/' | head -5"
|
|
12
|
+
)
|
|
13
|
+
print("PROCS:", stdout.read().decode()[:300])
|
|
14
|
+
|
|
15
|
+
stdin, stdout, stderr = c.exec_command("ls /home/ubuntu/agentx-gateway/dist/index.js 2>/dev/null && echo DIST_OK || echo NO_DIST")
|
|
16
|
+
print("DIST:", stdout.read().decode()[:100])
|
|
17
|
+
|
|
18
|
+
c.close()
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import paramiko
|
|
2
|
+
import time
|
|
3
|
+
import base64
|
|
4
|
+
|
|
5
|
+
host_fe = '43.156.78.59'
|
|
6
|
+
password = 'Asdf1234!'
|
|
7
|
+
|
|
8
|
+
def run(cmd, desc=""):
|
|
9
|
+
c2 = paramiko.SSHClient()
|
|
10
|
+
c2.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
11
|
+
c2.connect(host_fe, username='ubuntu', password=password, timeout=20)
|
|
12
|
+
print(f"[{desc}] > {cmd[:120]}")
|
|
13
|
+
stdin, stdout, stderr = c2.exec_command(cmd)
|
|
14
|
+
out = stdout.read().decode()
|
|
15
|
+
err = stderr.read().decode()
|
|
16
|
+
ec = stdout.channel.recv_exit_status()
|
|
17
|
+
if out and len(out) > 0: print(out[-600:])
|
|
18
|
+
if err: print("ERR:", err[-300:])
|
|
19
|
+
c2.close()
|
|
20
|
+
return ec, out
|
|
21
|
+
|
|
22
|
+
# Read local files as base64 and write them over SSH
|
|
23
|
+
def upload_content(remote_path, content):
|
|
24
|
+
b64 = base64.b64encode(content.encode()).decode()
|
|
25
|
+
# Write in chunks to avoid command length limits
|
|
26
|
+
chunk_size = 4000
|
|
27
|
+
# First truncate
|
|
28
|
+
run(f"true > {remote_path}", "truncate")
|
|
29
|
+
for i in range(0, len(b64), chunk_size):
|
|
30
|
+
chunk = b64[i:i+chunk_size]
|
|
31
|
+
run(f"printf '%s' '{chunk}' >> {remote_path}.b64", f"write chunk {i//chunk_size}")
|
|
32
|
+
run(f"base64 -d {remote_path}.b64 > {remote_path} && rm {remote_path}.b64 && echo 'written'", "decode")
|
|
33
|
+
|
|
34
|
+
# Step 1: Update SDK
|
|
35
|
+
print("=== Step 1: Install SDK ===")
|
|
36
|
+
run("cd /home/ubuntu/agentx-platform && npm install @agentxv2/sdk@0.6.1 2>&1 | tail -5", "install SDK")
|
|
37
|
+
|
|
38
|
+
# Step 2: Upload changed files
|
|
39
|
+
print("\n=== Step 2: Upload source files ===")
|
|
40
|
+
|
|
41
|
+
# Read files
|
|
42
|
+
fe_base = r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend'
|
|
43
|
+
|
|
44
|
+
with open(fe_base + r'\app\user\chat\[agentId]\page.tsx', 'r', encoding='utf-8') as f:
|
|
45
|
+
chat_page = f.read()
|
|
46
|
+
with open(fe_base + r'\hooks\useGatewayAuth.ts', 'r', encoding='utf-8') as f:
|
|
47
|
+
gateway_hook = f.read()
|
|
48
|
+
with open(fe_base + r'\components\chat\ToolCallBubble.tsx', 'r', encoding='utf-8') as f:
|
|
49
|
+
tool_bubble = f.read()
|
|
50
|
+
with open(fe_base + r'\.env.local', 'r', encoding='utf-8') as f:
|
|
51
|
+
env_local = f.read()
|
|
52
|
+
with open(fe_base + r'\.env.production', 'r', encoding='utf-8') as f:
|
|
53
|
+
env_prod = f.read()
|
|
54
|
+
with open(fe_base + r'\package.json', 'r', encoding='utf-8') as f:
|
|
55
|
+
pkg_json = f.read()
|
|
56
|
+
|
|
57
|
+
print(f"Chat page: {len(chat_page)} chars")
|
|
58
|
+
print(f"Gateway hook: {len(gateway_hook)} chars")
|
|
59
|
+
print(f"Tool bubble: {len(tool_bubble)} chars")
|
|
60
|
+
|
|
61
|
+
print("\n--- Uploading chat page ---")
|
|
62
|
+
upload_content('/home/ubuntu/agentx-platform/app/user/chat/[agentId]/page.tsx', chat_page)
|
|
63
|
+
|
|
64
|
+
print("\n--- Uploading gateway hook ---")
|
|
65
|
+
upload_content('/home/ubuntu/agentx-platform/hooks/useGatewayAuth.ts', gateway_hook)
|
|
66
|
+
|
|
67
|
+
print("\n--- Uploading tool bubble ---")
|
|
68
|
+
# Ensure dir exists
|
|
69
|
+
run("mkdir -p /home/ubuntu/agentx-platform/components/chat", "mkdir")
|
|
70
|
+
upload_content('/home/ubuntu/agentx-platform/components/chat/ToolCallBubble.tsx', tool_bubble)
|
|
71
|
+
|
|
72
|
+
print("\n--- Uploading env files ---")
|
|
73
|
+
upload_content('/home/ubuntu/agentx-platform/.env.local', env_local)
|
|
74
|
+
upload_content('/home/ubuntu/agentx-platform/.env.production', env_prod)
|
|
75
|
+
upload_content('/home/ubuntu/agentx-platform/package.json', pkg_json)
|
|
76
|
+
|
|
77
|
+
# Step 3: Clean + Build
|
|
78
|
+
print("\n=== Step 3: Build ===")
|
|
79
|
+
run("fuser -k 8080/tcp 2>/dev/null; pkill -f 'next' 2>/dev/null; sleep 1; echo cleaned")
|
|
80
|
+
run("rm -rf /home/ubuntu/agentx-platform/.next", "clean .next")
|
|
81
|
+
|
|
82
|
+
print("\n=== BUILDING (this takes 2-3 min) ===")
|
|
83
|
+
ec, out = run("cd /home/ubuntu/agentx-platform && NODE_OPTIONS='--max-old-space-size=1536' npx next build 2>&1", "build")
|
|
84
|
+
print(f"\nBUILD EXIT: {ec}")
|
|
85
|
+
|
|
86
|
+
# Check
|
|
87
|
+
ec, out = run("ls /home/ubuntu/agentx-platform/.next/BUILD_ID 2>/dev/null && echo 'BUILD OK!' || echo 'BUILD FAILED'")
|
|
88
|
+
if 'FAILED' in out:
|
|
89
|
+
run("tail -20 /home/ubuntu/agentx-platform/.next/trace 2>/dev/null || echo 'no trace'")
|
|
90
|
+
exit(1)
|
|
91
|
+
|
|
92
|
+
# Step 4: Start
|
|
93
|
+
print("\n=== Step 4: Start ===")
|
|
94
|
+
run("cd /home/ubuntu/agentx-platform && nohup npx next start -p 8080 > /tmp/fe-run.log 2>&1 &", "start")
|
|
95
|
+
time.sleep(5)
|
|
96
|
+
run("ss -tlnp | grep 8080", "check port")
|
|
97
|
+
run("tail -5 /tmp/fe-run.log", "check log")
|
|
98
|
+
|
|
99
|
+
print("\n=== ALL DONE ===")
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import paramiko
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
host_fe = '43.156.78.59'
|
|
5
|
+
|
|
6
|
+
# Use ONE connection for all commands
|
|
7
|
+
client = paramiko.SSHClient()
|
|
8
|
+
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
9
|
+
client.connect(host_fe, username='ubuntu', password='Asdf1234!', timeout=30)
|
|
10
|
+
|
|
11
|
+
def run(cmd, desc=""):
|
|
12
|
+
print(f"[{desc}] > {cmd[:120]}")
|
|
13
|
+
stdin, stdout, stderr = client.exec_command(cmd, timeout=300)
|
|
14
|
+
out = stdout.read().decode()
|
|
15
|
+
err = stderr.read().decode()
|
|
16
|
+
ec = stdout.channel.recv_exit_status()
|
|
17
|
+
if out: print(out[-500:])
|
|
18
|
+
if err and 'deprecat' not in err.lower() and 'warn' not in err.lower(): print("ERR:", err[-300:])
|
|
19
|
+
return ec, out
|
|
20
|
+
|
|
21
|
+
# Step 1: npm install SDK
|
|
22
|
+
print("=== Step 1 ===")
|
|
23
|
+
run("cd /home/ubuntu/agentx-platform && npm install @agentxv2/sdk@0.6.1 2>&1 | tail -5", "sdk")
|
|
24
|
+
|
|
25
|
+
# Step 2: Write the chat page using bash heredoc
|
|
26
|
+
print("\n=== Step 2: Chat page ===")
|
|
27
|
+
with open(r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend\app\user\chat\[agentId]\page.tsx', 'r', encoding='utf-8') as f:
|
|
28
|
+
chat_content = f.read()
|
|
29
|
+
# Write file by piping from echo using base64
|
|
30
|
+
import base64
|
|
31
|
+
b64 = base64.b64encode(chat_content.encode()).decode()
|
|
32
|
+
target = r"/home/ubuntu/agentx-platform/app/user/chat/\[agentId\]/page.tsx"
|
|
33
|
+
run(f"echo '{b64}' | base64 -d > {target} && wc -c {target}", "write")
|
|
34
|
+
|
|
35
|
+
# Step 3: Gateway hook
|
|
36
|
+
print("\n=== Step 3: Gateway hook ===")
|
|
37
|
+
with open(r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend\hooks\useGatewayAuth.ts', 'r', encoding='utf-8') as f:
|
|
38
|
+
hook_content = f.read()
|
|
39
|
+
b64 = base64.b64encode(hook_content.encode()).decode()
|
|
40
|
+
target = "/home/ubuntu/agentx-platform/hooks/useGatewayAuth.ts"
|
|
41
|
+
run(f"echo '{b64}' | base64 -d > {target} && wc -c {target}", "write")
|
|
42
|
+
|
|
43
|
+
# Step 4: ToolCallBubble
|
|
44
|
+
print("\n=== Step 4: ToolCallBubble ===")
|
|
45
|
+
with open(r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend\components\chat\ToolCallBubble.tsx', 'r', encoding='utf-8') as f:
|
|
46
|
+
bubble_content = f.read()
|
|
47
|
+
b64 = base64.b64encode(bubble_content.encode()).decode()
|
|
48
|
+
run("mkdir -p /home/ubuntu/agentx-platform/components/chat", "mkdir")
|
|
49
|
+
target = "/home/ubuntu/agentx-platform/components/chat/ToolCallBubble.tsx"
|
|
50
|
+
run(f"echo '{b64}' | base64 -d > {target} && wc -c {target}", "write")
|
|
51
|
+
|
|
52
|
+
# Step 5: env files
|
|
53
|
+
print("\n=== Step 5: env files ===")
|
|
54
|
+
b64 = base64.b64encode(b'NEXT_PUBLIC_AGENTX_GATEWAY_URL=http://101.33.109.117:3090').decode()
|
|
55
|
+
run(f"echo '{b64}' | base64 -d > /home/ubuntu/agentx-platform/.env.local && echo 'env-local ok'", "env-local")
|
|
56
|
+
|
|
57
|
+
with open(r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend\.env.production', 'r', encoding='utf-8') as f:
|
|
58
|
+
env_content = f.read()
|
|
59
|
+
b64 = base64.b64encode(env_content.encode()).decode()
|
|
60
|
+
run(f"echo '{b64}' | base64 -d > /home/ubuntu/agentx-platform/.env.production && echo 'env-prod ok'", "env-prod")
|
|
61
|
+
|
|
62
|
+
# Step 6: Clean + Build
|
|
63
|
+
print("\n=== Step 6: Clean ===")
|
|
64
|
+
run("fuser -k 8080/tcp 2>/dev/null; pkill -f 'next' 2>/dev/null; sleep 1")
|
|
65
|
+
run("rm -rf /home/ubuntu/agentx-platform/.next && echo cleaned")
|
|
66
|
+
|
|
67
|
+
print("\n=== Step 7: BUILD (2-3 min) ===")
|
|
68
|
+
ec, out = run("cd /home/ubuntu/agentx-platform && NODE_OPTIONS='--max-old-space-size=1536' npx next build 2>&1 | tail -25", "build")
|
|
69
|
+
print(f"\nBuild exit code: {ec}")
|
|
70
|
+
|
|
71
|
+
if ec != 0:
|
|
72
|
+
print("BUILD FAILED!")
|
|
73
|
+
client.close()
|
|
74
|
+
exit(1)
|
|
75
|
+
|
|
76
|
+
# Step 8: Start
|
|
77
|
+
print("\n=== Step 8: Start ===")
|
|
78
|
+
run("cd /home/ubuntu/agentx-platform && nohup npx next start -p 8080 > /tmp/fe-start.log 2>&1 &", "start")
|
|
79
|
+
time.sleep(5)
|
|
80
|
+
run("ss -tlnp | grep 8080", "port")
|
|
81
|
+
run("tail -3 /tmp/fe-start.log", "log")
|
|
82
|
+
|
|
83
|
+
client.close()
|
|
84
|
+
print("\n=== DONE ===")
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
# 1. Check balance
|
|
8
|
+
print("=== Checking OxaChain balance ===")
|
|
9
|
+
stdin, stdout, stderr = c.exec_command(
|
|
10
|
+
"export PATH=$HOME/.foundry/bin:$PATH && "
|
|
11
|
+
"cast balance 0x4F7744F97AaC9Ad7f0a67de75b149aDb87464103 --rpc-url http://43.156.99.215:18545 2>&1"
|
|
12
|
+
)
|
|
13
|
+
bal = stdout.read().decode().strip()
|
|
14
|
+
err = stderr.read().decode().strip()
|
|
15
|
+
print(f"Balance: {bal} wei")
|
|
16
|
+
if err: print(f"Error: {err}")
|
|
17
|
+
|
|
18
|
+
if bal == '0':
|
|
19
|
+
print("BALANCE STILL 0 - aborting")
|
|
20
|
+
c.close()
|
|
21
|
+
exit(1)
|
|
22
|
+
|
|
23
|
+
# 2. Start deploy in background
|
|
24
|
+
print("\n=== Starting OxaChain L1 A2A deploy ===")
|
|
25
|
+
stdin, stdout, stderr = c.exec_command(
|
|
26
|
+
"chmod +x /tmp/deploy_a2a_v2.sh && nohup bash /tmp/deploy_a2a_v2.sh &>/dev/null & echo 'PID='$!",
|
|
27
|
+
timeout=10
|
|
28
|
+
)
|
|
29
|
+
print(stdout.read().decode().strip())
|
|
30
|
+
|
|
31
|
+
c.close()
|
|
32
|
+
print("\nDeploy running on server... will check results shortly")
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import paramiko, base64
|
|
2
|
+
|
|
3
|
+
HOST = '43.156.225.164'
|
|
4
|
+
PWD = 'Asdf1234!'
|
|
5
|
+
|
|
6
|
+
c = paramiko.SSHClient()
|
|
7
|
+
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
8
|
+
c.connect(HOST, username='ubuntu', password=PWD, timeout=15)
|
|
9
|
+
|
|
10
|
+
# Setup script
|
|
11
|
+
setup = '''#!/bin/bash
|
|
12
|
+
set -e
|
|
13
|
+
sudo systemctl start postgresql
|
|
14
|
+
sudo systemctl enable postgresql
|
|
15
|
+
sudo systemctl status postgresql --no-pager 2>&1 | head -3
|
|
16
|
+
|
|
17
|
+
# Allow local TCP connections
|
|
18
|
+
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/*/main/postgresql.conf 2>/dev/null || true
|
|
19
|
+
sudo bash -c "echo 'host all all 127.0.0.1/32 md5' >> /etc/postgresql/*/main/pg_hba.conf" 2>/dev/null || true
|
|
20
|
+
sudo systemctl restart postgresql
|
|
21
|
+
|
|
22
|
+
# Create user + DB
|
|
23
|
+
sudo -u postgres psql -c "CREATE USER agentx WITH PASSWORD 'AgentX2024!Gateway' CREATEDB;" 2>&1
|
|
24
|
+
sudo -u postgres psql -c "CREATE DATABASE agentx_gateway OWNER agentx;" 2>&1
|
|
25
|
+
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE agentx_gateway TO agentx;" 2>&1
|
|
26
|
+
echo "PG_SETUP_DONE"
|
|
27
|
+
'''
|
|
28
|
+
b64 = base64.b64encode(setup.encode()).decode()
|
|
29
|
+
stdin, stdout, stderr = c.exec_command(
|
|
30
|
+
f"echo '{b64}' | base64 -d > /tmp/pg_setup.sh && chmod +x /tmp/pg_setup.sh && bash /tmp/pg_setup.sh 2>&1"
|
|
31
|
+
)
|
|
32
|
+
out = stdout.read().decode()
|
|
33
|
+
err = stderr.read().decode()
|
|
34
|
+
print(out)
|
|
35
|
+
if err: print("E:", err[-500:])
|
|
36
|
+
c.close()
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import paramiko
|
|
2
|
+
import tarfile
|
|
3
|
+
import os
|
|
4
|
+
import base64
|
|
5
|
+
import time
|
|
6
|
+
|
|
7
|
+
HOST = '43.156.225.164'
|
|
8
|
+
PWD = 'Asdf1234!'
|
|
9
|
+
PORT = '3000'
|
|
10
|
+
APP_DIR = '/home/ubuntu/agentx-platform'
|
|
11
|
+
|
|
12
|
+
# Step 1: Create tar of frontend source
|
|
13
|
+
local_dir = r'c:\Users\apply\Downloads\code\agentx\extracted\Agentx\frontend'
|
|
14
|
+
tar_path = r'c:\Users\apply\Downloads\code\agentx_fe_prod.tar.gz'
|
|
15
|
+
|
|
16
|
+
print("=== Creating tar ===")
|
|
17
|
+
count = 0
|
|
18
|
+
with tarfile.open(tar_path, 'w:gz') as tar:
|
|
19
|
+
for root, dirs, files in os.walk(local_dir):
|
|
20
|
+
dirs[:] = [d for d in dirs if d not in ('node_modules', '.next', '.git', '__pycache__')]
|
|
21
|
+
for f in files:
|
|
22
|
+
if f.endswith('.tsbuildinfo'): continue
|
|
23
|
+
if f == 'pnpm-lock.yaml': continue
|
|
24
|
+
full = os.path.join(root, f)
|
|
25
|
+
arc = os.path.relpath(full, local_dir).replace('\\', '/')
|
|
26
|
+
tar.add(full, arcname=arc)
|
|
27
|
+
count += 1
|
|
28
|
+
size_kb = os.path.getsize(tar_path) / 1024
|
|
29
|
+
print(f"{count} files, {size_kb:.0f} KB")
|
|
30
|
+
|
|
31
|
+
# Step 2: Upload via SFTP
|
|
32
|
+
print("\n=== Uploading tar ===")
|
|
33
|
+
transport = paramiko.Transport((HOST, 22))
|
|
34
|
+
transport.connect(username='ubuntu', password=PWD)
|
|
35
|
+
sftp = paramiko.SFTPClient.from_transport(transport)
|
|
36
|
+
sftp.put(tar_path, '/tmp/agentx_fe.tar.gz')
|
|
37
|
+
sftp.close()
|
|
38
|
+
transport.close()
|
|
39
|
+
|
|
40
|
+
# Step 3: SSH operations
|
|
41
|
+
c = paramiko.SSHClient()
|
|
42
|
+
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
43
|
+
c.connect(HOST, username='ubuntu', password=PWD, timeout=30)
|
|
44
|
+
|
|
45
|
+
def run(ssh_client, cmd, timeout=600):
|
|
46
|
+
print(f"> {cmd[:120]}")
|
|
47
|
+
stdin, stdout, stderr = ssh_client.exec_command(cmd, timeout=timeout)
|
|
48
|
+
out = stdout.read().decode()
|
|
49
|
+
err = stderr.read().decode()
|
|
50
|
+
ec = stdout.channel.recv_exit_status()
|
|
51
|
+
if out: print(out[-500:])
|
|
52
|
+
if err and 'warn' not in err.lower() and 'deprecated' not in err.lower(): print("E:", err[-300:])
|
|
53
|
+
return ec, out, err
|
|
54
|
+
|
|
55
|
+
# Extract
|
|
56
|
+
run(c, f"rm -rf {APP_DIR} && mkdir -p {APP_DIR} && cd {APP_DIR} && tar xzf /tmp/agentx_fe.tar.gz && echo 'extracted'")
|
|
57
|
+
|
|
58
|
+
# Upload .env.production with correct APP_URL
|
|
59
|
+
env_content = """# ============================================================
|
|
60
|
+
# AgentX Platform — PRODUCTION Environment Configuration
|
|
61
|
+
# ============================================================
|
|
62
|
+
NEXT_PUBLIC_APP_NAME="AgentX"
|
|
63
|
+
NEXT_PUBLIC_APP_URL=http://43.156.225.164:3000
|
|
64
|
+
NEXT_PUBLIC_DEFAULT_CHAIN_ID=11155111
|
|
65
|
+
|
|
66
|
+
# ── Sepolia (11155111) ──────────────────────────────────────
|
|
67
|
+
NEXT_PUBLIC_SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/63ee183a3afa43208e99d6f3f1e7c5fb
|
|
68
|
+
NEXT_PUBLIC_SEPOLIA_IDENTITY_REGISTRY=0xe94ad380d3F8d08a7590eda0C84f354a93F96e5F
|
|
69
|
+
NEXT_PUBLIC_SEPOLIA_SUBSCRIPTION_MANAGER=0xC15fE80b9d800abb72121F353a6ae6d6E9077E63
|
|
70
|
+
NEXT_PUBLIC_SEPOLIA_REPUTATION_REGISTRY=0xeb6B410ea71b8d9dA0c96f6A91d35027CE143DC9
|
|
71
|
+
NEXT_PUBLIC_SEPOLIA_CONFIGURATION_REGISTRY=0x68DcE00e4C9077c94BC68016cD14B09557faEA6c
|
|
72
|
+
NEXT_PUBLIC_SEPOLIA_MULTI_ENDPOINT=0xEB5e866f186d4B73F97aa0d70B86f2C6e2e21Cb7
|
|
73
|
+
NEXT_PUBLIC_SEPOLIA_A2A_PROTOCOL=0x309C7447d89f3087A9924BB686d88df020F7e9cB
|
|
74
|
+
|
|
75
|
+
# ── OxaChain L1 (19505) ────────────────────────────────────
|
|
76
|
+
NEXT_PUBLIC_OXACHAIN_RPC_URL=http://43.156.99.215:18545
|
|
77
|
+
NEXT_PUBLIC_OXACHAIN_EXPLORER=http://43.156.99.215:18400
|
|
78
|
+
NEXT_PUBLIC_OXACHAIN_IDENTITY_REGISTRY=0xbf5F9db266c8c97E3334466C88597Eb758AfE212
|
|
79
|
+
NEXT_PUBLIC_OXACHAIN_SUBSCRIPTION_MANAGER=0x019AC9d945467478Dd371CDbD70cb2f325800E6B
|
|
80
|
+
NEXT_PUBLIC_OXACHAIN_REPUTATION_REGISTRY=0x6a18C2664E1b42063860d864b6448b824d7B843F
|
|
81
|
+
NEXT_PUBLIC_OXACHAIN_CONFIGURATION_REGISTRY=0x07280674ccc2898Fd038A9e3C22005CA83ffD2F8
|
|
82
|
+
NEXT_PUBLIC_OXACHAIN_MULTI_ENDPOINT=0xB361d04F49000013FC131D3C59C41c8486C64f8c
|
|
83
|
+
NEXT_PUBLIC_OXACHAIN_A2A_PROTOCOL=0xDF2939EFafEe6439eB2226DbEd07AD6F5Ae2112B
|
|
84
|
+
|
|
85
|
+
# ── Legacy (compat) ────────────────────────────────────────
|
|
86
|
+
NEXT_PUBLIC_IDENTITY_REGISTRY_ADDRESS=0xe94ad380d3F8d08a7590eda0C84f354a93F96e5F
|
|
87
|
+
NEXT_PUBLIC_SUBSCRIPTION_MANAGER_ADDRESS=0xC15fE80b9d800abb72121F353a6ae6d6E9077E63
|
|
88
|
+
NEXT_PUBLIC_REPUTATION_REGISTRY_ADDRESS=0xeb6B410ea71b8d9dA0c96f6A91d35027CE143DC9
|
|
89
|
+
NEXT_PUBLIC_CONFIGURATION_REGISTRY_ADDRESS=0x68DcE00e4C9077c94BC68016cD14B09557faEA6c
|
|
90
|
+
NEXT_PUBLIC_MULTI_ENDPOINT_ADDRESS=0xEB5e866f186d4B73F97aa0d70B86f2C6e2e21Cb7
|
|
91
|
+
NEXT_PUBLIC_A2A_PROTOCOL_ADDRESS=0x309C7447d89f3087A9924BB686d88df020F7e9cB
|
|
92
|
+
|
|
93
|
+
# ── Gateway ─────────────────────────────────────────────────
|
|
94
|
+
NEXT_PUBLIC_AGENTX_GATEWAY_URL=http://101.33.109.117:3090
|
|
95
|
+
"""
|
|
96
|
+
b64 = base64.b64encode(env_content.encode()).decode()
|
|
97
|
+
run(c, f"echo '{b64}' | base64 -d > {APP_DIR}/.env.production && echo 'env written'")
|
|
98
|
+
run(c, f"cat > {APP_DIR}/.env.local << 'EOF'\nNEXT_PUBLIC_AGENTX_GATEWAY_URL=http://101.33.109.117:3090\nEOF\necho 'env.local written'")
|
|
99
|
+
|
|
100
|
+
# npm install
|
|
101
|
+
print("\n=== npm install ===")
|
|
102
|
+
ec, out, err = run(c, f"cd {APP_DIR} && npm install 2>&1 | tail -10", timeout=300)
|
|
103
|
+
|
|
104
|
+
# Build
|
|
105
|
+
print("\n=== next build (this takes 2-4 min) ===")
|
|
106
|
+
ec, out, err = run(c, f"cd {APP_DIR} && NODE_OPTIONS='--max-old-space-size=2560' npx next build 2>&1 | tail -25", timeout=600)
|
|
107
|
+
print(f"\nBuild exit: {ec}")
|
|
108
|
+
|
|
109
|
+
if ec != 0:
|
|
110
|
+
print("BUILD FAILED!")
|
|
111
|
+
run(c, "free -h")
|
|
112
|
+
c.close()
|
|
113
|
+
exit(1)
|
|
114
|
+
|
|
115
|
+
# Start
|
|
116
|
+
print(f"\n=== Starting on port {PORT} ===")
|
|
117
|
+
run(c, f"fuser -k {PORT}/tcp 2>/dev/null; sleep 1")
|
|
118
|
+
# Use pm2 if not available, use nohup
|
|
119
|
+
run(c, f"cd {APP_DIR} && nohup npx next start -p {PORT} > /tmp/agentx-prod.log 2>&1 &", timeout=5)
|
|
120
|
+
time.sleep(6)
|
|
121
|
+
run(c, f"ss -tlnp | grep {PORT}")
|
|
122
|
+
run(c, "tail -3 /tmp/agentx-prod.log")
|
|
123
|
+
run(c, f"curl -sI http://localhost:{PORT}/ 2>&1 | head -5")
|
|
124
|
+
|
|
125
|
+
c.close()
|
|
126
|
+
print("\n=== DEPLOYMENT DONE ===")
|