@wlfi-agent/cli 1.4.13 → 1.4.15

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 (289) hide show
  1. package/Cargo.lock +3968 -0
  2. package/Cargo.toml +50 -0
  3. package/README.md +426 -6
  4. package/crates/vault-cli-admin/Cargo.toml +26 -0
  5. package/crates/vault-cli-admin/src/io_utils.rs +500 -0
  6. package/crates/vault-cli-admin/src/main.rs +3990 -0
  7. package/crates/vault-cli-admin/src/shared_config.rs +624 -0
  8. package/crates/vault-cli-admin/src/tui/amounts.rs +180 -0
  9. package/crates/vault-cli-admin/src/tui/token_rpc.rs +250 -0
  10. package/crates/vault-cli-admin/src/tui/utils.rs +82 -0
  11. package/crates/vault-cli-admin/src/tui.rs +3410 -0
  12. package/crates/vault-cli-agent/Cargo.toml +24 -0
  13. package/crates/vault-cli-agent/src/io_utils.rs +576 -0
  14. package/crates/vault-cli-agent/src/main.rs +833 -0
  15. package/crates/vault-cli-daemon/Cargo.toml +28 -0
  16. package/crates/vault-cli-daemon/src/bin/wlfi-agent-system-keychain.rs +216 -0
  17. package/crates/vault-cli-daemon/src/main.rs +644 -0
  18. package/crates/vault-cli-daemon/src/relay_sync.rs +894 -0
  19. package/crates/vault-cli-daemon/tests/system_keychain_helper_acl.rs +167 -0
  20. package/crates/vault-daemon/Cargo.toml +32 -0
  21. package/crates/vault-daemon/src/daemon_parts/api_impl_and_utils.rs +1041 -0
  22. package/crates/vault-daemon/src/daemon_parts/core_helpers.rs +1256 -0
  23. package/crates/vault-daemon/src/daemon_parts/types_api_rpc.rs +622 -0
  24. package/crates/vault-daemon/src/lib.rs +54 -0
  25. package/crates/vault-daemon/src/persistence.rs +441 -0
  26. package/crates/vault-daemon/src/tests.rs +237 -0
  27. package/crates/vault-daemon/src/tests_parts/part1.rs +1224 -0
  28. package/crates/vault-daemon/src/tests_parts/part2.rs +1021 -0
  29. package/crates/vault-daemon/src/tests_parts/part3.rs +835 -0
  30. package/crates/vault-daemon/src/tests_parts/part4.rs +604 -0
  31. package/crates/vault-domain/Cargo.toml +20 -0
  32. package/crates/vault-domain/src/action.rs +849 -0
  33. package/crates/vault-domain/src/address.rs +51 -0
  34. package/crates/vault-domain/src/approval.rs +90 -0
  35. package/crates/vault-domain/src/constants.rs +4 -0
  36. package/crates/vault-domain/src/error.rs +54 -0
  37. package/crates/vault-domain/src/keys.rs +71 -0
  38. package/crates/vault-domain/src/lib.rs +42 -0
  39. package/crates/vault-domain/src/nonce.rs +102 -0
  40. package/crates/vault-domain/src/policy.rs +172 -0
  41. package/crates/vault-domain/src/request.rs +53 -0
  42. package/crates/vault-domain/src/scope.rs +24 -0
  43. package/crates/vault-domain/src/session.rs +50 -0
  44. package/crates/vault-domain/src/signature.rs +34 -0
  45. package/crates/vault-domain/src/tests.rs +651 -0
  46. package/crates/vault-domain/src/u128_as_decimal_string.rs +44 -0
  47. package/crates/vault-policy/Cargo.toml +17 -0
  48. package/crates/vault-policy/src/engine.rs +301 -0
  49. package/crates/vault-policy/src/error.rs +81 -0
  50. package/crates/vault-policy/src/lib.rs +17 -0
  51. package/crates/vault-policy/src/report.rs +34 -0
  52. package/crates/vault-policy/src/tests.rs +891 -0
  53. package/crates/vault-policy/src/tests_explain.rs +78 -0
  54. package/crates/vault-sdk-agent/Cargo.toml +21 -0
  55. package/crates/vault-sdk-agent/src/lib.rs +711 -0
  56. package/crates/vault-signer/Cargo.toml +25 -0
  57. package/crates/vault-signer/src/lib.rs +731 -0
  58. package/crates/vault-signer/tests/secure_enclave_acl.rs +54 -0
  59. package/crates/vault-transport-unix/Cargo.toml +24 -0
  60. package/crates/vault-transport-unix/src/lib.rs +1640 -0
  61. package/crates/vault-transport-xpc/Cargo.toml +25 -0
  62. package/crates/vault-transport-xpc/src/client_codec_api.rs +635 -0
  63. package/crates/vault-transport-xpc/src/lib.rs +680 -0
  64. package/crates/vault-transport-xpc/src/tests.rs +818 -0
  65. package/crates/vault-transport-xpc/tests/e2e_flow.rs +773 -0
  66. package/dist/cli.cjs +35088 -0
  67. package/dist/cli.cjs.map +1 -0
  68. package/package.json +45 -41
  69. package/packages/cache/.turbo/turbo-build.log +52 -0
  70. package/packages/cache/dist/chunk-2QFWMUXT.cjs +43 -0
  71. package/packages/cache/dist/chunk-2QFWMUXT.cjs.map +1 -0
  72. package/packages/cache/dist/chunk-4U63TZTQ.js +43 -0
  73. package/packages/cache/dist/chunk-4U63TZTQ.js.map +1 -0
  74. package/packages/cache/dist/chunk-ALQ6H7KG.cjs +404 -0
  75. package/packages/cache/dist/chunk-ALQ6H7KG.cjs.map +1 -0
  76. package/packages/cache/dist/chunk-FGJEEF5N.js +404 -0
  77. package/packages/cache/dist/chunk-FGJEEF5N.js.map +1 -0
  78. package/packages/cache/dist/chunk-UYNEHZHB.cjs +45 -0
  79. package/packages/cache/dist/chunk-UYNEHZHB.cjs.map +1 -0
  80. package/packages/cache/dist/chunk-VXVMPG3W.js +45 -0
  81. package/packages/cache/dist/chunk-VXVMPG3W.js.map +1 -0
  82. package/packages/cache/dist/client/index.cjs +11 -0
  83. package/packages/cache/dist/client/index.cjs.map +1 -0
  84. package/packages/cache/dist/client/index.d.cts +15 -0
  85. package/packages/cache/dist/client/index.d.ts +15 -0
  86. package/packages/cache/dist/client/index.js +11 -0
  87. package/packages/cache/dist/client/index.js.map +1 -0
  88. package/packages/cache/dist/errors/index.cjs +11 -0
  89. package/packages/cache/dist/errors/index.cjs.map +1 -0
  90. package/packages/cache/dist/errors/index.d.cts +26 -0
  91. package/packages/cache/dist/errors/index.d.ts +26 -0
  92. package/packages/cache/dist/errors/index.js +11 -0
  93. package/packages/cache/dist/errors/index.js.map +1 -0
  94. package/packages/cache/dist/index.cjs +29 -0
  95. package/packages/cache/dist/index.cjs.map +1 -0
  96. package/packages/cache/dist/index.d.cts +4 -0
  97. package/packages/cache/dist/index.d.ts +4 -0
  98. package/packages/cache/dist/index.js +29 -0
  99. package/packages/cache/dist/index.js.map +1 -0
  100. package/packages/cache/dist/service/index.cjs +15 -0
  101. package/packages/cache/dist/service/index.cjs.map +1 -0
  102. package/packages/cache/dist/service/index.d.cts +184 -0
  103. package/packages/cache/dist/service/index.d.ts +184 -0
  104. package/packages/cache/dist/service/index.js +15 -0
  105. package/packages/cache/dist/service/index.js.map +1 -0
  106. package/packages/cache/node_modules/.bin/jiti +17 -0
  107. package/packages/cache/node_modules/.bin/tsc +17 -0
  108. package/packages/cache/node_modules/.bin/tsserver +17 -0
  109. package/packages/cache/node_modules/.bin/tsup +17 -0
  110. package/packages/cache/node_modules/.bin/tsup-node +17 -0
  111. package/packages/cache/node_modules/.bin/tsx +17 -0
  112. package/packages/cache/node_modules/.bin/vitest +17 -0
  113. package/packages/cache/package.json +48 -0
  114. package/packages/cache/src/client/index.ts +56 -0
  115. package/packages/cache/src/errors/index.ts +53 -0
  116. package/packages/cache/src/index.ts +3 -0
  117. package/packages/cache/src/service/index.test.ts +263 -0
  118. package/packages/cache/src/service/index.ts +678 -0
  119. package/packages/cache/tsconfig.json +13 -0
  120. package/packages/cache/tsup.config.ts +13 -0
  121. package/packages/cache/vitest.config.ts +16 -0
  122. package/packages/config/.turbo/turbo-build.log +18 -0
  123. package/packages/config/dist/index.cjs +1037 -0
  124. package/packages/config/dist/index.cjs.map +1 -0
  125. package/packages/config/dist/index.d.ts +131 -0
  126. package/packages/config/node_modules/.bin/jiti +17 -0
  127. package/packages/config/node_modules/.bin/tsc +17 -0
  128. package/packages/config/node_modules/.bin/tsserver +17 -0
  129. package/packages/config/node_modules/.bin/tsup +17 -0
  130. package/packages/config/node_modules/.bin/tsup-node +17 -0
  131. package/packages/config/node_modules/.bin/tsx +17 -0
  132. package/packages/config/package.json +21 -0
  133. package/packages/config/src/index.js +1 -0
  134. package/packages/config/src/index.ts +1282 -0
  135. package/packages/config/tsconfig.json +4 -0
  136. package/packages/rpc/.turbo/turbo-build.log +32 -0
  137. package/packages/rpc/dist/_esm-BCLXDO2R.cjs +3660 -0
  138. package/packages/rpc/dist/_esm-BCLXDO2R.cjs.map +1 -0
  139. package/packages/rpc/dist/ccip-OWJLAW55.cjs +16 -0
  140. package/packages/rpc/dist/ccip-OWJLAW55.cjs.map +1 -0
  141. package/packages/rpc/dist/chunk-APQIFZ3B.cjs +6247 -0
  142. package/packages/rpc/dist/chunk-APQIFZ3B.cjs.map +1 -0
  143. package/packages/rpc/dist/chunk-CDO2GWRD.cjs +410 -0
  144. package/packages/rpc/dist/chunk-CDO2GWRD.cjs.map +1 -0
  145. package/packages/rpc/dist/chunk-QGTNTFJ7.cjs +2249 -0
  146. package/packages/rpc/dist/chunk-QGTNTFJ7.cjs.map +1 -0
  147. package/packages/rpc/dist/chunk-TZDTAHWR.cjs +44 -0
  148. package/packages/rpc/dist/chunk-TZDTAHWR.cjs.map +1 -0
  149. package/packages/rpc/dist/index.cjs +7342 -0
  150. package/packages/rpc/dist/index.cjs.map +1 -0
  151. package/packages/rpc/dist/index.d.ts +3857 -0
  152. package/packages/rpc/dist/secp256k1-WCNM675D.cjs +18 -0
  153. package/packages/rpc/dist/secp256k1-WCNM675D.cjs.map +1 -0
  154. package/packages/rpc/node_modules/.bin/jiti +17 -0
  155. package/packages/rpc/node_modules/.bin/tsc +17 -0
  156. package/packages/rpc/node_modules/.bin/tsserver +17 -0
  157. package/packages/rpc/node_modules/.bin/tsup +17 -0
  158. package/packages/rpc/node_modules/.bin/tsup-node +17 -0
  159. package/packages/rpc/node_modules/.bin/tsx +17 -0
  160. package/packages/rpc/package.json +25 -0
  161. package/packages/rpc/src/index.ts +206 -0
  162. package/packages/rpc/tsconfig.json +4 -0
  163. package/packages/typescript/base.json +36 -0
  164. package/packages/typescript/nextjs.json +17 -0
  165. package/packages/typescript/package.json +10 -0
  166. package/packages/ui/.turbo/turbo-build.log +44 -0
  167. package/packages/ui/dist/chunk-MOAFBKSA.js +11 -0
  168. package/packages/ui/dist/chunk-MOAFBKSA.js.map +1 -0
  169. package/packages/ui/dist/components/badge.d.ts +12 -0
  170. package/packages/ui/dist/components/badge.js +31 -0
  171. package/packages/ui/dist/components/badge.js.map +1 -0
  172. package/packages/ui/dist/components/button.d.ts +13 -0
  173. package/packages/ui/dist/components/button.js +40 -0
  174. package/packages/ui/dist/components/button.js.map +1 -0
  175. package/packages/ui/dist/components/card.d.ts +10 -0
  176. package/packages/ui/dist/components/card.js +39 -0
  177. package/packages/ui/dist/components/card.js.map +1 -0
  178. package/packages/ui/dist/components/input.d.ts +5 -0
  179. package/packages/ui/dist/components/input.js +28 -0
  180. package/packages/ui/dist/components/input.js.map +1 -0
  181. package/packages/ui/dist/components/label.d.ts +5 -0
  182. package/packages/ui/dist/components/label.js +13 -0
  183. package/packages/ui/dist/components/label.js.map +1 -0
  184. package/packages/ui/dist/components/separator.d.ts +5 -0
  185. package/packages/ui/dist/components/separator.js +13 -0
  186. package/packages/ui/dist/components/separator.js.map +1 -0
  187. package/packages/ui/dist/components/textarea.d.ts +5 -0
  188. package/packages/ui/dist/components/textarea.js +27 -0
  189. package/packages/ui/dist/components/textarea.js.map +1 -0
  190. package/packages/ui/dist/tailwind.d.ts +56 -0
  191. package/packages/ui/dist/tailwind.js +60 -0
  192. package/packages/ui/dist/tailwind.js.map +1 -0
  193. package/packages/ui/dist/utils/cn.d.ts +5 -0
  194. package/packages/ui/dist/utils/cn.js +7 -0
  195. package/packages/ui/dist/utils/cn.js.map +1 -0
  196. package/packages/ui/node_modules/.bin/jiti +17 -0
  197. package/packages/ui/node_modules/.bin/tsc +17 -0
  198. package/packages/ui/node_modules/.bin/tsserver +17 -0
  199. package/packages/ui/node_modules/.bin/tsup +17 -0
  200. package/packages/ui/node_modules/.bin/tsup-node +17 -0
  201. package/packages/ui/node_modules/.bin/tsx +17 -0
  202. package/packages/ui/package.json +69 -0
  203. package/packages/ui/src/components/badge.tsx +27 -0
  204. package/packages/ui/src/components/button.tsx +40 -0
  205. package/packages/ui/src/components/card.tsx +31 -0
  206. package/packages/ui/src/components/input.tsx +21 -0
  207. package/packages/ui/src/components/label.tsx +6 -0
  208. package/packages/ui/src/components/separator.tsx +6 -0
  209. package/packages/ui/src/components/textarea.tsx +20 -0
  210. package/packages/ui/src/globals.css +70 -0
  211. package/packages/ui/src/tailwind.ts +56 -0
  212. package/packages/ui/src/utils/cn.ts +6 -0
  213. package/packages/ui/tsconfig.json +20 -0
  214. package/packages/ui/tsup.config.ts +20 -0
  215. package/pnpm-workspace.yaml +4 -0
  216. package/scripts/install-rust-binaries.mjs +84 -0
  217. package/scripts/launchd/install-user-daemon.sh +358 -0
  218. package/scripts/launchd/run-vault-daemon.sh +5 -0
  219. package/scripts/launchd/run-wlfi-agent-daemon.sh +73 -0
  220. package/scripts/launchd/uninstall-user-daemon.sh +103 -0
  221. package/src/cli.ts +2121 -0
  222. package/src/lib/admin-guard.js +1 -0
  223. package/src/lib/admin-guard.ts +185 -0
  224. package/src/lib/admin-passthrough.ts +33 -0
  225. package/src/lib/admin-reset.ts +751 -0
  226. package/src/lib/admin-setup.ts +1612 -0
  227. package/src/lib/agent-auth-clear.js +1 -0
  228. package/src/lib/agent-auth-clear.ts +58 -0
  229. package/src/lib/agent-auth-forwarding.js +1 -0
  230. package/src/lib/agent-auth-forwarding.ts +149 -0
  231. package/src/lib/agent-auth-migrate.js +1 -0
  232. package/src/lib/agent-auth-migrate.ts +150 -0
  233. package/src/lib/agent-auth-revoke.ts +103 -0
  234. package/src/lib/agent-auth-rotate.ts +107 -0
  235. package/src/lib/agent-auth-token.js +1 -0
  236. package/src/lib/agent-auth-token.ts +25 -0
  237. package/src/lib/agent-auth.ts +89 -0
  238. package/src/lib/asset-broadcast.js +1 -0
  239. package/src/lib/asset-broadcast.ts +285 -0
  240. package/src/lib/bootstrap-artifacts.js +1 -0
  241. package/src/lib/bootstrap-artifacts.ts +205 -0
  242. package/src/lib/bootstrap-credentials.js +1 -0
  243. package/src/lib/bootstrap-credentials.ts +832 -0
  244. package/src/lib/config-amounts.js +1 -0
  245. package/src/lib/config-amounts.ts +189 -0
  246. package/src/lib/config-mutation.ts +27 -0
  247. package/src/lib/fs-trust.js +1 -0
  248. package/src/lib/fs-trust.ts +537 -0
  249. package/src/lib/keychain.js +1 -0
  250. package/src/lib/keychain.ts +225 -0
  251. package/src/lib/local-admin-access.ts +106 -0
  252. package/src/lib/network-selection.js +1 -0
  253. package/src/lib/network-selection.ts +71 -0
  254. package/src/lib/passthrough-security.js +1 -0
  255. package/src/lib/passthrough-security.ts +114 -0
  256. package/src/lib/rpc-guard.js +1 -0
  257. package/src/lib/rpc-guard.ts +7 -0
  258. package/src/lib/rust-spawn-options.js +1 -0
  259. package/src/lib/rust-spawn-options.ts +98 -0
  260. package/src/lib/rust.js +1 -0
  261. package/src/lib/rust.ts +143 -0
  262. package/src/lib/signed-tx.js +1 -0
  263. package/src/lib/signed-tx.ts +116 -0
  264. package/src/lib/status-repair-cli.ts +116 -0
  265. package/src/lib/sudo.js +1 -0
  266. package/src/lib/sudo.ts +172 -0
  267. package/src/lib/vault-password-forwarding.js +1 -0
  268. package/src/lib/vault-password-forwarding.ts +155 -0
  269. package/src/lib/wallet-profile.js +1 -0
  270. package/src/lib/wallet-profile.ts +332 -0
  271. package/src/lib/wallet-repair.js +1 -0
  272. package/src/lib/wallet-repair.ts +304 -0
  273. package/src/lib/wallet-setup.js +1 -0
  274. package/src/lib/wallet-setup.ts +1466 -0
  275. package/src/lib/wallet-status.js +1 -0
  276. package/src/lib/wallet-status.ts +640 -0
  277. package/tsconfig.base.json +17 -0
  278. package/tsconfig.json +10 -0
  279. package/tsup.config.ts +25 -0
  280. package/turbo.json +41 -0
  281. package/LICENSE.md +0 -1
  282. package/dist/wlfa/index.cjs +0 -250
  283. package/dist/wlfa/index.d.cts +0 -1
  284. package/dist/wlfa/index.d.ts +0 -1
  285. package/dist/wlfa/index.js +0 -250
  286. package/dist/wlfc/index.cjs +0 -1839
  287. package/dist/wlfc/index.d.cts +0 -1
  288. package/dist/wlfc/index.d.ts +0 -1
  289. package/dist/wlfc/index.js +0 -1839
