kompass-sdk 0.2.1 → 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.
Files changed (49) hide show
  1. package/dist/cli.js +36 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/wallet/handlers/acp.d.ts +16 -0
  4. package/dist/wallet/handlers/acp.d.ts.map +1 -0
  5. package/dist/wallet/handlers/acp.js +65 -0
  6. package/dist/wallet/handlers/acp.js.map +1 -0
  7. package/dist/wallet/handlers/free.d.ts +10 -0
  8. package/dist/wallet/handlers/free.d.ts.map +1 -0
  9. package/dist/wallet/handlers/free.js +25 -0
  10. package/dist/wallet/handlers/free.js.map +1 -0
  11. package/dist/wallet/handlers/l402.d.ts +13 -0
  12. package/dist/wallet/handlers/l402.d.ts.map +1 -0
  13. package/dist/wallet/handlers/l402.js +94 -0
  14. package/dist/wallet/handlers/l402.js.map +1 -0
  15. package/dist/wallet/handlers/mpp.d.ts +21 -0
  16. package/dist/wallet/handlers/mpp.d.ts.map +1 -0
  17. package/dist/wallet/handlers/mpp.js +78 -0
  18. package/dist/wallet/handlers/mpp.js.map +1 -0
  19. package/dist/wallet/handlers/nanopayments.d.ts +25 -0
  20. package/dist/wallet/handlers/nanopayments.d.ts.map +1 -0
  21. package/dist/wallet/handlers/nanopayments.js +24 -0
  22. package/dist/wallet/handlers/nanopayments.js.map +1 -0
  23. package/dist/wallet/handlers/x402.d.ts +13 -0
  24. package/dist/wallet/handlers/x402.d.ts.map +1 -0
  25. package/dist/wallet/handlers/x402.js +48 -0
  26. package/dist/wallet/handlers/x402.js.map +1 -0
  27. package/dist/wallet/index.d.ts +9393 -0
  28. package/dist/wallet/index.d.ts.map +1 -0
  29. package/dist/wallet/index.js +135 -0
  30. package/dist/wallet/index.js.map +1 -0
  31. package/dist/wallet/keystore.d.ts +26 -0
  32. package/dist/wallet/keystore.d.ts.map +1 -0
  33. package/dist/wallet/keystore.js +48 -0
  34. package/dist/wallet/keystore.js.map +1 -0
  35. package/dist/wallet/payment-router.d.ts +20 -0
  36. package/dist/wallet/payment-router.d.ts.map +1 -0
  37. package/dist/wallet/payment-router.js +77 -0
  38. package/dist/wallet/payment-router.js.map +1 -0
  39. package/package.json +4 -1
  40. package/src/cli.ts +40 -0
  41. package/src/wallet/handlers/acp.ts +83 -0
  42. package/src/wallet/handlers/free.ts +28 -0
  43. package/src/wallet/handlers/l402.ts +119 -0
  44. package/src/wallet/handlers/mpp.ts +91 -0
  45. package/src/wallet/handlers/nanopayments.ts +31 -0
  46. package/src/wallet/handlers/x402.ts +58 -0
  47. package/src/wallet/index.ts +160 -0
  48. package/src/wallet/keystore.ts +70 -0
  49. package/src/wallet/payment-router.ts +101 -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;AAqBtH,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,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa;IAW5D,yBAAyB;IACzB,UAAU,IAAI,OAAO;IAIrB,uCAAuC;IACvC,UAAU;;;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;;;;;;;;;;kCAAynE,CAAC;yBAA2D,CAAC;kCAA6F,CAAC;;sCAA2F,CAAC;8BAAqD,CAAC;0BAAiD,CAAC;;;;yBAA+K,CAAC;4BAA4B,CAAC;;;;wBAA6I,CAAC;;;;;;;;;;;;;;;;IApDps8B,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,135 @@
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"; // TODO: prompt user for password in production
15
+ const ERC20_ABI = [
16
+ { type: "function", name: "balanceOf", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
17
+ { type: "function", name: "approve", inputs: [{ name: "spender", type: "address" }, { name: "amount", type: "uint256" }], outputs: [{ name: "", type: "bool" }], stateMutability: "nonpayable" },
18
+ ];
19
+ // Known USDC addresses per chain
20
+ const USDC_ADDRESSES = {
21
+ "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
22
+ "base": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
23
+ };
24
+ export class KompassWallet {
25
+ privateKey;
26
+ keystorePath;
27
+ network;
28
+ account;
29
+ publicClient;
30
+ walletClient;
31
+ constructor(privateKey, network, keystorePath) {
32
+ this.privateKey = privateKey;
33
+ this.network = network;
34
+ this.keystorePath = keystorePath;
35
+ this.account = privateKeyToAccount(privateKey);
36
+ const chain = network === "base" ? base : baseSepolia;
37
+ const rpcUrl = network === "base" ? "https://mainnet.base.org" : "https://sepolia.base.org";
38
+ this.publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
39
+ this.walletClient = createWalletClient({ account: this.account, chain, transport: http(rpcUrl) });
40
+ }
41
+ /**
42
+ * Create a new wallet. Generates a fresh keypair and saves encrypted keystore.
43
+ */
44
+ static create(options) {
45
+ const path = options?.path ?? DEFAULT_WALLET_PATH;
46
+ const network = options?.network ?? "base-sepolia";
47
+ const password = options?.password ?? DEFAULT_PASSWORD;
48
+ const privateKey = generatePrivateKey();
49
+ const account = privateKeyToAccount(privateKey);
50
+ const { encrypted, iv, salt } = encryptKey(privateKey, password);
51
+ const keystoreData = {
52
+ address: account.address,
53
+ encryptedKey: encrypted,
54
+ iv,
55
+ salt,
56
+ network,
57
+ createdAt: new Date().toISOString(),
58
+ };
59
+ saveKeystore(path, keystoreData);
60
+ return new KompassWallet(privateKey, network, path);
61
+ }
62
+ /**
63
+ * Load an existing wallet from keystore file.
64
+ */
65
+ static load(path, password) {
66
+ const keystorePath = path ?? DEFAULT_WALLET_PATH;
67
+ const pwd = password ?? DEFAULT_PASSWORD;
68
+ const data = loadKeystore(keystorePath);
69
+ const privateKey = decryptKey(data.encryptedKey, data.iv, data.salt, pwd);
70
+ const network = (data.network ?? "base-sepolia");
71
+ return new KompassWallet(privateKey, network, keystorePath);
72
+ }
73
+ /** Get wallet address */
74
+ getAddress() {
75
+ return this.account.address;
76
+ }
77
+ /** Get the viem account for signing */
78
+ getAccount() {
79
+ return this.account;
80
+ }
81
+ /** Get the viem wallet client for transactions */
82
+ getWalletClient() {
83
+ return this.walletClient;
84
+ }
85
+ /** Get the viem public client for reads */
86
+ getPublicClient() {
87
+ return this.publicClient;
88
+ }
89
+ /** Get the private key (use carefully) */
90
+ getPrivateKey() {
91
+ return this.privateKey;
92
+ }
93
+ /** Get network name */
94
+ getNetwork() {
95
+ return this.network;
96
+ }
97
+ /** Check USDC + ETH balance */
98
+ async getBalance() {
99
+ const address = this.account.address;
100
+ const ethBalance = await this.publicClient.getBalance({ address });
101
+ const usdcAddress = USDC_ADDRESSES[this.network];
102
+ let usdcBalance = 0n;
103
+ if (usdcAddress) {
104
+ usdcBalance = await this.publicClient.readContract({
105
+ address: usdcAddress,
106
+ abi: ERC20_ABI,
107
+ functionName: "balanceOf",
108
+ args: [address],
109
+ });
110
+ }
111
+ return {
112
+ address,
113
+ eth: formatEther(ethBalance),
114
+ usdc: formatUnits(usdcBalance, 6),
115
+ usdcRaw: usdcBalance,
116
+ ethRaw: ethBalance,
117
+ network: this.network,
118
+ };
119
+ }
120
+ /** Approve USDC spending for a contract */
121
+ async approveUSDC(spender, amount) {
122
+ const usdcAddress = USDC_ADDRESSES[this.network];
123
+ if (!usdcAddress)
124
+ throw new Error(`No USDC address for network: ${this.network}`);
125
+ const txHash = await this.walletClient.writeContract({
126
+ address: usdcAddress,
127
+ abi: ERC20_ABI,
128
+ functionName: "approve",
129
+ args: [spender, amount],
130
+ });
131
+ await this.publicClient.waitForTransactionReceipt({ hash: txHash });
132
+ return txHash;
133
+ }
134
+ }
135
+ //# 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,EAA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d,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,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACtC,MAAM,EAAE,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IAElC,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,EAAE,GAA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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;AAQvE,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,CAiDxB"}
@@ -0,0 +1,77 @@
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
+ export async function routePayment(wallet, agent, task, options) {
12
+ const protocol = determinePaymentProtocol(agent);
13
+ try {
14
+ switch (protocol) {
15
+ case "x402": {
16
+ const result = await handleX402Payment(wallet, agent, task);
17
+ return { ...result, protocol: "x402", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
18
+ }
19
+ case "acp": {
20
+ const result = await handleACPPayment(wallet, agent, task, options?.budget);
21
+ return { ...result, protocol: "acp-escrow", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
22
+ }
23
+ case "l402": {
24
+ const result = await handleL402Payment(wallet, agent, task, options?.nwcUri);
25
+ return { ...result, protocol: "l402-lightning" };
26
+ }
27
+ case "mpp": {
28
+ const result = await handleMPPPayment(wallet, agent, task);
29
+ return { ...result, protocol: "mpp-tempo", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
30
+ }
31
+ case "nanopayments": {
32
+ const result = await handleNanopayment(wallet, agent, task);
33
+ return { ...result, protocol: "circle-nanopayments", costUSDC: parseFloat(agent.pricing?.amount ?? "0") };
34
+ }
35
+ case "free": {
36
+ const result = await handleFreePayment(agent, task);
37
+ return { ...result, protocol: "free", costUSDC: 0 };
38
+ }
39
+ default:
40
+ return {
41
+ success: false,
42
+ protocol: protocol,
43
+ error: `Unsupported payment protocol: ${protocol}`,
44
+ };
45
+ }
46
+ }
47
+ catch (err) {
48
+ return {
49
+ success: false,
50
+ protocol,
51
+ error: err instanceof Error ? err.message : String(err),
52
+ };
53
+ }
54
+ }
55
+ function determinePaymentProtocol(agent) {
56
+ // Free tools
57
+ if (agent.pricing?.model === "free" || agent.protocol === "skill" || agent.protocol === "mcp") {
58
+ return "free";
59
+ }
60
+ // Explicit protocol from agent data
61
+ if (agent.endpoints.x402)
62
+ return "x402";
63
+ if (agent.endpoints.l402)
64
+ return "l402";
65
+ if (agent.endpoints.acp)
66
+ return "acp";
67
+ // Infer from source
68
+ switch (agent.source) {
69
+ case "acp": return "acp";
70
+ case "x402-ecosystem": return "x402";
71
+ case "l402-directory": return "l402";
72
+ case "mcp-registry": return "free";
73
+ case "skills-registry": return "free";
74
+ default: return agent.protocol === "onchain" ? "acp" : "free";
75
+ }
76
+ }
77
+ //# 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;AAYvD,MAAM,CAAC,KAAK,UAAU,YA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AC,SAAS,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;IACxC,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IAEtC,oBAAoB;IACpB,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC;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.3.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-sepolia")
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,83 @@
1
+ /**
2
+ * ACP Escrow Payment Handler
3
+ * Creates ERC-8183 escrow jobs on Virtuals ACP
4
+ *
5
+ * Uses @virtuals-protocol/acp-node SDK programmatically
6
+ * Falls back to CLI if SDK init fails (requires ACP registration)
7
+ */
8
+
9
+ import { execFile } from "child_process";
10
+ import { promisify } from "util";
11
+ import type { KompassWallet } from "../index.js";
12
+ import type { UnifiedAgent } from "../../sources/types.js";
13
+
14
+ const execFileAsync = promisify(execFile);
15
+
16
+ export async function handleACPPayment(
17
+ wallet: KompassWallet,
18
+ agent: UnifiedAgent,
19
+ task: string,
20
+ budget?: bigint
21
+ ): Promise<{ success: boolean; deliverable?: unknown; txHash?: string; jobId?: string }> {
22
+ const offering = (agent.raw as any)?.jobs?.[0] ?? (agent.raw as any)?.jobOfferings?.[0];
23
+ if (!offering) {
24
+ return { success: false, deliverable: { error: "Agent has no ACP job offerings" } };
25
+ }
26
+
27
+ const walletAddress = agent.endpoints.acp?.walletAddress;
28
+ if (!walletAddress) {
29
+ return { success: false, deliverable: { error: "No ACP wallet address for agent" } };
30
+ }
31
+
32
+ try {
33
+ // Use ACP CLI with execFile (not execSync) to avoid shell injection
34
+ // Arguments passed as array, not concatenated string
35
+ const requirements = JSON.stringify({ description: task });
36
+
37
+ const { stdout } = await execFileAsync(
38
+ "npx",
39
+ [
40
+ "acp", "job", "create",
41
+ walletAddress,
42
+ String(offering.id),
43
+ "--requirements", requirements,
44
+ "--isAutomated", "true",
45
+ "--json",
46
+ ],
47
+ {
48
+ cwd: "/tmp/openclaw-acp",
49
+ timeout: 60000,
50
+ env: { ...process.env, NODE_NO_WARNINGS: "1" },
51
+ }
52
+ );
53
+
54
+ const jobData = JSON.parse(stdout.trim());
55
+
56
+ return {
57
+ success: true,
58
+ deliverable: {
59
+ type: "acp-escrow",
60
+ jobId: jobData.jobId ?? jobData.id,
61
+ status: "created",
62
+ message: "ACP escrow job created with ERC-8183. Agent will process and deliver.",
63
+ offering: offering.name,
64
+ price: offering.price,
65
+ agent: agent.name,
66
+ },
67
+ jobId: String(jobData.jobId ?? jobData.id),
68
+ };
69
+ } catch (err) {
70
+ const message = err instanceof Error ? err.message : String(err);
71
+
72
+ // If CLI fails, return helpful error
73
+ return {
74
+ success: false,
75
+ deliverable: {
76
+ error: `ACP job creation failed: ${message}`,
77
+ hint: "Ensure ACP CLI is set up: cd /tmp/openclaw-acp && npx acp setup",
78
+ agent: agent.name,
79
+ offering: offering.name,
80
+ },
81
+ };
82
+ }
83
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Free Payment Handler
3
+ * For MCP tools, free skills, and open APIs — no payment needed
4
+ */
5
+
6
+ import type { UnifiedAgent } from "../../sources/types.js";
7
+
8
+ export async function handleFreePayment(agent: UnifiedAgent, task: string): Promise<{ success: boolean; deliverable?: unknown }> {
9
+ // No payment needed — just call the endpoint if available
10
+ const endpoint = agent.endpoints.http ?? agent.endpoints.mcp;
11
+
12
+ if (!endpoint) {
13
+ return { success: true, deliverable: { type: "free", message: "Free capability — install or call directly", agent: agent.name } };
14
+ }
15
+
16
+ try {
17
+ const res = await fetch(endpoint, {
18
+ method: "POST",
19
+ headers: { "Content-Type": "application/json" },
20
+ body: JSON.stringify({ task }),
21
+ signal: AbortSignal.timeout(30000),
22
+ });
23
+ const data = await res.json().catch(() => null);
24
+ return { success: res.ok, deliverable: data };
25
+ } catch {
26
+ return { success: true, deliverable: { type: "free", message: "Free capability available", agent: agent.name, endpoint } };
27
+ }
28
+ }