run402 4.93.2 → 4.95.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 (316) hide show
  1. package/README.md +61 -59
  2. package/cli.mjs +40 -47
  3. package/core-dist/config.js +52 -18
  4. package/core-dist/control-plane-session.js +31 -6
  5. package/core-dist/keystore.js +7 -7
  6. package/core-dist/profiles.js +9 -7
  7. package/core-dist/{allowance-auth.js → wallet-auth.js} +15 -15
  8. package/{sdk/core-dist/allowance.js → core-dist/wallet.js} +20 -20
  9. package/{sdk/core-dist/write-auth-session.js → core-dist/write-approvals.js} +19 -19
  10. package/gitvault-surface.json +2 -2
  11. package/lib/admin.mjs +6 -6
  12. package/lib/agent.mjs +20 -18
  13. package/lib/ai.mjs +5 -5
  14. package/lib/approve.mjs +81 -0
  15. package/lib/apps.mjs +12 -12
  16. package/lib/archives.mjs +371 -8
  17. package/lib/argparse.mjs +5 -5
  18. package/lib/assets.mjs +14 -14
  19. package/lib/auth.mjs +34 -34
  20. package/lib/billing.mjs +6 -6
  21. package/lib/branches.mjs +7 -7
  22. package/lib/buzz-doctor.mjs +2 -2
  23. package/lib/buzz-notifications.mjs +5 -5
  24. package/lib/buzz.mjs +3 -3
  25. package/lib/buzz.test.mjs +1 -1
  26. package/lib/cache.mjs +1 -1
  27. package/lib/cdn.mjs +2 -2
  28. package/lib/ci.mjs +12 -12
  29. package/lib/claims.mjs +2 -2
  30. package/lib/cold-start.mjs +21 -21
  31. package/lib/command-manifest.mjs +55 -70
  32. package/lib/config.mjs +28 -28
  33. package/lib/contacts.mjs +16 -16
  34. package/lib/contracts.mjs +12 -12
  35. package/lib/credentials.mjs +33 -33
  36. package/lib/daemon-path.mjs +1 -1
  37. package/lib/delegates.mjs +14 -14
  38. package/lib/deliveries.mjs +6 -6
  39. package/lib/deploy-rehearse-discovery.test.mjs +7 -7
  40. package/lib/deploy-v2.mjs +241 -193
  41. package/lib/deploy.mjs +21 -53
  42. package/lib/dev.mjs +3 -3
  43. package/lib/doctor-source-scan.mjs +1 -1
  44. package/lib/doctor.mjs +63 -63
  45. package/lib/domains.mjs +27 -27
  46. package/lib/email.mjs +38 -38
  47. package/lib/errors.mjs +40 -24
  48. package/lib/escalations.mjs +5 -5
  49. package/lib/events.mjs +32 -25
  50. package/lib/feedback.mjs +12 -12
  51. package/lib/functions.mjs +34 -34
  52. package/lib/gitvault-daemon.mjs +1 -1
  53. package/lib/gitvault-scaffold.mjs +2 -2
  54. package/lib/gitvault.mjs +2 -2
  55. package/lib/grants.mjs +7 -7
  56. package/lib/image.mjs +10 -10
  57. package/lib/init.mjs +69 -69
  58. package/lib/jobs.mjs +15 -15
  59. package/lib/lightning-wallet.mjs +28 -28
  60. package/lib/live.mjs +1 -1
  61. package/lib/login.mjs +207 -0
  62. package/lib/logout.mjs +53 -0
  63. package/lib/logs.mjs +8 -8
  64. package/lib/messages.mjs +5 -5
  65. package/lib/next-actions.mjs +16 -16
  66. package/lib/org-context.mjs +13 -13
  67. package/lib/{org.mjs → orgs.mjs} +215 -167
  68. package/lib/pay.mjs +1 -1
  69. package/lib/projects.mjs +70 -84
  70. package/lib/redeem.mjs +7 -8
  71. package/lib/remote-helper-session.mjs +12 -12
  72. package/lib/repos.mjs +83 -83
  73. package/lib/rooms.mjs +105 -69
  74. package/lib/sdk-errors.mjs +10 -5
  75. package/lib/sdk.mjs +3 -3
  76. package/lib/secrets.mjs +13 -13
  77. package/lib/service.mjs +5 -5
  78. package/lib/session-proofs.mjs +21 -0
  79. package/lib/sign-in.mjs +296 -0
  80. package/lib/sites.mjs +22 -22
  81. package/lib/snapshots.mjs +10 -10
  82. package/lib/stats.mjs +2 -2
  83. package/lib/status.mjs +25 -25
  84. package/lib/subdomains.mjs +30 -30
  85. package/lib/subscriptions.mjs +10 -10
  86. package/lib/tier.mjs +29 -22
  87. package/lib/transfer.mjs +59 -86
  88. package/lib/up.mjs +14 -14
  89. package/lib/wallet-context.mjs +4 -4
  90. package/lib/wallet-context.test.mjs +3 -3
  91. package/lib/wallets.mjs +197 -32
  92. package/lib/webhook-secret.mjs +6 -6
  93. package/lib/webhooks.mjs +8 -8
  94. package/lib/whoami.mjs +102 -0
  95. package/package.json +1 -1
  96. package/sdk/core-dist/config.js +52 -18
  97. package/sdk/core-dist/control-plane-session.js +31 -6
  98. package/sdk/core-dist/keystore.js +7 -7
  99. package/sdk/core-dist/profiles.js +9 -7
  100. package/sdk/core-dist/{allowance-auth.js → wallet-auth.js} +15 -15
  101. package/{core-dist/allowance.js → sdk/core-dist/wallet.js} +20 -20
  102. package/{core-dist/write-auth-session.js → sdk/core-dist/write-approvals.js} +19 -19
  103. package/sdk/dist/actions.d.ts +4 -4
  104. package/sdk/dist/actions.d.ts.map +1 -1
  105. package/sdk/dist/app-up.d.ts +2 -2
  106. package/sdk/dist/app-up.d.ts.map +1 -1
  107. package/sdk/dist/config.d.ts +1 -2
  108. package/sdk/dist/config.d.ts.map +1 -1
  109. package/sdk/dist/config.js.map +1 -1
  110. package/sdk/dist/control-plane-credentials.d.ts +8 -8
  111. package/sdk/dist/control-plane-credentials.js +7 -7
  112. package/sdk/dist/credentials.d.ts +20 -20
  113. package/sdk/dist/credentials.d.ts.map +1 -1
  114. package/sdk/dist/credentials.js +1 -1
  115. package/sdk/dist/errors.d.ts +26 -28
  116. package/sdk/dist/errors.d.ts.map +1 -1
  117. package/sdk/dist/errors.js +35 -38
  118. package/sdk/dist/errors.js.map +1 -1
  119. package/sdk/dist/index.d.ts +29 -16
  120. package/sdk/dist/index.d.ts.map +1 -1
  121. package/sdk/dist/index.js +30 -17
  122. package/sdk/dist/index.js.map +1 -1
  123. package/sdk/dist/kernel.d.ts +1 -1
  124. package/sdk/dist/kernel.d.ts.map +1 -1
  125. package/sdk/dist/kernel.js +10 -9
  126. package/sdk/dist/kernel.js.map +1 -1
  127. package/sdk/dist/namespaces/admin.d.ts +52 -121
  128. package/sdk/dist/namespaces/admin.d.ts.map +1 -1
  129. package/sdk/dist/namespaces/admin.js +41 -45
  130. package/sdk/dist/namespaces/admin.js.map +1 -1
  131. package/sdk/dist/namespaces/agent.d.ts +2 -2
  132. package/sdk/dist/namespaces/agent.d.ts.map +1 -1
  133. package/sdk/dist/namespaces/agent.js +2 -2
  134. package/sdk/dist/namespaces/agent.js.map +1 -1
  135. package/sdk/dist/namespaces/ai.d.ts +2 -2
  136. package/sdk/dist/namespaces/ai.js +3 -3
  137. package/sdk/dist/namespaces/ai.js.map +1 -1
  138. package/sdk/dist/namespaces/assets.js +1 -1
  139. package/sdk/dist/namespaces/assets.js.map +1 -1
  140. package/sdk/dist/namespaces/billing.d.ts +6 -3
  141. package/sdk/dist/namespaces/billing.d.ts.map +1 -1
  142. package/sdk/dist/namespaces/billing.js.map +1 -1
  143. package/sdk/dist/namespaces/buzz-notifications.types.d.ts +1 -1
  144. package/sdk/dist/namespaces/buzz.d.ts +2 -2
  145. package/sdk/dist/namespaces/buzz.d.ts.map +1 -1
  146. package/sdk/dist/namespaces/buzz.js +2 -2
  147. package/sdk/dist/namespaces/buzz.js.map +1 -1
  148. package/sdk/dist/namespaces/buzz.types.d.ts +2 -2
  149. package/sdk/dist/namespaces/buzz.types.d.ts.map +1 -1
  150. package/sdk/dist/namespaces/ci.js +3 -3
  151. package/sdk/dist/namespaces/ci.js.map +1 -1
  152. package/sdk/dist/namespaces/credentials.types.d.ts +1 -1
  153. package/sdk/dist/namespaces/deploy.d.ts +1 -1
  154. package/sdk/dist/namespaces/deploy.d.ts.map +1 -1
  155. package/sdk/dist/namespaces/deploy.js +31 -32
  156. package/sdk/dist/namespaces/deploy.js.map +1 -1
  157. package/sdk/dist/namespaces/deploy.types.d.ts +6 -6
  158. package/sdk/dist/namespaces/deploy.types.d.ts.map +1 -1
  159. package/sdk/dist/namespaces/domains.d.ts +10 -2
  160. package/sdk/dist/namespaces/domains.d.ts.map +1 -1
  161. package/sdk/dist/namespaces/domains.js +10 -5
  162. package/sdk/dist/namespaces/domains.js.map +1 -1
  163. package/sdk/dist/namespaces/errors.js +1 -1
  164. package/sdk/dist/namespaces/escalations.d.ts +1 -1
  165. package/sdk/dist/namespaces/escalations.js +1 -1
  166. package/sdk/dist/namespaces/escalations.types.d.ts +2 -2
  167. package/sdk/dist/namespaces/escalations.types.d.ts.map +1 -1
  168. package/sdk/dist/namespaces/events.types.d.ts +1 -1
  169. package/sdk/dist/namespaces/functions.d.ts +1 -1
  170. package/sdk/dist/namespaces/functions.js +2 -2
  171. package/sdk/dist/namespaces/functions.js.map +1 -1
  172. package/sdk/dist/namespaces/gitvault.crypto.d.ts +1 -1
  173. package/sdk/dist/namespaces/gitvault.d.ts +26 -26
  174. package/sdk/dist/namespaces/gitvault.d.ts.map +1 -1
  175. package/sdk/dist/namespaces/gitvault.js +113 -113
  176. package/sdk/dist/namespaces/gitvault.js.map +1 -1
  177. package/sdk/dist/namespaces/me.d.ts +120 -0
  178. package/sdk/dist/namespaces/me.d.ts.map +1 -0
  179. package/sdk/dist/namespaces/me.js +34 -0
  180. package/sdk/dist/namespaces/me.js.map +1 -0
  181. package/sdk/dist/namespaces/org.d.ts +108 -6
  182. package/sdk/dist/namespaces/org.d.ts.map +1 -1
  183. package/sdk/dist/namespaces/org.js +63 -7
  184. package/sdk/dist/namespaces/org.js.map +1 -1
  185. package/sdk/dist/namespaces/org.types.d.ts +29 -9
  186. package/sdk/dist/namespaces/org.types.d.ts.map +1 -1
  187. package/sdk/dist/namespaces/pay.js +3 -3
  188. package/sdk/dist/namespaces/pay.js.map +1 -1
  189. package/sdk/dist/namespaces/projects.d.ts +9 -9
  190. package/sdk/dist/namespaces/projects.js +15 -15
  191. package/sdk/dist/namespaces/projects.js.map +1 -1
  192. package/sdk/dist/namespaces/projects.types.d.ts +28 -12
  193. package/sdk/dist/namespaces/projects.types.d.ts.map +1 -1
  194. package/sdk/dist/namespaces/rooms.d.ts +7 -7
  195. package/sdk/dist/namespaces/rooms.js +17 -17
  196. package/sdk/dist/namespaces/rooms.js.map +1 -1
  197. package/sdk/dist/namespaces/rooms.types.d.ts +9 -9
  198. package/sdk/dist/namespaces/rooms.types.d.ts.map +1 -1
  199. package/sdk/dist/namespaces/service.d.ts +1 -1
  200. package/sdk/dist/namespaces/service.js +1 -1
  201. package/sdk/dist/namespaces/{operator-session.d.ts → session.d.ts} +135 -51
  202. package/sdk/dist/namespaces/session.d.ts.map +1 -0
  203. package/sdk/dist/namespaces/{operator-session.js → session.js} +118 -30
  204. package/sdk/dist/namespaces/session.js.map +1 -0
  205. package/sdk/dist/namespaces/subdomains.d.ts +5 -5
  206. package/sdk/dist/namespaces/subdomains.d.ts.map +1 -1
  207. package/sdk/dist/namespaces/subdomains.js +6 -6
  208. package/sdk/dist/namespaces/subdomains.js.map +1 -1
  209. package/sdk/dist/namespaces/tier.d.ts +44 -21
  210. package/sdk/dist/namespaces/tier.d.ts.map +1 -1
  211. package/sdk/dist/namespaces/tier.js +7 -7
  212. package/sdk/dist/namespaces/tier.js.map +1 -1
  213. package/sdk/dist/namespaces/transfers.d.ts +119 -85
  214. package/sdk/dist/namespaces/transfers.d.ts.map +1 -1
  215. package/sdk/dist/namespaces/transfers.js +31 -38
  216. package/sdk/dist/namespaces/transfers.js.map +1 -1
  217. package/sdk/dist/namespaces/vouchers.d.ts +9 -10
  218. package/sdk/dist/namespaces/vouchers.d.ts.map +1 -1
  219. package/sdk/dist/namespaces/vouchers.js +4 -5
  220. package/sdk/dist/namespaces/vouchers.js.map +1 -1
  221. package/sdk/dist/namespaces/wallets.d.ts +72 -3
  222. package/sdk/dist/namespaces/wallets.d.ts.map +1 -1
  223. package/sdk/dist/namespaces/wallets.js +141 -3
  224. package/sdk/dist/namespaces/wallets.js.map +1 -1
  225. package/sdk/dist/namespaces/write-approval.d.ts +101 -0
  226. package/sdk/dist/namespaces/write-approval.d.ts.map +1 -0
  227. package/sdk/dist/namespaces/write-approval.js +62 -0
  228. package/sdk/dist/namespaces/write-approval.js.map +1 -0
  229. package/sdk/dist/node/actions-node.d.ts +3 -3
  230. package/sdk/dist/node/actions-node.d.ts.map +1 -1
  231. package/sdk/dist/node/actions-node.js +44 -44
  232. package/sdk/dist/node/actions-node.js.map +1 -1
  233. package/sdk/dist/node/assets-node.js +6 -6
  234. package/sdk/dist/node/assets-node.js.map +1 -1
  235. package/sdk/dist/node/{bearer-claim-key.d.ts → bearer-redeem-key.d.ts} +12 -12
  236. package/sdk/dist/node/bearer-redeem-key.d.ts.map +1 -0
  237. package/sdk/dist/node/{bearer-claim-key.js → bearer-redeem-key.js} +21 -21
  238. package/sdk/dist/node/bearer-redeem-key.js.map +1 -0
  239. package/sdk/dist/node/ci.d.ts +1 -1
  240. package/sdk/dist/node/ci.d.ts.map +1 -1
  241. package/sdk/dist/node/ci.js +6 -6
  242. package/sdk/dist/node/ci.js.map +1 -1
  243. package/sdk/dist/node/credentials.d.ts +18 -17
  244. package/sdk/dist/node/credentials.d.ts.map +1 -1
  245. package/sdk/dist/node/credentials.js +29 -28
  246. package/sdk/dist/node/credentials.js.map +1 -1
  247. package/sdk/dist/node/deploy-manifest.d.ts +3 -5
  248. package/sdk/dist/node/deploy-manifest.d.ts.map +1 -1
  249. package/sdk/dist/node/deploy-manifest.js +3 -12
  250. package/sdk/dist/node/deploy-manifest.js.map +1 -1
  251. package/sdk/dist/node/funding-recovery.d.ts +1 -1
  252. package/sdk/dist/node/funding-recovery.d.ts.map +1 -1
  253. package/sdk/dist/node/funding-recovery.js +1 -1
  254. package/sdk/dist/node/funding-recovery.js.map +1 -1
  255. package/sdk/dist/node/gitvault-apply.d.ts +1 -1
  256. package/sdk/dist/node/gitvault-apply.d.ts.map +1 -1
  257. package/sdk/dist/node/gitvault-apply.js +1 -1
  258. package/sdk/dist/node/gitvault-apply.js.map +1 -1
  259. package/sdk/dist/node/gitvault-handoff.d.ts +22 -22
  260. package/sdk/dist/node/gitvault-handoff.d.ts.map +1 -1
  261. package/sdk/dist/node/gitvault-handoff.js +45 -45
  262. package/sdk/dist/node/gitvault-handoff.js.map +1 -1
  263. package/sdk/dist/node/gitvault-prewarm.js +7 -7
  264. package/sdk/dist/node/gitvault-prewarm.js.map +1 -1
  265. package/sdk/dist/node/gitvault-restore.d.ts +1 -1
  266. package/sdk/dist/node/gitvault-restore.js +1 -1
  267. package/sdk/dist/node/index.d.ts +16 -16
  268. package/sdk/dist/node/index.d.ts.map +1 -1
  269. package/sdk/dist/node/index.js +15 -15
  270. package/sdk/dist/node/index.js.map +1 -1
  271. package/sdk/dist/node/manifest-export.js +2 -2
  272. package/sdk/dist/node/manifest-export.js.map +1 -1
  273. package/sdk/dist/node/org-adopt.d.ts +49 -0
  274. package/sdk/dist/node/org-adopt.d.ts.map +1 -0
  275. package/sdk/dist/node/org-adopt.js +77 -0
  276. package/sdk/dist/node/org-adopt.js.map +1 -0
  277. package/sdk/dist/node/paid-fetch.d.ts +7 -7
  278. package/sdk/dist/node/paid-fetch.d.ts.map +1 -1
  279. package/sdk/dist/node/paid-fetch.js +54 -54
  280. package/sdk/dist/node/paid-fetch.js.map +1 -1
  281. package/sdk/dist/node/preflight.d.ts +1 -1
  282. package/sdk/dist/node/preflight.d.ts.map +1 -1
  283. package/sdk/dist/node/preflight.js +1 -1
  284. package/sdk/dist/node/preflight.js.map +1 -1
  285. package/sdk/dist/node/sites-node.js +1 -1
  286. package/sdk/dist/node/sites-node.js.map +1 -1
  287. package/sdk/dist/node/source-scan.d.ts +1 -1
  288. package/sdk/dist/node/source-scan.js +2 -2
  289. package/sdk/dist/node/source-scan.js.map +1 -1
  290. package/sdk/dist/scoped.d.ts +11 -11
  291. package/sdk/dist/scoped.d.ts.map +1 -1
  292. package/sdk/dist/scoped.js +5 -5
  293. package/sdk/dist/scoped.js.map +1 -1
  294. package/core-dist/operator-session.js +0 -154
  295. package/lib/allowance.mjs +0 -355
  296. package/lib/cloud.mjs +0 -256
  297. package/lib/core.mjs +0 -123
  298. package/lib/operator-proofs.mjs +0 -22
  299. package/lib/operator.mjs +0 -771
  300. package/sdk/core-dist/operator-session.js +0 -154
  301. package/sdk/dist/namespaces/allowance.d.ts +0 -79
  302. package/sdk/dist/namespaces/allowance.d.ts.map +0 -1
  303. package/sdk/dist/namespaces/allowance.js +0 -149
  304. package/sdk/dist/namespaces/allowance.js.map +0 -1
  305. package/sdk/dist/namespaces/operator-session.d.ts.map +0 -1
  306. package/sdk/dist/namespaces/operator-session.js.map +0 -1
  307. package/sdk/dist/namespaces/operator.d.ts +0 -359
  308. package/sdk/dist/namespaces/operator.d.ts.map +0 -1
  309. package/sdk/dist/namespaces/operator.js +0 -272
  310. package/sdk/dist/namespaces/operator.js.map +0 -1
  311. package/sdk/dist/node/bearer-claim-key.d.ts.map +0 -1
  312. package/sdk/dist/node/bearer-claim-key.js.map +0 -1
  313. package/sdk/dist/node/operator-claim.d.ts +0 -49
  314. package/sdk/dist/node/operator-claim.d.ts.map +0 -1
  315. package/sdk/dist/node/operator-claim.js +0 -77
  316. package/sdk/dist/node/operator-claim.js.map +0 -1