package/Cargo.toml ADDED
@@ -0,0 +1,50 @@
1
+ [workspace]
2
+ members = [
3
+ "crates/vault-domain",
4
+ "crates/vault-policy",
5
+ "crates/vault-signer",
6
+ "crates/vault-daemon",
7
+ "crates/vault-transport-unix",
8
+ "crates/vault-sdk-agent",
9
+ "crates/vault-cli-admin",
10
+ "crates/vault-cli-agent",
11
+ "crates/vault-cli-daemon",
12
+ "crates/vault-transport-xpc",
13
+ ]
14
+ resolver = "2"
15
+
16
+ [workspace.package]
17
+ edition = "2021"
18
+ license = "MIT"
19
+ version = "0.1.0"
20
+ authors = ["WLFI Agent SDK Team"]
21
+
22
+ [workspace.dependencies]
23
+ alloy-primitives = "0.8"
24
+ alloy-sol-types = "0.8"
25
+ anyhow = "1"
26
+ argon2 = "0.5"
27
+ async-trait = "0.1"
28
+ block = "0.1"
29
+ chacha20poly1305 = "0.10"
30
+ clap = { version = "4.5", features = ["derive", "env"] }
31
+ core-foundation = "0.10"
32
+ crossterm = "0.28"
33
+ hex = "0.4"
34
+ k256 = { version = "0.13", features = ["ecdsa"] }
35
+ libc = "0.2"
36
+ rand = "0.9"
37
+ reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
38
+ ratatui = "0.29"
39
+ rpassword = "7"
40
+ security-framework = { version = "3.7", features = ["OSX_10_15"] }
41
+ security-framework-sys = "2.17"
42
+ serde = { version = "1", features = ["derive"] }
43
+ serde_json = "1"
44
+ sha2 = "0.10"
45
+ thiserror = "2"
46
+ time = { version = "0.3", features = ["macros", "serde", "formatting", "parsing"] }
47
+ tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "net", "io-util", "time", "signal"] }
48
+ uuid = { version = "1", features = ["serde", "v4"] }
49
+ zeroize = "1"
50
+ x25519-dalek = { version = "2", features = ["static_secrets"] }
package/README.md CHANGED
@@ -1,17 +1,437 @@
1
- # @wlfi-agent/cli
1
+ # WLFI Agent SDK
2
2
 
