@cavos/cli 0.0.7 → 0.1.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @cavos/cli
2
2
 
3
- **Cavos CLI** is the ultimate toolkit for AI Agents to interact with Starknet. It provides a session-key based wallet interface designed for both human manual use and autonomous agent execution.
3
+ **Cavos CLI** is the ultimate toolkit for AI Agents to interact with Starknet (Mainnet). It provides a session-key based wallet interface designed for both human manual use and autonomous agent execution.
4
4
 
5
5
  ## Features
6
6
 
@@ -31,7 +31,7 @@ Before acting, you need a session token. You can generate one from your Cavos Da
31
31
 
32
32
  1. **Import Session:**
33
33
  ```bash
34
- cavos session import "eyJhbG..." --app-id "YOUR_APP_ID"
34
+ cavos session import "eyJhbG..."
35
35
  ```
36
36
 
37
37
  2. **Verify Status:**
package/dist/cli.js CHANGED
@@ -712,7 +712,7 @@ async function getBalance(provider, tokenAddress, walletAddress) {
712
712
  contractAddress: tokenAddress,
713
713
  entrypoint: "balanceOf",
714
714
  calldata: [walletAddress]
715
- });
715
+ }, "latest");
716
716
  const low = BigInt(result[0]);
717
717
  const high = BigInt(result[1]);
718
718
  return low + (high << 128n);
