a2acalling 0.6.23 → 0.6.25
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/bin/cli.js +53 -10
- package/package.json +1 -1
- package/src/lib/invite-host.js +2 -1
package/bin/cli.js
CHANGED
|
@@ -407,15 +407,36 @@ async function resolveInviteHostname() {
|
|
|
407
407
|
try {
|
|
408
408
|
const { A2AConfig } = require('../src/lib/config');
|
|
409
409
|
const config = new A2AConfig();
|
|
410
|
+
const agent = config.getAgent() || {};
|
|
411
|
+
const onboarding = config.getAll().onboarding || {};
|
|
412
|
+
|
|
413
|
+
// If hostname is set without a port (e.g., "149.28.213.47"), assume port 80
|
|
414
|
+
// (user configured reverse proxy or direct bind to 80)
|
|
415
|
+
// If hostname has a port (e.g., "149.28.213.47:3007"), use that port
|
|
416
|
+
// If no hostname set, use server_port from onboarding
|
|
417
|
+
const hostname = agent.hostname || '';
|
|
418
|
+
const hasExplicitPort = hostname.includes(':') && !hostname.startsWith('[');
|
|
419
|
+
|
|
420
|
+
let defaultPort;
|
|
421
|
+
if (hasExplicitPort) {
|
|
422
|
+
defaultPort = null; // Will be parsed from hostname
|
|
423
|
+
} else if (hostname && !hostname.includes('localhost')) {
|
|
424
|
+
// External hostname without port = assume port 80 (reverse proxy or direct)
|
|
425
|
+
defaultPort = 80;
|
|
426
|
+
} else {
|
|
427
|
+
// Local or no hostname - use actual server port
|
|
428
|
+
defaultPort = onboarding.server_port || process.env.PORT || process.env.A2A_PORT || 80;
|
|
429
|
+
}
|
|
430
|
+
|
|
410
431
|
const resolved = await resolveInviteHost({
|
|
411
432
|
config,
|
|
412
|
-
defaultPort
|
|
433
|
+
defaultPort
|
|
413
434
|
});
|
|
414
435
|
return resolved;
|
|
415
436
|
} catch (err) {
|
|
416
437
|
return resolveInviteHost({
|
|
417
438
|
fallbackHost: process.env.OPENCLAW_HOSTNAME || process.env.HOSTNAME || 'localhost',
|
|
418
|
-
defaultPort: process.env.PORT || process.env.A2A_PORT ||
|
|
439
|
+
defaultPort: process.env.PORT || process.env.A2A_PORT || 80
|
|
419
440
|
});
|
|
420
441
|
}
|
|
421
442
|
}
|
|
@@ -1459,26 +1480,48 @@ https://github.com/onthegonow/a2a_calling`;
|
|
|
1459
1480
|
console.log(`\n RECOMMENDED: Configure reverse proxy to route /api/a2a/* to port ${serverPort}`);
|
|
1460
1481
|
|
|
1461
1482
|
if (hasNginx) {
|
|
1462
|
-
console.log(`\n
|
|
1483
|
+
console.log(`\n ┌─────────────────────────────────────────────────────────────────┐`);
|
|
1484
|
+
console.log(` │ nginx config — add inside your server {} block │`);
|
|
1485
|
+
console.log(` │ File: /etc/nginx/sites-available/default │`);
|
|
1486
|
+
console.log(` └─────────────────────────────────────────────────────────────────┘`);
|
|
1487
|
+
console.log(``);
|
|
1488
|
+
console.log(` # ══════════════════════════════════════════════════════════════`);
|
|
1489
|
+
console.log(` # A2A (Agent-to-Agent) Protocol Proxy`);
|
|
1490
|
+
console.log(` # ══════════════════════════════════════════════════════════════`);
|
|
1491
|
+
console.log(` # A2A enables AI agents to communicate across different instances.`);
|
|
1492
|
+
console.log(` # This proxy routes federation requests from port 80 to the local`);
|
|
1493
|
+
console.log(` # A2A server on port ${serverPort}.`);
|
|
1494
|
+
console.log(` #`);
|
|
1495
|
+
console.log(` # Protocol: https://github.com/onthegonow/a2a_calling`);
|
|
1496
|
+
console.log(` # All requests to /api/a2a/* are agent-to-agent API calls.`);
|
|
1497
|
+
console.log(` # ══════════════════════════════════════════════════════════════`);
|
|
1463
1498
|
console.log(` location /api/a2a/ {`);
|
|
1464
1499
|
console.log(` proxy_pass http://127.0.0.1:${serverPort}/api/a2a/;`);
|
|
1465
1500
|
console.log(` proxy_http_version 1.1;`);
|
|
1466
1501
|
console.log(` proxy_set_header Host $host;`);
|
|
1467
1502
|
console.log(` proxy_set_header X-Real-IP $remote_addr;`);
|
|
1503
|
+
console.log(` proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;`);
|
|
1504
|
+
console.log(` proxy_set_header X-Forwarded-Proto $scheme;`);
|
|
1468
1505
|
console.log(` }`);
|
|
1469
|
-
console.log(
|
|
1470
|
-
console.log(
|
|
1471
|
-
console.log(` sudo nano /etc/nginx/sites-available/default`);
|
|
1472
|
-
console.log(`
|
|
1473
|
-
console.log(` sudo nginx -t
|
|
1506
|
+
console.log(``);
|
|
1507
|
+
console.log(` To apply:`);
|
|
1508
|
+
console.log(` 1. sudo nano /etc/nginx/sites-available/default`);
|
|
1509
|
+
console.log(` 2. Add the config above inside your server { } block`);
|
|
1510
|
+
console.log(` 3. sudo nginx -t`);
|
|
1511
|
+
console.log(` 4. sudo systemctl reload nginx`);
|
|
1474
1512
|
}
|
|
1475
1513
|
|
|
1476
1514
|
if (hasCaddy) {
|
|
1477
|
-
console.log(`\n
|
|
1515
|
+
console.log(`\n ┌─────────────────────────────────────────────────────────────────┐`);
|
|
1516
|
+
console.log(` │ Caddy config │`);
|
|
1517
|
+
console.log(` └─────────────────────────────────────────────────────────────────┘`);
|
|
1518
|
+
console.log(``);
|
|
1519
|
+
console.log(` # A2A (Agent-to-Agent) Protocol Proxy`);
|
|
1520
|
+
console.log(` # Routes federation requests to local A2A server on port ${serverPort}`);
|
|
1521
|
+
console.log(` # Protocol: https://github.com/onthegonow/a2a_calling`);
|
|
1478
1522
|
console.log(` handle /api/a2a/* {`);
|
|
1479
1523
|
console.log(` reverse_proxy 127.0.0.1:${serverPort}`);
|
|
1480
1524
|
console.log(` }`);
|
|
1481
|
-
console.log(` ───────────────────`);
|
|
1482
1525
|
}
|
|
1483
1526
|
|
|
1484
1527
|
console.log(`\n After reverse proxy is configured:`);
|
package/package.json
CHANGED
package/src/lib/invite-host.js
CHANGED
|
@@ -74,7 +74,8 @@ function formatHostPort(hostname, port) {
|
|
|
74
74
|
if (!host) return '';
|
|
75
75
|
const needsBrackets = net.isIP(host) === 6;
|
|
76
76
|
const hostPart = needsBrackets ? `[${host}]` : host;
|
|
77
|
-
|
|
77
|
+
// Don't append port 80 (it's the default HTTP port)
|
|
78
|
+
return (p && p !== 80) ? `${hostPart}:${p}` : hostPart;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
function isPrivateIpv4(ip) {
|