3
- Command-line package for WLFI Agent Wallet workflows.
3
+ WLFI Agent SDK is a root-managed local signing daemon with policy enforcement, a single `wlfi-agent` CLI, and an optional relay + web approval flow.
4
+
5
+ The main user path is:
6
+
7
+ 1. run `wlfi-agent admin setup`
8
+ 2. let it install the daemon and set up a wallet
9
+ 3. use `wlfi-agent transfer`, `wlfi-agent transfer-native`, `wlfi-agent approve`, or `wlfi-agent broadcast`
10
+ 4. optionally connect a relay for browser-based manual approvals
11
+
12
+ User-facing examples below avoid shell env vars on purpose. Prefer prompts, config files, `wlfi-agent admin tui`, and explicit command flags.
13
+
14
+ ## Command model
15
+
16
+ - `wlfi-agent admin setup`
17
+ - first-run setup
18
+ - stores the vault password in macOS System Keychain
19
+ - installs the root LaunchDaemon
20
+ - creates a vault key + agent key
21
+ - prints the Ethereum address
22
+ - `wlfi-agent admin tui`
23
+ - token-first policy editor for per-token defaults, destination overrides, and manual approvals
24
+ - `wlfi-agent admin reset`
25
+ - removes the managed daemon state and local wallet credentials
26
+ - use it only when you are intentionally discarding the current wallet
27
+ - `wlfi-agent admin uninstall`
28
+ - fully removes the managed daemon, root-owned state, local config, local binaries, and logs
29
+ - use it when you want WLFI removed from the machine instead of preparing for another setup
30
+ - `wlfi-agent admin ...`
31
+ - direct policy and relay configuration commands
32
+ - `wlfi-agent transfer`, `wlfi-agent transfer-native`, `wlfi-agent approve`, `wlfi-agent broadcast`
33
+ - submits signing requests through the daemon
34
+ - uses the configured agent key id plus the macOS Keychain token by default
35
+ - `wlfi-agent status`
36
+ - inspects local wallet security posture, daemon/socket trust, state-file trust, bootstrap artifacts, and agent token storage
37
+ - use `--strict` when you want CI or automation to fail on warnings
38
+ - `wlfi-agent repair`
39
+ - non-privileged local cleanup for plaintext bootstrap artifacts and legacy `agentAuthToken` config storage
40
+ - uses `--overwrite-keychain` only when you have confirmed the plaintext config token is the credential you intend to keep
41
+ - `wlfi-agent daemon`
42
+ - not a user entrypoint; daemon lifecycle is managed by `wlfi-agent admin setup`
4
43
 
