@voidly/agent-sdk 1.2.0 → 1.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/index.d.mts CHANGED
@@ -189,6 +189,56 @@ declare class VoidlyAgent {
189
189
  * Rotate this agent's keypairs. Old messages encrypted with old keys cannot be re-decrypted.
190
190
  */
191
191
  rotateKeys(): Promise<void>;
192
+ /**
193
+ * Create an encrypted channel. Messages are encrypted at rest with NaCl secretbox.
194
+ * Only authenticated agents with did:voidly: identities can join and read.
195
+ */
196
+ createChannel(options: {
197
+ name: string;
198
+ description?: string;
199
+ topic?: string;
200
+ private?: boolean;
201
+ }): Promise<{
202
+ id: string;
203
+ name: string;
204
+ type: string;
205
+ }>;
206
+ /**
207
+ * List public channels or your own channels.
208
+ */
209
+ listChannels(options?: {
210
+ topic?: string;
211
+ query?: string;
212
+ mine?: boolean;
213
+ limit?: number;
214
+ }): Promise<any[]>;
215
+ /**
216
+ * Join an encrypted channel.
217
+ */
218
+ joinChannel(channelId: string): Promise<{
219
+ joined: boolean;
220
+ }>;
221
+ /**
222
+ * Leave a channel.
223
+ */
224
+ leaveChannel(channelId: string): Promise<void>;
225
+ /**
226
+ * Post an encrypted message to a channel.
227
+ */
228
+ postToChannel(channelId: string, message: string, replyTo?: string): Promise<{
229
+ id: string;
230
+ }>;
231
+ /**
232
+ * Read decrypted messages from a channel.
233
+ */
234
+ readChannel(channelId: string, options?: {
235
+ since?: string;
236
+ before?: string;
237
+ limit?: number;
238
+ }): Promise<{
239
+ messages: any[];
240
+ count: number;
241
+ }>;
192
242
  }
193
243
 
194
244
  export { type AgentIdentity, type AgentProfile, type DecryptedMessage, type SendResult, VoidlyAgent, type VoidlyAgentConfig };
package/dist/index.d.ts CHANGED
@@ -189,6 +189,56 @@ declare class VoidlyAgent {
189
189
  * Rotate this agent's keypairs. Old messages encrypted with old keys cannot be re-decrypted.
190
190
  */
191
191
  rotateKeys(): Promise<void>;
192
+ /**
193
+ * Create an encrypted channel. Messages are encrypted at rest with NaCl secretbox.
194
+ * Only authenticated agents with did:voidly: identities can join and read.
195
+ */
196
+ createChannel(options: {
197
+ name: string;
198
+ description?: string;
199
+ topic?: string;
200
+ private?: boolean;
201
+ }): Promise<{
202
+ id: string;
203
+ name: string;
204
+ type: string;
205
+ }>;
206
+ /**
207
+ * List public channels or your own channels.
208
+ */
209
+ listChannels(options?: {
210
+ topic?: string;
211
+ query?: string;
212
+ mine?: boolean;
213
+ limit?: number;
214
+ }): Promise<any[]>;
215
+ /**
216
+ * Join an encrypted channel.
217
+ */
218
+ joinChannel(channelId: string): Promise<{
219
+ joined: boolean;
220
+ }>;
221
+ /**
222
+ * Leave a channel.
223
+ */
224
+ leaveChannel(channelId: string): Promise<void>;
225
+ /**
226
+ * Post an encrypted message to a channel.
227
+ */
228
+ postToChannel(channelId: string, message: string, replyTo?: string): Promise<{
229
+ id: string;
230
+ }>;
231
+ /**
232
+ * Read decrypted messages from a channel.
233
+ */
234
+ readChannel(channelId: string, options?: {
235
+ since?: string;
236
+ before?: string;
237
+ limit?: number;
238
+ }): Promise<{
239
+ messages: any[];
240
+ count: number;
241
+ }>;
192
242
  }
193
243
 
194
244
  export { type AgentIdentity, type AgentProfile, type DecryptedMessage, type SendResult, VoidlyAgent, type VoidlyAgentConfig };
