kompass-sdk 0.2.1 → 0.4.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.
Files changed (54) hide show
  1. package/dist/cli.js +36 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/wallet/bridge.d.ts +41 -0
  4. package/dist/wallet/bridge.d.ts.map +1 -0
  5. package/dist/wallet/bridge.js +121 -0
  6. package/dist/wallet/bridge.js.map +1 -0
  7. package/dist/wallet/handlers/acp.d.ts +16 -0
  8. package/dist/wallet/handlers/acp.d.ts.map +1 -0
  9. package/dist/wallet/handlers/acp.js +78 -0
  10. package/dist/wallet/handlers/acp.js.map +1 -0
  11. package/dist/wallet/handlers/free.d.ts +10 -0
  12. package/dist/wallet/handlers/free.d.ts.map +1 -0
  13. package/dist/wallet/handlers/free.js +25 -0
  14. package/dist/wallet/handlers/free.js.map +1 -0
  15. package/dist/wallet/handlers/l402.d.ts +13 -0
  16. package/dist/wallet/handlers/l402.d.ts.map +1 -0
  17. package/dist/wallet/handlers/l402.js +94 -0
  18. package/dist/wallet/handlers/l402.js.map +1 -0
  19. package/dist/wallet/handlers/mpp.d.ts +21 -0
  20. package/dist/wallet/handlers/mpp.d.ts.map +1 -0
  21. package/dist/wallet/handlers/mpp.js +78 -0
  22. package/dist/wallet/handlers/mpp.js.map +1 -0
  23. package/dist/wallet/handlers/nanopayments.d.ts +25 -0
  24. package/dist/wallet/handlers/nanopayments.d.ts.map +1 -0
  25. package/dist/wallet/handlers/nanopayments.js +24 -0
  26. package/dist/wallet/handlers/nanopayments.js.map +1 -0
  27. package/dist/wallet/handlers/x402.d.ts +13 -0
  28. package/dist/wallet/handlers/x402.d.ts.map +1 -0
  29. package/dist/wallet/handlers/x402.js +48 -0
  30. package/dist/wallet/handlers/x402.js.map +1 -0
  31. package/dist/wallet/index.d.ts +9393 -0
  32. package/dist/wallet/index.d.ts.map +1 -0
  33. package/dist/wallet/index.js +136 -0
  34. package/dist/wallet/index.js.map +1 -0
  35. package/dist/wallet/keystore.d.ts +26 -0
  36. package/dist/wallet/keystore.d.ts.map +1 -0
  37. package/dist/wallet/keystore.js +48 -0
  38. package/dist/wallet/keystore.js.map +1 -0
  39. package/dist/wallet/payment-router.d.ts +20 -0
  40. package/dist/wallet/payment-router.d.ts.map +1 -0
  41. package/dist/wallet/payment-router.js +92 -0
  42. package/dist/wallet/payment-router.js.map +1 -0
  43. package/package.json +4 -1
  44. package/src/cli.ts +40 -0
  45. package/src/wallet/bridge.ts +164 -0
  46. package/src/wallet/handlers/acp.ts +98 -0
  47. package/src/wallet/handlers/free.ts +28 -0
  48. package/src/wallet/handlers/l402.ts +120 -0
  49. package/src/wallet/handlers/mpp.ts +91 -0
  50. package/src/wallet/handlers/nanopayments.ts +31 -0
  51. package/src/wallet/handlers/x402.ts +58 -0
  52. package/src/wallet/index.ts +161 -0
  53. package/src/wallet/keystore.ts +70 -0
  54. package/src/wallet/payment-router.ts +116 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA0E,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAsBtH,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,OAAO,CAAyC;IACxD,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,YAAY,CAAwC;IAE5D,OAAO;IAaP;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,aAAa;IAsB/G;;OAEG;IACH,MAAM,CAAC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AAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAAs0N,CAAC;uBAA6D,CAAC;uBAA6D,CAAC;sBAAyD,CAAC;;;;;;;;;;;;;;;;;;;;;;;kCAAynE,CAAC;yBAA2D,CAAC;kCAA6F,CAAC;;sCAA2F,CAAC;8BAAqD,CAAC;0BAAiD,CAAC;;;;yBAA+K,CAAC;4BAA4B,CAAC;;;;wBAA6I,CAAC;;;;;;;;;;;;;;;;IApDpq8B,0CAA0C;IAC1C,aAAa,IAAI,GAAG;IAIpB,uBAAuB;IACvB,UAAU,IAAI,MAAM;IAIpB,+BAA+B;IACzB,UAAU,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAyB9H,2CAA2C;IACrC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAclE"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Kompass Wallet