5
44
  ## Install
6
45
 
46
+ ### Install from npm
47
+
7
48
  ```bash
8
49
  npm i -g @wlfi-agent/cli
9
50
  ```
10
51
 
11
- ## Configuration
52
+ ### Work from this repo
53
+
54
+ ```bash
55
+ pnpm install
56
+ npm run build
57
+ npm run install:rust-binaries
58
+ ```
59
+
60
+ If you update Rust daemon code, rerun `npm run install:rust-binaries` so the root-managed daemon uses the new installed binaries under `~/.wlfi_agent/bin`.
61
+
62
+ ## Easiest wallet setup
63
+
64
+ Run this once:
65
+
66
+ ```bash
67
+ wlfi-agent admin setup
68
+ ```
69
+
70
+ Preview the exact sanitized setup plan first:
71
+
72
+ ```bash
73
+ wlfi-agent admin setup --plan
74
+ ```
75
+
76
+ The preview is read-only. It does not prompt for the vault password, does not touch sudo, and does not mutate wallet or policy state. It prints the planned Rust command, trust preflight results, overwrite risk, and the password transport mode that would be used for the real setup.
77
+
78
+ You will be prompted for the vault password. The command:
79
+
80
+ - installs or refreshes the root daemon
81
+ - waits for the daemon to come up
82
+ - configures the requested spending policies
83
+ - imports the agent token into macOS Keychain
84
+ - prints the wallet address
85
+
86
+ By default, setup keeps the freshly issued agent auth token in macOS Keychain and redacts it from CLI output. Only use `--print-agent-auth-token` when you intentionally need to export that secret.
87
+
88
+ Example with explicit chain config:
89
+
90
+ ```bash
91
+ wlfi-agent admin setup \
92
+ --network 11155111 \
93
+ --chain-name sepolia \
94
+ --rpc-url https://rpc.sepolia.example \
95
+ --allow-native-eth \
96
+ --per-tx-max-wei 1000000000000000000 \
97
+ --daily-max-wei 5000000000000000000 \
98
+ --weekly-max-wei 20000000000000000000
99
+ ```
100
+
101
+ Typical output ends with:
102
+
103
+ ```text
104
+ setup complete
105
+ address: 0x...
106
+ vault key id: ...
107
+ agent key id: ...
108
+ daemon socket: /Library/WLFI/run/daemon.sock
109
+ state file: /var/db/wlfi-agent/daemon-state.enc
110
+ ```
111
+
112
+ ## Policy definition
113
+
114
+ There are three practical policy layers:
115
+
116
+ 1. default limits for every destination
117
+ 2. stricter per-destination overrides
118
+ 3. manual-approval overlays for transactions that should pause for operator review
119
+
120
+ ### Token-first policy setup: `wlfi-agent admin tui`
121
+
122
+ Use the TUI when you want the easiest way to define:
123
+
124
+ - a saved token inventory as the primary view
125
+ - per-token per-tx / daily / weekly limits in token decimals
126
+ - per-token gas / fee / calldata caps
127
+ - token-specific destination overrides
128
+ - token-specific manual approval overlays
129
+ - token mappings across multiple saved networks
130
+
131
+ Run:
132
+
133
+ ```bash
134
+ wlfi-agent admin tui
135
+ ```
136
+
137
+ Like `admin setup`, the TUI stores the new agent auth token in macOS Keychain by default and does not print it unless you pass `--print-agent-auth-token`.
138
+
139
+ The TUI starts on the token list, lets you add new tokens or networks, fetches token name/symbol/decimals from the selected network RPC, and bootstraps every saved token across its selected networks.
140
+
141
+ Important rule: destination overrides can only tighten the matching token policy; they cannot relax it.
142
+
143
+ ### Direct setup flags
144
+
145
+ If you prefer direct flags over the TUI, `wlfi-agent admin setup` already passes through the common policy and wallet-setup options shown above.
146
+
147
+ Useful direct flags include:
148
+
149
+ - `--per-tx-max-wei`
150
+ - `--daily-max-wei`
151
+ - `--weekly-max-wei`
152
+ - `--max-gas-per-chain-wei`
153
+ - `--daily-max-tx-count`
154
+ - `--per-tx-max-fee-per-gas-wei`
155
+ - `--per-tx-max-priority-fee-per-gas-wei`
156
+ - `--per-tx-max-calldata-bytes`
157
+ - `--network`
158
+ - `--token`
159
+ - `--allow-native-eth`
160
+ - `--recipient`
161
+
162
+ ### Manual approval policies
163
+
164
+ Manual approval is an overlay policy: matching requests are held until an operator approves or rejects them.
165
+
166
+ Create one with direct flags:
167
+
168
+ ```bash
169
+ wlfi-agent admin add-manual-approval-policy \
170
+ --network 11155111 \
171
+ --recipient 0x1111111111111111111111111111111111111111 \
172
+ --allow-native-eth \
173
+ --min-amount-wei 1000000000000000 \
174
+ --max-amount-wei 2000000000000000
175
+ ```
176
+
177
+ ERC-20 example:
178
+
179
+ ```bash
180
+ wlfi-agent admin add-manual-approval-policy \
181
+ --network 11155111 \
182
+ --recipient 0x2222222222222222222222222222222222222222 \
183
+ --token 0x3333333333333333333333333333333333333333 \
184
+ --min-amount-wei 1000000 \
185
+ --max-amount-wei 5000000
186
+ ```
187
+
188
+ The policy matches all transactions of the requested type that fall inside the destination / token / amount range.
189
+
190
+ ### Inspect and resolve manual approvals locally
191
+
192
+ ```bash
193
+ wlfi-agent admin list-manual-approval-requests
194
+ ```
195
+
196
+ Approve locally:
197
+
198
+ ```bash
199
+ wlfi-agent admin approve-manual-approval-request \
200
+ --approval-request-id <REQUEST_ID>
201
+ ```
202
+
203
+ Reject locally:
204
+
205
+ ```bash
206
+ wlfi-agent admin reject-manual-approval-request \
207
+ --approval-request-id <REQUEST_ID>
208
+ ```
209
+
210
+ ## Agent requests
211
+
212
+ Top-level signing commands always go through the daemon.
213
+
214
+ After `wlfi-agent admin setup`, the normal path is to rely on the configured agent key id plus the token already stored in macOS Keychain. You only need `--agent-key-id` or `--agent-auth-token-stdin` when overriding that default.
215
+
216
+ Native transfer:
217
+
218
+ ```bash
219
+ wlfi-agent transfer-native \
220
+ --network 11155111 \
221
+ --to 0x1111111111111111111111111111111111111111 \
222
+ --amount-wei 1500000000000000
223
+ ```
224
+
225
+ ERC-20 transfer:
226
+
227
+ ```bash
228
+ wlfi-agent transfer \
229
+ --network 11155111 \
230
+ --token 0x3333333333333333333333333333333333333333 \
231
+ --to 0x2222222222222222222222222222222222222222 \
232
+ --amount-wei 1000000
233
+ ```
234
+
235
+ Approve allowance:
236
+
237
+ ```bash
238
+ wlfi-agent approve \
239
+ --network 11155111 \
240
+ --token 0x3333333333333333333333333333333333333333 \
241
+ --spender 0x4444444444444444444444444444444444444444 \
242
+ --amount-wei 1000000
243
+ ```
244
+
245
+ Raw policy-checked transaction request:
246
+
247
+ ```bash
248
+ wlfi-agent broadcast \
249
+ --network 11155111 \
250
+ --to 0x1111111111111111111111111111111111111111 \
251
+ --gas-limit 21000 \
252
+ --max-fee-per-gas-wei 2000000000 \
253
+ --value-wei 1500000000000000
254
+ ```
255
+
256
+ If a request hits a manual-approval policy, the CLI prints:
12
257
 