package/lib/init.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { readAllowance, saveAllowance, loadKeyStore, configDir, configureApiBase, getActiveProjectId } from "./config.mjs";
1
+ import { readWallet, saveWallet, loadKeyStore, configDir, configureApiBase, getActiveProjectId } from "./config.mjs";
2
2
  import { getSdk } from "./sdk.mjs";
3
3
  import { fail } from "./sdk-errors.mjs";
4
4
  import { upDeployAction, deployAction } from "./next-actions.mjs";
@@ -13,7 +13,7 @@ const USDC_SEPOLIA = "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
13
13
  const PATH_USD = "0x20c0000000000000000000000000000000000000";
14
14
  const TEMPO_RPC = "https://rpc.moderato.tempo.xyz/";
15
15
 
16
- const HELP = `run402 init — Set up allowance, funding, and check tier status
16
+ const HELP = `run402 init — Set up wallet, funding, and check tier status
17
17
 
18
18
  Usage:
19
19
  run402 init Set up with x402 (Base Sepolia) — default
@@ -21,19 +21,19 @@ Usage:
21
21
  Configure a Run402 Core/API target for the active
22
22
  profile without setting up Cloud payment.
23
23
  run402 init mpp Set up with MPP (Tempo Moderato)
24
- run402 init lightning Set up the Lightning allowance: a budgeted wallet
24
+ run402 init lightning Set up the Lightning wallet: a budgeted wallet
25
25
  minted on Run402's Hub (custody: Run402), plus the
