@clawdvault/sdk 0.3.2 → 0.4.1

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.js CHANGED
@@ -586,10 +586,19 @@ var ClawdVaultClient = class {
586
586
  */
587
587
  async uploadImage(file, filename = "image.png") {
588
588
  const formData = new FormData();
589
+ const extMap = {
590
+ ".png": "image/png",
591
+ ".jpg": "image/jpeg",
592
+ ".jpeg": "image/jpeg",
593
+ ".gif": "image/gif",
594
+ ".webp": "image/webp"
595
+ };
596
+ const ext = "." + (filename.split(".").pop()?.toLowerCase() ?? "png");
597
+ const mimeType = extMap[ext] || "image/png";
589
598
  if (file instanceof Blob) {
590
599
  formData.append("file", file, filename);
591
600
  } else {
592
- const blob = new Blob([file]);
601
+ const blob = new Blob([file], { type: mimeType });
593
602
  formData.append("file", blob, filename);
594
603
  }
595
604
  return this.request("POST", "/upload", { formData });
@@ -604,6 +613,76 @@ var ClawdVaultClient = class {
604
613
  const filename = path.basename(filePath);
605
614
  return this.uploadImage(buffer, filename);
606
615
  }
616
+ // ============ Agent Operations ============
617
+ /**
618
+ * Register a new agent
619
+ */
620
+ async registerAgent(params) {
621
+ return this.request("POST", "/agent/register", { body: params });
622
+ }
623
+ /**
624
+ * Verify agent via Twitter claim
625
+ */
626
+ async claimAgent(params) {
627
+ return this.request("POST", "/agent/claim", { body: params });
628
+ }
629
+ /**
630
+ * List agents (leaderboard)
631
+ */
632
+ async listAgents(params = {}) {
633
+ return this.request("GET", "/agents", { params });
634
+ }
635
+ /**
636
+ * List users (leaderboard)
637
+ */
638
+ async listUsers(params = {}) {
639
+ return this.request("GET", "/users", { params });
640
+ }
641
+ /**
642
+ * Get site-wide stats
643
+ */
644
+ async getSiteStats() {
645
+ return this.request("GET", "/site-stats");
646
+ }
647
+ /**
648
+ * Upload avatar image for an agent
649
+ * Requires API key authentication
650
+ */
651
+ async uploadAvatar(file, wallet, apiKey, filename = "avatar.png") {
652
+ const formData = new FormData();
653
+ const extMap = {
654
+ ".png": "image/png",
655
+ ".jpg": "image/jpeg",
656
+ ".jpeg": "image/jpeg",
657
+ ".gif": "image/gif",
658
+ ".webp": "image/webp"
659
+ };
660
+ const ext = "." + (filename.split(".").pop()?.toLowerCase() ?? "png");
661
+ const mimeType = extMap[ext] || "image/png";
662
+ if (file instanceof Blob) {
663
+ formData.append("file", file, filename);
664
+ } else {
665
+ const blob = new Blob([file], { type: mimeType });
666
+ formData.append("file", blob, filename);
667
+ }
668
+ formData.append("type", "avatar");
669
+ formData.append("wallet", wallet);
670
+ const url = `${this.baseUrl}/upload`;
671
+ const response = await fetch(url, {
672
+ method: "POST",
673
+ headers: { "Authorization": `Bearer ${apiKey}` },
674
+ body: formData
675
+ });
676
+ if (!response.ok) {
677
+ const error = await response.json().catch(() => ({ error: response.statusText }));
678
+ const err = new Error(error.error || error.message || `HTTP ${response.status}`);
679
+ err.status = response.status;
680
+ err.response = error;
681
+ this.onError?.(err);
682
+ throw err;
683
+ }
684
+ return response.json();
685
+ }
607
686
  // ============ Network ============
608
687
  /**
609
688
  * Get network status
package/dist/index.mjs CHANGED
@@ -562,10 +562,19 @@ var ClawdVaultClient = class {
562
562
  */
563
563
  async uploadImage(file, filename = "image.png") {
564
564
  const formData = new FormData();
565
+ const extMap = {
566
+ ".png": "image/png",
567
+ ".jpg": "image/jpeg",
568
+ ".jpeg": "image/jpeg",
569
+ ".gif": "image/gif",
570
+ ".webp": "image/webp"
571
+ };
572
+ const ext = "." + (filename.split(".").pop()?.toLowerCase() ?? "png");
573
+ const mimeType = extMap[ext] || "image/png";
565
574
  if (file instanceof Blob) {
566
575
  formData.append("file", file, filename);
567
576
  } else {
568
- const blob = new Blob([file]);
577
+ const blob = new Blob([file], { type: mimeType });
569
578
  formData.append("file", blob, filename);
570
579
  }
571
580
  return this.request("POST", "/upload", { formData });
@@ -580,6 +589,76 @@ var ClawdVaultClient = class {
580
589
  const filename = path.basename(filePath);
581
590
  return this.uploadImage(buffer, filename);
582
591
  }
592
+ // ============ Agent Operations ============
593
+ /**
594
+ * Register a new agent
595
+ */
596
+ async registerAgent(params) {
597
+ return this.request("POST", "/agent/register", { body: params });
598
+ }
599
+ /**
600
+ * Verify agent via Twitter claim
601
+ */
602
+ async claimAgent(params) {
603
+ return this.request("POST", "/agent/claim", { body: params });
604
+ }
605
+ /**
606
+ * List agents (leaderboard)
607
+ */
608
+ async listAgents(params = {}) {
609
+ return this.request("GET", "/agents", { params });
610
+ }
611
+ /**
612
+ * List users (leaderboard)
613
+ */
614
+ async listUsers(params = {}) {
615
+ return this.request("GET", "/users", { params });
616
+ }
617
+ /**
618
+ * Get site-wide stats
619
+ */
620
+ async getSiteStats() {
621
+ return this.request("GET", "/site-stats");
622
+ }
623
+ /**
624
+ * Upload avatar image for an agent
625
+ * Requires API key authentication
626
+ */
627
+ async uploadAvatar(file, wallet, apiKey, filename = "avatar.png") {
628
+ const formData = new FormData();
629
+ const extMap = {
630
+ ".png": "image/png",
631
+ ".jpg": "image/jpeg",
632
+ ".jpeg": "image/jpeg",
633
+ ".gif": "image/gif",
634
+ ".webp": "image/webp"
635
+ };
636
+ const ext = "." + (filename.split(".").pop()?.toLowerCase() ?? "png");
637
+ const mimeType = extMap[ext] || "image/png";
638
+ if (file instanceof Blob) {
639
+ formData.append("file", file, filename);
640
+ } else {
641
+ const blob = new Blob([file], { type: mimeType });
642
+ formData.append("file", blob, filename);
643
+ }
644
+ formData.append("type", "avatar");
645
+ formData.append("wallet", wallet);
646
+ const url = `${this.baseUrl}/upload`;
647
+ const response = await fetch(url, {
648
+ method: "POST",
649
+ headers: { "Authorization": `Bearer ${apiKey}` },
650
+ body: formData
651
+ });
652
+ if (!response.ok) {
653
+ const error = await response.json().catch(() => ({ error: response.statusText }));
654
+ const err = new Error(error.error || error.message || `HTTP ${response.status}`);
655
+ err.status = response.status;
656
+ err.response = error;
657
+ this.onError?.(err);
658
+ throw err;
659
+ }
660
+ return response.json();
661
+ }
583
662
  // ============ Network ============
584
663
  /**
585
664
  * Get network status
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawdvault/sdk",
3
- "version": "0.3.2",
3
+ "version": "0.4.1",
4
4
  "description": "TypeScript SDK for ClawdVault - Solana token launchpad",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",