13
- Backend URL is read from `WLFI_AGENT_BACKEND_URL` and defaults to `http://localhost:3000`.
258
+ - approval request id
259
+ - frontend approval URL, if relay is configured
260
+ - relay URL
261
+ - fallback local admin CLI command
14
262
 
15
- ## Documentation
263
+ ## Local health checks and cleanup
16
264
 
17
- For full usage and API details, see `docs/agent-wallet.md` in this repository.
265
+ Inspect the current machine state:
266
+
267
+ ```bash
268
+ wlfi-agent status
269
+ ```
270
+
271
+ Strict mode is useful in automation:
272
+
273
+ ```bash
274
+ wlfi-agent status --strict
275
+ ```
276
+
277
+ Repair local non-root issues such as lingering plaintext bootstrap files or legacy `agentAuthToken` config storage:
278
+
279
+ ```bash
280
+ wlfi-agent repair
281
+ ```
282
+
283
+ If you intentionally want to keep bootstrap artifacts but redact them in place instead of deleting them:
284
+
285
+ ```bash
286
+ wlfi-agent repair --redact-bootstrap
287
+ ```
288
+
289
+ ## Relay setup
290
+
291
+ Relay is optional. Use it when you want browser-based manual approval.
292
+
293
+ ### Local development setup
294
+
295
+ 1. Copy the relay config file:
296
+
297
+ ```bash
298
+ cp apps/relay/.env.example apps/relay/.env
299
+ ```
300
+
301
+ 2. Edit `apps/relay/.env` and set the real values you want to use.
302
+
303
+ 3. Create `apps/web/.env.local`:
304
+
305
+ ```bash
306
+ cat > apps/web/.env.local <<'EOF_WEB'
307
+ NEXT_PUBLIC_WLFI_RELAY_BASE_URL=http://localhost:8787
308
+ NEXT_PUBLIC_WLFI_SITE_NAME=WLFI Approval Console
309
+ EOF_WEB
310
+ ```
311
+
312
+ 4. Start Valkey:
313
+
314
+ ```bash
315
+ docker compose -f zarf/docker/valkey/compose.yml up -d
316
+ ```
317
+
318
+ 5. Start the relay:
319
+
320
+ ```bash
321
+ pnpm --filter @wlfi-agent/relay dev
322
+ ```
323
+
324
+ 6. Start the web UI:
325
+
326
+ ```bash
327
+ pnpm --filter @wlfi-agent/web exec next dev --hostname 127.0.0.1 --port 3000
328
+ ```
329
+
330
+ 7. Point the daemon at the relay and web UI:
331
+
332
+ ```bash
333
+ wlfi-agent admin set-relay-config \
334
+ --relay-url http://localhost:8787 \
335
+ --frontend-url http://127.0.0.1:3000
336
+ ```
337
+
338
+ The relay does not require daemon auth for daemon registration, polling, or feedback. Only
339
+ admin relay APIs require `RELAY_ADMIN_TOKEN`.
340
+
341
+ 8. Confirm the daemon-side relay config:
342
+
343
+ ```bash
344
+ wlfi-agent admin get-relay-config
345
+ ```
346
+
347
+ ### Production relay deploy
348
+
349
+ The relay app includes Serverless configs under `zarf/serverless/relay/`.
350
+
351
+ ```bash
352
+ pnpm --filter @wlfi-agent/relay deploy:development
353
+ pnpm --filter @wlfi-agent/relay deploy:production
354
+ ```
355
+
356
+ For local dev, prefer the checked-in `apps/relay/.env` file. For deployed environments, use your normal secret manager or platform config.
357
+
358
+ ## Relay approval flow
359
+
360
+ When relay is configured and a request requires manual approval:
361
+
362
+ 1. the agent CLI prints a frontend approval URL
363
+ 2. the operator opens that URL in the browser
364
+ 3. the frontend encrypts the vault password + decision to the daemon’s advertised X25519 public key
365
+ 4. the relay queues the encrypted update
366
+ 5. the daemon polls, decrypts, applies the decision, and reports status back
367
+ 6. the original request can be retried and signed
368
+
369
+ If the frontend link is unavailable, operators can always fall back to the local admin CLI approval command printed by the agent CLI.
370
+
371
+ ## Operational notes
372
+
373
+ - The daemon state file lives at `/var/db/wlfi-agent/daemon-state.enc` and is intended to be root-only.
374
+ - The managed socket lives at `/Library/WLFI/run/daemon.sock`.
375
+ - If `setup` says the daemon password does not unlock the stored state, use the original vault password or reset the managed state before setting up a fresh wallet.
376
+ - Forgotten vault password recovery is destructive: run `wlfi-agent admin reset`, then `wlfi-agent admin setup` to create a new wallet.
377
+ - After changing daemon-side Rust code, run `npm run install:rust-binaries` and restart the managed daemon through `wlfi-agent admin setup`.
378
+
379
+ ## Reset a forgotten password
380
+
381
+ If you forgot the vault password, there is no recovery path for the existing encrypted daemon state. Use reset only when you intentionally want to discard the old wallet and create a new one.
382
+
383
+ ```bash
384
+ wlfi-agent admin reset
385
+ ```
386
+
387
+ For automation or CI-style local flows:
388
+
389
+ ```bash
390
+ wlfi-agent admin reset --yes
391
+ ```
392
+
393
+ By default, reset keeps non-secret config like chain settings, but removes the managed daemon state, the daemon password stored in System Keychain, the local agent token, and lingering bootstrap artifacts.
394
+
395
+ If you want a totally clean local slate too:
396
+
397
+ ```bash
398
+ wlfi-agent admin reset --yes --delete-config
399
+ ```
400
+
401
+ After reset, run `wlfi-agent admin setup` to create a new wallet.
402
+
403
+ ## Fully uninstall WLFI Agent
404
+
405
+ Use uninstall when you want a full local cleanup instead of preparing for another setup. It removes:
406
+
407
+ - the managed LaunchDaemon
408
+ - `/Library/WLFI`
409
+ - `/var/db/wlfi-agent`
410
+ - `/var/log/wlfi-agent`
411
+ - `~/.wlfi_agent`
412
+ - the daemon password in System Keychain
413
+ - the local agent auth token in Keychain
414
+
415
+ ```bash
416
+ wlfi-agent admin uninstall
417
+ ```
418
+
419
+ For automation or CI-style local flows:
420
+
421
+ ```bash
422
+ wlfi-agent admin uninstall --yes
423
+ ```
424
+
425
+ ## Useful commands
426
+
427
+ ```bash
428
+ wlfi-agent admin setup
429
+ wlfi-agent admin tui
430
+ wlfi-agent admin uninstall
431
+ wlfi-agent admin get-relay-config
432
+ wlfi-agent admin list-manual-approval-requests
433
+ wlfi-agent wallet status
434
+ npm run install:rust-binaries
435
+ pnpm build
436
+ pnpm typecheck
437
+ ```
@@ -0,0 +1,26 @@
1
+ [package]
2
+ name = "wlfi-agent-admin"
3
+ version.workspace = true
4
+ edition.workspace = true
5
+ license.workspace = true
6
+ authors.workspace = true
7
+
8
+ [dependencies]
9
+ anyhow.workspace = true
10
+ clap.workspace = true
11
+ crossterm.workspace = true
12
+ hex.workspace = true
13
+ libc.workspace = true
14
+ ratatui.workspace = true
15
+ reqwest.workspace = true
16
+ serde.workspace = true
17
+ serde_json.workspace = true
18
+ rpassword.workspace = true
19
+ time.workspace = true
20
+ tokio.workspace = true
21
+ uuid.workspace = true
22
+ zeroize.workspace = true
23
+ vault-daemon = { path = "../vault-daemon" }
24
+ vault-domain = { path = "../vault-domain" }
25
+ vault-signer = { path = "../vault-signer" }
26
+ vault-transport-unix = { path = "../vault-transport-unix" }