@voidly/agent-sdk 1.1.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
@@ -124,6 +124,22 @@ declare class VoidlyAgent {
124
124
  since?: string;
125
125
  limit?: number;
126
126
  }): Promise<DecryptedMessage[]>;
127
+ /**
128
+ * Delete a message by ID (must be sender or recipient).
129
+ */
130
+ deleteMessage(messageId: string): Promise<boolean>;
131
+ /**
132
+ * Get this agent's own profile.
133
+ */
134
+ getProfile(): Promise<AgentProfile>;
135
+ /**
136
+ * Update this agent's profile (name, capabilities, metadata).
137
+ */
138
+ updateProfile(updates: {
139
+ name?: string;
140
+ capabilities?: string[];
141
+ metadata?: Record<string, unknown>;
142
+ }): Promise<void>;
127
143
  /**
128
144
  * Look up an agent's public profile and keys.
129
145
  */
@@ -173,6 +189,56 @@ declare class VoidlyAgent {
173
189
  * Rotate this agent's keypairs. Old messages encrypted with old keys cannot be re-decrypted.
174
190
  */
175
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
+ }>;
176
242
  }
177
243
 
178
244
  export { type AgentIdentity, type AgentProfile, type DecryptedMessage, type SendResult, VoidlyAgent, type VoidlyAgentConfig };
package/dist/index.d.ts CHANGED
@@ -124,6 +124,22 @@ declare class VoidlyAgent {
124
124
  since?: string;
125
125
  limit?: number;
126
126
  }): Promise<DecryptedMessage[]>;
127
+ /**
128
+ * Delete a message by ID (must be sender or recipient).
129
+ */
130
+ deleteMessage(messageId: string): Promise<boolean>;
131
+ /**
132
+ * Get this agent's own profile.
133
+ */
134
+ getProfile(): Promise<AgentProfile>;
135
+ /**
136
+ * Update this agent's profile (name, capabilities, metadata).
137
+ */
138
+ updateProfile(updates: {
139
+ name?: string;
140
+ capabilities?: string[];
141
+ metadata?: Record<string, unknown>;
142
+ }): Promise<void>;
127
143
  /**
128
144
  * Look up an agent's public profile and keys.
129
145
  */
@@ -173,6 +189,56 @@ declare class VoidlyAgent {
173
189
  * Rotate this agent's keypairs. Old messages encrypted with old keys cannot be re-decrypted.
174
190
  */
175
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
+ }>;
176
242
  }
177
243
 
178
244
  export { type AgentIdentity, type AgentProfile, type DecryptedMessage, type SendResult, VoidlyAgent, type VoidlyAgentConfig };
package/dist/index.js CHANGED
@@ -2526,6 +2526,47 @@ var VoidlyAgent = class _VoidlyAgent {
2526
2526
  }
2527
2527
  return decrypted;
2528
2528
  }
2529
+ // ─── Message Management ─────────────────────────────────────────────────────
2530
+ /**
2531
+ * Delete a message by ID (must be sender or recipient).
2532
+ */
2533
+ async deleteMessage(messageId) {
2534
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/${messageId}`, {
2535
+ method: "DELETE",
2536
+ headers: { "X-Agent-Key": this.apiKey }
2537
+ });
2538
+ return res.ok;
2539
+ }
2540
+ // ─── Profile ──────────────────────────────────────────────────────────────
2541
+ /**
2542
+ * Get this agent's own profile.
2543
+ */
2544
+ async getProfile() {
2545
+ const res = await fetch(`${this.baseUrl}/v1/agent/profile`, {
2546
+ headers: { "X-Agent-Key": this.apiKey }
2547
+ });
2548
+ if (!res.ok) {
2549
+ throw new Error("Failed to fetch profile");
2550
+ }
2551
+ return await res.json();
2552
+ }
2553
+ /**
2554
+ * Update this agent's profile (name, capabilities, metadata).
2555
+ */
2556
+ async updateProfile(updates) {
2557
+ const res = await fetch(`${this.baseUrl}/v1/agent/profile`, {
2558
+ method: "PATCH",
2559
+ headers: {
2560
+ "Content-Type": "application/json",
2561
+ "X-Agent-Key": this.apiKey
2562
+ },
2563
+ body: JSON.stringify(updates)
2564
+ });
2565
+ if (!res.ok) {
2566
+ const err = await res.json().catch(() => ({}));
2567
+ throw new Error(`Profile update failed: ${err.error || res.statusText}`);
2568
+ }
2569
+ }
2529
2570
  // ─── Discovery ──────────────────────────────────────────────────────────────
2530
2571
  /**
2531
2572
  * Look up an agent's public profile and keys.
@@ -2644,6 +2685,98 @@ var VoidlyAgent = class _VoidlyAgent {
2644
2685
  this.signingKeyPair = newSigningKeyPair;
2645
2686
  this.encryptionKeyPair = newEncryptionKeyPair;
2646
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
+ }
2647
2780
  };
2648
2781
  // Annotate the CommonJS export names for ESM import in node:
2649
2782
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -2516,6 +2516,47 @@ var VoidlyAgent = class _VoidlyAgent {
2516
2516
  }
2517
2517
  return decrypted;
2518
2518
  }
2519
+ // ─── Message Management ─────────────────────────────────────────────────────
2520
+ /**
2521
+ * Delete a message by ID (must be sender or recipient).
2522
+ */
2523
+ async deleteMessage(messageId) {
2524
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/${messageId}`, {
2525
+ method: "DELETE",
2526
+ headers: { "X-Agent-Key": this.apiKey }
2527
+ });
2528
+ return res.ok;
2529
+ }
2530
+ // ─── Profile ──────────────────────────────────────────────────────────────
2531
+ /**
2532
+ * Get this agent's own profile.
2533
+ */
2534
+ async getProfile() {
2535
+ const res = await fetch(`${this.baseUrl}/v1/agent/profile`, {
2536
+ headers: { "X-Agent-Key": this.apiKey }
2537
+ });
2538
+ if (!res.ok) {
2539
+ throw new Error("Failed to fetch profile");
2540
+ }
2541
+ return await res.json();
2542
+ }
2543
+ /**
2544
+ * Update this agent's profile (name, capabilities, metadata).
2545
+ */
2546
+ async updateProfile(updates) {
2547
+ const res = await fetch(`${this.baseUrl}/v1/agent/profile`, {
2548
+ method: "PATCH",
2549
+ headers: {
2550
+ "Content-Type": "application/json",
2551
+ "X-Agent-Key": this.apiKey
2552
+ },
2553
+ body: JSON.stringify(updates)
2554
+ });
2555
+ if (!res.ok) {
2556
+ const err = await res.json().catch(() => ({}));
2557
+ throw new Error(`Profile update failed: ${err.error || res.statusText}`);
2558
+ }
2559
+ }
2519
2560
  // ─── Discovery ──────────────────────────────────────────────────────────────
2520
2561
  /**
2521
2562
  * Look up an agent's public profile and keys.
@@ -2634,6 +2675,98 @@ var VoidlyAgent = class _VoidlyAgent {
2634
2675
  this.signingKeyPair = newSigningKeyPair;
2635
2676
  this.encryptionKeyPair = newEncryptionKeyPair;
2636
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
+ }
2637
2770
  };
2638
2771
  var export_decodeBase64 = import_tweetnacl_util.decodeBase64;
2639
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.1.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",