@agentvault/agentvault 0.20.0 → 0.20.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/dist/channel.d.ts +8 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +99 -74
- package/dist/cli.js.map +2 -2
- package/dist/index.js +99 -74
- package/dist/index.js.map +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -65125,6 +65125,19 @@ var init_channel = __esm({
|
|
|
65125
65125
|
}
|
|
65126
65126
|
}
|
|
65127
65127
|
await this._persistState();
|
|
65128
|
+
for (const [chId, chState] of Object.entries(this._persisted?.a2aChannels ?? {})) {
|
|
65129
|
+
if (chState.role === "creator" && !chState.mlsGroupId && chState.participants.some((p2) => p2.status === "active")) {
|
|
65130
|
+
const activeParticipants = chState.participants.filter((p2) => p2.status === "active");
|
|
65131
|
+
if (activeParticipants.length >= 1) {
|
|
65132
|
+
console.log(`[AgentVault] Sync fallback: founding MLS group for channel ${chId.slice(0, 8)}`);
|
|
65133
|
+
try {
|
|
65134
|
+
await this._foundA2AGroup(chId, chState.conversationId, activeParticipants);
|
|
65135
|
+
} catch (err) {
|
|
65136
|
+
console.warn(`[AgentVault] Sync fallback MLS founding failed for ${chId.slice(0, 8)}:`, err);
|
|
65137
|
+
}
|
|
65138
|
+
}
|
|
65139
|
+
}
|
|
65140
|
+
}
|
|
65128
65141
|
}
|
|
65129
65142
|
return channels;
|
|
65130
65143
|
}
|
|
@@ -65739,79 +65752,7 @@ var init_channel = __esm({
|
|
|
65739
65752
|
this.emit("a2a_channel_approved", channelData);
|
|
65740
65753
|
if (this._persisted && convId && channelId && role === "creator") {
|
|
65741
65754
|
try {
|
|
65742
|
-
|
|
65743
|
-
`${this.config.apiUrl}/api/v1/mls/a2a/${channelId}/init`,
|
|
65744
|
-
{
|
|
65745
|
-
method: "POST",
|
|
65746
|
-
headers: {
|
|
65747
|
-
Authorization: `Bearer ${this._deviceJwt}`,
|
|
65748
|
-
"Content-Type": "application/json"
|
|
65749
|
-
},
|
|
65750
|
-
body: JSON.stringify({ member_device_ids: [] })
|
|
65751
|
-
}
|
|
65752
|
-
);
|
|
65753
|
-
if (mlsInitRes.ok) {
|
|
65754
|
-
const mlsData = await mlsInitRes.json();
|
|
65755
|
-
const entry = this._persisted.a2aChannels?.[channelId];
|
|
65756
|
-
if (entry) {
|
|
65757
|
-
entry.mlsGroupId = mlsData.group_id;
|
|
65758
|
-
await this._persistState();
|
|
65759
|
-
console.log(
|
|
65760
|
-
`[SecureChannel] A2A ${channelId.slice(0, 8)} MLS group founded as creator (groupId=${mlsData.group_id.slice(0, 8)})`
|
|
65761
|
-
);
|
|
65762
|
-
try {
|
|
65763
|
-
const mgr = new MLSGroupManager();
|
|
65764
|
-
const identity = new TextEncoder().encode(this._persisted.deviceId);
|
|
65765
|
-
const creatorKp = await mgr.generateKeyPackage(identity);
|
|
65766
|
-
const groupIdBytes = new TextEncoder().encode(mlsData.group_id);
|
|
65767
|
-
await mgr.createGroup(groupIdBytes, creatorKp);
|
|
65768
|
-
this._mlsGroups.set(`a2a:${channelId}`, mgr);
|
|
65769
|
-
await saveMlsState(this.config.dataDir, mlsData.group_id, JSON.stringify(mgr.exportState()));
|
|
65770
|
-
for (const p2 of entry.participants ?? []) {
|
|
65771
|
-
if (p2.status !== "active" && p2.status !== "invited") continue;
|
|
65772
|
-
try {
|
|
65773
|
-
const kpRes = await fetch(
|
|
65774
|
-
`${this.config.apiUrl}/api/v1/mls/key-packages?hub_id=${encodeURIComponent(p2.hubId)}`,
|
|
65775
|
-
{ headers: { Authorization: `Bearer ${this._deviceJwt}` } }
|
|
65776
|
-
);
|
|
65777
|
-
if (kpRes.ok) {
|
|
65778
|
-
const kpData = await kpRes.json();
|
|
65779
|
-
if (kpData.key_package) {
|
|
65780
|
-
const kpBytes = new Uint8Array(Buffer.from(kpData.key_package, "hex"));
|
|
65781
|
-
const memberKp = MLSGroupManager.deserializeKeyPackage(kpBytes);
|
|
65782
|
-
const { commit, welcome } = await mgr.addMembers([memberKp]);
|
|
65783
|
-
if (welcome && this._ws) {
|
|
65784
|
-
this._ws.send(JSON.stringify({
|
|
65785
|
-
event: "mls_commit",
|
|
65786
|
-
data: {
|
|
65787
|
-
group_id: mlsData.group_id,
|
|
65788
|
-
epoch: Number(mgr.epoch),
|
|
65789
|
-
payload: Buffer.from(commit).toString("hex")
|
|
65790
|
-
}
|
|
65791
|
-
}));
|
|
65792
|
-
this._ws.send(JSON.stringify({
|
|
65793
|
-
event: "mls_welcome",
|
|
65794
|
-
data: {
|
|
65795
|
-
group_id: mlsData.group_id,
|
|
65796
|
-
welcome: Buffer.from(welcome).toString("hex"),
|
|
65797
|
-
target_hub_id: p2.hubId,
|
|
65798
|
-
a2a_channel_id: channelId
|
|
65799
|
-
}
|
|
65800
|
-
}));
|
|
65801
|
-
console.log(`[SecureChannel] Sent MLS Welcome to ${p2.hubAddress} for A2A ${channelId.slice(0, 8)}`);
|
|
65802
|
-
}
|
|
65803
|
-
await saveMlsState(this.config.dataDir, mlsData.group_id, JSON.stringify(mgr.exportState()));
|
|
65804
|
-
}
|
|
65805
|
-
}
|
|
65806
|
-
} catch (kpErr) {
|
|
65807
|
-
console.warn(`[SecureChannel] Failed to Welcome participant ${p2.hubAddress}:`, kpErr);
|
|
65808
|
-
}
|
|
65809
|
-
}
|
|
65810
|
-
} catch (mlsErr) {
|
|
65811
|
-
console.warn(`[SecureChannel] MLS group creation failed:`, mlsErr);
|
|
65812
|
-
}
|
|
65813
|
-
}
|
|
65814
|
-
}
|
|
65755
|
+
await this._foundA2AGroup(channelId, convId, this._persisted.a2aChannels?.[channelId]?.participants ?? []);
|
|
65815
65756
|
} catch (err) {
|
|
65816
65757
|
console.warn(`[SecureChannel] A2A MLS init failed (non-fatal):`, err);
|
|
65817
65758
|
}
|
|
@@ -67330,6 +67271,90 @@ ${messageText}`;
|
|
|
67330
67271
|
console.error(`[SecureChannel] MLS A2A decrypt failed for ${a2aChannelId.slice(0, 8)}:`, err);
|
|
67331
67272
|
}
|
|
67332
67273
|
}
|
|
67274
|
+
/**
|
|
67275
|
+
* Found the MLS group for an A2A channel as the creator agent.
|
|
67276
|
+
* Calls /mls/a2a/{channelId}/init, creates the local MLS group, and sends
|
|
67277
|
+
* Welcome messages to all active/invited participants.
|
|
67278
|
+
* Extracted from the a2a_channel_approved WS handler so it can also be called
|
|
67279
|
+
* from the sync fallback in listA2AChannels.
|
|
67280
|
+
*/
|
|
67281
|
+
async _foundA2AGroup(channelId, convId, participants) {
|
|
67282
|
+
if (!this._persisted || !this._deviceJwt) return;
|
|
67283
|
+
const mlsInitRes = await fetch(
|
|
67284
|
+
`${this.config.apiUrl}/api/v1/mls/a2a/${channelId}/init`,
|
|
67285
|
+
{
|
|
67286
|
+
method: "POST",
|
|
67287
|
+
headers: {
|
|
67288
|
+
Authorization: `Bearer ${this._deviceJwt}`,
|
|
67289
|
+
"Content-Type": "application/json"
|
|
67290
|
+
},
|
|
67291
|
+
body: JSON.stringify({ member_device_ids: [] })
|
|
67292
|
+
}
|
|
67293
|
+
);
|
|
67294
|
+
if (!mlsInitRes.ok) {
|
|
67295
|
+
const detail = await mlsInitRes.text();
|
|
67296
|
+
throw new Error(`MLS A2A init failed (${mlsInitRes.status}): ${detail}`);
|
|
67297
|
+
}
|
|
67298
|
+
const mlsData = await mlsInitRes.json();
|
|
67299
|
+
const entry = this._persisted.a2aChannels?.[channelId];
|
|
67300
|
+
if (!entry) return;
|
|
67301
|
+
entry.mlsGroupId = mlsData.group_id;
|
|
67302
|
+
await this._persistState();
|
|
67303
|
+
console.log(
|
|
67304
|
+
`[SecureChannel] A2A ${channelId.slice(0, 8)} MLS group founded as creator (groupId=${mlsData.group_id.slice(0, 8)})`
|
|
67305
|
+
);
|
|
67306
|
+
try {
|
|
67307
|
+
const mgr = new MLSGroupManager();
|
|
67308
|
+
const identity = new TextEncoder().encode(this._persisted.deviceId);
|
|
67309
|
+
const creatorKp = await mgr.generateKeyPackage(identity);
|
|
67310
|
+
const groupIdBytes = new TextEncoder().encode(mlsData.group_id);
|
|
67311
|
+
await mgr.createGroup(groupIdBytes, creatorKp);
|
|
67312
|
+
this._mlsGroups.set(`a2a:${channelId}`, mgr);
|
|
67313
|
+
await saveMlsState(this.config.dataDir, mlsData.group_id, JSON.stringify(mgr.exportState()));
|
|
67314
|
+
for (const p2 of participants) {
|
|
67315
|
+
if (p2.status !== "active" && p2.status !== "invited") continue;
|
|
67316
|
+
try {
|
|
67317
|
+
const kpRes = await fetch(
|
|
67318
|
+
`${this.config.apiUrl}/api/v1/mls/key-packages?hub_id=${encodeURIComponent(p2.hubId)}`,
|
|
67319
|
+
{ headers: { Authorization: `Bearer ${this._deviceJwt}` } }
|
|
67320
|
+
);
|
|
67321
|
+
if (kpRes.ok) {
|
|
67322
|
+
const kpData = await kpRes.json();
|
|
67323
|
+
if (kpData.key_package) {
|
|
67324
|
+
const kpBytes = new Uint8Array(Buffer.from(kpData.key_package, "hex"));
|
|
67325
|
+
const memberKp = MLSGroupManager.deserializeKeyPackage(kpBytes);
|
|
67326
|
+
const { commit, welcome } = await mgr.addMembers([memberKp]);
|
|
67327
|
+
if (welcome && this._ws) {
|
|
67328
|
+
this._ws.send(JSON.stringify({
|
|
67329
|
+
event: "mls_commit",
|
|
67330
|
+
data: {
|
|
67331
|
+
group_id: mlsData.group_id,
|
|
67332
|
+
epoch: Number(mgr.epoch),
|
|
67333
|
+
payload: Buffer.from(commit).toString("hex")
|
|
67334
|
+
}
|
|
67335
|
+
}));
|
|
67336
|
+
this._ws.send(JSON.stringify({
|
|
67337
|
+
event: "mls_welcome",
|
|
67338
|
+
data: {
|
|
67339
|
+
group_id: mlsData.group_id,
|
|
67340
|
+
welcome: Buffer.from(welcome).toString("hex"),
|
|
67341
|
+
target_hub_id: p2.hubId,
|
|
67342
|
+
a2a_channel_id: channelId
|
|
67343
|
+
}
|
|
67344
|
+
}));
|
|
67345
|
+
console.log(`[SecureChannel] Sent MLS Welcome to ${p2.hubAddress} for A2A ${channelId.slice(0, 8)}`);
|
|
67346
|
+
}
|
|
67347
|
+
await saveMlsState(this.config.dataDir, mlsData.group_id, JSON.stringify(mgr.exportState()));
|
|
67348
|
+
}
|
|
67349
|
+
}
|
|
67350
|
+
} catch (kpErr) {
|
|
67351
|
+
console.warn(`[SecureChannel] Failed to Welcome participant ${p2.hubAddress}:`, kpErr);
|
|
67352
|
+
}
|
|
67353
|
+
}
|
|
67354
|
+
} catch (mlsErr) {
|
|
67355
|
+
console.warn(`[SecureChannel] MLS group creation failed:`, mlsErr);
|
|
67356
|
+
}
|
|
67357
|
+
}
|
|
67333
67358
|
/**
|
|
67334
67359
|
* Paginated sync: fetch missed messages in pages of 200, up to 5 pages (1000 messages).
|
|
67335
67360
|
* Tracks message IDs in _syncMessageIds to prevent duplicate processing from concurrent WS messages.
|
|
@@ -94409,7 +94434,7 @@ var init_index = __esm({
|
|
|
94409
94434
|
init_skill_invoker();
|
|
94410
94435
|
await init_skill_telemetry();
|
|
94411
94436
|
await init_policy_enforcer();
|
|
94412
|
-
VERSION = true ? "0.20.
|
|
94437
|
+
VERSION = true ? "0.20.1" : "0.0.0-dev";
|
|
94413
94438
|
}
|
|
94414
94439
|
});
|
|
94415
94440
|
await init_index();
|