@cogcoin/client 1.1.8 → 1.1.9

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 (266) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/commands/mining-read.js +1 -1
  3. package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
  4. package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
  5. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
  6. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
  7. package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
  8. package/dist/cli/commands/wallet-mutation/cog.js +131 -0
  9. package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
  10. package/dist/cli/commands/wallet-mutation/context.js +18 -0
  11. package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
  12. package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
  13. package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
  14. package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
  15. package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
  16. package/dist/cli/commands/wallet-mutation/field.js +125 -0
  17. package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
  18. package/dist/cli/commands/wallet-mutation/register.js +38 -0
  19. package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
  20. package/dist/cli/commands/wallet-mutation/registry.js +39 -0
  21. package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
  22. package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
  23. package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
  24. package/dist/cli/commands/wallet-mutation/types.js +1 -0
  25. package/dist/cli/commands/wallet-mutation.js +13 -765
  26. package/dist/cli/commands/wallet-read.js +4 -4
  27. package/dist/cli/mutation-success.d.ts +0 -2
  28. package/dist/cli/output/classify.d.ts +7 -0
  29. package/dist/cli/output/classify.js +94 -0
  30. package/dist/cli/output/render.d.ts +2 -0
  31. package/dist/cli/output/render.js +13 -0
  32. package/dist/cli/output/rules/cli-surface.d.ts +2 -0
  33. package/dist/cli/output/rules/cli-surface.js +110 -0
  34. package/dist/cli/output/rules/generic.d.ts +2 -0
  35. package/dist/cli/output/rules/generic.js +13 -0
  36. package/dist/cli/output/rules/index.d.ts +2 -0
  37. package/dist/cli/output/rules/index.js +24 -0
  38. package/dist/cli/output/rules/mining-update.d.ts +2 -0
  39. package/dist/cli/output/rules/mining-update.js +68 -0
  40. package/dist/cli/output/rules/services.d.ts +2 -0
  41. package/dist/cli/output/rules/services.js +110 -0
  42. package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
  43. package/dist/cli/output/rules/wallet-admin.js +224 -0
  44. package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
  45. package/dist/cli/output/rules/wallet-mutations.js +274 -0
  46. package/dist/cli/output/types.d.ts +16 -0
  47. package/dist/cli/output/types.js +1 -0
  48. package/dist/cli/output.d.ts +2 -168
  49. package/dist/cli/output.js +6 -989
  50. package/dist/cli/pagination.d.ts +15 -0
  51. package/dist/cli/pagination.js +16 -0
  52. package/dist/cli/recommendations.d.ts +4 -0
  53. package/dist/cli/recommendations.js +108 -0
  54. package/dist/cli/wallet-format/availability.d.ts +5 -0
  55. package/dist/cli/wallet-format/availability.js +96 -0
  56. package/dist/cli/wallet-format/balance.d.ts +2 -0
  57. package/dist/cli/wallet-format/balance.js +162 -0
  58. package/dist/cli/wallet-format/domains.d.ts +8 -0
  59. package/dist/cli/wallet-format/domains.js +84 -0
  60. package/dist/cli/wallet-format/fields.d.ts +6 -0
  61. package/dist/cli/wallet-format/fields.js +61 -0
  62. package/dist/cli/wallet-format/identity.d.ts +5 -0
  63. package/dist/cli/wallet-format/identity.js +19 -0
  64. package/dist/cli/wallet-format/locks.d.ts +7 -0
  65. package/dist/cli/wallet-format/locks.js +52 -0
  66. package/dist/cli/wallet-format/overview.d.ts +2 -0
  67. package/dist/cli/wallet-format/overview.js +122 -0
  68. package/dist/cli/wallet-format/pending.d.ts +13 -0
  69. package/dist/cli/wallet-format/pending.js +101 -0
  70. package/dist/cli/wallet-format/shared.d.ts +7 -0
  71. package/dist/cli/wallet-format/shared.js +31 -0
  72. package/dist/cli/wallet-format/status.d.ts +3 -0
  73. package/dist/cli/wallet-format/status.js +27 -0
  74. package/dist/cli/wallet-format.d.ts +8 -30
  75. package/dist/cli/wallet-format.js +8 -830
  76. package/dist/cli/wallet-read-helpers.d.ts +6 -0
  77. package/dist/cli/wallet-read-helpers.js +17 -0
  78. package/dist/wallet/mining/candidate.d.ts +1 -1
  79. package/dist/wallet/mining/candidate.js +3 -3
  80. package/dist/wallet/mining/constants.d.ts +2 -2
  81. package/dist/wallet/mining/constants.js +2 -2
  82. package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
  83. package/dist/wallet/mining/sentences.js +8 -8
  84. package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
  85. package/dist/wallet/tx/anchor/confirm.js +60 -0
  86. package/dist/wallet/tx/anchor/draft.d.ts +39 -0
  87. package/dist/wallet/tx/anchor/draft.js +167 -0
  88. package/dist/wallet/tx/anchor/index.d.ts +5 -0
  89. package/dist/wallet/tx/anchor/index.js +148 -0
  90. package/dist/wallet/tx/anchor/intent.d.ts +61 -0
  91. package/dist/wallet/tx/anchor/intent.js +101 -0
  92. package/dist/wallet/tx/anchor/plan.d.ts +3 -0
  93. package/dist/wallet/tx/anchor/plan.js +18 -0
  94. package/dist/wallet/tx/anchor/result.d.ts +25 -0
  95. package/dist/wallet/tx/anchor/result.js +20 -0
  96. package/dist/wallet/tx/anchor.d.ts +1 -39
  97. package/dist/wallet/tx/anchor.js +1 -494
  98. package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
  99. package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
  100. package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
  101. package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
  102. package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
  103. package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
  104. package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
  105. package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
  106. package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
  107. package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
  108. package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
  109. package/dist/wallet/tx/bitcoin-transfer.js +1 -200
  110. package/dist/wallet/tx/cog/confirm.d.ts +13 -0
  111. package/dist/wallet/tx/cog/confirm.js +59 -0
  112. package/dist/wallet/tx/cog/draft.d.ts +20 -0
  113. package/dist/wallet/tx/cog/draft.js +114 -0
  114. package/dist/wallet/tx/cog/index.d.ts +6 -0
  115. package/dist/wallet/tx/cog/index.js +117 -0
  116. package/dist/wallet/tx/cog/intent.d.ts +30 -0
  117. package/dist/wallet/tx/cog/intent.js +169 -0
  118. package/dist/wallet/tx/cog/plan.d.ts +19 -0
  119. package/dist/wallet/tx/cog/plan.js +65 -0
  120. package/dist/wallet/tx/cog/result.d.ts +27 -0
  121. package/dist/wallet/tx/cog/result.js +28 -0
  122. package/dist/wallet/tx/cog/types.d.ts +186 -0
  123. package/dist/wallet/tx/cog/types.js +2 -0
  124. package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
  125. package/dist/wallet/tx/cog/variants/claim.js +92 -0
  126. package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
  127. package/dist/wallet/tx/cog/variants/lock.js +102 -0
  128. package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
  129. package/dist/wallet/tx/cog/variants/send.js +77 -0
  130. package/dist/wallet/tx/cog.d.ts +1 -96
  131. package/dist/wallet/tx/cog.js +1 -824
  132. package/dist/wallet/tx/common.d.ts +14 -199
  133. package/dist/wallet/tx/common.js +10 -493
  134. package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
  135. package/dist/wallet/tx/domain-admin/confirm.js +58 -0
  136. package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
  137. package/dist/wallet/tx/domain-admin/draft.js +161 -0
  138. package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
  139. package/dist/wallet/tx/domain-admin/index.js +150 -0
  140. package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
  141. package/dist/wallet/tx/domain-admin/intent.js +61 -0
  142. package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
  143. package/dist/wallet/tx/domain-admin/plan.js +64 -0
  144. package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
  145. package/dist/wallet/tx/domain-admin/result.js +33 -0
  146. package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
  147. package/dist/wallet/tx/domain-admin/types.js +1 -0
  148. package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
  149. package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
  150. package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
  151. package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
  152. package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
  153. package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
  154. package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
  155. package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
  156. package/dist/wallet/tx/domain-admin.d.ts +1 -107
  157. package/dist/wallet/tx/domain-admin.js +1 -729
  158. package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
  159. package/dist/wallet/tx/domain-market/confirm.js +52 -0
  160. package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
  161. package/dist/wallet/tx/domain-market/draft.js +286 -0
  162. package/dist/wallet/tx/domain-market/index.d.ts +6 -0
  163. package/dist/wallet/tx/domain-market/index.js +145 -0
  164. package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
  165. package/dist/wallet/tx/domain-market/intent.js +131 -0
  166. package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
  167. package/dist/wallet/tx/domain-market/plan.js +98 -0
  168. package/dist/wallet/tx/domain-market/result.d.ts +45 -0
  169. package/dist/wallet/tx/domain-market/result.js +88 -0
  170. package/dist/wallet/tx/domain-market/types.d.ts +221 -0
  171. package/dist/wallet/tx/domain-market/types.js +1 -0
  172. package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
  173. package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
  174. package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
  175. package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
  176. package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
  177. package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
  178. package/dist/wallet/tx/domain-market.d.ts +1 -116
  179. package/dist/wallet/tx/domain-market.js +1 -1078
  180. package/dist/wallet/tx/draft-build.d.ts +60 -0
  181. package/dist/wallet/tx/draft-build.js +127 -0
  182. package/dist/wallet/tx/executor.d.ts +6 -40
  183. package/dist/wallet/tx/executor.js +6 -100
  184. package/dist/wallet/tx/fee.d.ts +30 -0
  185. package/dist/wallet/tx/fee.js +98 -0
  186. package/dist/wallet/tx/field/confirm.d.ts +11 -0
  187. package/dist/wallet/tx/field/confirm.js +19 -0
  188. package/dist/wallet/tx/field/draft.d.ts +23 -0
  189. package/dist/wallet/tx/field/draft.js +202 -0
  190. package/dist/wallet/tx/field/index.d.ts +5 -0
  191. package/dist/wallet/tx/field/index.js +140 -0
  192. package/dist/wallet/tx/field/intent.d.ts +5 -0
  193. package/dist/wallet/tx/field/intent.js +50 -0
  194. package/dist/wallet/tx/field/plan.d.ts +20 -0
  195. package/dist/wallet/tx/field/plan.js +65 -0
  196. package/dist/wallet/tx/field/result.d.ts +29 -0
  197. package/dist/wallet/tx/field/result.js +103 -0
  198. package/dist/wallet/tx/field/types.d.ts +163 -0
  199. package/dist/wallet/tx/field/types.js +1 -0
  200. package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
  201. package/dist/wallet/tx/field/variants/clear.js +60 -0
  202. package/dist/wallet/tx/field/variants/create.d.ts +2 -0
  203. package/dist/wallet/tx/field/variants/create.js +67 -0
  204. package/dist/wallet/tx/field/variants/set.d.ts +2 -0
  205. package/dist/wallet/tx/field/variants/set.js +195 -0
  206. package/dist/wallet/tx/field.d.ts +1 -95
  207. package/dist/wallet/tx/field.js +1 -920
  208. package/dist/wallet/tx/mining-preemption.d.ts +6 -0
  209. package/dist/wallet/tx/mining-preemption.js +7 -0
  210. package/dist/wallet/tx/primitives.d.ts +13 -0
  211. package/dist/wallet/tx/primitives.js +42 -0
  212. package/dist/wallet/tx/psbt-assert.d.ts +14 -0
  213. package/dist/wallet/tx/psbt-assert.js +39 -0
  214. package/dist/wallet/tx/publish.d.ts +37 -0
  215. package/dist/wallet/tx/publish.js +88 -0
  216. package/dist/wallet/tx/readiness.d.ts +7 -0
  217. package/dist/wallet/tx/readiness.js +61 -0
  218. package/dist/wallet/tx/reconcile.d.ts +24 -0
  219. package/dist/wallet/tx/reconcile.js +72 -0
  220. package/dist/wallet/tx/register/confirm.d.ts +6 -0
  221. package/dist/wallet/tx/register/confirm.js +66 -0
  222. package/dist/wallet/tx/register/draft.d.ts +42 -0
  223. package/dist/wallet/tx/register/draft.js +181 -0
  224. package/dist/wallet/tx/register/index.d.ts +6 -0
  225. package/dist/wallet/tx/register/index.js +158 -0
  226. package/dist/wallet/tx/register/intent.d.ts +74 -0
  227. package/dist/wallet/tx/register/intent.js +119 -0
  228. package/dist/wallet/tx/register/plan.d.ts +43 -0
  229. package/dist/wallet/tx/register/plan.js +168 -0
  230. package/dist/wallet/tx/register/result.d.ts +78 -0
  231. package/dist/wallet/tx/register/result.js +41 -0
  232. package/dist/wallet/tx/register.d.ts +1 -70
  233. package/dist/wallet/tx/register.js +1 -681
  234. package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
  235. package/dist/wallet/tx/reputation/confirm.js +51 -0
  236. package/dist/wallet/tx/reputation/draft.d.ts +20 -0
  237. package/dist/wallet/tx/reputation/draft.js +130 -0
  238. package/dist/wallet/tx/reputation/index.d.ts +4 -0
  239. package/dist/wallet/tx/reputation/index.js +162 -0
  240. package/dist/wallet/tx/reputation/intent.d.ts +36 -0
  241. package/dist/wallet/tx/reputation/intent.js +157 -0
  242. package/dist/wallet/tx/reputation/plan.d.ts +19 -0
  243. package/dist/wallet/tx/reputation/plan.js +64 -0
  244. package/dist/wallet/tx/reputation/result.d.ts +21 -0
  245. package/dist/wallet/tx/reputation/result.js +31 -0
  246. package/dist/wallet/tx/reputation/types.d.ts +130 -0
  247. package/dist/wallet/tx/reputation/types.js +1 -0
  248. package/dist/wallet/tx/reputation.d.ts +1 -74
  249. package/dist/wallet/tx/reputation.js +1 -556
  250. package/dist/wallet/tx/signing.d.ts +18 -0
  251. package/dist/wallet/tx/signing.js +31 -0
  252. package/dist/wallet/tx/state-persist.d.ts +27 -0
  253. package/dist/wallet/tx/state-persist.js +54 -0
  254. package/dist/wallet/tx/types.d.ts +44 -0
  255. package/dist/wallet/tx/types.js +1 -0
  256. package/package.json +1 -1
  257. package/dist/cli/mining-json.d.ts +0 -20
  258. package/dist/cli/mining-json.js +0 -46
  259. package/dist/cli/mutation-json.d.ts +0 -325
  260. package/dist/cli/mutation-json.js +0 -269
  261. package/dist/cli/mutation-resolved-json.d.ts +0 -117
  262. package/dist/cli/mutation-resolved-json.js +0 -123
  263. package/dist/cli/preview-json.d.ts +0 -319
  264. package/dist/cli/preview-json.js +0 -254
  265. package/dist/cli/read-json.d.ts +0 -190
  266. package/dist/cli/read-json.js +0 -627
