arc402-cli 0.3.3 → 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.
- package/dist/commands/accept.d.ts.map +1 -1
- package/dist/commands/accept.js +17 -7
- package/dist/commands/accept.js.map +1 -1
- package/dist/commands/agent-handshake.d.ts.map +1 -1
- package/dist/commands/agent-handshake.js +9 -4
- package/dist/commands/agent-handshake.js.map +1 -1
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +14 -8
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/agreements.d.ts.map +1 -1
- package/dist/commands/agreements.js +51 -26
- package/dist/commands/agreements.js.map +1 -1
- package/dist/commands/arbitrator.d.ts.map +1 -1
- package/dist/commands/arbitrator.js +15 -7
- package/dist/commands/arbitrator.js.map +1 -1
- package/dist/commands/arena-handshake.d.ts.map +1 -1
- package/dist/commands/arena-handshake.js +14 -11
- package/dist/commands/arena-handshake.js.map +1 -1
- package/dist/commands/channel.d.ts.map +1 -1
- package/dist/commands/channel.js +27 -17
- package/dist/commands/channel.js.map +1 -1
- package/dist/commands/coldstart.d.ts.map +1 -1
- package/dist/commands/coldstart.js +33 -22
- package/dist/commands/coldstart.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +33 -17
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +44 -37
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/endpoint.d.ts.map +1 -1
- package/dist/commands/endpoint.js +4 -3
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/feed.d.ts.map +1 -1
- package/dist/commands/feed.js.map +1 -1
- package/dist/commands/hire.d.ts.map +1 -1
- package/dist/commands/hire.js +3 -0
- package/dist/commands/hire.js.map +1 -1
- package/dist/commands/owner.d.ts.map +1 -1
- package/dist/commands/owner.js +5 -1
- package/dist/commands/owner.js.map +1 -1
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/relay.d.ts.map +1 -1
- package/dist/commands/relay.js.map +1 -1
- package/dist/commands/remediate.d.ts.map +1 -1
- package/dist/commands/remediate.js.map +1 -1
- package/dist/commands/reputation.d.ts.map +1 -1
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/trust.d.ts.map +1 -1
- package/dist/commands/trust.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/wallet.d.ts.map +1 -1
- package/dist/commands/wallet.js +15 -5
- package/dist/commands/wallet.js.map +1 -1
- package/dist/commands/watch.d.ts +3 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +23 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/watchtower.d.ts.map +1 -1
- package/dist/commands/watchtower.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -2
- package/dist/config.js.map +1 -1
- package/dist/index.js +73 -38
- package/dist/index.js.map +1 -1
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +4 -2
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/tree.d.ts +7 -0
- package/dist/ui/tree.d.ts.map +1 -0
- package/dist/ui/tree.js +13 -0
- package/dist/ui/tree.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/accept.ts +19 -10
- package/src/commands/agent-handshake.ts +9 -4
- package/src/commands/agent.ts +15 -6
- package/src/commands/agreements.ts +51 -25
- package/src/commands/arbitrator.ts +26 -10
- package/src/commands/arena-handshake.ts +15 -8
- package/src/commands/channel.ts +27 -17
- package/src/commands/coldstart.ts +29 -20
- package/src/commands/config.ts +33 -17
- package/src/commands/daemon.ts +45 -38
- package/src/commands/endpoint.ts +4 -3
- package/src/commands/feed.ts +1 -0
- package/src/commands/hire.ts +8 -0
- package/src/commands/owner.ts +5 -1
- package/src/commands/policy.ts +3 -0
- package/src/commands/relay.ts +1 -0
- package/src/commands/remediate.ts +2 -0
- package/src/commands/reputation.ts +4 -0
- package/src/commands/trust.ts +3 -0
- package/src/commands/verify.ts +2 -0
- package/src/commands/wallet.ts +15 -5
- package/src/commands/watch.ts +23 -0
- package/src/commands/watchtower.ts +4 -0
- package/src/config.ts +15 -2
- package/src/index.ts +44 -4
- package/src/ui/banner.ts +5 -2
- package/src/ui/tree.ts +16 -0
package/src/commands/wallet.ts
CHANGED
|
@@ -17,6 +17,9 @@ import { clearWCSession } from "../walletconnect-session";
|
|
|
17
17
|
import { handleWalletError } from "../wallet-router";
|
|
18
18
|
import { requestCoinbaseSmartWalletSignature } from "../coinbase-smart-wallet";
|
|
19
19
|
import { sendTelegramMessage } from "../telegram-notify";
|
|
20
|
+
import { renderTree } from "../ui/tree";
|
|
21
|
+
import { startSpinner } from "../ui/spinner";
|
|
22
|
+
import { c } from "../ui/colors";
|
|
20
23
|
|
|
21
24
|
const POLICY_ENGINE_DEFAULT = "0x44102e70c2A366632d98Fe40d892a2501fC7fFF2";
|
|
22
25
|
|
|
@@ -319,7 +322,10 @@ export function registerWalletCommands(program: Command): void {
|
|
|
319
322
|
if (opts.json) {
|
|
320
323
|
console.log(JSON.stringify({ address, balance: formatted, balanceWei: ethBalance.toString() }));
|
|
321
324
|
} else {
|
|
322
|
-
|
|
325
|
+
renderTree([
|
|
326
|
+
{ label: "Address", value: address },
|
|
327
|
+
{ label: "Balance", value: `${formatted} ETH`, last: true },
|
|
328
|
+
]);
|
|
323
329
|
}
|
|
324
330
|
});
|
|
325
331
|
|
|
@@ -665,7 +671,7 @@ export function registerWalletCommands(program: Command): void {
|
|
|
665
671
|
console.warn(" Run `arc402 config set walletConnectProjectId <id>` to enable phone wallet signing.");
|
|
666
672
|
const { signer, address } = await requireSigner(config);
|
|
667
673
|
const factory = new ethers.Contract(factoryAddress, WALLET_FACTORY_ABI, signer);
|
|
668
|
-
|
|
674
|
+
const deploySpinner = startSpinner(`Deploying ARC402Wallet via factory at ${factoryAddress}...`);
|
|
669
675
|
const tx = await factory.createWallet("0x0000000071727De22E5E9d8BAf0edAc6f37da032");
|
|
670
676
|
const receipt = await tx.wait();
|
|
671
677
|
let walletAddress: string | null = null;
|
|
@@ -679,9 +685,10 @@ export function registerWalletCommands(program: Command): void {
|
|
|
679
685
|
} catch { /* skip unparseable logs */ }
|
|
680
686
|
}
|
|
681
687
|
if (!walletAddress) {
|
|
682
|
-
|
|
688
|
+
deploySpinner.fail("Could not find WalletCreated event in receipt. Check the transaction on-chain.");
|
|
683
689
|
process.exit(1);
|
|
684
690
|
}
|
|
691
|
+
deploySpinner.succeed("Wallet deployed");
|
|
685
692
|
|
|
686
693
|
// Generate guardian key (separate from hot key) and call setGuardian
|
|
687
694
|
const guardianWallet = ethers.Wallet.createRandom();
|
|
@@ -712,8 +719,11 @@ export function registerWalletCommands(program: Command): void {
|
|
|
712
719
|
},
|
|
713
720
|
);
|
|
714
721
|
|
|
715
|
-
console.log(`
|
|
716
|
-
|
|
722
|
+
console.log(` ${c.success} ARC402Wallet deployed`);
|
|
723
|
+
renderTree([
|
|
724
|
+
{ label: "Wallet", value: walletAddress },
|
|
725
|
+
{ label: "Guardian", value: guardianWallet.address, last: true },
|
|
726
|
+
]);
|
|
717
727
|
console.log(`Guardian private key saved to config (keep it safe — used for emergency freeze only)`);
|
|
718
728
|
console.log(`Your wallet contract is ready for policy enforcement`);
|
|
719
729
|
printOpenShellHint();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { c } from "../ui/colors";
|
|
3
|
+
import { loadConfig } from "../config";
|
|
4
|
+
|
|
5
|
+
export function registerWatchCommand(program: Command): void {
|
|
6
|
+
program
|
|
7
|
+
.command("watch")
|
|
8
|
+
.description("Watch wallet activity in real-time")
|
|
9
|
+
.action(async () => {
|
|
10
|
+
const config = loadConfig();
|
|
11
|
+
const wallet = config.walletContractAddress ?? "(no wallet)";
|
|
12
|
+
const shortWallet = wallet.length > 10
|
|
13
|
+
? `${wallet.slice(0, 6)}...${wallet.slice(-4)}`
|
|
14
|
+
: wallet;
|
|
15
|
+
const line = "─".repeat(20);
|
|
16
|
+
|
|
17
|
+
console.log(`${c.mark} ARC-402 Watching ${c.white(shortWallet)} ${c.dim(line)}`);
|
|
18
|
+
console.log(`${c.dim("···")} ${c.dim("waiting")}`);
|
|
19
|
+
|
|
20
|
+
// Keep process alive
|
|
21
|
+
process.stdin.resume();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -5,6 +5,10 @@ import * as os from "os";
|
|
|
5
5
|
import { loadConfig } from "../config";
|
|
6
6
|
import { requireSigner, getClient } from "../client";
|
|
7
7
|
import { WatchtowerClient, ChannelClient } from "@arc402/sdk";
|
|
8
|
+
import { c } from '../ui/colors';
|
|
9
|
+
import { startSpinner } from '../ui/spinner';
|
|
10
|
+
import { renderTree } from '../ui/tree';
|
|
11
|
+
import { formatAddress } from '../ui/format';
|
|
8
12
|
|
|
9
13
|
const CHANNEL_STATES_DIR = path.join(os.homedir(), ".arc402", "channel-states");
|
|
10
14
|
|
package/src/config.ts
CHANGED
|
@@ -55,8 +55,21 @@ export const getConfigPath = () => CONFIG_PATH;
|
|
|
55
55
|
|
|
56
56
|
export function loadConfig(): Arc402Config {
|
|
57
57
|
if (!fs.existsSync(CONFIG_PATH)) {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
// Auto-create with Base Mainnet defaults — zero friction
|
|
59
|
+
const defaults = NETWORK_DEFAULTS["base-mainnet"] ?? {};
|
|
60
|
+
const autoConfig: Arc402Config = {
|
|
61
|
+
network: "base-mainnet",
|
|
62
|
+
rpcUrl: defaults.rpcUrl ?? "https://mainnet.base.org",
|
|
63
|
+
trustRegistryAddress: defaults.trustRegistryAddress ?? "",
|
|
64
|
+
agentRegistryAddress: (defaults as Record<string,string>).agentRegistryV2Address ?? defaults.agentRegistryAddress,
|
|
65
|
+
serviceAgreementAddress: defaults.serviceAgreementAddress,
|
|
66
|
+
reputationOracleAddress: defaults.reputationOracleAddress,
|
|
67
|
+
capabilityRegistryAddress: defaults.capabilityRegistryAddress,
|
|
68
|
+
governanceAddress: defaults.governanceAddress,
|
|
69
|
+
};
|
|
70
|
+
saveConfig(autoConfig);
|
|
71
|
+
console.log(`◈ Config auto-created at ${CONFIG_PATH} (Base Mainnet)`);
|
|
72
|
+
return autoConfig;
|
|
60
73
|
}
|
|
61
74
|
return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8")) as Arc402Config;
|
|
62
75
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import os from "os";
|
|
3
6
|
import { registerAcceptCommand } from "./commands/accept";
|
|
4
7
|
import { registerAgentCommands } from "./commands/agent";
|
|
5
8
|
import { registerAgreementsCommands } from "./commands/agreements";
|
|
@@ -32,17 +35,51 @@ import { registerColdStartCommands } from "./commands/coldstart";
|
|
|
32
35
|
import { registerMigrateCommands } from "./commands/migrate";
|
|
33
36
|
import { registerFeedCommand } from "./commands/feed";
|
|
34
37
|
import { registerArenaCommands } from "./commands/arena";
|
|
38
|
+
import { registerWatchCommand } from "./commands/watch";
|
|
35
39
|
import reputation from "./commands/reputation.js";
|
|
36
40
|
import policy from "./commands/policy.js";
|
|
41
|
+
import { BannerConfig } from "./ui/banner";
|
|
37
42
|
|
|
38
43
|
// Show banner when invoked with no arguments
|
|
39
44
|
if (process.argv.length <= 2) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
void (async () => {
|
|
46
|
+
const CONFIG_PATH = path.join(os.homedir(), ".arc402", "config.json");
|
|
47
|
+
let bannerCfg: BannerConfig | undefined;
|
|
48
|
+
|
|
49
|
+
if (fs.existsSync(CONFIG_PATH)) {
|
|
50
|
+
try {
|
|
51
|
+
const raw = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8")) as {
|
|
52
|
+
network?: string;
|
|
53
|
+
walletContractAddress?: string;
|
|
54
|
+
rpcUrl?: string;
|
|
55
|
+
};
|
|
56
|
+
bannerCfg = { network: raw.network };
|
|
57
|
+
if (raw.walletContractAddress) {
|
|
58
|
+
const w = raw.walletContractAddress;
|
|
59
|
+
bannerCfg.wallet = `${w.slice(0, 6)}...${w.slice(-4)}`;
|
|
60
|
+
}
|
|
61
|
+
if (raw.rpcUrl && raw.walletContractAddress) {
|
|
62
|
+
try {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
64
|
+
const ethersLib = require("ethers") as typeof import("ethers");
|
|
65
|
+
const provider = new ethersLib.ethers.JsonRpcProvider(raw.rpcUrl);
|
|
66
|
+
const bal = await Promise.race([
|
|
67
|
+
provider.getBalance(raw.walletContractAddress),
|
|
68
|
+
new Promise<never>((_, r) => setTimeout(() => r(new Error("timeout")), 2000)),
|
|
69
|
+
]);
|
|
70
|
+
bannerCfg.balance = `${parseFloat(ethersLib.ethers.formatEther(bal)).toFixed(4)} ETH`;
|
|
71
|
+
} catch { /* skip balance on error/timeout */ }
|
|
72
|
+
}
|
|
73
|
+
} catch { /* skip config info on parse error */ }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
renderBanner(bannerCfg);
|
|
77
|
+
process.exit(0);
|
|
78
|
+
})();
|
|
79
|
+
} else {
|
|
43
80
|
|
|
44
81
|
const program = new Command();
|
|
45
|
-
program.name("arc402").description("ARC-402 CLI aligned to canonical-capability discovery → negotiate → hire → remediate → dispute workflow").version("
|
|
82
|
+
program.name("arc402").description("ARC-402 CLI aligned to canonical-capability discovery → negotiate → hire → remediate → dispute workflow").version(require("../package.json").version);
|
|
46
83
|
registerConfigCommands(program);
|
|
47
84
|
registerHandshakeCommand(program);
|
|
48
85
|
registerAgentCommands(program);
|
|
@@ -74,6 +111,9 @@ registerColdStartCommands(program);
|
|
|
74
111
|
registerMigrateCommands(program);
|
|
75
112
|
registerFeedCommand(program);
|
|
76
113
|
registerArenaCommands(program);
|
|
114
|
+
registerWatchCommand(program);
|
|
77
115
|
program.addCommand(reputation);
|
|
78
116
|
program.addCommand(policy);
|
|
79
117
|
program.parse(process.argv);
|
|
118
|
+
|
|
119
|
+
} // end else (has arguments)
|
package/src/ui/banner.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
4
|
+
const _pkg = require("../../package.json") as { version: string };
|
|
5
|
+
|
|
3
6
|
const ART = `
|
|
4
7
|
██████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗
|
|
5
8
|
██╔══██╗██╔══██╗██╔════╝ ██║ ██║██╔═══██╗╚════██╗
|
|
@@ -19,7 +22,7 @@ export interface BannerConfig {
|
|
|
19
22
|
export function renderBanner(config?: BannerConfig): void {
|
|
20
23
|
console.log(chalk.cyan(ART));
|
|
21
24
|
console.log();
|
|
22
|
-
console.log(" " + chalk.dim(
|
|
25
|
+
console.log(" " + chalk.dim(`agent-to-agent arcing · v${_pkg.version}`));
|
|
23
26
|
console.log(" " + SEPARATOR);
|
|
24
27
|
|
|
25
28
|
if (config) {
|
|
@@ -36,6 +39,6 @@ export function renderBanner(config?: BannerConfig): void {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
console.log();
|
|
39
|
-
console.log(` ${chalk.dim("Type '
|
|
42
|
+
console.log(` ${chalk.dim("Type 'arc402 help' to get started")}`);
|
|
40
43
|
console.log();
|
|
41
44
|
}
|
package/src/ui/tree.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { c } from "./colors";
|
|
2
|
+
|
|
3
|
+
export interface TreeItem {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
last?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function renderTree(items: TreeItem[]): void {
|
|
10
|
+
items.forEach((item, i) => {
|
|
11
|
+
const isLast = item.last ?? (i === items.length - 1);
|
|
12
|
+
const branch = isLast ? "└" : "├";
|
|
13
|
+
const paddedLabel = item.label.padEnd(10);
|
|
14
|
+
console.log(` ${c.dim(branch)} ${c.dim(paddedLabel)} ${c.white(item.value)}`);
|
|
15
|
+
});
|
|
16
|
+
}
|