open-agents-nexus 0.2.0 → 0.3.0
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/dist/config.d.ts +2 -0
- package/dist/config.js.map +1 -1
- package/dist/discovery.d.ts +60 -21
- package/dist/discovery.js +106 -24
- package/dist/discovery.js.map +1 -1
- package/dist/node.js +9 -3
- package/dist/node.js.map +1 -1
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface NexusConfig {
|
|
|
12
12
|
enableCircuitRelay?: boolean;
|
|
13
13
|
enablePubsubDiscovery?: boolean;
|
|
14
14
|
enableMdns?: boolean;
|
|
15
|
+
useDnsaddr?: boolean;
|
|
16
|
+
useTcpBootstrap?: boolean;
|
|
15
17
|
datastorePath?: string;
|
|
16
18
|
connectionTimeoutMs: number;
|
|
17
19
|
syncTimeoutMs: number;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAuCA,MAAM,CAAC,MAAM,cAAc,GAAgB;IACzC,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,0BAA0B;IAC3C,IAAI,EAAE,MAAM;IACZ,eAAe,EAAE;QACf,oBAAoB;QACpB,uBAAuB;KACxB;IACD,SAAS,EAAE,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAC5D,SAAS,EAAE,YAAY;IACvB,mBAAmB,EAAE,MAAM;IAC3B,aAAa,EAAE,MAAM;IACrB,oBAAoB,EAAE,EAAE;IACxB,mBAAmB,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,OAA8B;IAC1D,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;AAC3C,CAAC"}
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,43 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Multi-layer peer discovery cascade
|
|
2
|
+
* Multi-layer peer discovery cascade with comprehensive free fallbacks
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Agents find each other across the internet with zero configuration.
|
|
5
|
+
* Every discovery method is free, public, and requires no accounts.
|
|
6
6
|
*
|
|
7
|
-
* Discovery levels (
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* Discovery levels (all active simultaneously, graceful degradation):
|
|
8
|
+
*
|
|
9
|
+
* Level 1: Signaling Server (openagents.nexus)
|
|
10
|
+
* → HTTP fetch for bootstrap peers from the nexus hub
|
|
11
|
+
* → Fails gracefully if hub is down
|
|
12
|
+
*
|
|
13
|
+
* Level 2: Public WebSocket Bootstrap Nodes (Protocol Labs + IPFS)
|
|
14
|
+
* → 15+ well-known nodes across 3 continents
|
|
15
|
+
* → Both /dns4/.../wss and /dnsaddr/ formats for maximum compatibility
|
|
16
|
+
* → These are free public infrastructure maintained by Protocol Labs
|
|
17
|
+
*
|
|
18
|
+
* Level 3: Pubsub Peer Discovery (multiple redundant topics)
|
|
19
|
+
* → 3 discovery topics — if one is congested, others still work
|
|
20
|
+
* → Any nexus agent on ANY topic discovers ALL others
|
|
21
|
+
* → Self-organizing: more agents = more reliable discovery
|
|
22
|
+
*
|
|
23
|
+
* Level 4: mDNS (LAN)
|
|
24
|
+
* → Zero-config local network discovery
|
|
25
|
+
* → Works without internet
|
|
26
|
+
*
|
|
27
|
+
* Level 5: Circuit Relay v2 (NAT traversal)
|
|
28
|
+
* → Agents behind NAT relay through public nodes
|
|
29
|
+
* → Full/storage nodes serve as free relays for the network
|
|
30
|
+
*
|
|
31
|
+
* Level 6: DHT Random Walk
|
|
32
|
+
* → Once connected to ANY peer, DHT walking finds more
|
|
33
|
+
* → Our private /nexus/kad/1.0.0 DHT self-discovers
|
|
13
34
|
*/
|
|
14
35
|
export declare const PUBLIC_BOOTSTRAP_WSS: string[];
|
|
36
|
+
export declare const PUBLIC_BOOTSTRAP_DNSADDR: string[];
|
|
37
|
+
export declare const PUBLIC_BOOTSTRAP_TCP: string[];
|
|
38
|
+
export declare const ALL_PUBLIC_BOOTSTRAP: string[];
|
|
15
39
|
export declare const NEXUS_DISCOVERY_TOPIC = "_nexus._peer-discovery._p2p._pubsub";
|
|
40
|
+
export declare const NEXUS_DISCOVERY_TOPICS: string[];
|
|
16
41
|
export interface DiscoveryConfig {
|
|
17
|
-
/**
|
|
42
|
+
/** Connect to public Protocol Labs bootstrap nodes (free, global) */
|
|
18
43
|
usePublicBootstrap: boolean;
|
|
19
|
-
/**
|
|
44
|
+
/** Enable circuit relay v2 (NAT traversal via free public relays) */
|
|
20
45
|
enableCircuitRelay: boolean;
|
|
21
|
-
/**
|
|
46
|
+
/** Enable pubsub-based peer discovery on all NEXUS_DISCOVERY_TOPICS */
|
|
22
47
|
enablePubsubDiscovery: boolean;
|
|
23
|
-
/**
|
|
48
|
+
/** Enable mDNS (LAN discovery, no internet needed) */
|
|
24
49
|
enableMdns: boolean;
|
|
25
|
-
/**
|
|
50
|
+
/** Use DNS-based bootstrap addresses (more resilient to IP changes) */
|
|
51
|
+
useDnsaddr: boolean;
|
|
52
|
+
/** Use TCP bootstrap nodes (server-to-server, no WSS overhead) */
|
|
53
|
+
useTcpBootstrap: boolean;
|
|
54
|
+
/** Additional user-supplied bootstrap peers */
|
|
26
55
|
customBootstrapPeers: string[];
|
|
56
|
+
/** Pubsub discovery interval in ms (lower = faster discovery, more bandwidth) */
|
|
57
|
+
pubsubDiscoveryIntervalMs: number;
|
|
27
58
|
}
|
|
28
59
|
export declare const DEFAULT_DISCOVERY: DiscoveryConfig;
|
|
29
60
|
/**
|
|
30
|
-
* Merge
|
|
31
|
-
* Does not mutate the defaults.
|
|
61
|
+
* Merge partial discovery config with defaults (does not mutate defaults).
|
|
32
62
|
*/
|
|
33
63
|
export declare function resolveDiscovery(partial?: Partial<DiscoveryConfig>): DiscoveryConfig;
|
|
34
64
|
/**
|
|
35
|
-
* Build the complete bootstrap peer list from all
|
|
36
|
-
*
|
|
65
|
+
* Build the complete bootstrap peer list from all available sources.
|
|
66
|
+
* Sources (in priority order):
|
|
67
|
+
* 1. Signaling server peers (freshest, most relevant)
|
|
37
68
|
* 2. Custom user-supplied peers
|
|
38
|
-
* 3.
|
|
69
|
+
* 3. Public WSS bootstrap nodes (global, free)
|
|
70
|
+
* 4. Public dnsaddr bootstrap nodes (resilient to IP changes)
|
|
71
|
+
* 5. Public TCP bootstrap nodes (server-to-server)
|
|
39
72
|
*
|
|
40
|
-
* Deduplicates
|
|
41
|
-
*
|
|
73
|
+
* Deduplicates by PeerId to avoid connecting to the same node twice
|
|
74
|
+
* even when it appears with different transport multiaddrs.
|
|
42
75
|
*/
|
|
43
76
|
export declare function buildBootstrapList(config: DiscoveryConfig, signalingPeers?: string[]): string[];
|
|
77
|
+
/**
|
|
78
|
+
* Get the list of pubsub discovery topics for this node.
|
|
79
|
+
* Using multiple topics provides redundancy — if one mesh is fragmented,
|
|
80
|
+
* agents can still discover each other through the other topics.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getDiscoveryTopics(): string[];
|
package/dist/discovery.js
CHANGED
|
@@ -1,70 +1,152 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Multi-layer peer discovery cascade
|
|
2
|
+
* Multi-layer peer discovery cascade with comprehensive free fallbacks
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Agents find each other across the internet with zero configuration.
|
|
5
|
+
* Every discovery method is free, public, and requires no accounts.
|
|
6
6
|
*
|
|
7
|
-
* Discovery levels (
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* Discovery levels (all active simultaneously, graceful degradation):
|
|
8
|
+
*
|
|
9
|
+
* Level 1: Signaling Server (openagents.nexus)
|
|
10
|
+
* → HTTP fetch for bootstrap peers from the nexus hub
|
|
11
|
+
* → Fails gracefully if hub is down
|
|
12
|
+
*
|
|
13
|
+
* Level 2: Public WebSocket Bootstrap Nodes (Protocol Labs + IPFS)
|
|
14
|
+
* → 15+ well-known nodes across 3 continents
|
|
15
|
+
* → Both /dns4/.../wss and /dnsaddr/ formats for maximum compatibility
|
|
16
|
+
* → These are free public infrastructure maintained by Protocol Labs
|
|
17
|
+
*
|
|
18
|
+
* Level 3: Pubsub Peer Discovery (multiple redundant topics)
|
|
19
|
+
* → 3 discovery topics — if one is congested, others still work
|
|
20
|
+
* → Any nexus agent on ANY topic discovers ALL others
|
|
21
|
+
* → Self-organizing: more agents = more reliable discovery
|
|
22
|
+
*
|
|
23
|
+
* Level 4: mDNS (LAN)
|
|
24
|
+
* → Zero-config local network discovery
|
|
25
|
+
* → Works without internet
|
|
26
|
+
*
|
|
27
|
+
* Level 5: Circuit Relay v2 (NAT traversal)
|
|
28
|
+
* → Agents behind NAT relay through public nodes
|
|
29
|
+
* → Full/storage nodes serve as free relays for the network
|
|
30
|
+
*
|
|
31
|
+
* Level 6: DHT Random Walk
|
|
32
|
+
* → Once connected to ANY peer, DHT walking finds more
|
|
33
|
+
* → Our private /nexus/kad/1.0.0 DHT self-discovers
|
|
13
34
|
*/
|
|
14
|
-
//
|
|
15
|
-
//
|
|
35
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
36
|
+
// PUBLIC BOOTSTRAP NODES — Free, maintained by Protocol Labs / IPFS
|
|
37
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
38
|
+
// WebSocket Secure (WSS) bootstrap nodes — work from both Node.js and browsers
|
|
16
39
|
export const PUBLIC_BOOTSTRAP_WSS = [
|
|
40
|
+
// Protocol Labs Amino DHT bootstrappers (WebSocket on port 443)
|
|
17
41
|
'/dns4/am6.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
|
|
18
42
|
'/dns4/sg1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt',
|
|
19
43
|
'/dns4/sv15.bootstrap.libp2p.io/tcp/443/wss/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
|
|
44
|
+
// Protocol Labs geographic bootstrap nodes (WSS)
|
|
20
45
|
'/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
|
|
21
46
|
'/dns4/sfo-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx',
|
|
22
47
|
'/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
|
|
48
|
+
'/dns4/sfo-2.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
|
|
49
|
+
'/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
|
|
50
|
+
'/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
|
|
23
51
|
'/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
|
|
52
|
+
'/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
|
|
53
|
+
];
|
|
54
|
+
// DNS-based bootstrap (dnsaddr records — auto-resolve to current IPs)
|
|
55
|
+
// These are more resilient than hardcoded IPs because Protocol Labs can
|
|
56
|
+
// update the underlying addresses without requiring a package update.
|
|
57
|
+
export const PUBLIC_BOOTSTRAP_DNSADDR = [
|
|
58
|
+
'/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
|
|
59
|
+
'/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa',
|
|
60
|
+
'/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
|
|
61
|
+
'/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt',
|
|
62
|
+
];
|
|
63
|
+
// TCP bootstrap nodes (for server-to-server when WSS isn't needed)
|
|
64
|
+
export const PUBLIC_BOOTSTRAP_TCP = [
|
|
65
|
+
'/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
|
|
24
66
|
];
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
67
|
+
// Combined: all free public bootstrap nodes
|
|
68
|
+
export const ALL_PUBLIC_BOOTSTRAP = [
|
|
69
|
+
...PUBLIC_BOOTSTRAP_WSS,
|
|
70
|
+
...PUBLIC_BOOTSTRAP_DNSADDR,
|
|
71
|
+
...PUBLIC_BOOTSTRAP_TCP,
|
|
72
|
+
];
|
|
73
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
74
|
+
// PUBSUB DISCOVERY TOPICS — Multiple for redundancy
|
|
75
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
76
|
+
// Primary discovery topic — all nexus agents subscribe here
|
|
28
77
|
export const NEXUS_DISCOVERY_TOPIC = '_nexus._peer-discovery._p2p._pubsub';
|
|
78
|
+
// Redundant discovery topics — if one is congested or has issues, others work
|
|
79
|
+
// Using multiple topics ensures agents can always find each other even if
|
|
80
|
+
// some GossipSub meshes are fragmented
|
|
81
|
+
export const NEXUS_DISCOVERY_TOPICS = [
|
|
82
|
+
'_nexus._peer-discovery._p2p._pubsub', // Primary
|
|
83
|
+
'nexus:agents:discovery:v1', // Alternate namespace
|
|
84
|
+
'_open-agents._nexus._discovery', // Fallback
|
|
85
|
+
];
|
|
29
86
|
export const DEFAULT_DISCOVERY = {
|
|
30
87
|
usePublicBootstrap: true,
|
|
31
88
|
enableCircuitRelay: true,
|
|
32
89
|
enablePubsubDiscovery: true,
|
|
33
90
|
enableMdns: true,
|
|
91
|
+
useDnsaddr: true,
|
|
92
|
+
useTcpBootstrap: true,
|
|
34
93
|
customBootstrapPeers: [],
|
|
94
|
+
pubsubDiscoveryIntervalMs: 10_000,
|
|
35
95
|
};
|
|
36
96
|
/**
|
|
37
|
-
* Merge
|
|
38
|
-
* Does not mutate the defaults.
|
|
97
|
+
* Merge partial discovery config with defaults (does not mutate defaults).
|
|
39
98
|
*/
|
|
40
99
|
export function resolveDiscovery(partial) {
|
|
41
100
|
return { ...DEFAULT_DISCOVERY, ...partial };
|
|
42
101
|
}
|
|
43
102
|
/**
|
|
44
|
-
* Build the complete bootstrap peer list from all
|
|
45
|
-
*
|
|
103
|
+
* Build the complete bootstrap peer list from all available sources.
|
|
104
|
+
* Sources (in priority order):
|
|
105
|
+
* 1. Signaling server peers (freshest, most relevant)
|
|
46
106
|
* 2. Custom user-supplied peers
|
|
47
|
-
* 3.
|
|
107
|
+
* 3. Public WSS bootstrap nodes (global, free)
|
|
108
|
+
* 4. Public dnsaddr bootstrap nodes (resilient to IP changes)
|
|
109
|
+
* 5. Public TCP bootstrap nodes (server-to-server)
|
|
48
110
|
*
|
|
49
|
-
* Deduplicates
|
|
50
|
-
*
|
|
111
|
+
* Deduplicates by PeerId to avoid connecting to the same node twice
|
|
112
|
+
* even when it appears with different transport multiaddrs.
|
|
51
113
|
*/
|
|
52
114
|
export function buildBootstrapList(config, signalingPeers = []) {
|
|
53
115
|
const peers = new Set();
|
|
54
|
-
// Signaling server peers
|
|
116
|
+
// 1. Signaling server peers (highest priority)
|
|
55
117
|
for (const peer of signalingPeers) {
|
|
56
118
|
peers.add(peer);
|
|
57
119
|
}
|
|
58
|
-
// Custom
|
|
120
|
+
// 2. Custom peers
|
|
59
121
|
for (const peer of config.customBootstrapPeers) {
|
|
60
122
|
peers.add(peer);
|
|
61
123
|
}
|
|
62
|
-
// Public bootstrap nodes
|
|
124
|
+
// 3. Public WSS bootstrap nodes
|
|
63
125
|
if (config.usePublicBootstrap) {
|
|
64
126
|
for (const peer of PUBLIC_BOOTSTRAP_WSS) {
|
|
65
127
|
peers.add(peer);
|
|
66
128
|
}
|
|
67
129
|
}
|
|
130
|
+
// 4. DNS-based bootstrap (auto-resolving)
|
|
131
|
+
if (config.useDnsaddr) {
|
|
132
|
+
for (const peer of PUBLIC_BOOTSTRAP_DNSADDR) {
|
|
133
|
+
peers.add(peer);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// 5. TCP bootstrap nodes
|
|
137
|
+
if (config.useTcpBootstrap) {
|
|
138
|
+
for (const peer of PUBLIC_BOOTSTRAP_TCP) {
|
|
139
|
+
peers.add(peer);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
68
142
|
return Array.from(peers);
|
|
69
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Get the list of pubsub discovery topics for this node.
|
|
146
|
+
* Using multiple topics provides redundancy — if one mesh is fragmented,
|
|
147
|
+
* agents can still discover each other through the other topics.
|
|
148
|
+
*/
|
|
149
|
+
export function getDiscoveryTopics() {
|
|
150
|
+
return [...NEXUS_DISCOVERY_TOPICS];
|
|
151
|
+
}
|
|
70
152
|
//# sourceMappingURL=discovery.js.map
|
package/dist/discovery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AAEtE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,gEAAgE;IAChE,8FAA8F;IAC9F,8FAA8F;IAC9F,+FAA+F;IAC/F,iDAAiD;IACjD,gGAAgG;IAChG,gGAAgG;IAChG,gGAAgG;IAChG,gGAAgG;IAChG,gGAAgG;IAChG,gGAAgG;IAChG,gGAAgG;IAChG,gGAAgG;CACjG,CAAC;AAEF,sEAAsE;AACtE,wEAAwE;AACxE,sEAAsE;AACtE,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,iFAAiF;IACjF,iFAAiF;IACjF,iFAAiF;IACjF,iFAAiF;CAClF,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,iFAAiF;CAClF,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,GAAG,oBAAoB;IACvB,GAAG,wBAAwB;IAC3B,GAAG,oBAAoB;CACxB,CAAC;AAEF,sEAAsE;AACtE,oDAAoD;AACpD,sEAAsE;AAEtE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,qCAAqC,CAAC;AAE3E,8EAA8E;AAC9E,0EAA0E;AAC1E,uCAAuC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,qCAAqC,EAAQ,UAAU;IACvD,2BAA2B,EAAoB,sBAAsB;IACrE,gCAAgC,EAAe,WAAW;CAC3D,CAAC;AAyBF,MAAM,CAAC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C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,CAAC,GAAG,sBAAsB,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/node.js
CHANGED
|
@@ -29,7 +29,7 @@ import { ping } from '@libp2p/ping';
|
|
|
29
29
|
import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay-v2';
|
|
30
30
|
import { pubsubPeerDiscovery } from '@libp2p/pubsub-peer-discovery';
|
|
31
31
|
import { msgIdFn as nexusMsgIdFn, PROTOCOLS } from './protocol/index.js';
|
|
32
|
-
import { resolveDiscovery, buildBootstrapList,
|
|
32
|
+
import { resolveDiscovery, buildBootstrapList, getDiscoveryTopics, } from './discovery.js';
|
|
33
33
|
import { createLogger } from './logger.js';
|
|
34
34
|
const log = createLogger('node');
|
|
35
35
|
/**
|
|
@@ -59,6 +59,8 @@ export async function createNexusNode(config, privateKey, discoveryConfig, signa
|
|
|
59
59
|
enableCircuitRelay: config.enableCircuitRelay,
|
|
60
60
|
enablePubsubDiscovery: config.enablePubsubDiscovery,
|
|
61
61
|
enableMdns: config.enableMdns,
|
|
62
|
+
useDnsaddr: config.useDnsaddr,
|
|
63
|
+
useTcpBootstrap: config.useTcpBootstrap,
|
|
62
64
|
...discoveryConfig,
|
|
63
65
|
});
|
|
64
66
|
// Build the combined bootstrap peer list from all sources
|
|
@@ -74,11 +76,15 @@ export async function createNexusNode(config, privateKey, discoveryConfig, signa
|
|
|
74
76
|
peerDiscovery.push(mdns());
|
|
75
77
|
}
|
|
76
78
|
if (discovery.enablePubsubDiscovery) {
|
|
79
|
+
// Subscribe to ALL discovery topics for maximum redundancy.
|
|
80
|
+
// If one mesh is fragmented, agents still find each other via the others.
|
|
81
|
+
const topics = getDiscoveryTopics();
|
|
77
82
|
peerDiscovery.push(pubsubPeerDiscovery({
|
|
78
|
-
interval: 10_000,
|
|
79
|
-
topics
|
|
83
|
+
interval: discovery.pubsubDiscoveryIntervalMs ?? 10_000,
|
|
84
|
+
topics,
|
|
80
85
|
listenOnly: false,
|
|
81
86
|
}));
|
|
87
|
+
log.info(`Pubsub discovery on ${topics.length} topics: ${topics.join(', ')}`);
|
|
82
88
|
}
|
|
83
89
|
// Build transport list — always include circuit relay transport so we can
|
|
84
90
|
// both dial and receive relay-mediated connections.
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EACL,gBAAgB,EA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AAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1D;KACF,CAAC,CAAC;IAEH,GAAG,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAChE,GAAG,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,GAAG,CAAC,IAAI,CACN,wBAAwB,aAAa,CAAC,MAAM,UAAU;QACtD,QAAQ,SAAS,CAAC,UAAU,IAAI;QAChC,UAAU,SAAS,CAAC,qBAAqB,IAAI;QAC7C,SAAS,SAAS,CAAC,kBAAkB,EAAE,CACxC,CAAC;IACF,GAAG,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEtF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-agents-nexus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Zero-config decentralized agent-to-agent communication. Agents npm install, connect, and talk — no servers, no accounts, no surveillance. Built on libp2p + IPFS with encrypted P2P mesh networking, viral content pinning, and automatic peer discovery.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|