@agentsbazaar/sdk 0.2.0 → 0.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/client.js CHANGED
@@ -2,9 +2,11 @@ import nacl from "tweetnacl";
2
2
  export class AgentBazaarClient {
3
3
  baseUrl;
4
4
  keypair;
5
- constructor(options) {
6
- this.baseUrl = (options.baseUrl || "https://agentbazaar.dev").replace(/\/$/, "");
5
+ apiKey;
6
+ constructor(options = {}) {
7
+ this.baseUrl = (options.baseUrl || process.env.AGENTBAZAAR_API || "https://agentbazaar.dev").replace(/\/$/, "");
7
8
  this.keypair = options.keypair || null;
9
+ this.apiKey = options.apiKey || null;
8
10
  }
9
11
  signMessage(action) {
10
12
  if (!this.keypair) {
@@ -21,8 +23,17 @@ export class AgentBazaarClient {
21
23
  };
22
24
  }
23
25
  async request(path, options) {
24
- const res = await fetch(`${this.baseUrl}${path}`, options);
25
- const data = await res.json();
26
+ const res = await fetch(`${this.baseUrl}${path}`, {
27
+ ...options,
28
+ signal: options?.signal || AbortSignal.timeout(60_000),
29
+ });
30
+ let data;
31
+ try {
32
+ data = await res.json();
33
+ }
34
+ catch {
35
+ throw new Error(`HTTP ${res.status}: invalid response`);
36
+ }
26
37
  if (!res.ok) {
27
38
  throw new Error(data.error || `HTTP ${res.status}`);
28
39
  }
@@ -117,7 +128,15 @@ export class AgentBazaarClient {
117
128
  return this.request("/health");
118
129
  }
119
130
  // ── A2A Protocol ──
120
- async a2aSend(slug, task) {
131
+ async a2aSend(slug, task, options) {
132
+ const parts = [
133
+ { type: "text", text: task },
134
+ ];
135
+ if (options?.files) {
136
+ for (const f of options.files) {
137
+ parts.push({ type: "file", url: f.url, name: f.name, mimeType: f.mimeType });
138
+ }
139
+ }
121
140
  return this.request(`/a2a/${slug}/`, {
122
141
  method: "POST",
123
142
  headers: { "Content-Type": "application/json" },
@@ -125,9 +144,7 @@ export class AgentBazaarClient {
125
144
  jsonrpc: "2.0",
126
145
  id: 1,
127
146
  method: "tasks/send",
128
- params: {
129
- message: { parts: [{ type: "text", text: task }] },
130
- },
147
+ params: { message: { parts } },
131
148
  }),
132
149
  });
133
150
  }
@@ -155,43 +172,140 @@ export class AgentBazaarClient {
155
172
  }),
156
173
  });
157
174
  }
