libp2p-mesh 2026.5.32 → 2026.6.2
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/README.md +66 -79
- package/api.ts +19 -1
- package/dist/api.d.ts +3 -1
- package/dist/api.js +2 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +23 -0
- package/dist/src/agent-tools.d.ts +181 -80
- package/dist/src/agent-tools.js +155 -146
- package/dist/src/inbound-delivery.d.ts +11 -0
- package/dist/src/inbound-delivery.js +83 -0
- package/dist/src/inbound.d.ts +3 -10
- package/dist/src/inbound.js +4 -139
- package/dist/src/instance-peer-store.d.ts +11 -0
- package/dist/src/instance-peer-store.js +135 -0
- package/dist/src/instance-router.d.ts +14 -0
- package/dist/src/instance-router.js +326 -0
- package/dist/src/mesh.js +56 -29
- package/dist/src/plugin.js +30 -159
- package/dist/src/types.d.ts +106 -5
- package/index.ts +24 -1
- package/openclaw.plugin.json +33 -8
- package/package.json +2 -4
- package/src/agent-tools.ts +161 -152
- package/src/inbound-delivery.ts +117 -0
- package/src/inbound.ts +6 -149
- package/src/instance-peer-store.ts +186 -0
- package/src/instance-router.ts +426 -0
- package/src/mesh.ts +76 -34
- package/src/plugin.ts +31 -174
- package/src/types.ts +124 -5
- package/dist/src/identity-exchange.d.ts +0 -19
- package/dist/src/identity-exchange.js +0 -64
- package/dist/src/peer-identity.d.ts +0 -37
- package/dist/src/peer-identity.js +0 -130
- package/src/identity-exchange.ts +0 -111
- package/src/peer-identity.ts +0 -176
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MeshNetwork } from "./types.js";
|
|
2
|
-
export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
1
|
+
import type { InstanceRouter, MeshNetwork } from "./types.js";
|
|
2
|
+
export declare function buildP2PTools(mesh: MeshNetwork, router?: InstanceRouter): ({
|
|
3
3
|
name: string;
|
|
4
4
|
label: string;
|
|
5
5
|
description: string;
|
|
@@ -14,8 +14,8 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
14
14
|
type: "string";
|
|
15
15
|
description: string;
|
|
16
16
|
};
|
|
17
|
-
instanceId?: undefined;
|
|
18
17
|
topic?: undefined;
|
|
18
|
+
instanceId?: undefined;
|
|
19
19
|
};
|
|
20
20
|
required: string[];
|
|
21
21
|
};
|
|
@@ -52,7 +52,7 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
52
52
|
parameters: {
|
|
53
53
|
type: "object";
|
|
54
54
|
properties: {
|
|
55
|
-
|
|
55
|
+
topic: {
|
|
56
56
|
type: "string";
|
|
57
57
|
description: string;
|
|
58
58
|
};
|
|
@@ -61,46 +61,59 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
61
61
|
description: string;
|
|
62
62
|
};
|
|
63
63
|
peerId?: undefined;
|
|
64
|
-
|
|
64
|
+
instanceId?: undefined;
|
|
65
65
|
};
|
|
66
66
|
required: string[];
|
|
67
67
|
};
|
|
68
68
|
execute(_toolCallId: string, params: {
|
|
69
|
-
|
|
69
|
+
topic: string;
|
|
70
70
|
message: string;
|
|
71
|
-
}
|
|
71
|
+
}): Promise<{
|
|
72
72
|
content: {
|
|
73
73
|
type: "text";
|
|
74
74
|
text: string;
|
|
75
75
|
}[];
|
|
76
76
|
details: {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
peerId?: undefined;
|
|
77
|
+
broadcast: boolean;
|
|
78
|
+
topic: string;
|
|
79
|
+
error?: undefined;
|
|
81
80
|
};
|
|
82
|
-
isError
|
|
81
|
+
isError?: undefined;
|
|
83
82
|
} | {
|
|
84
83
|
content: {
|
|
85
84
|
type: "text";
|
|
86
85
|
text: string;
|
|
87
86
|
}[];
|
|
88
87
|
details: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
error
|
|
92
|
-
peerId?: undefined;
|
|
88
|
+
broadcast: boolean;
|
|
89
|
+
topic: string;
|
|
90
|
+
error: string;
|
|
93
91
|
};
|
|
94
92
|
isError: boolean;
|
|
95
|
-
}
|
|
93
|
+
}>;
|
|
94
|
+
} | {
|
|
95
|
+
name: string;
|
|
96
|
+
label: string;
|
|
97
|
+
description: string;
|
|
98
|
+
parameters: {
|
|
99
|
+
type: "object";
|
|
100
|
+
properties: {
|
|
101
|
+
peerId?: undefined;
|
|
102
|
+
message?: undefined;
|
|
103
|
+
topic?: undefined;
|
|
104
|
+
instanceId?: undefined;
|
|
105
|
+
};
|
|
106
|
+
required?: undefined;
|
|
107
|
+
};
|
|
108
|
+
execute(_toolCallId: string): Promise<{
|
|
96
109
|
content: {
|
|
97
110
|
type: "text";
|
|
98
111
|
text: string;
|
|
99
112
|
}[];
|
|
100
113
|
details: {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
localPeerId: string;
|
|
115
|
+
connectedPeers: string[];
|
|
116
|
+
count: number;
|
|
104
117
|
error?: undefined;
|
|
105
118
|
};
|
|
106
119
|
isError?: undefined;
|
|
@@ -110,10 +123,10 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
110
123
|
text: string;
|
|
111
124
|
}[];
|
|
112
125
|
details: {
|
|
113
|
-
sent: boolean;
|
|
114
|
-
instanceId: string;
|
|
115
126
|
error: string;
|
|
116
|
-
|
|
127
|
+
localPeerId?: undefined;
|
|
128
|
+
connectedPeers?: undefined;
|
|
129
|
+
count?: undefined;
|
|
117
130
|
};
|
|
118
131
|
isError: boolean;
|
|
119
132
|
}>;
|
|
@@ -124,30 +137,32 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
124
137
|
parameters: {
|
|
125
138
|
type: "object";
|
|
126
139
|
properties: {
|
|
127
|
-
topic: {
|
|
128
|
-
type: "string";
|
|
129
|
-
description: string;
|
|
130
|
-
};
|
|
131
|
-
message: {
|
|
132
|
-
type: "string";
|
|
133
|
-
description: string;
|
|
134
|
-
};
|
|
135
140
|
peerId?: undefined;
|
|
141
|
+
message?: undefined;
|
|
142
|
+
topic?: undefined;
|
|
136
143
|
instanceId?: undefined;
|
|
137
144
|
};
|
|
138
|
-
required
|
|
145
|
+
required?: undefined;
|
|
139
146
|
};
|
|
140
|
-
execute(_toolCallId: string
|
|
141
|
-
topic: string;
|
|
142
|
-
message: string;
|
|
143
|
-
}): Promise<{
|
|
147
|
+
execute(_toolCallId: string): Promise<{
|
|
144
148
|
content: {
|
|
145
149
|
type: "text";
|
|
146
150
|
text: string;
|
|
147
151
|
}[];
|
|
148
152
|
details: {
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
initialized: boolean;
|
|
154
|
+
identity?: undefined;
|
|
155
|
+
error?: undefined;
|
|
156
|
+
};
|
|
157
|
+
isError?: undefined;
|
|
158
|
+
} | {
|
|
159
|
+
content: {
|
|
160
|
+
type: "text";
|
|
161
|
+
text: string;
|
|
162
|
+
}[];
|
|
163
|
+
details: {
|
|
164
|
+
identity: import("./types.js").InstanceIdentity;
|
|
165
|
+
initialized?: undefined;
|
|
151
166
|
error?: undefined;
|
|
152
167
|
};
|
|
153
168
|
isError?: undefined;
|
|
@@ -157,9 +172,9 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
157
172
|
text: string;
|
|
158
173
|
}[];
|
|
159
174
|
details: {
|
|
160
|
-
broadcast: boolean;
|
|
161
|
-
topic: string;
|
|
162
175
|
error: string;
|
|
176
|
+
initialized?: undefined;
|
|
177
|
+
identity?: undefined;
|
|
163
178
|
};
|
|
164
179
|
isError: boolean;
|
|
165
180
|
}>;
|
|
@@ -172,22 +187,21 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
172
187
|
properties: {
|
|
173
188
|
peerId?: undefined;
|
|
174
189
|
message?: undefined;
|
|
175
|
-
instanceId?: undefined;
|
|
176
190
|
topic?: undefined;
|
|
191
|
+
instanceId?: undefined;
|
|
177
192
|
};
|
|
178
193
|
required?: undefined;
|
|
179
194
|
};
|
|
180
|
-
execute(_toolCallId: string
|
|
195
|
+
execute(_toolCallId: string): Promise<{
|
|
181
196
|
content: {
|
|
182
197
|
type: "text";
|
|
183
198
|
text: string;
|
|
184
199
|
}[];
|
|
185
200
|
details: {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}[];
|
|
201
|
+
peerId: string;
|
|
202
|
+
instanceId: string | undefined;
|
|
203
|
+
listenAddrs: string[];
|
|
204
|
+
connectedPeers: string[];
|
|
191
205
|
error?: undefined;
|
|
192
206
|
};
|
|
193
207
|
isError?: undefined;
|
|
@@ -198,7 +212,10 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
198
212
|
}[];
|
|
199
213
|
details: {
|
|
200
214
|
error: string;
|
|
201
|
-
|
|
215
|
+
peerId?: undefined;
|
|
216
|
+
instanceId?: undefined;
|
|
217
|
+
listenAddrs?: undefined;
|
|
218
|
+
connectedPeers?: undefined;
|
|
202
219
|
};
|
|
203
220
|
isError: boolean;
|
|
204
221
|
}>;
|
|
@@ -211,8 +228,8 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
211
228
|
properties: {
|
|
212
229
|
peerId?: undefined;
|
|
213
230
|
message?: undefined;
|
|
214
|
-
instanceId?: undefined;
|
|
215
231
|
topic?: undefined;
|
|
232
|
+
instanceId?: undefined;
|
|
216
233
|
};
|
|
217
234
|
required?: undefined;
|
|
218
235
|
};
|
|
@@ -223,17 +240,29 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
223
240
|
}[];
|
|
224
241
|
details: {
|
|
225
242
|
initialized: boolean;
|
|
226
|
-
|
|
243
|
+
instances?: undefined;
|
|
244
|
+
count?: undefined;
|
|
227
245
|
error?: undefined;
|
|
228
246
|
};
|
|
229
|
-
isError
|
|
247
|
+
isError: boolean;
|
|
230
248
|
} | {
|
|
231
249
|
content: {
|
|
232
250
|
type: "text";
|
|
233
251
|
text: string;
|
|
234
252
|
}[];
|
|
235
253
|
details: {
|
|
236
|
-
|
|
254
|
+
instances: {
|
|
255
|
+
connected: boolean;
|
|
256
|
+
instanceId: string;
|
|
257
|
+
peerId: string;
|
|
258
|
+
instanceName?: string;
|
|
259
|
+
multiaddrs: string[];
|
|
260
|
+
pubkey?: string;
|
|
261
|
+
lastSeenAt: number;
|
|
262
|
+
lastAnnouncedAt: number;
|
|
263
|
+
source: "announce";
|
|
264
|
+
}[];
|
|
265
|
+
count: number;
|
|
237
266
|
initialized?: undefined;
|
|
238
267
|
error?: undefined;
|
|
239
268
|
};
|
|
@@ -246,7 +275,8 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
246
275
|
details: {
|
|
247
276
|
error: string;
|
|
248
277
|
initialized?: undefined;
|
|
249
|
-
|
|
278
|
+
instances?: undefined;
|
|
279
|
+
count?: undefined;
|
|
250
280
|
};
|
|
251
281
|
isError: boolean;
|
|
252
282
|
}>;
|
|
@@ -257,26 +287,31 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
257
287
|
parameters: {
|
|
258
288
|
type: "object";
|
|
259
289
|
properties: {
|
|
290
|
+
instanceId: {
|
|
291
|
+
type: "string";
|
|
292
|
+
description: string;
|
|
293
|
+
};
|
|
260
294
|
peerId?: undefined;
|
|
261
295
|
message?: undefined;
|
|
262
|
-
instanceId?: undefined;
|
|
263
296
|
topic?: undefined;
|
|
264
297
|
};
|
|
265
|
-
required
|
|
298
|
+
required: string[];
|
|
266
299
|
};
|
|
267
|
-
execute(_toolCallId: string
|
|
300
|
+
execute(_toolCallId: string, params: {
|
|
301
|
+
instanceId: string;
|
|
302
|
+
}): Promise<{
|
|
268
303
|
content: {
|
|
269
304
|
type: "text";
|
|
270
305
|
text: string;
|
|
271
306
|
}[];
|
|
272
307
|
details: {
|
|
273
|
-
|
|
274
|
-
instanceId: string | undefined;
|
|
275
|
-
listenAddrs: string[];
|
|
276
|
-
connectedPeers: string[];
|
|
308
|
+
initialized: boolean;
|
|
277
309
|
error?: undefined;
|
|
310
|
+
instanceId?: undefined;
|
|
311
|
+
found?: undefined;
|
|
312
|
+
route?: undefined;
|
|
278
313
|
};
|
|
279
|
-
isError
|
|
314
|
+
isError: boolean;
|
|
280
315
|
} | {
|
|
281
316
|
content: {
|
|
282
317
|
type: "text";
|
|
@@ -284,12 +319,38 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
284
319
|
}[];
|
|
285
320
|
details: {
|
|
286
321
|
error: string;
|
|
287
|
-
|
|
322
|
+
initialized?: undefined;
|
|
288
323
|
instanceId?: undefined;
|
|
289
|
-
|
|
290
|
-
|
|
324
|
+
found?: undefined;
|
|
325
|
+
route?: undefined;
|
|
291
326
|
};
|
|
292
327
|
isError: boolean;
|
|
328
|
+
} | {
|
|
329
|
+
content: {
|
|
330
|
+
type: "text";
|
|
331
|
+
text: string;
|
|
332
|
+
}[];
|
|
333
|
+
details: {
|
|
334
|
+
instanceId: string;
|
|
335
|
+
found: boolean;
|
|
336
|
+
initialized?: undefined;
|
|
337
|
+
error?: undefined;
|
|
338
|
+
route?: undefined;
|
|
339
|
+
};
|
|
340
|
+
isError: boolean;
|
|
341
|
+
} | {
|
|
342
|
+
content: {
|
|
343
|
+
type: "text";
|
|
344
|
+
text: string;
|
|
345
|
+
}[];
|
|
346
|
+
details: {
|
|
347
|
+
found: boolean;
|
|
348
|
+
route: import("./types.js").InstancePeerRecord;
|
|
349
|
+
initialized?: undefined;
|
|
350
|
+
error?: undefined;
|
|
351
|
+
instanceId?: undefined;
|
|
352
|
+
};
|
|
353
|
+
isError?: undefined;
|
|
293
354
|
}>;
|
|
294
355
|
} | {
|
|
295
356
|
name: string;
|
|
@@ -298,31 +359,71 @@ export declare function buildP2PTools(mesh: MeshNetwork): ({
|
|
|
298
359
|
parameters: {
|
|
299
360
|
type: "object";
|
|
300
361
|
properties: {
|
|
362
|
+
instanceId: {
|
|
363
|
+
type: "string";
|
|
364
|
+
description: string;
|
|
365
|
+
};
|
|
366
|
+
message: {
|
|
367
|
+
type: "string";
|
|
368
|
+
description: string;
|
|
369
|
+
};
|
|
301
370
|
peerId?: undefined;
|
|
302
|
-
message?: undefined;
|
|
303
|
-
instanceId?: undefined;
|
|
304
371
|
topic?: undefined;
|
|
305
372
|
};
|
|
306
|
-
required
|
|
373
|
+
required: string[];
|
|
307
374
|
};
|
|
308
|
-
execute(_toolCallId: string,
|
|
375
|
+
execute(_toolCallId: string, params: {
|
|
376
|
+
instanceId: string;
|
|
377
|
+
message: string;
|
|
378
|
+
}): Promise<{
|
|
309
379
|
content: {
|
|
310
380
|
type: "text";
|
|
311
381
|
text: string;
|
|
312
382
|
}[];
|
|
313
383
|
details: {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
384
|
+
initialized: boolean;
|
|
385
|
+
error?: undefined;
|
|
386
|
+
};
|
|
387
|
+
isError: boolean;
|
|
388
|
+
} | {
|
|
389
|
+
content: {
|
|
390
|
+
type: "text";
|
|
391
|
+
text: string;
|
|
392
|
+
}[];
|
|
393
|
+
details: {
|
|
394
|
+
error: string;
|
|
395
|
+
initialized?: undefined;
|
|
326
396
|
};
|
|
397
|
+
isError: boolean;
|
|
398
|
+
} | {
|
|
399
|
+
content: {
|
|
400
|
+
type: "text";
|
|
401
|
+
text: string;
|
|
402
|
+
}[];
|
|
403
|
+
details: {
|
|
404
|
+
sent: boolean;
|
|
405
|
+
delivered: boolean;
|
|
406
|
+
toInstanceId: string;
|
|
407
|
+
toPeerId: string;
|
|
408
|
+
ackMessageId?: string;
|
|
409
|
+
inboundChannel?: string;
|
|
410
|
+
error?: string;
|
|
411
|
+
};
|
|
412
|
+
isError: boolean;
|
|
413
|
+
} | {
|
|
414
|
+
content: {
|
|
415
|
+
type: "text";
|
|
416
|
+
text: string;
|
|
417
|
+
}[];
|
|
418
|
+
details: {
|
|
419
|
+
sent: boolean;
|
|
420
|
+
delivered: boolean;
|
|
421
|
+
toInstanceId: string;
|
|
422
|
+
toPeerId: string;
|
|
423
|
+
ackMessageId?: string;
|
|
424
|
+
inboundChannel?: string;
|
|
425
|
+
error?: string;
|
|
426
|
+
};
|
|
427
|
+
isError?: undefined;
|
|
327
428
|
}>;
|
|
328
429
|
})[];
|