arc402-cli 0.7.4 → 0.8.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 (256) hide show
  1. package/MIGRATION-SPEC.md +108 -0
  2. package/dist/abis.js +14 -17
  3. package/dist/abis.js.map +1 -1
  4. package/dist/bundler.d.ts +1 -1
  5. package/dist/bundler.d.ts.map +1 -1
  6. package/dist/bundler.js +27 -61
  7. package/dist/bundler.js.map +1 -1
  8. package/dist/client.d.ts +1 -1
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +5 -9
  11. package/dist/client.js.map +1 -1
  12. package/dist/coinbase-smart-wallet.js +1 -4
  13. package/dist/coinbase-smart-wallet.js.map +1 -1
  14. package/dist/commands/accept.js +25 -28
  15. package/dist/commands/accept.js.map +1 -1
  16. package/dist/commands/agent-handshake.js +15 -18
  17. package/dist/commands/agent-handshake.js.map +1 -1
  18. package/dist/commands/agent.js +98 -104
  19. package/dist/commands/agent.js.map +1 -1
  20. package/dist/commands/agreements.js +62 -98
  21. package/dist/commands/agreements.js.map +1 -1
  22. package/dist/commands/arbitrator.js +45 -81
  23. package/dist/commands/arbitrator.js.map +1 -1
  24. package/dist/commands/arena-handshake.js +27 -30
  25. package/dist/commands/arena-handshake.js.map +1 -1
  26. package/dist/commands/arena.js +12 -18
  27. package/dist/commands/arena.js.map +1 -1
  28. package/dist/commands/backup.js +30 -36
  29. package/dist/commands/backup.js.map +1 -1
  30. package/dist/commands/cancel.js +15 -18
  31. package/dist/commands/cancel.js.map +1 -1
  32. package/dist/commands/channel.js +45 -81
  33. package/dist/commands/channel.js.map +1 -1
  34. package/dist/commands/coldstart.js +31 -34
  35. package/dist/commands/coldstart.js.map +1 -1
  36. package/dist/commands/config.js +23 -29
  37. package/dist/commands/config.js.map +1 -1
  38. package/dist/commands/contract-interaction.js +12 -15
  39. package/dist/commands/contract-interaction.js.map +1 -1
  40. package/dist/commands/daemon.d.ts.map +1 -1
  41. package/dist/commands/daemon.js +98 -135
  42. package/dist/commands/daemon.js.map +1 -1
  43. package/dist/commands/deliver.js +37 -76
  44. package/dist/commands/deliver.js.map +1 -1
  45. package/dist/commands/discover.js +24 -27
  46. package/dist/commands/discover.js.map +1 -1
  47. package/dist/commands/dispute.js +104 -110
  48. package/dist/commands/dispute.js.map +1 -1
  49. package/dist/commands/doctor.js +16 -55
  50. package/dist/commands/doctor.js.map +1 -1
  51. package/dist/commands/endpoint.js +56 -95
  52. package/dist/commands/endpoint.js.map +1 -1
  53. package/dist/commands/feed.js +11 -18
  54. package/dist/commands/feed.js.map +1 -1
  55. package/dist/commands/hire.js +37 -40
  56. package/dist/commands/hire.js.map +1 -1
  57. package/dist/commands/migrate.js +30 -33
  58. package/dist/commands/migrate.js.map +1 -1
  59. package/dist/commands/negotiate.d.ts.map +1 -1
  60. package/dist/commands/negotiate.js +34 -36
  61. package/dist/commands/negotiate.js.map +1 -1
  62. package/dist/commands/openshell.js +68 -104
  63. package/dist/commands/openshell.js.map +1 -1
  64. package/dist/commands/owner.js +17 -20
  65. package/dist/commands/owner.js.map +1 -1
  66. package/dist/commands/policy.js +41 -43
  67. package/dist/commands/policy.js.map +1 -1
  68. package/dist/commands/relay.d.ts.map +1 -1
  69. package/dist/commands/relay.js +18 -51
  70. package/dist/commands/relay.js.map +1 -1
  71. package/dist/commands/remediate.js +20 -23
  72. package/dist/commands/remediate.js.map +1 -1
  73. package/dist/commands/reputation.js +25 -27
  74. package/dist/commands/reputation.js.map +1 -1
  75. package/dist/commands/setup.js +65 -104
  76. package/dist/commands/setup.js.map +1 -1
  77. package/dist/commands/trust.js +17 -20
  78. package/dist/commands/trust.js.map +1 -1
  79. package/dist/commands/verify.js +18 -21
  80. package/dist/commands/verify.js.map +1 -1
  81. package/dist/commands/wallet.js +619 -625
  82. package/dist/commands/wallet.js.map +1 -1
  83. package/dist/commands/watch.js +33 -36
  84. package/dist/commands/watch.js.map +1 -1
  85. package/dist/commands/watchtower.js +37 -73
  86. package/dist/commands/watchtower.js.map +1 -1
  87. package/dist/commands/workroom.d.ts.map +1 -1
  88. package/dist/commands/workroom.js +138 -171
  89. package/dist/commands/workroom.js.map +1 -1
  90. package/dist/config.js +21 -65
  91. package/dist/config.js.map +1 -1
  92. package/dist/daemon/config.d.ts.map +1 -1
  93. package/dist/daemon/config.js +16 -53
  94. package/dist/daemon/config.js.map +1 -1
  95. package/dist/daemon/hire-listener.d.ts +3 -3
  96. package/dist/daemon/hire-listener.d.ts.map +1 -1
  97. package/dist/daemon/hire-listener.js +13 -47
  98. package/dist/daemon/hire-listener.js.map +1 -1
  99. package/dist/daemon/index.d.ts +1 -1
  100. package/dist/daemon/index.d.ts.map +1 -1
  101. package/dist/daemon/index.js +50 -88
  102. package/dist/daemon/index.js.map +1 -1
  103. package/dist/daemon/job-lifecycle.d.ts +1 -1
  104. package/dist/daemon/job-lifecycle.d.ts.map +1 -1
  105. package/dist/daemon/job-lifecycle.js +11 -51
  106. package/dist/daemon/job-lifecycle.js.map +1 -1
  107. package/dist/daemon/notify.d.ts +1 -1
  108. package/dist/daemon/notify.d.ts.map +1 -1
  109. package/dist/daemon/notify.js +19 -53
  110. package/dist/daemon/notify.js.map +1 -1
  111. package/dist/daemon/token-metering.js +8 -47
  112. package/dist/daemon/token-metering.js.map +1 -1
  113. package/dist/daemon/userops.d.ts +2 -2
  114. package/dist/daemon/userops.d.ts.map +1 -1
  115. package/dist/daemon/userops.js +23 -27
  116. package/dist/daemon/userops.js.map +1 -1
  117. package/dist/daemon/wallet-monitor.d.ts +1 -1
  118. package/dist/daemon/wallet-monitor.d.ts.map +1 -1
  119. package/dist/daemon/wallet-monitor.js +8 -12
  120. package/dist/daemon/wallet-monitor.js.map +1 -1
  121. package/dist/drain-v4.js +26 -64
  122. package/dist/drain-v4.js.map +1 -1
  123. package/dist/endpoint-config.js +20 -63
  124. package/dist/endpoint-config.js.map +1 -1
  125. package/dist/endpoint-notify.js +9 -48
  126. package/dist/endpoint-notify.js.map +1 -1
  127. package/dist/index.js +16 -50
  128. package/dist/index.js.map +1 -1
  129. package/dist/openshell-runtime.d.ts.map +1 -1
  130. package/dist/openshell-runtime.js +38 -82
  131. package/dist/openshell-runtime.js.map +1 -1
  132. package/dist/program.d.ts.map +1 -1
  133. package/dist/program.js +77 -83
  134. package/dist/program.js.map +1 -1
  135. package/dist/repl.js +25 -31
  136. package/dist/repl.js.map +1 -1
  137. package/dist/signing.js +3 -6
  138. package/dist/signing.js.map +1 -1
  139. package/dist/telegram-notify.js +3 -40
  140. package/dist/telegram-notify.js.map +1 -1
  141. package/dist/tui/App.d.ts.map +1 -1
  142. package/dist/tui/App.js +44 -50
  143. package/dist/tui/App.js.map +1 -1
  144. package/dist/tui/Footer.js +4 -7
  145. package/dist/tui/Footer.js.map +1 -1
  146. package/dist/tui/Header.js +7 -13
  147. package/dist/tui/Header.js.map +1 -1
  148. package/dist/tui/InputLine.js +17 -23
  149. package/dist/tui/InputLine.js.map +1 -1
  150. package/dist/tui/Viewport.js +5 -8
  151. package/dist/tui/Viewport.js.map +1 -1
  152. package/dist/tui/WalletConnectPairing.d.ts +23 -0
  153. package/dist/tui/WalletConnectPairing.d.ts.map +1 -0
  154. package/dist/tui/WalletConnectPairing.js +75 -0
  155. package/dist/tui/WalletConnectPairing.js.map +1 -0
  156. package/dist/tui/index.d.ts.map +1 -1
  157. package/dist/tui/index.js +14 -21
  158. package/dist/tui/index.js.map +1 -1
  159. package/dist/tui/useChat.js +13 -19
  160. package/dist/tui/useChat.js.map +1 -1
  161. package/dist/tui/useCommand.js +12 -18
  162. package/dist/tui/useCommand.js.map +1 -1
  163. package/dist/tui/useScroll.js +9 -12
  164. package/dist/tui/useScroll.js.map +1 -1
  165. package/dist/ui/banner.js +12 -19
  166. package/dist/ui/banner.js.map +1 -1
  167. package/dist/ui/colors.js +13 -19
  168. package/dist/ui/colors.js.map +1 -1
  169. package/dist/ui/format.js +6 -14
  170. package/dist/ui/format.js.map +1 -1
  171. package/dist/ui/spinner.js +6 -12
  172. package/dist/ui/spinner.js.map +1 -1
  173. package/dist/ui/tree.js +3 -6
  174. package/dist/ui/tree.js.map +1 -1
  175. package/dist/utils/format.js +27 -41
  176. package/dist/utils/format.js.map +1 -1
  177. package/dist/utils/hash.js +4 -42
  178. package/dist/utils/hash.js.map +1 -1
  179. package/dist/utils/time.js +2 -6
  180. package/dist/utils/time.js.map +1 -1
  181. package/dist/wallet-router.d.ts +1 -1
  182. package/dist/wallet-router.d.ts.map +1 -1
  183. package/dist/wallet-router.js +12 -19
  184. package/dist/wallet-router.js.map +1 -1
  185. package/dist/walletconnect-session.d.ts +1 -1
  186. package/dist/walletconnect-session.d.ts.map +1 -1
  187. package/dist/walletconnect-session.js +6 -11
  188. package/dist/walletconnect-session.js.map +1 -1
  189. package/dist/walletconnect.d.ts +6 -1
  190. package/dist/walletconnect.d.ts.map +1 -1
  191. package/dist/walletconnect.js +32 -35
  192. package/dist/walletconnect.js.map +1 -1
  193. package/package.json +7 -6
  194. package/src/bundler.ts +1 -1
  195. package/src/client.ts +1 -1
  196. package/src/commands/accept.ts +7 -7
  197. package/src/commands/agent-handshake.ts +4 -4
  198. package/src/commands/agent.ts +9 -9
  199. package/src/commands/agreements.ts +8 -8
  200. package/src/commands/arbitrator.ts +5 -5
  201. package/src/commands/arena-handshake.ts +6 -6
  202. package/src/commands/arena.ts +2 -2
  203. package/src/commands/backup.ts +1 -1
  204. package/src/commands/cancel.ts +6 -6
  205. package/src/commands/channel.ts +6 -6
  206. package/src/commands/coldstart.ts +5 -5
  207. package/src/commands/config.ts +2 -2
  208. package/src/commands/contract-interaction.ts +2 -2
  209. package/src/commands/daemon.ts +14 -11
  210. package/src/commands/deliver.ts +9 -9
  211. package/src/commands/discover.ts +5 -5
  212. package/src/commands/dispute.ts +7 -7
  213. package/src/commands/doctor.ts +2 -2
  214. package/src/commands/endpoint.ts +6 -6
  215. package/src/commands/feed.ts +1 -1
  216. package/src/commands/hire.ts +10 -10
  217. package/src/commands/migrate.ts +7 -7
  218. package/src/commands/negotiate.ts +6 -5
  219. package/src/commands/openshell.ts +4 -4
  220. package/src/commands/owner.ts +5 -5
  221. package/src/commands/policy.ts +5 -5
  222. package/src/commands/relay.ts +5 -1
  223. package/src/commands/remediate.ts +5 -5
  224. package/src/commands/reputation.ts +6 -6
  225. package/src/commands/setup.ts +1 -1
  226. package/src/commands/trust.ts +6 -6
  227. package/src/commands/verify.ts +6 -6
  228. package/src/commands/wallet.ts +15 -15
  229. package/src/commands/watch.ts +3 -3
  230. package/src/commands/watchtower.ts +6 -6
  231. package/src/commands/workroom.ts +14 -10
  232. package/src/daemon/config.ts +2 -1
  233. package/src/daemon/hire-listener.ts +3 -3
  234. package/src/daemon/index.ts +10 -9
  235. package/src/daemon/job-lifecycle.ts +1 -1
  236. package/src/daemon/notify.ts +4 -4
  237. package/src/daemon/userops.ts +4 -4
  238. package/src/daemon/wallet-monitor.ts +2 -2
  239. package/src/endpoint-notify.ts +1 -1
  240. package/src/index.ts +8 -7
  241. package/src/openshell-runtime.ts +5 -1
  242. package/src/program.ts +36 -36
  243. package/src/repl.ts +3 -3
  244. package/src/tui/App.tsx +15 -10
  245. package/src/tui/Header.tsx +1 -1
  246. package/src/tui/InputLine.tsx +1 -1
  247. package/src/tui/WalletConnectPairing.tsx +131 -0
  248. package/src/tui/index.tsx +7 -8
  249. package/src/tui/useChat.ts +1 -1
  250. package/src/tui/useCommand.ts +4 -4
  251. package/src/ui/banner.ts +2 -2
  252. package/src/ui/tree.ts +1 -1
  253. package/src/wallet-router.ts +2 -2
  254. package/src/walletconnect-session.ts +1 -1
  255. package/src/walletconnect.ts +20 -5
  256. package/tsconfig.json +16 -7
