@agentvault/secure-channel 0.6.25 → 0.7.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/channel.d.ts +22 -1
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +195 -11
- package/dist/cli.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +195 -11
- package/dist/index.js.map +2 -2
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/__tests__/install-plugin.test.d.ts +0 -2
- package/dist/__tests__/install-plugin.test.d.ts.map +0 -1
package/dist/channel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import type { SecureChannelConfig, ChannelState, SendOptions, DecisionRequest, DecisionResponse, HeartbeatStatus, StatusAlert, RoomMemberInfo, RoomConversationInfo, RoomInfo } from "./types.js";
|
|
2
|
+
import type { SecureChannelConfig, ChannelState, SendOptions, DecisionRequest, DecisionResponse, HeartbeatStatus, StatusAlert, RoomMemberInfo, RoomConversationInfo, RoomInfo, A2AChannel } from "./types.js";
|
|
3
3
|
export declare class SecureChannel extends EventEmitter {
|
|
4
4
|
private config;
|
|
5
5
|
private _state;
|
|
@@ -129,6 +129,27 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
129
129
|
name: string;
|
|
130
130
|
isDefault: boolean;
|
|
131
131
|
}>>;
|
|
132
|
+
/**
|
|
133
|
+
* Request a new A2A channel with another agent by their hub address.
|
|
134
|
+
* Returns the channel_id from the server response.
|
|
135
|
+
*/
|
|
136
|
+
requestA2AChannel(responderHubAddress: string): Promise<string>;
|
|
137
|
+
/**
|
|
138
|
+
* Send a message to another agent via an active A2A channel.
|
|
139
|
+
* Looks up the A2A conversation by hub address and sends via WS.
|
|
140
|
+
*
|
|
141
|
+
* NOTE: Currently sends plaintext over the WS (server-side relay).
|
|
142
|
+
* Full E2E encryption (X3DH + Double Ratchet per A2A session) will be
|
|
143
|
+
* added when the A2A ratchet activation flow is implemented.
|
|
144
|
+
*/
|
|
145
|
+
sendToAgent(hubAddress: string, text: string, opts?: {
|
|
146
|
+
parentSpanId?: string;
|
|
147
|
+
}): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* List all A2A channels for this agent.
|
|
150
|
+
* Fetches from the server and updates local persisted state.
|
|
151
|
+
*/
|
|
152
|
+
listA2AChannels(): Promise<A2AChannel[]>;
|
|
132
153
|
private _enroll;
|
|
133
154
|
private _poll;
|
|
134
155
|
private _activate;
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAMZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,QAAQ,
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAMZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,QAAQ,EAER,UAAU,EAEX,MAAM,YAAY,CAAC;AAmDpB,qBAAa,aAAc,SAAQ,YAAY;IAkCjC,OAAO,CAAC,MAAM;IAjC1B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,sBAAsB,CAAc;IAC5C,OAAO,CAAC,UAAU,CAAuB;IACzC,OA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EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,IAAI,CAAC;IA8ChB;;;OAGG;YACW,oBAAoB;IAqClC;;;OAGG;YACW,uBAAuB;IAkCrC;;;;OAIG;YACW,mBAAmB;IAkEjC;;;OAGG;YACW,kBAAkB;IAwEhC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAiBlC;;;OAGG;IACH;;;OAGG;YACW,mBAAmB;IA8GjC,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,UAAU;YAMJ,mBAAmB;IAmCjC,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,kBAAkB;IAiH1B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,YAAY;IAKpB;;;OAGG;YACW,aAAa;CAc5B"}
|
package/dist/cli.js
CHANGED
|
@@ -45303,20 +45303,24 @@ var init_channel = __esm({
|
|
|
45303
45303
|
topicId
|
|
45304
45304
|
};
|
|
45305
45305
|
if (this._state === "ready" && this._ws) {
|
|
45306
|
+
const payload = {
|
|
45307
|
+
conversation_id: msg.convId,
|
|
45308
|
+
header_blob: msg.headerBlob,
|
|
45309
|
+
ciphertext: msg.ciphertext,
|
|
45310
|
+
message_group_id: msg.messageGroupId,
|
|
45311
|
+
topic_id: msg.topicId,
|
|
45312
|
+
message_type: messageType,
|
|
45313
|
+
priority,
|
|
45314
|
+
parent_span_id: parentSpanId,
|
|
45315
|
+
metadata: envelopeMetadata
|
|
45316
|
+
};
|
|
45317
|
+
if (this._persisted?.hubAddress) {
|
|
45318
|
+
payload.hub_address = this._persisted.hubAddress;
|
|
45319
|
+
}
|
|
45306
45320
|
this._ws.send(
|
|
45307
45321
|
JSON.stringify({
|
|
45308
45322
|
event: "message",
|
|
45309
|
-
data:
|
|
45310
|
-
conversation_id: msg.convId,
|
|
45311
|
-
header_blob: msg.headerBlob,
|
|
45312
|
-
ciphertext: msg.ciphertext,
|
|
45313
|
-
message_group_id: msg.messageGroupId,
|
|
45314
|
-
topic_id: msg.topicId,
|
|
45315
|
-
message_type: messageType,
|
|
45316
|
-
priority,
|
|
45317
|
-
parent_span_id: parentSpanId,
|
|
45318
|
-
metadata: envelopeMetadata
|
|
45319
|
-
}
|
|
45323
|
+
data: payload
|
|
45320
45324
|
})
|
|
45321
45325
|
);
|
|
45322
45326
|
} else {
|
|
@@ -45846,6 +45850,130 @@ var init_channel = __esm({
|
|
|
45846
45850
|
await this._persistState();
|
|
45847
45851
|
return topics;
|
|
45848
45852
|
}
|
|
45853
|
+
// --- A2A Channel methods (agent-to-agent communication) ---
|
|
45854
|
+
/**
|
|
45855
|
+
* Request a new A2A channel with another agent by their hub address.
|
|
45856
|
+
* Returns the channel_id from the server response.
|
|
45857
|
+
*/
|
|
45858
|
+
async requestA2AChannel(responderHubAddress) {
|
|
45859
|
+
if (!this._persisted?.hubAddress) {
|
|
45860
|
+
throw new Error("This agent does not have a hub address assigned");
|
|
45861
|
+
}
|
|
45862
|
+
if (!this._deviceJwt) {
|
|
45863
|
+
throw new Error("Channel not authenticated");
|
|
45864
|
+
}
|
|
45865
|
+
const res = await fetch(`${this.config.apiUrl}/api/v1/a2a/channels/request`, {
|
|
45866
|
+
method: "POST",
|
|
45867
|
+
headers: {
|
|
45868
|
+
"Content-Type": "application/json",
|
|
45869
|
+
Authorization: `Bearer ${this._deviceJwt}`
|
|
45870
|
+
},
|
|
45871
|
+
body: JSON.stringify({
|
|
45872
|
+
initiator_hub_address: this._persisted.hubAddress,
|
|
45873
|
+
responder_hub_address: responderHubAddress
|
|
45874
|
+
})
|
|
45875
|
+
});
|
|
45876
|
+
if (!res.ok) {
|
|
45877
|
+
const detail = await res.text();
|
|
45878
|
+
throw new Error(`A2A channel request failed (${res.status}): ${detail}`);
|
|
45879
|
+
}
|
|
45880
|
+
const resp = await res.json();
|
|
45881
|
+
const channelId = resp.channel_id || resp.id;
|
|
45882
|
+
if (!this._persisted.a2aChannels) {
|
|
45883
|
+
this._persisted.a2aChannels = {};
|
|
45884
|
+
}
|
|
45885
|
+
this._persisted.a2aChannels[channelId] = {
|
|
45886
|
+
channelId,
|
|
45887
|
+
hubAddress: responderHubAddress,
|
|
45888
|
+
conversationId: resp.conversation_id || ""
|
|
45889
|
+
};
|
|
45890
|
+
await this._persistState();
|
|
45891
|
+
return channelId;
|
|
45892
|
+
}
|
|
45893
|
+
/**
|
|
45894
|
+
* Send a message to another agent via an active A2A channel.
|
|
45895
|
+
* Looks up the A2A conversation by hub address and sends via WS.
|
|
45896
|
+
*
|
|
45897
|
+
* NOTE: Currently sends plaintext over the WS (server-side relay).
|
|
45898
|
+
* Full E2E encryption (X3DH + Double Ratchet per A2A session) will be
|
|
45899
|
+
* added when the A2A ratchet activation flow is implemented.
|
|
45900
|
+
*/
|
|
45901
|
+
async sendToAgent(hubAddress, text, opts) {
|
|
45902
|
+
if (!this._persisted?.a2aChannels) {
|
|
45903
|
+
throw new Error("No A2A channels established");
|
|
45904
|
+
}
|
|
45905
|
+
const channelEntry = Object.values(this._persisted.a2aChannels).find(
|
|
45906
|
+
(ch) => ch.hubAddress === hubAddress
|
|
45907
|
+
);
|
|
45908
|
+
if (!channelEntry) {
|
|
45909
|
+
throw new Error(`No A2A channel found for hub address: ${hubAddress}`);
|
|
45910
|
+
}
|
|
45911
|
+
if (!channelEntry.conversationId) {
|
|
45912
|
+
throw new Error(`A2A channel ${channelEntry.channelId} does not have a conversation yet (not activated)`);
|
|
45913
|
+
}
|
|
45914
|
+
if (this._state !== "ready" || !this._ws) {
|
|
45915
|
+
throw new Error("Channel is not connected");
|
|
45916
|
+
}
|
|
45917
|
+
const payload = {
|
|
45918
|
+
conversation_id: channelEntry.conversationId,
|
|
45919
|
+
plaintext: text,
|
|
45920
|
+
message_type: "a2a",
|
|
45921
|
+
parent_span_id: opts?.parentSpanId
|
|
45922
|
+
};
|
|
45923
|
+
if (this._persisted.hubAddress) {
|
|
45924
|
+
payload.hub_address = this._persisted.hubAddress;
|
|
45925
|
+
}
|
|
45926
|
+
this._ws.send(
|
|
45927
|
+
JSON.stringify({
|
|
45928
|
+
event: "a2a_message",
|
|
45929
|
+
data: payload
|
|
45930
|
+
})
|
|
45931
|
+
);
|
|
45932
|
+
}
|
|
45933
|
+
/**
|
|
45934
|
+
* List all A2A channels for this agent.
|
|
45935
|
+
* Fetches from the server and updates local persisted state.
|
|
45936
|
+
*/
|
|
45937
|
+
async listA2AChannels() {
|
|
45938
|
+
if (!this._deviceJwt) {
|
|
45939
|
+
throw new Error("Channel not authenticated");
|
|
45940
|
+
}
|
|
45941
|
+
const res = await fetch(`${this.config.apiUrl}/api/v1/a2a/channels`, {
|
|
45942
|
+
headers: {
|
|
45943
|
+
Authorization: `Bearer ${this._deviceJwt}`
|
|
45944
|
+
}
|
|
45945
|
+
});
|
|
45946
|
+
if (!res.ok) {
|
|
45947
|
+
const detail = await res.text();
|
|
45948
|
+
throw new Error(`List A2A channels failed (${res.status}): ${detail}`);
|
|
45949
|
+
}
|
|
45950
|
+
const resp = await res.json();
|
|
45951
|
+
const channels = resp.map((ch) => ({
|
|
45952
|
+
channelId: ch.channel_id || ch.id,
|
|
45953
|
+
initiatorHubAddress: ch.initiator_hub_address,
|
|
45954
|
+
responderHubAddress: ch.responder_hub_address,
|
|
45955
|
+
conversationId: ch.conversation_id,
|
|
45956
|
+
status: ch.status,
|
|
45957
|
+
createdAt: ch.created_at
|
|
45958
|
+
}));
|
|
45959
|
+
if (this._persisted) {
|
|
45960
|
+
if (!this._persisted.a2aChannels) {
|
|
45961
|
+
this._persisted.a2aChannels = {};
|
|
45962
|
+
}
|
|
45963
|
+
for (const ch of channels) {
|
|
45964
|
+
if (ch.status === "active" || ch.status === "approved") {
|
|
45965
|
+
const otherAddress = ch.initiatorHubAddress === this._persisted.hubAddress ? ch.responderHubAddress : ch.initiatorHubAddress;
|
|
45966
|
+
this._persisted.a2aChannels[ch.channelId] = {
|
|
45967
|
+
channelId: ch.channelId,
|
|
45968
|
+
hubAddress: otherAddress,
|
|
45969
|
+
conversationId: ch.conversationId || ""
|
|
45970
|
+
};
|
|
45971
|
+
}
|
|
45972
|
+
}
|
|
45973
|
+
await this._persistState();
|
|
45974
|
+
}
|
|
45975
|
+
return channels;
|
|
45976
|
+
}
|
|
45849
45977
|
// --- Internal lifecycle ---
|
|
45850
45978
|
async _enroll() {
|
|
45851
45979
|
this._setState("enrolling");
|
|
@@ -46098,6 +46226,62 @@ var init_channel = __esm({
|
|
|
46098
46226
|
if (data.event === "policy_rejected") {
|
|
46099
46227
|
this.emit("policy_rejected", data.data);
|
|
46100
46228
|
}
|
|
46229
|
+
if (data.event === "hub_identity_assigned") {
|
|
46230
|
+
if (this._persisted) {
|
|
46231
|
+
this._persisted.hubAddress = data.data.hub_address;
|
|
46232
|
+
this._persistState();
|
|
46233
|
+
}
|
|
46234
|
+
this.emit("hub_identity_assigned", data.data);
|
|
46235
|
+
}
|
|
46236
|
+
if (data.event === "hub_identity_removed") {
|
|
46237
|
+
if (this._persisted) {
|
|
46238
|
+
delete this._persisted.hubAddress;
|
|
46239
|
+
this._persistState();
|
|
46240
|
+
}
|
|
46241
|
+
this.emit("hub_identity_removed", data.data);
|
|
46242
|
+
}
|
|
46243
|
+
if (data.event === "a2a_channel_approved") {
|
|
46244
|
+
const channelData = data.data || data;
|
|
46245
|
+
const channelId = channelData.channel_id;
|
|
46246
|
+
const convId = channelData.conversation_id;
|
|
46247
|
+
if (this._persisted && convId) {
|
|
46248
|
+
if (!this._persisted.a2aChannels) this._persisted.a2aChannels = {};
|
|
46249
|
+
this._persisted.a2aChannels[channelId] = {
|
|
46250
|
+
channelId,
|
|
46251
|
+
hubAddress: "",
|
|
46252
|
+
conversationId: convId
|
|
46253
|
+
};
|
|
46254
|
+
await this._persistState();
|
|
46255
|
+
}
|
|
46256
|
+
this.emit("a2a_channel_approved", channelData);
|
|
46257
|
+
}
|
|
46258
|
+
if (data.event === "a2a_channel_rejected") {
|
|
46259
|
+
this.emit("a2a_channel_rejected", data.data || data);
|
|
46260
|
+
}
|
|
46261
|
+
if (data.event === "a2a_channel_revoked") {
|
|
46262
|
+
const channelData = data.data || data;
|
|
46263
|
+
const channelId = channelData.channel_id;
|
|
46264
|
+
if (this._persisted?.a2aChannels?.[channelId]) {
|
|
46265
|
+
delete this._persisted.a2aChannels[channelId];
|
|
46266
|
+
await this._persistState();
|
|
46267
|
+
}
|
|
46268
|
+
this.emit("a2a_channel_revoked", channelData);
|
|
46269
|
+
}
|
|
46270
|
+
if (data.event === "a2a_message") {
|
|
46271
|
+
const msgData = data.data || data;
|
|
46272
|
+
const a2aMsg = {
|
|
46273
|
+
text: msgData.plaintext || msgData.text,
|
|
46274
|
+
fromHubAddress: msgData.from_hub_address || msgData.hub_address || "",
|
|
46275
|
+
channelId: msgData.channel_id || "",
|
|
46276
|
+
conversationId: msgData.conversation_id || "",
|
|
46277
|
+
parentSpanId: msgData.parent_span_id,
|
|
46278
|
+
timestamp: msgData.timestamp || (/* @__PURE__ */ new Date()).toISOString()
|
|
46279
|
+
};
|
|
46280
|
+
this.emit("a2a_message", a2aMsg);
|
|
46281
|
+
if (this.config.onA2AMessage) {
|
|
46282
|
+
this.config.onA2AMessage(a2aMsg);
|
|
46283
|
+
}
|
|
46284
|
+
}
|
|
46101
46285
|
} catch (err) {
|
|
46102
46286
|
this.emit("error", err);
|
|
46103
46287
|
}
|