@agentvault/agentvault 0.20.10 → 0.20.12

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/cli.js CHANGED
@@ -67040,103 +67040,105 @@ ${messageText}`;
67040
67040
  return;
67041
67041
  }
67042
67042
  const { messages } = await res.json();
67043
- if (!messages || messages.length === 0) return;
67044
- const order = { welcome: 0, commit: 1, application: 2 };
67045
- messages.sort((a2, b2) => {
67046
- const ao = order[a2.message_type] ?? 2;
67047
- const bo = order[b2.message_type] ?? 2;
67048
- if (ao !== bo) return ao - bo;
67049
- return new Date(a2.created_at).getTime() - new Date(b2.created_at).getTime();
67050
- });
67051
- const ackedIds = [];
67052
- const nackedIds = [];
67053
- for (const msg of messages) {
67054
- try {
67055
- if (msg.sender_device_id === this._deviceId) {
67056
- ackedIds.push(msg.queue_id);
67057
- continue;
67058
- }
67059
- if (msg.message_type === "welcome") {
67060
- await this._handleMlsWelcome({
67061
- group_id: msg.group_id,
67062
- sender_device_id: msg.sender_device_id,
67063
- payload: msg.payload,
67064
- room_id: msg.room_id,
67065
- conversation_id: msg.conversation_id,
67066
- a2a_channel_id: msg.a2a_channel_id
67067
- });
67068
- } else if (msg.message_type === "commit") {
67069
- await this._handleMlsCommit({
67070
- group_id: msg.group_id,
67071
- sender_device_id: msg.sender_device_id,
67072
- epoch: msg.epoch,
67073
- payload: msg.payload
67074
- });
67075
- } else if (msg.message_type === "application") {
67076
- if (msg.room_id) {
67077
- await this._handleRoomMessageMLS({
67078
- message_id: msg.message_id,
67043
+ const hasMessages = messages && messages.length > 0;
67044
+ if (hasMessages) {
67045
+ const order = { welcome: 0, commit: 1, application: 2 };
67046
+ messages.sort((a2, b2) => {
67047
+ const ao = order[a2.message_type] ?? 2;
67048
+ const bo = order[b2.message_type] ?? 2;
67049
+ if (ao !== bo) return ao - bo;
67050
+ return new Date(a2.created_at).getTime() - new Date(b2.created_at).getTime();
67051
+ });
67052
+ const ackedIds = [];
67053
+ const nackedIds = [];
67054
+ for (const msg of messages) {
67055
+ try {
67056
+ if (msg.sender_device_id === this._deviceId) {
67057
+ ackedIds.push(msg.queue_id);
67058
+ continue;
67059
+ }
67060
+ if (msg.message_type === "welcome") {
67061
+ await this._handleMlsWelcome({
67079
67062
  group_id: msg.group_id,
67080
67063
  sender_device_id: msg.sender_device_id,
67081
- epoch: msg.epoch,
67082
67064
  payload: msg.payload,
67083
67065
  room_id: msg.room_id,
67084
- created_at: msg.created_at
67085
- });
67086
- } else if (msg.a2a_channel_id) {
67087
- await this._handleA2AMessageMLS({
67088
- message_id: msg.message_id,
67089
- group_id: msg.group_id,
67090
- sender_device_id: msg.sender_device_id,
67091
- epoch: msg.epoch,
67092
- payload: msg.payload,
67093
- a2a_channel_id: msg.a2a_channel_id,
67094
- created_at: msg.created_at
67066
+ conversation_id: msg.conversation_id,
67067
+ a2a_channel_id: msg.a2a_channel_id
67095
67068
  });
67096
- } else if (msg.conversation_id) {
67097
- await this._handleMessageMLS({
67098
- message_id: msg.message_id,
67069
+ } else if (msg.message_type === "commit") {
67070
+ await this._handleMlsCommit({
67099
67071
  group_id: msg.group_id,
67100
67072
  sender_device_id: msg.sender_device_id,
67101
67073
  epoch: msg.epoch,
67102
- payload: msg.payload,
67103
- conversation_id: msg.conversation_id,
67104
- created_at: msg.created_at
67074
+ payload: msg.payload
67105
67075
  });
67076
+ } else if (msg.message_type === "application") {
67077
+ if (msg.room_id) {
67078
+ await this._handleRoomMessageMLS({
67079
+ message_id: msg.message_id,
67080
+ group_id: msg.group_id,
67081
+ sender_device_id: msg.sender_device_id,
67082
+ epoch: msg.epoch,
67083
+ payload: msg.payload,
67084
+ room_id: msg.room_id,
67085
+ created_at: msg.created_at
67086
+ });
67087
+ } else if (msg.a2a_channel_id) {
67088
+ await this._handleA2AMessageMLS({
67089
+ message_id: msg.message_id,
67090
+ group_id: msg.group_id,
67091
+ sender_device_id: msg.sender_device_id,
67092
+ epoch: msg.epoch,
67093
+ payload: msg.payload,
67094
+ a2a_channel_id: msg.a2a_channel_id,
67095
+ created_at: msg.created_at
67096
+ });
67097
+ } else if (msg.conversation_id) {
67098
+ await this._handleMessageMLS({
67099
+ message_id: msg.message_id,
67100
+ group_id: msg.group_id,
67101
+ sender_device_id: msg.sender_device_id,
67102
+ epoch: msg.epoch,
67103
+ payload: msg.payload,
67104
+ conversation_id: msg.conversation_id,
67105
+ created_at: msg.created_at
67106
+ });
67107
+ }
67106
67108
  }
67109
+ ackedIds.push(msg.queue_id);
67110
+ } catch (err) {
67111
+ console.warn(`[SecureChannel] Delivery ${msg.message_type} processing failed:`, err);
67112
+ nackedIds.push(msg.queue_id);
67107
67113
  }
67108
- ackedIds.push(msg.queue_id);
67109
- } catch (err) {
67110
- console.warn(`[SecureChannel] Delivery ${msg.message_type} processing failed:`, err);
67111
- nackedIds.push(msg.queue_id);
67112
67114
  }
67113
- }
67114
- if (nackedIds.length > 0) {
67115
- try {
67116
- await fetch(`${this.config.apiUrl}/api/v1/mls/delivery/nack`, {
67117
- method: "POST",
67118
- headers: {
67119
- Authorization: `Bearer ${this._deviceJwt}`,
67120
- "Content-Type": "application/json"
67121
- },
67122
- body: JSON.stringify({ queue_ids: nackedIds })
67123
- });
67124
- } catch {
67115
+ if (nackedIds.length > 0) {
67116
+ try {
67117
+ await fetch(`${this.config.apiUrl}/api/v1/mls/delivery/nack`, {
67118
+ method: "POST",
67119
+ headers: {
67120
+ Authorization: `Bearer ${this._deviceJwt}`,
67121
+ "Content-Type": "application/json"
67122
+ },
67123
+ body: JSON.stringify({ queue_ids: nackedIds })
67124
+ });
67125
+ } catch {
67126
+ }
67125
67127
  }
67126
- }
67127
- if (ackedIds.length > 0) {
67128
- try {
67129
- await fetch(`${this.config.apiUrl}/api/v1/mls/delivery/ack`, {
67130
- method: "POST",
67131
- headers: {
67132
- Authorization: `Bearer ${this._deviceJwt}`,
67133
- "Content-Type": "application/json"
67134
- },
67135
- body: JSON.stringify({ queue_ids: ackedIds, device_id: this._deviceId })
67136
- });
67137
- console.log(`[SecureChannel] Delivery acked ${ackedIds.length}/${messages.length}`);
67138
- } catch (ackErr) {
67139
- console.warn("[SecureChannel] Delivery ack failed:", ackErr);
67128
+ if (ackedIds.length > 0) {
67129
+ try {
67130
+ await fetch(`${this.config.apiUrl}/api/v1/mls/delivery/ack`, {
67131
+ method: "POST",
67132
+ headers: {
67133
+ Authorization: `Bearer ${this._deviceJwt}`,
67134
+ "Content-Type": "application/json"
67135
+ },
67136
+ body: JSON.stringify({ queue_ids: ackedIds, device_id: this._deviceId })
67137
+ });
67138
+ console.log(`[SecureChannel] Delivery acked ${ackedIds.length}/${messages.length}`);
67139
+ } catch (ackErr) {
67140
+ console.warn("[SecureChannel] Delivery ack failed:", ackErr);
67141
+ }
67140
67142
  }
67141
67143
  }
67142
67144
  for (const [roomId, mlsGroup] of this._mlsGroups) {
@@ -67254,9 +67256,10 @@ ${messageText}`;
67254
67256
  { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
67255
67257
  );
67256
67258
  if (!kpRes.ok) continue;
67257
- const kpArr = await kpRes.json();
67258
- if (kpArr.length === 0) continue;
67259
- const kpBytes = new Uint8Array(Buffer.from(kpArr[0].key_package, "hex"));
67259
+ const kpData = await kpRes.json();
67260
+ const kpHex = kpData[req.requesting_device_id];
67261
+ if (!kpHex) continue;
67262
+ const kpBytes = new Uint8Array(Buffer.from(kpHex, "hex"));
67260
67263
  const memberKp = MLSGroupManager.deserializeKeyPackage(kpBytes);
67261
67264
  const { commit, welcome } = await mlsGroup.addMembers([memberKp]);
67262
67265
  if (welcome) {
@@ -88658,7 +88661,7 @@ var init_index = __esm({
88658
88661
  init_skill_invoker();
88659
88662
  await init_skill_telemetry();
88660
88663
  await init_policy_enforcer();
88661
- VERSION = true ? "0.20.10" : "0.0.0-dev";
88664
+ VERSION = true ? "0.20.12" : "0.0.0-dev";
88662
88665
  }
88663
88666
  });
88664
88667