158
- async *a2aStream(slug, task) {
159
- const res = await fetch(`${this.baseUrl}/a2a/${slug}/`, {
160
- method: "POST",
161
- headers: { "Content-Type": "application/json" },
162
- body: JSON.stringify({
163
- jsonrpc: "2.0",
164
- id: 1,
165
- method: "tasks/sendSubscribe",
166
- params: {
167
- message: { parts: [{ type: "text", text: task }] },
168
- },
169
- }),
170
- });
171
- if (!res.ok || !res.body) {
172
- throw new Error(`A2A stream failed: HTTP ${res.status}`);
175
+ async *a2aStream(slug, task, options) {
176
+ const parts = [
177
+ { type: "text", text: task },
178
+ ];
179
+ if (options?.files) {
180
+ for (const f of options.files) {
181
+ parts.push({ type: "file", url: f.url, name: f.name, mimeType: f.mimeType });
182
+ }
173
183
  }
174
- const reader = res.body.getReader();
175
- const decoder = new TextDecoder();
176
- let buffer = "";
177
- while (true) {
178
- const { done, value } = await reader.read();
179
- if (done)
180
- break;
181
- buffer += decoder.decode(value, { stream: true });
182
- const lines = buffer.split("\n");
183
- buffer = lines.pop() || "";
184
- for (const line of lines) {
185
- if (line.startsWith("data: ")) {
186
- try {
187
- yield JSON.parse(line.slice(6));
188
- }
189
- catch {
190
- // skip malformed events
184
+ const controller = new AbortController();
185
+ const timeoutMs = options?.timeoutMs ?? 60_000;
186
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
187
+ try {
188
+ const res = await fetch(`${this.baseUrl}/a2a/${slug}/`, {
189
+ method: "POST",
190
+ headers: { "Content-Type": "application/json" },
191
+ body: JSON.stringify({
192
+ jsonrpc: "2.0",
193
+ id: 1,
194
+ method: "tasks/sendSubscribe",
195
+ params: { message: { parts } },
196
+ }),
197
+ signal: controller.signal,
198
+ });
199
+ if (!res.ok || !res.body) {
200
+ throw new Error(`A2A stream failed: HTTP ${res.status}`);
201
+ }
202
+ const reader = res.body.getReader();
203
+ const decoder = new TextDecoder();
204
+ let buffer = "";
205
+ while (true) {
206
+ const { done, value } = await reader.read();
207
+ if (done)
208
+ break;
209
+ buffer += decoder.decode(value, { stream: true });
210
+ const lines = buffer.split("\n");
211
+ buffer = lines.pop() || "";
212
+ for (const line of lines) {
213
+ if (line.startsWith("data: ")) {
214
+ try {
215
+ yield JSON.parse(line.slice(6));
216
+ }
217
+ catch {
218
+ // skip malformed events
219
+ }
191
220
  }
192
221
  }
193
222
  }
194
223
  }
224
+ finally {
225
+ clearTimeout(timeout);
226
+ }
227
+ }
228
+ // ── Quoting ──
229
+ async quote(params) {
230
+ return this.request("/quote", {
231
+ method: "POST",
232
+ headers: { "Content-Type": "application/json" },
233
+ body: JSON.stringify(params),
234
+ });
235
+ }
236
+ async getQuote(quoteId) {
237
+ return this.request(`/quote/${quoteId}`);
238
+ }
239
+ // ── Sessions ──
240
+ // ── Sessions — multi-turn conversations ──
241
+ /**
242
+ * Start a session with an agent. Returns a sessionId for multi-turn conversations.
243
+ */
244
+ async startSession(agentPubkey, budgetLimit) {
245
+ const auth = this.signMessage("chat");
246
+ return this.request("/chat/start", {
247
+ method: "POST",
248
+ headers: {
249
+ "Content-Type": "application/json",
250
+ "X-Wallet-Address": auth.address,
251
+ "X-Wallet-Signature": auth.signature,
252
+ "X-Wallet-Message": auth.message,
253
+ },
254
+ body: JSON.stringify({ agent: agentPubkey, ...(budgetLimit && { budgetLimit }) }),
255
+ });
256
+ }
257
+ /**
258
+ * Send a message in an existing session. Returns a quote with an unsigned payment transaction.
259
+ * Call paySession() with the paymentId to execute.
260
+ */
261
+ async sendMessage(sessionId, task, fileUrl) {
262
+ const auth = this.signMessage("chat");
263
+ return this.request("/chat/send", {
264
+ method: "POST",
265
+ headers: {
266
+ "Content-Type": "application/json",
267
+ "X-Wallet-Address": auth.address,
268
+ "X-Wallet-Signature": auth.signature,
269
+ "X-Wallet-Message": auth.message,
270
+ },
271
+ body: JSON.stringify({ sessionId, task, ...(fileUrl && { fileUrl }) }),
272
+ });
273
+ }
274
+ /**
275
+ * Pay for a message and get the agent's response.
276
+ * Pass the paymentId from sendMessage() and the signed transaction.
277
+ */
278
+ async paySession(paymentId, signedTransaction) {
279
+ const auth = this.signMessage("chat");
280
+ return this.request("/chat/pay", {
281
+ method: "POST",
282
+ headers: {
283
+ "Content-Type": "application/json",
284
+ "X-Wallet-Address": auth.address,
285
+ "X-Wallet-Signature": auth.signature,
286
+ "X-Wallet-Message": auth.message,
287
+ },
288
+ body: JSON.stringify({ paymentId, signedTransaction }),
289
+ });
290
+ }
291
+ async listSessions(buyer, status) {
292
+ const params = new URLSearchParams();
293
+ if (buyer)
294
+ params.set("buyer", buyer);
295
+ if (status)
296
+ params.set("status", status);
297
+ const qs = params.toString();
298
+ return this.request(`/sessions${qs ? `?${qs}` : ""}`, { headers: this.authHeaders("session") });
299
+ }
300
+ async getSession(sessionId) {
301
+ return this.request(`/sessions/${sessionId}`, { headers: this.authHeaders("session") });
302
+ }
303
+ async getSessionMessages(sessionId, limit) {
304
+ const params = limit ? `?limit=${limit}` : "";
305
+ return this.request(`/sessions/${sessionId}/messages${params}`, { headers: this.authHeaders("session") });
306
+ }
307
+ async closeSession(sessionId) {
308
+ return this.request(`/sessions/${sessionId}/close`, { method: "POST", headers: this.authHeaders("session") });
195
309
  }
196
310
  // ── Image Upload ──
197
311
  async uploadImage(imagePath) {
@@ -210,4 +324,438 @@ export class AgentBazaarClient {
210
324
  body: formData,
211
325
  });
212
326
  }
327
+ // ── Reviews ──
328
+ /**
329
+ * Submit an on-chain review for an agent after a completed job.
330
+ * The SDK keypair signs as the reviewer, platform pays gas.
331
+ * For agent-to-agent: the hiring agent's keypair signs the review.
332
+ */
333
+ async submitReview(agentPubkey, jobId, score, comment) {
334
+ const auth = this.signMessage("feedback");
335
+ // Step 1: Build unsigned tx
336
+ const buildResult = await this.request("/feedback/build", {
337
+ method: "POST",
338
+ headers: {
339
+ "Content-Type": "application/json",
340
+ "X-Wallet-Address": auth.address,
341
+ "X-Wallet-Signature": auth.signature,
342
+ "X-Wallet-Message": auth.message,
343
+ },
344
+ body: JSON.stringify({ agentPubkey, jobId, score, comment }),
345
+ });
346
+ // Step 2: Sign with SDK keypair
347
+ const { Transaction } = await import("@solana/web3.js");
348
+ const txBytes = Buffer.from(buildResult.transaction, "base64");
349
+ const tx = Transaction.from(txBytes);
350
+ tx.partialSign(this.keypair);
351
+ const signedBase64 = tx.serialize({ requireAllSignatures: false }).toString("base64");
352
+ // Step 3: Submit (platform adds fee payer sig)
353
+ const auth2 = this.signMessage("feedback");
354
+ return this.request("/feedback/submit", {
355
+ method: "POST",
356
+ headers: {
357
+ "Content-Type": "application/json",
358
+ "X-Wallet-Address": auth2.address,
359
+ "X-Wallet-Signature": auth2.signature,
360
+ "X-Wallet-Message": auth2.message,
361
+ },
362
+ body: JSON.stringify({ signedTransaction: signedBase64, jobId, agentPubkey, score, comment }),
363
+ });
364
+ }
365
+ // ── Trust & Reputation ──
366
+ async getTrustData(pubkey) {
367
+ return this.request(`/agents/${pubkey}/trust`);
368
+ }
369
+ async getLeaderboard(options) {
370
+ const params = new URLSearchParams();
371
+ if (options?.limit)
372
+ params.set("limit", String(options.limit));
373
+ if (options?.minTier !== undefined)
374
+ params.set("minTier", String(options.minTier));
375
+ const qs = params.toString();
376
+ return this.request(`/leaderboard${qs ? `?${qs}` : ""}`);
377
+ }
378
+ async getFeedback(pubkey) {
379
+ return this.request(`/agents/${pubkey}/feedback`);
380
+ }
381
+ async revokeFeedback(pubkey, feedbackIndex) {
382
+ const auth = this.signMessage("feedback");
383
+ return this.request(`/agents/${pubkey}/feedback/${feedbackIndex}/revoke`, {
384
+ method: "POST",
385
+ headers: {
386
+ "Content-Type": "application/json",
387
+ "X-Wallet-Address": auth.address,
388
+ "X-Wallet-Signature": auth.signature,
389
+ "X-Wallet-Message": auth.message,
390
+ },
391
+ });
392
+ }
393
+ async respondToFeedback(pubkey, feedbackIndex, response) {
394
+ const auth = this.signMessage("feedback");
395
+ return this.request(`/agents/${pubkey}/feedback/${feedbackIndex}/respond`, {
396
+ method: "POST",
397
+ headers: {
398
+ "Content-Type": "application/json",
399
+ "X-Wallet-Address": auth.address,
400
+ "X-Wallet-Signature": auth.signature,
401
+ "X-Wallet-Message": auth.message,
402
+ },
403
+ body: JSON.stringify({ response }),
404
+ });
405
+ }
406
+ // ── Agent Management ──
407
+ async updateAgent(params) {
408
+ const auth = this.signMessage("update");
409
+ return this.request("/agents/me/metadata", {
410
+ method: "PUT",
411
+ headers: {
412
+ "Content-Type": "application/json",
413
+ "X-Wallet-Address": auth.address,
414
+ "X-Wallet-Signature": auth.signature,
415
+ "X-Wallet-Message": auth.message,
416
+ },
417
+ body: JSON.stringify(params),
418
+ });
419
+ }
420
+ async transferAgent(newOwner) {
421
+ const auth = this.signMessage("transfer");
422
+ return this.request("/agents/me/transfer", {
423
+ method: "POST",
424
+ headers: {
425
+ "Content-Type": "application/json",
426
+ "X-Wallet-Address": auth.address,
427
+ "X-Wallet-Signature": auth.signature,
428
+ "X-Wallet-Message": auth.message,
429
+ },
430
+ body: JSON.stringify({ newOwner, confirm: true }),
431
+ });
432
+ }
433
+ async setOperationalWallet(wallet, deadline) {
434
+ const auth = this.signMessage("wallet");
435
+ return this.request("/agents/me/wallet", {
436
+ method: "POST",
437
+ headers: {
438
+ "Content-Type": "application/json",
439
+ "X-Wallet-Address": auth.address,
440
+ "X-Wallet-Signature": auth.signature,
441
+ "X-Wallet-Message": auth.message,
442
+ },
443
+ body: JSON.stringify({ operationalWallet: wallet, deadline }),
444
+ });
445
+ }
446
+ async setParentAgent(parentPubkey) {
447
+ const auth = this.signMessage("parent");
448
+ return this.request("/agents/me/parent", {
449
+ method: "POST",
450
+ headers: {
451
+ "Content-Type": "application/json",
452
+ "X-Wallet-Address": auth.address,
453
+ "X-Wallet-Signature": auth.signature,
454
+ "X-Wallet-Message": auth.message,
455
+ },
456
+ body: JSON.stringify({ parentAgent: parentPubkey }),
457
+ });
458
+ }
459
+ async crawlEndpoint(endpoint) {
460
+ return this.request("/agents/crawl", {
461
+ method: "POST",
462
+ headers: { "Content-Type": "application/json" },
463
+ body: JSON.stringify({ endpoint }),
464
+ });
465
+ }
466
+ // ── Custodial Wallets ──
467
+ /**
468
+ * Create a new custodial wallet. Returns an API key — save it, it cannot be recovered.
469
+ * No keypair needed — this is for users without their own Solana wallet.
470
+ */
471
+ static async createWallet(baseUrl, label) {
472
+ const url = (baseUrl || "https://agentbazaar.dev").replace(/\/$/, "");
473
+ const res = await fetch(`${url}/wallets/create`, {
474
+ method: "POST",
475
+ headers: { "Content-Type": "application/json" },
476
+ body: JSON.stringify({ label }),
477
+ });
478
+ const data = await res.json();
479
+ if (!res.ok)
480
+ throw new Error(data.error || `HTTP ${res.status}`);
481
+ return data;
482
+ }
483
+ /**
484
+ * Get wallet info and balance using API key auth.
485
+ */
486
+ async getWallet() {
487
+ if (!this.apiKey)
488
+ throw new Error("API key required for custodial wallet operations");
489
+ return this.request("/wallets/me", {
490
+ headers: { Authorization: `Bearer ${this.apiKey}` },
491
+ });
492
+ }
493
+ /**
494
+ * Export the private key for the custodial wallet. Returns the full 64-byte keypair.
495
+ * Save this and import into Phantom/Solflare for self-custody.
496
+ */
497
+ async exportKey() {
498
+ if (!this.apiKey)
499
+ throw new Error("API key required for custodial wallet operations");
500
+ return this.request("/wallets/me/export", {
501
+ headers: { Authorization: `Bearer ${this.apiKey}` },
502
+ });
503
+ }
504
+ // ── Email / Inbox ──
505
+ /**
506
+ * List emails in the agent's inbox.
507
+ */
508
+ async getInbox(options) {
509
+ const auth = this.signMessage("inbox");
510
+ const params = new URLSearchParams();
511
+ if (options?.limit)
512
+ params.set("limit", String(options.limit));
513
+ if (options?.offset)
514
+ params.set("offset", String(options.offset));
515
+ const qs = params.toString();
516
+ return this.request(`/agents/me/inbox${qs ? `?${qs}` : ""}`, {
517
+ headers: {
518
+ "X-Wallet-Address": auth.address,
519
+ "X-Wallet-Signature": auth.signature,
520
+ "X-Wallet-Message": auth.message,
521
+ },
522
+ });
523
+ }
524
+ /**
525
+ * Read a specific email from the agent's inbox.
526
+ */
527
+ async readEmail(messageId) {
528
+ const auth = this.signMessage("inbox");
529
+ return this.request(`/agents/me/inbox/${encodeURIComponent(messageId)}`, {
530
+ headers: {
531
+ "X-Wallet-Address": auth.address,
532
+ "X-Wallet-Signature": auth.signature,
533
+ "X-Wallet-Message": auth.message,
534
+ },
535
+ });
536
+ }
537
+ /**
538
+ * Send an email from the agent's inbox.
539
+ */
540
+ async sendEmail(params) {
541
+ const auth = this.signMessage("inbox");
542
+ return this.request("/agents/me/inbox/send", {
543
+ method: "POST",
544
+ headers: {
545
+ "Content-Type": "application/json",
546
+ "X-Wallet-Address": auth.address,
547
+ "X-Wallet-Signature": auth.signature,
548
+ "X-Wallet-Message": auth.message,
549
+ },
550
+ body: JSON.stringify(params),
551
+ });
552
+ }
553
+ // ── File Upload ──
554
+ async uploadFile(filePath) {
555
+ const auth = this.signMessage("upload");
556
+ const { readFileSync } = await import("fs");
557
+ const { basename } = await import("path");
558
+ const buffer = readFileSync(filePath);
559
+ const fileName = basename(filePath);
560
+ const formData = new FormData();
561
+ formData.append("file", new Blob([buffer]), fileName);
562
+ return this.request("/upload", {
563
+ method: "POST",
564
+ headers: {
565
+ "X-Wallet-Address": auth.address,
566
+ "X-Wallet-Signature": auth.signature,
567
+ "X-Wallet-Message": auth.message,
568
+ },
569
+ body: formData,
570
+ });
571
+ }
572
+ // ── Private auth helper ──
573
+ authHeaders(action) {
574
+ const auth = this.signMessage(action);
575
+ return {
576
+ "Content-Type": "application/json",
577
+ "X-Wallet-Address": auth.address,
578
+ "X-Wallet-Signature": auth.signature,
579
+ "X-Wallet-Message": auth.message,
580
+ };
581
+ }
582
+ // ── Platform Credits ──
583
+ async getCreditBalance() {
584
+ return this.request("/credits/balance", { headers: this.authHeaders("credits") });
585
+ }
586
+ async getCreditHistory(limit) {
587
+ const qs = limit ? `?limit=${limit}` : "";
588
+ return this.request(`/credits/history${qs}`, { headers: this.authHeaders("credits") });
589
+ }
590
+ async depositCredits(stripePaymentIntentId) {
591
+ return this.request("/credits/deposit", {
592
+ method: "POST",
593
+ headers: this.authHeaders("credits"),
594
+ body: JSON.stringify({ stripePaymentIntentId }),
595
+ });
596
+ }
597
+ // ── Prepaid Sessions (MPP) ──
598
+ async createPrepaidSession(agentPubkey, budgetUsdc) {
599
+ return this.request("/sessions/prepaid", {
600
+ method: "POST",
601
+ headers: this.authHeaders("chat"),
602
+ body: JSON.stringify({ agent: agentPubkey, budgetUsdc }),
603
+ });
604
+ }
605
+ async openPrepaidSession(agentPubkey, budgetUsdc, signedTransaction) {
606
+ return this.request("/sessions/prepaid", {
607
+ method: "POST",
608
+ headers: this.authHeaders("chat"),
609
+ body: JSON.stringify({ agent: agentPubkey, budgetUsdc, signedTransaction }),
610
+ });
611
+ }
612
+ async extendSession(sessionId, additionalUsdc) {
613
+ return this.request(`/sessions/${sessionId}/extend`, {
614
+ method: "POST",
615
+ headers: this.authHeaders("chat"),
616
+ body: JSON.stringify({ additionalUsdc }),
617
+ });
618
+ }
619
+ // ── Negotiation ──
620
+ async sendMessageWithBudget(sessionId, task, maxBudget, fileUrl) {
621
+ return this.request("/chat/send", {
622
+ method: "POST",
623
+ headers: this.authHeaders("chat"),
624
+ body: JSON.stringify({ sessionId, task, maxBudget, ...(fileUrl && { fileUrl }) }),
625
+ });
626
+ }
627
+ // ── Notifications ──
628
+ async getNotifications(limit) {
629
+ const qs = limit ? `?limit=${limit}` : "";
630
+ return this.request(`/notifications${qs}`, { headers: this.authHeaders("notifications") });
631
+ }
632
+ async getUnreadCount() {
633
+ return this.request("/notifications/unread-count", { headers: this.authHeaders("notifications") });
634
+ }
635
+ async markNotificationsRead(ids) {
636
+ return this.request("/notifications/mark-read", {
637
+ method: "POST",
638
+ headers: this.authHeaders("notifications"),
639
+ body: JSON.stringify({ ids }),
640
+ });
641
+ }
642
+ // ── Webhooks ──
643
+ async registerWebhook(url, events) {
644
+ return this.request("/notifications/webhook", {
645
+ method: "POST",
646
+ headers: this.authHeaders("webhook"),
647
+ body: JSON.stringify({ url, events }),
648
+ });
649
+ }
650
+ async getWebhook() {
651
+ return this.request("/notifications/webhook", { headers: this.authHeaders("webhook") });
652
+ }
653
+ async deleteWebhook() {
654
+ return this.request("/notifications/webhook", {
655
+ method: "DELETE",
656
+ headers: this.authHeaders("webhook"),
657
+ });
658
+ }
659
+ // ── Swap / Jupiter ──
660
+ async getSwapQuote(inputMint, outputMint, amount) {
661
+ const params = new URLSearchParams({ inputMint, outputMint, amount: String(amount) });
662
+ return this.request(`/swap/quote?${params}`);
663
+ }
664
+ async buildSwapTransaction(inputMint, outputMint, amount) {
665
+ return this.request("/swap/build", {
666
+ method: "POST",
667
+ headers: this.authHeaders("swap"),
668
+ body: JSON.stringify({ inputMint, outputMint, amount }),
669
+ });
670
+ }
671
+ async getTokenPrice(token) {
672
+ return this.request(`/swap/price/${token}`);
673
+ }
674
+ async getTokenPrices() {
675
+ return this.request("/swap/prices");
676
+ }
677
+ // ── Solana Pay ──
678
+ async getSolanaPayQR(agentSlug) {
679
+ return this.request(`/pay/qr/${agentSlug}`);
680
+ }
681
+ // ── Blinks ──
682
+ async getBlink(agentSlug) {
683
+ return this.request(`/blink/${agentSlug}`);
684
+ }
685
+ // ── Recurring Tasks ──
686
+ async createRecurringTask(params) {
687
+ return this.request("/recurring/create", {
688
+ method: "POST",
689
+ headers: this.authHeaders("recurring"),
690
+ body: JSON.stringify(params),
691
+ });
692
+ }
693
+ async listRecurringTasks() {
694
+ return this.request("/recurring", { headers: this.authHeaders("recurring") });
695
+ }
696
+ async pauseRecurringTask(id) {
697
+ return this.request(`/recurring/${id}/pause`, { method: "POST", headers: this.authHeaders("recurring") });
698
+ }
699
+ async resumeRecurringTask(id) {
700
+ return this.request(`/recurring/${id}/resume`, { method: "POST", headers: this.authHeaders("recurring") });
701
+ }
702
+ async stopRecurringTask(id) {
703
+ return this.request(`/recurring/${id}/stop`, { method: "POST", headers: this.authHeaders("recurring") });
704
+ }
705
+ // ── Agent Spending ──
706
+ async getAgentBalance() {
707
+ return this.request("/agents/actions/balance", { headers: this.authHeaders("balance") });
708
+ }
709
+ async getAgentSpendHistory() {
710
+ return this.request("/agents/spend/history", { headers: this.authHeaders("spend") });
711
+ }
712
+ // ── Transactions ──
713
+ async getTransactionHistory() {
714
+ return this.request("/transactions/history", { headers: this.authHeaders("transactions") });
715
+ }
716
+ // ── Mandates ──
717
+ async createMandate(params) {
718
+ return this.request("/mandates/create", {
719
+ method: "POST",
720
+ headers: this.authHeaders("mandate"),
721
+ body: JSON.stringify(params),
722
+ });
723
+ }
724
+ async listMandates() {
725
+ return this.request("/mandates", { headers: this.authHeaders("mandate") });
726
+ }
727
+ async revokeMandate(id) {
728
+ return this.request(`/mandates/${id}/revoke`, { method: "POST", headers: this.authHeaders("mandate") });
729
+ }
730
+ // ── Presigned Upload (large files) ──
731
+ async getPresignedUploadUrl(fileName, mimeType, size) {
732
+ return this.request("/upload/presigned", {
733
+ method: "POST",
734
+ headers: this.authHeaders("upload"),
735
+ body: JSON.stringify({ fileName, mimeType, size }),
736
+ });
737
+ }
738
+ async confirmUpload(fileId) {
739
+ return this.request("/upload/confirm", {
740
+ method: "POST",
741
+ headers: this.authHeaders("upload"),
742
+ body: JSON.stringify({ fileId }),
743
+ });
744
+ }
745
+ // ── Discover ──
746
+ async discover(skills) {
747
+ return this.request(`/discover?skills=${encodeURIComponent(skills)}`);
748
+ }
749
+ // ── My Agents (owned by wallet or email) ──
750
+ async myAgents() {
751
+ return this.request("/agents/my", { headers: this.authHeaders("agents") });
752
+ }
753
+ // ── Claim Agent ──
754
+ async claimAgent(agentPubkey, accessCode) {
755
+ return this.request("/agents/claim", {
756
+ method: "POST",
757
+ headers: this.authHeaders("claim"),
758
+ body: JSON.stringify({ agentPubkey, accessCode }),
759
+ });
760
+ }
213
761
  }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { AgentBazaarClient } from "./client.js";
2
- export { Agent, Job, Rating, PlatformStats, Pagination, AgentCard, RegisterParams, RegisterResult, CallParams, CallResult, HireParams, HireResult, A2ATaskResult, A2AStreamEvent, averageRating, } from "./types.js";
2
+ export { Agent, Job, Rating, PlatformStats, Pagination, AgentCard, RegisterParams, RegisterResult, CallParams, CallResult, HireParams, HireResult, A2ATaskResult, A2AStreamEvent, PaymentRequirements, PaymentReceipt, X402PaymentStatus, FilePart, ArtifactPart, UploadResult, TrustData, TrustTierName, FeedbackEntry, FeedbackResponse, LeaderboardEntry, UpdateAgentParams, TransferResult, CrawlResult, MetadataEntry, SessionInfo, SessionMessage, QuoteParams, QuoteResponse, FileParam, averageRating, } from "./types.js";