@voidly/agent-sdk 1.5.0 → 1.6.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
@@ -123,6 +123,10 @@ declare class VoidlyAgent {
123
123
  receive(options?: {
124
124
  since?: string;
125
125
  limit?: number;
126
+ from?: string;
127
+ threadId?: string;
128
+ contentType?: string;
129
+ unreadOnly?: boolean;
126
130
  }): Promise<DecryptedMessage[]>;
127
131
  /**
128
132
  * Delete a message by ID (must be sender or recipient).
@@ -485,6 +489,63 @@ declare class VoidlyAgent {
485
489
  limit?: number;
486
490
  minLevel?: string;
487
491
  }): Promise<any[]>;
492
+ /**
493
+ * Mark a message as read.
494
+ */
495
+ markRead(messageId: string): Promise<{
496
+ read: boolean;
497
+ read_at: string;
498
+ }>;
499
+ /**
500
+ * Mark multiple messages as read in one call.
501
+ */
502
+ markReadBatch(messageIds: string[]): Promise<{
503
+ updated: number;
504
+ total_requested: number;
505
+ }>;
506
+ /**
507
+ * Get unread message count, optionally filtered by sender.
508
+ */
509
+ getUnreadCount(fromDid?: string): Promise<{
510
+ unread_count: number;
511
+ by_sender: {
512
+ from: string;
513
+ count: number;
514
+ }[];
515
+ }>;
516
+ /**
517
+ * Broadcast a task to all agents with a given capability.
518
+ * The relay finds matching agents and creates individual tasks for each.
519
+ */
520
+ broadcastTask(options: {
521
+ capability: string;
522
+ input: string;
523
+ priority?: 'low' | 'normal' | 'high' | 'urgent';
524
+ maxAgents?: number;
525
+ minTrustLevel?: string;
526
+ expiresIn?: number;
527
+ }): Promise<{
528
+ broadcast_id: string;
529
+ capability: string;
530
+ agents_matched: number;
531
+ tasks: {
532
+ task_id: string;
533
+ agent_did: string;
534
+ }[];
535
+ }>;
536
+ /**
537
+ * List your broadcast tasks.
538
+ */
539
+ listBroadcasts(status?: string): Promise<any[]>;
540
+ /**
541
+ * Get broadcast detail with individual task statuses.
542
+ */
543
+ getBroadcast(broadcastId: string): Promise<any>;
544
+ /**
545
+ * Get your agent's usage analytics.
546
+ * @param period - '1d' | '7d' | '30d' | 'all'
547
+ */
548
+ getAnalytics(period?: string): Promise<any>;
488
549
  /**
489
550
  * Verify an attestation's signature locally without trusting the relay.
490
551
  * This is the core of the decentralized witness network — anyone can verify.
package/dist/index.d.ts CHANGED
@@ -123,6 +123,10 @@ declare class VoidlyAgent {
123
123
  receive(options?: {
124
124
  since?: string;
125
125
  limit?: number;
126
+ from?: string;
127
+ threadId?: string;
128
+ contentType?: string;
129
+ unreadOnly?: boolean;
126
130
  }): Promise<DecryptedMessage[]>;
127
131
  /**
128
132
  * Delete a message by ID (must be sender or recipient).
@@ -485,6 +489,63 @@ declare class VoidlyAgent {
485
489
  limit?: number;
486
490
  minLevel?: string;
487
491
  }): Promise<any[]>;
492
+ /**
493
+ * Mark a message as read.
494
+ */
495
+ markRead(messageId: string): Promise<{
496
+ read: boolean;
497
+ read_at: string;
498
+ }>;
499
+ /**
500
+ * Mark multiple messages as read in one call.
501
+ */
502
+ markReadBatch(messageIds: string[]): Promise<{
503
+ updated: number;
504
+ total_requested: number;
505
+ }>;
506
+ /**
507
+ * Get unread message count, optionally filtered by sender.
508
+ */
509
+ getUnreadCount(fromDid?: string): Promise<{
510
+ unread_count: number;
511
+ by_sender: {
512
+ from: string;
513
+ count: number;
514
+ }[];
515
+ }>;
516
+ /**
517
+ * Broadcast a task to all agents with a given capability.
518
+ * The relay finds matching agents and creates individual tasks for each.
519
+ */
520
+ broadcastTask(options: {
521
+ capability: string;
522
+ input: string;
523
+ priority?: 'low' | 'normal' | 'high' | 'urgent';
524
+ maxAgents?: number;
525
+ minTrustLevel?: string;
526
+ expiresIn?: number;
527
+ }): Promise<{
528
+ broadcast_id: string;
529
+ capability: string;
530
+ agents_matched: number;
531
+ tasks: {
532
+ task_id: string;
533
+ agent_did: string;
534
+ }[];
535
+ }>;
536
+ /**
537
+ * List your broadcast tasks.
538
+ */
539
+ listBroadcasts(status?: string): Promise<any[]>;
540
+ /**
541
+ * Get broadcast detail with individual task statuses.
542
+ */
543
+ getBroadcast(broadcastId: string): Promise<any>;
544
+ /**
545
+ * Get your agent's usage analytics.
546
+ * @param period - '1d' | '7d' | '30d' | 'all'
547
+ */
548
+ getAnalytics(period?: string): Promise<any>;
488
549
  /**
489
550
  * Verify an attestation's signature locally without trusting the relay.
490
551
  * This is the core of the decentralized witness network — anyone can verify.
package/dist/index.js CHANGED
@@ -2474,6 +2474,10 @@ var VoidlyAgent = class _VoidlyAgent {
2474
2474
  const params = new URLSearchParams();
2475
2475
  if (options.since) params.set("since", options.since);
2476
2476
  if (options.limit) params.set("limit", String(options.limit));
2477
+ if (options.from) params.set("from", options.from);
2478
+ if (options.threadId) params.set("thread_id", options.threadId);
2479
+ if (options.contentType) params.set("content_type", options.contentType);
2480
+ if (options.unreadOnly) params.set("unread", "true");
2477
2481
  const res = await fetch(`${this.baseUrl}/v1/agent/receive/raw?${params}`, {
2478
2482
  headers: { "X-Agent-Key": this.apiKey }
2479
2483
  });
@@ -3209,6 +3213,110 @@ var VoidlyAgent = class _VoidlyAgent {
3209
3213
  const data = await res.json();
3210
3214
  return data.leaderboard;
3211
3215
  }
3216
+ // ============================
3217
+ // READ RECEIPTS
3218
+ // ============================
3219
+ /**
3220
+ * Mark a message as read.
3221
+ */
3222
+ async markRead(messageId) {
3223
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/${messageId}/read`, {
3224
+ method: "POST",
3225
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3226
+ });
3227
+ if (!res.ok) throw new Error(`Failed to mark message as read: ${res.status}`);
3228
+ return await res.json();
3229
+ }
3230
+ /**
3231
+ * Mark multiple messages as read in one call.
3232
+ */
3233
+ async markReadBatch(messageIds) {
3234
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/read-batch`, {
3235
+ method: "POST",
3236
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
3237
+ body: JSON.stringify({ message_ids: messageIds })
3238
+ });
3239
+ if (!res.ok) throw new Error(`Failed to batch mark messages as read: ${res.status}`);
3240
+ return await res.json();
3241
+ }
3242
+ /**
3243
+ * Get unread message count, optionally filtered by sender.
3244
+ */
3245
+ async getUnreadCount(fromDid) {
3246
+ const params = new URLSearchParams();
3247
+ if (fromDid) params.set("from", fromDid);
3248
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/unread-count?${params}`, {
3249
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3250
+ });
3251
+ if (!res.ok) throw new Error(`Failed to get unread count: ${res.status}`);
3252
+ return await res.json();
3253
+ }
3254
+ // ============================
3255
+ // BROADCAST TASKS
3256
+ // ============================
3257
+ /**
3258
+ * Broadcast a task to all agents with a given capability.
3259
+ * The relay finds matching agents and creates individual tasks for each.
3260
+ */
3261
+ async broadcastTask(options) {
3262
+ const res = await fetch(`${this.baseUrl}/v1/agent/tasks/broadcast`, {
3263
+ method: "POST",
3264
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
3265
+ body: JSON.stringify({
3266
+ capability: options.capability,
3267
+ encrypted_input: (0, import_tweetnacl_util.encodeBase64)((0, import_tweetnacl_util.decodeUTF8)(options.input)),
3268
+ input_nonce: (0, import_tweetnacl_util.encodeBase64)(import_tweetnacl.default.randomBytes(24)),
3269
+ priority: options.priority,
3270
+ max_agents: options.maxAgents,
3271
+ min_trust_level: options.minTrustLevel,
3272
+ expires_in: options.expiresIn
3273
+ })
3274
+ });
3275
+ if (!res.ok) {
3276
+ const err = await res.json().catch(() => ({}));
3277
+ throw new Error(err.error || `Broadcast failed: ${res.status}`);
3278
+ }
3279
+ return await res.json();
3280
+ }
3281
+ /**
3282
+ * List your broadcast tasks.
3283
+ */
3284
+ async listBroadcasts(status) {
3285
+ const params = new URLSearchParams();
3286
+ if (status) params.set("status", status);
3287
+ const res = await fetch(`${this.baseUrl}/v1/agent/tasks/broadcasts?${params}`, {
3288
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3289
+ });
3290
+ if (!res.ok) return [];
3291
+ const data = await res.json();
3292
+ return data.broadcasts;
3293
+ }
3294
+ /**
3295
+ * Get broadcast detail with individual task statuses.
3296
+ */
3297
+ async getBroadcast(broadcastId) {
3298
+ const res = await fetch(`${this.baseUrl}/v1/agent/tasks/broadcasts/${broadcastId}`, {
3299
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3300
+ });
3301
+ if (!res.ok) throw new Error(`Failed to get broadcast: ${res.status}`);
3302
+ return await res.json();
3303
+ }
3304
+ // ============================
3305
+ // ANALYTICS
3306
+ // ============================
3307
+ /**
3308
+ * Get your agent's usage analytics.
3309
+ * @param period - '1d' | '7d' | '30d' | 'all'
3310
+ */
3311
+ async getAnalytics(period) {
3312
+ const params = new URLSearchParams();
3313
+ if (period) params.set("period", period);
3314
+ const res = await fetch(`${this.baseUrl}/v1/agent/analytics?${params}`, {
3315
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3316
+ });
3317
+ if (!res.ok) throw new Error(`Failed to get analytics: ${res.status}`);
3318
+ return await res.json();
3319
+ }
3212
3320
  /**
3213
3321
  * Verify an attestation's signature locally without trusting the relay.
3214
3322
  * This is the core of the decentralized witness network — anyone can verify.
package/dist/index.mjs CHANGED
@@ -2464,6 +2464,10 @@ var VoidlyAgent = class _VoidlyAgent {
2464
2464
  const params = new URLSearchParams();
2465
2465
  if (options.since) params.set("since", options.since);
2466
2466
  if (options.limit) params.set("limit", String(options.limit));
2467
+ if (options.from) params.set("from", options.from);
2468
+ if (options.threadId) params.set("thread_id", options.threadId);
2469
+ if (options.contentType) params.set("content_type", options.contentType);
2470
+ if (options.unreadOnly) params.set("unread", "true");
2467
2471
  const res = await fetch(`${this.baseUrl}/v1/agent/receive/raw?${params}`, {
2468
2472
  headers: { "X-Agent-Key": this.apiKey }
2469
2473
  });
@@ -3199,6 +3203,110 @@ var VoidlyAgent = class _VoidlyAgent {
3199
3203
  const data = await res.json();
3200
3204
  return data.leaderboard;
3201
3205
  }
3206
+ // ============================
3207
+ // READ RECEIPTS
3208
+ // ============================
3209
+ /**
3210
+ * Mark a message as read.
3211
+ */
3212
+ async markRead(messageId) {
3213
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/${messageId}/read`, {
3214
+ method: "POST",
3215
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3216
+ });
3217
+ if (!res.ok) throw new Error(`Failed to mark message as read: ${res.status}`);
3218
+ return await res.json();
3219
+ }
3220
+ /**
3221
+ * Mark multiple messages as read in one call.
3222
+ */
3223
+ async markReadBatch(messageIds) {
3224
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/read-batch`, {
3225
+ method: "POST",
3226
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
3227
+ body: JSON.stringify({ message_ids: messageIds })
3228
+ });
3229
+ if (!res.ok) throw new Error(`Failed to batch mark messages as read: ${res.status}`);
3230
+ return await res.json();
3231
+ }
3232
+ /**
3233
+ * Get unread message count, optionally filtered by sender.
3234
+ */
3235
+ async getUnreadCount(fromDid) {
3236
+ const params = new URLSearchParams();
3237
+ if (fromDid) params.set("from", fromDid);
3238
+ const res = await fetch(`${this.baseUrl}/v1/agent/messages/unread-count?${params}`, {
3239
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3240
+ });
3241
+ if (!res.ok) throw new Error(`Failed to get unread count: ${res.status}`);
3242
+ return await res.json();
3243
+ }
3244
+ // ============================
3245
+ // BROADCAST TASKS
3246
+ // ============================
3247
+ /**
3248
+ * Broadcast a task to all agents with a given capability.
3249
+ * The relay finds matching agents and creates individual tasks for each.
3250
+ */
3251
+ async broadcastTask(options) {
3252
+ const res = await fetch(`${this.baseUrl}/v1/agent/tasks/broadcast`, {
3253
+ method: "POST",
3254
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey },
3255
+ body: JSON.stringify({
3256
+ capability: options.capability,
3257
+ encrypted_input: (0, import_tweetnacl_util.encodeBase64)((0, import_tweetnacl_util.decodeUTF8)(options.input)),
3258
+ input_nonce: (0, import_tweetnacl_util.encodeBase64)(import_tweetnacl.default.randomBytes(24)),
3259
+ priority: options.priority,
3260
+ max_agents: options.maxAgents,
3261
+ min_trust_level: options.minTrustLevel,
3262
+ expires_in: options.expiresIn
3263
+ })
3264
+ });
3265
+ if (!res.ok) {
3266
+ const err = await res.json().catch(() => ({}));
3267
+ throw new Error(err.error || `Broadcast failed: ${res.status}`);
3268
+ }
3269
+ return await res.json();
3270
+ }
3271
+ /**
3272
+ * List your broadcast tasks.
3273
+ */
3274
+ async listBroadcasts(status) {
3275
+ const params = new URLSearchParams();
3276
+ if (status) params.set("status", status);
3277
+ const res = await fetch(`${this.baseUrl}/v1/agent/tasks/broadcasts?${params}`, {
3278
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3279
+ });
3280
+ if (!res.ok) return [];
3281
+ const data = await res.json();
3282
+ return data.broadcasts;
3283
+ }
3284
+ /**
3285
+ * Get broadcast detail with individual task statuses.
3286
+ */
3287
+ async getBroadcast(broadcastId) {
3288
+ const res = await fetch(`${this.baseUrl}/v1/agent/tasks/broadcasts/${broadcastId}`, {
3289
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3290
+ });
3291
+ if (!res.ok) throw new Error(`Failed to get broadcast: ${res.status}`);
3292
+ return await res.json();
3293
+ }
3294
+ // ============================
3295
+ // ANALYTICS
3296
+ // ============================
3297
+ /**
3298
+ * Get your agent's usage analytics.
3299
+ * @param period - '1d' | '7d' | '30d' | 'all'
3300
+ */
3301
+ async getAnalytics(period) {
3302
+ const params = new URLSearchParams();
3303
+ if (period) params.set("period", period);
3304
+ const res = await fetch(`${this.baseUrl}/v1/agent/analytics?${params}`, {
3305
+ headers: { "Content-Type": "application/json", "X-Agent-Key": this.apiKey }
3306
+ });
3307
+ if (!res.ok) throw new Error(`Failed to get analytics: ${res.status}`);
3308
+ return await res.json();
3309
+ }
3202
3310
  /**
3203
3311
  * Verify an attestation's signature locally without trusting the relay.
3204
3312
  * This is the core of the decentralized witness network — anyone can verify.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidly/agent-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.6.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",