3
+ * Self-custody spending wallet for agents.
4
+ * One wallet, every payment protocol (x402, L402, ACP, MPP, Circle).
5
+ * Kompass NEVER holds keys or funds.
6
+ */
7
+ import { createPublicClient, createWalletClient, http, formatUnits, formatEther } from "viem";
8
+ import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
9
+ import { baseSepolia, base } from "viem/chains";
10
+ import { encryptKey, decryptKey, saveKeystore, loadKeystore } from "./keystore.js";
11
+ import { homedir } from "os";
12
+ import { join } from "path";
13
+ const DEFAULT_WALLET_PATH = join(homedir(), ".kompass", "wallet.json");
14
+ const DEFAULT_PASSWORD = "kompass-agent";
15
+ const DEFAULT_NETWORK = "base"; // Mainnet by default
16
+ const ERC20_ABI = [
17
+ { type: "function", name: "balanceOf", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
18
+ { type: "function", name: "approve", inputs: [{ name: "spender", type: "address" }, { name: "amount", type: "uint256" }], outputs: [{ name: "", type: "bool" }], stateMutability: "nonpayable" },
19
+ ];
20
+ // Known USDC addresses per chain
21
+ const USDC_ADDRESSES = {
22
+ "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
23
+ "base": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
24
+ };
25
+ export class KompassWallet {
26
+ privateKey;
27
+ keystorePath;
28
+ network;
29
+ account;
30
+ publicClient;
31
+ walletClient;
32
+ constructor(privateKey, network, keystorePath) {
33
+ this.privateKey = privateKey;
34
+ this.network = network;
35
+ this.keystorePath = keystorePath;
36
+ this.account = privateKeyToAccount(privateKey);
37
+ const chain = network === "base" ? base : baseSepolia;
38
+ const rpcUrl = network === "base" ? "https://mainnet.base.org" : "https://sepolia.base.org";
39
+ this.publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
40
+ this.walletClient = createWalletClient({ account: this.account, chain, transport: http(rpcUrl) });
41
+ }
42
+ /**
43
+ * Create a new wallet. Generates a fresh keypair and saves encrypted keystore.
44
+ */
45
+ static create(options) {
46
+ const path = options?.path ?? DEFAULT_WALLET_PATH;
47
+ const network = options?.network ?? DEFAULT_NETWORK;
48
+ const password = options?.password ?? DEFAULT_PASSWORD;
49
+ const privateKey = generatePrivateKey();
50
+ const account = privateKeyToAccount(privateKey);
51
+ const { encrypted, iv, salt } = encryptKey(privateKey, password);
52
+ const keystoreData = {
53
+ address: account.address,
54
+ encryptedKey: encrypted,
55
+ iv,
56
+ salt,
57
+ network,
58
+ createdAt: new Date().toISOString(),
59
+ };
60
+ saveKeystore(path, keystoreData);
61
+ return new KompassWallet(privateKey, network, path);
62
+ }
63
+ /**
64
+ * Load an existing wallet from keystore file.
65
+ */
66
+ static load(path, password) {
67
+ const keystorePath = path ?? DEFAULT_WALLET_PATH;
68
+ const pwd = password ?? DEFAULT_PASSWORD;
69
+ const data = loadKeystore(keystorePath);
70
+ const privateKey = decryptKey(data.encryptedKey, data.iv, data.salt, pwd);
71
+ const network = (data.network ?? "base-sepolia");
72
+ return new KompassWallet(privateKey, network, keystorePath);
73
+ }
74
+ /** Get wallet address */
75
+ getAddress() {
76
+ return this.account.address;
77
+ }
78
+ /** Get the viem account for signing */
79
+ getAccount() {
80
+ return this.account;
81
+ }
82
+ /** Get the viem wallet client for transactions */
83
+ getWalletClient() {
84
+ return this.walletClient;
85
+ }
86
+ /** Get the viem public client for reads */
87
+ getPublicClient() {
88
+ return this.publicClient;
89
+ }
90
+ /** Get the private key (use carefully) */
91
+ getPrivateKey() {
92
+ return this.privateKey;
93
+ }
94
+ /** Get network name */
95
+ getNetwork() {
96
+ return this.network;
97
+ }
98
+ /** Check USDC + ETH balance */
99
+ async getBalance() {
100
+ const address = this.account.address;
101
+ const ethBalance = await this.publicClient.getBalance({ address });
102
+ const usdcAddress = USDC_ADDRESSES[this.network];
103
+ let usdcBalance = 0n;
104
+ if (usdcAddress) {
105
+ usdcBalance = await this.publicClient.readContract({
106
+ address: usdcAddress,
107
+ abi: ERC20_ABI,
108
+ functionName: "balanceOf",
109
+ args: [address],
110
+ });
111
+ }
112
+ return {
113
+ address,
114
+ eth: formatEther(ethBalance),
115
+ usdc: formatUnits(usdcBalance, 6),
116
+ usdcRaw: usdcBalance,
117
+ ethRaw: ethBalance,
118
+ network: this.network,
119
+ };
120
+ }
121
+ /** Approve USDC spending for a contract */
122
+ async approveUSDC(spender, amount) {
123
+ const usdcAddress = USDC_ADDRESSES[this.network];
124
+ if (!usdcAddress)
125
+ throw new Error(`No USDC address for network: ${this.network}`);
126
+ const txHash = await this.walletClient.writeContract({
127
+ address: usdcAddress,
128
+ abi: ERC20_ABI,
129
+ functionName: "approve",
130
+ args: [spender, amount],
131
+ });
132
+ await this.publicClient.waitForTransactionReceipt({ hash: txHash });
133
+ return txHash;
134
+ }
135
+ }
136
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAA0B,MAAM,MAAM,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;AACvE,MAAM,gBAAgB,GAAG,eAAe,CAAC;AACzC,MAAM,eAAe,GAA4B,MAAM,CAAC,CAAC,qBAAqB;AAE9E,MAAM,SAAS,GAAG;IAChB,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE;IAC1J,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,E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ACjD,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAElF,MAAM,MAAM,GAAG,MAAO,IAAI,CAAC,YAAoB,CAAC,aAAa,CAAC;YAC5D,OAAO,EAAE,WAAW;YACpB,GAAG,EAAE,SAAS;YACd,YAAY,EAAE,SAAS;YACvB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;SACxB,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Kompass Wallet Keystore
3
+ * Encrypted private key storage — AES-256-GCM
4
+ * Private key never stored in plaintext
5
+ */
6
+ export interface KeystoreData {
7
+ address: string;
8
+ encryptedKey: string;
9
+ iv: string;
10
+ salt: string;
11
+ network: string;
12
+ createdAt: string;
13
+ config?: {
14
+ nwcUri?: string;
15
+ stripeKey?: string;
16
+ };
17
+ }
18
+ export declare function encryptKey(privateKey: string, password: string): {
19
+ encrypted: string;
20
+ iv: string;
21
+ salt: string;
22
+ };
23
+ export declare function decryptKey(encrypted: string, iv: string, salt: string, password: string): string;
24
+ export declare function saveKeystore(path: string, data: KeystoreData): void;
25
+ export declare function loadKeystore(path: string): KeystoreData;
26
+ //# sourceMappingURL=keystore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keystore.d.ts","sourceRoot":"","sources":["../../src/wallet/keystore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAWD,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAehH;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUhG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAGnE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAGvD"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Kompass Wallet Keystore
3
+ * Encrypted private key storage — AES-256-GCM
4
+ * Private key never stored in plaintext
5
+ */
6
+ import { randomBytes, createCipheriv, createDecipheriv, scryptSync } from "crypto";
7
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
8
+ import { dirname } from "path";
9
+ const ALGORITHM = "aes-256-gcm";
10
+ const KEY_LENGTH = 32;
11
+ const IV_LENGTH = 16;
12
+ const SALT_LENGTH = 32;
13
+ function deriveKey(password, salt) {
14
+ return scryptSync(password, salt, KEY_LENGTH);
15
+ }
16
+ export function encryptKey(privateKey, password) {
17
+ const salt = randomBytes(SALT_LENGTH);
18
+ const key = deriveKey(password, salt);
19
+ const iv = randomBytes(IV_LENGTH);
20
+ const cipher = createCipheriv(ALGORITHM, key, iv);
21
+ let encrypted = cipher.update(privateKey, "utf8", "hex");
22
+ encrypted += cipher.final("hex");
23
+ const authTag = cipher.getAuthTag().toString("hex");
24
+ return {
25
+ encrypted: encrypted + ":" + authTag,
26
+ iv: iv.toString("hex"),
27
+ salt: salt.toString("hex"),
28
+ };
29
+ }
30
+ export function decryptKey(encrypted, iv, salt, password) {
31
+ const key = deriveKey(password, Buffer.from(salt, "hex"));
32
+ const [encData, authTag] = encrypted.split(":");
33
+ const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(iv, "hex"));
34
+ decipher.setAuthTag(Buffer.from(authTag, "hex"));
35
+ let decrypted = decipher.update(encData, "hex", "utf8");
36
+ decrypted += decipher.final("utf8");
37
+ return decrypted;
38
+ }
39
+ export function saveKeystore(path, data) {
40
+ mkdirSync(dirname(path), { recursive: true });
41
+ writeFileSync(path, JSON.stringify(data, null, 2), { mode: 0o600 }); // owner-only permissions
42
+ }
43
+ export function loadKeystore(path) {
44
+ if (!existsSync(path))
45
+ throw new Error(`Keystore not found: ${path}`);
46
+ return JSON.parse(readFileSync(path, "utf8"));
47
+ }
48
+ //# sourceMappingURL=keystore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keystore.js","sourceRoot":"","sources":["../../src/wallet/keystore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAe/B,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,SAAS,SAAS,CAAC,QAAgB,EAAE,IAAY;IAC/C,OAAO,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,UAAkB,EAAE,QAAgB;IAC7D,MAAM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AK,EAAE,MAAM,CAAC,CAAC;IACxD,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAkB;IAC3D,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,yBAAyB;AAChG,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Kompass Payment Router
3
+ * Routes payment to the right protocol handler based on agent type
4
+ */
5
+ import type { KompassWallet } from "./index.js";
6
+ import type { UnifiedAgent } from "../sources/types.js";
7
+ export interface PaymentResult {
8
+ success: boolean;
9
+ protocol: string;
10
+ deliverable?: unknown;
11
+ txHash?: string;
12
+ jobId?: string;
13
+ error?: string;
14
+ costUSDC?: number;
15
+ }
16
+ export declare function routePayment(wallet: KompassWallet, agent: UnifiedAgent, task: string, options?: {
17
+ nwcUri?: string;
18
+ budget?: bigint;
19
+ }): Promise<PaymentResult>;
20
+ //# sourceMappingURL=payment-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-router.d.ts","sourceRoot":"","sources":["../../src/wallet/payment-router.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AASvE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,aAAa,CAAC,CA+DxB"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Kompass Payment Router
3
+ * Routes payment to the right protocol handler based on agent type
4
+ */
5
+ import { handleX402Payment } from "./handlers/x402.js";
6
+ import { handleACPPayment } from "./handlers/acp.js";
7
+ import { handleL402Payment } from "./handlers/l402.js";
8
+ import { handleMPPPayment } from "./handlers/mpp.js";
9
+ import { handleNanopayment } from "./handlers/nanopayments.js";
10
+ import { handleFreePayment } from "./handlers/free.js";
11
+ import { ensureSufficientBalance } from "./bridge.js";
12
+ export async function routePayment(wallet, agent, task, options) {
13
+ const protocol = determinePaymentProtocol(agent);
14
+ try {
15
+ // Pre-payment: ensure wallet has enough funds (skip for free)
16
+ if (protocol !== "free") {
17
+ const estimatedCost = parseFloat(agent.pricing?.amount ?? "0.05");
18
+ try {
19
+ await ensureSufficientBalance(wallet, estimatedCost);
20
+ }
21
+ catch (balErr) {
22
+ return {
23
+ success: false,
24
+ protocol,
25
+ error: balErr instanceof Error ? balErr.message : String(balErr),
26
+ };
27
+ }
28
+ }
29
+ switch (protocol) {
30
+ case "x402": {
31
+ const result = await handleX402Payment(wallet, agent, task);
32
+ return { ...result, protocol: "x402", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
33
+ }
34
+ case "acp": {
35
+ const result = await handleACPPayment(wallet, agent, task, options?.budget);
36
+ return { ...result, protocol: "acp-escrow", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
37
+ }
38
+ case "l402": {
39
+ const result = await handleL402Payment(wallet, agent, task, options?.nwcUri);
40
+ return { ...result, protocol: "l402-lightning" };
41
+ }
42
+ case "mpp": {
43
+ const result = await handleMPPPayment(wallet, agent, task);
44
+ return { ...result, protocol: "mpp-tempo", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
45
+ }
46
+ case "nanopayments": {
47
+ const result = await handleNanopayment(wallet, agent, task);
48
+ return { ...result, protocol: "circle-nanopayments", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
49
+ }
50
+ case "free": {
51
+ const result = await handleFreePayment(agent, task);
52
+ return { ...result, protocol: "free", costUSDC: 0 };
53
+ }
54
+ default:
55
+ return {
56
+ success: false,
57
+ protocol: protocol,
58
+ error: `Unsupported payment protocol: ${protocol}`,
59
+ };
60
+ }
61
+ }
62
+ catch (err) {
63
+ return {
64
+ success: false,
65
+ protocol,
66
+ error: err instanceof Error ? err.message : String(err),
67
+ };
68
+ }
69
+ }
70
+ function determinePaymentProtocol(agent) {
71
+ // Free tools
72
+ if (agent.pricing?.model === "free" || agent.protocol === "skill" || agent.protocol === "mcp") {
73
+ return "free";
74
+ }
75
+ // Explicit protocol from agent data
76
+ if (agent.endpoints.x402)
77
+ return "x402";
78
+ if (agent.endpoints.l402)
79
+ return "l402";
80
+ if (agent.endpoints.acp)
81
+ return "acp";
82
+ // Infer from source
83
+ switch (agent.source) {
84
+ case "acp": return "acp";
85
+ case "x402-ecosystem": return "x402";
86
+ case "l402-directory": return "l402";
87
+ case "mcp-registry": return "free";
88
+ case "skills-registry": return "free";
89
+ default: return agent.protocol === "onchain" ? "acp" : "free";
90
+ }
91
+ }
92
+ //# sourceMappingURL=payment-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-router.js","sourceRoot":"","sources":["../../src/wallet/payment-router.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAYtD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAqB,EACrB,KAAmB,EACnB,IAAY,EACZ,OAA8C;IAE9C,MAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEjD,IAAI,CAAC;QACH,8DAA8D;QAC9D,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;YACxB,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC;YAClE,IAAI,CAAC;gBACH,MAAM,uBAAuB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;YACvD,CAAC;YAAC,OAAO,MAAM,EAAE,CAAC;gBAChB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,QAAQ;oBACR,KAAK,EAAE,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;iBACjE,CAAC;YACJ,CAAC;QACH,CAAC;QAED,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,MAAM,CAAC,CAAC,CAAC;gBACZ,MAAM,M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AC;QACzB,KAAK,gBAAgB,CAAC,CAAC,OAAO,MAAM,CAAC;QACrC,KAAK,gBAAgB,CAAC,CAAC,OAAO,MAAM,CAAC;QACrC,KAAK,cAAc,CAAC,CAAC,OAAO,MAAM,CAAC;QACnC,KAAK,iBAAiB,CAAC,CAAC,OAAO,MAAM,CAAC;QACtC,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAChE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kompass-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Get any job done. Universal agent capability discovery + coordination across ACP, MCP, x402, A2A, skills, L402, and ERC-8004.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,8 +45,11 @@
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
47
  "@a2a-js/sdk": "^0.3.13",
48
+ "@getalby/lightning-tools": "^7.0.2",
48
49
  "@types/express": "^5.0.6",
49
50
  "@virtuals-protocol/acp-node": "^0.3.0-beta.39",
51
+ "@x402/evm": "^2.7.0",
52
+ "@x402/fetch": "^2.7.0",
50
53
  "commander": "^14.0.3",
51
54
  "dotenv": "^17.3.1",
52
55
  "express": "^5.2.1",
package/src/cli.ts CHANGED
@@ -196,6 +196,46 @@ program
196
196
  console.log(`Backend: ACP (Virtuals Protocol)`);
197
197
  });
198
198
 
199
+ // ── Wallet Commands ──────────────────────────────────────
200
+
201
+ const walletCmd = program.command("wallet").description("Manage Kompass spending wallet");
202
+
203
+ walletCmd
204
+ .command("create")
205
+ .description("Create a new Kompass spending wallet")
206
+ .option("-n, --network <network>", "base or base-sepolia", "base")
207
+ .option("-p, --path <path>", "keystore file path")
208
+ .action(async (opts: { network: string; path?: string }) => {
209
+ const { KompassWallet } = await import("./wallet/index.js");
210
+ const wallet = KompassWallet.create({
211
+ network: opts.network as "base" | "base-sepolia",
212
+ path: opts.path,
213
+ });
214
+ const balance = await wallet.getBalance();
215
+ console.log(`\n🔑 Kompass Wallet Created`);
216
+ console.log(` Address: ${balance.address}`);
217
+ console.log(` Network: ${balance.network}`);
218
+ console.log(` ETH: ${balance.eth}`);
219
+ console.log(` USDC: ${balance.usdc}`);
220
+ console.log(`\n Fund this address with USDC to start using Kompass.`);
221
+ console.log(` Keystore saved. Your private key is encrypted and never leaves your machine.\n`);
222
+ });
223
+
224
+ walletCmd
225
+ .command("balance")
226
+ .description("Check wallet balance")
227
+ .option("-p, --path <path>", "keystore file path")
228
+ .action(async (opts: { path?: string }) => {
229
+ const { KompassWallet } = await import("./wallet/index.js");
230
+ const wallet = KompassWallet.load(opts.path);
231
+ const balance = await wallet.getBalance();
232
+ console.log(`\n💰 Kompass Wallet`);
233
+ console.log(` Address: ${balance.address}`);
234
+ console.log(` Network: ${balance.network}`);
235
+ console.log(` ETH: ${balance.eth}`);
236
+ console.log(` USDC: ${balance.usdc}\n`);
237
+ });
238
+
199
239
  // ── Core Command: Do ─────────────────────────────────────
200
240
 
201
241
  program
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Kompass Internal Bridge
3
+ * Handles all fund routing that the agent never sees:
4
+ * - USDC transfer to ACP wallet (same chain)
5
+ * - USDC → Lightning sats swap (via Boltz)
6
+ * - Cross-chain USDC bridging (via CCTP)
7
+ */
8
+
9
+ import { type Address, type Hex, parseUnits, formatUnits } from "viem";
10
+ import type { KompassWallet } from "./index.js";
11
+
12
+ const USDC_ABI = [
13
+ { type: "function", name: "transfer", inputs: [{ name: "to", type: "address" }, { name: "amount", type: "uint256" }], outputs: [{ name: "", type: "bool" }], stateMutability: "nonpayable" },
14
+ { type: "function", name: "balanceOf", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
15
+ ] as const;
16
+
17
+ const USDC_ADDRESSES: Record<string, Address> = {
18
+ "base": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
19
+ "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
20
+ };
21
+
22
+ // ── ACP Wallet Topup ─────────────────────────────────────
23
+
24
+ /**
25
+ * Transfer USDC from Kompass wallet to ACP smart wallet on Base.
26
+ * This is a simple ERC-20 transfer on the same chain.
27
+ */
28
+ export async function topupACPWallet(
29
+ wallet: KompassWallet,
30
+ acpWalletAddress: Address,
31
+ amountUSDC: number
32
+ ): Promise<{ txHash: Hex; amount: string }> {
33
+ const network = wallet.getNetwork();
34
+ const usdcAddress = USDC_ADDRESSES[network];
35
+ if (!usdcAddress) throw new Error(`No USDC address for network: ${network}`);
36
+
37
+ const amount = parseUnits(String(amountUSDC), 6);
38
+
39
+ // Check balance first
40
+ const balance = await wallet.getPublicClient().readContract({
41
+ address: usdcAddress,
42
+ abi: USDC_ABI,
43
+ functionName: "balanceOf",
44
+ args: [wallet.getAddress()],
45
+ });
46
+
47
+ if (balance < amount) {
48
+ throw new Error(
49
+ `Insufficient USDC: have ${formatUnits(balance, 6)}, need ${amountUSDC}. ` +
50
+ `Fund your Kompass wallet at ${wallet.getAddress()} on ${network}.`
51
+ );
52
+ }
53
+
54
+ const txHash = await (wallet.getWalletClient() as any).writeContract({
55
+ address: usdcAddress,
56
+ abi: USDC_ABI,
57
+ functionName: "transfer",
58
+ args: [acpWalletAddress, amount],
59
+ });
60
+
61
+ await wallet.getPublicClient().waitForTransactionReceipt({ hash: txHash });
62
+
63
+ console.log(`[Kompass Bridge] Transferred ${amountUSDC} USDC to ACP wallet ${acpWalletAddress.slice(0, 10)}... | tx: ${txHash}`);
64
+
65
+ return { txHash, amount: String(amountUSDC) };
66
+ }
67
+
68
+ // ── Lightning Swap (USDC → sats) ─────────────────────────
69
+
70
+ /**
71
+ * Swap USDC to Lightning sats via Boltz Exchange API.
72
+ * Boltz supports atomic submarine swaps: USDC on-chain → Lightning invoice paid.
73
+ */
74
+ export async function swapUSDCtoLightning(
75
+ wallet: KompassWallet,
76
+ invoiceAmountSats: number,
77
+ invoice: string
78
+ ): Promise<{ success: boolean; preimage?: string; error?: string }> {
79
+ // Boltz Exchange API for submarine swaps
80
+ // https://docs.boltz.exchange/api
81
+ const BOLTZ_API = "https://api.boltz.exchange/v2";
82
+
83
+ try {
84
+ // Step 1: Create a submarine swap (on-chain → Lightning)
85
+ const createRes = await fetch(`${BOLTZ_API}/swap/submarine`, {
86
+ method: "POST",
87
+ headers: { "Content-Type": "application/json" },
88
+ body: JSON.stringify({
89
+ from: "USDC", // or "BTC" for on-chain BTC
90
+ to: "BTC",
91
+ invoice,
92
+ referralId: "kompass",
93
+ }),
94
+ });
95
+
96
+ if (!createRes.ok) {
97
+ const err = await createRes.text();
98
+ return { success: false, error: `Boltz swap creation failed: ${err}` };
99
+ }
100
+
101
+ const swapData = await createRes.json();
102
+
103
+ // Step 2: Send the required on-chain amount to Boltz's lock address
104
+ // Boltz provides: address, expectedAmount, and a swap ID
105
+ // The agent's wallet sends USDC/BTC to the lock address
106
+ // Boltz atomically pays the Lightning invoice
107
+
108
+ return {
109
+ success: false,
110
+ error: `Lightning swap prepared via Boltz. Swap ID: ${swapData.id ?? "unknown"}. ` +
111
+ `Send ${swapData.expectedAmount ?? invoiceAmountSats} sats worth of USDC to ${swapData.address ?? "Boltz lock address"} to complete.`,
112
+ };
113
+ } catch (err) {
114
+ return {
115
+ success: false,
116
+ error: `Lightning swap failed: ${err instanceof Error ? err.message : String(err)}`,
117
+ };
118
+ }
119
+ }
120
+
121
+ // ── Cross-Chain USDC Bridge ──────────────────────────────
122
+
123
+ /**
124
+ * Bridge USDC from Base to another chain via Circle CCTP.
125
+ * Most agent capabilities are on Base, so this is rarely needed.
126
+ */
127
+ export async function bridgeUSDCCrossChain(
128
+ wallet: KompassWallet,
129
+ toChain: string,
130
+ amountUSDC: number
131
+ ): Promise<{ success: boolean; txHash?: string; error?: string }> {
132
+ // Circle CCTP (Cross-Chain Transfer Protocol) endpoints
133
+ // https://developers.circle.com/stablecoins/cctp-getting-started
134
+
135
+ // For hackathon: most capabilities are on Base, bridging rarely needed
136
+ return {
137
+ success: false,
138
+ error: `Cross-chain bridging to ${toChain} is not yet automated. ` +
139
+ `Most agent capabilities are on Base. Use a bridge like bridge.circle.com manually if needed.`,
140
+ };
141
+ }
142
+
143
+ // ── Balance Check ────────────────────────────────────────
144
+
145
+ /**
146
+ * Check if wallet has enough USDC for a payment.
147
+ * Returns true if sufficient, throws descriptive error if not.
148
+ */
149
+ export async function ensureSufficientBalance(
150
+ wallet: KompassWallet,
151
+ requiredUSDC: number
152
+ ): Promise<boolean> {
153
+ const balance = await wallet.getBalance();
154
+ const available = parseFloat(balance.usdc);
155
+
156
+ if (available < requiredUSDC) {
157
+ throw new Error(
158
+ `Insufficient USDC: have $${available.toFixed(2)}, need $${requiredUSDC.toFixed(2)}. ` +
159
+ `Fund your Kompass wallet: send USDC to ${balance.address} on Base.`
160
+ );
161
+ }
162
+
163
+ return true;
164
+ }