arc402-cli 0.4.3 → 0.6.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/client.d.ts.map +1 -1
- package/dist/client.js +3 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +6 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/wallet.d.ts.map +1 -1
- package/dist/commands/wallet.js +414 -20
- package/dist/commands/wallet.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +22 -111
- package/dist/index.js.map +1 -1
- package/dist/program.d.ts +3 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +85 -0
- package/dist/program.js.map +1 -0
- package/dist/repl.d.ts +2 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +669 -0
- package/dist/repl.js.map +1 -0
- package/dist/ui/banner.d.ts +2 -0
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +27 -18
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/spinner.d.ts.map +1 -1
- package/dist/ui/spinner.js +11 -0
- package/dist/ui/spinner.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +3 -1
- package/src/commands/config.ts +6 -0
- package/src/commands/wallet.ts +458 -32
- package/src/config.ts +1 -0
- package/src/index.ts +22 -115
- package/src/program.ts +83 -0
- package/src/repl.ts +793 -0
- package/src/ui/banner.ts +26 -19
- package/src/ui/spinner.ts +10 -0
package/src/index.ts
CHANGED
|
@@ -1,119 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import path from "path";
|
|
5
|
-
import os from "os";
|
|
6
|
-
import { registerAcceptCommand } from "./commands/accept";
|
|
7
|
-
import { registerAgentCommands } from "./commands/agent";
|
|
8
|
-
import { registerAgreementsCommands } from "./commands/agreements";
|
|
9
|
-
import { registerArbitratorCommand } from "./commands/arbitrator";
|
|
10
|
-
import { registerCancelCommand } from "./commands/cancel";
|
|
11
|
-
import { registerChannelCommands } from "./commands/channel";
|
|
12
|
-
import { registerConfigCommands } from "./commands/config";
|
|
13
|
-
import { registerDeliverCommand } from "./commands/deliver";
|
|
14
|
-
import { registerDiscoverCommand } from "./commands/discover";
|
|
15
|
-
import { registerEndpointCommands } from "./commands/endpoint";
|
|
16
|
-
import { registerDisputeCommand } from "./commands/dispute";
|
|
17
|
-
import { registerHireCommand } from "./commands/hire";
|
|
18
|
-
import { registerHandshakeCommand } from "./commands/agent-handshake";
|
|
19
|
-
import { registerNegotiateCommands } from "./commands/negotiate";
|
|
20
|
-
import { registerRelayCommands } from "./commands/relay";
|
|
21
|
-
import { registerRemediateCommands } from "./commands/remediate";
|
|
22
|
-
import { registerDaemonCommands } from "./commands/daemon";
|
|
23
|
-
import { registerOpenShellCommands } from "./commands/openshell";
|
|
24
|
-
import { registerWorkroomCommands } from "./commands/workroom";
|
|
25
|
-
import { registerArenaHandshakeCommands } from "./commands/arena-handshake";
|
|
26
|
-
import { registerTrustCommand } from "./commands/trust";
|
|
27
|
-
import { registerWalletCommands } from "./commands/wallet";
|
|
28
|
-
import { renderBanner } from "./ui/banner";
|
|
29
|
-
import { registerOwnerCommands } from "./commands/owner";
|
|
30
|
-
import { registerSetupCommands } from "./commands/setup";
|
|
31
|
-
import { registerVerifyCommand } from "./commands/verify";
|
|
32
|
-
import { registerContractInteractionCommands } from "./commands/contract-interaction";
|
|
33
|
-
import { registerWatchtowerCommands } from "./commands/watchtower";
|
|
34
|
-
import { registerColdStartCommands } from "./commands/coldstart";
|
|
35
|
-
import { registerMigrateCommands } from "./commands/migrate";
|
|
36
|
-
import { registerFeedCommand } from "./commands/feed";
|
|
37
|
-
import { registerArenaCommands } from "./commands/arena";
|
|
38
|
-
import { registerWatchCommand } from "./commands/watch";
|
|
39
|
-
import reputation from "./commands/reputation.js";
|
|
40
|
-
import policy from "./commands/policy.js";
|
|
41
|
-
import { BannerConfig } from "./ui/banner";
|
|
2
|
+
import { createProgram } from "./program";
|
|
3
|
+
import { startREPL } from "./repl";
|
|
42
4
|
|
|
43
|
-
|
|
44
|
-
if (process.argv.length <= 2) {
|
|
45
|
-
void (async () => {
|
|
46
|
-
const CONFIG_PATH = path.join(os.homedir(), ".arc402", "config.json");
|
|
47
|
-
let bannerCfg: BannerConfig | undefined;
|
|
5
|
+
const printMode = process.argv.includes("--print");
|
|
48
6
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
})();
|
|
7
|
+
if (printMode) {
|
|
8
|
+
// --print mode: skip REPL entirely, suppress ANSI/spinners, run command, exit.
|
|
9
|
+
// Used by OpenClaw agents running arc402 commands via ACP.
|
|
10
|
+
process.argv = process.argv.filter((a) => a !== "--print");
|
|
11
|
+
process.env["NO_COLOR"] = "1";
|
|
12
|
+
process.env["FORCE_COLOR"] = "0";
|
|
13
|
+
process.env["ARC402_PRINT"] = "1";
|
|
14
|
+
const program = createProgram();
|
|
15
|
+
void program.parseAsync(process.argv).then(() => process.exit(0)).catch((e: unknown) => {
|
|
16
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
17
|
+
process.exit(1);
|
|
18
|
+
});
|
|
19
|
+
} else if (process.argv.length <= 2) {
|
|
20
|
+
// No subcommand — enter interactive REPL
|
|
21
|
+
void startREPL();
|
|
79
22
|
} else {
|
|
80
|
-
|
|
81
|
-
const program =
|
|
82
|
-
program.
|
|
83
|
-
|
|
84
|
-
registerHandshakeCommand(program);
|
|
85
|
-
registerAgentCommands(program);
|
|
86
|
-
registerDiscoverCommand(program);
|
|
87
|
-
registerEndpointCommands(program);
|
|
88
|
-
registerNegotiateCommands(program);
|
|
89
|
-
registerHireCommand(program);
|
|
90
|
-
registerAgreementsCommands(program);
|
|
91
|
-
registerAcceptCommand(program);
|
|
92
|
-
registerDeliverCommand(program);
|
|
93
|
-
registerRemediateCommands(program);
|
|
94
|
-
registerDisputeCommand(program);
|
|
95
|
-
registerArbitratorCommand(program);
|
|
96
|
-
registerCancelCommand(program);
|
|
97
|
-
registerChannelCommands(program);
|
|
98
|
-
registerRelayCommands(program);
|
|
99
|
-
registerDaemonCommands(program);
|
|
100
|
-
registerOpenShellCommands(program);
|
|
101
|
-
registerWorkroomCommands(program);
|
|
102
|
-
registerArenaHandshakeCommands(program);
|
|
103
|
-
registerTrustCommand(program);
|
|
104
|
-
registerWalletCommands(program);
|
|
105
|
-
registerOwnerCommands(program);
|
|
106
|
-
registerSetupCommands(program);
|
|
107
|
-
registerVerifyCommand(program);
|
|
108
|
-
registerContractInteractionCommands(program);
|
|
109
|
-
registerWatchtowerCommands(program);
|
|
110
|
-
registerColdStartCommands(program);
|
|
111
|
-
registerMigrateCommands(program);
|
|
112
|
-
registerFeedCommand(program);
|
|
113
|
-
registerArenaCommands(program);
|
|
114
|
-
registerWatchCommand(program);
|
|
115
|
-
program.addCommand(reputation);
|
|
116
|
-
program.addCommand(policy);
|
|
117
|
-
program.parse(process.argv);
|
|
118
|
-
|
|
119
|
-
} // end else (has arguments)
|
|
23
|
+
// One-shot mode — arc402 wallet deploy still works as usual
|
|
24
|
+
const program = createProgram();
|
|
25
|
+
program.parse(process.argv);
|
|
26
|
+
}
|
package/src/program.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { registerAcceptCommand } from "./commands/accept";
|
|
3
|
+
import { registerAgentCommands } from "./commands/agent";
|
|
4
|
+
import { registerAgreementsCommands } from "./commands/agreements";
|
|
5
|
+
import { registerArbitratorCommand } from "./commands/arbitrator";
|
|
6
|
+
import { registerCancelCommand } from "./commands/cancel";
|
|
7
|
+
import { registerChannelCommands } from "./commands/channel";
|
|
8
|
+
import { registerConfigCommands } from "./commands/config";
|
|
9
|
+
import { registerDeliverCommand } from "./commands/deliver";
|
|
10
|
+
import { registerDiscoverCommand } from "./commands/discover";
|
|
11
|
+
import { registerEndpointCommands } from "./commands/endpoint";
|
|
12
|
+
import { registerDisputeCommand } from "./commands/dispute";
|
|
13
|
+
import { registerHireCommand } from "./commands/hire";
|
|
14
|
+
import { registerHandshakeCommand } from "./commands/agent-handshake";
|
|
15
|
+
import { registerNegotiateCommands } from "./commands/negotiate";
|
|
16
|
+
import { registerRelayCommands } from "./commands/relay";
|
|
17
|
+
import { registerRemediateCommands } from "./commands/remediate";
|
|
18
|
+
import { registerDaemonCommands } from "./commands/daemon";
|
|
19
|
+
import { registerOpenShellCommands } from "./commands/openshell";
|
|
20
|
+
import { registerWorkroomCommands } from "./commands/workroom";
|
|
21
|
+
import { registerArenaHandshakeCommands } from "./commands/arena-handshake";
|
|
22
|
+
import { registerTrustCommand } from "./commands/trust";
|
|
23
|
+
import { registerWalletCommands } from "./commands/wallet";
|
|
24
|
+
import { registerOwnerCommands } from "./commands/owner";
|
|
25
|
+
import { registerSetupCommands } from "./commands/setup";
|
|
26
|
+
import { registerVerifyCommand } from "./commands/verify";
|
|
27
|
+
import { registerContractInteractionCommands } from "./commands/contract-interaction";
|
|
28
|
+
import { registerWatchtowerCommands } from "./commands/watchtower";
|
|
29
|
+
import { registerColdStartCommands } from "./commands/coldstart";
|
|
30
|
+
import { registerMigrateCommands } from "./commands/migrate";
|
|
31
|
+
import { registerFeedCommand } from "./commands/feed";
|
|
32
|
+
import { registerArenaCommands } from "./commands/arena";
|
|
33
|
+
import { registerWatchCommand } from "./commands/watch";
|
|
34
|
+
import reputation from "./commands/reputation.js";
|
|
35
|
+
import policy from "./commands/policy.js";
|
|
36
|
+
|
|
37
|
+
export function createProgram(): Command {
|
|
38
|
+
const program = new Command();
|
|
39
|
+
program
|
|
40
|
+
.name("arc402")
|
|
41
|
+
.description(
|
|
42
|
+
"ARC-402 CLI aligned to canonical-capability discovery → negotiate → hire → remediate → dispute workflow"
|
|
43
|
+
)
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
45
|
+
.version((require("../package.json") as { version: string }).version);
|
|
46
|
+
|
|
47
|
+
registerConfigCommands(program);
|
|
48
|
+
registerHandshakeCommand(program);
|
|
49
|
+
registerAgentCommands(program);
|
|
50
|
+
registerDiscoverCommand(program);
|
|
51
|
+
registerEndpointCommands(program);
|
|
52
|
+
registerNegotiateCommands(program);
|
|
53
|
+
registerHireCommand(program);
|
|
54
|
+
registerAgreementsCommands(program);
|
|
55
|
+
registerAcceptCommand(program);
|
|
56
|
+
registerDeliverCommand(program);
|
|
57
|
+
registerRemediateCommands(program);
|
|
58
|
+
registerDisputeCommand(program);
|
|
59
|
+
registerArbitratorCommand(program);
|
|
60
|
+
registerCancelCommand(program);
|
|
61
|
+
registerChannelCommands(program);
|
|
62
|
+
registerRelayCommands(program);
|
|
63
|
+
registerDaemonCommands(program);
|
|
64
|
+
registerOpenShellCommands(program);
|
|
65
|
+
registerWorkroomCommands(program);
|
|
66
|
+
registerArenaHandshakeCommands(program);
|
|
67
|
+
registerTrustCommand(program);
|
|
68
|
+
registerWalletCommands(program);
|
|
69
|
+
registerOwnerCommands(program);
|
|
70
|
+
registerSetupCommands(program);
|
|
71
|
+
registerVerifyCommand(program);
|
|
72
|
+
registerContractInteractionCommands(program);
|
|
73
|
+
registerWatchtowerCommands(program);
|
|
74
|
+
registerColdStartCommands(program);
|
|
75
|
+
registerMigrateCommands(program);
|
|
76
|
+
registerFeedCommand(program);
|
|
77
|
+
registerArenaCommands(program);
|
|
78
|
+
registerWatchCommand(program);
|
|
79
|
+
program.addCommand(reputation);
|
|
80
|
+
program.addCommand(policy);
|
|
81
|
+
|
|
82
|
+
return program;
|
|
83
|
+
}
|