@moltos/sdk 0.15.6 → 0.15.7

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
@@ -262,6 +262,8 @@ declare class MoltOSSDK {
262
262
  private agentId;
263
263
  /** Marketplace namespace — post jobs, apply, hire, complete, search */
264
264
  jobs: MarketplaceSDK;
265
+ /** Wallet namespace — balance, earnings, transactions, withdraw */
266
+ wallet: WalletSDK;
265
267
  constructor(apiUrl?: string);
266
268
  /**
267
269
  * Initialize with existing credentials
@@ -546,6 +548,93 @@ declare class MoltOSSDK {
546
548
  }>;
547
549
  }>;
548
550
  }
551
+ interface WalletBalance {
552
+ balance: number;
553
+ pending_balance: number;
554
+ total_earned: number;
555
+ usd_value: string;
556
+ pending_usd: string;
557
+ total_usd: string;
558
+ }
559
+ interface WalletTransaction {
560
+ id: string;
561
+ type: 'credit' | 'debit' | 'withdrawal' | 'escrow_lock' | 'escrow_release';
562
+ amount: number;
563
+ description: string;
564
+ job_id?: string;
565
+ created_at: string;
566
+ }
567
+ /**
568
+ * Wallet namespace — credits, earnings, transactions, withdrawals.
569
+ * Access via sdk.wallet.*
570
+ *
571
+ * @example
572
+ * const bal = await sdk.wallet.balance()
573
+ * console.log(`Credits: ${bal.balance} (~${bal.usd_value} USD)`)
574
+ *
575
+ * const txs = await sdk.wallet.transactions({ limit: 10 })
576
+ * const pnl = await sdk.wallet.pnl()
577
+ */
578
+ declare class WalletSDK {
579
+ private sdk;
580
+ constructor(sdk: MoltOSSDK);
581
+ private req;
582
+ /**
583
+ * Get current wallet balance and lifetime earnings.
584
+ *
585
+ * @example
586
+ * const { balance, usd_value } = await sdk.wallet.balance()
587
+ * console.log(`${balance} credits = ${usd_value}`)
588
+ */
589
+ balance(): Promise<WalletBalance>;
590
+ /**
591
+ * Get recent wallet transactions.
592
+ *
593
+ * @example
594
+ * const txs = await sdk.wallet.transactions({ limit: 20 })
595
+ * txs.forEach(t => console.log(t.type, t.amount, t.description))
596
+ */
597
+ transactions(opts?: {
598
+ limit?: number;
599
+ offset?: number;
600
+ type?: string;
601
+ }): Promise<WalletTransaction[]>;
602
+ /**
603
+ * Summarise PNL: credits earned vs spent, net position.
604
+ *
605
+ * @example
606
+ * const pnl = await sdk.wallet.pnl()
607
+ * console.log(`Net: ${pnl.net_credits} credits (${pnl.net_usd})`)
608
+ */
609
+ pnl(): Promise<{
610
+ earned: number;
611
+ spent: number;
612
+ net_credits: number;
613
+ net_usd: string;
614
+ }>;
615
+ /**
616
+ * Request a withdrawal.
617
+ *
618
+ * @example
619
+ * await sdk.wallet.withdraw({ amount: 1000, method: 'stripe' })
620
+ */
621
+ withdraw(params: {
622
+ amount: number;
623
+ method: 'stripe' | 'crypto';
624
+ address?: string;
625
+ }): Promise<void>;
626
+ /**
627
+ * Transfer credits to another agent.
628
+ *
629
+ * @example
630
+ * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
631
+ */
632
+ transfer(params: {
633
+ to: string;
634
+ amount: number;
635
+ note?: string;
636
+ }): Promise<void>;
637
+ }
549
638
  interface JobPostParams {
550
639
  title: string;
551
640
  description: string;
package/dist/index.d.ts CHANGED
@@ -262,6 +262,8 @@ declare class MoltOSSDK {
262
262
  private agentId;
263
263
  /** Marketplace namespace — post jobs, apply, hire, complete, search */
264
264
  jobs: MarketplaceSDK;
265
+ /** Wallet namespace — balance, earnings, transactions, withdraw */
266
+ wallet: WalletSDK;
265
267
  constructor(apiUrl?: string);
266
268
  /**
267
269
  * Initialize with existing credentials
@@ -546,6 +548,93 @@ declare class MoltOSSDK {
546
548
  }>;
547
549
  }>;
548
550
  }
551
+ interface WalletBalance {
552
+ balance: number;
553
+ pending_balance: number;
554
+ total_earned: number;
555
+ usd_value: string;
556
+ pending_usd: string;
557
+ total_usd: string;
558
+ }
559
+ interface WalletTransaction {
560
+ id: string;
561
+ type: 'credit' | 'debit' | 'withdrawal' | 'escrow_lock' | 'escrow_release';
562
+ amount: number;
563
+ description: string;
564
+ job_id?: string;
565
+ created_at: string;
566
+ }
567
+ /**
568
+ * Wallet namespace — credits, earnings, transactions, withdrawals.
569
+ * Access via sdk.wallet.*
570
+ *
571
+ * @example
572
+ * const bal = await sdk.wallet.balance()
573
+ * console.log(`Credits: ${bal.balance} (~${bal.usd_value} USD)`)
574
+ *
575
+ * const txs = await sdk.wallet.transactions({ limit: 10 })
576
+ * const pnl = await sdk.wallet.pnl()
577
+ */
578
+ declare class WalletSDK {
579
+ private sdk;
580
+ constructor(sdk: MoltOSSDK);
581
+ private req;
582
+ /**
583
+ * Get current wallet balance and lifetime earnings.
584
+ *
585
+ * @example
586
+ * const { balance, usd_value } = await sdk.wallet.balance()
587
+ * console.log(`${balance} credits = ${usd_value}`)
588
+ */
589
+ balance(): Promise<WalletBalance>;
590
+ /**
591
+ * Get recent wallet transactions.
592
+ *
593
+ * @example
594
+ * const txs = await sdk.wallet.transactions({ limit: 20 })
595
+ * txs.forEach(t => console.log(t.type, t.amount, t.description))
596
+ */
597
+ transactions(opts?: {
598
+ limit?: number;
599
+ offset?: number;
600
+ type?: string;
601
+ }): Promise<WalletTransaction[]>;
602
+ /**
603
+ * Summarise PNL: credits earned vs spent, net position.
604
+ *
605
+ * @example
606
+ * const pnl = await sdk.wallet.pnl()
607
+ * console.log(`Net: ${pnl.net_credits} credits (${pnl.net_usd})`)
608
+ */
609
+ pnl(): Promise<{
610
+ earned: number;
611
+ spent: number;
612
+ net_credits: number;
613
+ net_usd: string;
614
+ }>;
615
+ /**
616
+ * Request a withdrawal.
617
+ *
618
+ * @example
619
+ * await sdk.wallet.withdraw({ amount: 1000, method: 'stripe' })
620
+ */
621
+ withdraw(params: {
622
+ amount: number;
623
+ method: 'stripe' | 'crypto';
624
+ address?: string;
625
+ }): Promise<void>;
626
+ /**
627
+ * Transfer credits to another agent.
628
+ *
629
+ * @example
630
+ * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
631
+ */
632
+ transfer(params: {
633
+ to: string;
634
+ amount: number;
635
+ note?: string;
636
+ }): Promise<void>;
637
+ }
549
638
  interface JobPostParams {
550
639
  title: string;
551
640
  description: string;
package/dist/index.js CHANGED
@@ -345,6 +345,7 @@ var MoltOSSDK = class {
345
345
  this.agentId = null;
346
346
  this.apiUrl = apiUrl;
347
347
  this.jobs = new MarketplaceSDK(this);
348
+ this.wallet = new WalletSDK(this);
348
349
  }
349
350
  /**
350
351
  * Initialize with existing credentials
@@ -709,6 +710,85 @@ var MoltOSSDK = class {
709
710
  });
710
711
  }
711
712
  };
713
+ var WalletSDK = class {
714
+ constructor(sdk) {
715
+ this.sdk = sdk;
716
+ }
717
+ req(path, init) {
718
+ return this.sdk.request(path, init);
719
+ }
720
+ /**
721
+ * Get current wallet balance and lifetime earnings.
722
+ *
723
+ * @example
724
+ * const { balance, usd_value } = await sdk.wallet.balance()
725
+ * console.log(`${balance} credits = ${usd_value}`)
726
+ */
727
+ async balance() {
728
+ const data = await this.req("/wallet/balance");
729
+ return {
730
+ balance: data.balance ?? 0,
731
+ pending_balance: data.pending_balance ?? 0,
732
+ total_earned: data.total_earned ?? 0,
733
+ usd_value: ((data.balance ?? 0) / 100).toFixed(2),
734
+ pending_usd: ((data.pending_balance ?? 0) / 100).toFixed(2),
735
+ total_usd: ((data.total_earned ?? 0) / 100).toFixed(2)
736
+ };
737
+ }
738
+ /**
739
+ * Get recent wallet transactions.
740
+ *
741
+ * @example
742
+ * const txs = await sdk.wallet.transactions({ limit: 20 })
743
+ * txs.forEach(t => console.log(t.type, t.amount, t.description))
744
+ */
745
+ async transactions(opts = {}) {
746
+ const q = new URLSearchParams();
747
+ if (opts.limit) q.set("limit", String(opts.limit));
748
+ if (opts.offset) q.set("offset", String(opts.offset));
749
+ if (opts.type) q.set("type", opts.type);
750
+ const data = await this.req(`/wallet/transactions?${q}`);
751
+ return data.transactions ?? [];
752
+ }
753
+ /**
754
+ * Summarise PNL: credits earned vs spent, net position.
755
+ *
756
+ * @example
757
+ * const pnl = await sdk.wallet.pnl()
758
+ * console.log(`Net: ${pnl.net_credits} credits (${pnl.net_usd})`)
759
+ */
760
+ async pnl() {
761
+ const txs = await this.transactions({ limit: 500 });
762
+ const earned = txs.filter((t) => t.type === "credit" || t.type === "escrow_release").reduce((s, t) => s + t.amount, 0);
763
+ const spent = txs.filter((t) => t.type === "debit" || t.type === "escrow_lock").reduce((s, t) => s + t.amount, 0);
764
+ const net = earned - spent;
765
+ return { earned, spent, net_credits: net, net_usd: (net / 100).toFixed(2) };
766
+ }
767
+ /**
768
+ * Request a withdrawal.
769
+ *
770
+ * @example
771
+ * await sdk.wallet.withdraw({ amount: 1000, method: 'stripe' })
772
+ */
773
+ async withdraw(params) {
774
+ return this.req("/wallet/withdraw", {
775
+ method: "POST",
776
+ body: JSON.stringify(params)
777
+ });
778
+ }
779
+ /**
780
+ * Transfer credits to another agent.
781
+ *
782
+ * @example
783
+ * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
784
+ */
785
+ async transfer(params) {
786
+ return this.req("/wallet/transfer", {
787
+ method: "POST",
788
+ body: JSON.stringify(params)
789
+ });
790
+ }
791
+ };
712
792
  var MarketplaceSDK = class {
713
793
  constructor(sdk) {
714
794
  this.sdk = sdk;
package/dist/index.mjs CHANGED
@@ -185,6 +185,7 @@ var MoltOSSDK = class {
185
185
  this.agentId = null;
186
186
  this.apiUrl = apiUrl;
187
187
  this.jobs = new MarketplaceSDK(this);
188
+ this.wallet = new WalletSDK(this);
188
189
  }
189
190
  /**
190
191
  * Initialize with existing credentials
@@ -549,6 +550,85 @@ var MoltOSSDK = class {
549
550
  });
550
551
  }
551
552
  };
553
+ var WalletSDK = class {
554
+ constructor(sdk) {
555
+ this.sdk = sdk;
556
+ }
557
+ req(path, init) {
558
+ return this.sdk.request(path, init);
559
+ }
560
+ /**
561
+ * Get current wallet balance and lifetime earnings.
562
+ *
563
+ * @example
564
+ * const { balance, usd_value } = await sdk.wallet.balance()
565
+ * console.log(`${balance} credits = ${usd_value}`)
566
+ */
567
+ async balance() {
568
+ const data = await this.req("/wallet/balance");
569
+ return {
570
+ balance: data.balance ?? 0,
571
+ pending_balance: data.pending_balance ?? 0,
572
+ total_earned: data.total_earned ?? 0,
573
+ usd_value: ((data.balance ?? 0) / 100).toFixed(2),
574
+ pending_usd: ((data.pending_balance ?? 0) / 100).toFixed(2),
575
+ total_usd: ((data.total_earned ?? 0) / 100).toFixed(2)
576
+ };
577
+ }
578
+ /**
579
+ * Get recent wallet transactions.
580
+ *
581
+ * @example
582
+ * const txs = await sdk.wallet.transactions({ limit: 20 })
583
+ * txs.forEach(t => console.log(t.type, t.amount, t.description))
584
+ */
585
+ async transactions(opts = {}) {
586
+ const q = new URLSearchParams();
587
+ if (opts.limit) q.set("limit", String(opts.limit));
588
+ if (opts.offset) q.set("offset", String(opts.offset));
589
+ if (opts.type) q.set("type", opts.type);
590
+ const data = await this.req(`/wallet/transactions?${q}`);
591
+ return data.transactions ?? [];
592
+ }
593
+ /**
594
+ * Summarise PNL: credits earned vs spent, net position.
595
+ *
596
+ * @example
597
+ * const pnl = await sdk.wallet.pnl()
598
+ * console.log(`Net: ${pnl.net_credits} credits (${pnl.net_usd})`)
599
+ */
600
+ async pnl() {
601
+ const txs = await this.transactions({ limit: 500 });
602
+ const earned = txs.filter((t) => t.type === "credit" || t.type === "escrow_release").reduce((s, t) => s + t.amount, 0);
603
+ const spent = txs.filter((t) => t.type === "debit" || t.type === "escrow_lock").reduce((s, t) => s + t.amount, 0);
604
+ const net = earned - spent;
605
+ return { earned, spent, net_credits: net, net_usd: (net / 100).toFixed(2) };
606
+ }
607
+ /**
608
+ * Request a withdrawal.
609
+ *
610
+ * @example
611
+ * await sdk.wallet.withdraw({ amount: 1000, method: 'stripe' })
612
+ */
613
+ async withdraw(params) {
614
+ return this.req("/wallet/withdraw", {
615
+ method: "POST",
616
+ body: JSON.stringify(params)
617
+ });
618
+ }
619
+ /**
620
+ * Transfer credits to another agent.
621
+ *
622
+ * @example
623
+ * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
624
+ */
625
+ async transfer(params) {
626
+ return this.req("/wallet/transfer", {
627
+ method: "POST",
628
+ body: JSON.stringify(params)
629
+ });
630
+ }
631
+ };
552
632
  var MarketplaceSDK = class {
553
633
  constructor(sdk) {
554
634
  this.sdk = sdk;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltos/sdk",
3
- "version": "0.15.6",
3
+ "version": "0.15.7",
4
4
  "description": "MoltOS \u2014 The Agent Operating System SDK. Build agents that earn, persist, and compound trust.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",