@@ -1515,20 +1515,19 @@ var tools_default = [
1515
1515
 
1516
1516
  // src/cli.ts
1517
1517
  var program = new import_commander.Command();
1518
- program.name("cavos").description("Cavos CLI \u2014 AI agent wallet toolkit for Starknet").version("0.0.7");
1518
+ program.name("cavos").description("Cavos CLI \u2014 AI agent wallet toolkit for Starknet").version("0.1.0");
1519
1519
  var DEFAULT_APP_ID = "0c3ff58a-1968-41c2-b0e0-a5c47309e77d";
1520
- var DEFAULT_NETWORK = "mainnet";
1521
1520
  function getAgent(opts) {
1522
1521
  const config = loadConfig();
1523
1522
  const appId = opts.appId || config.defaultAppId || process.env.CAVOS_APP_ID || DEFAULT_APP_ID;
1524
- const network = opts.network || config.network || process.env.CAVOS_NETWORK || DEFAULT_NETWORK;
1523
+ const network = "mainnet";
1525
1524
  const policy2 = loadPolicy();
1526
1525
  return new CavosAgent({ appId, network, policy: policy2 });
1527
1526
  }
1528
- function resolveToken(symbol, network) {
1529
- if (!symbol) return network === "mainnet" ? TOKENS_MAINNET.STRK : TOKENS_SEPOLIA.STRK;
1527
+ function resolveToken(symbol) {
1528
+ if (!symbol) return TOKENS_MAINNET.STRK;
1530
1529
  const upper = symbol.toUpperCase();
1531
- const tokens = network === "mainnet" ? TOKENS_MAINNET : TOKENS_SEPOLIA;
1530
+ const tokens = TOKENS_MAINNET;
1532
1531
  if (upper === "STRK") return tokens.STRK;
1533
1532
  if (upper === "ETH") return tokens.ETH;
1534
1533
  return symbol;
@@ -1571,7 +1570,7 @@ async function waitForTx(agent, txHash, timeoutMs = 12e4) {
1571
1570
  }
1572
1571
  throw new Error(`Transaction confirmation timeout after ${timeoutMs / 1e3}s`);
1573
1572
  }
1574
- program.command("whoami").description("Show current session info").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--json", "Output as JSON").action(async (opts) => {
1573
+ program.command("whoami").description("Show current session info").option("--app-id <appId>", "App ID").option("--json", "Output as JSON").action(async (opts) => {
1575
1574
  try {
1576
1575
  const agent = getAgent(opts);
1577
1576
  const mode = process.env.CAVOS_TOKEN || process.env.CAVOS_SESSION_TOKEN ? "env" : "disk";
@@ -1608,13 +1607,11 @@ program.command("whoami").description("Show current session info").option("--app
1608
1607
  outError(opts.json, err.message);
1609
1608
  }
1610
1609
  });
1611
- program.command("transfer").description("Transfer ERC-20 tokens").requiredOption("--to <address>", "Recipient address").requiredOption("--amount <amount>", "Amount in human-readable units (e.g. 1.5)").option("--token <token>", "Token symbol (STRK, ETH) or address", "STRK").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1610
+ program.command("transfer").description("Transfer ERC-20 tokens").requiredOption("--to <address>", "Recipient address").requiredOption("--amount <amount>", "Amount in human-readable units (e.g. 1.5)").option("--token <token>", "Token symbol (STRK, ETH) or address", "STRK").option("--app-id <appId>", "App ID").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1612
1611
  try {
1613
1612
  const agent = getAgent(opts);
1614
1613
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
1615
- const config = loadConfig();
1616
- const network = opts.network || config.network || DEFAULT_NETWORK;
1617
- const tokenAddress = resolveToken(opts.token, network);
1614
+ const tokenAddress = resolveToken(opts.token);
1618
1615
  const amount = BigInt(Math.floor(parseFloat(opts.amount) * 1e18));
1619
1616
  if (!opts.json) console.log(`Transferring ${opts.amount} ${opts.token} to ${opts.to}...`);
1620
1617
  const txHash = await agent.transfer(tokenAddress, opts.to, amount);
@@ -1622,7 +1619,7 @@ program.command("transfer").description("Transfer ERC-20 tokens").requiredOption
1622
1619
  if (!opts.json) console.log("Waiting for confirmation...");
1623
1620
  await waitForTx(agent, txHash);
1624
1621
  }
1625
- const explorerBase = network === "mainnet" ? "https://voyager.online/tx" : "https://sepolia.voyager.online/tx";
1622
+ const explorerBase = "https://voyager.online/tx";
1626
1623
  out(opts.json, { status: "ok", transaction_hash: txHash, explorer: `${explorerBase}/${txHash}` }, () => {
1627
1624
  console.log(`Transaction: ${txHash}`);
1628
1625
  console.log(`Explorer: ${explorerBase}/${txHash}`);
@@ -1631,13 +1628,11 @@ program.command("transfer").description("Transfer ERC-20 tokens").requiredOption
1631
1628
  outError(opts.json, err.message, "TransferFailed");
1632
1629
  }
1633
1630
  });
1634
- program.command("approve").description("Approve ERC-20 spending").requiredOption("--spender <address>", "Spender address").requiredOption("--amount <amount>", "Amount in human-readable units").option("--token <token>", "Token symbol or address", "STRK").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1631
+ program.command("approve").description("Approve ERC-20 spending").requiredOption("--spender <address>", "Spender address").requiredOption("--amount <amount>", "Amount in human-readable units").option("--token <token>", "Token symbol or address", "STRK").option("--app-id <appId>", "App ID").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1635
1632
  try {
1636
1633
  const agent = getAgent(opts);
1637
1634
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
1638
- const config = loadConfig();
1639
- const network = opts.network || config.network || DEFAULT_NETWORK;
1640
- const tokenAddress = resolveToken(opts.token, network);
1635
+ const tokenAddress = resolveToken(opts.token);
1641
1636
  const amount = BigInt(Math.floor(parseFloat(opts.amount) * 1e18));
1642
1637
  if (!opts.json) console.log(`Approving ${opts.amount} ${opts.token} for ${opts.spender}...`);
1643
1638
  const txHash = await agent.approve(tokenAddress, opts.spender, amount);
@@ -1645,7 +1640,7 @@ program.command("approve").description("Approve ERC-20 spending").requiredOption
1645
1640
  if (!opts.json) console.log("Waiting for confirmation...");
1646
1641
  await waitForTx(agent, txHash);
1647
1642
  }
1648
- const explorerBase = network === "mainnet" ? "https://voyager.online/tx" : "https://sepolia.voyager.online/tx";
1643
+ const explorerBase = "https://voyager.online/tx";
1649
1644
  out(opts.json, { status: "ok", transaction_hash: txHash, explorer: `${explorerBase}/${txHash}` }, () => {
1650
1645
  console.log(`Transaction: ${txHash}`);
1651
1646
  console.log(`Explorer: ${explorerBase}/${txHash}`);
@@ -1654,20 +1649,18 @@ program.command("approve").description("Approve ERC-20 spending").requiredOption
1654
1649
  outError(opts.json, err.message, "ApproveFailed");
1655
1650
  }
1656
1651
  });
1657
- program.command("execute").description("Execute a raw contract call").requiredOption("--contract <address>", "Contract address").requiredOption("--entrypoint <name>", "Entrypoint name").option("--calldata <data>", "Comma-separated calldata values").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1652
+ program.command("execute").description("Execute a raw contract call").requiredOption("--contract <address>", "Contract address").requiredOption("--entrypoint <name>", "Entrypoint name").option("--calldata <data>", "Comma-separated calldata values").option("--app-id <appId>", "App ID").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1658
1653
  try {
1659
1654
  const agent = getAgent(opts);
1660
1655
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
1661
1656
  const calldata = opts.calldata ? opts.calldata.split(",").map((s) => s.trim()) : [];
1662
- const config = loadConfig();
1663
- const network = opts.network || config.network || DEFAULT_NETWORK;
1664
1657
  if (!opts.json) console.log(`Executing ${opts.entrypoint} on ${opts.contract}...`);
1665
1658
  const txHash = await agent.execute({ contractAddress: opts.contract, entrypoint: opts.entrypoint, calldata });
1666
1659
  if (opts.wait) {
1667
1660
  if (!opts.json) console.log("Waiting for confirmation...");
1668
1661
  await waitForTx(agent, txHash);
1669
1662
  }
1670
- const explorerBase = network === "mainnet" ? "https://voyager.online/tx" : "https://sepolia.voyager.online/tx";
1663
+ const explorerBase = "https://voyager.online/tx";
1671
1664
  out(opts.json, { status: "ok", transaction_hash: txHash, explorer: `${explorerBase}/${txHash}` }, () => {
1672
1665
  console.log(`Transaction: ${txHash}`);
1673
1666
  console.log(`Explorer: ${explorerBase}/${txHash}`);
@@ -1676,7 +1669,7 @@ program.command("execute").description("Execute a raw contract call").requiredOp
1676
1669
  outError(opts.json, err.message, "ExecuteFailed");
1677
1670
  }
1678
1671
  });
1679
- program.command("multicall").description("Execute multiple contract calls in one transaction").requiredOption("--calls <json>", 'JSON array of calls: [{"contractAddress":"0x...","entrypoint":"fn","calldata":["0x..."]}]').option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1672
+ program.command("multicall").description("Execute multiple contract calls in one transaction").requiredOption("--calls <json>", 'JSON array of calls: [{"contractAddress":"0x...","entrypoint":"fn","calldata":["0x..."]}]').option("--app-id <appId>", "App ID").option("--wait", "Wait for on-chain confirmation").option("--json", "Output as JSON").action(async (opts) => {
1680
1673
  try {
1681
1674
  const agent = getAgent(opts);
1682
1675
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
@@ -1688,15 +1681,13 @@ program.command("multicall").description("Execute multiple contract calls in one
1688
1681
  outError(opts.json, `Invalid --calls JSON: ${e.message}`, "InvalidInput");
1689
1682
  return;
1690
1683
  }
1691
- const config = loadConfig();
1692
- const network = opts.network || config.network || DEFAULT_NETWORK;
1693
1684
  if (!opts.json) console.log(`Executing ${calls.length} calls...`);
1694
1685
  const txHash = await agent.execute(calls);
1695
1686
  if (opts.wait) {
1696
1687
  if (!opts.json) console.log("Waiting for confirmation...");
1697
1688
  await waitForTx(agent, txHash);
1698
1689
  }
1699
- const explorerBase = network === "mainnet" ? "https://voyager.online/tx" : "https://sepolia.voyager.online/tx";
1690
+ const explorerBase = "https://voyager.online/tx";
1700
1691
  out(opts.json, { status: "ok", transaction_hash: txHash, call_count: calls.length, explorer: `${explorerBase}/${txHash}` }, () => {
1701
1692
  console.log(`Transaction: ${txHash}`);
1702
1693
  console.log(`Explorer: ${explorerBase}/${txHash}`);
@@ -1705,7 +1696,7 @@ program.command("multicall").description("Execute multiple contract calls in one
1705
1696
  outError(opts.json, err.message, "MulticallFailed");
1706
1697
  }
1707
1698
  });
1708
- program.command("deploy").description("Deploy the account contract").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--json", "Output as JSON").action(async (opts) => {
1699
+ program.command("deploy").description("Deploy the account contract").option("--app-id <appId>", "App ID").option("--json", "Output as JSON").action(async (opts) => {
1709
1700
  try {
1710
1701
  const agent = getAgent(opts);
1711
1702
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
@@ -1724,15 +1715,13 @@ program.command("deploy").description("Deploy the account contract").option("--a
1724
1715
  outError(opts.json, err.message, "DeployFailed");
1725
1716
  }
1726
1717
  });
1727
- program.command("balance").description("Show token balance").option("--token <token>", "Token symbol or address").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--json", "Output as JSON").action(async (opts) => {
1718
+ program.command("balance").description("Show token balance").option("--token <token>", "Token symbol or address").option("--app-id <appId>", "App ID").option("--json", "Output as JSON").action(async (opts) => {
1728
1719
  try {
1729
1720
  const agent = getAgent(opts);
1730
1721
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
1731
- const config = loadConfig();
1732
- const network = opts.network || config.network || DEFAULT_NETWORK;
1733
- const tokens = network === "mainnet" ? TOKENS_MAINNET : TOKENS_SEPOLIA;
1722
+ const tokens = TOKENS_MAINNET;
1734
1723
  if (opts.token) {
1735
- const tokenAddress = resolveToken(opts.token, network);
1724
+ const tokenAddress = resolveToken(opts.token);
1736
1725
  const balance = await agent.getBalance(tokenAddress);
1737
1726
  out(opts.json, { status: "ok", token: opts.token, balance: formatBalance(balance), raw: balance.toString() }, () => {
1738
1727
  console.log(`${opts.token}: ${formatBalance(balance)}`);
@@ -1754,7 +1743,7 @@ program.command("balance").description("Show token balance").option("--token <to
1754
1743
  outError(opts.json, err.message);
1755
1744
  }
1756
1745
  });
1757
- program.command("session-status").description("Show on-chain session status").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--json", "Output as JSON").action(async (opts) => {
1746
+ program.command("session-status").description("Show on-chain session status").option("--app-id <appId>", "App ID").option("--json", "Output as JSON").action(async (opts) => {
1758
1747
  try {
1759
1748
  const agent = getAgent(opts);
1760
1749
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
@@ -1778,7 +1767,7 @@ program.command("session-status").description("Show on-chain session status").op
1778
1767
  }
1779
1768
  });
1780
1769
  var session = program.command("session").description("Manage agent sessions");
1781
- session.command("import").description("Import an agent session token provisioned from the Dashboard").argument("<token>", "Base64 encoded session token").option("--app-id <appId>", "App ID to associate with this session").option("--network <network>", "Network (mainnet | sepolia)").option("--json", "Output as JSON").action((token, opts) => {
1770
+ session.command("import").description("Import an agent session token provisioned from the Dashboard").argument("<token>", "Base64 encoded session token").option("--app-id <appId>", "App ID to associate with this session").option("--json", "Output as JSON").action((token, opts) => {
1782
1771
  try {
1783
1772
  const decoded = Buffer.from(token, "base64").toString();
1784
1773
  const sessionData = JSON.parse(decoded);
@@ -1787,12 +1776,10 @@ session.command("import").description("Import an agent session token provisioned
1787
1776
  }
1788
1777
  const config = loadConfig();
1789
1778
  const appId = opts.appId || config.defaultAppId || DEFAULT_APP_ID;
1790
- const network = opts.network || config.network || DEFAULT_NETWORK;
1791
1779
  saveSession(appId, sessionData);
1792
- saveConfig({ defaultAppId: appId, network });
1793
- out(opts.json, { status: "ok", address: sessionData.walletAddress, app_id: appId, network }, () => {
1780
+ saveConfig({ defaultAppId: appId });
1781
+ out(opts.json, { status: "ok", address: sessionData.walletAddress, app_id: appId }, () => {
1794
1782
  console.log(`Session imported: ${sessionData.walletAddress}`);
1795
- console.log(`App ID: ${appId} | Network: ${network}`);
1796
1783
  });
1797
1784
  } catch (err) {
1798
1785
  if (opts.json) {
@@ -1802,7 +1789,7 @@ session.command("import").description("Import an agent session token provisioned
1802
1789
  }
1803
1790
  }
1804
1791
  });
1805
- program.command("revoke-session").description("Revoke a session key (requires active session)").option("--key <sessionKey>", "Specific session key to revoke (defaults to current)").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--json", "Output as JSON").action(async (opts) => {
1792
+ program.command("revoke-session").description("Revoke a session key (requires active session)").option("--key <sessionKey>", "Specific session key to revoke (defaults to current)").option("--app-id <appId>", "App ID").option("--json", "Output as JSON").action(async (opts) => {
1806
1793
  try {
1807
1794
  const agent = getAgent(opts);
1808
1795
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");
@@ -1816,7 +1803,7 @@ program.command("revoke-session").description("Revoke a session key (requires ac
1816
1803
  outError(opts.json, err.message, code);
1817
1804
  }
1818
1805
  });
1819
- program.command("emergency-revoke").description("Emergency revoke all sessions").option("--app-id <appId>", "App ID").option("--network <network>", "Network").option("--json", "Output as JSON").action(async (opts) => {
1806
+ program.command("emergency-revoke").description("Emergency revoke all sessions").option("--app-id <appId>", "App ID").option("--json", "Output as JSON").action(async (opts) => {
1820
1807
  try {
1821
1808
  const agent = getAgent(opts);
1822
1809
  if (!agent.isAuthenticated()) outError(opts.json, "No session. Import one: cavos session import <token>", "NoSession");