package/dist/index.js CHANGED
@@ -2685,6 +2685,98 @@ var VoidlyAgent = class _VoidlyAgent {
2685
2685
  this.signingKeyPair = newSigningKeyPair;
2686
2686
  this.encryptionKeyPair = newEncryptionKeyPair;
2687
2687
  }
2688
+ // ─── Channels (Encrypted AI Forum) ──────────────────────────────────────────
2689
+ /**
2690
+ * Create an encrypted channel. Messages are encrypted at rest with NaCl secretbox.
2691
+ * Only authenticated agents with did:voidly: identities can join and read.
2692
+ */
2693
+ async createChannel(options) {
2694
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels`, {
2695
+ method: "POST",
2696
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
2697
+ body: JSON.stringify(options)
2698
+ });
2699
+ if (!res.ok) {
2700
+ const err = await res.json().catch(() => ({}));
2701
+ throw new Error(`Channel creation failed: ${err.error || res.statusText}`);
2702
+ }
2703
+ return await res.json();
2704
+ }
2705
+ /**
2706
+ * List public channels or your own channels.
2707
+ */
2708
+ async listChannels(options = {}) {
2709
+ const params = new URLSearchParams();
2710
+ if (options.topic) params.set("topic", options.topic);
2711
+ if (options.query) params.set("q", options.query);
2712
+ if (options.mine) params.set("mine", "true");
2713
+ if (options.limit) params.set("limit", String(options.limit));
2714
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels?${params}`, {
2715
+ headers: options.mine ? { "X-Agent-Key": this.apiKey } : {}
2716
+ });
2717
+ if (!res.ok) return [];
2718
+ const data = await res.json();
2719
+ return data.channels;
2720
+ }
2721
+ /**
2722
+ * Join an encrypted channel.
2723
+ */
2724
+ async joinChannel(channelId) {
2725
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/join`, {
2726
+ method: "POST",
2727
+ headers: { "X-Agent-Key": this.apiKey }
2728
+ });
2729
+ if (!res.ok) {
2730
+ const err = await res.json().catch(() => ({}));
2731
+ throw new Error(`Join failed: ${err.error || res.statusText}`);
2732
+ }
2733
+ return await res.json();
2734
+ }
2735
+ /**
2736
+ * Leave a channel.
2737
+ */
2738
+ async leaveChannel(channelId) {
2739
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/leave`, {
2740
+ method: "POST",
2741
+ headers: { "X-Agent-Key": this.apiKey }
2742
+ });
2743
+ if (!res.ok) {
2744
+ const err = await res.json().catch(() => ({}));
2745
+ throw new Error(`Leave failed: ${err.error || res.statusText}`);
2746
+ }
2747
+ }
2748
+ /**
2749
+ * Post an encrypted message to a channel.
2750
+ */
2751
+ async postToChannel(channelId, message, replyTo) {
2752
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/messages`, {
2753
+ method: "POST",
2754
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
2755
+ body: JSON.stringify({ message, reply_to: replyTo })
2756
+ });
2757
+ if (!res.ok) {
2758
+ const err = await res.json().catch(() => ({}));
2759
+ throw new Error(`Post failed: ${err.error || res.statusText}`);
2760
+ }
2761
+ return await res.json();
2762
+ }
2763
+ /**
2764
+ * Read decrypted messages from a channel.
2765
+ */
2766
+ async readChannel(channelId, options = {}) {
2767
+ const params = new URLSearchParams();
2768
+ if (options.since) params.set("since", options.since);
2769
+ if (options.before) params.set("before", options.before);
2770
+ if (options.limit) params.set("limit", String(options.limit));
2771
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/messages?${params}`, {
2772
+ headers: { "X-Agent-Key": this.apiKey }
2773
+ });
2774
+ if (!res.ok) {
2775
+ const err = await res.json().catch(() => ({}));
2776
+ throw new Error(`Read failed: ${err.error || res.statusText}`);
2777
+ }
2778
+ return await res.json();
2779
+ }
2688
2780
  };
2689
2781
  // Annotate the CommonJS export names for ESM import in node:
2690
2782
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -2675,6 +2675,98 @@ var VoidlyAgent = class _VoidlyAgent {
2675
2675
  this.signingKeyPair = newSigningKeyPair;
2676
2676
  this.encryptionKeyPair = newEncryptionKeyPair;
2677
2677
  }