26
- Base allowance as the x402 fallback. Lightning
26
+ Base wallet as the x402 fallback. Lightning
27
27
  becomes the default rail for paid calls.
28
28
  run402 init <rail> --switch-rail
29
29
  Switch the persisted payment rail to <rail>.
30
- Required when an allowance already exists on
30
+ Required when a wallet already exists on
31
31
  the other rail; protects scripted re-runs from
32
32
  silently flipping billing networks.
33
33
 
34
34
  Options:
35
- --voucher <code> Redeem a promo code after setup and credit this
36
- organization. Never blocks setup: if the code is invalid,
35
+ --voucher <code> Redeem a promo code after setup into this
36
+ organization's allowance. Never blocks setup: if the code is invalid,
37
37
  expired, already used, or the call fails, init warns and
38
38
  finishes normally with 'voucher_error' in the summary.
39
39
  Equivalent to running 'run402 redeem <code>' afterwards.
@@ -41,7 +41,7 @@ Options:
41
41
  for a self-hosted Run402 Core Gateway, e.g.
42
42
  http://my-core:4020.
43
43
  --switch-rail Confirm switching the persisted payment rail. Re-running
44
- init with the SAME rail as the existing allowance is always
44
+ init with the SAME rail as the existing wallet is always
45
45
  idempotent and does not need this flag.
