@cogcoin/client 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/bitcoind/indexer-daemon.d.ts +3 -0
- package/dist/bitcoind/indexer-daemon.js +58 -8
- package/dist/bitcoind/retryable-rpc.js +3 -0
- package/dist/bitcoind/service.d.ts +1 -0
- package/dist/bitcoind/service.js +31 -9
- package/dist/cli/commands/mining-admin.js +9 -0
- package/dist/cli/commands/mining-runtime.js +114 -12
- package/dist/cli/commands/sync.js +1 -91
- package/dist/cli/commands/update.d.ts +2 -0
- package/dist/cli/commands/update.js +101 -0
- package/dist/cli/context.js +33 -1
- package/dist/cli/mining-format.js +28 -0
- package/dist/cli/mining-json.js +6 -0
- package/dist/cli/output.js +50 -2
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.js +5 -0
- package/dist/cli/prompt.js +109 -0
- package/dist/cli/read-json.d.ts +13 -0
- package/dist/cli/read-json.js +17 -0
- package/dist/cli/runner.js +4 -0
- package/dist/cli/sync-progress.d.ts +6 -0
- package/dist/cli/sync-progress.js +91 -0
- package/dist/cli/types.d.ts +8 -2
- package/dist/cli/update-notifier.js +7 -222
- package/dist/cli/update-service.d.ts +44 -0
- package/dist/cli/update-service.js +218 -0
- package/dist/cli/wallet-format.js +3 -0
- package/dist/client/initialization.js +5 -0
- package/dist/wallet/lifecycle.d.ts +10 -0
- package/dist/wallet/lifecycle.js +6 -0
- package/dist/wallet/mining/config.js +13 -3
- package/dist/wallet/mining/control.d.ts +2 -1
- package/dist/wallet/mining/control.js +143 -19
- package/dist/wallet/mining/index.d.ts +2 -2
- package/dist/wallet/mining/index.js +1 -1
- package/dist/wallet/mining/provider-model.d.ts +30 -0
- package/dist/wallet/mining/provider-model.js +134 -0
- package/dist/wallet/mining/runner.d.ts +105 -3
- package/dist/wallet/mining/runner.js +490 -88
- package/dist/wallet/mining/runtime-artifacts.js +1 -0
- package/dist/wallet/mining/sentences.d.ts +2 -2
- package/dist/wallet/mining/sentences.js +25 -2
- package/dist/wallet/mining/types.d.ts +9 -1
- package/dist/wallet/mining/visualizer.js +28 -5
- package/dist/wallet/read/context.js +3 -0
- package/dist/wallet/reset.js +1 -0
- package/dist/wallet/tx/anchor.js +1 -0
- package/dist/wallet/tx/bitcoin-transfer.js +1 -0
- package/dist/wallet/tx/cog.js +3 -0
- package/dist/wallet/tx/domain-admin.js +1 -0
- package/dist/wallet/tx/domain-market.js +3 -0
- package/dist/wallet/tx/field.js +1 -0
- package/dist/wallet/tx/register.js +1 -0
- package/dist/wallet/tx/reputation.js +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { writeLine } from "../io.js";
|
|
2
|
+
import { createMutationSuccessEnvelope, describeCanonicalCommand, resolveStableMutationJsonSchema, writeHandledCliError, writeJsonValue, } from "../output.js";
|
|
3
|
+
import { CLI_INSTALL_COMMAND, EXPLICIT_UPDATE_CHECK_TIMEOUT_MS, applyUpdateCheckResult, compareSemver, createEmptyUpdateCheckCache, fetchLatestPublishedVersion, loadUpdateCheckCache, persistUpdateCheckCache, } from "../update-service.js";
|
|
4
|
+
function createUpdateResult(currentVersion, latestVersion, status, applied) {
|
|
5
|
+
return {
|
|
6
|
+
currentVersion,
|
|
7
|
+
latestVersion,
|
|
8
|
+
installCommand: CLI_INSTALL_COMMAND,
|
|
9
|
+
status,
|
|
10
|
+
applied,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function writeVersionSummary(context, currentVersion, latestVersion) {
|
|
14
|
+
writeLine(context.stdout, `Current version: ${currentVersion}`);
|
|
15
|
+
writeLine(context.stdout, `Latest version: ${latestVersion}`);
|
|
16
|
+
writeLine(context.stdout, `Run: ${CLI_INSTALL_COMMAND}`);
|
|
17
|
+
}
|
|
18
|
+
async function confirmApplyUpdate(context) {
|
|
19
|
+
const prompter = context.createPrompter();
|
|
20
|
+
if (!prompter.isInteractive) {
|
|
21
|
+
throw new Error("cli_update_requires_tty");
|
|
22
|
+
}
|
|
23
|
+
while (true) {
|
|
24
|
+
const answer = (await prompter.prompt("Install update now? [Y/n]: ")).trim().toLowerCase();
|
|
25
|
+
if (answer === "" || answer === "y" || answer === "yes") {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (answer === "n" || answer === "no") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
prompter.writeLine("Enter \"y\" to continue or \"n\" to cancel.");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function writeSuccessJson(parsed, context, result) {
|
|
35
|
+
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMutationJsonSchema(parsed), describeCanonicalCommand(parsed), result.status, result));
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
export async function runUpdateCommand(parsed, context) {
|
|
39
|
+
try {
|
|
40
|
+
const currentVersion = await context.readPackageVersion();
|
|
41
|
+
const cachePath = context.resolveUpdateCheckStatePath();
|
|
42
|
+
const now = context.now();
|
|
43
|
+
const cache = await loadUpdateCheckCache(cachePath) ?? createEmptyUpdateCheckCache();
|
|
44
|
+
const updateResult = await fetchLatestPublishedVersion(context.fetchImpl, {
|
|
45
|
+
timeoutMs: EXPLICIT_UPDATE_CHECK_TIMEOUT_MS,
|
|
46
|
+
});
|
|
47
|
+
if (updateResult.kind !== "success") {
|
|
48
|
+
throw new Error("cli_update_registry_unavailable");
|
|
49
|
+
}
|
|
50
|
+
await persistUpdateCheckCache(cachePath, applyUpdateCheckResult(cache, updateResult, now));
|
|
51
|
+
const latestVersion = updateResult.latestVersion;
|
|
52
|
+
const comparison = compareSemver(latestVersion, currentVersion);
|
|
53
|
+
if (comparison === null) {
|
|
54
|
+
throw new Error("cli_update_registry_unavailable");
|
|
55
|
+
}
|
|
56
|
+
if (comparison <= 0) {
|
|
57
|
+
const result = createUpdateResult(currentVersion, latestVersion, "up-to-date", false);
|
|
58
|
+
if (parsed.outputMode === "json") {
|
|
59
|
+
return writeSuccessJson(parsed, context, result);
|
|
60
|
+
}
|
|
61
|
+
writeVersionSummary(context, currentVersion, latestVersion);
|
|
62
|
+
writeLine(context.stdout, "Cogcoin is already up to date.");
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
if (!parsed.assumeYes) {
|
|
66
|
+
if (parsed.outputMode !== "text") {
|
|
67
|
+
throw new Error("cli_update_requires_tty");
|
|
68
|
+
}
|
|
69
|
+
writeVersionSummary(context, currentVersion, latestVersion);
|
|
70
|
+
if (!(await confirmApplyUpdate(context))) {
|
|
71
|
+
writeLine(context.stdout, "Update canceled.");
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (parsed.outputMode === "text") {
|
|
76
|
+
writeVersionSummary(context, currentVersion, latestVersion);
|
|
77
|
+
}
|
|
78
|
+
if (parsed.outputMode === "text") {
|
|
79
|
+
writeLine(context.stdout, "Installing update...");
|
|
80
|
+
}
|
|
81
|
+
await context.runGlobalClientUpdateInstall({
|
|
82
|
+
stdout: parsed.outputMode === "json" ? context.stderr : context.stdout,
|
|
83
|
+
stderr: context.stderr,
|
|
84
|
+
env: context.env,
|
|
85
|
+
});
|
|
86
|
+
const result = createUpdateResult(currentVersion, latestVersion, "updated", true);
|
|
87
|
+
if (parsed.outputMode === "json") {
|
|
88
|
+
return writeSuccessJson(parsed, context, result);
|
|
89
|
+
}
|
|
90
|
+
writeLine(context.stdout, "Update completed. The next cogcoin invocation will use the new install.");
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return writeHandledCliError({
|
|
95
|
+
parsed,
|
|
96
|
+
stdout: context.stdout,
|
|
97
|
+
stderr: context.stderr,
|
|
98
|
+
error,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
package/dist/cli/context.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
1
2
|
import { mkdir, readFile } from "node:fs/promises";
|
|
2
3
|
import { attachOrStartIndexerDaemon, probeIndexerDaemon, readObservedIndexerDaemonStatus, stopIndexerDaemonService, } from "../bitcoind/indexer-daemon.js";
|
|
3
4
|
import { createRpcClient } from "../bitcoind/node.js";
|
|
@@ -10,7 +11,7 @@ import { initializeWallet, deleteImportedWalletSeed, previewResetWallet, repairW
|
|
|
10
11
|
import { resolveWalletRuntimePathsForTesting } from "../wallet/runtime.js";
|
|
11
12
|
import { openWalletReadContext } from "../wallet/read/index.js";
|
|
12
13
|
import { loadRawWalletStateEnvelope, loadWalletState } from "../wallet/state/storage.js";
|
|
13
|
-
import { followMiningLog, inspectMiningControlPlane, readMiningLog, runForegroundMining, setupBuiltInMining, startBackgroundMining, stopBackgroundMining, } from "../wallet/mining/index.js";
|
|
14
|
+
import { ensureBuiltInMiningSetupIfNeeded, followMiningLog, inspectMiningControlPlane, readMiningLog, runForegroundMining, setupBuiltInMining, startBackgroundMining, stopBackgroundMining, } from "../wallet/mining/index.js";
|
|
14
15
|
import { createLazyDefaultWalletSecretProvider } from "../wallet/state/provider.js";
|
|
15
16
|
import { anchorDomain, transferBitcoin, buyDomain, claimCogLock, clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, clearField, createField, giveReputation, lockCogToDomain, registerDomain, reclaimCogLock, revokeReputation, sendCog, setField, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, sellDomain, transferDomain, } from "../wallet/tx/index.js";
|
|
16
17
|
import { createTerminalPrompter } from "./prompt.js";
|
|
@@ -36,6 +37,35 @@ export async function readPackageVersionFromDisk() {
|
|
|
36
37
|
}
|
|
37
38
|
return "0.0.0";
|
|
38
39
|
}
|
|
40
|
+
async function runGlobalClientUpdateInstall(options) {
|
|
41
|
+
const binary = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
42
|
+
await new Promise((resolve, reject) => {
|
|
43
|
+
const child = spawn(binary, ["install", "-g", "@cogcoin/client"], {
|
|
44
|
+
env: options.env,
|
|
45
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
46
|
+
});
|
|
47
|
+
child.stdout?.on("data", (chunk) => {
|
|
48
|
+
options.stdout.write(typeof chunk === "string" ? chunk : chunk.toString("utf8"));
|
|
49
|
+
});
|
|
50
|
+
child.stderr?.on("data", (chunk) => {
|
|
51
|
+
options.stderr.write(typeof chunk === "string" ? chunk : chunk.toString("utf8"));
|
|
52
|
+
});
|
|
53
|
+
child.on("error", (error) => {
|
|
54
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
55
|
+
reject(new Error("cli_update_npm_not_found"));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
reject(new Error("cli_update_install_failed"));
|
|
59
|
+
});
|
|
60
|
+
child.on("close", (code) => {
|
|
61
|
+
if (code === 0) {
|
|
62
|
+
resolve();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
reject(new Error("cli_update_install_failed"));
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
39
69
|
export function createDefaultContext(overrides = {}) {
|
|
40
70
|
return {
|
|
41
71
|
stdout: overrides.stdout ?? process.stdout,
|
|
@@ -48,6 +78,7 @@ export function createDefaultContext(overrides = {}) {
|
|
|
48
78
|
process.exit(code);
|
|
49
79
|
}),
|
|
50
80
|
fetchImpl: overrides.fetchImpl ?? fetch,
|
|
81
|
+
runGlobalClientUpdateInstall: overrides.runGlobalClientUpdateInstall ?? runGlobalClientUpdateInstall,
|
|
51
82
|
openSqliteStore: overrides.openSqliteStore ?? openSqliteStore,
|
|
52
83
|
openManagedBitcoindClient: overrides.openManagedBitcoindClient ?? openManagedBitcoindClient,
|
|
53
84
|
inspectPassiveClientStatus: overrides.inspectPassiveClientStatus ?? inspectPassiveClientStatus,
|
|
@@ -80,6 +111,7 @@ export function createDefaultContext(overrides = {}) {
|
|
|
80
111
|
giveReputation: overrides.giveReputation ?? giveReputation,
|
|
81
112
|
revokeReputation: overrides.revokeReputation ?? revokeReputation,
|
|
82
113
|
inspectMiningControlPlane: overrides.inspectMiningControlPlane ?? inspectMiningControlPlane,
|
|
114
|
+
ensureBuiltInMiningSetupIfNeeded: overrides.ensureBuiltInMiningSetupIfNeeded ?? ensureBuiltInMiningSetupIfNeeded,
|
|
83
115
|
runForegroundMining: overrides.runForegroundMining ?? runForegroundMining,
|
|
84
116
|
startBackgroundMining: overrides.startBackgroundMining ?? startBackgroundMining,
|
|
85
117
|
stopBackgroundMining: overrides.stopBackgroundMining ?? stopBackgroundMining,
|
|
@@ -13,6 +13,20 @@ function formatIndexerTruthSource(source) {
|
|
|
13
13
|
return "none";
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
function formatProviderModel(mining) {
|
|
17
|
+
if (mining.provider.effectiveModel === null || mining.provider.usingDefaultModel === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return `${mining.provider.effectiveModel} (${mining.provider.usingDefaultModel ? "default" : "override"})`;
|
|
21
|
+
}
|
|
22
|
+
function formatProviderModelSource(mining) {
|
|
23
|
+
return mining.provider.modelSelectionSource;
|
|
24
|
+
}
|
|
25
|
+
function resolveProviderNotFoundNextStep(mining) {
|
|
26
|
+
return mining.provider.usingDefaultModel === false
|
|
27
|
+
? "Next: run `cogcoin mine setup` and clear or correct the provider model."
|
|
28
|
+
: "Next: run `cogcoin mine setup` and choose a valid provider model.";
|
|
29
|
+
}
|
|
16
30
|
export function formatMiningSummaryLine(mining) {
|
|
17
31
|
const provider = mining.provider.configured
|
|
18
32
|
? `${mining.provider.provider} configured`
|
|
@@ -42,6 +56,17 @@ export function formatMineStatusReport(mining) {
|
|
|
42
56
|
lines.push(`Last suspend detected: ${formatMaybeIso(mining.runtime.lastSuspendDetectedAtUnixMs)}`);
|
|
43
57
|
}
|
|
44
58
|
lines.push(`Provider: ${mining.provider.configured ? `${mining.provider.provider} configured` : mining.provider.status}`);
|
|
59
|
+
const providerModel = formatProviderModel(mining);
|
|
60
|
+
if (providerModel !== null) {
|
|
61
|
+
lines.push(`Provider model: ${providerModel}`);
|
|
62
|
+
}
|
|
63
|
+
const providerModelSource = formatProviderModelSource(mining);
|
|
64
|
+
if (providerModelSource !== null) {
|
|
65
|
+
lines.push(`Provider model source: ${providerModelSource}`);
|
|
66
|
+
}
|
|
67
|
+
if (mining.provider.estimatedDailyCostDisplay !== null) {
|
|
68
|
+
lines.push(`Estimated daily cost: ${mining.provider.estimatedDailyCostDisplay}`);
|
|
69
|
+
}
|
|
45
70
|
if (mining.provider.message !== null) {
|
|
46
71
|
lines.push(`Provider note: ${mining.provider.message}`);
|
|
47
72
|
}
|
|
@@ -105,6 +130,9 @@ export function formatMineStatusReport(mining) {
|
|
|
105
130
|
if (mining.runtime.miningState === "repair-required") {
|
|
106
131
|
lines.push("Next: run `cogcoin repair` before mining again.");
|
|
107
132
|
}
|
|
133
|
+
else if (mining.runtime.providerState === "not-found") {
|
|
134
|
+
lines.push(resolveProviderNotFoundNextStep(mining));
|
|
135
|
+
}
|
|
108
136
|
else if (mining.runtime.pauseReason === "zero-reward") {
|
|
109
137
|
lines.push("Next: wait for the next positive-reward target height; mining resumes automatically.");
|
|
110
138
|
}
|
package/dist/cli/mining-json.js
CHANGED
|
@@ -18,8 +18,14 @@ export function buildMineSetupData(view) {
|
|
|
18
18
|
configured: view.provider.configured,
|
|
19
19
|
provider: view.provider.provider,
|
|
20
20
|
status: view.provider.status,
|
|
21
|
+
modelId: view.provider.modelId,
|
|
21
22
|
modelOverride: view.provider.modelOverride,
|
|
23
|
+
modelSelectionSource: view.provider.modelSelectionSource,
|
|
24
|
+
effectiveModel: view.provider.effectiveModel,
|
|
25
|
+
usingDefaultModel: view.provider.usingDefaultModel,
|
|
22
26
|
extraPromptConfigured: view.provider.extraPromptConfigured,
|
|
27
|
+
estimatedDailyCostUsd: view.provider.estimatedDailyCostUsd,
|
|
28
|
+
estimatedDailyCostDisplay: view.provider.estimatedDailyCostDisplay,
|
|
23
29
|
},
|
|
24
30
|
runtime: summarizeRuntime(view.runtime),
|
|
25
31
|
};
|
package/dist/cli/output.js
CHANGED
|
@@ -127,7 +127,9 @@ export function classifyCliError(error) {
|
|
|
127
127
|
return { exitCode: 2, errorCode: message, message };
|
|
128
128
|
}
|
|
129
129
|
if (message === "mining_setup_invalid_provider"
|
|
130
|
-
|| message === "mining_setup_missing_api_key"
|
|
130
|
+
|| message === "mining_setup_missing_api_key"
|
|
131
|
+
|| message === "mining_setup_missing_model_id"
|
|
132
|
+
|| message === "mining_setup_canceled") {
|
|
131
133
|
return { exitCode: 2, errorCode: message, message };
|
|
132
134
|
}
|
|
133
135
|
if (message.endsWith("_typed_ack_required")) {
|
|
@@ -507,6 +509,20 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
507
509
|
next: "Rerun `cogcoin mine setup` and enter the provider API key when prompted.",
|
|
508
510
|
};
|
|
509
511
|
}
|
|
512
|
+
if (errorCode === "mining_setup_missing_model_id") {
|
|
513
|
+
return {
|
|
514
|
+
what: "Mining model ID is required.",
|
|
515
|
+
why: "Built-in mining setup cannot save a custom mining model choice unless it has a non-empty model ID.",
|
|
516
|
+
next: "Rerun `cogcoin mine setup`, choose `Custom model ID...`, and enter the model ID when prompted.",
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
if (errorCode === "mining_setup_canceled") {
|
|
520
|
+
return {
|
|
521
|
+
what: "Mining setup was canceled.",
|
|
522
|
+
why: "The interactive mining-model selection was canceled before any provider configuration was saved.",
|
|
523
|
+
next: "Rerun `cogcoin mine setup` when you are ready to choose a provider model.",
|
|
524
|
+
};
|
|
525
|
+
}
|
|
510
526
|
if (errorCode.endsWith("_confirmation_rejected")) {
|
|
511
527
|
return {
|
|
512
528
|
what: "Confirmation was declined.",
|
|
@@ -561,7 +577,7 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
561
577
|
next: "Restore or otherwise recover the wallet into the current format, then retry the command.",
|
|
562
578
|
};
|
|
563
579
|
}
|
|
564
|
-
if (errorCode.endsWith("_requires_tty")) {
|
|
580
|
+
if (errorCode.endsWith("_requires_tty") && errorCode !== "cli_update_requires_tty") {
|
|
565
581
|
return {
|
|
566
582
|
what: "Interactive terminal input is required.",
|
|
567
583
|
why: "This command needs terminal input before it can continue safely.",
|
|
@@ -860,6 +876,34 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
860
876
|
next: "Rerun the command in an interactive terminal, or add `--yes` if that is appropriate for your workflow.",
|
|
861
877
|
};
|
|
862
878
|
}
|
|
879
|
+
if (errorCode === "cli_update_requires_tty") {
|
|
880
|
+
return {
|
|
881
|
+
what: "Updating Cogcoin needs an interactive terminal or `--yes`.",
|
|
882
|
+
why: "When a newer client release is available, `cogcoin update` prompts before running the global npm install unless `--yes` is provided.",
|
|
883
|
+
next: "Rerun `cogcoin update` in an interactive terminal, or add `--yes` to apply the update non-interactively.",
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
if (errorCode === "cli_update_registry_unavailable") {
|
|
887
|
+
return {
|
|
888
|
+
what: "Cogcoin could not read the latest client version from the npm registry.",
|
|
889
|
+
why: "The explicit update command requires a fresh registry lookup before it can compare versions or run the install.",
|
|
890
|
+
next: "Check network access and rerun `cogcoin update`.",
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
if (errorCode === "cli_update_npm_not_found") {
|
|
894
|
+
return {
|
|
895
|
+
what: "Cogcoin could not find npm to install the update.",
|
|
896
|
+
why: "The update command runs `npm install -g @cogcoin/client`, and no usable `npm` executable was available on PATH.",
|
|
897
|
+
next: "Install Node.js/npm or fix PATH, then rerun `cogcoin update`.",
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
if (errorCode === "cli_update_install_failed") {
|
|
901
|
+
return {
|
|
902
|
+
what: "Cogcoin update installation failed.",
|
|
903
|
+
why: "The global npm install exited unsuccessfully before the client update completed.",
|
|
904
|
+
next: "Review the npm output above, fix the installation issue, then rerun `cogcoin update`.",
|
|
905
|
+
};
|
|
906
|
+
}
|
|
863
907
|
if (errorCode === "wallet_claim_sender_not_local") {
|
|
864
908
|
return {
|
|
865
909
|
what: "The claim sender is not locally controlled.",
|
|
@@ -918,6 +962,8 @@ export function describeCanonicalCommand(parsed) {
|
|
|
918
962
|
return "cogcoin reset";
|
|
919
963
|
case "repair":
|
|
920
964
|
return "cogcoin repair";
|
|
965
|
+
case "update":
|
|
966
|
+
return "cogcoin update";
|
|
921
967
|
case "anchor":
|
|
922
968
|
case "domain-anchor":
|
|
923
969
|
return `cogcoin anchor ${args[0] ?? "<domain>"}`;
|
|
@@ -1096,6 +1142,8 @@ export function resolveStableMutationJsonSchema(parsed) {
|
|
|
1096
1142
|
return "cogcoin/reset/v1";
|
|
1097
1143
|
case "repair":
|
|
1098
1144
|
return "cogcoin/repair/v1";
|
|
1145
|
+
case "update":
|
|
1146
|
+
return "cogcoin/update/v1";
|
|
1099
1147
|
case "anchor":
|
|
1100
1148
|
case "domain-anchor":
|
|
1101
1149
|
return "cogcoin/anchor/v1";
|
package/dist/cli/parse.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ParsedCliArgs } from "./types.js";
|
|
2
|
-
export declare const HELP_TEXT = "Usage: cogcoin <command> [options]\n\nCommands:\n status Show wallet-aware local service and chain status\n status --output json Emit the stable v1 machine-readable status envelope\n client unlock Unlock password-protected local wallet secrets for a limited time\n client lock Flush the cached client password unlock session\n client change-password Rotate the client password that protects local wallet secrets\n bitcoin start Start the managed Bitcoin daemon\n bitcoin stop Stop the managed Bitcoin daemon and paired indexer\n bitcoin status Show managed Bitcoin daemon status without starting it\n bitcoin transfer <sats> --to <address>\n Send plain BTC from the wallet address\n indexer start Start the managed Cogcoin indexer (and bitcoind if needed)\n indexer stop Stop the managed Cogcoin indexer only\n indexer status Show managed Cogcoin indexer status without starting it\n init Initialize a new local wallet root\n init --output json Emit the stable v1 machine-readable init result envelope\n restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n reset Factory-reset local Cogcoin state with interactive retention prompts\n repair Recover bounded wallet/indexer/runtime state\n wallet address Alias for address\n wallet ids Alias for ids\n mine Run the miner in the foreground\n mine start Start the miner as a background worker\n mine stop Stop the active background miner\n mine setup Configure the built-in mining provider\n mine setup --output json\n Emit the stable v1 machine-readable mine setup result envelope\n mine status Show mining control-plane health and readiness\n mine log Show recent mining control-plane events\n anchor <domain> Anchor an owned unanchored domain with the wallet address\n register <domain>\n Register a root domain or subdomain\n transfer <domain> --to <btc-target>\n Transfer an unanchored domain to another BTC address or script\n sell <domain> <price> List an unanchored domain for sale in COG\n unsell <domain> Clear an active domain listing\n buy <domain>\n Buy an unanchored listed domain in COG\n send <amount> --to <btc-target>\n Send COG from the wallet address to another BTC target\n claim <lock-id> --preimage <32-byte-hex>\n Claim an active COG lock before timeout\n reclaim <lock-id> Reclaim an expired COG lock as the original locker\n cog lock <amount> --to-domain <domain> (--for <blocks-or-duration> | --until-height <height>) --condition <sha256hex>\n Lock COG to an anchored recipient domain\n wallet status Show detailed wallet-local status and service health\n wallet init Initialize a new local wallet root\n wallet restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n wallet delete Delete one imported named seed without affecting main\n wallet show-mnemonic Reveal the initialized wallet recovery phrase after typed confirmation\n address Show the BTC wallet address for this wallet\n ids Show the local wallet address\n balance Show local wallet COG balances\n locks Show locally related active COG locks\n domain list Alias for domains\n domain show <domain> Alias for show <domain>\n domains [--anchored] [--listed] [--mineable]\n Show locally related domains\n show <domain> Show one domain and its local-wallet relationship\n fields <domain> List current fields on a domain\n field <domain> <field> Show one current field value\n field create <domain> <field>\n Create a new empty anchored field\n field set <domain> <field>\n Update an existing anchored field value\n field clear <domain> <field>\n Clear an existing anchored field value\n rep give <source-domain> <target-domain> <amount>\n Burn COG as anchored-domain reputation support\n rep revoke <source-domain> <target-domain> <amount>\n Revoke visible support without refunding burned COG\n\nOptions:\n --db <path> Override the SQLite database path\n --data-dir <path> Override the managed bitcoin datadir\n --for <duration> Relative timeout for cog lock, like 15m, 2h, or 1d\n --message <text> Founding message text for anchor\n --to <btc-target> Transfer or send target as an address or spk:<hex>\n --to-domain <domain>\n Recipient domain for cog lock\n --condition <sha256hex>\n 32-byte lock condition hash\n --until-height <height>\n Absolute timeout height for cog lock\n --preimage <32-byte-hex>\n Claim preimage for an active lock\n --review <text> Optional public review text for reputation operations\n --satvb <n> Override the mutation fee rate in sat/vB\n --text <utf8> UTF-8 payload text for endpoint or field writes\n --json <json> UTF-8 payload JSON text for endpoint or field writes\n --bytes <spec> Payload bytes as hex:<hex> or @<path>\n --permanent Create the field as permanent\n --format <spec> Advanced field format as raw:<u8>\n --value <spec> Advanced field value as hex:<hex>, @<path>, or utf8:<text>\n --claimable Show only currently claimable locks\n --reclaimable Show only currently reclaimable locks\n --anchored Show only anchored domains\n --listed Show only currently listed domains\n --mineable Show only locally mineable root domains\n --limit <n> Limit list rows (1..1000)\n --all Show all rows for list commands\n --follow Follow mining log output\n --output <mode> Output mode: text, json, or preview-json\n --progress <mode> Progress output mode: auto, tty, or none\n --seed <name> Select an imported wallet seed for wallet-aware commands\n --force Reserved for future use\n --force-race Allow a visible root registration race\n --yes Approve eligible plain yes/no mutation confirmations non-interactively\n --help Show help\n --version Show package version\n\nQuickstart:\n 1. Run `cogcoin init` to create the wallet.\n 2. Run `cogcoin sync` to bootstrap assumeutxo and the managed Bitcoin/indexer state.\n 3. Run `cogcoin address`, then fund the wallet with about 0.0015 BTC so you can buy a 6+ character domain to start mining and still keep BTC available for mining transaction fees.\n\nExamples:\n cogcoin status --output json\n cogcoin bitcoin status\n cogcoin indexer status\n cogcoin init --output json\n cogcoin restore --seed trading\n cogcoin wallet address\n cogcoin domain list --mineable\n cogcoin register alpha-child\n cogcoin anchor alpha\n cogcoin register alpha --satvb 12.5\n cogcoin buy alpha\n cogcoin field set alpha bio --text \"hello\"\n cogcoin rep give alpha beta 10 --review \"great operator\"\n cogcoin mine setup --output json\n cogcoin register alpha-child --output preview-json\n cogcoin mine status\n";
|
|
2
|
+
export declare const HELP_TEXT = "Usage: cogcoin <command> [options]\n\nCommands:\n status Show wallet-aware local service and chain status\n status --output json Emit the stable v1 machine-readable status envelope\n update Show the current and latest client versions and install updates\n update --output json Emit the stable v1 machine-readable update result envelope\n client unlock Unlock password-protected local wallet secrets for a limited time\n client lock Flush the cached client password unlock session\n client change-password Rotate the client password that protects local wallet secrets\n bitcoin start Start the managed Bitcoin daemon\n bitcoin stop Stop the managed Bitcoin daemon and paired indexer\n bitcoin status Show managed Bitcoin daemon status without starting it\n bitcoin transfer <sats> --to <address>\n Send plain BTC from the wallet address\n indexer start Start the managed Cogcoin indexer (and bitcoind if needed)\n indexer stop Stop the managed Cogcoin indexer only\n indexer status Show managed Cogcoin indexer status without starting it\n init Initialize a new local wallet root\n init --output json Emit the stable v1 machine-readable init result envelope\n restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n reset Factory-reset local Cogcoin state with interactive retention prompts\n repair Recover bounded wallet/indexer/runtime state\n wallet address Alias for address\n wallet ids Alias for ids\n mine Run the miner in the foreground\n mine start Start the miner as a background worker\n mine stop Stop the active background miner\n mine setup Configure the built-in mining provider\n mine setup --output json\n Emit the stable v1 machine-readable mine setup result envelope\n mine status Show mining control-plane health and readiness\n mine log Show recent mining control-plane events\n anchor <domain> Anchor an owned unanchored domain with the wallet address\n register <domain>\n Register a root domain or subdomain\n transfer <domain> --to <btc-target>\n Transfer an unanchored domain to another BTC address or script\n sell <domain> <price> List an unanchored domain for sale in COG\n unsell <domain> Clear an active domain listing\n buy <domain>\n Buy an unanchored listed domain in COG\n send <amount> --to <btc-target>\n Send COG from the wallet address to another BTC target\n claim <lock-id> --preimage <32-byte-hex>\n Claim an active COG lock before timeout\n reclaim <lock-id> Reclaim an expired COG lock as the original locker\n cog lock <amount> --to-domain <domain> (--for <blocks-or-duration> | --until-height <height>) --condition <sha256hex>\n Lock COG to an anchored recipient domain\n wallet status Show detailed wallet-local status and service health\n wallet init Initialize a new local wallet root\n wallet restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n wallet delete Delete one imported named seed without affecting main\n wallet show-mnemonic Reveal the initialized wallet recovery phrase after typed confirmation\n address Show the BTC wallet address for this wallet\n ids Show the local wallet address\n balance Show local wallet COG balances\n locks Show locally related active COG locks\n domain list Alias for domains\n domain show <domain> Alias for show <domain>\n domains [--anchored] [--listed] [--mineable]\n Show locally related domains\n show <domain> Show one domain and its local-wallet relationship\n fields <domain> List current fields on a domain\n field <domain> <field> Show one current field value\n field create <domain> <field>\n Create a new empty anchored field\n field set <domain> <field>\n Update an existing anchored field value\n field clear <domain> <field>\n Clear an existing anchored field value\n rep give <source-domain> <target-domain> <amount>\n Burn COG as anchored-domain reputation support\n rep revoke <source-domain> <target-domain> <amount>\n Revoke visible support without refunding burned COG\n\nOptions:\n --db <path> Override the SQLite database path\n --data-dir <path> Override the managed bitcoin datadir\n --for <duration> Relative timeout for cog lock, like 15m, 2h, or 1d\n --message <text> Founding message text for anchor\n --to <btc-target> Transfer or send target as an address or spk:<hex>\n --to-domain <domain>\n Recipient domain for cog lock\n --condition <sha256hex>\n 32-byte lock condition hash\n --until-height <height>\n Absolute timeout height for cog lock\n --preimage <32-byte-hex>\n Claim preimage for an active lock\n --review <text> Optional public review text for reputation operations\n --satvb <n> Override the mutation fee rate in sat/vB\n --text <utf8> UTF-8 payload text for endpoint or field writes\n --json <json> UTF-8 payload JSON text for endpoint or field writes\n --bytes <spec> Payload bytes as hex:<hex> or @<path>\n --permanent Create the field as permanent\n --format <spec> Advanced field format as raw:<u8>\n --value <spec> Advanced field value as hex:<hex>, @<path>, or utf8:<text>\n --claimable Show only currently claimable locks\n --reclaimable Show only currently reclaimable locks\n --anchored Show only anchored domains\n --listed Show only currently listed domains\n --mineable Show only locally mineable root domains\n --limit <n> Limit list rows (1..1000)\n --all Show all rows for list commands\n --follow Follow mining log output\n --output <mode> Output mode: text, json, or preview-json\n --progress <mode> Progress output mode: auto, tty, or none\n --seed <name> Select an imported wallet seed for wallet-aware commands\n --force Reserved for future use\n --force-race Allow a visible root registration race\n --yes Approve eligible plain yes/no mutation confirmations non-interactively\n --help Show help\n --version Show package version\n\nQuickstart:\n 1. Run `cogcoin init` to create the wallet.\n 2. Run `cogcoin sync` to bootstrap assumeutxo and the managed Bitcoin/indexer state.\n 3. Run `cogcoin address`, then fund the wallet with about 0.0015 BTC so you can buy a 6+ character domain to start mining and still keep BTC available for mining transaction fees.\n\nExamples:\n cogcoin status --output json\n cogcoin bitcoin status\n cogcoin indexer status\n cogcoin init --output json\n cogcoin restore --seed trading\n cogcoin wallet address\n cogcoin domain list --mineable\n cogcoin register alpha-child\n cogcoin anchor alpha\n cogcoin register alpha --satvb 12.5\n cogcoin buy alpha\n cogcoin field set alpha bio --text \"hello\"\n cogcoin rep give alpha beta 10 --review \"great operator\"\n cogcoin mine setup --output json\n cogcoin register alpha-child --output preview-json\n cogcoin mine status\n";
|
|
3
3
|
export declare function parseCliArgs(argv: string[]): ParsedCliArgs;
|
package/dist/cli/parse.js
CHANGED
|
@@ -5,6 +5,8 @@ export const HELP_TEXT = `Usage: cogcoin <command> [options]
|
|
|
5
5
|
Commands:
|
|
6
6
|
status Show wallet-aware local service and chain status
|
|
7
7
|
status --output json Emit the stable v1 machine-readable status envelope
|
|
8
|
+
update Show the current and latest client versions and install updates
|
|
9
|
+
update --output json Emit the stable v1 machine-readable update result envelope
|
|
8
10
|
client unlock Unlock password-protected local wallet secrets for a limited time
|
|
9
11
|
client lock Flush the cached client password unlock session
|
|
10
12
|
client change-password Rotate the client password that protects local wallet secrets
|
|
@@ -138,6 +140,7 @@ Examples:
|
|
|
138
140
|
`;
|
|
139
141
|
function supportsYesFlag(command) {
|
|
140
142
|
switch (command) {
|
|
143
|
+
case "update":
|
|
141
144
|
case "sync":
|
|
142
145
|
case "follow":
|
|
143
146
|
case "bitcoin-transfer":
|
|
@@ -834,6 +837,7 @@ export function parseCliArgs(argv) {
|
|
|
834
837
|
|| token === "restore"
|
|
835
838
|
|| token === "reset"
|
|
836
839
|
|| token === "repair"
|
|
840
|
+
|| token === "update"
|
|
837
841
|
|| token === "sync"
|
|
838
842
|
|| token === "status"
|
|
839
843
|
|| token === "follow"
|
|
@@ -864,6 +868,7 @@ export function parseCliArgs(argv) {
|
|
|
864
868
|
args.push(token);
|
|
865
869
|
}
|
|
866
870
|
if ((command === "status"
|
|
871
|
+
|| command === "update"
|
|
867
872
|
|| command === "bitcoin-start"
|
|
868
873
|
|| command === "bitcoin-stop"
|
|
869
874
|
|| command === "bitcoin-status"
|
package/dist/cli/prompt.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
2
|
const CLEAR_SENSITIVE_DISPLAY_SEQUENCE = "\u001B[2J\u001B[3J\u001B[H";
|
|
3
|
+
const CLEAR_MENU_SEQUENCE = "\u001B[0J";
|
|
4
|
+
function countRenderedLines(text) {
|
|
5
|
+
return text.endsWith("\n") ? text.split("\n").length - 1 : text.split("\n").length;
|
|
6
|
+
}
|
|
3
7
|
export function createTerminalPrompter(input, output) {
|
|
4
8
|
const ensureReadableInput = () => {
|
|
5
9
|
if (!("on" in input) || !("off" in input)) {
|
|
@@ -8,6 +12,12 @@ export function createTerminalPrompter(input, output) {
|
|
|
8
12
|
return input;
|
|
9
13
|
};
|
|
10
14
|
const ensureWritableOutput = () => output;
|
|
15
|
+
const supportsRawSelection = () => {
|
|
16
|
+
const readable = ensureReadableInput();
|
|
17
|
+
return Boolean(readable.isTTY
|
|
18
|
+
&& output.isTTY
|
|
19
|
+
&& typeof readable.setRawMode === "function");
|
|
20
|
+
};
|
|
11
21
|
const ask = async (message, questionOutput) => {
|
|
12
22
|
const readline = createInterface({
|
|
13
23
|
input: ensureReadableInput(),
|
|
@@ -20,6 +30,99 @@ export function createTerminalPrompter(input, output) {
|
|
|
20
30
|
readline.close();
|
|
21
31
|
}
|
|
22
32
|
};
|
|
33
|
+
const promptSelectionFallback = async (options) => {
|
|
34
|
+
const writableOutput = ensureWritableOutput();
|
|
35
|
+
writableOutput.write(`${options.message}\n`);
|
|
36
|
+
for (const [index, option] of options.options.entries()) {
|
|
37
|
+
const description = option.description == null || option.description.length === 0
|
|
38
|
+
? ""
|
|
39
|
+
: ` - ${option.description}`;
|
|
40
|
+
writableOutput.write(`${index + 1}. ${option.label}${description}\n`);
|
|
41
|
+
}
|
|
42
|
+
if (options.footer != null && options.footer.length > 0) {
|
|
43
|
+
writableOutput.write(`${options.footer}\n`);
|
|
44
|
+
}
|
|
45
|
+
while (true) {
|
|
46
|
+
const answer = (await ask(`Choice [1-${options.options.length}]: `, writableOutput)).trim();
|
|
47
|
+
if (/^(q|quit|esc|escape)$/i.test(answer)) {
|
|
48
|
+
throw new Error("mining_setup_canceled");
|
|
49
|
+
}
|
|
50
|
+
const selection = Number.parseInt(answer, 10);
|
|
51
|
+
if (Number.isInteger(selection) && selection >= 1 && selection <= options.options.length) {
|
|
52
|
+
return options.options[selection - 1].value;
|
|
53
|
+
}
|
|
54
|
+
writableOutput.write(`Enter a number from 1 to ${options.options.length}, or q to cancel.\n`);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const promptSelectionRaw = async (options) => {
|
|
58
|
+
const readableInput = ensureReadableInput();
|
|
59
|
+
const writableOutput = ensureWritableOutput();
|
|
60
|
+
const initialIndex = options.initialValue == null
|
|
61
|
+
? -1
|
|
62
|
+
: options.options.findIndex((option) => option.value === options.initialValue);
|
|
63
|
+
let selectedIndex = initialIndex === -1 ? 0 : initialIndex;
|
|
64
|
+
let renderedLineCount = 0;
|
|
65
|
+
const renderMenu = () => {
|
|
66
|
+
if (renderedLineCount > 0) {
|
|
67
|
+
writableOutput.write(`\u001B[${renderedLineCount}A${CLEAR_MENU_SEQUENCE}`);
|
|
68
|
+
}
|
|
69
|
+
const lines = [
|
|
70
|
+
options.message,
|
|
71
|
+
"Use Up/Down to choose, Enter to confirm, or q/Esc/Ctrl+C to cancel.",
|
|
72
|
+
...options.options.map((option, index) => {
|
|
73
|
+
const prefix = index === selectedIndex ? ">" : " ";
|
|
74
|
+
const description = option.description == null || option.description.length === 0
|
|
75
|
+
? ""
|
|
76
|
+
: ` - ${option.description}`;
|
|
77
|
+
return `${prefix} ${option.label}${description}`;
|
|
78
|
+
}),
|
|
79
|
+
];
|
|
80
|
+
if (options.footer != null && options.footer.length > 0) {
|
|
81
|
+
lines.push(options.footer);
|
|
82
|
+
}
|
|
83
|
+
const rendered = `${lines.join("\n")}\n`;
|
|
84
|
+
renderedLineCount = countRenderedLines(rendered);
|
|
85
|
+
writableOutput.write(rendered);
|
|
86
|
+
};
|
|
87
|
+
return await new Promise((resolve, reject) => {
|
|
88
|
+
const finish = (handler) => {
|
|
89
|
+
readableInput.off("data", onData);
|
|
90
|
+
readableInput.setRawMode(false);
|
|
91
|
+
readableInput.pause?.();
|
|
92
|
+
writableOutput.write("\n");
|
|
93
|
+
handler();
|
|
94
|
+
};
|
|
95
|
+
const onData = (chunk) => {
|
|
96
|
+
const value = Buffer.isBuffer(chunk) ? chunk.toString("utf8") : chunk;
|
|
97
|
+
switch (value) {
|
|
98
|
+
case "\u001B[A":
|
|
99
|
+
selectedIndex = selectedIndex === 0 ? options.options.length - 1 : selectedIndex - 1;
|
|
100
|
+
renderMenu();
|
|
101
|
+
return;
|
|
102
|
+
case "\u001B[B":
|
|
103
|
+
selectedIndex = selectedIndex === options.options.length - 1 ? 0 : selectedIndex + 1;
|
|
104
|
+
renderMenu();
|
|
105
|
+
return;
|
|
106
|
+
case "\r":
|
|
107
|
+
case "\n":
|
|
108
|
+
finish(() => resolve(options.options[selectedIndex].value));
|
|
109
|
+
return;
|
|
110
|
+
case "\u001B":
|
|
111
|
+
case "\u0003":
|
|
112
|
+
case "q":
|
|
113
|
+
case "Q":
|
|
114
|
+
finish(() => reject(new Error("mining_setup_canceled")));
|
|
115
|
+
return;
|
|
116
|
+
default:
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
readableInput.setRawMode(true);
|
|
121
|
+
readableInput.resume?.();
|
|
122
|
+
readableInput.on("data", onData);
|
|
123
|
+
renderMenu();
|
|
124
|
+
});
|
|
125
|
+
};
|
|
23
126
|
return {
|
|
24
127
|
isInteractive: Boolean(input.isTTY && output.isTTY),
|
|
25
128
|
writeLine(message) {
|
|
@@ -44,6 +147,12 @@ export function createTerminalPrompter(input, output) {
|
|
|
44
147
|
output.write("\n");
|
|
45
148
|
}
|
|
46
149
|
},
|
|
150
|
+
async selectOption(options) {
|
|
151
|
+
if (!supportsRawSelection()) {
|
|
152
|
+
return await promptSelectionFallback(options);
|
|
153
|
+
}
|
|
154
|
+
return await promptSelectionRaw(options);
|
|
155
|
+
},
|
|
47
156
|
clearSensitiveDisplay(scope) {
|
|
48
157
|
if (!input.isTTY || !output.isTTY) {
|
|
49
158
|
return;
|
package/dist/cli/read-json.d.ts
CHANGED
|
@@ -114,6 +114,19 @@ export declare function buildMineStatusJson(mining: MiningControlPlaneView): Rea
|
|
|
114
114
|
phase: string;
|
|
115
115
|
lastSuspendDetectedAtUnixMs: number | null;
|
|
116
116
|
pauseReason: string | null;
|
|
117
|
+
providerState: string | null;
|
|
118
|
+
provider: {
|
|
119
|
+
configured: boolean;
|
|
120
|
+
kind: string | null;
|
|
121
|
+
modelId: string | null;
|
|
122
|
+
effectiveModel: string | null;
|
|
123
|
+
modelOverride: string | null;
|
|
124
|
+
modelSelectionSource: string | null;
|
|
125
|
+
usingDefaultModel: boolean | null;
|
|
126
|
+
extraPromptConfigured: boolean;
|
|
127
|
+
estimatedDailyCostUsd: number | null;
|
|
128
|
+
estimatedDailyCostDisplay: string | null;
|
|
129
|
+
};
|
|
117
130
|
fees: Record<string, unknown>;
|
|
118
131
|
worker: Record<string, unknown>;
|
|
119
132
|
availability: Record<string, JsonAvailabilityEntry>;
|
package/dist/cli/read-json.js
CHANGED
|
@@ -288,6 +288,18 @@ function buildMiningStatusData(mining) {
|
|
|
288
288
|
phase: mining.runtime.currentPhase,
|
|
289
289
|
lastSuspendDetectedAtUnixMs: mining.runtime.lastSuspendDetectedAtUnixMs,
|
|
290
290
|
pauseReason: mining.runtime.pauseReason,
|
|
291
|
+
provider: {
|
|
292
|
+
configured: mining.provider.configured,
|
|
293
|
+
kind: mining.provider.provider,
|
|
294
|
+
modelId: mining.provider.modelId,
|
|
295
|
+
effectiveModel: mining.provider.effectiveModel,
|
|
296
|
+
modelOverride: mining.provider.modelOverride,
|
|
297
|
+
modelSelectionSource: mining.provider.modelSelectionSource,
|
|
298
|
+
usingDefaultModel: mining.provider.usingDefaultModel,
|
|
299
|
+
extraPromptConfigured: mining.provider.extraPromptConfigured,
|
|
300
|
+
estimatedDailyCostUsd: mining.provider.estimatedDailyCostUsd,
|
|
301
|
+
estimatedDailyCostDisplay: mining.provider.estimatedDailyCostDisplay,
|
|
302
|
+
},
|
|
291
303
|
providerState: mining.runtime.providerState,
|
|
292
304
|
tipsAligned: mining.runtime.tipsAligned,
|
|
293
305
|
sameDomainCompetitorSuppressed: mining.runtime.sameDomainCompetitorSuppressed,
|
|
@@ -393,6 +405,11 @@ export function buildMineStatusJson(mining) {
|
|
|
393
405
|
if (mining.runtime.miningState === "repair-required") {
|
|
394
406
|
nextSteps.push("Run `cogcoin repair` before mining again.");
|
|
395
407
|
}
|
|
408
|
+
else if (mining.runtime.providerState === "not-found") {
|
|
409
|
+
nextSteps.push(mining.provider.usingDefaultModel === false
|
|
410
|
+
? "Run `cogcoin mine setup` and clear or correct the provider model."
|
|
411
|
+
: "Run `cogcoin mine setup` and choose a valid provider model.");
|
|
412
|
+
}
|
|
396
413
|
else if (mining.runtime.pauseReason === "zero-reward") {
|
|
397
414
|
nextSteps.push("Wait for the next positive-reward target height; mining resumes automatically.");
|
|
398
415
|
}
|
package/dist/cli/runner.js
CHANGED
|
@@ -10,6 +10,7 @@ import { runMiningRuntimeCommand } from "./commands/mining-runtime.js";
|
|
|
10
10
|
import { runServiceRuntimeCommand } from "./commands/service-runtime.js";
|
|
11
11
|
import { runStatusCommand } from "./commands/status.js";
|
|
12
12
|
import { runSyncCommand } from "./commands/sync.js";
|
|
13
|
+
import { runUpdateCommand } from "./commands/update.js";
|
|
13
14
|
import { runWalletAdminCommand } from "./commands/wallet-admin.js";
|
|
14
15
|
import { runWalletMutationCommand } from "./commands/wallet-mutation.js";
|
|
15
16
|
import { runWalletReadCommand } from "./commands/wallet-read.js";
|
|
@@ -52,6 +53,9 @@ export async function runCli(argv, contextOverrides = {}) {
|
|
|
52
53
|
}
|
|
53
54
|
await maybeNotifyAboutCliUpdate(parsed, context);
|
|
54
55
|
try {
|
|
56
|
+
if (parsed.command === "update") {
|
|
57
|
+
return runUpdateCommand(parsed, context);
|
|
58
|
+
}
|
|
55
59
|
if (commandUsesExistingWalletSeed(parsed)) {
|
|
56
60
|
const mainPaths = context.resolveWalletRuntimePaths("main");
|
|
57
61
|
const seedIndex = await loadWalletSeedIndex({
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ManagedBitcoindProgressEvent } from "../bitcoind/types.js";
|
|
2
|
+
import type { ParsedCliArgs } from "./types.js";
|
|
3
|
+
export declare function createSyncProgressReporter(options: {
|
|
4
|
+
progressOutput: ParsedCliArgs["progressOutput"];
|
|
5
|
+
write: (line: string) => void;
|
|
6
|
+
}): (event: ManagedBitcoindProgressEvent) => void;
|