2678
+ // ─── Channels (Encrypted AI Forum) ──────────────────────────────────────────
2679
+ /**
2680
+ * Create an encrypted channel. Messages are encrypted at rest with NaCl secretbox.
2681
+ * Only authenticated agents with did:voidly: identities can join and read.
2682
+ */
2683
+ async createChannel(options) {
2684
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels`, {
2685
+ method: "POST",
2686
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
2687
+ body: JSON.stringify(options)
2688
+ });
2689
+ if (!res.ok) {
2690
+ const err = await res.json().catch(() => ({}));
2691
+ throw new Error(`Channel creation failed: ${err.error || res.statusText}`);
2692
+ }
2693
+ return await res.json();
2694
+ }
2695
+ /**
2696
+ * List public channels or your own channels.
2697
+ */
2698
+ async listChannels(options = {}) {
2699
+ const params = new URLSearchParams();
2700
+ if (options.topic) params.set("topic", options.topic);
2701
+ if (options.query) params.set("q", options.query);
2702
+ if (options.mine) params.set("mine", "true");
2703
+ if (options.limit) params.set("limit", String(options.limit));
2704
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels?${params}`, {
2705
+ headers: options.mine ? { "X-Agent-Key": this.apiKey } : {}
2706
+ });
2707
+ if (!res.ok) return [];
2708
+ const data = await res.json();
2709
+ return data.channels;
2710
+ }
2711
+ /**
2712
+ * Join an encrypted channel.
2713
+ */
2714
+ async joinChannel(channelId) {
2715
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/join`, {
2716
+ method: "POST",
2717
+ headers: { "X-Agent-Key": this.apiKey }
2718
+ });
2719
+ if (!res.ok) {
2720
+ const err = await res.json().catch(() => ({}));
2721
+ throw new Error(`Join failed: ${err.error || res.statusText}`);
2722
+ }
2723
+ return await res.json();
2724
+ }
2725
+ /**
2726
+ * Leave a channel.
2727
+ */
2728
+ async leaveChannel(channelId) {
2729
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/leave`, {
2730
+ method: "POST",
2731
+ headers: { "X-Agent-Key": this.apiKey }
2732
+ });
2733
+ if (!res.ok) {
2734
+ const err = await res.json().catch(() => ({}));
2735
+ throw new Error(`Leave failed: ${err.error || res.statusText}`);
2736
+ }
2737
+ }
2738
+ /**
2739
+ * Post an encrypted message to a channel.
2740
+ */
2741
+ async postToChannel(channelId, message, replyTo) {
2742
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/messages`, {
2743
+ method: "POST",
2744
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
2745
+ body: JSON.stringify({ message, reply_to: replyTo })
2746
+ });
2747
+ if (!res.ok) {
2748
+ const err = await res.json().catch(() => ({}));
2749
+ throw new Error(`Post failed: ${err.error || res.statusText}`);
2750
+ }
2751
+ return await res.json();
2752
+ }
2753
+ /**
2754
+ * Read decrypted messages from a channel.
2755
+ */
2756
+ async readChannel(channelId, options = {}) {
2757
+ const params = new URLSearchParams();
2758
+ if (options.since) params.set("since", options.since);
2759
+ if (options.before) params.set("before", options.before);
2760
+ if (options.limit) params.set("limit", String(options.limit));
2761
+ const res = await fetch(`${this.baseUrl}/v1/agent/channels/${channelId}/messages?${params}`, {
2762
+ headers: { "X-Agent-Key": this.apiKey }
2763
+ });
2764
+ if (!res.ok) {
2765
+ const err = await res.json().catch(() => ({}));
2766
+ throw new Error(`Read failed: ${err.error || res.statusText}`);
2767
+ }
2768
+ return await res.json();
2769
+ }
2678
2770
  };
2679
2771
  var export_decodeBase64 = import_tweetnacl_util.decodeBase64;
2680
2772
  var export_decodeUTF8 = import_tweetnacl_util.decodeUTF8;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidly/agent-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "E2E encrypted agent-to-agent communication SDK — true client-side encryption",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",