46
46
  --name <name> Set this principal's display name (1-64 chars) — what promotion
47
47
  credit, \`run402 up\`'s room presence, and audit surfaces show
@@ -49,7 +49,7 @@ Options:
49
49
  client (claude-code, codex, cursor, or grok; RUN402_CLIENT=<name>
50
50
  declares one that is not auto-detected) and otherwise writes
51
51
  nothing; RUN402_AGENT_NAME=<name> sets or overrides it. Change
52
- it any time with \`run402 org whoami --set-name <name>\`.
52
+ it any time with \`run402 whoami --set-name <name>\`.
53
53
  --git-remote Also 'git init' the current directory when it is not a
54
54
  repository yet, so the gitvault remote can be added there.
55
55
  Opt-in on purpose: init is often run outside a project
@@ -60,7 +60,7 @@ Options:
60
60
  Output:
61
61
  Stdout is a JSON summary { config_dir, wallet, rail, network, balances,
62
62
  tier, projects_saved, active_project_id, next_step }. Progress lines
63
- (Config / Allowance / Balance / Tier / Next) go to stderr so a human
63
+ (Config / Wallet / Balance / Tier / Next) go to stderr so a human
64
64
  re-running interactively sees what's happening while a script piping stdout
65
65
  to jq stays clean. The summary also carries { gitvault } (the scaffolded
66
66
  remote), or { gitvault: null, gitvault_skipped } naming why no remote was
@@ -69,17 +69,17 @@ Output:
69
69
  project the gitvault scaffold acted on.
70
70
 
71
71
  init scaffolds the git remote only. It does NOT allocate the vault — that is
72
- \`run402 repos create --project <id>\`, which mints key material and a
72
+ \`run402 repos create --project <project_id>\`, which mints key material and a
73
73
  recovery receipt and therefore stays an explicit step.
74
74
 
75
75
  Steps (idempotent when re-run with the same rail; pass --switch-rail to change rails):
76
76
  1. Creates config directory (~/.config/run402)
77
- 2. Creates agent allowance if none exists
77
+ 2. Creates agent wallet if none exists
78
78
  3. Checks on-chain balance; requests faucet if zero
79
- 4. Shows current tier subscription status
79
+ 4. Shows current tier and lease status
80
80
  5. Lists local project count
81
- 6. Suggests next step (run402 up -y when no tier is held yet — it subscribes
82
- the prototype tier as part of the first deploy — or deploy apply)
81
+ 6. Suggests next step (run402 up -y when no tier is held yet — it sets
82
+ the prototype tier as part of the first deploy — or run402 deploy)
83
83
 
84
84
  Run this once to get started, or again to check your setup.
85
85
  `;
@@ -246,7 +246,7 @@ export async function run(args = []) {
246
246
  // scaffolder's help, not the rail-setup help. The rest of init's
247
247
  // payment-rail setup is intentionally orthogonal — agents typically
248
248
  // run `run402 init astro <dir>` to scaffold AND `run402 init` once
249
- // to set up allowance / tier.
249
+ // to set up wallet / tier.
250
250
  if (args[0] === "astro") {
251
251
  const { runInitAstro } = await import("./init-astro.mjs");
252
252
  await runInitAstro(args.slice(1));
@@ -286,7 +286,7 @@ export async function run(args = []) {
286
286
  });
287
287
  }
288
288
  // This branch configures a Core/API target and returns without setting up
289
- // an allowance — there is no organization here to credit, and promo
289
+ // a wallet — there is no organization here to credit, and promo
290
290
  // vouchers are a Run402 Cloud concept. Say so instead of accepting the
291
291
  // flag and silently dropping it.