@@ -3,8 +3,8 @@ import { formatBalanceReport, formatDetailedWalletStatusReport, formatDomainRepo
3
3
  import { writeLine } from "../io.js";
4
4
  import { findWalletDomain, listDomainFields } from "../../wallet/read/index.js";
5
5
  import { filterWalletDomains } from "../../wallet/read/index.js";
6
- import { normalizeListPage } from "../output.js";
7
- import { listFieldsForJson, listLocksForJson } from "../read-json.js";
6
+ import { normalizeListPage } from "../pagination.js";
7
+ import { listVisibleDomainFields, listVisibleWalletLocks } from "../wallet-read-helpers.js";
8
8
  import { formatNextStepLines, getAddressNextSteps, getFundingQuickstartGuidance, getIdsNextSteps, getLocksNextSteps, } from "../workflow-hints.js";
9
9
  import { withInteractiveWalletSecretProvider } from "../../wallet/state/provider.js";
10
10
  function activeDomainFilters(parsed) {
@@ -73,7 +73,7 @@ export async function runWalletReadCommand(parsed, context) {
73
73
  limit: parsed.listAll ? null : (parsed.listLimit ?? defaultLimit),
74
74
  all: parsed.listAll,
75
75
  }));
76
- const locks = listLocksForJson(readContext, {
76
+ const locks = listVisibleWalletLocks(readContext, {
77
77
  claimableOnly: parsed.locksClaimableOnly,
78
78
  reclaimableOnly: parsed.locksReclaimableOnly,
79
79
  });
@@ -118,7 +118,7 @@ export async function runWalletReadCommand(parsed, context) {
118
118
  case "fields": {
119
119
  const defaultLimit = 100;
120
120
  const domainName = parsed.args[0];
121
- const fields = listFieldsForJson(readContext, domainName);
121
+ const fields = listVisibleDomainFields(readContext, domainName);
122
122
  if (readContext.snapshot !== null && fields === null) {
123
123
  writeLine(context.stdout, formatFieldsReport(readContext, domainName, {
124
124
  limit: parsed.listAll ? null : (parsed.listLimit ?? defaultLimit),
@@ -7,8 +7,6 @@ export interface MutationSuccessNextSteps {
7
7
  export declare function commandMutationNextSteps(command: string): MutationSuccessNextSteps;
8
8
  export declare function workflowMutationNextSteps(nextSteps: readonly string[]): MutationSuccessNextSteps;
9
9
  export declare function writeMutationCommandSuccess(parsed: ParsedCliArgs, context: RequiredCliRunnerContext, options: {
10
- data: unknown;
11
- previewData?: unknown;
12
10
  reusedExisting: boolean;
13
11
  reusedMessage: string;
14
12
  fees?: WalletMutationFeeSummary | null;
@@ -0,0 +1,7 @@
1
+ import type { CliErrorClassification } from "./types.js";
2
+ export declare function classifyCliError(error: unknown): CliErrorClassification;
3
+ export declare function isBlockedError(message: string): boolean;
4
+ export declare function describeBusyLock(errorCode: string, error?: unknown): {
5
+ lockPath: string;
6
+ lockPurpose: string | null;
7
+ } | null;
@@ -0,0 +1,94 @@
1
+ import { FileLockBusyError } from "../../wallet/fs/lock.js";
2
+ export function classifyCliError(error) {
3
+ const message = error instanceof Error ? error.message : String(error);
4
+ if (message.startsWith("cli_")) {
5
+ return { exitCode: 2, errorCode: message, message };
6
+ }
7
+ if (/^wallet_init_confirmation_failed_word_\d+$/.test(message)) {
8
+ return { exitCode: 2, errorCode: message, message };
9
+ }
10
+ if (message === "mining_setup_invalid_provider"
11
+ || message === "mining_setup_missing_api_key"
12
+ || message === "mining_setup_missing_model_id"
13
+ || message === "mining_setup_canceled") {
14
+ return { exitCode: 2, errorCode: message, message };
15
+ }
16
+ if (message.endsWith("_typed_ack_required")) {
17
+ return { exitCode: 2, errorCode: message, message };
18
+ }
19
+ if (message === "wallet_typed_confirmation_rejected"
20
+ || message === "wallet_delete_confirmation_required"
21
+ || message === "wallet_prompt_value_required"
22
+ || message === "wallet_restore_mnemonic_invalid"
23
+ || message === "wallet_restore_replace_confirmation_required"
24
+ || message === "wallet_seed_name_invalid"
25
+ || message === "wallet_seed_name_reserved"
26
+ || message === "reset_wallet_choice_invalid") {
27
+ return { exitCode: 2, errorCode: message, message };
28
+ }
29
+ if (message === "not_found") {
30
+ return { exitCode: 3, errorCode: "not_found", message: "Requested object not found." };
31
+ }
32
+ if (message === "wallet_seed_not_found") {
33
+ return { exitCode: 3, errorCode: message, message };
34
+ }
35
+ if (message === "wallet_seed_index_invalid") {
36
+ return { exitCode: 4, errorCode: message, message };
37
+ }
38
+ if (message === "reset_process_shutdown_failed"
39
+ || message === "reset_data_root_delete_failed"
40
+ || message === "reset_secret_cleanup_failed"
41
+ || message === "reset_snapshot_preserve_failed") {
42
+ return { exitCode: 5, errorCode: message, message };
43
+ }
44
+ if (isBlockedError(message)) {
45
+ return { exitCode: 4, errorCode: message, message };
46
+ }
47
+ return { exitCode: 5, errorCode: message, message };
48
+ }
49
+ export function isBlockedError(message) {
50
+ if (message === "wallet_control_lock_busy"
51
+ || message.startsWith("file_lock_busy_")) {
52
+ return true;
53
+ }
54
+ if (message === "wallet_uninitialized"
55
+ || message === "local-state-corrupt"
56
+ || message === "wallet_already_initialized"
57
+ || message === "wallet_restore_requires_main_wallet"
58
+ || message === "wallet_seed_name_exists"
59
+ || message === "wallet_seed_not_found"
60
+ || message === "wallet_delete_main_not_supported"
61
+ || message === "wallet_repair_indexer_reset_requires_yes"
62
+ || message === "managed_bitcoind_service_version_mismatch"
63
+ || message === "managed_bitcoind_wallet_root_mismatch"
64
+ || message === "managed_bitcoind_runtime_mismatch"
65
+ || message === "indexer_daemon_service_version_mismatch"
66
+ || message === "indexer_daemon_wallet_root_mismatch"
67
+ || message === "indexer_daemon_schema_mismatch"
68
+ || message === "mine_setup_requires_tty"
69
+ || message === "mine_prompt_requires_tty"
70
+ || message === "mine_prompt_domain_not_mineable"
71
+ || message === "mining_preemption_timeout"
72
+ || message === "wallet_client_password_setup_required"
73
+ || message === "wallet_client_password_migration_required"
74
+ || message === "wallet_client_password_locked"
75
+ || message === "wallet_secret_provider_linux_runtime_error"
76
+ || message === "wallet_secret_provider_macos_runtime_error"
77
+ || message === "wallet_secret_provider_windows_runtime_error"
78
+ || message === "wallet_state_legacy_envelope_unsupported") {
79
+ return true;
80
+ }
81
+ return /(?:^|_)(?:locked|uninitialized|repair_required|requires_tty|typed_ack_required|confirmation_rejected|tip_mismatch|core_replica_not_ready|setup|no_eligible_sender|ambiguous_sender|insufficient|stale|paused|validation|catching_up|starting|unavailable|schema_mismatch|service_version_mismatch|wallet_root_mismatch|runtime_mismatch|replica_missing|replica_mismatch|failed)(?:_|$)/.test(message)
82
+ || /repair-required/.test(message);
83
+ }
84
+ export function describeBusyLock(errorCode, error) {
85
+ if (!errorCode.startsWith("file_lock_busy_")) {
86
+ return null;
87
+ }
88
+ return {
89
+ lockPath: errorCode.slice("file_lock_busy_".length),
90
+ lockPurpose: error instanceof FileLockBusyError
91
+ ? error.existingMetadata?.purpose ?? null
92
+ : null,
93
+ };
94
+ }
@@ -0,0 +1,2 @@
1
+ import type { CliErrorPresentation } from "./types.js";
2
+ export declare function formatCliTextErrorLines(presentation: CliErrorPresentation | null): string[] | null;
@@ -0,0 +1,13 @@
1
+ export function formatCliTextErrorLines(presentation) {
2
+ if (presentation === null) {
3
+ return null;
4
+ }
5
+ const lines = [`What happened: ${presentation.what}`];
6
+ if (presentation.why !== null) {
7
+ lines.push(`Why: ${presentation.why}`);
8
+ }
9
+ if (presentation.next !== null) {
10
+ lines.push(`Next: ${presentation.next}`);
11
+ }
12
+ return lines;
13
+ }
@@ -0,0 +1,2 @@
1
+ import type { CliErrorPresentationRule } from "../types.js";
2
+ export declare const cliSurfaceErrorRules: readonly CliErrorPresentationRule[];
@@ -0,0 +1,110 @@
1
+ export const cliSurfaceErrorRules = [
2
+ ({ errorCode }) => {
3
+ if (errorCode === "cli_client_unlock_removed") {
4
+ return {
5
+ what: "`client unlock` was removed.",
6
+ why: "Cogcoin no longer shares unlocked client-password sessions across separate CLI commands.",
7
+ next: "Rerun password-aware commands in an interactive terminal so Cogcoin can prompt for the client password when needed.",
8
+ };
9
+ }
10
+ if (errorCode === "cli_client_lock_removed") {
11
+ return {
12
+ what: "`client lock` was removed.",
13
+ why: "Cogcoin no longer keeps reusable unlocked client-password sessions after a command exits.",
14
+ next: "Fresh CLI invocations start locked automatically and prompt when wallet-local secrets are needed.",
15
+ };
16
+ }
17
+ if (errorCode === "cli_restore_removed" || errorCode === "cli_wallet_restore_removed") {
18
+ return {
19
+ what: "Standalone restore commands were removed.",
20
+ why: "Cogcoin now uses `cogcoin init` as the single wallet setup entrypoint for both new and restored wallets.",
21
+ next: "Run `cogcoin init` and choose \"Restore existing wallet\".",
22
+ };
23
+ }
24
+ if (errorCode === "cli_wallet_delete_removed") {
25
+ return {
26
+ what: "`wallet delete` was removed.",
27
+ why: "Cogcoin no longer supports multiple local wallet seeds, so replacing the wallet now flows through reset and init.",
28
+ next: "Run `cogcoin reset`, choose \"clear wallet entropy\", then rerun `cogcoin init`.",
29
+ };
30
+ }
31
+ if (errorCode === "cli_seed_removed") {
32
+ return {
33
+ what: "`--seed` was removed.",
34
+ why: "Cogcoin now supports only a single local wallet instead of multiple named wallet seeds.",
35
+ next: "Use the current wallet directly, or run `cogcoin reset`, choose \"clear wallet entropy\", then rerun `cogcoin init` to import a different wallet.",
36
+ };
37
+ }
38
+ if (errorCode === "cli_missing_seed_name") {
39
+ return {
40
+ what: "Named wallet seeds were removed.",
41
+ why: "This version of Cogcoin no longer supports `--seed`.",
42
+ next: "Drop `--seed` and retry, or use reset plus init if you need to replace the wallet.",
43
+ };
44
+ }
45
+ if (errorCode === "cli_seed_not_supported_for_command" || errorCode === "wallet_init_seed_not_supported") {
46
+ return {
47
+ what: "Named wallet seeds were removed.",
48
+ why: "Cogcoin now operates on a single local wallet instead of multiple named wallet seeds.",
49
+ next: "Drop `--seed` and retry.",
50
+ };
51
+ }
52
+ if (errorCode === "cli_from_not_supported_for_command") {
53
+ return {
54
+ what: "`--from` is no longer supported.",
55
+ why: "Cogcoin now uses a single wallet address for local transaction authorship, so sender selection is no longer part of the CLI.",
56
+ next: "Retry the command without `--from`.",
57
+ };
58
+ }
59
+ if (errorCode === "cli_missing_satvb") {
60
+ return {
61
+ what: "A sat/vB value is required.",
62
+ why: "`--satvb` needs an explicit positive fee rate value in sat/vB for the mutation you are submitting.",
63
+ next: "Rerun the command with `--satvb <number>`.",
64
+ };
65
+ }
66
+ if (errorCode === "cli_invalid_satvb") {
67
+ return {
68
+ what: "The sat/vB value is invalid.",
69
+ why: "`--satvb` accepts only a positive finite decimal number such as `12` or `12.5`.",
70
+ next: "Choose a positive sat/vB value and retry.",
71
+ };
72
+ }
73
+ if (errorCode === "cli_satvb_not_supported_for_command") {
74
+ return {
75
+ what: "This command does not support `--satvb`.",
76
+ why: "The fee-rate override only applies to wallet mutation commands that build and broadcast transactions.",
77
+ next: "Drop `--satvb` for this command, or use it with a wallet mutation command like `cogcoin register` or `cogcoin send`.",
78
+ };
79
+ }
80
+ if (errorCode === "cli_anchor_clear_removed") {
81
+ return {
82
+ what: "`anchor clear` is no longer available.",
83
+ why: "Anchor is now a direct single-transaction wallet mutation, so there is no separate cleanup command for reserved local workflow state.",
84
+ next: "Retry with `cogcoin anchor <domain>` or inspect the domain with `cogcoin show <domain>`.",
85
+ };
86
+ }
87
+ if (errorCode === "cli_wallet_export_removed") {
88
+ return {
89
+ what: "`wallet export` is no longer available.",
90
+ why: "Portable encrypted wallet archives were removed from the client, so wallet state is no longer exported through a `.cogcoin` archive file.",
91
+ next: "Use the wallet mnemonic as the supported recovery path, or retry with another wallet command.",
92
+ };
93
+ }
94
+ if (errorCode === "cli_wallet_import_removed") {
95
+ return {
96
+ what: "`wallet import` is no longer available.",
97
+ why: "Portable encrypted wallet archives were removed from the client, so this version no longer imports wallet state from archive files.",
98
+ next: "Use `cogcoin init`, choose \"Restore existing wallet\", and enter the recovery mnemonic instead.",
99
+ };
100
+ }
101
+ if (errorCode === "cli_field_create_initial_value_not_supported") {
102
+ return {
103
+ what: "`field create` no longer accepts an initial value.",
104
+ why: "Field creation is now always a single FIELD_REG transaction. Any field value must be written afterward with a separate `field set` command.",
105
+ next: "Create the field first, then run `cogcoin field set <domain> <field> ...`.",
106
+ };
107
+ }
108
+ return null;
109
+ },
110
+ ];
@@ -0,0 +1,2 @@
1
+ import type { CliErrorPresentationRule } from "../types.js";
2
+ export declare const genericCliErrorRules: readonly CliErrorPresentationRule[];
@@ -0,0 +1,13 @@
1
+ import { isBlockedError } from "../classify.js";
2
+ export const genericCliErrorRules = [
3
+ ({ errorCode, fallbackMessage }) => {
4
+ if (!isBlockedError(errorCode)) {
5
+ return null;
6
+ }
7
+ return {
8
+ what: fallbackMessage,
9
+ why: "The command was blocked by the current local wallet or service state.",
10
+ next: "Review `cogcoin status` and retry after the blocking condition is cleared.",
11
+ };
12
+ },
13
+ ];
@@ -0,0 +1,2 @@
1
+ import type { CliErrorPresentation } from "../types.js";
2
+ export declare function createCliErrorPresentation(errorCode: string, fallbackMessage: string, error?: unknown): CliErrorPresentation | null;
@@ -0,0 +1,24 @@
1
+ import { cliSurfaceErrorRules } from "./cli-surface.js";
2
+ import { genericCliErrorRules } from "./generic.js";
3
+ import { miningAndUpdateErrorRules } from "./mining-update.js";
4
+ import { serviceErrorRules } from "./services.js";
5
+ import { walletAdminErrorRules } from "./wallet-admin.js";
6
+ import { walletMutationErrorRules } from "./wallet-mutations.js";
7
+ const cliErrorPresentationRules = [
8
+ ...walletAdminErrorRules,
9
+ ...cliSurfaceErrorRules,
10
+ ...miningAndUpdateErrorRules,
11
+ ...serviceErrorRules,
12
+ ...walletMutationErrorRules,
13
+ ...genericCliErrorRules,
14
+ ];
15
+ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
16
+ const input = { errorCode, fallbackMessage, error };
17
+ for (const rule of cliErrorPresentationRules) {
18
+ const presentation = rule(input);
19
+ if (presentation !== null) {
20
+ return presentation;
21
+ }
22
+ }
23
+ return null;
24
+ }
@@ -0,0 +1,2 @@
1
+ import type { CliErrorPresentationRule } from "../types.js";
2
+ export declare const miningAndUpdateErrorRules: readonly CliErrorPresentationRule[];
@@ -0,0 +1,68 @@
1
+ export const miningAndUpdateErrorRules = [
2
+ ({ errorCode }) => {
3
+ if (errorCode === "mining_setup_invalid_provider") {
4
+ return {
5
+ what: "Mining provider choice is invalid.",
6
+ why: "Built-in mining setup currently supports only `openai` or `anthropic` as the provider selection.",
7
+ next: "Rerun `cogcoin mine setup` and choose either `openai` or `anthropic`.",
8
+ };
9
+ }
10
+ if (errorCode === "mining_setup_missing_api_key") {
11
+ return {
12
+ what: "Mining provider API key is required.",
13
+ why: "Built-in mining setup cannot save provider configuration without a non-empty API key.",
14
+ next: "Rerun `cogcoin mine setup` and enter the provider API key when prompted.",
15
+ };
16
+ }
17
+ if (errorCode === "mining_setup_missing_model_id") {
18
+ return {
19
+ what: "Mining model ID is required.",
20
+ why: "Built-in mining setup cannot save a custom mining model choice unless it has a non-empty model ID.",
21
+ next: "Rerun `cogcoin mine setup`, choose `Custom model ID...`, and enter the model ID when prompted.",
22
+ };
23
+ }
24
+ if (errorCode === "mining_setup_canceled") {
25
+ return {
26
+ what: "Mining setup was canceled.",
27
+ why: "The interactive mining-model selection was canceled before any provider configuration was saved.",
28
+ next: "Rerun `cogcoin mine setup` when you are ready to choose a provider model.",
29
+ };
30
+ }
31
+ if (errorCode === "mine_prompt_domain_not_mineable") {
32
+ return {
33
+ what: "A new mining prompt override can only target a mineable anchored root domain.",
34
+ why: "Cogcoin only creates new domain prompt overrides for locally controlled anchored root domains that are currently mineable. Existing stored prompt entries can still be edited or cleared by name even when they are dormant.",
35
+ next: "Run `cogcoin domains --mineable` to see eligible domains, or rerun `cogcoin mine prompt <domain>` for an existing stored prompt entry.",
36
+ };
37
+ }
38
+ if (errorCode === "cli_update_requires_tty") {
39
+ return {
40
+ what: "Updating Cogcoin needs an interactive terminal or `--yes`.",
41
+ why: "When a newer client release is available, `cogcoin update` prompts before running the global npm install unless `--yes` is provided.",
42
+ next: "Rerun `cogcoin update` in an interactive terminal, or add `--yes` to apply the update non-interactively.",
43
+ };
44
+ }
45
+ if (errorCode === "cli_update_registry_unavailable") {
46
+ return {
47
+ what: "Cogcoin could not read the latest client version from the npm registry.",
48
+ why: "The explicit update command requires a fresh registry lookup before it can compare versions or run the install.",
49
+ next: "Check network access and rerun `cogcoin update`.",
50
+ };
51
+ }
52
+ if (errorCode === "cli_update_npm_not_found") {
53
+ return {
54
+ what: "Cogcoin could not find npm to install the update.",
55
+ why: "The update command runs `npm install -g @cogcoin/client`, and no usable `npm` executable was available on PATH.",
56
+ next: "Install Node.js/npm or fix PATH, then rerun `cogcoin update`.",
57
+ };
58
+ }
59
+ if (errorCode === "cli_update_install_failed") {
60
+ return {
61
+ what: "Cogcoin update installation failed.",
62
+ why: "The global npm install exited unsuccessfully before the client update completed.",
63
+ next: "Review the npm output above, fix the installation issue, then rerun `cogcoin update`.",
64
+ };
65
+ }
66
+ return null;
67
+ },
68
+ ];
@@ -0,0 +1,2 @@
1
+ import type { CliErrorPresentationRule } from "../types.js";
2
+ export declare const serviceErrorRules: readonly CliErrorPresentationRule[];
@@ -0,0 +1,110 @@
1
+ export const serviceErrorRules = [
2
+ ({ errorCode }) => {
3
+ if (errorCode.endsWith("_requires_tty") && errorCode !== "cli_update_requires_tty") {
4
+ return {
5
+ what: "Interactive terminal input is required.",
6
+ why: "This command needs terminal input before it can continue safely.",
7
+ next: "Rerun the command in an interactive terminal.",
8
+ };
9
+ }
10
+ if (errorCode.includes("tip_mismatch") || errorCode.includes("stale") || errorCode.includes("catching_up") || errorCode.includes("starting")) {
11
+ return {
12
+ what: "Trusted service state is not ready.",
13
+ why: "The wallet, bitcoind, or indexer is not yet aligned closely enough for this command to proceed safely.",
14
+ next: "Check `cogcoin status`, wait for services to settle, and retry. If the state stays degraded, run `cogcoin repair`.",
15
+ };
16
+ }
17
+ if (errorCode === "indexer_daemon_background_follow_recovery_failed") {
18
+ return {
19
+ what: "The managed indexer daemon could not recover automatic background follow.",
20
+ why: "Cogcoin tried to resume or restart the compatible managed indexer daemon, but it still failed to enter background follow.",
21
+ next: "Run `cogcoin repair` if this persists, then retry.",
22
+ };
23
+ }
24
+ if (errorCode === "indexer_daemon_service_version_mismatch") {
25
+ return {
26
+ what: "The live indexer daemon is running an incompatible service API version.",
27
+ why: "This wallet only trusts indexer daemons that speak `cogcoin/indexer-ipc/v1`, and the reachable daemon reported a different API version.",
28
+ next: "Run `cogcoin repair` so the wallet can stop the incompatible daemon and restart a compatible managed indexer service.",
29
+ };
30
+ }
31
+ if (errorCode === "indexer_daemon_wallet_root_mismatch") {
32
+ return {
33
+ what: "The live indexer daemon belongs to a different wallet root.",
34
+ why: "Managed indexer daemons are namespaced per wallet root, and the reachable daemon reported a different wallet root than this local wallet.",
35
+ next: "Run `cogcoin repair` so the wallet can stop the conflicting managed daemon and restore the correct local indexer service.",
36
+ };
37
+ }
38
+ if (errorCode === "indexer_daemon_schema_mismatch") {
39
+ return {
40
+ what: "The live indexer daemon is using an incompatible sqlite schema.",
41
+ why: "This wallet only trusts indexer daemons with the expected sqlite schema contract, and the reachable daemon reported a schema mismatch.",
42
+ next: "Run `cogcoin repair` after stopping the incompatible daemon, then retry.",
43
+ };
44
+ }
45
+ if (errorCode === "indexer_daemon_protocol_error") {
46
+ return {
47
+ what: "The live indexer daemon socket is not speaking the expected protocol.",
48
+ why: "A process is bound to the managed indexer socket, but it did not respond with a valid cogcoin indexer IPC status exchange.",
49
+ next: "Run `cogcoin repair` to clear stale managed indexer artifacts and restore a compatible daemon.",
50
+ };
51
+ }
52
+ if (errorCode === "managed_bitcoind_service_version_mismatch" || errorCode.includes("bitcoind_service_version_mismatch")) {
53
+ return {
54
+ what: "The live managed bitcoind service is running an incompatible service version.",
55
+ why: "This wallet only trusts managed bitcoind services that speak `cogcoin/bitcoind-service/v1`, and the reachable service reported a different runtime contract.",
56
+ next: "Run `cogcoin repair` so the wallet can stop the incompatible managed bitcoind service and restart a compatible one.",
57
+ };
58
+ }
59
+ if (errorCode === "managed_bitcoind_wallet_root_mismatch" || errorCode.includes("bitcoind_wallet_root_mismatch")) {
60
+ return {
61
+ what: "The live managed bitcoind service belongs to a different wallet root.",
62
+ why: "Managed bitcoind services are tied to one wallet root, and the reachable service reported a different wallet root than this local wallet expects.",
63
+ next: "Run `cogcoin repair` so the wallet can stop the conflicting managed bitcoind service and restore the correct one.",
64
+ };
65
+ }
66
+ if (errorCode === "managed_bitcoind_runtime_mismatch" || errorCode.includes("bitcoind_runtime_mismatch")) {
67
+ return {
68
+ what: "The live managed bitcoind service runtime does not match this wallet.",
69
+ why: "The reachable service is using a different chain, data directory, or runtime root than this wallet expects, so its status cannot be trusted here.",
70
+ next: "Run `cogcoin repair` so the wallet can clear the conflicting runtime and restart a compatible managed bitcoind service.",
71
+ };
72
+ }
73
+ if (errorCode.includes("bitcoind_replica_missing")) {
74
+ return {
75
+ what: "The managed Core wallet replica is missing.",
76
+ why: "This wallet needs a matching managed Core descriptor-wallet replica before it can safely perform stateful operations.",
77
+ next: "Run `cogcoin repair` to recreate the managed Core wallet replica, then retry.",
78
+ };
79
+ }
80
+ if (errorCode.includes("bitcoind_replica_mismatch")) {
81
+ return {
82
+ what: "The managed Core wallet replica does not match trusted wallet state.",
83
+ why: "The local wallet state and the managed Core replica disagree, so this command refuses to keep going on untrusted Core metadata.",
84
+ next: "Run `cogcoin repair` to recreate or rebind the managed Core wallet replica, then retry.",
85
+ };
86
+ }
87
+ if (errorCode === "mining_preemption_timeout") {
88
+ return {
89
+ what: "Wallet repair is blocked by active mining work.",
90
+ why: "Repair waits for mining generation work to acknowledge preemption before it mutates local indexer runtime artifacts.",
91
+ next: "Pause or stop mining, then rerun `cogcoin repair`.",
92
+ };
93
+ }
94
+ if (errorCode.includes("paused")) {
95
+ return {
96
+ what: "Work is currently paused.",
97
+ why: "Another wallet or mining workflow has priority right now.",
98
+ next: "Wait for the current work to settle, then rerun the command.",
99
+ };
100
+ }
101
+ if (errorCode.includes("setup") || errorCode.includes("validation") || errorCode.includes("core_replica_not_ready")) {
102
+ return {
103
+ what: "Local setup is incomplete.",
104
+ why: "This command depends on a local component that is not ready yet.",
105
+ next: "Review the local status output, finish the required setup or repair step, and retry.",
106
+ };
107
+ }
108
+ return null;
109
+ },
110
+ ];
@@ -0,0 +1,2 @@
1
+ import type { CliErrorPresentationRule } from "../types.js";
2
+ export declare const walletAdminErrorRules: readonly CliErrorPresentationRule[];