@@ -1,10 +1,10 @@
1
1
  import { Command } from "commander";
2
2
  import { DisputeArbitrationClient } from "@arc402/sdk";
3
- import { loadConfig } from "../config";
4
- import { requireSigner } from "../client";
5
- import { c } from '../ui/colors';
6
- import { startSpinner } from '../ui/spinner';
7
- import { formatAddress } from '../ui/format';
3
+ import { loadConfig } from "../config.js";
4
+ import { requireSigner } from "../client.js";
5
+ import { c } from '../ui/colors.js';
6
+ import { startSpinner } from '../ui/spinner.js';
7
+ import { formatAddress } from '../ui/format.js';
8
8
 
9
9
  export function registerOwnerCommands(program: Command): void {
10
10
  const owner = program.command("owner").description("Protocol ownership management (DisputeArbitration two-step transfer)");
@@ -1,10 +1,10 @@
1
1
  import { Command } from "commander";
2
2
  import { ethers } from "ethers";
3
- import { loadConfig } from "../config";
4
- import { getClient, requireSigner } from "../client";
5
- import { c } from '../ui/colors';
6
- import { startSpinner } from '../ui/spinner';
7
- import { formatAddress } from '../ui/format';
3
+ import { loadConfig } from "../config.js";
4
+ import { getClient, requireSigner } from "../client.js";
5
+ import { c } from '../ui/colors.js';
6
+ import { startSpinner } from '../ui/spinner.js';
7
+ import { formatAddress } from '../ui/format.js';
8
8
 
9
9
  const POLICY_ENGINE_EXTENDED_ABI = [
10
10
  "function addToBlocklist(address wallet, address provider) external",
@@ -5,7 +5,11 @@ import * as os from "os";
5
5
  import * as http from "http";
6
6
  import * as https from "https";
7
7
  import { spawn } from "child_process";
8
- import { c } from '../ui/colors';
8
+ import { c } from '../ui/colors.js';
9
+
10
+ import { fileURLToPath } from "node:url";
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
9
13
 
10
14
  const PID_FILE = path.join(os.homedir(), ".arc402", "relay.pid");
11
15
 
@@ -1,10 +1,10 @@
1
1
  import { Command } from "commander";
2
2
  import { ProviderResponseType, ServiceAgreementClient } from "@arc402/sdk";
3
- import { loadConfig } from "../config";
4
- import { getClient, requireSigner } from "../client";
5
- import { hashFile, hashString } from "../utils/hash";
6
- import { c } from '../ui/colors';
7
- import { startSpinner } from '../ui/spinner';
3
+ import { loadConfig } from "../config.js";
4
+ import { getClient, requireSigner } from "../client.js";
5
+ import { hashFile, hashString } from "../utils/hash.js";
6
+ import { c } from '../ui/colors.js';
7
+ import { startSpinner } from '../ui/spinner.js';
8
8
 
9
9
  export function registerRemediateCommands(program: Command): void {
10
10
  const remediate = program.command("remediate").description("Negotiated remediation before formal dispute");
@@ -1,12 +1,12 @@
1
1
  import { Command } from "commander";
2
2
  import { ReputationOracleClient, ReputationSignalType } from "@arc402/sdk";
3
3
  import { ethers } from "ethers";
4
- import { loadConfig } from "../config";
5
- import { getClient, requireSigner } from "../client";
6
- import { c } from '../ui/colors';
7
- import { startSpinner } from '../ui/spinner';
8
- import { renderTree } from '../ui/tree';
9
- import { formatAddress } from '../ui/format';
4
+ import { loadConfig } from "../config.js";
5
+ import { getClient, requireSigner } from "../client.js";
6
+ import { c } from '../ui/colors.js';
7
+ import { startSpinner } from '../ui/spinner.js';
8
+ import { renderTree } from '../ui/tree.js';
9
+ import { formatAddress } from '../ui/format.js';
10
10
 
11
11
  const reputation = new Command("reputation").description("Network-wide reputation signals");
12
12
 
@@ -3,7 +3,7 @@ import * as net from "net";
3
3
  import { execSync, spawn } from "child_process";
4
4
  import chalk from "chalk";
5
5
  import prompts from "prompts";
6
- import { configExists, loadConfig, getSubdomainApi } from "../config";
6
+ import { configExists, loadConfig, getSubdomainApi } from "../config.js";
7
7
 
8
8
  const DAEMON_PORT = 4402;
9
9
 
@@ -1,11 +1,11 @@
1
1
  import { Command } from "commander";
2
2
  import { ReputationOracleClient, SponsorshipAttestationClient, TrustClient } from "@arc402/sdk";
3
- import { loadConfig } from "../config";
4
- import { getClient } from "../client";
5
- import { getTrustTier, identityTierLabel } from "../utils/format";
6
- import { c } from '../ui/colors';
7
- import { renderTree } from '../ui/tree';
8
- import { formatAddress } from '../ui/format';
3
+ import { loadConfig } from "../config.js";
4
+ import { getClient } from "../client.js";
5
+ import { getTrustTier, identityTierLabel } from "../utils/format.js";
6
+ import { c } from '../ui/colors.js';
7
+ import { renderTree } from '../ui/tree.js';
8
+ import { formatAddress } from '../ui/format.js';
9
9
 
10
10
  export function registerTrustCommand(program: Command): void {
11
11
  program.command("trust <address>").description("Look up trust plus secondary sponsorship/reputation signals for an address").option("--json").action(async (address, opts) => {
@@ -1,12 +1,12 @@
1
1
  import { Command } from "commander";
2
2
  import { ServiceAgreementClient } from "@arc402/sdk";
3
3
  import { ethers } from "ethers";
4
- import { loadConfig } from "../config";
5
- import { getClient, requireSigner } from "../client";
6
- import { printSenderInfo, executeContractWriteViaWallet } from "../wallet-router";
7
- import { SERVICE_AGREEMENT_ABI } from "../abis";
8
- import { c } from '../ui/colors';
9
- import { startSpinner } from '../ui/spinner';
4
+ import { loadConfig } from "../config.js";
5
+ import { getClient, requireSigner } from "../client.js";
6
+ import { printSenderInfo, executeContractWriteViaWallet } from "../wallet-router.js";
7
+ import { SERVICE_AGREEMENT_ABI } from "../abis.js";
8
+ import { c } from '../ui/colors.js';
9
+ import { startSpinner } from '../ui/spinner.js';
10
10
 
11
11
  // Agreement status values from the contract
12
12
  const AGREEMENT_STATUS_NAMES: Record<number, string> = {
@@ -6,21 +6,21 @@ import fs from "fs";
6
6
  import path from "path";
7
7
  import os from "os";
8
8
  import { spawnSync } from "child_process";
9
- import { Arc402Config, getConfigPath, getUsdcAddress, loadConfig, NETWORK_DEFAULTS, saveConfig } from "../config";
10
- import { getClient, requireSigner } from "../client";
11
- import { getTrustTier } from "../utils/format";
12
- import { AGENT_REGISTRY_ABI, ARC402_WALLET_EXECUTE_ABI, ARC402_WALLET_GUARDIAN_ABI, ARC402_WALLET_MACHINE_KEY_ABI, ARC402_WALLET_OWNER_ABI, ARC402_WALLET_PASSKEY_ABI, ARC402_WALLET_PROTOCOL_ABI, ARC402_WALLET_REGISTRY_ABI, POLICY_ENGINE_GOVERNANCE_ABI, POLICY_ENGINE_LIMITS_ABI, TRUST_REGISTRY_ABI, WALLET_FACTORY_ABI } from "../abis";
13
- import { warnIfPublicRpc } from "../config";
14
- import { connectPhoneWallet, sendTransactionWithSession, requestPhoneWalletSignature } from "../walletconnect";
15
- import { BundlerClient, buildSponsoredUserOp, PaymasterClient, DEFAULT_ENTRY_POINT } from "../bundler";
16
- import { clearWCSession } from "../walletconnect-session";
17
- import { handleWalletError } from "../wallet-router";
18
- import { requestCoinbaseSmartWalletSignature } from "../coinbase-smart-wallet";
19
- import { sendTelegramMessage } from "../telegram-notify";
20
- import { renderTree } from "../ui/tree";
21
- import { startSpinner } from "../ui/spinner";
22
- import { c } from "../ui/colors";
23
- import { formatAddress } from "../ui/format";
9
+ import { Arc402Config, getConfigPath, getUsdcAddress, loadConfig, NETWORK_DEFAULTS, saveConfig } from "../config.js";
10
+ import { getClient, requireSigner } from "../client.js";
11
+ import { getTrustTier } from "../utils/format.js";
12
+ import { AGENT_REGISTRY_ABI, ARC402_WALLET_EXECUTE_ABI, ARC402_WALLET_GUARDIAN_ABI, ARC402_WALLET_MACHINE_KEY_ABI, ARC402_WALLET_OWNER_ABI, ARC402_WALLET_PASSKEY_ABI, ARC402_WALLET_PROTOCOL_ABI, ARC402_WALLET_REGISTRY_ABI, POLICY_ENGINE_GOVERNANCE_ABI, POLICY_ENGINE_LIMITS_ABI, TRUST_REGISTRY_ABI, WALLET_FACTORY_ABI } from "../abis.js";
13
+ import { warnIfPublicRpc } from "../config.js";
14
+ import { connectPhoneWallet, sendTransactionWithSession, requestPhoneWalletSignature } from "../walletconnect.js";
15
+ import { BundlerClient, buildSponsoredUserOp, PaymasterClient, DEFAULT_ENTRY_POINT } from "../bundler.js";
16
+ import { clearWCSession } from "../walletconnect-session.js";
17
+ import { handleWalletError } from "../wallet-router.js";
18
+ import { requestCoinbaseSmartWalletSignature } from "../coinbase-smart-wallet.js";
19
+ import { sendTelegramMessage } from "../telegram-notify.js";
20
+ import { renderTree } from "../ui/tree.js";
21
+ import { startSpinner } from "../ui/spinner.js";
22
+ import { c } from "../ui/colors.js";
23
+ import { formatAddress } from "../ui/format.js";
24
24
 
25
25
  const POLICY_ENGINE_DEFAULT = "0x44102e70c2A366632d98Fe40d892a2501fC7fFF2";
26
26
  const GUARDIAN_KEY_PATH = path.join(os.homedir(), ".arc402", "guardian.key");
@@ -1,8 +1,8 @@
1
1
  import { Command } from "commander";
2
2
  import { ethers } from "ethers";
3
- import { loadConfig } from "../config";
4
- import { getClient } from "../client";
5
- import { c } from "../ui/colors";
3
+ import { loadConfig } from "../config.js";
4
+ import { getClient } from "../client.js";
5
+ import { c } from "../ui/colors.js";
6
6
 
7
7
  // ─── Minimal ABIs for event watching ─────────────────────────────────────────
8
8
 
@@ -2,13 +2,13 @@ import { Command } from "commander";
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
4
  import * as os from "os";
5
- import { loadConfig } from "../config";
6
- import { requireSigner, getClient } from "../client";
5
+ import { loadConfig } from "../config.js";
6
+ import { requireSigner, getClient } from "../client.js";
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
+ import { c } from '../ui/colors.js';
9
+ import { startSpinner } from '../ui/spinner.js';
10
+ import { renderTree } from '../ui/tree.js';
11
+ import { formatAddress } from '../ui/format.js';
12
12
 
13
13
  const CHANNEL_STATES_DIR = path.join(os.homedir(), ".arc402", "channel-states");
14
14
 
@@ -1,4 +1,5 @@
1
1
  import { Command } from "commander";
2
+ import * as crypto from "node:crypto";
2
3
  import * as fs from "fs";
3
4
  import * as path from "path";
4
5
  import * as os from "os";
@@ -7,12 +8,16 @@ import { spawnSync, execSync } from "child_process";
7
8
  import {
8
9
  ARC402_DIR,
9
10
  runCmd,
10
- } from "../openshell-runtime";
11
- import { DAEMON_LOG, DAEMON_TOML } from "../daemon/config";
12
- import { c } from "../ui/colors";
13
- import { startSpinner } from "../ui/spinner";
14
- import { renderTree } from "../ui/tree";
15
- import { formatAddress } from "../ui/format";
11
+ } from "../openshell-runtime.js";
12
+ import { DAEMON_LOG, DAEMON_TOML, loadDaemonConfig } from "../daemon/config.js";
13
+ import { c } from "../ui/colors.js";
14
+ import { startSpinner } from "../ui/spinner.js";
15
+ import { renderTree } from "../ui/tree.js";
16
+ import { formatAddress } from "../ui/format.js";
17
+
18
+ import { fileURLToPath } from "node:url";
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = path.dirname(__filename);
16
21
 
17
22
  // ─── Daemon lifecycle notify ──────────────────────────────────────────────────
18
23
 
@@ -27,7 +32,6 @@ function notifyDaemonWorkroomStatus(
27
32
  let daemonPort = port;
28
33
  if (fs.existsSync(DAEMON_TOML)) {
29
34
  try {
30
- const { loadDaemonConfig } = require("../daemon/config") as typeof import("../daemon/config");
31
35
  const cfg = loadDaemonConfig();
32
36
  daemonPort = cfg.relay?.listen_port ?? port;
33
37
  } catch { /* use default */ }
@@ -101,7 +105,7 @@ function buildImage(): boolean {
101
105
  function getPolicyHash(): string {
102
106
  if (!fs.existsSync(POLICY_FILE)) return "(no policy file)";
103
107
  const content = fs.readFileSync(POLICY_FILE, "utf-8");
104
- const crypto = require("crypto");
108
+ // crypto imported at top level
105
109
  return "0x" + crypto.createHash("sha256").update(content).digest("hex").slice(0, 16);
106
110
  }
107
111
 
@@ -131,7 +135,7 @@ export function registerWorkroomCommands(program: Command): void {
131
135
  if (!fs.existsSync(POLICY_FILE)) {
132
136
  console.log(c.dim("No policy file found. Generating default..."));
133
137
  // Import and call the existing policy generator
134
- const { registerOpenShellCommands } = require("./openshell");
138
+ const { registerOpenShellCommands } = await import("./openshell.js");
135
139
  console.log(c.dim(`Policy file will be generated at: ${POLICY_FILE}`));
136
140
  console.log(c.dim("Run 'arc402 workroom policy preset core-launch' after init to apply defaults."));
137
141
  } else {
@@ -797,7 +801,7 @@ No learnings yet. Complete your first hired task to start accumulating expertise
797
801
  .command("token-usage [agreementId]")
798
802
  .description("Show token usage for a specific agreement or across all jobs.")
799
803
  .action(async (agreementId) => {
800
- const { readUsageReport, formatUsageReport } = require("../daemon/token-metering");
804
+ const { readUsageReport, formatUsageReport } = await import("../daemon/token-metering.js");
801
805
 
802
806
  if (agreementId) {
803
807
  const usage = readUsageReport(agreementId);
@@ -6,6 +6,7 @@
6
6
  import * as fs from "fs";
7
7
  import * as path from "path";
8
8
  import * as os from "os";
9
+ import { ethers } from "ethers";
9
10
  import { parse as parseToml } from "smol-toml";
10
11
 
11
12
  export const DAEMON_DIR = path.join(os.homedir(), ".arc402");
@@ -249,7 +250,7 @@ export function loadMachineKey(config: DaemonConfig): { privateKey: string; addr
249
250
  throw new Error(`Machine key not found. Set environment variable: ${envVarName}`);
250
251
  }
251
252
 
252
- const { ethers } = require("ethers") as typeof import("ethers");
253
+ // ethers imported at top level
253
254
  let address: string;
254
255
  try {
255
256
  const w = new ethers.Wallet(privateKey);
@@ -5,9 +5,9 @@
5
5
  import * as http from "http";
6
6
  import * as https from "https";
7
7
  import { ethers } from "ethers";
8
- import type { DaemonConfig } from "./config";
9
- import type { DaemonDB } from "./index";
10
- import type { Notifier } from "./notify";
8
+ import type { DaemonConfig } from "./config.js";
9
+ import type { DaemonDB } from "./index.js";
10
+ import type { Notifier } from "./notify.js";
11
11
 
12
12
  export interface HireProposal {
13
13
  messageId: string;
@@ -8,6 +8,7 @@
8
8
  * Signals: SIGTERM → graceful shutdown.
9
9
  */
10
10
  import * as fs from "fs";
11
+ import * as os from "os";
11
12
  import * as path from "path";
12
13
  import * as net from "net";
13
14
  import * as http from "http";
@@ -25,12 +26,12 @@ import {
25
26
  DAEMON_DB,
26
27
  DAEMON_SOCK,
27
28
  type DaemonConfig,
28
- } from "./config";
29
- import { verifyWallet, getWalletBalance } from "./wallet-monitor";
30
- import { buildNotifier } from "./notify";
31
- import { HireListener } from "./hire-listener";
32
- import { UserOpsManager, buildAcceptCalldata } from "./userops";
33
- import { generateReceipt, extractLearnings, createJobDirectory, cleanJobDirectory } from "./job-lifecycle";
29
+ } from "./config.js";
30
+ import { verifyWallet, getWalletBalance } from "./wallet-monitor.js";
31
+ import { buildNotifier } from "./notify.js";
32
+ import { HireListener } from "./hire-listener.js";
33
+ import { UserOpsManager, buildAcceptCalldata } from "./userops.js";
34
+ import { generateReceipt, extractLearnings, createJobDirectory, cleanJobDirectory } from "./job-lifecycle.js";
34
35
 
35
36
  // ─── State DB ─────────────────────────────────────────────────────────────────
36
37
 
@@ -432,7 +433,7 @@ function formatUptime(seconds: number): string {
432
433
  // ─── Daemon main ──────────────────────────────────────────────────────────────
433
434
 
434
435
  // Extend config with serviceAgreementAddress (loaded from CLI config if available)
435
- declare module "./config" {
436
+ declare module "./config.js" {
436
437
  interface DaemonConfig {
437
438
  serviceAgreementAddress?: string;
438
439
  }
@@ -448,7 +449,7 @@ export async function runDaemon(foreground = false): Promise<void> {
448
449
  let config: DaemonConfig;
449
450
  try {
450
451
  config = loadDaemonConfig();
451
- log({ event: "config_loaded", path: require("path").join(require("os").homedir(), ".arc402", "daemon.toml") });
452
+ log({ event: "config_loaded", path: path.join(os.homedir(), ".arc402", "daemon.toml") });
452
453
  } catch (err) {
453
454
  process.stderr.write(`Config error: ${err}\n`);
454
455
  process.exit(1);
@@ -763,7 +764,7 @@ export async function runDaemon(foreground = false): Promise<void> {
763
764
  }
764
765
 
765
766
  // Policy check
766
- const { evaluatePolicy } = await import("./hire-listener");
767
+ const { evaluatePolicy } = await import("./hire-listener.js");
767
768
  const activeCount = db.countActiveHireRequests();
768
769
  const policyResult = evaluatePolicy(proposal, config, activeCount);
769
770
 
@@ -13,7 +13,7 @@ import * as fs from "fs";
13
13
  import * as path from "path";
14
14
  import * as os from "os";
15
15
  import * as crypto from "crypto";
16
- import { readUsageReport, type AggregatedTokenUsage } from "./token-metering";
16
+ import { readUsageReport, type AggregatedTokenUsage } from "./token-metering.js";
17
17
 
18
18
  const ARC402_DIR = path.join(os.homedir(), ".arc402");
19
19
  const RECEIPTS_DIR = path.join(ARC402_DIR, "receipts");
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import * as https from "https";
6
6
  import * as http from "http";
7
- import type { DaemonConfig } from "./config";
7
+ import type { DaemonConfig } from "./config.js";
8
8
 
9
9
  export type NotifyEvent =
10
10
  | "hire_request"
@@ -133,11 +133,11 @@ export class EmailChannel implements NotificationChannel {
133
133
  async send(title: string, body: string): Promise<void> {
134
134
  // nodemailer is an optional runtime dependency — load via require to skip
135
135
  // compile-time module resolution. Throws a clear message if not installed.
136
- // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
137
  let nodemailer: any;
138
138
  try {
139
- // Using Function constructor avoids TypeScript static import analysis.
140
- nodemailer = (new Function("require", "return require('nodemailer')"))(require);
139
+ // @ts-expect-error nodemailer is an optional dependency
140
+ nodemailer = await import("nodemailer");
141
141
  } catch {
142
142
  throw new Error("nodemailer is not installed. Run: npm install nodemailer");
143
143
  }
@@ -3,10 +3,10 @@
3
3
  * Wraps protocol calls (accept, fulfill) into ERC-4337 UserOperations.
4
4
  */
5
5
  import { ethers } from "ethers";
6
- import { BundlerClient } from "../bundler";
7
- import type { UserOperation } from "../bundler";
8
- import type { DaemonConfig } from "./config";
9
- import { ARC402_WALLET_EXECUTE_ABI } from "../abis";
6
+ import { BundlerClient } from "../bundler.js";
7
+ import type { UserOperation } from "../bundler.js";
8
+ import type { DaemonConfig } from "./config.js";
9
+ import { ARC402_WALLET_EXECUTE_ABI } from "../abis.js";
10
10
 
11
11
  // ServiceAgreement calldata encoders
12
12
  const SA_IFACE = new ethers.Interface([
@@ -3,11 +3,11 @@
3
3
  * Steps 4 and 5 of the daemon startup sequence (Spec 32 §3).
4
4
  */
5
5
  import { ethers } from "ethers";
6
- import type { DaemonConfig } from "./config";
6
+ import type { DaemonConfig } from "./config.js";
7
7
  import {
8
8
  ARC402_WALLET_GUARDIAN_ABI,
9
9
  ARC402_WALLET_MACHINE_KEY_ABI,
10
- } from "../abis";
10
+ } from "../abis.js";
11
11
 
12
12
  export interface WalletStatus {
13
13
  contractAddress: string;
@@ -4,7 +4,7 @@
4
4
  * and POSTs lifecycle events after onchain transactions.
5
5
  */
6
6
  import { ethers } from "ethers";
7
- import { AGENT_REGISTRY_ABI } from "./abis";
7
+ import { AGENT_REGISTRY_ABI } from "./abis.js";
8
8
  import * as dns from "dns/promises";
9
9
 
10
10
  export const DEFAULT_REGISTRY_ADDRESS = "0xD5c2851B00090c92Ba7F4723FB548bb30C9B6865";
package/src/index.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { createProgram } from "./program";
3
- import { startREPL } from "./repl";
4
- import { configExists, loadConfig, saveConfig } from "./config";
2
+ import { createRequire } from "node:module";
3
+ import { createProgram } from "./program.js";
4
+ import { startREPL } from "./repl.js";
5
+ import { configExists, loadConfig, saveConfig } from "./config.js";
5
6
 
6
7
  // ── Upgrade safety check ────────────────────────────────────────────────────
7
- // eslint-disable-next-line @typescript-eslint/no-var-requires
8
- const currentVersion: string = (require("../package.json") as { version: string }).version;
8
+ const _require = createRequire(import.meta.url);
9
+ const currentVersion: string = (_require("../package.json") as { version: string }).version;
9
10
 
10
11
  function checkUpgrade(): void {
11
12
  if (!configExists()) return;
@@ -52,10 +53,10 @@ if (printMode) {
52
53
  console.error(e instanceof Error ? e.message : String(e));
53
54
  process.exit(1);
54
55
  });
55
- } else if (process.stdout.isTTY && !hasSubcommand && process.argv.length <= 2) {
56
+ } else if (process.stdout.isTTY && !hasSubcommand && process.argv.length <= 2 && !process.env.ARC402_NO_TUI) {
56
57
  // TTY with no subcommand — launch Ink TUI
57
58
  checkUpgrade();
58
- void import("./tui/index").then(({ launchTUI }) => launchTUI()).catch((e: unknown) => {
59
+ void import("./tui/index.js").then(({ launchTUI }) => launchTUI()).catch((e: unknown) => {
59
60
  console.error("TUI failed to start:", e instanceof Error ? e.message : String(e));
60
61
  // Fallback to REPL
61
62
  void startREPL();
@@ -3,7 +3,11 @@ import * as os from "os";
3
3
  import * as path from "path";
4
4
  import { spawnSync } from "child_process";
5
5
  import { parse as parseToml } from "smol-toml";
6
- import { loadConfig } from "./config";
6
+ import { loadConfig } from "./config.js";
7
+
8
+ import { fileURLToPath } from "node:url";
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
7
11
 
8
12
  export const ARC402_DIR = path.join(os.homedir(), ".arc402");
9
13
  export const OPENSHELL_TOML = path.join(ARC402_DIR, "openshell.toml");
package/src/program.ts CHANGED
@@ -1,38 +1,39 @@
1
+ import { createRequire } from "node:module";
1
2
  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 { registerDoctorCommand } from "./commands/doctor";
31
- import { registerMigrateCommands } from "./commands/migrate";
32
- import { registerFeedCommand } from "./commands/feed";
33
- import { registerArenaCommands } from "./commands/arena";
34
- import { registerWatchCommand } from "./commands/watch";
35
- import { registerBackupCommand } from "./commands/backup";
3
+ import { registerAcceptCommand } from "./commands/accept.js";
4
+ import { registerAgentCommands } from "./commands/agent.js";
5
+ import { registerAgreementsCommands } from "./commands/agreements.js";
6
+ import { registerArbitratorCommand } from "./commands/arbitrator.js";
7
+ import { registerCancelCommand } from "./commands/cancel.js";
8
+ import { registerChannelCommands } from "./commands/channel.js";
9
+ import { registerConfigCommands } from "./commands/config.js";
10
+ import { registerDeliverCommand } from "./commands/deliver.js";
11
+ import { registerDiscoverCommand } from "./commands/discover.js";
12
+ import { registerEndpointCommands } from "./commands/endpoint.js";
13
+ import { registerDisputeCommand } from "./commands/dispute.js";
14
+ import { registerHireCommand } from "./commands/hire.js";
15
+ import { registerHandshakeCommand } from "./commands/agent-handshake.js";
16
+ import { registerNegotiateCommands } from "./commands/negotiate.js";
17
+ import { registerRelayCommands } from "./commands/relay.js";
18
+ import { registerRemediateCommands } from "./commands/remediate.js";
19
+ import { registerDaemonCommands } from "./commands/daemon.js";
20
+ import { registerOpenShellCommands } from "./commands/openshell.js";
21
+ import { registerWorkroomCommands } from "./commands/workroom.js";
22
+ import { registerArenaHandshakeCommands } from "./commands/arena-handshake.js";
23
+ import { registerTrustCommand } from "./commands/trust.js";
24
+ import { registerWalletCommands } from "./commands/wallet.js";
25
+ import { registerOwnerCommands } from "./commands/owner.js";
26
+ import { registerSetupCommands } from "./commands/setup.js";
27
+ import { registerVerifyCommand } from "./commands/verify.js";
28
+ import { registerContractInteractionCommands } from "./commands/contract-interaction.js";
29
+ import { registerWatchtowerCommands } from "./commands/watchtower.js";
30
+ import { registerColdStartCommands } from "./commands/coldstart.js";
31
+ import { registerDoctorCommand } from "./commands/doctor.js";
32
+ import { registerMigrateCommands } from "./commands/migrate.js";
33
+ import { registerFeedCommand } from "./commands/feed.js";
34
+ import { registerArenaCommands } from "./commands/arena.js";
35
+ import { registerWatchCommand } from "./commands/watch.js";
36
+ import { registerBackupCommand } from "./commands/backup.js";
36
37
  import reputation from "./commands/reputation.js";
37
38
  import policy from "./commands/policy.js";
38
39
 
@@ -43,8 +44,7 @@ export function createProgram(): Command {
43
44
  .description(
44
45
  "ARC-402 CLI aligned to canonical-capability discovery → negotiate → hire → remediate → dispute workflow"
45
46
  )
46
- // eslint-disable-next-line @typescript-eslint/no-var-requires
47
- .version((require("../package.json") as { version: string }).version);
47
+ .version((createRequire(import.meta.url)("../package.json") as { version: string }).version);
48
48
 
49
49
  registerConfigCommands(program);
50
50
  registerHandshakeCommand(program);
package/src/repl.ts CHANGED
@@ -3,9 +3,9 @@ import fs from "fs";
3
3
  import path from "path";
4
4
  import os from "os";
5
5
  import readline from "readline";
6
- import { createProgram } from "./program";
7
- import { getBannerLines, BannerConfig } from "./ui/banner";
8
- import { c } from "./ui/colors";
6
+ import { createProgram } from "./program.js";
7
+ import { getBannerLines, BannerConfig } from "./ui/banner.js";
8
+ import { c } from "./ui/colors.js";
9
9
 
10
10
  // ─── Config helpers ────────────────────────────────────────────────────────────
11
11
 
package/src/tui/App.tsx CHANGED
@@ -1,17 +1,17 @@
1
1
  import React, { useState, useCallback, useEffect } from "react";
2
+ import { createRequire } from "node:module";
2
3
  import { Box, Text, useApp } from "ink";
3
- import { Header } from "./Header";
4
- import { Viewport } from "./Viewport";
5
- import { Footer } from "./Footer";
6
- import { InputLine } from "./InputLine";
7
- import { useCommand } from "./useCommand";
8
- import { useChat } from "./useChat";
9
- import { useScroll } from "./useScroll";
10
- import { createProgram } from "../program";
4
+ import { Header } from "./Header.js";
5
+ import { Viewport } from "./Viewport.js";
6
+ import { Footer } from "./Footer.js";
7
+ import { InputLine } from "./InputLine.js";
8
+ import { useCommand } from "./useCommand.js";
9
+ import { useChat } from "./useChat.js";
10
+ import { useScroll } from "./useScroll.js";
11
+ import { createProgram } from "../program.js";
11
12
  import chalk from "chalk";
12
13
 
13
- // eslint-disable-next-line @typescript-eslint/no-var-requires
14
- const pkg = require("../../package.json") as { version: string };
14
+ const pkg = createRequire(import.meta.url)("../../package.json") as { version: string };
15
15
 
16
16
  const BUILTIN_CMDS = ["help", "exit", "quit", "clear", "status"];
17
17
 
@@ -205,6 +205,11 @@ export function App({ version, network, wallet, balance }: AppProps) {
205
205
  isAutoScroll={isAutoScroll}
206
206
  />
207
207
 
208
+ {/* Bottom separator */}
209
+ <Box>
210
+ <Text dimColor>{"─".repeat(60)}</Text>
211
+ </Box>
212
+
208
213
  {/* FOOTER — fixed, input pinned */}
209
214
  <Footer>
210
215
  <InputLine onSubmit={handleCommand} isDisabled={isDisabled} />
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Box, Text } from "ink";
3
- import { getBannerLines } from "../ui/banner";
3
+ import { getBannerLines } from "../ui/banner.js";
4
4
 
5
5
  interface HeaderProps {
6
6
  version: string;