292
292
  if (voucherCode) {
@@ -350,12 +350,12 @@ export async function run(args = []) {
350
350
  const requestedRail = isLightning ? "lightning" : isMpp ? "mpp" : "x402";
351
351
  const switchRailConfirmed = args.includes("--switch-rail");
352
352
 
353
- const existingAllowance = readAllowance();
354
- if (existingAllowance?.rail && existingAllowance.rail !== requestedRail && !switchRailConfirmed) {
353
+ const existingWallet = readWallet();
354
+ if (existingWallet?.rail && existingWallet.rail !== requestedRail && !switchRailConfirmed) {
355
355
  fail({
356
356
  code: "RAIL_SWITCH_REQUIRES_CONFIRM",
357
- message: `Already on rail '${existingAllowance.rail}'. Pass --switch-rail to switch to '${requestedRail}'.`,
358
- details: { current_rail: existingAllowance.rail, requested_rail: requestedRail },
357
+ message: `Already on rail '${existingWallet.rail}'. Pass --switch-rail to switch to '${requestedRail}'.`,
358
+ details: { current_rail: existingWallet.rail, requested_rail: requestedRail },
359
359
  });
360
360
  }
361
361
 
@@ -387,28 +387,28 @@ export async function run(args = []) {
387
387
  mkdirSync(CONFIG_DIR, { recursive: true });
388
388
  line("Config", CONFIG_DIR);
389
389
 
390
- // 2. Allowance
391
- let allowance = existingAllowance;
392
- const previousRail = allowance?.rail;
393
- if (!allowance) {
390
+ // 2. Wallet
391
+ let localWallet = existingWallet;
392
+ const previousRail = localWallet?.rail;
393
+ if (!localWallet) {
394
394
  const { generatePrivateKey, privateKeyToAccount } = await import("viem/accounts");
395
395
  const privateKey = generatePrivateKey();
396
396
  const account = privateKeyToAccount(privateKey);
397
- allowance = { address: account.address, privateKey, created: new Date().toISOString(), funded: false, rail: requestedRail };
398
- saveAllowance(allowance);
399
- line("Allowance", `${short(allowance.address)} (created)`);
397
+ localWallet = { address: account.address, privateKey, created: new Date().toISOString(), funded: false, rail: requestedRail };
398
+ saveWallet(localWallet);
399
+ line("Wallet", `${short(localWallet.address)} (created)`);
400
400
  } else {
401
401
  // Update rail if switching (a wallet leaving Lightning keeps its pairing on disk until revoked).
402
- if (allowance.rail !== requestedRail) {
403
- allowance = { ...allowance, rail: requestedRail };
404
- saveAllowance(allowance);
402
+ if (localWallet.rail !== requestedRail) {
403
+ localWallet = { ...localWallet, rail: requestedRail };
404
+ saveWallet(localWallet);
405
405
  }
406
- line("Allowance", short(allowance.address));
406
+ line("Wallet", short(localWallet.address));
407
407
  }
408
408
 
409
409
  const walletName = getActiveProfile();
410
410
  const walletMeta = readMeta(walletName);
411
- summary.wallet = { local_label: walletName, server_label: walletMeta?.label ?? null, address: allowance.address };
411
+ summary.wallet = { local_label: walletName, server_label: walletMeta?.label ?? null, address: localWallet.address };
412
412
  summary.network = isLightning ? "bitcoin-mainnet" : isMpp ? "tempo-moderato" : "base-sepolia";
413
413
  summary.rail = requestedRail;
414
414
 
@@ -432,7 +432,7 @@ export async function run(args = []) {
432
432
  const client = createPublicClient({ chain: tempoModerato, transport: http() });
433
433
 
434
434
  try {
435
- const raw = await client.readContract({ address: PATH_USD, abi: USDC_ABI, functionName: "balanceOf", args: [allowance.address] });
435
+ const raw = await client.readContract({ address: PATH_USD, abi: USDC_ABI, functionName: "balanceOf", args: [localWallet.address] });
436
436
  balance = Number(raw);
437
437
  } catch {}
438
438
 
@@ -442,7 +442,7 @@ export async function run(args = []) {
442
442
  const res = await fetch(TEMPO_RPC, {
443
443
  method: "POST",
444
444
  headers: { "Content-Type": "application/json" },
445
- body: JSON.stringify({ jsonrpc: "2.0", method: "tempo_fundAddress", params: [allowance.address], id: 1 }),
445
+ body: JSON.stringify({ jsonrpc: "2.0", method: "tempo_fundAddress", params: [localWallet.address], id: 1 }),
446
446
  });
447
447
  const data = await res.json();
448
448
  if (data.result) {
@@ -452,12 +452,12 @@ export async function run(args = []) {
452
452
  for (let i = 0; i < 30; i++) {
453
453
  await new Promise(r => setTimeout(r, 1000));
454
454
  try {
455
- const raw = await client.readContract({ address: PATH_USD, abi: USDC_ABI, functionName: "balanceOf", args: [allowance.address] });
455
+ const raw = await client.readContract({ address: PATH_USD, abi: USDC_ABI, functionName: "balanceOf", args: [localWallet.address] });
456
456
  balance = Number(raw);
457
457
  if (balance > 0) break;
458
458
  } catch {}
459
459
  }
460
- saveAllowance({ ...allowance, funded: true, lastFaucet: new Date().toISOString() });
460
+ saveWallet({ ...localWallet, funded: true, lastFaucet: new Date().toISOString() });
461
461
  if (balance > 0) {
462
462
  line("Balance", `${(balance / 1e6).toFixed(2)} pathUSD (funded)`);
463
463
  } else {
@@ -482,24 +482,24 @@ export async function run(args = []) {
482
482
  const client = createPublicClient({ chain: baseSepolia, transport: http() });
483
483
 
484
484
  try {
485
- const raw = await client.readContract({ address: USDC_SEPOLIA, abi: USDC_ABI, functionName: "balanceOf", args: [allowance.address] });
485
+ const raw = await client.readContract({ address: USDC_SEPOLIA, abi: USDC_ABI, functionName: "balanceOf", args: [localWallet.address] });
486
486
  balance = Number(raw);
487
487
  } catch {}
488
488
 
489
489
  if (balance === 0) {
490
490
  line("Balance", "0 USDC — requesting faucet...");
491
491
  try {
492
- await getSdk().allowance.faucet(allowance.address);
492
+ await getSdk().wallets.faucet(localWallet.address);
493
493
  // Poll for up to 30s
494
494
  for (let i = 0; i < 30; i++) {
495
495
  await new Promise(r => setTimeout(r, 1000));
496
496
  try {
497
- const raw = await client.readContract({ address: USDC_SEPOLIA, abi: USDC_ABI, functionName: "balanceOf", args: [allowance.address] });
497
+ const raw = await client.readContract({ address: USDC_SEPOLIA, abi: USDC_ABI, functionName: "balanceOf", args: [localWallet.address] });
498
498
  balance = Number(raw);
499
499
  if (balance > 0) break;
500
500
  } catch {}
501
501
  }
502
- saveAllowance({ ...allowance, funded: true, lastFaucet: new Date().toISOString() });
502
+ saveWallet({ ...localWallet, funded: true, lastFaucet: new Date().toISOString() });
503
503
  if (balance > 0) {
504
504
  line("Balance", `${(balance / 1e6).toFixed(2)} USDC (funded)`);
505
505
  } else {
@@ -517,8 +517,8 @@ export async function run(args = []) {
517
517
 
518
518
  // 3b. Promo code, when one was handed to us.
519
519
  //
520
- // This runs BEFORE the balance read below so the credited amount shows up in
521
- // `prepaid_credit_usd_micros` without a second round-trip, and AFTER the
520
+ // This runs BEFORE the balance read below so the redeemed amount shows up in
521
+ // `allowance_usd_micros` without a second round-trip, and AFTER the
522
522
  // wallet exists so the redemption authenticates as this agent.
523
523
  //
524
524
  // NOTHING here may fail init. An advertised gift that dead-ends a build is
@@ -530,12 +530,12 @@ export async function run(args = []) {
530
530
  if (voucherCode) {
531
531
  try {
532
532
  const redemption = await getSdk().vouchers.redeem(voucherCode);
533
- const credited = (redemption.amount_usd_micros / 1_000_000).toFixed(2);
533
+ const redeemed = (redemption.amount_usd_micros / 1_000_000).toFixed(2);
534
534
  line(
535
535
  "Voucher",
536
536
  redemption.already_redeemed
537
- ? `$${credited} already credited (no second credit)`
538
- : `$${credited} credited`,
537
+ ? `$${redeemed} already added to the allowance (not added twice)`
538
+ : `$${redeemed} added to the allowance`,
539
539
  );
540
540
  summary.voucher = {
541
541
  voucher_id: redemption.voucher_id,
@@ -544,12 +544,12 @@ export async function run(args = []) {
544
544
  next_actions: Array.isArray(redemption.next_actions) ? redemption.next_actions : [],
545
545
  };
546
546
  // Relate the gift to what it buys, in the gateway's own words: its
547
- // `set_tier` next action names the largest tier the credit covers, and
548
- // that purchase settles from credit — no wallet funding step between.
547
+ // `set_tier` next action names the largest tier the allowance covers, and
548
+ // that purchase settles from the allowance — no wallet funding step between.
549
549
  const covers = summary.voucher.next_actions.find((a) => a?.type === "set_tier" && typeof a.cli === "string");
550
550
  if (covers) {
551
551
  const tierName = covers.highest_affordable_tier ?? covers.cli.replace(/^run402 tier set\s+/, "");
552
- line("Credit", `$${credited} covers ${tierName} — ${covers.cli} (settles from credit; no wallet funds needed)`);
552
+ line("Allowance", `$${redeemed} covers ${tierName} — ${covers.cli} (settles from the allowance; no wallet funds needed)`);
553
553
  }
554
554
  } catch (err) {
555
555
  // Faithful: name what failed and keep going. `voucher_error` is a
@@ -564,15 +564,15 @@ export async function run(args = []) {
564
564
  }
565
565
  }
566
566
 
567
- // Balances mirror `run402 status`: the on-chain figure above plus the
568
- // Run402-held prepaid credit (rail-independent). Prepaid credit is fetched
569
- // best-effort so a billing read failure never blocks setup.
570
- const billing = await getSdk().billing.checkBalance(allowance.address).catch(() => null);
567
+ // Balances mirror `run402 status`: the on-chain wallet figure above plus the
568
+ // organization's Run402-held allowance (rail-independent). The allowance is
569
+ // fetched best-effort so a billing read failure never blocks setup.
570
+ const billing = await getSdk().billing.checkBalance(localWallet.address).catch(() => null);
571
571
  const hasBilling = billing && billing.exists !== false;
572
572
  summary.balances = {
573
573
  on_chain_usd_micros: balance,
574
574
  on_chain_token: isMpp ? "pathUSD" : "USDC",
575
- prepaid_credit_usd_micros: hasBilling ? billing.available_usd_micros : null,
575
+ allowance_usd_micros: hasBilling ? billing.allowance_usd_micros : null,
576
576
  held_usd_micros: hasBilling ? (billing.held_usd_micros ?? 0) : null,
577
577
  };
578
578
 
@@ -582,7 +582,7 @@ export async function run(args = []) {
582
582
  line("Note", `Switched from ${previousRail} — ${prev} balance still available if you switch back`);
583
583
  }
584
584
 
585
- // 3b. The Lightning allowance (mpp-lightning-over-nwc): a budgeted wallet
585
+ // 3b. The Lightning wallet (mpp-lightning-over-nwc): a budgeted wallet
586
586
  // on Run402's Hub, minted by the platform, its pairing kept beside the
587
587
  // Base key. Never printed. A Hub that is not configured leaves the rail
588
588
  // on Lightning with x402 as the live fallback, and says so.
@@ -591,14 +591,14 @@ export async function run(args = []) {
591
591
  try {
592
592
  const { ensureLightningWallet, describeLightning, readLightningBalance } = await import("./lightning-wallet.mjs");
593
593
  const result = await ensureLightningWallet();
594
- allowance = result.allowance;
594
+ localWallet = result.localWallet;
595
595
  const settled = result.outcome === "stored" || result.outcome === "present";
596
- const balance = settled ? await readLightningBalance(allowance) : null;
597
- summary.lightning = { ...(describeLightning(allowance, result.wallet, balance) ?? {}), outcome: result.outcome };
596
+ const balance = settled ? await readLightningBalance(localWallet) : null;
597
+ summary.lightning = { ...(describeLightning(localWallet, result.wallet, balance) ?? {}), outcome: result.outcome };
598
598
  if (result.outcome === "stored") {
599
599
  line("Lightning", `wallet minted on Run402's Hub (${result.wallet.budget_sats} sats budget, ${result.wallet.starter_sats} starter)`);
600
600
  } else if (result.outcome === "present") {
601
- line("Lightning", `wallet ${allowance.lightning.wallet_id}${balance ? ` — ${balance.balance_sats} sats` : ""}`);
601
+ line("Lightning", `wallet ${localWallet.lightning.wallet_id}${balance ? ` — ${balance.balance_sats} sats` : ""}`);
602
602
  } else if (result.outcome === "minting") {
603
603
  line("Lightning", "the platform is still minting the wallet — rerun `run402 init lightning` in a few seconds");
604
604
  } else if (result.outcome === "unavailable") {
@@ -736,7 +736,7 @@ export async function run(args = []) {
736
736
  if (rows.length === 1) {
737
737
  line("Org", `${rows[0].org_id}${rows[0].display_name ? ` (${rows[0].display_name})` : ""}`);
738
738
  } else if (rows.length > 1) {
739
- line("Org", `${rows.length} organizations — run402 org list`);
739
+ line("Org", `${rows.length} organizations — run402 orgs list`);
740
740
  }
741
741
  } catch {
742
742
  // Best-effort, exactly like the billing read: a listing failure must never
@@ -751,7 +751,7 @@ export async function run(args = []) {
751
751
  summary.funding = fundingRecovery(fundingError, fundingPending);
752
752
  const fundingBlocked = fundingBlocksBootstrap(summary.funding, {
753
753
  activeTier: !tierMissing, onChainBalance: balance,
754
- prepaidBalance: summary.balances.prepaid_credit_usd_micros,
754
+ allowanceBalance: summary.balances.allowance_usd_micros,
755
755
  lightningBalance: summary.lightning?.balance_sats,
756
756
  });
757
757
  summary.next_actions = [tierMissing ? upDeployAction() : deployAction()];
@@ -759,7 +759,7 @@ export async function run(args = []) {
759
759
  const quotedWallet = `'${walletName.replaceAll("'", "'\\''")}'`;
760
760
  summary.next_actions = summary.funding.next_actions.map(action => ({ ...action,
761
761
  ...(["retry", "check_balance"].includes(action.type) ? {
762
- command: `run402 --wallet ${quotedWallet} allowance ${action.type === "retry" ? "fund" : "balance"}`,
762
+ command: `run402 --wallet ${quotedWallet} wallets ${action.type === "retry" ? "fund" : "balance"}`,
763
763
  } : {}),
764
764
  }));
765
765
  }
@@ -769,19 +769,19 @@ export async function run(args = []) {
769
769
  write(` ${summary.next_actions[0].why}`);
770
770
  if (summary.next_step) write(` Next: ${summary.next_step}`);
771
771
  } else if (tierMissing) {
772
- // `up -y` subscribes the prototype tier itself as part of the first
772
+ // `up -y` sets the prototype tier itself as part of the first
773
773
  // deploy; `init` never buys the tier, so the one command that finishes
774
774
  // the cold start is `up`, with `tier set` named as the standalone option.
775
- const creditCovers = summary.voucher?.next_actions?.find((a) => a?.type === "set_tier" && typeof a.cli === "string");
775
+ const allowanceCovers = summary.voucher?.next_actions?.find((a) => a?.type === "set_tier" && typeof a.cli === "string");
776
776
  write(" Next: run402 up -y");
777
- write(" Deploy with run402 up -y — it subscribes the prototype tier (free on testnet) as part of the first deploy.");
778
- if (creditCovers) {
779
- write(` Your credit covers ${creditCovers.highest_affordable_tier ?? "a larger tier"}: ${creditCovers.cli} — then run402 up -y.`);
777
+ write(" Deploy with run402 up -y — it sets the prototype tier (free on testnet) as part of the first deploy.");
778
+ if (allowanceCovers) {
779
+ write(` Your allowance covers ${allowanceCovers.highest_affordable_tier ?? "a larger tier"}: ${allowanceCovers.cli} — then run402 up -y.`);
780
780
  } else {
781
- write(" Or subscribe separately: run402 tier set prototype.");
781
+ write(" Or set it separately: run402 tier set prototype.");
782
782
  }
783
783
  } else {
784
- write(" Ready to deploy. Run: run402 deploy apply --manifest app.json");
784
+ write(" Ready to deploy. Run: run402 deploy --manifest app.json");
785
785
  }
786
786
  write("");
787
787
 
package/lib/jobs.mjs CHANGED
@@ -48,13 +48,13 @@ const SUB_HELP = {
48
48
  submit: `run402 jobs submit — Submit a managed job request
49
49
 
50
50
  Usage:
51
- run402 jobs submit --file <path> [--project <id>]
52
- run402 jobs submit --stdin [--project <id>]
51
+ run402 jobs submit --file <path> [--project <project_id>]
52
+ run402 jobs submit --stdin [--project <project_id>]
53
53
 
54
54
  Options:
55
55
  --file <path> Read the JSON submit request from a file
56
56
  --stdin Read the JSON submit request from stdin
57
- --project <id> Project ID (defaults to the active project)
57
+ --project <project_id> Project ID (defaults to the active project)
58
58
 
59
59
  Example request:
60
60
  {
@@ -72,36 +72,36 @@ Example request:
72
72
  get: `run402 jobs get — Get a managed job run
73
73
 
74
74
  Usage:
75
- run402 jobs get <job_id> [--project <id>]
75
+ run402 jobs get <job_id> [--project <project_id>]
76
76
 
77
77
  Options:
78
- --project <id> Project ID (defaults to the active project)
78
+ --project <project_id> Project ID (defaults to the active project)
79
79
  `,
80
80
  logs: `run402 jobs logs — Read managed job logs
81
81
 
82
82
  Usage:
83
- run402 jobs logs <job_id> [--project <id>] [--tail <n>] [--since <iso>]
83
+ run402 jobs logs <job_id> [--project <project_id>] [--tail <n>] [--since <iso>]
84
84
 
85
85
  Options:
86
- --project <id> Project ID (defaults to the active project)
86
+ --project <project_id> Project ID (defaults to the active project)
87
87
  --tail <n> Maximum entries to return (gateway max: 1000)
88
88
  --since <iso> Only include logs at or after this ISO-8601 timestamp
89
89
  `,
90
90
  cancel: `run402 jobs cancel — Cancel a managed job run
91
91
 
92
92
  Usage:
93
- run402 jobs cancel <job_id> [--project <id>]
93
+ run402 jobs cancel <job_id> [--project <project_id>]
94
94
 
95
95
  Options:
96
- --project <id> Project ID (defaults to the active project)
96
+ --project <project_id> Project ID (defaults to the active project)
97
97
  `,
98
98
  purge: `run402 jobs purge — Purge all managed job runs for a project
99
99
 
100
100
  Usage:
101
- run402 jobs purge [--project <id>]
101
+ run402 jobs purge [--project <project_id>]
102
102
 
103
103
  Options:
104
- --project <id> Project ID (defaults to the active project)
104
+ --project <project_id> Project ID (defaults to the active project)
105
105
 
106
106
  Deletes all project-scoped managed-job run records. Queued/running jobs are
107
107
  included in the purge; known active runner instances are terminated first.
@@ -110,7 +110,7 @@ Prints { deleted_jobs, cancelled_active_jobs, terminated_instances }.
110
110
  artifacts: `run402 jobs artifacts — Download outputs from a completed managed job
111
111
 
112
112
  Usage:
113
- run402 jobs artifacts get <job_id> <file> --output <path> [--project <id>]
113
+ run402 jobs artifacts get <job_id> <file> --output <path> [--project <project_id>]
114
114
 
115
115
  Actions:
116
116
  get <job_id> <file> Download the named artifact to a local file
@@ -121,14 +121,14 @@ recorded filenames on a given run.
121
121
  "artifacts get": `run402 jobs artifacts get — Download a completed job's artifact
122
122
 
123
123
  Usage:
124
- run402 jobs artifacts get <job_id> --file <name> --output <path> [--project <id>]
124
+ run402 jobs artifacts get <job_id> --file <name> --output <path> [--project <project_id>]
125
125
 
126
126
  Legacy (still supported):
127
- run402 jobs artifacts get <job_id> <file> --output <path> [--project <id>]
127
+ run402 jobs artifacts get <job_id> <file> --output <path> [--project <project_id>]
128
128
 
129
129
  Options:
130
130
  --output, -o <path> Local destination path (required)
131
- --project <id> Project ID (defaults to the active project)
131
+ --project <project_id> Project ID (defaults to the active project)
132
132
 
133
133
  The job must be completed and the filename must be in its recorded artifact
134
134
  set (see the 'artifacts' map from 'run402 jobs get <job_id>'); otherwise the
@@ -1,18 +1,18 @@
1
1
  /**
2
- * The Lightning allowance on the CLI: mint the agent's budgeted wallet on
3
- * Run402's Hub, keep its pairing in the active profile's allowance.json
2
+ * The Lightning wallet on the CLI: mint the agent's budgeted wallet on
3
+ * Run402's Hub, keep its pairing in the active profile's wallet.json
4
4
  * beside the Base key, report its balance, revoke it. Shared by
5
5
  * `run402 init lightning`, `run402 wallets lightning …`, and
6
- * `run402 allowance status`. The pairing secret is never printed.
6
+ * `run402 wallets current`. The pairing secret is never printed.
7
7
  */
8
- import { readAllowance, saveAllowance } from "../core-dist/allowance.js";
8
+ import { readWallet, saveWallet } from "../core-dist/wallet.js";
9
9
  import { getSdk } from "./sdk.mjs";
10
10
 
11
11
  export const LIGHTNING_MINT_TIMEOUT_MS = 45_000;
12
12
 
13
13
  /** Public facts only: never the pairing. */
14
- export function describeLightning(allowance, wallet = null, balance = null) {
15
- const local = allowance?.lightning ?? null;
14
+ export function describeLightning(localWallet, wallet = null, balance = null) {
15
+ const local = localWallet?.lightning ?? null;
16
16
  if (!local && !wallet) return null;
17
17
  return {
18
18
  wallet_id: wallet?.wallet_id ?? local?.wallet_id ?? null,
@@ -29,8 +29,8 @@ export function describeLightning(allowance, wallet = null, balance = null) {
29
29
  }
30
30
 
31
31
  /** Balance and remaining budget over NWC, best-effort (null on any failure). */
32
- export async function readLightningBalance(allowance) {
33
- const nwc = allowance?.lightning?.nwc;
32
+ export async function readLightningBalance(localWallet) {
33
+ const nwc = localWallet?.lightning?.nwc;
34
34
  if (!nwc) return null;
35
35
  try {
36
36
  const { NwcWallet, closeNwcConnections } = await import("#sdk/node");
@@ -46,9 +46,9 @@ export async function readLightningBalance(allowance) {
46
46
  }
47
47
  }
48
48
 
49
- function storePairing(allowance, wallet) {
49
+ function storePairing(localWallet, wallet) {
50
50
  const next = {
51
- ...allowance,
51
+ ...localWallet,
52
52
  rail: "lightning",
53
53
  lightning: {
54
54
  wallet_id: wallet.wallet_id,
@@ -60,46 +60,46 @@ function storePairing(allowance, wallet) {
60
60
  minted_at: wallet.activated_at ?? new Date().toISOString(),
61
61
  },
62
62
  };
63
- saveAllowance(next);
63
+ saveWallet(next);
64
64
  return next;
65
65
  }
66
66
 
67
67
  /**
68
68
  * Ensure the active profile holds an active Lightning wallet. Returns
69
- * `{ allowance, wallet, outcome }` where outcome is `stored` (pairing just
69
+ * `{ localWallet, wallet, outcome }` where outcome is `stored` (pairing just
70
70
  * saved), `present` (already held locally), `minting` (the platform is still
71
71
  * minting; rerun later), `unavailable` (no Hub on this gateway), or
72
72
  * `pairing_lost` (the wallet is active but its one-time pairing was handed to
73
73
  * another machine; revoke and mint again).
74
74
  */
75
75
  export async function ensureLightningWallet(options = {}) {
76
- let allowance = readAllowance();
77
- if (!allowance) throw new Error("no allowance configured; run `run402 init` first");
78
- if (allowance.lightning?.nwc) {
76
+ let localWallet = readWallet();
77
+ if (!localWallet) throw new Error("no local wallet configured; run `run402 init` first");
78
+ if (localWallet.lightning?.nwc) {
79
79
  let wallet = null;
80
80
  try { wallet = await getSdk().agent.lightningWallet.get(); } catch { /* offline read is fine */ }
81
- if (wallet && wallet.status !== "active") return { allowance, wallet, outcome: wallet.status };
82
- return { allowance, wallet, outcome: "present" };
81
+ if (wallet && wallet.status !== "active") return { localWallet, wallet, outcome: wallet.status };
82
+ return { localWallet, wallet, outcome: "present" };
83
83
  }
84
84
  let wallet;
85
85
  try {
86
86
  wallet = await getSdk().agent.lightningWallet.mint({ timeoutMs: options.timeoutMs ?? LIGHTNING_MINT_TIMEOUT_MS });
87
87
  } catch (err) {
88
88
  const code = err?.body?.code ?? err?.code;
89
- if (code === "LIGHTNING_WALLET_NOT_AVAILABLE") return { allowance, wallet: null, outcome: "unavailable", error: err };
90
- if (code === "LIGHTNING_WALLET_STILL_MINTING") return { allowance, wallet: null, outcome: "minting", error: err };
89
+ if (code === "LIGHTNING_WALLET_NOT_AVAILABLE") return { localWallet, wallet: null, outcome: "unavailable", error: err };
90
+ if (code === "LIGHTNING_WALLET_STILL_MINTING") return { localWallet, wallet: null, outcome: "minting", error: err };
91
91
  throw err;
92
92
  }
93
- if (wallet.status === "minting") return { allowance, wallet, outcome: "minting" };
94
- if (wallet.status !== "active") return { allowance, wallet, outcome: wallet.status };
95
- if (typeof wallet.pairing !== "string") return { allowance, wallet, outcome: "pairing_lost" };
96
- allowance = storePairing(allowance, wallet);
97
- return { allowance, wallet, outcome: "stored" };
93
+ if (wallet.status === "minting") return { localWallet, wallet, outcome: "minting" };
94
+ if (wallet.status !== "active") return { localWallet, wallet, outcome: wallet.status };
95
+ if (typeof wallet.pairing !== "string") return { localWallet, wallet, outcome: "pairing_lost" };
96
+ localWallet = storePairing(localWallet, wallet);
97
+ return { localWallet, wallet, outcome: "stored" };
98
98
  }
99
99
 
100
100
  /** Revoke on the platform and forget the pairing locally; the rail returns to x402. */
101
101
  export async function revokeLightningWallet() {
102
- const allowance = readAllowance();
102
+ const localWallet = readWallet();
103
103
  let wallet = null;
104
104
  try {
105
105
  wallet = await getSdk().agent.lightningWallet.revoke();
@@ -107,9 +107,9 @@ export async function revokeLightningWallet() {
107
107
  const code = err?.body?.code ?? err?.code;
108
108
  if (code !== "LIGHTNING_WALLET_NOT_FOUND") throw err;
109
109
  }
110
- if (allowance) {
111
- const { lightning: _dropped, ...rest } = allowance;
112
- saveAllowance({ ...rest, rail: rest.rail === "lightning" ? "x402" : rest.rail });
110
+ if (localWallet) {
111
+ const { lightning: _dropped, ...rest } = localWallet;
112
+ saveWallet({ ...rest, rail: rest.rail === "lightning" ? "x402" : rest.rail });
113
113
  }
114
114
  return wallet;
115
115
  }
package/lib/live.mjs CHANGED
@@ -23,7 +23,7 @@ Usage:
23
23
  Options:
24
24
  --tables <names> Comma-separated live table names (tables with "live": true in the
25
25
  expose manifest). Required.
26
- --project <id> Project to read (defaults to the active project)
26
+ --project <project_id> Project to read (defaults to the active project)
27
27
  --cursor <c> Resume from a cursor (a previous "cursor" or a change's cursor)
28
28
  --as <audience> anon (project anon key; public-policy tables) or service (service
29
29
  key; every hint, including owner-scoped ones). Default anon.